From 26e7d516fe403f4fef98b9bb349fedcd9eb3a13d Mon Sep 17 00:00:00 2001
From: sparky4 <sparky4@cock.li>
Date: Wed, 19 Apr 2017 15:20:05 -0500
Subject: [PATCH] p16 is being worked on a bunch by me wwww [16_ca needs huge
 amounts of work and I should remember what needs to be done soon][OpenVGMFile
 needs to be ported to 16_snd.c]going to port rest of code to borland c some
 time so we can use the core components of id engine here [going to add
 16_us.c eventually but the debug system and CA_ PM_ and MM_ usage is priority
 now]older zcroll renamed to xcroll][zcroll is now the pre menu game loop
 system with PROPER data usage with CAMMPM] MM_ShowMemory works how i want
 wwww

---
 src/lib/16_mm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c
index 75fc0d9a..22364943 100755
--- a/src/lib/16_mm.c
+++ b/src/lib/16_mm.c
@@ -1445,6 +1445,7 @@ void MM_ShowMemory (global_game_variables_t *gvar)
 			{
 				ccolor = 1;		// red = locked
 			}
+			end = scaninfo[qq].scan->length-1;
 /*typedef struct mmblockstruct{
 	word	start,length;
 	unsigned	attributes;
@@ -1461,15 +1462,17 @@ void MM_ShowMemory (global_game_variables_t *gvar)
 			sprintf(global_temp_status_text, "block #%04u", qq); MMSMPRINTMEMINFO
 //			sprintf(global_temp_status_text, "%Fp", scaninfo[qq].scan->useptr); MMSMPRINTMEMINFO
 			sprintf(global_temp_status_text, "%04x", (unsigned)scaninfo[qq].scan->useptr); MMSMPRINTMEMINFO
-			sprintf(global_temp_status_text, "size: %05u", (unsigned)scan->length); MMSMPRINTMEMINFO
-			sprintf(global_temp_status_text, "free: %05u", (unsigned)(scaninfo[qq].scan->next->start-scaninfo[qq].scan->start)); MMSMPRINTMEMINFO
-			end = scaninfo[qq].scan->length-1;
+			sprintf(global_temp_status_text, "size: %05u", (unsigned)scaninfo[qq].scan->length); MMSMPRINTMEMINFO
+			if (scaninfo[qq].scan->next && scaninfo[qq].scan->next->start > end+1)
+			{
+				sprintf(global_temp_status_text, "free: %05u", (unsigned)(scaninfo[qq].scan->next->start-scaninfo[qq].scan->start)); MMSMPRINTMEMINFO
+			}
 			y = ypos;//scaninfo[qq].scan->start/width;
 			x = xpos;//scaninfo[qq].scan->start%width;
 			VW_Hlin(x,x+end,y,ccolor,gvar);
 			VL_Plot(x,y,5,gvar);
 			if (scaninfo[qq].scan->next && scaninfo[qq].scan->next->start > end+1)
-				VW_Hlin(x+end+1,x+(scaninfo[qq].scan->next->start-scan->start),y,3,gvar);	// black = free//now green
+				VW_Hlin(x+end+1,x+(scaninfo[qq].scan->next->start-scaninfo[qq].scan->start),y,3,gvar);	// black = free//now green
 
 			//if (scan->next && scan->next->start > end+1) free
 			xpos = 16;
-- 
2.39.5