|
|
1.1 ! root 1: /* ! 2: Hatari - hatari-glue.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. ! 6: ! 7: This file contains some code to glue the UAE CPU core to the rest of the ! 8: emulator and Hatari's "illegal" opcodes. ! 9: */ ! 10: const char HatariGlue_fileid[] = "Hatari hatari-glue.c : " __DATE__ " " __TIME__; ! 11: ! 12: ! 13: #include <stdio.h> ! 14: ! 15: #include "main.h" ! 16: #include "configuration.h" ! 17: #include "cycInt.h" ! 18: #include "tos.h" ! 19: #include "gemdos.h" ! 20: #include "cart.h" ! 21: #include "vdi.h" ! 22: #include "stMemory.h" ! 23: #include "ikbd.h" ! 24: #include "screen.h" ! 25: #include "video.h" ! 26: ! 27: #include "sysdeps.h" ! 28: #include "maccess.h" ! 29: #include "memory.h" ! 30: #include "newcpu.h" ! 31: #include "hatari-glue.h" ! 32: ! 33: ! 34: struct uae_prefs currprefs, changed_prefs; ! 35: ! 36: int pendingInterrupts = 0; ! 37: ! 38: ! 39: /** ! 40: * Reset custom chips ! 41: */ ! 42: void customreset(void) ! 43: { ! 44: pendingInterrupts = 0; ! 45: ! 46: /* In case the 6301 was executing a custom program from its RAM */ ! 47: /* we must turn it back to the 'normal' mode. */ ! 48: IKBD_Reset_ExeMode (); ! 49: ! 50: /* Reseting the GLUE video chip should also set freq/res register to 0 */ ! 51: Video_Reset_Glue (); ! 52: } ! 53: ! 54: ! 55: /** ! 56: * Return interrupt number (1 - 7), -1 means no interrupt. ! 57: * Note that the interrupt stays pending if it can't be executed yet ! 58: * due to the interrupt level field in the SR. ! 59: */ ! 60: int intlev(void) ! 61: { ! 62: /* There are only VBL and HBL autovector interrupts in the ST... */ ! 63: assert((pendingInterrupts & ~((1<<4)|(1<<2))) == 0); ! 64: ! 65: if (pendingInterrupts & (1 << 4)) /* VBL interrupt? */ ! 66: { ! 67: if (regs.intmask < 4) ! 68: pendingInterrupts &= ~(1 << 4); ! 69: return 4; ! 70: } ! 71: else if (pendingInterrupts & (1 << 2)) /* HBL interrupt? */ ! 72: { ! 73: if (regs.intmask < 2) ! 74: pendingInterrupts &= ~(1 << 2); ! 75: return 2; ! 76: } ! 77: ! 78: return -1; ! 79: } ! 80: ! 81: /** ! 82: * Initialize 680x0 emulation ! 83: */ ! 84: int Init680x0(void) ! 85: { ! 86: currprefs.cpu_level = changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel; ! 87: ! 88: switch (currprefs.cpu_level) { ! 89: case 0 : currprefs.cpu_model = 68000; break; ! 90: case 1 : currprefs.cpu_model = 68010; break; ! 91: case 2 : currprefs.cpu_model = 68020; break; ! 92: case 3 : currprefs.cpu_model = 68030; break; ! 93: case 4 : currprefs.cpu_model = 68040; break; ! 94: case 5 : currprefs.cpu_model = 68060; break; ! 95: default: fprintf (stderr, "Init680x0() : Error, cpu_level unknown\n"); ! 96: } ! 97: ! 98: currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu; ! 99: currprefs.address_space_24 = changed_prefs.address_space_24 = ConfigureParams.System.bAddressSpace24; ! 100: currprefs.cpu_cycle_exact = changed_prefs.cpu_cycle_exact = ConfigureParams.System.bCycleExactCpu; ! 101: currprefs.fpu_model = changed_prefs.fpu_model = ConfigureParams.System.n_FPUType; ! 102: currprefs.fpu_strict = changed_prefs.fpu_strict = ConfigureParams.System.bCompatibleFPU; ! 103: currprefs.mmu_model = changed_prefs.mmu_model = ConfigureParams.System.bMMU; ! 104: ! 105: init_m68k(); ! 106: ! 107: return true; ! 108: } ! 109: ! 110: ! 111: /** ! 112: * Deinitialize 680x0 emulation ! 113: */ ! 114: void Exit680x0(void) ! 115: { ! 116: memory_uninit(); ! 117: ! 118: free(table68k); ! 119: table68k = NULL; ! 120: } ! 121: ! 122: /** ! 123: * This function will be called at system init by the cartridge routine ! 124: * (after gemdos init, before booting floppies). ! 125: * The GEMDOS vector (#$84) is setup and we also initialize the connected ! 126: * drive mask and Line-A variables (for an extended VDI resolution) from here. ! 127: */ ! 128: unsigned long OpCode_SysInit(uae_u32 opcode) ! 129: { ! 130: /* Add any drives mapped by TOS in the interim */ ! 131: ConnectedDriveMask |= STMemory_ReadLong(0x4c2); ! 132: /* Initialize the connected drive mask */ ! 133: STMemory_WriteLong(0x4c2, ConnectedDriveMask); ! 134: ! 135: if (!bInitGemDOS) ! 136: { ! 137: /* Init on boot - see cart.c */ ! 138: GemDOS_Boot(); ! 139: ! 140: /* Update LineA for extended VDI res ! 141: * D0: LineA base, A1: Font base ! 142: */ ! 143: VDI_LineA(regs.regs[0], regs.regs[9]); ! 144: } ! 145: ! 146: m68k_incpc(2); ! 147: fill_prefetch_0(); ! 148: return 4; ! 149: } ! 150: ! 151: ! 152: /** ! 153: * Intercept GEMDOS calls. ! 154: * Used for GEMDOS HD emulation (see gemdos.c). ! 155: */ ! 156: unsigned long OpCode_GemDos(uae_u32 opcode) ! 157: { ! 158: GemDOS_OpCode(); /* handler code in gemdos.c */ ! 159: ! 160: m68k_incpc(2); ! 161: fill_prefetch_0(); ! 162: return 4; ! 163: } ! 164: ! 165: ! 166: /** ! 167: * This is called after completion of each VDI call ! 168: */ ! 169: unsigned long OpCode_VDI(uae_u32 opcode) ! 170: { ! 171: VDI_Complete(); ! 172: ! 173: /* Set PC back to where originated from to continue instruction decoding */ ! 174: m68k_setpc(VDI_OldPC); ! 175: ! 176: fill_prefetch_0(); ! 177: return 4; ! 178: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.