Skip to content

Commit ae18f8b

Browse files
fhoedemakersCopilot
andauthored
NSF playback and FDS settings with various fixes (#198)
* .nsf player Co-authored-by: Copilot <copilot@github.com> * Metroid ERR 24 solved ( #192 ) Auto Insert feature via FDS_AuotInsertEnabled. Will be a setting later, now hardcoded false * FDS save games work: #193 Co-authored-by: Copilot <copilot@github.com> * Fix for Zelda lockup when transfering from one gameplay screen to another. Co-authored-by: Copilot <copilot@github.com> * Add Auto Swap FDS setting to NES visibility settings * Update subproject commit reference in pico_shared * Refactor FDS_AutoInsertEnabled to read from settings.flags.autoSwapFDS and include settings.h Co-authored-by: Copilot <copilot@github.com> * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update README.md * Update .gitignore to include additional file types * Implement FDS expansion Audio Co-authored-by: Copilot <copilot@github.com> * Update CHANGELOG * Refine FDS audio output gain calculation for improved bass response Co-authored-by: Copilot <copilot@github.com> * Update CHANGELOG * Update CHANGELOG * Update README * Update CHANGELOG * Update CHANGELOG * Update CHANGELOG * Add *.nsf to .gitignore * Enhance NSF playback performance by optimizing PPU processing and bank management * Update README.md * update CHANGELOG * Update README * Update README * Update FDS auto swap setting to depend on PSRAM availability * update README * Exclude DPCM from the silence detection * Add load-address offset handling for NSF data * Enhance NSF playback initialization by directly setting APU control registers to prevent silent playback in certain tracks * Implement NSF performance diagnostics and optimize bank switching for VRC6 audio rendering * Prevent audio bleed in NSF mode by skipping rendering when playback is stopped * Update README * FIX bootsel mode dissapeared from settings menu. * Update subproject reference in pico_shared * Update CHANGELOG.md * Update README.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update CHANGELOG.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README * Update README * Update README * Update README * Update subproject commit reference in pico_shared --------- Co-authored-by: Copilot <copilot@github.com>
1 parent ca530c6 commit ae18f8b

19 files changed

Lines changed: 2328 additions & 222 deletions

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
*Zone.Identifier
22
fh.log
3+
*.nes
4+
*.fds
5+
*.wav
6+
*.nsf
37
CMakePresets.json
48
/pimoroni-pico/
59
# Prerequisites
@@ -74,8 +78,7 @@ bld/
7478
[Oo]bj/
7579
[Ll]og/
7680
[Ll]ogs/
77-
*.nes
78-
*.fds
81+
7982
# Visual Studio 2015/2017 cache/options directory
8083
.vs/
8184
# Uncomment if you have tasks that create the project's static files in wwwroot

CHANGELOG.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# CHANGELOG
22

3-
Famicom Disk System support with limitations, additional mapper improvements, and native PAL/Dendy frame rates on RP2350 boards.
3+
This release brings improvements to Famicom Disk System support, including the ability to save games back to disk and bug fixes for disk errors in Metroid and Zelda. It also introduces an NSF audio player. The settings interface has been refined for improved usability, and several other issues have been fixed.
4+
45

56
# General Info
67

@@ -10,6 +11,44 @@ Famicom Disk System support with limitations, additional mapper improvements, an
1011

1112
[See setup section in readme how to install and wire up](https://github.com/fhoedemakers/pico-infonesPlus#pico-setup)
1213

14+
# v0.41
15+
16+
## Features
17+
18+
**Famicom Disk System**
19+
20+
Note that FDS support requires an RP2350 board with PSRAM and a BIOS file at `/bios/fds-bios.rom`.
21+
22+
- Implement save games for games that support write save data back to disk, like Metroid and Zelda. Saves are stored as `/SAVES/gametitle_fds.sav` [#193](https://github.com/fhoedemakers/pico-infonesPlus/issues/193)
23+
- Added an option to the settings menu to automatically swap disk sides. This setting is disabled by default. When it’s off, you can manually swap disks in-game using SELECT + START.
24+
25+
Audio is not perfect but acceptable.
26+
27+
**NSF sound playback**
28+
29+
- Added NSF playback. Emulator can load and play `.nsf` (Nintendo Sound Format) roms.
30+
- Controls:
31+
- LEFT/RIGHT change track
32+
- Button2 Stop
33+
- Button1 Resume
34+
35+
**Settings menu**
36+
37+
- Better use of screen real estate:
38+
- SAVE / DEFAULT / CANCEL are on the same row.
39+
- FG/BG color codes now placed to the left to the color grid.
40+
41+
## Fixes
42+
43+
**Famicom Disk System**
44+
45+
- Fix disk error 24 in Metroid and possible in other games too. [#192](https://github.com/fhoedemakers/pico-infonesPlus/issues/192)
46+
- Fix for game lock-up in Zelda when moving to the next screen during gameplay.
47+
48+
## Use of AI
49+
50+
FDS, NSF, additional mappers developed with the help of [Anthropic Claude Opus 4.6](https://www.anthropic.com/claude/opus)
51+
1352
# v0.40 (This is a re-release of v0.39 with some fixes and improvements)
1453

1554
- Fix incorrect parsing of region in NES 2.0 header. [#197](https://github.com/fhoedemakers/pico-infonesPlus/issues/197) Thanks to [@Lome-one](https://github.com/Lome-one) for reporting.

README.md

Lines changed: 93 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
- **SD Card Menu System** – Browse and launch games from an on-screen menu interface
1111
- **Dual Controller Support** – Two simultaneous controllers for multiplayer gameplay ([details](#about-two-player-games))
1212
- **Save State Management** – Automatic battery-backed SRAM persistence and manual save states
13-
- **Audio Playback** – WAV format audio playback in the menu (RP2350 only)
14-
- **Famicom Disk System** – Support for FDS game images with user-supplied BIOS
13+
- **Famicom Disk System** – Support for FDS game images with user-supplied BIOS. More info on this in the [FDS Games](#famicom-disk-system-fds-games-1) section below.
1514
- **Multi-Region Support** – NTSC, PAL, and Dendy region compatibility
16-
- **Flexible Hardware** – Compatible with standard DVI/HDMI breakout boards, with optional [custom PCB](#pcb-with-raspberry-pi-pico-or-pico-2) and [3D-printed case](https://github.com/fhoedemakers/pico-infonesPlus#3d-printed-case)
15+
- **NSF Audio Playback** – Play NES music files (`.nsf`) with visual VU-meter overlay. More info on this in the [Playing NSF Audio Files](#playing-nsf-audio-files) section below.
16+
- **WAV Audio Playback** – WAV (`.wav`) format audio playback in the menu (RP2350 only). More info on this in the [WAV Music Playback in Menu](#wav-music-playback-in-menu-rp2350-only) section below.
17+
- **Flexible Hardware**[Compatible with standard DVI/HDMI breakout boards](#possible-configurations), with optional [custom PCB](#pcb-with-raspberry-pi-pico-or-pico-2) and [3D-printed case](https://github.com/fhoedemakers/pico-infonesPlus#3d-printed-case)
18+
19+
1720

1821
### Regional Support
1922

@@ -118,7 +121,7 @@ See downloads in the releases page for the correct binary to use with these boar
118121
***
119122

120123
## Gamecontroller support
121-
Depending on the hardware configuration, the emulator supports these gamecontrollers. An USB-Y cable is needed to both connect power and a gamecontroller to the usb-port.
124+
Depending on the hardware configuration, the emulator supports these gamecontrollers. In some configurations, an USB-Y cable is needed to both connect power and a gamecontroller to the usb-port.
122125

123126
### USB game Controllers
124127
- Sony Dual Shock 4
@@ -145,7 +148,7 @@ For more info, see [pio_usb.md](pio_usb.md).
145148

146149
### Legacy controllers
147150
- One or optional two original NES controllers for two player games. In some configurations, soldering is required.
148-
- WII-classic controller: Adafruit Feather RP2040 and WaveShare RP2040 Pi-Zero boards only
151+
- WII-classic controller: Adafruit Feather RP2040, WaveShare RP2040 Pi-Zero, Adafruit Metro RP2350, Adafruit Fruit Jam boards only
149152

150153
Parts list for legacy controllers
151154
* NES Controller. A second controller port and controller is optional and only needed if you want to play two player games using NES controllers. Two player games can also be played with a USB controller and a NES controller.
@@ -182,17 +185,23 @@ Without PSRAM, selecting a game ROM triggers a reboot: the ROM is written to fla
182185

183186
With PSRAM, this step is no longer needed. Games are loaded directly from the SD card into PSRAM and executed immediately, resulting in much faster startup times.
184187

188+
189+
185190
| Board | PSRAM Included |
186191
|:--|:--|
187-
| [Waveshare RP2350-PiZero](https://www.waveshare.com/rp2350-pizero.htm) | No – optional, must be soldered ([PSRAM module](https://www.adafruit.com/product/4677)) |
192+
| [Waveshare RP2350-PiZero](https://www.waveshare.com/rp2350-pizero.htm) | No – optional, must be soldered ([PSRAM module](https://www.adafruit.com/product/4677)) See also issue [#191](https://github.com/fhoedemakers/pico-infonesPlus/issues/191) |
188193
| [Adafruit Metro RP2350 with PSRAM](https://www.adafruit.com/product/6267) | Yes – pre-installed |
189194
| [Pimoroni Pico Plus 2](https://shop.pimoroni.com/products/pimoroni-pico-plus-2) | Yes – pre-installed |
195+
| [Adafruit Fruit Jam](https://www.adafruit.com/product/6200) | Yes - pre-installed |
196+
197+
> [!NOTE]
198+
> The Waveshare RP2350-PiZero requires a Winbond flash chip for PSRAM to function correctly with the emulator. However, some boards ship with a flash chip from a different manufacturer, causing the emulator to crash. See issue [#191](https://github.com/fhoedemakers/pico-infonesPlus/issues/191). In this scenario the board can only run the emulator if no PSRAM is installed.
199+
190200

191201

192202
***
193203

194204
## Warning
195-
Repeatedly flashing your Pico will eventually wear out the flash memory.
196205

197206
The emulator overclocks the Pico in order to get the emulator working fast enough. Overclocking can reduce the Pico's lifespan.
198207

@@ -232,7 +241,7 @@ Click on the link below for your specific board configuration:
232241
> This board is discontinued and no longer sold by Pimoroni
233242
234243
### materials needed
235-
- Raspberry Pi Pico or Pico 2 with soldered male headers.
244+
- Raspberry Pi Pico, Pico 2 or [Pimoroni Pico Plus 2](https://shop.pimoroni.com/products/pimoroni-pico-plus-2?variant=42092668289107) with soldered male headers.
236245
- [Pimoroni Pico DV Demo Base](https://shop.pimoroni.com/products/pimoroni-pico-dv-demo-base?variant=39494203998291).
237246
- [Micro usb to usb OTG Cable](https://a.co/d/dKW6WGe)
238247
- Controllers (Depending on what you have)
@@ -682,7 +691,7 @@ Please keep the following in mind:
682691
- One of these Waveshare boards:
683692
- [Waveshare RP2040-PiZero Development Board](https://www.waveshare.com/rp2040-pizero.htm).
684693
- [Waveshare RP2350-PiZero Development Board](https://www.waveshare.com/rp2350-pizero.htm).
685-
- Optional: [PSRAM chip](https://www.adafruit.com/product/4677) When installed, the emulator loads ROMs from PSRAM instead of flash memory for significantly faster performance. Fully functional even without PSRAM
694+
- Optional: [PSRAM chip](https://www.adafruit.com/product/4677) When installed, the emulator loads ROMs from PSRAM instead of flash memory for significantly faster performance. Fully functional even without PSRAM. There is an issue with boards usings flash chips from another brand than Winbond, where the PSRAM is not working. See [#191](https://github.com/fhoedemakers/pico-infonesPlus/issues/191)
686695
- [USB-C to USB-A cable](https://a.co/d/2i7rJid) for flashing the uf2 onto the board.
687696
- USB-C Power supply. Connect to the port labelled USB, not PIO-USB. See note below.
688697
- [Mini HDMI to HDMI Cable](https://a.co/d/5BZg3Z6).
@@ -815,7 +824,7 @@ When ordering, simply upload the zip file containing the gerber design. This fi
815824
> If you are looking for the previous design (v0.2). You can find it [here](PCB/v0.2)
816825
817826
> [!NOTE]
818-
> It seems that sellers on AliExpress have copied the PCB design and are selling pre-populated PCB's. For questions about those boards, please contact the seller on AliExpress.
827+
> Sellers on AliExpress have copied the PCB design and are selling pre-populated PCB's. For questions about those boards, please contact the seller on AliExpress.
819828
820829
Other materials needed:
821830

@@ -935,25 +944,7 @@ Download the metadata pack from the [releases page](https://github.com/fhoedemak
935944

936945
<img width="1920" height="1080" alt="Screenshot 2025-08-25 15-43-24" src="https://github.com/user-attachments/assets/7aa98825-e3b1-4c7a-ba13-80e04929a27d" />
937946

938-
# Famicom Disk System (FDS) Games
939-
940-
FDS games are supported with the following limitations:
941-
942-
- A BIOS file is required. Place it at `/bios/fds-bios.rom` on the SD card.
943-
- An RP2350 board with PSRAM is required.
944-
- Games that save data to disk may not work correctly or at all. (Zelda, Metroid)
945-
- Expansion audio is not supported.
946-
947-
See [#192](https://github.com/fhoedemakers/pico-infonesPlus/issues/192), [#193](https://github.com/fhoedemakers/pico-infonesPlus/issues/193), [#194](https://github.com/fhoedemakers/pico-infonesPlus/issues/194), [#195](https://github.com/fhoedemakers/pico-infonesPlus/issues/195) for issues regarding to FDS.
948-
949-
### Swapping Disks
950-
951-
When prompted to swap disks, use the in-game settings menu:
952-
953-
1. Press **SELECT + START** to open the settings menu.
954-
2. Select the first option to change the disk.
955-
3. Press **LEFT/RIGHT** to choose the disk side.
956-
4. Press **Button2** to confirm and return.
947+
***
957948

958949
# Gamepad and keyboard usage
959950

@@ -1016,7 +1007,52 @@ Save States should work for mapper 0,1,2,3 and 4. Other mappers may or may not
10161007

10171008
***
10181009

1019-
# Music Playback in menu (RP2350 Only)
1010+
# Famicom Disk System (FDS) Games
1011+
1012+
FDS games are supported with the following requirements:
1013+
1014+
- A BIOS file is required. Place it at `/bios/fds-bios.rom` on the SD card.
1015+
- An RP2350 board with PSRAM is required.
1016+
- You need roms with the `.fds` extension.
1017+
1018+
FDS games have these features:
1019+
1020+
- For games that support write save data back to disk, you must go back to the menu to save the game. Saves are written to `/saves/gamename_fds.sav`. Save states are not supported for FDS games.
1021+
- Audio is not perfect but acceptable.
1022+
1023+
### Swapping Disks
1024+
1025+
When prompted to swap disks, use the in-game settings menu:
1026+
1027+
1. Press **SELECT + START** to open the settings menu.
1028+
2. Select the first option to change the disk.
1029+
3. Press **LEFT/RIGHT** to choose the disk side.
1030+
4. Press **Button2** to confirm and return.
1031+
1032+
### Auto Swapping disks
1033+
1034+
In the settings menu, there is an option **Auto Swap FDS Disks**. This is disabled by default. When enabled, the emulator will automatically swap disks when needed. Note that in some cases you still need to manually swap the disks.
1035+
1036+
***
1037+
1038+
# Playing NSF audio files
1039+
1040+
The emulator can play Nintendo Sound Format files. These are roms with the `.nsf` extension. This works on both the RP2040 and RP2350 boards.
1041+
1042+
Each NSF file can have multiple tracks. Loading a `.nsf` rom from the menu will automatically start the first track. Each track is played for the maximum duration of 3 minutes. Then the next track is played. When there is silence for more than 4 seconds, the next track is played.
1043+
1044+
**Controls**
1045+
1046+
- Right/Left: Next/Previous track.
1047+
- Button1: Stop Playback
1048+
- Button2: Resume playback.
1049+
- Select + Start: Back to the menu.
1050+
1051+
<img width="1920" height="1080" alt="Screenshot 2026-05-04 10-12-59" src="https://github.com/user-attachments/assets/6e6a954e-e58f-48c3-9989-ea5482f3e992" />
1052+
1053+
***
1054+
1055+
# WAV Music Playback in menu (RP2350 Only)
10201056

10211057
The menu allows you to play music files. Files must meet the following requirements:
10221058

@@ -1132,16 +1168,17 @@ Alternatively, you can use the [bld.sh](bld.sh) shell script:
11321168
```
11331169
Build script for the piconesPlus project
11341170
1135-
Usage: ./pico_shared/bld.sh [-d] [-2 | -r] [-w] [-u] [-m] [-t path to toolchain] [ -p nprocessors] [-c <hwconfig>]
1171+
Usage: ./pico_shared/bld.sh [-d] [-2 | -r] [-w] [-u] [-m] [-D] [-t path to toolchain] [ -p nprocessors] [-c <hwconfig>]
11361172
Options:
11371173
-d: build in DEBUG configuration
11381174
-2: build for Pico 2 board (RP2350)
11391175
-r: build for Pico 2 board (RP2350) with riscv core
1140-
-u: enable PIO USB support (default is disabled, RP2350 only)
1176+
-u: enable PIO USB support (RP2350 only) disabled by default except for Waveshare RP2350-PiZero and Adafruit Fruit Jam.
11411177
-w: build for Pico_w or Pico2_w
11421178
-t <path to riscv toolchain>: only needed for riscv, specify the path to the riscv toolchain bin folder
11431179
Default is $PICO_SDK_PATH/toolchain/RISCV_RPI_2_0_0_2/bin
11441180
-p <nprocessors>: specify the number of processors to use for the build
1181+
-D Force DVI over HSTX.
11451182
-c <hwconfig>: specify the hardware configuration
11461183
1: Pimoroni Pico DV Demo Base (Default)
11471184
2: Breadboard with Adafruit AdaFruit DVI Breakout Board and AdaFruit MicroSD card breakout board
@@ -1150,6 +1187,14 @@ Options:
11501187
4: Waveshare RP2040-PiZero
11511188
5: Adafruit Metro RP2350 (latest branch of TinyUSB is required for this board)
11521189
6: Waveshare RP2040-Zero/RP2350-Zero with custom PCB
1190+
7: WaveShare RP2350-PiZero - PIO USB enabled, -u implied.
1191+
8: Adafruit Fruit Jam - PIO USB enabled, -u implied.
1192+
9: WaveShare RP2350-USBA - PIO USB enabled, -u implied.
1193+
10: Spotpear HDMI board. https://spotpear.com/index/product/detail/id/1207.html
1194+
11: RP2350-USB-A - OLD config with different SD pins. Deprecated, do not use.
1195+
12: Murmulator M1
1196+
13: Murmulator M2 (rp2350 only)
1197+
14: Adafruit Feather RP2350 with TLV320DAC3100 I2S DAC and sdcard breakout board and PIO USB.
11531198
-m: Run cmake only, do not build the project
11541199
-h: display this help
11551200
@@ -1233,9 +1278,23 @@ PSRAM: https://github.com/AndrewCapon/PicoPlusPsram
12331278

12341279
lwmem: https://github.com/MaJerle/lwmem
12351280

1236-
Mesen NES rom database: https://github.com/SourMesen/Mesen2
1281+
Mesen: https://github.com/SourMesen/Mesen2 used as basis for:
1282+
1283+
- NES rom database
1284+
- FDS implementation
1285+
- NSF playback.
1286+
1287+
[Anthropic Claude Opus 4.6](https://www.anthropic.com/claude/opus) assisted with:
1288+
1289+
- Famicom Disk System (FDS) support
1290+
- mapper 5 (MMC5)
1291+
- mapper 24 (VRC6a)
1292+
- mapper 30
1293+
- mapper 85
1294+
- fixes in other mappers
1295+
- NSF player support
1296+
- general code optimizations and bug fixes
12371297

1238-
[Anthropic Claude Opus 4.6](https://www.anthropic.com/claude/opus): Assisted with NES mapper 5 (MMC5), mapper 24 (VRC6a), mapper 30, fixes in other mappers, and with general code optimizations and bug fixes.
12391298

12401299
***
12411300

infones/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ INTERFACE
77
InfoNES.cpp
88
InfoNES_Region.cpp
99
InfoNES_FDS.cpp
10+
InfoNES_NSF.cpp
1011
K6502.cpp
1112
)
1213

infones/InfoNES.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "InfoNES_System.h"
4040
#include "InfoNES_Mapper.h"
4141
#include "InfoNES_pAPU.h"
42+
#include "InfoNES_NSF.h"
4243
#include "K6502.h"
4344
#include <assert.h>
4445
#include <pico.h>
@@ -470,6 +471,15 @@ int InfoNES_Reset()
470471
ROM_Trainer = 0;
471472
ROM_FourScr = 0;
472473
}
474+
else if (IsNSF)
475+
{
476+
// Nintendo Sound Format: dispatch through synthetic mapper 31.
477+
MapperNo = 31;
478+
ROM_Mirroring = 0;
479+
ROM_SRAM = 0;
480+
ROM_Trainer = 0;
481+
ROM_FourScr = 0;
482+
}
473483
else
474484
{
475485
// Mapper Number is 8bits. Always use lower 4bits of byInfo2 for compatibility with old ROMs.
@@ -556,6 +566,12 @@ int InfoNES_Reset()
556566

557567
K6502_Reset();
558568

569+
// NSF: override CPU state after reset (A=track, X=region, SP=$FD, PC=$4100)
570+
if (IsNSF)
571+
{
572+
nsfSetupCpuState();
573+
}
574+
559575
// Successful
560576
return 0;
561577
}
@@ -844,7 +860,12 @@ int __not_in_flash_func(InfoNES_HSync)()
844860
if (PPU_Scanline >= 4 && PPU_Scanline < 240 - 4)
845861
{
846862
InfoNES_PreDrawLine(PPU_Scanline);
847-
InfoNES_DrawLine();
863+
/* NSF mode has no PPU work — InfoNES_PostDrawLine paints the
864+
NSF VU-meter overlay over the line buffer, so skipping the
865+
PPU pixel pipeline buys back a large slice of CPU time
866+
(Akumajou1.nsf and other heavy NSFs). */
867+
if (!IsNSF)
868+
InfoNES_DrawLine();
848869
InfoNES_PostDrawLine(PPU_Scanline);
849870
}
850871
// todo: 描画しないラインにもスプライトオーバーレジスタとかは反映する必要がある

infones/InfoNES.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ extern BYTE ROM_FourScr;
309309
Set by parseROM in main before InfoNES_Reset. RP2350 + PSRAM only. */
310310
extern bool IsFDS;
311311

312+
/* True when the loaded image is an NSF (Nintendo Sound Format) file. */
313+
extern bool IsNSF;
314+
312315
/*-------------------------------------------------------------------*/
313316
/* Function prototypes */
314317
/*-------------------------------------------------------------------*/

0 commit comments

Comments
 (0)