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