From d82960c553cba8404715877afb61e85820108f02 Mon Sep 17 00:00:00 2001 From: zeromus Date: Wed, 6 Aug 2008 09:36:48 +0000 Subject: [PATCH] fix the rest of kuja's issues --- src/boards/mmc5.cpp | 58 ++++++++++++++++++++++++++++----------------- src/ppu.cpp | 15 +++++++++++- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/boards/mmc5.cpp b/src/boards/mmc5.cpp index 5ec9e3c6..62de7966 100644 --- a/src/boards/mmc5.cpp +++ b/src/boards/mmc5.cpp @@ -52,7 +52,7 @@ static uint8 PRGBanks[4]; static uint8 WRAMPage; static uint8 CHRBanksA[8], CHRBanksB[4]; static uint8 WRAMMaskEnable[2]; -static uint8 ABMode; /* A=0, B=1 */ +uint8 mmc5ABMode; /* A=0, B=1 */ static uint8 IRQScanline,IRQEnable; static uint8 CHRMode, NTAMirroring, NTFill, ATFill; @@ -128,17 +128,24 @@ int DetectMMC5WRAMSize(uint32 crc32) static void BuildWRAMSizeTable(void) { - int x; - for(x=0;x<8;x++) - { - switch(MMC5WRAMsize) - { - case 0: MMC5WRAMIndex[x]=255; break; - case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break; - case 2: MMC5WRAMIndex[x]=(x&4)>>2; break; - case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break; - } - } + int x; + for(x=0;x<8;x++) + { + switch(MMC5WRAMsize) + { + case 0: MMC5WRAMIndex[x]=255; break; //X,X,X,X,X,X,X,X + case 1: MMC5WRAMIndex[x]=(x>3)?255:0; break; //0,0,0,0,X,X,X,X + case 2: MMC5WRAMIndex[x]=(x&4)>>2; break; //0,0,0,0,1,1,1,1 + case 4: MMC5WRAMIndex[x]=(x>3)?255:(x&3); break; //0,1,2,3,X,X,X,X + case 8: MMC5WRAMIndex[x]=x; break; //0,1,2,3,4,5,6,7,8 + //mbg 8/6/08 - i added this to support 64KB of wram + //now, I have at least one example (laser invasion) which actually uses size 1 but isnt in the crc list + //so, whereas before my change on 8/4/08 we would have selected size 1, now we select size 8 + //this means that we could have just introduced an emulation bug, in case those games happened to + //address, say, page 3. with size 1 that would resolve to [0] but in size 8 it resolves to [3]. + //so, you know what to do if there are problems. + } + } } static void MMC5CHRA(void) @@ -293,7 +300,7 @@ static DECLFW(Mapper5_write) { if(A>=0x5120&&A<=0x5127) { - ABMode = 0; + mmc5ABMode = 0; CHRBanksA[A&7]=V; MMC5CHRA(); } @@ -305,10 +312,14 @@ static DECLFW(Mapper5_write) { switch((V>>(x<<1))&3) { - case 0:PPUNTARAM|=1<>10][(V)] -#define MMC5BGVRAMADR(V) &MMC5BGVPage[(V)>>10][(V)] #define VRAMADR(V) &VPage[(V)>>10][(V)] +//mbg 8/6/08 - fix a bug relating to +//"When in 8x8 sprite mode, only one set is used for both BG and sprites." +//in mmc5 docs +uint8 * MMC5BGVRAMADR(uint32 V) { + if(!Sprite16) { + extern uint8 mmc5ABMode; /* A=0, B=1 */ + if(mmc5ABMode==0) + return MMC5SPRVRAMADR(V); + else + return &MMC5BGVPage[(V)>>10][(V)]; + } else return &MMC5BGVPage[(V)>>10][(V)]; +} static DECLFR(A2002) {