Nuked console

This commit is contained in:
2025-11-03 09:22:18 -06:00
parent 3feb43fdad
commit 3ef6205ea3
53 changed files with 127 additions and 1570 deletions

View File

@@ -9,7 +9,6 @@
#include "assetmanager.h"
#include "util/memory.h"
#include "assert/assert.h"
#include "console/console.h"
assetdef_t ASSET_DEFINITIONS[ASSET_TYPE_COUNT] = {
[ASSET_TYPE_PALETTE_IMAGE] = {
@@ -18,9 +17,6 @@ assetdef_t ASSET_DEFINITIONS[ASSET_TYPE_COUNT] = {
[ASSET_TYPE_ALPHA_IMAGE] = {
"DAI", assetAlphaImageLoad, assetAlphaImageDispose
},
[ASSET_TYPE_CONFIG] = {
"DCF", assetConfigLoad, assetConfigDispose
},
};
errorret_t assetInit(asset_t *asset, const char_t *filename) {

View File

@@ -12,7 +12,6 @@
#include "asset/type/assetpaletteimage.h"
#include "asset/type/assetalphaimage.h"
#include "asset/type/assetconfig.h"
#define ASSET_HEADER_SIZE 3
#define ASSET_REFERENCE_COUNT_MAX 8
@@ -32,7 +31,6 @@ typedef enum {
ASSET_TYPE_UNKNOWN,
ASSET_TYPE_PALETTE_IMAGE,
ASSET_TYPE_ALPHA_IMAGE,
ASSET_TYPE_CONFIG,
ASSET_TYPE_COUNT
} assettype_t;
@@ -48,7 +46,6 @@ typedef struct asset_s {
union {
assetpaletteimage_t paletteImage;
assetalphaimage_t alphaImage;
assetconfig_t config;
};
} asset_t;

View File

@@ -7,7 +7,6 @@
#include "assetmanager.h"
#include "util/memory.h"
#include "console/console.h"
#include "util/string.h"
#include "assert/assert.h"
@@ -17,16 +16,17 @@ assetmanager_t ASSET_MANAGER;
errorret_t assetManagerInit(void) {
memoryZero(&ASSET_MANAGER, sizeof(assetmanager_t));
// Default system path, intended to be overridden by the paltform
stringCopy(ASSET_MANAGER.systemPath, ".", FILENAME_MAX);
// Open zip file
char_t searchPath[FILENAME_MAX];
consolevar_t *var = consoleVarGet("sys_path");
const char_t *sysPath = var ? var->value : ".";
for(int32_t i = 0; i < ASSET_MANAGER_SEARCH_PATHS_COUNT; i++) {
sprintf(
searchPath,
ASSET_MANAGER_SEARCH_PATHS[i],
sysPath,
ASSET_MANAGER.systemPath,
ASSET_ASSET_FILE
);

View File

@@ -31,6 +31,7 @@ static const char_t ASSET_MANAGER_SEARCH_PATHS[][FILENAME_MAX] = {
typedef struct {
zip_t *zip;
asset_t assets[ASSET_MANAGER_ASSET_COUNT_MAX];
char_t systemPath[FILENAME_MAX];
uint8_t assetCount;
} assetmanager_t;

View File

@@ -7,6 +7,5 @@
target_sources(${DUSK_TARGET_NAME}
PRIVATE
assetalphaimage.c
assetconfig.c
assetpaletteimage.c
)

View File

@@ -1,61 +0,0 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "asset/asset.h"
#include "console/console.h"
#include "assert/assert.h"
errorret_t assetConfigLoad(asset_t *asset) {
char_t buffer[CONSOLE_LINE_MAX + 1];
// Read byte by byte.
zip_int64_t bytesRead = 0;
zip_int64_t totalBytesRead = 0;
char_t c;
while(1) {
bytesRead = zip_fread(
asset->file,
&c,
1
);
if(bytesRead < 0) errorThrow("Failed to read from config asset file");
// Is byte execute?
if(c != ';' && c != '\n' && c != '\r' && bytesRead == 1) {
// Not execute, add to buffer.
buffer[totalBytesRead] = c;
if(++totalBytesRead >= CONSOLE_LINE_MAX) {
errorThrow("Config line too long!");
}
continue;
}
// Execute buffer.
buffer[totalBytesRead] = '\0';
consoleExec(buffer);
totalBytesRead = 0;
if(bytesRead == 0) break;
}
if(totalBytesRead > 0) {
// Execute remaining buffer.
buffer[totalBytesRead] = '\0';
consoleExec(buffer);
}
errorOk();
}
errorret_t assetConfigExecute(asset_t *asset) {
errorOk();
}
errorret_t assetConfigDispose(asset_t *asset) {
errorOk();
}

View File

@@ -1,42 +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"
typedef struct asset_s asset_t;
typedef struct {
zip_int64_t pos;
zip_int64_t size;
} assetconfig_t;
/**
* Loads a config asset from the given asset structure. The asset must be of
* type ASSET_TYPE_CONFIG and must be loaded.
*
* @param asset The asset to load the config from.
* @return An error code.
*/
errorret_t assetConfigLoad(asset_t *asset);
/**
* Executes the config commands in the given asset. The asset must be of type
* ASSET_TYPE_CONFIG and must be loaded.
*
* @param asset The asset to execute the config from.
* @return An error code.
*/
errorret_t assetConfigExecute(asset_t *asset);
/**
* Disposes of a config asset, freeing any allocated resources.
*
* @param asset The asset to dispose of.
* @return An error code.
*/
errorret_t assetConfigDispose(asset_t *asset);