12 |
|
#include "sysdeps.h" |
13 |
|
|
14 |
|
#include "cpu_emulation.h" |
15 |
+ |
#include "main.h" |
16 |
+ |
#include "video.h" |
17 |
+ |
|
18 |
|
#include "m68k.h" |
19 |
|
#include "memory.h" |
20 |
|
#include "readcpu.h" |
21 |
|
#include "newcpu.h" |
22 |
< |
#include "main.h" |
23 |
< |
#include "video.h" |
22 |
> |
|
23 |
> |
#if !REAL_ADDRESSING && !DIRECT_ADDRESSING |
24 |
|
|
25 |
|
static bool illegal_mem = false; |
26 |
|
|
30 |
|
addrbank mem_banks[65536]; |
31 |
|
#endif |
32 |
|
|
33 |
+ |
#ifdef WORDS_BIGENDIAN |
34 |
+ |
# define swap_words(X) (X) |
35 |
+ |
#else |
36 |
+ |
# define swap_words(X) (((X) >> 16) | ((X) << 16)) |
37 |
+ |
#endif |
38 |
+ |
|
39 |
|
#ifdef NO_INLINE_MEMORY_ACCESS |
40 |
|
__inline__ uae_u32 longget (uaecptr addr) |
41 |
|
{ |
132 |
|
static int REGPARAM2 ram_check(uaecptr addr, uae_u32 size) REGPARAM; |
133 |
|
static uae_u8 *REGPARAM2 ram_xlate(uaecptr addr) REGPARAM; |
134 |
|
|
135 |
< |
static uae_u32 RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
135 |
> |
static uintptr RAMBaseDiff; // RAMBaseHost - RAMBaseMac |
136 |
|
|
137 |
|
uae_u32 REGPARAM2 ram_lget(uaecptr addr) |
138 |
|
{ |
252 |
|
static int REGPARAM2 rom_check(uaecptr addr, uae_u32 size) REGPARAM; |
253 |
|
static uae_u8 *REGPARAM2 rom_xlate(uaecptr addr) REGPARAM; |
254 |
|
|
255 |
< |
static uae_u32 ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
255 |
> |
static uintptr ROMBaseDiff; // ROMBaseHost - ROMBaseMac |
256 |
|
|
257 |
|
uae_u32 REGPARAM2 rom_lget(uaecptr addr) |
258 |
|
{ |
363 |
|
static int REGPARAM2 frame_check(uaecptr addr, uae_u32 size) REGPARAM; |
364 |
|
static uae_u8 *REGPARAM2 frame_xlate(uaecptr addr) REGPARAM; |
365 |
|
|
366 |
< |
static uae_u32 FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
366 |
> |
static uintptr FrameBaseDiff; // MacFrameBaseHost - MacFrameBaseMac |
367 |
|
|
368 |
|
uae_u32 REGPARAM2 frame_direct_lget(uaecptr addr) |
369 |
|
{ |
408 |
|
uae_u32 *m, l; |
409 |
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
410 |
|
l = *m; |
411 |
< |
return (l >> 16) | (l << 16); |
411 |
> |
return swap_words(l); |
412 |
|
} |
413 |
|
|
414 |
|
uae_u32 REGPARAM2 frame_host_555_wget(uaecptr addr) |
422 |
|
{ |
423 |
|
uae_u32 *m; |
424 |
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
425 |
< |
*m = (l >> 16) | (l << 16); |
425 |
> |
*m = swap_words(l); |
426 |
|
} |
427 |
|
|
428 |
|
void REGPARAM2 frame_host_555_wput(uaecptr addr, uae_u32 w) |
438 |
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
439 |
|
l = *m; |
440 |
|
l = (l & 0x001f001f) | ((l >> 1) & 0x7fe07fe0); |
441 |
< |
return (l >> 16) | (l << 16); |
441 |
> |
return swap_words(l); |
442 |
|
} |
443 |
|
|
444 |
|
uae_u32 REGPARAM2 frame_host_565_wget(uaecptr addr) |
454 |
|
uae_u32 *m; |
455 |
|
m = (uae_u32 *)(FrameBaseDiff + addr); |
456 |
|
l = (l & 0x001f001f) | ((l << 1) & 0xffc0ffc0); |
457 |
< |
*m = (l >> 16) | (l << 16); |
457 |
> |
*m = swap_words(l); |
458 |
|
} |
459 |
|
|
460 |
|
void REGPARAM2 frame_host_565_wput(uaecptr addr, uae_u32 w) |
559 |
|
|
560 |
|
void memory_init(void) |
561 |
|
{ |
562 |
< |
int i; |
554 |
< |
for(i=0; i<65536; i++) |
562 |
> |
for(long i=0; i<65536; i++) |
563 |
|
put_mem_bank(i<<16, &dummy_bank); |
564 |
|
|
557 |
– |
RAMBaseDiff = (uae_u32)RAMBaseHost - (uae_u32)RAMBaseMac; |
558 |
– |
ROMBaseDiff = (uae_u32)ROMBaseHost - (uae_u32)ROMBaseMac; |
559 |
– |
FrameBaseDiff = (uae_u32)MacFrameBaseHost - (uae_u32)MacFrameBaseMac; |
560 |
– |
|
565 |
|
// Limit RAM size to not overlap ROM |
562 |
– |
#if REAL_ADDRESSING |
563 |
– |
uint32 ram_size = RAMSize; |
564 |
– |
#else |
566 |
|
uint32 ram_size = RAMSize > ROMBaseMac ? ROMBaseMac : RAMSize; |
566 |
– |
#endif |
567 |
|
|
568 |
< |
// RAM and ROM |
568 |
> |
RAMBaseDiff = (uintptr)RAMBaseHost - (uintptr)RAMBaseMac; |
569 |
> |
ROMBaseDiff = (uintptr)ROMBaseHost - (uintptr)ROMBaseMac; |
570 |
> |
FrameBaseDiff = (uintptr)MacFrameBaseHost - (uintptr)MacFrameBaseMac; |
571 |
> |
|
572 |
> |
// Map RAM and ROM |
573 |
|
if (TwentyFourBitAddressing) { |
574 |
|
map_banks(&ram24_bank, RAMBaseMac >> 16, ram_size >> 16); |
575 |
|
map_banks(&rom24_bank, ROMBaseMac >> 16, ROMSize >> 16); |
578 |
|
map_banks(&rom_bank, ROMBaseMac >> 16, ROMSize >> 16); |
579 |
|
} |
580 |
|
|
581 |
< |
// Frame buffer |
581 |
> |
// Map frame buffer |
582 |
|
switch (MacFrameLayout) { |
583 |
|
case FLAYOUT_DIRECT: |
584 |
|
map_banks(&frame_direct_bank, MacFrameBaseMac >> 16, (MacFrameSize >> 16) + 1); |
610 |
|
for (bnr = start; bnr < start+size; bnr++) |
611 |
|
put_mem_bank((bnr + hioffs) << 16, bank); |
612 |
|
} |
613 |
+ |
|
614 |
+ |
#endif /* !REAL_ADDRESSING && !DIRECT_ADDRESSING */ |
615 |
+ |
|