From: Rune Holm Date: Sun, 20 Jun 2021 16:12:09 +0000 (+0200) Subject: step 1: add a state parameter to all opcode functions X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=18cba7ddc6d8b268f5749bf3ba8cf3cbd0d226b2;p=pistorm step 1: add a state parameter to all opcode functions --- diff --git a/m68k_in.c b/m68k_in.c index ec2614f..cb5190e 100644 --- a/m68k_in.c +++ b/m68k_in.c @@ -112,7 +112,9 @@ M68KMAKE_PROTOTYPE_FOOTER /* Build the opcode handler table */ void m68ki_build_opcode_table(void); -extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ +struct m68ki_cpu_core; + +extern void (*m68ki_instruction_jump_table[0x10000])(struct m68ki_cpu_core *state); /* opcode handler jump table */ extern unsigned char m68ki_cycles[][0x10000]; @@ -136,13 +138,13 @@ M68KMAKE_TABLE_HEADER #define NUM_CPU_TYPES 5 -void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ +void (*m68ki_instruction_jump_table[0x10000])(m68ki_cpu_core *state); /* opcode handler jump table */ unsigned char m68ki_cycles[NUM_CPU_TYPES][0x10000]; /* Cycles used by CPU type */ /* This is used to generate the opcode handler jump table */ typedef struct { - void (*opcode_handler)(void); /* handler function */ + void (*opcode_handler)(m68ki_cpu_core *state); /* handler function */ unsigned int mask; /* mask on opcode */ unsigned int match; /* what to match after masking */ unsigned char cycles[NUM_CPU_TYPES]; /* cycles each cpu type takes */ diff --git a/m68kcpu.c b/m68kcpu.c index b91be0a..fb66609 100644 --- a/m68kcpu.c +++ b/m68kcpu.c @@ -42,7 +42,6 @@ extern void m68040_fpu_op0(void); extern void m68040_fpu_op1(void); extern void m68851_mmu_ops(); extern unsigned char m68ki_cycles[][0x10000]; -extern void (*m68ki_instruction_jump_table[0x10000])(void); /* opcode handler jump table */ extern void m68ki_build_opcode_table(void); #include "m68kops.h" @@ -1012,7 +1011,7 @@ int m68k_execute(int num_cycles) /* Read an instruction and call its handler */ REG_IR = m68ki_read_imm_16(); - m68ki_instruction_jump_table[REG_IR](); + m68ki_instruction_jump_table[REG_IR](&m68ki_cpu); USE_CYCLES(CYC_INSTRUCTION[REG_IR]); /* Trace m68k_exception, if necessary */ diff --git a/m68kcpu.h b/m68kcpu.h index b5b9197..e93c3d4 100644 --- a/m68kcpu.h +++ b/m68kcpu.h @@ -946,7 +946,7 @@ typedef struct -typedef struct +typedef struct m68ki_cpu_core { uint cpu_type; /* CPU Type: 68000, 68008, 68010, 68EC020, 68020, 68EC030, 68030, 68EC040, or 68040 */ uint dar[16]; /* Data and Address Registers */ diff --git a/m68kmake.c b/m68kmake.c index adadc36..3e5a5c1 100644 --- a/m68kmake.c +++ b/m68kmake.c @@ -785,7 +785,7 @@ void get_base_name(char* base_name, opcode_struct* op) /* Write the name of an opcode handler function */ void write_function_name(FILE* filep, char* base_name) { - fprintf(filep, "static void %s(void)\n", base_name); + fprintf(filep, "static void %s(m68ki_cpu_core *state)\n", base_name); } void add_opcode_output_table_entry(opcode_struct* op, char* name)