Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOOM Classic Mode with 24bpp color #2

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion doomclassic/doom/am_map.cpp
Expand Up @@ -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));
}


Expand Down
1 change: 0 additions & 1 deletion doomclassic/doom/d_main.cpp
Expand Up @@ -265,7 +265,6 @@ void D_Display (void)
R_DrawViewBorder (); // erase old menu stuff
::g->borderdrawcount--;
}

}

::g->menuactivestate = ::g->menuactive;
Expand Down
4 changes: 3 additions & 1 deletion doomclassic/doom/defs.h
Expand Up @@ -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
Expand Down
31 changes: 19 additions & 12 deletions doomclassic/doom/f_finale.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
38 changes: 15 additions & 23 deletions doomclassic/doom/f_wipe.cpp
Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -101,7 +97,6 @@ wipe_initMelt
else if (::g->wipe_y[i] == -16)
::g->wipe_y[i] = -15;
}

return 0;
}

Expand All @@ -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++)
Expand All @@ -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--)
Expand All @@ -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--)
Expand Down Expand Up @@ -232,4 +225,3 @@ wipe_ScreenWipe

return !::g->go;
}

4 changes: 2 additions & 2 deletions doomclassic/doom/g_game.cpp
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion doomclassic/doom/i_video.h
Expand Up @@ -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);
Expand Down
40 changes: 26 additions & 14 deletions doomclassic/doom/i_video_ps3.cpp
Expand Up @@ -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 ) {
Expand All @@ -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()
Expand Down
22 changes: 13 additions & 9 deletions doomclassic/doom/r_data.cpp
Expand Up @@ -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];
}


Expand Down Expand Up @@ -769,8 +778,3 @@ void R_PrecacheLevel (void)
}
}
}





14 changes: 4 additions & 10 deletions doomclassic/doom/r_defs.h
Expand Up @@ -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;

//
// ?
Expand Down