gb: pause function
This commit is contained in:
parent
46124af6cf
commit
d7c21149e4
2 changed files with 20 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
static int fd;
|
static int fd;
|
||||||
static int sc, ch1c, ch2c, ch3c, ch4c, ch4sr = 1, ch1vec, ch2vec, ch4vec, ch1v, ch2v, ch4v;
|
static int sc, ch1c, ch2c, ch3c, ch4c, ch4sr = 1, ch1vec, ch2vec, ch4vec, ch1v, ch2v, ch4v;
|
||||||
|
extern int paused;
|
||||||
|
|
||||||
enum { SAMPLE = 44100 };
|
enum { SAMPLE = 44100 };
|
||||||
|
|
||||||
|
@ -201,6 +202,9 @@ audioproc(void *)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
|
if(paused)
|
||||||
|
memset(samples, 0, sizeof samples);
|
||||||
|
else
|
||||||
for(i = 0; i < sizeof samples/4; i++)
|
for(i = 0; i < sizeof samples/4; i++)
|
||||||
dosample(samples + 2 * i);
|
dosample(samples + 2 * i);
|
||||||
write(fd, samples, sizeof samples);
|
write(fd, samples, sizeof samples);
|
||||||
|
|
|
@ -9,10 +9,11 @@
|
||||||
#include "fns.h"
|
#include "fns.h"
|
||||||
|
|
||||||
uchar *cart, *ram;
|
uchar *cart, *ram;
|
||||||
int mbc, rombanks, rambanks, clock, ppuclock, divclock, timerclock, syncclock, syncfreq, sleeps, checkclock, msgclock, timerfreq, timer, keys, savefd, savereq, loadreq, scale;
|
int mbc, rombanks, rambanks, clock, ppuclock, divclock, timerclock, syncclock, syncfreq, sleeps, checkclock, msgclock, timerfreq, timer, keys, savefd, savereq, loadreq, scale, paused;
|
||||||
Rectangle picr;
|
Rectangle picr;
|
||||||
Image *bg, *tmp;
|
Image *bg, *tmp;
|
||||||
Mousectl *mc;
|
Mousectl *mc;
|
||||||
|
QLock pauselock;
|
||||||
|
|
||||||
void
|
void
|
||||||
message(char *fmt, ...)
|
message(char *fmt, ...)
|
||||||
|
@ -177,7 +178,7 @@ keyproc(void *)
|
||||||
if(read(fd, buf, 256) <= 0)
|
if(read(fd, buf, 256) <= 0)
|
||||||
sysfatal("read /dev/kbd: %r");
|
sysfatal("read /dev/kbd: %r");
|
||||||
if(buf[0] == 'c'){
|
if(buf[0] == 'c'){
|
||||||
if(strchr(buf, Kesc))
|
if(utfrune(buf, KF|12) || utfrune(buf, 'o'))
|
||||||
threadexitsall(nil);
|
threadexitsall(nil);
|
||||||
if(utfrune(buf, KF|5))
|
if(utfrune(buf, KF|5))
|
||||||
savereq = 1;
|
savereq = 1;
|
||||||
|
@ -192,6 +193,13 @@ keyproc(void *)
|
||||||
s += chartorune(&r, s);
|
s += chartorune(&r, s);
|
||||||
switch(r){
|
switch(r){
|
||||||
case Kesc:
|
case Kesc:
|
||||||
|
if(paused)
|
||||||
|
qunlock(&pauselock);
|
||||||
|
else
|
||||||
|
qlock(&pauselock);
|
||||||
|
paused = !paused;
|
||||||
|
break;
|
||||||
|
case KF|12:
|
||||||
threadexitsall(nil);
|
threadexitsall(nil);
|
||||||
case Kdown:
|
case Kdown:
|
||||||
keys |= 1<<3;
|
keys |= 1<<3;
|
||||||
|
@ -270,6 +278,10 @@ threadmain(int argc, char** argv)
|
||||||
loadstate("gb.save");
|
loadstate("gb.save");
|
||||||
loadreq = 0;
|
loadreq = 0;
|
||||||
}
|
}
|
||||||
|
if(paused){
|
||||||
|
qlock(&pauselock);
|
||||||
|
qunlock(&pauselock);
|
||||||
|
}
|
||||||
t = step();
|
t = step();
|
||||||
clock += t;
|
clock += t;
|
||||||
ppuclock += t;
|
ppuclock += t;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue