ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/uae_cpu/memory.cpp
Revision: 1.2
Committed: 1999-11-03T10:56:43Z (24 years, 8 months ago) by cebix
Branch: MAIN
CVS Tags: snapshot-13072000, snapshot-22121999, release-0_8-1
Changes since 1.1: +10 -7 lines
Log Message:
- imported UAE CPU 0.8.10 changes
- new utility functions Mac_memset, Mac2Host_memcpy, Host2Mac_memcpu and
  Mac2Mac_memcpy
- extfs.cpp: fixed bug in fs_rename() and fs_cat_move() (auxiliary IOParam
  block was not in Mac address space)
- some provisions for using UAE CPU compiler (doesn't work yet)

File Contents

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