Skip to content

Commit

Permalink
Merge branch 'punesemu:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoyo authored Feb 6, 2024
2 parents 7554dc6 + d58c234 commit 125eed7
Show file tree
Hide file tree
Showing 91 changed files with 4,704 additions and 2,645 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Changelog:
* Changed the format of the diff file, now I use the IPS format (which can always be applied to the original image).
- Rewritten the format and management of save states.
WARNING save states of version 0.110 or earlier are no longer compatible.
- Rewritten the audio of the VRC7.
Implemented the project "A YM2413 emulator written in C" of okaxaki :
* https://github.com/digital-sound-antiques/emu2413
- Added support to Quick Disk format.
- Added an option for RAM initialization (#276).
It's possible to choose between three values:
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<img src="https://user-images.githubusercontent.com/14859058/132302943-a466d3d5-75c2-4bac-b0b2-7f0aeb8c058d.png" alt="puNES"/><br>
</p>
<h3 align="center">Qt-based Nintendo Entertainment System emulator and NSF/NSFe Music Player</h3>
<h3 align="center">Qt-based Nintendo Entertainment System emulator and NSF/NSF2/NSFe Music Player</h3>

<p align="center">
<a href="https://github.com/punesemu/puNES/releases/latest">
Expand Down Expand Up @@ -50,16 +50,16 @@ If you want buy me a beer : <span class="badge-paypal"><a href="https://www.payp
:camera: Screenshots
-----------
<p align="center">
<img src="https://user-images.githubusercontent.com/14859058/208288696-b3a5494c-6c0f-4cf3-a339-bffe52806e09.png" width="400" alt="puNES main window"/>
<img src="https://user-images.githubusercontent.com/14859058/208289018-e26ecb19-92d8-449f-8c35-77f67f8c8911.png" width="400" alt="puNES NSFE Player"/>
<img src="https://user-images.githubusercontent.com/14859058/208288805-fff96548-ebc1-4cef-b8ce-a813f0ccf27e.png" width="400" alt="puNES Slot Preview"/>
<img src="https://user-images.githubusercontent.com/14859058/135748722-ea73e6b3-db6b-4cf2-b13d-755ca4824975.png" width="400" alt="puNES General Settings"/>
<img src="https://user-images.githubusercontent.com/14859058/140854472-60a88023-e719-4637-9289-08991a367ddd.png" width="400" alt="puNES Video Filters Settings"/>
<img src="https://user-images.githubusercontent.com/14859058/202864520-bdd84d5c-646e-40c0-84be-5ff2d225d015.png" width="400" alt="puNES Cheat Editor"/>
<img src="https://user-images.githubusercontent.com/14859058/208847541-778fb8fb-e070-432f-baf1-fb67cf13f3c5.png" width="400" alt="puNES Xbox360 Standard Controller Settings"/>
<img src="https://user-images.githubusercontent.com/14859058/208848284-0c30ff3f-d6f3-415d-87b1-e408e5454bba.png" width="400" alt="puNES PS4 Standard Controller Settings"/>
<img src="https://user-images.githubusercontent.com/14859058/196442457-e799ee41-17cd-46bf-821e-7532b85c304e.png" width="800" alt="puNES Family BASIC Virtual Keyboard"/>
<img src="https://user-images.githubusercontent.com/14859058/197157708-e2eab47e-001c-4e18-9df8-eb46fb106980.png" width="800" alt="puNES Subor Virtual Keyboard"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/435ad06b-ec4d-4601-84d1-bf444281afe2" width="400" alt="puNES main window"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/8cfa48dd-7d2c-4463-b71d-94edc051cde9" width="400" alt="puNES NSF2 Player"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/da5db672-86e4-4345-a944-687587d04391" width="400" alt="puNES Slot Preview"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/ac74652d-d71d-4378-9dd0-cd894b133ae7" width="400" alt="puNES General Settings"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/1db1eacd-7e67-45c2-9512-ea24553987f5" width="400" alt="puNES Video Filters Settings"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/b309a584-e3ba-487e-9cd7-ca78d1997ac8" width="400" alt="puNES Cheat Editor"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/d115817b-b802-4d75-bdce-3df9efda929c" width="400" alt="puNES Xbox360 Standard Controller Settings"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/ffc4ba31-6899-4385-b0c1-59f7bf5764a2" width="400" alt="puNES PS4 Standard Controller Settings"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/315dbca5-ea3b-4390-b91b-9b7b0028af88" width="800" alt="puNES Family BASIC Virtual Keyboard"/>
<img src="https://github.com/punesemu/puNES/assets/14859058/1347fde5-bcc5-46d2-8e68-1e4875759a6e" width="800" alt="puNES Subor Virtual Keyboard"/>
</p>

:keyboard: Configuration
Expand Down
2 changes: 1 addition & 1 deletion misc/io.github.punesemu.puNES.metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0</project_license>
<description>
<p>Qt-based Nintendo Entertaiment System emulator and NSF/NSFe Music Player</p>
<p>Qt-based Nintendo Entertaiment System emulator and NSF/NSF2/NSFe Music Player</p>
</description>
<screenshots>
<screenshot type="default">
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ set(core_srcs
core/mappers/MMC4.c
core/mappers/N118.c
core/mappers/OneBus.c
extra/Nuked-OPLL/opll.c
extra/emu2413/emu2413.c
core/mappers/serial_devices.cpp
core/mappers/serial_devices_interface.cpp
core/mappers/SST39SF040.c
Expand All @@ -517,7 +517,6 @@ set(core_srcs
core/cheat.c
core/cpu.c
core/detach_barcode.c
core/draw_on_screen.c
core/emu.c
core/emu_thread.c
core/external_calls.c
Expand Down Expand Up @@ -628,6 +627,7 @@ set(gui_srcs
gui/dlgVsSystem.hpp
gui/dlgWizard.cpp
gui/dlgWizard.hpp
gui/draw_on_screen.cpp
gui/mainApplication.cpp
gui/mainApplication.hpp
gui/mainWindow.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/audio/blipbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ static void apu_tick_blipbuf_VRC6(void) {
}
static void apu_tick_blipbuf_VRC7(void) {
if (++blipbuf.vrc7.period == blipbuf.vrc7.min_period) {
blipbuf.output = extra_out(opll_calc()) * (32.0f * cfg->apu.volume[APU_EXTRA]);
blipbuf.output = extra_out(opll_calc()) * (4.0f * cfg->apu.volume[APU_EXTRA]);
update_tick_extra_blbuf(vrc7, 0);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ enum _nes_chips_info {
/* le dimesioni dello screen da renderizzare */
enum screen_dimension { SCR_ROWS = 240, SCR_COLUMNS = 256 };
enum type_of_system_info { HEADER, DATABASE };
enum header_type { iNES_1_0, NES_2_0, UNIF_FORMAT, FDS_FORMAT, QD_FORMAT, NSF_FORMAT, NSFE_FORMAT, HEADER_UNKOWN };
enum header_type { iNES_1_0, NES_2_0, UNIF_FORMAT, FDS_FORMAT, QD_FORMAT, NSF_FORMAT, NSF2_FORMAT, NSFE_FORMAT, HEADER_UNKOWN };
enum length_file_name_type {
LENGTH_FILE_NAME = 512,
LENGTH_FILE_NAME_MID = 1024,
Expand Down
4 changes: 2 additions & 2 deletions src/core/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ typedef struct _config {
BYTE save_battery_ram_file;
BYTE multiple_instances;
BYTE nsf_player_effect;
BYTE nsf_player_nsfe_playlist;
BYTE nsf_player_nsfe_fadeout;
BYTE nsf_player_playlist;
BYTE nsf_player_nsf_fadeout;
#if defined (FULLSCREEN_RESFREQ)
BYTE adaptive_rrate;
int fullscreen_res_w;
Expand Down
202 changes: 137 additions & 65 deletions src/core/cpu_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,42 +472,25 @@ INLINE static void nsf_rd_mem(BYTE nidx, WORD address, BYTE made_tick) {
}
switch (address) {
case 0xFFFA:
if (nsf.routine.INT_NMI) {
nsf.routine.INT_NMI--;
if (nsf.state & NSF_CHANGE_SONG) {
nes[nidx].c.cpu.openbus = 0x00;
snd_reset_buffers();
nsf_reset();
} else {
nes[nidx].c.cpu.openbus = 0x0E;
}
return;
if (nsf.state & NSF_CHANGE_SONG) {
nes[nidx].c.cpu.openbus = NSF_ROUTINE_NSF_INIT & 0xFF;
} else {
nes[nidx].c.cpu.openbus = NSF_ROUTINE_NMI & 0xFF;
}
break;
return;
case 0xFFFB:
if (nsf.routine.INT_NMI) {
nsf.routine.INT_NMI--;
nes[nidx].c.cpu.openbus = 0x25;
snd_reset_buffers();
nsf_reset();
return;
}
break;
nes[nidx].c.cpu.openbus = NSF_ROUTINE_START >> 8;
return;
case 0xFFFC:
if (nsf.routine.INT_RESET) {
nsf.routine.INT_RESET--;
nes[nidx].c.cpu.openbus = 0x08;
snd_reset_buffers();
nsf_reset();
return;
}
break;
nes[nidx].c.cpu.openbus = NSF_ROUTINE_RESET & 0xFF;
return;
case 0xFFFD:
if (nsf.routine.INT_RESET) {
nsf.routine.INT_RESET--;
nes[nidx].c.cpu.openbus = 0x25;
snd_reset_buffers();
nsf_reset();
nes[nidx].c.cpu.openbus = NSF_ROUTINE_RESET >> 8;
return;
case 0xFFFE:
case 0xFFFF:
if (nsf2.features.irq_support) {
nes[nidx].c.cpu.openbus = nsf2.irq.vector[address & 0x01];
return;
}
break;
Expand All @@ -526,11 +509,31 @@ INLINE static void nsf_rd_mem(BYTE nidx, WORD address, BYTE made_tick) {
return;
}
// APU
if (address == 0x4015) {
if ((address >= 0x4000) && (address <= 0x4015)) {
nes[nidx].c.cpu.openbus = apu_rd_reg(nidx, address);
tick_hw(nidx, 1);
return;
}
// IRQ
if (nsf2.features.irq_support) {
if (address == 0x401B) {
nes[nidx].c.cpu.openbus = nsf2.irq.reload & 0xFF;
tick_hw(nidx, 1);
return;
}
if (address == 0x401C) {
nes[nidx].c.cpu.openbus = nsf2.irq.reload >> 8;
tick_hw(nidx, 1);
return;
}
if (address == 0x401D) {
nes[nidx].c.cpu.openbus = !!(nes[nidx].c.irq.high & EXT_IRQ) << 7;
nes[nidx].c.irq.high &= ~EXT_IRQ;
nes[nidx].c.cpu.openbus = (nes[nidx].c.cpu.openbus & 0x80) | !!(nes[nidx].c.irq.high & EXT_IRQ);
tick_hw(nidx, 1);
return;
}
}
// FDS
if (nsf.sound_chips.fds) {
if ((address >= 0x4040) && (address <= 0x407F)) {
Expand Down Expand Up @@ -577,25 +580,79 @@ INLINE static void nsf_rd_mem(BYTE nidx, WORD address, BYTE made_tick) {
return;
}
// NSF Player Routine
if ((address >= NSF_R_START) && (address <= NSF_R_END)) {
if (made_tick) {
tick_hw(nidx, 1);
}
if (made_tick) {
tick_hw(nidx, 1);
}

switch (address) {
case 0x2500:
nsf_init_tune();
break;
case NSF_R_PLAY_INST:
nsf.routine.prg[NSF_R_JMP_PLAY] = NSF_R_LOOP;
break;
default:
break;
if ((address >= NSF_ROUTINE_START) && (address <= NSF_ROUTINE_END)) {
if (nes[nidx].c.cpu.opcode_PC == address) {
switch (address) {
case NSF_ROUTINE_NMI:
nsf.nmi.in_use = TRUE;
break;
case NSF_ROUTINE_NMI_RTI:
nsf.nmi.in_use = FALSE;
break;
case NSF_ROUTINE_RESET:
break;
case NSF_ROUTINE_CLEAR_ALL:
snd_reset_buffers();
nsf_reset();
break;
case NSF_ROUTINE_YES_PLAY:
nsf.adr.loop = NSF_ROUTINE_LOOP;
nsf.rate.count = nsf.rate.reload;
if (!cfg->apu.channel[APU_MASTER]) {
extcl_audio_samples_mod_nsf(NULL, 0);
}
break;
case NSF_ROUTINE_NSF_INIT:
nsf_init_tune();
break;
default:
break;
}
}

nes[nidx].c.cpu.openbus = nsf.routine.prg[address & NSF_R_MASK];
nes[nidx].c.cpu.openbus = nsf.routine[address & 0xFF];
return;
}
if ((address >= NSF_DATA_START) && (address <= NSF_DATA_END)) {
switch (address) {
case NSF_DATA_INIT_LO:
nes[nidx].c.cpu.openbus = nsf.adr.init;
return;
case NSF_DATA_INIT_HI:
nes[nidx].c.cpu.openbus = nsf.adr.init >> 8;
return;
case NSF_DATA_PLAY_LO:
nes[nidx].c.cpu.openbus = nsf.adr.play;
return;
case NSF_DATA_PLAY_HI:
nes[nidx].c.cpu.openbus = nsf.adr.play >> 8;
return;
case NSF_DATA_IRQ_SUPPORT:
nes[nidx].c.cpu.openbus = nsf2.features.irq_support;
return;
case NSF_DATA_NON_RETURNING_INIT:
nes[nidx].c.cpu.openbus = nsf2.features.non_returning_init;
return;
case NSF_DATA_SUPPRESS_PLAY:
nes[nidx].c.cpu.openbus = nsf2.features.suppressed_PLAY;
return;
case NSF_DATA_CURRENT_SONG:
nes[nidx].c.cpu.openbus = nsf.songs.current;
return;
case NSF_DATA_TYPE:
nes[nidx].c.cpu.openbus = nsf.type;
return;
case NSF_DATA_LOOP_LO:
nes[nidx].c.cpu.openbus = nsf.adr.loop;
return;
case NSF_DATA_LOOP_HI:
nes[nidx].c.cpu.openbus = nsf.adr.loop >> 8;
return;
}
}
}
INLINE static BYTE fds_rd_mem(BYTE nidx, WORD address, BYTE made_tick) {
if (address >= 0x8000) {
Expand Down Expand Up @@ -906,9 +963,7 @@ void cpu_wr_mem(BYTE nidx, WORD address, BYTE value) {
if (address < 0x8000) {
/* eseguo un tick hardware */
tick_hw(nidx, 1);

wram_wr(nidx, address, value);

if (info.mapper.extend_wr) {
extcl_cpu_wr_mem(nidx, address, value);
}
Expand Down Expand Up @@ -1635,6 +1690,12 @@ INLINE static void nsf_wr_mem(BYTE nidx, WORD address, BYTE value) {
// Ram
if (address >= 0x8000) {
tick_hw(nidx, 1);
if (nsf2.features.irq_support) {
if (address >= 0xFFFE) {
nsf2.irq.vector[address & 0x01] = value;
return;
}
}

if (nsf.sound_chips.vrc6) {
switch (address) {
Expand Down Expand Up @@ -1695,6 +1756,11 @@ INLINE static void nsf_wr_mem(BYTE nidx, WORD address, BYTE value) {
return;
}
// APU
if ((address >= 0x4000) && (address <= 0x4013)) {
apu_wr_reg(nidx, address, value);
tick_hw(nidx, 1);
return;
}
if (address == 0x4015) {
apu_wr_reg(nidx, address, value);
tick_hw(nidx, 1);
Expand All @@ -1705,6 +1771,24 @@ INLINE static void nsf_wr_mem(BYTE nidx, WORD address, BYTE value) {
apu_wr_reg(nidx, address, value);
return;
}
// IRQ
if (nsf2.features.irq_support) {
if (address == 0x401B) {
nsf2.irq.reload = (nsf2.irq.reload & 0xFF00) | value;
tick_hw(nidx, 1);
return;
}
if (address == 0x401C) {
nsf2.irq.reload = (nsf2.irq.reload & 0x00FF) | (value << 8);
tick_hw(nidx, 1);
return;
}
if (address == 0x401D) {
nsf2.irq.enable = value & 0x01;
tick_hw(nidx, 1);
return;
}
}
// FDS
if (nsf.sound_chips.fds && (address >= 0x4040) && (address <= 0x408A)) {
fds_wr_mem(nidx, address, value);
Expand Down Expand Up @@ -2078,24 +2162,12 @@ INLINE static void tick_hw(BYTE nidx, BYTE value) {
}

tick_hw_start:
if (nsf.enabled) {
if (nsf.made_tick) {
nes[nidx].c.cpu.opcode_cycle++;
nes[nidx].c.nmi.before = nes[nidx].c.nmi.high;
nes[nidx].c.irq.before = nes[nidx].c.irq.high;
nsf_tick();

apu_tick(&value);
nes[nidx].c.cpu.odd_cycle = !nes[nidx].c.cpu.odd_cycle;
value--;
mod_cycles_op(-=, 1);
}
return;
}
nes[nidx].c.cpu.opcode_cycle++;
nes[nidx].c.nmi.before = nes[nidx].c.nmi.high;
nes[nidx].c.irq.before = nes[nidx].c.irq.high;
ppu_tick(nidx);
if (!nsf.enabled) {
ppu_tick(nidx);
}

if (nidx == 0) {
if (!nes[nidx].p.overclock.in_extra_sclines) {
Expand Down
Loading

0 comments on commit 125eed7

Please sign in to comment.