X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fmusashi%2Fm68kcpu.h;h=63055cbe23f64c4a962c9a1799c13fe78b0ea05f;hb=9db6a54485501b56b0f2f5db4d093c38fe495bda;hp=88855956248e8b45410a58bb3c4308f91959befe;hpb=cc68a136aa179a5f32fe40208371eb9c2b0aadae;p=picodrive.git diff --git a/cpu/musashi/m68kcpu.h b/cpu/musashi/m68kcpu.h index 8885595..63055cb 100644 --- a/cpu/musashi/m68kcpu.h +++ b/cpu/musashi/m68kcpu.h @@ -4,10 +4,10 @@ /* ======================================================================== */ /* * MUSASHI - * Version 3.3 + * Version 3.31 * * A portable Motorola M680x0 processor emulation engine. - * Copyright 1998-2001 Karl Stenerud. All rights reserved. + * Copyright 1998-2007 Karl Stenerud. All rights reserved. * * This code may be freely used for non-commercial purposes as long as this * copyright notice remains unaltered in the source code and any binary files @@ -27,6 +27,9 @@ #define M68KCPU__HEADER // notaz: something's missing this +#ifndef UINT64 +#define UINT64 unsigned long long +#endif #ifndef UINT16 #define UINT32 unsigned int #define UINT16 unsigned short @@ -65,10 +68,10 @@ #define sint8 signed char /* ASG: changed from char to signed char */ #define sint16 signed short -#define sint32 signed long +#define sint32 signed int /* AWJ: changed from long to int */ #define uint8 unsigned char #define uint16 unsigned short -#define uint32 unsigned long +#define uint32 unsigned int /* AWJ: changed from long to int */ /* signed and unsigned int must be at least 32 bits wide */ #define sint signed int @@ -116,7 +119,7 @@ /* Allow for architectures that don't have 32-bit sizes */ -#if ULONG_MAX == 0xffffffff +#if UINT_MAX == 0xffffffff #define MAKE_INT_32(A) (sint32)(A) #else #undef sint32 @@ -127,13 +130,8 @@ { return (value & 0x80000000) ? value | ~0xffffffff : value & 0xffffffff; } -#endif /* ULONG_MAX == 0xffffffff */ +#endif /* UINT_MAX == 0xffffffff */ -// notaz -INLINE sint32 MAKE_INT_24(uint value) -{ - return (value & 0x800000) ? value | ~0xffffff : value & 0xffffff; -} @@ -328,6 +326,11 @@ INLINE sint32 MAKE_INT_24(uint value) #define REG_CAAR m68ki_cpu.caar #define REG_IR m68ki_cpu.ir +#define REG_FP m68ki_cpu.fpr +#define REG_FPCR m68ki_cpu.fpcr +#define REG_FPSR m68ki_cpu.fpsr +#define REG_FPIAR m68ki_cpu.fpiar + #define FLAG_T1 m68ki_cpu.t1_flag #define FLAG_T0 m68ki_cpu.t0_flag #define FLAG_S m68ki_cpu.s_flag @@ -367,6 +370,7 @@ INLINE sint32 MAKE_INT_24(uint value) #define CALLBACK_RESET_INSTR m68ki_cpu.reset_instr_callback #define CALLBACK_CMPILD_INSTR m68ki_cpu.cmpild_instr_callback #define CALLBACK_RTE_INSTR m68ki_cpu.rte_instr_callback +#define CALLBACK_TAS_INSTR m68ki_cpu.tas_instr_callback #define CALLBACK_PC_CHANGED m68ki_cpu.pc_changed_callback #define CALLBACK_SET_FC m68ki_cpu.set_fc_callback #define CALLBACK_INSTR_HOOK m68ki_cpu.instr_hook_callback @@ -487,6 +491,17 @@ INLINE sint32 MAKE_INT_24(uint value) #define m68ki_rte_callback() #endif /* M68K_RTE_HAS_CALLBACK */ +#if M68K_TAS_HAS_CALLBACK + #if M68K_TAS_HAS_CALLBACK == OPT_SPECIFY_HANDLER + #define m68ki_tas_callback() M68K_TAS_CALLBACK() + #else + #define m68ki_tas_callback() CALLBACK_TAS_INSTR() + #endif +#else + #define m68ki_tas_callback() +#endif /* M68K_TAS_HAS_CALLBACK */ + + #if M68K_INSTRUCTION_HOOK #if M68K_INSTRUCTION_HOOK == OPT_SPECIFY_HANDLER #define m68ki_instr_hook() M68K_INSTRUCTION_CALLBACK() @@ -835,6 +850,12 @@ INLINE sint32 MAKE_INT_24(uint value) /* =============================== PROTOTYPES ============================= */ /* ======================================================================== */ +typedef union +{ + UINT64 i; + double f; +} fp_reg; + typedef struct { uint cpu_type; /* CPU Type: 68000, 68008, 68010, 68EC020, or 68020 */ @@ -848,6 +869,10 @@ typedef struct uint cacr; /* Cache Control Register (m68020, unemulated) */ uint caar; /* Cache Address Register (m68020, unemulated) */ uint ir; /* Instruction Register */ + fp_reg fpr[8]; /* FPU Data Register (m68040) */ + uint fpiar; /* FPU Instruction Address Register (m68040) */ + uint fpsr; /* FPU Status Register (m68040) */ + uint fpcr; /* FPU Control Register (m68040) */ uint t1_flag; /* Trace 1 */ uint t0_flag; /* Trace 0 */ uint s_flag; /* Supervisor */ @@ -887,17 +912,24 @@ typedef struct void (*reset_instr_callback)(void); /* Called when a RESET instruction is encountered */ void (*cmpild_instr_callback)(unsigned int, int); /* Called when a CMPI.L #v, Dn instruction is encountered */ void (*rte_instr_callback)(void); /* Called when a RTE instruction is encountered */ + int (*tas_instr_callback)(void); /* Called when a TAS instruction is encountered, allows / disallows writeback */ void (*pc_changed_callback)(unsigned int new_pc); /* Called when the PC changes by a large amount */ void (*set_fc_callback)(unsigned int new_fc); /* Called when the CPU function code changes */ void (*instr_hook_callback)(void); /* Called every instruction cycle prior to execution */ + // notaz + sint cyc_remaining_cycles; + sint not_polling; } m68ki_cpu_core; - +// notaz extern m68ki_cpu_core *m68ki_cpu_p; -#define m68ki_cpu (*m68ki_cpu_p) // test +#define m68ki_cpu (*m68ki_cpu_p) +#define m68ki_remaining_cycles m68ki_cpu_p->cyc_remaining_cycles -extern sint m68ki_remaining_cycles; + +//extern m68ki_cpu_core m68ki_cpu; +//extern sint m68ki_remaining_cycles; extern uint m68ki_tracing; extern uint8 m68ki_shift_8_table[]; extern uint16 m68ki_shift_16_table[]; @@ -1505,7 +1537,8 @@ INLINE void m68ki_set_sr_noint_nosp(uint value) INLINE void m68ki_set_sr(uint value) { m68ki_set_sr_noint(value); - m68ki_check_interrupts(); + if (GET_CYCLES() >= 0) // notaz + m68ki_check_interrupts(); } @@ -1590,7 +1623,7 @@ INLINE void m68ki_stack_frame_buserr(uint sr) /* Format 8 stack frame (68010). * 68010 only. This is the 29 word bus/address error frame. */ -void m68ki_stack_frame_1000(uint pc, uint sr, uint vector) +INLINE void m68ki_stack_frame_1000(uint pc, uint sr, uint vector) { /* VERSION * NUMBER @@ -1644,7 +1677,7 @@ void m68ki_stack_frame_1000(uint pc, uint sr, uint vector) * if the error happens at an instruction boundary. * PC stacked is address of next instruction. */ -void m68ki_stack_frame_1010(uint sr, uint vector, uint pc) +INLINE void m68ki_stack_frame_1010(uint sr, uint vector, uint pc) { /* INTERNAL REGISTER */ m68ki_push_16(0); @@ -1691,7 +1724,7 @@ void m68ki_stack_frame_1010(uint sr, uint vector, uint pc) * if the error happens during instruction execution. * PC stacked is address of instruction in progress. */ -void m68ki_stack_frame_1011(uint sr, uint vector, uint pc) +INLINE void m68ki_stack_frame_1011(uint sr, uint vector, uint pc) { /* INTERNAL REGISTERS (18 words) */ m68ki_push_32(0); @@ -1933,8 +1966,9 @@ m68k_read_memory_8(0x00ffff01); USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ADDRESS_ERROR] - CYC_INSTRUCTION[REG_IR]); } + /* Service an interrupt request and start exception processing */ -void m68ki_exception_interrupt(uint int_level) +INLINE void m68ki_exception_interrupt(uint int_level) { uint vector; uint sr; @@ -1979,6 +2013,7 @@ void m68ki_exception_interrupt(uint int_level) /* Get the new PC */ new_pc = m68ki_read_data_32((vector<<2) + REG_VBR); + //new_pc = m68k_read_immediate_32((vector<<2) + REG_VBR); // notaz hack /* If vector is uninitialized, call the uninitialized interrupt vector */ if(new_pc == 0)