]> 4ch.mooo.com Git - 16.git/blob - src/lib/16_dbg.c
forgot to add it to reinitlibs
[16.git] / src / lib / 16_dbg.c
1 /* Project 16 Source Code~\r
2  * Copyright (C) 2012-2022 sparky4 & pngwen & andrius4669 & joncampbell123 & yakui-lover\r
3  *\r
4  * This file is part of Project 16.\r
5  *\r
6  * Project 16 is free software; you can redistribute it and/or modify\r
7  * it under the terms of the GNU General Public License as published by\r
8  * the Free Software Foundation; either version 3 of the License, or\r
9  * (at your option) any later version.\r
10  *\r
11  * Project 16 is distributed in the hope that it will be useful,\r
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.\r
15  *\r
16  * You should have received a copy of the GNU General Public License\r
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>, or\r
18  * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
19  * Fifth Floor, Boston, MA 02110-1301 USA.\r
20  *\r
21  */\r
22 \r
23 #include "src/lib/16_dbg.h"\r
24 \r
25 #ifdef __DEBUG__\r
26 #ifdef __DEBUG_MM__\r
27 boolean dbg_debugmm=0;\r
28 #endif\r
29 #ifdef __DEBUG_PM__\r
30 boolean dbg_debugpm=0;\r
31 #endif\r
32 #ifdef __DEBUG_CA__\r
33 boolean dbg_debugca=0;\r
34 #endif\r
35 #ifdef __DEBUG_InputMgr__\r
36 boolean dbg_testkeyin=0,dbg_testcontrolnoisy=0,dbg_nointest=0,dbg_joymousedelta=0;\r
37 #endif\r
38 #ifdef __DEBUG_MAP__\r
39 boolean dbg_maptext=0;\r
40 byte *dbg_mapdata;\r
41 #endif\r
42 #ifdef __DEBUG_RF__\r
43 boolean dbg_pagenorendermap=0,dbg_pagedelayrendermap=0;\r
44 #endif\r
45 #ifdef __DEBUG_SPRI__\r
46 boolean dbg_delayanimation=0;\r
47 #endif\r
48 #endif  //debug\r
49 \r
50 \r
51 /*\r
52 ================\r
53 =\r
54 = ShapeTest\r
55 =\r
56 ================\r
57 */\r
58 \r
59 #pragma warn -pia\r
60 void ShapeTest_(global_game_variables_t *gvar)\r
61 {\r
62 extern  word    NumDigi;\r
63 extern  word    _seg *DigiList;\r
64 static  char    buf[10];\r
65 \r
66         boolean                 done;\r
67         ScanCode                scan;\r
68         int                             i,j;\r
69 //      dword           l; word k,x;\r
70         memptr                  addr;\r
71         PageListStruct  far *page;\r
72 \r
73 //      CenterWindow(20,16);\r
74 //      VW_UpdateScreen();\r
75         for (i = 0,done = false;!done;)\r
76         {\r
77 //              US_ClearWindow();\r
78 //              sound = -1;\r
79 \r
80                 page = &(gvar->pm.PMPages[i]);\r
81 //              US_Print(" Page #");\r
82 //              US_PrintUnsigned(i);\r
83                 printf(" Page #%u", i);\r
84 //++            if (i < (gvar->pm.fi.PMSpriteStart))\r
85 //                      US_Print(" (Wall)");\r
86 //++                    printf(" (Wall)");\r
87 /*              else if (i < (gvar->pm.fi.PMSoundStart))\r
88 //                      US_Print(" (Sprite)");\r
89                         printf(" (Sprite)");\r
90                 else if (i == (gvar->pm.fi.ChunksInFile - 1))\r
91 //                      US_Print(" (Sound Info)");\r
92                         printf(" (Sound Info)");\r
93                 else\r
94 //                      US_Print(" (Sound)");\r
95                         printf(" (Sound)");*/\r
96 \r
97 //              US_Print("\n XMS: ");\r
98                 printf("\n XMS: ");\r
99                 if (page->xmsPage != -1)\r
100 //                      US_PrintUnsigned(page->xmsPage);\r
101                         printf("%u", page->xmsPage);\r
102                 else\r
103 //                      US_Print("No");\r
104                         printf("No");\r
105 \r
106 //              US_Print("\n Main: ");\r
107                 if (page->mainPage != -1)\r
108 //                      US_PrintUnsigned(page->mainPage);\r
109                         printf("\n Main: %u", page->mainPage);\r
110                 else if (page->emsPage != -1)\r
111                 {\r
112 //                      US_Print("EMS ");\r
113 //                      US_PrintUnsigned(page->emsPage);\r
114                         printf("EMS %u", page->emsPage);\r
115                 }\r
116                 else\r
117 //                      US_Print("No");\r
118                         printf("No");\r
119 \r
120 //              US_Print("\n Last hit: ");\r
121 //              US_PrintUnsigned(page->lastHit);\r
122                 printf("\n Last hit: %u", page->lastHit);\r
123 \r
124 //              US_Print("\n Address: ");\r
125                 printf("\n Address: ");\r
126                 addr = PM_GetPageAddress(i, gvar);\r
127                 sprintf(buf,"0x%04x",(word)addr);\r
128 //              US_Print(buf);\r
129                 printf("%s", buf);\r
130 \r
131                 if (addr)\r
132                 {\r
133 /*                      if (i < PMSpriteStart)\r
134                         {\r
135                         //\r
136                         // draw the wall\r
137                         //\r
138                                 bufferofs += 32*SCREENWIDTH;\r
139                                 postx = 128;\r
140                                 postwidth = 1;\r
141                                 postsource = ((long)((unsigned)addr))<<16;\r
142                                 for (x=0;x<64;x++,postx++,postsource+=64)\r
143                                 {\r
144                                         wallheight[postx] = 256;\r
145                                         FarScalePost ();\r
146                                 }\r
147                                 bufferofs -= 32*SCREENWIDTH;\r
148                         }\r
149                         else if (i < PMSoundStart)\r
150                         {\r
151                         //\r
152                         // draw the sprite\r
153                         //\r
154                                 bufferofs += 32*SCREENWIDTH;\r
155                                 SimpleScaleShape (160, i-PMSpriteStart, 64);\r
156                                 bufferofs -= 32*SCREENWIDTH;\r
157                         }\r
158                         else if (i == ChunksInFile - 1)\r
159                         {\r
160                                 US_Print("\n\n Number of sounds: ");\r
161                                 US_PrintUnsigned(NumDigi);\r
162                                 for (l = j = k = 0;j < NumDigi;j++)\r
163                                 {\r
164                                         l += DigiList[(j * 2) + 1];\r
165                                         k += (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;\r
166                                 }\r
167                                 US_Print("\n Total bytes: ");\r
168                                 US_PrintUnsigned(l);\r
169                                 US_Print("\n Total pages: ");\r
170                                 US_PrintUnsigned(k);\r
171                         }\r
172                         else\r
173                         {\r
174                                 byte far *dp = (byte far *)MK_FP(addr,0);\r
175                                 for (j = 0;j < NumDigi;j++)\r
176                                 {\r
177                                         k = (DigiList[(j * 2) + 1] + (PMPageSize - 1)) / PMPageSize;\r
178                                         if\r
179                                         (\r
180                                                 (i >= PMSoundStart + DigiList[j * 2])\r
181                                         &&      (i < PMSoundStart + DigiList[j * 2] + k)\r
182                                         )\r
183                                                 break;\r
184                                 }\r
185                                 if (j < NumDigi)\r
186                                 {\r
187 //                                      sound = j;\r
188                                         US_Print("\n Sound #");\r
189                                         US_PrintUnsigned(j);\r
190                                         US_Print("\n Segment #");\r
191                                         US_PrintUnsigned(i - PMSoundStart - DigiList[j * 2]);\r
192                                 }\r
193                                 for (j = 0;j < page->length;j += 32)\r
194                                 {\r
195                                         byte v = dp[j];\r
196                                         int v2 = (unsigned)v;\r
197                                         v2 -= 128;\r
198                                         v2 /= 4;\r
199                                         if (v2 < 0)\r
200                                                 VWB_Vlin(WindowY + WindowH - 32 + v2,\r
201                                                                 WindowY + WindowH - 32,\r
202                                                                 WindowX + 8 + (j / 32),BLACK);\r
203                                         else\r
204                                                 VWB_Vlin(WindowY + WindowH - 32,\r
205                                                                 WindowY + WindowH - 32 + v2,\r
206                                                                 WindowX + 8 + (j / 32),BLACK);\r
207                                 }\r
208                         }*/\r
209                         printf("\naddr ok\n");\r
210                 }\r
211 \r
212 //              VW_UpdateScreen();\r
213 \r
214                 while (!(scan = gvar->in.inst->LastScan))\r
215                 {}\r
216 //                      SD_Poll();\r
217 \r
218                 IN_ClearKey(scan);\r
219                 switch (scan)\r
220                 {\r
221                 case sc_LeftArrow:\r
222                         if (i)\r
223                                 i--;\r
224                         break;\r
225                 case sc_RightArrow:\r
226                         if (++i >= (gvar->pm.fi.ChunksInFile))\r
227                                 i--;\r
228                         break;\r
229                 case sc_W:      // Walls\r
230                         i = 0;\r
231                         break;\r
232                 case sc_S:      // Sprites\r
233 //                      i = (gvar->pm.fi.PMSpriteStart);\r
234                         break;\r
235                 case sc_D:      // Digitized\r
236 //                      i = (gvar->pm.fi.PMSoundStart);\r
237                         break;\r
238                 case sc_I:      // Digitized info\r
239                         i = (gvar->pm.fi.ChunksInFile - 1);\r
240                         break;\r
241                 case sc_L:      // Load all pages\r
242                         for (j = 0;j < (gvar->pm.fi.ChunksInFile);j++)\r
243                                 PM_GetPage(j, gvar);\r
244                         break;\r
245                 case sc_P:\r
246 //                      if (sound != -1)\r
247 //                              SD_PlayDigitized(sound);\r
248                         break;\r
249                 case sc_Escape:\r
250                         done = true;\r
251                         break;\r
252                 case sc_Enter:\r
253                         PM_GetPage(i, gvar);\r
254                         break;\r
255                 }\r
256         }\r
257         //SD_StopDigitized();\r
258 }\r
259 #pragma warn +pia\r
260 \r
261 #ifdef __WATCOMC__\r
262 #ifdef __DEBUG_VL__\r
263 \r
264 //===========================================================================\r
265 \r
266 /*\r
267 ================\r
268 =\r
269 = ShowPalVarSync\r
270 =\r
271 ================\r
272 */\r
273 \r
274 //#define SHOWPALVARIMODQUAD    ((spv.i)%QUADWH)\r
275 #define SHOWPALVARIMOD                  ((spv.i)%TILEWH)\r
276 #define SHOWPALVARIDIV                  ((spv.i)/TILEWH)\r
277 #define SHOWPALVARIMODIFCOND    if((!SHOWPALVARIMOD) && spv.i)\r
278 #define SHOWPALVARIDIVIFCOND            if((!SHOWPALVARIDIV) && spv.i)\r
279 //<PAL_SIZE/3 && spv.i)\r
280 #define SHOWPALVARPALSIZELIMIT  255\r
281 \r
282 spv_t ShowPalVarSync (spv_t *spv)\r
283 {\r
284         spv_t           result;\r
285         result = *spv;\r
286 \r
287 //      if(result.paly<result.palq+TILEWH*8) result.paly+=result.mult;\r
288 //      if(result.palx<result.palq+TILEWH*12) result.palx+=result.mult;\r
289 //      modexClearRegion(&gvar->video.page[0], result.palx+TILEWH, result.paly+TILEWH, result.mult, result.mult, result.i);\r
290         return result;\r
291 }\r
292 \r
293 /*\r
294 ================\r
295 =\r
296 = ShowPalVal\r
297 =\r
298 ================\r
299 */\r
300 \r
301 void ShowPalVal (global_game_variables_t *gvar)\r
302 {\r
303         boolean                 done                            ,err;\r
304         ScanCode                scan;\r
305         spv_t                   spv;\r
306         word ccolor = 3, xpos = gvar->video.page[0].dx, ypos = gvar->video.page[0].dy;\r
307 \r
308         spv.mult=(QUADWH);\r
309         spv.palq=(spv.mult)*TILEWH;\r
310         spv.i = 0;\r
311 \r
312 //      IN_UserInput(1, gvar);\r
313         modexpdump(0, gvar);\r
314 \r
315         for (spv.oi = 1,done = false;!done;)\r
316         {\r
317                 SHOWPALVARIMODIFCOND\r
318                 {\r
319                         if(err) printf("SHOWPALVARIMODIFCOND\n");\r
320                         if(spv.i==SHOWPALVARPALSIZELIMIT) spv.paly=(TILEWH*8)+spv.mult*SHOWPALVARIDIV;\r
321                         spv.palx=(TILEWH*12);\r
322                 }else   spv.palx=(TILEWH*12)+spv.mult*SHOWPALVARIMOD;\r
323                 if(spv.i<SHOWPALVARPALSIZELIMIT) SHOWPALVARIDIVIFCOND\r
324                 {\r
325                         if(err) printf("SHOWPALVARIDIVIFCOND\n");\r
326                         spv.paly=(TILEWH*8);\r
327                 }else   spv.paly=(TILEWH*8)+spv.mult*SHOWPALVARIDIV;\r
328 \r
329                 if((spv.palx<TILEWH*12 || spv.paly<TILEWH*8) && spv.i) err=true;\r
330                 else err = false;\r
331                 if(err){ printf("ERR    "); printf("%ux%u       %u\n", spv.palx, spv.paly, spv.i); }\r
332 \r
333                 if(spv.oi!=spv.i)\r
334                 {\r
335                         modexpdump(0, gvar);\r
336                         modexClearRegion(&gvar->video.page[0], spv.palx+TILEWH, spv.paly+TILEWH, spv.mult, spv.mult, 5);\r
337                         modexClearRegion(&gvar->video.page[0], spv.palx+TILEWH+1, spv.paly+TILEWH+1, spv.mult-2, spv.mult-2, spv.i);\r
338                         spv.oi = spv.i;\r
339                 }\r
340 \r
341 #define SHOWPALVARPRINT modexprint(&(gvar->video.page[0]), xpos, ypos, 1, 1, ccolor, 8, gvar->video.VL_Started, global_temp_status_text); ypos+=8;\r
342                 sprintf(global_temp_status_text, "%03u", spv.i); SHOWPALVARPRINT\r
343                 sprintf(global_temp_status_text, "r %03u", gvar->video.palette[(spv.i*3)+0]/*>>2*/); SHOWPALVARPRINT\r
344                 sprintf(global_temp_status_text, "g %03u", gvar->video.palette[(spv.i*3)+1]/*>>2*/); SHOWPALVARPRINT\r
345                 sprintf(global_temp_status_text, "b %03u", gvar->video.palette[(spv.i*3)+2]/*>>2*/); SHOWPALVARPRINT\r
346                 xpos = gvar->video.page[0].dx; ypos = gvar->video.page[0].dy;\r
347 \r
348                 while (!(scan = gvar->in.inst->LastScan))\r
349                 {}\r
350 \r
351                 IN_ClearKey(scan);\r
352                 switch (scan)\r
353                 {\r
354                 case sc_LeftArrow:\r
355                         if (spv.i > 0)\r
356                         {\r
357                                 spv.i--;\r
358                         }\r
359                         else\r
360                         {\r
361                                 spv.palx=gvar->video.page[0].sw-spv.mult;\r
362                                 spv.paly=gvar->video.page[0].sh-spv.mult;\r
363                                 spv.i = SHOWPALVARPALSIZELIMIT;\r
364                         }\r
365                 break;\r
366                 case sc_RightArrow:\r
367                         if (spv.i < SHOWPALVARPALSIZELIMIT)\r
368                         {\r
369                                 spv.i++;\r
370                         }\r
371                                 else\r
372                         {\r
373                                 spv.palx=TILEWH*12;\r
374                                 spv.paly=TILEWH*8;\r
375                                 spv.i = 0;\r
376                         }\r
377                 break;\r
378                 case sc_UpArrow:\r
379                         if (spv.i > 0)\r
380                         {\r
381                                 spv.i-=16;\r
382                         }\r
383                         else\r
384                         {\r
385                                 spv.palx=gvar->video.page[0].sw-spv.mult;\r
386                                 spv.paly=gvar->video.page[0].sh-spv.mult;\r
387                                 spv.i = SHOWPALVARPALSIZELIMIT;\r
388                         }\r
389                 break;\r
390                 case sc_DownArrow:\r
391                         if (spv.i < SHOWPALVARPALSIZELIMIT)\r
392                         {\r
393                                 spv.i+=16;\r
394                         }\r
395                                 else\r
396                         {\r
397                                 spv.palx=TILEWH*12;\r
398                                 spv.paly=TILEWH*8;\r
399                                 spv.i = 0;\r
400                         }\r
401                 break;\r
402                 case sc_W:      // Walls\r
403                         spv.i = 0;\r
404                         break;\r
405                 case sc_Escape:\r
406                         done = true;\r
407                         break;\r
408                 }\r
409         }\r
410 //      IN_UserInput(1, gvar);\r
411 }\r
412 #endif  //debug vl\r
413 #endif  //watcomc\r