-loadpal now loads a palette from disk and returns it in a table.

-setpal sets a palette from a table as the current palette.
This commit is contained in:
2022-10-05 18:51:26 +02:00
parent 8415841c5c
commit 035d82c1ec
3 changed files with 184 additions and 136 deletions

View File

@@ -292,7 +292,7 @@ void color(uint8_t color) {
ds::pen_color=color;
}
void loadpal(const char* filename) {
uint32_t *loadpal(const char* filename) {
FILE *f = fopen(filename, "rb");
if (f) {
fseek(f, 0, SEEK_END);
@@ -303,9 +303,15 @@ void loadpal(const char* filename) {
fclose(f);
uint32_t *pal = LoadPalette(buffer);
free(buffer);
memcpy(palette, pal, 1024);
free(pal);
return pal;
//memcpy(palette, pal, 1024);
//free(pal);
}
return NULL;
}
void setpal(uint32_t *pal) {
memcpy(palette, pal, 1024);
}
void setcolor(uint8_t index, uint32_t color) {