From d410694e409700db45a1f8256e05a087e429aca9 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Wed, 30 Oct 2019 05:51:58 +0000 Subject: [PATCH] SW: Fix 3D Realms and ANM palettes git-svn-id: https://svn.eduke32.com/eduke32@8272 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/duke3d/src/astub.cpp # source/sw/src/anim.cpp # source/sw/src/colormap.cpp # source/sw/src/common_game.h # source/sw/src/game.cpp --- source/sw/src/anim.cpp | 21 ++++++--------------- source/sw/src/colormap.cpp | 6 ++++-- source/sw/src/common_game.h | 10 ++++++++++ source/sw/src/game.cpp | 36 ++++++++++-------------------------- 4 files changed, 30 insertions(+), 43 deletions(-) diff --git a/source/sw/src/anim.cpp b/source/sw/src/anim.cpp index 2a4a75d95..8ca489aba 100644 --- a/source/sw/src/anim.cpp +++ b/source/sw/src/anim.cpp @@ -47,6 +47,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "animlib.h" #include "anim.h" +#include "common_game.h" + BEGIN_SW_NS #define MAX_ANMS 10 @@ -262,12 +264,9 @@ unsigned char *LoadAnm(short anim_num) void playanm(short anim_num) { - unsigned char *animbuf, *palptr; + unsigned char *animbuf; int i, j, k, length = 0, numframes = 0; int32_t handle = -1; - unsigned char ANIMvesapal[4*256]; - char tempbuf[256]; - char *palook_bak = palookup[0]; UserInput uinfo = { FALSE, FALSE, dir_None }; ANIMnum = anim_num; @@ -292,21 +291,15 @@ playanm(short anim_num) DSPRINTF(ds,"PlayAnm - Palette Stuff"); MONO_PRINT(ds); - for (i = 0; i < 256; i++) - tempbuf[i] = i; - palookup[0] = tempbuf; - ANIM_LoadAnim(animbuf, length); ANIMnumframes = ANIM_NumFrames(); numframes = ANIMnumframes; - palptr = ANIM_GetPalette(); - videoClearViewableArea(0L); - paletteSetColorTable(0, ANIMvesapal, true); - videoSetPalette(0,0,2); + paletteSetColorTable(ANIMPAL, ANIM_GetPalette()); + videoSetPalette(0, ANIMPAL, 2); if (ANIMnum == 1) { // draw the first frame @@ -375,10 +368,8 @@ ENDOFANIMLOOP: videoClearViewableArea(0L); videoNextPage(); - palookup[0] = palook_bak; - paletteSetColorTable(0, (unsigned char *)palette_data); - videoSetPalette(0, 0, 2); + videoSetPalette(0, BASEPAL, 2); KB_FlushKeyboardQueue(); KB_ClearKeysDown(); diff --git a/source/sw/src/colormap.cpp b/source/sw/src/colormap.cpp index 670f8c902..b81b1bf86 100644 --- a/source/sw/src/colormap.cpp +++ b/source/sw/src/colormap.cpp @@ -31,6 +31,8 @@ Prepared for public release: 03/28/2005 - Charlie Wiederhold, 3D Realms #include "pal.h" #include "game.h" +#include "common_game.h" + BEGIN_SW_NS short f_c = 3; @@ -435,8 +437,8 @@ void SetPaletteToVESA(unsigned char *pal) VBE_setPalette(0, 256, pal_buff); */ - paletteSetColorTable(0, pal); - videoSetPalette(0,0,4|2); + paletteSetColorTable(BASEPAL, pal); + videoSetPalette(0, BASEPAL, 4|2); // fprintf(stderr,"SetPaletteToVESA() called\n"); } diff --git a/source/sw/src/common_game.h b/source/sw/src/common_game.h index 6b279233a..a247c4505 100644 --- a/source/sw/src/common_game.h +++ b/source/sw/src/common_game.h @@ -148,5 +148,15 @@ void SW_ExtInit(void); + +typedef enum basepal_ { + BASEPAL = 0, + DREALMSPAL, + TITLEPAL, + TENPAL, + ANIMPAL, + BASEPALCOUNT +} basepal_t; + END_SW_NS #endif diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index b0bb87366..f196def7a 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -854,8 +854,8 @@ void AnimateCacheCursor(void) void COVERsetbrightness(int bright, unsigned char *pal) { - paletteSetColorTable(0, pal); - videoSetPalette(bright, 0, 0); + paletteSetColorTable(BASEPAL, pal); + videoSetPalette(bright, BASEPAL, 0); } @@ -1678,37 +1678,25 @@ LogoLevel(void) { char called; int fin; - unsigned char backup_pal[256*3]; - char tempbuf[256]; - char *palook_bak = palookup[0]; UserInput uinfo = { FALSE, FALSE, dir_None }; - int i; DSPRINTF(ds,"LogoLevel..."); MONO_PRINT(ds); - for (i = 0; i < 256; i++) - tempbuf[i] = i; - palookup[0] = tempbuf; - - DSPRINTF(ds,"Created palookup..."); - MONO_PRINT(ds); - - //GetPaletteFromVESA(pal); - //memcpy(backup_pal, pal, PAL_SIZE); - - DSPRINTF(ds,"Got Palette from VESA..."); - MONO_PRINT(ds); - // PreCache Anim LoadAnm(0); auto pal = kloadfile("3drealms.pal", 0); if (pal.Size() >= 768) { - paletteSetColorTable(1, pal.Data()); - videoSetPalette(0, 1, 2); + + + for (auto & c : pal) + c <<= 2; + + paletteSetColorTable(DREALMSPAL, pal); + videoSetPalette(0, DREALMSPAL, 2); } DSPRINTF(ds,"Just read in 3drealms.pal..."); MONO_PRINT(ds); @@ -1747,13 +1735,9 @@ LogoLevel(void) } } - palookup[0] = palook_bak; - videoClearViewableArea(0L); videoNextPage(); - //SetPaletteToVESA(backup_pal); - paletteSetColorTable(0, &palette_data[0][0]); - videoSetPalette(0, 0, 2); + videoSetPalette(0, BASEPAL, 2); // put up a blank screen while loading