games/md: moonwalker!

This commit is contained in:
aiju 2014-05-26 01:10:46 +02:00
parent 235cc0747d
commit c124e341b9
6 changed files with 41 additions and 15 deletions

View file

@ -461,7 +461,7 @@ step(void)
int n, m, d; int n, m, d;
static int cnt; static int cnt;
if(0 && pc == 0x48ee){ if(0 && pc == 0x61e8){
trace++; trace++;
print("%x\n", curpc); print("%x\n", curpc);
} }
@ -935,7 +935,7 @@ step(void)
if((op & 8) != 0){ if((op & 8) != 0){
a = amode(4, n, 0); a = amode(4, n, 0);
v = rmode(a, 0); v = rmode(a, 0);
w = rmode(amode(5, n, 0), 0); w = rmode(amode(4, m, 0), 0);
v = addbcd(v, w); v = addbcd(v, w);
wmode(a, 0, v); wmode(a, 0, v);
}else }else

View file

@ -35,6 +35,8 @@ enum {
HORSCR = 0x0d, HORSCR = 0x0d,
AUTOINC = 0x0f, AUTOINC = 0x0f,
PLSIZ = 0x10, PLSIZ = 0x10,
WINH = 0x11,
WINV = 0x12,
DMACL = 0x13, DMACL = 0x13,
DMACH = 0x14, DMACH = 0x14,
DMASRC0 = 0x15, DMASRC0 = 0x15,

View file

@ -97,7 +97,7 @@ keyproc(void *)
if(buf[0] != 'k' && buf[0] != 'K') if(buf[0] != 'k' && buf[0] != 'K')
continue; continue;
s = buf + 1; s = buf + 1;
k = 0; k = 0xc00;
while(*s != 0){ while(*s != 0){
s += chartorune(&r, s); s += chartorune(&r, s);
switch(r){ switch(r){

View file

@ -31,8 +31,8 @@ regread(u16int a)
v >>= 8; v >>= 8;
return ctl[0] & 0xc0 | v & 0x3f; return ctl[0] & 0xc0 | v & 0x3f;
case 0x0005: case 0x0005:
return ctl[1] & 0xc0 | 0x3f;
case 0x0007: case 0x0007:
return ctl[1] & 0xc0 | 0x3f;
case 0x0009: case 0x000b: case 0x000d: case 0x0009: case 0x000b: case 0x000d:
return ctl[a-3>>1]; return ctl[a-3>>1];
case 0x1101: return (~z80bus & BUSACK) << 7; 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 int
intack(int l) intack(int l)

View file

@ -1,7 +1,7 @@
</$objtype/mkfile </$objtype/mkfile
BIN=/$objtype/bin/games BIN=/$objtype/bin/games
TARG=sega TARG=md
OFILES=\ OFILES=\
cpu.$O\ cpu.$O\
mem.$O\ mem.$O\

View file

@ -69,6 +69,7 @@ struct pctxt {
u16int t; u16int t;
u32int c; u32int c;
} pctxt[3]; } pctxt[3];
int lwin, rwin;
static void static void
tile(struct pctxt *p) tile(struct pctxt *p)
@ -79,7 +80,7 @@ tile(struct pctxt *p)
switch(p - pctxt){ switch(p - pctxt){
default: a = (reg[PANT] & 0x38) << 9; break; default: a = (reg[PANT] & 0x38) << 9; break;
case 1: a = (reg[PBNT] & 7) << 12; break; case 1: a = (reg[PBNT] & 7) << 12; break;
case 2: a = (reg[PWNT] & 0x38) << 9; break; case 2: a = (reg[PWNT] & 0x3e) << 9; break;
} }
a += p->ty << p->ws; a += p->ty << p->ws;
a += p->tx; a += p->tx;
@ -102,7 +103,7 @@ planeinit(void)
pctxt[0].ws = pctxt[1].ws = szs[reg[PLSIZ] & 3]; pctxt[0].ws = pctxt[1].ws = szs[reg[PLSIZ] & 3];
pctxt[2].ws = (reg[MODE4] & WIDE) != 0 ? 6 : 5; pctxt[2].ws = (reg[MODE4] & WIDE) != 0 ? 6 : 5;
pctxt[2].hs = 5; pctxt[2].hs = 5;
for(i = 0; i < 2; i++){ for(i = 0; i <= 2; i++){
pctxt[i].h = 1<<pctxt[i].hs; pctxt[i].h = 1<<pctxt[i].hs;
pctxt[i].w = 1<<pctxt[i].ws; pctxt[i].w = 1<<pctxt[i].ws;
} }
@ -120,7 +121,7 @@ planeinit(void)
v = vsram[i] + vdpy; v = vsram[i] + vdpy;
p->tny = v & 7; p->tny = v & 7;
p->ty = v >> 3 & pctxt[i].h - 1; p->ty = v >> 3 & pctxt[i].h - 1;
tile(pctxt + i); tile(p);
if(p->tnx != 0) if(p->tnx != 0)
if((p->t & 0x800) != 0) if((p->t & 0x800) != 0)
p->c >>= p->tnx << 2; p->c >>= p->tnx << 2;
@ -129,10 +130,30 @@ planeinit(void)
} }
sx = 0; sx = 0;
snx = 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 static void
plane(int n) plane(int n, int w)
{ {
struct pctxt *p; struct pctxt *p;
u8int v, pr; u8int v, pr;
@ -145,7 +166,7 @@ plane(int n)
v = p->c >> 28; v = p->c >> 28;
p->c <<= 4; p->c <<= 4;
} }
if(v != 0){ if(v != 0 && w != 0){
v |= p->t >> 9 & 48; v |= p->t >> 9 & 48;
pr = 2 - (n & 1) + (p->t >> 13 & 4); pr = 2 - (n & 1) + (p->t >> 13 & 4);
pixel(v, pr); pixel(v, pr);
@ -161,7 +182,7 @@ plane(int n)
static void static void
planes(void) planes(void)
{ {
int i; int i, w;
u16int v; u16int v;
if((reg[MODE3] & 4) != 0 && ++snx == 16){ if((reg[MODE3] & 4) != 0 && ++snx == 16){
@ -173,8 +194,11 @@ planes(void)
pctxt[i].ty = v >> 3 & pctxt[i].h - 1; pctxt[i].ty = v >> 3 & pctxt[i].h - 1;
} }
} }
plane(0); w = vdpx < rwin && vdpx >= lwin;
plane(1); plane(0, !w);
plane(1, 1);
if(w)
plane(2, 1);
} }
static struct sprite { static struct sprite {
@ -289,7 +313,7 @@ vdpstep(void)
vdpy = 0; vdpy = 0;
irq &= ~INTVBL; irq &= ~INTVBL;
vdpstat ^= STATFR; vdpstat ^= STATFR;
vdpstat &= ~(STATINT | STATFR | STATOVR | STATCOLL); vdpstat &= ~(STATINT | STATVBL | STATOVR | STATCOLL);
flush(); flush();
} }
if(vdpy == 0 || vdpy >= 225) if(vdpy == 0 || vdpy >= 225)