Palette image (incomplete)

This commit is contained in:
2025-08-27 22:55:47 -05:00
parent 31fa4948d5
commit 30232d1275
8 changed files with 46 additions and 6 deletions

View File

@@ -9,6 +9,7 @@ target_sources(${DUSK_TARGET_NAME}
asset.c asset.c
assetpalette.c assetpalette.c
assettileset.c assettileset.c
assetpaletteimage.c
) )
# Compile definitions # Compile definitions

View File

@@ -9,6 +9,7 @@
#include "dusk.h" #include "dusk.h"
#include "assetpalette.h" #include "assetpalette.h"
#include "assettileset.h" #include "assettileset.h"
#include "assetpalleteimage.h"
#include "error/error.h" #include "error/error.h"
#include <zip.h> #include <zip.h>
#include "display/texture/texture.h" #include "display/texture/texture.h"
@@ -28,6 +29,7 @@ typedef struct {
union { union {
assetpalette_t palette; assetpalette_t palette;
assettileset_t tileset; assettileset_t tileset;
assetpaletteimage_t paletteImage;
}; };
} assetdata_t; } assetdata_t;
#pragma pack(pop) #pragma pack(pop)
@@ -36,6 +38,7 @@ typedef struct {
union { union {
texture_t palette; texture_t palette;
assettileset_t *tileset; assettileset_t *tileset;
texture_t paletteImage;
}; };
} assetloaded_t; } assetloaded_t;
@@ -80,6 +83,7 @@ static const char_t ASSET_SEARCH_PATHS[][FILENAME_MAX] = {
static const assetmap_t ASSET_MAP[] = { static const assetmap_t ASSET_MAP[] = {
{ "DPF", ".dpf", assetParsePalette }, { "DPF", ".dpf", assetParsePalette },
{ "DPT", ".dpt", assetParseTileset }, { "DPT", ".dpt", assetParseTileset },
{ "DPI", ".dpi", assetParsePaletteImage },
{ NULL, NULL, NULL } { NULL, NULL, NULL }
}; };

View File

@@ -19,4 +19,4 @@ typedef struct {
/** /**
* Parse the palette from the loaded raw data. * Parse the palette from the loaded raw data.
*/ */
void assetParsePalette(); void assetParsePalette(void);

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "asset.h"
void assetParsePaletteImage(void) {
printf("nothin doin\n");
}

View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
#define ASSET_PALETTE_IMAGE_PIXELS_MAX (256*256)
typedef struct {
int32_t width;
int32_t height;
uint8_t paletteIndex;
uint8_t paletteIndexes[ASSET_PALETTE_IMAGE_PIXELS_MAX];
} assetpaletteimage_t;
/**
* Parse the palette image from the loaded raw data.
*/
void assetParsePaletteImage(void);

View File

@@ -21,4 +21,4 @@ typedef struct {
/** /**
* Parse the tileset from the loaded raw data. * Parse the tileset from the loaded raw data.
*/ */
void assetParseTileset(); void assetParseTileset(void);

View File

@@ -20,8 +20,8 @@ engine_t ENGINE;
void assetLoadCallback(void *data) { void assetLoadCallback(void *data) {
consolePrint("Asset load callback called!"); consolePrint("Asset load callback called!");
test = ASSET.loaded.palette; // test = ASSET.loaded.palette;
consolePrint("Loaded palette with %d colors", ASSET.data.palette.colorCount); // consolePrint("Loaded palette with %d colors", ASSET.data.palette.colorCount);
} }
errorret_t engineInit(void) { errorret_t engineInit(void) {
@@ -35,7 +35,7 @@ errorret_t engineInit(void) {
errorChain(assetInit()); errorChain(assetInit());
errorChain(displayInit()); errorChain(displayInit());
assetLoad("first.palette.dpf", assetLoadCallback, NULL); assetLoad("entities.dpi", assetLoadCallback, NULL);
if(ASSET.state == ASSET_STATE_ERROR) errorChain(ASSET.error); if(ASSET.state == ASSET_STATE_ERROR) errorChain(ASSET.error);
sceneTestAdd(); sceneTestAdd();

View File

@@ -102,7 +102,7 @@ def processImage(assetPath):
f.write(b"DPI") # Dusk Palettized Image f.write(b"DPI") # Dusk Palettized Image
f.write(struct.pack("<i", image.width)) # Width f.write(struct.pack("<i", image.width)) # Width
f.write(struct.pack("<i", image.height)) # Height f.write(struct.pack("<i", image.height)) # Height
f.write(struct.pack("<i", paletteIndex)) # Palette index f.write(struct.pack("B", paletteIndex)) # Palette index
# Write uint8_t pixel index. # Write uint8_t pixel index.
for index in indexes: for index in indexes: