diff options
author | aiju <devnull@localhost> | 2014-06-13 18:06:44 +0200 |
---|---|---|
committer | aiju <devnull@localhost> | 2014-06-13 18:06:44 +0200 |
commit | f0ed9ed9f0799ee4993ee916994811dc9257191a (patch) | |
tree | 6a158c045dfa4c9e9107a59a623901e1bd52bcb3 | |
parent | 7c25ae8a34ad4b15e83c07477b5bd9e59fac3c5f (diff) |
games/md: vdp window fix, added ym2612 timers
-rw-r--r-- | sys/src/games/md/dat.h | 2 | ||||
-rw-r--r-- | sys/src/games/md/mem.c | 2 | ||||
-rw-r--r-- | sys/src/games/md/vdp.c | 8 | ||||
-rw-r--r-- | sys/src/games/md/ym.c | 34 |
4 files changed, 42 insertions, 4 deletions
diff --git a/sys/src/games/md/dat.h b/sys/src/games/md/dat.h index 3df16bb2c..33467024e 100644 --- a/sys/src/games/md/dat.h +++ b/sys/src/games/md/dat.h @@ -22,7 +22,7 @@ extern u32int cramc[64]; extern u16int vdpstat; extern int vdpx, vdpy; -extern u8int ym[512]; +extern u8int ym[512], ymstat; enum { MODE1 = 0x00, diff --git a/sys/src/games/md/mem.c b/sys/src/games/md/mem.c index e874d7f24..a1474934e 100644 --- a/sys/src/games/md/mem.c +++ b/sys/src/games/md/mem.c @@ -328,7 +328,7 @@ z80read(u16int a) case 1: return zram[a & 0x1fff]; case 2: - return 0; + return ymstat; case 3: if(a >= 0x7f00){ v = memread(0xc00000 | a & 0x7e); diff --git a/sys/src/games/md/vdp.c b/sys/src/games/md/vdp.c index 8230a8cdd..a16f08841 100644 --- a/sys/src/games/md/vdp.c +++ b/sys/src/games/md/vdp.c @@ -144,7 +144,8 @@ planeinit(void) } if(rwin > lwin){ p = pctxt + 2; - p->tx = p->ty = 0; + p->tx = lwin >> 3 & pctxt[2].w - 1; + p->tnx = lwin & 7; p->tny = vdpy & 7; p->ty = vdpy >> 3 & pctxt[2].h - 1; tile(p); @@ -306,7 +307,10 @@ vdpstep(void) pri = 0; planes(); sprites(); - pixeldraw(vdpx, vdpy, cramc[col]); + if((reg[MODE2] & 0x40) != 0 && (vdpx >= 8 || (reg[MODE1] & 0x20) == 0)) + pixeldraw(vdpx, vdpy, cramc[col]); + else + pixeldraw(vdpx, vdpy, 0); }else pixeldraw(vdpx, vdpy, 0xcccccc); if(++vdpx >= xmax){ diff --git a/sys/src/games/md/ym.c b/sys/src/games/md/ym.c index 835c1881d..16389a693 100644 --- a/sys/src/games/md/ym.c +++ b/sys/src/games/md/ym.c @@ -35,13 +35,42 @@ struct fm { u8int st, alg, en, fbs; float samp; } fms[6]; +u8int ymstat; static u32int cyc; +static u16int tima; +static u8int timb; static short sbuf[2 * 2000], *sbufp; static int fd; static int sint[256], expt[256]; static void +timers(void) +{ + u8int m; + static u8int bdiv; + + m = ym[0x27]; + if((m & 1) != 0){ + tima = (tima + 1) & 0x3ff; + if(tima == 0 && (m & 4) != 0){ + ymstat |= 2; + tima = ym[0x24] | ym[0x25] << 8 & 0x300; + } + } + if(++bdiv == 8){ + bdiv = 0; + if((m & 2) != 0){ + timb++; + if(timb == 0 && (m & 8) != 0){ + ymstat |= 1; + timb = ym[0x26]; + } + } + } +} + +static void calcfreq(int n) { int i, fr; @@ -129,6 +158,10 @@ ymwrite(u8int a, u8int v, u8int c) ch = c + (a & 3); switch(a){ case MODE: + if((v & 0x10) != 0) + ymstat &= ~2; + if((v & 0x20) != 0) + ymstat &= ~1; calcfreq(2); calcfreq(5); break; @@ -359,6 +392,7 @@ ymstep(void) if(++ymcyc == 3){ cyc++; ymcyc = 0; + timers(); } } ymop = 0; |