X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fmusashi%2Fm68kcpu.c;h=7564c116df2dcd006da82965981570f35ef0cb4c;hb=d5715559cf1bc112e4a879b4c9e6f3a4272fc5cf;hp=b3cd36db2e95fcb5382583b6e4f9fb5f44785cc6;hpb=cc68a136aa179a5f32fe40208371eb9c2b0aadae;p=picodrive.git diff --git a/cpu/musashi/m68kcpu.c b/cpu/musashi/m68kcpu.c index b3cd36d..7564c11 100644 --- a/cpu/musashi/m68kcpu.c +++ b/cpu/musashi/m68kcpu.c @@ -5,9 +5,9 @@ #if 0 static const char* copyright_notice = "MUSASHI\n" -"Version 3.3 (2001-01-29)\n" +"Version 3.31 (2007-07-09)\n" "A portable Motorola M680x0 processor emulation engine.\n" -"Copyright 1998-2001 Karl Stenerud. All rights reserved.\n" +"Copyright 1998-2007 Karl Stenerud. All rights reserved.\n" "\n" "This code may be freely used for non-commercial purpooses as long as this\n" "copyright notice remains unaltered in the source code and any binary files\n" @@ -32,15 +32,19 @@ static const char* copyright_notice = /* ================================ INCLUDES ============================== */ /* ======================================================================== */ +extern void m68040_fpu_op0(void); +extern void m68040_fpu_op1(void); + #include "m68kops.h" #include "m68kcpu.h" +//#include "m68kfpu.c" /* ======================================================================== */ /* ================================= DATA ================================= */ /* ======================================================================== */ int m68ki_initial_cycles; -int m68ki_remaining_cycles = 0; /* Number of clocks remaining */ +//int m68ki_remaining_cycles = 0; /* Number of clocks remaining */ uint m68ki_tracing = 0; uint m68ki_address_space; @@ -68,8 +72,9 @@ const char* m68ki_cpu_names[] = #endif /* M68K_LOG_ENABLE */ /* The CPU core */ -// m68ki_cpu_core m68ki_cpu = {0}; +// notaz m68ki_cpu_core *m68ki_cpu_p = NULL; +//m68ki_cpu_core m68ki_cpu = {0}; #if M68K_EMULATE_ADDRESS_ERROR @@ -477,6 +482,12 @@ static void default_rte_instr_callback(void) { } +/* Called when a tas instruction is executed */ +static int default_tas_instr_callback(void) +{ + return 1; // allow writeback +} + /* Called when the program counter changed by a large value */ static unsigned int default_pc_changed_callback_data; static void default_pc_changed_callback(unsigned int new_pc) @@ -647,6 +658,11 @@ void m68k_set_rte_instr_callback(void (*callback)(void)) CALLBACK_RTE_INSTR = callback ? callback : default_rte_instr_callback; } +void m68k_set_tas_instr_callback(int (*callback)(void)) +{ + CALLBACK_TAS_INSTR = callback ? callback : default_tas_instr_callback; +} + void m68k_set_pc_changed_callback(void (*callback)(unsigned int new_pc)) { CALLBACK_PC_CHANGED = callback ? callback : default_pc_changed_callback; @@ -774,6 +790,9 @@ int m68k_execute(int num_cycles) /* Make sure we're not stopped */ if(!CPU_STOPPED) { + // notaz + m68ki_check_interrupts(); + /* Set our pool of clock cycles available */ SET_CYCLES(num_cycles); m68ki_initial_cycles = num_cycles; @@ -786,10 +805,14 @@ int m68k_execute(int num_cycles) m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */ /* Main loop. Keep going until we run out of clock cycles */ - while(GET_CYCLES() > 0) + // notaz + m68ki_trace_t1(); + + while(GET_CYCLES() >= 0) +// do { /* Set tracing accodring to T1. (T0 is done inside instruction) */ - m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */ + //m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */ /* Set the address space for reads */ m68ki_use_data_space(); /* auto-disable (see m68kcpu.h) */ @@ -802,12 +825,14 @@ int m68k_execute(int num_cycles) /* Read an instruction and call its handler */ REG_IR = m68ki_read_imm_16(); + USE_CYCLES(CYC_INSTRUCTION[REG_IR]); // notaz m68ki_instruction_jump_table[REG_IR](); - USE_CYCLES(CYC_INSTRUCTION[REG_IR]); /* Trace m68k_exception, if necessary */ m68ki_exception_if_trace(); /* auto-disable (see m68kcpu.h) */ - } + + m68ki_trace_t1(); /* notaz */ + } // while(GET_CYCLES() > 0); // notaz /* set previous PC to current PC for the next entry into the loop */ REG_PPC = REG_PC; @@ -886,6 +911,7 @@ void m68k_init(void) m68k_set_reset_instr_callback(NULL); m68k_set_cmpild_instr_callback(NULL); m68k_set_rte_instr_callback(NULL); + m68k_set_tas_instr_callback(NULL); m68k_set_pc_changed_callback(NULL); m68k_set_fc_callback(NULL); m68k_set_instr_hook_callback(NULL); @@ -939,17 +965,17 @@ unsigned int m68k_context_size() return sizeof(m68ki_cpu_core); } -/* unsigned int m68k_get_context(void* dst) { if(dst) *(m68ki_cpu_core*)dst = m68ki_cpu; return sizeof(m68ki_cpu_core); } -*/ void m68k_set_context(void* src) { + // notaz if(src) m68ki_cpu_p = src; +// if(src) m68ki_cpu = *(m68ki_cpu_core*)src; } @@ -960,8 +986,6 @@ void m68k_set_context(void* src) #if M68K_COMPILE_FOR_MAME == OPT_ON -#include "state.h" - static struct { UINT16 sr; UINT8 stopped;