From 38c54756657dd3c4b90852fc3d83ae218e0c40c6 Mon Sep 17 00:00:00 2001 From: Arceveti <73617174+Arceveti@users.noreply.github.com> Date: Sat, 11 Sep 2021 20:46:38 -0700 Subject: [PATCH 1/4] Use -Ofast since it doesn't seem to break anything --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 84330d1b..f4254683 100644 --- a/Makefile +++ b/Makefile @@ -157,12 +157,12 @@ LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i)) ifeq ($(COMPILER),gcc) NON_MATCHING := 1 MIPSISET := -mips3 - OPT_FLAGS := -O2 + OPT_FLAGS := -Ofast else ifeq ($(COMPILER),clang) NON_MATCHING := 1 # clang doesn't support ABI 'o32' for 'mips3' MIPSISET := -mips2 - OPT_FLAGS := -O2 + OPT_FLAGS := -Ofast endif @@ -398,8 +398,8 @@ export LD_LIBRARY_PATH=./tools AS := $(CROSS)as ifeq ($(COMPILER),gcc) CC := $(CROSS)gcc - $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -O2 -mlong-calls - $(BUILD_DIR)/levels/%.o: OPT_FLAGS := -O2 -mlong-calls + $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -Ofast -mlong-calls + $(BUILD_DIR)/levels/%.o: OPT_FLAGS := -Ofast -mlong-calls else ifeq ($(COMPILER),clang) CC := clang endif From 5a1a075e359695b92a91fea2074222496a93473c Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 12 Sep 2021 12:37:15 +0100 Subject: [PATCH 2/4] Puppylights ambient and direction fix --- src/game/crash_screen.c | 8 ++++++++ src/game/puppylights.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/game/crash_screen.c b/src/game/crash_screen.c index 2b85b42a..1d24342f 100644 --- a/src/game/crash_screen.c +++ b/src/game/crash_screen.c @@ -3,6 +3,8 @@ #include #include #include "buffers/framebuffers.h" +#include "types.h" +#include "puppyprint.h" #include "sm64.h" @@ -256,9 +258,15 @@ void thread2_crash_screen(UNUSED void *arg) { osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1); osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2); do { +#if PUPPYPRINT_DEBUG + OSTime first = osGetTime(); +#endif osRecvMesg(&gCrashScreen.mesgQueue, &mesg, 1); thread = get_crashed_thread(); gCrashScreen.framebuffer = (u16 *) gFrameBuffers[sRenderedFramebuffer]; +#if PUPPYPRINT_DEBUG + profiler_update(faultTime, first); +#endif } while (thread == NULL); draw_crash_screen(thread); for (;;) { diff --git a/src/game/puppylights.c b/src/game/puppylights.c index 9b5ee0b9..552e41f0 100644 --- a/src/game/puppylights.c +++ b/src/game/puppylights.c @@ -200,8 +200,9 @@ void puppylights_iterate(struct PuppyLight *light, Lights1 *src, struct Object * //A slightly hacky way to offset the ambient lighting in order to prevent directional lighting from having a noticeable change in ambient brightness. if (flags & LIGHTFLAG_DIRECTIONAL_OFFSET) { - tempLight->a.l.col[i] *= 1.5f; - tempLight->a.l.colc[i] *= 1.5f; + ambient = approach_f32_asymptotic(tempLight->a.l.col[i] * 1.5f, tempLight->a.l.col[i], scale2*((f32)light->rgba[3]/255.0f)); + tempLight->a.l.col[i] = ambient; + tempLight->a.l.colc[i] = ambient; } //Apply direction. It takes the relative positions, and then multiplies them with the perspective matrix to get a correct direction. //Index 1 of the first dimension of gMatStack is perspective. Note that if you ever decide to cheat your way into rendering things after the game does :^) @@ -216,6 +217,7 @@ void puppylights_run(Lights1 *src, struct Object *obj, s32 flags, u32 baseColour { s32 i; s32 numlights = 0; + s32 offsetPlaced = 0; s32 lightFlags = flags; if (gCurrLevelNum < 4) @@ -252,8 +254,11 @@ void puppylights_run(Lights1 *src, struct Object *obj, s32 flags, u32 baseColour { if (gPuppyLights[i]->rgba[3] > 0 && gPuppyLights[i]->active == TRUE && gPuppyLights[i]->area == gCurrAreaIndex && (gPuppyLights[i]->room == -1 || gPuppyLights[i]->room == gMarioCurrentRoom)) { - if (i == gDynLightStart) + if (gPuppyLights[i]->flags & PUPPYLIGHT_DIRECTIONAL && !offsetPlaced) + { lightFlags |= LIGHTFLAG_DIRECTIONAL_OFFSET; + offsetPlaced = 1; + } else lightFlags &= ~LIGHTFLAG_DIRECTIONAL_OFFSET; puppylights_iterate(gPuppyLights[i], src, obj, lightFlags); @@ -282,12 +287,17 @@ void puppylights_object_emit(struct Object *obj) goto deallocate; //That's right. I used a goto. Eat your heart out xkcd. if (obj->oLightID == 0xFFFF) { + s32 fadingExists = FALSE; if (ABS(gNumLights - gDynLightStart) < MAX_LIGHTS_DYNAMIC) goto deallocate; for (i = gDynLightStart; i < MIN(gDynLightStart+MAX_LIGHTS_DYNAMIC, MAX_LIGHTS); i++) { if (gPuppyLights[i]->active == TRUE) + { + if (gPuppyLights[i]->flags & PUPPYLIGHT_DELETE) + fadingExists = TRUE; continue; + } memcpy(gPuppyLights[i], &obj->puppylight, sizeof(struct PuppyLight)); gPuppyLights[i]->active = TRUE; gPuppyLights[i]->area = gCurrAreaIndex; @@ -295,6 +305,22 @@ void puppylights_object_emit(struct Object *obj) obj->oLightID = i; goto updatepos; } + //Go through all the lights again, now this time, ignore the fading light flag and overwrite them. + if (fadingExists) + { + for (i = gDynLightStart; i < MIN(gDynLightStart+MAX_LIGHTS_DYNAMIC, MAX_LIGHTS); i++) + { + if (gPuppyLights[i]->active == TRUE && !(gPuppyLights[i]->flags & PUPPYLIGHT_DELETE)) + continue; + memcpy(gPuppyLights[i], &obj->puppylight, sizeof(struct PuppyLight)); + gPuppyLights[i]->active = TRUE; + gPuppyLights[i]->area = gCurrAreaIndex; + gPuppyLights[i]->room = obj->oRoom; + gPuppyLights[i]->flags &= ~PUPPYLIGHT_DELETE; + obj->oLightID = i; + goto updatepos; + } + } } else { From 815d02a685bc662aac1bf2bbe99740fb6ce5ebaa Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 12 Sep 2021 13:02:45 +0100 Subject: [PATCH 3/4] Strength. --- src/game/puppylights.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/game/puppylights.c b/src/game/puppylights.c index 552e41f0..16c189cc 100644 --- a/src/game/puppylights.c +++ b/src/game/puppylights.c @@ -200,7 +200,7 @@ void puppylights_iterate(struct PuppyLight *light, Lights1 *src, struct Object * //A slightly hacky way to offset the ambient lighting in order to prevent directional lighting from having a noticeable change in ambient brightness. if (flags & LIGHTFLAG_DIRECTIONAL_OFFSET) { - ambient = approach_f32_asymptotic(tempLight->a.l.col[i] * 1.5f, tempLight->a.l.col[i], scale2*((f32)light->rgba[3]/255.0f)); + ambient = approach_f32_asymptotic(MIN(tempLight->a.l.col[i] * 2, 0xFF), tempLight->a.l.col[i], scale2*((f32)light->rgba[3]/255.0f)); tempLight->a.l.col[i] = ambient; tempLight->a.l.colc[i] = ambient; } From c67cd55d033f9bf22675ea89c2510b7c3a018c6a Mon Sep 17 00:00:00 2001 From: Fazana <52551480+FazanaJ@users.noreply.github.com> Date: Sun, 12 Sep 2021 17:23:59 +0100 Subject: [PATCH 4/4] Make --- Makefile | 8 ++++---- src/game/puppycam2.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f4254683..57b9f4c4 100644 --- a/Makefile +++ b/Makefile @@ -157,12 +157,12 @@ LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i)) ifeq ($(COMPILER),gcc) NON_MATCHING := 1 MIPSISET := -mips3 - OPT_FLAGS := -Ofast + OPT_FLAGS := -Os else ifeq ($(COMPILER),clang) NON_MATCHING := 1 # clang doesn't support ABI 'o32' for 'mips3' MIPSISET := -mips2 - OPT_FLAGS := -Ofast + OPT_FLAGS := -Os endif @@ -398,8 +398,8 @@ export LD_LIBRARY_PATH=./tools AS := $(CROSS)as ifeq ($(COMPILER),gcc) CC := $(CROSS)gcc - $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -Ofast -mlong-calls - $(BUILD_DIR)/levels/%.o: OPT_FLAGS := -Ofast -mlong-calls + $(BUILD_DIR)/actors/%.o: OPT_FLAGS := -Os -mlong-calls + $(BUILD_DIR)/levels/%.o: OPT_FLAGS := -Os -mlong-calls else ifeq ($(COMPILER),clang) CC := clang endif diff --git a/src/game/puppycam2.c b/src/game/puppycam2.c index 28e7c033..ddb6240f 100644 --- a/src/game/puppycam2.c +++ b/src/game/puppycam2.c @@ -24,6 +24,7 @@ #include "mario.h" #include "puppyprint.h" #include "debug_box.h" +#include "main.h" #ifdef PUPPYCAM