2
* basilisk_glue.cpp - Glue UAE CPU to Basilisk II CPU engine interface
4
* Basilisk II (C) 1997-2002 Christian Bauer
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
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
#include "cpu_emulation.h"
27
#include "rom_patches.h"
32
#include "compiler/compemu.h"
35
// RAM and ROM pointers
36
uint32 RAMBaseMac = 0; // RAM base (Mac address space) gb-- initializer is important
37
uint8 *RAMBaseHost; // RAM base (host address space)
38
uint32 RAMSize; // Size of RAM
39
uint32 ROMBaseMac; // ROM base (Mac address space)
40
uint8 *ROMBaseHost; // ROM base (host address space)
41
uint32 ROMSize; // Size of ROM
45
uint8 *MacFrameBaseHost; // Frame buffer base (host address space)
46
uint32 MacFrameSize; // Size of frame buffer
47
int MacFrameLayout; // Frame buffer layout
51
uintptr MEMBaseDiff; // Global offset between a Mac address and its Host equivalent
59
extern bool quit_program;
63
* Initialize 680x0 emulation, CheckROM() must have been called first
69
// Mac address space = host address space
70
RAMBaseMac = (uint32)RAMBaseHost;
71
ROMBaseMac = (uint32)ROMBaseHost;
72
#elif DIRECT_ADDRESSING
73
// Mac address space = host address space minus constant offset (MEMBaseDiff)
74
// NOTE: MEMBaseDiff is set up in main_unix.cpp/main()
76
ROMBaseMac = Host2MacAddr(ROMBaseHost);
78
// Initialize UAE memory banks
82
case ROM_VERSION_PLUS:
83
case ROM_VERSION_CLASSIC:
84
ROMBaseMac = 0x00400000;
87
ROMBaseMac = 0x00a00000;
90
ROMBaseMac = 0x40800000;
100
UseJIT = compiler_use_jit();
109
* Deinitialize 680x0 emulation
123
* Initialize memory mapping of frame buffer (called upon video mode change)
126
void InitFrameBufferMapping(void)
128
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING
134
* Reset and start 680x0 emulation (doesn't return)
137
void Start680x0(void)
142
m68k_compile_execute();
153
void TriggerInterrupt(void)
155
SPCFLAGS_SET( SPCFLAG_INT );
158
void TriggerNMI(void)
160
//!! not implemented yet
165
* Get 68k interrupt level
170
return InterruptFlags ? 1 : 0;
175
* Execute MacOS 68k trap
176
* r->a[7] and r->sr are unused!
179
void Execute68kTrap(uint16 trap, struct M68kRegisters *r)
184
uaecptr oldpc = m68k_getpc();
188
m68k_dreg(regs, i) = r->d[i];
190
m68k_areg(regs, i) = r->a[i];
192
// Push trap and EXEC_RETURN on stack
193
m68k_areg(regs, 7) -= 2;
194
put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
195
m68k_areg(regs, 7) -= 2;
196
put_word(m68k_areg(regs, 7), trap);
199
m68k_setpc(m68k_areg(regs, 7));
201
quit_program = false;
205
m68k_areg(regs, 7) += 4;
213
r->d[i] = m68k_dreg(regs, i);
215
r->a[i] = m68k_areg(regs, i);
216
quit_program = false;
221
* Execute 68k subroutine
222
* The executed routine must reside in UAE memory!
223
* r->a[7] and r->sr are unused!
226
void Execute68k(uint32 addr, struct M68kRegisters *r)
231
uaecptr oldpc = m68k_getpc();
235
m68k_dreg(regs, i) = r->d[i];
237
m68k_areg(regs, i) = r->a[i];
239
// Push EXEC_RETURN and faked return address (points to EXEC_RETURN) on stack
240
m68k_areg(regs, 7) -= 2;
241
put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
242
m68k_areg(regs, 7) -= 4;
243
put_long(m68k_areg(regs, 7), m68k_areg(regs, 7) + 4);
248
quit_program = false;
252
m68k_areg(regs, 7) += 2;
260
r->d[i] = m68k_dreg(regs, i);
262
r->a[i] = m68k_areg(regs, i);
263
quit_program = false;