1 |
|
/* |
2 |
|
* basilisk_glue.cpp - Glue UAE CPU to Basilisk II CPU engine interface |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-1999 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2005 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
19 |
|
*/ |
20 |
|
|
21 |
|
#include "sysdeps.h" |
22 |
+ |
|
23 |
|
#include "cpu_emulation.h" |
24 |
|
#include "main.h" |
25 |
+ |
#include "prefs.h" |
26 |
|
#include "emul_op.h" |
27 |
|
#include "rom_patches.h" |
28 |
+ |
#include "timer.h" |
29 |
|
#include "m68k.h" |
30 |
|
#include "memory.h" |
31 |
|
#include "readcpu.h" |
32 |
|
#include "newcpu.h" |
33 |
< |
#include "compiler.h" |
33 |
> |
#include "compiler/compemu.h" |
34 |
|
|
35 |
|
|
36 |
|
// RAM and ROM pointers |
37 |
< |
uint32 RAMBaseMac; // RAM base (Mac address space) |
37 |
> |
uint32 RAMBaseMac = 0; // RAM base (Mac address space) gb-- initializer is important |
38 |
|
uint8 *RAMBaseHost; // RAM base (host address space) |
39 |
|
uint32 RAMSize; // Size of RAM |
40 |
|
uint32 ROMBaseMac; // ROM base (Mac address space) |
48 |
|
int MacFrameLayout; // Frame buffer layout |
49 |
|
#endif |
50 |
|
|
51 |
+ |
#if DIRECT_ADDRESSING |
52 |
+ |
uintptr MEMBaseDiff; // Global offset between a Mac address and its Host equivalent |
53 |
+ |
#endif |
54 |
+ |
|
55 |
+ |
#if USE_JIT |
56 |
+ |
bool UseJIT = false; |
57 |
+ |
#endif |
58 |
+ |
|
59 |
|
// From newcpu.cpp |
60 |
< |
extern int quit_program; |
60 |
> |
extern bool quit_program; |
61 |
|
|
62 |
|
|
63 |
|
/* |
68 |
|
{ |
69 |
|
#if REAL_ADDRESSING |
70 |
|
// Mac address space = host address space |
71 |
< |
RAMBaseMac = (uint32)RAMBaseHost; |
72 |
< |
ROMBaseMac = (uint32)ROMBaseHost; |
71 |
> |
RAMBaseMac = (uintptr)RAMBaseHost; |
72 |
> |
ROMBaseMac = (uintptr)ROMBaseHost; |
73 |
> |
#elif DIRECT_ADDRESSING |
74 |
> |
// Mac address space = host address space minus constant offset (MEMBaseDiff) |
75 |
> |
// NOTE: MEMBaseDiff is set up in main_unix.cpp/main() |
76 |
> |
RAMBaseMac = 0; |
77 |
> |
ROMBaseMac = Host2MacAddr(ROMBaseHost); |
78 |
|
#else |
79 |
|
// Initialize UAE memory banks |
80 |
|
RAMBaseMac = 0; |
97 |
|
#endif |
98 |
|
|
99 |
|
init_m68k(); |
100 |
< |
compiler_init(); |
100 |
> |
#if USE_JIT |
101 |
> |
UseJIT = compiler_use_jit(); |
102 |
> |
if (UseJIT) |
103 |
> |
compiler_init(); |
104 |
> |
#endif |
105 |
|
return true; |
106 |
|
} |
107 |
|
|
112 |
|
|
113 |
|
void Exit680x0(void) |
114 |
|
{ |
115 |
+ |
#if USE_JIT |
116 |
+ |
if (UseJIT) |
117 |
+ |
compiler_exit(); |
118 |
+ |
#endif |
119 |
+ |
exit_m68k(); |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
|
/* |
124 |
+ |
* Initialize memory mapping of frame buffer (called upon video mode change) |
125 |
+ |
*/ |
126 |
+ |
|
127 |
+ |
void InitFrameBufferMapping(void) |
128 |
+ |
{ |
129 |
+ |
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
130 |
+ |
memory_init(); |
131 |
+ |
#endif |
132 |
+ |
} |
133 |
+ |
|
134 |
+ |
/* |
135 |
|
* Reset and start 680x0 emulation (doesn't return) |
136 |
|
*/ |
137 |
|
|
138 |
|
void Start680x0(void) |
139 |
|
{ |
140 |
|
m68k_reset(); |
141 |
< |
m68k_go(true); |
141 |
> |
#if USE_JIT |
142 |
> |
if (UseJIT) |
143 |
> |
m68k_compile_execute(); |
144 |
> |
else |
145 |
> |
#endif |
146 |
> |
m68k_execute(); |
147 |
|
} |
148 |
|
|
149 |
|
|
153 |
|
|
154 |
|
void TriggerInterrupt(void) |
155 |
|
{ |
156 |
< |
regs.spcflags |= SPCFLAG_INT; |
156 |
> |
idle_resume(); |
157 |
> |
SPCFLAGS_SET( SPCFLAG_INT ); |
158 |
> |
} |
159 |
> |
|
160 |
> |
void TriggerNMI(void) |
161 |
> |
{ |
162 |
> |
//!! not implemented yet |
163 |
|
} |
164 |
|
|
165 |
|
|
200 |
|
// Execute trap |
201 |
|
m68k_setpc(m68k_areg(regs, 7)); |
202 |
|
fill_prefetch_0(); |
203 |
< |
quit_program = 0; |
204 |
< |
m68k_go(true); |
203 |
> |
quit_program = false; |
204 |
> |
m68k_execute(); |
205 |
|
|
206 |
|
// Clean up stack |
207 |
|
m68k_areg(regs, 7) += 4; |
215 |
|
r->d[i] = m68k_dreg(regs, i); |
216 |
|
for (i=0; i<7; i++) |
217 |
|
r->a[i] = m68k_areg(regs, i); |
218 |
< |
quit_program = 0; |
218 |
> |
quit_program = false; |
219 |
|
} |
220 |
|
|
221 |
|
|
247 |
|
// Execute routine |
248 |
|
m68k_setpc(addr); |
249 |
|
fill_prefetch_0(); |
250 |
< |
quit_program = 0; |
251 |
< |
m68k_go(true); |
250 |
> |
quit_program = false; |
251 |
> |
m68k_execute(); |
252 |
|
|
253 |
|
// Clean up stack |
254 |
|
m68k_areg(regs, 7) += 2; |
262 |
|
r->d[i] = m68k_dreg(regs, i); |
263 |
|
for (i=0; i<7; i++) |
264 |
|
r->a[i] = m68k_areg(regs, i); |
265 |
< |
quit_program = 0; |
265 |
> |
quit_program = false; |
266 |
|
} |