DS: Fix exposed CPU frequencies and audio timing

This commit is contained in:
Vicki Pfau 2017-04-15 20:59:37 -07:00
parent b796a689cb
commit c0f427597e
4 changed files with 9 additions and 7 deletions

View File

@ -21,6 +21,7 @@ Bugfixes:
- 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

View File

@ -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 @@ static void _sample(struct mTiming* timing, void* user, uint32_t cyclesLate) {
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;
}
}

View File

@ -409,7 +409,7 @@ static int32_t _DSCoreFrameCounter(const struct mCore* core) {
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) {

View File

@ -20,8 +20,8 @@
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 };