Merge
This commit is contained in:
@@ -35,6 +35,7 @@ add_subdirectory(engine)
|
||||
add_subdirectory(error)
|
||||
add_subdirectory(input)
|
||||
# add_subdirectory(locale)
|
||||
add_subdirectory(rpg)
|
||||
add_subdirectory(scene)
|
||||
add_subdirectory(thread)
|
||||
add_subdirectory(time)
|
||||
|
@@ -99,7 +99,7 @@ extern asset_t ASSET;
|
||||
errorret_t assetInit(void);
|
||||
|
||||
/**
|
||||
* Gets an asset by filename, does not load it.
|
||||
* Loads an asset by filename, blocking.
|
||||
*
|
||||
* @param filename The filename of the asset to get.
|
||||
* @param callback The callback to call when the asset is loaded.
|
||||
|
@@ -8,6 +8,7 @@ target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
display.c
|
||||
camera.c
|
||||
palette.c
|
||||
)
|
||||
|
||||
# Subdirectories
|
||||
|
19
src/display/palette.c
Normal file
19
src/display/palette.c
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "palette.h"
|
||||
#include "assert/assert.h"
|
||||
|
||||
palette_t PALETTE[PALETTE_COUNT_MAX];
|
||||
uint8_t PALETTE_COUNT = 0;
|
||||
|
||||
void paletteAssetLoadCallback(void *data) {
|
||||
assertNotNull(data, "Data cannot be NULL.");
|
||||
|
||||
uint8_t index = *((uint8_t*)data);
|
||||
assertTrue(index < PALETTE_COUNT_MAX, "Palette index out of bounds.");
|
||||
}
|
26
src/display/palette.h
Normal file
26
src/display/palette.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "dusk.h"
|
||||
|
||||
typedef struct {
|
||||
|
||||
} palette_t;
|
||||
|
||||
#define PALETTE_COUNT_MAX 8
|
||||
|
||||
extern palette_t PALETTE[PALETTE_COUNT_MAX];
|
||||
extern uint8_t PALETTE_COUNT;
|
||||
|
||||
/**
|
||||
* Palette asset load callback.
|
||||
*
|
||||
* @param data The data passed to the callback, should be a uint8_t* index
|
||||
* into the PALETTE array.
|
||||
*/
|
||||
void paletteAssetLoadCallback(void *data);
|
@@ -11,17 +11,13 @@
|
||||
#include "console/console.h"
|
||||
#include "display/display.h"
|
||||
#include "asset/asset.h"
|
||||
#include "rpg/rpg.h"
|
||||
|
||||
#include "display/palette.h"
|
||||
#include "scene/test/scenetest.h"
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
errorret_t engineInit(void) {
|
||||
memoryZero(&ENGINE, sizeof(engine_t));
|
||||
ENGINE.running = true;
|
||||
@@ -31,8 +27,10 @@ errorret_t engineInit(void) {
|
||||
consoleInit();
|
||||
errorChain(assetInit());
|
||||
errorChain(displayInit());
|
||||
rpgInit();
|
||||
|
||||
assetLoad("entities.dpi", assetLoadCallback, NULL);
|
||||
uint8_t slot = 0;
|
||||
assetLoad("entities.dpi", paletteAssetLoadCallback, &slot);
|
||||
if(ASSET.state == ASSET_STATE_ERROR) errorChain(ASSET.error);
|
||||
|
||||
sceneTestAdd();
|
||||
|
@@ -6,6 +6,7 @@
|
||||
# Sources
|
||||
target_sources(${DUSK_TARGET_NAME}
|
||||
PRIVATE
|
||||
rpg.c
|
||||
)
|
||||
|
||||
# Subdirs
|
||||
|
13
src/rpg/rpg.c
Normal file
13
src/rpg/rpg.c
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#include "rpg.h"
|
||||
#include "rpg/entity/player.h"
|
||||
|
||||
void rpgInit() {
|
||||
|
||||
}
|
13
src/rpg/rpg.h
Normal file
13
src/rpg/rpg.h
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Initializes the RPG subsystem.
|
||||
*/
|
||||
void rpgInit();
|
@@ -8,7 +8,7 @@
|
||||
#include "chunk.h"
|
||||
#include "util/memory.h"
|
||||
#include "assert/assert.h"
|
||||
#include "world/world.h"
|
||||
#include "rpg/world/world.h"
|
||||
|
||||
void renderChunkUpdated(chunk_t *chunk);
|
||||
|
||||
@@ -260,12 +260,12 @@ void chunkLoad(chunk_t *chunk, const uint16_t x, const uint16_t y) {
|
||||
};
|
||||
|
||||
// Load this entity.
|
||||
entityLoad(entity, data);
|
||||
// entityLoad(entity, data);
|
||||
data++;
|
||||
}
|
||||
|
||||
// Allow the rendering platform to know this chunk is loaded.
|
||||
renderChunkUpdated(chunk);
|
||||
// renderChunkUpdated(chunk);
|
||||
}
|
||||
|
||||
void chunkUnload(chunk_t *chunk) {
|
||||
|
@@ -7,15 +7,15 @@
|
||||
|
||||
#pragma once
|
||||
#include "tile.h"
|
||||
#include "display/render.h"
|
||||
#include "display/display.h"
|
||||
|
||||
#define CHUNK_WIDTH 8
|
||||
#define CHUNK_HEIGHT 8
|
||||
#define CHUNK_TILE_COUNT (CHUNK_WIDTH * CHUNK_HEIGHT)
|
||||
#define CHUNK_ENTITY_COUNT_MAX 8
|
||||
|
||||
#define CHUNK_MAP_WIDTH (((RENDER_WIDTH / TILE_WIDTH_HEIGHT)/CHUNK_WIDTH)+2)
|
||||
#define CHUNK_MAP_HEIGHT (((RENDER_HEIGHT / TILE_WIDTH_HEIGHT)/CHUNK_HEIGHT)+2)
|
||||
#define CHUNK_MAP_WIDTH (((DISPLAY_WIDTH / TILE_WIDTH_HEIGHT)/CHUNK_WIDTH)+2)
|
||||
#define CHUNK_MAP_HEIGHT (((DISPLAY_HEIGHT / TILE_WIDTH_HEIGHT)/CHUNK_HEIGHT)+2)
|
||||
#define CHUNK_MAP_COUNT (CHUNK_MAP_WIDTH * CHUNK_MAP_HEIGHT)
|
||||
|
||||
typedef struct {
|
||||
|
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
#include "chunk.h"
|
||||
#include "entity/entity.h"
|
||||
#include "rpg/entity/entity.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t layerBase[CHUNK_TILE_COUNT];
|
||||
|
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "overworld.h"
|
||||
#include "chunk.h"
|
||||
#include "display/render.h"
|
||||
#include "display/display.h"
|
||||
#include "assert/assert.h"
|
||||
#include "entity/entity.h"
|
||||
#include "rpg/entity/entity.h"
|
||||
|
||||
uint32_t OVERWORLD_CAMERA_X;
|
||||
uint32_t OVERWORLD_CAMERA_Y;
|
||||
|
16
src/rpg/world/world.h
Normal file
16
src/rpg/world/world.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "rpg/world/chunkdata.h"
|
||||
|
||||
#define WORLD_WIDTH 1
|
||||
#define WORLD_HEIGHT 1
|
||||
|
||||
static const chunkdata_t *WORLD_CHUNKS[WORLD_HEIGHT * WORLD_WIDTH] = {
|
||||
NULL
|
||||
};
|
Reference in New Issue
Block a user