From 2fce2e7bd46d422768a43777e640bbb8eff06013 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 15 Apr 2021 17:40:48 +0100 Subject: Disassemble referenced functions in bank 2 --- src/constants/card_data_constants.asm | 21 +- src/engine/bank01.asm | 19 +- src/engine/bank02.asm | 6290 +++++++++++++++++++++++++-------- src/engine/bank03.asm | 2 +- src/engine/bank06.asm | 21 +- src/engine/bank1c.asm | 4 +- src/engine/effect_functions.asm | 2 +- src/engine/home.asm | 21 +- src/hram.asm | 1 + src/sram.asm | 4 +- src/text/text2.asm | 44 +- src/text/text3.asm | 24 +- src/text/text_offsets.asm | 68 +- src/wram.asm | 48 +- 14 files changed, 5019 insertions(+), 1550 deletions(-) (limited to 'src') diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 3b775b0..cd7d401 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -128,13 +128,22 @@ DIAMOND EQU $1 STAR EQU $2 PROMOSTAR EQU $ff +; card set constants (set 1) + const_def + const CARD_SET_COLOSSEUM ; $0 + const CARD_SET_EVOLUTION ; $1 + const CARD_SET_MYSTERY ; $2 + const CARD_SET_LABORATORY ; $3 + const CARD_SET_PROMOTIONAL ; $4 + const CARD_SET_ENERGY ; $5 + ; CARD_DATA_SET constants (set 1) -COLOSSEUM EQU $0 << 4 -EVOLUTION EQU $1 << 4 -MYSTERY EQU $2 << 4 -LABORATORY EQU $3 << 4 -PROMOTIONAL EQU $4 << 4 -ENERGY EQU $5 << 4 +COLOSSEUM EQU CARD_SET_COLOSSEUM << 4 +EVOLUTION EQU CARD_SET_EVOLUTION << 4 +MYSTERY EQU CARD_SET_MYSTERY << 4 +LABORATORY EQU CARD_SET_LABORATORY << 4 +PROMOTIONAL EQU CARD_SET_PROMOTIONAL << 4 +ENERGY EQU CARD_SET_ENERGY << 4 ; CARD_DATA_SET constants (set 2) JUNGLE EQU $1 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c706842..449cd75 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -1813,7 +1813,7 @@ Func_4b60: ; 4b60 (1:4b60) call ChooseInitialArenaAndBenchPokemon call SwapTurn jp c, .asm_4c77 - call Func_311d + call DrawPlayAreaToPlacePrizeCards ldtx hl, PlacingThePrizesText call DrawWideTextBox_WaitForInput call ExchangeRNG @@ -3684,7 +3684,7 @@ Func_5805: ; 5805 (1:5805) ldtx hl, WillDrawNPrizesText call DrawWideTextBox_WaitForInput ld a, [wNumberPrizeCardsToTake] - call Func_310a + call SelectPrizeCards ld hl, hTemp_ffa0 ld d, [hl] inc hl @@ -8523,7 +8523,20 @@ Func_7576: ; 7576 (1:7576) ret ; 0x757b - INCROM $757b, $758a +Func_757b: ; 757b (1:757b) + farcall Func_19e42 + ret +; 0x7580 + +Func_7580: ; 7580 (1:7580) + farcall Func_1a162 + ret +; 0x7585 + +Func_7585: ; 7585 (1:7585) + farcall Func_1a270 + ret +; 0x758a Func_758a: ; 758a (1:758a) farcall Func_19eb4 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 3483af2..05a79d7 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1281,7 +1281,7 @@ HandleCheckMenuInput_YourOrOppPlayArea: ; 86ac (2:46ac) ld e, a .erase - ld a, $01 + ld a, TRUE ld [wPlaysSfx], a push de call EraseCheckMenuCursor_YourOrOppPlayArea @@ -1620,8 +1620,68 @@ Func_8883_TransitionTable: ; 88fa (2:48fa) cursor_transition $08, $38, $00, $07, $07, $05, $04 cursor_transition $08, $60, $00, $06, $06, $01, $00 -Func_8932: ; 8932 (2:4932) - INCROM $8932, $8992 +_DrawAIPeekScreen: ; 8932 (2:4932) + push bc + call Set_OBJ_8x8 + call LoadCursorTile + xor a + ld [wce56], a + ldh a, [hWhoseTurn] + ld l, a + ld de, Func_8764_TransitionTable + pop bc + bit AI_PEEK_TARGET_HAND_F, b + jr z, .draw_play_area + +; AI chose the hand + call SwapTurn + ld a, $01 + ld [wce56], a + ldh a, [hWhoseTurn] + ld de, Func_8883_TransitionTable +.draw_play_area + ld h, a + push bc + push de + call DrawYourOrOppPlayAreaScreen + pop de + pop bc + +; get the right cursor position +; depending on what action the AI chose +; (prize card, hand, deck) + ld hl, wMenuInputTablePointer + ld [hl], e + inc hl + ld [hl], d + ld a, b + and $7f + cp $7f + jr nz, .prize_card +; cursor on the deck + ld a, $7 + ld [wPrizeCardCursorPosition], a + jr .got_cursor_position +.prize_card + bit AI_PEEK_TARGET_PRIZE_F, a + jr z, .hand + and $3f + ld [wPrizeCardCursorPosition], a + jr .got_cursor_position +.hand + ld a, $6 + ld [wPrizeCardCursorPosition], a +.got_cursor_position + call Func_89ae.draw_cursor + + ld a, $1 + ld [wVBlankOAMCopyToggle], a + ld a, [wce56] + or a + ret z + call SwapTurn + ret +; 0x8992 LoadCursorTile: ; 8992 (2:4992) ld de, v0Tiles0 @@ -1755,7 +1815,7 @@ Func_89ae: ; 89ae (2:49ae) jr .make_bitmask_loop .next - ld a, $01 + ld a, TRUE ld [wPlaysSfx], a ; reset cursor blink @@ -1826,11 +1886,232 @@ ZeroObjectPositionsWithCopyToggleOn: ; 8aa1 (2:4aa1) ld [wVBlankOAMCopyToggle], a ret -Func_8aaa: ; 8aaa (2:4aaa) - INCROM $8aaa, $8b85 +; handles the screen for Player to select prize card(s) +_SelectPrizeCards: ; 8aaa (2:4aaa) + xor a + call GetFirstSetPrizeCard + ld [wPrizeCardCursorPosition], a + ld de, hTempPlayAreaLocation_ffa1 + ld hl, wSelectedPrizeCardListPtr + ld [hl], e + inc hl + ld [hl], d + +.check_prize_cards_to_select + ld a, [wNumberOfPrizeCardsToSelect] + or a + jr z, .done_selection + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + or a + jr nz, .got_prizes + +.done_selection + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + ldh [hTemp_ffa0], a + ld a, [wSelectedPrizeCardListPtr + 0] + ld l, a + ld a, [wSelectedPrizeCardListPtr + 1] + ld h, a + ld [hl], $ff + ret + +.got_prizes + ldh a, [hWhoseTurn] + ld h, a + ld l, a + call DrawYourOrOppPlayAreaScreen + call DrawWideTextBox + ld de, $10e + call InitTextPrinting + ldtx hl, PleaseChooseAPrizeText + call ProcessTextFromID + ld de, .cursor_transition_table + ld hl, wMenuInputTablePointer + ld [hl], e + inc hl + ld [hl], d +.loop_handle_input + ld a, $1 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call Func_89ae + jr nc, .loop_handle_input + cp $ff + jr z, .loop_handle_input + + call ZeroObjectPositionsWithCopyToggleOn + +; get prize bit mask that corresponds +; to the one pointed by the cursor + ld a, [wPrizeCardCursorPosition] + ld c, a + ld b, $1 +.loop + or a + jr z, .got_prize_mask + sla b + dec a + jr .loop + +.got_prize_mask + ; if cursor prize is not set, + ; then return to input loop + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + and b + jp z, .loop_handle_input ; can be jr + + ; remove prize + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + sub b + ld [hl], a + + ; get its deck index + ld a, c + add DUELVARS_PRIZE_CARDS + call GetTurnDuelistVariable + + ld hl, wSelectedPrizeCardListPtr + ld e, [hl] + inc hl + ld d, [hl] + ld [de], a ; store deck index + inc de + ld [hl], d + dec hl + ld [hl], e + + ; add prize card to hand + call AddCardToHand + call LoadCardDataToBuffer1_FromDeckIndex + call Set_OBJ_8x16 + bank1call OpenCardPage_FromHand + ld a, [wNumberOfPrizeCardsToSelect] + dec a + ld [wNumberOfPrizeCardsToSelect], a + ld a, [wPrizeCardCursorPosition] + call GetFirstSetPrizeCard + ld [wPrizeCardCursorPosition], a + jp .check_prize_cards_to_select + +.cursor_transition_table + cursor_transition $08, $28, $00, $04, $02, $01, $01 + cursor_transition $30, $28, $20, $05, $03, $00, $00 + cursor_transition $08, $38, $00, $00, $04, $03, $03 + cursor_transition $30, $38, $20, $01, $05, $02, $02 + cursor_transition $08, $48, $00, $02, $00, $05, $05 + cursor_transition $30, $48, $20, $03, $01, $04, $04 +; 0x8b85 + +_DrawPlayAreaToPlacePrizeCards: ; 8b85 (2:4b85) + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + call EmptyScreen + call LoadSymbolsFont + call LoadPlacingThePrizesScreenTiles + + ldh a, [hWhoseTurn] + ld [wCheckMenuPlayAreaWhichLayout], a + ld [wCheckMenuPlayAreaWhichDuelist], a + + lb de, 0, 10 + ld c, 3 + call DrawPlayArea_BenchCards + ld hl, .player_icon_coordinates + call DrawYourOrOppPlayArea_Icons.draw + lb de, 8, 6 + ld a, $a0 + lb hl, 1, 4 + lb bc, 4, 3 + call FillRectangle + + call SwapTurn + ld a, $01 + ld [wce56], a + ldh a, [hWhoseTurn] + ld [wCheckMenuPlayAreaWhichDuelist], a + lb de, 6, 0 + ld c, 3 + call DrawPlayArea_BenchCards + ld hl, .opp_icon_coordinates + call DrawYourOrOppPlayArea_Icons.draw + lb de, 8, 3 + ld a, $a0 + lb hl, 1, 4 + lb bc, 4, 3 + call FillRectangle + call SwapTurn + ret + +.player_icon_coordinates + db 15, 11 + db 15, 6 + db 15, 8 + +.opp_icon_coordinates + db 0, 0 + db 0, 4 + db 0, 2 +; 0x8bf2 + + INCROM $8bf2, $8c57 + +; gets the first prize card index that is set +; beginning from index in register a +; a = prize card index +GetFirstSetPrizeCard: ; 8c57 (2:4c57) + push bc + push de + push hl + ld e, PRIZES_6 + ld c, a + ldh a, [hWhoseTurn] + ld h, a + ld l, DUELVARS_PRIZES + ld d, [hl] +.loop_prizes + call .GetPrizeMask + and d + jr nz, .done ; prize is set + dec e + jr nz, .next_prize + ld c, 0 + jr .done +.next_prize + inc c + ld a, PRIZES_6 + cp c + jr nz, .loop_prizes + ld c, 0 + jr .loop_prizes + +.done + ld a, c ; first prize index that is set + pop hl + pop de + pop bc + ret -Func_8b85: ; 8b85 (2:4b85) - INCROM $8b85, $8c8e +; returns 1 shifted left by c bits +.GetPrizeMask + push bc + ld a, c + ld b, $1 +.loop + or a + jr z, .got_mask + sla b + dec a + jr .loop +.got_mask + ld a, b + pop bc + ret +; 0x8c8e OpenGlossaryScreen_TransitionTable: cursor_transition $08, $28, $00, $04, $01, $05, $05 @@ -1951,8 +2232,7 @@ Data_8da9: ; 8da9 (2:4da9) db $50, $04, $01 dw HandleDeckConfigurationMenu dw DeckConfigurationMenu_TransitionTable - - INCROM $8db0, $8db0 +; 0x8db0 Func_8db0: ; 8db0 (2:4db0) ld hl, Data_8da9 @@ -1962,7 +2242,7 @@ Func_8db0: ; 8db0 (2:4db0) xor a Func_8dbc: ; 8dbc (2:4dbc) - ld hl, Unknown_8de2 + ld hl, .DeckSelectionMenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText @@ -1979,8 +2259,13 @@ Func_8dbc: ; 8dbc (2:4dbc) ld [wceb1], a jp Func_8e42 -Unknown_8de2: ; 8de2 (2:4de2) - INCROM $8de2, $8dea +.DeckSelectionMenuParameters + db 1, 2 ; cursor x, cursor y + db 3 ; y displacement between items + db 4 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw NULL ; function pointer if non-0 Func_8dea: ; 8dea (2:4dea) ldh a, [hDPadHeld] @@ -2031,7 +2316,7 @@ Func_8e1f: ; 8e1f (2:4e1f) Func_8e42: ; 8e42 (2:4e42) call DrawWideTextBox - ld hl, Unknown_9027 + ld hl, DeckSelectionData call PlaceTextItems call ResetCheckMenuCursorPositionAndBlink .asm_8e4e @@ -2263,8 +2548,13 @@ Func_8ff2: ; 8ff2 (2:4ff2) Func_9026: ; 9026 (2:5026) ret -Unknown_9027: ; 9027 (2:5027) - INCROM $9027, $9038 +DeckSelectionData: ; 9027 (2:5027) + textitem 2, 14, ModifyDeckText + textitem 12, 14, SelectDeckText + textitem 2, 16, ChangeNameText + textitem 12, 16, CancelText + db $ff +; 0x9038 ; return, in hl, the pointer to sDeckXName where X is [wceb1] + 1 GetPointerToDeckName: ; 9038 (2:5038) @@ -2342,7 +2632,7 @@ HandleCheckMenuInput: ; 9065 (2:5065) ld e, a .okay - ld a, $01 + ld a, TRUE ld [wPlaysSfx], a push de call EraseCheckMenuCursor @@ -2538,7 +2828,7 @@ Func_9168: ; 9168 (2:5168) lb de, 0, 9 lb bc, 20, 4 call DrawRegularTextBox - ld hl, Unknown_9242 + ld hl, DeckNameMenuData call PlaceTextItems ld a, 4 ld hl, wceb2 @@ -2621,9 +2911,15 @@ Func_9168: ; 9168 (2:5168) call DrawHandCardsTileOnSelectedDeck call EnableLCD ret +; 0x9242 -Unknown_9242: ; 9242 (2:5242) - INCROM $9242, $9253 +DeckNameMenuData: ; 9242 (2:5242) + textitem 4, 2, Deck1Text + textitem 4, 5, Deck2Text + textitem 4, 8, Deck3Text + textitem 4, 11, Deck4Text + db $ff +; 0x9253 Func_9253: ; 9253 (2:5253) ld de, wDefaultText @@ -2772,7 +3068,7 @@ Func_9345: ; 9345 (2:5345) xor a ld [wcea1], a - ld [wced3], a + ld [wCurCardTypeFilter], a call Func_993d .skip_draw @@ -2786,16 +3082,16 @@ Func_9345: ; 9345 (2:5345) ld a, $01 call PlaySFXConfirmOrCancel call ConfirmDeckConfiguration - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld [wNamingScreenCursorY], a jr .wait_input .no_start_btn - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld b, a ld a, [wNamingScreenCursorY] cp b jr z, .check_down_btn - ld [wced3], a + ld [wCurCardTypeFilter], a ld hl, wcea1 ld [hl], $00 call Func_993d @@ -2815,15 +3111,15 @@ Func_9345: ; 9345 (2:5345) cp $ff jp z, Func_9461 .asm_93a9 - ld a, [wceab + 3] + ld a, [wceae] or a jr z, .wait_input xor a .asm_93b0 ld hl, Data_9670 call Func_9a6d - ld a, [wceab + 3] - ld [wcfe4 + 2], a + ld a, [wceae] + ld [wcfe6], a ld hl, wcecb cp [hl] jr nc, .asm_93c5 @@ -2872,7 +3168,7 @@ Func_9345: ; 9345 (2:5345) call DrawCardTypeIconsAndPrintCardCounts ld hl, Data_9667 call Func_9a6d - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld [wNamingScreenCursorY], a call Func_9b20 call PrintDeckBuildingCardList @@ -2892,7 +3188,7 @@ Func_9345: ; 9345 (2:5345) jr nz, .asm_93fc ld hl, Data_9667 call Func_9a6d - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld [wNamingScreenCursorY], a jp .wait_input ; 0x9461 @@ -2939,7 +3235,7 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) call DrawCardTypeIconsAndPrintCardCounts ld a, [wced4] ld [wNamingScreenCursorY], a - ld a, [wced3] + ld a, [wCurCardTypeFilter] call Func_993d jp Func_9345.skip_draw @@ -2975,10 +3271,10 @@ ConfirmDeckConfiguration: ; 94d3 (2:54d3) call DrawCardTypeIconsAndPrintCardCounts ld hl, Data_9667 call Func_9a6d - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld [wNamingScreenCursorY], a call Func_9b20 - ld a, [wced3] + ld a, [wCurCardTypeFilter] call Func_993d ld a, [wced6] ld [wNamingScreenCursorY], a @@ -3056,7 +3352,7 @@ DismantleDeck: ; 9566 (2:5566) call EmptyScreen ld hl, Data_9667 call Func_9a6d - ld a, [wced3] + ld a, [wCurCardTypeFilter] ld [wNamingScreenCursorY], a call Func_9b20 call PrintDeckBuildingCardList @@ -3458,7 +3754,7 @@ CreateFilteredCardList: ; 978b (2:578b) .add_terminator_byte ld a, l - ld [wceab + 3], a + ld [wceae], a ; add terminator bytes in both lists xor a ld c, l @@ -4061,7 +4357,57 @@ Func_9a6d: ; 9a6d (2:5a6d) ; 0x9a83 Func_9a83: ; 9a83 (2:5a83) - INCROM $9a83, $9ad7 + xor a + ld [wPlaysSfx], a + ldh a, [hDPadHeld] + or a + jr z, .handle_ab_btns + ld b, a + ld a, [wNamingScreenKeyboardHeight] + ld c, a + ld a, [wNamingScreenCursorY] + bit D_LEFT_F, b + jr z, .check_d_right + dec a + bit 7, a + jr z, .got_new_cursor_y + ld a, [wNamingScreenKeyboardHeight] + dec a + jr .got_new_cursor_y +.check_d_right + bit D_RIGHT_F, b + jr z, .handle_ab_btns + inc a + cp c + jr c, .got_new_cursor_y + + xor a +.got_new_cursor_y + push af + ld a, TRUE + ld [wPlaysSfx], a + call Func_9b00 + pop af + + ld [wNamingScreenCursorY], a + xor a + ld [wCheckMenuCursorBlinkCounter], a + +.handle_ab_btns + ld a, [wNamingScreenCursorY] + ld [hffb3], a + ldh a, [hKeysPressed] + and A_BUTTON | B_BUTTON + jr z, Func_9ae8 + and A_BUTTON + jr nz, Func_9ad7 + ; b button + ld a, $ff + ld [hffb3], a + call PlaySFXConfirmOrCancel + scf + ret +; 0x9ad7 Func_9ad7: ; 9ad7 (2:5ad7) call Func_9b20 @@ -4074,7 +4420,25 @@ Func_9ad7: ; 9ad7 (2:5ad7) ret ; 0x9ae8 - INCROM $9ae8, $9b03 +Func_9ae8: ; 9ae8 (2:5ae8) + ld a, [wPlaysSfx] + or a + jr z, .skip_sfx + call PlaySFX +.skip_sfx + ld hl, wCheckMenuCursorBlinkCounter + ld a, [hl] + inc [hl] + and $0f + ret nz + ld a, [wceaa] + bit 4, [hl] + jr z, Func_9b03 +; 0x9b00 + +Func_9b00: ; 9b00 (2:5b00) + ld a, [wceab] +; fallthrough Func_9b03: ; 9b03 (2:5b03) ld e, a @@ -4102,33 +4466,169 @@ Func_9b20: ; 9b20 (2:5b20) ; 0x9b25 Func_9b25: ; 9b25 (2:5b25) - INCROM $9b25, $9c0e - -Func_9c0e: ; 9c0e (2:5c0e) - INCROM $9c0e, $9c11 + xor a ; FALSE + ld [wPlaysSfx], a -; a = tile to write -Func_9c11: ; 9c11 (2:5c11) - ld e, a - ld a, [wcea5 + 3] - ld l, a - ld a, [wNamingScreenCursorY] - ld h, a - call HtimesL - ld a, l - ld hl, wcea5 - add [hl] + ldh a, [hDPadHeld] + or a + jp z, .asm_9bb9 ld b, a - ld a, [wcea5 + 2] - ld l, a - ld a, [wNamingScreenCursorY] - ld h, a - call HtimesL - ld a, l - ld hl, wcea5 + 1 - add [hl] + ld a, [wNamingScreenKeyboardHeight] ld c, a - ld a, e + ld a, [wNamingScreenCursorY] + bit D_UP_F, b + jr z, .check_d_down + push af + ld a, TRUE + ld [wPlaysSfx], a + pop af + dec a + bit 7, a + jr z, .asm_9b8f + ld a, [wcea1] + or a + jr z, .asm_9b5a + dec a + ld [wcea1], a + ld hl, wcece + call CallIndirect + xor a + jr .asm_9b8f +.asm_9b5a + xor a + ld [wPlaysSfx], a + jr .asm_9b8f + +.check_d_down + bit D_DOWN_F, b + jr z, .asm_9b9d + push af + ld a, TRUE + ld [wPlaysSfx], a + pop af + inc a + cp c + jr c, .asm_9b8f + push af + ld a, [wcecd] + or a + jr nz, .asm_9b87 + ld a, [wcea1] + inc a + ld [wcea1], a + ld hl, wcece + call CallIndirect + pop af + dec a + jr .asm_9b8f + +.asm_9b87 + pop af + dec a + push af + xor a ; FALSE + ld [wPlaysSfx], a + pop af +.asm_9b8f + push af + call Func_9c0e + pop af + ld [wNamingScreenCursorY], a + xor a + ld [wCheckMenuCursorBlinkCounter], a + jr .asm_9bb9 +.asm_9b9d + ld a, [wced2] + or a + jr z, .asm_9bb9 + + bit D_LEFT_F, b + jr z, .check_d_right + call Func_9db3 + call Func_9de4 + jr .asm_9bb9 +.check_d_right + bit D_RIGHT_F, b + jr z, .asm_9bb9 + call Func_9db3 + call Func_9d0c +.asm_9bb9 + ld a, [wNamingScreenCursorY] + ld [hffb3], a + ld hl, wceac + ld a, [hli] + or [hl] + jr z, .asm_9be2 + ld a, [hld] + ld l, [hl] + ld h, a + ld a, [hffb3] + call CallHL + jr nc, .handle_blink +.asm_9bd1 + call Func_9c3a + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenCursorY] + ld e, a + ld a, [hffb3] + scf + ret + +.asm_9be2 + ldh a, [hKeysPressed] + and A_BUTTON | B_BUTTON + jr z, .asm_9bf6 + and A_BUTTON + jr nz, .asm_9bd1 + ld a, $ff + ld [hffb3], a + call PlaySFXConfirmOrCancel + scf + ret + +.asm_9bf6 + ld a, [wPlaysSfx] + or a + jr z, .handle_blink + call PlaySFX +.handle_blink + ld hl, wCheckMenuCursorBlinkCounter + ld a, [hl] + inc [hl] + and $0f + ret nz + ld a, [wceaa] + bit 4, [hl] + jr z, Func_9c11 +; 0x9c0e + +Func_9c0e: ; 9c0e (2:5c0e) + ld a, [wceab] +; fallthrough + +; a = tile to write +Func_9c11: ; 9c11 (2:5c11) + ld e, a + ld a, [wcea5 + 3] + ld l, a + ld a, [wNamingScreenCursorY] + ld h, a + call HtimesL + ld a, l + ld hl, wcea5 + add [hl] + ld b, a + ld a, [wcea5 + 2] + ld l, a + ld a, [wNamingScreenCursorY] + ld h, a + call HtimesL + ld a, l + ld hl, wcea5 + 1 + add [hl] + ld c, a + ld a, e call WriteByteToBGMap0 or a ret @@ -4140,1614 +4640,4459 @@ Func_9c3a: ; 9c3a (2:5c3a) ; 0x9c3f Func_9c3f: ; 9c3f (2:5c3f) - INCROM $9c3f, $9e31 + ld hl, wcfd8 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wNamingScreenCursorY] + ld c, a + ld b, $00 + add hl, bc + ld a, [wcea1] + ld c, a + ld b, $00 + add hl, bc + ld e, [hl] + ld d, $00 + push de + call LoadCardDataToBuffer1_FromCardID + lb de, $38, $9f + call SetupText + bank1call OpenCardPage_FromCheckHandOrDiscardPile + pop de -Func_9e31: ; 9e31 (2:5e31) - ld hl, hffb0 - ld [hl], $01 - call Func_9fc0 - ld hl, hffb0 - ld [hl], $00 - jp PrintConfirmationCardList -; 0x9e41 +.handle_input + ldh a, [hDPadHeld] + ld b, a + and A_BUTTON | B_BUTTON | SELECT | START + jp nz, .asm_9ce1 -Func_9e41: ; 9e41 (2:5e41) - ld a, [wcecc] + xor a ; FALSE + ld [wPlaysSfx], a + ld a, [wNamingScreenKeyboardHeight] + ld c, a + ld a, [wNamingScreenCursorY] + bit D_UP_F, b + jr z, .asm_9c94 + push af + ld a, TRUE + ld [wPlaysSfx], a + pop af + dec a + bit 7, a + jr z, .asm_9cc6 + ld a, [wcea1] or a - jp z, Func_9f40 - call Func_a028 - call Func_a06e - - xor a + jr z, .asm_9cd9 + dec a ld [wcea1], a -.asm_9e52 - ld hl, Data_9eaf - call Func_9a6d - ld a, [wced9] - ld [wcfe4+ 2], a - cp $07 - jr c, .asm_9e64 - ld a, $07 -.asm_9e64 - ld [wNamingScreenKeyboardHeight], a - ld [wcecb], a - call Func_9f52 - ld hl, Func_9e31 - ld d, h - ld a, l - ld hl, wcece - ld [hli], a - ld [hl], d xor a - ld [wced2], a -.asm_9e7b - call DoFrame - call Func_9b25 - jr c, .asm_9ea7 - call Func_9eb8 - jr c, .asm_9e7b - ldh a, [hDPadHeld] - and START - jr z, .asm_9e7b + jr .asm_9cc6 -.asm_9e8e - ld a, $01 - call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] - ld [wced7], a - ld de, wOwnedCardsCountList +.asm_9c94 + bit D_DOWN_F, b + jr z, .asm_9cd9 + push af + ld a, TRUE + ld [wPlaysSfx], a + pop af + inc a + cp c + jr c, .asm_9cc6 + push af ld hl, wcfd8 - ld [hl], e - inc hl - ld [hl], d - call Func_9c3f - jr .asm_9e52 - -.asm_9ea7 - ld a, [hffb3] - cp $ff - ret z - jr .asm_9e8e -; 0x9eaf - -Data_9eaf: - db $00, $05, $02, $00, $07, $0f, $00, $00, $00 - -Func_9eb8: ; 9eb8 (2:5eb8) - ld a, [wNamingScreenKeyboardHeight] - ld d, a + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wNamingScreenCursorY] + ld c, a + ld b, $00 + add hl, bc ld a, [wcea1] + inc a ld c, a - ldh a, [hDPadHeld] - cp D_RIGHT - jr z, .right - cp D_LEFT - jr z, .left + ld b, $00 + add hl, bc + ld a, [hl] or a - ret - -.right + jr z, .asm_9cd6 ld a, [wcea1] - add d - ld b, a - add d - ld hl, wcfe4 + 2 - cp [hl] - jr c, .asm_9ee8 - ld a, [wcfe4 + 2] - sub d - ld b, a - jr .asm_9ee8 - -.left - ld a, [wcea1] - sub d - ld b, a - jr nc, .asm_9ee8 - ld b, $00 -.asm_9ee8 - ld a, b + inc a ld [wcea1], a - cp c - jr z, .asm_9efa - ld a, SFX_01 + pop af + dec a +.asm_9cc6 + ld [wNamingScreenCursorY], a + ld a, [wPlaysSfx] + or a + jp z, Func_9c3f call PlaySFX - ld hl, wcece - call CallIndirect -.asm_9efa - scf - ret -; 0x9efc + jp Func_9c3f -Func_9efc: ; 9efc (2:5efc) - INCROM $9efc, $9f40 +.asm_9cd6 + pop af + jr .asm_9cd9 ; unnecessary jr +.asm_9cd9 + push de + bank1call OpenCardPage.input_loop + pop de + jp .handle_input -Func_9f40: ; 9f40 (2:5f40) - call Func_9f81 -.wait_input - call DoFrame - ldh a, [hKeysPressed] - and B_BUTTON - jr z, .wait_input - ld a, $ff - call PlaySFXConfirmOrCancel +.asm_9ce1 + ld a, $1 + ld [wVBlankOAMCopyToggle], a + ld a, [wNamingScreenCursorY] + ld [wced4], a ret -; 0x9f52 +; 0x9ced -Func_9f52: ; 9f52 (2:5f52) - call Func_9f81 - lb de, 3, 5 - ld hl, wced0 + INCROM $9ced, $9d0c + +Func_9d0c: ; 9d0c (2:5d0c) + call Func_9d22 + ret c + push de + call PrintCardTypeCounts + lb de, 15, 0 + call PrintTotalCardCount + pop de + call Func_9850 + call Func_9dbf + ret +; 0x9d22 + +Func_9d22: ; 9d22 (2:5d22) + ld a, [wcfd1] + ld d, a + ld a, [wcecc] + cp d + jr nz, .asm_9d2e + scf + ret + +.asm_9d2e + push de + call Func_9d74 + pop de + ret c + push de + call Func_9850 + ld b, a + ld hl, wOwnedCardsCountList + ld d, $00 + ld a, [wcea1] + ld e, a + add hl, de + ld a, [wNamingScreenCursorY] + ld e, a + add hl, de + ld d, [hl] + ld a, b + cp d + pop de + scf + ret z + ld a, SFX_01 + call PlaySFX + push de + call Func_9d65 + ld a, [wCurCardTypeFilter] + ld c, a + ld b, $00 + ld hl, wcebb + add hl, bc + inc [hl] + pop de + or a + ret +; 0x9d65 + +; finds first empty slot in wcf17 +; then writes the value in e to it +Func_9d65: ; 9d65 (2:5d65) + ld hl, wcf17 +.loop + ld a, [hl] + or a + jr z, .empty + inc hl + jr .loop +.empty ld [hl], e inc hl - ld [hl], d - call PrintConfirmationCardList + xor a + ld [hl], a ret -; 0x9f62 +; 0x9d74 -; counts all values stored in wcebb -; if the total count is 0, then -; prints "No cards chosen." -Func_9f62: ; 9f62 (2:5f62) - lb bc, 0, 0 - ld hl, wcebb +; e = card id +Func_9d74: ; 9d74 (2:5d74) + call LoadCardDataToBuffer1_FromCardID + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY_DOUBLE_COLORLESS + jr z, .double_colorless + and TYPE_ENERGY + cp TYPE_ENERGY + jr z, .exit ; return if basic energy card +.double_colorless + +; compare this card's name to +; the names of cards in list wcf17 + ld a, [wLoadedCard1Name + 0] + ld c, a + ld a, [wLoadedCard1Name + 1] + ld b, a + ld hl, wcf17 + ld d, $00 + push de .loop ld a, [hli] - add b - ld b, a - inc c - ld a, $9 + or a + jr z, .exit_pop_de + ld e, a + ld d, $00 + call GetCardName + ld a, e cp c jr nz, .loop - ld a, b - or a - ret nz - lb de, 11, 1 - call InitTextPrinting - ldtx hl, NoCardsChosenText - call ProcessTextFromID + ld a, d + cp b + jr nz, .loop + ; has same name + pop de + inc d + ld a, [wcfd1 + 1] + cp d + push de + jr nz, .loop + pop de + scf ret -; 0x9f81 -Func_9f81: ; 9f81 (2:5f81) - call Func_8d56 - lb de, 0, 0 - lb bc, 20, 4 - call DrawRegularTextBox - ld a, [wcfb9] +.exit_pop_de + pop de +.exit or a - jp z, .print_card_count ; should be jr - call Func_9fc0 - ld a, [wceb1] - ld b, a - call EnableSRAM - ld a, [sCurrentlySelectedDeck] - call DisableSRAM - cp b - jr nz, .print_card_count - lb de, 2, 1 - call DrawHandCardsTileAtDE + ret +; 0x9db3 -.print_card_count - lb de, 14, 1 - call PrintTotalCardCount - lb de, 16, 1 - call PrintSlashSixty - call Func_9f62 - call EnableLCD +; gets the element in wcec4 +; corresponding to index wNamingScreenCursorY +Func_9db3: ; 9db3 (2:5db3) + ld hl, wcec4 + ld a, [wNamingScreenCursorY] + ld e, a + ld d, $00 + add hl, de + ld e, [hl] ret -; 0x9fc0 +; 0x9dbf -Func_9fc0: ; 9fc0 (2:5fc0) - ld a, [wceb1] - cp $ff - jr z, .asm_9fea - lb de, 3, 2 - call InitTextPrinting - ld a, [wceb1] - bit 7, a - jr z, .asm_9fd8 - and $7f - jr .asm_9fd9 -.asm_9fd8 - inc a -.asm_9fd9 - ld hl, wDefaultText +; a = value to convert to numerical digits +Func_9dbf: ; 9dbf (2:5dbf) + ld hl, wc590 call ConvertToNumericalDigits - ld [hl], $77 - inc hl ld [hl], TX_END - ld hl, wDefaultText - call ProcessText - -.asm_9fea - ld hl, wcfb9 - ld de, wDefaultText - call CopyListFromHLToDE - ld a, [wceb1] - cp $ff - jr z, .asm_a01b - ld hl, wDefaultText - call GetTextLengthInTiles - ld b, $0 - ld hl, wDefaultText - add hl, bc - ld d, h - ld e, l - ld hl, Data_92a7 - call CopyListFromHLToDE - lb de, 6, 2 - ld hl, wDefaultText + ld a, [wcea5 + 2] + ld l, a + ld a, [wNamingScreenCursorY] + ld h, a + call HtimesL + ld a, l + ld hl, wcea5 + 1 + add [hl] + ld e, a + ld d, $0e call InitTextPrinting + ld hl, wc590 call ProcessText ret +; 0x9de4 -.asm_a01b - lb de, 2, 2 - ld hl, wDefaultText - call InitTextPrinting - call ProcessText +Func_9de4: ; 9de4 (2:5de4) + call Func_9dfa + ret nc + push de + call PrintCardTypeCounts + lb de, 15, 0 + call PrintTotalCardCount + pop de + call Func_9850 + call Func_9dbf ret -; 0xa028 +; 0x9dfa -Func_a028: ; a028 (2:6028) +Func_9dfa: ; 9dfa (2:5dfa) + push de + call Func_9850 + pop de + or a + ret z + ld a, SFX_01 + call PlaySFX + push de + call Func_9e18 + ld a, [wCurCardTypeFilter] + ld c, a + ld b, $00 + ld hl, wcebb + add hl, bc + dec [hl] + pop de + scf + ret +; 0x9e18 + +Func_9e18: ; 9e18 (2:5e18) ld hl, wcf17 - ld de, wOpponentDeck - ld bc, wDuelTempList - ld a, -1 - ld [bc], a -.loop_copy - inc a - push af + ld d, $00 +.loop_1 + inc d + ld a, [hli] + cp e + jr nz, .loop_1 + ld c, l + ld b, h + dec bc +.loop_2 + inc d ld a, [hli] - ld [de], a - inc de or a - jr z, .sort_cards - pop af + jr z, .done ld [bc], a inc bc - jr .loop_copy - -.sort_cards - pop af - ld a, $ff + jr .loop_2 +.done + xor a ld [bc], a - ldh a, [hWhoseTurn] - push af - ld a, OPPONENT_TURN - ldh [hWhoseTurn], a - call SortCardsInDuelTempListByID - pop af - ldh [hWhoseTurn], a + ret +; 0x9e31 - ld hl, wcf17 - ld de, wDuelTempList -.asm_a058 - ld a, [de] - cp $ff - jr z, .done - ld c, a - ld b, $0 - push hl - ld hl, wOpponentDeck - add hl, bc - ld a, [hl] - pop hl - ld [hli], a - inc de - jr .asm_a058 +Func_9e31: ; 9e31 (2:5e31) + ld hl, hffb0 + ld [hl], $01 + call Func_9fc0 + ld hl, hffb0 + ld [hl], $00 + jp PrintConfirmationCardList +; 0x9e41 + +Func_9e41: ; 9e41 (2:5e41) + ld a, [wcecc] + or a + jp z, Func_9f40 + call Func_a028 + call Func_a06e -.done xor a - ld [hl], a - ret -; 0xa06e + ld [wcea1], a +.asm_9e52 + ld hl, Data_9eaf + call Func_9a6d + ld a, [wced9] + ld [wcfe6], a + cp $07 + jr c, .asm_9e64 + ld a, $07 +.asm_9e64 + ld [wNamingScreenKeyboardHeight], a + ld [wcecb], a + call Func_9f52 + ld hl, Func_9e31 + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + xor a + ld [wced2], a +.asm_9e7b + call DoFrame + call Func_9b25 + jr c, .asm_9ea7 + call Func_9eb8 + jr c, .asm_9e7b + ldh a, [hDPadHeld] + and START + jr z, .asm_9e7b -; goes through list in wcf17, and for each card in it -; creates list in wTempHandCardList of all unique cards -; it finds (assuming wcf17 is sorted by ID) -; also counts the number of the different cards -Func_a06e: ; a06e (2:606e) - ld b, 0 - ld c, $0 - ld hl, wcf17 - ld de, wTempHandCardList -.loop - ld a, [hli] - cp c - jr z, .loop +.asm_9e8e + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenCursorY] + ld [wced7], a + ld de, wOwnedCardsCountList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_9c3f + jr .asm_9e52 + +.asm_9ea7 + ld a, [hffb3] + cp $ff + ret z + jr .asm_9e8e +; 0x9eaf + +Data_9eaf: + db $00, $05, $02, $00, $07, $0f, $00, $00, $00 + +Func_9eb8: ; 9eb8 (2:5eb8) + ld a, [wNamingScreenKeyboardHeight] + ld d, a + ld a, [wcea1] ld c, a - ld [de], a - inc de + ldh a, [hDPadHeld] + cp D_RIGHT + jr z, .right + cp D_LEFT + jr z, .left or a - jr z, .done - inc b - jr .loop -.done - ld a, b - ld [wced9], a ret -; 0xa08a -; prints the list of cards visible in the window -; of the confirmation screen -; card info is presented with name, level and -; its count preceded by "x" -PrintConfirmationCardList: ; a08a (2:608a) - push bc - ld hl, wced0 - ld e, [hl] - inc hl - ld d, [hl] - ld b, 19 ; x coord - ld c, e - dec c +.right ld a, [wcea1] - or a - jr z, .no_cursor - ld a, SYM_CURSOR_U - jr .got_cursor_tile_1 -.no_cursor - ld a, SYM_SPACE -.got_cursor_tile_1 - call WriteByteToBGMap0 + add d + ld b, a + add d + ld hl, wcfe6 + cp [hl] + jr c, .asm_9ee8 + ld a, [wcfe6] + sub d + ld b, a + jr .asm_9ee8 -; iterates by decreasing value in wcecb -; by 1 until it reaches 0 +.left ld a, [wcea1] - ld c, a - ld b, $0 - ld hl, wTempHandCardList - add hl, bc - ld a, [wcecb] -.loop_cards - push de - or a - jr z, .exit_loop + sub d ld b, a - ld a, [hli] - or a - jr z, .no_more_cards - ld e, a - call Func_9a59 - call LoadCardDataToBuffer1_FromCardID - ; places in wDefaultText the card's name and level - ; then appends at the end "x" with the count of that card - ; draws the card's type icon as well - ld a, 13 - push bc - push hl - push de - call CopyCardNameAndLevel - pop de - call .PrintCardCount - pop hl - pop bc - pop de - call .DrawCardTypeIcon - push hl - call InitTextPrinting - ld hl, wDefaultText - call ProcessText - pop hl + jr nc, .asm_9ee8 + ld b, $00 +.asm_9ee8 ld a, b - dec a - inc e - inc e - jr .loop_cards + ld [wcea1], a + cp c + jr z, .asm_9efa + ld a, SFX_01 + call PlaySFX + ld hl, wcece + call CallIndirect +.asm_9efa + scf + ret +; 0x9efc -.exit_loop - ld a, [hli] +Func_9efc: ; 9efc (2:5efc) + ld a, [wNamingScreenKeyboardHeight] + ld d, a + ld a, [wcea1] + ld c, a + ldh a, [hDPadHeld] + cp SELECT | D_DOWN + jr z, .sel_down + cp SELECT | D_UP + jr z, .sel_up or a - jr z, .no_more_cards - pop de - xor a - ld [wcecd], a - ld a, SYM_CURSOR_D - jr .got_cursor_tile_2 - -.no_more_cards - pop de - ld a, $01 - ld [wcecd], a - ld a, SYM_SPACE -.got_cursor_tile_2 - ld b, 19 ; x coord - ld c, e - dec c - dec c - call WriteByteToBGMap0 - pop bc ret -; prints the card count preceded by a cross -; for example "x42" -.PrintCardCount - push af - push bc - push de - push hl -.loop_search - ld a, [hl] - or a - jr z, .found_card_id - inc hl - jr .loop_search -.found_card_id - call Func_9850 - ld [hl], TX_SYMBOL - inc hl - ld [hl], SYM_CROSS - inc hl - call ConvertToNumericalDigits - ld [hl], TX_END - pop hl - pop de - pop bc - pop af +.sel_down + ld a, [wcea1] + add d + ld b, a + add d + ld hl, wcfe6 + cp [hl] + jr c, .asm_9f2c + ld a, [wcfe6] + sub d + ld b, a + jr .asm_9f2c +.sel_up + ld a, [wcea1] + sub d + ld b, a + jr nc, .asm_9f2c + ld b, $00 +.asm_9f2c + ld a, b + ld [wcea1], a + cp c + jr z, .set_carry + ld a, SFX_01 + call PlaySFX + ld hl, wcece + call CallIndirect +.set_carry + scf ret +; 0x9f40 -; draws the icon corresponding to the loaded card's type -; can be any of Pokemon stages (basic, 1st and 2nd stage) -; Energy or Trainer -; draws it 2 tiles to the left and 1 up to -; the current coordinate in de -.DrawCardTypeIcon - push hl - push de - push bc - ld a, [wLoadedCard1Type] - cp TYPE_ENERGY - jr nc, .not_pkmn_card - -; pokemon card - ld a, [wLoadedCard1Stage] - ld b, a - add b - add b - add b ; *4 - add ICON_TILE_BASIC_POKEMON - jr .got_tile +Func_9f40: ; 9f40 (2:5f40) + call Func_9f81 +.wait_input + call DoFrame + ldh a, [hKeysPressed] + and B_BUTTON + jr z, .wait_input + ld a, $ff + call PlaySFXConfirmOrCancel + ret +; 0x9f52 -.not_pkmn_card - cp TYPE_TRAINER - jr nc, .trainer_card +Func_9f52: ; 9f52 (2:5f52) + call Func_9f81 + lb de, 3, 5 + ld hl, wced0 + ld [hl], e + inc hl + ld [hl], d + call PrintConfirmationCardList + ret +; 0x9f62 -; energy card - sub TYPE_ENERGY - ld b, a - add b +; counts all values stored in wcebb +; if the total count is 0, then +; prints "No cards chosen." +Func_9f62: ; 9f62 (2:5f62) + lb bc, 0, 0 + ld hl, wcebb +.loop + ld a, [hli] add b - add b ; *4 - add ICON_TILE_FIRE - jr .got_tile - -.trainer_card - ld a, ICON_TILE_TRAINER -.got_tile - dec d - dec d - dec e - push af - lb hl, 1, 2 - lb bc, 2, 2 - call FillRectangle - pop af - - call GetCardTypeIconPalette ld b, a - ld a, [wConsole] - cp CONSOLE_CGB - jr nz, .skip_pal + inc c + ld a, $9 + cp c + jr nz, .loop ld a, b - lb bc, 2, 2 - lb hl, 0, 0 - call BankswitchVRAM1 - call FillRectangle - call BankswitchVRAM0 -.skip_pal - pop bc - pop de - pop hl + or a + ret nz + lb de, 11, 1 + call InitTextPrinting + ldtx hl, NoCardsChosenText + call ProcessTextFromID ret -; 0xa173 +; 0x9f81 -; returns in a the BG Pal corresponding to the -; card type icon in input register a -; if not found, returns $00 -GetCardTypeIconPalette: ; a173 (2:6173) - push bc - push hl - ld b, a - ld hl, .CardTypeIconPalettes -.loop - ld a, [hli] +Func_9f81: ; 9f81 (2:5f81) + call Func_8d56 + lb de, 0, 0 + lb bc, 20, 4 + call DrawRegularTextBox + ld a, [wcfb9] or a - jr z, .done + jp z, .print_card_count ; should be jr + call Func_9fc0 + ld a, [wceb1] + ld b, a + call EnableSRAM + ld a, [sCurrentlySelectedDeck] + call DisableSRAM cp b - jr z, .done - inc hl - jp .loop ; should be jr -.done - ld a, [hl] - pop hl - pop bc + jr nz, .print_card_count + lb de, 2, 1 + call DrawHandCardsTileAtDE + +.print_card_count + lb de, 14, 1 + call PrintTotalCardCount + lb de, 16, 1 + call PrintSlashSixty + call Func_9f62 + call EnableLCD ret +; 0x9fc0 -.CardTypeIconPalettes -; icon tile, BG pal - db ICON_TILE_FIRE, 1 - db ICON_TILE_GRASS, 2 - db ICON_TILE_LIGHTNING, 1 - db ICON_TILE_WATER, 2 - db ICON_TILE_FIGHTING, 3 - db ICON_TILE_PSYCHIC, 3 - db ICON_TILE_COLORLESS, 0 - db ICON_TILE_ENERGY, 2 - db ICON_TILE_BASIC_POKEMON, 2 - db ICON_TILE_STAGE_1_POKEMON, 2 - db ICON_TILE_STAGE_2_POKEMON, 1 - db ICON_TILE_TRAINER, 2 - db $00, $ff -; 0xa1a2 +Func_9fc0: ; 9fc0 (2:5fc0) + ld a, [wceb1] + cp $ff + jr z, .asm_9fea + lb de, 3, 2 + call InitTextPrinting + ld a, [wceb1] + bit 7, a + jr z, .asm_9fd8 + and $7f + jr .asm_9fd9 +.asm_9fd8 + inc a +.asm_9fd9 + ld hl, wDefaultText + call ConvertToNumericalDigits + ld [hl], $77 + inc hl + ld [hl], TX_END + ld hl, wDefaultText + call ProcessText -Func_a1a2: ; a1a2 (2:61a2) - ld hl, wcf17 - ld a, DECK_SIZE + $15 - call ClearNBytesFromHL - ld a, $ff - ld [wceb1], a - ld hl, .text - ld de, wcfb9 +.asm_9fea + ld hl, wcfb9 + ld de, wDefaultText call CopyListFromHLToDE - ld hl, .unknown_a1d8 - call Func_8d9d - call Func_9345 + ld a, [wceb1] + cp $ff + jr z, .asm_a01b + ld hl, wDefaultText + call GetTextLengthInTiles + ld b, $0 + ld hl, wDefaultText + add hl, bc + ld d, h + ld e, l + ld hl, Data_92a7 + call CopyListFromHLToDE + lb de, 6, 2 + ld hl, wDefaultText + call InitTextPrinting + call ProcessText ret -.text - text "Cards chosen to send" - db TX_END +.asm_a01b + lb de, 2, 2 + ld hl, wDefaultText + call InitTextPrinting + call ProcessText + ret +; 0xa028 -.unknown_a1d8 - db $3c, $3c, $00 - dw HandleSendDeckConfigurationMenu - dw SendDeckConfigurationMenu_TransitionTable +Func_a028: ; a028 (2:6028) + ld hl, wcf17 + ld de, wOpponentDeck + ld bc, wDuelTempList + ld a, -1 + ld [bc], a +.loop_copy + inc a + push af + ld a, [hli] + ld [de], a + inc de + or a + jr z, .sort_cards + pop af + ld [bc], a + inc bc + jr .loop_copy + +.sort_cards + pop af + ld a, $ff + ld [bc], a + ldh a, [hWhoseTurn] + push af + ld a, OPPONENT_TURN + ldh [hWhoseTurn], a + call SortCardsInDuelTempListByID + pop af + ldh [hWhoseTurn], a + + ld hl, wcf17 + ld de, wDuelTempList +.asm_a058 + ld a, [de] + cp $ff + jr z, .done + ld c, a + ld b, $0 + push hl + ld hl, wOpponentDeck + add hl, bc + ld a, [hl] + pop hl + ld [hli], a + inc de + jr .asm_a058 + +.done + xor a + ld [hl], a + ret +; 0xa06e + +; goes through list in wcf17, and for each card in it +; creates list in wOwnedCardsCountList of all unique cards +; it finds (assuming wcf17 is sorted by ID) +; also counts the number of the different cards +Func_a06e: ; a06e (2:606e) + ld b, 0 + ld c, $0 + ld hl, wcf17 + ld de, wOwnedCardsCountList +.loop + ld a, [hli] + cp c + jr z, .loop + ld c, a + ld [de], a + inc de + or a + jr z, .done + inc b + jr .loop +.done + ld a, b + ld [wced9], a + ret +; 0xa08a + +; prints the list of cards visible in the window +; of the confirmation screen +; card info is presented with name, level and +; its count preceded by "x" +PrintConfirmationCardList: ; a08a (2:608a) + push bc + ld hl, wced0 + ld e, [hl] + inc hl + ld d, [hl] + ld b, 19 ; x coord + ld c, e + dec c + ld a, [wcea1] + or a + jr z, .no_cursor + ld a, SYM_CURSOR_U + jr .got_cursor_tile_1 +.no_cursor + ld a, SYM_SPACE +.got_cursor_tile_1 + call WriteByteToBGMap0 + +; iterates by decreasing value in wcecb +; by 1 until it reaches 0 + ld a, [wcea1] + ld c, a + ld b, $0 + ld hl, wOwnedCardsCountList + add hl, bc + ld a, [wcecb] +.loop_cards + push de + or a + jr z, .exit_loop + ld b, a + ld a, [hli] + or a + jr z, .no_more_cards + ld e, a + call Func_9a59 + call LoadCardDataToBuffer1_FromCardID + ; places in wDefaultText the card's name and level + ; then appends at the end "x" with the count of that card + ; draws the card's type icon as well + ld a, 13 + push bc + push hl + push de + call CopyCardNameAndLevel + pop de + call .PrintCardCount + pop hl + pop bc + pop de + call .DrawCardTypeIcon + push hl + call InitTextPrinting + ld hl, wDefaultText + call ProcessText + pop hl + ld a, b + dec a + inc e + inc e + jr .loop_cards + +.exit_loop + ld a, [hli] + or a + jr z, .no_more_cards + pop de + xor a + ld [wcecd], a + ld a, SYM_CURSOR_D + jr .got_cursor_tile_2 + +.no_more_cards + pop de + ld a, $01 + ld [wcecd], a + ld a, SYM_SPACE +.got_cursor_tile_2 + ld b, 19 ; x coord + ld c, e + dec c + dec c + call WriteByteToBGMap0 + pop bc + ret + +; prints the card count preceded by a cross +; for example "x42" +.PrintCardCount + push af + push bc + push de + push hl +.loop_search + ld a, [hl] + or a + jr z, .found_card_id + inc hl + jr .loop_search +.found_card_id + call Func_9850 + ld [hl], TX_SYMBOL + inc hl + ld [hl], SYM_CROSS + inc hl + call ConvertToNumericalDigits + ld [hl], TX_END + pop hl + pop de + pop bc + pop af + ret + +; draws the icon corresponding to the loaded card's type +; can be any of Pokemon stages (basic, 1st and 2nd stage) +; Energy or Trainer +; draws it 2 tiles to the left and 1 up to +; the current coordinate in de +.DrawCardTypeIcon + push hl + push de + push bc + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY + jr nc, .not_pkmn_card + +; pokemon card + ld a, [wLoadedCard1Stage] + ld b, a + add b + add b + add b ; *4 + add ICON_TILE_BASIC_POKEMON + jr .got_tile + +.not_pkmn_card + cp TYPE_TRAINER + jr nc, .trainer_card + +; energy card + sub TYPE_ENERGY + ld b, a + add b + add b + add b ; *4 + add ICON_TILE_FIRE + jr .got_tile + +.trainer_card + ld a, ICON_TILE_TRAINER +.got_tile + dec d + dec d + dec e + push af + lb hl, 1, 2 + lb bc, 2, 2 + call FillRectangle + pop af + + call GetCardTypeIconPalette + ld b, a + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .skip_pal + ld a, b + lb bc, 2, 2 + lb hl, 0, 0 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 +.skip_pal + pop bc + pop de + pop hl + ret +; 0xa173 + +; returns in a the BG Pal corresponding to the +; card type icon in input register a +; if not found, returns $00 +GetCardTypeIconPalette: ; a173 (2:6173) + push bc + push hl + ld b, a + ld hl, .CardTypeIconPalettes +.loop + ld a, [hli] + or a + jr z, .done + cp b + jr z, .done + inc hl + jp .loop ; should be jr +.done + ld a, [hl] + pop hl + pop bc + ret + +.CardTypeIconPalettes +; icon tile, BG pal + db ICON_TILE_FIRE, 1 + db ICON_TILE_GRASS, 2 + db ICON_TILE_LIGHTNING, 1 + db ICON_TILE_WATER, 2 + db ICON_TILE_FIGHTING, 3 + db ICON_TILE_PSYCHIC, 3 + db ICON_TILE_COLORLESS, 0 + db ICON_TILE_ENERGY, 2 + db ICON_TILE_BASIC_POKEMON, 2 + db ICON_TILE_STAGE_1_POKEMON, 2 + db ICON_TILE_STAGE_2_POKEMON, 1 + db ICON_TILE_TRAINER, 2 + db $00, $ff +; 0xa1a2 + +Func_a1a2: ; a1a2 (2:61a2) + ld hl, wcf17 + ld a, DECK_SIZE + $15 + call ClearNBytesFromHL + ld a, $ff + ld [wceb1], a + ld hl, .text + ld de, wcfb9 + call CopyListFromHLToDE + ld hl, .unknown_a1d8 + call Func_8d9d + call Func_9345 + ret + +.text + text "Cards chosen to send" + db TX_END + +.unknown_a1d8 + db $3c, $3c, $00 + dw HandleSendDeckConfigurationMenu + dw SendDeckConfigurationMenu_TransitionTable ; 0xa1df -SendDeckConfigurationMenu_TransitionTable: ; a1df (2:61df) - cursor_transition $10, $20, $00, $00, $00, $01, $02 - cursor_transition $48, $20, $00, $01, $01, $02, $00 - cursor_transition $80, $20, $00, $02, $02, $00, $01 +SendDeckConfigurationMenu_TransitionTable: ; a1df (2:61df) + cursor_transition $10, $20, $00, $00, $00, $01, $02 + cursor_transition $48, $20, $00, $01, $01, $02, $00 + cursor_transition $80, $20, $00, $02, $02, $00, $01 + +SendDeckConfigurationMenuData: ; a1f4 (2:61f4) + textitem 2, 2, ConfirmText + textitem 9, 2, SendText + textitem 16, 2, CancelText + db $ff + +HandleSendDeckConfigurationMenu: ; a201 (2:6201) + ld de, $0 + lb bc, 20, 6 + call DrawRegularTextBox + ld hl, SendDeckConfigurationMenuData + call PlaceTextItems + ld a, $ff + ld [wDuelInitialPrizesUpperBitsSet], a +.loop_input + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call Func_89ae + jr nc, .loop_input + ld [wced6], a + cp $ff + jr nz, .asm_a23b + call DrawCardTypeIconsAndPrintCardCounts + ld a, [wced4] + ld [wNamingScreenCursorY], a + ld a, [wCurCardTypeFilter] + call Func_993d + jp Func_9345.skip_draw +.asm_a23b + ld hl, .func_table + call JumpToFunctionInTable + jp Func_9461.asm_9475 + +.func_table + dw ConfirmDeckConfiguration ; Confirm + dw SendDeckConfiguration ; Send + dw CancelSendDeckConfiguration ; Cancel +; 0xa24a + +SendDeckConfiguration: ; a24a (2:624a) + ld a, [wcf17] + or a + jr z, CancelSendDeckConfiguration + xor a + ld [wcea1], a + ld hl, Data_b04a + call Func_9a6d + ld hl, wcf17 + ld de, wDuelTempList + call CopyListFromHLToDE + call Func_b131 + call Func_b088 + call EnableLCD + ldtx hl, SendTheseCardsText + call YesOrNoMenuWithText + jr nc, .asm_a279 + add sp, $2 + jp Func_9345.skip_count +.asm_a279 + add sp, $2 + scf + ret + +CancelSendDeckConfiguration: ; a27d (2:627d) + add sp, $2 + or a + ret +; 0xa281 + +; copies b bytes from hl to de +CopyNBytesFromHLToDE: ; a281 (2:6281) + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, CopyNBytesFromHLToDE + ret +; 0xa288 + +Func_a288: ; a288 (2:6288) + call Func_8ce7 + call Func_a4c6 + xor a + ld [wcea1], a + ld [wCurCardTypeFilter], a + call Func_a39f + call EnableLCD + xor a + ld hl, Data_9667 + call Func_9a6d +.asm_a2a2 + call DoFrame + ld a, [wCurCardTypeFilter] + ld b, a + ld a, [wNamingScreenCursorY] + cp b + jr z, .asm_a2cc + ld [wCurCardTypeFilter], a + ld hl, wcea1 + ld [hl], $00 + call Func_a39f + + ld hl, hffb0 + ld [hl], $01 + call Func_a4de + ld hl, hffb0 + ld [hl], $00 + + ld a, $09 + ld [wNamingScreenKeyboardHeight], a +.asm_a2cc + ldh a, [hDPadHeld] + and D_DOWN + jr z, .asm_a2d7 + call Func_9ad7 + jr .asm_a2e4 + +.asm_a2d7 + call Func_9a83 + jr nc, .asm_a2a2 + ld a, [hffb3] + cp $ff + jr nz, .asm_a2e4 + ret + +.asm_a2e4 + ld a, [wceae] + or a + jr z, .asm_a2a2 + + xor a + ld hl, Data_a396 + call Func_9a6d + ld a, [wceae] + ld [wcfe6], a + ld hl, wcecb + cp [hl] + jr nc, .asm_a300 + ld [wNamingScreenKeyboardHeight], a +.asm_a300 + ld hl, PrintCardSelectionList + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + xor a + ld [wced2], a + +.loop_input + call DoFrame + call Func_9efc + jr c, .loop_input + call Func_9b25 + jr c, .asm_a36a + ldh a, [hDPadHeld] + and START + jr z, .loop_input + ; start btn pressed + +.asm_a321 + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenKeyboardHeight] + ld [wcfdf], a + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld de, wHandTempList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_9c3f + call Func_a4c6 + ld hl, Data_9667 + call Func_9a6d + ld a, [wCurCardTypeFilter] + ld [wNamingScreenCursorY], a + call Func_9b20 + call PrintCardSelectionList + call EnableLCD + ld hl, Data_a396 + call Func_9a6d + ld a, [wcfdf] + ld [wNamingScreenKeyboardHeight], a + ld a, [wced4] + ld [wNamingScreenCursorY], a + jr .loop_input + +.asm_a36a + call Func_9c0e + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld a, [hffb3] + cp $ff + jr nz, .asm_a321 + ld hl, Data_9667 + call Func_9a6d + ld a, [wCurCardTypeFilter] + ld [wNamingScreenCursorY], a + ld hl, hffb0 + ld [hl], $01 + call Func_a4de + ld hl, hffb0 + ld [hl], $00 + jp .asm_a2a2 +; 0xa396 + +Data_a396: ; a396 (2:6396) + db $01, $05, $02, $00, $07, $0f, $00, $00, $00 +; 0xa39f + +; a = which card type filter +Func_a39f: ; a39f (2:639f) + push af + ld hl, CardTypeFilters + ld b, $00 + ld c, a + add hl, bc + ld a, [hl] + push af + ld a, $ff + call Func_a3ca + pop af + call CreateFilteredCardList + + ld a, $07 + ld [wcecb], a + lb de, 2, 5 + ld hl, wced0 + ld [hl], e + inc hl + ld [hl], d + ld a, SYM_SPACE + ld [wCursorAlternateTile], a + call PrintCardSelectionList + pop af + ret +; 0xa3ca + +Func_a3ca: ; a3ca (2:63ca) + ld [hffb5], a + ld hl, sCardCollection + ld de, wTempCardCollection + ld b, $ff + call EnableSRAM + call CopyNBytesFromHLToDE + call DisableSRAM +; deck_1 + ld a, [hffb5] ; should be ldh + bit 0, a + jr z, .deck_2 + ld de, sDeck1Cards + call GetDeckCardCounts +.deck_2 + ld a, [hffb5] ; should be ldh + bit 1, a + jr z, .deck_3 + ld de, sDeck2Cards + call GetDeckCardCounts +.deck_3 + ld a, [hffb5] ; should be ldh + bit 2, a + jr z, .deck_4 + ld de, sDeck3Cards + call GetDeckCardCounts +.deck_4 + ld a, [hffb5] ; should be ldh + bit 3, a + ret z + ld de, sDeck4Cards + call GetDeckCardCounts + ret +; 0xa412 + +; goes through deck cards in de +; and gets the count of each card ID +; in wTempCardCollection in card collection order +GetDeckCardCounts: ; a412 (2:6412) + call EnableSRAM + ld bc, wTempCardCollection + ld h, DECK_SIZE +.loop + ld a, [de] + inc de + or a + jr z, .done + push hl + ld h, $0 + ld l, a + add hl, bc + inc [hl] + pop hl + dec h + jr nz, .loop +.done + call DisableSRAM + ret +; 0xa42d + +; prints the name, level and storage count of the cards +; that are visible in the list window +; in the form: +; CARD NAME/LEVEL X +; where X is the current count of that card +PrintCardSelectionList: ; a42d (2:642d) + push bc + ld hl, wced0 + ld e, [hl] + inc hl + ld d, [hl] + ld b, 19 ; x coord + ld c, e + ld a, [wcea1] + or a + jr z, .alternate_cursor_tile + ld a, SYM_CURSOR_U + jr .got_cursor_tile_1 +.alternate_cursor_tile + ld a, [wCursorAlternateTile] +.got_cursor_tile_1 + call WriteByteToBGMap0 + +; iterates by decreasing value in wcecb +; by 1 until it reaches 0 + ld a, [wcea1] + ld c, a + ld b, $0 + ld hl, wFilteredCardList + add hl, bc + ld a, [wcecb] +.loop_filtered_cards + push de + or a + jr z, .exit_loop + ld b, a + ld a, [hli] + or a + jr z, .invalid_card ; card ID of 0 + ld e, a + call Func_9a59 + call LoadCardDataToBuffer1_FromCardID + ; places in wDefaultText the card's name and level + ; then appends at the end the count of that card + ; in the card storage + ld a, 14 + push bc + push hl + push de + call CopyCardNameAndLevel + pop de + call AppendOwnedCardCountNumber + pop hl + pop bc + pop de + push hl + call InitTextPrinting + ld hl, wDefaultText + jr .process_text +.invalid_card + pop de + push hl + call InitTextPrinting + ld hl, Text_9a36 +.process_text + call ProcessText + pop hl + + ld a, b + dec a + inc e + inc e + jr .loop_filtered_cards + +.exit_loop + ld a, [hli] + or a + jr z, .cannot_scroll + pop de +; draw down cursor because +; there are still more cards +; to be scrolled down + xor a + ld [wcecd], a + ld a, SYM_CURSOR_D + jr .got_cursor_tile_2 +.cannot_scroll + pop de + ld a, $01 + ld [wcecd], a + ld a, [wCursorAlternateTile] +.got_cursor_tile_2 + ld b, 19 ; x coord + ld c, e + dec c + dec c + call WriteByteToBGMap0 + pop bc + ret +; 0xa4ae + +; appends the card count given in register e +; to the list in hl, in numerical form +; (i.e. its numeric symbol representation) +AppendOwnedCardCountNumber: ; a4ae (2:64ae) + push af + push bc + push de + push hl +; increment hl until end is reached ($00 byte) +.loop + ld a, [hl] + or a + jr z, .end + inc hl + jr .loop +.end + call GetOwnedCardCount + call ConvertToNumericalDigits + ld [hl], $00 ; insert byte terminator + pop hl + pop de + pop bc + pop af + ret +; 0xa4c6 + +Func_a4c6: ; a4c6 (2:64c6) + call Set_OBJ_8x8 + call Func_8d78 +; fallthrough + +Func_a4cc: ; a4cc (2:64cc) + lb bc, 0, 4 + ld a, SYM_BOX_TOP + call FillBGMapLineWithA + call PrintTotalNumberOfCardsInCollection + call Func_a4de + call DrawCardTypeIcons + ret +; 0xa4de + +Func_a4de: ; a4de (2:64de) + ld de, $100 + call InitTextPrinting + ld de, wc590 + call CopyPlayerName + ld hl, wc590 + call ProcessText + ld hl, wc590 + call GetTextLengthInTiles + inc b + ld d, b + ld e, $00 + call InitTextPrinting + ldtx hl, SCardsText + call ProcessTextFromID + ret +; 0xa504 + +PrintTotalNumberOfCardsInCollection: ; a504 (2:6504) + ld a, $ff + call Func_a3ca + +; count all the cards in collection + ld de, wTempCardCollection + 1 + ld b, 0 + ld hl, 0 +.loop_all_cards + ld a, [de] + inc de + and $7f + push bc + ld b, $00 + ld c, a + add hl, bc + pop bc + inc b + ld a, NUM_CARDS + cp b + jr nz, .loop_all_cards + +; hl = total number of cards in collection + call .GetTotalCountDigits + ld hl, wTempCardCollection + ld de, wOnesAndTensPlace + ld b, $00 + call .PlaceNumericalChar + call .PlaceNumericalChar + call .PlaceNumericalChar + call .PlaceNumericalChar + call .PlaceNumericalChar + ld a, $07 + ld [hli], a + ld [hl], TX_END + ld de, $d00 + call InitTextPrinting + ld hl, wTempCardCollection + call ProcessText + ret + +; places a numerical character in hl from de +; doesn't place a 0 if no non-0 +; numerical character has been placed before +; this makes it so that there are no +; 0s in more significant digits +.PlaceNumericalChar + ld [hl], TX_SYMBOL + inc hl + ld a, b + or a + jr z, .leading_num + ld a, [de] + inc de + ld [hli], a + ret +.leading_num +; don't place a 0 as a leading number + ld a, [de] + inc de + cp SYM_0 + jr z, .space_char + ld [hli], a + ld b, $01 ; at least one non-0 char was placed + ret +.space_char + xor a ; SYM_SPACE + ld [hli], a + ret + +; gets the digits in decimal form +; of value stored in hl +; stores the result in wOnesAndTensPlace +.GetTotalCountDigits + ld de, wOnesAndTensPlace + ld bc, -10000 + call .GetDigit + ld bc, -1000 + call .GetDigit + ld bc, -100 + call .GetDigit + ld bc, -10 + call .GetDigit + ld bc, -1 + call .GetDigit + ret + +.GetDigit + ld a, SYM_0 - 1 +.loop + inc a + add hl, bc + jr c, .loop + ld [de], a + inc de + ld a, l + sub c + ld l, a + ld a, h + sbc b + ld h, a + ret +; 0xa596 + +; a = CARD_SET_* constant +Func_a596: ; a596 (2:6596) + push af + ld a, DECK_SIZE + ld hl, wHandTempList + call ClearNBytesFromHL + ld a, DECK_SIZE + ld hl, wOwnedCardsCountList + call ClearNBytesFromHL + xor a + ld [wcfe2], a + pop af + + ld hl, 0 + lb de, 0, 0 + ld b, a +.loop_all_cards + inc e + call LoadCardDataToBuffer1_FromCardID + jr c, .asm_a5e6 + ld a, [wLoadedCard1Set] + and $f0 ; set 1 + swap a + cp b + jr nz, .loop_all_cards + +; it's same set as input + ld a, e + cp VENUSAUR1 + jp z, .Func_a681 + cp MEW2 + jp z, .Func_a667 + + push bc + push hl + ld bc, wHandTempList + add hl, bc + ld [hl], e ; card ID + + ld hl, wTempCardCollection + add hl, de + ld a, [hl] + pop hl + push hl + ld bc, wOwnedCardsCountList + add hl, bc + ld [hl], a ; card count in collection + pop hl + + inc l + pop bc + jr .loop_all_cards + +.asm_a5e6 + ld a, b + cp CARD_SET_MYSTERY + jr z, .mystery + or a + jr nz, .not_colosseum_or_mystery + +; colosseum +; places all basic energy cards in wHandTempList + lb de, 0, 0 +.loop_basic_energy_cards + inc e + ld a, e + cp DOUBLE_COLORLESS_ENERGY + jr z, .not_colosseum_or_mystery + push bc + push hl + ld bc, wHandTempList + add hl, bc + ld [hl], e + ld hl, wTempCardCollection + add hl, de + ld a, [hl] + pop hl + push hl + ld bc, wOwnedCardsCountList + add hl, bc + ld [hl], a + pop hl + inc l + pop bc + jr .loop_basic_energy_cards + +.mystery +; places double colorless energy card in wHandTempList + lb de, 0, 0 +.loop_find_double_colorless + inc e + ld a, e + cp BULBASAUR + jr z, .not_colosseum_or_mystery + cp DOUBLE_COLORLESS_ENERGY + jr nz, .loop_find_double_colorless + ; double colorless energy + push bc + push hl + ld bc, wHandTempList + add hl, bc + ld [hl], e + ld hl, wTempCardCollection + add hl, de + ld a, [hl] + pop hl + push hl + ld bc, wOwnedCardsCountList + add hl, bc + ld [hl], a + pop hl + inc l + pop bc + jr .loop_find_double_colorless + +.not_colosseum_or_mystery + ld a, [wcfe2] + bit 0, a + jr z, .asm_a63e + call .Func_a685 +.asm_a63e + bit 1, a + jr z, .asm_a645 + call .Func_a69a + +.asm_a645 + dec l + ld c, l + ld b, h +.loop_owned_cards + ld hl, wOwnedCardsCountList + add hl, bc + ld a, [hl] + cp $80 + jr nz, .found_not_owned + dec c + jr .loop_owned_cards + +.found_not_owned + inc c + ld a, c + ld [wceae], a + xor a + ld hl, wHandTempList + add hl, bc + ld [hl], a + ld a, $ff + ld hl, wOwnedCardsCountList + add hl, bc + ld [hl], a + ret + +.Func_a667 + ld a, $02 +; fallthrough + +.Func_a669 + push hl + push bc + ld b, a + ld hl, wTempCardCollection + add hl, de + ld a, [hl] + cp $80 + jr z, .asm_a67c + ld a, [wcfe2] + or b + ld [wcfe2], a +.asm_a67c + pop bc + pop hl + jp .loop_all_cards + +.Func_a681 + ld a, $01 + jr .Func_a669 + +.Func_a685 + push af + push hl + ld e, VENUSAUR1 +; fallthrough + +.Func_a689 + ld bc, wHandTempList + add hl, bc + ld [hl], e + pop hl + push hl + ld bc, wOwnedCardsCountList + add hl, bc + ld [hl], $01 + pop hl + inc l + pop af + ret + +.Func_a69a + push af + push hl + ld e, MEW2 + jr .Func_a689 +; 0xa6a0 + +; a = CARD_SET_* constant +Func_a6a0: ; a6a0 (2:66a0) + push af + ld hl, sCardCollection + ld de, wTempCardCollection + ld b, $ff + call EnableSRAM + call CopyNBytesFromHLToDE + call DisableSRAM + pop af + + push af + call Func_a6ca + call Func_a596 + ld a, $07 + ld [wcecb], a + ld de, $204 + ld hl, wced0 + ld [hl], e + inc hl + ld [hl], d + pop af + ret +; 0xa6ca + +; a = CARD_SET_* constant +Func_a6ca: ; a6ca (2:66ca) + push af + cp CARD_SET_PROMOTIONAL + jr nz, .asm_a6d4 + ld de, $33f + jr .asm_a6f2 +.asm_a6d4 + cp CARD_SET_LABORATORY + jr nz, .asm_a6dd + ld de, $333 + jr .asm_a6f2 +.asm_a6dd + cp CARD_SET_MYSTERY + jr nz, .asm_a6e6 + ld de, $332 + jr .asm_a6f2 +.asm_a6e6 + cp CARD_SET_EVOLUTION + jr nz, .asm_a6ef + ld de, $331 + jr .asm_a6f2 +.asm_a6ef + ld de, $330 +.asm_a6f2 + ld hl, wcfb9 + ld [hl], d + inc hl + ld [hl], e + pop af + ret +; 0xa6fa + +Func_a6fa: ; a6fa (2:66fa) + push bc + ld hl, wced0 + ld e, [hl] + inc hl + ld d, [hl] + ld b, $13 + ld c, e + dec c + dec c + ld a, [wcea1] + or a + jr z, .asm_a710 + ld a, $0c + jr .asm_a712 +.asm_a710 + ld a, $19 +.asm_a712 + call WriteByteToBGMap0 + ld a, [wcea1] + ld l, a + ld h, $00 + ld a, [wcecb] +.asm_a71e + push de + or a + jr z, .asm_a777 + ld b, a + ld de, wHandTempList + push hl + add hl, de + ld a, [hl] + pop hl + inc l + or a + jr z, .asm_a788 + ld e, a + call Func_9a59 + call LoadCardDataToBuffer1_FromCardID + push bc + push hl + ld de, wOwnedCardsCountList + add hl, de + dec hl + ld a, [hl] + cp $80 + jr nz, .asm_a74c + ld hl, $6799 + ld de, wc590 + call CopyListFromHLToDE + jr .asm_a751 +.asm_a74c + ld a, $0d + call CopyCardNameAndLevel +.asm_a751 + pop hl + pop bc + pop de + push hl + call InitTextPrinting + pop hl + push hl + call Func_a7a7 + call ProcessText + ld hl, wc590 + jr .asm_a76d + pop de + push hl + call InitTextPrinting + ld hl, Text_9a36 +.asm_a76d + call ProcessText + pop hl + ld a, b + dec a + inc e + inc e + jr .asm_a71e +.asm_a777 + ld de, wHandTempList + add hl, de + ld a, [hl] + or a + jr z, .asm_a788 + pop de + xor a + ld [wcecd], a + ld a, $2f + jr .asm_a790 +.asm_a788 + pop de + ld a, $01 + ld [wcecd], a + ld a, $1b +.asm_a790 + ld b, $13 + ld c, $11 + call WriteByteToBGMap0 + pop bc + ret +; 0xa799 + + INCROM $a799, $a7a7 + +Func_a7a7: ; a7a7 (2:67a7) + push bc + push de + ld de, wHandTempList + add hl, de + dec hl + ld a, [hl] + cp BULBASAUR + jr c, .energy_card + cp VENUSAUR1 + jr z, .phantom_card + cp MEW2 + jr z, .phantom_card + + ld a, [wcecb] + sub b + ld hl, wcea1 + add [hl] + inc a + call CalculateOnesAndTensDigits + ld hl, wOnesAndTensPlace + ld a, [hli] + ld b, a + ld a, [hl] + or a + jr nz, .asm_a7d2 + ld a, SYM_0 +.asm_a7d2 + ld hl, wcfb9 + 2 + ld [hl], TX_SYMBOL + inc hl + ld [hli], a + ld [hl], TX_SYMBOL + inc hl + ld a, b + ld [hli], a + ld [hl], TX_SYMBOL + inc hl + xor a + ld [hli], a + ld [hl], a + ld hl, wcfb9 + pop de + pop bc + ret + +.energy_card + call CalculateOnesAndTensDigits + ld hl, wOnesAndTensPlace + ld a, [hli] + ld b, a + ld hl, wcfb9 + 2 + ld de, $334 + ld [hl], d + inc hl + ld [hl], e + inc hl + ld [hl], TX_SYMBOL + inc hl + ld a, SYM_0 + ld [hli], a + ld [hl], TX_SYMBOL + inc hl + ld a, b + ld [hli], a + ld [hl], TX_SYMBOL + inc hl + xor a + ld [hli], a + ld [hl], a + ld hl, wcfb9 + 2 + pop de + pop bc + ret + +.phantom_card + ld hl, wcfb9 + 2 + ld [hl], $6c + inc hl + ld [hl], $6c + inc hl + ld [hl], TX_SYMBOL + inc hl + xor a + ld [hli], a + ld [hl], a + ld hl, wcfb9 + pop de + pop bc + ret +; 0xa828 + +Func_a828: ; a828 (2:6828) + ld a, [wNamingScreenCursorY] + ld b, a + ld a, [wcea1] + add b + ld c, a + ld b, $00 + ld hl, wOwnedCardsCountList + add hl, bc + ld a, [hl] + cp $80 + jr z, .handle_input + + ld hl, wcfd8 + ld a, [hli] + ld h, [hl] + ld l, a + add hl, bc + ld e, [hl] + ld d, $00 + push de + call LoadCardDataToBuffer1_FromCardID + lb de, $38, $9f + call SetupText + bank1call OpenCardPage_FromCheckHandOrDiscardPile + pop de + +.handle_input + ldh a, [hDPadHeld] + ld b, a + and A_BUTTON | B_BUTTON | SELECT | START + jp nz, .asm_a8f5 + xor a ; FALSE + ld [wPlaysSfx], a + ld a, [wNamingScreenKeyboardHeight] + ld c, a + ld a, [wNamingScreenCursorY] + bit D_UP_F, b + jr z, .asm_a891 + + push af + ld a, TRUE + ld [wPlaysSfx], a + ld a, [wNamingScreenCursorY] + ld hl, wcea1 + add [hl] + ld hl, wcfe5 + cp [hl] + jr z, .open_card_page_pop_af + pop af + + dec a + bit 7, a + jr z, .asm_a8c3 + ld a, [wcea1] + or a + jr z, .open_card_page + dec a + ld [wcea1], a + xor a + jr .asm_a8c3 + +.asm_a891 + bit D_DOWN_F, b + jr z, .asm_a8d6 + + push af + ld a, TRUE + ld [wPlaysSfx], a + pop af + + inc a + cp c + jr c, .asm_a8c3 + push af + ld hl, wcfd8 + ld a, [hli] + ld h, [hl] + ld l, a + ld a, [wNamingScreenCursorY] + ld c, a + ld b, $00 + add hl, bc + ld a, [wcea1] + inc a + ld c, a + ld b, $00 + add hl, bc + ld a, [hl] + or a + jr z, .asm_a8d3 + ld a, [wcea1] + inc a + ld [wcea1], a + pop af + dec a +.asm_a8c3 + ld [wNamingScreenCursorY], a + ld a, [wPlaysSfx] + or a + jp z, Func_a828 + call PlaySFX + jp Func_a828 +.asm_a8d3 + pop af + jr .open_card_page + +.asm_a8d6 + ld a, [wced2] + or a + jr z, .open_card_page + bit D_LEFT_F, b + jr z, .asm_a8e5 + call Func_9dfa + jr .open_card_page +.asm_a8e5 + bit D_RIGHT_F, b + jr z, .open_card_page + call Func_9d22 + +.open_card_page_pop_af + pop af +.open_card_page + push de + bank1call OpenCardPage.input_loop + pop de + jp .handle_input + +.asm_a8f5 + ld a, $01 + ld [wVBlankOAMCopyToggle], a + ld a, [wNamingScreenCursorY] + ld [wced4], a + ret +; 0xa901 + +Func_a901: ; a901 (2:6901) + ld hl, wOwnedCardsCountList + ld b, $00 +.asm_a906 + ld a, [hli] + cp $80 + jr nz, .asm_a90e + inc b + jr .asm_a906 +.asm_a90e + ld a, b + ld [wcfe5], a + ret +; 0xa913 + +Func_a913: ; a913 (2:6913) + ld a, $01 + ld [hffb4], a ; should be ldh + + xor a +.asm_a919 + ld hl, .MenuParameters + call InitializeMenuParameters + call .Func_aade +.loop_input_1 + call DoFrame + call HandleMenuInput + jp nc, .loop_input_1 ; should be jr + ldh a, [hCurMenuItem] + cp $ff + ret z + ld c, a + ld b, $00 + ld hl, wcec4 + add hl, bc + ld a, [hl] + or a + jr nz, .loop_input_1 + + ld a, c + ld [wcfe0], a + call Func_a6a0 + call .Func_aa24 + xor a + ld [wcea1], a + call Func_a6fa + call EnableLCD + ld a, [wceae] + or a + jr nz, .asm_a968 + +.loop_input_2 + call DoFrame + ldh a, [hKeysPressed] + and B_BUTTON + jr z, .loop_input_2 + ld a, $ff + call PlaySFXConfirmOrCancel + ldh a, [hCurMenuItem] + jp .asm_a919 + +.asm_a968 + call .Func_aa13 + xor a + ld hl, .data_aa0a + call Func_9a6d + ld a, [wceae] + ld hl, wcecb + cp [hl] + jr nc, .asm_a97e + ld [wNamingScreenKeyboardHeight], a +.asm_a97e + ld hl, Func_a6fa + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + + xor a + ld [wced2], a +.loop_input_3 + call DoFrame + call Func_9b25 + jr c, .asm_a9ed + call Func_9eb8 + jr c, .loop_input_3 + ldh a, [hDPadHeld] + and START + jr z, .loop_input_3 +.asm_a99f + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenKeyboardHeight] + ld [wcfdf], a + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld c, a + ld a, [wcea1] + add c + ld hl, wOwnedCardsCountList + ld c, a + ld b, $00 + add hl, bc + ld a, [hl] + cp $80 + jr z, .loop_input_3 + ld de, wHandTempList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_a901 + call Func_a828 + call .Func_aa24 + call Func_a6fa + call EnableLCD + ld hl, .data_aa0a + call Func_9a6d + ld a, [wcfdf] + ld [wNamingScreenKeyboardHeight], a + ld a, [wced4] + ld [wNamingScreenCursorY], a + jr .loop_input_3 + +.asm_a9ed + call Func_9c0e + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld a, [hffb3] + cp $ff + jr nz, .asm_a99f + ldh a, [hCurMenuItem] + jp .asm_a919 + +.MenuParameters + db 3, 3 ; cursor x, cursor y + db 2 ; y displacement between items + db 5 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw NULL ; function pointer if non-0 + +.data_aa0a + db $01, $04, $02, $00, $07, $0f, $00, $00, $00 + +.Func_aa13 + ld hl, wHandTempList + ld b, $00 +.asm_aa18 + ld a, [hli] + or a + jr z, .asm_aa1f + inc b + jr .asm_aa18 +.asm_aa1f + ld a, b + ld [wcfe6], a + ret + +.Func_aa24 + call Set_OBJ_8x8 + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + call EmptyScreen + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call LoadCursorTile + call LoadSymbolsFont + call LoadDuelCardSymbolTiles + bank1call SetDefaultPalettes + lb de, $3c, $ff + call SetupText + ld de, $101 + call InitTextPrinting + + ld a, [wcfe0] + cp CARD_SET_PROMOTIONAL + jr nz, .check_laboratory + ldtx hl, Item5PromotionalCardText + ld e, 18 + ld a, [wcfe2] + bit 0, a + jr z, .asm_aa62 + inc e ; 19 +.asm_aa62 + bit 1, a + jr z, .asm_aa8f + inc e ; 20 + jr .asm_aa8f +.check_laboratory + cp CARD_SET_LABORATORY + jr nz, .check_mystery + ldtx hl, Item4LaboratoryText + ld e, 51 + jr .asm_aa8f +.check_mystery + cp CARD_SET_MYSTERY + jr nz, .check_evolution + ldtx hl, Item3MysteryText + ld e, 51 + jr .asm_aa8f +.check_evolution + cp CARD_SET_EVOLUTION + jr nz, .colosseum + ldtx hl, Item2EvolutionText + ld e, 50 + jr .asm_aa8f +.colosseum + ldtx hl, Item1ColosseumText + ld e, 56 + +.asm_aa8f + push de + call ProcessTextFromID + call .Func_aac8 + ld de, SerialHandleSend.send_escaped + call InitTextPrinting + + ld a, [wcfe1] + ld hl, wc590 + call ConvertToNumericalDigits + call CalculateOnesAndTensDigits + ld [hl], TX_SYMBOL + inc hl + ld [hl], SYM_SLASH + inc hl + pop de + + ld a, e + call ConvertToNumericalDigits + ld [hl], TX_END + ld hl, wc590 + call ProcessText + lb de, 0, 2 + lb bc, 20, 16 + call DrawRegularTextBox + call EnableLCD + ret + +.Func_aac8 + ld hl, wOwnedCardsCountList + ld b, $00 +.asm_aacd + ld a, [hli] + cp $ff + jr z, .asm_aad9 + cp $80 + jr z, .asm_aacd + inc b + jr .asm_aacd +.asm_aad9 + ld a, b + ld [wcfe1], a + ret + +.Func_aade + xor a + ld [wTileMapFill], a + call EmptyScreen + ld a, [hffb4] + dec a + jr nz, .asm_ab0b + ld [hffb4], a + call Set_OBJ_8x8 + call ZeroObjectPositions + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call LoadCursorTile + call LoadSymbolsFont + call LoadDuelCardSymbolTiles + bank1call SetDefaultPalettes + lb de, $3c, $ff + call SetupText + +.asm_ab0b + lb de, 0, 0 + lb bc, 20, 13 + call DrawRegularTextBox + ld hl, .BoosterPacksMenuData + call PlaceTextItems + ld a, 5 + ld hl, wcec4 + call ClearNBytesFromHL + call EnableSRAM + ld a, [sb703] + call DisableSRAM + or a + jr nz, .asm_ab58 + + ld a, CARD_SET_PROMOTIONAL + call Func_a6a0 + ld a, [wHandTempList] + or a + jr nz, .asm_ab4d + ld a, $01 + ld [wcec4 + 4], a + ld e, $0b + ld d, $05 + call InitTextPrinting + ldtx hl, Text0259 + call ProcessTextFromID + jr .asm_ab58 + +.asm_ab4d + call EnableSRAM + ld a, $01 + ld [sb703], a + call DisableSRAM +.asm_ab58 + ldtx hl, ViewWhichCardFileText + call DrawWideTextBox_PrintText + call EnableLCD + ret + +.BoosterPacksMenuData + textitem 7, 1, BoosterPackTitleText + textitem 5, 3, Item1ColosseumText + textitem 5, 5, Item2EvolutionText + textitem 5, 7, Item3MysteryText + textitem 5, 9, Item4LaboratoryText + textitem 5, 11, Item5PromotionalCardText + db $ff +; 0xab7b + +PrinterMenu_PokemonCards: ; ab7b (2:6b7b) + call Func_8ce7 + call Func_a4c6 + xor a + ld [wcea1], a + ld [wCurCardTypeFilter], a + call Func_a39f + call EnableLCD + xor a + ld hl, Data_9667 + call Func_9a6d + +.loop_frame_1 + call DoFrame + ld a, [wCurCardTypeFilter] + ld b, a + ld a, [wNamingScreenCursorY] + cp b + jr z, .handle_input + ld [wCurCardTypeFilter], a + ld hl, wcea1 + ld [hl], $00 + call Func_a39f + ld hl, hffb0 + ld [hl], $01 + call Func_a4de + ld hl, hffb0 + ld [hl], $00 + ld a, $09 + ld [wNamingScreenKeyboardHeight], a +.handle_input + ldh a, [hDPadHeld] + and D_DOWN + jr z, .asm_abca +; d_down + call Func_9ad7 + jr .asm_abd7 +.asm_abca + call Func_9a83 + jr nc, .loop_frame_1 + ld a, [hffb3] + cp $ff + jr nz, .asm_abd7 + ret + +.asm_abd7 + ld a, [wceae] + or a + jr z, .loop_frame_1 + + xor a + ld hl, Data_a396 + call Func_9a6d + ld a, [wceae] + ld [wcfe6], a + ld hl, wcecb + cp [hl] + jr nc, .asm_abf6 + ld [wNamingScreenKeyboardHeight], a + ld [wcfdf], a +.asm_abf6 + ld hl, PrintCardSelectionList + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + xor a + ld [wced2], a + +.loop_frame_2 + call DoFrame + call Func_9efc + jr c, .loop_frame_2 + call Func_9b25 + jr c, .asm_ac60 + ldh a, [hDPadHeld] + and START + jr z, .loop_frame_2 +; start btn + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenKeyboardHeight] + ld [wcfdf], a + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld de, wHandTempList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_9c3f + call Func_a4c6 + +.asm_ac37 + ld hl, Data_9667 + call Func_9a6d + ld a, [wCurCardTypeFilter] + ld [wNamingScreenCursorY], a + call Func_9b20 + call PrintCardSelectionList + call EnableLCD + ld hl, Data_a396 + call Func_9a6d + ld a, [wcfdf] + ld [wNamingScreenKeyboardHeight], a + ld a, [wced4] + ld [wNamingScreenCursorY], a + jr .loop_frame_2 + +.asm_ac60 + call Func_9c0e + ld a, [wNamingScreenKeyboardHeight] + ld [wcfdf], a + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld a, [hffb3] + cp $ff + jr nz, .asm_ac92 + + ld hl, Data_9667 + call Func_9a6d + ld a, [wCurCardTypeFilter] + ld [wNamingScreenCursorY], a + ld hl, hffb0 + ld [hl], $01 + call Func_a4de + ld hl, hffb0 + ld [hl], $00 + jp .loop_frame_1 + +.asm_ac92 + call Func_9c3a + call .Func_acde + ld de, $101 + call InitTextPrinting + ldtx hl, PrintThisCardYesNoText + call ProcessTextFromID + ld a, $01 + ld hl, Data_ad05 + call Func_9a6d +.loop_frame + call DoFrame + call Func_9a83 + jr nc, .loop_frame + ld a, [hffb3] + or a + jr nz, .asm_acd5 + ld hl, wHandTempList + ld a, [wced4] + ld c, a + ld b, $00 + add hl, bc + ld a, [wcea1] + ld c, a + ld b, $00 + add hl, bc + ld a, [hl] + bank1call Func_758a + call Func_a4c6 + jp .asm_ac37 + +.asm_acd5 + call .Func_acde + call Func_a4cc + jp .asm_ac37 + +.Func_acde + xor a + lb hl, 0, 0 + lb de, 0, 0 + lb bc, 20, 4 + call FillRectangle + ld a, [wConsole] + cp CONSOLE_CGB + ret nz ; exit if not CGB + + xor a + lb hl, 0, 0 + lb de, 0, 0 + lb bc, 20, 4 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 + ret +; 0xad0e + +Data_ad05: ; ad05 (2:6d05) + db $03, $03, $00, $04, $02, $0f, $00, $00, $00 +; 0xad0e + +PrinterMenu_CardList: ; ad0e (2:6d0e) + call Func_8ce7 + call Set_OBJ_8x8 + call Func_8d78 + lb bc, 0, 4 + ld a, SYM_BOX_TOP + call FillBGMapLineWithA + + xor a + ld [wcea1], a + ld [wCurCardTypeFilter], a + call Func_a39f + call EnableLCD + ld de, $101 + call InitTextPrinting + ld hl, EnableLCD + call ProcessTextFromID + ld a, $01 + ld hl, Data_ad05 + call Func_9a6d +.loop_frame + call DoFrame + call Func_9a83 + jr nc, .loop_frame + ld a, [hffb3] + or a + ret nz + bank1call Func_7585 + ret +; 0xad51 + +HandlePrinterMenu: ; ad51 (2:6d51) + bank1call Func_757b + ret c + xor a +.loop + ld hl, PrinterMenuParameters + call InitializeMenuParameters + call Func_8d56 + lb de, 4, 0 + lb bc, 12, 12 + call DrawRegularTextBox + ld de, $602 + call InitTextPrinting + ldtx hl, PrintMenuItemsText + call ProcessTextFromID + ldtx hl, WhatWouldYouLikeToPrintText + call DrawWideTextBox_PrintText + call EnableLCD +.loop_input + call DoFrame + call HandleMenuInput + jr nc, .loop_input + ldh a, [hCurMenuItem] + cp $ff + call z, PrinterMenu_QuitPrint + ld [wcfe4], a + ld hl, PrinterMenuFunctionTable + call JumpToFunctionInTable + ld a, [wcfe4] + jr .loop +; 0xad9a + +PrinterMenu_QuitPrint: ; ad9a (2:6d9a) + add sp, $2 ; exit menu + ldtx hl, PleaseMakeSureToTurnGameBoyPrinterOffText + call DrawWideTextBox_WaitForInput + ret +; 0xada3 + +PrinterMenuFunctionTable: ; ada3 (2:6da3) + dw PrinterMenu_PokemonCards + dw PrinterMenu_DeckConfiguration + dw PrinterMenu_CardList + dw PrinterMenu_PrintQuality + dw PrinterMenu_QuitPrint +; 0xadad + +PrinterMenuParameters: ; adad (2:6dad) + db 5, 2 ; cursor x, cursor y + db 2 ; y displacement between items + db 5 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw NULL ; function pointer if non-0 +; 0xadb5 + +PrinterMenu_PrintQuality: ; adb5 (2:6db5) + ldtx hl, PleaseSetTheContrastText + call DrawWideTextBox_PrintText + call EnableSRAM + ld a, [sPrinterContrastLevel] + call DisableSRAM + ld hl, Data_adf5 + call Func_9a6d +.loop_frame + call DoFrame + call Func_9a83 + jr nc, .loop_frame + ld a, [hffb3] + cp $ff + jr z, .asm_ade2 + call EnableSRAM + ld [sPrinterContrastLevel], a + call DisableSRAM +.asm_ade2 + add sp, $2 ; exit menu + ld a, [wcfe4] + ld hl, PrinterMenuParameters + call InitializeMenuParameters + ldtx hl, WhatWouldYouLikeToPrintText + call DrawWideTextBox_PrintText + jr HandlePrinterMenu.loop_input +; 0xadf5 + +Data_adf5: ; adf5 (2:6df5) + db $05, $10, $00, $02, $05, $0f, $00, $00, $00 +; 0xadfe + +Func_adfe: ; adfe (2:6dfe) + push de + ld de, wcfb9 + call CopyListFromHLToDEInSRAM + pop de + ld hl, wcf17 + call Func_8cd4 + ld a, $09 + ld hl, wcebb + call ClearNBytesFromHL + ld a, DECK_SIZE + ld [wcecc], a + ld hl, wcebb + ld [hl], a + call Func_ae21 + ret +; 0xae21 + +Func_ae21: ; ae21 (2:6e21) + call Func_a028 + call Func_a06e + xor a + ld [wcea1], a +.loop + ld hl, Data_ae91 + call Func_9a6d + ld a, [wced9] + ld [wcfe6], a + cp $05 + jr c, .asm_ae3d + ld a, $05 +.asm_ae3d + ld [wNamingScreenKeyboardHeight], a + ld [wcecb], a + call Func_aeb9 + ld hl, wcfda + ld a, [hli] + ld h, [hl] + ld l, a + call DrawWideTextBox_PrintText + + ld hl, Func_ae9a + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + xor a + ld [wced2], a + +.loop_input + call DoFrame + call Func_9b25 + jr c, .asm_ae89 + call Func_9eb8 + jr c, .loop_input + ldh a, [hDPadHeld] + and START + jr z, .loop_input +.asm_ae70 + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenCursorY] + ld [wced7], a + ld de, wOwnedCardsCountList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_9c3f + jr .loop + +.asm_ae89 + ld a, [hffb3] + cp $ff + ret z + jr .asm_ae70 +; 0xae91 + +Data_ae91: ; ae91 (2:6e91) + db $00, $03, $02, $00, $05, $0f, $00, $00, $00 +; 0xae9a + +Func_ae9a: ; ae9a (2:6e9a) + ld hl, hffb0 + ld [hl], $01 + call Func_aed3 + ld de, $10e + call InitTextPrinting + ld hl, wcfda + ld a, [hli] + ld h, [hl] + ld l, a + call ProcessTextFromID + ld hl, hffb0 + ld [hl], $00 + jp PrintConfirmationCardList +; 0xaeb9 + +Func_aeb9: ; aeb9 (2:6eb9) + call .Func_aec9 + ld de, $303 + ld hl, wced0 + ld [hl], e + inc hl + ld [hl], d + call PrintConfirmationCardList + ret + +.Func_aec9 + call Func_8d56 + call Func_aed3 + call EnableLCD + ret +; 0xaed3 + +Func_aed3: ; aed3 (2:6ed3) + ld a, [wcfb9] + or a + ret z + ld de, $1 + call InitTextPrinting + ld a, [wceb1] + inc a + ld hl, wc590 + call ConvertToNumericalDigits + ld [hl], $77 + inc hl + ld [hl], TX_END + ld hl, wc590 + call ProcessText + + ld hl, wcfb9 + ld de, wc590 + call CopyListFromHLToDE + ld hl, wc590 + call GetTextLengthInTiles + ld b, $00 + ld hl, wc590 + add hl, bc + ld d, h + ld e, l + ld hl, Data_92a7 + call CopyListFromHLToDE + ld de, $301 + ld hl, wc590 + call InitTextPrinting + call ProcessText + ret +; 0xaf1d + +Func_af1d: ; af1d (2:6f1d) + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + call EmptyScreen + ld a, $1 + ld [wVBlankOAMCopyToggle], a + call LoadSymbolsFont + bank1call SetDefaultPalettes + + lb de, $3c, $bf + call SetupText + lb de, 3, 1 + call InitTextPrinting + ldtx hl, ProceduresForSendingCardsText + call ProcessTextFromID + lb de, 1, 3 + call InitTextPrinting + ldtx hl, CardSendingProceduresText + ld a, $01 + ld [wLineSeparation], a + call ProcessTextFromID + xor a + ld [wLineSeparation], a + ldtx hl, PleaseReadTheProceduresForSendingCardsText + call DrawWideTextBox_WaitForInput + + call EnableLCD + call Func_a1a2 + jr c, .asm_af6b + ld a, $01 + or a + ret + +.asm_af6b + ld hl, wcf17 + ld de, wDuelTempList + call CopyListFromHLToDE + xor a + ld [wNameBuffer], a + bank1call Func_756c + ret c + call EnableSRAM + ld hl, wcf17 + call Func_910a + call DisableSRAM + call SaveGame + ld hl, wNameBuffer + ld de, wDefaultText + call CopyListFromHLToDE + xor a + ret + +; never reached + scf + ret +; 0xaf98 + +Func_af98: ; af98 (2:6f98) + xor a + ld [wDuelTempList], a + ld [wNameBuffer], a + bank1call Func_7567 + ret c + + call EnableSRAM + ld hl, wDuelTempList + call Func_9120 + call DisableSRAM + call SaveGame + xor a + ld [wcea1], a + ld hl, Data_b04a + call Func_9a6d + call Func_b141 + call Func_b088 + call EnableLCD + ld a, [wceae] + ld [wcfe6], a + ld hl, wcecb + cp [hl] + jr nc, .asm_afd4 + ld [wNamingScreenKeyboardHeight], a +.asm_afd4 + ld hl, Func_b053 + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + + xor a + ld [wced2], a +.asm_afe2 + call DoFrame + call Func_9b25 + jr c, .asm_b02f + call Func_9eb8 + jr c, .asm_afe2 + ldh a, [hDPadHeld] + and START + jr z, .asm_afe2 +.asm_aff5 + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld de, wFilteredCardList + ld hl, wcfd8 + ld [hl], e + inc hl + ld [hl], d + call Func_9c3f + call Func_b141 + call PrintCardSelectionList + call EnableLCD + ld hl, Data_b04a + call Func_9a6d + ld a, [wceae] + ld hl, wcecb + cp [hl] + jr nc, .asm_b027 + ld [wNamingScreenKeyboardHeight], a +.asm_b027 + ld a, [wced4] + ld [wNamingScreenCursorY], a + jr .asm_afe2 +.asm_b02f + call Func_9c0e + ld a, [wNamingScreenCursorY] + ld [wced4], a + ld a, [hffb3] + cp $ff + jr nz, .asm_aff5 + ld hl, wNameBuffer + ld de, wDefaultText + call CopyListFromHLToDE + or a + ret + +Data_b04a: ; b04a (2:704a) + db $01, $03, $02, $00, $05, $0f, $00, $00, $00 + +Func_b053: ; b053 (2:7053) + ld hl, hffb0 + ld [hl], $01 + lb de, 1, 1 + call InitTextPrinting + ldtx hl, CardReceivedText + call ProcessTextFromID + ld hl, wNameBuffer + ld de, wDefaultText + call CopyListFromHLToDE + xor a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + lb de, 1, 14 + call InitTextPrinting + ldtx hl, ReceivedTheseCardsFromText + call PrintTextNoDelay + ld hl, hffb0 + ld [hl], $00 + jp PrintCardSelectionList +; 0xb088 + +Func_b088: ; b088 (2:7088) + ld a, $ff + ld hl, wTempCardCollection + call ClearNBytesFromHL + ld de, wDuelTempList + call .Func_b0b2 + ld a, $ff + call .Func_b0c0 + ld a, $05 + ld [wcecb], a + lb de, 2, 3 + ld hl, wced0 + ld [hl], e + inc hl + ld [hl], d + ld a, SYM_BOX_RIGHT + ld [wCursorAlternateTile], a + call PrintCardSelectionList + ret + +.Func_b0b2 + ld bc, wTempCardCollection +.loop + ld a, [de] + inc de + or a + ret z + ld h, $00 + ld l, a + add hl, bc + inc [hl] + jr .loop + +.Func_b0c0 + push af + push bc + push de + push hl + push af + ld a, DECK_SIZE + ld hl, wOwnedCardsCountList + call ClearNBytesFromHL + ld a, DECK_SIZE + ld hl, wFilteredCardList + call ClearNBytesFromHL + pop af + ld hl, $0 + ld de, $0 + ld b, a +.asm_b0dd + inc e + call GetCardType + jr c, .asm_b119 + ld c, a + ld a, b + cp $ff + jr z, .asm_b0fc + and $20 + cp $20 + jr z, .asm_b0f5 + ld a, c + cp b + jr nz, .asm_b0dd + jr .asm_b0fc +.asm_b0f5 + ld a, c + and TYPE_ENERGY + cp TYPE_ENERGY + jr nz, .asm_b0dd +.asm_b0fc + push bc + push hl + ld bc, wFilteredCardList + add hl, bc + ld [hl], e + ld hl, wTempCardCollection + add hl, de + ld a, [hl] + and $7f + pop hl + or a + jr z, .asm_b116 + push hl + ld bc, wOwnedCardsCountList + add hl, bc + ld [hl], a + pop hl + inc l +.asm_b116 + pop bc + jr .asm_b0dd + +.asm_b119 + ld a, l + ld [wceae], a + xor a + ld c, l + ld b, h + ld hl, wFilteredCardList + add hl, bc + ld [hl], a + ld a, $ff + ld hl, wOwnedCardsCountList + add hl, bc + ld [hl], a + pop hl + pop de + pop bc + pop af + ret +; 0xb131 + +Func_b131: ; b131 (2:7131) + call Func_b141.Func_b167 + lb de, 1, 1 + call InitTextPrinting + ldtx hl, CardToSendText + call ProcessTextFromID + ret +; 0xb141 -SendDeckConfigurationMenuData: ; a1f4 (2:61f4) - textitem 2, 2, ConfirmText - textitem 9, 2, SendText - textitem 16, 2, CancelText - db $ff +Func_b141: ; b141 (2:7141) + call .Func_b167 + lb de, 1, 1 + call InitTextPrinting + ldtx hl, CardReceivedText + call ProcessTextFromID + ld hl, wNameBuffer + ld de, wDefaultText + call CopyListFromHLToDE + xor a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + ldtx hl, ReceivedTheseCardsFromText + call DrawWideTextBox_PrintText + ret -HandleSendDeckConfigurationMenu: ; a201 (2:6201) +.Func_b167 + call Set_OBJ_8x8 + call Func_8d78 ld de, $0 - lb bc, 20, 6 + lb bc, 20, 13 call DrawRegularTextBox - ld hl, SendDeckConfigurationMenuData - call PlaceTextItems - ld a, $ff - ld [wDuelInitialPrizesUpperBitsSet], a -.loop_input - ld a, $01 - ld [wVBlankOAMCopyToggle], a - call DoFrame - call Func_89ae - jr nc, .loop_input - ld [wced6], a - cp $ff - jr nz, .asm_a23b - call DrawCardTypeIconsAndPrintCardCounts - ld a, [wced4] - ld [wNamingScreenCursorY], a - ld a, [wced3] - call Func_993d - jp Func_9345.skip_draw -.asm_a23b - ld hl, .func_table + ret +; 0xb177 + +Func_b177: ; b177 (2:7177) + ld a, [wd10e] + and $03 + ld hl, .FunctionTable call JumpToFunctionInTable - jp Func_9461.asm_9475 + jr c, .asm_b18f + or a + jr nz, .asm_b18f + xor a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + ret +.asm_b18f + ld a, $ff + ld [wd10e], a + ret -.func_table - dw ConfirmDeckConfiguration ; Confirm - dw SendDeckConfiguration ; Send - dw CancelSendDeckConfiguration ; Cancel -; 0xa24a +.FunctionTable + dw Func_af1d + dw Func_af98 + dw Func_bc04 + dw Func_bc7a +; 0xb19d -SendDeckConfiguration: ; a24a (2:624a) - ld a, [wcf17] - or a - jr z, CancelSendDeckConfiguration +Func_b19d: ; b19d (2:719d) xor a ld [wcea1], a - ld hl, Data_b04a + ldtx de, DeckSaveMachineText + ld hl, wd0a2 + ld [hl], e + inc hl + ld [hl], d + call Func_b379 + ld a, $3c + ld [wd0a5], a + xor a +.asm_b1b3 + ld hl, Data_b6fb call Func_9a6d - ld hl, wcf17 - ld de, wDuelTempList - call CopyListFromHLToDE - call Func_b131 - call Func_b088 - call EnableLCD - ldtx hl, SendTheseCardsText + call Func_b704 + call Func_b545 + ldtx hl, PleaseSelectDeckText + call DrawWideTextBox_PrintText + ldtx de, PleaseSelectDeckText + call Func_b285 + call Func_b29f + jr c, .asm_b1b3 + cp $ff + ret z + ld b, a + ld a, [wcea1] + add b + ld [wd088], a + call ResetCheckMenuCursorPositionAndBlink + call DrawWideTextBox + ld hl, Unknown_b274 + call PlaceTextItems +.asm_b1e7 + call DoFrame + call HandleCheckMenuInput + jp nc, .asm_b1e7 + cp $ff + jr nz, .asm_b1fa + ld a, [wd086] + jp .asm_b1b3 + +.asm_b1fa + ld a, [wCheckMenuCursorYPosition] + sla a + ld hl, wCheckMenuCursorXPosition + add [hl] + or a + jr nz, .asm_b22c + call Func_b35b + jr nc, .asm_b216 + call Func_b592 + ld a, [wd086] + jp c, .asm_b1b3 + jr .asm_b25e + +.asm_b216 + ldtx hl, OKIfFileDeletedText call YesOrNoMenuWithText - jr nc, .asm_a279 - add sp, $2 - jp Func_9345.skip_count -.asm_a279 - add sp, $2 + ld a, [wd086] + jr c, .asm_b1b3 + call Func_b592 + ld a, [wd086] + jp c, .asm_b1b3 + jr .asm_b25e + +.asm_b22c + cp $1 + jr nz, .asm_b24c + call Func_b35b + jr c, .asm_b240 + call Func_b6ca + ld a, [wd086] + jp c, .asm_b1b3 + jr .asm_b25e + +.asm_b240 + ld hl, WaitForVBlank + call DrawWideTextBox_WaitForInput + ld a, [wd086] + jp .asm_b1b3 + +.asm_b24c + cp $2 + jr nz, .asm_b273 + call Func_b35b + jr c, .asm_b240 + call Func_b7c6 + ld a, [wd086] + jp nc, .asm_b1b3 + +.asm_b25e + ld a, [wd087] + ld [wcea1], a + call Func_b379 + call Func_b704 + call Func_b545 + ld a, [wd086] + jp .asm_b1b3 + +.asm_b273 + ret + +Unknown_b274: ; b274 (2:7274) + textitem 2, 14, SaveADeckText + textitem 12, 14, DeleteADeckText + textitem 2, 16, BuildADeckText + textitem 12, 16, CancelText + db $ff + +Func_b285: ; b285 (2:7285) + ld a, $05 + ld [wNamingScreenKeyboardHeight], a + ld hl, wd0a7 + ld [hl], e + inc hl + ld [hl], d + ld hl, Func_b403 + ld d, h + ld a, l + ld hl, wcece + ld [hli], a + ld [hl], d + xor a + ld [wced2], a + ret +; 0xb29f + +Func_b29f: ; b29f (2:729f) + call DoFrame + call Func_9b25 + jr c, .asm_b303 + call .Func_b317 + jr c, Func_b29f ; loop back to start + ldh a, [hDPadHeld] + and START + jr z, Func_b29f ; loop back to start + +; start btn + ld a, [wcea1] + ld [wd087], a + ld b, a + ld a, [wNamingScreenCursorY] + ld [wd086], a + add b + ld c, a + inc a + or $80 + ld [wceb1], a + sla c + ld b, $00 + ld hl, wd00d + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + push hl + ld bc, $18 + add hl, bc + ld d, h + ld e, l + call EnableSRAM + ld a, [hl] + call DisableSRAM + pop hl + or a + jr z, Func_b29f ; loop back to start + + ld a, $01 + call PlaySFXConfirmOrCancel + call Func_8e1f + ld a, [wd087] + ld [wcea1], a + call Func_b379 + call Func_b704 + call Func_b545 + ld a, [wd086] + ld [wNamingScreenCursorY], a scf ret -CancelSendDeckConfiguration: ; a27d (2:627d) - add sp, $2 +.asm_b303 + call Func_9c3a + ld a, [wcea1] + ld [wd087], a + ld a, [wNamingScreenCursorY] + ld [wd086], a + ld a, [hffb3] or a ret -; 0xa281 -; copies b bytes from hl to de -CopyNBytesFromHLToDE: ; a281 (2:6281) - ld a, [hli] - ld [de], a - inc de - dec b - jr nz, CopyNBytesFromHLToDE +.Func_b317 + ld a, [wcea1] + ld c, a + ldh a, [hDPadHeld] + cp D_RIGHT + jr z, .d_right + cp D_LEFT + jr z, .d_left + or a ret -; 0xa288 -Func_a288: ; a288 (2:6288) - INCROM $a288, $a3ca +.d_right + ld a, [wcea1] + add $05 + ld b, a + add $05 + ld hl, wd0a5 + cp [hl] + jr c, .asm_b347 + ld a, [wd0a5] + sub $05 + ld b, a + jr .asm_b347 -Func_a3ca: ; a3ca (2:63ca) - ld [hffb5], a - ld hl, sCardCollection - ld de, wTempCardCollection - ld b, $ff - call EnableSRAM - call CopyNBytesFromHLToDE - call DisableSRAM -; deck_1 - ld a, [hffb5] ; should be ldh - bit 0, a - jr z, .deck_2 - ld de, sDeck1Cards - call GetDeckCardCounts -.deck_2 - ld a, [hffb5] ; should be ldh - bit 1, a - jr z, .deck_3 - ld de, sDeck2Cards - call GetDeckCardCounts -.deck_3 - ld a, [hffb5] ; should be ldh - bit 2, a - jr z, .deck_4 - ld de, sDeck3Cards - call GetDeckCardCounts -.deck_4 - ld a, [hffb5] ; should be ldh - bit 3, a - ret z - ld de, sDeck4Cards - call GetDeckCardCounts +.d_left + ld a, [wcea1] + sub $05 + ld b, a + jr nc, .asm_b347 + ld b, $00 + +.asm_b347 + ld a, b + ld [wcea1], a + cp c + jr z, .asm_b359 + ld a, SFX_01 + call PlaySFX + call Func_b403 + call Func_b545 +.asm_b359 + scf ret -; 0xa412 +; 0xb35b -; goes through deck cards in de -; and gets the count of each card ID -; in wTempCardCollection in card collection order -GetDeckCardCounts: ; a412 (2:6412) - call EnableSRAM - ld bc, wTempCardCollection - ld h, DECK_SIZE -.loop - ld a, [de] - inc de - or a - jr z, .done - push hl - ld h, $0 +Func_b35b: ; b35b (2:735b) + ld a, [wd088] + sla a ld l, a + ld h, $00 + ld bc, wd00d add hl, bc - inc [hl] - pop hl - dec h - jr nz, .loop -.done + ld a, [hli] + ld h, [hl] + ld l, a + ld bc, $18 + add hl, bc + call EnableSRAM + ld a, [hl] call DisableSRAM + or a + ret nz + scf ret -; 0xa42d +; 0xb379 -; prints the name, level and storage count of the cards -; that are visible in the list window -; in the form: -; CARD NAME/LEVEL X -; where X is the current count of that card -PrintCardSelectionList: ; a42d (2:642d) - push bc - ld hl, wced0 - ld e, [hl] - inc hl - ld d, [hl] - ld b, 19 ; x coord - ld c, e - ld a, [wcea1] - or a - jr z, .alternate_cursor_tile - ld a, SYM_CURSOR_U - jr .got_cursor_tile_1 -.alternate_cursor_tile - ld a, [wCursorAlternateTile] -.got_cursor_tile_1 - call WriteByteToBGMap0 +Func_b379: ; b379 (2:7379) + call Set_OBJ_8x8 + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + call EmptyScreen + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call LoadSymbolsFont + call LoadDuelCardSymbolTiles + bank1call SetDefaultPalettes + lb de, $3c, $ff + call SetupText + lb de, 0, 0 + lb bc, 20, 13 + call DrawRegularTextBox + call Func_b3b3 + call Func_b3c3 + call Func_b3e5 + call Func_b525 + call EnableLCD + ret +; 0xb3b3 -; iterates by decreasing value in wcecb -; by 1 until it reaches 0 - ld a, [wcea1] - ld c, a - ld b, $0 - ld hl, wFilteredCardList +Func_b3b3: ; b3b3 (2:73b3) + lb de, 1, 0 + call InitTextPrinting + ld hl, wd0a2 + ld a, [hli] + ld h, [hl] + ld l, a + call ProcessTextFromID + ret +; 0xb3c3 + +Func_b3c3: ; b3c3 (2:73c3) + ld a, DECK_SIZE + add DECK_SIZE + ld hl, wd00d + call ClearNBytesFromHL + ld de, wd00d + ld hl, s0a350 + ld bc, $54 + ld a, DECK_SIZE +.asm_b3d8 + push af + ld a, l + ld [de], a + inc de + ld a, h + ld [de], a + inc de add hl, bc - ld a, [wcecb] -.loop_filtered_cards + pop af + dec a + jr nz, .asm_b3d8 + ret +; 0xb3e5 + +Func_b3e5: ; b3e5 (2:73e5) + ld a, [wcea1] + ld de, $202 + ld b, $05 +.asm_b3ed + push af + push bc push de - or a - jr z, .exit_loop - ld b, a + call Func_b424 + pop de + pop bc + pop af + ret c + dec b + ret z + inc a + inc e + inc e + jr .asm_b3ed +; 0xb3fe + +Func_b3fe: ; b3fe (2:73fe) + call Func_b704 + jr Func_b3e5 +; 0xb403 + +Func_b403: ; b403 (2:7403) + call Func_b704 + ld hl, hffb0 + ld [hl], $01 + call Func_b3b3 + lb de, 1, 14 + call InitTextPrinting + ld hl, wd0a7 ld a, [hli] - or a - jr z, .invalid_card ; card ID of 0 - ld e, a - call Func_9a59 - call LoadCardDataToBuffer1_FromCardID - ; places in wDefaultText the card's name and level - ; then appends at the end the count of that card - ; in the card storage - ld a, 14 + ld h, [hl] + ld l, a + call ProcessTextFromID + ld hl, hffb0 + ld [hl], $00 + jr Func_b3e5 +; 0xb424 + +Func_b424: ; b424 (2:7424) + ld b, a push bc - push hl + ld hl, wDefaultText + inc a + call ConvertToNumericalDigits + ld [hl], $77 + inc hl + ld [hl], $00 + call InitTextPrinting + ld hl, wDefaultText + call ProcessText + pop af + push af + sla a + ld l, a + ld h, $00 + ld bc, wd00d + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + inc d + inc d + inc d push de - call CopyCardNameAndLevel + call Func_92be pop de - call AppendOwnedCardCountNumber - pop hl pop bc - pop de - push hl + jr nc, .asm_b46b call InitTextPrinting - ld hl, wDefaultText - jr .process_text -.invalid_card - pop de - push hl + ldtx hl, Text025b + call ProcessTextFromID + ld d, 13 + inc e call InitTextPrinting - ld hl, Text_9a36 -.process_text + ld hl, Text_b4d4 call ProcessText - pop hl + scf + ret - ld a, b - dec a - inc e - inc e - jr .loop_filtered_cards +.asm_b46b + push de + push bc + ld d, 18 + call InitTextPrinting + ld a, $00 + call Func_b625 + pop bc + ld hl, wDefaultText + jr c, .asm_b482 + ld de, $35f ; "○" + jr .asm_b4c2 -.exit_loop +.asm_b482 + push bc + ld a, $ff + call Func_b625 + jr c, .asm_b490 + pop bc + ld de, $360 ; "❄" + jr .asm_b4c2 + +.asm_b490 + ld de, $6c ; "✕" + call Func_22ca + pop bc + pop de + push bc + ld d, 17 + inc e + call InitTextPrinting + pop bc + call Func_b4e1 + call CalculateOnesAndTensDigits + ld hl, wOnesAndTensPlace ld a, [hli] + ld b, a + ld a, [hl] + ld hl, wDefaultText + ld [hl], TX_SYMBOL + inc hl + ld [hli], a + ld [hl], TX_SYMBOL + inc hl + ld a, b + ld [hli], a + ld [hl], TX_END + ld hl, wDefaultText + call ProcessText or a - jr z, .cannot_scroll - pop de -; draw down cursor because -; there are still more cards -; to be scrolled down - xor a - ld [wcecd], a - ld a, SYM_CURSOR_D - jr .got_cursor_tile_2 -.cannot_scroll + ret + +.asm_b4c2 + call Func_22ca pop de - ld a, $01 - ld [wcecd], a - ld a, [wCursorAlternateTile] -.got_cursor_tile_2 - ld b, 19 ; x coord - ld c, e - dec c - dec c - call WriteByteToBGMap0 - pop bc + ld d, 13 + inc e + call InitTextPrinting + ld hl, Text_b4d4 + call ProcessText + or a ret -; 0xa4ae +; 0xb4d4 -; appends the card count given in register e -; to the list in hl, in numerical form -; (i.e. its numeric symbol representation) -AppendOwnedCardCountNumber: ; a4ae (2:64ae) - push af +Text_b4d4: ; b4d4 (2:74d4) + db TX_SYMBOL, TX_END + db TX_SYMBOL, TX_END + db TX_SYMBOL, TX_END + db TX_SYMBOL, TX_END + db TX_SYMBOL, TX_END + db TX_SYMBOL, TX_END + db TX_END +; 0xb4e1 + +Func_b4e1: ; b4e1 (2:74e1) push bc - push de + call Func_b644 + call Func_a3ca + call Func_b664 + pop bc + sla b + ld c, b + ld b, $00 + ld hl, wd00d + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + ld bc, $18 + add hl, bc + call EnableSRAM + ld de, wTempCardCollection + ld bc, $0 +.asm_b505 + inc b + ld a, DECK_SIZE + cp b + jr c, .asm_b520 + ld a, [hli] push hl -; increment hl until end is reached ($00 byte) -.loop + ld l, a + ld h, $00 + add hl, de ld a, [hl] + and $7f or a - jr z, .end - inc hl - jr .loop -.end - call GetOwnedCardCount - call ConvertToNumericalDigits - ld [hl], $00 ; insert byte terminator + jr z, .asm_b51c + dec a + ld [hl], a pop hl - pop de - pop bc - pop af + jr .asm_b505 +.asm_b51c + inc c + pop hl + jr .asm_b505 +.asm_b520 + ld a, c + call DisableSRAM ret -; 0xa4c6 - - INCROM $a4c6, $a913 - -Func_a913: ; a913 (2:6913) - INCROM $a913, $ad51 - -Func_ad51: ; ad51 (2:6d51) - INCROM $ad51, $adfe - -Func_adfe: ; adfe (2:6dfe) - INCROM $adfe, $af1d - -Func_af1d: ; af1d (2:6f1d) - xor a - ld [wTileMapFill], a - call ZeroObjectPositions - call EmptyScreen - ld a, $1 - ld [wVBlankOAMCopyToggle], a - call LoadSymbolsFont - bank1call SetDefaultPalettes - - lb de, $3c, $bf - call SetupText - lb de, 3, 1 - call InitTextPrinting - ldtx hl, ProceduresForSendingCardsText - call ProcessTextFromID - lb de, 1, 3 - call InitTextPrinting - ldtx hl, CardSendingProceduresText - ld a, $01 - ld [wLineSeparation], a - call ProcessTextFromID - xor a - ld [wLineSeparation], a - ldtx hl, PleaseReadTheProceduresForSendingCardsText - call DrawWideTextBox_WaitForInput +; 0xb525 - call EnableLCD - call Func_a1a2 - jr c, .asm_af6b - ld a, $01 +Func_b525: ; b525 (2:7525) + call EnableSRAM + ld hl, s0a350 + ld bc, $54 + ld d, DECK_SIZE + ld e, $00 +.loop + ld a, [hl] or a + jr z, .asm_b537 + inc e +.asm_b537 + dec d + jr z, .asm_b53d + add hl, bc + jr .loop +.asm_b53d + ld a, e + ld [wd085], a + call DisableSRAM ret +; 0xb545 -.asm_af6b - ld hl, wcf17 - ld de, wDuelTempList - call CopyListFromHLToDE - xor a - ld [wNameBuffer], a - bank1call Func_756c - ret c - call EnableSRAM - ld hl, wcf17 - call Func_910a - call DisableSRAM - call SaveGame - ld hl, wNameBuffer - ld de, wDefaultText - call CopyListFromHLToDE - xor a +Func_b545: ; b545 (2:7545) + ld a, [wd085] + ld hl, wc590 + call ConvertToNumericalDigits + ld a, TX_SYMBOL + ld [hli], a + ld a, SYM_SLASH + ld [hli], a + ld a, DECK_SIZE + call ConvertToNumericalDigits + ld [hl], TX_END + ld de, SerialHandleSend.send_escaped + call InitTextPrinting + ld hl, wc590 + call ProcessText ret +; 0xb568 -; never reached - scf - ret -; 0xaf98 + INCROM $b568, $b592 -Func_af98: ; af98 (2:6f98) +Func_b592: ; b592 (2:7592) + ld a, $ff + call Func_9168 xor a - ld [wDuelTempList], a - ld [wNameBuffer], a - bank1call Func_7567 - ret c +.asm_b598 + ld hl, DeckMachineMenuParameters + call InitializeMenuParameters + ldtx hl, ChooseADeckToSaveText + call DrawWideTextBox_PrintText +.loop_input + call DoFrame + call Func_8dea + jr c, .asm_b598 + call HandleMenuInput + jp nc, .loop_input ; should be jr + ldh a, [hCurMenuItem] + cp $ff + ret z + ld [wceb1], a + call Func_8ff2 + jp nc, .Func_b5c8 + call Func_8fe8 + ld a, [wceb1] + jr .asm_b598 +.Func_b5c8 + call GetPointerToDeckName + call Func_b611 + ld b, $54 call EnableSRAM - ld hl, wDuelTempList - call Func_9120 + call CopyNBytesFromHLToDE call DisableSRAM - call SaveGame - xor a - ld [wcea1], a - ld hl, Data_b04a - call Func_9a6d - call Func_b141 - call Func_b088 - call EnableLCD - ld a, [wceab + 3] - ld [wcfe4 + 2], a - ld hl, wcecb - cp [hl] - jr nc, .asm_afd4 - ld [wNamingScreenKeyboardHeight], a -.asm_afd4 - ld hl, Func_b053 - ld d, h - ld a, l - ld hl, wcece - ld [hli], a - ld [hl], d - - xor a - ld [wced2], a -.asm_afe2 - call DoFrame - call Func_9b25 - jr c, .asm_b02f - call Func_9eb8 - jr c, .asm_afe2 - ldh a, [hDPadHeld] - and START - jr z, .asm_afe2 -.asm_aff5 - ld a, $01 - call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] - ld [wced4], a - ld de, wFilteredCardList - ld hl, wcfd8 - ld [hl], e - inc hl - ld [hl], d - call Func_9c3f - call Func_b141 - call PrintCardSelectionList - call EnableLCD - ld hl, Data_b04a + call Func_b379 + call Func_b704 + call Func_b545 + ld a, [wd086] + ld hl, Data_b6fb call Func_9a6d - ld a, [wceab + 3] - ld hl, wcecb - cp [hl] - jr nc, .asm_b027 - ld [wNamingScreenKeyboardHeight], a -.asm_b027 - ld a, [wced4] - ld [wNamingScreenCursorY], a - jr .asm_afe2 -.asm_b02f - call Func_9c0e - ld a, [wNamingScreenCursorY] - ld [wced4], a - ld a, [hffb3] - cp $ff - jr nz, .asm_aff5 - ld hl, wNameBuffer - ld de, wDefaultText - call CopyListFromHLToDE - or a - ret - -Data_b04a: ; b04a (2:704a) - db $01, $03, $02, $00, $05, $0f, $00, $00, $00 - -Func_b053: ; b053 (2:7053) - ld hl, hffb0 - ld [hl], $01 - lb de, 1, 1 - call InitTextPrinting - ldtx hl, CardReceivedText - call ProcessTextFromID - ld hl, wNameBuffer - ld de, wDefaultText - call CopyListFromHLToDE + call Func_9c3a + call GetPointerToDeckName + call EnableSRAM + call Func_9253 + call DisableSRAM xor a ld [wTxRam2 + 0], a ld [wTxRam2 + 1], a - lb de, 1, 14 - call InitTextPrinting - ldtx hl, ReceivedTheseCardsFromText - call PrintTextNoDelay - ld hl, hffb0 - ld [hl], $00 - jp PrintCardSelectionList -; 0xb088 + ldtx hl, SavedTheConfigurationForText + call DrawWideTextBox_WaitForInput + scf + ret +; 0xb609 -Func_b088: ; b088 (2:7088) - ld a, $ff - ld hl, wTempCardCollection - call ClearNBytesFromHL - ld de, wDuelTempList - call .Func_b0b2 - ld a, $ff - call .Func_b0c0 - ld a, $05 - ld [wcecb], a - lb de, 2, 3 - ld hl, wced0 - ld [hl], e +DeckMachineMenuParameters: ; b609 (2:7609) + db 1, 2 ; cursor x, cursor y + db 3 ; y displacement between items + db 4 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw NULL ; function pointer if non-0 +; 0xb611 + +Func_b611: ; b611 (2:7611) + push af + push hl + ld a, [wd088] + sla a + ld e, a + ld d, $00 + ld hl, wd00d + add hl, de + ld e, [hl] inc hl - ld [hl], d - ld a, SYM_BOX_RIGHT - ld [wCursorAlternateTile], a - call PrintCardSelectionList + ld d, [hl] + pop hl + pop af ret +; 0xb625 -.Func_b0b2 - ld bc, wTempCardCollection -.loop - ld a, [de] - inc de - or a - ret z - ld h, $00 +Func_b625: ; b625 (2:7625) + push bc + call Func_b644 + call Func_a3ca + call Func_b664 + pop bc + sla b + ld c, b + ld b, $00 + ld hl, wd00d + add hl, bc + ld a, [hli] + ld h, [hl] ld l, a + ld bc, $18 add hl, bc - inc [hl] - jr .loop + call Func_b675 + ret +; 0xb644 -.Func_b0c0 +; switches to SRAM bank 0 and stores current SRAM bank in wd0a4 +; skips if current SRAM bank is already 0 +Func_b644: ; b644 (2:7644) push af - push bc - push de - push hl + ldh a, [hBankSRAM] + or a + jr z, .skip + ld [wd0a4], a + xor a + call BankswitchSRAM +.skip + pop af + ret +; 0xb653 + +; switches to SRAM bank 1 and stores current SRAM bank in wd0a4 +; skips if current SRAM bank is already 1 +Func_b653: ; b653 (2:7653) push af - ld a, DECK_SIZE - ld hl, wOwnedCardsCountList - call ClearNBytesFromHL - ld a, DECK_SIZE - ld hl, wFilteredCardList - call ClearNBytesFromHL + ldh a, [hBankSRAM] + cp BANK("SRAM1") + jr z, .skip + ld [wd0a4], a + ld a, BANK("SRAM1") + call BankswitchSRAM +.skip pop af - ld hl, $0 - ld de, $0 - ld b, a -.asm_b0dd - inc e - call GetCardType - jr c, .asm_b119 - ld c, a - ld a, b - cp $ff - jr z, .asm_b0fc - and $20 - cp $20 - jr z, .asm_b0f5 - ld a, c - cp b - jr nz, .asm_b0dd - jr .asm_b0fc -.asm_b0f5 - ld a, c - and TYPE_ENERGY - cp TYPE_ENERGY - jr nz, .asm_b0dd -.asm_b0fc + ret +; 0xb664 + +Func_b664: ; b664 (2:7664) + push af push bc + ldh a, [hBankSRAM] + ld b, a + ld a, [wd0a4] + cp b + jr z, .asm_b672 + call BankswitchSRAM +.asm_b672 + pop bc + pop af + ret +; 0xb675 + +Func_b675: ; b675 (2:7675) + call EnableSRAM + ld de, wTempCardCollection + ld b, 0 +.asm_b67d + inc b + ld a, DECK_SIZE + cp b + jr c, .no_carry + ld a, [hli] push hl - ld bc, wFilteredCardList - add hl, bc - ld [hl], e - ld hl, wTempCardCollection + ld l, a + ld h, $00 add hl, de ld a, [hl] - and $7f - pop hl or a - jr z, .asm_b116 - push hl - ld bc, wOwnedCardsCountList - add hl, bc + jr z, .set_carry + cp $80 + jr z, .set_carry + dec a ld [hl], a pop hl - inc l -.asm_b116 - pop bc - jr .asm_b0dd + jr .asm_b67d -.asm_b119 - ld a, l - ld [wceab + 3], a - xor a - ld c, l - ld b, h - ld hl, wFilteredCardList - add hl, bc - ld [hl], a - ld a, $ff - ld hl, wOwnedCardsCountList - add hl, bc - ld [hl], a +.set_carry pop hl - pop de - pop bc - pop af + call DisableSRAM + scf ret -; 0xb131 -Func_b131: ; b131 (2:7131) - call Func_b141.Func_b167 - lb de, 1, 1 - call InitTextPrinting - ldtx hl, CardToSendText - call ProcessTextFromID +.no_carry + call DisableSRAM + or a ret -; 0xb141 +; 0xb6a1 -Func_b141: ; b141 (2:7141) - call .Func_b167 - lb de, 1, 1 - call InitTextPrinting - ldtx hl, CardReceivedText - call ProcessTextFromID - ld hl, wNameBuffer - ld de, wDefaultText - call CopyListFromHLToDE +Func_b6a1: ; b6a1 (2:76a1) + ld hl, sDeck1Cards + ld a, [hl] + or a + jr nz, .check_deck_2 xor a - ld [wTxRam2 + 0], a - ld [wTxRam2 + 1], a - ldtx hl, ReceivedTheseCardsFromText - call DrawWideTextBox_PrintText ret -.Func_b167 - call Set_OBJ_8x8 - call Func_8d78 - ld de, $0 - lb bc, 20, 13 - call DrawRegularTextBox +.check_deck_2 + ld hl, sDeck2Cards + ld a, [hl] + or a + jr nz, .check_deck_3 + ld a, $01 ret -; 0xb177 -Func_b177: ; b177 (2:7177) - ld a, [wd10e] - and $03 - ld hl, .FunctionTable - call JumpToFunctionInTable - jr c, .asm_b18f +.check_deck_3 + ld hl, sDeck3Cards + ld a, [hl] or a - jr nz, .asm_b18f - xor a - ld [wTxRam2 + 0], a - ld [wTxRam2 + 1], a - ret -.asm_b18f - ld a, $ff - ld [wd10e], a + jr nz, .check_deck_4 + ld a, $02 ret -.FunctionTable - dw Func_af1d - dw Func_af98 - dw Func_bc04 - dw Func_bc7a -; 0xb19d - -Func_b19d: ; b19d (2:719d) - xor a - ld [wcea1], a - ldtx de, DeckSaveMachineText - ld hl, wd0a2 - ld [hl], e - inc hl - ld [hl], d - call Func_b379 - ld a, $3c - ld [wd0a5], a - xor a -.asm_b1b3 - ld hl, Data_b6fb - call Func_9a6d - call Func_b704 - call Func_b545 - ldtx hl, PleaseSelectDeckText - call DrawWideTextBox_PrintText - ldtx de, PleaseSelectDeckText - call Func_b285 - call Func_b29f - jr c, .asm_b1b3 - cp $ff - ret z - ld b, a - ld a, [wcea1] - add b - ld [wd088], a - call ResetCheckMenuCursorPositionAndBlink - call DrawWideTextBox - ld hl, Unknown_b274 - call PlaceTextItems -.asm_b1e7 - call DoFrame - call HandleCheckMenuInput - jp nc, .asm_b1e7 - cp $ff - jr nz, .asm_b1fa - ld a, [wd086] - jp .asm_b1b3 - -.asm_b1fa - ld a, [wCheckMenuCursorYPosition] - sla a - ld hl, wCheckMenuCursorXPosition - add [hl] +.check_deck_4 + ld hl, sDeck4Cards + ld a, [hl] or a - jr nz, .asm_b22c - call Func_b35b - jr nc, .asm_b216 - call Func_b592 - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e - -.asm_b216 - ldtx hl, OKIfFileDeletedText - call YesOrNoMenuWithText - ld a, [wd086] - jr c, .asm_b1b3 - call Func_b592 - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e - -.asm_b22c - cp $1 - jr nz, .asm_b24c - call Func_b35b - jr c, .asm_b240 - call Func_b6ca - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e - -.asm_b240 - ld hl, WaitForVBlank - call DrawWideTextBox_WaitForInput - ld a, [wd086] - jp .asm_b1b3 - -.asm_b24c - cp $2 - jr nz, .asm_b273 - call Func_b35b - jr c, .asm_b240 - call Func_b7c6 - ld a, [wd086] - jp nc, .asm_b1b3 - -.asm_b25e - ld a, [wd087] - ld [wcea1], a - call Func_b379 - call Func_b704 - call Func_b545 - ld a, [wd086] - jp .asm_b1b3 - -.asm_b273 + jr nz, .set_carry + ld a, $03 ret -Unknown_b274: ; b274 (2:7274) - INCROM $b274, $b285 +.set_carry + scf + ret +; 0xb6ca -Func_b285: ; b285 (2:7285) - ld a, $05 - ld [wNamingScreenKeyboardHeight], a - ld hl, wd0a7 - ld [hl], e - inc hl - ld [hl], d - ld hl, Func_b403 - ld d, h - ld a, l - ld hl, wcece - ld [hli], a - ld [hl], d +Func_b6ca: ; b6ca (2:76ca) + ldtx hl, DoYouReallyWishToDeleteText + call YesOrNoMenuWithText + jr c, .no + call Func_b611 + ld l, e + ld h, d + push hl + call EnableSRAM + call Func_9253 + pop hl + ld a, $54 + call ClearNBytesFromHL + call DisableSRAM xor a - ld [wced2], a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + ldtx hl, DeletedTheConfigurationForText + call DrawWideTextBox_WaitForInput + or a + ret + +.no + ld a, [wNamingScreenCursorY] + scf ret -; 0xb29f +; 0xb6fb -Func_b29f: ; b29f (2:729f) - INCROM $b29f, $b35b +Data_b6fb: ; b6fb (2:76fb) + db $01, $02, $02, $00, $05, $0f, $00, $00, $00 -Func_b35b: ; b35b (2:735b) - INCROM $b35b, $b379 +Func_b704: ; b704 (2:7704) + ld a, [wcea1] + or a + jr z, .asm_b70e + ld a, SYM_CURSOR_U + jr .got_tile_1 +.asm_b70e + ld a, SYM_BOX_RIGHT +.got_tile_1 + lb bc, 19, 1 + call WriteByteToBGMap0 -Func_b379: ; b379 (2:7379) - INCROM $b379, $b3b3 + ld a, [wcea1] + add $06 + ld b, a + ld a, [wd0a5] + cp b + jr c, .asm_b72a + xor a + ld [wcecd], a + ld a, SYM_CURSOR_D + jr .got_tile_2 +.asm_b72a + ld a, $01 + ld [wcecd], a + ld a, SYM_BOX_RIGHT +.got_tile_2 + lb bc, 19, 11 + call WriteByteToBGMap0 + ret +; 0xb738 -Func_b3b3: ; b3b3 (2:73b3) - lb de, 1, 0 - call InitTextPrinting - ld hl, wd0a2 - ld a, [hli] - ld h, [hl] - ld l, a - call ProcessTextFromID +Func_b738: ; b738 (2:7738) + ldtx hl, YouMayOnlyCarry4DecksText + call DrawWideTextBox_WaitForInput + call Func_b644 + ld a, $ff + call Func_9168 + xor a +.init_menu_params + ld hl, DeckMachineMenuParameters + call InitializeMenuParameters + ldtx hl, ChooseADeckToDismantleText + call DrawWideTextBox_PrintText +.loop_input + call DoFrame + call Func_8dea + jr c, .init_menu_params + call HandleMenuInput + jp nc, .loop_input ; should be jr + ldh a, [hCurMenuItem] + cp $ff + jr nz, .asm_b76c + call Func_b664 + scf ret -; 0xb3c3 - INCROM $b3c3, $b3e5 +.asm_b76c + ld [wceb1], a + ldtx hl, DismantleThisDeckText + call YesOrNoMenuWithText + jr nc, .dismantle + ld a, [wceb1] + jr .init_menu_params -Func_b3e5: ; b3e5 (2:73e5) - ld a, [wcea1] - ld de, $202 - ld b, $05 -.asm_b3ed - push af +.dismantle + call GetPointerToDeckName + push hl + ld de, wd089 + call EnableSRAM + call CopyListFromHLToDE + pop hl + push hl + ld bc, $18 + add hl, bc + call Func_9152 + pop hl + ld a, $54 + call ClearNBytesFromHL + call DisableSRAM + ld a, $ff + call Func_9168 + ld a, [wceb1] + ld hl, DeckMachineMenuParameters + call InitializeMenuParameters + call DrawCursor2 + call Func_b664 + ld hl, wd089 + call Func_9253 + xor a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + ld hl, $26a + call DrawWideTextBox_WaitForInput + ld a, [wceb1] + ret +; 0xb7c6 + +Func_b7c6: ; b7c6 (2:77c6) + ld a, [wd088] + ld b, a push bc - push de - call Func_b424 - pop de + ld a, $00 + call Func_b625 pop bc - pop af - ret c - dec b - ret z - inc a - inc e - inc e - jr .asm_b3ed -; 0xb3fe + jr nc, .asm_b7f3 + ld a, $ff + call Func_b625 + jr c, .asm_b7ea + ldtx hl, ThisDeckCanOnlyBeBuiltIfYouDismantleText + call DrawWideTextBox_WaitForInput + call Func_b87d + jr nc, .asm_b7f3 -Unknown_b3fe: ; b3fe (2:73fe) - INCROM $b3fe, $b403 +.asm_b7e5 + ld a, [wNamingScreenCursorY] + scf + ret -Func_b403: ; b403 (2:7403) - call Func_b704 - ld hl, hffb0 - ld [hl], $01 - call Func_b3b3 - lb de, 1, 14 - call InitTextPrinting - ld hl, wd0a7 - ld a, [hli] - ld h, [hl] - ld l, a - call ProcessTextFromID - ld hl, hffb0 - ld [hl], $00 - jr Func_b3e5 -; 0xb424 +.asm_b7ea + ldtx hl, YouDoNotOwnAllCardsNeededToBuildThisDeckText + call DrawWideTextBox_WaitForInput + jp Func_b8f4 -Func_b424: ; b424 (2:7424) - ld b, a - push bc - ld hl, wDefaultText - inc a - call ConvertToNumericalDigits - ld [hl], $77 - inc hl - ld [hl], $00 - call InitTextPrinting - ld hl, wDefaultText - call ProcessText - pop af - push af - sla a - ld l, a - ld h, $00 - ld bc, wd00d +.asm_b7f3 + call EnableSRAM + call Func_b644 + call Func_b6a1 + call Func_b664 + call DisableSRAM + jr nc, .asm_b80b + call Func_b738 + jr nc, .asm_b80b + scf + ret + +.asm_b80b + ld [wd08a + $17], a + ld a, [wd088] + ld c, a + ld b, $00 + sla c + ld hl, wd00d add hl, bc ld a, [hli] ld h, [hl] ld l, a - inc d - inc d - inc d - push de - call Func_92be - pop de - pop bc - jr nc, .asm_b46b - call InitTextPrinting - ldtx hl, Text025b - call ProcessTextFromID - ld d, 13 - inc e - call InitTextPrinting - ld hl, Text_b4d4 - call ProcessText - scf - ret + ld de, wc000 + ld b, $54 + call EnableSRAM + call CopyNBytesFromHLToDE -.asm_b46b - push de - push bc - ld d, 18 - call InitTextPrinting - ld a, $00 - call Func_b625 - pop bc - ld hl, wDefaultText - jr c, .asm_b482 - ld de, $35f - jr .asm_b4c2 + ld hl, wc000 + $18 + call Func_b644 + call Func_910a + ld a, [wd08a + $17] + ld l, a + ld h, $54 + call HtimesL + ld bc, sDeck1Name + add hl, bc + ld d, h + ld e, l + ld hl, wc000 + ld b, $54 + call CopyNBytesFromHLToDE + call DisableSRAM -.asm_b482 - push bc ld a, $ff - call Func_b625 - jr c, .asm_b490 - pop bc - ld de, $360 - jr .asm_b4c2 - -.asm_b490 - ld de, $6c - call Func_22ca - pop bc - pop de - push bc - ld d, 17 - inc e - call InitTextPrinting - pop bc - call Func_b4e1 - call CalculateOnesAndTensDigits - ld hl, wOnesAndTensPlace - ld a, [hli] - ld b, a - ld a, [hl] - ld hl, wDefaultText - ld [hl], TX_SYMBOL - inc hl - ld [hli], a - ld [hl], TX_SYMBOL - inc hl - ld a, b - ld [hli], a - ld [hl], TX_END - ld hl, wDefaultText - call ProcessText - or a - ret + call Func_9168 + ld a, [wd08a + $17] + ld [wceb1], a + ld hl, DeckMachineMenuParameters + call InitializeMenuParameters + call DrawCursor2 + call GetPointerToDeckName + call EnableSRAM + call Func_9253 + call DisableSRAM + call Func_b664 -.asm_b4c2 - call Func_22ca - pop de - ld d, 13 - inc e - call InitTextPrinting - ld hl, Text_b4d4 - call ProcessText - or a + xor a + ld [wTxRam2 + 0], a + ld [wTxRam2 + 1], a + ldtx hl, BuiltDeckText + call DrawWideTextBox_WaitForInput + scf ret -; 0xb4d4 - -Text_b4d4: ; b4d4 (2:74d4) - db TX_SYMBOL, TX_END - db TX_SYMBOL, TX_END - db TX_SYMBOL, TX_END - db TX_SYMBOL, TX_END - db TX_SYMBOL, TX_END - db TX_SYMBOL, TX_END - db TX_END -; 0xb4e1 +; 0xb87d -Func_b4e1: ; b4e1 (2:74e1) - push bc +Func_b87d: ; b87d (2:787d) + farcall Func_1ba9a call Func_b644 - call Func_a3ca + call Func_9168 + ldtx hl, DismantleTheseDecksText + call YesOrNoMenuWithText + jr nc, .yes +; no call Func_b664 - pop bc - sla b - ld c, b - ld b, $00 - ld hl, wd00d - add hl, bc - ld a, [hli] - ld h, [hl] + scf + ret + +.yes + call EnableSRAM + ld a, [wd0a6] + bit 0, a + jr z, .asm_b8a3 + ld a, $00 + call .Func_b8db +.asm_b8a3 + ld a, [wd0a6] + bit 1, a + jr z, .asm_b8af + ld a, $01 + call .Func_b8db +.asm_b8af + ld a, [wd0a6] + bit 2, a + jr z, .asm_b8bb + ld a, $02 + call .Func_b8db +.asm_b8bb + ld a, [wd0a6] + bit 3, a + jr z, .asm_b8c7 + ld a, $03 + call .Func_b8db +.asm_b8c7 + call DisableSRAM + ld a, [wd0a6] + call Func_9168 + call Func_b664 + ldtx hl, DismantledTheDeckText + call DrawWideTextBox_WaitForInput + or a + ret + +.Func_b8db ld l, a + ld h, $54 + call HtimesL + ld bc, sDeck1Name + add hl, bc + push hl ld bc, $18 add hl, bc + call Func_9152 + pop hl + ld a, $54 + call ClearNBytesFromHL + ret +; 0xb8f4 + +Func_b8f4: ; b8f4 (2:78f4) + ld a, [wd088] + ld [wceb1], a + call Func_b611 + ld hl, $18 + add hl, de + ld de, wcf17 + ld b, DECK_SIZE call EnableSRAM - ld de, wTempCardCollection - ld bc, $0 -.asm_b505 - inc b - ld a, DECK_SIZE - cp b - jr c, .asm_b520 + call CopyNBytesFromHLToDE + call DisableSRAM + xor a + ld [wcf53], a + call Func_a028 + call Func_a06e + ld a, $ff + call Func_b644 + call Func_a3ca + call Func_b664 + ld hl, wTempHandCardList + ld de, wHandTempList +.asm_b92a ld a, [hli] - push hl - ld l, a - ld h, $00 - add hl, de - ld a, [hl] - and $7f or a - jr z, .asm_b51c - dec a - ld [hl], a - pop hl - jr .asm_b505 -.asm_b51c - inc c + jr z, .asm_b946 + ld b, a + push bc + push de + push hl + ld hl, wcf17 + call Func_b960 pop hl - jr .asm_b505 -.asm_b520 + pop de + pop bc + jr nc, .asm_b92a + ld c, a + ld a, b +.asm_b93f + ld [de], a + inc de + dec c + jr nz, .asm_b93f + jr .asm_b92a +.asm_b946 + xor a + ld [de], a + ldtx bc, TheseCardsAreNeededToBuildThisDeckText + ld hl, wcfda ld a, c - call DisableSRAM - ret -; 0xb525 - - INCROM $b525, $b545 - -Func_b545: ; b545 (2:7545) - INCROM $b545, $b592 + ld [hli], a + ld a, b + ld [hl], a + call Func_b611 + ld h, d + ld l, e + ld de, wHandTempList + call Func_adfe + jp Func_b7c6.asm_b7e5 +; 0xb960 -Func_b592: ; b592 (2:7592) - INCROM $b592, $b611 +Func_b960: ; b960 (2:7960) + call .Func_b976 + ld hl, wc000 + push de + call .Func_b986 + ld a, e + pop de + cp d + jr c, .asm_b971 + or a + ret +.asm_b971 + ld e, a + ld a, d + sub e + scf + ret z -Func_b611: ; b611 (2:7611) +.Func_b976 push af - push hl - ld a, [wd088] - sla a ld e, a ld d, $00 - ld hl, wd00d - add hl, de - ld e, [hl] - inc hl - ld d, [hl] - pop hl +.loop + ld a, [hli] + or a + jr z, .asm_b984 + cp e + jr nz, .loop + inc d + jr .loop +.asm_b984 pop af ret -; 0xb625 - -Func_b625: ; b625 (2:7625) - INCROM $b625, $b644 - -Func_b644: ; b644 (2:7644) - INCROM $b644, $b653 - -Func_b653: ; b653 (2:7653) - INCROM $b653, $b664 -Func_b664: ; b664 (2:7664) +.Func_b986 push af - push bc - ldh a, [hBankSRAM] - ld b, a - ld a, [wd0a4] - cp b - jr z, .asm_b672 - call BankswitchSRAM -.asm_b672 - pop bc + ld e, a + ld d, $00 + add hl, de + ld a, [hl] + and $7f + ld e, a pop af ret -; 0xb675 +; 0xb991 - INCROM $b675, $b6ca - -Func_b6ca: ; b6ca (2:76ca) - INCROM $b6ca, $b6fb +PrinterMenu_DeckConfiguration: ; b991 (2:7991) + xor a + ld [wcea1], a + call Func_b379 + ld a, DECK_SIZE + ld [wd0a5], a -Data_b6fb: ; b6fb (2:76fb) - db $01, $02, $02, $00, $05, $0f, $00, $00, $00 + xor a +.asm_b99e + ld hl, Data_b6fb + call Func_9a6d + call Func_b704 + call Func_b545 + ld hl, WaitForVBlank.lcd_off + call DrawWideTextBox_PrintText + ld de, WaitForVBlank.lcd_off + call Func_b285 +.asm_b9b6 + call Func_b29f + jr c, .asm_b99e + cp $ff + ret z -Func_b704: ; b704 (2:7704) - INCROM $b704, $b7c6 + ld b, a + ld a, [wcea1] + add b + ld [wd088], a + call Func_b35b + jr c, .asm_b9b6 + call DrawWideTextBox + ldtx hl, PrintThisDeckText + call YesOrNoMenuWithText + jr c, .no + call Func_b611 + ld hl, $18 + add hl, de + ld de, wcf17 + ld b, DECK_SIZE + call EnableSRAM + call CopyNBytesFromHLToDE + call DisableSRAM + xor a + ld [wcf53], a + call Func_a028 + ld a, [wd088] + bank1call Func_7580 + call Func_b379 -Func_b7c6: ; b7c6 (2:77c6) - INCROM $b7c6, $ba04 +.no + ld a, [wd086] + ld [wNamingScreenCursorY], a + jp .asm_b99e +; 0xba04 Func_ba04: ; ba04 (2:7a04) ld a, [wd0a9] @@ -5771,13 +9116,13 @@ Func_ba04: ; ba04 (2:7a04) ; fallthrough Func_ba25: ; ba25 (2:7a25) - ld hl, Func_bb6e + ld hl, .MenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText ld a, $5 ld [wNamingScreenKeyboardHeight], a - ld hl, Unknown_b3fe + ld hl, Func_b3fe ld d, h ld a, l ld hl, wcece @@ -5934,11 +9279,20 @@ Func_ba25: ; ba25 (2:7a25) ld a, [wd086] jp Func_ba25 -Func_bb6e: ; bb6e (2:7b6e) - INCROM $bb6e, $bb76 +.MenuParameters + db 1, 2 ; cursor x, cursor y + db 2 ; y displacement between items + db 5 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw NULL ; function pointer if non-0 +; 0xbb76 Data_bb76: ; bb76 (2:7b76) - INCROM $bb76, $bb83 + textitem 2, 14, BuildADeckText + textitem 12, 14, CancelText + textitem 2, 16, ReadTheInstructionsText + db $ff Data_bb83: ; bb83 (2:7b83) tx FightingMachineText @@ -5953,7 +9307,59 @@ Data_bb83: ; bb83 (2:7b83) tx LegendaryMachineText Func_bb97: ; bb97 (2:7b97) - INCROM $bb97, $bc04 + call Set_OBJ_8x8 + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + call EmptyScreen + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call LoadSymbolsFont + call LoadDuelCardSymbolTiles + bank1call SetDefaultPalettes + lb de, $3c, $ff + call SetupText + lb de, 0, 0 + lb bc, 20, 13 + call DrawRegularTextBox + ld de, $100 + call InitTextPrinting + ld hl, wd0a2 + ld a, [hli] + ld h, [hl] + ld l, a + call ProcessTextFromID + call Func_b653 + farcall Func_1ba14 + call Func_bbe4 + call Func_b3e5 + call Func_b644 + call EnableLCD + ret +; 0xbbe4 + +Func_bbe4: ; bbe4 (2:7be4) + ld a, $0a + ld hl, wd00d + call ClearNBytesFromHL + ld de, wd00d + ld hl, s0a350 + ld bc, $54 + ld a, $05 +.loop + push af + ld a, l + ld [de], a + inc de + ld a, h + ld [de], a + inc de + add hl, bc + pop af + dec a + jr nz, .loop + ret +; 0xbc04 Func_bc04: ; bc04 (2:7c04) xor a diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index d2065ae..fa60650 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1272,7 +1272,7 @@ Func_c877: ; c877 (3:4877) ldh [hSCY], a call Set_OBJ_8x16 farcall Func_1288c - farcall Func_ad51 + farcall HandlePrinterMenu call Set_OBJ_8x8 call WhiteOutDMGPals call DoFrameIfLCDEnabled diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index a03f631..c52a4a4 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -2087,8 +2087,8 @@ Func_1996e: ; 1996e (6:596e) add hl, de dec c jr nz, .asm_199b2 - ld a, $2 - ld [s0a003], a + ld a, 2 + ld [sPrinterContrastLevel], a ld a, $2 ld [sTextSpeed], a ld [wTextSpeed], a @@ -2673,6 +2673,7 @@ CalculateNameHash: ; 19e32 (6:5e32) ret ; 0x19e42 +Func_19e42: ; 19e42 (6:5e42) INCROM $19e42, $19e5a ; shows message on screen depending on wPrinterStatus @@ -2955,7 +2956,7 @@ Func_1a035: ; 1a035 (6:6035) ld a, $10 ld [wce9b], a call EnableSRAM - ld a, [s0a003] + ld a, [sPrinterContrastLevel] ld [wce99], a call DisableSRAM ldh a, [hBankSRAM] @@ -3140,7 +3141,13 @@ Func_1a138: ; 1a138 (6:6138) db $00, $20, $40, $60, $7f ; 0x1a14b - INCROM $1a14b, $1a435 + INCROM $1a14b, $1a162 + +Func_1a162: ; 1a162 (6:6162) + INCROM $1a162, $1a270 + +Func_1a270: ; 1a270 (6:6270) + INCROM $1a270, $1a435 ; compresses $28 tiles in sGfxBuffer5 ; and writes it in sGfxBuffer5 + $28 tiles. @@ -4917,11 +4924,9 @@ KeyboardData_Deck: ; 1b019 (6:7019) ; unknown data. ; needs analyze. ; (6:70d6) - INCROM $1b0d6, $1ba12 + INCROM $1b0d6, $1ba14 -Func_1ba12: ; 1ba12 (6:7a12) - push af - ld [bc], a +Func_1ba14: ; 1ba14 (6:7a14) call EnableSRAM ld a, [wd0a9] ld l, a diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 1c68fb5..e7eb5e5 100644 --- a/src/engine/bank1c.asm +++ b/src/engine/bank1c.asm @@ -430,7 +430,7 @@ ENDM border_medal_tile v0Tiles1 + $23a, $6a, $10 border_medal_tile v0Tiles1 + $23c, $6b, $10 -; FIGHTING_MEDAL +; PSYCHIC_MEDAL border_medal_tile v0Tiles1 + $2b8, $7e, $10 border_medal_tile v0Tiles1 + $2ba, $7f, $10 border_medal_tile v0Tiles1 + $2bc, $80, $10 @@ -452,7 +452,7 @@ ENDM border_medal_tile v0Tiles1 + $43a, $7c, $10 border_medal_tile v0Tiles1 + $43c, $7d, $10 -; PSYCHIC_MEDAL +; FIGHTING_MEDAL border_medal_tile v0Tiles1 + $4b8, $6c, $10 border_medal_tile v0Tiles1 + $4ba, $6d, $10 border_medal_tile v0Tiles1 + $4bc, $6e, $10 diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index b8b4914..e999242 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -6660,7 +6660,7 @@ Peek_SelectEffect: ; 2e2b4 (b:62b4) call SwapTurn ldh a, [hAIPkmnPowerEffectParam] xor $80 - call Func_30f9 + call DrawAIPeekScreen call SwapTurn ldtx hl, CardPeekWasUsedOnText call DrawWideTextBox_WaitForInput diff --git a/src/engine/home.asm b/src/engine/home.asm index b848287..05a5cdc 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9315,34 +9315,35 @@ Func_30e7: ; 30e7 (0:30e7) ld a, b ret -Func_30f9: ; 30f9 (0:30f9) +DrawAIPeekScreen: ; 30f9 (0:30f9) ld b, a ldh a, [hBankROM] push af - ld a, BANK(Func_8932) + ld a, BANK(_DrawAIPeekScreen) call BankswitchROM - call Func_8932 + call _DrawAIPeekScreen pop af call BankswitchROM ret -Func_310a: ; 310a (0:310a) - ld [wce59], a +; a = number of prize cards for player to select to take +SelectPrizeCards: ; 310a (0:310a) + ld [wNumberOfPrizeCardsToSelect], a ldh a, [hBankROM] push af - ld a, BANK(Func_8aaa) + ld a, BANK(_SelectPrizeCards) call BankswitchROM - call Func_8aaa + call _SelectPrizeCards pop af call BankswitchROM ret -Func_311d: ; 311d (0:311d) +DrawPlayAreaToPlacePrizeCards: ; 311d (0:311d) ldh a, [hBankROM] push af - ld a, BANK(Func_8b85) + ld a, BANK(_DrawPlayAreaToPlacePrizeCards) call BankswitchROM - call Func_8b85 + call _DrawPlayAreaToPlacePrizeCards pop af call BankswitchROM ret diff --git a/src/hram.asm b/src/hram.asm index fee69a9..6877f9c 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -171,6 +171,7 @@ hCurSelectionItem:: ; ffb2 hffb3:: ; ffb3 ds $1 +hffb4:: ; ffb4 ds $1 hffb5:: ; ffb5 diff --git a/src/sram.asm b/src/sram.asm index 481c8e4..cb8d7d2 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -3,7 +3,9 @@ SECTION "SRAM0", SRAM s0a000:: ; a000 ds $3 -s0a003:: ; a003 +; what was the last option selected by the player +; for the printer contrast level (0 ~ 4) +sPrinterContrastLevel:: ; a003 ds $1 s0a004:: ; a004 ds $1 diff --git a/src/text/text2.asm b/src/text/text2.asm index 0e0c083..1cba1e0 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1607,15 +1607,15 @@ PleaseSelectDeckText: ; 3ba0d (e:7a0d) text "Please select deck." done -Text0225: ; 3ba22 (e:7a22) +ModifyDeckText: ; 3ba22 (e:7a22) text "Modify deck" done -Text0226: ; 3ba2f (e:7a2f) +ChangeNameText: ; 3ba2f (e:7a2f) text "Change name" done -Text0227: ; 3ba3c (e:7a3c) +SelectDeckText: ; 3ba3c (e:7a3c) text "Select deck" done @@ -1771,7 +1771,7 @@ WhichCardWouldYouLikeToSeeText: ; 3bce5 (e:7ce5) text "Which card would you like to see?" done -Text024d: ; 3bd08 (e:7d08) +PleaseChooseAPrizeText: ; 3bd08 (e:7d08) text "Please choose a Prize." done @@ -1792,31 +1792,31 @@ EmptyLineText: ; 3bd42 (e:7d42) textfw0 " ", " ", " ", " ", " ", " ", " ", " ", " " done -Text0252: ; 3bd55 (e:7d55) +BoosterPackTitleText: ; 3bd55 (e:7d55) text "Booster Pack" done -Text0253: ; 3bd63 (e:7d63) +Item1ColosseumText: ; 3bd63 (e:7d63) text "1. Colosseum" done -Text0254: ; 3bd71 (e:7d71) +Item2EvolutionText: ; 3bd71 (e:7d71) text "2. Evolution" done -Text0255: ; 3bd7f (e:7d7f) +Item3MysteryText: ; 3bd7f (e:7d7f) text "3. Mystery" done -Text0256: ; 3bd8b (e:7d8b) +Item4LaboratoryText: ; 3bd8b (e:7d8b) text "4. Laboratory" done -Text0257: ; 3bd9a (e:7d9a) +Item5PromotionalCardText: ; 3bd9a (e:7d9a) text "5. Promotional Card" done -Text0258: ; 3bdaf (e:7daf) +ViewWhichCardFileText: ; 3bdaf (e:7daf) text "View which Card File?" done @@ -1824,7 +1824,7 @@ Text0259: ; 3bdc6 (e:7dc6) textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" done -Text025a: ; 3bdd1 (e:7dd1) +SCardsText: ; 3bdd1 (e:7dd1) text "'s Cards" done @@ -1836,19 +1836,19 @@ DeckSaveMachineText: ; 3bdea (e:7dea) text " Deck Save Machine " done -Text025d: ; 3be02 (e:7e02) +SaveADeckText: ; 3be02 (e:7e02) text "Save a Deck" done -Text025e: ; 3be0f (e:7e0f) +DeleteADeckText: ; 3be0f (e:7e0f) text "Delete a Deck" done -Text025f: ; 3be1e (e:7e1e) +BuildADeckText: ; 3be1e (e:7e1e) text "Build a Deck" done -Text0260: ; 3be2c (e:7e2c) +ChooseADeckToSaveText: ; 3be2c (e:7e2c) text "Choose a Deck to Save." done @@ -1861,7 +1861,7 @@ Text0262: ; 3be7d (e:7e7d) text "for" done -Text0263: ; 3be82 (e:7e82) +SavedTheConfigurationForText: ; 3be82 (e:7e82) text "Saved the configuration for" line "" text "! " @@ -1876,21 +1876,21 @@ Text0265: ; 3beb7 (e:7eb7) line "configuration to delete." done -Text0266: ; 3bee7 (e:7ee7) +DoYouReallyWishToDeleteText: ; 3bee7 (e:7ee7) text "Do you really wish to delete?" done -Text0267: ; 3bf06 (e:7f06) +DeletedTheConfigurationForText: ; 3bf06 (e:7f06) text "Deleted the configuration for" line "" text "." done -Text0268: ; 3bf29 (e:7f29) +YouMayOnlyCarry4DecksText: ; 3bf29 (e:7f29) text "You may only carry 4 Decks!" done -Text0269: ; 3bf46 (e:7f46) +ChooseADeckToDismantleText: ; 3bf46 (e:7f46) text "Choose a deck to dismantle." done @@ -1905,7 +1905,7 @@ Text026b: ; 3bf73 (e:7f73) line "you wish to Build." done -Text026c: ; 3bf9e (e:7f9e) +ThisDeckCanOnlyBeBuiltIfYouDismantleText: ; 3bf9e (e:7f9e) text "This Deck can only be built if" line "you dismantle another Deck." done diff --git a/src/text/text3.asm b/src/text/text3.asm index 3d32c15..bf23e60 100644 --- a/src/text/text3.asm +++ b/src/text/text3.asm @@ -1,23 +1,23 @@ -Text026d: ; 3c000 (f:4000) +YouDoNotOwnAllCardsNeededToBuildThisDeckText: ; 3c000 (f:4000) text "You do not own all cards needed" line "to build this Deck." done -Text026e: ; 3c035 (f:4035) +BuiltDeckText: ; 3c035 (f:4035) text "Built" line "" done -Text026f: ; 3c03e (f:403e) +TheseCardsAreNeededToBuildThisDeckText: ; 3c03e (f:403e) text "These cards are needed" line "to build this Deck:" done -Text0270: ; 3c06a (f:406a) +DismantleTheseDecksText: ; 3c06a (f:406a) text "Dismantle these Decks?" done -Text0271: ; 3c082 (f:4082) +DismantledTheDeckText: ; 3c082 (f:4082) text "Dismantled the Deck." done @@ -25,11 +25,11 @@ OKIfFileDeletedText: ; 3c098 (f:4098) text "OK if this file is deleted?" done -Text0273: ; 3c0b5 (f:40b5) +ReadTheInstructionsText: ; 3c0b5 (f:40b5) text "Read the Instructions" done -Text0274: ; 3c0cc (f:40cc) +PrintThisCardYesNoText: ; 3c0cc (f:40cc) text "Print this card?" line " Yes No" done @@ -39,7 +39,7 @@ Text0275: ; 3c0ef (f:40ef) line "to print." done -Text0276: ; 3c11d (f:411d) +PrintThisDeckText: ; 3c11d (f:411d) text "Print this Deck?" done @@ -48,7 +48,7 @@ Text0277: ; 3c12f (f:412f) line " Yes No" done -Text0278: ; 3c156 (f:4156) +PrintMenuItemsText: ; 3c156 (f:4156) text "Pokémon Cards" line "Deck Configuration" line "Card List" @@ -56,16 +56,16 @@ Text0278: ; 3c156 (f:4156) line "Quit Print" done -Text0279: ; 3c19b (f:419b) +WhatWouldYouLikeToPrintText: ; 3c19b (f:419b) text "What would you like to print?" done -Text027a: ; 3c1ba (f:41ba) +PleaseSetTheContrastText: ; 3c1ba (f:41ba) text "Please set the contrast:" line " Light 1 2 3 4 5 Dark" done -Text027b: ; 3c1f7 (f:41f7) +PleaseMakeSureToTurnGameBoyPrinterOffText: ; 3c1f7 (f:41f7) text "Please make sure to turn" line "the Game Boy Printer OFF." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index b8a1dbf..02d028b 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -550,9 +550,9 @@ TextOffsets:: ; 34000 (d:4000) textpointer DeckNameKeyboardText ; 0x0222 textpointer NewDeckText ; 0x0223 textpointer PleaseSelectDeckText ; 0x0224 - textpointer Text0225 ; 0x0225 - textpointer Text0226 ; 0x0226 - textpointer Text0227 ; 0x0227 + textpointer ModifyDeckText ; 0x0225 + textpointer ChangeNameText ; 0x0226 + textpointer SelectDeckText ; 0x0227 textpointer CancelText ; 0x0228 textpointer Text0229 ; 0x0229 textpointer ChosenAsDuelingDeckText ; 0x022a @@ -590,53 +590,53 @@ TextOffsets:: ; 34000 (d:4000) textpointer InPlayAreaText ; 0x024a textpointer GlossaryText ; 0x024b textpointer WhichCardWouldYouLikeToSeeText ; 0x024c - textpointer Text024d ; 0x024d + textpointer PleaseChooseAPrizeText ; 0x024d textpointer HandText_2 ; 0x024e textpointer DuelistHandText_2 ; 0x024f textpointer DuelistDiscardPileText ; 0x0250 textpointer EmptyLineText ; 0x0251 - textpointer Text0252 ; 0x0252 - textpointer Text0253 ; 0x0253 - textpointer Text0254 ; 0x0254 - textpointer Text0255 ; 0x0255 - textpointer Text0256 ; 0x0256 - textpointer Text0257 ; 0x0257 - textpointer Text0258 ; 0x0258 + textpointer BoosterPackTitleText ; 0x0252 + textpointer Item1ColosseumText ; 0x0253 + textpointer Item2EvolutionText ; 0x0254 + textpointer Item3MysteryText ; 0x0255 + textpointer Item4LaboratoryText ; 0x0256 + textpointer Item5PromotionalCardText ; 0x0257 + textpointer ViewWhichCardFileText ; 0x0258 textpointer Text0259 ; 0x0259 - textpointer Text025a ; 0x025a + textpointer SCardsText ; 0x025a textpointer Text025b ; 0x025b textpointer DeckSaveMachineText ; 0x025c - textpointer Text025d ; 0x025d - textpointer Text025e ; 0x025e - textpointer Text025f ; 0x025f - textpointer Text0260 ; 0x0260 + textpointer SaveADeckText ; 0x025d + textpointer DeleteADeckText ; 0x025e + textpointer BuildADeckText ; 0x025f + textpointer ChooseADeckToSaveText ; 0x0260 textpointer Text0261 ; 0x0261 textpointer Text0262 ; 0x0262 - textpointer Text0263 ; 0x0263 + textpointer SavedTheConfigurationForText ; 0x0263 textpointer Text0264 ; 0x0264 textpointer Text0265 ; 0x0265 - textpointer Text0266 ; 0x0266 - textpointer Text0267 ; 0x0267 - textpointer Text0268 ; 0x0268 - textpointer Text0269 ; 0x0269 + textpointer DoYouReallyWishToDeleteText ; 0x0266 + textpointer DeletedTheConfigurationForText ; 0x0267 + textpointer YouMayOnlyCarry4DecksText ; 0x0268 + textpointer ChooseADeckToDismantleText ; 0x0269 textpointer Text026a ; 0x026a textpointer Text026b ; 0x026b - textpointer Text026c ; 0x026c - textpointer Text026d ; 0x026d - textpointer Text026e ; 0x026e - textpointer Text026f ; 0x026f - textpointer Text0270 ; 0x0270 - textpointer Text0271 ; 0x0271 + textpointer ThisDeckCanOnlyBeBuiltIfYouDismantleText ; 0x026c + textpointer YouDoNotOwnAllCardsNeededToBuildThisDeckText ; 0x026d + textpointer BuiltDeckText ; 0x026e + textpointer TheseCardsAreNeededToBuildThisDeckText ; 0x026f + textpointer DismantleTheseDecksText ; 0x0270 + textpointer DismantledTheDeckText ; 0x0271 textpointer OKIfFileDeletedText ; 0x0272 - textpointer Text0273 ; 0x0273 - textpointer Text0274 ; 0x0274 + textpointer ReadTheInstructionsText ; 0x0273 + textpointer PrintThisCardYesNoText ; 0x0274 textpointer Text0275 ; 0x0275 - textpointer Text0276 ; 0x0276 + textpointer PrintThisDeckText ; 0x0276 textpointer Text0277 ; 0x0277 - textpointer Text0278 ; 0x0278 - textpointer Text0279 ; 0x0279 - textpointer Text027a ; 0x027a - textpointer Text027b ; 0x027b + textpointer PrintMenuItemsText ; 0x0278 + textpointer WhatWouldYouLikeToPrintText ; 0x0279 + textpointer PleaseSetTheContrastText ; 0x027a + textpointer PleaseMakeSureToTurnGameBoyPrinterOffText ; 0x027b textpointer ProceduresForSendingCardsText ; 0x027c textpointer CardSendingProceduresText ; 0x027d textpointer PleaseReadTheProceduresForSendingCardsText ; 0x027e diff --git a/src/wram.asm b/src/wram.asm index 75e1e66..f1b740d 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1740,9 +1740,14 @@ wInPlayAreaPreservedPosition:: ; ce57 wInPlayAreaTemporaryPosition:: ; ce58 ds $1 -wce59:: ; ce59 +; number of prize cards still to be +; picked by the player +wNumberOfPrizeCardsToSelect:: ; ce59 ds $1 +; pointer to a $ff-terminated list +; of the prize cards selected by the player +wSelectedPrizeCardListPtr:: ; ce5a ds $2 wce5c:: ; ce5c @@ -1917,7 +1922,13 @@ wceaa:: ; ceaa ds $1 wceab:: ; ceab - ds $4 + ds $1 + +wceac:: ; ceac + ds $2 + +wceae:: ; ceae + ds $1 wCheckMenuCursorXPosition:: ; ceaf ds $1 @@ -1974,7 +1985,9 @@ wced0:: ; ced0 wced2:: ; ced2 ds $1 -wced3:: ; ced3 +; the current filter being used +; from the CardTypeFilters list +wCurCardTypeFilter:: ; ced3 ds $1 wced4:: ; ced4 @@ -2012,7 +2025,10 @@ wcf16:: ; cf16 wcf17:: ; cf17 ds DECK_SIZE - ds $15 +wcf53:: ; cf53 + ds $1 + + ds $14 ; stores the count number of cards owned ; can be 0 in the case that a card is not available @@ -2049,14 +2065,27 @@ wCursorAlternateTile:: ; cfde wcfdf:: ; cfdf ds $1 - ds $3 +wcfe0:: ; cfe0 + ds $1 + +wcfe1:: ; cfe1 + ds $1 + +wcfe2:: ; cfe2 + ds $1 ; a flag indicating whether sfx should be played. wPlaysSfx:: ; cfe3 ds $1 wcfe4:: ; cfe4 - ds $3 + ds $1 + +wcfe5:: ; cfe5 + ds $1 + +wcfe6:: ; cfe6 + ds $1 ; a name buffer in the naming screen. wNamingScreenBuffer:: ; cfe7 @@ -2092,9 +2121,12 @@ wd009:: ; d009 ds $4 wd00d:: ; d00d - ds $1 + ds $18 - ds $78 + ds $60 + +wd085:: ; d085 + ds $1 wd086:: ; d086 ds $1 -- cgit v1.2.3 From e979d9106a5d507f99ee9108c26c9798d6f1fd26 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 17 Apr 2021 11:07:24 +0100 Subject: Document HandlePeekSelection --- src/constants/duel_constants.asm | 12 +- src/engine/bank02.asm | 262 ++++++++++++++++++++------------------- src/engine/bank06.asm | 2 +- src/engine/effect_functions.asm | 2 +- src/engine/home.asm | 6 +- src/wram.asm | 12 +- 6 files changed, 156 insertions(+), 140 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index fe21753..89377dc 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -257,12 +257,12 @@ EFFECT_FAILED_UNSUCCESSFUL EQU $02 ; wAnimationQueue length ANIMATION_QUEUE_LENGTH EQU 7 -PRIZES_1 EQU $01 -PRIZES_2 EQU $02 -PRIZES_3 EQU $03 -PRIZES_4 EQU $04 -PRIZES_5 EQU $05 -PRIZES_6 EQU $06 +PRIZES_1 EQU $01 +PRIZES_2 EQU $02 +PRIZES_3 EQU $03 +PRIZES_4 EQU $04 +PRIZES_5 EQU $05 +PRIZES_6 EQU $06 ; constants to use as input to LookForCardInDeck SEARCHEFFECT_CARD_ID EQU $0 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 05a79d7..26a4ba4 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1367,20 +1367,20 @@ DrawCheckMenuCursor_YourOrOppPlayArea: ; 8743 (2:4743) call WriteByteToBGMap0 or a ret +; 0x8760 DisplayCheckMenuCursor_YourOrOppPlayArea: ; 8760 (2:4760) ld a, SYM_CURSOR_R ; load cursor byte jr DrawCheckMenuCursor_YourOrOppPlayArea -; seems to be function to deal with the Peek menu -; to select a prize card to view -Func_8764: ; 8764 (2:4764) +; handles Peek Pkmn Power selection menus +_HandlePeekSelection: ; 8764 (2:4764) call Set_OBJ_8x8 call LoadCursorTile -; reset ce5c and ce56 +; reset ce5c and wIsSwapTurnPending xor a ld [wce5c], a - ld [wce56], a + ld [wIsSwapTurnPending], a ; draw play area screen for the turn player ldh a, [hWhoseTurn] @@ -1388,51 +1388,51 @@ Func_8764: ; 8764 (2:4764) ld l, a call DrawYourOrOppPlayAreaScreen -.swap - ld a, [wce56] +.check_swap + ld a, [wIsSwapTurnPending] or a - jr z, .draw_menu -; if ce56 != 0, swap turn + jr z, .draw_menu_1 +; if wIsSwapTurnPending is TRUE, swap turn call SwapTurn xor a - ld [wce56], a + ld [wIsSwapTurnPending], a -.draw_menu +; prompt player to choose either own Play Area or opponent's +.draw_menu_1 xor a - ld hl, PlayAreaMenuParameters + ld hl, .PlayAreaMenuParameters call InitializeMenuParameters call DrawWideTextBox - - ld hl, YourOrOppPlayAreaData + ld hl, .YourOrOppPlayAreaData call PlaceTextItems -.loop_1 +.loop_input_1 call DoFrame - call HandleMenuInput ; await input - jr nc, .loop_1 - cp $ff - jr z, .loop_1 + call HandleMenuInput + jr nc, .loop_input_1 + cp -1 + jr z, .loop_input_1 ; can't use B btn call EraseCursor ldh a, [hCurMenuItem] or a - jp nz, Func_8883 ; jump if not first option + jp nz, .PrepareYourPlayAreaSelection ; jump if not Opp Play Area -; hCurMenuItem = 0 +; own Play Area was chosen ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a ldh a, [hWhoseTurn] cp b - jr z, .text + jr z, .text_1 ; switch the play area to draw ld h, a ld l, a call DrawYourOrOppPlayAreaScreen xor a - ld [wce56], a + ld [wIsSwapTurnPending], a -.text +.text_1 call DrawWideTextBox lb de, 1, 14 call InitTextPrinting @@ -1440,43 +1440,43 @@ Func_8764: ; 8764 (2:4764) call ProcessTextFromID xor a - ld [wPrizeCardCursorPosition], a - ld de, Func_8764_TransitionTable - ld hl, wce53 + ld [wYourOrOppPlayAreaCurPosition], a + ld de, PeekYourPlayAreaTransitionTable + ld hl, wTransitionTablePtr ld [hl], e inc hl ld [hl], d -.loop_2 +.loop_input_2 ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame - call Func_89ae - jr c, .asm_87e7 - jr .loop_2 -.asm_87e7 - cp $ff - jr nz, .asm_87f0 + call YourOrOppPlayAreaScreen_HandleInput + jr c, .selection_cancelled + jr .loop_input_2 +.selection_cancelled + cp -1 + jr nz, .selection_made call ZeroObjectPositionsWithCopyToggleOn - jr .swap -.asm_87f0 - ld hl, .asm_87f8 + jr .check_swap +.selection_made + ld hl, .SelectionFunctionTable call JumpToFunctionInTable - jr .loop_2 + jr .loop_input_2 -.asm_87f8 +.SelectionFunctionTable rept 6 - dw Func_8819 + dw .SelectedPrize endr - dw Func_883c - dw Func_8849 + dw .SelectedOppsHand + dw .SelectedDeck -YourOrOppPlayAreaData: ; 8808 (2:4808) +.YourOrOppPlayAreaData ; 8808 (2:4808) textitem 2, 14, YourPlayAreaText textitem 2, 16, OppPlayAreaText db $ff -PlayAreaMenuParameters: ; 8811 (2:4811) +.PlayAreaMenuParameters ; 8811 (2:4811) db 1, 14 ; cursor x, cursor y db 2 ; y displacement between items db 2 ; number of items @@ -1484,21 +1484,21 @@ PlayAreaMenuParameters: ; 8811 (2:4811) db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -Func_8819: ; 8819 (2:4819) - ld a, [wPrizeCardCursorPosition] +.SelectedPrize: ; 8819 (2:4819) + ld a, [wYourOrOppPlayAreaCurPosition] ld c, a ld b, $01 ; left-shift b a number of times ; corresponding to this prize card -.loop +.loop_prize_bitmask or a - jr z, .asm_8827 + jr z, .got_prize_bitmask sla b dec a - jr .loop + jr .loop_prize_bitmask -.asm_8827 +.got_prize_bitmask ld a, DUELVARS_PRIZES call GetTurnDuelistVariable and b @@ -1510,17 +1510,17 @@ Func_8819: ; 8819 (2:4819) ld a, c add DUELVARS_PRIZE_CARDS call GetTurnDuelistVariable - jr Func_8855 + jr .ShowSelectedCard -Func_883c: ; 883c (2:483c) +.SelectedOppsHand ; 883c (2:483c) call CreateHandCardList ret c ld hl, wDuelTempList call ShuffleCards ld a, [hl] - jr Func_8855 + jr .ShowSelectedCard -Func_8849: ; 8849 (2:4849) +.SelectedDeck ; 8849 (2:4849) call CreateDeckCardList ret c ld a, %01111111 @@ -1533,11 +1533,12 @@ Func_8849: ; 8849 (2:4849) ; output: ; a = ce5c ; with upper bit set if turn was swapped -Func_8855: ; 8855 (2:4855) +.ShowSelectedCard ; 8855 (2:4855) ld b, a ld a, [wce5c] or a jr nz, .display + ; if wce5c is not set, set it as input deck index ld a, b ld [wce5c], a .display @@ -1549,8 +1550,8 @@ Func_8855: ; 8855 (2:4855) ld [wVBlankOAMCopyToggle], a pop af -; if ce56 != 0, swap turn - ld a, [wce56] +; if wIsSwapTurnPending is TRUE, swap turn + ld a, [wIsSwapTurnPending] or a jr z, .dont_swap call SwapTurn @@ -1561,26 +1562,28 @@ Func_8855: ; 8855 (2:4855) ld a, [wce5c] ret -Func_8883: ; 8883 (2:4883) +; prepare menu parameters to handle selection +; of player's own Play Area +.PrepareYourPlayAreaSelection: ; 8883 (2:4883) ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a ldh a, [hWhoseTurn] cp b - jr nz, .text + jr nz, .text_2 ld l, a cp PLAYER_TURN jr nz, .opponent ld a, OPPONENT_TURN - jr .draw + jr .draw_menu_2 .opponent ld a, PLAYER_TURN -.draw +.draw_menu_2 ld h, a call DrawYourOrOppPlayAreaScreen -.text +.text_2 call DrawWideTextBox lb de, 1, 14 call InitTextPrinting @@ -1588,19 +1591,19 @@ Func_8883: ; 8883 (2:4883) call ProcessTextFromID xor a - ld [wPrizeCardCursorPosition], a - ld de, Func_8883_TransitionTable - ld hl, wce53 + ld [wYourOrOppPlayAreaCurPosition], a + ld de, PeekOppPlayAreaTransitionTable + ld hl, wTransitionTablePtr ld [hl], e inc hl ld [hl], d call SwapTurn - ld a, $01 - ld [wce56], a - jp Func_8764.loop_2 + ld a, TRUE + ld [wIsSwapTurnPending], a ; mark pending to swap turn + jp .loop_input_2 -Func_8764_TransitionTable: ; 88c2 (2:48c2) +PeekYourPlayAreaTransitionTable: ; 88c2 (2:48c2) cursor_transition $08, $28, $00, $04, $02, $01, $07 cursor_transition $30, $28, $20, $05, $03, $07, $00 cursor_transition $08, $38, $00, $00, $04, $03, $07 @@ -1610,7 +1613,7 @@ Func_8764_TransitionTable: ; 88c2 (2:48c2) cursor_transition $78, $50, $00, $07, $07, $00, $01 cursor_transition $78, $28, $00, $07, $07, $00, $01 -Func_8883_TransitionTable: ; 88fa (2:48fa) +PeekOppPlayAreaTransitionTable: ; 88fa (2:48fa) cursor_transition $a0, $60, $20, $02, $04, $07, $01 cursor_transition $78, $60, $00, $03, $05, $00, $07 cursor_transition $a0, $50, $20, $04, $00, $06, $03 @@ -1625,20 +1628,20 @@ _DrawAIPeekScreen: ; 8932 (2:4932) call Set_OBJ_8x8 call LoadCursorTile xor a - ld [wce56], a + ld [wIsSwapTurnPending], a ldh a, [hWhoseTurn] ld l, a - ld de, Func_8764_TransitionTable + ld de, PeekYourPlayAreaTransitionTable pop bc bit AI_PEEK_TARGET_HAND_F, b jr z, .draw_play_area ; AI chose the hand call SwapTurn - ld a, $01 - ld [wce56], a + ld a, TRUE + ld [wIsSwapTurnPending], a ; mark pending to swap turn ldh a, [hWhoseTurn] - ld de, Func_8883_TransitionTable + ld de, PeekOppPlayAreaTransitionTable .draw_play_area ld h, a push bc @@ -1660,23 +1663,23 @@ _DrawAIPeekScreen: ; 8932 (2:4932) jr nz, .prize_card ; cursor on the deck ld a, $7 - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a jr .got_cursor_position .prize_card bit AI_PEEK_TARGET_PRIZE_F, a jr z, .hand and $3f - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a jr .got_cursor_position .hand ld a, $6 - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a .got_cursor_position - call Func_89ae.draw_cursor + call YourOrOppPlayAreaScreen_HandleInput.draw_cursor ld a, $1 ld [wVBlankOAMCopyToggle], a - ld a, [wce56] + ld a, [wIsSwapTurnPending] or a ret z call SwapTurn @@ -1694,24 +1697,26 @@ LoadCursorTile: ; 8992 (2:4992) db $e0, $c0, $98, $b0, $84, $8c, $83, $82 db $86, $8f, $9d, $be, $f4, $f8, $50, $60 -; similar to OpenInPlayAreaScreen_HandleInput -Func_89ae: ; 89ae (2:49ae) +; handles input inside the "Your Play Area" or "Opp Play Area" screens +; returns carry if either A or B button were pressed +; returns -1 in a if B button was pressed +YourOrOppPlayAreaScreen_HandleInput: ; 89ae (2:49ae) xor a ld [wPlaysSfx], a - ld hl, wce53 +; get the transition data for the prize card with cursor + ld hl, wTransitionTablePtr ld e, [hl] inc hl ld d, [hl] - - ld a, [wPrizeCardCursorPosition] + ld a, [wYourOrOppPlayAreaCurPosition] ld [wPrizeCardCursorTemporaryPosition], a ld l, a - ld h, 7 + ld h, 7 ; length of each transition table item call HtimesL add hl, de -; hl = [wce53] + 7 * wce52 +; get the transition index related to the directional input ldh a, [hDPadHeld] or a jp z, .check_button @@ -1752,8 +1757,8 @@ Func_89ae: ; 89ae (2:49ae) ; left ld a, [hl] .process_dpad - ld [wPrizeCardCursorPosition], a - cp $08 ; if a >= 0x8 + ld [wYourOrOppPlayAreaCurPosition], a + cp $8 ; if a >= 0x8 jr nc, .next ld b, $01 @@ -1776,7 +1781,7 @@ Func_89ae: ; 89ae (2:49ae) ; when no cards exist at the cursor, ld a, [wPrizeCardCursorTemporaryPosition] cp $06 - jr nz, Func_89ae + jr nz, YourOrOppPlayAreaScreen_HandleInput ; move once more in the direction (recursively) until it reaches an existing item. ; check if one of the dpad, left or right, is pressed. @@ -1785,33 +1790,40 @@ Func_89ae: ; 89ae (2:49ae) bit D_RIGHT_F, a jr nz, .left_or_right bit D_LEFT_F, a - jr z, Func_89ae + jr z, YourOrOppPlayAreaScreen_HandleInput .left_or_right + ; if started with 5 or 6 prize cards + ; can switch sides normally, ld a, [wDuelInitialPrizes] - cp $05 + cp PRIZES_5 jr nc, .next - ld a, [wPrizeCardCursorPosition] - cp $05 - jr nz, .asm_8a28 - ld a, $03 - ld [wPrizeCardCursorPosition], a - jr .asm_8a2d + ; else if it's last card, + ld a, [wYourOrOppPlayAreaCurPosition] + cp 5 + jr nz, .not_last_card + ; place it at pos 3 + ld a, 3 + ld [wYourOrOppPlayAreaCurPosition], a + jr .ok +.not_last_card + ; otherwise place at pos 2 + ld a, 2 + ld [wYourOrOppPlayAreaCurPosition], a -.asm_8a28 - ld a, $02 - ld [wPrizeCardCursorPosition], a -.asm_8a2d +.ok ld a, [wDuelInitialPrizes] - cp $03 - jr nc, .asm_8a3c - ld a, [wPrizeCardCursorPosition] - sub $02 - ld [wPrizeCardCursorPosition], a -.asm_8a3c - ld a, [wPrizeCardCursorPosition] + cp PRIZES_3 + jr nc, .handled_cursor_pos + ; in this case can just sub 2 from pos + ld a, [wYourOrOppPlayAreaCurPosition] + sub 2 + ld [wYourOrOppPlayAreaCurPosition], a + +.handled_cursor_pos + ld a, [wYourOrOppPlayAreaCurPosition] ld [wPrizeCardCursorTemporaryPosition], a - ld b, $01 + ld b, $1 jr .make_bitmask_loop .next @@ -1838,7 +1850,7 @@ Func_89ae: ; 89ae (2:49ae) call .draw_cursor ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wPrizeCardCursorPosition] + ld a, [wYourOrOppPlayAreaCurPosition] scf ret @@ -1858,16 +1870,16 @@ Func_89ae: ; 89ae (2:49ae) .draw_cursor call ZeroObjectPositions - ld hl, wce53 + ld hl, wTransitionTablePtr ld e, [hl] inc hl ld d, [hl] - ld a, [wPrizeCardCursorPosition] + ld a, [wYourOrOppPlayAreaCurPosition] ld l, a ld h, 7 call HtimesL add hl, de -; hl = [wce53] + 7 * wce52 +; hl = [wTransitionTablePtr] + 7 * wce52 ld d, [hl] inc hl @@ -1890,7 +1902,7 @@ ZeroObjectPositionsWithCopyToggleOn: ; 8aa1 (2:4aa1) _SelectPrizeCards: ; 8aaa (2:4aaa) xor a call GetFirstSetPrizeCard - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a ld de, hTempPlayAreaLocation_ffa1 ld hl, wSelectedPrizeCardListPtr ld [hl], e @@ -1936,7 +1948,7 @@ _SelectPrizeCards: ; 8aaa (2:4aaa) ld a, $1 ld [wVBlankOAMCopyToggle], a call DoFrame - call Func_89ae + call YourOrOppPlayAreaScreen_HandleInput jr nc, .loop_handle_input cp $ff jr z, .loop_handle_input @@ -1945,7 +1957,7 @@ _SelectPrizeCards: ; 8aaa (2:4aaa) ; get prize bit mask that corresponds ; to the one pointed by the cursor - ld a, [wPrizeCardCursorPosition] + ld a, [wYourOrOppPlayAreaCurPosition] ld c, a ld b, $1 .loop @@ -1992,9 +2004,9 @@ _SelectPrizeCards: ; 8aaa (2:4aaa) ld a, [wNumberOfPrizeCardsToSelect] dec a ld [wNumberOfPrizeCardsToSelect], a - ld a, [wPrizeCardCursorPosition] + ld a, [wYourOrOppPlayAreaCurPosition] call GetFirstSetPrizeCard - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a jp .check_prize_cards_to_select .cursor_transition_table @@ -2030,8 +2042,8 @@ _DrawPlayAreaToPlacePrizeCards: ; 8b85 (2:4b85) call FillRectangle call SwapTurn - ld a, $01 - ld [wce56], a + ld a, TRUE + ld [wIsSwapTurnPending], a ; mark pending to swap turn ldh a, [hWhoseTurn] ld [wCheckMenuPlayAreaWhichDuelist], a lb de, 6, 0 @@ -3195,7 +3207,7 @@ Func_9345: ; 9345 (2:5345) Func_9461: ; 9461 (2:5461) xor a - ld [wPrizeCardCursorPosition], a + ld [wYourOrOppPlayAreaCurPosition], a ld de, wcfd1 + 5 ld hl, wMenuInputTablePointer ld a, [de] @@ -3226,7 +3238,7 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) ld a, $1 ld [wVBlankOAMCopyToggle], a call DoFrame - call Func_89ae + call YourOrOppPlayAreaScreen_HandleInput jr nc, .do_frame ld [wced6], a cp $ff @@ -3241,7 +3253,7 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) .asm_94b5 push af - call Func_89ae.draw_cursor + call YourOrOppPlayAreaScreen_HandleInput.draw_cursor ld a, $01 ld [wVBlankOAMCopyToggle], a pop af @@ -5607,7 +5619,7 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201) ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame - call Func_89ae + call YourOrOppPlayAreaScreen_HandleInput jr nc, .loop_input ld [wced6], a cp $ff diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index c52a4a4..5ff33a1 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -746,7 +746,7 @@ OpenGlossaryScreen: ; 184c8 (6:44c8) and SELECT jr nz, .on_select - farcall Func_89ae + farcall YourOrOppPlayAreaScreen_HandleInput jr nc, .next cp -1 ; b button diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index e999242..f67a89b 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -6622,7 +6622,7 @@ Peek_SelectEffect: ; 2e2b4 (b:62b4) ; player call Func_3b31 - call Func_30e7 + call HandlePeekSelection ldh [hAIPkmnPowerEffectParam], a call SerialSend8Bytes ret diff --git a/src/engine/home.asm b/src/engine/home.asm index 05a5cdc..0b60609 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9303,12 +9303,12 @@ DrawPlayersPrizeAndBenchCards: ; 30d7 (0:30d7) call BankswitchROM ret -Func_30e7: ; 30e7 (0:30e7) +HandlePeekSelection: ; 30e7 (0:30e7) ldh a, [hBankROM] push af - ld a, BANK(Func_8764) + ld a, BANK(_HandlePeekSelection) call BankswitchROM - call Func_8764 + call _HandlePeekSelection ld b, a pop af call BankswitchROM diff --git a/src/wram.asm b/src/wram.asm index f1b740d..50e0894 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1712,21 +1712,25 @@ wCheckMenuPlayAreaWhichLayout:: ; ce51 ; the position of cursor in the "In Play Area" screen wInPlayAreaCurPosition:: ; ce52 -; holds the position of the cursor when selecting a prize card -wPrizeCardCursorPosition:: ; ce52 +; holds the position of the cursor when selecting +; in the "Your Play Area" or "Opp Play Area" screens +wYourOrOppPlayAreaCurPosition:: ; ce52 ds $1 ; pointer to the table which contains information for each key-press. wMenuInputTablePointer:: ; ce53 -wce53:: ; ce53 +; pointer to transition table data +wTransitionTablePtr:: ; ce53 ds $2 ; same as wDuelInitialPrizes but with upper 2 bits set wDuelInitialPrizesUpperBitsSet:: ; ce55 ds $1 -wce56:: ; ce56 +; if TRUE, SwapTurn is called +; after some operations are concluded +wIsSwapTurnPending:: ; ce56 ds $1 ; it's used for restore the position of cursor -- cgit v1.2.3 From 32eeaa6163225cb49837260e221f6b0955acb041 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Mon, 19 Apr 2021 15:34:53 +0100 Subject: Add menu_constants, document some deck menu routines --- src/constants.asm | 1 + src/constants/menu_constants.asm | 14 + src/engine/bank02.asm | 819 ++++++++++++++++++++++----------------- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 72 ++-- 6 files changed, 533 insertions(+), 377 deletions(-) create mode 100644 src/constants/menu_constants.asm (limited to 'src') diff --git a/src/constants.asm b/src/constants.asm index 96361c9..1a04af4 100644 --- a/src/constants.asm +++ b/src/constants.asm @@ -8,6 +8,7 @@ INCLUDE "constants/duel_interface_constants.asm" INCLUDE "constants/gfx_constants.asm" INCLUDE "constants/hardware_constants.asm" INCLUDE "constants/map_constants.asm" +INCLUDE "constants/menu_constants.asm" INCLUDE "constants/misc_constants.asm" INCLUDE "constants/music_constants.asm" INCLUDE "constants/name_constants.asm" diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm new file mode 100644 index 0000000..47582a2 --- /dev/null +++ b/src/constants/menu_constants.asm @@ -0,0 +1,14 @@ +; filter types for CardTypeFilters +; used to categorise the different cards +; i.e. in the deck building screen +FILTER_FIRE EQUS "TYPE_PKMN_FIRE" +FILTER_GRASS EQUS "TYPE_PKMN_GRASS" +FILTER_LIGHTNING EQUS "TYPE_PKMN_LIGHTNING" +FILTER_WATER EQUS "TYPE_PKMN_WATER" +FILTER_FIGHTING EQUS "TYPE_PKMN_FIGHTING" +FILTER_PSYCHIC EQUS "TYPE_PKMN_PSYCHIC" +FILTER_COLORLESS EQUS "TYPE_PKMN_COLORLESS" +FILTER_TRAINER EQUS "TYPE_TRAINER" +FILTER_ENERGY EQU $20 + +NUM_FILTERS EQU 9 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 26a4ba4..7176518 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -512,7 +512,7 @@ DrawInPlayAreaScreen: ; 82ce (2:42ce) call DoFrame call EmptyScreen - ld a, $0a + ld a, CHECK_PLAY_AREA ld [wDuelDisplayedScreen], a call Set_OBJ_8x8 call LoadCursorTile @@ -1487,7 +1487,7 @@ endr .SelectedPrize: ; 8819 (2:4819) ld a, [wYourOrOppPlayAreaCurPosition] ld c, a - ld b, $01 + ld b, $1 ; left-shift b a number of times ; corresponding to this prize card @@ -1760,7 +1760,7 @@ YourOrOppPlayAreaScreen_HandleInput: ; 89ae (2:49ae) ld [wYourOrOppPlayAreaCurPosition], a cp $8 ; if a >= 0x8 jr nc, .next - ld b, $01 + ld b, $1 ; this loop equals to ; b = (1 << a) @@ -2138,7 +2138,7 @@ OpenGlossaryScreen_TransitionTable: cursor_transition $58, $68, $00, $08, $05, $04, $04 ; copies DECK_SIZE number of cards from de to hl in SRAM -Func_8cd4: ; 8cd4 (2:4cd4) +CopyDeckFromSRAM: ; 8cd4 (2:4cd4) push bc call EnableSRAM ld b, DECK_SIZE @@ -2161,7 +2161,7 @@ Func_8ce7: ; 8ce7 (2:4ce7) ld bc, DECK_SIZE add hl, bc ld [hl], a ; wcf16 - ld hl, wcf17 + ld hl, wCurDeckCards ld bc, $50 add hl, bc ld [hl], a @@ -2192,7 +2192,7 @@ HandCardsGfx: ; 8d15 (2:4d15) INCBIN "gfx/hand_cards.2bpp" db $00 ; end of data -Func_8d56: ; 8d56 (2:4d56) +EmptyScreenAndLoadFontDuelAndHandCardsIcons: ; 8d56 (2:4d56) xor a ld [wTileMapFill], a call EmptyScreen @@ -2250,25 +2250,26 @@ Func_8db0: ; 8db0 (2:4db0) ld hl, Data_8da9 call Func_8d9d ld a, $ff - call Func_9168 + call DrawDecksScreen xor a +; fallthrough Func_8dbc: ; 8dbc (2:4dbc) ld hl, .DeckSelectionMenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText -.asm_8dc8 +.loop_input call DoFrame - jr c, Func_8dbc - call Func_8dea + jr c, Func_8dbc ; reinit menu parameters + call HandleStartButtonInDeckSelectionMenu jr c, Func_8dbc call HandleMenuInput - jr nc, .asm_8dc8 + jr nc, .loop_input ldh a, [hCurMenuItem] cp $ff ret z - ld [wceb1], a + ld [wCurDeck], a jp Func_8e42 .DeckSelectionMenuParameters @@ -2279,52 +2280,64 @@ Func_8dbc: ; 8dbc (2:4dbc) db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -Func_8dea: ; 8dea (2:4dea) +; handles START button press when in deck selection menu +; does nothing if START button isn't pressed +; if a press was handled, returns carry +; prints "There is no deck here!" if the selected deck is empty +HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea) ldh a, [hDPadHeld] and START - ret z + ret z ; skip + +; set menu item as current deck ld a, [wCurMenuItem] - ld [wceb1], a - call Func_8ff2 - jp nc, Func_8e05 + ld [wCurDeck], a + call CheckIfCurDeckIsValid + jp nc, .valid_deck ; can be jr + +; not a valid deck, cancel ld a, $ff ; cancel call PlaySFXConfirmOrCancel - call Func_8fe8 + call PrintThereIsNoDeckHereText scf ret -Func_8e05: ; 8e05 (2:4e05) +.valid_deck ld a, $1 call PlaySFXConfirmOrCancel call GetPointerToDeckCards push hl call GetPointerToDeckName pop de - call Func_8e1f + call HandleDeckConfirmationMenu ld a, $ff - call Func_9168 - ld a, [wceb1] + call DrawDecksScreen + ld a, [wCurDeck] scf ret -; copies deck in hl to wcfb9 -; copies deck in de to wcf17 -Func_8e1f: ; 8e1f (2:4e1f) + +HandleDeckConfirmationMenu: ; 8e1f (2:4e1f) +; copy deck name push de - ld de, wcfb9 + ld de, wCurDeckName call CopyListFromHLToDEInSRAM pop de - ld hl, wcf17 - call Func_8cd4 - ld a, 9 - ld hl, wcebb + +; copy deck cards + ld hl, wCurDeckCards + call CopyDeckFromSRAM + + ld a, NUM_FILTERS + ld hl, wCardFilterCounts call ClearNBytesFromHL ld a, DECK_SIZE - ld [wcecc], a - ld hl, wcebb + ld [wTotalCardCount], a + ld hl, wCardFilterCounts ld [hl], a call Func_9e41 ret +; 0x8e42 Func_8e42: ; 8e42 (2:4e42) call DrawWideTextBox @@ -2338,7 +2351,7 @@ Func_8e42: ; 8e42 (2:4e42) cp $ff jr nz, .asm_8e64 call EraseCheckMenuCursor - ld a, [wceb1] + ld a, [wCurDeck] jp Func_8dbc .asm_8e64 ld a, [wCheckMenuCursorXPosition] @@ -2350,25 +2363,25 @@ Func_8e42: ; 8e42 (2:4e42) call GetPointerToDeckCards ld e, l ld d, h - ld hl, wcf17 - call Func_8cd4 + ld hl, wCurDeckCards + call CopyDeckFromSRAM ld a, 20 - ld hl, wcfb9 + ld hl, wCurDeckName call ClearNBytesFromHL - ld de, wcfb9 + ld de, wCurDeckName call GetPointerToDeckName call CopyListFromHLToDEInSRAM call Func_9345 jr nc, .asm_8ec4 call EnableSRAM - ld hl, wcf17 + ld hl, wCurDeckCards call Func_910a call GetPointerToDeckCards call Func_9152 ld e, l ld d, h - ld hl, wcf17 - ld b, $3c + ld hl, wCurDeckCards + ld b, DECK_SIZE .asm_8ea9 ld a, [hli] ld [de], a @@ -2378,7 +2391,7 @@ Func_8e42: ; 8e42 (2:4e42) call GetPointerToDeckName ld d, h ld e, l - ld hl, wcfb9 + ld hl, wCurDeckName call CopyListFromHLToDE call GetPointerToDeckName ld a, [hl] @@ -2387,34 +2400,34 @@ Func_8e42: ; 8e42 (2:4e42) jr z, .asm_8edb .asm_8ec4 ld a, $ff - call Func_9168 - ld a, [wceb1] + call DrawDecksScreen + ld a, [wCurDeck] jp Func_8dbc .asm_8ecf - call Func_8ff2 + call CheckIfCurDeckIsValid jp nc, .asm_8edb - call Func_8fe8 + call PrintThereIsNoDeckHereText jp Func_8dbc .asm_8edb ld a, 20 - ld hl, wcfb9 + ld hl, wCurDeckName call ClearNBytesFromHL - ld de, wcfb9 + ld de, wCurDeckName call GetPointerToDeckName call CopyListFromHLToDEInSRAM call Func_8f05 call GetPointerToDeckName ld d, h ld e, l - ld hl, wcfb9 + ld hl, wCurDeckName call CopyListFromHLToDEInSRAM ld a, $ff - call Func_9168 - ld a, [wceb1] + call DrawDecksScreen + ld a, [wCurDeck] jp Func_8dbc Func_8f05: ; 8f05 (2:4f05) - ld a, [wceb1] + ld a, [wCurDeck] or a jr nz, .asm_8f10 ; it refers to a data in the other bank without any bank desc. @@ -2435,9 +2448,9 @@ Func_8f05: ; 8f05 (2:4f05) .asm_8f23 ld a, MAX_DECK_NAME_LENGTH lb bc, 4, 1 - ld de, wcfb9 + ld de, wCurDeckName farcall InputDeckName - ld a, [wcfb9] + ld a, [wCurDeckName] or a ret nz call Func_8f38 @@ -2452,7 +2465,7 @@ Func_8f38: ; 8f38 (2:4f38) ld l, a ld de, wDefaultText call TwoByteNumberToText - ld hl, wcfb9 + ld hl, wCurDeckName ld [hl], $6 inc hl ld [hl], $44 @@ -2500,9 +2513,9 @@ Func_8f8a: ; 8f8a (2:4f8a) ld a, [wCheckMenuCursorYPosition] or a jp nz, Func_9026 - call Func_8ff2 + call CheckIfCurDeckIsValid jp nc, Func_8f9d - call Func_8fe8 + call PrintThereIsNoDeckHereText jp Func_8dbc Func_8f9d: ; 8f9d (2:4f9d) @@ -2519,11 +2532,11 @@ Func_8f9d: ; 8f9d (2:4f9d) lb hl, 0, 0 lb bc, 2, 2 call FillRectangle - ld a, [wceb1] + ld a, [wCurDeck] call EnableSRAM ld [sCurrentlySelectedDeck], a call DisableSRAM - call DrawHandCardsTileOnSelectedDeck + call DrawHandCardsTileOnCurDeck call GetPointerToDeckName call EnableSRAM call Func_9253 @@ -2533,26 +2546,28 @@ Func_8f9d: ; 8f9d (2:4f9d) ld [wTxRam2 + 1], a ldtx hl, ChosenAsDuelingDeckText call DrawWideTextBox_WaitForInput - ld a, [wceb1] + ld a, [wCurDeck] jp Func_8dbc -Func_8fe8: ; 8fe8 (2:4fe8) +PrintThereIsNoDeckHereText: ; 8fe8 (2:4fe8) ldtx hl, ThereIsNoDeckHereText call DrawWideTextBox_WaitForInput - ld a, [wceb1] + ld a, [wCurDeck] ret -Func_8ff2: ; 8ff2 (2:4ff2) - ld a, [wceb1] - ld hl, wceb2 +; returns carry if deck in wCurDeck +; is not a valid deck +CheckIfCurDeckIsValid: ; 8ff2 (2:4ff2) + ld a, [wCurDeck] + ld hl, wDecksValid ld b, $0 ld c, a add hl, bc ld a, [hl] or a - ret nz + ret nz ; is valid scf - ret + ret ; is not valid ; 0x9001 INCROM $9001, $9026 @@ -2568,9 +2583,9 @@ DeckSelectionData: ; 9027 (2:5027) db $ff ; 0x9038 -; return, in hl, the pointer to sDeckXName where X is [wceb1] + 1 +; return, in hl, the pointer to sDeckXName where X is [wCurDeck] + 1 GetPointerToDeckName: ; 9038 (2:5038) - ld a, [wceb1] + ld a, [wCurDeck] ld h, a ld l, sDeck2Name - sDeck1Name call HtimesL @@ -2580,10 +2595,10 @@ GetPointerToDeckName: ; 9038 (2:5038) pop de ret -; return, in hl, the pointer to sDeckXCards where X is [wceb1] + 1 +; return, in hl, the pointer to sDeckXCards where X is [wCurDeck] + 1 GetPointerToDeckCards: ; 9048 (2:5048) push af - ld a, [wceb1] + ld a, [wCurDeck] ld h, a ld l, sDeck2Cards - sDeck1Cards call HtimesL @@ -2747,7 +2762,7 @@ PlaySFXConfirmOrCancel: ; 90fb (2:50fb) Func_910a: ; 910a (2:510a) push hl ld b, $0 - ld d, $3c + ld d, DECK_SIZE .asm_910f ld a, [hli] or a @@ -2825,9 +2840,12 @@ Func_9152: ; 9152 (2:5152) pop hl ret -Func_9168: ; 9168 (2:5168) +; draws the screen which shows the player's current +; deck configurations +; a = some flags to pick which deck names to show +DrawDecksScreen: ; 9168 (2:5168) ld [hffb5], a - call Func_8d56 + call EmptyScreenAndLoadFontDuelAndHandCardsIcons lb de, 0, 0 lb bc, 20, 4 call DrawRegularTextBox @@ -2842,85 +2860,100 @@ Func_9168: ; 9168 (2:5168) call DrawRegularTextBox ld hl, DeckNameMenuData call PlaceTextItems - ld a, 4 - ld hl, wceb2 + +; mark all decks as invalid + ld a, NUM_DECKS + ld hl, wDecksValid call ClearNBytesFromHL + +; for each deck, check if it has cards and if so +; mark is as valid in wDecksValid + +; deck 1 ld a, [hffb5] ; should be ldh bit 0, a - jr z, .asm_91b0 + jr z, .skip_name_1 ld hl, sDeck1Name lb de, 6, 2 - call Func_926e -.asm_91b0 + call PrintDeckName +.skip_name_1 ld hl, sDeck1Cards - call Func_9314 - jr c, .asm_91bd - ld a, $1 - ld [wceb2], a -.asm_91bd + call CheckIfDeckHasCards + jr c, .deck_2 + ld a, TRUE + ld [wDeck1Valid], a + +.deck_2 ld a, [hffb5] ; should be ldh bit 1, a - jr z, .asm_91cd + jr z, .skip_name_2 ld hl, sDeck2Name lb de, 6, 5 - call Func_926e -.asm_91cd + call PrintDeckName +.skip_name_2 ld hl, sDeck2Cards - call Func_9314 - jr c, .asm_91da - ld a, $1 - ld [wceb3], a -.asm_91da + call CheckIfDeckHasCards + jr c, .deck_3 + ld a, TRUE + ld [wDeck2Valid], a + +.deck_3 ld a, [hffb5] ; should be ldh bit 2, a - jr z, .asm_91ea + jr z, .skip_name_3 ld hl, sDeck3Name lb de, 6, 8 - call Func_926e -.asm_91ea + call PrintDeckName +.skip_name_3 ld hl, sDeck3Cards - call Func_9314 - jr c, .asm_91f7 - ld a, $1 - ld [wceb4], a -.asm_91f7 + call CheckIfDeckHasCards + jr c, .deck_4 + ld a, TRUE + ld [wDeck3Valid], a + +.deck_4 ld a, [hffb5] ; should be ldh bit 3, a - jr z, .asm_9207 + jr z, .skip_name_4 ld hl, sDeck4Name lb de, 6, 11 - call Func_926e -.asm_9207 + call PrintDeckName +.skip_name_4 ld hl, sDeck4Cards - call Func_9314 - jr c, .asm_9214 - ld a, $1 - ld [wceb5], a -.asm_9214 + call CheckIfDeckHasCards + jr c, .place_cursor + ld a, TRUE + ld [wDeck4Valid], a + +.place_cursor +; places cursor on sCurrentlySelectedDeck +; if it's an empty deck, then advance the cursor +; until it's selecting a valid deck call EnableSRAM ld a, [sCurrentlySelectedDeck] ld c, a ld b, $0 - ld d, $2 -.asm_921f - ld hl, wceb2 + ld d, 2 +.check_valid_deck + ld hl, wDecksValid add hl, bc ld a, [hl] or a - jr nz, .asm_9234 + jr nz, .valid_selected_deck inc c - ld a, $4 + ld a, NUM_DECKS cp c - jr nz, .asm_921f - ld c, $0 + jr nz, .check_valid_deck + ld c, 0 ; roll back to deck 1 dec d - jr z, .asm_9234 - jr .asm_921f -.asm_9234 + jr z, .valid_selected_deck + jr .check_valid_deck + +.valid_selected_deck ld a, c ld [sCurrentlySelectedDeck], a call DisableSRAM - call DrawHandCardsTileOnSelectedDeck + call DrawHandCardsTileOnCurDeck call EnableLCD ret ; 0x9242 @@ -2943,16 +2976,22 @@ Func_9253: ; 9253 (2:5253) add hl, bc ld d, h ld e, l - ld hl, Data_92a7 + ld hl, DeckNameSuffix call CopyListFromHLToDE ret +; prints deck name given in hl in position de +; if it's an empty deck, print "NEW DECK" instead +; returns carry if it's an empty deck +; hl = deck name (sDeck1Name ~ sDeck4Name) ; de = coordinates to print text -Func_926e: ; 926e (2:526e) +PrintDeckName: ; 926e (2:526e) push hl - call Func_9314 + call CheckIfDeckHasCards pop hl - jr c, .asm_929c + jr c, .new_deck + +; print " deck" push de ld de, wDefaultText call CopyListFromHLToDEInSRAM @@ -2963,7 +3002,7 @@ Func_926e: ; 926e (2:526e) add hl, bc ld d, h ld e, l - ld hl, Data_92a7 + ld hl, DeckNameSuffix call CopyListFromHLToDE pop de ld hl, wDefaultText @@ -2971,14 +3010,16 @@ Func_926e: ; 926e (2:526e) call ProcessText or a ret -.asm_929c + +.new_deck +; print "NEW DECK" call InitTextPrinting ldtx hl, NewDeckText call ProcessTextFromID scf ret -Data_92a7: ; 92a7 (2:52a7) +DeckNameSuffix: ; 92a7 (2:52a7) db " deck" db TX_END @@ -3001,7 +3042,7 @@ CopyListFromHLToDEInSRAM: ; 92b4 (2:52b4) Func_92be: ; 92be (2:52be) push hl - call Func_9314 + call CheckIfDeckHasCards pop hl ret c push de @@ -3036,23 +3077,31 @@ Func_92be: ; 92be (2:52be) .text_end ; 0x9314 -Func_9314: ; 9314 (2:5314) - ld bc, $0018 +; returns carry if the deck in hl +; is not valid, that is, has no cards +; alternatively, the direct address of the cards +; can be used, since DECK_SIZE > DECK_NAME_SIZE +; hl = deck name (sDeck1Name ~ sDeck4Name) +; or deck cards (sDeck1Cards ~ sDeck4Cards) +CheckIfDeckHasCards: ; 9314 (2:5314) + ld bc, DECK_NAME_SIZE add hl, bc call EnableSRAM ld a, [hl] call DisableSRAM + ; being max size means last char + ; is not TX_END, i.e. $0 or a - jr nz, .asm_9324 + jr nz, .max_size scf ret -.asm_9324 +.max_size or a ret ; calculates the y coordinate of the currently selected deck ; and draws the hands card tile at that position -DrawHandCardsTileOnSelectedDeck: ; 9326 (2:5326) +DrawHandCardsTileOnCurDeck: ; 9326 (2:5326) call EnableSRAM ld a, [sCurrentlySelectedDeck] call DisableSRAM @@ -3208,7 +3257,7 @@ Func_9345: ; 9345 (2:5345) Func_9461: ; 9461 (2:5461) xor a ld [wYourOrOppPlayAreaCurPosition], a - ld de, wcfd1 + 5 + ld de, wcfd6 ld hl, wMenuInputTablePointer ld a, [de] ld [hli], a @@ -3220,7 +3269,7 @@ Func_9461: ; 9461 (2:5461) .asm_9475 xor a ld [wCheckMenuCursorBlinkCounter], a - ld hl, wcfd1 + 3 + ld hl, wcfd4 ld a, [hli] ld h, [hl] ld l, a @@ -3312,9 +3361,9 @@ CancelDeckModifications: ; 9509 (2:5509) SaveDeckConfiguration: ; 951a (2:551a) ; handle deck configuration size - ld a, [wcecc] + ld a, [wTotalCardCount] cp DECK_SIZE - jp z, .ask_to_save_deck ; should be jr + jp z, .ask_to_save_deck ; can be jr ldtx hl, ThisIsntA60CardDeckText call DrawWideTextBox_WaitForInput ldtx hl, ReturnToOriginalConfigurationText @@ -3358,7 +3407,7 @@ DismantleDeck: ; 9566 (2:5566) call YesOrNoMenuWithText jr c, SaveDeckConfiguration.go_back call Func_9622 - jp nc, .Dismantle ; should be jr + jp nc, .Dismantle ; can be jr ldtx hl, ThereIsOnly1DeckSoCannotBeDismantledText call DrawWideTextBox_WaitForInput call EmptyScreen @@ -3398,7 +3447,7 @@ ChangeDeckName: ; 95b9 (2:55b9) ; 0x95c1 Func_95c1: ; 95c1 (2:55c1) - ld a, [wcecc] + ld a, [wTotalCardCount] or a jr z, .skip_size_check cp DECK_SIZE @@ -3413,12 +3462,12 @@ Func_95c1: ; 95c1 (2:55c1) call CopyNBytesFromHLToDE call DisableSRAM -; loops through cards in wcf17 +; loops through cards in wCurDeckCards ; then if that card is found in wc590 ; overwrite it by $0 ld a, $ff ld [wc5cc], a - ld de, wcf17 + ld de, wCurDeckCards .loop_outer ld a, [de] or a @@ -3451,7 +3500,7 @@ Func_95c1: ; 95c1 (2:55c1) ; wc590 is empty (all $0) .is_empty call GetPointerToDeckName - ld de, wcfb9 + ld de, wCurDeckName call EnableSRAM .asm_9610 ld a, [de] @@ -3470,7 +3519,7 @@ Func_95c1: ; 95c1 (2:55c1) ; 0x9622 Func_9622: ; 9622 (2:5622) - ld hl, wceb2 + ld hl, wDecksValid ld bc, $0 .loop inc b @@ -3498,11 +3547,11 @@ Func_9622: ; 9622 (2:5622) ret ; 0x9649 -; checks if wcf17 has any basics +; checks if wCurDeckCards has any basics ; returns carry set if there is at least ; 1 Basic Pokemon card Func_9649: ; 9649 (2:5649) - ld hl, wcf17 + ld hl, wCurDeckCards .loop_cards ld a, [hli] ld e, a @@ -3525,10 +3574,16 @@ Func_9649: ; 9649 (2:5649) ; 0x9667 Data_9667: ; 9667 (2:5667) - db $01, $01, $00, $02, $09, $2f, $00, $00, $00 + db $01, $01, $00, $02, $09 + db SYM_CURSOR_D + db SYM_SPACE + dw NULL Data_9670: ; 9670 (2:5670) - db $00, $07, $02, $00, $06, $0f, $00, $00, $00 + db $00, $07, $02, $00, $06 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL DeckConfigurationMenu_TransitionTable: ; 9679 (2:5679) cursor_transition $10, $20, $00, $03, $03, $01, $02 @@ -3577,10 +3632,10 @@ FillBGMapLineWithA: ; 96c7 (2:56c7) ret ; 0x96e3 -; saves the count of each type of card that is in wcf17 -; stores these values in wcebb +; saves the count of each type of card that is in wCurDeckCards +; stores these values in wCardFilterCounts CountNumberOfCardsForEachCardType: ; 96e3 (2:56e3) - ld hl, wcebb + ld hl, wCardFilterCounts ld de, CardTypeFilters .loop ld a, [de] @@ -3724,8 +3779,8 @@ CreateFilteredCardList: ; 978b (2:578b) ld a, b cp $ff jr z, .add_card - and $20 - cp $20 + and FILTER_ENERGY + cp FILTER_ENERGY jr z, .check_energy ld a, c cp b @@ -3852,12 +3907,12 @@ ClearNBytesFromHL: ; 9843 (2:5843) ret ; 0x9850 -; finds instance of e in list wcf17 +; finds instance of e in list wCurDeckCards ; returns the position in the list that it was found ; if not found, returns last position + 1 Func_9850: ; 9850 (2:5850) push hl - ld hl, wcf17 + ld hl, wCurDeckCards ld d, $00 .loop ld a, [hli] @@ -3997,7 +4052,7 @@ ConvertToNumericalDigits: ; 98c7 (2:58c7) ret ; 0x98dc -; counts the number of cards in wcf17 +; counts the number of cards in wCurDeckCards ; that are the same type as input in register a ; if input is $20, counts all energy cards instead ; input: @@ -4013,7 +4068,7 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc) .loop_cards push hl push bc - ld bc, wcf17 + ld bc, wCurDeckCards add hl, bc ld a, [hl] pop bc @@ -4023,7 +4078,7 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc) jr z, .done ; end of card list ; get card type and compare it with input type -; if input is $20, run a separate comparison +; if input is FILTER_ENERGY, run a separate comparison ; if it's the same type, increase the count ld e, a call GetCardType @@ -4031,8 +4086,8 @@ CountNumberOfCardsOfType: ; 98dc (2:58dc) push hl ld l, a ld a, b - and $20 - cp $20 + and FILTER_ENERGY + cp FILTER_ENERGY jr z, .check_energy ld a, l pop hl @@ -4066,7 +4121,7 @@ PrintCardTypeCounts: ; 9916 (2:5916) ld hl, wDefaultText .loop push hl - ld hl, wcebb + ld hl, wCardFilterCounts add hl, bc ld a, [hl] pop hl @@ -4074,7 +4129,7 @@ PrintCardTypeCounts: ; 9916 (2:5916) call ConvertToNumericalDigits pop bc inc c - ld a, $9 + ld a, NUM_FILTERS cp c jr nz, .loop ld [hl], TX_END @@ -4102,7 +4157,7 @@ Func_993d: ; 993d (2:593d) call CopyNBytesFromHLToDE call DisableSRAM - ld a, [wcfd1 + 2] + ld a, [wcfd3] or a jr z, .ok call GetPointerToDeckCards @@ -4114,8 +4169,8 @@ Func_993d: ; 993d (2:593d) call CreateFilteredCardList ld a, $06 ld [wcecb], a - lb de, 1 ,7 - ld hl, wced0 + lb de, 1, 7 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -4126,36 +4181,36 @@ Func_993d: ; 993d (2:593d) ; used to filter the cards in the deck building/card selection screen CardTypeFilters: ; 997d (2:597d) - db TYPE_PKMN_GRASS - db TYPE_PKMN_FIRE - db TYPE_PKMN_WATER - db TYPE_PKMN_LIGHTNING - db TYPE_PKMN_FIGHTING - db TYPE_PKMN_PSYCHIC - db TYPE_PKMN_COLORLESS - db TYPE_TRAINER - db $20 + db FILTER_GRASS + db FILTER_FIRE + db FILTER_WATER + db FILTER_LIGHTNING + db FILTER_FIGHTING + db FILTER_PSYCHIC + db FILTER_COLORLESS + db FILTER_TRAINER + db FILTER_ENERGY db -1 ; end of list ; 0x9987 ; counts all the cards from each card type -; (stored in wcebb) and store it in wcecc +; (stored in wCardFilterCounts) and store it in wTotalCardCount ; also prints it in coordinates de PrintTotalCardCount: ; 9987 (2:5987) push de ld bc, $0 - ld hl, wcebb + ld hl, wCardFilterCounts .loop ld a, [hli] add b ld b, a inc c - ld a, $9 + ld a, NUM_FILTERS cp c jr nz, .loop ld hl, wDefaultText ld a, b - ld [wcecc], a + ld [wTotalCardCount], a push bc call ConvertToNumericalDigits pop bc @@ -4175,7 +4230,7 @@ PrintTotalCardCount: ; 9987 (2:5987) ; and Y is the storage count of that card PrintDeckBuildingCardList: ; 99b0 (2:59b0) push bc - ld hl, wced0 + ld hl, wCardListCoords ld e, [hl] inc hl ld d, [hl] @@ -4452,9 +4507,10 @@ Func_9b00: ; 9b00 (2:5b00) ld a, [wceab] ; fallthrough +; a = tile to write Func_9b03: ; 9b03 (2:5b03) ld e, a - ld a, [wcea5 + 3] + ld a, [wcea8] ld l, a ld a, [wNamingScreenCursorY] ld h, a @@ -4463,7 +4519,7 @@ Func_9b03: ; 9b03 (2:5b03) ld hl, wcea5 add [hl] ld b, a - ld hl, wcea5 + 1 + ld hl, wcea6 ld a, [hl] ld c, a ld a, e @@ -4484,6 +4540,7 @@ Func_9b25: ; 9b25 (2:5b25) ldh a, [hDPadHeld] or a jp z, .asm_9bb9 + ld b, a ld a, [wNamingScreenKeyboardHeight] ld c, a @@ -4541,6 +4598,7 @@ Func_9b25: ; 9b25 (2:5b25) xor a ; FALSE ld [wPlaysSfx], a pop af + .asm_9b8f push af call Func_9c0e @@ -4564,6 +4622,7 @@ Func_9b25: ; 9b25 (2:5b25) jr z, .asm_9bb9 call Func_9db3 call Func_9d0c + .asm_9bb9 ld a, [wNamingScreenCursorY] ld [hffb3], a @@ -4590,7 +4649,7 @@ Func_9b25: ; 9b25 (2:5b25) .asm_9be2 ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON - jr z, .asm_9bf6 + jr z, .check_sfx and A_BUTTON jr nz, .asm_9bd1 ld a, $ff @@ -4599,7 +4658,7 @@ Func_9b25: ; 9b25 (2:5b25) scf ret -.asm_9bf6 +.check_sfx ld a, [wPlaysSfx] or a jr z, .handle_blink @@ -4613,7 +4672,7 @@ Func_9b25: ; 9b25 (2:5b25) ld a, [wceaa] bit 4, [hl] jr z, Func_9c11 -; 0x9c0e +; fallthrough Func_9c0e: ; 9c0e (2:5c0e) ld a, [wceab] @@ -4622,7 +4681,7 @@ Func_9c0e: ; 9c0e (2:5c0e) ; a = tile to write Func_9c11: ; 9c11 (2:5c11) ld e, a - ld a, [wcea5 + 3] + ld a, [wcea8] ld l, a ld a, [wNamingScreenCursorY] ld h, a @@ -4631,13 +4690,13 @@ Func_9c11: ; 9c11 (2:5c11) ld hl, wcea5 add [hl] ld b, a - ld a, [wcea5 + 2] + ld a, [wcea7] ld l, a ld a, [wNamingScreenCursorY] ld h, a call HtimesL ld a, l - ld hl, wcea5 + 1 + ld hl, wcea6 add [hl] ld c, a ld a, e @@ -4776,7 +4835,7 @@ Func_9d0c: ; 9d0c (2:5d0c) Func_9d22: ; 9d22 (2:5d22) ld a, [wcfd1] ld d, a - ld a, [wcecc] + ld a, [wTotalCardCount] cp d jr nz, .asm_9d2e scf @@ -4811,7 +4870,7 @@ Func_9d22: ; 9d22 (2:5d22) ld a, [wCurCardTypeFilter] ld c, a ld b, $00 - ld hl, wcebb + ld hl, wCardFilterCounts add hl, bc inc [hl] pop de @@ -4819,10 +4878,10 @@ Func_9d22: ; 9d22 (2:5d22) ret ; 0x9d65 -; finds first empty slot in wcf17 +; finds first empty slot in wCurDeckCards ; then writes the value in e to it Func_9d65: ; 9d65 (2:5d65) - ld hl, wcf17 + ld hl, wCurDeckCards .loop ld a, [hl] or a @@ -4849,12 +4908,12 @@ Func_9d74: ; 9d74 (2:5d74) .double_colorless ; compare this card's name to -; the names of cards in list wcf17 +; the names of cards in list wCurDeckCards ld a, [wLoadedCard1Name + 0] ld c, a ld a, [wLoadedCard1Name + 1] ld b, a - ld hl, wcf17 + ld hl, wCurDeckCards ld d, $00 push de .loop @@ -4873,7 +4932,7 @@ Func_9d74: ; 9d74 (2:5d74) ; has same name pop de inc d - ld a, [wcfd1 + 1] + ld a, [wcfd2] cp d push de jr nz, .loop @@ -4905,13 +4964,13 @@ Func_9dbf: ; 9dbf (2:5dbf) ld hl, wc590 call ConvertToNumericalDigits ld [hl], TX_END - ld a, [wcea5 + 2] + ld a, [wcea7] ld l, a ld a, [wNamingScreenCursorY] ld h, a call HtimesL ld a, l - ld hl, wcea5 + 1 + ld hl, wcea6 add [hl] ld e, a ld d, $0e @@ -4947,7 +5006,7 @@ Func_9dfa: ; 9dfa (2:5dfa) ld a, [wCurCardTypeFilter] ld c, a ld b, $00 - ld hl, wcebb + ld hl, wCardFilterCounts add hl, bc dec [hl] pop de @@ -4956,7 +5015,7 @@ Func_9dfa: ; 9dfa (2:5dfa) ; 0x9e18 Func_9e18: ; 9e18 (2:5e18) - ld hl, wcf17 + ld hl, wCurDeckCards ld d, $00 .loop_1 inc d @@ -4980,42 +5039,48 @@ Func_9e18: ; 9e18 (2:5e18) ret ; 0x9e31 -Func_9e31: ; 9e31 (2:5e31) +UpdateConfirmationCardScreen: ; 9e31 (2:5e31) ld hl, hffb0 ld [hl], $01 - call Func_9fc0 + call PrintCurDeckNumberAndName ld hl, hffb0 ld [hl], $00 jp PrintConfirmationCardList ; 0x9e41 Func_9e41: ; 9e41 (2:5e41) - ld a, [wcecc] +; if deck is empty, just show deck info header with empty card list + ld a, [wTotalCardCount] or a - jp z, Func_9f40 - call Func_a028 - call Func_a06e + jp z, ShowDeckInfoHeaderAndWaitForBButton + +; create list of all unique cards + call SortCurDeckCardsByID + call CreateCurDeckUniqueCardList xor a ld [wcea1], a .asm_9e52 ld hl, Data_9eaf call Func_9a6d - ld a, [wced9] + ld a, [wNumUniqueCards] ld [wcfe6], a cp $07 - jr c, .asm_9e64 + jr c, .no_cap + ; cap to 7 ld a, $07 -.asm_9e64 +.no_cap ld [wNamingScreenKeyboardHeight], a ld [wcecb], a - call Func_9f52 - ld hl, Func_9e31 + call ShowConfirmationCardScreen + + ld hl, UpdateConfirmationCardScreen ld d, h ld a, l ld hl, wcece ld [hli], a ld [hl], d + xor a ld [wced2], a .asm_9e7b @@ -5049,7 +5114,10 @@ Func_9e41: ; 9e41 (2:5e41) ; 0x9eaf Data_9eaf: - db $00, $05, $02, $00, $07, $0f, $00, $00, $00 + db $00, $05, $02, $00, $07 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL Func_9eb8: ; 9eb8 (2:5eb8) ld a, [wNamingScreenKeyboardHeight] @@ -5142,8 +5210,10 @@ Func_9efc: ; 9efc (2:5efc) ret ; 0x9f40 -Func_9f40: ; 9f40 (2:5f40) - call Func_9f81 +; simply draws the deck info header +; then awaits a b button press to exit +ShowDeckInfoHeaderAndWaitForBButton: ; 9f40 (2:5f40) + call ShowDeckInfoHeader .wait_input call DoFrame ldh a, [hKeysPressed] @@ -5154,10 +5224,10 @@ Func_9f40: ; 9f40 (2:5f40) ret ; 0x9f52 -Func_9f52: ; 9f52 (2:5f52) - call Func_9f81 +ShowConfirmationCardScreen: ; 9f52 (2:5f52) + call ShowDeckInfoHeader lb de, 3, 5 - ld hl, wced0 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -5165,18 +5235,18 @@ Func_9f52: ; 9f52 (2:5f52) ret ; 0x9f62 -; counts all values stored in wcebb +; counts all values stored in wCardFilterCounts ; if the total count is 0, then ; prints "No cards chosen." Func_9f62: ; 9f62 (2:5f62) lb bc, 0, 0 - ld hl, wcebb + ld hl, wCardFilterCounts .loop ld a, [hli] add b ld b, a inc c - ld a, $9 + ld a, NUM_FILTERS cp c jr nz, .loop ld a, b @@ -5189,16 +5259,22 @@ Func_9f62: ; 9f62 (2:5f62) ret ; 0x9f81 -Func_9f81: ; 9f81 (2:5f81) - call Func_8d56 +; draws a box on the top of the screen +; with wCurDeck's number, name and card count +; and draws the Hand Cards icon if it's +; the current dueling deck +ShowDeckInfoHeader: ; 9f81 (2:5f81) + call EmptyScreenAndLoadFontDuelAndHandCardsIcons lb de, 0, 0 lb bc, 20, 4 call DrawRegularTextBox - ld a, [wcfb9] + ld a, [wCurDeckName] or a - jp z, .print_card_count ; should be jr - call Func_9fc0 - ld a, [wceb1] + jp z, .print_card_count ; can be jr + +; draw hand cards icon if it's the current dueling deck + call PrintCurDeckNumberAndName + ld a, [wCurDeck] ld b, a call EnableSRAM ld a, [sCurrentlySelectedDeck] @@ -5218,35 +5294,44 @@ Func_9f81: ; 9f81 (2:5f81) ret ; 0x9fc0 -Func_9fc0: ; 9fc0 (2:5fc0) - ld a, [wceb1] +; prints the name of wCurDeck in the form +; "X· deck", where X is the number +; of the deck in the given menu +; if no current deck, print blank line +PrintCurDeckNumberAndName: ; 9fc0 (2:5fc0) + ld a, [wCurDeck] cp $ff - jr z, .asm_9fea + jr z, .skip_deck_numeral + +; print the deck number in the menu +; in the form "X·" lb de, 3, 2 call InitTextPrinting - ld a, [wceb1] + ld a, [wCurDeck] bit 7, a - jr z, .asm_9fd8 + jr z, .incr_by_one and $7f - jr .asm_9fd9 -.asm_9fd8 + jr .got_deck_numeral +.incr_by_one inc a -.asm_9fd9 +.got_deck_numeral ld hl, wDefaultText call ConvertToNumericalDigits - ld [hl], $77 + ld [hl], "FW0_·" inc hl ld [hl], TX_END ld hl, wDefaultText call ProcessText -.asm_9fea - ld hl, wcfb9 +.skip_deck_numeral + ld hl, wCurDeckName ld de, wDefaultText call CopyListFromHLToDE - ld a, [wceb1] + ld a, [wCurDeck] cp $ff - jr z, .asm_a01b + jr z, .blank_deck_name + +; print " deck" ld hl, wDefaultText call GetTextLengthInTiles ld b, $0 @@ -5254,7 +5339,7 @@ Func_9fc0: ; 9fc0 (2:5fc0) add hl, bc ld d, h ld e, l - ld hl, Data_92a7 + ld hl, DeckNameSuffix call CopyListFromHLToDE lb de, 6, 2 ld hl, wDefaultText @@ -5262,7 +5347,7 @@ Func_9fc0: ; 9fc0 (2:5fc0) call ProcessText ret -.asm_a01b +.blank_deck_name lb de, 2, 2 ld hl, wDefaultText call InitTextPrinting @@ -5270,14 +5355,17 @@ Func_9fc0: ; 9fc0 (2:5fc0) ret ; 0xa028 -Func_a028: ; a028 (2:6028) - ld hl, wcf17 +; sorts wCurDeckCards by ID +SortCurDeckCardsByID: ; a028 (2:6028) +; wOpponentDeck is used to temporarily store deck's cards +; so that it can be later sorted by ID + ld hl, wCurDeckCards ld de, wOpponentDeck ld bc, wDuelTempList ld a, -1 ld [bc], a .loop_copy - inc a + inc a ; incr deck index push af ld a, [hli] ld [de], a @@ -5285,14 +5373,16 @@ Func_a028: ; a028 (2:6028) or a jr z, .sort_cards pop af - ld [bc], a + ld [bc], a ; store deck index inc bc jr .loop_copy .sort_cards pop af - ld a, $ff + ld a, $ff ; terminator byte for wDuelTempList ld [bc], a + +; force Opp Turn so that SortCardsInDuelTempListByID can be used ldh a, [hWhoseTurn] push af ld a, OPPONENT_TURN @@ -5301,9 +5391,13 @@ Func_a028: ; a028 (2:6028) pop af ldh [hWhoseTurn], a - ld hl, wcf17 +; given the ordered cards in wOpponentDeck, +; each entry in it corresponds to its deck index +; (first ordered card is deck index 0, second is deck index 1, etc) +; place these in this order in wCurDeckCards + ld hl, wCurDeckCards ld de, wDuelTempList -.asm_a058 +.loop_order_by_deck_index ld a, [de] cp $ff jr z, .done @@ -5316,7 +5410,7 @@ Func_a028: ; a028 (2:6028) pop hl ld [hli], a inc de - jr .asm_a058 + jr .loop_order_by_deck_index .done xor a @@ -5324,14 +5418,14 @@ Func_a028: ; a028 (2:6028) ret ; 0xa06e -; goes through list in wcf17, and for each card in it +; goes through list in wCurDeckCards, and for each card in it ; creates list in wOwnedCardsCountList of all unique cards -; it finds (assuming wcf17 is sorted by ID) +; it finds (assuming wCurDeckCards is sorted by ID) ; also counts the number of the different cards -Func_a06e: ; a06e (2:606e) +CreateCurDeckUniqueCardList: ; a06e (2:606e) ld b, 0 ld c, $0 - ld hl, wcf17 + ld hl, wCurDeckCards ld de, wOwnedCardsCountList .loop ld a, [hli] @@ -5346,7 +5440,7 @@ Func_a06e: ; a06e (2:606e) jr .loop .done ld a, b - ld [wced9], a + ld [wNumUniqueCards], a ret ; 0xa08a @@ -5356,7 +5450,7 @@ Func_a06e: ; a06e (2:606e) ; its count preceded by "x" PrintConfirmationCardList: ; a08a (2:608a) push bc - ld hl, wced0 + ld hl, wCardListCoords ld e, [hl] inc hl ld d, [hl] @@ -5548,7 +5642,7 @@ GetCardTypeIconPalette: ; a173 (2:6173) cp b jr z, .done inc hl - jp .loop ; should be jr + jp .loop ; can be jr .done ld a, [hl] pop hl @@ -5573,13 +5667,13 @@ GetCardTypeIconPalette: ; a173 (2:6173) ; 0xa1a2 Func_a1a2: ; a1a2 (2:61a2) - ld hl, wcf17 + ld hl, wCurDeckCards ld a, DECK_SIZE + $15 call ClearNBytesFromHL ld a, $ff - ld [wceb1], a + ld [wCurDeck], a ld hl, .text - ld de, wcfb9 + ld de, wCurDeckName call CopyListFromHLToDE ld hl, .unknown_a1d8 call Func_8d9d @@ -5642,14 +5736,14 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201) ; 0xa24a SendDeckConfiguration: ; a24a (2:624a) - ld a, [wcf17] + ld a, [wCurDeckCards] or a jr z, CancelSendDeckConfiguration xor a ld [wcea1], a ld hl, Data_b04a call Func_9a6d - ld hl, wcf17 + ld hl, wCurDeckCards ld de, wDuelTempList call CopyListFromHLToDE call Func_b131 @@ -5811,7 +5905,10 @@ Func_a288: ; a288 (2:6288) ; 0xa396 Data_a396: ; a396 (2:6396) - db $01, $05, $02, $00, $07, $0f, $00, $00, $00 + db $01, $05, $02, $00, $07 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL ; 0xa39f ; a = which card type filter @@ -5831,7 +5928,7 @@ Func_a39f: ; a39f (2:639f) ld a, $07 ld [wcecb], a lb de, 2, 5 - ld hl, wced0 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -5909,7 +6006,7 @@ GetDeckCardCounts: ; a412 (2:6412) ; where X is the current count of that card PrintCardSelectionList: ; a42d (2:642d) push bc - ld hl, wced0 + ld hl, wCardListCoords ld e, [hl] inc hl ld d, [hl] @@ -6386,8 +6483,8 @@ Func_a6a0: ; a6a0 (2:66a0) call Func_a596 ld a, $07 ld [wcecb], a - ld de, $204 - ld hl, wced0 + lb de, 2, 4 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -6420,7 +6517,7 @@ Func_a6ca: ; a6ca (2:66ca) .asm_a6ef ld de, $330 .asm_a6f2 - ld hl, wcfb9 + ld hl, wCurDeckName ld [hl], d inc hl ld [hl], e @@ -6430,7 +6527,7 @@ Func_a6ca: ; a6ca (2:66ca) Func_a6fa: ; a6fa (2:66fa) push bc - ld hl, wced0 + ld hl, wCardListCoords ld e, [hl] inc hl ld d, [hl] @@ -6441,10 +6538,10 @@ Func_a6fa: ; a6fa (2:66fa) ld a, [wcea1] or a jr z, .asm_a710 - ld a, $0c + ld a, SYM_CURSOR_U jr .asm_a712 .asm_a710 - ld a, $19 + ld a, SYM_BOX_TOP_R .asm_a712 call WriteByteToBGMap0 ld a, [wcea1] @@ -6475,12 +6572,12 @@ Func_a6fa: ; a6fa (2:66fa) ld a, [hl] cp $80 jr nz, .asm_a74c - ld hl, $6799 + ld hl, .text ld de, wc590 call CopyListFromHLToDE jr .asm_a751 .asm_a74c - ld a, $0d + ld a, 13 call CopyCardNameAndLevel .asm_a751 pop hl @@ -6515,22 +6612,24 @@ Func_a6fa: ; a6fa (2:66fa) pop de xor a ld [wcecd], a - ld a, $2f + ld a, SYM_CURSOR_D jr .asm_a790 .asm_a788 pop de ld a, $01 ld [wcecd], a - ld a, $1b + ld a, SYM_BOX_BTM_R .asm_a790 - ld b, $13 - ld c, $11 + ld b, 19 + ld c, 17 call WriteByteToBGMap0 pop bc ret -; 0xa799 - INCROM $a799, $a7a7 +.text + db "kkkkkkkkkkkkk" + db TX_END +; 0xa7a7 Func_a7a7: ; a7a7 (2:67a7) push bc @@ -6560,7 +6659,7 @@ Func_a7a7: ; a7a7 (2:67a7) jr nz, .asm_a7d2 ld a, SYM_0 .asm_a7d2 - ld hl, wcfb9 + 2 + ld hl, wCurDeckName + 2 ld [hl], TX_SYMBOL inc hl ld [hli], a @@ -6573,7 +6672,7 @@ Func_a7a7: ; a7a7 (2:67a7) xor a ld [hli], a ld [hl], a - ld hl, wcfb9 + ld hl, wCurDeckName pop de pop bc ret @@ -6583,8 +6682,8 @@ Func_a7a7: ; a7a7 (2:67a7) ld hl, wOnesAndTensPlace ld a, [hli] ld b, a - ld hl, wcfb9 + 2 - ld de, $334 + ld hl, wCurDeckName + 2 + lb de, 3, "FW3_E" ld [hl], d inc hl ld [hl], e @@ -6602,13 +6701,13 @@ Func_a7a7: ; a7a7 (2:67a7) xor a ld [hli], a ld [hl], a - ld hl, wcfb9 + 2 + ld hl, wCurDeckName + 2 pop de pop bc ret .phantom_card - ld hl, wcfb9 + 2 + ld hl, wCurDeckName + 2 ld [hl], $6c inc hl ld [hl], $6c @@ -6618,7 +6717,7 @@ Func_a7a7: ; a7a7 (2:67a7) xor a ld [hli], a ld [hl], a - ld hl, wcfb9 + ld hl, wCurDeckName pop de pop bc ret @@ -6787,7 +6886,7 @@ Func_a913: ; a913 (2:6913) .loop_input_1 call DoFrame call HandleMenuInput - jp nc, .loop_input_1 ; should be jr + jp nc, .loop_input_1 ; can be jr ldh a, [hCurMenuItem] cp $ff ret z @@ -6904,7 +7003,10 @@ Func_a913: ; a913 (2:6913) dw NULL ; function pointer if non-0 .data_aa0a - db $01, $04, $02, $00, $07, $0f, $00, $00, $00 + db $01, $04, $02, $00, $07 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL .Func_aa13 ld hl, wHandTempList @@ -7274,7 +7376,10 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ; 0xad0e Data_ad05: ; ad05 (2:6d05) - db $03, $03, $00, $04, $02, $0f, $00, $00, $00 + db $03, $03, $00, $04, $02 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL ; 0xad0e PrinterMenu_CardList: ; ad0e (2:6d0e) @@ -7315,7 +7420,7 @@ HandlePrinterMenu: ; ad51 (2:6d51) .loop ld hl, PrinterMenuParameters call InitializeMenuParameters - call Func_8d56 + call EmptyScreenAndLoadFontDuelAndHandCardsIcons lb de, 4, 0 lb bc, 12, 12 call DrawRegularTextBox @@ -7393,36 +7498,39 @@ PrinterMenu_PrintQuality: ; adb5 (2:6db5) ; 0xadf5 Data_adf5: ; adf5 (2:6df5) - db $05, $10, $00, $02, $05, $0f, $00, $00, $00 + db $05, $10, $00, $02, $05 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL ; 0xadfe Func_adfe: ; adfe (2:6dfe) push de - ld de, wcfb9 + ld de, wCurDeckName call CopyListFromHLToDEInSRAM pop de - ld hl, wcf17 - call Func_8cd4 - ld a, $09 - ld hl, wcebb + ld hl, wCurDeckCards + call CopyDeckFromSRAM + ld a, NUM_FILTERS + ld hl, wCardFilterCounts call ClearNBytesFromHL ld a, DECK_SIZE - ld [wcecc], a - ld hl, wcebb + ld [wTotalCardCount], a + ld hl, wCardFilterCounts ld [hl], a call Func_ae21 ret ; 0xae21 Func_ae21: ; ae21 (2:6e21) - call Func_a028 - call Func_a06e + call SortCurDeckCardsByID + call CreateCurDeckUniqueCardList xor a ld [wcea1], a .loop ld hl, Data_ae91 call Func_9a6d - ld a, [wced9] + ld a, [wNumUniqueCards] ld [wcfe6], a cp $05 jr c, .asm_ae3d @@ -7476,7 +7584,10 @@ Func_ae21: ; ae21 (2:6e21) ; 0xae91 Data_ae91: ; ae91 (2:6e91) - db $00, $03, $02, $00, $05, $0f, $00, $00, $00 + db $00, $03, $02, $00, $05 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL ; 0xae9a Func_ae9a: ; ae9a (2:6e9a) @@ -7497,8 +7608,8 @@ Func_ae9a: ; ae9a (2:6e9a) Func_aeb9: ; aeb9 (2:6eb9) call .Func_aec9 - ld de, $303 - ld hl, wced0 + lb de, 3, 3 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -7506,29 +7617,29 @@ Func_aeb9: ; aeb9 (2:6eb9) ret .Func_aec9 - call Func_8d56 + call EmptyScreenAndLoadFontDuelAndHandCardsIcons call Func_aed3 call EnableLCD ret ; 0xaed3 Func_aed3: ; aed3 (2:6ed3) - ld a, [wcfb9] + ld a, [wCurDeckName] or a ret z ld de, $1 call InitTextPrinting - ld a, [wceb1] + ld a, [wCurDeck] inc a ld hl, wc590 call ConvertToNumericalDigits - ld [hl], $77 + ld [hl], "FW0_·" inc hl ld [hl], TX_END ld hl, wc590 call ProcessText - ld hl, wcfb9 + ld hl, wCurDeckName ld de, wc590 call CopyListFromHLToDE ld hl, wc590 @@ -7538,7 +7649,7 @@ Func_aed3: ; aed3 (2:6ed3) add hl, bc ld d, h ld e, l - ld hl, Data_92a7 + ld hl, DeckNameSuffix call CopyListFromHLToDE ld de, $301 ld hl, wc590 @@ -7582,7 +7693,7 @@ Func_af1d: ; af1d (2:6f1d) ret .asm_af6b - ld hl, wcf17 + ld hl, wCurDeckCards ld de, wDuelTempList call CopyListFromHLToDE xor a @@ -7590,7 +7701,7 @@ Func_af1d: ; af1d (2:6f1d) bank1call Func_756c ret c call EnableSRAM - ld hl, wcf17 + ld hl, wCurDeckCards call Func_910a call DisableSRAM call SaveGame @@ -7688,7 +7799,10 @@ Func_af98: ; af98 (2:6f98) ret Data_b04a: ; b04a (2:704a) - db $01, $03, $02, $00, $05, $0f, $00, $00, $00 + db $01, $03, $02, $00, $05 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL Func_b053: ; b053 (2:7053) ld hl, hffb0 @@ -7723,7 +7837,7 @@ Func_b088: ; b088 (2:7088) ld a, $05 ld [wcecb], a lb de, 2, 3 - ld hl, wced0 + ld hl, wCardListCoords ld [hl], e inc hl ld [hl], d @@ -7769,8 +7883,8 @@ Func_b088: ; b088 (2:7088) ld a, b cp $ff jr z, .asm_b0fc - and $20 - cp $20 + and FILTER_ENERGY + cp FILTER_ENERGY jr z, .asm_b0f5 ld a, c cp b @@ -7852,7 +7966,7 @@ Func_b141: ; b141 (2:7141) .Func_b167 call Set_OBJ_8x8 call Func_8d78 - ld de, $0 + lb de, 0, 0 lb bc, 20, 13 call DrawRegularTextBox ret @@ -8030,7 +8144,7 @@ Func_b29f: ; b29f (2:729f) ld c, a inc a or $80 - ld [wceb1], a + ld [wCurDeck], a sla c ld b, $00 ld hl, wd00d @@ -8052,7 +8166,7 @@ Func_b29f: ; b29f (2:729f) ld a, $01 call PlaySFXConfirmOrCancel - call Func_8e1f + call HandleDeckConfirmationMenu ld a, [wd087] ld [wcea1], a call Func_b379 @@ -8247,9 +8361,9 @@ Func_b424: ; b424 (2:7424) ld hl, wDefaultText inc a call ConvertToNumericalDigits - ld [hl], $77 + ld [hl], "FW0_·" inc hl - ld [hl], $00 + ld [hl], TX_END call InitTextPrinting ld hl, wDefaultText call ProcessText @@ -8292,7 +8406,7 @@ Func_b424: ; b424 (2:7424) pop bc ld hl, wDefaultText jr c, .asm_b482 - ld de, $35f ; "○" + lb de, 3, "FW3_○" jr .asm_b4c2 .asm_b482 @@ -8301,11 +8415,11 @@ Func_b424: ; b424 (2:7424) call Func_b625 jr c, .asm_b490 pop bc - ld de, $360 ; "❄" + lb de, 3, "FW3_❄" jr .asm_b4c2 .asm_b490 - ld de, $6c ; "✕" + lb de, 0, "FW0_✕" call Func_22ca pop bc pop de @@ -8448,7 +8562,7 @@ Func_b545: ; b545 (2:7545) Func_b592: ; b592 (2:7592) ld a, $ff - call Func_9168 + call DrawDecksScreen xor a .asm_b598 ld hl, DeckMachineMenuParameters @@ -8457,18 +8571,18 @@ Func_b592: ; b592 (2:7592) call DrawWideTextBox_PrintText .loop_input call DoFrame - call Func_8dea + call HandleStartButtonInDeckSelectionMenu jr c, .asm_b598 call HandleMenuInput - jp nc, .loop_input ; should be jr + jp nc, .loop_input ; can be jr ldh a, [hCurMenuItem] cp $ff ret z - ld [wceb1], a - call Func_8ff2 + ld [wCurDeck], a + call CheckIfCurDeckIsValid jp nc, .Func_b5c8 - call Func_8fe8 - ld a, [wceb1] + call PrintThereIsNoDeckHereText + ld a, [wCurDeck] jr .asm_b598 .Func_b5c8 @@ -8691,7 +8805,10 @@ Func_b6ca: ; b6ca (2:76ca) ; 0xb6fb Data_b6fb: ; b6fb (2:76fb) - db $01, $02, $02, $00, $05, $0f, $00, $00, $00 + db $01, $02, $02, $00, $05 + db SYM_CURSOR_R + db SYM_SPACE + dw NULL Func_b704: ; b704 (2:7704) ld a, [wcea1] @@ -8730,7 +8847,7 @@ Func_b738: ; b738 (2:7738) call DrawWideTextBox_WaitForInput call Func_b644 ld a, $ff - call Func_9168 + call DrawDecksScreen xor a .init_menu_params ld hl, DeckMachineMenuParameters @@ -8739,10 +8856,10 @@ Func_b738: ; b738 (2:7738) call DrawWideTextBox_PrintText .loop_input call DoFrame - call Func_8dea + call HandleStartButtonInDeckSelectionMenu jr c, .init_menu_params call HandleMenuInput - jp nc, .loop_input ; should be jr + jp nc, .loop_input ; can be jr ldh a, [hCurMenuItem] cp $ff jr nz, .asm_b76c @@ -8751,11 +8868,11 @@ Func_b738: ; b738 (2:7738) ret .asm_b76c - ld [wceb1], a + ld [wCurDeck], a ldtx hl, DismantleThisDeckText call YesOrNoMenuWithText jr nc, .dismantle - ld a, [wceb1] + ld a, [wCurDeck] jr .init_menu_params .dismantle @@ -8774,8 +8891,8 @@ Func_b738: ; b738 (2:7738) call ClearNBytesFromHL call DisableSRAM ld a, $ff - call Func_9168 - ld a, [wceb1] + call DrawDecksScreen + ld a, [wCurDeck] ld hl, DeckMachineMenuParameters call InitializeMenuParameters call DrawCursor2 @@ -8785,9 +8902,9 @@ Func_b738: ; b738 (2:7738) xor a ld [wTxRam2 + 0], a ld [wTxRam2 + 1], a - ld hl, $26a + ldtx hl, DismantledDeckText call DrawWideTextBox_WaitForInput - ld a, [wceb1] + ld a, [wCurDeck] ret ; 0xb7c6 @@ -8862,9 +8979,9 @@ Func_b7c6: ; b7c6 (2:77c6) call DisableSRAM ld a, $ff - call Func_9168 + call DrawDecksScreen ld a, [wd08a + $17] - ld [wceb1], a + ld [wCurDeck], a ld hl, DeckMachineMenuParameters call InitializeMenuParameters call DrawCursor2 @@ -8886,7 +9003,7 @@ Func_b7c6: ; b7c6 (2:77c6) Func_b87d: ; b87d (2:787d) farcall Func_1ba9a call Func_b644 - call Func_9168 + call DrawDecksScreen ldtx hl, DismantleTheseDecksText call YesOrNoMenuWithText jr nc, .yes @@ -8923,7 +9040,7 @@ Func_b87d: ; b87d (2:787d) .asm_b8c7 call DisableSRAM ld a, [wd0a6] - call Func_9168 + call DrawDecksScreen call Func_b664 ldtx hl, DismantledTheDeckText call DrawWideTextBox_WaitForInput @@ -8948,19 +9065,19 @@ Func_b87d: ; b87d (2:787d) Func_b8f4: ; b8f4 (2:78f4) ld a, [wd088] - ld [wceb1], a + ld [wCurDeck], a call Func_b611 ld hl, $18 add hl, de - ld de, wcf17 + ld de, wCurDeckCards ld b, DECK_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM xor a ld [wcf53], a - call Func_a028 - call Func_a06e + call SortCurDeckCardsByID + call CreateCurDeckUniqueCardList ld a, $ff call Func_b644 call Func_a3ca @@ -8975,7 +9092,7 @@ Func_b8f4: ; b8f4 (2:78f4) push bc push de push hl - ld hl, wcf17 + ld hl, wCurDeckCards call Func_b960 pop hl pop de @@ -9088,14 +9205,14 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) call Func_b611 ld hl, $18 add hl, de - ld de, wcf17 + ld de, wCurDeckCards ld b, DECK_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM xor a ld [wcf53], a - call Func_a028 + call SortCurDeckCardsByID ld a, [wd088] bank1call Func_7580 call Func_b379 @@ -9161,7 +9278,7 @@ Func_ba25: ; ba25 (2:7a25) ld c, a inc a or $80 - ld [wceb1], a + ld [wCurDeck], a sla c ld b, $0 ld hl, wd00d @@ -9171,7 +9288,7 @@ Func_ba25: ; ba25 (2:7a25) ld h, [hl] ld l, a push hl - ld bc, $0018 + ld bc, $18 add hl, bc ld d, h ld e, l @@ -9183,7 +9300,7 @@ Func_ba25: ; ba25 (2:7a25) ld a, $1 call PlaySFXConfirmOrCancel call Func_b653 - call Func_8e1f + call HandleDeckConfirmationMenu call Func_b644 ld a, [wd087] ld [wcea1], a @@ -9250,7 +9367,7 @@ Func_ba25: ; ba25 (2:7a25) ld [wd086], a add b ld c, a - ld [wceb1], a + ld [wCurDeck], a sla c ld b, $0 ld hl, wd00d @@ -9270,7 +9387,7 @@ Func_ba25: ; ba25 (2:7a25) ld h, [hl] ld l, a push hl - ld bc, $0018 + ld bc, $18 add hl, bc ld d, h ld e, l diff --git a/src/text/text2.asm b/src/text/text2.asm index 1cba1e0..933f8ff 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1894,7 +1894,7 @@ ChooseADeckToDismantleText: ; 3bf46 (e:7f46) text "Choose a deck to dismantle." done -Text026a: ; 3bf63 (e:7f63) +DismantledDeckText: ; 3bf63 (e:7f63) text "Dismantled" line "" text "." diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 02d028b..c656626 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -619,7 +619,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer DeletedTheConfigurationForText ; 0x0267 textpointer YouMayOnlyCarry4DecksText ; 0x0268 textpointer ChooseADeckToDismantleText ; 0x0269 - textpointer Text026a ; 0x026a + textpointer DismantledDeckText ; 0x026a textpointer Text026b ; 0x026b textpointer ThisDeckCanOnlyBeBuiltIfYouDismantleText ; 0x026c textpointer YouDoNotOwnAllCardsNeededToBuildThisDeckText ; 0x026d diff --git a/src/wram.asm b/src/wram.asm index 50e0894..e2db894 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1917,7 +1917,16 @@ wNamingScreenCursorY:: ; cea4 ds $1 wcea5:: ; cea5 - ds $4 + ds $1 + +wcea6:: ; cea6 + ds $1 + +wcea7:: ; cea7 + ds $1 + +wcea8:: ; cea8 + ds $1 wNamingScreenKeyboardHeight:: ; cea9 ds $1 @@ -1940,20 +1949,18 @@ wCheckMenuCursorXPosition:: ; ceaf wCheckMenuCursorYPosition:: ; ceb0 ds $1 -wceb1:: ; ceb1 +; deck selected by the player in the Decks screen +wCurDeck:: ; ceb1 ds $1 -wceb2:: ; ceb2 - ds $1 - -wceb3:: ; ceb3 - ds $1 - -wceb4:: ; ceb4 - ds $1 - -wceb5:: ; ceb5 - ds $1 +; each of these are a boolean to +; represent whether a given deck +; that the player has is a valid deck +wDecksValid:: +wDeck1Valid:: ds $1 ; ceb2 +wDeck2Valid:: ds $1 ; ceb3 +wDeck3Valid:: ds $1 ; ceb4 +wDeck4Valid:: ds $1 ; ceb5 ; used to store the tens digit and ; ones digit of a value for printing @@ -1965,8 +1972,11 @@ wOnesAndTensPlace:: ; ceb6 ds $3 -wcebb:: ; cebb - ds $9 +; each of these stores the card count +; of each filter in the deck building screen +; the order follows CardTypeFilters +wCardFilterCounts:: ; cebb + ds NUM_FILTERS wcec4:: ; cec4 ds $7 @@ -1974,7 +1984,7 @@ wcec4:: ; cec4 wcecb:: ; cecb ds $1 -wcecc:: ; cecc +wTotalCardCount:: ; cecc ds $1 wcecd:: ; cecd @@ -1983,7 +1993,9 @@ wcecd:: ; cecd wcece:: ; cece ds $2 -wced0:: ; ced0 +; holds y and x coordinates (in that order) +; of start of card list (top-left corner) +wCardListCoords:: ; ced0 ds $2 wced2:: ; ced2 @@ -2009,7 +2021,8 @@ wced7:: ; ced7 wced8:: ; ced8 ds $1 -wced9:: ; ced9 +; stores how many different cards there are in a deck +wNumUniqueCards:: ; ced9 ds $1 ; stores the list of all card IDs that filtered by its card type @@ -2026,7 +2039,7 @@ wcf16:: ; cf16 ds $1 ; used in bank2, probably related to wTempHandCardList (another temp list?) -wcf17:: ; cf17 +wCurDeckCards:: ; cf17 ds DECK_SIZE wcf53:: ; cf53 @@ -2045,13 +2058,24 @@ wTempHandCardList:: ; cf68 ds $15 -wcfb9:: ; cfb9 - ds $14 - - ds $4 +; name of the selected deck +wCurDeckName:: ; cfb9 + ds DECK_NAME_SIZE wcfd1:: ; cfd1 - ds $7 + ds $1 + +wcfd2:: ; cfd2 + ds $1 + +wcfd3:: ; cfd3 + ds $1 + +wcfd4:: ; cfd4 + ds $2 + +wcfd6:: ; cfd6 + ds $2 wcfd8:: ; cfd8 ds $2 -- cgit v1.2.3 From 516cd6502eb3209a40e45b33aa14d7a4e503ca24 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Mon, 3 May 2021 00:28:20 +0100 Subject: Document/label bank2 and WRAM related stuff, add menu related constants --- src/constants/card_data_constants.asm | 11 +- src/constants/menu_constants.asm | 15 + src/engine/bank02.asm | 1602 +++++++++++++++++++-------------- src/engine/bank03.asm | 2 +- src/engine/bank06.asm | 62 +- src/macros/wram.asm | 5 + src/sram.asm | 104 ++- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 92 +- 10 files changed, 1095 insertions(+), 802 deletions(-) (limited to 'src') diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index cd7d401..50fdb52 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -8,9 +8,14 @@ CARD_NOT_OWNED EQU 1 << CARD_NOT_OWNED_F CARD_COUNT_MASK EQU $7f ; sDeck* and generic deck constants -NUM_DECKS EQU 4 -DECK_NAME_SIZE EQU 24 -DECK_SIZE EQU 60 +NUM_DECKS EQU 4 +DECK_NAME_SIZE EQU 24 +DECK_NAME_SIZE_WO_SUFFIX EQU 21 ; name part before "deck" +DECK_SIZE EQU 60 +DECK_STRUCT_SIZE EQU DECK_NAME_SIZE + DECK_SIZE +DECK_CONFIG_BUFFER_SIZE EQU 80 +MAX_NUM_SAME_NAME_CARDS EQU 4 +MAX_UNNAMED_DECK_NUM EQU 999 ; card data offsets (data/cards.asm and card_data_struct) diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm index 47582a2..75dd568 100644 --- a/src/constants/menu_constants.asm +++ b/src/constants/menu_constants.asm @@ -12,3 +12,18 @@ FILTER_TRAINER EQUS "TYPE_TRAINER" FILTER_ENERGY EQU $20 NUM_FILTERS EQU 9 + +MAX_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7 +MAX_FILTERED_LIST_VISIBLE_CARDS EQU 6 + +; deck flags + const_def + const DECK_1_F ; $0 + const DECK_2_F ; $1 + const DECK_3_F ; $2 + const DECK_4_F ; $3 + +ALL_DECKS EQU $ff + +NUM_DECK_SAVE_MACHINE_SLOTS EQU 60 +NUM_DECK_MACHINE_SLOTS EQU 5 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 7176518..f8297bd 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2155,6 +2155,7 @@ CopyDeckFromSRAM: ; 8cd4 (2:4cd4) ret ; 0x8ce7 +; clears some WRAM addresses Func_8ce7: ; 8ce7 (2:4ce7) xor a ld hl, wceda @@ -2162,24 +2163,26 @@ Func_8ce7: ; 8ce7 (2:4ce7) add hl, bc ld [hl], a ; wcf16 ld hl, wCurDeckCards - ld bc, $50 + ld bc, DECK_CONFIG_BUFFER_SIZE add hl, bc - ld [hl], a + ld [hl], a ; wCurDeckCardsTerminator ret ; 0x8cf9 +; inits some SRAM addresses Func_8cf9: ; 8cf9 (2:4cf9) call EnableSRAM xor a ld hl, sb703 ld [hli], a - inc a + inc a ; $1 ld [hli], a ld [hli], a ld [hl], a - ld [sb701], a + ld [sUnnamedDeckCounter], a call DisableSRAM -; fallthrough +; ret missing +; unintentional fallthrough ; loads the Hard Cards icon gfx to v0Tiles2 LoadHandCardsIcon: ; 8d0b (2:4d0b) @@ -2228,9 +2231,14 @@ Func_8d78: ; 8d78 (2:4d78) ret ; 0x8d9d -; copies 7 bytes from hl to wcfd1 -Func_8d9d: ; 8d9d (2:4d9d) - ld de, wcfd1 +; inits the following deck building params from hl: +; wMaxNumCardsAllowed +; wSameNameCardsLimit +; wIncludeCardsInDeck +; wDeckConfigurationMenuHandlerFunction +; wDeckConfigurationMenuTransitionTable +InitDeckBuildingParams: ; 8d9d (2:4d9d) + ld de, wMaxNumCardsAllowed ld b, $7 .loop ld a, [hli] @@ -2240,37 +2248,39 @@ Func_8d9d: ; 8d9d (2:4d9d) jr nz, .loop ret -Data_8da9: ; 8da9 (2:4da9) - db $50, $04, $01 +DeckBuildingParams: ; 8da9 (2:4da9) + db DECK_CONFIG_BUFFER_SIZE ; max number of cards + db MAX_NUM_SAME_NAME_CARDS ; max number of same name cards + db TRUE ; whether to include deck cards dw HandleDeckConfigurationMenu dw DeckConfigurationMenu_TransitionTable ; 0x8db0 -Func_8db0: ; 8db0 (2:4db0) - ld hl, Data_8da9 - call Func_8d9d +DeckSelectionMenu: ; 8db0 (2:4db0) + ld hl, DeckBuildingParams + call InitDeckBuildingParams ld a, $ff call DrawDecksScreen xor a -; fallthrough -Func_8dbc: ; 8dbc (2:4dbc) +.init_menu_params ld hl, .DeckSelectionMenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText .loop_input call DoFrame - jr c, Func_8dbc ; reinit menu parameters + jr c, .init_menu_params ; reinit menu parameters call HandleStartButtonInDeckSelectionMenu - jr c, Func_8dbc + jr c, .init_menu_params call HandleMenuInput jr nc, .loop_input ldh a, [hCurMenuItem] cp $ff - ret z + ret z ; B btn returns +; A btn pressed on a deck ld [wCurDeck], a - jp Func_8e42 + jp DeckSelectionSubMenu .DeckSelectionMenuParameters db 1, 2 ; cursor x, cursor y @@ -2315,7 +2325,7 @@ HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea) ld a, [wCurDeck] scf ret - +; 0x8e1f HandleDeckConfirmationMenu: ; 8e1f (2:4e1f) ; copy deck name @@ -2339,27 +2349,37 @@ HandleDeckConfirmationMenu: ; 8e1f (2:4e1f) ret ; 0x8e42 -Func_8e42: ; 8e42 (2:4e42) +; handles the submenu when selecting a deck +; (Modify Deck, Select Deck, Change Name and Cancel) +DeckSelectionSubMenu: ; 8e42 (2:4e42) call DrawWideTextBox ld hl, DeckSelectionData call PlaceTextItems call ResetCheckMenuCursorPositionAndBlink -.asm_8e4e +.loop_input call DoFrame call HandleCheckMenuInput - jp nc, .asm_8e4e + jp nc, .loop_input cp $ff - jr nz, .asm_8e64 + jr nz, .option_selected +; B btn pressed +; erase cursor and go back +; to deck selection handling call EraseCheckMenuCursor ld a, [wCurDeck] - jp Func_8dbc -.asm_8e64 + jp DeckSelectionMenu.init_menu_params + +.option_selected ld a, [wCheckMenuCursorXPosition] or a - jp nz, Func_8f8a + jp nz, DeckSelectionSubMenu_SelectOrCancel ld a, [wCheckMenuCursorYPosition] or a - jp nz, .asm_8ecf + jp nz, .ChangeName + +; Modify Deck +; read deck from SRAM +; TODO call GetPointerToDeckCards ld e, l ld d, h @@ -2371,13 +2391,14 @@ Func_8e42: ; 8e42 (2:4e42) ld de, wCurDeckName call GetPointerToDeckName call CopyListFromHLToDEInSRAM + call Func_9345 jr nc, .asm_8ec4 call EnableSRAM ld hl, wCurDeckCards - call Func_910a + call DecrementDeckCardsInCollection call GetPointerToDeckCards - call Func_9152 + call AddDeckToCollection ld e, l ld d, h ld hl, wCurDeckCards @@ -2397,25 +2418,26 @@ Func_8e42: ; 8e42 (2:4e42) ld a, [hl] call DisableSRAM or a - jr z, .asm_8edb + jr z, .get_input_deck_name .asm_8ec4 ld a, $ff call DrawDecksScreen ld a, [wCurDeck] - jp Func_8dbc -.asm_8ecf + jp DeckSelectionMenu.init_menu_params + +.ChangeName call CheckIfCurDeckIsValid - jp nc, .asm_8edb + jp nc, .get_input_deck_name call PrintThereIsNoDeckHereText - jp Func_8dbc -.asm_8edb + jp DeckSelectionMenu.init_menu_params +.get_input_deck_name ld a, 20 ld hl, wCurDeckName call ClearNBytesFromHL ld de, wCurDeckName call GetPointerToDeckName call CopyListFromHLToDEInSRAM - call Func_8f05 + call InputCurDeckName call GetPointerToDeckName ld d, h ld e, l @@ -2424,28 +2446,28 @@ Func_8e42: ; 8e42 (2:4e42) ld a, $ff call DrawDecksScreen ld a, [wCurDeck] - jp Func_8dbc + jp DeckSelectionMenu.init_menu_params -Func_8f05: ; 8f05 (2:4f05) +; gets current deck's name from user input +InputCurDeckName: ; 8f05 (2:4f05) ld a, [wCurDeck] or a - jr nz, .asm_8f10 - ; it refers to a data in the other bank without any bank desc. + jr nz, .deck_2 ld hl, Deck1Data - jr .asm_8f23 -.asm_8f10 + jr .got_deck_ptr +.deck_2 dec a - jr nz, .asm_8f18 + jr nz, .deck_3 ld hl, Deck2Data - jr .asm_8f23 -.asm_8f18 + jr .got_deck_ptr +.deck_3 dec a - jr nz, .asm_8f20 + jr nz, .deck_4 ld hl, Deck3Data - jr .asm_8f23 -.asm_8f20 + jr .got_deck_ptr +.deck_4 ld hl, Deck4Data -.asm_8f23 +.got_deck_ptr ld a, MAX_DECK_NAME_LENGTH lb bc, 4, 1 ld de, wCurDeckName @@ -2453,11 +2475,17 @@ Func_8f05: ; 8f05 (2:4f05) ld a, [wCurDeckName] or a ret nz - call Func_8f38 + ; empty name + call .UnnamedDeck ret -Func_8f38: ; 8f38 (2:4f38) - ld hl, sb701 +; handles the naming of unnamed decks +; inputs as the deck name "DECK XXX" +; where XXX is the current unnamed deck counter +.UnnamedDeck +; read the current unnamed deck number +; and convert it to text + ld hl, sUnnamedDeckCounter call EnableSRAM ld a, [hli] ld h, [hl] @@ -2465,20 +2493,21 @@ Func_8f38: ; 8f38 (2:4f38) ld l, a ld de, wDefaultText call TwoByteNumberToText + ld hl, wCurDeckName ld [hl], $6 inc hl - ld [hl], $44 + ld [hl], "D" inc hl - ld [hl], $65 + ld [hl], "e" inc hl - ld [hl], $63 + ld [hl], "c" inc hl - ld [hl], $6b + ld [hl], "k" inc hl - ld [hl], $20 + ld [hl], " " inc hl - ld de, wc592 + ld de, wDefaultText + 2 ld a, [de] inc de ld [hli], a @@ -2489,39 +2518,53 @@ Func_8f38: ; 8f38 (2:4f38) ld [hli], a xor a ld [hl], a - ld hl, sb701 + +; increment the unnamed deck counter + ld hl, sUnnamedDeckCounter call EnableSRAM ld e, [hl] inc hl ld d, [hl] - ld a, $3 +; capped at 999 + ld a, HIGH(MAX_UNNAMED_DECK_NUM) cp d - jr nz, .asm_8f82 - ld a, $e7 + jr nz, .incr_counter + ld a, LOW(MAX_UNNAMED_DECK_NUM) cp e - jr nz, .asm_8f82 - ld de, $0000 -.asm_8f82 + jr nz, .incr_counter + ; reset counter + ld de, 0 +.incr_counter inc de ld [hl], d dec hl ld [hl], e call DisableSRAM ret +; 0x8f8a -Func_8f8a: ; 8f8a (2:4f8a) +; handle deck selection sub-menu +; the option is either "Select Deck" or "Cancel" +; depending on the cursor Y pos +DeckSelectionSubMenu_SelectOrCancel: ; 8f8a (2:4f8a) ld a, [wCheckMenuCursorYPosition] or a - jp nz, Func_9026 + jp nz, CancelDeckSelectionSubMenu + +; select deck call CheckIfCurDeckIsValid - jp nc, Func_8f9d + jp nc, .SelectDeck + ; invalid deck call PrintThereIsNoDeckHereText - jp Func_8dbc + jp DeckSelectionMenu.init_menu_params -Func_8f9d: ; 8f9d (2:4f9d) +.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, $3 ld l, a call HtimesL @@ -2532,14 +2575,19 @@ Func_8f9d: ; 8f9d (2:4f9d) 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 call DisableSRAM call DrawHandCardsTileOnCurDeck + +; print " was chosen as the dueling deck!" call GetPointerToDeckName call EnableSRAM - call Func_9253 + call CopyDeckName call DisableSRAM xor a ld [wTxRam2], a @@ -2547,7 +2595,8 @@ Func_8f9d: ; 8f9d (2:4f9d) ldtx hl, ChosenAsDuelingDeckText call DrawWideTextBox_WaitForInput ld a, [wCurDeck] - jp Func_8dbc + jp DeckSelectionMenu.init_menu_params +; 0x8fe8 PrintThereIsNoDeckHereText: ; 8fe8 (2:4fe8) ldtx hl, ThereIsNoDeckHereText @@ -2572,7 +2621,7 @@ CheckIfCurDeckIsValid: ; 8ff2 (2:4ff2) INCROM $9001, $9026 -Func_9026: ; 9026 (2:5026) +CancelDeckSelectionSubMenu: ; 9026 (2:5026) ret DeckSelectionData: ; 9027 (2:5027) @@ -2759,14 +2808,17 @@ PlaySFXConfirmOrCancel: ; 90fb (2:50fb) pop af ret -Func_910a: ; 910a (2:510a) +; goes through whole deck in hl +; for each card ID, goes to its corresponding +; entry in sCardCollection and decrements its count +DecrementDeckCardsInCollection: ; 910a (2:510a) push hl ld b, $0 ld d, DECK_SIZE -.asm_910f +.loop_deck ld a, [hli] or a - jr z, .asm_911e + jr z, .done ld c, a push hl ld hl, sCardCollection @@ -2774,17 +2826,24 @@ Func_910a: ; 910a (2:510a) dec [hl] pop hl dec d - jr nz, .asm_910f -.asm_911e + jr nz, .loop_deck +.done pop hl ret ; 0x9120 -Func_9120: ; 9120 (2:5120) +; like AddDeckToCollection, but takes care to +; check if increasing the collection count would +; go over MAX_AMOUNT_OF_CARD and caps it +; this is because it's used within Gift Center, +; so we cannot assume that the deck configuration +; won't make it go over MAX_AMOUNT_OF_CARD +; hl = deck configuration, with cards to add +AddGiftCenterDeckCardsToCollection: ; 9120 (2:5120) push hl - ld b, $00 + ld b, $0 ld d, DECK_SIZE -.asm_9125 +.loop_deck ld a, [hli] or a jr z, .done @@ -2792,42 +2851,46 @@ Func_9120: ; 9120 (2:5120) push hl push de push bc - ld a, $ff - call Func_a3ca + ld a, ALL_DECKS + call CreateCardCollectionListWithDeckCards pop bc pop de ld hl, wTempCardCollection add hl, bc ld a, [hl] - cp $63 - jr z, .asm_914c - call EnableSRAM + cp MAX_AMOUNT_OF_CARD + jr z, .next_card ; capped + call EnableSRAM ; no DisableSRAM ld hl, sCardCollection add hl, bc ld a, [hl] - cp $80 - jr nz, .asm_914b + cp CARD_NOT_OWNED + jr nz, .incr + ; not owned xor a ld [hl], a -.asm_914b +.incr inc [hl] -.asm_914c +.next_card pop hl dec d - jr nz, .asm_9125 + jr nz, .loop_deck .done pop hl ret ; 0x9152 -Func_9152: ; 9152 (2:5152) +; adds all cards in deck in hl to player's collection +; assumes SRAM is enabled +; hl = pointer to deck cards +AddDeckToCollection: ; 9152 (2:5152) push hl ld b, $0 ld d, DECK_SIZE -.asm_9157 +.loop_deck ld a, [hli] or a - jr z, .asm_9166 + jr z, .done ld c, a push hl ld hl, sCardCollection @@ -2835,8 +2898,8 @@ Func_9152: ; 9152 (2:5152) inc [hl] pop hl dec d - jr nz, .asm_9157 -.asm_9166 + jr nz, .loop_deck +.done pop hl ret @@ -2966,7 +3029,10 @@ DeckNameMenuData: ; 9242 (2:5242) db $ff ; 0x9253 -Func_9253: ; 9253 (2:5253) +; copies text from hl to wDefaultText +; with " deck" appended to the end +; hl = ptr to deck name +CopyDeckName: ; 9253 (2:5253) ld de, wDefaultText call CopyListFromHLToDE ld hl, wDefaultText @@ -3021,7 +3087,7 @@ PrintDeckName: ; 926e (2:526e) DeckNameSuffix: ; 92a7 (2:52a7) db " deck" - db TX_END + done ; copies a $00-terminated list from hl to de CopyListFromHLToDE: ; 92ad (2:52ad) @@ -3040,31 +3106,41 @@ CopyListFromHLToDEInSRAM: ; 92b4 (2:52b4) ret ; 0x92be -Func_92be: ; 92be (2:52be) +; appends text in hl to wDefaultText +; then adds "deck" to the end +; returns carry if deck has no cards +; hl = text to append +; de = input to InitTextPrinting +AppendDeckName: ; 92be (2:52be) push hl call CheckIfDeckHasCards pop hl - ret c + ret c ; no cards + push de + ; append the text from hl ld de, wDefaultText call CopyListFromHLToDEInSRAM + + ; get string length (up to DECK_NAME_SIZE_WO_SUFFIX) ld hl, wDefaultText call GetTextLengthInTiles ld a, c - cp 21 - jr c, .asm_92d8 - ld c, 21 -.asm_92d8 + cp DECK_NAME_SIZE_WO_SUFFIX + jr c, .got_len + ld c, DECK_NAME_SIZE_WO_SUFFIX +.got_len ld b, $0 ld hl, wDefaultText add hl, bc ld d, h ld e, l + ; append "deck" starting from the given length ld hl, .text_start ld b, .text_end - .text_start call CopyNBytesFromHLToDE - xor a - ld [wc5aa], a + xor a ; TX_END + ld [wDefaultText + DECK_NAME_SIZE + 2], a pop de ld hl, wDefaultText call InitTextPrinting @@ -3120,6 +3196,7 @@ DrawHandCardsTileAtDE: ; 9339 (2:5339) lb bc, 2, 2 call FillRectangle ret +; 0x9345 Func_9345: ; 9345 (2:5345) call Func_8ce7 @@ -3129,8 +3206,8 @@ Func_9345: ; 9345 (2:5345) xor a ld [wcea1], a - ld [wCurCardTypeFilter], a - call Func_993d + ld [wCurCardTypeFilter], a ; FILTER_GRASS + call PrintFilteredCardList .skip_draw ld hl, Data_9667 @@ -3144,33 +3221,36 @@ Func_9345: ; 9345 (2:5345) call PlaySFXConfirmOrCancel call ConfirmDeckConfiguration ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a + ld [wTempCardTypeFilter], a jr .wait_input + .no_start_btn ld a, [wCurCardTypeFilter] ld b, a - ld a, [wNamingScreenCursorY] + ld a, [wTempCardTypeFilter] cp b jr z, .check_down_btn + ; need to refresh the filtered card list ld [wCurCardTypeFilter], a ld hl, wcea1 ld [hl], $00 - call Func_993d - ld a, $09 - ld [wNamingScreenKeyboardHeight], a + call PrintFilteredCardList + ld a, NUM_FILTERS + ld [wCardListNumCursorPositions], a .check_down_btn ldh a, [hDPadHeld] and D_DOWN jr z, .no_down_btn - call Func_9ad7 + call ConfirmSelectionAndReturnCarry jr .asm_93a9 + .no_down_btn call Func_9a83 jr nc, .wait_input ld a, [hffb3] cp $ff - jp z, Func_9461 + jp z, OpenDeckConfigurationMenu .asm_93a9 ld a, [wceae] or a @@ -3181,10 +3261,10 @@ Func_9345: ; 9345 (2:5345) call Func_9a6d ld a, [wceae] ld [wcfe6], a - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_93c5 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a .asm_93c5 ld hl, PrintDeckBuildingCardList ld d, h @@ -3202,7 +3282,7 @@ Func_9345: ; 9345 (2:5345) jr z, .asm_93f0 ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced5], a call ConfirmDeckConfiguration ld a, [wced5] @@ -3216,9 +3296,9 @@ Func_9345: ; 9345 (2:5345) .asm_93fc ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld [wcfdf], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld de, wceda ld hl, wcfd8 @@ -3230,19 +3310,20 @@ Func_9345: ; 9345 (2:5345) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a - call Func_9b20 + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible call PrintDeckBuildingCardList ld hl, Data_9670 call Func_9a6d ld a, [wcfdf] - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jr .asm_93d4 + .asm_9442 - call Func_9c0e - ld a, [wNamingScreenCursorY] + call DrawListCursor_Invisible + ld a, [wCardListCursorPos] ld [wced4], a ld a, [hffb3] cp $ff @@ -3250,14 +3331,14 @@ Func_9345: ; 9345 (2:5345) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a + ld [wTempCardTypeFilter], a jp .wait_input ; 0x9461 -Func_9461: ; 9461 (2:5461) +OpenDeckConfigurationMenu: ; 9461 (2:5461) xor a ld [wYourOrOppPlayAreaCurPosition], a - ld de, wcfd6 + ld de, wDeckConfigurationMenuTransitionTable ld hl, wMenuInputTablePointer ld a, [de] ld [hli], a @@ -3266,10 +3347,10 @@ Func_9461: ; 9461 (2:5461) ld [hl], a ld a, $ff ld [wDuelInitialPrizesUpperBitsSet], a -.asm_9475 +.skip_init xor a ld [wCheckMenuCursorBlinkCounter], a - ld hl, wcfd4 + ld hl, wDeckConfigurationMenuHandlerFunction ld a, [hli] ld h, [hl] ld l, a @@ -3295,9 +3376,9 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) .draw_icons call DrawCardTypeIconsAndPrintCardCounts ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ld a, [wCurCardTypeFilter] - call Func_993d + call PrintFilteredCardList jp Func_9345.skip_draw .asm_94b5 @@ -3308,7 +3389,7 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) pop af ld hl, .func_table call JumpToFunctionInTable - jr Func_9461.asm_9475 + jr OpenDeckConfigurationMenu.skip_init .func_table dw ConfirmDeckConfiguration ; Confirm @@ -3333,12 +3414,12 @@ ConfirmDeckConfiguration: ; 94d3 (2:54d3) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a - call Func_9b20 + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible ld a, [wCurCardTypeFilter] - call Func_993d + call PrintFilteredCardList ld a, [wced6] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ret ; 0x9505 @@ -3382,7 +3463,7 @@ SaveDeckConfiguration: ; 951a (2:551a) ldtx hl, SaveThisDeckText call YesOrNoMenuWithText jr c, .go_back - call Func_9649 + call CheckIfThereAreAnyBasicCardsInDeck jr c, .set_carry ldtx hl, ThereAreNoBasicPokemonInThisDeckText call DrawWideTextBox_WaitForInput @@ -3393,7 +3474,7 @@ SaveDeckConfiguration: ; 951a (2:551a) call DrawCardTypeIconsAndPrintCardCounts call PrintDeckBuildingCardList ld a, [wced6] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ret .set_carry @@ -3406,7 +3487,7 @@ DismantleDeck: ; 9566 (2:5566) ldtx hl, DismantleThisDeckText call YesOrNoMenuWithText jr c, SaveDeckConfiguration.go_back - call Func_9622 + call CheckIfHasOtherValidDecks jp nc, .Dismantle ; can be jr ldtx hl, ThereIsOnly1DeckSoCannotBeDismantledText call DrawWideTextBox_WaitForInput @@ -3414,12 +3495,12 @@ DismantleDeck: ; 9566 (2:5566) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a - call Func_9b20 + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible call PrintDeckBuildingCardList call EnableLCD ld a, [wced6] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ret .Dismantle @@ -3431,7 +3512,7 @@ DismantleDeck: ; 9566 (2:5566) ld a, NAME_BUFFER_LENGTH call ClearNBytesFromHL call GetPointerToDeckCards - call Func_9152 + call AddDeckToCollection ld a, DECK_SIZE call ClearNBytesFromHL .done_dismantle @@ -3441,7 +3522,7 @@ DismantleDeck: ; 9566 (2:5566) ; 0x95b9 ChangeDeckName: ; 95b9 (2:55b9) - call Func_8f05 + call InputCurDeckName add sp, $2 jp Func_9345.skip_count ; 0x95c1 @@ -3518,31 +3599,40 @@ Func_95c1: ; 95c1 (2:55c1) ret ; 0x9622 -Func_9622: ; 9622 (2:5622) +; returns carry if doesn't have a valid deck +; aside from the current deck +CheckIfHasOtherValidDecks: ; 9622 (2:5622) ld hl, wDecksValid - ld bc, $0 + lb bc, 0, 0 .loop inc b - ld a, $04 + ld a, NUM_DECKS cp b - jr c, .asm_963a + jr c, .check_has_cards ld a, [hli] or a jr z, .loop + ; is valid inc c - ld a, $01 + ld a, 1 cp c - jr nc, .loop + jr nc, .loop ; just 1 valid + ; at least 2 decks are valid .no_carry or a ret -.asm_963a + +.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 GetPointerToDeckCards call EnableSRAM ld a, [hl] call DisableSRAM or a - jr z, .no_carry + jr z, .no_carry ; no cards + ; has cards, is the only valid deck! scf ret ; 0x9649 @@ -3550,7 +3640,7 @@ Func_9622: ; 9622 (2:5622) ; checks if wCurDeckCards has any basics ; returns carry set if there is at least ; 1 Basic Pokemon card -Func_9649: ; 9649 (2:5649) +CheckIfThereAreAnyBasicCardsInDeck: ; 9649 (2:5649) ld hl, wCurDeckCards .loop_cards ld a, [hli] @@ -3574,16 +3664,24 @@ Func_9649: ; 9649 (2:5649) ; 0x9667 Data_9667: ; 9667 (2:5667) - db $01, $01, $00, $02, $09 - db SYM_CURSOR_D - db SYM_SPACE - dw NULL + db 1 ; x pos + db 1 ; y pos + db 0 ; y spacing + db 2 ; x spacing + db NUM_FILTERS ; num entries + db SYM_CURSOR_D ; visible cusor tile + db SYM_SPACE ; invisible cusor tile + dw NULL ; wceac Data_9670: ; 9670 (2:5670) - db $00, $07, $02, $00, $06 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 0 ; x pos + db 7 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 6 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac DeckConfigurationMenu_TransitionTable: ; 9679 (2:5679) cursor_transition $10, $20, $00, $03, $03, $01, $02 @@ -3907,13 +4005,12 @@ ClearNBytesFromHL: ; 9843 (2:5843) ret ; 0x9850 -; finds instance of e in list wCurDeckCards -; returns the position in the list that it was found -; if not found, returns last position + 1 -Func_9850: ; 9850 (2:5850) +; returns the number of times that card e +; appears in wCurDeckCards +GetCountOfCardInCurDeck: ; 9850 (2:5850) push hl ld hl, wCurDeckCards - ld d, $00 + ld d, 0 .loop ld a, [hli] or a @@ -3976,7 +4073,7 @@ AppendOwnedCardCountAndStorageCountNumbers: ; 9880 (2:5880) jr .loop .print push de - call Func_9850 + call GetCountOfCardInCurDeck call ConvertToNumericalDigits ld [hl], TX_SYMBOL inc hl @@ -4140,7 +4237,10 @@ PrintCardTypeCounts: ; 9916 (2:5916) ret ; 0x993d -Func_993d: ; 993d (2:593d) +; prints the list of cards, applying the filter from register a +; the counts of each card displayed is taken from wCurDeck +; a = card type filter +PrintFilteredCardList: ; 993d (2:593d) push af ld hl, CardTypeFilters ld b, $00 @@ -4153,22 +4253,23 @@ Func_993d: ; 993d (2:593d) call EnableSRAM ld hl, sCardCollection ld de, wTempCardCollection - ld b, $ff + ld b, CARD_COLLECTION_SIZE - 1 call CopyNBytesFromHLToDE call DisableSRAM - ld a, [wcfd3] + ld a, [wIncludeCardsInDeck] or a jr z, .ok call GetPointerToDeckCards ld d, h ld e, l - call GetDeckCardCounts + call IncrementDeckCardsInTempCollection .ok pop af + call CreateFilteredCardList - ld a, $06 - ld [wcecb], a + ld a, MAX_FILTERED_LIST_VISIBLE_CARDS + ld [wNumVisibleCardListEntries], a lb de, 1, 7 ld hl, wCardListCoords ld [hl], e @@ -4247,14 +4348,14 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0) .got_cursor_tile call WriteByteToBGMap0 -; iterates by decreasing value in wcecb +; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 ld a, [wcea1] ld c, a ld b, $0 ld hl, wFilteredCardList add hl, bc - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] .loop_filtered_cards push de or a @@ -4264,7 +4365,7 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0) or a jr z, .invalid_card ; card ID of 0 ld e, a - call Func_9a59 + call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID ld a, 13 push bc @@ -4383,22 +4484,24 @@ Text_9a56: db TX_SYMBOL, TX_END Text_9a58: - db TX_END + done +; writes the card ID in register e to wVisibleListCardIDs +; given its position in the list in register b ; input: -; b = ? +; b = list position (starts from bottom) ; e = card ID -Func_9a59: ; 9a59 (2:5a59) +AddCardIDToVisibleList: ; 9a59 (2:5a59) push af push bc push hl - ld hl, wcec4 + ld hl, wVisibleListCardIDs ld c, b - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] sub c - ld c, a - ld b, $00 - add hl, bc ; = wcec4 + (wcecb - b) + ld c, a ; wNumVisibleCardListEntries - b + ld b, $0 + add hl, bc ld [hl], e pop hl pop bc @@ -4406,11 +4509,19 @@ Func_9a59: ; 9a59 (2:5a59) ret ; 0x9a6d -; copies 9 bytes from hl to wcea5 +; copies data from hl to: +; wCardListCursorXPos +; wCardListCursorYPos +; wCardListYSpacing +; wCardListXSpacing +; wCardListNumCursorPositions +; wVisibleCursorTile +; wInvisibleCursorTile +; wceac Func_9a6d: ; 9a6d (2:5a6d) - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ld [hffb3], a - ld de, wcea5 + ld de, wCardListCursorXPos ld b, $9 .loop ld a, [hli] @@ -4424,50 +4535,52 @@ Func_9a6d: ; 9a6d (2:5a6d) ; 0x9a83 Func_9a83: ; 9a83 (2:5a83) - xor a + xor a ; FALSE ld [wPlaysSfx], a ldh a, [hDPadHeld] or a jr z, .handle_ab_btns + +; handle d-pad ld b, a - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld c, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] bit D_LEFT_F, b jr z, .check_d_right dec a bit 7, a - jr z, .got_new_cursor_y - ld a, [wNamingScreenKeyboardHeight] + jr z, .got_cursor_pos + ; if underflow, set to max cursor pos + ld a, [wCardListNumCursorPositions] dec a - jr .got_new_cursor_y + jr .got_cursor_pos .check_d_right bit D_RIGHT_F, b jr z, .handle_ab_btns inc a cp c - jr c, .got_new_cursor_y - + jr c, .got_cursor_pos + ; if over max pos, set to pos 0 xor a -.got_new_cursor_y +.got_cursor_pos push af ld a, TRUE ld [wPlaysSfx], a - call Func_9b00 + call DrawHorizontalListCursor_Invisible pop af - - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a xor a ld [wCheckMenuCursorBlinkCounter], a .handle_ab_btns - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [hffb3], a ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON jr z, Func_9ae8 and A_BUTTON - jr nz, Func_9ad7 + jr nz, ConfirmSelectionAndReturnCarry ; b button ld a, $ff ld [hffb3], a @@ -4476,11 +4589,12 @@ Func_9a83: ; 9a83 (2:5a83) ret ; 0x9ad7 -Func_9ad7: ; 9ad7 (2:5ad7) - call Func_9b20 +; outputs cursor position in e and selection in a +ConfirmSelectionAndReturnCarry: ; 9ad7 (2:5ad7) + call DrawHorizontalListCursor_Visible ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld e, a ld a, [hffb3] scf @@ -4498,39 +4612,42 @@ Func_9ae8: ; 9ae8 (2:5ae8) inc [hl] and $0f ret nz - ld a, [wceaa] + ld a, [wVisibleCursorTile] bit 4, [hl] - jr z, Func_9b03 + jr z, DrawHorizontalListCursor ; 0x9b00 -Func_9b00: ; 9b00 (2:5b00) - ld a, [wceab] +DrawHorizontalListCursor_Invisible: ; 9b00 (2:5b00) + ld a, [wInvisibleCursorTile] ; fallthrough +; like DrawListCursor but only +; for lists with one line, and each entry +; being laid horizontally ; a = tile to write -Func_9b03: ; 9b03 (2:5b03) +DrawHorizontalListCursor: ; 9b03 (2:5b03) ld e, a - ld a, [wcea8] + ld a, [wCardListXSpacing] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld h, a call HtimesL ld a, l - ld hl, wcea5 + ld hl, wCardListCursorXPos add [hl] - ld b, a - ld hl, wcea6 + ld b, a ; x coord + ld hl, wCardListCursorYPos ld a, [hl] - ld c, a + ld c, a ; y coord ld a, e call WriteByteToBGMap0 or a ret ; 0x9b20 -Func_9b20: ; 9b20 (2:5b20) - ld a, [wceaa] - jr Func_9b03 +DrawHorizontalListCursor_Visible: ; 9b20 (2:5b20) + ld a, [wVisibleCursorTile] + jr DrawHorizontalListCursor ; 0x9b25 Func_9b25: ; 9b25 (2:5b25) @@ -4542,9 +4659,9 @@ Func_9b25: ; 9b25 (2:5b25) jp z, .asm_9bb9 ld b, a - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld c, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] bit D_UP_F, b jr z, .check_d_down push af @@ -4601,9 +4718,9 @@ Func_9b25: ; 9b25 (2:5b25) .asm_9b8f push af - call Func_9c0e + call DrawListCursor_Invisible pop af - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a xor a ld [wCheckMenuCursorBlinkCounter], a jr .asm_9bb9 @@ -4614,17 +4731,17 @@ Func_9b25: ; 9b25 (2:5b25) bit D_LEFT_F, b jr z, .check_d_right - call Func_9db3 + call GetSelectedVisibleCardID call Func_9de4 jr .asm_9bb9 .check_d_right bit D_RIGHT_F, b jr z, .asm_9bb9 - call Func_9db3 + call GetSelectedVisibleCardID call Func_9d0c .asm_9bb9 - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [hffb3], a ld hl, wceac ld a, [hli] @@ -4637,10 +4754,10 @@ Func_9b25: ; 9b25 (2:5b25) call CallHL jr nc, .handle_blink .asm_9bd1 - call Func_9c3a + call DrawListCursor_Visible ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld e, a ld a, [hffb3] scf @@ -4669,45 +4786,48 @@ Func_9b25: ; 9b25 (2:5b25) inc [hl] and $0f ret nz - ld a, [wceaa] + ld a, [wVisibleCursorTile] bit 4, [hl] - jr z, Func_9c11 + jr z, DrawListCursor ; fallthrough -Func_9c0e: ; 9c0e (2:5c0e) - ld a, [wceab] +DrawListCursor_Invisible: ; 9c0e (2:5c0e) + ld a, [wInvisibleCursorTile] ; fallthrough +; draws cursor considering wCardListCursorPos +; spaces each entry horizontally by wCardListXSpacing +; and vertically by wCardListYSpacing ; a = tile to write -Func_9c11: ; 9c11 (2:5c11) +DrawListCursor: ; 9c11 (2:5c11) ld e, a - ld a, [wcea8] + ld a, [wCardListXSpacing] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld h, a call HtimesL ld a, l - ld hl, wcea5 + ld hl, wCardListCursorXPos add [hl] - ld b, a - ld a, [wcea7] + ld b, a ; x coord + ld a, [wCardListYSpacing] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld h, a call HtimesL ld a, l - ld hl, wcea6 + ld hl, wCardListCursorYPos add [hl] - ld c, a + ld c, a ; y coord ld a, e call WriteByteToBGMap0 or a ret ; 0x9c3a -Func_9c3a: ; 9c3a (2:5c3a) - ld a, [wceaa] - jr Func_9c11 +DrawListCursor_Visible: ; 9c3a (2:5c3a) + ld a, [wVisibleCursorTile] + jr DrawListCursor ; 0x9c3f Func_9c3f: ; 9c3f (2:5c3f) @@ -4715,7 +4835,7 @@ Func_9c3f: ; 9c3f (2:5c3f) ld a, [hli] ld h, [hl] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld c, a ld b, $00 add hl, bc @@ -4740,9 +4860,9 @@ Func_9c3f: ; 9c3f (2:5c3f) xor a ; FALSE ld [wPlaysSfx], a - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld c, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] bit D_UP_F, b jr z, .asm_9c94 push af @@ -4775,7 +4895,7 @@ Func_9c3f: ; 9c3f (2:5c3f) ld a, [hli] ld h, [hl] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld c, a ld b, $00 add hl, bc @@ -4793,7 +4913,7 @@ Func_9c3f: ; 9c3f (2:5c3f) pop af dec a .asm_9cc6 - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ld a, [wPlaysSfx] or a jp z, Func_9c3f @@ -4812,49 +4932,62 @@ Func_9c3f: ; 9c3f (2:5c3f) .asm_9ce1 ld a, $1 ld [wVBlankOAMCopyToggle], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ret ; 0x9ced INCROM $9ced, $9d0c +; input: +; e = card ID Func_9d0c: ; 9d0c (2:5d0c) - call Func_9d22 - ret c + call TryAddCardToDeck + ret c ; failed to add card push de call PrintCardTypeCounts lb de, 15, 0 call PrintTotalCardCount pop de - call Func_9850 - call Func_9dbf + call GetCountOfCardInCurDeck + call PrintNumberValueInCursorYPos ret ; 0x9d22 -Func_9d22: ; 9d22 (2:5d22) - ld a, [wcfd1] +; tries to add card ID in register e to wCurDeckCards +; fails to add card if one of the following conditions are met: +; - total cards are equal to wMaxNumCardsAllowed +; - cards with the same name as it reached the allowed limit +; - player doesn't own more copies in the collection +; returns carry if fails +; otherwise, writes card ID to first empty slot in wCurDeckCards +; input: +; e = card ID +TryAddCardToDeck: ; 9d22 (2:5d22) + ld a, [wMaxNumCardsAllowed] ld d, a ld a, [wTotalCardCount] cp d - jr nz, .asm_9d2e + jr nz, .not_equal + ; wMaxNumCardsAllowed == wTotalCardCount scf ret -.asm_9d2e +.not_equal push de - call Func_9d74 + call .CheckIfCanAddCardWithSameName pop de - ret c + ret c ; cannot add more cards with this name + push de - call Func_9850 + call GetCountOfCardInCurDeck ld b, a ld hl, wOwnedCardsCountList - ld d, $00 + ld d, $0 ld a, [wcea1] ld e, a add hl, de - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld e, a add hl, de ld d, [hl] @@ -4862,25 +4995,25 @@ Func_9d22: ; 9d22 (2:5d22) cp d pop de scf - ret z + ret z ; cannot add because player doesn't own more copies + ld a, SFX_01 call PlaySFX push de - call Func_9d65 + call .AddCardToCurDeck ld a, [wCurCardTypeFilter] ld c, a - ld b, $00 + ld b, $0 ld hl, wCardFilterCounts add hl, bc inc [hl] pop de or a ret -; 0x9d65 ; finds first empty slot in wCurDeckCards ; then writes the value in e to it -Func_9d65: ; 9d65 (2:5d65) +.AddCardToCurDeck ld hl, wCurDeckCards .loop ld a, [hl] @@ -4894,14 +5027,18 @@ Func_9d65: ; 9d65 (2:5d65) xor a ld [hl], a ret -; 0x9d74 +; returns carry if card ID in e cannot be +; added to the current deck configuration +; due to having reached the maximum number +; of cards allowed with that same name ; e = card id -Func_9d74: ; 9d74 (2:5d74) +.CheckIfCanAddCardWithSameName call LoadCardDataToBuffer1_FromCardID ld a, [wLoadedCard1Type] cp TYPE_ENERGY_DOUBLE_COLORLESS jr z, .double_colorless + ; basic energy cards have no limit and TYPE_ENERGY cp TYPE_ENERGY jr z, .exit ; return if basic energy card @@ -4914,28 +5051,30 @@ Func_9d74: ; 9d74 (2:5d74) ld a, [wLoadedCard1Name + 1] ld b, a ld hl, wCurDeckCards - ld d, $00 + ld d, 0 push de -.loop +.loop_cards ld a, [hli] or a jr z, .exit_pop_de ld e, a - ld d, $00 + ld d, $0 call GetCardName ld a, e cp c - jr nz, .loop + jr nz, .loop_cards ld a, d cp b - jr nz, .loop + jr nz, .loop_cards ; has same name pop de - inc d - ld a, [wcfd2] + inc d ; increment counter of cards with this name + ld a, [wSameNameCardsLimit] cp d push de - jr nz, .loop + jr nz, .loop_cards + ; reached the maximum number + ; of cards with same name allowed pop de scf ret @@ -4947,11 +5086,11 @@ Func_9d74: ; 9d74 (2:5d74) ret ; 0x9db3 -; gets the element in wcec4 -; corresponding to index wNamingScreenCursorY -Func_9db3: ; 9db3 (2:5db3) - ld hl, wcec4 - ld a, [wNamingScreenCursorY] +; gets the element in wVisibleListCardIDs +; corresponding to index wCardListCursorPos +GetSelectedVisibleCardID: ; 9db3 (2:5db3) + ld hl, wVisibleListCardIDs + ld a, [wCardListCursorPos] ld e, a ld d, $00 add hl, de @@ -4959,64 +5098,68 @@ Func_9db3: ; 9db3 (2:5db3) ret ; 0x9dbf +; appends the digits of value in register a to wDefaultText +; then prints it in cursor Y position ; a = value to convert to numerical digits -Func_9dbf: ; 9dbf (2:5dbf) - ld hl, wc590 +PrintNumberValueInCursorYPos: ; 9dbf (2:5dbf) + ld hl, wDefaultText call ConvertToNumericalDigits ld [hl], TX_END - ld a, [wcea7] + ld a, [wCardListYSpacing] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld h, a call HtimesL ld a, l - ld hl, wcea6 + ld hl, wCardListCursorYPos add [hl] ld e, a ld d, $0e call InitTextPrinting - ld hl, wc590 + ld hl, wDefaultText call ProcessText ret ; 0x9de4 Func_9de4: ; 9de4 (2:5de4) - call Func_9dfa + call RemoveCardFromDeck ret nc push de call PrintCardTypeCounts lb de, 15, 0 call PrintTotalCardCount pop de - call Func_9850 - call Func_9dbf + call GetCountOfCardInCurDeck + call PrintNumberValueInCursorYPos ret ; 0x9dfa -Func_9dfa: ; 9dfa (2:5dfa) +; removes card ID in e from wCurDeckCards +RemoveCardFromDeck: ; 9dfa (2:5dfa) push de - call Func_9850 + call GetCountOfCardInCurDeck pop de or a - ret z + ret z ; card is not in deck ld a, SFX_01 call PlaySFX push de - call Func_9e18 + call .RemoveCard ld a, [wCurCardTypeFilter] ld c, a - ld b, $00 + ld b, $0 ld hl, wCardFilterCounts add hl, bc dec [hl] pop de scf ret -; 0x9e18 -Func_9e18: ; 9e18 (2:5e18) +; remove first card instance of card ID in e +; and shift all elements up by one +.RemoveCard ld hl, wCurDeckCards - ld d, $00 + ld d, 0 .loop_1 inc d ld a, [hli] @@ -5025,14 +5168,16 @@ Func_9e18: ; 9e18 (2:5e18) ld c, l ld b, h dec bc + .loop_2 - inc d + inc d ; unnecessary ld a, [hli] or a jr z, .done ld [bc], a inc bc jr .loop_2 + .done xor a ld [bc], a @@ -5065,13 +5210,12 @@ Func_9e41: ; 9e41 (2:5e41) call Func_9a6d ld a, [wNumUniqueCards] ld [wcfe6], a - cp $07 + cp MAX_DECK_CONFIRMATION_VISIBLE_CARDS jr c, .no_cap - ; cap to 7 - ld a, $07 + ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS .no_cap - ld [wNamingScreenKeyboardHeight], a - ld [wcecb], a + ld [wCardListNumCursorPositions], a + ld [wNumVisibleCardListEntries], a call ShowConfirmationCardScreen ld hl, UpdateConfirmationCardScreen @@ -5096,7 +5240,7 @@ Func_9e41: ; 9e41 (2:5e41) .asm_9e8e ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced7], a ld de, wOwnedCardsCountList ld hl, wcfd8 @@ -5114,13 +5258,17 @@ Func_9e41: ; 9e41 (2:5e41) ; 0x9eaf Data_9eaf: - db $00, $05, $02, $00, $07 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 0 ; x pos + db 5 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 7 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac Func_9eb8: ; 9eb8 (2:5eb8) - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld d, a ld a, [wcea1] ld c, a @@ -5166,7 +5314,7 @@ Func_9eb8: ; 9eb8 (2:5eb8) ; 0x9efc Func_9efc: ; 9efc (2:5efc) - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld d, a ld a, [wcea1] ld c, a @@ -5238,7 +5386,7 @@ ShowConfirmationCardScreen: ; 9f52 (2:5f52) ; counts all values stored in wCardFilterCounts ; if the total count is 0, then ; prints "No cards chosen." -Func_9f62: ; 9f62 (2:5f62) +TallyCardsInCardFilterLists: ; 9f62 (2:5f62) lb bc, 0, 0 ld hl, wCardFilterCounts .loop @@ -5289,7 +5437,7 @@ ShowDeckInfoHeader: ; 9f81 (2:5f81) call PrintTotalCardCount lb de, 16, 1 call PrintSlashSixty - call Func_9f62 + call TallyCardsInCardFilterLists call EnableLCD ret ; 0x9fc0 @@ -5419,14 +5567,14 @@ SortCurDeckCardsByID: ; a028 (2:6028) ; 0xa06e ; goes through list in wCurDeckCards, and for each card in it -; creates list in wOwnedCardsCountList of all unique cards +; creates list in wTempHandCardList of all unique cards ; it finds (assuming wCurDeckCards is sorted by ID) ; also counts the number of the different cards CreateCurDeckUniqueCardList: ; a06e (2:606e) ld b, 0 ld c, $0 ld hl, wCurDeckCards - ld de, wOwnedCardsCountList + ld de, wTempHandCardList .loop ld a, [hli] cp c @@ -5467,14 +5615,14 @@ PrintConfirmationCardList: ; a08a (2:608a) .got_cursor_tile_1 call WriteByteToBGMap0 -; iterates by decreasing value in wcecb +; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 ld a, [wcea1] ld c, a ld b, $0 ld hl, wOwnedCardsCountList add hl, bc - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] .loop_cards push de or a @@ -5484,7 +5632,7 @@ PrintConfirmationCardList: ; a08a (2:608a) or a jr z, .no_more_cards ld e, a - call Func_9a59 + call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID ; places in wDefaultText the card's name and level ; then appends at the end "x" with the count of that card @@ -5549,7 +5697,7 @@ PrintConfirmationCardList: ; a08a (2:608a) inc hl jr .loop_search .found_card_id - call Func_9850 + call GetCountOfCardInCurDeck ld [hl], TX_SYMBOL inc hl ld [hl], SYM_CROSS @@ -5668,24 +5816,26 @@ GetCardTypeIconPalette: ; a173 (2:6173) Func_a1a2: ; a1a2 (2:61a2) ld hl, wCurDeckCards - ld a, DECK_SIZE + $15 + ld a, wCurDeckCardsEnd - wCurDeckCards call ClearNBytesFromHL ld a, $ff ld [wCurDeck], a ld hl, .text ld de, wCurDeckName call CopyListFromHLToDE - ld hl, .unknown_a1d8 - call Func_8d9d + ld hl, .DeckConfigurationParams + call InitDeckBuildingParams call Func_9345 ret .text text "Cards chosen to send" - db TX_END + done -.unknown_a1d8 - db $3c, $3c, $00 +.DeckConfigurationParams + db DECK_SIZE ; max number of cards + db 60 ; max number of same name cards + db FALSE ; whether to include deck cards dw HandleSendDeckConfigurationMenu dw SendDeckConfigurationMenu_TransitionTable ; 0xa1df @@ -5720,14 +5870,14 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201) jr nz, .asm_a23b call DrawCardTypeIconsAndPrintCardCounts ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ld a, [wCurCardTypeFilter] - call Func_993d + call PrintFilteredCardList jp Func_9345.skip_draw .asm_a23b ld hl, .func_table call JumpToFunctionInTable - jp Func_9461.asm_9475 + jp OpenDeckConfigurationMenu.skip_init .func_table dw ConfirmDeckConfiguration ; Confirm @@ -5746,7 +5896,7 @@ SendDeckConfiguration: ; a24a (2:624a) ld hl, wCurDeckCards ld de, wDuelTempList call CopyListFromHLToDE - call Func_b131 + call PrintCardToSendText call Func_b088 call EnableLCD ldtx hl, SendTheseCardsText @@ -5781,7 +5931,7 @@ Func_a288: ; a288 (2:6288) xor a ld [wcea1], a ld [wCurCardTypeFilter], a - call Func_a39f + call PrintFilteredCardSelectionList call EnableLCD xor a ld hl, Data_9667 @@ -5790,27 +5940,27 @@ Func_a288: ; a288 (2:6288) call DoFrame ld a, [wCurCardTypeFilter] ld b, a - ld a, [wNamingScreenCursorY] + ld a, [wTempCardTypeFilter] cp b jr z, .asm_a2cc ld [wCurCardTypeFilter], a ld hl, wcea1 ld [hl], $00 - call Func_a39f + call PrintFilteredCardSelectionList ld hl, hffb0 ld [hl], $01 - call Func_a4de + call PrintPlayersCardsText ld hl, hffb0 ld [hl], $00 - ld a, $09 - ld [wNamingScreenKeyboardHeight], a + ld a, NUM_FILTERS + ld [wCardListNumCursorPositions], a .asm_a2cc ldh a, [hDPadHeld] and D_DOWN jr z, .asm_a2d7 - call Func_9ad7 + call ConfirmSelectionAndReturnCarry jr .asm_a2e4 .asm_a2d7 @@ -5831,10 +5981,10 @@ Func_a288: ; a288 (2:6288) call Func_9a6d ld a, [wceae] ld [wcfe6], a - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_a300 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a .asm_a300 ld hl, PrintCardSelectionList ld d, h @@ -5859,9 +6009,9 @@ Func_a288: ; a288 (2:6288) .asm_a321 ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld [wcfdf], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld de, wHandTempList ld hl, wcfd8 @@ -5873,21 +6023,21 @@ Func_a288: ; a288 (2:6288) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a - call Func_9b20 + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible call PrintCardSelectionList call EnableLCD ld hl, Data_a396 call Func_9a6d ld a, [wcfdf] - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jr .loop_input .asm_a36a - call Func_9c0e - ld a, [wNamingScreenCursorY] + call DrawListCursor_Invisible + ld a, [wCardListCursorPos] ld [wced4], a ld a, [hffb3] cp $ff @@ -5895,24 +6045,28 @@ Func_a288: ; a288 (2:6288) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a + ld [wTempCardTypeFilter], a ld hl, hffb0 ld [hl], $01 - call Func_a4de + call PrintPlayersCardsText ld hl, hffb0 ld [hl], $00 jp .asm_a2a2 ; 0xa396 Data_a396: ; a396 (2:6396) - db $01, $05, $02, $00, $07 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 1 ; x pos + db 5 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 7 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac ; 0xa39f ; a = which card type filter -Func_a39f: ; a39f (2:639f) +PrintFilteredCardSelectionList: ; a39f (2:639f) push af ld hl, CardTypeFilters ld b, $00 @@ -5920,13 +6074,13 @@ Func_a39f: ; a39f (2:639f) add hl, bc ld a, [hl] push af - ld a, $ff - call Func_a3ca + ld a, ALL_DECKS + call CreateCardCollectionListWithDeckCards pop af call CreateFilteredCardList - ld a, $07 - ld [wcecb], a + ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS + ld [wNumVisibleCardListEntries], a lb de, 2, 5 ld hl, wCardListCoords ld [hl], e @@ -5939,45 +6093,50 @@ Func_a39f: ; a39f (2:639f) ret ; 0xa3ca -Func_a3ca: ; a3ca (2:63ca) +; outputs in wTempCardCollection all the cards in sCardCollection +; plus the cards that are being used in built decks +; a = DECK_* flags for which decks to include in the collection +CreateCardCollectionListWithDeckCards: ; a3ca (2:63ca) ld [hffb5], a +; copies sCardCollection to wTempCardCollection ld hl, sCardCollection ld de, wTempCardCollection - ld b, $ff + ld b, CARD_COLLECTION_SIZE - 1 call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM + ; deck_1 ld a, [hffb5] ; should be ldh - bit 0, a + bit DECK_1_F, a jr z, .deck_2 ld de, sDeck1Cards - call GetDeckCardCounts + call IncrementDeckCardsInTempCollection .deck_2 ld a, [hffb5] ; should be ldh - bit 1, a + bit DECK_2_F, a jr z, .deck_3 ld de, sDeck2Cards - call GetDeckCardCounts + call IncrementDeckCardsInTempCollection .deck_3 ld a, [hffb5] ; should be ldh - bit 2, a + bit DECK_3_F, a jr z, .deck_4 ld de, sDeck3Cards - call GetDeckCardCounts + call IncrementDeckCardsInTempCollection .deck_4 ld a, [hffb5] ; should be ldh - bit 3, a + bit DECK_4_F, a ret z ld de, sDeck4Cards - call GetDeckCardCounts + call IncrementDeckCardsInTempCollection ret ; 0xa412 -; goes through deck cards in de -; and gets the count of each card ID -; in wTempCardCollection in card collection order -GetDeckCardCounts: ; a412 (2:6412) +; goes through cards in deck in de +; and for each card ID, increments its corresponding +; entry in wTempCardCollection +IncrementDeckCardsInTempCollection: ; a412 (2:6412) call EnableSRAM ld bc, wTempCardCollection ld h, DECK_SIZE @@ -6022,14 +6181,14 @@ PrintCardSelectionList: ; a42d (2:642d) .got_cursor_tile_1 call WriteByteToBGMap0 -; iterates by decreasing value in wcecb +; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 ld a, [wcea1] ld c, a ld b, $0 ld hl, wFilteredCardList add hl, bc - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] .loop_filtered_cards push de or a @@ -6039,7 +6198,7 @@ PrintCardSelectionList: ; a42d (2:642d) or a jr z, .invalid_card ; card ID of 0 ld e, a - call Func_9a59 + call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID ; places in wDefaultText the card's name and level ; then appends at the end the count of that card @@ -6126,29 +6285,29 @@ AppendOwnedCardCountNumber: ; a4ae (2:64ae) ret ; 0xa4c6 +; print header info (card count and player name) Func_a4c6: ; a4c6 (2:64c6) call Set_OBJ_8x8 call Func_8d78 -; fallthrough - -Func_a4cc: ; a4cc (2:64cc) +.skip_empty_screen lb bc, 0, 4 ld a, SYM_BOX_TOP call FillBGMapLineWithA call PrintTotalNumberOfCardsInCollection - call Func_a4de + call PrintPlayersCardsText call DrawCardTypeIcons ret ; 0xa4de -Func_a4de: ; a4de (2:64de) +; prints "'s cards" +PrintPlayersCardsText: ; a4de (2:64de) ld de, $100 call InitTextPrinting - ld de, wc590 + ld de, wDefaultText call CopyPlayerName - ld hl, wc590 + ld hl, wDefaultText call ProcessText - ld hl, wc590 + ld hl, wDefaultText call GetTextLengthInTiles inc b ld d, b @@ -6160,8 +6319,8 @@ Func_a4de: ; a4de (2:64de) ; 0xa504 PrintTotalNumberOfCardsInCollection: ; a504 (2:6504) - ld a, $ff - call Func_a3ca + ld a, ALL_DECKS + call CreateCardCollectionListWithDeckCards ; count all the cards in collection ld de, wTempCardCollection + 1 @@ -6396,7 +6555,7 @@ Func_a596: ; a596 (2:6596) ld hl, wOwnedCardsCountList add hl, bc ld a, [hl] - cp $80 + cp CARD_NOT_OWNED jr nz, .found_not_owned dec c jr .loop_owned_cards @@ -6426,7 +6585,7 @@ Func_a596: ; a596 (2:6596) ld hl, wTempCardCollection add hl, de ld a, [hl] - cp $80 + cp CARD_NOT_OWNED jr z, .asm_a67c ld a, [wcfe2] or b @@ -6472,7 +6631,7 @@ Func_a6a0: ; a6a0 (2:66a0) push af ld hl, sCardCollection ld de, wTempCardCollection - ld b, $ff + ld b, CARD_COLLECTION_SIZE - 1 call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM @@ -6481,8 +6640,8 @@ Func_a6a0: ; a6a0 (2:66a0) push af call Func_a6ca call Func_a596 - ld a, $07 - ld [wcecb], a + ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS + ld [wNumVisibleCardListEntries], a lb de, 2, 4 ld hl, wCardListCoords ld [hl], e @@ -6547,7 +6706,7 @@ Func_a6fa: ; a6fa (2:66fa) ld a, [wcea1] ld l, a ld h, $00 - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] .asm_a71e push de or a @@ -6562,7 +6721,7 @@ Func_a6fa: ; a6fa (2:66fa) or a jr z, .asm_a788 ld e, a - call Func_9a59 + call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID push bc push hl @@ -6570,10 +6729,10 @@ Func_a6fa: ; a6fa (2:66fa) add hl, de dec hl ld a, [hl] - cp $80 + cp CARD_NOT_OWNED jr nz, .asm_a74c ld hl, .text - ld de, wc590 + ld de, wDefaultText call CopyListFromHLToDE jr .asm_a751 .asm_a74c @@ -6589,7 +6748,7 @@ Func_a6fa: ; a6fa (2:66fa) push hl call Func_a7a7 call ProcessText - ld hl, wc590 + ld hl, wDefaultText jr .asm_a76d pop de push hl @@ -6628,7 +6787,7 @@ Func_a6fa: ; a6fa (2:66fa) .text db "kkkkkkkkkkkkk" - db TX_END + done ; 0xa7a7 Func_a7a7: ; a7a7 (2:67a7) @@ -6645,7 +6804,7 @@ Func_a7a7: ; a7a7 (2:67a7) cp MEW2 jr z, .phantom_card - ld a, [wcecb] + ld a, [wNumVisibleCardListEntries] sub b ld hl, wcea1 add [hl] @@ -6708,9 +6867,9 @@ Func_a7a7: ; a7a7 (2:67a7) .phantom_card ld hl, wCurDeckName + 2 - ld [hl], $6c + ld [hl], "l" inc hl - ld [hl], $6c + ld [hl], "l" inc hl ld [hl], TX_SYMBOL inc hl @@ -6724,7 +6883,7 @@ Func_a7a7: ; a7a7 (2:67a7) ; 0xa828 Func_a828: ; a828 (2:6828) - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld b, a ld a, [wcea1] add b @@ -6733,7 +6892,7 @@ Func_a828: ; a828 (2:6828) ld hl, wOwnedCardsCountList add hl, bc ld a, [hl] - cp $80 + cp CARD_NOT_OWNED jr z, .handle_input ld hl, wcfd8 @@ -6757,19 +6916,19 @@ Func_a828: ; a828 (2:6828) jp nz, .asm_a8f5 xor a ; FALSE ld [wPlaysSfx], a - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld c, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] bit D_UP_F, b jr z, .asm_a891 push af ld a, TRUE ld [wPlaysSfx], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld hl, wcea1 add [hl] - ld hl, wcfe5 + ld hl, wFirstOwnedCardIndex cp [hl] jr z, .open_card_page_pop_af pop af @@ -6802,7 +6961,7 @@ Func_a828: ; a828 (2:6828) ld a, [hli] ld h, [hl] ld l, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld c, a ld b, $00 add hl, bc @@ -6820,7 +6979,7 @@ Func_a828: ; a828 (2:6828) pop af dec a .asm_a8c3 - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a ld a, [wPlaysSfx] or a jp z, Func_a828 @@ -6836,12 +6995,12 @@ Func_a828: ; a828 (2:6828) jr z, .open_card_page bit D_LEFT_F, b jr z, .asm_a8e5 - call Func_9dfa + call RemoveCardFromDeck jr .open_card_page .asm_a8e5 bit D_RIGHT_F, b jr z, .open_card_page - call Func_9d22 + call TryAddCardToDeck .open_card_page_pop_af pop af @@ -6854,23 +7013,23 @@ Func_a828: ; a828 (2:6828) .asm_a8f5 ld a, $01 ld [wVBlankOAMCopyToggle], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ret ; 0xa901 -Func_a901: ; a901 (2:6901) +GetFirstOwnedCardIndex: ; a901 (2:6901) ld hl, wOwnedCardsCountList - ld b, $00 -.asm_a906 + ld b, 0 +.loop_cards ld a, [hli] - cp $80 - jr nz, .asm_a90e + cp CARD_NOT_OWNED + jr nz, .owned inc b - jr .asm_a906 -.asm_a90e + jr .loop_cards +.owned ld a, b - ld [wcfe5], a + ld [wFirstOwnedCardIndex], a ret ; 0xa913 @@ -6892,7 +7051,7 @@ Func_a913: ; a913 (2:6913) ret z ld c, a ld b, $00 - ld hl, wcec4 + ld hl, wVisibleListCardIDs add hl, bc ld a, [hl] or a @@ -6926,10 +7085,10 @@ Func_a913: ; a913 (2:6913) ld hl, .data_aa0a call Func_9a6d ld a, [wceae] - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_a97e - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a .asm_a97e ld hl, Func_a6fa ld d, h @@ -6952,9 +7111,9 @@ Func_a913: ; a913 (2:6913) .asm_a99f ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld [wcfdf], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld c, a ld a, [wcea1] @@ -6964,14 +7123,14 @@ Func_a913: ; a913 (2:6913) ld b, $00 add hl, bc ld a, [hl] - cp $80 + cp CARD_NOT_OWNED jr z, .loop_input_3 ld de, wHandTempList ld hl, wcfd8 ld [hl], e inc hl ld [hl], d - call Func_a901 + call GetFirstOwnedCardIndex call Func_a828 call .Func_aa24 call Func_a6fa @@ -6979,14 +7138,14 @@ Func_a913: ; a913 (2:6913) ld hl, .data_aa0a call Func_9a6d ld a, [wcfdf] - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jr .loop_input_3 .asm_a9ed - call Func_9c0e - ld a, [wNamingScreenCursorY] + call DrawListCursor_Invisible + ld a, [wCardListCursorPos] ld [wced4], a ld a, [hffb3] cp $ff @@ -7003,10 +7162,14 @@ Func_a913: ; a913 (2:6913) dw NULL ; function pointer if non-0 .data_aa0a - db $01, $04, $02, $00, $07 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 1 ; x pos + db 4 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 7 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac .Func_aa13 ld hl, wHandTempList @@ -7083,7 +7246,7 @@ Func_a913: ; a913 (2:6913) call InitTextPrinting ld a, [wcfe1] - ld hl, wc590 + ld hl, wDefaultText call ConvertToNumericalDigits call CalculateOnesAndTensDigits ld [hl], TX_SYMBOL @@ -7095,7 +7258,7 @@ Func_a913: ; a913 (2:6913) ld a, e call ConvertToNumericalDigits ld [hl], TX_END - ld hl, wc590 + ld hl, wDefaultText call ProcessText lb de, 0, 2 lb bc, 20, 16 @@ -7110,7 +7273,7 @@ Func_a913: ; a913 (2:6913) ld a, [hli] cp $ff jr z, .asm_aad9 - cp $80 + cp CARD_NOT_OWNED jr z, .asm_aacd inc b jr .asm_aacd @@ -7145,7 +7308,7 @@ Func_a913: ; a913 (2:6913) ld hl, .BoosterPacksMenuData call PlaceTextItems ld a, 5 - ld hl, wcec4 + ld hl, wVisibleListCardIDs call ClearNBytesFromHL call EnableSRAM ld a, [sb703] @@ -7159,7 +7322,7 @@ Func_a913: ; a913 (2:6913) or a jr nz, .asm_ab4d ld a, $01 - ld [wcec4 + 4], a + ld [wVisibleListCardIDs + 4], a ld e, $0b ld d, $05 call InitTextPrinting @@ -7194,7 +7357,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) xor a ld [wcea1], a ld [wCurCardTypeFilter], a - call Func_a39f + call PrintFilteredCardSelectionList call EnableLCD xor a ld hl, Data_9667 @@ -7204,26 +7367,26 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) call DoFrame ld a, [wCurCardTypeFilter] ld b, a - ld a, [wNamingScreenCursorY] + ld a, [wTempCardTypeFilter] cp b jr z, .handle_input ld [wCurCardTypeFilter], a ld hl, wcea1 ld [hl], $00 - call Func_a39f + call PrintFilteredCardSelectionList ld hl, hffb0 ld [hl], $01 - call Func_a4de + call PrintPlayersCardsText ld hl, hffb0 ld [hl], $00 - ld a, $09 - ld [wNamingScreenKeyboardHeight], a + ld a, NUM_FILTERS + ld [wCardListNumCursorPositions], a .handle_input ldh a, [hDPadHeld] and D_DOWN jr z, .asm_abca ; d_down - call Func_9ad7 + call ConfirmSelectionAndReturnCarry jr .asm_abd7 .asm_abca call Func_9a83 @@ -7243,10 +7406,10 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) call Func_9a6d ld a, [wceae] ld [wcfe6], a - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_abf6 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld [wcfdf], a .asm_abf6 ld hl, PrintCardSelectionList @@ -7270,9 +7433,9 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ; start btn ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenKeyboardHeight] + ld a, [wCardListNumCursorPositions] ld [wcfdf], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld de, wHandTempList ld hl, wcfd8 @@ -7286,23 +7449,23 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a - call Func_9b20 + ld [wTempCardTypeFilter], a + call DrawHorizontalListCursor_Visible call PrintCardSelectionList call EnableLCD ld hl, Data_a396 call Func_9a6d ld a, [wcfdf] - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jr .loop_frame_2 .asm_ac60 - call Func_9c0e - ld a, [wNamingScreenKeyboardHeight] + call DrawListCursor_Invisible + ld a, [wCardListNumCursorPositions] ld [wcfdf], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld a, [hffb3] cp $ff @@ -7311,16 +7474,16 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld hl, Data_9667 call Func_9a6d ld a, [wCurCardTypeFilter] - ld [wNamingScreenCursorY], a + ld [wTempCardTypeFilter], a ld hl, hffb0 ld [hl], $01 - call Func_a4de + call PrintPlayersCardsText ld hl, hffb0 ld [hl], $00 jp .loop_frame_1 .asm_ac92 - call Func_9c3a + call DrawListCursor_Visible call .Func_acde ld de, $101 call InitTextPrinting @@ -7352,7 +7515,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) .asm_acd5 call .Func_acde - call Func_a4cc + call Func_a4c6.skip_empty_screen jp .asm_ac37 .Func_acde @@ -7376,10 +7539,14 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ; 0xad0e Data_ad05: ; ad05 (2:6d05) - db $03, $03, $00, $04, $02 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 3 ; x pos + db 3 ; y pos + db 0 ; y spacing + db 4 ; x spacing + db 2 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac ; 0xad0e PrinterMenu_CardList: ; ad0e (2:6d0e) @@ -7393,7 +7560,7 @@ PrinterMenu_CardList: ; ad0e (2:6d0e) xor a ld [wcea1], a ld [wCurCardTypeFilter], a - call Func_a39f + call PrintFilteredCardSelectionList call EnableLCD ld de, $101 call InitTextPrinting @@ -7498,12 +7665,18 @@ PrinterMenu_PrintQuality: ; adb5 (2:6db5) ; 0xadf5 Data_adf5: ; adf5 (2:6df5) - db $05, $10, $00, $02, $05 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 5 ; x pos + db 16 ; y pos + db 0 ; y spacing + db 2 ; x spacing + db 5 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac ; 0xadfe +; hl = ? +; de = deck Func_adfe: ; adfe (2:6dfe) push de ld de, wCurDeckName @@ -7518,17 +7691,16 @@ Func_adfe: ; adfe (2:6dfe) ld [wTotalCardCount], a ld hl, wCardFilterCounts ld [hl], a - call Func_ae21 + call .Func_ae21 ret -; 0xae21 -Func_ae21: ; ae21 (2:6e21) +.Func_ae21 call SortCurDeckCardsByID call CreateCurDeckUniqueCardList xor a ld [wcea1], a .loop - ld hl, Data_ae91 + ld hl, .Data_ae91 call Func_9a6d ld a, [wNumUniqueCards] ld [wcfe6], a @@ -7536,16 +7708,16 @@ Func_ae21: ; ae21 (2:6e21) jr c, .asm_ae3d ld a, $05 .asm_ae3d - ld [wNamingScreenKeyboardHeight], a - ld [wcecb], a - call Func_aeb9 + ld [wCardListNumCursorPositions], a + ld [wNumVisibleCardListEntries], a + call .Func_aeb9 ld hl, wcfda ld a, [hli] ld h, [hl] ld l, a call DrawWideTextBox_PrintText - ld hl, Func_ae9a + ld hl, .Func_ae9a ld d, h ld a, l ld hl, wcece @@ -7566,7 +7738,7 @@ Func_ae21: ; ae21 (2:6e21) .asm_ae70 ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced7], a ld de, wOwnedCardsCountList ld hl, wcfd8 @@ -7581,19 +7753,21 @@ Func_ae21: ; ae21 (2:6e21) cp $ff ret z jr .asm_ae70 -; 0xae91 -Data_ae91: ; ae91 (2:6e91) - db $00, $03, $02, $00, $05 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL -; 0xae9a - -Func_ae9a: ; ae9a (2:6e9a) +.Data_ae91 + db 0 ; x pos + db 3 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 5 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac + +.Func_ae9a ld hl, hffb0 ld [hl], $01 - call Func_aed3 + call .Func_aed3 ld de, $10e call InitTextPrinting ld hl, wcfda @@ -7604,9 +7778,8 @@ Func_ae9a: ; ae9a (2:6e9a) ld hl, hffb0 ld [hl], $00 jp PrintConfirmationCardList -; 0xaeb9 -Func_aeb9: ; aeb9 (2:6eb9) +.Func_aeb9 call .Func_aec9 lb de, 3, 3 ld hl, wCardListCoords @@ -7618,12 +7791,11 @@ Func_aeb9: ; aeb9 (2:6eb9) .Func_aec9 call EmptyScreenAndLoadFontDuelAndHandCardsIcons - call Func_aed3 + call .Func_aed3 call EnableLCD ret -; 0xaed3 -Func_aed3: ; aed3 (2:6ed3) +.Func_aed3 ld a, [wCurDeckName] or a ret z @@ -7631,28 +7803,28 @@ Func_aed3: ; aed3 (2:6ed3) call InitTextPrinting ld a, [wCurDeck] inc a - ld hl, wc590 + ld hl, wDefaultText call ConvertToNumericalDigits ld [hl], "FW0_·" inc hl ld [hl], TX_END - ld hl, wc590 + ld hl, wDefaultText call ProcessText ld hl, wCurDeckName - ld de, wc590 + ld de, wDefaultText call CopyListFromHLToDE - ld hl, wc590 + ld hl, wDefaultText call GetTextLengthInTiles ld b, $00 - ld hl, wc590 + ld hl, wDefaultText add hl, bc ld d, h ld e, l ld hl, DeckNameSuffix call CopyListFromHLToDE ld de, $301 - ld hl, wc590 + ld hl, wDefaultText call InitTextPrinting call ProcessText ret @@ -7702,7 +7874,7 @@ Func_af1d: ; af1d (2:6f1d) ret c call EnableSRAM ld hl, wCurDeckCards - call Func_910a + call DecrementDeckCardsInCollection call DisableSRAM call SaveGame ld hl, wNameBuffer @@ -7725,24 +7897,24 @@ Func_af98: ; af98 (2:6f98) call EnableSRAM ld hl, wDuelTempList - call Func_9120 + call AddGiftCenterDeckCardsToCollection call DisableSRAM call SaveGame xor a ld [wcea1], a ld hl, Data_b04a call Func_9a6d - call Func_b141 + call PrintReceivedTheseCardsText call Func_b088 call EnableLCD ld a, [wceae] ld [wcfe6], a - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_afd4 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a .asm_afd4 - ld hl, Func_b053 + ld hl, ShowReceivedCardsList ld d, h ld a, l ld hl, wcece @@ -7763,7 +7935,7 @@ Func_af98: ; af98 (2:6f98) .asm_aff5 ld a, $01 call PlaySFXConfirmOrCancel - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wced4], a ld de, wFilteredCardList ld hl, wcfd8 @@ -7771,23 +7943,23 @@ Func_af98: ; af98 (2:6f98) inc hl ld [hl], d call Func_9c3f - call Func_b141 + call PrintReceivedTheseCardsText call PrintCardSelectionList call EnableLCD ld hl, Data_b04a call Func_9a6d ld a, [wceae] - ld hl, wcecb + ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_b027 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a .asm_b027 ld a, [wced4] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jr .asm_afe2 .asm_b02f - call Func_9c0e - ld a, [wNamingScreenCursorY] + call DrawListCursor_Invisible + ld a, [wCardListCursorPos] ld [wced4], a ld a, [hffb3] cp $ff @@ -7799,12 +7971,16 @@ Func_af98: ; af98 (2:6f98) ret Data_b04a: ; b04a (2:704a) - db $01, $03, $02, $00, $05 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL - -Func_b053: ; b053 (2:7053) + db 1 ; x pos + db 3 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 5 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac + +ShowReceivedCardsList: ; b053 (2:7053) ld hl, hffb0 ld [hl], $01 lb de, 1, 1 @@ -7827,7 +8003,7 @@ Func_b053: ; b053 (2:7053) ; 0xb088 Func_b088: ; b088 (2:7088) - ld a, $ff + ld a, CARD_COLLECTION_SIZE - 1 ld hl, wTempCardCollection call ClearNBytesFromHL ld de, wDuelTempList @@ -7835,7 +8011,7 @@ Func_b088: ; b088 (2:7088) ld a, $ff call .Func_b0c0 ld a, $05 - ld [wcecb], a + ld [wNumVisibleCardListEntries], a lb de, 2, 3 ld hl, wCardListCoords ld [hl], e @@ -7938,8 +8114,8 @@ Func_b088: ; b088 (2:7088) ret ; 0xb131 -Func_b131: ; b131 (2:7131) - call Func_b141.Func_b167 +PrintCardToSendText: ; b131 (2:7131) + call EmptyScreenAndDrawTextBox lb de, 1, 1 call InitTextPrinting ldtx hl, CardToSendText @@ -7947,8 +8123,8 @@ Func_b131: ; b131 (2:7131) ret ; 0xb141 -Func_b141: ; b141 (2:7141) - call .Func_b167 +PrintReceivedTheseCardsText: ; b141 (2:7141) + call EmptyScreenAndDrawTextBox lb de, 1, 1 call InitTextPrinting ldtx hl, CardReceivedText @@ -7962,8 +8138,9 @@ Func_b141: ; b141 (2:7141) ldtx hl, ReceivedTheseCardsFromText call DrawWideTextBox_PrintText ret +; 0xb167 -.Func_b167 +EmptyScreenAndDrawTextBox: ; b167 (2:7167) call Set_OBJ_8x8 call Func_8d78 lb de, 0, 0 @@ -8012,7 +8189,7 @@ Func_b19d: ; b19d (2:719d) ld hl, Data_b6fb call Func_9a6d call Func_b704 - call Func_b545 + call PrintNumSavedDecks ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText ldtx de, PleaseSelectDeckText @@ -8067,7 +8244,7 @@ Func_b19d: ; b19d (2:719d) jr nz, .asm_b24c call Func_b35b jr c, .asm_b240 - call Func_b6ca + call TryDeleteSavedDeck ld a, [wd086] jp c, .asm_b1b3 jr .asm_b25e @@ -8092,7 +8269,7 @@ Func_b19d: ; b19d (2:719d) ld [wcea1], a call Func_b379 call Func_b704 - call Func_b545 + call PrintNumSavedDecks ld a, [wd086] jp .asm_b1b3 @@ -8108,7 +8285,7 @@ Unknown_b274: ; b274 (2:7274) Func_b285: ; b285 (2:7285) ld a, $05 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld hl, wd0a7 ld [hl], e inc hl @@ -8138,7 +8315,7 @@ Func_b29f: ; b29f (2:729f) ld a, [wcea1] ld [wd087], a ld b, a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wd086], a add b ld c, a @@ -8147,7 +8324,7 @@ Func_b29f: ; b29f (2:729f) ld [wCurDeck], a sla c ld b, $00 - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] @@ -8171,17 +8348,17 @@ Func_b29f: ; b29f (2:729f) ld [wcea1], a call Func_b379 call Func_b704 - call Func_b545 + call PrintNumSavedDecks ld a, [wd086] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a scf ret .asm_b303 - call Func_9c3a + call DrawListCursor_Visible ld a, [wcea1] ld [wd087], a - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld [wd086], a ld a, [hffb3] or a @@ -8226,7 +8403,7 @@ Func_b29f: ; b29f (2:729f) ld a, SFX_01 call PlaySFX call Func_b403 - call Func_b545 + call PrintNumSavedDecks .asm_b359 scf ret @@ -8237,7 +8414,7 @@ Func_b35b: ; b35b (2:735b) sla a ld l, a ld h, $00 - ld bc, wd00d + ld bc, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] @@ -8270,9 +8447,9 @@ Func_b379: ; b379 (2:7379) lb bc, 20, 13 call DrawRegularTextBox call Func_b3b3 - call Func_b3c3 + call GetSavedDeckPointers call Func_b3e5 - call Func_b525 + call GetSavedDeckCount call EnableLCD ret ; 0xb3b3 @@ -8288,16 +8465,17 @@ Func_b3b3: ; b3b3 (2:73b3) ret ; 0xb3c3 -Func_b3c3: ; b3c3 (2:73c3) - ld a, DECK_SIZE - add DECK_SIZE - ld hl, wd00d +; save all sSavedDecks pointers in wMachineDeckPtrs +GetSavedDeckPointers: ; b3c3 (2:73c3) + ld a, NUM_DECK_SAVE_MACHINE_SLOTS + add NUM_DECK_SAVE_MACHINE_SLOTS ; add a is better + ld hl, wMachineDeckPtrs call ClearNBytesFromHL - ld de, wd00d - ld hl, s0a350 - ld bc, $54 - ld a, DECK_SIZE -.asm_b3d8 + ld de, wMachineDeckPtrs + ld hl, sSavedDecks + ld bc, DECK_STRUCT_SIZE + ld a, NUM_DECK_SAVE_MACHINE_SLOTS +.loop_saved_decks push af ld a, l ld [de], a @@ -8308,7 +8486,7 @@ Func_b3c3: ; b3c3 (2:73c3) add hl, bc pop af dec a - jr nz, .asm_b3d8 + jr nz, .loop_saved_decks ret ; 0xb3e5 @@ -8372,7 +8550,7 @@ Func_b424: ; b424 (2:7424) sla a ld l, a ld h, $00 - ld bc, wd00d + ld bc, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] @@ -8381,12 +8559,15 @@ Func_b424: ; b424 (2:7424) inc d inc d push de - call Func_92be + call AppendDeckName pop de pop bc - jr nc, .asm_b46b + jr nc, .valid_deck + +; invalid deck, give it the default +; empty deck name ("--------------") call InitTextPrinting - ldtx hl, Text025b + ldtx hl, EmptyDeckNameText call ProcessTextFromID ld d, 13 inc e @@ -8396,13 +8577,13 @@ Func_b424: ; b424 (2:7424) scf ret -.asm_b46b +.valid_deck push de push bc ld d, 18 call InitTextPrinting - ld a, $00 - call Func_b625 + ld a, $0 + call CheckIfCanBuildSavedDeck pop bc ld hl, wDefaultText jr c, .asm_b482 @@ -8411,8 +8592,8 @@ Func_b424: ; b424 (2:7424) .asm_b482 push bc - ld a, $ff - call Func_b625 + ld a, ALL_DECKS + call CheckIfCanBuildSavedDeck jr c, .asm_b490 pop bc lb de, 3, "FW3_❄" @@ -8467,19 +8648,19 @@ Text_b4d4: ; b4d4 (2:74d4) db TX_SYMBOL, TX_END db TX_SYMBOL, TX_END db TX_SYMBOL, TX_END - db TX_END + done ; 0xb4e1 Func_b4e1: ; b4e1 (2:74e1) push bc - call Func_b644 - call Func_a3ca - call Func_b664 + call SafelySwitchToSRAM0 + call CreateCardCollectionListWithDeckCards + call SafelySwitchToTempSRAMBank pop bc sla b ld c, b ld b, $00 - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] @@ -8517,43 +8698,46 @@ Func_b4e1: ; b4e1 (2:74e1) ret ; 0xb525 -Func_b525: ; b525 (2:7525) +; counts how many decks in sSavedDecks are not empty +; stored value in wNumSavedDecks +GetSavedDeckCount: ; b525 (2:7525) call EnableSRAM - ld hl, s0a350 - ld bc, $54 - ld d, DECK_SIZE - ld e, $00 + ld hl, sSavedDecks + ld bc, DECK_STRUCT_SIZE + ld d, NUM_DECK_SAVE_MACHINE_SLOTS + ld e, 0 .loop ld a, [hl] or a - jr z, .asm_b537 + jr z, .empty_slot inc e -.asm_b537 +.empty_slot dec d - jr z, .asm_b53d + jr z, .got_count add hl, bc jr .loop -.asm_b53d +.got_count ld a, e - ld [wd085], a + ld [wNumSavedDecks], a call DisableSRAM ret ; 0xb545 -Func_b545: ; b545 (2:7545) - ld a, [wd085] - ld hl, wc590 +; prints "[wNumSavedDecks]/60" +PrintNumSavedDecks: ; b545 (2:7545) + ld a, [wNumSavedDecks] + ld hl, wDefaultText call ConvertToNumericalDigits ld a, TX_SYMBOL ld [hli], a ld a, SYM_SLASH ld [hli], a - ld a, DECK_SIZE + ld a, NUM_DECK_SAVE_MACHINE_SLOTS call ConvertToNumericalDigits ld [hl], TX_END - ld de, SerialHandleSend.send_escaped + ld de, $0e01 call InitTextPrinting - ld hl, wc590 + ld hl, wDefaultText call ProcessText ret ; 0xb568 @@ -8587,21 +8771,21 @@ Func_b592: ; b592 (2:7592) .Func_b5c8 call GetPointerToDeckName - call Func_b611 - ld b, $54 + call GetSelectedSavedDeckPtr + ld b, DECK_STRUCT_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM call Func_b379 call Func_b704 - call Func_b545 + call PrintNumSavedDecks ld a, [wd086] ld hl, Data_b6fb call Func_9a6d - call Func_9c3a + call DrawListCursor_Visible call GetPointerToDeckName call EnableSRAM - call Func_9253 + call CopyDeckName call DisableSRAM xor a ld [wTxRam2 + 0], a @@ -8621,14 +8805,16 @@ DeckMachineMenuParameters: ; b609 (2:7609) dw NULL ; function pointer if non-0 ; 0xb611 -Func_b611: ; b611 (2:7611) +; outputs in de pointer of saved deck +; corresponding to index in wd088 +GetSelectedSavedDeckPtr: ; b611 (2:7611) push af push hl ld a, [wd088] sla a ld e, a ld d, $00 - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, de ld e, [hl] inc hl @@ -8638,34 +8824,39 @@ Func_b611: ; b611 (2:7611) ret ; 0xb625 -Func_b625: ; b625 (2:7625) +; checks if it's possible to build saved deck with index b +; includes cards from already built decks from flags in a +; returns carry if cannot build the deck with the given criteria +; a = DECK_* flags for which decks to include in the collection +; b = saved deck index +CheckIfCanBuildSavedDeck: ; b625 (2:7625) push bc - call Func_b644 - call Func_a3ca - call Func_b664 + call SafelySwitchToSRAM0 + call CreateCardCollectionListWithDeckCards + call SafelySwitchToTempSRAMBank pop bc sla b ld c, b - ld b, $00 - ld hl, wd00d + ld b, $0 + ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc - call Func_b675 + call CheckIfHasEnoughCardsToBuildDeck ret ; 0xb644 -; switches to SRAM bank 0 and stores current SRAM bank in wd0a4 +; switches to SRAM bank 0 and stores current SRAM bank in wTempBankSRAM ; skips if current SRAM bank is already 0 -Func_b644: ; b644 (2:7644) +SafelySwitchToSRAM0: ; b644 (2:7644) push af ldh a, [hBankSRAM] or a jr z, .skip - ld [wd0a4], a + ld [wTempBankSRAM], a xor a call BankswitchSRAM .skip @@ -8673,14 +8864,14 @@ Func_b644: ; b644 (2:7644) ret ; 0xb653 -; switches to SRAM bank 1 and stores current SRAM bank in wd0a4 +; switches to SRAM bank 1 and stores current SRAM bank in wTempBankSRAM ; skips if current SRAM bank is already 1 -Func_b653: ; b653 (2:7653) +SafelySwitchToSRAM1: ; b653 (2:7653) push af ldh a, [hBankSRAM] cp BANK("SRAM1") jr z, .skip - ld [wd0a4], a + ld [wTempBankSRAM], a ld a, BANK("SRAM1") call BankswitchSRAM .skip @@ -8688,26 +8879,29 @@ Func_b653: ; b653 (2:7653) ret ; 0xb664 -Func_b664: ; b664 (2:7664) +SafelySwitchToTempSRAMBank: ; b664 (2:7664) push af push bc ldh a, [hBankSRAM] ld b, a - ld a, [wd0a4] + ld a, [wTempBankSRAM] cp b - jr z, .asm_b672 + jr z, .skip call BankswitchSRAM -.asm_b672 +.skip pop bc pop af ret ; 0xb675 -Func_b675: ; b675 (2:7675) +; returns carry if wTempCardCollection does not +; have enough cards to build deck pointed by hl +; hl = pointer to cards of deck to check +CheckIfHasEnoughCardsToBuildDeck: ; b675 (2:7675) call EnableSRAM ld de, wTempCardCollection ld b, 0 -.asm_b67d +.loop inc b ld a, DECK_SIZE cp b @@ -8720,12 +8914,12 @@ Func_b675: ; b675 (2:7675) ld a, [hl] or a jr z, .set_carry - cp $80 + cp CARD_NOT_OWNED jr z, .set_carry dec a ld [hl], a pop hl - jr .asm_b67d + jr .loop .set_carry pop hl @@ -8739,7 +8933,9 @@ Func_b675: ; b675 (2:7675) ret ; 0xb6a1 -Func_b6a1: ; b6a1 (2:76a1) +; outputs in a the first slot that is empty to build a deck +; if no empty slot is found, return carry +FindFirstEmptyDeckSlot: ; b6a1 (2:76a1) ld hl, sDeck1Cards ld a, [hl] or a @@ -8752,7 +8948,7 @@ Func_b6a1: ; b6a1 (2:76a1) ld a, [hl] or a jr nz, .check_deck_3 - ld a, $01 + ld a, 1 ret .check_deck_3 @@ -8760,7 +8956,7 @@ Func_b6a1: ; b6a1 (2:76a1) ld a, [hl] or a jr nz, .check_deck_4 - ld a, $02 + ld a, 2 ret .check_deck_4 @@ -8768,7 +8964,7 @@ Func_b6a1: ; b6a1 (2:76a1) ld a, [hl] or a jr nz, .set_carry - ld a, $03 + ld a, 3 ret .set_carry @@ -8776,18 +8972,22 @@ Func_b6a1: ; b6a1 (2:76a1) ret ; 0xb6ca -Func_b6ca: ; b6ca (2:76ca) +; prompts the player whether to delete selected saved deck +; if player selects yes, clears memory in SRAM +; corresponding to that saved deck slot +; if player selects no, return carry +TryDeleteSavedDeck: ; b6ca (2:76ca) ldtx hl, DoYouReallyWishToDeleteText call YesOrNoMenuWithText jr c, .no - call Func_b611 + call GetSelectedSavedDeckPtr ld l, e ld h, d push hl call EnableSRAM - call Func_9253 + call CopyDeckName pop hl - ld a, $54 + ld a, DECK_STRUCT_SIZE call ClearNBytesFromHL call DisableSRAM xor a @@ -8799,16 +8999,20 @@ Func_b6ca: ; b6ca (2:76ca) ret .no - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] scf ret ; 0xb6fb Data_b6fb: ; b6fb (2:76fb) - db $01, $02, $02, $00, $05 - db SYM_CURSOR_R - db SYM_SPACE - dw NULL + db 1 ; x pos + db 2 ; y pos + db 2 ; y spacing + db 0 ; x spacing + db 5 ; num entries + db SYM_CURSOR_R ; visible cursor tile + db SYM_SPACE ; invisible cursor tile + dw NULL ; wceac Func_b704: ; b704 (2:7704) ld a, [wcea1] @@ -8845,7 +9049,7 @@ Func_b704: ; b704 (2:7704) Func_b738: ; b738 (2:7738) ldtx hl, YouMayOnlyCarry4DecksText call DrawWideTextBox_WaitForInput - call Func_b644 + call SafelySwitchToSRAM0 ld a, $ff call DrawDecksScreen xor a @@ -8863,7 +9067,7 @@ Func_b738: ; b738 (2:7738) ldh a, [hCurMenuItem] cp $ff jr nz, .asm_b76c - call Func_b664 + call SafelySwitchToTempSRAMBank scf ret @@ -8885,9 +9089,9 @@ Func_b738: ; b738 (2:7738) push hl ld bc, $18 add hl, bc - call Func_9152 + call AddDeckToCollection pop hl - ld a, $54 + ld a, DECK_STRUCT_SIZE call ClearNBytesFromHL call DisableSRAM ld a, $ff @@ -8896,9 +9100,9 @@ Func_b738: ; b738 (2:7738) ld hl, DeckMachineMenuParameters call InitializeMenuParameters call DrawCursor2 - call Func_b664 + call SafelySwitchToTempSRAMBank ld hl, wd089 - call Func_9253 + call CopyDeckName xor a ld [wTxRam2 + 0], a ld [wTxRam2 + 1], a @@ -8912,12 +9116,12 @@ Func_b7c6: ; b7c6 (2:77c6) ld a, [wd088] ld b, a push bc - ld a, $00 - call Func_b625 + ld a, $0 + call CheckIfCanBuildSavedDeck pop bc jr nc, .asm_b7f3 - ld a, $ff - call Func_b625 + ld a, ALL_DECKS + call CheckIfCanBuildSavedDeck jr c, .asm_b7ea ldtx hl, ThisDeckCanOnlyBeBuiltIfYouDismantleText call DrawWideTextBox_WaitForInput @@ -8925,7 +9129,7 @@ Func_b7c6: ; b7c6 (2:77c6) jr nc, .asm_b7f3 .asm_b7e5 - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] scf ret @@ -8936,9 +9140,9 @@ Func_b7c6: ; b7c6 (2:77c6) .asm_b7f3 call EnableSRAM - call Func_b644 - call Func_b6a1 - call Func_b664 + call SafelySwitchToSRAM0 + call FindFirstEmptyDeckSlot + call SafelySwitchToTempSRAMBank call DisableSRAM jr nc, .asm_b80b call Func_b738 @@ -8952,29 +9156,29 @@ Func_b7c6: ; b7c6 (2:77c6) ld c, a ld b, $00 sla c - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] ld l, a ld de, wc000 - ld b, $54 + ld b, DECK_STRUCT_SIZE call EnableSRAM call CopyNBytesFromHLToDE ld hl, wc000 + $18 - call Func_b644 - call Func_910a + call SafelySwitchToSRAM0 + call DecrementDeckCardsInCollection ld a, [wd08a + $17] ld l, a - ld h, $54 + ld h, DECK_STRUCT_SIZE call HtimesL ld bc, sDeck1Name add hl, bc ld d, h ld e, l ld hl, wc000 - ld b, $54 + ld b, DECK_STRUCT_SIZE call CopyNBytesFromHLToDE call DisableSRAM @@ -8987,9 +9191,9 @@ Func_b7c6: ; b7c6 (2:77c6) call DrawCursor2 call GetPointerToDeckName call EnableSRAM - call Func_9253 + call CopyDeckName call DisableSRAM - call Func_b664 + call SafelySwitchToTempSRAMBank xor a ld [wTxRam2 + 0], a @@ -9002,13 +9206,13 @@ Func_b7c6: ; b7c6 (2:77c6) Func_b87d: ; b87d (2:787d) farcall Func_1ba9a - call Func_b644 + call SafelySwitchToSRAM0 call DrawDecksScreen ldtx hl, DismantleTheseDecksText call YesOrNoMenuWithText jr nc, .yes ; no - call Func_b664 + call SafelySwitchToTempSRAMBank scf ret @@ -9041,7 +9245,7 @@ Func_b87d: ; b87d (2:787d) call DisableSRAM ld a, [wd0a6] call DrawDecksScreen - call Func_b664 + call SafelySwitchToTempSRAMBank ldtx hl, DismantledTheDeckText call DrawWideTextBox_WaitForInput or a @@ -9049,16 +9253,16 @@ Func_b87d: ; b87d (2:787d) .Func_b8db ld l, a - ld h, $54 + ld h, DECK_STRUCT_SIZE call HtimesL ld bc, sDeck1Name add hl, bc push hl ld bc, $18 add hl, bc - call Func_9152 + call AddDeckToCollection pop hl - ld a, $54 + ld a, DECK_STRUCT_SIZE call ClearNBytesFromHL ret ; 0xb8f4 @@ -9066,7 +9270,7 @@ Func_b87d: ; b87d (2:787d) Func_b8f4: ; b8f4 (2:78f4) ld a, [wd088] ld [wCurDeck], a - call Func_b611 + call GetSelectedSavedDeckPtr ld hl, $18 add hl, de ld de, wCurDeckCards @@ -9074,14 +9278,14 @@ Func_b8f4: ; b8f4 (2:78f4) call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM - xor a - ld [wcf53], a + xor a ; terminator byte for deck + ld [wCurDeckCards + DECK_SIZE], a call SortCurDeckCardsByID call CreateCurDeckUniqueCardList - ld a, $ff - call Func_b644 - call Func_a3ca - call Func_b664 + ld a, ALL_DECKS + call SafelySwitchToSRAM0 + call CreateCardCollectionListWithDeckCards + call SafelySwitchToTempSRAMBank ld hl, wTempHandCardList ld de, wHandTempList .asm_b92a @@ -9115,7 +9319,7 @@ Func_b8f4: ; b8f4 (2:78f4) ld [hli], a ld a, b ld [hl], a - call Func_b611 + call GetSelectedSavedDeckPtr ld h, d ld l, e ld de, wHandTempList @@ -9181,7 +9385,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) ld hl, Data_b6fb call Func_9a6d call Func_b704 - call Func_b545 + call PrintNumSavedDecks ld hl, WaitForVBlank.lcd_off call DrawWideTextBox_PrintText ld de, WaitForVBlank.lcd_off @@ -9202,7 +9406,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) ldtx hl, PrintThisDeckText call YesOrNoMenuWithText jr c, .no - call Func_b611 + call GetSelectedSavedDeckPtr ld hl, $18 add hl, de ld de, wCurDeckCards @@ -9210,8 +9414,8 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM - xor a - ld [wcf53], a + xor a ; terminator byte for deck + ld [wCurDeckCards + DECK_SIZE], a call SortCurDeckCardsByID ld a, [wd088] bank1call Func_7580 @@ -9219,7 +9423,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) .no ld a, [wd086] - ld [wNamingScreenCursorY], a + ld [wCardListCursorPos], a jp .asm_b99e ; 0xba04 @@ -9250,7 +9454,7 @@ Func_ba25: ; ba25 (2:7a25) ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText ld a, $5 - ld [wNamingScreenKeyboardHeight], a + ld [wCardListNumCursorPositions], a ld hl, Func_b3fe ld d, h ld a, l @@ -9281,9 +9485,9 @@ Func_ba25: ; ba25 (2:7a25) ld [wCurDeck], a sla c ld b, $0 - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, bc - call Func_b653 + call SafelySwitchToSRAM1 ld a, [hli] ld h, [hl] ld l, a @@ -9294,14 +9498,14 @@ Func_ba25: ; ba25 (2:7a25) ld e, l ld a, [hl] pop hl - call Func_b644 + call SafelySwitchToSRAM0 or a jr z, .asm_ba40 ld a, $1 call PlaySFXConfirmOrCancel - call Func_b653 + call SafelySwitchToSRAM1 call HandleDeckConfirmationMenu - call Func_b644 + call SafelySwitchToSRAM0 ld a, [wd087] ld [wcea1], a call Func_bb97 @@ -9340,9 +9544,9 @@ Func_ba25: ; ba25 (2:7a25) add [hl] or a jr nz, .asm_bb09 - call Func_b653 + call SafelySwitchToSRAM1 call Func_b7c6 - call Func_b644 + call SafelySwitchToSRAM0 ld a, [wd086] jp nc, Func_ba25 ld a, [wd087] @@ -9356,7 +9560,7 @@ Func_ba25: ; ba25 (2:7a25) jr nz, .asm_bb12 .asm_bb0d xor a - ld [wd0a4], a + ld [wTempBankSRAM], a ret .asm_bb12 @@ -9370,7 +9574,7 @@ Func_ba25: ; ba25 (2:7a25) ld [wCurDeck], a sla c ld b, $0 - ld hl, wd00d + ld hl, wMachineDeckPtrs add hl, bc push hl ld hl, wd0aa @@ -9382,7 +9586,7 @@ Func_ba25: ; ba25 (2:7a25) ld a, [hl] ld [bc], a pop hl - call Func_b653 + call SafelySwitchToSRAM1 ld a, [hli] ld h, [hl] ld l, a @@ -9393,15 +9597,15 @@ Func_ba25: ; ba25 (2:7a25) ld e, l ld a, [hl] pop hl - call Func_b644 + call SafelySwitchToSRAM0 or a jp z, .asm_ba40 ld a, $1 call PlaySFXConfirmOrCancel - call Func_b653 + call SafelySwitchToSRAM1 xor a call Func_adfe - call Func_b644 + call SafelySwitchToSRAM0 ld a, [wd087] ld [wcea1], a call Func_bb97 @@ -9458,23 +9662,23 @@ Func_bb97: ; bb97 (2:7b97) ld h, [hl] ld l, a call ProcessTextFromID - call Func_b653 + call SafelySwitchToSRAM1 farcall Func_1ba14 call Func_bbe4 call Func_b3e5 - call Func_b644 + call SafelySwitchToSRAM0 call EnableLCD ret ; 0xbbe4 Func_bbe4: ; bbe4 (2:7be4) - ld a, $0a - ld hl, wd00d + ld a, 2 * NUM_DECK_MACHINE_SLOTS + ld hl, wMachineDeckPtrs call ClearNBytesFromHL - ld de, wd00d - ld hl, s0a350 - ld bc, $54 - ld a, $05 + ld de, wMachineDeckPtrs + ld hl, sSavedDecks + ld bc, DECK_STRUCT_SIZE + ld a, NUM_DECK_MACHINE_SLOTS .loop push af ld a, l @@ -9506,7 +9710,7 @@ Func_bc04: ; bc04 (2:7c04) ld hl, Data_b6fb call Func_9a6d call Func_b704 - call Func_b545 + call PrintNumSavedDecks ldtx hl, PleaseChooseADeckConfigurationToSendText call DrawWideTextBox_PrintText ldtx de, PleaseChooseADeckConfigurationToSendText @@ -9527,11 +9731,11 @@ Func_bc04: ; bc04 (2:7c04) call Func_b35b jr c, .asm_bc32 - call Func_b611 + call GetSelectedSavedDeckPtr ld l, e ld h, d ld de, wDuelTempList - ld b, $54 + ld b, DECK_STRUCT_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM @@ -9541,7 +9745,7 @@ Func_bc04: ; bc04 (2:7c04) bank1call Func_7562 ret c - call Func_b611 + call GetSelectedSavedDeckPtr ld l, e ld h, d ld de, wDefaultText @@ -9568,7 +9772,7 @@ Func_bc7a: ; bc7a (2:7c7a) ld hl, Data_b6fb call Func_9a6d call Func_b704 - call Func_b545 + call PrintNumSavedDecks ldtx hl, PleaseChooseASaveSlotText call DrawWideTextBox_PrintText ldtx de, PleaseChooseASaveSlotText @@ -9592,7 +9796,7 @@ Func_bc7a: ; bc7a (2:7c7a) ldtx hl, OKIfFileDeletedText call YesOrNoMenuWithText jr nc, .asm_bcd1 - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] jr .asm_bc90 .asm_bcd1 xor a @@ -9602,18 +9806,18 @@ Func_bc7a: ; bc7a (2:7c7a) ret c call EnableSRAM ld hl, wDuelTempList - call Func_b611 - ld b, $54 + call GetSelectedSavedDeckPtr + ld b, DECK_STRUCT_SIZE call CopyNBytesFromHLToDE call DisableSRAM call SaveGame call Func_b379 - ld a, [wNamingScreenCursorY] + ld a, [wCardListCursorPos] ld hl, Data_b6fb call Func_9a6d call Func_b704 - call Func_b545 - call Func_9c3a + call PrintNumSavedDecks + call DrawListCursor_Visible ld hl, wNameBuffer ld de, wDefaultText call CopyListFromHLToDE @@ -9622,7 +9826,7 @@ Func_bc7a: ; bc7a (2:7c7a) ld [wTxRam2 + 1], a ldtx hl, ReceivedADeckConfigurationFromText call DrawWideTextBox_WaitForInput - call Func_b611 + call GetSelectedSavedDeckPtr ld l, e ld h, d ld de, wDefaultText diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index fa60650..dfffa88 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1173,7 +1173,7 @@ Func_c7b8: ; c7b8 (3:47b8) ldh [hSCY], a call Set_OBJ_8x16 farcall Func_1288c - farcall Func_8db0 + farcall DeckSelectionMenu call Set_OBJ_8x8 ret diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 5ff33a1..89d7093 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -2050,29 +2050,32 @@ Func_1996e: ; 1996e (6:596e) ldh [hWhoseTurn], a ld hl, sCardCollection ld bc, $1607 -.asm_1997b +.loop_clear xor a ld [hli], a dec bc ld a, c or b - jr nz, .asm_1997b - ld a, $5 - ld hl, s0a350 + jr nz, .loop_clear + + ld a, CHARMANDER_AND_FRIENDS_DECK + ld hl, sSavedDeck1 call Func_199e0 - ld a, $7 - ld hl, s0a3a4 + ld a, SQUIRTLE_AND_FRIENDS_DECK + ld hl, sSavedDeck2 call Func_199e0 - ld a, $9 - ld hl, s0a3f8 + ld a, BULBASAUR_AND_FRIENDS_DECK + ld hl, sSavedDeck3 call Func_199e0 + call EnableSRAM ld hl, sCardCollection ld a, CARD_NOT_OWNED -.asm_199a2 +.loop_collection ld [hl], a inc l - jr nz, .asm_199a2 + jr nz, .loop_collection + ld hl, sCurrentDuel xor a ld [hli], a @@ -2080,13 +2083,14 @@ Func_1996e: ; 1996e (6:596e) ld [hl], a ld hl, sCardPopNameList - ld c, $10 -.asm_199b2 + ld c, CARDPOP_NAME_LIST_MAX_ELEMS +.loop_card_pop_names ld [hl], $0 - ld de, $0010 + ld de, NAME_BUFFER_LENGTH add hl, de dec c - jr nz, .asm_199b2 + jr nz, .loop_card_pop_names + ld a, 2 ld [sPrinterContrastLevel], a ld a, $2 @@ -3592,9 +3596,9 @@ InputPlayerName: ; 1a7a3 (6:67a3) ld a, $06 ld [wNamingScreenKeyboardHeight], a ld a, $0f - ld [wceaa], a + ld [wVisibleCursorTile], a ld a, $00 - ld [wceab], a + ld [wInvisibleCursorTile], a .loop ld a, $01 ld [wVBlankOAMCopyToggle], a @@ -3950,12 +3954,12 @@ NamingScreen_CheckButtonState: ; 1a908 (6:6908) inc [hl] and $0f ret nz - ld a, [wceaa] + ld a, [wVisibleCursorTile] bit 4, [hl] jr z, Func_1aa07.asm_6a0a Func_1aa07: ; 1aa07 (6:6a07) - ld a, [wceab] + ld a, [wInvisibleCursorTile] .asm_6a0a ld e, a ld a, [wNamingScreenCursorX] @@ -3974,7 +3978,7 @@ Func_1aa07: ; 1aa07 (6:6a07) ret Func_1aa23: ; 1aa23 (6:6a23) - ld a, [wceaa] + ld a, [wVisibleCursorTile] jr Func_1aa07.asm_6a0a Func_1aa28: ; 1aa28 (6:6a28) @@ -3986,7 +3990,7 @@ Func_1aa28: ; 1aa28 (6:6a28) call ZeroObjectPositions pop af ld b, a - ld a, [wceab] + ld a, [wInvisibleCursorTile] cp b jr z, .asm_6a60 ld a, [wNamingScreenBufferLength] @@ -4456,9 +4460,9 @@ InputDeckName: ; 1ad89 (6:6d89) ld a, $07 ld [wNamingScreenKeyboardHeight], a ld a, $0f - ld [wceaa], a + ld [wVisibleCursorTile], a ld a, $00 - ld [wceab], a + ld [wInvisibleCursorTile], a .loop ld a, $01 ld [wVBlankOAMCopyToggle], a @@ -4748,12 +4752,12 @@ Func_1aefb: ; 1aefb (6:6efb) inc [hl] and $0f ret nz - ld a, [wceaa] + ld a, [wVisibleCursorTile] bit 4, [hl] jr z, Func_1afa1.asm_6fa4 Func_1afa1: ; 1afa1 (6:6fa1) - ld a, [wceab] + ld a, [wInvisibleCursorTile] .asm_6fa4 ld e, a ld a, [wNamingScreenCursorX] @@ -4772,7 +4776,7 @@ Func_1afa1: ; 1afa1 (6:6fa1) ret Func_1afbd: ; 1afbd (6:6fbd) - ld a, [wceaa] + ld a, [wVisibleCursorTile] jr Func_1afa1.asm_6fa4 Func_1afc2: ; 1afc2 (6:6fc2) @@ -4784,7 +4788,7 @@ Func_1afc2: ; 1afc2 (6:6fc2) call ZeroObjectPositions pop af ld b, a - ld a, [wceab] + ld a, [wInvisibleCursorTile] cp b jr z, .asm_6ffb ld a, [wNamingScreenBufferLength] @@ -4963,9 +4967,9 @@ Func_1ba14: ; 1ba14 (6:7a14) Func_1ba4c: ; 1ba4c (6:7a4c) push hl ld l, b - ld h, $54 + ld h, DECK_STRUCT_SIZE call HtimesL - ld de, s0a350 + ld de, sSavedDecks add hl, de ld d, h ld e, l @@ -5080,7 +5084,7 @@ Func_1bae4: ; 1bae4 (6:7ae4) push af ld hl, wd088 ld b, [hl] - farcall Func_b625 + farcall CheckIfCanBuildSavedDeck jr c, .asm_7af5 pop af ld [wd0a6], a diff --git a/src/macros/wram.asm b/src/macros/wram.asm index 5e7eb1c..5eca96b 100644 --- a/src/macros/wram.asm +++ b/src/macros/wram.asm @@ -93,3 +93,8 @@ duel_anim_struct: MACRO \1Unknown2:: ds 1 \1Bank:: ds 1 ENDM + +deck_struct: MACRO +\1Name:: ds DECK_NAME_SIZE +\1Cards:: ds DECK_SIZE +ENDM diff --git a/src/sram.asm b/src/sram.asm index cb8d7d2..f1e5549 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -44,47 +44,89 @@ sPlayerName:: ; a010 sCardCollection:: ; a100 ds $100 -sDeck1Name:: ; a200 - ds DECK_NAME_SIZE -sDeck1Cards:: ; a218 - ds DECK_SIZE - -sDeck2Name:: ; a254 - ds DECK_NAME_SIZE -sDeck2Cards:: ; a26c - ds DECK_SIZE - -sDeck3Name:: ; a2a8 - ds DECK_NAME_SIZE -sDeck3Cards:: ; a2c0 - ds DECK_SIZE - -sDeck4Name:: ; a2fc - ds DECK_NAME_SIZE -sDeck4Cards:: ; a314 - ds DECK_SIZE - -s0a350:: ; a350 - ds DECK_NAME_SIZE + DECK_SIZE -s0a3a4:: ; a3a4 - ds DECK_NAME_SIZE + DECK_SIZE -s0a3f8:: ; a3f8 - ds DECK_NAME_SIZE + DECK_SIZE - - ds $12b4 +sDeck1:: deck_struct sDeck1 ; a200 +sDeck2:: deck_struct sDeck2 ; a254 +sDeck3:: deck_struct sDeck3 ; a2a8 +sDeck4:: deck_struct sDeck4 ; a2fc + +sSavedDecks:: +sSavedDeck1:: deck_struct sSavedDeck1 ; a350 +sSavedDeck2:: deck_struct sSavedDeck2 ; a3a4 +sSavedDeck3:: deck_struct sSavedDeck3 ; a3f8 +sSavedDeck4:: deck_struct sSavedDeck4 ; a44c +sSavedDeck5:: deck_struct sSavedDeck5 ; a4a0 +sSavedDeck6:: deck_struct sSavedDeck6 ; a4f4 +sSavedDeck7:: deck_struct sSavedDeck7 ; a548 +sSavedDeck8:: deck_struct sSavedDeck8 ; a59c +sSavedDeck9:: deck_struct sSavedDeck9 ; a5f0 +sSavedDeck10:: deck_struct sSavedDeck10 ; a644 +sSavedDeck11:: deck_struct sSavedDeck11 ; a698 +sSavedDeck12:: deck_struct sSavedDeck12 ; a6ec +sSavedDeck13:: deck_struct sSavedDeck13 ; a740 +sSavedDeck14:: deck_struct sSavedDeck14 ; a794 +sSavedDeck15:: deck_struct sSavedDeck15 ; a7e8 +sSavedDeck16:: deck_struct sSavedDeck16 ; a83c +sSavedDeck17:: deck_struct sSavedDeck17 ; a890 +sSavedDeck18:: deck_struct sSavedDeck18 ; a8e4 +sSavedDeck19:: deck_struct sSavedDeck19 ; a938 +sSavedDeck20:: deck_struct sSavedDeck20 ; a98c +sSavedDeck21:: deck_struct sSavedDeck21 ; a9e0 +sSavedDeck22:: deck_struct sSavedDeck22 ; aa34 +sSavedDeck23:: deck_struct sSavedDeck23 ; aa88 +sSavedDeck24:: deck_struct sSavedDeck24 ; aadc +sSavedDeck25:: deck_struct sSavedDeck25 ; ab30 +sSavedDeck26:: deck_struct sSavedDeck26 ; ab84 +sSavedDeck27:: deck_struct sSavedDeck27 ; abd8 +sSavedDeck28:: deck_struct sSavedDeck28 ; ac2c +sSavedDeck29:: deck_struct sSavedDeck29 ; ac80 +sSavedDeck30:: deck_struct sSavedDeck30 ; acd4 +sSavedDeck31:: deck_struct sSavedDeck31 ; ad28 +sSavedDeck32:: deck_struct sSavedDeck32 ; ad7c +sSavedDeck33:: deck_struct sSavedDeck33 ; add0 +sSavedDeck34:: deck_struct sSavedDeck34 ; ae24 +sSavedDeck35:: deck_struct sSavedDeck35 ; ae78 +sSavedDeck36:: deck_struct sSavedDeck36 ; aecc +sSavedDeck37:: deck_struct sSavedDeck37 ; af20 +sSavedDeck38:: deck_struct sSavedDeck38 ; af74 +sSavedDeck39:: deck_struct sSavedDeck39 ; afc8 +sSavedDeck40:: deck_struct sSavedDeck40 ; b01c +sSavedDeck41:: deck_struct sSavedDeck41 ; b070 +sSavedDeck42:: deck_struct sSavedDeck42 ; b0c4 +sSavedDeck43:: deck_struct sSavedDeck43 ; b118 +sSavedDeck44:: deck_struct sSavedDeck44 ; b16c +sSavedDeck45:: deck_struct sSavedDeck45 ; b1c0 +sSavedDeck46:: deck_struct sSavedDeck46 ; b214 +sSavedDeck47:: deck_struct sSavedDeck47 ; b268 +sSavedDeck48:: deck_struct sSavedDeck48 ; b2bc +sSavedDeck49:: deck_struct sSavedDeck49 ; b310 +sSavedDeck50:: deck_struct sSavedDeck50 ; b364 +sSavedDeck51:: deck_struct sSavedDeck51 ; b3b8 +sSavedDeck52:: deck_struct sSavedDeck52 ; b40c +sSavedDeck53:: deck_struct sSavedDeck53 ; b460 +sSavedDeck54:: deck_struct sSavedDeck54 ; b4b4 +sSavedDeck55:: deck_struct sSavedDeck55 ; b508 +sSavedDeck56:: deck_struct sSavedDeck56 ; b55c +sSavedDeck57:: deck_struct sSavedDeck57 ; b5b0 +sSavedDeck58:: deck_struct sSavedDeck58 ; b604 +sSavedDeck59:: deck_struct sSavedDeck59 ; b658 +sSavedDeck60:: deck_struct sSavedDeck60 ; b6ac sCurrentlySelectedDeck:: ; b700 ds $1 -sb701:: ; b701 +; 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:: ; b701 ds $1 ds $1 sb703:: ; b703 - ds $1 + ds $4 - ds $fc + ds $f9 sb800:: ; b800 ds $8 diff --git a/src/text/text2.asm b/src/text/text2.asm index 933f8ff..ded4bd9 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1828,7 +1828,7 @@ SCardsText: ; 3bdd1 (e:7dd1) text "'s Cards" done -Text025b: ; 3bddb (e:7ddb) +EmptyDeckNameText: ; 3bddb (e:7ddb) textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index c656626..636ccbf 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -604,7 +604,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer ViewWhichCardFileText ; 0x0258 textpointer Text0259 ; 0x0259 textpointer SCardsText ; 0x025a - textpointer Text025b ; 0x025b + textpointer EmptyDeckNameText ; 0x025b textpointer DeckSaveMachineText ; 0x025c textpointer SaveADeckText ; 0x025d textpointer DeleteADeckText ; 0x025e diff --git a/src/wram.asm b/src/wram.asm index e2db894..bb7de79 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -448,17 +448,7 @@ UNION ; this is kept updated with some default text that is used ; when the text printing functions are called with text id $0000 wDefaultText:: ; c590 - ds $2 - -wc592:: ; c592 - ds $3 - - ds $15 - -wc5aa:: ; c5aa - ds $1 - - ds $21 + ds $3c NEXTU @@ -1913,28 +1903,38 @@ wcea1:: ; cea1 wCheckMenuCursorBlinkCounter:: ; cea3 ds $1 +; used to temporarily store wCurCardTypeFilter +; to check whether a new filter is to be applied +wTempCardTypeFilter:: ; cea4 + +wCardListCursorPos:: ; cea4 + wNamingScreenCursorY:: ; cea4 ds $1 -wcea5:: ; cea5 +wCardListCursorXPos:: ; cea5 ds $1 -wcea6:: ; cea6 +wCardListCursorYPos:: ; cea6 ds $1 -wcea7:: ; cea7 +wCardListYSpacing:: ; cea7 ds $1 -wcea8:: ; cea8 +wCardListXSpacing:: ; cea8 ds $1 +wCardListNumCursorPositions:: ; cea9 + wNamingScreenKeyboardHeight:: ; cea9 ds $1 -wceaa:: ; ceaa +; tile to draw when cursor is blinking +wVisibleCursorTile:: ; ceaa ds $1 -wceab:: ; ceab +; tile to draw when cursor is visible +wInvisibleCursorTile:: ; ceab ds $1 wceac:: ; ceac @@ -1978,10 +1978,14 @@ wOnesAndTensPlace:: ; ceb6 wCardFilterCounts:: ; cebb ds NUM_FILTERS -wcec4:: ; cec4 - ds $7 +; buffer used to show which card IDs +; are visible in a given list +wVisibleListCardIDs:: ; cec4 + ds MAX_DECK_CONFIRMATION_VISIBLE_CARDS -wcecb:: ; cecb +; number of visible entries +; when showing a list of cards +wNumVisibleCardListEntries:: ; cecb ds $1 wTotalCardCount:: ; cecc @@ -2035,17 +2039,17 @@ wHandTempList:: ; ceda wceda:: ; ceda ds DECK_SIZE +; terminator for wceda wcf16:: ; cf16 ds $1 -; used in bank2, probably related to wTempHandCardList (another temp list?) +; holds cards for the current deck wCurDeckCards:: ; cf17 - ds DECK_SIZE + ds DECK_CONFIG_BUFFER_SIZE -wcf53:: ; cf53 +wCurDeckCardsTerminator:: ; cf67 ds $1 - - ds $14 +wCurDeckCardsEnd:: ; stores the count number of cards owned ; can be 0 in the case that a card is not available @@ -2062,21 +2066,35 @@ wTempHandCardList:: ; cf68 wCurDeckName:: ; cfb9 ds DECK_NAME_SIZE -wcfd1:: ; cfd1 +; max number of cards that are allowed +; to include when building a deck configuration +wMaxNumCardsAllowed:: ; cfd1 ds $1 -wcfd2:: ; cfd2 +; max number of cards with same name that are allowed +; to be included when building a deck configuration +wSameNameCardsLimit:: ; cfd2 ds $1 -wcfd3:: ; cfd3 +; 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:: ; cfd3 ds $1 -wcfd4:: ; cfd4 +; pointer to a function that handles the menu +; when building a deck configuration +wDeckConfigurationMenuHandlerFunction:: ; cfd4 ds $2 -wcfd6:: ; cfd6 +; pointer to a transition table for the +; function in wDeckConfigurationMenuHandlerFunction +wDeckConfigurationMenuTransitionTable:: ; cfd6 ds $2 +; pointer to a list of cards wcfd8:: ; cfd8 ds $2 @@ -2109,7 +2127,8 @@ wPlaysSfx:: ; cfe3 wcfe4:: ; cfe4 ds $1 -wcfe5:: ; cfe5 +; collection index of the first owned card +wFirstOwnedCardIndex:: ; cfe5 ds $1 wcfe6:: ; cfe6 @@ -2148,12 +2167,11 @@ wNamingScreenNamePosition:: ; d007 wd009:: ; d009 ds $4 -wd00d:: ; d00d - ds $18 - - ds $60 +; pointers to all decks of current deck machine +wMachineDeckPtrs:: ; d00d + ds 2 * NUM_DECK_SAVE_MACHINE_SLOTS -wd085:: ; d085 +wNumSavedDecks:: ; d085 ds $1 wd086:: ; d086 @@ -2174,7 +2192,7 @@ wd08a:: ; d08a wd0a2:: ; d0a2 ds $2 -wd0a4:: ; d0a4 +wTempBankSRAM:: ; d0a4 ds $1 wd0a5:: ; d0a5 -- cgit v1.2.3 From 7f3a75ee22b403b74051f733bedee73040622ddc Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 7 May 2021 11:00:42 +0100 Subject: Document functions related to deck building screen --- src/engine/bank02.asm | 843 +++++++++++++++++++++++++++----------------------- src/engine/bank03.asm | 2 +- src/wram.asm | 34 +- 3 files changed, 487 insertions(+), 392 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index f8297bd..5c16f2f 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2155,10 +2155,11 @@ CopyDeckFromSRAM: ; 8cd4 (2:4cd4) ret ; 0x8ce7 -; clears some WRAM addresses -Func_8ce7: ; 8ce7 (2:4ce7) +; clears some WRAM addresses to act as +; terminator bytes to wFilteredCardList and wCurDeckCards +WriteCardListsTerminatorBytes: ; 8ce7 (2:4ce7) xor a - ld hl, wceda + ld hl, wFilteredCardList ld bc, DECK_SIZE add hl, bc ld [hl], a ; wcf16 @@ -2319,7 +2320,7 @@ HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea) push hl call GetPointerToDeckName pop de - call HandleDeckConfirmationMenu + call OpenDeckConfirmationMenu ld a, $ff call DrawDecksScreen ld a, [wCurDeck] @@ -2327,7 +2328,7 @@ HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea) ret ; 0x8e1f -HandleDeckConfirmationMenu: ; 8e1f (2:4e1f) +OpenDeckConfirmationMenu: ; 8e1f (2:4e1f) ; copy deck name push de ld de, wCurDeckName @@ -2345,7 +2346,7 @@ HandleDeckConfirmationMenu: ; 8e1f (2:4e1f) ld [wTotalCardCount], a ld hl, wCardFilterCounts ld [hl], a - call Func_9e41 + call HandleDeckConfirmationMenu ret ; 0x8e42 @@ -2392,7 +2393,7 @@ DeckSelectionSubMenu: ; 8e42 (2:4e42) call GetPointerToDeckName call CopyListFromHLToDEInSRAM - call Func_9345 + call HandleDeckBuildScreen jr nc, .asm_8ec4 call EnableSRAM ld hl, wCurDeckCards @@ -3198,25 +3199,29 @@ DrawHandCardsTileAtDE: ; 9339 (2:5339) ret ; 0x9345 -Func_9345: ; 9345 (2:5345) - call Func_8ce7 +; handles user input when selecting a card filter +; when building a deck configuration +; the handling of selecting cards themselves from the list +; to add/remove to the deck is done in HandleDeckCardSelectionList +HandleDeckBuildScreen: ; 9345 (2:5345) + call WriteCardListsTerminatorBytes call CountNumberOfCardsForEachCardType .skip_count call DrawCardTypeIconsAndPrintCardCounts xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld [wCurCardTypeFilter], a ; FILTER_GRASS call PrintFilteredCardList .skip_draw - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams .wait_input call DoFrame ldh a, [hDPadHeld] and START - jr z, .no_start_btn + jr z, .no_start_btn_1 ld a, $01 call PlaySFXConfirmOrCancel call ConfirmDeckConfiguration @@ -3224,7 +3229,7 @@ Func_9345: ; 9345 (2:5345) ld [wTempCardTypeFilter], a jr .wait_input -.no_start_btn +.no_start_btn_1 ld a, [wCurCardTypeFilter] ld b, a ld a, [wTempCardTypeFilter] @@ -3232,8 +3237,8 @@ Func_9345: ; 9345 (2:5345) jr z, .check_down_btn ; need to refresh the filtered card list ld [wCurCardTypeFilter], a - ld hl, wcea1 - ld [hl], $00 + ld hl, wCardListVisibleOffset + ld [hl], 0 call PrintFilteredCardList ld a, NUM_FILTERS ld [wCardListNumCursorPositions], a @@ -3243,29 +3248,34 @@ Func_9345: ; 9345 (2:5345) and D_DOWN jr z, .no_down_btn call ConfirmSelectionAndReturnCarry - jr .asm_93a9 + jr .jump_to_list .no_down_btn - call Func_9a83 + call HandleCardSelectionInput jr nc, .wait_input ld a, [hffb3] - cp $ff + cp $ff ; operation cancelled? jp z, OpenDeckConfigurationMenu -.asm_93a9 - ld a, [wceae] + +; input was made to jump to the card list +.jump_to_list + ld a, [wNumEntriesInCurFilter] or a jr z, .wait_input xor a -.asm_93b0 - ld hl, Data_9670 - call Func_9a6d - ld a, [wceae] - ld [wcfe6], a +.wait_list_input + ld hl, FilteredCardListSelectionParams + call InitCardSelectionParams + ld a, [wNumEntriesInCurFilter] + ld [wNumCardListEntries], a ld hl, wNumVisibleCardListEntries cp [hl] - jr nc, .asm_93c5 + jr nc, .ok + ; if total number of entries is greater or equal than + ; the number of visible entries, then set number of cursor positions + ; as number of visible entries ld [wCardListNumCursorPositions], a -.asm_93c5 +.ok ld hl, PrintDeckBuildingCardList ld d, h ld a, l @@ -3275,61 +3285,71 @@ Func_9345: ; 9345 (2:5345) ld a, $01 ld [wced2], a -.asm_93d4 +.loop_input call DoFrame ldh a, [hDPadHeld] and START - jr z, .asm_93f0 + jr z, .no_start_btn_2 ld a, $01 call PlaySFXConfirmOrCancel + + ; temporarily store current cursor position + ; to retrieve it later ld a, [wCardListCursorPos] - ld [wced5], a + ld [wTempFilteredCardListNumCursorPositions], a call ConfirmDeckConfiguration - ld a, [wced5] - jr .asm_93b0 -.asm_93f0 - call Func_9efc - jr c, .asm_93d4 - call Func_9b25 - jr c, .asm_9442 - jr .asm_93d4 -.asm_93fc + ld a, [wTempFilteredCardListNumCursorPositions] + jr .wait_list_input + +.no_start_btn_2 + call HandleSelectUpAndDownInList + jr c, .loop_input + call HandleDeckCardSelectionList + jr c, .selection_made + jr .loop_input + +.open_card_page ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListNumCursorPositions] - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a ld a, [wCardListCursorPos] - ld [wced4], a - ld de, wceda - ld hl, wcfd8 + ld [wTempCardListCursorPos], a + + ; set wFilteredCardList as current card list + ; and show card page screen + ld de, wFilteredCardList + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f + call OpenCardPageFromCardList call DrawCardTypeIconsAndPrintCardCounts - ld hl, Data_9667 - call Func_9a6d + + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible call PrintDeckBuildingCardList - ld hl, Data_9670 - call Func_9a6d - ld a, [wcfdf] + ld hl, FilteredCardListSelectionParams + call InitCardSelectionParams + ld a, [wTempCardListNumCursorPositions] ld [wCardListNumCursorPositions], a - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a - jr .asm_93d4 + jr .loop_input -.asm_9442 +.selection_made call DrawListCursor_Invisible ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff - jr nz, .asm_93fc - ld hl, Data_9667 - call Func_9a6d + jr nz, .open_card_page + ; cancelled + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a jp .wait_input @@ -3375,11 +3395,11 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) jr nz, .asm_94b5 .draw_icons call DrawCardTypeIconsAndPrintCardCounts - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a ld a, [wCurCardTypeFilter] call PrintFilteredCardList - jp Func_9345.skip_draw + jp HandleDeckBuildScreen.skip_draw .asm_94b5 push af @@ -3401,18 +3421,18 @@ HandleDeckConfigurationMenu: ; 9480 (2:5480) ; 0x94d3 ConfirmDeckConfiguration: ; 94d3 (2:54d3) - ld hl, wcea1 + ld hl, wCardListVisibleOffset ld a, [hl] ld hl, wced8 ld [hl], a - call Func_9e41 + call HandleDeckConfirmationMenu ld hl, wced8 ld a, [hl] - ld hl, wcea1 + ld hl, wCardListVisibleOffset ld [hl], a call DrawCardTypeIconsAndPrintCardCounts - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible @@ -3428,14 +3448,16 @@ ModifyDeckConfiguration: ; 9505 (2:5505) jr HandleDeckConfigurationMenu.draw_icons ; 0x9509 -; returns carry set if player chose to save deck +; returns carry set if player chose to go back CancelDeckModifications: ; 9509 (2:5509) - call Func_95c1 - jr nc, .asm_9516 +; if deck was not changed, cancel modification immediately + call CheckIfCurrentDeckWasChanged + jr nc, .cancel_modification +; else prompt the player to confirm ldtx hl, QuitModifyingTheDeckText call YesOrNoMenuWithText jr c, SaveDeckConfiguration.go_back -.asm_9516 +.cancel_modification add sp, $2 or a ret @@ -3492,8 +3514,8 @@ DismantleDeck: ; 9566 (2:5566) ldtx hl, ThereIsOnly1DeckSoCannotBeDismantledText call DrawWideTextBox_WaitForInput call EmptyScreen - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible @@ -3524,27 +3546,29 @@ DismantleDeck: ; 9566 (2:5566) ChangeDeckName: ; 95b9 (2:55b9) call InputCurDeckName add sp, $2 - jp Func_9345.skip_count + jp HandleDeckBuildScreen.skip_count ; 0x95c1 -Func_95c1: ; 95c1 (2:55c1) +; returns carry if current deck was changed +; either through its card configuration or its name +CheckIfCurrentDeckWasChanged: ; 95c1 (2:55c1) ld a, [wTotalCardCount] or a jr z, .skip_size_check cp DECK_SIZE - jr nz, .done + jr nz, .set_carry .skip_size_check -; copy the selected deck to wc590 +; copy the selected deck to wCurDeckCardChanges call GetPointerToDeckCards - ld de, wc590 + ld de, wCurDeckCardChanges ld b, DECK_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM ; loops through cards in wCurDeckCards -; then if that card is found in wc590 +; then if that card is found in wCurDeckCardChanges ; overwrite it by $0 ld a, $ff ld [wc5cc], a @@ -3555,7 +3579,7 @@ Func_95c1: ; 95c1 (2:55c1) jr z, .check_empty ld b, a inc de - ld hl, wc590 + ld hl, wCurDeckCardChanges .loop_inner ld a, [hli] cp $ff @@ -3569,31 +3593,33 @@ Func_95c1: ; 95c1 (2:55c1) jr .loop_outer .check_empty - ld hl, wc590 + ld hl, wCurDeckCardChanges .loop_check_empty ld a, [hli] cp $ff jr z, .is_empty or a - jr nz, .done + jr nz, .set_carry jr .loop_check_empty -; wc590 is empty (all $0) .is_empty +; wCurDeckCardChanges is empty (all $0) +; check if name was changed call GetPointerToDeckName ld de, wCurDeckName call EnableSRAM -.asm_9610 +.loop_name ld a, [de] cp [hl] - jr nz, .done + jr nz, .set_carry inc de inc hl or a - jr nz, .asm_9610 + jr nz, .loop_name call DisableSRAM ret -.done + +.set_carry call DisableSRAM scf ret @@ -3663,7 +3689,7 @@ CheckIfThereAreAnyBasicCardsInDeck: ; 9649 (2:5649) ret ; 0x9667 -Data_9667: ; 9667 (2:5667) +FiltersCardSelectionParams: ; 9667 (2:5667) db 1 ; x pos db 1 ; y pos db 0 ; y spacing @@ -3671,17 +3697,17 @@ Data_9667: ; 9667 (2:5667) db NUM_FILTERS ; num entries db SYM_CURSOR_D ; visible cusor tile db SYM_SPACE ; invisible cusor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction -Data_9670: ; 9670 (2:5670) +FilteredCardListSelectionParams: ; 9670 (2:5670) db 0 ; x pos db 7 ; y pos db 2 ; y spacing db 0 ; x spacing - db 6 ; num entries + db MAX_FILTERED_LIST_VISIBLE_CARDS ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction DeckConfigurationMenu_TransitionTable: ; 9679 (2:5679) cursor_transition $10, $20, $00, $03, $03, $01, $02 @@ -3872,7 +3898,7 @@ CreateFilteredCardList: ; 978b (2:578b) .loop_card_ids inc e call GetCardType - jr c, .add_terminator_byte + jr c, .store_count ld c, a ld a, b cp $ff @@ -3917,9 +3943,9 @@ CreateFilteredCardList: ; 978b (2:578b) pop bc jr .loop_card_ids -.add_terminator_byte +.store_count ld a, l - ld [wceae], a + ld [wNumEntriesInCurFilter], a ; add terminator bytes in both lists xor a ld c, l @@ -4338,7 +4364,7 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0) ld b, 19 ; x coord ld c, e dec c - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .no_cursor ld a, SYM_CURSOR_U @@ -4350,7 +4376,7 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0) ; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ld b, $0 ld hl, wFilteredCardList @@ -4517,8 +4543,8 @@ AddCardIDToVisibleList: ; 9a59 (2:5a59) ; wCardListNumCursorPositions ; wVisibleCursorTile ; wInvisibleCursorTile -; wceac -Func_9a6d: ; 9a6d (2:5a6d) +; wCardListHandlerFunction +InitCardSelectionParams: ; 9a6d (2:5a6d) ld [wCardListCursorPos], a ld [hffb3], a ld de, wCardListCursorXPos @@ -4534,7 +4560,7 @@ Func_9a6d: ; 9a6d (2:5a6d) ret ; 0x9a83 -Func_9a83: ; 9a83 (2:5a83) +HandleCardSelectionInput: ; 9a83 (2:5a83) xor a ; FALSE ld [wPlaysSfx], a ldh a, [hDPadHeld] @@ -4578,7 +4604,7 @@ Func_9a83: ; 9a83 (2:5a83) ld [hffb3], a ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON - jr z, Func_9ae8 + jr z, HandleCardSelectionCursorBlink and A_BUTTON jr nz, ConfirmSelectionAndReturnCarry ; b button @@ -4601,7 +4627,7 @@ ConfirmSelectionAndReturnCarry: ; 9ad7 (2:5ad7) ret ; 0x9ae8 -Func_9ae8: ; 9ae8 (2:5ae8) +HandleCardSelectionCursorBlink: ; 9ae8 (2:5ae8) ld a, [wPlaysSfx] or a jr z, .skip_sfx @@ -4650,7 +4676,13 @@ DrawHorizontalListCursor_Visible: ; 9b20 (2:5b20) jr DrawHorizontalListCursor ; 0x9b25 -Func_9b25: ; 9b25 (2:5b25) +; handles user input when selecting cards to add +; to deck configuration +; returns carry if a selection was made +; (either selected card or cancelled) +; outputs in a the list index if selection was made +; or $ff if operation was cancelled +HandleDeckCardSelectionList: ; 9b25 (2:5b25) xor a ; FALSE ld [wPlaysSfx], a @@ -4671,11 +4703,11 @@ Func_9b25: ; 9b25 (2:5b25) dec a bit 7, a jr z, .asm_9b8f - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .asm_9b5a dec a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld hl, wcece call CallIndirect xor a @@ -4699,9 +4731,9 @@ Func_9b25: ; 9b25 (2:5b25) ld a, [wcecd] or a jr nz, .asm_9b87 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] inc a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld hl, wcece call CallIndirect pop af @@ -4732,28 +4764,32 @@ Func_9b25: ; 9b25 (2:5b25) bit D_LEFT_F, b jr z, .check_d_right call GetSelectedVisibleCardID - call Func_9de4 + call RemoveCardFromDeckAndUpdateCount jr .asm_9bb9 .check_d_right bit D_RIGHT_F, b jr z, .asm_9bb9 call GetSelectedVisibleCardID - call Func_9d0c + call AddCardToDeckAndUpdateCount .asm_9bb9 ld a, [wCardListCursorPos] ld [hffb3], a - ld hl, wceac + ld hl, wCardListHandlerFunction ld a, [hli] or [hl] - jr z, .asm_9be2 + jr z, .handle_ab_btns + + ; this code seemingly never runs + ; because wCardListHandlerFunction is always NULL ld a, [hld] ld l, [hl] ld h, a ld a, [hffb3] call CallHL jr nc, .handle_blink -.asm_9bd1 + +.select_card call DrawListCursor_Visible ld a, $01 call PlaySFXConfirmOrCancel @@ -4763,12 +4799,12 @@ Func_9b25: ; 9b25 (2:5b25) scf ret -.asm_9be2 +.handle_ab_btns ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON jr z, .check_sfx and A_BUTTON - jr nz, .asm_9bd1 + jr nz, .select_card ld a, $ff ld [hffb3], a call PlaySFXConfirmOrCancel @@ -4830,21 +4866,23 @@ DrawListCursor_Visible: ; 9c3a (2:5c3a) jr DrawListCursor ; 0x9c3f -Func_9c3f: ; 9c3f (2:5c3f) - ld hl, wcfd8 +OpenCardPageFromCardList: ; 9c3f (2:5c3f) +; get the card index that is selected +; and open its card page + ld hl, wCurCardListPtr ld a, [hli] ld h, [hl] ld l, a ld a, [wCardListCursorPos] ld c, a - ld b, $00 + ld b, $0 add hl, bc - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a - ld b, $00 + ld b, $0 add hl, bc ld e, [hl] - ld d, $00 + ld d, $0 push de call LoadCardDataToBuffer1_FromCardID lb de, $38, $9f @@ -4856,92 +4894,99 @@ Func_9c3f: ; 9c3f (2:5c3f) ldh a, [hDPadHeld] ld b, a and A_BUTTON | B_BUTTON | SELECT | START - jp nz, .asm_9ce1 + jp nz, .exit +; check d-pad +; if UP or DOWN is pressed, change the +; card that is being shown, given the +; order in the current card list xor a ; FALSE ld [wPlaysSfx], a ld a, [wCardListNumCursorPositions] ld c, a ld a, [wCardListCursorPos] bit D_UP_F, b - jr z, .asm_9c94 + jr z, .check_d_down push af ld a, TRUE ld [wPlaysSfx], a pop af dec a bit 7, a - jr z, .asm_9cc6 - ld a, [wcea1] + jr z, .reopen_card_page + ld a, [wCardListVisibleOffset] or a - jr z, .asm_9cd9 + jr z, .handle_regular_card_page_input dec a - ld [wcea1], a + ld [wCardListVisibleOffset], a xor a - jr .asm_9cc6 + jr .reopen_card_page -.asm_9c94 +.check_d_down bit D_DOWN_F, b - jr z, .asm_9cd9 + jr z, .handle_regular_card_page_input push af ld a, TRUE ld [wPlaysSfx], a pop af inc a cp c - jr c, .asm_9cc6 + jr c, .reopen_card_page push af - ld hl, wcfd8 + ld hl, wCurCardListPtr ld a, [hli] ld h, [hl] ld l, a ld a, [wCardListCursorPos] ld c, a - ld b, $00 + ld b, $0 add hl, bc - ld a, [wcea1] + ld a, [wCardListVisibleOffset] inc a ld c, a - ld b, $00 + ld b, $0 add hl, bc ld a, [hl] or a - jr z, .asm_9cd6 - ld a, [wcea1] + jr z, .skip_change_card + ld a, [wCardListVisibleOffset] inc a - ld [wcea1], a + ld [wCardListVisibleOffset], a pop af dec a -.asm_9cc6 +.reopen_card_page ld [wCardListCursorPos], a ld a, [wPlaysSfx] or a - jp z, Func_9c3f + jp z, OpenCardPageFromCardList call PlaySFX - jp Func_9c3f + jp OpenCardPageFromCardList -.asm_9cd6 +.skip_change_card pop af - jr .asm_9cd9 ; unnecessary jr -.asm_9cd9 + jr .handle_regular_card_page_input ; unnecessary jr +.handle_regular_card_page_input push de bank1call OpenCardPage.input_loop pop de jp .handle_input -.asm_9ce1 +.exit ld a, $1 ld [wVBlankOAMCopyToggle], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ret ; 0x9ced INCROM $9ced, $9d0c +; adds card in register e to deck configuration +; and updates the values shown for its count +; in the card selection list ; input: ; e = card ID -Func_9d0c: ; 9d0c (2:5d0c) +AddCardToDeckAndUpdateCount: ; 9d0c (2:5d0c) call TryAddCardToDeck ret c ; failed to add card push de @@ -4984,7 +5029,7 @@ TryAddCardToDeck: ; 9d22 (2:5d22) ld b, a ld hl, wOwnedCardsCountList ld d, $0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld e, a add hl, de ld a, [wCardListCursorPos] @@ -5121,7 +5166,12 @@ PrintNumberValueInCursorYPos: ; 9dbf (2:5dbf) ret ; 0x9de4 -Func_9de4: ; 9de4 (2:5de4) +; removes card in register e from deck configuration +; and updates the values shown for its count +; in the card selection list +; input: +; e = card ID +RemoveCardFromDeckAndUpdateCount: ; 9de4 (2:5de4) call RemoveCardFromDeck ret nc push de @@ -5193,7 +5243,7 @@ UpdateConfirmationCardScreen: ; 9e31 (2:5e31) jp PrintConfirmationCardList ; 0x9e41 -Func_9e41: ; 9e41 (2:5e41) +HandleDeckConfirmationMenu: ; 9e41 (2:5e41) ; if deck is empty, just show deck info header with empty card list ld a, [wTotalCardCount] or a @@ -5204,12 +5254,12 @@ Func_9e41: ; 9e41 (2:5e41) call CreateCurDeckUniqueCardList xor a - ld [wcea1], a -.asm_9e52 - ld hl, Data_9eaf - call Func_9a6d + ld [wCardListVisibleOffset], a +.init_params + ld hl, .CardSelectionParams + call InitCardSelectionParams ld a, [wNumUniqueCards] - ld [wcfe6], a + ld [wNumCardListEntries], a cp MAX_DECK_CONFIRMATION_VISIBLE_CARDS jr c, .no_cap ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS @@ -5227,37 +5277,39 @@ Func_9e41: ; 9e41 (2:5e41) xor a ld [wced2], a -.asm_9e7b +.loop_input call DoFrame - call Func_9b25 - jr c, .asm_9ea7 - call Func_9eb8 - jr c, .asm_9e7b + call HandleDeckCardSelectionList + jr c, .selection_made + call HandleLeftRightInCardList + jr c, .loop_input ldh a, [hDPadHeld] and START - jr z, .asm_9e7b + jr z, .loop_input -.asm_9e8e +.selected_card ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListCursorPos] ld [wced7], a + + ; set wOwnedCardsCountList as current card list + ; and show card page screen ld de, wOwnedCardsCountList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f - jr .asm_9e52 + call OpenCardPageFromCardList + jr .init_params -.asm_9ea7 +.selection_made ld a, [hffb3] cp $ff - ret z - jr .asm_9e8e -; 0x9eaf + ret z ; operation cancelled + jr .selected_card -Data_9eaf: +.CardSelectionParams db 0 ; x pos db 5 ; y pos db 2 ; y spacing @@ -5265,12 +5317,17 @@ Data_9eaf: db 7 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac - -Func_9eb8: ; 9eb8 (2:5eb8) + dw NULL ; wCardListHandlerFunction +; 0x9eb8 + +; handles pressing left/right in card lists +; scrolls up/down a number of wCardListNumCursorPositions +; entries respectively +; returns carry if scrolling happened +HandleLeftRightInCardList: ; 9eb8 (2:5eb8) ld a, [wCardListNumCursorPositions] ld d, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ldh a, [hDPadHeld] cp D_RIGHT @@ -5281,27 +5338,27 @@ Func_9eb8: ; 9eb8 (2:5eb8) ret .right - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add d ld b, a add d - ld hl, wcfe6 + ld hl, wNumCardListEntries cp [hl] - jr c, .asm_9ee8 - ld a, [wcfe6] + jr c, .got_new_pos + ld a, [wNumCardListEntries] sub d ld b, a - jr .asm_9ee8 + jr .got_new_pos .left - ld a, [wcea1] + ld a, [wCardListVisibleOffset] sub d ld b, a - jr nc, .asm_9ee8 - ld b, $00 -.asm_9ee8 + jr nc, .got_new_pos + ld b, 0 ; first index +.got_new_pos ld a, b - ld [wcea1], a + ld [wCardListVisibleOffset], a cp c jr z, .asm_9efa ld a, SFX_01 @@ -5313,10 +5370,14 @@ Func_9eb8: ; 9eb8 (2:5eb8) ret ; 0x9efc -Func_9efc: ; 9efc (2:5efc) +; handles scrolling up and down with Select button +; in this case, the cursor position goes up/down +; by wCardListNumCursorPositions entries respectively +; return carry if scrolling happened, otherwise no carry +HandleSelectUpAndDownInList: ; 9efc (2:5efc) ld a, [wCardListNumCursorPositions] ld d, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ldh a, [hDPadHeld] cp SELECT | D_DOWN @@ -5327,26 +5388,27 @@ Func_9efc: ; 9efc (2:5efc) ret .sel_down - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add d - ld b, a + ld b, a ; wCardListVisibleOffset + wCardListNumCursorPositions add d - ld hl, wcfe6 + ld hl, wNumCardListEntries cp [hl] - jr c, .asm_9f2c - ld a, [wcfe6] + jr c, .got_new_pos + ld a, [wNumCardListEntries] sub d - ld b, a - jr .asm_9f2c + ld b, a ; wNumCardListEntries - wCardListNumCursorPositions + jr .got_new_pos .sel_up - ld a, [wcea1] + ld a, [wCardListVisibleOffset] sub d - ld b, a - jr nc, .asm_9f2c - ld b, $00 -.asm_9f2c + ld b, a ; wCardListVisibleOffset - wCardListNumCursorPositions + jr nc, .got_new_pos + ld b, 0 ; go to first position + +.got_new_pos ld a, b - ld [wcea1], a + ld [wCardListVisibleOffset], a cp c jr z, .set_carry ld a, SFX_01 @@ -5605,7 +5667,7 @@ PrintConfirmationCardList: ; a08a (2:608a) ld b, 19 ; x coord ld c, e dec c - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .no_cursor ld a, SYM_CURSOR_U @@ -5617,7 +5679,7 @@ PrintConfirmationCardList: ; a08a (2:608a) ; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ld b, $0 ld hl, wOwnedCardsCountList @@ -5814,7 +5876,8 @@ GetCardTypeIconPalette: ; a173 (2:6173) db $00, $ff ; 0xa1a2 -Func_a1a2: ; a1a2 (2:61a2) +; inits WRAM vars to start creating deck configuration to send +PrepareToBuildDeckConfigurationToSend: ; a1a2 (2:61a2) ld hl, wCurDeckCards ld a, wCurDeckCardsEnd - wCurDeckCards call ClearNBytesFromHL @@ -5825,7 +5888,7 @@ Func_a1a2: ; a1a2 (2:61a2) call CopyListFromHLToDE ld hl, .DeckConfigurationParams call InitDeckBuildingParams - call Func_9345 + call HandleDeckBuildScreen ret .text @@ -5869,11 +5932,11 @@ HandleSendDeckConfigurationMenu: ; a201 (2:6201) cp $ff jr nz, .asm_a23b call DrawCardTypeIconsAndPrintCardCounts - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a ld a, [wCurCardTypeFilter] call PrintFilteredCardList - jp Func_9345.skip_draw + jp HandleDeckBuildScreen.skip_draw .asm_a23b ld hl, .func_table call JumpToFunctionInTable @@ -5890,9 +5953,9 @@ SendDeckConfiguration: ; a24a (2:624a) or a jr z, CancelSendDeckConfiguration xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld hl, Data_b04a - call Func_9a6d + call InitCardSelectionParams ld hl, wCurDeckCards ld de, wDuelTempList call CopyListFromHLToDE @@ -5903,7 +5966,7 @@ SendDeckConfiguration: ; a24a (2:624a) call YesOrNoMenuWithText jr nc, .asm_a279 add sp, $2 - jp Func_9345.skip_count + jp HandleDeckBuildScreen.skip_count .asm_a279 add sp, $2 scf @@ -5925,26 +5988,27 @@ CopyNBytesFromHLToDE: ; a281 (2:6281) ret ; 0xa288 -Func_a288: ; a288 (2:6288) - call Func_8ce7 - call Func_a4c6 +; handles the screen showing all the player's cards +HandlePlayersCardsScreen: ; a288 (2:6288) + call WriteCardListsTerminatorBytes + call PrintPlayersCardsHeaderInfo xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld [wCurCardTypeFilter], a call PrintFilteredCardSelectionList call EnableLCD xor a - ld hl, Data_9667 - call Func_9a6d -.asm_a2a2 + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams +.wait_input call DoFrame ld a, [wCurCardTypeFilter] ld b, a ld a, [wTempCardTypeFilter] cp b - jr z, .asm_a2cc + jr z, .check_d_down ld [wCurCardTypeFilter], a - ld hl, wcea1 + ld hl, wCardListVisibleOffset ld [hl], $00 call PrintFilteredCardSelectionList @@ -5956,31 +6020,31 @@ Func_a288: ; a288 (2:6288) ld a, NUM_FILTERS ld [wCardListNumCursorPositions], a -.asm_a2cc +.check_d_down ldh a, [hDPadHeld] and D_DOWN - jr z, .asm_a2d7 + jr z, .no_d_down call ConfirmSelectionAndReturnCarry - jr .asm_a2e4 + jr .jump_to_list -.asm_a2d7 - call Func_9a83 - jr nc, .asm_a2a2 +.no_d_down + call HandleCardSelectionInput + jr nc, .wait_input ld a, [hffb3] - cp $ff - jr nz, .asm_a2e4 + cp $ff ; operation cancelled + jr nz, .jump_to_list ret -.asm_a2e4 - ld a, [wceae] +.jump_to_list + ld a, [wNumEntriesInCurFilter] or a - jr z, .asm_a2a2 + jr z, .wait_input xor a ld hl, Data_a396 - call Func_9a6d - ld a, [wceae] - ld [wcfe6], a + call InitCardSelectionParams + ld a, [wNumEntriesInCurFilter] + ld [wNumCardListEntries], a ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_a300 @@ -5997,53 +6061,57 @@ Func_a288: ; a288 (2:6288) .loop_input call DoFrame - call Func_9efc + call HandleSelectUpAndDownInList jr c, .loop_input - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_a36a ldh a, [hDPadHeld] and START jr z, .loop_input ; start btn pressed -.asm_a321 +.open_card_page ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListNumCursorPositions] - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a + + ; set wHandTempList as current card list + ; and show card page screen ld de, wHandTempList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f - call Func_a4c6 - ld hl, Data_9667 - call Func_9a6d + call OpenCardPageFromCardList + call PrintPlayersCardsHeaderInfo + + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible call PrintCardSelectionList call EnableLCD ld hl, Data_a396 - call Func_9a6d - ld a, [wcfdf] + call InitCardSelectionParams + ld a, [wTempCardListNumCursorPositions] ld [wCardListNumCursorPositions], a - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a jr .loop_input .asm_a36a call DrawListCursor_Invisible ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff - jr nz, .asm_a321 - ld hl, Data_9667 - call Func_9a6d + jr nz, .open_card_page + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a ld hl, hffb0 @@ -6051,7 +6119,7 @@ Func_a288: ; a288 (2:6288) call PrintPlayersCardsText ld hl, hffb0 ld [hl], $00 - jp .asm_a2a2 + jp .wait_input ; 0xa396 Data_a396: ; a396 (2:6396) @@ -6062,7 +6130,7 @@ Data_a396: ; a396 (2:6396) db 7 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction ; 0xa39f ; a = which card type filter @@ -6171,7 +6239,7 @@ PrintCardSelectionList: ; a42d (2:642d) ld d, [hl] ld b, 19 ; x coord ld c, e - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .alternate_cursor_tile ld a, SYM_CURSOR_U @@ -6183,7 +6251,7 @@ PrintCardSelectionList: ; a42d (2:642d) ; iterates by decreasing value in wNumVisibleCardListEntries ; by 1 until it reaches 0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ld b, $0 ld hl, wFilteredCardList @@ -6286,7 +6354,7 @@ AppendOwnedCardCountNumber: ; a4ae (2:64ae) ; 0xa4c6 ; print header info (card count and player name) -Func_a4c6: ; a4c6 (2:64c6) +PrintPlayersCardsHeaderInfo: ; a4c6 (2:64c6) call Set_OBJ_8x8 call Func_8d78 .skip_empty_screen @@ -6563,7 +6631,7 @@ Func_a596: ; a596 (2:6596) .found_not_owned inc c ld a, c - ld [wceae], a + ld [wNumEntriesInCurFilter], a xor a ld hl, wHandTempList add hl, bc @@ -6694,7 +6762,7 @@ Func_a6fa: ; a6fa (2:66fa) ld c, e dec c dec c - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .asm_a710 ld a, SYM_CURSOR_U @@ -6703,7 +6771,7 @@ Func_a6fa: ; a6fa (2:66fa) ld a, SYM_BOX_TOP_R .asm_a712 call WriteByteToBGMap0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld l, a ld h, $00 ld a, [wNumVisibleCardListEntries] @@ -6806,7 +6874,7 @@ Func_a7a7: ; a7a7 (2:67a7) ld a, [wNumVisibleCardListEntries] sub b - ld hl, wcea1 + ld hl, wCardListVisibleOffset add [hl] inc a call CalculateOnesAndTensDigits @@ -6885,7 +6953,7 @@ Func_a7a7: ; a7a7 (2:67a7) Func_a828: ; a828 (2:6828) ld a, [wCardListCursorPos] ld b, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add b ld c, a ld b, $00 @@ -6895,7 +6963,7 @@ Func_a828: ; a828 (2:6828) cp CARD_NOT_OWNED jr z, .handle_input - ld hl, wcfd8 + ld hl, wCurCardListPtr ld a, [hli] ld h, [hl] ld l, a @@ -6926,7 +6994,7 @@ Func_a828: ; a828 (2:6828) ld a, TRUE ld [wPlaysSfx], a ld a, [wCardListCursorPos] - ld hl, wcea1 + ld hl, wCardListVisibleOffset add [hl] ld hl, wFirstOwnedCardIndex cp [hl] @@ -6936,11 +7004,11 @@ Func_a828: ; a828 (2:6828) dec a bit 7, a jr z, .asm_a8c3 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .open_card_page dec a - ld [wcea1], a + ld [wCardListVisibleOffset], a xor a jr .asm_a8c3 @@ -6957,7 +7025,7 @@ Func_a828: ; a828 (2:6828) cp c jr c, .asm_a8c3 push af - ld hl, wcfd8 + ld hl, wCurCardListPtr ld a, [hli] ld h, [hl] ld l, a @@ -6965,7 +7033,7 @@ Func_a828: ; a828 (2:6828) ld c, a ld b, $00 add hl, bc - ld a, [wcea1] + ld a, [wCardListVisibleOffset] inc a ld c, a ld b, $00 @@ -6973,9 +7041,9 @@ Func_a828: ; a828 (2:6828) ld a, [hl] or a jr z, .asm_a8d3 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] inc a - ld [wcea1], a + ld [wCardListVisibleOffset], a pop af dec a .asm_a8c3 @@ -7014,7 +7082,7 @@ Func_a828: ; a828 (2:6828) ld a, $01 ld [wVBlankOAMCopyToggle], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ret ; 0xa901 @@ -7062,10 +7130,10 @@ Func_a913: ; a913 (2:6913) call Func_a6a0 call .Func_aa24 xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_a6fa call EnableLCD - ld a, [wceae] + ld a, [wNumEntriesInCurFilter] or a jr nz, .asm_a968 @@ -7083,8 +7151,8 @@ Func_a913: ; a913 (2:6913) call .Func_aa13 xor a ld hl, .data_aa0a - call Func_9a6d - ld a, [wceae] + call InitCardSelectionParams + ld a, [wNumEntriesInCurFilter] ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_a97e @@ -7101,9 +7169,9 @@ Func_a913: ; a913 (2:6913) ld [wced2], a .loop_input_3 call DoFrame - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_a9ed - call Func_9eb8 + call HandleLeftRightInCardList jr c, .loop_input_3 ldh a, [hDPadHeld] and START @@ -7112,11 +7180,11 @@ Func_a913: ; a913 (2:6913) ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListNumCursorPositions] - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld c, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add c ld hl, wOwnedCardsCountList ld c, a @@ -7125,28 +7193,31 @@ Func_a913: ; a913 (2:6913) ld a, [hl] cp CARD_NOT_OWNED jr z, .loop_input_3 + + ; set wHandTempList as current card list ld de, wHandTempList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d + call GetFirstOwnedCardIndex call Func_a828 call .Func_aa24 call Func_a6fa call EnableLCD ld hl, .data_aa0a - call Func_9a6d - ld a, [wcfdf] + call InitCardSelectionParams + ld a, [wTempCardListNumCursorPositions] ld [wCardListNumCursorPositions], a - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a jr .loop_input_3 .asm_a9ed call DrawListCursor_Invisible ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff jr nz, .asm_a99f @@ -7169,7 +7240,7 @@ Func_a913: ; a913 (2:6913) db 7 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction .Func_aa13 ld hl, wHandTempList @@ -7182,7 +7253,7 @@ Func_a913: ; a913 (2:6913) jr .asm_aa18 .asm_aa1f ld a, b - ld [wcfe6], a + ld [wNumCardListEntries], a ret .Func_aa24 @@ -7352,16 +7423,16 @@ Func_a913: ; a913 (2:6913) ; 0xab7b PrinterMenu_PokemonCards: ; ab7b (2:6b7b) - call Func_8ce7 - call Func_a4c6 + call WriteCardListsTerminatorBytes + call PrintPlayersCardsHeaderInfo xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld [wCurCardTypeFilter], a call PrintFilteredCardSelectionList call EnableLCD xor a - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams .loop_frame_1 call DoFrame @@ -7371,7 +7442,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) cp b jr z, .handle_input ld [wCurCardTypeFilter], a - ld hl, wcea1 + ld hl, wCardListVisibleOffset ld [hl], $00 call PrintFilteredCardSelectionList ld hl, hffb0 @@ -7389,7 +7460,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) call ConfirmSelectionAndReturnCarry jr .asm_abd7 .asm_abca - call Func_9a83 + call HandleCardSelectionInput jr nc, .loop_frame_1 ld a, [hffb3] cp $ff @@ -7397,20 +7468,20 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ret .asm_abd7 - ld a, [wceae] + ld a, [wNumEntriesInCurFilter] or a jr z, .loop_frame_1 xor a ld hl, Data_a396 - call Func_9a6d - ld a, [wceae] - ld [wcfe6], a + call InitCardSelectionParams + ld a, [wNumEntriesInCurFilter] + ld [wNumCardListEntries], a ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_abf6 ld [wCardListNumCursorPositions], a - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a .asm_abf6 ld hl, PrintCardSelectionList ld d, h @@ -7423,9 +7494,9 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) .loop_frame_2 call DoFrame - call Func_9efc + call HandleSelectUpAndDownInList jr c, .loop_frame_2 - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_ac60 ldh a, [hDPadHeld] and START @@ -7434,45 +7505,48 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListNumCursorPositions] - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a + + ; set wHandTempList as current card list + ; and show card page screen ld de, wHandTempList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f - call Func_a4c6 + call OpenCardPageFromCardList + call PrintPlayersCardsHeaderInfo .asm_ac37 - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a call DrawHorizontalListCursor_Visible call PrintCardSelectionList call EnableLCD ld hl, Data_a396 - call Func_9a6d - ld a, [wcfdf] + call InitCardSelectionParams + ld a, [wTempCardListNumCursorPositions] ld [wCardListNumCursorPositions], a - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a jr .loop_frame_2 .asm_ac60 call DrawListCursor_Invisible ld a, [wCardListNumCursorPositions] - ld [wcfdf], a + ld [wTempCardListNumCursorPositions], a ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff jr nz, .asm_ac92 - ld hl, Data_9667 - call Func_9a6d + ld hl, FiltersCardSelectionParams + call InitCardSelectionParams ld a, [wCurCardTypeFilter] ld [wTempCardTypeFilter], a ld hl, hffb0 @@ -7491,31 +7565,31 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) call ProcessTextFromID ld a, $01 ld hl, Data_ad05 - call Func_9a6d + call InitCardSelectionParams .loop_frame call DoFrame - call Func_9a83 + call HandleCardSelectionInput jr nc, .loop_frame ld a, [hffb3] or a jr nz, .asm_acd5 ld hl, wHandTempList - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld c, a ld b, $00 add hl, bc - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ld b, $00 add hl, bc ld a, [hl] bank1call Func_758a - call Func_a4c6 + call PrintPlayersCardsHeaderInfo jp .asm_ac37 .asm_acd5 call .Func_acde - call Func_a4c6.skip_empty_screen + call PrintPlayersCardsHeaderInfo.skip_empty_screen jp .asm_ac37 .Func_acde @@ -7546,11 +7620,11 @@ Data_ad05: ; ad05 (2:6d05) db 2 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction ; 0xad0e PrinterMenu_CardList: ; ad0e (2:6d0e) - call Func_8ce7 + call WriteCardListsTerminatorBytes call Set_OBJ_8x8 call Func_8d78 lb bc, 0, 4 @@ -7558,7 +7632,7 @@ PrinterMenu_CardList: ; ad0e (2:6d0e) call FillBGMapLineWithA xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld [wCurCardTypeFilter], a call PrintFilteredCardSelectionList call EnableLCD @@ -7568,10 +7642,10 @@ PrinterMenu_CardList: ; ad0e (2:6d0e) call ProcessTextFromID ld a, $01 ld hl, Data_ad05 - call Func_9a6d + call InitCardSelectionParams .loop_frame call DoFrame - call Func_9a83 + call HandleCardSelectionInput jr nc, .loop_frame ld a, [hffb3] or a @@ -7643,10 +7717,10 @@ PrinterMenu_PrintQuality: ; adb5 (2:6db5) ld a, [sPrinterContrastLevel] call DisableSRAM ld hl, Data_adf5 - call Func_9a6d + call InitCardSelectionParams .loop_frame call DoFrame - call Func_9a83 + call HandleCardSelectionInput jr nc, .loop_frame ld a, [hffb3] cp $ff @@ -7672,7 +7746,7 @@ Data_adf5: ; adf5 (2:6df5) db 5 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction ; 0xadfe ; hl = ? @@ -7698,12 +7772,12 @@ Func_adfe: ; adfe (2:6dfe) call SortCurDeckCardsByID call CreateCurDeckUniqueCardList xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a .loop ld hl, .Data_ae91 - call Func_9a6d + call InitCardSelectionParams ld a, [wNumUniqueCards] - ld [wcfe6], a + ld [wNumCardListEntries], a cp $05 jr c, .asm_ae3d ld a, $05 @@ -7728,9 +7802,9 @@ Func_adfe: ; adfe (2:6dfe) .loop_input call DoFrame - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_ae89 - call Func_9eb8 + call HandleLeftRightInCardList jr c, .loop_input ldh a, [hDPadHeld] and START @@ -7740,12 +7814,15 @@ Func_adfe: ; adfe (2:6dfe) call PlaySFXConfirmOrCancel ld a, [wCardListCursorPos] ld [wced7], a + + ; set wOwnedCardsCountList as current card list + ; and show card page screen ld de, wOwnedCardsCountList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f + call OpenCardPageFromCardList jr .loop .asm_ae89 @@ -7762,7 +7839,7 @@ Func_adfe: ; adfe (2:6dfe) db 5 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction .Func_ae9a ld hl, hffb0 @@ -7858,7 +7935,7 @@ Func_af1d: ; af1d (2:6f1d) call DrawWideTextBox_WaitForInput call EnableLCD - call Func_a1a2 + call PrepareToBuildDeckConfigurationToSend jr c, .asm_af6b ld a, $01 or a @@ -7901,14 +7978,14 @@ Func_af98: ; af98 (2:6f98) call DisableSRAM call SaveGame xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ld hl, Data_b04a - call Func_9a6d + call InitCardSelectionParams call PrintReceivedTheseCardsText call Func_b088 call EnableLCD - ld a, [wceae] - ld [wcfe6], a + ld a, [wNumEntriesInCurFilter] + ld [wNumCardListEntries], a ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_afd4 @@ -7925,9 +8002,9 @@ Func_af98: ; af98 (2:6f98) ld [wced2], a .asm_afe2 call DoFrame - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_b02f - call Func_9eb8 + call HandleLeftRightInCardList jr c, .asm_afe2 ldh a, [hDPadHeld] and START @@ -7936,31 +8013,35 @@ Func_af98: ; af98 (2:6f98) ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a + + ; set wFilteredCardList as current card list + ; and show card page screen ld de, wFilteredCardList - ld hl, wcfd8 + ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d - call Func_9c3f + call OpenCardPageFromCardList call PrintReceivedTheseCardsText + call PrintCardSelectionList call EnableLCD ld hl, Data_b04a - call Func_9a6d - ld a, [wceae] + call InitCardSelectionParams + ld a, [wNumEntriesInCurFilter] ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .asm_b027 ld [wCardListNumCursorPositions], a .asm_b027 - ld a, [wced4] + ld a, [wTempCardListCursorPos] ld [wCardListCursorPos], a jr .asm_afe2 .asm_b02f call DrawListCursor_Invisible ld a, [wCardListCursorPos] - ld [wced4], a + ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff jr nz, .asm_aff5 @@ -7978,7 +8059,7 @@ Data_b04a: ; b04a (2:704a) db 5 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction ShowReceivedCardsList: ; b053 (2:7053) ld hl, hffb0 @@ -8096,7 +8177,7 @@ Func_b088: ; b088 (2:7088) .asm_b119 ld a, l - ld [wceae], a + ld [wNumEntriesInCurFilter], a xor a ld c, l ld b, h @@ -8175,7 +8256,7 @@ Func_b177: ; b177 (2:7177) Func_b19d: ; b19d (2:719d) xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText ld hl, wd0a2 ld [hl], e @@ -8187,7 +8268,7 @@ Func_b19d: ; b19d (2:719d) xor a .asm_b1b3 ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call Func_b704 call PrintNumSavedDecks ldtx hl, PleaseSelectDeckText @@ -8199,7 +8280,7 @@ Func_b19d: ; b19d (2:719d) cp $ff ret z ld b, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add b ld [wd088], a call ResetCheckMenuCursorPositionAndBlink @@ -8266,7 +8347,7 @@ Func_b19d: ; b19d (2:719d) .asm_b25e ld a, [wd087] - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_b379 call Func_b704 call PrintNumSavedDecks @@ -8303,7 +8384,7 @@ Func_b285: ; b285 (2:7285) Func_b29f: ; b29f (2:729f) call DoFrame - call Func_9b25 + call HandleDeckCardSelectionList jr c, .asm_b303 call .Func_b317 jr c, Func_b29f ; loop back to start @@ -8312,7 +8393,7 @@ Func_b29f: ; b29f (2:729f) jr z, Func_b29f ; loop back to start ; start btn - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld [wd087], a ld b, a ld a, [wCardListCursorPos] @@ -8343,9 +8424,9 @@ Func_b29f: ; b29f (2:729f) ld a, $01 call PlaySFXConfirmOrCancel - call HandleDeckConfirmationMenu + call OpenDeckConfirmationMenu ld a, [wd087] - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_b379 call Func_b704 call PrintNumSavedDecks @@ -8356,7 +8437,7 @@ Func_b29f: ; b29f (2:729f) .asm_b303 call DrawListCursor_Visible - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld [wd087], a ld a, [wCardListCursorPos] ld [wd086], a @@ -8365,7 +8446,7 @@ Func_b29f: ; b29f (2:729f) ret .Func_b317 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld c, a ldh a, [hDPadHeld] cp D_RIGHT @@ -8376,7 +8457,7 @@ Func_b29f: ; b29f (2:729f) ret .d_right - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add $05 ld b, a add $05 @@ -8389,7 +8470,7 @@ Func_b29f: ; b29f (2:729f) jr .asm_b347 .d_left - ld a, [wcea1] + ld a, [wCardListVisibleOffset] sub $05 ld b, a jr nc, .asm_b347 @@ -8397,7 +8478,7 @@ Func_b29f: ; b29f (2:729f) .asm_b347 ld a, b - ld [wcea1], a + ld [wCardListVisibleOffset], a cp c jr z, .asm_b359 ld a, SFX_01 @@ -8491,7 +8572,7 @@ GetSavedDeckPointers: ; b3c3 (2:73c3) ; 0xb3e5 Func_b3e5: ; b3e5 (2:73e5) - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld de, $202 ld b, $05 .asm_b3ed @@ -8781,7 +8862,7 @@ Func_b592: ; b592 (2:7592) call PrintNumSavedDecks ld a, [wd086] ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call DrawListCursor_Visible call GetPointerToDeckName call EnableSRAM @@ -9012,10 +9093,10 @@ Data_b6fb: ; b6fb (2:76fb) db 5 ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile - dw NULL ; wceac + dw NULL ; wCardListHandlerFunction Func_b704: ; b704 (2:7704) - ld a, [wcea1] + ld a, [wCardListVisibleOffset] or a jr z, .asm_b70e ld a, SYM_CURSOR_U @@ -9026,7 +9107,7 @@ Func_b704: ; b704 (2:7704) lb bc, 19, 1 call WriteByteToBGMap0 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add $06 ld b, a ld a, [wd0a5] @@ -9375,7 +9456,7 @@ Func_b960: ; b960 (2:7960) PrinterMenu_DeckConfiguration: ; b991 (2:7991) xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_b379 ld a, DECK_SIZE ld [wd0a5], a @@ -9383,7 +9464,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) xor a .asm_b99e ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call Func_b704 call PrintNumSavedDecks ld hl, WaitForVBlank.lcd_off @@ -9397,7 +9478,7 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) ret z ld b, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add b ld [wd088], a call Func_b35b @@ -9441,7 +9522,7 @@ Func_ba04: ; ba04 (2:7a04) ld a, [hl] ld [de], a xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_bb97 ld a, $5 ld [wd0a5], a @@ -9473,7 +9554,7 @@ Func_ba25: ; ba25 (2:7a25) ldh a, [hDPadHeld] and START jr z, .asm_ba40 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld [wd087], a ld b, a ld a, [wCurMenuItem] @@ -9504,17 +9585,17 @@ Func_ba25: ; ba25 (2:7a25) ld a, $1 call PlaySFXConfirmOrCancel call SafelySwitchToSRAM1 - call HandleDeckConfirmationMenu + call OpenDeckConfirmationMenu call SafelySwitchToSRAM0 ld a, [wd087] - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_bb97 ld a, [wd086] jp Func_ba25 .asm_baa3 call DrawCursor2 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld [wd087], a ld a, [wCurMenuItem] ld [wd086], a @@ -9550,7 +9631,7 @@ Func_ba25: ; ba25 (2:7a25) ld a, [wd086] jp nc, Func_ba25 ld a, [wd087] - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_bb97 ld a, [wd086] jp Func_ba25 @@ -9564,7 +9645,7 @@ Func_ba25: ; ba25 (2:7a25) ret .asm_bb12 - ld a, [wcea1] + ld a, [wCardListVisibleOffset] ld [wd087], a ld b, a ld a, [wCurMenuItem] @@ -9607,7 +9688,7 @@ Func_ba25: ; ba25 (2:7a25) call Func_adfe call SafelySwitchToSRAM0 ld a, [wd087] - ld [wcea1], a + ld [wCardListVisibleOffset], a call Func_bb97 ld a, [wd086] jp Func_ba25 @@ -9696,7 +9777,7 @@ Func_bbe4: ; bbe4 (2:7be4) Func_bc04: ; bc04 (2:7c04) xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText ld hl, wd0a2 ld [hl], e @@ -9708,7 +9789,7 @@ Func_bc04: ; bc04 (2:7c04) xor a .asm_bc1a ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call Func_b704 call PrintNumSavedDecks ldtx hl, PleaseChooseADeckConfigurationToSendText @@ -9725,7 +9806,7 @@ Func_bc04: ; bc04 (2:7c04) ret .asm_bc3f ld b, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add b ld [wd088], a call Func_b35b @@ -9758,7 +9839,7 @@ Func_bc04: ; bc04 (2:7c04) Func_bc7a: ; bc7a (2:7c7a) xor a - ld [wcea1], a + ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText ld hl, wd0a2 ld [hl], e @@ -9770,7 +9851,7 @@ Func_bc7a: ; bc7a (2:7c7a) xor a .asm_bc90 ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call Func_b704 call PrintNumSavedDecks ldtx hl, PleaseChooseASaveSlotText @@ -9786,7 +9867,7 @@ Func_bc7a: ; bc7a (2:7c7a) ret .asm_bcb5 ld b, a - ld a, [wcea1] + ld a, [wCardListVisibleOffset] add b ld [wd088], a call Func_b35b @@ -9814,7 +9895,7 @@ Func_bc7a: ; bc7a (2:7c7a) call Func_b379 ld a, [wCardListCursorPos] ld hl, Data_b6fb - call Func_9a6d + call InitCardSelectionParams call Func_b704 call PrintNumSavedDecks call DrawListCursor_Visible diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index dfffa88..85e4e08 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1183,7 +1183,7 @@ Func_c7cc: ; c7cc (3:47cc) ldh [hSCY], a call Set_OBJ_8x16 farcall Func_1288c - farcall Func_a288 + farcall HandlePlayersCardsScreen call Set_OBJ_8x8 ret diff --git a/src/wram.asm b/src/wram.asm index bb7de79..d693c26 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -452,7 +452,10 @@ wDefaultText:: ; c590 NEXTU -wc590:: ; c590 +; used in CheckIfCurrentDeckWasChanged to determine whether +; wCurDeckCards was changed from the original +; deck it was based on +wCurDeckCardChanges:: ; c590 ds DECK_SIZE ENDU @@ -1892,7 +1895,10 @@ wce9f:: ; ce9f wCardPopCardObtainSong:: ; cea0 ds $1 -wcea1:: ; cea1 +; first index in the current card list that is visible +; used to calculate which element to get based +; on the cursor position +wCardListVisibleOffset:: ; cea1 ds $1 ds $1 @@ -1937,10 +1943,14 @@ wVisibleCursorTile:: ; ceaa wInvisibleCursorTile:: ; ceab ds $1 -wceac:: ; ceac +; unknown handler function run in HandleDeckCardSelectionList +; is always NULL +wCardListHandlerFunction:: ; ceac ds $2 -wceae:: ; ceae +; number of cards that are listed +; in the current filtered list +wNumEntriesInCurFilter:: ; ceae ds $1 wCheckMenuCursorXPosition:: ; ceaf @@ -2010,15 +2020,17 @@ wced2:: ; ced2 wCurCardTypeFilter:: ; ced3 ds $1 -wced4:: ; ced4 +; temporarily stores wCardListNumCursorPositions value +wTempCardListCursorPos:: ; ced4 ds $1 -wced5:: ; ced5 +wTempFilteredCardListNumCursorPositions:: ; ced5 ds $1 wced6:: ; ced6 ds $1 +; maybe unused, is written to but never read wced7:: ; ced7 ds $1 @@ -2094,8 +2106,9 @@ wDeckConfigurationMenuHandlerFunction:: ; cfd4 wDeckConfigurationMenuTransitionTable:: ; cfd6 ds $2 -; pointer to a list of cards -wcfd8:: ; cfd8 +; pointer to a list of cards that +; is currently being shown/manipulated +wCurCardListPtr:: ; cfd8 ds $2 wcfda:: ; cfda @@ -2108,7 +2121,8 @@ wcfda:: ; cfda wCursorAlternateTile:: ; cfde ds $1 -wcfdf:: ; cfdf +; temporarily stores value of wCardListNumCursorPositions +wTempCardListNumCursorPositions:: ; cfdf ds $1 wcfe0:: ; cfe0 @@ -2131,7 +2145,7 @@ wcfe4:: ; cfe4 wFirstOwnedCardIndex:: ; cfe5 ds $1 -wcfe6:: ; cfe6 +wNumCardListEntries:: ; cfe6 ds $1 ; a name buffer in the naming screen. -- cgit v1.2.3 From 1311cb0cba781b2d362fe4c749ee0ed14bb2d544 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 8 May 2021 20:09:54 +0100 Subject: Document Card Album functions --- src/constants/card_data_constants.asm | 1 + src/constants/menu_constants.asm | 13 + src/engine/bank02.asm | 482 ++++++++++++++++++---------------- src/engine/bank03.asm | 2 +- src/sram.asm | 5 +- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 26 +- 8 files changed, 301 insertions(+), 232 deletions(-) (limited to 'src') diff --git a/src/constants/card_data_constants.asm b/src/constants/card_data_constants.asm index 50fdb52..2fc0bfc 100644 --- a/src/constants/card_data_constants.asm +++ b/src/constants/card_data_constants.asm @@ -141,6 +141,7 @@ PROMOSTAR EQU $ff const CARD_SET_LABORATORY ; $3 const CARD_SET_PROMOTIONAL ; $4 const CARD_SET_ENERGY ; $5 +NUM_CARD_SETS EQU const_value - 1 ; CARD_DATA_SET constants (set 1) COLOSSEUM EQU CARD_SET_COLOSSEUM << 4 diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm index 75dd568..ab60293 100644 --- a/src/constants/menu_constants.asm +++ b/src/constants/menu_constants.asm @@ -14,6 +14,7 @@ FILTER_ENERGY EQU $20 NUM_FILTERS EQU 9 MAX_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7 +MAX_CARD_ALBUM_VISIBLE_CARDS EQU 7 MAX_FILTERED_LIST_VISIBLE_CARDS EQU 6 ; deck flags @@ -27,3 +28,15 @@ ALL_DECKS EQU $ff NUM_DECK_SAVE_MACHINE_SLOTS EQU 60 NUM_DECK_MACHINE_SLOTS EQU 5 + +; TODO find a way to not have these hardcoded? +NUM_CARDS_COLOSSEUM EQU 56 +NUM_CARDS_EVOLUTION EQU 50 +NUM_CARDS_MYSTERY EQU 51 +NUM_CARDS_LABORATORY EQU 51 +NUM_CARDS_PROMOTIONAL EQU 20 + +; wOwnedPhantomCardFlags flags + const_def + const VENUSAUR_OWNED_PHANTOM_F ; $0 + const MEW_OWNED_PHANTOM_F ; $1 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 5c16f2f..8680139 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2174,7 +2174,7 @@ WriteCardListsTerminatorBytes: ; 8ce7 (2:4ce7) Func_8cf9: ; 8cf9 (2:4cf9) call EnableSRAM xor a - ld hl, sb703 + ld hl, sHasPromotionalCards ld [hli], a inc a ; $1 ld [hli], a @@ -3279,7 +3279,7 @@ HandleDeckBuildScreen: ; 9345 (2:5345) ld hl, PrintDeckBuildingCardList ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d @@ -4708,7 +4708,7 @@ HandleDeckCardSelectionList: ; 9b25 (2:5b25) jr z, .asm_9b5a dec a ld [wCardListVisibleOffset], a - ld hl, wcece + ld hl, wCardListUpdateFunction call CallIndirect xor a jr .asm_9b8f @@ -4734,7 +4734,7 @@ HandleDeckCardSelectionList: ; 9b25 (2:5b25) ld a, [wCardListVisibleOffset] inc a ld [wCardListVisibleOffset], a - ld hl, wcece + ld hl, wCardListUpdateFunction call CallIndirect pop af dec a @@ -5271,7 +5271,7 @@ HandleDeckConfirmationMenu: ; 9e41 (2:5e41) ld hl, UpdateConfirmationCardScreen ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d @@ -5363,7 +5363,7 @@ HandleLeftRightInCardList: ; 9eb8 (2:5eb8) jr z, .asm_9efa ld a, SFX_01 call PlaySFX - ld hl, wcece + ld hl, wCardListUpdateFunction call CallIndirect .asm_9efa scf @@ -5413,7 +5413,7 @@ HandleSelectUpAndDownInList: ; 9efc (2:5efc) jr z, .set_carry ld a, SFX_01 call PlaySFX - ld hl, wcece + ld hl, wCardListUpdateFunction call CallIndirect .set_carry scf @@ -6053,7 +6053,7 @@ HandlePlayersCardsScreen: ; a288 (2:6288) ld hl, PrintCardSelectionList ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d xor a @@ -6078,9 +6078,9 @@ HandlePlayersCardsScreen: ; a288 (2:6288) ld a, [wCardListCursorPos] ld [wTempCardListCursorPos], a - ; set wHandTempList as current card list + ; set wFilteredCardList as current card list ; and show card page screen - ld de, wHandTempList + ld de, wFilteredCardList ld hl, wCurCardListPtr ld [hl], e inc hl @@ -6490,17 +6490,20 @@ PrintTotalNumberOfCardsInCollection: ; a504 (2:6504) ret ; 0xa596 +; fills wFilteredCardList and wOwnedCardsCountList +; with cards IDs and counts, respectively, +; from given Card Set in register a ; a = CARD_SET_* constant -Func_a596: ; a596 (2:6596) +CreateCardSetList: ; a596 (2:6596) push af ld a, DECK_SIZE - ld hl, wHandTempList + ld hl, wFilteredCardList call ClearNBytesFromHL ld a, DECK_SIZE ld hl, wOwnedCardsCountList call ClearNBytesFromHL xor a - ld [wcfe2], a + ld [wOwnedPhantomCardFlags], a pop af ld hl, 0 @@ -6509,7 +6512,7 @@ Func_a596: ; a596 (2:6596) .loop_all_cards inc e call LoadCardDataToBuffer1_FromCardID - jr c, .asm_a5e6 + jr c, .done_pkmn_cards ld a, [wLoadedCard1Set] and $f0 ; set 1 swap a @@ -6519,13 +6522,13 @@ Func_a596: ; a596 (2:6596) ; it's same set as input ld a, e cp VENUSAUR1 - jp z, .Func_a681 + jp z, .SetVenusaur1OwnedFlag cp MEW2 - jp z, .Func_a667 + jp z, .SetMew2OwnedFlag push bc push hl - ld bc, wHandTempList + ld bc, wFilteredCardList add hl, bc ld [hl], e ; card ID @@ -6543,24 +6546,26 @@ Func_a596: ; a596 (2:6596) pop bc jr .loop_all_cards -.asm_a5e6 +.done_pkmn_cards +; for the energy cards, put all basic energy cards in Colosseum +; and Double Colorless energy in Mystery ld a, b cp CARD_SET_MYSTERY jr z, .mystery or a - jr nz, .not_colosseum_or_mystery + jr nz, .skip_energy_cards ; colosseum -; places all basic energy cards in wHandTempList +; places all basic energy cards in wFilteredCardList lb de, 0, 0 .loop_basic_energy_cards inc e ld a, e cp DOUBLE_COLORLESS_ENERGY - jr z, .not_colosseum_or_mystery + jr z, .skip_energy_cards push bc push hl - ld bc, wHandTempList + ld bc, wFilteredCardList add hl, bc ld [hl], e ld hl, wTempCardCollection @@ -6577,19 +6582,19 @@ Func_a596: ; a596 (2:6596) jr .loop_basic_energy_cards .mystery -; places double colorless energy card in wHandTempList +; places double colorless energy card in wFilteredCardList lb de, 0, 0 .loop_find_double_colorless inc e ld a, e cp BULBASAUR - jr z, .not_colosseum_or_mystery + jr z, .skip_energy_cards cp DOUBLE_COLORLESS_ENERGY jr nz, .loop_find_double_colorless ; double colorless energy push bc push hl - ld bc, wHandTempList + ld bc, wFilteredCardList add hl, bc ld [hl], e ld hl, wTempCardCollection @@ -6605,17 +6610,17 @@ Func_a596: ; a596 (2:6596) pop bc jr .loop_find_double_colorless -.not_colosseum_or_mystery - ld a, [wcfe2] - bit 0, a - jr z, .asm_a63e - call .Func_a685 -.asm_a63e - bit 1, a - jr z, .asm_a645 - call .Func_a69a - -.asm_a645 +.skip_energy_cards + ld a, [wOwnedPhantomCardFlags] + bit VENUSAUR_OWNED_PHANTOM_F, a + jr z, .check_mew + call .PlaceVenusaur1InList +.check_mew + bit MEW_OWNED_PHANTOM_F, a + jr z, .find_first_owned + call .PlaceMew2InList + +.find_first_owned dec l ld c, l ld b, h @@ -6624,29 +6629,29 @@ Func_a596: ; a596 (2:6596) add hl, bc ld a, [hl] cp CARD_NOT_OWNED - jr nz, .found_not_owned + jr nz, .found_owned dec c jr .loop_owned_cards -.found_not_owned +.found_owned inc c ld a, c ld [wNumEntriesInCurFilter], a xor a - ld hl, wHandTempList + ld hl, wFilteredCardList add hl, bc ld [hl], a - ld a, $ff + ld a, $ff ; terminator byte ld hl, wOwnedCardsCountList add hl, bc ld [hl], a ret -.Func_a667 - ld a, $02 +.SetMew2OwnedFlag + ld a, (1 << MEW_OWNED_PHANTOM_F) ; fallthrough -.Func_a669 +.SetPhantomOwnedFlag push hl push bc ld b, a @@ -6654,27 +6659,28 @@ Func_a596: ; a596 (2:6596) add hl, de ld a, [hl] cp CARD_NOT_OWNED - jr z, .asm_a67c - ld a, [wcfe2] + jr z, .skip_set_flag + ld a, [wOwnedPhantomCardFlags] or b - ld [wcfe2], a -.asm_a67c + ld [wOwnedPhantomCardFlags], a +.skip_set_flag pop bc pop hl jp .loop_all_cards -.Func_a681 - ld a, $01 - jr .Func_a669 +.SetVenusaur1OwnedFlag + ld a, (1 << VENUSAUR_OWNED_PHANTOM_F) + jr .SetPhantomOwnedFlag -.Func_a685 +.PlaceVenusaur1InList push af push hl ld e, VENUSAUR1 ; fallthrough -.Func_a689 - ld bc, wHandTempList +; places card in register e directly in the list +.PlaceCardInList + ld bc, wFilteredCardList add hl, bc ld [hl], e pop hl @@ -6687,15 +6693,15 @@ Func_a596: ; a596 (2:6596) pop af ret -.Func_a69a +.PlaceMew2InList push af push hl ld e, MEW2 - jr .Func_a689 + jr .PlaceCardInList ; 0xa6a0 ; a = CARD_SET_* constant -Func_a6a0: ; a6a0 (2:66a0) +CreateCardSetListAndInitListCoords: ; a6a0 (2:66a0) push af ld hl, sCardCollection ld de, wTempCardCollection @@ -6706,9 +6712,9 @@ Func_a6a0: ; a6a0 (2:66a0) pop af push af - call Func_a6ca - call Func_a596 - ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS + call .GetEntryPrefix + call CreateCardSetList + ld a, MAX_CARD_ALBUM_VISIBLE_CARDS ld [wNumVisibleCardListEntries], a lb de, 2, 4 ld hl, wCardListCoords @@ -6717,33 +6723,34 @@ Func_a6a0: ; a6a0 (2:66a0) ld [hl], d pop af ret -; 0xa6ca +; places in entry name the prefix associated with the selected Card Set ; a = CARD_SET_* constant -Func_a6ca: ; a6ca (2:66ca) +.GetEntryPrefix push af cp CARD_SET_PROMOTIONAL - jr nz, .asm_a6d4 - ld de, $33f - jr .asm_a6f2 -.asm_a6d4 + jr nz, .laboratory + lb de, 3, "FW3_P" + jr .got_prefix +.laboratory cp CARD_SET_LABORATORY - jr nz, .asm_a6dd - ld de, $333 - jr .asm_a6f2 -.asm_a6dd + jr nz, .mystery + lb de, 3, "FW3_D" + jr .got_prefix +.mystery cp CARD_SET_MYSTERY - jr nz, .asm_a6e6 - ld de, $332 - jr .asm_a6f2 -.asm_a6e6 + jr nz, .evolution + lb de, 3, "FW3_C" + jr .got_prefix +.evolution cp CARD_SET_EVOLUTION - jr nz, .asm_a6ef - ld de, $331 - jr .asm_a6f2 -.asm_a6ef - ld de, $330 -.asm_a6f2 + jr nz, .colosseum + lb de, 3, "FW3_B" + jr .got_prefix +.colosseum + lb de, 3, "FW3_A" + +.got_prefix ld hl, wCurDeckName ld [hl], d inc hl @@ -6752,7 +6759,9 @@ Func_a6ca: ; a6ca (2:66ca) ret ; 0xa6fa -Func_a6fa: ; a6fa (2:66fa) +; prints the cards being shown in the Card Album screen +; for the corresponding Card Set +PrintCardSetListEntries: ; a6fa (2:66fa) push bc ld hl, wCardListCoords ld e, [hl] @@ -6762,32 +6771,35 @@ Func_a6fa: ; a6fa (2:66fa) ld c, e dec c dec c + +; draw up cursor on top right ld a, [wCardListVisibleOffset] or a - jr z, .asm_a710 + jr z, .no_up_cursor ld a, SYM_CURSOR_U - jr .asm_a712 -.asm_a710 + jr .got_up_cursor_tile +.no_up_cursor ld a, SYM_BOX_TOP_R -.asm_a712 +.got_up_cursor_tile call WriteByteToBGMap0 + ld a, [wCardListVisibleOffset] ld l, a ld h, $00 ld a, [wNumVisibleCardListEntries] -.asm_a71e +.loop_visible_cards push de or a - jr z, .asm_a777 + jr z, .handle_down_cursor ld b, a - ld de, wHandTempList + ld de, wFilteredCardList push hl add hl, de ld a, [hl] pop hl inc l or a - jr z, .asm_a788 + jr z, .no_down_cursor ld e, a call AddCardIDToVisibleList call LoadCardDataToBuffer1_FromCardID @@ -6798,15 +6810,15 @@ Func_a6fa: ; a6fa (2:66fa) dec hl ld a, [hl] cp CARD_NOT_OWNED - jr nz, .asm_a74c - ld hl, .text + jr nz, .owned + ld hl, .EmptySlotText ld de, wDefaultText call CopyListFromHLToDE - jr .asm_a751 -.asm_a74c + jr .print_text +.owned ld a, 13 call CopyCardNameAndLevel -.asm_a751 +.print_text pop hl pop bc pop de @@ -6814,14 +6826,17 @@ Func_a6fa: ; a6fa (2:66fa) call InitTextPrinting pop hl push hl - call Func_a7a7 + call .AppendCardListIndex call ProcessText ld hl, wDefaultText jr .asm_a76d + + ; this code is never reached pop de push hl call InitTextPrinting ld hl, Text_9a36 + .asm_a76d call ProcessText pop hl @@ -6829,43 +6844,44 @@ Func_a6fa: ; a6fa (2:66fa) dec a inc e inc e - jr .asm_a71e -.asm_a777 - ld de, wHandTempList + jr .loop_visible_cards + +.handle_down_cursor + ld de, wFilteredCardList add hl, de ld a, [hl] or a - jr z, .asm_a788 + jr z, .no_down_cursor pop de xor a ld [wcecd], a ld a, SYM_CURSOR_D - jr .asm_a790 -.asm_a788 + jr .got_down_cursor_tile +.no_down_cursor pop de ld a, $01 ld [wcecd], a ld a, SYM_BOX_BTM_R -.asm_a790 +.got_down_cursor_tile ld b, 19 ld c, 17 call WriteByteToBGMap0 pop bc ret -.text - db "kkkkkkkkkkkkk" +.EmptySlotText + textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" done -; 0xa7a7 -Func_a7a7: ; a7a7 (2:67a7) +; gets the index in the card list and adds it to wCurDeckName +.AppendCardListIndex push bc push de - ld de, wHandTempList + ld de, wFilteredCardList add hl, de dec hl ld a, [hl] - cp BULBASAUR + cp DOUBLE_COLORLESS_ENERGY + 1 jr c, .energy_card cp VENUSAUR1 jr z, .phantom_card @@ -6883,20 +6899,20 @@ Func_a7a7: ; a7a7 (2:67a7) ld b, a ld a, [hl] or a - jr nz, .asm_a7d2 + jr nz, .got_index ld a, SYM_0 -.asm_a7d2 - ld hl, wCurDeckName + 2 +.got_index + ld hl, wCurDeckName + 2 ; skip prefix ld [hl], TX_SYMBOL inc hl - ld [hli], a + ld [hli], a ; tens place ld [hl], TX_SYMBOL inc hl ld a, b - ld [hli], a + ld [hli], a ; ones place ld [hl], TX_SYMBOL inc hl - xor a + xor a ; SYM_SPACE ld [hli], a ld [hl], a ld hl, wCurDeckName @@ -6925,7 +6941,7 @@ Func_a7a7: ; a7a7 (2:67a7) ld [hli], a ld [hl], TX_SYMBOL inc hl - xor a + xor a ; SYM_SPACE ld [hli], a ld [hl], a ld hl, wCurDeckName + 2 @@ -6934,14 +6950,15 @@ Func_a7a7: ; a7a7 (2:67a7) ret .phantom_card +; phantom cards get only "✕✕" in their index number ld hl, wCurDeckName + 2 - ld [hl], "l" + ld [hl], "FW0_✕" inc hl - ld [hl], "l" + ld [hl], "FW0_✕" inc hl ld [hl], TX_SYMBOL inc hl - xor a + xor a ; SYM_SPACE ld [hli], a ld [hl], a ld hl, wCurDeckName @@ -6950,7 +6967,8 @@ Func_a7a7: ; a7a7 (2:67a7) ret ; 0xa828 -Func_a828: ; a828 (2:6828) +; handles opening card page, and inputs when inside Card Album +HandleCardAlbumCardPage: ; a828 (2:6828) ld a, [wCardListCursorPos] ld b, a ld a, [wCardListVisibleOffset] @@ -6981,14 +6999,14 @@ Func_a828: ; a828 (2:6828) ldh a, [hDPadHeld] ld b, a and A_BUTTON | B_BUTTON | SELECT | START - jp nz, .asm_a8f5 + jp nz, .exit xor a ; FALSE ld [wPlaysSfx], a ld a, [wCardListNumCursorPositions] ld c, a ld a, [wCardListCursorPos] bit D_UP_F, b - jr z, .asm_a891 + jr z, .check_d_down push af ld a, TRUE @@ -6998,21 +7016,21 @@ Func_a828: ; a828 (2:6828) add [hl] ld hl, wFirstOwnedCardIndex cp [hl] - jr z, .open_card_page_pop_af + jr z, .open_card_page_pop_af_2 pop af dec a bit 7, a - jr z, .asm_a8c3 + jr z, .got_new_pos ld a, [wCardListVisibleOffset] or a jr z, .open_card_page dec a ld [wCardListVisibleOffset], a xor a - jr .asm_a8c3 + jr .got_new_pos -.asm_a891 +.check_d_down bit D_DOWN_F, b jr z, .asm_a8d6 @@ -7023,7 +7041,7 @@ Func_a828: ; a828 (2:6828) inc a cp c - jr c, .asm_a8c3 + jr c, .got_new_pos push af ld hl, wCurCardListPtr ld a, [hli] @@ -7040,20 +7058,21 @@ Func_a828: ; a828 (2:6828) add hl, bc ld a, [hl] or a - jr z, .asm_a8d3 + jr z, .open_card_page_pop_af_1 ld a, [wCardListVisibleOffset] inc a ld [wCardListVisibleOffset], a pop af dec a -.asm_a8c3 +.got_new_pos + ; loop back to the start ld [wCardListCursorPos], a ld a, [wPlaysSfx] or a - jp z, Func_a828 + jp z, HandleCardAlbumCardPage call PlaySFX - jp Func_a828 -.asm_a8d3 + jp HandleCardAlbumCardPage +.open_card_page_pop_af_1 pop af jr .open_card_page @@ -7062,15 +7081,15 @@ Func_a828: ; a828 (2:6828) or a jr z, .open_card_page bit D_LEFT_F, b - jr z, .asm_a8e5 + jr z, .check_d_right call RemoveCardFromDeck jr .open_card_page -.asm_a8e5 +.check_d_right bit D_RIGHT_F, b jr z, .open_card_page call TryAddCardToDeck -.open_card_page_pop_af +.open_card_page_pop_af_2 pop af .open_card_page push de @@ -7078,7 +7097,7 @@ Func_a828: ; a828 (2:6828) pop de jp .handle_input -.asm_a8f5 +.exit ld a, $01 ld [wVBlankOAMCopyToggle], a ld a, [wCardListCursorPos] @@ -7101,15 +7120,15 @@ GetFirstOwnedCardIndex: ; a901 (2:6901) ret ; 0xa913 -Func_a913: ; a913 (2:6913) +HandleCardAlbumScreen: ; a913 (2:6913) ld a, $01 ld [hffb4], a ; should be ldh xor a -.asm_a919 +.album_card_list ld hl, .MenuParameters call InitializeMenuParameters - call .Func_aade + call .DrawCardAlbumScreen .loop_input_1 call DoFrame call HandleMenuInput @@ -7117,21 +7136,23 @@ Func_a913: ; a913 (2:6913) ldh a, [hCurMenuItem] cp $ff ret z + + ; ignore input if this Card Set is unavailable ld c, a - ld b, $00 - ld hl, wVisibleListCardIDs + ld b, $0 + ld hl, wUnavailableAlbumCardSets add hl, bc ld a, [hl] or a jr nz, .loop_input_1 ld a, c - ld [wcfe0], a - call Func_a6a0 - call .Func_aa24 + ld [wSelectedCardSet], a + call CreateCardSetListAndInitListCoords + call .PrintCardCount xor a ld [wCardListVisibleOffset], a - call Func_a6fa + call PrintCardSetListEntries call EnableLCD ld a, [wNumEntriesInCurFilter] or a @@ -7145,12 +7166,12 @@ Func_a913: ; a913 (2:6913) ld a, $ff call PlaySFXConfirmOrCancel ldh a, [hCurMenuItem] - jp .asm_a919 + jp .album_card_list .asm_a968 - call .Func_aa13 + call .GetNumCardEntries xor a - ld hl, .data_aa0a + ld hl, .CardSelectionParams call InitCardSelectionParams ld a, [wNumEntriesInCurFilter] ld hl, wNumVisibleCardListEntries @@ -7158,10 +7179,10 @@ Func_a913: ; a913 (2:6913) jr nc, .asm_a97e ld [wCardListNumCursorPositions], a .asm_a97e - ld hl, Func_a6fa + ld hl, PrintCardSetListEntries ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d @@ -7170,13 +7191,13 @@ Func_a913: ; a913 (2:6913) .loop_input_3 call DoFrame call HandleDeckCardSelectionList - jr c, .asm_a9ed + jr c, .selection_made call HandleLeftRightInCardList jr c, .loop_input_3 ldh a, [hDPadHeld] and START jr z, .loop_input_3 -.asm_a99f +.open_card_page ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListNumCursorPositions] @@ -7194,19 +7215,19 @@ Func_a913: ; a913 (2:6913) cp CARD_NOT_OWNED jr z, .loop_input_3 - ; set wHandTempList as current card list - ld de, wHandTempList + ; set wFilteredCardList as current card list + ld de, wFilteredCardList ld hl, wCurCardListPtr ld [hl], e inc hl ld [hl], d call GetFirstOwnedCardIndex - call Func_a828 - call .Func_aa24 - call Func_a6fa + call HandleCardAlbumCardPage + call .PrintCardCount + call PrintCardSetListEntries call EnableLCD - ld hl, .data_aa0a + ld hl, .CardSelectionParams call InitCardSelectionParams ld a, [wTempCardListNumCursorPositions] ld [wCardListNumCursorPositions], a @@ -7214,15 +7235,15 @@ Func_a913: ; a913 (2:6913) ld [wCardListCursorPos], a jr .loop_input_3 -.asm_a9ed +.selection_made call DrawListCursor_Invisible ld a, [wCardListCursorPos] ld [wTempCardListCursorPos], a ld a, [hffb3] cp $ff - jr nz, .asm_a99f + jr nz, .open_card_page ldh a, [hCurMenuItem] - jp .asm_a919 + jp .album_card_list .MenuParameters db 3, 3 ; cursor x, cursor y @@ -7232,31 +7253,33 @@ Func_a913: ; a913 (2:6913) db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -.data_aa0a +.CardSelectionParams db 1 ; x pos db 4 ; y pos db 2 ; y spacing db 0 ; x spacing - db 7 ; num entries + db MAX_CARD_ALBUM_VISIBLE_CARDS ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction -.Func_aa13 - ld hl, wHandTempList +.GetNumCardEntries + ld hl, wFilteredCardList ld b, $00 -.asm_aa18 +.loop_card_ids ld a, [hli] or a jr z, .asm_aa1f inc b - jr .asm_aa18 + jr .loop_card_ids .asm_aa1f ld a, b ld [wNumCardListEntries], a ret -.Func_aa24 +; prints "X/Y" where X is number of cards owned in the set +; and Y is the total card count of the Card Set +.PrintCardCount call Set_OBJ_8x8 xor a ld [wTileMapFill], a @@ -7273,50 +7296,52 @@ Func_a913: ; a913 (2:6913) ld de, $101 call InitTextPrinting - ld a, [wcfe0] +; print the total number of cards that are in the Card Set + ld a, [wSelectedCardSet] cp CARD_SET_PROMOTIONAL jr nz, .check_laboratory +; promotional ldtx hl, Item5PromotionalCardText - ld e, 18 - ld a, [wcfe2] - bit 0, a - jr z, .asm_aa62 - inc e ; 19 -.asm_aa62 - bit 1, a - jr z, .asm_aa8f - inc e ; 20 - jr .asm_aa8f + ld e, NUM_CARDS_PROMOTIONAL - 2 ; minus the phantom cards + ld a, [wOwnedPhantomCardFlags] + bit VENUSAUR_OWNED_PHANTOM_F, a + jr z, .check_owns_mew + inc e +.check_owns_mew + bit MEW_OWNED_PHANTOM_F, a + jr z, .has_card_set_count + inc e + jr .has_card_set_count .check_laboratory cp CARD_SET_LABORATORY jr nz, .check_mystery ldtx hl, Item4LaboratoryText - ld e, 51 - jr .asm_aa8f + ld e, NUM_CARDS_LABORATORY + jr .has_card_set_count .check_mystery cp CARD_SET_MYSTERY jr nz, .check_evolution ldtx hl, Item3MysteryText - ld e, 51 - jr .asm_aa8f + ld e, NUM_CARDS_MYSTERY + jr .has_card_set_count .check_evolution cp CARD_SET_EVOLUTION jr nz, .colosseum ldtx hl, Item2EvolutionText - ld e, 50 - jr .asm_aa8f + ld e, NUM_CARDS_EVOLUTION + jr .has_card_set_count .colosseum ldtx hl, Item1ColosseumText - ld e, 56 + ld e, NUM_CARDS_COLOSSEUM -.asm_aa8f +.has_card_set_count push de call ProcessTextFromID - call .Func_aac8 - ld de, SerialHandleSend.send_escaped + call .CountOwnedCardsInSet + ld de, $0e01 call InitTextPrinting - ld a, [wcfe1] + ld a, [wNumOwnedCardsInSet] ld hl, wDefaultText call ConvertToNumericalDigits call CalculateOnesAndTensDigits @@ -7337,29 +7362,31 @@ Func_a913: ; a913 (2:6913) call EnableLCD ret -.Func_aac8 +; counts number of cards in wOwnedCardsCountList +; that is not set as CARD_NOT_OWNED +.CountOwnedCardsInSet ld hl, wOwnedCardsCountList - ld b, $00 -.asm_aacd + ld b, 0 +.loop_card_count ld a, [hli] cp $ff - jr z, .asm_aad9 + jr z, .got_num_owned_cards cp CARD_NOT_OWNED - jr z, .asm_aacd + jr z, .loop_card_count inc b - jr .asm_aacd -.asm_aad9 + jr .loop_card_count +.got_num_owned_cards ld a, b - ld [wcfe1], a + ld [wNumOwnedCardsInSet], a ret -.Func_aade +.DrawCardAlbumScreen xor a ld [wTileMapFill], a call EmptyScreen ld a, [hffb4] dec a - jr nz, .asm_ab0b + jr nz, .skip_clear_screen ld [hffb4], a call Set_OBJ_8x8 call ZeroObjectPositions @@ -7372,41 +7399,48 @@ Func_a913: ; a913 (2:6913) lb de, $3c, $ff call SetupText -.asm_ab0b +.skip_clear_screen lb de, 0, 0 lb bc, 20, 13 call DrawRegularTextBox ld hl, .BoosterPacksMenuData call PlaceTextItems - ld a, 5 - ld hl, wVisibleListCardIDs + + ; set all Card Sets as available + ld a, NUM_CARD_SETS + ld hl, wUnavailableAlbumCardSets call ClearNBytesFromHL + + ; check whether player has had promotional cards call EnableSRAM - ld a, [sb703] + ld a, [sHasPromotionalCards] call DisableSRAM or a - jr nz, .asm_ab58 + jr nz, .has_promotional + ; doesn't have promotional, check if + ; this is still the case by checking the collection ld a, CARD_SET_PROMOTIONAL - call Func_a6a0 - ld a, [wHandTempList] + call CreateCardSetListAndInitListCoords + ld a, [wFilteredCardList] or a - jr nz, .asm_ab4d - ld a, $01 - ld [wVisibleListCardIDs + 4], a + jr nz, .set_has_promotional + ; still has no promotional, print empty Card Set name + ld a, TRUE + ld [wUnavailableAlbumCardSets + CARD_SET_PROMOTIONAL], a ld e, $0b ld d, $05 call InitTextPrinting - ldtx hl, Text0259 + ldtx hl, EmptyPromotionalCardText call ProcessTextFromID - jr .asm_ab58 + jr .has_promotional -.asm_ab4d +.set_has_promotional call EnableSRAM - ld a, $01 - ld [sb703], a + ld a, TRUE + ld [sHasPromotionalCards], a call DisableSRAM -.asm_ab58 +.has_promotional ldtx hl, ViewWhichCardFileText call DrawWideTextBox_PrintText call EnableLCD @@ -7486,7 +7520,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld hl, PrintCardSelectionList ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d xor a @@ -7509,9 +7543,9 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld a, [wCardListCursorPos] ld [wTempCardListCursorPos], a - ; set wHandTempList as current card list + ; set wFilteredCardList as current card list ; and show card page screen - ld de, wHandTempList + ld de, wFilteredCardList ld hl, wCurCardListPtr ld [hl], e inc hl @@ -7573,7 +7607,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) ld a, [hffb3] or a jr nz, .asm_acd5 - ld hl, wHandTempList + ld hl, wFilteredCardList ld a, [wTempCardListCursorPos] ld c, a ld b, $00 @@ -7794,7 +7828,7 @@ Func_adfe: ; adfe (2:6dfe) ld hl, .Func_ae9a ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d xor a @@ -7994,7 +8028,7 @@ Func_af98: ; af98 (2:6f98) ld hl, ShowReceivedCardsList ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d @@ -8374,7 +8408,7 @@ Func_b285: ; b285 (2:7285) ld hl, Func_b403 ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d xor a @@ -9368,7 +9402,7 @@ Func_b8f4: ; b8f4 (2:78f4) call CreateCardCollectionListWithDeckCards call SafelySwitchToTempSRAMBank ld hl, wTempHandCardList - ld de, wHandTempList + ld de, wFilteredCardList .asm_b92a ld a, [hli] or a @@ -9403,7 +9437,7 @@ Func_b8f4: ; b8f4 (2:78f4) call GetSelectedSavedDeckPtr ld h, d ld l, e - ld de, wHandTempList + ld de, wFilteredCardList call Func_adfe jp Func_b7c6.asm_b7e5 ; 0xb960 @@ -9539,7 +9573,7 @@ Func_ba25: ; ba25 (2:7a25) ld hl, Func_b3fe ld d, h ld a, l - ld hl, wcece + ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d .asm_ba40 diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 85e4e08..5a9b86f 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -1254,7 +1254,7 @@ Func_c859: ; c859 (3:4859) ldh [hSCY], a call Set_OBJ_8x16 farcall Func_1288c - farcall Func_a913 + farcall HandleCardAlbumScreen call Set_OBJ_8x8 ret diff --git a/src/sram.asm b/src/sram.asm index f1e5549..a26c7b5 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -123,7 +123,10 @@ sUnnamedDeckCounter:: ; b701 ds $1 -sb703:: ; b703 +; whether player has had Promotional cards +; to decide whether to show the option +; in the Card Album PC menu +sHasPromotionalCards:: ; b703 ds $4 ds $f9 diff --git a/src/text/text2.asm b/src/text/text2.asm index ded4bd9..8901f4e 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1820,7 +1820,7 @@ ViewWhichCardFileText: ; 3bdaf (e:7daf) text "View which Card File?" done -Text0259: ; 3bdc6 (e:7dc6) +EmptyPromotionalCardText: ; 3bdc6 (e:7dc6) textfw0 "-", "-", "-", "-", "-", "-", "-", "-", "-", "-" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 636ccbf..9f50d9d 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -602,7 +602,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer Item4LaboratoryText ; 0x0256 textpointer Item5PromotionalCardText ; 0x0257 textpointer ViewWhichCardFileText ; 0x0258 - textpointer Text0259 ; 0x0259 + textpointer EmptyPromotionalCardText ; 0x0259 textpointer SCardsText ; 0x025a textpointer EmptyDeckNameText ; 0x025b textpointer DeckSaveMachineText ; 0x025c diff --git a/src/wram.asm b/src/wram.asm index d693c26..7944c9a 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1988,11 +1988,23 @@ wOnesAndTensPlace:: ; ceb6 wCardFilterCounts:: ; cebb ds NUM_FILTERS +UNION + ; buffer used to show which card IDs ; are visible in a given list wVisibleListCardIDs:: ; cec4 ds MAX_DECK_CONFIRMATION_VISIBLE_CARDS +NEXTU + +; whether a given Card Set is unavailable in the Card Album screen +; used only for CARD_SET_PROMOTIONAL, in which case +; if it's unavailable, will print "----------" as the Card Set name +wUnavailableAlbumCardSets:: ; cec4 + ds NUM_CARD_SETS + +ENDU + ; number of visible entries ; when showing a list of cards wNumVisibleCardListEntries:: ; cecb @@ -2004,7 +2016,9 @@ wTotalCardCount:: ; cecc wcecd:: ; cecd ds $1 -wcece:: ; cece +; pointer to a function that should be called +; to update the card list being shown +wCardListUpdateFunction:: ; cece ds $2 ; holds y and x coordinates (in that order) @@ -2125,13 +2139,17 @@ wCursorAlternateTile:: ; cfde wTempCardListNumCursorPositions:: ; cfdf ds $1 -wcfe0:: ; cfe0 +; which Card Set selected by the player to view +wSelectedCardSet:: ; cfe0 ds $1 -wcfe1:: ; cfe1 +; number of cards the player owns from the given Card Set +wNumOwnedCardsInSet:: ; cfe1 ds $1 -wcfe2:: ; cfe2 +; flags that corresponds to each Phantom Card owned by the player +; see src/constants/menu_constants.asm +wOwnedPhantomCardFlags:: ; cfe2 ds $1 ; a flag indicating whether sfx should be played. -- cgit v1.2.3 From 475ab464d86bd7a742774407080b2d48e7eb10e4 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Tue, 11 May 2021 16:21:28 +0100 Subject: Auto Deck Machine functionalities --- src/constants/menu_constants.asm | 12 +- src/data/auto_deck_card_lists.asm | 1159 +++++++++++++++++++++++++++++++++++++ src/data/auto_deck_machines.asm | 82 +++ src/engine/bank02.asm | 1026 ++++++++++++++++++-------------- src/engine/bank03.asm | 6 +- src/engine/bank06.asm | 166 +++--- src/sram.asm | 22 + src/text/text3.asm | 202 +++---- src/text/text_offsets.asm | 202 +++---- src/wram.asm | 60 +- 10 files changed, 2198 insertions(+), 739 deletions(-) create mode 100644 src/data/auto_deck_card_lists.asm create mode 100644 src/data/auto_deck_machines.asm (limited to 'src') diff --git a/src/constants/menu_constants.asm b/src/constants/menu_constants.asm index ab60293..86df8bf 100644 --- a/src/constants/menu_constants.asm +++ b/src/constants/menu_constants.asm @@ -13,9 +13,10 @@ FILTER_ENERGY EQU $20 NUM_FILTERS EQU 9 -MAX_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7 -MAX_CARD_ALBUM_VISIBLE_CARDS EQU 7 -MAX_FILTERED_LIST_VISIBLE_CARDS EQU 6 +NUM_DECK_CONFIRMATION_VISIBLE_CARDS EQU 7 +NUM_CARD_ALBUM_VISIBLE_CARDS EQU 7 +NUM_FILTERED_LIST_VISIBLE_CARDS EQU 6 +NUM_DECK_MACHINE_VISIBLE_DECKS EQU 5 ; deck flags const_def @@ -24,6 +25,11 @@ MAX_FILTERED_LIST_VISIBLE_CARDS EQU 6 const DECK_3_F ; $2 const DECK_4_F ; $3 +DECK_1 EQU 1 << DECK_1_F ; $1 +DECK_2 EQU 1 << DECK_2_F ; $2 +DECK_3 EQU 1 << DECK_3_F ; $4 +DECK_4 EQU 1 << DECK_4_F ; $8 + ALL_DECKS EQU $ff NUM_DECK_SAVE_MACHINE_SLOTS EQU 60 diff --git a/src/data/auto_deck_card_lists.asm b/src/data/auto_deck_card_lists.asm new file mode 100644 index 0000000..8dbf6e5 --- /dev/null +++ b/src/data/auto_deck_card_lists.asm @@ -0,0 +1,1159 @@ +; card lists read by AutoDeckMachineEntries +; each list entry is a card count and card ID pair + +AllFightingPokemonCardList: ; 1b0da (6:70da) + db 26, FIGHTING_ENERGY + db 2, SANDSHREW + db 1, SANDSLASH + db 2, DIGLETT + db 1, DUGTRIO + db 2, MANKEY + db 1, PRIMEAPE + db 3, MACHOP + db 2, MACHOKE + db 1, MACHAMP + db 2, GEODUDE + db 1, GRAVELER + db 1, GOLEM + db 1, ONIX + db 2, CUBONE + db 1, MAROWAK1 + db 1, HITMONLEE + db 1, HITMONCHAN + db 2, RHYHORN + db 1, RHYDON + db 1, PROFESSOR_OAK + db 2, BILL + db 1, SWITCH + db 2, POTION + db 0 ; end of list + +BenchAttackCardList: ; 1b10b (6:710b) + db 12, LIGHTNING_ENERGY + db 14, FIGHTING_ENERGY + db 4, VOLTORB + db 2, ELECTRODE2 + db 2, ZAPDOS1 + db 4, HITMONLEE + db 2, HITMONCHAN + db 4, MEOWTH1 + db 1, PROFESSOR_OAK + db 2, BILL + db 1, MR_FUJI + db 2, ENERGY_RETRIEVAL + db 2, SWITCH + db 1, SCOOP_UP + db 2, PLUSPOWER + db 2, DEFENDER + db 1, ITEM_FINDER + db 1, GUST_OF_WIND + db 1, MAINTENANCE + db 0 ; end of list + +BattleContestCardList: ; 1b132 (6:7132) + db 24, FIGHTING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 3, MANKEY + db 4, MACHOP + db 3, MACHOKE + db 2, HITMONLEE + db 2, HITMONCHAN + db 3, MEOWTH1 + db 2, PERSIAN + db 3, DRATINI + db 2, DRAGONAIR + db 1, DRAGONITE2 + db 1, PROFESSOR_OAK + db 3, PLUSPOWER + db 3, DEFENDER + db 2, POTION + db 0 ; end of list + +HeatedBattleCardList: ; 1b153 (6:7153) + db 8, FIRE_ENERGY + db 4, LIGHTNING_ENERGY + db 15, FIGHTING_ENERGY + db 4, MAGMAR1 + db 2, ELECTABUZZ2 + db 3, MANKEY + db 2, PRIMEAPE + db 3, HITMONLEE + db 3, HITMONCHAN + db 2, KANGASKHAN + db 2, ENERGY_SEARCH + db 2, SCOOP_UP + db 3, PLUSPOWER + db 2, DEFENDER + db 3, POTION + db 2, FULL_HEAL + db 0 ; end of list + +FirstStrikeCardList: ; 1b174 (6:7174) + db 25, FIGHTING_ENERGY + db 4, MACHOP + db 3, MACHOKE + db 2, MACHAMP + db 2, HITMONCHAN + db 4, HITMONLEE + db 4, MANKEY + db 1, PRIMEAPE + db 2, POTION + db 2, DEFENDER + db 2, PLUSPOWER + db 2, SWITCH + db 3, GUST_OF_WIND + db 4, BILL + db 0 ; end of list + +SqueakingMouseCardList: ; 1b191 (6:7191) + db 8, LIGHTNING_ENERGY + db 15, FIGHTING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 2, PIKACHU1 + db 2, PIKACHU2 + db 1, RAICHU1 + db 1, RAICHU2 + db 4, SANDSHREW + db 3, SANDSLASH + db 4, RATTATA + db 3, RATICATE + db 1, PROFESSOR_OAK + db 2, BILL + db 1, POKEMON_TRADER + db 2, ENERGY_RETRIEVAL + db 1, COMPUTER_SEARCH + db 3, PLUSPOWER + db 2, DEFENDER + db 2, POTION + db 1, SUPER_POTION + db 0 ; end of list + +GreatQuakeCardList: ; 1b1ba (6:71ba) + db 25, FIGHTING_ENERGY + db 4, DIGLETT + db 3, DUGTRIO + db 4, ONIX + db 3, RHYHORN + db 2, RHYDON + db 2, KANGASKHAN + db 1, TAUROS + db 1, SNORLAX + db 1, PROFESSOR_OAK + db 2, BILL + db 2, POKEMON_TRADER + db 3, SWITCH + db 4, DEFENDER + db 3, POTION + db 0 ; end of list + +BoneAttackCardList: ; 1b1d9 (6:71d9) + db 24, FIGHTING_ENERGY + db 3, SANDSHREW + db 2, SANDSLASH + db 3, GEODUDE + db 2, GRAVELER + db 1, GOLEM + db 4, ONIX + db 4, CUBONE + db 1, MAROWAK1 + db 2, MAROWAK2 + db 2, RHYHORN + db 1, RHYDON + db 2, BILL + db 1, MR_FUJI + db 2, POKE_BALL + db 1, POKEDEX + db 3, DEFENDER + db 2, POKEMON_FLUTE + db 0 ; end of list + +ExcavationCardList: ; 1b1fe (6:71fe) + db 15, FIGHTING_ENERGY + db 8, WATER_ENERGY + db 3, SHELLDER + db 1, CLOYSTER + db 3, OMANYTE + db 2, OMASTAR + db 4, SANDSHREW + db 2, SANDSLASH + db 3, CUBONE + db 1, MAROWAK2 + db 3, HITMONCHAN + db 2, KABUTO + db 1, KABUTOPS + db 2, AERODACTYL + db 2, PROFESSOR_OAK + db 2, BILL + db 2, POKEMON_BREEDER + db 4, MYSTERIOUS_FOSSIL + db 0 ; end of list + +RockCrusherCardList: ; 1b223 (6:7223) + db 24, FIGHTING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 4, DIGLETT + db 2, DUGTRIO + db 4, GEODUDE + db 3, GRAVELER + db 2, GOLEM + db 3, ONIX + db 3, RHYHORN + db 2, PROFESSOR_OAK + db 1, POKEMON_BREEDER + db 2, ENERGY_REMOVAL + db 2, SWITCH + db 1, COMPUTER_SEARCH + db 2, DEFENDER + db 1, SUPER_POTION + db 2, POTION + db 0 ; end of list + +BlueWaterCardList: ; 1b246 (6:7246) + db 25, WATER_ENERGY + db 2, PSYDUCK + db 1, GOLDUCK + db 2, POLIWAG + db 1, POLIWHIRL + db 1, POLIWRATH + db 2, SEEL + db 1, DEWGONG + db 2, SHELLDER + db 1, CLOYSTER + db 2, KRABBY + db 1, KINGLER + db 2, HORSEA + db 1, SEADRA + db 1, MAGIKARP + db 1, GYARADOS + db 1, LAPRAS + db 1, OMANYTE + db 1, OMASTAR + db 1, ARTICUNO1 + db 1, PROFESSOR_OAK + db 2, BILL + db 1, POKEMON_TRADER + db 2, MYSTERIOUS_FOSSIL + db 1, ENERGY_SEARCH + db 1, POKE_BALL + db 1, POTION + db 1, SUPER_POTION + db 0 ; end of list + +OnTheBeachCardList: ; 1b27f (6:727f) + db 16, WATER_ENERGY + db 10, FIGHTING_ENERGY + db 2, SEEL + db 1, DEWGONG + db 3, SHELLDER + db 2, CLOYSTER + db 3, KRABBY + db 2, KINGLER + db 3, STARYU + db 2, STARMIE + db 3, SANDSHREW + db 2, SANDSLASH + db 2, BILL + db 2, ENERGY_RETRIEVAL + db 2, ENERGY_REMOVAL + db 2, GUST_OF_WIND + db 3, POTION + db 0 ; end of list + +ParalyzeCardList: ; 1b2a2 (6:72a2) + db 8, GRASS_ENERGY + db 14, WATER_ENERGY + db 4, DOUBLE_COLORLESS_ENERGY + db 3, CATERPIE + db 2, METAPOD + db 3, SQUIRTLE + db 2, WARTORTLE + db 3, SHELLDER + db 2, CLOYSTER + db 4, STARYU + db 3, STARMIE + db 2, PROFESSOR_OAK + db 2, BILL + db 2, PLUSPOWER + db 2, DEFENDER + db 4, POTION + db 0 ; end of list + +EnergyRemovalCardList: ; 1b2c3 (6:72c3) + db 15, WATER_ENERGY + db 8, PSYCHIC_ENERGY + db 3, DOUBLE_COLORLESS_ENERGY + db 3, PSYDUCK + db 2, GOLDUCK + db 4, POLIWAG + db 3, POLIWHIRL + db 2, POLIWRATH + db 4, GASTLY2 + db 3, HAUNTER1 + db 3, DRATINI + db 2, DRAGONAIR + db 1, PROFESSOR_OAK + db 1, BILL + db 1, LASS + db 2, ENERGY_SEARCH + db 2, ENERGY_REMOVAL + db 1, SUPER_ENERGY_REMOVAL + db 0 ; end of list + +RainDancerCardList: ; 1b2e8 (6:72e8) + db 24, WATER_ENERGY + db 4, SQUIRTLE + db 3, WARTORTLE + db 2, BLASTOISE + db 4, GOLDEEN + db 3, SEAKING + db 3, HORSEA + db 2, SEADRA + db 2, LAPRAS + db 2, PROFESSOR_OAK + db 1, POKEMON_BREEDER + db 1, ENERGY_RETRIEVAL + db 1, SUPER_ENERGY_RETRIEVAL + db 2, ENERGY_REMOVAL + db 1, SUPER_ENERGY_REMOVAL + db 2, SWITCH + db 2, POTION + db 1, GAMBLER + db 0 ; end of list + +CutePokemonCardList: ; 1b30d (6:730d) + db 4, FIRE_ENERGY + db 6, WATER_ENERGY + db 8, LIGHTNING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 1, FLAREON2 + db 1, VAPOREON2 + db 1, PIKACHU1 + db 1, PIKACHU2 + db 1, PIKACHU3 + db 1, PIKACHU4 + db 1, FLYING_PIKACHU + db 1, SURFING_PIKACHU1 + db 1, SURFING_PIKACHU2 + db 1, RAICHU1 + db 1, RAICHU2 + db 1, JOLTEON2 + db 2, CLEFAIRY + db 1, CLEFABLE + db 1, JIGGLYPUFF1 + db 2, JIGGLYPUFF2 + db 1, JIGGLYPUFF3 + db 2, WIGGLYTUFF + db 4, EEVEE + db 2, PROFESSOR_OAK + db 3, BILL + db 2, CLEFAIRY_DOLL + db 2, SCOOP_UP + db 1, COMPUTER_SEARCH + db 1, PLUSPOWER + db 1, DEFENDER + db 3, POTION + db 0 ; end of list + +PokemonFluteCardList: ; 1b34c (6:734c) + db 9, WATER_ENERGY + db 12, LIGHTNING_ENERGY + db 2, STARYU + db 2, LAPRAS + db 3, PIKACHU1 + db 1, RAICHU1 + db 2, MAGNEMITE1 + db 3, ELECTABUZZ2 + db 2, RATTATA + db 1, RATICATE + db 2, PROFESSOR_OAK + db 4, BILL + db 3, ENERGY_REMOVAL + db 1, COMPUTER_SEARCH + db 3, PLUSPOWER + db 2, ITEM_FINDER + db 4, GUST_OF_WIND + db 4, POKEMON_FLUTE + db 0 ; end of list + +YellowFlashCardList: ; 1b371 (6:7371) + db 26, LIGHTNING_ENERGY + db 2, PIKACHU1 + db 1, PIKACHU2 + db 1, RAICHU1 + db 1, RAICHU2 + db 2, MAGNEMITE1 + db 1, MAGNEMITE2 + db 1, MAGNETON1 + db 1, MAGNETON2 + db 3, VOLTORB + db 1, ELECTRODE1 + db 1, ELECTRODE2 + db 1, ELECTABUZZ1 + db 1, ELECTABUZZ2 + db 1, JOLTEON1 + db 1, JOLTEON2 + db 1, ZAPDOS1 + db 1, ZAPDOS2 + db 3, EEVEE + db 1, ENERGY_RETRIEVAL + db 2, ENERGY_REMOVAL + db 2, POKE_BALL + db 2, PLUSPOWER + db 2, DEFENDER + db 1, GUST_OF_WIND + db 0 ; end of list + +ElectricShockCardList: ; 1b3a4 (6:73a4) + db 24, LIGHTNING_ENERGY + db 1, DOUBLE_COLORLESS_ENERGY + db 2, PIKACHU2 + db 1, PIKACHU3 + db 1, PIKACHU4 + db 2, RAICHU1 + db 2, MAGNEMITE1 + db 2, MAGNEMITE2 + db 2, MAGNETON1 + db 4, VOLTORB + db 3, ELECTRODE2 + db 1, ZAPDOS2 + db 3, PORYGON + db 2, ENERGY_RETRIEVAL + db 2, PLUSPOWER + db 3, DEFENDER + db 2, ITEM_FINDER + db 3, GUST_OF_WIND + db 0 ; end of list + +ZappingSelfdestructCardList: ; 1b3c9 (6:73c9) + db 24, LIGHTNING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 4, MAGNEMITE1 + db 3, MAGNETON1 + db 4, VOLTORB + db 2, ELECTRODE1 + db 4, ELECTABUZZ2 + db 2, KANGASKHAN + db 1, TAUROS + db 1, PROFESSOR_OAK + db 2, BILL + db 2, SWITCH + db 4, DEFENDER + db 1, GUST_OF_WIND + db 4, POTION + db 0 ; end of list + +InsectCollectionCardList: ; 1b3e8 (6:73e8) + db 24, GRASS_ENERGY + db 3, CATERPIE + db 2, METAPOD + db 1, BUTTERFREE + db 3, WEEDLE + db 2, KAKUNA + db 1, BEEDRILL + db 4, PARAS + db 3, PARASECT + db 2, VENONAT + db 1, VENOMOTH + db 1, SCYTHER + db 1, PINSIR + db 2, BILL + db 2, POKEMON_BREEDER + db 2, SWITCH + db 2, POKE_BALL + db 2, POKEDEX + db 2, POTION + db 0 ; end of list + +JungleCardList: ; 1b40f (6:740f) + db 25, GRASS_ENERGY + db 1, DOUBLE_COLORLESS_ENERGY + db 2, EKANS + db 1, ARBOK + db 2, ZUBAT + db 1, GOLBAT + db 2, ODDISH + db 1, GLOOM + db 1, VILEPLUME + db 2, PARAS + db 1, PARASECT + db 2, VENONAT + db 1, VENOMOTH + db 2, BELLSPROUT + db 1, WEEPINBELL + db 1, VICTREEBEL + db 1, PINSIR + db 1, LICKITUNG + db 1, KANGASKHAN + db 2, BILL + db 1, SWITCH + db 1, POKE_BALL + db 2, PLUSPOWER + db 2, DEFENDER + db 2, POTION + db 1, FULL_HEAL + db 0 ; end of list + +FlowerGardenCardList: ; 1b444 (6:7444) + db 24, GRASS_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 3, BULBASAUR + db 2, IVYSAUR + db 2, VENUSAUR2 + db 3, ODDISH + db 2, GLOOM + db 2, VILEPLUME + db 2, BELLSPROUT + db 1, WEEPINBELL + db 1, VICTREEBEL + db 2, TANGELA1 + db 1, TANGELA2 + db 2, LICKITUNG + db 2, POKEMON_TRADER + db 3, POKEMON_BREEDER + db 1, ENERGY_SEARCH + db 2, SWITCH + db 2, POTION + db 1, FULL_HEAL + db 0 ; end of list + +KaleidoscopeCardList: ; 1b46d (6:746d) + db 10, GRASS_ENERGY + db 4, FIRE_ENERGY + db 4, WATER_ENERGY + db 4, LIGHTNING_ENERGY + db 3, DOUBLE_COLORLESS_ENERGY + db 3, VENONAT + db 2, VENOMOTH + db 1, FLAREON1 + db 1, FLAREON2 + db 1, VAPOREON1 + db 1, VAPOREON2 + db 1, JOLTEON1 + db 1, JOLTEON2 + db 4, DITTO + db 4, EEVEE + db 4, PORYGON + db 2, BILL + db 2, MR_FUJI + db 2, ENERGY_SEARCH + db 4, SWITCH + db 2, GUST_OF_WIND + db 0 ; end of list + +FlowerPowerCardList: ; 1b498 (6:7498) + db 18, GRASS_ENERGY + db 4, PSYCHIC_ENERGY + db 4, BULBASAUR + db 3, IVYSAUR + db 2, VENUSAUR2 + db 4, ODDISH + db 3, GLOOM + db 2, VILEPLUME + db 4, EXEGGCUTE + db 3, EXEGGUTOR + db 2, PROFESSOR_OAK + db 3, BILL + db 2, POKEMON_BREEDER + db 2, ENERGY_RETRIEVAL + db 2, SWITCH + db 2, POTION + db 0 ; end of list + +PsychicPowerCardList: ; 1b4b9 (6:74b9) + db 25, PSYCHIC_ENERGY + db 3, ABRA + db 2, KADABRA + db 1, ALAKAZAM + db 2, SLOWPOKE2 + db 1, SLOWBRO + db 1, GASTLY1 + db 2, GASTLY2 + db 1, HAUNTER1 + db 1, HAUNTER2 + db 1, GENGAR + db 2, DROWZEE + db 1, HYPNO + db 1, MR_MIME + db 1, JYNX + db 1, MEWTWO1 + db 1, MEW3 + db 1, CLEFAIRY + db 1, CLEFABLE + db 1, SNORLAX + db 2, PROFESSOR_OAK + db 1, POKEMON_TRADER + db 1, POKEMON_BREEDER + db 2, SWITCH + db 1, POKEMON_CENTER + db 2, PLUSPOWER + db 1, DEVOLUTION_SPRAY + db 0 ; end of list + +DreamEaterHaunterCardList: ; 1b40f (6:740f) + db 7, GRASS_ENERGY + db 17, PSYCHIC_ENERGY + db 3, ZUBAT + db 2, GOLBAT + db 4, GASTLY1 + db 1, HAUNTER1 + db 2, HAUNTER2 + db 2, GENGAR + db 3, DROWZEE + db 2, HYPNO + db 2, JIGGLYPUFF3 + db 2, MEOWTH2 + db 2, PROFESSOR_OAK + db 2, BILL + db 2, ENERGY_RETRIEVAL + db 1, SUPER_ENERGY_RETRIEVAL + db 2, SWITCH + db 1, COMPUTER_SEARCH + db 3, REVIVE + db 0 ; end of list + +ScavengingSlowbroCardList: ; 1b517 (6:7517) + db 23, PSYCHIC_ENERGY + db 4, SLOWPOKE2 + db 3, SLOWBRO + db 3, JYNX + db 2, MEWTWO1 + db 2, MEW3 + db 2, JIGGLYPUFF2 + db 2, JIGGLYPUFF3 + db 2, EEVEE + db 2, ENERGY_RETRIEVAL + db 3, ENERGY_REMOVAL + db 2, PLUSPOWER + db 3, DEFENDER + db 3, POTION + db 4, RECYCLE + db 0 ; end of list + +StrangePowerCardList: ; 1b536 (6:7536) + db 25, PSYCHIC_ENERGY + db 1, DOUBLE_COLORLESS_ENERGY + db 3, SLOWPOKE1 + db 2, SLOWBRO + db 4, DROWZEE + db 3, HYPNO + db 2, MR_MIME + db 2, JYNX + db 1, MEW1 + db 2, MEW3 + db 2, LICKITUNG + db 1, SNORLAX + db 2, POKEMON_TRADER + db 2, ENERGY_RETRIEVAL + db 2, ENERGY_REMOVAL + db 1, SUPER_ENERGY_REMOVAL + db 2, PLUSPOWER + db 1, ITEM_FINDER + db 1, GUST_OF_WIND + db 1, FULL_HEAL + db 0 ; end of list + +StrangePsyshockCardList: ; 1b55f (6:755f) + db 22, PSYCHIC_ENERGY + db 4, ABRA + db 3, KADABRA + db 2, ALAKAZAM + db 2, MR_MIME + db 3, CHANSEY + db 3, KANGASKHAN + db 2, SNORLAX + db 2, PROFESSOR_OAK + db 2, POKEMON_CENTER + db 3, ENERGY_REMOVAL + db 3, GUST_OF_WIND + db 4, SCOOP_UP + db 4, SWITCH + db 1, GAMBLER + db 0 ; end of list + +LovelyNidoranCardList: ; 1b57e (6:757e) + db 20, GRASS_ENERGY + db 4, NIDORANF + db 3, NIDORINA + db 2, NIDOQUEEN + db 4, NIDORANM + db 4, NIDORINO + db 4, NIDOKING + db 3, LICKITUNG + db 2, PROFESSOR_OAK + db 3, POKEMON_TRADER + db 3, POKEMON_BREEDER + db 2, ENERGY_RETRIEVAL + db 3, SWITCH + db 1, COMPUTER_SEARCH + db 2, ITEM_FINDER + db 0 ; end of list + +ScienceCorpsCardList: ; 1b59d (6:759d) + db 26, GRASS_ENERGY + db 2, EKANS + db 1, ARBOK + db 2, NIDORANF + db 1, NIDORINA + db 1, NIDOQUEEN + db 3, NIDORANM + db 2, NIDORINO + db 1, NIDOKING + db 2, ZUBAT + db 1, GOLBAT + db 2, GRIMER + db 1, MUK + db 2, KOFFING + db 1, WEEZING + db 2, MEOWTH2 + db 1, PERSIAN + db 1, PROFESSOR_OAK + db 1, BILL + db 1, POKEMON_TRADER + db 1, POKEMON_BREEDER + db 1, POTION + db 1, FULL_HEAL + db 1, MAINTENANCE + db 1, GAMBLER + db 1, RECYCLE + db 0 ; end of list + +FlyinPokemonCardList: ; 1b5d2 (6:75d2) + db 13, GRASS_ENERGY + db 10, LIGHTNING_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 4, ZUBAT + db 3, GOLBAT + db 2, FLYING_PIKACHU + db 4, PIDGEY + db 3, PIDGEOTTO + db 1, PIDGEOT1 + db 1, PIDGEOT2 + db 4, SPEAROW + db 3, FEAROW + db 2, IMPOSTER_PROFESSOR_OAK + db 2, LASS + db 2, BILL + db 4, POTION + db 0 ; end of list + +PoisonCardList: ; 1b5f3 (6:75f3) + db 24, GRASS_ENERGY + db 3, WEEDLE + db 2, KAKUNA + db 1, BEEDRILL + db 4, EKANS + db 3, ARBOK + db 4, NIDORANM + db 3, NIDORINO + db 2, NIDOKING + db 3, KOFFING + db 2, WEEZING + db 1, PROFESSOR_OAK + db 2, IMPOSTER_PROFESSOR_OAK + db 1, POKEMON_BREEDER + db 2, POTION + db 2, FULL_HEAL + db 1, GAMBLER + db 0 ; end of list + +WondersOfScienceCardList: ; 1b616 (6:7616) + db 15, GRASS_ENERGY + db 8, PSYCHIC_ENERGY + db 4, GRIMER + db 3, MUK + db 4, KOFFING + db 3, WEEZING + db 2, MEWTWO1 + db 1, MEWTWO3 + db 1, MEWTWO2 + db 2, PORYGON + db 1, IMPOSTER_PROFESSOR_OAK + db 2, PROFESSOR_OAK + db 2, BILL + db 2, ENERGY_SEARCH + db 2, SWITCH + db 2, COMPUTER_SEARCH + db 2, POKEDEX + db 2, MAINTENANCE + db 2, FULL_HEAL + db 0 ; end of list + +ReplaceEmAllCardList: ; 1b63d (6:763d) + db 24, FIRE_ENERGY + db 4, VULPIX + db 2, NINETAILS1 + db 1, NINETAILS2 + db 4, GROWLITHE + db 1, ARCANINE1 + db 1, ARCANINE2 + db 4, PIDGEY + db 3, PIDGEOTTO + db 1, PIDGEOT1 + db 1, PIDGEOT2 + db 3, DODUO + db 2, DODRIO + db 2, PROFESSOR_OAK + db 2, IMPOSTER_PROFESSOR_OAK + db 2, LASS + db 3, GUST_OF_WIND + db 0 ; end of list + +ChariSaurCardList: ; 1b660 (6:7660) + db 12, GRASS_ENERGY + db 10, FIRE_ENERGY + db 4, BULBASAUR + db 3, IVYSAUR + db 2, VENUSAUR2 + db 4, CHARMANDER + db 3, CHARMELEON + db 2, CHARIZARD + db 3, FLAREON1 + db 4, EEVEE + db 2, BILL + db 3, POKEMON_TRADER + db 3, POKEMON_BREEDER + db 2, ENERGY_RETRIEVAL + db 1, ENERGY_REMOVAL + db 2, POTION + db 0 ; end of list + +TrafficLightCardList: ; 1b681 (6:7681) + db 10, FIRE_ENERGY + db 8, WATER_ENERGY + db 8, LIGHTNING_ENERGY + db 3, CHARMANDER + db 2, CHARMELEON + db 3, PONYTA + db 2, RAPIDASH + db 2, FLAREON1 + db 2, VAPOREON1 + db 2, PIKACHU1 + db 3, VOLTORB + db 2, ELECTRODE2 + db 2, JOLTEON1 + db 4, EEVEE + db 2, ENERGY_SEARCH + db 2, SWITCH + db 3, PLUSPOWER + db 0 ; end of list + +FirePokemonCardList: ; 1b6a4 (6:76a4) + db 24, FIRE_ENERGY + db 2, DOUBLE_COLORLESS_ENERGY + db 3, CHARMANDER + db 2, CHARMELEON + db 1, CHARIZARD + db 3, VULPIX + db 1, NINETAILS1 + db 1, NINETAILS2 + db 2, GROWLITHE + db 1, ARCANINE2 + db 2, PONYTA + db 1, RAPIDASH + db 1, MAGMAR1 + db 1, MAGMAR2 + db 1, FLAREON1 + db 1, FLAREON2 + db 1, MOLTRES1 + db 3, EEVEE + db 1, PROFESSOR_OAK + db 2, BILL + db 1, POKEMON_TRADER + db 1, POKEMON_BREEDER + db 1, ENERGY_RETRIEVAL + db 1, SUPER_ENERGY_RETRIEVAL + db 1, SWITCH + db 1, GUST_OF_WIND + db 0 ; end of list + +FireChargeCardList: ; 1b6d9 (6:76d9) + db 21, FIRE_ENERGY + db 4, DOUBLE_COLORLESS_ENERGY + db 4, GROWLITHE + db 3, ARCANINE2 + db 2, MAGMAR1 + db 3, JIGGLYPUFF1 + db 1, JIGGLYPUFF3 + db 1, WIGGLYTUFF + db 2, CHANSEY + db 2, TAUROS + db 1, PROFESSOR_OAK + db 2, BILL + db 2, ENERGY_RETRIEVAL + db 1, POKE_BALL + db 1, COMPUTER_SEARCH + db 2, DEFENDER + db 3, POTION + db 1, FULL_HEAL + db 3, RECYCLE + db 1, GAMBLER + db 0 ; end of list + +CharmanderAndFriendsCardList: ; 1b702 (6:7702) + db 8, GRASS_ENERGY + db 10, FIRE_ENERGY + db 6, WATER_ENERGY + db 2, CATERPIE + db 1, METAPOD + db 2, NIDORANF + db 1, NIDORANM + db 1, PINSIR + db 2, CHARMANDER + db 1, CHARMELEON + db 1, CHARIZARD + db 2, GROWLITHE + db 1, ARCANINE2 + db 2, PONYTA + db 1, MAGMAR1 + db 2, SEEL + db 1, DEWGONG + db 2, GOLDEEN + db 1, SEAKING + db 2, RATTATA + db 1, RATICATE + db 1, MEOWTH1 + db 1, PROFESSOR_OAK + db 2, BILL + db 1, SWITCH + db 1, COMPUTER_SEARCH + db 1, PLUSPOWER + db 2, POTION + db 2, FULL_HEAL + db 0 ; end of list + +SquirtleAndFriendsCardList: ; 1b73d (6:773d) + db 8, FIRE_ENERGY + db 11, WATER_ENERGY + db 6, LIGHTNING_ENERGY + db 2, CHARMANDER + db 1, CHARMELEON + db 1, GROWLITHE + db 1, ARCANINE2 + db 1, MAGMAR1 + db 2, SQUIRTLE + db 1, WARTORTLE + db 1, BLASTOISE + db 2, SEEL + db 1, DEWGONG + db 1, GOLDEEN + db 1, SEAKING + db 1, STARYU + db 1, STARMIE + db 1, LAPRAS + db 2, PIKACHU1 + db 1, MAGNEMITE1 + db 1, MAGNETON1 + db 1, ELECTABUZZ2 + db 2, RATTATA + db 1, RATICATE + db 1, MEOWTH1 + db 1, PROFESSOR_OAK + db 1, BILL + db 1, SWITCH + db 1, POKE_BALL + db 1, SCOOP_UP + db 1, ITEM_FINDER + db 1, POTION + db 1, FULL_HEAL + db 0 ; end of list + +BulbasaurAndFriendsCardList: ; 1b780 (6:7780) + db 9, GRASS_ENERGY + db 8, LIGHTNING_ENERGY + db 6, PSYCHIC_ENERGY + db 2, BULBASAUR + db 1, IVYSAUR + db 1, VENUSAUR2 + db 2, NIDORANF + db 2, NIDORANM + db 1, NIDORINO + db 1, TANGELA2 + db 2, PIKACHU1 + db 1, RAICHU1 + db 1, MAGNEMITE1 + db 1, ELECTABUZZ2 + db 2, ABRA + db 1, KADABRA + db 2, GASTLY1 + db 1, HAUNTER2 + db 1, JYNX + db 1, JIGGLYPUFF3 + db 1, MEOWTH1 + db 1, KANGASKHAN + db 1, PROFESSOR_OAK + db 1, BILL + db 1, SWITCH + db 1, POKE_BALL + db 2, PLUSPOWER + db 1, DEFENDER + db 1, GUST_OF_WIND + db 2, POTION + db 2, FULL_HEAL + db 0 ; end of list + +PsychicMachampCardList: ; 1b7b (6:77b) + db 12, FIGHTING_ENERGY + db 12, PSYCHIC_ENERGY + db 2, DIGLETT + db 1, DUGTRIO + db 2, MACHOP + db 1, MACHOKE + db 1, MACHAMP + db 1, ONIX + db 1, HITMONLEE + db 1, HITMONCHAN + db 2, ABRA + db 1, KADABRA + db 1, ALAKAZAM + db 2, GASTLY1 + db 1, HAUNTER2 + db 1, GENGAR + db 1, MR_MIME + db 1, JYNX + db 1, MEW3 + db 2, PIDGEY + db 1, PIDGEOTTO + db 1, PIDGEOT2 + db 2, RATTATA + db 1, RATICATE + db 1, PROFESSOR_OAK + db 2, BILL + db 1, SWITCH + db 1, GUST_OF_WIND + db 2, POTION + db 1, FULL_HEAL + db 0 ; end of list + +WaterBeetleCardList: ; 1b7fc (6:77fc) + db 14, GRASS_ENERGY + db 10, WATER_ENERGY + db 2, WEEDLE + db 1, KAKUNA + db 1, BEEDRILL + db 2, NIDORANM + db 1, NIDORINO + db 1, NIDOKING + db 2, BELLSPROUT + db 1, WEEPINBELL + db 1, VICTREEBEL + db 1, SCYTHER + db 2, POLIWAG + db 1, POLIWHIRL + db 1, POLIWRATH + db 2, KRABBY + db 1, KINGLER + db 2, MAGIKARP + db 1, GYARADOS + db 1, LAPRAS + db 1, ARTICUNO1 + db 1, LICKITUNG + db 1, KANGASKHAN + db 1, TAUROS + db 1, PROFESSOR_OAK + db 2, BILL + db 1, ENERGY_RETRIEVAL + db 1, ENERGY_SEARCH + db 1, SWITCH + db 1, PLUSPOWER + db 1, FULL_HEAL + db 0 ; end of list + +LegendaryMoltresCardList: ; 1b83b (6:783b) + db 25, FIRE_ENERGY + db 4, VULPIX + db 3, NINETAILS2 + db 4, GROWLITHE + db 2, ARCANINE2 + db 2, MAGMAR1 + db 2, MAGMAR2 + db 2, MOLTRES1 + db 2, MOLTRES2 + db 3, BILL + db 2, LASS + db 1, POKEMON_TRADER + db 1, ENERGY_RETRIEVAL + db 1, SUPER_ENERGY_RETRIEVAL + db 2, ENERGY_REMOVAL + db 2, SWITCH + db 1, POTION + db 1, SUPER_POTION + db 0 ; end of list + +LegendaryZapdosCardList: ; 1b860 (6:7860) + db 25, LIGHTNING_ENERGY + db 4, VOLTORB + db 3, ELECTRODE1 + db 4, ELECTABUZZ2 + db 2, JOLTEON2 + db 1, ZAPDOS1 + db 1, ZAPDOS2 + db 2, ZAPDOS3 + db 3, EEVEE + db 4, BILL + db 2, ENERGY_RETRIEVAL + db 2, SWITCH + db 3, PLUSPOWER + db 3, POTION + db 1, GAMBLER + db 0 ; end of list + +LegendaryArticunoCardList: ; 1b87f (6:787f) + db 25, WATER_ENERGY + db 4, SEEL + db 3, DEWGONG + db 4, LAPRAS + db 2, ARTICUNO2 + db 2, ARTICUNO1 + db 3, CHANSEY + db 2, DITTO + db 2, PROFESSOR_OAK + db 2, POKEMON_TRADER + db 3, ENERGY_RETRIEVAL + db 3, SWITCH + db 4, SCOOP_UP + db 1, GAMBLER + db 0 ; end of list + +LegendaryDragoniteCardList: ; 1b89c (6:789c) + db 20, WATER_ENERGY + db 4, DOUBLE_COLORLESS_ENERGY + db 3, CHARMANDER + db 2, CHARMELEON + db 2, CHARIZARD + db 3, MAGIKARP + db 2, GYARADOS + db 2, LAPRAS + db 2, KANGASKHAN + db 4, DRATINI + db 3, DRAGONAIR + db 2, DRAGONITE1 + db 2, PROFESSOR_OAK + db 2, POKEMON_TRADER + db 2, POKEMON_BREEDER + db 1, ENERGY_RETRIEVAL + db 1, SUPER_ENERGY_RETRIEVAL + db 2, SWITCH + db 1, GAMBLER + db 0 ; end of list + +MysteriousPokemonCardList: ; 1b8c3 (6:78c3) + db 12, GRASS_ENERGY + db 14, PSYCHIC_ENERGY + db 4, BULBASAUR + db 3, IVYSAUR + db 2, VENUSAUR1 + db 2, SCYTHER + db 4, ABRA + db 3, KADABRA + db 2, ALAKAZAM + db 2, MR_MIME + db 1, MEW1 + db 2, MEW2 + db 1, PROFESSOR_OAK + db 2, BILL + db 2, POKEMON_BREEDER + db 1, ENERGY_REMOVAL + db 2, SWITCH + db 1, POKEMON_CENTER + db 0 ; end of list +; 0x1b8e8 diff --git a/src/data/auto_deck_machines.asm b/src/data/auto_deck_machines.asm new file mode 100644 index 0000000..17ca823 --- /dev/null +++ b/src/data/auto_deck_machines.asm @@ -0,0 +1,82 @@ +; each Auto Deck Machine has 5 slots for deck configurations +; each entry in an Auto Deck Machine consists of a card list +; (see data/auto_deck_card_lists.asm) and two text IDs +; for the corresponding deck name and description/flavor text + +auto_deck: MACRO + dw \1 ; deck card list + tx \2 ; deck name text ID + tx \3 ; deck description text ID +ENDM + +AutoDeckMachineEntries: ; 1b8e8 (6:78e8) +; Fighting Auto Deck Machine + auto_deck AllFightingPokemonCardList, AllFightingPokemonText, AllFightingPokemonDescriptionText + auto_deck BenchAttackCardList, BenchAttackText, BenchAttackDescriptionText + auto_deck BattleContestCardList, BattleContestText, BattleContestDescriptionText + auto_deck HeatedBattleCardList, HeatedBattleText, HeatedBattleDescriptionText + auto_deck FirstStrikeCardList, FirstStrikeText, FirstStrikeDescriptionText + +; Rock Auto Deck Machine + auto_deck SqueakingMouseCardList, SqueakingMouseText, SqueakingMouseDescriptionText + auto_deck GreatQuakeCardList, GreatQuakeText, GreatQuakeDescriptionText + auto_deck BoneAttackCardList, BoneAttackText, BoneAttackDescriptionText + auto_deck ExcavationCardList, ExcavationText, ExcavationDescriptionText + auto_deck RockCrusherCardList, RockCrusherText, RockCrusherDescriptionText + +; Water Auto Deck Machine + auto_deck BlueWaterCardList, BlueWaterText, BlueWaterDescriptionText + auto_deck OnTheBeachCardList, OnTheBeachText, OnTheBeachDescriptionText + auto_deck ParalyzeCardList, ParalyzeText, ParalyzeDescriptionText + auto_deck EnergyRemovalCardList, EnergyRemovalText, EnergyRemovalDescriptionText + auto_deck RainDancerCardList, RainDancerText, RainDancerDescriptionText + +; Lightning Auto Deck Machine + auto_deck CutePokemonCardList, CutePokemonText, CutePokemonDescriptionText + auto_deck PokemonFluteCardList, PokemonFluteText, PokemonFluteDescriptionText + auto_deck YellowFlashCardList, YellowFlashText, YellowFlashDescriptionText + auto_deck ElectricShockCardList, ElectricShockText, ElectricShockDescriptionText + auto_deck ZappingSelfdestructCardList, ZappingSelfdestructText, ZappingSelfdestructDescriptionText + +; Grass Auto Deck Machine + auto_deck InsectCollectionCardList, InsectCollectionText, InsectCollectionDescriptionText + auto_deck JungleCardList, JungleText, JungleDescriptionText + auto_deck FlowerGardenCardList, FlowerGardenText, FlowerGardenDescriptionText + auto_deck KaleidoscopeCardList, KaleidoscopeText, KaleidoscopeDescriptionText + auto_deck FlowerPowerCardList, FlowerPowerText, FlowerPowerDescriptionText + +; Psychic Auto Deck Machine + auto_deck PsychicPowerCardList, PsychicPowerText, PsychicPowerDescriptionText + auto_deck DreamEaterHaunterCardList, DreamEaterHaunterText, DreamEaterHaunterDescriptionText + auto_deck ScavengingSlowbroCardList, ScavengingSlowbroText, ScavengingSlowbroDescriptionText + auto_deck StrangePowerCardList, StrangePowerText, StrangePowerDescriptionText + auto_deck StrangePsyshockCardList, StrangePsyshockText, StrangePsyshockDescriptionText + +; Science Auto Deck Machine + auto_deck LovelyNidoranCardList, LovelyNidoranText, LovelyNidoranDescriptionText + auto_deck ScienceCorpsCardList, ScienceCorpsText, ScienceCorpsDescriptionText + auto_deck FlyinPokemonCardList, FlyinPokemonText, FlyinPokemonDescriptionText + auto_deck PoisonCardList, PoisonText, PoisonDescriptionText + auto_deck WondersOfScienceCardList, WondersOfScienceText, WondersOfScienceDescriptionText + +; Fire Auto Deck Machine + auto_deck ReplaceEmAllCardList, ReplaceEmAllText, ReplaceEmAllDescriptionText + auto_deck ChariSaurCardList, ChariSaurText, ChariSaurDescriptionText + auto_deck TrafficLightCardList, TrafficLightText, TrafficLightDescriptionText + auto_deck FirePokemonCardList, FirePokemonDeckText, FirePokemonDescriptionText + auto_deck FireChargeCardList, FireChargeText, FireChargeDescriptionText + +; Auto Deck Machine + auto_deck CharmanderAndFriendsCardList, CharmanderAndFriendsText, CharmanderAndFriendsDescriptionText + auto_deck SquirtleAndFriendsCardList, SquirtleAndFriendsText, SquirtleAndFriendsDescriptionText + auto_deck BulbasaurAndFriendsCardList, BulbasaurAndFriendsText, BulbasaurAndFriendsDescriptionText + auto_deck PsychicMachampCardList, PsychicMachampText, PsychicMachampDescriptionText + auto_deck WaterBeetleCardList, WaterBeetleText, WaterBeetleDescriptionText + +; Legendary Auto Deck Machine + auto_deck LegendaryMoltresCardList, LegendaryMoltresText, LegendaryMoltresDescriptionText + auto_deck LegendaryZapdosCardList, LegendaryZapdosText, LegendaryZapdosDescriptionText + auto_deck LegendaryArticunoCardList, LegendaryArticunoText, LegendaryArticunoDescriptionText + auto_deck LegendaryDragoniteCardList, LegendaryDragoniteText, LegendaryDragoniteDescriptionText + auto_deck MysteriousPokemonCardList, MysteriousPokemonText, MysteriousPokemonDescriptionText +; 0x1ba14 diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 8680139..46df6f6 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2260,7 +2260,7 @@ DeckBuildingParams: ; 8da9 (2:4da9) DeckSelectionMenu: ; 8db0 (2:4db0) ld hl, DeckBuildingParams call InitDeckBuildingParams - ld a, $ff + ld a, ALL_DECKS call DrawDecksScreen xor a @@ -2321,7 +2321,7 @@ HandleStartButtonInDeckSelectionMenu: ; 8dea (2:4dea) call GetPointerToDeckName pop de call OpenDeckConfirmationMenu - ld a, $ff + ld a, ALL_DECKS call DrawDecksScreen ld a, [wCurDeck] scf @@ -2421,7 +2421,7 @@ DeckSelectionSubMenu: ; 8e42 (2:4e42) or a jr z, .get_input_deck_name .asm_8ec4 - ld a, $ff + ld a, ALL_DECKS call DrawDecksScreen ld a, [wCurDeck] jp DeckSelectionMenu.init_menu_params @@ -2444,7 +2444,7 @@ DeckSelectionSubMenu: ; 8e42 (2:4e42) ld e, l ld hl, wCurDeckName call CopyListFromHLToDEInSRAM - ld a, $ff + ld a, ALL_DECKS call DrawDecksScreen ld a, [wCurDeck] jp DeckSelectionMenu.init_menu_params @@ -2637,7 +2637,7 @@ DeckSelectionData: ; 9027 (2:5027) GetPointerToDeckName: ; 9038 (2:5038) ld a, [wCurDeck] ld h, a - ld l, sDeck2Name - sDeck1Name + ld l, DECK_STRUCT_SIZE call HtimesL push de ld de, sDeck1Name @@ -2906,7 +2906,7 @@ AddDeckToCollection: ; 9152 (2:5152) ; draws the screen which shows the player's current ; deck configurations -; a = some flags to pick which deck names to show +; a = DECK_* flags to pick which deck names to show DrawDecksScreen: ; 9168 (2:5168) ld [hffb5], a call EmptyScreenAndLoadFontDuelAndHandCardsIcons @@ -3704,7 +3704,7 @@ FilteredCardListSelectionParams: ; 9670 (2:5670) db 7 ; y pos db 2 ; y spacing db 0 ; x spacing - db MAX_FILTERED_LIST_VISIBLE_CARDS ; num entries + db NUM_FILTERED_LIST_VISIBLE_CARDS ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction @@ -4294,7 +4294,7 @@ PrintFilteredCardList: ; 993d (2:593d) pop af call CreateFilteredCardList - ld a, MAX_FILTERED_LIST_VISIBLE_CARDS + ld a, NUM_FILTERED_LIST_VISIBLE_CARDS ld [wNumVisibleCardListEntries], a lb de, 1, 7 ld hl, wCardListCoords @@ -4431,14 +4431,14 @@ PrintDeckBuildingCardList: ; 99b0 (2:59b0) ; draw down cursor because ; there are still more cards ; to be scrolled down - xor a - ld [wcecd], a + xor a ; FALSE + ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D jr .draw_cursor .cannot_scroll pop de - ld a, $01 - ld [wcecd], a + ld a, TRUE + ld [wUnableToScrollDown], a ld a, SYM_SPACE .draw_cursor ld b, 19 ; x coord @@ -4728,9 +4728,9 @@ HandleDeckCardSelectionList: ; 9b25 (2:5b25) cp c jr c, .asm_9b8f push af - ld a, [wcecd] + ld a, [wUnableToScrollDown] or a - jr nz, .asm_9b87 + jr nz, .cannot_scroll_down ld a, [wCardListVisibleOffset] inc a ld [wCardListVisibleOffset], a @@ -4740,7 +4740,7 @@ HandleDeckCardSelectionList: ; 9b25 (2:5b25) dec a jr .asm_9b8f -.asm_9b87 +.cannot_scroll_down pop af dec a push af @@ -5260,9 +5260,9 @@ HandleDeckConfirmationMenu: ; 9e41 (2:5e41) call InitCardSelectionParams ld a, [wNumUniqueCards] ld [wNumCardListEntries], a - cp MAX_DECK_CONFIRMATION_VISIBLE_CARDS + cp NUM_DECK_CONFIRMATION_VISIBLE_CARDS jr c, .no_cap - ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS + ld a, NUM_DECK_CONFIRMATION_VISIBLE_CARDS .no_cap ld [wCardListNumCursorPositions], a ld [wNumVisibleCardListEntries], a @@ -5629,14 +5629,14 @@ SortCurDeckCardsByID: ; a028 (2:6028) ; 0xa06e ; goes through list in wCurDeckCards, and for each card in it -; creates list in wTempHandCardList of all unique cards +; creates list in wUniqueDeckCardList of all unique cards ; it finds (assuming wCurDeckCards is sorted by ID) -; also counts the number of the different cards +; also counts the total number of the different cards CreateCurDeckUniqueCardList: ; a06e (2:606e) ld b, 0 ld c, $0 ld hl, wCurDeckCards - ld de, wTempHandCardList + ld de, wUniqueDeckCardList .loop ld a, [hli] cp c @@ -5726,15 +5726,15 @@ PrintConfirmationCardList: ; a08a (2:608a) or a jr z, .no_more_cards pop de - xor a - ld [wcecd], a + xor a ; FALSE + ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D jr .got_cursor_tile_2 .no_more_cards pop de - ld a, $01 - ld [wcecd], a + ld a, TRUE + ld [wUnableToScrollDown], a ld a, SYM_SPACE .got_cursor_tile_2 ld b, 19 ; x coord @@ -6147,7 +6147,7 @@ PrintFilteredCardSelectionList: ; a39f (2:639f) pop af call CreateFilteredCardList - ld a, MAX_DECK_CONFIRMATION_VISIBLE_CARDS + ld a, NUM_DECK_CONFIRMATION_VISIBLE_CARDS ld [wNumVisibleCardListEntries], a lb de, 2, 5 ld hl, wCardListCoords @@ -6308,14 +6308,14 @@ PrintCardSelectionList: ; a42d (2:642d) ; draw down cursor because ; there are still more cards ; to be scrolled down - xor a - ld [wcecd], a + xor a ; FALSE + ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D jr .got_cursor_tile_2 .cannot_scroll pop de - ld a, $01 - ld [wcecd], a + ld a, TRUE + ld [wUnableToScrollDown], a ld a, [wCursorAlternateTile] .got_cursor_tile_2 ld b, 19 ; x coord @@ -6714,7 +6714,7 @@ CreateCardSetListAndInitListCoords: ; a6a0 (2:66a0) push af call .GetEntryPrefix call CreateCardSetList - ld a, MAX_CARD_ALBUM_VISIBLE_CARDS + ld a, NUM_CARD_ALBUM_VISIBLE_CARDS ld [wNumVisibleCardListEntries], a lb de, 2, 4 ld hl, wCardListCoords @@ -6853,14 +6853,14 @@ PrintCardSetListEntries: ; a6fa (2:66fa) or a jr z, .no_down_cursor pop de - xor a - ld [wcecd], a + xor a ; FALSE + ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D jr .got_down_cursor_tile .no_down_cursor pop de - ld a, $01 - ld [wcecd], a + ld a, TRUE + ld [wUnableToScrollDown], a ld a, SYM_BOX_BTM_R .got_down_cursor_tile ld b, 19 @@ -7258,7 +7258,7 @@ HandleCardAlbumScreen: ; a913 (2:6913) db 4 ; y pos db 2 ; y spacing db 0 ; x spacing - db MAX_CARD_ALBUM_VISIBLE_CARDS ; num entries + db NUM_CARD_ALBUM_VISIBLE_CARDS ; num entries db SYM_CURSOR_R ; visible cursor tile db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction @@ -7783,15 +7783,20 @@ Data_adf5: ; adf5 (2:6df5) dw NULL ; wCardListHandlerFunction ; 0xadfe -; hl = ? -; de = deck -Func_adfe: ; adfe (2:6dfe) +; handles printing and player input +; in the card confirmation list shown +; when cards are missing for some deck configuration +; hl = deck name +; de = deck cards +HandleDeckMissingCardsList: ; adfe (2:6dfe) +; read deck name from hl and cards from de push de ld de, wCurDeckName call CopyListFromHLToDEInSRAM pop de ld hl, wCurDeckCards call CopyDeckFromSRAM + ld a, NUM_FILTERS ld hl, wCardFilterCounts call ClearNBytesFromHL @@ -7799,33 +7804,34 @@ Func_adfe: ; adfe (2:6dfe) ld [wTotalCardCount], a ld hl, wCardFilterCounts ld [hl], a - call .Func_ae21 + call .HandleList ; can skip call and fallthrough instead ret -.Func_ae21 +.HandleList call SortCurDeckCardsByID call CreateCurDeckUniqueCardList xor a ld [wCardListVisibleOffset], a .loop - ld hl, .Data_ae91 + ld hl, .DeckConfirmationCardSelectionParams call InitCardSelectionParams ld a, [wNumUniqueCards] ld [wNumCardListEntries], a cp $05 - jr c, .asm_ae3d + jr c, .got_num_positions ld a, $05 -.asm_ae3d +.got_num_positions ld [wCardListNumCursorPositions], a ld [wNumVisibleCardListEntries], a - call .Func_aeb9 - ld hl, wcfda + call .PrintTitleAndList + ld hl, wCardConfirmationText ld a, [hli] ld h, [hl] ld l, a call DrawWideTextBox_PrintText - ld hl, .Func_ae9a +; set card update function + ld hl, .CardListUpdateFunction ld d, h ld a, l ld hl, wCardListUpdateFunction @@ -7837,13 +7843,14 @@ Func_adfe: ; adfe (2:6dfe) .loop_input call DoFrame call HandleDeckCardSelectionList - jr c, .asm_ae89 + jr c, .selection_made call HandleLeftRightInCardList jr c, .loop_input ldh a, [hDPadHeld] and START jr z, .loop_input -.asm_ae70 + +.open_card_pge ld a, $01 call PlaySFXConfirmOrCancel ld a, [wCardListCursorPos] @@ -7859,13 +7866,13 @@ Func_adfe: ; adfe (2:6dfe) call OpenCardPageFromCardList jr .loop -.asm_ae89 +.selection_made ld a, [hffb3] cp $ff ret z - jr .asm_ae70 + jr .open_card_pge -.Data_ae91 +.DeckConfirmationCardSelectionParams db 0 ; x pos db 3 ; y pos db 2 ; y spacing @@ -7875,13 +7882,13 @@ Func_adfe: ; adfe (2:6dfe) db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction -.Func_ae9a +.CardListUpdateFunction ld hl, hffb0 ld [hl], $01 - call .Func_aed3 + call .PrintDeckIndexAndName ld de, $10e call InitTextPrinting - ld hl, wcfda + ld hl, wCardConfirmationText ld a, [hli] ld h, [hl] ld l, a @@ -7890,8 +7897,8 @@ Func_adfe: ; adfe (2:6dfe) ld [hl], $00 jp PrintConfirmationCardList -.Func_aeb9 - call .Func_aec9 +.PrintTitleAndList + call .ClearScreenAndPrintDeckTitle lb de, 3, 3 ld hl, wCardListCoords ld [hl], e @@ -7900,16 +7907,18 @@ Func_adfe: ; adfe (2:6dfe) call PrintConfirmationCardList ret -.Func_aec9 +.ClearScreenAndPrintDeckTitle call EmptyScreenAndLoadFontDuelAndHandCardsIcons - call .Func_aed3 + call .PrintDeckIndexAndName call EnableLCD ret -.Func_aed3 +; prints text in the form "X. deck" +; where X is the deck index in the list +.PrintDeckIndexAndName ld a, [wCurDeckName] or a - ret z + ret z ; not a valid deck ld de, $1 call InitTextPrinting ld a, [wCurDeck] @@ -7927,7 +7936,7 @@ Func_adfe: ; adfe (2:6dfe) call CopyListFromHLToDE ld hl, wDefaultText call GetTextLengthInTiles - ld b, $00 + ld b, $0 ld hl, wDefaultText add hl, bc ld d, h @@ -8288,124 +8297,138 @@ Func_b177: ; b177 (2:7177) dw Func_bc7a ; 0xb19d -Func_b19d: ; b19d (2:719d) +HandleDeckSaveMachineMenu: ; b19d (2:719d) xor a ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText - ld hl, wd0a2 + ld hl, wDeckMachineTitleText ld [hl], e inc hl ld [hl], d - call Func_b379 - ld a, $3c - ld [wd0a5], a + call ClearScreenAndDrawDeckMachineScreen + ld a, NUM_DECK_SAVE_MACHINE_SLOTS + ld [wNumDeckMachineEntries], a + xor a -.asm_b1b3 - ld hl, Data_b6fb +.wait_input + ld hl, DeckMachineSelectionParams call InitCardSelectionParams - call Func_b704 + call DrawListScrollArrows call PrintNumSavedDecks ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText ldtx de, PleaseSelectDeckText - call Func_b285 - call Func_b29f - jr c, .asm_b1b3 + call InitDeckMachineDrawingParams + call HandleDeckMachineSelection + jr c, .wait_input cp $ff - ret z + ret z ; operation cancelled + ; get the index of selected deck ld b, a ld a, [wCardListVisibleOffset] add b - ld [wd088], a + ld [wSelectedDeckMachineEntry], a + call ResetCheckMenuCursorPositionAndBlink call DrawWideTextBox - ld hl, Unknown_b274 + ld hl, .DeckMachineMenuData call PlaceTextItems -.asm_b1e7 +.wait_input_submenu call DoFrame call HandleCheckMenuInput - jp nc, .asm_b1e7 + jp nc, .wait_input_submenu cp $ff - jr nz, .asm_b1fa - ld a, [wd086] - jp .asm_b1b3 + jr nz, .submenu_option_selected + ; return from submenu + ld a, [wTempDeckMachineCursorPos] + jp .wait_input -.asm_b1fa +.submenu_option_selected ld a, [wCheckMenuCursorYPosition] sla a ld hl, wCheckMenuCursorXPosition add [hl] or a - jr nz, .asm_b22c - call Func_b35b - jr nc, .asm_b216 - call Func_b592 - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e + jr nz, .ok_1 -.asm_b216 +; Save a Deck + call CheckIfSelectedDeckMachineEntryIsEmpty + jr nc, .prompt_ok_if_deleted + call SaveDeckInDeckSaveMachine + ld a, [wTempDeckMachineCursorPos] + jp c, .wait_input + jr .return_to_list +.prompt_ok_if_deleted ldtx hl, OKIfFileDeletedText call YesOrNoMenuWithText - ld a, [wd086] - jr c, .asm_b1b3 - call Func_b592 - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e - -.asm_b22c + ld a, [wTempDeckMachineCursorPos] + jr c, .wait_input + call SaveDeckInDeckSaveMachine + ld a, [wTempDeckMachineCursorPos] + jp c, .wait_input + jr .return_to_list + +.ok_1 cp $1 - jr nz, .asm_b24c - call Func_b35b - jr c, .asm_b240 + jr nz, .ok_2 + +; Delete a Deck + call CheckIfSelectedDeckMachineEntryIsEmpty + jr c, .is_empty call TryDeleteSavedDeck - ld a, [wd086] - jp c, .asm_b1b3 - jr .asm_b25e + ld a, [wTempDeckMachineCursorPos] + jp c, .wait_input + jr .return_to_list -.asm_b240 +.is_empty ld hl, WaitForVBlank call DrawWideTextBox_WaitForInput - ld a, [wd086] - jp .asm_b1b3 + ld a, [wTempDeckMachineCursorPos] + jp .wait_input -.asm_b24c +.ok_2 cp $2 - jr nz, .asm_b273 - call Func_b35b - jr c, .asm_b240 - call Func_b7c6 - ld a, [wd086] - jp nc, .asm_b1b3 - -.asm_b25e - ld a, [wd087] + jr nz, .cancel + +; Build a Deck + call CheckIfSelectedDeckMachineEntryIsEmpty + jr c, .is_empty + call TryBuildDeckMachineDeck + ld a, [wTempDeckMachineCursorPos] + jp nc, .wait_input + +.return_to_list + ld a, [wTempCardListVisibleOffset] ld [wCardListVisibleOffset], a - call Func_b379 - call Func_b704 + call ClearScreenAndDrawDeckMachineScreen + call DrawListScrollArrows call PrintNumSavedDecks - ld a, [wd086] - jp .asm_b1b3 + ld a, [wTempDeckMachineCursorPos] + jp .wait_input -.asm_b273 +.cancel ret -Unknown_b274: ; b274 (2:7274) +.DeckMachineMenuData textitem 2, 14, SaveADeckText textitem 12, 14, DeleteADeckText textitem 2, 16, BuildADeckText textitem 12, 16, CancelText db $ff +; 0xb285 -Func_b285: ; b285 (2:7285) - ld a, $05 +; sets the number of cursor positions for deck machine menu, +; sets the text ID to show given by de +; and sets DrawDeckMachineScreen as the update function +; de = text ID +InitDeckMachineDrawingParams: ; b285 (2:7285) + ld a, NUM_DECK_MACHINE_SLOTS ld [wCardListNumCursorPositions], a - ld hl, wd0a7 + ld hl, wDeckMachineText ld [hl], e inc hl ld [hl], d - ld hl, Func_b403 + ld hl, DrawDeckMachineScreen ld d, h ld a, l ld hl, wCardListUpdateFunction @@ -8416,36 +8439,44 @@ Func_b285: ; b285 (2:7285) ret ; 0xb29f -Func_b29f: ; b29f (2:729f) +; handles player input inside the Deck Machine screen +; the Start button opens up the deck confirmation menu +; and returns carry +; otherwise, returns no carry and selection made in a +HandleDeckMachineSelection: ; b29f (2:729f) call DoFrame call HandleDeckCardSelectionList - jr c, .asm_b303 - call .Func_b317 - jr c, Func_b29f ; loop back to start + jr c, .selection_made + + call .HandleListJumps + jr c, HandleDeckMachineSelection ; jump back to start ldh a, [hDPadHeld] and START - jr z, Func_b29f ; loop back to start + jr z, HandleDeckMachineSelection ; jump back to start ; start btn ld a, [wCardListVisibleOffset] - ld [wd087], a + ld [wTempCardListVisibleOffset], a ld b, a ld a, [wCardListCursorPos] - ld [wd086], a + ld [wTempDeckMachineCursorPos], a add b ld c, a inc a or $80 ld [wCurDeck], a + + ; get pointer to selected deck cards + ; and if it's an empty deck, jump to start sla c - ld b, $00 + ld b, $0 ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] ld l, a push hl - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc ld d, h ld e, l @@ -8454,32 +8485,36 @@ Func_b29f: ; b29f (2:729f) call DisableSRAM pop hl or a - jr z, Func_b29f ; loop back to start + jr z, HandleDeckMachineSelection ; jump back to start +; show deck confirmation screen with deck cards +; and return carry set ld a, $01 call PlaySFXConfirmOrCancel call OpenDeckConfirmationMenu - ld a, [wd087] + ld a, [wTempCardListVisibleOffset] ld [wCardListVisibleOffset], a - call Func_b379 - call Func_b704 + call ClearScreenAndDrawDeckMachineScreen + call DrawListScrollArrows call PrintNumSavedDecks - ld a, [wd086] + ld a, [wTempDeckMachineCursorPos] ld [wCardListCursorPos], a scf ret -.asm_b303 +.selection_made call DrawListCursor_Visible ld a, [wCardListVisibleOffset] - ld [wd087], a + ld [wTempCardListVisibleOffset], a ld a, [wCardListCursorPos] - ld [wd086], a + ld [wTempDeckMachineCursorPos], a ld a, [hffb3] or a ret -.Func_b317 +; handles right and left input for jumping several entries at once +; returns carry if jump was made +.HandleListJumps ld a, [wCardListVisibleOffset] ld c, a ldh a, [hDPadHeld] @@ -8492,60 +8527,64 @@ Func_b29f: ; b29f (2:729f) .d_right ld a, [wCardListVisibleOffset] - add $05 + add NUM_DECK_MACHINE_SLOTS ld b, a - add $05 - ld hl, wd0a5 + add NUM_DECK_MACHINE_SLOTS + ld hl, wNumDeckMachineEntries cp [hl] - jr c, .asm_b347 - ld a, [wd0a5] - sub $05 + jr c, .got_new_pos + ld a, [wNumDeckMachineEntries] + sub NUM_DECK_MACHINE_SLOTS ld b, a - jr .asm_b347 + jr .got_new_pos .d_left ld a, [wCardListVisibleOffset] - sub $05 + sub NUM_DECK_MACHINE_SLOTS ld b, a - jr nc, .asm_b347 - ld b, $00 + jr nc, .got_new_pos + ld b, 0 ; first entry -.asm_b347 +.got_new_pos ld a, b ld [wCardListVisibleOffset], a cp c - jr z, .asm_b359 + jr z, .set_carry + ; play SFX if jump was made + ; and update UI ld a, SFX_01 call PlaySFX - call Func_b403 + call DrawDeckMachineScreen call PrintNumSavedDecks -.asm_b359 +.set_carry scf ret ; 0xb35b -Func_b35b: ; b35b (2:735b) - ld a, [wd088] +; returns carry if deck corresponding to the +; entry selected in the Deck Machine menu is empty +CheckIfSelectedDeckMachineEntryIsEmpty: ; b35b (2:735b) + ld a, [wSelectedDeckMachineEntry] sla a ld l, a - ld h, $00 + ld h, $0 ld bc, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc call EnableSRAM ld a, [hl] call DisableSRAM or a - ret nz + ret nz ; is valid scf - ret + ret; is empty ; 0xb379 -Func_b379: ; b379 (2:7379) +ClearScreenAndDrawDeckMachineScreen: ; b379 (2:7379) call Set_OBJ_8x8 xor a ld [wTileMapFill], a @@ -8561,18 +8600,19 @@ Func_b379: ; b379 (2:7379) lb de, 0, 0 lb bc, 20, 13 call DrawRegularTextBox - call Func_b3b3 + call SetDeckMachineTitleText call GetSavedDeckPointers - call Func_b3e5 + call PrintVisibleDeckMachineEntries call GetSavedDeckCount call EnableLCD ret ; 0xb3b3 -Func_b3b3: ; b3b3 (2:73b3) +; prints wDeckMachineTitleText as title text +SetDeckMachineTitleText: ; b3b3 (2:73b3) lb de, 1, 0 call InitTextPrinting - ld hl, wd0a2 + ld hl, wDeckMachineTitleText ld a, [hli] ld h, [hl] ld l, a @@ -8605,50 +8645,57 @@ GetSavedDeckPointers: ; b3c3 (2:73c3) ret ; 0xb3e5 -Func_b3e5: ; b3e5 (2:73e5) +; given the cursor position in the deck machine menu +; prints the deck names of all entries that are visible +PrintVisibleDeckMachineEntries: ; b3e5 (2:73e5) ld a, [wCardListVisibleOffset] - ld de, $202 - ld b, $05 -.asm_b3ed + lb de, 2, 2 + ld b, NUM_DECK_MACHINE_VISIBLE_DECKS +.loop push af push bc push de - call Func_b424 + call PrintDeckMachineEntry pop de pop bc pop af - ret c + ret c ; jump never made? dec b - ret z + ret z ; no more entries inc a inc e inc e - jr .asm_b3ed + jr .loop ; 0xb3fe -Func_b3fe: ; b3fe (2:73fe) - call Func_b704 - jr Func_b3e5 +UpdateDeckMachineScrollArrowsAndEntries: ; b3fe (2:73fe) + call DrawListScrollArrows + jr PrintVisibleDeckMachineEntries ; 0xb403 -Func_b403: ; b403 (2:7403) - call Func_b704 +DrawDeckMachineScreen: ; b403 (2:7403) + call DrawListScrollArrows ld hl, hffb0 ld [hl], $01 - call Func_b3b3 + call SetDeckMachineTitleText lb de, 1, 14 call InitTextPrinting - ld hl, wd0a7 + ld hl, wDeckMachineText ld a, [hli] ld h, [hl] ld l, a call ProcessTextFromID ld hl, hffb0 ld [hl], $00 - jr Func_b3e5 + jr PrintVisibleDeckMachineEntries ; 0xb424 -Func_b424: ; b424 (2:7424) +; prints the deck name of the deck corresponding +; to index in register a, from wMachineDeckPtrs +; also checks whether the deck can be built +; either by dismantling other decks or not, +; and places the corresponding symbol next to the name +PrintDeckMachineEntry: ; b424 (2:7424) ld b, a push bc ld hl, wDefaultText @@ -8661,10 +8708,13 @@ Func_b424: ; b424 (2:7424) ld hl, wDefaultText call ProcessText pop af + +; get the deck corresponding to input index +; and append its name to wDefaultText push af sla a ld l, a - ld h, $00 + ld h, $0 ld bc, wMachineDeckPtrs add hl, bc ld a, [hli] @@ -8687,7 +8737,7 @@ Func_b424: ; b424 (2:7424) ld d, 13 inc e call InitTextPrinting - ld hl, Text_b4d4 + ld hl, .text call ProcessText scf ret @@ -8697,34 +8747,39 @@ Func_b424: ; b424 (2:7424) push bc ld d, 18 call InitTextPrinting - ld a, $0 + +; print the symbol hat symbolizes whether the deck can +; be built, or if another deck has to be dismantled to build it + ld a, $0 ; no decks dismantled call CheckIfCanBuildSavedDeck pop bc ld hl, wDefaultText - jr c, .asm_b482 - lb de, 3, "FW3_○" + jr c, .cannot_build + lb de, 3, "FW3_○" ; can build jr .asm_b4c2 - -.asm_b482 +.cannot_build push bc ld a, ALL_DECKS call CheckIfCanBuildSavedDeck - jr c, .asm_b490 + jr c, .cannot_build_at_all pop bc - lb de, 3, "FW3_❄" + lb de, 3, "FW3_❄" ; can build by dismantling jr .asm_b4c2 -.asm_b490 - lb de, 0, "FW0_✕" +.cannot_build_at_all + lb de, 0, "FW0_✕" ; cannot build even by dismantling call Func_22ca pop bc pop de + +; place in wDefaultText the number of cards +; that are needed in order to build the deck push bc ld d, 17 inc e call InitTextPrinting pop bc - call Func_b4e1 + call .GetNumCardsMissingToBuildDeck call CalculateOnesAndTensDigits ld hl, wOnesAndTensPlace ld a, [hli] @@ -8750,13 +8805,12 @@ Func_b424: ; b424 (2:7424) ld d, 13 inc e call InitTextPrinting - ld hl, Text_b4d4 + ld hl, .text call ProcessText or a ret -; 0xb4d4 -Text_b4d4: ; b4d4 (2:74d4) +.text db TX_SYMBOL, TX_END db TX_SYMBOL, TX_END db TX_SYMBOL, TX_END @@ -8764,14 +8818,18 @@ Text_b4d4: ; b4d4 (2:74d4) db TX_SYMBOL, TX_END db TX_SYMBOL, TX_END done -; 0xb4e1 -Func_b4e1: ; b4e1 (2:74e1) +; outputs in a the number of cards that the player does not own +; in order to build the deck entry from wMachineDeckPtrs +; given in register b +.GetNumCardsMissingToBuildDeck push bc call SafelySwitchToSRAM0 call CreateCardCollectionListWithDeckCards call SafelySwitchToTempSRAMBank pop bc + +; get address to cards for the corresponding deck entry sla b ld c, b ld b, $00 @@ -8780,34 +8838,35 @@ Func_b4e1: ; b4e1 (2:74e1) ld a, [hli] ld h, [hl] ld l, a - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc + call EnableSRAM ld de, wTempCardCollection - ld bc, $0 -.asm_b505 + lb bc, 0, 0 +.loop inc b ld a, DECK_SIZE cp b - jr c, .asm_b520 + jr c, .done ld a, [hli] push hl ld l, a ld h, $00 add hl, de ld a, [hl] - and $7f + and CARD_COUNT_MASK or a - jr z, .asm_b51c + jr z, .none dec a ld [hl], a pop hl - jr .asm_b505 -.asm_b51c + jr .loop +.none inc c pop hl - jr .asm_b505 -.asm_b520 + jr .loop +.done ld a, c call DisableSRAM ret @@ -8859,43 +8918,53 @@ PrintNumSavedDecks: ; b545 (2:7545) INCROM $b568, $b592 -Func_b592: ; b592 (2:7592) - ld a, $ff +; handles player choice in what deck to save +; in the Deck Save Machine +; assumes the slot to save was selected and +; is stored in wSelectedDeckMachineEntry +; if operation was successful, return carry +SaveDeckInDeckSaveMachine: ; b592 (2:7592) + ld a, ALL_DECKS call DrawDecksScreen xor a -.asm_b598 +.wait_input ld hl, DeckMachineMenuParameters call InitializeMenuParameters ldtx hl, ChooseADeckToSaveText call DrawWideTextBox_PrintText -.loop_input +.wait_submenu_input call DoFrame call HandleStartButtonInDeckSelectionMenu - jr c, .asm_b598 + jr c, .wait_input call HandleMenuInput - jp nc, .loop_input ; can be jr + jp nc, .wait_submenu_input ; can be jr ldh a, [hCurMenuItem] cp $ff - ret z + ret z ; operation cancelled ld [wCurDeck], a call CheckIfCurDeckIsValid - jp nc, .Func_b5c8 + jp nc, .SaveDeckInSelectedEntry ; can be jr + ; is an empty deck call PrintThereIsNoDeckHereText ld a, [wCurDeck] - jr .asm_b598 + jr .wait_input -.Func_b5c8 +; overwrites data in the selected deck in SRAM +; with the deck that was chosen, in wCurDeck +; then returns carry +.SaveDeckInSelectedEntry call GetPointerToDeckName call GetSelectedSavedDeckPtr ld b, DECK_STRUCT_SIZE call EnableSRAM call CopyNBytesFromHLToDE call DisableSRAM - call Func_b379 - call Func_b704 + + call ClearScreenAndDrawDeckMachineScreen + call DrawListScrollArrows call PrintNumSavedDecks - ld a, [wd086] - ld hl, Data_b6fb + ld a, [wTempDeckMachineCursorPos] + ld hl, DeckMachineSelectionParams call InitCardSelectionParams call DrawListCursor_Visible call GetPointerToDeckName @@ -8921,11 +8990,11 @@ DeckMachineMenuParameters: ; b609 (2:7609) ; 0xb611 ; outputs in de pointer of saved deck -; corresponding to index in wd088 +; corresponding to index in wSelectedDeckMachineEntry GetSelectedSavedDeckPtr: ; b611 (2:7611) push af push hl - ld a, [wd088] + ld a, [wSelectedDeckMachineEntry] sla a ld e, a ld d, $00 @@ -9119,7 +9188,7 @@ TryDeleteSavedDeck: ; b6ca (2:76ca) ret ; 0xb6fb -Data_b6fb: ; b6fb (2:76fb) +DeckMachineSelectionParams: ; b6fb (2:76fb) db 1 ; x pos db 2 ; y pos db 2 ; y spacing @@ -9129,31 +9198,31 @@ Data_b6fb: ; b6fb (2:76fb) db SYM_SPACE ; invisible cursor tile dw NULL ; wCardListHandlerFunction -Func_b704: ; b704 (2:7704) +DrawListScrollArrows: ; b704 (2:7704) ld a, [wCardListVisibleOffset] or a - jr z, .asm_b70e + jr z, .no_up_cursor ld a, SYM_CURSOR_U jr .got_tile_1 -.asm_b70e +.no_up_cursor ld a, SYM_BOX_RIGHT .got_tile_1 lb bc, 19, 1 call WriteByteToBGMap0 ld a, [wCardListVisibleOffset] - add $06 + add NUM_DECK_MACHINE_VISIBLE_DECKS + 1 ld b, a - ld a, [wd0a5] + ld a, [wNumDeckMachineEntries] cp b - jr c, .asm_b72a - xor a - ld [wcecd], a + jr c, .no_down_cursor + xor a ; FALSE + ld [wUnableToScrollDown], a ld a, SYM_CURSOR_D jr .got_tile_2 -.asm_b72a - ld a, $01 - ld [wcecd], a +.no_down_cursor + ld a, TRUE + ld [wUnableToScrollDown], a ld a, SYM_BOX_RIGHT .got_tile_2 lb bc, 19, 11 @@ -9161,11 +9230,13 @@ Func_b704: ; b704 (2:7704) ret ; 0xb738 -Func_b738: ; b738 (2:7738) +; handles the deck menu for when the player +; needs to make space for new deck to build +HandleDismantleDeckToMakeSpace: ; b738 (2:7738) ldtx hl, YouMayOnlyCarry4DecksText call DrawWideTextBox_WaitForInput call SafelySwitchToSRAM0 - ld a, $ff + ld a, ALL_DECKS call DrawDecksScreen xor a .init_menu_params @@ -9181,12 +9252,13 @@ Func_b738: ; b738 (2:7738) jp nc, .loop_input ; can be jr ldh a, [hCurMenuItem] cp $ff - jr nz, .asm_b76c + jr nz, .selected_deck + ; operation was cancelled call SafelySwitchToTempSRAMBank scf ret -.asm_b76c +.selected_deck ld [wCurDeck], a ldtx hl, DismantleThisDeckText call YesOrNoMenuWithText @@ -9197,26 +9269,28 @@ Func_b738: ; b738 (2:7738) .dismantle call GetPointerToDeckName push hl - ld de, wd089 + ld de, wDismantledDeckName call EnableSRAM call CopyListFromHLToDE pop hl push hl - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc call AddDeckToCollection pop hl ld a, DECK_STRUCT_SIZE call ClearNBytesFromHL call DisableSRAM - ld a, $ff + + ; redraw deck screen + ld a, ALL_DECKS call DrawDecksScreen ld a, [wCurDeck] ld hl, DeckMachineMenuParameters call InitializeMenuParameters call DrawCursor2 call SafelySwitchToTempSRAMBank - ld hl, wd089 + ld hl, wDismantledDeckName call CopyDeckName xor a ld [wTxRam2 + 0], a @@ -9227,79 +9301,92 @@ Func_b738: ; b738 (2:7738) ret ; 0xb7c6 -Func_b7c6: ; b7c6 (2:77c6) - ld a, [wd088] +; tries to build the deck in wSelectedDeckMachineEntry +; will check if can be built with or without dismantling +; prompts the player in case a deck has to be dismantled +; or, if it's impossible to build deck, shows missing cards list +TryBuildDeckMachineDeck: ; b7c6 (2:77c6) + ld a, [wSelectedDeckMachineEntry] ld b, a push bc ld a, $0 call CheckIfCanBuildSavedDeck pop bc - jr nc, .asm_b7f3 + jr nc, .build_deck ld a, ALL_DECKS call CheckIfCanBuildSavedDeck - jr c, .asm_b7ea + jr c, .do_not_own_all_cards_needed + ; can only be built by dismantling some deck ldtx hl, ThisDeckCanOnlyBeBuiltIfYouDismantleText call DrawWideTextBox_WaitForInput - call Func_b87d - jr nc, .asm_b7f3 + call .DismantleDecksNeededToBuild + jr nc, .build_deck + ; player chose not to dismantle -.asm_b7e5 +.set_carry_and_return ld a, [wCardListCursorPos] scf ret -.asm_b7ea +.do_not_own_all_cards_needed ldtx hl, YouDoNotOwnAllCardsNeededToBuildThisDeckText call DrawWideTextBox_WaitForInput - jp Func_b8f4 + jp .ShowMissingCardList -.asm_b7f3 +.build_deck call EnableSRAM call SafelySwitchToSRAM0 call FindFirstEmptyDeckSlot call SafelySwitchToTempSRAMBank call DisableSRAM - jr nc, .asm_b80b - call Func_b738 - jr nc, .asm_b80b + jr nc, .got_deck_slot + call HandleDismantleDeckToMakeSpace + jr nc, .got_deck_slot scf ret -.asm_b80b - ld [wd08a + $17], a - ld a, [wd088] +.got_deck_slot + ld [wDeckSlotForNewDeck], a + ld a, [wSelectedDeckMachineEntry] ld c, a - ld b, $00 + ld b, $0 sla c ld hl, wMachineDeckPtrs add hl, bc ld a, [hli] ld h, [hl] ld l, a - ld de, wc000 + + ; copy deck to buffer + ld de, wDeckToBuild ld b, DECK_STRUCT_SIZE call EnableSRAM call CopyNBytesFromHLToDE - ld hl, wc000 + $18 + ; remove the needed cards from collection + ld hl, wDeckToBuild + DECK_NAME_SIZE call SafelySwitchToSRAM0 call DecrementDeckCardsInCollection - ld a, [wd08a + $17] + + ; copy the deck cards from the buffer + ; to the deck slot that was chosen + ld a, [wDeckSlotForNewDeck] ld l, a ld h, DECK_STRUCT_SIZE call HtimesL - ld bc, sDeck1Name + ld bc, sBuiltDecks add hl, bc ld d, h ld e, l - ld hl, wc000 + ld hl, wDeckToBuild ld b, DECK_STRUCT_SIZE call CopyNBytesFromHLToDE call DisableSRAM - ld a, $ff + ; draw Decks screen + ld a, ALL_DECKS call DrawDecksScreen - ld a, [wd08a + $17] + ld a, [wDeckSlotForNewDeck] ld [wCurDeck], a ld hl, DeckMachineMenuParameters call InitializeMenuParameters @@ -9309,7 +9396,6 @@ Func_b7c6: ; b7c6 (2:77c6) call CopyDeckName call DisableSRAM call SafelySwitchToTempSRAMBank - xor a ld [wTxRam2 + 0], a ld [wTxRam2 + 1], a @@ -9317,10 +9403,15 @@ Func_b7c6: ; b7c6 (2:77c6) call DrawWideTextBox_WaitForInput scf ret -; 0xb87d -Func_b87d: ; b87d (2:787d) - farcall Func_1ba9a +; asks the player for confirmation to dismantle decks +; needed to build the selected deck from the Deck Save Machine +; returns carry set if player selected "no" +; if player selected "yes", dismantle decks +.DismantleDecksNeededToBuild +; shows Decks screen with the names +; of the decks to be dismantled + farcall CheckWhichDecksToDismantleToBuildSavedDeck call SafelySwitchToSRAM0 call DrawDecksScreen ldtx hl, DismantleTheseDecksText @@ -9333,32 +9424,33 @@ Func_b87d: ; b87d (2:787d) .yes call EnableSRAM - ld a, [wd0a6] - bit 0, a - jr z, .asm_b8a3 - ld a, $00 - call .Func_b8db -.asm_b8a3 - ld a, [wd0a6] - bit 1, a - jr z, .asm_b8af - ld a, $01 - call .Func_b8db -.asm_b8af - ld a, [wd0a6] - bit 2, a - jr z, .asm_b8bb - ld a, $02 - call .Func_b8db -.asm_b8bb - ld a, [wd0a6] - bit 3, a - jr z, .asm_b8c7 - ld a, $03 - call .Func_b8db -.asm_b8c7 + ld a, [wDecksToBeDismantled] + bit DECK_1_F, a + jr z, .deck_2 + ld a, DECK_1_F + call .DismantleDeck +.deck_2 + ld a, [wDecksToBeDismantled] + bit DECK_2_F, a + jr z, .deck_3 + ld a, DECK_2_F + call .DismantleDeck +.deck_3 + ld a, [wDecksToBeDismantled] + bit DECK_3_F, a + jr z, .deck_4 + ld a, DECK_3_F + call .DismantleDeck +.deck_4 + ld a, [wDecksToBeDismantled] + bit DECK_4_F, a + jr z, .done_dismantling + ld a, DECK_4_F + call .DismantleDeck + +.done_dismantling call DisableSRAM - ld a, [wd0a6] + ld a, [wDecksToBeDismantled] call DrawDecksScreen call SafelySwitchToTempSRAMBank ldtx hl, DismantledTheDeckText @@ -9366,27 +9458,33 @@ Func_b87d: ; b87d (2:787d) or a ret -.Func_b8db +; dismantles built deck given by a +; and adds its cards to the collection +; a = DECK_*_F to dismantle +.DismantleDeck ld l, a ld h, DECK_STRUCT_SIZE call HtimesL - ld bc, sDeck1Name + ld bc, sBuiltDecks add hl, bc push hl - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc call AddDeckToCollection pop hl ld a, DECK_STRUCT_SIZE call ClearNBytesFromHL ret -; 0xb8f4 -Func_b8f4: ; b8f4 (2:78f4) - ld a, [wd088] +; collects cards missing from player's collection +; and shows its confirmation list +.ShowMissingCardList +; copy saved deck card from SRAM to wCurDeckCards +; and make unique card list sorted by ID + ld a, [wSelectedDeckMachineEntry] ld [wCurDeck], a call GetSelectedSavedDeckPtr - ld hl, $18 + ld hl, DECK_NAME_SIZE add hl, de ld de, wCurDeckCards ld b, DECK_SIZE @@ -9397,92 +9495,122 @@ Func_b8f4: ; b8f4 (2:78f4) ld [wCurDeckCards + DECK_SIZE], a call SortCurDeckCardsByID call CreateCurDeckUniqueCardList + +; create collection card list, including +; the cards from all built decks ld a, ALL_DECKS call SafelySwitchToSRAM0 call CreateCardCollectionListWithDeckCards call SafelySwitchToTempSRAMBank - ld hl, wTempHandCardList + +; creates list in wFilteredCardList with +; cards that are missing to build this deck + ld hl, wUniqueDeckCardList ld de, wFilteredCardList -.asm_b92a +.loop_deck_configuration ld a, [hli] or a - jr z, .asm_b946 + jr z, .finish_missing_card_list ld b, a push bc push de push hl ld hl, wCurDeckCards - call Func_b960 + call .CheckIfCardIsMissing pop hl pop de pop bc - jr nc, .asm_b92a + jr nc, .loop_deck_configuration + ; this card is missing + ; store in wFilteredCardList this card ID + ; a number of times equal to the amount still needed ld c, a ld a, b -.asm_b93f +.loop_number_missing ld [de], a inc de dec c - jr nz, .asm_b93f - jr .asm_b92a -.asm_b946 - xor a + jr nz, .loop_number_missing + jr .loop_deck_configuration + +.finish_missing_card_list + xor a ; terminator byte ld [de], a + ldtx bc, TheseCardsAreNeededToBuildThisDeckText - ld hl, wcfda + ld hl, wCardConfirmationText ld a, c ld [hli], a ld a, b ld [hl], a + call GetSelectedSavedDeckPtr ld h, d ld l, e ld de, wFilteredCardList - call Func_adfe - jp Func_b7c6.asm_b7e5 -; 0xb960 - -Func_b960: ; b960 (2:7960) - call .Func_b976 - ld hl, wc000 + call HandleDeckMissingCardsList + jp .set_carry_and_return + +; checks if player has enough cards with ID given in register a +; in the collection to build the deck and, if not, returns +; carry set and outputs in a the difference +; a = card ID +; hl = deck cards +.CheckIfCardIsMissing + call .GetCardCountFromDeck + ld hl, wTempCardCollection push de - call .Func_b986 + call .GetCardCountFromCollection ld a, e pop de + + ; d = card count in deck + ; a = card count in collection cp d - jr c, .asm_b971 + jr c, .not_enough or a ret -.asm_b971 + +.not_enough +; needs more cards than player owns in collection +; return carry set and the number of cards needed ld e, a ld a, d sub e scf ret z -.Func_b976 +; returns in d the card count of card ID given in register a +; that is found in the card list in hl +; a = card ID +; hl = deck cards +.GetCardCountFromDeck push af ld e, a - ld d, $00 -.loop + ld d, 0 +.loop_deck_cards ld a, [hli] or a - jr z, .asm_b984 + jr z, .done_deck_cards cp e - jr nz, .loop + jr nz, .loop_deck_cards inc d - jr .loop -.asm_b984 + jr .loop_deck_cards +.done_deck_cards pop af ret -.Func_b986 +; returns in e the card count of card ID given in register a +; that is found in the card collection +; a = card ID +; hl = card collection +.GetCardCountFromCollection push af ld e, a - ld d, $00 + ld d, $0 add hl, de ld a, [hl] - and $7f + and CARD_COUNT_MASK ld e, a pop af ret @@ -9491,22 +9619,22 @@ Func_b960: ; b960 (2:7960) PrinterMenu_DeckConfiguration: ; b991 (2:7991) xor a ld [wCardListVisibleOffset], a - call Func_b379 + call ClearScreenAndDrawDeckMachineScreen ld a, DECK_SIZE - ld [wd0a5], a + ld [wNumDeckMachineEntries], a xor a .asm_b99e - ld hl, Data_b6fb + ld hl, DeckMachineSelectionParams call InitCardSelectionParams - call Func_b704 + call DrawListScrollArrows call PrintNumSavedDecks - ld hl, WaitForVBlank.lcd_off + ldtx hl, PleaseChooseDeckConfigurationToPrintText call DrawWideTextBox_PrintText - ld de, WaitForVBlank.lcd_off - call Func_b285 + ldtx de, PleaseChooseDeckConfigurationToPrintText + call InitDeckMachineDrawingParams .asm_b9b6 - call Func_b29f + call HandleDeckMachineSelection jr c, .asm_b99e cp $ff ret z @@ -9514,8 +9642,8 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) ld b, a ld a, [wCardListVisibleOffset] add b - ld [wd088], a - call Func_b35b + ld [wSelectedDeckMachineEntry], a + call CheckIfSelectedDeckMachineEntryIsEmpty jr c, .asm_b9b6 call DrawWideTextBox ldtx hl, PrintThisDeckText @@ -9532,24 +9660,24 @@ PrinterMenu_DeckConfiguration: ; b991 (2:7991) xor a ; terminator byte for deck ld [wCurDeckCards + DECK_SIZE], a call SortCurDeckCardsByID - ld a, [wd088] + ld a, [wSelectedDeckMachineEntry] bank1call Func_7580 - call Func_b379 + call ClearScreenAndDrawDeckMachineScreen .no - ld a, [wd086] + ld a, [wTempDeckMachineCursorPos] ld [wCardListCursorPos], a jp .asm_b99e ; 0xba04 -Func_ba04: ; ba04 (2:7a04) - ld a, [wd0a9] - ld hl, Data_bb83 +HandleAutoDeckMenu: ; ba04 (2:7a04) + ld a, [wCurAutoDeckMachine] + ld hl, .DeckMachineTitleTextList sla a ld c, a ld b, $0 add hl, bc - ld de, wd0a2 + ld de, wDeckMachineTitleText ld a, [hli] ld [de], a inc de @@ -9557,42 +9685,45 @@ Func_ba04: ; ba04 (2:7a04) ld [de], a xor a ld [wCardListVisibleOffset], a - call Func_bb97 - ld a, $5 - ld [wd0a5], a + call .InitAutoDeckMenu + ld a, NUM_DECK_MACHINE_SLOTS + ld [wNumDeckMachineEntries], a xor a - ; fallthrough -Func_ba25: ; ba25 (2:7a25) +.please_select_deck ld hl, .MenuParameters call InitializeMenuParameters ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText - ld a, $5 + ld a, NUM_DECK_MACHINE_SLOTS ld [wCardListNumCursorPositions], a - ld hl, Func_b3fe + ld hl, UpdateDeckMachineScrollArrowsAndEntries ld d, h ld a, l ld hl, wCardListUpdateFunction ld [hli], a ld [hl], d -.asm_ba40 +.wait_input call DoFrame call HandleMenuInput - jr c, .asm_baa3 + jr c, .deck_selection_made + +; the following lines do nothing ldh a, [hDPadHeld] and D_UP | D_DOWN jr z, .asm_ba4e - .asm_ba4e + +; check whether to show deck confirmation list ldh a, [hDPadHeld] and START - jr z, .asm_ba40 + jr z, .wait_input + ld a, [wCardListVisibleOffset] - ld [wd087], a + ld [wTempCardListVisibleOffset], a ld b, a ld a, [wCurMenuItem] - ld [wd086], a + ld [wTempDeckMachineCursorPos], a add b ld c, a inc a @@ -9607,7 +9738,7 @@ Func_ba25: ; ba25 (2:7a25) ld h, [hl] ld l, a push hl - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc ld d, h ld e, l @@ -9615,75 +9746,80 @@ Func_ba25: ; ba25 (2:7a25) pop hl call SafelySwitchToSRAM0 or a - jr z, .asm_ba40 + jr z, .wait_input ; invalid deck + + ; show confirmation list ld a, $1 call PlaySFXConfirmOrCancel call SafelySwitchToSRAM1 call OpenDeckConfirmationMenu call SafelySwitchToSRAM0 - ld a, [wd087] + ld a, [wTempCardListVisibleOffset] ld [wCardListVisibleOffset], a - call Func_bb97 - ld a, [wd086] - jp Func_ba25 + call .InitAutoDeckMenu + ld a, [wTempDeckMachineCursorPos] + jp .please_select_deck -.asm_baa3 +.deck_selection_made call DrawCursor2 ld a, [wCardListVisibleOffset] - ld [wd087], a + ld [wTempCardListVisibleOffset], a ld a, [wCurMenuItem] - ld [wd086], a + ld [wTempDeckMachineCursorPos], a ldh a, [hCurMenuItem] cp $ff - jp z, .asm_bb0d - ld [wd088], a + jp z, .exit ; operation cancelled + ld [wSelectedDeckMachineEntry], a call ResetCheckMenuCursorPositionAndBlink xor a ld [wce5e], a call DrawWideTextBox - ld hl, Data_bb76 + ld hl, .DeckMachineMenuData call PlaceTextItems -.asm_bacc +.wait_submenu_input call DoFrame call HandleCheckMenuInput_YourOrOppPlayArea - jp nc, .asm_bacc + jp nc, .wait_submenu_input cp $ff - jr nz, .asm_badf - ld a, [wd086] - jp Func_ba25 + jr nz, .submenu_option_selected + ld a, [wTempDeckMachineCursorPos] + jp .please_select_deck -.asm_badf +.submenu_option_selected ld a, [wCheckMenuCursorYPosition] sla a ld hl, wCheckMenuCursorXPosition add [hl] or a jr nz, .asm_bb09 + +; Build a Deck call SafelySwitchToSRAM1 - call Func_b7c6 + call TryBuildDeckMachineDeck call SafelySwitchToSRAM0 - ld a, [wd086] - jp nc, Func_ba25 - ld a, [wd087] + ld a, [wTempDeckMachineCursorPos] + jp nc, .please_select_deck + ld a, [wTempCardListVisibleOffset] ld [wCardListVisibleOffset], a - call Func_bb97 - ld a, [wd086] - jp Func_ba25 + call .InitAutoDeckMenu + ld a, [wTempDeckMachineCursorPos] + jp .please_select_deck .asm_bb09 cp $1 - jr nz, .asm_bb12 -.asm_bb0d + jr nz, .read_the_instructions +.exit xor a ld [wTempBankSRAM], a ret -.asm_bb12 +.read_the_instructions +; show card confirmation list ld a, [wCardListVisibleOffset] - ld [wd087], a + ld [wTempCardListVisibleOffset], a ld b, a ld a, [wCurMenuItem] - ld [wd086], a + ld [wTempDeckMachineCursorPos], a add b ld c, a ld [wCurDeck], a @@ -9691,22 +9827,25 @@ Func_ba25: ; ba25 (2:7a25) ld b, $0 ld hl, wMachineDeckPtrs add hl, bc + + ; set the description text in text box push hl - ld hl, wd0aa + ld hl, wAutoDeckMachineTextDescriptions add hl, bc - ld bc, wcfda + ld bc, wCardConfirmationText ld a, [hli] ld [bc], a inc bc ld a, [hl] ld [bc], a pop hl + call SafelySwitchToSRAM1 ld a, [hli] ld h, [hl] ld l, a push hl - ld bc, $18 + ld bc, DECK_NAME_SIZE add hl, bc ld d, h ld e, l @@ -9714,18 +9853,20 @@ Func_ba25: ; ba25 (2:7a25) pop hl call SafelySwitchToSRAM0 or a - jp z, .asm_ba40 + jp z, .wait_input ; invalid deck + + ; show confirmation list ld a, $1 call PlaySFXConfirmOrCancel call SafelySwitchToSRAM1 xor a - call Func_adfe + call HandleDeckMissingCardsList call SafelySwitchToSRAM0 - ld a, [wd087] + ld a, [wTempCardListVisibleOffset] ld [wCardListVisibleOffset], a - call Func_bb97 - ld a, [wd086] - jp Func_ba25 + call .InitAutoDeckMenu + ld a, [wTempDeckMachineCursorPos] + jp .please_select_deck .MenuParameters db 1, 2 ; cursor x, cursor y @@ -9734,15 +9875,14 @@ Func_ba25: ; ba25 (2:7a25) db SYM_CURSOR_R ; cursor tile number db SYM_SPACE ; tile behind cursor dw NULL ; function pointer if non-0 -; 0xbb76 -Data_bb76: ; bb76 (2:7b76) +.DeckMachineMenuData textitem 2, 14, BuildADeckText textitem 12, 14, CancelText textitem 2, 16, ReadTheInstructionsText db $ff -Data_bb83: ; bb83 (2:7b83) +.DeckMachineTitleTextList tx FightingMachineText tx RockMachineText tx WaterMachineText @@ -9754,7 +9894,10 @@ Data_bb83: ; bb83 (2:7b83) tx AutoMachineText tx LegendaryMachineText -Func_bb97: ; bb97 (2:7b97) +; clears screen, loads the proper tiles +; prints the Auto Deck title and deck entries +; and creates the auto deck configurations +.InitAutoDeckMenu call Set_OBJ_8x8 xor a ld [wTileMapFill], a @@ -9772,26 +9915,27 @@ Func_bb97: ; bb97 (2:7b97) call DrawRegularTextBox ld de, $100 call InitTextPrinting - ld hl, wd0a2 + ld hl, wDeckMachineTitleText ld a, [hli] ld h, [hl] ld l, a call ProcessTextFromID call SafelySwitchToSRAM1 - farcall Func_1ba14 - call Func_bbe4 - call Func_b3e5 + farcall ReadAutoDeckConfiguration + call .CreateAutoDeckPointerList + call PrintVisibleDeckMachineEntries call SafelySwitchToSRAM0 call EnableLCD ret -; 0xbbe4 -Func_bbe4: ; bbe4 (2:7be4) +; writes to wMachineDeckPtrs the pointers +; to the Auto Decks in sAutoDecks +.CreateAutoDeckPointerList ld a, 2 * NUM_DECK_MACHINE_SLOTS ld hl, wMachineDeckPtrs call ClearNBytesFromHL ld de, wMachineDeckPtrs - ld hl, sSavedDecks + ld hl, sAutoDecks ld bc, DECK_STRUCT_SIZE ld a, NUM_DECK_MACHINE_SLOTS .loop @@ -9813,25 +9957,25 @@ Func_bc04: ; bc04 (2:7c04) xor a ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText - ld hl, wd0a2 + ld hl, wDeckMachineTitleText ld [hl], e inc hl ld [hl], d - call Func_b379 + call ClearScreenAndDrawDeckMachineScreen ld a, DECK_SIZE - ld [wd0a5], a + ld [wNumDeckMachineEntries], a xor a .asm_bc1a - ld hl, Data_b6fb + ld hl, DeckMachineSelectionParams call InitCardSelectionParams - call Func_b704 + call DrawListScrollArrows call PrintNumSavedDecks ldtx hl, PleaseChooseADeckConfigurationToSendText call DrawWideTextBox_PrintText ldtx de, PleaseChooseADeckConfigurationToSendText - call Func_b285 + call InitDeckMachineDrawingParams .asm_bc32 - call Func_b29f + call HandleDeckMachineSelection jr c, .asm_bc1a cp $ff jr nz, .asm_bc3f @@ -9842,8 +9986,8 @@ Func_bc04: ; bc04 (2:7c04) ld b, a ld a, [wCardListVisibleOffset] add b - ld [wd088], a - call Func_b35b + ld [wSelectedDeckMachineEntry], a + call CheckIfSelectedDeckMachineEntryIsEmpty jr c, .asm_bc32 call GetSelectedSavedDeckPtr @@ -9875,24 +10019,24 @@ Func_bc7a: ; bc7a (2:7c7a) xor a ld [wCardListVisibleOffset], a ldtx de, DeckSaveMachineText - ld hl, wd0a2 + ld hl, wDeckMachineTitleText ld [hl], e inc hl ld [hl], d - call Func_b379 + call ClearScreenAndDrawDeckMachineScreen ld a, DECK_SIZE - ld [wd0a5], a + ld [wNumDeckMachineEntries], a xor a .asm_bc90 - ld hl, Data_b6fb + ld hl, DeckMachineSelectionParams call InitCardSelectionParams - call Func_b704 + call DrawListScrollArrows call PrintNumSavedDecks ldtx hl, PleaseChooseASaveSlotText call DrawWideTextBox_PrintText ldtx de, PleaseChooseASaveSlotText - call Func_b285 - call Func_b29f + call InitDeckMachineDrawingParams + call HandleDeckMachineSelection jr c, .asm_bc90 cp $ff jr nz, .asm_bcb5 @@ -9903,8 +10047,8 @@ Func_bc7a: ; bc7a (2:7c7a) ld b, a ld a, [wCardListVisibleOffset] add b - ld [wd088], a - call Func_b35b + ld [wSelectedDeckMachineEntry], a + call CheckIfSelectedDeckMachineEntryIsEmpty jr nc, .asm_bcc4 jr .asm_bcd1 .asm_bcc4 @@ -9926,11 +10070,11 @@ Func_bc7a: ; bc7a (2:7c7a) call CopyNBytesFromHLToDE call DisableSRAM call SaveGame - call Func_b379 + call ClearScreenAndDrawDeckMachineScreen ld a, [wCardListCursorPos] - ld hl, Data_b6fb + ld hl, DeckMachineSelectionParams call InitCardSelectionParams - call Func_b704 + call DrawListScrollArrows call PrintNumSavedDecks call DrawListCursor_Visible ld hl, wNameBuffer diff --git a/src/engine/bank03.asm b/src/engine/bank03.asm index 5a9b86f..75e3081 100644 --- a/src/engine/bank03.asm +++ b/src/engine/bank03.asm @@ -3124,11 +3124,11 @@ ScriptCommand_OpenDeckMachine: ; d336 (3:5336) or a jr z, .asm_d360 dec a - ld [wd0a9], a - farcall Func_ba04 + ld [wCurAutoDeckMachine], a + farcall HandleAutoDeckMenu jr .asm_d364 .asm_d360 - farcall Func_b19d + farcall HandleDeckSaveMachineMenu .asm_d364 call ResumeSong call Func_c2d4 diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 89d7093..467af8c 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -4925,28 +4925,32 @@ KeyboardData_Deck: ; 1b019 (6:7019) db $0e, $12, $02 db $10, $0f, $01 -; unknown data. -; needs analyze. -; (6:70d6) - INCROM $1b0d6, $1ba14 + ds 4 ; empty -Func_1ba14: ; 1ba14 (6:7a14) +INCLUDE "data/auto_deck_card_lists.asm" +INCLUDE "data/auto_deck_machines.asm" + +; writes to sAutoDecks all the deck configurations +; from the Auto Deck Machine in wCurAutoDeckMachine +ReadAutoDeckConfiguration: ; 1ba14 (6:7a14) call EnableSRAM - ld a, [wd0a9] + ld a, [wCurAutoDeckMachine] ld l, a - ld h, $1e + ld h, 6 * NUM_DECK_MACHINE_SLOTS call HtimesL - ld bc, $78e8 + ld bc, AutoDeckMachineEntries add hl, bc - ld b, $00 -.asm_7a26 - call Func_1ba4c - call Func_1ba5b - call Func_1ba7d + ld b, 0 +.loop_decks + call .GetPointerToSRAMAutoDeck + call .ReadDeckConfiguration + call .ReadDeckName + + ; store deck description text ID push hl - ld de, wd0aa + ld de, wAutoDeckMachineTextDescriptions ld h, b - ld l, $02 + ld l, 2 call HtimesL add hl, de ld d, h @@ -4959,24 +4963,27 @@ Func_1ba14: ; 1ba14 (6:7a14) ld [de], a inc b ld a, b - cp $05 - jr nz, .asm_7a26 + cp NUM_DECK_MACHINE_SLOTS + jr nz, .loop_decks call DisableSRAM ret -Func_1ba4c: ; 1ba4c (6:7a4c) +; outputs in de the saved deck with index b +.GetPointerToSRAMAutoDeck push hl ld l, b ld h, DECK_STRUCT_SIZE call HtimesL - ld de, sSavedDecks + ld de, sAutoDecks add hl, de ld d, h ld e, l pop hl ret -Func_1ba5b: ; 1ba5b (6:7a5b) +; writes the deck configuration in SRAM +; by reading the given deck card list +.ReadDeckConfiguration push hl push bc push de @@ -4985,24 +4992,24 @@ Func_1ba5b: ; 1ba5b (6:7a5b) inc hl ld d, [hl] pop hl - ld bc, $0018 + ld bc, DECK_NAME_SIZE add hl, bc -.asm_7a67 +.loop_create_deck ld a, [de] inc de - ld b, a + ld b, a ; card count or a - jr z, .asm_7a77 + jr z, .done_create_deck ld a, [de] inc de - ld c, a -.asm_7a70 + ld c, a ; card ID +.loop_card_count ld [hl], c inc hl dec b - jr nz, .asm_7a70 - jr .asm_7a67 -.asm_7a77 + jr nz, .loop_card_count + jr .loop_create_deck +.done_create_deck pop de pop bc pop hl @@ -5010,87 +5017,104 @@ Func_1ba5b: ; 1ba5b (6:7a5b) inc hl ret -Func_1ba7d: ; 1ba7d (6:7a7d) +.ReadDeckName push hl push bc push de ld a, [hli] ld h, [hl] ld l, a - ld de, wd089 + ld de, wDismantledDeckName call CopyText pop hl - ld de, wd089 -.asm_7a8d + ld de, wDismantledDeckName +.loop_copy_name ld a, [de] ld [hli], a or a - jr z, .asm_7a95 + jr z, .done_copy_name inc de - jr .asm_7a8d -.asm_7a95 + jr .loop_copy_name +.done_copy_name pop bc pop hl inc hl inc hl ret -; farcall from 0xb87e(2:787d): [EF|06|9A|7A] -Func_1ba9a: ; 1ba9a (6:7a9a) +; tries out all combinations of dismantling the player's decks +; in order to build the deck in wSelectedDeckMachineEntry +; if none of the combinations work, return carry set +; otherwise, return in a which deck flags should be dismantled +CheckWhichDecksToDismantleToBuildSavedDeck: ; 1ba9a (6:7a9a) xor a - ld [wd0a6], a - ld a, $01 -.asm_7aa0 - call Func_1bae4 + ld [wDecksToBeDismantled], a + +; first check if it can be built by +; only dismantling a single deck + ld a, DECK_1 +.loop_single_built_decks + call .CheckIfCanBuild ret nc - sla a - cp $10 - jr z, .asm_7aac - jr .asm_7aa0 -.asm_7aac - ld a, $03 - call Func_1bae4 + sla a ; next deck + cp (1 << NUM_DECKS) + jr z, .two_deck_combinations + jr .loop_single_built_decks + +.two_deck_combinations +; next check all two deck combinations + ld a, DECK_1 | DECK_2 + call .CheckIfCanBuild ret nc - ld a, $05 - call Func_1bae4 + ld a, DECK_1 | DECK_3 + call .CheckIfCanBuild ret nc - ld a, $09 - call Func_1bae4 + ld a, DECK_1 | DECK_4 + call .CheckIfCanBuild ret nc - ld a, $06 - call Func_1bae4 + ld a, DECK_2 | DECK_3 + call .CheckIfCanBuild ret nc - ld a, $0a - call Func_1bae4 + ld a, DECK_2 | DECK_4 + call .CheckIfCanBuild ret nc - ld a, $0c - call Func_1bae4 + ld a, DECK_3 | DECK_4 + call .CheckIfCanBuild ret nc - ld a, $f7 -.asm_7ad2 - call Func_1bae4 + +; all but one deck combinations + ld a, $ff ^ DECK_4 +.loop_three_deck_combinations + call .CheckIfCanBuild ret nc sra a cp $ff - jr z, .asm_7ade - jr .asm_7ad2 -.asm_7ade - call Func_1bae4 + jr z, .all_decks + jr .loop_three_deck_combinations + +.all_decks +; finally check if can be built by dismantling all decks + call .CheckIfCanBuild ret nc + +; none of the combinations work scf ret -Func_1bae4: ; 1bae4 (6:7ae4) +; returns cary if wSelectedDeckMachineEntry cannot be built +; by dismantling the decks given by register a +; a = DECK_* flags +.CheckIfCanBuild push af - ld hl, wd088 + ld hl, wSelectedDeckMachineEntry ld b, [hl] farcall CheckIfCanBuildSavedDeck - jr c, .asm_7af5 + jr c, .cannot_build pop af - ld [wd0a6], a + ld [wDecksToBeDismantled], a or a ret -.asm_7af5 +.cannot_build pop af scf ret diff --git a/src/sram.asm b/src/sram.asm index a26c7b5..3b2b83c 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -44,6 +44,7 @@ sPlayerName:: ; a010 sCardCollection:: ; a100 ds $100 +sBuiltDecks:: sDeck1:: deck_struct sDeck1 ; a200 sDeck2:: deck_struct sDeck2 ; a254 sDeck3:: deck_struct sDeck3 ; a2a8 @@ -257,6 +258,8 @@ sCardPopNameList:: ; bb00 SECTION "SRAM1", SRAM +UNION + ; buffers used to temporary store gfx related data ; such as tiles or BG maps sGfxBuffer0:: ; a000 @@ -277,6 +280,25 @@ sGfxBuffer4:: ; b000 sGfxBuffer5:: ; b400 ds $400 +NEXTU + + ds $350 + +; buffer used to store the deck configuration +; from the Auto Deck Machines +; intentionally uses the same address as sSavedDecks +; since TryBuildDeckMachineDeck uses the same +; address in SRAM whether it's an auto deck or a saved deck +; the difference is whether SRAM0 or SRAM1 are loaded +sAutoDecks:: +sAutoDeck1:: deck_struct sAutoDeck1 ; a350 +sAutoDeck2:: deck_struct sAutoDeck2 ; a3a4 +sAutoDeck3:: deck_struct sAutoDeck3 ; a3f8 +sAutoDeck4:: deck_struct sAutoDeck4 ; a44c +sAutoDeck5:: deck_struct sAutoDeck5 ; a4a0 + +ENDU + SECTION "SRAM2", SRAM ds $18fe diff --git a/src/text/text3.asm b/src/text/text3.asm index bf23e60..ffe0f59 100644 --- a/src/text/text3.asm +++ b/src/text/text3.asm @@ -34,7 +34,7 @@ PrintThisCardYesNoText: ; 3c0cc (f:40cc) line " Yes No" done -Text0275: ; 3c0ef (f:40ef) +PleaseChooseDeckConfigurationToPrintText: ; 3c0ef (f:40ef) text "Please choose a Deck configuration" line "to print." done @@ -169,452 +169,452 @@ LegendaryMachineText: ; 3c4cb (f:44cb) text " Legendary Machine " done -Text0292: ; 3c4e3 (f:44e3) +AllFightingPokemonText: ; 3c4e3 (f:44e3) text "All Fighting Pokémon" done -Text0293: ; 3c4f9 (f:44f9) +BenchAttackText: ; 3c4f9 (f:44f9) text "Bench Attack" done -Text0294: ; 3c507 (f:4507) +BattleContestText: ; 3c507 (f:4507) text "Battle Contest" done -Text0295: ; 3c517 (f:4517) +HeatedBattleText: ; 3c517 (f:4517) text "Heated Battle" done -Text0296: ; 3c526 (f:4526) +FirstStrikeText: ; 3c526 (f:4526) text "First-Strike" done -Text0297: ; 3c534 (f:4534) +SqueakingMouseText: ; 3c534 (f:4534) text "Squeaking Mouse" done -Text0298: ; 3c545 (f:4545) +GreatQuakeText: ; 3c545 (f:4545) text "Great Quake" done -Text0299: ; 3c552 (f:4552) +BoneAttackText: ; 3c552 (f:4552) text "Bone Attack" done -Text029a: ; 3c55f (f:455f) +ExcavationText: ; 3c55f (f:455f) text "Excavation" done -Text029b: ; 3c56b (f:456b) +RockCrusherText: ; 3c56b (f:456b) text "Rock Crusher" done -Text029c: ; 3c579 (f:4579) +BlueWaterText: ; 3c579 (f:4579) text "Blue Water" done -Text029d: ; 3c585 (f:4585) +OnTheBeachText: ; 3c585 (f:4585) text "On the Beach" done -Text029e: ; 3c593 (f:4593) +ParalyzeText: ; 3c593 (f:4593) text "Paralyze!" done -Text029f: ; 3c59e (f:459e) +EnergyRemovalText: ; 3c59e (f:459e) text "Energy Removal" done -Text02a0: ; 3c5ae (f:45ae) +RainDancerText: ; 3c5ae (f:45ae) text "Rain Dancer" done -Text02a1: ; 3c5bb (f:45bb) +CutePokemonText: ; 3c5bb (f:45bb) text "Cute Pokémon" done -Text02a2: ; 3c5c9 (f:45c9) +PokemonFluteText: ; 3c5c9 (f:45c9) text "Pokémon Flute" done -Text02a3: ; 3c5d8 (f:45d8) +YellowFlashText: ; 3c5d8 (f:45d8) text "Yellow Flash" done -Text02a4: ; 3c5e6 (f:45e6) +ElectricShockText: ; 3c5e6 (f:45e6) text "Electric Shock" done -Text02a5: ; 3c5f6 (f:45f6) +ZappingSelfdestructText: ; 3c5f6 (f:45f6) text "Zapping Selfdestruct" done -Text02a6: ; 3c60c (f:460c) +InsectCollectionText: ; 3c60c (f:460c) text "Insect Collection" done -Text02a7: ; 3c61f (f:461f) +JungleText: ; 3c61f (f:461f) text "Jungle" done -Text02a8: ; 3c627 (f:4627) +FlowerGardenText: ; 3c627 (f:4627) text "Flower Garden" done -Text02a9: ; 3c636 (f:4636) +KaleidoscopeText: ; 3c636 (f:4636) text "Kaleidoscope" done -Text02aa: ; 3c644 (f:4644) +FlowerPowerText: ; 3c644 (f:4644) text "Flower Power" done -Text02ab: ; 3c652 (f:4652) +PsychicPowerText: ; 3c652 (f:4652) text "Psychic Power" done -Text02ac: ; 3c661 (f:4661) +DreamEaterHaunterText: ; 3c661 (f:4661) text "Dream Eater Haunter" done -Text02ad: ; 3c676 (f:4676) +ScavengingSlowbroText: ; 3c676 (f:4676) text "Scavenging Slowbro" done -Text02ae: ; 3c68a (f:468a) +StrangePowerText: ; 3c68a (f:468a) text "Strange Power" done -Text02af: ; 3c699 (f:4699) +StrangePsyshockText: ; 3c699 (f:4699) text "Strange Psyshock" done -Text02b0: ; 3c6ab (f:46ab) +LovelyNidoranText: ; 3c6ab (f:46ab) text "Lovely Nidoran" done -Text02b1: ; 3c6bb (f:46bb) +ScienceCorpsText: ; 3c6bb (f:46bb) text "Science Corps" done -Text02b2: ; 3c6ca (f:46ca) +FlyinPokemonText: ; 3c6ca (f:46ca) text "Flyin' Pokémon" done -Text02b3: ; 3c6da (f:46da) +PoisonText: ; 3c6da (f:46da) text "Poison" done -Text02b4: ; 3c6e2 (f:46e2) +WondersOfScienceText: ; 3c6e2 (f:46e2) text "Wonders of Science" done -Text02b5: ; 3c6f6 (f:46f6) +ReplaceEmAllText: ; 3c6f6 (f:46f6) text "Replace 'Em All" done -Text02b6: ; 3c707 (f:4707) +ChariSaurText: ; 3c707 (f:4707) text "Chari-Saur" done -Text02b7: ; 3c713 (f:4713) +TrafficLightText: ; 3c713 (f:4713) text "Traffic Light" done -Text02b8: ; 3c722 (f:4722) +FirePokemonDeckText: ; 3c722 (f:4722) text "Fire Pokémon" done -Text02b9: ; 3c730 (f:4730) +FireChargeText: ; 3c730 (f:4730) text "Fire Charge" done -Text02ba: ; 3c73d (f:473d) +CharmanderAndFriendsText: ; 3c73d (f:473d) text "Charmander & Friends" done -Text02bb: ; 3c753 (f:4753) +SquirtleAndFriendsText: ; 3c753 (f:4753) text "Squirtle & Friends" done -Text02bc: ; 3c767 (f:4767) +BulbasaurAndFriendsText: ; 3c767 (f:4767) text "Bulbasaur & Friends" done -Text02bd: ; 3c77c (f:477c) +PsychicMachampText: ; 3c77c (f:477c) text "Psychic Machamp" done -Text02be: ; 3c78d (f:478d) +WaterBeetleText: ; 3c78d (f:478d) text "Water Beetle" done -Text02bf: ; 3c79b (f:479b) +LegendaryMoltresText: ; 3c79b (f:479b) text "Legendary Moltres" done -Text02c0: ; 3c7ae (f:47ae) +LegendaryZapdosText: ; 3c7ae (f:47ae) text "Legendary Zapdos" done -Text02c1: ; 3c7c0 (f:47c0) +LegendaryArticunoText: ; 3c7c0 (f:47c0) text "Legendary Articuno" done -Text02c2: ; 3c7d4 (f:47d4) +LegendaryDragoniteText: ; 3c7d4 (f:47d4) text "Legendary Dragonite" done -Text02c3: ; 3c7e9 (f:47e9) +MysteriousPokemonText: ; 3c7e9 (f:47e9) text "Mysterious Pokémon" done -Text02c4: ; 3c7fd (f:47fd) +AllFightingPokemonDescriptionText: ; 3c7fd (f:47fd) text "A Deck of Fighting Pokémon:" line "Feel their Fighting power!" done -Text02c5: ; 3c835 (f:4835) +BenchAttackDescriptionText: ; 3c835 (f:4835) text "A Deck of Pokémon that can" line "attack the Bench." done -Text02c6: ; 3c863 (f:4863) +BattleContestDescriptionText: ; 3c863 (f:4863) text "A Deck which uses Fighting Attacks" line "such as Slash and Punch." done -Text02c7: ; 3c8a0 (f:48a0) +HeatedBattleDescriptionText: ; 3c8a0 (f:48a0) text "A powerful Deck with both Fire" line "and Fighting Pokémon." done -Text02c8: ; 3c8d6 (f:48d6) +FirstStrikeDescriptionText: ; 3c8d6 (f:48d6) text "A Deck for fast and furious " line "attacks." done -Text02c9: ; 3c8fd (f:48fd) +SqueakingMouseDescriptionText: ; 3c8fd (f:48fd) text "A Deck made of Mouse Pokémon." line "Uses PlusPower to Power up!" done -Text02ca: ; 3c938 (f:4938) +GreatQuakeDescriptionText: ; 3c938 (f:4938) text "Use Dugtrio's Earthquake" line "to cause great damage." done -Text02cb: ; 3c969 (f:4969) +BoneAttackDescriptionText: ; 3c969 (f:4969) text "A Deck of Cubone and Marowak - " line "A call for help." done -Text02cc: ; 3c99b (f:499b) +ExcavationDescriptionText: ; 3c99b (f:499b) text "A Deck which creates Pokémon by" line "evolving Mysterious Fossils." done -Text02cd: ; 3c9d9 (f:49d9) +RockCrusherDescriptionText: ; 3c9d9 (f:49d9) text "A Deck of Rock Pokémon. It's" line "Strong against Lightning Pokémon." done -Text02ce: ; 3ca19 (f:4a19) +BlueWaterDescriptionText: ; 3ca19 (f:4a19) text "A Deck of Water Pokémon: Their" line "Blue Horror washes over enemies." done -Text02cf: ; 3ca5a (f:4a5a) +OnTheBeachDescriptionText: ; 3ca5a (f:4a5a) text "A well balanced Deck" line "of Sandshrew and Water Pokémon!" done -Text02d0: ; 3ca90 (f:4a90) +ParalyzeDescriptionText: ; 3ca90 (f:4a90) text "Paralyze the opponent's Pokémon:" line "Stop 'em and drop 'em!" done -Text02d1: ; 3cac9 (f:4ac9) +EnergyRemovalDescriptionText: ; 3cac9 (f:4ac9) text "Uses Whirlpool and Hyper Beam to" line "remove opponents' Energy cards." done -Text02d2: ; 3cb0b (f:4b0b) +RainDancerDescriptionText: ; 3cb0b (f:4b0b) text "Use Rain Dance to attach Water" line "Energy for powerful Attacks!" done -Text02d3: ; 3cb48 (f:4b48) +CutePokemonDescriptionText: ; 3cb48 (f:4b48) text "A Deck of cute Pokémon such as" line "Pikachu and Eevee." done -Text02d4: ; 3cb7b (f:4b7b) +PokemonFluteDescriptionText: ; 3cb7b (f:4b7b) text "Use the Pokémon Flute to revive" line "opponents' Pokémon and Attack!" done -Text02d5: ; 3cbbb (f:4bbb) +YellowFlashDescriptionText: ; 3cbbb (f:4bbb) text "A deck of Pokémon that use Lightning" line "Energy to zap opponents." done -Text02d6: ; 3cbfa (f:4bfa) +ElectricShockDescriptionText: ; 3cbfa (f:4bfa) text "A Deck which Shocks and Paralyzes" line "opponents with its Attacks." done -Text02d7: ; 3cc39 (f:4c39) +ZappingSelfdestructDescriptionText: ; 3cc39 (f:4c39) text "Selfdestruct causes great damage " line "- even to the opponent's Bench." done -Text02d8: ; 3cc7c (f:4c7c) +InsectCollectionDescriptionText: ; 3cc7c (f:4c7c) text "A Deck made of Insect Pokémon" line "Go Bug Power!" done -Text02d9: ; 3cca9 (f:4ca9) +JungleDescriptionText: ; 3cca9 (f:4ca9) text "A Deck of Grass Pokémon: There " line "are many dangers in the Jungle." done -Text02da: ; 3ccea (f:4cea) +FlowerGardenDescriptionText: ; 3ccea (f:4cea) text "A Deck of Flower Pokémon:" line "Beautiful but Dangerous" done -Text02db: ; 3cd1d (f:4d1d) +KaleidoscopeDescriptionText: ; 3cd1d (f:4d1d) text "Uses Venomoth's Pokémon Power to" line "change the opponent's Weakness." done -Text02dc: ; 3cd5f (f:4d5f) +FlowerPowerDescriptionText: ; 3cd5f (f:4d5f) text "A powerful Big Eggsplosion " line "and Energy Transfer combo!" done -Text02dd: ; 3cd97 (f:4d97) +PsychicPowerDescriptionText: ; 3cd97 (f:4d97) text "Use the Psychic power of the" line "Psychic Pokémon to Attack!" done -Text02de: ; 3cdd0 (f:4dd0) +DreamEaterHaunterDescriptionText: ; 3cdd0 (f:4dd0) text "Uses Haunter's Dream Eater" line "to cause great damage!" done -Text02df: ; 3ce03 (f:4e03) +ScavengingSlowbroDescriptionText: ; 3ce03 (f:4e03) text "Continually draw Trainer " line "Cards from the Discard Pile!" done -Text02e0: ; 3ce3b (f:4e3b) +StrangePowerDescriptionText: ; 3ce3b (f:4e3b) text "Confuse opponents with" line "mysterious power!" done -Text02e1: ; 3ce65 (f:4e65) +StrangePsyshockDescriptionText: ; 3ce65 (f:4e65) text "Use Alakazam's Damage Swap" line "to move damage counters!" done -Text02e2: ; 3ce9a (f:4e9a) +LovelyNidoranDescriptionText: ; 3ce9a (f:4e9a) text "Uses Nidoqueen's Boyfriends to cause" line "great damage to the opponent." done -Text02e3: ; 3cede (f:4ede) +ScienceCorpsDescriptionText: ; 3cede (f:4ede) text "The march of the Science Corps!" line "Attack with the power of science!" done -Text02e4: ; 3cf21 (f:4f21) +FlyinPokemonDescriptionText: ; 3cf21 (f:4f21) text "Pokémon with feathers flock " line "together! Retreating is easy!" done -Text02e5: ; 3cf5d (f:4f5d) +PoisonDescriptionText: ; 3cf5d (f:4f5d) text "A Deck that uses Poison to " line "slowly Knock Out the opponent." done -Text02e6: ; 3cf99 (f:4f99) +WondersOfScienceDescriptionText: ; 3cf99 (f:4f99) text "Block Pokémon Powers with " line "Muk and attack with Mewtwo!" done -Text02e7: ; 3cfd1 (f:4fd1) +ReplaceEmAllDescriptionText: ; 3cfd1 (f:4fd1) text "A Deck that shuffles" line "the opponent's cards" done -Text02e8: ; 3cffc (f:4ffc) +ChariSaurDescriptionText: ; 3cffc (f:4ffc) text "Attack with Charizard - with " line "just a few Fire Energy cards!" done -Text02e9: ; 3d039 (f:5039) +TrafficLightDescriptionText: ; 3d039 (f:5039) text "Pokémon that can Attack with" line "Fire, Water or Lightning Energy!" done -Text02ea: ; 3d078 (f:5078) +FirePokemonDescriptionText: ; 3d078 (f:5078) text "With Fire Pokémon like Charizard, " line "Rapidash and Magmar, it's hot!" done -Text02eb: ; 3d0bb (f:50bb) +FireChargeDescriptionText: ; 3d0bb (f:50bb) text "Desperate attacks Damage your " line "opponent and you!" done -Text02ec: ; 3d0ed (f:50ed) +CharmanderAndFriendsDescriptionText: ; 3d0ed (f:50ed) text "A Fire, Grass and Water Deck:" line "Charmander, Pinsir and Seel" done -Text02ed: ; 3d128 (f:5128) +SquirtleAndFriendsDescriptionText: ; 3d128 (f:5128) text "A Water, Fire, and Lightning Deck:" line "Squirtle, Charmander and Pikachu" done -Text02ee: ; 3d16d (f:516d) +BulbasaurAndFriendsDescriptionText: ; 3d16d (f:516d) text "A Grass, Lightning and Psychic Deck:" line "Bulbasaur, Pikachu and Abra" done -Text02ef: ; 3d1af (f:51af) +PsychicMachampDescriptionText: ; 3d1af (f:51af) text "Machamp, Hitmonlee, Hitmonchan" line "Gengar and Alakazam are furious!" done -Text02f0: ; 3d1f0 (f:51f0) +WaterBeetleDescriptionText: ; 3d1f0 (f:51f0) text "An Evolution Deck with Weedle, " line "Nidoran♂ and Bellsprout." done -Text02f1: ; 3d22a (f:522a) +LegendaryMoltresDescriptionText: ; 3d22a (f:522a) text "Gather Fire Energy with the" line "Legendary Moltres!" done -Text02f2: ; 3d25a (f:525a) +LegendaryZapdosDescriptionText: ; 3d25a (f:525a) text "Zap opponents with the" line "Legandary Zapdos!" done -Text02f3: ; 3d284 (f:5284) +LegendaryArticunoDescriptionText: ; 3d284 (f:5284) text "Paralyze opponents with the" line "Legendary Articuno!" done -Text02f4: ; 3d2b5 (f:52b5) +LegendaryDragoniteDescriptionText: ; 3d2b5 (f:52b5) text "Heal your Pokémon with the" line "Legendary Dragonite!" done -Text02f5: ; 3d2e6 (f:52e6) +MysteriousPokemonDescriptionText: ; 3d2e6 (f:52e6) text "A very special Deck made of" line "very rare Pokémon cards!" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 9f50d9d..b9d2561 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -630,7 +630,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer OKIfFileDeletedText ; 0x0272 textpointer ReadTheInstructionsText ; 0x0273 textpointer PrintThisCardYesNoText ; 0x0274 - textpointer Text0275 ; 0x0275 + textpointer PleaseChooseDeckConfigurationToPrintText ; 0x0275 textpointer PrintThisDeckText ; 0x0276 textpointer Text0277 ; 0x0277 textpointer PrintMenuItemsText ; 0x0278 @@ -659,106 +659,106 @@ TextOffsets:: ; 34000 (d:4000) textpointer FireMachineText ; 0x028f textpointer AutoMachineText ; 0x0290 textpointer LegendaryMachineText ; 0x0291 - textpointer Text0292 ; 0x0292 - textpointer Text0293 ; 0x0293 - textpointer Text0294 ; 0x0294 - textpointer Text0295 ; 0x0295 - textpointer Text0296 ; 0x0296 - textpointer Text0297 ; 0x0297 - textpointer Text0298 ; 0x0298 - textpointer Text0299 ; 0x0299 - textpointer Text029a ; 0x029a - textpointer Text029b ; 0x029b - textpointer Text029c ; 0x029c - textpointer Text029d ; 0x029d - textpointer Text029e ; 0x029e - textpointer Text029f ; 0x029f - textpointer Text02a0 ; 0x02a0 - textpointer Text02a1 ; 0x02a1 - textpointer Text02a2 ; 0x02a2 - textpointer Text02a3 ; 0x02a3 - textpointer Text02a4 ; 0x02a4 - textpointer Text02a5 ; 0x02a5 - textpointer Text02a6 ; 0x02a6 - textpointer Text02a7 ; 0x02a7 - textpointer Text02a8 ; 0x02a8 - textpointer Text02a9 ; 0x02a9 - textpointer Text02aa ; 0x02aa - textpointer Text02ab ; 0x02ab - textpointer Text02ac ; 0x02ac - textpointer Text02ad ; 0x02ad - textpointer Text02ae ; 0x02ae - textpointer Text02af ; 0x02af - textpointer Text02b0 ; 0x02b0 - textpointer Text02b1 ; 0x02b1 - textpointer Text02b2 ; 0x02b2 - textpointer Text02b3 ; 0x02b3 - textpointer Text02b4 ; 0x02b4 - textpointer Text02b5 ; 0x02b5 - textpointer Text02b6 ; 0x02b6 - textpointer Text02b7 ; 0x02b7 - textpointer Text02b8 ; 0x02b8 - textpointer Text02b9 ; 0x02b9 - textpointer Text02ba ; 0x02ba - textpointer Text02bb ; 0x02bb - textpointer Text02bc ; 0x02bc - textpointer Text02bd ; 0x02bd - textpointer Text02be ; 0x02be - textpointer Text02bf ; 0x02bf - textpointer Text02c0 ; 0x02c0 - textpointer Text02c1 ; 0x02c1 - textpointer Text02c2 ; 0x02c2 - textpointer Text02c3 ; 0x02c3 - textpointer Text02c4 ; 0x02c4 - textpointer Text02c5 ; 0x02c5 - textpointer Text02c6 ; 0x02c6 - textpointer Text02c7 ; 0x02c7 - textpointer Text02c8 ; 0x02c8 - textpointer Text02c9 ; 0x02c9 - textpointer Text02ca ; 0x02ca - textpointer Text02cb ; 0x02cb - textpointer Text02cc ; 0x02cc - textpointer Text02cd ; 0x02cd - textpointer Text02ce ; 0x02ce - textpointer Text02cf ; 0x02cf - textpointer Text02d0 ; 0x02d0 - textpointer Text02d1 ; 0x02d1 - textpointer Text02d2 ; 0x02d2 - textpointer Text02d3 ; 0x02d3 - textpointer Text02d4 ; 0x02d4 - textpointer Text02d5 ; 0x02d5 - textpointer Text02d6 ; 0x02d6 - textpointer Text02d7 ; 0x02d7 - textpointer Text02d8 ; 0x02d8 - textpointer Text02d9 ; 0x02d9 - textpointer Text02da ; 0x02da - textpointer Text02db ; 0x02db - textpointer Text02dc ; 0x02dc - textpointer Text02dd ; 0x02dd - textpointer Text02de ; 0x02de - textpointer Text02df ; 0x02df - textpointer Text02e0 ; 0x02e0 - textpointer Text02e1 ; 0x02e1 - textpointer Text02e2 ; 0x02e2 - textpointer Text02e3 ; 0x02e3 - textpointer Text02e4 ; 0x02e4 - textpointer Text02e5 ; 0x02e5 - textpointer Text02e6 ; 0x02e6 - textpointer Text02e7 ; 0x02e7 - textpointer Text02e8 ; 0x02e8 - textpointer Text02e9 ; 0x02e9 - textpointer Text02ea ; 0x02ea - textpointer Text02eb ; 0x02eb - textpointer Text02ec ; 0x02ec - textpointer Text02ed ; 0x02ed - textpointer Text02ee ; 0x02ee - textpointer Text02ef ; 0x02ef - textpointer Text02f0 ; 0x02f0 - textpointer Text02f1 ; 0x02f1 - textpointer Text02f2 ; 0x02f2 - textpointer Text02f3 ; 0x02f3 - textpointer Text02f4 ; 0x02f4 - textpointer Text02f5 ; 0x02f5 + textpointer AllFightingPokemonText ; 0x0292 + textpointer BenchAttackText ; 0x0293 + textpointer BattleContestText ; 0x0294 + textpointer HeatedBattleText ; 0x0295 + textpointer FirstStrikeText ; 0x0296 + textpointer SqueakingMouseText ; 0x0297 + textpointer GreatQuakeText ; 0x0298 + textpointer BoneAttackText ; 0x0299 + textpointer ExcavationText ; 0x029a + textpointer RockCrusherText ; 0x029b + textpointer BlueWaterText ; 0x029c + textpointer OnTheBeachText ; 0x029d + textpointer ParalyzeText ; 0x029e + textpointer EnergyRemovalText ; 0x029f + textpointer RainDancerText ; 0x02a0 + textpointer CutePokemonText ; 0x02a1 + textpointer PokemonFluteText ; 0x02a2 + textpointer YellowFlashText ; 0x02a3 + textpointer ElectricShockText ; 0x02a4 + textpointer ZappingSelfdestructText ; 0x02a5 + textpointer InsectCollectionText ; 0x02a6 + textpointer JungleText ; 0x02a7 + textpointer FlowerGardenText ; 0x02a8 + textpointer KaleidoscopeText ; 0x02a9 + textpointer FlowerPowerText ; 0x02aa + textpointer PsychicPowerText ; 0x02ab + textpointer DreamEaterHaunterText ; 0x02ac + textpointer ScavengingSlowbroText ; 0x02ad + textpointer StrangePowerText ; 0x02ae + textpointer StrangePsyshockText ; 0x02af + textpointer LovelyNidoranText ; 0x02b0 + textpointer ScienceCorpsText ; 0x02b1 + textpointer FlyinPokemonText ; 0x02b2 + textpointer PoisonText ; 0x02b3 + textpointer WondersOfScienceText ; 0x02b4 + textpointer ReplaceEmAllText ; 0x02b5 + textpointer ChariSaurText ; 0x02b6 + textpointer TrafficLightText ; 0x02b7 + textpointer FirePokemonDeckText ; 0x02b8 + textpointer FireChargeText ; 0x02b9 + textpointer CharmanderAndFriendsText ; 0x02ba + textpointer SquirtleAndFriendsText ; 0x02bb + textpointer BulbasaurAndFriendsText ; 0x02bc + textpointer PsychicMachampText ; 0x02bd + textpointer WaterBeetleText ; 0x02be + textpointer LegendaryMoltresText ; 0x02bf + textpointer LegendaryZapdosText ; 0x02c0 + textpointer LegendaryArticunoText ; 0x02c1 + textpointer LegendaryDragoniteText ; 0x02c2 + textpointer MysteriousPokemonText ; 0x02c3 + textpointer AllFightingPokemonDescriptionText ; 0x02c4 + textpointer BenchAttackDescriptionText ; 0x02c5 + textpointer BattleContestDescriptionText ; 0x02c6 + textpointer HeatedBattleDescriptionText ; 0x02c7 + textpointer FirstStrikeDescriptionText ; 0x02c8 + textpointer SqueakingMouseDescriptionText ; 0x02c9 + textpointer GreatQuakeDescriptionText ; 0x02ca + textpointer BoneAttackDescriptionText ; 0x02cb + textpointer ExcavationDescriptionText ; 0x02cc + textpointer RockCrusherDescriptionText ; 0x02cd + textpointer BlueWaterDescriptionText ; 0x02ce + textpointer OnTheBeachDescriptionText ; 0x02cf + textpointer ParalyzeDescriptionText ; 0x02d0 + textpointer EnergyRemovalDescriptionText ; 0x02d1 + textpointer RainDancerDescriptionText ; 0x02d2 + textpointer CutePokemonDescriptionText ; 0x02d3 + textpointer PokemonFluteDescriptionText ; 0x02d4 + textpointer YellowFlashDescriptionText ; 0x02d5 + textpointer ElectricShockDescriptionText ; 0x02d6 + textpointer ZappingSelfdestructDescriptionText ; 0x02d7 + textpointer InsectCollectionDescriptionText ; 0x02d8 + textpointer JungleDescriptionText ; 0x02d9 + textpointer FlowerGardenDescriptionText ; 0x02da + textpointer KaleidoscopeDescriptionText ; 0x02db + textpointer FlowerPowerDescriptionText ; 0x02dc + textpointer PsychicPowerDescriptionText ; 0x02dd + textpointer DreamEaterHaunterDescriptionText ; 0x02de + textpointer ScavengingSlowbroDescriptionText ; 0x02df + textpointer StrangePowerDescriptionText ; 0x02e0 + textpointer StrangePsyshockDescriptionText ; 0x02e1 + textpointer LovelyNidoranDescriptionText ; 0x02e2 + textpointer ScienceCorpsDescriptionText ; 0x02e3 + textpointer FlyinPokemonDescriptionText ; 0x02e4 + textpointer PoisonDescriptionText ; 0x02e5 + textpointer WondersOfScienceDescriptionText ; 0x02e6 + textpointer ReplaceEmAllDescriptionText ; 0x02e7 + textpointer ChariSaurDescriptionText ; 0x02e8 + textpointer TrafficLightDescriptionText ; 0x02e9 + textpointer FirePokemonDescriptionText ; 0x02ea + textpointer FireChargeDescriptionText ; 0x02eb + textpointer CharmanderAndFriendsDescriptionText ; 0x02ec + textpointer SquirtleAndFriendsDescriptionText ; 0x02ed + textpointer BulbasaurAndFriendsDescriptionText ; 0x02ee + textpointer PsychicMachampDescriptionText ; 0x02ef + textpointer WaterBeetleDescriptionText ; 0x02f0 + textpointer LegendaryMoltresDescriptionText ; 0x02f1 + textpointer LegendaryZapdosDescriptionText ; 0x02f2 + textpointer LegendaryArticunoDescriptionText ; 0x02f3 + textpointer LegendaryDragoniteDescriptionText ; 0x02f4 + textpointer MysteriousPokemonDescriptionText ; 0x02f5 textpointer PokemonCardGlossaryText ; 0x02f6 textpointer GlossaryMenuPage1Text ; 0x02f7 textpointer GlossaryMenuPage2Text ; 0x02f8 diff --git a/src/wram.asm b/src/wram.asm index 7944c9a..621b985 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -38,6 +38,12 @@ NEXTU wCardPopNameList:: ; c000 ds CARDPOP_NAME_LIST_SIZE +NEXTU + +; buffer used to store a deck that will be built +wDeckToBuild:: ; c000 + ds DECK_STRUCT_SIZE + ENDU ds $100 @@ -1993,7 +1999,7 @@ UNION ; buffer used to show which card IDs ; are visible in a given list wVisibleListCardIDs:: ; cec4 - ds MAX_DECK_CONFIRMATION_VISIBLE_CARDS + ds NUM_DECK_CONFIRMATION_VISIBLE_CARDS NEXTU @@ -2013,7 +2019,9 @@ wNumVisibleCardListEntries:: ; cecb wTotalCardCount:: ; cecc ds $1 -wcecd:: ; cecd +; is TRUE if list cannot be scrolled down +; past the last visible entry +wUnableToScrollDown:: ; cecd ds $1 ; pointer to a function that should be called @@ -2077,6 +2085,10 @@ wCurDeckCardsTerminator:: ; cf67 ds $1 wCurDeckCardsEnd:: + +; list of all the different cards in a deck configuration +wUniqueDeckCardList:: ; cf68 + ; stores the count number of cards owned ; can be 0 in the case that a card is not available ; i.e. already inside a built deck @@ -2125,7 +2137,8 @@ wDeckConfigurationMenuTransitionTable:: ; cfd6 wCurCardListPtr:: ; cfd8 ds $2 -wcfda:: ; cfda +; text ID to print in the card confirmation screen text box +wCardConfirmationText:: ; cfda ds $2 ds $2 @@ -2206,43 +2219,52 @@ wMachineDeckPtrs:: ; d00d wNumSavedDecks:: ; d085 ds $1 -wd086:: ; d086 +; temporarily holds value of wCardListCursorPos +wTempDeckMachineCursorPos:: ; d086 ds $1 -wd087:: ; d087 +; temporarily holds value of wCardListVisibleOffset +wTempCardListVisibleOffset:: ; d087 ds $1 -wd088:: ; d088 +; which list entry was selected in the Deck Machine screen +wSelectedDeckMachineEntry:: ; d088 ds $1 -wd089:: ; d089 - ds $1 +wDismantledDeckName:: ; d089 + ds DECK_NAME_SIZE -wd08a:: ; d08a - ds $18 +; which deck slot to be used to +; build a new deck +wDeckSlotForNewDeck:: ; d0a1 + ds $1 -wd0a2:: ; d0a2 +wDeckMachineTitleText:: ; d0a2 ds $2 wTempBankSRAM:: ; d0a4 ds $1 -wd0a5:: ; d0a5 +wNumDeckMachineEntries:: ; d0a5 ds $1 -wd0a6:: ; d0a6 +; DECK_* flags to be dismantled to build a given deck +wDecksToBeDismantled:: ; d0a6 ds $1 -wd0a7:: ; d0a7 +; text ID to print in the text box when +; inside the Deck Machine menu +wDeckMachineText:: ; d0a7 ds $2 -wd0a9:: ; d0a9 +; which deck machine is being used +wCurAutoDeckMachine:: ; d0a9 ds $1 -wd0aa:: ; d0aa - ds $1 - - ds $9 +; text IDs for each deck descriptions of the +; Ato Deck Machine currently being shown +wAutoDeckMachineTextDescriptions:: ; d0aa + ds 2 * NUM_DECK_MACHINE_SLOTS wd0b4:: ; d0b4 ds $1 -- cgit v1.2.3 From 217fe0e5d7f42b31043fc03acb4d3efbd7f109a1 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Tue, 11 May 2021 16:46:46 +0100 Subject: Disassemble remaining bank 2 functions --- src/engine/bank02.asm | 138 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 134 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 46df6f6..ade91b7 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -2070,7 +2070,68 @@ _DrawPlayAreaToPlacePrizeCards: ; 8b85 (2:4b85) db 0, 2 ; 0x8bf2 - INCROM $8bf2, $8c57 +; seems like a function to draw prize cards +; given a list of coordinates in hl +; unreferenced? +; hl = pointer to coords +Func_8bf2: ; 8bf2 (2:4bf2) + push hl + ld a, [wCheckMenuPlayAreaWhichDuelist] + ld h, a + ld l, DUELVARS_PRIZES + ld a, [hl] + pop hl + + ld b, 0 + push af +.loop_prize_cards + inc b + ld a, [wDuelInitialPrizes] + inc a + cp b + jr z, .done + pop af + srl a + push af + jr c, .not_taken + ; same tile whether the prize card is taken or not + ld a, $ac + jr .got_tile +.not_taken + ld a, $ac +.got_tile + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push hl + push bc + lb hl, 0, 0 + lb bc, 1, 1 + call FillRectangle + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .skip_pal + ld a, $02 + lb bc, 1, 1 + lb hl, 0, 0 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 +.skip_pal + pop bc + pop hl + jr .loop_prize_cards +.done + pop af + ret +; 0x8c3f + +; unknown data +; unreferenced? +Data_8c3f: ; 8c3f (6:4c3f) + db $06, $05, $06, $06, $07, $05, $07, $06, $08, $05, $08, $06, $05, $0e, $05, $0d, $04, $0e, $04, $0d, $03, $0e, $03, $0d +; 0x8c57 ; gets the first prize card index that is set ; beginning from index in register a @@ -2620,7 +2681,35 @@ CheckIfCurDeckIsValid: ; 8ff2 (2:4ff2) ret ; is not valid ; 0x9001 - INCROM $9001, $9026 +; write to $d00a the decimal representation (number characters) +; of the value in hl +; unreferenced? +Func_9001: ; 9001 (2:5001) + ld de, $d00a + ld bc, -100 + call .GetNumberChar + ld bc, -10 + call .GetNumberChar + ld bc, -1 + call .GetNumberChar + ret + +.GetNumberChar + ld a, SYM_0 - 1 +.loop + inc a + add hl, bc + jr c, .loop + ld [de], a + inc de + ld a, l + sub c + ld l, a + ld a, h + sbc b + ld h, a + ret +; 0x9026 CancelDeckSelectionSubMenu: ; 9026 (2:5026) ret @@ -4979,7 +5068,25 @@ OpenCardPageFromCardList: ; 9c3f (2:5c3f) ret ; 0x9ced - INCROM $9ced, $9d0c +; opens card page from the card list +; unreferenced? +Func_9ced: ; 9ced (2:5ced) + ld hl, wVisibleListCardIDs + ld a, [wCardListCursorPos] + ld c, a + ld b, $00 + add hl, bc + ld e, [hl] + inc hl + ld d, [hl] + call LoadCardDataToBuffer1_FromCardID + ld de, $389f + call SetupText + bank1call OpenCardPage_FromHand + ld a, $01 + ld [wVBlankOAMCopyToggle], a + ret +; 0x9d0c ; adds card in register e to deck configuration ; and updates the values shown for its count @@ -8916,7 +9023,30 @@ PrintNumSavedDecks: ; b545 (2:7545) ret ; 0xb568 - INCROM $b568, $b592 +; prints "X/Y" where X is the current list index +; and Y is the total number of saved decks +; unreferenced? +Func_b568: ; b568 (2:7568) + ld a, [wCardListCursorPos] + ld b, a + ld a, [wCardListVisibleOffset] + add b + inc a + ld hl, wDefaultText + call ConvertToNumericalDigits + ld a, TX_SYMBOL + ld [hli], a + ld a, SYM_SLASH + ld [hli], a + ld a, [wNumSavedDecks] + call ConvertToNumericalDigits + ld [hl], TX_END + ld de, $0e01 + call InitTextPrinting + ld hl, wDefaultText + call ProcessText + ret +; 0xb592 ; handles player choice in what deck to save ; in the Deck Save Machine -- cgit v1.2.3 From 2246fb7c38f6481a93b2f1baa55a23a102b6bc30 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 13 May 2021 09:57:01 +0100 Subject: Minor corrections --- src/engine/bank02.asm | 38 +++++++++++++++++++------------------- src/engine/bank06.asm | 2 +- src/sram.asm | 4 +--- src/wram.asm | 2 +- 4 files changed, 22 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index ade91b7..d7baf51 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -434,7 +434,7 @@ _DrawYourOrOppPlayAreaScreen: ; 8211 (2:4211) ; a = (6 - name text in tiles) / 2 + 4 ld d, a ; text horizontal alignment - ld e, $00 + ld e, 0 call InitTextPrinting ldtx hl, DuelistsPlayAreaText ldh a, [hWhoseTurn] @@ -1935,7 +1935,7 @@ _SelectPrizeCards: ; 8aaa (2:4aaa) ld l, a call DrawYourOrOppPlayAreaScreen call DrawWideTextBox - ld de, $10e + lb de, 1, 14 call InitTextPrinting ldtx hl, PleaseChooseAPrizeText call ProcessTextFromID @@ -5266,7 +5266,7 @@ PrintNumberValueInCursorYPos: ; 9dbf (2:5dbf) ld hl, wCardListCursorYPos add [hl] ld e, a - ld d, $0e + ld d, 14 call InitTextPrinting ld hl, wDefaultText call ProcessText @@ -6476,7 +6476,7 @@ PrintPlayersCardsHeaderInfo: ; a4c6 (2:64c6) ; prints "'s cards" PrintPlayersCardsText: ; a4de (2:64de) - ld de, $100 + lb de, 1, 0 call InitTextPrinting ld de, wDefaultText call CopyPlayerName @@ -6486,7 +6486,7 @@ PrintPlayersCardsText: ; a4de (2:64de) call GetTextLengthInTiles inc b ld d, b - ld e, $00 + ld e, 0 call InitTextPrinting ldtx hl, SCardsText call ProcessTextFromID @@ -6528,7 +6528,7 @@ PrintTotalNumberOfCardsInCollection: ; a504 (2:6504) ld a, $07 ld [hli], a ld [hl], TX_END - ld de, $d00 + lb de, 13, 0 call InitTextPrinting ld hl, wTempCardCollection call ProcessText @@ -7400,7 +7400,7 @@ HandleCardAlbumScreen: ; a913 (2:6913) bank1call SetDefaultPalettes lb de, $3c, $ff call SetupText - ld de, $101 + lb de, 1, 1 call InitTextPrinting ; print the total number of cards that are in the Card Set @@ -7445,7 +7445,7 @@ HandleCardAlbumScreen: ; a913 (2:6913) push de call ProcessTextFromID call .CountOwnedCardsInSet - ld de, $0e01 + lb de, 14, 1 call InitTextPrinting ld a, [wNumOwnedCardsInSet] @@ -7535,8 +7535,8 @@ HandleCardAlbumScreen: ; a913 (2:6913) ; still has no promotional, print empty Card Set name ld a, TRUE ld [wUnavailableAlbumCardSets + CARD_SET_PROMOTIONAL], a - ld e, $0b - ld d, $05 + ld e, 11 + ld d, 5 call InitTextPrinting ldtx hl, EmptyPromotionalCardText call ProcessTextFromID @@ -7700,7 +7700,7 @@ PrinterMenu_PokemonCards: ; ab7b (2:6b7b) .asm_ac92 call DrawListCursor_Visible call .Func_acde - ld de, $101 + lb de, 1, 1 call InitTextPrinting ldtx hl, PrintThisCardYesNoText call ProcessTextFromID @@ -7777,7 +7777,7 @@ PrinterMenu_CardList: ; ad0e (2:6d0e) ld [wCurCardTypeFilter], a call PrintFilteredCardSelectionList call EnableLCD - ld de, $101 + lb de, 1, 1 call InitTextPrinting ld hl, EnableLCD call ProcessTextFromID @@ -7806,7 +7806,7 @@ HandlePrinterMenu: ; ad51 (2:6d51) lb de, 4, 0 lb bc, 12, 12 call DrawRegularTextBox - ld de, $602 + lb de, 6, 2 call InitTextPrinting ldtx hl, PrintMenuItemsText call ProcessTextFromID @@ -7993,7 +7993,7 @@ HandleDeckMissingCardsList: ; adfe (2:6dfe) ld hl, hffb0 ld [hl], $01 call .PrintDeckIndexAndName - ld de, $10e + lb de, 1, 14 call InitTextPrinting ld hl, wCardConfirmationText ld a, [hli] @@ -8026,7 +8026,7 @@ HandleDeckMissingCardsList: ; adfe (2:6dfe) ld a, [wCurDeckName] or a ret z ; not a valid deck - ld de, $1 + lb de, 0, 1 call InitTextPrinting ld a, [wCurDeck] inc a @@ -8050,7 +8050,7 @@ HandleDeckMissingCardsList: ; adfe (2:6dfe) ld e, l ld hl, DeckNameSuffix call CopyListFromHLToDE - ld de, $301 + lb de, 3, 1 ld hl, wDefaultText call InitTextPrinting call ProcessText @@ -9016,7 +9016,7 @@ PrintNumSavedDecks: ; b545 (2:7545) ld a, NUM_DECK_SAVE_MACHINE_SLOTS call ConvertToNumericalDigits ld [hl], TX_END - ld de, $0e01 + lb de, 14, 1 call InitTextPrinting ld hl, wDefaultText call ProcessText @@ -9041,7 +9041,7 @@ Func_b568: ; b568 (2:7568) ld a, [wNumSavedDecks] call ConvertToNumericalDigits ld [hl], TX_END - ld de, $0e01 + lb de, 14, 1 call InitTextPrinting ld hl, wDefaultText call ProcessText @@ -10043,7 +10043,7 @@ HandleAutoDeckMenu: ; ba04 (2:7a04) lb de, 0, 0 lb bc, 20, 13 call DrawRegularTextBox - ld de, $100 + lb de, 1, 0 call InitTextPrinting ld hl, wDeckMachineTitleText ld a, [hli] diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 467af8c..1e728fd 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -5101,7 +5101,7 @@ CheckWhichDecksToDismantleToBuildSavedDeck: ; 1ba9a (6:7a9a) scf ret -; returns cary if wSelectedDeckMachineEntry cannot be built +; returns carry if wSelectedDeckMachineEntry cannot be built ; by dismantling the decks given by register a ; a = DECK_* flags .CheckIfCanBuild diff --git a/src/sram.asm b/src/sram.asm index 3b2b83c..b64d8c3 100644 --- a/src/sram.asm +++ b/src/sram.asm @@ -120,9 +120,7 @@ sCurrentlySelectedDeck:: ; b700 ; an unnamed deck (i.e. DECK XXX) ; max number is MAX_UNNAMED_DECK_NUM sUnnamedDeckCounter:: ; b701 - ds $1 - - ds $1 + ds $2 ; whether player has had Promotional cards ; to decide whether to show the option diff --git a/src/wram.asm b/src/wram.asm index 621b985..4bfbc8d 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -2262,7 +2262,7 @@ wCurAutoDeckMachine:: ; d0a9 ds $1 ; text IDs for each deck descriptions of the -; Ato Deck Machine currently being shown +; Auto Deck Machine currently being shown wAutoDeckMachineTextDescriptions:: ; d0aa ds 2 * NUM_DECK_MACHINE_SLOTS -- cgit v1.2.3 From 504f4ad42f82f262bbb85d1471970d20e5957213 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 13 May 2021 09:59:07 +0100 Subject: Typo corrections --- src/engine/bank02.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index d7baf51..b36bfaf 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -8855,7 +8855,7 @@ PrintDeckMachineEntry: ; b424 (2:7424) ld d, 18 call InitTextPrinting -; print the symbol hat symbolizes whether the deck can +; print the symbol that symbolizes whether the deck can ; be built, or if another deck has to be dismantled to build it ld a, $0 ; no decks dismantled call CheckIfCanBuildSavedDeck @@ -8980,7 +8980,7 @@ PrintDeckMachineEntry: ; b424 (2:7424) ; 0xb525 ; counts how many decks in sSavedDecks are not empty -; stored value in wNumSavedDecks +; stores value in wNumSavedDecks GetSavedDeckCount: ; b525 (2:7525) call EnableSRAM ld hl, sSavedDecks -- cgit v1.2.3 From ef5a54d4d18baa51aea8552f184880e3ccd4d423 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 13 May 2021 20:12:45 +0100 Subject: Minor documentation fixing --- src/engine/bank02.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index b36bfaf..9afbaed 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -3360,7 +3360,7 @@ HandleDeckBuildScreen: ; 9345 (2:5345) ld hl, wNumVisibleCardListEntries cp [hl] jr nc, .ok - ; if total number of entries is greater or equal than + ; 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 [wCardListNumCursorPositions], a @@ -5316,9 +5316,9 @@ RemoveCardFromDeck: ; 9dfa (2:5dfa) ; and shift all elements up by one .RemoveCard ld hl, wCurDeckCards - ld d, 0 + ld d, 0 ; unnecessary .loop_1 - inc d + inc d ; unnecessary ld a, [hli] cp e jr nz, .loop_1 -- cgit v1.2.3