Skip to content

Commit

Permalink
QoL aaaaaa123456789#9: fast saving (because we'll save a lot during t…
Browse files Browse the repository at this point in the history
…esting here)
  • Loading branch information
aaaaaa123456789 authored and vulcandth committed Oct 16, 2022
1 parent 697e147 commit a99d3bb
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 93 deletions.
11 changes: 0 additions & 11 deletions data/text/common_3.asm
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,11 @@ _WouldYouLikeToSaveTheGameText::
line "save the game?"
done

_SavingDontTurnOffThePowerText::
text "SAVING… DON'T TURN"
line "OFF THE POWER."
done

_SavedTheGameText::
text "<PLAYER> saved"
line "the game."
done

_AlreadyASaveFileText::
text "There is already a"
line "save file. Is it"
cont "OK to overwrite?"
done

_AnotherSaveFileText::
text "There is another"
line "save file. Is it"
Expand Down
3 changes: 1 addition & 2 deletions engine/events/halloffame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ HallOfFame_FadeOutMusic:
ld [wVramState], a
ldh [hMapAnims], a
farcall InitDisplayForHallOfFame
ld c, 100
jp DelayFrames
ret

HallOfFame_PlayMusicDE:
push de
Expand Down
2 changes: 0 additions & 2 deletions engine/link/link.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2518,8 +2518,6 @@ TryQuickSave:
xor a ; FALSE
.return_result
ld [wScriptVar], a
ld c, 30
call DelayFrames
pop af
ld [wChosenCableClubRoom], a
ret
Expand Down
94 changes: 19 additions & 75 deletions engine/menus/save.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SaveMenu:
call AskOverwriteSaveFile
jr c, .refused
call PauseGameLogic
call _SavingDontTurnOffThePower
call SavedTheGame
call ResumeGameLogic
call ExitMenu
and a
Expand Down Expand Up @@ -46,7 +46,6 @@ ChangeBoxSaveGame:
call AskOverwriteSaveFile
jr c, .refused
call PauseGameLogic
call SavingDontTurnOffThePower
call SaveBox
pop de
ld a, e
Expand All @@ -64,7 +63,7 @@ Link_SaveGame:
call AskOverwriteSaveFile
jr c, .refused
call PauseGameLogic
call _SavingDontTurnOffThePower
call SavedTheGame
call ResumeGameLogic
and a

Expand Down Expand Up @@ -109,10 +108,7 @@ MoveMonWOMail_InsertMon_SaveGame:
call LoadBox
call ResumeGameLogic
ld de, SFX_SAVE
call PlaySFX
ld c, 24
call DelayFrames
ret
jp PlaySFX

StartMoveMonWOMail_SaveGame:
ld hl, MoveMonWOMailSaveText
Expand All @@ -123,7 +119,7 @@ StartMoveMonWOMail_SaveGame:
call AskOverwriteSaveFile
jr c, .refused
call PauseGameLogic
call _SavingDontTurnOffThePower
call SavedTheGame
call ResumeGameLogic
and a
ret
Expand Down Expand Up @@ -174,31 +170,18 @@ AddHallOfFameEntry:
"MOBILE_EVENT_OBJECT_GS_BALL is no longer equal to $0b."
ret

SaveGameData:
call _SaveGameData
ret

AskOverwriteSaveFile:
ld a, [wSaveFileExists]
and a
jr z, .erase
call CompareLoadedAndSavedPlayerID
jr z, .yoursavefile
ret z
ld hl, AnotherSaveFileText
call SaveTheGame_yesorno
jr nz, .refused
jr .erase

.yoursavefile
ld hl, AlreadyASaveFileText
call SaveTheGame_yesorno
jr nz, .refused
jr .ok

.erase
call ErasePreviousSave

.ok
and a
ret

Expand Down Expand Up @@ -236,34 +219,27 @@ CompareLoadedAndSavedPlayerID:
cp c
ret

_SavingDontTurnOffThePower:
call SavingDontTurnOffThePower
SavedTheGame:
call _SaveGameData
; wait 32 frames
ld c, 32
call DelayFrames
; copy the original text speed setting to the stack
ld a, [wOptions]
push af
; set text speed to medium
ld a, TEXT_DELAY_MED
ld [wOptions], a
ld hl, wOptions
set NO_TEXT_SCROLL, [hl]
push hl
ld hl, .saving_text
call PrintText
pop hl
res NO_TEXT_SCROLL, [hl]
call SaveGameData
; <PLAYER> saved the game!
ld hl, SavedTheGameText
call PrintText
; restore the original text speed setting
pop af
ld [wOptions], a
ld de, SFX_SAVE
call WaitPlaySFX
call WaitSFX
; wait 30 frames
ld c, 30
call DelayFrames
ret
jp WaitSFX

_SaveGameData:
.saving_text
text "Saving…"
done

SaveGameData:
ld a, TRUE
ld [wSaveFileExists], a
farcall StageRTCTimeForSave
Expand Down Expand Up @@ -333,30 +309,6 @@ FindStackTop:
inc hl
jr .loop

SavingDontTurnOffThePower:
; Prevent joypad interrupts
xor a
ldh [hJoypadReleased], a
ldh [hJoypadPressed], a
ldh [hJoypadSum], a
ldh [hJoypadDown], a
; Save the text speed setting to the stack
ld a, [wOptions]
push af
; Set the text speed to medium
ld a, TEXT_DELAY_MED
ld [wOptions], a
; SAVING... DON'T TURN OFF THE POWER.
ld hl, SavingDontTurnOffThePowerText
call PrintText
; Restore the text speed setting
pop af
ld [wOptions], a
; Wait for 16 frames
ld c, 16
call DelayFrames
ret

ErasePreviousSave:
call EraseBoxes
call EraseHallOfFame
Expand Down Expand Up @@ -1095,18 +1047,10 @@ WouldYouLikeToSaveTheGameText:
text_far _WouldYouLikeToSaveTheGameText
text_end

SavingDontTurnOffThePowerText:
text_far _SavingDontTurnOffThePowerText
text_end

SavedTheGameText:
text_far _SavedTheGameText
text_end

AlreadyASaveFileText:
text_far _AlreadyASaveFileText
text_end

AnotherSaveFileText:
text_far _AnotherSaveFileText
text_end
Expand Down
2 changes: 0 additions & 2 deletions engine/pokemon/bills_pc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1929,8 +1929,6 @@ MovePKMNWithoutMail_InsertMon:
hlcoord 1, 16
ld de, .Saving_LeaveOn
call PlaceString
ld c, 20
call DelayFrames
pop af
pop bc
pop de
Expand Down
2 changes: 1 addition & 1 deletion mobile/mobile_5f.asm
Original file line number Diff line number Diff line change
Expand Up @@ -2964,7 +2964,7 @@ MACRO inc_crash_check_pointer_farcall
ENDM

IncCrashCheckPointer_SaveGameData:
inc_crash_check_pointer_farcall _SaveGameData
inc_crash_check_pointer_farcall SaveGameData

IncCrashCheckPointer_SaveAfterLinkTrade:
inc_crash_check_pointer_farcall SaveAfterLinkTrade
Expand Down

0 comments on commit a99d3bb

Please sign in to comment.