Save functions; feeble attempt at serial and link functions

This commit is contained in:
pikalaxalt 2016-05-11 21:19:52 -04:00
parent af0119ca7e
commit 6a3b3e3773
8 changed files with 117 additions and 108 deletions

View File

@ -2020,7 +2020,7 @@ MovePKMNWitoutMail_InsertMon: ; e31e7
.dw_return ; e322a .dw_return ; e322a
pop af pop af
ld e, a ld e, a
callba Function14ad5 callba MovePkmnWOMail_InsertMon_SaveGame
ret ret
; e3233 ; e3233

View File

@ -1942,20 +1942,20 @@ LinkTrade: ; 28b87
pop af pop af
ld c, a ld c, a
cp MEW cp MEW
jr z, .asm_28e49 jr z, .loop
ld a, [CurPartySpecies] ld a, [CurPartySpecies]
cp MEW cp MEW
jr z, .asm_28e49 jr z, .loop
ld b, $2 ld b, $2
ld a, c ld a, c
cp CELEBI cp CELEBI
jr z, .asm_28e49 jr z, .loop
ld a, [CurPartySpecies] ld a, [CurPartySpecies]
cp CELEBI cp CELEBI
jr z, .asm_28e49 jr z, .loop
ld b, $0 ld b, $0
.asm_28e49 .loop
ld a, b ld a, b
ld [wPlayerLinkAction], a ld [wPlayerLinkAction], a
push bc push bc
@ -1963,16 +1963,16 @@ LinkTrade: ; 28b87
pop bc pop bc
ld a, [wLinkMode] ld a, [wLinkMode]
cp LINK_TIMECAPSULE cp LINK_TIMECAPSULE
jr z, .asm_28e63 jr z, .save
ld a, b ld a, b
and a and a
jr z, .asm_28e63 jr z, .save
ld a, [wOtherPlayerLinkAction] ld a, [wOtherPlayerLinkAction]
cp b cp b
jr nz, .asm_28e49 jr nz, .loop
.asm_28e63 .save
callba Function14a58 callba SaveAfterLinkTrade
callba MobileFn_1060af callba MobileFn_1060af
callba BackupMobileEventIndex callba BackupMobileEventIndex
ld c, 40 ld c, 40
@ -2255,7 +2255,7 @@ Special_WaitForLinkedFriend: ; 29d11
.asm_29d2f .asm_29d2f
ld a, $2 ld a, $2
ld [wcf5c], a ld [wcf5b + 1], a
ld a, $ff ld a, $ff
ld [wcf5b], a ld [wcf5b], a
.asm_29d39 .asm_29d39
@ -2278,9 +2278,9 @@ Special_WaitForLinkedFriend: ; 29d11
dec a dec a
ld [wcf5b], a ld [wcf5b], a
jr nz, .asm_29d68 jr nz, .asm_29d68
ld a, [wcf5c] ld a, [wcf5b + 1]
dec a dec a
ld [wcf5c], a ld [wcf5b + 1], a
jr z, .asm_29d8d jr z, .asm_29d8d
.asm_29d68 .asm_29d68
@ -2384,24 +2384,24 @@ Function29e0c: ; 29e0c
ld [hFFCA], a ld [hFFCA], a
ld a, [wcf5b] ld a, [wcf5b]
ld h, a ld h, a
ld a, [wcf5c] ld a, [wcf5b + 1]
ld l, a ld l, a
push hl push hl
call Function29e3b call .CheckConnected
pop hl pop hl
jr nz, .asm_29e2f jr nz, .load_true
call Function29e47 call .AcknowledgeSerial
call Function29e53 call .ConvertDW
call Function29e3b call .CheckConnected
jr nz, .asm_29e2f jr nz, .load_true
call Function29e47 call .AcknowledgeSerial
xor a xor a
jr .asm_29e31 jr .load_scriptvar
.asm_29e2f .load_true
ld a, $1 ld a, $1
.asm_29e31 .load_scriptvar
ld [ScriptVar], a ld [ScriptVar], a
ld hl, wcf5b ld hl, wcf5b
xor a xor a
@ -2410,7 +2410,7 @@ Function29e0c: ; 29e0c
ret ret
; 29e3b ; 29e3b
Function29e3b: ; 29e3b .CheckConnected: ; 29e3b
call Function87d call Function87d
ld hl, wcf5b ld hl, wcf5b
ld a, [hli] ld a, [hli]
@ -2421,17 +2421,19 @@ Function29e3b: ; 29e3b
ret ret
; 29e47 ; 29e47
Function29e47: ; 29e47 .AcknowledgeSerial: ; 29e47
ld b, $a ld b, 10
.asm_29e49 .loop
call DelayFrame call DelayFrame
call LinkDataReceived call LinkDataReceived
dec b dec b
jr nz, .asm_29e49 jr nz, .loop
ret ret
; 29e53 ; 29e53
Function29e53: ; 29e53 .ConvertDW: ; 29e53
; hl = ((hl - $100) / 4) + $100
; = (hl / 4) + $c0
dec h dec h
srl h srl h
rr l rr l
@ -2441,7 +2443,7 @@ Function29e53: ; 29e53
ld a, h ld a, h
ld [wcf5b], a ld [wcf5b], a
ld a, l ld a, l
ld [wcf5c], a ld [wcf5b + 1], a
ret ret
; 29e66 ; 29e66

View File

@ -4,7 +4,7 @@ SaveMenu: ; 14a1a
call SpeechTextBox call SpeechTextBox
call UpdateSprites call UpdateSprites
callba SaveMenu_LoadEDTile callba SaveMenu_LoadEDTile
ld hl, UnknownText_0x15283 ld hl, Text_WouldYouLikeToSaveTheGame
call SaveTheGame_yesorno call SaveTheGame_yesorno
jr nz, .refused jr nz, .refused
call AskOverwriteSaveFile call AskOverwriteSaveFile
@ -23,7 +23,7 @@ SaveMenu: ; 14a1a
scf scf
ret ret
Function14a58: ; 14a58 SaveAfterLinkTrade: ; 14a58
call PauseGameLogic call PauseGameLogic
callba StageRTCTimeForSave callba StageRTCTimeForSave
callba BackupMysteryGift callba BackupMysteryGift
@ -40,7 +40,7 @@ Function14a58: ; 14a58
ChangeBoxSaveGame: ; 14a83 (5:4a83) ChangeBoxSaveGame: ; 14a83 (5:4a83)
push de push de
ld hl, UnknownText_0x152a1 ld hl, Text_SaveOnBoxSwitch
call MenuTextBox call MenuTextBox
call YesNoBox call YesNoBox
call ExitMenu call ExitMenu
@ -86,7 +86,7 @@ MovePkmnWOMail_SaveGame: ; 14ac2
ret ret
; 14ad5 ; 14ad5
Function14ad5: ; 14ad5 MovePkmnWOMail_InsertMon_SaveGame: ; 14ad5
call PauseGameLogic call PauseGameLogic
push de push de
call SaveBox call SaveBox
@ -120,7 +120,7 @@ Function14ad5: ; 14ad5
; 14b34 ; 14b34
StartMovePkmnWOMail_SaveGame: ; 14b34 StartMovePkmnWOMail_SaveGame: ; 14b34
ld hl, UnknownText_0x152a6 ld hl, Text_SaveOnMovePkmnWOMail
call MenuTextBox call MenuTextBox
call YesNoBox call YesNoBox
call ExitMenu call ExitMenu
@ -184,13 +184,13 @@ AskOverwriteSaveFile: ; 14b89
jr z, .erase jr z, .erase
call CompareLoadedAndSavedPlayerID call CompareLoadedAndSavedPlayerID
jr z, .yoursavefile jr z, .yoursavefile
ld hl, UnknownText_0x15297 ld hl, Text_AnotherSaveFile
call SaveTheGame_yesorno call SaveTheGame_yesorno
jr nz, .refused jr nz, .refused
jr .erase jr .erase
.yoursavefile .yoursavefile
ld hl, UnknownText_0x15292 ld hl, Text_AlreadyASaveFile
call SaveTheGame_yesorno call SaveTheGame_yesorno
jr nz, .refused jr nz, .refused
jr .ok jr .ok
@ -208,7 +208,7 @@ AskOverwriteSaveFile: ; 14b89
; 14baf ; 14baf
SaveTheGame_yesorno: ; 14baf SaveTheGame_yesorno: ; 14baf
ld b, BANK(UnknownText_0x15283) ld b, BANK(Text_WouldYouLikeToSaveTheGame)
call MapTextbox call MapTextbox
call LoadMenuTextBox call LoadMenuTextBox
lb bc, 0, 7 lb bc, 0, 7
@ -253,7 +253,7 @@ SavedTheGame: ; 14be6
ld a, 3 ld a, 3
ld [Options], a ld [Options], a
; <PLAYER> saved the game! ; <PLAYER> saved the game!
ld hl, UnknownText_0x1528d ld hl, Text_PlayerSavedTheGame
call PrintText call PrintText
; restore the original text speed setting ; restore the original text speed setting
pop af pop af
@ -355,7 +355,7 @@ SavingDontTurnOffThePower: ; 14c99
ld a, $3 ld a, $3
ld [Options], a ld [Options], a
; SAVING... DON'T TURN OFF THE POWER. ; SAVING... DON'T TURN OFF THE POWER.
ld hl, UnknownText_0x15288 ld hl, Text_SavingDontTurnOffThePower
call PrintText call PrintText
; Restore the text speed setting ; Restore the text speed setting
pop af pop af
@ -416,17 +416,18 @@ EraseHallOfFame: ; 14d06
; 14d18 ; 14d18
Function14d18: ; 14d18 Function14d18: ; 14d18
; copy Unknown_14d2c to SRA4:a007 ; XXX
; copy .Data to SRA4:a007
ld a, $4 ld a, $4
call GetSRAMBank call GetSRAMBank
ld hl, Unknown_14d2c ld hl, .Data
ld de, $a007 ld de, $a007
ld bc, 48 ld bc, .DataEnd - .Data
call CopyBytes call CopyBytes
jp CloseSRAM jp CloseSRAM
; 14d2c ; 14d2c
Unknown_14d2c: ; 14d2c .Data: ; 14d2c
db $0d, $02, $00, $05, $00, $00 db $0d, $02, $00, $05, $00, $00
db $22, $02, $01, $05, $00, $00 db $22, $02, $01, $05, $00, $00
db $03, $04, $05, $08, $03, $05 db $03, $04, $05, $08, $03, $05
@ -436,6 +437,7 @@ Unknown_14d2c: ; 14d2c
db $0f, $05, $14, $07, $05, $05 db $0f, $05, $14, $07, $05, $05
db $11, $0c, $0c, $06, $06, $04 db $11, $0c, $0c, $06, $06, $04
; 14d5c ; 14d5c
.DataEnd
EraseBattleTowerStatus: ; 14d5c EraseBattleTowerStatus: ; 14d5c
ld a, BANK(sBattleTowerChallengeState) ld a, BANK(sBattleTowerChallengeState)
@ -451,6 +453,7 @@ SaveData: ; 14d68
; 14d6c ; 14d6c
Function14d6c: ; 14d6c Function14d6c: ; 14d6c
; XXX
ld a, $4 ld a, $4
call GetSRAMBank call GetSRAMBank
ld a, [$a60b] ld a, [$a60b]
@ -467,6 +470,7 @@ Function14d6c: ; 14d6c
; 14d83 ; 14d83
Function14d83: ; 14d83 Function14d83: ; 14d83
; XXX
ld a, $4 ld a, $4
call GetSRAMBank call GetSRAMBank
xor a xor a
@ -477,6 +481,7 @@ Function14d83: ; 14d83
; 14d93 ; 14d93
Function14d93: ; 14d93 Function14d93: ; 14d93
; XXX
ld a, $7 ld a, $7
call GetSRAMBank call GetSRAMBank
xor a xor a
@ -664,7 +669,7 @@ TryLoadSaveFile: ; 14ea5 (5:4ea5)
push af push af
set NO_TEXT_SCROLL, a set NO_TEXT_SCROLL, a
ld [Options], a ld [Options], a
ld hl, UnknownText_0x1529c ld hl, Text_SaveFileCorrupted
call PrintText call PrintText
pop af pop af
ld [Options], a ld [Options], a
@ -1156,49 +1161,49 @@ Checksum: ; 15273
; 15283 ; 15283
UnknownText_0x15283: ; 0x15283 Text_WouldYouLikeToSaveTheGame: ; 0x15283
; Would you like to save the game? ; Would you like to save the game?
text_jump UnknownText_0x1c454b text_jump UnknownText_0x1c454b
db "@" db "@"
; 0x15288 ; 0x15288
UnknownText_0x15288: ; 0x15288 Text_SavingDontTurnOffThePower: ; 0x15288
; SAVING… DON'T TURN OFF THE POWER. ; SAVING… DON'T TURN OFF THE POWER.
text_jump UnknownText_0x1c456d text_jump UnknownText_0x1c456d
db "@" db "@"
; 0x1528d ; 0x1528d
UnknownText_0x1528d: ; 0x1528d Text_PlayerSavedTheGame: ; 0x1528d
; saved the game. ; saved the game.
text_jump UnknownText_0x1c4590 text_jump UnknownText_0x1c4590
db "@" db "@"
; 0x15292 ; 0x15292
UnknownText_0x15292: ; 0x15292 Text_AlreadyASaveFile: ; 0x15292
; There is already a save file. Is it OK to overwrite? ; There is already a save file. Is it OK to overwrite?
text_jump UnknownText_0x1c45a3 text_jump UnknownText_0x1c45a3
db "@" db "@"
; 0x15297 ; 0x15297
UnknownText_0x15297: ; 0x15297 Text_AnotherSaveFile: ; 0x15297
; There is another save file. Is it OK to overwrite? ; There is another save file. Is it OK to overwrite?
text_jump UnknownText_0x1c45d9 text_jump UnknownText_0x1c45d9
db "@" db "@"
; 0x1529c ; 0x1529c
UnknownText_0x1529c: ; 0x1529c Text_SaveFileCorrupted: ; 0x1529c
; The save file is corrupted! ; The save file is corrupted!
text_jump UnknownText_0x1c460d text_jump UnknownText_0x1c460d
db "@" db "@"
; 0x152a1 ; 0x152a1
UnknownText_0x152a1: ; 0x152a1 Text_SaveOnBoxSwitch: ; 0x152a1
; When you change a #MON BOX, data will be saved. OK? ; When you change a #MON BOX, data will be saved. OK?
text_jump UnknownText_0x1c462a text_jump UnknownText_0x1c462a
db "@" db "@"
; 0x152a6 ; 0x152a6
UnknownText_0x152a6: ; 0x152a6 Text_SaveOnMovePkmnWOMail: ; 0x152a6
; Each time you move a #MON, data will be saved. OK? ; Each time you move a #MON, data will be saved. OK?
text_jump UnknownText_0x1c465f text_jump UnknownText_0x1c465f
db "@" db "@"

View File

@ -78,7 +78,7 @@ Serial:: ; 6ef
.player2 .player2
ld a, $1 ld a, $1
ld [hFFCA], a ld [hFFCA], a
ld a, -2 ld a, $fe
ld [hSerialSend], a ld [hSerialSend], a
.end .end
@ -126,92 +126,93 @@ Function75f:: ; 75f
; 78a ; 78a
Function78a:: ; 78a Function78a:: ; 78a
.loop
xor a xor a
ld [hFFCA], a ld [hFFCA], a
ld a, [hLinkPlayerNumber] ld a, [hLinkPlayerNumber]
cp $2 cp $2
jr nz, .asm_79b jr nz, .not_player_2
ld a, $1 ld a, $1
ld [rSC], a ld [rSC], a
ld a, $81 ld a, $81
ld [rSC], a ld [rSC], a
.not_player_2
.asm_79b .loop2
ld a, [hFFCA] ld a, [hFFCA]
and a and a
jr nz, .asm_7e5 jr nz, .reset_ffca
ld a, [hLinkPlayerNumber] ld a, [hLinkPlayerNumber]
cp $1 cp $1
jr nz, .asm_7c0 jr nz, .not_player_1_or_wcf5b_zero
call Function82b call Checkwcf5bNonzero
jr z, .asm_7c0 jr z, .not_player_1_or_wcf5b_zero
call .asm_825 call .delay_15_cycles
push hl push hl
ld hl, wcf5c ld hl, wcf5b + 1
inc [hl] inc [hl]
jr nz, .asm_7b7 jr nz, .no_rollover_up
dec hl dec hl
inc [hl] inc [hl]
.asm_7b7 .no_rollover_up
pop hl pop hl
call Function82b call Checkwcf5bNonzero
jr nz, .asm_79b jr nz, .loop2
jp Function833 jp SerialDisconnected
.asm_7c0 .not_player_1_or_wcf5b_zero
ld a, [rIE] ld a, [rIE]
and $f and $f
cp $8 cp $8
jr nz, .asm_79b jr nz, .loop2
ld a, [wcf5d] ld a, [wcf5d]
dec a dec a
ld [wcf5d], a ld [wcf5d], a
jr nz, .asm_79b jr nz, .loop2
ld a, [wcf5d + 1] ld a, [wcf5d + 1]
dec a dec a
ld [wcf5d + 1], a ld [wcf5d + 1], a
jr nz, .asm_79b jr nz, .loop2
ld a, [hLinkPlayerNumber] ld a, [hLinkPlayerNumber]
cp $1 cp $1
jr z, .asm_7e5 jr z, .reset_ffca
ld a, $ff ld a, 255
.asm_7e2 .delay_255_cycles
dec a dec a
jr nz, .asm_7e2 jr nz, .delay_255_cycles
.asm_7e5 .reset_ffca
xor a xor a
ld [hFFCA], a ld [hFFCA], a
ld a, [rIE] ld a, [rIE]
and $f and $f
sub $8 sub $8
jr nz, .asm_7f8 jr nz, .rIE_not_equal_8
ld [wcf5d], a ld [wcf5d], a
ld a, $50 ld a, $50
ld [wcf5d + 1], a ld [wcf5d + 1], a
.asm_7f8 .rIE_not_equal_8
ld a, [hSerialReceive] ld a, [hSerialReceive]
cp $fe cp $fe
ret nz ret nz
call Function82b call Checkwcf5bNonzero
jr z, .asm_813 jr z, .wcf5b_zero
push hl push hl
ld hl, wcf5c ld hl, wcf5b + 1
ld a, [hl] ld a, [hl]
dec a dec a
ld [hld], a ld [hld], a
inc a inc a
jr nz, .asm_80d jr nz, .no_rollover
dec [hl] dec [hl]
.asm_80d .no_rollover
pop hl pop hl
call Function82b call Checkwcf5bNonzero
jr z, Function833 jr z, SerialDisconnected
.asm_813 .wcf5b_zero
ld a, [rIE] ld a, [rIE]
and $f and $f
cp $8 cp $8
@ -220,17 +221,17 @@ Function78a:: ; 78a
ld a, [hl] ld a, [hl]
ld [hSerialSend], a ld [hSerialSend], a
call DelayFrame call DelayFrame
jp Function78a jp .loop
.asm_825 .delay_15_cycles
ld a, $f ld a, 15
.asm_827 .delay_cycles
dec a dec a
jr nz, .asm_827 jr nz, .delay_cycles
ret ret
; 82b ; 82b
Function82b:: ; 82b Checkwcf5bNonzero:: ; 82b
push hl push hl
ld hl, wcf5b ld hl, wcf5b
ld a, [hli] ld a, [hli]
@ -239,10 +240,10 @@ Function82b:: ; 82b
ret ret
; 833 ; 833
Function833:: ; 833 SerialDisconnected:: ; 833
dec a dec a
ld [wcf5b], a ld [wcf5b], a
ld [wcf5c], a ld [wcf5b + 1], a
ret ret
; 83b ; 83b
@ -294,18 +295,19 @@ Function87d:: ; 87d
.loop .loop
call LinkTransfer call LinkTransfer
call DelayFrame call DelayFrame
call Function82b call Checkwcf5bNonzero
jr z, .check jr z, .check
push hl push hl
ld hl, wcf5c ld hl, wcf5b + 1
dec [hl] dec [hl]
jr nz, .skip jr nz, .skip
dec hl dec hl
dec [hl] dec [hl]
jr nz, .skip jr nz, .skip
; We might be disconnected
pop hl pop hl
xor a xor a
jp Function833 jp SerialDisconnected
.skip .skip
pop hl pop hl
@ -395,6 +397,7 @@ LinkDataReceived:: ; 908
; 919 ; 919
Function919:: ; 919 Function919:: ; 919
; XXX
ld a, [wLinkMode] ld a, [wLinkMode]
and a and a
ret nz ret nz

View File

@ -5451,7 +5451,7 @@ Function102416: ; 102416
Function102423: ; 102423 Function102423: ; 102423
call Function102921 call Function102921
ret nc ret nc
callba Function14a58 callba SaveAfterLinkTrade
callba MobileFn_1060af callba MobileFn_1060af
callba BackupMobileEventIndex callba BackupMobileEventIndex
ld hl, wcd4b ld hl, wcd4b

View File

@ -7331,7 +7331,7 @@ Function11b5c0: ; 11b5c0
ld [wPokemonWithdrawDepositParameter], a ld [wPokemonWithdrawDepositParameter], a
callba RemoveMonFromPartyOrBox callba RemoveMonFromPartyOrBox
callba Function170807 callba Function170807
callba Function14a58 callba SaveAfterLinkTrade
jp Function11ad8a jp Function11ad8a
; 11b5e0 ; 11b5e0
@ -7616,7 +7616,7 @@ Function11b7e5: ; 11b7e5
callba EvolvePokemon callba EvolvePokemon
xor a xor a
ld [wLinkMode], a ld [wLinkMode], a
callba Function14a58 callba SaveAfterLinkTrade
ld a, $5 ld a, $5
call GetSRAMBank call GetSRAMBank
ld a, $5 ld a, $5
@ -7781,7 +7781,7 @@ Function11b93b: ; 11b93b
ld a, $c64b / $100 ld a, $c64b / $100
ld [wMobileMonMailPointerBuffer + 1], a ld [wMobileMonMailPointerBuffer + 1], a
call AddMobileMonToParty call AddMobileMonToParty
callba Function14a58 callba SaveAfterLinkTrade
ret ret
; 11b98f ; 11b98f

View File

@ -308,7 +308,7 @@ Function17d0f3: ; 17d0f3
callba EvolvePokemon callba EvolvePokemon
xor a xor a
ld [wLinkMode], a ld [wLinkMode], a
callba Function14a58 callba SaveAfterLinkTrade
ld a, $5 ld a, $5
call GetSRAMBank call GetSRAMBank
ld a, $5 ld a, $5
@ -3059,7 +3059,7 @@ Function17e37e: ; 17e37e
push af push af
ld a, $1 ld a, $1
ld [rSVBK], a ld [rSVBK], a
callba Function14a58 callba SaveAfterLinkTrade
pop af pop af
ld [rSVBK], a ld [rSVBK], a
ret ret

View File

@ -1268,8 +1268,7 @@ wOtherPlayerLinkMode:: ds 1
wOtherPlayerLinkAction:: ds 4 wOtherPlayerLinkAction:: ds 4
wPlayerLinkAction:: ds 1 wPlayerLinkAction:: ds 1
wcf57:: ds 4 wcf57:: ds 4
wcf5b:: ds 1 wcf5b:: dw
wcf5c:: ds 1
wcf5d:: ds 2 wcf5d:: ds 2
MonType:: ; cf5f MonType:: ; cf5f