3DS: Remove CSND, add some size optimizations

This commit is contained in:
Vicki Pfau 2018-01-28 15:31:32 -08:00
parent 72e5aa0782
commit 4a3c942332
4 changed files with 7 additions and 85 deletions

View File

@ -63,6 +63,7 @@ Misc:
- 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:

View File

@ -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")

View File

@ -174,7 +174,6 @@ AccessControlInfo:
- ldr:ro
- ir:USER
- ir:u
- csnd:SND
SystemControlInfo:
@ -195,7 +194,6 @@ SystemControlInfo:
cecd: 0x0004013000002602L
cfg: 0x0004013000001702L
codec: 0x0004013000001802L
csnd: 0x0004013000002702L
dlp: 0x0004013000002802L
dsp: 0x0004013000001a02L
friends: 0x0004013000003202L

View File

@ -80,8 +80,7 @@ static struct m3DSImageSource {
static enum {
NO_SOUND,
DSP_SUPPORTED,
CSND_SUPPORTED
DSP_SUPPORTED
} hasSound;
// TODO: Move into context
@ -156,37 +155,19 @@ static void _cleanup(void) {
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 @@ static void _gameLoaded(struct mGUIRunner* runner) {
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 _gameLoaded(struct mGUIRunner* runner) {
}
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 _requestImage(struct mImageSource* source, const void** buffer, size
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);
@ -878,12 +807,6 @@ int main() {
}
}
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);
if (!_initGpu()) {