Alchemy
Loading...
Searching...
No Matches

clear.c File Reference

The file select overlay: the Golden Sun logo, the start menu (new game, continue, copy and delete), the door to the Battle Arena and the transfer of a save's data, by link or as a password. More...

Go to the source code of this file.

Data Structures

struct  SaveMenuSceneState
 A view of the scene state that names its copy of the play time, checked against the loaded game's. More...
struct  SaveLinkGreeting
 A linked console's signature: four letters naming its language and game. More...
struct  PasswordStats
 A party member's base stats, which the password clamps and packs. More...
struct  PasswordOwner
 A party member as the password reads them: their level, base stats, inventory and Djinn. More...

Macros

#define CLEAR_PASSWORD_BUFFER_SIZE   320
#define CLEAR_LINK_WINDOW_X   6
#define CLEAR_LINK_WINDOW_WIDTH   18
#define CLEAR_LINK_LANGUAGE_TAG   'U'
#define CLEAR_LINK_ERROR_WINDOW_X   5
#define CLEAR_LINK_ERROR_WINDOW_WIDTH   20
#define CLEAR_HELP_WINDOW_X   10
#define CLEAR_HELP_WINDOW_WIDTH   10
#define CLEAR_PAGE_LABEL_X   80
#define CLEAR_MESSAGE_WINDOW_X   1
#define CLEAR_MESSAGE_WINDOW_WIDTH   28
#define PASSWORD_SYMBOLS_PER_PAGE   50
#define PASSWORD_SYMBOL_MASK   0x3f
#define CLEAR_EXTRA_CODE_HELD   (*(s16 *)&gClear_ExtraCodeHeld)
 Whether a key of the extra code is still held.
#define CLEAR_SEQUENCE_KEYS(sequence)

Functions

static s32 Clear_PackPasswordData (s32 unused, s32 mode, u8 *out)
 Packs selected flags, levels, Djinn and optional stats/inventories/coins.
static s32 Clear_EncodePassword (u8 *data, s32 size, u8 *out)
 Obscures the packed bytes and emits position-adjusted six-bit password symbols.
static u16 Clear_ComputePasswordCrc16 (u32 byteCount, u8 *data)
 Runs the original shift/subtract checksum, initially 0xffff, and returns its complemented low 16 bits.
u8 * Clear_GetEntrances (void)
 The file select overlay's scene tables, for the scene loader: one entrance, the exit, and no placements or events.
s32 SceneData_ReturnZero (void)
u8 * Clear_GetExits (void)
u8 * Clear_GetPlacements (void)
u8 * Clear_GetEvents (void)
static void Clear_LoadBackground (void)
 Loads the Golden Sun logo, maps its tiles and resets background scroll.
static void Clear_UpdateBlend (void)
 Advances the logo blend every two frames and removes itself at completion.
static void Clear_CheckButtonCodes (void)
 Tracks two hidden key sequences, requiring a full release after each key.
static void Clear_NameEntryCharacter (s32 cell, u8 *text)
 Converts a six-bit password symbol to the edition's one- or two-byte glyph.
static s32 Clear_GetSaveRecoveryBlockMask (void)
 Returns -1 when the flagged saved scene blocks recovery, otherwise zero.
s32 __divsi3 (s32, s32)
s32 SaveMenu_Run (void)
 Runs new/continue/copy/delete, arena entry and save-data transfer/password menus.
static UNUSED void SaveMenu_FillTileGrid (struct UiWindow *window, const void *compressedTiles)
 UNUSED: decodes tiles and maps a 16-by-eight window region in VRAM and shadow.
static UNUSED void SaveMenu_FillTileBlock (const struct UiWindow *window)
 UNUSED: fills a 16-by-eight region with palette 15 tiles beginning at tile 32.

Variables

const u16 gClear_CodeSequence []
 Hidden command: sequence of pressed keys, terminated by 0.
const u16 gClear_ExtraCodeSequence []
struct SceneEntrance gClear_Entrances []
u32 gClear_Exits []
struct ScenePlacement gClear_Placements []
struct SceneEvent gClear_Events []
s16 gClear_BlendFrame = 0
s16 gClear_CodeUnlocked = 0
s16 gClear_ExtraCodeUnlocked = 0
s16 gClear_CodeProgress = 0
s16 gClear_ExtraCodeProgress = 0
s16 gClear_CodeHeld = 0
s32 gClear_ExtraCodeHeld = 0
u32 gClear_PasswordMembers []
u32 gClear_PasswordFlags []
u32 gClear_PasswordKeyItems []
u16 gClear_PasswordStackItems []

Detailed Description

The file select overlay: the Golden Sun logo, the start menu (new game, continue, copy and delete), the door to the Battle Arena and the transfer of a save's data, by link or as a password.

Definition in file clear.c.

Macro Definition Documentation

◆ CLEAR_PASSWORD_BUFFER_SIZE

#define CLEAR_PASSWORD_BUFFER_SIZE   320

Definition at line 54 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_LINK_WINDOW_X

#define CLEAR_LINK_WINDOW_X   6

Definition at line 64 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_LINK_WINDOW_WIDTH

#define CLEAR_LINK_WINDOW_WIDTH   18

Definition at line 65 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_LINK_LANGUAGE_TAG

#define CLEAR_LINK_LANGUAGE_TAG   'U'

Definition at line 79 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_LINK_ERROR_WINDOW_X

#define CLEAR_LINK_ERROR_WINDOW_X   5

Definition at line 87 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_LINK_ERROR_WINDOW_WIDTH

#define CLEAR_LINK_ERROR_WINDOW_WIDTH   20

Definition at line 88 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_HELP_WINDOW_X

#define CLEAR_HELP_WINDOW_X   10

Definition at line 96 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_HELP_WINDOW_WIDTH

#define CLEAR_HELP_WINDOW_WIDTH   10

Definition at line 97 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_PAGE_LABEL_X

#define CLEAR_PAGE_LABEL_X   80

Definition at line 101 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_MESSAGE_WINDOW_X

#define CLEAR_MESSAGE_WINDOW_X   1

Definition at line 114 of file clear.c.

Referenced by SaveMenu_Run().

◆ CLEAR_MESSAGE_WINDOW_WIDTH

#define CLEAR_MESSAGE_WINDOW_WIDTH   28

Definition at line 115 of file clear.c.

Referenced by SaveMenu_Run().

◆ PASSWORD_SYMBOLS_PER_PAGE

#define PASSWORD_SYMBOLS_PER_PAGE   50

Definition at line 118 of file clear.c.

Referenced by SaveMenu_Run().

◆ PASSWORD_SYMBOL_MASK

#define PASSWORD_SYMBOL_MASK   0x3f

Definition at line 119 of file clear.c.

Referenced by Clear_EncodePassword(), and SaveMenu_Run().

◆ CLEAR_EXTRA_CODE_HELD

#define CLEAR_EXTRA_CODE_HELD   (*(s16 *)&gClear_ExtraCodeHeld)

Whether a key of the extra code is still held.

UB: the flag is a word the code reads and writes as its low halfword; UBFIX uses the word.

Definition at line 126 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ CLEAR_SEQUENCE_KEYS

#define CLEAR_SEQUENCE_KEYS ( sequence)
Value:
(((struct { u16 key[1]; } *)(sequence))->key)
unsigned short u16
Definition types.h:13

Definition at line 233 of file clear.c.

Referenced by Clear_CheckButtonCodes().

Function Documentation

◆ Clear_PackPasswordData()

s32 Clear_PackPasswordData ( s32 unused,
s32 mode,
u8 * out )
static

Packs selected flags, levels, Djinn and optional stats/inventories/coins.

Clamps the source base stats and levels in place; returns the raw byte count.

Definition at line 946 of file clear.c.

Referenced by Clear_PackPasswordData(), and SaveMenu_Run().

◆ Clear_EncodePassword()

s32 Clear_EncodePassword ( u8 * data,
s32 size,
u8 * out )
static

Obscures the packed bytes and emits position-adjusted six-bit password symbols.

Definition at line 1155 of file clear.c.

Referenced by Clear_EncodePassword(), and SaveMenu_Run().

◆ Clear_ComputePasswordCrc16()

u16 Clear_ComputePasswordCrc16 ( u32 byteCount,
u8 * data )
static

Runs the original shift/subtract checksum, initially 0xffff, and returns its complemented low 16 bits.

Definition at line 1207 of file clear.c.

Referenced by Clear_ComputePasswordCrc16(), and SaveMenu_Run().

◆ Clear_GetEntrances()

u8 * Clear_GetEntrances ( void )

The file select overlay's scene tables, for the scene loader: one entrance, the exit, and no placements or events.

Definition at line 135 of file clear.c.

Referenced by Clear_GetEntrances().

◆ SceneData_ReturnZero()

s32 SceneData_ReturnZero ( void )

Definition at line 137 of file clear.c.

◆ Clear_GetExits()

u8 * Clear_GetExits ( void )

Definition at line 139 of file clear.c.

Referenced by Clear_GetExits().

◆ Clear_GetPlacements()

u8 * Clear_GetPlacements ( void )

Definition at line 141 of file clear.c.

Referenced by Clear_GetPlacements().

◆ Clear_GetEvents()

u8 * Clear_GetEvents ( void )

Definition at line 143 of file clear.c.

Referenced by Clear_GetEvents().

◆ Clear_LoadBackground()

void Clear_LoadBackground ( void )
static

Loads the Golden Sun logo, maps its tiles and resets background scroll.

Definition at line 146 of file clear.c.

Referenced by Clear_LoadBackground(), and SaveMenu_Run().

◆ Clear_UpdateBlend()

void Clear_UpdateBlend ( void )
static

Advances the logo blend every two frames and removes itself at completion.

Definition at line 195 of file clear.c.

Referenced by Clear_UpdateBlend(), and SaveMenu_Run().

◆ Clear_CheckButtonCodes()

void Clear_CheckButtonCodes ( void )
static

Tracks two hidden key sequences, requiring a full release after each key.

Definition at line 238 of file clear.c.

Referenced by Clear_CheckButtonCodes(), and SaveMenu_Run().

◆ Clear_NameEntryCharacter()

void Clear_NameEntryCharacter ( s32 cell,
u8 * text )
static

Converts a six-bit password symbol to the edition's one- or two-byte glyph.

Definition at line 283 of file clear.c.

Referenced by Clear_NameEntryCharacter(), and SaveMenu_Run().

◆ Clear_GetSaveRecoveryBlockMask()

s32 Clear_GetSaveRecoveryBlockMask ( void )
static

Returns -1 when the flagged saved scene blocks recovery, otherwise zero.

Definition at line 341 of file clear.c.

Referenced by Clear_GetSaveRecoveryBlockMask(), and SaveMenu_Run().

◆ __divsi3()

◆ SaveMenu_Run()

s32 SaveMenu_Run ( void )

Runs new/continue/copy/delete, arena entry and save-data transfer/password menus.

Returns zero after choosing a destination; cancellation returns to selection.

Definition at line 372 of file clear.c.

Referenced by SaveMenu_Run().

◆ SaveMenu_FillTileGrid()

UNUSED void SaveMenu_FillTileGrid ( struct UiWindow * window,
const void * compressedTiles )
static

UNUSED: decodes tiles and maps a 16-by-eight window region in VRAM and shadow.

Definition at line 855 of file clear.c.

Referenced by SaveMenu_FillTileGrid().

◆ SaveMenu_FillTileBlock()

UNUSED void SaveMenu_FillTileBlock ( const struct UiWindow * window)
static

UNUSED: fills a 16-by-eight region with palette 15 tiles beginning at tile 32.

Definition at line 885 of file clear.c.

Referenced by SaveMenu_FillTileBlock().

Variable Documentation

◆ gClear_CodeSequence

const u16 gClear_CodeSequence[]
Initial value:
= {
}
@ KEY_SELECT
Definition io_reg.h:245

Hidden command: sequence of pressed keys, terminated by 0.

Definition at line 217 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ gClear_ExtraCodeSequence

const u16 gClear_ExtraCodeSequence[]
Initial value:

Definition at line 221 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ gClear_Entrances

struct SceneEntrance gClear_Entrances[]
Initial value:
= {
{0, CONDITION_ALWAYS, 0, 0, 0, FACING_SOUTH, 0, -1, -1, -1, -1, 0},
}
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ FACING_SOUTH
Definition field_scene.h:28

Definition at line 1233 of file clear.c.

Referenced by Clear_GetEntrances().

◆ gClear_Exits

u32 gClear_Exits[]
Initial value:
= {
}
#define SCENE_EXITS(scene)
Definition field_scene.h:72

Definition at line 1238 of file clear.c.

Referenced by Clear_GetExits().

◆ gClear_Placements

struct ScenePlacement gClear_Placements[]
Initial value:
= {
}

Definition at line 1242 of file clear.c.

Referenced by Clear_GetPlacements().

◆ gClear_Events

struct SceneEvent gClear_Events[]
Initial value:
= {
}
#define SCENE_EVENTS_END

Definition at line 1246 of file clear.c.

Referenced by Clear_GetEvents().

◆ gClear_BlendFrame

s16 gClear_BlendFrame = 0

Definition at line 1250 of file clear.c.

Referenced by Clear_UpdateBlend().

◆ gClear_CodeUnlocked

s16 gClear_CodeUnlocked = 0

Definition at line 1252 of file clear.c.

Referenced by Clear_CheckButtonCodes(), and SaveMenu_Run().

◆ gClear_ExtraCodeUnlocked

s16 gClear_ExtraCodeUnlocked = 0

Definition at line 1254 of file clear.c.

Referenced by Clear_CheckButtonCodes(), and SaveMenu_Run().

◆ gClear_CodeProgress

s16 gClear_CodeProgress = 0

Definition at line 1256 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ gClear_ExtraCodeProgress

s16 gClear_ExtraCodeProgress = 0

Definition at line 1258 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ gClear_CodeHeld

s16 gClear_CodeHeld = 0

Definition at line 1260 of file clear.c.

Referenced by Clear_CheckButtonCodes().

◆ gClear_ExtraCodeHeld

s32 gClear_ExtraCodeHeld = 0

Definition at line 1262 of file clear.c.

◆ gClear_PasswordMembers

u32 gClear_PasswordMembers[]
Initial value:
= {
0, 1, 2, 3,
}

Definition at line 1265 of file clear.c.

Referenced by Clear_PackPasswordData().

◆ gClear_PasswordFlags

u32 gClear_PasswordFlags[]
Initial value:
= {
0x9510941, 0x8d108b3, 0x868081e,
}

Definition at line 1269 of file clear.c.

Referenced by Clear_PackPasswordData().

◆ gClear_PasswordKeyItems

u32 gClear_PasswordKeyItems[]
Initial value:
= {
0xc900c8, 0xcb00ca, 0xcd00cc, 0xcf00ce,
}

Definition at line 1273 of file clear.c.

Referenced by Clear_PackPasswordData().

◆ gClear_PasswordStackItems

u16 gClear_PasswordStackItems[]
Initial value:
= {
180, 181, 182, 183, 186, 187, 188, 189,
191, 192, 193, 194, 195, 196, 226, 227,
228, 229, 236, 238, 239, 240, 241,
}

Definition at line 1277 of file clear.c.

Referenced by Clear_PackPasswordData().