1 |
cebix |
1.1 |
/* |
2 |
|
|
* UAE - The Un*x Amiga Emulator |
3 |
|
|
* |
4 |
|
|
* Memory management |
5 |
|
|
* |
6 |
|
|
* (c) 1995 Bernd Schmidt |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
#include <stdio.h> |
10 |
|
|
#include <stdlib.h> |
11 |
|
|
|
12 |
|
|
#include "sysdeps.h" |
13 |
|
|
|
14 |
|
|
#include "cpu_emulation.h" |
15 |
gbeauche |
1.6 |
#include "main.h" |
16 |
|
|
#include "video.h" |
17 |
|
|
|
18 |
cebix |
1.1 |
#include "m68k.h" |
19 |
|
|
#include "memory.h" |
20 |
|
|
#include "readcpu.h" |
21 |
|
|
#include "newcpu.h" |
22 |
|
|
|
23 |
gbeauche |
1.3 |
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
24 |
|
|
|
25 |
cebix |
1.1 |
static bool illegal_mem = false; |
26 |
|
|
|
27 |
|
|
#ifdef SAVE_MEMORY_BANKS |
28 |
|
|
addrbank *mem_banks[65536]; |
29 |
|
|
#else |
30 |
|
|
addrbank mem_banks[65536]; |
31 |
|
|
#endif |
32 |
|
|
|
33 |
gbeauche |
1.3 |
#ifdef WORDS_BIGENDIAN |
34 |
|
|
# define swap_words(X) (X) |
35 |
|
|
#else |
36 |
|
|
# define swap_words(X) (((X) >> 16) | ((X) << 16)) |
37 |
|
|
#endif |
38 |
|
|
|
39 |
cebix |
1.1 |
#ifdef NO_INLINE_MEMORY_ACCESS |
40 |
gbeauche |
1.8 |
uae_u32 longget (uaecptr addr) |
41 |
cebix |
1.1 |
{ |
42 |
|
|
return call_mem_get_func (get_mem_bank (addr).lget, addr); |
43 |
|
|
} |
44 |
gbeauche |
1.8 |
uae_u32 wordget (uaecptr addr) |
45 |
cebix |
1.1 |
{ |
46 |
|
|
return call_mem_get_func (get_mem_bank (addr).wget, addr); |
47 |
|
|
} |
48 |
gbeauche |
1.8 |
uae_u32 byteget (uaecptr addr) |
49 |
cebix |
1.1 |
{ |
50 |
|
|
return call_mem_get_func (get_mem_bank (addr).bget, addr); |
51 |
|
|
} |
52 |
gbeauche |
1.8 |
void longput (uaecptr addr, uae_u32 l) |
53 |
cebix |
1.1 |
{ |
54 |
|
|
call_mem_put_func (get_mem_bank (addr).lput, addr, l); |
55 |
|
|
} |
56 |
gbeauche |
1.8 |
void wordput (uaecptr addr, uae_u32 w) |
57 |
cebix |
1.1 |
{ |
58 |
|
|
call_mem_put_func (get_mem_bank (addr).wput, addr, w); |
59 |
|
|
} |
60 |
gbeauche |
1.8 |
void byteput (uaecptr addr, uae_u32 b) |
61 |
cebix |
1.1 |
{ |
62 |
|
|
call_mem_put_func (get_mem_bank (addr).bput, addr, b); |
63 |
|
|
} |
64 |
|
|
#endif |
65 |
|
|
|
66 |
|
|
/* A dummy bank that only contains zeros */ |
67 |
|
|
|
68 |
|
|
static uae_u32 REGPARAM2 dummy_lget (uaecptr) REGPARAM; |
69 |
|
|
static uae_u32 REGPARAM2 dummy_wget (uaecptr) REGPARAM; |
70 |
|
|
static uae_u32 REGPARAM2 dummy_bget (uaecptr) REGPARAM; |
71 |
|
|
static void REGPARAM2 dummy_lput (uaecptr, uae_u32) REGPARAM; |
72 |
|
|
static void REGPARAM2 dummy_wput (uaecptr, uae_u32) REGPARAM; |
73 |
|
|
static void REGPARAM2 dummy_bput (uaecptr, uae_u32) REGPARAM; |
74 |
|
|
|
75 |
|
|
uae_u32 REGPARAM2 dummy_lget (uaecptr addr) |
76 |
|
|
{ |
77 |
|
|
if (illegal_mem) |
78 |
|
|
write_log ("Illegal lget at %08lx\n", addr); |
79 |
|
|
|
80 |
|
|
return 0; |
81 |
|
|
} |
82 |
|
|
|
83 |
|
|
uae_u32 REGPARAM2 dummy_wget (uaecptr addr) |
84 |
|
|
{ |
85 |
|
|
if (illegal_mem) |
86 |
|
|
write_log ("Illegal wget at %08lx\n", addr); |
87 |
|
|
|
88 |
|
|
return 0; |
89 |
|
|
} |
90 |
|
|
|
91 |
|
|
uae_u32 REGPARAM2 dummy_bget (uaecptr addr) |
92 |
|
|
{ |
93 |
|
|
if (illegal_mem) |
94 |
|
|
write_log ("Illegal bget at %08lx\n", addr); |
95 |
|
|
|
96 |
|
|
return 0; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
void REGPARAM2 dummy_lput (uaecptr addr, uae_u32 l) |
100 |
|
|
{ |
101 |
|
|
if (illegal_mem) |
102 |
|
|
write_log ("Illegal lput at %08lx\n", addr); |
103 |
|
|
} |
104 |
|
|
void REGPARAM2 dummy_wput (uaecptr addr, uae_u32 w) |
105 |
|
|
{ |
106 |
|
|
if (illegal_mem) |
107 |
|
|
write_log ("Illegal wput at %08lx\n", addr); |
108 |
|
|
} |
109 |
|
|
void REGPARAM2 dummy_bput (uaecptr addr, uae_u32 b) |
110 |
|
|
{ |
111 |
|
|
if (illegal_mem) |
112 |
|
|
write_log ("Illegal bput at %08lx\n", addr); |
113 |
|
|
} |
114 |
|
|
|
115 |
|
|
/* Mac RAM (32 bit addressing) */ |
116 |
|
|
|
117 |
|
|
static uae_u32 REGPARAM2 ram_lget(uaecptr) REGPARAM; |
118 |
|
|
static uae_u32 REGPARAM2 ram_wget(uaecptr) REGPARAM; |
119 |
|
|
static uae_u32 REGPARAM2 ram_bget(uaecptr) REGPARAM; |
120 |
|
|
static void REGPARAM2 ram_lput(uaecptr, uae_u32) REGPARAM; |
121 |
|
|
static void REGPARAM2 ram_wput(uaecptr, uae_u32) REGPARAM; |
122 |
|
|
static void REGPARAM2 ram_bput(uaecptr, uae_u32) REGPARAM; |
123 |
|
|
static uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) REGPARAM; |
124 |
|
|
|
125 |
gbeauche |
1.7 |
static uintptr RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
126 |
cebix |
1.1 |
|
127 |
|
|
uae_u32 REGPARAM2 ram_lget(uaecptr addr) |
128 |
|
|
{ |
129 |
|
|
uae_u32 *m; |
130 |
|
|
m = (uae_u32 *)(RAMBaseDiff + addr); |
131 |
|
|
return do_get_mem_long(m); |
132 |
|
|
} |
133 |
|
|
|
134 |
|
|
uae_u32 REGPARAM2 ram_wget(uaecptr addr) |
135 |
|
|
{ |
136 |
|
|
uae_u16 *m; |
137 |
|
|
m = (uae_u16 *)(RAMBaseDiff + addr); |
138 |
|
|
return do_get_mem_word(m); |
139 |
|
|
} |
140 |
|
|
|
141 |
|
|
uae_u32 REGPARAM2 ram_bget(uaecptr addr) |
142 |
|
|
{ |
143 |
|
|
return (uae_u32)*(uae_u8 *)(RAMBaseDiff + addr); |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
void REGPARAM2 ram_lput(uaecptr addr, uae_u32 l) |
147 |
|
|
{ |
148 |
|
|
uae_u32 *m; |
149 |
|
|
m = (uae_u32 *)(RAMBaseDiff + addr); |
150 |
|
|
do_put_mem_long(m, l); |
151 |
|
|
} |
152 |
|
|
|
153 |
|
|
void REGPARAM2 ram_wput(uaecptr addr, uae_u32 w) |
154 |
|
|
{ |
155 |
|
|
uae_u16 *m; |
156 |
|
|
m = (uae_u16 *)(RAMBaseDiff + addr); |
157 |
|
|
do_put_mem_word(m, w); |
158 |
|
|
} |
159 |
|
|
|
160 |
|
|
void REGPARAM2 ram_bput(uaecptr addr, uae_u32 b) |
161 |
|
|
{ |
162 |
|
|
*(uae_u8 *)(RAMBaseDiff + addr) = b; |
163 |
|
|
} |
164 |
|
|
|
165 |
|
|
uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) |
166 |
|
|
{ |
167 |
|
|
return (uae_u8 *)(RAMBaseDiff + addr); |
168 |
|
|
} |
169 |
|
|
|
170 |
|
|
/* Mac RAM (24 bit addressing) */ |
171 |
|
|
|
172 |
|
|
static uae_u32 REGPARAM2 ram24_lget(uaecptr) REGPARAM; |
173 |
|
|
static uae_u32 REGPARAM2 ram24_wget(uaecptr) REGPARAM; |
174 |
|
|
static uae_u32 REGPARAM2 ram24_bget(uaecptr) REGPARAM; |
175 |
|
|
static void REGPARAM2 ram24_lput(uaecptr, uae_u32) REGPARAM; |
176 |
|
|
static void REGPARAM2 ram24_wput(uaecptr, uae_u32) REGPARAM; |
177 |
|
|
static void REGPARAM2 ram24_bput(uaecptr, uae_u32) REGPARAM; |
178 |
|
|
static uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr) REGPARAM; |
179 |
|
|
|
180 |
|
|
uae_u32 REGPARAM2 ram24_lget(uaecptr addr) |
181 |
|
|
{ |
182 |
|
|
uae_u32 *m; |
183 |
|
|
m = (uae_u32 *)(RAMBaseDiff + (addr & 0xffffff)); |
184 |
|
|
return do_get_mem_long(m); |
185 |
|
|
} |
186 |
|
|
|
187 |
|
|
uae_u32 REGPARAM2 ram24_wget(uaecptr addr) |
188 |
|
|
{ |
189 |
|
|
uae_u16 *m; |
190 |
|
|
m = (uae_u16 *)(RAMBaseDiff + (addr & 0xffffff)); |
191 |
|
|
return do_get_mem_word(m); |
192 |
|
|
} |
193 |
|
|
|
194 |
|
|
uae_u32 REGPARAM2 ram24_bget(uaecptr addr) |
195 |
|
|
{ |
196 |
|
|
return (uae_u32)*(uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)); |
197 |
|
|
} |
198 |
|
|
|
199 |
|
|
void REGPARAM2 ram24_lput(uaecptr addr, uae_u32 l) |
200 |
|
|
{ |
201 |
|
|
uae_u32 *m; |
202 |
|
|
m = (uae_u32 *)(RAMBaseDiff + (addr & 0xffffff)); |
203 |
|
|
do_put_mem_long(m, l); |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
void REGPARAM2 ram24_wput(uaecptr addr, uae_u32 w) |
207 |
|
|
{ |
208 |
|
|
uae_u16 *m; |
209 |
|
|
m = (uae_u16 *)(RAMBaseDiff + (addr & 0xffffff)); |
210 |
|
|
do_put_mem_word(m, w); |
211 |
|
|
} |
212 |
|
|
|
213 |
|
|
void REGPARAM2 ram24_bput(uaecptr addr, uae_u32 b) |
214 |
|
|
{ |
215 |
|
|
*(uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)) = b; |
216 |
|
|
} |
217 |
|
|
|
218 |
|
|
uae_u8 *REGPARAM2 ram24_xlate(uaecptr addr) |
219 |
|
|
{ |
220 |
|
|
return (uae_u8 *)(RAMBaseDiff + (addr & 0xffffff)); |
221 |
|
|
} |
222 |
|
|
|
223 |
|
|
/* Mac ROM (32 bit addressing) */ |
224 |
|
|
|
225 |
|
|
static uae_u32 REGPARAM2 rom_lget(uaecptr) REGPARAM; |
226 |
|
|
static uae_u32 REGPARAM2 rom_wget(uaecptr) REGPARAM; |
227 |
|
|
static uae_u32 REGPARAM2 rom_bget(uaecptr) REGPARAM; |
228 |
|
|
static void REGPARAM2 rom_lput(uaecptr, uae_u32) REGPARAM; |
229 |
|
|
static void REGPARAM2 rom_wput(uaecptr, uae_u32) REGPARAM; |
230 |
|
|
static void REGPARAM2 rom_bput(uaecptr, uae_u32) REGPARAM; |
231 |
|
|
static uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) REGPARAM; |
232 |
|
|
|
233 |
gbeauche |
1.7 |
static uintptr ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
234 |
cebix |
1.1 |
|
235 |
|
|
uae_u32 REGPARAM2 rom_lget(uaecptr addr) |
236 |
|
|
{ |
237 |
|
|
uae_u32 *m; |
238 |
|
|
m = (uae_u32 *)(ROMBaseDiff + addr); |
239 |
|
|
return do_get_mem_long(m); |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
uae_u32 REGPARAM2 rom_wget(uaecptr addr) |
243 |
|
|
{ |
244 |
|
|
uae_u16 *m; |
245 |
|
|
m = (uae_u16 *)(ROMBaseDiff + addr); |
246 |
|
|
return do_get_mem_word(m); |
247 |
|
|
} |
248 |
|
|
|
249 |
|
|
uae_u32 REGPARAM2 rom_bget(uaecptr addr) |
250 |
|
|
{ |
251 |
|
|
return (uae_u32)*(uae_u8 *)(ROMBaseDiff + addr); |
252 |
|
|
} |
253 |
|
|
|
254 |
|
|
void REGPARAM2 rom_lput(uaecptr addr, uae_u32 b) |
255 |
|
|
{ |
256 |
|
|
if (illegal_mem) |
257 |
|
|
write_log ("Illegal ROM lput at %08lx\n", addr); |
258 |
|
|
} |
259 |
|
|
|
260 |
|
|
void REGPARAM2 rom_wput(uaecptr addr, uae_u32 b) |
261 |
|
|
{ |
262 |
|
|
if (illegal_mem) |
263 |
|
|
write_log ("Illegal ROM wput at %08lx\n", addr); |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
void REGPARAM2 rom_bput(uaecptr addr, uae_u32 b) |
267 |
|
|
{ |
268 |
|
|
if (illegal_mem) |
269 |
|
|
write_log ("Illegal ROM bput at %08lx\n", addr); |
270 |
|
|
} |
271 |
|
|
|
272 |
|
|
uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) |
273 |
|
|
{ |
274 |
|
|
return (uae_u8 *)(ROMBaseDiff + addr); |
275 |
|
|
} |
276 |
|
|
|
277 |
|
|
/* Mac ROM (24 bit addressing) */ |
278 |
|
|
|
279 |
|
|
static uae_u32 REGPARAM2 rom24_lget(uaecptr) REGPARAM; |
280 |
|
|
static uae_u32 REGPARAM2 rom24_wget(uaecptr) REGPARAM; |
281 |
|
|
static uae_u32 REGPARAM2 rom24_bget(uaecptr) REGPARAM; |
282 |
|
|
static uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr) REGPARAM; |
283 |
|
|
|
284 |
|
|
uae_u32 REGPARAM2 rom24_lget(uaecptr addr) |
285 |
|
|
{ |
286 |
|
|
uae_u32 *m; |
287 |
|
|
m = (uae_u32 *)(ROMBaseDiff + (addr & 0xffffff)); |
288 |
|
|
return do_get_mem_long(m); |
289 |
|
|
} |
290 |
|
|
|
291 |
|
|
uae_u32 REGPARAM2 rom24_wget(uaecptr addr) |
292 |
|
|
{ |
293 |
|
|
uae_u16 *m; |
294 |
|
|
m = (uae_u16 *)(ROMBaseDiff + (addr & 0xffffff)); |
295 |
|
|
return do_get_mem_word(m); |
296 |
|
|
} |
297 |
|
|
|
298 |
|
|
uae_u32 REGPARAM2 rom24_bget(uaecptr addr) |
299 |
|
|
{ |
300 |
|
|
return (uae_u32)*(uae_u8 *)(ROMBaseDiff + (addr & 0xffffff)); |
301 |
|
|
} |
302 |
|
|
|
303 |
|
|
uae_u8 *REGPARAM2 rom24_xlate(uaecptr addr) |
304 |
|
|
{ |
305 |
|
|
return (uae_u8 *)(ROMBaseDiff + (addr & 0xffffff)); |
306 |
|
|
} |
307 |
|
|
|
308 |
|
|
/* Frame buffer */ |
309 |
|
|
|
310 |
|
|
static uae_u32 REGPARAM2 frame_direct_lget(uaecptr) REGPARAM; |
311 |
|
|
static uae_u32 REGPARAM2 frame_direct_wget(uaecptr) REGPARAM; |
312 |
|
|
static uae_u32 REGPARAM2 frame_direct_bget(uaecptr) REGPARAM; |
313 |
|
|
static void REGPARAM2 frame_direct_lput(uaecptr, uae_u32) REGPARAM; |
314 |
|
|
static void REGPARAM2 frame_direct_wput(uaecptr, uae_u32) REGPARAM; |
315 |
|
|
static void REGPARAM2 frame_direct_bput(uaecptr, uae_u32) REGPARAM; |
316 |
|
|
|
317 |
|
|
static uae_u32 REGPARAM2 frame_host_555_lget(uaecptr) REGPARAM; |
318 |
|
|
static uae_u32 REGPARAM2 frame_host_555_wget(uaecptr) REGPARAM; |
319 |
|
|
static void REGPARAM2 frame_host_555_lput(uaecptr, uae_u32) REGPARAM; |
320 |
|
|
static void REGPARAM2 frame_host_555_wput(uaecptr, uae_u32) REGPARAM; |
321 |
|
|
|
322 |
|
|
static uae_u32 REGPARAM2 frame_host_565_lget(uaecptr) REGPARAM; |
323 |
|
|
static uae_u32 REGPARAM2 frame_host_565_wget(uaecptr) REGPARAM; |
324 |
|
|
static void REGPARAM2 frame_host_565_lput(uaecptr, uae_u32) REGPARAM; |
325 |
|
|
static void REGPARAM2 frame_host_565_wput(uaecptr, uae_u32) REGPARAM; |
326 |
|
|
|
327 |
|
|
static uae_u32 REGPARAM2 frame_host_888_lget(uaecptr) REGPARAM; |
328 |
|
|
static void REGPARAM2 frame_host_888_lput(uaecptr, uae_u32) REGPARAM; |
329 |
|
|
|
330 |
|
|
static uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) REGPARAM; |
331 |
|
|
|
332 |
gbeauche |
1.7 |
static uintptr FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
333 |
cebix |
1.1 |
|
334 |
|
|
uae_u32 REGPARAM2 frame_direct_lget(uaecptr addr) |
335 |
|
|
{ |
336 |
|
|
uae_u32 *m; |
337 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
338 |
|
|
return do_get_mem_long(m); |
339 |
|
|
} |
340 |
|
|
|
341 |
|
|
uae_u32 REGPARAM2 frame_direct_wget(uaecptr addr) |
342 |
|
|
{ |
343 |
|
|
uae_u16 *m; |
344 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
345 |
|
|
return do_get_mem_word(m); |
346 |
|
|
} |
347 |
|
|
|
348 |
|
|
uae_u32 REGPARAM2 frame_direct_bget(uaecptr addr) |
349 |
|
|
{ |
350 |
|
|
return (uae_u32)*(uae_u8 *)(FrameBaseDiff + addr); |
351 |
|
|
} |
352 |
|
|
|
353 |
|
|
void REGPARAM2 frame_direct_lput(uaecptr addr, uae_u32 l) |
354 |
|
|
{ |
355 |
|
|
uae_u32 *m; |
356 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
357 |
|
|
do_put_mem_long(m, l); |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
void REGPARAM2 frame_direct_wput(uaecptr addr, uae_u32 w) |
361 |
|
|
{ |
362 |
|
|
uae_u16 *m; |
363 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
364 |
|
|
do_put_mem_word(m, w); |
365 |
|
|
} |
366 |
|
|
|
367 |
|
|
void REGPARAM2 frame_direct_bput(uaecptr addr, uae_u32 b) |
368 |
|
|
{ |
369 |
|
|
*(uae_u8 *)(FrameBaseDiff + addr) = b; |
370 |
|
|
} |
371 |
|
|
|
372 |
|
|
uae_u32 REGPARAM2 frame_host_555_lget(uaecptr addr) |
373 |
|
|
{ |
374 |
|
|
uae_u32 *m, l; |
375 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
376 |
|
|
l = *m; |
377 |
gbeauche |
1.3 |
return swap_words(l); |
378 |
cebix |
1.1 |
} |
379 |
|
|
|
380 |
|
|
uae_u32 REGPARAM2 frame_host_555_wget(uaecptr addr) |
381 |
|
|
{ |
382 |
|
|
uae_u16 *m; |
383 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
384 |
|
|
return *m; |
385 |
|
|
} |
386 |
|
|
|
387 |
|
|
void REGPARAM2 frame_host_555_lput(uaecptr addr, uae_u32 l) |
388 |
|
|
{ |
389 |
|
|
uae_u32 *m; |
390 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
391 |
gbeauche |
1.3 |
*m = swap_words(l); |
392 |
cebix |
1.1 |
} |
393 |
|
|
|
394 |
|
|
void REGPARAM2 frame_host_555_wput(uaecptr addr, uae_u32 w) |
395 |
|
|
{ |
396 |
|
|
uae_u16 *m; |
397 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
398 |
|
|
*m = w; |
399 |
|
|
} |
400 |
|
|
|
401 |
|
|
uae_u32 REGPARAM2 frame_host_565_lget(uaecptr addr) |
402 |
|
|
{ |
403 |
|
|
uae_u32 *m, l; |
404 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
405 |
|
|
l = *m; |
406 |
|
|
l = (l & 0x001f001f) | ((l >> 1) & 0x7fe07fe0); |
407 |
gbeauche |
1.3 |
return swap_words(l); |
408 |
cebix |
1.1 |
} |
409 |
|
|
|
410 |
|
|
uae_u32 REGPARAM2 frame_host_565_wget(uaecptr addr) |
411 |
|
|
{ |
412 |
|
|
uae_u16 *m, w; |
413 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
414 |
|
|
w = *m; |
415 |
|
|
return (w & 0x1f) | ((w >> 1) & 0x7fe0); |
416 |
|
|
} |
417 |
|
|
|
418 |
|
|
void REGPARAM2 frame_host_565_lput(uaecptr addr, uae_u32 l) |
419 |
|
|
{ |
420 |
|
|
uae_u32 *m; |
421 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
422 |
|
|
l = (l & 0x001f001f) | ((l << 1) & 0xffc0ffc0); |
423 |
gbeauche |
1.3 |
*m = swap_words(l); |
424 |
cebix |
1.1 |
} |
425 |
|
|
|
426 |
|
|
void REGPARAM2 frame_host_565_wput(uaecptr addr, uae_u32 w) |
427 |
|
|
{ |
428 |
|
|
uae_u16 *m; |
429 |
|
|
m = (uae_u16 *)(FrameBaseDiff + addr); |
430 |
|
|
*m = (w & 0x1f) | ((w << 1) & 0xffc0); |
431 |
|
|
} |
432 |
|
|
|
433 |
|
|
uae_u32 REGPARAM2 frame_host_888_lget(uaecptr addr) |
434 |
|
|
{ |
435 |
|
|
uae_u32 *m, l; |
436 |
|
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
437 |
|
|
return *m; |
438 |
|
|
} |
439 |
|
|
|
440 |
|
|
void REGPARAM2 frame_host_888_lput(uaecptr addr, uae_u32 l) |
441 |
|
|
{ |
442 |
|
|
uae_u32 *m; |
443 |
|
|
m = (uae_u32 *)(MacFrameBaseHost + addr - MacFrameBaseMac); |
444 |
|
|
*m = l; |
445 |
|
|
} |
446 |
|
|
|
447 |
|
|
uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) |
448 |
|
|
{ |
449 |
|
|
return (uae_u8 *)(FrameBaseDiff + addr); |
450 |
|
|
} |
451 |
|
|
|
452 |
|
|
/* Default memory access functions */ |
453 |
|
|
|
454 |
|
|
uae_u8 *REGPARAM2 default_xlate (uaecptr a) |
455 |
|
|
{ |
456 |
|
|
write_log("Your Mac program just did something terribly stupid\n"); |
457 |
|
|
return NULL; |
458 |
|
|
} |
459 |
|
|
|
460 |
|
|
/* Address banks */ |
461 |
|
|
|
462 |
|
|
addrbank dummy_bank = { |
463 |
|
|
dummy_lget, dummy_wget, dummy_bget, |
464 |
|
|
dummy_lput, dummy_wput, dummy_bput, |
465 |
gbeauche |
1.9 |
default_xlate |
466 |
cebix |
1.1 |
}; |
467 |
|
|
|
468 |
|
|
addrbank ram_bank = { |
469 |
|
|
ram_lget, ram_wget, ram_bget, |
470 |
|
|
ram_lput, ram_wput, ram_bput, |
471 |
gbeauche |
1.9 |
ram_xlate |
472 |
cebix |
1.1 |
}; |
473 |
|
|
|
474 |
|
|
addrbank ram24_bank = { |
475 |
|
|
ram24_lget, ram24_wget, ram24_bget, |
476 |
|
|
ram24_lput, ram24_wput, ram24_bput, |
477 |
gbeauche |
1.9 |
ram24_xlate |
478 |
cebix |
1.1 |
}; |
479 |
|
|
|
480 |
|
|
addrbank rom_bank = { |
481 |
|
|
rom_lget, rom_wget, rom_bget, |
482 |
|
|
rom_lput, rom_wput, rom_bput, |
483 |
gbeauche |
1.9 |
rom_xlate |
484 |
cebix |
1.1 |
}; |
485 |
|
|
|
486 |
|
|
addrbank rom24_bank = { |
487 |
|
|
rom24_lget, rom24_wget, rom24_bget, |
488 |
|
|
rom_lput, rom_wput, rom_bput, |
489 |
gbeauche |
1.9 |
rom24_xlate |
490 |
cebix |
1.1 |
}; |
491 |
|
|
|
492 |
|
|
addrbank frame_direct_bank = { |
493 |
|
|
frame_direct_lget, frame_direct_wget, frame_direct_bget, |
494 |
|
|
frame_direct_lput, frame_direct_wput, frame_direct_bput, |
495 |
gbeauche |
1.9 |
frame_xlate |
496 |
cebix |
1.1 |
}; |
497 |
|
|
|
498 |
|
|
addrbank frame_host_555_bank = { |
499 |
|
|
frame_host_555_lget, frame_host_555_wget, frame_direct_bget, |
500 |
|
|
frame_host_555_lput, frame_host_555_wput, frame_direct_bput, |
501 |
gbeauche |
1.9 |
frame_xlate |
502 |
cebix |
1.1 |
}; |
503 |
|
|
|
504 |
|
|
addrbank frame_host_565_bank = { |
505 |
|
|
frame_host_565_lget, frame_host_565_wget, frame_direct_bget, |
506 |
|
|
frame_host_565_lput, frame_host_565_wput, frame_direct_bput, |
507 |
gbeauche |
1.9 |
frame_xlate |
508 |
cebix |
1.1 |
}; |
509 |
|
|
|
510 |
|
|
addrbank frame_host_888_bank = { |
511 |
|
|
frame_host_888_lget, frame_direct_wget, frame_direct_bget, |
512 |
|
|
frame_host_888_lput, frame_direct_wput, frame_direct_bput, |
513 |
gbeauche |
1.9 |
frame_xlate |
514 |
cebix |
1.1 |
}; |
515 |
|
|
|
516 |
|
|
void memory_init(void) |
517 |
|
|
{ |
518 |
cebix |
1.4 |
for(long i=0; i<65536; i++) |
519 |
cebix |
1.1 |
put_mem_bank(i<<16, &dummy_bank); |
520 |
|
|
|
521 |
|
|
// Limit RAM size to not overlap ROM |
522 |
|
|
uint32 ram_size = RAMSize > ROMBaseMac ? ROMBaseMac : RAMSize; |
523 |
|
|
|
524 |
gbeauche |
1.7 |
RAMBaseDiff = (uintptr)RAMBaseHost - (uintptr)RAMBaseMac; |
525 |
|
|
ROMBaseDiff = (uintptr)ROMBaseHost - (uintptr)ROMBaseMac; |
526 |
|
|
FrameBaseDiff = (uintptr)MacFrameBaseHost - (uintptr)MacFrameBaseMac; |
527 |
cebix |
1.2 |
|
528 |
|
|
// Map RAM and ROM |
529 |
cebix |
1.1 |
if (TwentyFourBitAddressing) { |
530 |
|
|
map_banks(&ram24_bank, RAMBaseMac >> 16, ram_size >> 16); |
531 |
|
|
map_banks(&rom24_bank, ROMBaseMac >> 16, ROMSize >> 16); |
532 |
|
|
} else { |
533 |
|
|
map_banks(&ram_bank, RAMBaseMac >> 16, ram_size >> 16); |
534 |
|
|
map_banks(&rom_bank, ROMBaseMac >> 16, ROMSize >> 16); |
535 |
|
|
} |
536 |
|
|
|
537 |
cebix |
1.2 |
// Map frame buffer |
538 |
cebix |
1.1 |
switch (MacFrameLayout) { |
539 |
|
|
case FLAYOUT_DIRECT: |
540 |
|
|
map_banks(&frame_direct_bank, MacFrameBaseMac >> 16, (MacFrameSize >> 16) + 1); |
541 |
|
|
break; |
542 |
|
|
case FLAYOUT_HOST_555: |
543 |
|
|
map_banks(&frame_host_555_bank, MacFrameBaseMac >> 16, (MacFrameSize >> 16) + 1); |
544 |
|
|
break; |
545 |
|
|
case FLAYOUT_HOST_565: |
546 |
|
|
map_banks(&frame_host_565_bank, MacFrameBaseMac >> 16, (MacFrameSize >> 16) + 1); |
547 |
|
|
break; |
548 |
|
|
case FLAYOUT_HOST_888: |
549 |
|
|
map_banks(&frame_host_888_bank, MacFrameBaseMac >> 16, (MacFrameSize >> 16) + 1); |
550 |
|
|
break; |
551 |
|
|
} |
552 |
|
|
} |
553 |
|
|
|
554 |
|
|
void map_banks(addrbank *bank, int start, int size) |
555 |
|
|
{ |
556 |
|
|
int bnr; |
557 |
|
|
unsigned long int hioffs = 0, endhioffs = 0x100; |
558 |
|
|
|
559 |
|
|
if (start >= 0x100) { |
560 |
|
|
for (bnr = start; bnr < start + size; bnr++) |
561 |
|
|
put_mem_bank (bnr << 16, bank); |
562 |
|
|
return; |
563 |
|
|
} |
564 |
|
|
if (TwentyFourBitAddressing) endhioffs = 0x10000; |
565 |
|
|
for (hioffs = 0; hioffs < endhioffs; hioffs += 0x100) |
566 |
|
|
for (bnr = start; bnr < start+size; bnr++) |
567 |
|
|
put_mem_bank((bnr + hioffs) << 16, bank); |
568 |
|
|
} |
569 |
gbeauche |
1.3 |
|
570 |
|
|
#endif /* !REAL_ADDRESSING && !DIRECT_ADDRESSING */ |
571 |
|
|
|