]> git.sesse.net Git - pistorm/commitdiff
step 1: add a state parameter to all opcode functions
authorRune Holm <rune.holm@gmail.com>
Sun, 20 Jun 2021 16:12:09 +0000 (18:12 +0200)
committerRune Holm <rune.holm@gmail.com>
Sun, 20 Jun 2021 19:50:15 +0000 (21:50 +0200)
m68k_in.c
m68kcpu.c
m68kcpu.h
m68kmake.c

index ec2614fb48e84a5c133defa5d21257ed65dcd189..cb5190e4a06255a38d733120b7796d767cbd29ec 100644 (file)
--- 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 */
index b91be0a0b37ebf196d1c2726584f45b5206b9d5c..fb666093618135572d4ddcc914343e5e6bddd0b5 100644 (file)
--- 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 */
index b5b919745217c2837c88a73d6cd9421f4de5c1fa..e93c3d4a04703f259e3dea05f8901ddcb0c3610a 100644 (file)
--- 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 */
index adadc36952bd6a2e9414adf21187620abf828c0f..3e5a5c142c3efbdd8f08ab4252da2b5c5bfef731 100644 (file)
@@ -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)