Remove color mem indirection

This commit is contained in:
Alexander Batalov
2025-02-11 19:56:42 +03:00
parent 1b6fe7e15b
commit d540a9ff04
3 changed files with 3 additions and 24 deletions

View File

@@ -6,6 +6,7 @@
#include <algorithm>
#include "db.h"
#include "memory.h"
#include "svga.h"
namespace fallout {
@@ -51,15 +52,6 @@ static double gBrightness = 1.0;
// 0x51DF20
static ColorTransitionCallback* gColorPaletteTransitionCallback = nullptr;
// 0x51DF24
static MallocProc* gColorPaletteMallocProc = colorPaletteMallocDefaultImpl;
// 0x51DF28
static ReallocProc* gColorPaletteReallocProc = colorPaletteReallocDefaultImpl;
// 0x51DF2C
static FreeProc* gColorPaletteFreeProc = colorPaletteFreeDefaultImpl;
// 0x51DF30
static ColorFileNameManger* gColorFileNameMangler = nullptr;
@@ -492,7 +484,7 @@ unsigned char* _getColorBlendTable(int ch)
unsigned char* ptr;
if (_blendTable[ch] == nullptr) {
ptr = (unsigned char*)gColorPaletteMallocProc(4100);
ptr = (unsigned char*)internal_malloc(4100);
*(int*)ptr = 1;
_blendTable[ch] = ptr + 4;
_buildBlendTable(_blendTable[ch], ch);
@@ -512,20 +504,12 @@ void _freeColorBlendTable(int a1)
int* count = (int*)(v2 - sizeof(int));
*count -= 1;
if (*count == 0) {
gColorPaletteFreeProc(count);
internal_free(count);
_blendTable[a1] = nullptr;
}
}
}
// 0x4C7E58
void colorPaletteSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc)
{
gColorPaletteMallocProc = mallocProc;
gColorPaletteReallocProc = reallocProc;
gColorPaletteFreeProc = freeProc;
}
// 0x4C7E6C
void colorSetBrightness(double value)
{

View File

@@ -1,8 +1,6 @@
#ifndef COLOR_H
#define COLOR_H
#include "memory_defs.h"
namespace fallout {
typedef unsigned char Color;
@@ -31,7 +29,6 @@ bool colorPaletteLoad(const char* path);
char* _colorError();
unsigned char* _getColorBlendTable(int ch);
void _freeColorBlendTable(int a1);
void colorPaletteSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc);
void colorSetBrightness(double value);
bool colorPushColorPalette();
bool colorPopColorPalette();

View File

@@ -180,8 +180,6 @@ int windowManagerInit(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitP
_buffering = false;
_doing_refresh_all = 0;
colorPaletteSetMemoryProcs(internal_malloc, internal_realloc, internal_free);
if (!_initColors()) {
unsigned char* palette = (unsigned char*)internal_malloc(768);
if (palette == nullptr) {