X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.c;h=7fe1110df998e96ff457d5f9151c402236623881;hb=ce3c236194323bcbc331bad4a059ea95fb6c7947;hp=566006852f7fe54059f190aefb921eae5a6d567f;hpb=8807e59c1c5d34b1ee351dd92fb7cd57b6c2847f;p=16.git
diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c
index 56600685..7fe1110d 100755
--- a/src/lib/16_mm.c
+++ b/src/lib/16_mm.c
@@ -1,19 +1,23 @@
-/* Catacomb Apocalypse Source Code
- * Copyright (C) 1993-2014 Flat Rock Software
+/* Project 16 Source Code~
+ * Copyright (C) 2012-2017 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover
*
- * This program is free software; you can redistribute it and/or modify
+ * This file is part of Project 16.
+ *
+ * Project 16 is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * Project 16 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see , or
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,
+ * Fifth Floor, Boston, MA 02110-1301 USA.
+ *
*/
// NEWMM.C
@@ -74,8 +78,10 @@ void (* XMSaddr) (void); // far pointer to XMS driver
=============================================================================
*/
#ifndef __16_PM__
+#if 0
static char *ParmStringsexmm[] = {"noems","noxms",""};
#endif
+#endif
/*
======================
=
@@ -172,6 +178,7 @@ boolean MML_CheckForEMS(void)
}
#ifndef __16_PM__
+#if 0
/*
======================
=
@@ -456,6 +463,7 @@ byte MM_MapXEMS(global_game_variables_t *gvar)
return 0;
}
#endif
+#endif
//==========================================================================
/*
@@ -491,6 +499,7 @@ boolean MML_CheckForXMS(void)
}
#ifndef __16_PM__
+#if 0
/*
======================
=
@@ -578,6 +587,7 @@ void MML_ShutdownXMS(global_game_variables_t *gvar)
}
}
#endif
+#endif
//==========================================================================
/*
@@ -815,6 +825,7 @@ void MM_Startup(global_game_variables_t *gvar)
gvar->mmi.mainmem = gvar->mmi.nearheap + gvar->mmi.farheap;
#if !defined(__16_PM__)// && defined(__WATCOMC__)
+#if 0
if(!dbg_debugpm) {
//
// detect EMS and allocate up to 64K at page frame
@@ -856,6 +867,7 @@ goto xmsskip;//0000
}
xmsskip:
#endif
+#endif
//
// allocate the misc buffer
//
@@ -889,6 +901,7 @@ void MM_Shutdown(global_game_variables_t *gvar)
free(gvar->mm.nearheap);// printf(" near freed\n");
#endif
#ifndef __16_PM__
+#if 0
#ifdef __DEBUG__
if(!dbg_debugpm) {
#endif
@@ -898,6 +911,7 @@ void MM_Shutdown(global_game_variables_t *gvar)
}
#endif
#endif
+#endif
}
//==========================================================================
@@ -1247,28 +1261,35 @@ void MM_SortMem (global_game_variables_t *gvar)
=====================
*/
-//#define MMSMSORTNEWTYPE
-#define MMSHOWMEMOFFSET 0//(gvar->video.page[0].dx+(gvar->video.page[0].dy*gvar->video.page[0].stridew))
+#ifdef __WATCOMC__
+//#define MMSMPANVID
+#define MMSMSCANINFO
+#endif
void MM_ShowMemory (global_game_variables_t *gvar)
{
mmblocktype far *scan;
- unsigned color,temp,x,y ,w;//,bofstemp;
+ unsigned color,temp,x,y ,w,q,width;
sdword end,owner;
- byte scratch[160],scratch0[4096],str[16];
+ byte scratch[160],scratch0[4096],str[16];
+ mmshowmemoryinfo_t scaninfo[MAXBLOCKS];
+ if(!gvar->video.page[0].width) gvar->video.page[0].sw = gvar->video.page[0].width = 320; //to prevent division by 0
//-- VL_SetLineWidth(40, gvar);
//temp = gvar->video.ofs.bufferofs;
//gvar->video.ofs.bufferofs = gvar->video.ofs.displayofs;
- temp = BDOFSCONV gvar->video.BOFS+MMSHOWMEMOFFSET;
+ temp = BDOFSCONV gvar->video.BOFS;
gvar->video.BOFS = gvar->video.DOFS;
scan = gvar->mm.mmhead;
end = -1; w = 0;
+ width = gvar->video.page[0].width; q = 0;
+
CA_OpenDebug (gvar);
while (scan)
{
+ scaninfo[q].scan = scan;
strcpy(scratch, AARESET);
if(scan->attributes & PURGEBITS)
{
@@ -1283,7 +1304,7 @@ void MM_ShowMemory (global_game_variables_t *gvar)
color = 1; // red = locked
strcpy(scratch0, AARED); // red = locked
}
- if(scan->start<=end)
+ if (scan->start<=end)
{
printf("\nend==%d\n\n", end);
strcat(scratch, "MM_ShowMemory: Memory block order currupted!\n");
@@ -1296,28 +1317,21 @@ void MM_ShowMemory (global_game_variables_t *gvar)
write(gvar->handle.debughandle,scratch,strlen(scratch));
Quit (gvar, "MM_ShowMemory: Memory block order currupted!");
}
-#ifdef MMSMSORTNEWTYPE
- end = scan->start+(scan->length)-1;
-#else
end = scan->length-1;
-#endif
- if(!gvar->video.page[0].width) gvar->video.page[0].width = 352;
- y = scan->start/gvar->video.page[0].width;
- x = scan->start%gvar->video.page[0].width;
+ y = scan->start/width;
+ x = scan->start%width;
+ scaninfo[q].x = x;
+ scaninfo[q].y = y;
VW_Hlin(x,x+end,y,color,gvar);
- VL_Plot(x,y,15,gvar);
+ VL_Plot(x,y,5,gvar);
+//++==++==optional strcat(scratch0, AARESET); strcat(scratch0, AAGREY); strcat(scratch0,"_");
for(w=(scan->start)/80;w<=end/80;w++)
{
- //printf("+ %u %lu\n", w, scan->length);
+//printf("+ %u %lu\n", w, scan->length);
strcat(scratch0, "+");
}
- //++==++==optional
- strcat(scratch0, AARESET); strcat(scratch0, AAGREY); strcat(scratch0,"_");
-#ifdef MMSMSORTNEWTYPE
+
if (scan->next && scan->next->start > end+1)
-#else
- if (scan->next && scan->next->start >= end+1)
-#endif
{
VW_Hlin(x+end+1,x+(scan->next->start-scan->start),y,3,gvar); // black = free//now green
strcat(scratch0, AARESET);
@@ -1325,7 +1339,7 @@ void MM_ShowMemory (global_game_variables_t *gvar)
strcat(scratch0,AAGREEN);
for(w=(end+1)/80;w<=((scan->next->start-scan->start)/80);w++)
{
- //printf("0 %x %u %lu\n", scan->next->start, w, scan->length);
+//printf("0 %x %u %lu\n", scan->next->start, w, scan->length);
strcat(scratch0,"0");
}
//printf("==================\n");
@@ -1370,11 +1384,166 @@ void MM_ShowMemory (global_game_variables_t *gvar)
//fprintf(stdout, "%s", scratch);
scan = scan->next;
+ q++;
+//if(color!=6) IN_Ack(gvar);
}
CA_CloseDebug (gvar);
- IN_Ack(gvar);
+#ifdef MMSMPANVID
+ {
+ int dx,dy,odx,ody;
+ odx = gvar->video.page[0].dx;
+ ody = gvar->video.page[0].dy;
+ dx = dy = 0;
+ while(!gvar->in.inst->Keyboard[sc_Escape])
+ {
+ if(gvar->in.inst->Keyboard[sc_UpArrow])
+ {
+ if(dy>0)
+ dy--;
+ }
+ else if(gvar->in.inst->Keyboard[sc_DownArrow])
+ {
+ if(dyvideo.page[0].height-gvar->video.page[0].sh)
+ dy++;
+ }
+ if(gvar->in.inst->Keyboard[sc_LeftArrow])
+ {
+ if(dx>0)
+ dx--;
+ }
+ else if(gvar->in.inst->Keyboard[sc_RightArrow])
+ {
+ if(dxvideo.page[0].width-gvar->video.page[0].sw)
+ dx++;
+ }
+
+ modexPanPage(&gvar->video.page[0], dx, dy);
+ VL_ShowPage(&gvar->video.page[0], 1, 1);
+ }
+
+ gvar->video.page[0].dx = odx;
+ gvar->video.page[0].dy = ody;
+ }
+#endif
+#ifdef MMSMSCANINFO
+ {
+ byte scratch1[4];
+ unsigned maxq = q;
+ boolean done;
+ ScanCode scancode;
+ int xpos,ypos;
+ word qq, ccolor = 3;
+ IN_Ack(gvar);
+// VL_ClearVideo (8);
+ for (qq = 0,done = false;!done;)
+ {
+ if(scaninfo[qq].scan->attributes & PURGEBITS)
+ {
+ ccolor = 6; // dark purple = purgable
+ strcpy(scratch1, AAMAGENTA); // dark purple = purgable
+ //printf("%s", AAMAGENTA);
+ }else{
+ ccolor = 2; // medium blue = non purgable
+ strcpy(scratch1, AABLUE); // medium blue = non purgable
+ //printf("%s", AABLUE);
+ }
+ if(scaninfo[qq].scan->attributes & LOCKBIT)
+ {
+ ccolor = 1; // red = locked
+ strcpy(scratch1, AARED); // red = locked
+ //printf("%s", AARED);
+ }
+ end = scaninfo[qq].scan->length-1;
+/*typedef struct mmblockstruct{
+ word start,length;
+ unsigned attributes;
+ memptr *useptr; // pointer to the segment start
+ struct mmblockstruct far *next;
+} mmblocktype;*/
+ //modexprint(page, x, y, t, tlsw, color, bgcolor, vidsw, const byte *str);
+#define MMSMPRINTMEMINFO modexprint(&(gvar->video.page[0]), xpos, ypos, 1, 0, ccolor, 8, gvar->video.VL_Started, global_temp_status_text); ypos+=8;
+ if(!gvar->video.VL_Started) clrscr(); else
+ {
+ VL_ShowPage(&gvar->video.page[0], 1, 0);
+ modexClearRegion(&gvar->video.page[0], 0, 0, gvar->video.page[0].width, gvar->video.page[0].height, 8);
+ }
+ 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)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
+ }
+ if(gvar->video.VL_Started)
+ {
+ 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);
+ }
+ else
+ {
+ printf("%s", scratch1);
+ printf("%s", AAGREY); printf("_");
+ for(w=(scaninfo[qq].scan->start)/80;w<=end/80;w++)
+ {
+ //strcat(scratch1, "+");
+ printf("+");
+ }
+ }
+
+
+ if (scaninfo[qq].scan->next && scaninfo[qq].scan->next->start > end+1) if(!gvar->video.VL_Started)
+ {
+ //strcat(scratch1, AARESET);
+ printf("%s", AARESET);
+ //strcat(scratch1,AAGREEN);
+ printf("%s", AAGREEN);
+ for(w=(end+1)/80;w<=((scaninfo[qq].scan->next->start-scaninfo[qq].scan->start)/80);w++)
+ {
+ //strcat(scratch1,"0");
+ printf("0");
+ }
+ }else VW_Hlin(x+end+1,x+(scaninfo[qq].scan->next->start-scaninfo[qq].scan->start),y,3,gvar); // black = free//now green
+
+
+ if(gvar->video.VL_Started)
+ {
+ //if (scan->next && scan->next->start > end+1) free
+ xpos = 16;
+ ypos = 16;//(gvar->video.page[0].sh-(32));//8*4
+ }
+ else
+ {
+ //printf("%s\n", scratch1);
+ printf("%s", AARESET);
+ printf("\n");
+ }
+ while (!(scancode = gvar->in.inst->LastScan)){}
+
+ IN_ClearKey(scancode);
+ switch (scancode)
+ {
+ case sc_LeftArrow:
+ if(qq>0) qq--;
+ else qq = maxq;
+ break;
+ case sc_RightArrow:
+ if(qqvideo.VL_Started) IN_Ack(gvar);
gvar->video.BOFS = (byte __far *)temp;
}
@@ -1526,7 +1695,7 @@ dword MM_TotalFree (global_game_variables_t *gvar)
=====================
*/
-void MM_Report_(global_game_variables_t *gvar)
+void MM_Report_ (global_game_variables_t *gvar)
{
printf("========================================\n");
printf(" MM_Report_\n");
@@ -1537,7 +1706,7 @@ void MM_Report_(global_game_variables_t *gvar)
printf(" %c%cEMM v%x.%x available\n", 0xC7, 0xC4, gvar->pm.emm.EMSVer>>4,gvar->pm.emm.EMSVer&0x0F);
printf(" %c%ctotalEMSpages: %u ", 0xC7, 0xC4, gvar->pm.emm.totalEMSpages); printf("freeEMSpages: %u\n", gvar->pm.emm.freeEMSpages);
printf(" %c%cEMSPageFrame: %04x\n", 0xC7, 0xC4, gvar->pm.emm.EMSPageFrame);
- printf(" %c%cEMSmem: %lu or %luk\n", 0xD3, 0xC4, gvar->mmi.EMSmem, gvar->mmi.EMSmem/1204);
+ printf(" %c%cEMSmem: %lu\n", 0xD3, 0xC4, gvar->mmi.EMSmem);
}
if(MML_CheckForXMS())
{
@@ -1545,7 +1714,7 @@ void MM_Report_(global_game_variables_t *gvar)
printf(" %c%cXMS v%x.%x available\n", 0xC7, 0xC4, XMSVer>>8,XMSVer&0x0F);
printf(" %c%cXMSDriver: %Fp\n", 0xC7, 0xC4, XMSDriver);
printf(" %c%cXMSHandle: %04x\n", 0xC7, 0xC4, gvar->pm.xmm.XMSHandle);
- printf(" %c%cXMSmem: %lu or %lukb\n", 0xD3, 0xC4, gvar->mmi.XMSmem, gvar->mmi.XMSmem/1024);
+ printf(" %c%cXMSmem: %lu\n", 0xD3, 0xC4, gvar->mmi.XMSmem);
}
printf(" %cConv. %u\n", 0xC9, gvar->pm.mm.MainPresent); DebugMemory_(gvar, 0);
//printf("mainmem: %lu\n", gvar->mmi.mainmem);