Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

DOOM Classic Mode with 24bpp color #2

Open
wants to merge 4 commits into from

1 participant

@JamesDunne

This work precalculates a 24bpp colormap (in I_SetPalette) in order to use 24bpp RGB values for lighting instead of the palette mapping table from the COLORMAP lump.

Full disclosure

  • The fuzz effect has been modified slightly; the original COLORMAP lump is still loaded primarily for this purpose.
  • NUMCOLORMAPS is increased from 32 to 64; produces smoother lighting.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  doomclassic/doom/am_map.cpp
@@ -713,7 +713,7 @@ void AM_Ticker (void)
//
void AM_clearFB(int color)
{
- memset(::g->fb, color, ::g->f_w*::g->f_h);
+ memset(::g->fb, color, ::g->f_w*::g->f_h * sizeof(colormapindex_t));
}
View
1  doomclassic/doom/d_main.cpp
@@ -265,7 +265,6 @@ void D_Display (void)
R_DrawViewBorder (); // erase old menu stuff
::g->borderdrawcount--;
}
-
}
::g->menuactivestate = ::g->menuactive;
View
4 doomclassic/doom/defs.h
@@ -230,7 +230,9 @@ If you have questions concerning this license or the applicable additional terms
#define MAX_ADJOINING_SECTORS 20
// p_spec.defs end //
// p_user.defs begin //
-#define INVERSECOLORMAP 32
+
+// CHANGE(jsd): Was 32 for COLORMAP index
+#define INVERSECOLORMAP (NUMCOLORMAPS)
// DHM - NERVE :: MAXBOB reduced 25%
//#define MAXBOB 0x100000
View
31 doomclassic/doom/f_finale.cpp
@@ -333,8 +333,8 @@ void F_Ticker (void)
void F_TextWrite (void)
{
byte* src;
- byte* dest;
-
+ colormapindex_t* dest;
+
int x,y,w;
int count;
const char* ch;
@@ -352,16 +352,23 @@ void F_TextWrite (void)
for (y=0 ; y<SCREENHEIGHT ; y++)
{
- for (x=0 ; x<SCREENWIDTH/64 ; x++)
- {
- memcpy (dest, src+((y&63)<<6), 64);
- dest += 64;
- }
- if (SCREENWIDTH&63)
- {
- memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63);
- dest += (SCREENWIDTH&63);
- }
+#if 0
+ for (x=0 ; x<SCREENWIDTH/64 ; x++)
+ {
+ memcpy (dest, src+((y&63)<<6), 64);
+ dest += 64;
+ }
+ if (SCREENWIDTH&63)
+ {
+ memcpy (dest, src+((y&63)<<6), SCREENWIDTH&63);
+ dest += (SCREENWIDTH&63);
+ }
+#else
+ for (x=0 ; x<SCREENWIDTH; x++)
+ {
+ *dest++ = (src+((y&63)<<6))[x & 63];
+ }
+#endif
}
V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
View
38 doomclassic/doom/f_wipe.cpp
@@ -43,31 +43,27 @@ If you have questions concerning this license or the applicable additional terms
// when zero, stop the wipe
-
void
wipe_shittyColMajorXform
-( short* array,
+( colormapindex_t* array,
int width,
int height )
{
int x;
int y;
- short* dest;
+ colormapindex_t* dest;
- //dest = (short*) DoomLib::Z_Malloc(width*height*2, PU_STATIC, 0 );
- dest = new short[ width * height ];
+ dest = new colormapindex_t[ width * height ];
for(y=0;y<height;y++)
for(x=0;x<width;x++)
dest[x*height+y] = array[y*width+x];
- memcpy(array, dest, width*height*2);
+ memcpy(array, dest, width*height*sizeof(colormapindex_t));
- //Z_Free(dest);
delete[] dest;
}
-
int
wipe_initMelt
( int width,
@@ -77,13 +73,13 @@ wipe_initMelt
int i, r;
// copy start screen to main screen
- memcpy(::g->wipe_scr, ::g->wipe_scr_start, width*height);
-
+ memcpy(::g->wipe_scr, ::g->wipe_scr_start, width*height*sizeof(colormapindex_t));
+
// makes this wipe faster (in theory)
// to have stuff in column-major format
- wipe_shittyColMajorXform((short*)::g->wipe_scr_start, width/2, height);
- wipe_shittyColMajorXform((short*)::g->wipe_scr_end, width/2, height);
-
+ wipe_shittyColMajorXform(::g->wipe_scr_start, width, height);
+ wipe_shittyColMajorXform(::g->wipe_scr_end, width, height);
+
// setup initial column positions
// (::g->wipe_y<0 => not ready to scroll yet)
::g->wipe_y = (int *) DoomLib::Z_Malloc(width*sizeof(int), PU_STATIC, 0);
@@ -101,7 +97,6 @@ wipe_initMelt
else if (::g->wipe_y[i] == -16)
::g->wipe_y[i] = -15;
}
-
return 0;
}
@@ -111,12 +106,10 @@ int wipe_doMelt( int width, int height, int ticks ) {
int dy;
int idx;
- short* s;
- short* d;
+ colormapindex_t* s;
+ colormapindex_t* d;
qboolean done = true;
- width/=2;
-
while (ticks--)
{
for (i=0;i<width;i++)
@@ -133,8 +126,8 @@ int wipe_doMelt( int width, int height, int ticks ) {
if (::g->wipe_y[i]+dy >= height)
dy = height - ::g->wipe_y[i];
- s = &((short *)::g->wipe_scr_end)[i*height+::g->wipe_y[i]];
- d = &((short *)::g->wipe_scr)[::g->wipe_y[i]*width+i];
+ s = &(::g->wipe_scr_end)[i*height+::g->wipe_y[i]];
+ d = &(::g->wipe_scr)[::g->wipe_y[i]*width+i];
idx = 0;
for (j=dy;j;j--)
@@ -145,8 +138,8 @@ int wipe_doMelt( int width, int height, int ticks ) {
::g->wipe_y[i] += dy;
- s = &((short *)::g->wipe_scr_start)[i*height];
- d = &((short *)::g->wipe_scr)[::g->wipe_y[i]*width+i];
+ s = &(::g->wipe_scr_start)[i*height];
+ d = &(::g->wipe_scr)[::g->wipe_y[i]*width+i];
idx = 0;
for (j=height-::g->wipe_y[i];j;j--)
@@ -232,4 +225,3 @@ wipe_ScreenWipe
return !::g->go;
}
-
View
4 doomclassic/doom/g_game.cpp
@@ -1398,7 +1398,7 @@ qboolean G_DoLoadGame ()
::g->gameaction = ga_nothing;
- M_ReadFile (::g->savename, &::g->savebuffer);
+ M_ReadFile (::g->savename, &::g->savebuffer);
waitingForWipe = true;
@@ -1509,7 +1509,7 @@ qboolean G_DoSaveGame (void)
}
- ::g->save_p = ::g->savebuffer = ::g->screens[1];
+ ::g->save_p = ::g->savebuffer = (byte*) ::g->screens[1];
memcpy (::g->save_p, description, SAVESTRINGSIZE);
::g->save_p += SAVESTRINGSIZE;
View
2  doomclassic/doom/i_video.h
@@ -54,7 +54,7 @@ void I_FinishUpdate (void);
// Wait for vertical retrace or pause a bit.
void I_WaitVBL(int count);
-void I_ReadScreen (byte* scr);
+void I_ReadScreen (colormapindex_t* scr);
void I_BeginRead (void);
void I_EndRead (void);
View
40 doomclassic/doom/i_video_ps3.cpp
@@ -144,9 +144,9 @@ void I_FinishUpdate (void)
//
// I_ReadScreen
//
-void I_ReadScreen (byte* scr)
+void I_ReadScreen (colormapindex_t* scr)
{
- memcpy(scr, ::g->screens[0], SCREENWIDTH*SCREENHEIGHT);
+ memcpy(scr, ::g->screens[0], SCREENWIDTH*SCREENHEIGHT * sizeof(colormapindex_t));
}
inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g, unsigned int b ) {
@@ -165,19 +165,31 @@ inline unsigned int I_PackColor( unsigned int a, unsigned int r, unsigned int g,
//
void I_SetPalette (byte* palette)
{
-
int i;
-
- // set the X colormap entries
- for (i=0 ; i<256 ; i++)
- {
- int r,b,g;
- r = gammatable[::g->usegamma][*palette++];
- g = gammatable[::g->usegamma][*palette++];
- b = gammatable[::g->usegamma][*palette++];
- ::g->XColorMap[i] = I_PackColor(0xff, r, g, b);
- }
-
+ int scale;
+
+ for (int c = 0; c < NUMCOLORMAPS; ++c)
+ {
+ // Find the darkening scale for this colormap:
+ scale = (256 - (256 / NUMCOLORMAPS) * c);
+
+ // set the X colormap entries
+ for (i = 0; i < 256; ++i)
+ {
+ int r,b,g;
+
+ r = palette[i*3+0];
+ g = palette[i*3+1];
+ b = palette[i*3+2];
+
+ // Darken the color to black according to light level [0..(NUMCOLORMAPS-1)] where 0 is full bright and (NUMCOLORMAPS-1) is full dark:
+ r = gammatable[::g->usegamma][(r * scale) / 256];
+ g = gammatable[::g->usegamma][(g * scale) / 256];
+ b = gammatable[::g->usegamma][(b * scale) / 256];
+
+ ::g->XColorMap[c * 256 + i] = I_PackColor(0xff, r, g, b);
+ }
+ }
}
void I_InitGraphics()
View
22 doomclassic/doom/r_data.cpp
@@ -569,14 +569,23 @@ void R_InitSpriteLumps (void)
void R_InitColormaps (void)
{
int lump, length;
-
+
// Load in the light tables,
// 256 byte align tables.
lump = W_GetNumForName("COLORMAP");
length = W_LumpLength (lump) + 255;
- ::g->colormaps = (lighttable_t*)DoomLib::Z_Malloc (length, PU_STATIC, 0);
- ::g->colormaps = (byte *)( ((int)::g->colormaps + 255)&~0xff);
- W_ReadLump (lump,::g->colormaps);
+ ::g->stored_colormaps = (byte*)DoomLib::Z_Malloc (length, PU_STATIC, 0);
+ ::g->stored_colormaps = (byte*)( ((int)::g->stored_colormaps + 255)&~0xff);
+ W_ReadLump (lump,::g->stored_colormaps);
+
+ // Calculate 24bpp colormaps as identity functions:
+ ::g->colormaps = (lighttable_t*)DoomLib::Z_Malloc (256 * (NUMCOLORMAPS + 1) * sizeof(lighttable_t), PU_STATIC, 0);
+ for (int c = 0; c < NUMCOLORMAPS; ++c)
+ for (int i = 0; i < 256; ++i)
+ ::g->colormaps[c * 256 + i] = c * 256 + i;
+ // Setup the inverse colormap for invulnerable mode:
+ for (int i = 0; i < 256; ++i)
+ ::g->colormaps[(INVERSECOLORMAP * 256) + i] = ::g->stored_colormaps[(32 * 256) + i];
}
@@ -769,8 +778,3 @@ void R_PrecacheLevel (void)
}
}
}
-
-
-
-
-
View
14 doomclassic/doom/r_defs.h
@@ -305,16 +305,10 @@ typedef post_t postColumn_t;
//
// OTHER TYPES
//
-
-// This could be wider for >8 bit display.
-// Indeed, true color support is posibble
-// precalculating 24bpp lightmap/colormap LUT.
-// from darkening PLAYPAL to all black.
-// Could even us emore than 32 levels.
-typedef byte lighttable_t;
-
-
-
+// ADD(jsd): colormapindex_t represents a index into the final palette (which can be > 256 colors for 32bpp lightmapping)
+typedef unsigned int colormapindex_t;
+// CHANGE(jsd): Alias of colormapindex_t; was byte
+typedef colormapindex_t lighttable_t;
//
// ?
View
88 doomclassic/doom/r_draw.cpp
@@ -87,7 +87,7 @@ void R_DrawColumn ( lighttable_t * dc_colormap,
byte * dc_source )
{
int count;
- byte* dest;
+ colormapindex_t* dest;
fixed_t frac;
fixed_t fracstep;
@@ -197,8 +197,8 @@ void R_DrawColumnLow ( lighttable_t * dc_colormap,
byte * dc_source )
{
int count;
- byte* dest;
- byte* dest2;
+ colormapindex_t* dest;
+ colormapindex_t* dest2;
fixed_t frac;
fixed_t fracstep;
@@ -259,7 +259,7 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
byte * dc_source )
{
int count;
- byte* dest;
+ colormapindex_t* dest;
fixed_t frac;
fixed_t fracstep;
@@ -329,7 +329,14 @@ void R_DrawFuzzColumn ( lighttable_t * dc_colormap,
// a pixel that is either one column
// left or right of the current one.
// Add index from colormap to index.
- *dest = ::g->colormaps[6*256+dest[::g->fuzzoffset[::g->fuzzpos]]];
+ //*dest = ::g->colormaps[6*256+dest[::g->fuzzoffset[::g->fuzzpos]]];
+
+ colormapindex_t curr = dest[::g->fuzzoffset[::g->fuzzpos]];
+ int level = ((curr >> 8) - 3);
+ if (level < 0) level = 0;
+
+ //*dest = (curr & 255) + (level * 256);
+ *dest = ::g->stored_colormaps[6*256+ (curr & 255)] + (level * 256);
// Clamp table lookup index.
if (++::g->fuzzpos == FUZZTABLE)
@@ -358,7 +365,7 @@ void R_DrawTranslatedColumn ( lighttable_t * dc_colormap,
byte * dc_source )
{
int count;
- byte* dest;
+ colormapindex_t* dest;
fixed_t frac;
fixed_t fracstep;
@@ -481,18 +488,18 @@ void R_InitTranslationTables (void)
//
// Draws the actual span.
void R_DrawSpan ( fixed_t xfrac,
- fixed_t yfrac,
- fixed_t ds_y,
- int ds_x1,
- int ds_x2,
- fixed_t ds_xstep,
- fixed_t ds_ystep,
- lighttable_t * ds_colormap,
- byte * ds_source )
+ fixed_t yfrac,
+ fixed_t ds_y,
+ int ds_x1,
+ int ds_x2,
+ fixed_t ds_xstep,
+ fixed_t ds_ystep,
+ lighttable_t * ds_colormap,
+ byte * ds_source )
{
- byte* dest;
- int count;
- int spot;
+ colormapindex_t* dest;
+ int count;
+ int spot;
#ifdef RANGECHECK
if (::g->ds_x2 < ::g->ds_x1
@@ -511,11 +518,13 @@ void R_DrawSpan ( fixed_t xfrac,
// We do not check for zero spans here?
count = ds_x2 - g->ds_x1;
+ /*
if ( ds_x2 < ds_x1 ) {
return; // SMF - think this is the sky
}
+ */
- do
+ do
{
// Current texture index in u,v.
spot = ((yfrac>>(16-6))&(63*64)) + ((xfrac>>16)&63);
@@ -528,7 +537,7 @@ void R_DrawSpan ( fixed_t xfrac,
xfrac += ds_xstep;
yfrac += ds_ystep;
- } while (count--);
+ } while (count--);
}
@@ -619,7 +628,7 @@ void R_DrawSpanLow ( fixed_t xfrac,
lighttable_t * ds_colormap,
byte * ds_source )
{
- byte* dest;
+ colormapindex_t* dest;
int count;
int spot;
@@ -701,9 +710,9 @@ R_InitBuffer
// Also draws a beveled edge.
//
void R_FillBackScreen (void)
-{
+{
byte* src;
- byte* dest;
+ colormapindex_t* dest;
int x;
int y;
int width, height, windowx, windowy;
@@ -727,17 +736,22 @@ void R_FillBackScreen (void)
src = (byte*)W_CacheLumpName (name, PU_CACHE_SHARED);
dest = ::g->screens[1];
- for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) {
- for (x=0 ; x<SCREENWIDTH/64 ; x++) {
- memcpy(dest, src+((y&63)<<6), 64);
- dest += 64;
- }
- if (SCREENWIDTH&63)
- {
- memcpy(dest, src+((y&63)<<6), SCREENWIDTH&63);
- dest += (SCREENWIDTH&63);
- }
- }
+ for (y=0 ; y<SCREENHEIGHT-SBARHEIGHT ; y++) {
+#if 0
+ for (x=0 ; x<SCREENWIDTH/64 ; x++) {
+ memcpy(dest, src+((y&63)<<6), 64);
+ dest += 64;
+ }
+ if (SCREENWIDTH&63)
+ {
+ memcpy(dest, src+((y&63)<<6), SCREENWIDTH&63);
+ dest += (SCREENWIDTH&63);
+ }
+#else
+ for (x=0 ; x<SCREENWIDTH ; x++)
+ *dest++ = (colormapindex_t) (src+((y&63)<<6))[x & 63];
+#endif
+ }
width = ::g->scaledviewwidth / GLOBAL_IMAGE_SCALER;
height = ::g->viewheight / GLOBAL_IMAGE_SCALER;
@@ -769,7 +783,7 @@ void R_FillBackScreen (void)
V_DrawPatch(windowx+width, windowy-8, 1, (patch_t*)W_CacheLumpName ("brdr_tr",PU_CACHE_SHARED));
V_DrawPatch(windowx-8, windowy+height, 1, (patch_t*)W_CacheLumpName ("brdr_bl",PU_CACHE_SHARED));
V_DrawPatch (windowx+width, windowy+height, 1, (patch_t*)W_CacheLumpName ("brdr_br",PU_CACHE_SHARED));
-}
+}
//
@@ -779,14 +793,14 @@ void
R_VideoErase
( unsigned ofs,
int count )
-{
+{
// LFB copy.
// This might not be a good idea if memcpy
// is not optiomal, e.g. byte by byte on
// a 32bit CPU, as GNU GCC/Linux libc did
// at one point.
- memcpy(::g->screens[0]+ofs, ::g->screens[1]+ofs, count);
-}
+ memcpy(::g->screens[0]+ofs, ::g->screens[1]+ofs, count * sizeof(colormapindex_t));
+}
//
View
3  doomclassic/doom/r_main.cpp
@@ -841,8 +841,7 @@ void R_SetupFrame (player_t* player)
if (player->fixedcolormap)
{
::g->fixedcolormap =
- ::g->colormaps
- + player->fixedcolormap*256*sizeof(lighttable_t);
+ ::g->colormaps + player->fixedcolormap*256;
::g->walllights = ::g->scalelightfixed;
View
2  doomclassic/doom/r_main.h
@@ -90,7 +90,7 @@ extern lighttable_t* fixedcolormap;
// Number of diminishing brightness levels.
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
-#define NUMCOLORMAPS 32
+#define NUMCOLORMAPS 64
// Blocky/low detail mode.
View
72 doomclassic/doom/r_plane.cpp
@@ -113,24 +113,14 @@ R_MapPlane
}
//#endif
- if (::g->planeheight != ::g->cachedheight[y])
- {
- ::g->cachedheight[y] = ::g->planeheight;
- distance = ::g->cacheddistance[y] = FixedMul (::g->planeheight, ::g->yslope[y]);
- ::g->ds_xstep = ::g->cachedxstep[y] = FixedMul (distance,::g->basexscale);
- ::g->ds_ystep = ::g->cachedystep[y] = FixedMul (distance,::g->baseyscale);
- }
- else
- {
- distance = ::g->cacheddistance[y];
- ::g->ds_xstep = ::g->cachedxstep[y];
- ::g->ds_ystep = ::g->cachedystep[y];
- }
-
- extern angle_t GetViewAngle();
+ distance = FixedMul (::g->planeheight, ::g->yslope[y]);
+ ::g->ds_xstep = FixedMul (distance,::g->basexscale);
+ ::g->ds_ystep = FixedMul (distance,::g->baseyscale);
+
+ extern angle_t GetViewAngle();
length = FixedMul (distance,::g->distscale[x1]);
angle = (GetViewAngle() + ::g->xtoviewangle[x1])>>ANGLETOFINESHIFT;
- extern fixed_t GetViewX(); extern fixed_t GetViewY();
+ extern fixed_t GetViewX(); extern fixed_t GetViewY();
::g->ds_xfrac = GetViewX() + FixedMul(finecosine[angle], length);
::g->ds_yfrac = -GetViewY() - FixedMul(finesine[angle], length);
@@ -145,7 +135,7 @@ R_MapPlane
::g->ds_colormap = ::g->planezlight[index];
}
-
+
::g->ds_y = y;
::g->ds_x1 = x1;
::g->ds_x2 = x2;
@@ -160,7 +150,7 @@ R_MapPlane
::g->ds_xstep,
::g->ds_ystep,
::g->ds_colormap,
- ::g->ds_source );
+ ::g->ds_source );
}
@@ -180,16 +170,16 @@ void R_ClearPlanes (void)
::g->ceilingclip[i] = -1;
}
- ::g->lastvisplane = ::g->visplanes;
+ ::g->lastvisplane = ::g->visplanes;
::g->lastopening = ::g->openings;
// texture calculation
memset (::g->cachedheight, 0, sizeof(::g->cachedheight));
// left to right mapping
- extern angle_t GetViewAngle();
+ extern angle_t GetViewAngle();
angle = (GetViewAngle()-ANG90)>>ANGLETOFINESHIFT;
-
+
// scale will be unit scale at SCREENWIDTH/2 distance
::g->basexscale = FixedDiv (finecosine[angle],::g->centerxfrac);
::g->baseyscale = -FixedDiv (finesine[angle],::g->centerxfrac);
@@ -205,26 +195,26 @@ visplane_t* R_FindPlane( fixed_t height, int picnum, int lightlevel ) {
visplane_t* check;
if (picnum == ::g->skyflatnum) {
- height = 0; // all skys map together
- lightlevel = 0;
- }
+ height = 0; // all skys map together
+ lightlevel = 0;
+ }
- for (check=::g->visplanes; check < ::g->lastvisplane; check++) {
- if (height == check->height && picnum == check->picnum && lightlevel == check->lightlevel) {
- break;
- }
+ for (check=::g->visplanes; check < ::g->lastvisplane; check++) {
+ if (height == check->height && picnum == check->picnum && lightlevel == check->lightlevel) {
+ break;
}
+ }
- if (check < ::g->lastvisplane)
- return check;
+ if (check < ::g->lastvisplane)
+ return check;
//if (::g->lastvisplane - ::g->visplanes == MAXVISPLANES)
- //I_Error ("R_FindPlane: no more visplanes");
- if ( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES ) {
- check = ::g->visplanes;
- return check;
- }
-
+ //I_Error ("R_FindPlane: no more visplanes");
+ if ( ::g->lastvisplane - ::g->visplanes == MAXVISPLANES ) {
+ check = ::g->visplanes;
+ return check;
+ }
+
::g->lastvisplane++;
check->height = height;
@@ -329,7 +319,7 @@ R_MakeSpans
R_MapPlane (b1,::g->spanstart[b1],x-1);
b1--;
}
-
+
while (t2 < t1 && t2<=b2)
{
::g->spanstart[t2] = x;
@@ -355,7 +345,7 @@ void R_DrawPlanes (void)
int x;
int stop;
int angle;
-
+
#ifdef RANGECHECK
if (::g->ds_p - ::g->drawsegs > MAXDRAWSEGS)
I_Error ("R_DrawPlanes: ::g->drawsegs overflow (%i)",
@@ -403,12 +393,12 @@ void R_DrawPlanes (void)
}
continue;
}
-
+
// regular flat
::g->ds_source = (byte*)W_CacheLumpNum(::g->firstflat +
::g->flattranslation[pl->picnum],
PU_CACHE_SHARED);
-
+
::g->planeheight = abs(pl->height-::g->viewz);
light = (pl->lightlevel >> LIGHTSEGSHIFT)+::g->extralight;
@@ -422,7 +412,7 @@ void R_DrawPlanes (void)
pl->top[pl->maxx+1] = 0xffff;
pl->top[pl->minx-1] = 0xffff;
-
+
stop = pl->maxx + 1;
for (x=pl->minx ; x<= stop ; x++)
View
4 doomclassic/doom/st_stuff.cpp
@@ -1274,8 +1274,8 @@ void ST_Init (void)
{
::g->veryfirsttime = 0;
ST_loadData();
- ::g->screens[4] = (byte *) DoomLib::Z_Malloc( SCREENWIDTH * SCREENHEIGHT /*ST_WIDTH*ST_HEIGHT*/, PU_STATIC, 0);
- memset( ::g->screens[4], 0, SCREENWIDTH * SCREENHEIGHT );
+ ::g->screens[4] = (colormapindex_t *) DoomLib::Z_Malloc( SCREENWIDTH * SCREENHEIGHT * sizeof(colormapindex_t) /*ST_WIDTH*ST_HEIGHT*/, PU_STATIC, 0);
+ memset( ::g->screens[4], 0, SCREENWIDTH * SCREENHEIGHT * sizeof(colormapindex_t) );
}
View
66 doomclassic/doom/v_video.cpp
@@ -164,8 +164,8 @@ V_CopyRect
int desty,
int destscrn )
{
- byte* src;
- byte* dest;
+ colormapindex_t* src;
+ colormapindex_t* dest;
#ifdef RANGECHECK
if (srcx<0
@@ -181,7 +181,7 @@ V_CopyRect
I_Error ("Bad V_CopyRect");
}
#endif
- V_MarkRect (destx, desty, width, height);
+ V_MarkRect (destx, desty, width, height);
// SMF - rewritten for scaling
srcx *= GLOBAL_IMAGE_SCALER;
@@ -191,16 +191,16 @@ V_CopyRect
width *= GLOBAL_IMAGE_SCALER;
height *= GLOBAL_IMAGE_SCALER;
- src = ::g->screens[srcscrn] + srcy * SCREENWIDTH + srcx;
- dest = ::g->screens[destscrn] + desty * SCREENWIDTH + destx;
+ src = ::g->screens[srcscrn] + srcy * SCREENWIDTH + srcx;
+ dest = ::g->screens[destscrn] + desty * SCREENWIDTH + destx;
+
+ for ( ; height>0 ; height--) {
+ memcpy(dest, src, width * sizeof(colormapindex_t));
+ src += SCREENWIDTH;
+ dest += SCREENWIDTH;
+ }
+}
- for ( ; height>0 ; height--) {
- memcpy(dest, src, width);
- src += SCREENWIDTH;
- dest += SCREENWIDTH;
- }
-}
-
//
// V_DrawPatch
@@ -433,10 +433,10 @@ V_DrawBlock
int scrn,
int width,
int height,
- byte* src )
+ colormapindex_t* src )
{
- byte* dest;
-
+ colormapindex_t* dest;
+
#ifdef RANGECHECK
if (x<0
||x+width >SCREENWIDTH
@@ -447,16 +447,16 @@ V_DrawBlock
I_Error ("Bad V_DrawBlock");
}
#endif
-
+
V_MarkRect (x, y, width, height);
-
+
dest = ::g->screens[scrn] + y*SCREENWIDTH+x;
- while (height--)
- {
- memcpy(dest, src, width);
- src += width;
- dest += SCREENWIDTH;
+ while (height--)
+ {
+ memcpy(dest, src, width * sizeof(colormapindex_t));
+ src += width;
+ dest += SCREENWIDTH;
}
}
@@ -473,10 +473,10 @@ V_GetBlock
int scrn,
int width,
int height,
- byte* dest )
+ colormapindex_t* dest )
{
- byte* src;
-
+ colormapindex_t* src;
+
#ifdef RANGECHECK
if (x<0
||x+width >SCREENWIDTH
@@ -487,14 +487,14 @@ V_GetBlock
I_Error ("Bad V_DrawBlock");
}
#endif
-
+
src = ::g->screens[scrn] + y*SCREENWIDTH+x;
- while (height--)
- {
- memcpy(dest, src, width);
- src += SCREENWIDTH;
- dest += width;
+ while (height--)
+ {
+ memcpy(dest, src, width * sizeof(colormapindex_t));
+ src += SCREENWIDTH;
+ dest += width;
}
}
@@ -507,11 +507,11 @@ V_GetBlock
void V_Init (void)
{
int i;
- byte* base;
+ colormapindex_t* base;
// stick these in low dos memory on PCs
- base = (byte*)DoomLib::Z_Malloc(SCREENWIDTH*SCREENHEIGHT*4, PU_STATIC, 0);
+ base = (colormapindex_t *)DoomLib::Z_Malloc(SCREENWIDTH*SCREENHEIGHT*sizeof(colormapindex_t)*4, PU_STATIC, 0);
for (i=0 ; i<4 ; i++)
::g->screens[i] = base + i*SCREENWIDTH*SCREENHEIGHT;
View
6 doomclassic/doom/v_video.h
@@ -48,7 +48,7 @@ If you have questions concerning this license or the applicable additional terms
-extern byte* screens[5];
+extern colormapindex_t* screens[5];
extern int dirtybox[4];
@@ -95,7 +95,7 @@ V_DrawBlock
int scrn,
int width,
int height,
- byte* src );
+ colormapindex_t* src );
// Reads a linear block of pixels into the view buffer.
void
@@ -105,7 +105,7 @@ V_GetBlock
int scrn,
int width,
int height,
- byte* dest );
+ colormapindex_t* dest );
void
View
17 doomclassic/doom/vars.h
@@ -44,7 +44,7 @@ int f_y;
int f_w;
int f_h;
int lightlev; // used for funky strobing effect
-byte* fb; // pseudo-frame buffer
+colormapindex_t* fb; // pseudo-frame buffer
int amclock;
mpoint_t m_paninc; // how far the window pans each tic (map coords)
fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords)
@@ -175,9 +175,9 @@ int laststage;
// f_finale.vars end //
// f_wipe.vars begin //
qboolean go ;
-byte* wipe_scr_start;
-byte* wipe_scr_end;
-byte* wipe_scr;
+colormapindex_t* wipe_scr_start;
+colormapindex_t* wipe_scr_end;
+colormapindex_t* wipe_scr;
void *g_tempPointer;
int* wipe_y;
// f_wipe.vars end //
@@ -312,7 +312,7 @@ int current_time ;
// i_system.vars end //
// i_video_xbox.vars begin //
-unsigned int XColorMap[256];
+unsigned int XColorMap[256 * NUMCOLORMAPS];
unsigned int *ImageBuff;
unsigned int *ImageBuffs[2];
@@ -565,6 +565,7 @@ fixed_t* spritewidth;
fixed_t* spriteoffset;
fixed_t* spritetopoffset;
lighttable_t *colormaps;
+byte *stored_colormaps;
int flatmemory;
int texturememory;
int spritememory;
@@ -576,7 +577,7 @@ int scaledviewwidth;
int viewheight;
int viewwindowx;
int viewwindowy;
-byte* ylookup[MAXHEIGHT];
+colormapindex_t* ylookup[MAXHEIGHT];
int columnofs[MAXWIDTH];
byte translations[3][256];
lighttable_t* dc_colormap;
@@ -780,8 +781,8 @@ int numChannels;
int nextcleanup;
// s_sound.vars end //
// v_video.vars begin //
-byte* screens[5];
-int dirtybox[4];
+colormapindex_t* screens[5];
+int dirtybox[4];
int usegamma;
// v_video.vars end //
// wi_stuff.vars begin //
View
2  doomclassic/doom/wi_stuff.cpp
@@ -270,7 +270,7 @@ void localCalculateAchievements(bool epComplete)
void WI_slamBackground(void)
{
- memcpy(::g->screens[0], ::g->screens[1], SCREENWIDTH * SCREENHEIGHT);
+ memcpy(::g->screens[0], ::g->screens[1], SCREENWIDTH * SCREENHEIGHT * sizeof(colormapindex_t));
V_MarkRect (0, 0, SCREENWIDTH, SCREENHEIGHT);
}
View
2  doomclassic/doom/z_zone.cpp
@@ -76,7 +76,7 @@ void *I_ZoneBase( int *size )
{
enum
{
- HEAP_SIZE = 15 * 1024 * 1024 // SMF - was 10 * 1024 * 1024
+ HEAP_SIZE = 20 * 1024 * 1024 // SMF - was 10 * 1024 * 1024
};
*size = HEAP_SIZE;
return malloc( HEAP_SIZE );
View
49 neo/framework/common_frame.cpp
@@ -710,38 +710,35 @@ void idCommonLocal::RunDoomClassicFrame() {
static int doomTics = 0;
if( DoomLib::expansionDirty ) {
-
// re-Initialize the Doom Engine.
DoomLib::Interface.Shutdown();
DoomLib::Interface.Startup( 1, false );
DoomLib::expansionDirty = false;
}
-
- if ( DoomLib::Interface.Frame( doomTics, &userCmdMgr ) ) {
- Globals *data = (Globals*)DoomLib::GetGlobalData( 0 );
-
- idArray< unsigned int, 256 > palette;
- std::copy( data->XColorMap, data->XColorMap + palette.Num(), palette.Ptr() );
-
- // Do the palette lookup.
- for ( int row = 0; row < DOOMCLASSIC_RENDERHEIGHT; ++row ) {
- for ( int column = 0; column < DOOMCLASSIC_RENDERWIDTH; ++column ) {
- const int doomScreenPixelIndex = row * DOOMCLASSIC_RENDERWIDTH + column;
- const byte paletteIndex = data->screens[0][doomScreenPixelIndex];
- const unsigned int paletteColor = palette[paletteIndex];
- const byte red = (paletteColor & 0xFF000000) >> 24;
- const byte green = (paletteColor & 0x00FF0000) >> 16;
- const byte blue = (paletteColor & 0x0000FF00) >> 8;
-
- const int imageDataPixelIndex = row * DOOMCLASSIC_RENDERWIDTH * DOOMCLASSIC_BYTES_PER_PIXEL + column * DOOMCLASSIC_BYTES_PER_PIXEL;
- doomClassicImageData[imageDataPixelIndex] = red;
- doomClassicImageData[imageDataPixelIndex + 1] = green;
- doomClassicImageData[imageDataPixelIndex + 2] = blue;
- doomClassicImageData[imageDataPixelIndex + 3] = 255;
- }
- }
- }
+ if ( DoomLib::Interface.Frame( doomTics, &userCmdMgr ) ) {
+ Globals *data = (Globals*)DoomLib::GetGlobalData( 0 );
+
+ // Do the palette lookup.
+ for ( int row = 0; row < DOOMCLASSIC_RENDERHEIGHT; ++row ) {
+ for ( int column = 0; column < DOOMCLASSIC_RENDERWIDTH; ++column ) {
+ const int doomScreenPixelIndex = row * DOOMCLASSIC_RENDERWIDTH + column;
+ const colormapindex_t paletteIndex = data->screens[0][doomScreenPixelIndex];
+
+ const unsigned int paletteColor = data->XColorMap[paletteIndex];
+
+ const byte red = (paletteColor & 0xFF000000) >> 24;
+ const byte green = (paletteColor & 0x00FF0000) >> 16;
+ const byte blue = (paletteColor & 0x0000FF00) >> 8;
+
+ const int imageDataPixelIndex = row * DOOMCLASSIC_RENDERWIDTH * DOOMCLASSIC_BYTES_PER_PIXEL + column * DOOMCLASSIC_BYTES_PER_PIXEL;
+ doomClassicImageData[imageDataPixelIndex] = red;
+ doomClassicImageData[imageDataPixelIndex + 1] = green;
+ doomClassicImageData[imageDataPixelIndex + 2] = blue;
+ doomClassicImageData[imageDataPixelIndex + 3] = 255;
+ }
+ }
+ }
renderSystem->UploadImage( "_doomClassic", doomClassicImageData.Ptr(), DOOMCLASSIC_RENDERWIDTH, DOOMCLASSIC_RENDERHEIGHT );
doomTics++;
Something went wrong with that request. Please try again.