diff --git a/ChangeLog b/ChangeLog index 11269e5da..a3c2af136 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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). diff --git a/README.md b/README.md index c1d76fa00..00722a26a 100644 --- a/README.md +++ b/README.md @@ -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 | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a7487494c..97fc67808 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/core/mappers.c b/src/core/mappers.c index 5605890dd..3672355c0 100644 --- a/src/core/mappers.c +++ b/src/core/mappers.c @@ -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; diff --git a/src/core/mappers.h b/src/core/mappers.h index c778acfec..8af1b7e7a 100644 --- a/src/core/mappers.h +++ b/src/core/mappers.h @@ -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" diff --git a/src/core/mappers/OneBus.c b/src/core/mappers/OneBus.c index 82e14d732..f31047cca 100644 --- a/src/core/mappers/OneBus.c +++ b/src/core/mappers/OneBus.c @@ -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: diff --git a/src/core/mappers/mapper_034.c b/src/core/mappers/mapper_034.c index 8e26e67bb..fefa7762b 100644 --- a/src/core/mappers/mapper_034.c +++ b/src/core/mappers/mapper_034.c @@ -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); diff --git a/src/core/mappers/mapper_042.c b/src/core/mappers/mapper_042.c index 07b9e57c6..2e02a810a 100644 --- a/src/core/mappers/mapper_042.c +++ b/src/core/mappers/mapper_042.c @@ -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); diff --git a/src/core/mappers/mapper_085.c b/src/core/mappers/mapper_085.c index fc24cddd5..fc5f5b5a8 100644 --- a/src/core/mappers/mapper_085.c +++ b/src/core/mappers/mapper_085.c @@ -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; diff --git a/src/core/mappers/mapper_236.c b/src/core/mappers/mapper_236.c index 6872da0da..dbe1c5287 100644 --- a/src/core/mappers/mapper_236.c +++ b/src/core/mappers/mapper_236.c @@ -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); diff --git a/src/core/mappers/mapper_354.c b/src/core/mappers/mapper_354.c new file mode 100644 index 000000000..e4f3e933b --- /dev/null +++ b/src/core/mappers/mapper_354.c @@ -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 +#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); + } +} diff --git a/src/core/mappers/mapper_354.h b/src/core/mappers/mapper_354.h new file mode 100644 index 000000000..dc12a19d5 --- /dev/null +++ b/src/core/mappers/mapper_354.h @@ -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_ */ diff --git a/src/core/mappers/mapper_390.c b/src/core/mappers/mapper_390.c index 9c9d3420b..9cef898af 100644 --- a/src/core/mappers/mapper_390.c +++ b/src/core/mappers/mapper_390.c @@ -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); diff --git a/src/core/mappers/mapper_517.c b/src/core/mappers/mapper_517.c index 0fd2b75fd..493437369 100644 --- a/src/core/mappers/mapper_517.c +++ b/src/core/mappers/mapper_517.c @@ -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; diff --git a/src/gui/wdgOverlayUi.cpp b/src/gui/wdgOverlayUi.cpp index 8195fe092..4116df553 100644 --- a/src/gui/wdgOverlayUi.cpp +++ b/src/gui/wdgOverlayUi.cpp @@ -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);