Skip to content

Commit 5b4e9f6

Browse files
committed
minor adjustments
1 parent 0bfdf09 commit 5b4e9f6

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

source/switch/main.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99

1010
#include <arm_neon.h>
1111

12+
#include "../GBACheats.h"
1213
#include "../gba.h"
1314
#include "../globals.h"
1415
#include "../memory.h"
1516
#include "../port.h"
1617
#include "../sound.h"
1718
#include "../system.h"
1819
#include "../types.h"
19-
#include "../GBACheats.h"
2020
#include "gbaover.h"
2121

22+
2223
#include "util.h"
2324
#include "zoom.h"
2425

@@ -34,7 +35,11 @@ u32 currentFBHeight;
3435
#define MIN(a, b) ((a) < (b) ? (a) : (b))
3536
#define MAX(a, b) ((a) > (b) ? (a) : (b))
3637
#define SECONDS_PER_TICKS (1.0 / 19200000)
37-
#define TARGET_FRAMETIME (1.0 / 60.0)
38+
#define TARGET_FPS (16777216.0 / 280896.0)
39+
#define TARGET_FRAMETIME (1.0 / TARGET_FPS)
40+
#define TARGET_FRAMETIME_us (u64)(TARGET_FRAMETIME * 1000000000)
41+
#define TARGET_FRAMETIME_TICKS (u64)(TARGET_FRAMETIME * 19200000)
42+
#define TICKS_PER_us (1000000000ul / 19200000ul)
3843

3944
uint8_t libretro_save_buf[0x20000 + 0x2000]; /* Workaround for broken-by-design GBA save semantics. */
4045

@@ -225,7 +230,7 @@ static void gba_init(void) {
225230

226231
doMirroring(mirroringEnable);
227232

228-
soundSetSampleRate(AUDIO_SAMPLERATE + 10); // slight oversampling makes the sound better
233+
soundSetSampleRate(AUDIO_SAMPLERATE + 10); // slight oversampling makes the sound better
229234

230235
#if HAVE_HLE_BIOS
231236
bool usebios = false;
@@ -384,6 +389,8 @@ void systemOnWriteDataToSoundBuffer(int16_t *finalWave, int length) {
384389
audioTransferBufferUsed += length / 2;
385390
mutexUnlock(&audioLock);
386391

392+
audio_samples_written += length / 2;
393+
387394
g_audio_frames += length / 2;
388395
}
389396

@@ -412,7 +419,7 @@ void threadFunc(void *args) {
412419

413420
double endTime = (double)svcGetSystemTick() * SECONDS_PER_TICKS;
414421

415-
if (!(inputTransferKeysHeld & buttonMap[10])) condvarWaitTimeout(&requestFrameCond, TARGET_FRAMETIME * 1000000000);
422+
if (!(inputTransferKeysHeld & buttonMap[10])) condvarWaitTimeout(&requestFrameCond, TARGET_FRAMETIME_us);
416423
}
417424

418425
mutexLock(&emulationLock);
@@ -462,9 +469,7 @@ int main(int argc, char *argv[]) {
462469

463470
romfsInit();
464471

465-
gfxInitResolutionDefault();
466472
gfxInitDefault();
467-
gfxConfigureAutoResolutionDefault(true);
468473

469474
setsysInitialize();
470475

@@ -758,7 +763,7 @@ int main(int argc, char *argv[]) {
758763
frameTimeFrames = 0;
759764
}
760765
#endif
761-
766+
762767
gfxFlushBuffers();
763768
gfxSwapBuffers();
764769
gfxWaitForVsync();

0 commit comments

Comments
 (0)