summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
committerKarl Kurbjun <kkurbjun@gmail.com>2006-04-02 01:52:44 +0000
commit51db2d3f2cfddfb1c94de1085d130c817bcd953f (patch)
treea8452577070b7febf0ec640d2a065cd7e2c89847 /apps
parente61b079c26e5eaa12f403da6964ac20282df248e (diff)
downloadrockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.tar.gz
rockbox-51db2d3f2cfddfb1c94de1085d130c817bcd953f.zip
Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9418 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/plugins/doom/d_main.c20
-rw-r--r--apps/plugins/doom/doomdef.h6
-rw-r--r--apps/plugins/doom/i_system.c7
-rw-r--r--apps/plugins/doom/i_video.c96
-rw-r--r--apps/plugins/doom/r_bsp.c104
-rw-r--r--apps/plugins/doom/r_bsp.h20
-rw-r--r--apps/plugins/doom/r_data.c151
-rw-r--r--apps/plugins/doom/r_data.h6
-rw-r--r--apps/plugins/doom/r_defs.h112
-rw-r--r--apps/plugins/doom/r_draw.c53
-rw-r--r--apps/plugins/doom/r_main.c36
-rw-r--r--apps/plugins/doom/r_main.h2
-rw-r--r--apps/plugins/doom/r_plane.c20
-rw-r--r--apps/plugins/doom/r_segs.c58
-rw-r--r--apps/plugins/doom/r_things.c259
-rw-r--r--apps/plugins/doom/r_things.h112
-rw-r--r--apps/plugins/doom/rockdoom.c20
-rw-r--r--apps/plugins/doom/v_video.c24
18 files changed, 569 insertions, 537 deletions
diff --git a/apps/plugins/doom/d_main.c b/apps/plugins/doom/d_main.c
index 0b4f80f18f..2c03752abe 100644
--- a/apps/plugins/doom/d_main.c
+++ b/apps/plugins/doom/d_main.c
@@ -629,35 +629,35 @@ void D_DoomMainSetup(void)
629 else if (M_CheckParm ("-deathmatch")) 629 else if (M_CheckParm ("-deathmatch"))
630 deathmatch = 1; 630 deathmatch = 1;
631 631
632 printf("Welcome to Rockdoom"); 632 printf("Welcome to Rockdoom\n");
633 633
634 switch ( gamemode ) 634 switch ( gamemode )
635 { 635 {
636 case retail: 636 case retail:
637 printf ("The Ultimate DOOM Startup v%d.%d",DVERSION/100,DVERSION%100); 637 printf ("The Ultimate DOOM Startup v%d.%d\n",DVERSION/100,DVERSION%100);
638 break; 638 break;
639 case shareware: 639 case shareware:
640 printf ("DOOM Shareware Startup v%d.%d",DVERSION/100,DVERSION%100); 640 printf ("DOOM Shareware Startup v%d.%d\n",DVERSION/100,DVERSION%100);
641 break; 641 break;
642 case registered: 642 case registered:
643 printf ("DOOM Registered Startup v%d.%d",DVERSION/100,DVERSION%100); 643 printf ("DOOM Registered Startup v%d.%d\n",DVERSION/100,DVERSION%100);
644 break; 644 break;
645 case commercial: 645 case commercial:
646 switch (gamemission) 646 switch (gamemission)
647 { 647 {
648 case pack_plut: 648 case pack_plut:
649 printf ("DOOM 2: Plutonia Experiment v%d.%d",DVERSION/100,DVERSION%100); 649 printf ("DOOM 2: Plutonia Experiment v%d.%d\n",DVERSION/100,DVERSION%100);
650 break; 650 break;
651 case pack_tnt: 651 case pack_tnt:
652 printf ("DOOM 2: TNT - Evilution v%d.%d",DVERSION/100,DVERSION%100); 652 printf ("DOOM 2: TNT - Evilution v%d.%d\n",DVERSION/100,DVERSION%100);
653 break; 653 break;
654 default: 654 default:
655 printf ("DOOM 2: Hell on Earth v%d.%d",DVERSION/100,DVERSION%100); 655 printf ("DOOM 2: Hell on Earth v%d.%d\n",DVERSION/100,DVERSION%100);
656 break; 656 break;
657 } 657 }
658 break; 658 break;
659 default: 659 default:
660 printf ("Public DOOM v%d.%d",DVERSION/100,DVERSION%100); 660 printf ("Public DOOM v%d.%d\n",DVERSION/100,DVERSION%100);
661 break; 661 break;
662 } 662 }
663 663
@@ -745,14 +745,14 @@ void D_DoomMainSetup(void)
745 int i; 745 int i;
746 746
747 if ( gamemode == shareware) 747 if ( gamemode == shareware)
748 I_Error("\nYou cannot -file with the shareware version. Register!"); 748 I_Error("\nYou cannot -file with the shareware version. Register!\n");
749 749
750 // Check for fake IWAD with right name, 750 // Check for fake IWAD with right name,
751 // but w/o all the lumps of the registered version. 751 // but w/o all the lumps of the registered version.
752 if (gamemode == registered) 752 if (gamemode == registered)
753 for (i = 0;i < 23; i++) 753 for (i = 0;i < 23; i++)
754 if (W_CheckNumForName(name[i])<0) 754 if (W_CheckNumForName(name[i])<0)
755 I_Error("\nThis is not the registered version."); 755 I_Error("This is not the registered version.\n");
756 } 756 }
757 757
758 // Iff additonal PWAD files are used, print modified banner 758 // Iff additonal PWAD files are used, print modified banner
diff --git a/apps/plugins/doom/doomdef.h b/apps/plugins/doom/doomdef.h
index f76b09263a..1910e7c48a 100644
--- a/apps/plugins/doom/doomdef.h
+++ b/apps/plugins/doom/doomdef.h
@@ -92,8 +92,10 @@ typedef enum {
92#define MAX_SCREENWIDTH 1600 92#define MAX_SCREENWIDTH 1600
93#define MAX_SCREENHEIGHT 1200 93#define MAX_SCREENHEIGHT 1200
94 94
95#define SCREENWIDTH 320 95#define SCREENWIDTH LCD_WIDTH
96#define SCREENHEIGHT 200 96//#define SCREENWIDTH 320
97//#define SCREENHEIGHT 200
98#define SCREENHEIGHT LCD_HEIGHT
97 99
98// The maximum number of players, multiplayer/networking. 100// The maximum number of players, multiplayer/networking.
99#define MAXPLAYERS 4 101#define MAXPLAYERS 4
diff --git a/apps/plugins/doom/i_system.c b/apps/plugins/doom/i_system.c
index 1e564054f8..ad1001cf8b 100644
--- a/apps/plugins/doom/i_system.c
+++ b/apps/plugins/doom/i_system.c
@@ -16,7 +16,10 @@
16// GNU General Public License for more details. 16// GNU General Public License for more details.
17// 17//
18// $Log$ 18// $Log$
19// Revision 1.1 2006/03/28 15:44:01 dave 19// Revision 1.2 2006/04/02 01:52:44 kkurbjun
20// Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
21//
22// Revision 1.1 2006-03-28 15:44:01 dave
20// Patch #2969 - Doom! Currently only working on the H300. 23// Patch #2969 - Doom! Currently only working on the H300.
21// 24//
22// 25//
@@ -120,7 +123,7 @@ void I_Error (char *error, ...)
120 vsnprintf(p_buf,sizeof(p_buf), error, ap); 123 vsnprintf(p_buf,sizeof(p_buf), error, ap);
121 va_end(ap); 124 va_end(ap);
122 125
123 printf("%s",p_buf); 126 printf("%s\n",p_buf);
124 127
125 // Shutdown. Here might be other errors. 128 // Shutdown. Here might be other errors.
126 if (demorecording) 129 if (demorecording)
diff --git a/apps/plugins/doom/i_video.c b/apps/plugins/doom/i_video.c
index 1bfbf93ce8..b7dbd2bcf5 100644
--- a/apps/plugins/doom/i_video.c
+++ b/apps/plugins/doom/i_video.c
@@ -16,7 +16,10 @@
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * $Log$ 18 * $Log$
19 * Revision 1.2 2006/03/28 17:20:49 christian 19 * Revision 1.3 2006/04/02 01:52:44 kkurbjun
20 * Update adds prboom's high resolution support, also makes the scaling for platforms w/ resolution less then 320x200 much nicer. IDoom's lookup table code has been removed. Also fixed a pallete bug. Some graphic errors are present in menu and status bar. Also updates some headers and output formatting.
21 *
22 * Revision 1.2 2006-03-28 17:20:49 christian
20 * added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD 23 * added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD
21 * 24 *
22 * Revision 1.1 2006-03-28 15:44:01 dave 25 * Revision 1.1 2006-03-28 15:44:01 dave
@@ -40,51 +43,12 @@
40#include "doomdef.h" 43#include "doomdef.h"
41 44
42#include "rockmacros.h" 45#include "rockmacros.h"
43 46#if defined(CPU_COLDFIRE)
47static char fastscreen[LCD_WIDTH*LCD_HEIGHT] IBSS_ATTR;
48#endif
44static fb_data palette[256] IBSS_ATTR; 49static fb_data palette[256] IBSS_ATTR;
45static fb_data *paldata=NULL; 50static fb_data *paldata=NULL;
46 51
47#if !defined(CPU_COLDFIRE) || defined(SIMULATOR)
48/*
49 This code is credit to the IDOOM port. It is not used for the H300, but
50 serves as a good reference point for other targets.
51*/
52static fb_data * xtable = 0;
53static fb_data * ytable1 = 0;
54static fb_data * ytable2 = 0;
55
56#define FLOOR4(a) \
57 (( a >> 2) << 2)
58
59static int video_w, video_h;
60
61static void genscalexytable(void)
62{
63 // shall we use uint8_t intead of ints?
64 int y = video_h-1;
65 int x = video_w-1;
66 int i = 1 + (x>y?x:y);
67 xtable = malloc(sizeof(int)*video_w );
68 ytable1 = malloc(sizeof(int)*video_h );
69 ytable2 = malloc(sizeof(int)*video_h );
70
71 while(i--)
72 {
73 if(y>=0)
74 {
75 ytable1[y] = ((y*SCREENHEIGHT) / video_h) * SCREENWIDTH;
76 ytable2[y] = y*video_w;
77 y--;
78 }
79 if(x>=0)
80 {
81 xtable[x] = (x*SCREENWIDTH) / video_w;
82 x--;
83 }
84 }
85}
86#endif
87
88// 52//
89// I_ShutdownGraphics (NOT USED) 53// I_ShutdownGraphics (NOT USED)
90// 54//
@@ -360,9 +324,7 @@ void I_FinishUpdate (void)
360{ 324{
361#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 325#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
362 /* 326 /*
363 Faster screen update than the lookuptables -> I'm wasting 7 pixels of width 327 Lookup tables are no longer needed
364 though. This code also doesn't use the framebuffer so rockbox's drawing
365 functions will not work on top of the doom drawing.
366 */ 328 */
367 329
368 // Start the write 330 // Start the write
@@ -373,51 +335,27 @@ void I_FinishUpdate (void)
373 unsigned char *screenptr=screens[0]; 335 unsigned char *screenptr=screens[0];
374 int wcnt=0, hcnt=0; 336 int wcnt=0, hcnt=0;
375 337
376 *(volatile unsigned short *) 0xf0000002 = 0;
377 *(volatile unsigned short *) 0xf0000002 = 0;
378 *(volatile unsigned short *) 0xf0000002 = 0;
379
380 while(hcnt<LCD_HEIGHT) 338 while(hcnt<LCD_HEIGHT)
381 { 339 {
382 while(wcnt<LCD_WIDTH-7) 340 while(wcnt<LCD_WIDTH)
383 { 341 {
384 if((wcnt&0x01))
385 screenptr++; // Skip every so many pixels in Doom buffer
386 *(volatile unsigned short *)0xf0000002 = palette[*screenptr]; 342 *(volatile unsigned short *)0xf0000002 = palette[*screenptr];
387 screenptr++; 343 screenptr++;
388 wcnt++; 344 wcnt++;
389 } 345 }
390 screenptr++;
391 // move on past those 7 pixels
392 *(volatile unsigned short *) 0xf0000002 = 0;
393 *(volatile unsigned short *) 0xf0000002 = 0;
394 *(volatile unsigned short *) 0xf0000002 = 0;
395 *(volatile unsigned short *) 0xf0000002 = 0;
396 *(volatile unsigned short *) 0xf0000002 = 0;
397 *(volatile unsigned short *) 0xf0000002 = 0;
398 *(volatile unsigned short *) 0xf0000002 = 0;
399 wcnt=0; 346 wcnt=0;
400 hcnt++; 347 hcnt++;
401 if((hcnt&0x07)==0x07)
402 screenptr+=SCREENWIDTH; // Skip every 7th line
403 } 348 }
404#else 349#else
405 // The IDOOM code for screen updates
406 unsigned char paletteIndex; 350 unsigned char paletteIndex;
407 int x, y; 351 int x, y;
408 352
409 for (y = 0; y < video_h; y++) 353 for (y = 0; y < LCD_HEIGHT; y++)
410 { 354 {
411 for (x = 0; x < video_w; x++) 355 for (x = 0; x < LCD_WIDTH; x++)
412 { 356 {
413#if LCD_HEIGHT >= SCREENHEIGHT 357 paletteIndex = screens[0][y*SCREENWIDTH + x];
414 paletteIndex = screens[0][((y*SCREENHEIGHT) / video_h) 358 rb->lcd_framebuffer[y * LCD_WIDTH + x] = palette[paletteIndex];
415 * SCREENWIDTH + x];
416 rb->lcd_framebuffer[y * video_w + x] = palette[paletteIndex];
417#else
418 paletteIndex = screens[0][ytable1[y] +xtable[x]];
419 rb->lcd_framebuffer[x + ytable2[y]] = palette[paletteIndex];
420#endif
421 } 359 }
422 } 360 }
423 rb->lcd_update(); 361 rb->lcd_update();
@@ -454,14 +392,12 @@ void I_InitGraphics(void)
454 printf("Starting Graphics engine\n"); 392 printf("Starting Graphics engine\n");
455 393
456 /* Note: The other screens are initialized later */ 394 /* Note: The other screens are initialized later */
457 screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char));
458 395
459#if defined(CPU_COLDFIRE) && !defined(SIMULATOR) 396#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
460 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); 397 coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE);
398 screens[0] = fastscreen;
461#else 399#else
462 400 // Don't know if this will fit in other IRAMs
463 video_h = LCD_HEIGHT; 401 screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char));
464 video_w = FLOOR4(LCD_WIDTH); // From IDOOM, the width has to be a multiple of 4
465 genscalexytable();
466#endif 402#endif
467} 403}
diff --git a/apps/plugins/doom/r_bsp.c b/apps/plugins/doom/r_bsp.c
index 358787dc58..e6ce74c029 100644
--- a/apps/plugins/doom/r_bsp.c
+++ b/apps/plugins/doom/r_bsp.c
@@ -29,21 +29,14 @@
29 * 29 *
30 *-----------------------------------------------------------------------------*/ 30 *-----------------------------------------------------------------------------*/
31 31
32#include "doomdef.h" 32#include "doomstat.h"
33
34#include "m_bbox.h" 33#include "m_bbox.h"
35
36#include "i_system.h" 34#include "i_system.h"
37
38#include "r_main.h" 35#include "r_main.h"
36#include "r_segs.h"
39#include "r_plane.h" 37#include "r_plane.h"
40#include "r_things.h" 38#include "r_things.h"
41 39#include "r_bsp.h" // cph - sanity checking
42// State.
43#include "doomstat.h"
44#include "r_state.h"
45#include "r_segs.h"
46#include "rockmacros.h"
47 40
48seg_t *curline; 41seg_t *curline;
49side_t *sidedef; 42side_t *sidedef;
@@ -52,14 +45,19 @@ sector_t *frontsector;
52sector_t *backsector; 45sector_t *backsector;
53drawseg_t *ds_p; 46drawseg_t *ds_p;
54 47
48// killough 4/7/98: indicates doors closed wrt automap bugfix:
49// cph - replaced by linedef rendering flags - int doorclosed;
55 50
51// killough: New code which removes 2s linedef limit
56drawseg_t *drawsegs; 52drawseg_t *drawsegs;
57unsigned maxdrawsegs; 53unsigned maxdrawsegs;
54// drawseg_t drawsegs[MAXDRAWSEGS]; // old code -- killough
58 55
59// 56//
60// R_ClearDrawSegs 57// R_ClearDrawSegs
61// 58//
62void R_ClearDrawSegs (void) 59
60void R_ClearDrawSegs(void)
63{ 61{
64 ds_p = drawsegs; 62 ds_p = drawsegs;
65} 63}
@@ -79,16 +77,24 @@ byte solidcol[SCREENWIDTH] IBSS_ATTR;
79void R_ClipWallSegment(int first, int last, boolean solid) 77void R_ClipWallSegment(int first, int last, boolean solid)
80{ 78{
81 byte *p; 79 byte *p;
82 while (first < last) { 80 while (first < last)
83 if (solidcol[first]) { 81 {
84 if (!(p = memchr(solidcol+first, 0, last-first))) return; // All solid 82 if (solidcol[first])
83 {
84 if (!(p = memchr(solidcol+first, 0, last-first)))
85 return; // All solid
85 first = p - solidcol; 86 first = p - solidcol;
86 } else { 87 }
88 else
89 {
87 int to; 90 int to;
88 if (!(p = memchr(solidcol+first, 1, last-first))) to = last; 91 if (!(p = memchr(solidcol+first, 1, last-first)))
89 else to = p - solidcol; 92 to = last;
93 else
94 to = p - solidcol;
90 R_StoreWallRange(first, to-1); 95 R_StoreWallRange(first, to-1);
91 if (solid) { 96 if (solid)
97 {
92 memset(solidcol+first,1,to-first); 98 memset(solidcol+first,1,to-first);
93 } 99 }
94 first = to; 100 first = to;
@@ -136,7 +142,8 @@ static void R_RecalcLineFlags(void)
136 ) 142 )
137 ) 143 )
138 linedef->r_flags = RF_CLOSED; 144 linedef->r_flags = RF_CLOSED;
139 else { 145 else
146 {
140 // Reject empty lines used for triggers 147 // Reject empty lines used for triggers
141 // and special events. 148 // and special events.
142 // Identical floor and ceiling on both sides, 149 // Identical floor and ceiling on both sides,
@@ -151,17 +158,22 @@ static void R_RecalcLineFlags(void)
151 sizeof(frontsector->ceiling_xoffs) + sizeof(frontsector->ceiling_yoffs) + 158 sizeof(frontsector->ceiling_xoffs) + sizeof(frontsector->ceiling_yoffs) +
152 sizeof(frontsector->ceilingpic) + sizeof(frontsector->floorpic) + 159 sizeof(frontsector->ceilingpic) + sizeof(frontsector->floorpic) +
153 sizeof(frontsector->lightlevel) + sizeof(frontsector->floorlightsec) + 160 sizeof(frontsector->lightlevel) + sizeof(frontsector->floorlightsec) +
154 sizeof(frontsector->ceilinglightsec))) { 161 sizeof(frontsector->ceilinglightsec)))
155 linedef->r_flags = 0; return; 162 {
156 } else 163 linedef->r_flags = 0;
164 return;
165 }
166 else
157 linedef->r_flags = RF_IGNORE; 167 linedef->r_flags = RF_IGNORE;
158 } 168 }
159 169
160 /* cph - I'm too lazy to try and work with offsets in this */ 170 /* cph - I'm too lazy to try and work with offsets in this */
161 if (curline->sidedef->rowoffset) return; 171 if (curline->sidedef->rowoffset)
172 return;
162 173
163 /* Now decide on texture tiling */ 174 /* Now decide on texture tiling */
164 if (linedef->flags & ML_TWOSIDED) { 175 if (linedef->flags & ML_TWOSIDED)
176 {
165 int c; 177 int c;
166 178
167 /* Does top texture need tiling */ 179 /* Does top texture need tiling */
@@ -173,7 +185,9 @@ static void R_RecalcLineFlags(void)
173 if ((c = frontsector->floorheight - backsector->floorheight) > 0 && 185 if ((c = frontsector->floorheight - backsector->floorheight) > 0 &&
174 (textureheight[texturetranslation[curline->sidedef->bottomtexture]] > c)) 186 (textureheight[texturetranslation[curline->sidedef->bottomtexture]] > c))
175 linedef->r_flags |= RF_BOT_TILE; 187 linedef->r_flags |= RF_BOT_TILE;
176 } else { 188 }
189 else
190 {
177 int c; 191 int c;
178 /* Does middle texture need tiling */ 192 /* Does middle texture need tiling */
179 if ((c = frontsector->ceilingheight - frontsector->floorheight) > 0 && 193 if ((c = frontsector->ceilingheight - frontsector->floorheight) > 0 &&
@@ -228,13 +242,17 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec,
228 tempsec->floor_xoffs = s->floor_xoffs; 242 tempsec->floor_xoffs = s->floor_xoffs;
229 tempsec->floor_yoffs = s->floor_yoffs; 243 tempsec->floor_yoffs = s->floor_yoffs;
230 244
231 if (underwater) { 245 if (underwater)
232 if (s->ceilingpic == skyflatnum) { 246 {
247 if (s->ceilingpic == skyflatnum)
248 {
233 tempsec->floorheight = tempsec->ceilingheight+1; 249 tempsec->floorheight = tempsec->ceilingheight+1;
234 tempsec->ceilingpic = tempsec->floorpic; 250 tempsec->ceilingpic = tempsec->floorpic;
235 tempsec->ceiling_xoffs = tempsec->floor_xoffs; 251 tempsec->ceiling_xoffs = tempsec->floor_xoffs;
236 tempsec->ceiling_yoffs = tempsec->floor_yoffs; 252 tempsec->ceiling_yoffs = tempsec->floor_yoffs;
237 } else { 253 }
254 else
255 {
238 tempsec->ceilingpic = s->ceilingpic; 256 tempsec->ceilingpic = s->ceilingpic;
239 tempsec->ceiling_xoffs = s->ceiling_xoffs; 257 tempsec->ceiling_xoffs = s->ceiling_xoffs;
240 tempsec->ceiling_yoffs = s->ceiling_yoffs; 258 tempsec->ceiling_yoffs = s->ceiling_yoffs;
@@ -384,7 +402,8 @@ static void R_AddLine (seg_t *line)
384 402
385static const int checkcoord[12][4] = // killough -- static const 403static const int checkcoord[12][4] = // killough -- static const
386 { 404 {
387 {3,0,2,1}, 405 {
406 3,0,2,1},
388 {3,0,2,0}, 407 {3,0,2,0},
389 {3,1,2,0}, 408 {3,1,2,0},
390 {0}, 409 {0},
@@ -421,7 +440,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
421 440
422 // cph - replaced old code, which was unclear and badly commented 441 // cph - replaced old code, which was unclear and badly commented
423 // Much more efficient code now 442 // Much more efficient code now
424 if ((signed)angle1 < (signed)angle2) { /* it's "behind" us */ 443 if ((signed)angle1 < (signed)angle2)
444 { /* it's "behind" us */
425 /* Either angle1 or angle2 is behind us, so it doesn't matter if we 445 /* Either angle1 or angle2 is behind us, so it doesn't matter if we
426 * change it to the corect sign 446 * change it to the corect sign
427 */ 447 */
@@ -431,10 +451,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
431 angle2 = INT_MIN; 451 angle2 = INT_MIN;
432 } 452 }
433 453
434 if ((signed)angle2 >= (signed)clipangle) return false; // Both off left edge 454 if ((signed)angle2 >= (signed)clipangle)
435 if ((signed)angle1 <= -(signed)clipangle) return false; // Both off right edge 455 return false; // Both off left edge
436 if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle; // Clip at left edge 456 if ((signed)angle1 <= -(signed)clipangle)
437 if ((signed)angle2 <= -(signed)clipangle) angle2 = 0-clipangle; // Clip at right edge 457 return false; // Both off right edge
458 if ((signed)angle1 >= (signed)clipangle)
459 angle1 = clipangle; // Clip at left edge
460 if ((signed)angle2 <= -(signed)clipangle)
461 angle2 = 0-clipangle; // Clip at right edge
438 462
439 // Find the first clippost 463 // Find the first clippost
440 // that touches the source post 464 // that touches the source post
@@ -450,7 +474,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord)
450 if (sx1 == sx2) 474 if (sx1 == sx2)
451 return false; 475 return false;
452 476
453 if (!memchr(solidcol+sx1, 0, sx2-sx1)) return false; 477 if (!memchr(solidcol+sx1, 0, sx2-sx1))
478 return false;
454 // All columns it covers are already solidly covered 479 // All columns it covers are already solidly covered
455 } 480 }
456 481
@@ -477,6 +502,7 @@ static void R_Subsector(int num)
477 int ceilinglightlevel; // killough 4/11/98 502 int ceilinglightlevel; // killough 4/11/98
478 503
479#ifdef RANGECHECK 504#ifdef RANGECHECK
505
480 if (num>=numsubsectors) 506 if (num>=numsubsectors)
481 I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors); 507 I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors);
482#endif 508#endif
@@ -485,7 +511,7 @@ static void R_Subsector(int num)
485 frontsector = sub->sector; 511 frontsector = sub->sector;
486 count = sub->numlines; 512 count = sub->numlines;
487 line = &segs[sub->firstline]; 513 line = &segs[sub->firstline];
488// sscount++; 514 // sscount++;
489 515
490 // killough 3/8/98, 4/4/98: Deep water / fake ceiling effect 516 // killough 3/8/98, 4/4/98: Deep water / fake ceiling effect
491 frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel, 517 frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel,
@@ -497,8 +523,7 @@ static void R_Subsector(int num)
497 523
498 floorplane = frontsector->floorheight < viewz || // killough 3/7/98 524 floorplane = frontsector->floorheight < viewz || // killough 3/7/98
499 (frontsector->heightsec != -1 && 525 (frontsector->heightsec != -1 &&
500 sectors[frontsector->heightsec].ceilingpic == skyflatnum) 526 sectors[frontsector->heightsec].ceilingpic == skyflatnum) ?
501 ?
502 R_FindPlane(frontsector->floorheight, 527 R_FindPlane(frontsector->floorheight,
503 frontsector->floorpic == skyflatnum && // kilough 10/98 528 frontsector->floorpic == skyflatnum && // kilough 10/98
504 frontsector->sky & PL_SKYFLAT ? frontsector->sky : 529 frontsector->sky & PL_SKYFLAT ? frontsector->sky :
@@ -511,8 +536,7 @@ static void R_Subsector(int num)
511 ceilingplane = frontsector->ceilingheight > viewz || 536 ceilingplane = frontsector->ceilingheight > viewz ||
512 frontsector->ceilingpic == skyflatnum || 537 frontsector->ceilingpic == skyflatnum ||
513 (frontsector->heightsec != -1 && 538 (frontsector->heightsec != -1 &&
514 sectors[frontsector->heightsec].floorpic == skyflatnum) 539 sectors[frontsector->heightsec].floorpic == skyflatnum) ?
515 ?
516 R_FindPlane(frontsector->ceilingheight, // killough 3/8/98 540 R_FindPlane(frontsector->ceilingheight, // killough 3/8/98
517 frontsector->ceilingpic == skyflatnum && // kilough 10/98 541 frontsector->ceilingpic == skyflatnum && // kilough 10/98
518 frontsector->sky & PL_SKYFLAT ? frontsector->sky : 542 frontsector->sky & PL_SKYFLAT ? frontsector->sky :
diff --git a/apps/plugins/doom/r_bsp.h b/apps/plugins/doom/r_bsp.h
index 2ea653833d..72fb0b63e7 100644
--- a/apps/plugins/doom/r_bsp.h
+++ b/apps/plugins/doom/r_bsp.h
@@ -29,7 +29,6 @@
29 * 29 *
30 *-----------------------------------------------------------------------------*/ 30 *-----------------------------------------------------------------------------*/
31 31
32
33#ifndef __R_BSP__ 32#ifndef __R_BSP__
34#define __R_BSP__ 33#define __R_BSP__
35 34
@@ -48,28 +47,17 @@ extern boolean segtextured;
48extern boolean markfloor; /* false if the back side is the same plane */ 47extern boolean markfloor; /* false if the back side is the same plane */
49extern boolean markceiling; 48extern boolean markceiling;
50 49
51//extern boolean skymap;
52
53/* old code -- killough: 50/* old code -- killough:
54 * extern drawseg_t drawsegs[MAXDRAWSEGS]; 51 * extern drawseg_t drawsegs[MAXDRAWSEGS];
55 * new code -- killough: */ 52 * new code -- killough: */
56extern drawseg_t *drawsegs; 53extern drawseg_t *drawsegs;
57extern unsigned maxdrawsegs; 54extern unsigned maxdrawsegs;
58 55
59extern drawseg_t* ds_p; 56extern drawseg_t *ds_p;
60
61/*extern lighttable_t** hscalelight;
62extern lighttable_t** vscalelight;
63extern lighttable_t** dscalelight;
64*/
65
66//typedef void (*drawfunc_t) (int start, int stop);
67
68 57
69// BSP? 58void R_ClearClipSegs(void);
70void R_ClearClipSegs (void); 59void R_ClearDrawSegs(void);
71void R_ClearDrawSegs (void); 60void R_RenderBSPNode(int bspnum);
72void R_RenderBSPNode (int bspnum);
73int R_DoorClosed(void); /* killough 1/17/98 */ 61int R_DoorClosed(void); /* killough 1/17/98 */
74 62
75/* killough 4/13/98: fake floors/ceilings for deep water / fake ceilings: */ 63/* killough 4/13/98: fake floors/ceilings for deep water / fake ceilings: */
diff --git a/apps/plugins/doom/r_data.c b/apps/plugins/doom/r_data.c
index aad16e4d95..1d5c6ad272 100644
--- a/apps/plugins/doom/r_data.c
+++ b/apps/plugins/doom/r_data.c
@@ -63,7 +63,8 @@ typedef struct
63 short patch; 63 short patch;
64 short stepdir; // unused in Doom but might be used in Phase 2 Boom 64 short stepdir; // unused in Doom but might be used in Phase 2 Boom
65 short colormap; // unused in Doom but might be used in Phase 2 Boom 65 short colormap; // unused in Doom but might be used in Phase 2 Boom
66} PACKEDATTR mappatch_t; 66}
67PACKEDATTR mappatch_t;
67 68
68typedef struct 69typedef struct
69{ 70{
@@ -74,7 +75,8 @@ typedef struct
74 char pad[4]; // unused in Doom but might be used in Boom Phase 2 75 char pad[4]; // unused in Doom but might be used in Boom Phase 2
75 short patchcount; 76 short patchcount;
76 mappatch_t patches[1]; 77 mappatch_t patches[1];
77} PACKEDATTR maptexture_t; 78}
79PACKEDATTR maptexture_t;
78 80
79// A maptexturedef_t describes a rectangular texture, which is composed 81// A maptexturedef_t describes a rectangular texture, which is composed
80// of one or more mappatch_t structures that arrange graphic patches. 82// of one or more mappatch_t structures that arrange graphic patches.
@@ -247,7 +249,8 @@ static void R_GenerateLookup(int texnum, int *const errors)
247 249
248 struct { 250 struct {
249 unsigned short patches, posts; 251 unsigned short patches, posts;
250 } *count = calloc(sizeof *count, texture->width); 252 }
253 *count = calloc(sizeof *count, texture->width);
251 254
252 { 255 {
253 int i = texture->patchcount; 256 int i = texture->patchcount;
@@ -300,9 +303,11 @@ static void R_GenerateLookup(int texnum, int *const errors)
300 { 303 {
301 //jff 8/3/98 use logical output routine 304 //jff 8/3/98 use logical output routine
302 printf("\nR_GenerateLookup: Column %d is without a patch in texture %s", 305 printf("\nR_GenerateLookup: Column %d is without a patch in texture %s",
303 x, texture->name); 306 x, texture->name);
304 if (errors) ++*errors; 307 if (errors)
305 else I_Error("R_GenerateLookup: Failed"); 308 ++*errors;
309 else
310 I_Error("R_GenerateLookup: Failed");
306 } 311 }
307 if (count[x].patches > 1) // killough 4/9/98 312 if (count[x].patches > 1) // killough 4/9/98
308 { 313 {
@@ -333,7 +338,8 @@ static void R_GenerateLookup(int texnum, int *const errors)
333const byte *R_GetColumn(int tex, int col) 338const byte *R_GetColumn(int tex, int col)
334{ 339{
335 const texture_t *texture = textures[tex]; 340 const texture_t *texture = textures[tex];
336 if (!texture->columnlump) R_GenerateLookup(tex, NULL); 341 if (!texture->columnlump)
342 R_GenerateLookup(tex, NULL);
337 { 343 {
338 int lump = texture->columnlump[col &= texture->widthmask]; 344 int lump = texture->columnlump[col &= texture->widthmask];
339 int ofs = texture->columnofs[col]; // cph - WARNING: must be after the above line 345 int ofs = texture->columnofs[col]; // cph - WARNING: must be after the above line
@@ -345,7 +351,8 @@ const byte *R_GetColumn(int tex, int col)
345 if ((lump<=0) && (lastlump<=0)) 351 if ((lump<=0) && (lastlump<=0))
346 lump = lastlump; // cph - force equal 352 lump = lastlump; // cph - force equal
347 353
348 if (lump != lastlump) { 354 if (lump != lastlump)
355 {
349 // cph - must change the cached lump 356 // cph - must change the cached lump
350 if (lastlump>0) 357 if (lastlump>0)
351 W_UnlockLumpNum(lastlump); 358 W_UnlockLumpNum(lastlump);
@@ -353,9 +360,11 @@ const byte *R_GetColumn(int tex, int col)
353 if ((lastlump = lump) > 0) 360 if ((lastlump = lump) > 0)
354 lastlumpdata = W_CacheLumpNum(lump); 361 lastlumpdata = W_CacheLumpNum(lump);
355#ifdef RANGECHECK 362#ifdef RANGECHECK
363
356 else 364 else
357 lastlumpdata = NULL; 365 lastlumpdata = NULL;
358#endif 366#endif
367
359 } 368 }
360 369
361 if (lump > 0) 370 if (lump > 0)
@@ -533,12 +542,13 @@ void R_InitTextures (void)
533 { 542 {
534 //jff 8/3/98 use logical output routine 543 //jff 8/3/98 use logical output routine
535 printf("\nR_InitTextures: Missing patch %d in texture %s", 544 printf("\nR_InitTextures: Missing patch %d in texture %s",
536 SHORT(mpatch->patch), texture->name); // killough 4/17/98 545 SHORT(mpatch->patch), texture->name); // killough 4/17/98
537 ++errors; 546 ++errors;
538 } 547 }
539 } 548 }
540 549
541 texture->columnofs = NULL; texture->columnlump = NULL; 550 texture->columnofs = NULL;
551 texture->columnlump = NULL;
542 552
543 for (j=1; j*2 <= texture->width; j<<=1) 553 for (j=1; j*2 <= texture->width; j<<=1)
544 ; 554 ;
@@ -687,7 +697,8 @@ int R_ColormapNumForName(const char *name)
687struct _cache { 697struct _cache {
688 unsigned char pct; 698 unsigned char pct;
689 unsigned char playpal[256]; 699 unsigned char playpal[256];
690} cache; 700}
701cache;
691 702
692int tran_filter_pct = 66; // filter percent 703int tran_filter_pct = 66; // filter percent
693 704
@@ -712,10 +723,10 @@ void R_InitTranMap(int progress)
712 // Use cached translucency filter if it's available 723 // Use cached translucency filter if it's available
713 724
714 if ((cachefd<0) ? cachefd = open(GAMEBASE"tranmap.dat",O_WRONLY | O_CREAT) , 1 : 725 if ((cachefd<0) ? cachefd = open(GAMEBASE"tranmap.dat",O_WRONLY | O_CREAT) , 1 :
715 read(cachefd, &cache, sizeof(cache)) != sizeof(cache) || 726 read(cachefd, &cache, sizeof(cache)) != sizeof(cache) ||
716 cache.pct != tran_filter_pct || 727 cache.pct != tran_filter_pct ||
717 memcmp(cache.playpal, playpal, sizeof cache.playpal) || 728 memcmp(cache.playpal, playpal, sizeof cache.playpal) ||
718 read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98 729 read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98
719 { 730 {
720 731
721 long *stackdeath=malloc(256*7*sizeof(long)); // This was a bunch of static varibles, way too big for rockbox 732 long *stackdeath=malloc(256*7*sizeof(long)); // This was a bunch of static varibles, way too big for rockbox
@@ -733,7 +744,7 @@ void R_InitTranMap(int progress)
733 if (progress) 744 if (progress)
734 printf("Please wait: Tranmap build"); 745 printf("Please wait: Tranmap build");
735 // First, convert playpal into long int type, and transpose array, 746 // First, convert playpal into long int type, and transpose array,
736 // for fast inner-loop calculations. Precompute tot array. 747 // for fast inner-loop calculations. Precompute tot array.
737 748
738 { 749 {
739 register int i = 255; 750 register int i = 255;
@@ -749,7 +760,8 @@ void R_InitTranMap(int progress)
749 d += t*t; 760 d += t*t;
750 p -= 3; 761 p -= 3;
751 tot[i] = d << (TSC-1); 762 tot[i] = d << (TSC-1);
752 } while (--i>=0); 763 }
764 while (--i>=0);
753 } 765 }
754 766
755 // Next, compute all entries using minimum arithmetic. 767 // Next, compute all entries using minimum arithmetic.
@@ -775,9 +787,10 @@ void R_InitTranMap(int progress)
775 long best = LONG_MAX; 787 long best = LONG_MAX;
776 do 788 do
777 if ((err = tot[color] - pal[0][color]*r 789 if ((err = tot[color] - pal[0][color]*r
778 - pal[1][color]*g - pal[2][color]*b) < best) 790 - pal[1][color]*g - pal[2][color]*b) < best)
779 best = err, *tp = color; 791 best = err, *tp = color;
780 while (--color >= 0); 792 while (--color >= 0)
793 ;
781 } 794 }
782 } 795 }
783 } 796 }
@@ -886,78 +899,78 @@ int R_TextureNumForName(const char *name) // const added -- killough
886 899
887void R_PrecacheLevel(void) 900void R_PrecacheLevel(void)
888{ 901{
889 register int i; 902 register int i;
890 register byte *hitlist; 903 register byte *hitlist;
891 904
892 if (demoplayback) 905 if (demoplayback)
893 return; 906 return;
894 907
895 { 908 {
896 size_t size = numflats > numsprites ? numflats : numsprites; 909 size_t size = numflats > numsprites ? numflats : numsprites;
897 hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size); 910 hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size);
898 } 911 }
899 // Precache flats. 912 // Precache flats.
900 913
901 memset(hitlist, 0, numflats); 914 memset(hitlist, 0, numflats);
902 915
903 for (i = numsectors; --i >= 0; ) 916 for (i = numsectors; --i >= 0; )
904 hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; 917 hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1;
905 918
906 for (i = numflats; --i >= 0; ) 919 for (i = numflats; --i >= 0; )
907 if (hitlist[i]) 920 if (hitlist[i])
908 (W_CacheLumpNum)(firstflat + i, 0); 921 (W_CacheLumpNum)(firstflat + i, 0);
909 922
910 // Precache textures. 923 // Precache textures.
911 924
912 memset(hitlist, 0, numtextures); 925 memset(hitlist, 0, numtextures);
913 926
914 for (i = numsides; --i >= 0;) 927 for (i = numsides; --i >= 0;)
915 hitlist[sides[i].bottomtexture] = 928 hitlist[sides[i].bottomtexture] =
916 hitlist[sides[i].toptexture] = 929 hitlist[sides[i].toptexture] =
917 hitlist[sides[i].midtexture] = 1; 930 hitlist[sides[i].midtexture] = 1;
918 931
919 // Sky texture is always present. 932 // Sky texture is always present.
920 // Note that F_SKY1 is the name used to 933 // Note that F_SKY1 is the name used to
921 // indicate a sky floor/ceiling as a flat, 934 // indicate a sky floor/ceiling as a flat,
922 // while the sky texture is stored like 935 // while the sky texture is stored like
923 // a wall texture, with an episode dependend 936 // a wall texture, with an episode dependend
924 // name. 937 // name.
925 938
926 hitlist[skytexture] = 1; 939 hitlist[skytexture] = 1;
927 940
928 for (i = numtextures; --i >= 0; ) 941 for (i = numtextures; --i >= 0; )
929 if (hitlist[i]) 942 if (hitlist[i])
930 { 943 {
931 texture_t *texture = textures[i]; 944 texture_t *texture = textures[i];
932 int j = texture->patchcount; 945 int j = texture->patchcount;
933 while (--j >= 0) 946 while (--j >= 0)
934 (W_CacheLumpNum)(texture->patches[j].patch, 0); 947 (W_CacheLumpNum)(texture->patches[j].patch, 0);
935 } 948 }
936 949
937 // Precache sprites. 950 // Precache sprites.
938 memset(hitlist, 0, numsprites); 951 memset(hitlist, 0, numsprites);
939 952
940 { 953 {
941 thinker_t *th; 954 thinker_t *th;
942 for (th = thinkercap.next ; th != &thinkercap ; th=th->next) 955 for (th = thinkercap.next ; th != &thinkercap ; th=th->next)
943 if (th->function == P_MobjThinker) 956 if (th->function == P_MobjThinker)
944 hitlist[((mobj_t *)th)->sprite] = 1; 957 hitlist[((mobj_t *)th)->sprite] = 1;
945 } 958 }
946 959
947 for (i=numsprites; --i >= 0;) 960 for (i=numsprites; --i >= 0;)
948 if (hitlist[i]) 961 if (hitlist[i])
949 { 962 {
950 int j = sprites[i].numframes; 963 int j = sprites[i].numframes;
951 while (--j >= 0) 964 while (--j >= 0)
952 { 965 {
953 short *sflump = sprites[i].spriteframes[j].lump; 966 short *sflump = sprites[i].spriteframes[j].lump;
954 int k = 7; 967 int k = 7;
955 do 968 do
956 (W_CacheLumpNum)(firstspritelump + sflump[k], 0); 969 (W_CacheLumpNum)(firstspritelump + sflump[k], 0);
957 while (--k >= 0); 970 while (--k >= 0);
958 } 971 }
959 } 972 }
960 free(hitlist); 973 free(hitlist);
961} 974}
962 975
963// Proff - Added for OpenGL 976// Proff - Added for OpenGL
diff --git a/apps/plugins/doom/r_data.h b/apps/plugins/doom/r_data.h
index 12c9eb74af..905928fac7 100644
--- a/apps/plugins/doom/r_data.h
+++ b/apps/plugins/doom/r_data.h
@@ -47,7 +47,8 @@ typedef struct
47{ 47{
48 int originx, originy; // Block origin, which has already accounted 48 int originx, originy; // Block origin, which has already accounted
49 int patch; // for the internal origin of the patch. 49 int patch; // for the internal origin of the patch.
50} texpatch_t; 50}
51texpatch_t;
51 52
52// 53//
53// Texture definition. 54// Texture definition.
@@ -69,7 +70,8 @@ typedef struct
69 short width, height; 70 short width, height;
70 short patchcount; // All the patches[patchcount] are drawn 71 short patchcount; // All the patches[patchcount] are drawn
71 texpatch_t patches[1]; // back-to-front into the cached texture. 72 texpatch_t patches[1]; // back-to-front into the cached texture.
72} texture_t; 73}
74texture_t;
73 75
74// Retrieve column data for span blitting. 76// Retrieve column data for span blitting.
75const byte* 77const byte*
diff --git a/apps/plugins/doom/r_defs.h b/apps/plugins/doom/r_defs.h
index a3bd5cdf33..0fbaf9a9ac 100644
--- a/apps/plugins/doom/r_defs.h
+++ b/apps/plugins/doom/r_defs.h
@@ -1,24 +1,33 @@
1// Emacs style mode select -*- C++ -*- 1/* Emacs style mode select -*- C++ -*-
2//----------------------------------------------------------------------------- 2 *-----------------------------------------------------------------------------
3// 3 *
4// $Id$ 4 *
5// 5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6// Copyright (C) 1993-1996 by id Software, Inc. 6 * based on BOOM, a modified and improved DOOM engine
7// 7 * Copyright (C) 1999 by
8// This program is free software; you can redistribute it and/or 8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9// modify it under the terms of the GNU General Public License 9 * Copyright (C) 1999-2000 by
10// as published by the Free Software Foundation; either version 2 10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11// of the License, or (at your option) any later version. 11 *
12// 12 * This program is free software; you can redistribute it and/or
13// This program is distributed in the hope that it will be useful, 13 * modify it under the terms of the GNU General Public License
14// but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * as published by the Free Software Foundation; either version 2
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * of the License, or (at your option) any later version.
16// GNU General Public License for more details. 16 *
17// 17 * This program is distributed in the hope that it will be useful,
18// DESCRIPTION: 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19// Refresh/rendering module, shared data struct definitions. 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// 20 * GNU General Public License for more details.
21//----------------------------------------------------------------------------- 21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
26 *
27 * DESCRIPTION:
28 * Refresh/rendering module, shared data struct definitions.
29 *
30 *-----------------------------------------------------------------------------*/
22 31
23#ifndef __R_DEFS__ 32#ifndef __R_DEFS__
24#define __R_DEFS__ 33#define __R_DEFS__
@@ -62,18 +71,16 @@
62typedef struct 71typedef struct
63{ 72{
64 fixed_t x, y; 73 fixed_t x, y;
65} vertex_t; 74}
66 75vertex_t;
67
68// Forward of LineDefs, for Sectors.
69struct line_s;
70 76
71// Each sector has a degenmobj_t in its center for sound origin purposes. 77// Each sector has a degenmobj_t in its center for sound origin purposes.
72typedef struct 78typedef struct
73{ 79{
74 thinker_t thinker; // not used for anything 80 thinker_t thinker; // not used for anything
75 fixed_t x, y, z; 81 fixed_t x, y, z;
76} degenmobj_t; 82}
83degenmobj_t;
77 84
78// 85//
79// The SECTORS record, at runtime. 86// The SECTORS record, at runtime.
@@ -142,8 +149,8 @@ typedef struct
142 short special; 149 short special;
143 short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap) 150 short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap)
144 short tag; 151 short tag;
145 void* specialdata; // ROCKDOOM obsolete 152}
146} sector_t; 153sector_t;
147 154
148// 155//
149// The SideDef. 156// The SideDef.
@@ -164,7 +171,8 @@ typedef struct
164 171
165 int special; 172 int special;
166 173
167} side_t; 174}
175side_t;
168 176
169// 177//
170// Move clipping aid for LineDefs. 178// Move clipping aid for LineDefs.
@@ -201,7 +209,8 @@ typedef struct line_s
201 RF_IGNORE = 8, // Renderer can skip this line 209 RF_IGNORE = 8, // Renderer can skip this line
202 RF_CLOSED =16, // Line blocks view 210 RF_CLOSED =16, // Line blocks view
203 } r_flags; 211 } r_flags;
204} line_t; 212}
213line_t;
205 214
206// phares 3/14/98 215// phares 3/14/98
207// 216//
@@ -228,7 +237,8 @@ typedef struct msecnode_s
228 struct msecnode_s *m_sprev; // prev msecnode_t for this sector 237 struct msecnode_s *m_sprev; // prev msecnode_t for this sector
229 struct msecnode_s *m_snext; // next msecnode_t for this sector 238 struct msecnode_s *m_snext; // next msecnode_t for this sector
230 boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms 239 boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms
231} msecnode_t; 240}
241msecnode_t;
232 242
233// 243//
234// The LineSeg. 244// The LineSeg.
@@ -249,7 +259,8 @@ typedef struct
249 // backsector is NULL for one sided lines 259 // backsector is NULL for one sided lines
250 260
251 sector_t *frontsector, *backsector; 261 sector_t *frontsector, *backsector;
252} seg_t; 262}
263seg_t;
253 264
254// 265//
255// A SubSector. 266// A SubSector.
@@ -263,7 +274,8 @@ typedef struct subsector_s
263{ 274{
264 sector_t *sector; 275 sector_t *sector;
265 unsigned short numlines, firstline; 276 unsigned short numlines, firstline;
266} subsector_t; 277}
278subsector_t;
267 279
268// 280//
269// BSP node. 281// BSP node.
@@ -273,14 +285,16 @@ typedef struct
273 fixed_t x, y, dx, dy; // Partition line. 285 fixed_t x, y, dx, dy; // Partition line.
274 fixed_t bbox[2][4]; // Bounding box for each child. 286 fixed_t bbox[2][4]; // Bounding box for each child.
275 unsigned short children[2]; // If NF_SUBSECTOR its a subsector. 287 unsigned short children[2]; // If NF_SUBSECTOR its a subsector.
276} node_t; 288}
289node_t;
277 290
278// posts are runs of non masked source pixels 291// posts are runs of non masked source pixels
279typedef struct 292typedef struct
280{ 293{
281 byte topdelta; // -1 is the last post in a column 294 byte topdelta; // -1 is the last post in a column
282 byte length; // length data bytes follows 295 byte length; // length data bytes follows
283} post_t; 296}
297post_t;
284 298
285// column_t is a list of 0 or more post_t, (byte)-1 terminated 299// column_t is a list of 0 or more post_t, (byte)-1 terminated
286typedef post_t column_t; 300typedef post_t column_t;
@@ -293,7 +307,8 @@ typedef post_t column_t;
293// Indeed, true color support is posibble 307// Indeed, true color support is posibble
294// precalculating 24bpp lightmap/colormap LUT. 308// precalculating 24bpp lightmap/colormap LUT.
295// from darkening PLAYPAL to all black. 309// from darkening PLAYPAL to all black.
296// Could even us emore than 32 levels. 310// Could use even more than 32 levels.
311
297typedef byte lighttable_t; 312typedef byte lighttable_t;
298 313
299// 314//
@@ -301,7 +316,7 @@ typedef byte lighttable_t;
301// 316//
302typedef struct drawseg_s 317typedef struct drawseg_s
303{ 318{
304 seg_t* curline; 319 seg_t *curline;
305 int x1, x2; 320 int x1, x2;
306 fixed_t scale1, scale2, scalestep; 321 fixed_t scale1, scale2, scalestep;
307 int silhouette; // 0=none, 1=bottom, 2=top, 3=both 322 int silhouette; // 0=none, 1=bottom, 2=top, 3=both
@@ -312,7 +327,8 @@ typedef struct drawseg_s
312 // all three adjusted so [x1] is first value. 327 // all three adjusted so [x1] is first value.
313 short *sprtopclip, *sprbottomclip, *maskedtexturecol; 328 short *sprtopclip, *sprbottomclip, *maskedtexturecol;
314 329
315} drawseg_t; 330}
331drawseg_t;
316 332
317// 333//
318// Patches. 334// Patches.
@@ -328,7 +344,8 @@ typedef struct
328 short leftoffset; // pixels to the left of origin 344 short leftoffset; // pixels to the left of origin
329 short topoffset; // pixels below the origin 345 short topoffset; // pixels below the origin
330 int columnofs[8]; // only [width] used 346 int columnofs[8]; // only [width] used
331} patch_t; 347}
348patch_t;
332 349
333// proff: Added for OpenGL 350// proff: Added for OpenGL
334typedef struct 351typedef struct
@@ -336,7 +353,8 @@ typedef struct
336 int width,height; 353 int width,height;
337 int leftoffset,topoffset; 354 int leftoffset,topoffset;
338 int lumpnum; 355 int lumpnum;
339} patchnum_t; 356}
357patchnum_t;
340 358
341// 359//
342// A vissprite_t is a thing that will be drawn during a refresh. 360// A vissprite_t is a thing that will be drawn during a refresh.
@@ -360,7 +378,8 @@ typedef struct vissprite_s
360 378
361 // killough 3/27/98: height sector for underwater/fake ceiling support 379 // killough 3/27/98: height sector for underwater/fake ceiling support
362 int heightsec; 380 int heightsec;
363} vissprite_t; 381}
382vissprite_t;
364 383
365// 384//
366// Sprites are patches with a special naming convention 385// Sprites are patches with a special naming convention
@@ -390,7 +409,8 @@ typedef struct
390 // Flip bit (1 = flip) to use for view angles 0-7. 409 // Flip bit (1 = flip) to use for view angles 0-7.
391 byte flip[8]; 410 byte flip[8];
392 411
393} spriteframe_t; 412}
413spriteframe_t;
394 414
395// 415//
396// A sprite definition: 416// A sprite definition:
@@ -401,7 +421,8 @@ typedef struct
401{ 421{
402 int numframes; 422 int numframes;
403 spriteframe_t *spriteframes; 423 spriteframe_t *spriteframes;
404} spritedef_t; 424}
425spritedef_t;
405 426
406// 427//
407// Now what is a visplane, anyway? 428// Now what is a visplane, anyway?
@@ -417,6 +438,7 @@ typedef struct visplane
417 unsigned short pad2, pad3; // killough 2/8/98, 4/25/98 438 unsigned short pad2, pad3; // killough 2/8/98, 4/25/98
418 unsigned short bottom[SCREENWIDTH]; 439 unsigned short bottom[SCREENWIDTH];
419 unsigned short pad4; 440 unsigned short pad4;
420} visplane_t; 441}
442visplane_t;
421 443
422#endif 444#endif
diff --git a/apps/plugins/doom/r_draw.c b/apps/plugins/doom/r_draw.c
index df682776cd..f0b9d3300b 100644
--- a/apps/plugins/doom/r_draw.c
+++ b/apps/plugins/doom/r_draw.c
@@ -41,12 +41,6 @@
41//#include "lprintf.h" 41//#include "lprintf.h"
42#include "rockmacros.h" 42#include "rockmacros.h"
43 43
44#define MAXWIDTH 1120
45#define MAXHEIGHT 832
46
47// status bar height at bottom of screen
48#define SBARHEIGHT 32
49
50// 44//
51// All drawing to the view buffer is accomplished in this file. 45// All drawing to the view buffer is accomplished in this file.
52// The other refresh files only know about ccordinates, 46// The other refresh files only know about ccordinates,
@@ -113,9 +107,10 @@ void R_DrawColumn (void)
113 return; 107 return;
114 108
115#ifdef RANGECHECK 109#ifdef RANGECHECK
110
116 if ((unsigned)dc_x >= SCREENWIDTH 111 if ((unsigned)dc_x >= SCREENWIDTH
117 || dc_yl < 0 112 || dc_yl < 0
118 || dc_yh >= SCREENHEIGHT) 113 || dc_yh >= SCREENHEIGHT)
119 I_Error ("R_DrawColumn: %d to %d at %d", dc_yl, dc_yh, dc_x); 114 I_Error ("R_DrawColumn: %d to %d at %d", dc_yl, dc_yh, dc_x);
120#endif 115#endif
121 116
@@ -127,6 +122,7 @@ void R_DrawColumn (void)
127 // Determine scaling, 122 // Determine scaling,
128 // which is the only mapping to be done. 123 // which is the only mapping to be done.
129#define fracstep dc_iscale 124#define fracstep dc_iscale
125
130 frac = dc_texturemid + (dc_yl-centery)*fracstep; 126 frac = dc_texturemid + (dc_yl-centery)*fracstep;
131 127
132 // Inner loop that does the actual texture mapping, 128 // Inner loop that does the actual texture mapping,
@@ -135,21 +131,27 @@ void R_DrawColumn (void)
135 // 131 //
136 // killough 2/1/98: more performance tuning 132 // killough 2/1/98: more performance tuning
137 133
138 if (dc_texheight == 128) { 134 if (dc_texheight == 128)
135 {
139 while(count--) 136 while(count--)
140 { 137 {
141 *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; 138 *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]];
142 frac += fracstep; 139 frac += fracstep;
143 dest += SCREENWIDTH; 140 dest += SCREENWIDTH;
144 } 141 }
145 } else if (dc_texheight == 0) { 142 }
143 else if (dc_texheight == 0)
144 {
146 /* cph - another special case */ 145 /* cph - another special case */
147 while (count--) { 146 while (count--)
147 {
148 *dest = dc_colormap[dc_source[frac>>FRACBITS]]; 148 *dest = dc_colormap[dc_source[frac>>FRACBITS]];
149 frac += fracstep; 149 frac += fracstep;
150 dest += SCREENWIDTH; 150 dest += SCREENWIDTH;
151 } 151 }
152 } else { 152 }
153 else
154 {
153 register unsigned heightmask = dc_texheight-1; // CPhipps - specify type 155 register unsigned heightmask = dc_texheight-1; // CPhipps - specify type
154 if (! (dc_texheight & heightmask) ) // power of 2 -- killough 156 if (! (dc_texheight & heightmask) ) // power of 2 -- killough
155 { 157 {
@@ -167,7 +169,8 @@ void R_DrawColumn (void)
167 heightmask <<= FRACBITS; 169 heightmask <<= FRACBITS;
168 170
169 if (frac < 0) 171 if (frac < 0)
170 while ((frac += heightmask) < 0); 172 while ((frac += heightmask) < 0)
173 ;
171 else 174 else
172 while (frac >= (int)heightmask) 175 while (frac >= (int)heightmask)
173 frac -= heightmask; 176 frac -= heightmask;
@@ -215,6 +218,7 @@ void R_DrawTLColumn (void)
215 return; 218 return;
216 219
217#ifdef RANGECHECK 220#ifdef RANGECHECK
221
218 if ((unsigned)dc_x >= (unsigned)SCREENWIDTH 222 if ((unsigned)dc_x >= (unsigned)SCREENWIDTH
219 || dc_yl < 0 223 || dc_yl < 0
220 || dc_yh >= SCREENHEIGHT) 224 || dc_yh >= SCREENHEIGHT)
@@ -227,6 +231,7 @@ void R_DrawTLColumn (void)
227 // Determine scaling, 231 // Determine scaling,
228 // which is the only mapping to be done. 232 // which is the only mapping to be done.
229#define fracstep dc_iscale 233#define fracstep dc_iscale
234
230 frac = dc_texturemid + (dc_yl-centery)*fracstep; 235 frac = dc_texturemid + (dc_yl-centery)*fracstep;
231 236
232 // Inner loop that does the actual texture mapping, 237 // Inner loop that does the actual texture mapping,
@@ -245,7 +250,8 @@ void R_DrawTLColumn (void)
245 heightmask <<= FRACBITS; 250 heightmask <<= FRACBITS;
246 251
247 if (frac < 0) 252 if (frac < 0)
248 while ((frac += heightmask) < 0); 253 while ((frac += heightmask) < 0)
254 ;
249 else 255 else
250 while (frac >= (int)heightmask) 256 while (frac >= (int)heightmask)
251 frac -= heightmask; 257 frac -= heightmask;
@@ -336,6 +342,7 @@ void R_DrawFuzzColumn(void)
336 return; 342 return;
337 343
338#ifdef RANGECHECK 344#ifdef RANGECHECK
345
339 if ((unsigned) dc_x >= (unsigned)SCREENWIDTH 346 if ((unsigned) dc_x >= (unsigned)SCREENWIDTH
340 || dc_yl < 0 347 || dc_yl < 0
341 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT) 348 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT)
@@ -377,7 +384,8 @@ void R_DrawFuzzColumn(void)
377 dest += SCREENWIDTH; 384 dest += SCREENWIDTH;
378 385
379 frac += fracstep; 386 frac += fracstep;
380 } while (count--); 387 }
388 while (count--);
381} 389}
382 390
383// 391//
@@ -404,6 +412,7 @@ void R_DrawTranslatedColumn (void)
404 return; 412 return;
405 413
406#ifdef RANGECHECK 414#ifdef RANGECHECK
415
407 if ((unsigned)dc_x >= (unsigned)SCREENWIDTH 416 if ((unsigned)dc_x >= (unsigned)SCREENWIDTH
408 || dc_yl < 0 417 || dc_yl < 0
409 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT) 418 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT)
@@ -449,6 +458,7 @@ void R_InitTranslationTables (void)
449{ 458{
450 int i, j; 459 int i, j;
451#define MAXTRANS 3 460#define MAXTRANS 3
461
452 byte transtocolour[MAXTRANS]; 462 byte transtocolour[MAXTRANS];
453 463
454 // killough 5/2/98: 464 // killough 5/2/98:
@@ -457,15 +467,20 @@ void R_InitTranslationTables (void)
457 if (translationtables == NULL) // CPhipps - allow multiple calls 467 if (translationtables == NULL) // CPhipps - allow multiple calls
458 translationtables = Z_Malloc(256*MAXTRANS, PU_STATIC, 0); 468 translationtables = Z_Malloc(256*MAXTRANS, PU_STATIC, 0);
459 469
460 for (i=0; i<MAXTRANS; i++) transtocolour[i] = 255; 470 for (i=0; i<MAXTRANS; i++)
471 transtocolour[i] = 255;
461 472
462 for (i=0; i<MAXPLAYERS; i++) { 473 for (i=0; i<MAXPLAYERS; i++)
474 {
463 byte wantcolour = mapcolor_plyr[i]; 475 byte wantcolour = mapcolor_plyr[i];
464 playernumtotrans[i] = 0; 476 playernumtotrans[i] = 0;
465 if (wantcolour != 0x70) // Not green, would like translation 477 if (wantcolour != 0x70) // Not green, would like translation
466 for (j=0; j<MAXTRANS; j++) 478 for (j=0; j<MAXTRANS; j++)
467 if (transtocolour[j] == 255) { 479 if (transtocolour[j] == 255)
468 transtocolour[j] = wantcolour; playernumtotrans[i] = j+1; break; 480 {
481 transtocolour[j] = wantcolour;
482 playernumtotrans[i] = j+1;
483 break;
469 } 484 }
470 } 485 }
471 486
diff --git a/apps/plugins/doom/r_main.c b/apps/plugins/doom/r_main.c
index f79097a969..5afb85b3ce 100644
--- a/apps/plugins/doom/r_main.c
+++ b/apps/plugins/doom/r_main.c
@@ -61,6 +61,8 @@ int centerx IBSS_ATTR;
61int centery IBSS_ATTR; 61int centery IBSS_ATTR;
62fixed_t centerxfrac, centeryfrac; 62fixed_t centerxfrac, centeryfrac;
63fixed_t projection; 63fixed_t projection;
64// proff 11/06/98: Added for high-res
65fixed_t projectiony;
64fixed_t viewx, viewy, viewz; 66fixed_t viewx, viewy, viewz;
65angle_t viewangle; 67angle_t viewangle;
66fixed_t viewcos, viewsin; 68fixed_t viewcos, viewsin;
@@ -333,10 +335,17 @@ void R_ExecuteSetViewSize (void)
333 scaledviewwidth = SCREENWIDTH; 335 scaledviewwidth = SCREENWIDTH;
334 viewheight = SCREENHEIGHT; 336 viewheight = SCREENHEIGHT;
335 } 337 }
338 // proff 09/24/98: Added for high-res
339 else if (setblocks == 10)
340 {
341 scaledviewwidth = SCREENWIDTH;
342 viewheight = SCREENHEIGHT-ST_SCALED_HEIGHT;
343 }
336 else 344 else
337 { 345 {
338 scaledviewwidth = setblocks*32; 346 // proff 08/17/98: Changed for high-res
339 viewheight = (setblocks*168/10)&~7; 347 scaledviewwidth = setblocks*SCREENWIDTH/10;
348 viewheight = (setblocks*(SCREENHEIGHT-ST_SCALED_HEIGHT)/10) & ~7;
340 } 349 }
341 350
342 viewwidth = scaledviewwidth; 351 viewwidth = scaledviewwidth;
@@ -346,14 +355,19 @@ void R_ExecuteSetViewSize (void)
346 centerxfrac = centerx<<FRACBITS; 355 centerxfrac = centerx<<FRACBITS;
347 centeryfrac = centery<<FRACBITS; 356 centeryfrac = centery<<FRACBITS;
348 projection = centerxfrac; 357 projection = centerxfrac;
358 // proff 11/06/98: Added for high-res
359 projectiony = ((SCREENHEIGHT * centerx * 320) / 200) / SCREENWIDTH * FRACUNIT;
349 360
350 R_InitBuffer (scaledviewwidth, viewheight); 361 R_InitBuffer (scaledviewwidth, viewheight);
351 362
352 R_InitTextureMapping(); 363 R_InitTextureMapping();
353 364
354 // psprite scales 365 // psprite scales
355 pspritescale = FRACUNIT*viewwidth/SCREENWIDTH; 366 // proff 08/17/98: Changed for high-res
356 pspriteiscale = FRACUNIT*SCREENWIDTH/viewwidth; 367 pspritescale = FRACUNIT*viewwidth/320;
368 pspriteiscale = FRACUNIT*320/viewwidth;
369 // proff 11/06/98: Added for high-res
370 pspriteyscale = (((SCREENHEIGHT*viewwidth)/SCREENWIDTH) << FRACBITS) / 200;
357 371
358 // thing clipping 372 // thing clipping
359 for (i=0 ; i<viewwidth ; i++) 373 for (i=0 ; i<viewwidth ; i++)
@@ -363,7 +377,8 @@ void R_ExecuteSetViewSize (void)
363 for (i=0 ; i<viewheight ; i++) 377 for (i=0 ; i<viewheight ; i++)
364 { // killough 5/2/98: reformatted 378 { // killough 5/2/98: reformatted
365 fixed_t dy = D_abs(((i-viewheight/2)<<FRACBITS)+FRACUNIT/2); 379 fixed_t dy = D_abs(((i-viewheight/2)<<FRACBITS)+FRACUNIT/2);
366 yslope[i] = FixedDiv ( (viewwidth)/2*FRACUNIT, dy); 380 // proff 08/17/98: Changed for high-res
381 yslope[i] = FixedDiv(projectiony, dy);
367 } 382 }
368 383
369 for (i=0 ; i<viewwidth ; i++) 384 for (i=0 ; i<viewwidth ; i++)
@@ -379,10 +394,7 @@ void R_ExecuteSetViewSize (void)
379 int j, startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS; 394 int j, startmap = ((LIGHTLEVELS-1-i)*2)*NUMCOLORMAPS/LIGHTLEVELS;
380 for (j=0 ; j<MAXLIGHTSCALE ; j++) 395 for (j=0 ; j<MAXLIGHTSCALE ; j++)
381 { 396 {
382 // CPhipps - use 320 here instead of SCREENWIDTH, otherwise hires is 397 int t, level = startmap - j*320/viewwidth/DISTMAP;
383 // brighter than normal res
384 int scale = FixedDiv ((320/2*FRACUNIT), (j+1)<<LIGHTZSHIFT);
385 int t, level = startmap - (scale >>= LIGHTSCALESHIFT)/DISTMAP;
386 398
387 if (level < 0) 399 if (level < 0)
388 level = 0; 400 level = 0;
@@ -410,12 +422,14 @@ void R_Init (void)
410 // CPhipps - R_DrawColumn isn't constant anymore, so must 422 // CPhipps - R_DrawColumn isn't constant anymore, so must
411 // initialise in code 423 // initialise in code
412 colfunc = R_DrawColumn; // current column draw function 424 colfunc = R_DrawColumn; // current column draw function
413 if (SCREENWIDTH<320) 425// if (SCREENWIDTH<320)
414 I_Error("R_Init: Screenwidth(%d) < 320",SCREENWIDTH); 426// I_Error("R_Init: Screenwidth(%d) < 320",SCREENWIDTH);
415#if 1 427#if 1
428
416 printf("\nR_LoadTrigTables: "); 429 printf("\nR_LoadTrigTables: ");
417 R_LoadTrigTables(); 430 R_LoadTrigTables();
418#endif 431#endif
432
419 printf("\nR_InitData: "); 433 printf("\nR_InitData: ");
420 R_InitData(); 434 R_InitData();
421 R_SetViewSize(screenblocks); 435 R_SetViewSize(screenblocks);
diff --git a/apps/plugins/doom/r_main.h b/apps/plugins/doom/r_main.h
index 10978b3e71..61bf02766b 100644
--- a/apps/plugins/doom/r_main.h
+++ b/apps/plugins/doom/r_main.h
@@ -54,6 +54,8 @@ extern int centery;
54extern fixed_t centerxfrac; 54extern fixed_t centerxfrac;
55extern fixed_t centeryfrac; 55extern fixed_t centeryfrac;
56extern fixed_t projection; 56extern fixed_t projection;
57// proff 11/06/98: Added for high-res
58extern fixed_t projectiony;
57extern int validcount; 59extern int validcount;
58extern int linecount; 60extern int linecount;
59extern int loopcount; 61extern int loopcount;
diff --git a/apps/plugins/doom/r_plane.c b/apps/plugins/doom/r_plane.c
index 60d37f876b..1ea1dd9193 100644
--- a/apps/plugins/doom/r_plane.c
+++ b/apps/plugins/doom/r_plane.c
@@ -128,6 +128,7 @@ static void R_MapPlane(int y, int x1, int x2)
128 unsigned index; 128 unsigned index;
129 129
130#ifdef RANGECHECK 130#ifdef RANGECHECK
131
131 if (x2 < x1 || x1<0 || x2>=viewwidth || (unsigned)y>(unsigned)viewheight) 132 if (x2 < x1 || x1<0 || x2>=viewwidth || (unsigned)y>(unsigned)viewheight)
132 I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); 133 I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y);
133#endif 134#endif
@@ -295,10 +296,13 @@ visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop)
295 for (x=intrl ; x <= intrh && pl->top[x] == 0xffff; x++) 296 for (x=intrl ; x <= intrh && pl->top[x] == 0xffff; x++)
296 ; 297 ;
297 298
298 if (x > intrh) { /* Can use existing plane; extend range */ 299 if (x > intrh)
299 pl->minx = unionl; pl->maxx = unionh; 300 { /* Can use existing plane; extend range */
301 pl->minx = unionl;
302 pl->maxx = unionh;
300 return pl; 303 return pl;
301 } else /* Cannot use existing plane; create a new one */ 304 }
305 else /* Cannot use existing plane; create a new one */
302 return R_DupPlane(pl,start,stop); 306 return R_DupPlane(pl,start,stop);
303} 307}
304 308
@@ -323,8 +327,10 @@ static void R_MakeSpans(int x, int t1, int b1, int t2, int b2)
323static void R_DoDrawPlane(visplane_t *pl) 327static void R_DoDrawPlane(visplane_t *pl)
324{ 328{
325 register int x; 329 register int x;
326 if (pl->minx <= pl->maxx) { 330 if (pl->minx <= pl->maxx)
327 if (pl->picnum == skyflatnum || pl->picnum & PL_SKYFLAT) { // sky flat 331 {
332 if (pl->picnum == skyflatnum || pl->picnum & PL_SKYFLAT)
333 { // sky flat
328 int texture; 334 int texture;
329 angle_t an, flip; 335 angle_t an, flip;
330 336
@@ -390,7 +396,9 @@ static void R_DoDrawPlane(visplane_t *pl)
390 ANGLETOSKYSHIFT); 396 ANGLETOSKYSHIFT);
391 colfunc(); 397 colfunc();
392 } 398 }
393 } else { // regular flat 399 }
400 else
401 { // regular flat
394 402
395 int stop, light; 403 int stop, light;
396 404
diff --git a/apps/plugins/doom/r_segs.c b/apps/plugins/doom/r_segs.c
index 4771132c77..8d38e4bd5f 100644
--- a/apps/plugins/doom/r_segs.c
+++ b/apps/plugins/doom/r_segs.c
@@ -95,18 +95,19 @@ static short *maskedtexturecol;
95// rw_distance must be calculated first. 95// rw_distance must be calculated first.
96// 96//
97// killough 5/2/98: reformatted, cleaned up 97// killough 5/2/98: reformatted, cleaned up
98static fixed_t R_ScaleFromGlobalAngle (angle_t visangle) 98// CPhipps - moved here from r_main.c
99
100static fixed_t R_ScaleFromGlobalAngle(angle_t visangle)
99{ 101{
100 int anglea = ANG90 + (visangle-viewangle); 102 int anglea = ANG90 + (visangle-viewangle);
101 int angleb = ANG90 + (visangle-rw_normalangle); 103 int angleb = ANG90 + (visangle-rw_normalangle);
102 int sinea = finesine[anglea>>ANGLETOFINESHIFT]; 104 int den = FixedMul(rw_distance, finesine[anglea>>ANGLETOFINESHIFT]);
103 int sineb = finesine[angleb>>ANGLETOFINESHIFT]; 105 // proff 11/06/98: Changed for high-res
104 fixed_t num = FixedMul(projection,sineb); 106 fixed_t num = FixedMul(projectiony, finesine[angleb>>ANGLETOFINESHIFT]);
105 int den = FixedMul(rw_distance,sinea); 107 return den > num>>16 ? (num = FixedDiv(num, den)) > 64*FRACUNIT ?
106 108 64*FRACUNIT : num < 256 ? 256 : num : 64*FRACUNIT;
107 return den > num>>16 ? (num=FixedDiv (num, den)) > 64*FRACUNIT ?
108 64*FRACUNIT : num < 256 ? 256 : num : 64*FRACUNIT ;
109} 109}
110
110// 111//
111// R_RenderMaskedSegRange 112// R_RenderMaskedSegRange
112// 113//
@@ -146,11 +147,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2)
146 147
147 // killough 4/13/98: get correct lightlevel for 2s normal textures 148 // killough 4/13/98: get correct lightlevel for 2s normal textures
148 lightnum = (R_FakeFlat(frontsector, &tempsec, NULL, NULL, false) 149 lightnum = (R_FakeFlat(frontsector, &tempsec, NULL, NULL, false)
149 ->lightlevel >> LIGHTSEGSHIFT)+extralight; 150 ->lightlevel >> LIGHTSEGSHIFT)+extralight;
150 151
151 /* cph - ...what is this for? adding contrast to rooms? 152 /* cph - ...what is this for? adding contrast to rooms?
152 * It looks crap in outdoor areas */ 153 * It looks crap in outdoor areas */
153 if (fake_contrast) { 154 if (fake_contrast)
155 {
154 if (curline->v1->y == curline->v2->y) 156 if (curline->v1->y == curline->v2->y)
155 lightnum--; 157 lightnum--;
156 else 158 else
@@ -402,8 +404,10 @@ static void R_RenderSegLoop (void)
402 // cph - if we completely blocked further sight through this column, 404 // cph - if we completely blocked further sight through this column,
403 // add this info to the solid columns array for r_bsp.c 405 // add this info to the solid columns array for r_bsp.c
404 if ((markceiling || markfloor) && 406 if ((markceiling || markfloor) &&
405 (floorclip[rw_x] <= ceilingclip[rw_x] + 1)) { 407 (floorclip[rw_x] <= ceilingclip[rw_x] + 1))
406 solidcol[rw_x] = 1; didsolidcol = 1; 408 {
409 solidcol[rw_x] = 1;
410 didsolidcol = 1;
407 } 411 }
408 412
409 // save texturecol for backdrawing of masked mid texture 413 // save texturecol for backdrawing of masked mid texture
@@ -460,6 +464,7 @@ void R_StoreWallRange(const int start, const int stop)
460 464
461 465
462#ifdef RANGECHECK 466#ifdef RANGECHECK
467
463 if (start >=viewwidth || start > stop) 468 if (start >=viewwidth || start > stop)
464 I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); 469 I_Error ("Bad R_RenderWallRange: %i to %i", start , stop);
465#endif 470#endif
@@ -574,7 +579,8 @@ void R_StoreWallRange(const int start, const int stop)
574 ds_p->sprtopclip = ds_p->sprbottomclip = NULL; 579 ds_p->sprtopclip = ds_p->sprbottomclip = NULL;
575 ds_p->silhouette = 0; 580 ds_p->silhouette = 0;
576 581
577 if (linedef->r_flags & RF_CLOSED) { /* cph - closed 2S line e.g. door */ 582 if (linedef->r_flags & RF_CLOSED)
583 { /* cph - closed 2S line e.g. door */
578 // cph - killough's (outdated) comment follows - this deals with both 584 // cph - killough's (outdated) comment follows - this deals with both
579 // "automap fixes", his and mine 585 // "automap fixes", his and mine
580 // killough 1/17/98: this test is required if the fix 586 // killough 1/17/98: this test is required if the fix
@@ -589,7 +595,9 @@ void R_StoreWallRange(const int start, const int stop)
589 ds_p->sprtopclip = screenheightarray; 595 ds_p->sprtopclip = screenheightarray;
590 ds_p->tsilheight = INT_MIN; 596 ds_p->tsilheight = INT_MIN;
591 597
592 } else { /* not solid - old code */ 598 }
599 else
600 { /* not solid - old code */
593 601
594 if (frontsector->floorheight > backsector->floorheight) 602 if (frontsector->floorheight > backsector->floorheight)
595 { 603 {
@@ -721,7 +729,8 @@ void R_StoreWallRange(const int start, const int stop)
721 729
722 /* cph - ...what is this for? adding contrast to rooms? 730 /* cph - ...what is this for? adding contrast to rooms?
723 * It looks crap in outdoor areas */ 731 * It looks crap in outdoor areas */
724 if (fake_contrast) { 732 if (fake_contrast)
733 {
725 if (curline->v1->y == curline->v2->y) 734 if (curline->v1->y == curline->v2->y)
726 lightnum--; 735 lightnum--;
727 else if (curline->v1->x == curline->v2->x) 736 else if (curline->v1->x == curline->v2->x)
@@ -778,14 +787,16 @@ void R_StoreWallRange(const int start, const int stop)
778 } 787 }
779 788
780 // render it 789 // render it
781 if (markceiling) { 790 if (markceiling)
791 {
782 if (ceilingplane) // killough 4/11/98: add NULL ptr checks 792 if (ceilingplane) // killough 4/11/98: add NULL ptr checks
783 ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); 793 ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1);
784 else 794 else
785 markceiling = 0; 795 markceiling = 0;
786 } 796 }
787 797
788 if (markfloor) { 798 if (markfloor)
799 {
789 if (floorplane) // killough 4/11/98: add NULL ptr checks 800 if (floorplane) // killough 4/11/98: add NULL ptr checks
790 /* cph 2003/04/18 - ceilingplane and floorplane might be the same 801 /* cph 2003/04/18 - ceilingplane and floorplane might be the same
791 * visplane (e.g. if both skies); R_CheckPlane doesn't know about 802 * visplane (e.g. if both skies); R_CheckPlane doesn't know about
@@ -805,12 +816,15 @@ void R_StoreWallRange(const int start, const int stop)
805 R_RenderSegLoop(); 816 R_RenderSegLoop();
806 817
807 /* cph - if a column was made solid by this wall, we _must_ save full clipping info */ 818 /* cph - if a column was made solid by this wall, we _must_ save full clipping info */
808 if (backsector && didsolidcol) { 819 if (backsector && didsolidcol)
809 if (!(ds_p->silhouette & SIL_BOTTOM)) { 820 {
821 if (!(ds_p->silhouette & SIL_BOTTOM))
822 {
810 ds_p->silhouette |= SIL_BOTTOM; 823 ds_p->silhouette |= SIL_BOTTOM;
811 ds_p->bsilheight = backsector->floorheight; 824 ds_p->bsilheight = backsector->floorheight;
812 } 825 }
813 if (!(ds_p->silhouette & SIL_TOP)) { 826 if (!(ds_p->silhouette & SIL_TOP))
827 {
814 ds_p->silhouette |= SIL_TOP; 828 ds_p->silhouette |= SIL_TOP;
815 ds_p->tsilheight = backsector->ceilingheight; 829 ds_p->tsilheight = backsector->ceilingheight;
816 } 830 }
diff --git a/apps/plugins/doom/r_things.c b/apps/plugins/doom/r_things.c
index 2e1f72e34c..461edadce1 100644
--- a/apps/plugins/doom/r_things.c
+++ b/apps/plugins/doom/r_things.c
@@ -52,7 +52,8 @@ typedef struct {
52 int column; 52 int column;
53 int topclip; 53 int topclip;
54 int bottomclip; 54 int bottomclip;
55} maskdraw_t; 55}
56maskdraw_t;
56 57
57// 58//
58// Sprite rotation 0 is facing the viewer, 59// Sprite rotation 0 is facing the viewer,
@@ -63,6 +64,8 @@ typedef struct {
63// 64//
64fixed_t pspritescale; 65fixed_t pspritescale;
65fixed_t pspriteiscale; 66fixed_t pspriteiscale;
67// proff 11/06/98: Added for high-res
68fixed_t pspriteyscale;
66 69
67static lighttable_t** spritelights; 70static lighttable_t** spritelights;
68 71
@@ -95,33 +98,33 @@ static void R_InstallSpriteLump(int lump, unsigned frame,
95 unsigned rotation, boolean flipped) 98 unsigned rotation, boolean flipped)
96{ 99{
97 100
98 if (frame >= MAX_SPRITE_FRAMES || rotation > 8) 101 if (frame >= MAX_SPRITE_FRAMES || rotation > 8)
99 I_Error("R_InstallSpriteLump: Bad frame characters in lump %i", lump); 102 I_Error("R_InstallSpriteLump: Bad frame characters in lump %i", lump);
100 103
101 if ((int)frame > maxframe) 104 if ((int)frame > maxframe)
102 maxframe = frame; 105 maxframe = frame;
103 106
104 if (rotation == 0) 107 if (rotation == 0)
105 { // the lump should be used for all rotations 108 { // the lump should be used for all rotations
106 int r; 109 int r;
107 for (r=0 ; r<8 ; r++) 110 for (r=0 ; r<8 ; r++)
108 if (sprtemp[frame].lump[r]==-1) 111 if (sprtemp[frame].lump[r]==-1)
109 { 112 {
110 sprtemp[frame].lump[r] = lump - firstspritelump; 113 sprtemp[frame].lump[r] = lump - firstspritelump;
111 sprtemp[frame].flip[r] = (byte) flipped; 114 sprtemp[frame].flip[r] = (byte) flipped;
112 sprtemp[frame].rotate = false; //jff 4/24/98 if any subbed, rotless 115 sprtemp[frame].rotate = false; //jff 4/24/98 if any subbed, rotless
113 } 116 }
114 return; 117 return;
115 } 118 }
116 119
117 // the lump is only used for one rotation 120 // the lump is only used for one rotation
118 121
119 if (sprtemp[frame].lump[--rotation] == -1) 122 if (sprtemp[frame].lump[--rotation] == -1)
120 { 123 {
121 sprtemp[frame].lump[rotation] = lump - firstspritelump; 124 sprtemp[frame].lump[rotation] = lump - firstspritelump;
122 sprtemp[frame].flip[rotation] = (byte) flipped; 125 sprtemp[frame].flip[rotation] = (byte) flipped;
123 sprtemp[frame].rotate = true; //jff 4/24/98 only change if rot used 126 sprtemp[frame].rotate = true; //jff 4/24/98 only change if rot used
124 } 127 }
125} 128}
126 129
127// 130//
@@ -152,110 +155,114 @@ static void R_InstallSpriteLump(int lump, unsigned frame,
152 155
153void R_InitSpriteDefs(const char * const * namelist) 156void R_InitSpriteDefs(const char * const * namelist)
154{ 157{
155 size_t numentries = lastspritelump-firstspritelump+1; 158 size_t numentries = lastspritelump-firstspritelump+1;
156 struct { int index, next; } *hash; 159 struct {
157 int i; 160 int index, next;
161 }
162 *hash;
163 int i;
158 164
159 if (!numentries || !*namelist) 165 if (!numentries || !*namelist)
160 return; 166 return;
161 167
162 // count the number of sprite names 168 // count the number of sprite names
163 for (i=0; namelist[i]; i++) 169 for (i=0; namelist[i]; i++)
164 ; 170 ;
165 171
166 numsprites = i; 172 numsprites = i;
167 173
168 sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); 174 sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL);
169 175
170 // Create hash table based on just the first four letters of each sprite 176 // Create hash table based on just the first four letters of each sprite
171 // killough 1/31/98 177 // killough 1/31/98
172 178
173 hash = malloc(sizeof(*hash)*numentries); // allocate hash table 179 hash = malloc(sizeof(*hash)*numentries); // allocate hash table
174 180
175 for (i=0; (size_t)i<numentries; i++) // initialize hash table as empty 181 for (i=0; (size_t)i<numentries; i++) // initialize hash table as empty
176 hash[i].index = -1; 182 hash[i].index = -1;
177 183
178 for (i=0; (size_t)i<numentries; i++) // Prepend each sprite to hash chain 184 for (i=0; (size_t)i<numentries; i++) // Prepend each sprite to hash chain
179 { // prepend so that later ones win 185 { // prepend so that later ones win
180 int j = R_SpriteNameHash(lumpinfo[i+firstspritelump].name) % numentries; 186 int j = R_SpriteNameHash(lumpinfo[i+firstspritelump].name) % numentries;
181 hash[i].next = hash[j].index; 187 hash[i].next = hash[j].index;
182 hash[j].index = i; 188 hash[j].index = i;
183 } 189 }
184 190
185 // scan all the lump names for each of the names, 191 // scan all the lump names for each of the names,
186 // noting the highest frame letter. 192 // noting the highest frame letter.
187 193
188 for (i=0 ; i<numsprites ; i++) 194 for (i=0 ; i<numsprites ; i++)
189 { 195 {
190 const char *spritename = namelist[i]; 196 const char *spritename = namelist[i];
191 int j = hash[R_SpriteNameHash(spritename) % numentries].index; 197 int j = hash[R_SpriteNameHash(spritename) % numentries].index;
192 198
193 if (j >= 0) 199 if (j >= 0)
194 { 200 {
195 memset(sprtemp, -1, sizeof(sprtemp)); 201 memset(sprtemp, -1, sizeof(sprtemp));
196 maxframe = -1; 202 maxframe = -1;
197 do 203 do
198 { 204 {
199 register lumpinfo_t *lump = lumpinfo + j + firstspritelump; 205 register lumpinfo_t *lump = lumpinfo + j + firstspritelump;
200 206
201 // Fast portable comparison -- killough 207 // Fast portable comparison -- killough
202 // (using int pointer cast is nonportable): 208 // (using int pointer cast is nonportable):
203 209
204 if (!((lump->name[0] ^ spritename[0]) | 210 if (!((lump->name[0] ^ spritename[0]) |
205 (lump->name[1] ^ spritename[1]) | 211 (lump->name[1] ^ spritename[1]) |
206 (lump->name[2] ^ spritename[2]) | 212 (lump->name[2] ^ spritename[2]) |
207 (lump->name[3] ^ spritename[3]))) 213 (lump->name[3] ^ spritename[3])))
208 { 214 {
215 R_InstallSpriteLump(j+firstspritelump,
216 lump->name[4] - 'A',
217 lump->name[5] - '0',
218 false);
219 if (lump->name[6])
209 R_InstallSpriteLump(j+firstspritelump, 220 R_InstallSpriteLump(j+firstspritelump,
210 lump->name[4] - 'A', 221 lump->name[6] - 'A',
211 lump->name[5] - '0', 222 lump->name[7] - '0',
212 false); 223 true);
213 if (lump->name[6])
214 R_InstallSpriteLump(j+firstspritelump,
215 lump->name[6] - 'A',
216 lump->name[7] - '0',
217 true);
218 }
219 } 224 }
220 while ((j = hash[j].next) >= 0); 225 }
226 while ((j = hash[j].next) >= 0)
227 ;
221 228
222 // check the frames that were found for completeness 229 // check the frames that were found for completeness
223 if ((sprites[i].numframes = ++maxframe)) // killough 1/31/98 230 if ((sprites[i].numframes = ++maxframe)) // killough 1/31/98
224 { 231 {
225 int frame; 232 int frame;
226 for (frame = 0; frame < maxframe; frame++) 233 for (frame = 0; frame < maxframe; frame++)
227 switch ((int) sprtemp[frame].rotate) 234 switch ((int) sprtemp[frame].rotate)
235 {
236 case -1:
237 // no rotations were found for that frame at all
238 I_Error ("R_InitSprites: No patches found "
239 "for %.8s frame %c", namelist[i], frame+'A');
240 break;
241
242 case 0:
243 // only the first rotation is needed
244 break;
245
246 case 1:
247 // must have all 8 frames
228 { 248 {
229 case -1: 249 int rotation;
230 // no rotations were found for that frame at all 250 for (rotation=0 ; rotation<8 ; rotation++)
231 I_Error ("R_InitSprites: No patches found "
232 "for %.8s frame %c", namelist[i], frame+'A');
233 break;
234
235 case 0:
236 // only the first rotation is needed
237 break;
238
239 case 1:
240 // must have all 8 frames
241 {
242 int rotation;
243 for (rotation=0 ; rotation<8 ; rotation++)
244 if (sprtemp[frame].lump[rotation] == -1) 251 if (sprtemp[frame].lump[rotation] == -1)
245 I_Error ("R_InitSprites: Sprite %.8s frame %c " 252 I_Error ("R_InitSprites: Sprite %.8s frame %c "
246 "is missing rotations", 253 "is missing rotations",
247 namelist[i], frame+'A'); 254 namelist[i], frame+'A');
248 break; 255 break;
249 }
250 } 256 }
251 // allocate space for the frames present and copy sprtemp to it 257 }
252 sprites[i].spriteframes = 258 // allocate space for the frames present and copy sprtemp to it
253 Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); 259 sprites[i].spriteframes =
254 memcpy (sprites[i].spriteframes, sprtemp, 260 Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL);
255 maxframe*sizeof(spriteframe_t)); 261 memcpy (sprites[i].spriteframes, sprtemp,
256 } 262 maxframe*sizeof(spriteframe_t));
257 } 263 }
258 } 264 }
265 }
259 free(hash); // free hash table 266 free(hash); // free hash table
260} 267}
261 268
@@ -313,13 +320,13 @@ fixed_t sprtopscreen;
313 320
314void R_DrawMaskedColumn(const column_t *column) 321void R_DrawMaskedColumn(const column_t *column)
315{ 322{
316 int topscreen; 323 int topscreen;
317 int bottomscreen; 324 int bottomscreen;
318 fixed_t basetexturemid = dc_texturemid; 325 fixed_t basetexturemid = dc_texturemid;
319 326
320 dc_texheight = 0; // killough 11/98 327 dc_texheight = 0; // killough 11/98
321 while (column->topdelta != 0xff) 328 while (column->topdelta != 0xff)
322 { 329 {
323 // calculate unclipped screen coordinates for post 330 // calculate unclipped screen coordinates for post
324 topscreen = sprtopscreen + spryscale*column->topdelta; 331 topscreen = sprtopscreen + spryscale*column->topdelta;
325 bottomscreen = topscreen + spryscale*column->length; 332 bottomscreen = topscreen + spryscale*column->length;
@@ -328,24 +335,24 @@ void R_DrawMaskedColumn(const column_t *column)
328 dc_yh = (bottomscreen-1)>>FRACBITS; 335 dc_yh = (bottomscreen-1)>>FRACBITS;
329 336
330 if (dc_yh >= mfloorclip[dc_x]) 337 if (dc_yh >= mfloorclip[dc_x])
331 dc_yh = mfloorclip[dc_x]-1; 338 dc_yh = mfloorclip[dc_x]-1;
332 339
333 if (dc_yl <= mceilingclip[dc_x]) 340 if (dc_yl <= mceilingclip[dc_x])
334 dc_yl = mceilingclip[dc_x]+1; 341 dc_yl = mceilingclip[dc_x]+1;
335 342
336 // killough 3/2/98, 3/27/98: Failsafe against overflow/crash: 343 // killough 3/2/98, 3/27/98: Failsafe against overflow/crash:
337 if (dc_yl <= dc_yh && dc_yh < viewheight) 344 if (dc_yl <= dc_yh && dc_yh < viewheight)
338 { 345 {
339 dc_source = (byte *)column + 3; 346 dc_source = (byte *)column + 3;
340 dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS); 347 dc_texturemid = basetexturemid - (column->topdelta<<FRACBITS);
341 348
342 // Drawn by either R_DrawColumn 349 // Drawn by either R_DrawColumn
343 // or (SHADOW) R_DrawFuzzColumn. 350 // or (SHADOW) R_DrawFuzzColumn.
344 colfunc (); 351 colfunc ();
345 } 352 }
346 column = (const column_t *)( (byte *)column + column->length + 4); 353 column = (const column_t *)( (byte *)column + column->length + 4);
347 } 354 }
348 dc_texturemid = basetexturemid; 355 dc_texturemid = basetexturemid;
349} 356}
350 357
351// 358//
@@ -384,10 +391,10 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2)
384 } 391 }
385 else 392 else
386 colfunc = R_DrawColumn; // killough 3/14/98, 4/11/98 393 colfunc = R_DrawColumn; // killough 3/14/98, 4/11/98
387 394
388 395
389 // proff 11/06/98: Changed for high-res 396 // proff 11/06/98: Changed for high-res
390 dc_iscale = D_abs(vis->xiscale); 397 dc_iscale = FixedDiv (FRACUNIT, vis->scale);
391 dc_texturemid = vis->texturemid; 398 dc_texturemid = vis->texturemid;
392 frac = vis->startfrac; 399 frac = vis->startfrac;
393 spryscale = vis->scale; 400 spryscale = vis->scale;
@@ -398,6 +405,7 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2)
398 texturecolumn = frac>>FRACBITS; 405 texturecolumn = frac>>FRACBITS;
399 406
400#ifdef RANGECHECK 407#ifdef RANGECHECK
408
401 if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) 409 if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width))
402 I_Error ("R_DrawSpriteRange: Bad texturecolumn"); 410 I_Error ("R_DrawSpriteRange: Bad texturecolumn");
403#endif 411#endif
@@ -428,8 +436,10 @@ void R_ProjectSprite (mobj_t* thing)
428 boolean flip; 436 boolean flip;
429 vissprite_t *vis; 437 vissprite_t *vis;
430#ifndef GL_DOOM 438#ifndef GL_DOOM
439
431 fixed_t iscale; 440 fixed_t iscale;
432#endif 441#endif
442
433 int heightsec; // killough 3/27/98 443 int heightsec; // killough 3/27/98
434 444
435 // transform the origin point 445 // transform the origin point
@@ -457,6 +467,7 @@ void R_ProjectSprite (mobj_t* thing)
457 467
458 // decide which patch to use for sprite relative to player 468 // decide which patch to use for sprite relative to player
459#ifdef RANGECHECK 469#ifdef RANGECHECK
470
460 if ((unsigned) thing->sprite >= (unsigned)numsprites) 471 if ((unsigned) thing->sprite >= (unsigned)numsprites)
461 I_Error ("R_ProjectSprite: Invalid sprite number %i", thing->sprite); 472 I_Error ("R_ProjectSprite: Invalid sprite number %i", thing->sprite);
462#endif 473#endif
@@ -464,6 +475,7 @@ void R_ProjectSprite (mobj_t* thing)
464 sprdef = &sprites[thing->sprite]; 475 sprdef = &sprites[thing->sprite];
465 476
466#ifdef RANGECHECK 477#ifdef RANGECHECK
478
467 if ((thing->frame&FF_FRAMEMASK) >= sprdef->numframes) 479 if ((thing->frame&FF_FRAMEMASK) >= sprdef->numframes)
468 I_Error ("R_ProjectSprite: Invalid sprite frame %i : %i", thing->sprite, 480 I_Error ("R_ProjectSprite: Invalid sprite frame %i : %i", thing->sprite,
469 thing->frame); 481 thing->frame);
@@ -538,7 +550,7 @@ void R_ProjectSprite (mobj_t* thing)
538 550
539 vis->mobjflags = thing->flags; 551 vis->mobjflags = thing->flags;
540 // proff 11/06/98: Changed for high-res 552 // proff 11/06/98: Changed for high-res
541 vis->scale = xscale; 553 vis->scale = FixedDiv(projectiony, tz);
542 vis->gx = thing->x; 554 vis->gx = thing->x;
543 vis->gy = thing->y; 555 vis->gy = thing->y;
544 vis->gz = thing->z; 556 vis->gz = thing->z;
@@ -634,6 +646,7 @@ void R_DrawPSprite (pspdef_t *psp)
634 // decide which patch to use 646 // decide which patch to use
635 647
636#ifdef RANGECHECK 648#ifdef RANGECHECK
649
637 if ( (unsigned)psp->state->sprite >= (unsigned)numsprites) 650 if ( (unsigned)psp->state->sprite >= (unsigned)numsprites)
638 I_Error ("R_ProjectSprite: Invalid sprite number %i", psp->state->sprite); 651 I_Error ("R_ProjectSprite: Invalid sprite number %i", psp->state->sprite);
639#endif 652#endif
@@ -641,6 +654,7 @@ void R_DrawPSprite (pspdef_t *psp)
641 sprdef = &sprites[psp->state->sprite]; 654 sprdef = &sprites[psp->state->sprite];
642 655
643#ifdef RANGECHECK 656#ifdef RANGECHECK
657
644 if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) 658 if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes)
645 I_Error ("R_ProjectSprite: Invalid sprite frame %i : %li", 659 I_Error ("R_ProjectSprite: Invalid sprite frame %i : %li",
646 psp->state->sprite, psp->state->frame); 660 psp->state->sprite, psp->state->frame);
@@ -677,7 +691,7 @@ void R_DrawPSprite (pspdef_t *psp)
677 vis->x1 = x1 < 0 ? 0 : x1; 691 vis->x1 = x1 < 0 ? 0 : x1;
678 vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; 692 vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2;
679 // proff 11/06/98: Added for high-res 693 // proff 11/06/98: Added for high-res
680 vis->scale = pspritescale; 694 vis->scale = pspriteyscale;
681 695
682 if (flip) 696 if (flip)
683 { 697 {
@@ -760,7 +774,8 @@ static void msort(vissprite_t **s, vissprite_t **t, int n)
760 msort(s2, t, n2); 774 msort(s2, t, n2);
761 775
762 while ((*s1)->scale > (*s2)->scale ? 776 while ((*s1)->scale > (*s2)->scale ?
763 (*d++ = *s1++, --n1) : (*d++ = *s2++, --n2)); 777 (*d++ = *s1++, --n1) : (*d++ = *s2++, --n2))
778 ;
764 779
765 if (n2) 780 if (n2)
766 bcopyp(d, s2, n2); 781 bcopyp(d, s2, n2);
@@ -778,7 +793,8 @@ static void msort(vissprite_t **s, vissprite_t **t, int n)
778 if (s[i-1]->scale < temp->scale) 793 if (s[i-1]->scale < temp->scale)
779 { 794 {
780 int j = i; 795 int j = i;
781 while ((s[j] = s[j-1])->scale < temp->scale && --j); 796 while ((s[j] = s[j-1])->scale < temp->scale && --j)
797 ;
782 s[j] = temp; 798 s[j] = temp;
783 } 799 }
784 } 800 }
@@ -893,7 +909,8 @@ void R_DrawSprite (vissprite_t* spr)
893 int phs = viewplayer->mo->subsector->sector->heightsec; 909 int phs = viewplayer->mo->subsector->sector->heightsec;
894 if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && 910 if ((mh = sectors[spr->heightsec].floorheight) > spr->gz &&
895 (h = centeryfrac - FixedMul(mh-=viewz, spr->scale)) >= 0 && 911 (h = centeryfrac - FixedMul(mh-=viewz, spr->scale)) >= 0 &&
896 (h >>= FRACBITS) < viewheight) { 912 (h >>= FRACBITS) < viewheight)
913 {
897 if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) 914 if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight))
898 { // clip bottom 915 { // clip bottom
899 for (x=spr->x1 ; x<=spr->x2 ; x++) 916 for (x=spr->x1 ; x<=spr->x2 ; x++)
@@ -909,7 +926,8 @@ void R_DrawSprite (vissprite_t* spr)
909 926
910 if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt && 927 if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt &&
911 (h = centeryfrac - FixedMul(mh-viewz, spr->scale)) >= 0 && 928 (h = centeryfrac - FixedMul(mh-viewz, spr->scale)) >= 0 &&
912 (h >>= FRACBITS) < viewheight) { 929 (h >>= FRACBITS) < viewheight)
930 {
913 if (phs != -1 && viewz >= sectors[phs].ceilingheight) 931 if (phs != -1 && viewz >= sectors[phs].ceilingheight)
914 { // clip bottom 932 { // clip bottom
915 for (x=spr->x1 ; x<=spr->x2 ; x++) 933 for (x=spr->x1 ; x<=spr->x2 ; x++)
@@ -927,7 +945,8 @@ void R_DrawSprite (vissprite_t* spr)
927 // all clipping has been performed, so draw the sprite 945 // all clipping has been performed, so draw the sprite
928 // check for unclipped columns 946 // check for unclipped columns
929 947
930 for (x = spr->x1 ; x<=spr->x2 ; x++) { 948 for (x = spr->x1 ; x<=spr->x2 ; x++)
949 {
931 if (clipbot[x] == -2) 950 if (clipbot[x] == -2)
932 clipbot[x] = viewheight; 951 clipbot[x] = viewheight;
933 952
@@ -953,7 +972,7 @@ void R_DrawMasked(void)
953 972
954 // draw all vissprites back to front 973 // draw all vissprites back to front
955 974
956// rendered_vissprites = num_vissprite; 975 // rendered_vissprites = num_vissprite;
957 for (i = num_vissprite ;--i>=0; ) 976 for (i = num_vissprite ;--i>=0; )
958 R_DrawSprite(vissprite_ptrs[i]); // killough 977 R_DrawSprite(vissprite_ptrs[i]); // killough
959 978
diff --git a/apps/plugins/doom/r_things.h b/apps/plugins/doom/r_things.h
index dc93e30d54..c3308744b8 100644
--- a/apps/plugins/doom/r_things.h
+++ b/apps/plugins/doom/r_things.h
@@ -1,80 +1,66 @@
1// Emacs style mode select -*- C++ -*- 1/* Emacs style mode select -*- C++ -*-
2//----------------------------------------------------------------------------- 2 *-----------------------------------------------------------------------------
3// 3 *
4// $Id$ 4 *
5// 5 * PrBoom a Doom port merged with LxDoom and LSDLDoom
6// Copyright (C) 1993-1996 by id Software, Inc. 6 * based on BOOM, a modified and improved DOOM engine
7// 7 * Copyright (C) 1999 by
8// This program is free software; you can redistribute it and/or 8 * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman
9// modify it under the terms of the GNU General Public License 9 * Copyright (C) 1999-2000 by
10// as published by the Free Software Foundation; either version 2 10 * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze
11// of the License, or (at your option) any later version. 11 *
12// 12 * This program is free software; you can redistribute it and/or
13// This program is distributed in the hope that it will be useful, 13 * modify it under the terms of the GNU General Public License
14// but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * as published by the Free Software Foundation; either version 2
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * of the License, or (at your option) any later version.
16// GNU General Public License for more details. 16 *
17// 17 * This program is distributed in the hope that it will be useful,
18// DESCRIPTION: 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19// Rendering of moving objects, sprites. 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20// 20 * GNU General Public License for more details.
21//----------------------------------------------------------------------------- 21 *
22 22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 * 02111-1307, USA.
26 *
27 * DESCRIPTION:
28 * Rendering of moving objects, sprites.
29 *
30 *-----------------------------------------------------------------------------*/
23 31
24#ifndef __R_THINGS__ 32#ifndef __R_THINGS__
25#define __R_THINGS__ 33#define __R_THINGS__
26 34
27
28#ifdef __GNUG__ 35#ifdef __GNUG__
29#pragma interface 36#pragma interface
30#endif 37#endif
31 38
32#define MAXVISSPRITES 128 39/* Constant arrays used for psprite clipping and initializing clipping. */
33/*
34extern vissprite_t vissprites[MAXVISSPRITES];
35extern vissprite_t* vissprite_p;
36extern vissprite_t vsprsortedhead;*/
37
38// Constant arrays used for psprite clipping
39// and initializing clipping.
40extern short negonearray[SCREENWIDTH];
41extern short screenheightarray[SCREENWIDTH];
42
43// vars for R_DrawMaskedColumn
44extern short* mfloorclip;
45extern short* mceilingclip;
46extern fixed_t spryscale;
47extern fixed_t sprtopscreen;
48 40
49extern fixed_t pspritescale; 41extern short negonearray[SCREENWIDTH];
50extern fixed_t pspriteiscale; 42extern short screenheightarray[SCREENWIDTH];
51 43
44/* Vars for R_DrawMaskedColumn */
52 45
53void R_DrawMaskedColumn (const column_t* column); 46extern short *mfloorclip;
54 47extern short *mceilingclip;
55 48extern fixed_t spryscale;
56void R_SortVisSprites (void); 49extern fixed_t sprtopscreen;
50extern fixed_t pspritescale;
51extern fixed_t pspriteiscale;
52/* proff 11/06/98: Added for high-res */
53extern fixed_t pspriteyscale;
57 54
55void R_DrawMaskedColumn(const column_t *column);
56void R_SortVisSprites(void);
58void R_AddSprites(subsector_t* subsec, int lightlevel); 57void R_AddSprites(subsector_t* subsec, int lightlevel);
59void R_AddPSprites (void); 58void R_AddPSprites(void);
60void R_DrawSprites (void); 59void R_DrawSprites(void);
61void R_InitSprites(const char * const * namelist); 60void R_InitSprites(const char * const * namelist);
62void R_ClearSprites (void); 61void R_ClearSprites(void);
63void R_DrawMasked (void); 62void R_DrawMasked(void);
64
65void
66R_ClipVisSprite
67( vissprite_t* vis,
68 int xl,
69 int xh );
70 63
64void R_ClipVisSprite(vissprite_t *vis, int xl, int xh);
71 65
72#endif 66#endif
73//-----------------------------------------------------------------------------
74//
75// $Log$
76// Revision 1.1 2006/03/28 15:44:01 dave
77// Patch #2969 - Doom! Currently only working on the H300.
78//
79//
80//-----------------------------------------------------------------------------
diff --git a/apps/plugins/doom/rockdoom.c b/apps/plugins/doom/rockdoom.c
index 315adb34e0..ae5ea39a66 100644
--- a/apps/plugins/doom/rockdoom.c
+++ b/apps/plugins/doom/rockdoom.c
@@ -176,22 +176,6 @@ cont:
176 } 176 }
177 /* NOTREACHED */ 177 /* NOTREACHED */
178} 178}
179#if 0
180 static char *tp=NULL;
181
182 if(string!=NULL)
183 tp=string;
184
185 while(*tp!=NULL)
186 {
187 if(*tp==*delimiters)
188 break;
189 tp++;
190 }
191 *tp=0;
192 return tp;
193}
194#endif
195 179
196inline void* memcpy(void* dst, const void* src, size_t size) 180inline void* memcpy(void* dst, const void* src, size_t size)
197{ 181{
@@ -415,7 +399,7 @@ int Dbuild_addons(struct opt_items *names)
415 names[0].string=startpt; 399 names[0].string=startpt;
416 names[0].voice_id=0; 400 names[0].voice_id=0;
417 401
418 addons=opendir(GAMEBASE"Addons/"); 402 addons=opendir(GAMEBASE"addons/");
419 if(addons==NULL) 403 if(addons==NULL)
420 return 1; 404 return 1;
421 405
@@ -448,7 +432,7 @@ int Dbuild_demos(struct opt_items *names)
448 names[0].string=startpt; 432 names[0].string=startpt;
449 names[0].voice_id=0; 433 names[0].voice_id=0;
450 434
451 demos=opendir(GAMEBASE"Demos/"); 435 demos=opendir(GAMEBASE"demos/");
452 if(demos==NULL) 436 if(demos==NULL)
453 return 1; 437 return 1;
454 438
diff --git a/apps/plugins/doom/v_video.c b/apps/plugins/doom/v_video.c
index a7dbe84d6a..75ccc3ffda 100644
--- a/apps/plugins/doom/v_video.c
+++ b/apps/plugins/doom/v_video.c
@@ -44,7 +44,7 @@
44#include "m_swap.h" 44#include "m_swap.h"
45#include "rockmacros.h" 45#include "rockmacros.h"
46// Each screen is [SCREENWIDTH*SCREENHEIGHT]; 46// Each screen is [SCREENWIDTH*SCREENHEIGHT];
47byte *screens[6]; 47byte *screens[6] IBSS_ATTR;
48int dirtybox[4]; 48int dirtybox[4];
49 49
50/* jff 4/24/98 initialize this at runtime */ 50/* jff 4/24/98 initialize this at runtime */
@@ -428,22 +428,22 @@ void V_DrawMemPatch(int x, int y, int scrn, const patch_t *patch,
428 y -= SHORT(patch->topoffset); 428 y -= SHORT(patch->topoffset);
429 x -= SHORT(patch->leftoffset); 429 x -= SHORT(patch->leftoffset);
430 430
431 // CPhipps - auto-no-stretch if not high-res 431// // CPhipps - auto-no-stretch if not high-res
432 if (flags & VPT_STRETCH) 432// if (flags & VPT_STRETCH)
433 if ((SCREENWIDTH==320) && (SCREENHEIGHT==200)) 433// if ((SCREENWIDTH==320) && (SCREENHEIGHT==200))
434 flags &= ~VPT_STRETCH; 434// flags &= ~VPT_STRETCH;
435 435
436 // CPhipps - null translation pointer => no translation 436 // CPhipps - null translation pointer => no translation
437 if (!trans) 437 if (!trans)
438 flags &= ~VPT_TRANS; 438 flags &= ~VPT_TRANS;
439 439
440 if (x<0 440// if (x<0
441 ||x+SHORT(patch->width) > ((flags & VPT_STRETCH) ? 320 : SCREENWIDTH) 441// ||x+SHORT(patch->width) > ((flags & VPT_STRETCH) ? 320 : SCREENWIDTH)
442 || y<0 442// || y<0
443 || y+SHORT(patch->height) > ((flags & VPT_STRETCH) ? 200 : SCREENHEIGHT)) 443// || y+SHORT(patch->height) > ((flags & VPT_STRETCH) ? 200 : SCREENHEIGHT))
444 // killough 1/19/98: improved error message: 444// // killough 1/19/98: improved error message:
445 I_Error("V_DrawMemPatch: Patch (%d,%d)-(%d,%d) exceeds LFB" 445// I_Error("V_DrawMemPatch: Patch (%d,%d)-(%d,%d) exceeds LFB"
446 "Bad V_DrawMemPatch (flags=%u)", x, y, x+SHORT(patch->width), y+SHORT(patch->height), flags); 446// "Bad V_DrawMemPatch (flags=%u)", x, y, x+SHORT(patch->width), y+SHORT(patch->height), flags);
447 447
448 if (!(flags & VPT_STRETCH)) { 448 if (!(flags & VPT_STRETCH)) {
449 unsigned int col; 449 unsigned int col;