13 #include "wl_cloudsky.h"
17 =============================================================================
21 =============================================================================
24 #define VIEWTILEX (viewwidth/16)
25 #define VIEWTILEY (viewheight/16)
28 =============================================================================
32 =============================================================================
43 void SimpleScaleShape (int xcenter
, int shapenum
, unsigned height
);
46 =============================================================================
50 =============================================================================
55 enum {mapview
,tilemapview
,actoratview
,visview
} viewtype
;
59 //===========================================================================
69 void CountObjects (void)
71 int i
,total
,count
,active
,inactive
,doors
;
75 active
= inactive
= count
= doors
= 0;
77 US_Print ("Total statics :");
78 total
= (int)(laststatobj
-&statobjlist
[0]);
79 US_PrintUnsigned (total
);
82 sprintf(str
,"\nlaststatobj=%.8X",(int32_t)(uintptr_t)laststatobj
);
85 US_Print ("\nIn use statics:");
88 if (statobjlist
[i
].shapenum
!= -1)
93 US_PrintUnsigned (count
);
95 US_Print ("\nDoors :");
96 US_PrintUnsigned (doornum
);
98 for (obj
=player
->next
;obj
;obj
=obj
->next
)
106 US_Print ("\nTotal actors :");
107 US_PrintUnsigned (active
+inactive
);
109 US_Print ("\nActive actors :");
110 US_PrintUnsigned (active
);
117 //===========================================================================
126 void PictureGrabber (void)
128 static char fname
[] = "WSHOT000.BMP";
130 for(int i
= 0; i
< 1000; i
++)
132 fname
[7] = i
% 10 + '0';
133 fname
[6] = (i
/ 10) % 10 + '0';
134 fname
[5] = i
/ 100 + '0';
135 int file
= open(fname
, O_RDONLY
| O_BINARY
);
136 if(file
== -1) break; // file does not exist, so use that filename
140 // overwrites WSHOT999.BMP if all wshot files exist
142 SDL_SaveBMP(curSurface
, fname
);
145 US_PrintCentered ("Screenshot taken");
151 //===========================================================================
161 void BasicOverhead (void)
163 int x
, y
, z
, offx
, offy
;
165 z
= 128/MAPSIZE
; // zoom scale
167 offy
= (160-MAPSIZE
*z
)/2;
177 for(x
=0;x
<MAPSIZE
;x
++)
178 for(y
=0;y
<MAPSIZE
;y
++)
179 VWB_Bar(x
*z
+offx
, y
*z
+offy
,z
,z
,(unsigned)(uintptr_t)actorat
[x
][y
]);
181 // left side (filtered)
187 for(x
=0;x
<MAPSIZE
;x
++)
189 for(y
=0;y
<MAPSIZE
;y
++)
191 tile
= (uintptr_t)actorat
[x
][y
];
192 if (ISPOINTER(tile
) && ((objtype
*)tile
)->flags
&FL_SHOOTABLE
) color
= 72; // enemy
193 else if (!tile
|| ISPOINTER(tile
))
195 if (spotvis
[x
][y
]) color
= 111; // visable
196 else color
= 0; // nothing
198 else if (MAPSPOT(x
,y
,1) == PUSHABLETILE
) color
= 171; // pushwall
199 else if (tile
== 64) color
= 158; // solid obj
200 else if (tile
< 128) color
= 154; // walls
201 else if (tile
< 256) color
= 146; // doors
203 VWB_Bar(x
*z
+offx
, y
*z
+offy
,z
,z
,color
);
207 VWB_Bar(player
->tilex
*z
+offx
,player
->tiley
*z
+offy
,z
,z
,15); // player
209 // resize the border to match
221 //===========================================================================
231 void ShapeTest (void)
236 extern word
*DigiList
;
238 extern int postwidth
;
239 extern byte
*postsource
;
248 // PageListStruct far *page;
252 for (i
= 0,done
= false; !done
;)
255 sound
= (soundnames
) -1;
257 // page = &PMPages[i];
260 if (i
< PMSpriteStart
)
262 else if (i
< PMSoundStart
)
263 US_Print(" (Sprite)");
264 else if (i
== ChunksInFile
- 1)
265 US_Print(" (Sound Info)");
267 US_Print(" (Sound)");
269 /* US_Print("\n XMS: ");
270 if (page->xmsPage != -1)
271 US_PrintUnsigned(page->xmsPage);
275 US_Print("\n Main: ");
276 if (page->mainPage != -1)
277 US_PrintUnsigned(page->mainPage);
278 else if (page->emsPage != -1)
281 US_PrintUnsigned(page->emsPage);
286 US_Print("\n Last hit: ");
287 US_PrintUnsigned(page->lastHit);*/
289 US_Print("\n Address: ");
290 addr
= (byte
*) PM_GetPage(i
);
291 sprintf(buf
,"0x%08X",(int32_t) addr
);
296 if (i
< PMSpriteStart
)
301 vbuf
+= 32*SCREENWIDTH
;
305 for (x
=0;x
<64;x
++,postx
++,postsource
+=64)
307 wallheight
[postx
] = 256;
310 vbuf
-= 32*SCREENWIDTH
;
312 else if (i
< PMSoundStart
)
317 vbuf
+= 32*SCREENWIDTH
;
318 SimpleScaleShape (160, i
-PMSpriteStart
, 64);
319 vbuf
-= 32*SCREENWIDTH
;
321 else if (i
== ChunksInFile
- 1)
323 US_Print("\n\n Number of sounds: ");
324 US_PrintUnsigned(NumDigi
);
325 for (l
= j
= k
= 0;j
< NumDigi
;j
++)
327 l
+= DigiList
[(j
* 2) + 1];
328 k
+= (DigiList
[(j
* 2) + 1] + (PMPageSize
- 1)) / PMPageSize
;
330 US_Print("\n Total bytes: ");
332 US_Print("\n Total pages: ");
338 for (j
= 0;j
< NumDigi
;j
++)
340 k
= (DigiList
[(j
* 2) + 1] + (PMPageSize
- 1)) / PMPageSize
;
341 if ((i
>= PMSoundStart
+ DigiList
[j
* 2])
342 && (i
< PMSoundStart
+ DigiList
[j
* 2] + k
))
347 sound
= (soundnames
) j
;
348 US_Print("\n Sound #");
350 US_Print("\n Segment #");
351 US_PrintUnsigned(i
- PMSoundStart
- DigiList
[j
* 2]);
353 for (j
= 0;j
< PageLengths
[i
];j
+= 32)
356 int v2
= (unsigned)v
;
360 VWB_Vlin(WindowY
+ WindowH
- 32 + v2
,
361 WindowY
+ WindowH
- 32,
362 WindowX
+ 8 + (j
/ 32),BLACK
);
364 VWB_Vlin(WindowY
+ WindowH
- 32,
365 WindowY
+ WindowH
- 32 + v2
,
366 WindowX
+ 8 + (j
/ 32),BLACK
);
384 if (++i
>= ChunksInFile
)
390 case sc_S
: // Sprites
393 case sc_D
: // Digitized
396 case sc_I
: // Digitized info
397 i
= ChunksInFile
- 1;
399 /* case sc_L: // Load all pages
400 for (j = 0;j < ChunksInFile;j++)
405 SD_PlayDigitized(sound
,8,8);
420 //===========================================================================
436 if (Keyboard
[sc_B
]) // B = border color
440 US_Print(" Border color (0-56): ");
442 esc
= !US_LineInput (px
,py
,str
,NULL
,true,2,0);
446 if (level
>=0 && level
<=99)
448 if (level
<30) level
+= 31;
451 if (level
> 56) level
=31;
457 if (bordercol
== VIEWCOLOR
)
458 DrawStatusBorder(bordercol
);
467 if (Keyboard
[sc_C
]) // C = count objects
472 if (Keyboard
[sc_D
]) // D = Darkone's FPS counter
476 US_PrintCentered ("Darkone's FPS Counter OFF");
478 US_PrintCentered ("Darkone's FPS Counter ON");
484 if (Keyboard
[sc_E
]) // E = quit level
485 playstate
= ex_completed
;
487 if (Keyboard
[sc_F
]) // F = facing spot
491 US_Print ("x:"); US_PrintUnsigned (player
->x
);
492 US_Print (" ("); US_PrintUnsigned (player
->x
%65536);
493 US_Print (")\ny:"); US_PrintUnsigned (player
->y
);
494 US_Print (" ("); US_PrintUnsigned (player
->y
%65536);
495 US_Print (")\nA:"); US_PrintUnsigned (player
->angle
);
496 US_Print (" X:"); US_PrintUnsigned (player
->tilex
);
497 US_Print (" Y:"); US_PrintUnsigned (player
->tiley
);
498 US_Print ("\n1:"); US_PrintUnsigned (tilemap
[player
->tilex
][player
->tiley
]);
499 sprintf(str
," 2:%.8X",(unsigned)(uintptr_t)actorat
[player
->tilex
][player
->tiley
]); US_Print(str
);
500 US_Print ("\nf 1:"); US_PrintUnsigned (player
->areanumber
);
501 US_Print (" 2:"); US_PrintUnsigned (MAPSPOT(player
->tilex
,player
->tiley
,1));
503 if ((unsigned)(uintptr_t)actorat
[player
->tilex
][player
->tiley
] < 256)
504 US_PrintUnsigned (spotvis
[player
->tilex
][player
->tiley
]);
506 US_PrintUnsigned (actorat
[player
->tilex
][player
->tiley
]->flags
);
512 if (Keyboard
[sc_G
]) // G = god mode
516 US_PrintCentered ("God mode ON");
517 else if (godmode
== 1)
518 US_PrintCentered ("God (no flash)");
519 else if (godmode
== 2)
520 US_PrintCentered ("God mode OFF");
530 if (Keyboard
[sc_H
]) // H = hurt self
533 TakeDamage (16,NULL
);
535 else if (Keyboard
[sc_I
]) // I = item cheat
538 US_PrintCentered ("Free items!");
542 if (gamestate
.bestweapon
<wp_chaingun
)
543 GiveWeapon (gamestate
.bestweapon
+1);
544 gamestate
.ammo
+= 50;
545 if (gamestate
.ammo
> 99)
551 else if (Keyboard
[sc_K
]) // K = give keys
555 US_Print(" Give Key (1-4): ");
557 esc
= !US_LineInput (px
,py
,str
,NULL
,true,1,0);
561 if (level
>0 && level
<5)
566 else if (Keyboard
[sc_L
]) // L = level ratios
568 byte x
,start
,end
=LRpack
;
570 if (end
== 8) // wolf3d
581 for(x
=start
;x
<end
;x
++)
583 US_PrintUnsigned(x
+1);
585 US_PrintUnsigned(LevelRatios
[x
].time
/60);
587 if (LevelRatios
[x
].time
%60 < 10)
589 US_PrintUnsigned(LevelRatios
[x
].time
%60);
591 US_PrintUnsigned(LevelRatios
[x
].kill
);
593 US_PrintUnsigned(LevelRatios
[x
].secret
);
595 US_PrintUnsigned(LevelRatios
[x
].treasure
);
600 if (end
== 10 && gamestate
.mapon
> 9)
602 start
= 10; end
= 20;
609 else if (Keyboard
[sc_N
]) // N = no clip
614 US_PrintCentered ("No clipping ON");
616 US_PrintCentered ("No clipping OFF");
621 else if (Keyboard
[sc_O
]) // O = basic overhead
626 else if(Keyboard
[sc_P
]) // P = Ripper's picture grabber
631 else if (Keyboard
[sc_Q
]) // Q = fast quit
633 else if (Keyboard
[sc_S
]) // S = slow motion
637 US_Print(" Slow Motion steps (default 14): ");
639 esc
= !US_LineInput (px
,py
,str
,NULL
,true,2,0);
643 if (level
>=0 && level
<=50)
648 else if (Keyboard
[sc_T
]) // T = shape test
653 else if (Keyboard
[sc_V
]) // V = extra VBLs
657 US_Print(" Add how many extra VBLs(0-8): ");
659 esc
= !US_LineInput (px
,py
,str
,NULL
,true,1,0);
663 if (level
>=0 && level
<=8)
668 else if (Keyboard
[sc_W
]) // W = warp to level
673 US_Print(" Warp to which level(1-10): ");
675 US_Print(" Warp to which level(1-21): ");
678 esc
= !US_LineInput (px
,py
,str
,NULL
,true,2,0);
683 if (level
>0 && level
<11)
685 if (level
>0 && level
<22)
688 gamestate
.mapon
= level
-1;
689 playstate
= ex_warped
;
694 else if (Keyboard
[sc_X
]) // X = item cheat
697 US_PrintCentered ("Extra stuff!");
699 // DEBUG: put stuff here
704 else if(Keyboard
[sc_Z
])
710 US_Print(" Recalculate sky with seek: ");
711 int seekpx
= px
, seekpy
= py
;
712 US_PrintUnsigned(curSky
->seed
);
713 US_Print("\n Use color map (0-");
714 US_PrintUnsigned(numColorMaps
- 1);
716 int mappx
= px
, mappy
= py
;
717 US_PrintUnsigned(curSky
->colorMapIndex
);
720 sprintf(defstr
, "%u", curSky
->seed
);
721 esc
= !US_LineInput(seekpx
, seekpy
, str
, defstr
, true, 10, 0);
723 curSky
->seed
= (uint32_t) atoi(str
);
725 sprintf(defstr
, "%u", curSky
->colorMapIndex
);
726 esc
= !US_LineInput(mappx
, mappy
, str
, defstr
, true, 10, 0);
728 uint32_t newInd
= (uint32_t) atoi(str
);
729 if(newInd
< (uint32_t) numColorMaps
)
731 curSky
->colorMapIndex
= newInd
;
737 US_PrintCentered ("Illegal color map!");
757 void OverheadRefresh (void)
759 unsigned x
,y
,endx
,endy
,sx
,sy
;
763 endx
= maporgx
+VIEWTILEX
;
764 endy
= maporgy
+VIEWTILEY
;
766 for (y
=maporgy
;y
<endy
;y
++)
768 for (x
=maporgx
;x
<endx
;x
++)
777 tile
= *(mapsegs
[0]+farmapylookup
[y
]+x
);
781 tile
= tilemap
[x
][y
];
785 tile
= spotvis
[x
][y
];
789 tile
= (unsigned)actorat
[x
][y
];
793 if (tile
<MAXWALLTILES
)
794 LatchDrawTile(sx
,sy
,tile
);
797 LatchDrawChar(sx
,sy
,NUMBERCHARS
+((tile
&0xf000)>>12));
798 LatchDrawChar(sx
+8,sy
,NUMBERCHARS
+((tile
&0x0f00)>>8));
799 LatchDrawChar(sx
,sy
+8,NUMBERCHARS
+((tile
&0x00f0)>>4));
800 LatchDrawChar(sx
+8,sy
+8,NUMBERCHARS
+(tile
&0x000f));
820 viewtype
= actoratview
;
821 // button0held = false;
824 maporgx
= player
->tilex
- VIEWTILEX
/2;
827 if (maporgx
>MAPSIZE
-VIEWTILEX
)
828 maporgx
=MAPSIZE
-VIEWTILEX
;
829 maporgy
= player
->tiley
- VIEWTILEY
/2;
832 if (maporgy
>MAPSIZE
-VIEWTILEY
)
833 maporgy
=MAPSIZE
-VIEWTILEY
;
838 // let user pan around
841 if (controlx
< 0 && maporgx
>0)
843 if (controlx
> 0 && maporgx
<mapwidth
-VIEWTILEX
)
845 if (controly
< 0 && maporgy
>0)
847 if (controly
> 0 && maporgy
<mapheight
-VIEWTILEY
)
851 if (c
.button0
&& !button0held
)
855 if (viewtype
>visview
)
864 } while (!Keyboard
[sc_Escape
]);