SNES: Moved to retro-core (2)

This commit is contained in:
Alex Duchesne 2024-03-26 19:55:16 -04:00
parent 1783bb7d52
commit ca3d607420
10 changed files with 29 additions and 44 deletions

View File

@ -667,7 +667,7 @@ static void application(const char *desc, const char *name, const char *exts, co
void applications_init(void)
{
application("Nintendo Entertainment System", "nes", "nes fc fds nsf", "retro-core", 16);
application("Super Nintendo", "snes", "smc sfc", "snes9x-go", 0);
application("Super Nintendo", "snes", "smc sfc", "retro-core", 0);
application("Nintendo Gameboy", "gb", "gb gbc", "retro-core", 0);
application("Nintendo Gameboy Color", "gbc", "gbc gb", "retro-core", 0);
application("Nintendo Game & Watch", "gw", "gw", "retro-core", 0);

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
set(COMPONENTS "main retro-go nofrendo gnuboy pce-go gw-emulator handy smsplus app_trace bootloader esptool_py")
set(COMPONENTS "main retro-go nofrendo gnuboy pce-go gw-emulator handy smsplus snes9x app_trace bootloader esptool_py")
include(../base.cmake)
project(retro-core)

View File

@ -19,6 +19,10 @@ void S9xResetDSP1(void)
DSP1.in_index = 0;
DSP1.out_index = 0;
DSP1.first_parameter = true;
if (!DSP1.output)
DSP1.output = malloc(512);
if (!DSP1.parameters)
DSP1.parameters = malloc(512);
}
uint8_t S9xGetDSP(uint16_t address)

View File

@ -24,8 +24,8 @@ typedef struct
uint32_t in_index;
uint32_t out_count;
uint32_t out_index;
uint8_t parameters [512];
uint8_t output [512];
uint8_t *parameters; // [512];
uint8_t *output; // [512];
} SDSP1;
void S9xResetDSP1(void);

View File

@ -1,6 +1,6 @@
#include "shared.h"
#include "smsplus.h"
#include <smsplus.h>
static rg_surface_t *updates[2];
static rg_surface_t *currentUpdate;

View File

@ -5,32 +5,27 @@
#include <time.h>
#include <math.h>
#include "snes9x.h"
#include "soundux.h"
#include "memmap.h"
#include "apu.h"
#include "display.h"
#include "gfx.h"
#include "cpuexec.h"
#include "srtc.h"
#include "save.h"
#include "../components/snes9x/snes9x.h"
#include "../components/snes9x/soundux.h"
#include "../components/snes9x/memmap.h"
#include "../components/snes9x/apu.h"
#include "../components/snes9x/display.h"
#include "../components/snes9x/gfx.h"
#include "../components/snes9x/cpuexec.h"
#include "../components/snes9x/srtc.h"
#include "../components/snes9x/save.h"
#include "keymap.h"
#include "keymap_snes.h"
#include "shared.h"
#define AUDIO_SAMPLE_RATE (32040)
#define AUDIO_BUFFER_LENGTH (AUDIO_SAMPLE_RATE / 60 + 2)
#define AUDIO_LOW_PASS_RANGE ((60 * 65536) / 100)
static rg_surface_t *updates[2];
static rg_surface_t *currentUpdate;
static rg_app_t *app;
static bool apu_enabled = true;
static bool lowpass_filter = false;
bool overclock_cycles = false;
int one_c = 4, slow_one_c = 5, two_c = 6;
static int keymap_id = 0;
static keymap_t keymap;
@ -236,13 +231,12 @@ static void S9xAudioCallback(void)
{
S9xFinalizeSamples();
size_t available_samples = S9xGetSampleCount();
rg_audio_sample_t mixbuffer[available_samples];
S9xMixSamples(&mixbuffer, available_samples);
rg_audio_submit(mixbuffer, available_samples >> 1);
S9xMixSamples((void *)audioBuffer, available_samples);
rg_audio_submit(audioBuffer, available_samples >> 1);
}
#endif
void app_main(void)
void snes_main(void)
{
const rg_handlers_t handlers = {
.loadState = &load_state_handler,
@ -257,7 +251,7 @@ void app_main(void)
{0, "Controls ", "-", RG_DIALOG_FLAG_NORMAL, &menu_keymap_cb},
RG_DIALOG_END,
};
app = rg_system_init(AUDIO_SAMPLE_RATE, &handlers, options);
app = rg_system_reinit(AUDIO_SAMPLE_RATE, &handlers, options);
apu_enabled = rg_settings_get_number(NS_APP, SETTING_APU_EMULATION, 1);
@ -301,7 +295,6 @@ void app_main(void)
#ifdef USE_BLARGG_APU
S9xSetSamplesAvailableCallback(S9xAudioCallback);
#else
rg_audio_sample_t mixbuffer[AUDIO_BUFFER_LENGTH];
S9xSetPlaybackRate(Settings.SoundPlaybackRate);
#endif
@ -359,16 +352,16 @@ void app_main(void)
#ifndef USE_BLARGG_APU
if (apu_enabled && lowpass_filter)
S9xMixSamplesLowPass((void *)mixbuffer, AUDIO_BUFFER_LENGTH << 1, AUDIO_LOW_PASS_RANGE);
S9xMixSamplesLowPass((void *)audioBuffer, AUDIO_BUFFER_LENGTH << 1, AUDIO_LOW_PASS_RANGE);
else if (apu_enabled)
S9xMixSamples((void *)mixbuffer, AUDIO_BUFFER_LENGTH << 1);
S9xMixSamples((void *)audioBuffer, AUDIO_BUFFER_LENGTH << 1);
#endif
rg_system_tick(rg_system_timer() - startTime);
#ifndef USE_BLARGG_APU
if (apu_enabled)
rg_audio_submit(mixbuffer, AUDIO_BUFFER_LENGTH);
rg_audio_submit(audioBuffer, AUDIO_BUFFER_LENGTH);
#endif
if (skipFrames == 0)

View File

@ -18,9 +18,6 @@
{
"path": "retro-core"
},
{
"path": "snes9x-go"
},
{
"path": ".",
"name": "root"

View File

@ -11,9 +11,8 @@ PROJECT_ICON = "assets/icon.raw"
PROJECT_APPS = {
# Project name Type, SubType, Size
'launcher': [0, 0, 917504],
'retro-core': [0, 0, 720896],
'snes9x-go': [0, 0, 524288],
'retro-core': [0, 0, 917504],
'prboom-go': [0, 0, 786432],
'gwenesis': [0, 0, 983040],
'fmsx': [0, 0, 655360],
'fmsx': [0, 0, 589824],
}

View File

@ -1,4 +0,0 @@
cmake_minimum_required(VERSION 3.5)
set(COMPONENTS "main retro-go snes9x cxx app_trace bootloader esptool_py")
include(../base.cmake)
project(snes9x-go)

View File

@ -1,4 +0,0 @@
set(COMPONENT_SRCDIRS ".")
set(COMPONENT_ADD_INCLUDEDIRS ".")
register_component()
rg_setup_compile_options(-O2)