shithub: riscv

Download patch

ref: 235cc0747d3909c4d3eac307fa58664896eb5951
parent: c5214cd6d9b36622d838fe171273d9f0dd5ba407
author: aiju <devnull@localhost>
date: Sun May 25 17:45:13 EDT 2014

games/md: small cpu and vdp bug fixes

--- a/sys/src/games/md/cpu.c
+++ b/sys/src/games/md/cpu.c
@@ -252,7 +252,7 @@
 		if((v >> 32) != 0)
 			rS |= FLAGC;
 		if((v >> 31) != 0)
-			rS |= FLAGV;
+			rS |= FLAGN;
 		if((~(w ^ u) & (v ^ u) & (1<<31)) != 0)
 			rS |= FLAGV;
 		if((u32int)v != 0)
@@ -461,7 +461,7 @@
 	int n, m, d;
 	static int cnt;
 
-	if(0 && pc == 0x13dc4){
+	if(0 && pc == 0x48ee){
 		trace++;
 		print("%x\n", curpc);
 	}
--- a/sys/src/games/md/dat.h
+++ b/sys/src/games/md/dat.h
@@ -3,6 +3,7 @@
 typedef signed long s32int;
 
 extern u32int curpc, irq;
+extern int trace;
 
 extern u8int reg[32];
 extern u8int dma;
--- a/sys/src/games/md/md.c
+++ b/sys/src/games/md/md.c
@@ -91,6 +91,8 @@
 				close(fd);
 				threadexitsall(nil);
 			}
+			if(utfrune(buf, 't'))
+				trace = !trace;
 		}
 		if(buf[0] != 'k' && buf[0] != 'K')
 			continue;
--- a/sys/src/games/md/vdp.c
+++ b/sys/src/games/md/vdp.c
@@ -187,13 +187,13 @@
 static void
 spritesinit(void)
 {
-	u16int *t, *p, dy, *c;
+	u16int t, *p, dy, *c;
 	u32int v;
 	int i, ns, np;
 	struct sprite *q;
 	
-	t = vram + (reg[SPRTAB] << 8 & 0x7f00);
-	p = t;
+	t = (reg[SPRTAB] << 8 & 0x7f00);
+	p = vram + t;
 	q = spr;
 	ns = (reg[MODE4] & WIDE) != 0 ? 20 : 16;
 	np = 0;
@@ -229,7 +229,7 @@
 			vdpstat |= STATOVR;
 			break;
 		}
-	}while(p = t + ((p[1] & 0x7f) << 2), p != t);
+	}while(p = vram + (u16int)(t + ((p[1] & 0x7f) << 2)), p - vram != t);
 	lsp = q;
 }