|
|
1.1.1.6 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: */
1.1.1.13! root 10: const char HatariGlue_fileid[] = "Hatari hatari-glue.c : " __DATE__ " " __TIME__;
1.1.1.6 root 11:
1.1 root 12:
13: #include <stdio.h>
14:
15: #include "../includes/main.h"
1.1.1.11 root 16: #include "../includes/configuration.h"
1.1 root 17: #include "../includes/int.h"
18: #include "../includes/tos.h"
1.1.1.3 root 19: #include "../includes/gemdos.h"
20: #include "../includes/cart.h"
1.1.1.5 root 21: #include "../includes/vdi.h"
22: #include "../includes/stMemory.h"
1.1.1.12 root 23: #include "../includes/ikbd.h"
1.1.1.13! root 24: #include "../includes/video.h"
1.1 root 25:
1.1.1.3 root 26: #include "sysdeps.h"
27: #include "maccess.h"
1.1.1.5 root 28: #include "memory.h"
1.1.1.3 root 29: #include "newcpu.h"
1.1.1.8 root 30: #include "hatari-glue.h"
1.1 root 31:
32: #ifndef FALSE
33: #define FALSE 0
34: #define TRUE 1
35: #endif
36:
37:
1.1.1.11 root 38: struct uae_prefs currprefs, changed_prefs;
1.1 root 39:
1.1.1.8 root 40: int pendingInterrupts = 0;
1.1.1.6 root 41:
1.1 root 42:
43: /* Reset custom chips */
44: void customreset(void)
45: {
1.1.1.8 root 46: pendingInterrupts = 0;
1.1.1.12 root 47:
48: /* In case the 6301 was executing a custom program from its RAM */
49: /* we must turn it back to the 'normal' mode. */
50: IKBD_Reset_ExeMode ();
1.1.1.13! root 51:
! 52: /* Reseting the GLUE video chip should also set freq/res register to 0 */
! 53: Video_Reset_Glue ();
1.1.1.6 root 54: }
55:
56:
1.1.1.8 root 57: /* Return interrupt number (1 - 7), -1 means no interrupt.
58: * Note that the interrupt stays pending if it can't be executed yet
59: * due to the interrupt level field in the SR. */
1.1.1.6 root 60: int intlev(void)
61: {
1.1.1.8 root 62: /* There are only VBL and HBL autovector interrupts in the ST... */
63: assert((pendingInterrupts & ~((1<<4)|(1<<2))) == 0);
1.1.1.6 root 64:
1.1.1.8 root 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;
1.1 root 79: }
80:
81:
1.1.1.4 root 82: /* Initialize 680x0 emulation */
1.1 root 83: int Init680x0(void)
84: {
1.1.1.11 root 85: currprefs.cpu_level = changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel;
86: currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
87: currprefs.address_space_24 = changed_prefs.address_space_24 = TRUE;
1.1 root 88:
1.1.1.4 root 89: init_m68k();
90: return TRUE;
1.1 root 91: }
92:
93:
94: /* Deinitialize 680x0 emulation */
95: void Exit680x0(void)
96: {
1.1.1.7 root 97: memory_uninit();
1.1.1.8 root 98:
99: free(table68k);
100: table68k = NULL;
1.1 root 101: }
102:
103:
1.1.1.4 root 104: /* Check if the CPU type has been changed */
1.1.1.11 root 105: void check_prefs_changed_cpu(void)
1.1.1.4 root 106: {
1.1.1.11 root 107: if (currprefs.cpu_level != changed_prefs.cpu_level
108: || currprefs.cpu_compatible != changed_prefs.cpu_compatible)
1.1.1.4 root 109: {
1.1.1.11 root 110: currprefs.cpu_level = changed_prefs.cpu_level;
111: currprefs.cpu_compatible = changed_prefs.cpu_compatible;
1.1.1.7 root 112: set_special(SPCFLAG_MODE_CHANGE);
1.1.1.11 root 113: build_cpufunctbl ();
1.1.1.4 root 114: }
1.1 root 115: }
116:
117:
118: /* ----------------------------------------------------------------------- */
119: /*
1.1.1.7 root 120: This function will be called at system init by the cartridge routine
121: (after gemdos init, before booting floppies).
122:
123: The GEMDOS vector (#$84) is setup and we also initialize the connected
124: drive mask and Line-A variables (for an extended VDI resolution) from here.
1.1 root 125: */
1.1.1.7 root 126: unsigned long OpCode_SysInit(uae_u32 opcode)
1.1 root 127: {
1.1.1.7 root 128: /* Initialize the connected drive mask */
129: STMemory_WriteLong(0x4c2, ConnectedDriveMask);
130:
131: if(!bInitGemDOS)
132: {
1.1.1.9 root 133: /* Init on boot - see cart.c */
1.1.1.7 root 134: GemDOS_Boot();
135:
1.1.1.11 root 136: /* Update LineA for extended VDI res
137: * D0: LineA base, A1: Font base
138: */
139: VDI_LineA(regs.regs[0], regs.regs[9]);
1.1.1.7 root 140: }
1.1.1.4 root 141:
1.1.1.7 root 142: m68k_incpc(2);
1.1.1.4 root 143: fill_prefetch_0();
144: return 4;
1.1.1.3 root 145: }
146:
1.1.1.5 root 147:
1.1.1.3 root 148: /* ----------------------------------------------------------------------- */
149: /*
1.1.1.7 root 150: Intercept GEMDOS calls
1.1.1.3 root 151:
1.1.1.7 root 152: Used for GEMDOS HD emulation (see gemdos.c).
1.1.1.3 root 153: */
154: unsigned long OpCode_GemDos(uae_u32 opcode)
155: {
1.1.1.7 root 156: GemDOS_OpCode(); /* handler code in gemdos.c */
1.1.1.3 root 157:
1.1.1.5 root 158: m68k_incpc(2);
159: fill_prefetch_0();
160: return 4;
1.1 root 161: }
162:
1.1.1.5 root 163:
164: /*-----------------------------------------------------------------------*/
165: /*
166: This is called after completion of each VDI call
167: */
168: unsigned long OpCode_VDI(uae_u32 opcode)
169: {
170: VDI_Complete();
171:
172: /* Set PC back to where originated from to continue instruction decoding */
173: m68k_setpc(VDI_OldPC);
174:
175: fill_prefetch_0();
176: return 4;
1.1 root 177: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.