Skip to content

Commit

Permalink
Added support to mapper 354 (#355).
Browse files Browse the repository at this point in the history
  • Loading branch information
punesemu committed Dec 22, 2023
1 parent 5249080 commit e378474
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Changelog:
- Added full support for the NES 2.0 header format.
- Added video filter : "NTSC CRT LMP88959" and "NTSC NES LMP88959" (https://github.com/LMP88959/NTSC-CRT, Thx to LMP88959 for is great work).
- Added video filter : "PAL CRT LMP88959" and "PAL NES LMP88959" (https://github.com/LMP88959/PAL-CRT, Thx to LMP88959 for is great work).
- Added support to mapper : 100, 122, 157, 170, 272, 291, 311, 334, 362, 366, 384, 421, 446, 471, 517, 551, 552, 555, 561.
- Added support to mapper : 100, 122, 157, 170, 272, 291, 311, 334, 354, 362, 366, 384, 421, 446, 471, 517, 551, 552, 555, 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.
- Added full support for the Detach Barcode Reader of mapper 157.
- Added support for nes20db.xml and dip.cfg (many thx to NewRisingSun for is for his immense work).
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ To see a list of available command-line options, start puNES with the `-h` argum
| 319 | 320 | | 322 | 323 | 324 | 325 | | 327 | 328 | 329 |
| | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 |
| 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 |
| 352 | 353 | | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 |
| 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 |
| | | | 366 | | 368 | 369 | 370 | | 372 | |
| 374 | 375 | | 377 | | | 380 | 381 | 382 | | 384 |
| | 386 | 387 | 388 | 389 | 390 | | | 393 | 394 | 395 |
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ set(core_srcs
core/mappers/mapper_351.c
core/mappers/mapper_352.c
core/mappers/mapper_353.c
core/mappers/mapper_354.c
core/mappers/mapper_355.c
core/mappers/mapper_356.c
core/mappers/mapper_357.c
Expand Down
3 changes: 3 additions & 0 deletions src/core/mappers.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,9 @@ BYTE map_init(void) {
case 353:
map_init_353();
break;
case 354:
map_init_354();
break;
case 355:
map_init_355();
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 @@ -314,6 +314,7 @@
#include "mappers/mapper_351.h"
#include "mappers/mapper_352.h"
#include "mappers/mapper_353.h"
#include "mappers/mapper_354.h"
#include "mappers/mapper_355.h"
#include "mappers/mapper_356.h"
#include "mappers/mapper_357.h"
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/OneBus.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void extcl_cpu_wr_mem_OneBus(BYTE nidx, WORD address, BYTE value) {
}
BYTE extcl_cpu_rd_mem_OneBus(BYTE nidx, WORD address, UNUSED(BYTE openbus)) {
if ((address >= 0x4100) && (address <= 0x4FFF)) {
switch(address & 0x0FFF) {
switch (address & 0x0FFF) {
case 0x140: case 0x141: case 0x142: case 0x143: case 0x144: case 0x145: case 0x146: case 0x147:
case 0x148: case 0x149: case 0x14A: case 0x14B: case 0x14C: case 0x14D: case 0x14E: case 0x14F:
case 0x150: case 0x151: case 0x152: case 0x153: case 0x154: case 0x155: case 0x156: case 0x157:
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_034.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void map_init_034(void) {
type = 2;
}

switch(type) {
switch (type) {
default:
case 1: // NINA-01
EXTCL_AFTER_MAPPER_INIT(034_s1);
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_042.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void map_init_042(void) {
}
}

switch(info.mapper.submapper) {
switch (info.mapper.submapper) {
default:
case 1:
EXTCL_AFTER_MAPPER_INIT(042_s1);
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_085.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void map_init_085(void) {
EXTCL_APU_TICK(VRC7);
map_internal_struct_init((BYTE *)&vrc7, sizeof(vrc7));

switch(info.mapper.submapper) {
switch (info.mapper.submapper) {
case 1:
init_VRC7(0x08, 0x20, info.reset);
break;
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_236.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ BYTE extcl_save_mapper_236(BYTE mode, BYTE slot, FILE *fp) {
INLINE static void prg_fix_236(void) {
WORD bank = chrrom_size() ? (m236.reg[1] & 0x0F) : (m236.reg[1] & 0x07) | (m236.reg[0] << 3);

switch(m236.reg[1] & 0x30) {
switch (m236.reg[1] & 0x30) {
case 0x00:
case 0x10:
memmap_auto_16k(0, MMCPU(0x8000), bank);
Expand Down
111 changes: 111 additions & 0 deletions src/core/mappers/mapper_354.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* 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 "save_slot.h"

INLINE static void prg_fix_354(void);
INLINE static void chr_fix_354(void);
INLINE static void wram_fix_354(void);
INLINE static void mirroring_fix_354(void);

struct _m354 {
WORD reg[2];
} m354;

void map_init_354(void) {
EXTCL_AFTER_MAPPER_INIT(354);
EXTCL_CPU_WR_MEM(354);
EXTCL_SAVE_MAPPER(354);
map_internal_struct_init((BYTE *)&m354, sizeof(m354));

memset(&m354, 0x00, sizeof(m354));
}
void extcl_after_mapper_init_354(void) {
prg_fix_354();
chr_fix_354();
wram_fix_354();
mirroring_fix_354();
}
void extcl_cpu_wr_mem_354(UNUSED(BYTE nidx), WORD address, BYTE value) {
if (address >= (info.mapper.submapper == 0 ? 0xF000 : 0xE000)) {
m354.reg[0] = address;
m354.reg[1] = value;
prg_fix_354();
chr_fix_354();
wram_fix_354();
mirroring_fix_354();
}
}
BYTE extcl_save_mapper_354(BYTE mode, BYTE slot, FILE *fp) {
save_slot_ele(mode, slot, m354.reg);
return (EXIT_OK);
}

INLINE static void prg_fix_354(void) {
DBWORD bank = ((m354.reg[0] & 0x1000) >> 5) | ((m354.reg[0] & 0x10) << 2) | (m354.reg[1] & 0x3F);

switch (m354.reg[0] & 0x07) {
default:
case 0:
case 4:
memmap_auto_32k(0, MMCPU(0x8000), (bank >> 1));
break;
case 1:
memmap_auto_16k(0, MMCPU(0x8000), bank);
memmap_auto_16k(0, MMCPU(0xC000), (bank | 0x07));
break;
case 2:
case 6:
memmap_auto_8k(0, MMCPU(0x8000), ((bank << 1) | (m354.reg[1] >> 7)));
memmap_auto_8k(0, MMCPU(0xA000), ((bank << 1) | (m354.reg[1] >> 7)));
memmap_auto_8k(0, MMCPU(0xC000), ((bank << 1) | (m354.reg[1] >> 7)));
memmap_auto_8k(0, MMCPU(0xE000), ((bank << 1) | (m354.reg[1] >> 7)));
break;
case 3:
case 7:
memmap_auto_16k(0, MMCPU(0x8000), bank);
memmap_auto_16k(0, MMCPU(0xC000), bank);
break;
case 5:
memmap_auto_32k(0, MMCPU(0x8000), ((bank >> 1) | 0x03));
break;
}
}
INLINE static void chr_fix_354(void) {
BYTE enabled = !(m354.reg[0] & 0x08);

memmap_auto_wp_8k(0, MMPPU(0x0000), 0, TRUE, enabled);
}
INLINE static void wram_fix_354(void) {
DBWORD bank = ((m354.reg[0] & 0x1000) >> 5) | ((m354.reg[0] & 0x10) << 2) | (m354.reg[1] & 0x3F);

if ((m354.reg[0] & 0x0007) == 5) {
memmap_prgrom_8k(0, MMCPU(0x6000), ((bank << 1) | (m354.reg[1] >> 7)));
} else {
memmap_disable_8k(0, MMCPU(0x6000));
}
}
INLINE static void mirroring_fix_354(void) {
if (m354.reg[1] & 0x40) {
mirroring_H(0);
} else {
mirroring_V(0);
}
}
29 changes: 29 additions & 0 deletions src/core/mappers/mapper_354.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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_354_H_
#define MAPPER_354_H_

#include "common.h"

void map_init_354(void);
void extcl_after_mapper_init_354(void);
void extcl_cpu_wr_mem_354(BYTE nidx, WORD address, BYTE value);
BYTE extcl_save_mapper_354(BYTE mode, BYTE slot, FILE *fp);

#endif /* MAPPER_354_H_ */
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_390.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BYTE extcl_save_mapper_390(BYTE mode, BYTE slot, FILE *fp) {
INLINE static void prg_fix_390(void) {
WORD bank = m390.reg[1];

switch(m390.reg[1] & 0x30) {
switch (m390.reg[1] & 0x30) {
case 0x00:
case 0x10:
memmap_auto_16k(0, MMCPU(0x8000), bank);
Expand Down
2 changes: 1 addition & 1 deletion src/core/mappers/mapper_517.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ BYTE extcl_cpu_rd_mem_517(BYTE nidx, WORD address, UNUSED(BYTE openbus)) {
BYTE result = 0;

if (address == 0x6000) {
switch(m517.adc.state) {
switch (m517.adc.state) {
case 0:
m517.adc.state = 1;
result = 0;
Expand Down
1 change: 0 additions & 1 deletion src/gui/wdgOverlayUi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#if defined (FULLSCREEN_RESFREQ)
#include "video/gfx_monitor.h"
#include "input/standard_controller.h"

#endif

void overlay_info_append_qstring(BYTE alignment, const QString &msg);
Expand Down

0 comments on commit e378474

Please sign in to comment.