all repos — mgba @ 4a3c9423321a9d05a506b124c0af1772cb4a395e

mGBA Game Boy Advance Emulator

3DS: Remove CSND, add some size optimizations
Vicki Pfau vi@endrift.com
Sun, 28 Jan 2018 15:31:32 -0800
commit

4a3c9423321a9d05a506b124c0af1772cb4a395e

parent

72e5aa078281a797854e4bd4620489e956fce866

4 files changed, 7 insertions(+), 85 deletions(-)

jump to
M CHANGESCHANGES

@@ -63,6 +63,7 @@ - Libretro: Add frameskip option

- GBA Memory: 64 MiB GBA Video cartridge support - 3DS: Scale font based on glyph heights (fixes mgba.io/i/961) - PSP2: Use system enter key by default + - 3DS: Remove deprecated CSND interface 0.6.1: (2017-10-01) Bugfixes:
M src/platform/3ds/CMakeToolchain.txtsrc/platform/3ds/CMakeToolchain.txt

@@ -23,9 +23,9 @@ endif()

set(CMAKE_PROGRAM_PATH ${DEVKITARM}/bin) set(cross_prefix arm-none-eabi-) -set(arch_flags "-march=armv6k -mtune=mpcore -mfpu=vfp -mfloat-abi=hard") +set(arch_flags "-march=armv6k -mtune=mpcore -mfloat-abi=hard -ffunction-sections") set(inc_flags "-I${CTRULIB}/include ${arch_flags} -mword-relocations") -set(link_flags "-L${CTRULIB}/lib -lctru -specs=3dsx.specs ${arch_flags}") +set(link_flags "-L${CTRULIB}/lib -lctru -specs=3dsx.specs ${arch_flags} -Wl,--gc-sections") set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name") set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "processor")
M src/platform/3ds/cia.rsf.insrc/platform/3ds/cia.rsf.in

@@ -174,7 +174,6 @@ - y2r:u

- ldr:ro - ir:USER - ir:u - - csnd:SND SystemControlInfo:

@@ -195,7 +194,6 @@ camera: 0x0004013000001602L

cecd: 0x0004013000002602L cfg: 0x0004013000001702L codec: 0x0004013000001802L - csnd: 0x0004013000002702L dlp: 0x0004013000002802L dsp: 0x0004013000001a02L friends: 0x0004013000003202L
M src/platform/3ds/main.csrc/platform/3ds/main.c

@@ -80,8 +80,7 @@ } camera;

static enum { NO_SOUND, - DSP_SUPPORTED, - CSND_SUPPORTED + DSP_SUPPORTED } hasSound; // TODO: Move into context

@@ -156,37 +155,19 @@ if (hasSound != NO_SOUND) {

linearFree(audioLeft); } - if (hasSound == CSND_SUPPORTED) { - linearFree(audioRight); - csndExit(); - } - if (hasSound == DSP_SUPPORTED) { ndspExit(); } camExit(); - csndExit(); + ndspExit(); ptmuExit(); } static void _aptHook(APT_HookType hook, void* user) { UNUSED(user); switch (hook) { - case APTHOOK_ONSUSPEND: - case APTHOOK_ONSLEEP: - if (hasSound == CSND_SUPPORTED) { - CSND_SetPlayState(8, 0); - CSND_SetPlayState(9, 0); - csndExecCmds(false); - } - break; case APTHOOK_ONEXIT: - if (hasSound == CSND_SUPPORTED) { - CSND_SetPlayState(8, 0); - CSND_SetPlayState(9, 0); - csndExecCmds(false); - } _cleanup(); exit(0); break;

@@ -199,33 +180,6 @@ static void _map3DSKey(struct mInputMap* map, int ctrKey, enum GBAKey key) {

mInputBindKey(map, _3DS_INPUT, __builtin_ctz(ctrKey), key); } -static void _csndPlaySound(u32 flags, u32 sampleRate, float vol, void* left, void* right, u32 size) { - u32 pleft = 0, pright = 0; - - int loopMode = (flags >> 10) & 3; - if (!loopMode) { - flags |= SOUND_ONE_SHOT; - } - - pleft = osConvertVirtToPhys(left); - pright = osConvertVirtToPhys(right); - - u32 timer = CSND_TIMER(sampleRate); - if (timer < 0x0042) { - timer = 0x0042; - } - else if (timer > 0xFFFF) { - timer = 0xFFFF; - } - flags &= ~0xFFFF001F; - flags |= SOUND_ENABLE | (timer << 16); - - u32 volumes = CSND_VOL(vol, -1.0); - CSND_SetChnRegs(flags | SOUND_CHANNEL(8), pleft, pleft, size, volumes, volumes); - volumes = CSND_VOL(vol, 1.0); - CSND_SetChnRegs(flags | SOUND_CHANNEL(9), pright, pright, size, volumes, volumes); -} - static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right); static void _drawStart(void) {

@@ -383,12 +337,7 @@ blip_set_rates(runner->core->getAudioChannel(runner->core, 1), runner->core->frequency(runner->core), 32768 * ratio);

if (hasSound != NO_SOUND) { audioPos = 0; } - if (hasSound == CSND_SUPPORTED) { - memset(audioLeft, 0, AUDIO_SAMPLE_BUFFER * sizeof(int16_t)); - memset(audioRight, 0, AUDIO_SAMPLE_BUFFER * sizeof(int16_t)); - _csndPlaySound(SOUND_REPEAT | SOUND_FORMAT_16BIT, 32768, 1.0, audioLeft, audioRight, AUDIO_SAMPLE_BUFFER * sizeof(int16_t)); - csndExecCmds(false); - } else if (hasSound == DSP_SUPPORTED) { + if (hasSound == DSP_SUPPORTED) { memset(audioLeft, 0, AUDIO_SAMPLE_BUFFER * 2 * sizeof(int16_t)); } unsigned mode;

@@ -430,11 +379,6 @@ }

} static void _gameUnloaded(struct mGUIRunner* runner) { - if (hasSound == CSND_SUPPORTED) { - CSND_SetPlayState(8, 0); - CSND_SetPlayState(9, 0); - csndExecCmds(false); - } osSetSpeedupEnable(false); frameLimiter = true;

@@ -796,22 +740,7 @@ }

static void _postAudioBuffer(struct mAVStream* stream, blip_t* left, blip_t* right) { UNUSED(stream); - if (hasSound == CSND_SUPPORTED) { - blip_read_samples(left, &audioLeft[audioPos], AUDIO_SAMPLES, false); - blip_read_samples(right, &audioRight[audioPos], AUDIO_SAMPLES, false); - GSPGPU_FlushDataCache(&audioLeft[audioPos], AUDIO_SAMPLES * sizeof(int16_t)); - GSPGPU_FlushDataCache(&audioRight[audioPos], AUDIO_SAMPLES * sizeof(int16_t)); - audioPos = (audioPos + AUDIO_SAMPLES) % AUDIO_SAMPLE_BUFFER; - if (audioPos == AUDIO_SAMPLES * 3) { - u8 playing = 0; - csndIsPlaying(0x8, &playing); - if (!playing) { - CSND_SetPlayState(0x8, 1); - CSND_SetPlayState(0x9, 1); - csndExecCmds(false); - } - } - } else if (hasSound == DSP_SUPPORTED) { + if (hasSound == DSP_SUPPORTED) { int startId = bufferId; while (dspBuffer[bufferId].status == NDSP_WBUF_QUEUED || dspBuffer[bufferId].status == NDSP_WBUF_PLAYING) { bufferId = (bufferId + 1) & (DSP_BUFFERS - 1);

@@ -876,12 +805,6 @@ for (i = 0; i < DSP_BUFFERS; ++i) {

dspBuffer[i].data_pcm16 = &audioLeft[AUDIO_SAMPLES * i * 2]; dspBuffer[i].nsamples = AUDIO_SAMPLES; } - } - - if (hasSound == NO_SOUND && !csndInit()) { - hasSound = CSND_SUPPORTED; - audioLeft = linearMemAlign(AUDIO_SAMPLE_BUFFER * sizeof(int16_t), 0x80); - audioRight = linearMemAlign(AUDIO_SAMPLE_BUFFER * sizeof(int16_t), 0x80); } gfxInit(GSP_BGR8_OES, GSP_BGR8_OES, true);