From de0646e43026042aa868de14dd24e06b2ed41401 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Fri, 20 Sep 2024 14:00:38 +0900 Subject: [PATCH 1/6] Implement ChipmunkSpriteEngine.SP_{Suspend,Resume,IsSuspend} Their exact meaning is unknown; currently it is just a read/write boolean flag. --- include/sprite.h | 2 ++ src/hll/ChipmunkSpriteEngine.c | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/include/sprite.h b/include/sprite.h index 20cfa39..4cdc652 100644 --- a/include/sprite.h +++ b/include/sprite.h @@ -60,6 +60,8 @@ struct sact_sprite { int no; // The CG number attached to the sprite. int cg_no; + // The sprite is suspended. The exact meaning of this is unknown. + bool suspended; // (optional) Draw plugin bound to this sprite. struct draw_plugin *plugin; }; diff --git a/src/hll/ChipmunkSpriteEngine.c b/src/hll/ChipmunkSpriteEngine.c index 9906eb1..1776e8c 100644 --- a/src/hll/ChipmunkSpriteEngine.c +++ b/src/hll/ChipmunkSpriteEngine.c @@ -259,9 +259,28 @@ static bool ChipmunkSpriteEngine_SP_GetFontWidth(struct string *text, int *width //static int CG_GetFormat_by_index(int cg_no); //static int CG_GetFormat(struct string *cg_name); -HLL_WARN_UNIMPLEMENTED(false, bool, ChipmunkSpriteEngine, SP_Suspend, int sp_no); -//static bool ChipmunkSpriteEngine_SP_Resume(int sp_no); -//static bool ChipmunkSpriteEngine_SP_IsSuspend(int sp_no); +static bool ChipmunkSpriteEngine_SP_Suspend(int sp_no) +{ + struct sact_sprite *sp = sact_try_get_sprite(sp_no); + if (!sp) return false; + sp->suspended = true; + return true; +} + +static bool ChipmunkSpriteEngine_SP_Resume(int sp_no) +{ + struct sact_sprite *sp = sact_try_get_sprite(sp_no); + if (!sp) return false; + sp->suspended = false; + return true; +} + +static bool ChipmunkSpriteEngine_SP_IsSuspend(int sp_no) +{ + struct sact_sprite *sp = sact_try_get_sprite(sp_no); + return sp && sp->suspended; +} + //static bool ChipmunkSpriteEngine_Debug_GetVideoMemoryInfo(int *max_size, int *use_size, int *use_max_size); //static void ChipmunkSpriteEngine_CombineTexture(void); //static void ChipmunkSpriteEngine_ReleaseCombinedTexture(void); @@ -407,8 +426,8 @@ HLL_LIBRARY(ChipmunkSpriteEngine, HLL_TODO_EXPORT(Debug_GetFillRate, StoatSpriteEngine_Debug_GetFillRate), HLL_TODO_EXPORT(MUSIC_ReloadParam, StoatSpriteEngine_MUSIC_ReloadParam), HLL_EXPORT(SP_Suspend, ChipmunkSpriteEngine_SP_Suspend), - HLL_TODO_EXPORT(SP_Resume, ChipmunkSpriteEngine_SP_Resume), - HLL_TODO_EXPORT(SP_IsSuspend, ChipmunkSpriteEngine_SP_IsSuspend), + HLL_EXPORT(SP_Resume, ChipmunkSpriteEngine_SP_Resume), + HLL_EXPORT(SP_IsSuspend, ChipmunkSpriteEngine_SP_IsSuspend), HLL_TODO_EXPORT(Debug_GetVideoMemoryInfo, ChipmunkSpriteEngine_Debug_GetVideoMemoryInfo), HLL_TODO_EXPORT(CombineTexture, ChipmunkSpriteEngine_CombineTexture), HLL_TODO_EXPORT(ReleaseCombinedTexture, ChipmunkSpriteEngine_ReleaseCombinedTexture)); From d6abcc2f928a478d3fb8e7ee1555d301c57c2771 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 22 Oct 2024 10:55:20 +0900 Subject: [PATCH 2/6] Plumb GoatGUIEngine.AddWholeMotionVibrationSize --- src/hll/GoatGUIEngine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hll/GoatGUIEngine.c b/src/hll/GoatGUIEngine.c index 9a3a169..c09f3b2 100644 --- a/src/hll/GoatGUIEngine.c +++ b/src/hll/GoatGUIEngine.c @@ -159,7 +159,7 @@ HLL_LIBRARY(GoatGUIEngine, HLL_EXPORT(AddMotionRotateY, GoatGUIEngine_AddMotionRotateY), HLL_EXPORT(AddMotionRotateZ, GoatGUIEngine_AddMotionRotateZ), HLL_EXPORT(AddMotionVibrationSize, PE_AddMotionVibrationSize), - HLL_TODO_EXPORT(AddWholeMotionVibrationSize, PE_AddWholeMotionVibrationSize), + HLL_EXPORT(AddWholeMotionVibrationSize, PE_AddWholeMotionVibrationSize), HLL_EXPORT(AddMotionSound, PE_AddMotionSound), HLL_EXPORT(BeginMotion, PE_BeginMotion), HLL_EXPORT(EndMotion, PE_EndMotion), From e6d069b757657f762d9a37a304047307bce84674 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 15 Feb 2025 13:13:31 +0900 Subject: [PATCH 3/6] SystemService.GetGameFolderPath should return SJIS string --- src/hll/SystemService.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hll/SystemService.c b/src/hll/SystemService.c index 2ae5563..fe6730a 100644 --- a/src/hll/SystemService.c +++ b/src/hll/SystemService.c @@ -19,6 +19,7 @@ #include "system4/ain.h" #include "system4/string.h" +#include "system4/utfsjis.h" #include "cJSON.h" #include "input.h" @@ -257,7 +258,9 @@ static bool SystemService_GetMouseCursorConfig(int type, int *value) void SystemService_GetGameFolderPath(struct string **folder_path) { - *folder_path = make_string(config.game_dir, strlen(config.game_dir)); + char *sjis = utf2sjis(config.game_dir, 0); + *folder_path = make_string(sjis, strlen(sjis)); + free(sjis); } static void SystemService_GetTime(int *hour, int *min, int *sec) From 2ede7e6bb122ea30516e00d7479eda3c3c5efa1f Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sat, 17 May 2025 09:00:55 +0900 Subject: [PATCH 4/6] StoatSpriteEngine: Clear cached font_size struct in SP_SetTextSpriteType This fixes a bug where the wrong font was used on the Rance Quest status screen. Commit 6c2a55c reset `font_size` on size changes, but the same is needed for face changes. --- src/hll/StoatSpriteEngine.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hll/StoatSpriteEngine.c b/src/hll/StoatSpriteEngine.c index 6fb8f85..c30693d 100644 --- a/src/hll/StoatSpriteEngine.c +++ b/src/hll/StoatSpriteEngine.c @@ -127,6 +127,8 @@ bool StoatSpriteEngine_SP_SetTextSprite(int sp_no, struct string *text) void StoatSpriteEngine_SP_SetTextSpriteType(int type) { + if (text_sprite_ts.face != type) + text_sprite_ts.font_size = NULL; text_sprite_ts.face = type; } From 5d271deec00e5ceeac8e8e98cd7a6ff98fc7c1cf Mon Sep 17 00:00:00 2001 From: kichikuou Date: Sun, 18 May 2025 11:34:08 +0900 Subject: [PATCH 5/6] ChipmunkSpriteEngine: Remove duplicated HLL_EXPORT entries --- src/hll/ChipmunkSpriteEngine.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/hll/ChipmunkSpriteEngine.c b/src/hll/ChipmunkSpriteEngine.c index 1776e8c..c04e979 100644 --- a/src/hll/ChipmunkSpriteEngine.c +++ b/src/hll/ChipmunkSpriteEngine.c @@ -341,13 +341,6 @@ HLL_LIBRARY(ChipmunkSpriteEngine, HLL_EXPORT(SP_SetTextSpriteBoldWeight, StoatSpriteEngine_SP_SetTextSpriteBoldWeight), HLL_EXPORT(SP_SetTextSpriteEdgeWeight, StoatSpriteEngine_SP_SetTextSpriteEdgeWeight), HLL_EXPORT(SP_SetTextSpriteEdgeColor, StoatSpriteEngine_SP_SetTextSpriteEdgeColor), - HLL_EXPORT(SP_SetTextSprite, StoatSpriteEngine_SP_SetTextSprite), - HLL_EXPORT(SP_SetTextSpriteType, StoatSpriteEngine_SP_SetTextSpriteType), - HLL_EXPORT(SP_SetTextSpriteSize, StoatSpriteEngine_SP_SetTextSpriteSize), - HLL_EXPORT(SP_SetTextSpriteColor, StoatSpriteEngine_SP_SetTextSpriteColor), - HLL_EXPORT(SP_SetTextSpriteBoldWeight, StoatSpriteEngine_SP_SetTextSpriteBoldWeight), - HLL_EXPORT(SP_SetTextSpriteEdgeWeight, StoatSpriteEngine_SP_SetTextSpriteEdgeWeight), - HLL_EXPORT(SP_SetTextSpriteEdgeColor, StoatSpriteEngine_SP_SetTextSpriteEdgeColor), HLL_TODO_EXPORT(SP_GetFontDescent, ChipmunkSpriteEngine_SP_GetFontDescent), HLL_EXPORT(SP_GetFontWidth, ChipmunkSpriteEngine_SP_GetFontWidth), HLL_EXPORT(SP_SetDashTextSprite, StoatSpriteEngine_SP_SetDashTextSprite), From 724bbcdfdd5166ae07099bacc82d66973583bc37 Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 20 May 2025 15:05:51 +0900 Subject: [PATCH 6/6] 3d: Disable light mapping for meshes without light_uv --- src/3d/3d_internal.h | 1 + src/3d/parser.c | 1 + src/3d/renderer.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/3d/3d_internal.h b/src/3d/3d_internal.h index a7c1677..4175210 100644 --- a/src/3d/3d_internal.h +++ b/src/3d/3d_internal.h @@ -438,6 +438,7 @@ enum mesh_flags { MESH_NO_EDGE = 1 << 6, MESH_NO_HEIGHT_DETECTION = 1 << 7, MESH_ALPHA = 1 << 8, + MESH_HAS_LIGHT_UV = 1 << 9, }; struct pol_mesh { diff --git a/src/3d/parser.c b/src/3d/parser.c index cec10a4..207c9f7 100644 --- a/src/3d/parser.c +++ b/src/3d/parser.c @@ -218,6 +218,7 @@ static struct pol_mesh *parse_mesh(struct buffer *r, const struct pol *pol) mesh->nr_light_uvs = buffer_read_int32(r); if (mesh->nr_light_uvs > 0) { + mesh->flags |= MESH_HAS_LIGHT_UV; mesh->light_uvs = xcalloc(mesh->nr_light_uvs, sizeof(vec2)); for (uint32_t i = 0; i < mesh->nr_light_uvs; i++) { mesh->light_uvs[i][0] = buffer_read_float(r); diff --git a/src/3d/renderer.c b/src/3d/renderer.c index 750d9ad..78b053c 100644 --- a/src/3d/renderer.c +++ b/src/3d/renderer.c @@ -401,7 +401,7 @@ static void render_model(struct RE_instance *inst, struct RE_renderer *r, enum d glUniform1i(r->diffuse_type, DIFFUSE_ENV_MAP); } else if (mesh->flags & MESH_NOLIGHTING) { glUniform1i(r->diffuse_type, DIFFUSE_EMISSIVE); - } else if (material->light_map && inst->plugin->light_map_mode) { + } else if (material->light_map && mesh->flags & MESH_HAS_LIGHT_UV && inst->plugin->light_map_mode) { glUniform1i(r->diffuse_type, DIFFUSE_LIGHT_MAP); glActiveTexture(GL_TEXTURE0 + LIGHT_TEXTURE_UNIT); glBindTexture(GL_TEXTURE_2D, material->light_map);