summaryrefslogtreecommitdiff
path: root/sys/src/games
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2015-04-02 22:09:34 +0200
committeraiju <devnull@localhost>2015-04-02 22:09:34 +0200
commit8e588754bccfbc8446e9d5092cd99fdc071d8188 (patch)
tree9e19c90baf9c84967fb0b097733fca71a6d1942d /sys/src/games
parent52ab0d153472f74effbcbd7fbfb6faa84dd80e61 (diff)
games/gba: fix -3 crash and prevent >100% speed
Diffstat (limited to 'sys/src/games')
-rw-r--r--sys/src/games/gba/dat.h2
-rw-r--r--sys/src/games/gba/gba.c17
-rw-r--r--sys/src/games/gba/ppu.c3
3 files changed, 20 insertions, 2 deletions
diff --git a/sys/src/games/gba/dat.h b/sys/src/games/gba/dat.h
index 4f4651c0a..a609b850b 100644
--- a/sys/src/games/gba/dat.h
+++ b/sys/src/games/gba/dat.h
@@ -141,6 +141,8 @@ enum {
KB = 1024,
BACKTYPELEN = 64,
HZ = 16777216,
+ MILLION = 1000000,
+ BILLION = 1000000000,
};
typedef struct Var Var;
diff --git a/sys/src/games/gba/gba.c b/sys/src/games/gba/gba.c
index bfb65c738..cebd1a830 100644
--- a/sys/src/games/gba/gba.c
+++ b/sys/src/games/gba/gba.c
@@ -317,6 +317,8 @@ flush(void)
extern uchar pic[];
Mouse m;
int x;
+ static vlong old, delta;
+ vlong new, diff;
if(nbrecvul(mc->resizec) > 0){
if(getwindow(display, Refnone) < 0)
@@ -347,7 +349,20 @@ flush(void)
flushimage(display, 1);
if(profile)
timing();
- audioout();
+ if(audioout() < 0){
+ new = nsec();
+ diff = 0;
+ if(old != 0){
+ diff = BILLION/60 - (new - old) - delta;
+ if(diff >= MILLION)
+ sleep(diff/MILLION);
+ }
+ old = nsec();
+ if(diff != 0){
+ diff = (old - new) - (diff / MILLION) * MILLION;
+ delta += (diff - delta) / 100;
+ }
+ }
if(framestep){
paused = 1;
qlock(&pauselock);
diff --git a/sys/src/games/gba/ppu.c b/sys/src/games/gba/ppu.c
index 85d1d0652..a87caba17 100644
--- a/sys/src/games/gba/ppu.c
+++ b/sys/src/games/gba/ppu.c
@@ -754,7 +754,8 @@ hblanktick(void *)
setif(IRQVCTR);
}else{
syncppu(240);
- linecopy();
+ if(ppuy < 160)
+ linecopy();
addevent(&evhblank, 68*4);
hblank = 1;
if((stat & IRQHBLEN) != 0)