Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to return to title screen from the pause screen after the save prompt. #2339

Open
wants to merge 16 commits into
base: Dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added ASM/actor.o
Binary file not shown.
1,475 changes: 766 additions & 709 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
877 changes: 451 additions & 426 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions ASM/c/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
#define AUDIO_H

#include <stdint.h>

typedef struct {
float x, y, z;
} Vec3f; // move this if needed elsewhere
#include "z64.h"

extern Vec3f z64_SfxDefaultPos;
extern float z64_SfxDefaultFreqAndVolScale;
Expand Down
218 changes: 218 additions & 0 deletions ASM/c/kaleido_scope.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
#include "kaleido_scope.h"
#include "stdint.h"

extern KaleidoMgrOverlay gKaleidoMgrOverlayTable[];
extern KaleidoMgrOverlay* gKaleidoMgrCurOvl;

extern u8 CFG_SAVE_AND_QUIT;
s16* D_8082B25C_RELOCATED;
static s32 saveAndQuitConfig = 0;
extern void* ICON_STATIC_GAME_OVER;
extern s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size);
extern Vec3f z64_SfxDefaultPos;
extern f32 z64_SfxDefaultFreqAndVolScale;
extern u8 z64_SfxDefaultReverb;

void kaleidoScope_Case7(z64_game_t* play) {
z64_pause_ctxt_t* pauseCtx = &play->pause_ctxt;
switch (play->pause_ctxt.unk_1EC) {
case 0:
play->pause_ctxt.unk_204 -= 314.0f / WREG(6);
WREG(16) -= WREG(25) / WREG(6);
WREG(17) -= WREG(26) / WREG(6);
if (play->pause_ctxt.unk_204 <= -628.0f) {
play->pause_ctxt.unk_204 = -628.0f;
play->pause_ctxt.unk_1EC = 1;
}
break;

case 1:
if (play->common.input[0].pad_pressed.a) {
if (CFG_SAVE_AND_QUIT == 0) {
if (play->pause_ctxt.prompt_choice != 0) {
Interface_SetDoAction(play, DO_ACTION_NONE);
z64_file.button_status[0] = z64_file.button_status[1] = z64_file.button_status[2] =
z64_file.button_status[3] = 0;
z64_file.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
play->pause_ctxt.unk_1EC = 2;
WREG(2) = -6240;
YREG(8) = play->pause_ctxt.unk_204;
func_800F64E0(0);
} else {
Audio_PlaySfxGeneral(18467, &z64_SfxDefaultPos, 4,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultReverb);
Play_SaveSceneFlags(play);

z64_file.scene_index = play->scene_index;
Sram_WriteSave_call(&play->unk_0F_[0x0207]);
play->pause_ctxt.unk_1EC = 4;
(*D_8082B25C_RELOCATED) = 90;
}
} else {
if (play->pause_ctxt.prompt_choice != 0) {
play->pause_ctxt.prompt_choice = 0;
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
play->pause_ctxt.state = PAUSE_STATE_RETURN_TO_TITLE_PROMPT;
DmaMgr_RequestSync(ICON_STATIC_GAME_OVER, 0x00860000, 0x3300);
} else {
Audio_PlaySfxGeneral(18467, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
play->pause_ctxt.prompt_choice = 0;
Play_SaveSceneFlags(play);
z64_file.scene_index = play->scene_index;
Sram_WriteSave_call(&play->unk_0F_[0x0207]);
play->pause_ctxt.state = PAUSE_STATE_RETURN_TO_TITLE_PROMPT_TIMER;
(*D_8082B25C_RELOCATED) = 3;
DmaMgr_RequestSync(ICON_STATIC_GAME_OVER, 0x00860000, 0x3300);
}
}

} else if (play->common.input[0].pad_pressed.s ||
play->common.input[0].pad_pressed.b) {
Interface_SetDoAction(play, DO_ACTION_NONE);
play->pause_ctxt.unk_1EC = 2;
WREG(2) = -6240;
YREG(8) = play->pause_ctxt.unk_204;
func_800F64E0(0);
z64_file.button_status[0] = z64_file.button_status[1] = z64_file.button_status[2] =
z64_file.button_status[3] = 0;
z64_file.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
}
break;

case 4:
if (play->common.input[0].pad_pressed.b || play->common.input[0].pad_pressed.a ||
play->common.input[0].pad_pressed.s || (--(*D_8082B25C_RELOCATED) == 0)) {
Interface_SetDoAction(play, DO_ACTION_NONE);
z64_file.button_status[0] = z64_file.button_status[1] = z64_file.button_status[2] =
z64_file.button_status[3] = 0;
z64_file.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
play->pause_ctxt.unk_1EC = 5;
WREG(2) = -6240;
YREG(8) = play->pause_ctxt.unk_204;
func_800F64E0(0);
}
break;
//
case 3:
case 6:
play->pause_ctxt.unk_204 += 314.0f / WREG(6);
WREG(16) += WREG(25) / WREG(6);
WREG(17) += WREG(26) / WREG(6);
if (play->pause_ctxt.unk_204 >= -314.0f) {
play->pause_ctxt.state = PAUSE_STATE_MAIN;
play->pause_ctxt.unk_1EC = 0;
play->pause_ctxt.unk_1F4 = play->pause_ctxt.unk_1F8 = play->pause_ctxt.unk_1FC = play->pause_ctxt.unk_200 = 0.0f;
play->pause_ctxt.unk_204 = -314.0f;
}
break;

case 2:
case 5:
if (play->pause_ctxt.unk_204 != (YREG(8) + 160.0f)) {
play->pause_ctxt.unk_1F4 = play->pause_ctxt.unk_1F8 = play->pause_ctxt.unk_1FC = play->pause_ctxt.unk_200 +=
160.0f / WREG(6);
play->pause_ctxt.unk_204 += 160.0f / WREG(6);
play->pause_ctxt.info_panel_offset_y -= 40 / WREG(6);
WREG(16) -= WREG(25) / WREG(6);
WREG(17) -= WREG(26) / WREG(6);
XREG(5) -= 150 / WREG(6);
play->pause_ctxt.alpha -= (u16)(255 / WREG(6));
if (play->pause_ctxt.unk_204 == (YREG(8) + 160.0f)) {
play->pause_ctxt.alpha = 0;
}
} else {
play->pause_ctxt.debugState = 0;
play->pause_ctxt.state = PAUSE_STATE_RESUME_GAMEPLAY;
play->pause_ctxt.unk_1F4 = play->pause_ctxt.unk_1F8 = play->pause_ctxt.unk_1FC = play->pause_ctxt.unk_200 = 160.0f;
play->pause_ctxt.item_id = 999;
play->pause_ctxt.changing = PAUSE_MAIN_STATE_IDLE;
play->pause_ctxt.unk_204 = -434.0f;
}
break;

default:
break;
}

}

void kaleidoScope_Case21(z64_game_t* play) {
z64_pause_ctxt_t* pauseCtx = &play->pause_ctxt;

if (play->common.input[0].pad_pressed.a || play->common.input[0].pad_pressed.s) {
if (play->pause_ctxt.prompt_choice == 0) {
//Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
// &z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
Interface_SetDoAction(play, DO_ACTION_NONE);
play->pause_ctxt.unk_1EC = 2;
WREG(2) = -6240;
YREG(8) = play->pause_ctxt.unk_204;
func_800F64E0(0);
z64_file.button_status[0] = z64_file.button_status[1] = z64_file.button_status[2] =
z64_file.button_status[3] = 0;
z64_file.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_ALL);
play->pause_ctxt.state = PAUSE_STATE_SAVE_PROMPT;
return;
} else {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
func_800F64E0(0);
SEQCMD_STOP_SEQUENCE(0, 5);
SEQCMD_STOP_SEQUENCE(3, 5);
play->pause_ctxt.state = PAUSE_STATE_REUTRN_TO_TITLE;
}
}
}

void kaleidoScope_Case20(z64_game_t* play) {
z64_pause_ctxt_t* pauseCtx = &play->pause_ctxt;

(*D_8082B25C_RELOCATED)--;
if ((*D_8082B25C_RELOCATED) == 0) {
play->pause_ctxt.state = PAUSE_STATE_RETURN_TO_TITLE_PROMPT;
} else if (((*D_8082B25C_RELOCATED) <= 80) &&
(play->common.input[0].pad_pressed.a || play->common.input[0].pad_pressed.s)) {
play->pause_ctxt.state = PAUSE_STATE_RETURN_TO_TITLE_PROMPT;
}
}

static s16 D_8082A6E0[] = { 100, 255 };

void KaleidoScope_UpdatePrompt(z64_game_t* play) {
s8 stickAdjX = play->common.input[0].adjusted_x;
s16 step;

if (((play->pause_ctxt.state == PAUSE_STATE_SAVE_PROMPT) && (play->pause_ctxt.unk_1EC == 1)) ||
(play->pause_ctxt.state == PAUSE_STATE_14) || (play->pause_ctxt.state == PAUSE_STATE_16) || (play->pause_ctxt.state == PAUSE_STATE_RETURN_TO_TITLE_PROMPT)) {
if ((play->pause_ctxt.prompt_choice == 0) && (stickAdjX >= 30)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
play->pause_ctxt.prompt_choice = 4;
} else if ((play->pause_ctxt.prompt_choice != 0) && (stickAdjX <= -30)) {
Audio_PlaySfxGeneral(NA_SE_SY_CURSOR, &z64_SfxDefaultPos, 4, &z64_SfxDefaultFreqAndVolScale,
&z64_SfxDefaultFreqAndVolScale, &z64_SfxDefaultReverb);
play->pause_ctxt.prompt_choice = 0;
}

step = ABS(VREG(61) - D_8082A6E0[VREG(62)]) / VREG(63);
if (VREG(61) >= D_8082A6E0[VREG(62)]) {
VREG(61) -= step;
} else {
VREG(61) += step;
}

VREG(63)--;
if (VREG(63) == 0) {
VREG(61) = D_8082A6E0[VREG(62)];
VREG(63) = VREG(60) + VREG(62);
VREG(62) ^= 1;
}
}
}
73 changes: 73 additions & 0 deletions ASM/c/kaleido_scope.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#pragma once
owlisnotacat1 marked this conversation as resolved.
Show resolved Hide resolved
Copy link

@rrealmuto rrealmuto Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does our compiler support #pragma once?

Copy link

@flagrama flagrama Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use a modern version of gcc so it should. Whether we should mix that with headers already using header guards is another question though.


#include "z64.h"

typedef signed char s8;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably just add a header that mimics ultratypes.h for these base types

typedef short s16;
typedef int s32;
typedef long long s64;
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;
typedef float f32;
typedef double f64;

extern void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd);
extern void Sram_WriteSave_call(void* sramCtx);
extern void Play_SaveSceneFlags(z64_game_t* play);
extern void Interface_SetDoAction(z64_game_t* play, u16 action);
extern void Interface_ChangeHudVisibilityMode(u16 hudVisibilityMode);
extern void func_800F64E0(u8 arg0);

typedef enum DoAction {
/* 0x00 */ DO_ACTION_ATTACK,
/* 0x01 */ DO_ACTION_CHECK,
/* 0x02 */ DO_ACTION_ENTER,
/* 0x03 */ DO_ACTION_RETURN,
/* 0x04 */ DO_ACTION_OPEN,
/* 0x05 */ DO_ACTION_JUMP,
/* 0x06 */ DO_ACTION_DECIDE,
/* 0x07 */ DO_ACTION_DIVE,
/* 0x08 */ DO_ACTION_FASTER,
/* 0x09 */ DO_ACTION_THROW,
/* 0x0A */ DO_ACTION_NONE, // in do_action_static, the texture at this position is NAVI, however this value is in practice the "No Action" value
/* 0x0B */ DO_ACTION_CLIMB,
/* 0x0C */ DO_ACTION_DROP,
/* 0x0D */ DO_ACTION_DOWN,
/* 0x0E */ DO_ACTION_SAVE,
/* 0x0F */ DO_ACTION_SPEAK,
/* 0x10 */ DO_ACTION_NEXT,
/* 0x11 */ DO_ACTION_GRAB,
/* 0x12 */ DO_ACTION_STOP,
/* 0x13 */ DO_ACTION_PUTAWAY,
/* 0x14 */ DO_ACTION_REEL,
/* 0x15 */ DO_ACTION_1,
/* 0x16 */ DO_ACTION_2,
/* 0x17 */ DO_ACTION_3,
/* 0x18 */ DO_ACTION_4,
/* 0x19 */ DO_ACTION_5,
/* 0x1A */ DO_ACTION_6,
/* 0x1B */ DO_ACTION_7,
/* 0x1C */ DO_ACTION_8,
/* 0x1D */ DO_ACTION_MAX
} DoAction;

typedef enum HudVisibilityMode {
/* 0 */ HUD_VISIBILITY_NO_CHANGE,
/* 1 */ HUD_VISIBILITY_NOTHING,
/* 2 */ HUD_VISIBILITY_NOTHING_ALT, // Identical to HUD_VISIBILITY_NOTHING
/* 3 */ HUD_VISIBILITY_HEARTS_FORCE, // See above
/* 4 */ HUD_VISIBILITY_A,
/* 5 */ HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE, // See above
/* 6 */ HUD_VISIBILITY_A_HEARTS_MAGIC_MINIMAP_FORCE, // See above
/* 7 */ HUD_VISIBILITY_ALL_NO_MINIMAP_BY_BTN_STATUS, // Only raises button alphas if not disabled
/* 8 */ HUD_VISIBILITY_B,
/* 9 */ HUD_VISIBILITY_HEARTS_MAGIC,
/* 10 */ HUD_VISIBILITY_B_ALT, // Identical to HUD_VISIBILITY_B
/* 11 */ HUD_VISIBILITY_HEARTS,
/* 12 */ HUD_VISIBILITY_A_B_MINIMAP,
/* 13 */ HUD_VISIBILITY_HEARTS_MAGIC_FORCE, // See above
/* 50 */ HUD_VISIBILITY_ALL = 50, // Only raises button alphas if not disabled
/* 52 */ HUD_VISIBILITY_NOTHING_INSTANT = 52
} HudVisibilityMode;
3 changes: 3 additions & 0 deletions ASM/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@

void Gameplay_InitSkybox(z64_game_t* globalCtx, int16_t skyboxId);

extern void* ICON_STATIC_GAME_OVER;

void c_init() {
heap_init();
gfx_init();
item_overrides_init();
override_flags_init();
models_init();
init_textures();
ICON_STATIC_GAME_OVER = heap_alloc(0x3300);
}

void before_game_state_update() {
Expand Down
Loading
Loading