ref: 1de584dc355cd0951829a22fb130f11b7e66e359
parent: 74521987445ac78c20d0ca7021230e927864b62a
author: aiju <devnull@localhost>
date: Sun Feb 23 06:55:29 EST 2014
games/nes: added oflag
--- a/sys/src/games/nes/dat.h
+++ b/sys/src/games/nes/dat.h
@@ -6,7 +6,7 @@
extern u8int ppusx, vrambuf;
extern int mirr, ppux, ppuy, odd, vramlatch, keylatch;
-extern int map, scale, mmc3hack;
+extern int map, scale, mmc3hack, oflag;
extern uchar *prg, *chr;
extern int nprg, nchr, map, chrram;
--- a/sys/src/games/nes/nes.c
+++ b/sys/src/games/nes/nes.c
@@ -15,7 +15,7 @@
Image *tmp, *bg;
int clock, ppuclock, syncclock, syncfreq, checkclock, msgclock, sleeps;
Mousectl *mc;
-int keys, paused, savereq, loadreq;
+int keys, paused, savereq, loadreq, oflag;
int mirr;
QLock pauselock;
@@ -155,11 +155,12 @@
void
threadmain(int argc, char **argv)
{- int t;
+ int t, h;
Point p;
uvlong old, new, diff;
scale = 1;
+ h = 240;
ARGBEGIN {case '2':
scale = 2;
@@ -167,6 +168,10 @@
case '3':
scale = 3;
break;
+ case 'o':
+ oflag = 1;
+ h -= 16;
+ break;
} ARGEND;
if(argc < 1)
@@ -180,9 +185,9 @@
proccreate(keyproc, nil, 8192);
originwindow(screen, Pt(0, 0), screen->r.min);
p = divpt(addpt(screen->r.min, screen->r.max), 2);
- picr = (Rectangle){subpt(p, Pt(scale * 128, scale * 120)), addpt(p, Pt(scale * 128, scale * 120))};+ picr = (Rectangle){subpt(p, Pt(scale * 128, scale * h/2)), addpt(p, Pt(scale * 128, scale * h/2))};if(screen->chan != XRGB32)
- tmp = allocimage(display, Rect(0, 0, scale * 256, scale * 240), XRGB32, 0, 0);
+ tmp = allocimage(display, Rect(0, 0, scale * 256, scale * h), XRGB32, 0, 0);
bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
draw(screen, screen->r, bg, nil, ZP);
--- a/sys/src/games/nes/ppu.c
+++ b/sys/src/games/nes/ppu.c
@@ -257,7 +257,11 @@
extern Mousectl *mc;
Mouse m;
Point p;
+ int h;
+ h = 240;
+ if(oflag)
+ h -= 16;
while(nbrecv(mc->c, &m) > 0)
;
if(nbrecvul(mc->resizec) > 0){@@ -264,15 +268,15 @@
if(getwindow(display, Refnone) < 0)
sysfatal("resize failed: %r");p = divpt(addpt(screen->r.min, screen->r.max), 2);
- picr = (Rectangle){subpt(p, Pt(scale * 128, scale * 120)), addpt(p, Pt(scale * 128, scale * 120))};+ picr = (Rectangle){subpt(p, Pt(scale * 128, scale * h/2)), addpt(p, Pt(scale * 128, scale * h/2))};bg = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, 0xCCCCCCFF);
draw(screen, screen->r, bg, nil, ZP);
}
if(tmp){- loadimage(tmp, tmp->r, pic, 256*240*4*scale*scale);
+ loadimage(tmp, tmp->r, pic + oflag*8*256*4*scale*scale, 256*h*4*scale*scale);
draw(screen, picr, tmp, nil, ZP);
}else
- loadimage(screen, picr, pic, 256*240*4*scale*scale);
+ loadimage(screen, picr, pic + oflag*8*256*4*scale*scale, 256*h*4*scale*scale);
flushimage(display, 1);
memset(pic, sizeof pic, 0);
}
--
⑨