Skip to content

Commit

Permalink
Change mapper 269 back
Browse files Browse the repository at this point in the history
  • Loading branch information
LibretroAdmin committed Feb 27, 2024
1 parent e4a7ea8 commit b278b82
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/mappers/mapper269.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ static uint8 reg[4];
static uint8 cmd;

static void M269CW(uint16 A, uint16 V) {
uint32 mask = 0xFF >> (~reg[2] & 0xF);
uint32 base = ((reg[2] << 4) & 0xF00) | reg[0];

setchr1(A, (base & ~mask) | (V & mask));
uint16 NV = V;
if (reg[2] & 8)
NV &= (1 << ((reg[2] & 7) + 1)) - 1;
NV |= reg[0] | ((reg[2] & 0xF0) << 4);
setchr1(A, NV);
}

static void M269PW(uint16 A, uint16 V) {
uint32 mask = ~reg[3] & 0x3F;
uint32 base = ((reg[2] << 2) & 0x300) | reg[1];

setprg8(A, (base & ~mask) | (V & mask));
uint16 MV = V & ((reg[3] & 0x3F) ^ 0x3F);
MV |= reg[1];
MV |= ((reg[3] & 0x40) << 2);
setprg8(A, MV);
}

static DECLFW(M269Write5) {
Expand All @@ -53,6 +54,13 @@ static DECLFW(M269Write5) {
}
}

static void M269Close(void) {
MMC3_Close();
if (ROM.chr.data)
FCEU_free(ROM.chr.data);
ROM.chr.data = NULL;
}

static void M269Reset(void) {
reg[0] = reg[1] = reg[3] = cmd = 0;
reg[2] = 0x0F;
Expand All @@ -77,6 +85,7 @@ void Mapper269_Init(CartInfo *info) {
MMC3_pwrap = M269PW;
info->Power = M269Power;
info->Reset = M269Reset;
info->Close = M269Close;
AddExState(reg, 4, 0, "EXPR");
AddExState(&cmd, 1, 0, "CMD0");

Expand All @@ -91,5 +100,6 @@ void Mapper269_Init(CartInfo *info) {
ROM.chr.data[i] = unscrambleCHR(ROM.prg.data[i]);
}
SetupCartCHRMapping(0, ROM.chr.data, PRGsize[0], 0);
AddExState(ROM.chr.data, PRGsize[0], 0, "_CHR");
}
}

0 comments on commit b278b82

Please sign in to comment.