shithub: sms

Download patch

ref: aa425c4c0a27ec301be84d153e6809b6d6c3f5e9
parent: 67600add6ce675dc2578495cb12c9874db4bd617
author: Jean-André Santoni <jean.andre.santoni@gmail.com>
date: Mon Jan 12 06:23:57 EST 2026

Fix ext224

--- a/vdp.c
+++ b/vdp.c
@@ -41,10 +41,16 @@
 static void
 planes(void)
 {
-	u16int screenmap = (reg[PANT] & 0x0e) << 10;
+	int ext224 = ((reg[MODE1] & 0x06) == 0x06) && ((reg[MODE2] & 0x18) == 0x10);
+	u16int screenmap = (reg[PANT] & (ext224 ? 0x0c : 0x0e)) << 10;
+	if(ext224)
+		screenmap |= 0x700;
 
-	u8int y = vdpy + reg[VERSCR];
-	y %= 224;
+	int y = vdpy + reg[VERSCR];
+	if(ext224)
+		y &= 0xff;
+	else if(y >= 224)
+		y -= 224;
 	int ty = y >> 3;
 	int tyoff = y & 7;
 
@@ -80,7 +86,7 @@
 spritesinit(void)
 {
 	u16int t1 = (reg[SPRTAB] << 7 & 0x3f00);
-	// u16int t2 = t1 + 0x80;
+	int disph = ((reg[MODE1] & 0x06) == 0x06) && ((reg[MODE2] & 0x18) == 0x10) ? 224 : 192;
 
 	int bufidx = 0;
 	for(int i = bufidx; i < 8; i++)
@@ -97,7 +103,7 @@
 
 		if(vdpy >= y && vdpy < y+h && y > 1){
 			if(bufidx >= 8){
-				if(vdpy < 192)
+				if(vdpy < disph)
 					vdpstat |= STATOVR;
 				break;
 			}
@@ -227,10 +233,11 @@
 void
 vdpstep(void)
 {
+	int disph = ((reg[MODE1] & 0x06) == 0x06) && ((reg[MODE2] & 0x18) == 0x10) ? 224 : 192;
 	if(vdpx == 0)
 		spritesinit();
 
-	if(vdpx < 320 && vdpy < 192)
+	if(vdpx < 320 && vdpy < disph)
 		if(vdpx < xdisp){
 			int c = (reg[BGCOL] & 0x0f) + 16;
 			pixeldraw(vdpx, vdpy, c);
@@ -249,7 +256,7 @@
 		}
 		if(intla)
 			vdpyy = vdpy << 1 | frame;
-		if(vdpy == 0 || vdpy > 192)
+		if(vdpy == 0 || vdpy > disph)
 			hctr = reg[HORCTR];
 		else
 			if(hctr-- == 0){
--