From 8d4b602bde997b708caf016cc340bac9c07cdd54 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Mon, 10 Nov 2025 09:00:42 -0600 Subject: [PATCH 01/27] disasm pause menu key_functions --- src/engine/bank02.asm | 301 +++++++++++++++++++++++++++++++++++++++++- src/engine/bank04.asm | 37 +++++- src/engine/bank06.asm | 3 + src/engine/bank07.asm | 250 +++++++++++++++++++++++++++++++++++ src/engine/bank0e.asm | 90 +++++++++++++ 5 files changed, 674 insertions(+), 7 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 8092a87..39c8823 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -583,6 +583,37 @@ Func_8f6b: ret ; 0x8f77 +SECTION "Bank 2@4f7f", ROMX[$4f7f], BANK[$2] + +Func_8f7f: + ld hl, $4f77 + call Func_8f6b + ld a, $ff + call DrawDeckSelectionMenu + xor a +; fallthrough + +Func_8f8b: +.asm_8f8b + ld hl, $4fb1 + call InitializeMenuParameters + ld hl, $28d + call DrawWideTextBox_PrintText +.asm_8f97 + call DoFrame + jr c, .asm_8f8b + call Func_8fb9 + jr c, .asm_8f8b + call HandleMenuInput + jr nc, .asm_8f97 + ldh a, [hCurScrollMenuItem] + cp $ff + ret z + ld [wCurDeck], a + jp Func_903f +; 0x8fb1 + + SECTION "Bank 2@4fb9", ROMX[$4fb9], BANK[$2] Func_8fb9: @@ -636,7 +667,237 @@ OpenDeckConfirmationMenu: ret ; 0x9014 -SECTION "Bank 2@5215", ROMX[$5215], BANK[$2] +SECTION "Bank 2@503f", ROMX[$503f], BANK[$2] + +Func_903f: + call DrawWideTextBox + ld hl, $5254 + call PlaceTextItems + call Func_9287 +; fallthrough + +Func_904b: + call DoFrame + call Func_9292 + jp nc, Func_904b + cp $ff + jr nz, .asm_9061 + call Func_9292.asm_9305 + ld a, [wCurDeck] + jp Func_8f8b +.asm_9061 + ld a, [wd0ef] + or a + jp nz, Func_91b7 + ld a, [wMusicStereoPanningBackup] + or a + jp nz, Func_90d8 + call GetSRAMPointerToCurDeckCards + ld e, l + ld d, h + ld hl, wCurDeckCards + call CopyDeckFromSRAM + ld de, wCurDeckName + call GetSRAMPointerToCurDeck + call CopyListFromHLToDEInSRAM + xor a + ld [wd121], a + call Func_95d6 + jr nc, .asm_90cd + call EnableSRAM + ld hl, wCurDeckCards + call Func_935d + call GetSRAMPointerToCurDeckCards + call Func_9397 + ld de, wCurDeckCards + bank1call SaveDeckCards + call GetSRAMPointerToCurDeck + ld d, h + ld e, l + ld hl, wCurDeckName + call CopyListFromHLToDE + call GetSRAMPointerToCurDeck + ld a, [hl] + call DisableSRAM + or a + jr z, Func_90e8 + ld a, [hffbf] + or a + jr z, .asm_90cd + call EnableSRAM + ld de, wCurDeckCards + farcall Func_3be8d + call DisableSRAM + farcall Func_3bead +.asm_90cd + ld a, $ff + call DrawDeckSelectionMenu + ld a, [wCurDeck] + jp Func_8f8b + +Func_90d8: + xor a + ld [hffbf], a + call CheckIfCurDeckIsEmpty + jp nc, Func_90e8 + call Func_9215 + jp Func_8f8b + +Func_90e8: + ld de, wCurDeckName + call GetSRAMPointerToCurDeck + call CopyListFromHLToDEInSRAM + call Func_9124 + call GetSRAMPointerToCurDeck + ld d, h + ld e, l + ld hl, wCurDeckName + call CopyListFromHLToDEInSRAM + ld a, [hffbf] + or a + jr z, .asm_9119 + call EnableSRAM + ld hl, wCurDeckName + ld de, wCurDeckCards + farcall Func_3be8d + call DisableSRAM + farcall Func_3bead +.asm_9119 + ld a, $ff + call DrawDeckSelectionMenu + ld a, [wCurDeck] + jp Func_8f8b + +Func_9124: + ld a, [wCurDeck] + or a + jr nz, .asm_912f + ld hl, $6e65 + jr .asm_914a +.asm_912f + dec a + jr nz, .asm_9137 + ld hl, $6e6e + jr .asm_914a +.asm_9137 + dec a + jr nz, .asm_913f + ld hl, $6e77 + jr .asm_914a +.asm_913f + dec a + jr nz, .asm_9147 + ld hl, $6e80 + jr .asm_914a +.asm_9147 + ld hl, $6e89 +.asm_914a + ld a, $14 + ld bc, $401 + ld de, wCurDeckName + farcall Func_1aeab + ld a, [wCurDeckName] + or a + ret nz + call Func_915f + ret + +Func_915f: + ld hl, s0b7a1 + call EnableSRAM + ld e, [hl] + inc hl + ld d, [hl] + push de + ld de, wCurDeckName + call CopyPlayerName + ld h, d + ld l, e + pop de + ld [hl], $0e + inc hl + ld [hl], $29 + inc hl + push hl + ld h, d + ld l, e + call Func_922e + call DisableSRAM + pop hl + ld a, [$d3ec] + ld [hl], $05 + inc hl + ld [hli], a + ld a, [$d3ed] + ld [hl], $05 + inc hl + ld [hli], a + ld a, [$d3ee] + ld [hl], $05 + inc hl + ld [hli], a + xor a + ld [hl], a + ld hl, s0b7a1 + call EnableSRAM + ld e, [hl] + inc hl + ld d, [hl] + ld a, $03 + cp d + jr nz, .asm_91af + ld a, $e7 + cp e + jr nz, .asm_91af + ld de, $0 +.asm_91af + inc de + ld [hl], d + dec hl + ld [hl], e + call DisableSRAM + ret + +Func_91b7: + ld a, [wMusicStereoPanningBackup] + or a + jp nz, Func_9253 + call CheckIfCurDeckIsEmpty + jp nc, Func_91ca + call Func_9215 + jp Func_8f8b + +Func_91ca: + call EnableSRAM + ld a, [sCurrentlySelectedDeck] + call DisableSRAM + ld h, $03 + ld l, a + call HtimesL + ld e, l + inc e + ld d, $02 + xor a + ld hl, $0 + ld bc, $202 + call FillRectangle + ld a, [wCurDeck] + call EnableSRAM + ld [sCurrentlySelectedDeck], a + call DisableSRAM + call DrawHandCardsTileOnCurDeck + call GetSRAMPointerToCurDeck + call EnableSRAM + call CopyDeckName + call DisableSRAM + xor a + ld [wTxRam2], a + ld [$cdd7], a + ld hl, $293 + call DrawWideTextBox_WaitForInput + ld a, [wCurDeck] + jp Func_8f8b +; 0x9215 Func_9215: ldtx hl, ThereIsNoDeckHereText @@ -658,6 +919,36 @@ CheckIfCurDeckIsEmpty: ret ; 0x922e +Func_922e: + ld de, $d3ec + ld bc, $ff9c + call Func_9244 + ld bc, $fff6 + call Func_9244 + ld bc, $ffff + call Func_9244 + ret + +Func_9244: + ld a, $1f +.asm_9246 + inc a + add hl, bc + jr c, .asm_9246 + ld [de], a + inc de + ld a, l + sub c + ld l, a + ld a, h + sbc b + ld h, a + ret + +Func_9253: + ret +; 0x9254 + SECTION "Bank 2@5265", ROMX[$5265], BANK[$2] GetSRAMPointerToCurDeck: @@ -809,6 +1100,9 @@ Func_9337: call CopyDeckFromSRAM call EnableSRAM ld hl, wTempSavedDeckCards +; fallthrough + +Func_9346: ld b, DECK_SIZE .asm_9348 ld e, [hl] @@ -829,6 +1123,11 @@ Func_9337: ret ; 0x935d +Func_935d: + push hl + jr Func_9346 +; 0x9360 + SECTION "Bank 2@5397", ROMX[$5397], BANK[$2] Func_9397: diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index ad8353b..24ba27b 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1268,12 +1268,12 @@ Func_10836: ret Data_1083d: ; pause menu - db $00, $07, $f2, $45 ; status - db $01, $07, $02, $45 ; diary - db $02, $04, $65, $48 ; deck - db $03, $07, $4f, $67 ; minicon - db $04, $07, $9a, $5c ; coin - db $05, $07, $6e, $41 ; settings + key_func $00, Func_1c5f2 ; status + key_func $01, Func_1c502 ; diary + key_func $02, Func_10865 ; deck + key_func $03, Func_1e74f ; minicon + key_func $04, Func_1dc9a ; coin + key_func $05, Func_1c16e ; settings db $ff Func_10856: @@ -1283,6 +1283,31 @@ Func_10856: ret ; 0x10861 +SECTION "Bank 4@4865", ROMX[$4865], BANK[$4] + +Func_10865: + call Func_1022a + call Func_1086f + call Func_10252 + ret + +Func_1086f: + push af + push bc + push de + push hl + call SetFadePalsFrameFunc + farcall Func_8f7f + farcall StartFadeToWhite + farcall WaitPalFading_Bank07 + call UnsetFadePalsFrameFunc + pop hl + pop de + pop bc + pop af + ret +; 0x1088a + SECTION "Bank 4@488a", ROMX[$488a], BANK[$4] ZeroObjectPositionsAndEnableOBPFading: diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 3d1894c..69f96df 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -5993,6 +5993,9 @@ InputPlayerName: ld a, MAX_PLAYER_NAME_LENGTH ld hl, WhatIsYourNameData lb bc, 12, 1 +; fallthrough + +Func_1aeab: call InitializeInputName call Set_OBJ_8x8 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index dc019cd..12b7acb 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -317,6 +317,15 @@ GetDuelistPortrait:: db PORTRAIT_DR_MASON ; DR_MASON_PIC ; 0x1c116 +SECTION "Bank 7@416e", ROMX[$416e], BANK[$7] + +Func_1c16e: + farcall Func_1022a + call ShowConfigMenu + farcall Func_10252 + ret +; 0x1c17a + SECTION "Bank 7@417a", ROMX[$417a], BANK[$7] ShowConfigMenu: @@ -689,6 +698,71 @@ ConvertTextSpeedToMessageSpeedSetting: db 0, 1, 2, 0, 3, 0, 4 ; 0x1c45a +SECTION "Bank 7@4502", ROMX[$4502], BANK[$7] + +Func_1c502: + farcall Func_1022a + call Func_1c50e + farcall Func_10252 + ret + +Func_1c50e: + push af + push bc + push de + push hl + call Func_1c51a + pop hl + pop de + pop bc + pop af + ret + +Func_1c51a: + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + farcall ClearSpriteAnims + call Func_1c53f + farcall SetFadePalsFrameFunc + call StartFadeFromWhite + call WaitPalFading_Bank07 + ld c, $00 + call Func_1c5a3 + call StartFadeToWhite + call WaitPalFading_Bank07 + farcall UnsetFadePalsFrameFunc + ret + +Func_1c53f: + ld de, $0 + ld bc, $140c + call DrawRegularTextBoxVRAM0 + ld de, $c + ld bc, $1406 + call DrawRegularTextBoxVRAM0 + ld hl, $458e + call PlaceTextItemsVRAM0 + ld bc, $103 + call DrawPlayerPortrait + ld hl, $5ac + ld de, $501 + call PrintTextNoDelay_InitVRAM0 + ld hl, $5be + ld de, $b04 + call PrintTextNoDelay_InitVRAM0 + call CountEventCoinsObtained + ld l, a + ld h, $00 + ld de, $1006 + ld a, $02 + ld b, $01 + call PrintNumber + ld de, $d0a + farcall PrintPlayTime + ld de, $c08 + farcall PrintCardAlbumProgress + ret +; 0x1c58e + SECTION "Bank 7@45a3", ROMX[$45a3], BANK[$7] Func_1c5a3: @@ -742,6 +816,88 @@ Func_1c5d6: ret ; 0x1c5f2 +Func_1c5f2: + farcall Func_1022a + call Func_1c5fe + farcall Func_10252 + ret + +Func_1c5fe: + push af + push bc + push de + push hl + call Func_1c60a + pop hl + pop de + pop bc + pop af + ret + +Func_1c60a: + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + farcall ClearSpriteAnims + call DisableLCD + call Func_1c62d + call Func_1c667 + call EnableLCD + farcall SetFrameFuncAndFadeFromWhite + ld c, $03 + farcall Func_10221 + farcall FadeToWhiteAndUnsetFrameFunc + ret + +Func_1c62d: + ld de, $0 + ld bc, $1408 + call DrawRegularTextBoxVRAM0 + ld hl, $465a + call PlaceTextItemsVRAM0 + ld bc, $101 + call DrawPlayerPortrait + ld hl, $5be + ld de, $b02 + call PrintTextNoDelay_InitVRAM0 + ld de, $d06 + farcall PrintPlayTime + ld de, $c04 + farcall PrintCardAlbumProgress + ret +; 0x1c65a + +SECTION "Bank 7@4667", ROMX[$4667], BANK[$7] + +Func_1c667: + ld de, $8 + ld bc, $140a + call DrawRegularTextBoxVRAM0 + ld de, $108 + ld bc, $901 + farcall FillBoxInBGMapWithZero + ld hl, $46b2 + call PlaceTextItemsVRAM0 + call Func_1dfb5 + call GetCoinName + ld de, $40c + call InitTextPrinting_ProcessTextFromIDVRAM0 + call Func_1dfb5 + add $28 + ld de, $1c6c + call CreateCoinAnimation + call CheckObtainedGRCoinPieces + add $40 + ld de, $1c8c + call CreateCoinAnimation + call CheckObtainedGRCoinPieces + and a + jr z, .asm_1c6b1 + ld hl, $5b6 + ld de, $40e + call InitTextPrinting_ProcessTextFromIDVRAM0 +.asm_1c6b1 + ret +; 0x1c6b2 + SECTION "Bank 7@46bb", ROMX[$46bb], BANK[$7] SetAllPaletteFadeConfigsToEnabled: @@ -5378,6 +5534,25 @@ Func_1e73a: ret ; 0x1e74f +Func_1e74f: + farcall Func_1022a + call Func_1e75b + farcall Func_10252 + ret + +Func_1e75b: + push af + push bc + push de + push hl + call Func_1e76c + pop hl + pop de + pop bc + pop af + ret +; 0x1e767 + SECTION "Bank 7@6767", ROMX[$6767], BANK[$7] Func_1e767: @@ -5386,6 +5561,81 @@ Func_1e767: ret ; 0x1e76c +Func_1e76c: + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + call Func_1e795 + farcall SetFrameFuncAndFadeFromWhite +.asm_1e777 + call Func_1e808 + jr c, .asm_1e790 + call Func_1e823 + jr c, .asm_1e790 + call DisableLCD + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + call Func_1e795 + call EnableLCD + jr .asm_1e777 +.asm_1e790 + farcall FadeToWhiteAndUnsetFrameFunc + ret + +Func_1e795: + ld b, $07 + ld hl, $67e0 + ld de, $3 + call LoadMenuBoxParams + ld a, [wdd07] + call DrawMenuBox + ld de, $0 + ld bc, $1404 + call DrawRegularTextBoxVRAM0 + ld hl, $598 + ld de, CopyDataHLtoDE_SaveRegisters + call InitTextPrinting_ProcessTextFromIDVRAM0 + ld de, $c + ld bc, $1406 + call DrawRegularTextBoxVRAM0 + ld hl, $67c + ld de, $10e + call InitTextPrinting_ProcessTextFromIDVRAM0 + call Func_1f309 + jr z, .asm_1e7df + ld b, $07 + ld hl, $6800 + ld d, $78 + ld e, $20 + ld a, $00 + ld c, $00 + call CreateSpriteAnim +.asm_1e7df + ret +; 0x1e7e0 + +SECTION "Bank 7@6808", ROMX[$6808], BANK[$7] + +Func_1e808: + ld a, [wdd07] + call HandleMenuBox + ld [wdd07], a + jr c, .asm_1e81b + push af + ld a, $02 + call CallPlaySFX + pop af + ret +.asm_1e81b + push af + ld a, $03 + call CallPlaySFX + pop af + ret + +Func_1e823: + ld hl, $682a + call CallMappedFunction + ret +; 0x1e82a + SECTION "Bank 7@6837", ROMX[$6837], BANK[$7] Func_1e837: diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index 8143332..41b1a16 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -7101,6 +7101,96 @@ Func_3bd3b: ret ; 0x3bd5c +SECTION "Bank e@7e8d", ROMX[$7e8d], BANK[$e] + +Func_3be8d: + push de + ld de, wc000 + call Func_3afb1 + pop de + ld hl, $c018 + bank1call SaveDeckCards + call SwitchToWRAM2 + ld hl, wc000 + ld de, w2d28e + ld b, $60 + call CopyBBytesFromHLToDE_Bank0e + call SwitchToWRAM1 + ret + +Func_3bead: + ld a, [wCurDeck] + push af + xor a + ld [wScrollMenuScrollOffset], a + ld de, $2d3 + ld hl, wDeckMachineTitleText + ld [hl], e + inc hl + ld [hl], d + call ClearScreenAndDrawDeckMachineScreen + ld a, $32 + ld [wNumDeckMachineEntries], a + xor a +.asm_3bec7 + ld hl, $5eac + farcall InitializeScrollMenuParameters + call DrawListScrollArrows + call PrintNumSavedDecks + ld hl, $28d + call DrawWideTextBox_PrintText + ld de, $28d + call InitDeckMachineDrawingParams + call HandleDeckMachineSelection.start + jr c, .asm_3bec7 + cp $ff + jr z, .asm_3bf50 + ld b, a + ld a, [wScrollMenuScrollOffset] + add b + ld [wSelectedDeckMachineEntry], a + call CheckIfSelectedDeckMachineEntryIsEmpty + jr c, .asm_3bf01 + ld hl, $2ec + call YesOrNoMenuWithText + ld a, [wTempScrollMenuItem] + jr c, .asm_3bec7 +.asm_3bf01 + call GetSelectedSavedDeckPtr + ld d, h + ld e, l + ld hl, w2d28e + ld b, $60 + call EnableSRAM + call SwitchToWRAM2 + call CopyBBytesFromHLToDE_Bank0e + call SwitchToWRAM1 + call DisableSRAM + call ClearScreenAndDrawDeckMachineScreen + call DrawListScrollArrows + call PrintNumSavedDecks + ld a, [wTempScrollMenuItem] + ld hl, $5eac + farcall InitializeScrollMenuParameters + call HandleScrollMenu.draw_visible_cursor + pop af + ld [wCurDeck], a + farcall GetSRAMPointerToCurDeck + call EnableSRAM + farcall CopyDeckName + call DisableSRAM + xor a + ld [wTxRam2], a + ld [$cdd7], a + ld hl, $2da + call DrawWideTextBox_WaitForInput + ret +.asm_3bf50 + pop af + ld [wCurDeck], a + ret +; 0x3bf55 + SECTION "Bank e@7f5e", ROMX[$7f5e], BANK[$e] Func_3bf5e: From 6190d4499fc932eeacae7fec5a401d2e154e058b Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Tue, 11 Nov 2025 08:18:30 -0600 Subject: [PATCH 02/27] filling in text constants, coords and other magic numbers in functions called by the pause menu --- src/engine/bank02.asm | 6 ++-- src/engine/bank07.asm | 82 +++++++++++++++++++++---------------------- src/engine/bank0e.asm | 8 ++--- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 39c8823..a4eed33 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -597,7 +597,7 @@ Func_8f8b: .asm_8f8b ld hl, $4fb1 call InitializeMenuParameters - ld hl, $28d + ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText .asm_8f97 call DoFrame @@ -879,7 +879,7 @@ Func_91ca: ld d, $02 xor a ld hl, $0 - ld bc, $202 + lb bc, 2, 2 call FillRectangle ld a, [wCurDeck] call EnableSRAM @@ -893,7 +893,7 @@ Func_91ca: xor a ld [wTxRam2], a ld [$cdd7], a - ld hl, $293 + ldtx hl, ChosenAsDuelingDeckText call DrawWideTextBox_WaitForInput ld a, [wCurDeck] jp Func_8f8b diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 12b7acb..ecbd592 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -733,32 +733,32 @@ Func_1c51a: ret Func_1c53f: - ld de, $0 - ld bc, $140c + lb de, 0, 0 + lb bc, 20, 12 call DrawRegularTextBoxVRAM0 - ld de, $c - ld bc, $1406 + lb de, 0, 12 + lb bc, 20, 6 call DrawRegularTextBoxVRAM0 ld hl, $458e call PlaceTextItemsVRAM0 - ld bc, $103 + lb bc, 1, 3 call DrawPlayerPortrait - ld hl, $5ac - ld de, $501 + ldtx hl, PlayerDiaryTitleText + lb de, 5, 1 call PrintTextNoDelay_InitVRAM0 - ld hl, $5be - ld de, $b04 + ldtx hl, TxRam1Text + lb de, 11, 4 call PrintTextNoDelay_InitVRAM0 call CountEventCoinsObtained ld l, a ld h, $00 - ld de, $1006 + lb de, 16, 6 ld a, $02 - ld b, $01 + ld b, TRUE call PrintNumber - ld de, $d0a + lb de, 13, 10 farcall PrintPlayTime - ld de, $c08 + lb de, 12, 8 farcall PrintCardAlbumProgress ret ; 0x1c58e @@ -848,19 +848,19 @@ Func_1c60a: ret Func_1c62d: - ld de, $0 - ld bc, $1408 + lb de, 0, 0 + lb bc, 20, 8 call DrawRegularTextBoxVRAM0 ld hl, $465a call PlaceTextItemsVRAM0 - ld bc, $101 + lb bc, 1, 1 call DrawPlayerPortrait - ld hl, $5be - ld de, $b02 + ldtx hl, TxRam1Text + lb de, 11, 2 call PrintTextNoDelay_InitVRAM0 - ld de, $d06 + lb de, 13, 6 farcall PrintPlayTime - ld de, $c04 + lb de, 12, 4 farcall PrintCardAlbumProgress ret ; 0x1c65a @@ -868,31 +868,31 @@ Func_1c62d: SECTION "Bank 7@4667", ROMX[$4667], BANK[$7] Func_1c667: - ld de, $8 - ld bc, $140a + lb de, 0, 8 + lb bc, 20, 10 call DrawRegularTextBoxVRAM0 - ld de, $108 - ld bc, $901 + lb de, 1, 8 + lb bc, 9, 1 farcall FillBoxInBGMapWithZero ld hl, $46b2 call PlaceTextItemsVRAM0 call Func_1dfb5 call GetCoinName - ld de, $40c + lb de, 4, 12 call InitTextPrinting_ProcessTextFromIDVRAM0 call Func_1dfb5 add $28 - ld de, $1c6c + lb de, 28, 108 call CreateCoinAnimation call CheckObtainedGRCoinPieces add $40 - ld de, $1c8c + lb de, 28, 140 call CreateCoinAnimation call CheckObtainedGRCoinPieces and a jr z, .asm_1c6b1 - ld hl, $5b6 - ld de, $40e + ldtx hl, PlayerStatusGRCoinText + lb de, 4, 14 call InitTextPrinting_ProcessTextFromIDVRAM0 .asm_1c6b1 ret @@ -5582,28 +5582,28 @@ Func_1e76c: Func_1e795: ld b, $07 ld hl, $67e0 - ld de, $3 + lb de, 0, 3 call LoadMenuBoxParams ld a, [wdd07] call DrawMenuBox - ld de, $0 - ld bc, $1404 + lb de, 0, 0 + lb bc, 20, 4 call DrawRegularTextBoxVRAM0 - ld hl, $598 + ldtx hl, PauseMenuMinicomText ld de, CopyDataHLtoDE_SaveRegisters call InitTextPrinting_ProcessTextFromIDVRAM0 - ld de, $c - ld bc, $1406 + lb de, 0, 12 + lb bc, 20, 6 call DrawRegularTextBoxVRAM0 - ld hl, $67c - ld de, $10e + ldtx hl, MinicomDialogText + lb de, 1, 14 call InitTextPrinting_ProcessTextFromIDVRAM0 call Func_1f309 jr z, .asm_1e7df ld b, $07 ld hl, $6800 - ld d, $78 - ld e, $20 + ld d, 120 + ld e, 32 ld a, $00 ld c, $00 call CreateSpriteAnim @@ -5619,13 +5619,13 @@ Func_1e808: ld [wdd07], a jr c, .asm_1e81b push af - ld a, $02 + ld a, SFX_CONFIRM call CallPlaySFX pop af ret .asm_1e81b push af - ld a, $03 + ld a, SFX_CANCEL call CallPlaySFX pop af ret diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index 41b1a16..4344161 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -7137,9 +7137,9 @@ Func_3bead: farcall InitializeScrollMenuParameters call DrawListScrollArrows call PrintNumSavedDecks - ld hl, $28d + ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText - ld de, $28d + ldtx de, PleaseSelectDeckText call InitDeckMachineDrawingParams call HandleDeckMachineSelection.start jr c, .asm_3bec7 @@ -7151,7 +7151,7 @@ Func_3bead: ld [wSelectedDeckMachineEntry], a call CheckIfSelectedDeckMachineEntryIsEmpty jr c, .asm_3bf01 - ld hl, $2ec + ldtx hl, DeleteSavedDeckPromptText call YesOrNoMenuWithText ld a, [wTempScrollMenuItem] jr c, .asm_3bec7 @@ -7182,7 +7182,7 @@ Func_3bead: xor a ld [wTxRam2], a ld [$cdd7], a - ld hl, $2da + ldtx hl, SavedDeckToMachineText call DrawWideTextBox_WaitForInput ret .asm_3bf50 From 58e0119e1eeeb715378cb9ea834d5d0fb5e6449f Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Tue, 11 Nov 2025 08:30:03 -0600 Subject: [PATCH 03/27] disassembling text item data in newly dumped functions --- src/engine/bank02.asm | 10 +++++++--- src/engine/bank07.asm | 28 +++++++++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index a4eed33..2d00dec 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -671,7 +671,7 @@ SECTION "Bank 2@503f", ROMX[$503f], BANK[$2] Func_903f: call DrawWideTextBox - ld hl, $5254 + ld hl, Data_9254 call PlaceTextItems call Func_9287 ; fallthrough @@ -947,9 +947,13 @@ Func_9244: Func_9253: ret -; 0x9254 -SECTION "Bank 2@5265", ROMX[$5265], BANK[$2] +Data_9254: + db $02, $0e, $8e, $02 + db $0c, $0e, $90, $02 + db $02, $10, $8f, $02 + db $0c, $10, $91, $02 + db $ff GetSRAMPointerToCurDeck: ld a, [wCurDeck] diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index ecbd592..2702fb3 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -739,7 +739,7 @@ Func_1c53f: lb de, 0, 12 lb bc, 20, 6 call DrawRegularTextBoxVRAM0 - ld hl, $458e + ld hl, Data_1c58e call PlaceTextItemsVRAM0 lb bc, 1, 3 call DrawPlayerPortrait @@ -761,9 +761,14 @@ Func_1c53f: lb de, 12, 8 farcall PrintCardAlbumProgress ret -; 0x1c58e -SECTION "Bank 7@45a3", ROMX[$45a3], BANK[$7] +Data_1c58e: + db $07, $04, $ad, $05 + db $07, $06, $af, $05 + db $12, $06, $ca, $05 + db $07, $08, $b0, $05 + db $07, $0a, $b1, $05 + db $ff Func_1c5a3: push bc @@ -851,7 +856,7 @@ Func_1c62d: lb de, 0, 0 lb bc, 20, 8 call DrawRegularTextBoxVRAM0 - ld hl, $465a + ld hl, Data_1c65a call PlaceTextItemsVRAM0 lb bc, 1, 1 call DrawPlayerPortrait @@ -863,9 +868,12 @@ Func_1c62d: lb de, 12, 4 farcall PrintCardAlbumProgress ret -; 0x1c65a -SECTION "Bank 7@4667", ROMX[$4667], BANK[$7] +Data_1c65a: + db $07, $02, $ad, $05 + db $07, $04, $b0, $05 + db $07, $06, $b1, $05 + db $ff Func_1c667: lb de, 0, 8 @@ -874,7 +882,7 @@ Func_1c667: lb de, 1, 8 lb bc, 9, 1 farcall FillBoxInBGMapWithZero - ld hl, $46b2 + ld hl, Data_1c6b2 call PlaceTextItemsVRAM0 call Func_1dfb5 call GetCoinName @@ -896,9 +904,11 @@ Func_1c667: call InitTextPrinting_ProcessTextFromIDVRAM0 .asm_1c6b1 ret -; 0x1c6b2 -SECTION "Bank 7@46bb", ROMX[$46bb], BANK[$7] +Data_1c6b2: + db $01, $08, $ae, $05 + db $04, $0a, $b5, $05 + db $ff SetAllPaletteFadeConfigsToEnabled: call SetAllBGPaletteFadeConfigsToEnabled From b55dc16cc42442d24840d53a10635f99accd81ce Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Tue, 11 Nov 2025 09:33:26 -0600 Subject: [PATCH 04/27] documenting newly disassembled textitems --- src/engine/bank02.asm | 12 ++++++------ src/engine/bank07.asm | 32 ++++++++++++++++---------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 2d00dec..9ba4c22 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -671,7 +671,7 @@ SECTION "Bank 2@503f", ROMX[$503f], BANK[$2] Func_903f: call DrawWideTextBox - ld hl, Data_9254 + ld hl, DeckSelectScreenTextItems call PlaceTextItems call Func_9287 ; fallthrough @@ -948,11 +948,11 @@ Func_9244: Func_9253: ret -Data_9254: - db $02, $0e, $8e, $02 - db $0c, $0e, $90, $02 - db $02, $10, $8f, $02 - db $0c, $10, $91, $02 +DeckSelectScreenTextItems: + textitem 2, 14, ModifyDeckText + textitem 12, 14, ChooseAsDuelingDeckText + textitem 2, 16, RenameDeckText + textitem 12, 16, CancelDeckText db $ff GetSRAMPointerToCurDeck: diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 2702fb3..444bb66 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -739,7 +739,7 @@ Func_1c53f: lb de, 0, 12 lb bc, 20, 6 call DrawRegularTextBoxVRAM0 - ld hl, Data_1c58e + ld hl, .TextItems call PlaceTextItemsVRAM0 lb bc, 1, 3 call DrawPlayerPortrait @@ -762,12 +762,12 @@ Func_1c53f: farcall PrintCardAlbumProgress ret -Data_1c58e: - db $07, $04, $ad, $05 - db $07, $06, $af, $05 - db $12, $06, $ca, $05 - db $07, $08, $b0, $05 - db $07, $0a, $b1, $05 +.TextItems: + textitem 7, 4, PlayerDiaryNameText + textitem 7, 6, PlayerDiaryEventCoinText + textitem 18, 6, PlayerDiaryCardsUnitText + textitem 7, 8, PlayerDiaryAlbumText + textitem 7, 10, PlayerDiaryPlayTimeText db $ff Func_1c5a3: @@ -856,7 +856,7 @@ Func_1c62d: lb de, 0, 0 lb bc, 20, 8 call DrawRegularTextBoxVRAM0 - ld hl, Data_1c65a + ld hl, .TextItems call PlaceTextItemsVRAM0 lb bc, 1, 1 call DrawPlayerPortrait @@ -869,10 +869,10 @@ Func_1c62d: farcall PrintCardAlbumProgress ret -Data_1c65a: - db $07, $02, $ad, $05 - db $07, $04, $b0, $05 - db $07, $06, $b1, $05 +.TextItems: + textitem 7, 2, PlayerDiaryNameText + textitem 7, 4, PlayerDiaryAlbumText + textitem 7, 6, PlayerDiaryPlayTimeText db $ff Func_1c667: @@ -882,7 +882,7 @@ Func_1c667: lb de, 1, 8 lb bc, 9, 1 farcall FillBoxInBGMapWithZero - ld hl, Data_1c6b2 + ld hl, .TextItems call PlaceTextItemsVRAM0 call Func_1dfb5 call GetCoinName @@ -905,9 +905,9 @@ Func_1c667: .asm_1c6b1 ret -Data_1c6b2: - db $01, $08, $ae, $05 - db $04, $0a, $b5, $05 +.TextItems: + textitem 1, 8, PlayerStatusEventCoinTitleText + textitem 4, 10, PlayerStatusCurrentCoinText db $ff SetAllPaletteFadeConfigsToEnabled: From 99bc9feec8d0847c0ff9cc13ecd67cd8bf3bbe03 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 08:57:01 -0600 Subject: [PATCH 05/27] disassembling two menu data structures, using new macros --- src/engine/bank02.asm | 7 +++---- src/engine/bank07.asm | 16 +++++++++++++--- src/macros.asm | 1 + src/macros/menu.asm | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/macros/menu.asm diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 9ba4c22..14c8ae8 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -595,7 +595,7 @@ Func_8f7f: Func_8f8b: .asm_8f8b - ld hl, $4fb1 + ld hl, .MenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText @@ -611,10 +611,9 @@ Func_8f8b: ret z ld [wCurDeck], a jp Func_903f -; 0x8fb1 - -SECTION "Bank 2@4fb9", ROMX[$4fb9], BANK[$2] +.MenuParameters: + menu_parameters 1, 2, 3, NUM_DECKS, SYM_CURSOR_R, SYM_SPACE, NULL Func_8fb9: ldh a, [hDPadHeld] diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 444bb66..e062106 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -5590,8 +5590,8 @@ Func_1e76c: ret Func_1e795: - ld b, $07 - ld hl, $67e0 + ld b, BANK(.menu) + ld hl, .menu lb de, 0, 3 call LoadMenuBoxParams ld a, [wdd07] @@ -5619,7 +5619,17 @@ Func_1e795: call CreateSpriteAnim .asm_1e7df ret -; 0x1e7e0 + +.menu: + menu_box_params TRUE, 20, 10, \ + SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ + PAD_A, PAD_B, FALSE, 1, NULL, NULL + textitem 3, 2, MinicomDeckSaveMachineText + textitem 3, 4, MinicomMailboxText + textitem 3, 6, MinicomCardAlbumText + textitem 3, 8, PCMenuShutdownText + db $ff +; 0x1e800 SECTION "Bank 7@6808", ROMX[$6808], BANK[$7] diff --git a/src/macros.asm b/src/macros.asm index 796b079..41238c9 100644 --- a/src/macros.asm +++ b/src/macros.asm @@ -4,6 +4,7 @@ INCLUDE "macros/code.asm" INCLUDE "macros/data.asm" INCLUDE "macros/animations.asm" INCLUDE "macros/map.asm" +INCLUDE "macros/menu.asm" INCLUDE "macros/scripts.asm" INCLUDE "macros/text.asm" INCLUDE "macros/wram.asm" diff --git a/src/macros/menu.asm b/src/macros/menu.asm new file mode 100644 index 0000000..739fcdd --- /dev/null +++ b/src/macros/menu.asm @@ -0,0 +1,39 @@ +/* + \1 ; cursor x coordinate - int + \2 ; cursor y coordinate - int + \3 ; y displacement between items - int + \4 ; number of items - int + \5 ; cursor tile number - SYM_*, usually SYM_CURSOR_R + \6 ; tile behind cursor - SYM_*, usually SYM_SPACE + \7 ; function pointer if non-0 - function ptr or NULL + +8 bytes. Used by InitializeMenuParameters. +*/ +MACRO menu_parameters + db \1, \2, \3, \4, \5, \6 + dw \7 +ENDM + +/* + \1 ; skip clear - TRUE or FALSE + \2 ; width - int + \3 ; height - int + \4 ; blink cursor symbol - SYM_*, usually SYM_CURSOR_R + \5 ; space symbol - SYM_*, usually SYM_SPACE + \6 ; default cursor symbol - SYM_*, usually SYM_CURSOR_R + \7 ; selection cursor symbol - SYM_*, usually SYM_CURSOR_R + \8 ; press keys - PAD_*, usually PAD_A + \9 ; held keys - PAD_*, usually PAD_B + \10 ; has horizontal scroll - TRUE or FALSE + \11 ; vertical step - int + \12 ; update function - function ptr or NULL + \13 ; label text ID - text ptr + +15 bytes. Used by LoadMenuBoxParams. +Usually followed by a list of textitem macros, then $ff +*/ +MACRO menu_box_params + db \1, \2, \3, \4, \5, \6, \7, \8, \9, \<10>, \<11> + dw \<12> + tx \<13> +ENDM \ No newline at end of file From 36bb0e4197c5ad438b6e1382b00d2c687677c8ce Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 09:44:30 -0600 Subject: [PATCH 06/27] documenting pause menu functions status screen, diary screen, and a the initiaL minicon screen --- src/engine/bank02.asm | 5 +- src/engine/bank03.asm | 2 +- src/engine/bank04.asm | 22 +++--- src/engine/bank07.asm | 117 ++++++++++++++++---------------- src/engine/credits_commands.asm | 2 +- src/wram.asm | 2 +- 6 files changed, 76 insertions(+), 74 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 14c8ae8..27b025f 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -574,12 +574,12 @@ PrepareMenuGraphics: Func_8f6b: ld de, wMaxNumCardsAllowed ld b, $08 -.asm_8f70 +.loop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_8f70 + jr nz, .loop ret ; 0x8f77 @@ -1160,6 +1160,7 @@ Func_9397: pop hl ret +; a - ? DrawDeckSelectionMenu: ld [hffbf], a diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index efd19a6..3317aa4 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -5680,7 +5680,7 @@ Func_f085: dec c jr nz, .asm_f091 ld c, PAD_A | PAD_B - farcall Func_10221 + farcall WaitForButtonPress pop de ret ; 0xf0c3 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 24ba27b..e32c763 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -189,7 +189,7 @@ SECTION "Bank 4@4221", ROMX[$4221], BANK[$4] ; waits until any of the keys ; in register c are pressed -Func_10221: +WaitForButtonPress: .loop call DoFrame ldh a, [hKeysPressed] @@ -1263,17 +1263,17 @@ Func_1081a: ret Func_10836: - ld hl, Data_1083d + ld hl, .function_map call CallMappedFunction ret -Data_1083d: ; pause menu - key_func $00, Func_1c5f2 ; status - key_func $01, Func_1c502 ; diary - key_func $02, Func_10865 ; deck - key_func $03, Func_1e74f ; minicon - key_func $04, Func_1dc9a ; coin - key_func $05, Func_1c16e ; settings +.function_map: ; pause menu + key_func $00, PauseMenuStatusScreen ; status + key_func $01, PauseMenuDiaryScreen ; diary + key_func $02, PauseMenuDeckScreen ; deck + key_func $03, PauseMenuMiniconScreen ; minicon + key_func $04, PauseMenuCoinScreen ; coin + key_func $05, PauseMenuSettingsScreen ; settings db $ff Func_10856: @@ -1285,7 +1285,7 @@ Func_10856: SECTION "Bank 4@4865", ROMX[$4865], BANK[$4] -Func_10865: +PauseMenuDeckScreen: call Func_1022a call Func_1086f call Func_10252 @@ -6328,7 +6328,7 @@ Func_131d7: ldtx hl, GameCenterBlackBoxSaveRequestText call PrintScrollableText_NoTextBoxLabelVRAM0 ld c, $00 - farcall Func_1c5a3 + farcall DrawSavePromptAndWaitForInput ret nc ldtx hl, GameCenterBlackBoxUnableSaveRequiredText call PrintScrollableText_NoTextBoxLabelVRAM0 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index e062106..9de2a93 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -319,7 +319,7 @@ GetDuelistPortrait:: SECTION "Bank 7@416e", ROMX[$416e], BANK[$7] -Func_1c16e: +PauseMenuSettingsScreen: farcall Func_1022a call ShowConfigMenu farcall Func_10252 @@ -700,39 +700,39 @@ ConvertTextSpeedToMessageSpeedSetting: SECTION "Bank 7@4502", ROMX[$4502], BANK[$7] -Func_1c502: +PauseMenuDiaryScreen: farcall Func_1022a - call Func_1c50e + call PushRegistersAndShowDiaryScreen farcall Func_10252 ret -Func_1c50e: +PushRegistersAndShowDiaryScreen: push af push bc push de push hl - call Func_1c51a + call ShowDiaryScreen pop hl pop de pop bc pop af ret -Func_1c51a: +ShowDiaryScreen: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall ClearSpriteAnims - call Func_1c53f + call DrawDiaryStatusBox farcall SetFadePalsFrameFunc call StartFadeFromWhite call WaitPalFading_Bank07 ld c, $00 - call Func_1c5a3 + call DrawSavePromptAndWaitForInput call StartFadeToWhite call WaitPalFading_Bank07 farcall UnsetFadePalsFrameFunc ret -Func_1c53f: +DrawDiaryStatusBox: lb de, 0, 0 lb bc, 20, 12 call DrawRegularTextBoxVRAM0 @@ -770,7 +770,8 @@ Func_1c53f: textitem 7, 10, PlayerDiaryPlayTimeText db $ff -Func_1c5a3: +; c - ? +DrawSavePromptAndWaitForInput: push bc push de push hl @@ -819,40 +820,39 @@ Func_1c5d6: pop bc pop af ret -; 0x1c5f2 -Func_1c5f2: +PauseMenuStatusScreen: farcall Func_1022a - call Func_1c5fe + call PushRegistersAndShowStatusScreen farcall Func_10252 ret -Func_1c5fe: +PushRegistersAndShowStatusScreen: push af push bc push de push hl - call Func_1c60a + call ShowStatusScreen pop hl pop de pop bc pop af ret -Func_1c60a: +ShowStatusScreen: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall ClearSpriteAnims call DisableLCD - call Func_1c62d - call Func_1c667 + call DrawStatusScreenTopBox + call DrawStatusScreenBottomBox call EnableLCD farcall SetFrameFuncAndFadeFromWhite - ld c, $03 - farcall Func_10221 + ld c, PAD_A | PAD_B + farcall WaitForButtonPress farcall FadeToWhiteAndUnsetFrameFunc ret -Func_1c62d: +DrawStatusScreenTopBox: lb de, 0, 0 lb bc, 20, 8 call DrawRegularTextBoxVRAM0 @@ -875,7 +875,7 @@ Func_1c62d: textitem 7, 6, PlayerDiaryPlayTimeText db $ff -Func_1c667: +DrawStatusScreenBottomBox: lb de, 0, 8 lb bc, 20, 10 call DrawRegularTextBoxVRAM0 @@ -3014,7 +3014,7 @@ Func_1d475: farcall ClearCardPopNameList call EnableAnimations - call Func_1e767 + call ClearwMiniconMenuCursorPosition farcall Func_111f0 call InitDefaultConfigMenuSettings call SaveConfigMenuChoicesToSRAM @@ -3659,7 +3659,7 @@ Func_1da2a: ldtx de, ReceptionistText farcall PrintScrollableText_WithTextBoxLabelVRAM0 ld c, $01 - call Func_1c5a3 + call DrawSavePromptAndWaitForInput ret nc ldtx hl, GiftCenterServiceUnavailableSaveRequiredText ldtx de, ReceptionistText @@ -3884,7 +3884,7 @@ Func_1dc52: call Func_1dd89 ret -Func_1dc9a: +PauseMenuCoinScreen: farcall Func_1022a call ShowCoinMenuWithoutIncomingCoin farcall Func_10252 @@ -5542,59 +5542,54 @@ Func_1e73a: pop bc pop af ret -; 0x1e74f -Func_1e74f: +PauseMenuMiniconScreen: farcall Func_1022a - call Func_1e75b + call PushRegistersAndShowMiniconScreen farcall Func_10252 ret -Func_1e75b: +PushRegistersAndShowMiniconScreen: push af push bc push de push hl - call Func_1e76c + call ShowMiniconScreen pop hl pop de pop bc pop af ret -; 0x1e767 -SECTION "Bank 7@6767", ROMX[$6767], BANK[$7] - -Func_1e767: +ClearwMiniconMenuCursorPosition: xor a - ld [wdd07], a + ld [wMiniconMenuCursorPosition], a ret -; 0x1e76c -Func_1e76c: +ShowMiniconScreen: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - call Func_1e795 + call DrawMiniconMainScreen farcall SetFrameFuncAndFadeFromWhite -.asm_1e777 - call Func_1e808 - jr c, .asm_1e790 - call Func_1e823 - jr c, .asm_1e790 +.loop + call HandleMinicomMenuBox + jr c, .end + call CallMiniconMenuFunction + jr c, .end call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - call Func_1e795 + call DrawMiniconMainScreen call EnableLCD - jr .asm_1e777 -.asm_1e790 + jr .loop +.end farcall FadeToWhiteAndUnsetFrameFunc ret -Func_1e795: +DrawMiniconMainScreen: ld b, BANK(.menu) ld hl, .menu lb de, 0, 3 call LoadMenuBoxParams - ld a, [wdd07] + ld a, [wMiniconMenuCursorPosition] call DrawMenuBox lb de, 0, 0 lb bc, 20, 4 @@ -5633,30 +5628,36 @@ Func_1e795: SECTION "Bank 7@6808", ROMX[$6808], BANK[$7] -Func_1e808: - ld a, [wdd07] +; return +; a - cursor position, used later in CallMiniconMenuFunction +HandleMinicomMenuBox: + ld a, [wMiniconMenuCursorPosition] call HandleMenuBox - ld [wdd07], a - jr c, .asm_1e81b + ld [wMiniconMenuCursorPosition], a + jr c, .cancel push af ld a, SFX_CONFIRM call CallPlaySFX pop af ret -.asm_1e81b +.cancel push af ld a, SFX_CANCEL call CallPlaySFX pop af ret -Func_1e823: - ld hl, $682a +; a - function table index +CallMiniconMenuFunction: + ld hl, .minicon_functions call CallMappedFunction ret -; 0x1e82a -SECTION "Bank 7@6837", ROMX[$6837], BANK[$7] +.minicon_functions: + db $00, $07, $37, $68 + db $01, $07, $96, $6c + db $02, $07, $40, $68 + db $ff Func_1e837: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration @@ -5865,7 +5866,7 @@ Func_1e99c: call LoadGfxPalettes farcall SetFrameFuncAndFadeFromWhite ld c, PAD_B - farcall Func_10221 + farcall WaitForButtonPress call Func_3f61 farcall FadeToWhiteAndUnsetFrameFunc ret diff --git a/src/engine/credits_commands.asm b/src/engine/credits_commands.asm index 05c01cd..edfffb5 100644 --- a/src/engine/credits_commands.asm +++ b/src/engine/credits_commands.asm @@ -344,7 +344,7 @@ Func_13ac1:: CreditsCmd_WaitInput: ld a, [wCreditsCmdArg1] ld c, a - call Func_10221 + call WaitForButtonPress ret CreditsCmd_MusicFadeOut: diff --git a/src/wram.asm b/src/wram.asm index 08dd6b9..61ae601 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -3194,7 +3194,7 @@ wdd05:: ; dd05 wdd06:: ; dd06 ds $1 -wdd07:: ; dd07 +wMiniconMenuCursorPosition:: ; dd07 ds $1 wCurBoosterPack:: ; dd08 From e26340f332bc9b30d45d5e55a240a329a6256ce6 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 13:59:52 -0600 Subject: [PATCH 07/27] documenting deck menu the bulk of the names for functions, labels, wram and constants came from corresponding code in poketcg1 this refactoring extends outside the scope of newly disassembled code from the pause menu, and into code that was disassembled from the big mapfunctions dump --- src/constants/menu_constants.asm | 1 + src/engine/bank02.asm | 710 ++++++++++++++++++------------- src/engine/bank04.asm | 9 +- src/engine/bank06.asm | 32 +- src/engine/bank0a.asm | 6 +- src/engine/bank0e.asm | 32 +- src/sram.asm | 10 +- src/wram.asm | 28 +- 8 files changed, 492 insertions(+), 336 deletions(-) diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm index 6f5e91c..4b0fcf3 100644 --- a/src/constants/menu_constants.asm +++ b/src/constants/menu_constants.asm @@ -55,6 +55,7 @@ DEF FILTER_ENERGY EQU $20 DEF NUM_FILTERS EQU 9 DEF NUM_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7 +DEF NUM_FILTERED_LIST_VISIBLE_CARDS EQU 6 DEF NUM_DECK_SAVE_MACHINE_SLOTS EQU 50 DEF NUM_DECK_MACHINE_VISIBLE_DECKS EQU 5 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 27b025f..ee04dad 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -132,9 +132,9 @@ SECTION "Bank 2@47d3", ROMX[$47d3], BANK[$2] Func_87d3: xor a ld [wMenuInputSFX], a - ld a, [wd0ef] + ld a, [wCheckMenuCursorXPosition] ld d, a - ld a, [wd0ef + 1] + ld a, [wCheckMenuCursorYPosition] ld e, a ldh a, [hDPadHeld] or a @@ -205,9 +205,9 @@ Func_87d3: call .asm_8884 pop de ld a, d - ld [wd0ef], a + ld [wCheckMenuCursorXPosition], a ld a, e - ld [wd0ef + 1], a + ld [wCheckMenuCursorYPosition], a xor a ld [wScrollMenuCursorBlinkCounter], a .asm_8852 @@ -246,13 +246,13 @@ Func_87d3: ld e, a ld a, $0a ld l, a - ld a, [wd0ef] + ld a, [wCheckMenuCursorXPosition] ld h, a call HtimesL ld a, l add $01 ld b, a - ld a, [wd0ef + 1] + ld a, [wCheckMenuCursorYPosition] sla a add $0e ld c, a @@ -533,7 +533,7 @@ Func_8f10: ld [hli], a ld [hli], a ld [hl], a - ld [s0b7a1], a + ld [sUnnamedDeckCounter], a call DisableSRAM ; fallthrough @@ -572,8 +572,16 @@ PrepareMenuGraphics: ret Func_8f6b: +; inits the following deck building params from hl: +; wMaxNumCardsAllowed +; wd381 +; wSameNameCardsLimit +; wIncludeCardsInDeck +; wDeckConfigurationMenuHandlerFunction +; wDeckConfigurationMenuTransitionTable +InitDeckBuildingParams: ld de, wMaxNumCardsAllowed - ld b, $08 + ld b, 8 .loop ld a, [hli] ld [de], a @@ -581,41 +589,45 @@ Func_8f6b: dec b jr nz, .loop ret -; 0x8f77 -SECTION "Bank 2@4f7f", ROMX[$4f7f], BANK[$2] +DeckBuildingParams: + db DECK_CONFIG_BUFFER_SIZE + db DECK_SIZE + db MAX_NUM_SAME_NAME_CARDS + db TRUE ; whether to include deck cards + db $31, $57 ; function + db $43, $5a ; data table -Func_8f7f: - ld hl, $4f77 - call Func_8f6b +DeckSelectionMenu: + ld hl, DeckBuildingParams + call InitDeckBuildingParams ld a, $ff - call DrawDeckSelectionMenu + call DrawDecksScreen xor a -; fallthrough -Func_8f8b: -.asm_8f8b +.init_menu_params ld hl, .MenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText -.asm_8f97 +.loop_input call DoFrame - jr c, .asm_8f8b - call Func_8fb9 - jr c, .asm_8f8b + jr c, .init_menu_params + call HandleStartButtonInDeckSelectionMenu + jr c, .init_menu_params call HandleMenuInput - jr nc, .asm_8f97 + jr nc, .loop_input ldh a, [hCurScrollMenuItem] cp $ff - ret z + ret z ; B btn returns +; A btn pressed on a deck ld [wCurDeck], a - jp Func_903f + jp DeckSelectionSubMenu .MenuParameters: menu_parameters 1, 2, 3, NUM_DECKS, SYM_CURSOR_R, SYM_SPACE, NULL -Func_8fb9: +HandleStartButtonInDeckSelectionMenu: ldh a, [hDPadHeld] and PAD_START ret z @@ -625,7 +637,7 @@ Func_8fb9: jp nc, .valid_deck ; can be jr ld a, MENU_CANCEL call PlayConfirmOrCancelSFX - call Func_9215 + call PrintThereIsNoDeckHereText scf ret @@ -637,8 +649,8 @@ Func_8fb9: call GetSRAMPointerToCurDeck pop de call OpenDeckConfirmationMenu - ld a, $ff ; all decks - call DrawDeckSelectionMenu + ld a, ALL_DECKS + call DrawDecksScreen ld a, [wCurDeck] scf ret @@ -668,29 +680,35 @@ OpenDeckConfirmationMenu: SECTION "Bank 2@503f", ROMX[$503f], BANK[$2] -Func_903f: +; a - selected deck +; handles the submenu when selecting a deck +; (Modify Deck, Select Deck, Change Name and Cancel) +DeckSelectionSubMenu: call DrawWideTextBox ld hl, DeckSelectScreenTextItems call PlaceTextItems - call Func_9287 -; fallthrough - -Func_904b: + call ResetCheckMenuCursorPositionAndBlink +.loop_input: call DoFrame - call Func_9292 - jp nc, Func_904b + call HandleCheckMenuInput + jp nc, .loop_input cp $ff - jr nz, .asm_9061 - call Func_9292.asm_9305 + jr nz, .option_selected +; B btn pressed +; erase cursor and go back +; to deck selection handling + call EraseCheckMenuCursor ld a, [wCurDeck] - jp Func_8f8b -.asm_9061 - ld a, [wd0ef] + jp DeckSelectionMenu.init_menu_params + +.option_selected + ld a, [wCheckMenuCursorXPosition] or a - jp nz, Func_91b7 - ld a, [wMusicStereoPanningBackup] + jp nz, DeckSelectionSubMenu_SelectOrCancel + ld a, [wCheckMenuCursorYPosition] or a - jp nz, Func_90d8 + jp nz, .ChangeName + call GetSRAMPointerToCurDeckCards ld e, l ld d, h @@ -701,13 +719,14 @@ Func_904b: call CopyListFromHLToDEInSRAM xor a ld [wd121], a - call Func_95d6 + + call HandleDeckBuildScreen jr nc, .asm_90cd call EnableSRAM ld hl, wCurDeckCards - call Func_935d + call DecrementDeckCardsInCollection call GetSRAMPointerToCurDeckCards - call Func_9397 + call AddDeckToCollection ld de, wCurDeckCards bank1call SaveDeckCards call GetSRAMPointerToCurDeck @@ -719,7 +738,7 @@ Func_904b: ld a, [hl] call DisableSRAM or a - jr z, Func_90e8 + jr z, .get_input_deck_name ld a, [hffbf] or a jr z, .asm_90cd @@ -729,24 +748,24 @@ Func_904b: call DisableSRAM farcall Func_3bead .asm_90cd - ld a, $ff - call DrawDeckSelectionMenu + ld a, ALL_DECKS + call DrawDecksScreen ld a, [wCurDeck] - jp Func_8f8b + jp DeckSelectionMenu.init_menu_params -Func_90d8: +.ChangeName xor a ld [hffbf], a call CheckIfCurDeckIsEmpty - jp nc, Func_90e8 - call Func_9215 - jp Func_8f8b + jp nc, .get_input_deck_name + call PrintThereIsNoDeckHereText + jp DeckSelectionMenu.init_menu_params -Func_90e8: +.get_input_deck_name ld de, wCurDeckName call GetSRAMPointerToCurDeck call CopyListFromHLToDEInSRAM - call Func_9124 + call InputCurDeckName call GetSRAMPointerToCurDeck ld d, h ld e, l @@ -762,47 +781,50 @@ Func_90e8: call DisableSRAM farcall Func_3bead .asm_9119 - ld a, $ff - call DrawDeckSelectionMenu + ld a, ALL_DECKS + call DrawDecksScreen ld a, [wCurDeck] - jp Func_8f8b + jp DeckSelectionMenu.init_menu_params -Func_9124: +InputCurDeckName: ld a, [wCurDeck] or a - jr nz, .asm_912f - ld hl, $6e65 - jr .asm_914a -.asm_912f + jr nz, .try_deck_2 + ld hl, Deck1RenameText + jr .got_deck_ptr +.try_deck_2 dec a - jr nz, .asm_9137 - ld hl, $6e6e - jr .asm_914a -.asm_9137 + jr nz, .try_deck_3 + ld hl, Deck2RenameText + jr .got_deck_ptr +.try_deck_3 dec a - jr nz, .asm_913f - ld hl, $6e77 - jr .asm_914a -.asm_913f + jr nz, .try_deck_4 + ld hl, Deck3RenameText + jr .got_deck_ptr +.try_deck_4 dec a - jr nz, .asm_9147 - ld hl, $6e80 - jr .asm_914a -.asm_9147 - ld hl, $6e89 -.asm_914a - ld a, $14 - ld bc, $401 + jr nz, .deck_5 + ld hl, Deck4RenameText + jr .got_deck_ptr +.deck_5 + ld hl, Deck5RenameText +.got_deck_ptr + ld a, DECK_NAME_SIZE_WO_SUFFIX + lb bc, 4, 1 ld de, wCurDeckName - farcall Func_1aeab + farcall InputName ld a, [wCurDeckName] or a ret nz - call Func_915f + call .UnnamedDeck ret -Func_915f: - ld hl, s0b7a1 +; handles the naming of unnamed decks +; inputs as the deck name " no XXX" +; where XXX is the current unnamed deck counter +.UnnamedDeck + ld hl, sUnnamedDeckCounter call EnableSRAM ld e, [hl] inc hl @@ -813,43 +835,50 @@ Func_915f: ld h, d ld l, e pop de - ld [hl], $0e + + ld [hl], TX_HIRAGANA inc hl - ld [hl], $29 + ld [hl], $29 ; "の" inc hl + push hl ld h, d ld l, e - call Func_922e + call UnnamedDeckCounterToText call DisableSRAM pop hl - ld a, [$d3ec] - ld [hl], $05 + + ld a, [wTempUnnamedDeckCounter] + ld [hl], TX_SYMBOL inc hl ld [hli], a - ld a, [$d3ed] - ld [hl], $05 + ld a, [wTempUnnamedDeckCounter + 1] + ld [hl], TX_SYMBOL inc hl ld [hli], a - ld a, [$d3ee] - ld [hl], $05 + ld a, [wTempUnnamedDeckCounter + 2] + ld [hl], TX_SYMBOL inc hl ld [hli], a xor a ld [hl], a - ld hl, s0b7a1 + +; increment the unnamed deck counter + ld hl, sUnnamedDeckCounter call EnableSRAM ld e, [hl] inc hl ld d, [hl] - ld a, $03 +; capped at 999 + ld a, HIGH(MAX_UNNAMED_DECK_NUM) cp d - jr nz, .asm_91af - ld a, $e7 + jr nz, .incr_counter + ld a, LOW(MAX_UNNAMED_DECK_NUM) cp e - jr nz, .asm_91af - ld de, $0 -.asm_91af + jr nz, .incr_counter + ; reset counter + ld de, 0 +.incr_counter inc de ld [hl], d dec hl @@ -857,29 +886,40 @@ Func_915f: call DisableSRAM ret -Func_91b7: - ld a, [wMusicStereoPanningBackup] +; handle deck selection sub-menu +; the option is either "Select Deck" or "Cancel" +; depending on the cursor Y pos +DeckSelectionSubMenu_SelectOrCancel: + ld a, [wCheckMenuCursorYPosition] or a - jp nz, Func_9253 - call CheckIfCurDeckIsEmpty - jp nc, Func_91ca - call Func_9215 - jp Func_8f8b + jp nz, CancelDeckSelectionSubMenu -Func_91ca: + call CheckIfCurDeckIsEmpty + jp nc, .SelectDeck + ; invalid deck + call PrintThereIsNoDeckHereText + jp DeckSelectionMenu.init_menu_params + +.SelectDeck call EnableSRAM ld a, [sCurrentlySelectedDeck] call DisableSRAM + +; draw empty rectangle on currently selected deck +; i.e. erase the Hand Cards Gfx icon ld h, $03 ld l, a call HtimesL ld e, l inc e - ld d, $02 + ld d, 2 xor a - ld hl, $0 + lb hl, 0, 0 lb bc, 2, 2 call FillRectangle + +; set current deck as the selected deck +; and draw the Hand Cards Gfx icon ld a, [wCurDeck] call EnableSRAM ld [sCurrentlySelectedDeck], a @@ -891,14 +931,13 @@ Func_91ca: call DisableSRAM xor a ld [wTxRam2], a - ld [$cdd7], a + ld [wTxRam2 + 1], a ldtx hl, ChosenAsDuelingDeckText call DrawWideTextBox_WaitForInput ld a, [wCurDeck] - jp Func_8f8b -; 0x9215 + jp DeckSelectionMenu.init_menu_params -Func_9215: +PrintThereIsNoDeckHereText: ldtx hl, ThereIsNoDeckHereText call DrawWideTextBox_WaitForInput ld a, [wCurDeck] @@ -916,24 +955,24 @@ CheckIfCurDeckIsEmpty: ret nz scf ret -; 0x922e -Func_922e: - ld de, $d3ec - ld bc, $ff9c - call Func_9244 - ld bc, $fff6 - call Func_9244 - ld bc, $ffff - call Func_9244 +; convert the number at hl to text (ascii) format and write it to wTempUnnamedDeckCounter +UnnamedDeckCounterToText: + ld de, wTempUnnamedDeckCounter + ld bc, -100 + call .get_digit + ld bc, -10 + call .get_digit + ld bc, -1 + call .get_digit ret -Func_9244: - ld a, $1f -.asm_9246 +.get_digit + ld a, $1f ; "0" - 1 +.subtract_loop inc a add hl, bc - jr c, .asm_9246 + jr c, .subtract_loop ld [de], a inc de ld a, l @@ -944,7 +983,7 @@ Func_9244: ld h, a ret -Func_9253: +CancelDeckSelectionSubMenu: ret DeckSelectScreenTextItems: @@ -978,106 +1017,122 @@ GetSRAMPointerToCurDeckCards: pop af ret -Func_9287: +ResetCheckMenuCursorPositionAndBlink: xor a - ld [wd0ef], a - ld [wd0ef + 1], a + ld [wCheckMenuCursorXPosition], a + ld [wCheckMenuCursorYPosition], a ld [wScrollMenuCursorBlinkCounter], a ret -Func_9292: +; handle player input in check menu +; works out which cursor coordinate to go to +; and sets carry flag if A or B are pressed +; returns a = $1 if A pressed +; returns a = $ff if B pressed +HandleCheckMenuInput: xor a ld [wMenuInputSFX], a - ld a, [wd0ef] + ld a, [wCheckMenuCursorXPosition] ld d, a - ld a, [wd0ef + 1] + ld a, [wCheckMenuCursorYPosition] ld e, a ldh a, [hDPadHeld] or a - jr z, .asm_92d3 + jr z, .no_pad bit B_PAD_LEFT, a - jr nz, .asm_92ab + jr nz, .horizontal bit B_PAD_RIGHT, a - jr z, .asm_92b1 -.asm_92ab + jr z, .check_vertical +.horizontal ld a, d - xor $01 + xor $01; flips x coordinate ld d, a - jr .asm_92bd -.asm_92b1 - bit 6, a - jr nz, .asm_92b9 - bit 7, a - jr z, .asm_92d3 -.asm_92b9 + jr .okay +.check_vertical + bit B_PAD_UP, a + jr nz, .vertical + bit B_PAD_DOWN, a + jr z, .no_pad +.vertical ld a, e - xor $01 + xor $01 ; flips y coordinate ld e, a -.asm_92bd +.okay ld a, SFX_CURSOR ld [wMenuInputSFX], a push de - call .asm_9305 + call EraseCheckMenuCursor pop de ld a, d - ld [wd0ef], a + ld [wCheckMenuCursorXPosition], a ld a, e - ld [wd0ef + 1], a + ld [wCheckMenuCursorYPosition], a xor a ld [wScrollMenuCursorBlinkCounter], a -.asm_92d3 +.no_pad ldh a, [hKeysPressed] and PAD_A | PAD_B - jr z, .asm_92ee + jr z, .no_input and PAD_A - jr nz, .asm_92e4 + jr nz, .a_press ld a, MENU_CANCEL call PlayConfirmOrCancelSFX scf ret -.asm_92e4 - call .asm_9324 + +.a_press + call DisplayCheckMenuCursor ld a, MENU_CONFIRM call PlayConfirmOrCancelSFX scf ret -.asm_92ee +.no_input ld a, [wMenuInputSFX] or a - jr z, .asm_92f7 + jr z, .check_blink call PlaySFX -.asm_92f7 + +.check_blink ld hl, wScrollMenuCursorBlinkCounter ld a, [hl] inc [hl] - and $0f - ret nz - ld a, $0f - bit 4, [hl] - jr z, .asm_9307 -.asm_9305 - ld a, $00 -.asm_9307 + and %00001111 + ret nz ; only update cursor if blink's lower nibble is 0 + + ld a, SYM_CURSOR_R + bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set + jr z, DrawCheckMenuCursor + +; draws in the cursor position +EraseCheckMenuCursor: + ld a, SYM_SPACE +; fallthrough + +; draws in the cursor position +; input: +; a = tile byte to draw +DrawCheckMenuCursor: ld e, a - ld a, $0a + ld a, 10 ld l, a - ld a, [wd0ef] + ld a, [wCheckMenuCursorXPosition] ld h, a call HtimesL ld a, l - add $01 + add 1 ld b, a - ld a, [wd0ef + 1] + ld a, [wCheckMenuCursorYPosition] sla a - add $0e + add 14 ld c, a ld a, e call WriteByteToBGMap0 or a ret -.asm_9324: - ld a, $0f - jr .asm_9307 + +DisplayCheckMenuCursor: + ld a, SYM_CURSOR_R + jr DrawCheckMenuCursor ; if a = MENU_CANCEL (-1), play SFX_CANCEL (usually following B button) ; else SFX_CONFIRM (usually following A button) @@ -1105,14 +1160,17 @@ Func_9337: ld hl, wTempSavedDeckCards ; fallthrough -Func_9346: +; goes through whole deck in hl +; for each card ID, goes to its corresponding +; entry in sCardCollection and decrements its count +_DecrementDeckCardsInCollection: ld b, DECK_SIZE -.asm_9348 +.loop ld e, [hl] inc hl ld d, [hl] call CheckIfCardIDIsZero - jr c, .asm_935b + jr c, .done inc hl push hl ld hl, sCardCollection @@ -1120,20 +1178,26 @@ Func_9346: dec [hl] pop hl dec b - jr nz, .asm_9348 -.asm_935b + jr nz, .loop +.done pop hl ret ; 0x935d -Func_935d: +; goes through whole deck in hl +; for each card ID, goes to its corresponding +; entry in sCardCollection and decrements its count +DecrementDeckCardsInCollection: push hl - jr Func_9346 + jr _DecrementDeckCardsInCollection ; 0x9360 SECTION "Bank 2@5397", ROMX[$5397], BANK[$2] -Func_9397: +; adds all cards in deck in hl to player's collection +; Enables SRAM (contrary to this function in poketcg1) +; hl = pointer to deck cards +AddDeckToCollection: push hl ld d, h ld e, l @@ -1142,12 +1206,12 @@ Func_9397: call EnableSRAM ld hl, wTempSavedDeckCards ld b, DECK_SIZE -.asm_93a8 +.loop_deck ld e, [hl] inc hl ld d, [hl] call CheckIfCardIDIsZero - jr c, .asm_93bb + jr c, .done inc hl push hl ld hl, sCardCollection @@ -1155,13 +1219,15 @@ Func_9397: inc [hl] pop hl dec b - jr nz, .asm_93a8 -.asm_93bb + jr nz, .loop_deck +.done pop hl ret -; a - ? -DrawDeckSelectionMenu: +; draws the screen which shows the player's current +; deck configurations +; a = DECK_* flags to pick which deck names to show +DrawDecksScreen: ld [hffbf], a call EmptyScreenAndLoadFontDuelAndHandCardsIcons @@ -1490,89 +1556,104 @@ DrawHandCardsTileAtDE: call FillRectangle ret -Func_95d6: +HandleDeckBuildScreen: xor a ld [hffbf], a call WriteCardListsTerminatorBytes - call Func_9aaa - call Func_9a6d + call CountNumberOfCardsForEachCardType + call DrawCardTypeIconsAndPrintCardCounts + xor a ld [wScrollMenuScrollOffset], a - ld [wCurCardTypeFilter], a - call Func_9d41 + ld [wCurCardTypeFilter], a ; FILTER_GRASS + call PrintFilteredCardList + ld hl, FiltersCardSelectionParams call InitializeScrollMenuParameters -.asm_95f3 +.wait_input call DoFrame ldh a, [hDPadHeld] and PAD_START - jr z, .asm_960c + jr z, .no_start_btn_1 ld a, MENU_CONFIRM call PlayConfirmOrCancelSFX - call Func_9787 + call ConfirmDeckConfiguration ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a - jr .asm_95f3 -.asm_960c + jr .wait_input + +.no_start_btn_1 ld a, [wCurCardTypeFilter] ld b, a ld a, [wTempCardTypeFilter] cp b - jr z, .asm_9626 + jr z, .check_down_btn + ; need to refresh the filtered card list ld [wCurCardTypeFilter], a ld hl, wScrollMenuScrollOffset - ld [hl], $00 - call Func_9d41 - ld a, $09 + ld [hl], 0 + call PrintFilteredCardList + ld a, NUM_FILTERS ld [wNumMenuItems], a -.asm_9626 + +.check_down_btn ldh a, [hDPadHeld] and PAD_DOWN - jr z, .asm_9631 + jr z, .no_down_btn call ConfirmSelectionAndReturnCarry - jr .asm_963e -.asm_9631 + jr .jump_to_list + +.no_down_btn call HandleCardSelectionInput - jr nc, .asm_95f3 + jr nc, .wait_input ld a, [hCurMenuItem] cp $ff - jp z, Func_9712 -.asm_963e + jp z, OpenDeckConfigurationMenu + +.jump_to_list ld a, [wNumEntriesInCurFilter] or a - jr z, .asm_95f3 + jr z, .wait_input xor a -.asm_9645 +.wait_list_input ld hl, $5a3a call InitializeScrollMenuParameters ld a, [wNumEntriesInCurFilter] ld [wNumCardListEntries], a ld hl, wNumVisibleCardListEntries cp [hl] - jr nc, .asm_965a + jr nc, .ok + ; if total number of entries is greater than or equal to + ; the number of visible entries, then set number of cursor positions + ; as number of visible entries ld [wNumMenuItems], a -.asm_965a - ld hl, Func_9dbf +.ok + ld hl, PrintDeckBuildingCardList ld d, h ld a, l ld hl, wScrollMenuScrollFunc ld [hli], a ld [hl], d + ld a, $01 ld [wd119], a -.asm_9669 +.loop_input call DoFrame ldh a, [hDPadHeld] and PAD_START - jr z, .asm_9685 + jr z, .no_start_btn_2 ld a, MENU_CONFIRM call PlayConfirmOrCancelSFX + + ; temporarily store current cursor position + ; to retrieve it later ld a, [wTempCardTypeFilter] - ld [wd11c], a - call Func_9787 - ld a, [wd11c] - jr .asm_9645 -.asm_9685 + ld [wTempFilteredCardListNumCursorPositions], a + call ConfirmDeckConfiguration + ld a, [wTempFilteredCardListNumCursorPositions] + jr .wait_list_input + +.no_start_btn_2 ldh a, [hDPadHeld] and PAD_UP jr z, .asm_96a0 @@ -1585,12 +1666,14 @@ Func_95d6: ld a, MENU_CANCEL call PlayConfirmOrCancelSFX jr .asm_96f3 + .asm_96a0 call HandleSelectUpAndDownInList - jr c, .asm_9669 + jr c, .loop_input call HandleScrollListInput jr c, .asm_96f3 - jr .asm_9669 + jr .loop_input + .asm_96ac ld a, MENU_CONFIRM call PlayConfirmOrCancelSFX @@ -1604,20 +1687,22 @@ Func_95d6: inc hl ld [hl], d call OpenCardPageFromCardList - call Func_9a6d + call DrawCardTypeIconsAndPrintCardCounts + ld hl, FiltersCardSelectionParams call InitializeScrollMenuParameters ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible - call Func_9dbf + call PrintDeckBuildingCardList ld hl, $5a3a call InitializeScrollMenuParameters ld a, [wTempScrollMenuNumVisibleItems] ld [wNumMenuItems], a ld a, [wTempCurMenuItem] ld [wTempCardTypeFilter], a - jp .asm_9669 + jp .loop_input + .asm_96f3 call DrawListCursor_Invisible ld a, [wTempCardTypeFilter] @@ -1629,12 +1714,12 @@ Func_95d6: call InitializeScrollMenuParameters ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a - jp .asm_95f3 + jp .wait_input -Func_9712: +OpenDeckConfigurationMenu: xor a ld [wd0c1], a - ld de, wd386 + ld de, wDeckConfigurationMenuTransitionTable ld hl, wTransitionTablePtr ld a, [de] ld [hli], a @@ -1645,7 +1730,7 @@ Func_9712: ld [wd0c4], a xor a ld [wScrollMenuCursorBlinkCounter], a - ld hl, wd384 + ld hl, wDeckConfigurationMenuHandlerFunction ld a, [hli] ld h, [hl] ld l, a @@ -1654,24 +1739,24 @@ Func_9712: SECTION "Bank 2@5787", ROMX[$5787], BANK[$2] -Func_9787: +ConfirmDeckConfiguration: ld hl, wScrollMenuScrollOffset ld a, [hl] - ld hl, wd11f + ld hl, wCardListVisibleOffsetBackup ld [hl], a call HandleDeckConfirmationMenu - ld hl, wd11f + ld hl, wCardListVisibleOffsetBackup ld a, [hl] ld hl, wScrollMenuScrollOffset ld [hl], a - call Func_9a6d + call DrawCardTypeIconsAndPrintCardCounts ld hl, FiltersCardSelectionParams call InitializeScrollMenuParameters ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible ld a, [wCurCardTypeFilter] - call Func_9d41 + call PrintFilteredCardList ld a, [wde84] ld [wTempCardTypeFilter], a ret @@ -1714,7 +1799,11 @@ FiltersCardSelectionParams: SECTION "Bank 2@5a6d", ROMX[$5a6d], BANK[$2] -Func_9a6d: +; draws each card type icon in a line +; the respective card counts underneath each icon +; and prints"X/60" in the upper-right corner, +; where X is the total card count +DrawCardTypeIconsAndPrintCardCounts: call PrepareMenuGraphics lb bc, 0, 5 ld a, SYM_BOX_TOP @@ -1746,17 +1835,19 @@ FillBGMapLineWithA: call BankswitchVRAM0 ret -Func_9aaa: +; saves the count of each type of card that is in wCurDeckCards +; stores these values in wCardFilterCounts +CountNumberOfCardsForEachCardType: ld hl, wCardFilterCounts ld de, CardTypeFilters -.asm_9ab0 +.loop ld a, [de] - cp $ff + cp -1 ret z inc de - call Func_9cdc + call CountNumberOfCardsOfType ld [hli], a - jr .asm_9ab0 + jr .loop ; a = byte to write ; b = number of bytes @@ -2097,22 +2188,27 @@ Func_9c55: pop hl ret -Func_9c80: +; appends text "X/Y", where X is the number of included cards +; and Y is the total number of cards in storage of a given card ID +; input: +; e = card ID +AppendOwnedCardCountAndStorageCountNumbers: push af push bc push de push hl -.asm_9c84 +; count how many bytes until $00 +.loop ld a, [hl] or a - jr z, .asm_9c8b + jr z, .print inc hl - jr .asm_9c84 -.asm_9c8b + jr .loop +.print push de call GetCountOfCardInCurDeck call ConvertToNumericalDigits - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl ld [hl], SYM_SLASH inc hl @@ -2178,13 +2274,13 @@ ConvertToNumericalDigits: ld [hli], a ret -Func_9cdc: +CountNumberOfCardsOfType: push de push hl ld hl, $0 ld b, a ld c, $00 -.asm_9ce4 +.loop_cards push hl push bc ld bc, wCurDeckCards @@ -2197,30 +2293,32 @@ Func_9cdc: inc hl inc hl call CheckIfCardIDIsZero - jr c, .asm_9d16 + jr c, .done call GetCardType - jr c, .asm_9d16 + jr c, .done push hl ld l, a ld a, b - and $20 - cp $20 - jr z, .asm_9d0b + and FILTER_ENERGY + cp FILTER_ENERGY + jr z, .check_energy ld a, l pop hl cp b - jr nz, .asm_9ce4 - jr .asm_9d13 -.asm_9d0b + jr nz, .loop_cards + jr .incr_count + +; counts all energy cards as the same +.check_energy ld a, l pop hl - and $08 - cp $08 - jr nz, .asm_9ce4 -.asm_9d13 + and TYPE_ENERGY + cp TYPE_ENERGY + jr nz, .loop_cards +.incr_count inc c - jr .asm_9ce4 -.asm_9d16 + jr .loop_cards +.done ld a, c pop hl pop de @@ -2253,7 +2351,7 @@ PrintCardTypeCounts: call ProcessText ret -Func_9d41: +PrintFilteredCardList: push af ld hl, CardTypeFilters ld b, $00 @@ -2261,9 +2359,11 @@ Func_9d41: add hl, bc ld a, [hl] push af + +; copy sCardCollection to wTempCardCollection call EnableSRAM ld hl, sCardCollection - ld de, wc000 + ld de, wTempCardCollection ld b, $00 call CopyBBytesFromHLToDE_Bank02 ld hl, $a200 @@ -2271,24 +2371,25 @@ Func_9d41: ld b, $00 call CopyBBytesFromHLToDE_Bank02 call DisableSRAM - ld a, [wd383] + + ld a, [wIncludeCardsInDeck] or a - jr z, .asm_9d75 + jr z, .ok call GetSRAMPointerToCurDeckCards ld d, h ld e, l call IncrementDeckCardsInTempCollection -.asm_9d75 +.ok pop af call CreateFilteredCardList - ld a, $06 + ld a, NUM_FILTERED_LIST_VISIBLE_CARDS ld [wNumVisibleCardListEntries], a lb de, 1, 7 ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d - call Func_9dbf + call PrintDeckBuildingCardList pop af ret @@ -2333,7 +2434,13 @@ PrintTotalCardCount: call ProcessText ret -Func_9dbf: +; prints the name, level and storage count of the cards +; that are visible in the list window +; in the form: +; CARD NAME/LEVEL X/Y +; where X is the current count of that card +; and Y is the storage count of that card +PrintDeckBuildingCardList: push bc ld hl, wCardListCoords ld e, [hl] @@ -2344,13 +2451,16 @@ Func_9dbf: dec c ld a, [wScrollMenuScrollOffset] or a - jr z, .asm_9dd4 + jr z, .no_cursor ld a, SYM_CURSOR_U - jr .asm_9dd6 -.asm_9dd4 + jr .got_cursor_tile +.no_cursor ld a, SYM_SPACE -.asm_9dd6 +.got_cursor_tile call WriteByteToBGMap0 + +; iterates by decreasing value in wNumVisibleCardListEntries +; by 1 until it reaches 0 ld a, [wScrollMenuScrollOffset] add a ld c, a @@ -2358,66 +2468,72 @@ Func_9dbf: ld hl, wTempCardList add hl, bc ld a, [wNumVisibleCardListEntries] -.asm_9de7 +.loop_filtered_cards push de or a - jr z, .asm_9e25 + jr z, .exit_loop ld b, a ld e, [hl] inc hl ld d, [hl] inc hl call CheckIfCardIDIsZero - jr c, .asm_9e13 + jr c, .invalid_card call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID - ld a, $0d + ld a, 13 push bc push hl push de call CopyCardNameAndLevel pop de - call Func_9c80 + call AppendOwnedCardCountAndStorageCountNumbers pop hl pop bc pop de push hl call InitTextPrinting ld hl, wDefaultText - jr .asm_9e1b -.asm_9e13 + jr .process_text + +.invalid_card pop de push hl call InitTextPrinting ld hl, Text_9e48 -.asm_9e1b +.process_text call ProcessText pop hl + ld a, b dec a inc e inc e - jr .asm_9de7 -.asm_9e25 + jr .loop_filtered_cards + +.exit_loop ld a, [hli] or a - jr nz, .asm_9e2d + jr nz, .can_scroll ld a, [hli] or a - jr z, .asm_9e36 -.asm_9e2d + jr z, .cannot_scroll +.can_scroll pop de - xor a +; draw down cursor because +; there are still more cards +; to be scrolled down + xor a ; FALSE ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D - jr .asm_9e3e -.asm_9e36 + jr .draw_cursor +.cannot_scroll pop de - ld a, $01 + ld a, TRUE ld [wUnableToScrollDown], a - ld a, $00 -.asm_9e3e - ld b, $13 + ld a, SYM_SPACE +.draw_cursor + ld b, 19 ; x coord ld c, e dec c dec c @@ -3877,7 +3993,7 @@ Func_a705: call Func_8f6b ld a, $01 ld [wd121], a - call Func_95d6 + call HandleDeckBuildScreen ret ; 0xa726 diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index e32c763..786b006 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1287,17 +1287,17 @@ SECTION "Bank 4@4865", ROMX[$4865], BANK[$4] PauseMenuDeckScreen: call Func_1022a - call Func_1086f + call ShowDeckSelectionMenuFromPauseMenu call Func_10252 ret -Func_1086f: +ShowDeckSelectionMenuFromPauseMenu: push af push bc push de push hl call SetFadePalsFrameFunc - farcall Func_8f7f + farcall DeckSelectionMenu farcall StartFadeToWhite farcall WaitPalFading_Bank07 call UnsetFadePalsFrameFunc @@ -1306,9 +1306,6 @@ Func_1086f: pop bc pop af ret -; 0x1088a - -SECTION "Bank 4@488a", ROMX[$488a], BANK[$4] ZeroObjectPositionsAndEnableOBPFading: push af diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 69f96df..d8663f2 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -5965,9 +5965,31 @@ HandCardsGfx: WhatIsYourNameData: textitem 1, 1, WhatIsYourNameText db $ff ; end -; 0x1ae65 -SECTION "Bank 6@6e92", ROMX[$6e92], BANK[$6] +Deck1RenameText: + textitem 2, 1, Deck1Text + textitem 14, 1, DeckText + db $ff + +Deck2RenameText: + textitem 2, 1, Deck2Text + textitem 14, 1, DeckText + db $ff + +Deck3RenameText: + textitem 2, 1, Deck3Text + textitem 14, 1, DeckText + db $ff + +Deck4RenameText: + textitem 2, 1, Deck4Text + textitem 14, 1, DeckText + db $ff + +Deck5RenameText: + textitem 2, 1, Deck5Text + textitem 14, 1, DeckText + db $ff ; dupe of PlayConfirmOrCancelSFX in bank 2 ; if a = MENU_CANCEL (-1), play SFX_CANCEL (usually following B button) @@ -5995,7 +6017,11 @@ InputPlayerName: lb bc, 12, 1 ; fallthrough -Func_1aeab: +; a = maximum length of name (depending on whether player's or deck's). +; bc = position of name. +; de = dest. pointer. +; hl = pointer to text item of the question. +InputName: call InitializeInputName call Set_OBJ_8x8 diff --git a/src/engine/bank0a.asm b/src/engine/bank0a.asm index f182862..4e5fda3 100644 --- a/src/engine/bank0a.asm +++ b/src/engine/bank0a.asm @@ -3531,7 +3531,7 @@ Func_2bc4f: ld [hl], d ld a, $ff ; all decks - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen xor a .asm_2bc5c ld hl, .MenuParameters @@ -3543,7 +3543,7 @@ Func_2bc4f: call DrawWideTextBox_PrintText .loop_input call DoFrame - farcall Func_8fb9 + farcall HandleStartButtonInDeckSelectionMenu jr c, .asm_2bc5c call HandleMenuInput jp nc, .loop_input ; can be jr @@ -3558,7 +3558,7 @@ Func_2bc4f: farcall CheckIfCurDeckIsEmpty jp nc, .valid ; can be jr ; deck is empty - farcall Func_9215 + farcall PrintThereIsNoDeckHereText jr .asm_2bc5c .valid diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index 4344161..297c924 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -4877,20 +4877,20 @@ Func_3ada1: ld a, [wScrollMenuScrollOffset] add b ld [wSelectedDeckMachineEntry], a - farcall Func_9287 + farcall ResetCheckMenuCursorPositionAndBlink call DrawWideTextBox ld hl, $6e7b call PlaceTextItems .asm_3aded: call DoFrame - farcall Func_9292 + farcall HandleCheckMenuInput jp nc, .asm_3aded cp $ff jr nz, .asm_3ae01 ld a, [wTempScrollMenuItem] jp .asm_3adb7 .asm_3ae01 - ld a, [wMusicStereoPanningBackup] + ld a, [wCheckMenuCursorYPosition] sla a ld hl, wCurSongBankBackup add [hl] @@ -5636,7 +5636,7 @@ SECTION "Bank e@72db", ROMX[$72db], BANK[$e] Func_3b2db: ld a, $ff - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen xor a .asm_3b2e2 ld hl, $735e @@ -5645,7 +5645,7 @@ Func_3b2db: call DrawWideTextBox_PrintText .asm_3b2ee call DoFrame - farcall Func_8fb9 + farcall HandleStartButtonInDeckSelectionMenu jr c, .asm_3b2e2 call HandleMenuInput jp nc, .asm_3b2ee @@ -5655,7 +5655,7 @@ Func_3b2db: ld [wCurDeck], a farcall CheckIfCurDeckIsEmpty jp nc, Func_3b315 - farcall Func_9215 + farcall PrintThereIsNoDeckHereText ld a, [wCurDeck] jr .asm_3b2e2 @@ -5871,7 +5871,7 @@ Func_3b45f: ldtx hl, YouMayOnlyCarry4DecksText call DrawWideTextBox_WaitForInput ld a, $ff - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen xor a .asm_3b46c ld hl, $735e @@ -5880,7 +5880,7 @@ Func_3b45f: call DrawWideTextBox_PrintText .asm_3b478 call DoFrame - farcall Func_8fb9 + farcall HandleStartButtonInDeckSelectionMenu jr c, .asm_3b46c call HandleMenuInput jp nc, .asm_3b478 @@ -5906,13 +5906,13 @@ Func_3b45f: push hl ld bc, $18 add hl, bc - farcall Func_9397 + farcall AddDeckToCollection pop hl ld a, $60 farcall ClearNBytesFromHL call DisableSRAM ld a, $ff - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen ld a, [wCurDeck] ld hl, $735e call InitializeMenuParameters @@ -6001,7 +6001,7 @@ Func_3b4eb: call CopyBBytesFromHLToDE_Bank0e call DisableSRAM ld a, $ff - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen ld a, [wd496] ld [wCurDeck], a ld hl, $735e @@ -6042,7 +6042,7 @@ Func_3b4eb: Func_3b5f1: call Func_3bcd6 - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen ldtx hl, DismantleTheseDecksPromptText call YesOrNoMenuWithText jr nc, .asm_3b601 @@ -6075,7 +6075,7 @@ Func_3b5f1: .asm_3b634 call DisableSRAM ld a, [wd49a] - farcall DrawDeckSelectionMenu + farcall DrawDecksScreen ldtx hl, DismantledTheseDecksText call DrawWideTextBox_WaitForInput or a @@ -6090,7 +6090,7 @@ Func_3b646: push hl ld bc, $18 add hl, bc - farcall Func_9397 + farcall AddDeckToCollection pop hl ld a, $60 farcall ClearNBytesFromHL @@ -6914,7 +6914,7 @@ Func_3bb09: ld a, [wScrollMenuScrollOffset] add b ld [wSelectedDeckMachineEntry], a - farcall Func_9287 + farcall ResetCheckMenuCursorPositionAndBlink xor a ld [wd0cd], a call DrawWideTextBox @@ -6929,7 +6929,7 @@ Func_3bb09: ld a, [wTempScrollMenuItem] jp .asm_3bb30 .asm_3bbe6 - ld a, [wMusicStereoPanningBackup] + ld a, [wCheckMenuCursorYPosition] sla a ld hl, wCurSongBankBackup add [hl] diff --git a/src/sram.asm b/src/sram.asm index 1975cfa..54c58ef 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -71,10 +71,12 @@ ENDR sCurrentlySelectedDeck:: ; b7a0 ds $1 -s0b7a1:: ; b7a1 - ds $1 - - ds $1 +; keeps track of how many unnamed decks have been built +; this is the number that gets appended at the end of +; an unnamed deck (i.e. DECK XXX) +; max number is MAX_UNNAMED_DECK_NUM +sUnnamedDeckCounter:: ; b7a1 + ds $2 ; each bit represents whether the player has ; obtained a card from a given set diff --git a/src/wram.asm b/src/wram.asm index 61ae601..44f1611 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1861,8 +1861,11 @@ wNumEntriesInCurFilter:: wBoosterPackCardListSize:: ; d0ee ds $1 -wd0ef:: ; d0ef - ds $2 +wCheckMenuCursorXPosition:: ; d0ef + ds $1 + +wCheckMenuCursorYPosition:: ; d0f0 + ds $1 ; deck selected by the player in the Decks screen wCurDeck:: ; d0f1 @@ -1940,7 +1943,7 @@ wCurCardTypeFilter:: ; d11a wTempCurMenuItem:: ; d11b ds $1 -wd11c:: ; d11c +wTempFilteredCardListNumCursorPositions:: ; d11c ds $1 ds $1 @@ -1948,7 +1951,7 @@ wd11c:: ; d11c wced7:: ; d11e ds $1 -wd11f:: ; d11f +wCardListVisibleOffsetBackup:: ; d11f ds $1 ; stores how many different cards there are in a deck @@ -2014,13 +2017,22 @@ wd381:: ; d381 wSameNameCardsLimit:: ; d382 ds $1 -wd383:: ; d383 +; whether to include the cards in the selected deck +; to appear in the filtered lists +; is TRUE when building a deck (since the cards should be shown for removal) +; is FALSE when choosing a deck configuration to send through Gift Center +; (can't select cards that are included in already built decks) +wIncludeCardsInDeck:: ; d383 ds $1 -wd384:: ; d384 +; pointer to a function that handles the menu +; when building a deck configuration +wDeckConfigurationMenuHandlerFunction:: ; d384 ds $2 -wd386:: ; d386 +; pointer to a transition table for the +; function in wDeckConfigurationMenuHandlerFunction +wDeckConfigurationMenuTransitionTable:: ; d386 ds $2 wCurCardListPtr:: ; d388 @@ -2106,6 +2118,8 @@ wNamingScreenNamePosition:: ; d3e9 wNamingScreenMode:: ; d3eb ds $1 +; see also sUnnamedDeckCounter +wTempUnnamedDeckCounter:: ; d3ec ds $3 wd3ef:: ; d3ef From 77b6460ecf19d26e08761d0d2b5b18693fc3f30c Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 14:48:57 -0600 Subject: [PATCH 08/27] disassemble DeckBuildingParams function --- src/engine/bank02.asm | 140 ++++++++++++++++++++++++++++++++++++++++-- src/engine/bank09.asm | 3 +- 2 files changed, 137 insertions(+), 6 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index ee04dad..aa92d77 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -595,8 +595,8 @@ DeckBuildingParams: db DECK_SIZE db MAX_NUM_SAME_NAME_CARDS db TRUE ; whether to include deck cards - db $31, $57 ; function - db $43, $5a ; data table + dw Func_9731 ; function + dw DeckConfigurationMenu_TransitionTable DeckSelectionMenu: ld hl, DeckBuildingParams @@ -1568,6 +1568,7 @@ HandleDeckBuildScreen: ld [wCurCardTypeFilter], a ; FILTER_GRASS call PrintFilteredCardList +.skip_draw ld hl, FiltersCardSelectionParams call InitializeScrollMenuParameters .wait_input @@ -1728,6 +1729,8 @@ OpenDeckConfigurationMenu: ld [hl], a ld a, $ff ld [wd0c4], a + +.skip_init xor a ld [wScrollMenuCursorBlinkCounter], a ld hl, wDeckConfigurationMenuHandlerFunction @@ -1735,9 +1738,47 @@ OpenDeckConfigurationMenu: ld h, [hl] ld l, a jp hl -; 0x9731 -SECTION "Bank 2@5787", ROMX[$5787], BANK[$2] +Func_9731: + call Func_98eb + ld de, $0 + ld bc, $1406 + call DrawRegularTextBox + ld hl, $5b18 + call PlaceTextItems +.asm_9743 + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call HandleMultiDirectionalMenu + jr nc, .asm_9743 + ld [wde84], a + cp $ff + jr nz, .asm_9769 + call DrawCardTypeIconsAndPrintCardCounts + ld a, [wTempCurMenuItem] + ld [wTempCardTypeFilter], a + ld a, [wCurCardTypeFilter] + call PrintFilteredCardList + jp HandleDeckBuildScreen.skip_draw +.asm_9769 + push af + call HandleMultiDirectionalMenu.DrawCursor + ld a, $01 + ld [wVBlankOAMCopyToggle], a + pop af + ld hl, .Data_977b + call JumpToFunctionInTable + jr OpenDeckConfigurationMenu.skip_init + +.Data_977b: + db $87, $57 + db $b9, $57 + db $a8, $58 + db $ce, $57 + db $27, $58 + db $bd, $57 + ConfirmDeckConfiguration: ld hl, wScrollMenuScrollOffset @@ -1762,6 +1803,87 @@ ConfirmDeckConfiguration: ret ; 0x97b9 +SECTION "Bank 2@58b0", ROMX[$58b0], BANK[$2] + +Func_98b0: + push de + push hl + ld hl, $58e8 + ld de, wDefaultText + call CopyListFromHLToDE + pop hl + call CopyListFromHLToDEInSRAM + ld hl, wDefaultText + call GetTextLengthInTiles + ld b, $00 + ld hl, wDefaultText + add hl, bc + ld d, h + ld e, l + ld hl, $58df + call CopyListFromHLToDE + pop de + ld hl, wDefaultText + call InitTextPrinting + call ProcessText + or a + ret +; 0x98df + +SECTION "Bank 2@58eb", ROMX[$58eb], BANK[$2] + +Func_98eb: + ld de, $6 + ld bc, $140c + call DrawRegularTextBox + ld hl, wCurDeckName + ld a, [hl] + or a + jr z, .asm_9910 + ld de, $106 + call Func_98b0 + ld hl, wCurDeckName + call GetTextLengthInTiles + ld a, $05 + add b + ld de, $106 + call ZeroAttributesAtDE +.asm_9910 + ld hl, wCurDeckCards + farcall CheckDeck.asm_25461 + ld de, $208 + call InitTextPrinting + ld hl, $537 + call ProcessTextFromID + ld a, [wDeckCheckEnergyCount] + ld de, $f08 + call Func_9951 + ld a, [wDeckCheckBasicCount] + ld de, $f0a + call Func_9951 + ld a, [wDeckCheckStage1Count] + ld de, $f0c + call Func_9951 + ld a, [wDeckCheckStage2Count] + ld de, $0f0e + call Func_9951 + ld a, [wDeckCheckTrainerCount] + ld de, $f10 + call Func_9951 + ret + +Func_9951: + push de + ld hl, wDefaultText + call ConvertToNumericalDigits + ld [hl], $00 + pop de + call InitTextPrinting + ld hl, wDefaultText + call ProcessText + ret +; 0x9965 + SECTION "Bank 2@5a0f", ROMX[$5a0f], BANK[$2] Func_9a0f: @@ -1797,7 +1919,15 @@ FiltersCardSelectionParams: db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction -SECTION "Bank 2@5a6d", ROMX[$5a6d], BANK[$2] +SECTION "Bank 2@5a43", ROMX[$5a43], BANK[$2] + +DeckConfigurationMenu_TransitionTable: + cursor_transition $10, $20, $00, $03, $03, $01, $02 + cursor_transition $48, $20, $00, $04, $04, $02, $00 + cursor_transition $80, $20, $00, $05, $05, $00, $01 + cursor_transition $10, $30, $00, $00, $00, $04, $05 + cursor_transition $48, $30, $00, $01, $01, $05, $03 + cursor_transition $80, $30, $00, $02, $02, $03, $04 ; draws each card type icon in a line ; the respective card counts underneath each icon diff --git a/src/engine/bank09.asm b/src/engine/bank09.asm index f80fcb3..38146bb 100644 --- a/src/engine/bank09.asm +++ b/src/engine/bank09.asm @@ -2185,7 +2185,7 @@ CheckDeck: ; of each type there are (Basic, Stage1, Stage2, Energy, Trainer) ; and within Energy cards, count each color as well ; outputs all results in wDeckCheckCardCounts -.GetDeckCardCounts: +.GetDeckCardCounts ld e, l ld d, h ld hl, wPlayerDeck @@ -2195,6 +2195,7 @@ CheckDeck: call DisableSRAM pop hl +.asm_25461 push hl ld hl, wDeckCheckCardCounts ld c, wDeckCheckCardCountsEnd - wDeckCheckCardCounts From b2c3808230f97ffc842034ac706196669e3b9a72 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 15:08:54 -0600 Subject: [PATCH 09/27] disassemble function map --- src/engine/bank02.asm | 248 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 237 insertions(+), 11 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index aa92d77..bca774e 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1561,6 +1561,7 @@ HandleDeckBuildScreen: ld [hffbf], a call WriteCardListsTerminatorBytes call CountNumberOfCardsForEachCardType +.asm_95e0 call DrawCardTypeIconsAndPrintCardCounts xor a @@ -1755,6 +1756,7 @@ Func_9731: ld [wde84], a cp $ff jr nz, .asm_9769 +.asm_9757 call DrawCardTypeIconsAndPrintCardCounts ld a, [wTempCurMenuItem] ld [wTempCardTypeFilter], a @@ -1772,13 +1774,12 @@ Func_9731: jr OpenDeckConfigurationMenu.skip_init .Data_977b: - db $87, $57 - db $b9, $57 - db $a8, $58 - db $ce, $57 - db $27, $58 - db $bd, $57 - + dw ConfirmDeckConfiguration + dw Func_97b9 + dw Func_98a8 + dw Func_97ce + dw Func_9827 + dw Func_97bd ConfirmDeckConfiguration: ld hl, wScrollMenuScrollOffset @@ -1801,9 +1802,126 @@ ConfirmDeckConfiguration: ld a, [wde84] ld [wTempCardTypeFilter], a ret -; 0x97b9 -SECTION "Bank 2@58b0", ROMX[$58b0], BANK[$2] +Func_97b9: + add sp, $02 + jr Func_9731.asm_9757 + +Func_97bd: + call Func_9965 + jr nc, .asm_97ca + ld hl, $2a6 + call YesOrNoMenuWithText + jr c, Func_97ce.asm_9809 +.asm_97ca + add sp, $02 + or a + ret + +Func_97ce: + ld a, [wTotalCardCount] + cp $3c + jp z, .asm_97f0 + ld hl, $2a2 + call DrawWideTextBox_WaitForInput + ld hl, $2a4 + call YesOrNoMenuWithText + jr c, .asm_97e8 + add sp, $02 + or a + ret +.asm_97e8 + ld hl, $2a3 + call DrawWideTextBox_WaitForInput + jr .asm_9809 +.asm_97f0 + ld hl, $2a5 + call YesOrNoMenuWithText + jr c, .asm_9809 + call Func_9a0f + jr c, .asm_9816 + ld hl, $2a0 + call DrawWideTextBox_WaitForInput + ld hl, $2a1 + call DrawWideTextBox_WaitForInput +.asm_9809 + call DrawCardTypeIconsAndPrintCardCounts + call PrintDeckBuildingCardList + ld a, [wde84] + ld [wTempCardTypeFilter], a + ret +.asm_9816 + ld hl, $2a8 + call YesOrNoMenuWithText + jr c, .asm_9823 + ld a, $01 + ld [hffbf], a +.asm_9823 + add sp, $02 + scf + ret + +Func_9827: + ld hl, $2a7 + call YesOrNoMenuWithText + jr c, Func_97ce.asm_9809 + call Func_99ed + jp nc, Func_985a + ld hl, $29f + call DrawWideTextBox_WaitForInput + call EmptyScreen + ld hl, FiltersCardSelectionParams + call InitializeScrollMenuParameters + ld a, [wCurCardTypeFilter] + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible + call PrintDeckBuildingCardList + call EnableLCD + ld a, [wde84] + ld [wTempCardTypeFilter], a + ret + +Func_985a: + call EnableSRAM + call GetSRAMPointerToCurDeck + ld a, [hl] + or a + jr z, .asm_9871 + push hl + call GetSRAMPointerToCurDeckCards + call AddDeckToCollection + pop hl + ld a, $60 + call ClearNBytesFromHL +.asm_9871 + ld hl, $2a9 + call YesOrNoMenuWithText + jr c, .asm_989d + ld a, [wCurDeckName] + or a + jr z, .asm_98a0 + ld a, [wTotalCardCount] + cp $3c + jp nz, .asm_98a0 + call Func_9a0f + jr nc, .asm_98a0 + ld hl, wCurDeckName + ld de, wCurDeckCards + farcall Func_3be8d + call DisableSRAM + farcall Func_3bead +.asm_989d + add sp, $02 + ret +.asm_98a0 + ld hl, $2aa + call DrawWideTextBox_WaitForInput + jr .asm_989d + +Func_98a8: + call InputCurDeckName + add sp, $02 + jp HandleDeckBuildScreen.asm_95e0 Func_98b0: push de @@ -1882,9 +2000,117 @@ Func_9951: ld hl, wDefaultText call ProcessText ret -; 0x9965 -SECTION "Bank 2@5a0f", ROMX[$5a0f], BANK[$2] +Func_9965: + ld a, [wTotalCardCount] + or a + jr z, .asm_996f + cp $3c + jr nz, .asm_99e8 +.asm_996f + call GetSRAMPointerToCurDeckCards + ld d, h + ld e, l + ld hl, wc000 + call EnableSRAM + bank1call DecompressSRAMDeck + call DisableSRAM + ld a, $ff + ld [$c078], a + ld [$c079], a + ld hl, wCurDeckCards +.asm_998b + ld e, [hl] + inc hl + ld d, [hl] + inc hl + call CheckIfCardIDIsZero + jr c, .asm_99b7 + push hl + ld hl, wc000 +.asm_9998 + ld c, [hl] + inc hl + ld b, [hl] + inc hl + ld a, b + cp $ff + ld a, c + jr nz, .asm_99a9 + cp $ff + jr nz, .asm_99a9 + pop hl + jr .asm_998b +.asm_99a9 + cp e + jr nz, .asm_9998 + ld a, b + cp d + jr nz, .asm_9998 + dec hl + xor a + ld [hld], a + ld [hl], a + pop hl + jr .asm_998b +.asm_99b7 + ld hl, wc000 +.asm_99ba + ld e, [hl] + inc hl + ld d, [hl] + inc hl + cp16 $ffff + jr z, .asm_99d2 + call CheckIfCardIDIsZero + jr nc, .asm_99e8 + or a + jr nz, .asm_99e8 + jr .asm_99ba +.asm_99d2 + call GetSRAMPointerToCurDeck + ld de, wCurDeckName + call EnableSRAM +.asm_99db + ld a, [de] + cp [hl] + jr nz, .asm_99e8 + inc de + inc hl + or a + jr nz, .asm_99db + call DisableSRAM + ret +.asm_99e8 + call DisableSRAM + scf + ret + +Func_99ed: + ld hl, wDecksValid + ld bc, $0 +.asm_99f3 + inc b + ld a, $04 + cp b + jr c, .asm_9a05 + ld a, [hli] + or a + jr z, .asm_99f3 + inc c + ld a, $01 + cp c + jr nc, .asm_99f3 +.asm_9a03 + or a + ret +.asm_9a05 + call GetSRAMPointerToCurDeckCards + call CheckIfDeckHasCards + jr c, .asm_9a03 + scf + ret +; 0x9a0f Func_9a0f: ld hl, wCurDeckCards From a7af3d69a25ea20ad2499ea6a4cd8abbae96cd22 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 21:48:10 -0600 Subject: [PATCH 10/27] documenting code that came from disassembling the DeckBuildingParams function like previous commits, most of these names were copied from poketcg1 (where the code was the same) --- src/engine/bank02.asm | 248 ++++++++++++++++++++++++------------------ src/engine/bank0e.asm | 2 +- src/wram.asm | 2 + 3 files changed, 146 insertions(+), 106 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index bca774e..a278d7b 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -595,7 +595,7 @@ DeckBuildingParams: db DECK_SIZE db MAX_NUM_SAME_NAME_CARDS db TRUE ; whether to include deck cards - dw Func_9731 ; function + dw HandleDeckConfigurationMenu dw DeckConfigurationMenu_TransitionTable DeckSelectionMenu: @@ -1561,7 +1561,7 @@ HandleDeckBuildScreen: ld [hffbf], a call WriteCardListsTerminatorBytes call CountNumberOfCardsForEachCardType -.asm_95e0 +.skip_count call DrawCardTypeIconsAndPrintCardCounts xor a @@ -1740,46 +1740,48 @@ OpenDeckConfigurationMenu: ld l, a jp hl -Func_9731: +HandleDeckConfigurationMenu: call Func_98eb - ld de, $0 - ld bc, $1406 + lb de, 0, 0 + lb bc, 20, 6 call DrawRegularTextBox - ld hl, $5b18 + ld hl, DeckBuildMenuTextItems call PlaceTextItems -.asm_9743 + +.do_frame ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame call HandleMultiDirectionalMenu - jr nc, .asm_9743 + jr nc, .do_frame ld [wde84], a cp $ff jr nz, .asm_9769 -.asm_9757 +.draw_icons call DrawCardTypeIconsAndPrintCardCounts ld a, [wTempCurMenuItem] ld [wTempCardTypeFilter], a ld a, [wCurCardTypeFilter] call PrintFilteredCardList jp HandleDeckBuildScreen.skip_draw + .asm_9769 push af call HandleMultiDirectionalMenu.DrawCursor ld a, $01 ld [wVBlankOAMCopyToggle], a pop af - ld hl, .Data_977b + ld hl, .function_table call JumpToFunctionInTable jr OpenDeckConfigurationMenu.skip_init -.Data_977b: +.function_table: dw ConfirmDeckConfiguration - dw Func_97b9 - dw Func_98a8 - dw Func_97ce - dw Func_9827 - dw Func_97bd + dw ModifyDeckConfiguration + dw ChangeDeckName + dw SaveDeckConfiguration + dw DismantleDeck + dw CancelDeckModifications ConfirmDeckConfiguration: ld hl, wScrollMenuScrollOffset @@ -1803,85 +1805,94 @@ ConfirmDeckConfiguration: ld [wTempCardTypeFilter], a ret -Func_97b9: +ModifyDeckConfiguration: add sp, $02 - jr Func_9731.asm_9757 + jr HandleDeckConfigurationMenu.draw_icons -Func_97bd: - call Func_9965 - jr nc, .asm_97ca - ld hl, $2a6 +; returns carry set if player chose to go back +CancelDeckModifications: +; if deck was not changed, cancel modification immediately + call CheckIfCurrentDeckWasChanged + jr nc, .cancel_modification + ldtx hl, DeckBuildingQuitPromptText call YesOrNoMenuWithText - jr c, Func_97ce.asm_9809 -.asm_97ca + jr c, SaveDeckConfiguration.go_back +.cancel_modification add sp, $02 or a ret -Func_97ce: +SaveDeckConfiguration: +; handle deck configuration size ld a, [wTotalCardCount] - cp $3c - jp z, .asm_97f0 - ld hl, $2a2 + cp DECK_SIZE + jp z, .ask_to_save_deck + ldtx hl, DeckBuildingWarningNot60CardsText call DrawWideTextBox_WaitForInput - ld hl, $2a4 + ldtx hl, DeckBuildingRevertPromptText call YesOrNoMenuWithText - jr c, .asm_97e8 + jr c, .print_deck_size_warning +; return no carry add sp, $02 or a ret -.asm_97e8 - ld hl, $2a3 + +.print_deck_size_warning + ldtx hl, DeckBuildingWarningMustInclude60CardsText call DrawWideTextBox_WaitForInput - jr .asm_9809 -.asm_97f0 - ld hl, $2a5 + jr .go_back + +.ask_to_save_deck + ldtx hl, DeckBuildingSavePromptText call YesOrNoMenuWithText - jr c, .asm_9809 - call Func_9a0f - jr c, .asm_9816 - ld hl, $2a0 + jr c, .go_back + call CheckIfThereAreAnyBasicCardsInDeck + jr c, .ask_to_save_to_deck_machine + ldtx hl, DeckBuildingWarningNoBasicPokemonText call DrawWideTextBox_WaitForInput - ld hl, $2a1 + ldtx hl, DeckBuildingWarningMustIncludeBasicPokemonText call DrawWideTextBox_WaitForInput -.asm_9809 + +.go_back call DrawCardTypeIconsAndPrintCardCounts call PrintDeckBuildingCardList ld a, [wde84] - ld [wTempCardTypeFilter], a + ld [wCardListCursorPos], a ret -.asm_9816 - ld hl, $2a8 + +.ask_to_save_to_deck_machine + ldtx hl, DeckBuildingSaveToMachinePromptText call YesOrNoMenuWithText - jr c, .asm_9823 + jr c, .set_carry ld a, $01 ld [hffbf], a -.asm_9823 + +.set_carry add sp, $02 scf ret -Func_9827: - ld hl, $2a7 +DismantleDeck: + ldtx hl, DeckBuildingDismantlePromptText call YesOrNoMenuWithText - jr c, Func_97ce.asm_9809 - call Func_99ed - jp nc, Func_985a - ld hl, $29f + jr c, SaveDeckConfiguration.go_back + call CheckIfHasOtherValidDecks + jp nc, .Dismantle + ldtx hl, DeckBuildingWarningTheOnlyDeckNotDismantleableText call DrawWideTextBox_WaitForInput call EmptyScreen ld hl, FiltersCardSelectionParams call InitializeScrollMenuParameters ld a, [wCurCardTypeFilter] - ld [wTempCardTypeFilter], a + ld [wCardListCursorPos], a call DrawHorizontalListCursor_Visible call PrintDeckBuildingCardList call EnableLCD ld a, [wde84] - ld [wTempCardTypeFilter], a + ld [wCardListCursorPos], a ret -Func_985a: +.Dismantle call EnableSRAM call GetSRAMPointerToCurDeck ld a, [hl] @@ -1893,17 +1904,18 @@ Func_985a: pop hl ld a, $60 call ClearNBytesFromHL + .asm_9871 - ld hl, $2a9 + ldtx hl, DeckBuildingRevertAndSaveToMachinePromptText call YesOrNoMenuWithText jr c, .asm_989d ld a, [wCurDeckName] or a jr z, .asm_98a0 ld a, [wTotalCardCount] - cp $3c + cp DECK_SIZE jp nz, .asm_98a0 - call Func_9a0f + call CheckIfThereAreAnyBasicCardsInDeck jr nc, .asm_98a0 ld hl, wCurDeckName ld de, wCurDeckCards @@ -1914,19 +1926,20 @@ Func_985a: add sp, $02 ret .asm_98a0 - ld hl, $2aa + ldtx hl, DeckBuildingWarningIncompleteCannotSaveToMachineText call DrawWideTextBox_WaitForInput jr .asm_989d -Func_98a8: +ChangeDeckName: call InputCurDeckName add sp, $02 - jp HandleDeckBuildScreen.asm_95e0 + jp HandleDeckBuildScreen.skip_count +; de - coordinates Func_98b0: push de push hl - ld hl, $58e8 + ld hl, .Data_98e8 ld de, wDefaultText call CopyListFromHLToDE pop hl @@ -1938,7 +1951,7 @@ Func_98b0: add hl, bc ld d, h ld e, l - ld hl, $58df + ld hl, .DeckNameSuffix call CopyListFromHLToDE pop de ld hl, wDefaultText @@ -1946,32 +1959,40 @@ Func_98b0: call ProcessText or a ret -; 0x98df -SECTION "Bank 2@58eb", ROMX[$58eb], BANK[$2] +.DeckNameSuffix + katakana "デ" + katakana "ッ" + katakana "キ" + katakana " " + done + +.Data_98e8: + katakana " " + done Func_98eb: - ld de, $6 - ld bc, $140c + lb de, 0, 6 + lb bc, 20, 12 call DrawRegularTextBox ld hl, wCurDeckName ld a, [hl] or a jr z, .asm_9910 - ld de, $106 + lb de, 1, 6 call Func_98b0 ld hl, wCurDeckName call GetTextLengthInTiles - ld a, $05 + ld a, 5 add b - ld de, $106 + lb de, 1, 6 call ZeroAttributesAtDE .asm_9910 ld hl, wCurDeckCards farcall CheckDeck.asm_25461 - ld de, $208 + lb de, 2, 8 call InitTextPrinting - ld hl, $537 + ldtx hl, DeckDiagnosisBreakdownText call ProcessTextFromID ld a, [wDeckCheckEnergyCount] ld de, $f08 @@ -1983,7 +2004,7 @@ Func_98eb: ld de, $f0c call Func_9951 ld a, [wDeckCheckStage2Count] - ld de, $0f0e + ld de, $f0e call Func_9951 ld a, [wDeckCheckTrainerCount] ld de, $f10 @@ -2001,13 +2022,16 @@ Func_9951: call ProcessText ret -Func_9965: +; returns carry if current deck was changed +; either through its card configuration or its name +CheckIfCurrentDeckWasChanged: ld a, [wTotalCardCount] or a - jr z, .asm_996f - cp $3c - jr nz, .asm_99e8 -.asm_996f + jr z, .skip_size_check + cp DECK_SIZE + jr nz, .set_carry + +.skip_size_check call GetSRAMPointerToCurDeckCards ld d, h ld e, l @@ -2063,75 +2087,83 @@ Func_9965: cp16 $ffff jr z, .asm_99d2 call CheckIfCardIDIsZero - jr nc, .asm_99e8 + jr nc, .set_carry or a - jr nz, .asm_99e8 + jr nz, .set_carry jr .asm_99ba .asm_99d2 call GetSRAMPointerToCurDeck ld de, wCurDeckName call EnableSRAM -.asm_99db +.loop_name ld a, [de] cp [hl] - jr nz, .asm_99e8 + jr nz, .set_carry inc de inc hl or a - jr nz, .asm_99db + jr nz, .loop_name call DisableSRAM ret -.asm_99e8 +.set_carry call DisableSRAM scf ret -Func_99ed: +; returns carry if doesn't have a valid deck +; aside from the current deck +CheckIfHasOtherValidDecks: ld hl, wDecksValid - ld bc, $0 -.asm_99f3 + lb bc, 0, 0 +.loop inc b - ld a, $04 + ld a, NUM_DECKS cp b - jr c, .asm_9a05 + jr c, .check_has_cards ld a, [hli] or a - jr z, .asm_99f3 + jr z, .loop + ; is valid inc c - ld a, $01 + ld a, 1 cp c - jr nc, .asm_99f3 -.asm_9a03 + jr nc, .loop; just 1 valid + ; at least 2 decks are valid +.no_carry or a ret -.asm_9a05 + +.check_has_cards +; doesn't have at least 2 valid decks +; check if current deck is the only one +; that is valid (i.e. has cards) call GetSRAMPointerToCurDeckCards call CheckIfDeckHasCards - jr c, .asm_9a03 + jr c, .no_carry ; no cards + ; has cards, is the only valid deck! scf ret -; 0x9a0f -Func_9a0f: +CheckIfThereAreAnyBasicCardsInDeck: ld hl, wCurDeckCards -.asm_9a12 +.loop_cards ld e, [hl] inc hl ld d, [hl] inc hl call CheckIfCardIDIsZero - jr c, .asm_9a2f + jr c, .no_carry call LoadCardDataToBuffer1_FromCardID - jr c, .asm_9a2f + jr c, .no_carry ld a, [wLoadedCard1Type] and TYPE_ENERGY - jr nz, .asm_9a12 + jr nz, .loop_cards ld a, [wLoadedCard1Stage] or a - jr nz, .asm_9a12 + jr nz, .loop_cards scf ret -.asm_9a2f +.no_carry or a ret @@ -2270,9 +2302,15 @@ DrawCardTypeIcons: db ICON_TILE_TRAINER, 15, 2 db ICON_TILE_ENERGY, 17, 2 db $00 -; 0x9b18 -SECTION "Bank 2@5b31", ROMX[$5b31], BANK[$2] +DeckBuildMenuTextItems: + textitem 2, 2, DeckBuildingConfirmText + textitem 9, 2, DeckBuildingContinueModifyingText + textitem 16, 2, DeckBuildingNameText + textitem 2, 4, DeckBuildingSaveText + textitem 9, 4, DeckBuildingDismantleText + textitem 16, 4, CancelDeckText + db $ff ; prints "/60" to the coordinates given in de PrintSlashSixty: diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index 297c924..59d03a3 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -6134,7 +6134,7 @@ Func_3b661: ld de, wCurDeckCards ld b, $80 call CopyBBytesFromHLToDE_Bank0e - farcall Func_9a0f + farcall CheckIfThereAreAnyBasicCardsInDeck jr c, .asm_3b6c0 ldtx hl, CannotBuildLackingBasicPokemonText call DrawWideTextBox_WaitForInput diff --git a/src/wram.asm b/src/wram.asm index 44f1611..1fc71ac 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1819,6 +1819,8 @@ wNamingScreenCursorBlinkCounter:: ; d0e3 ; to check whether a new filter is to be applied wTempCardTypeFilter:: ; d0e4 +wCardListCursorPos:: ; d0e4 + wCurScrollMenuItem:: ; d0e4 wNamingScreenCursorY:: ; d0e4 From 6718adb2c0145f6a0094d00ba1117dd7bc5dee35 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 14 Nov 2025 22:11:26 -0600 Subject: [PATCH 11/27] disassemble .minicon_functions --- src/engine/bank02.asm | 126 +++++++- src/engine/bank07.asm | 715 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 830 insertions(+), 11 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index a278d7b..9756d8a 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -4401,9 +4401,131 @@ CopyBBytesFromHLToDE_Bank02: dec b jr nz, .loop ret -; 0xa786 -SECTION "Bank 2@689d", ROMX[$689d], BANK[$2] +Func_a786: + call WriteCardListsTerminatorBytes + call PrintPlayersCardsHeaderInfo + xor a + ld [wScrollMenuScrollOffset], a + ld [wCurCardTypeFilter], a + call PrintFilteredCardSelectionList + call EnableLCD + xor a + ld hl, FiltersCardSelectionParams + call InitializeScrollMenuParameters +.asm_a7a0 + call DoFrame + ld a, [wCurCardTypeFilter] + ld b, a + ld a, [wTempCardTypeFilter] + cp b + jr z, .asm_a7ca + ld [wCurCardTypeFilter], a + ld hl, wScrollMenuScrollOffset + ld [hl], $00 + call PrintFilteredCardSelectionList + ld hl, hffbb + ld [hl], $01 + call PrintPlayersCardsText + ld hl, hffbb + ld [hl], $00 + ld a, $09 + ld [wNumMenuItems], a +.asm_a7ca + ldh a, [hDPadHeld] + and $80 + jr z, .asm_a7d5 + call ConfirmSelectionAndReturnCarry + jr .asm_a7e2 +.asm_a7d5 + call HandleCardSelectionInput + jr nc, .asm_a7a0 + ld a, [hCurMenuItem] + cp $ff + jr nz, .asm_a7e2 + ret +.asm_a7e2 + ld a, [wNumEntriesInCurFilter] + or a + jr z, .asm_a7a0 + xor a + ld hl, GeneralCardListMenuParams + call InitializeScrollMenuParameters + ld a, [wNumEntriesInCurFilter] + ld [wNumCardListEntries], a + ld hl, wNumVisibleCardListEntries + cp [hl] + jr nc, .asm_a7fe + ld [wNumMenuItems], a +.asm_a7fe + ld hl, GeneralCardListUpdateFunc + ld d, h + ld a, l + ld hl, wScrollMenuScrollFunc + ld [hli], a + ld [hl], d + xor a + ld [wd119], a +.asm_a80c + call DoFrame + ldh a, [hDPadHeld] + and $40 + jr z, .asm_a825 + ld a, [wTempCardTypeFilter] + ld hl, wScrollMenuScrollOffset + add [hl] + jr nz, .asm_a825 + ld a, $ff + ld [hCurMenuItem], a + jr .asm_a87e +.asm_a825 + call HandleSelectUpAndDownInList + jr c, .asm_a80c + call HandleScrollListInput + jr c, .asm_a87e + ldh a, [hDPadHeld] + and $08 + jr z, .asm_a80c +.asm_a835 + ld a, $01 + call PlayConfirmOrCancelSFX + ld a, [wNumMenuItems] + ld [wTempScrollMenuNumVisibleItems], a + ld a, [wTempCardTypeFilter] + ld [wTempCurMenuItem], a + ld de, wTempCardList + ld hl, wCurCardListPtr + ld [hl], e + inc hl + ld [hl], d + call OpenCardPageFromCardList + call PrintPlayersCardsHeaderInfo + ld hl, FiltersCardSelectionParams + call InitializeScrollMenuParameters + ld a, [wCurCardTypeFilter] + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible + call PrintCardSelectionList + call EnableLCD + ld hl, GeneralCardListMenuParams + call InitializeScrollMenuParameters + ld a, [wTempScrollMenuNumVisibleItems] + ld [wNumMenuItems], a + ld a, [wTempCurMenuItem] + ld [wTempCardTypeFilter], a + jr .asm_a80c +.asm_a87e + call DrawListCursor_Invisible + ld a, [wTempCardTypeFilter] + ld [wTempCurMenuItem], a + ld a, [hCurMenuItem] + cp $ff + jr nz, .asm_a835 + ld hl, FiltersCardSelectionParams + call InitializeScrollMenuParameters + ld a, [wCurCardTypeFilter] + ld [wTempCardTypeFilter], a + jp .asm_a7a0 GeneralCardListMenuParams: db 1 ; x pos diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 9de2a93..f492a88 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -5654,18 +5654,20 @@ CallMiniconMenuFunction: ret .minicon_functions: - db $00, $07, $37, $68 - db $01, $07, $96, $6c - db $02, $07, $40, $68 + key_func $00, Func_1e837 + key_func $01, Func_1ec96 + key_func $02, Func_1e840 db $ff Func_1e837: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall Func_baec ret -; 0x1e840 -SECTION "Bank 7@6849", ROMX[$6849], BANK[$7] +Func_1e840: + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + farcall Func_a786 + ret Func_1e849: farcall Func_1022a @@ -6140,7 +6142,20 @@ Func_1ec0f: ret ; 0x1ec38 -SECTION "Bank 7@6ca5", ROMX[$6ca5], BANK[$7] +SECTION "Bank 7@6c96", ROMX[$6c96], BANK[$7] + +Func_1ec96: + push af + push bc + push de + push hl + call Func_1ece4 + call Func_1eda5 + pop hl + pop de + pop bc + pop af + ret Func_1eca5: push af @@ -6172,9 +6187,680 @@ Func_1eca5: pop bc pop af ret -; 0x1ece4 -SECTION "Bank 7@724e", ROMX[$724e], BANK[$7] +Func_1ece4: + call DisableLCD + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + call Func_1ed18 + call Func_1ed2d + call FlushAllPalettes + call EnableLCD + ld a, [wdd5a] + and a + jr z, .asm_1ed04 + push af + ld a, $82 + call CallPlaySFX + pop af +.asm_1ed04 + call Func_1ed57 + call DisableLCD + xor a + ld [wdd5a], a + ld [wdd5c], a + ld [wdd5d], a + ld [wdd5b], a + ret + +Func_1ed18: + ld b, $00 + ld a, [wdd5b] + and a + jr nz, .asm_1ed28 + inc b + ld a, [wdd5a] + and a + jr nz, .asm_1ed28 + inc b +.asm_1ed28 + ld a, b + ld [$dd31], a + ret + +Func_1ed2d: + ld de, $0 + ld bc, $1404 + call DrawRegularTextBoxVRAM0 + ld hl, $72b + ld de, $602 + call InitTextPrinting_ProcessTextFromIDVRAM0 + ld de, $c + ld bc, $1406 + call DrawRegularTextBoxVRAM0 + call Func_1ed5e + call Func_1ed4f + ret + +Func_1ed4f: + ld bc, $505 + ld a, [hli] + call LoadScene + ret + +Func_1ed57: + ld a, [hli] + ld h, [hl] + ld l, a + farcall PrintScrollableText_NoTextBoxLabelVRAM0 +; fallthrough + +Func_1ed5e: + ld a, [$dd31] + add a + ld c, a + ld b, $00 + ld hl, $6d6d + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ret +; 0x1ed6d + +SECTION "Bank 7@6da5", ROMX[$6da5], BANK[$7] + +Func_1eda5: + call DisableLCD + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + ld de, $40ff + call SetupText + call Func_1edd1 + call FlushAllPalettes + call EnableLCD +.asm_1edbb + call Func_1ede4 + call Func_1eef8 + jr c, .asm_1edd0 + call Func_1efa4 + call Func_1efd9 + jr c, .asm_1edbb + call Func_1efe1 + jr .asm_1edbb +.asm_1edd0 + ret + +Func_1edd1: + ld de, $4 + ld bc, $140e + call DrawRegularTextBoxVRAM0 + ld de, $0 + ld bc, $1405 + call DrawRegularTextBoxVRAM0 + ret + +Func_1ede4: + push af + push bc + push de + push hl + ld de, $105 + ld b, $07 + ld hl, $6ed8 + call LoadMenuBoxParams + ld a, [wdd5d] + call DrawMenuBox + ld de, $0 + ld bc, $1405 + call DrawRegularTextBoxVRAM0 + ld hl, $72f + ld a, [wdd50] + and a + jr nz, .asm_1ee0e + ld hl, $73a +.asm_1ee0e + ld de, $102 + call InitTextPrinting_ProcessTextFromIDVRAM0 + ld hl, $72b + ld de, $100 + call Func_2c4b + ld a, [wdd5c] + add a + add a + ld c, a + ld b, $00 + ld hl, wdd51 + add hl, bc + ld de, $206 + ld c, $04 +.asm_1ee2e + ld a, [hli] + and a + jr z, .asm_1ee38 + call Func_1ee4a + dec c + jr nz, .asm_1ee2e +.asm_1ee38 + ld a, $04 + sub c + and a + jr nz, .asm_1ee3f + inc a +.asm_1ee3f + call SetMenuBoxNumItems + call Func_1ee97 + pop hl + pop de + pop bc + pop af + ret + +Func_1ee4a: + push bc + push hl + ld hl, $730 + call InitTextPrinting_ProcessTextFromIDVRAM0 + inc e + ld hl, $731 + call InitTextPrinting_ProcessTextFromIDVRAM0 + and a + jr z, .asm_1ee68 + bit 7, a + jr nz, .asm_1ee68 + dec d + ld hl, $738 + call InitTextPrinting_ProcessTextFromIDVRAM0 + inc d +.asm_1ee68 + ld hl, $734f + and $7f + ld c, a + ld b, $00 + sla c + rl b + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld a, d + add $05 + ld d, a + dec e + push hl + ld a, [hli] + ld h, [hl] + ld l, a + call InitTextPrinting_ProcessTextFromIDVRAM0 + pop hl + inc hl + inc hl + inc e + ld a, [hli] + ld h, [hl] + ld l, a + call InitTextPrinting_ProcessTextFromIDVRAM0 + inc e + inc e + ld a, d + sub $05 + ld d, a + pop hl + pop bc + ret + +Func_1ee97: + ld bc, $111 + ld d, $1d + ld e, $01 + call Func_383b + ld a, [wdd5c] + cp $01 + jr nz, .asm_1eebd + ld bc, $104 + ld d, $2f + ld e, $41 + call Func_383b + ld bc, $111 + ld d, $1d + ld e, $01 + call Func_383b + ret +.asm_1eebd + ld a, [wdd50] + cp $05 + ret c + ld bc, $111 + ld d, $2f + ld e, $01 + call Func_383b + ld bc, $104 + ld d, $1d + ld e, $01 + call Func_383b + ret +; 0x1eed8 + +SECTION "Bank 7@6ef8", ROMX[$6ef8], BANK[$7] + +Func_1eef8: +.asm_1eef8 + ld a, [wdd5d] + call HandleMenuBox + ld [wdd5d], a + jr c, .asm_1ef22 + call Func_1f342 + ld c, a + ld b, $00 + ld hl, wdd51 + add hl, bc + ld a, [hl] + and a + jr nz, .asm_1ef1a + push af + ld a, $04 + call CallPlaySFX + pop af + jr .asm_1eef8 +.asm_1ef1a + push af + ld a, $02 + call CallPlaySFX + pop af + ret +.asm_1ef22 + push af + ld a, $03 + call CallPlaySFX + pop af + ret +; 0x1ef2a + +SECTION "Bank 7@6fa4", ROMX[$6fa4], BANK[$7] + +Func_1efa4: + ld de, $0 + ld b, $07 + ld hl, $6fbd + call LoadMenuBoxParams + xor a + call DrawMenuBox + ld hl, $732 + ld de, $101 + call InitTextPrinting_ProcessTextFromIDVRAM0 + ret +; 0x1efbd + +SECTION "Bank 7@6fd9", ROMX[$6fd9], BANK[$7] + +Func_1efd9: + xor a + call HandleMenuBox + ld [wdd5e], a + ret + +Func_1efe1: + ld a, [wdd5e] + ld hl, .Data_1efeb + call CallMappedFunction + ret + +.Data_1efeb: + key_func $00, Func_1eff4 + key_func $01, Func_1f161 + db $ff + +Func_1eff4: + call Func_1effb + call Func_1f023 + ret + +Func_1effb: + ld de, $407f + call SetupText + ld de, $0 + ld bc, $1405 + call DrawRegularTextBoxVRAM0 + ld hl, $72b + ld de, $100 + call Func_2c4b + ld hl, $701a + call PlaceTextItemsVRAM0 + ret +; 0x1f01a + +SECTION "Bank 7@7023", ROMX[$7023], BANK[$7] + +Func_1f023: + ld bc, $111 + ld d, $1d + ld e, $01 + call Func_383b + call Func_1f342 + ld c, a + ld b, $00 + ld hl, wdd51 + add hl, bc + ld a, [hl] + ld [$dd30], a + set 7, a + ld [hl], a + add a + ld c, a + ld b, $00 + ld hl, $734f + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [hli] + ld [$dd32], a + ld a, [hli] + ld [$dd33], a + call Func_1f07a + ld a, [hli] + ld [$dd34], a + ld a, [hli] + ld [$dd35], a + call Func_1f08b +.asm_1f05f + ld a, [hl] + cp $ff + jr nz, .asm_1f06a + inc hl + ld a, [hld] + cp $ff + jr z, .asm_1f079 +.asm_1f06a + call Func_1f0a7 + jr z, .asm_1f074 + push hl + call WaitForWideTextBoxInput + pop hl +.asm_1f074 + call Func_1f0c3 + jr .asm_1f05f +.asm_1f079 + ret + +Func_1f07a: + push hl + ld a, [$dd32] + ld l, a + ld a, [$dd33] + ld h, a + ld de, $602 + call InitTextPrinting_ProcessTextFromIDVRAM0 + pop hl + ret + +Func_1f08b: + push hl + ld a, [$dd34] + ld l, a + ld a, [$dd35] + ld h, a + ld de, $603 + call InitTextPrinting_ProcessTextFromIDVRAM0 + pop hl + ret + +Func_1f09c: + ld de, $105 + ld bc, $120c + farcall FillBoxInBGMapWithZero + ret + +Func_1f0a7: + push hl + ld de, $80ff + call SetupText + pop hl + push hl + ld a, [hli] + ld h, [hl] + ld l, a + or h + jr z, .asm_1f0bf + call Func_1f09c + ld de, $106 + call PrintTextNoDelay_InitVRAM0 +.asm_1f0bf + pop hl + inc hl + inc hl + ret + +Func_1f0c3: + push hl + ld a, [$dd30] + bit 7, a + jr nz, .asm_1f0e1 + ld a, [hli] + ld b, [hl] + ld c, a + or b + jr z, .asm_1f0e1 + bit 7, b + jr nz, .asm_1f0e5 + bit 6, b + jr nz, .asm_1f0f6 + bit 5, b + jr nz, .asm_1f103 + bit 4, b + jr nz, .asm_1f11b +.asm_1f0e1 + pop hl + inc hl + inc hl + ret +.asm_1f0e5 + call StartFadeToWhite + call WaitPalFading_Bank07 + ld a, c + ld b, $00 + call GiveBoosterPacks + call Func_1f140 + jr .asm_1f0e1 +.asm_1f0f6 + ld a, b + and $3f + ld d, a + ld e, c + call Func_1f12d + call Func_1f140 + jr .asm_1f0e1 +.asm_1f103 + push hl + ld hl, wdd5f +.asm_1f107 + xor a + ld e, [hl] + ld [hli], a + ld d, [hl] + ld [hli], a + ld a, d + or e + jr z, .asm_1f115 + call Func_1f12d + jr .asm_1f107 +.asm_1f115 + pop hl + call Func_1f140 + jr .asm_1f0e1 +.asm_1f11b + push hl + ld hl, wdd73 + xor a + ld e, [hl] + ld [hli], a + ld d, [hl] + ld [hli], a + call Func_1f12d + pop hl + call Func_1f140 + jr .asm_1f0e1 + +Func_1f12d: + call StartFadeToWhite + call WaitPalFading_Bank07 + push hl + farcall GetReceivedCardText + call AddCardToCollection + call Func_1d53a + pop hl + ret + +Func_1f140: + inc hl + ld a, [hli] + ld b, a + ld a, [hl] + or b + jr z, Func_1f0c3.asm_1f0e1 + farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration + call DisableLCD + call Func_1edd1 + call Func_1effb + call Func_1f07a + call Func_1f08b + call FlushAllPalettes + call EnableLCD + ret + +Func_1f161: + push af + push bc + push de + push hl + call Func_1f342 + ld c, a + ld b, $00 + ld hl, wdd51 + add hl, bc + ld a, [hl] + ld [$dd30], a + call Func_1f1ca + jr c, .asm_1f1ad + dec a + jr z, .asm_1f1ad + bit 7, [hl] + jr nz, .asm_1f187 + call Func_1f1d3 + jr c, .asm_1f1ad + dec a + jr z, .asm_1f1ad +.asm_1f187 + xor a + ld [hl], a + ld d, h + ld e, l + inc hl + ld a, $08 + sub c + and a + jr z, .asm_1f19d + ld c, a +.asm_1f193 + push af + ld a, [hli] + ld [de], a + inc de + pop af + dec a + jr nz, .asm_1f193 + xor a + ld [hl], a +.asm_1f19d + ld a, [wdd50] + dec a + ld [wdd50], a + call Func_1f236 + call Func_1f1b2 + call Func_1f210 +.asm_1f1ad + pop hl + pop de + pop bc + pop af + ret + +Func_1f1b2: + ld de, $0 + ld bc, $1405 + call DrawRegularTextBoxVRAM0 + ld hl, $737 + ld de, $102 + call InitTextPrinting_ProcessTextFromIDVRAM0 + ld a, $3c + call DoAFrames_WithPreCheck + ret + +Func_1f1ca: + push hl + ld hl, $735 + call Func_1f1dc + pop hl + ret + +Func_1f1d3: + push hl + ld hl, $736 + call Func_1f1dc + pop hl + ret + +Func_1f1dc: + push hl + ld b, $07 + ld hl, $71f8 + ld de, $0 + call LoadMenuBoxParams + pop hl + ld a, $01 + call DrawMenuBox + ld de, $101 + call InitTextPrinting_ProcessTextFromIDVRAM0 + call HandleMenuBox + ret +; 0x1f1f8 + +SECTION "Bank 7@7210", ROMX[$7210], BANK[$7] + +Func_1f210: + ld a, [wdd5d] + and a + jr nz, .asm_1f225 + ld a, [wdd5c] + and a + ret z + xor a + ld [wdd5c], a + ld a, $03 + ld [wdd5d], a + ret +.asm_1f225 + ld a, [wdd50] + ld c, a + call Func_1f342 + cp c + ret c + ld a, [wdd5d] + dec a + ld [wdd5d], a + ret + +Func_1f236: + ld a, [$dd30] + cp $01 + jr nz, .asm_1f244 + ld de, $0 + call Func_1f30e + ret +.asm_1f244 + cp $02 + ret nz + ld de, $0 + call Func_1f319 + ret ; input: a ; set carry if [wdd36] = wDD37_BUFFER_SIZE - 1 @@ -6373,7 +7059,18 @@ Func_1f333: .asm_1f340 pop bc ret -; 0x1f342 + +Func_1f342: + push bc + ld a, [wdd5c] + add a + add a + ld b, a + ld a, [wdd5d] + add b + pop bc + ret +; 0x1f34f SECTION "Bank 7@757b", ROMX[$757b], BANK[$7] From 7cdeea6f20b8dbefdcf316b7d73f944aa8d4c55b Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 09:15:56 -0600 Subject: [PATCH 12/27] documenting lots of code and wram related to the minicom mailbox I checked the new WRAM values in-game with a debugger --- src/constants/script_constants.asm | 3 +- src/engine/bank02.asm | 8 +- src/engine/bank04.asm | 2 +- src/engine/bank07.asm | 596 ++++++++++++++++------------- src/engine/bank09.asm | 2 +- src/engine/bank0e.asm | 2 +- src/engine/bank11.asm | 34 +- src/macros/menu.asm | 2 +- src/wram.asm | 70 ++-- 9 files changed, 394 insertions(+), 325 deletions(-) diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 9807bc0..42ce9fc 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -330,7 +330,8 @@ ENDR DEF wD606_STRUCT_SIZE EQU $8 DEF SCRIPT_BUFFER_SIZE EQU $20 DEF SCRIPT_STACK_SIZE EQU $10 -DEF wDD37_BUFFER_SIZE EQU $19 +DEF wMAIL_QUEUE_BUFFER_SIZE EQU $19 +DEF B_MAIL_READ EQU 7 ; TODO: Figure out why 2 is added in IngameCardPop const_def diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 9756d8a..c12bd69 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -4433,7 +4433,7 @@ Func_a786: ld [wNumMenuItems], a .asm_a7ca ldh a, [hDPadHeld] - and $80 + and PAD_DOWN jr z, .asm_a7d5 call ConfirmSelectionAndReturnCarry jr .asm_a7e2 @@ -4469,7 +4469,7 @@ Func_a786: .asm_a80c call DoFrame ldh a, [hDPadHeld] - and $40 + and PAD_UP jr z, .asm_a825 ld a, [wTempCardTypeFilter] ld hl, wScrollMenuScrollOffset @@ -4484,10 +4484,10 @@ Func_a786: call HandleScrollListInput jr c, .asm_a87e ldh a, [hDPadHeld] - and $08 + and PAD_START jr z, .asm_a80c .asm_a835 - ld a, $01 + ld a, MENU_CONFIRM call PlayConfirmOrCancelSFX ld a, [wNumMenuItems] ld [wTempScrollMenuNumVisibleItems], a diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 786b006..03fd74a 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -6342,7 +6342,7 @@ Func_131eb: ret Func_131fd: - farcall Func_1f324 + farcall CheckForBlackBoxCardInMail ret nc ldtx hl, GameCenterBlackBoxUnableLastOutputRemainingText call PrintScrollableText_NoTextBoxLabelVRAM0 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index f492a88..e26e92e 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -3004,7 +3004,7 @@ Func_1d475: farcall MaxOutEventValue farcall ClearGameCenterChips - call Func_1eca5 + call InitializeMailboxWRAM call Func_1d7a1 call Func_1d9f9 call Func_1dcb7 @@ -5654,24 +5654,24 @@ CallMiniconMenuFunction: ret .minicon_functions: - key_func $00, Func_1e837 - key_func $01, Func_1ec96 - key_func $02, Func_1e840 + key_func $00, MiniconDeckSaveMachine + key_func $01, MiniconMailbox + key_func $02, MiniconCardAlbum db $ff -Func_1e837: +MiniconDeckSaveMachine: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall Func_baec ret -Func_1e840: +MiniconCardAlbum: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall Func_a786 ret Func_1e849: farcall Func_1022a - call Func_1e837 + call MiniconDeckSaveMachine farcall Func_10252 ret @@ -6144,42 +6144,42 @@ Func_1ec0f: SECTION "Bank 7@6c96", ROMX[$6c96], BANK[$7] -Func_1ec96: +MiniconMailbox: push af push bc push de push hl - call Func_1ece4 - call Func_1eda5 + call MiniconMailboxNewMailScreen + call MiniconMailboxMainScreen pop hl pop de pop bc pop af ret -Func_1eca5: +InitializeMailboxWRAM: push af push bc push de push hl xor a - ld [wdd36], a - ld [wdd50], a - ld [wdd5c], a - ld [wdd5d], a - ld [wdd5e], a - ld [wdd5b], a - ld [wdd5a], a - ld [wdd5f], a - ld [wdd60], a - ld [wdd73], a - ld [wdd74], a + ld [wNumMailInQueue], a + ld [wMailCount], a + ld [wMailboxPage], a + ld [wSelectedMailCursorPosition], a + ld [wMailOptionSelected], a + ld [wTempNumMailInQueue], a + ld [wNewMail], a + ld [wBlackBoxCardReceived], a + ld [wBlackBoxCardReceived + 1], a + ld [wBillsPCCardReceived], a + ld [wBillsPCCardReceived + 1], a xor a - ld hl, wdd37 - ld bc, $19 + ld hl, wMailQueue + ld bc, wMAIL_QUEUE_BUFFER_SIZE call WriteBCBytesToHL xor a - ld hl, wdd51 + ld hl, wMailList ld bc, $9 call WriteBCBytesToHL pop hl @@ -6188,65 +6188,67 @@ Func_1eca5: pop af ret -Func_1ece4: +; the screen after selecting the mailbox which has a large picture of a literal mailbox on it +MiniconMailboxNewMailScreen: call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - call Func_1ed18 + call CalculateMailboxStatus call Func_1ed2d call FlushAllPalettes call EnableLCD - ld a, [wdd5a] + ld a, [wNewMail] and a jr z, .asm_1ed04 push af - ld a, $82 + ld a, SFX_NEW_MAIL call CallPlaySFX pop af .asm_1ed04 call Func_1ed57 call DisableLCD xor a - ld [wdd5a], a - ld [wdd5c], a - ld [wdd5d], a - ld [wdd5b], a + ld [wNewMail], a + ld [wMailboxPage], a + ld [wSelectedMailCursorPosition], a + ld [wTempNumMailInQueue], a ret -Func_1ed18: +CalculateMailboxStatus: ld b, $00 - ld a, [wdd5b] + ld a, [wTempNumMailInQueue] and a jr nz, .asm_1ed28 inc b - ld a, [wdd5a] + ld a, [wNewMail] and a jr nz, .asm_1ed28 inc b .asm_1ed28 ld a, b - ld [$dd31], a + ld [wMailboxStatus], a ret Func_1ed2d: - ld de, $0 - ld bc, $1404 + lb de, 0, 0 + lb bc, 20, 4 call DrawRegularTextBoxVRAM0 - ld hl, $72b - ld de, $602 + ldtx hl, MailboxTitleText + lb de, 6, 2 call InitTextPrinting_ProcessTextFromIDVRAM0 - ld de, $c - ld bc, $1406 + lb de, 0, 12 + lb bc, 20, 6 call DrawRegularTextBoxVRAM0 call Func_1ed5e - call Func_1ed4f + call LoadMailboxScene ret -Func_1ed4f: - ld bc, $505 +LoadMailboxScene: + lb bc, 5, 5 ld a, [hli] call LoadScene ret +; hl - text Func_1ed57: ld a, [hli] ld h, [hl] @@ -6255,11 +6257,11 @@ Func_1ed57: ; fallthrough Func_1ed5e: - ld a, [$dd31] + ld a, [wMailboxStatus] add a ld c, a ld b, $00 - ld hl, $6d6d + ld hl, $6d6d ; TODO: mailbox scene data table add hl, bc ld a, [hli] ld h, [hl] @@ -6269,32 +6271,32 @@ Func_1ed5e: SECTION "Bank 7@6da5", ROMX[$6da5], BANK[$7] -Func_1eda5: +MiniconMailboxMainScreen: call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - ld de, $40ff + lb de, $40, $ff call SetupText - call Func_1edd1 + call MiniconMailboxMainScreen_DrawTextBoxes call FlushAllPalettes call EnableLCD -.asm_1edbb +.loop call Func_1ede4 call Func_1eef8 - jr c, .asm_1edd0 - call Func_1efa4 - call Func_1efd9 - jr c, .asm_1edbb - call Func_1efe1 - jr .asm_1edbb -.asm_1edd0 + jr c, .done + call MailboxSelectedMail_LoadMenuBoxParams + call MailboxSelectedMail_HandleMenuBox + jr c, .loop + call MailboxSelectedMail_CallMappedFunction + jr .loop +.done ret -Func_1edd1: - ld de, $4 - ld bc, $140e +MiniconMailboxMainScreen_DrawTextBoxes: + lb de, 0, 4 + lb bc, 20, 14 call DrawRegularTextBoxVRAM0 - ld de, $0 - ld bc, $1405 + lb de, 0, 0 + lb bc, 20, 5 call DrawRegularTextBoxVRAM0 ret @@ -6303,32 +6305,32 @@ Func_1ede4: push bc push de push hl - ld de, $105 - ld b, $07 - ld hl, $6ed8 + lb de, 1, 5 + ld b, BANK(Data_1eed8) + ld hl, Data_1eed8 call LoadMenuBoxParams - ld a, [wdd5d] + ld a, [wSelectedMailCursorPosition] call DrawMenuBox - ld de, $0 - ld bc, $1405 + lb de, 0, 0 + lb bc, 20, 5 call DrawRegularTextBoxVRAM0 - ld hl, $72f - ld a, [wdd50] + ldtx hl, MailboxChooseMailText + ld a, [wMailCount] and a jr nz, .asm_1ee0e - ld hl, $73a + ldtx hl, MailboxEmptyText .asm_1ee0e - ld de, $102 + lb de, 1, 2 call InitTextPrinting_ProcessTextFromIDVRAM0 - ld hl, $72b - ld de, $100 + ldtx hl, MailboxTitleText + lb de, 1, 0 call Func_2c4b - ld a, [wdd5c] + ld a, [wMailboxPage] add a add a ld c, a ld b, $00 - ld hl, wdd51 + ld hl, wMailList add hl, bc ld de, $206 ld c, $04 @@ -6357,17 +6359,17 @@ Func_1ede4: Func_1ee4a: push bc push hl - ld hl, $730 + ldtx hl, MailboxSenderText call InitTextPrinting_ProcessTextFromIDVRAM0 inc e - ld hl, $731 + ldtx hl, MailboxSubjectText call InitTextPrinting_ProcessTextFromIDVRAM0 and a jr z, .asm_1ee68 bit 7, a jr nz, .asm_1ee68 dec d - ld hl, $738 + ldtx hl, MailboxUnreadSymbolText call InitTextPrinting_ProcessTextFromIDVRAM0 inc d .asm_1ee68 @@ -6408,67 +6410,73 @@ Func_1ee4a: ret Func_1ee97: - ld bc, $111 + lb bc, 1, 17 ld d, $1d ld e, $01 call Func_383b - ld a, [wdd5c] + ld a, [wMailboxPage] cp $01 jr nz, .asm_1eebd - ld bc, $104 + lb bc, 1, 4 ld d, $2f ld e, $41 call Func_383b - ld bc, $111 + lb bc, 1, 17 ld d, $1d ld e, $01 call Func_383b ret .asm_1eebd - ld a, [wdd50] + ld a, [wMailCount] cp $05 ret c - ld bc, $111 + lb bc, 1, 17 ld d, $2f ld e, $01 call Func_383b - ld bc, $104 + lb bc, 1, 4 ld d, $1d ld e, $01 call Func_383b ret -; 0x1eed8 -SECTION "Bank 7@6ef8", ROMX[$6ef8], BANK[$7] +Data_1eed8: + menu_box_params FALSE, 18, 12, \ + SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ + PAD_A, PAD_B, FALSE, 1, $3e75, NULL + textitem 1, 1, SingleSpaceText + textitem 1, 4, SingleSpaceText + textitem 1, 7, SingleSpaceText + textitem 1, 10, SingleSpaceText + db $ff Func_1eef8: -.asm_1eef8 - ld a, [wdd5d] + ld a, [wSelectedMailCursorPosition] call HandleMenuBox - ld [wdd5d], a + ld [wSelectedMailCursorPosition], a jr c, .asm_1ef22 - call Func_1f342 + call GetSelectedMailPosition ld c, a ld b, $00 - ld hl, wdd51 + ld hl, wMailList add hl, bc ld a, [hl] and a jr nz, .asm_1ef1a push af - ld a, $04 + ld a, SFX_DENIED call CallPlaySFX pop af - jr .asm_1eef8 + jr Func_1eef8 .asm_1ef1a push af - ld a, $02 + ld a, SFX_CONFIRM call CallPlaySFX pop af ret .asm_1ef22 push af - ld a, $03 + ld a, SFX_CANCEL call CallPlaySFX pop af ret @@ -6476,142 +6484,159 @@ Func_1eef8: SECTION "Bank 7@6fa4", ROMX[$6fa4], BANK[$7] -Func_1efa4: - ld de, $0 - ld b, $07 - ld hl, $6fbd +MailboxSelectedMail_LoadMenuBoxParams: + lb de, 0, 0 + ld b, BANK(.menu_box_params) + ld hl, .menu_box_params call LoadMenuBoxParams xor a call DrawMenuBox - ld hl, $732 - ld de, $101 + ldtx hl, MailboxActionPromptText + lb de, 1, 1 call InitTextPrinting_ProcessTextFromIDVRAM0 ret -; 0x1efbd -SECTION "Bank 7@6fd9", ROMX[$6fd9], BANK[$7] +.menu_box_params + menu_box_params TRUE, 20, 5, \ + SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ + PAD_A, PAD_B, TRUE, 0, NULL, NULL + textitem 2, 3, MailboxActionReadText + textitem 9, 3, MailboxActionDeleteText + textitem 16, 3, GiftCenterQuitText + db $ff -Func_1efd9: +MailboxSelectedMail_HandleMenuBox: xor a call HandleMenuBox - ld [wdd5e], a + ld [wMailOptionSelected], a ret -Func_1efe1: - ld a, [wdd5e] - ld hl, .Data_1efeb +MailboxSelectedMail_CallMappedFunction: + ld a, [wMailOptionSelected] + ld hl, .function_map call CallMappedFunction ret -.Data_1efeb: - key_func $00, Func_1eff4 - key_func $01, Func_1f161 +.function_map: + key_func $00, ReadMail + key_func $01, DeleteMail db $ff -Func_1eff4: - call Func_1effb - call Func_1f023 +ReadMail: + call DrawReadMailScreenHeader + call _ReadMail ret -Func_1effb: - ld de, $407f +; draws the box at the top that says the sender and subject +; does not actually fill in the sender and subject names though +DrawReadMailScreenHeader: + lb de, $40, $7f call SetupText - ld de, $0 - ld bc, $1405 + lb de, 0, 0 + lb bc, 20, 5 call DrawRegularTextBoxVRAM0 - ld hl, $72b - ld de, $100 + ldtx hl, MailboxTitleText + lb de, 1, 0 call Func_2c4b - ld hl, $701a + ld hl, .text_items call PlaceTextItemsVRAM0 ret -; 0x1f01a -SECTION "Bank 7@7023", ROMX[$7023], BANK[$7] +.text_items: + textitem 1, 2, MailboxSenderText + textitem 1, 3, MailboxSubjectText + db $ff -Func_1f023: - ld bc, $111 +_ReadMail: + lb bc, 1, 17 ld d, $1d ld e, $01 call Func_383b - call Func_1f342 + call GetSelectedMailPosition ld c, a ld b, $00 - ld hl, wdd51 + ld hl, wMailList add hl, bc ld a, [hl] - ld [$dd30], a - set 7, a + ld [wMailId], a + set B_MAIL_READ, a ; mark mail as read ld [hl], a add a ld c, a ld b, $00 - ld hl, $734f + ld hl, $734f ; TODO: data table of all mail add hl, bc ld a, [hli] ld h, [hl] ld l, a ld a, [hli] - ld [$dd32], a + ld [wMailSenderText], a ld a, [hli] - ld [$dd33], a - call Func_1f07a + ld [wMailSenderText + 1], a + call PrintMailSender ld a, [hli] - ld [$dd34], a + ld [wMailSubjectText], a ld a, [hli] - ld [$dd35], a - call Func_1f08b -.asm_1f05f + ld [wMailSubjectText + 1], a + call PrintMailSubject +.read_mail_loop + ; mail is terminated with $ffff ld a, [hl] cp $ff - jr nz, .asm_1f06a + jr nz, .print_body inc hl ld a, [hld] cp $ff - jr z, .asm_1f079 -.asm_1f06a - call Func_1f0a7 + jr z, .done +.print_body + call PrintMailBodyPage jr z, .asm_1f074 push hl call WaitForWideTextBoxInput pop hl .asm_1f074 - call Func_1f0c3 - jr .asm_1f05f -.asm_1f079 + call ProcessMailCommand + jr .read_mail_loop +.done ret -Func_1f07a: +PrintMailSender: push hl - ld a, [$dd32] + ld a, [wMailSenderText] ld l, a - ld a, [$dd33] + ld a, [wMailSenderText + 1] ld h, a - ld de, $602 + lb de, 6, 2 call InitTextPrinting_ProcessTextFromIDVRAM0 pop hl ret -Func_1f08b: +PrintMailSubject: push hl - ld a, [$dd34] + ld a, [wMailSubjectText] ld l, a - ld a, [$dd35] + ld a, [wMailSubjectText + 1] ld h, a - ld de, $603 + lb de, 6, 3 call InitTextPrinting_ProcessTextFromIDVRAM0 pop hl ret -Func_1f09c: - ld de, $105 - ld bc, $120c +ClearMailBodyPage: + lb de, 1, 5 + lb bc, 18, 12 farcall FillBoxInBGMapWithZero ret -Func_1f0a7: +; hl - mail body text +; fills the lower portion of the ReadMail screen with the mail body text at hl +; and then increments hl by 2 (advancing it to the next body page's text). +; prints nothing if value at hl is $0000 +; return +; - hl: input incremented by 2 +PrintMailBodyPage: push hl - ld de, $80ff + lb de, $80, $ff call SetupText pop hl push hl @@ -6619,26 +6644,28 @@ Func_1f0a7: ld h, [hl] ld l, a or h - jr z, .asm_1f0bf - call Func_1f09c - ld de, $106 + jr z, .skip + call ClearMailBodyPage + lb de, 1, 6 call PrintTextNoDelay_InitVRAM0 -.asm_1f0bf +.skip pop hl inc hl inc hl ret -Func_1f0c3: +; processes a mail command at hl that is not just body text (e.g. giving booster packs or cards) +ProcessMailCommand: push hl - ld a, [$dd30] - bit 7, a - jr nz, .asm_1f0e1 + ld a, [wMailId] + bit B_MAIL_READ, a + ; don't give out a card again if this mail has already been read + jr nz, .done ld a, [hli] ld b, [hl] ld c, a or b - jr z, .asm_1f0e1 + jr z, .done bit 7, b jr nz, .asm_1f0e5 bit 6, b @@ -6647,7 +6674,7 @@ Func_1f0c3: jr nz, .asm_1f103 bit 4, b jr nz, .asm_1f11b -.asm_1f0e1 +.done pop hl inc hl inc hl @@ -6658,19 +6685,21 @@ Func_1f0c3: ld a, c ld b, $00 call GiveBoosterPacks - call Func_1f140 - jr .asm_1f0e1 + call .asm_1f140 + jr .done + .asm_1f0f6 ld a, b and $3f ld d, a ld e, c - call Func_1f12d - call Func_1f140 - jr .asm_1f0e1 + call .asm_1f12d + call .asm_1f140 + jr .done + .asm_1f103 push hl - ld hl, wdd5f + ld hl, wBlackBoxCardReceived .asm_1f107 xor a ld e, [hl] @@ -6680,26 +6709,27 @@ Func_1f0c3: ld a, d or e jr z, .asm_1f115 - call Func_1f12d + call .asm_1f12d jr .asm_1f107 .asm_1f115 pop hl - call Func_1f140 - jr .asm_1f0e1 + call .asm_1f140 + jr .done + .asm_1f11b push hl - ld hl, wdd73 + ld hl, wBillsPCCardReceived xor a ld e, [hl] ld [hli], a ld d, [hl] ld [hli], a - call Func_1f12d + call .asm_1f12d pop hl - call Func_1f140 - jr .asm_1f0e1 + call .asm_1f140 + jr .done -Func_1f12d: +.asm_1f12d call StartFadeToWhite call WaitPalFading_Bank07 push hl @@ -6709,42 +6739,42 @@ Func_1f12d: pop hl ret -Func_1f140: +.asm_1f140 inc hl ld a, [hli] ld b, a ld a, [hl] or b - jr z, Func_1f0c3.asm_1f0e1 + jr z, .done farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration call DisableLCD - call Func_1edd1 - call Func_1effb - call Func_1f07a - call Func_1f08b + call MiniconMailboxMainScreen_DrawTextBoxes + call DrawReadMailScreenHeader + call PrintMailSender + call PrintMailSubject call FlushAllPalettes call EnableLCD ret -Func_1f161: +DeleteMail: push af push bc push de push hl - call Func_1f342 + call GetSelectedMailPosition ld c, a ld b, $00 - ld hl, wdd51 + ld hl, wMailList add hl, bc ld a, [hl] - ld [$dd30], a - call Func_1f1ca + ld [wMailId], a + call MailboxYesNoPrompt_DeleteConfirm jr c, .asm_1f1ad dec a jr z, .asm_1f1ad bit 7, [hl] jr nz, .asm_1f187 - call Func_1f1d3 + call MailboxYesNoPrompt_DeleteUnreadConfirm jr c, .asm_1f1ad dec a jr z, .asm_1f1ad @@ -6770,11 +6800,11 @@ Func_1f161: xor a ld [hl], a .asm_1f19d - ld a, [wdd50] + ld a, [wMailCount] dec a - ld [wdd50], a - call Func_1f236 - call Func_1f1b2 + ld [wMailCount], a + call DeleteGameCenterMailedCard + call DrawMailDeletedTextBox call Func_1f210 .asm_1f1ad pop hl @@ -6783,105 +6813,113 @@ Func_1f161: pop af ret -Func_1f1b2: - ld de, $0 - ld bc, $1405 +DrawMailDeletedTextBox: + lb de, 0, 0 + lb bc, 20, 5 call DrawRegularTextBoxVRAM0 - ld hl, $737 - ld de, $102 + ldtx hl, MailboxDeletedText + lb de, 1, 2 call InitTextPrinting_ProcessTextFromIDVRAM0 - ld a, $3c + ld a, 60 call DoAFrames_WithPreCheck ret -Func_1f1ca: +MailboxYesNoPrompt_DeleteConfirm: push hl - ld hl, $735 - call Func_1f1dc + ldtx hl, MailboxActionDeleteConfirmText + call MailboxYesNoPrompt pop hl ret -Func_1f1d3: +MailboxYesNoPrompt_DeleteUnreadConfirm: push hl - ld hl, $736 - call Func_1f1dc + ldtx hl, MailboxActionDeleteUnreadConfirmText + call MailboxYesNoPrompt pop hl ret -Func_1f1dc: +; hl - text +MailboxYesNoPrompt: push hl - ld b, $07 - ld hl, $71f8 - ld de, $0 + ld b, BANK(.menu_box_params) + ld hl, .menu_box_params + lb de, 0, 0 call LoadMenuBoxParams pop hl ld a, $01 call DrawMenuBox - ld de, $101 + lb de, 1, 1 call InitTextPrinting_ProcessTextFromIDVRAM0 call HandleMenuBox ret -; 0x1f1f8 -SECTION "Bank 7@7210", ROMX[$7210], BANK[$7] +.menu_box_params + menu_box_params TRUE, 20, 5, \ + SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ + PAD_A, PAD_B, TRUE, 0, NULL, NULL + textitem 7, 3, PlayerDiaryPromptYesText + textitem 11, 3, PlayerDiaryPromptNoText + db $ff Func_1f210: - ld a, [wdd5d] + ld a, [wSelectedMailCursorPosition] and a jr nz, .asm_1f225 - ld a, [wdd5c] + ld a, [wMailboxPage] and a ret z xor a - ld [wdd5c], a + ld [wMailboxPage], a ld a, $03 - ld [wdd5d], a + ld [wSelectedMailCursorPosition], a ret .asm_1f225 - ld a, [wdd50] + ld a, [wMailCount] ld c, a - call Func_1f342 + call GetSelectedMailPosition cp c ret c - ld a, [wdd5d] + ld a, [wSelectedMailCursorPosition] dec a - ld [wdd5d], a + ld [wSelectedMailCursorPosition], a ret -Func_1f236: - ld a, [$dd30] - cp $01 +; if the current mail being read/acted on is from the game center, +; delete the card that is waiting to be collected. +DeleteGameCenterMailedCard: + ld a, [wMailId] + cp $01 ; black box mail id jr nz, .asm_1f244 ld de, $0 - call Func_1f30e + call SetBlackBoxCard ret .asm_1f244 - cp $02 + cp $02 ; bill's PC mail id ret nz ld de, $0 - call Func_1f319 + call SetBillsPCCard ret ; input: a -; set carry if [wdd36] = wDD37_BUFFER_SIZE - 1 +; set carry if [wNumMailInQueue] = wMAIL_QUEUE_BUFFER_SIZE - 1 ; else: -; - if bit 7 of a is 0, [wdd37 + [wdd36] ] = a +; - if bit 7 of a is 0, [wMailQueue + [wNumMailInQueue] ] = a ; - if bit 7 of a is 1, -; (the first byte in wdd37[n] whose bit 7 is 0) = a +; (the first byte in wMailQueue[n] whose bit 7 is 0) = a ; and shift the rest -; and increment [wdd36] by 1 +; and increment [wNumMailInQueue] by 1 Func_1f24e: push bc push de push hl ld e, a - ld a, [wdd36] - cp wDD37_BUFFER_SIZE - 1 + ld a, [wNumMailInQueue] + cp wMAIL_QUEUE_BUFFER_SIZE - 1 jr z, .set_carry bit 7, e call z, .not_bit7 call nz, .has_bit7 - ld hl, wdd36 + ld hl, wNumMailInQueue inc [hl] ; clear carry scf @@ -6898,10 +6936,10 @@ Func_1f24e: .not_bit7: push af - ld a, [wdd36] + ld a, [wNumMailInQueue] ld c, a ld b, 0 - ld hl, wdd37 + ld hl, wMailQueue add hl, bc ld [hl], e pop af @@ -6909,8 +6947,8 @@ Func_1f24e: .has_bit7: push af - ld hl, wdd37 - ld c, wDD37_BUFFER_SIZE - 1 + ld hl, wMailQueue + ld c, wMAIL_QUEUE_BUFFER_SIZE - 1 .check_byte_loop bit 7, [hl] jr z, .shift_loop @@ -6932,17 +6970,17 @@ Func_1f293: push bc push de push hl - ld a, [wdd36] + ld a, [wNumMailInQueue] and a jr z, .asm_1f2eb ld a, $ff - ld [wdd5a], a - ld a, [wdd50] + ld [wNewMail], a + ld a, [wMailCount] cp $08 jr z, .asm_1f2eb - ld de, wdd51 - ld hl, wdd37 - ld a, [wdd50] + ld de, wMailList + ld hl, wMailQueue + ld a, [wMailCount] ld b, a ld a, $08 sub b @@ -6958,16 +6996,16 @@ Func_1f293: dec b jr nz, .asm_1f2b9 .asm_1f2c6 - ld a, [wdd50] + ld a, [wMailCount] add c - ld [wdd50], a - ld a, [wdd36] + ld [wMailCount], a + ld a, [wNumMailInQueue] sub c - ld [wdd36], a - ld hl, wdd37 + ld [wNumMailInQueue], a + ld hl, wMailQueue ld b, $00 add hl, bc - ld de, wdd37 + ld de, wMailQueue ld a, $18 sub c ld c, a @@ -6982,8 +7020,8 @@ Func_1f293: dec c jr nz, .asm_1f2e2 .asm_1f2eb - ld a, [wdd36] - ld [wdd5b], a + ld a, [wNumMailInQueue] + ld [wTempNumMailInQueue], a pop hl pop de pop bc @@ -7012,33 +7050,36 @@ Func_1f293: ret Func_1f309: - ld a, [wdd5a] + ld a, [wNewMail] and a ret -Func_1f30e: +; de - card offset +SetBlackBoxCard: push af ld a, e - ld [wdd5f], a + ld [wBlackBoxCardReceived], a ld a, d - ld [wdd60], a + ld [wBlackBoxCardReceived + 1], a pop af ret -Func_1f319: +; de - card offset +SetBillsPCCard: push af ld a, e - ld [wdd73], a + ld [wBillsPCCardReceived], a ld a, d - ld [wdd74], a + ld [wBillsPCCardReceived + 1], a pop af ret -Func_1f324: +; set carry if there is a black box card +CheckForBlackBoxCardInMail: push bc - ld a, [wdd5f] + ld a, [wBlackBoxCardReceived] ld b, a - ld a, [wdd60] + ld a, [wBlackBoxCardReceived + 1] or b scf jr nz, .asm_1f331 @@ -7047,11 +7088,12 @@ Func_1f324: pop bc ret -Func_1f333: +; set carry if there is a bill's pc card +CheckForBillsPCCardInMail: push bc - ld a, [wdd73] + ld a, [wBillsPCCardReceived] ld b, a - ld a, [wdd74] + ld a, [wBillsPCCardReceived + 1] or b scf jr nz, .asm_1f340 @@ -7060,13 +7102,15 @@ Func_1f333: pop bc ret -Func_1f342: +; return +; a - position in the mail list of the currently selected mail item +GetSelectedMailPosition: push bc - ld a, [wdd5c] + ld a, [wMailboxPage] add a add a ld b, a - ld a, [wdd5d] + ld a, [wSelectedMailCursorPosition] add b pop bc ret @@ -7618,7 +7662,7 @@ Func_1f8f7: jr c, .asm_1f914 ldtx hl, GameCenterToBeMailedText_2 farcall PrintScrollableText_NoTextBoxLabelVRAM0 - call Func_1f319 + call SetBillsPCCard ld a, $82 call Func_1f24e .asm_1f914 diff --git a/src/engine/bank09.asm b/src/engine/bank09.asm index 38146bb..da77a82 100644 --- a/src/engine/bank09.asm +++ b/src/engine/bank09.asm @@ -4856,7 +4856,7 @@ Func_2612a: ldtx hl, GameCenterBillsPCStartPromptText call YesOrNoMenuWithText ret c - farcall Func_1f333 + farcall CheckForBillsPCCardInMail ldtx hl, GameCenterBillsPCUnableLastOutputRemainingText jr c, .asm_2619a farcall GetGameCenterChips diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index 59d03a3..f042853 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -4857,7 +4857,7 @@ Func_3ada1: inc hl ld [hl], d call ClearScreenAndDrawDeckMachineScreen - ld a, $32 + ld a, NUM_DECK_SAVE_MACHINE_SLOTS ld [wNumDeckMachineEntries], a xor a .asm_3adb7 diff --git a/src/engine/bank11.asm b/src/engine/bank11.asm index 5c0f369..64961d5 100644 --- a/src/engine/bank11.asm +++ b/src/engine/bank11.asm @@ -2023,7 +2023,7 @@ Func_456de: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld c, $03 .asm_45734 ld a, e @@ -2057,7 +2057,7 @@ Func_456de: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld c, $05 .asm_4576b ld a, e @@ -2080,7 +2080,7 @@ Func_456de: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld a, e ld [hli], a ld a, d @@ -2107,7 +2107,7 @@ Func_456de: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld a, e ld [hli], a ld a, d @@ -2137,7 +2137,7 @@ Func_456de: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld a, e ld [hli], a ld a, d @@ -2215,7 +2215,7 @@ Func_457ea: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived .asm_45858 ld a, e ld [hli], a @@ -2234,7 +2234,7 @@ Func_457ea: Func_45868: xor a - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld [hli], a ld [hl], a ld hl, BlackboxPromoCards @@ -2262,7 +2262,7 @@ Func_45868: ld a, [hld] ld d, a push hl - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL ld hl, wCurDeckCards call Func_443bd @@ -2287,7 +2287,7 @@ Func_45868: or e jr z, .asm_458be push hl - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL pop hl jr .asm_458ad @@ -2296,7 +2296,7 @@ Func_45868: Func_458bf: xor a - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld [hli], a ld [hl], a ld hl, wCurDeckCards @@ -2319,7 +2319,7 @@ Func_458bf: jr c, .asm_458c8 .asm_458e7 push hl - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL pop hl jr .asm_458c8 @@ -2387,7 +2387,7 @@ Func_458bf: cp $02 jp nc, .asm_4593a push hl - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL pop hl jr .asm_4593a @@ -2496,7 +2496,7 @@ Func_458bf: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL dec c jr nz, .asm_459f7 @@ -2534,7 +2534,7 @@ Func_458bf: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL dec c jr nz, .asm_45a3c @@ -2572,7 +2572,7 @@ Func_458bf: ld a, [hli] ld e, a ld d, [hl] - ld hl, wdd5f + ld hl, wBlackBoxCardReceived call AppendCardToListInHL dec c jr nz, .asm_45a81 @@ -2580,7 +2580,7 @@ Func_458bf: ret .asm_45a9c call Func_45bc3 - ld hl, wdd5f + ld hl, wBlackBoxCardReceived ld de, $a call AppendCardToListInHL jr .asm_45a9b @@ -2757,7 +2757,7 @@ Func_45bc3: push de push hl ld hl, wCurDeckCards - ld de, wdd5f + ld de, wBlackBoxCardReceived ld bc, $c call CopyDataHLtoDE_SaveRegisters pop hl diff --git a/src/macros/menu.asm b/src/macros/menu.asm index 739fcdd..0729bae 100644 --- a/src/macros/menu.asm +++ b/src/macros/menu.asm @@ -27,7 +27,7 @@ ENDM \10 ; has horizontal scroll - TRUE or FALSE \11 ; vertical step - int \12 ; update function - function ptr or NULL - \13 ; label text ID - text ptr + \13 ; label text ID - text ptr or NULL 15 bytes. Used by LoadMenuBoxParams. Usually followed by a list of textitem macros, then $ff diff --git a/src/wram.asm b/src/wram.asm index 1fc71ac..749c3a6 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -3261,48 +3261,72 @@ wdd2e:: ; dd2e wdd2f:: ; dd2f ds $1 - ds $6 - -wdd36:: ; dd36 +; id of the mail item being read +wMailId:: ; dd30 ds $1 -wdd37:: ; dd37 - ds wDD37_BUFFER_SIZE - -wdd50:: ; dd50 +; 0 - mailbox full, 1 - new mail, 2 - no new mail +wMailboxStatus:: ; dd31 ds $1 -wdd51:: ; dd51 +; text offset of the sender line. displayed when reading a mail +wMailSenderText:: ; dd32 + ds $2 + +; text offset of the subject line. displayed when reading a mail +wMailSubjectText:: ; dd34 + ds $2 + +; number of minicom mail queued to be delivered. mail is delivered when changing OW locations +wNumMailInQueue:: ; dd36 + ds $1 + +; list of mail items queued to be delivered +wMailQueue:: ; dd37 + ds wMAIL_QUEUE_BUFFER_SIZE + +; total number of mail in your mailbox +wMailCount:: ; dd50 + ds $1 + +; list of mail items in the player's mailbox. holds up to 8 mail. +; Each byte is the id of a mail item. +; When mail is read, $80 is added to the id +wMailList:: ; dd51 ds $9 -wdd5a:: ; dd5a +; $ff when the player has new mail. set to 0 when opening mincom mail menu. affects the mailbox animation +wNewMail:: ; dd5a ds $1 -wdd5b:: ; dd5b +; copied from wNumMailInQueue when visiting world map. +; cleared after viewing the mailbox screen once. +; used to show the "mailbox full" graphic +wTempNumMailInQueue:: ; dd5b ds $1 -wdd5c:: ; dd5c +; which page of mail you are viewing. 0 or 1 +wMailboxPage:: ; dd5c ds $1 -wdd5d:: ; dd5d +; the mail you have selected to read/delete +wSelectedMailCursorPosition:: ; dd5d ds $1 -wdd5e:: ; dd5e +; 0 - read mail, 1 - delete mail, 2 - quit +wMailOptionSelected:: ; dd5e ds $1 -wdd5f:: ; dd5f - ds $1 - -wdd60:: ; dd60 - ds $1 +; card offset. the card mailed to you after using the Game Center black box +wBlackBoxCardReceived:: ; dd5f + ds $2 +; TODO: are these also black box cards? ds $12 -wdd73:: ; dd73 - ds $1 - -wdd74:: ; dd74 - ds $1 +; card offset. the card mailed to you after using the Game Center Bill's PC +wBillsPCCardReceived:: ; dd73 + ds $2 wdd75:: ; dd75 ds $1 From 9525678649cf98eeb35eb6dc73b2521c957f43c9 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 09:24:25 -0600 Subject: [PATCH 13/27] disassembling mailbox scene data --- src/engine/bank07.asm | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index e26e92e..0f2460b 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6261,13 +6261,27 @@ Func_1ed5e: add a ld c, a ld b, $00 - ld hl, $6d6d ; TODO: mailbox scene data table + ld hl, .MailboxScenes add hl, bc ld a, [hli] ld h, [hl] ld l, a ret -; 0x1ed6d + +.MailboxScenes: + dw .SceneFull + dw .SceneGotMail + dw .SceneNoNewMail +.SceneFull + db SCENE_FULL_MAILBOX + tx MailboxFullWarningText +.SceneGotMail + db SCENE_GOT_MAIL + tx MailboxNewMailText +.SceneNoNewMail + db SCENE_MAILBOX + tx MailboxNoNewMailText +; 0x1ed7c SECTION "Bank 7@6da5", ROMX[$6da5], BANK[$7] From e8c62bde651ad277023dde0698719fb8ad5ec207 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 09:37:27 -0600 Subject: [PATCH 14/27] dumping mail data --- src/data/mail.asm | 337 ++++++++++++++++++++++++++++++++++++++++++ src/engine/bank07.asm | 3 +- 2 files changed, 338 insertions(+), 2 deletions(-) create mode 100644 src/data/mail.asm diff --git a/src/data/mail.asm b/src/data/mail.asm new file mode 100644 index 0000000..01912b2 --- /dev/null +++ b/src/data/mail.asm @@ -0,0 +1,337 @@ +Data_1f34f: + db $89, $73 + db $8f, $73 + db $9d, $73 + db $ab, $73 + db $bd, $73 + db $d3, $73 + db $e9, $73 + db $fb, $73 + db $09, $74 + db $1b, $74 + db $29, $74 + db $3b, $74 + db $4d, $74 + db $5f, $74 + db $6d, $74 + db $7f, $74 + db $8d, $74 + db $9b, $74 + db $a9, $74 + db $b7, $74 + db $c5, $74 + db $db, $74 + db $ed, $74 + db $ff, $74 + db $11, $75 + db $23, $75 + db $3d, $75 + db $53, $75 + db $6d, $75 + +Data_1f389: + db $9e, $06 + db $9f, $06 + db $ff, $ff + +Data_1f38f: + db $a0, $06 + db $a1, $06 + db $a2, $06 + db $00, $20 + db $a3, $06 + db $00, $00 + db $ff, $ff + +Data_1f39d: + db $a4, $06 + db $a5, $06 + db $a6, $06 + db $00, $10 + db $a7, $06 + db $00, $00 + db $ff, $ff + +Data_1f3ab: + db $a8, $06 + db $a9, $06 + db $aa, $06 + db $00, $00 + db $ab, $06 + db $00, $00 + db $ac, $06 + db $08, $80 + db $ff, $ff + +Data_1f3bd: + db $ae, $06 + db $af, $06 + db $b0, $06 + db $00, $00 + db $b1, $06 + db $00, $00 + db $b2, $06 + db $00, $00 + db $b3, $06 + db $00, $00 + db $ff, $ff + +Data_1f3d3: + db $b4, $06 + db $b5, $06 + db $b6, $06 + db $00, $00 + db $b7, $06 + db $00, $00 + db $b8, $06 + db $00, $00 + db $b9, $06 + db $00, $00 + db $ff, $ff + +Data_1f3e9: + db $ba, $06 + db $bb, $06 + db $bc, $06 + db $00, $00 + db $bd, $06 + db $00, $00 + db $be, $06 + db $00, $00 + db $ff, $ff + +Data_1f3fb: + db $bf, $06 + db $c0, $06 + db $c1, $06 + db $00, $00 + db $c2, $06 + db $00, $00 + db $ff, $ff + +Data_1f409: + db $c3, $06 + db $c4, $06 + db $c5, $06 + db $00, $00 + db $c6, $06 + db $00, $00 + db $c7, $06 + db $00, $80 + db $ff, $ff + +Data_1f41b: + db $c8, $06 + db $c9, $06 + db $ca, $06 + db $00, $00 + db $cb, $06 + db $01, $80 + db $ff, $ff + +Data_1f429: + db $cd, $06 + db $ce, $06 + db $cf, $06 + db $00, $00 + db $d0, $06 + db $00, $00 + db $d1, $06 + db $02, $80 + db $ff, $ff + +Data_1f43b: + db $d2, $06 + db $d3, $06 + db $d4, $06 + db $00, $00 + db $d5, $06 + db $00, $00 + db $d6, $06 + db $04, $80 + db $ff, $ff + +Data_1f44d: + db $d7, $06 + db $d8, $06 + db $d9, $06 + db $00, $00 + db $da, $06 + db $00, $00 + db $db, $06 + db $00, $00 + db $ff, $ff + +Data_1f45f: + db $dc, $06 + db $dd, $06 + db $de, $06 + db $00, $00 + db $df, $06 + db $00, $00 + db $ff, $ff + +Data_1f46d: + db $e0, $06 + db $e1, $06 + db $e2, $06 + db $00, $00 + db $e3, $06 + db $00, $00 + db $e4, $06 + db $00, $00 + db $ff, $ff + +Data_1f47f: + db $e5, $06 + db $e6, $06 + db $e7, $06 + db $00, $00 + db $e8, $06 + db $00, $00 + db $ff, $ff + +Data_1f48d: + db $e9, $06 + db $ea, $06 + db $eb, $06 + db $00, $00 + db $ec, $06 + db $00, $00 + db $ff, $ff + +Data_1f49b: + db $ed, $06 + db $ee, $06 + db $ef, $06 + db $00, $00 + db $f0, $06 + db $00, $00 + db $ff, $ff + +Data_1f4a9: + db $f1, $06 + db $f2, $06 + db $f3, $06 + db $00, $00 + db $f4, $06 + db $00, $00 + db $ff, $ff + +Data_1f4b7: + db $f5, $06 + db $f6, $06 + db $f7, $06 + db $00, $00 + db $f8, $06 + db $00, $00 + db $ff, $ff + +Data_1f4c5: + db $f9, $06 + db $fa, $06 + db $fb, $06 + db $00, $00 + db $fc, $06 + db $00, $00 + db $fd, $06 + db $00, $00 + db $fe, $06 + db $00, $00 + db $ff, $ff + +Data_1f4db: + db $ff, $06 + db $00, $07 + db $01, $07 + db $00, $00 + db $02, $07 + db $00, $00 + db $03, $07 + db $00, $00 + db $ff, $ff + +Data_1f4ed: + db $04, $07 + db $05, $07 + db $06, $07 + db $00, $00 + db $07, $07 + db $00, $00 + db $08, $07 + db $00, $00 + db $ff, $ff + +Data_1f4ff: + db $09, $07 + db $0a, $07 + db $0b, $07 + db $00, $00 + db $0c, $07 + db $00, $00 + db $0d, $07 + db $00, $00 + db $ff, $ff + +Data_1f511: + db $0e, $07 + db $0f, $07 + db $10, $07 + db $00, $00 + db $11, $07 + db $00, $00 + db $12, $07 + db $00, $00 + db $ff, $ff + +Data_1f523: + db $13, $07 + db $14, $07 + db $15, $07 + db $00, $00 + db $16, $07 + db $00, $00 + db $17, $07 + db $00, $00 + db $18, $07 + db $00, $00 + db $19, $07 + db $00, $00 + db $ff, $ff + +Data_1f53d: + db $1a, $07 + db $1b, $07 + db $1c, $07 + db $00, $00 + db $1d, $07 + db $00, $00 + db $1e, $07 + db $00, $00 + db $1f, $07 + db $00, $00 + db $ff, $ff + +Data_1f553: + db $20, $07 + db $21, $07 + db $22, $07 + db $00, $00 + db $23, $07 + db $00, $00 + db $24, $07 + db $00, $00 + db $25, $07 + db $00, $00 + db $26, $07 + db $00, $00 + db $ff, $ff + +Data_1f56d: + db $27, $07 + db $28, $07 + db $29, $07 + db $00, $00 + db $2a, $07 + db $00, $00 + db $ff, $ff \ No newline at end of file diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 0f2460b..66aae09 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -7128,9 +7128,8 @@ GetSelectedMailPosition: add b pop bc ret -; 0x1f34f -SECTION "Bank 7@757b", ROMX[$757b], BANK[$7] +INCLUDE "data/mail.asm" Func_1f57b:: push af From f2d40cc2fa427cfce292bd1dfcb2995a8f50e3f7 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 09:58:19 -0600 Subject: [PATCH 15/27] labelling mail body text --- src/data/mail.asm | 280 +++++++++++++++++++++++----------------------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/src/data/mail.asm b/src/data/mail.asm index 01912b2..2efb05a 100644 --- a/src/data/mail.asm +++ b/src/data/mail.asm @@ -30,308 +30,308 @@ Data_1f34f: db $6d, $75 Data_1f389: - db $9e, $06 - db $9f, $06 + tx MailboxEmptySenderText + tx MailboxEmptySubjectText db $ff, $ff Data_1f38f: - db $a0, $06 - db $a1, $06 - db $a2, $06 + tx MailBlackBoxOutputSenderText + tx MailBlackBoxOutputSubjectText + tx MailBlackBoxOutputBody1Text db $00, $20 - db $a3, $06 + tx MailBlackBoxOutputBody2Text db $00, $00 db $ff, $ff Data_1f39d: - db $a4, $06 - db $a5, $06 - db $a6, $06 + tx MailBillsPCOutputSenderText + tx MailBillsPCOutputSubjectText + tx MailBillsPCOutputBody1Text db $00, $10 - db $a7, $06 + tx MailBillsPCOutputBody2Text db $00, $00 db $ff, $ff Data_1f3ab: - db $a8, $06 - db $a9, $06 - db $aa, $06 + tx MailMailboxIntroSenderText + tx MailMailboxIntroSubjectText + tx MailMailboxIntroBody1Text db $00, $00 - db $ab, $06 + tx MailMailboxIntroBody2Text db $00, $00 - db $ac, $06 + tx MailMailboxIntroBody3Text db $08, $80 db $ff, $ff Data_1f3bd: - db $ae, $06 - db $af, $06 - db $b0, $06 + tx MailDeckDiagnosis1SenderText + tx MailDeckDiagnosis1SubjectText + tx MailDeckDiagnosis1Body1Text db $00, $00 - db $b1, $06 + tx MailDeckDiagnosis1Body2Text db $00, $00 - db $b2, $06 + tx MailDeckDiagnosis1Body3Text db $00, $00 - db $b3, $06 + tx MailDeckDiagnosis1Body4Text db $00, $00 db $ff, $ff Data_1f3d3: - db $b4, $06 - db $b5, $06 - db $b6, $06 + tx MailDeckDiagnosis2SenderText + tx MailDeckDiagnosis2SubjectText + tx MailDeckDiagnosis2Body1Text db $00, $00 - db $b7, $06 + tx MailDeckDiagnosis2Body2Text db $00, $00 - db $b8, $06 + tx MailDeckDiagnosis2Body3Text db $00, $00 - db $b9, $06 + tx MailDeckDiagnosis2Body4Text db $00, $00 db $ff, $ff Data_1f3e9: - db $ba, $06 - db $bb, $06 - db $bc, $06 + tx MailDeckDiagnosis3SenderText + tx MailDeckDiagnosis3SubjectText + tx MailDeckDiagnosis3Body1Text db $00, $00 - db $bd, $06 + tx MailDeckDiagnosis3Body2Text db $00, $00 - db $be, $06 + tx MailDeckDiagnosis3Body3Text db $00, $00 db $ff, $ff Data_1f3fb: - db $bf, $06 - db $c0, $06 - db $c1, $06 + tx MailDeckDiagnosis4SenderText + tx MailDeckDiagnosis4SubjectText + tx MailDeckDiagnosis4Body1Text db $00, $00 - db $c2, $06 + tx MailDeckDiagnosis4Body2Text db $00, $00 db $ff, $ff Data_1f409: - db $c3, $06 - db $c4, $06 - db $c5, $06 + tx MailAutoDeckMachine1SenderText + tx MailAutoDeckMachine1SubjectText + tx MailAutoDeckMachine1Body1Text db $00, $00 - db $c6, $06 + tx MailAutoDeckMachine1Body2Text db $00, $00 - db $c7, $06 + tx MailAutoDeckMachine1Body3Text db $00, $80 db $ff, $ff Data_1f41b: - db $c8, $06 - db $c9, $06 - db $ca, $06 + tx MailAutoDeckMachine2SenderText + tx MailAutoDeckMachine2SubjectText + tx MailAutoDeckMachine2Body1Text db $00, $00 - db $cb, $06 + tx MailAutoDeckMachine2Body2Text db $01, $80 db $ff, $ff Data_1f429: - db $cd, $06 - db $ce, $06 - db $cf, $06 + tx MailAutoDeckMachine3SenderText + tx MailAutoDeckMachine3SubjectText + tx MailAutoDeckMachine3Body1Text db $00, $00 - db $d0, $06 + tx MailAutoDeckMachine3Body2Text db $00, $00 - db $d1, $06 + tx MailAutoDeckMachine3Body3Text db $02, $80 db $ff, $ff Data_1f43b: - db $d2, $06 - db $d3, $06 - db $d4, $06 + tx MailAutoDeckMachine4SenderText + tx MailAutoDeckMachine4SubjectText + tx MailAutoDeckMachine4Body1Text db $00, $00 - db $d5, $06 + tx MailAutoDeckMachine4Body2Text db $00, $00 - db $d6, $06 + tx MailAutoDeckMachine4Body3Text db $04, $80 db $ff, $ff Data_1f44d: - db $d7, $06 - db $d8, $06 - db $d9, $06 + tx MailAutoDeckMachine5SenderText + tx MailAutoDeckMachine5SubjectText + tx MailAutoDeckMachine5Body1Text db $00, $00 - db $da, $06 + tx MailAutoDeckMachine5Body2Text db $00, $00 - db $db, $06 + tx MailAutoDeckMachine5Body3Text db $00, $00 db $ff, $ff Data_1f45f: - db $dc, $06 - db $dd, $06 - db $de, $06 + tx MailChallengeMachineSenderText + tx MailChallengeMachineSubjectText + tx MailChallengeMachineBody1Text db $00, $00 - db $df, $06 + tx MailChallengeMachineBody2Text db $00, $00 db $ff, $ff Data_1f46d: - db $e0, $06 - db $e1, $06 - db $e2, $06 + tx MailGRChallengeMachineSenderText + tx MailGRChallengeMachineSubjectText + tx MailGRChallengeMachineBody1Text db $00, $00 - db $e3, $06 + tx MailGRChallengeMachineBody2Text db $00, $00 - db $e4, $06 + tx MailGRChallengeMachineBody3Text db $00, $00 db $ff, $ff Data_1f47f: - db $e5, $06 - db $e6, $06 - db $e7, $06 + tx MailGrandMasterCupSenderText + tx MailGrandMasterCupSubjectText + tx MailGrandMasterCupBody1Text db $00, $00 - db $e8, $06 + tx MailGrandMasterCupBody2Text db $00, $00 db $ff, $ff Data_1f48d: - db $e9, $06 - db $ea, $06 - db $eb, $06 + tx MailRonaldsScoutGR1SenderText + tx MailRonaldsScoutGR1SubjectText + tx MailRonaldsScoutGR1Body1Text db $00, $00 - db $ec, $06 + tx MailRonaldsScoutGR1Body2Text db $00, $00 db $ff, $ff Data_1f49b: - db $ed, $06 - db $ee, $06 - db $ef, $06 + tx MailRonaldsScoutGR2SenderText + tx MailRonaldsScoutGR2SubjectText + tx MailRonaldsScoutGR2Body1Text db $00, $00 - db $f0, $06 + tx MailRonaldsScoutGR2Body2Text db $00, $00 db $ff, $ff Data_1f4a9: - db $f1, $06 - db $f2, $06 - db $f3, $06 + tx MailRonaldsScoutGR3SenderText + tx MailRonaldsScoutGR3SubjectText + tx MailRonaldsScoutGR3Body1Text db $00, $00 - db $f4, $06 + tx MailRonaldsScoutGR3Body2Text db $00, $00 db $ff, $ff Data_1f4b7: - db $f5, $06 - db $f6, $06 - db $f7, $06 + tx MailRonaldsScoutGR4SenderText + tx MailRonaldsScoutGR4SubjectText + tx MailRonaldsScoutGR4Body1Text db $00, $00 - db $f8, $06 + tx MailRonaldsScoutGR4Body2Text db $00, $00 db $ff, $ff Data_1f4c5: - db $f9, $06 - db $fa, $06 - db $fb, $06 + tx MailRonaldsScoutMorinoSenderText + tx MailRonaldsScoutMorinoSubjectText + tx MailRonaldsScoutMorinoBody1Text db $00, $00 - db $fc, $06 + tx MailRonaldsScoutMorinoBody2Text db $00, $00 - db $fd, $06 + tx MailRonaldsScoutMorinoBody3Text db $00, $00 - db $fe, $06 + tx MailRonaldsScoutMorinoBody4Text db $00, $00 db $ff, $ff Data_1f4db: - db $ff, $06 - db $00, $07 - db $01, $07 + tx MailRonaldsScoutCatherineSenderText + tx MailRonaldsScoutCatherineSubjectText + tx MailRonaldsScoutCatherineBody1Text db $00, $00 - db $02, $07 + tx MailRonaldsScoutCatherineBody2Text db $00, $00 - db $03, $07 + tx MailRonaldsScoutCatherineBody3Text db $00, $00 db $ff, $ff Data_1f4ed: - db $04, $07 - db $05, $07 - db $06, $07 + tx MailRonaldsScoutHideroSenderText + tx MailRonaldsScoutHideroSubjectText + tx MailRonaldsScoutHideroBody1Text db $00, $00 - db $07, $07 + tx MailRonaldsScoutHideroBody2Text db $00, $00 - db $08, $07 + tx MailRonaldsScoutHideroBody3Text db $00, $00 db $ff, $ff Data_1f4ff: - db $09, $07 - db $0a, $07 - db $0b, $07 + tx MailRonaldsScoutKanokoSenderText + tx MailRonaldsScoutKanokoSubjectText + tx MailRonaldsScoutKanokoBody1Text db $00, $00 - db $0c, $07 + tx MailRonaldsScoutKanokoBody2Text db $00, $00 - db $0d, $07 + tx MailRonaldsScoutKanokoBody3Text db $00, $00 db $ff, $ff Data_1f511: - db $0e, $07 - db $0f, $07 - db $10, $07 + tx MailRonaldsScoutKamiyaSenderText + tx MailRonaldsScoutKamiyaSubjectText + tx MailRonaldsScoutKamiyaBody1Text db $00, $00 - db $11, $07 + tx MailRonaldsScoutKamiyaBody2Text db $00, $00 - db $12, $07 + tx MailRonaldsScoutKamiyaBody3Text db $00, $00 db $ff, $ff Data_1f523: - db $13, $07 - db $14, $07 - db $15, $07 + tx MailRonaldsScoutMamiSenderText + tx MailRonaldsScoutMamiSubjectText + tx MailRonaldsScoutMamiBody1Text db $00, $00 - db $16, $07 + tx MailRonaldsScoutMamiBody2Text db $00, $00 - db $17, $07 + tx MailRonaldsScoutMamiBody3Text db $00, $00 - db $18, $07 + tx MailRonaldsScoutMamiBody4Text db $00, $00 - db $19, $07 + tx MailRonaldsScoutMamiBody5Text db $00, $00 db $ff, $ff Data_1f53d: - db $1a, $07 - db $1b, $07 - db $1c, $07 + tx MailRonaldsScoutColorlessAltarSenderText + tx MailRonaldsScoutColorlessAltarSubjectText + tx MailRonaldsScoutColorlessAltarBody1Text db $00, $00 - db $1d, $07 + tx MailRonaldsScoutColorlessAltarBody2Text db $00, $00 - db $1e, $07 + tx MailRonaldsScoutColorlessAltarBody3Text db $00, $00 - db $1f, $07 + tx MailRonaldsScoutColorlessAltarBody4Text db $00, $00 db $ff, $ff Data_1f553: - db $20, $07 - db $21, $07 - db $22, $07 + tx MailRonaldsScoutBiruritchiSenderText + tx MailRonaldsScoutBiruritchiSubjectText + tx MailRonaldsScoutBiruritchiBody1Text db $00, $00 - db $23, $07 + tx MailRonaldsScoutBiruritchiBody2Text db $00, $00 - db $24, $07 + tx MailRonaldsScoutBiruritchiBody3Text db $00, $00 - db $25, $07 + tx MailRonaldsScoutBiruritchiBody4Text db $00, $00 - db $26, $07 + tx MailRonaldsScoutBiruritchiBody5Text db $00, $00 db $ff, $ff Data_1f56d: - db $27, $07 - db $28, $07 - db $29, $07 + tx MailLinkDuelSenderText + tx MailLinkDuelSubjectText + tx MailLinkDuelBody1Text db $00, $00 - db $2a, $07 + tx MailLinkDuelBody2Text db $00, $00 - db $ff, $ff \ No newline at end of file + db $ff, $ff From 0f444f8e41f95a832ed836bff227c1af6c3ae424 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 10:59:42 -0600 Subject: [PATCH 16/27] documenting mail body commands --- src/constants/script_constants.asm | 11 + src/data/mail.asm | 346 +++++++++++++++-------------- src/engine/bank07.asm | 72 +++--- src/wram.asm | 2 +- 4 files changed, 230 insertions(+), 201 deletions(-) diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 42ce9fc..1399cd5 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -333,6 +333,17 @@ DEF SCRIPT_STACK_SIZE EQU $10 DEF wMAIL_QUEUE_BUFFER_SIZE EQU $19 DEF B_MAIL_READ EQU 7 +DEF B_MAIL_BOOSTER_PACK EQU 7 +DEF B_MAIL_GENERIC_CARD EQU 6 +DEF B_MAIL_BLACK_BOX EQU 5 +DEF B_MAIL_BILLS_PC EQU 4 + +DEF MAIL_COMMAND_GIVE_BOOSTER EQU 1 << B_MAIL_BOOSTER_PACK +DEF MAIL_COMMAND_GIVE_GENERIC_CARD EQU 1 << B_MAIL_GENERIC_CARD +DEF MAIL_COMMAND_GIVE_BLACK_BOX EQU 1 << B_MAIL_BLACK_BOX +DEF MAIL_COMMAND_GIVE_BILLS_PC EQU 1 << B_MAIL_BILLS_PC +DEF MAIL_TERMINATOR EQU $ffff + ; TODO: Figure out why 2 is added in IngameCardPop const_def const SCRIPTED_CARD_POP_RONALD ; $0 diff --git a/src/data/mail.asm b/src/data/mail.asm index 2efb05a..ef824cf 100644 --- a/src/data/mail.asm +++ b/src/data/mail.asm @@ -1,337 +1,345 @@ -Data_1f34f: - db $89, $73 - db $8f, $73 - db $9d, $73 - db $ab, $73 - db $bd, $73 - db $d3, $73 - db $e9, $73 - db $fb, $73 - db $09, $74 - db $1b, $74 - db $29, $74 - db $3b, $74 - db $4d, $74 - db $5f, $74 - db $6d, $74 - db $7f, $74 - db $8d, $74 - db $9b, $74 - db $a9, $74 - db $b7, $74 - db $c5, $74 - db $db, $74 - db $ed, $74 - db $ff, $74 - db $11, $75 - db $23, $75 - db $3d, $75 - db $53, $75 - db $6d, $75 +MACRO end_mail + dw MAIL_TERMINATOR +ENDM -Data_1f389: +MACRO no_card + dw $0000 +ENDM + +Mail: + dw .MailEmpty + dw .MailBlackBox + dw .MailBillsPCOutput + dw .MailMailboxIntro + dw .MailDeckDiagnosis1 + dw .MailDeckDiagnosis2 + dw .MailDeckDiagnosis3 + dw .MailDeckDiagnosis4 + dw .MailAutoDeckMachine1 + dw .MailAutoDeckMachine2 + dw .MailAutoDeckMachine3 + dw .MailAutoDeckMachine4 + dw .MailAutoDeckMachine5 + dw .MailChallengeMachine + dw .MailGRChallengeMachine + dw .MailGrandMasterCup + dw .MailRonaldsScoutGR1 + dw .MailRonaldsScoutGR2 + dw .MailRonaldsScoutGR3 + dw .MailRonaldsScoutGR4 + dw .MailRonaldsScoutMorino + dw .MailRonaldsScoutCatherine + dw .MailRonaldsScoutHidero + dw .MailRonaldsScoutKanoko + dw .MailRonaldsScoutKamiya + dw .MailRonaldsScoutMami + dw .MailRonaldsScoutColorlessAltar + dw .MailRonaldsScoutBiruritchi + dw .MailLinkDuel + +.MailEmpty tx MailboxEmptySenderText tx MailboxEmptySubjectText - db $ff, $ff + end_mail -Data_1f38f: +.MailBlackBox tx MailBlackBoxOutputSenderText tx MailBlackBoxOutputSubjectText tx MailBlackBoxOutputBody1Text - db $00, $20 + db $00, MAIL_COMMAND_GIVE_BLACK_BOX tx MailBlackBoxOutputBody2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f39d: +.MailBillsPCOutput tx MailBillsPCOutputSenderText tx MailBillsPCOutputSubjectText tx MailBillsPCOutputBody1Text - db $00, $10 + db $00, MAIL_COMMAND_GIVE_BILLS_PC tx MailBillsPCOutputBody2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f3ab: +.MailMailboxIntro tx MailMailboxIntroSenderText tx MailMailboxIntroSubjectText tx MailMailboxIntroBody1Text - db $00, $00 + no_card tx MailMailboxIntroBody2Text - db $00, $00 + no_card tx MailMailboxIntroBody3Text - db $08, $80 - db $ff, $ff + db BOOSTER_PRESENT_PACK_1, MAIL_COMMAND_GIVE_BOOSTER + end_mail -Data_1f3bd: +.MailDeckDiagnosis1 tx MailDeckDiagnosis1SenderText tx MailDeckDiagnosis1SubjectText tx MailDeckDiagnosis1Body1Text - db $00, $00 + no_card tx MailDeckDiagnosis1Body2Text - db $00, $00 + no_card tx MailDeckDiagnosis1Body3Text - db $00, $00 + no_card tx MailDeckDiagnosis1Body4Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f3d3: +.MailDeckDiagnosis2 tx MailDeckDiagnosis2SenderText tx MailDeckDiagnosis2SubjectText tx MailDeckDiagnosis2Body1Text - db $00, $00 + no_card tx MailDeckDiagnosis2Body2Text - db $00, $00 + no_card tx MailDeckDiagnosis2Body3Text - db $00, $00 + no_card tx MailDeckDiagnosis2Body4Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f3e9: +.MailDeckDiagnosis3 tx MailDeckDiagnosis3SenderText tx MailDeckDiagnosis3SubjectText tx MailDeckDiagnosis3Body1Text - db $00, $00 + no_card tx MailDeckDiagnosis3Body2Text - db $00, $00 + no_card tx MailDeckDiagnosis3Body3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f3fb: +.MailDeckDiagnosis4 tx MailDeckDiagnosis4SenderText tx MailDeckDiagnosis4SubjectText tx MailDeckDiagnosis4Body1Text - db $00, $00 + no_card tx MailDeckDiagnosis4Body2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f409: +.MailAutoDeckMachine1 tx MailAutoDeckMachine1SenderText tx MailAutoDeckMachine1SubjectText tx MailAutoDeckMachine1Body1Text - db $00, $00 + no_card tx MailAutoDeckMachine1Body2Text - db $00, $00 + no_card tx MailAutoDeckMachine1Body3Text - db $00, $80 - db $ff, $ff + db BOOSTER_BEGINNING_POKEMON, MAIL_COMMAND_GIVE_BOOSTER + end_mail -Data_1f41b: +.MailAutoDeckMachine2 tx MailAutoDeckMachine2SenderText tx MailAutoDeckMachine2SubjectText tx MailAutoDeckMachine2Body1Text - db $00, $00 + no_card tx MailAutoDeckMachine2Body2Text - db $01, $80 - db $ff, $ff + db BOOSTER_LEGENDARY_POWER, MAIL_COMMAND_GIVE_BOOSTER + end_mail -Data_1f429: +.MailAutoDeckMachine3 tx MailAutoDeckMachine3SenderText tx MailAutoDeckMachine3SubjectText tx MailAutoDeckMachine3Body1Text - db $00, $00 + no_card tx MailAutoDeckMachine3Body2Text - db $00, $00 + no_card tx MailAutoDeckMachine3Body3Text - db $02, $80 - db $ff, $ff + db BOOSTER_ISLAND_OF_FOSSIL, MAIL_COMMAND_GIVE_BOOSTER + end_mail -Data_1f43b: +.MailAutoDeckMachine4 tx MailAutoDeckMachine4SenderText tx MailAutoDeckMachine4SubjectText tx MailAutoDeckMachine4Body1Text - db $00, $00 + no_card tx MailAutoDeckMachine4Body2Text - db $00, $00 + no_card tx MailAutoDeckMachine4Body3Text - db $04, $80 - db $ff, $ff + db BOOSTER_SKY_FLYING_POKEMON, MAIL_COMMAND_GIVE_BOOSTER + end_mail -Data_1f44d: +.MailAutoDeckMachine5 tx MailAutoDeckMachine5SenderText tx MailAutoDeckMachine5SubjectText tx MailAutoDeckMachine5Body1Text - db $00, $00 + no_card tx MailAutoDeckMachine5Body2Text - db $00, $00 + no_card tx MailAutoDeckMachine5Body3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f45f: +.MailChallengeMachine tx MailChallengeMachineSenderText tx MailChallengeMachineSubjectText tx MailChallengeMachineBody1Text - db $00, $00 + no_card tx MailChallengeMachineBody2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f46d: +.MailGRChallengeMachine tx MailGRChallengeMachineSenderText tx MailGRChallengeMachineSubjectText tx MailGRChallengeMachineBody1Text - db $00, $00 + no_card tx MailGRChallengeMachineBody2Text - db $00, $00 + no_card tx MailGRChallengeMachineBody3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f47f: +.MailGrandMasterCup tx MailGrandMasterCupSenderText tx MailGrandMasterCupSubjectText tx MailGrandMasterCupBody1Text - db $00, $00 + no_card tx MailGrandMasterCupBody2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f48d: +.MailRonaldsScoutGR1 tx MailRonaldsScoutGR1SenderText tx MailRonaldsScoutGR1SubjectText tx MailRonaldsScoutGR1Body1Text - db $00, $00 + no_card tx MailRonaldsScoutGR1Body2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f49b: +.MailRonaldsScoutGR2 tx MailRonaldsScoutGR2SenderText tx MailRonaldsScoutGR2SubjectText tx MailRonaldsScoutGR2Body1Text - db $00, $00 + no_card tx MailRonaldsScoutGR2Body2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4a9: +.MailRonaldsScoutGR3 tx MailRonaldsScoutGR3SenderText tx MailRonaldsScoutGR3SubjectText tx MailRonaldsScoutGR3Body1Text - db $00, $00 + no_card tx MailRonaldsScoutGR3Body2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4b7: +.MailRonaldsScoutGR4 tx MailRonaldsScoutGR4SenderText tx MailRonaldsScoutGR4SubjectText tx MailRonaldsScoutGR4Body1Text - db $00, $00 + no_card tx MailRonaldsScoutGR4Body2Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4c5: +.MailRonaldsScoutMorino tx MailRonaldsScoutMorinoSenderText tx MailRonaldsScoutMorinoSubjectText tx MailRonaldsScoutMorinoBody1Text - db $00, $00 + no_card tx MailRonaldsScoutMorinoBody2Text - db $00, $00 + no_card tx MailRonaldsScoutMorinoBody3Text - db $00, $00 + no_card tx MailRonaldsScoutMorinoBody4Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4db: +.MailRonaldsScoutCatherine tx MailRonaldsScoutCatherineSenderText tx MailRonaldsScoutCatherineSubjectText tx MailRonaldsScoutCatherineBody1Text - db $00, $00 + no_card tx MailRonaldsScoutCatherineBody2Text - db $00, $00 + no_card tx MailRonaldsScoutCatherineBody3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4ed: +.MailRonaldsScoutHidero tx MailRonaldsScoutHideroSenderText tx MailRonaldsScoutHideroSubjectText tx MailRonaldsScoutHideroBody1Text - db $00, $00 + no_card tx MailRonaldsScoutHideroBody2Text - db $00, $00 + no_card tx MailRonaldsScoutHideroBody3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f4ff: +.MailRonaldsScoutKanoko tx MailRonaldsScoutKanokoSenderText tx MailRonaldsScoutKanokoSubjectText tx MailRonaldsScoutKanokoBody1Text - db $00, $00 + no_card tx MailRonaldsScoutKanokoBody2Text - db $00, $00 + no_card tx MailRonaldsScoutKanokoBody3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f511: +.MailRonaldsScoutKamiya tx MailRonaldsScoutKamiyaSenderText tx MailRonaldsScoutKamiyaSubjectText tx MailRonaldsScoutKamiyaBody1Text - db $00, $00 + no_card tx MailRonaldsScoutKamiyaBody2Text - db $00, $00 + no_card tx MailRonaldsScoutKamiyaBody3Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f523: +.MailRonaldsScoutMami tx MailRonaldsScoutMamiSenderText tx MailRonaldsScoutMamiSubjectText tx MailRonaldsScoutMamiBody1Text - db $00, $00 + no_card tx MailRonaldsScoutMamiBody2Text - db $00, $00 + no_card tx MailRonaldsScoutMamiBody3Text - db $00, $00 + no_card tx MailRonaldsScoutMamiBody4Text - db $00, $00 + no_card tx MailRonaldsScoutMamiBody5Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f53d: +.MailRonaldsScoutColorlessAltar tx MailRonaldsScoutColorlessAltarSenderText tx MailRonaldsScoutColorlessAltarSubjectText tx MailRonaldsScoutColorlessAltarBody1Text - db $00, $00 + no_card tx MailRonaldsScoutColorlessAltarBody2Text - db $00, $00 + no_card tx MailRonaldsScoutColorlessAltarBody3Text - db $00, $00 + no_card tx MailRonaldsScoutColorlessAltarBody4Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f553: +.MailRonaldsScoutBiruritchi tx MailRonaldsScoutBiruritchiSenderText tx MailRonaldsScoutBiruritchiSubjectText tx MailRonaldsScoutBiruritchiBody1Text - db $00, $00 + no_card tx MailRonaldsScoutBiruritchiBody2Text - db $00, $00 + no_card tx MailRonaldsScoutBiruritchiBody3Text - db $00, $00 + no_card tx MailRonaldsScoutBiruritchiBody4Text - db $00, $00 + no_card tx MailRonaldsScoutBiruritchiBody5Text - db $00, $00 - db $ff, $ff + no_card + end_mail -Data_1f56d: +.MailLinkDuel tx MailLinkDuelSenderText tx MailLinkDuelSubjectText tx MailLinkDuelBody1Text - db $00, $00 + no_card tx MailLinkDuelBody2Text - db $00, $00 - db $ff, $ff + no_card + end_mail diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 66aae09..1feb0bb 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6578,7 +6578,7 @@ _ReadMail: add a ld c, a ld b, $00 - ld hl, $734f ; TODO: data table of all mail + ld hl, Mail add hl, bc ld a, [hli] ld h, [hl] @@ -6594,7 +6594,7 @@ _ReadMail: ld [wMailSubjectText + 1], a call PrintMailSubject .read_mail_loop - ; mail is terminated with $ffff + ; mail is terminated with MAIL_TERMINATOR ($ffff) ld a, [hl] cp $ff jr nz, .print_body @@ -6609,7 +6609,7 @@ _ReadMail: call WaitForWideTextBoxInput pop hl .asm_1f074 - call ProcessMailCommand + call GiveCardsAttachedToMailPage jr .read_mail_loop .done ret @@ -6668,53 +6668,62 @@ PrintMailBodyPage: inc hl ret -; processes a mail command at hl that is not just body text (e.g. giving booster packs or cards) -ProcessMailCommand: +; give the card(s) attached to the current page of mail, if present +GiveCardsAttachedToMailPage: push hl ld a, [wMailId] bit B_MAIL_READ, a ; don't give out a card again if this mail has already been read jr nz, .done + ld a, [hli] ld b, [hl] ld c, a or b jr z, .done - bit 7, b - jr nz, .asm_1f0e5 - bit 6, b - jr nz, .asm_1f0f6 - bit 5, b - jr nz, .asm_1f103 - bit 4, b - jr nz, .asm_1f11b + bit B_MAIL_BOOSTER_PACK, b + jr nz, .give_booster + bit B_MAIL_GENERIC_CARD, b + jr nz, .give_generic_card + bit B_MAIL_BLACK_BOX, b + jr nz, .give_blackbox_cards + bit B_MAIL_BILLS_PC, b + jr nz, .give_billspc_card + .done pop hl inc hl inc hl ret -.asm_1f0e5 + +; gives the booster pack specified in the first byte of the command +.give_booster call StartFadeToWhite call WaitPalFading_Bank07 ld a, c ld b, $00 call GiveBoosterPacks - call .asm_1f140 + call .redraw_mail_screen jr .done -.asm_1f0f6 +; gives a card specified in the first byte of the command. +; this would effectively be a "hard-coded" card delivered with the mail. +; appears to be unused in the real game mail data +.give_generic_card ld a, b - and $3f + and %00111111 ld d, a ld e, c - call .asm_1f12d - call .asm_1f140 + call .give_card + call .redraw_mail_screen jr .done -.asm_1f103 +; gives the cards attached to black box mail, found at [wBlackBoxCardReceived] +; clears out the cards by setting to $0000 as it gives them +.give_blackbox_cards push hl ld hl, wBlackBoxCardReceived -.asm_1f107 +.blackbox_card_loop xor a ld e, [hl] ld [hli], a @@ -6722,15 +6731,16 @@ ProcessMailCommand: ld [hli], a ld a, d or e - jr z, .asm_1f115 - call .asm_1f12d - jr .asm_1f107 -.asm_1f115 + jr z, .loop_done + call .give_card + jr .blackbox_card_loop +.loop_done pop hl - call .asm_1f140 + call .redraw_mail_screen jr .done -.asm_1f11b +; gives the cards attached to bill's PC mail, found at [wBillsPCCardReceived] +.give_billspc_card push hl ld hl, wBillsPCCardReceived xor a @@ -6738,12 +6748,12 @@ ProcessMailCommand: ld [hli], a ld d, [hl] ld [hli], a - call .asm_1f12d + call .give_card pop hl - call .asm_1f140 + call .redraw_mail_screen jr .done -.asm_1f12d +.give_card call StartFadeToWhite call WaitPalFading_Bank07 push hl @@ -6753,7 +6763,7 @@ ProcessMailCommand: pop hl ret -.asm_1f140 +.redraw_mail_screen inc hl ld a, [hli] ld b, a diff --git a/src/wram.asm b/src/wram.asm index 749c3a6..ddf7600 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -3321,7 +3321,7 @@ wMailOptionSelected:: ; dd5e wBlackBoxCardReceived:: ; dd5f ds $2 -; TODO: are these also black box cards? +; TODO: how many of these are these also black box cards? ds $12 ; card offset. the card mailed to you after using the Game Center Bill's PC From 2fef8e67836df5c1c13601b3fb6ad69a5f12c727 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 11:12:25 -0600 Subject: [PATCH 17/27] adding a few more mail-related constants --- src/constants/script_constants.asm | 6 +++++- src/engine/bank07.asm | 10 +++++----- src/wram.asm | 11 ++++------- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 1399cd5..b18bc43 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -330,7 +330,11 @@ ENDR DEF wD606_STRUCT_SIZE EQU $8 DEF SCRIPT_BUFFER_SIZE EQU $20 DEF SCRIPT_STACK_SIZE EQU $10 -DEF wMAIL_QUEUE_BUFFER_SIZE EQU $19 + +DEF MAIL_QUEUE_BUFFER_SIZE EQU $19 +DEF BLACK_BOX_CARDS_BUFFER_SIZE EQU $14 +DEF MAIL_MAX_NUM EQU 8 +DEF MAIL_BUFFER_SIZE EQU MAIL_MAX_NUM + 1 DEF B_MAIL_READ EQU 7 DEF B_MAIL_BOOSTER_PACK EQU 7 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 1feb0bb..8025bf3 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6176,11 +6176,11 @@ InitializeMailboxWRAM: ld [wBillsPCCardReceived + 1], a xor a ld hl, wMailQueue - ld bc, wMAIL_QUEUE_BUFFER_SIZE + ld bc, MAIL_QUEUE_BUFFER_SIZE call WriteBCBytesToHL xor a ld hl, wMailList - ld bc, $9 + ld bc, MAIL_BUFFER_SIZE call WriteBCBytesToHL pop hl pop de @@ -6925,7 +6925,7 @@ DeleteGameCenterMailedCard: ret ; input: a -; set carry if [wNumMailInQueue] = wMAIL_QUEUE_BUFFER_SIZE - 1 +; set carry if [wNumMailInQueue] = MAIL_QUEUE_BUFFER_SIZE - 1 ; else: ; - if bit 7 of a is 0, [wMailQueue + [wNumMailInQueue] ] = a ; - if bit 7 of a is 1, @@ -6938,7 +6938,7 @@ Func_1f24e: push hl ld e, a ld a, [wNumMailInQueue] - cp wMAIL_QUEUE_BUFFER_SIZE - 1 + cp MAIL_QUEUE_BUFFER_SIZE - 1 jr z, .set_carry bit 7, e call z, .not_bit7 @@ -6972,7 +6972,7 @@ Func_1f24e: .has_bit7: push af ld hl, wMailQueue - ld c, wMAIL_QUEUE_BUFFER_SIZE - 1 + ld c, MAIL_QUEUE_BUFFER_SIZE - 1 .check_byte_loop bit 7, [hl] jr z, .shift_loop diff --git a/src/wram.asm b/src/wram.asm index ddf7600..ad513c0 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -3283,7 +3283,7 @@ wNumMailInQueue:: ; dd36 ; list of mail items queued to be delivered wMailQueue:: ; dd37 - ds wMAIL_QUEUE_BUFFER_SIZE + ds MAIL_QUEUE_BUFFER_SIZE ; total number of mail in your mailbox wMailCount:: ; dd50 @@ -3293,7 +3293,7 @@ wMailCount:: ; dd50 ; Each byte is the id of a mail item. ; When mail is read, $80 is added to the id wMailList:: ; dd51 - ds $9 + ds MAIL_BUFFER_SIZE ; $ff when the player has new mail. set to 0 when opening mincom mail menu. affects the mailbox animation wNewMail:: ; dd5a @@ -3317,12 +3317,9 @@ wSelectedMailCursorPosition:: ; dd5d wMailOptionSelected:: ; dd5e ds $1 -; card offset. the card mailed to you after using the Game Center black box +; card offsets. the cards mailed to you after using the Game Center black box wBlackBoxCardReceived:: ; dd5f - ds $2 - -; TODO: how many of these are these also black box cards? - ds $12 + ds BLACK_BOX_CARDS_BUFFER_SIZE ; card offset. the card mailed to you after using the Game Center Bill's PC wBillsPCCardReceived:: ; dd73 From 1316fa2fc8970858629651a25240c1bbaab48003 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 13:01:07 -0600 Subject: [PATCH 18/27] documenting a number of commands related to sending/delivering mail also identified script_command_64 as the send_mail command! --- src/constants/script_constants.asm | 6 +- src/engine/bank03.asm | 41 ++++++------ src/engine/bank07.asm | 100 +++++++++++++++++------------ src/engine/bank0b.asm | 12 ++-- src/engine/bank0c.asm | 20 +++--- src/engine/bank0d.asm | 28 ++++---- src/engine/bank0f.asm | 4 +- src/engine/bank10.asm | 14 ++-- src/macros/scripts.asm | 6 +- src/wram.asm | 10 +-- 10 files changed, 135 insertions(+), 106 deletions(-) diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index b18bc43..3dec787 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -331,11 +331,15 @@ DEF wD606_STRUCT_SIZE EQU $8 DEF SCRIPT_BUFFER_SIZE EQU $20 DEF SCRIPT_STACK_SIZE EQU $10 -DEF MAIL_QUEUE_BUFFER_SIZE EQU $19 DEF BLACK_BOX_CARDS_BUFFER_SIZE EQU $14 +DEF MAIL_QUEUE_BUFFER_SIZE EQU $19 +DEF NEW_MAIL EQU $ff +DEF NUM_UNIQUE_MAILS_IN_GAME EQU 29 DEF MAIL_MAX_NUM EQU 8 DEF MAIL_BUFFER_SIZE EQU MAIL_MAX_NUM + 1 + DEF B_MAIL_READ EQU 7 +DEF B_MAIL_PRIORITY_DELIVERY EQU 7 DEF B_MAIL_BOOSTER_PACK EQU 7 DEF B_MAIL_GENERIC_CARD EQU 6 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 3317aa4..2ec2313 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -348,10 +348,10 @@ Func_c24d: ld [wd586], a ld [wCurOWLocation], a ld [wCurMusic], a - ld [wd611 + 0], a - ld [wd611 + 1], a - ld [wd613 + 0], a - ld [wd613 + 1], a + ld [wSentMailBitmask + 0], a + ld [wSentMailBitmask + 1], a + ld [wSentMailBitmask + 2], a + ld [wSentMailBitmask + 3], a call Func_ebc6 jr nc, .asm_c299 call Func_eb39 @@ -2836,7 +2836,7 @@ OverworldScriptTable: dw ScriptCommand_SetTextRAM2b ; $61 dw ScriptCommand_SetVariableTextRAM2b ; $62 dw ScriptCommand_ReplaceNPC ; $63 - dw ScriptCommand_64 ; $64 + dw ScriptCommand_SendMail ; $64 dw ScriptCommand_CheckNPCLoaded ; $65 dw ScriptCommand_GiveDeck ; $66 dw ScriptCommand_67 ; $67 @@ -4388,22 +4388,24 @@ ScriptCommand_ReplaceNPC: jp IncreaseScriptPointerBy3 ; for the buffer value n, -; - if n = 0 or n >= 29, skip -; - else, set bit (m-1) of [dw hl] and Func_1f24e, where -; - hl = wd611 and m = n if 0 < n <= 16, -; - hl = wd613 and m = n-16 if 16 < n < 29, +; - if n = 0 or n >= NUM_UNIQUE_MAILS_IN_GAME, skip +; - else, set bit (m-1) of [dw hl] and AddMailToQueue, where +; - hl = wSentMailBitmask and m = n if 0 < n <= 16, +; - hl = wSentMailBitmask + 2 and m = n-16 if 16 < n < NUM_UNIQUE_MAILS_IN_GAME, ; then IncreaseScriptPointerBy2 -ScriptCommand_64: +ScriptCommand_SendMail: call Get1ScriptArg_IncrIndexBy1 or a - jr z, .done - cp $1d - jr nc, .done - ld hl, wd611 + jr z, .done ; 0 is an invalid mail number + + cp NUM_UNIQUE_MAILS_IN_GAME + jr nc, .done ; mail > NUM_UNIQUE_MAILS_IN_GAME is another invalid mail number + + ld hl, wSentMailBitmask cp $10 + 1 jr c, .set_bitmask inc hl - inc hl ; wd613 + inc hl ; wSentMailBitmask + 2 sub $10 .set_bitmask ld de, 1 @@ -4414,7 +4416,7 @@ ScriptCommand_64: rl d jr .set_bitmask_loop .got_bitmask - ld a, [hli] + ld a, [hli] ; wSentMailBitmask or wSentMailBitmask + 2 ld c, a ld a, [hld] ld b, a @@ -4424,8 +4426,11 @@ ScriptCommand_64: ld a, b and d .checked_bit + ; if the bit is set then we have already sent this mail before. do not send again jr nz, .done -; set bit and call + + ; if we got here, this mail has never been sent before. + ; set the appropriate bit in the bitmask, and send the mail ld a, c or e ld c, a @@ -4436,7 +4441,7 @@ ScriptCommand_64: ld [hli], a ld [hl], b call Get1ScriptArg_IncrIndexBy1 - farcall Func_1f24e + farcall AddMailToQueue .done jp IncreaseScriptPointerBy2 diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 8025bf3..d248c32 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6924,32 +6924,34 @@ DeleteGameCenterMailedCard: call SetBillsPCCard ret -; input: a -; set carry if [wNumMailInQueue] = MAIL_QUEUE_BUFFER_SIZE - 1 +; input: a - new mail to add to queue +; set carry and quit if mail queue is full, i.e. [wNumMailInQueue] = MAIL_QUEUE_BUFFER_SIZE - 1 ; else: -; - if bit 7 of a is 0, [wMailQueue + [wNumMailInQueue] ] = a -; - if bit 7 of a is 1, -; (the first byte in wMailQueue[n] whose bit 7 is 0) = a -; and shift the rest -; and increment [wNumMailInQueue] by 1 -Func_1f24e: +; - if bit 7 (B_MAIL_PRIORITY_DELIVERY) of a is 0, add to the END of the mail queue +; - if bit 7 (B_MAIL_PRIORITY_DELIVERY) of a is 1, +; add to the FRONT of the mail queue and shift the rest +; this new mail will be inserted BETWEEN any current priority mail in the queue, and the non-priority +; finally, increment [wNumMailInQueue] by 1 +AddMailToQueue: push bc push de push hl ld e, a ld a, [wNumMailInQueue] cp MAIL_QUEUE_BUFFER_SIZE - 1 - jr z, .set_carry - bit 7, e - call z, .not_bit7 - call nz, .has_bit7 + jr z, .mail_queue_full + + bit B_MAIL_PRIORITY_DELIVERY, e + call z, .not_priority + call nz, .has_priority + ld hl, wNumMailInQueue inc [hl] ; clear carry scf ccf jr .done -.set_carry +.mail_queue_full scf ; fallthrough .done @@ -6958,7 +6960,8 @@ Func_1f24e: pop bc ret -.not_bit7: +; if not priority mail, add it to the END of the mail queue +.not_priority: push af ld a, [wNumMailInQueue] ld c, a @@ -6969,19 +6972,22 @@ Func_1f24e: pop af ret -.has_bit7: +; if mail is high priority, add it to the FRONT of the mail queue +; black box and bill's PC mail, for example, are sent as high priority +.has_priority: push af ld hl, wMailQueue ld c, MAIL_QUEUE_BUFFER_SIZE - 1 + ; skip past other high priority mail .check_byte_loop - bit 7, [hl] + bit B_MAIL_PRIORITY_DELIVERY, [hl] jr z, .shift_loop inc hl dec c jr nz, .check_byte_loop .shift_loop ld b, [hl] - ld [hl], e + ld [hl], e ; at top of function, e was copied from input a (our new mail) ld e, b inc hl dec c @@ -6989,52 +6995,63 @@ Func_1f24e: pop af ret -Func_1f293: +DeliverMailFromQueue: push af push bc push de push hl ld a, [wNumMailInQueue] and a - jr z, .asm_1f2eb - ld a, $ff + jr z, .done + + ld a, NEW_MAIL ld [wNewMail], a ld a, [wMailCount] - cp $08 - jr z, .asm_1f2eb + cp MAIL_MAX_NUM + ; if the mailbox already has MAIL_MAX_NUM, can't deliver more mail + jr z, .done + ld de, wMailList ld hl, wMailQueue ld a, [wMailCount] ld b, a - ld a, $08 + ld a, MAIL_MAX_NUM sub b - ld b, a - ld c, $00 -.asm_1f2b9 + ld b, a ; number of mail to insert + ld c, $00 ; counts how many times we insert mail in the loop + +.insert_new_mail_loop ld a, [hli] and a - jr z, .asm_1f2c6 - res 7, a - call .Func_1f2f6 + ; break the loop if the next mail in the queue is $00, i.e. we have drained the whole queue + jr z, .done_inserting_mail + ; reset bit 7, because when mail is in the mailbox it means it has been read (B_MAIL_READ) + res B_MAIL_PRIORITY_DELIVERY, a + call InsertNewMail inc c dec b - jr nz, .asm_1f2b9 -.asm_1f2c6 + jr nz, .insert_new_mail_loop + ; fallthrough if b = 0; i.e. when we have filled up the mailbox again + +.done_inserting_mail + ; update the mail counts based on how many we inserted ld a, [wMailCount] add c ld [wMailCount], a ld a, [wNumMailInQueue] sub c ld [wNumMailInQueue], a + ld hl, wMailQueue ld b, $00 add hl, bc ld de, wMailQueue - ld a, $18 + ld a, MAIL_QUEUE_BUFFER_SIZE - 1 sub c ld c, a ld a, [hli] -.asm_1f2e2 + +.loop2 ld [de], a inc de ld b, [hl] @@ -7042,8 +7059,9 @@ Func_1f293: ld [hli], a ld a, b dec c - jr nz, .asm_1f2e2 -.asm_1f2eb + jr nz, .loop2 + +.done ld a, [wNumMailInQueue] ld [wTempNumMailInQueue], a pop hl @@ -7052,12 +7070,14 @@ Func_1f293: pop af ret -; shift data in de 1 byte right -.Func_1f2f6: +; a - new mail to add +; de - wMailList +; Shifts the mail list one byte to the right, and inserts (a) at the front +InsertNewMail: push bc push de push hl - ld c, $08 + ld c, MAIL_MAX_NUM .loop ld l, a ld a, [de] @@ -7686,8 +7706,8 @@ Func_1f8f7: ldtx hl, GameCenterToBeMailedText_2 farcall PrintScrollableText_NoTextBoxLabelVRAM0 call SetBillsPCCard - ld a, $82 - call Func_1f24e + ld a, $82 ; priority bill's PC mail + call AddMailToQueue .asm_1f914 farcall FadeToWhiteAndUnsetFrameFunc pop hl diff --git a/src/engine/bank0b.asm b/src/engine/bank0b.asm index a80ef61..2e7a5ab 100644 --- a/src/engine/bank0b.asm +++ b/src/engine/bank0b.asm @@ -69,7 +69,7 @@ Func_2c0c8: Func_2c0d1: xor a start_script - script_command_64 $11 + send_mail $11 end_script ld a, EVENT_F5 farcall GetEventValue @@ -700,7 +700,7 @@ Func_2c584: xor a start_script wait_for_fade - script_command_64 $13 + send_mail $13 set_event EVENT_MET_GR4_LIGHTNING_CLUB set_active_npc NPC_GR_4, DialogGR4Text script_command_01 @@ -6031,7 +6031,7 @@ Func_2ed37: Func_2ed3e: xor a start_script - script_command_64 $12 + send_mail $12 end_script call WaterClubEntrance_ShouldRonaldAppear jr c, .quit @@ -6529,7 +6529,7 @@ Script_2f127: reset_event EVENT_TALKED_TO_KEN reset_event EVENT_TALKED_TO_ADAM reset_event EVENT_TALKED_TO_GR3_WATER_CLUB - script_command_64 $05 + send_mail $05 print_npc_text Text0833 script_command_02 set_active_npc_direction WEST @@ -7128,7 +7128,7 @@ Func_2f56e: Func_2f575: xor a start_script - script_command_64 $12 + send_mail $12 end_script call FireClubEntrance_ShouldRonaldAppear jr c, .quit @@ -8024,7 +8024,7 @@ Func_2fc29: ret Script_2fc3e: - script_command_64 $09 + send_mail $09 set_event EVENT_GOT_GR_COIN_PIECE_BOTTOM_LEFT print_npc_text Text0c6e give_coin COIN_GR_START + COIN_GR_PIECE3 diff --git a/src/engine/bank0c.asm b/src/engine/bank0c.asm index 0658031..b0b8bbe 100644 --- a/src/engine/bank0c.asm +++ b/src/engine/bank0c.asm @@ -234,7 +234,7 @@ Func_30192: Func_301c0: farcall Func_d683 - farcall Func_1f293 + farcall DeliverMailFromQueue call WaitPalFading .loop call DoFrame @@ -1784,7 +1784,7 @@ Func_317eb: ld a, [wd584] cp MAP_GRASS_FORT_ENTRANCE jr nz, .asm_317f6 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_317f6 ld bc, $3b ld a, $14 @@ -2552,7 +2552,7 @@ Func_31da0: script_jump_if_b0nz .ows_31dcb ask_question Text11ae, TRUE script_jump_if_b0z .ows_31dcb - script_command_64 $15 + send_mail $15 set_event EVENT_LIGHTNING_FORT_ENTRANCE_DOOR_STATE script_command_02 play_sfx SFX_DOORS @@ -2849,7 +2849,7 @@ Func_32016: ld a, [wd584] cp MAP_LIGHTNING_FORT_ENTRANCE jr nz, .asm_32021 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_32021 ld a, EVENT_RENNAS_ROOM_DOOR_STATE farcall GetEventValue @@ -3502,7 +3502,7 @@ Func_324e1: set_event EVENT_BEAT_CATHERINE set_var VAR_30, $01 set_var VAR_33, $00 - script_command_64 $07 + send_mail $07 print_npc_text Text11d6 give_booster_packs BoosterList_cd63 script_jump .ows_32524 @@ -3692,7 +3692,7 @@ Func_32664: script_jump_if_b0nz .ows_3268f ask_question Text0c83, TRUE script_jump_if_b0z .ows_3268f - script_command_64 $16 + send_mail $16 set_event EVENT_FIRE_FORT_ENTRANCE_DOOR_STATE script_command_02 play_sfx SFX_DOORS @@ -3936,7 +3936,7 @@ Func_3286d: ld a, [wd584] cp MAP_FIRE_FORT_ENTRANCE jr nz, .asm_32878 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_32878 ld a, EVENT_JES_ROOM_DOOR_STATE farcall GetEventValue @@ -5061,7 +5061,7 @@ Func_3308e: script_jump_if_b0nz .ows_330b9 ask_question Text1215, TRUE script_jump_if_b0z .ows_330b9 - script_command_64 $17 + send_mail $17 set_event EVENT_WATER_FORT_ENTRANCE_DOOR_STATE script_command_02 play_sfx SFX_DOORS @@ -5127,7 +5127,7 @@ Func_33129: ld a, [wd584] cp MAP_WATER_FORT_ENTRANCE jr nz, .asm_33134 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_33134 ld a, EVENT_MIYAJIMAS_ROOM_DOOR_STATE farcall GetEventValue @@ -5632,7 +5632,7 @@ Func_334b3: ret Script_334f6: - script_command_64 $18 + send_mail $18 script_command_02 play_sfx SFX_DOORS load_tilemap TILEMAP_094, $04, $07 diff --git a/src/engine/bank0d.asm b/src/engine/bank0d.asm index ccba43a..6b10327 100644 --- a/src/engine/bank0d.asm +++ b/src/engine/bank0d.asm @@ -1,7 +1,7 @@ Script_34000: wait_for_fade set_var VAR_TIMES_MET_RONALD, $01 - script_command_64 $10 + send_mail $10 set_active_npc NPC_RONALD, DialogRonaldText move_player .NPCMovement_34031, TRUE wait_for_player_animation @@ -265,7 +265,7 @@ Func_341f7: xor a start_script wait_for_fade - script_command_64 $06 + send_mail $06 set_var VAR_TIMES_MET_RONALD, $04 set_var VAR_28, $01 set_var VAR_2B, $00 @@ -394,7 +394,7 @@ Func_342ef: xor a start_script wait_for_fade - script_command_64 $14 + send_mail $14 set_var VAR_TIMES_MET_RONALD, $05 load_npc NPC_GR_X, 4, 15, SOUTH set_active_npc NPC_GR_X, DialogGRXText @@ -561,8 +561,8 @@ Func_3442d: xor a start_script wait_for_fade - script_command_64 $19 - script_command_64 $1a + send_mail $19 + send_mail $1a set_var VAR_TIMES_MET_RONALD, $07 script_command_01 print_npc_text Text1285 @@ -601,7 +601,7 @@ Func_3442d: Func_3448d: xor a start_script - script_command_64 $1b + send_mail $1b set_var VAR_TIMES_MET_RONALD, $08 play_song_next MUSIC_RONALD do_frames 60 @@ -1705,8 +1705,8 @@ Func_34d15: farcall Func_1312e jr c, .asm_34d2f farcall Func_4569f - ld a, $81 - farcall Func_1f24e + ld a, $81 ; priority black box mail + farcall AddMailToQueue .asm_34d2f ld a, $00 ld [wd582], a @@ -2830,7 +2830,7 @@ Func_35596: script_jump_if_b0nz .ows_355b4 set_event EVENT_BEAT_MORINO reset_event EVENT_TALKED_TO_MORINO - script_command_64 $0a + send_mail $0a print_npc_text Text0dc0 give_booster_packs BoosterList_cd59 script_jump .ows_355d1 @@ -3409,7 +3409,7 @@ Func_35a0d: ld a, [wd584] cp MAP_FIGHTING_FORT_ENTRANCE jr nz, .asm_35a18 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_35a18 ld a, EVENT_BEAT_KAMIYA farcall GetEventValue @@ -3630,7 +3630,7 @@ Func_35b82: end_script ret .ows_35bbf - script_command_64 $0b + send_mail $0b set_event EVENT_GOT_MACHAMP_COIN print_npc_text Text0c25 give_coin COIN_MACHAMP @@ -4628,7 +4628,7 @@ Func_3639f: ld a, [wd584] cp MAP_PSYCHIC_STRONGHOLD_ENTRANCE jr nz, .asm_363aa - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_363aa xor a start_script @@ -6205,7 +6205,7 @@ Func_36fe9: ret Func_36ff2: - farcall Func_1f293 + farcall DeliverMailFromQueue ld a, EVENT_MET_COLORLESS_ALTAR_MEMBERS farcall GetEventValue jr nz, .asm_3700f @@ -7044,7 +7044,7 @@ Func_3766c: ld a, [wd584] cp MAP_GR_CASTLE_ENTRANCE jr nz, .asm_37677 - farcall Func_1f293 + farcall DeliverMailFromQueue .asm_37677 ld a, EVENT_MET_BIRURITCHI_AND_ADMINS farcall GetEventValue diff --git a/src/engine/bank0f.asm b/src/engine/bank0f.asm index e3e37c5..67131b6 100644 --- a/src/engine/bank0f.asm +++ b/src/engine/bank0f.asm @@ -230,7 +230,7 @@ Func_3c1d0: ask_question BattleCenterBeginPromptText, TRUE script_jump_if_b0z .ows_3c20b play_song MUSIC_CARD_POP - script_command_64 $1c + send_mail $1c script_command_02 link_duel script_jump_if_b1nz .ows_3c204 @@ -346,7 +346,7 @@ Func_3c1d0: get_var VAR_20 compare_loaded_var $05 script_jump_if_b0z .ows_3c2d8 - script_command_64 $0f + send_mail $0f .ows_3c2d8 script_ret diff --git a/src/engine/bank10.asm b/src/engine/bank10.asm index f5c025c..46636a6 100644 --- a/src/engine/bank10.asm +++ b/src/engine/bank10.asm @@ -860,7 +860,7 @@ Func_4053e: HandleTCGIslandInput: farcall Func_d683 - farcall Func_1f293 + farcall DeliverMailFromQueue call WaitPalFading .loop_input call DoFrame @@ -1514,9 +1514,9 @@ Func_40f46: wait_for_player_animation set_active_npc NPC_DR_MASON, DialogDrMasonText script_command_01 - script_command_64 $03 - script_command_64 $04 - script_command_64 $08 + send_mail $03 + send_mail $04 + send_mail $08 set_event EVENT_GOT_CHANSEY_COIN script_call .ows_40f83 script_call .ows_40fac @@ -1647,7 +1647,7 @@ Func_4101d: start_script set_event EVENT_EB set_var VAR_34, $01 - script_command_64 $0d + send_mail $0d end_script farcall Func_eff7 jr .asm_41073 @@ -3420,7 +3420,7 @@ Func_41d64: script_command_02 script_jump .ows_41d99 .ows_41d94 - script_command_64 $0e + send_mail $0e script_jump .ows_41d88 .ows_41d99 end_script @@ -5719,7 +5719,7 @@ Func_42fe1: script_jump Script_432a0 Script_43000: - script_command_64 $0c + send_mail $0c play_song_next MUSIC_HALL_OF_HONOR script_command_02 print_npc_text Text0927 diff --git a/src/macros/scripts.asm b/src/macros/scripts.asm index dc51c9b..2f04014 100644 --- a/src/macros/scripts.asm +++ b/src/macros/scripts.asm @@ -107,7 +107,7 @@ ENDM const ScriptCommand_SetTextRAM2b_index ; $61 const ScriptCommand_SetVariableTextRAM2b_index ; $62 const ScriptCommand_ReplaceNPC_index ; $63 - const ScriptCommand_64_index ; $64 + const ScriptCommand_SendMail_index ; $64 const ScriptCommand_CheckNPCLoaded_index ; $65 const ScriptCommand_GiveDeck_index ; $66 const ScriptCommand_67_index ; $67 @@ -664,8 +664,8 @@ MACRO replace_npc db \2 ; npc to load ENDM -MACRO script_command_64 - run_command ScriptCommand_64 +MACRO send_mail + run_command ScriptCommand_SendMail db \1 ENDM diff --git a/src/wram.asm b/src/wram.asm index ad513c0..bf7ae56 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -2379,11 +2379,11 @@ wScriptNPC:: ; d60e wScriptNPCName:: ; d60f ds $2 -wd611:: ; d611 - ds $2 - -wd613:: ; d613 - ds $2 +; a bitmask for every unique mail in the game (29 total). +; the corresponding bit is set when a mail is sent, and mask is checked before sending +; mail in event scripts. Mail that is not sent via event script skips the check. +wSentMailBitmask:: ; d611 + ds $4 wd615:: ; d615 ds $1 From f9f9f28bbdfe819f37e9eb379a523b5b818267bc Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 13:04:47 -0600 Subject: [PATCH 19/27] fixed minicom typo I mistyped minicom as minicon in a lot of places. oops --- src/engine/bank04.asm | 2 +- src/engine/bank07.asm | 66 +++++++++++++++++++++---------------------- src/wram.asm | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 03fd74a..7442214 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1271,7 +1271,7 @@ Func_10836: key_func $00, PauseMenuStatusScreen ; status key_func $01, PauseMenuDiaryScreen ; diary key_func $02, PauseMenuDeckScreen ; deck - key_func $03, PauseMenuMiniconScreen ; minicon + key_func $03, PauseMenuMinicomScreen ; minicom key_func $04, PauseMenuCoinScreen ; coin key_func $05, PauseMenuSettingsScreen ; settings db $ff diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index d248c32..a18bf1f 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -3014,7 +3014,7 @@ Func_1d475: farcall ClearCardPopNameList call EnableAnimations - call ClearwMiniconMenuCursorPosition + call ClearwMinicomMenuCursorPosition farcall Func_111f0 call InitDefaultConfigMenuSettings call SaveConfigMenuChoicesToSRAM @@ -5543,53 +5543,53 @@ Func_1e73a: pop af ret -PauseMenuMiniconScreen: +PauseMenuMinicomScreen: farcall Func_1022a - call PushRegistersAndShowMiniconScreen + call PushRegistersAndShowMinicomScreen farcall Func_10252 ret -PushRegistersAndShowMiniconScreen: +PushRegistersAndShowMinicomScreen: push af push bc push de push hl - call ShowMiniconScreen + call ShowMinicomScreen pop hl pop de pop bc pop af ret -ClearwMiniconMenuCursorPosition: +ClearwMinicomMenuCursorPosition: xor a - ld [wMiniconMenuCursorPosition], a + ld [wMinicomMenuCursorPosition], a ret -ShowMiniconScreen: +ShowMinicomScreen: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - call DrawMiniconMainScreen + call DrawMinicomMainScreen farcall SetFrameFuncAndFadeFromWhite .loop call HandleMinicomMenuBox jr c, .end - call CallMiniconMenuFunction + call CallMinicomMenuFunction jr c, .end call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration - call DrawMiniconMainScreen + call DrawMinicomMainScreen call EnableLCD jr .loop .end farcall FadeToWhiteAndUnsetFrameFunc ret -DrawMiniconMainScreen: +DrawMinicomMainScreen: ld b, BANK(.menu) ld hl, .menu lb de, 0, 3 call LoadMenuBoxParams - ld a, [wMiniconMenuCursorPosition] + ld a, [wMinicomMenuCursorPosition] call DrawMenuBox lb de, 0, 0 lb bc, 20, 4 @@ -5629,11 +5629,11 @@ DrawMiniconMainScreen: SECTION "Bank 7@6808", ROMX[$6808], BANK[$7] ; return -; a - cursor position, used later in CallMiniconMenuFunction +; a - cursor position, used later in CallMinicomMenuFunction HandleMinicomMenuBox: - ld a, [wMiniconMenuCursorPosition] + ld a, [wMinicomMenuCursorPosition] call HandleMenuBox - ld [wMiniconMenuCursorPosition], a + ld [wMinicomMenuCursorPosition], a jr c, .cancel push af ld a, SFX_CONFIRM @@ -5648,30 +5648,30 @@ HandleMinicomMenuBox: ret ; a - function table index -CallMiniconMenuFunction: - ld hl, .minicon_functions +CallMinicomMenuFunction: + ld hl, .minicom_functions call CallMappedFunction ret -.minicon_functions: - key_func $00, MiniconDeckSaveMachine - key_func $01, MiniconMailbox - key_func $02, MiniconCardAlbum +.minicom_functions: + key_func $00, MinicomDeckSaveMachine + key_func $01, MinicomMailbox + key_func $02, MinicomCardAlbum db $ff -MiniconDeckSaveMachine: +MinicomDeckSaveMachine: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall Func_baec ret -MiniconCardAlbum: +MinicomCardAlbum: farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration farcall Func_a786 ret Func_1e849: farcall Func_1022a - call MiniconDeckSaveMachine + call MinicomDeckSaveMachine farcall Func_10252 ret @@ -6144,13 +6144,13 @@ Func_1ec0f: SECTION "Bank 7@6c96", ROMX[$6c96], BANK[$7] -MiniconMailbox: +MinicomMailbox: push af push bc push de push hl - call MiniconMailboxNewMailScreen - call MiniconMailboxMainScreen + call MinicomMailboxNewMailScreen + call MinicomMailboxMainScreen pop hl pop de pop bc @@ -6189,7 +6189,7 @@ InitializeMailboxWRAM: ret ; the screen after selecting the mailbox which has a large picture of a literal mailbox on it -MiniconMailboxNewMailScreen: +MinicomMailboxNewMailScreen: call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration call CalculateMailboxStatus @@ -6285,12 +6285,12 @@ Func_1ed5e: SECTION "Bank 7@6da5", ROMX[$6da5], BANK[$7] -MiniconMailboxMainScreen: +MinicomMailboxMainScreen: call DisableLCD farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration lb de, $40, $ff call SetupText - call MiniconMailboxMainScreen_DrawTextBoxes + call MinicomMailboxMainScreen_DrawTextBoxes call FlushAllPalettes call EnableLCD .loop @@ -6305,7 +6305,7 @@ MiniconMailboxMainScreen: .done ret -MiniconMailboxMainScreen_DrawTextBoxes: +MinicomMailboxMainScreen_DrawTextBoxes: lb de, 0, 4 lb bc, 20, 14 call DrawRegularTextBoxVRAM0 @@ -6772,7 +6772,7 @@ GiveCardsAttachedToMailPage: jr z, .done farcall ClearSpriteAnimsAndSetInitialGraphicsConfiguration call DisableLCD - call MiniconMailboxMainScreen_DrawTextBoxes + call MinicomMailboxMainScreen_DrawTextBoxes call DrawReadMailScreenHeader call PrintMailSender call PrintMailSubject diff --git a/src/wram.asm b/src/wram.asm index bf7ae56..3cabd9a 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -3210,7 +3210,7 @@ wdd05:: ; dd05 wdd06:: ; dd06 ds $1 -wMiniconMenuCursorPosition:: ; dd07 +wMinicomMenuCursorPosition:: ; dd07 ds $1 wCurBoosterPack:: ; dd08 From eec0aa5c59c04c3df67d5ba5ba9f63f2dcd2ba6e Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 13:20:24 -0600 Subject: [PATCH 20/27] send_mail script command missed adding this file two commits ago, oops --- tools/script_extractor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/script_extractor.py b/tools/script_extractor.py index 3e4d86c..0b4b1f2 100644 --- a/tools/script_extractor.py +++ b/tools/script_extractor.py @@ -126,7 +126,7 @@ script_commands = { 0x61: { "name": "set_text_ram2b", "params": [ "text" ] }, 0x62: { "name": "set_variable_text_ram2b", "params": [ "text", "text" ] }, 0x63: { "name": "replace_npc", "params": [ "npc", "npc" ] }, - 0x64: { "name": "script_command_64", "params": [ "byte" ] }, # ? + 0x64: { "name": "send_mail", "params": [ "byte" ] }, # ? 0x65: { "name": "check_npc_loaded", "params": [ "npc" ] }, 0x66: { "name": "give_deck", "params": [ "deck" ] }, 0x67: { "name": "script_command_67", "params": [ "byte", "byte" ] }, # ? From 8602c8802eda3ef5333060db8537c57331459778 Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 15:23:04 -0600 Subject: [PATCH 21/27] disasemble Func_1ef2a --- src/engine/bank07.asm | 68 +++++++++++++++++++++++++++++++++++++++++-- src/home/unsorted.asm | 2 +- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index a18bf1f..32d7065 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6457,7 +6457,7 @@ Func_1ee97: Data_1eed8: menu_box_params FALSE, 18, 12, \ SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ - PAD_A, PAD_B, FALSE, 1, $3e75, NULL + PAD_A, PAD_B, FALSE, 1, Func_3e75, NULL textitem 1, 1, SingleSpaceText textitem 1, 4, SingleSpaceText textitem 1, 7, SingleSpaceText @@ -6494,7 +6494,71 @@ Func_1eef8: call CallPlaySFX pop af ret -; 0x1ef2a + +Func_1ef2a:: + push af + push bc + push de + push hl + call GetMenuBoxFocusedItem + and $03 + cp $03 + call z, Func_1ef46 + call GetMenuBoxFocusedItem + and $03 + and a + call z, Func_1ef73 + pop hl + pop de + pop bc + pop af + ret + +Func_1ef46: + ldh a, [hDPadHeld] + and $80 + ret z + ld a, [wMailboxPage] + cp $01 + ret z + ld a, [wMailCount] + cp $05 + ret c + push af + ld a, $01 + call CallPlaySFX + pop af + ld a, [wMailboxPage] + inc a + ld [wMailboxPage], a + xor a + ld [wSelectedMailCursorPosition], a + call Func_1ede4 + call SetMenuBoxFocusedItem + call SetwDA37 + ret + +Func_1ef73: + ldh a, [hDPadHeld] + and $40 + ret z + ld a, [wMailboxPage] + and a + ret z + push af + ld a, $01 + call CallPlaySFX + pop af + ld a, [wMailboxPage] + dec a + ld [wMailboxPage], a + ld a, $03 + ld [wSelectedMailCursorPosition], a + call Func_1ede4 + call SetMenuBoxFocusedItem + call SetwDA37 + ret +; 0x1ef9a SECTION "Bank 7@6fa4", ROMX[$6fa4], BANK[$7] diff --git a/src/home/unsorted.asm b/src/home/unsorted.asm index 9dc9b08..f91a10a 100644 --- a/src/home/unsorted.asm +++ b/src/home/unsorted.asm @@ -2665,7 +2665,7 @@ LoadScene:: ret Func_3e75:: - farcall $7, $6f2a + farcall Func_1ef2a ret Func_3e7a:: From 33710962109532f003cba77e867a3a270bd6c78d Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 15:56:34 -0600 Subject: [PATCH 22/27] light documentation of UpdateMailboxPage and functions in its call hierarchy --- src/engine/bank07.asm | 86 ++++++++++++++++++++++++------------------- src/home/unsorted.asm | 4 +- 2 files changed, 51 insertions(+), 39 deletions(-) diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 32d7065..0ac1270 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -6294,7 +6294,7 @@ MinicomMailboxMainScreen: call FlushAllPalettes call EnableLCD .loop - call Func_1ede4 + call MailboxMainScreen call Func_1eef8 jr c, .done call MailboxSelectedMail_LoadMenuBoxParams @@ -6314,14 +6314,14 @@ MinicomMailboxMainScreen_DrawTextBoxes: call DrawRegularTextBoxVRAM0 ret -Func_1ede4: +MailboxMainScreen: push af push bc push de push hl lb de, 1, 5 - ld b, BANK(Data_1eed8) - ld hl, Data_1eed8 + ld b, BANK(MailboxMainScreenMenuBoxParams) + ld hl, MailboxMainScreenMenuBoxParams call LoadMenuBoxParams ld a, [wSelectedMailCursorPosition] call DrawMenuBox @@ -6346,22 +6346,22 @@ Func_1ede4: ld b, $00 ld hl, wMailList add hl, bc - ld de, $206 - ld c, $04 -.asm_1ee2e + lb de, 2, 6 + ld c, 4 ; number of mail items that can fit on screen +.print_mail_loop ld a, [hli] and a - jr z, .asm_1ee38 - call Func_1ee4a + jr z, .count_mail_items_on_screen + call PrintMailSenderAndSubjectToScreen dec c - jr nz, .asm_1ee2e -.asm_1ee38 - ld a, $04 + jr nz, .print_mail_loop +.count_mail_items_on_screen + ld a, 4 ; number of mail items that can fit on screen sub c and a - jr nz, .asm_1ee3f + jr nz, .done inc a -.asm_1ee3f +.done call SetMenuBoxNumItems call Func_1ee97 pop hl @@ -6370,7 +6370,9 @@ Func_1ede4: pop af ret -Func_1ee4a: +; a - mail ID to print +; de - coordinates passed to InitTextPrinting_ProcessTextFromIDVRAM0 +PrintMailSenderAndSubjectToScreen: push bc push hl ldtx hl, MailboxSenderText @@ -6380,15 +6382,15 @@ Func_1ee4a: call InitTextPrinting_ProcessTextFromIDVRAM0 and a jr z, .asm_1ee68 - bit 7, a + bit B_MAIL_READ, a jr nz, .asm_1ee68 dec d ldtx hl, MailboxUnreadSymbolText call InitTextPrinting_ProcessTextFromIDVRAM0 inc d .asm_1ee68 - ld hl, $734f - and $7f + ld hl, Mail + and %01111111 ; drop bit 7 (B_MAIL_READ) ld c, a ld b, $00 sla c @@ -6401,11 +6403,14 @@ Func_1ee4a: add $05 ld d, a dec e + push hl ld a, [hli] ld h, [hl] ld l, a + ; sender call InitTextPrinting_ProcessTextFromIDVRAM0 + pop hl inc hl inc hl @@ -6413,6 +6418,7 @@ Func_1ee4a: ld a, [hli] ld h, [hl] ld l, a + ; subject call InitTextPrinting_ProcessTextFromIDVRAM0 inc e inc e @@ -6454,10 +6460,11 @@ Func_1ee97: call Func_383b ret -Data_1eed8: +; a menu box with blank text items that line up with mail items on screen +MailboxMainScreenMenuBoxParams: menu_box_params FALSE, 18, 12, \ SYM_CURSOR_R, SYM_SPACE, SYM_CURSOR_R, SYM_CURSOR_R, \ - PAD_A, PAD_B, FALSE, 1, Func_3e75, NULL + PAD_A, PAD_B, FALSE, 1, UpdateMailboxPage, NULL textitem 1, 1, SingleSpaceText textitem 1, 4, SingleSpaceText textitem 1, 7, SingleSpaceText @@ -6495,37 +6502,40 @@ Func_1eef8: pop af ret -Func_1ef2a:: +_UpdateMailboxPage:: push af push bc push de push hl call GetMenuBoxFocusedItem - and $03 - cp $03 - call z, Func_1ef46 + and $03 ; bottom-most mail item on the screen + cp 3 + call z, ScrollMailboxPageOnPadDown call GetMenuBoxFocusedItem and $03 - and a - call z, Func_1ef73 + and a ; top mail item on the screen + call z, ScrollMailboxPageOnPadUp pop hl pop de pop bc pop af ret -Func_1ef46: +ScrollMailboxPageOnPadDown: ldh a, [hDPadHeld] - and $80 + and PAD_DOWN ret z + ld a, [wMailboxPage] - cp $01 + cp 1 ret z + ld a, [wMailCount] - cp $05 + cp 5 ret c + push af - ld a, $01 + ld a, SFX_CURSOR call CallPlaySFX pop af ld a, [wMailboxPage] @@ -6533,28 +6543,30 @@ Func_1ef46: ld [wMailboxPage], a xor a ld [wSelectedMailCursorPosition], a - call Func_1ede4 + call MailboxMainScreen call SetMenuBoxFocusedItem call SetwDA37 ret -Func_1ef73: +ScrollMailboxPageOnPadUp: ldh a, [hDPadHeld] - and $40 + and PAD_UP ret z + ld a, [wMailboxPage] and a ret z + push af - ld a, $01 + ld a, SFX_CURSOR call CallPlaySFX pop af ld a, [wMailboxPage] dec a ld [wMailboxPage], a - ld a, $03 + ld a, 3 ld [wSelectedMailCursorPosition], a - call Func_1ede4 + call MailboxMainScreen call SetMenuBoxFocusedItem call SetwDA37 ret diff --git a/src/home/unsorted.asm b/src/home/unsorted.asm index f91a10a..82cba78 100644 --- a/src/home/unsorted.asm +++ b/src/home/unsorted.asm @@ -2664,8 +2664,8 @@ LoadScene:: farcall _LoadScene ret -Func_3e75:: - farcall Func_1ef2a +UpdateMailboxPage:: + farcall _UpdateMailboxPage ret Func_3e7a:: From d123b4619f6022acacea62bdb65925c54ef729bb Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Sun, 16 Nov 2025 15:58:26 -0600 Subject: [PATCH 23/27] =?UTF-8?q?replace=20a=20ld=20with=20appropriate=20c?= =?UTF-8?q?haracter=20constant=20"=E3=81=AE"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/bank02.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index c12bd69..897a190 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -838,7 +838,7 @@ InputCurDeckName: ld [hl], TX_HIRAGANA inc hl - ld [hl], $29 ; "の" + ldfw [hl], "の" inc hl push hl From 411a03e52e386eda6231ebcc44b0e920af090fb5 Mon Sep 17 00:00:00 2001 From: Mitchell Draves Date: Thu, 20 Nov 2025 08:53:05 -0600 Subject: [PATCH 24/27] Apply suggestions from code review from @earthoul. small amendments by myself to fix names of functions called that did not come through the github commit. Co-authored-by: Kensuke Sano --- src/engine/bank02.asm | 12 ++++++------ src/engine/bank0e.asm | 44 +++++++++++++++++++++---------------------- src/sram.asm | 3 +-- 3 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 897a190..c015f89 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -744,9 +744,9 @@ DeckSelectionSubMenu: jr z, .asm_90cd call EnableSRAM ld de, wCurDeckCards - farcall Func_3be8d + farcall SaveDeckDataToWRAM2 call DisableSRAM - farcall Func_3bead + farcall OpenDeckSaveMachineFromDeckBuilding .asm_90cd ld a, ALL_DECKS call DrawDecksScreen @@ -777,9 +777,9 @@ DeckSelectionSubMenu: call EnableSRAM ld hl, wCurDeckName ld de, wCurDeckCards - farcall Func_3be8d + farcall SaveDeckDataToWRAM2 call DisableSRAM - farcall Func_3bead + farcall OpenDeckSaveMachineFromDeckBuilding .asm_9119 ld a, ALL_DECKS call DrawDecksScreen @@ -1919,9 +1919,9 @@ DismantleDeck: jr nc, .asm_98a0 ld hl, wCurDeckName ld de, wCurDeckCards - farcall Func_3be8d + farcall SaveDeckDataToWRAM2 call DisableSRAM - farcall Func_3bead + farcall OpenDeckSaveMachineFromDeckBuilding .asm_989d add sp, $02 ret diff --git a/src/engine/bank0e.asm b/src/engine/bank0e.asm index f042853..f8562b8 100644 --- a/src/engine/bank0e.asm +++ b/src/engine/bank0e.asm @@ -4892,7 +4892,7 @@ Func_3ada1: .asm_3ae01 ld a, [wCheckMenuCursorYPosition] sla a - ld hl, wCurSongBankBackup + ld hl, wCheckMenuCursorXPosition add [hl] or a jr nz, .asm_3ae33 @@ -5133,7 +5133,7 @@ CopyBBytesFromHLToDE_Bank0e: jr nz, .loop ret -Func_3afb1: +CopyListFromHLToDE_Bank0e: .asm_3afb1 ld a, [hli] ld [de], a @@ -5901,7 +5901,7 @@ Func_3b45f: push hl ld de, wd47e call EnableSRAM - call Func_3afb1 + call CopyListFromHLToDE_Bank0e pop hl push hl ld bc, $18 @@ -7103,37 +7103,37 @@ Func_3bd3b: SECTION "Bank e@7e8d", ROMX[$7e8d], BANK[$e] -Func_3be8d: +SaveDeckDataToWRAM2: push de ld de, wc000 - call Func_3afb1 + call CopyListFromHLToDE_Bank0e pop de - ld hl, $c018 + ld hl, wc000 + DECK_NAME_SIZE bank1call SaveDeckCards call SwitchToWRAM2 ld hl, wc000 ld de, w2d28e - ld b, $60 + ld b, DECK_COMPRESSED_STRUCT_SIZE call CopyBBytesFromHLToDE_Bank0e call SwitchToWRAM1 ret -Func_3bead: +OpenDeckSaveMachineFromDeckBuilding: ld a, [wCurDeck] push af xor a ld [wScrollMenuScrollOffset], a - ld de, $2d3 + ldtx de, DeckSaveMachineText ld hl, wDeckMachineTitleText ld [hl], e inc hl ld [hl], d call ClearScreenAndDrawDeckMachineScreen - ld a, $32 + ld a, NUM_DECK_SAVE_MACHINE_SLOTS ld [wNumDeckMachineEntries], a xor a -.asm_3bec7 - ld hl, $5eac +.wait_input + ld hl, DeckMachineSelectionParams farcall InitializeScrollMenuParameters call DrawListScrollArrows call PrintNumSavedDecks @@ -7141,26 +7141,26 @@ Func_3bead: call DrawWideTextBox_PrintText ldtx de, PleaseSelectDeckText call InitDeckMachineDrawingParams - call HandleDeckMachineSelection.start - jr c, .asm_3bec7 + call HandleDeckMachineSelection + jr c, .wait_input cp $ff - jr z, .asm_3bf50 + jr z, .cancel ld b, a ld a, [wScrollMenuScrollOffset] add b ld [wSelectedDeckMachineEntry], a call CheckIfSelectedDeckMachineEntryIsEmpty - jr c, .asm_3bf01 + jr c, .save_deck ldtx hl, DeleteSavedDeckPromptText call YesOrNoMenuWithText ld a, [wTempScrollMenuItem] - jr c, .asm_3bec7 -.asm_3bf01 + jr c, .wait_input +.save_deck call GetSelectedSavedDeckPtr ld d, h ld e, l ld hl, w2d28e - ld b, $60 + ld b, DECK_COMPRESSED_STRUCT_SIZE call EnableSRAM call SwitchToWRAM2 call CopyBBytesFromHLToDE_Bank0e @@ -7170,7 +7170,7 @@ Func_3bead: call DrawListScrollArrows call PrintNumSavedDecks ld a, [wTempScrollMenuItem] - ld hl, $5eac + ld hl, DeckMachineSelectionParams farcall InitializeScrollMenuParameters call HandleScrollMenu.draw_visible_cursor pop af @@ -7181,11 +7181,11 @@ Func_3bead: call DisableSRAM xor a ld [wTxRam2], a - ld [$cdd7], a + ld [wTxRam2 + 1], a ldtx hl, SavedDeckToMachineText call DrawWideTextBox_WaitForInput ret -.asm_3bf50 +.cancel pop af ld [wCurDeck], a ret diff --git a/src/sram.asm b/src/sram.asm index 54c58ef..524ec66 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -72,8 +72,7 @@ sCurrentlySelectedDeck:: ; b7a0 ds $1 ; keeps track of how many unnamed decks have been built -; this is the number that gets appended at the end of -; an unnamed deck (i.e. DECK XXX) +; as they suffix the number ### in the form of "の###デッキ" ; max number is MAX_UNNAMED_DECK_NUM sUnnamedDeckCounter:: ; b7a1 ds $2 From 833a6e927f24818c6866316cac0831f6c7ee445f Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Thu, 20 Nov 2025 09:20:05 -0600 Subject: [PATCH 25/27] batching up a few PR suggestions from @earthoul: - create MAIL_MAX_ON_SCREEN - fix call to stray Func_8f6b label - disasm new .SpriteAnimGfxParams - touch-ups to DrawMinicomMainScreen --- src/constants/script_constants.asm | 1 + src/engine/bank02.asm | 3 +-- src/engine/bank07.asm | 21 ++++++++++++--------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/constants/script_constants.asm b/src/constants/script_constants.asm index 3dec787..0326590 100644 --- a/src/constants/script_constants.asm +++ b/src/constants/script_constants.asm @@ -336,6 +336,7 @@ DEF MAIL_QUEUE_BUFFER_SIZE EQU $19 DEF NEW_MAIL EQU $ff DEF NUM_UNIQUE_MAILS_IN_GAME EQU 29 DEF MAIL_MAX_NUM EQU 8 +DEF MAIL_MAX_ON_SCREEN EQU 4 DEF MAIL_BUFFER_SIZE EQU MAIL_MAX_NUM + 1 DEF B_MAIL_READ EQU 7 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index c015f89..f6631b4 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -571,7 +571,6 @@ PrepareMenuGraphics: call SetupText ret -Func_8f6b: ; inits the following deck building params from hl: ; wMaxNumCardsAllowed ; wd381 @@ -4384,7 +4383,7 @@ Func_a705: ld hl, wCurDeckName ld [hl], TX_END ld hl, $6726 - call Func_8f6b + call InitDeckBuildingParams ld a, $01 ld [wd121], a call HandleDeckBuildScreen diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index 0ac1270..dca03ca 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -5595,7 +5595,7 @@ DrawMinicomMainScreen: lb bc, 20, 4 call DrawRegularTextBoxVRAM0 ldtx hl, PauseMenuMinicomText - ld de, CopyDataHLtoDE_SaveRegisters + lb de, 7, 2 call InitTextPrinting_ProcessTextFromIDVRAM0 lb de, 0, 12 lb bc, 20, 6 @@ -5604,15 +5604,15 @@ DrawMinicomMainScreen: lb de, 1, 14 call InitTextPrinting_ProcessTextFromIDVRAM0 call Func_1f309 - jr z, .asm_1e7df - ld b, $07 - ld hl, $6800 + jr z, .done + ld b, BANK(.SpriteAnimGfxParams) + ld hl, .SpriteAnimGfxParams ld d, 120 ld e, 32 ld a, $00 ld c, $00 call CreateSpriteAnim -.asm_1e7df +.done ret .menu: @@ -5624,9 +5624,12 @@ DrawMinicomMainScreen: textitem 3, 6, MinicomCardAlbumText textitem 3, 8, PCMenuShutdownText db $ff -; 0x1e800 -SECTION "Bank 7@6808", ROMX[$6808], BANK[$7] +.SpriteAnimGfxParams: + dw TILESET_SMALL_ENVELOPE + dw SPRITE_ANIM_AA + dw FRAMESET_173 + dw PALETTE_180 ; return ; a - cursor position, used later in CallMinicomMenuFunction @@ -6347,7 +6350,7 @@ MailboxMainScreen: ld hl, wMailList add hl, bc lb de, 2, 6 - ld c, 4 ; number of mail items that can fit on screen + ld c, MAIL_MAX_ON_SCREEN .print_mail_loop ld a, [hli] and a @@ -6356,7 +6359,7 @@ MailboxMainScreen: dec c jr nz, .print_mail_loop .count_mail_items_on_screen - ld a, 4 ; number of mail items that can fit on screen + ld a, MAIL_MAX_ON_SCREEN sub c and a jr nz, .done From f6aaaf1e69c4a1aa97171b554774131cff44c95d Mon Sep 17 00:00:00 2001 From: mdraves91 Date: Fri, 28 Nov 2025 17:40:30 -0600 Subject: [PATCH 26/27] rename settings to config --- src/engine/bank04.asm | 2 +- src/engine/bank07.asm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 7442214..9242f59 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1273,7 +1273,7 @@ Func_10836: key_func $02, PauseMenuDeckScreen ; deck key_func $03, PauseMenuMinicomScreen ; minicom key_func $04, PauseMenuCoinScreen ; coin - key_func $05, PauseMenuSettingsScreen ; settings + key_func $05, PauseMenuConfigScreen ; config db $ff Func_10856: diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index dca03ca..dd7702e 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -319,7 +319,7 @@ GetDuelistPortrait:: SECTION "Bank 7@416e", ROMX[$416e], BANK[$7] -PauseMenuSettingsScreen: +PauseMenuConfigScreen: farcall Func_1022a call ShowConfigMenu farcall Func_10252 From 5d6428884cf2216160734f287c3ed8866736b3a2 Mon Sep 17 00:00:00 2001 From: Mitchell Draves Date: Fri, 28 Nov 2025 17:43:10 -0600 Subject: [PATCH 27/27] apply PR suggestion Co-authored-by: Kensuke Sano --- src/engine/bank02.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index f6631b4..cfa3139 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -967,7 +967,7 @@ UnnamedDeckCounterToText: ret .get_digit - ld a, $1f ; "0" - 1 + ld a, SYM_0 - 1 .subtract_loop inc a add hl, bc