Refator pass 1

This commit is contained in:
2025-10-06 19:14:52 -05:00
parent 85434b4edb
commit fc52afdb00
113 changed files with 96 additions and 726 deletions

21
archive/rpg/game.c Normal file
View File

@@ -0,0 +1,21 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "game/game.h"
errorret_t gameInit(void) {
printf("Init RPG\n");
errorOk();
}
void gameUpdate(void) {
}
void gameDispose(void) {
}

View File

@@ -7,8 +7,8 @@
#include "sceneoverworld.h"
#include "rpg/entity/entity.h"
#include "display/spritebatch/spritebatch.h"
#include "display/framebuffer/framebuffer.h"
#include "display/spritebatch.h"
#include "display/framebuffer.h"
#include "display/scene/scenemanager.h"
#include "display/mesh/quad.h"
#include "asset/assetmanager.h"

View File

@@ -7,7 +7,7 @@
#include "screen.h"
#include "assert/assert.h"
#include "display/spritebatch/spritebatch.h"
#include "display/spritebatch.h"
screen_t SCREEN;

View File

@@ -7,7 +7,7 @@
#pragma once
#include "display/camera.h"
#include "display/framebuffer/framebuffer.h"
#include "display/framebuffer.h"
typedef struct {
#if DISPLAY_SIZE_DYNAMIC == 1

View File

@@ -7,7 +7,7 @@
#include "scenetest.h"
#include "display/scene/scenemanager.h"
#include "display/spritebatch/spritebatch.h"
#include "display/spritebatch.h"
scenetest_t SCENE_TEST;

View File

@@ -3,10 +3,11 @@
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
if(DUSK_TARGET_GAME STREQUAL "rpg")
add_subdirectory(rpg)
elseif(DUSK_TARGET_GAME STREQUAL "minesweeper")
add_subdirectory(minesweeper)
else()
message(FATAL_ERROR "Unknown game specified: ${DUSK_TARGET_GAME}")
endif()
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
add_subdirectory(palette)# Palette asset needs to be added before any images.
add_subdirectory(config)
add_subdirectory(entity)
add_subdirectory(map)
add_subdirectory(ui)

View File

@@ -4,4 +4,5 @@
# https://opensource.org/licenses/MIT
add_asset(CONFIG init.dcf)
add_asset(CONFIG init_psp.dcf)
add_asset(CONFIG init-base.dcf)
add_asset(CONFIG init-psp.dcf)

View File

@@ -0,0 +1,2 @@
echo " = Dawn Init = ";
fps 1;

View File

@@ -1,4 +1,6 @@
echo " = Dawn PSP = ";
exec "config/init-base";
screen backbuffer;
bind up up;
bind down down;
@@ -8,10 +10,7 @@ bind cross accept;
bind circle cancel;
bind select toggleconsole;
bind start toggleconsole;
bind lstick_negative_y up;
bind lstick_positive_y down;
bind lstick_negative_x left;
bind lstick_positive_x right;
fps 1;

View File

@@ -1,4 +1,6 @@
echo " = Dawn Init = ";
exec "config/init-base";
screen height 270;
bind ` toggleconsole;
bind w up;
@@ -13,5 +15,3 @@ bind e accept;
bind enter accept;
bind q cancel;
bind esc quit;
fps 1;

View File

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 336 B

View File

@@ -1,11 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
# Palette asset needs to be added before any images.
add_subdirectory(palette)
add_subdirectory(config)
add_subdirectory(ui)

View File

@@ -1,19 +0,0 @@
echo " = Dawn Init = ";
bind ` toggleconsole;
bind w up;
bind s down;
bind a left;
bind d right;
bind up up;
bind down down;
bind left left;
bind right right;
bind e accept;
bind enter accept;
bind q cancel;
bind esc quit;
fps 1;
scene sweep;

View File

@@ -1,19 +0,0 @@
echo " = Dawn PSP = ";
bind up up;
bind down down;
bind left left;
bind right right;
bind cross accept;
bind circle cancel;
bind select toggleconsole;
bind start toggleconsole;
bind lstick_negative_y up;
bind lstick_positive_y down;
bind lstick_negative_x left;
bind lstick_positive_x right;
fps 1;
scene sweep;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

View File

@@ -1,4 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,9 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
add_asset(TILESET minogram.png type=ALPHA tileWidth=6 tileHeight=10 columns=16 rows=6)
add_asset(TILESET ui.png type=PALETTIZED tileWidth=16 tileHeight=16)
add_asset(TILESET ui_frame.png type=PALETTIZED tileWidth=16 tileHeight=16)
add_asset(TILESET background.png type=PALETTIZED tileWidth=16 tileHeight=16)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 268 B

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 293 B

View File

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View File

@@ -1,13 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
set(DUSK_GAME_ASSETS_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL ${DUSK_CACHE_TARGET})
add_subdirectory(palette)# Palette asset needs to be added before any images.
add_subdirectory(config)
add_subdirectory(entity)
add_subdirectory(map)
add_subdirectory(ui)

View File

@@ -1,7 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
add_asset(CONFIG init.dcf)
add_asset(CONFIG init_psp.dcf)

View File

@@ -1,6 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
add_asset(PALETTE palette0.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 758 B

After

Width:  |  Height:  |  Size: 758 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -33,7 +33,6 @@ add_subdirectory(console)
add_subdirectory(display)
add_subdirectory(engine)
add_subdirectory(error)
add_subdirectory(game)
add_subdirectory(input)
# add_subdirectory(locale)
add_subdirectory(physics)

View File

@@ -7,7 +7,7 @@
#pragma once
#include "error/error.h"
#include "display/texture/texture.h"
#include "display/texture.h"
#define ASSET_ALPHA_IMAGE_WIDTH_MAX 256
#define ASSET_ALPHA_IMAGE_HEIGHT_MAX 256

View File

@@ -7,7 +7,7 @@
#pragma once
#include "error/error.h"
#include "display/texture/texture.h"
#include "display/texture.h"
#define ASSET_PALETTE_IMAGE_WIDTH_MAX 128
#define ASSET_PALETTE_IMAGE_HEIGHT_MAX 128

View File

@@ -0,0 +1,22 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "console/console.h"
#include "display/screen.h"
void cmdScreen(const consolecmdexec_t *exec) {
if(exec->argc < 1) {
consolePrint("Expected 1 argument: <mode> [value]");
return;
}
if(strcmp(exec->argv[0], "backbuffer") == 0) {
SCREEN.mode = SCREEN_MODE_BACKBUFFER;
return;
}
}

View File

@@ -20,6 +20,7 @@
#include "console/cmd/cmdtoggleconsole.h"
#include "console/cmd/cmdalias.h"
#include "console/cmd/cmdscene.h"
#include "console/cmd/cmdscreen.h"
console_t CONSOLE;
@@ -36,6 +37,7 @@ void consoleInit() {
consoleRegCmd("toggleconsole", cmdToggleConsole);
consoleRegCmd("alias", cmdAlias);
consoleRegCmd("scene", cmdScene);
consoleRegCmd("screen", cmdScreen);
#if CONSOLE_POSIX
threadInit(&CONSOLE.thread, consoleInputThread);

View File

@@ -7,17 +7,17 @@
target_sources(${DUSK_TARGET_NAME}
PRIVATE
display.c
framebuffer.c
camera.c
tileset.c
screen.c
texture.c
spritebatch.c
)
# Subdirectories
add_subdirectory(framebuffer)
add_subdirectory(mesh)
add_subdirectory(palette)
add_subdirectory(texture)
add_subdirectory(spritebatch)
add_subdirectory(tileset)
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
target_compile_definitions(${DUSK_TARGET_NAME}

View File

@@ -8,7 +8,7 @@
#include "camera.h"
#include "display/display.h"
#include "assert/assert.h"
#include "display/framebuffer/framebuffer.h"
#include "display/framebuffer.h"
void cameraInit(camera_t *camera) {
cameraInitPerspective(camera);

View File

@@ -7,11 +7,10 @@
#include "display/display.h"
#include "console/console.h"
#include "display/framebuffer/framebuffer.h"
#include "display/framebuffer.h"
#include "scene/scenemanager.h"
#include "display/spritebatch/spritebatch.h"
#include "display/spritebatch.h"
#include "display/mesh/quad.h"
#include "game/game.h"
#include "display/screen.h"
display_t DISPLAY;

View File

@@ -9,7 +9,7 @@
#include "displaydefs.h"
#include "error/error.h"
#include "display/camera.h"
#include "display/framebuffer/framebuffer.h"
#include "display/framebuffer.h"
typedef struct {
#if DISPLAY_SDL2

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "display/texture/texture.h"
#include "display/texture.h"
#define FRAMEBUFFER_CLEAR_COLOR (1 << 0)
#define FRAMEBUFFER_CLEAR_DEPTH (1 << 1)

View File

@@ -1,10 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
framebuffer.c
)

View File

@@ -7,7 +7,7 @@
#pragma once
#include "dusk.h"
#include "display/framebuffer/framebuffer.h"
#include "display/framebuffer.h"
#include "display/camera.h"
#include "display/mesh/quad.h"

View File

@@ -7,7 +7,7 @@
#pragma once
#include "display/mesh/quad.h"
#include "display/texture/texture.h"
#include "display/texture.h"
#define SPRITEBATCH_SPRITES_MAX 1
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)

View File

@@ -1,13 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
texture.c
)
# Subdirs
# add_subdirectory(draw)

View File

@@ -6,5 +6,5 @@
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
spritebatch.c
tileset.c
)

View File

@@ -13,7 +13,6 @@
#include "display/display.h"
#include "scene/scenemanager.h"
#include "asset/assetmanager.h"
#include "game/game.h"
engine_t ENGINE;
@@ -31,11 +30,10 @@ errorret_t engineInit(void) {
errorChain(assetManagerInit());
errorChain(displayInit());
errorChain(sceneManagerInit());
errorChain(gameInit());
// Init scripts
#if PSP
consoleExec("exec config/init_psp.dcf");
consoleExec("exec config/init-psp.dcf");
#else
consoleExec("exec config/init.dcf");
#endif
@@ -49,7 +47,6 @@ errorret_t engineUpdate(void) {
consoleUpdate();
assetManagerUpdate();
gameUpdate();
sceneManagerUpdate();
errorChain(displayUpdate());
@@ -57,11 +54,9 @@ errorret_t engineUpdate(void) {
}
errorret_t engineDispose(void) {
gameDispose();
sceneManagerDispose();
errorChain(displayDispose());
assetManagerDispose();
consoleDispose();
errorOk();
}

View File

@@ -1,18 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
if(NOT DEFINED DUSK_TARGET_GAME)
message(FATAL_ERROR "DUSK_TARGET_GAME is not defined.")
endif()
string(TOUPPER "${DUSK_TARGET_GAME}" DUSK_TARGET_GAME_UPPER)
target_compile_definitions(${DUSK_TARGET_NAME}
PRIVATE
DUSK_TARGET_GAME=${DUSK_TARGET_GAME}
DUSK_GAME_${DUSK_TARGET_GAME_UPPER}=1
)
add_subdirectory(${DUSK_TARGET_GAME})

View File

@@ -1,26 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "error/error.h"
/**
* Initialize the game.
*
* @return Error code.
*/
errorret_t gameInit(void);
/**
* Update the game state.
*/
void gameUpdate(void);
/**
* Dispose of the game.
*/
void gameDispose(void);

View File

@@ -1,15 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
game.c
)
# Subdirs
add_subdirectory(display)
add_subdirectory(scene)
add_subdirectory(ui)

View File

@@ -1,12 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
sweepboard.c
)
# Subdirs

View File

@@ -1,30 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "sweepboard.h"
sweepboard_t SWEEPBOARD;
void sweepBoardInit() {
// Initialize the sweep board
}
void sweepBoardRender(const float_t x, const float_t y) {
// Frame
// uiFrameDrawTiled(
// 32, 32,
// w - 64, h - 64,
// UI.frameTileset,
// 0, 0,
// true,
// &UI.frameAsset->paletteImage.texture
// );
}
void sweepBoardDispose() {
// Dispose of the sweep board resources
}

View File

@@ -1,25 +0,0 @@
/**
* 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 {
int32_t nothing;
} sweepboard_t;
extern sweepboard_t SWEEPBOARD;
/**
* Initializes the sweep board.
*/
void sweepBoardInit();
/**
* Disposes of the sweep board resources.
*/
void sweepBoardDispose();

View File

@@ -1,33 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "game/game.h"
#include "game/minesweeper/ui/ui.h"
#include "game/minesweeper/scene/scenesweep.h"
#include "scene/scenemanager.h"
#include "console/console.h"
#include "display/screen.h"
errorret_t gameInit(void) {
// Setup screen
SCREEN.mode = SCREEN_MODE_FIXED_HEIGHT;
SCREEN.fixedHeight.height = 270;
errorChain(uiInit());
sceneManagerRegisterScene(&SCENE_SWEEP);
errorOk();
}
void gameUpdate(void) {
}
void gameDispose(void) {
uiDispose();
}

View File

@@ -1,12 +0,0 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
# Sources
target_sources(${DUSK_TARGET_NAME}
PRIVATE
scenesweep.c
)
# Subdirs

View File

@@ -1,76 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "scenesweep.h"
#include "game/minesweeper/ui/ui.h"
#include "ui/uiframe.h"
#include "display/spritebatch/spritebatch.h"
#include "game/minesweeper/display/sweepboard.h"
#include "display/screen.h"
scene_t SCENE_SWEEP = {
.name = "sweep",
.init = sceneSweepInit,
.update = sceneSweepUpdate,
.render = sceneSweepRender,
.dispose = sceneSweepDispose,
.background = color_hex(0x48413cff)
};
scenesweep_t SCENE_SWEEP_DATA;
errorret_t sceneSweepInit(void) {
cameraInitOrthographic(&SCENE_SWEEP_DATA.camera);
// Initialize scene data here
errorOk();
}
void sceneSweepUpdate(void) {
// Update scene logic here
}
void sceneSweepRender(void) {
int32_t w = SCREEN.width;
int32_t h = SCREEN.height;
SCENE_SWEEP_DATA.camera.orthographic.left = 0;
SCENE_SWEEP_DATA.camera.orthographic.right = w;
SCENE_SWEEP_DATA.camera.orthographic.bottom = h;
SCENE_SWEEP_DATA.camera.orthographic.top = 0;
cameraPushMatrix(&SCENE_SWEEP_DATA.camera);
// Background
uiFrameDrawTiled(
8, 8,
w - 16, h - 16,
UI.backgroundTileset,
0, 0,
true,
&UI.backgroundAsset->paletteImage.texture
);
// Frame
uiFrameDrawTiled(
32, 32,
w - 64, h - 64,
UI.frameTileset,
0, 0,
true,
&UI.frameAsset->paletteImage.texture
);
spriteBatchFlush();
cameraPopMatrix();
uiRender();
}
void sceneSweepDispose(void) {
// Clean up scene resources here
printf("Disposing sweep scene\n");
}

View File

@@ -1,37 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "scene/scene.h"
#include "display/camera.h"
typedef struct {
camera_t camera;
} scenesweep_t;
extern scene_t SCENE_SWEEP;
extern scenesweep_t SCENE_SWEEP_DATA;
/**
* Initializes the scene.
*/
errorret_t sceneSweepInit(void);
/**
* Updates the state of the scene.
*/
void sceneSweepUpdate(void);
/**
* Renders the current state of the scene.
*/
void sceneSweepRender(void);
/**
* Cleans up resources used by the scene.
*/
void sceneSweepDispose(void);

Some files were not shown because too many files have changed in this diff Show More