diff --git a/sys/src/games/gb/dat.h b/sys/src/games/gb/dat.h index 8ce259acb..110e955de 100644 --- a/sys/src/games/gb/dat.h +++ b/sys/src/games/gb/dat.h @@ -22,7 +22,7 @@ extern u8int ppuy, ppustate; extern u8int mode; extern u8int mbc, feat; -extern int keys; +extern int keys, scale; enum { JOYP = 0x00, diff --git a/sys/src/games/gb/ppu.c b/sys/src/games/gb/ppu.c index 3dbd221d2..bd1ecf905 100644 --- a/sys/src/games/gb/ppu.c +++ b/sys/src/games/gb/ppu.c @@ -5,7 +5,7 @@ #include "fns.h" u8int ppustate, ppuy; -u32int pic[PICW*PICH]; +u32int pic[PICW*PICH*3]; ulong hblclock, rendclock; jmp_buf mainjmp, renderjmp; static int cyc, done, ppux, ppux0; @@ -63,7 +63,7 @@ ppurender(void) } ppux = 0; ppux0 = 0; - picp = pic + ppuy * PICW; + picp = pic + ppuy * PICW * scale; y = ppuy + reg[SCY] << 1 & 14; ta = 0x1800 | reg[LCDC] << 7 & 0x400 | ppuy + reg[SCY] << 2 & 0x3e0 | reg[SCX] >> 3; x = -(reg[SCX] & 7); @@ -197,7 +197,7 @@ sprites(void) int x, x1; u16int chr; - picp = pic + ppuy * PICW; + picp = pic + ppuy * PICW * scale; for(q = spr; q < sprm; q++){ if(q->x <= ppux0 || q->x >= ppux + 8) continue; @@ -250,6 +250,25 @@ linelen(void) return t*2; } +static void +lineexpand(void) +{ + u32int *picp, *p, *q, l; + int i, s; + + s = scale; + picp = pic + ppuy * PICW * s; + p = picp + PICW; + q = picp + PICW * scale; + for(i = PICW; --i >= 0; ){ + l = *--p; + *--q = l; + *--q = l; + if(scale == 3) + *--q = l; + } +} + void hblanktick(void *) { @@ -298,6 +317,8 @@ hblanktick(void *) ppusync(); if(!done) print("not done?!\n"); done = 0; + if(scale > 1) + lineexpand(); ppustate = 0; if((reg[STAT] & IRQM0) != 0) reg[IF] |= IRQLCDS;