all repos — mgba @ c0f427597ebf649bdc7cea2e03869135fe6902cf

mGBA Game Boy Advance Emulator

DS: Fix exposed CPU frequencies and audio timing
Vicki Pfau vi@endrift.com
Sat, 15 Apr 2017 20:59:37 -0700
commit

c0f427597ebf649bdc7cea2e03869135fe6902cf

parent

b796a689cbbb6e320654d03d2e8a300072d256ec

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

jump to
M CHANGESCHANGES

@@ -21,6 +21,7 @@ - DS GX: Don't reset state between buffer swaps (fixes mgba.io/i/642)

- DS GX: Allow viewport to change in the middle of a frame - DS GX: Properly mask address for slot 2 4x4-texel textures - DS Slot-1: Emulate initial SPI command delay + - DS: Fix exposed CPU frequencies and audio timing Misc: - DS: Set boot complete bit in RAM on boot (fixes mgba.io/i/576, mgba.io/i/580, mgba.io/i/586) - DS Memory: Ensure DS9 I/O is 8-byte aligned
M src/ds/audio.csrc/ds/audio.c

@@ -12,7 +12,7 @@

mLOG_DEFINE_CATEGORY(DS_AUDIO, "DS Audio", "ds.audio"); static const unsigned BLIP_BUFFER_SIZE = 0x4000; -static const int CLOCKS_PER_FRAME = 0x4000; +static const int CLOCKS_PER_FRAME = 0x8000; const int DS_AUDIO_VOLUME_MAX = 0x100; static void _updateChannel(struct mTiming* timing, void* user, uint32_t cyclesLate);

@@ -332,10 +332,11 @@ blip_add_delta(audio->left, audio->clock, sampleLeft - audio->lastLeft);

blip_add_delta(audio->right, audio->clock, sampleRight - audio->lastRight); audio->lastLeft = sampleLeft; audio->lastRight = sampleRight; - audio->clock += audio->sampleInterval; + // blip clock is in ARM9 cycles, but sampleInterval is in ARM7 cycles + audio->clock += audio->sampleInterval * 2; if (audio->clock >= CLOCKS_PER_FRAME) { - blip_end_frame(audio->left, audio->clock); - blip_end_frame(audio->right, audio->clock); + blip_end_frame(audio->left, CLOCKS_PER_FRAME); + blip_end_frame(audio->right, CLOCKS_PER_FRAME); audio->clock -= CLOCKS_PER_FRAME; } }
M src/ds/core.csrc/ds/core.c

@@ -409,7 +409,7 @@ }

static int32_t _DSCoreFrameCycles(const struct mCore* core) { UNUSED(core); - return DS_VIDEO_TOTAL_LENGTH; + return DS_VIDEO_TOTAL_LENGTH * 2; } static int32_t _DSCoreFrequency(const struct mCore* core) {
M src/ds/ds.csrc/ds/ds.c

@@ -20,8 +20,8 @@ #define SLICE_CYCLES 2048

mLOG_DEFINE_CATEGORY(DS, "DS", "ds"); -const uint32_t DS_ARM946ES_FREQUENCY = 0x1FF61FE; -const uint32_t DS_ARM7TDMI_FREQUENCY = 0xFFB0FF; +const uint32_t DS_ARM946ES_FREQUENCY = 0x3FEC3FC; +const uint32_t DS_ARM7TDMI_FREQUENCY = 0x1FF61FE; const uint32_t DS_COMPONENT_MAGIC = 0x1FF61FE; const uint8_t DS_CHIP_ID[4] = { 0xC2, 0x0F, 0x00, 0x00 };