From d540a9ff04e886351ef992bbb2f393d301c7669c Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 11 Feb 2025 19:56:42 +0300 Subject: [PATCH] Remove color mem indirection --- src/color.cc | 22 +++------------------- src/color.h | 3 --- src/window_manager.cc | 2 -- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/color.cc b/src/color.cc index b7c282e..8657cae 100644 --- a/src/color.cc +++ b/src/color.cc @@ -6,6 +6,7 @@ #include #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) { diff --git a/src/color.h b/src/color.h index c92ce06..6dadfc9 100644 --- a/src/color.h +++ b/src/color.h @@ -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(); diff --git a/src/window_manager.cc b/src/window_manager.cc index 5b23635..a039842 100644 --- a/src/window_manager.cc +++ b/src/window_manager.cc @@ -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) {