X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?p=fceu.git;a=blobdiff_plain;f=cart.c;h=0dd8fee24c2dcd7d0487674f16376f9aed42a999;hp=ff9aceb7aa977c3827ce11dafcf0530f0243fa45;hb=d0f72c9ab3d6acf18f236970c1c359fafa3e1ce7;hpb=92764e6252a3691033d6044b466bf716c96b62d5 diff --git a/cart.c b/cart.c index ff9aceb..0dd8fee 100644 --- a/cart.c +++ b/cart.c @@ -22,6 +22,10 @@ #include #include +#ifdef GP2X +#include // for sync() +#endif + #include "types.h" #include "fce.h" #include "ppu.h" @@ -167,6 +171,7 @@ void FASTAPASS(3) setprg2r(int r, unsigned int A, unsigned int V) { V&=PRGmask2[r]; setpageptr(2,A,PRGptr[r]?(&PRGptr[r][V<<11]):0,PRGram[r]); + X6502_Rebase(); } void FASTAPASS(2) setprg2(uint32 A, uint32 V) @@ -178,6 +183,7 @@ void FASTAPASS(3) setprg4r(int r, unsigned int A, unsigned int V) { V&=PRGmask4[r]; setpageptr(4,A,PRGptr[r]?(&PRGptr[r][V<<12]):0,PRGram[r]); + X6502_Rebase(); } void FASTAPASS(2) setprg4(uint32 A, uint32 V) @@ -199,6 +205,7 @@ void FASTAPASS(3) setprg8r(int r, unsigned int A, unsigned int V) for(x=0;x<4;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg8(uint32 A, uint32 V) @@ -221,6 +228,7 @@ void FASTAPASS(3) setprg16r(int r, unsigned int A, unsigned int V) for(x=0;x<8;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg16(uint32 A, uint32 V) @@ -243,6 +251,7 @@ void FASTAPASS(3) setprg32r(int r,unsigned int A, unsigned int V) for(x=0;x<16;x++) setpageptr(2,A+(x<<11),PRGptr[r]?(&PRGptr[r][((VA+x)&PRGmask2[r])<<11]):0,PRGram[r]); } + X6502_Rebase(); } void FASTAPASS(2) setprg32(uint32 A, uint32 V) @@ -637,6 +646,24 @@ void GeniePower(void) geniestage=2; } +static uint8 *real_pages[16]; + +void GenieSetPages(int restore) +{ + int page; + if (restore) + { + for (page=16; page<32; page++) + Page[page] = real_pages[page-16]; + } + else + { + for (page=16; page<32; page++) { + real_pages[page-16] = Page[page]; + Page[page]=GENIEROM - (page<<11) + ((page&1)<<11); + } + } +} void FCEU_SaveGameSave(CartInfo *LocalHWInfo) { @@ -660,6 +687,10 @@ void FCEU_SaveGameSave(CartInfo *LocalHWInfo) fwrite(LocalHWInfo->SaveGame[x],1, LocalHWInfo->SaveGameLen[x],sp); } + fclose(sp); +#ifdef GP2X + sync(); +#endif } free(soot); } @@ -683,9 +714,28 @@ void FCEU_LoadGameSave(CartInfo *LocalHWInfo) for(x=0;x<4;x++) if(LocalHWInfo->SaveGame[x]) fread(LocalHWInfo->SaveGame[x],1,LocalHWInfo->SaveGameLen[x],sp); + fclose(sp); } free(soot); } } +void DumpEmptyCartMapping(void) +{ + int x, st=0, end=-1; + + for(x=8;x<32;x++) + { + if (Page[x] == (nothing-x*2048) || Page[x] == 0) + { + if (end != x) st=x; + end=x+1; + } + if (end == x) + printf("DumpEmptyCartMapping: %04x-%04x\n", st*2048, end*2048-1); + } + if (end==32) + printf("DumpEmptyCartMapping: %04x-%04x\n", st*2048, end*2048-1); +} +