Skip to content

Commit

Permalink
Added support for mapper 272.
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Oct 4, 2023
1 parent 9bfd2a2 commit 8637aa6
Show file tree
Hide file tree
Showing 8 changed files with 206 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Changelog:
- Added Polish translation (thx to elektronicznypank).
- Added fully support to NES 2.0 file cart format header.
- Rewritten mappers : All.
- Added support to mapper : 100, 122, 157, 291, 311, 334, 362, 366, 384, 421, 446, 471, 551, 552, 561.
- Added support to mapper : 100, 122, 157, 272, 291, 311, 334, 362, 366, 384, 421, 446, 471, 551, 552, 561.
- Added support to UNIF mapper : Transformer, UNROM, AMROM, AOROM, LH09, A60AS, T4A54A, FC-28-5027, 150in1A, 212-HONG-KONG, GKCXIN, 113in1JY110, 820561C, M2C52A, S-2009.
- Windows x86_64: Update to Qt5 5.15.8 (#279).
- Fixed map of one keyboard button to multiple controllers (#277).
Expand All @@ -19,6 +19,7 @@ Changelog:
* Linux/BSD - {default system datadir}/puNES
* Windows - directory where the executable is placed.
if you want to use a more updated version than the one distributed with the emulator, just copy it either in the executable directory or in the working directory of the emulator, which can also be opened from the "File -> Open working directory" menu.
- Added full support for Vs System (UniSystem and DualSystem).
- Rewritten WRAM, VRAM, PRGROM, CHROM and Nametebles management.
- Rewritten the format and management of save states.
WARNING save states of version 0.110 or earlier are no longer compatible.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ To see a list of available command-line options, start puNES with the `-h` argum
| 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | | 240 | 241 |
| 242 | 243 | 244 | 245 | 246 | | 248 | 249 | 250 | | 252 |
| 253 | 254 | 255 | 256 | | 258 | 259 | 260 | 261 | 262 | 263 |
| 264 | 265 | 266 | 267 | 268 | 269 | | 271 | | | 274 |
| 264 | 265 | 266 | 267 | 268 | 269 | | 271 | 272 | | 274 |
| | | | | | | 281 | 282 | 283 | 284 | 285 |
| 286 | 287 | 288 | 289 | 290 | 291 | 292 | | | 295 | |
| 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 |
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ set(core_srcs
core/mappers/mapper_268.c
core/mappers/mapper_269.c
core/mappers/mapper_271.c
core/mappers/mapper_272.c
core/mappers/mapper_274.c
core/mappers/mapper_281.c
core/mappers/mapper_282.c
Expand Down
6 changes: 4 additions & 2 deletions src/core/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -2771,8 +2771,6 @@ static const _dbelement dblist[] = {

/* Akumajou Special - Boku Dracula-kun (J) [o1].nes */
{"f7baf2b7f4e2bff59d57f9c249c532fc52decbc2", 23, 2, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},
/* Akumajou Special - Boku Dracula-kun (J) [p1][t1].nes */
{"4dcff251754747ede445b6cd7cc894f11bff3d95", 23, 2, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},
/* Akumajou Special - Boku Dracula-kun (J) [t1].nes */
{"5582871715c4d7a5ed432a78b5c5c10cfa7c157a", 23, 2, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},
/* Akumajou Special - Boku Dracula-kun (J) [t2].nes */
Expand Down Expand Up @@ -4010,6 +4008,10 @@ static const _dbelement dblist[] = {
/* 4-in-1 (MGC-026, TXC, Idea-Tek).nes */
{"a612291ad4cd3a9a4dc8a3ff511a7c3f4979d0af", 271, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},

/* -------------------------------------------- 272 --------------------------------------- */
/* Akumajou Special - Boku Dracula-kun (J) [p1][t1].nes */
{"4dcff251754747ede445b6cd7cc894f11bff3d95", 272, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},

/* -------------------------------------------- 291 --------------------------------------- */
/* 2-in-1- Mortal Kombat VI + Mortal Kombat VII (Multi)[Unknown][NT-639].nes */
{"4478cd97d34a1e5b7e0498851b36d6afa8172a76", 291, DEFAULT, DEFAULT, DEFAULT, DEFAULT, DEFAULT, NOEXTRA},
Expand Down
3 changes: 3 additions & 0 deletions src/core/mappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ BYTE map_init(void) {
case 271:
map_init_271();
break;
case 272:
map_init_272();
break;
case 274:
map_init_274();
break;
Expand Down
1 change: 1 addition & 0 deletions src/core/mappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@
#include "mappers/mapper_268.h"
#include "mappers/mapper_269.h"
#include "mappers/mapper_271.h"
#include "mappers/mapper_272.h"
#include "mappers/mapper_274.h"
#include "mappers/mapper_281.h"
#include "mappers/mapper_282.h"
Expand Down
162 changes: 162 additions & 0 deletions src/core/mappers/mapper_272.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Copyright (C) 2010-2023 Fabio Cavallo (aka FHorse)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#include <string.h>
#include "mappers.h"
#include "cpu.h"
#include "save_slot.h"

INLINE static void prg_fix_272(void);
INLINE static void chr_fix_272(void);
INLINE static void mirroring_fix_272(void);

struct _m272 {
BYTE prg[2];
BYTE chr[8];
BYTE mirroring[2];
struct _m272_irq {
BYTE enabled;
BYTE counter;
WORD index;
} irq;
} m272;

void map_init_272(void) {
EXTCL_AFTER_MAPPER_INIT(272);
EXTCL_CPU_WR_MEM(272);
EXTCL_SAVE_MAPPER(272);
EXTCL_PPU_000_TO_34X(272);
mapper.internal_struct[0] = (BYTE *)&m272;
mapper.internal_struct_size[0] = sizeof(m272);

if (info.reset >= HARD) {
memset(&m272, 0x00, sizeof(m272));
}
}
void extcl_after_mapper_init_272(void) {
prg_fix_272();
chr_fix_272();
mirroring_fix_272();
}
void extcl_cpu_wr_mem_272(BYTE nidx, WORD address, BYTE value) {
switch (address & 0xC000) {
case 0x8000:
if ((address & 0x000C) == 0x0004) {
m272.mirroring[0] = value & 0x03;
mirroring_fix_272();
} else if ((address & 0x000C) == 0x000C) {
nes[nidx].c.irq.high |= EXT_IRQ;
}
break;
case 0xC000:
if ((address & 0x000C) == 0x0004) {
nes[nidx].c.irq.high &= ~EXT_IRQ;
} else if ((address & 0x000C) == 0x0008) {
m272.irq.enabled = TRUE;
} else if ((address & 0x000C) == 0x000C) {
nes[nidx].c.irq.high &= ~EXT_IRQ;
m272.irq.enabled = FALSE;
m272.irq.counter = 0;
}
break;
}
switch (address & 0xF000) {
case 0x8000:
m272.prg[0] = value;
prg_fix_272();
break;
case 0x9000:
m272.mirroring[1] = value & 0x01;
mirroring_fix_272();
break;
case 0xA000:
m272.prg[1] = value;
prg_fix_272();
break;
case 0xF000:
break;
default: {
BYTE index = ((address - 0xB000) >> 11) | ((address & 0x02) >> 1);

if (address & 0x0001) {
m272.chr[index] = (m272.chr[index] & 0x0F) | ((value & 0x0F) << 4);
} else {
m272.chr[index] = (m272.chr[index] & 0xF0) | (value & 0x0F);
}
chr_fix_272();
break;
}
}
}
BYTE extcl_save_mapper_272(BYTE mode, BYTE slot, FILE *fp) {
save_slot_ele(mode, slot, m272.prg);
save_slot_ele(mode, slot, m272.chr);
save_slot_ele(mode, slot, m272.mirroring);
save_slot_ele(mode, slot, m272.irq.enabled);
save_slot_ele(mode, slot, m272.irq.counter);
return (EXIT_OK);
}
void extcl_ppu_000_to_34x_272(BYTE nidx) {
if (nes[nidx].p.r2001.visible && ((nes[nidx].p.ppu.frame_y >= nes[nidx].p.ppu_sclines.vint)) &&
(nes[nidx].p.ppu.frame_y < nes[nidx].p.ppu_sclines.total)) {
if (++m272.irq.index == 6) {
if (m272.irq.enabled && (++m272.irq.counter == 84)) {
nes[nidx].c.irq.high |= EXT_IRQ;
m272.irq.counter = 0;
}
} else if (m272.irq.index == 8) {
m272.irq.index = 0;
}
}
if (nes[nidx].p.ppu.frame_x == 340) {
m272.irq.index = 0;
}
}

INLINE static void prg_fix_272(void) {
memmap_auto_8k(0, MMCPU(0x8000), m272.prg[0]);
memmap_auto_8k(0, MMCPU(0xA000), m272.prg[1]);
memmap_auto_16k(0, MMCPU(0xC000), 0xFF);
}
INLINE static void chr_fix_272(void) {
memmap_auto_1k(0, MMPPU(0x0000), m272.chr[0]);
memmap_auto_1k(0, MMPPU(0x0400), m272.chr[1]);
memmap_auto_1k(0, MMPPU(0x0800), m272.chr[2]);
memmap_auto_1k(0, MMPPU(0x0C00), m272.chr[3]);
memmap_auto_1k(0, MMPPU(0x1000), m272.chr[4]);
memmap_auto_1k(0, MMPPU(0x1400), m272.chr[5]);
memmap_auto_1k(0, MMPPU(0x1800), m272.chr[6]);
memmap_auto_1k(0, MMPPU(0x1C00), m272.chr[7]);
}
INLINE static void mirroring_fix_272(void) {
switch (m272.mirroring[0]) {
default:
if (m272.mirroring[1]) {
mirroring_H(0);
} else {
mirroring_V(0);
}
break;
case 2:
mirroring_SCR0(0);
break;
case 3:
mirroring_SCR1(0);
break;
}
}
32 changes: 32 additions & 0 deletions src/core/mappers/mapper_272.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2010-2023 Fabio Cavallo (aka FHorse)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef MAPPER_272_H_
#define MAPPER_272_H_

#include "common.h"

void map_init_272(void);
void extcl_after_mapper_init_272(void);
void extcl_cpu_wr_mem_272(BYTE nidx, WORD address, BYTE value);
BYTE extcl_save_mapper_272(BYTE mode, BYTE slot, FILE *fp);

void extcl_ppu_000_to_34x_272(BYTE nidx);
void extcl_rd_ppu_mem_272(BYTE nidx, WORD address);

#endif /* MAPPER_272_H_ */

0 comments on commit 8637aa6

Please sign in to comment.