diff --git a/sys/src/games/gba/apu.c b/sys/src/games/gba/apu.c index 0e0c01548..3b99a4614 100644 --- a/sys/src/games/gba/apu.c +++ b/sys/src/games/gba/apu.c @@ -209,7 +209,7 @@ sampletick(void *) s16int s[2]; int i; - addevent(&evsamp, sratediv + evsamp.time); + addevent(&evsamp, sratediv); if(--envctr == 0){ envctr = envrel; diff --git a/sys/src/games/gba/ev.c b/sys/src/games/gba/ev.c index e4612114c..fb75129ad 100644 --- a/sys/src/games/gba/ev.c +++ b/sys/src/games/gba/ev.c @@ -185,9 +185,11 @@ timertick(void *aux) Timer *t; u32int v; int to; + ulong clock0; t = aux; - t->clock = clock + t->time & -(1 << t->sh); + clock0 = clock + t->time; + t->clock = clock0 & -(1 << t->sh); t->val = -t->time >> t->sh; do{ to = 0; @@ -196,7 +198,7 @@ timertick(void *aux) to++; }while(v >= 0x10000); if(t == aux) - addevent(t, (0x10000 - t->val << t->sh) + (-clock & (1 << t->sh) - 1)); + addevent(t, (0x10000 - t->val << t->sh) + (-clock0 & (1 << t->sh) - 1)); if((*t->cnt & TIMERIRQ) != 0) setif(IRQTIM0 << t->i); if(t->snd) diff --git a/sys/src/games/gba/ppu.c b/sys/src/games/gba/ppu.c index 43d334d6c..85d1d0652 100644 --- a/sys/src/games/gba/ppu.c +++ b/sys/src/games/gba/ppu.c @@ -733,7 +733,7 @@ hblanktick(void *) stat = reg[DISPSTAT]; if(hblank){ hblclock = clock + evhblank.time; - addevent(&evhblank, 240*4 + evhblank.time); + addevent(&evhblank, 240*4); hblank = 0; ppux0 = 0; memset(pixpri, VACANT, sizeof(pixpri)); @@ -755,7 +755,7 @@ hblanktick(void *) }else{ syncppu(240); linecopy(); - addevent(&evhblank, 68*4 + evhblank.time); + addevent(&evhblank, 68*4); hblank = 1; if((stat & IRQHBLEN) != 0) setif(IRQHBL);