--- hatari/src/uae-cpu/newcpu.h 2019/04/01 07:14:57 1.1.1.11 +++ hatari/src/uae-cpu/newcpu.h 2019/04/09 08:57:03 1.1.1.17 @@ -7,8 +7,8 @@ * * Adaptation to Hatari by Thomas Huth * - * This file is distributed under the GNU Public License, version 2 or at - * your option any later version. Read the file gpl.txt for details. + * This file is distributed under the GNU General Public License, version 2 + * or at your option any later version. Read the file gpl.txt for details. */ #ifndef UAE_NEWCPU_H @@ -20,13 +20,14 @@ /* Possible exceptions sources for M68000_Exception() and Exception() */ -#define M68000_EXCEPTION_SRC_CPU 1 /* exception is a direct CPU exception */ -#define M68000_EXCEPTION_SRC_INT_MFP 2 /* exception caused by an MFP interrupt */ -#define M68000_EXCEPTION_SRC_INT_VIDEO 3 /* exception caused by a video interrupt */ - +#define M68000_EXC_SRC_CPU 1 /* Direct CPU exception */ +#define M68000_EXC_SRC_AUTOVEC 2 /* Auto-vector exception (e.g. VBL) */ +#define M68000_EXC_SRC_INT_MFP 3 /* MFP interrupt exception */ +#define M68000_EXC_SRC_INT_DSP 4 /* DSP interrupt exception */ /* Special flags */ +#define SPCFLAG_DEBUGGER 1 #define SPCFLAG_STOP 2 #define SPCFLAG_BUSERROR 4 #define SPCFLAG_INT 8 @@ -38,6 +39,7 @@ #define SPCFLAG_MFP 0x200 #define SPCFLAG_EXEC 0x400 #define SPCFLAG_MODE_CHANGE 0x800 +#define SPCFLAG_DSP 0x1000 #ifndef SET_CFLG @@ -115,6 +117,8 @@ extern struct regstruct uae_u32 pc; uae_u8 *pc_p; uae_u8 *pc_oldp; + uae_u16 opcode; + uae_u32 instruction_pc; uae_u32 vbr,sfc,dfc; @@ -167,17 +171,49 @@ STATIC_INLINE uaecptr m68k_getpc_p (uae_ STATIC_INLINE void refill_prefetch (uae_u32 currpc, uae_u32 offs) { uae_u32 t = (currpc + offs) & ~1; - uae_s32 pc_p_offs = t - currpc; - uae_u8 *ptr = regs.pc_p + pc_p_offs; uae_u32 r; + +//fprintf ( stderr , "refill pc %x o %d old %x\n" , currpc,offs,regs.prefetch_pc ); #ifdef UNALIGNED_PROFITABLE - r = *(uae_u32 *)ptr; + if ( t - regs.prefetch_pc == 2 ) /* keep 1 word and read 1 new word */ + { + r = regs.prefetch; + r <<= 16; + r |= get_word (t+2); + } + else + { + /* [NP] FIXME : when we refill with 4 bytes, we should not read one long */ + /* but 2 words, else some bus errors are not detected if the address overlaps */ + /* on a bus error region (eg : get_long(t=213ffffe) doesn't give a bus error, */ + /* but it should. This should be better handled in memory.c */ +// r = get_long (t); /* read 2 new words */ + r = get_word (t); + r <<= 16; + r |= get_word (t+2); + } regs.prefetch = r; #else - r = do_get_mem_long (ptr); + if ( t - regs.prefetch_pc == 2 ) /* keep 1 word and read 1 new word */ + { + r = do_get_mem_word (((uae_u8 *)®s.prefetch) + 2); + r <<= 16; + r |= get_word (t+2); + } + else + { + /* [NP] FIXME : when we refill with 4 bytes, we should not read one long */ + /* but 2 words, else some bus errors are not detected if the address overlaps */ + /* on a bus error region (eg : get_long(t=213ffffe) doesn't give a bus error, */ + /* but it should. This should be better handled in memory.c */ +// r = get_long (t); /* read 2 new words */ + r = get_word (t); + r <<= 16; + r |= get_word (t+2); + } do_put_mem_long (®s.prefetch, r); #endif - /* printf ("PC %lx T %lx PCPOFFS %d R %lx\n", currpc, t, pc_p_offs, r); */ +//fprintf (stderr,"PC %x PREFPC %x T %x R %x\n", currpc, regs.prefetch_pc, t, r); regs.prefetch_pc = t; } @@ -203,6 +239,7 @@ STATIC_INLINE uae_u32 get_iword_prefetch uae_u32 addr = currpc + o; uae_u32 offs = addr - regs.prefetch_pc; uae_u32 v; +//fprintf (stderr,"get_iword PC %lx ADDR %lx OFFS %lx V %lx\n", currpc, addr, offs, v); if (offs > 3) { refill_prefetch (currpc, o); offs = addr - regs.prefetch_pc; @@ -210,6 +247,7 @@ STATIC_INLINE uae_u32 get_iword_prefetch v = do_get_mem_word (((uae_u8 *)®s.prefetch) + offs); if (offs >= 2) refill_prefetch (currpc, 2); +//fprintf (stderr,"get_iword PC %lx ADDR %lx OFFS %lx V %lx\n", currpc, addr, offs, v); /* printf ("get_iword PC %lx ADDR %lx OFFS %lx V %lx\n", currpc, addr, offs, v); */ return v; } @@ -327,6 +365,10 @@ extern uae_u16 last_op_for_exception_3; extern uaecptr last_addr_for_exception_3; /* Address that generated the exception */ extern uaecptr last_fault_for_exception_3; +/* read (0) or write (1) access */ +extern int last_writeaccess_for_exception_3; +/* instruction (1) or data (0) access */ +extern int last_instructionaccess_for_exception_3; #define CPU_OP_NAME(a) op ## a @@ -350,4 +392,8 @@ extern uae_u32 caar, cacr; /* Family of the latest instruction executed (to check for pairing) */ extern int OpcodeFamily; /* see instrmnem in readcpu.h */ +/* How many cycles to add to the current instruction in case a "misaligned" bus access is made */ +/* (used when addressing mode is d8(an,ix)) */ +extern int BusCyclePenalty; + #endif /* UAE_NEWCPU_H */