Skip to content

Commit

Permalink
Disassemble and document Card Pop! functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroDeoxys committed Feb 22, 2021
1 parent 2119316 commit 8a7b143
Show file tree
Hide file tree
Showing 11 changed files with 1,245 additions and 34 deletions.
16 changes: 16 additions & 0 deletions src/constants/misc_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ OWMODE_MOVE EQU 1
OWMODE_START_SCRIPT EQU 2
OWMODE_SCRIPT EQU 3

; max number of player names that
; can be written to sCardPopNameList
CARDPOP_NAME_LIST_MAX_ELEMS EQU 16
CARDPOP_NAME_LIST_SIZE EQUS "CARDPOP_NAME_LIST_MAX_ELEMS * NAME_BUFFER_LENGTH"

; commands transmitted through IR to be
; executed by the other device
; (see ExecuteReceivedIRCommands)
const_def
const IRCMD_CLOSE ; $0
const IRCMD_RETURN_WO_CLOSING ; $1
const IRCMD_TRANSMIT_DATA ; $2
const IRCMD_RECEIVE_DATA ; $3
const IRCMD_CALL_FUNCTION ; $4
NUM_IR_COMMANDS EQU const_value

NULL EQU $0000

FALSE EQU 0
Expand Down
5 changes: 3 additions & 2 deletions src/engine/bank01.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8493,8 +8493,9 @@ Func_74dc: ; 74dc (1:74dc)

INCROM $7528, $7571

Func_7571: ; 7571 (1:7571)
farcall Func_19c20
; handles all the Card Pop! functionality
DoCardPop: ; 7571 (1:7571)
farcall _DoCardPop
ret

Func_7576: ; 7576 (1:7576)
Expand Down
60 changes: 56 additions & 4 deletions src/engine/bank04.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1089,7 +1089,31 @@ Func_11238: ; 11238 (4:5238)
INCROM $11238, $1124d

Func_1124d: ; 1124d (4:524d)
INCROM $1124d, $11320
INCROM $1124d, $1127f

; writes in de total num of cards collected
; and in (de + 1) total num of cards to collect
; also updates wTotalNumCardsCollected and wTotalNumCardsToCollect
UpdateAlbumProgress: ; 1127f (4:527f)
push hl
push de
push de
call GetCardAlbumProgress
call EnableSRAM
pop hl
ld a, d
ld [wTotalNumCardsCollected], a
ld [hli], a
ld a, e
ld [wTotalNumCardsToCollect], a
ld [hl], a
call DisableSRAM
pop de
pop hl
ret
; 0x11299

INCROM $11299, $11320

Func_11320: ; 11320 (4:5320)
INCROM $11320, $11343
Expand Down Expand Up @@ -1246,8 +1270,36 @@ _SaveGame: ; 1157c (4:557c)
call Func_11238
ret

Func_115a3: ; 115a3 (4:55a3)
INCROM $115a3, $1162a
_AddCardToCollectionAndUpdateAlbumProgress: ; 115a3 (4:55a3)
ld [wCardToAddToCollection], a
push hl
push bc
push de
ldh a, [hBankSRAM]
push af
ld a, BANK(sAlbumProgress)
call BankswitchSRAM
ld a, [wCardToAddToCollection]
call AddCardToCollection
ld de, sAlbumProgress
call UpdateAlbumProgress
pop af
call BankswitchSRAM
call DisableSRAM ; unnecessary

; unintentional? runs the same write operation
; on the same address but on the current SRAM bank
ld a, [wCardToAddToCollection]
call AddCardToCollection
ld de, $b8fe
call UpdateAlbumProgress
pop de
pop bc
pop hl
ret
; 0x115d4

INCROM $115d4, $1162a

INCLUDE "data/map_scripts.asm"

Expand Down Expand Up @@ -2825,7 +2877,7 @@ MainMenu_ContinueFromDiary: ; 12741 (4:6741)
MainMenu_CardPop: ; 12768 (4:6768)
ld a, MUSIC_CARD_POP
call PlaySong
bank1call Func_7571
bank1call DoCardPop
farcall WhiteOutDMGPals
call DoFrameIfLCDEnabled
ld a, MUSIC_STOP
Expand Down
Loading

0 comments on commit 8a7b143

Please sign in to comment.