ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/basilisk_glue.cpp
Revision: 1.1.1.1 (vendor branch)
Committed: 1999-10-03T14:16:26Z (25 years, 1 month ago) by cebix
Branch: cebix
CVS Tags: release-0_7-2, snapshot-21101999, start, snapshot-02111999
Changes since 1.1: +0 -0 lines
Error occurred while calculating annotation data.
Log Message:
Imported sources

File Contents

# Content
1 /*
2 * basilisk_glue.cpp - Glue UAE CPU to Basilisk II CPU engine interface
3 *
4 * Basilisk II (C) 1997-1999 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
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
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.
15 *
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
19 */
20
21 #include "sysdeps.h"
22 #include "cpu_emulation.h"
23 #include "main.h"
24 #include "emul_op.h"
25 #include "rom_patches.h"
26 #include "m68k.h"
27 #include "memory.h"
28 #include "readcpu.h"
29 #include "newcpu.h"
30 #include "compiler.h"
31
32
33 // RAM and ROM pointers
34 uint32 RAMBaseMac; // RAM base (Mac address space)
35 uint8 *RAMBaseHost; // RAM base (host address space)
36 uint32 RAMSize; // Size of RAM
37 uint32 ROMBaseMac; // ROM base (Mac address space)
38 uint8 *ROMBaseHost; // ROM base (host address space)
39 uint32 ROMSize; // Size of ROM
40
41 #if !REAL_ADDRESSING
42 // Mac frame buffer
43 uint8 *MacFrameBaseHost; // Frame buffer base (host address space)
44 uint32 MacFrameSize; // Size of frame buffer
45 int MacFrameLayout; // Frame buffer layout
46 #endif
47
48 // From newcpu.cpp
49 extern int quit_program;
50
51
52 /*
53 * Initialize 680x0 emulation, CheckROM() must have been called first
54 */
55
56 bool Init680x0(void)
57 {
58 #if REAL_ADDRESSING
59 // Mac address space = host address space
60 RAMBaseMac = (uint32)RAMBaseHost;
61 ROMBaseMac = (uint32)ROMBaseHost;
62 #else
63 // Initialize UAE memory banks
64 RAMBaseMac = 0;
65 switch (ROMVersion) {
66 case ROM_VERSION_64K:
67 case ROM_VERSION_PLUS:
68 case ROM_VERSION_CLASSIC:
69 ROMBaseMac = 0x00400000;
70 break;
71 case ROM_VERSION_II:
72 ROMBaseMac = 0x00a00000;
73 break;
74 case ROM_VERSION_32:
75 ROMBaseMac = 0x40800000;
76 break;
77 default:
78 return false;
79 }
80 memory_init();
81 #endif
82
83 init_m68k();
84 return true;
85 }
86
87
88 /*
89 * Deinitialize 680x0 emulation
90 */
91
92 void Exit680x0(void)
93 {
94 }
95
96
97 /*
98 * Reset and start 680x0 emulation (doesn't return)
99 */
100
101 void Start680x0(void)
102 {
103 m68k_reset();
104 m68k_go(true);
105 }
106
107
108 /*
109 * Trigger interrupt
110 */
111
112 void TriggerInterrupt(void)
113 {
114 regs.spcflags |= SPCFLAG_INT;
115 }
116
117
118 /*
119 * Get 68k interrupt level
120 */
121
122 int intlev(void)
123 {
124 return InterruptFlags ? 1 : 0;
125 }
126
127
128 /*
129 * Execute MacOS 68k trap
130 * r->a[7] and r->sr are unused!
131 */
132
133 void Execute68kTrap(uint16 trap, struct M68kRegisters *r)
134 {
135 int i;
136
137 // Save old PC
138 uaecptr oldpc = m68k_getpc();
139
140 // Set registers
141 for (i=0; i<8; i++)
142 m68k_dreg(regs, i) = r->d[i];
143 for (i=0; i<7; i++)
144 m68k_areg(regs, i) = r->a[i];
145
146 // Push trap and EXEC_RETURN on stack
147 m68k_areg(regs, 7) -= 2;
148 put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
149 m68k_areg(regs, 7) -= 2;
150 put_word(m68k_areg(regs, 7), trap);
151
152 // Execute trap
153 m68k_setpc(m68k_areg(regs, 7));
154 fill_prefetch_0();
155 quit_program = 0;
156 m68k_go(true);
157
158 // Clean up stack
159 m68k_areg(regs, 7) += 4;
160
161 // Restore old PC
162 m68k_setpc(oldpc);
163 fill_prefetch_0();
164
165 // Get registers
166 for (i=0; i<8; i++)
167 r->d[i] = m68k_dreg(regs, i);
168 for (i=0; i<7; i++)
169 r->a[i] = m68k_areg(regs, i);
170 quit_program = 0;
171 }
172
173
174 /*
175 * Execute 68k subroutine
176 * The executed routine must reside in UAE memory!
177 * r->a[7] and r->sr are unused!
178 */
179
180 void Execute68k(uint32 addr, struct M68kRegisters *r)
181 {
182 int i;
183
184 // Save old PC
185 uaecptr oldpc = m68k_getpc();
186
187 // Set registers
188 for (i=0; i<8; i++)
189 m68k_dreg(regs, i) = r->d[i];
190 for (i=0; i<7; i++)
191 m68k_areg(regs, i) = r->a[i];
192
193 // Push EXEC_RETURN and faked return address (points to EXEC_RETURN) on stack
194 m68k_areg(regs, 7) -= 2;
195 put_word(m68k_areg(regs, 7), M68K_EXEC_RETURN);
196 m68k_areg(regs, 7) -= 4;
197 put_long(m68k_areg(regs, 7), m68k_areg(regs, 7) + 4);
198
199 // Execute routine
200 m68k_setpc(addr);
201 fill_prefetch_0();
202 quit_program = 0;
203 m68k_go(true);
204
205 // Clean up stack
206 m68k_areg(regs, 7) += 2;
207
208 // Restore old PC
209 m68k_setpc(oldpc);
210 fill_prefetch_0();
211
212 // Get registers
213 for (i=0; i<8; i++)
214 r->d[i] = m68k_dreg(regs, i);
215 for (i=0; i<7; i++)
216 r->a[i] = m68k_areg(regs, i);
217 quit_program = 0;
218 }