Author SHA1 Message Date
YourWishesandClaude Opus 5 5cf81aa238 Normalize code style to match established conventions
An assistant-written stretch of code had drifted from the conventions the
older hand-written files establish. Sweeps the whole of src/ back into line.

Systematic:
- @returns -> @return (163 occurrences, 84 files). Concentrated in ui/ and
  rpg/cutscene/; the rest of the tree already used @return 646 times.
- Lowercase "null" -> "NULL" in assert/error message strings (170
  occurrences, 28 files), matching the dominant 441-use spelling. Covers
  "cannot be null", "must not be null" and adjectival uses.

Localized:
- sort.c: drop a stray #include <stdlib.h> that sat *above* the copyright
  header, leaving it the only file in the repo without a leading header
  block. Also drops the same redundant include from random.c and npcturn.c
  (dusk.h already pulls in stdlib.h).
- Convert 7 files' license headers from // lines to the /** */ block form.
- cutscenesystem.c: memset -> memoryZero, matching the identical call ~20
  lines further down and the rest of the codebase.
- Struct tags suffixed _t -> _s: threadlock_t -> threadmutex_s (which also
  makes the tag match its typedef) and chunkpos_t -> chunkpos_s.
- Convert 20 inline /* */ block comments to // across the mesh builders,
  assetfile.c and assetlocaleloader.c.
- Pointer truthiness if(!ptr) -> if(ptr == NULL) in 16 places, matching the
  267 existing explicit comparisons. Boolean !x checks are left alone.
- entityanim.h: drop a JSDoc-style type annotation from an @return.
- Document easing.h's 16 undeclared easing functions and
  assetjsonloader.h's 3 loader callbacks.

No behavioral change. Builds clean with no new warnings; ctest shows the
same 6 pre-existing failures as HEAD, verified against a pristine worktree.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-07 17:10:32 -05:00
206 changed files with 1142 additions and 1403 deletions

No files matched your search

@@ -1,10 +0,0 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_-1_0_0_0.dmf",
"color": [
255,
255,
255,
255
],
"texture": "tiles.png"
}
+10
View File
@@ -0,0 +1,10 @@
{
"mesh": "meshes/chunks/chunk_-1_0_0_0.dmf",
"color": [
255,
255,
255,
255
],
"texture": "tiles.png"
}
@@ -1,5 +1,5 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_0_0_0_0.dmf",
"mesh": "meshes/chunks/chunk_0_0_0_0.dmf",
"color": [
255,
255,
@@ -1,5 +1,5 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_0_1_0_0.dmf",
"mesh": "meshes/chunks/chunk_0_1_0_0.dmf",
"color": [
255,
255,
@@ -1,5 +1,5 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_1_0_0_0.dmf",
"mesh": "meshes/chunks/chunk_1_0_0_0.dmf",
"color": [
255,
255,
@@ -1,5 +1,5 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_1_1_0_0.dmf",
"mesh": "meshes/chunks/chunk_1_1_0_0.dmf",
"color": [
255,
255,
@@ -1,5 +1,5 @@
{
"mesh": "maps/overworld/meshes/chunks/chunk_2_0_0_0.dmf",
"mesh": "meshes/chunks/chunk_2_0_0_0.dmf",
"color": [
255,
255,
-1
View File
@@ -1 +0,0 @@
{}
+5 -7
View File
@@ -345,14 +345,12 @@
return promise;
}
const MAP_NAME = "overworld";
function chunkPaths(x, y, z) {
return {
raw: `assetsraw/maps/${MAP_NAME}/chunks/chunk_${x}_${y}_${z}.json`,
dcf: `assets/maps/${MAP_NAME}/chunks/${x}_${y}_${z}.dcf`,
terrainDmf: `assets/maps/${MAP_NAME}/meshes/chunks/chunk_${x}_${y}_${z}_0.dmf`,
terrainModel: `assets/maps/${MAP_NAME}/models/chunks/chunk_${x}_${y}_${z}_0.json`,
raw: `assetsraw/chunks/chunk_${x}_${y}_${z}.json`,
dcf: `assets/chunks/${x}_${y}_${z}.dcf`,
terrainDmf: `assets/meshes/chunks/chunk_${x}_${y}_${z}_0.dmf`,
terrainModel: `assets/models/chunks/chunk_${x}_${y}_${z}_0.json`,
};
}
@@ -769,7 +767,7 @@
async function buildChunkBrowseList() {
const list = document.getElementById("chunkBrowseList");
list.innerHTML = "";
const res = await apiLs(`assetsraw/maps/${MAP_NAME}/chunks`);
const res = await apiLs("assetsraw/chunks");
for(const entry of res.entries || []) {
const m = entry.name.match(/^chunk_(-?\d+)_(-?\d+)_(-?\d+)\.json$/);
if(!m) continue;
+1 -4
View File
@@ -209,10 +209,7 @@ class Handler(BaseHTTPRequestHandler):
self.send_json({"error": "invalid chunk coordinates"}, 400)
return
json_path = (
PROJECT_ROOT / "assetsraw" / "maps" / "overworld" / "chunks"
/ f"chunk_{x}_{y}_{z}.json"
)
json_path = PROJECT_ROOT / "assetsraw" / "chunks" / f"chunk_{x}_{y}_{z}.json"
if not json_path.is_file():
self.send_json({"error": "chunk json not found"}, 404)
return
+11 -9
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "animation.h"
#include "assert/assert.h"
@@ -14,9 +16,9 @@ void animationInit(
uint16_t *keyframeCounts,
const uint16_t layerCount
) {
assertNotNull(anim, "Animation pointer cannot be null.");
assertNotNull(keyframes, "Keyframes pointer cannot be null.");
assertNotNull(keyframeCounts, "Keyframe counts pointer cannot be null.");
assertNotNull(anim, "Animation pointer cannot be NULL.");
assertNotNull(keyframes, "Keyframes pointer cannot be NULL.");
assertNotNull(keyframeCounts, "Keyframe counts pointer cannot be NULL.");
assertTrue(layerCount > 0, "Layer count must be greater than zero.");
memoryZero(anim, sizeof(animation_t));
@@ -49,7 +51,7 @@ void animationInit(
}
float_t animationGetLayerValue(const animation_t *anim, const uint16_t layer) {
assertNotNull(anim, "Animation pointer cannot be null.");
assertNotNull(anim, "Animation pointer cannot be NULL.");
assertTrue(layer < anim->layerCount, "Layer index out of bounds.");
uint16_t keyframeCount = anim->keyframeCounts[layer];
@@ -61,7 +63,7 @@ void animationUpdate(
animation_t *anim,
const float_t deltaTime
) {
assertNotNull(anim, "Animation pointer cannot be null.");
assertNotNull(anim, "Animation pointer cannot be NULL.");
assertTrue(deltaTime >= 0, "Delta time must be non-negative.");
bool_t justCompleted = false;
+6 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "keyframe.h"
+6 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "easing.h"
#include "assert/assert.h"
+123 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
@@ -45,19 +47,136 @@ extern const easingfn_t EASING_FUNCTIONS[EASING_COUNT];
*/
float_t easingApply(const easingtype_t type, const float_t t);
/**
* No easing - returns t unchanged.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, equal to t.
*/
float_t easingLinear(const float_t t);
/**
* Sinusoidal easing in: starts slow, accelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInSine(const float_t t);
/**
* Sinusoidal easing out: starts fast, decelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingOutSine(const float_t t);
/**
* Sinusoidal easing in and out: slow at both ends, fastest in
* the middle.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInOutSine(const float_t t);
/**
* Quadratic easing in: starts slow, accelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInQuad(const float_t t);
/**
* Quadratic easing out: starts fast, decelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingOutQuad(const float_t t);
/**
* Quadratic easing in and out: slow at both ends, fastest in the
* middle.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInOutQuad(const float_t t);
/**
* Cubic easing in: starts slow, accelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInCubic(const float_t t);
/**
* Cubic easing out: starts fast, decelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingOutCubic(const float_t t);
/**
* Cubic easing in and out: slow at both ends, fastest in the
* middle.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInOutCubic(const float_t t);
/**
* Quartic easing in: starts slow, accelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInQuart(const float_t t);
/**
* Quartic easing out: starts fast, decelerates to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingOutQuart(const float_t t);
/**
* Quartic easing in and out: slow at both ends, fastest in the
* middle.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, in the range [0, 1].
*/
float_t easingInOutQuart(const float_t t);
/**
* Back easing in: overshoots backwards before moving to the end.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, which may fall below 0.
*/
float_t easingInBack(const float_t t);
/**
* Back easing out: overshoots past the end before settling on it.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, which may rise above 1.
*/
float_t easingOutBack(const float_t t);
/**
* Back easing in and out: overshoots backwards at the start and
* past the end before settling on it.
*
* @param t The input time, in the range [0, 1].
* @return The eased value, which may fall below 0 or rise above 1.
*/
float_t easingInOutBack(const float_t t);
+1 -1
View File
@@ -14,7 +14,7 @@ float_t keyframeGetValue(
const uint32_t keyframeCount,
const float_t time
) {
assertNotNull(keyframes, "Keyframes pointer cannot be null.");
assertNotNull(keyframes, "Keyframes pointer cannot be NULL.");
assertTrue(keyframeCount > 0, "Keyframe count must be more than 0.");
assertTrue(time >= 0, "Time must be non-negative.");
#ifdef DUSK_ASSERTIONS
+6 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "easing.h"
+15 -5
View File
@@ -25,9 +25,11 @@ errorret_t assetInit(void) {
threadMutexInit(&ASSET.loading[i].mutex);
}
// assetInitPlatform must either define ASSET.zip or throw an error.
// assetInitPlatform must either define both ASSET.zip/ASSET.zipStored or
// throw an error.
errorChain(assetInitPlatform());
assertNotNull(ASSET.zip, "Asset zip null without error.");
assertNotNull(ASSET.zip, "Asset zip NULL without error.");
assertNotNull(ASSET.zipStored, "Asset stored zip NULL without error.");
threadInit(&ASSET.loadThread, assetUpdateAsync);
threadStart(&ASSET.loadThread);
@@ -38,7 +40,9 @@ bool_t assetFileExists(const char_t *filename) {
assertStrLenMax(filename, ASSET_FILE_NAME_MAX, "Filename too long.");
threadMutexLock(&ASSET.zipLock);
bool_t found = zip_name_locate(ASSET.zip, filename, 0) >= 0;
bool_t found =
zip_name_locate(ASSET.zip, filename, 0) >= 0 ||
zip_name_locate(ASSET.zipStored, filename, 0) >= 0;
threadMutexUnlock(&ASSET.zipLock);
return found;
}
@@ -441,13 +445,19 @@ errorret_t assetDispose(void) {
errorChain(assetReapUnused());
// Cleanup zip file.
// Cleanup zip files.
if(ASSET.zip != NULL) {
if(zip_close(ASSET.zip) != 0) {
errorThrow("Failed to close asset zip archive.");
errorThrow("Failed to close compressed asset zip archive.");
}
ASSET.zip = NULL;
}
if(ASSET.zipStored != NULL) {
if(zip_close(ASSET.zipStored) != 0) {
errorThrow("Failed to close stored asset zip archive.");
}
ASSET.zipStored = NULL;
}
errorChain(assetDisposePlatform());
threadMutexDispose(&ASSET.zipLock);
+9 -5
View File
@@ -29,12 +29,16 @@
#define ASSET_BASE_DIRECTORY_MAX 256
typedef struct asset_s {
// The dusk.dsk archive - a single uncompressed (ZIP_STORED) zip, so
// every entry gets the reliable repeated seeking/re-opening that
// libzip only supports reliably for uncompressed entries (locale
// strings, MP3 loop restarts, etc.).
// Compressed (DEFLATE) archive - expected to hold the bulk of a game's
// binary assets. Looked up first by assetFileInit().
zip_t *zip;
// Stored (uncompressed) archive - expected to hold small files that need
// reliable repeated seeking/re-opening (e.g. locale strings), which
// libzip only supports reliably for uncompressed entries. Looked up by
// assetFileInit() only if the name isn't found in `zip`.
zip_t *zipStored;
// Directory dusk.dsk was actually found/opened in (on PSP, the directory
// EBOOT.PBP lives in, since dusk.dsk is embedded inside it rather than a
// loose file) - populated by each platform's own assetInitXxx() once it
@@ -48,7 +52,7 @@ typedef struct asset_s {
assetplatform_t platform;
// Guards every libzip call against ASSET.zip (zip_fopen,
// Guards every libzip call against ASSET.zip/ASSET.zipStored (zip_fopen,
// zip_fread, zip_fclose, zip_fseek, zip_stat, zip_name_locate - see
// assetfile.c/assetFileExists). libzip is documented as not thread-safe,
// and this asset system genuinely calls it from multiple real threads at
+163 -39
View File
@@ -30,9 +30,9 @@ errorret_t assetDskParseHeader(
// Every field is a little-endian uint32_t regardless of host - convert
// to host order (a no-op on little-endian hosts, a real byteswap on
// Dolphin's big-endian PowerPC).
uint32_t fields[3];
uint32_t fields[7];
memoryCopy(fields, bytes + ASSET_DSK_MAGIC_SIZE, sizeof(fields));
for(uint8_t i = 0; i < 3; i++) {
for(uint8_t i = 0; i < 7; i++) {
fields[i] = endianLittleToHost32(fields[i]);
}
@@ -41,17 +41,24 @@ errorret_t assetDskParseHeader(
errorThrow("dusk.dsk has an unsupported version: %u", version);
}
outHeader->size = fields[1];
outHeader->checksum = fields[2];
outHeader->compressedOffset = fields[1];
outHeader->compressedSize = fields[2];
outHeader->compressedChecksum = fields[3];
outHeader->storedOffset = fields[4];
outHeader->storedSize = fields[5];
outHeader->storedChecksum = fields[6];
errorOk();
}
errorret_t assetDskOpenFromPath(
const char_t *path,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
) {
errorChain(assetDskOpenFromPathRange(path, 0, SIZE_MAX, outZip));
errorChain(assetDskOpenFromPathRange(
path, 0, SIZE_MAX, outCompressed, outStored
));
errorOk();
}
@@ -59,12 +66,15 @@ errorret_t assetDskOpenFromPathRange(
const char_t *path,
const size_t baseOffset,
const size_t baseSize,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
) {
assertNotNull(path, "Path cannot be NULL.");
assertNotNull(outZip, "Out zip cannot be NULL.");
assertNotNull(outCompressed, "Out compressed cannot be NULL.");
assertNotNull(outStored, "Out stored cannot be NULL.");
*outZip = NULL;
*outCompressed = NULL;
*outStored = NULL;
FILE *headerFile = fopen(path, "rb");
if(headerFile == NULL) {
@@ -86,30 +96,104 @@ errorret_t assetDskOpenFromPathRange(
assetdskheader_t header;
errorChain(assetDskParseHeader(headerBytes, sizeof(headerBytes), &header));
if((size_t) ASSET_DSK_HEADER_SIZE + header.size > baseSize) {
errorThrow("dusk.dsk header describes a range beyond its containing file.");
if(
(size_t) header.compressedOffset + header.compressedSize > baseSize ||
(size_t) header.storedOffset + header.storedSize > baseSize
) {
errorThrow("dusk.dsk header describes ranges beyond its containing file.");
}
zip_error_t zipError;
zip_error_init(&zipError);
zip_source_t *source = zip_source_file_create(
zip_source_t *compressedSource = zip_source_file_create(
path,
(zip_uint64_t) (baseOffset + ASSET_DSK_HEADER_SIZE),
(zip_int64_t) header.size,
(zip_uint64_t) (baseOffset + header.compressedOffset),
(zip_int64_t) header.compressedSize,
&zipError
);
if(source == NULL) {
if(compressedSource == NULL) {
errorThrow(
"Failed to create dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create compressed dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outZip = zip_open_from_source(source, ZIP_RDONLY, &zipError);
if(*outZip == NULL) {
zip_source_free(source);
*outCompressed =
zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
if(*outCompressed == NULL) {
zip_source_free(compressedSource);
errorThrow(
"Failed to open dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open compressed dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
zip_source_t *storedSource = zip_source_file_create(
path,
(zip_uint64_t) (baseOffset + header.storedOffset),
(zip_int64_t) header.storedSize,
&zipError
);
if(storedSource == NULL) {
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to create stored dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outStored = zip_open_from_source(storedSource, ZIP_RDONLY, &zipError);
if(*outStored == NULL) {
zip_source_free(storedSource);
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to open stored dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
// The stored archive is small by convention, so verifying its checksum
// here (one extra small read) is cheap; the compressed archive isn't
// checked since it's meant to be read lazily/on-demand from here on.
uint8_t *storedBytes = (uint8_t *) memoryAllocate(header.storedSize);
FILE *storedFile = fopen(path, "rb");
if(storedFile == NULL) {
memoryFree(storedBytes);
zip_close(*outStored);
zip_close(*outCompressed);
*outStored = NULL;
*outCompressed = NULL;
errorThrow(
"Failed to re-open dusk.dsk to verify stored checksum: %s", path
);
}
fseek(storedFile, (long) (baseOffset + header.storedOffset), SEEK_SET);
size_t storedRead = fread(storedBytes, 1, header.storedSize, storedFile);
fclose(storedFile);
if(storedRead != header.storedSize) {
memoryFree(storedBytes);
zip_close(*outStored);
zip_close(*outCompressed);
*outStored = NULL;
*outCompressed = NULL;
errorThrow(
"Failed to read dusk.dsk stored archive to verify checksum: %s", path
);
}
uint32_t checksum =
(uint32_t) crc32(0L, storedBytes, (uInt) header.storedSize);
memoryFree(storedBytes);
if(checksum != header.storedChecksum) {
zip_close(*outStored);
zip_close(*outCompressed);
*outStored = NULL;
*outCompressed = NULL;
errorThrow(
"dusk.dsk stored archive failed checksum verification: %s", path
);
}
@@ -119,45 +203,85 @@ errorret_t assetDskOpenFromPathRange(
errorret_t assetDskOpenFromBuffer(
uint8_t *buffer,
const size_t bufferSize,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
) {
assertNotNull(buffer, "Buffer cannot be NULL.");
assertNotNull(outZip, "Out zip cannot be NULL.");
assertNotNull(outCompressed, "Out compressed cannot be NULL.");
assertNotNull(outStored, "Out stored cannot be NULL.");
*outZip = NULL;
*outCompressed = NULL;
*outStored = NULL;
assetdskheader_t header;
errorChain(assetDskParseHeader(buffer, bufferSize, &header));
if((size_t) ASSET_DSK_HEADER_SIZE + header.size > bufferSize) {
errorThrow("dusk.dsk header describes a range beyond the buffer.");
if(
(size_t) header.compressedOffset + header.compressedSize > bufferSize ||
(size_t) header.storedOffset + header.storedSize > bufferSize
) {
errorThrow("dusk.dsk header describes ranges beyond the buffer.");
}
uint8_t *data = buffer + ASSET_DSK_HEADER_SIZE;
uint32_t checksum = (uint32_t) crc32(0L, data, (uInt) header.size);
if(checksum != header.checksum) {
errorThrow("dusk.dsk archive failed checksum verification.");
uint32_t compressedChecksum = (uint32_t) crc32(
0L, buffer + header.compressedOffset, (uInt) header.compressedSize
);
if(compressedChecksum != header.compressedChecksum) {
errorThrow("dusk.dsk compressed archive failed checksum verification.");
}
uint32_t storedChecksum = (uint32_t) crc32(
0L, buffer + header.storedOffset, (uInt) header.storedSize
);
if(storedChecksum != header.storedChecksum) {
errorThrow("dusk.dsk stored archive failed checksum verification.");
}
zip_error_t zipError;
zip_error_init(&zipError);
// freep=0 - this is a non-owning window into the same caller-owned
// buffer, not an independent allocation libzip should free.
zip_source_t *source = zip_source_buffer_create(
data, header.size, 0, &zipError
// freep=0 for both - they're non-owning windows into the same caller-owned
// buffer, not independent allocations libzip should free.
zip_source_t *compressedSource = zip_source_buffer_create(
buffer + header.compressedOffset, header.compressedSize, 0, &zipError
);
if(source == NULL) {
if(compressedSource == NULL) {
errorThrow(
"Failed to create dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create compressed dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outZip = zip_open_from_source(source, ZIP_RDONLY, &zipError);
if(*outZip == NULL) {
zip_source_free(source);
*outCompressed =
zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
if(*outCompressed == NULL) {
zip_source_free(compressedSource);
errorThrow(
"Failed to open dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open compressed dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
zip_source_t *storedSource = zip_source_buffer_create(
buffer + header.storedOffset, header.storedSize, 0, &zipError
);
if(storedSource == NULL) {
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to create stored dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outStored = zip_open_from_source(storedSource, ZIP_RDONLY, &zipError);
if(*outStored == NULL) {
zip_source_free(storedSource);
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to open stored dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
+47 -36
View File
@@ -13,26 +13,30 @@
// never gets misread as a valid dusk.dsk.
#define ASSET_DSK_MAGIC_SIZE 4
#define ASSET_DSK_MAGIC "DSK2"
#define ASSET_DSK_VERSION 2
#define ASSET_DSK_VERSION 1
// magic(4) + version(4) + size(4) + checksum(4), all little-endian
// regardless of host - see assetDskParseHeader. The zip archive itself
// starts immediately after, at ASSET_DSK_HEADER_SIZE.
#define ASSET_DSK_HEADER_SIZE 16
// magic(4) + version(4) + compressedOffset(4) + compressedSize(4) +
// compressedChecksum(4) + storedOffset(4) + storedSize(4) +
// storedChecksum(4), all little-endian regardless of host - see
// assetDskParseHeader.
#define ASSET_DSK_HEADER_SIZE 32
/**
* Parsed dusk.dsk (DSK2 format) header. dusk.dsk is a single uncompressed
* (ZIP_STORED) zip archive (see tools/asset/pack) rather than DEFLATEd -
* the bulk of what's packed (audio, images) is already compressed at the
* file level, so DEFLATE-ing the whole archive on top buys negligible
* space for real CPU cost, and every entry gets the reliable repeated
* seeking/re-opening that libzip only supports for uncompressed entries
* (locale line-by-line reads, MP3 loop restarts, etc.) instead of just a
* hand-picked subset of files.
* Parsed dusk.dsk (DSK2 format) header. dusk.dsk is two independent, back
* to back zip archives (see tools/asset/pack) rather than a single plain
* zip: a "compressed" one (DEFLATE, expected to hold the bulk of a game's
* binary assets, opened lazily/on-demand) and a "stored" one (uncompressed,
* expected to hold small files - locale strings, config - that need
* reliable repeated seeking/re-opening, which libzip only supports for
* uncompressed entries).
*/
typedef struct {
uint32_t size;
uint32_t checksum;
uint32_t compressedOffset;
uint32_t compressedSize;
uint32_t compressedChecksum;
uint32_t storedOffset;
uint32_t storedSize;
uint32_t storedChecksum;
} assetdskheader_t;
/**
@@ -52,24 +56,27 @@ errorret_t assetDskParseHeader(
);
/**
* Opens the dusk.dsk archive given a filesystem path, using a lazy/
* windowed file-backed zip source - no more memory used than the
* Opens both archives of a dusk.dsk file given a filesystem path, using
* lazy/windowed file-backed zip sources - no more memory used than the
* existing per-platform small read buffers, matching the memory
* characteristics of a plain zip_open() on the whole file. The checksum
* is intentionally not verified here since doing so would require
* reading the whole (potentially large) archive just to compute it.
* characteristics of a plain zip_open() on the whole file. Verifies the
* (small, by convention) stored archive's checksum; the compressed
* archive's checksum is intentionally not verified here since doing so
* would require reading the bulk of the game's assets just to compute it.
*
* See assetDskOpenFromPathRange() for the case where the DSK2 blob isn't
* the whole file (e.g. embedded inside another container).
*
* @param path Filesystem path to the dusk.dsk file.
* @param outZip Set to the opened archive on success.
* @param outCompressed Set to the opened compressed archive on success.
* @param outStored Set to the opened stored archive on success.
* @return OK on success, error if the file is missing, too short, has a
* bad header, or the archive fails to open.
* bad header, or either archive fails to open/verify.
*/
errorret_t assetDskOpenFromPath(
const char_t *path,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
);
/**
@@ -83,35 +90,39 @@ errorret_t assetDskOpenFromPath(
* @param path Filesystem path to the container file.
* @param baseOffset Byte offset within `path` where the DSK2 blob starts.
* @param baseSize Number of bytes available at `baseOffset`.
* @param outZip Set to the opened archive on success.
* @param outCompressed Set to the opened compressed archive on success.
* @param outStored Set to the opened stored archive on success.
* @return OK on success, error if the file is missing, too short, has a
* bad header, or the archive fails to open.
* bad header, or either archive fails to open/verify.
*/
errorret_t assetDskOpenFromPathRange(
const char_t *path,
const size_t baseOffset,
const size_t baseSize,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
);
/**
* Opens the dusk.dsk archive already fully resident in memory (e.g. a
* PSAR embedded in an EBOOT.PBP, or an ISO-embedded file already read via
* DVD_ReadAbs - platforms that already buffer the whole file for reasons
* unrelated to this format). The returned archive doesn't take ownership
* of `buffer` (it's opened as a non-owning sub-range of it) - the caller
* Opens both archives of a dusk.dsk file already fully resident in memory
* (e.g. a PSAR embedded in an EBOOT.PBP, or an ISO-embedded file already
* read via DVD_ReadAbs - platforms that already buffer the whole file for
* reasons unrelated to this format). Neither archive takes ownership of
* `buffer` (both are opened as non-owning sub-ranges of it) - the caller
* remains responsible for freeing it, and must keep it alive for as long
* as the archive stays open. Verifies the checksum, since the bytes are
* already resident.
* as either archive stays open. Verifies both archives' checksums, since
* the bytes are already resident.
*
* @param buffer The whole dusk.dsk file's bytes.
* @param bufferSize Number of bytes at `buffer`.
* @param outZip Set to the opened archive on success.
* @param outCompressed Set to the opened compressed archive on success.
* @param outStored Set to the opened stored archive on success.
* @return OK on success, error if too short, has a bad header/checksum, or
* the archive fails to open.
* either archive fails to open.
*/
errorret_t assetDskOpenFromBuffer(
uint8_t *buffer,
const size_t bufferSize,
zip_t **outZip
zip_t **outCompressed,
zip_t **outStored
);
+22 -16
View File
@@ -24,11 +24,20 @@ errorret_t assetFileInit(
file->params = params;
file->output = output;
// Stat the file, trying the compressed archive first and falling back to
// the stored one - remember which matched so assetFileOpen opens it from
// the right archive.
zip_stat_init(&file->stat);
threadMutexLock(&ASSET.zipLock);
int statResult = zip_stat(ASSET.zip, filename, 0, &file->stat);
if(zip_stat(ASSET.zip, filename, 0, &file->stat) == 0) {
file->sourceZip = ASSET.zip;
} else if(zip_stat(ASSET.zipStored, filename, 0, &file->stat) == 0) {
file->sourceZip = ASSET.zipStored;
} else {
file->sourceZip = NULL;
}
threadMutexUnlock(&ASSET.zipLock);
if(statResult != 0) {
if(file->sourceZip == NULL) {
errorThrow("Failed to stat asset file: %s", filename);
}
@@ -76,10 +85,11 @@ errorret_t assetFileRewind(assetfile_t *file) {
errorret_t assetFileOpen(assetfile_t *file) {
assertNotNull(file, "Asset file cannot be NULL.");
assertNotNull(file->filename, "Asset file filename cannot be NULL.");
assertNotNull(file->sourceZip, "Asset file must be inited before opening.");
assertNull(file->zipFile, "Asset file already open.");
threadMutexLock(&ASSET.zipLock);
file->zipFile = zip_fopen(ASSET.zip, file->filename, 0);
file->zipFile = zip_fopen(file->sourceZip, file->filename, 0);
threadMutexUnlock(&ASSET.zipLock);
if(file->zipFile == NULL) {
errorThrow("Failed to open asset file: %s", file->filename);
@@ -269,7 +279,7 @@ errorret_t assetFileLineReaderAppend(
errorOk();
}
/* reserve room for optional NUL terminator */
// reserve room for optional NUL terminator
if(reader->lineLength + srcLength >= reader->outBufferSize) {
errorThrow("Line length exceeds output buffer size.");
}
@@ -318,7 +328,7 @@ errorret_t assetFileLineReaderFill(assetfilelinereader_t *reader) {
size_t unreadBytes = assetFileLineReaderUnreadBytes(reader);
/* If buffer is fully consumed, refill from start. */
// If buffer is fully consumed, refill from start.
if(unreadBytes == 0) {
reader->bufferStart = 0;
reader->bufferEnd = 0;
@@ -339,18 +349,14 @@ errorret_t assetFileLineReaderFill(assetfilelinereader_t *reader) {
errorOk();
}
/*
* There are unread bytes left but no newline in them.
* If bufferStart > 0, slide unread bytes to front so we can read more.
* This only happens when necessary to make space.
*/
// There are unread bytes left but no newline in them.
// If bufferStart > 0, slide unread bytes to front so we can read more.
// This only happens when necessary to make space.
if(reader->bufferEnd == reader->readBufferSize) {
if(reader->bufferStart == 0) {
/*
* Entire read buffer is unread and contains no newline.
* Caller must have a large enough outBuffer to accumulate across fills,
* so we consume these bytes into outBuffer before refilling.
*/
// Entire read buffer is unread and contains no newline.
// Caller must have a large enough outBuffer to accumulate across fills,
// so we consume these bytes into outBuffer before refilling.
errorOk();
}
@@ -393,7 +399,7 @@ errorret_t assetFileLineReaderNext(assetfilelinereader_t *reader) {
size_t chunkLength = (size_t)newlineIndex - reader->bufferStart;
errorret_t ret;
/* strip CR in CRLF */
// strip CR in CRLF
if(
chunkLength > 0 &&
reader->readBuffer[(size_t)newlineIndex - 1] == '\r'
+6 -1
View File
@@ -9,7 +9,7 @@
#include "error/error.h"
#include <zip.h>
#define ASSET_FILE_NAME_MAX 128
#define ASSET_FILE_NAME_MAX 48
// Max bytes requested per zip_fread() call in assetFileRead(). Some
// zip_fread() implementations (seen on PSP) reject a single call asking
@@ -32,6 +32,11 @@ typedef struct assetfile_s {
zip_int64_t position;
zip_int64_t lastRead;
zip_file_t *zipFile;
// The archive this file was found in (ASSET.zip or ASSET.zipStored),
// set by assetFileInit and used by assetFileOpen so lookups fall back
// correctly between the two dusk.dsk archives.
zip_t *sourceZip;
} assetfile_t;
/**
+1 -1
View File
@@ -62,7 +62,7 @@ errorret_t assetModelLoaderSync(assetloading_t *loading) {
// Parse required mesh path.
yyjson_val *meshVal = yyjson_obj_get(root, "mesh");
if(!meshVal || !yyjson_is_str(meshVal)) {
if(meshVal == NULL || !yyjson_is_str(meshVal)) {
assetUnlockEntry(jsonEntry);
loading->entry->state = ASSET_ENTRY_STATE_ERROR;
errorThrow("Model JSON missing 'mesh' string");
+3 -3
View File
@@ -32,7 +32,7 @@ typedef struct {
* on the main thread; this callback is never reached.
*
* @param loading Loading information for the asset being loaded.
* @returns Always success.
* @return Always success.
*/
errorret_t assetModelLoaderAsync(assetloading_t *loading);
@@ -44,7 +44,7 @@ errorret_t assetModelLoaderAsync(assetloading_t *loading);
* within ASSET_LOADING_COUNT_MAX slot limits.
*
* @param loading Loading information for the asset being loaded.
* @returns Error code indicating success or failure.
* @return Error code indicating success or failure.
*/
errorret_t assetModelLoaderSync(assetloading_t *loading);
@@ -53,6 +53,6 @@ errorret_t assetModelLoaderSync(assetloading_t *loading);
* sub-asset entries.
*
* @param entry Asset entry containing the model to dispose.
* @returns Error code indicating success or failure.
* @return Error code indicating success or failure.
*/
errorret_t assetModelDispose(assetentry_t *entry);
+1 -1
View File
@@ -77,7 +77,7 @@ errorret_t assetJsonLoaderSync(assetloading_t *loading) {
memoryFree(buffer);
loading->loading.json.buffer = NULL;
if(!loading->entry->data.json) {
if(loading->entry->data.json == NULL) {
assetLoaderErrorThrow(loading, "Failed to parse JSON");
}
@@ -41,6 +41,32 @@ typedef struct {
typedef yyjson_doc * assetjsonoutput_t;
/**
* Asynchronous loader callback. Opens the JSON file and reads the whole of
* it into a heap buffer, so the main thread is not blocked on I/O. The
* buffer is parsed later, on the main thread, by assetJsonLoaderSync. Sets
* the entry state to `ASSET_ENTRY_STATE_PENDING_SYNC` on success.
*
* @param loading The loading slot for this asset entry.
* @return OK on success, error otherwise.
*/
errorret_t assetJsonLoaderAsync(assetloading_t *loading);
/**
* Synchronous loader callback. Drives the load state machine: on the first
* call it queues the async read, and once that has completed it parses the
* buffer into a `yyjson_doc` (comments and trailing commas allowed), frees
* the buffer and marks the entry `ASSET_ENTRY_STATE_LOADED`.
*
* @param loading The loading slot for this asset entry.
* @return OK on success, error otherwise.
*/
errorret_t assetJsonLoaderSync(assetloading_t *loading);
/**
* Dispose callback. Frees the parsed `yyjson_doc` held by the entry.
*
* @param entry The asset entry to dispose.
* @return OK on success, error otherwise.
*/
errorret_t assetJsonDispose(assetentry_t *entry);
@@ -93,7 +93,7 @@ errorret_t assetLocaleParseHeader(
// Find "Plural-Forms: " line and parse out plural form info
char_t *pluralFormsLine = strstr(headerBuffer, "Plural-Forms:");
if(!pluralFormsLine) {
if(pluralFormsLine == NULL) {
errorOk();
}
@@ -101,7 +101,7 @@ errorret_t assetLocaleParseHeader(
// Expect nplurals
char_t *npluralsStr = strstr(pluralFormsLine, "nplurals=");
if(!npluralsStr) {
if(npluralsStr == NULL) {
errorThrow("Failed to find nplurals in Plural-Forms header.");
}
npluralsStr += strlen("nplurals=");
@@ -120,7 +120,7 @@ errorret_t assetLocaleParseHeader(
// Expect plural=
char_t *pluralStr = strstr(pluralFormsLine, "plural=");
if(!pluralStr) {
if(pluralStr == NULL) {
errorThrow("Failed to find plural in Plural-Forms header.");
}
pluralStr += strlen("plural=");
@@ -128,7 +128,7 @@ errorret_t assetLocaleParseHeader(
// Expect ( [expressions] )
char_t *openParen = strchr(pluralStr, '(');
char_t *closeParen = strrchr(pluralStr, ')');
if(!openParen || !closeParen || closeParen < openParen) {
if(openParen == NULL || closeParen == NULL || closeParen < openParen) {
errorThrow("Failed to find plural expression in Plural-Forms header.");
}
@@ -399,12 +399,12 @@ errorret_t assetLocaleLineUnbuffer(
// At the point this funciton is called, we are looking for an opening quote.
char_t *start = strchr((char_t *)lineBuffer, '"');
if(!start) {
if(start == NULL) {
errorThrow("Expected open (0) \"");
}
char *end = strchr(start + 1, '"');
if(!end) {
if(end == NULL) {
errorThrow("Expected close (0) \"");
}
*end = '\0';
@@ -690,7 +690,7 @@ errorret_t assetLocaleGetStringLookup(
// Parse until ]
char *end = strchr(ptr, ']');
if(!end) {
if(end == NULL) {
errorThrow("Expected ] for plural form, found: %s", lineBuffer);
}
*end = '\0';
@@ -854,7 +854,7 @@ errorret_t assetLocaleGetStringWithArgs(
inIndex++;
/* Escaped percent */
// Escaped percent
if(format[inIndex] == '%') {
if(outIndex + 1 >= bufferSize) {
memoryFree(format);
@@ -880,7 +880,7 @@ errorret_t assetLocaleGetStringWithArgs(
specBuffer[specLength++] = '%';
/* Allow flags / width / precision */
// Allow flags / width / precision
while(format[inIndex] != '\0') {
char_t ch = format[inIndex];
+4 -4
View File
@@ -87,10 +87,10 @@ errorret_t audioStreamPcmSeek(audiostream_t *stream, const size_t frame) {
const size_t currentByte = (size_t) stream->pcm.file.position;
if(targetByte < currentByte) {
// A rewind is needed to move the read cursor earlier once it's
// already advanced past a point - assetFileRewind() takes the cheap
// in-place seek path since every dusk.dsk entry is stored
// uncompressed.
// Only a full rewind can move a read cursor earlier once it's already
// advanced past a point - a compressed archive entry can't be decoded
// backward. See this function's own doc comment for the performance
// implications of a deep loopTo.
errorChain(assetFileRewind(&stream->pcm.file));
errorChain(assetFileRead(&stream->pcm.file, NULL, targetByte));
} else if(targetByte > currentByte) {
+5 -2
View File
@@ -63,8 +63,11 @@ size_t audioStreamPcmGetTotalFrames(const audiostream_t *stream);
* (relative to the start of the PCM data - the same units as
* audiostream_t's startFrame/loopStart/loopTo, once converted from
* seconds). Seeking backward re-reads from the start of the underlying
* asset file (see assetFileRewind()), which is a cheap in-place seek
* since every dusk.dsk entry is stored uncompressed.
* asset file (see assetFileRewind()) since a compressed archive entry can
* only be decoded forward - this makes a loop with a deep loopTo more
* expensive to restart than one near the start, which is a real
* performance caveat, not just a theoretical one, for anything backed by
* a compressed (not stored) asset archive entry.
*
* @param stream The audio stream to seek. Must be AUDIO_STREAM_TYPE_PCM.
* @param frame Frame offset to seek to, relative to the start of the PCM
+5 -5
View File
@@ -55,8 +55,8 @@ void capsuleBuffer(
vertices[vi].uv[1] = (v); \
vi++;
/* ---- Top hemisphere ---- */
/* phi ranges from PI/2 (top pole) down to 0 (equator). */
// ---- Top hemisphere ----
// phi ranges from PI/2 (top pole) down to 0 (equator).
const float_t capStep = (float_t)GLM_PI_2 / (float_t)capRings;
for(int32_t i = 0; i < capRings; i++) {
const float_t phi1 = (float_t)GLM_PI_2 - (float_t)i * capStep;
@@ -67,8 +67,8 @@ void capsuleBuffer(
const float_t lxz1 = radius * cosf(phi1);
const float_t lxz2 = radius * cosf(phi2);
/* UV: top cap occupies v in [0.5 + halfHeightFrac .. 1.0]: we use a
* simple per-band normalisation against the full height. */
// UV: top cap occupies v in [0.5 + halfHeightFrac .. 1.0]: we use a
// simple per-band normalisation against the full height.
const float_t v1 = 1.0f - (float_t)i / (float_t)(2 * capRings + 1);
const float_t v2 = 1.0f - (float_t)(i + 1) / (float_t)(2 * capRings + 1);
@@ -97,7 +97,7 @@ void capsuleBuffer(
}
}
/* ---- Cylindrical body ---- */
// ---- Cylindrical body ----
{
const float_t yTop = cy + halfHeight;
const float_t yBot = cy - halfHeight;
+6 -4
View File
@@ -1,7 +1,9 @@
// Copyright (c) 2026 Dominic Masters
//
// This software is released under the MIT License.
// https://opensource.org/licenses/MIT
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "display/display.h"
+3 -3
View File
@@ -59,7 +59,7 @@ void planeBuffer(
switch(axis) {
case PLANE_AXIS_XY: {
/* Flat in XY at z = min[2]; spans X and Y. */
// Flat in XY at z = min[2]; spans X and Y.
const float_t z = min[2];
PLANE_VERT(0, min[0], min[1], z, u0, v0)
PLANE_VERT(1, max[0], min[1], z, u1, v0)
@@ -71,7 +71,7 @@ void planeBuffer(
}
case PLANE_AXIS_XZ: {
/* Flat in XZ at y = min[1]; spans X and Z. */
// Flat in XZ at y = min[1]; spans X and Z.
const float_t y = min[1];
PLANE_VERT(0, min[0], y, min[2], u0, v0)
PLANE_VERT(1, max[0], y, min[2], u1, v0)
@@ -83,7 +83,7 @@ void planeBuffer(
}
case PLANE_AXIS_YZ: {
/* Flat in YZ at x = min[0]; spans Y and Z. */
// Flat in YZ at x = min[0]; spans Y and Z.
const float_t x = min[0];
PLANE_VERT(0, x, min[1], min[2], u0, v0)
PLANE_VERT(1, x, max[1], min[2], u1, v0)
+1 -1
View File
@@ -44,7 +44,7 @@ void sphereBuffer(
int32_t vi = 0;
for(int32_t i = 0; i < stacks; i++) {
/* Latitude angles: top of band -> bottom of band */
// Latitude angles: top of band -> bottom of band
const float_t phi1 = (float_t)GLM_PI_2 - (float_t)i * stackStep;
const float_t phi2 = (float_t)GLM_PI_2 - (float_t)(i + 1) * stackStep;
+5 -5
View File
@@ -47,17 +47,17 @@ void triPrismBuffer(
vertices[vi].uv[1] = (v); \
vi++;
/* --- Front face (z = maxZ), CCW from +Z --- */
// --- Front face (z = maxZ), CCW from +Z ---
PRISM_VERT(x0, y0, maxZ, 0.0f, 0.0f)
PRISM_VERT(x1, y1, maxZ, 1.0f, 0.0f)
PRISM_VERT(x2, y2, maxZ, 0.5f, 1.0f)
/* --- Back face (z = minZ), CCW from -Z (reverse winding) --- */
// --- Back face (z = minZ), CCW from -Z (reverse winding) ---
PRISM_VERT(x2, y2, minZ, 0.5f, 1.0f)
PRISM_VERT(x1, y1, minZ, 1.0f, 0.0f)
PRISM_VERT(x0, y0, minZ, 0.0f, 0.0f)
/* --- Side face 0: edge p0->p1 --- */
// --- Side face 0: edge p0->p1 ---
PRISM_VERT(x0, y0, minZ, 0.0f, 0.0f)
PRISM_VERT(x1, y1, minZ, 1.0f, 0.0f)
PRISM_VERT(x1, y1, maxZ, 1.0f, 1.0f)
@@ -66,7 +66,7 @@ void triPrismBuffer(
PRISM_VERT(x1, y1, maxZ, 1.0f, 1.0f)
PRISM_VERT(x0, y0, maxZ, 0.0f, 1.0f)
/* --- Side face 1: edge p1->p2 --- */
// --- Side face 1: edge p1->p2 ---
PRISM_VERT(x1, y1, minZ, 0.0f, 0.0f)
PRISM_VERT(x2, y2, minZ, 1.0f, 0.0f)
PRISM_VERT(x2, y2, maxZ, 1.0f, 1.0f)
@@ -75,7 +75,7 @@ void triPrismBuffer(
PRISM_VERT(x2, y2, maxZ, 1.0f, 1.0f)
PRISM_VERT(x1, y1, maxZ, 0.0f, 1.0f)
/* --- Side face 2: edge p2->p0 --- */
// --- Side face 2: edge p2->p0 ---
PRISM_VERT(x2, y2, minZ, 0.0f, 0.0f)
PRISM_VERT(x0, y0, minZ, 1.0f, 0.0f)
PRISM_VERT(x0, y0, maxZ, 1.0f, 1.0f)
+10 -10
View File
@@ -13,14 +13,14 @@
shader_t *bound = NULL;
errorret_t shaderInit(shader_t *shader, const shaderdefinition_t *def) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
errorChain(shaderInitPlatform(shader, def));
bound = NULL;
errorOk();
}
errorret_t shaderBind(shader_t *shader) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
errorChain(shaderBindPlatform(shader));
bound = shader;
errorOk();
@@ -31,9 +31,9 @@ errorret_t shaderSetMatrix(
const char_t *name,
mat4 matrix
) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
assertStrLenMin(name, 1, "Uniform name cannot be empty");
assertNotNull(matrix, "Matrix cannot be null");
assertNotNull(matrix, "Matrix cannot be NULL");
assertTrue(bound == shader, "Shader must be bound.");
errorChain(shaderSetMatrixPlatform(shader, name, matrix));
errorOk();
@@ -44,7 +44,7 @@ errorret_t shaderSetTexture(
const char_t *name,
texture_t *texture
) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
assertStrLenMin(name, 1, "Uniform name cannot be empty");
assertTrue(bound == shader, "Shader must be bound.");
errorChain(shaderSetTexturePlatform(shader, name, texture));
@@ -56,7 +56,7 @@ errorret_t shaderSetColor(
const char_t *name,
color_t color
) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
assertStrLenMin(name, 1, "Uniform name cannot be empty");
assertTrue(bound == shader, "Shader must be bound.");
errorChain(shaderSetColorPlatform(shader, name, color));
@@ -67,16 +67,16 @@ errorret_t shaderSetMaterial(
shader_t *shader,
const shadermaterial_t *material
) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(material, "Material cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
assertNotNull(material, "Material cannot be NULL");
assertTrue(bound == shader, "Shader must be bound.");
assertNotNull(shader->definition, "Shader definition cannot be null");
assertNotNull(shader->definition, "Shader definition cannot be NULL");
assertNotNull(shader->definition->setMaterial, "Def lacks setMaterial");
return shader->definition->setMaterial(shader, material);
}
errorret_t shaderDispose(shader_t *shader) {
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
bound = NULL;
errorChain(shaderDisposePlatform(shader));
errorOk();
+3 -3
View File
@@ -41,10 +41,10 @@ errorret_t shaderListInit() {
}
assertNotNull(
SHADER_LIST_DEFS[i].shader, "Shader cannot be null"
SHADER_LIST_DEFS[i].shader, "Shader cannot be NULL"
);
assertNotNull(
SHADER_LIST_DEFS[i].definition, "Shader definition cannot be null"
SHADER_LIST_DEFS[i].definition, "Shader definition cannot be NULL"
);
errorChain(shaderInit(
@@ -78,7 +78,7 @@ errorret_t shaderListDispose(void) {
}
assertNotNull(
SHADER_LIST_DEFS[i].shader, "Shader cannot be null"
SHADER_LIST_DEFS[i].shader, "Shader cannot be NULL"
);
errorChain(shaderDispose(SHADER_LIST_DEFS[i].shader));
+4 -4
View File
@@ -31,9 +31,9 @@ errorret_t spriteBatchBuffer(
shader_t *shader,
const shadermaterial_t material
) {
assertNotNull(sprites, "Sprites cannot be null");
assertNotNull(sprites, "Sprites cannot be NULL");
assertTrue(count > 0, "Count must be greater than zero");
assertNotNull(shader, "Shader cannot be null");
assertNotNull(shader, "Shader cannot be NULL");
// Did the shader or material data change?
if(shader != SPRITEBATCH.shader) {
@@ -92,9 +92,9 @@ void spriteBatchBufferToMesh(
meshvertex_t *vertices,
const uint32_t verticesSize
) {
assertNotNull(sprites, "Sprites cannot be null");
assertNotNull(sprites, "Sprites cannot be NULL");
assertTrue(count > 0, "Count must be greater than zero");
assertNotNull(vertices, "Vertices cannot be null");
assertNotNull(vertices, "Vertices cannot be NULL");
assertTrue(
verticesSize >= count * QUAD_VERTEX_COUNT, "Vertices array too small"
);
@@ -27,7 +27,7 @@ typedef struct {
* @param y Screen y position of the sprite's top-left corner.
* @param width Width of the sprite in screen space.
* @param height Height of the sprite in screen space.
* @returns The populated sprite.
* @return The populated sprite.
*/
spritebatchsprite_t spriteBatchSpriteTilesetPosition(
const tileset_t *tileset,
+4 -4
View File
@@ -152,7 +152,7 @@ float_t inputGetLastValue(const inputaction_t action) {
const inputaction_t negY, const inputaction_t posY,
vec2 result
) {
assertNotNull(result, "Result vector cannot be null");
assertNotNull(result, "Result vector cannot be NULL");
result[0] = inputAxisDynamic(negX, posX);
result[1] = inputAxisDynamic(negY, posY);
}
@@ -162,7 +162,7 @@ float_t inputGetLastValue(const inputaction_t action) {
const inputaction_t negY, const inputaction_t posY,
vec2 result
) {
assertNotNull(result, "Result vector cannot be null");
assertNotNull(result, "Result vector cannot be NULL");
float_t x = inputAxisDynamic(negX, posX);
float_t y = inputAxisDynamic(negY, posY);
float_t mag = sqrtf(x * x + y * y);
@@ -208,7 +208,7 @@ void inputAxis2D(
const inputaction_t negY, const inputaction_t posY,
vec2 result
) {
assertNotNull(result, "Result vector cannot be null");
assertNotNull(result, "Result vector cannot be NULL");
result[0] = inputAxis(negX, posX);
result[1] = inputAxis(negY, posY);
}
@@ -218,7 +218,7 @@ void inputAngle2D(
const inputaction_t negY, const inputaction_t posY,
vec2 result
) {
assertNotNull(result, "Result vector cannot be null");
assertNotNull(result, "Result vector cannot be NULL");
float_t x = inputAxis(negX, posX);
float_t y = inputAxis(negY, posY);
float_t mag = sqrtf(x * x + y * y);
+1 -1
View File
@@ -82,6 +82,6 @@ void battleFighterInit(
* is not dead).
*
* @param fighter Pointer to the fighter to check.
* @returns True if the fighter can act.
* @return True if the fighter can act.
*/
bool_t battleFighterIsAlive(const battlefighter_t *fighter);
+1 -1
View File
@@ -136,7 +136,7 @@ void cutsceneSystemNext() {
// Start item.
const cutsceneitem_t *item = cutsceneSystemGetCurrentItem();
memset(&CUTSCENE_SYSTEM.data, 0, sizeof(CUTSCENE_SYSTEM.data));
memoryZero(&CUTSCENE_SYSTEM.data, sizeof(CUTSCENE_SYSTEM.data));
cutsceneItemStart(item, &CUTSCENE_SYSTEM.data);
}
+4 -4
View File
@@ -146,7 +146,7 @@ void cutsceneSystemSetOnComplete(cutscenecallback_t onComplete);
* Asserts the resolved entity is within bounds.
*
* @param entityIndex Raw entity index or sentinel value.
* @returns Pointer to the resolved entity.
* @return Pointer to the resolved entity.
*/
entity_t * cutsceneSystemGetEntity(const uint8_t entityIndex);
@@ -155,7 +155,7 @@ entity_t * cutsceneSystemGetEntity(const uint8_t entityIndex);
* a concrete map area ID.
*
* @param areaId Raw map area ID or sentinel value.
* @returns The resolved map area ID.
* @return The resolved map area ID.
*/
uint8_t cutsceneSystemGetAreaId(const uint8_t areaId);
@@ -164,7 +164,7 @@ uint8_t cutsceneSystemGetAreaId(const uint8_t areaId);
* sentinel) to a concrete UI_TEXTBOX_MINI_LIST slot index.
*
* @param index Raw slot index or sentinel value.
* @returns The resolved slot index.
* @return The resolved slot index.
*/
uint8_t cutsceneSystemGetTextMiniId(const uint8_t index);
@@ -174,7 +174,7 @@ uint8_t cutsceneSystemGetTextMiniId(const uint8_t index);
* once its keyboard closes). Empty ("") if nothing has been cached yet
* for the running cutscene.
*
* @returns The cached text.
* @return The cached text.
*/
const char_t * cutsceneSystemGetTextCache(void);
@@ -36,7 +36,7 @@ void cutsceneAudioFadeStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioFadeUpdate(
const cutsceneitem_t *item,
@@ -16,7 +16,7 @@
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the channel is no longer fading.
* @return true once the channel is no longer fading.
*/
bool_t cutsceneAudioFadeWaitUpdate(
const cutsceneitem_t *item,
@@ -25,7 +25,7 @@ void cutsceneAudioPauseStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioPauseUpdate(
const cutsceneitem_t *item,
@@ -38,7 +38,7 @@ void cutsceneAudioPlayStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioPlayUpdate(
const cutsceneitem_t *item,
@@ -25,7 +25,7 @@ void cutsceneAudioResumeStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioResumeUpdate(
const cutsceneitem_t *item,
@@ -37,7 +37,7 @@ void cutsceneAudioSetStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioSetUpdate(
const cutsceneitem_t *item,
@@ -34,7 +34,7 @@ void cutsceneAudioSetLoopStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioSetLoopUpdate(
const cutsceneitem_t *item,
@@ -31,7 +31,7 @@ void cutsceneAudioSetPanStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioSetPanUpdate(
const cutsceneitem_t *item,
@@ -25,7 +25,7 @@ void cutsceneAudioStopStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneAudioStopUpdate(
const cutsceneitem_t *item,
@@ -32,7 +32,7 @@ void cutsceneBattleForceActionStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneBattleForceActionUpdate(
const cutsceneitem_t *item,
@@ -20,7 +20,7 @@ typedef struct {
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once BATTLE.state equals the watched state.
* @return true once BATTLE.state equals the watched state.
*/
bool_t cutsceneBattleWaitStateUpdate(
const cutsceneitem_t *item,
@@ -43,7 +43,7 @@ void cutsceneStartBattleStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the battle has ended.
* @return true once the battle has ended.
*/
bool_t cutsceneStartBattleUpdate(
const cutsceneitem_t *item,
@@ -52,7 +52,7 @@ void cutsceneConcurrentStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once every child has completed.
* @return true once every child has completed.
*/
bool_t cutsceneConcurrentUpdate(
const cutsceneitem_t *item,
@@ -15,7 +15,7 @@
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneIdleUpdate(
const cutsceneitem_t *item,
@@ -29,7 +29,7 @@ void cutsceneMarkerStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneMarkerUpdate(
const cutsceneitem_t *item,
@@ -27,7 +27,7 @@ void cutsceneQuitGameStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneQuitGameUpdate(
const cutsceneitem_t *item,
@@ -27,7 +27,7 @@ void cutsceneRestartStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneRestartUpdate(
const cutsceneitem_t *item,
@@ -33,7 +33,7 @@ void cutsceneSceneStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneSceneUpdate(
const cutsceneitem_t *item,
@@ -25,7 +25,7 @@ void cutsceneSetPauseStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneSetPauseUpdate(
const cutsceneitem_t *item,
@@ -27,7 +27,7 @@ void cutsceneWaitStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true when the wait has elapsed.
* @return true when the wait has elapsed.
*/
bool_t cutsceneWaitUpdate(
const cutsceneitem_t *item,
@@ -26,7 +26,7 @@ void cutsceneCallbackStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneCallbackUpdate(
const cutsceneitem_t *item,
+2 -2
View File
@@ -213,7 +213,7 @@ void cutsceneItemStart(
*
* @param item The cutscene item to tick.
* @param data Runtime data storage.
* @returns true if the item is complete and the cutscene should advance.
* @return true if the item is complete and the cutscene should advance.
*/
bool_t cutsceneItemUpdate(
const cutsceneitem_t *item,
@@ -252,7 +252,7 @@ void cutsceneCutsceneStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneCutsceneUpdate(
const cutsceneitem_t *item,
+1 -1
View File
@@ -30,7 +30,7 @@ void cutscenePrintStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutscenePrintUpdate(
const cutsceneitem_t *item,
@@ -31,7 +31,7 @@ void cutsceneEntityAddStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneEntityAddUpdate(
const cutsceneitem_t *item,
@@ -28,7 +28,7 @@ void cutsceneEntityRemoveStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneEntityRemoveUpdate(
const cutsceneitem_t *item,
@@ -30,7 +30,7 @@ void cutsceneEntityTeleportStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneEntityTeleportUpdate(
const cutsceneitem_t *item,
@@ -32,7 +32,7 @@ void cutsceneEntityTurnStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the entity is idle and facing the target direction.
* @return true once the entity is idle and facing the target direction.
*/
bool_t cutsceneEntityTurnUpdate(
const cutsceneitem_t *item,
@@ -36,7 +36,7 @@ void cutsceneEntityWalkToStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once all waypoints have been reached.
* @return true once all waypoints have been reached.
*/
bool_t cutsceneEntityWalkToUpdate(
const cutsceneitem_t *item,
@@ -36,7 +36,7 @@ void cutsceneEntityWalkToEntityStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the entity has reached the target's side.
* @return true once the entity has reached the target's side.
*/
bool_t cutsceneEntityWalkToEntityUpdate(
const cutsceneitem_t *item,
@@ -30,7 +30,7 @@ void cutsceneItemGiveStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneItemGiveUpdate(
const cutsceneitem_t *item,
@@ -34,7 +34,7 @@ void cutsceneMapAreaAddStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneMapAreaAddUpdate(
const cutsceneitem_t *item,
@@ -29,7 +29,7 @@ void cutsceneMapAreaRemoveStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneMapAreaRemoveUpdate(
const cutsceneitem_t *item,
@@ -38,7 +38,7 @@ void cutsceneMapAreaWaitStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once any watched area has been triggered.
* @return true once any watched area has been triggered.
*/
bool_t cutsceneMapAreaWaitUpdate(
const cutsceneitem_t *item,
@@ -34,7 +34,7 @@ void cutsceneSaveDeviceCheckStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneSaveDeviceCheckUpdate(
const cutsceneitem_t *item,
@@ -33,7 +33,7 @@ void cutsceneSaveLoadAllSlotsStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneSaveLoadAllSlotsUpdate(
const cutsceneitem_t *item,
@@ -32,7 +32,7 @@ void cutsceneEmojiStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneEmojiUpdate(
const cutsceneitem_t *item,
+1 -1
View File
@@ -33,7 +33,7 @@ void cutsceneFadeStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the overlay transition has completed.
* @return true once the overlay transition has completed.
*/
bool_t cutsceneFadeUpdate(
const cutsceneitem_t *item,
@@ -36,7 +36,7 @@ void cutsceneKeyboardStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once the keyboard has closed; false while still open.
* @return true once the keyboard has closed; false while still open.
*/
bool_t cutsceneKeyboardUpdate(
const cutsceneitem_t *item,
@@ -71,7 +71,7 @@ void cutsceneModalStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true once immediately for a message-only modal; false
* @return true once immediately for a message-only modal; false
* always for a modal with options.
*/
bool_t cutsceneModalUpdate(
@@ -114,7 +114,7 @@ void cutsceneModalCloseStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns true always.
* @return true always.
*/
bool_t cutsceneModalCloseUpdate(
const cutsceneitem_t *item,
@@ -46,7 +46,7 @@ void cutsceneModalOptionsMarkersStart(
*
* @param item The cutscene item.
* @param data Runtime data storage.
* @returns false always.
* @return false always.
*/
bool_t cutsceneModalOptionsMarkersUpdate(
const cutsceneitem_t *item,
Loaded 100 of 206 files, more files were not shown because too many files have changed in this diff. Show more