joriszwart.nl

I code dreams™

Emulation

Introduction

C64JS is a Commodore 64 emulator written in JavaScript. It learned me a lot about emulation of CPU, Video (VIC-II) and Audio (SID) and other stuff (Disk format/file system, Input/Output, keyboard handling) and about performance coding in JavaScript. And that emulation is boring :-)

There is almost no keyboard support yet, but you can use the buttons to load some test programs.

You need something modern than your C=64 to emulate a C=64!
Log messages

The red ones are very buggy and crash the emulator. Also you may need to refresh the page because a 'hard reset' doesn't reset everything.

It is far from finished, but other individual parts have been written:

Version history

VersionDate
0.0.0.15 January 2014Initial version. Runs test1.prg, test2.prg, test3.prg succesfully!
0.0.0.26 January 2014Loads KERNAL, BASIC and CHARGEN. But ends up in a loop due to no VIC (KERNAL does initialize $d012 to some non-zero value and later on $d012; BNE *-3 :-). Fixed by initializing $d012 to zero.
0.0.0.38 January 2014Runs KERNAL, BASIC and crashes.
0.0.0.413 January 2014Still crashes due to wrong instruction decoding (probably). Added rudimentary disassembler and debugger.
0.0.0.516 January 2014Added preliminary VIC-II emulation. Textmodus only.
Kernal still ends up in an endless loop though :-(
0.0.0.620 January 2014Added preliminary SID emulation.
Kernal still looping :-( Suspect is that ADC / SBC do not set the overflow-flag correctly and cause an incorrect branch (BVS)
0.0.0.727 January 2014[Branch] .D64 support
0.0.0.828 January 2014[Branch] Start writing unit tests for 6510.
0.0.0.929 January 2014KERNAL loop was caused by BEQ not branching on Z = 1, but on Z = 0 :s. Another KERNAL loop was caused by initializing I/O (but there is no I/O yet). Patched up KERNAL for now. Added missing opcodes.
0.0.1.029 January 2014Prints BASIC startup message! Compare instructions did not handle C-flag very well (reversed logic). Added a bunch of opcodes. BASIC BYTES FREE is incorrect though ('H26439.4215').
0.0.1.130 January 2014Rudimentary keyboard and CIA timer implementation, enough to call timer IRQ and thus show a blinking cursor and waiting for input \o/ Every command yields a syntax error though.
Also known as IFYOUREHAPPYANDYOUKNOWITSYNTAXERROR-version.
0.0.1.26 February 2014Fixed some carry- and overflow-flag bugs. Is able to execute BASIC programs, but bugs when doing calculations. PRINT 10 yields 0.00000128 :-)
0.0.1.38 February 2014[Branch] minor work on VIC-II emulation; timings, colors and XSCROLL ($d016)
0.0.1.49 February 2014Fixed a lot of ASL, LSR, ROR and ROL bugs (mostly carry-flag related), wrong addressing modes etc. CPU emulation is at ~90% now. Lacks BCD-mode (Binary-coded decimal) and illegal opcodes.
ART.BAS other BASIC programs run fine. BASIC BYTES FREE is better now, but still wrong ('51216') because all memory is writable and memory test sees $d011 as highest non-writable address :-) Hence $d011 - $0801 = 51216!
Performance in Firefox degraded badly :-(
0.0.1.510 February 2014VIC-II emulation: implemented HIRES mode ($d011, bit 5). Runs HIRES.BAS, hairline-monochrome.prg and last but not least: MATRIX.PRG!
0.0.1.627 February 2014Implemented basic memory manager for I/O-traps.
0.0.1.7? February 2014[Branch] Improved keyboard emulation; all keys on a regular C=64 are supported now.