1 #include "../PicoInt.h"
4 typedef unsigned char u8;
5 typedef unsigned short u16;
6 typedef unsigned int u32;
10 // -----------------------------------------------------------------
11 // Read Rom and read Ram
13 static u32 PicoReadPico8(u32 a)
17 if ((a&0xe00000)==0xe00000) { d = *(u8 *)(Pico.ram+((a^1)&0xffff)); goto end; } // Ram
18 if (a<Pico.romsize) { d = *(u8 *)(Pico.rom+(a^1)); goto end; } // Rom
22 if ((a&0xffffe0)==0xc00000) { // VDP
28 elprintf(EL_UIO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
31 elprintf(EL_IO, "r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
35 static u32 PicoReadPico16(u32 a)
39 if ((a&0xe00000)==0xe00000) { d=*(u16 *)(Pico.ram+(a&0xfffe)); goto end; } // Ram
43 if (a<Pico.romsize) { d = *(u16 *)(Pico.rom+a); goto end; } // Rom
45 if ((a&0xffffe0)==0xc00000) {
50 elprintf(EL_UIO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
53 elprintf(EL_IO, "r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
57 static u32 PicoReadPico32(u32 a)
61 if ((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); d = (pm[0]<<16)|pm[1]; goto end; } // Ram
65 if (a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+a); d = (pm[0]<<16)|pm[1]; goto end; } // Rom
67 if ((a&0xffffe0)==0xc00000) {
68 d = (PicoVideoRead(a)<<16)|PicoVideoRead(a+2);
72 elprintf(EL_UIO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
75 elprintf(EL_IO, "r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
79 // -----------------------------------------------------------------
82 static void PicoWritePico8(u32 a,u8 d)
84 elprintf(EL_IO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
86 if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram
89 if ((a&0xffffe0)==0xc00000) { // VDP
91 PicoVideoWrite(a,(u16)(d|(d<<8))); // Byte access gets mirrored
95 elprintf(EL_UIO, "w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
98 static void PicoWritePico16(u32 a,u16 d)
100 elprintf(EL_IO, "w16: %06x, %04x", a&0xffffff, d);
102 if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram
105 if ((a&0xffffe0)==0xc00000) { PicoVideoWrite(a,(u16)d); return; } // VDP
107 elprintf(EL_UIO, "w16: %06x, %04x", a&0xffffff, d);
110 static void PicoWritePico32(u32 a,u32 d)
112 elprintf(EL_IO, "w32: %06x, %08x", a&0xffffff, d);
114 if ((a&0xe00000)==0xe00000)
117 u16 *pm=(u16 *)(Pico.ram+(a&0xfffe));
118 pm[0]=(u16)(d>>16); pm[1]=(u16)d;
123 if ((a&0xffffe0)==0xc00000)
126 PicoVideoWrite(a, (u16)(d>>16));
127 PicoVideoWrite(a+2,(u16)d);
131 elprintf(EL_UIO, "w32: %06x, %08x", a&0xffffff, d);
135 extern unsigned int (*pm68k_read_memory_8) (unsigned int address);
136 extern unsigned int (*pm68k_read_memory_16)(unsigned int address);
137 extern unsigned int (*pm68k_read_memory_32)(unsigned int address);
138 extern void (*pm68k_write_memory_8) (unsigned int address, unsigned char value);
139 extern void (*pm68k_write_memory_16)(unsigned int address, unsigned short value);
140 extern void (*pm68k_write_memory_32)(unsigned int address, unsigned int value);
141 extern unsigned int (*pm68k_read_memory_pcr_8) (unsigned int address);
142 extern unsigned int (*pm68k_read_memory_pcr_16)(unsigned int address);
143 extern unsigned int (*pm68k_read_memory_pcr_32)(unsigned int address);
145 static unsigned int m68k_read_memory_pcrp_8(unsigned int a)
147 if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
151 static unsigned int m68k_read_memory_pcrp_16(unsigned int a)
153 if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
157 static unsigned int m68k_read_memory_pcrp_32(unsigned int a)
159 if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
165 PICO_INTERNAL void PicoMemSetupPico(void)
168 pm68k_read_memory_8 = PicoReadPico8;
169 pm68k_read_memory_16 = PicoReadPico16;
170 pm68k_read_memory_32 = PicoReadPico32;
171 pm68k_write_memory_8 = PicoWritePico8;
172 pm68k_write_memory_16 = PicoWritePico16;
173 pm68k_write_memory_32 = PicoWritePico32;
174 pm68k_read_memory_pcr_8 = m68k_read_memory_pcrp_8;
175 pm68k_read_memory_pcr_16 = m68k_read_memory_pcrp_16;
176 pm68k_read_memory_pcr_32 = m68k_read_memory_pcrp_32;