Skip to content

Commit

Permalink
MMC5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
FIX94 committed Aug 21, 2017
1 parent e6145f2 commit 1c2eabf
Show file tree
Hide file tree
Showing 10 changed files with 989 additions and 295 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -3,7 +3,7 @@ This is yet another NES Emulator which was written so I can learn about the NES,
If you want to check it out for some reason I do include a windows binary in the "Releases" tab, if you want to compile it go check out the "build" files.
You will need freeglut as well as openal-soft to compile the project, it should run on most systems since it is fairly generic C code.
NTSC and PAL .nes ROMs are supported right now, it also creates .sav files if the chosen game supports saving.
Supported Mappers: 0,1,2,3,4,7,9,10,11,13,15,21,22,23,24,25,26,33,34,36,37,38,44,45,46,47,48,52,61,66,70,71,75,78,79,85,87,89,93,94,97,99,101,113,133,140,144,145,146,147,148,149,152,180,184,185,240 and 242.
Supported Mappers: 0,1,2,3,4,5,7,9,10,11,13,15,21,22,23,24,25,26,33,34,36,37,38,44,45,46,47,48,52,61,66,70,71,75,78,79,85,87,89,93,94,97,99,101,113,133,140,144,145,146,147,148,149,152,180,184,185,240 and 242.
Normal .nes files are supported, if you are starting a PAL NES title then make sure it has (E) in the name 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 files, changing tracks works by pressing left/right.
Expand Down
11 changes: 8 additions & 3 deletions main.c
Expand Up @@ -32,7 +32,7 @@
#define DEBUG_KEY 0
#define DEBUG_LOAD_INFO 1

static const char *VERSION_STRING = "fixNES Alpha v0.9.1";
static const char *VERSION_STRING = "fixNES Alpha v0.9.2";
static char window_title[256];
static char window_title_pause[256];

Expand Down Expand Up @@ -124,8 +124,13 @@ int main(int argc, char** argv)
bool trainer = (emuNesROM[6] & (1<<2)) != 0;
uint32_t prgROMsize = emuNesROM[4] * 0x4000;
uint32_t chrROMsize = emuNesROM[5] * 0x2000;
emuPrgRAMsize = emuNesROM[8] * 0x2000;
if(emuPrgRAMsize == 0) emuPrgRAMsize = 0x2000;
if(mapper == 5) //just to be on the safe side
emuPrgRAMsize = 0x10000;
else
{
emuPrgRAMsize = emuNesROM[8] * 0x2000;
if(emuPrgRAMsize == 0) emuPrgRAMsize = 0x2000;
}
emuPrgRAM = malloc(emuPrgRAMsize);
uint8_t *prgROM = emuNesROM+16;
if(trainer)
Expand Down
17 changes: 16 additions & 1 deletion mapper.c
Expand Up @@ -12,13 +12,16 @@
#include "mapperList.h"
#include "mapper_h/nsf.h"
#include "mapper_h/fds.h"
#include "ppu.h"

get8FuncT mapperGet8;
set8FuncT mapperSet8;
getChrFuncT mapperGetChr;
chrGet8FuncT mapperChrGet8;
chrSet8FuncT mapperChrSet8;
vramGet8FuncT mapperVramGet8;
vramSet8FuncT mapperVramSet8;
cycleFuncT mapperCycle;
uint8_t mapperChrMode;

bool mapperInit(uint8_t mapper, uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize)
{
Expand All @@ -33,6 +36,16 @@ bool mapperInit(uint8_t mapper, uint8_t *prgROM, uint32_t prgROMsize, uint8_t *p
mapperChrGet8 = mapperList[mapper].chrGet8F;
mapperChrSet8 = mapperList[mapper].chrSet8F;
mapperCycle = mapperList[mapper].cycleFuncF;
//some mappers re-route VRAM
if(mapperList[mapper].vramGet8F == NULL)
mapperVramGet8 = ppuVRAMGet8;
else
mapperVramGet8 = mapperList[mapper].vramGet8F;
if(mapperList[mapper].vramSet8F == NULL)
mapperVramSet8 = ppuVRAMSet8;
else
mapperVramSet8 = mapperList[mapper].vramSet8F;
mapperChrMode = 0;
return true;
}

Expand All @@ -44,6 +57,7 @@ bool mapperInitNSF(uint8_t *nsfBIN, uint32_t nsfBINsize, uint8_t *prgRAM, uint32
mapperChrGet8 = nsfchrGet8;
mapperChrSet8 = nsfchrSet8;
mapperCycle = nsfcycle;
mapperChrMode = 0;
return true;
}

Expand Down Expand Up @@ -78,5 +92,6 @@ bool mapperInitFDS(uint8_t *fdsFile, bool fdsSideB, uint8_t *prgRAM, uint32_t pr
mapperChrGet8 = fdschrGet8;
mapperChrSet8 = fdschrSet8;
mapperCycle = fdscycle;
mapperChrMode = 0;
return true;
}
6 changes: 5 additions & 1 deletion mapper.h
Expand Up @@ -13,7 +13,8 @@ typedef uint8_t (*get8FuncT)(uint16_t, uint8_t);
typedef void (*set8FuncT)(uint16_t, uint8_t);
typedef uint8_t (*chrGet8FuncT)(uint16_t);
typedef void (*chrSet8FuncT)(uint16_t, uint8_t);
typedef uint8_t* (*getChrFuncT)();
typedef uint8_t (*vramGet8FuncT)(uint16_t);
typedef void (*vramSet8FuncT)(uint16_t, uint8_t);
typedef void (*cycleFuncT)();

bool mapperInit(uint8_t mapper, uint8_t *prgROM, uint32_t prgROMsize, uint8_t *prgRAM, uint32_t prgRAMsize, uint8_t *chrROM, uint32_t chrROMsize);
Expand All @@ -24,6 +25,9 @@ extern get8FuncT mapperGet8;
extern set8FuncT mapperSet8;
extern chrGet8FuncT mapperChrGet8;
extern chrSet8FuncT mapperChrSet8;
extern vramGet8FuncT mapperVramGet8;
extern vramSet8FuncT mapperVramSet8;
extern cycleFuncT mapperCycle;
extern uint8_t mapperChrMode;

#endif

0 comments on commit 1c2eabf

Please sign in to comment.