]> git.lizzy.rs Git - plan9front.git/commitdiff
games/nes: added oflag
authoraiju <devnull@localhost>
Sun, 23 Feb 2014 10:55:29 +0000 (11:55 +0100)
committeraiju <devnull@localhost>
Sun, 23 Feb 2014 10:55:29 +0000 (11:55 +0100)
sys/src/games/nes/dat.h
sys/src/games/nes/nes.c
sys/src/games/nes/ppu.c

index 0dee8f83bb2834b7992864c424362513a9214f35..04e2c504254b2483dedea110216753de119c5bf6 100644 (file)
@@ -6,7 +6,7 @@ extern u16int pput, ppuv;
 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;
 
index 6c9c8c69d46eaf778faadbec2a9917d18fde1bb5..15bee498f7f16adaa50319938c10396c6688affb 100644 (file)
@@ -15,7 +15,7 @@ Rectangle picr;
 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 @@ keyproc(void *)
 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 @@ threadmain(int argc, char **argv)
        case '3':
                scale = 3;
                break;
+       case 'o':
+               oflag = 1;
+               h -= 16;
+               break;
        } ARGEND;
 
        if(argc < 1)
@@ -180,9 +185,9 @@ threadmain(int argc, char **argv)
        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);
        
index 09b875851071e5587c556dfef41b2531badb1a5e..14926a2cfa103ca9d08b584e5479502e950acf36 100644 (file)
@@ -257,22 +257,26 @@ flush(void)
        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){
                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);
 }