From: Jonathan Campbell <jonathan@castus.tv>
Date: Sun, 17 Apr 2016 06:53:43 +0000 (-0700)
Subject: clear video RAM using pointer set after INT 10h + vga update, not
X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=cb4574433d1faa6a5345362d66211108f9aaaa3c;p=16.git

clear video RAM using pointer set after INT 10h + vga update, not
before. this fixes scribbling over VGA ROM BIOS and possible DOSBox
UMB corruption.
---

diff --git a/src/lib/modex16.c b/src/lib/modex16.c
index 70e8e871..cab13766 100755
--- a/src/lib/modex16.c
+++ b/src/lib/modex16.c
@@ -80,7 +80,6 @@ vgaGetMode()
 void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)
 {
 	word i;
-	dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA;      /* used for faster screen clearing */
 	struct vga_mode_params cm;
 	int CRTParmCount;
 
@@ -138,10 +137,12 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv)
 	/* clear video memory */
 	switch (cmem)
 	{
-		case 1:
-		/* clear video memory */
-		vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/);
-		for(i=0; i<0x8000; i++) ptr[i] = 0x0000;
+		case 1: {
+			/* clear video memory */
+			dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA;      /* used for faster screen clearing */
+			vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/);
+			for(i = 0;i < 0x4000; i++) ptr[i] = 0x0000; // 0x4000 x dword = 64KB
+		}
 		break;
 	}
 	gv->video.page[0].tilesw = gv->video.page[0].sw/TILEWH;