Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New mapper code #612

Merged
merged 14 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/workflows/compilation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Upload artifacts
if: ${{ success() }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: fceumm_libretro_ps2-${{ steps.slug.outputs.sha8 }}
path: fceumm_libretro_ps2.a
10 changes: 7 additions & 3 deletions Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ INCFLAGS := \
-I$(LIBRETRO_COMM_DIR)/include \
-I$(CORE_DIR) \
-I$(CORE_DIR)/input \
-I$(CORE_DIR)/boards
-I$(CORE_DIR)/mappers \
-I$(CORE_DIR)/mappers/hw \
-I$(CORE_DIR)/mappers/sound

ifneq (,$(findstring msvc2003,$(platform)))
INCFLAGS += -I$(LIBRETRO_COMM_DIR)/include/compat/msvc
Expand All @@ -18,7 +20,10 @@ COREDEFINES = \
-DFRONTEND_SUPPORTS_RGB565

FCEU_SRC_DIRS := \
$(CORE_DIR)/boards \
$(CORE_DIR)/mappers \
$(CORE_DIR)/mappers/m468 \
$(CORE_DIR)/mappers/hw \
$(CORE_DIR)/mappers/sound \
$(CORE_DIR)/input

SOURCES_C := $(foreach dir,$(FCEU_SRC_DIRS),$(wildcard $(dir)/*.c))
Expand Down Expand Up @@ -46,7 +51,6 @@ SOURCES_C += \
$(CORE_DIR)/general.c \
$(CORE_DIR)/input.c \
$(CORE_DIR)/md5.c \
$(CORE_DIR)/nsf.c \
$(CORE_DIR)/palette.c \
$(CORE_DIR)/ppu.c \
$(CORE_DIR)/sound.c \
Expand Down
45 changes: 45 additions & 0 deletions fceumm_libretro.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Software Information
display_name = "Nintendo - NES / Famicom (FCEUmm)"
authors = "FCEU Team|CaH4e3"
supported_extensions = "fds|nes|unif|unf|nsf|nsfe"
corename = "FCEUmm"
license = "GPLv2"
permissions = ""
display_version = "SVN"
categories = "Emulator"

# Hardware Information
manufacturer = "Nintendo"
systemname = "Nintendo Entertainment System"
systemid = "nes"

# Libretro Features
supports_no_game = "false"
savestate = "true"
savestate_features = "deterministic"
cheats = "true"
input_descriptors = "true"
memory_descriptors = "true"
libretro_saves = "true"
core_options = "true"
core_options_version = "1.0"
load_subsystem = "false"
hw_render = "false"
needs_fullpath = "false"
disk_control = "false"
database = "Nintendo - Nintendo Entertainment System|Nintendo - Family Computer Disk System"

# BIOS / Firmware
firmware_count = 3
firmware0_desc = "disksys.rom (Family Computer Disk System BIOS)"
firmware0_path = "disksys.rom"
firmware0_opt = "true"
firmware1_desc = "nes.pal (custom NES Palette)"
firmware1_path = "nes.pal"
firmware1_opt = "true"
firmware2_desc = "gamegenie.nes (Game Genie add-on cartridge)"
firmware2_path = "gamegenie.nes"
firmware2_opt = "true"
notes = "(!) disksys.rom (md5): ca30b50f880eb660a320674ed365ef7a|(!) gamegenie.nes (md5): 7f98d77d7a094ad7d069b74bd553ec98|(!) nes.pal must be located in system directory."

description = "FCEUmm libretro is based on the FCEUmm (mappers modified) fork of the FCEU emulator. It is very fast and supports many mappers, including those for weird, obscure bootleg carts. It is tightly integrated with libretro features, which makes it a good choice for users seeking advanced frontend functionality, such as runahead and rollback netplay. While most NES emulators are lightweight, FCEUmm's particularly low resource requirements make it a good option for mobile, low-power/embedded and console targets."
5 changes: 5 additions & 0 deletions src/cart.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ typedef struct {
* code, used by mapper/board code, maybe
* other code in the future.
*/

int HasTrainer; /* indicated the presence of trainer rom data */
int HasMisc; /* indicated the presence of misc rom data */
} CartInfo;

extern CartInfo iNESCart;

extern uint8 *Page[32], *VPage[8], *MMC5SPRVPage[8], *MMC5BGVPage[8];

void ResetCartMapping(void);
Expand Down
124 changes: 95 additions & 29 deletions src/drivers/libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,11 +1464,17 @@ static bool update_option_visibility(void)
"fceumm_sndlowpass",
"fceumm_sndstereodelay",
"fceumm_swapduty",
"fceumm_apu_1",
"fceumm_apu_2",
"fceumm_apu_3",
"fceumm_apu_4",
"fceumm_apu_5"
"fceumm_apu_square_1",
"fceumm_apu_square_2",
"fceumm_apu_triangle",
"fceumm_apu_noise",
"fceumm_apu_dpcm",
"fceumm_apu_fds",
"fceumm_apu_s5b",
"fceumm_apu_n163",
"fceumm_apu_vrc6",
"fceumm_apu_vrc7",
"fceumm_apu_mmc5"
};

option_display.visible = opt_showAdvSoundOptions;
Expand Down Expand Up @@ -1671,7 +1677,7 @@ void retro_set_environment(retro_environment_t cb)
void retro_get_system_info(struct retro_system_info *info)
{
info->need_fullpath = true;
info->valid_extensions = "fds|nes|unf|unif";
info->valid_extensions = "fds|nes|unf|unif|nsf|nsfe";
#ifdef GIT_VERSION
info->library_version = "(SVN)" GIT_VERSION;
#else
Expand Down Expand Up @@ -1851,20 +1857,93 @@ void retro_reset(void)
ResetNES();
}

static void set_apu_channels(int chan)
{
FSettings.SquareVolume[1] = (chan & 1) ? 256 : 0;
FSettings.SquareVolume[0] = (chan & 2) ? 256 : 0;
FSettings.TriangleVolume = (chan & 3) ? 256 : 0;
FSettings.NoiseVolume = (chan & 4) ? 256 : 0;
FSettings.PCMVolume = (chan & 5) ? 256 : 0;
#define VOLUME_MAX 256

static void check_variables_volume_levels(void) {
struct retro_variable var = { 0 };
int i = 0;
int ssize;

var.key = "fceumm_apu_square_1";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
FSettings.SquareVolume[1] = VOLUME_MAX * atoi(var.value) / 100;
}

var.key = "fceumm_apu_square_2";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
FSettings.SquareVolume[0] = VOLUME_MAX * atoi(var.value) / 100;
}

var.key = "fceumm_apu_triangle";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
FSettings.TriangleVolume = VOLUME_MAX * atoi(var.value) / 100;
}

var.key = "fceumm_apu_noise";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
FSettings.NoiseVolume = VOLUME_MAX * atoi(var.value) / 100;
}

var.key = "fceumm_apu_dpcm";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
FSettings.PCMVolume = VOLUME_MAX * atoi(var.value) / 100;
}

/* EXPANSION AUDIO VOLUME SETTINGS */

var.key = "fceumm_apu_fds";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_FDS, val);
}

var.key = "fceumm_apu_s5b";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_S5B, val);
}

var.key = "fceumm_apu_n163";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_N163, val);
}

var.key = "fceumm_apu_vrc6";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_VRC6, val);
}

var.key = "fceumm_apu_vrc7";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_VRC7, val);
}

var.key = "fceumm_apu_mmc5";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = VOLUME_MAX * atoi(var.value) / 100;
FCEUI_SetExpSoundVolume(SND_MMC5, val);
}
}

static void check_variables(bool startup)
{
struct retro_variable var = {0};
char key[256];
int i, enable_apu;
int i;
bool stereo_filter_updated = false;

/* 1 = Performs only geometry update: e.g. overscans */
Expand Down Expand Up @@ -2298,8 +2377,7 @@ static void check_variables(bool startup)

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
int val = (int)(atof(var.value) * 25.6);
sndvolume = val;
sndvolume = (unsigned)((float)VOLUME_MAX * atof(var.value) / 200.0f);
FCEUD_SoundToggle();
}

Expand All @@ -2322,19 +2400,7 @@ static void check_variables(bool startup)
swapDuty = newval;
}

var.key = key;

enable_apu = 0xff;

strcpy(key, "fceumm_apu_x");
for (i = 0; i < 5; i++)
{
key[strlen("fceumm_apu_")] = '1' + i;
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && !strcmp(var.value, "disabled"))
enable_apu &= ~(1 << i);
}
set_apu_channels(enable_apu);
check_variables_volume_levels();

update_dipswitch();

Expand Down
Loading
Loading