SDL-1.2: atari:video:xbios: fix Milan and CTPCI XBIOS

From 3f69082c4018262c74dbd9a23618d961fed2479b Mon Sep 17 00:00:00 2001
From: Miro Kropacek <[EMAIL REDACTED]>
Date: Wed, 27 Sep 2023 21:08:25 +0200
Subject: [PATCH] atari:video:xbios: fix Milan and CTPCI XBIOS

---
 src/video/xbios/SDL_xbios_ctpci.c |  8 +++++---
 src/video/xbios/SDL_xbios_milan.c | 11 +++++++----
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/src/video/xbios/SDL_xbios_ctpci.c b/src/video/xbios/SDL_xbios_ctpci.c
index ac95b7adb..07fab127c 100644
--- a/src/video/xbios/SDL_xbios_ctpci.c
+++ b/src/video/xbios/SDL_xbios_ctpci.c
@@ -159,6 +159,8 @@ static void saveMode(_THIS, SDL_PixelFormat *vformat)
 	this->info.current_w = si.scrWidth;
 	this->info.current_h = si.scrHeight;
 
+	XBIOS_oldvbase = (void*)si.frameadr;
+
 	vformat->BitsPerPixel = si.scrPlanes;
 
 	XBIOS_oldnumcol = 0;
@@ -187,8 +189,8 @@ static void setMode(_THIS, xbiosmode_t *new_video_mode)
 
 static void restoreMode(_THIS)
 {
-	VsetScreen(-1, &XBIOS_oldvbase, VN_MAGIC, CMD_SETADR);
-	VsetScreen(-1, &XBIOS_oldvmode, VN_MAGIC, CMD_SETMODE);
+	VsetScreen(-1, XBIOS_oldvbase, VN_MAGIC, CMD_SETADR);
+	VsetScreen(-1, XBIOS_oldvmode, VN_MAGIC, CMD_SETMODE);
 	if (XBIOS_oldnumcol) {
 		VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
 	}
@@ -220,7 +222,7 @@ static int allocVbuffers(_THIS, int num_buffers, int bufsize)
 			/* Buffer 0 is current screen */
 			XBIOS_screensmem[i] = XBIOS_oldvbase;
 		} else {
-			VsetScreen(-1, &XBIOS_screensmem[i], VN_MAGIC, CMD_ALLOCPAGE);
+			VsetScreen(&XBIOS_screensmem[i], XBIOS_current, VN_MAGIC, CMD_ALLOCPAGE);
 		}
 
 		if (!XBIOS_screensmem[i]) {
diff --git a/src/video/xbios/SDL_xbios_milan.c b/src/video/xbios/SDL_xbios_milan.c
index 6aefc71b8..a05d3624f 100644
--- a/src/video/xbios/SDL_xbios_milan.c
+++ b/src/video/xbios/SDL_xbios_milan.c
@@ -144,6 +144,8 @@ static void saveMode(_THIS, SDL_PixelFormat *vformat)
 	this->info.current_w = si.scrWidth;
 	this->info.current_h = si.scrHeight;
 
+	XBIOS_oldvbase = (void*)si.frameadr;
+
 	XBIOS_oldnumcol = 0;
 	if (si.scrFlags & SCRINFO_OK) {
 		if (si.scrPlanes <= 8) {
@@ -170,8 +172,8 @@ static void setMode(_THIS, xbiosmode_t *new_video_mode)
 
 static void restoreMode(_THIS)
 {
-	VsetScreen(-1, &XBIOS_oldvbase, MI_MAGIC, CMD_SETADR);
-	VsetScreen(-1, &XBIOS_oldvmode, MI_MAGIC, CMD_SETMODE);
+	VsetScreen(-1, XBIOS_oldvbase, MI_MAGIC, CMD_SETADR);
+	VsetScreen(-1, XBIOS_oldvmode, MI_MAGIC, CMD_SETMODE);
 	if (XBIOS_oldnumcol) {
 		VsetRGB(0, XBIOS_oldnumcol, XBIOS_oldpalette);
 	}
@@ -179,7 +181,8 @@ static void restoreMode(_THIS)
 
 static void swapVbuffers(_THIS)
 {
-	VsetScreen(-1, XBIOS_screens[XBIOS_fbnum], MI_MAGIC, CMD_SETADR);
+	/*VsetScreen(-1, XBIOS_screens[XBIOS_fbnum], MI_MAGIC, CMD_SETADR);*/
+	VsetScreen(-1, -1, MI_MAGIC, CMD_FLIPPAGE);
 }
 
 static int getLineWidth(_THIS, xbiosmode_t *new_video_mode, int width, int bpp)
@@ -208,7 +211,7 @@ static int allocVbuffers(_THIS, int num_buffers, int bufsize)
 			/* Buffer 0 is current screen */
 			XBIOS_screensmem[i] = XBIOS_oldvbase;
 		} else {
-			VsetScreen(-1, &XBIOS_screensmem[i], MI_MAGIC, CMD_ALLOCPAGE);
+			VsetScreen(&XBIOS_screensmem[i], XBIOS_current, MI_MAGIC, CMD_ALLOCPAGE);
 		}
 
 		if (!XBIOS_screensmem[i]) {