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
assetpalette.c
assettileset.c
assetpaletteimage.c
)
# Compile definitions

View File

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

View File

@@ -19,4 +19,4 @@ typedef struct {
/**
* 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.
*/
void assetParseTileset();
void assetParseTileset(void);

View File

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

View File

@@ -102,7 +102,7 @@ def processImage(assetPath):
f.write(b"DPI") # Dusk Palettized Image
f.write(struct.pack("<i", image.width)) # Width
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.
for index in indexes: