Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1 batch of backports/cleanups #575

Merged
merged 24 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 10 additions & 12 deletions src/boards/09-034a.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,35 @@ static SFORMAT StateRegs[] =
{ 0 }
};

static void Sync(void) {
static void UNLSMB2JSync(void) {
setprg8(0x6000, 4 | prg);
setprg32(0x8000, 0);
setchr8(0);
}

static DECLFW(UNLSMB2JWrite1) {
static void UNLSMB2JWrite1(uint32 A, uint8 V) {
prg = V & 1;
Sync();
UNLSMB2JSync();
}

static DECLFW(UNLSMB2JWrite2) {
static void UNLSMB2JWrite2(uint32 A, uint8 V) {
IRQa = V & 1;
IRQCount = 0;
X6502_IRQEnd(FCEU_IQEXT);
}

static DECLFR(UNLSMB2JRead) {
return 0xFF;
}
static uint8 UNLSMB2JRead(uint32 A) { return 0xFF; }

static void UNLSMB2JPower(void) {
prg = 0;
Sync();
UNLSMB2JSync();
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetReadHandler(0x4042, 0x4055, UNLSMB2JRead);
SetWriteHandler(0x4068, 0x4068, UNLSMB2JWrite2);
SetWriteHandler(0x4027, 0x4027, UNLSMB2JWrite1);
}

static void FP_FASTAPASS(1) UNLSMB2JIRQHook(int a) {
static void UNLSMB2JIRQHook(int a) {
if (IRQa)
{
if (IRQCount < 5750) /* completely by guess */
Expand All @@ -85,13 +83,13 @@ static void FP_FASTAPASS(1) UNLSMB2JIRQHook(int a) {
}
}

static void StateRestore(int version) {
Sync();
static void UNLSMB2JStateRestore(int version) {
UNLSMB2JSync();
}

void UNLSMB2J_Init(CartInfo *info) {
info->Power = UNLSMB2JPower;
MapIRQHook = UNLSMB2JIRQHook;
GameStateRestore = StateRestore;
GameStateRestore = UNLSMB2JStateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}
12 changes: 5 additions & 7 deletions src/boards/103.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,23 @@ static void Sync(void) {
setmirror(reg1 ^ 1);
}

static DECLFW(M103RamWrite0) {
WRAM[A & 0x1FFF] = V;
}
static void M103RamWrite0(uint32 A, uint8 V) { WRAM[A & 0x1FFF] = V; }

static DECLFW(M103RamWrite1) {
static void M103RamWrite1(uint32 A, uint8 V) {
WRAM[0x2000 + ((A - 0xB800) & 0x1FFF)] = V;
}

static DECLFW(M103Write0) {
static void M103Write0(uint32 A, uint8 V) {
reg0 = V & 0xf;
Sync();
}

static DECLFW(M103Write1) {
static void M103Write1(uint32 A, uint8 V) {
reg1 = (V >> 3) & 1;
Sync();
}

static DECLFW(M103Write2) {
static void M103Write2(uint32 A, uint8 V) {
reg2 = V;
Sync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/boards/104.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ static void Sync(void) {
setchr8(0);
}

static DECLFW(M104WriteBank) {
static void M104WriteBank(uint32 A, uint8 V) {
if ((V & 8) > 0) {
preg[0] = ((V << 4) & 0x70) | (preg[0] & 0x0F);
preg[1] = ((V << 4) & 0x70) | 0x0F;
Sync();
}
}

static DECLFW(M104WritePreg) {
static void M104WritePreg(uint32 A, uint8 V) {
preg[0] = (preg[0] & 0x70) | (V & 0x0F);
Sync();
}
Expand Down
4 changes: 2 additions & 2 deletions src/boards/106.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void Sync(void) {
setmirror((reg[0xc] & 1) ^ 1);
}

static DECLFW(M106Write) {
static void M106Write(uint32 A, uint8 V) {
A &= 0xF;
switch (A) {
case 0xD: IRQa = 0; IRQCount = 0; X6502_IRQEnd(FCEU_IQEXT); break;
Expand Down Expand Up @@ -78,7 +78,7 @@ static void M106Close(void) {
WRAM = NULL;
}

void FP_FASTAPASS(1) M106CpuHook(int a) {
void M106CpuHook(int a) {
if (IRQa) {
IRQCount += a;
if (IRQCount > 0x10000) {
Expand Down
6 changes: 2 additions & 4 deletions src/boards/108.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void Sync(void) {
setchr8(0);
}

static DECLFW(M108Write) {
static void M108Write(uint32 A, uint8 V) {
reg = V;
Sync();
}
Expand All @@ -53,9 +53,7 @@ static void M108Power(void) {
SetWriteHandler(0xF000, 0xFFFF, M108Write); /* simplified Kaiser BB Hack */
}

static void StateRestore(int version) {
Sync();
}
static void StateRestore(int version) { Sync(); }

void Mapper108_Init(CartInfo *info) {
info->Power = M108Power;
Expand Down
2 changes: 1 addition & 1 deletion src/boards/112.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static void Sync(void) {
setchr1(0x1C00, ((bank & 0x80) << 1) | reg[7]);
}

static DECLFW(M112Write) {
static void M112Write(uint32 A, uint8 V) {
switch (A) {
case 0xe000: mirror = V & 1; Sync();; break;
case 0x8000: cmd = V & 7; break;
Expand Down
6 changes: 2 additions & 4 deletions src/boards/116.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,7 @@ static void Sync(void) {
SyncMIR();
}

static DECLFW(UNLSL12ModeWrite) {
/* FCEU_printf("%04X:%02X\n",A,V); */
static void UNLSL12ModeWrite(uint32 A, uint8 V) {
if ((A & 0x4100) == 0x4100) {
mode = V;
if (A & 1) { /* hacky hacky, there are two configuration modes on SOMARI HUANG-1 PCBs
Expand All @@ -200,8 +199,7 @@ static DECLFW(UNLSL12ModeWrite) {
}
}

static DECLFW(UNLSL12Write) {
/* FCEU_printf("%04X:%02X\n",A,V); */
static void UNLSL12Write(uint32 A, uint8 V) {
switch (mode & 3) {
case 0: {
if ((A >= 0xB000) && (A <= 0xE003)) {
Expand Down
2 changes: 1 addition & 1 deletion src/boards/117.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static void Sync(void) {
setmirror(mirror ^ 1);
}

static DECLFW(M117Write) {
static void M117Write(uint32 A, uint8 V) {
if (A < 0x8004) {
prgreg[A & 3] = V;
Sync();
Expand Down
2 changes: 1 addition & 1 deletion src/boards/120.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void Sync(void) {
setchr8(0);
}

static DECLFW(M120Write) {
static void M120Write(uint32 A, uint8 V) {
if (A == 0x41FF) {
reg = V & 7;
Sync();
Expand Down
16 changes: 3 additions & 13 deletions src/boards/121.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,20 @@ static void M121PW(uint32 A, uint8 V) {
}
}

static DECLFW(M121Write) {
/* FCEU_printf("write: %04x:%04x\n",A&0xE003,V); */
static void M121Write(uint32 A, uint8 V) {
switch (A & 0xE003) {
case 0x8000:
/* EXPREGS[5] = 0; */
/* FCEU_printf("gen: %02x\n",V); */
MMC3_CMDWrite(A, V);
FixMMC3PRG(MMC3_cmd);
break;
case 0x8001:
EXPREGS[6] = ((V & 1) << 5) | ((V & 2) << 3) | ((V & 4) << 1) | ((V & 8) >> 1) | ((V & 0x10) >> 3) | ((V & 0x20) >> 5);
/* FCEU_printf("bank: %02x (%02x)\n",V,EXPREGS[6]); */
if (!EXPREGS[7]) Sync();
MMC3_CMDWrite(A, V);
FixMMC3PRG(MMC3_cmd);
break;
case 0x8003:
EXPREGS[5] = V;
/* EXPREGS[7] = 0; */
/* FCEU_printf("prot: %02x\n",EXPREGS[5]); */
Sync();
MMC3_CMDWrite(0x8000, V);
FixMMC3PRG(MMC3_cmd);
Expand All @@ -92,20 +86,16 @@ static DECLFW(M121Write) {
}

static uint8 prot_array[16] = { 0x83, 0x83, 0x42, 0x00 };
static DECLFW(M121LoWrite) {
static void M121LoWrite(uint32 A, uint8 V) {
EXPREGS[4] = prot_array[V & 3]; /* 0x100 bit in address seems to be switch arrays 0, 2, 2, 3 (Contra Fighter) */
if ((A & 0x5180) == 0x5180) { /* A9713 multigame extension */
EXPREGS[3] = V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
/* FCEU_printf("write: %04x:%04x\n",A,V); */
}

static DECLFR(M121Read) {
/* FCEU_printf("read: %04x->\n",A,EXPREGS[0]); */
return EXPREGS[4];
}
static uint8 M121Read(uint32 A) { return EXPREGS[4]; }

static void M121Power(void) {
EXPREGS[3] = 0x80;
Expand Down
6 changes: 3 additions & 3 deletions src/boards/126-422-534.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void wrapMirroring(uint8 V) {

}

static DECLFW(writeWRAM) {
static void writeWRAM(uint32 A, uint8 V) {
CartBW(A, V);
if ((A &3) ==2) { /* CNROM Bank (D0-D3), Bank Enable (D4-D6) and Bank Enable Lock (D7) */
int latchMask =0xFF &~(EXPREGS[2] &0x80? 0x70: 0x00) &~(EXPREGS [2] >>3 &0x0E);
Expand All @@ -122,7 +122,7 @@ static DECLFW(writeWRAM) {
}
}

static DECLFW(writeCart) {
static void writeCart(uint32 A, uint8 V) {
if ((EXPREGS[3] &0x09) ==0x09) /* UNROM and ANROM modes treat all writes to $8000-$FFFF as if they were going to $8000-$9FFF */
MMC3_CMDWrite(0x8000 | (EXPREGS[3] &0x08? 1: A) &1, V); /* A0 substitution only looks at bit 3 of register 3 */
else
Expand All @@ -132,7 +132,7 @@ static DECLFW(writeCart) {
MMC3_CMDWrite(A, V);
}

static DECLFR(readPRG) {
static uint8 readPRG(uint32 A) {
if (EXPREGS[1] &1) A =A &~1 | SL0 &1; /* Replace A0 with SL0 input */
return CartBR(A);
}
Expand Down
18 changes: 9 additions & 9 deletions src/boards/12in1.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ static SFORMAT StateRegs[] =
{ 0 }
};

static void Sync(void) {
static void BMC12IN1Sync(void) {
uint8 bank = (ctrl & 3) << 3;
setchr4(0x0000, (prgchr[0] >> 3) | (bank << 2));
setchr4(0x1000, (prgchr[1] >> 3) | (bank << 2));
Expand All @@ -46,28 +46,28 @@ static void Sync(void) {
setmirror(((ctrl & 4) >> 2) ^ 1);
}

static DECLFW(BMC12IN1Write) {
static void BMC12IN1Write(uint32 A, uint8 V) {
switch (A & 0xE000) {
case 0xA000: prgchr[0] = V; Sync(); break;
case 0xC000: prgchr[1] = V; Sync(); break;
case 0xE000: ctrl = V & 0x0F; Sync(); break;
case 0xA000: prgchr[0] = V; BMC12IN1Sync(); break;
case 0xC000: prgchr[1] = V; BMC12IN1Sync(); break;
case 0xE000: ctrl = V & 0x0F; BMC12IN1Sync(); break;
}
}

static void BMC12IN1Power(void) {
prgchr[0] = prgchr[1] = ctrl = 0;
Sync();
BMC12IN1Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, BMC12IN1Write);
}

static void StateRestore(int version) {
Sync();
static void BMC12IN1StateRestore(int version) {
BMC12IN1Sync();
}

void BMC12IN1_Init(CartInfo *info) {
info->Power = BMC12IN1Power;
GameStateRestore = StateRestore;
GameStateRestore = BMC12IN1StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

6 changes: 2 additions & 4 deletions src/boards/134.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ static void Mapper134_CHRWrap(uint32 A, uint8 V) {
setchr1(A, V &chrAND | chrOR &~chrAND);
}

static DECLFR(Mapper134_Read) {
return EXPREGS[0] &0x40? dip: CartBR(A);
}
static uint8 Mapper134_Read(uint32 A) { return EXPREGS[0] &0x40 ? dip : CartBR(A); }

static DECLFW(Mapper134_Write) {
static void Mapper134_Write(uint32 A, uint8 V) {
if (~EXPREGS[0] &0x80) {
EXPREGS[A &3] =V;
FixMMC3PRG(MMC3_cmd);
Expand Down
Loading
Loading