Wrap long lines to fit within 80 columns across the codebase

Pure whitespace/line-break reformatting (braces, newlines, and line
continuations matching this codebase's existing wrap conventions) - no
logic, string content, or identifiers changed anywhere. Confirmed via
diff against the pre-change tree and by rebuilding + re-running the
affected test suites, which produce identical pass/fail results.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
2026-09-05 13:13:10 -05:00
co-authored by Claude Sonnet 5
parent de53bebeb8
commit cebd3d81e7
70 changed files with 1025 additions and 425 deletions
+4 -1
View File
@@ -25,7 +25,10 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "vita")
add_subdirectory(dusksdl2)
add_subdirectory(duskgl)
elseif(DUSK_TARGET_SYSTEM STREQUAL "wii" OR DUSK_TARGET_SYSTEM STREQUAL "gamecube")
elseif(
DUSK_TARGET_SYSTEM STREQUAL "wii" OR
DUSK_TARGET_SYSTEM STREQUAL "gamecube"
)
add_subdirectory(duskdolphin)
add_subdirectory(duskmad)
+6 -2
View File
@@ -26,7 +26,9 @@ if(NOT stb_image_FOUND)
if(STB_IMAGE_FOUND)
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC stb_image)
else()
message(FATAL_ERROR "stb_image not found. Please ensure stb is correctly fetched.")
message(FATAL_ERROR
"stb_image not found. Please ensure stb is correctly fetched."
)
endif()
endif()
@@ -35,7 +37,9 @@ if(NOT yyjson_FOUND)
if(yyjson_FOUND)
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC yyjson::yyjson)
else()
message(FATAL_ERROR "yyjson not found. Please ensure yyjson is correctly fetched.")
message(FATAL_ERROR
"yyjson not found. Please ensure yyjson is correctly fetched."
)
endif()
endif()
+3 -1
View File
@@ -364,7 +364,9 @@ errorret_t assetUpdate(void) {
assetentry_t *errEntry = loading->entry;
loading->entry = NULL;
threadMutexUnlock(&loading->mutex);
if(errEntry->onError) errEntry->onError(errEntry, errEntry->onErrorUser);
if(errEntry->onError) {
errEntry->onError(errEntry, errEntry->onErrorUser);
}
loading++;
break;
}
+31 -14
View File
@@ -114,15 +114,18 @@ errorret_t assetDskOpenFromPathRange(
);
if(compressedSource == NULL) {
errorThrow(
"Failed to create compressed dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create compressed dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outCompressed = zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
*outCompressed =
zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
if(*outCompressed == NULL) {
zip_source_free(compressedSource);
errorThrow(
"Failed to open compressed dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open compressed dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
@@ -136,7 +139,8 @@ errorret_t assetDskOpenFromPathRange(
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to create stored dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create stored dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
@@ -146,7 +150,8 @@ errorret_t assetDskOpenFromPathRange(
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to open stored dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open stored dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
@@ -161,7 +166,9 @@ errorret_t assetDskOpenFromPathRange(
zip_close(*outCompressed);
*outStored = NULL;
*outCompressed = NULL;
errorThrow("Failed to re-open dusk.dsk to verify stored checksum: %s", path);
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);
@@ -172,17 +179,22 @@ errorret_t assetDskOpenFromPathRange(
zip_close(*outCompressed);
*outStored = NULL;
*outCompressed = NULL;
errorThrow("Failed to read dusk.dsk stored archive to verify checksum: %s", path);
errorThrow(
"Failed to read dusk.dsk stored archive to verify checksum: %s", path
);
}
uint32_t checksum = (uint32_t) crc32(0L, storedBytes, (uInt) header.storedSize);
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);
errorThrow(
"dusk.dsk stored archive failed checksum verification: %s", path
);
}
errorOk();
@@ -235,15 +247,18 @@ errorret_t assetDskOpenFromBuffer(
);
if(compressedSource == NULL) {
errorThrow(
"Failed to create compressed dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create compressed dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
*outCompressed = zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
*outCompressed =
zip_open_from_source(compressedSource, ZIP_RDONLY, &zipError);
if(*outCompressed == NULL) {
zip_source_free(compressedSource);
errorThrow(
"Failed to open compressed dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open compressed dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
@@ -254,7 +269,8 @@ errorret_t assetDskOpenFromBuffer(
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to create stored dusk.dsk source: %s", zip_error_strerror(&zipError)
"Failed to create stored dusk.dsk source: %s",
zip_error_strerror(&zipError)
);
}
@@ -264,7 +280,8 @@ errorret_t assetDskOpenFromBuffer(
zip_close(*outCompressed);
*outCompressed = NULL;
errorThrow(
"Failed to open stored dusk.dsk archive: %s", zip_error_strerror(&zipError)
"Failed to open stored dusk.dsk archive: %s",
zip_error_strerror(&zipError)
);
}
@@ -25,7 +25,8 @@
// 'name' to a sibling assets/cutscenes/<name>.jsonc asset at parse time -
// see the CUTSCENE_ITEM_TYPE_CUTSCENE case below.
// Indexed directly by cutsceneitemtype_t rather than searched by value.
static const assetcutsceneitemtypeentry_t ASSET_CUTSCENE_ITEM_TYPE_TABLE[CUTSCENE_ITEM_TYPE_COUNT] = {
static const assetcutsceneitemtypeentry_t
ASSET_CUTSCENE_ITEM_TYPE_TABLE[CUTSCENE_ITEM_TYPE_COUNT] = {
[CUTSCENE_ITEM_TYPE_NULL] = { "NULL" },
[CUTSCENE_ITEM_TYPE_TEXT] = { "TEXT" },
[CUTSCENE_ITEM_TYPE_TEXT_MINI] = { "TEXT_MINI" },
@@ -134,13 +135,15 @@ static const assetcutsceneenumentry_t ASSET_CUTSCENE_UI_EMOJI_TABLE[] = {
#define ASSET_CUTSCENE_UI_EMOJI_TABLE_COUNT \
(sizeof(ASSET_CUTSCENE_UI_EMOJI_TABLE) / sizeof(assetcutsceneenumentry_t))
static const assetcutsceneenumentry_t ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE[] = {
static const assetcutsceneenumentry_t
ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE[] = {
{ "REGULAR", BATTLE_ENCOUNTER_REGULAR },
{ "PLAYER_ADVANTAGE", BATTLE_ENCOUNTER_PLAYER_ADVANTAGE },
{ "BACK_ATTACK", BATTLE_ENCOUNTER_BACK_ATTACK },
};
#define ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE_COUNT \
(sizeof(ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE) / sizeof(assetcutsceneenumentry_t))
(sizeof(ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE) / \
sizeof(assetcutsceneenumentry_t))
static const assetcutsceneenumentry_t ASSET_CUTSCENE_BATTLE_STATE_TABLE[] = {
{ "NONE", BATTLE_STATE_NONE },
@@ -168,7 +171,8 @@ static const assetcutsceneenumentry_t ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE[] = {
{ "MAIN_MENU", UI_SCREEN_TYPE_MAIN_MENU },
};
#define ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE_COUNT \
(sizeof(ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE) / sizeof(assetcutsceneenumentry_t))
(sizeof(ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE) / \
sizeof(assetcutsceneenumentry_t))
static const assetcutsceneenumentry_t ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE[] = {
{ "BGM_0", AUDIO_MIXER_CHANNEL_BGM_0 },
@@ -180,7 +184,8 @@ static const assetcutsceneenumentry_t ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE[] = {
{ "SFX_3", AUDIO_MIXER_CHANNEL_SFX_3 },
};
#define ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT \
(sizeof(ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE) / sizeof(assetcutsceneenumentry_t))
(sizeof(ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE) / \
sizeof(assetcutsceneenumentry_t))
// Sentinels accepted in place of a literal index/id - see
// cutscenesystem.h's CUTSCENE_ENTITY_INTERACT/INTERACTED/CUTSCENE_AREA_
@@ -381,15 +386,20 @@ errorret_t assetCutsceneParseItem(
(uint32_t)index
);
}
item->textMini.position[0] = (float_t)yyjson_get_num(yyjson_arr_get(position, 0));
item->textMini.position[1] = (float_t)yyjson_get_num(yyjson_arr_get(position, 1));
item->textMini.position[2] = (float_t)yyjson_get_num(yyjson_arr_get(position, 2));
item->textMini.duration = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
item->textMini.position[0] =
(float_t)yyjson_get_num(yyjson_arr_get(position, 0));
item->textMini.position[1] =
(float_t)yyjson_get_num(yyjson_arr_get(position, 1));
item->textMini.position[2] =
(float_t)yyjson_get_num(yyjson_arr_get(position, 2));
item->textMini.duration =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
break;
}
case CUTSCENE_ITEM_TYPE_TEXT_MINI_HIDE:
item->textMiniHide.index = (uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "index"));
item->textMiniHide.index =
(uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "index"));
break;
case CUTSCENE_ITEM_TYPE_WAIT:
@@ -400,7 +410,8 @@ errorret_t assetCutsceneParseItem(
const char_t *name = yyjson_get_str(yyjson_obj_get(itemObj, "name"));
if(name == NULL) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (CUTSCENE): missing 'name'", (uint32_t)index
loading, "Cutscene item %u (CUTSCENE): missing 'name'",
(uint32_t)index
);
}
@@ -415,12 +426,14 @@ errorret_t assetCutsceneParseItem(
int32_t pathLen = stringFormat(NULL, 0, "cutscenes/%s.jsonc", name);
if(pathLen < 0 || (size_t)pathLen >= ASSET_FILE_NAME_MAX) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (CUTSCENE): 'name' too long", (uint32_t)index
loading, "Cutscene item %u (CUTSCENE): 'name' too long",
(uint32_t)index
);
}
stringFormat(path, sizeof(path), "cutscenes/%s.jsonc", name);
assetentry_t *refEntry = assetLock(path, ASSET_LOADER_TYPE_CUTSCENE, NULL);
assetentry_t *refEntry =
assetLock(path, ASSET_LOADER_TYPE_CUTSCENE, NULL);
assetLoaderErrorChain(loading, assetRequireLoaded(refEntry));
item->cutscene = &refEntry->data.cutscene.cutscene;
break;
@@ -428,7 +441,8 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_ENTITY_TELEPORT:
if(!assetCutsceneResolveEntityIndex(
yyjson_obj_get(itemObj, "entityIndex"), &item->entityTeleport.entityIndex
yyjson_obj_get(itemObj, "entityIndex"),
&item->entityTeleport.entityIndex
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (ENTITY_TELEPORT): invalid 'entityIndex'",
@@ -439,8 +453,8 @@ errorret_t assetCutsceneParseItem(
yyjson_obj_get(itemObj, "target"), &item->entityTeleport.target
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (ENTITY_TELEPORT): 'target' must be [x, y, z]",
(uint32_t)index
loading, "Cutscene item %u (ENTITY_TELEPORT): 'target' must be "
"[x, y, z]", (uint32_t)index
);
}
break;
@@ -455,7 +469,8 @@ errorret_t assetCutsceneParseItem(
);
}
yyjson_val *walkAround = yyjson_obj_get(itemObj, "walkAround");
item->entityWalkTo.walkAround = walkAround == NULL ? true : yyjson_get_bool(walkAround);
item->entityWalkTo.walkAround =
walkAround == NULL ? true : yyjson_get_bool(walkAround);
yyjson_val *positions = yyjson_obj_get(itemObj, "positions");
size_t count = yyjson_arr_size(positions);
@@ -504,9 +519,11 @@ errorret_t assetCutsceneParseItem(
item->fade.to.g = (uint8_t)yyjson_get_int(yyjson_arr_get(to, 1));
item->fade.to.b = (uint8_t)yyjson_get_int(yyjson_arr_get(to, 2));
item->fade.to.a = (uint8_t)yyjson_get_int(yyjson_arr_get(to, 3));
item->fade.duration = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
item->fade.duration =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
const char_t *easingName = yyjson_get_str(yyjson_obj_get(itemObj, "easing"));
const char_t *easingName =
yyjson_get_str(yyjson_obj_get(itemObj, "easing"));
int32_t easingValue = EASING_LINEAR;
if(easingName != NULL && !assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_EASING_TABLE, ASSET_CUTSCENE_EASING_TABLE_COUNT,
@@ -534,7 +551,8 @@ errorret_t assetCutsceneParseItem(
while((flagVal = yyjson_arr_iter_next(&iter)) != NULL) {
int32_t flagValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_PAUSE_FLAG_TABLE, ASSET_CUTSCENE_PAUSE_FLAG_TABLE_COUNT,
ASSET_CUTSCENE_PAUSE_FLAG_TABLE,
ASSET_CUTSCENE_PAUSE_FLAG_TABLE_COUNT,
yyjson_get_str(flagVal), &flagValue
)) {
assetLoaderErrorThrow(
@@ -549,8 +567,10 @@ errorret_t assetCutsceneParseItem(
}
case CUTSCENE_ITEM_TYPE_ITEM_GIVE:
item->itemGive.item = (itemid_t)yyjson_get_int(yyjson_obj_get(itemObj, "item"));
item->itemGive.quantity = (uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "quantity"));
item->itemGive.item =
(itemid_t)yyjson_get_int(yyjson_obj_get(itemObj, "item"));
item->itemGive.quantity =
(uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "quantity"));
break;
case CUTSCENE_ITEM_TYPE_ENTITY_REMOVE:
@@ -567,7 +587,8 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_ENTITY_ADD: {
int32_t entityTypeValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_ENTITY_TYPE_TABLE, ASSET_CUTSCENE_ENTITY_TYPE_TABLE_COUNT,
ASSET_CUTSCENE_ENTITY_TYPE_TABLE,
ASSET_CUTSCENE_ENTITY_TYPE_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "entityType")), &entityTypeValue
)) {
assetLoaderErrorThrow(
@@ -580,8 +601,8 @@ errorret_t assetCutsceneParseItem(
yyjson_obj_get(itemObj, "position"), &item->entityAdd.position
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (ENTITY_ADD): 'position' must be [x, y, z]",
(uint32_t)index
loading, "Cutscene item %u (ENTITY_ADD): 'position' must be "
"[x, y, z]", (uint32_t)index
);
}
break;
@@ -612,14 +633,15 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_ENTITY_WALK_TO_ENTITY:
if(!assetCutsceneResolveEntityIndex(
yyjson_obj_get(itemObj, "entityIndex"), &item->entityWalkToEntity.entityIndex
yyjson_obj_get(itemObj, "entityIndex"),
&item->entityWalkToEntity.entityIndex
) || !assetCutsceneResolveEntityIndex(
yyjson_obj_get(itemObj, "targetEntityIndex"),
&item->entityWalkToEntity.targetEntityIndex
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (ENTITY_WALK_TO_ENTITY): invalid entity index",
(uint32_t)index
loading, "Cutscene item %u (ENTITY_WALK_TO_ENTITY): invalid entity "
"index", (uint32_t)index
);
}
item->entityWalkToEntity.offsetX =
@@ -642,7 +664,10 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_MAP_AREA_WAIT: {
yyjson_val *areaIds = yyjson_obj_get(itemObj, "areaIds");
size_t count = yyjson_arr_size(areaIds);
if(!yyjson_is_arr(areaIds) || count == 0 || count > CUTSCENE_MAP_AREA_WAIT_MAX) {
if(
!yyjson_is_arr(areaIds) || count == 0 ||
count > CUTSCENE_MAP_AREA_WAIT_MAX
) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (MAP_AREA_WAIT): 'areaIds' must have "
"1-%u entries", (uint32_t)index, (uint32_t)CUTSCENE_MAP_AREA_WAIT_MAX
@@ -671,8 +696,10 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_START_BATTLE: {
int32_t encounterValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE, ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "encounterType")), &encounterValue
ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE,
ASSET_CUTSCENE_BATTLE_ENCOUNTER_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "encounterType")),
&encounterValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (START_BATTLE): invalid 'encounterType'",
@@ -691,7 +718,8 @@ errorret_t assetCutsceneParseItem(
enemyCount > CUTSCENE_START_BATTLE_ENEMY_COUNT_MAX) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (START_BATTLE): 'enemies' must have 1-%u "
"entries", (uint32_t)index, (uint32_t)CUTSCENE_START_BATTLE_ENEMY_COUNT_MAX
"entries", (uint32_t)index,
(uint32_t)CUTSCENE_START_BATTLE_ENEMY_COUNT_MAX
);
}
item->startBattle.enemyCount = (uint8_t)enemyCount;
@@ -708,13 +736,20 @@ errorret_t assetCutsceneParseItem(
);
}
cutscenestartbattleenemy_t *enemy = &item->startBattle.enemies[e];
enemy->stats.attack = (uint16_t)yyjson_get_int(yyjson_obj_get(stats, "attack"));
enemy->stats.defense = (uint16_t)yyjson_get_int(yyjson_obj_get(stats, "defense"));
enemy->stats.magic = (uint16_t)yyjson_get_int(yyjson_obj_get(stats, "magic"));
enemy->stats.speed = (uint16_t)yyjson_get_int(yyjson_obj_get(stats, "speed"));
enemy->stats.luck = (uint16_t)yyjson_get_int(yyjson_obj_get(stats, "luck"));
enemy->healthMax = (uint16_t)yyjson_get_int(yyjson_obj_get(enemyVal, "healthMax"));
enemy->mpMax = (uint16_t)yyjson_get_int(yyjson_obj_get(enemyVal, "mpMax"));
enemy->stats.attack =
(uint16_t)yyjson_get_int(yyjson_obj_get(stats, "attack"));
enemy->stats.defense =
(uint16_t)yyjson_get_int(yyjson_obj_get(stats, "defense"));
enemy->stats.magic =
(uint16_t)yyjson_get_int(yyjson_obj_get(stats, "magic"));
enemy->stats.speed =
(uint16_t)yyjson_get_int(yyjson_obj_get(stats, "speed"));
enemy->stats.luck =
(uint16_t)yyjson_get_int(yyjson_obj_get(stats, "luck"));
enemy->healthMax =
(uint16_t)yyjson_get_int(yyjson_obj_get(enemyVal, "healthMax"));
enemy->mpMax =
(uint16_t)yyjson_get_int(yyjson_obj_get(enemyVal, "mpMax"));
e++;
}
break;
@@ -725,17 +760,20 @@ errorret_t assetCutsceneParseItem(
yyjson_obj_get(itemObj, "entityIndex"), &item->emoji.entityIndex
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (EMOJI): invalid 'entityIndex'", (uint32_t)index
loading, "Cutscene item %u (EMOJI): invalid 'entityIndex'",
(uint32_t)index
);
}
item->emoji.duration = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
item->emoji.duration =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
int32_t emojiValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_UI_EMOJI_TABLE, ASSET_CUTSCENE_UI_EMOJI_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "emojiType")), &emojiValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (EMOJI): invalid 'emojiType'", (uint32_t)index
loading, "Cutscene item %u (EMOJI): invalid 'emojiType'",
(uint32_t)index
);
}
item->emoji.emojiType = (uiemojitype_t)emojiValue;
@@ -743,14 +781,17 @@ errorret_t assetCutsceneParseItem(
}
case CUTSCENE_ITEM_TYPE_SHAKE:
item->shake.amount = (uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "amount"));
item->shake.duration = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
item->shake.amount =
(uint8_t)yyjson_get_int(yyjson_obj_get(itemObj, "amount"));
item->shake.duration =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
break;
case CUTSCENE_ITEM_TYPE_BATTLE_WAIT_STATE: {
int32_t stateValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_BATTLE_STATE_TABLE, ASSET_CUTSCENE_BATTLE_STATE_TABLE_COUNT,
ASSET_CUTSCENE_BATTLE_STATE_TABLE,
ASSET_CUTSCENE_BATTLE_STATE_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "state")), &stateValue
)) {
assetLoaderErrorThrow(
@@ -780,7 +821,8 @@ errorret_t assetCutsceneParseItem(
itemObj, "title", "", item->modal.title, CUTSCENE_MODAL_TITLE_MAX_CHARS
);
if(!assetCutsceneCopyStringField(
itemObj, "message", NULL, item->modal.message, CUTSCENE_MODAL_MESSAGE_MAX_CHARS
itemObj, "message", NULL, item->modal.message,
CUTSCENE_MODAL_MESSAGE_MAX_CHARS
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (MODAL): missing/too-long 'message'",
@@ -821,7 +863,8 @@ errorret_t assetCutsceneParseItem(
size_t o = 0;
while((optionVal = yyjson_arr_iter_next(&iter)) != NULL) {
const char_t *text = yyjson_get_str(yyjson_obj_get(optionVal, "text"));
const char_t *marker = yyjson_get_str(yyjson_obj_get(optionVal, "marker"));
const char_t *marker =
yyjson_get_str(yyjson_obj_get(optionVal, "marker"));
if(text == NULL || marker == NULL) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (MODAL_OPTIONS_MARKERS): options[%u] "
@@ -843,7 +886,8 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_UI_SHOW: {
int32_t screenValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE, ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE_COUNT,
ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE,
ASSET_CUTSCENE_UI_SCREEN_TYPE_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "name")), &screenValue
)) {
assetLoaderErrorThrow(
@@ -859,7 +903,8 @@ errorret_t assetCutsceneParseItem(
itemObj, "text", NULL, item->print.text, CUTSCENE_PRINT_MAX_CHARS
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (PRINT): missing/too-long 'text'", (uint32_t)index
loading, "Cutscene item %u (PRINT): missing/too-long 'text'",
(uint32_t)index
);
}
break;
@@ -882,7 +927,8 @@ errorret_t assetCutsceneParseItem(
yyjson_get_str(yyjson_obj_get(itemObj, "sceneType")), &sceneValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (SCENE): invalid 'sceneType'", (uint32_t)index
loading, "Cutscene item %u (SCENE): invalid 'sceneType'",
(uint32_t)index
);
}
item->sceneChange.type = (scenetype_t)sceneValue;
@@ -890,8 +936,10 @@ errorret_t assetCutsceneParseItem(
}
case CUTSCENE_ITEM_TYPE_SAVE_DEVICE_CHECK: {
const char_t *successMarker = yyjson_get_str(yyjson_obj_get(itemObj, "successMarker"));
const char_t *failureMarker = yyjson_get_str(yyjson_obj_get(itemObj, "failureMarker"));
const char_t *successMarker =
yyjson_get_str(yyjson_obj_get(itemObj, "successMarker"));
const char_t *failureMarker =
yyjson_get_str(yyjson_obj_get(itemObj, "failureMarker"));
if(successMarker == NULL || failureMarker == NULL) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (SAVE_DEVICE_CHECK): needs "
@@ -904,8 +952,10 @@ errorret_t assetCutsceneParseItem(
}
case CUTSCENE_ITEM_TYPE_SAVE_LOAD_ALL_SLOTS: {
const char_t *successMarker = yyjson_get_str(yyjson_obj_get(itemObj, "successMarker"));
const char_t *failureMarker = yyjson_get_str(yyjson_obj_get(itemObj, "failureMarker"));
const char_t *successMarker =
yyjson_get_str(yyjson_obj_get(itemObj, "successMarker"));
const char_t *failureMarker =
yyjson_get_str(yyjson_obj_get(itemObj, "failureMarker"));
if(successMarker == NULL || failureMarker == NULL) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (SAVE_LOAD_ALL_SLOTS): needs "
@@ -928,21 +978,25 @@ errorret_t assetCutsceneParseItem(
}
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (AUDIO_PLAY): invalid 'channel'", (uint32_t)index
loading, "Cutscene item %u (AUDIO_PLAY): invalid 'channel'",
(uint32_t)index
);
}
item->audioPlay.channel = (audiomixerchannel_t)channelValue;
yyjson_val *volume = yyjson_obj_get(itemObj, "volume");
item->audioPlay.volume = volume == NULL ? 1.0f : (float_t)yyjson_get_num(volume);
item->audioPlay.volume =
volume == NULL ? 1.0f : (float_t)yyjson_get_num(volume);
yyjson_val *pan = yyjson_obj_get(itemObj, "pan");
item->audioPlay.pan = pan == NULL ? 0.0f : (float_t)yyjson_get_num(pan);
yyjson_val *looping = yyjson_obj_get(itemObj, "looping");
item->audioPlay.looping = looping == NULL ? false : yyjson_get_bool(looping);
item->audioPlay.looping =
looping == NULL ? false : yyjson_get_bool(looping);
yyjson_val *loopCount = yyjson_obj_get(itemObj, "loopCount");
item->audioPlay.loopCount =
loopCount == NULL ? 0 : (uint8_t)yyjson_get_int(loopCount);
@@ -950,7 +1004,8 @@ errorret_t assetCutsceneParseItem(
item->audioPlay.loopStart =
loopStart == NULL ? -1.0f : (float_t)yyjson_get_num(loopStart);
yyjson_val *loopTo = yyjson_obj_get(itemObj, "loopTo");
item->audioPlay.loopTo = loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
item->audioPlay.loopTo =
loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
break;
}
@@ -960,7 +1015,8 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_AUDIO_FADE_WAIT: {
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
@@ -989,26 +1045,33 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_AUDIO_FADE: {
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (AUDIO_FADE): invalid 'channel'", (uint32_t)index
loading, "Cutscene item %u (AUDIO_FADE): invalid 'channel'",
(uint32_t)index
);
}
item->audioFade.channel = (audiomixerchannel_t)channelValue;
item->audioFade.from = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "from"));
item->audioFade.to = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "to"));
item->audioFade.duration = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
item->audioFade.from =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "from"));
item->audioFade.to =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "to"));
item->audioFade.duration =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "duration"));
const char_t *easingName = yyjson_get_str(yyjson_obj_get(itemObj, "easing"));
const char_t *easingName =
yyjson_get_str(yyjson_obj_get(itemObj, "easing"));
int32_t easingValue = EASING_LINEAR;
if(easingName != NULL && !assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_EASING_TABLE, ASSET_CUTSCENE_EASING_TABLE_COUNT,
easingName, &easingValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (AUDIO_FADE): invalid 'easing'", (uint32_t)index
loading, "Cutscene item %u (AUDIO_FADE): invalid 'easing'",
(uint32_t)index
);
}
item->audioFade.easing = (easingtype_t)easingValue;
@@ -1018,7 +1081,8 @@ errorret_t assetCutsceneParseItem(
case CUTSCENE_ITEM_TYPE_AUDIO_SET_PAN: {
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
@@ -1027,14 +1091,16 @@ errorret_t assetCutsceneParseItem(
);
}
item->audioSetPan.channel = (audiomixerchannel_t)channelValue;
item->audioSetPan.pan = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "pan"));
item->audioSetPan.pan =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "pan"));
break;
}
case CUTSCENE_ITEM_TYPE_AUDIO_SET_LOOP: {
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
@@ -1044,7 +1110,8 @@ errorret_t assetCutsceneParseItem(
}
item->audioSetLoop.channel = (audiomixerchannel_t)channelValue;
yyjson_val *looping = yyjson_obj_get(itemObj, "looping");
item->audioSetLoop.looping = looping == NULL ? true : yyjson_get_bool(looping);
item->audioSetLoop.looping =
looping == NULL ? true : yyjson_get_bool(looping);
yyjson_val *loopCount = yyjson_obj_get(itemObj, "loopCount");
item->audioSetLoop.loopCount =
loopCount == NULL ? 0 : (uint8_t)yyjson_get_int(loopCount);
@@ -1052,24 +1119,29 @@ errorret_t assetCutsceneParseItem(
item->audioSetLoop.loopStart =
loopStart == NULL ? -1.0f : (float_t)yyjson_get_num(loopStart);
yyjson_val *loopTo = yyjson_obj_get(itemObj, "loopTo");
item->audioSetLoop.loopTo = loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
item->audioSetLoop.loopTo =
loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
break;
}
case CUTSCENE_ITEM_TYPE_AUDIO_SET: {
int32_t channelValue;
if(!assetCutsceneLookupEnumInsensitive(
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE, ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE,
ASSET_CUTSCENE_AUDIO_CHANNEL_TABLE_COUNT,
yyjson_get_str(yyjson_obj_get(itemObj, "channel")), &channelValue
)) {
assetLoaderErrorThrow(
loading, "Cutscene item %u (AUDIO_SET): invalid 'channel'", (uint32_t)index
loading, "Cutscene item %u (AUDIO_SET): invalid 'channel'",
(uint32_t)index
);
}
item->audioSet.channel = (audiomixerchannel_t)channelValue;
item->audioSet.pan = (float_t)yyjson_get_num(yyjson_obj_get(itemObj, "pan"));
item->audioSet.pan =
(float_t)yyjson_get_num(yyjson_obj_get(itemObj, "pan"));
yyjson_val *looping = yyjson_obj_get(itemObj, "looping");
item->audioSet.looping = looping == NULL ? true : yyjson_get_bool(looping);
item->audioSet.looping =
looping == NULL ? true : yyjson_get_bool(looping);
yyjson_val *loopCount = yyjson_obj_get(itemObj, "loopCount");
item->audioSet.loopCount =
loopCount == NULL ? 0 : (uint8_t)yyjson_get_int(loopCount);
@@ -1077,7 +1149,8 @@ errorret_t assetCutsceneParseItem(
item->audioSet.loopStart =
loopStart == NULL ? -1.0f : (float_t)yyjson_get_num(loopStart);
yyjson_val *loopTo = yyjson_obj_get(itemObj, "loopTo");
item->audioSet.loopTo = loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
item->audioSet.loopTo =
loopTo == NULL ? 0.0f : (float_t)yyjson_get_num(loopTo);
break;
}
@@ -1112,7 +1185,9 @@ errorret_t assetCutsceneLoaderAsync(assetloading_t *loading) {
assertNotNull(loading, "Loading cannot be NULL");
assertNotMainThread("Should be called from an async thread.");
if(loading->loading.cutscene.state != ASSET_CUTSCENE_LOADING_STATE_READ_FILE) {
if(
loading->loading.cutscene.state != ASSET_CUTSCENE_LOADING_STATE_READ_FILE
) {
errorOk();
}
@@ -1124,7 +1199,9 @@ errorret_t assetCutsceneLoaderAsync(assetloading_t *loading) {
);
if(file->size > ASSET_CUTSCENE_FILE_SIZE_MAX) {
assetLoaderErrorThrow(loading, "Cutscene JSON exceeds maximum allowed size");
assetLoaderErrorThrow(
loading, "Cutscene JSON exceeds maximum allowed size"
);
}
size_t fileSize = (size_t)file->size;
@@ -1199,7 +1276,9 @@ errorret_t assetCutsceneLoaderSync(assetloading_t *loading) {
yyjson_get_str(flagVal), &flagValue
)) {
assetCutsceneFreeParsed(out);
assetLoaderErrorThrow(loading, "Cutscene JSON has an invalid 'pause' flag");
assetLoaderErrorThrow(
loading, "Cutscene JSON has an invalid 'pause' flag"
);
}
pause |= (cutscenepause_t)flagValue;
}
+2 -1
View File
@@ -115,7 +115,8 @@ errorret_t assetModelLoaderSync(assetloading_t *loading) {
assetUnlockEntry(jsonEntry);
// Lock and load the mesh sub-asset.
assetentry_t *meshEntry = assetLock(meshName, ASSET_LOADER_TYPE_MESH, NULL);
assetentry_t *meshEntry =
assetLock(meshName, ASSET_LOADER_TYPE_MESH, NULL);
ret = assetRequireLoaded(meshEntry);
if(errorIsNotOk(ret)) {
assetUnlockEntry(meshEntry);
@@ -502,7 +502,8 @@ errorret_t assetLocaleCacheFind(
if(i > 0) {
assetlocalecacheentry_t hit = *entry;
memoryMove(
&cache->entries[1], &cache->entries[0], i * sizeof(assetlocalecacheentry_t)
&cache->entries[1], &cache->entries[0],
i * sizeof(assetlocalecacheentry_t)
);
cache->entries[0] = hit;
}
@@ -533,7 +534,8 @@ void assetLocaleCacheInsert(
if(strlen(value) >= ASSET_LOCALE_CACHE_VALUE_MAX) return;
if(file->cache == NULL) {
file->cache = (assetlocalecache_t *)memoryAllocate(sizeof(assetlocalecache_t));
file->cache =
(assetlocalecache_t *)memoryAllocate(sizeof(assetlocalecache_t));
memoryZero(file->cache, sizeof(assetlocalecache_t));
}
+29 -12
View File
@@ -30,9 +30,15 @@ static const uint16_t ASSET_MP3_BITRATE_MPEG2_L3[16] = {
0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, 0
};
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG1[4] = { 44100, 48000, 32000, 0 };
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG2[4] = { 22050, 24000, 16000, 0 };
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG25[4] = { 11025, 12000, 8000, 0 };
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG1[4] = {
44100, 48000, 32000, 0
};
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG2[4] = {
22050, 24000, 16000, 0
};
static const uint32_t ASSET_MP3_SAMPLE_RATE_MPEG25[4] = {
11025, 12000, 8000, 0
};
errorret_t assetMp3LoaderAsync(assetloading_t *loading) {
assertNotNull(loading, "Loading cannot be NULL");
@@ -124,7 +130,9 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
(size_t) file->size > searchBase ? (size_t) file->size - searchBase : 0
);
if(searchWindowSize < 4) {
errorThrow("MP3 file is too short to contain a frame header: %s", file->filename);
errorThrow(
"MP3 file is too short to contain a frame header: %s", file->filename
);
}
uint8_t *window = (uint8_t *) memoryAllocate(searchWindowSize);
@@ -142,11 +150,14 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
const uint8_t versionBits = (window[i + 1] >> 3) & 0x3;
const uint8_t layerBits = (window[i + 1] >> 1) & 0x3;
if(versionBits == 1 || layerBits != 1) continue; // reserved version, or not Layer III
// reserved version, or not Layer III
if(versionBits == 1 || layerBits != 1) continue;
const uint8_t bitrateIndex = (window[i + 2] >> 4) & 0xF;
const uint8_t sampleRateIndex = (window[i + 2] >> 2) & 0x3;
if(bitrateIndex == 0 || bitrateIndex == 15 || sampleRateIndex == 3) continue;
if(
bitrateIndex == 0 || bitrateIndex == 15 || sampleRateIndex == 3
) continue;
const uint8_t channelMode = (window[i + 3] >> 6) & 0x3;
const bool_t isMpeg1 = versionBits == 3;
@@ -187,8 +198,10 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
if((flags & 0x1) != 0 && xingOffset + 12 <= searchWindowSize) {
const uint8_t *framesBytes = window + xingOffset + 8;
const uint32_t xingFrameCount = (
((uint32_t) framesBytes[0] << 24) | ((uint32_t) framesBytes[1] << 16) |
((uint32_t) framesBytes[2] << 8) | (uint32_t) framesBytes[3]
((uint32_t) framesBytes[0] << 24) |
((uint32_t) framesBytes[1] << 16) |
((uint32_t) framesBytes[2] << 8) |
(uint32_t) framesBytes[3]
);
// The Xing/Info header's frame count includes the header's own
// frame (this one, at `i`) - which libmad (and sceMp3) will
@@ -201,7 +214,8 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
// as "never loops"), since real decode output can never catch up
// to an overstated total.
if(xingFrameCount > 0) {
mp3File->totalFrames = (size_t) (xingFrameCount - 1) * mp3File->samplesPerFrame;
mp3File->totalFrames =
(size_t) (xingFrameCount - 1) * mp3File->samplesPerFrame;
}
}
}
@@ -215,7 +229,8 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
if(!found) {
errorThrow(
"MP3 file has no valid MPEG-1/2/2.5 Layer III frame within the first %u bytes: %s",
"MP3 file has no valid MPEG-1/2/2.5 Layer III frame within the first "
"%u bytes: %s",
(uint32_t) searchWindowSize, file->filename
);
}
@@ -229,9 +244,11 @@ errorret_t assetMp3ParseHeader(assetfile_t *file, assetmp3file_t *mp3File) {
// of an exact one).
if(mp3File->totalFrames == 0) {
const float_t durationSeconds = (
((float_t) mp3File->dataSize * 8.0f) / ((float_t) mp3File->bitrateKbps * 1000.0f)
((float_t) mp3File->dataSize * 8.0f) /
((float_t) mp3File->bitrateKbps * 1000.0f)
);
mp3File->totalFrames = (size_t) (durationSeconds * (float_t) mp3File->sampleRate);
mp3File->totalFrames =
(size_t) (durationSeconds * (float_t) mp3File->sampleRate);
}
errorOk();
+2 -1
View File
@@ -268,7 +268,8 @@ errorret_t audioStreamUpdate(audiostream_t *stream) {
stream->onLoop(stream);
}
} else {
stream->state &= ~(AUDIO_STREAM_STATE_PLAYING | AUDIO_STREAM_STATE_BUFFERED);
stream->state &=
~(AUDIO_STREAM_STATE_PLAYING | AUDIO_STREAM_STATE_BUFFERED);
if(stream->onEnd != NULL) {
stream->onEnd(stream);
+10 -4
View File
@@ -86,7 +86,9 @@ errorret_t audioStreamMp3Seek(audiostream_t *stream, const size_t frame) {
while(stream->mp3.position < frame) {
size_t decodedFrames = 0;
errorChain(audioStreamMp3DecoderDecodeFrame(stream, discard, &decodedFrames));
errorChain(
audioStreamMp3DecoderDecodeFrame(stream, discard, &decodedFrames)
);
if(decodedFrames == 0) {
// Ran out of stream before reaching the target - clamp rather than
// erroring, same tolerance audioStreamPcmRead() has for a
@@ -108,7 +110,9 @@ errorret_t audioStreamMp3Seek(audiostream_t *stream, const size_t frame) {
discard, discard + (framesNeeded * channels),
keepFrames * channels * sizeof(int16_t)
);
memoryCopy(stream->mp3.pending, discard, keepFrames * channels * sizeof(int16_t));
memoryCopy(
stream->mp3.pending, discard, keepFrames * channels * sizeof(int16_t)
);
stream->mp3.pendingFrames = keepFrames;
stream->mp3.pendingPosition = 0;
stream->mp3.position = frame;
@@ -142,8 +146,10 @@ errorret_t audioStreamMp3Read(
if(decodedFrames == 0) break; // Genuine end of stream.
}
const size_t framesAvailable = stream->mp3.pendingFrames - stream->mp3.pendingPosition;
const size_t framesToCopy = mathMin(frameCount - framesWritten, framesAvailable);
const size_t framesAvailable =
stream->mp3.pendingFrames - stream->mp3.pendingPosition;
const size_t framesToCopy =
mathMin(frameCount - framesWritten, framesAvailable);
memoryCopy(
buffer + (framesWritten * channels),
+14 -5
View File
@@ -8,9 +8,14 @@
#include "audiostreamtype.h"
#include "util/string.h"
const audiostreamassettypeinfo_t AUDIO_STREAM_TYPE_FOR_ASSET_TYPE[ASSET_LOADER_TYPE_COUNT] = {
[ASSET_LOADER_TYPE_WAV] = { .type = AUDIO_STREAM_TYPE_PCM, .extension = ".wav" },
[ASSET_LOADER_TYPE_MP3] = { .type = AUDIO_STREAM_TYPE_MP3, .extension = ".mp3" }
const audiostreamassettypeinfo_t
AUDIO_STREAM_TYPE_FOR_ASSET_TYPE[ASSET_LOADER_TYPE_COUNT] = {
[ASSET_LOADER_TYPE_WAV] = {
.type = AUDIO_STREAM_TYPE_PCM, .extension = ".wav"
},
[ASSET_LOADER_TYPE_MP3] = {
.type = AUDIO_STREAM_TYPE_MP3, .extension = ".mp3"
}
};
assetloadertype_t audioStreamAssetTypeForPath(const char_t *path) {
@@ -24,11 +29,15 @@ assetloadertype_t audioStreamAssetTypeForPath(const char_t *path) {
return ASSET_LOADER_TYPE_NULL;
}
audistreamtype_t audioStreamTypeForAssetType(const assetloadertype_t assetType) {
audistreamtype_t audioStreamTypeForAssetType(
const assetloadertype_t assetType
) {
return AUDIO_STREAM_TYPE_FOR_ASSET_TYPE[assetType].type;
}
assetloadertype_t audioStreamAssetTypeForStreamType(const audistreamtype_t streamType) {
assetloadertype_t audioStreamAssetTypeForStreamType(
const audistreamtype_t streamType
) {
if(streamType == AUDIO_STREAM_TYPE_NULL) return ASSET_LOADER_TYPE_NULL;
for(assetloadertype_t i = 0; i < ASSET_LOADER_TYPE_COUNT; i++) {
+5 -2
View File
@@ -32,7 +32,8 @@ typedef struct {
// use of this for the canonical "is this asset type supported" check. Use
// the functions below rather than indexing this directly, except where
// you already have an assetloadertype_t in hand.
extern const audiostreamassettypeinfo_t AUDIO_STREAM_TYPE_FOR_ASSET_TYPE[ASSET_LOADER_TYPE_COUNT];
extern const audiostreamassettypeinfo_t
AUDIO_STREAM_TYPE_FOR_ASSET_TYPE[ASSET_LOADER_TYPE_COUNT];
/**
* Determines which asset loader type a file path's extension corresponds
@@ -65,4 +66,6 @@ audistreamtype_t audioStreamTypeForAssetType(const assetloadertype_t assetType);
* @return The matching assetloadertype_t, or ASSET_LOADER_TYPE_NULL if
* streamType is AUDIO_STREAM_TYPE_NULL or otherwise unmapped.
*/
assetloadertype_t audioStreamAssetTypeForStreamType(const audistreamtype_t streamType);
assetloadertype_t audioStreamAssetTypeForStreamType(
const audistreamtype_t streamType
);
+12 -6
View File
@@ -73,27 +73,33 @@ void sphereBuffer(
const float_t u1 = (float_t)j / (float_t)sectors;
const float_t u2 = (float_t)(j + 1) / (float_t)sectors;
vertices[vi].pos[0] = center[0] + x11; vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[0] = center[0] + x11;
vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[2] = center[2] + z11;
vertices[vi].uv[0] = u1; vertices[vi].uv[1] = v1; vi++;
vertices[vi].pos[0] = center[0] + x21; vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[0] = center[0] + x21;
vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[2] = center[2] + z21;
vertices[vi].uv[0] = u1; vertices[vi].uv[1] = v2; vi++;
vertices[vi].pos[0] = center[0] + x12; vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[0] = center[0] + x12;
vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[2] = center[2] + z12;
vertices[vi].uv[0] = u2; vertices[vi].uv[1] = v1; vi++;
vertices[vi].pos[0] = center[0] + x12; vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[0] = center[0] + x12;
vertices[vi].pos[1] = center[1] + y1;
vertices[vi].pos[2] = center[2] + z12;
vertices[vi].uv[0] = u2; vertices[vi].uv[1] = v1; vi++;
vertices[vi].pos[0] = center[0] + x21; vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[0] = center[0] + x21;
vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[2] = center[2] + z21;
vertices[vi].uv[0] = u1; vertices[vi].uv[1] = v2; vi++;
vertices[vi].pos[0] = center[0] + x22; vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[0] = center[0] + x22;
vertices[vi].pos[1] = center[1] + y2;
vertices[vi].pos[2] = center[2] + z22;
vertices[vi].uv[0] = u2; vertices[vi].uv[1] = v2; vi++;
}
+2 -1
View File
@@ -76,7 +76,8 @@ errorret_t spriteBatchBuffer(
// Buffer to the mesh vertices.
spriteBatchBufferToMesh(
sprites + (count - remaining), batchCount, v, batchCount * QUAD_VERTEX_COUNT
sprites + (count - remaining), batchCount, v,
batchCount * QUAD_VERTEX_COUNT
);
SPRITEBATCH.spriteCount += batchCount;
remaining -= batchCount;
+20 -10
View File
@@ -82,9 +82,11 @@ const uint8_t FONT_DEFAULT_GLYPHS[FONT_DEFAULT_TILE_COUNT][
// Caps Lock's row widths becomes a column height here, centered
// vertically). Backslash was never drawn anyway, and isn't a key this
// virtual keyboard can type - see FONT_ICON_BACKSPACE.
{ 0x00, 0x00, 0x08, 0x1F, 0x3F, 0x3F, 0x1F, 0x08, 0x00, 0x00 }, // FONT_ICON_BACKSPACE
// FONT_ICON_BACKSPACE
{ 0x00, 0x00, 0x08, 0x1F, 0x3F, 0x3F, 0x1F, 0x08, 0x00, 0x00 },
{ 0x00, 0x18, 0x08, 0x08, 0x08, 0x08, 0x08, 0x18, 0x00, 0x00 }, // ]
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // ^ (not drawn in source font)
// ^ (not drawn in source font)
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3E }, // _
// Custom icon glyph, not a real backtick - an up arrow for Shift, same
// head as Caps Lock's (see FONT_ICON_CAPSLOCK) but with a shaft 2px
@@ -92,7 +94,8 @@ const uint8_t FONT_DEFAULT_GLYPHS[FONT_DEFAULT_TILE_COUNT][
// lighter/broken version of Caps Lock's thicker uninterrupted one.
// Backtick was never drawn anyway, and isn't a key this virtual
// keyboard can type - see FONT_ICON_SHIFT.
{ 0x0C, 0x1E, 0x3F, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x0C, 0x00 }, // FONT_ICON_SHIFT
// FONT_ICON_SHIFT
{ 0x0C, 0x1E, 0x3F, 0x0C, 0x0C, 0x0C, 0x0C, 0x00, 0x0C, 0x00 },
{ 0x00, 0x00, 0x00, 0x1E, 0x22, 0x22, 0x22, 0x1E, 0x00, 0x00 }, // a
{ 0x00, 0x20, 0x20, 0x3C, 0x22, 0x22, 0x22, 0x3C, 0x00, 0x00 }, // b
{ 0x00, 0x00, 0x00, 0x1C, 0x22, 0x20, 0x22, 0x1C, 0x00, 0x00 }, // c
@@ -125,21 +128,25 @@ const uint8_t FONT_DEFAULT_GLYPHS[FONT_DEFAULT_TILE_COUNT][
// hooks left into a leftward-pointing arrowhead, i.e. "<-|" rotated
// into an L. Pipe was never drawn anyway, and isn't a key this
// virtual keyboard can type - see FONT_ICON_NEWLINE.
{ 0x02, 0x02, 0x02, 0x02, 0x0E, 0x1E, 0x08, 0x00, 0x00, 0x00 }, // FONT_ICON_NEWLINE
// FONT_ICON_NEWLINE
{ 0x02, 0x02, 0x02, 0x02, 0x0E, 0x1E, 0x08, 0x00, 0x00, 0x00 },
{ 0x00, 0x10, 0x08, 0x08, 0x04, 0x08, 0x08, 0x10, 0x00, 0x00 }, // }
// Custom icon glyph, not a real tilde - a spacebar symbol for the
// keyboard's space key: an underscore with a tick at each end, like
// "|___|". Tilde was never drawn anyway, and was explicitly dropped
// from this virtual keyboard's own key set - see FONT_ICON_SPACE.
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x3F }, // FONT_ICON_SPACE
// FONT_ICON_SPACE
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0x3F },
// Custom icon glyph, not a real ASCII character - a thick, solid,
// uninterrupted up arrow for Caps Lock (contrast FONT_ICON_SHIFT's
// same head but a thinner, gapped shaft). Assigned to char code 127
// (DEL) since that codepoint is never legitimately typed text and
// (unlike 128+) is still a positive value regardless of whether this
// platform's plain `char` is signed - see FONT_ICON_CAPSLOCK.
{ 0x0C, 0x1E, 0x3F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00 }, // FONT_ICON_CAPSLOCK
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // unused trailing tile
// FONT_ICON_CAPSLOCK
{ 0x0C, 0x1E, 0x3F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00 },
// unused trailing tile
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
errorret_t fontDefaultInit(void) {
@@ -155,7 +162,8 @@ errorret_t fontDefaultInit(void) {
for(uint16_t i = 0; i < FONT_DEFAULT_TILE_COUNT; i++) {
const uint16_t tileX = (i % FONT_DEFAULT_COLUMNS) * FONT_DEFAULT_TILE_WIDTH;
const uint16_t tileY = (i / FONT_DEFAULT_COLUMNS) * FONT_DEFAULT_TILE_HEIGHT;
const uint16_t tileY =
(i / FONT_DEFAULT_COLUMNS) * FONT_DEFAULT_TILE_HEIGHT;
for(uint8_t row = 0; row < FONT_DEFAULT_TILE_HEIGHT; row++) {
const uint8_t bits = FONT_DEFAULT_GLYPHS[i][row];
@@ -172,8 +180,10 @@ errorret_t fontDefaultInit(void) {
FONT_DEFAULT_TILESET.columns = FONT_DEFAULT_COLUMNS;
FONT_DEFAULT_TILESET.rows = FONT_DEFAULT_ROWS;
FONT_DEFAULT_TILESET.tileCount = FONT_DEFAULT_TILE_COUNT;
FONT_DEFAULT_TILESET.uv[0] = (float_t)FONT_DEFAULT_TILE_WIDTH / (float_t)width;
FONT_DEFAULT_TILESET.uv[1] = (float_t)FONT_DEFAULT_TILE_HEIGHT / (float_t)height;
FONT_DEFAULT_TILESET.uv[0] =
(float_t)FONT_DEFAULT_TILE_WIDTH / (float_t)width;
FONT_DEFAULT_TILESET.uv[1] =
(float_t)FONT_DEFAULT_TILE_HEIGHT / (float_t)height;
const texturedata_t data = { .rgbaColors = pixels };
errorret_t textureResult = textureInit(
+3 -1
View File
@@ -214,7 +214,9 @@ void battleMoveTeamFirst(const battlefighterteam_t team) {
sorted[count++] = BATTLE.executionOrder[i];
}
memoryCopy(BATTLE.executionOrder, sorted, sizeof(uint8_t) * BATTLE.executionCount);
memoryCopy(
BATTLE.executionOrder, sorted, sizeof(uint8_t) * BATTLE.executionCount
);
}
battlefighter_t *battleAIChooseTarget(const battlefighter_t *fighter) {
@@ -15,7 +15,9 @@ void cutsceneEntityAddStart(
cutsceneitemdata_t *data
) {
uint8_t entIndex = entityGetAvailable();
assertTrue(entIndex != 0xFF, "No available entity slots for CUTSCENE_ENTITY_ADD");
assertTrue(
entIndex != 0xFF, "No available entity slots for CUTSCENE_ENTITY_ADD"
);
entity_t *entity = &ENTITIES[entIndex];
entityInit(entity, item->entityAdd.entityType);
+7 -3
View File
@@ -123,7 +123,9 @@ bool_t entityWalkCheckRampUp(
abovePos.z += 1;
tile_t tileAbove = mapGetTile(abovePos);
if(tileAbove.shape != TILE_SHAPE_NULL && tileShapeIsWalkable(tileAbove.shape)) {
if(
tileAbove.shape != TILE_SHAPE_NULL && tileShapeIsWalkable(tileAbove.shape)
) {
return true;
}
@@ -145,7 +147,8 @@ bool_t entityWalkCheckFall(
return (
// This handles regular cardinal ramps
(entityDirGetOpposite(direction)+TILE_SHAPE_RAMP_NORTH) == tileBelow.shape ||
(entityDirGetOpposite(direction)+TILE_SHAPE_RAMP_NORTH) ==
tileBelow.shape ||
// This handles diagonal ramps. Inner ramps share the same
// allowed directions as their outer counterparts.
(
@@ -209,7 +212,8 @@ void entityWalk(entity_t *entity, const entitydir_t direction) {
tile_t tileCurrent = mapGetTile(entity->position);
tile_t tileNew = mapGetTile(newPos);
bool_t raise = entityWalkCheckRampUp(tileCurrent, direction, newPos, &tileNew);
bool_t raise =
entityWalkCheckRampUp(tileCurrent, direction, newPos, &tileNew);
bool_t fall = !raise && entityWalkCheckFall(tileNew, newPos, direction);
// Can we walk here?
+2 -1
View File
@@ -21,7 +21,8 @@ typedef struct maparea_s maparea_t;
#define MAP_TRIGGER_STEP (1 << 0)
#define MAP_TRIGGER_ENTER (1 << 1)
#define MAP_TRIGGER_EXIT (1 << 2)
#define MAP_TRIGGER_ALL (MAP_TRIGGER_STEP | MAP_TRIGGER_ENTER | MAP_TRIGGER_EXIT)
#define MAP_TRIGGER_ALL \
(MAP_TRIGGER_STEP | MAP_TRIGGER_ENTER | MAP_TRIGGER_EXIT)
/**
* Callback invoked for a map area.
+4 -2
View File
@@ -155,7 +155,8 @@ bool_t saveDeviceRawIsValid(
return false;
}
uint32_t checksum = cryptCRC32(raw + sizeof(savedevicerawheader_t), compressedSize);
uint32_t checksum =
cryptCRC32(raw + sizeof(savedevicerawheader_t), compressedSize);
if(checksum != endianLittleToHost32(header->checksum)) return false;
if(outGeneration != NULL) {
@@ -395,7 +396,8 @@ errorret_t saveDeviceRawStoreItem(
header.version = endianLittleToHost32(SAVE_DEVICE_RAW_VERSION);
header.uncompressedSize = endianLittleToHost32((uint32_t)logicalSize);
header.compressedSize = endianLittleToHost32((uint32_t)compressedLen);
header.checksum = endianLittleToHost32(cryptCRC32(compressedBuf, compressedLen));
header.checksum =
endianLittleToHost32(cryptCRC32(compressedBuf, compressedLen));
header.generation = endianLittleToHost32(haveOld ? oldGeneration + 1 : 1);
size_t finalSize = sizeof(header) + compressedLen;
+14 -5
View File
@@ -282,7 +282,9 @@
yyjson_mut_val *saveJsonArr = yyjson_mut_arr(doc); \
size_t saveJsonArrIdx = 0; \
while(saveJsonArrIdx < (size_t)(count)) { \
yyjson_mut_arr_add_real(doc, saveJsonArr, (double)(value)[saveJsonArrIdx]); \
yyjson_mut_arr_add_real( \
doc, saveJsonArr, (double)(value)[saveJsonArrIdx] \
); \
saveJsonArrIdx++; \
} \
yyjson_mut_obj_add_val(doc, object, key, saveJsonArr); \
@@ -369,7 +371,9 @@
key, (int)(maxLength) \
); \
} \
stringCopy(saveJsonStringBuffer, yyjson_get_str(saveJsonStrVal), (maxLength)); \
stringCopy( \
saveJsonStringBuffer, yyjson_get_str(saveJsonStrVal), (maxLength) \
); \
} else { \
stringCopy(saveJsonStringBuffer, (def), (maxLength)); \
} \
@@ -402,7 +406,9 @@
yyjson_mut_val *saveJsonTimeObj = yyjson_mut_obj_add_obj(doc, object, key); \
yyjson_mut_obj_add_real(doc, saveJsonTimeObj, "time", (value).time); \
yyjson_mut_obj_add_real(doc, saveJsonTimeObj, "timeZone", (value).timeZone); \
yyjson_mut_obj_add_real(doc, saveJsonTimeObj, "offsetTime", (value).offsetTime); \
yyjson_mut_obj_add_real( \
doc, saveJsonTimeObj, "offsetTime", (value).offsetTime \
); \
}
/**
@@ -417,8 +423,11 @@
if(saveJsonTimeObj == NULL) errorThrow("Save JSON missing '%s' key", key); \
yyjson_val *saveJsonTimeTime = yyjson_obj_get(saveJsonTimeObj, "time"); \
yyjson_val *saveJsonTimeZone = yyjson_obj_get(saveJsonTimeObj, "timeZone"); \
yyjson_val *saveJsonTimeOffset = yyjson_obj_get(saveJsonTimeObj, "offsetTime"); \
if(saveJsonTimeTime == NULL) errorThrow("Save JSON missing '%s.time' key", key); \
yyjson_val *saveJsonTimeOffset = \
yyjson_obj_get(saveJsonTimeObj, "offsetTime"); \
if(saveJsonTimeTime == NULL) { \
errorThrow("Save JSON missing '%s.time' key", key); \
} \
if(saveJsonTimeZone == NULL) { \
errorThrow("Save JSON missing '%s.timeZone' key", key); \
} \
+3 -1
View File
@@ -100,7 +100,9 @@ errorret_t sceneOverworldRender(scenedata_t *sceneData) {
// shadermaterial_t skyboxMaterial = {
// .unlit = { .color = color(0xFF, 0x00, 0x00, 0xFF/2), .texture = NULL }
// };
// errorChain(spriteBatchBuffer(&skyboxSprite, 1, &SHADER_UNLIT, skyboxMaterial));
// errorChain(
// spriteBatchBuffer(&skyboxSprite, 1, &SHADER_UNLIT, skyboxMaterial)
// );
// errorChain(spriteBatchFlush());
errorOk();
+3 -1
View File
@@ -22,7 +22,9 @@ errorret_t uiConsoleInit(void) {
UICONSOLE.sprites[i], CONSOLE_LINE_MAX
);
uiLabelSetX(&UICONSOLE.labels[i], (float_t)SCREEN.scanX);
uiLabelSetY(&UICONSOLE.labels[i], (float_t)SCREEN.scanY + lineH * (float_t)i);
uiLabelSetY(
&UICONSOLE.labels[i], (float_t)SCREEN.scanY + lineH * (float_t)i
);
}
errorOk();
+13 -4
View File
@@ -381,7 +381,10 @@ void uiKeyboardMenuSelected(
}
}
if(UI_KEYBOARD.onKeyPress != NULL && !UI_KEYBOARD.onKeyPress(c, UI_KEYBOARD.user)) {
if(
UI_KEYBOARD.onKeyPress != NULL &&
!UI_KEYBOARD.onKeyPress(c, UI_KEYBOARD.user)
) {
return;
}
uiKeyboardAppendChar(c);
@@ -528,11 +531,15 @@ errorret_t uiKeyboardDraw(void) {
uint8_t rows = (UI_KEYBOARD.menu.itemCount + columns - 1) / columns;
float_t contentWidth = mathMax(
mathMax((float_t)UI_KEYBOARD.titleLabel.width, (float_t)UI_KEYBOARD.textLabel.width),
mathMax(
(float_t)UI_KEYBOARD.titleLabel.width,
(float_t)UI_KEYBOARD.textLabel.width
),
(float_t)columns * UI_KEYBOARD_KEY_WIDTH
);
float_t colStep = contentWidth / (float_t)columns;
float_t keyRowHeight = colStep * (UI_KEYBOARD_KEY_HEIGHT / UI_KEYBOARD_KEY_WIDTH);
float_t keyRowHeight =
colStep * (UI_KEYBOARD_KEY_HEIGHT / UI_KEYBOARD_KEY_WIDTH);
float_t contentHeight = rowHeight + UI_FRAME_PADDING_Y
+ textHeight + UI_FRAME_PADDING_Y
+ ((float_t)rows * keyRowHeight);
@@ -576,7 +583,9 @@ errorret_t uiKeyboardDraw(void) {
&UI_KEYBOARD.cursorLabel,
contentX + (float_t)cursorCol * (float_t)FONT_DEFAULT_TILE_WIDTH
);
uiLabelSetY(&UI_KEYBOARD.cursorLabel, textY + (float_t)cursorLine * rowHeight);
uiLabelSetY(
&UI_KEYBOARD.cursorLabel, textY + (float_t)cursorLine * rowHeight
);
errorChain(uiLabelRender(&UI_KEYBOARD.cursorLabel, COLOR_WHITE));
}
+3 -1
View File
@@ -50,7 +50,9 @@ bool_t uiSaveSlotIsHighlighted(const uisaveslot_t *saveSlot) {
return saveSlot->highlighted;
}
void uiSaveSlotSetHighlighted(uisaveslot_t *saveSlot, const bool_t highlighted) {
void uiSaveSlotSetHighlighted(
uisaveslot_t *saveSlot, const bool_t highlighted
) {
assertNotNull(saveSlot, "Save slot cannot be NULL");
saveSlot->highlighted = highlighted;
}
+5 -2
View File
@@ -157,7 +157,8 @@ void uiSelectSaveSetActionLabel(const uiselectsavetype_t type) {
);
if(errorIsNotOk(result)) errorCatch(result);
UI_SELECT_SAVE.slotItems[UI_SELECT_SAVE_ACTION_INDEX].button.label.dirty = true;
UI_SELECT_SAVE.slotItems[UI_SELECT_SAVE_ACTION_INDEX].button.label.dirty =
true;
}
void uiSelectSaveSwitchType(const uiselectsavetype_t type) {
@@ -346,7 +347,9 @@ void uiSelectSaveOpen(
uiSelectSaveSetActionLabel(type);
itemCount = UI_SELECT_SAVE_ITEM_CAPACITY;
}
uiMenuSetItems(&UI_SELECT_SAVE.slotMenu, UI_SELECT_SAVE.slotItems, itemCount, 1);
uiMenuSetItems(
&UI_SELECT_SAVE.slotMenu, UI_SELECT_SAVE.slotItems, itemCount, 1
);
uiScrollingInit(&UI_SELECT_SAVE.scroll);
uiMenuOpen(&UI_SELECT_SAVE.slotMenu);
+3 -1
View File
@@ -97,7 +97,9 @@ errorret_t uiFatalErrorDraw(void) {
const float_t menuY = contentY +
(float_t)UI_FATAL_ERROR.messageLabel.height + UI_FRAME_PADDING_Y;
errorChain(uiMenuDraw(&UI_FATAL_ERROR.menu, contentX, menuY, contentWidth, rowHeight));
errorChain(uiMenuDraw(
&UI_FATAL_ERROR.menu, contentX, menuY, contentWidth, rowHeight
));
errorChain(spriteBatchFlush());
errorOk();
+3 -1
View File
@@ -34,7 +34,9 @@ bool_t uiCheckboxIsHighlighted(const uicheckbox_t *checkbox) {
return checkbox->highlighted;
}
void uiCheckboxSetHighlighted(uicheckbox_t *checkbox, const bool_t highlighted) {
void uiCheckboxSetHighlighted(
uicheckbox_t *checkbox, const bool_t highlighted
) {
checkbox->highlighted = highlighted;
}
+10 -3
View File
@@ -232,7 +232,10 @@ bool_t uiMenuFocusDirection(
assertNotNull(focusItem->user, "Focus item user cannot be NULL");
uimenu_t *menu = (uimenu_t *)focusItem->user;
if(direction == UI_FOCUS_DIRECTION_LEFT || direction == UI_FOCUS_DIRECTION_RIGHT) {
if(
direction == UI_FOCUS_DIRECTION_LEFT ||
direction == UI_FOCUS_DIRECTION_RIGHT
) {
uint8_t slot = focusItem->y * menu->columns + focusItem->x;
uint8_t index = uiMenuFocusSlotToIndex(menu, slot);
@@ -405,7 +408,9 @@ uint8_t uiMenuFocusableCount(const uimenu_t *menu) {
uint8_t count = 0;
for(uint8_t i = 0; i < menu->itemCount; i++) {
uimenuwidgettype_t t = menu->items[i].type;
if(t != UI_MENU_WIDGET_TYPE_LABEL && t != UI_MENU_WIDGET_TYPE_SPACER) count++;
if(t != UI_MENU_WIDGET_TYPE_LABEL && t != UI_MENU_WIDGET_TYPE_SPACER) {
count++;
}
}
return count;
}
@@ -415,7 +420,9 @@ uint8_t uiMenuFocusSlotToIndex(const uimenu_t *menu, const uint8_t slot) {
uint8_t focusable = 0;
for(uint8_t i = 0; i < menu->itemCount; i++) {
uimenuwidgettype_t t = menu->items[i].type;
if(t == UI_MENU_WIDGET_TYPE_LABEL || t == UI_MENU_WIDGET_TYPE_SPACER) continue;
if(t == UI_MENU_WIDGET_TYPE_LABEL || t == UI_MENU_WIDGET_TYPE_SPACER) {
continue;
}
if(focusable == slot) return i;
focusable++;
}
+2 -1
View File
@@ -215,7 +215,8 @@ uint8_t uiMenuFocusSlotToIndex(const uimenu_t *menu, const uint8_t slot);
void uiMenuItemSetHighlighted(uimenuitem_t *item, const bool_t highlighted);
/**
* Internal focus callback - forwards selection to the menu's selected handler.
* Internal focus callback - forwards selection to the menu's selected
* handler.
*
* @param focusItem The active focus item; user field must point to uimenu_t.
* @returns True.
+2 -1
View File
@@ -166,7 +166,8 @@ void uiModalOpen(
optionCount <= UI_MODAL_OPTIONS_MAX, "Too many options for modal"
);
float_t maxContentWidth = ((float_t)SCREEN.scanWidth * UI_MODAL_MAX_WIDTH_RATIO)
float_t maxContentWidth =
((float_t)SCREEN.scanWidth * UI_MODAL_MAX_WIDTH_RATIO)
- (UI_FRAME_START_X * 2.0f);
UI_MODAL.hasTitle = title != NULL;
+3 -1
View File
@@ -159,7 +159,9 @@ errorret_t uiSliderDraw(
spritebatchsprite_t trackSprite = {
.min = { trackX, trackY, 0.0f },
.max = { trackX + UI_SLIDER_TRACK_WIDTH, trackY + UI_SLIDER_TRACK_HEIGHT, 0.0f },
.max = {
trackX + UI_SLIDER_TRACK_WIDTH, trackY + UI_SLIDER_TRACK_HEIGHT, 0.0f
},
.uvMin = { 0.0f, 0.0f },
.uvMax = { 1.0f, 1.0f }
};
+12 -6
View File
@@ -70,13 +70,16 @@ errorret_t audioStreamDolphinBuffer(audiostream_t *stream) {
// end of the clip if not looping (or if startFrame already landed past
// the loop end, e.g. a seek into an outro). See
// audioStreamComputeEndFrame()'s own comment.
const size_t endFrame = audioStreamComputeEndFrame(stream, startFrame, totalFrames);
const size_t endFrame =
audioStreamComputeEndFrame(stream, startFrame, totalFrames);
float_t leftFactor, rightFactor;
audioStreamGetPanFactors(stream, &leftFactor, &rightFactor);
const float_t baseVolume = stream->volume;
stream->platform.volumeLeft = (s32) mathClamp(baseVolume * leftFactor * MAX_VOLUME, 0, MAX_VOLUME);
stream->platform.volumeRight = (s32) mathClamp(baseVolume * rightFactor * MAX_VOLUME, 0, MAX_VOLUME);
stream->platform.volumeLeft =
(s32) mathClamp(baseVolume * leftFactor * MAX_VOLUME, 0, MAX_VOLUME);
stream->platform.volumeRight =
(s32) mathClamp(baseVolume * rightFactor * MAX_VOLUME, 0, MAX_VOLUME);
// A fresh pass discards whatever windows were previously queued (both
// ASND buffer slots) rather than letting it play out - a natural loop
@@ -140,13 +143,15 @@ errorret_t audioStreamDolphinFeed(audiostream_t *stream) {
// silently skipping every ASND_AddVoice() call forever after the first
// window - confirmed the hard way (only ever heard a clip's first
// buffered window, nothing ever played after it).
const bool_t ready = ASND_TestVoiceBufferReady(stream->platform.voiceId) == SND_OK;
const bool_t ready =
ASND_TestVoiceBufferReady(stream->platform.voiceId) == SND_OK;
if(stream->platform.primed && !ready) {
errorOk();
}
const size_t frameSize = stream->channels * sizeof(int16_t);
const size_t framesRemaining = stream->platform.endFrame - stream->platform.position;
const size_t framesRemaining =
stream->platform.endFrame - stream->platform.position;
const size_t framesToRead = mathMin(
(size_t) AUDIO_DOLPHIN_WINDOW_FRAMES, framesRemaining
);
@@ -179,7 +184,8 @@ errorret_t audioStreamDolphinFeed(audiostream_t *stream) {
}
if(!stream->platform.primed) {
const s32 format = stream->channels == 1 ? VOICE_MONO_16BIT : VOICE_STEREO_16BIT;
const s32 format =
stream->channels == 1 ? VOICE_MONO_16BIT : VOICE_STEREO_16BIT;
const s32 pitch = (s32) stream->sampleRate;
const s32 result = ASND_SetVoice(
stream->platform.voiceId, format, pitch, 0,
+3 -1
View File
@@ -221,7 +221,9 @@ errorret_t saveDeviceDolphinCardDataWrite(
int32_t writeResult = CARD_Write(&file, paddedBuffer, paddedSize, 0);
CARD_Close(&file);
memoryFree(paddedBuffer);
if(writeResult < 0) errorThrow("Failed to write save data: %s", targetFilename);
if(writeResult < 0) {
errorThrow("Failed to write save data: %s", targetFilename);
}
errorOk();
}
+4 -2
View File
@@ -27,7 +27,8 @@ systemdialogtype_t systemGetActiveDialogTypeDolphin(void);
* ratio of the system. I do believe that Gamecube will only ever return 4:3.
*
* Refer to;
* https://github.com/devkitPro/libogc/blob/20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
* https://github.com/devkitPro/libogc/blob/
* 20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
*
* @return Aspect ratio of the system.
*/
@@ -38,7 +39,8 @@ int32_t systemGetAspectRatioDolphin(void);
* locale management, to try to match the system language if possible.
*
* Refer to;
* https://github.com/devkitPro/libogc/blob/20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
* https://github.com/devkitPro/libogc/blob/
* 20d90e944b83c8991538e88b00b1e5f309428e85/gc/ogc/conf.h#L190
*
* On gamecube, refer to;
* https://libogc.devkitpro.org/system_8h.html
+2 -1
View File
@@ -25,7 +25,8 @@ errorret_t meshInitGL(
mesh->vertices = vertices;
#ifdef DUSK_OPENGL_LEGACY
// Nothing needed; client state is enabled once globally in displayOpenGLInit.
// Nothing needed; client state is enabled once globally in
// displayOpenGLInit.
#else
// Generate Vertex Buffer Object
glGenBuffers(1, &mesh->vboId);
+2 -1
View File
@@ -75,7 +75,8 @@ errorret_t audioStreamLinuxBuffer(audiostream_t *stream) {
// end of the clip if not looping (or if startFrame already landed past
// the loop end, e.g. a seek into an outro). See
// audioStreamComputeEndFrame()'s own comment.
const size_t endFrame = audioStreamComputeEndFrame(stream, startFrame, totalFrames);
const size_t endFrame =
audioStreamComputeEndFrame(stream, startFrame, totalFrames);
// Only an explicit seek discards whatever's still queued and jumps -
// a natural loop restart deliberately leaves the previous pass's tail
+2 -1
View File
@@ -111,7 +111,8 @@ errorret_t audioStreamMp3DecoderRefill(audiostream_t *stream);
* (minimad.c et al.), rounding to nearest and clamping to +/-1.0 rather
* than wrapping on overflow.
*
* @param sample The fixed-point sample to convert (mad_fixed_t, Q1.MAD_F_FRACBITS).
* @param sample The fixed-point sample to convert (mad_fixed_t,
* Q1.MAD_F_FRACBITS).
* @return The converted 16-bit signed sample.
*/
int16_t audioStreamMp3DecoderScale(mad_fixed_t sample);
+10 -4
View File
@@ -20,7 +20,8 @@ errorret_t audioStreamMp3RingInit(audiostream_t *stream) {
const size_t frameSize = stream->channels * sizeof(int16_t);
ring->data = (int16_t *) memoryAllocate(AUDIO_MP3_RING_FRAMES * frameSize);
ring->scratch = (int16_t *) memoryAllocate(AUDIO_MP3_RING_STEP_FRAMES * frameSize);
ring->scratch =
(int16_t *) memoryAllocate(AUDIO_MP3_RING_STEP_FRAMES * frameSize);
ring->readPos = 0;
ring->writePos = 0;
ring->filled = 0;
@@ -127,8 +128,12 @@ size_t audioStreamMp3RingDrain(
}
const size_t toCopy = mathMin(available, maxFrames);
const size_t firstPart = mathMin(toCopy, AUDIO_MP3_RING_FRAMES - ring->readPos);
memoryCopy(out, ring->data + ring->readPos * channels, firstPart * channels * sizeof(int16_t));
const size_t firstPart =
mathMin(toCopy, AUDIO_MP3_RING_FRAMES - ring->readPos);
memoryCopy(
out, ring->data + ring->readPos * channels,
firstPart * channels * sizeof(int16_t)
);
if(toCopy > firstPart) {
memoryCopy(
out + firstPart * channels, ring->data,
@@ -286,7 +291,8 @@ errorret_t audioStreamReadForPlayback(
if(stream->type == AUDIO_STREAM_TYPE_MP3) {
bool_t decodeDone = false;
*outFramesRead = audioStreamMp3RingDrain(stream, out, maxFrames, &decodeDone);
*outFramesRead =
audioStreamMp3RingDrain(stream, out, maxFrames, &decodeDone);
if(*outFramesRead == 0 && !decodeDone) {
*outNotReadyYet = true;
errorOk();
+2 -1
View File
@@ -147,7 +147,8 @@ errorret_t audioStreamMp3RingStop(audiostream_t *stream);
* it reaches endFrame, filling back up whenever audioStreamMp3RingDrain()
* makes room.
*
* @param stream The audio stream to start decoding. Must be AUDIO_STREAM_TYPE_MP3.
* @param stream The audio stream to start decoding. Must be
* AUDIO_STREAM_TYPE_MP3.
* @param startFrame This pass's starting frame offset.
* @param endFrame This pass's stop frame offset.
* @return Error state if any.
+5 -2
View File
@@ -194,7 +194,9 @@ errorret_t audioStreamMp3DecoderDecodeFrame(
const size_t frameSize = stream->channels * sizeof(int16_t);
for(;;) {
if(sceMp3CheckStreamDataNeeded(decoder->handle) > 0 && !decoder->endOfFile) {
if(
sceMp3CheckStreamDataNeeded(decoder->handle) > 0 && !decoder->endOfFile
) {
errorChain(audioStreamMp3DecoderFillStream(stream));
}
@@ -210,7 +212,8 @@ errorret_t audioStreamMp3DecoderDecodeFrame(
// whatever followed stream->mp3.pending in memory, and only showed
// up as very intermittent audio clicking.
assertTrue(
(size_t) bytesDecoded <= AUDIO_MP3_MAX_SAMPLES_PER_FRAME * sizeof(int16_t),
(size_t) bytesDecoded <=
AUDIO_MP3_MAX_SAMPLES_PER_FRAME * sizeof(int16_t),
"sceMp3Decode returned more PCM than the destination buffer can hold."
);
const size_t frames = (size_t) bytesDecoded / frameSize;
+3 -2
View File
@@ -48,8 +48,9 @@ typedef struct {
/**
* Feeds sceMp3 more compressed bytes if (and only as much as) it currently
* wants: asks it where in the stream and how much (sceMp3GetInfoToAddStreamData()),
* reads exactly that from stream->mp3.file, and hands it back
* wants: asks it where in the stream and how much
* (sceMp3GetInfoToAddStreamData()), reads exactly that from stream->mp3.file,
* and hands it back
* (sceMp3NotifyAddStreamData()). A no-op if sceMp3 doesn't currently want
* more. See this file's own top-of-file comment on why the source
* position sceMp3 requests is asserted rather than actually used to seek.
+24 -11
View File
@@ -127,7 +127,8 @@ errorret_t audioStreamPSPBuffer(audiostream_t *stream) {
stream->platform.loopEndFrame
);
const size_t startFrame = mathMin(stream->startFrame, stream->platform.totalFrames);
const size_t startFrame =
mathMin(stream->startFrame, stream->platform.totalFrames);
stream->startFrame = 0;
stream->seeking = false;
@@ -181,10 +182,12 @@ void audioStreamPSPTopUp(audiostream_t *stream) {
const size_t room = mathMin(
AUDIO_PSP_RING_FRAMES - filled, (size_t) AUDIO_PSP_TOPUP_STEP_FRAMES
);
const size_t currentEndFrame = stream->platform.readPosition < stream->platform.loopEndFrame
const size_t currentEndFrame =
stream->platform.readPosition < stream->platform.loopEndFrame
? stream->platform.loopEndFrame
: stream->platform.totalFrames;
const size_t framesRemainingInSegment = currentEndFrame - stream->platform.readPosition;
const size_t framesRemainingInSegment =
currentEndFrame - stream->platform.readPosition;
const size_t framesToRead = mathMin(room, framesRemainingInSegment);
if(framesToRead > 0) {
@@ -201,7 +204,8 @@ void audioStreamPSPTopUp(audiostream_t *stream) {
if(framesRead > 0) {
threadMutexLock(&stream->platform.ringLock);
for(size_t i = 0; i < framesRead; i++) {
const size_t writeIndex = (stream->platform.ringWritePos + i) % AUDIO_PSP_RING_FRAMES;
const size_t writeIndex =
(stream->platform.ringWritePos + i) % AUDIO_PSP_RING_FRAMES;
memoryCopy(
stream->platform.ring + (writeIndex * channels),
scratch + (i * channels),
@@ -239,7 +243,8 @@ void audioStreamPSPTopUp(audiostream_t *stream) {
// still the right thing to compare against loopLimit.
const bool_t loopLimitReached = stream->loopLimit > 0 &&
stream->loopRestartCount >= stream->loopLimit;
const bool_t reachesSegmentEnd = stream->platform.readPosition >= currentEndFrame;
const bool_t reachesSegmentEnd =
stream->platform.readPosition >= currentEndFrame;
const bool_t willLoop = reachesSegmentEnd &&
(stream->state & AUDIO_STREAM_STATE_LOOPING) && !loopLimitReached;
@@ -257,7 +262,8 @@ void audioStreamPSPTopUp(audiostream_t *stream) {
const size_t index = (
stream->platform.loopMarkerHead + stream->platform.loopMarkerCount
) % AUDIO_PSP_LOOP_MARKER_MAX;
stream->platform.loopMarkerFrames[index] = stream->platform.framesEnqueued;
stream->platform.loopMarkerFrames[index] =
stream->platform.framesEnqueued;
stream->platform.loopMarkerCount++;
}
threadMutexUnlock(&stream->platform.ringLock);
@@ -282,7 +288,9 @@ bool_t audioStreamPSPIsFinished(audiostream_t *stream) {
void audioStreamPSPThreadFeed(thread_t *thread) {
assertNotNull(thread, "Thread cannot be NULL.");
sceKernelChangeThreadPriority(sceKernelGetThreadId(), AUDIO_PSP_THREAD_PRIORITY);
sceKernelChangeThreadPriority(
sceKernelGetThreadId(), AUDIO_PSP_THREAD_PRIORITY
);
audiostream_t *stream = (audiostream_t *) thread->data;
const size_t channels = stream->channels;
@@ -321,7 +329,9 @@ void audioStreamPSPThreadFeed(thread_t *thread) {
threadMutexUnlock(&stream->platform.ringLock);
if(available >= AUDIO_PSP_CHUNK_FRAMES) break;
if(stream->platform.readReachedEnd || stream->platform.readFailed) break;
if(
stream->platform.readReachedEnd || stream->platform.readFailed
) break;
if(threadShouldStop(thread)) {
stopRequested = true;
break;
@@ -358,7 +368,8 @@ void audioStreamPSPThreadFeed(thread_t *thread) {
threadMutexLock(&stream->platform.ringLock);
for(size_t i = 0; i < framesThisChunk; i++) {
const size_t readIndex = (stream->platform.ringReadPos + i) % AUDIO_PSP_RING_FRAMES;
const size_t readIndex =
(stream->platform.ringReadPos + i) % AUDIO_PSP_RING_FRAMES;
memoryCopy(
chunk + (i * channels),
stream->platform.ring + (readIndex * channels),
@@ -366,7 +377,8 @@ void audioStreamPSPThreadFeed(thread_t *thread) {
);
}
stream->platform.ringReadPos =
(stream->platform.ringReadPos + framesThisChunk) % AUDIO_PSP_RING_FRAMES;
(stream->platform.ringReadPos + framesThisChunk) %
AUDIO_PSP_RING_FRAMES;
stream->platform.ringFilled -= framesThisChunk;
threadMutexUnlock(&stream->platform.ringLock);
@@ -389,7 +401,8 @@ void audioStreamPSPThreadFeed(thread_t *thread) {
: AUDIO_PSP_FADE_FRAMES;
for(size_t i = 0; i < fadeFrames; i++) {
const size_t frame = framesThisChunk - fadeFrames + i;
const float_t factor = 1.0f - ((float_t) (i + 1) / (float_t) fadeFrames);
const float_t factor =
1.0f - ((float_t) (i + 1) / (float_t) fadeFrames);
for(size_t c = 0; c < channels; c++) {
int16_t *sample = &chunk[frame * channels + c];
*sample = (int16_t) ((float_t) *sample * factor);
+2 -1
View File
@@ -172,7 +172,8 @@ void networkPSPRequestConnection(
// This is all related to getting the PSP online, refer to;
// https://github.com/joel16/CMFileManager-PSP/blob/00dab16c64cd48bf6452fc274a3b898d77c39a8d/app/source/net.cpp#L97
// https://github.com/joel16/CMFileManager-PSP/blob/
// 00dab16c64cd48bf6452fc274a3b898d77c39a8d/app/source/net.cpp#L97
// since I follow this implementation closely.
memoryZero(&NETWORK.platform.dialogData, sizeof(NETWORK.platform.dialogData));
memoryZero(
+2 -1
View File
@@ -56,7 +56,8 @@ int_t systemPSPGetLanguage() {
int_t systemPSPGetCrossButtonSetting() {
int_t ret;
// See: https://pspdev.github.io/pspsdk/psputility__sysparam_8h.html#ab588fd5a14adc025f065e09325ffe729
// See: https://pspdev.github.io/pspsdk/psputility__sysparam_8h.html
// #ab588fd5a14adc025f065e09325ffe729
sceUtilityGetSystemParamInt(PSP_SYSTEMPARAM_ID_INT_UNKNOWN, &ret);
return (
ret == 1 ? PSP_UTILITY_ACCEPT_CROSS : PSP_UTILITY_ACCEPT_CIRCLE