extern const unsigned short vcounts[];\r
extern int rendstatus;\r
\r
+typedef unsigned char u8;\r
typedef unsigned short u16;\r
\r
\r
SekSetCyclesLeft(SekCyclesLeft - (len*(((488<<8)/167))>>8));\r
}\r
\r
- if ((source&0xe00000)==0xe00000) { pd=(u16 *)(Pico.ram+(source&0xfffe)); pdend=(u16 *)(Pico.ram+0x10000); } // Ram\r
- else if(PicoMCD & 1) {\r
- if(source<0x20000) { pd=(u16 *)(Pico_mcd->bios+(source&~1)); pdend=(u16 *)(Pico_mcd->bios+0x20000); } // Bios area\r
- else { dprintf("unsupported src"); return; } // Invalid source address\r
+ if ((source&0xe00000)==0xe00000) { // Ram\r
+ pd=(u16 *)(Pico.ram+(source&0xfffe));\r
+ pdend=(u16 *)(Pico.ram+0x10000);\r
+ } else if(PicoMCD & 1) {\r
+ dprintf("DmaSlow CD");\r
+ if(source<0x20000) { // Bios area\r
+ pd=(u16 *)(Pico_mcd->bios+(source&~1));\r
+ pdend=(u16 *)(Pico_mcd->bios+0x20000);\r
+ } else if ((source&0xfc0000)==0x200000 && (!(Pico_mcd->s68k_regs[3]&4))) { // Word Ram\r
+ if (!(Pico_mcd->s68k_regs[3]&4)) { // 2M mode\r
+ pd=(u16 *)(Pico_mcd->word_ram+(source&0x3fffe));\r
+ pdend=(u16 *)(Pico_mcd->word_ram+0x40000);\r
+ } else {\r
+ dprintf("DmaSlow: unsupported src");\r
+ return;\r
+ }\r
+ } else if ((source&0xfe0000)==0x020000) { // Prg Ram\r
+ u8 *prg_ram = Pico_mcd->prg_ram_b[Pico_mcd->s68k_regs[3]>>6];\r
+ pd=(u16 *)(prg_ram+(source&0x1fffe));\r
+ pdend=(u16 *)(prg_ram+0x20000);\r
+ } else {\r
+ dprintf("DmaSlow: unsupported src");\r
+ return;\r
+ }\r
} else {\r
- if(source<Pico.romsize) { pd=(u16 *)(Pico.rom+(source&~1)); pdend=(u16 *)(Pico.rom+Pico.romsize); } // Rom\r
- else { dprintf("invalid dma src"); return; } // Invalid source address\r
+ if(source<Pico.romsize) { // Rom\r
+ pd=(u16 *)(Pico.rom+(source&~1));\r
+ pdend=(u16 *)(Pico.rom+Pico.romsize);\r
+ } else {\r
+ dprintf("DmaSlow: invalid dma src");\r
+ return;\r
+ }\r
+ }\r
+\r
+ // overflow protection, might break something..\r
+ if (len > pdend - pd) {\r
+ len = pdend - pd;\r
+ dprintf("DmaSlow overflow");\r
}\r
\r
switch (Pico.video.type)\r
// AutoIncrement\r
a=(u16)(a+inc);\r
// didn't src overlap?\r
- if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM\r
+ //if(pd >= pdend) pd-=0x8000; // should be good for RAM, bad for ROM\r
}\r
rendstatus|=0x10;\r
break;\r
// AutoIncrement\r
a2+=inc;\r
// didn't src overlap?\r
- if(pd >= pdend) pd-=0x8000;\r
+ //if(pd >= pdend) pd-=0x8000;\r
// good dest?\r
if(a2 >= 0x80) break; // Todds Adventures in Slime World / Andre Agassi tennis\r
}\r
// AutoIncrement\r
a2+=inc;\r
// didn't src overlap?\r
- if(pd >= pdend) pd-=0x8000;\r
+ //if(pd >= pdend) pd-=0x8000;\r
// good dest?\r
if(a2 >= 0x80) break;\r
}\r
\r
//#define __debug_io\r
//#define __debug_io2\r
-//#define rdprintf dprintf\r
-#define rdprintf(...)\r
+#define rdprintf dprintf\r
+//#define rdprintf(...)\r
\r
// -----------------------------------------------------------------\r
\r
return (u8)d;\r
}\r
\r
+\r
u16 PicoReadM68k16(u32 a)\r
{\r
u16 d=0;\r
return d;\r
}\r
\r
+\r
u32 PicoReadM68k32(u32 a)\r
{\r
u32 d=0;\r
if (a >= 0x220000) {\r
dprintf("cell");\r
} else {\r
- u16 *pm;\r
a=((a&0x1fffe)<<1);\r
if (Pico_mcd->s68k_regs[3]&1) a+=2;\r
- pm=(u16 *)(Pico_mcd->word_ram+a);\r
- d = (pm[0]<<16)|pm[1];\r
+ d = *(u16 *)(Pico_mcd->word_ram+a) << 16;\r
+ d |= *(u16 *)(Pico_mcd->word_ram+a+4);\r
}\r
} else {\r
// allow access in any mode, like Gens does\r
return d;\r
}\r
\r
+\r
// -----------------------------------------------------------------\r
// Write Ram\r
\r
// dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
\r
\r
- if ((a&0xe00000)==0xe00000) { u8 *pm=(u8 *)(Pico.ram+((a^1)&0xffff)); pm[0]=d; return; } // Ram\r
+ if ((a&0xe00000)==0xe00000) { // Ram\r
+ *(u8 *)(Pico.ram+((a^1)&0xffff)) = d;\r
+ return;\r
+ }\r
\r
a&=0xffffff;\r
\r
OtherWrite8(a,d,8);\r
}\r
\r
+\r
void PicoWriteM68k16(u32 a,u16 d)\r
{\r
#ifdef __debug_io\r
#endif\r
// dprintf("w16: %06x, %04x @%06x", a&0xffffff, d, SekPc);\r
\r
- if ((a&0xe00000)==0xe00000) { *(u16 *)(Pico.ram+(a&0xfffe))=d; return; } // Ram\r
+ if ((a&0xe00000)==0xe00000) { // Ram\r
+ *(u16 *)(Pico.ram+(a&0xfffe))=d;\r
+ return;\r
+ }\r
\r
a&=0xfffffe;\r
\r
OtherWrite16(a,d);\r
}\r
\r
+\r
void PicoWriteM68k32(u32 a,u32 d)\r
{\r
#ifdef __debug_io\r
if (a >= 0x220000) {\r
dprintf("cell");\r
} else {\r
- u16 *pm;\r
a=((a&0x1fffe)<<1);\r
if (Pico_mcd->s68k_regs[3]&1) a+=2;\r
- pm=(u16 *)(Pico_mcd->word_ram+a);\r
- pm[0]=(u16)(d>>16); pm[1]=(u16)d;\r
+ *(u16 *)(Pico_mcd->word_ram+a) = d>>16;\r
+ *(u16 *)(Pico_mcd->word_ram+a+4) = d;\r
}\r
} else {\r
// allow access in any mode, like Gens does\r
if ((a&0xffffc0)==0xa12000)\r
rdprintf("m68k_regs w32: [%02x] %08x @%06x", a&0x3f, d, SekPc);\r
\r
+#if 0\r
+ if ((a&0x3f) == 0x1c && SekPc == 0xffff05ba)\r
+ {\r
+ int i;\r
+ FILE *ff;\r
+ unsigned short *ram = (unsigned short *) Pico.ram;\r
+ // unswap and dump RAM\r
+ for (i = 0; i < 0x10000/2; i++)\r
+ ram[i] = (ram[i]>>8) | (ram[i]<<8);\r
+ ff = fopen("ram.bin", "wb");\r
+ fwrite(ram, 1, 0x10000, ff);\r
+ fclose(ff);\r
+ exit(0);\r
+ }\r
+#endif\r
+\r
OtherWrite16(a, (u16)(d>>16));\r
OtherWrite16(a+2,(u16)d);\r
}\r
goto end;\r
}\r
\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ d = Pico_mcd->bram[(a>>1)&0x1fff];\r
+ goto end;\r
+ }\r
+\r
dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);\r
\r
end:\r
return (u8)d;\r
}\r
\r
+\r
u16 PicoReadS68k16(u32 a)\r
{\r
u16 d=0;\r
// allow access in any mode, like Gens does\r
d = *(u16 *)(Pico_mcd->word_ram+(a&0x3fffe));\r
}\r
- dprintf("ret = %04x", (u8)d);\r
+ dprintf("ret = %04x", d);\r
goto end;\r
}\r
\r
a=((a&0x1fffe)<<1);\r
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;\r
d = *(u16 *)(Pico_mcd->word_ram+a);\r
- dprintf("ret = %04x", (u8)d);\r
+ dprintf("ret = %04x", d);\r
+ goto end;\r
+ }\r
+\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ dprintf("s68k_bram r16: [%06x] @%06x", a, SekPc);\r
+ a = (a>>1)&0x1fff;\r
+ d = Pico_mcd->bram[a++]; // Gens does little endian here, an so do we..\r
+ d|= Pico_mcd->bram[a++] << 8;\r
+ dprintf("ret = %04x", d);\r
goto end;\r
}\r
\r
return d;\r
}\r
\r
+\r
u32 PicoReadS68k32(u32 a)\r
{\r
u32 d=0;\r
// allow access in any mode, like Gens does\r
u16 *pm=(u16 *)(Pico_mcd->word_ram+(a&0x3fffe)); d = (pm[0]<<16)|pm[1];\r
}\r
- dprintf("ret = %08x", (u8)d);\r
+ dprintf("ret = %08x", d);\r
goto end;\r
}\r
\r
// word RAM (1M area)\r
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
- u16 *pm;\r
- dprintf("s68k_wram1M 32: [%06x] @%06x", a, SekPc);\r
+ dprintf("s68k_wram1M r32: [%06x] @%06x", a, SekPc);\r
a=((a&0x1fffe)<<1);\r
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;\r
- pm=(u16 *)(Pico_mcd->word_ram+a);\r
- d = (pm[0]<<16)|pm[1];\r
- dprintf("ret = %08x", (u8)d);\r
+ d = *(u16 *)(Pico_mcd->word_ram+a) << 16;\r
+ d |= *(u16 *)(Pico_mcd->word_ram+a+4);\r
+ dprintf("ret = %08x", d);\r
+ goto end;\r
+ }\r
+\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ dprintf("s68k_bram r32: [%06x] @%06x", a, SekPc);\r
+ a = (a>>1)&0x1fff;\r
+ d = Pico_mcd->bram[a++] << 16; // middle endian? TODO: verify against Fusion..\r
+ d|= Pico_mcd->bram[a++] << 24;\r
+ d|= Pico_mcd->bram[a++];\r
+ d|= Pico_mcd->bram[a++] << 8;\r
+ dprintf("ret = %08x", d);\r
goto end;\r
}\r
\r
return d;\r
}\r
\r
+\r
// -----------------------------------------------------------------\r
\r
void PicoWriteS68k8(u32 a,u8 d)\r
return;\r
}\r
\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ Pico_mcd->bram[(a>>1)&0x1fff] = d;\r
+ SRam.changed = 1;\r
+ return;\r
+ }\r
+\r
dprintf("s68k w8 : %06x, %02x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
\r
+\r
void PicoWriteS68k16(u32 a,u16 d)\r
{\r
#ifdef __debug_io2\r
return;\r
}\r
\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ dprintf("s68k_bram w16: [%06x] %04x @%06x", a, d, SekPc);\r
+ a = (a>>1)&0x1fff;\r
+ Pico_mcd->bram[a++] = d; // Gens does little endian here, an so do we..\r
+ Pico_mcd->bram[a++] = d >> 8;\r
+ SRam.changed = 1;\r
+ return;\r
+ }\r
+\r
dprintf("s68k w16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
\r
+\r
void PicoWriteS68k32(u32 a,u32 d)\r
{\r
#ifdef __debug_io2\r
\r
// word RAM (1M area)\r
if ((a&0xfe0000)==0x0c0000 && (Pico_mcd->s68k_regs[3]&4)) { // 0c0000-0dffff\r
- u16 *pm;\r
if (d)\r
dprintf("s68k_wram1M w32: [%06x] %08x @%06x", a, d, SekPc);\r
a=((a&0x1fffe)<<1);\r
if (!(Pico_mcd->s68k_regs[3]&1)) a+=2;\r
- pm=(u16 *)(Pico_mcd->word_ram+a);\r
- pm[0]=(u16)(d>>16); pm[1]=(u16)d;\r
+ *(u16 *)(Pico_mcd->word_ram+a) = d>>16;\r
+ *(u16 *)(Pico_mcd->word_ram+a+4) = d;\r
return;\r
}\r
+\r
+ // bram\r
+ if ((a&0xff0000)==0xfe0000) {\r
+ dprintf("s68k_bram w32: [%06x] %08x @%06x", a, d, SekPc);\r
+ a = (a>>1)&0x1fff;\r
+ Pico_mcd->bram[a++] = d >> 16; // middle endian? verify?\r
+ Pico_mcd->bram[a++] = d >> 24;\r
+ Pico_mcd->bram[a++] = d;\r
+ Pico_mcd->bram[a++] = d >> 8;\r
+ SRam.changed = 1;\r
+ return;\r
+ }\r
+\r
dprintf("s68k w32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);\r
}\r
\r
}\r
if (do_it) {\r
blit("", (which & 0x1000) ? "LOADING GAME" : "SAVING GAME");\r
- if(movie_data) {\r
- }\r
emu_SaveLoadGame(which & 0x1000, 0);\r
}\r
\r
\r
// make save filename\r
romfname_ext(saveFname, "");\r
- if(sram) strcat(saveFname, ".srm");\r
+ if(sram) strcat(saveFname, (PicoMCD&1) ? ".brm" : ".srm");\r
else {\r
if(state_slot > 0 && state_slot < 10) sprintf(saveFname, "%s.%i", saveFname, state_slot);\r
strcat(saveFname, ".mds");\r
\r
if(sram) {\r
FILE *sramFile;\r
- int sram_size = SRam.end-SRam.start+1;\r
- if(SRam.reg_back & 4) sram_size=0x2000;\r
- if(!SRam.data) return 0; // SRam forcefully disabled for this game\r
+ int sram_size;\r
+ unsigned char *sram_data;\r
+ if (PicoMCD&1) {\r
+ sram_size = 0x2000;\r
+ sram_data = Pico_mcd->bram;\r
+ } else {\r
+ sram_size = SRam.end-SRam.start+1;\r
+ if(SRam.reg_back & 4) sram_size=0x2000;\r
+ sram_data = SRam.data;\r
+ }\r
+ if(!sram_data) return 0; // SRam forcefully disabled for this game\r
+\r
if(load) {\r
sramFile = fopen(saveFname, "rb");\r
if(!sramFile) return -1;\r
- fread(SRam.data, 1, sram_size, sramFile);\r
+ fread(sram_data, 1, sram_size, sramFile);\r
fclose(sramFile);\r
} else {\r
// sram save needs some special processing\r
// see if we have anything to save\r
for(; sram_size > 0; sram_size--)\r
- if(SRam.data[sram_size-1]) break;\r
+ if(sram_data[sram_size-1]) break;\r
\r
if(sram_size) {\r
sramFile = fopen(saveFname, "wb");\r
- ret = fwrite(SRam.data, 1, sram_size, sramFile);\r
+ ret = fwrite(sram_data, 1, sram_size, sramFile);\r
ret = (ret != sram_size) ? -1 : 0;\r
fclose(sramFile);\r
sync();\r
}\r
}\r
return ret;\r
- } else {\r
+ }\r
+ else\r
+ {\r
void *PmovFile = NULL;\r
// try gzip first\r
if(currentConfig.EmuOpt & 8) {\r