--- hatari/src/uae-cpu/hatari-glue.c 2019/04/01 07:11:00 1.1.1.7 +++ hatari/src/uae-cpu/hatari-glue.c 2019/04/01 07:13:11 1.1.1.10 @@ -7,7 +7,7 @@ This file contains some code to glue the UAE CPU core to the rest of the emulator and Hatari's "illegal" opcodes. */ -static char rcsid[] = "Hatari $Id: hatari-glue.c,v 1.1.1.7 2019/04/01 07:11:00 root Exp $"; +const char HatariGlue_rcsid[] = "Hatari $Id: hatari-glue.c,v 1.1.1.10 2019/04/01 07:13:11 root Exp $"; #include @@ -24,6 +24,7 @@ static char rcsid[] = "Hatari $Id: hatar #include "maccess.h" #include "memory.h" #include "newcpu.h" +#include "hatari-glue.h" #ifndef FALSE #define FALSE 0 @@ -31,28 +32,43 @@ static char rcsid[] = "Hatari $Id: hatar #endif -int illegal_mem = FALSE; +int illegal_mem = TRUE; int address_space_24 = TRUE; int cpu_level = 0; /* 68000 (default) */ int cpu_compatible = FALSE; -int requestedInterrupt = -1; +int pendingInterrupts = 0; /* Reset custom chips */ void customreset(void) { - requestedInterrupt = -1; + pendingInterrupts = 0; } -/* Return interrupt number (1 - 7), -1 means no interrupt. */ +/* Return interrupt number (1 - 7), -1 means no interrupt. + * Note that the interrupt stays pending if it can't be executed yet + * due to the interrupt level field in the SR. */ int intlev(void) { - int ret = requestedInterrupt; - requestedInterrupt = -1; + /* There are only VBL and HBL autovector interrupts in the ST... */ + assert((pendingInterrupts & ~((1<<4)|(1<<2))) == 0); - return ret; + if(pendingInterrupts & (1 << 4)) /* VBL interrupt? */ + { + if(regs.intmask < 4) + pendingInterrupts &= ~(1 << 4); + return 4; + } + else if(pendingInterrupts & (1 << 2)) /* HBL interrupt? */ + { + if(regs.intmask < 2) + pendingInterrupts &= ~(1 << 2); + return 2; + } + + return -1; } @@ -70,6 +86,9 @@ int Init680x0(void) void Exit680x0(void) { memory_uninit(); + + free(table68k); + table68k = NULL; } @@ -110,7 +129,7 @@ unsigned long OpCode_SysInit(uae_u32 opc if(!bInitGemDOS) { - /* Init on boot - see cartimg.c */ + /* Init on boot - see cart.c */ GemDOS_Boot(); /* We use this to get pointer to Line-A structure details @@ -128,18 +147,6 @@ unsigned long OpCode_SysInit(uae_u32 opc /* ----------------------------------------------------------------------- */ /* - Re-direct execution to old GEMDOS calls, used in 'cart.s' -*/ -unsigned long OpCode_OldGemDos(uae_u32 opcode) -{ - m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) ); - fill_prefetch_0(); - return 4; -} - - -/* ----------------------------------------------------------------------- */ -/* Intercept GEMDOS calls Used for GEMDOS HD emulation (see gemdos.c). @@ -154,31 +161,6 @@ unsigned long OpCode_GemDos(uae_u32 opco } -/* ----------------------------------------------------------------------- */ -/* - Modify TimerD in GEMDos to gain more desktop performance - - Obviously, we need to emulate all timers correctly but GemDOS set's up Timer D at a very - high rate(every couple of instructions). The interrupts isn't enabled but WinSTon still - needs to process the interrupt table and this HALVES our frame rate!!! (It causes a cache - reload each time). Some games actually reference this timer but don't set it up(eg Paradroid, - Speedball I) so we simply intercept the Timer D setup code in GemDOS and fix the numbers - with more 'laid-back' values. This still keeps 100% compatibility -*/ -#if 0 /* This is now done by intercepting the Timer-D hardware registers */ -unsigned long OpCode_TimerD(uae_u32 opcode) -{ - /*fprintf(stderr, "OpCode_TimerD handled\n");*/ - m68k_dreg(regs,0)=3; /* 3 = Select Timer D */ - m68k_dreg(regs,1)=7; /* 1 = /4 for 9600 baud(used /200) */ - m68k_dreg(regs,2)=100; /* 2 = 9600 baud(100) */ - m68k_incpc(2); - fill_prefetch_0(); - return 4; -} -#endif - - /*-----------------------------------------------------------------------*/ /* This is called after completion of each VDI call