--- /dev/null
+// WL_DEBUG.C\r
+\r
+#include "WL_DEF.H"\r
+#pragma hdrstop\r
+#include <BIOS.H>\r
+\r
+/*\r
+=============================================================================\r
+\r
+ LOCAL CONSTANTS\r
+\r
+=============================================================================\r
+*/\r
+\r
+#define VIEWTILEX (viewwidth/16)\r
+#define VIEWTILEY (viewheight/16)\r
+\r
+/*\r
+=============================================================================\r
+\r
+ GLOBAL VARIABLES\r
+\r
+=============================================================================\r
+*/\r
+\r
+\r
+int DebugKeys (void);\r
+\r
+/*\r
+=============================================================================\r
+\r
+ LOCAL VARIABLES\r
+\r
+=============================================================================\r
+*/\r
+\r
+\r
+int maporgx;\r
+int maporgy;\r
+enum {mapview,tilemapview,actoratview,visview} viewtype;\r
+\r
+void ViewMap (void);\r
+\r
+//===========================================================================\r
+\r
+/*\r
+==================\r
+=\r
+= DebugMemory\r
+=\r
+==================\r
+*/\r
+\r
+void DebugMemory (void)\r
+{\r
+ int i;\r
+ char scratch[80],str[10];\r
+ long mem;\r
+ spritetype _seg *block;\r
+\r
+ CenterWindow (16,7);\r
+\r
+ US_CPrint ("Memory Usage");\r
+ US_CPrint ("------------");\r
+ US_Print ("Total :");\r
+ US_PrintUnsigned (mminfo.mainmem/1024);\r
+ US_Print ("k\nFree :");\r
+ US_PrintUnsigned (MM_UnusedMemory()/1024);\r
+ US_Print ("k\nWith purge:");\r
+ US_PrintUnsigned (MM_TotalFree()/1024);\r
+ US_Print ("k\n");\r
+ VW_UpdateScreen();\r
+ IN_Ack ();\r
+}\r
+\r
+//===========================================================================\r
+\r
+/*\r
+==================\r
+=\r
+= CountObjects\r
+=\r
+==================\r
+*/\r
+\r
+void CountObjects (void)\r
+{\r
+ int i,total,count,active,inactive,doors;\r
+ objtype *obj;\r
+\r
+ CenterWindow (16,7);\r
+ active = inactive = count = doors = 0;\r
+\r
+ US_Print ("Total statics :");\r
+ total = laststatobj-&statobjlist[0];\r
+ US_PrintUnsigned (total);\r
+\r
+ US_Print ("\nIn use statics:");\r
+ for (i=0;i<total;i++)\r
+ if (statobjlist[i].shapenum != -1)\r
+ count++;\r
+ else\r
+ doors++; //debug\r
+ US_PrintUnsigned (count);\r
+\r
+ US_Print ("\nDoors :");\r
+ US_PrintUnsigned (doornum);\r
+\r
+ for (obj=player->next;obj;obj=obj->next)\r
+ {\r
+ if (obj->active)\r
+ active++;\r
+ else\r
+ inactive++;\r
+ }\r
+\r
+ US_Print ("\nTotal actors :");\r
+ US_PrintUnsigned (active+inactive);\r
+\r
+ US_Print ("\nActive actors :");\r
+ US_PrintUnsigned (active);\r
+\r
+ VW_UpdateScreen();\r
+ IN_Ack ();\r
+}\r
+\r
+//===========================================================================\r
+\r
+/*\r
+================\r
+=\r
+= PicturePause\r
+=\r
+================\r
+*/\r
+\r
+void PicturePause (void)\r
+{\r
+ int i;\r
+ byte p;\r
+ unsigned x;\r
+ byte far *dest,far *src;\r
+ memptr buffer;\r
+\r
+ VW_ColorBorder (15);\r
+ FinishPaletteShifts ();\r
+\r
+ LastScan = 0;\r
+ while (!LastScan)\r
+ ;\r
+ if (LastScan != sc_Enter)\r
+ {\r
+ VW_ColorBorder (0);\r
+ return;\r
+ }\r
+\r
+ VW_ColorBorder (1);\r
+ VW_SetScreen (0,0);\r
+//\r
+// vga stuff...\r
+//\r
+\r
+ ClearMemory ();\r
+ CA_SetAllPurge();\r
+ MM_GetPtr (&buffer,64000);\r
+ for (p=0;p<4;p++)\r
+ {\r
+ src = MK_FP(0xa000,displayofs);\r
+ dest = (byte far *)buffer+p;\r
+ VGAREADMAP(p);\r
+ for (x=0;x<16000;x++,dest+=4)\r
+ *dest = *src++;\r
+ }\r
+\r
+\r
+#if 0\r
+ for (p=0;p<4;p++)\r
+ {\r
+ src = MK_FP(0xa000,0);\r
+ dest = (byte far *)buffer+51200+p;\r
+ VGAREADMAP(p);\r
+ for (x=0;x<3200;x++,dest+=4)\r
+ *dest = *src++;\r
+ }\r
+#endif\r
+\r
+ asm mov ax,0x13\r
+ asm int 0x10\r
+\r
+ dest = MK_FP(0xa000,0);\r
+ _fmemcpy (dest,buffer,64000);\r
+\r
+ VL_SetPalette (&gamepal);\r
+\r
+\r
+ IN_Shutdown ();\r
+\r
+ VW_WaitVBL(70);\r
+ bioskey(0);\r
+ VW_WaitVBL(70);\r
+ Quit (NULL);\r
+}\r
+\r
+\r
+//===========================================================================\r
+\r
+\r
+/*\r
+================\r
+=\r
+= ShapeTest\r
+=\r
+================\r
+*/\r
+\r
+#pragma warn -pia\r
+void ShapeTest (void)\r
+{\r
+extern word NumDigi;\r
+extern word _seg *DigiList;\r
+static char buf[10];\r
+\r
+ boolean done;\r
+ ScanCode scan;\r
+ int i,j,k,x;\r
+ longword l;\r
+ memptr addr;\r
+ PageListStruct far *page;\r
+\r
+ CenterWindow(20,16);\r
+ VW_UpdateScreen();\r
+ for (i = 0,done = false;!done;)\r
+ {\r
+ US_ClearWindow();\r
+// sound = -1;\r
+\r
+ page = &PMPages[i];\r
+ US_Print(" Page #");\r
+ US_PrintUnsigned(i);\r
+ if (i < PMSpriteStart)\r
+ US_Print(" (Wall)");\r
+ else if (i < PMSoundStart)\r
+ US_Print(" (Sprite)");\r
+ else if (i == ChunksInFile - 1)\r
+ US_Print(" (Sound Info)");\r
+ else\r
+ US_Print(" (Sound)");\r
+\r
+ US_Print("\n XMS: ");\r
+ if (page->xmsPage != -1)\r
+ US_PrintUnsigned(page->xmsPage);\r
+ else\r
+ US_Print("No");\r
+\r
+ US_Print("\n Main: ");\r
+ if (page->mainPage != -1)\r
+ US_PrintUnsigned(page->mainPage);\r
+ else if (page->emsPage != -1)\r
+ {\r
+ US_Print("EMS ");\r
+ US_PrintUnsigned(page->emsPage);\r
+ }\r
+ else\r
+ US_Print("No");\r
+\r
+ US_Print("\n Last hit: ");\r
+ US_PrintUnsigned(page->lastHit);\r
+\r
+ US_Print("\n Address: ");\r
+ addr = PM_GetPageAddress(i);\r
+ sprintf(buf,"0x%04x",(word)addr);\r
+ US_Print(buf);\r
+\r
+ if (addr)\r
+ {\r
+ if (i < PMSpriteStart)\r
+ {\r
+ //\r
+ // draw the wall\r
+ //\r
+ bufferofs += 32*SCREENWIDTH;\r
+ postx = 128;\r
+ postwidth = 1;\r
+ postsource = ((long)((unsigned)addr))<<16;\r
+ for (x=0;x<64;x++,postx++,postsource+=64)\r
+ {\r
+ wallheight[postx] = 256;\r
+ FarScalePost ();\r
+ }\r
+ bufferofs -= 32*SCREENWIDTH;\r
+ }\r
+ else if (i < PMSoundStart)\r
+ {\r
+ //\r
+ // draw the sprite\r
+ //\r
+ bufferofs += 32*SCREENWIDTH;\r
+ SimpleScaleShape (160, i-PMSpriteStart, 64);\r
+ bufferofs -= 32*SCREENWIDTH;\r
+ }\r
+ else if (i == ChunksInFile - 1)\r
+ {\r
+ US_Print("\n\n Number of sounds: ");\r
+ US_PrintUnsigned(NumDigi);\r
+ for (l = j = k = 0;j < NumDigi;j++)\r
+ {\r
+ l += DigiList[(j * 2) + 1];\r
+ k += (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;\r
+ }\r
+ US_Print("\n Total bytes: ");\r
+ US_PrintUnsigned(l);\r
+ US_Print("\n Total pages: ");\r
+ US_PrintUnsigned(k);\r
+ }\r
+ else\r
+ {\r
+ byte far *dp = (byte far *)MK_FP(addr,0);\r
+ for (j = 0;j < NumDigi;j++)\r
+ {\r
+ k = (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;\r
+ if\r
+ (\r
+ (i >= PMSoundStart + DigiList[j * 2])\r
+ && (i < PMSoundStart + DigiList[j * 2] + k)\r
+ )\r
+ break;\r
+ }\r
+ if (j < NumDigi)\r
+ {\r
+// sound = j;\r
+ US_Print("\n Sound #");\r
+ US_PrintUnsigned(j);\r
+ US_Print("\n Segment #");\r
+ US_PrintUnsigned(i - PMSoundStart - DigiList[j * 2]);\r
+ }\r
+ for (j = 0;j < page->length;j += 32)\r
+ {\r
+ byte v = dp[j];\r
+ int v2 = (unsigned)v;\r
+ v2 -= 128;\r
+ v2 /= 4;\r
+ if (v2 < 0)\r
+ VWB_Vlin(WindowY + WindowH - 32 + v2,\r
+ WindowY + WindowH - 32,\r
+ WindowX + 8 + (j / 32),BLACK);\r
+ else\r
+ VWB_Vlin(WindowY + WindowH - 32,\r
+ WindowY + WindowH - 32 + v2,\r
+ WindowX + 8 + (j / 32),BLACK);\r
+ }\r
+ }\r
+ }\r
+\r
+ VW_UpdateScreen();\r
+\r
+ while (!(scan = LastScan))\r
+ SD_Poll();\r
+\r
+ IN_ClearKey(scan);\r
+ switch (scan)\r
+ {\r
+ case sc_LeftArrow:\r
+ if (i)\r
+ i--;\r
+ break;\r
+ case sc_RightArrow:\r
+ if (++i >= ChunksInFile)\r
+ i--;\r
+ break;\r
+ case sc_W: // Walls\r
+ i = 0;\r
+ break;\r
+ case sc_S: // Sprites\r
+ i = PMSpriteStart;\r
+ break;\r
+ case sc_D: // Digitized\r
+ i = PMSoundStart;\r
+ break;\r
+ case sc_I: // Digitized info\r
+ i = ChunksInFile - 1;\r
+ break;\r
+ case sc_L: // Load all pages\r
+ for (j = 0;j < ChunksInFile;j++)\r
+ PM_GetPage(j);\r
+ break;\r
+ case sc_P:\r
+// if (sound != -1)\r
+// SD_PlayDigitized(sound);\r
+ break;\r
+ case sc_Escape:\r
+ done = true;\r
+ break;\r
+ case sc_Enter:\r
+ PM_GetPage(i);\r
+ break;\r
+ }\r
+ }\r
+ SD_StopDigitized();\r
+}\r
+#pragma warn +pia\r
+\r
+\r
+\r
+//===========================================================================\r
+\r
+\r
+/*\r
+================\r
+=\r
+= DebugKeys\r
+=\r
+================\r
+*/\r
+\r
+int DebugKeys (void)\r
+{\r
+ boolean esc;\r
+ int level,i;\r
+\r
+ if (Keyboard[sc_B]) // B = border color\r
+ {\r
+ CenterWindow(24,3);\r
+ PrintY+=6;\r
+ US_Print(" Border color (0-15):");\r
+ VW_UpdateScreen();\r
+ esc = !US_LineInput (px,py,str,NULL,true,2,0);\r
+ if (!esc)\r
+ {\r
+ level = atoi (str);\r
+ if (level>=0 && level<=15)\r
+ VW_ColorBorder (level);\r
+ }\r
+ return 1;\r
+ }\r
+\r
+ if (Keyboard[sc_C]) // C = count objects\r
+ {\r
+ CountObjects();\r
+ return 1;\r
+ }\r
+\r
+ if (Keyboard[sc_E]) // E = quit level\r
+ {\r
+ if (tedlevel)\r
+ Quit (NULL);\r
+ playstate = ex_completed;\r
+// gamestate.mapon++;\r
+ }\r
+\r
+ if (Keyboard[sc_F]) // F = facing spot\r
+ {\r
+ CenterWindow (14,4);\r
+ US_Print ("X:");\r
+ US_PrintUnsigned (player->x);\r
+ US_Print ("\nY:");\r
+ US_PrintUnsigned (player->y);\r
+ US_Print ("\nA:");\r
+ US_PrintUnsigned (player->angle);\r
+ VW_UpdateScreen();\r
+ IN_Ack();\r
+ return 1;\r
+ }\r
+\r
+ if (Keyboard[sc_G]) // G = god mode\r
+ {\r
+ CenterWindow (12,2);\r
+ if (godmode)\r
+ US_PrintCentered ("God mode OFF");\r
+ else\r
+ US_PrintCentered ("God mode ON");\r
+ VW_UpdateScreen();\r
+ IN_Ack();\r
+ godmode ^= 1;\r
+ return 1;\r
+ }\r
+ if (Keyboard[sc_H]) // H = hurt self\r
+ {\r
+ IN_ClearKeysDown ();\r
+ TakeDamage (16,NULL);\r
+ }\r
+ else if (Keyboard[sc_I]) // I = item cheat\r
+ {\r
+ CenterWindow (12,3);\r
+ US_PrintCentered ("Free items!");\r
+ VW_UpdateScreen();\r
+ GivePoints (100000);\r
+ HealSelf (99);\r
+ if (gamestate.bestweapon<wp_chaingun)\r
+ GiveWeapon (gamestate.bestweapon+1);\r
+ gamestate.ammo += 50;\r
+ if (gamestate.ammo > 99)\r
+ gamestate.ammo = 99;\r
+ DrawAmmo ();\r
+ IN_Ack ();\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_M]) // M = memory info\r
+ {\r
+ DebugMemory();\r
+ return 1;\r
+ }\r
+#ifdef SPEAR\r
+ else if (Keyboard[sc_N]) // N = no clip\r
+ {\r
+ noclip^=1;\r
+ CenterWindow (18,3);\r
+ if (noclip)\r
+ US_PrintCentered ("No clipping ON");\r
+ else\r
+ US_PrintCentered ("No clipping OFF");\r
+ VW_UpdateScreen();\r
+ IN_Ack ();\r
+ return 1;\r
+ }\r
+#endif\r
+#if 0\r
+ else if (Keyboard[sc_O]) // O = overhead\r
+ {\r
+ ViewMap();\r
+ return 1;\r
+ }\r
+#endif\r
+ else if (Keyboard[sc_P]) // P = pause with no screen disruptioon\r
+ {\r
+ PicturePause ();\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_Q]) // Q = fast quit\r
+ Quit (NULL);\r
+ else if (Keyboard[sc_S]) // S = slow motion\r
+ {\r
+ singlestep^=1;\r
+ CenterWindow (18,3);\r
+ if (singlestep)\r
+ US_PrintCentered ("Slow motion ON");\r
+ else\r
+ US_PrintCentered ("Slow motion OFF");\r
+ VW_UpdateScreen();\r
+ IN_Ack ();\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_T]) // T = shape test\r
+ {\r
+ ShapeTest ();\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_V]) // V = extra VBLs\r
+ {\r
+ CenterWindow(30,3);\r
+ PrintY+=6;\r
+ US_Print(" Add how many extra VBLs(0-8):");\r
+ VW_UpdateScreen();\r
+ esc = !US_LineInput (px,py,str,NULL,true,2,0);\r
+ if (!esc)\r
+ {\r
+ level = atoi (str);\r
+ if (level>=0 && level<=8)\r
+ extravbls = level;\r
+ }\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_W]) // W = warp to level\r
+ {\r
+ CenterWindow(26,3);\r
+ PrintY+=6;\r
+#ifndef SPEAR\r
+ US_Print(" Warp to which level(1-10):");\r
+#else\r
+ US_Print(" Warp to which level(1-21):");\r
+#endif\r
+ VW_UpdateScreen();\r
+ esc = !US_LineInput (px,py,str,NULL,true,2,0);\r
+ if (!esc)\r
+ {\r
+ level = atoi (str);\r
+#ifndef SPEAR\r
+ if (level>0 && level<11)\r
+#else\r
+ if (level>0 && level<22)\r
+#endif\r
+ {\r
+ gamestate.mapon = level-1;\r
+ playstate = ex_warped;\r
+ }\r
+ }\r
+ return 1;\r
+ }\r
+ else if (Keyboard[sc_X]) // X = item cheat\r
+ {\r
+ CenterWindow (12,3);\r
+ US_PrintCentered ("Extra stuff!");\r
+ VW_UpdateScreen();\r
+ // DEBUG: put stuff here\r
+ IN_Ack ();\r
+ return 1;\r
+ }\r
+\r
+ return 0;\r
+}\r
+\r
+\r
+#if 0\r
+/*\r
+===================\r
+=\r
+= OverheadRefresh\r
+=\r
+===================\r
+*/\r
+\r
+void OverheadRefresh (void)\r
+{\r
+ unsigned x,y,endx,endy,sx,sy;\r
+ unsigned tile;\r
+\r
+\r
+ endx = maporgx+VIEWTILEX;\r
+ endy = maporgy+VIEWTILEY;\r
+\r
+ for (y=maporgy;y<endy;y++)\r
+ for (x=maporgx;x<endx;x++)\r
+ {\r
+ sx = (x-maporgx)*16;\r
+ sy = (y-maporgy)*16;\r
+\r
+ switch (viewtype)\r
+ {\r
+#if 0\r
+ case mapview:\r
+ tile = *(mapsegs[0]+farmapylookup[y]+x);\r
+ break;\r
+\r
+ case tilemapview:\r
+ tile = tilemap[x][y];\r
+ break;\r
+\r
+ case visview:\r
+ tile = spotvis[x][y];\r
+ break;\r
+#endif\r
+ case actoratview:\r
+ tile = (unsigned)actorat[x][y];\r
+ break;\r
+ }\r
+\r
+ if (tile<MAXWALLTILES)\r
+ LatchDrawTile(sx,sy,tile);\r
+ else\r
+ {\r
+ LatchDrawChar(sx,sy,NUMBERCHARS+((tile&0xf000)>>12));\r
+ LatchDrawChar(sx+8,sy,NUMBERCHARS+((tile&0x0f00)>>8));\r
+ LatchDrawChar(sx,sy+8,NUMBERCHARS+((tile&0x00f0)>>4));\r
+ LatchDrawChar(sx+8,sy+8,NUMBERCHARS+(tile&0x000f));\r
+ }\r
+ }\r
+\r
+}\r
+#endif\r
+\r
+#if 0\r
+/*\r
+===================\r
+=\r
+= ViewMap\r
+=\r
+===================\r
+*/\r
+\r
+void ViewMap (void)\r
+{\r
+ boolean button0held;\r
+\r
+ viewtype = actoratview;\r
+// button0held = false;\r
+\r
+\r
+ maporgx = player->tilex - VIEWTILEX/2;\r
+ if (maporgx<0)\r
+ maporgx = 0;\r
+ if (maporgx>MAPSIZE-VIEWTILEX)\r
+ maporgx=MAPSIZE-VIEWTILEX;\r
+ maporgy = player->tiley - VIEWTILEY/2;\r
+ if (maporgy<0)\r
+ maporgy = 0;\r
+ if (maporgy>MAPSIZE-VIEWTILEY)\r
+ maporgy=MAPSIZE-VIEWTILEY;\r
+\r
+ do\r
+ {\r
+//\r
+// let user pan around\r
+//\r
+ PollControls ();\r
+ if (controlx < 0 && maporgx>0)\r
+ maporgx--;\r
+ if (controlx > 0 && maporgx<mapwidth-VIEWTILEX)\r
+ maporgx++;\r
+ if (controly < 0 && maporgy>0)\r
+ maporgy--;\r
+ if (controly > 0 && maporgy<mapheight-VIEWTILEY)\r
+ maporgy++;\r
+\r
+#if 0\r
+ if (c.button0 && !button0held)\r
+ {\r
+ button0held = true;\r
+ viewtype++;\r
+ if (viewtype>visview)\r
+ viewtype = mapview;\r
+ }\r
+ if (!c.button0)\r
+ button0held = false;\r
+#endif\r
+\r
+ OverheadRefresh ();\r
+\r
+ } while (!Keyboard[sc_Escape]);\r
+\r
+ IN_ClearKeysDown ();\r
+}\r
+#endif\r
+\r