diff --git a/README.md b/README.md index 6f32916..8104b6e 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ If you want to check it out for some reason I do include a windows binary in the Loading Files: NTSC and PAL .nes ROMs are supported, it also creates .sav files if the chosen game supports saving. -If you are starting a PAL NES title then make sure it has (E),(Europe),(Australia),(France),(Germany),(Italy),(Spain) or (Sweden) in the filename to be started in PAL mode. +If you are starting a PAL NES title then make sure it has (E),(Europe),(PAL),(Australia),(France),(Germany),(Italy),(Spain) or (Sweden) in the filename to be started in PAL mode. You can also play FDS titles if you have the FDS BIOS named disksys.rom in the same folder as your .fds/.qd files. You can also listen to .nsf music files, changing tracks works by pressing left/right. To start a file, simply drag and drop it into the fixNES Application or call it via command line with the file as argument. You can also load from a .zip file, the first found supported file from that .zip will be used. Supported .nes Mappers: -0,1,2,3,4,5,7,9,10,11,12,13,15,19,21,22,23,24,25,26,32,33,34,36,37,38,41,44,45,46,47,48,49,52,57,58,60,61,62,65,66,67,68,69,70,71,73,75,76,78,79,85,87,88,89,93,94,95,97,101,112,113,118,119,133,140,144,145,146,147,148,149,152,154,155,156,174,180,184,185,200,201,202,203,205,206,210,212,225,226,228,232,232,240 and 242. +0,1,2,3,4,5,7,9,10,11,12,13,15,19,21,22,23,24,25,26,28,31,32,33,34,36,37,38,41,44,45,46,47,48,49,52,57,58,60,61,62,65,66,67,68,69,70,71,73,75,76,78,79,85,87,88,89,93,94,95,97,101,107,112,113,118,119,132,133,136,137,138,139,140,141,144,145,146,147,148,149,152,154,155,156,172,173,174,180,184,185,193,200,201,202,203,205,206,210,212,221,225,226,228,229,230,231,232,235,237,240 and 242. Supported Audio Expansions (for both ROMs and NSF Files): VRC6, VRC7, FDS, MMC5, N163, Sunsoft 5B diff --git a/libretro/Makefile b/libretro/Makefile index 4c2007a..ad2c08b 100644 --- a/libretro/Makefile +++ b/libretro/Makefile @@ -352,10 +352,15 @@ OBJS += ../mapper/common.o OBJS += ../mapper/fds.o OBJS += ../mapper/m13.o OBJS += ../mapper/m15.o +OBJS += ../mapper/m137.o OBJS += ../mapper/m156.o +OBJS += ../mapper/m193.o +OBJS += ../mapper/m28.o OBJS += ../mapper/m206.o OBJS += ../mapper/m225.o OBJS += ../mapper/m228.o +OBJS += ../mapper/m237.o +OBJS += ../mapper/m31.o OBJS += ../mapper/m32.o OBJS += ../mapper/m33.o OBJS += ../mapper/m34.o diff --git a/main.c b/main.c index 760249b..8081d8a 100644 --- a/main.c +++ b/main.c @@ -38,7 +38,7 @@ #define DEBUG_KEY 0 #define DEBUG_LOAD_INFO 1 -const char *VERSION_STRING = "fixNES Alpha v1.2.2"; +const char *VERSION_STRING = "fixNES Alpha v1.2.3"; static char window_title[256]; static char window_title_pause[256]; @@ -195,18 +195,34 @@ int main(int argc, char** argv) nesEmuFileClose(); nesPAL = (strstr(emuFileName,"(E)") != NULL) || (strstr(emuFileName,"(Europe)") != NULL) || (strstr(emuFileName,"(Australia)") != NULL) || (strstr(emuFileName,"(France)") != NULL) || (strstr(emuFileName,"(Germany)") != NULL) || (strstr(emuFileName,"(Italy)") != NULL) - || (strstr(emuFileName,"(Spain)") != NULL) || (strstr(emuFileName,"(Sweden)") != NULL); + || (strstr(emuFileName,"(Spain)") != NULL) || (strstr(emuFileName,"(Sweden)") != NULL) || (strstr(emuFileName,"(PAL)") != NULL); uint8_t mapper = ((emuNesROM[6] & 0xF0) >> 4) | ((emuNesROM[7] & 0xF0)); emuSaveEnabled = (emuNesROM[6] & (1<<1)) != 0; bool trainer = (emuNesROM[6] & (1<<2)) != 0; uint32_t ROMsize = emuNesROMsize-16; uint32_t prgROMsize = emuNesROM[4] * 0x4000; if(prgROMsize > ROMsize) //ensure we read in bounds + { + printf("Suggested PRG ROM of 0x%04x is too big, using 0x%04x instead\n", prgROMsize, ROMsize); prgROMsize = ROMsize; + } ROMsize -= prgROMsize; uint32_t chrROMsize = emuNesROM[5] * 0x2000; - if(chrROMsize > ROMsize) //ensure we read in bounds + if(prgROMsize == 0) //can happen on some roms... + { + printf("PRG ROM size was 0, forcing the whole file to be PRG ROM\n"); + prgROMsize = ROMsize; + if(chrROMsize) //force use CHR RAM in this case for now... + { + printf("CHR ROM was set to 0x%04x, instead of the suggested CHR ROM it will now use CHR RAM\n", chrROMsize); + chrROMsize = 0; + } + } + else if(chrROMsize > ROMsize) //ensure we read in bounds + { + printf("Suggested CHR ROM of 0x%04x is too big, using 0x%04x instead\n", chrROMsize, ROMsize); chrROMsize = ROMsize; + } if(mapper == 5) //just to be on the safe side emuPrgRAMsize = 0x10000; else diff --git a/mapper/common.c b/mapper/common.c index 24a1155..9131ec9 100644 --- a/mapper/common.c +++ b/mapper/common.c @@ -14,6 +14,58 @@ #include "../mem.h" +static struct { + uint8_t *prgROM; + uint32_t prgROMand; + uint8_t *prgROMBank0Ptr, *prgROMBank1Ptr, + *prgROMBank2Ptr, *prgROMBank3Ptr, + *prgROMBank4Ptr, *prgROMBank5Ptr, + *prgROMBank6Ptr, *prgROMBank7Ptr; +} prg4; + +void prg4init(uint8_t *prgROM, uint32_t prgROMsize) +{ + prg4.prgROM = prgROM; + prg4.prgROMand = mapperGetAndValue(prgROMsize); + prg4setBank0(0); prg4setBank1(0); prg4setBank2(0); prg4setBank3(0); + prg4setBank4(0); prg4setBank5(0); prg4setBank6(0); prg4setBank7(0); + printf("Using Common PRG ROM (%iKB Total) 4KB Banks\n", (prgROMsize>>10)); +} + +static uint8_t prg4GetROM0(uint16_t addr) { return prg4.prgROMBank0Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM1(uint16_t addr) { return prg4.prgROMBank1Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM2(uint16_t addr) { return prg4.prgROMBank2Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM3(uint16_t addr) { return prg4.prgROMBank3Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM4(uint16_t addr) { return prg4.prgROMBank4Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM5(uint16_t addr) { return prg4.prgROMBank5Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM6(uint16_t addr) { return prg4.prgROMBank6Ptr[addr&0xFFF]; } +static uint8_t prg4GetROM7(uint16_t addr) { return prg4.prgROMBank7Ptr[addr&0xFFF]; } + +void prg4initGet8(uint16_t addr) +{ + if(addr < 0x8000) return; + else if(addr < 0x9000) memInitMapperGetPointer(addr, prg4GetROM0); + else if(addr < 0xA000) memInitMapperGetPointer(addr, prg4GetROM1); + else if(addr < 0xB000) memInitMapperGetPointer(addr, prg4GetROM2); + else if(addr < 0xC000) memInitMapperGetPointer(addr, prg4GetROM3); + else if(addr < 0xD000) memInitMapperGetPointer(addr, prg4GetROM4); + else if(addr < 0xE000) memInitMapperGetPointer(addr, prg4GetROM5); + else if(addr < 0xF000) memInitMapperGetPointer(addr, prg4GetROM6); + else memInitMapperGetPointer(addr, prg4GetROM7); +} + +void prg4setBank0(uint32_t val) { prg4.prgROMBank0Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank1(uint32_t val) { prg4.prgROMBank1Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank2(uint32_t val) { prg4.prgROMBank2Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank3(uint32_t val) { prg4.prgROMBank3Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank4(uint32_t val) { prg4.prgROMBank4Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank5(uint32_t val) { prg4.prgROMBank5Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank6(uint32_t val) { prg4.prgROMBank6Ptr = prg4.prgROM+(val&prg4.prgROMand); } +void prg4setBank7(uint32_t val) { prg4.prgROMBank7Ptr = prg4.prgROM+(val&prg4.prgROMand); } + + + + static struct { uint8_t *prgROM; uint32_t prgROMand; diff --git a/mapper/m137.c b/mapper/m137.c new file mode 100644 index 0000000..bc5bccf --- /dev/null +++ b/mapper/m137.c @@ -0,0 +1,235 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#include +#include +#include +#include +#include "../ppu.h" +#include "../mapper.h" +#include "../mem.h" +#include "../mapper_h/common.h" + +static struct { + uint8_t reg, regB, regC, + regc, regd, rege, regf; + uint8_t mode, mirror; + bool revhv; +} m137; + +static void m137setChrBankPtr() +{ + uint8_t chrBank0 = m137.regc&7; + if(m137.mode == 0) + { + uint8_t chrBank1 = (m137.regd&7)|((m137.regB&1)?0x10:0); + uint8_t chrBank2 = (m137.rege&7)|((m137.regB&2)?0x10:0); + uint8_t chrBank3 = (m137.regf&7)|((m137.regB&4)?0x10:0)|((m137.regC&1)?8:0); + chr1setBank0(chrBank0<<10); chr1setBank1(chrBank1<<10); + chr1setBank2(chrBank2<<10); chr1setBank3(chrBank3<<10); + } + else + { + chr1setBank0(chrBank0<<10); chr1setBank1(chrBank0<<10); + chr1setBank2(chrBank0<<10); chr1setBank3(chrBank0<<10); + } +} + +static void m138setChrBankPtr() +{ + uint8_t chrBank0 = (m137.regc&7)|((m137.regB<<3)&0x38); + if(m137.mode == 0) + { + uint8_t chrBank1 = (m137.regd&7)|((m137.regB<<3)&0x38); + uint8_t chrBank2 = (m137.rege&7)|((m137.regB<<3)&0x38); + uint8_t chrBank3 = (m137.regf&7)|((m137.regB<<3)&0x38); + chr2setBank0(chrBank0<<11); chr2setBank1(chrBank1<<11); + chr2setBank2(chrBank2<<11); chr2setBank3(chrBank3<<11); + } + else + { + chr2setBank0(chrBank0<<11); chr2setBank1(chrBank0<<11); + chr2setBank2(chrBank0<<11); chr2setBank3(chrBank0<<11); + } +} + +static void m139setChrBankPtr() +{ + uint8_t chrBank0 = ((m137.regc<<2)&0x1C)|((m137.regB<<5)&0xE0); + if(m137.mode == 0) + { + uint8_t chrBank1 = ((m137.regd<<2)&0x1C)|((m137.regB<<5)&0xE0); + uint8_t chrBank2 = ((m137.rege<<2)&0x1C)|((m137.regB<<5)&0xE0); + uint8_t chrBank3 = ((m137.regf<<2)&0x1C)|((m137.regB<<5)&0xE0); + chr2setBank0((chrBank0|0)<<11); chr2setBank1((chrBank1|1)<<11); + chr2setBank2((chrBank2|2)<<11); chr2setBank3((chrBank3|3)<<11); + } + else + { + chr2setBank0((chrBank0|0)<<11); chr2setBank1((chrBank0|1)<<11); + chr2setBank2((chrBank0|2)<<11); chr2setBank3((chrBank0|3)<<11); + } +} + +static void m141setChrBankPtr() +{ + uint8_t chrBank0 = ((m137.regc<<1)&0xE)|((m137.regB<<4)&0x70); + if(m137.mode == 0) + { + uint8_t chrBank1 = ((m137.regd<<1)&0xE)|((m137.regB<<4)&0x70); + uint8_t chrBank2 = ((m137.rege<<1)&0xE)|((m137.regB<<4)&0x70); + uint8_t chrBank3 = ((m137.regf<<1)&0xE)|((m137.regB<<4)&0x70); + chr2setBank0((chrBank0|0)<<11); chr2setBank1((chrBank1|1)<<11); + chr2setBank2((chrBank2|0)<<11); chr2setBank3((chrBank3|1)<<11); + } + else + { + chr2setBank0((chrBank0|0)<<11); chr2setBank1((chrBank0|1)<<11); + chr2setBank2((chrBank0|0)<<11); chr2setBank3((chrBank0|1)<<11); + } +} + +static void m137_commonInit() +{ + m137.reg = 0, m137.regB = 0, m137.regC = 0, + m137.regc = 0, m137.regd = 0, m137.rege = 0, m137.regf = 0; + m137.mode = 0, m137.mirror = 0; +} + +void m137init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + m137_commonInit(); + m137.revhv = true; + prg32init(prgROMin, prgROMsizeIn); + (void)prgRAMin; + (void)prgRAMsizeIn; + chr1init(chrROMin, chrROMsizeIn); + m137setChrBankPtr(); + chr1setBank4(chrROMsizeIn - 0x1000); + chr1setBank5(chrROMsizeIn - 0x0C00); + chr1setBank6(chrROMsizeIn - 0x0800); + chr1setBank7(chrROMsizeIn - 0x0400); + printf("Mapper 137 inited\n"); +} + +void m138init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + m137_commonInit(); + m137.revhv = false; + prg32init(prgROMin, prgROMsizeIn); + (void)prgRAMin; + (void)prgRAMsizeIn; + chr2init(chrROMin, chrROMsizeIn); + m138setChrBankPtr(); + printf("Mapper 138 inited\n"); +} + +void m139init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + m137_commonInit(); + m137.revhv = false; + prg32init(prgROMin, prgROMsizeIn); + (void)prgRAMin; + (void)prgRAMsizeIn; + chr2init(chrROMin, chrROMsizeIn); + m139setChrBankPtr(); + printf("Mapper 139 inited\n"); +} + +void m141init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + m137_commonInit(); + m137.revhv = false; + prg32init(prgROMin, prgROMsizeIn); + (void)prgRAMin; + (void)prgRAMsizeIn; + chr2init(chrROMin, chrROMsizeIn); + m141setChrBankPtr(); + printf("Mapper 141 inited\n"); +} + +static void m137common_setParams4100(uint16_t addr, uint8_t val) { (void)addr; m137.reg = val&7; } +static void m137common_setParams4101(uint16_t addr, uint8_t val) +{ + (void)addr; + switch(m137.reg&7) + { + case 0: + m137.regc = val&7; + break; + case 1: + m137.regd = val&7; + break; + case 2: + m137.rege = val&7; + break; + case 3: + m137.regf = val&7; + break; + case 4: + m137.regB = val&7; + break; + case 5: + prg32setBank0((val&7)<<15); + break; + case 6: + m137.regC = val&1; + break; + case 7: + m137.mode = val&1; + m137.mirror = (val>>1)&3; + //update ppu mirroring + if(m137.mirror == 0 || m137.mode) + m137.revhv ? ppuSetNameTblHorizontal() : ppuSetNameTblVertical(); + else if(m137.mirror == 1) + m137.revhv ? ppuSetNameTblVertical() : ppuSetNameTblHorizontal(); + else if(m137.mirror == 2) + ppuSetNameTblCustom(0,0x400,0x400,0x400); + else if(m137.mirror == 3) + ppuSetNameTblSingleLower(); + break; + } +} +static void m137setParams4101(uint16_t addr, uint8_t val) { m137common_setParams4101(addr,val); m137setChrBankPtr(); } +void m137initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xC101; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m137common_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m137setParams4101); +} + +static void m138setParams4101(uint16_t addr, uint8_t val) { m137common_setParams4101(addr,val); m138setChrBankPtr(); } +void m138initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xC101; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m137common_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m138setParams4101); +} + +static void m139setParams4101(uint16_t addr, uint8_t val) { m137common_setParams4101(addr,val); m139setChrBankPtr(); } +void m139initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xC101; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m137common_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m139setParams4101); +} + +static void m141setParams4101(uint16_t addr, uint8_t val) { m137common_setParams4101(addr,val); m141setChrBankPtr(); } +void m141initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xC101; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m137common_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m141setParams4101); +} diff --git a/mapper/m193.c b/mapper/m193.c new file mode 100644 index 0000000..09156e9 --- /dev/null +++ b/mapper/m193.c @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#include +#include +#include +#include +#include "../ppu.h" +#include "../mapper.h" +#include "../mem.h" +#include "../mapper_h/common.h" + +void m193init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + (void)prgRAMin; + (void)prgRAMsizeIn; + prg8init(prgROMin,prgROMsizeIn); + prg8setBank1(prgROMsizeIn-0x6000); + prg8setBank2(prgROMsizeIn-0x4000); + prg8setBank3(prgROMsizeIn-0x2000); + chr2init(chrROMin,chrROMsizeIn); + //default state of this mapper? + ppuSetNameTblVertical(); + printf("Mapper 193 inited\n"); +} + +static void m193setParams6000(uint16_t addr, uint8_t val) { (void)addr; chr2setBank0(((val>>1)&0xFE)<<11); chr2setBank1(((val>>1)|0x01)<<11); } +static void m193setParams6001(uint16_t addr, uint8_t val) { (void)addr; chr2setBank2((val>>1)<<11); } +static void m193setParams6002(uint16_t addr, uint8_t val) { (void)addr; chr2setBank3((val>>1)<<11); } +static void m193setParams6003(uint16_t addr, uint8_t val) { (void)addr; prg8setBank0(val<<13); } +void m193initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xE003; + if(proc_addr == 0x6000) memInitMapperSetPointer(ori_addr, m193setParams6000); + else if(proc_addr == 0x6001) memInitMapperSetPointer(ori_addr, m193setParams6001); + else if(proc_addr == 0x6002) memInitMapperSetPointer(ori_addr, m193setParams6002); + else if(proc_addr == 0x6003) memInitMapperSetPointer(ori_addr, m193setParams6003); +} diff --git a/mapper/m206.c b/mapper/m206.c index f56ac54..f3f3265 100644 --- a/mapper/m206.c +++ b/mapper/m206.c @@ -57,6 +57,8 @@ void m95init(uint8_t *prgROMin, uint32_t prgROMsizeIn, //top right it will have an X without PRG RAM and the game will not function //correctly, with PRG RAM however it will display "OK" and actually work static bool m112_usesPrgRAM; +//extended chr bank bit used by for example "Fighting Hero III" +static uint16_t m112b0Upper, m112b1Upper, m112b2Upper, m112b3Upper; void m112init(uint8_t *prgROMin, uint32_t prgROMsizeIn, uint8_t *prgRAMin, uint32_t prgRAMsizeIn, uint8_t *chrROMin, uint32_t chrROMsizeIn) @@ -67,6 +69,9 @@ void m112init(uint8_t *prgROMin, uint32_t prgROMsizeIn, prgRAM8init(prgRAMin); m112_usesPrgRAM = true; } + else + m112_usesPrgRAM = false; + m112b0Upper = 0, m112b1Upper = 0, m112b2Upper = 0, m112b3Upper = 0; } void m112initGet8(uint16_t addr) @@ -158,16 +163,16 @@ static void m112setParamsA000(uint16_t addr, uint8_t val) m206CHRBank1Ptr = m206chrROM+(((val&~1)<<10)&m206chrROMand); break; case 4: - m206CHRBank2Ptr = m206chrROM+((val<<10)&m206chrROMand); + m206CHRBank2Ptr = m206chrROM+(((val|m112b0Upper)<<10)&m206chrROMand); break; case 5: - m206CHRBank3Ptr = m206chrROM+((val<<10)&m206chrROMand); + m206CHRBank3Ptr = m206chrROM+(((val|m112b1Upper)<<10)&m206chrROMand); break; case 6: - m206CHRBank4Ptr = m206chrROM+((val<<10)&m206chrROMand); + m206CHRBank4Ptr = m206chrROM+(((val|m112b2Upper)<<10)&m206chrROMand); break; case 7: - m206CHRBank5Ptr = m206chrROM+((val<<10)&m206chrROMand); + m206CHRBank5Ptr = m206chrROM+(((val|m112b3Upper)<<10)&m206chrROMand); break; } } @@ -219,6 +224,12 @@ static void m95setParams8001(uint16_t addr, uint8_t val) } } +static void m112setParamsC000(uint16_t addr, uint8_t val) +{ + (void)addr; + m112b0Upper = (val&0x10)<<4, m112b1Upper = (val&0x20)<<3, + m112b2Upper = (val&0x40)<<2, m112b3Upper = (val&0x80)<<1; +} static void m112setParamsE000(uint16_t addr, uint8_t val) { (void)addr; @@ -272,6 +283,7 @@ void m112initSet8(uint16_t ori_addr) uint16_t proc_addr = ori_addr&0xE001; if(proc_addr == 0x8000) memInitMapperSetPointer(ori_addr, m206setParams8000); else if(proc_addr == 0xA000) memInitMapperSetPointer(ori_addr, m112setParamsA000); + else if(proc_addr == 0xC000) memInitMapperSetPointer(ori_addr, m112setParamsC000); else if(proc_addr == 0xE000) memInitMapperSetPointer(ori_addr, m112setParamsE000); } void m154initSet8(uint16_t ori_addr) diff --git a/mapper/m225.c b/mapper/m225.c index 75d12d1..cbb4d99 100644 --- a/mapper/m225.c +++ b/mapper/m225.c @@ -13,6 +13,7 @@ #include "../mapper.h" #include "../mem.h" #include "../mapper_h/common.h" +#include "../mapper_h/m225.h" static uint8_t m225_regRAM[4]; @@ -23,7 +24,7 @@ void m225init(uint8_t *prgROMin, uint32_t prgROMsizeIn, (void)prgRAMin; (void)prgRAMsizeIn; prg16init(prgROMin,prgROMsizeIn); - prg16setBank0(0<<14); prg16setBank1(1<<14); + m225reset(); chr8init(chrROMin,chrROMsizeIn); memset(m225_regRAM,0,4); printf("Mapper 225 inited\n"); @@ -53,8 +54,8 @@ static void m225setParams(uint16_t addr, uint8_t val) uint8_t prgBank = (addr>>6)&0x3F; if(addr&0x4000) { - chrBank |= 0x80; - prgBank |= 0x80; + chrBank |= 0x40; + prgBank |= 0x40; } if((addr&0x1000) == 0) //mode 32k { @@ -80,3 +81,13 @@ void m225initSet8(uint16_t addr) else if(addr >= 0x8000) memInitMapperSetPointer(addr, m225setParams); } + +void m225reset() +{ + //reset to menu vectors seem to generally exist on most games, + //however on some without this it will reset glitchy, + //so for the sake of clean resetting everywhere do this + prg16setBank0(0<<14); prg16setBank1(1<<14); + chr8setBank0(0); + ppuSetNameTblVertical(); +} diff --git a/mapper/m237.c b/mapper/m237.c new file mode 100644 index 0000000..5c7a4a1 --- /dev/null +++ b/mapper/m237.c @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#include +#include +#include +#include +#include "../ppu.h" +#include "../mapper.h" +#include "../mem.h" +#include "../mapper_h/common.h" +#include "../mapper_h/m237.h" + +static struct { + uint8_t *prgROM; + uint32_t prgROMand; + uint8_t *prgROMBank0Ptr, *prgROMBank1Ptr; + uint16_t type; + uint8_t prgBank; + bool lock; +} m237; + +static void m237setBank0(uint32_t val) { m237.prgROMBank0Ptr = m237.prgROM+(val&m237.prgROMand); } +static void m237setBank1(uint32_t val) { m237.prgROMBank1Ptr = m237.prgROM+(val&m237.prgROMand); } + +void m237init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + (void)prgRAMin; + (void)prgRAMsizeIn; + m237.prgROM = prgROMin; + m237.prgROMand = mapperGetAndValue(prgROMsizeIn); + //sets prg banks + m237reset(); + chr8init(chrROMin,chrROMsizeIn); + printf("Mapper 237 inited\n"); +} + +static uint8_t m237GetROM0(uint16_t addr) { return m237.prgROMBank0Ptr[(addr|m237.type)&0x3FFF]; } +static uint8_t m237GetROM1(uint16_t addr) { return m237.prgROMBank1Ptr[(addr|m237.type)&0x3FFF]; } + +void m237initGet8(uint16_t addr) +{ + if(addr < 0x8000) return; + else if(addr < 0xC000) memInitMapperGetPointer(addr, m237GetROM0); + else memInitMapperGetPointer(addr, m237GetROM1); +} + +static void m237setParams(uint16_t addr, uint8_t val) +{ + m237.prgBank = (m237.prgBank&0x38)|(val&7); + if(!m237.lock) + { + m237.prgBank = ((addr<<3)&0x20)|(val&0x18)|(m237.prgBank&7); + m237.lock = ((addr&2) != 0); + m237.type = (addr&1) ? 2 : 0; + if((val&0x20) == 0) + ppuSetNameTblVertical(); + else + ppuSetNameTblHorizontal(); + } + switch((val>>6)&3) + { + case 0: + m237setBank0(m237.prgBank<<14); + m237setBank1((m237.prgBank|0x07)<<14); + break; + case 1: + m237setBank0((m237.prgBank&0xFE)<<14); + m237setBank1((m237.prgBank|0x07)<<14); + break; + case 2: + m237setBank0(m237.prgBank<<14); + m237setBank1(m237.prgBank<<14); + break; + case 3: + m237setBank0((m237.prgBank&0xFE)<<14); + m237setBank1((m237.prgBank|0x01)<<14); + break; + } +} +void m237initSet8(uint16_t addr) +{ + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m237setParams); +} + +void m237reset() +{ + m237setBank0(0<<14); m237setBank1(7<<14); + m237.type = 0; + m237.prgBank = 0; + m237.lock = false; +} diff --git a/mapper/m28.c b/mapper/m28.c new file mode 100644 index 0000000..2d12847 --- /dev/null +++ b/mapper/m28.c @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#include +#include +#include +#include +#include "../ppu.h" +#include "../mapper.h" +#include "../mem.h" +#include "../mapper_h/common.h" + +static struct { + uint8_t chrRAM[0x8000]; + uint8_t *chrRAMBankPtr; + uint8_t prgBankMode; + uint16_t prgBankAnd; + uint8_t prgBankInner; + uint16_t prgBankOuter; + uint8_t reg; + uint8_t mirror; + bool usesPrgRAM; +} m28; + +static void m28SetPrgROMBankPtr() +{ + //inner can be both 16k and 32k + uint8_t curPrgBankInner = (m28.prgBankMode&2) ? (m28.prgBankInner) : (m28.prgBankInner<<1); + //combine both inner and outer banks + uint16_t curPrgBank = (curPrgBankInner&m28.prgBankAnd) | (m28.prgBankOuter&~m28.prgBankAnd); + //set current 16k bank 0 + if((m28.prgBankMode&3) == 3) //normal inner+outer bank + prg16setBank0(curPrgBank<<14); + else if((m28.prgBankMode&3) == 2) //use lower half of outer bank + prg16setBank0((m28.prgBankOuter&0x1FE)<<14); + else //use lower half of inner+outer bank + prg16setBank0((curPrgBank&0x1FE)<<14); + //set current 16k bank 1 + if((m28.prgBankMode&3) == 2) //normal inner+outer bank + prg16setBank1(curPrgBank<<14); + else if((m28.prgBankMode&3) == 3) //use upper half of outer bank + prg16setBank1((m28.prgBankOuter|0x01)<<14); + else //use upper half of inner+outer bank + prg16setBank1((curPrgBank|0x01)<<14); +} + +static void m28SetMirroring() +{ + switch(m28.mirror&3) + { + case 0: + ppuSetNameTblSingleLower(); + break; + case 1: + ppuSetNameTblSingleUpper(); + break; + case 2: + ppuSetNameTblVertical(); + break; + case 3: + ppuSetNameTblHorizontal(); + break; + } +} + +void m28init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + if(prgRAMin && prgRAMsizeIn) + { + prgRAM8init(prgRAMin); + m28.usesPrgRAM = true; + } + else + m28.usesPrgRAM = false; + prg16init(prgROMin,prgROMsizeIn); + m28.prgBankMode = 0, m28.prgBankAnd = 0, + m28.prgBankInner = 0, m28.prgBankOuter = 0; + prg16setBank1(prgROMsizeIn - 0x4000); + (void)chrROMin; (void)chrROMsizeIn; + m28.chrRAMBankPtr = m28.chrRAM; + m28.reg = 0; m28.mirror = 0; + printf("Mapper 28 inited\n"); +} + +void m28initGet8(uint16_t addr) +{ + if(m28.usesPrgRAM) + prgRAM8initGet8(addr); + prg16initGet8(addr); +} + +static void m28setParams5XXX(uint16_t addr, uint8_t val) { (void)addr; m28.reg = ((val>>6)&2)|(val&1); } +static void m28setParams8XXX(uint16_t addr, uint8_t val) +{ + (void)addr; + if((m28.reg&2) == 0 && (m28.mirror&2) == 0) + { + m28.mirror = ((val>>4)&1); + m28SetMirroring(); + } + switch(m28.reg&3) + { + case 0: + m28.chrRAMBankPtr = m28.chrRAM+((val&3)<<13); + break; + case 1: + m28.prgBankInner = val&0xF; + m28SetPrgROMBankPtr(); + break; + case 2: + m28.mirror = (val&3); + m28SetMirroring(); + m28.prgBankMode = (val>>2)&3; + m28.prgBankAnd = (2<<((val>>4)&3))-1; + m28SetPrgROMBankPtr(); + break; + case 3: + m28.prgBankOuter = (val<<1); + m28SetPrgROMBankPtr(); + break; + } +} +void m28initSet8(uint16_t addr) +{ + if(m28.usesPrgRAM) + prgRAM8initSet8(addr); + if(addr >= 0x5000 && addr < 0x6000) + memInitMapperSetPointer(addr, m28setParams5XXX); + else if(addr >= 0x8000) + memInitMapperSetPointer(addr, m28setParams8XXX); +} + +static uint8_t m28ChrGetRAM(uint16_t addr) { return m28.chrRAMBankPtr[addr]; } +void m28initPPUGet8(uint16_t addr) +{ + if(addr < 0x2000) + memInitMapperPPUGetPointer(addr, m28ChrGetRAM); +} + +static void m28ChrSetRAM(uint16_t addr, uint8_t val) { m28.chrRAMBankPtr[addr] = val; } +void m28initPPUSet8(uint16_t addr) +{ + if(addr < 0x2000) + memInitMapperPPUSetPointer(addr, m28ChrSetRAM); +} diff --git a/mapper/m31.c b/mapper/m31.c new file mode 100644 index 0000000..fe602db --- /dev/null +++ b/mapper/m31.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#include +#include +#include +#include +#include "../ppu.h" +#include "../mapper.h" +#include "../mem.h" +#include "../mapper_h/common.h" + +void m31init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + prg4init(prgROMin, prgROMsizeIn); + prg4setBank7(prgROMsizeIn - 0x1000); + (void)prgRAMin; (void)prgRAMsizeIn; + chr8init(chrROMin,chrROMsizeIn); + printf("Mapper 31 inited\n"); +} + +static void m31setParams5000(uint16_t addr, uint8_t val) { (void)addr; prg4setBank0(val<<12); } +static void m31setParams5001(uint16_t addr, uint8_t val) { (void)addr; prg4setBank1(val<<12); } +static void m31setParams5002(uint16_t addr, uint8_t val) { (void)addr; prg4setBank2(val<<12); } +static void m31setParams5003(uint16_t addr, uint8_t val) { (void)addr; prg4setBank3(val<<12); } +static void m31setParams5004(uint16_t addr, uint8_t val) { (void)addr; prg4setBank4(val<<12); } +static void m31setParams5005(uint16_t addr, uint8_t val) { (void)addr; prg4setBank5(val<<12); } +static void m31setParams5006(uint16_t addr, uint8_t val) { (void)addr; prg4setBank6(val<<12); } +static void m31setParams5007(uint16_t addr, uint8_t val) { (void)addr; prg4setBank7(val<<12); } +void m31initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xF007; + if(proc_addr == 0x5000) memInitMapperSetPointer(ori_addr, m31setParams5000); + else if(proc_addr == 0x5001) memInitMapperSetPointer(ori_addr, m31setParams5001); + else if(proc_addr == 0x5002) memInitMapperSetPointer(ori_addr, m31setParams5002); + else if(proc_addr == 0x5003) memInitMapperSetPointer(ori_addr, m31setParams5003); + else if(proc_addr == 0x5004) memInitMapperSetPointer(ori_addr, m31setParams5004); + else if(proc_addr == 0x5005) memInitMapperSetPointer(ori_addr, m31setParams5005); + else if(proc_addr == 0x5006) memInitMapperSetPointer(ori_addr, m31setParams5006); + else if(proc_addr == 0x5007) memInitMapperSetPointer(ori_addr, m31setParams5007); +} diff --git a/mapper/mmc3add.c b/mapper/mmc3add.c index fcd9975..a62be52 100644 --- a/mapper/mmc3add.c +++ b/mapper/mmc3add.c @@ -41,7 +41,7 @@ void m44_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, printf("Mapper 44 (Mapper 4 Game Select) inited\n"); } -static uint8_t m45_curReg; +static uint8_t m45_curReg, m45_chrROMandVal; void m45_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, uint8_t *prgRAMin, uint32_t prgRAMsizeIn, @@ -227,12 +227,21 @@ void m44_initSet8(uint16_t addr) mmc3initSet8(addr); } +static void m45_setChrROMand() +{ + if(mmc3GetChrROMadd() || m45_chrROMandVal) //default chr rom mask generation + mmc3_chrROMand = (((0xFF >> ((~m45_chrROMandVal)&0xF))+1)<<10)-1; + else //this code is just a guess, if no chr rom or/and value, use full and value + mmc3_chrROMand = (((0xFF >> ((~0xF)&0xF))+1)<<10)-1; +} + static void m45_setParams6XXX(uint16_t addr, uint8_t val) { (void)addr; if(m45_curReg == 0) { mmc3SetChrROMadd((mmc3GetChrROMadd() & ~0x3FFFF) | (val<<10)); + m45_setChrROMand(); //update because of new add value //printf("mmc3_chrROMadd r0 %08x inVal %02x\n", mmc3GetChrROMadd(), val); } else if(m45_curReg == 1) @@ -242,8 +251,9 @@ static void m45_setParams6XXX(uint16_t addr, uint8_t val) } else if(m45_curReg == 2) { - mmc3_chrROMand = (((0xFF >> ((~val)&0xF))+1)<<10)-1; mmc3SetChrROMadd((mmc3GetChrROMadd() & 0x3FFFF) | ((val>>4)<<18)); + m45_chrROMandVal = val&0xF; + m45_setChrROMand(); //printf("mmc3_chrROMand %08x mmc3_chrROMadd r1 %08x inVal %02x\n", mmc3_chrROMand, mmc3GetChrROMadd(), val); } else if(m45_curReg == 3) @@ -491,7 +501,8 @@ void m45_reset() mmc3_prgROMand = 0x7FFFF; mmc3SetPrgROMBankPtr(); mmc3SetChrROMadd(0); - mmc3_chrROMand = 0x7FFFF; + m45_chrROMandVal = 0; + m45_setChrROMand(); mmc3SetChrROMBankPtr(); mmc3add_regLock = false; mmc3add_prgRAMenable = false; diff --git a/mapper/p16c8.c b/mapper/p16c8.c index d6c9869..8867501 100644 --- a/mapper/p16c8.c +++ b/mapper/p16c8.c @@ -57,6 +57,15 @@ void m57_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, p1632c8SetPrgROMBank(); } +void m58_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + p16c8init(prgROMin, prgROMsizeIn, prgRAMin, prgRAMsizeIn, chrROMin, chrROMsizeIn); + //sets special prg bank layout + m58_reset(); +} + static uint8_t m60_state; void m60_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, uint8_t *prgRAMin, uint32_t prgRAMsizeIn, @@ -132,6 +141,48 @@ void m200_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, m200SetPrgROMBank(0); } +static uint8_t m221_prgmode; +static uint32_t m221_curPRGBank,m221_outerPRGBank; +static void m221SetPrgROMBank() +{ + if(m221_prgmode&1) + { + if(m221_prgmode&2) + { + prg16setBank0((m221_curPRGBank)|m221_outerPRGBank); + prg16setBank1((((m221_curPRGBank)&~0x1FFFF)|0x1C000)|m221_outerPRGBank); + } + else + { + prg16setBank0((m221_curPRGBank&~0x7FFF)|m221_outerPRGBank); + prg16setBank1((m221_curPRGBank|0x4000)|m221_outerPRGBank); + } + } + else + { + prg16setBank0(m221_curPRGBank|m221_outerPRGBank); + prg16setBank1(m221_curPRGBank|m221_outerPRGBank); + } +} + +void m221_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + p16c8init(prgROMin, prgROMsizeIn, prgRAMin, prgRAMsizeIn, chrROMin, chrROMsizeIn); + //sets special prg bank layout + m221_reset(); +} + +void m226_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + p16c8init(prgROMin, prgROMsizeIn, prgRAMin, prgRAMsizeIn, chrROMin, chrROMsizeIn); + //sets special prg bank layout + m226_reset(); +} + static void m231SetPrgROMBank(uint32_t bank) { prg16setBank0(bank&~0x7FFF); prg16setBank1(bank); @@ -146,6 +197,17 @@ void m231_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, m231SetPrgROMBank(0); } +static uint8_t m230_mode; +void m230_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + p16c8init(prgROMin, prgROMsizeIn, prgRAMin, prgRAMsizeIn, chrROMin, chrROMsizeIn); + //special prg bank layout + m230_mode = 0; + m230_reset(); +} + static uint32_t m232_curPRGBank; static void m232SetPrgROMBank() { @@ -163,6 +225,29 @@ void m232_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, m232SetPrgROMBank(); } +static uint8_t m235_bankshift; +void m235_init(uint8_t *prgROMin, uint32_t prgROMsizeIn, + uint8_t *prgRAMin, uint32_t prgRAMsizeIn, + uint8_t *chrROMin, uint32_t chrROMsizeIn) +{ + p16c8init(prgROMin, prgROMsizeIn, prgRAMin, prgRAMsizeIn, chrROMin, chrROMsizeIn); + //seemingly select from either 512kb or 1mb rom banks depending on input size + m235_bankshift = (prgROMsizeIn <= 0x200000) ? 19 : 20; + //special prg bank layout + m235_reset(); +} + + +extern uint8_t memLastVal; +static uint8_t m212_getParams(uint16_t addr) { (void)addr; return 0x80|memLastVal; } +void m212_initGet8(uint16_t addr) +{ + if((addr&0xE010) == 0x6000) //required for some to not lock up + memInitMapperGetPointer(addr, m212_getParams); + else //normal rom init + prg16initGet8(addr); +} + static void m2_setParams(uint16_t addr, uint8_t val) { (void)addr; prg16setBank0((val & 0xF)<<14); } void m2_initSet8(uint16_t addr) { @@ -416,6 +501,8 @@ static void m200_setParams(uint16_t addr, uint8_t val) (void)val; m200SetPrgROMBank((addr&7)<<14); chr8setBank0((addr&7)<<13); + //some assigned to 200 seem to have this reversed so + //those will look wrong, oh well.. if((addr&8) != 0) ppuSetNameTblHorizontal(); else @@ -475,6 +562,31 @@ void m212_initSet8(uint16_t addr) memInitMapperSetPointer(addr, m212_setParams); } +static void m221_setParams8000(uint16_t addr, uint8_t val) +{ + (void)val; + if(addr&1) + ppuSetNameTblHorizontal(); + else + ppuSetNameTblVertical(); + m221_prgmode = ((addr>>1)&1)|((addr>>7)&2); + //this selection can indeed overlap the inner bank seemingly... + m221_outerPRGBank = ((addr>>2)&0x3F)<<14; + m221SetPrgROMBank(); +} +static void m221_setParamsC000(uint16_t addr, uint8_t val) +{ + (void)val; + m221_curPRGBank = (addr&7)<<14; + m221SetPrgROMBank(); +} +void m221_initSet8(uint16_t addr) +{ + if(addr < 0x8000) return; + if((addr&0xC000) == 0x8000) memInitMapperSetPointer(addr, m221_setParams8000); + else memInitMapperSetPointer(addr, m221_setParamsC000); +} + static void m226_setParams8XX0(uint16_t addr, uint8_t val) { (void)addr; @@ -501,6 +613,45 @@ void m226_initSet8(uint16_t addr) else memInitMapperSetPointer(addr, m226_setParams8XX1); } +static void m229_setParams(uint16_t addr, uint8_t val) +{ + (void)val; + //rather unusual mode switch + p1632_p16 = ((addr&0x1E) != 0); + p1632_curPRGBank = (addr&0x1F)<<14; + p1632c8SetPrgROMBank(); + chr8setBank0((addr&0x1F)<<13); + if((addr&0x20) != 0) + ppuSetNameTblHorizontal(); + else + ppuSetNameTblVertical(); + +} +void m229_initSet8(uint16_t addr) +{ + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m229_setParams); +} + +static void m230_setParamsContra(uint16_t addr, uint8_t val) { (void)addr; prg16setBank0((val&7)<<14); } +static void m230_setParamsMulti(uint16_t addr, uint8_t val) +{ + (void)addr; + p1632_p16 = ((val&0x20) != 0); + p1632_curPRGBank = ((val&0x1F)<<14)+(8<<14); + p1632c8SetPrgROMBank(); + if((val&0x40) != 0) + ppuSetNameTblVertical(); + else + ppuSetNameTblHorizontal(); +} +void m230_initSet8(uint16_t addr) +{ + if(addr < 0x8000) return; + if(m230_mode == 0) memInitMapperSetPointer(addr, m230_setParamsContra); + else memInitMapperSetPointer(addr, m230_setParamsMulti); +} + static void m231_setParams(uint16_t addr, uint8_t val) { (void)val; @@ -537,6 +688,37 @@ void m232_initSet8(uint16_t addr) else memInitMapperSetPointer(addr, m232_setParamsCXXX); } +static void m235_setParams(uint16_t addr, uint8_t val) +{ + (void)val; + p1632_p16 = ((addr&0x800) != 0); + p1632_curPRGBank = (addr&0x1F)<<15; + if(p1632_p16 && (addr&0x1000) != 0) //upper 16k + p1632_curPRGBank |= (1<<14); + p1632_curPRGBank |= (((addr>>8)&3)<= 0x4100 && maskedAddr < 0x4104) + uint16_t maskedAddr = (addr & 0xE100); + if(maskedAddr == 0x4100) memInitMapperGetPointer(addr, m36getParams); else //normal ROM get prg32initGet8(addr); } +static uint8_t m132getParams(uint16_t addr) +{ + (void)addr; + uint8_t ret = memLastVal&0xF0; + if(m36.invert) //reverse of the set + ret |= (m36.reg&7)|((m36.reg^8)&8); + else ret |= (m36.reg&0xF); + return ret; +} +void m132_initGet8(uint16_t addr) +{ + uint16_t maskedAddr = (addr & 0xE100); + if(maskedAddr == 0x4100) + memInitMapperGetPointer(addr, m132getParams); + else //normal ROM get + prg32initGet8(addr); +} + +static uint8_t m136getParams(uint16_t addr) +{ + (void)addr; + uint8_t ret = memLastVal&0xC0; + if(m36.invert) //reverse of the set + ret |= (m36.reg&0xF)|((m36.reg^0x30)&0x30); + else ret |= (m36.reg&0x3F); + return ret; +} +void m136_initGet8(uint16_t addr) +{ + uint16_t maskedAddr = (addr & 0xE100); + if(maskedAddr == 0x4100) + memInitMapperGetPointer(addr, m136getParams); + else //normal ROM get + prg32initGet8(addr); +} + +//Mapper 172 has data bits reversed so this has to be done +static uint8_t m172doBitRev(uint8_t val) +{ + return (val&0xC0)|((val>>5)&1)|((val>>3)&2)|((val>>1)&4) + |((val<<1)&8)|((val<<3)&0x10)|((val<<5)&0x20); +} +static uint8_t m172getParams(uint16_t addr) { return m172doBitRev(m136getParams(addr)); } +void m172_initGet8(uint16_t addr) +{ + uint16_t maskedAddr = (addr & 0xE100); + if(maskedAddr == 0x4100) + memInitMapperGetPointer(addr, m172getParams); + else //normal ROM get + prg32initGet8(addr); +} + void m0_initSet8(uint16_t addr) { if(p32c8_usesPrgRAM) @@ -171,75 +219,40 @@ static void m36_setParams41X0(uint16_t addr, uint8_t val) (void)addr; (void)val; if(m36.mode == 0) { - if(m36.invert == 0) - m36.regstat = m36.prgstat&3; - else - m36.regstat = (~m36.prgstat)&3; - } - else - { - m36.regstat++; - m36.regstat&=3; + if(m36.invert == 0) m36.reg = m36.input&3; + else m36.reg = (~m36.input)&3; } + else m36.reg = (m36.reg+1)&3; } -static void m36_setParams41X1(uint16_t addr, uint8_t val) -{ - (void)addr; - m36.invert = (val>>4)&1; -} -static void m36_setParams41X2(uint16_t addr, uint8_t val) -{ - (void)addr; - m36.prgstat = (val>>4)&3; -} -static void m36_setParams41X3(uint16_t addr, uint8_t val) -{ - (void)addr; - m36.mode = (val>>4)&1; -} -static void m36_setParams42XX(uint16_t addr, uint8_t val) -{ - (void)addr; - chr8setBank0((val & 0xF)<<13); -} +static void m36_setParams41X1(uint16_t addr, uint8_t val) { (void)addr; m36.invert = (val>>4)&1; } +static void m36_setParams41X2(uint16_t addr, uint8_t val) { (void)addr; m36.input = (val>>4)&3; } +static void m36_setParams41X3(uint16_t addr, uint8_t val) { (void)addr; m36.mode = (val>>4)&1; } +static void m36_setParams42XX(uint16_t addr, uint8_t val) { (void)addr; chr8setBank0((val & 0xF)<<13); } static void m36_setParams41X0_42XX(uint16_t addr, uint8_t val) { m36_setParams41X0(addr,val); m36_setParams42XX(addr,val); } static void m36_setParams41X1_42XX(uint16_t addr, uint8_t val) { m36_setParams41X1(addr,val); m36_setParams42XX(addr,val); } static void m36_setParams41X2_42XX(uint16_t addr, uint8_t val) { m36_setParams41X2(addr,val); m36_setParams42XX(addr,val); } static void m36_setParams41X3_42XX(uint16_t addr, uint8_t val) { m36_setParams41X3(addr,val); m36_setParams42XX(addr,val); } -static void m36_setParams8XXX(uint16_t addr, uint8_t val) -{ - (void)addr; (void)val; - prg32setBank0(m36.regstat<<15); -} +static void m36_setParams8XXX(uint16_t addr, uint8_t val) { (void)addr; (void)val; prg32setBank0((m36.reg&3)<<15); } void m36_initSet8(uint16_t addr) { uint16_t maskedAddr1 = (addr & 0xE103); uint16_t maskedAddr2 = (addr & 0xE200); if(maskedAddr2 == 0x4200) { - if(maskedAddr1 == 0x4100) - memInitMapperSetPointer(addr, m36_setParams41X0_42XX); - else if(maskedAddr1 == 0x4100) - memInitMapperSetPointer(addr, m36_setParams41X1_42XX); - else if(maskedAddr1 == 0x4102) - memInitMapperSetPointer(addr, m36_setParams41X2_42XX); - else if(maskedAddr1 == 0x4103) - memInitMapperSetPointer(addr, m36_setParams41X3_42XX); + if(maskedAddr1 == 0x4100) memInitMapperSetPointer(addr, m36_setParams41X0_42XX); + else if(maskedAddr1 == 0x4101) memInitMapperSetPointer(addr, m36_setParams41X1_42XX); + else if(maskedAddr1 == 0x4102) memInitMapperSetPointer(addr, m36_setParams41X2_42XX); + else if(maskedAddr1 == 0x4103) memInitMapperSetPointer(addr, m36_setParams41X3_42XX); else //just maskedAddr2 == 0x4200 memInitMapperSetPointer(addr, m36_setParams42XX); } else { - if(maskedAddr1 == 0x4100) - memInitMapperSetPointer(addr, m36_setParams41X0); - else if(maskedAddr1 == 0x4100) - memInitMapperSetPointer(addr, m36_setParams41X1); - else if(maskedAddr1 == 0x4102) - memInitMapperSetPointer(addr, m36_setParams41X2); - else if(maskedAddr1 == 0x4103) - memInitMapperSetPointer(addr, m36_setParams41X3); - else if(addr >= 0x8000) - memInitMapperSetPointer(addr, m36_setParams8XXX); + if(maskedAddr1 == 0x4100) memInitMapperSetPointer(addr, m36_setParams41X0); + else if(maskedAddr1 == 0x4101) memInitMapperSetPointer(addr, m36_setParams41X1); + else if(maskedAddr1 == 0x4102) memInitMapperSetPointer(addr, m36_setParams41X2); + else if(maskedAddr1 == 0x4103) memInitMapperSetPointer(addr, m36_setParams41X3); + else if(addr >= 0x8000) memInitMapperSetPointer(addr, m36_setParams8XXX); } } @@ -361,6 +374,18 @@ void m101_initSet8(uint16_t addr) memInitMapperSetPointer(addr, m101_setParams); } +void m107_setParams(uint16_t addr, uint8_t val) +{ + (void)addr; + prg32setBank0((val>>1)<<15); + chr8setBank0(val<<13); +} +void m107_initSet8(uint16_t addr) +{ + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m107_setParams); +} + static void m113_setParams(uint16_t addr, uint8_t val) { (void)addr; @@ -377,6 +402,36 @@ void m113_initSet8(uint16_t ori_addr) if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m113_setParams); } +static void m132_setParams4100(uint16_t addr, uint8_t val) +{ + (void)addr; (void)val; + if(m36.mode == 0) + { + if(m36.invert) //reverse of the get + m36.reg = (m36.input&8)|((m36.input^7)&7); + else m36.reg = (m36.input&0xF); + } //special reg increase + else m36.reg = (m36.reg&8)|((m36.reg+1)&7); +} +static void m132_setParams4101(uint16_t addr, uint8_t val) { (void)addr; m36.invert = val&1; } +static void m132_setParams4102(uint16_t addr, uint8_t val) { (void)addr; m36.input = val&0xF; } +static void m132_setParams4103(uint16_t addr, uint8_t val) { (void)addr; m36.mode = val&1; } +static void m132_setParams8XXX(uint16_t addr, uint8_t val) +{ + (void)addr; (void)val; + chr8setBank0((m36.reg&3)<<13); + prg32setBank0(((m36.reg>>2)&1)<<15); +} +void m132_initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xE103; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m132_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m132_setParams4101); + else if(proc_addr == 0x4102) memInitMapperSetPointer(ori_addr, m132_setParams4102); + else if(proc_addr == 0x4103) memInitMapperSetPointer(ori_addr, m132_setParams4103); + else if(ori_addr >= 0x8000) memInitMapperSetPointer(ori_addr, m132_setParams8XXX); +} + static void m133_setParams(uint16_t addr, uint8_t val) { (void)addr; @@ -389,6 +444,31 @@ void m133_initSet8(uint16_t ori_addr) if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m133_setParams); } +static void m136_setParams4100(uint16_t addr, uint8_t val) +{ + (void)addr; (void)val; + if(m36.mode == 0) + { + if(m36.invert) //reverse of the get + m36.reg = (m36.input&0x30)|((m36.input^0xF)&0xF); + else m36.reg = (m36.input&0x3F); + } //special reg increase + else m36.reg = (m36.reg&0x30)|((m36.reg+1)&0xF); +} +static void m136_setParams4101(uint16_t addr, uint8_t val) { (void)addr; m36.invert = val&1; } +static void m136_setParams4102(uint16_t addr, uint8_t val) { (void)addr; m36.input = val&0x3F; } +static void m136_setParams4103(uint16_t addr, uint8_t val) { (void)addr; m36.mode = val&1; } +static void m136_setParams8XXX(uint16_t addr, uint8_t val) { (void)addr; (void)val; chr8setBank0((m36.reg&3)<<13); } +void m136_initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xE103; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m136_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m136_setParams4101); + else if(proc_addr == 0x4102) memInitMapperSetPointer(ori_addr, m136_setParams4102); + else if(proc_addr == 0x4103) memInitMapperSetPointer(ori_addr, m136_setParams4103); + else if(ori_addr >= 0x8000) memInitMapperSetPointer(ori_addr, m136_setParams8XXX); +} + static void m140_setParams(uint16_t addr, uint8_t val) { (void)addr; @@ -409,8 +489,8 @@ static void m144_setParams(uint16_t addr, uint8_t val) } void m144_initSet8(uint16_t addr) { - if(addr > 0x8000) //ignore 0x8000 - memInitMapperSetPointer(addr, m144_setParams); + if(addr <= 0x8000) return; //ignore 0x8000 + memInitMapperSetPointer(addr, m144_setParams); } static void m145_setParams(uint16_t addr, uint8_t val) @@ -444,14 +524,55 @@ static void m148_setParams(uint16_t addr, uint8_t val) } void m148_initSet8(uint16_t addr) { - if(addr >= 0x8000) - memInitMapperSetPointer(addr, m148_setParams); + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m148_setParams); } void m149_initSet8(uint16_t addr) { - if(addr >= 0x8000) //uses mapper 145 chr set type - memInitMapperSetPointer(addr, m145_setParams); + if(addr < 0x8000) return; + //uses mapper 145 chr set type + memInitMapperSetPointer(addr, m145_setParams); +} + +//again identical to 136, just the data bits get reversed +static void m172_setParams4100(uint16_t addr, uint8_t val) { m136_setParams4100(addr, m172doBitRev(val)); } +static void m172_setParams4101(uint16_t addr, uint8_t val) { m136_setParams4101(addr, m172doBitRev(val)); } +static void m172_setParams4102(uint16_t addr, uint8_t val) { m136_setParams4102(addr, m172doBitRev(val)); } +static void m172_setParams4103(uint16_t addr, uint8_t val) { m136_setParams4103(addr, m172doBitRev(val)); } +static void m172_setParams8XXX(uint16_t addr, uint8_t val) +{ + m136_setParams8XXX(addr,m172doBitRev(val)); + //actually something different to m136 + if(m36.invert) + ppuSetNameTblVertical(); + else + ppuSetNameTblHorizontal(); +} +void m172_initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xE103; + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m172_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m172_setParams4101); + else if(proc_addr == 0x4102) memInitMapperSetPointer(ori_addr, m172_setParams4102); + else if(proc_addr == 0x4103) memInitMapperSetPointer(ori_addr, m172_setParams4103); + else if(ori_addr >= 0x8000) memInitMapperSetPointer(ori_addr, m172_setParams8XXX); +} + +static void m173_setParams8XXX(uint16_t addr, uint8_t val) +{ + (void)addr; (void)val; + chr8setBank0( ( (m36.reg&1) | (((~m36.invert)&1)<<1) ) <<13 ); +} +void m173_initSet8(uint16_t ori_addr) +{ + uint16_t proc_addr = ori_addr&0xE103; + //all the 41.. writes are identical to 132, only the 8... write is different + if(proc_addr == 0x4100) memInitMapperSetPointer(ori_addr, m132_setParams4100); + else if(proc_addr == 0x4101) memInitMapperSetPointer(ori_addr, m132_setParams4101); + else if(proc_addr == 0x4102) memInitMapperSetPointer(ori_addr, m132_setParams4102); + else if(proc_addr == 0x4103) memInitMapperSetPointer(ori_addr, m132_setParams4103); + else if(ori_addr >= 0x8000) memInitMapperSetPointer(ori_addr, m173_setParams8XXX); } static void m185_setParams(uint16_t addr, uint8_t val) @@ -464,8 +585,8 @@ static void m185_setParams(uint16_t addr, uint8_t val) } void m185_initSet8(uint16_t addr) { - if(addr >= 0x8000) - memInitMapperSetPointer(addr, m185_setParams); + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m185_setParams); } static void m201_setParams(uint16_t addr, uint8_t val) @@ -476,8 +597,8 @@ static void m201_setParams(uint16_t addr, uint8_t val) } void m201_initSet8(uint16_t addr) { - if(addr >= 0x8000) - memInitMapperSetPointer(addr, m201_setParams); + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m201_setParams); } static void m240_setParams(uint16_t addr, uint8_t val) @@ -507,8 +628,8 @@ void m242_initSet8(uint16_t addr) { if(p32c8_usesPrgRAM) prgRAM8initSet8(addr); - if(addr >= 0x8000) - memInitMapperSetPointer(addr, m242_setParams); + if(addr < 0x8000) return; + memInitMapperSetPointer(addr, m242_setParams); } static uint8_t m185_chrGetGarbage(uint16_t addr) { (void)addr; return 1; } diff --git a/mapperList.c b/mapperList.c index aa2447e..d4fd2fc 100644 --- a/mapperList.c +++ b/mapperList.c @@ -15,15 +15,20 @@ #include "mapper_h/mmc5.h" #include "mapper_h/m13.h" #include "mapper_h/m15.h" +#include "mapper_h/m28.h" +#include "mapper_h/m31.h" #include "mapper_h/m32.h" #include "mapper_h/m33.h" #include "mapper_h/m34.h" #include "mapper_h/m48.h" #include "mapper_h/m65.h" +#include "mapper_h/m137.h" #include "mapper_h/m156.h" +#include "mapper_h/m193.h" #include "mapper_h/m206.h" #include "mapper_h/m225.h" #include "mapper_h/m228.h" +#include "mapper_h/m237.h" #include "mapper_h/namco.h" #include "mapper_h/p16c8.h" #include "mapper_h/p32c8.h" @@ -71,10 +76,10 @@ mapperList_t mapperList[256] = { { vrc2_4_init, vrc2_4_initGet8, m25_initSet8, chr1initPPUGet8, chr1initPPUSet8, vrc_irq_cycle, NULL }, { vrc6init, vrc6initGet8, m26_initSet8, chr1initPPUGet8, chr1initPPUSet8, vrc6cycle, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m28init, m28initGet8, m28initSet8, m28initPPUGet8, m28initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m31init, prg4initGet8, m31initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { m32init, m32initGet8, m32initSet8, chr1initPPUGet8, chr1initPPUSet8, NULL, NULL }, { m33init, prg8initGet8, m33initSet8, chr1initPPUGet8, chr1initPPUSet8, NULL, NULL }, { m34init, m34initGet8, m34initSet8, chr4initPPUGet8, chr4initPPUSet8, NULL, NULL }, @@ -101,7 +106,7 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { m57_init, prg16initGet8, m57_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, - { p1632c8init, prg16initGet8, m58_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, + { m58_init, prg16initGet8, m58_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m58_reset }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { m60_init, prg16initGet8, m60_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m60_reset }, { p1632c8init, prg16initGet8, m61_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, @@ -150,7 +155,7 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { p32c8init, prg32initGet8, m107_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -175,16 +180,16 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m36_init, m132_initGet8, m132_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { p32c8init, prg32initGet8, m133_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m36_init, m136_initGet8, m136_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, + { m137init, prg32initGet8, m137initSet8, chr1initPPUGet8, chr1initPPUSet8, NULL, NULL }, + { m138init, prg32initGet8, m138initSet8, chr2initPPUGet8, chr2initPPUSet8, NULL, NULL }, + { m139init, prg32initGet8, m139initSet8, chr2initPPUGet8, chr2initPPUSet8, NULL, NULL }, { p32c8init, prg32initGet8, m140_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m141init, prg32initGet8, m141initSet8, chr2initPPUGet8, chr2initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { p32c8init, prg32initGet8, m144_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, @@ -215,8 +220,8 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m36_init, m172_initGet8, m172_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, + { m36_init, m132_initGet8, m173_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { m174_init, prg16initGet8, m174_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -236,7 +241,7 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m193init, prg8initGet8, m193initSet8, chr2initPPUGet8, chr2initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -255,8 +260,7 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { namco_init, namco_initGet8, namco_initSet8, namco_initPPUGet8, namco_initPPUSet8, namco_cycle, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { m174_init, prg16initGet8, m212_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m174_init, m212_initGet8, m212_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, @@ -265,22 +269,23 @@ mapperList_t mapperList[256] = { { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m221_init, prg16initGet8, m221_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m221_reset }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { m225init, m225initGet8, m225initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, - { p1632c8init, prg16initGet8, m226_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, + { m225init, m225initGet8, m225initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m225reset }, + { m226_init, prg16initGet8, m226_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m226_reset }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { m228init, m228initGet8, m228initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { p1632c8init, prg16initGet8, m229_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, + { m230_init, prg16initGet8, m230_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m230_reset }, { m231_init, prg16initGet8, m231_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { m232_init, prg16initGet8, m232_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m235_init, prg16initGet8, m235_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m235_reset }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + { m237init, m237initGet8, m237initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, m237reset }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { p32c8RAMinit, p32c8RAMinitGet8, m240_initSet8, chr8initPPUGet8, chr8initPPUSet8, NULL, NULL }, diff --git a/mapper_h/common.h b/mapper_h/common.h index 853bc5e..5cd3f20 100644 --- a/mapper_h/common.h +++ b/mapper_h/common.h @@ -8,6 +8,17 @@ #ifndef _COMMON_H_ #define _COMMON_H_ +void prg4init(uint8_t *prgROM, uint32_t prgROMsize); +void prg4initGet8(uint16_t addr); +void prg4setBank0(uint32_t val); +void prg4setBank1(uint32_t val); +void prg4setBank2(uint32_t val); +void prg4setBank3(uint32_t val); +void prg4setBank4(uint32_t val); +void prg4setBank5(uint32_t val); +void prg4setBank6(uint32_t val); +void prg4setBank7(uint32_t val); + void prg8init(uint8_t *prgROM, uint32_t prgROMsize); void prg8initGet8(uint16_t addr); void prg8setBank0(uint32_t val); diff --git a/mapper_h/m137.h b/mapper_h/m137.h new file mode 100644 index 0000000..5eb5172 --- /dev/null +++ b/mapper_h/m137.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef m137_h_ +#define m137_h_ + +void m137init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m138init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m139init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m141init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m137initSet8(uint16_t addr); +void m138initSet8(uint16_t addr); +void m139initSet8(uint16_t addr); +void m141initSet8(uint16_t addr); + +#endif diff --git a/mapper_h/m193.h b/mapper_h/m193.h new file mode 100644 index 0000000..a391d11 --- /dev/null +++ b/mapper_h/m193.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef m193_h_ +#define m193_h_ + +void m193init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m193initSet8(uint16_t addr); + +#endif diff --git a/mapper_h/m225.h b/mapper_h/m225.h index 7bf2c9b..f400141 100644 --- a/mapper_h/m225.h +++ b/mapper_h/m225.h @@ -13,5 +13,6 @@ void m225init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *chrROM, uint32_t chrROMsize); void m225initGet8(uint16_t addr); void m225initSet8(uint16_t addr); +void m225reset(); #endif diff --git a/mapper_h/m237.h b/mapper_h/m237.h new file mode 100644 index 0000000..0765244 --- /dev/null +++ b/mapper_h/m237.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef m237_h_ +#define m237_h_ + +void m237init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m237initGet8(uint16_t addr); +void m237initSet8(uint16_t addr); +void m237reset(); + +#endif diff --git a/mapper_h/m28.h b/mapper_h/m28.h new file mode 100644 index 0000000..63df478 --- /dev/null +++ b/mapper_h/m28.h @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2017 - 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef m28_h_ +#define m28_h_ + +void m28init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m28initGet8(uint16_t addr); +void m28initSet8(uint16_t addr); +void m28initPPUGet8(uint16_t addr); +void m28initPPUSet8(uint16_t addr); + +#endif diff --git a/mapper_h/m31.h b/mapper_h/m31.h new file mode 100644 index 0000000..909da3a --- /dev/null +++ b/mapper_h/m31.h @@ -0,0 +1,16 @@ +/* + * Copyright (C) 2018 FIX94 + * + * This software may be modified and distributed under the terms + * of the MIT license. See the LICENSE file for details. + */ + +#ifndef m31_h_ +#define m31_h_ + +void m31init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m31initSet8(uint16_t addr); + +#endif diff --git a/mapper_h/p16c8.h b/mapper_h/p16c8.h index a115a47..5ef66aa 100644 --- a/mapper_h/p16c8.h +++ b/mapper_h/p16c8.h @@ -17,6 +17,9 @@ void p1632c8init(uint8_t *prgROM, uint32_t prgROMsize, void m57_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); +void m58_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); void m60_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); @@ -35,13 +38,25 @@ void m180_init(uint8_t *prgROM, uint32_t prgROMsize, void m200_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); +void m221_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m226_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m230_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); void m231_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); void m232_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); -void p16c8initGet8(uint16_t addr); +void m235_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m212_initGet8(uint16_t addr); uint8_t m97_get8(uint16_t addr, uint8_t val); uint8_t m180_get8(uint16_t addr, uint8_t val); uint8_t m200_get8(uint16_t addr, uint8_t val); @@ -67,10 +82,19 @@ void m200_initSet8(uint16_t addr); void m202_initSet8(uint16_t addr); void m203_initSet8(uint16_t addr); void m212_initSet8(uint16_t addr); +void m221_initSet8(uint16_t addr); void m226_initSet8(uint16_t addr); +void m229_initSet8(uint16_t addr); +void m230_initSet8(uint16_t addr); void m231_initSet8(uint16_t addr); void m232_initSet8(uint16_t addr); +void m235_initSet8(uint16_t addr); +void m58_reset(); void m60_reset(); void m62_reset(); +void m221_reset(); +void m226_reset(); +void m230_reset(); +void m235_reset(); #endif diff --git a/mapper_h/p32c8.h b/mapper_h/p32c8.h index 3ab99d7..71eef70 100644 --- a/mapper_h/p32c8.h +++ b/mapper_h/p32c8.h @@ -26,6 +26,12 @@ void m41_init(uint8_t *prgROM, uint32_t prgROMsize, void m46_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); +void m132_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); +void m136_init(uint8_t *prgROM, uint32_t prgROMsize, + uint8_t *prgRAM, uint32_t prgRAMsize, + uint8_t *chrROM, uint32_t chrROMsize); void m185_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize); @@ -34,6 +40,9 @@ void m242_init(uint8_t *prgROM, uint32_t prgROMsize, uint8_t *chrROM, uint32_t chrROMsize); void p32c8RAMinitGet8(uint16_t addr); void m36_initGet8(uint16_t addr); +void m132_initGet8(uint16_t addr); +void m136_initGet8(uint16_t addr); +void m172_initGet8(uint16_t addr); void m0_initSet8(uint16_t addr); void m3_initSet8(uint16_t addr); void m7_initSet8(uint16_t addr); @@ -46,14 +55,19 @@ void m66_initSet8(uint16_t addr); void m79_initSet8(uint16_t addr); void m87_initSet8(uint16_t addr); void m101_initSet8(uint16_t addr); +void m107_initSet8(uint16_t addr); void m113_initSet8(uint16_t addr); +void m132_initSet8(uint16_t addr); void m133_initSet8(uint16_t addr); +void m136_initSet8(uint16_t addr); void m140_initSet8(uint16_t addr); void m144_initSet8(uint16_t addr); void m145_initSet8(uint16_t addr); void m147_initSet8(uint16_t addr); void m148_initSet8(uint16_t addr); void m149_initSet8(uint16_t addr); +void m172_initSet8(uint16_t addr); +void m173_initSet8(uint16_t addr); void m185_initSet8(uint16_t addr); void m201_initSet8(uint16_t addr); void m240_initSet8(uint16_t addr);