Pointer-ified the SPC700.

This commit is contained in:
R. Belmont 2008-11-28 23:29:21 +00:00
parent 4c2953d8ef
commit fdc7c5b358
2 changed files with 395 additions and 475 deletions

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,38 @@ enum
#define SPC700_INT_IRQ 1
#define SPC700_INT_NMI 2
/* CPU Structure */
typedef struct
{
uint a; /* Accumulator */
uint x; /* Index Register X */
uint y; /* Index Register Y */
uint s; /* Stack Pointer */
uint pc; /* Program Counter */
uint ppc; /* Previous Program Counter */
uint flag_n; /* Negative Flag */
uint flag_z; /* Zero flag */
uint flag_v; /* Overflow Flag */
uint flag_p; /* Direct Page Flag */
uint flag_b; /* BRK Instruction Flag */
uint flag_h; /* Half-carry Flag */
uint flag_i; /* Interrupt Mask Flag */
uint flag_c; /* Carry Flag */
uint line_irq; /* Status of the IRQ line */
uint line_nmi; /* Status of the NMI line */
uint line_rst; /* Status of the RESET line */
uint ir; /* Instruction Register */
cpu_irq_callback int_ack;
const device_config *device;
const address_space *program;
uint stopped; /* stopped status */
int ICount;
uint source;
uint destination;
uint temp1, temp2, temp3;
short spc_int16;
int spc_int32;
} spc700i_cpu;
/* ======================================================================== */
@ -44,61 +76,47 @@ CPU_INIT( spc700 );
CPU_RESET( spc700 );
/* Set the RESET line on the CPU */
void spc700_set_reset_line(int state, void* param);
void spc700_set_reset_line(spc700i_cpu *cpustate, int state, void* param);
/* Clean up after the emulation core - Not used in this core - */
CPU_EXIT( spc700 );
/* Get the current CPU context */
unsigned spc700_get_context(void *dst);
/* Set the current CPU context */
CPU_SET_CONTEXT( spc700 );
/* Get the current Program Counter */
unsigned spc700_get_pc(void);
unsigned spc700_get_pc(spc700i_cpu *cpustate);
/* Set the current Program Counter */
void spc700_set_pc(unsigned val);
void spc700_set_pc(spc700i_cpu *cpustate,unsigned val);
/* Get the current Stack Pointer */
unsigned spc700_get_sp(void);
unsigned spc700_get_sp(spc700i_cpu *cpustate);
/* Set the current Stack Pointer */
void spc700_set_sp(unsigned val);
void spc700_set_sp(spc700i_cpu *cpustate,unsigned val);
/* Get a register from the core */
unsigned spc700_get_reg(int regnum);
unsigned spc700_get_reg(spc700i_cpu *cpustate,int regnum);
/* Set a register in the core */
void spc700_set_reg(int regnum, unsigned val);
void spc700_set_reg(spc700i_cpu *cpustate,int regnum, unsigned val);
/* Note about NMI:
* NMI is a one-shot trigger. In order to trigger NMI again, you must
* clear NMI and then assert it again.
*/
void spc700_set_nmi_line(int state);
void spc700_set_nmi_line(spc700i_cpu *cpustate,int state);
/* Assert or clear the IRQ pin */
void spc700_set_irq_line(int line, int state);
void spc700_set_irq_line(spc700i_cpu *cpustate,int line, int state);
/* Set the callback that will be called when an interrupt is serviced */
void spc700_set_irq_callback(cpu_irq_callback callback);
/* Save the current CPU state to disk */
void spc700_state_save(void *file);
/* Load a CPU state from disk */
void spc700_state_load(void *file);
void spc700_set_irq_callback(spc700i_cpu *cpustate,cpu_irq_callback callback);
/* Get a formatted string representing a register and its contents */
const char *spc700_info(void *context, int regnum);
const char *spc700_info(spc700i_cpu *cpustate,void *context, int regnum);
/* Pulse the SO (Set Overflow) pin on the CPU */
void spc700_pulse_so(void);
int spc700_execute(int clocks);
void spc700_pulse_so(spc700i_cpu *cpustate);
/* ======================================================================== */
@ -132,15 +150,15 @@ void spc700_branching(unsigned int new_pc);
extern CPU_GET_INFO( spc700 );
#define spc700_read_8(addr) memory_read_byte_8le(spc700i_cpu.program,addr)
#define spc700_write_8(addr,data) memory_write_byte_8le(spc700i_cpu.program,addr,data)
#define spc700_read_8(addr) memory_read_byte_8le(cpustate->program,addr)
#define spc700_write_8(addr,data) memory_write_byte_8le(cpustate->program,addr,data)
#define spc700_read_8_direct(A) spc700_read_8(A)
#define spc700_write_8_direct(A, V) spc700_write_8(A, V)
//#define spc700_read_instruction(A) memory_decrypted_read_byte(spc700i_cpu.program,A)
//#define spc700_read_8_immediate(A) memory_raw_read_byte(spc700i_cpu.program,A)
#define spc700_read_instruction(A) memory_read_byte_8le(spc700i_cpu.program,A)
#define spc700_read_8_immediate(A) memory_read_byte_8le(spc700i_cpu.program,A)
//#define spc700_read_instruction(A) memory_decrypted_read_byte(cpustate->program,A)
//#define spc700_read_8_immediate(A) memory_raw_read_byte(cpustate->program,A)
#define spc700_read_instruction(A) memory_read_byte_8le(cpustate->program,A)
#define spc700_read_8_immediate(A) memory_read_byte_8le(cpustate->program,A)
#define spc700_jumping(A)
#define spc700_branching(A)