Skip to content

Commit

Permalink
[NSF2] Added support for the following chunks : RATE, plst, time, fad…
Browse files Browse the repository at this point in the history
…e, tlbl, taut, auth, text and regn.
  • Loading branch information
punesemu committed Feb 3, 2024
1 parent 57f5698 commit a4a9ab6
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 162 deletions.
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
2 changes: 1 addition & 1 deletion src/core/emu.c
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ void emu_info_rom(void) {
return;
} else if (info.header.format == NSFE_FORMAT) {
log_close_box(uL("NSFE"));
nsfe_info();
nsf_info();
return;
} else if (info.header.format == FDS_FORMAT) {
log_close_box(uL("FDS"));
Expand Down
69 changes: 53 additions & 16 deletions src/core/mappers/mapper_NSF.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "video/gfx.h"
#include "fps.h"

INLINE static void select_region(void);

void map_init_NSF(void) {
EXTCL_AFTER_MAPPER_INIT(NSF);
EXTCL_SAVE_MAPPER(NSF);
Expand All @@ -41,7 +43,7 @@ void map_init_NSF(void) {
}

if (info.reset >= HARD) {
if (cfg->nsf_player_nsfe_playlist && (nsf.playlist.count > 0)) {
if (cfg->nsf_player_playlist && (nsf.playlist.count > 0)) {
nsf.songs.current = nsf.playlist.starting;
nsf.playlist.index = 0;

Expand All @@ -61,23 +63,23 @@ void map_init_NSF(void) {

nsf.state = NSF_PLAY | NSF_CHANGE_SONG;

{
double rate = 0, nmi_rate = 0;

if (machine.type == NTSC) {
rate = nsf.play_speed.ntsc;
nmi_rate = 0x40FF;
} else if (machine.type == DENDY) {
rate = nsf.play_speed.dendy;
nmi_rate = 0x4E1D;
} else {
rate = nsf.play_speed.pal;
nmi_rate = 0x4E1D;
}
nsf.rate.reload = (DBWORD)(machine.cpu_hz / (1000000.0f / rate));
nsf.nmi.reload = (DBWORD)(machine.cpu_hz / (1000000.0f / nmi_rate));
switch (cfg->mode) {
default:
case AUTO:
nsf.type = nsf.region.preferred;
break;
case NTSC:
nsf.type = nsf.region.supported & 0x01 ? nsf.type = NSF_NTSC_MODE : nsf.region.preferred;
break;
case PAL:
nsf.type = nsf.region.supported & 0x02 ? nsf.type = NSF_PAL_MODE : nsf.region.preferred;
break;
case DENDY:
nsf.type = nsf.region.supported & 0x04 ? nsf.type = NSF_DENDY_MODE : nsf.region.preferred;
break;
}

select_region();
nsf.rate.count = nsf.rate.reload;
nsf.nmi.count = nsf.rate.reload;
nsf.nmi.in_use = FALSE;
Expand Down Expand Up @@ -155,6 +157,7 @@ BYTE extcl_save_mapper_NSF(BYTE mode, BYTE slot, FILE *fp) {
}

if (mode == SAVE_SLOT_READ) {
select_region();
nsf_reset_song_title();
nsf_reset_timers();
nsf.curtain_title_song.redraw.all = TRUE;
Expand Down Expand Up @@ -274,3 +277,37 @@ void extcl_apu_tick_NSF(void) {
extcl_apu_tick_FME7();
}
}


INLINE static void select_region(void) {
double rate = 0, nmi_rate = 0;

switch (nsf.type & 0x03) {
case NSF_NTSC_MODE:
info.machine[DATABASE] = NTSC;
break;
case NSF_PAL_MODE:
info.machine[DATABASE] = PAL;
break;
case NSF_DENDY_MODE:
info.machine[DATABASE] = DENDY;
break;
default:
nsf.type = NSF_NTSC_MODE;
info.machine[DATABASE] = NTSC;
break;
}

if (machine.type == NTSC) {
rate = nsf.play_speed.ntsc;
nmi_rate = 0x40FF;
} else if (machine.type == DENDY) {
rate = nsf.play_speed.dendy;
nmi_rate = 0x4E1D;
} else {
rate = nsf.play_speed.pal;
nmi_rate = 0x4E1D;
}
nsf.rate.reload = (DBWORD)(machine.cpu_hz / (1000000.0f / rate));
nsf.nmi.reload = (DBWORD)(machine.cpu_hz / (1000000.0f / nmi_rate));
}
Loading

0 comments on commit a4a9ab6

Please sign in to comment.