DSC Engine
Loading...
Searching...
No Matches
palette_manager.hpp
Go to the documentation of this file.
1
4#pragma once
5
6#include "DSCEngine/types/hash_map.hpp"
7#include "DSCEngine/resources/asset_data.hpp"
8
9namespace DSC
10{
11 struct PaletteAllocationResult;
12
16 {
17 private:
18 static int hashColor(const short& color);
19
20 void* pal_offset;
21 int free_space[8];
22
23 short records4bpp[16];
24
26
27 int get_chksum(short* colors);
28 int get_pal16(short* colors, int chksum);
29 public:
33 PaletteManager(void* palettes_offset);
34
42 int reserve1(int color);
43
51 int reserve16(const void* palette4);
52
53
61 void unload1(int color);
62
69 void unload16(const void* palette4);
70
71
77
78
85 void unload(const AssetData* asset);
86
88 };
89
93 {
101 short* indices = nullptr;
102
108 int length;
109
113
118
119 ~PaletteAllocationResult(); // this is in order not to worry about the indices deallocation
120
121 PaletteAllocationResult(short* indices = nullptr, int length = 0, char color_depth = 0, bool succeeded = false);
124
125 PaletteAllocationResult& operator = (const PaletteAllocationResult& other);
127
128 bool operator == (const PaletteAllocationResult& other) const;
129 };
130}
Definition: asset_data.hpp:8
Generic hash map.
Definition: hash_map.hpp:18
Automatic palette manager.
Definition: palette_manager.hpp:16
void unload16(const void *palette4)
removes a 4-bit palette
void unload(const AssetData *asset)
Unloads colors from a previously loaded asset data palette.
PaletteAllocationResult try_load(const AssetData *asset)
Attempts to load colors from asset data palette.
PaletteManager(void *palettes_offset)
creates a new PaletteManager instance
int reserve16(const void *palette4)
loads a 4-bit palette
void unload1(int color)
removes a certain color from the palette
int reserve1(int color)
choose an index for the specified color
Struct that contains information following an asset allocation attempt via PaletteManager::try_load()...
Definition: palette_manager.hpp:93
bool succeeded
flag that specifies whether the operation succeeded or failed. This struct contains relevant data onl...
Definition: palette_manager.hpp:117
char color_depth
color depth of the asset
Definition: palette_manager.hpp:112
short * indices
The positions colors have been dynamically allocated to.
Definition: palette_manager.hpp:101
int length
size of the provided indices
Definition: palette_manager.hpp:108