Refactoring: move extra CHR-RAM and WRAM into one CartRAM module.
This commit is contained in:
@@ -20,9 +20,8 @@
|
||||
|
||||
#include "mapinc.h"
|
||||
#include "asic_vrc2and4.h"
|
||||
#include "cartram.h"
|
||||
|
||||
static uint8 *CHRRAM;
|
||||
static uint32 CHRRAMSize;
|
||||
static uint8 nt[4];
|
||||
static uint8 prg;
|
||||
static uint8 mask;
|
||||
@@ -48,7 +47,7 @@ static void sync () {
|
||||
}
|
||||
|
||||
static const uint8 compares[8] = { 0x28, 0x00, 0x4C, 0x64, 0x46, 0x7C, 0x04, 0xFF };
|
||||
static DECLFW(Mapper544_interceptPPUWrite) {
|
||||
static DECLFW (interceptPPUWrite) {
|
||||
if (~RefreshAddr &0x2000) {
|
||||
int bank =VRC24_getCHRBank(RefreshAddr >>10 &7);
|
||||
if (bank &0x80) {
|
||||
@@ -66,11 +65,11 @@ static DECLFW(Mapper544_interceptPPUWrite) {
|
||||
writePPU(A, V);
|
||||
}
|
||||
|
||||
int Mapper544_getPRGBank(uint8 bank) {
|
||||
static int getPRGBank (uint8 bank) {
|
||||
return bank ==2? prg: VRC24_getPRGBank(bank);
|
||||
}
|
||||
|
||||
DECLFW(Mapper544_externalSelect) {
|
||||
static DECLFW (externalSelect) {
|
||||
if (A &4)
|
||||
nt[A &3] =V;
|
||||
else
|
||||
@@ -79,7 +78,7 @@ DECLFW(Mapper544_externalSelect) {
|
||||
}
|
||||
|
||||
|
||||
void Mapper544_power (void) {
|
||||
void power (void) {
|
||||
mask =0xFC;
|
||||
compare =0x28;
|
||||
nt[0] =nt[1] =0xE0;
|
||||
@@ -87,24 +86,12 @@ void Mapper544_power (void) {
|
||||
prg =0xFE;
|
||||
VRC24_power();
|
||||
writePPU =GetWriteHandler(0x2007);
|
||||
SetWriteHandler(0x2007, 0x2007, Mapper544_interceptPPUWrite);
|
||||
}
|
||||
|
||||
void Mapper544_close(void) {
|
||||
if (CHRRAM) {
|
||||
FCEU_gfree(CHRRAM);
|
||||
CHRRAM =NULL;
|
||||
}
|
||||
SetWriteHandler(0x2007, 0x2007, interceptPPUWrite);
|
||||
}
|
||||
|
||||
void Mapper544_Init (CartInfo *info) {
|
||||
VRC4_init(info, sync, 0x400, 0x800, 1, Mapper544_getPRGBank, NULL, NULL, NULL, Mapper544_externalSelect);
|
||||
info->Power =Mapper544_power;
|
||||
info->Close =Mapper544_close;
|
||||
VRC4_init(info, sync, 0x400, 0x800, 1, getPRGBank, NULL, NULL, NULL, externalSelect);
|
||||
CartRAM_init(info, 8, 2);
|
||||
info->Power =power;
|
||||
AddExState(stateRegs, ~0, 0, 0);
|
||||
|
||||
CHRRAMSize =info->CHRRamSize +info->CHRRamSaveSize;
|
||||
CHRRAM =(uint8*)FCEU_gmalloc(CHRRAMSize);
|
||||
AddExState(CHRRAM, CHRRAMSize, 0, "CRAM");
|
||||
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSize, 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user