X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2F16_mm.c;h=7fe1110df998e96ff457d5f9151c402236623881;hb=ce3c236194323bcbc331bad4a059ea95fb6c7947;hp=ee484c1a39fd7f64057a02aa5aa94a3488554107;hpb=597af81b9704b1b5e5c6753071e6e0ee18b1a9d5;p=16.git
diff --git a/src/lib/16_mm.c b/src/lib/16_mm.c
index ee484c1a..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
@@ -1257,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)
{
@@ -1293,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");
@@ -1306,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);
@@ -1335,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");
@@ -1380,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;
}