From 0300ba1b98636bec56acead7ffbe11e03ad173f7 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 4 Jul 2019 20:58:03 +0100 Subject: Disassemble bank 2 --- src/engine/bank02.asm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 4bbf7ca..87b78b0 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,5 +1,41 @@ Func_8000: ; 8000 (2:4000) - INCROM $8000, $8211 +.asm_8000 + call Func_905a + xor a + ld [wce5e], a + call DrawWideTextBox + xor a + ld [wcea3], a + ld hl, $4158 + call PlaceTextItems +.asm_8014 + call DoFrame + call Func_9065 + jr nc, .asm_8014 + cp $ff + ret z + ld a, [wceb0] + sla a + ld b, a + ld a, [wceaf] + add b + ld hl, $4031 + call JumpToFunctionInTable + jr .asm_8000 +; 0x8031 + +Func_8031: ; 8031 (2:4031) + INCROM $8031, $8158 + +.asm_8158 + textitem 2, 14, Text024a + textitem 2, 16, Text0248 + textitem 12, 14, Text024b + textitem 12, 16, Text0249 + db $ff + +Func_8169: ; 8169 (2:4169) + INCROM $8169, $8211 Func_8211: ; 8211 (2:4211) INCROM $8211, $833c -- cgit v1.2.3 From 1ee38c7bd02db0ec98524ab7213f370ee576a863 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 4 Jul 2019 21:29:47 +0100 Subject: Label bank 2 text data --- src/engine/bank02.asm | 16 ++++++++-------- src/text/text2.asm | 8 ++++---- src/text/text_offsets.asm | 8 ++++---- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 87b78b0..dd72f27 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,12 +1,12 @@ Func_8000: ; 8000 (2:4000) -.asm_8000 +.begin call Func_905a xor a ld [wce5e], a call DrawWideTextBox xor a ld [wcea3], a - ld hl, $4158 + ld hl, CheckMenuData call PlaceTextItems .asm_8014 call DoFrame @@ -21,17 +21,17 @@ Func_8000: ; 8000 (2:4000) add b ld hl, $4031 call JumpToFunctionInTable - jr .asm_8000 + jr .begin ; 0x8031 Func_8031: ; 8031 (2:4031) INCROM $8031, $8158 -.asm_8158 - textitem 2, 14, Text024a - textitem 2, 16, Text0248 - textitem 12, 14, Text024b - textitem 12, 16, Text0249 +CheckMenuData ; (2:4158) + textitem 2, 14, InPlayAreaText + textitem 2, 16, YourPlayAreaText + textitem 12, 14, GlossaryText + textitem 12, 16, OppPlayAreaText db $ff Func_8169: ; 8169 (2:4169) diff --git a/src/text/text2.asm b/src/text/text2.asm index 27ccff9..7227085 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1751,19 +1751,19 @@ Text0247: ; 3bc9e (e:7c9e) text "'s Play Area" done -Text0248: ; 3bcad (e:7cad) +YourPlayAreaText: ; 3bcad (e:7cad) text "Your Play Area" done -Text0249: ; 3bcbd (e:7cbd) +OppPlayAreaText: ; 3bcbd (e:7cbd) text "Opp. Play Area" done -Text024a: ; 3bccd (e:7ccd) +InPlayAreaText: ; 3bccd (e:7ccd) text "In Play Area" done -Text024b: ; 3bcdb (e:7cdb) +GlossaryText: ; 3bcdb (e:7cdb) text "Glossary" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 65dab94..f024288 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -585,10 +585,10 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text0245 ; 0x0245 textpointer Text0246 ; 0x0246 textpointer Text0247 ; 0x0247 - textpointer Text0248 ; 0x0248 - textpointer Text0249 ; 0x0249 - textpointer Text024a ; 0x024a - textpointer Text024b ; 0x024b + textpointer YourPlayAreaText ; 0x0248 + textpointer OppPlayAreaText ; 0x0249 + textpointer InPlayAreaText ; 0x024a + textpointer GlossaryText ; 0x024b textpointer Text024c ; 0x024c textpointer Text024d ; 0x024d textpointer Text024e ; 0x024e -- cgit v1.2.3 From 62521e80a6a44e80ea816ff579572f49b3eb3c0c Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 4 Jul 2019 23:20:46 +0100 Subject: Identify wDuelCursorBlinkCounter --- src/engine/bank02.asm | 8 ++++---- src/engine/bank06.asm | 22 +++++++++++----------- src/wram.asm | 3 ++- 3 files changed, 17 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index dd72f27..d0a3ea0 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -5,7 +5,7 @@ Func_8000: ; 8000 (2:4000) ld [wce5e], a call DrawWideTextBox xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a ld hl, CheckMenuData call PlaceTextItems .asm_8014 @@ -466,7 +466,7 @@ Func_905a: ; 905a (2:505a) xor a ld [wceaf], a ld [wceb0], a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a ret Func_9065: ; 9065 (2:5065) @@ -508,7 +508,7 @@ Func_9065: ; 9065 (2:5065) ld a, e ld [wceb0], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a .asm_90a6 ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON @@ -531,7 +531,7 @@ Func_9065: ; 9065 (2:5065) jr z, .asm_90ca call PlaySFX .asm_90ca - ld hl, wcea3 + ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $f diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index d9cb234..246282e 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -152,7 +152,7 @@ Func_180d5: ; 180d5 (6:40d5) ld [$ce52], a .asm_006_40da xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a farcall $2, $42ce call EnableLCD call IsClairvoyanceActive @@ -509,7 +509,7 @@ Func_006_43bb: ; 183bb (6:43bb) ld a, $01 ld [wcfe3], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a .asm_006_446b ldh a, [hKeysPressed] and $03 @@ -533,7 +533,7 @@ Func_006_43bb: ; 183bb (6:43bb) jr z, .asm_006_4494 call PlaySFX .asm_006_4494 - ld hl, wcea3 + ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -581,7 +581,7 @@ Func_006_44bf: ; 184bf (6:44bf) ld a, $ff ld [$ce55], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a .asm_006_44e5 ld a, $01 ld [wVBlankOAMCopyToggle], a @@ -604,7 +604,7 @@ Func_006_44bf: ; 184bf (6:44bf) call Func_006_4598 call Func_006_452b xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a jr .asm_006_44e5 .asm_006_4518 ld a, $01 @@ -803,7 +803,7 @@ GlossaryData2: ld a, e ld [wceb0], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a .asm_006_46a2 ldh a, [hKeysPressed] and $03 @@ -826,7 +826,7 @@ GlossaryData2: jr z, .asm_006_46c6 call PlaySFX .asm_006_46c6 - ld hl, wcea3 + ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -1882,7 +1882,7 @@ NamingScreen_CheckButtonState: ld a, h ld [wNamingScreenCursorX], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a ld a, $06 cp d jp z, NamingScreen_CheckButtonState @@ -1908,7 +1908,7 @@ NamingScreen_CheckButtonState: jr z, .asm_006_69f8 call PlaySFX .asm_006_69f8 - ld hl, wcea3 + ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -2663,7 +2663,7 @@ Func_006_6efb: ld a, h ld [wNamingScreenCursorX], a xor a - ld [wcea3], a + ld [wDuelCursorBlinkCounter], a ld a, $02 cp d jp z, Func_006_6efb @@ -2689,7 +2689,7 @@ Func_006_6efb: jr z, .asm_006_6f92 call PlaySFX .asm_006_6f92 - ld hl, wcea3 + ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $0f diff --git a/src/wram.asm b/src/wram.asm index 3af5361..bcc3714 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1388,7 +1388,8 @@ wcea1:: ; cea1 ds $1 -wcea3:: ; cea3 +; used to blink the cursor in duel menu +wDuelCursorBlinkCounter:: ; cea3 ds $1 wNamingScreenCursorY:: ; cea4 -- cgit v1.2.3 From ced986e050b539e94a087fb7ad3834fb4c77b1d1 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 4 Jul 2019 23:50:41 +0100 Subject: Label Check menu functions --- src/engine/bank01.asm | 6 +++--- src/engine/bank02.asm | 2 +- src/engine/home.asm | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index fff7239..3ea4ca9 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -812,7 +812,7 @@ UsePokemonCard: ; 44db (1:44db) ; triggered by selecting the "Check" item in the duel menu DuelMenu_Check: ; 4585 (1:4585) call Func_3b31 - call Func_3096 + call CallDuelCheckInterface jp DuelMainInterface ; triggered by pressing SELECT in the duel menu @@ -5199,7 +5199,7 @@ Func_60dd: ; 60dd (1:60dd) jr z, .asm_6119 or a jr z, .asm_6132 - call Func_3096 + call CallDuelCheckInterface jr .asm_60f2 .asm_6132 call OpenTurnHolderHandScreen_Simple @@ -6297,7 +6297,7 @@ Func_67fb: ; 67fb (1:67fb) ld a, [wCurrentDuelMenuItem] or a jr z, .asm_6839 - call Func_3096 + call CallDuelCheckInterface jr .asm_6829 .asm_6839 call OpenTurnHolderHandScreen_Simple diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index d0a3ea0..aa99d5d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,4 +1,4 @@ -Func_8000: ; 8000 (2:4000) +DuelCheckInterface: ; 8000 (2:4000) .begin call Func_905a xor a diff --git a/src/engine/home.asm b/src/engine/home.asm index 0101028..4043ff5 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9276,12 +9276,12 @@ CompareDEtoBC: ; 3090 (0:3090) cp c ret -Func_3096: ; 3096 (0:3096) +CallDuelCheckInterface: ; 3096 (0:3096) ldh a, [hBankROM] push af - ld a, BANK(Func_8000) + ld a, BANK(DuelCheckInterface) call BankswitchROM - call Func_8000 + call DuelCheckInterface pop af call BankswitchROM ret -- cgit v1.2.3 From f26a3e2b4dbfae41a908e7819f7b0a650c277517 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 5 Jul 2019 00:10:11 +0100 Subject: Identify duel cursor position --- src/engine/bank02.asm | 44 ++++++++++++++++++++++---------------------- src/engine/bank06.asm | 12 ++++++------ src/wram.asm | 4 ++-- 3 files changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index aa99d5d..7cf480d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,6 +1,6 @@ DuelCheckInterface: ; 8000 (2:4000) .begin - call Func_905a + call ResetCursorPosAndBlink xor a ld [wce5e], a call DrawWideTextBox @@ -14,10 +14,10 @@ DuelCheckInterface: ; 8000 (2:4000) jr nc, .asm_8014 cp $ff ret z - ld a, [wceb0] + ld a, [wCursorDuelYPosition] sla a ld b, a - ld a, [wceaf] + ld a, [wCursorDuelXPosition] add b ld hl, $4031 call JumpToFunctionInTable @@ -203,7 +203,7 @@ Func_8e42: ; 8e42 (2:4e42) call DrawWideTextBox ld hl, Unknown_9027 call PlaceTextItems - call Func_905a + call ResetCursorPosAndBlink .asm_8e4e call DoFrame call Func_9065 @@ -214,10 +214,10 @@ Func_8e42: ; 8e42 (2:4e42) ld a, [wceb1] jp Func_8dbc .asm_8e64 - ld a, [wceaf] + ld a, [wCursorDuelXPosition] or a jp nz, Func_8f8a - ld a, [wceb0] + ld a, [wCursorDuelYPosition] or a jp nz, .asm_8ecf call GetPointerToDeckCards @@ -370,7 +370,7 @@ Func_8f38: ; 8f38 (2:4f38) ret Func_8f8a: ; 8f8a (2:4f8a) - ld a, [wceb0] + ld a, [wCursorDuelYPosition] or a jp nz, Func_9026 call Func_8ff2 @@ -462,19 +462,19 @@ GetPointerToDeckCards: ; 9048 (2:5048) pop af ret -Func_905a: ; 905a (2:505a) +ResetCursorPosAndBlink: ; 905a (2:505a) xor a - ld [wceaf], a - ld [wceb0], a + ld [wCursorDuelXPosition], a + ld [wCursorDuelYPosition], a ld [wDuelCursorBlinkCounter], a ret Func_9065: ; 9065 (2:5065) xor a ld [wcfe3], a - ld a, [wceaf] + ld a, [wCursorDuelXPosition] ld d, a - ld a, [wceb0] + ld a, [wCursorDuelYPosition] ld e, a ldh a, [hDPadHeld] or a @@ -504,9 +504,9 @@ Func_9065: ; 9065 (2:5065) call Func_90d8 pop de ld a, d - ld [wceaf], a + ld [wCursorDuelXPosition], a ld a, e - ld [wceb0], a + ld [wCursorDuelYPosition], a xor a ld [wDuelCursorBlinkCounter], a .asm_90a6 @@ -545,13 +545,13 @@ asm_90da ld e, a ld a, $a ld l, a - ld a, [wceaf] + ld a, [wCursorDuelXPosition] ld h, a call HtimesL ld a, l add $1 ld b, a - ld a, [wceb0] + ld a, [wCursorDuelYPosition] sla a add $e ld c, a @@ -860,7 +860,7 @@ Func_b19d: ; b19d (2:719d) ld a, [wcea1] add b ld [wd088], a - call Func_905a + call ResetCursorPosAndBlink call DrawWideTextBox ld hl, $7274 call PlaceTextItems @@ -873,9 +873,9 @@ Func_b19d: ; b19d (2:719d) jp $71b3 .asm_b1fa - ld a, [wceb0] + ld a, [wCursorDuelYPosition] sla a - ld hl, wceaf + ld hl, wCursorDuelXPosition add [hl] or a jr nz, .asm_b22c @@ -1028,7 +1028,7 @@ Func_ba04: ; ba04 (2:7a04) cp $ff jp z, $7b0d ld [wd088], a - call Func_905a + call ResetCursorPosAndBlink xor a ld [wce5e], a call DrawWideTextBox @@ -1043,9 +1043,9 @@ Func_ba04: ; ba04 (2:7a04) jp $7a25 .asm_badf - ld a, [wceb0] + ld a, [wCursorDuelYPosition] sla a - ld hl, wceaf + ld hl, wCursorDuelXPosition add [hl] or a jr nz, .asm_bb09 diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 246282e..7aec911 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -767,9 +767,9 @@ GlossaryData2: ; (6:4661) xor a ld [wcfe3], a - ld a, [wceaf] + ld a, [wCursorDuelXPosition] ld d, a - ld a, [wceb0] + ld a, [wCursorDuelYPosition] ld e, a ldh a, [hDPadHeld] or a @@ -799,9 +799,9 @@ GlossaryData2: call .asm_006_46d4 pop de ld a, d - ld [wceaf], a + ld [wCursorDuelXPosition], a ld a, e - ld [wceb0], a + ld [wCursorDuelYPosition], a xor a ld [wDuelCursorBlinkCounter], a .asm_006_46a2 @@ -840,13 +840,13 @@ GlossaryData2: ld e, a ld a, $0a ld l, a - ld a, [wceaf] + ld a, [wCursorDuelXPosition] ld h, a call HtimesL ld a, l add $01 ld b, a - ld a, [wceb0] + ld a, [wCursorDuelYPosition] sla a add $0e ld c, a diff --git a/src/wram.asm b/src/wram.asm index bcc3714..02a013d 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1407,10 +1407,10 @@ wceaa:: ; ceaa wceab:: ; ceab ds $4 -wceaf:: ; ceaf +wCursorDuelXPosition:: ; ceaf ds $1 -wceb0:: ; ceb0 +wCursorDuelYPosition:: ; ceb0 ds $1 wceb1:: ; ceb1 -- cgit v1.2.3 From 60ecedab9e7f1fc01c289306f1196a8a0bd62886 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 5 Jul 2019 08:28:45 +0100 Subject: Identify duel check function table --- src/engine/bank02.asm | 28 +++++++++++++++++++++++----- src/engine/bank06.asm | 1 + 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 7cf480d..f4b873c 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -19,15 +19,33 @@ DuelCheckInterface: ; 8000 (2:4000) ld b, a ld a, [wCursorDuelXPosition] add b - ld hl, $4031 + ld hl, DuelCheckMenuFunctionTable call JumpToFunctionInTable jr .begin -; 0x8031 -Func_8031: ; 8031 (2:4031) - INCROM $8031, $8158 +DuelCheckMenuFunctionTable: ; 8031 (2:4031) + dw DuelCheckMenu_InPlayArea + dw DuelCheckMenu_Glossary + dw DuelCheckMenu_YourPlayArea + dw DuelCheckMenu_OppPlayArea -CheckMenuData ; (2:4158) +DuelCheckMenu_InPlayArea: ; 8039 (2:4039) + xor a + ld [wce60], a + farcall Func_180d5 + ret + +DuelCheckMenu_Glossary: ; 8042 (2:4042) + farcall Func_006_44c8 + ret + +DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) + INCROM $8047, $80da + +DuelCheckMenu_OppPlayArea: ; 80da (2:40da) + INCROM $80da, $8158 + +CheckMenuData: ; (2:4158) textitem 2, 14, InPlayAreaText textitem 2, 16, YourPlayAreaText textitem 12, 14, GlossaryText diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 7aec911..d25dccb 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -568,6 +568,7 @@ Func_006_44bf: ; 184bf (6:44bf) ld [wVBlankOAMCopyToggle], a ret +Func_006_44c8: ; 184c8 (6:44c8) xor a ld [wGlossaryPageNo], a call Func_006_452b -- cgit v1.2.3 From 5d040d3c1a519401da55ae1eef91c5d9def93d86 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 5 Jul 2019 19:51:30 +0100 Subject: Label Func_9065 --- src/engine/bank02.asm | 76 +++++++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index f4b873c..c0116f9 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,5 +1,4 @@ DuelCheckInterface: ; 8000 (2:4000) -.begin call ResetCursorPosAndBlink xor a ld [wce5e], a @@ -10,7 +9,7 @@ DuelCheckInterface: ; 8000 (2:4000) call PlaceTextItems .asm_8014 call DoFrame - call Func_9065 + call HandleDuelMenuInput2 jr nc, .asm_8014 cp $ff ret z @@ -21,7 +20,7 @@ DuelCheckInterface: ; 8000 (2:4000) add b ld hl, DuelCheckMenuFunctionTable call JumpToFunctionInTable - jr .begin + jr DuelCheckInterface DuelCheckMenuFunctionTable: ; 8031 (2:4031) dw DuelCheckMenu_InPlayArea @@ -224,11 +223,11 @@ Func_8e42: ; 8e42 (2:4e42) call ResetCursorPosAndBlink .asm_8e4e call DoFrame - call Func_9065 + call HandleDuelMenuInput2 jp nc, .asm_8e4e cp $ff jr nz, .asm_8e64 - call Func_90d8 + call DrawCursorEmpty ld a, [wceb1] jp Func_8dbc .asm_8e64 @@ -487,7 +486,12 @@ ResetCursorPosAndBlink: ; 905a (2:505a) ld [wDuelCursorBlinkCounter], a ret -Func_9065: ; 9065 (2:5065) +; handle player input in menu +; works out which cursor coordinate to go to +; and sets carry flag if A or B are pressed +; returns a = $1 if A pressed +; returns a = $ff if B pressed +HandleDuelMenuInput2: ; 9065 (2:5065) xor a ld [wcfe3], a ld a, [wCursorDuelXPosition] @@ -496,30 +500,30 @@ Func_9065: ; 9065 (2:5065) ld e, a ldh a, [hDPadHeld] or a - jr z, .asm_90a6 + jr z, .no_pad bit D_LEFT_F, a - jr nz, .asm_907e + jr nz, .horizontal bit D_RIGHT_F, a - jr z, .asm_9084 -.asm_907e + jr z, .check_vertical +.horizontal ld a, d - xor $1 + xor $1 ; flips x coordinate ld d, a - jr .asm_9090 -.asm_9084 + jr .okay +.check_vertical bit D_UP_F, a - jr nz, .asm_908c + jr nz, .vertical bit D_DOWN_F, a - jr z, .asm_90a6 -.asm_908c + jr z, .no_pad +.vertical ld a, e - xor $1 + xor $1 ; flips y coordinate ld e, a -.asm_9090 +.okay ld a, $1 ld [wcfe3], a push de - call Func_90d8 + call DrawCursorEmpty pop de ld a, d ld [wCursorDuelXPosition], a @@ -527,39 +531,45 @@ Func_9065: ; 9065 (2:5065) ld [wCursorDuelYPosition], a xor a ld [wDuelCursorBlinkCounter], a -.asm_90a6 +.no_pad ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON - jr z, .asm_90c1 + jr z, .no_input and A_BUTTON - jr nz, .asm_90b7 + jr nz, .a_press ld a, $ff call Func_90fb scf ret -.asm_90b7 +.a_press call Func_90f7 ld a, $1 call Func_90fb scf ret -.asm_90c1 +.no_input ld a, [wcfe3] or a - jr z, .asm_90ca + jr z, .check_blink call PlaySFX -.asm_90ca +.check_blink ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] and $f - ret nz + ret nz ; don't update cursor ld a, $f bit 4, [hl] - jr z, asm_90da -Func_90d8: ; 90d8 (2:50d8) - ld a, $0 -asm_90da + jr z, DrawByteInCursor + +; draws in the cursor position +DrawCursorEmpty: ; 90d8 (2:50d8) + ld a, $0 ; empty cursor +; fallthrough + +; draws in the cursor position +; with byte in a +DrawByteInCursor: ld e, a ld a, $a ld l, a @@ -580,7 +590,7 @@ asm_90da Func_90f7: ; 90f7 (2:50f7) ld a, $f - jr asm_90da + jr DrawByteInCursor Func_90fb: ; 90fb (2:50fb) push af @@ -883,7 +893,7 @@ Func_b19d: ; b19d (2:719d) ld hl, $7274 call PlaceTextItems call DoFrame - call Func_9065 + call HandleDuelMenuInput2 jp nc, $71e7 cp $ff jr nz, .asm_b1fa -- cgit v1.2.3 From a4cbb583e1d85b63fd7c030a86a5ff32d66fc9a2 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 17:03:10 +0100 Subject: More bank 2 disassembling --- src/engine/bank02.asm | 177 +++++++++++++++++++++++++++++++++++++++++++++++--- src/engine/home.asm | 5 +- 2 files changed, 172 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index c0116f9..02251a5 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -7,13 +7,13 @@ DuelCheckInterface: ; 8000 (2:4000) ld [wDuelCursorBlinkCounter], a ld hl, CheckMenuData call PlaceTextItems -.asm_8014 +.loop call DoFrame call HandleDuelMenuInput2 - jr nc, .asm_8014 + jr nc, .loop cp $ff - ret z - ld a, [wCursorDuelYPosition] + ret z ; B was pressed + ld a, [wCursorDuelYPosition] ; A was pressed sla a ld b, a ld a, [wCursorDuelXPosition] @@ -39,7 +39,46 @@ DuelCheckMenu_Glossary: ; 8042 (2:4042) ret DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) - INCROM $8047, $80da + call ResetCursorPosAndBlink + xor a + ld [wce5e], a + ldh a, [hWhoseTurn] +.asm_8050 + ld h, a + ld l, a + call Func_8209 + ld a, [wCursorDuelYPosition] + sla a + ld b, a + ld a, [wCursorDuelXPosition] + add b + ld [$ce5f], a + ld b, $f8 + call Func_81ba + call DrawWideTextBox + xor a + ld [wDuelCursorBlinkCounter], a + ld hl, $4169 + call PlaceTextItems +.asm_8074 + call DoFrame + xor a + call Func_818c + call Func_86ac + jr nc, .asm_8074 + call Func_81af + cp $ff + ret z + ld a, [wCursorDuelYPosition] + sla a + ld b, a + ld a, [wCursorDuelXPosition] + add b + ld hl, $4098 + call JumpToFunctionInTable + jr .asm_8050 +; 0x8098 + INCROM $8098, $80da DuelCheckMenu_OppPlayArea: ; 80da (2:40da) INCROM $80da, $8158 @@ -52,19 +91,139 @@ CheckMenuData: ; (2:4158) db $ff Func_8169: ; 8169 (2:4169) - INCROM $8169, $8211 + INCROM $8169, $818c + +Func_818c: ; 818c (2:418c) + INCROM $818c, $81af + +Func_81af: ; 81af (2:41af) + INCROM $81af, $81ba + +Func_81ba: ; 81ba (2:41ba) + INCROM $81ba, $8209 + +Func_8209: ; 8209 (2:4209) + ld a, h + ld [wce50], a + ld a, l + ld [wce51], a Func_8211: ; 8211 (2:4211) - INCROM $8211, $833c + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call EmptyScreen + call Set_OBJ_8x8 + call Func_8992 + call LoadSymbolsFont + call LoadDeckAndDiscardPileIcons + ld a, [wce50] + cp $c2 + jr nz, .asm_823e + ld de, wDefaultText + call CopyPlayerName + jr .asm_8244 +.asm_823e + ld de, wDefaultText + call CopyOpponentName +.asm_8244 + ld hl, wDefaultText + call GetTextLengthInTiles + ld a, $06 + sub b + srl a + add $04 + ld d, a + ld e, $00 + call InitTextPrinting + ld hl, $247 + ldh a, [hWhoseTurn] + cp $c2 + jr nz, .asm_8267 + ld a, [wce50] + cp $c2 + jr nz, .asm_826c +.asm_8267 + call PrintTextNoDelay + jr .asm_8275 +.asm_826c + call SwapTurn + call PrintTextNoDelay + call SwapTurn +.asm_8275 + ld a, [wce50] + ld b, a + ld a, [wce51] + cp b + jr nz, .asm_8299 + ld hl, $44b4 + call Func_8464 + ld de, $602 + call Func_837e + ld de, $109 + ld c, $04 + call Func_8511 + xor a + call Func_85aa + jr .asm_82b2 +.asm_8299 + ld hl, $44c0 + call Func_8464 + ld de, $605 + call Func_837e + ld de, $102 + ld c, $04 + call Func_8511 + ld a, $01 + call Func_85aa +.asm_82b2 + call EnableLCD + ret +; 0x82b6 + +Func_82b6: ; 82b6 (2:42b6) + INCROM $82b6, $833c Func_833c: ; 833c (2:433c) - INCROM $833c, $8764 + INCROM $833c, $837e + +Func_837e: ; 837e (2:437e) + INCROM $837e, $8464 + +Func_8464: ; 8464 (2:4464) + INCROM $8464, $8511 + +Func_8511: ; 8511 (2:4511) + INCROM $8511, $85aa + +Func_85aa: ; 85aa (2:45aa) + INCROM $85aa, $86ac + +Func_86ac: ; 86ac (2:46ac) + INCROM $86ac, $8764 Func_8764: ; 8764 (2:4764) INCROM $8764, $8932 Func_8932: ; 8932 (2:4932) - INCROM $8932, $8aaa + INCROM $8932, $8992 + +Func_8992: ; 8992 (2:4992) + ld de, v0Tiles0 + ld hl, Data_899e + ld b, 16 + call SafeCopyDataHLtoDE + ret +; 0x899e + +Data_899e: ; 899e (2:499e) + db $e0, $c0, $98, $b0, $84, $8c, $83, $82 + db $86, $8f, $9d, $be, $f4, $f8, $50, $60 + + INCROM $89ae, $8aaa Func_8aaa: ; 8aaa (2:4aaa) INCROM $8aaa, $8b85 diff --git a/src/engine/home.asm b/src/engine/home.asm index 4043ff5..528bc53 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -6238,7 +6238,10 @@ LoadPlacingThePrizesScreenTiles: ; 20f0 (0:20f0) ld de, v0Tiles1 + $20 tiles ld b, $d call CopyFontsOrDuelGraphicsTiles - ; load the Deck and the Discard Pile icons +; fallthrough + +; load the Deck and the Discard Pile icons +LoadDeckAndDiscardPileIcons: ; 20fb (0:20fb) ld hl, DuelDmgSgbSymbolGraphics + $54 tiles - $4000 ld a, [wConsole] cp CONSOLE_CGB -- cgit v1.2.3 From 7749ebd22d28a67db2f1a9208e254da6b8e29ef0 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 18:28:09 +0100 Subject: Work on Func_8211 --- src/engine/bank02.asm | 86 +++++++++++++++++++++++++++++---------------------- src/engine/home.asm | 4 +-- src/wram.asm | 6 ++-- 3 files changed, 55 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 02251a5..d8cc194 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -46,7 +46,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .asm_8050 ld h, a ld l, a - call Func_8209 + call LoadTurnHolders ld a, [wCursorDuelYPosition] sla a ld b, a @@ -102,84 +102,96 @@ Func_81af: ; 81af (2:41af) Func_81ba: ; 81ba (2:41ba) INCROM $81ba, $8209 -Func_8209: ; 8209 (2:4209) +; loads the turn holders +; with the turn that a holds +LoadTurnHolders: ; 8209 (2:4209) ld a, h - ld [wce50], a + ld [wTurnHolder1], a ld a, l - ld [wce51], a + ld [wTurnHolder2], a +; fallthrough +; loads tiles and icons to display play area +; and draws the screen according to the turn player Func_8211: ; 8211 (2:4211) xor a ld [wTileMapFill], a call ZeroObjectPositions + ld a, $01 ld [wVBlankOAMCopyToggle], a + call DoFrame call EmptyScreen call Set_OBJ_8x8 - call Func_8992 + call LoadCursorTile call LoadSymbolsFont call LoadDeckAndDiscardPileIcons - ld a, [wce50] - cp $c2 - jr nz, .asm_823e + + ld a, [wTurnHolder1] + cp PLAYER_TURN + jr nz, .opp_turn1 ld de, wDefaultText call CopyPlayerName - jr .asm_8244 -.asm_823e + jr .get_text_length +.opp_turn1 ld de, wDefaultText call CopyOpponentName -.asm_8244 +.get_text_length ld hl, wDefaultText + call GetTextLengthInTiles - ld a, $06 + ld a, 6 ; max name size in tiles sub b srl a - add $04 - ld d, a + add 4 + ; a = (6 - name text in tiles) / 2 + 4 + ld d, a ; text horizontal alignment + ld e, $00 call InitTextPrinting - ld hl, $247 + lb hl, $02, $47 ldh a, [hWhoseTurn] - cp $c2 - jr nz, .asm_8267 - ld a, [wce50] - cp $c2 - jr nz, .asm_826c -.asm_8267 + cp PLAYER_TURN + jr nz, .opp_turn2 + ld a, [wTurnHolder1] + cp PLAYER_TURN + jr nz, .swap +.opp_turn2 call PrintTextNoDelay jr .asm_8275 -.asm_826c +.swap call SwapTurn call PrintTextNoDelay call SwapTurn + .asm_8275 - ld a, [wce50] + ld a, [wTurnHolder1] ld b, a - ld a, [wce51] + ld a, [wTurnHolder2] cp b - jr nz, .asm_8299 - ld hl, $44b4 + jr nz, .not_equal + lb hl, $44, $b4 call Func_8464 - ld de, $602 + lb de, $06, 02 call Func_837e - ld de, $109 + lb de, $01, $09 ld c, $04 call Func_8511 xor a call Func_85aa - jr .asm_82b2 -.asm_8299 - ld hl, $44c0 + jr .lcd +.not_equal + lb hl, $44, $c0 call Func_8464 - ld de, $605 + lb de, $06, $05 call Func_837e - ld de, $102 + lb de, $01, $02 ld c, $04 call Func_8511 ld a, $01 call Func_85aa -.asm_82b2 +.lcd call EnableLCD ret ; 0x82b6 @@ -211,15 +223,15 @@ Func_8764: ; 8764 (2:4764) Func_8932: ; 8932 (2:4932) INCROM $8932, $8992 -Func_8992: ; 8992 (2:4992) +LoadCursorTile: ; 8992 (2:4992) ld de, v0Tiles0 - ld hl, Data_899e + ld hl, .tile_data ld b, 16 call SafeCopyDataHLtoDE ret ; 0x899e -Data_899e: ; 899e (2:499e) +.tile_data: ; 899e (2:499e) db $e0, $c0, $98, $b0, $84, $8c, $83, $82 db $86, $8f, $9d, $be, $f4, $f8, $50, $60 diff --git a/src/engine/home.asm b/src/engine/home.asm index 528bc53..c0c0485 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9304,9 +9304,9 @@ Func_30a6: ; 30a6 (0:30a6) Func_30bc: ; 30bc (0:30bc) ld a, h - ld [wce50], a + ld [wTurnHolder1], a ld a, l - ld [wce51], a + ld [wTurnHolder2], a ldh a, [hBankROM] push af ld a, BANK(Func_8211) diff --git a/src/wram.asm b/src/wram.asm index 02a013d..9468724 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1283,10 +1283,12 @@ wTextBoxLabel:: ; ce4c wCoinTossScreenTextID:: ; ce4e ds $2 -wce50:: ; ce50 +; these hold either player or opponent turn +; for temporary calculations +wTurnHolder1:: ; ce50 ds $1 -wce51:: ; ce51 +wTurnHolder2:: ; ce51 ds $1 ds $7 -- cgit v1.2.3 From f7362f9c484afc6486e8e309f194a196bd233908 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 21:10:22 +0100 Subject: Work on Func_8464 --- src/engine/bank02.asm | 105 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/engine/bank06.asm | 2 +- src/wram.asm | 9 ++++- 3 files changed, 110 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index d8cc194..381e9b4 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -164,14 +164,14 @@ Func_8211: ; 8211 (2:4211) call SwapTurn call PrintTextNoDelay call SwapTurn - + .asm_8275 ld a, [wTurnHolder1] ld b, a ld a, [wTurnHolder2] cp b jr nz, .not_equal - lb hl, $44, $b4 + ld hl, PrizeCardsCoordinateData.player call Func_8464 lb de, $06, 02 call Func_837e @@ -182,7 +182,7 @@ Func_8211: ; 8211 (2:4211) call Func_85aa jr .lcd .not_equal - lb hl, $44, $c0 + ld hl, PrizeCardsCoordinateData.opponent call Func_8464 lb de, $06, $05 call Func_837e @@ -206,7 +206,104 @@ Func_837e: ; 837e (2:437e) INCROM $837e, $8464 Func_8464: ; 8464 (2:4464) - INCROM $8464, $8511 + push hl + call Func_84fc + ld a, [wTurnHolder1] + ld h, a + ld l, DUELVARS_PRIZES + ld a, [hl] + + pop hl + ld b, 0 + push af +; loop each prize card + 1 +.loop + inc b + ld a, [wDuelInitialPrizes] + inc a + cp b + jr z, .done + + pop af + srl a ; right shift prize cards left + push af + jr c, .not_taken + ld a, $e0 ; tile byte for empty slot + jr .draw +.not_taken + ld a, $dc ; tile byte for card +.draw + ld e, [hl] + inc hl + ld d, [hl] + inc hl + + push hl + push bc + lb hl, $01, $02 ; card tile gfx + lb bc, 2, 2 ; rectangle size + call FillRectangle + + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .not_cgb + ld a, $02 ; blue colour + lb bc, 2, 2 + lb hl, $00, $00 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 +.not_cgb + pop bc + pop hl + jr .loop +.done + pop af + ret +; 0x84b4 + +PrizeCardsCoordinateData: +; x and y coordinates for player prize cards +.player + db 2, 1 + db 2, 3 + db 4, 1 + db 4, 3 + db 6, 1 + db 6, 3 +; x and y coordinates for opponent prize cards +.opponent + db 9, 17 + db 9, 15 + db 7, 17 + db 7, 15 + db 5, 17 + db 5, 15 + + INCROM $84cc, $84fc + +; returns in a bits set up to the number of +; initial prizes, with upper 2 bits set, i.e: +; 6 prizes: a = %11111111 +; 4 prizes: a = %11001111 +; 3 prizes: a = %11000111 +; 2 prizes: a = %11000011 +Func_84fc: ; 84fc (2:44fc) + ld a, [wDuelInitialPrizes] + ld b, $01 +.loop + or a + jr z, .done + sla b + dec a + jr .loop +.done + dec b + ld a, b + or %11000000 + ld [wDuelInitialPrizesUpperBitsSet], a + ret +; 0x8511 Func_8511: ; 8511 (2:4511) INCROM $8511, $85aa diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index d25dccb..2feb1e3 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -580,7 +580,7 @@ Func_006_44c8: ; 184c8 (6:44c8) inc hl ld [hl], d ld a, $ff - ld [$ce55], a + ld [wDuelInitialPrizesUpperBitsSet], a xor a ld [wDuelCursorBlinkCounter], a .asm_006_44e5 diff --git a/src/wram.asm b/src/wram.asm index 9468724..a9887c4 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1291,7 +1291,14 @@ wTurnHolder1:: ; ce50 wTurnHolder2:: ; ce51 ds $1 - ds $7 + ds $3 + +; same as wDuelInitialPrizes but +; with upper 2 bits set +wDuelInitialPrizesUpperBitsSet:: ; ce55 + ds $1 + + ds $3 wce59:: ; ce59 ds $1 -- cgit v1.2.3 From c8cb81d6f9a8721eab40a40f8ec50d3384bdeb65 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 21:21:35 +0100 Subject: Label more bank 2 --- src/engine/bank01.asm | 6 +++--- src/engine/bank02.asm | 26 +++++++++++++------------- src/engine/bank06.asm | 2 +- src/engine/home.asm | 12 ++++++------ 4 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 3ea4ca9..09bdee4 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -812,7 +812,7 @@ UsePokemonCard: ; 44db (1:44db) ; triggered by selecting the "Check" item in the duel menu DuelMenu_Check: ; 4585 (1:4585) call Func_3b31 - call CallDuelCheckInterface + call DuelCheckInterface jp DuelMainInterface ; triggered by pressing SELECT in the duel menu @@ -5199,7 +5199,7 @@ Func_60dd: ; 60dd (1:60dd) jr z, .asm_6119 or a jr z, .asm_6132 - call CallDuelCheckInterface + call DuelCheckInterface jr .asm_60f2 .asm_6132 call OpenTurnHolderHandScreen_Simple @@ -6297,7 +6297,7 @@ Func_67fb: ; 67fb (1:67fb) ld a, [wCurrentDuelMenuItem] or a jr z, .asm_6839 - call CallDuelCheckInterface + call DuelCheckInterface jr .asm_6829 .asm_6839 call OpenTurnHolderHandScreen_Simple diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 381e9b4..1c9e389 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,4 +1,4 @@ -DuelCheckInterface: ; 8000 (2:4000) +_DuelCheckInterface: ; 8000 (2:4000) call ResetCursorPosAndBlink xor a ld [wce5e], a @@ -20,7 +20,7 @@ DuelCheckInterface: ; 8000 (2:4000) add b ld hl, DuelCheckMenuFunctionTable call JumpToFunctionInTable - jr DuelCheckInterface + jr _DuelCheckInterface DuelCheckMenuFunctionTable: ; 8031 (2:4031) dw DuelCheckMenu_InPlayArea @@ -58,7 +58,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DrawWideTextBox xor a ld [wDuelCursorBlinkCounter], a - ld hl, $4169 + lb hl, $41, $69 call PlaceTextItems .asm_8074 call DoFrame @@ -74,7 +74,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld b, a ld a, [wCursorDuelXPosition] add b - ld hl, $4098 + lb hl, $40, $98 call JumpToFunctionInTable jr .asm_8050 ; 0x8098 @@ -113,7 +113,7 @@ LoadTurnHolders: ; 8209 (2:4209) ; loads tiles and icons to display play area ; and draws the screen according to the turn player -Func_8211: ; 8211 (2:4211) +_DrawPlayArea: ; 8211 (2:4211) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -159,20 +159,20 @@ Func_8211: ; 8211 (2:4211) jr nz, .swap .opp_turn2 call PrintTextNoDelay - jr .asm_8275 + jr .draw .swap call SwapTurn call PrintTextNoDelay call SwapTurn -.asm_8275 +.draw ld a, [wTurnHolder1] ld b, a ld a, [wTurnHolder2] cp b jr nz, .not_equal ld hl, PrizeCardsCoordinateData.player - call Func_8464 + call DrawPrizeCards lb de, $06, 02 call Func_837e lb de, $01, $09 @@ -183,7 +183,7 @@ Func_8211: ; 8211 (2:4211) jr .lcd .not_equal ld hl, PrizeCardsCoordinateData.opponent - call Func_8464 + call DrawPrizeCards lb de, $06, $05 call Func_837e lb de, $01, $02 @@ -205,9 +205,9 @@ Func_833c: ; 833c (2:433c) Func_837e: ; 837e (2:437e) INCROM $837e, $8464 -Func_8464: ; 8464 (2:4464) +DrawPrizeCards: ; 8464 (2:4464) push hl - call Func_84fc + call GetDuelInitialPrizesUpperBitsSet ld a, [wTurnHolder1] ld h, a ld l, DUELVARS_PRIZES @@ -282,13 +282,13 @@ PrizeCardsCoordinateData: INCROM $84cc, $84fc -; returns in a bits set up to the number of +; calculates bits set up to the number of ; initial prizes, with upper 2 bits set, i.e: ; 6 prizes: a = %11111111 ; 4 prizes: a = %11001111 ; 3 prizes: a = %11000111 ; 2 prizes: a = %11000011 -Func_84fc: ; 84fc (2:44fc) +GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ld a, [wDuelInitialPrizes] ld b, $01 .loop diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 2feb1e3..8d7d110 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -1100,7 +1100,7 @@ Func_006_50fb: ; 190fb (6:50fb) ld a, [wWhoseTurn] ld l, a .asm_006_5127 - call Func_30bc + call DrawPlayArea pop af ld [wDuelDisplayedScreen], a .asm_006_512e diff --git a/src/engine/home.asm b/src/engine/home.asm index c0c0485..e0e9974 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9279,12 +9279,12 @@ CompareDEtoBC: ; 3090 (0:3090) cp c ret -CallDuelCheckInterface: ; 3096 (0:3096) +DuelCheckInterface: ; 3096 (0:3096) ldh a, [hBankROM] push af - ld a, BANK(DuelCheckInterface) + ld a, BANK(_DuelCheckInterface) call BankswitchROM - call DuelCheckInterface + call _DuelCheckInterface pop af call BankswitchROM ret @@ -9302,16 +9302,16 @@ Func_30a6: ; 30a6 (0:30a6) call BankswitchROM ret -Func_30bc: ; 30bc (0:30bc) +DrawPlayArea: ; 30bc (0:30bc) ld a, h ld [wTurnHolder1], a ld a, l ld [wTurnHolder2], a ldh a, [hBankROM] push af - ld a, BANK(Func_8211) + ld a, BANK(_DrawPlayArea) call BankswitchROM - call Func_8211 + call _DrawPlayArea call DrawWideTextBox pop af call BankswitchROM -- cgit v1.2.3 From 38e9ccc28a9114fe2f496b17867c53c4c7b686b7 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 23:11:29 +0100 Subject: More YourPlayArea functions --- src/engine/bank02.asm | 110 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/wram.asm | 3 ++ 2 files changed, 109 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 1c9e389..c4f7cf3 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -47,12 +47,13 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld h, a ld l, a call LoadTurnHolders + ld a, [wCursorDuelYPosition] sla a ld b, a ld a, [wCursorDuelXPosition] add b - ld [$ce5f], a + ld [wLastCursorPosition_YourPlayArea], a ld b, $f8 call Func_81ba call DrawWideTextBox @@ -94,13 +95,114 @@ Func_8169: ; 8169 (2:4169) INCROM $8169, $818c Func_818c: ; 818c (2:418c) - INCROM $818c, $81af + push af + ld b, a + add b + add b + ld c, a + ld a, [wCursorDuelYPosition] + sla a + ld b, a + ld a, [wCursorDuelXPosition] + add b + add c + ; a = 2 * cursor ycoord + cursor xcoord + 3*a + ld hl, wLastCursorPosition_YourPlayArea + cp [hl] + jr z, .unchanged + call Func_81af + ld [wLastCursorPosition_YourPlayArea], a + ld b, $f8 ; black cursor tile byte + call Func_81ba +.unchanged + pop af + ret + +; load white tile in b to erase +; the bytes drawn previously Func_81af: ; 81af (2:41af) - INCROM $81af, $81ba + push af + ld a, [wLastCursorPosition_YourPlayArea] + ld b, $00 ; white tile + call Func_81ba + pop af + ret +; writes tile in b to positions tabulated in +; Data_81d7, with offset calculated from the +; cursor x and y positions Func_81ba: ; 81ba (2:41ba) - INCROM $81ba, $8209 + push bc + ld hl, Data_81d7 + sla a + ld c, a + ld b, $00 + add hl, bc + ; hl points to Data_81d7 plus offset corresponding to a + + ld a, [hli] + ld h, [hl] + ld l, a + pop de + +.loop + ld a, [hli] + cp $ff + jr z, .done + ld b, a + ld a, [hli] + ld c, a + ld a, d + call WriteByteToBGMap0 + jr .loop +.done + ret +; 0x81d7 + +Data_81d7: ; 81d7 (2:41d7) + dw Data_81e3.data_81e3 + dw Data_81e3.data_81f0 + dw Data_81e3.data_81f3 + dw Data_81e3.data_81f6 + dw Data_81e3.data_8203 + dw Data_81e3.data_8206 + +Data_81e3: ; 81e3 (2:41e3) +; x and y coordinates to draw byte +.data_81e3: + db 5, 5 + db 0, 10 + db 4, 10 + db 8, 10 + db 12, 10 + db 16, 10 + db $ff + +.data_81f0: + db 14, 7 + db $ff + +.data_81f3: + db 14, 5 + db $ff + +.data_81f6: + db 5, 7 + db 0, 3 + db 4, 3 + db 8, 3 + db 12, 3 + db 16, 3 + db $ff + +.data_8203: + db 0, 5 + db $ff + +.data_8206: + db 0, 8 + db $ff ; loads the turn holders ; with the turn that a holds diff --git a/src/wram.asm b/src/wram.asm index a9887c4..4d10b86 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1308,6 +1308,9 @@ wce59:: ; ce59 wce5e:: ; ce5e ds $1 +; this is used to store last cursor position +; in the Your Play Area screen +wLastCursorPosition_YourPlayArea:: ; ce5f ds $1 wce60:: ; ce60 -- cgit v1.2.3 From 853fd045da706f07c9ccef72cbde2075675074cd Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 23:24:45 +0100 Subject: YourPlayArea function labels --- src/engine/bank02.asm | 60 +++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index c4f7cf3..8d846db 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -54,8 +54,9 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld a, [wCursorDuelXPosition] add b ld [wLastCursorPosition_YourPlayArea], a - ld b, $f8 - call Func_81ba + ld b, $f8 ; black arrow tile + call DrawByteToTabulatedPositions + call DrawWideTextBox xor a ld [wDuelCursorBlinkCounter], a @@ -64,10 +65,10 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .asm_8074 call DoFrame xor a - call Func_818c + call DrawByteToTabulatedPositions_FromCursor call Func_86ac jr nc, .asm_8074 - call Func_81af + call EraseByteFromTabulatedPositions cp $ff ret z ld a, [wCursorDuelYPosition] @@ -78,7 +79,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) lb hl, $40, $98 call JumpToFunctionInTable jr .asm_8050 -; 0x8098 + INCROM $8098, $80da DuelCheckMenu_OppPlayArea: ; 80da (2:40da) @@ -94,7 +95,9 @@ CheckMenuData: ; (2:4158) Func_8169: ; 8169 (2:4169) INCROM $8169, $818c -Func_818c: ; 818c (2:418c) +; checks if arrows need to be erased in Play Area +; and draws new arrows upon cursor position change +DrawByteToTabulatedPositions_FromCursor: ; 818c (2:418c) push af ld b, a add b @@ -111,35 +114,37 @@ Func_818c: ; 818c (2:418c) ld hl, wLastCursorPosition_YourPlayArea cp [hl] jr z, .unchanged - call Func_81af + call EraseByteFromTabulatedPositions + ld [wLastCursorPosition_YourPlayArea], a - ld b, $f8 ; black cursor tile byte - call Func_81ba + ld b, $f8 ; black arrow tile byte + call DrawByteToTabulatedPositions .unchanged pop af ret ; load white tile in b to erase ; the bytes drawn previously -Func_81af: ; 81af (2:41af) +EraseByteFromTabulatedPositions: ; 81af (2:41af) push af ld a, [wLastCursorPosition_YourPlayArea] ld b, $00 ; white tile - call Func_81ba + call DrawByteToTabulatedPositions pop af ret ; writes tile in b to positions tabulated in -; Data_81d7, with offset calculated from the -; cursor x and y positions -Func_81ba: ; 81ba (2:41ba) +; PlayAreaDrawPositionsPointerTable, with offset calculated from the +; cursor x and y positions in a +DrawByteToTabulatedPositions: ; 81ba (2:41ba) push bc - ld hl, Data_81d7 + ld hl, PlayAreaDrawPositionsPointerTable sla a ld c, a ld b, $00 add hl, bc - ; hl points to Data_81d7 plus offset corresponding to a + ; hl points to PlayAreaDrawPositionsPointerTable + ; plus offset corresponding to a ld a, [hli] ld h, [hl] @@ -158,17 +163,16 @@ Func_81ba: ; 81ba (2:41ba) jr .loop .done ret -; 0x81d7 -Data_81d7: ; 81d7 (2:41d7) - dw Data_81e3.data_81e3 - dw Data_81e3.data_81f0 - dw Data_81e3.data_81f3 - dw Data_81e3.data_81f6 - dw Data_81e3.data_8203 - dw Data_81e3.data_8206 +PlayAreaDrawPositionsPointerTable: ; 81d7 (2:41d7) + dw PlayAreaDrawPositions.data_81e3 + dw PlayAreaDrawPositions.data_81f0 + dw PlayAreaDrawPositions.data_81f3 + dw PlayAreaDrawPositions.data_81f6 + dw PlayAreaDrawPositions.data_8203 + dw PlayAreaDrawPositions.data_8206 -Data_81e3: ; 81e3 (2:41e3) +PlayAreaDrawPositions: ; 81e3 (2:41e3) ; x and y coordinates to draw byte .data_81e3: db 5, 5 @@ -296,7 +300,6 @@ _DrawPlayArea: ; 8211 (2:4211) .lcd call EnableLCD ret -; 0x82b6 Func_82b6: ; 82b6 (2:42b6) INCROM $82b6, $833c @@ -362,9 +365,8 @@ DrawPrizeCards: ; 8464 (2:4464) .done pop af ret -; 0x84b4 -PrizeCardsCoordinateData: +PrizeCardsCoordinateData: ; 0x84b4 (2:44b4) ; x and y coordinates for player prize cards .player db 2, 1 @@ -405,7 +407,6 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) or %11000000 ld [wDuelInitialPrizesUpperBitsSet], a ret -; 0x8511 Func_8511: ; 8511 (2:4511) INCROM $8511, $85aa @@ -428,7 +429,6 @@ LoadCursorTile: ; 8992 (2:4992) ld b, 16 call SafeCopyDataHLtoDE ret -; 0x899e .tile_data: ; 899e (2:499e) db $e0, $c0, $98, $b0, $84, $8c, $83, $82 -- cgit v1.2.3 From dc903e4686c326dd579d2086529937c4c546f80d Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sat, 6 Jul 2019 23:44:00 +0100 Subject: YourPlayArea text data --- src/engine/bank02.asm | 16 +++++++++++----- src/text/text2.asm | 6 +++--- src/text/text_offsets.asm | 6 +++--- 3 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 8d846db..9ca9cfd 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -60,12 +60,13 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DrawWideTextBox xor a ld [wDuelCursorBlinkCounter], a - lb hl, $41, $69 + ld hl, YourPlayAreaMenuData call PlaceTextItems + .asm_8074 call DoFrame xor a - call DrawByteToTabulatedPositions_FromCursor + call DrawArrowsToTabulatedPositions call Func_86ac jr nc, .asm_8074 call EraseByteFromTabulatedPositions @@ -92,12 +93,17 @@ CheckMenuData: ; (2:4158) textitem 12, 16, OppPlayAreaText db $ff -Func_8169: ; 8169 (2:4169) - INCROM $8169, $818c +YourPlayAreaMenuData: ; (2:4169) + textitem 2, 14, YourPokemonText + textitem 12, 14, YourHandText + textitem 2, 16, YourDiscardPileText2 + db $ff + + INCROM $8176, $818c ; checks if arrows need to be erased in Play Area ; and draws new arrows upon cursor position change -DrawByteToTabulatedPositions_FromCursor: ; 818c (2:418c) +DrawArrowsToTabulatedPositions: ; 818c (2:418c) push af ld b, a add b diff --git a/src/text/text2.asm b/src/text/text2.asm index 7227085..b9c6d01 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1715,15 +1715,15 @@ Text023e: ; 3bbf8 (e:7bf8) text "No cards chosen." done -Text023f: ; 3bc0a (e:7c0a) +YourPokemonText: ; 3bc0a (e:7c0a) text "Your Pokémon" done -Text0240: ; 3bc18 (e:7c18) +YourDiscardPileText2: ; 3bc18 (e:7c18) text "Your Discard Pile" done -Text0241: ; 3bc2b (e:7c2b) +YourHandText: ; 3bc2b (e:7c2b) text "Your Hand" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index f024288..fc96176 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -576,9 +576,9 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text023c ; 0x023c textpointer Text023d ; 0x023d textpointer Text023e ; 0x023e - textpointer Text023f ; 0x023f - textpointer Text0240 ; 0x0240 - textpointer Text0241 ; 0x0241 + textpointer YourPokemonText ; 0x023f + textpointer YourDiscardPileText2 ; 0x0240 + textpointer YourHandText ; 0x0241 textpointer Text0242 ; 0x0242 textpointer Text0243 ; 0x0243 textpointer Text0244 ; 0x0244 -- cgit v1.2.3 From d577a77e5e93422d24d1829b72ddda9c9a347e82 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 09:54:40 +0100 Subject: Function to draw Play Area benches --- src/engine/bank02.asm | 190 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 179 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 9ca9cfd..7b526fe 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -283,26 +283,28 @@ _DrawPlayArea: ; 8211 (2:4211) ld a, [wTurnHolder2] cp b jr nz, .not_equal + ld hl, PrizeCardsCoordinateData.player call DrawPrizeCards - lb de, $06, 02 - call Func_837e + lb de, 6, 2 ; coordinates to draw player's active card + call DrawActiveCardGfx lb de, $01, $09 ld c, $04 - call Func_8511 + call DrawPlayAreaBenchCards xor a call Func_85aa jr .lcd .not_equal ld hl, PrizeCardsCoordinateData.opponent call DrawPrizeCards - lb de, $06, $05 - call Func_837e + lb de, 6, 5 ; coordinates to draw opponent's active card + call DrawActiveCardGfx lb de, $01, $02 ld c, $04 - call Func_8511 + call DrawPlayAreaBenchCards ld a, $01 call Func_85aa + .lcd call EnableLCD ret @@ -313,8 +315,58 @@ Func_82b6: ; 82b6 (2:42b6) Func_833c: ; 833c (2:433c) INCROM $833c, $837e -Func_837e: ; 837e (2:437e) - INCROM $837e, $8464 +; draws the active card gfx at coordinates de +; of the player (or opponent) depending on wTurnHolder1 +DrawActiveCardGfx: ; 837e (2:437e) + push de + ld a, DUELVARS_ARENA_CARD + ld l, a + ld a, [wTurnHolder1] + ld h, a + ld a, [hl] + cp $ff + jr z, .no_pokemon + + ld d, a + ld a, [wTurnHolder1] + ld b, a + ldh a, [hWhoseTurn] + cp b + jr nz, .swap + ld a, d + call LoadCardDataToBuffer1_FromDeckIndex + jr .draw +.swap + call SwapTurn + ld a, d + call LoadCardDataToBuffer1_FromDeckIndex + call SwapTurn + +.draw + lb de, $8a, $00 ; destination offset of loaded gfx + ld hl, wLoadedCard1Gfx + ld a, [hli] + ld h, [hl] + ld l, a + lb bc, $30, TILE_SIZE + call LoadCardGfx + bank1call SetBGP6OrSGB3ToCardPalette + bank1call FlushAllPalettesOrSendPal23Packet + pop de + + ; draw card gfx + ld a, $a0 + lb hl, $06, $01 + lb bc, 8, 6 + call FillRectangle + bank1call ApplyBGP6OrSGB3ToCardImage + ret + +.no_pokemon + pop de + ret + + INCROM $83cc, $8464 DrawPrizeCards: ; 8464 (2:4464) push hl @@ -327,7 +379,7 @@ DrawPrizeCards: ; 8464 (2:4464) pop hl ld b, 0 push af -; loop each prize card + 1 +; loop each prize card .loop inc b ld a, [wDuelInitialPrizes] @@ -414,8 +466,124 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ld [wDuelInitialPrizesUpperBitsSet], a ret -Func_8511: ; 8511 (2:4511) - INCROM $8511, $85aa +; draws filled and empty bench slots depending +; on the turn loaded in wTurnHolder1 +; at coordinates loaded in de +; if wTurnHolder1 is different from wTurnHolder2 +; adjusts coordinates of the bench slots +DrawPlayAreaBenchCards: ; 8511 (2:4511) + ld a, [wTurnHolder2] + ld b, a + ld a, [wTurnHolder1] + cp b + jr z, .skip + + ld a, d + add c + add c + add c + add c + ld d, a + ; d = d + 4 * c + + xor a + sub c + ld c, a + ; c = $ff - c + 1 + + ld a, [wTurnHolder1] +.skip + ld h, a + ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + ld b, [hl] + ld l, DUELVARS_BENCH1_CARD_STAGE +.loop1 + dec b ; num of Bench Pokemon left + jr z, .done + + ld a, [hli] + push hl + push bc + sla a + sla a + add $e4 + ; a holds the correct stage gfx tile + ld b, a + push bc + + lb hl, $01, $02 + lb bc, $02, $02 + call FillRectangle + + ld a, [wConsole] + cp CONSOLE_CGB + pop bc + jr nz, .next + + ld a, b + cp $ec ; tile offset of 2 stage + jr z, .two_stage + cp $f0 ; tile offset of 2 stage with no 1 stage + jr z, .two_stage + + ld a, $02 ; blue colour + jr .palette1 +.two_stage + ld a, $01 ; red colour +.palette1 + lb bc, $02, $02 + lb hl, $00, $00 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 + +.next ; adjust coordinates for next card + pop bc + pop hl + ld a, d + add c + ld d, a + ; d = d + c + jr .loop1 + +.done + ld a, [wTurnHolder1] + ld h, a + ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + ld b, [hl] + ld a, MAX_PLAY_AREA_POKEMON + sub b + ret z ; return if already full + + ld b, a + inc b +.loop2 + dec b + ret z + + push bc + ld a, $f4 ; empty bench slot tile + lb hl, $01, $02 + lb bc, $02, $02 + call FillRectangle + + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .not_cgb + + ld a, $02 ; colour + lb bc, $02, $02 + lb hl, $00, $00 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 + +.not_cgb + pop bc + ld a, d + add c + ld d, a + jr .loop2 Func_85aa: ; 85aa (2:45aa) INCROM $85aa, $86ac -- cgit v1.2.3 From 6a4d382fdece6ed96ae08c0a81335309d97c03a8 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 10:46:31 +0100 Subject: Disassemble more YourPlayArea functions --- src/engine/bank02.asm | 165 ++++++++++++++++++++++++++++++++++++++++++++++++-- src/wram.asm | 8 ++- 2 files changed, 167 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 7b526fe..473d69d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -288,7 +288,7 @@ _DrawPlayArea: ; 8211 (2:4211) call DrawPrizeCards lb de, 6, 2 ; coordinates to draw player's active card call DrawActiveCardGfx - lb de, $01, $09 + lb de, 1, 9 ld c, $04 call DrawPlayAreaBenchCards xor a @@ -527,10 +527,10 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) jr z, .two_stage ld a, $02 ; blue colour - jr .palette1 + jr .palette .two_stage ld a, $01 ; red colour -.palette1 +.palette lb bc, $02, $02 lb hl, $00, $00 call BankswitchVRAM1 @@ -586,7 +586,132 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) jr .loop2 Func_85aa: ; 85aa (2:45aa) - INCROM $85aa, $86ac + or a + jr nz, .asm_85b2 + lb hl, $46, $35 + jr .asm_85b5 +.asm_85b2 + lb hl, $46, $3b +.asm_85b5 + ld a, [wTurnHolder1] + ld d, a + ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND + ld a, [de] + ld b, a + ld a, $d0 + call Func_8676 + + ld a, [wTurnHolder1] + ld d, a + ld e, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + ld a, [de] + ld b, a + ld a, DECK_SIZE + sub b + ld b, a + ld a, $d4 + call Func_85e1 + + ld a, [wTurnHolder1] + ld d, a + ld e, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE + ld a, [de] + ld b, a + ld a, $d8 + call Func_85e1 + ret + +Func_85e1: ; 85e1 (2:45e1) + ld d, [hl] + inc hl + ld e, [hl] + inc hl + push hl + push bc + lb hl, $01, $02 + lb bc, $02, $02 + call FillRectangle + + ld a, [wConsole] + cp CONSOLE_CGB + jr nz, .asm_8608 + + ld a, $02 + lb bc, $02, $02 + lb hl, $00, $00 + call BankswitchVRAM1 + call FillRectangle + call BankswitchVRAM0 + +.asm_8608 + inc d + inc d + inc e + call InitTextPrinting + pop bc + ld a, b + call Func_98a6 + + ld hl, $ceb6 + ld a, [hli] + ld b, a + ld a, [hl] + + ld hl, wDefaultText + ld [hl], $05 + inc hl + ld [hl], SYM_CROSS + inc hl + ld [hl], $05 + inc hl + ld [hli], a + ld [hl], $05 + inc hl + ld a, b + ld [hli], a + ld [hl], $00 + ld hl, wDefaultText + call ProcessText + pop hl + ret + + INCROM $8635, $8676 + +Func_8676: ; 8676 (2:4676) + ld d, [hl] + inc hl + ld e, [hl] + inc hl + push hl + push bc + call InitTextPrinting + ld hl, $24e + call ProcessTextFromID + pop bc + ld a, b + call Func_98a6 + ld hl, $ceb6 + ld a, [hli] + ld b, a + ld a, [hl] + ld hl, wDefaultText + ld [hl], $05 + inc hl + ld [hl], $2d + inc hl + ld [hl], $05 + inc hl + ld [hli], a + ld [hl], $05 + inc hl + ld a, b + ld [hli], a + ld [hl], $00 + ld hl, wDefaultText + call ProcessText + pop hl + ret +; 0x86ac Func_86ac: ; 86ac (2:46ac) INCROM $86ac, $8764 @@ -1392,7 +1517,37 @@ Func_9345: ; 9345 (2:5345) INCROM $9345, $9843 Func_9843: ; 9843 (2:5843) - INCROM $9843, $9e41 + INCROM $9843, $98a6 + +Func_98a6: ; 98a6 (2:58a6) + push af + push bc + push de + push hl + ld c, $ff +.asm_98ac + inc c + sub $0a + jr nc, .asm_98ac + jr z, .asm_98b5 + add $0a +.asm_98b5 + add $20 + ld hl, $ceb6 + ld [hli], a + ld a, c + or a + jr z, .asm_98c1 + add $20 +.asm_98c1 + ld [hl], a + pop hl + pop de + pop bc + pop af + ret + + INCROM $98c7, $9e41 Func_9e41: ; 9e41 (2:5e41) INCROM $9e41, $a288 diff --git a/src/wram.asm b/src/wram.asm index 4d10b86..c4cc27d 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1440,7 +1440,13 @@ wceb4:: ; ceb4 wceb5:: ; ceb5 ds $1 - ds $5 +wceb6:: ; ceb6 + ds $1 + +wceb7:: ; ceb7 + ds $1 + + ds $3 wcebb:: ; cebb ds $1 -- cgit v1.2.3 From 457d28cd343ae546023ca717b7a5e6fdb7a79660 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 11:15:12 +0100 Subject: Label data at 8635 --- src/engine/bank02.asm | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 473d69d..3f450e5 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -171,16 +171,16 @@ DrawByteToTabulatedPositions: ; 81ba (2:41ba) ret PlayAreaDrawPositionsPointerTable: ; 81d7 (2:41d7) - dw PlayAreaDrawPositions.data_81e3 - dw PlayAreaDrawPositions.data_81f0 - dw PlayAreaDrawPositions.data_81f3 - dw PlayAreaDrawPositions.data_81f6 - dw PlayAreaDrawPositions.data_8203 - dw PlayAreaDrawPositions.data_8206 + dw PlayAreaDrawPositions.asm_81e3 + dw PlayAreaDrawPositions.asm_81f0 + dw PlayAreaDrawPositions.asm_81f3 + dw PlayAreaDrawPositions.asm_81f6 + dw PlayAreaDrawPositions.asm_8203 + dw PlayAreaDrawPositions.asm_8206 PlayAreaDrawPositions: ; 81e3 (2:41e3) ; x and y coordinates to draw byte -.data_81e3: +.asm_81e3: db 5, 5 db 0, 10 db 4, 10 @@ -189,15 +189,15 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 10 db $ff -.data_81f0: +.asm_81f0: db 14, 7 db $ff -.data_81f3: +.asm_81f3: db 14, 5 db $ff -.data_81f6: +.asm_81f6: db 5, 7 db 0, 3 db 4, 3 @@ -206,11 +206,11 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 3 db $ff -.data_8203: +.asm_8203: db 0, 5 db $ff -.data_8206: +.asm_8206: db 0, 8 db $ff @@ -588,10 +588,10 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) Func_85aa: ; 85aa (2:45aa) or a jr nz, .asm_85b2 - lb hl, $46, $35 + ld hl, Data_8635.asm_8635 jr .asm_85b5 .asm_85b2 - lb hl, $46, $3b + ld hl, Data_8635.asm_863b .asm_85b5 ld a, [wTurnHolder1] ld d, a @@ -675,7 +675,25 @@ Func_85e1: ; 85e1 (2:45e1) pop hl ret - INCROM $8635, $8676 +Data_8635 ; 8635 (2:4635) +.asm_8635 + db 15, 7 + db 15, 2 + db 15, 4 +.asm_863b + db 1, 5 + db 1, 9 + db 1, 7 +.asm_8641 + db 15, 14 + db 15, 9 + db 15, 11 +.asm_8647 + db 0, 2 + db 0, 6 + db 0, 4 + + INCROM $864d, $8676 Func_8676: ; 8676 (2:4676) ld d, [hl] -- cgit v1.2.3 From 6d4808678e1edab777671b66cd34349d073e09de Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 11:46:08 +0100 Subject: Identify CalculateOnesAndTensDigits --- src/engine/bank02.asm | 56 ++++++++++++++++++++++++++++++++------------------- src/wram.asm | 12 ++++++----- 2 files changed, 42 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 3f450e5..a12d327 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -650,22 +650,22 @@ Func_85e1: ; 85e1 (2:45e1) call InitTextPrinting pop bc ld a, b - call Func_98a6 + call CalculateOnesAndTensDigits - ld hl, $ceb6 + ld hl, wOnesAndTensPlace ld a, [hli] ld b, a ld a, [hl] ld hl, wDefaultText - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl ld [hl], SYM_CROSS inc hl - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl ld [hli], a - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl ld a, b ld [hli], a @@ -700,28 +700,32 @@ Func_8676: ; 8676 (2:4676) inc hl ld e, [hl] inc hl + push hl push bc call InitTextPrinting ld hl, $24e call ProcessTextFromID pop bc + ld a, b - call Func_98a6 - ld hl, $ceb6 + call CalculateOnesAndTensDigits + ld hl, wOnesAndTensPlace ld a, [hli] ld b, a ld a, [hl] + ld hl, wDefaultText - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl - ld [hl], $2d + ld [hl], SYM_CROSS inc hl - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl ld [hli], a - ld [hl], $05 + ld [hl], TX_SYMBOL inc hl + ld a, b ld [hli], a ld [hl], $00 @@ -1537,28 +1541,38 @@ Func_9345: ; 9345 (2:5345) Func_9843: ; 9843 (2:5843) INCROM $9843, $98a6 -Func_98a6: ; 98a6 (2:58a6) +; determines the ones and tens digits in a for printing +; the ones place is added $20 so that it maps to a +; numerical character while if the tens is 0, +; it maps to an empty character +CalculateOnesAndTensDigits: ; 98a6 (2:58a6) push af push bc push de push hl ld c, $ff -.asm_98ac +.loop inc c - sub $0a - jr nc, .asm_98ac - jr z, .asm_98b5 - add $0a -.asm_98b5 + sub 10 + jr nc, .loop + jr z, .zero1 + add 10 + ; a = a mod 10 + ; c = floor(a / 10) +.zero1 +; ones digit add $20 - ld hl, $ceb6 + ld hl, wOnesAndTensPlace ld [hli], a + +; tens digit ld a, c or a - jr z, .asm_98c1 + jr z, .zero2 add $20 -.asm_98c1 +.zero2 ld [hl], a + pop hl pop de pop bc diff --git a/src/wram.asm b/src/wram.asm index c4cc27d..79266e9 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1440,11 +1440,13 @@ wceb4:: ; ceb4 wceb5:: ; ceb5 ds $1 -wceb6:: ; ceb6 - ds $1 - -wceb7:: ; ceb7 - ds $1 +; used to store the tens digit and +; ones digit of a value for printing +; the ones digit is added $20 +; ceb6 = ones digit (+ $20) +; ceb7 = tens digit +wOnesAndTensPlace:: ; ceb6 + ds $2 ds $3 -- cgit v1.2.3 From d67a5a155863994fb4161f88551ae103c89b9a02 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 11:57:43 +0100 Subject: Work on Func_85e1 --- src/engine/bank02.asm | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index a12d327..5e79a77 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -610,7 +610,7 @@ Func_85aa: ; 85aa (2:45aa) sub b ld b, a ld a, $d4 - call Func_85e1 + call DrawIconWithValue ld a, [wTurnHolder1] ld d, a @@ -618,10 +618,16 @@ Func_85aa: ; 85aa (2:45aa) ld a, [de] ld b, a ld a, $d8 - call Func_85e1 + call DrawIconWithValue ret -Func_85e1: ; 85e1 (2:45e1) +; draws the interface icon corresponding to +; the gfx tile loaded in a +; also prints the number in decimalcorresponding +; to the value variable loaded in b +; the coordinates in screen are given by [hl] +DrawIconWithValue: ; 85e1 (2:45e1) +; drawing the icon ld d, [hl] inc hl ld e, [hl] @@ -634,7 +640,7 @@ Func_85e1: ; 85e1 (2:45e1) ld a, [wConsole] cp CONSOLE_CGB - jr nz, .asm_8608 + jr nz, .skip ld a, $02 lb bc, $02, $02 @@ -643,7 +649,8 @@ Func_85e1: ; 85e1 (2:45e1) call FillRectangle call BankswitchVRAM0 -.asm_8608 +.skip +; adjust coordinate to the lower right inc d inc d inc e @@ -664,12 +671,14 @@ Func_85e1: ; 85e1 (2:45e1) inc hl 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 [hl], $00 + ld [hli], a ; ones place + ld [hl], TX_END + +; printing the decimal value ld hl, wDefaultText call ProcessText pop hl @@ -728,12 +737,11 @@ Func_8676: ; 8676 (2:4676) ld a, b ld [hli], a - ld [hl], $00 + ld [hl], TX_END ld hl, wDefaultText call ProcessText pop hl ret -; 0x86ac Func_86ac: ; 86ac (2:46ac) INCROM $86ac, $8764 -- cgit v1.2.3 From b0f1126b70af919921cd25889cb9ff17639f9657 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 12:30:53 +0100 Subject: Text label in Func_85aa --- src/engine/bank02.asm | 17 ++++++++++++----- src/engine/bank06.asm | 2 +- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 5e79a77..51fe129 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -593,14 +593,16 @@ Func_85aa: ; 85aa (2:45aa) .asm_85b2 ld hl, Data_8635.asm_863b .asm_85b5 +; hand icon and value ld a, [wTurnHolder1] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND ld a, [de] ld b, a ld a, $d0 - call Func_8676 + call PrintsHandTextAndValue +; deck icon and value ld a, [wTurnHolder1] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK @@ -609,15 +611,16 @@ Func_85aa: ; 85aa (2:45aa) ld a, DECK_SIZE sub b ld b, a - ld a, $d4 + ld a, $d4 ; deck icon call DrawIconWithValue +; discard pile icon and value ld a, [wTurnHolder1] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE ld a, [de] ld b, a - ld a, $d8 + ld a, $d8 ; discard pile icon call DrawIconWithValue ret @@ -704,19 +707,23 @@ Data_8635 ; 8635 (2:4635) INCROM $864d, $8676 -Func_8676: ; 8676 (2:4676) +; prints text HandText2 and a cross with +; decimal value of b +PrintsHandTextAndValue: ; 8676 (2:4676) ld d, [hl] inc hl ld e, [hl] inc hl +; text push hl push bc call InitTextPrinting - ld hl, $24e + ldtx hl, HandText2 call ProcessTextFromID pop bc +; decimal value ld a, b call CalculateOnesAndTensDigits ld hl, wOnesAndTensPlace diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 8d7d110..abb4425 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -228,7 +228,7 @@ Func_180d5: ; 180d5 (6:40d5) call ProcessTextFromID ld hl, hffb0 ld [hl], $01 - ldtx hl, Text024e + ldtx hl, HandText2 call ProcessTextFromID ld hl, hffb0 ld [hl], $00 diff --git a/src/text/text2.asm b/src/text/text2.asm index b9c6d01..07c0da8 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1775,7 +1775,7 @@ Text024d: ; 3bd08 (e:7d08) text "Please choose a Prize." done -Text024e: ; 3bd20 (e:7d20) +HandText2: ; 3bd20 (e:7d20) text "Hand" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index fc96176..4787481 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -591,7 +591,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer GlossaryText ; 0x024b textpointer Text024c ; 0x024c textpointer Text024d ; 0x024d - textpointer Text024e ; 0x024e + textpointer HandText2 ; 0x024e textpointer Text024f ; 0x024f textpointer Text0250 ; 0x0250 textpointer Text0251 ; 0x0251 -- cgit v1.2.3 From 1f8adecb2b92575c66c01538ab39221ab376374d Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 13:00:48 +0100 Subject: Document functions --- src/engine/bank02.asm | 107 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 70 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 51fe129..7cede6e 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -142,6 +142,8 @@ EraseByteFromTabulatedPositions: ; 81af (2:41af) ; writes tile in b to positions tabulated in ; PlayAreaDrawPositionsPointerTable, with offset calculated from the ; cursor x and y positions in a +; input: +; a = cursor position (2*y + x) DrawByteToTabulatedPositions: ; 81ba (2:41ba) push bc ld hl, PlayAreaDrawPositionsPointerTable @@ -171,16 +173,16 @@ DrawByteToTabulatedPositions: ; 81ba (2:41ba) ret PlayAreaDrawPositionsPointerTable: ; 81d7 (2:41d7) - dw PlayAreaDrawPositions.asm_81e3 - dw PlayAreaDrawPositions.asm_81f0 - dw PlayAreaDrawPositions.asm_81f3 - dw PlayAreaDrawPositions.asm_81f6 - dw PlayAreaDrawPositions.asm_8203 - dw PlayAreaDrawPositions.asm_8206 + dw PlayAreaDrawPositions.player_pokemon + dw PlayAreaDrawPositions.player_hand + dw PlayAreaDrawPositions.player_discard_pile + dw PlayAreaDrawPositions.opponent_pokemon + dw PlayAreaDrawPositions.opponent_hand + dw PlayAreaDrawPositions.opponent_discard_pile PlayAreaDrawPositions: ; 81e3 (2:41e3) ; x and y coordinates to draw byte -.asm_81e3: +.player_pokemon: db 5, 5 db 0, 10 db 4, 10 @@ -189,15 +191,15 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 10 db $ff -.asm_81f0: +.player_hand: db 14, 7 db $ff -.asm_81f3: +.player_discard_pile: db 14, 5 db $ff -.asm_81f6: +.opponent_pokemon: db 5, 7 db 0, 3 db 4, 3 @@ -206,16 +208,17 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 3 db $ff -.asm_8203: +.opponent_hand: db 0, 5 db $ff -.asm_8206: +.opponent_discard_pile: db 0, 8 db $ff ; loads the turn holders -; with the turn that a holds +; input: +; a = turn player LoadTurnHolders: ; 8209 (2:4209) ld a, h ld [wTurnHolder1], a @@ -289,10 +292,10 @@ _DrawPlayArea: ; 8211 (2:4211) lb de, 6, 2 ; coordinates to draw player's active card call DrawActiveCardGfx lb de, 1, 9 - ld c, $04 + ld c, 4 call DrawPlayAreaBenchCards xor a - call Func_85aa + call DrawPlayAreaIcons jr .lcd .not_equal ld hl, PrizeCardsCoordinateData.opponent @@ -300,10 +303,10 @@ _DrawPlayArea: ; 8211 (2:4211) lb de, 6, 5 ; coordinates to draw opponent's active card call DrawActiveCardGfx lb de, $01, $02 - ld c, $04 + ld c, 4 call DrawPlayAreaBenchCards ld a, $01 - call Func_85aa + call DrawPlayAreaIcons .lcd call EnableLCD @@ -317,6 +320,8 @@ Func_833c: ; 833c (2:433c) ; draws the active card gfx at coordinates de ; of the player (or opponent) depending on wTurnHolder1 +; input: +; de = coordinates DrawActiveCardGfx: ; 837e (2:437e) push de ld a, DUELVARS_ARENA_CARD @@ -368,6 +373,10 @@ DrawActiveCardGfx: ; 837e (2:437e) INCROM $83cc, $8464 +; draws prize cards depending on the turn +; loaded in wTurnHolder1 +; input: +; hl = coordinates DrawPrizeCards: ; 8464 (2:4464) push hl call GetDuelInitialPrizesUpperBitsSet @@ -468,9 +477,11 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ; draws filled and empty bench slots depending ; on the turn loaded in wTurnHolder1 -; at coordinates loaded in de ; if wTurnHolder1 is different from wTurnHolder2 ; adjusts coordinates of the bench slots +; input: +; de = coordinates to draw bench +; c = spacing between slots DrawPlayAreaBenchCards: ; 8511 (2:4511) ld a, [wTurnHolder2] ld b, a @@ -478,6 +489,7 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) cp b jr z, .skip +; adjust the starting bench position for opponent ld a, d add c add c @@ -486,6 +498,7 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) ld d, a ; d = d + 4 * c +; have the spacing go to the left instead of right xor a sub c ld c, a @@ -585,14 +598,19 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) ld d, a jr .loop2 -Func_85aa: ; 85aa (2:45aa) +; draws Play Area icons depending on value in a +; input: +; a = $00: draws player icons +; a = $01: draws opponent icons +DrawPlayAreaIcons: ; 85aa (2:45aa) or a - jr nz, .asm_85b2 - ld hl, Data_8635.asm_8635 - jr .asm_85b5 -.asm_85b2 - ld hl, Data_8635.asm_863b -.asm_85b5 + jr nz, .opponent + ld hl, PlayAreaIconCoordinates.player + jr .draw +.opponent + ld hl, PlayAreaIconCoordinates.opponent + +.draw ; hand icon and value ld a, [wTurnHolder1] ld d, a @@ -626,9 +644,13 @@ Func_85aa: ; 85aa (2:45aa) ; draws the interface icon corresponding to ; the gfx tile loaded in a -; also prints the number in decimalcorresponding -; to the value variable loaded in b +; also prints the number in decimal corresponding +; to the value loaded in b ; the coordinates in screen are given by [hl] +; input: +; a = tile for the icon +; b = value to print alongside icon +; hl = pointer to coordinates DrawIconWithValue: ; 85e1 (2:45e1) ; drawing the icon ld d, [hl] @@ -687,15 +709,15 @@ DrawIconWithValue: ; 85e1 (2:45e1) pop hl ret -Data_8635 ; 8635 (2:4635) -.asm_8635 - db 15, 7 - db 15, 2 - db 15, 4 -.asm_863b - db 1, 5 - db 1, 9 - db 1, 7 +PlayAreaIconCoordinates ; 8635 (2:4635) +.player + db 15, 7 ; hand + db 15, 2 ; deck + db 15, 4 ; discard pile +.opponent + db 1, 5 ; hand + db 1, 9 ; deck + db 1, 7 ; discard pile .asm_8641 db 15, 14 db 15, 9 @@ -709,6 +731,8 @@ Data_8635 ; 8635 (2:4635) ; prints text HandText2 and a cross with ; decimal value of b +; input +; b = value to print alongside text PrintsHandTextAndValue: ; 8676 (2:4676) ld d, [hl] inc hl @@ -1195,6 +1219,7 @@ ResetCursorPosAndBlink: ; 905a (2:505a) ; handle player input in menu ; works out which cursor coordinate to go to ; and sets carry flag if A or B are pressed +; input ; returns a = $1 if A pressed ; returns a = $ff if B pressed HandleDuelMenuInput2: ; 9065 (2:5065) @@ -1204,6 +1229,7 @@ HandleDuelMenuInput2: ; 9065 (2:5065) ld d, a ld a, [wCursorDuelYPosition] ld e, a + ldh a, [hDPadHeld] or a jr z, .no_pad @@ -1225,12 +1251,14 @@ HandleDuelMenuInput2: ; 9065 (2:5065) ld a, e xor $1 ; flips y coordinate ld e, a + .okay ld a, $1 ld [wcfe3], a push de call DrawCursorEmpty pop de + ld a, d ld [wCursorDuelXPosition], a ld a, e @@ -1247,17 +1275,20 @@ HandleDuelMenuInput2: ; 9065 (2:5065) call Func_90fb scf ret + .a_press call Func_90f7 ld a, $1 call Func_90fb scf ret + .no_input ld a, [wcfe3] or a jr z, .check_blink call PlaySFX + .check_blink ld hl, wDuelCursorBlinkCounter ld a, [hl] @@ -1274,7 +1305,8 @@ DrawCursorEmpty: ; 90d8 (2:50d8) ; fallthrough ; draws in the cursor position -; with byte in a +; input: +; a = tile byte to draw DrawByteInCursor: ld e, a ld a, $a @@ -1560,6 +1592,7 @@ Func_9843: ; 9843 (2:5843) ; the ones place is added $20 so that it maps to a ; numerical character while if the tens is 0, ; it maps to an empty character +; a = value to calculate digits CalculateOnesAndTensDigits: ; 98a6 (2:58a6) push af push bc -- cgit v1.2.3 From 4b2be5326433a1a1cedfc8d16ca310529e48e5f1 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 13:21:33 +0100 Subject: Tidy function tables --- src/engine/bank02.asm | 70 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 7cede6e..d11ed8b 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -18,11 +18,11 @@ _DuelCheckInterface: ; 8000 (2:4000) ld b, a ld a, [wCursorDuelXPosition] add b - ld hl, DuelCheckMenuFunctionTable + ld hl, .table call JumpToFunctionInTable jr _DuelCheckInterface -DuelCheckMenuFunctionTable: ; 8031 (2:4031) +.table: ; 8031 (2:4031) dw DuelCheckMenu_InPlayArea dw DuelCheckMenu_Glossary dw DuelCheckMenu_YourPlayArea @@ -43,7 +43,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) xor a ld [wce5e], a ldh a, [hWhoseTurn] -.asm_8050 +.draw ld h, a ld l, a call LoadTurnHolders @@ -63,25 +63,79 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld hl, YourPlayAreaMenuData call PlaceTextItems -.asm_8074 +.loop call DoFrame xor a call DrawArrowsToTabulatedPositions call Func_86ac - jr nc, .asm_8074 + jr nc, .loop + call EraseByteFromTabulatedPositions cp $ff ret z + ld a, [wCursorDuelYPosition] sla a ld b, a ld a, [wCursorDuelXPosition] add b - lb hl, $40, $98 + ld hl, .table call JumpToFunctionInTable - jr .asm_8050 + jr .draw + +.table ; 8098 (2:8098) + dw OpenDuelScreen.turn_holder_play_area + dw OpenDuelScreen.turn_holder_hand + dw OpenDuelScreen.turn_holder_discard_pile + +OpenDuelScreen: ; 809e (2:409e) +.turn_holder_play_area + ldh a, [hWhoseTurn] + push af + bank1call OpenTurnHolderPlayAreaScreen + pop af + ldh [hWhoseTurn], a + ret + +.non_turn_holder_play_area + ldh a, [hWhoseTurn] + push af + bank1call OpenNonTurnHolderPlayAreaScreen + pop af + ldh [hWhoseTurn], a + ret + +.turn_holder_hand + ldh a, [hWhoseTurn] + push af + bank1call OpenTurnHolderHandScreen_Simple + pop af + ldh [hWhoseTurn], a + ret + +.non_turn_holder_hand + ldh a, [hWhoseTurn] + push af + bank1call OpenNonTurnHolderHandScreen_Simple + pop af + ldh [hWhoseTurn], a + ret - INCROM $8098, $80da +.turn_holder_discard_pile + ldh a, [hWhoseTurn] + push af + bank1call OpenTurnHolderDiscardPileScreen + pop af + ldh [hWhoseTurn], a + ret + +.non_turn_holder_discard_pile + ldh a, [hWhoseTurn] + push af + bank1call OpenNonTurnHolderDiscardPileScreen + pop af + ldh [hWhoseTurn], a + ret DuelCheckMenu_OppPlayArea: ; 80da (2:40da) INCROM $80da, $8158 -- cgit v1.2.3 From bbac07ad938c578dda414ed4c5496d35e24c6a38 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 15:14:04 +0100 Subject: Work on Opponent's Play Area menu --- src/engine/bank02.asm | 90 +++++++++++++++++++++++++++++++++++++++++++++-- src/text/text2.asm | 6 ++-- src/text/text_offsets.asm | 6 ++-- 3 files changed, 94 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index d11ed8b..86acc6d 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -137,8 +137,84 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret +; handles the menu when in the Opponent's Play Area submenu +; if clairvoyance is active, add the option to check +; opponent's hand DuelCheckMenu_OppPlayArea: ; 80da (2:40da) - INCROM $80da, $8158 + call ResetCursorPosAndBlink + call IsClairvoyanceActive + jr c, .clairvoyance1 + + ld a, $80 + ld [wce5e], a + jr .begin +.clairvoyance1 + xor a + ld [wce5e], a + +.begin + ldh a, [hWhoseTurn] +.turns + ld l, a + cp PLAYER_TURN + jr nz, .opponent + ld a, OPPONENT_TURN + ld h, a + jr .cursor +.opponent + ld a, PLAYER_TURN + ld h, a + +.cursor + call LoadTurnHolders + ld a, [wCursorDuelYPosition] + sla a + ld b, a + ld a, [wCursorDuelXPosition] + add b + add $03 + ld [wLastCursorPosition_YourPlayArea], a + + ld b, $f8 ; black arrow tile + call DrawByteToTabulatedPositions + call DrawWideTextBox + + xor a + ld [wDuelCursorBlinkCounter], a + + call IsClairvoyanceActive + jr c, .clairvoyance2 + ld hl, OppPlayAreaMenuData + call PlaceTextItems + jr .loop +.clairvoyance2 + ld hl, OppPlayAreaMenuData_WithClairvoyance + call PlaceTextItems + +.loop + call DoFrame + ld a, $01 + call DrawArrowsToTabulatedPositions + call Func_86ac + jr nc, .loop + + call EraseByteFromTabulatedPositions + cp $ff + ret z + + ld a, [wCursorDuelYPosition] + sla a + ld b, a + ld a, [wCursorDuelXPosition] + add b + ld hl, .table + call JumpToFunctionInTable + jr .turns + +.table + dw OpenDuelScreen.non_turn_holder_play_area + dw OpenDuelScreen.non_turn_holder_hand + dw OpenDuelScreen.non_turn_holder_discard_pile CheckMenuData: ; (2:4158) textitem 2, 14, InPlayAreaText @@ -153,7 +229,16 @@ YourPlayAreaMenuData: ; (2:4169) textitem 2, 16, YourDiscardPileText2 db $ff - INCROM $8176, $818c +OppPlayAreaMenuData: ; (2:4176) + textitem 2, 14, OpponentsPokemonText + textitem 2, 16, OpponentsDiscardPileText2 + db $ff + +OppPlayAreaMenuData_WithClairvoyance: ; (2:4176) + textitem 2, 14, OpponentsPokemonText + textitem 12, 14, OpponentsHandText + textitem 2, 16, OpponentsDiscardPileText2 + db $ff ; checks if arrows need to be erased in Play Area ; and draws new arrows upon cursor position change @@ -198,6 +283,7 @@ EraseByteFromTabulatedPositions: ; 81af (2:41af) ; cursor x and y positions in a ; input: ; a = cursor position (2*y + x) +; b = byte to draw DrawByteToTabulatedPositions: ; 81ba (2:41ba) push bc ld hl, PlayAreaDrawPositionsPointerTable diff --git a/src/text/text2.asm b/src/text/text2.asm index 07c0da8..3c46d8d 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1731,15 +1731,15 @@ Text0242: ; 3bc36 (e:7c36) text "To Your Play Area" done -Text0243: ; 3bc49 (e:7c49) +OpponentsPokemonText: ; 3bc49 (e:7c49) text "Opponent's Pokémon" done -Text0244: ; 3bc5d (e:7c5d) +OpponentsDiscardPileText2: ; 3bc5d (e:7c5d) text "Opponent's Discard Pile" done -Text0245: ; 3bc76 (e:7c76) +OpponentsHandText: ; 3bc76 (e:7c76) text "Opponent Hand" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 4787481..f8c547d 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -580,9 +580,9 @@ TextOffsets:: ; 34000 (d:4000) textpointer YourDiscardPileText2 ; 0x0240 textpointer YourHandText ; 0x0241 textpointer Text0242 ; 0x0242 - textpointer Text0243 ; 0x0243 - textpointer Text0244 ; 0x0244 - textpointer Text0245 ; 0x0245 + textpointer OpponentsPokemonText ; 0x0243 + textpointer OpponentsDiscardPileText2 ; 0x0244 + textpointer OpponentsHandText ; 0x0245 textpointer Text0246 ; 0x0246 textpointer Text0247 ; 0x0247 textpointer YourPlayAreaText ; 0x0248 -- cgit v1.2.3 From cfe78ab4c072977de3371ec1de337582c100f8fa Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 16:07:23 +0100 Subject: Work on Opp. Play Area menu --- src/engine/bank02.asm | 192 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 170 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 86acc6d..40e0344 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -4,12 +4,12 @@ _DuelCheckInterface: ; 8000 (2:4000) ld [wce5e], a call DrawWideTextBox xor a - ld [wDuelCursorBlinkCounter], a + ld [wDuelCursorBlinkCounter], a ; reset cursor blink ld hl, CheckMenuData call PlaceTextItems .loop call DoFrame - call HandleDuelMenuInput2 + call HandleDuelMenuInput_YourPlayArea jr nc, .loop cp $ff ret z ; B was pressed @@ -59,7 +59,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DrawWideTextBox xor a - ld [wDuelCursorBlinkCounter], a + ld [wDuelCursorBlinkCounter], a ; reset cursor blink ld hl, YourPlayAreaMenuData call PlaceTextItems @@ -67,7 +67,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DoFrame xor a call DrawArrowsToTabulatedPositions - call Func_86ac + call HandleDuelMenuInput_OppPlayArea jr nc, .loop call EraseByteFromTabulatedPositions @@ -180,7 +180,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call DrawWideTextBox xor a - ld [wDuelCursorBlinkCounter], a + ld [wDuelCursorBlinkCounter], a ; reset cursor blink call IsClairvoyanceActive jr c, .clairvoyance2 @@ -195,7 +195,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call DoFrame ld a, $01 call DrawArrowsToTabulatedPositions - call Func_86ac + call HandleDuelMenuInput_OppPlayArea jr nc, .loop call EraseByteFromTabulatedPositions @@ -914,8 +914,154 @@ PrintsHandTextAndValue: ; 8676 (2:4676) pop hl ret -Func_86ac: ; 86ac (2:46ac) - INCROM $86ac, $8764 +; handle player input in menu in Opp. Play Area +; works out which cursor coordinate to go to +; and sets carry flag if A or B are pressed +; input +; returns a = $1 if A pressed +; returns a = $ff if B pressed +HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) + xor a + ld [wcfe3], a + ld a, [wCursorDuelXPosition] + ld d, a + ld a, [wCursorDuelYPosition] + ld e, a + + ldh a, [hDPadHeld] + or a + jr z, .asm_870f + +; pad is pressed + ld a, [wce5e] + and $80 + ldh a, [hDPadHeld] + jr nz, .asm_86e8 + bit 5, a + jr nz, .asm_86ce + bit 4, a + jr z, .asm_86e8 +.asm_86ce + ld a, [wce5e] + and %01111111 + or a + jr nz, .asm_86dd + ld a, e + or a + jr z, .asm_86e2 + dec e + jr .asm_86e2 +.asm_86dd + ld a, e + or a + jr nz, .asm_86e2 + inc e +.asm_86e2 + ld a, d + xor $01 + ld d, a + jr .asm_86f9 +.asm_86e8 + bit 6, a + jr nz, .asm_86f0 + bit 7, a + jr z, .asm_870f +.asm_86f0 + ld a, d + or a + jr z, .asm_86f5 + dec d +.asm_86f5 + ld a, e + xor $01 + ld e, a +.asm_86f9 + ld a, $01 + ld [wcfe3], a + push de + call DrawCursorEmpty_OppPlayArea + pop de + + ld a, d + ld [wCursorDuelXPosition], a + ld a, e + ld [wCursorDuelYPosition], a + + xor a + ld [wDuelCursorBlinkCounter], a ; reset cursor blink +.asm_870f + ldh a, [hKeysPressed] + and A_BUTTON | B_BUTTON + jr z, .sfx + and A_BUTTON + jr nz, .a_pressed + +; b pressed + ld a, $ff + call Func_90fb + scf + ret + +.a_pressed + call Func_8760 + ld a, $01 + call Func_90fb + scf + ret + +.sfx + ld a, [wcfe3] + or a + jr z, .draw_cursor + call PlaySFX + +.draw_cursor + ld hl, wDuelCursorBlinkCounter + ld a, [hl] + inc [hl] + and %00001111 + ret nz ; only update cursor if blink's lower nibble is 0 + + ld a, $0f + bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set + jr z, DrawByteInCursor_OppPlayArea +; fallthrough + +; transforms cursor position into coordinates +; in order to draw byte on menu cursor +DrawCursorEmpty_OppPlayArea: ; 8741 (2:4741) + ld a, $00 ; white tile +; fallthrough + +; draws in the cursor position +; input: +; a = tile byte to draw +DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) + ld e, a + ld a, 10 + ld l, a + ld a, [wCursorDuelXPosition] + ld h, a + call HtimesL +; h = 10 * cursor x pos + + ld a, l + add 1 + ld b, a + ld a, [wCursorDuelYPosition] + sla a + add 14 + ld c, a +; c = 11 + 2 * cursor y pos + 14 + +; draw tile loaded in e + ld a, e + call WriteByteToBGMap0 + or a + ret + +Func_8760: ; 8760 (2:4760) + INCROM $8760, $8764 Func_8764: ; 8764 (2:4764) INCROM $8764, $8932 @@ -1093,11 +1239,11 @@ Func_8e42: ; 8e42 (2:4e42) call ResetCursorPosAndBlink .asm_8e4e call DoFrame - call HandleDuelMenuInput2 + call HandleDuelMenuInput_YourPlayArea jp nc, .asm_8e4e cp $ff jr nz, .asm_8e64 - call DrawCursorEmpty + call DrawCursorEmpty_YourPlayArea ld a, [wceb1] jp Func_8dbc .asm_8e64 @@ -1356,13 +1502,13 @@ ResetCursorPosAndBlink: ; 905a (2:505a) ld [wDuelCursorBlinkCounter], a ret -; handle player input in menu +; handle player input in menu in Your Play Area ; works out which cursor coordinate to go to ; and sets carry flag if A or B are pressed ; input ; returns a = $1 if A pressed ; returns a = $ff if B pressed -HandleDuelMenuInput2: ; 9065 (2:5065) +HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) xor a ld [wcfe3], a ld a, [wCursorDuelXPosition] @@ -1396,15 +1542,16 @@ HandleDuelMenuInput2: ; 9065 (2:5065) ld a, $1 ld [wcfe3], a push de - call DrawCursorEmpty + call DrawCursorEmpty_YourPlayArea pop de ld a, d ld [wCursorDuelXPosition], a ld a, e ld [wCursorDuelYPosition], a + xor a - ld [wDuelCursorBlinkCounter], a + ld [wDuelCursorBlinkCounter], a ; reset cursor blink .no_pad ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON @@ -1434,20 +1581,21 @@ HandleDuelMenuInput2: ; 9065 (2:5065) ld a, [hl] inc [hl] and $f - ret nz ; don't update cursor - ld a, $f - bit 4, [hl] - jr z, DrawByteInCursor + ret nz ; only update cursor if blink's lower nibble is 0 + + ld a, $0f + bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set + jr z, DrawByteInCursor_YourPlayArea ; draws in the cursor position -DrawCursorEmpty: ; 90d8 (2:50d8) +DrawCursorEmpty_YourPlayArea: ; 90d8 (2:50d8) ld a, $0 ; empty cursor ; fallthrough ; draws in the cursor position ; input: ; a = tile byte to draw -DrawByteInCursor: +DrawByteInCursor_YourPlayArea: ld e, a ld a, $a ld l, a @@ -1468,7 +1616,7 @@ DrawByteInCursor: Func_90f7: ; 90f7 (2:50f7) ld a, $f - jr DrawByteInCursor + jr DrawByteInCursor_YourPlayArea Func_90fb: ; 90fb (2:50fb) push af @@ -1812,7 +1960,7 @@ Func_b19d: ; b19d (2:719d) ld hl, $7274 call PlaceTextItems call DoFrame - call HandleDuelMenuInput2 + call HandleDuelMenuInput_YourPlayArea jp nc, $71e7 cp $ff jr nz, .asm_b1fa -- cgit v1.2.3 From e3b4ae38b01c2b248ebbf1e02382a1f1da525397 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 16:13:50 +0100 Subject: Label Func_90fb --- src/engine/bank02.asm | 35 ++++++++++++++++++++--------------- src/engine/bank06.asm | 8 ++++---- 2 files changed, 24 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 40e0344..b5c13b1 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -998,14 +998,14 @@ HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) ; b pressed ld a, $ff - call Func_90fb + call PlaySFXConfirmOrCancel scf ret .a_pressed call Func_8760 ld a, $01 - call Func_90fb + call PlaySFXConfirmOrCancel scf ret @@ -1196,14 +1196,14 @@ Func_8dea: ; 8dea (2:4dea) call Func_8ff2 jp nc, Func_8e05 ld a, $ff - call Func_90fb + call PlaySFXConfirmOrCancel call Func_8fe8 scf ret Func_8e05: ; 8e05 (2:4e05) ld a, $1 - call Func_90fb + call PlaySFXConfirmOrCancel call GetPointerToDeckCards push hl call GetPointerToDeckName @@ -1559,14 +1559,14 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) and A_BUTTON jr nz, .a_press ld a, $ff - call Func_90fb + call PlaySFXConfirmOrCancel scf ret .a_press call Func_90f7 ld a, $1 - call Func_90fb + call PlaySFXConfirmOrCancel scf ret @@ -1618,15 +1618,20 @@ Func_90f7: ; 90f7 (2:50f7) ld a, $f jr DrawByteInCursor_YourPlayArea -Func_90fb: ; 90fb (2:50fb) +; plays sound depending on value in a +; input: +; a = $ff: play cancel sound +; a != $ff: play confirm sound +PlaySFXConfirmOrCancel: ; 90fb (2:50fb) push af inc a - jr z, .asm_9103 - ld a, $2 - jr .asm_9105 -.asm_9103 - ld a, $3 -.asm_9105 + jr z, .cancel + ld a, $2 ; confirmation sfx + jr .sfx +.cancel + ld a, $3 ; cancellation sfx + +.sfx call PlaySFX pop af ret @@ -2103,7 +2108,7 @@ Func_ba04: ; ba04 (2:7a04) or a jr z, .asm_ba40 ld a, $1 - call Func_90fb + call PlaySFXConfirmOrCancel call $7653 call Func_8e1f call $7644 @@ -2200,7 +2205,7 @@ Func_ba04: ; ba04 (2:7a04) or a jp z, $7a40 ld a, $1 - call Func_90fb + call PlaySFXConfirmOrCancel call $7653 xor a call $6dfe diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index abb4425..348fce1 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -517,13 +517,13 @@ Func_006_43bb: ; 183bb (6:43bb) and $01 jr nz, .asm_006_447d ld a, $ff - farcall Func_90fb + farcall PlaySFXConfirmOrCancel scf ret .asm_006_447d call Func_006_44a0 ld a, $01 - farcall Func_90fb + farcall PlaySFXConfirmOrCancel ld a, [$ce52] scf ret @@ -609,7 +609,7 @@ Func_006_44c8: ; 184c8 (6:44c8) jr .asm_006_44e5 .asm_006_4518 ld a, $01 - farcall Func_90fb + farcall PlaySFXConfirmOrCancel .asm_006_451e ld a, [wGlossaryPageNo] xor $01 @@ -733,7 +733,7 @@ Func_006_4598: ; 18598 (6:4598) and B_BUTTON jr z, .asm_006_45f7 ld a, $ff - farcall Func_90fb + farcall PlaySFXConfirmOrCancel ret ; unit: 5 bytes. -- cgit v1.2.3 From cdf1288a00520c05b93cbaf7e365aba6fb28f975 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 18:27:56 +0100 Subject: Label more bank 2 --- src/engine/bank02.asm | 122 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 81 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index b5c13b1..b000eb8 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -46,7 +46,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .draw ld h, a ld l, a - call LoadTurnHolders + call DrawPlayArea_LoadTurnHolders ld a, [wCursorDuelYPosition] sla a @@ -67,7 +67,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DoFrame xor a call DrawArrowsToTabulatedPositions - call HandleDuelMenuInput_OppPlayArea + call HandleDuelMenuInput_PlayArea jr nc, .loop call EraseByteFromTabulatedPositions @@ -83,7 +83,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call JumpToFunctionInTable jr .draw -.table ; 8098 (2:8098) +.table ; 8098 (2:4098) dw OpenDuelScreen.turn_holder_play_area dw OpenDuelScreen.turn_holder_hand dw OpenDuelScreen.turn_holder_discard_pile @@ -145,7 +145,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call IsClairvoyanceActive jr c, .clairvoyance1 - ld a, $80 + ld a, %10000000 ld [wce5e], a jr .begin .clairvoyance1 @@ -166,7 +166,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld h, a .cursor - call LoadTurnHolders + call DrawPlayArea_LoadTurnHolders ld a, [wCursorDuelYPosition] sla a ld b, a @@ -195,7 +195,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call DoFrame ld a, $01 call DrawArrowsToTabulatedPositions - call HandleDuelMenuInput_OppPlayArea + call HandleDuelMenuInput_PlayArea jr nc, .loop call EraseByteFromTabulatedPositions @@ -359,7 +359,7 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) ; loads the turn holders ; input: ; a = turn player -LoadTurnHolders: ; 8209 (2:4209) +DrawPlayArea_LoadTurnHolders: ; 8209 (2:4209) ld a, h ld [wTurnHolder1], a ld a, l @@ -452,8 +452,24 @@ _DrawPlayArea: ; 8211 (2:4211) call EnableLCD ret -Func_82b6: ; 82b6 (2:42b6) - INCROM $82b6, $833c +DrawTurnHolderPrizeCards: ; 82b6 (2:42b6) + ld a, [wTurnHolder1] + ld b, a + ld a, [wTurnHolder2] + cp b + jr nz, .not_equal + + ld hl, PrizeCardsCoordinateData.player + call DrawPrizeCards + ret + +.not_equal + ld hl, PrizeCardsCoordinateData.opponent + call DrawPrizeCards + ret + +Func_82ce: ; 82ce (2:42ce) + INCROM $82ce, $833c Func_833c: ; 833c (2:433c) INCROM $833c, $837e @@ -920,7 +936,7 @@ PrintsHandTextAndValue: ; 8676 (2:4676) ; input ; returns a = $1 if A pressed ; returns a = $ff if B pressed -HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) +HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) xor a ld [wcfe3], a ld a, [wCursorDuelXPosition] @@ -928,60 +944,74 @@ HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) ld a, [wCursorDuelYPosition] ld e, a +; d = cursor x position +; e = cursor y position + ldh a, [hDPadHeld] or a - jr z, .asm_870f + jr z, .skip ; pad is pressed ld a, [wce5e] - and $80 + and %10000000 ldh a, [hDPadHeld] - jr nz, .asm_86e8 - bit 5, a - jr nz, .asm_86ce - bit 4, a - jr z, .asm_86e8 -.asm_86ce + jr nz, .check_vertical + bit 5, a ; test left button + jr nz, .horizontal + bit 4, a ; test right button + jr z, .check_vertical + +; handle horizontal input +.horizontal ld a, [wce5e] and %01111111 or a - jr nz, .asm_86dd + jr nz, .asm_86dd ; jump if wce5e's lower 7 bits aren't set ld a, e or a - jr z, .asm_86e2 - dec e - jr .asm_86e2 + jr z, .flip_x ; jump if y is 0 + +; wce5e = %10000000 +; e = 1 + dec e ; change y position + jr .flip_x + .asm_86dd ld a, e or a - jr nz, .asm_86e2 - inc e -.asm_86e2 + jr nz, .flip_x ; jump if y is not 0 + inc e ; change y position +.flip_x ld a, d - xor $01 + xor $01 ; flip x position ld d, a - jr .asm_86f9 -.asm_86e8 - bit 6, a - jr nz, .asm_86f0 - bit 7, a - jr z, .asm_870f -.asm_86f0 + jr .erase + +.check_vertical + bit 6, a ; test up button + jr nz, .vertical + bit 7, a ; test down button + jr z, .skip + +; handle vertical input +.vertical ld a, d or a - jr z, .asm_86f5 + jr z, .flip_y ; jump if x is 0 dec d -.asm_86f5 +.flip_y ld a, e - xor $01 + xor $01 ; flip y position ld e, a -.asm_86f9 + +.erase ld a, $01 ld [wcfe3], a push de call DrawCursorEmpty_OppPlayArea pop de +;update x and y cursor positions ld a, d ld [wCursorDuelXPosition], a ld a, e @@ -989,7 +1019,8 @@ HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) xor a ld [wDuelCursorBlinkCounter], a ; reset cursor blink -.asm_870f + +.skip ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON jr z, .sfx @@ -1003,7 +1034,7 @@ HandleDuelMenuInput_OppPlayArea: ; 86ac (2:46ac) ret .a_pressed - call Func_8760 + call DrawCursor_OppPlayArea ld a, $01 call PlaySFXConfirmOrCancel scf @@ -1060,8 +1091,9 @@ DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) or a ret -Func_8760: ; 8760 (2:4760) - INCROM $8760, $8764 +DrawCursor_OppPlayArea: ; 8760 (2:4760) + ld a, $0f ; load cursor byte + jr DrawByteInCursor_OppPlayArea Func_8764: ; 8764 (2:4764) INCROM $8764, $8932 @@ -1516,6 +1548,9 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ld a, [wCursorDuelYPosition] ld e, a +; d = cursor x position +; e = cursor y position + ldh a, [hDPadHeld] or a jr z, .no_pad @@ -1523,6 +1558,8 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) jr nz, .horizontal bit D_RIGHT_F, a jr z, .check_vertical + +; handle horizontal input .horizontal ld a, d xor $1 ; flips x coordinate @@ -1533,6 +1570,8 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) jr nz, .vertical bit D_DOWN_F, a jr z, .no_pad + +; handle vertical input .vertical ld a, e xor $1 ; flips y coordinate @@ -1545,6 +1584,7 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) call DrawCursorEmpty_YourPlayArea pop de +;update x and y cursor positions ld a, d ld [wCursorDuelXPosition], a ld a, e -- cgit v1.2.3 From 5cb56b12a42ca4db426941fa25421429e620019d Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 18:40:49 +0100 Subject: Disassemble Func_82ce --- src/engine/bank02.asm | 89 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 82 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index b000eb8..627e801 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -427,7 +427,7 @@ _DrawPlayArea: ; 8211 (2:4211) cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData.player + ld hl, PrizeCardsCoordinateData1.player call DrawPrizeCards lb de, 6, 2 ; coordinates to draw player's active card call DrawActiveCardGfx @@ -438,7 +438,7 @@ _DrawPlayArea: ; 8211 (2:4211) call DrawPlayAreaIcons jr .lcd .not_equal - ld hl, PrizeCardsCoordinateData.opponent + ld hl, PrizeCardsCoordinateData1.opponent call DrawPrizeCards lb de, 6, 5 ; coordinates to draw opponent's active card call DrawActiveCardGfx @@ -459,17 +459,72 @@ DrawTurnHolderPrizeCards: ; 82b6 (2:42b6) cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData.player + ld hl, PrizeCardsCoordinateData1.player call DrawPrizeCards ret .not_equal - ld hl, PrizeCardsCoordinateData.opponent + ld hl, PrizeCardsCoordinateData1.opponent call DrawPrizeCards ret Func_82ce: ; 82ce (2:42ce) - INCROM $82ce, $833c + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call EmptyScreen + + ld a, $0a + ld [wDuelDisplayedScreen], a + call Set_OBJ_8x8 + call LoadCursorTile + call LoadSymbolsFont + call LoadDeckAndDiscardPileIcons + + lb de, $80, $9f + call SetupText + +; reset turn holders + ldh a, [hWhoseTurn] + ld [wTurnHolder1], a + ld [wTurnHolder2], a + +; player prize cards + ld hl, PrizeCardsCoordinateData2.player + call DrawPrizeCards + +; player bench cards + lb de, 3, 15 + ld c, 3 + call DrawPlayAreaBenchCards + + ld hl, $4641 + call Func_864d + + call SwapTurn + ldh a, [hWhoseTurn] + ld [wTurnHolder1], a + call SwapTurn + +; opponent prize cards + ld hl, PrizeCardsCoordinateData2.opponent + call DrawPrizeCards + +; opponent bench cards + lb de, 3, 0 + ld c, 3 + call DrawPlayAreaBenchCards + + call SwapTurn + ld hl, $4647 + call Func_864d + call SwapTurn + call Func_83cc + ret Func_833c: ; 833c (2:433c) INCROM $833c, $837e @@ -527,6 +582,7 @@ DrawActiveCardGfx: ; 837e (2:437e) pop de ret +Func_83cc: ; 83cc (2:43cc) INCROM $83cc, $8464 ; draws prize cards depending on the turn @@ -589,7 +645,7 @@ DrawPrizeCards: ; 8464 (2:4464) pop af ret -PrizeCardsCoordinateData: ; 0x84b4 (2:44b4) +PrizeCardsCoordinateData1: ; 0x84b4 (2:44b4) ; x and y coordinates for player prize cards .player db 2, 1 @@ -607,7 +663,25 @@ PrizeCardsCoordinateData: ; 0x84b4 (2:44b4) db 5, 17 db 5, 15 - INCROM $84cc, $84fc + INCROM $84cc, $84e4 + +PrizeCardsCoordinateData2: ; 0x84e4 (2:44e4) +; x and y coordinates for player prize cards +.player + db 9, 1 + db 9, 3 + db 11, 1 + db 11, 3 + db 13, 1 + db 13, 3 +; x and y coordinates for opponent prize cards +.opponent + db 6, 17 + db 6, 15 + db 4, 17 + db 4, 15 + db 2, 17 + db 2, 15 ; calculates bits set up to the number of ; initial prizes, with upper 2 bits set, i.e: @@ -883,6 +957,7 @@ PlayAreaIconCoordinates ; 8635 (2:4635) db 0, 6 db 0, 4 +Func_864d: ; 864d (2:464d) INCROM $864d, $8676 ; prints text HandText2 and a cross with -- cgit v1.2.3 From 97d0be88e7be848bd64e128e0a4dedb7381895f1 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 22:14:04 +0100 Subject: Work on In Play Area menu --- src/engine/bank02.asm | 115 ++++++++++++++++++++++++++++++++++++++++++++------ src/wram.asm | 8 +++- 2 files changed, 108 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 627e801..53ca639 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -430,7 +430,7 @@ _DrawPlayArea: ; 8211 (2:4211) ld hl, PrizeCardsCoordinateData1.player call DrawPrizeCards lb de, 6, 2 ; coordinates to draw player's active card - call DrawActiveCardGfx + call DrawActiveCardGfx_YourOrOppPlayArea lb de, 1, 9 ld c, 4 call DrawPlayAreaBenchCards @@ -441,7 +441,7 @@ _DrawPlayArea: ; 8211 (2:4211) ld hl, PrizeCardsCoordinateData1.opponent call DrawPrizeCards lb de, 6, 5 ; coordinates to draw opponent's active card - call DrawActiveCardGfx + call DrawActiveCardGfx_YourOrOppPlayArea lb de, $01, $02 ld c, 4 call DrawPlayAreaBenchCards @@ -502,7 +502,7 @@ Func_82ce: ; 82ce (2:42ce) ld c, 3 call DrawPlayAreaBenchCards - ld hl, $4641 + ld hl, PlayAreaIconCoordinates.player2 call Func_864d call SwapTurn @@ -520,10 +520,11 @@ Func_82ce: ; 82ce (2:42ce) call DrawPlayAreaBenchCards call SwapTurn - ld hl, $4647 + ld hl, PlayAreaIconCoordinates.opponent2 call Func_864d + call SwapTurn - call Func_83cc + call DrawActiveCardGfx_InPlayArea ret Func_833c: ; 833c (2:433c) @@ -533,7 +534,7 @@ Func_833c: ; 833c (2:433c) ; of the player (or opponent) depending on wTurnHolder1 ; input: ; de = coordinates -DrawActiveCardGfx: ; 837e (2:437e) +DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) push de ld a, DUELVARS_ARENA_CARD ld l, a @@ -582,8 +583,91 @@ DrawActiveCardGfx: ; 837e (2:437e) pop de ret -Func_83cc: ; 83cc (2:43cc) - INCROM $83cc, $8464 +; draws player and opponent arena card graphics +DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) + xor a + ld [wArenaCardsInPlayArea], a + + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + cp $ff ; no pokemon + jr z, .opponent1 + + push af + ld a, [wArenaCardsInPlayArea] + or $01 ; set the player arena Pokemon bit + ld [wArenaCardsInPlayArea], a + pop af + +; load card gfx + call LoadCardDataToBuffer1_FromDeckIndex + lb de, $8a, $00 + ld hl, wLoadedCard1Gfx + ld a, [hli] + ld h, [hl] + ld l, a + lb bc, $30, TILE_SIZE + call LoadCardGfx + bank1call SetBGP6OrSGB3ToCardPalette + +.opponent1 + ld a, DUELVARS_ARENA_CARD + call GetNonTurnDuelistVariable + cp $ff ; no pokemon + jr z, .draw + + push af + ld a, [wArenaCardsInPlayArea] + or $02 ; set the opponent arena Pokemon bit + ld [wArenaCardsInPlayArea], a + pop af + +; load card gfx + call SwapTurn + call LoadCardDataToBuffer1_FromDeckIndex + lb de, $95, $00 + ld hl, wLoadedCard1Gfx + ld a, [hli] + ld h, [hl] + ld l, a + lb bc, $30, TILE_SIZE + call LoadCardGfx + bank1call SetBGP7OrSGB2ToCardPalette + call SwapTurn + +.draw + ld a, [wArenaCardsInPlayArea] + or a + ret z ; no arena cards in play + + bank1call FlushAllPalettesOrSendPal23Packet + ld a, [wArenaCardsInPlayArea] + and $01 ; test player arena card bit + jr z, .opponent2 + +; draw player arena card + ld a, $a0 + lb de, 6, 9 + lb hl, $06, $01 + lb bc, $08, $06 + call FillRectangle + bank1call ApplyBGP6OrSGB3ToCardImage + +.opponent2 + ld a, [wArenaCardsInPlayArea] + and $02 + ret z + +; draw opponent arena card + call SwapTurn + ld a, $50 + lb de, 6, 2 + lb hl, $06, $01 + lb bc, $08, $06 + call FillRectangle + bank1call ApplyBGP7OrSGB2ToCardImage + call SwapTurn + ret ; draws prize cards depending on the turn ; loaded in wTurnHolder1 @@ -835,10 +919,10 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) DrawPlayAreaIcons: ; 85aa (2:45aa) or a jr nz, .opponent - ld hl, PlayAreaIconCoordinates.player + ld hl, PlayAreaIconCoordinates.player1 jr .draw .opponent - ld hl, PlayAreaIconCoordinates.opponent + ld hl, PlayAreaIconCoordinates.opponent1 .draw ; hand icon and value @@ -940,19 +1024,22 @@ DrawIconWithValue: ; 85e1 (2:45e1) ret PlayAreaIconCoordinates ; 8635 (2:4635) -.player +; used for "Your/Opp. Play Area" screen +.player1 db 15, 7 ; hand db 15, 2 ; deck db 15, 4 ; discard pile -.opponent +.opponent1 db 1, 5 ; hand db 1, 9 ; deck db 1, 7 ; discard pile -.asm_8641 + +; used for "In Play Area" screen +.player2 db 15, 14 db 15, 9 db 15, 11 -.asm_8647 +.opponent2 db 0, 2 db 0, 6 db 0, 4 diff --git a/src/wram.asm b/src/wram.asm index 79266e9..79ea9ed 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1303,7 +1303,13 @@ wDuelInitialPrizesUpperBitsSet:: ; ce55 wce59:: ; ce59 ds $1 - ds $4 + ds $3 + +; stores whether there are Pokemon in play area +; player arena Pokemon sets bit 0 +; opponent arena Pokemon sets bit 1 +wArenaCardsInPlayArea:: ; ce5e + ds $1 wce5e:: ; ce5e ds $1 -- cgit v1.2.3 From c78bd6cf30cd0fa4863cc0981734b6395e99b1cd Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 22:30:41 +0100 Subject: Clean up Play Area drawing functions --- src/engine/bank02.asm | 29 +++++++++++++++-------------- src/engine/bank06.asm | 2 +- src/engine/home.asm | 6 +++--- 3 files changed, 19 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 53ca639..30450a5 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -46,7 +46,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .draw ld h, a ld l, a - call DrawPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea_LoadTurnHolders ld a, [wCursorDuelYPosition] sla a @@ -166,7 +166,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld h, a .cursor - call DrawPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea_LoadTurnHolders ld a, [wCursorDuelYPosition] sla a ld b, a @@ -359,16 +359,16 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) ; loads the turn holders ; input: ; a = turn player -DrawPlayArea_LoadTurnHolders: ; 8209 (2:4209) +DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209) ld a, h ld [wTurnHolder1], a ld a, l ld [wTurnHolder2], a ; fallthrough -; loads tiles and icons to display play area +; loads tiles and icons to display your/opp play area ; and draws the screen according to the turn player -_DrawPlayArea: ; 8211 (2:4211) +_DrawYourOrOppPlayArea: ; 8211 (2:4211) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -433,9 +433,9 @@ _DrawPlayArea: ; 8211 (2:4211) call DrawActiveCardGfx_YourOrOppPlayArea lb de, 1, 9 ld c, 4 - call DrawPlayAreaBenchCards + call DrawYourOrOppPlayArea_BenchCards xor a - call DrawPlayAreaIcons + call DrawYourOrOppPlayArea_Icons jr .lcd .not_equal ld hl, PrizeCardsCoordinateData1.opponent @@ -444,9 +444,9 @@ _DrawPlayArea: ; 8211 (2:4211) call DrawActiveCardGfx_YourOrOppPlayArea lb de, $01, $02 ld c, 4 - call DrawPlayAreaBenchCards + call DrawYourOrOppPlayArea_BenchCards ld a, $01 - call DrawPlayAreaIcons + call DrawYourOrOppPlayArea_Icons .lcd call EnableLCD @@ -468,7 +468,8 @@ DrawTurnHolderPrizeCards: ; 82b6 (2:42b6) call DrawPrizeCards ret -Func_82ce: ; 82ce (2:42ce) +; draws icons and cards to the In Play Area screen +_DrawInPlayArea: ; 82ce (2:42ce) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -500,7 +501,7 @@ Func_82ce: ; 82ce (2:42ce) ; player bench cards lb de, 3, 15 ld c, 3 - call DrawPlayAreaBenchCards + call DrawYourOrOppPlayArea_BenchCards ld hl, PlayAreaIconCoordinates.player2 call Func_864d @@ -517,7 +518,7 @@ Func_82ce: ; 82ce (2:42ce) ; opponent bench cards lb de, 3, 0 ld c, 3 - call DrawPlayAreaBenchCards + call DrawYourOrOppPlayArea_BenchCards call SwapTurn ld hl, PlayAreaIconCoordinates.opponent2 @@ -796,7 +797,7 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ; input: ; de = coordinates to draw bench ; c = spacing between slots -DrawPlayAreaBenchCards: ; 8511 (2:4511) +DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) ld a, [wTurnHolder2] ld b, a ld a, [wTurnHolder1] @@ -916,7 +917,7 @@ DrawPlayAreaBenchCards: ; 8511 (2:4511) ; input: ; a = $00: draws player icons ; a = $01: draws opponent icons -DrawPlayAreaIcons: ; 85aa (2:45aa) +DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) or a jr nz, .opponent ld hl, PlayAreaIconCoordinates.player1 diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 348fce1..26c1057 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -1100,7 +1100,7 @@ Func_006_50fb: ; 190fb (6:50fb) ld a, [wWhoseTurn] ld l, a .asm_006_5127 - call DrawPlayArea + call DrawYourOrOppPlayArea pop af ld [wDuelDisplayedScreen], a .asm_006_512e diff --git a/src/engine/home.asm b/src/engine/home.asm index e0e9974..a0f09ff 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9302,16 +9302,16 @@ Func_30a6: ; 30a6 (0:30a6) call BankswitchROM ret -DrawPlayArea: ; 30bc (0:30bc) +DrawYourOrOppPlayArea: ; 30bc (0:30bc) ld a, h ld [wTurnHolder1], a ld a, l ld [wTurnHolder2], a ldh a, [hBankROM] push af - ld a, BANK(_DrawPlayArea) + ld a, BANK(_DrawYourOrOppPlayArea) call BankswitchROM - call _DrawPlayArea + call _DrawYourOrOppPlayArea call DrawWideTextBox pop af call BankswitchROM -- cgit v1.2.3 From 281b96db02f69c558df57a5670b2b1dd3e609d00 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Sun, 7 Jul 2019 22:47:24 +0100 Subject: Label DrawInPlayArea_Icons --- src/engine/bank02.asm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 30450a5..9566659 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -932,7 +932,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND ld a, [de] ld b, a - ld a, $d0 + ld a, $d0 ; hand icon, unused? call PrintsHandTextAndValue ; deck icon and value @@ -1045,8 +1045,37 @@ PlayAreaIconCoordinates ; 8635 (2:4635) db 0, 6 db 0, 4 -Func_864d: ; 864d (2:464d) - INCROM $864d, $8676 +; draws In Play Area icons +DrawInPlayArea_Icons: ; 864d (2:464d) + ldh a, [hWhoseTurn] + ld d, a + ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND + ld a, [de] + ld b, a + ld a, $d0 ; hand icon, unused? + call PrintsHandTextAndValue + +; deck + ldh a, [hWhoseTurn] + ld d, a + ld e, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK + ld a, [de] + ld b, a + ld a, DECK_SIZE + sub b + ld b, a + ld a, $d4 ; deck tile + call DrawIconWithValue + +; discard pile + ldh a, [hWhoseTurn] + ld d, a + ld e, $ed + ld a, [de] + ld b, a + ld a, $d8 ; discard pile tile + call DrawIconWithValue + ret ; prints text HandText2 and a cross with ; decimal value of b -- cgit v1.2.3 From 358b85a879fab87fe3e918fb9cf1691dcf3896a6 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Tue, 9 Jul 2019 00:08:36 +0100 Subject: Work on Func_8764 --- src/engine/bank02.asm | 124 ++++++++++++++++++++++++++++++++++++++++++++-- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 5 +- 4 files changed, 125 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 9566659..b24ed7e 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -358,7 +358,8 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) ; loads the turn holders ; input: -; a = turn player +; h = turn holder 1 +; l = turn holder 2 DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209) ld a, h ld [wTurnHolder1], a @@ -504,7 +505,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) call DrawYourOrOppPlayArea_BenchCards ld hl, PlayAreaIconCoordinates.player2 - call Func_864d + call DrawInPlayArea_Icons call SwapTurn ldh a, [hWhoseTurn] @@ -522,7 +523,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) call SwapTurn ld hl, PlayAreaIconCoordinates.opponent2 - call Func_864d + call DrawInPlayArea_Icons call SwapTurn call DrawActiveCardGfx_InPlayArea @@ -1288,7 +1289,116 @@ DrawCursor_OppPlayArea: ; 8760 (2:4760) jr DrawByteInCursor_OppPlayArea Func_8764: ; 8764 (2:4764) - INCROM $8764, $8932 + call Set_OBJ_8x8 + call LoadCursorTile + +; reset ce5c and ce56 + xor a + ld [$ce5c], a + ld [$ce56], a + +; draw play area screen for the turn player + ldh a, [hWhoseTurn] + ld h, a + ld l, a + call DrawYourOrOppPlayArea_LoadTurnHolders + +.swap + ld a, [$ce56] + or a + jr z, .draw_menu + +; if ce56 != 0, swap turn + call SwapTurn + xor a + ld [$ce56], a + +.draw_menu + xor a + ld hl, PlayAreaMenuParameters + call InitializeMenuParameters + call DrawWideTextBox + + ld hl, YourOrOppPlayAreaData + call PlaceTextItems + +.loop1 + call DoFrame + call HandleMenuInput ; await input + jr nc, .loop1 + cp $ff ; test if input was to cancel + jr z, .loop1 + + call EraseCursor + ldh a, [hCurMenuItem] + or a + jp nz, Func_8883 ; jump if not first option + +; hCurMenuItem = 0 + ld a, [wTurnHolder1] + ld b, a + ldh a, [hWhoseTurn] + cp b + jr z, .asm_87bc + +; switch the play area to draw + ld h, a + ld l, a + call DrawYourOrOppPlayArea_LoadTurnHolders + xor a + ld [$ce56], a + +.asm_87bc + call DrawWideTextBox + lb de, $01, $0e + call InitTextPrinting + ldtx hl, WhichCardWouldYouLikeToSeeText + call ProcessTextFromID + + xor a + ld [$ce52], a + lb de, $48, $c2 + ld hl, wce53 + ld [hl], e + inc hl + ld [hl], d + +.loop2 + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call Func_89ae + jr c, .asm_87e7 + jr .loop2 +.asm_87e7 + cp $ff + jr nz, .asm_87f0 + call Func_8aa1 + jr .swap +.asm_87f0 + ld hl, $47f8 + call JumpToFunctionInTable + jr .loop2 + + INCROM $87f8, $8808 + +YourOrOppPlayAreaData: ; 8808 (2:4808) + textitem 2, 14, YourPlayAreaText + textitem 2, 16, OppPlayAreaText + db $ff + +PlayAreaMenuParameters: ; 8811 (2:4811) + db 1, 14 ; cursor x, cursor y + db 2 ; y displacement between items + db 2 ; number of items + db SYM_CURSOR_R ; cursor tile number + db SYM_SPACE ; tile behind cursor + dw $0000 ; function pointer if non-0 + + INCROM $8819, $8883 + +Func_8883: ; 8883 (2:4883) + INCROM $8883, $8932 Func_8932: ; 8932 (2:4932) INCROM $8932, $8992 @@ -1304,7 +1414,11 @@ LoadCursorTile: ; 8992 (2:4992) db $e0, $c0, $98, $b0, $84, $8c, $83, $82 db $86, $8f, $9d, $be, $f4, $f8, $50, $60 - INCROM $89ae, $8aaa +Func_89ae: ; 89ae (2:49ae) + INCROM $89ae, $8aa1 + +Func_8aa1: ; 8aa1 (2:4aa1) + INCROM $8aa1, $8aaa Func_8aaa: ; 8aaa (2:4aaa) INCROM $8aaa, $8b85 diff --git a/src/text/text2.asm b/src/text/text2.asm index 3c46d8d..a7e4ee1 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1767,7 +1767,7 @@ GlossaryText: ; 3bcdb (e:7cdb) text "Glossary" done -Text024c: ; 3bce5 (e:7ce5) +WhichCardWouldYouLikeToSeeText: ; 3bce5 (e:7ce5) text "Which card would you like to see?" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index f8c547d..b933222 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -589,7 +589,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer OppPlayAreaText ; 0x0249 textpointer InPlayAreaText ; 0x024a textpointer GlossaryText ; 0x024b - textpointer Text024c ; 0x024c + textpointer WhichCardWouldYouLikeToSeeText ; 0x024c textpointer Text024d ; 0x024d textpointer HandText2 ; 0x024e textpointer Text024f ; 0x024f diff --git a/src/wram.asm b/src/wram.asm index 79ea9ed..1838a3e 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1291,7 +1291,10 @@ wTurnHolder1:: ; ce50 wTurnHolder2:: ; ce51 ds $1 - ds $3 + ds $1 + +wce53:: ; ce51 + ds $2 ; same as wDuelInitialPrizes but ; with upper 2 bits set -- cgit v1.2.3 From e41cbb8d5fb584fc04bc810402ee91feb6083728 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 10 Jul 2019 21:30:15 +0100 Subject: Clean up documentation --- src/engine/bank02.asm | 214 ++++++++++++++++++++++++++++++---------------- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 2 +- 4 files changed, 144 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index b24ed7e..4370eaa 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -3,8 +3,10 @@ _DuelCheckInterface: ; 8000 (2:4000) xor a ld [wce5e], a call DrawWideTextBox + +; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a ; reset cursor blink + ld [wDuelCursorBlinkCounter], a ld hl, CheckMenuData call PlaceTextItems .loop @@ -12,8 +14,10 @@ _DuelCheckInterface: ; 8000 (2:4000) call HandleDuelMenuInput_YourPlayArea jr nc, .loop cp $ff - ret z ; B was pressed - ld a, [wCursorDuelYPosition] ; A was pressed + ret z ; B pressed + +; A was pressed + ld a, [wCursorDuelYPosition] sla a ld b, a ld a, [wCursorDuelXPosition] @@ -58,8 +62,10 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DrawByteToTabulatedPositions call DrawWideTextBox + +; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a ; reset cursor blink + ld [wDuelCursorBlinkCounter], a ld hl, YourPlayAreaMenuData call PlaceTextItems @@ -167,21 +173,29 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) .cursor call DrawYourOrOppPlayArea_LoadTurnHolders + +; convert cursor position and +; store it in wLastCursorPosition_YourPlayArea ld a, [wCursorDuelYPosition] sla a ld b, a ld a, [wCursorDuelXPosition] add b - add $03 + add 3 ld [wLastCursorPosition_YourPlayArea], a +; draw black arrows in the Play Area ld b, $f8 ; black arrow tile call DrawByteToTabulatedPositions call DrawWideTextBox - xor a - ld [wDuelCursorBlinkCounter], a ; reset cursor blink +; reset cursor blink + xor a + ld [wDuelCursorBlinkCounter], a + +; place text items depending on clairvoyance +; when active, allows to look at opp. hand call IsClairvoyanceActive jr c, .clairvoyance2 ld hl, OppPlayAreaMenuData @@ -191,17 +205,19 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld hl, OppPlayAreaMenuData_WithClairvoyance call PlaceTextItems +; handle input .loop call DoFrame - ld a, $01 + ld a, 1 call DrawArrowsToTabulatedPositions call HandleDuelMenuInput_PlayArea jr nc, .loop - call EraseByteFromTabulatedPositions cp $ff - ret z + ret z ; B was pressed +; A was pressed +; jump to function corresponding to cursor position ld a, [wCursorDuelYPosition] sla a ld b, a @@ -242,6 +258,8 @@ OppPlayAreaMenuData_WithClairvoyance: ; (2:4176) ; checks if arrows need to be erased in Play Area ; and draws new arrows upon cursor position change +; input: +; a = an initial offset applied to the cursor position DrawArrowsToTabulatedPositions: ; 818c (2:418c) push af ld b, a @@ -254,16 +272,20 @@ DrawArrowsToTabulatedPositions: ; 818c (2:418c) ld a, [wCursorDuelXPosition] add b add c - ; a = 2 * cursor ycoord + cursor xcoord + 3*a +; a = 2 * cursor ycoord + cursor xcoord + 3*a +; if cursor position is different than +; last position, then update arrows ld hl, wLastCursorPosition_YourPlayArea cp [hl] jr z, .unchanged - call EraseByteFromTabulatedPositions +; erase and draw arrows + call EraseByteFromTabulatedPositions ld [wLastCursorPosition_YourPlayArea], a ld b, $f8 ; black arrow tile byte call DrawByteToTabulatedPositions + .unchanged pop af ret @@ -291,9 +313,10 @@ DrawByteToTabulatedPositions: ; 81ba (2:41ba) ld c, a ld b, $00 add hl, bc - ; hl points to PlayAreaDrawPositionsPointerTable - ; plus offset corresponding to a +; hl points to PlayAreaDrawPositionsPointerTable +; plus offset corresponding to a +; load hl with draw position pointer ld a, [hli] ld h, [hl] ld l, a @@ -356,11 +379,12 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 0, 8 db $ff -; loads the turn holders -; input: +; loads tiles and icons to display your/opp play area +; and draws the screen according to the turn player ; h = turn holder 1 ; l = turn holder 2 DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209) +; loads the turn holders ld a, h ld [wTurnHolder1], a ld a, l @@ -387,6 +411,8 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) ld a, [wTurnHolder1] cp PLAYER_TURN jr nz, .opp_turn1 + +; print 's Play Area ld de, wDefaultText call CopyPlayerName jr .get_text_length @@ -401,12 +427,12 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) sub b srl a add 4 - ; a = (6 - name text in tiles) / 2 + 4 +; a = (6 - name text in tiles) / 2 + 4 ld d, a ; text horizontal alignment ld e, $00 call InitTextPrinting - lb hl, $02, $47 + ldtx hl, PlayersPlayAreaText ldh a, [hWhoseTurn] cp PLAYER_TURN jr nz, .opp_turn2 @@ -430,10 +456,10 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) ld hl, PrizeCardsCoordinateData1.player call DrawPrizeCards - lb de, 6, 2 ; coordinates to draw player's active card + lb de, 6, 2 ; coordinates of player's active card call DrawActiveCardGfx_YourOrOppPlayArea - lb de, 1, 9 - ld c, 4 + lb de, 1, 9 ; coordinates of player's bench cards + ld c, 4 ; spacing call DrawYourOrOppPlayArea_BenchCards xor a call DrawYourOrOppPlayArea_Icons @@ -441,10 +467,10 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) .not_equal ld hl, PrizeCardsCoordinateData1.opponent call DrawPrizeCards - lb de, 6, 5 ; coordinates to draw opponent's active card + lb de, 6, 5 ; coordinates of opponent's active card call DrawActiveCardGfx_YourOrOppPlayArea - lb de, $01, $02 - ld c, 4 + lb de, 1, 2 ; coordinates of opponent's bench cards + ld c, 4 ; spacing call DrawYourOrOppPlayArea_BenchCards ld a, $01 call DrawYourOrOppPlayArea_Icons @@ -543,7 +569,7 @@ DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) ld a, [wTurnHolder1] ld h, a ld a, [hl] - cp $ff + cp -1 jr z, .no_pokemon ld d, a @@ -573,9 +599,9 @@ DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) bank1call FlushAllPalettesOrSendPal23Packet pop de - ; draw card gfx +; draw card gfx ld a, $a0 - lb hl, $06, $01 + lb hl, 6, 1 lb bc, 8, 6 call FillRectangle bank1call ApplyBGP6OrSGB3ToCardImage @@ -586,18 +612,19 @@ DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) ret ; draws player and opponent arena card graphics +; in the play area screen DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) xor a ld [wArenaCardsInPlayArea], a ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable - cp $ff ; no pokemon + cp -1 ; no pokemon jr z, .opponent1 push af ld a, [wArenaCardsInPlayArea] - or $01 ; set the player arena Pokemon bit + or %00000001 ; set the player arena Pokemon bit ld [wArenaCardsInPlayArea], a pop af @@ -615,12 +642,12 @@ DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) .opponent1 ld a, DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable - cp $ff ; no pokemon + cp -1 ; no pokemon jr z, .draw push af ld a, [wArenaCardsInPlayArea] - or $02 ; set the opponent arena Pokemon bit + or %00000010 ; set the opponent arena Pokemon bit ld [wArenaCardsInPlayArea], a pop af @@ -644,28 +671,28 @@ DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) bank1call FlushAllPalettesOrSendPal23Packet ld a, [wArenaCardsInPlayArea] - and $01 ; test player arena card bit + and %00000001 ; test player arena card bit jr z, .opponent2 ; draw player arena card ld a, $a0 lb de, 6, 9 - lb hl, $06, $01 - lb bc, $08, $06 + lb hl, 6, 1 + lb bc, 8, 6 call FillRectangle bank1call ApplyBGP6OrSGB3ToCardImage .opponent2 ld a, [wArenaCardsInPlayArea] - and $02 + and %00000010 ; test opponent arena card bit ret z ; draw opponent arena card call SwapTurn ld a, $50 lb de, 6, 2 - lb hl, $06, $01 - lb bc, $08, $06 + lb hl, 6, 1 + lb bc, 8, 6 call FillRectangle bank1call ApplyBGP7OrSGB2ToCardImage call SwapTurn @@ -719,7 +746,7 @@ DrawPrizeCards: ; 8464 (2:4464) jr nz, .not_cgb ld a, $02 ; blue colour lb bc, 2, 2 - lb hl, $00, $00 + lb hl, 0, 0 call BankswitchVRAM1 call FillRectangle call BankswitchVRAM0 @@ -836,12 +863,12 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) sla a sla a add $e4 - ; a holds the correct stage gfx tile +; a holds the correct stage gfx tile ld b, a push bc - lb hl, $01, $02 - lb bc, $02, $02 + lb hl, 1, 2 + lb bc, 2, 2 call FillRectangle ld a, [wConsole] @@ -860,8 +887,8 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) .two_stage ld a, $01 ; red colour .palette - lb bc, $02, $02 - lb hl, $00, $00 + lb bc, 2, 2 + lb hl, 0, 0 call BankswitchVRAM1 call FillRectangle call BankswitchVRAM0 @@ -892,8 +919,8 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) push bc ld a, $f4 ; empty bench slot tile - lb hl, $01, $02 - lb bc, $02, $02 + lb hl, 1, 2 + lb bc, 2, 2 call FillRectangle ld a, [wConsole] @@ -901,8 +928,8 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) jr nz, .not_cgb ld a, $02 ; colour - lb bc, $02, $02 - lb hl, $00, $00 + lb bc, 2, 2 + lb hl, 0, 0 call BankswitchVRAM1 call FillRectangle call BankswitchVRAM0 @@ -958,10 +985,8 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) call DrawIconWithValue ret -; draws the interface icon corresponding to -; the gfx tile loaded in a -; also prints the number in decimal corresponding -; to the value loaded in b +; draws the interface icon corresponding to the gfx tile in a +; also prints the number in decimal corresponding to the value in b ; the coordinates in screen are given by [hl] ; input: ; a = tile for the icon @@ -975,8 +1000,8 @@ DrawIconWithValue: ; 85e1 (2:45e1) inc hl push hl push bc - lb hl, $01, $02 - lb bc, $02, $02 + lb hl, 1, 2 + lb bc, 2, 2 call FillRectangle ld a, [wConsole] @@ -984,8 +1009,8 @@ DrawIconWithValue: ; 85e1 (2:45e1) jr nz, .skip ld a, $02 - lb bc, $02, $02 - lb hl, $00, $00 + lb bc, 2, 2 + lb hl, 0, 0 call BankswitchVRAM1 call FillRectangle call BankswitchVRAM0 @@ -1005,6 +1030,7 @@ DrawIconWithValue: ; 85e1 (2:45e1) ld b, a ld a, [hl] +; loading numerical and cross symbols ld hl, wDefaultText ld [hl], TX_SYMBOL inc hl @@ -1115,6 +1141,7 @@ PrintsHandTextAndValue: ; 8676 (2:4676) ld [hl], TX_SYMBOL inc hl +; draw to screen ld a, b ld [hli], a ld [hl], TX_END @@ -1181,9 +1208,9 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) jr .erase .check_vertical - bit 6, a ; test up button + bit D_UP_F, a jr nz, .vertical - bit 7, a ; test down button + bit D_DOWN_F, a jr z, .skip ; handle vertical input @@ -1210,8 +1237,9 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) ld a, e ld [wCursorDuelYPosition], a +; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a ; reset cursor blink + ld [wDuelCursorBlinkCounter], a .skip ldh a, [hKeysPressed] @@ -1220,7 +1248,7 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) and A_BUTTON jr nz, .a_pressed -; b pressed +; B pressed ld a, $ff call PlaySFXConfirmOrCancel scf @@ -1246,7 +1274,7 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) and %00001111 ret nz ; only update cursor if blink's lower nibble is 0 - ld a, $0f + ld a, $0f ; cursor byte bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set jr z, DrawByteInCursor_OppPlayArea ; fallthrough @@ -1398,7 +1426,44 @@ PlayAreaMenuParameters: ; 8811 (2:4811) INCROM $8819, $8883 Func_8883: ; 8883 (2:4883) - INCROM $8883, $8932 + ld a, [wTurnHolder1] + ld b, a + ldh a, [hWhoseTurn] + cp b + jr nz, .asm_889b + + ld l, a + cp PLAYER_TURN + jr nz, .opponent + ld a, OPPONENT_TURN + jr .draw +.opponent + ld a, PLAYER_TURN +.draw + ld h, a + call DrawYourOrOppPlayArea_LoadTurnHolders + +.asm_889b + call DrawWideTextBox + lb de, $01, $0e + call InitTextPrinting + ldtx hl, WhichCardWouldYouLikeToSeeText + call ProcessTextFromID + + xor a + ld [$ce52], a + ld de, $48fa + ld hl, wce53 + ld [hl], e + inc hl + ld [hl], d + call SwapTurn + + ld a, $01 + ld [$ce56], a + jp Func_8764.loop2 + + INCROM $88c2, $8932 Func_8932: ; 8932 (2:4932) INCROM $8932, $8992 @@ -1880,11 +1945,11 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ; handle vertical input .vertical ld a, e - xor $1 ; flips y coordinate + xor $01 ; flips y coordinate ld e, a .okay - ld a, $1 + ld a, $01 ld [wcfe3], a push de call DrawCursorEmpty_YourPlayArea @@ -1895,9 +1960,10 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ld [wCursorDuelXPosition], a ld a, e ld [wCursorDuelYPosition], a - + +; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a ; reset cursor blink + ld [wDuelCursorBlinkCounter], a .no_pad ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON @@ -1911,7 +1977,7 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) .a_press call Func_90f7 - ld a, $1 + ld a, $01 call PlaySFXConfirmOrCancel scf ret @@ -1926,16 +1992,16 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ld hl, wDuelCursorBlinkCounter ld a, [hl] inc [hl] - and $f + and %00001111 ret nz ; only update cursor if blink's lower nibble is 0 - ld a, $0f + ld a, $0f ; cursor byte bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set jr z, DrawByteInCursor_YourPlayArea ; draws in the cursor position DrawCursorEmpty_YourPlayArea: ; 90d8 (2:50d8) - ld a, $0 ; empty cursor + ld a, $00 ; empty cursor ; fallthrough ; draws in the cursor position @@ -1943,18 +2009,20 @@ DrawCursorEmpty_YourPlayArea: ; 90d8 (2:50d8) ; a = tile byte to draw DrawByteInCursor_YourPlayArea: ld e, a - ld a, $a + ld a, 10 ld l, a ld a, [wCursorDuelXPosition] ld h, a call HtimesL + ld a, l - add $1 + add 1 ld b, a ld a, [wCursorDuelYPosition] sla a - add $e + add 14 ld c, a + ld a, e call WriteByteToBGMap0 or a @@ -2237,7 +2305,7 @@ CalculateOnesAndTensDigits: ; 98a6 (2:58a6) push bc push de push hl - ld c, $ff + ld c, -1 .loop inc c sub 10 diff --git a/src/text/text2.asm b/src/text/text2.asm index a7e4ee1..a4cabe8 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1747,7 +1747,7 @@ Text0246: ; 3bc85 (e:7c85) text "To Opponent's Play Area" done -Text0247: ; 3bc9e (e:7c9e) +PlayersPlayAreaText: ; 3bc9e (e:7c9e) text "'s Play Area" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index b933222..a1e2ef5 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -584,7 +584,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer OpponentsDiscardPileText2 ; 0x0244 textpointer OpponentsHandText ; 0x0245 textpointer Text0246 ; 0x0246 - textpointer Text0247 ; 0x0247 + textpointer PlayersPlayAreaText ; 0x0247 textpointer YourPlayAreaText ; 0x0248 textpointer OppPlayAreaText ; 0x0249 textpointer InPlayAreaText ; 0x024a diff --git a/src/wram.asm b/src/wram.asm index 1838a3e..505587f 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1311,7 +1311,7 @@ wce59:: ; ce59 ; stores whether there are Pokemon in play area ; player arena Pokemon sets bit 0 ; opponent arena Pokemon sets bit 1 -wArenaCardsInPlayArea:: ; ce5e +wArenaCardsInPlayArea:: ; ce5d ds $1 wce5e:: ; ce5e -- cgit v1.2.3 From 556beed77f9832cc480f025db0713599b6f67d7e Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 10 Jul 2019 21:59:10 +0100 Subject: Work on Func_833c --- src/engine/bank02.asm | 76 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 4370eaa..849e53e 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -454,7 +454,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData1.player + ld hl, PrizeCardsCoordinateData_1.player call DrawPrizeCards lb de, 6, 2 ; coordinates of player's active card call DrawActiveCardGfx_YourOrOppPlayArea @@ -465,7 +465,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) call DrawYourOrOppPlayArea_Icons jr .lcd .not_equal - ld hl, PrizeCardsCoordinateData1.opponent + ld hl, PrizeCardsCoordinateData_1.opponent call DrawPrizeCards lb de, 6, 5 ; coordinates of opponent's active card call DrawActiveCardGfx_YourOrOppPlayArea @@ -486,12 +486,12 @@ DrawTurnHolderPrizeCards: ; 82b6 (2:42b6) cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData1.player + ld hl, PrizeCardsCoordinateData_1.player call DrawPrizeCards ret .not_equal - ld hl, PrizeCardsCoordinateData1.opponent + ld hl, PrizeCardsCoordinateData_1.opponent call DrawPrizeCards ret @@ -522,7 +522,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) ld [wTurnHolder2], a ; player prize cards - ld hl, PrizeCardsCoordinateData2.player + ld hl, PrizeCardsCoordinateData_3.player call DrawPrizeCards ; player bench cards @@ -539,7 +539,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) call SwapTurn ; opponent prize cards - ld hl, PrizeCardsCoordinateData2.opponent + ld hl, PrizeCardsCoordinateData_3.opponent call DrawPrizeCards ; opponent bench cards @@ -555,8 +555,38 @@ _DrawInPlayArea: ; 82ce (2:42ce) call DrawActiveCardGfx_InPlayArea ret -Func_833c: ; 833c (2:433c) - INCROM $833c, $837e +; draws players prize cards +; and bench cards +DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) + xor a + ld [wTileMapFill], a + call ZeroObjectPositions + ld a, $01 + ld [wVBlankOAMCopyToggle], a + call DoFrame + call EmptyScreen + call LoadSymbolsFont + call LoadDeckAndDiscardPileIcons + +; player cards + ld a, PLAYER_TURN + ld [wTurnHolder1], a + ld [wTurnHolder2], a + ld hl, PrizeCardsCoordinateData_2.player + call DrawPrizeCards + lb de, 5, 10 ; coordinates + ld c, 3 ; spacing + call DrawYourOrOppPlayArea_BenchCards + +; opponent cards + ld a, OPPONENT_TURN + ld [wTurnHolder1], a + ld hl, PrizeCardsCoordinateData_2.opponent + call DrawPrizeCards + lb de, 1, 0 ; coordinates + ld c, 3 ; spacing + call DrawYourOrOppPlayArea_BenchCards + ret ; draws the active card gfx at coordinates de ; of the player (or opponent) depending on wTurnHolder1 @@ -701,7 +731,7 @@ DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) ; draws prize cards depending on the turn ; loaded in wTurnHolder1 ; input: -; hl = coordinates +; hl = pointer to coordinates DrawPrizeCards: ; 8464 (2:4464) push hl call GetDuelInitialPrizesUpperBitsSet @@ -758,7 +788,7 @@ DrawPrizeCards: ; 8464 (2:4464) pop af ret -PrizeCardsCoordinateData1: ; 0x84b4 (2:44b4) +PrizeCardsCoordinateData_1: ; 0x84b4 (2:44b4) ; x and y coordinates for player prize cards .player db 2, 1 @@ -776,9 +806,25 @@ PrizeCardsCoordinateData1: ; 0x84b4 (2:44b4) db 5, 17 db 5, 15 - INCROM $84cc, $84e4 - -PrizeCardsCoordinateData2: ; 0x84e4 (2:44e4) +PrizeCardsCoordinateData_2: +; x and y coordinates for player prize cards +.player + db 6, 0 + db 6, 2 + db 8, 0 + db 8, 2 + db 10, 0 + db 10, 2 +; x and y coordinates for opponent prize cards +.opponent + db 4, 18 + db 4, 16 + db 2, 18 + db 2, 16 + db 0, 18 + db 0, 16 + +PrizeCardsCoordinateData_3: ; 0x84e4 (2:44e4) ; x and y coordinates for player prize cards .player db 9, 1 @@ -1176,9 +1222,9 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) and %10000000 ldh a, [hDPadHeld] jr nz, .check_vertical - bit 5, a ; test left button + bit D_LEFT_F, a ; test left button jr nz, .horizontal - bit 4, a ; test right button + bit D_RIGHT_F, a ; test right button jr z, .check_vertical ; handle horizontal input -- cgit v1.2.3 From eaa72e0cfb141eac96969cb361fa84dfc8907b05 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 10 Jul 2019 22:42:22 +0100 Subject: Work on Func_8764 --- src/engine/bank02.asm | 18 +++++++++--------- src/engine/home.asm | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 849e53e..0f78d45 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -557,7 +557,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) ; draws players prize cards ; and bench cards -DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) +_DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -1361,11 +1361,11 @@ DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) DrawCursor_OppPlayArea: ; 8760 (2:4760) ld a, $0f ; load cursor byte jr DrawByteInCursor_OppPlayArea +; fallthrough Func_8764: ; 8764 (2:4764) call Set_OBJ_8x8 call LoadCursorTile - ; reset ce5c and ce56 xor a ld [$ce5c], a @@ -1381,7 +1381,6 @@ Func_8764: ; 8764 (2:4764) ld a, [$ce56] or a jr z, .draw_menu - ; if ce56 != 0, swap turn call SwapTurn xor a @@ -1400,7 +1399,7 @@ Func_8764: ; 8764 (2:4764) call DoFrame call HandleMenuInput ; await input jr nc, .loop1 - cp $ff ; test if input was to cancel + cp $ff jr z, .loop1 call EraseCursor @@ -1413,7 +1412,7 @@ Func_8764: ; 8764 (2:4764) ld b, a ldh a, [hWhoseTurn] cp b - jr z, .asm_87bc + jr z, .text ; switch the play area to draw ld h, a @@ -1422,7 +1421,7 @@ Func_8764: ; 8764 (2:4764) xor a ld [$ce56], a -.asm_87bc +.text call DrawWideTextBox lb de, $01, $0e call InitTextPrinting @@ -1476,7 +1475,7 @@ Func_8883: ; 8883 (2:4883) ld b, a ldh a, [hWhoseTurn] cp b - jr nz, .asm_889b + jr nz, .text ld l, a cp PLAYER_TURN @@ -1485,11 +1484,12 @@ Func_8883: ; 8883 (2:4883) jr .draw .opponent ld a, PLAYER_TURN + .draw ld h, a call DrawYourOrOppPlayArea_LoadTurnHolders -.asm_889b +.text call DrawWideTextBox lb de, $01, $0e call InitTextPrinting @@ -1503,8 +1503,8 @@ Func_8883: ; 8883 (2:4883) ld [hl], e inc hl ld [hl], d - call SwapTurn + call SwapTurn ld a, $01 ld [$ce56], a jp Func_8764.loop2 diff --git a/src/engine/home.asm b/src/engine/home.asm index a0f09ff..47f28f3 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9317,12 +9317,12 @@ DrawYourOrOppPlayArea: ; 30bc (0:30bc) call BankswitchROM ret -Func_30d7: ; 30d7 (0:30d7) +DrawPlayersPrizeAndBenchCards: ; 30d7 (0:30d7) ldh a, [hBankROM] push af - ld a, BANK(Func_833c) + ld a, BANK(_DrawPlayersPrizeAndBenchCards) call BankswitchROM - call Func_833c + call _DrawPlayersPrizeAndBenchCards pop af call BankswitchROM ret -- cgit v1.2.3 From fdbe48673e9df2068c70453debca1234e48c82c5 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 10 Jul 2019 22:48:53 +0100 Subject: Disassemble Func_89ae --- src/engine/bank02.asm | 150 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 0f78d45..66f6f77 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1526,10 +1526,156 @@ LoadCursorTile: ; 8992 (2:4992) db $86, $8f, $9d, $be, $f4, $f8, $50, $60 Func_89ae: ; 89ae (2:49ae) - INCROM $89ae, $8aa1 + xor a + ld [wcfe3], a + ld hl, wce53 + ld e, [hl] + inc hl + ld d, [hl] + ld a, [$ce52] + ld [wce61], a + ld l, a + ld h, $07 + call HtimesL + add hl, de + ldh a, [hDPadHeld] + or a + jp z, .asm_8a4f + inc hl + inc hl + inc hl + bit 6, a + jr z, .asm_89d5 + ld a, [hl] + jr .asm_89eb +.asm_89d5 + inc hl + bit 7, a + jr z, .asm_89dd + ld a, [hl] + jr .asm_89eb +.asm_89dd + inc hl + bit 4, a + jr z, .asm_89e5 + ld a, [hl] + jr .asm_89eb +.asm_89e5 + inc hl + bit 5, a + jr z, .asm_8a4f + ld a, [hl] +.asm_89eb + ld [$ce52], a + cp $08 + jr nc, .asm_8a46 + ld b, $01 +.asm_89f4 + or a + jr z, .asm_89fc + sla b + dec a + jr .asm_89f4 +.asm_89fc + ld a, [wDuelInitialPrizesUpperBitsSet] + and b + jr nz, .asm_8a46 + ld a, [wce61] + cp $06 + jr nz, Func_89ae + ldh a, [hDPadHeld] + bit 4, a + jr nz, .asm_8a13 + bit 5, a + jr z, Func_89ae +.asm_8a13 + ld a, [wDuelInitialPrizes] + cp $05 + jr nc, .asm_8a46 + ld a, [$ce52] + cp $05 + jr nz, .asm_8a28 + ld a, $03 + ld [$ce52], a + jr .asm_8a2d +.asm_8a28 + ld a, $02 + ld [$ce52], a +.asm_8a2d + ld a, [wDuelInitialPrizes] + cp $03 + jr nc, .asm_8a3c + ld a, [$ce52] + sub $02 + ld [$ce52], a +.asm_8a3c + ld a, [$ce52] + ld [wce61], a + ld b, $01 + jr .asm_89f4 +.asm_8a46 + ld a, $01 + ld [wcfe3], a + xor a + ld [wDuelCursorBlinkCounter], a +.asm_8a4f + ldh a, [hKeysPressed] + and $03 + jr z, .asm_8a6d + and $01 + jr nz, .asm_8a60 + ld a, $ff + call PlaySFXConfirmOrCancel + scf + ret +.asm_8a60 + call Func_8a82 + ld a, $01 + call PlaySFXConfirmOrCancel + ld a, [$ce52] + scf + ret +.asm_8a6d + ld a, [wcfe3] + or a + jr z, .asm_8a76 + call PlaySFX +.asm_8a76 + ld hl, wDuelCursorBlinkCounter + ld a, [hl] + inc [hl] + and $0f + ret nz + bit 4, [hl] + jr nz, Func_8aa1 + +Func_8a82 ; 8a82 (2:4a82) + call ZeroObjectPositions + ld hl, wce53 + ld e, [hl] + inc hl + ld d, [hl] + ld a, [$ce52] + ld l, a + ld h, $07 + call HtimesL + add hl, de + ld d, [hl] + inc hl + ld e, [hl] + inc hl + ld b, [hl] + ld c, $00 + call SetOneObjectAttributes + or a + ret Func_8aa1: ; 8aa1 (2:4aa1) - INCROM $8aa1, $8aaa + call ZeroObjectPositions + ld a, $01 + ld [wVBlankOAMCopyToggle], a + ret +; 0x8aaa Func_8aaa: ; 8aaa (2:4aaa) INCROM $8aaa, $8b85 -- cgit v1.2.3 From c9c998baa4757a231903aa5127b6bc11b49489f0 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 11 Jul 2019 22:03:52 +0100 Subject: Label wPrizeCardCursorPosition --- src/engine/bank02.asm | 60 ++++++++++++++++++++++++++++++--------------------- src/engine/bank06.asm | 52 ++++++++++++++++++++++---------------------- src/wram.asm | 5 ++++- 3 files changed, 66 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 66f6f77..5d3814c 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1295,7 +1295,7 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) jr nz, .a_pressed ; B pressed - ld a, $ff + ld a, $ff ; cancel call PlaySFXConfirmOrCancel scf ret @@ -1429,7 +1429,7 @@ Func_8764: ; 8764 (2:4764) call ProcessTextFromID xor a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a lb de, $48, $c2 ld hl, wce53 ld [hl], e @@ -1497,7 +1497,7 @@ Func_8883: ; 8883 (2:4883) call ProcessTextFromID xor a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a ld de, $48fa ld hl, wce53 ld [hl], e @@ -1528,45 +1528,51 @@ LoadCursorTile: ; 8992 (2:4992) Func_89ae: ; 89ae (2:49ae) xor a ld [wcfe3], a + ld hl, wce53 ld e, [hl] inc hl ld d, [hl] - ld a, [$ce52] + + ld a, [wPrizeCardCursorPosition] ld [wce61], a ld l, a - ld h, $07 + ld h, 7 call HtimesL add hl, de +; hl = [wce53] + 7 * wce52 + ldh a, [hDPadHeld] or a jp z, .asm_8a4f + inc hl inc hl inc hl - bit 6, a + bit D_UP_F, a jr z, .asm_89d5 ld a, [hl] jr .asm_89eb + .asm_89d5 inc hl - bit 7, a + bit D_DOWN_F, a jr z, .asm_89dd ld a, [hl] jr .asm_89eb .asm_89dd inc hl - bit 4, a + bit D_RIGHT_F, a jr z, .asm_89e5 ld a, [hl] jr .asm_89eb .asm_89e5 inc hl - bit 5, a + bit D_LEFT_F, a jr z, .asm_8a4f ld a, [hl] .asm_89eb - ld [$ce52], a + ld [wPrizeCardCursorPosition], a cp $08 jr nc, .asm_8a46 ld b, $01 @@ -1592,47 +1598,51 @@ Func_89ae: ; 89ae (2:49ae) ld a, [wDuelInitialPrizes] cp $05 jr nc, .asm_8a46 - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] cp $05 jr nz, .asm_8a28 ld a, $03 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_8a2d .asm_8a28 ld a, $02 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a .asm_8a2d ld a, [wDuelInitialPrizes] cp $03 jr nc, .asm_8a3c - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] sub $02 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a .asm_8a3c - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld [wce61], a ld b, $01 jr .asm_89f4 .asm_8a46 ld a, $01 ld [wcfe3], a + +; reset cursor blink xor a ld [wDuelCursorBlinkCounter], a + .asm_8a4f ldh a, [hKeysPressed] - and $03 + and A_BUTTON | B_BUTTON jr z, .asm_8a6d - and $01 + and A_BUTTON jr nz, .asm_8a60 - ld a, $ff + ld a, $ff ; cancel call PlaySFXConfirmOrCancel scf ret + .asm_8a60 call Func_8a82 ld a, $01 call PlaySFXConfirmOrCancel - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] scf ret .asm_8a6d @@ -1655,11 +1665,13 @@ Func_8a82 ; 8a82 (2:4a82) ld e, [hl] inc hl ld d, [hl] - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld l, a - ld h, $07 + ld h, 7 call HtimesL add hl, de +; hl = [wce53] + 7 * wce52 + ld d, [hl] inc hl ld e, [hl] @@ -1790,7 +1802,7 @@ Func_8dea: ; 8dea (2:4dea) ld [wceb1], a call Func_8ff2 jp nc, Func_8e05 - ld a, $ff + ld a, $ff ; cancel call PlaySFXConfirmOrCancel call Func_8fe8 scf @@ -2162,7 +2174,7 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) jr z, .no_input and A_BUTTON jr nz, .a_press - ld a, $ff + ld a, $ff ; cancel call PlaySFXConfirmOrCancel scf ret diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 26c1057..2aa63af 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -149,7 +149,7 @@ Func_18086: ; 18086 (6:4086) Func_180d5: ; 180d5 (6:40d5) ld a, $05 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a .asm_006_40da xor a ld [wDuelCursorBlinkCounter], a @@ -166,7 +166,7 @@ Func_180d5: ; 180d5 (6:40d5) ld [hl], e inc hl ld [hl], d - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] call .asm_006_4171 .asm_006_40fe ld a, $01 @@ -182,11 +182,11 @@ Func_180d5: ; 180d5 (6:40d5) and $04 jr nz, .asm_006_4148 .asm_006_4118 - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld [$ce58], a call Func_006_43bb jr c, .asm_006_4139 - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] cp $10 jp z, .asm_006_41f8 cp $11 @@ -213,12 +213,12 @@ Func_180d5: ; 180d5 (6:40d5) call Func_006_44bf lb de, $38, $9f call SetupText - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld [$ce57], a ld hl, .jump_table call JumpToFunctionInTable ld a, [$ce57] - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jp .asm_006_40da .asm_006_4171 ; 18171 (6:4171) push af @@ -249,7 +249,7 @@ Func_180d5: ; 180d5 (6:40d5) ld a, l cp $06 jr nc, .asm_006_41e3 - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] cp $06 jr nc, .asm_006_41c2 ld a, l @@ -277,7 +277,7 @@ Func_180d5: ; 180d5 (6:40d5) call ProcessText ret .asm_006_41e3 - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] cp $08 jr nc, .asm_006_41ee call PrintTextNoDelay @@ -296,7 +296,7 @@ Func_180d5: ; 180d5 (6:40d5) pop af ldh [hWhoseTurn], a ld a, [$ce57] - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jp .asm_006_40da .asm_006_4210 lb de, $38, $9f @@ -307,7 +307,7 @@ Func_180d5: ; 180d5 (6:40d5) pop af ldh [hWhoseTurn], a ld a, [$ce57] - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jp .asm_006_40da .jump_table ; (6:4228) dw Func_006_4248 @@ -328,7 +328,7 @@ Func_180d5: ; 180d5 (6:40d5) dw Func_006_426a Func_006_4248: - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] inc a cp PLAY_AREA_BENCH_5 + $01 jr nz, .asm_006_4251 @@ -347,7 +347,7 @@ Func_006_4248: ret Func_006_426a: - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] sub $08 or a jr z, .asm_006_4274 @@ -410,7 +410,7 @@ Func_006_43bb: ; 183bb (6:43bb) ld e, [hl] inc hl ld d, [hl] - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld l, a .asm_006_43c9 ld h, $07 @@ -446,10 +446,10 @@ Func_006_43bb: ; 183bb (6:43bb) ld a, [hl] .asm_006_43f5 push af - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld [$ce57], a pop af - ld [$ce52], a + ld [wPrizeCardCursorPosition], a cp $05 jr c, .asm_006_440e cp $0b @@ -463,23 +463,23 @@ Func_006_43bb: ; 183bb (6:43bb) dec a jr nz, .asm_006_441d ld a, $10 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_006_4462 .asm_006_441d ld b, a - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] cp b jr c, .asm_006_4462 ldh a, [hDPadHeld] bit D_RIGHT_F, a jr z, .asm_006_4430 xor a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_006_4462 .asm_006_4430: ld a, b dec a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_006_4462 .asm_006_4437: ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -487,11 +487,11 @@ Func_006_43bb: ; 183bb (6:43bb) dec a jr nz, .asm_006_4446 ld a, $11 - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_006_4462 .asm_006_4446 ld b, a - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] sub $0b cp b jr c, .asm_006_4462 @@ -499,12 +499,12 @@ Func_006_43bb: ; 183bb (6:43bb) bit D_LEFT_F, a jr z, .asm_006_445c ld a, $0b - ld [$ce52], a + ld [wPrizeCardCursorPosition], a jr .asm_006_4462 .asm_006_445c ld a, b add $0a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a .asm_006_4462 ld a, $01 ld [wcfe3], a @@ -524,7 +524,7 @@ Func_006_43bb: ; 183bb (6:43bb) call Func_006_44a0 ld a, $01 farcall PlaySFXConfirmOrCancel - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] scf ret .asm_006_448b @@ -547,7 +547,7 @@ Func_006_44a0: ; 184a0 (6:44a0) ld e, [hl] inc hl ld d, [hl] - ld a, [$ce52] + ld a, [wPrizeCardCursorPosition] ld l, a ld h, $07 call HtimesL @@ -573,7 +573,7 @@ Func_006_44c8: ; 184c8 (6:44c8) ld [wGlossaryPageNo], a call Func_006_452b xor a - ld [$ce52], a + ld [wPrizeCardCursorPosition], a ld de, $4c8e ld hl, $ce53 ld [hl], e diff --git a/src/wram.asm b/src/wram.asm index 505587f..8708005 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1291,9 +1291,12 @@ wTurnHolder1:: ; ce50 wTurnHolder2:: ; ce51 ds $1 +; holds the position of the cursor +; when selecting a prize card +wPrizeCardCursorPosition:: ds $1 -wce53:: ; ce51 +wce53:: ; ce53 ds $2 ; same as wDuelInitialPrizes but -- cgit v1.2.3 From bf6fed02f9e503a51a25171ceb286a81c246032f Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Thu, 11 Jul 2019 22:26:42 +0100 Subject: Disassemble Func_8819 --- src/engine/bank02.asm | 72 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 5d3814c..2aff6a0 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1449,11 +1449,16 @@ Func_8764: ; 8764 (2:4764) call Func_8aa1 jr .swap .asm_87f0 - ld hl, $47f8 + ld hl, .asm_87f8 call JumpToFunctionInTable jr .loop2 - INCROM $87f8, $8808 +.asm_87f8 +REPT 6 + dw Func_8819 +ENDR + dw Func_8819.asm_883C + dw Func_8819.asm_8849 YourOrOppPlayAreaData: ; 8808 (2:4808) textitem 2, 14, YourPlayAreaText @@ -1468,7 +1473,68 @@ PlayAreaMenuParameters: ; 8811 (2:4811) db SYM_SPACE ; tile behind cursor dw $0000 ; function pointer if non-0 - INCROM $8819, $8883 +Func_8819: ; 8819 (2:4819) + ld a, [wPrizeCardCursorPosition] + ld c, a + ld b, $01 +.asm_881f + or a + jr z, .asm_8827 + sla b + dec a + jr .asm_881f +.asm_8827 + ld a, $ec + call GetTurnDuelistVariable + and b + ret z + ld a, c + add $40 + ld [$ce5c], a + ld a, c + add $3c + call GetTurnDuelistVariable + jr .asm_8855 + +.asm_883C: + call CreateHandCardList + ret c + ld hl, wDuelTempList + call ShuffleCards + ld a, [hl] + jr .asm_8855 + +.asm_8849: + call CreateDeckCardList + ret c + ld a, $7f + ld [$ce5c], a + ld a, [wDuelTempList] +.asm_8855 + ld b, a + ld a, [$ce5c] + or a + jr nz, .asm_8860 + ld a, b + ld [$ce5c], a +.asm_8860 + ld a, b + call LoadCardDataToBuffer1_FromDeckIndex + call Set_OBJ_8x16 + bank1call OpenCardPage_FromHand + ld a, $01 + ld [wVBlankOAMCopyToggle], a + pop af + ld a, [$ce56] + or a + jr z, .asm_887f + call SwapTurn + ld a, [$ce5c] + or $80 + ret +.asm_887f + ld a, [$ce5c] + ret Func_8883: ; 8883 (2:4883) ld a, [wTurnHolder1] -- cgit v1.2.3 From cd3ec421cb23b6414ed3976c6bca394dec8d84c2 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Mon, 15 Jul 2019 19:49:20 +0100 Subject: Work on Func_8819 --- src/engine/bank02.asm | 52 +++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 2aff6a0..7a5a78a 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1363,6 +1363,8 @@ DrawCursor_OppPlayArea: ; 8760 (2:4760) jr DrawByteInCursor_OppPlayArea ; fallthrough +; seems to be function to deal with the Peek menu +; to select a prize card to view Func_8764: ; 8764 (2:4764) call Set_OBJ_8x8 call LoadCursorTile @@ -1457,8 +1459,8 @@ Func_8764: ; 8764 (2:4764) REPT 6 dw Func_8819 ENDR - dw Func_8819.asm_883C - dw Func_8819.asm_8849 + dw Func_883C + dw Func_8849 YourOrOppPlayAreaData: ; 8808 (2:4808) textitem 2, 14, YourPlayAreaText @@ -1477,47 +1479,59 @@ Func_8819: ; 8819 (2:4819) ld a, [wPrizeCardCursorPosition] ld c, a ld b, $01 -.asm_881f + +; left-shift b a number of times +; corresponding to this prize card +.loop or a jr z, .asm_8827 sla b dec a - jr .asm_881f + jr .loop + .asm_8827 - ld a, $ec + ld a, DUELVARS_PRIZES call GetTurnDuelistVariable and b - ret z + ret z ; return if prize card taken + ld a, c add $40 ld [$ce5c], a ld a, c - add $3c + add DUELVARS_PRIZE_CARDS call GetTurnDuelistVariable - jr .asm_8855 + jr Func_8855 -.asm_883C: +Func_883C: call CreateHandCardList ret c ld hl, wDuelTempList call ShuffleCards ld a, [hl] - jr .asm_8855 + jr Func_8855 -.asm_8849: +Func_8849: call CreateDeckCardList ret c - ld a, $7f + ld a, %01111111 ld [$ce5c], a ld a, [wDuelTempList] -.asm_8855 +; fallthrough + +; input: +; a = deck index of card to be loaded +; output: +; a = ce5c +; with upper bit set if turn was swapped +Func_8855: ld b, a ld a, [$ce5c] or a - jr nz, .asm_8860 + jr nz, .display ld a, b ld [$ce5c], a -.asm_8860 +.display ld a, b call LoadCardDataToBuffer1_FromDeckIndex call Set_OBJ_8x16 @@ -1525,14 +1539,16 @@ Func_8819: ; 8819 (2:4819) ld a, $01 ld [wVBlankOAMCopyToggle], a pop af + +; if ce56 != 0, swap turn ld a, [$ce56] or a - jr z, .asm_887f + jr z, .dont_swap call SwapTurn ld a, [$ce5c] - or $80 + or %10000000 ret -.asm_887f +.dont_swap ld a, [$ce5c] ret -- cgit v1.2.3 From 53ad70b112d47ffa2536ee179fd136df900018a3 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Fri, 19 Jul 2019 19:51:33 +0100 Subject: Apply corrections --- src/engine/bank01.asm | 6 +- src/engine/bank02.asm | 244 +++++++++++++++++++++++----------------------- src/engine/bank06.asm | 34 +++---- src/engine/home.asm | 6 +- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 2 +- src/wram.asm | 8 +- 7 files changed, 150 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 09bdee4..680555b 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -812,7 +812,7 @@ UsePokemonCard: ; 44db (1:44db) ; triggered by selecting the "Check" item in the duel menu DuelMenu_Check: ; 4585 (1:4585) call Func_3b31 - call DuelCheckInterface + call OpenDuelCheckMenu jp DuelMainInterface ; triggered by pressing SELECT in the duel menu @@ -5199,7 +5199,7 @@ Func_60dd: ; 60dd (1:60dd) jr z, .asm_6119 or a jr z, .asm_6132 - call DuelCheckInterface + call OpenDuelCheckMenu jr .asm_60f2 .asm_6132 call OpenTurnHolderHandScreen_Simple @@ -6297,7 +6297,7 @@ Func_67fb: ; 67fb (1:67fb) ld a, [wCurrentDuelMenuItem] or a jr z, .asm_6839 - call DuelCheckInterface + call OpenDuelCheckMenu jr .asm_6829 .asm_6839 call OpenTurnHolderHandScreen_Simple diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 7a5a78a..e6957cc 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,30 +1,30 @@ -_DuelCheckInterface: ; 8000 (2:4000) - call ResetCursorPosAndBlink +_OpenDuelCheckMenu: ; 8000 (2:4000) + call ResetCursorPositionAndBlink xor a ld [wce5e], a call DrawWideTextBox ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a ld hl, CheckMenuData call PlaceTextItems .loop call DoFrame - call HandleDuelMenuInput_YourPlayArea + call HandleCheckMenuInput jr nc, .loop cp $ff ret z ; B pressed ; A was pressed - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b ld hl, .table call JumpToFunctionInTable - jr _DuelCheckInterface + jr _OpenDuelCheckMenu .table: ; 8031 (2:4031) dw DuelCheckMenu_InPlayArea @@ -43,7 +43,7 @@ DuelCheckMenu_Glossary: ; 8042 (2:4042) ret DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) - call ResetCursorPosAndBlink + call ResetCursorPositionAndBlink xor a ld [wce5e], a ldh a, [hWhoseTurn] @@ -52,12 +52,12 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld l, a call DrawYourOrOppPlayArea_LoadTurnHolders - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b - ld [wLastCursorPosition_YourPlayArea], a + ld [wLastCursorPosition_YourOrOppPlayArea], a ld b, $f8 ; black arrow tile call DrawByteToTabulatedPositions @@ -65,7 +65,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a ld hl, YourPlayAreaMenuData call PlaceTextItems @@ -73,29 +73,28 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) call DoFrame xor a call DrawArrowsToTabulatedPositions - call HandleDuelMenuInput_PlayArea + call HandleCheckMenuInput_YourOrOppPlayArea jr nc, .loop call EraseByteFromTabulatedPositions cp $ff ret z - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b ld hl, .table call JumpToFunctionInTable jr .draw .table ; 8098 (2:4098) - dw OpenDuelScreen.turn_holder_play_area - dw OpenDuelScreen.turn_holder_hand - dw OpenDuelScreen.turn_holder_discard_pile + dw OpenDuelScreen_TurnHolderPlayArea + dw OpenDuelScreen_TurnHolderHand + dw OpenDuelScreen_TurnHolderDiscardPile -OpenDuelScreen: ; 809e (2:409e) -.turn_holder_play_area +OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e) ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderPlayAreaScreen @@ -103,7 +102,7 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret -.non_turn_holder_play_area +OpenDuelScreen_NonTurnHolderPlayArea ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderPlayAreaScreen @@ -111,7 +110,7 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret -.turn_holder_hand +OpenDuelScreen_TurnHolderHand ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderHandScreen_Simple @@ -119,7 +118,7 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret -.non_turn_holder_hand +OpenDuelScreen_NonTurnHolderHand ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderHandScreen_Simple @@ -127,7 +126,7 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret -.turn_holder_discard_pile +OpenDuelScreen_TurnHolderDiscardPile ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderDiscardPileScreen @@ -135,7 +134,7 @@ OpenDuelScreen: ; 809e (2:409e) ldh [hWhoseTurn], a ret -.non_turn_holder_discard_pile +OpenDuelScreen_NonTurnHolderDiscardPile ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderDiscardPileScreen @@ -147,7 +146,7 @@ OpenDuelScreen: ; 809e (2:409e) ; if clairvoyance is active, add the option to check ; opponent's hand DuelCheckMenu_OppPlayArea: ; 80da (2:40da) - call ResetCursorPosAndBlink + call ResetCursorPositionAndBlink call IsClairvoyanceActive jr c, .clairvoyance1 @@ -175,14 +174,14 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call DrawYourOrOppPlayArea_LoadTurnHolders ; convert cursor position and -; store it in wLastCursorPosition_YourPlayArea - ld a, [wCursorDuelYPosition] +; store it in wLastCursorPosition_YourOrOppPlayArea + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b add 3 - ld [wLastCursorPosition_YourPlayArea], a + ld [wLastCursorPosition_YourOrOppPlayArea], a ; draw black arrows in the Play Area ld b, $f8 ; black arrow tile @@ -192,7 +191,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a ; place text items depending on clairvoyance ; when active, allows to look at opp. hand @@ -210,7 +209,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) call DoFrame ld a, 1 call DrawArrowsToTabulatedPositions - call HandleDuelMenuInput_PlayArea + call HandleCheckMenuInput_YourOrOppPlayArea jr nc, .loop call EraseByteFromTabulatedPositions cp $ff @@ -218,19 +217,19 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ; A was pressed ; jump to function corresponding to cursor position - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b ld hl, .table call JumpToFunctionInTable jr .turns .table - dw OpenDuelScreen.non_turn_holder_play_area - dw OpenDuelScreen.non_turn_holder_hand - dw OpenDuelScreen.non_turn_holder_discard_pile + dw OpenDuelScreen_NonTurnHolderPlayArea + dw OpenDuelScreen_NonTurnHolderHand + dw OpenDuelScreen_NonTurnHolderDiscardPile CheckMenuData: ; (2:4158) textitem 2, 14, InPlayAreaText @@ -266,23 +265,23 @@ DrawArrowsToTabulatedPositions: ; 818c (2:418c) add b add b ld c, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] add b add c ; a = 2 * cursor ycoord + cursor xcoord + 3*a ; if cursor position is different than ; last position, then update arrows - ld hl, wLastCursorPosition_YourPlayArea + ld hl, wLastCursorPosition_YourOrOppPlayArea cp [hl] jr z, .unchanged ; erase and draw arrows call EraseByteFromTabulatedPositions - ld [wLastCursorPosition_YourPlayArea], a + ld [wLastCursorPosition_YourOrOppPlayArea], a ld b, $f8 ; black arrow tile byte call DrawByteToTabulatedPositions @@ -294,8 +293,8 @@ DrawArrowsToTabulatedPositions: ; 818c (2:418c) ; the bytes drawn previously EraseByteFromTabulatedPositions: ; 81af (2:41af) push af - ld a, [wLastCursorPosition_YourPlayArea] - ld b, $00 ; white tile + ld a, [wLastCursorPosition_YourOrOppPlayArea] + ld b, SYM_SPACE ; white tile call DrawByteToTabulatedPositions pop af ret @@ -432,7 +431,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) ld e, $00 call InitTextPrinting - ldtx hl, PlayersPlayAreaText + ldtx hl, DuelistsPlayAreaText ldh a, [hWhoseTurn] cp PLAYER_TURN jr nz, .opp_turn2 @@ -899,7 +898,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA ld b, [hl] ld l, DUELVARS_BENCH1_CARD_STAGE -.loop1 +.loop_1 dec b ; num of Bench Pokemon left jr z, .done @@ -946,7 +945,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) add c ld d, a ; d = d + c - jr .loop1 + jr .loop_1 .done ld a, [wTurnHolder1] @@ -959,7 +958,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) ld b, a inc b -.loop2 +.loop_2 dec b ret z @@ -985,7 +984,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) ld a, d add c ld d, a - jr .loop2 + jr .loop_2 ; draws Play Area icons depending on value in a ; input: @@ -1196,18 +1195,17 @@ PrintsHandTextAndValue: ; 8676 (2:4676) pop hl ret -; handle player input in menu in Opp. Play Area +; handle player input in menu in Your or Opp. Play Area ; works out which cursor coordinate to go to ; and sets carry flag if A or B are pressed -; input ; returns a = $1 if A pressed ; returns a = $ff if B pressed -HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) +HandleCheckMenuInput_YourOrOppPlayArea: ; 86ac (2:46ac) xor a ld [wcfe3], a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld d, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] ld e, a ; d = cursor x position @@ -1274,18 +1272,18 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) ld a, $01 ld [wcfe3], a push de - call DrawCursorEmpty_OppPlayArea + call EraseCheckMenuCursor_YourOrOppPlayArea pop de ;update x and y cursor positions ld a, d - ld [wCursorDuelXPosition], a + ld [wCheckMenuCursorXPosition], a ld a, e - ld [wCursorDuelYPosition], a + ld [wCheckMenuCursorYPosition], a ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .skip ldh a, [hKeysPressed] @@ -1301,7 +1299,7 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) ret .a_pressed - call DrawCursor_OppPlayArea + call DisplayCheckMenuCursor_OppPlayArea ld a, $01 call PlaySFXConfirmOrCancel scf @@ -1314,31 +1312,31 @@ HandleDuelMenuInput_PlayArea: ; 86ac (2:46ac) call PlaySFX .draw_cursor - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and %00001111 ret nz ; only update cursor if blink's lower nibble is 0 - ld a, $0f ; cursor byte + ld a, SYM_CURSOR_R ; cursor byte bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set - jr z, DrawByteInCursor_OppPlayArea + jr z, DrawCheckMenuCursor_YourOrOppPlayArea ; fallthrough ; transforms cursor position into coordinates ; in order to draw byte on menu cursor -DrawCursorEmpty_OppPlayArea: ; 8741 (2:4741) - ld a, $00 ; white tile +EraseCheckMenuCursor_YourOrOppPlayArea: ; 8741 (2:4741) + ld a, SYM_SPACE ; white tile ; fallthrough ; draws in the cursor position ; input: ; a = tile byte to draw -DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) +DrawCheckMenuCursor_YourOrOppPlayArea: ; 8743 (2:4743) ld e, a ld a, 10 ld l, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld h, a call HtimesL ; h = 10 * cursor x pos @@ -1346,7 +1344,7 @@ DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) ld a, l add 1 ld b, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a add 14 ld c, a @@ -1358,9 +1356,9 @@ DrawByteInCursor_OppPlayArea: ; 8743 (2:4743) or a ret -DrawCursor_OppPlayArea: ; 8760 (2:4760) - ld a, $0f ; load cursor byte - jr DrawByteInCursor_OppPlayArea +DisplayCheckMenuCursor_OppPlayArea: ; 8760 (2:4760) + ld a, SYM_CURSOR_R ; load cursor byte + jr DrawCheckMenuCursor_YourOrOppPlayArea ; fallthrough ; seems to be function to deal with the Peek menu @@ -1397,12 +1395,12 @@ Func_8764: ; 8764 (2:4764) ld hl, YourOrOppPlayAreaData call PlaceTextItems -.loop1 +.loop_1 call DoFrame call HandleMenuInput ; await input - jr nc, .loop1 + jr nc, .loop_1 cp $ff - jr z, .loop1 + jr z, .loop_1 call EraseCursor ldh a, [hCurMenuItem] @@ -1432,19 +1430,19 @@ Func_8764: ; 8764 (2:4764) xor a ld [wPrizeCardCursorPosition], a - lb de, $48, $c2 + ld de, Func_88c2 ld hl, wce53 ld [hl], e inc hl ld [hl], d -.loop2 +.loop_2 ld a, $01 ld [wVBlankOAMCopyToggle], a call DoFrame call Func_89ae jr c, .asm_87e7 - jr .loop2 + jr .loop_2 .asm_87e7 cp $ff jr nz, .asm_87f0 @@ -1453,13 +1451,13 @@ Func_8764: ; 8764 (2:4764) .asm_87f0 ld hl, .asm_87f8 call JumpToFunctionInTable - jr .loop2 + jr .loop_2 .asm_87f8 -REPT 6 +rept 6 dw Func_8819 -ENDR - dw Func_883C +endr + dw Func_883c dw Func_8849 YourOrOppPlayAreaData: ; 8808 (2:4808) @@ -1503,7 +1501,7 @@ Func_8819: ; 8819 (2:4819) call GetTurnDuelistVariable jr Func_8855 -Func_883C: +Func_883c: call CreateHandCardList ret c ld hl, wDuelTempList @@ -1589,8 +1587,9 @@ Func_8883: ; 8883 (2:4883) call SwapTurn ld a, $01 ld [$ce56], a - jp Func_8764.loop2 + jp Func_8764.loop_2 +Func_88c2: ; 88c2 (2:48c2) INCROM $88c2, $8932 Func_8932: ; 8932 (2:4932) @@ -1707,7 +1706,7 @@ Func_89ae: ; 89ae (2:49ae) ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .asm_8a4f ldh a, [hKeysPressed] @@ -1733,7 +1732,7 @@ Func_89ae: ; 89ae (2:49ae) jr z, .asm_8a76 call PlaySFX .asm_8a76 - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -1925,21 +1924,21 @@ Func_8e42: ; 8e42 (2:4e42) call DrawWideTextBox ld hl, Unknown_9027 call PlaceTextItems - call ResetCursorPosAndBlink + call ResetCursorPositionAndBlink .asm_8e4e call DoFrame - call HandleDuelMenuInput_YourPlayArea + call HandleCheckMenuInput jp nc, .asm_8e4e cp $ff jr nz, .asm_8e64 - call DrawCursorEmpty_YourPlayArea + call EraseCheckMenuCursor ld a, [wceb1] jp Func_8dbc .asm_8e64 - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] or a jp nz, Func_8f8a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] or a jp nz, .asm_8ecf call GetPointerToDeckCards @@ -2092,7 +2091,7 @@ Func_8f38: ; 8f38 (2:4f38) ret Func_8f8a: ; 8f8a (2:4f8a) - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] or a jp nz, Func_9026 call Func_8ff2 @@ -2184,25 +2183,24 @@ GetPointerToDeckCards: ; 9048 (2:5048) pop af ret -ResetCursorPosAndBlink: ; 905a (2:505a) +ResetCursorPositionAndBlink: ; 905a (2:505a) xor a - ld [wCursorDuelXPosition], a - ld [wCursorDuelYPosition], a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorXPosition], a + ld [wCheckMenuCursorYPosition], a + ld [wCheckMenuCursorBlinkCounter], a ret -; handle player input in menu in Your Play Area +; handle player input in check menu ; works out which cursor coordinate to go to ; and sets carry flag if A or B are pressed -; input ; returns a = $1 if A pressed ; returns a = $ff if B pressed -HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) +HandleCheckMenuInput: ; 9065 (2:5065) xor a ld [wcfe3], a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld d, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] ld e, a ; d = cursor x position @@ -2238,18 +2236,18 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ld a, $01 ld [wcfe3], a push de - call DrawCursorEmpty_YourPlayArea + call EraseCheckMenuCursor pop de ;update x and y cursor positions ld a, d - ld [wCursorDuelXPosition], a + ld [wCheckMenuCursorXPosition], a ld a, e - ld [wCursorDuelYPosition], a + ld [wCheckMenuCursorYPosition], a ; reset cursor blink xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .no_pad ldh a, [hKeysPressed] and A_BUTTON | B_BUTTON @@ -2262,7 +2260,7 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) ret .a_press - call Func_90f7 + call DisplayCheckMenuCursor ld a, $01 call PlaySFXConfirmOrCancel scf @@ -2275,36 +2273,36 @@ HandleDuelMenuInput_YourPlayArea: ; 9065 (2:5065) call PlaySFX .check_blink - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and %00001111 ret nz ; only update cursor if blink's lower nibble is 0 - ld a, $0f ; cursor byte + ld a, SYM_CURSOR_R ; cursor byte bit 4, [hl] ; only draw cursor if blink counter's fourth bit is not set - jr z, DrawByteInCursor_YourPlayArea + jr z, DrawCheckMenuCursor ; draws in the cursor position -DrawCursorEmpty_YourPlayArea: ; 90d8 (2:50d8) - ld a, $00 ; empty cursor +EraseCheckMenuCursor: ; 90d8 (2:50d8) + ld a, SYM_SPACE ; empty cursor ; fallthrough ; draws in the cursor position ; input: ; a = tile byte to draw -DrawByteInCursor_YourPlayArea: +DrawCheckMenuCursor: ld e, a ld a, 10 ld l, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld h, a call HtimesL ld a, l add 1 ld b, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a add 14 ld c, a @@ -2314,9 +2312,9 @@ DrawByteInCursor_YourPlayArea: or a ret -Func_90f7: ; 90f7 (2:50f7) - ld a, $f - jr DrawByteInCursor_YourPlayArea +DisplayCheckMenuCursor: ; 90f7 (2:50f7) + ld a, SYM_CURSOR_R + jr DrawCheckMenuCursor ; plays sound depending on value in a ; input: @@ -2602,7 +2600,7 @@ CalculateOnesAndTensDigits: ; 98a6 (2:58a6) ; c = floor(a / 10) .zero1 ; ones digit - add $20 + add SYM_0 ld hl, wOnesAndTensPlace ld [hli], a @@ -2610,7 +2608,7 @@ CalculateOnesAndTensDigits: ; 98a6 (2:58a6) ld a, c or a jr z, .zero2 - add $20 + add SYM_0 .zero2 ld [hl], a @@ -2660,12 +2658,12 @@ Func_b19d: ; b19d (2:719d) ld a, [wcea1] add b ld [wd088], a - call ResetCursorPosAndBlink + call ResetCursorPositionAndBlink call DrawWideTextBox ld hl, $7274 call PlaceTextItems call DoFrame - call HandleDuelMenuInput_YourPlayArea + call HandleCheckMenuInput jp nc, $71e7 cp $ff jr nz, .asm_b1fa @@ -2673,9 +2671,9 @@ Func_b19d: ; b19d (2:719d) jp $71b3 .asm_b1fa - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a - ld hl, wCursorDuelXPosition + ld hl, wCheckMenuCursorXPosition add [hl] or a jr nz, .asm_b22c @@ -2828,7 +2826,7 @@ Func_ba04: ; ba04 (2:7a04) cp $ff jp z, $7b0d ld [wd088], a - call ResetCursorPosAndBlink + call ResetCursorPositionAndBlink xor a ld [wce5e], a call DrawWideTextBox @@ -2843,9 +2841,9 @@ Func_ba04: ; ba04 (2:7a04) jp $7a25 .asm_badf - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a - ld hl, wCursorDuelXPosition + ld hl, wCheckMenuCursorXPosition add [hl] or a jr nz, .asm_bb09 diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 2aa63af..e0d1672 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -152,7 +152,7 @@ Func_180d5: ; 180d5 (6:40d5) ld [wPrizeCardCursorPosition], a .asm_006_40da xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a farcall $2, $42ce call EnableLCD call IsClairvoyanceActive @@ -509,7 +509,7 @@ Func_006_43bb: ; 183bb (6:43bb) ld a, $01 ld [wcfe3], a xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .asm_006_446b ldh a, [hKeysPressed] and $03 @@ -533,7 +533,7 @@ Func_006_43bb: ; 183bb (6:43bb) jr z, .asm_006_4494 call PlaySFX .asm_006_4494 - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -582,7 +582,7 @@ Func_006_44c8: ; 184c8 (6:44c8) ld a, $ff ld [wDuelInitialPrizesUpperBitsSet], a xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .asm_006_44e5 ld a, $01 ld [wVBlankOAMCopyToggle], a @@ -605,7 +605,7 @@ Func_006_44c8: ; 184c8 (6:44c8) call Func_006_4598 call Func_006_452b xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a jr .asm_006_44e5 .asm_006_4518 ld a, $01 @@ -768,9 +768,9 @@ GlossaryData2: ; (6:4661) xor a ld [wcfe3], a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld d, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] ld e, a ldh a, [hDPadHeld] or a @@ -800,11 +800,11 @@ GlossaryData2: call .asm_006_46d4 pop de ld a, d - ld [wCursorDuelXPosition], a + ld [wCheckMenuCursorXPosition], a ld a, e - ld [wCursorDuelYPosition], a + ld [wCheckMenuCursorYPosition], a xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a .asm_006_46a2 ldh a, [hKeysPressed] and $03 @@ -827,7 +827,7 @@ GlossaryData2: jr z, .asm_006_46c6 call PlaySFX .asm_006_46c6 - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -841,13 +841,13 @@ GlossaryData2: ld e, a ld a, $0a ld l, a - ld a, [wCursorDuelXPosition] + ld a, [wCheckMenuCursorXPosition] ld h, a call HtimesL ld a, l add $01 ld b, a - ld a, [wCursorDuelYPosition] + ld a, [wCheckMenuCursorYPosition] sla a add $0e ld c, a @@ -1883,7 +1883,7 @@ NamingScreen_CheckButtonState: ld a, h ld [wNamingScreenCursorX], a xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a ld a, $06 cp d jp z, NamingScreen_CheckButtonState @@ -1909,7 +1909,7 @@ NamingScreen_CheckButtonState: jr z, .asm_006_69f8 call PlaySFX .asm_006_69f8 - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and $0f @@ -2664,7 +2664,7 @@ Func_006_6efb: ld a, h ld [wNamingScreenCursorX], a xor a - ld [wDuelCursorBlinkCounter], a + ld [wCheckMenuCursorBlinkCounter], a ld a, $02 cp d jp z, Func_006_6efb @@ -2690,7 +2690,7 @@ Func_006_6efb: jr z, .asm_006_6f92 call PlaySFX .asm_006_6f92 - ld hl, wDuelCursorBlinkCounter + ld hl, wCheckMenuCursorBlinkCounter ld a, [hl] inc [hl] and $0f diff --git a/src/engine/home.asm b/src/engine/home.asm index 47f28f3..10298fe 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9279,12 +9279,12 @@ CompareDEtoBC: ; 3090 (0:3090) cp c ret -DuelCheckInterface: ; 3096 (0:3096) +OpenDuelCheckMenu: ; 3096 (0:3096) ldh a, [hBankROM] push af - ld a, BANK(_DuelCheckInterface) + ld a, BANK(_OpenDuelCheckMenu) call BankswitchROM - call _DuelCheckInterface + call _OpenDuelCheckMenu pop af call BankswitchROM ret diff --git a/src/text/text2.asm b/src/text/text2.asm index a4cabe8..61d7fdc 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -1747,7 +1747,7 @@ Text0246: ; 3bc85 (e:7c85) text "To Opponent's Play Area" done -PlayersPlayAreaText: ; 3bc9e (e:7c9e) +DuelistsPlayAreaText: ; 3bc9e (e:7c9e) text "'s Play Area" done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index a1e2ef5..56dda1f 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -584,7 +584,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer OpponentsDiscardPileText2 ; 0x0244 textpointer OpponentsHandText ; 0x0245 textpointer Text0246 ; 0x0246 - textpointer PlayersPlayAreaText ; 0x0247 + textpointer DuelistsPlayAreaText ; 0x0247 textpointer YourPlayAreaText ; 0x0248 textpointer OppPlayAreaText ; 0x0249 textpointer InPlayAreaText ; 0x024a diff --git a/src/wram.asm b/src/wram.asm index 8708005..3ded6e7 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1322,7 +1322,7 @@ wce5e:: ; ce5e ; this is used to store last cursor position ; in the Your Play Area screen -wLastCursorPosition_YourPlayArea:: ; ce5f +wLastCursorPosition_YourOrOppPlayArea:: ; ce5f ds $1 wce60:: ; ce60 @@ -1413,7 +1413,7 @@ wcea1:: ; cea1 ds $1 ; used to blink the cursor in duel menu -wDuelCursorBlinkCounter:: ; cea3 +wCheckMenuCursorBlinkCounter:: ; cea3 ds $1 wNamingScreenCursorY:: ; cea4 @@ -1431,10 +1431,10 @@ wceaa:: ; ceaa wceab:: ; ceab ds $4 -wCursorDuelXPosition:: ; ceaf +wCheckMenuCursorXPosition:: ; ceaf ds $1 -wCursorDuelYPosition:: ; ceb0 +wCheckMenuCursorYPosition:: ; ceb0 ds $1 wceb1:: ; ceb1 -- cgit v1.2.3