games/gb: fix -2/-3

This commit is contained in:
aiju 2015-04-01 19:02:03 +02:00
parent edfdc4ac07
commit 66c98fab71
2 changed files with 25 additions and 4 deletions

View file

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

View file

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