summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElectroDeoxys <ElectroDeoxys@gmail.com>2021-06-05 16:15:31 +0100
committerElectroDeoxys <ElectroDeoxys@gmail.com>2021-06-05 16:15:31 +0100
commita69683c9fb19c90d38d356229a9245ae45bf4ab8 (patch)
tree33a1878709aee3e094ec695b81a959e5fcf2bee3
parent63f0559573cbec5a199645263a36b51b503d4ed1 (diff)
Finish Bank 6
-rw-r--r--src/constants/misc_constants.asm7
-rw-r--r--src/constants/npc_constants.asm1
-rw-r--r--src/constants/printer_constants.asm24
-rw-r--r--src/engine/bank01.asm85
-rw-r--r--src/engine/bank02.asm33
-rw-r--r--src/engine/bank06.asm1146
-rw-r--r--src/engine/home.asm40
-rw-r--r--src/sram.asm7
-rw-r--r--src/text/text1.asm2
-rw-r--r--src/text/text2.asm28
-rw-r--r--src/text/text_offsets.asm30
-rw-r--r--src/wram.asm82
12 files changed, 1244 insertions, 241 deletions
diff --git a/src/constants/misc_constants.asm b/src/constants/misc_constants.asm
index 8649881..033ce71 100644
--- a/src/constants/misc_constants.asm
+++ b/src/constants/misc_constants.asm
@@ -66,6 +66,13 @@ CARDPOP_NAME_LIST_SIZE EQUS "CARDPOP_NAME_LIST_MAX_ELEMS * NAME_BUFFER_LENGTH"
const IRCMD_CALL_FUNCTION ; $4
NUM_IR_COMMANDS EQU const_value
+; parameters for IR communication
+; (see InitIRCommunications)
+ const_def 1
+ const IRPARAM_CARD_POP ; $1
+ const IRPARAM_SEND_CARDS ; $2
+ const IRPARAM_SEND_DECK ; $3
+
NULL EQU $0000
FALSE EQU 0
diff --git a/src/constants/npc_constants.asm b/src/constants/npc_constants.asm
index 1aac946..8743548 100644
--- a/src/constants/npc_constants.asm
+++ b/src/constants/npc_constants.asm
@@ -75,6 +75,7 @@ NPC_DATA_LENGTH EQU const_value
const JESSICA_PIC ; $27
const STEPHANIE_PIC ; $28
const AARON_PIC ; $29
+ const LINK_OPP_PIC ; $29
const_def 1
const NPC_DRMASON ; $01
diff --git a/src/constants/printer_constants.asm b/src/constants/printer_constants.asm
index ed6b663..e65eb1b 100644
--- a/src/constants/printer_constants.asm
+++ b/src/constants/printer_constants.asm
@@ -1,9 +1,17 @@
; wPrinterStatus
- const_def 1
- const PRINTER_STATUS_CHECKING
- const PRINTER_STATUS_TRANSMITTING
- const PRINTER_STATUS_PRINTING
- const PRINTER_ERROR_1
- const PRINTER_ERROR_PAPER_JAMMED
- const PRINTER_ERROR_CABLE_PRINTER_SWITCH
- const PRINTER_ERROR_BATTERIES_LOST_CHARGE
+ const_def
+ const PRINTER_ERROR_CHECKSUM ; $0
+ const PRINTER_STATUS_BUSY ; $1
+ const PRINTER_STATUS_IMAGE_FULL ; $2
+ const PRINTER_STATUS_PRINTING ; $3
+ const PRINTER_ERROR_INVALID_PACKET ; $4
+ const PRINTER_ERROR_PAPER_JAMMED ; $5
+ const PRINTER_ERROR_CABLE_PRINTER_SWITCH ; $6
+ const PRINTER_ERROR_BATTERIES_LOST_CHARGE ; $7
+
+; printer packet types
+PRINTERPKT_INIT EQU $01
+PRINTERPKT_PRINT_INSTRUCTION EQU $02
+PRINTERPKT_DATA EQU $04
+PRINTERPKT_BREAK EQU $08
+PRINTERPKT_NUL EQU $0f
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index 358aabf..508f103 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -85,7 +85,7 @@ HandleFailedToContinueDuel: ; 4097 (1:4097)
; this function begins the duel after the opponent's graphics, name and deck have been introduced
; loads both player's decks and sets up the variables and resources required to begin a duel.
-StartDuel: ; 409f (1:409f)
+StartDuel_VSAIOpp: ; 409f (1:409f)
ld a, PLAYER_TURN
ldh [hWhoseTurn], a
ld a, DUELIST_TYPE_PLAYER
@@ -96,9 +96,9 @@ StartDuel: ; 409f (1:409f)
call SwapTurn
call LoadOpponentDeck
call SwapTurn
- jr .decks_loaded
+ jr StartDuel
-; unreferenced?
+StartDuel_VSLinkOpp: ; 40bc (1:40bc)
ld a, MUSIC_DUEL_THEME_1
ld [wDuelTheme], a
ld hl, wOpponentName
@@ -106,8 +106,9 @@ StartDuel: ; 409f (1:409f)
ld [hli], a
ld [hl], a
ld [wIsPracticeDuel], a
+; fallthrough
-.decks_loaded
+StartDuel: ; 40ca (1:40ca)
ld hl, sp+$0
ld a, l
ld [wDuelReturnAddress], a
@@ -8447,12 +8448,12 @@ Func_74dc: ; 74dc (1:74dc)
call EmptyScreen
call EnableLCD
ld a, GRASS_ENERGY
- ld [wce9a], a
+ ld [wPrizeCardSelectionFrameCounter], a
.wait_input
call DoFrame
ldh a, [hDPadHeld]
ld b, a
- ld a, [wce9a]
+ ld a, [wPrizeCardSelectionFrameCounter]
; left
bit D_LEFT_F, b
jr z, .right
@@ -8471,13 +8472,13 @@ Func_74dc: ; 74dc (1:74dc)
sub 10
.got_card_id
- ld [wce9a], a
+ ld [wPrizeCardSelectionFrameCounter], a
lb bc, 5, 5
bank1call WriteTwoByteNumberInTxSymbolFormat
ldh a, [hKeysPressed]
and START
jr z, .wait_input
- ld a, [wce9a]
+ ld a, [wPrizeCardSelectionFrameCounter]
ld e, a
ld d, $0
.asm_751b
@@ -8491,25 +8492,59 @@ Func_74dc: ; 74dc (1:74dc)
jr .asm_751b
; 0x7528
- INCROM $7528, $755d
+; seems to communicate with other device
+; for starting a duel
+; outputs in hl either wPlayerDuelVariables
+; or wOpponentDuelVariables depending on wSerialOp
+DecideLinkDuelVariables: ; 7528 (1:7528)
+ call Func_0e8e
+ ldtx hl, PressStartWhenReadyText
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+.loop_frame
+ call DoFrame
+ ldh a, [hKeysPressed]
+ bit B_BUTTON_F, a
+ jr nz, .cancel
+ and START
+ call Func_cc5
+ jr nc, .loop_frame
+ ld hl, wPlayerDuelVariables
+ ld a, [wSerialOp]
+ cp $29
+ jr z, .success
+ ld hl, wOpponentDuelVariables
+ cp $12
+ jr z, .success
+.cancel
+ call ResetSerial
+ scf
+ ret
+
+.success
+ or a
+ ret
+; 0x755c
+
+ ret ; stray ret
-Func_755d: ; 755d (1:755d)
- farcall Func_19bfb
+ReceiveDeckConfiguration: ; 755d (1:755d)
+ farcall _ReceiveDeckConfiguration
ret
; 0x7562
-Func_7562: ; 7562 (1:7562)
- farcall Func_19bc5
+SendDeckConfiguration: ; 7562 (1:7562)
+ farcall _SendDeckConfiguration
ret
; 0x7567
-Func_7567: ; 7567 (1:7567)
- farcall Func_19b8c
+ReceiveCard: ; 7567 (1:7567)
+ farcall _ReceiveCard
ret
; 0x756c
-Func_756c: ; 756c (1:756c)
- farcall Func_19b41
+SendCard: ; 756c (1:756c)
+ farcall _SendCard
ret
; 0x7571
@@ -8523,18 +8558,18 @@ Func_7576: ; 7576 (1:7576)
ret
; 0x757b
-Func_757b: ; 757b (1:757b)
- farcall Func_19e42
+PreparePrinterConnection: ; 757b (1:757b)
+ farcall _PreparePrinterConnection
ret
; 0x7580
-Func_7580: ; 7580 (1:7580)
- farcall Func_1a162
+PrintDeckConfiguration: ; 7580 (1:7580)
+ farcall _PrintDeckConfiguration
ret
; 0x7585
-Func_7585: ; 7585 (1:7585)
- farcall Func_1a270
+PrintCardList: ; 7585 (1:7585)
+ farcall _PrintCardList
ret
; 0x758a
@@ -8543,8 +8578,8 @@ Func_758a: ; 758a (1:758a)
ret
; 0x758f
-Func_758f: ; 758f (1:758f)
- farcall Func_1a4cf
+SetUpAndStartLinkDuel: ; 758f (1:758f)
+ farcall _SetUpAndStartLinkDuel
ret
Func_7594: ; 7594 (1:7594)
diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm
index 9afbaed..9994dac 100644
--- a/src/engine/bank02.asm
+++ b/src/engine/bank02.asm
@@ -2238,7 +2238,7 @@ Func_8cf9: ; 8cf9 (2:4cf9)
ld hl, sHasPromotionalCards
ld [hli], a
inc a ; $1
- ld [hli], a
+ ld [hli], a ; sb704
ld [hli], a
ld [hl], a
ld [sUnnamedDeckCounter], a
@@ -3659,8 +3659,8 @@ CheckIfCurrentDeckWasChanged: ; 95c1 (2:55c1)
; loops through cards in wCurDeckCards
; then if that card is found in wCurDeckCardChanges
; overwrite it by $0
- ld a, $ff
- ld [wc5cc], a
+ ld a, $ff ; terminator byte
+ ld [wCurDeckCardChanges + DECK_SIZE], a
ld de, wCurDeckCards
.loop_outer
ld a, [de]
@@ -6050,15 +6050,14 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201)
jp OpenDeckConfigurationMenu.skip_init
.func_table
- dw ConfirmDeckConfiguration ; Confirm
- dw SendDeckConfiguration ; Send
- dw CancelSendDeckConfiguration ; Cancel
-; 0xa24a
+ dw ConfirmDeckConfiguration ; Confirm
+ dw .SendDeckConfiguration ; Send
+ dw .CancelSendDeckConfiguration ; Cancel
-SendDeckConfiguration: ; a24a (2:624a)
+.SendDeckConfiguration
ld a, [wCurDeckCards]
or a
- jr z, CancelSendDeckConfiguration
+ jr z, .CancelSendDeckConfiguration
xor a
ld [wCardListVisibleOffset], a
ld hl, Data_b04a
@@ -6079,7 +6078,7 @@ SendDeckConfiguration: ; a24a (2:624a)
scf
ret
-CancelSendDeckConfiguration: ; a27d (2:627d)
+.CancelSendDeckConfiguration
add sp, $2
or a
ret
@@ -7791,12 +7790,12 @@ PrinterMenu_CardList: ; ad0e (2:6d0e)
ld a, [hffb3]
or a
ret nz
- bank1call Func_7585
+ bank1call PrintCardList
ret
; 0xad51
HandlePrinterMenu: ; ad51 (2:6d51)
- bank1call Func_757b
+ bank1call PreparePrinterConnection
ret c
xor a
.loop
@@ -8097,7 +8096,7 @@ Func_af1d: ; af1d (2:6f1d)
call CopyListFromHLToDE
xor a
ld [wNameBuffer], a
- bank1call Func_756c
+ bank1call SendCard
ret c
call EnableSRAM
ld hl, wCurDeckCards
@@ -8119,7 +8118,7 @@ Func_af98: ; af98 (2:6f98)
xor a
ld [wDuelTempList], a
ld [wNameBuffer], a
- bank1call Func_7567
+ bank1call ReceiveCard
ret c
call EnableSRAM
@@ -9791,7 +9790,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991)
ld [wCurDeckCards + DECK_SIZE], a
call SortCurDeckCardsByID
ld a, [wSelectedDeckMachineEntry]
- bank1call Func_7580
+ bank1call PrintDeckConfiguration
call ClearScreenAndDrawDeckMachineScreen
.no
@@ -10131,7 +10130,7 @@ Func_bc04: ; bc04 (2:7c04)
xor a
ld [wNameBuffer], a
- bank1call Func_7562
+ bank1call SendDeckConfiguration
ret c
call GetSelectedSavedDeckPtr
@@ -10191,7 +10190,7 @@ Func_bc7a: ; bc7a (2:7c7a)
xor a
ld [wDuelTempList], a
ld [wNameBuffer], a
- bank1call Func_755d
+ bank1call ReceiveDeckConfiguration
ret c
call EnableSRAM
ld hl, wDuelTempList
diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm
index d0c928c..fc0117e 100644
--- a/src/engine/bank06.asm
+++ b/src/engine/bank06.asm
@@ -1655,7 +1655,7 @@ ReceiveNBytesToHLThroughIR: ; 1977d (6:577d)
; disables interrupts, and sets joypad and IR communication port
; switches to CGB normal speed
-InitiateIRCommunications: ; 19792 (6:5792)
+StartIRCommunications: ; 19792 (6:5792)
di
call SwitchToCGBNormalSpeed
ld a, P14
@@ -1695,7 +1695,7 @@ ClearRP: ; 197b8 (6:57b8)
; in wIRDataBuffer + 1, then calls the subroutine
; corresponding to that command
ExecuteReceivedIRCommands: ; 197bd (6:57bd)
- call InitiateIRCommunications
+ call StartIRCommunications
.loop_commands
call ReceiveIRDataBuffer
jr c, .error
@@ -1778,11 +1778,12 @@ ExecuteReceivedIRCommands: ; 197bd (6:57bd)
ret
; 0x1981d
-Func_1981d: ; 1981d (6:581d)
- call InitiateIRCommunications
+; returns carry set if request sent was not acknowledged
+TrySendIRRequest: ; 1981d (6:581d)
+ call StartIRCommunications
ld hl, rRP
ld c, 4
-.asm_19825
+.send_request
ld a, $aa ; request
push bc
call TransmitByteThroughIR
@@ -1791,38 +1792,41 @@ Func_1981d: ; 1981d (6:581d)
call ReceiveByteThroughIR_ZeroIfUnsuccessful
pop bc
cp $33 ; acknowledgement
- jr z, .asm_1983b
+ jr z, .received_ack
dec c
- jr nz, .asm_19825
+ jr nz, .send_request
scf
- jr .asm_1983c
-.asm_1983b
+ jr .close
+
+.received_ack
xor a
-.asm_1983c
+.close
push af
call CloseIRCommunications
pop af
ret
; 0x19842
-Func_19842: ; 19842 (6:5842)
- call InitiateIRCommunications
+; returns carry set if request was not received
+TryReceiveIRRequest: ; 19842 (6:5842)
+ call StartIRCommunications
ld hl, rRP
-.asm_19848
+.wait_request
call ReceiveByteThroughIR_ZeroIfUnsuccessful
cp $aa ; request
- jr z, .asm_19859
+ jr z, .send_ack
ldh a, [rJOYP]
cpl
and P10 | P11
- jr z, .asm_19848
+ jr z, .wait_request
scf
- jr .asm_1985f
-.asm_19859
+ jr .close
+
+.send_ack
ld a, $33 ; acknowledgement
call TransmitByteThroughIR
xor a
-.asm_1985f
+.close
push af
call CloseIRCommunications
pop af
@@ -1831,7 +1835,7 @@ Func_19842: ; 19842 (6:5842)
; sends request for other device to close current communication
RequestCloseIRCommunication: ; 19865 (6:5865)
- call InitiateIRCommunications
+ call StartIRCommunications
ld a, IRCMD_CLOSE
ld [wIRDataBuffer + 1], a
call TransmitIRDataBuffer
@@ -1890,7 +1894,7 @@ TransmitRegistersThroughIR: ; 198a3 (6:58a3)
push de
push bc
call StoreRegistersInIRDataBuffer
- call InitiateIRCommunications
+ call StartIRCommunications
call TransmitIRDataBuffer
pop bc
pop de
@@ -1973,7 +1977,8 @@ Func_198e7: ; 198e7 (6:58e7)
ret
; 0x19907
-Func_19907: ; 19907 (6:5907)
+; sets backup VBlank function as wVBlankFunctionTrampoline
+RestoreVBlankFunction: ; 19907 (6:5907)
ld hl, wVBlankFunctionTrampolineBackup
ld de, wVBlankFunctionTrampoline + 1
call BackupVBlankFunctionTrampoline
@@ -2153,11 +2158,49 @@ Func_19a12: ; 19a12 (6:5a12)
ret
; 0x19a1f
- INCROM $19a1f, $19a55
+; hl = text ID
+LoadLinkConnectingScene: ; 19a1f (6:5a1f)
+ push hl
+ call Func_198e7
+ ld a, SCENE_GAMEBOY_LINK_CONNECTING
+ lb bc, 0, 0
+ call LoadScene
+ pop hl
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+ ret
+; 0x19a33
-; prepares data for Card Pop! communications
-InitializeCardPopCommunications: ; 19a55 (6:5a55)
- ld hl, wc5eb
+; shows Link Not Connected scene
+; then asks the player whether they want to try again
+; if the player selectes "no", return carry
+; input:
+; - hl = text ID
+LoadLinkNotConnectedSceneAndAskWhetherToTryAgain: ; 19a33 (6:5a33)
+ push hl
+ call RestoreVBlankFunction
+ call Func_198e7
+ ld a, SCENE_GAMEBOY_LINK_NOT_CONNECTED
+ lb bc, 0, 0
+ call LoadScene
+ pop hl
+ call DrawWideTextBox_WaitForInput
+ ldtx hl, WouldYouLikeToTryAgainText
+ call YesOrNoMenuWithText_SetCursorToYes
+; fallthrough
+
+ClearRPAndRestoreVBlankFunction: ; 19a4c (6:5a4c)
+ push af
+ call ClearRP
+ call RestoreVBlankFunction
+ pop af
+ ret
+; 0x19a55
+
+; prepares IR communication parameter data
+; a = a IRPARAM_* constant for the function of this connection
+InitIRCommunications: ; 19a55 (6:5a55)
+ ld hl, wOwnIRCommunicationParams
ld [hl], a
inc hl
ld [hl], $50
@@ -2166,7 +2209,7 @@ InitializeCardPopCommunications: ; 19a55 (6:5a55)
inc hl
ld [hl], $31
ld a, $ff
- ld [wc5ea], a
+ ld [wIRCommunicationErrorCode], a
ld a, PLAYER_TURN
ldh [hWhoseTurn], a
; clear wNameBuffer and wOpponentName
@@ -2191,25 +2234,66 @@ InitializeCardPopCommunications: ; 19a55 (6:5a55)
ret
; 0x19a89
- INCROM $19a89, $19ab7
+; returns carry if communication was unsuccessful
+; if a = 0, then it was a communication error
+; if a = 1, then operation was cancelled by the player
+PrepareSendCardOrDeckConfigurationThroughIR: ; 19a89 (6:5a89)
+ call InitIRCommunications
-Func_19ab7: ; 19ab7 (6:5ab7)
- ld hl, wc5eb
- ld de, wc5ef
+; pressing A button triggers request for IR communication
+.loop_frame
+ call DoFrame
+ ldh a, [hKeysPressed]
+ bit B_BUTTON_F, a
+ jr nz, .b_btn
+ ldh a, [hKeysHeld]
+ bit A_BUTTON_F, a
+ jr z, .loop_frame
+; a btn
+ call TrySendIRRequest
+ jr nc, .request_success
+ or a
+ jr z, .loop_frame
+ xor a
+ scf
+ ret
+
+.b_btn
+ ; cancelled by the player
+ ld a, $01
+ scf
+ ret
+
+.request_success
+ call ExchangeIRCommunicationParameters
+ ret c
+ ld a, [wOtherIRCommunicationParams + 3]
+ cp $31
+ jr nz, SetIRCommunicationErrorCode_Error
+ or a
+ ret
+; 0x19ab7
+
+; exchanges player names and IR communication parameters
+; checks whether parameters for communication match
+; and if they don't, an error is issued
+ExchangeIRCommunicationParameters: ; 19ab7 (6:5ab7)
+ ld hl, wOwnIRCommunicationParams
+ ld de, wOtherIRCommunicationParams
ld c, 4
call RequestDataTransmissionThroughIR
jr c, .error
- ld hl, wc5ef + 1
+ ld hl, wOtherIRCommunicationParams + 1
ld a, [hli]
cp $50
jr nz, .error
ld a, [hli]
cp $4b
jr nz, .error
- ld a, [wc5eb]
- ld hl, wc5ef
- cp [hl]
- jr nz, .asm_19af9
+ ld a, [wOwnIRCommunicationParams]
+ ld hl, wOtherIRCommunicationParams
+ cp [hl] ; do parameters match?
+ jr nz, SetIRCommunicationErrorCode_Error
; receives wDefaultText from other device
; and writes it to wNameBuffer
@@ -2232,11 +2316,12 @@ Func_19ab7: ; 19ab7 (6:5ab7)
xor a
scf
ret
+; 0x19af9
-.asm_19af9
- ld hl, wc5ea
+SetIRCommunicationErrorCode_Error: ; 19af9 (6:5af9)
+ ld hl, wIRCommunicationErrorCode
ld [hl], $01
- ld de, wc5ea
+ ld de, wIRCommunicationErrorCode
ld c, 1
call RequestDataReceivalThroughIR
call RequestCloseIRCommunication
@@ -2245,10 +2330,10 @@ Func_19ab7: ; 19ab7 (6:5ab7)
ret
; 0x19b0d
-Func_19b0d: ; 19b0d (6:5b0d)
- ld hl, wc5eb
+SetIRCommunicationErrorCode_NoError: ; 19b0d (6:5b0d)
+ ld hl, wOwnIRCommunicationParams
ld [hl], $00
- ld de, wc5ea
+ ld de, wIRCommunicationErrorCode
ld c, 1
call RequestDataReceivalThroughIR
ret c
@@ -2257,19 +2342,158 @@ Func_19b0d: ; 19b0d (6:5b0d)
ret
; 0x19b20
- INCROM $19b20, $19b41
+; makes device receptive to receive data from other device
+; to write in wDuelTempList (either list of cards or a deck configuration)
+; returns carry if some error occured
+TryReceiveCardOrDeckConfigurationThroughIR: ; 19b20 (6:5b20)
+ call InitIRCommunications
+.loop_receive_request
+ xor a
+ ld [wDuelTempList], a
+ call TryReceiveIRRequest
+ jr nc, .receive_data
+ bit 1, a
+ jr nz, .cancelled
+ jr .loop_receive_request
+.receive_data
+ call ExecuteReceivedIRCommands
+ ld a, [wIRCommunicationErrorCode]
+ or a
+ ret z ; no error
+ xor a
+ scf
+ ret
-Func_19b41: ; 19b41 (6:5b41)
- INCROM $19b41, $19b8c
+.cancelled
+ ld a, $01
+ scf
+ ret
+; 0x19b41
-Func_19b8c: ; 19b8c (6:5b8c)
- INCROM $19b8c, $19bc5
+; returns carry if card(s) wasn't successfully sent
+_SendCard: ; 19b41 (6:5b41)
+ call StopMusic
+ ldtx hl, SendingACardText
+ call LoadLinkConnectingScene
+ ld a, IRPARAM_SEND_CARDS
+ call PrepareSendCardOrDeckConfigurationThroughIR
+ jr c, .fail
-Func_19bc5: ; 19bc5 (6:5bc5)
- INCROM $19bc5, $19bfb
+ ; send cards
+ xor a
+ ld [wDuelTempList + DECK_SIZE], a
+ ld hl, wDuelTempList
+ ld e, l
+ ld d, h
+ ld c, DECK_SIZE + 1
+ call RequestDataReceivalThroughIR
+ jr c, .fail
+ call SetIRCommunicationErrorCode_NoError
+ jr c, .fail
+ call ExecuteReceivedIRCommands
+ jr c, .fail
+ ld a, [wOwnIRCommunicationParams + 1]
+ cp $4f
+ jr nz, .fail
+ call PlayCardPopSong
+ xor a
+ call ClearRPAndRestoreVBlankFunction
+ ret
+
+.fail
+ call PlayCardPopSong
+ ldtx hl, CardTransferWasntSuccessful1Text
+ call LoadLinkNotConnectedSceneAndAskWhetherToTryAgain
+ jr nc, _SendCard ; loop back and try again
+ ; failed
+ scf
+ ret
+; 0x19b87
+
+PlayCardPopSong: ; 19b87 (6:5b87)
+ ld a, MUSIC_CARD_POP
+ jp PlaySong
+; 0x19b8c
+
+_ReceiveCard: ; 19b8c (6:5b8c)
+ call StopMusic
+ ldtx hl, ReceivingACardText
+ call LoadLinkConnectingScene
+ ld a, IRPARAM_SEND_CARDS
+ call TryReceiveCardOrDeckConfigurationThroughIR
+ ld a, $4f
+ ld [wOwnIRCommunicationParams + 1], a
+ ld hl, wOwnIRCommunicationParams
+ ld e, l
+ ld d, h
+ ld c, 4
+ call RequestDataReceivalThroughIR
+ jr c, .fail
+ call RequestCloseIRCommunication
+ jr c, .fail
+ call PlayCardPopSong
+ or a
+ call ClearRPAndRestoreVBlankFunction
+ ret
+
+.fail
+ call PlayCardPopSong
+ ldtx hl, CardTransferWasntSuccessful2Text
+ call LoadLinkNotConnectedSceneAndAskWhetherToTryAgain
+ jr nc, _ReceiveCard
+ scf
+ ret
+; 0x19bc5
+
+_SendDeckConfiguration: ; 19bc5 (6:5bc5)
+ call StopMusic
+ ldtx hl, SendingADeckConfigurationText
+ call LoadLinkConnectingScene
+ ld a, IRPARAM_SEND_DECK
+ call PrepareSendCardOrDeckConfigurationThroughIR
+ jr c, .fail
+ ld hl, wDuelTempList
+ ld e, l
+ ld d, h
+ ld c, DECK_STRUCT_SIZE
+ call RequestDataReceivalThroughIR
+ jr c, .fail
+ call SetIRCommunicationErrorCode_NoError
+ jr c, .fail
+ call PlayCardPopSong
+ call ClearRPAndRestoreVBlankFunction
+ or a
+ ret
+
+.fail
+ call PlayCardPopSong
+ ldtx hl, DeckConfigurationTransferWasntSuccessful1Text
+ call LoadLinkNotConnectedSceneAndAskWhetherToTryAgain
+ jr nc, _SendDeckConfiguration
+ scf
+ ret
+; 0x19bfb
-Func_19bfb: ; 19bfb (6:5bfb)
- INCROM $19bfb, $19c20
+_ReceiveDeckConfiguration: ; 19bfb (6:5bfb)
+ call StopMusic
+ ldtx hl, ReceivingDeckConfigurationText
+ call LoadLinkConnectingScene
+ ld a, IRPARAM_SEND_DECK
+ call TryReceiveCardOrDeckConfigurationThroughIR
+ jr c, .fail
+ call PlayCardPopSong
+ call ClearRPAndRestoreVBlankFunction
+ or a
+ ret
+
+.fail
+ call PlayCardPopSong
+ ldtx hl, DeckConfigurationTransferWasntSuccessful2Text
+ call LoadLinkNotConnectedSceneAndAskWhetherToTryAgain
+ jr nc, _ReceiveDeckConfiguration ; loop back and try again
+ scf
+ ret
+; 0x19c20
_DoCardPop: ; 19c20 (6:5c20)
; loads scene for Card Pop! screen
@@ -2281,7 +2505,7 @@ _DoCardPop: ; 19c20 (6:5c20)
call LoadScene
ldtx hl, AreYouBothReadyToCardPopText
call PrintScrollableText_NoTextBoxLabel
- call Func_19907
+ call RestoreVBlankFunction
ldtx hl, CardPopCannotBePlayedWithTheGameBoyText
ld a, [wConsole]
cp CONSOLE_SGB
@@ -2300,7 +2524,7 @@ _DoCardPop: ; 19c20 (6:5c20)
push af
push hl
call ClearRP
- call Func_19907
+ call RestoreVBlankFunction
pop hl
pop af
jr c, .error
@@ -2343,7 +2567,7 @@ _DoCardPop: ; 19c20 (6:5c20)
call LoadScene
pop hl
call PrintScrollableText_NoTextBoxLabel
- call Func_19907
+ call RestoreVBlankFunction
ret
; 0x19cb2
@@ -2359,18 +2583,18 @@ HandleCardPopCommunications: ; 19cb2 (6:5cb2)
call CopyDataHLtoDE
call DisableSRAM
- ld a, $01
- call InitializeCardPopCommunications
+ ld a, IRPARAM_CARD_POP
+ call InitIRCommunications
.asm_19cc9
- call Func_19842 ; send request
+ call TryReceiveIRRequest ; receive request
jr nc, .asm_19d05
bit 1, a
jr nz, .fail
- call Func_1981d ; receive request
+ call TrySendIRRequest ; send request
jr c, .asm_19cc9
; do the player name search, then transmit the result
- call Func_19ab7
+ call ExchangeIRCommunicationParameters
jr c, .fail
ld hl, wCardPopNameList
ld de, wOtherPlayerCardPopNameList
@@ -2383,7 +2607,7 @@ HandleCardPopCommunications: ; 19cb2 (6:5cb2)
ld c, 1
call RequestDataReceivalThroughIR
jr c, .fail
- call Func_19b0d
+ call SetIRCommunicationErrorCode_NoError
jr c, .fail
call ExecuteReceivedIRCommands
jr c, .fail
@@ -2391,7 +2615,7 @@ HandleCardPopCommunications: ; 19cb2 (6:5cb2)
.asm_19d05
call ExecuteReceivedIRCommands
- ld a, [wc5ea]
+ ld a, [wIRCommunicationErrorCode]
or a
jr nz, .fail
call RequestCloseIRCommunication
@@ -2677,8 +2901,25 @@ CalculateNameHash: ; 19e32 (6:5e32)
ret
; 0x19e42
-Func_19e42: ; 19e42 (6:5e42)
- INCROM $19e42, $19e5a
+; sends serial data to printer
+; if there's an error in connection,
+; show Printer Not Connected scene with error message
+_PreparePrinterConnection: ; 19e42 (6:5e42)
+ ld bc, $0
+ lb de, PRINTERPKT_DATA, $0
+ call SendPrinterPacket
+ ret nc ; return if no error
+
+ ld hl, wPrinterStatus
+ ld a, [hl]
+ or a
+ jr nz, .asm_19e55
+ ld [hl], $ff
+.asm_19e55
+ ld a, [hl]
+ cp $ff
+ jr z, ShowPrinterIsNotConnected
+; falltrough
; shows message on screen depending on wPrinterStatus
; also shows SCENE_GAMEBOY_PRINTER_NOT_CONNECTED.
@@ -2697,28 +2938,33 @@ HandlePrinterError: ; 19e5a (6:5e5a)
ldtx hl, PrinterPacketErrorText
ld a, $04
- jr .got_text
+ jr ShowPrinterConnectionErrorScene
.cable_or_printer_switch
ldtx hl, CheckCableOrPrinterSwitchText
ld a, $02
- jr .got_text
+ jr ShowPrinterConnectionErrorScene
.jammed_printer
ldtx hl, PrinterPaperIsJammedText
ld a, $03
- jr .got_text
+ jr ShowPrinterConnectionErrorScene
.batteries_lost_charge
ldtx hl, BatteriesHaveLostTheirChargeText
ld a, $01
- jr .got_text
+ jr ShowPrinterConnectionErrorScene
.interrupted
ldtx hl, PrintingWasInterruptedText
call DrawWideTextBox_WaitForInput
scf
ret
+ShowPrinterIsNotConnected: ; 19e94 (6:5e94)
ldtx hl, PrinterIsNotConnectedText
ld a, $02
-.got_text
+; fallthrough
+
+; a = error code
+; hl = text ID to print in text box
+ShowPrinterConnectionErrorScene: ; 19e99 (6:5e99)
push hl
; unnecessary loading TxRam, since the text data
; already incorporate the error number
@@ -2732,7 +2978,7 @@ HandlePrinterError: ; 19e5a (6:5e5a)
call LoadScene
pop hl
call DrawWideTextBox_WaitForInput
- call Func_19907
+ call RestoreVBlankFunction
scf
ret
; 0x19eb4
@@ -2754,7 +3000,7 @@ Func_19eb4: ; 19eb4 (6:5eb4)
ldtx hl, NowPrintingText
call DrawWideTextBox_PrintText
call EnableLCD
- call Func_1a035
+ call PrepareForPrinterCommunications
call DrawTopCardInfoInSRAMGfxBuffer0
call Func_19f87
call DrawCardPicInSRAMGfxBuffer2
@@ -2763,13 +3009,13 @@ Func_19eb4: ; 19eb4 (6:5eb4)
call DrawBottomCardInfoInSRAMGfxBuffer0
call Func_1a011
jr c, .error
- call Func_19907
- call Func_1a06b
+ call RestoreVBlankFunction
+ call ResetPrinterCommunicationSettings
or a
ret
.error
- call Func_19907
- call Func_1a06b
+ call RestoreVBlankFunction
+ call ResetPrinterCommunicationSettings
jp HandlePrinterError
; 0x19f05
@@ -2847,7 +3093,7 @@ DrawTopCardInfoInSRAMGfxBuffer0: ; 19f20 (6:5f20)
; 0x19f87
Func_19f87: ; 19f87 (6:5f87)
- call Func_1a089
+ call TryInitPrinterCommunications
ret c
ld hl, sGfxBuffer0
call Func_1a0cc
@@ -2858,7 +3104,7 @@ Func_19f87: ; 19f87 (6:5f87)
; 0x19f99
Func_19f99: ; 19f99 (6:5f99)
- call Func_1a089
+ call TryInitPrinterCommunications
ret c
ld hl, sGfxBuffer0 + $8 tiles
ld c, $06
@@ -2927,7 +3173,7 @@ RetreatWeakResistData: ; 1a004 (6:6004)
; 0x1a011
Func_1a011: ; 1a011 (6:6011)
- call Func_1a089
+ call TryInitPrinterCommunications
ret c
ld hl, sGfxBuffer0
ld c, $05
@@ -2954,21 +3200,23 @@ Func_1a025: ; 1a025 (6:6025)
; switches to CGB normal speed, resets serial
; enables SRAM and switches to SRAM1
; and clears sGfxBuffer0
-Func_1a035: ; 1a035 (6:6035)
+PrepareForPrinterCommunications: ; 1a035 (6:6035)
call SwitchToCGBNormalSpeed
call ResetSerial
ld a, $10
ld [wce9b], a
call EnableSRAM
ld a, [sPrinterContrastLevel]
- ld [wce99], a
+ ld [wPrinterContrastLevel], a
call DisableSRAM
ldh a, [hBankSRAM]
ld [wce8f], a
ld a, BANK("SRAM1")
call BankswitchSRAM
call EnableSRAM
- ; clear sGfxBuffer0
+; fallthrough
+
+ClearPrinterGfxBuffer: ; 1a035 (6:6035)
ld hl, sGfxBuffer0
ld bc, $400
.loop
@@ -2983,7 +3231,8 @@ Func_1a035: ; 1a035 (6:6035)
ret
; 0x1a06b
-Func_1a06b: ; 1a06b (6:606b)
+; reverts settings changed by PrepareForPrinterCommunications
+ResetPrinterCommunicationSettings: ; 1a06b (6:606b)
push af
call SwitchToCGBDoubleSpeed
ld a, [wce8f]
@@ -2995,31 +3244,39 @@ Func_1a06b: ; 1a06b (6:606b)
ret
; 0x1a080
- INCROM $1a080, $1a089
+; unreferenced
+; send some bytes through serial
+Func_1a080: ; 1a080 (6:6080)
+ ld bc, $0
+ lb de, PRINTERPKT_NUL, $0
+ jp SendPrinterPacket
+; 0x1a089
+; tries initiating the communications for
+; sending data to printer
; returns carry if operation was cancelled
-; or serial transfer took long
-Func_1a089: ; 1a089 (6:6089)
+; by pressing B button or serial transfer took long
+TryInitPrinterCommunications: ; 1a089 (6:6089)
xor a
- ld [wce9e], a
+ ld [wPrinterInitAttempts], a
.wait_input
call DoFrame
ldh a, [hKeysHeld]
and B_BUTTON
jr nz, .b_button
ld bc, $0
- ld de, $f00
- call Func_312d
+ lb de, PRINTERPKT_NUL, $0
+ call SendPrinterPacket
jr c, .delay
- and $0a
+ and (1 << PRINTER_STATUS_BUSY) | (1 << PRINTER_STATUS_PRINTING)
jr nz, .wait_input
-.asm_1a0a5
+.init
ld bc, $0
- ld de, $100
- call Func_312d
+ lb de, PRINTERPKT_INIT, $0
+ call SendPrinterPacket
jr nc, .no_carry
- ld hl, wce9e
+ ld hl, wPrinterInitAttempts
inc [hl]
ld a, [hl]
cp 3
@@ -3042,7 +3299,7 @@ Func_1a089: ; 1a089 (6:6089)
call DoFrame
dec c
jr nz, .delay_loop
- jr .asm_1a0a5
+ jr .init
; 0x1a0cc
; loads tiles given by map in hl to sGfxBuffer5
@@ -3054,8 +3311,8 @@ Func_1a0cc: ; 1a0cc (6:60cc)
call .Copy20Tiles
call .Copy20Tiles
push hl
- call CompressDataForSerialTransfer
- call Func_312d
+ call CompressDataForPrinterSerialTransfer
+ call SendPrinterPacket
pop hl
pop bc
ret
@@ -3101,13 +3358,13 @@ Func_1a0cc: ; 1a0cc (6:60cc)
; 0x1a108
Func_1a108: ; 1a108 (6:6108)
- call Func_1a138
+ call GetPrinterContrastSerialData
push hl
- ld hl, $301
- jr Func_1a11e
+ lb hl, $3, $1
+ jr SendPrinterInstructionPacket
Func_1a111: ; 1a111 (6:6111)
- call Func_1a138
+ call GetPrinterContrastSerialData
push hl
ld hl, wce9b
ld a, [hl]
@@ -3116,42 +3373,515 @@ Func_1a111: ; 1a111 (6:6111)
ld l, $01
; fallthrough
-Func_1a11e: ; 1a11e (6:611e)
+SendPrinterInstructionPacket: ; 1a11e (6:611e)
push hl
ld bc, $0
- ld de, $400
- call Func_312d
+ lb de, PRINTERPKT_DATA, $0
+ call SendPrinterPacket
jr c, .asm_1a135
- ld hl, sp+$00
- ld bc, $4
- ld de, $200
- call Func_312d
+ ld hl, sp+$00 ; contrast level bytes
+ ld bc, $4 ; instruction packets are 4 bytes in size
+ lb de, PRINTERPKT_PRINT_INSTRUCTION, $0
+ call SendPrinterPacket
.asm_1a135
pop hl
pop hl
ret
-Func_1a138: ; 1a138 (6:6138)
- ld a, [wce99]
+; returns in h and l the bytes
+; to be sent through serial to the printer
+; for the set contrast level
+GetPrinterContrastSerialData: ; 1a138 (6:6138)
+ ld a, [wPrinterContrastLevel]
ld e, a
ld d, $00
- ld hl, .unknown_1a146
+ ld hl, .contrast_level_data
add hl, de
ld h, [hl]
ld l, $e4
ret
-.unknown_1a146
+.contrast_level_data
db $00, $20, $40, $60, $7f
; 0x1a14b
- INCROM $1a14b, $1a162
+; unreferenced
+Func_1a14b: ; 1a14b (6:614b)
+ ld a, $01
+ jr .asm_1a15d
+ ld a, $02
+ jr .asm_1a15d
+ ld a, $03
+ jr .asm_1a15d
+ ld a, $04
+ jr .asm_1a15d
+ ld a, $05
+.asm_1a15d
+ ld [wce9d], a
+ scf
+ ret
+; 0x1a162
+
+; a = saved deck index to print
+_PrintDeckConfiguration: ; 1a162 (6:6162)
+; copies selected deck from SRAM to wDuelTempList
+ call EnableSRAM
+ ld l, a
+ ld h, DECK_STRUCT_SIZE
+ call HtimesL
+ ld de, sSavedDeck1
+ add hl, de
+ ld de, wDuelTempList
+ ld bc, DECK_STRUCT_SIZE
+ call CopyDataHLtoDE
+ call DisableSRAM
+
+ call ShowPrinterTransmitting
+ call PrepareForPrinterCommunications
+ call Func_1a025
+ call Func_212f
+ lb de, 0, 64
+ lb bc, 20, 4
+ call DrawRegularTextBoxDMG
+ lb de, 4, 66
+ call InitTextPrinting
+ ld hl, wDuelTempList ; print deck name
+ call ProcessText
+ ldtx hl, DeckPrinterText
+ call ProcessTextFromID
+
+ ld a, 5
+ ld [wPrinterHorizontalOffset], a
+ ld hl, wPrinterTotalCardCount
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ld [wPrintOnlyStarRarity], a
+
+ ld hl, wCurDeckCards
+.loop_cards
+ ld a, [hl]
+ or a
+ jr z, .asm_1a1d6
+ ld e, a
+ ld d, $00
+ call LoadCardDataToBuffer1_FromCardID
+
+ ; find out this card's count
+ ld a, [hli]
+ ld b, a
+ ld c, 1
+.loop_card_count
+ cp [hl]
+ jr nz, .got_card_count
+ inc hl
+ inc c
+ jr .loop_card_count
+
+.got_card_count
+ ld a, c
+ ld [wPrinterCardCount], a
+ call LoadCardInfoForPrinter
+ call AddToPrinterGfxBuffer
+ jr c, .printer_error
+ jr .loop_cards
+
+.asm_1a1d6
+ call SendCardListToPrinter
+ jr c, .printer_error
+ call ResetPrinterCommunicationSettings
+ call RestoreVBlankFunction
+ or a
+ ret
+
+.printer_error
+ call ResetPrinterCommunicationSettings
+ call RestoreVBlankFunction
+ jp HandlePrinterError
+; 0x1a1ec
+
+SendCardListToPrinter: ; 1a1ec (6:61ec)
+ ld a, [wPrinterHorizontalOffset]
+ cp 1
+ jr z, .skip_load_gfx
+ call LoadGfxBufferForPrinter
+ ret c
+.skip_load_gfx
+ call TryInitPrinterCommunications
+ ret c
+ call Func_1a108
+ ret
+; 0z1a1ff
+
+; increases printer horizontal offset by 2
+AddToPrinterGfxBuffer: ; 1a1ff (6:61ff)
+ push hl
+ ld hl, wPrinterHorizontalOffset
+ inc [hl]
+ inc [hl]
+ ld a, [hl]
+ pop hl
+ ; return no carry if below 18
+ cp 18
+ ccf
+ ret nc
+ ; >= 18
+; fallthrough
+
+; copies Gfx to Gfx buffer and sends some serial data
+; returns carry set if unsuccessful
+LoadGfxBufferForPrinter: ; 1a20b (6:620b)
+ push hl
+ call TryInitPrinterCommunications
+ jr c, .set_carry
+ ld a, [wPrinterHorizontalOffset]
+ srl a
+ ld c, a
+ ld hl, sGfxBuffer0
+.loop_gfx_buffer
+ call Func_1a0cc
+ jr c, .set_carry
+ dec c
+ jr nz, .loop_gfx_buffer
+ call Func_1a111
+ jr c, .set_carry
+
+ call ClearPrinterGfxBuffer
+ ld a, 1
+ ld [wPrinterHorizontalOffset], a
+ pop hl
+ or a
+ ret
+
+.set_carry
+ pop hl
+ scf
+ ret
+
+; load symbol, name, level and card count to buffer
+LoadCardInfoForPrinter: ; 1a235 (6:6235)
+ push hl
+ ld a, [wPrinterHorizontalOffset]
+ or %1000000
+ ld e, a
+ ld d, 3
+ ld a, [wPrintOnlyStarRarity]
+ or a
+ jr nz, .skip_card_symbol
+ ld hl, wPrinterTotalCardCount
+ ld a, [hli]
+ or [hl]
+ call z, DrawCardSymbol
+.skip_card_symbol
+ ld a, 14
+ call CopyCardNameAndLevel
+ call InitTextPrinting
+ ld hl, wDefaultText
+ call ProcessText
+ ld a, [wPrinterHorizontalOffset]
+ or %1000000
+ ld c, a
+ ld b, 16
+ ld a, SYM_CROSS
+ call WriteByteToBGMap0
+ inc b
+ ld a, [wPrinterCardCount]
+ bank1call WriteTwoDigitNumberInTxSymbolFormat
+ pop hl
+ ret
+; 0x1a270
+
+_PrintCardList: ; 1a270 (6:6270)
+; if Select button is held when printing card list
+; only print cards with Star rarity (excluding Promotional cards)
+; even if it's not marked as seen in the collection
+ ld e, FALSE
+ ldh a, [hKeysHeld]
+ and SELECT
+ jr z, .no_select
+ inc e ; TRUE
+.no_select
+ ld a, e
+ ld [wPrintOnlyStarRarity], a
+
+ call ShowPrinterTransmitting
+ call CreateTempCardCollection
+ ld de, wDefaultText
+ call CopyPlayerName
+ call PrepareForPrinterCommunications
+ call Func_1a025
+ call Func_212f
+
+ lb de, 0, 64
+ lb bc, 20, 4
+ call DrawRegularTextBoxDMG
+ ld a, PLAYER_TURN
+ ldh [hWhoseTurn], a
+ lb de, 2, 66
+ call InitTextPrinting
+ ld hl, wDefaultText
+ call ProcessText
+ ldtx hl, AllCardsOwnedText
+ call ProcessTextFromID
+ ld a, [wPrintOnlyStarRarity]
+ or a
+ jr z, .asm_1a2c2
+ ld a, TX_HALF2FULL
+ call ProcessSpecialTextCharacter
+ lb de, 3, 84
+ call Func_22ca
+.asm_1a2c2
+ ld a, $ff
+ ld [wCurPrinterCardType], a
+ xor a
+ ld hl, wPrinterTotalCardCount
+ ld [hli], a
+ ld [hl], a
+ ld [wPrinterNumCardTypes], a
+ ld a, 5
+ ld [wPrinterHorizontalOffset], a
+
+ ld e, GRASS_ENERGY
+.loop_cards
+ push de
+ ld d, $00
+ call LoadCardDataToBuffer1_FromCardID
+ jr c, .done_card_loop
+ ld d, HIGH(wTempCardCollection)
+ ld a, [de] ; card ID count in collection
+ ld [wPrinterCardCount], a
+ call .LoadCardTypeEntry
+ jr c, .printer_error_pop_de
+
+ ld a, [wPrintOnlyStarRarity]
+ or a
+ jr z, .all_owned_cards_mode
+ ld a, [wLoadedCard1Set]
+ and %11110000
+ cp PROMOTIONAL
+ jr z, .next_card
+ ld a, [wLoadedCard1Rarity]
+ cp STAR
+ jr nz, .next_card
+ ; not Promotional, and Star rarity
+ ld hl, wPrinterCardCount
+ res CARD_NOT_OWNED_F, [hl]
+ jr .got_card_count
+
+.all_owned_cards_mode
+ ld a, [wPrinterCardCount]
+ or a
+ jr z, .next_card
+ cp CARD_NOT_OWNED
+ jr z, .next_card ; ignore not owned cards
+
+.got_card_count
+ ld a, [wPrinterCardCount]
+ and CARD_COUNT_MASK
+ ld c, a
+
+ ; add to total card count
+ ld hl, wPrinterTotalCardCount
+ add [hl]
+ ld [hli], a
+ ld a, 0
+ adc [hl]
+ ld [hl], a
+
+ ; add to current card type count
+ ld hl, wPrinterCurCardTypeCount
+ ld a, c
+ add [hl]
+ ld [hli], a
+ ld a, 0
+ adc [hl]
+ ld [hl], a
+
+ ld hl, wPrinterNumCardTypes
+ inc [hl]
+ ld hl, wce98
+ inc [hl]
+ call LoadCardInfoForPrinter
+ call AddToPrinterGfxBuffer
+ jr c, .printer_error_pop_de
+.next_card
+ pop de
+ inc e
+ jr .loop_cards
+
+.printer_error_pop_de
+ pop de
+.printer_error
+ call ResetPrinterCommunicationSettings
+ call RestoreVBlankFunction
+ jp HandlePrinterError
+
+.done_card_loop
+ pop de
+ ; add separator line
+ ld a, [wPrinterHorizontalOffset]
+ dec a
+ or $40
+ ld c, a
+ ld b, 0
+ call BCCoordToBGMap0Address
+ ld a, $35
+ lb de, $35, $35
+ ld b, 20
+ call CopyLine
+ call AddToPrinterGfxBuffer
+ jr c, .printer_error
+
+ ld hl, wPrinterTotalCardCount
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+ ldtx hl, TotalNumberOfCardsText
+ call .PrintTextWithNumber
+ jr c, .printer_error
+ ld a, [wPrintOnlyStarRarity]
+ or a
+ jr nz, .done
+ ld a, [wPrinterNumCardTypes]
+ ld c, a
+ ld b, 0
+ ldtx hl, TypesOfCardsText
+ call .PrintTextWithNumber
+ jr c, .printer_error
+
+.done
+ call SendCardListToPrinter
+ jr c, .printer_error
+ call ResetPrinterCommunicationSettings
+ call RestoreVBlankFunction
+ or a
+ ret
+
+; prints text ID given in hl
+; with decimal representation of
+; the number given in bc
+; hl = text ID
+; bc = number
+.PrintTextWithNumber
+ push bc
+ ld a, [wPrinterHorizontalOffset]
+ dec a
+ or $40
+ ld e, a
+ ld d, 2
+ call InitTextPrinting
+ call ProcessTextFromID
+ ld d, 14
+ call InitTextPrinting
+ pop hl
+ call TwoByteNumberToTxSymbol_TrimLeadingZeros
+ ld hl, wStringBuffer
+ call ProcessText
+ call AddToPrinterGfxBuffer
+ ret
+
+; load's this card's type icon and text
+; if it's a new card type that hasn't been printed yet
+.LoadCardTypeEntry
+ ld a, [wLoadedCard1Type]
+ ld c, a
+ cp TYPE_ENERGY
+ jr c, .got_type ; jump if Pokemon card
+ ld c, $08
+ cp TYPE_TRAINER
+ jr nc, .got_type ; jump if Trainer card
+ ld c, $07
+.got_type
+ ld hl, wCurPrinterCardType
+ ld a, [hl]
+ cp c
+ ret z ; already handled this card type
+
+ ; show corresponding icon and text
+ ; for this new card type
+ ld a, c
+ ld [hl], a ; set it as current card type
+ add a
+ add c ; *3
+ ld c, a
+ ld b, $00
+ ld hl, .IconTextList
+ add hl, bc
+ ld a, [wPrinterHorizontalOffset]
+ dec a
+ or %1000000
+ ld e, a
+ ld d, 1
+ ld a, [hli]
+ push hl
+ lb bc, 2, 2
+ lb hl, 1, 2
+ call FillRectangle
+ pop hl
+ ld d, 3
+ inc e
+ call InitTextPrinting
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call ProcessTextFromID
+
+ call AddToPrinterGfxBuffer
+ ld hl, wPrinterCurCardTypeCount
+ xor a
+ ld [hli], a
+ ld [hl], a
+ ld [wce98], a
+ ret
+
+.IconTextList
+ ; Fire
+ db $e0 ; icon tile
+ tx FirePokemonText
+
+ ; Grass
+ db $e4 ; icon tile
+ tx GrassPokemonText
+
+ ; Lightning
+ db $e8 ; icon tile
+ tx LightningPokemonText
+
+ ; Water
+ db $ec ; icon tile
+ tx WaterPokemonText
+
+ ; Fighting
+ db $f0 ; icon tile
+ tx FightingPokemonText
+
+ ; Psychic
+ db $f4 ; icon tile
+ tx PsychicPokemonText
+
+ ; Colorless
+ db $f8 ; icon tile
+ tx ColorlessPokemonText
-Func_1a162: ; 1a162 (6:6162)
- INCROM $1a162, $1a270
+ ; Energy
+ db $fc ; icon tile
+ tx EnergyCardText
-Func_1a270: ; 1a270 (6:6270)
- INCROM $1a270, $1a435
+ ; Trainer
+ db $dc ; icon tile
+ tx TrainerCardText
+; 0x1a420
+
+ShowPrinterTransmitting: ; 1a420 (6:6420)
+ call Func_198e7
+ ld a, SCENE_GAMEBOY_PRINTER_TRANSMITTING
+ lb bc, 0, 0
+ call LoadScene
+ ldtx hl, NowPrintingPleaseWaitText
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+ ret
+; 0x1a435
; compresses $28 tiles in sGfxBuffer5
; and writes it in sGfxBuffer5 + $28 tiles.
@@ -3161,8 +3891,8 @@ Func_1a270: ; 1a270 (6:6270)
; - a command byte with bit 7 set, means to copy the following byte
; that many times + 2 (after masking the top bit of command byte).
; returns in bc the size of the compressed data and
-; in de the address of where it starts.
-CompressDataForSerialTransfer: ; 1a435 (6:6435)
+; in de the packet type data.
+CompressDataForPrinterSerialTransfer: ; 1a435 (6:6435)
ld hl, sGfxBuffer5
ld de, sGfxBuffer5 + $28 tiles
ld bc, $28 tiles
@@ -3226,7 +3956,7 @@ CompressDataForSerialTransfer: ; 1a435 (6:6435)
ld c, l
ld b, h
ld hl, sGfxBuffer5 + $28 tiles
- ld de, $401
+ lb de, PRINTERPKT_DATA, $1
ret
; 0x1a485
@@ -3321,8 +4051,186 @@ CheckDataCompression: ; 1a485 (6:6485)
jr .no_carry
; 0x1a4cf
-Func_1a4cf: ; 1a4cf (6:64cf)
- INCROM $1a4cf, $1a61f
+; sets up to start a link duel
+; decides which device will pick the number of prizes
+; then exchanges names and duels between the players
+; and starts the main duel routine
+_SetUpAndStartLinkDuel: ; 1a4cf (6:64cf)
+ ld hl, sp+$00
+ ld a, l
+ ld [wDuelReturnAddress + 0], a
+ ld a, h
+ ld [wDuelReturnAddress + 1], a
+ call Func_198e7
+
+ ld a, SCENE_GAMEBOY_LINK_TRANSMITTING
+ lb bc, 0, 0
+ call LoadScene
+
+ bank1call LoadPlayerDeck
+ call SwitchToCGBNormalSpeed
+ bank1call DecideLinkDuelVariables
+ push af
+ call RestoreVBlankFunction
+ pop af
+ jp c, .error
+
+ ld a, DUELIST_TYPE_PLAYER
+ ld [wPlayerDuelistType], a
+ ld a, DUELIST_TYPE_LINK_OPP
+ ld [wOpponentDuelistType], a
+ ld a, DUELTYPE_LINK
+ ld [wDuelType], a
+
+ call EmptyScreen
+ ld a, [wSerialOp]
+ cp $29
+ jr nz, .asm_1a540
+
+ ld a, PLAYER_TURN
+ ldh [hWhoseTurn], a
+ call .ExchangeNamesAndDecks
+ jr c, .error
+ lb de, 6, 2
+ lb bc, 8, 6
+ call DrawRegularTextBox
+ lb de, 7, 4
+ call InitTextPrinting
+ ldtx hl, PrizesCardsText
+ call ProcessTextFromID
+ ldtx hl, ChooseTheNumberOfPrizesText
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+ call .PickNumberOfPrizeCards
+ ld a, [wNPCDuelPrizes]
+ call SerialSend8Bytes
+ jr .prizes_decided
+
+.asm_1a540
+ ld a, OPPONENT_TURN
+ ldh [hWhoseTurn], a
+ call .ExchangeNamesAndDecks
+ jr c, .error
+ ldtx hl, PleaseWaitDecidingNumberOfPrizesText
+ call DrawWideTextBox_PrintText
+ call EnableLCD
+ call SerialRecv8Bytes
+ ld [wNPCDuelPrizes], a
+
+.prizes_decided
+ call ExchangeRNG
+ ld a, LINK_OPP_PIC
+ ld [wOpponentPortrait], a
+ ldh a, [hWhoseTurn]
+ push af
+ call EmptyScreen
+ bank1call SetDefaultPalettes
+ ld a, SHUFFLE_DECK
+ ld [wDuelDisplayedScreen], a
+ bank1call DrawDuelistPortraitsAndNames
+ ld a, OPPONENT_TURN
+ ldh [hWhoseTurn], a
+ ld a, [wNPCDuelPrizes]
+ ld l, a
+ ld h, $00
+ call LoadTxRam3
+ ldtx hl, BeginAPrizeDuelWithText
+ call DrawWideTextBox_WaitForInput
+ pop af
+ ldh [hWhoseTurn], a
+ call ExchangeRNG
+ bank1call StartDuel_VSLinkOpp
+ call SwitchToCGBDoubleSpeed
+ ret
+
+.error
+ ld a, -1
+ ld [wDuelResult], a
+ call Func_198e7
+
+ ld a, SCENE_GAMEBOY_LINK_NOT_CONNECTED
+ lb bc, 0, 0
+ call LoadScene
+
+ ldtx hl, TransmissionErrorText
+ call DrawWideTextBox_WaitForInput
+ call RestoreVBlankFunction
+ call ResetSerial
+ ret
+
+.ExchangeNamesAndDecks
+ ld de, wDefaultText
+ push de
+ call CopyPlayerName
+ pop hl
+ ld de, wNameBuffer
+ ld c, NAME_BUFFER_LENGTH
+ call SerialExchangeBytes
+ ret c
+ xor a
+ ld hl, wOpponentName
+ ld [hli], a
+ ld [hl], a
+ ld hl, wPlayerDeck
+ ld de, wOpponentDeck
+ ld c, DECK_SIZE
+ call SerialExchangeBytes
+ ret
+
+; handles player choice of number of prize cards
+; pressing left/right makes it decrease/increase respectively
+; selection is confirmed by pressing A button
+.PickNumberOfPrizeCards
+ ld a, PRIZES_4
+ ld [wNPCDuelPrizes], a
+ xor a
+ ld [wPrizeCardSelectionFrameCounter], a
+.loop_input
+ call DoFrame
+ ld a, [wNPCDuelPrizes]
+ add SYM_0
+ ld e, a
+ ; check frame counter so that it
+ ; either blinks or shows number
+ ld hl, wPrizeCardSelectionFrameCounter
+ ld a, [hl]
+ inc [hl]
+ and $10
+ jr z, .no_blink
+ ld e, SYM_SPACE
+.no_blink
+ ld a, e
+ lb bc, 9, 6
+ call WriteByteToBGMap0
+
+ ldh a, [hDPadHeld]
+ ld b, a
+ ld a, [wNPCDuelPrizes]
+ bit D_LEFT_F, b
+ jr z, .check_d_right
+ dec a
+ cp PRIZES_2
+ jr nc, .got_prize_count
+ ld a, PRIZES_6 ; wrap around to 6
+ jr .got_prize_count
+
+.check_d_right
+ bit D_RIGHT_F, b
+ jr z, .check_a_btn
+ inc a
+ cp PRIZES_6 + 1
+ jr c, .got_prize_count
+ ld a, PRIZES_2
+.got_prize_count
+ ld [wNPCDuelPrizes], a
+ xor a
+ ld [wPrizeCardSelectionFrameCounter], a
+
+.check_a_btn
+ bit A_BUTTON_F, b
+ jr z, .loop_input
+ ret
+; 0x1a61f
Func_1a61f: ; 1a61f (6:661f)
push af
diff --git a/src/engine/home.asm b/src/engine/home.asm
index 6935e0b..cdf9588 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -9349,13 +9349,16 @@ DrawPlayAreaToPlacePrizeCards: ; 311d (0:311d)
ret
; serial transfer-related
-Func_312d: ; 312d (0:312d)
+SendPrinterPacket: ; 312d (0:312d)
push hl
ld hl, wce64
+ ; Preamble
ld a, $88
ld [hli], a ; [wce64] ← $88
ld a, $33
ld [hli], a ; [wce65] ← $33
+
+ ; Header
ld [hl], d ; [wce66] ← d
inc hl
ld [hl], e ; [wce67] ← e
@@ -9364,8 +9367,9 @@ Func_312d: ; 312d (0:312d)
inc hl
ld [hl], b ; [wce69] ← b
inc hl
+
pop de
- ld [hl], e ; [wce6a] ← l
+ ld [hl], e ; [wPrinterPacketDataPtr] ← l
inc hl
ld [hl], d ; [wce6b] ← h
inc hl
@@ -9373,10 +9377,10 @@ Func_312d: ; 312d (0:312d)
ld [hl], e ; [wce6c] ← $45
inc hl
ld [hl], d ; [wce6d] ← $ff
- ld hl, wce70
- ld [hl], $64 ; [wce70] ← $64
+ ld hl, wSerialDataPtr
+ ld [hl], LOW(wce64) ; [wSerialDataPtr] ← $64
inc hl
- ld [hl], $ce ; [wce71] ← $ce
+ ld [hl], HIGH(wce64) ; [wSerialDataPtr] ← $ce
call Func_0e8e
ld a, $1
ld [wce63], a ; [wce63] ← 1
@@ -9387,12 +9391,14 @@ Func_312d: ; 312d (0:312d)
or a
jr nz, .asm_315d
call ResetSerial
- ld bc, $05dc
+
+ ld bc, 1500
.asm_316c
dec bc
ld a, b
or c
jr nz, .asm_316c
+
ld a, [wce6e]
cp $81
jr nz, .asm_3182
@@ -9403,6 +9409,7 @@ Func_312d: ; 312d (0:312d)
ret z
scf
ret
+
.asm_3182
ld a, $ff
ld [wPrinterStatus], a
@@ -9440,17 +9447,19 @@ Func_31b0: ; 31b0 (0:31b0)
ld hl, wce68
ld a, [hli]
or [hl]
- jr nz, .asm_31bf
+ jr nz, .set_data_ptr
call Func_31ab
jr Func_31dd
-.asm_31bf
- ld hl, wce6a
- ld de, wce70
+
+.set_data_ptr
+ ld hl, wPrinterPacketDataPtr
+ ld de, wSerialDataPtr
ld a, [hli]
ld [de], a
inc de
ld a, [hl]
ld [de], a
+; fallthrough
Func_31ca: ; 31ca (0:31ca)
call Func_31fc
@@ -9493,7 +9502,7 @@ Func_31f2: ; 31f2 (0:31f2)
ret
Func_31fc: ; 31fc (0:31fc)
- ld hl, wce70
+ ld hl, wSerialDataPtr
ld e, [hl]
inc hl
ld d, [hl]
@@ -9503,6 +9512,7 @@ Func_31fc: ; 31fc (0:31fc)
dec hl
ld [hl], e
ld e, a
+
ld hl, wce6c
add [hl]
ld [hli], a
@@ -10480,8 +10490,8 @@ SetupSound: ; 377f (0:377f)
farcall _SetupSound
ret
-Func_3784: ; 3784 (0:3784)
- xor a
+StopMusic: ; 3784 (0:3784)
+ xor a ; MUSIC_STOP
PlaySong: ; 3785 (0:3785)
farcall _PlaySong
ret
@@ -10685,7 +10695,7 @@ GameEvent_BattleCenter: ; 38a3 (0:38a3)
ld [wDuelTheme], a
ld a, MUSIC_CARD_POP
call PlaySong
- bank1call Func_758f
+ bank1call SetUpAndStartLinkDuel
scf
ret
@@ -10699,7 +10709,7 @@ GameEvent_Duel: ; 38c0 (0:38c0)
ld [sba44], a
call DisableSRAM
call SaveGeneralSaveData
- bank1call StartDuel
+ bank1call StartDuel_VSAIOpp
scf
ret
diff --git a/src/sram.asm b/src/sram.asm
index 5d01ef5..a9b5f4b 100644
--- a/src/sram.asm
+++ b/src/sram.asm
@@ -128,7 +128,12 @@ sUnnamedDeckCounter:: ; b701
; to decide whether to show the option
; in the Card Album PC menu
sHasPromotionalCards:: ; b703
- ds $4
+ ds $1
+
+; these are initialized to 1 when
+; creating a new game but are never used
+sb704:: ; b704
+ ds $3
sCardAndDeckSaveDataEnd::
ds $f9
diff --git a/src/text/text1.asm b/src/text/text1.asm
index 2b683d8..26ddc2c 100644
--- a/src/text/text1.asm
+++ b/src/text/text1.asm
@@ -126,7 +126,7 @@ EnergyCardText: ; 36453 (d:6453)
text "Energy Card"
done
-Text0021: ; 36460 (d:6460)
+DeckPrinterText: ; 36460 (d:6460)
text "Deck"
done
diff --git a/src/text/text2.asm b/src/text/text2.asm
index 8901f4e..c06bc51 100644
--- a/src/text/text2.asm
+++ b/src/text/text2.asm
@@ -764,22 +764,22 @@ Text0185: ; 39ca8 (e:5ca8)
text "Battle Center"
done
-Text0186: ; 39cb7 (e:5cb7)
+PrizesCardsText: ; 39cb7 (e:5cb7)
text "Prizes"
line " cards"
done
-Text0187: ; 39ccc (e:5ccc)
+ChooseTheNumberOfPrizesText: ; 39ccc (e:5ccc)
text "Choose the number"
line "of Prizes."
done
-Text0188: ; 39cea (e:5cea)
+PleaseWaitDecidingNumberOfPrizesText: ; 39cea (e:5cea)
text "Please wait..."
line "Deciding the number of Prizes..."
done
-Text0189: ; 39d1b (e:5d1b)
+BeginAPrizeDuelWithText: ; 39d1b (e:5d1b)
text "Begin a <RAMNUM>-Prize Duel"
line "with <RAMNAME>."
done
@@ -839,7 +839,7 @@ Text0194: ; 39ed3 (e:5ed3)
line "Looked at the card list!"
done
-Text0195: ; 39f03 (e:5f03)
+NowPrintingPleaseWaitText: ; 39f03 (e:5f03)
text "Now printing."
line "Please wait..."
done
@@ -848,7 +848,7 @@ BoosterPackText: ; 39f21 (e:5f21)
text "Booster Pack"
done
-Text0197: ; 39f2f (e:5f2f)
+WouldYouLikeToTryAgainText: ; 39f2f (e:5f2f)
text "Would you like to try again?"
done
@@ -860,40 +860,40 @@ Text0199: ; 39f59 (e:5f59)
text "Received from <RAMNAME>."
done
-Text019a: ; 39f6b (e:5f6b)
+SendingACardText: ; 39f6b (e:5f6b)
text "Sending a card...Move the Game"
line "Boys close and press the A Button."
done
-Text019b: ; 39fae (e:5fae)
+ReceivingACardText: ; 39fae (e:5fae)
text "Receiving a card...Move"
line "the Game Boys close together."
done
-Text019c: ; 39fe5 (e:5fe5)
+SendingADeckConfigurationText: ; 39fe5 (e:5fe5)
text "Sending a Deck Configuration..."
line "Position the Game Boys and press A."
done
-Text019d: ; 3a02a (e:602a)
+ReceivingDeckConfigurationText: ; 3a02a (e:602a)
text "Receiving Deck configuration..."
line "Position the Game Boys and press A."
done
-Text019e: ; 3a06f (e:606f)
+CardTransferWasntSuccessful1Text: ; 3a06f (e:606f)
text "Card transfer wasn't successful."
done
-Text019f: ; 3a091 (e:6091)
+CardTransferWasntSuccessful2Text: ; 3a091 (e:6091)
text "Card transfer wasn't successful"
done
-Text01a0: ; 3a0b2 (e:60b2)
+DeckConfigurationTransferWasntSuccessful1Text: ; 3a0b2 (e:60b2)
text "Deck configuration transfer"
line "wasn't successful"
done
-Text01a1: ; 3a0e1 (e:60e1)
+DeckConfigurationTransferWasntSuccessful2Text: ; 3a0e1 (e:60e1)
text "Deck configuration transfer"
line "wasn't successful."
done
diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm
index 7040fc8..69984c7 100644
--- a/src/text/text_offsets.asm
+++ b/src/text/text_offsets.asm
@@ -34,7 +34,7 @@ TextOffsets:: ; 34000 (d:4000)
textpointer ColorlessPokemonText ; 0x001e
textpointer TrainerCardText ; 0x001f
textpointer EnergyCardText ; 0x0020
- textpointer Text0021 ; 0x0021
+ textpointer DeckPrinterText ; 0x0021
textpointer Text0022 ; 0x0022
textpointer NoPokemonOnTheBenchText ; 0x0023
textpointer UnableDueToSleepText ; 0x0024
@@ -391,10 +391,10 @@ TextOffsets:: ; 34000 (d:4000)
textpointer ThereWasNoEffectFromPoisonConfusionText ; 0x0183
textpointer ExchangedCardsInDuelistsHandText ; 0x0184
textpointer Text0185 ; 0x0185
- textpointer Text0186 ; 0x0186
- textpointer Text0187 ; 0x0187
- textpointer Text0188 ; 0x0188
- textpointer Text0189 ; 0x0189
+ textpointer PrizesCardsText ; 0x0186
+ textpointer ChooseTheNumberOfPrizesText ; 0x0187
+ textpointer PleaseWaitDecidingNumberOfPrizesText ; 0x0188
+ textpointer BeginAPrizeDuelWithText ; 0x0189
textpointer AreYouBothReadyToCardPopText ; 0x018a
textpointer ThePopWasntSuccessfulText ; 0x018b
textpointer CannotCardPopWithFriendPreviouslyPoppedWithText ; 0x018c
@@ -406,19 +406,19 @@ TextOffsets:: ; 34000 (d:4000)
textpointer ReceivedPromotionalFlyingPikachuText ; 0x0192
textpointer ReceivedPromotionalSurfingPikachuText ; 0x0193
textpointer Text0194 ; 0x0194
- textpointer Text0195 ; 0x0195
+ textpointer NowPrintingPleaseWaitText ; 0x0195
textpointer BoosterPackText ; 0x0196
- textpointer Text0197 ; 0x0197
+ textpointer WouldYouLikeToTryAgainText ; 0x0197
textpointer Text0198 ; 0x0198
textpointer Text0199 ; 0x0199
- textpointer Text019a ; 0x019a
- textpointer Text019b ; 0x019b
- textpointer Text019c ; 0x019c
- textpointer Text019d ; 0x019d
- textpointer Text019e ; 0x019e
- textpointer Text019f ; 0x019f
- textpointer Text01a0 ; 0x01a0
- textpointer Text01a1 ; 0x01a1
+ textpointer SendingACardText ; 0x019a
+ textpointer ReceivingACardText ; 0x019b
+ textpointer SendingADeckConfigurationText ; 0x019c
+ textpointer ReceivingDeckConfigurationText ; 0x019d
+ textpointer CardTransferWasntSuccessful1Text ; 0x019e
+ textpointer CardTransferWasntSuccessful2Text ; 0x019f
+ textpointer DeckConfigurationTransferWasntSuccessful1Text ; 0x01a0
+ textpointer DeckConfigurationTransferWasntSuccessful2Text ; 0x01a1
textpointer NowPrintingText ; 0x01a2
textpointer DrMasonText ; 0x01a3
textpointer DrawSevenCardsPracticeDuelText ; 0x01a4
diff --git a/src/wram.asm b/src/wram.asm
index fd18f8a..f417c83 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -462,24 +462,24 @@ NEXTU
; wCurDeckCards was changed from the original
; deck it was based on
wCurDeckCardChanges:: ; c590
- ds DECK_SIZE
+ ds DECK_SIZE + 1
ENDU
-wc5cc:: ; c5cc
- ds $1
-
ds $1d
-wc5ea:: ; c5ea
+; signals what error, if any, occured
+; during IR communications
+; 0 means there was no error
+wIRCommunicationErrorCode:: ; c5ea
ds $1
-; related with wc5ef for Card Pop! communications
-wc5eb:: ; c5eb
+; parameters set for IR communications on own device
+; and received from the other device respectively
+; these must match for successful communication
+wOwnIRCommunicationParams:: ; c5eb
ds $4
-
-; related with wc5eb for Card Pop! communications
-wc5ef:: ; c5ef
+wOtherIRCommunicationParams:: ; c5ef
ds $4
; stores the result from LookUpNameInCardPopNameList
@@ -1653,7 +1653,7 @@ wTextHeader4:: ; ce3a
; text id for the first TX_RAM2 of a text
; prints from wDefaultText if $0000
-wTxRam2:: ; cd3f
+wTxRam2:: ; ce3f
ds $2
; text id for the second TX_RAM2 of a text
@@ -1804,11 +1804,10 @@ wce68:: ; ce68
wce69:: ; ce69
ds $1
-wce6a:: ; ce6a
- ds $1
-
-wce6b:: ; ce6b
- ds $1
+; pointer to memory of data to send
+; in the data packet to the printer
+wPrinterPacketDataPtr:: ; ce6a
+ ds $2
wce6c:: ; ce6c
ds $1
@@ -1822,11 +1821,10 @@ wce6e:: ; ce6e
wPrinterStatus:: ; ce6f
ds $1
-wce70:: ; ce70
- ds $1
-
-wce71:: ; ce71
- ds $1
+; pointer to packet data that is
+; being transmitted through serial
+wSerialDataPtr:: ; ce70
+ ds $2
wce72:: ; ce72
ds $1
@@ -1877,20 +1875,52 @@ wVBlankFunctionTrampolineBackup:: ; ce8d
wce8f:: ; ce8f
ds $1
- ds $9
+wPrinterHorizontalOffset:: ; ce90
+ ds $1
-wce99:: ; ce99
+; the count of some card ID in the deck to be printed
+wPrinterCardCount:: ; ce91
ds $1
-wce9a:: ; ce9a
+; total card count of list to be printed
+wPrinterTotalCardCount:: ; ce92
+ ds $2
+
+wCurPrinterCardType:: ; ce94
ds $1
+; total card count of the current card type
+; in list to be printed
+wPrinterCurCardTypeCount:: ; ce95
+ ds $2
+
+wPrinterNumCardTypes:: ; ce97
+ ds $1
+
+; related to printer functions
+; only wrtten to but never read
+wce98:: ; ce98
+ ds $1
+
+wPrinterContrastLevel:: ; ce99
+ ds $1
+
+wPrizeCardSelectionFrameCounter:: ; ce9a
+ ds $1
+
+; related to printer serial stuff
wce9b:: ; ce9b
ds $1
- ds $2
+wPrintOnlyStarRarity:: ; ce9c
+ ds $1
+
+; only used in unreferenced function Func_1a14b
+; otherwise unused
+wce9d:: ; ce9d
+ ds $1
-wce9e:: ; ce9e
+wPrinterInitAttempts:: ; ce9e
ds $1
wce9f:: ; ce9f