Skip to content

Commit

Permalink
Bugfixes (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
bates64 authored Jan 25, 2024
2 parents 65f7505 + 39e4f3e commit 8c73b5f
Show file tree
Hide file tree
Showing 35 changed files with 101 additions and 102 deletions.
6 changes: 0 additions & 6 deletions include/common_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1761,12 +1761,6 @@ typedef struct BombTrigger {
/* 0x0C */ s32 radius; // effective 'size' of the object, usually set to zero because bombettes explosion radius is large enough
} BombTrigger; // size = 0x10;

// the use of this is a bug in sam_11
typedef struct BombTriggerF {
/* 0x00 */ Vec3f pos;
/* 0x0C */ f32 radius;
} BombTriggerF; // size = 0x10;

typedef struct AnimatedModel {
/* 0x00 */ s32 animModelID;
/* 0x04 */ Vec3f pos;
Expand Down
6 changes: 6 additions & 0 deletions src/background_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "hud_element.h"
#include "sprite.h"
#include "overlay.h"
#include "dx/config.h"

extern s32 gPauseBackgroundFade;

Expand Down Expand Up @@ -258,6 +259,8 @@ void gfx_transfer_frame_to_depth(u16* frameBuffer0, u16* frameBuffer1, u16* zBuf
. x .
. .
*/
//TODO emulator test -- find which ones have bad performance here
#if !DX_PAUSE_LAG_FIX
if (((frameBuffer1[pixel] >> 2) & 0xF) < 8) {
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y - 1, x - 1, &filterBuf0[0]);
gfx_frame_filter_pass_0(frameBuffer0, frameBuffer1, y - 1, x + 1, &filterBuf0[1]);
Expand All @@ -271,6 +274,9 @@ void gfx_transfer_frame_to_depth(u16* frameBuffer0, u16* frameBuffer1, u16* zBuf
// Don't apply any filters to the edges of the screen
zBuffer[pixel] = frameBuffer0[pixel] | 1;
}
#else
zBuffer[pixel] = frameBuffer0[pixel] | 1;
#endif
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/battle/area/arn/actor/tubbas_heart.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ EvtScript N(EVS_TakeTurn) = {
Call(GetCurrentPartnerID, LVar0)
IfEq(LVar0, PARTNER_BOW)
Call(EnableBattleStatusBar, FALSE)
//@bug -- meant to OR 3 with value of AVAR_Flags, not PARTNER_BOW
Call(GetActorVar, ACTOR_SELF, AVAR_Flags, LVar0) // fix bug
Call(GetActorVar, ACTOR_SELF, AVAR_Flags, LVar0)
BitwiseOrConst(LVar0, AVAL_Flag_TauntBow | AVAL_Flag_HidStatusBar)
Call(SetActorVar, ACTOR_SELF, AVAR_Flags, LVar0)
Call(UseBattleCamPreset, BTL_CAM_PRESET_14)
Expand Down
1 change: 0 additions & 1 deletion src/battle/area/kmr_part_3/actor/final_jr_troopa.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,6 @@ EvtScript N(EVS_HandlePhase) = {
EndIf
CaseEq(PHASE_ENEMY_BEGIN)
CaseEq(PHASE_ENEMY_END)
CaseEq(PHASE_PLAYER_BEGIN) //@bug duplicate case, should be PHASE_PLAYER_END
EndSwitch
Call(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE)
Call(UseIdleAnimation, ACTOR_SELF, TRUE)
Expand Down
1 change: 0 additions & 1 deletion src/battle/area/kmr_part_3/actor/jr_troopa.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,6 @@ EvtScript N(EVS_HandlePhase) = {
Call(UseBattleCamPreset, BTL_CAM_DEFAULT)
Call(MoveBattleCamOver, 4)
EndIf
EndIf /// @bug END_IF with no IF
CaseEq(PHASE_ENEMY_BEGIN)
// trying showing the scene where Goompa congratulates the player for dealing damage to Jr Troopa
Call(GetActorVar, ACTOR_SELF, AVAR_HitReact_State, LVar0)
Expand Down
2 changes: 1 addition & 1 deletion src/battle/btl_states_actions.c
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@ void btl_state_update_end_training_battle(void) {
gBattleSubState = BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT;
}
break;
case BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT: //@bug should be BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT
case BTL_SUBSTATE_END_TRAINING_AWAIT_OUTTA_SIGHT:
if (!does_script_exist(partner->handleBatttlePhaseScriptID)) {
battleStatus->outtaSightActive = FALSE;
gBattleSubState = BTL_SUBSTATE_END_TRAINING_RESET_CAM;
Expand Down
15 changes: 10 additions & 5 deletions src/dx/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
/// Enables the debug menu.
#define DX_DEBUG_MENU 1

/// Loads last used save file
#define DX_QUICK_LAUNCH 0

/// Skips logos (Nintendo, Intelligent Systems, etc.).
#define DX_SKIP_LOGOS 1

/// Skips the title screen.
#define DX_SKIP_TITLE 1
/// Skips the introductory storybook.
#define DX_SKIP_STORY 1

/// Skips the file select.
/// If a save file exists, the game will load it automatically, otherwise it will start a new game.
#define DX_SKIP_FILE_SELECT 1
/// Skips the demo reel playing while waiting for the player to 'Press Start'.
#define DX_SKIP_DEMO 1

/// Map to load when starting a new game.
#define NEW_GAME_MAP_ID "kmr_20"
Expand All @@ -27,4 +29,7 @@
/// Press L + D-Pad Up to show/hide the profiler.
#define USE_PROFILER 1

/// Skip laggy blur operations when opening the pause menu on emulator
#define DX_PAUSE_LAG_FIX 1

#endif
5 changes: 0 additions & 5 deletions src/filemenu/filemenu_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "fio.h"
#include "ld_addrs.h"
#include "game_modes.h"
#include "dx/config.h"

extern HudScript HES_AnimatedCursorHand;

Expand Down Expand Up @@ -332,10 +331,6 @@ void filemenu_update(void) {
filemenu_heldButtons &= ~BUTTON_A;
}

#if DX_SKIP_FILE_SELECT
filemenu_pressedButtons = BUTTON_A;
#endif

if (menu->initialized) {
if (menu->fpHandleInput != NULL) {
menu->fpHandleInput(menu);
Expand Down
15 changes: 0 additions & 15 deletions src/filemenu/filemenu_yesno.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,6 @@ INCLUDE_ASM(void, "filemenu/filemenu_yesno", filemenu_yesno_handle_input);
void filemenu_yesno_handle_input(MenuPanel* menu) {
s32 oldSelected = menu->selected;

#if DX_SKIP_FILE_SELECT
s32 i;
for (i = 0; i < ARRAY_COUNT(gSaveSlotHasData); i++) {
if (gSaveSlotHasData[i]) {
filemenu_menus[0]->selected = i;
break;
}
}
if (i == ARRAY_COUNT(gSaveSlotHasData)) {
menu->page = 2; // create new save
} else {
menu->page = 4; // load save
}
#endif

if (filemenu_heldButtons & BUTTON_STICK_UP) {
menu->row--;
if (menu->row < 0) {
Expand Down
1 change: 0 additions & 1 deletion src/inventory.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "common.h"
#include "hud_element.h"
#include "dx/config.h"

#define FULLY_EXTENDED_Y 18
#define FULLY_RETRACTED_Y -100
Expand Down
16 changes: 13 additions & 3 deletions src/msg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include "charset/postcard.png.h"
#include "charset/letter_content_1.png.h"

//TODO get a real ceil
s32 my_ceil(f32 f) {
return (s32)(f + 0.999f);
}

extern IMG_BIN ui_msg_bubble_left_png[];
extern IMG_BIN ui_msg_bubble_mid_png[];
extern IMG_BIN ui_msg_bubble_right_png[];
Expand Down Expand Up @@ -2011,9 +2016,14 @@ void msg_draw_frame(s32 posX, s32 posY, s32 sizeX, s32 sizeY, s32 style, s32 pal
do {} while (0);
switch (style) {
case MSG_STYLE_CHOICE:
r = UNPACK_PAL_R(((u16*)ui_msg_palettes)[4]) * 8;
g = UNPACK_PAL_G(((u16*)ui_msg_palettes)[4]) * 8;
b = UNPACK_PAL_B(((u16*)ui_msg_palettes)[4]) * 8;
r = UNPACK_PAL_R(((u16*)ui_msg_palettes)[4]);
g = UNPACK_PAL_G(((u16*)ui_msg_palettes)[4]);
b = UNPACK_PAL_B(((u16*)ui_msg_palettes)[4]);
// BUGFIX: properly remap colors to full range [0, 255]
r = my_ceil(255 * r / 31.0);
g = my_ceil(255 * g / 31.0);
b = my_ceil(255 * b / 31.0);

gDPPipeSync(gMainGfxPos++);
if (fading != 0 && bgAlpha < 255) {
gDPSetRenderMode(gMainGfxPos++, IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c1(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA), IM_RD | CVG_DST_SAVE | ZMODE_XLU | FORCE_BL | GBL_c2(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA));
Expand Down
17 changes: 10 additions & 7 deletions src/state_intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#include "hud_element.h"
#include "sprite.h"
#include "game_modes.h"
#include "dx/config.h"

enum IntroStates {
INTRO_INIT = 0x00000000,
INTRO_DISABLE_DRAW_FRAME = 0x00000001,
INTRO_LOAD_MAP = 0x00000002,
INTRO_AWAIT_MAIN = 0x00000003,
INTRO_FADE_IN = 0x00000004,
INTRO_ENABLE_DRAW_FRAME = 0x00000015, // unused
INTRO_ENABLE_DRAW_FRAME = 0x00000015, // unused
};

SHIFT_BSS s32 IntroEnableDrawFrameDelay;
Expand All @@ -23,16 +24,13 @@ SHIFT_BSS s32 IntroOverlayType;
SHIFT_BSS s32 D_800A0964; // related to skipping the intro

void state_init_intro(void) {
s8 viewportMode;

gGameStatusPtr->startupState = INTRO_INIT;

set_curtain_scale_goal(1.0f);
set_curtain_fade_goal(0.3f);

viewportMode = gGameStatusPtr->introPart;
switch (viewportMode) {
case 0:
switch (gGameStatusPtr->introPart) {
case INTRO_PART_0:
startup_set_fade_screen_alpha(0);

IntroOverlayAlpha = 255;
Expand All @@ -49,7 +47,7 @@ void state_init_intro(void) {
gGameStatusPtr->mapID = 5; //TODO hard-coded map ID
gGameStatusPtr->entryID = 3;
break;
case 1:
case INTRO_PART_1:
startup_set_fade_screen_alpha(0);

IntroOverlayAlpha = 0;
Expand Down Expand Up @@ -96,6 +94,11 @@ void state_step_intro(void) {
u32 pressedButtons = gGameStatusPtr->pressedButtons[0];
s32 i;

#if DX_SKIP_STORY
// immediately quit out of the state when skipping story
pressedButtons = BUTTON_START;
#endif

if (gGameStatusPtr->introPart != INTRO_PART_NONE) {
if (D_800A0964 == 0 && pressedButtons & (BUTTON_A | BUTTON_B | BUTTON_START | BUTTON_Z)) {
D_800A0964 = 1;
Expand Down
14 changes: 0 additions & 14 deletions src/state_logos.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "nu/nusys.h"
#include "fio.h"
#include "game_modes.h"
#include "dx/config.h"

void appendGfx_intro_logos(void);

Expand Down Expand Up @@ -127,18 +126,14 @@ void state_init_logos(void) {
}

void state_step_logos(void) {
#if VERSION_JP
int pressedButtons = gGameStatusPtr->pressedButtons[0];
#endif

if (gGameStatusPtr->skipLogos) {
if (startup_fade_screen_out(10)) {
set_curtain_scale(1.0f);
set_curtain_fade(0.0f);
set_game_mode(GAME_MODE_TITLE_SCREEN);
}
} else {
#if VERSION_JP
if ((gGameStatusPtr->startupState == LOGOS_STATE_N64_HOLD
|| gGameStatusPtr->startupState == LOGOS_STATE_N64_FADE_OUT
|| gGameStatusPtr->startupState == LOGOS_STATE_NINTENDO_FADE_IN
Expand All @@ -154,7 +149,6 @@ void state_step_logos(void) {
startup_set_fade_screen_color(208);
gGameStatusPtr->skipLogos = TRUE;
}
#endif

switch (gGameStatusPtr->startupState) {
case LOGOS_STATE_N64_FADE_IN:
Expand Down Expand Up @@ -241,14 +235,6 @@ void state_step_logos(void) {
heap_free(gLogosImages);
gLogosImages = NULL;
startup_set_fade_screen_alpha(255);
#if DX_SKIP_TITLE
if (fio_load_game(0)) {
initialize_curtains();
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
set_game_mode(GAME_MODE_WORLD);
break;
}
#endif
gGameStatusPtr->introPart = INTRO_PART_0;
set_game_mode(GAME_MODE_INTRO);
break;
Expand Down
28 changes: 23 additions & 5 deletions src/state_startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,29 @@ void state_step_startup(void) {
}

gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_DRAW_FRAME;
#if DX_SKIP_LOGOS
set_game_mode(GAME_MODE_TITLE_SCREEN);
#else
set_game_mode(GAME_MODE_LOGOS);
#endif

#if DX_QUICK_LAUNCH
// immediately jump into the world using last-used save file
gGameStatusPtr->saveSlot = gSaveGlobals.lastFileSelected;
fio_load_game(gGameStatusPtr->saveSlot);
set_game_mode(GAME_MODE_ENTER_WORLD);
gOverrideFlags &= ~GLOBAL_OVERRIDES_DISABLE_RENDER_WORLD;
#elif DX_SKIP_LOGOS
// go right to the story book or file select
#if DX_SKIP_STORY
set_curtain_scale(1.0f);
set_curtain_fade(0.0f);
set_game_mode(GAME_MODE_TITLE_SCREEN);
#else
set_curtain_scale(1.0f);
set_curtain_fade(0.3f);
gGameStatusPtr->introPart = INTRO_PART_0;
set_game_mode(GAME_MODE_INTRO);
#endif
#else
// use vanilla startup process
set_game_mode(GAME_MODE_LOGOS);
#endif
}

void state_drawUI_startup(void) {
Expand Down
30 changes: 24 additions & 6 deletions src/state_title_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ void state_step_title_screen(void) {
set_curtain_scale(1.0f);
set_curtain_fade(0.0f);

#if DX_SKIP_TITLE
gGameStatusPtr->startupState = TITLE_STATE_EXIT;
TitleScreenNextState = NEXT_STATE_FILE_SELECT;
TitleScreen_TimeLeft = 0;
#endif

if (TitleScreen_TimeLeft > 0) {
TitleScreen_TimeLeft--;
}
Expand Down Expand Up @@ -233,6 +227,29 @@ void state_step_title_screen(void) {
startup_fade_screen_update();
break;
case TITLE_STATE_HOLD:

#if DX_SKIP_DEMO && DX_SKIP_STORY
// play neither demo nor story
TitleScreen_TimeLeft = 200;
#elif DX_SKIP_DEMO
// only the story may play
if (TitleScreen_TimeLeft == 120) {
bgm_set_song(0, -1, 0, 3900, 8);
}
if (TitleScreen_TimeLeft == 0) {
gGameStatusPtr->startupState = TITLE_STATE_BEGIN_DISMISS;
TitleScreenNextState = NEXT_STATE_INTRO;
return;
}
#elif DX_SKIP_STORY
// only the demo may play
if (TitleScreen_TimeLeft == 0) {
gGameStatusPtr->startupState = TITLE_STATE_BEGIN_DISMISS;
TitleScreenNextState = NEXT_STATE_DEMO;
return;
}
#else
// allow either demo or story to play
if (PlayIntroNext && TitleScreen_TimeLeft == 120) {
bgm_set_song(0, -1, 0, 3900, 8);
}
Expand All @@ -246,6 +263,7 @@ void state_step_title_screen(void) {
PlayIntroNext ^= 1;
return;
}
#endif
if (pressedButtons & (BUTTON_A | BUTTON_START)) {
gGameStatusPtr->startupState = TITLE_STATE_BEGIN_DISMISS;
TitleScreenNextState = NEXT_STATE_FILE_SELECT;
Expand Down
1 change: 0 additions & 1 deletion src/world/area_dro/dro_01/dro_01_4_shop.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ EvtScript N(EVS_SecretPurcahseOrder_Moustafa) = {
Set(GB_StoryProgress, STORY_CH2_BOUGHT_SECRET_ITEMS)
Call(func_802D2C14, 0)
ExecWait(N(EVS_JumpAway))
EndIf /// @bug unmatched endif in script
Return
End
};
Expand Down
Loading

0 comments on commit 8c73b5f

Please sign in to comment.