    ===================
    ec64 - emulated C64
    ===================


Maintainer:   Karsten Scheibler (aka nic and _nitro)
Homepage:     <http://mars.wiwi.uni-halle.de/ec64/>
Comments to:  <ec64@mars.wiwi.uni-halle.de>


Ok some words to the emulator itself. I decided to do it in Assembly
because:

1) I wanted to learn more about Assembly under Linux
2) it's fast

If you look in src/ you will see the directories console/ and player/,
which are empty at the moment. All pathnames from now on are relative to
src/emulator/.

If you want to know more about x86-Assembly under Linux surf to:
<http://lightning.voshod.com/asm/> or to a mirror, for example:
<http://mars.wiwi.uni-halle.de/asm/>

If you start ec64 the program control will be passed to main_start in
core/main.nasm. First all emulation modules becomes initialized. Then
commandline is parsed for a filename. After that the reset procedure of
the modules are called, the difference between initialize and reset: Some
modules are used twice (cpu65xx, cia6526, via6522), the initialize sets
some values on the module itself (if needed) and the reset creates an
instance of the module. So i can emulate the 6502 CPU in the VC1541 and
the 6510 CPU in the C64 with the same programcode, only the data differs.
I use the esi register for the cpu emulation to point to the data and for
via and cia i use the edi register.

The next thing being processing is the clock_cycle_loop in which every
clock cycle of VC1541 and C64 becomes emulated. Notice that the Floppy has
a slighty different Clock from the C64, it has a little bit higher clock
rate. In the clock_cycle_loop the different cycle functions from every
emulation Module are called. One common practice in all modules is to do a
call [pointer]. I will demontrate the advantage of this on the NOP
Instruction of the CPU. In the first cycle the pointer in call [pointer]
points to get_opcode, which reads the opcode from memory at the actual
Programcounter and does some decoding (finding the address from the code
snippet which processes this opcode and write it to pointer). The next
call [pointer] now jumps to the code snippet which emulates the NOP Opcode
at Cycle 2 (which does nothing ;-), loads the address of get_opcode to the
pointer and exits. All Opcodes are emulated like this of course with more
cycles or some more action. This method of emulating every clock cycle
is also used in ather modules.

If you wondering about some variable names like p__cpu_execute_opcode: i
use before every variable a one character-type-identifier followed by two
underscores:

b	byte
w	word
d	dword
q	quadword
p	pointer

sw	signed word

ad	array of dword
cb	chain of bytes (mostly null terminated strings)
