Skip to Content
The Alchemy Project

src/window/screens_save.c

Save files, the file list and the saving screen's progress bar. More…

Included by screens.c.

Macros

NameDescription
#defineSAVE_NO_FREE_FILE 999What mnSaveFindFreeFile returns when all BUP_FILE_COUNT files are in use.
#defineSAVE_ERROR_READ -2What the save functions return when they fail, after showing the message.
#defineSAVE_ERROR_WRITE
#defineSAVE_ERROR_ERASE -4erasing failed: "Failed to erase."
#defineSAVE_ERROR_NO_FILE -5no empty file to copy into
#defineSAVE_ERROR_NO_MEMORY
#definePLAY_TIME_HOURS_MAX 999The play time shown stops at PLAY_TIME_HOURS_MAX hours and 59 minutes.
#defineMINUTES_PER_HOUR 60
#defineSECONDS_PER_MINUTE 60
#defineWITH_LEADING_ZERO (n) ((n) + 100)A two-digit field for mnStringFormatNumber: with 100 added, its last two digits keep their leading zero.
#defineBUP_CHECKSUM_WORDS 968The words from GameFlagBytes that a file's checksum sums.
#defineFILE_LIST_GLOW_RED 22The file list's glow: the middle colour that HIGHLIGHT_PALETTE's colours 8 to 11 sway round, red twice as far as green and blue.
#defineFILE_LIST_GLOW_GREEN 16
#defineFILE_LIST_GLOW_BLUE 20
#defineFILE_LIST_SPRITE_SPACING 3The tiles between two of the file list's party sprites, and between two of its Djinn counts, one for each element.
#defineFILE_LIST_SPRITE_LIFT 500How high the file list lifts a party sprite, in pixels, and how far it brings it forward: the two cancel on screen, and its depth runs past the field's last slot, so it is drawn in front of every field sprite and behind the windows' (OAM_DEPTH_WINDOW).
#definePROGRESS_BAR_X 9The progress bar: twelve tiles wide at tile column 9, row 9 of the window map, drawn from tiles 128 on (mnSaveProgressOpen loads them), in seven stages.
#definePROGRESS_BAR_Y 9
#definePROGRESS_BAR_WIDTH 12
#definePROGRESS_BAR_LAST_ROW 6
#definePROGRESS_BAR_FIRST_TILE 128
#definePROGRESS_MUSIC_FADE_STEP 30The music fades out under the progress screen and back after it by this much of BGM_UNITY_SCALE a frame.
#defineSAVING_X FRENCH_OR(40, 76)Heading x coordinate: only French differs.
#defineERASING_X FRENCH_OR(48, 92)
#defineCOPYING_X FRENCH_OR(48, 84)
#defineDMA_STOP (n)Stops DMA channel n.
#defineERASE_CONFIRM_X 4The French confirmation window is farther left.
#defineFILE_LIST_HIGHLIGHT_TILE 6The window tile the file list's chosen row is filled with, drawn in HIGHLIGHT_PALETTE, whose colours mnFileListUpdatePulse makes glow.
#defineSUMMARY_LEVEL_X 64
#defineSUMMARY_COINS_X 56
#defineFILE_LIST_LEADER_X BY_LANGUAGE(12, 12, 6, 6, 6, 6)Where the leader's name and the area name start in a file's row of the file list, in pixels: the European languages start both farther left.
#defineFILE_LIST_AREA_X BY_LANGUAGE(72, 72, 62, 62, 62, 62)
#defineSAVE_MENU_NO_FILE -2mnFileListSelectFile's result when no file can be chosen for its purpose.
#defineFILE_LIST_SKIP_FILES (unusable)Moves mnFileListSelectFile's cursor round the files, from selectedFile, to the first that is neither empty nor unusable; when every file is one or the other, the list never opens and returns SAVE_MENU_NO_FILE.

Enumerations

NameDescription
enumSAVE_PROGRESS_KIND { SAVE_PROGRESS_SAVING, SAVE_PROGRESS_ERASING, SAVE_PROGRESS_C … }What the progress screen says it is doing.

Functions

NameDescription
voidmnSaveProgressAdvance (Sint32 step)The save's progress callback: moves the progress bar on by step sectors and draws its row of WindowProgressBarRows, the last (PROGRESS_BAR_LAST_ROW) once the bar is full.
WINDOW *mnSaveProgressOpen (Uint32 kind)Opens the progress screen for a SAVE_PROGRESS_KIND.
WINDOW *mnSaveProgressClose (WINDOW *window)Closes the progress screen.
Sint32mnSaveWritePartMasked (Sint32 partId, void *buf)Runs syBupWritePart with interrupts masked and all four DMA channels stopped, setting mnSaveProgressAdvance as the save's progress callback around it, then restores IE and IME.
Sint32mnSaveDeletePartMasked (Sint32 partId)Deletes a part of a save file (syBupDeletePart) with interrupts masked and all four DMA channels stopped, setting mnSaveProgressAdvance as the save's progress callback around it, as mnSaveWritePartMasked does around syBupWritePart.
Uint8 *mnStringFormatStopwatch (Uint32 ticks, Uint8 *out)Unused: writes ticks as "HHH:MM:SS:CC", hours to hundredths, into out and returns out.
void *mnStringFormatPlayTime (Sint32 ticks, Uint8 *out)Writes the play time ticks into out as hours and minutes, "hhh:mm" with the hours right-aligned in three characters, and returns out.
Uint32mnSaveFindFreeFile (void)Returns the first save file whose summary shows it empty (level 0), or SAVE_NO_FREE_FILE when all three are in use.
Sint32mnSaveCountFilesExcludingSent (Sint32 excludeSent)Returns how many save files there are, leaving out those whose summary has its send flag set (the files saved at the end of the game) when excludeSent is nonzero, or SAVE_ERROR_NO_MEMORY when the backup memory cannot be read.
Sint32mnSaveScanFileSummaries (void)Loads the save file summaries for the File Screen and returns how many files there are: plus SAVE_SCAN_ALL_CLEARED when every file is cleared (its send flag set), or SAVE_ERROR_NO_MEMORY when the backup memory cannot be read.
Sint32mnSaveBuildFileSummary (void)Prepares the save buffer for writing: stamps the main routine's state with the time and options, then fills the file summary shown on the file menus (the leader's name, level and class, the play time, area, coins, Djinn of each element, the party, the send flag and how many Djinn it has found) and its checksum, the sum of the BUP_CHECKSUM_WORDS words from GameFlagBytes on.
Sint32mnSaveWriteFile (Sint32 file)Writes both halves of the save buffer, as they are, to save file file.
Sint32mnSaveWriteLinkTallies (void)Writes the link lobby's tallies (MainRoutineStateWork.linkTallies) into the current file's first part (BupSlot), under the saving screen, leaving the rest of the part as it was saved.
Sint32mnSaveToFile (Uint32 file)Saves the game to file (the last file for any past it) under "Saving...", then says "Your game was saved." or that it failed.
Sint32mnSaveToChosenFile (void)Lets the player choose a file and saves the game to it, asking first before it writes over a file in use.
Sint32mnSaveChooseAndLoadFile (Sint32 purpose)Lets the player choose a file for purpose (FILE_LIST_PURPOSE) and loads it, with its play time and Auto-Sleep setting.
Sint32mnSaveCopyFile (void)Selects a file and copies it to a free file.
Sint32mnSaveEraseSelectedFile (void)Lets the player choose a file and, once they answer Yes, erases it.
voidmnFileListUpdatePulse (void)An event that makes colours 8-11 of HIGHLIGHT_PALETTE glow: each follows a sine wave of the frame counter, eight frames behind the one before.
voidmnFileListStartPulse (void)Starts the palette glow (mnFileListUpdatePulse) as an event.
voidmnFileListStopPulse (void)Stops the palette glow.
voidmnFileListFillHighlight ( WINDOW *window, Sint32 x, Sint32 y, Sint32 width, Sint32 height)Fills the width x height tile rectangle at (x, y) inside window, clipped to the screen as mnWindowSetTextTileBitRect clips, with FILE_LIST_HIGHLIGHT_TILE: the file list's glowing bar under the chosen file.
voidmnFileListShowPartySprites (WINDOW *window, Sint32 x, Sint32 y, BUP_SUMMARY *summary)Shows the party of save file summary (up to four party members) as sprites in a row from tile (x, y) inside window, and starts placing them every tick (mnFileListPlacePartySprites).
voidmnFileListHidePartySprites (void)Stops placing the party sprites of the file list and releases them.
voidmnFileListPlacePartySprites (void)An event: draws each party sprite of the file list at its place and scale for this tick.
voidmnFileListDrawDjinnCounts (WINDOW *window, BUP_SUMMARY *summary)Draws a saved game's Djinn of each element into window, four two-digit numbers 24 pixels apart at y 16; nothing when window is null.
voidmnFileListDrawSummary (WINDOW *window, BUP_SUMMARY *summary)Draws a file's summary into window, when there is one: the leader's name, level and class, the play time and the coins.
Sint32mnFileListSelectFile (Sint32 selectedFile, Sint32 purpose)The file list: lists the three files with each one's leader and area (or why it cannot be chosen) and, for the file under the cursor, its summary, its party and its Djinn, in that file's window colours.

Description

Save files, the file list and the saving screen's progress bar. Part of screens.c.

Macros in detail

SAVE_NO_FREE_FILE

#define SAVE_NO_FREE_FILE 999

What mnSaveFindFreeFile returns when all BUP_FILE_COUNT files are in use.

Referenced by mnSaveCopyFile() and mnSaveFindFreeFile().

Definition at line 8 of file screens_save.c.

SAVE_ERROR_READ

#define SAVE_ERROR_READ -2

What the save functions return when they fail, after showing the message.

a part could not be read

Referenced by mnSaveChooseAndLoadFile(), mnSaveCopyFile() and mnSaveWriteLinkTallies().

Definition at line 11 of file screens_save.c.

SAVE_ERROR_WRITE

#define SAVE_ERROR_WRITE

Referenced by mnSaveCopyFile(), mnSaveToChosenFile(), mnSaveToFile(), mnSaveWriteFile() and mnSaveWriteLinkTallies().

Definition at line 12 of file screens_save.c.

SAVE_ERROR_ERASE

#define SAVE_ERROR_ERASE -4

erasing failed: "Failed to erase."

Referenced by mnSaveEraseSelectedFile().

Definition at line 15 of file screens_save.c.

SAVE_ERROR_NO_FILE

#define SAVE_ERROR_NO_FILE -5

no empty file to copy into

Referenced by mnSaveCopyFile().

Definition at line 16 of file screens_save.c.

SAVE_ERROR_NO_MEMORY

#define SAVE_ERROR_NO_MEMORY

Referenced by mnSaveChooseAndLoadFile(), mnSaveCopyFile(), mnSaveCountFilesExcludingSent(), mnSaveEraseSelectedFile(), mnSaveScanFileSummaries(), mnSaveToChosenFile(), mnSaveToFile(), mnSaveWriteFile() and mnSaveWriteLinkTallies().

Definition at line 17 of file screens_save.c.

PLAY_TIME_HOURS_MAX

#define PLAY_TIME_HOURS_MAX 999

The play time shown stops at PLAY_TIME_HOURS_MAX hours and 59 minutes.

Referenced by mnStringFormatPlayTime().

Definition at line 22 of file screens_save.c.

MINUTES_PER_HOUR

#define MINUTES_PER_HOUR 60

Referenced by mnStringFormatPlayTime() and mnStringFormatStopwatch().

Definition at line 23 of file screens_save.c.

SECONDS_PER_MINUTE

#define SECONDS_PER_MINUTE 60

Referenced by mnStringFormatPlayTime() and mnStringFormatStopwatch().

Definition at line 24 of file screens_save.c.

WITH_LEADING_ZERO

#define WITH_LEADING_ZERO(n) ((n) + 100)

A two-digit field for mnStringFormatNumber: with 100 added, its last two digits keep their leading zero.

Referenced by mnStringFormatPlayTime() and mnStringFormatStopwatch().

Definition at line 28 of file screens_save.c.

BUP_CHECKSUM_WORDS

#define BUP_CHECKSUM_WORDS 968

The words from GameFlagBytes that a file's checksum sums.

Referenced by mnSaveBuildFileSummary().

Definition at line 31 of file screens_save.c.

FILE_LIST_GLOW_RED

#define FILE_LIST_GLOW_RED 22

The file list's glow: the middle colour that HIGHLIGHT_PALETTE's colours 8 to 11 sway round, red twice as far as green and blue.

Referenced by mnFileListUpdatePulse().

Definition at line 35 of file screens_save.c.

FILE_LIST_GLOW_GREEN

#define FILE_LIST_GLOW_GREEN 16

Referenced by mnFileListUpdatePulse().

Definition at line 36 of file screens_save.c.

FILE_LIST_GLOW_BLUE

#define FILE_LIST_GLOW_BLUE 20

Referenced by mnFileListUpdatePulse().

Definition at line 37 of file screens_save.c.

FILE_LIST_SPRITE_SPACING

#define FILE_LIST_SPRITE_SPACING 3

The tiles between two of the file list's party sprites, and between two of its Djinn counts, one for each element.

Referenced by mnFileListDrawDjinnCounts() and mnFileListShowPartySprites().

Definition at line 41 of file screens_save.c.

FILE_LIST_SPRITE_LIFT

#define FILE_LIST_SPRITE_LIFT 500

How high the file list lifts a party sprite, in pixels, and how far it brings it forward: the two cancel on screen, and its depth runs past the field's last slot, so it is drawn in front of every field sprite and behind the windows' (OAM_DEPTH_WINDOW).

Referenced by mnFileListPlacePartySprites().

Definition at line 46 of file screens_save.c.

PROGRESS_BAR_X

#define PROGRESS_BAR_X 9

The progress bar: twelve tiles wide at tile column 9, row 9 of the window map, drawn from tiles 128 on (mnSaveProgressOpen loads them), in seven stages.

Referenced by mnSaveProgressAdvance().

Definition at line 51 of file screens_save.c.

PROGRESS_BAR_Y

#define PROGRESS_BAR_Y 9

Referenced by mnSaveProgressAdvance().

Definition at line 52 of file screens_save.c.

PROGRESS_BAR_WIDTH

#define PROGRESS_BAR_WIDTH 12

Referenced by mnSaveProgressAdvance().

Definition at line 53 of file screens_save.c.

PROGRESS_BAR_LAST_ROW

#define PROGRESS_BAR_LAST_ROW 6

Referenced by mnSaveProgressAdvance().

Definition at line 54 of file screens_save.c.

PROGRESS_BAR_FIRST_TILE

#define PROGRESS_BAR_FIRST_TILE 128

Referenced by mnSaveProgressAdvance() and mnSaveProgressOpen().

Definition at line 55 of file screens_save.c.

PROGRESS_MUSIC_FADE_STEP

#define PROGRESS_MUSIC_FADE_STEP 30

The music fades out under the progress screen and back after it by this much of BGM_UNITY_SCALE a frame.

Referenced by mnSaveProgressClose() and mnSaveProgressOpen().

Definition at line 59 of file screens_save.c.

SAVING_X

#define SAVING_X FRENCH_OR(40, 76)

Heading x coordinate: only French differs.

Referenced by mnSaveProgressOpen().

Definition at line 86 of file screens_save.c.

ERASING_X

#define ERASING_X FRENCH_OR(48, 92)

Referenced by mnSaveProgressOpen().

Definition at line 87 of file screens_save.c.

COPYING_X

#define COPYING_X FRENCH_OR(48, 84)

Referenced by mnSaveProgressOpen().

Definition at line 88 of file screens_save.c.

DMA_STOP

#define DMA_STOP(n)

Stops DMA channel n.

Referenced by mnSaveDeletePartMasked() and mnSaveWritePartMasked().

Definition at line 147 of file screens_save.c.

ERASE_CONFIRM_X

#define ERASE_CONFIRM_X 4

#define ERASE_CONFIRM_X 8

The French confirmation window is farther left.

Referenced by mnSaveEraseSelectedFile().

Definition at lines 769 and 771 of file screens_save.c.

FILE_LIST_HIGHLIGHT_TILE

#define FILE_LIST_HIGHLIGHT_TILE 6

The window tile the file list's chosen row is filled with, drawn in HIGHLIGHT_PALETTE, whose colours mnFileListUpdatePulse makes glow.

Referenced by mnFileListFillHighlight().

Definition at line 884 of file screens_save.c.

SUMMARY_LEVEL_X

#define SUMMARY_LEVEL_X 64

#define SUMMARY_LEVEL_X 59

Referenced by mnFileListDrawSummary().

Definition at lines 1050 and 1053 of file screens_save.c.

SUMMARY_COINS_X

#define SUMMARY_COINS_X 56

#define SUMMARY_COINS_X 48

Definition at lines 1051, 1054, 1056 and 1058 of file screens_save.c.

FILE_LIST_LEADER_X

#define FILE_LIST_LEADER_X BY_LANGUAGE(12, 12, 6, 6, 6, 6)

Where the leader's name and the area name start in a file's row of the file list, in pixels: the European languages start both farther left.

Referenced by mnFileListSelectFile().

Definition at line 1120 of file screens_save.c.

FILE_LIST_AREA_X

#define FILE_LIST_AREA_X BY_LANGUAGE(72, 72, 62, 62, 62, 62)

Referenced by mnFileListSelectFile().

Definition at line 1121 of file screens_save.c.

SAVE_MENU_NO_FILE

#define SAVE_MENU_NO_FILE -2

mnFileListSelectFile's result when no file can be chosen for its purpose.

Referenced by mnFileListSelectFile().

Definition at line 1124 of file screens_save.c.

FILE_LIST_SKIP_FILES

#define FILE_LIST_SKIP_FILES(unusable)

Moves mnFileListSelectFile's cursor round the files, from selectedFile, to the first that is neither empty nor unusable; when every file is one or the other, the list never opens and returns SAVE_MENU_NO_FILE.

Referenced by mnFileListSelectFile().

Definition at line 1129 of file screens_save.c.

Enumerations in detail

SAVE_PROGRESS_KIND

enum SAVE_PROGRESS_KIND

What the progress screen says it is doing.

EnumeratorValueDescription
SAVE_PROGRESS_SAVING0"Saving..." (MsgSaving)
SAVE_PROGRESS_ERASING1"Erasing..." (MsgErasing)
SAVE_PROGRESS_COPYING2"Copying..." (MsgCopying)

Definition at line 91 of file screens_save.c.

Functions in detail

mnSaveProgressAdvance

void mnSaveProgressAdvance(Sint32 step)

The save's progress callback: moves the progress bar on by step sectors and draws its row of WindowProgressBarRows, the last (PROGRESS_BAR_LAST_ROW) once the bar is full.

References Sint32 and WindowProgressBarRows.

Referenced by mnSaveDeletePartMasked() and mnSaveWritePartMasked().

Definition at line 64 of file screens_save.c.

mnSaveProgressOpen

WINDOW *mnSaveProgressOpen(Uint32 kind)

Opens the progress screen for a SAVE_PROGRESS_KIND.

References mnTextDrawMessage(), mnWindowCreate(), Sint32, syDecompressTaggedLZ(), syDMAXCopy(), syHeapAllocateEWRAM(), syHeapRelease(), sySoundPlayStub(), sySoundSetBGMVolumeTargetStub(), sySynch() and WindowProgressBarTiles.

Referenced by mnSaveCopyFile(), mnSaveEraseSelectedFile(), mnSaveToChosenFile() and mnSaveWriteLinkTallies().

Definition at line 99 of file screens_save.c.

mnSaveProgressClose

WINDOW *mnSaveProgressClose(WINDOW *window)

Closes the progress screen.

References fdPlayQueuedMusicStub(), mnWindowClose(), sySoundSetBGMVolumeTargetStub() and sySynch().

Referenced by mnSaveCopyFile(), mnSaveEraseSelectedFile(), mnSaveToChosenFile() and mnSaveWriteLinkTallies().

Definition at line 137 of file screens_save.c.

mnSaveWritePartMasked

Sint32 mnSaveWritePartMasked(Sint32 partId, void *buf)

Runs syBupWritePart with interrupts masked and all four DMA channels stopped, setting mnSaveProgressAdvance as the save's progress callback around it, then restores IE and IME. mnSaveDeletePartMasked does the same around syBupDeletePart.

References mnSaveProgressAdvance(), result, Sint32, syBupSetProgressCallback() and syBupWritePart().

Referenced by mnSaveCopyFile(), mnSaveToChosenFile(), mnSaveToFile(), mnSaveWriteFile() and mnSaveWriteLinkTallies().

Definition at line 160 of file screens_save.c.

mnSaveDeletePartMasked

Sint32 mnSaveDeletePartMasked(Sint32 partId)

Deletes a part of a save file (syBupDeletePart) with interrupts masked and all four DMA channels stopped, setting mnSaveProgressAdvance as the save's progress callback around it, as mnSaveWritePartMasked does around syBupWritePart.

References mnSaveProgressAdvance(), result, Sint32, syBupDeletePart() and syBupSetProgressCallback().

Referenced by mnSaveEraseSelectedFile().

Definition at line 187 of file screens_save.c.

mnStringFormatStopwatch

Uint8 *mnStringFormatStopwatch(Uint32 ticks, Uint8 *out)

Unused: writes ticks as "HHH:MM:SS:CC", hours to hundredths, into out and returns out. Its stub is exported (stubs.s), but no overlay imports it and nothing calls it.

References mnStringFormatNumber().

Definition at line 213 of file screens_save.c.

mnStringFormatPlayTime

void *mnStringFormatPlayTime(Sint32 ticks, Uint8 *out)

Writes the play time ticks into out as hours and minutes, "hhh:mm" with the hours right-aligned in three characters, and returns out. The time stops at 999:59.

References mnStringFormatNumber() and Sint32.

Referenced by mnFileListDrawSummary().

Definition at line 272 of file screens_save.c.

mnSaveFindFreeFile

Uint32 mnSaveFindFreeFile(void)

Returns the first save file whose summary shows it empty (level 0), or SAVE_NO_FREE_FILE when all three are in use. The summaries must be loaded.

Referenced by mnSaveCopyFile().

Definition at line 313 of file screens_save.c.

mnSaveCountFilesExcludingSent

Sint32 mnSaveCountFilesExcludingSent(Sint32 excludeSent)

Returns how many save files there are, leaving out those whose summary has its send flag set (the files saved at the end of the game) when excludeSent is nonzero, or SAVE_ERROR_NO_MEMORY when the backup memory cannot be read. It opens and releases the save workspace itself.

References Sint32, syBupInitState(), syBupLoadFileSummaries() and syBupReleaseState().

Definition at line 332 of file screens_save.c.

mnSaveScanFileSummaries

Sint32 mnSaveScanFileSummaries(void)

Loads the save file summaries for the File Screen and returns how many files there are: plus SAVE_SCAN_ALL_CLEARED when every file is cleared (its send flag set), or SAVE_ERROR_NO_MEMORY when the backup memory cannot be read. Sets the title's options from them: Battle when a file has found a Djinni, Update when a file has a level and FLAG_REUNION clear.

References AnyFileCleared, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReleaseState(), TitleBattleOptionEnabled and TitleUpdateOptionEnabled.

Referenced by mnFileListSelectAction() and scInit().

Definition at line 366 of file screens_save.c.

mnSaveBuildFileSummary

Sint32 mnSaveBuildFileSummary(void)

Prepares the save buffer for writing: stamps the main routine's state with the time and options, then fills the file summary shown on the file menus (the leader's name, level and class, the play time, area, coins, Djinn of each element, the party, the send flag and how many Djinn it has found) and its checksum, the sum of the BUP_CHECKSUM_WORDS words from GameFlagBytes on.

References BupBuffer, fdAreaGetNameIndexStub(), GameFlagBytes, gmBuildStampGetTimeStub(), gmPartyListMembersStub(), gmPartySumDjinnCountsStub(), gmUnitGet(), IdleSleepEnabled, MainRoutineStateWork, PlayTimeTicks, SceneLocalState, Sint32 and syGameFlagGet().

Referenced by mnSaveToChosenFile() and mnSaveToFile().

Definition at line 409 of file screens_save.c.

mnSaveWriteFile

Sint32 mnSaveWriteFile(Sint32 file)

Writes both halves of the save buffer, as they are, to save file file. Returns 0, or a SAVE_ERROR_* after showing its message.

References BupBuffer, mnFieldMessageShow(), mnSaveWritePartMasked(), result, Sint32, syBupInitState() and syBupReleaseState().

Definition at line 482 of file screens_save.c.

mnSaveWriteLinkTallies

Sint32 mnSaveWriteLinkTallies(void)

Writes the link lobby's tallies (MainRoutineStateWork.linkTallies) into the current file's first part (BupSlot), under the saving screen, leaving the rest of the part as it was saved. Returns -1 when no file is current.

References BupBuffer, BupSlot, MainRoutineStateWork, mnFieldMessageShow(), mnSaveProgressClose(), mnSaveProgressOpen(), mnSaveWritePartMasked(), result, Sint32, syBupInitState(), syBupReadPart(), syBupReleaseState(), syHeapAllocateEWRAM() and syHeapRelease().

Referenced by scLinkLobbySaveBattleResults() and scLinkLobbySaveMonsterBattleResults().

Definition at line 503 of file screens_save.c.

mnSaveToFile

Sint32 mnSaveToFile(Uint32 file)

Saves the game to file (the last file for any past it) under "Saving...", then says "Your game was saved." or that it failed.

References BupBuffer, BupSlot, fdActorTableSnapshotStub(), mnFieldMessageShow(), mnMessageAllTyped(), mnMessageCloseFinishedWindows(), mnSaveBuildFileSummary(), mnSaveWritePartMasked(), result, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReleaseState(), sySoundPlayStub() and sySynch().

Definition at line 558 of file screens_save.c.

mnSaveToChosenFile

Sint32 mnSaveToChosenFile(void)

Lets the player choose a file and saves the game to it, asking first before it writes over a file in use.

References BupBuffer, BupSlot, fdActorTableSnapshotStub(), mnFieldMessageShow(), mnFileListSelectFile(), mnMessageAllTyped(), mnMessageCloseFinishedWindows(), mnSaveBuildFileSummary(), mnSaveProgressClose(), mnSaveProgressOpen(), mnSaveWritePartMasked(), mnYesNoMenuRun(), result, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReleaseState() and sySynch().

Referenced by mnPauseMenuRun() and scInit().

Definition at line 601 of file screens_save.c.

mnSaveChooseAndLoadFile

Sint32 mnSaveChooseAndLoadFile(Sint32 purpose)

Lets the player choose a file for purpose (FILE_LIST_PURPOSE) and loads it, with its play time and Auto-Sleep setting. Returns 0, -1 when cancelled, or a SAVE_ERROR_* after showing its message.

References BupBuffer, BupSlot, IdleSleepEnabled, IdleTicks, MainRoutineStateWork, mnFieldMessageShow(), mnFileListSelectFile(), PlayTimeTicks, result, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReadPart() and syBupReleaseState().

Referenced by scInit().

Definition at line 666 of file screens_save.c.

mnSaveCopyFile

Sint32 mnSaveCopyFile(void)

Selects a file and copies it to a free file. Its failures say "Failed to erase." (MsgEraseFailed), as erasing's do.

References BupBuffer, mnFieldMessageShow(), mnFileListSelectFile(), mnSaveFindFreeFile(), mnSaveProgressClose(), mnSaveProgressOpen(), mnSaveWritePartMasked(), result, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReadPart() and syBupReleaseState().

Referenced by scInit().

Definition at line 703 of file screens_save.c.

mnSaveEraseSelectedFile

Sint32 mnSaveEraseSelectedFile(void)

Lets the player choose a file and, once they answer Yes, erases it.

References mnFieldMessageShow(), mnFileListSelectFile(), mnMessageAllTyped(), mnMessageCloseFinishedWindows(), mnMessageOpenWindow(), mnSaveDeletePartMasked(), mnSaveProgressClose(), mnSaveProgressOpen(), mnYesNoMenuRun(), result, Sint32, syBupInitState(), syBupLoadFileSummaries(), syBupReleaseState() and sySynch().

Referenced by scInit().

Definition at line 775 of file screens_save.c.

mnFileListUpdatePulse

void mnFileListUpdatePulse(void)

An event that makes colours 8-11 of HIGHLIGHT_PALETTE glow: each follows a sine wave of the frame counter, eight frames behind the one before.

References FrameCount, Sint32 and sySin().

Referenced by mnFileListStartPulse() and mnFileListStopPulse().

Definition at line 833 of file screens_save.c.

mnFileListStartPulse

void mnFileListStartPulse(void)

Starts the palette glow (mnFileListUpdatePulse) as an event.

References mnFileListUpdatePulse(), Sint32 and sySetEvent().

Referenced by mnFileListSelectFile().

Definition at line 871 of file screens_save.c.

mnFileListStopPulse

void mnFileListStopPulse(void)

Stops the palette glow.

References mnFileListUpdatePulse(), Sint32 and syCloseEvent().

Referenced by mnFileListSelectFile().

Definition at line 877 of file screens_save.c.

mnFileListFillHighlight

void mnFileListFillHighlight( WINDOW *window, Sint32 x, Sint32 y, Sint32 width, Sint32 height)

Fills the width x height tile rectangle at (x, y) inside window, clipped to the screen as mnWindowSetTextTileBitRect clips, with FILE_LIST_HIGHLIGHT_TILE: the file list's glowing bar under the chosen file.

References Sint32.

Referenced by mnFileListSelectFile().

Definition at line 889 of file screens_save.c.

mnFileListShowPartySprites

void mnFileListShowPartySprites(WINDOW *window, Sint32 x, Sint32 y, BUP_SUMMARY *summary)

Shows the party of save file summary (up to four party members) as sprites in a row from tile (x, y) inside window, and starts placing them every tick (mnFileListPlacePartySprites).

References fdSpriteCreateStub(), fdSpriteStartAnimationStub(), mnFileListPlacePartySprites(), Sint32 and sySetEvent().

Referenced by mnFileListSelectFile().

Definition at line 952 of file screens_save.c.

mnFileListHidePartySprites

void mnFileListHidePartySprites(void)

Stops placing the party sprites of the file list and releases them.

References fdSpriteDestroyStub(), mnFileListPlacePartySprites(), Sint32 and syCloseEvent().

Referenced by mnFileListSelectFile().

Definition at line 982 of file screens_save.c.

mnFileListPlacePartySprites

void mnFileListPlacePartySprites(void)

An event: draws each party sprite of the file list at its place and scale for this tick.

References fdRenderApplyProjectedPlacementStub() and Sint32.

Referenced by mnFileListHidePartySprites() and mnFileListShowPartySprites().

Definition at line 1000 of file screens_save.c.

mnFileListDrawDjinnCounts

void mnFileListDrawDjinnCounts(WINDOW *window, BUP_SUMMARY *summary)

Draws a saved game's Djinn of each element into window, four two-digit numbers 24 pixels apart at y 16; nothing when window is null.

References mnTextDrawNumberAtOffset() and Sint32.

Referenced by mnFileListSelectFile().

Definition at line 1033 of file screens_save.c.

mnFileListDrawSummary

void mnFileListDrawSummary(WINDOW *window, BUP_SUMMARY *summary)

Draws a file's summary into window, when there is one: the leader's name, level and class, the play time and the coins.

References mnStringFormatPlayTime(), mnTextDrawMessageAsTiles(), mnTextDrawNumberAtOffset(), mnTextDrawNumberInWindow(), mnTextDrawStringAtOffset(), mnTextDrawStringInWindow(), mnWindowDrawDividerLine(), mnWindowSpritePrepareForRedraw(), MsgClassName, Sint32 and StatusMenuLevelLetterString.

Referenced by mnFileListSelectFile().

Definition at line 1063 of file screens_save.c.

mnFileListSelectFile

Sint32 mnFileListSelectFile(Sint32 selectedFile, Sint32 purpose)

The file list: lists the three files with each one's leader and area (or why it cannot be chosen) and, for the file under the cursor, its summary, its party and its Djinn, in that file's window colours. Returns the file chosen for purpose (FILE_LIST_PURPOSE), or -1 when cancelled.

References gmBuildStampGetTimeStub(), MainRoutineStateWork, mnDjinnFiguresInitTopRowStub(), mnDjinnFiguresReleaseTopRowStub(), mnDjinnFiguresSetShownStub(), mnDjinnFiguresSetSlotPosStub(), mnFileListDrawDjinnCounts(), mnFileListDrawSummary(), mnFileListFillHighlight(), mnFileListHidePartySprites(), mnFileListShowPartySprites(), mnFileListStartPulse(), mnFileListStopPulse(), mnTextDrawMessage(), mnTextDrawString(), mnTitleBob(), mnTitleCreate(), mnWindowClose(), mnWindowColorApply(), mnWindowCreate(), mnWindowDrawDividerLine(), mnWindowSpriteRedrawSavedRect(), PerWork, result, Sint32, syHeapSlotAllocate(), syHeapSlotRelease(), sySoundPlayStub() and sySynch().

Referenced by mnSaveChooseAndLoadFile(), mnSaveCopyFile(), mnSaveEraseSelectedFile() and mnSaveToChosenFile().

Definition at line 1148 of file screens_save.c.