From 334de771394656b24ad051a385abc8b8f1f1f762 Mon Sep 17 00:00:00 2001 From: MysterD Date: Sat, 19 Feb 2022 22:03:25 -0800 Subject: [PATCH 1/2] Fix graphical issues that stem from text drawing --- Makefile | 3 +-- src/pc/djui/djui_font.c | 12 +++--------- src/pc/djui/djui_inputbox.c | 4 +++- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cc9cdc96..5c83f6ae 100644 --- a/Makefile +++ b/Makefile @@ -92,8 +92,7 @@ TOOLS_DIR := tools ifeq ($(WINDOWS_AUTO_BUILDER),1) export SHELL=sh.exe - RM ?= rm.exe - EXTRA_INCLUDES := -I ../include/1 -I ../include/2 -I ../include/3 -I ../include/4 -fno-use-linker-plugin + EXTRA_INCLUDES := -I ../include/1 -I ../include/2 -I ../include/3 -I ../include/4 EXTRA_CFLAGS := -Wno-expansion-to-defined else EXTRA_INCLUDES := diff --git a/src/pc/djui/djui_font.c b/src/pc/djui/djui_font.c index 67c1e42b..6e8a36de 100644 --- a/src/pc/djui/djui_font.c +++ b/src/pc/djui/djui_font.c @@ -12,18 +12,13 @@ static Vtx djui_font_normal_vertices[] = { {{{ 0, 0, 0}, 0, { 512, 256}, { 0xff, 0xff, 0xff, 0xff }}}, }; -static const Gfx djui_font_normal_text_begin[] = { +const Gfx dl_font_normal_display_list[] = { gsDPPipeSync(), gsSPClearGeometryMode(G_LIGHTING), gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA), - //gsDPSetEnvColor(255, 255, 255, 255), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsDPSetTextureFilter(G_TF_POINT), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsSPEndDisplayList(), -}; - -static const Gfx djui_font_normal_text_settings[] = { gsDPSetTile(G_IM_FMT_IA, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, G_TX_WRAP | G_TX_NOMIRROR, 3, G_TX_NOLOD, G_TX_WRAP | G_TX_NOMIRROR, 4, G_TX_NOLOD), gsDPLoadSync(), gsDPLoadBlock(G_TX_LOADTILE, 0, 0, ((16 * 8 + G_IM_SIZ_4b_INCR) >> G_IM_SIZ_4b_SHIFT) - 1, CALC_DXT(16, G_IM_SIZ_4b_BYTES)), @@ -43,9 +38,8 @@ static void djui_font_normal_render_char(char c) { void* fontChar = (void*)font_normal_chars[c - '!']; if (fontChar == NULL) { fontChar = (void*)font_normal_chars[94]; } - gDPPipeSync(gDisplayListHead++); gDPSetTextureImage(gDisplayListHead++, G_IM_FMT_IA, G_IM_SIZ_16b, 1, (void*)fontChar); - gSPDisplayList(gDisplayListHead++, djui_font_normal_text_settings); + gSPDisplayList(gDisplayListHead++, dl_font_normal_display_list); } static f32 djui_font_normal_char_width(char c) { @@ -60,7 +54,7 @@ static const struct DjuiFont sDjuiFontNormal = { .lineHeight = 0.8125f, .defaultFontScale = 32.0f, .rotatedUV = true, - .textBeginDisplayList = djui_font_normal_text_begin, + .textBeginDisplayList = NULL, .render_char = djui_font_normal_render_char, .char_width = djui_font_normal_char_width, }; diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index a234365a..27ebf85c 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -479,7 +479,9 @@ static bool djui_inputbox_render(struct DjuiBase* base) { djui_inputbox_render_selection(inputbox); // begin font - gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList); + if (font->textBeginDisplayList != NULL) { + gSPDisplayList(gDisplayListHead++, font->textBeginDisplayList); + } // set color gDPSetEnvColor(gDisplayListHead++, inputbox->textColor.r, inputbox->textColor.g, inputbox->textColor.b, inputbox->textColor.a); From 4568da45f3d32fbad6c0488961333fe4ee8ba483 Mon Sep 17 00:00:00 2001 From: MysterD Date: Fri, 18 Feb 2022 21:11:16 -0800 Subject: [PATCH 2/2] Fixed crash in geo_obj_init_animation* --- src/engine/graph_node.c | 8 ++++++++ src/game/obj_behaviors.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/engine/graph_node.c b/src/engine/graph_node.c index 846be0cd..44379e0f 100644 --- a/src/engine/graph_node.c +++ b/src/engine/graph_node.c @@ -756,6 +756,10 @@ void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo * Initialize the animation of an object node */ void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr) { + if (graphNode == NULL) { return; } + if (animPtrAddr == NULL) { return; } + if (*animPtrAddr == NULL) { return; } + struct Animation **animSegmented = segmented_to_virtual(animPtrAddr); struct Animation *anim = segmented_to_virtual(*animSegmented); @@ -771,6 +775,10 @@ void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation * Initialize the animation of an object node */ void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel) { + if (graphNode == NULL) { return; } + if (animPtrAddr == NULL) { return; } + if (*animPtrAddr == NULL) { return; } + struct Animation **animSegmented = segmented_to_virtual(animPtrAddr); struct Animation *anim = segmented_to_virtual(*animSegmented); diff --git a/src/game/obj_behaviors.c b/src/game/obj_behaviors.c index 98b07007..e3857742 100644 --- a/src/game/obj_behaviors.c +++ b/src/game/obj_behaviors.c @@ -555,6 +555,10 @@ struct MarioState* nearest_mario_state_to_object(struct Object *obj) { checkActive = FALSE; } while (nearest == NULL); + if (nearest == NULL) { + nearest = &gMarioStates[0]; + } + return nearest; }