|
|
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 "cart.h"
19: #include "nextMemory.h"
20: #include "screen.h"
21: #include "video.h"
22:
23: #include "sysdeps.h"
24: #include "maccess.h"
25: #include "memory.h"
26: #include "newcpu.h"
27: #include "hatari-glue.h"
28:
29:
30: struct uae_prefs currprefs, changed_prefs;
31:
32: int pendingInterrupts = 0;
33:
34:
35: /**
36: * Reset custom chips
37: */
38: void customreset(void)
39: {
40: pendingInterrupts = 0;
41:
42: /* In case the 6301 was executing a custom program from its RAM */
43: /* we must turn it back to the 'normal' mode. */
44: // IKBD_Reset_ExeMode ();
45:
46: /* Reseting the GLUE video chip should also set freq/res register to 0 */
47: Video_Reset_Glue ();
48: }
49:
50:
51: /**
52: * Return interrupt number (1 - 7), -1 means no interrupt.
53: * Note that the interrupt stays pending if it can't be executed yet
54: * due to the interrupt level field in the SR.
55: */
56: int intlev(void)
57: {
58: /* There are only VBL and HBL autovector interrupts in the ST... */
1.1.1.2 ! root 59: // assert((pendingInterrupts & ~((1<<4)|(1<<2))) == 0);
1.1 root 60:
1.1.1.2 ! root 61: if (pendingInterrupts & (1 << 7))
! 62: {
! 63: if (regs.intmask < 7)
! 64: pendingInterrupts &= ~(1 << 7);
! 65: return 7;
! 66: }
! 67: else if (pendingInterrupts & (1 << 6))
! 68: {
! 69: if (regs.intmask < 6)
! 70: pendingInterrupts &= ~(1 << 6);
! 71: return 6;
! 72: }
! 73: else if (pendingInterrupts & (1 << 5))
! 74: {
! 75: if (regs.intmask < 5)
! 76: pendingInterrupts &= ~(1 << 5);
! 77: return 5;
! 78: }
! 79: else if (pendingInterrupts & (1 << 4))
1.1 root 80: {
81: if (regs.intmask < 4)
82: pendingInterrupts &= ~(1 << 4);
83: return 4;
84: }
1.1.1.2 ! root 85: else if (pendingInterrupts & (1 << 3))
! 86: {
! 87: if (regs.intmask < 3)
! 88: pendingInterrupts &= ~(1 << 3);
! 89: return 3;
! 90: }
! 91: else if (pendingInterrupts & (1 << 2))
1.1 root 92: {
93: if (regs.intmask < 2)
94: pendingInterrupts &= ~(1 << 2);
95: return 2;
96: }
1.1.1.2 ! root 97: else if (pendingInterrupts & (1 << 1))
! 98: {
! 99: if (regs.intmask < 1)
! 100: pendingInterrupts &= ~(1 << 1);
! 101: return 1;
! 102: }
1.1 root 103:
104: return -1;
105: }
106:
107: /**
108: * Initialize 680x0 emulation
109: */
110: int Init680x0(void)
111: {
112: currprefs.cpu_level = changed_prefs.cpu_level = ConfigureParams.System.nCpuLevel;
113:
114: switch (currprefs.cpu_level) {
115: case 0 : currprefs.cpu_model = 68000; break;
116: case 1 : currprefs.cpu_model = 68010; break;
117: case 2 : currprefs.cpu_model = 68020; break;
118: case 3 : currprefs.cpu_model = 68030; break;
119: case 4 : currprefs.cpu_model = 68040; break;
120: case 5 : currprefs.cpu_model = 68060; break;
121: default: fprintf (stderr, "Init680x0() : Error, cpu_level unknown\n");
122: }
123:
124: currprefs.cpu_compatible = changed_prefs.cpu_compatible = ConfigureParams.System.bCompatibleCpu;
125: currprefs.address_space_24 = changed_prefs.address_space_24 = ConfigureParams.System.bAddressSpace24;
126: currprefs.cpu_cycle_exact = changed_prefs.cpu_cycle_exact = ConfigureParams.System.bCycleExactCpu;
127: currprefs.fpu_model = changed_prefs.fpu_model = ConfigureParams.System.n_FPUType;
128: currprefs.fpu_strict = changed_prefs.fpu_strict = ConfigureParams.System.bCompatibleFPU;
129: currprefs.mmu_model = changed_prefs.mmu_model = ConfigureParams.System.bMMU;
1.1.1.2 ! root 130: write_log("Init680x0() called\n");
1.1 root 131:
132: init_m68k();
133:
134: return true;
135: }
136:
137:
138: /**
139: * Deinitialize 680x0 emulation
140: */
141: void Exit680x0(void)
142: {
143: memory_uninit();
144:
145: free(table68k);
146: table68k = NULL;
147: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.