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