diff --git a/sys/src/games/md/cpu.c b/sys/src/games/md/cpu.c index eb5ded675..c643bbe3b 100644 --- a/sys/src/games/md/cpu.c +++ b/sys/src/games/md/cpu.c @@ -461,7 +461,7 @@ step(void) int n, m, d; static int cnt; - if(0 && pc == 0x48ee){ + if(0 && pc == 0x61e8){ trace++; print("%x\n", curpc); } @@ -935,7 +935,7 @@ step(void) if((op & 8) != 0){ a = amode(4, n, 0); v = rmode(a, 0); - w = rmode(amode(5, n, 0), 0); + w = rmode(amode(4, m, 0), 0); v = addbcd(v, w); wmode(a, 0, v); }else diff --git a/sys/src/games/md/dat.h b/sys/src/games/md/dat.h index ab0fffdda..e63e9263e 100644 --- a/sys/src/games/md/dat.h +++ b/sys/src/games/md/dat.h @@ -35,6 +35,8 @@ enum { HORSCR = 0x0d, AUTOINC = 0x0f, PLSIZ = 0x10, + WINH = 0x11, + WINV = 0x12, DMACL = 0x13, DMACH = 0x14, DMASRC0 = 0x15, diff --git a/sys/src/games/md/md.c b/sys/src/games/md/md.c index a4df3b611..07ac121cb 100644 --- a/sys/src/games/md/md.c +++ b/sys/src/games/md/md.c @@ -97,7 +97,7 @@ keyproc(void *) if(buf[0] != 'k' && buf[0] != 'K') continue; s = buf + 1; - k = 0; + k = 0xc00; while(*s != 0){ s += chartorune(&r, s); switch(r){ diff --git a/sys/src/games/md/mem.c b/sys/src/games/md/mem.c index 38a185664..c746498a4 100644 --- a/sys/src/games/md/mem.c +++ b/sys/src/games/md/mem.c @@ -31,8 +31,8 @@ regread(u16int a) v >>= 8; return ctl[0] & 0xc0 | v & 0x3f; case 0x0005: - return ctl[1] & 0xc0 | 0x3f; case 0x0007: + return ctl[1] & 0xc0 | 0x3f; case 0x0009: case 0x000b: case 0x000d: return ctl[a-3>>1]; case 0x1101: return (~z80bus & BUSACK) << 7; @@ -330,7 +330,7 @@ z80write(u16int a, u8int v) } } -u32int irql[8] = {[6] INTVBL}; +u32int irql[8] = {[6] INTVBL, [4] INTHOR}; int intack(int l) diff --git a/sys/src/games/md/mkfile b/sys/src/games/md/mkfile index 6a0868a05..1be8902af 100644 --- a/sys/src/games/md/mkfile +++ b/sys/src/games/md/mkfile @@ -1,7 +1,7 @@ ty << p->ws; a += p->tx; @@ -102,7 +103,7 @@ planeinit(void) pctxt[0].ws = pctxt[1].ws = szs[reg[PLSIZ] & 3]; pctxt[2].ws = (reg[MODE4] & WIDE) != 0 ? 6 : 5; pctxt[2].hs = 5; - for(i = 0; i < 2; i++){ + for(i = 0; i <= 2; i++){ pctxt[i].h = 1<tny = v & 7; p->ty = v >> 3 & pctxt[i].h - 1; - tile(pctxt + i); + tile(p); if(p->tnx != 0) if((p->t & 0x800) != 0) p->c >>= p->tnx << 2; @@ -129,10 +130,30 @@ planeinit(void) } sx = 0; snx = 0; + v = reg[WINV] << 3 & 0xf8; + if((reg[WINV] & 0x80) != 0 ? vdpy < v : vdpy >= v){ + lwin = 0; + rwin = reg[WINH] << 4 & 0x1f0; + if((reg[WINH] & 0x80) != 0){ + lwin = rwin; + rwin = 320; + } + }else{ + lwin = 0; + rwin = 320; + } + if(rwin > lwin){ + p = pctxt + 2; + p->tx = p->ty = 0; + v = vdpy - v; + p->tny = vdpy & 7; + p->ty = vdpy >> 3 & pctxt[2].h - 1; + tile(p); + } } static void -plane(int n) +plane(int n, int w) { struct pctxt *p; u8int v, pr; @@ -145,7 +166,7 @@ plane(int n) v = p->c >> 28; p->c <<= 4; } - if(v != 0){ + if(v != 0 && w != 0){ v |= p->t >> 9 & 48; pr = 2 - (n & 1) + (p->t >> 13 & 4); pixel(v, pr); @@ -161,7 +182,7 @@ plane(int n) static void planes(void) { - int i; + int i, w; u16int v; if((reg[MODE3] & 4) != 0 && ++snx == 16){ @@ -173,8 +194,11 @@ planes(void) pctxt[i].ty = v >> 3 & pctxt[i].h - 1; } } - plane(0); - plane(1); + w = vdpx < rwin && vdpx >= lwin; + plane(0, !w); + plane(1, 1); + if(w) + plane(2, 1); } static struct sprite { @@ -289,7 +313,7 @@ vdpstep(void) vdpy = 0; irq &= ~INTVBL; vdpstat ^= STATFR; - vdpstat &= ~(STATINT | STATFR | STATOVR | STATCOLL); + vdpstat &= ~(STATINT | STATVBL | STATOVR | STATCOLL); flush(); } if(vdpy == 0 || vdpy >= 225)