Re: [hatari-devel] Extended VDI screen in Falcon mode

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On 05/02/2013 10:55, Eero Tamminen wrote:
What kind of changes?

Here is my patch.
I took yours and I fixed it for EmuTOS (CVS snapshots).
Now extended VDI screens work fine in Falcon mode, in any case.

What needs to be known:

1) The NVRAM video mode fix is the most important part. It forces a video mode similar to the one requested, so at startup EmuTOS picks up the right font (based on screen height) and palette (based on number of colors).

2) The NVRAM patch needs to be applied also when the user selects Reset in the Hatari UI. I put a kludge in VDI_SetResolution(), certainly not the best place.

3) After that, Hatari does its Line A patch as usual. Ideally, only the screen dimensions would need to be fixed. The character cell height and number of planes should already be correct, thanks to the right boot video mode.

4) This works very badly with TOS 4.04. The startup sequence is certainly different than the EmuTOS one. However, the NVRAM patching should not hurt. I believe that most problems come from video memory allocation, or Line A patching. Anyway, it was already very broken before the patch.

Regarding to the EmuTOS startup sequence, here is how it works:

1) Hatari hacks the boot video mode in the NVRAM
2) The VIDEL is initialized accordingly
3) The VT52 emulator is initialized accordingly (font, palette)
4) Then Hatari hacks the Line A. It can extend the screen dimensions, but changing the font or palette is not possible (too late) 5) At that point, the textmode BIOS console is correctly initialized. This can be seen on the EmuTOS welcome screen.
6) The VDI is initialized from the Line A values.

My goal was to check that EmuTOS was correct, and it is (latest CVS snapshots).
I don't plan to work more on this topic. You can clean up the patch and commit it, if you like. Extended video modes are a great feature combined to EmuTOS.

--
Vincent Rivière
diff -aurN hatari-HG-latest.orig/src/falcon/nvram.c hatari-HG-latest/src/falcon/nvram.c
--- hatari-HG-latest.orig/src/falcon/nvram.c	2013-02-07 17:27:01.125000000 +0100
+++ hatari-HG-latest/src/falcon/nvram.c	2013-02-07 17:14:03.578125000 +0100
@@ -35,6 +35,7 @@
 #include "log.h"
 #include "nvram.h"
 #include "paths.h"
+#include "vdi.h"
 
 
 // Defs for checksum
@@ -168,6 +169,51 @@
 		}
 		NvRam_SetChecksum();
 	}
+
+	if (bUseVDIRes)
+	{
+		/* The objective is to start the TOS with a video mode similar
+		 * to the requested one. This is important for the TOS to initialize
+		 * the right font height and palette. */
+		if (VDIHeight < 400)
+		{
+			/* This will select the 8x8 system font */
+			switch(VDIPlanes)
+			{
+			/* The case 1 is not handled, because that would result in 0x0000
+			 * which is an invalide video mode. This does not matter,
+			 * since any color palette is good for monochrome, anyway. */
+			case 2:	/* set 320x200x4 colors */
+				nvram[NVRAM_VMODE1] = 0x00;
+				nvram[NVRAM_VMODE2] = 0x01;
+				break;
+			case 4:	/* set 320x200x16 colors */
+			default:
+				nvram[NVRAM_VMODE1] = 0x00;
+				nvram[NVRAM_VMODE2] = 0x02;
+			}
+		}
+		else
+		{
+			/* This will select the 8x16 system font */
+			switch(VDIPlanes)
+			{
+			case 4:	/* set 640x400x16 colors */
+				nvram[NVRAM_VMODE1] = 0x01;
+				nvram[NVRAM_VMODE2] = 0x0a;
+				break;
+			case 2:	/* set 640x400x4 colors */
+				nvram[NVRAM_VMODE1] = 0x01;
+				nvram[NVRAM_VMODE2] = 0x09;
+				break;
+			case 1:	/* set 640x400x2 colors */
+			default:
+				nvram[NVRAM_VMODE1] = 0x01;
+				nvram[NVRAM_VMODE2] = 0x08;
+			}
+		}
+		NvRam_SetChecksum();
+	}
 
 	NvRam_Reset();
 }
diff -aurN hatari-HG-latest.orig/src/vdi.c hatari-HG-latest/src/vdi.c
--- hatari-HG-latest.orig/src/vdi.c	2013-02-07 17:27:01.390625000 +0100
+++ hatari-HG-latest/src/vdi.c	2013-02-07 16:34:17.265625000 +0100
@@ -22,6 +22,7 @@
 #include "vdi.h"
 #include "video.h"
 #include "configuration.h"
+#include "nvram.h"
 
 
 Uint32 VDI_OldPC;                  /* When call Trap#2, store off PC */
@@ -228,22 +229,21 @@
 		VDIRes = 2;
 		VDIPlanes = 1;
 		VDIColors = 2;
-		VDICharHeight = 16;
 		break;
 	 case GEMCOLOR_4:
 		VDIRes = 1;
 		VDIPlanes = 2;
 		VDIColors = 4;
-		VDICharHeight = 8;
 		break;
 	 case GEMCOLOR_16:
 		VDIRes = 0;
 		VDIPlanes = 4;
 		VDIColors = 16;
-		VDICharHeight = 8;
 		break;
 	}
 
+	VDICharHeight = HeightRequest < 400 ? 8 : 16;
+
 	/* screen size in bytes needs to be below limit */
 	VDI_ByteLimit(&w, &h, VDIPlanes);
 
@@ -257,6 +257,10 @@
 
 	/* Write resolution to re-boot takes effect with correct bit-depth */
 	VDI_FixDesktopInf();
+
+	/* Kludge to take in account the extended video mode on Reset */
+        /* FIXME: This should be done at the right place */
+	NvRam_Init();
 }
 
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/