X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=hacks%2Fasm6502.h;h=79b13a2b0144b0c9e1337370b3591358ec989a3c;hb=6f5482d73adb0165c0130bb47d852644ab0c4869;hp=bd7e79ca4b08db641b9c1f2aa41883f8cea4914f;hpb=c8c6deae79b408cffbc88043c766b3bc12cf0f13;p=xscreensaver diff --git a/hacks/asm6502.h b/hacks/asm6502.h index bd7e79ca..79b13a2b 100644 --- a/hacks/asm6502.h +++ b/hacks/asm6502.h @@ -46,7 +46,8 @@ enum { MAX_CMD_LEN = 4, /* Each assembly command is 3 characeters long */ /* The stack works from the top down in page $100 to $1ff */ STACK_TOP = 0x1ff, - STACK_BOTTOM = 0x100 + STACK_BOTTOM = 0x100, + PROG_START = 0x600 /* The default entry point for the program */ }; typedef enum{ @@ -55,7 +56,7 @@ typedef enum{ ZERO, ZERO_X, ZERO_Y, ABS_VALUE, ABS_OR_BRANCH, ABS_X, ABS_Y, ABS_LABEL_X, ABS_LABEL_Y, DCB_PARAM -} AddrMode; +} m6502_AddrMode; typedef struct machine_6502 machine_6502; @@ -72,14 +73,14 @@ typedef struct { Bit8 INDY; Bit8 SNGL; Bit8 BRA; - void (*func) (machine_6502*, AddrMode); -} Opcodes; + void (*func) (machine_6502*, m6502_AddrMode); +} m6502_Opcodes; /* Used to cache the index of each opcode */ typedef struct { Bit8 index; - AddrMode adm; -} OpcodeIndex; + m6502_AddrMode adm; +} m6502_OpcodeIndex; /* Plotter is a function that will be called everytime a pixel needs to be updated. The first two parameter are the x and y @@ -107,7 +108,7 @@ typedef struct { parameter. You can use this parameter to store state information. */ -typedef void (*Plotter) (Bit8, Bit8, Bit8, void*); +typedef void (*m6502_Plotter) (Bit8, Bit8, Bit8, void*); struct machine_6502 { BOOL codeCompiledOK; @@ -117,53 +118,64 @@ struct machine_6502 { Bit8 regP; Bit16 regPC; /* A pair of 8 bit registers */ Bit16 regSP; + Bit16 defaultCodePC; Bit8 memory[MEM_64K]; BOOL runForever; int labelPtr; BOOL codeRunning; int myInterval; - Opcodes opcodes[NUM_OPCODES]; + m6502_Opcodes opcodes[NUM_OPCODES]; int screen[32][32]; int codeLen; - OpcodeIndex opcache[0xff]; - Plotter plot; + m6502_OpcodeIndex opcache[0xff]; + m6502_Plotter plot; void *plotterState; }; /* build6502() - Creates an instance of the 6502 machine */ -machine_6502 *build6502(void); +machine_6502 *m6502_build(void); /* destroy6502() - compile the file and exectue it until the program is finished */ -void destroy6502(machine_6502 *machine); +void m6502_destroy6502(machine_6502 *machine); /* eval_file() - Compiles and runs a file until the program is finished */ -void eval_file(machine_6502 *machine, char *filename, - Plotter plot, void *plotterState); +void m6502_eval_file(machine_6502 *machine, const char *filename, + m6502_Plotter plot, void *plotterState); /* start_eval_file() - Compile the file and execute the first instruction */ -void start_eval_file(machine_6502 *machine, char *filename, - Plotter plot, void *plotterState); +void m6502_start_eval_file(machine_6502 *machine, const char *filename, + m6502_Plotter plot, void *plotterState); -void start_eval_binary(machine_6502 *machine, Bit8 *program, +/* XXX +void m6502_start_eval_binary(machine_6502 *machine, Bit8 *program, unsigned int proglen, Plotter plot, void *plotterState); +*/ + +void m6502_start_eval_string(machine_6502 *machine, const char *code, + m6502_Plotter plot, void *plotterState); /* next_eval() - Execute the next insno of machine instructions */ -void next_eval(machine_6502 *machine, int insno); +void m6502_next_eval(machine_6502 *machine, int insno); /* hexDump() - Dumps memory to output */ -void hexDump(machine_6502 *machine, Bit16 start, +void m6502_hexDump(machine_6502 *machine, Bit16 start, Bit16 numbytes, FILE *output); +/* Disassemble() - Prints the assembly code for the program currently + loaded in memory.*/ +void m6502_disassemble(machine_6502 *machine, FILE *output); + /* trace() - Prints to output the current value of registers, the current nmemonic, memory address and value. */ -void trace(machine_6502 *machine, FILE *output); +void m6502_trace(machine_6502 *machine, FILE *output); /* save_program() - Writes a binary file of the program loaded in memory. */ -void save_program(machine_6502 *machine, char *filename); - +/* XXX +void save_program(machine_6502 *machine, const char *filename); +*/ #endif /* __ASM6502_H__ */