Skip to content

Commit

Permalink
use svc timer for frame timer
Browse files Browse the repository at this point in the history
  • Loading branch information
skyfloogle committed Nov 26, 2023
1 parent 297f9d5 commit 555591a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions source/3ds/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ int main() {

osSetSpeedupEnable(true);

u64 lastTime = svcGetSystemTick();
Handle frameTimer;
svcCreateTimer(&frameTimer, RESET_STICKY);
svcSetTimer(frameTimer, 0, 20000000);

while(aptMainLoop()) {
uint64_t startTime = osGetTime();
Expand Down Expand Up @@ -123,11 +125,8 @@ int main() {
frame++;

if (!tVBOpt.FASTFORWARD) {
u64 newTime = svcGetSystemTick();
if (newTime - lastTime < 20 * CPU_TICKS_PER_MSEC) {
svcWaitSynchronization(nothingEvent, 2000 * (20 * CPU_TICKS_PER_MSEC - (newTime - lastTime)) / CPU_TICKS_PER_USEC);
}
lastTime = newTime;
svcWaitSynchronization(frameTimer, 20000000);
svcClearTimer(frameTimer);
}

#if DEBUGLEVEL == 0
Expand Down

0 comments on commit 555591a

Please sign in to comment.