--- hatari/src/uae-cpu/hatari-glue.c 2019/04/01 07:10:40 1.1.1.6 +++ hatari/src/uae-cpu/hatari-glue.c 2019/04/01 07:11:00 1.1.1.7 @@ -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.6 2019/04/01 07:10:40 root Exp $"; +static char rcsid[] = "Hatari $Id: hatari-glue.c,v 1.1.1.7 2019/04/01 07:11:00 root Exp $"; #include @@ -38,9 +38,6 @@ int cpu_compatible = FALSE; int requestedInterrupt = -1; -long STmem_size = 0x400000; /* 4MB */ -long TTmem_size = 0; - /* Reset custom chips */ void customreset(void) @@ -62,12 +59,9 @@ int intlev(void) /* Initialize 680x0 emulation */ int Init680x0(void) { - memory_init(); + /* Note: memory_init() is now done in tos.c */ init_m68k(); -#ifdef USE_COMPILER - compiler_init(); -#endif return TRUE; } @@ -75,6 +69,7 @@ int Init680x0(void) /* Deinitialize 680x0 emulation */ void Exit680x0(void) { + memory_uninit(); } @@ -93,27 +88,39 @@ void check_prefs_changed_cpu(int new_lev { cpu_level = new_level; cpu_compatible = new_compatible; - build_cpufunctbl (); + set_special(SPCFLAG_MODE_CHANGE); + if (table68k) + build_cpufunctbl (); } } - /* ----------------------------------------------------------------------- */ /* - We use an illegal opcode to set ConnectedDrives, as TOS (or an HD driver) - alters this value we cannot set it on init. - This opcode replaces the RTS at the end of the DMA bus boot routine + This function will be called at system init by the cartridge routine + (after gemdos init, before booting floppies). + + The GEMDOS vector (#$84) is setup and we also initialize the connected + drive mask and Line-A variables (for an extended VDI resolution) from here. */ -unsigned long OpCode_ConnectedDrive(uae_u32 opcode) +unsigned long OpCode_SysInit(uae_u32 opcode) { - fprintf(stderr, "OpCode_ConnectedDrive handled (%x)\n",ConnectedDriveMask ); - /* Set connected drives */ - STMemory_WriteLong(0x4c2, ConnectedDriveMask); - /* do an RTS (the opcode we replaced) */ - m68k_setpc(longget(m68k_areg(regs, 7))); - m68k_areg(regs, 7) += 4; + /* Initialize the connected drive mask */ + STMemory_WriteLong(0x4c2, ConnectedDriveMask); + + if(!bInitGemDOS) + { + /* Init on boot - see cartimg.c */ + GemDOS_Boot(); + + /* We use this to get pointer to Line-A structure details + * (to fix for extended VDI res) */ + LineABase = regs.regs[0]; /* D0 */ + FontBase = regs.regs[9]; /* A1 */ + VDI_LineA(); + } + m68k_incpc(2); fill_prefetch_0(); return 4; } @@ -125,7 +132,7 @@ unsigned long OpCode_ConnectedDrive(uae_ */ unsigned long OpCode_OldGemDos(uae_u32 opcode) { - m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) ); + m68k_setpc( STMemory_ReadLong(CART_OLDGEMDOS) ); fill_prefetch_0(); return 4; } @@ -133,30 +140,13 @@ unsigned long OpCode_OldGemDos(uae_u32 o /* ----------------------------------------------------------------------- */ /* - Intercept GEMDOS calls (setup vector $84) - The vector is setup when the gemdos-opcode is run the first time, by - the cartridge routine. (after gemdos init, before booting floppies) + Intercept GEMDOS calls - After this, our vector will be used, and handled by the GemDOS_OpCode - routine in gemdos.c + Used for GEMDOS HD emulation (see gemdos.c). */ unsigned long OpCode_GemDos(uae_u32 opcode) { - if(!bInitGemDOS) - { - /* Init on boot - see cartimg.c */ - GemDOS_Boot(); - - /* We use this to get pointer to Line-A structure details - * (to fix for extended VDI res) */ - LineABase = regs.regs[0]; /* D0 */ - FontBase = regs.regs[9]; /* A1 */ - VDI_LineA(); - } - else - { - GemDOS_OpCode(); /* handler code in gemdos.c */ - } + GemDOS_OpCode(); /* handler code in gemdos.c */ m68k_incpc(2); fill_prefetch_0(); @@ -175,6 +165,7 @@ unsigned long OpCode_GemDos(uae_u32 opco 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");*/ @@ -185,6 +176,7 @@ unsigned long OpCode_TimerD(uae_u32 opco fill_prefetch_0(); return 4; } +#endif /*-----------------------------------------------------------------------*/