games/gba: fix -3 crash and prevent >100% speed

This commit is contained in:
aiju 2015-04-02 22:09:34 +02:00
parent 52ab0d1534
commit 8e588754bc
3 changed files with 20 additions and 2 deletions

View file

@ -141,6 +141,8 @@ enum {
KB = 1024,
BACKTYPELEN = 64,
HZ = 16777216,
MILLION = 1000000,
BILLION = 1000000000,
};
typedef struct Var Var;

View file

@ -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);

View file

@ -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)