This commit is contained in:
aiju 2014-05-26 01:11:08 +02:00
commit a106a19bbf
6 changed files with 41 additions and 15 deletions

View file

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

View file

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

View file

@ -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){

View file

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

View file

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

View file

@ -69,6 +69,7 @@ struct pctxt {
u16int t;
u32int c;
} pctxt[3];
int lwin, rwin;
static void
tile(struct pctxt *p)
@ -79,7 +80,7 @@ tile(struct pctxt *p)
switch(p - pctxt){
default: a = (reg[PANT] & 0x38) << 9; 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->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<<pctxt[i].hs;
pctxt[i].w = 1<<pctxt[i].ws;
}
@ -120,7 +121,7 @@ planeinit(void)
v = vsram[i] + vdpy;
p->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)