From 51db2d3f2cfddfb1c94de1085d130c817bcd953f Mon Sep 17 00:00:00 2001 From: Karl Kurbjun Date: Sun, 2 Apr 2006 01:52:44 +0000 Subject: 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 --- apps/plugins/doom/d_main.c | 20 ++-- apps/plugins/doom/doomdef.h | 6 +- apps/plugins/doom/i_system.c | 7 +- apps/plugins/doom/i_video.c | 96 +++------------- apps/plugins/doom/r_bsp.c | 104 ++++++++++------- apps/plugins/doom/r_bsp.h | 20 +--- apps/plugins/doom/r_data.c | 151 +++++++++++++------------ apps/plugins/doom/r_data.h | 6 +- apps/plugins/doom/r_defs.h | 112 +++++++++++-------- apps/plugins/doom/r_draw.c | 53 +++++---- apps/plugins/doom/r_main.c | 36 ++++-- apps/plugins/doom/r_main.h | 2 + apps/plugins/doom/r_plane.c | 20 +++- apps/plugins/doom/r_segs.c | 58 ++++++---- apps/plugins/doom/r_things.c | 259 +++++++++++++++++++++++-------------------- apps/plugins/doom/r_things.h | 112 ++++++++----------- apps/plugins/doom/rockdoom.c | 20 +--- apps/plugins/doom/v_video.c | 24 ++-- 18 files changed, 569 insertions(+), 537 deletions(-) (limited to 'apps/plugins') 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) else if (M_CheckParm ("-deathmatch")) deathmatch = 1; - printf("Welcome to Rockdoom"); + printf("Welcome to Rockdoom\n"); switch ( gamemode ) { case retail: - printf ("The Ultimate DOOM Startup v%d.%d",DVERSION/100,DVERSION%100); + printf ("The Ultimate DOOM Startup v%d.%d\n",DVERSION/100,DVERSION%100); break; case shareware: - printf ("DOOM Shareware Startup v%d.%d",DVERSION/100,DVERSION%100); + printf ("DOOM Shareware Startup v%d.%d\n",DVERSION/100,DVERSION%100); break; case registered: - printf ("DOOM Registered Startup v%d.%d",DVERSION/100,DVERSION%100); + printf ("DOOM Registered Startup v%d.%d\n",DVERSION/100,DVERSION%100); break; case commercial: switch (gamemission) { case pack_plut: - printf ("DOOM 2: Plutonia Experiment v%d.%d",DVERSION/100,DVERSION%100); + printf ("DOOM 2: Plutonia Experiment v%d.%d\n",DVERSION/100,DVERSION%100); break; case pack_tnt: - printf ("DOOM 2: TNT - Evilution v%d.%d",DVERSION/100,DVERSION%100); + printf ("DOOM 2: TNT - Evilution v%d.%d\n",DVERSION/100,DVERSION%100); break; default: - printf ("DOOM 2: Hell on Earth v%d.%d",DVERSION/100,DVERSION%100); + printf ("DOOM 2: Hell on Earth v%d.%d\n",DVERSION/100,DVERSION%100); break; } break; default: - printf ("Public DOOM v%d.%d",DVERSION/100,DVERSION%100); + printf ("Public DOOM v%d.%d\n",DVERSION/100,DVERSION%100); break; } @@ -745,14 +745,14 @@ void D_DoomMainSetup(void) int i; if ( gamemode == shareware) - I_Error("\nYou cannot -file with the shareware version. Register!"); + I_Error("\nYou cannot -file with the shareware version. Register!\n"); // Check for fake IWAD with right name, // but w/o all the lumps of the registered version. if (gamemode == registered) for (i = 0;i < 23; i++) if (W_CheckNumForName(name[i])<0) - I_Error("\nThis is not the registered version."); + I_Error("This is not the registered version.\n"); } // 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 { #define MAX_SCREENWIDTH 1600 #define MAX_SCREENHEIGHT 1200 -#define SCREENWIDTH 320 -#define SCREENHEIGHT 200 +#define SCREENWIDTH LCD_WIDTH +//#define SCREENWIDTH 320 +//#define SCREENHEIGHT 200 +#define SCREENHEIGHT LCD_HEIGHT // The maximum number of players, multiplayer/networking. #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 @@ // GNU General Public License for more details. // // $Log$ -// Revision 1.1 2006/03/28 15:44:01 dave +// Revision 1.2 2006/04/02 01:52:44 kkurbjun +// 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. +// +// Revision 1.1 2006-03-28 15:44:01 dave // Patch #2969 - Doom! Currently only working on the H300. // // @@ -120,7 +123,7 @@ void I_Error (char *error, ...) vsnprintf(p_buf,sizeof(p_buf), error, ap); va_end(ap); - printf("%s",p_buf); + printf("%s\n",p_buf); // Shutdown. Here might be other errors. 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 @@ * GNU General Public License for more details. * * $Log$ - * Revision 1.2 2006/03/28 17:20:49 christian + * Revision 1.3 2006/04/02 01:52:44 kkurbjun + * 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. + * + * Revision 1.2 2006-03-28 17:20:49 christian * added good (tm) button mappings for x5, and added ifdef for HAS_BUTTON_HOLD * * Revision 1.1 2006-03-28 15:44:01 dave @@ -40,51 +43,12 @@ #include "doomdef.h" #include "rockmacros.h" - +#if defined(CPU_COLDFIRE) +static char fastscreen[LCD_WIDTH*LCD_HEIGHT] IBSS_ATTR; +#endif static fb_data palette[256] IBSS_ATTR; static fb_data *paldata=NULL; -#if !defined(CPU_COLDFIRE) || defined(SIMULATOR) -/* - This code is credit to the IDOOM port. It is not used for the H300, but - serves as a good reference point for other targets. -*/ -static fb_data * xtable = 0; -static fb_data * ytable1 = 0; -static fb_data * ytable2 = 0; - -#define FLOOR4(a) \ - (( a >> 2) << 2) - -static int video_w, video_h; - -static void genscalexytable(void) -{ - // shall we use uint8_t intead of ints? - int y = video_h-1; - int x = video_w-1; - int i = 1 + (x>y?x:y); - xtable = malloc(sizeof(int)*video_w ); - ytable1 = malloc(sizeof(int)*video_h ); - ytable2 = malloc(sizeof(int)*video_h ); - - while(i--) - { - if(y>=0) - { - ytable1[y] = ((y*SCREENHEIGHT) / video_h) * SCREENWIDTH; - ytable2[y] = y*video_w; - y--; - } - if(x>=0) - { - xtable[x] = (x*SCREENWIDTH) / video_w; - x--; - } - } -} -#endif - // // I_ShutdownGraphics (NOT USED) // @@ -360,9 +324,7 @@ void I_FinishUpdate (void) { #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) /* - Faster screen update than the lookuptables -> I'm wasting 7 pixels of width - though. This code also doesn't use the framebuffer so rockbox's drawing - functions will not work on top of the doom drawing. + Lookup tables are no longer needed */ // Start the write @@ -373,51 +335,27 @@ void I_FinishUpdate (void) unsigned char *screenptr=screens[0]; int wcnt=0, hcnt=0; - *(volatile unsigned short *) 0xf0000002 = 0; - *(volatile unsigned short *) 0xf0000002 = 0; - *(volatile unsigned short *) 0xf0000002 = 0; - while(hcnt= SCREENHEIGHT - paletteIndex = screens[0][((y*SCREENHEIGHT) / video_h) - * SCREENWIDTH + x]; - rb->lcd_framebuffer[y * video_w + x] = palette[paletteIndex]; -#else - paletteIndex = screens[0][ytable1[y] +xtable[x]]; - rb->lcd_framebuffer[x + ytable2[y]] = palette[paletteIndex]; -#endif + paletteIndex = screens[0][y*SCREENWIDTH + x]; + rb->lcd_framebuffer[y * LCD_WIDTH + x] = palette[paletteIndex]; } } rb->lcd_update(); @@ -454,14 +392,12 @@ void I_InitGraphics(void) printf("Starting Graphics engine\n"); /* Note: The other screens are initialized later */ - screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char)); #if defined(CPU_COLDFIRE) && !defined(SIMULATOR) coldfire_set_macsr(EMAC_FRACTIONAL | EMAC_SATURATE); + screens[0] = fastscreen; #else - - video_h = LCD_HEIGHT; - video_w = FLOOR4(LCD_WIDTH); // From IDOOM, the width has to be a multiple of 4 - genscalexytable(); + // Don't know if this will fit in other IRAMs + screens[0] = malloc (SCREENWIDTH * SCREENHEIGHT * sizeof(unsigned char)); #endif } 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 @@ * *-----------------------------------------------------------------------------*/ -#include "doomdef.h" - +#include "doomstat.h" #include "m_bbox.h" - #include "i_system.h" - #include "r_main.h" +#include "r_segs.h" #include "r_plane.h" #include "r_things.h" - -// State. -#include "doomstat.h" -#include "r_state.h" -#include "r_segs.h" -#include "rockmacros.h" +#include "r_bsp.h" // cph - sanity checking seg_t *curline; side_t *sidedef; @@ -52,14 +45,19 @@ sector_t *frontsector; sector_t *backsector; drawseg_t *ds_p; +// killough 4/7/98: indicates doors closed wrt automap bugfix: +// cph - replaced by linedef rendering flags - int doorclosed; +// killough: New code which removes 2s linedef limit drawseg_t *drawsegs; unsigned maxdrawsegs; +// drawseg_t drawsegs[MAXDRAWSEGS]; // old code -- killough // // R_ClearDrawSegs // -void R_ClearDrawSegs (void) + +void R_ClearDrawSegs(void) { ds_p = drawsegs; } @@ -79,16 +77,24 @@ byte solidcol[SCREENWIDTH] IBSS_ATTR; void R_ClipWallSegment(int first, int last, boolean solid) { byte *p; - while (first < last) { - if (solidcol[first]) { - if (!(p = memchr(solidcol+first, 0, last-first))) return; // All solid + while (first < last) + { + if (solidcol[first]) + { + if (!(p = memchr(solidcol+first, 0, last-first))) + return; // All solid first = p - solidcol; - } else { + } + else + { int to; - if (!(p = memchr(solidcol+first, 1, last-first))) to = last; - else to = p - solidcol; + if (!(p = memchr(solidcol+first, 1, last-first))) + to = last; + else + to = p - solidcol; R_StoreWallRange(first, to-1); - if (solid) { + if (solid) + { memset(solidcol+first,1,to-first); } first = to; @@ -136,7 +142,8 @@ static void R_RecalcLineFlags(void) ) ) linedef->r_flags = RF_CLOSED; - else { + else + { // Reject empty lines used for triggers // and special events. // Identical floor and ceiling on both sides, @@ -151,17 +158,22 @@ static void R_RecalcLineFlags(void) sizeof(frontsector->ceiling_xoffs) + sizeof(frontsector->ceiling_yoffs) + sizeof(frontsector->ceilingpic) + sizeof(frontsector->floorpic) + sizeof(frontsector->lightlevel) + sizeof(frontsector->floorlightsec) + - sizeof(frontsector->ceilinglightsec))) { - linedef->r_flags = 0; return; - } else + sizeof(frontsector->ceilinglightsec))) + { + linedef->r_flags = 0; + return; + } + else linedef->r_flags = RF_IGNORE; } /* cph - I'm too lazy to try and work with offsets in this */ - if (curline->sidedef->rowoffset) return; + if (curline->sidedef->rowoffset) + return; /* Now decide on texture tiling */ - if (linedef->flags & ML_TWOSIDED) { + if (linedef->flags & ML_TWOSIDED) + { int c; /* Does top texture need tiling */ @@ -173,7 +185,9 @@ static void R_RecalcLineFlags(void) if ((c = frontsector->floorheight - backsector->floorheight) > 0 && (textureheight[texturetranslation[curline->sidedef->bottomtexture]] > c)) linedef->r_flags |= RF_BOT_TILE; - } else { + } + else + { int c; /* Does middle texture need tiling */ if ((c = frontsector->ceilingheight - frontsector->floorheight) > 0 && @@ -228,13 +242,17 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, tempsec->floor_xoffs = s->floor_xoffs; tempsec->floor_yoffs = s->floor_yoffs; - if (underwater) { - if (s->ceilingpic == skyflatnum) { + if (underwater) + { + if (s->ceilingpic == skyflatnum) + { tempsec->floorheight = tempsec->ceilingheight+1; tempsec->ceilingpic = tempsec->floorpic; tempsec->ceiling_xoffs = tempsec->floor_xoffs; tempsec->ceiling_yoffs = tempsec->floor_yoffs; - } else { + } + else + { tempsec->ceilingpic = s->ceilingpic; tempsec->ceiling_xoffs = s->ceiling_xoffs; tempsec->ceiling_yoffs = s->ceiling_yoffs; @@ -384,7 +402,8 @@ static void R_AddLine (seg_t *line) static const int checkcoord[12][4] = // killough -- static const { - {3,0,2,1}, + { + 3,0,2,1}, {3,0,2,0}, {3,1,2,0}, {0}, @@ -421,7 +440,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) // cph - replaced old code, which was unclear and badly commented // Much more efficient code now - if ((signed)angle1 < (signed)angle2) { /* it's "behind" us */ + if ((signed)angle1 < (signed)angle2) + { /* it's "behind" us */ /* Either angle1 or angle2 is behind us, so it doesn't matter if we * change it to the corect sign */ @@ -431,10 +451,14 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) angle2 = INT_MIN; } - if ((signed)angle2 >= (signed)clipangle) return false; // Both off left edge - if ((signed)angle1 <= -(signed)clipangle) return false; // Both off right edge - if ((signed)angle1 >= (signed)clipangle) angle1 = clipangle; // Clip at left edge - if ((signed)angle2 <= -(signed)clipangle) angle2 = 0-clipangle; // Clip at right edge + if ((signed)angle2 >= (signed)clipangle) + return false; // Both off left edge + if ((signed)angle1 <= -(signed)clipangle) + return false; // Both off right edge + if ((signed)angle1 >= (signed)clipangle) + angle1 = clipangle; // Clip at left edge + if ((signed)angle2 <= -(signed)clipangle) + angle2 = 0-clipangle; // Clip at right edge // Find the first clippost // that touches the source post @@ -450,7 +474,8 @@ static boolean R_CheckBBox(const fixed_t *bspcoord) if (sx1 == sx2) return false; - if (!memchr(solidcol+sx1, 0, sx2-sx1)) return false; + if (!memchr(solidcol+sx1, 0, sx2-sx1)) + return false; // All columns it covers are already solidly covered } @@ -477,6 +502,7 @@ static void R_Subsector(int num) int ceilinglightlevel; // killough 4/11/98 #ifdef RANGECHECK + if (num>=numsubsectors) I_Error ("R_Subsector: ss %i with numss = %i", num, numsubsectors); #endif @@ -485,7 +511,7 @@ static void R_Subsector(int num) frontsector = sub->sector; count = sub->numlines; line = &segs[sub->firstline]; -// sscount++; + // sscount++; // killough 3/8/98, 4/4/98: Deep water / fake ceiling effect frontsector = R_FakeFlat(frontsector, &tempsec, &floorlightlevel, @@ -497,8 +523,7 @@ static void R_Subsector(int num) floorplane = frontsector->floorheight < viewz || // killough 3/7/98 (frontsector->heightsec != -1 && - sectors[frontsector->heightsec].ceilingpic == skyflatnum) - ? + sectors[frontsector->heightsec].ceilingpic == skyflatnum) ? R_FindPlane(frontsector->floorheight, frontsector->floorpic == skyflatnum && // kilough 10/98 frontsector->sky & PL_SKYFLAT ? frontsector->sky : @@ -511,8 +536,7 @@ static void R_Subsector(int num) ceilingplane = frontsector->ceilingheight > viewz || frontsector->ceilingpic == skyflatnum || (frontsector->heightsec != -1 && - sectors[frontsector->heightsec].floorpic == skyflatnum) - ? + sectors[frontsector->heightsec].floorpic == skyflatnum) ? R_FindPlane(frontsector->ceilingheight, // killough 3/8/98 frontsector->ceilingpic == skyflatnum && // kilough 10/98 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 @@ * *-----------------------------------------------------------------------------*/ - #ifndef __R_BSP__ #define __R_BSP__ @@ -48,28 +47,17 @@ extern boolean segtextured; extern boolean markfloor; /* false if the back side is the same plane */ extern boolean markceiling; -//extern boolean skymap; - /* old code -- killough: * extern drawseg_t drawsegs[MAXDRAWSEGS]; * new code -- killough: */ extern drawseg_t *drawsegs; extern unsigned maxdrawsegs; -extern drawseg_t* ds_p; - -/*extern lighttable_t** hscalelight; -extern lighttable_t** vscalelight; -extern lighttable_t** dscalelight; -*/ - -//typedef void (*drawfunc_t) (int start, int stop); - +extern drawseg_t *ds_p; -// BSP? -void R_ClearClipSegs (void); -void R_ClearDrawSegs (void); -void R_RenderBSPNode (int bspnum); +void R_ClearClipSegs(void); +void R_ClearDrawSegs(void); +void R_RenderBSPNode(int bspnum); int R_DoorClosed(void); /* killough 1/17/98 */ /* 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 short patch; short stepdir; // unused in Doom but might be used in Phase 2 Boom short colormap; // unused in Doom but might be used in Phase 2 Boom -} PACKEDATTR mappatch_t; +} +PACKEDATTR mappatch_t; typedef struct { @@ -74,7 +75,8 @@ typedef struct char pad[4]; // unused in Doom but might be used in Boom Phase 2 short patchcount; mappatch_t patches[1]; -} PACKEDATTR maptexture_t; +} +PACKEDATTR maptexture_t; // A maptexturedef_t describes a rectangular texture, which is composed // of one or more mappatch_t structures that arrange graphic patches. @@ -247,7 +249,8 @@ static void R_GenerateLookup(int texnum, int *const errors) struct { unsigned short patches, posts; - } *count = calloc(sizeof *count, texture->width); + } + *count = calloc(sizeof *count, texture->width); { int i = texture->patchcount; @@ -300,9 +303,11 @@ static void R_GenerateLookup(int texnum, int *const errors) { //jff 8/3/98 use logical output routine printf("\nR_GenerateLookup: Column %d is without a patch in texture %s", - x, texture->name); - if (errors) ++*errors; - else I_Error("R_GenerateLookup: Failed"); + x, texture->name); + if (errors) + ++*errors; + else + I_Error("R_GenerateLookup: Failed"); } if (count[x].patches > 1) // killough 4/9/98 { @@ -333,7 +338,8 @@ static void R_GenerateLookup(int texnum, int *const errors) const byte *R_GetColumn(int tex, int col) { const texture_t *texture = textures[tex]; - if (!texture->columnlump) R_GenerateLookup(tex, NULL); + if (!texture->columnlump) + R_GenerateLookup(tex, NULL); { int lump = texture->columnlump[col &= texture->widthmask]; 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) if ((lump<=0) && (lastlump<=0)) lump = lastlump; // cph - force equal - if (lump != lastlump) { + if (lump != lastlump) + { // cph - must change the cached lump if (lastlump>0) W_UnlockLumpNum(lastlump); @@ -353,9 +360,11 @@ const byte *R_GetColumn(int tex, int col) if ((lastlump = lump) > 0) lastlumpdata = W_CacheLumpNum(lump); #ifdef RANGECHECK + else lastlumpdata = NULL; #endif + } if (lump > 0) @@ -533,12 +542,13 @@ void R_InitTextures (void) { //jff 8/3/98 use logical output routine printf("\nR_InitTextures: Missing patch %d in texture %s", - SHORT(mpatch->patch), texture->name); // killough 4/17/98 + SHORT(mpatch->patch), texture->name); // killough 4/17/98 ++errors; } } - texture->columnofs = NULL; texture->columnlump = NULL; + texture->columnofs = NULL; + texture->columnlump = NULL; for (j=1; j*2 <= texture->width; j<<=1) ; @@ -687,7 +697,8 @@ int R_ColormapNumForName(const char *name) struct _cache { unsigned char pct; unsigned char playpal[256]; -} cache; +} +cache; int tran_filter_pct = 66; // filter percent @@ -712,10 +723,10 @@ void R_InitTranMap(int progress) // Use cached translucency filter if it's available if ((cachefd<0) ? cachefd = open(GAMEBASE"tranmap.dat",O_WRONLY | O_CREAT) , 1 : - read(cachefd, &cache, sizeof(cache)) != sizeof(cache) || - cache.pct != tran_filter_pct || - memcmp(cache.playpal, playpal, sizeof cache.playpal) || - read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98 + read(cachefd, &cache, sizeof(cache)) != sizeof(cache) || + cache.pct != tran_filter_pct || + memcmp(cache.playpal, playpal, sizeof cache.playpal) || + read(cachefd, my_tranmap, 256*256) != 256*256 ) // killough 4/11/98 { 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) if (progress) printf("Please wait: Tranmap build"); // First, convert playpal into long int type, and transpose array, - // for fast inner-loop calculations. Precompute tot array. + // for fast inner-loop calculations. Precompute tot array. { register int i = 255; @@ -749,7 +760,8 @@ void R_InitTranMap(int progress) d += t*t; p -= 3; tot[i] = d << (TSC-1); - } while (--i>=0); + } + while (--i>=0); } // Next, compute all entries using minimum arithmetic. @@ -775,9 +787,10 @@ void R_InitTranMap(int progress) long best = LONG_MAX; do if ((err = tot[color] - pal[0][color]*r - - pal[1][color]*g - pal[2][color]*b) < best) + - pal[1][color]*g - pal[2][color]*b) < best) best = err, *tp = color; - while (--color >= 0); + while (--color >= 0) + ; } } } @@ -886,78 +899,78 @@ int R_TextureNumForName(const char *name) // const added -- killough void R_PrecacheLevel(void) { - register int i; - register byte *hitlist; + register int i; + register byte *hitlist; - if (demoplayback) - return; + if (demoplayback) + return; - { - size_t size = numflats > numsprites ? numflats : numsprites; - hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size); - } - // Precache flats. + { + size_t size = numflats > numsprites ? numflats : numsprites; + hitlist = malloc((size_t)numtextures > size ? (unsigned)numtextures : size); + } + // Precache flats. - memset(hitlist, 0, numflats); + memset(hitlist, 0, numflats); - for (i = numsectors; --i >= 0; ) - hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; + for (i = numsectors; --i >= 0; ) + hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; - for (i = numflats; --i >= 0; ) - if (hitlist[i]) - (W_CacheLumpNum)(firstflat + i, 0); + for (i = numflats; --i >= 0; ) + if (hitlist[i]) + (W_CacheLumpNum)(firstflat + i, 0); - // Precache textures. + // Precache textures. - memset(hitlist, 0, numtextures); + memset(hitlist, 0, numtextures); - for (i = numsides; --i >= 0;) - hitlist[sides[i].bottomtexture] = - hitlist[sides[i].toptexture] = - hitlist[sides[i].midtexture] = 1; + for (i = numsides; --i >= 0;) + hitlist[sides[i].bottomtexture] = + hitlist[sides[i].toptexture] = + hitlist[sides[i].midtexture] = 1; - // Sky texture is always present. - // Note that F_SKY1 is the name used to - // indicate a sky floor/ceiling as a flat, - // while the sky texture is stored like - // a wall texture, with an episode dependend - // name. + // Sky texture is always present. + // Note that F_SKY1 is the name used to + // indicate a sky floor/ceiling as a flat, + // while the sky texture is stored like + // a wall texture, with an episode dependend + // name. - hitlist[skytexture] = 1; + hitlist[skytexture] = 1; - for (i = numtextures; --i >= 0; ) - if (hitlist[i]) + for (i = numtextures; --i >= 0; ) + if (hitlist[i]) { - texture_t *texture = textures[i]; - int j = texture->patchcount; - while (--j >= 0) - (W_CacheLumpNum)(texture->patches[j].patch, 0); + texture_t *texture = textures[i]; + int j = texture->patchcount; + while (--j >= 0) + (W_CacheLumpNum)(texture->patches[j].patch, 0); } - // Precache sprites. - memset(hitlist, 0, numsprites); + // Precache sprites. + memset(hitlist, 0, numsprites); - { - thinker_t *th; - for (th = thinkercap.next ; th != &thinkercap ; th=th->next) - if (th->function == P_MobjThinker) - hitlist[((mobj_t *)th)->sprite] = 1; - } + { + thinker_t *th; + for (th = thinkercap.next ; th != &thinkercap ; th=th->next) + if (th->function == P_MobjThinker) + hitlist[((mobj_t *)th)->sprite] = 1; + } - for (i=numsprites; --i >= 0;) - if (hitlist[i]) + for (i=numsprites; --i >= 0;) + if (hitlist[i]) { - int j = sprites[i].numframes; - while (--j >= 0) - { + int j = sprites[i].numframes; + while (--j >= 0) + { short *sflump = sprites[i].spriteframes[j].lump; int k = 7; do - (W_CacheLumpNum)(firstspritelump + sflump[k], 0); + (W_CacheLumpNum)(firstspritelump + sflump[k], 0); while (--k >= 0); - } + } } - free(hitlist); + free(hitlist); } // 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 { int originx, originy; // Block origin, which has already accounted int patch; // for the internal origin of the patch. -} texpatch_t; +} +texpatch_t; // // Texture definition. @@ -69,7 +70,8 @@ typedef struct short width, height; short patchcount; // All the patches[patchcount] are drawn texpatch_t patches[1]; // back-to-front into the cached texture. -} texture_t; +} +texture_t; // Retrieve column data for span blitting. const 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 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// Refresh/rendering module, shared data struct definitions. -// -//----------------------------------------------------------------------------- +/* Emacs style mode select -*- C++ -*- + *----------------------------------------------------------------------------- + * + * + * PrBoom a Doom port merged with LxDoom and LSDLDoom + * based on BOOM, a modified and improved DOOM engine + * Copyright (C) 1999 by + * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman + * Copyright (C) 1999-2000 by + * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * DESCRIPTION: + * Refresh/rendering module, shared data struct definitions. + * + *-----------------------------------------------------------------------------*/ #ifndef __R_DEFS__ #define __R_DEFS__ @@ -62,18 +71,16 @@ typedef struct { fixed_t x, y; -} vertex_t; - - -// Forward of LineDefs, for Sectors. -struct line_s; +} +vertex_t; // Each sector has a degenmobj_t in its center for sound origin purposes. typedef struct { thinker_t thinker; // not used for anything fixed_t x, y, z; -} degenmobj_t; +} +degenmobj_t; // // The SECTORS record, at runtime. @@ -142,8 +149,8 @@ typedef struct short special; short oldspecial; //jff 2/16/98 remembers if sector WAS secret (automap) short tag; - void* specialdata; // ROCKDOOM obsolete -} sector_t; +} +sector_t; // // The SideDef. @@ -164,7 +171,8 @@ typedef struct int special; -} side_t; +} +side_t; // // Move clipping aid for LineDefs. @@ -201,7 +209,8 @@ typedef struct line_s RF_IGNORE = 8, // Renderer can skip this line RF_CLOSED =16, // Line blocks view } r_flags; -} line_t; +} +line_t; // phares 3/14/98 // @@ -228,7 +237,8 @@ typedef struct msecnode_s struct msecnode_s *m_sprev; // prev msecnode_t for this sector struct msecnode_s *m_snext; // next msecnode_t for this sector boolean visited; // killough 4/4/98, 4/7/98: used in search algorithms -} msecnode_t; +} +msecnode_t; // // The LineSeg. @@ -249,7 +259,8 @@ typedef struct // backsector is NULL for one sided lines sector_t *frontsector, *backsector; -} seg_t; +} +seg_t; // // A SubSector. @@ -263,7 +274,8 @@ typedef struct subsector_s { sector_t *sector; unsigned short numlines, firstline; -} subsector_t; +} +subsector_t; // // BSP node. @@ -273,14 +285,16 @@ typedef struct fixed_t x, y, dx, dy; // Partition line. fixed_t bbox[2][4]; // Bounding box for each child. unsigned short children[2]; // If NF_SUBSECTOR its a subsector. -} node_t; +} +node_t; // posts are runs of non masked source pixels typedef struct { byte topdelta; // -1 is the last post in a column byte length; // length data bytes follows -} post_t; +} +post_t; // column_t is a list of 0 or more post_t, (byte)-1 terminated typedef post_t column_t; @@ -293,7 +307,8 @@ typedef post_t column_t; // Indeed, true color support is posibble // precalculating 24bpp lightmap/colormap LUT. // from darkening PLAYPAL to all black. -// Could even us emore than 32 levels. +// Could use even more than 32 levels. + typedef byte lighttable_t; // @@ -301,7 +316,7 @@ typedef byte lighttable_t; // typedef struct drawseg_s { - seg_t* curline; + seg_t *curline; int x1, x2; fixed_t scale1, scale2, scalestep; int silhouette; // 0=none, 1=bottom, 2=top, 3=both @@ -312,7 +327,8 @@ typedef struct drawseg_s // all three adjusted so [x1] is first value. short *sprtopclip, *sprbottomclip, *maskedtexturecol; -} drawseg_t; +} +drawseg_t; // // Patches. @@ -328,7 +344,8 @@ typedef struct short leftoffset; // pixels to the left of origin short topoffset; // pixels below the origin int columnofs[8]; // only [width] used -} patch_t; +} +patch_t; // proff: Added for OpenGL typedef struct @@ -336,7 +353,8 @@ typedef struct int width,height; int leftoffset,topoffset; int lumpnum; -} patchnum_t; +} +patchnum_t; // // A vissprite_t is a thing that will be drawn during a refresh. @@ -360,7 +378,8 @@ typedef struct vissprite_s // killough 3/27/98: height sector for underwater/fake ceiling support int heightsec; -} vissprite_t; +} +vissprite_t; // // Sprites are patches with a special naming convention @@ -390,7 +409,8 @@ typedef struct // Flip bit (1 = flip) to use for view angles 0-7. byte flip[8]; -} spriteframe_t; +} +spriteframe_t; // // A sprite definition: @@ -401,7 +421,8 @@ typedef struct { int numframes; spriteframe_t *spriteframes; -} spritedef_t; +} +spritedef_t; // // Now what is a visplane, anyway? @@ -417,6 +438,7 @@ typedef struct visplane unsigned short pad2, pad3; // killough 2/8/98, 4/25/98 unsigned short bottom[SCREENWIDTH]; unsigned short pad4; -} visplane_t; +} +visplane_t; #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 @@ //#include "lprintf.h" #include "rockmacros.h" -#define MAXWIDTH 1120 -#define MAXHEIGHT 832 - -// status bar height at bottom of screen -#define SBARHEIGHT 32 - // // All drawing to the view buffer is accomplished in this file. // The other refresh files only know about ccordinates, @@ -113,9 +107,10 @@ void R_DrawColumn (void) return; #ifdef RANGECHECK + if ((unsigned)dc_x >= SCREENWIDTH - || dc_yl < 0 - || dc_yh >= SCREENHEIGHT) + || dc_yl < 0 + || dc_yh >= SCREENHEIGHT) I_Error ("R_DrawColumn: %d to %d at %d", dc_yl, dc_yh, dc_x); #endif @@ -127,6 +122,7 @@ void R_DrawColumn (void) // Determine scaling, // which is the only mapping to be done. #define fracstep dc_iscale + frac = dc_texturemid + (dc_yl-centery)*fracstep; // Inner loop that does the actual texture mapping, @@ -135,21 +131,27 @@ void R_DrawColumn (void) // // killough 2/1/98: more performance tuning - if (dc_texheight == 128) { + if (dc_texheight == 128) + { while(count--) { *dest = dc_colormap[dc_source[(frac>>FRACBITS)&127]]; frac += fracstep; dest += SCREENWIDTH; } - } else if (dc_texheight == 0) { + } + else if (dc_texheight == 0) + { /* cph - another special case */ - while (count--) { + while (count--) + { *dest = dc_colormap[dc_source[frac>>FRACBITS]]; frac += fracstep; dest += SCREENWIDTH; } - } else { + } + else + { register unsigned heightmask = dc_texheight-1; // CPhipps - specify type if (! (dc_texheight & heightmask) ) // power of 2 -- killough { @@ -167,7 +169,8 @@ void R_DrawColumn (void) heightmask <<= FRACBITS; if (frac < 0) - while ((frac += heightmask) < 0); + while ((frac += heightmask) < 0) + ; else while (frac >= (int)heightmask) frac -= heightmask; @@ -215,6 +218,7 @@ void R_DrawTLColumn (void) return; #ifdef RANGECHECK + if ((unsigned)dc_x >= (unsigned)SCREENWIDTH || dc_yl < 0 || dc_yh >= SCREENHEIGHT) @@ -227,6 +231,7 @@ void R_DrawTLColumn (void) // Determine scaling, // which is the only mapping to be done. #define fracstep dc_iscale + frac = dc_texturemid + (dc_yl-centery)*fracstep; // Inner loop that does the actual texture mapping, @@ -245,7 +250,8 @@ void R_DrawTLColumn (void) heightmask <<= FRACBITS; if (frac < 0) - while ((frac += heightmask) < 0); + while ((frac += heightmask) < 0) + ; else while (frac >= (int)heightmask) frac -= heightmask; @@ -336,6 +342,7 @@ void R_DrawFuzzColumn(void) return; #ifdef RANGECHECK + if ((unsigned) dc_x >= (unsigned)SCREENWIDTH || dc_yl < 0 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT) @@ -377,7 +384,8 @@ void R_DrawFuzzColumn(void) dest += SCREENWIDTH; frac += fracstep; - } while (count--); + } + while (count--); } // @@ -404,6 +412,7 @@ void R_DrawTranslatedColumn (void) return; #ifdef RANGECHECK + if ((unsigned)dc_x >= (unsigned)SCREENWIDTH || dc_yl < 0 || (unsigned)dc_yh >= (unsigned)SCREENHEIGHT) @@ -449,6 +458,7 @@ void R_InitTranslationTables (void) { int i, j; #define MAXTRANS 3 + byte transtocolour[MAXTRANS]; // killough 5/2/98: @@ -457,15 +467,20 @@ void R_InitTranslationTables (void) if (translationtables == NULL) // CPhipps - allow multiple calls translationtables = Z_Malloc(256*MAXTRANS, PU_STATIC, 0); - for (i=0; i>= LIGHTSCALESHIFT)/DISTMAP; + int t, level = startmap - j*320/viewwidth/DISTMAP; if (level < 0) level = 0; @@ -410,12 +422,14 @@ void R_Init (void) // CPhipps - R_DrawColumn isn't constant anymore, so must // initialise in code colfunc = R_DrawColumn; // current column draw function - if (SCREENWIDTH<320) - I_Error("R_Init: Screenwidth(%d) < 320",SCREENWIDTH); +// if (SCREENWIDTH<320) +// I_Error("R_Init: Screenwidth(%d) < 320",SCREENWIDTH); #if 1 + printf("\nR_LoadTrigTables: "); R_LoadTrigTables(); #endif + printf("\nR_InitData: "); R_InitData(); 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; extern fixed_t centerxfrac; extern fixed_t centeryfrac; extern fixed_t projection; +// proff 11/06/98: Added for high-res +extern fixed_t projectiony; extern int validcount; extern int linecount; extern 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) unsigned index; #ifdef RANGECHECK + if (x2 < x1 || x1<0 || x2>=viewwidth || (unsigned)y>(unsigned)viewheight) I_Error ("R_MapPlane: %i, %i at %i",x1,x2,y); #endif @@ -295,10 +296,13 @@ visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop) for (x=intrl ; x <= intrh && pl->top[x] == 0xffff; x++) ; - if (x > intrh) { /* Can use existing plane; extend range */ - pl->minx = unionl; pl->maxx = unionh; + if (x > intrh) + { /* Can use existing plane; extend range */ + pl->minx = unionl; + pl->maxx = unionh; return pl; - } else /* Cannot use existing plane; create a new one */ + } + else /* Cannot use existing plane; create a new one */ return R_DupPlane(pl,start,stop); } @@ -323,8 +327,10 @@ static void R_MakeSpans(int x, int t1, int b1, int t2, int b2) static void R_DoDrawPlane(visplane_t *pl) { register int x; - if (pl->minx <= pl->maxx) { - if (pl->picnum == skyflatnum || pl->picnum & PL_SKYFLAT) { // sky flat + if (pl->minx <= pl->maxx) + { + if (pl->picnum == skyflatnum || pl->picnum & PL_SKYFLAT) + { // sky flat int texture; angle_t an, flip; @@ -390,7 +396,9 @@ static void R_DoDrawPlane(visplane_t *pl) ANGLETOSKYSHIFT); colfunc(); } - } else { // regular flat + } + else + { // regular flat int stop, light; 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; // rw_distance must be calculated first. // // killough 5/2/98: reformatted, cleaned up -static fixed_t R_ScaleFromGlobalAngle (angle_t visangle) +// CPhipps - moved here from r_main.c + +static fixed_t R_ScaleFromGlobalAngle(angle_t visangle) { - int anglea = ANG90 + (visangle-viewangle); - int angleb = ANG90 + (visangle-rw_normalangle); - int sinea = finesine[anglea>>ANGLETOFINESHIFT]; - int sineb = finesine[angleb>>ANGLETOFINESHIFT]; - fixed_t num = FixedMul(projection,sineb); - int den = FixedMul(rw_distance,sinea); - - return den > num>>16 ? (num=FixedDiv (num, den)) > 64*FRACUNIT ? - 64*FRACUNIT : num < 256 ? 256 : num : 64*FRACUNIT ; + int anglea = ANG90 + (visangle-viewangle); + int angleb = ANG90 + (visangle-rw_normalangle); + int den = FixedMul(rw_distance, finesine[anglea>>ANGLETOFINESHIFT]); + // proff 11/06/98: Changed for high-res + fixed_t num = FixedMul(projectiony, finesine[angleb>>ANGLETOFINESHIFT]); + return den > num>>16 ? (num = FixedDiv(num, den)) > 64*FRACUNIT ? + 64*FRACUNIT : num < 256 ? 256 : num : 64*FRACUNIT; } + // // R_RenderMaskedSegRange // @@ -146,11 +147,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, int x1, int x2) // killough 4/13/98: get correct lightlevel for 2s normal textures lightnum = (R_FakeFlat(frontsector, &tempsec, NULL, NULL, false) - ->lightlevel >> LIGHTSEGSHIFT)+extralight; + ->lightlevel >> LIGHTSEGSHIFT)+extralight; /* cph - ...what is this for? adding contrast to rooms? * It looks crap in outdoor areas */ - if (fake_contrast) { + if (fake_contrast) + { if (curline->v1->y == curline->v2->y) lightnum--; else @@ -402,8 +404,10 @@ static void R_RenderSegLoop (void) // cph - if we completely blocked further sight through this column, // add this info to the solid columns array for r_bsp.c if ((markceiling || markfloor) && - (floorclip[rw_x] <= ceilingclip[rw_x] + 1)) { - solidcol[rw_x] = 1; didsolidcol = 1; + (floorclip[rw_x] <= ceilingclip[rw_x] + 1)) + { + solidcol[rw_x] = 1; + didsolidcol = 1; } // save texturecol for backdrawing of masked mid texture @@ -460,6 +464,7 @@ void R_StoreWallRange(const int start, const int stop) #ifdef RANGECHECK + if (start >=viewwidth || start > stop) I_Error ("Bad R_RenderWallRange: %i to %i", start , stop); #endif @@ -574,7 +579,8 @@ void R_StoreWallRange(const int start, const int stop) ds_p->sprtopclip = ds_p->sprbottomclip = NULL; ds_p->silhouette = 0; - if (linedef->r_flags & RF_CLOSED) { /* cph - closed 2S line e.g. door */ + if (linedef->r_flags & RF_CLOSED) + { /* cph - closed 2S line e.g. door */ // cph - killough's (outdated) comment follows - this deals with both // "automap fixes", his and mine // killough 1/17/98: this test is required if the fix @@ -589,7 +595,9 @@ void R_StoreWallRange(const int start, const int stop) ds_p->sprtopclip = screenheightarray; ds_p->tsilheight = INT_MIN; - } else { /* not solid - old code */ + } + else + { /* not solid - old code */ if (frontsector->floorheight > backsector->floorheight) { @@ -721,7 +729,8 @@ void R_StoreWallRange(const int start, const int stop) /* cph - ...what is this for? adding contrast to rooms? * It looks crap in outdoor areas */ - if (fake_contrast) { + if (fake_contrast) + { if (curline->v1->y == curline->v2->y) lightnum--; else if (curline->v1->x == curline->v2->x) @@ -778,14 +787,16 @@ void R_StoreWallRange(const int start, const int stop) } // render it - if (markceiling) { + if (markceiling) + { if (ceilingplane) // killough 4/11/98: add NULL ptr checks ceilingplane = R_CheckPlane (ceilingplane, rw_x, rw_stopx-1); else markceiling = 0; } - if (markfloor) { + if (markfloor) + { if (floorplane) // killough 4/11/98: add NULL ptr checks /* cph 2003/04/18 - ceilingplane and floorplane might be the same * 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) R_RenderSegLoop(); /* cph - if a column was made solid by this wall, we _must_ save full clipping info */ - if (backsector && didsolidcol) { - if (!(ds_p->silhouette & SIL_BOTTOM)) { + if (backsector && didsolidcol) + { + if (!(ds_p->silhouette & SIL_BOTTOM)) + { ds_p->silhouette |= SIL_BOTTOM; ds_p->bsilheight = backsector->floorheight; } - if (!(ds_p->silhouette & SIL_TOP)) { + if (!(ds_p->silhouette & SIL_TOP)) + { ds_p->silhouette |= SIL_TOP; ds_p->tsilheight = backsector->ceilingheight; } 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 { int column; int topclip; int bottomclip; -} maskdraw_t; +} +maskdraw_t; // // Sprite rotation 0 is facing the viewer, @@ -63,6 +64,8 @@ typedef struct { // fixed_t pspritescale; fixed_t pspriteiscale; +// proff 11/06/98: Added for high-res +fixed_t pspriteyscale; static lighttable_t** spritelights; @@ -95,33 +98,33 @@ static void R_InstallSpriteLump(int lump, unsigned frame, unsigned rotation, boolean flipped) { - if (frame >= MAX_SPRITE_FRAMES || rotation > 8) - I_Error("R_InstallSpriteLump: Bad frame characters in lump %i", lump); + if (frame >= MAX_SPRITE_FRAMES || rotation > 8) + I_Error("R_InstallSpriteLump: Bad frame characters in lump %i", lump); if ((int)frame > maxframe) maxframe = frame; - if (rotation == 0) - { // the lump should be used for all rotations + if (rotation == 0) + { // the lump should be used for all rotations int r; for (r=0 ; r<8 ; r++) - if (sprtemp[frame].lump[r]==-1) - { + if (sprtemp[frame].lump[r]==-1) + { sprtemp[frame].lump[r] = lump - firstspritelump; sprtemp[frame].flip[r] = (byte) flipped; sprtemp[frame].rotate = false; //jff 4/24/98 if any subbed, rotless - } + } return; - } + } - // the lump is only used for one rotation + // the lump is only used for one rotation - if (sprtemp[frame].lump[--rotation] == -1) - { + if (sprtemp[frame].lump[--rotation] == -1) + { sprtemp[frame].lump[rotation] = lump - firstspritelump; sprtemp[frame].flip[rotation] = (byte) flipped; sprtemp[frame].rotate = true; //jff 4/24/98 only change if rot used - } + } } // @@ -152,110 +155,114 @@ static void R_InstallSpriteLump(int lump, unsigned frame, void R_InitSpriteDefs(const char * const * namelist) { - size_t numentries = lastspritelump-firstspritelump+1; - struct { int index, next; } *hash; - int i; + size_t numentries = lastspritelump-firstspritelump+1; + struct { + int index, next; + } + *hash; + int i; - if (!numentries || !*namelist) - return; + if (!numentries || !*namelist) + return; - // count the number of sprite names - for (i=0; namelist[i]; i++) - ; + // count the number of sprite names + for (i=0; namelist[i]; i++) + ; - numsprites = i; + numsprites = i; - sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); + sprites = Z_Malloc(numsprites *sizeof(*sprites), PU_STATIC, NULL); - // Create hash table based on just the first four letters of each sprite - // killough 1/31/98 + // Create hash table based on just the first four letters of each sprite + // killough 1/31/98 - hash = malloc(sizeof(*hash)*numentries); // allocate hash table + hash = malloc(sizeof(*hash)*numentries); // allocate hash table - for (i=0; (size_t)i= 0) - { - memset(sprtemp, -1, sizeof(sprtemp)); - maxframe = -1; - do - { - register lumpinfo_t *lump = lumpinfo + j + firstspritelump; + { + memset(sprtemp, -1, sizeof(sprtemp)); + maxframe = -1; + do + { + register lumpinfo_t *lump = lumpinfo + j + firstspritelump; - // Fast portable comparison -- killough - // (using int pointer cast is nonportable): + // Fast portable comparison -- killough + // (using int pointer cast is nonportable): - if (!((lump->name[0] ^ spritename[0]) | - (lump->name[1] ^ spritename[1]) | - (lump->name[2] ^ spritename[2]) | - (lump->name[3] ^ spritename[3]))) - { + if (!((lump->name[0] ^ spritename[0]) | + (lump->name[1] ^ spritename[1]) | + (lump->name[2] ^ spritename[2]) | + (lump->name[3] ^ spritename[3]))) + { + R_InstallSpriteLump(j+firstspritelump, + lump->name[4] - 'A', + lump->name[5] - '0', + false); + if (lump->name[6]) R_InstallSpriteLump(j+firstspritelump, - lump->name[4] - 'A', - lump->name[5] - '0', - false); - if (lump->name[6]) - R_InstallSpriteLump(j+firstspritelump, - lump->name[6] - 'A', - lump->name[7] - '0', - true); - } + lump->name[6] - 'A', + lump->name[7] - '0', + true); } - while ((j = hash[j].next) >= 0); + } + while ((j = hash[j].next) >= 0) + ; - // check the frames that were found for completeness - if ((sprites[i].numframes = ++maxframe)) // killough 1/31/98 - { - int frame; - for (frame = 0; frame < maxframe; frame++) - switch ((int) sprtemp[frame].rotate) + // check the frames that were found for completeness + if ((sprites[i].numframes = ++maxframe)) // killough 1/31/98 + { + int frame; + for (frame = 0; frame < maxframe; frame++) + switch ((int) sprtemp[frame].rotate) + { + case -1: + // no rotations were found for that frame at all + I_Error ("R_InitSprites: No patches found " + "for %.8s frame %c", namelist[i], frame+'A'); + break; + + case 0: + // only the first rotation is needed + break; + + case 1: + // must have all 8 frames { - case -1: - // no rotations were found for that frame at all - I_Error ("R_InitSprites: No patches found " - "for %.8s frame %c", namelist[i], frame+'A'); - break; - - case 0: - // only the first rotation is needed - break; - - case 1: - // must have all 8 frames - { - int rotation; - for (rotation=0 ; rotation<8 ; rotation++) + int rotation; + for (rotation=0 ; rotation<8 ; rotation++) if (sprtemp[frame].lump[rotation] == -1) - I_Error ("R_InitSprites: Sprite %.8s frame %c " - "is missing rotations", - namelist[i], frame+'A'); - break; - } + I_Error ("R_InitSprites: Sprite %.8s frame %c " + "is missing rotations", + namelist[i], frame+'A'); + break; } - // allocate space for the frames present and copy sprtemp to it - sprites[i].spriteframes = - Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); - memcpy (sprites[i].spriteframes, sprtemp, - maxframe*sizeof(spriteframe_t)); - } - } - } + } + // allocate space for the frames present and copy sprtemp to it + sprites[i].spriteframes = + Z_Malloc (maxframe * sizeof(spriteframe_t), PU_STATIC, NULL); + memcpy (sprites[i].spriteframes, sprtemp, + maxframe*sizeof(spriteframe_t)); + } + } + } free(hash); // free hash table } @@ -313,13 +320,13 @@ fixed_t sprtopscreen; void R_DrawMaskedColumn(const column_t *column) { - int topscreen; - int bottomscreen; - fixed_t basetexturemid = dc_texturemid; + int topscreen; + int bottomscreen; + fixed_t basetexturemid = dc_texturemid; - dc_texheight = 0; // killough 11/98 - while (column->topdelta != 0xff) - { + dc_texheight = 0; // killough 11/98 + while (column->topdelta != 0xff) + { // calculate unclipped screen coordinates for post topscreen = sprtopscreen + spryscale*column->topdelta; bottomscreen = topscreen + spryscale*column->length; @@ -328,24 +335,24 @@ void R_DrawMaskedColumn(const column_t *column) dc_yh = (bottomscreen-1)>>FRACBITS; if (dc_yh >= mfloorclip[dc_x]) - dc_yh = mfloorclip[dc_x]-1; + dc_yh = mfloorclip[dc_x]-1; if (dc_yl <= mceilingclip[dc_x]) - dc_yl = mceilingclip[dc_x]+1; + dc_yl = mceilingclip[dc_x]+1; // killough 3/2/98, 3/27/98: Failsafe against overflow/crash: if (dc_yl <= dc_yh && dc_yh < viewheight) - { - dc_source = (byte *)column + 3; - dc_texturemid = basetexturemid - (column->topdelta<topdelta<length + 4); - } - dc_texturemid = basetexturemid; + } + dc_texturemid = basetexturemid; } // @@ -384,10 +391,10 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2) } else colfunc = R_DrawColumn; // killough 3/14/98, 4/11/98 - + // proff 11/06/98: Changed for high-res - dc_iscale = D_abs(vis->xiscale); + dc_iscale = FixedDiv (FRACUNIT, vis->scale); dc_texturemid = vis->texturemid; frac = vis->startfrac; spryscale = vis->scale; @@ -398,6 +405,7 @@ void R_DrawVisSprite(vissprite_t *vis, int x1, int x2) texturecolumn = frac>>FRACBITS; #ifdef RANGECHECK + if (texturecolumn < 0 || texturecolumn >= SHORT(patch->width)) I_Error ("R_DrawSpriteRange: Bad texturecolumn"); #endif @@ -428,8 +436,10 @@ void R_ProjectSprite (mobj_t* thing) boolean flip; vissprite_t *vis; #ifndef GL_DOOM + fixed_t iscale; #endif + int heightsec; // killough 3/27/98 // transform the origin point @@ -457,6 +467,7 @@ void R_ProjectSprite (mobj_t* thing) // decide which patch to use for sprite relative to player #ifdef RANGECHECK + if ((unsigned) thing->sprite >= (unsigned)numsprites) I_Error ("R_ProjectSprite: Invalid sprite number %i", thing->sprite); #endif @@ -464,6 +475,7 @@ void R_ProjectSprite (mobj_t* thing) sprdef = &sprites[thing->sprite]; #ifdef RANGECHECK + if ((thing->frame&FF_FRAMEMASK) >= sprdef->numframes) I_Error ("R_ProjectSprite: Invalid sprite frame %i : %i", thing->sprite, thing->frame); @@ -538,7 +550,7 @@ void R_ProjectSprite (mobj_t* thing) vis->mobjflags = thing->flags; // proff 11/06/98: Changed for high-res - vis->scale = xscale; + vis->scale = FixedDiv(projectiony, tz); vis->gx = thing->x; vis->gy = thing->y; vis->gz = thing->z; @@ -634,6 +646,7 @@ void R_DrawPSprite (pspdef_t *psp) // decide which patch to use #ifdef RANGECHECK + if ( (unsigned)psp->state->sprite >= (unsigned)numsprites) I_Error ("R_ProjectSprite: Invalid sprite number %i", psp->state->sprite); #endif @@ -641,6 +654,7 @@ void R_DrawPSprite (pspdef_t *psp) sprdef = &sprites[psp->state->sprite]; #ifdef RANGECHECK + if ( (psp->state->frame & FF_FRAMEMASK) >= sprdef->numframes) I_Error ("R_ProjectSprite: Invalid sprite frame %i : %li", psp->state->sprite, psp->state->frame); @@ -677,7 +691,7 @@ void R_DrawPSprite (pspdef_t *psp) vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth-1 : x2; // proff 11/06/98: Added for high-res - vis->scale = pspritescale; + vis->scale = pspriteyscale; if (flip) { @@ -760,7 +774,8 @@ static void msort(vissprite_t **s, vissprite_t **t, int n) msort(s2, t, n2); while ((*s1)->scale > (*s2)->scale ? - (*d++ = *s1++, --n1) : (*d++ = *s2++, --n2)); + (*d++ = *s1++, --n1) : (*d++ = *s2++, --n2)) + ; if (n2) bcopyp(d, s2, n2); @@ -778,7 +793,8 @@ static void msort(vissprite_t **s, vissprite_t **t, int n) if (s[i-1]->scale < temp->scale) { int j = i; - while ((s[j] = s[j-1])->scale < temp->scale && --j); + while ((s[j] = s[j-1])->scale < temp->scale && --j) + ; s[j] = temp; } } @@ -893,7 +909,8 @@ void R_DrawSprite (vissprite_t* spr) int phs = viewplayer->mo->subsector->sector->heightsec; if ((mh = sectors[spr->heightsec].floorheight) > spr->gz && (h = centeryfrac - FixedMul(mh-=viewz, spr->scale)) >= 0 && - (h >>= FRACBITS) < viewheight) { + (h >>= FRACBITS) < viewheight) + { if (mh <= 0 || (phs != -1 && viewz > sectors[phs].floorheight)) { // clip bottom for (x=spr->x1 ; x<=spr->x2 ; x++) @@ -909,7 +926,8 @@ void R_DrawSprite (vissprite_t* spr) if ((mh = sectors[spr->heightsec].ceilingheight) < spr->gzt && (h = centeryfrac - FixedMul(mh-viewz, spr->scale)) >= 0 && - (h >>= FRACBITS) < viewheight) { + (h >>= FRACBITS) < viewheight) + { if (phs != -1 && viewz >= sectors[phs].ceilingheight) { // clip bottom for (x=spr->x1 ; x<=spr->x2 ; x++) @@ -927,7 +945,8 @@ void R_DrawSprite (vissprite_t* spr) // all clipping has been performed, so draw the sprite // check for unclipped columns - for (x = spr->x1 ; x<=spr->x2 ; x++) { + for (x = spr->x1 ; x<=spr->x2 ; x++) + { if (clipbot[x] == -2) clipbot[x] = viewheight; @@ -953,7 +972,7 @@ void R_DrawMasked(void) // draw all vissprites back to front -// rendered_vissprites = num_vissprite; + // rendered_vissprites = num_vissprite; for (i = num_vissprite ;--i>=0; ) R_DrawSprite(vissprite_ptrs[i]); // killough 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 @@ -// Emacs style mode select -*- C++ -*- -//----------------------------------------------------------------------------- -// -// $Id$ -// -// Copyright (C) 1993-1996 by id Software, Inc. -// -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// DESCRIPTION: -// Rendering of moving objects, sprites. -// -//----------------------------------------------------------------------------- - +/* Emacs style mode select -*- C++ -*- + *----------------------------------------------------------------------------- + * + * + * PrBoom a Doom port merged with LxDoom and LSDLDoom + * based on BOOM, a modified and improved DOOM engine + * Copyright (C) 1999 by + * id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman + * Copyright (C) 1999-2000 by + * Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + * + * DESCRIPTION: + * Rendering of moving objects, sprites. + * + *-----------------------------------------------------------------------------*/ #ifndef __R_THINGS__ #define __R_THINGS__ - #ifdef __GNUG__ #pragma interface #endif -#define MAXVISSPRITES 128 -/* -extern vissprite_t vissprites[MAXVISSPRITES]; -extern vissprite_t* vissprite_p; -extern vissprite_t vsprsortedhead;*/ - -// Constant arrays used for psprite clipping -// and initializing clipping. -extern short negonearray[SCREENWIDTH]; -extern short screenheightarray[SCREENWIDTH]; - -// vars for R_DrawMaskedColumn -extern short* mfloorclip; -extern short* mceilingclip; -extern fixed_t spryscale; -extern fixed_t sprtopscreen; +/* Constant arrays used for psprite clipping and initializing clipping. */ -extern fixed_t pspritescale; -extern fixed_t pspriteiscale; +extern short negonearray[SCREENWIDTH]; +extern short screenheightarray[SCREENWIDTH]; +/* Vars for R_DrawMaskedColumn */ -void R_DrawMaskedColumn (const column_t* column); - - -void R_SortVisSprites (void); +extern short *mfloorclip; +extern short *mceilingclip; +extern fixed_t spryscale; +extern fixed_t sprtopscreen; +extern fixed_t pspritescale; +extern fixed_t pspriteiscale; +/* proff 11/06/98: Added for high-res */ +extern fixed_t pspriteyscale; +void R_DrawMaskedColumn(const column_t *column); +void R_SortVisSprites(void); void R_AddSprites(subsector_t* subsec, int lightlevel); -void R_AddPSprites (void); -void R_DrawSprites (void); +void R_AddPSprites(void); +void R_DrawSprites(void); void R_InitSprites(const char * const * namelist); -void R_ClearSprites (void); -void R_DrawMasked (void); - -void -R_ClipVisSprite -( vissprite_t* vis, - int xl, - int xh ); +void R_ClearSprites(void); +void R_DrawMasked(void); +void R_ClipVisSprite(vissprite_t *vis, int xl, int xh); #endif -//----------------------------------------------------------------------------- -// -// $Log$ -// Revision 1.1 2006/03/28 15:44:01 dave -// Patch #2969 - Doom! Currently only working on the H300. -// -// -//----------------------------------------------------------------------------- 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: } /* NOTREACHED */ } -#if 0 - static char *tp=NULL; - - if(string!=NULL) - tp=string; - - while(*tp!=NULL) - { - if(*tp==*delimiters) - break; - tp++; - } - *tp=0; - return tp; -} -#endif inline void* memcpy(void* dst, const void* src, size_t size) { @@ -415,7 +399,7 @@ int Dbuild_addons(struct opt_items *names) names[0].string=startpt; names[0].voice_id=0; - addons=opendir(GAMEBASE"Addons/"); + addons=opendir(GAMEBASE"addons/"); if(addons==NULL) return 1; @@ -448,7 +432,7 @@ int Dbuild_demos(struct opt_items *names) names[0].string=startpt; names[0].voice_id=0; - demos=opendir(GAMEBASE"Demos/"); + demos=opendir(GAMEBASE"demos/"); if(demos==NULL) return 1; 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 @@ #include "m_swap.h" #include "rockmacros.h" // Each screen is [SCREENWIDTH*SCREENHEIGHT]; -byte *screens[6]; +byte *screens[6] IBSS_ATTR; int dirtybox[4]; /* 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, y -= SHORT(patch->topoffset); x -= SHORT(patch->leftoffset); - // CPhipps - auto-no-stretch if not high-res - if (flags & VPT_STRETCH) - if ((SCREENWIDTH==320) && (SCREENHEIGHT==200)) - flags &= ~VPT_STRETCH; +// // CPhipps - auto-no-stretch if not high-res +// if (flags & VPT_STRETCH) +// if ((SCREENWIDTH==320) && (SCREENHEIGHT==200)) +// flags &= ~VPT_STRETCH; // CPhipps - null translation pointer => no translation if (!trans) flags &= ~VPT_TRANS; - if (x<0 - ||x+SHORT(patch->width) > ((flags & VPT_STRETCH) ? 320 : SCREENWIDTH) - || y<0 - || y+SHORT(patch->height) > ((flags & VPT_STRETCH) ? 200 : SCREENHEIGHT)) - // killough 1/19/98: improved error message: - I_Error("V_DrawMemPatch: Patch (%d,%d)-(%d,%d) exceeds LFB" - "Bad V_DrawMemPatch (flags=%u)", x, y, x+SHORT(patch->width), y+SHORT(patch->height), flags); +// if (x<0 +// ||x+SHORT(patch->width) > ((flags & VPT_STRETCH) ? 320 : SCREENWIDTH) +// || y<0 +// || y+SHORT(patch->height) > ((flags & VPT_STRETCH) ? 200 : SCREENHEIGHT)) +// // killough 1/19/98: improved error message: +// I_Error("V_DrawMemPatch: Patch (%d,%d)-(%d,%d) exceeds LFB" +// "Bad V_DrawMemPatch (flags=%u)", x, y, x+SHORT(patch->width), y+SHORT(patch->height), flags); if (!(flags & VPT_STRETCH)) { unsigned int col; -- cgit v1.2.3