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 From c6b095eae729ed1a8cc19c28be746c43744d83d3 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 20 Jul 2019 14:08:50 +0200 Subject: A few more text labels --- src/engine/bank01.asm | 25 ++++++++++++------------- src/engine/home.asm | 1 + src/text/text1.asm | 8 ++++---- src/text/text_offsets.asm | 8 ++++---- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index df61f37..792b235 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -466,18 +466,17 @@ OpenNonTurnHolderDiscardPileScreen: ; 4339 (1:4339) OpenTurnHolderDiscardPileScreen: ; 4342 (1:4342) jp OpenDiscardPileScreen -; draw the non-turn holder's hand screen. -; simpler version of OpenPlayerHandScreen where any selected card is directly submitted -; and the duelist could also be the opponent. +; draw the non-turn holder's hand screen. simpler version of OpenPlayerHandScreen +; used only for checking the cards rather than for playing them. OpenNonTurnHolderHandScreen_Simple: ; 4345 (1:4345) call SwapTurn call OpenTurnHolderHandScreen_Simple jp SwapTurn ; 0x434e -; draw the turn holder's hand screen. -; simpler version of OpenPlayerHandScreen where any selected card is directly submitted -; and the duelist could also be the opponent. +; draw the turn holder's hand screen. simpler version of OpenPlayerHandScreen +; used only for checking the cards rather than for playing them. +; used for example in the "Your Play Area" screen of the Check menu OpenTurnHolderHandScreen_Simple: ; 434e (1:434e) call CreateHandCardList jr c, .no_cards_in_hand @@ -2213,19 +2212,19 @@ Func_4e6e: ; 4e6e (1:4e6e) ld b, $52 ld c, $57 .asm_4e7c - ld hl, $63 - ld de, $67 + ldtx hl, ShufflesTheDeckText + ldtx de, Drew7CardsText jr Func_4e98 Func_4e84: ; 4e84 (1:4e84) ld b, $53 ld c, $55 - ld hl, $65 - ld de, $66 + ldtx hl, EachPlayerShuffleOpponentsDeckText + ldtx de, EachPlayerDraw7CardsText ld a, [wDuelType] cp DUELTYPE_PRACTICE jr nz, Func_4e98 - ld hl, $64 + ldtx hl, ThisIsJustPracticeDoNotShuffleText ; fallthrough Func_4e98: ; 4e98 (1:4e98) @@ -2243,10 +2242,10 @@ Func_4e98: ; 4e98 (1:4e98) call EnableLCD ld a, [wDuelType] cp DUELTYPE_PRACTICE - jr nz, .asm_4ebf + jr nz, .not_practice call WaitForWideTextBoxInput jr .asm_4ee0 -.asm_4ebf +.not_practice call Func_3b21 ld hl, sp+$03 ld a, [hl] diff --git a/src/engine/home.asm b/src/engine/home.asm index c4507ef..84cabdd 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -858,6 +858,7 @@ CallIndirect: ; 05b6 (0:05b6) ld h, a pop af ; fallthrough + CallHL: ; 05c1 (0:05c1) jp hl ; 0x5c2 diff --git a/src/text/text1.asm b/src/text/text1.asm index 8245b3b..e7b0fe4 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -434,21 +434,21 @@ ShufflesTheDeckText: ; 36afe (d:6afe) text " shuffles the Deck." done -Text0064: ; 36b14 (d:6b14) +ThisIsJustPracticeDoNotShuffleText: ; 36b14 (d:6b14) text "Since this is just practice," line "Do not shuffle the Deck." done -Text0065: ; 36b4b (d:6b4b) +EachPlayerShuffleOpponentsDeckText: ; 36b4b (d:6b4b) text "Each player will" line "shuffle the opponent's Deck." done -Text0066: ; 36b7a (d:6b7a) +EachPlayerDraw7CardsText: ; 36b7a (d:6b7a) text "Each player will draw 7 cards." done -Text0067: ; 36b9a (d:6b9a) +Drew7CardsText: ; 36b9a (d:6b9a) text "" line "drew 7 cards." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 2f56aaa..df61804 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -101,10 +101,10 @@ TextOffsets:: ; 34000 (d:4000) textpointer PlacedOnTheBenchText ; 0x0061 textpointer PlacedInTheArenaText ; 0x0062 textpointer ShufflesTheDeckText ; 0x0063 - textpointer Text0064 ; 0x0064 - textpointer Text0065 ; 0x0065 - textpointer Text0066 ; 0x0066 - textpointer Text0067 ; 0x0067 + textpointer ThisIsJustPracticeDoNotShuffleText ; 0x0064 + textpointer EachPlayerShuffleOpponentsDeckText ; 0x0065 + textpointer EachPlayerDraw7CardsText ; 0x0066 + textpointer Drew7CardsText ; 0x0067 textpointer DeckHasXCardsText ; 0x0068 textpointer ChooseBasicPkmnToPlaceInArenaText ; 0x0069 textpointer ThereAreNoBasicPokemonInHand ; 0x006a -- cgit v1.2.3 From 9d1dd609f95c9670e1108444a504dc6d8b053392 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 20 Jul 2019 15:32:04 +0200 Subject: Consolidate some bank2 function names --- src/engine/bank02.asm | 274 ++++++++++++++++++++++++++------------------------ src/engine/bank06.asm | 2 +- src/wram.asm | 4 +- 3 files changed, 145 insertions(+), 135 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 2b4d598..38d74f7 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -1,5 +1,5 @@ _OpenDuelCheckMenu: ; 8000 (2:4000) - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink xor a ld [wce5e], a call DrawWideTextBox @@ -17,7 +17,7 @@ _OpenDuelCheckMenu: ; 8000 (2:4000) ret z ; B pressed ; A was pressed - ld a, [wCheckMenuCursorYPosition] + ld a, [wCheckMenuCursorYPosition] sla a ld b, a ld a, [wCheckMenuCursorXPosition] @@ -32,18 +32,21 @@ _OpenDuelCheckMenu: ; 8000 (2:4000) dw DuelCheckMenu_YourPlayArea dw DuelCheckMenu_OppPlayArea +; opens the In Play Area submenu DuelCheckMenu_InPlayArea: ; 8039 (2:4039) xor a ld [wce60], a farcall Func_180d5 ret +; opens the Glossary submenu DuelCheckMenu_Glossary: ; 8042 (2:4042) farcall Func_006_44c8 ret +; opens the Your Play Area submenu DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink xor a ld [wce5e], a ldh a, [hWhoseTurn] @@ -57,12 +60,12 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) ld b, a ld a, [wCheckMenuCursorXPosition] add b - ld [wLastCursorPosition_YourOrOppPlayArea], a + ld [wYourOrOppPlayAreaLastCursorPosition], a ld b, $f8 ; black arrow tile - call DrawByteToTabulatedPositions + call DrawYourOrOppPlayArea_DrawArrows call DrawWideTextBox - + ; reset cursor blink xor a ld [wCheckMenuCursorBlinkCounter], a @@ -72,11 +75,11 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .loop call DoFrame xor a - call DrawArrowsToTabulatedPositions + call DrawYourOrOppPlayArea_RefreshArrows call HandleCheckMenuInput_YourOrOppPlayArea jr nc, .loop - call EraseByteFromTabulatedPositions + call DrawYourOrOppPlayArea_EraseArrows cp $ff ret z @@ -93,7 +96,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) dw OpenDuelScreen_TurnHolderPlayArea dw OpenDuelScreen_TurnHolderHand dw OpenDuelScreen_TurnHolderDiscardPile - + OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e) ldh a, [hWhoseTurn] push af @@ -102,7 +105,7 @@ OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e) ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderPlayArea +OpenDuelScreen_NonTurnHolderPlayArea: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderPlayAreaScreen @@ -110,7 +113,7 @@ OpenDuelScreen_NonTurnHolderPlayArea ldh [hWhoseTurn], a ret -OpenDuelScreen_TurnHolderHand +OpenDuelScreen_TurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderHandScreen_Simple @@ -118,7 +121,7 @@ OpenDuelScreen_TurnHolderHand ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderHand +OpenDuelScreen_NonTurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderHandScreen_Simple @@ -126,7 +129,7 @@ OpenDuelScreen_NonTurnHolderHand ldh [hWhoseTurn], a ret -OpenDuelScreen_TurnHolderDiscardPile +OpenDuelScreen_TurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderDiscardPileScreen @@ -134,7 +137,7 @@ OpenDuelScreen_TurnHolderDiscardPile ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderDiscardPile +OpenDuelScreen_NonTurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderDiscardPileScreen @@ -142,11 +145,11 @@ OpenDuelScreen_NonTurnHolderDiscardPile ldh [hWhoseTurn], a ret -; handles the menu when in the Opponent's Play Area submenu +; opens the Opp. Play Area submenu ; if clairvoyance is active, add the option to check ; opponent's hand DuelCheckMenu_OppPlayArea: ; 80da (2:40da) - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink call IsClairvoyanceActive jr c, .clairvoyance1 @@ -173,22 +176,22 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) .cursor call DrawYourOrOppPlayArea_LoadTurnHolders -; convert cursor position and -; store it in wLastCursorPosition_YourOrOppPlayArea +; convert cursor position and +; store it in wYourOrOppPlayAreaLastCursorPosition ld a, [wCheckMenuCursorYPosition] sla a ld b, a ld a, [wCheckMenuCursorXPosition] add b add 3 - ld [wLastCursorPosition_YourOrOppPlayArea], a + ld [wYourOrOppPlayAreaLastCursorPosition], a ; draw black arrows in the Play Area ld b, $f8 ; black arrow tile - call DrawByteToTabulatedPositions + call DrawYourOrOppPlayArea_DrawArrows call DrawWideTextBox - + ; reset cursor blink xor a ld [wCheckMenuCursorBlinkCounter], a @@ -208,10 +211,10 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) .loop call DoFrame ld a, 1 - call DrawArrowsToTabulatedPositions + call DrawYourOrOppPlayArea_RefreshArrows call HandleCheckMenuInput_YourOrOppPlayArea jr nc, .loop - call EraseByteFromTabulatedPositions + call DrawYourOrOppPlayArea_EraseArrows cp $ff ret z ; B was pressed @@ -245,8 +248,8 @@ YourPlayAreaMenuData: ; (2:4169) db $ff OppPlayAreaMenuData: ; (2:4176) - textitem 2, 14, OpponentsPokemonText - textitem 2, 16, OpponentsDiscardPileText2 + textitem 2, 14, OpponentsPokemonText + textitem 2, 16, OpponentsDiscardPileText2 db $ff OppPlayAreaMenuData_WithClairvoyance: ; (2:4176) @@ -255,11 +258,12 @@ OppPlayAreaMenuData_WithClairvoyance: ; (2:4176) textitem 2, 16, OpponentsDiscardPileText2 db $ff -; checks if arrows need to be erased in Play Area +; checks if arrows need to be erased in Your Play Area or Opp. Play Area ; and draws new arrows upon cursor position change ; input: -; a = an initial offset applied to the cursor position -DrawArrowsToTabulatedPositions: ; 818c (2:418c) +; a = an initial offset applied to the cursor position (used to adjust +; for the different layouts of the Your Play Area and Opp. Play Area screens) +DrawYourOrOppPlayArea_RefreshArrows: ; 818c (2:418c) push af ld b, a add b @@ -275,44 +279,47 @@ DrawArrowsToTabulatedPositions: ; 818c (2:418c) ; if cursor position is different than ; last position, then update arrows - ld hl, wLastCursorPosition_YourOrOppPlayArea + ld hl, wYourOrOppPlayAreaLastCursorPosition cp [hl] jr z, .unchanged ; erase and draw arrows - call EraseByteFromTabulatedPositions - ld [wLastCursorPosition_YourOrOppPlayArea], a + call DrawYourOrOppPlayArea_EraseArrows + ld [wYourOrOppPlayAreaLastCursorPosition], a ld b, $f8 ; black arrow tile byte - call DrawByteToTabulatedPositions + call DrawYourOrOppPlayArea_DrawArrows .unchanged pop af ret -; load white tile in b to erase -; the bytes drawn previously -EraseByteFromTabulatedPositions: ; 81af (2:41af) +; write SYM_SPACE to positions tabulated in +; YourOrOppPlayAreaArrowPositions, with offset calculated from the +; cursor x and y positions in [wYourOrOppPlayAreaLastCursorPosition] +; input: +; [wYourOrOppPlayAreaLastCursorPosition]: cursor position (2*y + x) +DrawYourOrOppPlayArea_EraseArrows: ; 81af (2:41af) push af - ld a, [wLastCursorPosition_YourOrOppPlayArea] + ld a, [wYourOrOppPlayAreaLastCursorPosition] ld b, SYM_SPACE ; white tile - call DrawByteToTabulatedPositions + call DrawYourOrOppPlayArea_DrawArrows pop af ret ; writes tile in b to positions tabulated in -; PlayAreaDrawPositionsPointerTable, with offset calculated from the +; YourOrOppPlayAreaArrowPositions, with offset calculated from the ; cursor x and y positions in a ; input: ; a = cursor position (2*y + x) ; b = byte to draw -DrawByteToTabulatedPositions: ; 81ba (2:41ba) +DrawYourOrOppPlayArea_DrawArrows: ; 81ba (2:41ba) push bc - ld hl, PlayAreaDrawPositionsPointerTable + ld hl, YourOrOppPlayAreaArrowPositions sla a ld c, a ld b, $00 add hl, bc -; hl points to PlayAreaDrawPositionsPointerTable +; hl points to YourOrOppPlayAreaArrowPositions ; plus offset corresponding to a ; load hl with draw position pointer @@ -334,17 +341,16 @@ DrawByteToTabulatedPositions: ; 81ba (2:41ba) .done ret -PlayAreaDrawPositionsPointerTable: ; 81d7 (2:41d7) - 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 +YourOrOppPlayAreaArrowPositions: ; 81d7 (2:41d7) + dw YourOrOppPlayAreaArrowPositions_PlayerPokemon + dw YourOrOppPlayAreaArrowPositions_PlayerHand + dw YourOrOppPlayAreaArrowPositions_PlayerDiscardPile + dw YourOrOppPlayAreaArrowPositions_OpponentPokemon + dw YourOrOppPlayAreaArrowPositions_OpponentHand + dw YourOrOppPlayAreaArrowPositions_OpponentDiscardPile -PlayAreaDrawPositions: ; 81e3 (2:41e3) +YourOrOppPlayAreaArrowPositions_PlayerPokemon: ; 81e3 (2:41e3) ; x and y coordinates to draw byte -.player_pokemon: db 5, 5 db 0, 10 db 4, 10 @@ -353,15 +359,15 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 10 db $ff -.player_hand: +YourOrOppPlayAreaArrowPositions_PlayerHand: db 14, 7 db $ff -.player_discard_pile: +YourOrOppPlayAreaArrowPositions_PlayerDiscardPile: db 14, 5 db $ff -.opponent_pokemon: +YourOrOppPlayAreaArrowPositions_OpponentPokemon: db 5, 7 db 0, 3 db 4, 3 @@ -370,11 +376,11 @@ PlayAreaDrawPositions: ; 81e3 (2:41e3) db 16, 3 db $ff -.opponent_hand: +YourOrOppPlayAreaArrowPositions_OpponentHand: db 0, 5 db $ff -.opponent_discard_pile: +YourOrOppPlayAreaArrowPositions_OpponentDiscardPile: db 0, 8 db $ff @@ -390,7 +396,7 @@ DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209) ld [wTurnHolder2], a ; fallthrough -; loads tiles and icons to display your/opp play area +; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player _DrawYourOrOppPlayArea: ; 8211 (2:4211) xor a @@ -453,24 +459,24 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData_1.player - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.player + call DrawPlayArea_PrizeCards lb de, 6, 2 ; coordinates of player's active card - call DrawActiveCardGfx_YourOrOppPlayArea + call DrawYourOrOppPlayArea_ActiveCardGfx lb de, 1, 9 ; coordinates of player's bench cards ld c, 4 ; spacing - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards xor a call DrawYourOrOppPlayArea_Icons jr .lcd .not_equal - ld hl, PrizeCardsCoordinateData_1.opponent - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.opponent + call DrawPlayArea_PrizeCards lb de, 6, 5 ; coordinates of opponent's active card - call DrawActiveCardGfx_YourOrOppPlayArea + call DrawYourOrOppPlayArea_ActiveCardGfx lb de, 1, 2 ; coordinates of opponent's bench cards ld c, 4 ; spacing - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards ld a, $01 call DrawYourOrOppPlayArea_Icons @@ -478,23 +484,24 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) call EnableLCD ret -DrawTurnHolderPrizeCards: ; 82b6 (2:42b6) +Func_82b6: ; 82b6 (2:42b6) ld a, [wTurnHolder1] ld b, a ld a, [wTurnHolder2] cp b jr nz, .not_equal - ld hl, PrizeCardsCoordinateData_1.player - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.player + call DrawPlayArea_PrizeCards ret .not_equal - ld hl, PrizeCardsCoordinateData_1.opponent - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.opponent + call DrawPlayArea_PrizeCards ret -; draws icons and cards to the In Play Area screen +; loads tiles and icons to display the In Play Area screen, +; and draws the screen _DrawInPlayArea: ; 82ce (2:42ce) xor a ld [wTileMapFill], a @@ -521,13 +528,13 @@ _DrawInPlayArea: ; 82ce (2:42ce) ld [wTurnHolder2], a ; player prize cards - ld hl, PrizeCardsCoordinateData_3.player - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_InPlayArea.player + call DrawPlayArea_PrizeCards ; player bench cards lb de, 3, 15 ld c, 3 - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards ld hl, PlayAreaIconCoordinates.player2 call DrawInPlayArea_Icons @@ -538,24 +545,23 @@ _DrawInPlayArea: ; 82ce (2:42ce) call SwapTurn ; opponent prize cards - ld hl, PrizeCardsCoordinateData_3.opponent - call DrawPrizeCards + ld hl, PrizeCardsCoordinateData_InPlayArea.opponent + call DrawPlayArea_PrizeCards ; opponent bench cards lb de, 3, 0 ld c, 3 - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards call SwapTurn ld hl, PlayAreaIconCoordinates.opponent2 call DrawInPlayArea_Icons call SwapTurn - call DrawActiveCardGfx_InPlayArea + call DrawInPlayArea_ActiveCardGfx ret -; draws players prize cards -; and bench cards +; draws players prize cards and bench cards _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) xor a ld [wTileMapFill], a @@ -572,26 +578,26 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) ld [wTurnHolder1], a ld [wTurnHolder2], a ld hl, PrizeCardsCoordinateData_2.player - call DrawPrizeCards + call DrawPlayArea_PrizeCards lb de, 5, 10 ; coordinates ld c, 3 ; spacing - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards ; opponent cards ld a, OPPONENT_TURN ld [wTurnHolder1], a ld hl, PrizeCardsCoordinateData_2.opponent - call DrawPrizeCards + call DrawPlayArea_PrizeCards lb de, 1, 0 ; coordinates ld c, 3 ; spacing - call DrawYourOrOppPlayArea_BenchCards + call DrawPlayArea_BenchCards ret ; draws the active card gfx at coordinates de ; of the player (or opponent) depending on wTurnHolder1 ; input: ; de = coordinates -DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) +DrawYourOrOppPlayArea_ActiveCardGfx: ; 837e (2:437e) push de ld a, DUELVARS_ARENA_CARD ld l, a @@ -641,8 +647,8 @@ DrawActiveCardGfx_YourOrOppPlayArea: ; 837e (2:437e) ret ; draws player and opponent arena card graphics -; in the play area screen -DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) +; in the "In Play Area" screen +DrawInPlayArea_ActiveCardGfx: ; 83cc (2:43cc) xor a ld [wArenaCardsInPlayArea], a @@ -731,7 +737,7 @@ DrawActiveCardGfx_InPlayArea: ; 83cc (2:43cc) ; loaded in wTurnHolder1 ; input: ; hl = pointer to coordinates -DrawPrizeCards: ; 8464 (2:4464) +DrawPlayArea_PrizeCards: ; 8464 (2:4464) push hl call GetDuelInitialPrizesUpperBitsSet ld a, [wTurnHolder1] @@ -763,7 +769,7 @@ DrawPrizeCards: ; 8464 (2:4464) inc hl ld d, [hl] inc hl - + push hl push bc lb hl, $01, $02 ; card tile gfx @@ -787,7 +793,7 @@ DrawPrizeCards: ; 8464 (2:4464) pop af ret -PrizeCardsCoordinateData_1: ; 0x84b4 (2:44b4) +PrizeCardsCoordinateData_YourOrOppPlayArea: ; 0x84b4 (2:44b4) ; x and y coordinates for player prize cards .player db 2, 1 @@ -805,7 +811,8 @@ PrizeCardsCoordinateData_1: ; 0x84b4 (2:44b4) db 5, 17 db 5, 15 -PrizeCardsCoordinateData_2: +; used by Func_833c +PrizeCardsCoordinateData_2: ; 0x84cc (2:44cc) ; x and y coordinates for player prize cards .player db 6, 0 @@ -823,7 +830,7 @@ PrizeCardsCoordinateData_2: db 0, 18 db 0, 16 -PrizeCardsCoordinateData_3: ; 0x84e4 (2:44e4) +PrizeCardsCoordinateData_InPlayArea: ; 0x84e4 (2:44e4) ; x and y coordinates for player prize cards .player db 9, 1 @@ -841,8 +848,7 @@ PrizeCardsCoordinateData_3: ; 0x84e4 (2:44e4) db 2, 17 db 2, 15 -; calculates bits set up to the number of -; initial prizes, with upper 2 bits set, i.e: +; 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 @@ -863,14 +869,12 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ld [wDuelInitialPrizesUpperBitsSet], a ret -; draws filled and empty bench slots depending -; on the turn loaded in wTurnHolder1 -; if wTurnHolder1 is different from wTurnHolder2 -; adjusts coordinates of the bench slots +; draws filled and empty bench slots depending on the turn loaded in wTurnHolder1 +; if wTurnHolder1 is different from wTurnHolder2 adjusts coordinates of the bench slots ; input: ; de = coordinates to draw bench ; c = spacing between slots -DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) +DrawPlayArea_BenchCards: ; 8511 (2:4511) ld a, [wTurnHolder2] ld b, a ld a, [wTurnHolder1] @@ -907,7 +911,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) push bc sla a sla a - add $e4 + add $e4 ; a holds the correct stage gfx tile ld b, a push bc @@ -960,7 +964,7 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) inc b .loop_2 dec b - ret z + ret z push bc ld a, $f4 ; empty bench slot tile @@ -986,7 +990,10 @@ DrawYourOrOppPlayArea_BenchCards: ; 8511 (2:4511) ld d, a jr .loop_2 -; draws Play Area icons depending on value in a +; draws Your/Opp Play Area icons depending on value in a +; the icons correspond to Deck, Discard Pile, and Hand +; the corresponding number of cards is printed alongside each icon +; for "Hand", text is displayed rather than an icon ; input: ; a = $00: draws player icons ; a = $01: draws opponent icons @@ -1006,7 +1013,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) ld a, [de] ld b, a ld a, $d0 ; hand icon, unused? - call PrintsHandTextAndValue + call DrawPlayArea_HandText ; deck icon and value ld a, [wTurnHolder1] @@ -1018,7 +1025,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) sub b ld b, a ld a, $d4 ; deck icon - call DrawIconWithValue + call DrawPlayArea_IconWithValue ; discard pile icon and value ld a, [wTurnHolder1] @@ -1027,7 +1034,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) ld a, [de] ld b, a ld a, $d8 ; discard pile icon - call DrawIconWithValue + call DrawPlayArea_IconWithValue ret ; draws the interface icon corresponding to the gfx tile in a @@ -1037,7 +1044,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) ; a = tile for the icon ; b = value to print alongside icon ; hl = pointer to coordinates -DrawIconWithValue: ; 85e1 (2:45e1) +DrawPlayArea_IconWithValue: ; 85e1 (2:45e1) ; drawing the icon ld d, [hl] inc hl @@ -1096,7 +1103,7 @@ DrawIconWithValue: ; 85e1 (2:45e1) pop hl ret -PlayAreaIconCoordinates ; 8635 (2:4635) +PlayAreaIconCoordinates: ; 8635 (2:4635) ; used for "Your/Opp. Play Area" screen .player1 db 15, 7 ; hand @@ -1117,7 +1124,13 @@ PlayAreaIconCoordinates ; 8635 (2:4635) db 0, 6 db 0, 4 -; draws In Play Area icons +; draws In Play Area icons depending on value in a +; the icons correspond to Deck, Discard Pile, and Hand +; the corresponding number of cards is printed alongside each icon +; for "Hand", text is displayed rather than an icon +; input: +; a = $00: draws player icons +; a = $01: draws opponent icons DrawInPlayArea_Icons: ; 864d (2:464d) ldh a, [hWhoseTurn] ld d, a @@ -1125,7 +1138,7 @@ DrawInPlayArea_Icons: ; 864d (2:464d) ld a, [de] ld b, a ld a, $d0 ; hand icon, unused? - call PrintsHandTextAndValue + call DrawPlayArea_HandText ; deck ldh a, [hWhoseTurn] @@ -1137,7 +1150,7 @@ DrawInPlayArea_Icons: ; 864d (2:464d) sub b ld b, a ld a, $d4 ; deck tile - call DrawIconWithValue + call DrawPlayArea_IconWithValue ; discard pile ldh a, [hWhoseTurn] @@ -1146,14 +1159,13 @@ DrawInPlayArea_Icons: ; 864d (2:464d) ld a, [de] ld b, a ld a, $d8 ; discard pile tile - call DrawIconWithValue + call DrawPlayArea_IconWithValue ret -; prints text HandText2 and a cross with -; decimal value of b +; prints text HandText_2 and a cross with decimal value of b ; input ; b = value to print alongside text -PrintsHandTextAndValue: ; 8676 (2:4676) +DrawPlayArea_HandText: ; 8676 (2:4676) ld d, [hl] inc hl ld e, [hl] @@ -1163,7 +1175,7 @@ PrintsHandTextAndValue: ; 8676 (2:4676) push hl push bc call InitTextPrinting - ldtx hl, HandText2 + ldtx hl, HandText_2 call ProcessTextFromID pop bc @@ -1297,9 +1309,9 @@ HandleCheckMenuInput_YourOrOppPlayArea: ; 86ac (2:46ac) call PlaySFXConfirmOrCancel scf ret - + .a_pressed - call DisplayCheckMenuCursor_OppPlayArea + call DisplayCheckMenuCursor_YourOrOppPlayArea ld a, $01 call PlaySFXConfirmOrCancel scf @@ -1356,12 +1368,11 @@ DrawCheckMenuCursor_YourOrOppPlayArea: ; 8743 (2:4743) or a ret -DisplayCheckMenuCursor_OppPlayArea: ; 8760 (2:4760) +DisplayCheckMenuCursor_YourOrOppPlayArea: ; 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 +; 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 @@ -1391,7 +1402,7 @@ Func_8764: ; 8764 (2:4764) ld hl, PlayAreaMenuParameters call InitializeMenuParameters call DrawWideTextBox - + ld hl, YourOrOppPlayAreaData call PlaceTextItems @@ -1435,7 +1446,7 @@ Func_8764: ; 8764 (2:4764) ld [hl], e inc hl ld [hl], d - + .loop_2 ld a, $01 ld [wVBlankOAMCopyToggle], a @@ -1479,7 +1490,7 @@ Func_8819: ; 8819 (2:4819) ld b, $01 ; left-shift b a number of times -; corresponding to this prize card +; corresponding to this prize card .loop or a jr z, .asm_8827 @@ -1520,7 +1531,7 @@ Func_8849: ; input: ; a = deck index of card to be loaded ; output: -; a = ce5c +; a = ce5c ; with upper bit set if turn was swapped Func_8855: ld b, a @@ -1924,7 +1935,7 @@ Func_8e42: ; 8e42 (2:4e42) call DrawWideTextBox ld hl, Unknown_9027 call PlaceTextItems - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink .asm_8e4e call DoFrame call HandleCheckMenuInput @@ -2183,7 +2194,7 @@ GetPointerToDeckCards: ; 9048 (2:5048) pop af ret -ResetCursorPositionAndBlink: ; 905a (2:505a) +ResetCheckMenuCursorPositionAndBlink: ; 905a (2:505a) xor a ld [wCheckMenuCursorXPosition], a ld [wCheckMenuCursorYPosition], a @@ -2244,7 +2255,7 @@ HandleCheckMenuInput: ; 9065 (2:5065) ld [wCheckMenuCursorXPosition], a ld a, e ld [wCheckMenuCursorYPosition], a - + ; reset cursor blink xor a ld [wCheckMenuCursorBlinkCounter], a @@ -2578,10 +2589,9 @@ Func_9345: ; 9345 (2:5345) Func_9843: ; 9843 (2:5843) INCROM $9843, $98a6 -; 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 +; determines the ones and tens digits in a for printing +; the ones place is added $20 (SYM_0) so that it maps to a numerical character +; if the tens is 0, it maps to an empty character ; a = value to calculate digits CalculateOnesAndTensDigits: ; 98a6 (2:58a6) push af @@ -2657,7 +2667,7 @@ Func_b19d: ; b19d (2:719d) ld a, [wcea1] add b ld [wd088], a - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink call DrawWideTextBox ld hl, $7274 call PlaceTextItems @@ -2825,7 +2835,7 @@ Func_ba04: ; ba04 (2:7a04) cp $ff jp z, $7b0d ld [wd088], a - call ResetCursorPositionAndBlink + call ResetCheckMenuCursorPositionAndBlink xor a ld [wce5e], a call DrawWideTextBox diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 7a20b2f..fbf9016 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -158,7 +158,7 @@ Func_180d5: ; 180d5 (6:40d5) .asm_006_40da xor a ld [wCheckMenuCursorBlinkCounter], a - farcall $2, $42ce + farcall _DrawInPlayArea call EnableLCD call IsClairvoyanceActive jr c, .asm_006_40ef diff --git a/src/wram.asm b/src/wram.asm index 3ded6e7..b8f2f78 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1321,8 +1321,8 @@ wce5e:: ; ce5e ds $1 ; this is used to store last cursor position -; in the Your Play Area screen -wLastCursorPosition_YourOrOppPlayArea:: ; ce5f +; in the "Your Play Area" and the "Opp. Play Area" screens +wYourOrOppPlayAreaLastCursorPosition:: ; ce5f ds $1 wce60:: ; ce60 -- cgit v1.2.3 From 5f95d24c4deeb336b3acc3b0009ae3178da782f7 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sat, 20 Jul 2019 19:49:37 +0200 Subject: Some more bank2 cleanup --- src/engine/bank02.asm | 85 ++++++++++++++++++++++++++------------------------- src/engine/bank06.asm | 2 +- src/engine/home.asm | 12 ++++++-- src/wram.asm | 14 ++++++--- 4 files changed, 62 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 38d74f7..30c5299 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -53,7 +53,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .draw ld h, a ld l, a - call DrawYourOrOppPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea ld a, [wCheckMenuCursorYPosition] sla a @@ -174,7 +174,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld h, a .cursor - call DrawYourOrOppPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea ; convert cursor position and ; store it in wYourOrOppPlayAreaLastCursorPosition @@ -384,20 +384,20 @@ YourOrOppPlayAreaArrowPositions_OpponentDiscardPile: db 0, 8 db $ff -; loads tiles and icons to display your/opp play area +; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player -; h = turn holder 1 -; l = turn holder 2 -DrawYourOrOppPlayArea_LoadTurnHolders: ; 8209 (2:4209) +; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout] +DrawYourOrOppPlayArea: ; 8209 (2:4209) ; loads the turn holders ld a, h - ld [wTurnHolder1], a + ld [wCheckMenuPlayAreaWhichDuelist], a ld a, l - ld [wTurnHolder2], a + ld [wCheckMenuPlayAreaWhichLayout], a ; fallthrough ; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player +; input: [wCheckMenuPlayAreaWhichDuelist] and [wCheckMenuPlayAreaWhichLayout] _DrawYourOrOppPlayArea: ; 8211 (2:4211) xor a ld [wTileMapFill], a @@ -413,7 +413,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) call LoadSymbolsFont call LoadDeckAndDiscardPileIcons - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] cp PLAYER_TURN jr nz, .opp_turn1 @@ -441,7 +441,7 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) ldh a, [hWhoseTurn] cp PLAYER_TURN jr nz, .opp_turn2 - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] cp PLAYER_TURN jr nz, .swap .opp_turn2 @@ -453,9 +453,9 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) call SwapTurn .draw - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a - ld a, [wTurnHolder2] + ld a, [wCheckMenuPlayAreaWhichLayout] cp b jr nz, .not_equal @@ -468,7 +468,8 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) call DrawPlayArea_BenchCards xor a call DrawYourOrOppPlayArea_Icons - jr .lcd + jr .done + .not_equal ld hl, PrizeCardsCoordinateData_YourOrOppPlayArea.opponent call DrawPlayArea_PrizeCards @@ -480,14 +481,14 @@ _DrawYourOrOppPlayArea: ; 8211 (2:4211) ld a, $01 call DrawYourOrOppPlayArea_Icons -.lcd +.done call EnableLCD ret Func_82b6: ; 82b6 (2:42b6) - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a - ld a, [wTurnHolder2] + ld a, [wCheckMenuPlayAreaWhichLayout] cp b jr nz, .not_equal @@ -524,8 +525,8 @@ _DrawInPlayArea: ; 82ce (2:42ce) ; reset turn holders ldh a, [hWhoseTurn] - ld [wTurnHolder1], a - ld [wTurnHolder2], a + ld [wCheckMenuPlayAreaWhichDuelist], a + ld [wCheckMenuPlayAreaWhichLayout], a ; player prize cards ld hl, PrizeCardsCoordinateData_InPlayArea.player @@ -541,7 +542,7 @@ _DrawInPlayArea: ; 82ce (2:42ce) call SwapTurn ldh a, [hWhoseTurn] - ld [wTurnHolder1], a + ld [wCheckMenuPlayAreaWhichDuelist], a call SwapTurn ; opponent prize cards @@ -575,8 +576,8 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) ; player cards ld a, PLAYER_TURN - ld [wTurnHolder1], a - ld [wTurnHolder2], a + ld [wCheckMenuPlayAreaWhichDuelist], a + ld [wCheckMenuPlayAreaWhichLayout], a ld hl, PrizeCardsCoordinateData_2.player call DrawPlayArea_PrizeCards lb de, 5, 10 ; coordinates @@ -585,7 +586,7 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) ; opponent cards ld a, OPPONENT_TURN - ld [wTurnHolder1], a + ld [wCheckMenuPlayAreaWhichDuelist], a ld hl, PrizeCardsCoordinateData_2.opponent call DrawPlayArea_PrizeCards lb de, 1, 0 ; coordinates @@ -594,21 +595,21 @@ _DrawPlayersPrizeAndBenchCards: ; 833c (2:433c) ret ; draws the active card gfx at coordinates de -; of the player (or opponent) depending on wTurnHolder1 +; of the player (or opponent) depending on wCheckMenuPlayAreaWhichDuelist ; input: ; de = coordinates DrawYourOrOppPlayArea_ActiveCardGfx: ; 837e (2:437e) push de ld a, DUELVARS_ARENA_CARD ld l, a - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld h, a ld a, [hl] cp -1 jr z, .no_pokemon ld d, a - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a ldh a, [hWhoseTurn] cp b @@ -623,7 +624,7 @@ DrawYourOrOppPlayArea_ActiveCardGfx: ; 837e (2:437e) call SwapTurn .draw - lb de, $8a, $00 ; destination offset of loaded gfx + ld de, v0Tiles1 + $20 tiles ; destination offset of loaded gfx ld hl, wLoadedCard1Gfx ld a, [hli] ld h, [hl] @@ -734,13 +735,13 @@ DrawInPlayArea_ActiveCardGfx: ; 83cc (2:43cc) ret ; draws prize cards depending on the turn -; loaded in wTurnHolder1 +; loaded in wCheckMenuPlayAreaWhichDuelist ; input: ; hl = pointer to coordinates DrawPlayArea_PrizeCards: ; 8464 (2:4464) push hl call GetDuelInitialPrizesUpperBitsSet - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld h, a ld l, DUELVARS_PRIZES ld a, [hl] @@ -869,15 +870,15 @@ GetDuelInitialPrizesUpperBitsSet: ; 84fc (2:44fc) ld [wDuelInitialPrizesUpperBitsSet], a ret -; draws filled and empty bench slots depending on the turn loaded in wTurnHolder1 -; if wTurnHolder1 is different from wTurnHolder2 adjusts coordinates of the bench slots +; draws filled and empty bench slots depending on the turn loaded in wCheckMenuPlayAreaWhichDuelist +; if wCheckMenuPlayAreaWhichDuelist is different from wCheckMenuPlayAreaWhichLayout adjusts coordinates of the bench slots ; input: ; de = coordinates to draw bench ; c = spacing between slots DrawPlayArea_BenchCards: ; 8511 (2:4511) - ld a, [wTurnHolder2] + ld a, [wCheckMenuPlayAreaWhichLayout] ld b, a - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] cp b jr z, .skip @@ -896,7 +897,7 @@ DrawPlayArea_BenchCards: ; 8511 (2:4511) ld c, a ; c = $ff - c + 1 - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] .skip ld h, a ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA @@ -952,7 +953,7 @@ DrawPlayArea_BenchCards: ; 8511 (2:4511) jr .loop_1 .done - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld h, a ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA ld b, [hl] @@ -1007,7 +1008,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) .draw ; hand icon and value - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_IN_HAND ld a, [de] @@ -1016,7 +1017,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) call DrawPlayArea_HandText ; deck icon and value - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK ld a, [de] @@ -1028,7 +1029,7 @@ DrawYourOrOppPlayArea_Icons: ; 85aa (2:45aa) call DrawPlayArea_IconWithValue ; discard pile icon and value - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld d, a ld e, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE ld a, [de] @@ -1386,7 +1387,7 @@ Func_8764: ; 8764 (2:4764) ldh a, [hWhoseTurn] ld h, a ld l, a - call DrawYourOrOppPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea .swap ld a, [$ce56] @@ -1419,7 +1420,7 @@ Func_8764: ; 8764 (2:4764) jp nz, Func_8883 ; jump if not first option ; hCurMenuItem = 0 - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a ldh a, [hWhoseTurn] cp b @@ -1428,7 +1429,7 @@ Func_8764: ; 8764 (2:4764) ; switch the play area to draw ld h, a ld l, a - call DrawYourOrOppPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea xor a ld [$ce56], a @@ -1562,7 +1563,7 @@ Func_8855: ret Func_8883: ; 8883 (2:4883) - ld a, [wTurnHolder1] + ld a, [wCheckMenuPlayAreaWhichDuelist] ld b, a ldh a, [hWhoseTurn] cp b @@ -1578,7 +1579,7 @@ Func_8883: ; 8883 (2:4883) .draw ld h, a - call DrawYourOrOppPlayArea_LoadTurnHolders + call DrawYourOrOppPlayArea .text call DrawWideTextBox diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index fbf9016..90ee100 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -1122,7 +1122,7 @@ Func_006_50fb: ; 190fb (6:50fb) ld a, [wWhoseTurn] ld l, a .asm_006_5127 - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayArea_Bank0 pop af ld [wDuelDisplayedScreen], a .asm_006_512e diff --git a/src/engine/home.asm b/src/engine/home.asm index 40a1f85..1425359 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -9303,11 +9303,17 @@ Func_30a6: ; 30a6 (0:30a6) call BankswitchROM ret -DrawYourOrOppPlayArea: ; 30bc (0:30bc) +; loads tiles and icons to display Your Play Area / Opp. Play Area screen, +; and draws the screen according to the turn player +; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout] +; similar to DrawYourOrOppPlayArea (bank 2) except it also draws a wide text box. +; this is because bank 2's DrawYourOrOppPlayArea is supposed to come from the Check Menu, +; so the text box is always already there. +DrawYourOrOppPlayArea_Bank0: ; 30bc (0:30bc) ld a, h - ld [wTurnHolder1], a + ld [wCheckMenuPlayAreaWhichDuelist], a ld a, l - ld [wTurnHolder2], a + ld [wCheckMenuPlayAreaWhichLayout], a ldh a, [hBankROM] push af ld a, BANK(_DrawYourOrOppPlayArea) diff --git a/src/wram.asm b/src/wram.asm index b8f2f78..1f9eca1 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1283,12 +1283,16 @@ wTextBoxLabel:: ; ce4c wCoinTossScreenTextID:: ; ce4e ds $2 -; these hold either player or opponent turn -; for temporary calculations -wTurnHolder1:: ; ce50 +; set to PLAYER_TURN in the "Your Play Area" screen +; set to OPPONENT_TURN in the "Opp Play Area" screen +; set to [hWhoseTurn] in the "In Play Area" screen +wCheckMenuPlayAreaWhichDuelist:: ; ce50 ds $1 -wTurnHolder2:: ; ce51 +; apparently complements wCheckMenuPlayAreaWhichDuelist to be able to combine +; the usual player or opponent layout with the opposite duelist information +; appears not to be relevant in the "In Play Area" screen +wCheckMenuPlayAreaWhichLayout:: ; ce51 ds $1 ; holds the position of the cursor @@ -1452,7 +1456,7 @@ wceb4:: ; ceb4 wceb5:: ; ceb5 ds $1 -; used to store the tens digit and +; used to store the tens digit and ; ones digit of a value for printing ; the ones digit is added $20 ; ceb6 = ones digit (+ $20) -- cgit v1.2.3 From 112777ab450a38ec488dfdc9c2d41bef5a7ddb70 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 21 Jul 2019 14:39:11 +0200 Subject: Minor improvements regarding poison and double poison status constants --- src/engine/bank01.asm | 28 +++++++++++++++------------- src/wram.asm | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 868d284..54584af 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -2464,7 +2464,7 @@ DrawDuelHUDs: ; 503a (1:503a) inc c call CheckPrintPoisoned inc c - call CheckPrintDoublePoisoned + call CheckPrintDoublePoisoned ; if double poisoned, print a second poison icon call SwapTurn lb de, 7, 0 ; coordinates for opponent's arena card name and info icons lb bc, 3, 1 ; coordinates for opponent's attached energies and HP bar @@ -2477,7 +2477,7 @@ DrawDuelHUDs: ; 503a (1:503a) dec c call CheckPrintPoisoned dec c - call CheckPrintDoublePoisoned + call CheckPrintDoublePoisoned ; if double poisoned, print a second poison icon call SwapTurn ret ; 0x5093 @@ -5645,9 +5645,9 @@ CheckPrintPoisoned: ; 63bb (1:63bb) ; given a card's status in a, print the Poison symbol at bc if it's double poisoned CheckPrintDoublePoisoned: ; 63c7 (1:63c7) push af - and DOUBLE_POISONED - POISONED - jr nz, CheckPrintPoisoned.poison ; double poison (print a second symbol) - jr CheckPrintPoisoned.print ; not double poisoned + and DOUBLE_POISONED & (POISONED ^ $ff) + jr nz, CheckPrintPoisoned.poison ; double poisoned (print SYM_POISONED) + jr CheckPrintPoisoned.print ; not double poisoned (print SYM_SPACE) ; 0x63ce ; given a card's status in a, print the Confusion, Sleep, or Paralysis symbol at bc @@ -6117,7 +6117,7 @@ DuelDataToSave: ; 6729 (1:6729) ; dw address, number_of_bytes_to_copy dw wPlayerDuelVariables, wOpponentDuelVariables - wPlayerDuelVariables dw wOpponentDuelVariables, wPlayerDeck - wOpponentDuelVariables - dw wPlayerDeck, wNameBuffer + $10 - wPlayerDeck + dw wPlayerDeck, wDuelTempList - wPlayerDeck dw wWhoseTurn, wDuelTheme + $1 - wWhoseTurn dw hWhoseTurn, $1 dw wRNG1, wRNGCounter + $1 - wRNG1 @@ -6824,12 +6824,12 @@ Func_6ba2: ; 6ba2 (1:6ba2) ; apply and/or refresh status conditions and other events that trigger between turns HandleBetweenTurnsEvents: ; 6baf (1:6baf) - call IsArenaPokemonAsleepOrDoublePoisoned + call IsArenaPokemonAsleepOrPoisoned jr c, .something_to_handle cp PARALYZED jr z, .something_to_handle call SwapTurn - call IsArenaPokemonAsleepOrDoublePoisoned + call IsArenaPokemonAsleepOrPoisoned call SwapTurn jr c, .something_to_handle call DiscardAttachedPluspowers @@ -6839,8 +6839,8 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf) ret .something_to_handle ; either: - ; 1. turn holder's arena Pokemon is paralyzed, asleep or double poisoned - ; 2. non-turn holder's arena Pokemon is asleep or double poisoned + ; 1. turn holder's arena Pokemon is paralyzed, asleep, poisoned or double poisoned + ; 2. non-turn holder's arena Pokemon is asleep, poisoned or double poisoned call Func_3b21 call ZeroObjectPositionsAndToggleOAMCopy call EmptyScreen @@ -6923,14 +6923,16 @@ DiscardAttachedDefenders: ; 6c56 (1:6c56) jp MoveCardToDiscardPileIfInArena ; 0x6c68 -; return carry if the turn holder's arena Pokemon card is double poisoned or asleep. +; return carry if the turn holder's arena Pokemon card is asleep, poisoned, or double poisoned. ; also, if confused, paralyzed, or asleep, return the status condition in a. -IsArenaPokemonAsleepOrDoublePoisoned: ; 6c68 (1:6c68) +IsArenaPokemonAsleepOrPoisoned: ; 6c68 (1:6c68) ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable or a ret z - and DOUBLE_POISONED + ; note that POISONED | DOUBLE_POISONED is the same as just DOUBLE_POISONED ($c0) + ; poison status masking is normally done with PSN_DBLPSN ($f0) + and POISONED | DOUBLE_POISONED jr nz, .set_carry ld a, [hl] and CNF_SLP_PRZ diff --git a/src/wram.asm b/src/wram.asm index 1f9eca1..fbeb907 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -1285,7 +1285,7 @@ wCoinTossScreenTextID:: ; ce4e ; set to PLAYER_TURN in the "Your Play Area" screen ; set to OPPONENT_TURN in the "Opp Play Area" screen -; set to [hWhoseTurn] in the "In Play Area" screen +; alternates when drawing the "In Play Area" screen wCheckMenuPlayAreaWhichDuelist:: ; ce50 ds $1 -- cgit v1.2.3 From 92c2fc50a26eddc1bf0dda5afbe45f355dfdaa8f Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 21 Jul 2019 18:09:54 +0200 Subject: More progress related to move effects --- src/constants/duel_constants.asm | 4 + src/data/effect_commands.asm | 22 ++-- src/engine/bank01.asm | 13 ++- src/engine/bank02.asm | 40 ++++---- src/engine/bank06.asm | 4 +- src/engine/effect_functions.asm | 216 ++++++++++++++++++++++++++++++++------- src/engine/home.asm | 16 +-- src/text/text1.asm | 6 +- src/text/text2.asm | 2 +- src/text/text_offsets.asm | 8 +- src/wram.asm | 34 +++--- 11 files changed, 255 insertions(+), 110 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index d9b9e9c..943881b 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -165,6 +165,10 @@ NO_DAMAGE_OR_EFFECT_NSHIELD EQU $05 WEAKNESS EQU 1 RESISTANCE EQU 2 +; wEffectFailed constants +EFFECT_FAILED_NO_EFFECT EQU $01 +EFFECT_FAILED_UNSUCCESSFUL EQU $02 + ; Box message id's const_def const BOXMSG_PLAYERS_TURN diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index 6dc74ee..fa1bc81 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -109,8 +109,8 @@ ZubatLeechLifeEffectCommands: db $00 BeedrillTwineedleEffectCommands: - dbw $03, $47f5 - dbw $09, $47ed + dbw $03, Twineedle_MultiplierEffect + dbw $09, Twineedle_AIEffect db $00 BeedrillPoisonStingEffectCommands: @@ -127,8 +127,8 @@ ExeggcuteLeechSeedEffectCommands: db $00 KoffingFoulGasEffectCommands: - dbw $03, $482a - dbw $09, $4822 + dbw $03, FoulGas_PoisonOrConfusionEffect + dbw $09, FoulGas_AIEffect db $00 MetapodStiffenEffectCommands: @@ -158,19 +158,19 @@ ExeggutorTeleportEffectCommands: db $00 ExeggutorBigEggsplosionEffectCommands: - dbw $03, $4944 - dbw $09, $4925 + dbw $03, BigEggsplosion_MultiplierEffect + dbw $09, BigEggsplosion_AIEffect db $00 NidokingThrashEffectCommands: - dbw $03, $4973 - dbw $04, $4982 - dbw $09, $496b + dbw $03, Thrash_ModifierEffect + dbw $04, Func_2c982 + dbw $09, Thrash_AIEffect db $00 NidokingToxicEffectCommands: - dbw $03, $4994 - dbw $09, $498c + dbw $03, Toxic_DoublePoisonEffect + dbw $09, Toxic_AIEffect db $00 NidoqueenBoyfriendsEffectCommands: diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 54584af..c7a31d0 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -7191,9 +7191,9 @@ Func_6e49: ; 6e49 (1:6e49) INCROM $6e49, $700a ; print one of the "There was no effect from" texts depending -; on the value at wccf1 ($00 or a status condition constant) +; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant) PrintThereWasNoEffectFromStatusText: ; 700a (1:700a) - ld a, [wccf1] + ld a, [wNoEffectFromStatus] or a jr nz, .status ld hl, wLoadedMoveName @@ -7415,18 +7415,21 @@ ClearNonTurnTemporaryDuelvars_CopyStatus: ; 7189 (1:7189) ret ; 0x7195 +; update non-turn holder's DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE +; if wccef == 0: set to [wDealtDamage] +; if wceef != 0: set to 0 Func_7195: ; 7195 (1:7195) ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE call GetNonTurnDuelistVariable ld a, [wccef] or a - jr nz, .asm_71a9 + jr nz, .zero ld a, [wDealtDamage] ld [hli], a - ld a, [wccc0] + ld a, [wDealtDamage + 1] ld [hl], a ret -.asm_71a9 +.zero xor a ld [hli], a ld [hl], a diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm index 30c5299..a4a0f62 100644 --- a/src/engine/bank02.asm +++ b/src/engine/bank02.asm @@ -53,7 +53,7 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) .draw ld h, a ld l, a - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayAreaScreen ld a, [wCheckMenuCursorYPosition] sla a @@ -93,11 +93,11 @@ DuelCheckMenu_YourPlayArea: ; 8047 (2:4047) jr .draw .table ; 8098 (2:4098) - dw OpenDuelScreen_TurnHolderPlayArea - dw OpenDuelScreen_TurnHolderHand - dw OpenDuelScreen_TurnHolderDiscardPile + dw OpenYourOrOppPlayAreaScreen_TurnHolderPlayArea + dw OpenYourOrOppPlayAreaScreen_TurnHolderHand + dw OpenYourOrOppPlayAreaScreen_TurnHolderDiscardPile -OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e) +OpenYourOrOppPlayAreaScreen_TurnHolderPlayArea: ; 809e (2:409e) ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderPlayAreaScreen @@ -105,7 +105,7 @@ OpenDuelScreen_TurnHolderPlayArea: ; 809e (2:409e) ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderPlayArea: +OpenYourOrOppPlayAreaScreen_NonTurnHolderPlayArea: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderPlayAreaScreen @@ -113,7 +113,7 @@ OpenDuelScreen_NonTurnHolderPlayArea: ldh [hWhoseTurn], a ret -OpenDuelScreen_TurnHolderHand: +OpenYourOrOppPlayAreaScreen_TurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderHandScreen_Simple @@ -121,7 +121,7 @@ OpenDuelScreen_TurnHolderHand: ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderHand: +OpenYourOrOppPlayAreaScreen_NonTurnHolderHand: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderHandScreen_Simple @@ -129,7 +129,7 @@ OpenDuelScreen_NonTurnHolderHand: ldh [hWhoseTurn], a ret -OpenDuelScreen_TurnHolderDiscardPile: +OpenYourOrOppPlayAreaScreen_TurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenTurnHolderDiscardPileScreen @@ -137,7 +137,7 @@ OpenDuelScreen_TurnHolderDiscardPile: ldh [hWhoseTurn], a ret -OpenDuelScreen_NonTurnHolderDiscardPile: +OpenYourOrOppPlayAreaScreen_NonTurnHolderDiscardPile: ldh a, [hWhoseTurn] push af bank1call OpenNonTurnHolderDiscardPileScreen @@ -174,7 +174,7 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) ld h, a .cursor - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayAreaScreen ; convert cursor position and ; store it in wYourOrOppPlayAreaLastCursorPosition @@ -230,9 +230,9 @@ DuelCheckMenu_OppPlayArea: ; 80da (2:40da) jr .turns .table - dw OpenDuelScreen_NonTurnHolderPlayArea - dw OpenDuelScreen_NonTurnHolderHand - dw OpenDuelScreen_NonTurnHolderDiscardPile + dw OpenYourOrOppPlayAreaScreen_NonTurnHolderPlayArea + dw OpenYourOrOppPlayAreaScreen_NonTurnHolderHand + dw OpenYourOrOppPlayAreaScreen_NonTurnHolderDiscardPile CheckMenuData: ; (2:4158) textitem 2, 14, InPlayAreaText @@ -387,7 +387,7 @@ YourOrOppPlayAreaArrowPositions_OpponentDiscardPile: ; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player ; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout] -DrawYourOrOppPlayArea: ; 8209 (2:4209) +DrawYourOrOppPlayAreaScreen: ; 8209 (2:4209) ; loads the turn holders ld a, h ld [wCheckMenuPlayAreaWhichDuelist], a @@ -398,7 +398,7 @@ DrawYourOrOppPlayArea: ; 8209 (2:4209) ; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player ; input: [wCheckMenuPlayAreaWhichDuelist] and [wCheckMenuPlayAreaWhichLayout] -_DrawYourOrOppPlayArea: ; 8211 (2:4211) +_DrawYourOrOppPlayAreaScreen: ; 8211 (2:4211) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -503,7 +503,7 @@ Func_82b6: ; 82b6 (2:42b6) ; loads tiles and icons to display the In Play Area screen, ; and draws the screen -_DrawInPlayArea: ; 82ce (2:42ce) +DrawInPlayAreaScreen: ; 82ce (2:42ce) xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -1387,7 +1387,7 @@ Func_8764: ; 8764 (2:4764) ldh a, [hWhoseTurn] ld h, a ld l, a - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayAreaScreen .swap ld a, [$ce56] @@ -1429,7 +1429,7 @@ Func_8764: ; 8764 (2:4764) ; switch the play area to draw ld h, a ld l, a - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayAreaScreen xor a ld [$ce56], a @@ -1579,7 +1579,7 @@ Func_8883: ; 8883 (2:4883) .draw ld h, a - call DrawYourOrOppPlayArea + call DrawYourOrOppPlayAreaScreen .text call DrawWideTextBox diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 90ee100..cb1b0a9 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -158,7 +158,7 @@ Func_180d5: ; 180d5 (6:40d5) .asm_006_40da xor a ld [wCheckMenuCursorBlinkCounter], a - farcall _DrawInPlayArea + farcall DrawInPlayAreaScreen call EnableLCD call IsClairvoyanceActive jr c, .asm_006_40ef @@ -1122,7 +1122,7 @@ Func_006_50fb: ; 190fb (6:50fb) ld a, [wWhoseTurn] ld l, a .asm_006_5127 - call DrawYourOrOppPlayArea_Bank0 + call DrawYourOrOppPlayAreaScreen_Bank0 pop af ld [wDuelDisplayedScreen], a .asm_006_512e diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index b3c707b..c8d8f24 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -7,6 +7,7 @@ PoisonEffect: ; 2c007 (b:4007) lb bc, CNF_SLP_PRZ, POISONED jr ApplyStatusEffect +DoublePoisonEffect: ; 2c00c (b:400c) lb bc, CNF_SLP_PRZ, DOUBLE_POISONED jr ApplyStatusEffect @@ -56,7 +57,7 @@ ApplyStatusEffect: .cant_induce_status ld a, c - ld [wccf1], a + ld [wNoEffectFromStatus], a call SetNoEffectFromStatus or a ret @@ -118,49 +119,50 @@ Func_2c08c: ; 0x2c09c SetNoEffectFromStatus: ; 2c09c (b:409c) - ld a, $1 - ld [wcced], a + ld a, EFFECT_FAILED_NO_EFFECT + ld [wEffectFailed], a ret ; 0x2c0a2 SetWasUnsuccessful: ; 2c0a2 (b:40a2) - ld a, $2 - ld [wcced], a + ld a, EFFECT_FAILED_UNSUCCESSFUL + ld [wEffectFailed], a ret ; 0x2c0a8 INCROM $2c0a8, $2c0d4 ; Sets some flags for AI use -; if target double poisoned -; [wccbb] <- [wDamage] -; [wccbc] <- [wDamage] +; if target poisoned +; [wAIMinDamage] <- [wDamage] +; [wAIMaxDamage] <- [wDamage] ; else -; [wccbb] <- [wDamage] + d -; [wccbc] <- [wDamage] + e -; [wDamage] <- [wDamage] + a +; [wAIMinDamage] <- [wDamage] + d +; [wAIMaxDamage] <- [wDamage] + e +; [wDamage] <- [wDamage] + a Func_2c0d4: ; 2c0d4 (b:40d4) push af ld a, DUELVARS_ARENA_CARD_STATUS call GetNonTurnDuelistVariable - and DOUBLE_POISONED - jr z, .not_double_poisoned + and POISONED | DOUBLE_POISONED + jr z, Func_2c0e9.skip_push_af pop af ld a, [wDamage] - ld [wccbb], a - ld [wccbc], a + ld [wAIMinDamage], a + ld [wAIMaxDamage], a ret +Func_2c0e9: ; 2c0e9 (b:40e9) push af -.not_double_poisoned +.skip_push_af ld hl, wDamage ld a, [hl] add d - ld [wccbb], a + ld [wAIMinDamage], a ld a, [hl] add e - ld [wccbc], a + ld [wAIMaxDamage], a pop af add [hl] ld [hl], a @@ -168,17 +170,17 @@ Func_2c0d4: ; 2c0d4 (b:40d4) ; 0x2c0fb ; Sets some flags for AI use -; [wDamage] <- a -; [wccbb] <- d -; [wccbc] <- e +; [wDamage] <- a +; [wAIMinDamage] <- d +; [wAIMaxDamage] <- e Func_2c0fb: ; 2c0fb (b:40fb) ld [wDamage], a xor a ld [wDamage + 1], a ld a, d - ld [wccbb], a + ld [wAIMinDamage], a ld a, e - ld [wccbc], a + ld [wAIMaxDamage], a ret ; 0x2c10b @@ -219,14 +221,24 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149) ret ; 0x2c166 - INCROM $2c166, $2c6f0 +Func_2c166: ; 2c166 (b:4166) + ld [wDamage], a + ld [wAIMinDamage], a + ld [wAIMaxDamage], a + xor a + ld [wDamage + 1], a + ret +; 0x2c174 + + INCROM $2c174, $2c6f0 SpitPoison_AIEffect: ; 2c6f0 (b:46f0) - ld a, $5 - lb de, $0, $a + ld a, 5 + lb de, 0, 10 jp Func_2c0fb ; 0x2c6f8 +; If heads, defending Pokemon becomes poisoned SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) ldtx de, PoisonCheckText call TossCoin_BankB @@ -240,19 +252,20 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) INCROM $2c70a, $2c730 PoisonFang_AIEffect: ; 2c730 (b:4730) - ld a, $a - lb de, $a, $a + ld a, 10 + lb de, 10, 10 jp Func_2c0d4 ; 0x2c738 WeepinbellPoisonPowder_AIEffect: ; 2c738 (b:4738) - ld a, $5 - lb de, $0, $a + ld a, 5 + lb de, 0, 10 jp Func_2c0d4 ; 0x2c740 INCROM $2c740, $2c77e +; If heads, defending Pokemon can't retreat next turn AcidEffect: ; 2c77e (b:477e) ldtx de, AcidCheckText call TossCoin_BankB @@ -263,12 +276,12 @@ AcidEffect: ; 2c77e (b:477e) ; 0x2c78b GloomPoisonPowder_AIEffect: ; 2c78b (b:478b) - ld a, $a - lb de, $a, $a + ld a, 10 + lb de, 10, 10 jp Func_2c0d4 ; 0x2c793 -; confuses both the target and the user +; Defending Pokemon and user become confused FoulOdorEffect: ; 2c793 (b:4793) call ConfusionEffect call SwapTurn @@ -277,6 +290,7 @@ FoulOdorEffect: ; 2c793 (b:4793) ret ; 0x2c7a0 +; If heads, prevent all damage done to user next turn KakunaStiffenEffect: ; 2c7a0 (b:47a0) ldtx de, IfHeadsNoDamageNextTurnText call TossCoin_BankB @@ -289,13 +303,14 @@ KakunaStiffenEffect: ; 2c7a0 (b:47a0) ; 0x2c7b4 KakunaPoisonPowder_AIEffect: ; 2c7b4 (b:47b4) - ld a, $5 - lb de, $0, $a + ld a, 5 + lb de, 0, 10 jp Func_2c0d4 ; 0x2c7bc INCROM $2c7bc, $2c7d0 +; During your next turn, double damage SwordsDanceEffect: ; 2c7d0 (b:47d0) ld a, [wTempTurnDuelistCardID] cp SCYTHER @@ -305,15 +320,54 @@ SwordsDanceEffect: ; 2c7d0 (b:47d0) ret ; 0x2c7dc +; If heads, defending Pokemon becomes confused ZubatSupersonicEffect: ; 2c7dc (b:47dc) call Confusion50PercentEffect call nc, SetNoEffectFromStatus ret ; 0x2c7e3 - INCROM $2c7e3, $2c836 + INCROM $2c7e3, $2c7ed + +Twineedle_AIEffect: ; 2c7ed (b:47ed) + ld a, 30 + lb de, 0, 60 + jp Func_2c0fb +; 0x2c7f5 + +; Flip 2 coins; deal 30x number of heads +Twineedle_MultiplierEffect: ; 2c7f5 (b:47f5) + ld hl, 30 + call LoadTxRam3 + ldtx de, DamageCheckIfHeadsXDamageText + ld a, 2 + call TossCoinATimes_BankB + ld e, a + add a + add e + call ATimes10 + call Func_2c166 + ret +; 0x2c80d + + INCROM $2c80d, $2c822 + +FoulGas_AIEffect: ; 2c822 (b:4822) + ld a, 5 + lb de, 0, 10 + jp Func_2c0e9 +; 0x2c82a + +; If heads, defending Pokemon becomes poisoned. If tails, defending Pokemon becomes confused +FoulGas_PoisonOrConfusionEffect: ; 2c82a (b:482a) + ldtx de, PoisonedIfHeadsConfusedIfTailsText + call TossCoin_BankB + jp c, PoisonEffect + jp ConfusionEffect +; 0x2c836 ; an exact copy of KakunaStiffenEffect +; If heads, prevent all damage done to user next turn MetapodStiffenEffect: ; 2c836 (b:4836) ldtx de, IfHeadsNoDamageNextTurnText call TossCoin_BankB @@ -325,4 +379,92 @@ MetapodStiffenEffect: ; 2c836 (b:4836) ret ; 0x2c84a - INCROM $2c84a, $30000 + INCROM $2c84a, $2c925 + +BigEggsplosion_AIEffect: ; 2c925 (b:4925) + ldh a, [hTempPlayAreaLocation_ff9d] + ld e, a + call GetPlayAreaCardAttachedEnergies + ld a, [wTotalAttachedEnergies] + call SetDamageToATimes20 + inc h + jr nz, .capped + ld l, 255 +.capped + ld a, l + ld [wAIMaxDamage], a + srl a + ld [wDamage], a + xor a + ld [wAIMinDamage], a + ret +; 0x2c944 + +; Flip coins equal to attached energies; deal 20x number of heads +BigEggsplosion_MultiplierEffect: ; 2c944 (b:4944) + ld e, PLAY_AREA_ARENA + call GetPlayAreaCardAttachedEnergies + ld hl, 20 + call LoadTxRam3 + ld a, [wTotalAttachedEnergies] + ldtx de, DamageCheckIfHeadsXDamageText + call TossCoinATimes_BankB +; fallthrough + +; set damage to 20*a. Also return result in hl +SetDamageToATimes20: ; 2c958 (b:4958) + ld l, a + ld h, $00 + ld e, l + ld d, h + add hl, hl + add hl, hl + add hl, de + add hl, hl + add hl, hl + ld a, l + ld [wDamage], a + ld a, h + ld [wDamage + 1], a + ret +; 0x2c96b + +Thrash_AIEffect: ; 2c96b (b:496b) + ld a, 35 + lb de, 30, 40 + jp Func_2c0fb +; 0x2c973 + +; If heads 10 more damage; if tails, 10 damage to itself +Thrash_ModifierEffect: ; 2c973 (b:4973) + ldtx de, IfHeadPlus10IfTails10ToYourselfText + call TossCoin_BankB + ldh [hTemp_ffa0], a + ret nc + ld a, 10 + call AddToDamage + ret +; 0x2c982 + +Func_2c982: ; 2c982 (b:4982) + ldh a, [hTemp_ffa0] + or a + ret nz + ld a, 10 + call Func_1955 + ret +; 0x2c98c + +Toxic_AIEffect: ; 2c98c (b:498c) + ld a, 20 + lb de, 20, 20 + jp Func_2c0e9 +; 0x2c994 + +; Defending Pokémon becomes poisoned, but takes 20 damage (double poisoned) +Toxic_DoublePoisonEffect: ; 2c994 (b:4994) + call DoublePoisonEffect + ret +; 0x2c998 + + INCROM $2c998, $30000 diff --git a/src/engine/home.asm b/src/engine/home.asm index 1425359..ff07a17 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -4453,11 +4453,11 @@ Func_16f6: ; 16f6 (0:16f6) xor a ld [wccec], a ld [wEffectFunctionsFeedbackIndex], a - ld [wcced], a + ld [wEffectFailed], a ld [wIsDamageToSelf], a ld [wccef], a ld [wccf0], a - ld [wccf1], a + ld [wNoEffectFromStatus], a bank1call ClearNonTurnTemporaryDuelvars_CopyStatus ret @@ -5175,10 +5175,10 @@ Func_1bb4: ; 1bb4 (0:1bb4) call ExchangeRNG ret -; prints one of the ThereWasNoEffectFrom*Text if wcced contains $1, -; and WasUnsuccessfulText if wcced contains $2 +; prints one of the ThereWasNoEffectFrom*Text if wEffectFailed contains EFFECT_FAILED_NO_EFFECT, +; and prints WasUnsuccessfulText if wEffectFailed contains EFFECT_FAILED_UNSUCCESSFUL Func_1bca: ; 1bca (0:1bca) - ld a, [wcced] + ld a, [wEffectFailed] or a ret z cp $1 @@ -9309,16 +9309,16 @@ Func_30a6: ; 30a6 (0:30a6) ; similar to DrawYourOrOppPlayArea (bank 2) except it also draws a wide text box. ; this is because bank 2's DrawYourOrOppPlayArea is supposed to come from the Check Menu, ; so the text box is always already there. -DrawYourOrOppPlayArea_Bank0: ; 30bc (0:30bc) +DrawYourOrOppPlayAreaScreen_Bank0: ; 30bc (0:30bc) ld a, h ld [wCheckMenuPlayAreaWhichDuelist], a ld a, l ld [wCheckMenuPlayAreaWhichLayout], a ldh a, [hBankROM] push af - ld a, BANK(_DrawYourOrOppPlayArea) + ld a, BANK(_DrawYourOrOppPlayAreaScreen) call BankswitchROM - call _DrawYourOrOppPlayArea + call _DrawYourOrOppPlayAreaScreen call DrawWideTextBox pop af call BankswitchROM diff --git a/src/text/text1.asm b/src/text/text1.asm index e7b0fe4..8789758 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -1093,7 +1093,7 @@ Text00e8: ; 37d92 (d:7d92) line "10 damage for each Heads!!!" done -Text00e9: ; 37dc9 (d:7dc9) +IfHeadPlus10IfTails10ToYourselfText: ; 37dc9 (d:7dc9) text "If Heads, + 10 damage!" line "If Tails, +10 damage to yourself!" done @@ -1142,12 +1142,12 @@ Text00f2: ; 37f9a (d:7f9a) text "Damage check" done -Text00f3: ; 37fa8 (d:7fa8) +DamageCheckIfHeadsPlusDamageText: ; 37fa8 (d:7fa8) text "Damage check!" line "If Heads, + damage!!" done -Text00f4: ; 37fcd (d:7fcd) +DamageCheckIfHeadsXDamageText: ; 37fcd (d:7fcd) text "Damage check!" line "If Heads, x damage!!" done diff --git a/src/text/text2.asm b/src/text/text2.asm index 78fb6f9..8dac791 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -22,7 +22,7 @@ PokemonsSleepCheckText: ; 380db (e:40db) text "'s Sleep check." done -Text00fa: ; 380ed (e:40ed) +PoisonedIfHeadsConfusedIfTailsText: ; 380ed (e:40ed) text "Opponent is Poisoned if Heads," line "and Confused if Tails." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index f1ca193..6e03ba2 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -234,7 +234,7 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text00e6 ; 0x00e6 textpointer Text00e7 ; 0x00e7 textpointer Text00e8 ; 0x00e8 - textpointer Text00e9 ; 0x00e9 + textpointer IfHeadPlus10IfTails10ToYourselfText ; 0x00e9 textpointer Text00ea ; 0x00ea textpointer Text00eb ; 0x00eb textpointer Text00ec ; 0x00ec @@ -244,14 +244,14 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text00f0 ; 0x00f0 textpointer IfHeadsNoDamageNextTurnText ; 0x00f1 textpointer Text00f2 ; 0x00f2 - textpointer Text00f3 ; 0x00f3 - textpointer Text00f4 ; 0x00f4 + textpointer DamageCheckIfHeadsPlusDamageText ; 0x00f3 + textpointer DamageCheckIfHeadsXDamageText ; 0x00f4 textpointer AcidCheckText ; 0x00f5 textpointer TransparencyCheckText ; 0x00f6 textpointer ConfusionCheckDamageText ; 0x00f7 textpointer ConfusionCheckRetreatText ; 0x00f8 textpointer PokemonsSleepCheckText ; 0x00f9 - textpointer Text00fa ; 0x00fa + textpointer PoisonedIfHeadsConfusedIfTailsText ; 0x00fa textpointer Text00fb ; 0x00fb textpointer Text00fc ; 0x00fc textpointer AttackUnsuccessfulText ; 0x00fd diff --git a/src/wram.asm b/src/wram.asm index fbeb907..d2821b2 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -190,9 +190,7 @@ wPlayerArenaCardDisabledMoveIndex:: ; c2f2 ; damage taken the last time the opponent attacked (0 if no damage) wPlayerArenaCardLastTurnDamage:: ; c2f3 - ds $1 - - ds $1 + ds $2 ; status condition received the last time the opponent attacked (0 if none) wPlayerArenaCardLastTurnStatus:: ; c2f5 @@ -333,9 +331,7 @@ wOpponentArenaCardDisabledMoveIndex:: ; c3f2 ds $1 wOpponentArenaCardLastTurnDamage:: ; c3f3 - ds $1 - - ds $1 + ds $2 wOpponentArenaCardLastTurnStatus:: ; c3f5 ds $1 @@ -919,24 +915,25 @@ wLoadedMove:: ; cca6 move_data_struct wLoadedMove ; the damage field of an used move is loaded here +; doubles as "wAIAverageDamage" when complementing wAIMinDamage and wAIMaxDamage +; little-endian wDamage:: ; ccb9 ds $2 -; wccbb and wccbc appear to be used for AI scoring -wccbb:: ; ccbb +; wAIMinDamage and wAIMaxDamage appear to be used for AI scoring +; they are updated with the minimum (or floor) damage of the current move +; and with the maximum (or ceiling) damage of the current move +wAIMinDamage:: ; ccbb ds $1 -wccbc:: ; ccbc +wAIMaxDamage:: ; ccbc ds $1 ds $2 ; damage dealt by an attack to a target wDealtDamage:: ; ccbf - ds $1 - -wccc0:: ; ccc0 - ds $1 + ds $2 ; WEAKNESS and RESISTANCE flags for a damaging attack wDamageEffectiveness:: ; ccc1 @@ -999,16 +996,15 @@ wccec:: ; ccec ds $1 ; used by the effect functions to return the cause of an effect to fail -; $01: was not affected by a status condition -; $02: prints WasUnsuccessfulText -wcced:: ; cced +; in order print the appropriate text +wEffectFailed:: ; cced ds $1 wccee:: ; ccee ds $1 -; when this is non-0, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE and the -; next duelvar are always set to 0 after an attack +; flag to determine whether DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE +; gets zeroed or gets updated with wDealtDamage wccef:: ; ccef ds $1 @@ -1017,7 +1013,7 @@ wccf0:: ; ccf0 ; effect functions return a status condition constant here when it had no effect ; on the target, in order to print one of the ThereWasNoEffectFrom* texts -wccf1:: ; ccf1 +wNoEffectFromStatus:: ; ccf1 ds $1 ; when non-0, allows the player to skip some delays during a duel by pressing B. -- cgit v1.2.3 From a0f261836f9201c93fdeacab63542dab7d78aa98 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 21 Jul 2019 22:41:12 +0200 Subject: Effect command constants and documentation --- src/constants/duel_constants.asm | 13 + src/data/effect_commands.asm | 1280 +++++++++++++++++++------------------- src/engine/bank01.asm | 10 +- src/engine/bank08.asm | 2 +- src/engine/home.asm | 32 +- 5 files changed, 680 insertions(+), 657 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 943881b..80fe3b0 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -154,6 +154,19 @@ SUBSTATUS3_HEADACHE EQU 1 CAN_EVOLVE_THIS_TURN_F EQU 7 CAN_EVOLVE_THIS_TURN EQU 1 << CAN_EVOLVE_THIS_TURN_F +; effect command constants (TryExecuteEffectCommandFunction) +; ordered by (roughly) execution time +EFFECTCMDTYPE_INITIAL_EFFECT_1 EQU $01 +EFFECTCMDTYPE_INITIAL_EFFECT_2 EQU $02 +EFFECTCMDTYPE_DISCARD_ENERGY EQU $06 +EFFECTCMDTYPE_REQUIRE_SELECTION EQU $05 +EFFECTCMDTYPE_BEFORE_DAMAGE EQU $03 +EFFECTCMDTYPE_AFTER_DAMAGE EQU $04 +EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN EQU $0a +EFFECTCMDTYPE_PKMN_POWER_TRIGGER EQU $07 +EFFECTCMDTYPE_AI EQU $09 +EFFECTCMDTYPE_UNKNOWN_08 EQU $08 + ; wNoDamageOrEffect constants NO_DAMAGE_OR_EFFECT_AGILITY EQU $01 NO_DAMAGE_OR_EFFECT_BARRIER EQU $02 diff --git a/src/data/effect_commands.asm b/src/data/effect_commands.asm index fa1bc81..0e1886e 100644 --- a/src/data/effect_commands.asm +++ b/src/data/effect_commands.asm @@ -2,13 +2,23 @@ EffectCommands: ; 186f7 (6:46f7) ; Each move has a two-byte effect pointer (move's 7th param) that points to one of these structures. ; Similarly, trainer cards have a two-byte pointer (7th param) to one of these structures, which determines the card's function. ; Energy cards also point to one of these, but their data is just $00. -; db CommandType ($01 - $0a) +; db EFFECTCMDTYPE_* ($01 - $0a) ; dw Function ; ... ; db $00 -; Commands are associated to a time or a scope (CommandType) that determines when their function is executed during the turn. -; For example type $03 is executed right before dealing damage while type $09 is AI related and executed during enemy turn only. +; Commands are associated to a time or a scope (EFFECTCMDTYPE_*) that determines when their function is executed during the turn. +; - EFFECTCMDTYPE_INITIAL_EFFECT_1: Executed right after move or trainer card is used. Bypasses Smokescreen and Sand Attack effects. +; - EFFECTCMDTYPE_INITIAL_EFFECT_2: Executed right after move, Pokemon Power, or trainer card is used. +; - EFFECTCMDTYPE_DISCARD_ENERGY: For moves or trainer cards that require putting one or more attached energy cards into the discard pile. +; - EFFECTCMDTYPE_REQUIRE_SELECTION: For moves, Pokemon Powers, or trainer cards requring the user to select a card (from e.g. play area screen or card list). +; - EFFECTCMDTYPE_BEFORE_DAMAGE: Effect command of a move executed prior to the damage step. For trainer card or Pokemon Power, usually the main effect. +; - EFFECTCMDTYPE_AFTER_DAMAGE: Effect command executed after the damage step +; - EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN: For moves that may result in the defending Pokemon being switched out +; - EFFECTCMDTYPE_PKMN_POWER_TRIGGER: Pokemon Power effects that trigger the moment the Pokemon card is played +; - EFFECTCMDTYPE_AI: Used for AI scoring +; - EFFECTCMDTYPE_UNKNOWN_08: Unknown + ; Similar move effects of different Pokemon cards all point to a different command list, ; even though in some cases their commands and function pointers match. @@ -23,1375 +33,1375 @@ EffectCommands: ; 186f7 (6:46f7) ; SpitPoison_AIEffect ; EkansSpitPoisonEffectCommands: - dbw $03, SpitPoison_Poison50PercentEffect - dbw $09, SpitPoison_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SpitPoison_Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, SpitPoison_AIEffect db $00 EkansWrapEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 ArbokTerrorStrikeEffectCommands: - dbw $04, $4726 - dbw $05, $470a - dbw $0a, $470a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4726 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $470a + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $470a db $00 ArbokPoisonFangEffectCommands: - dbw $03, PoisonEffect - dbw $09, PoisonFang_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, PoisonFang_AIEffect db $00 WeepinbellPoisonPowderEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, WeepinbellPoisonPowder_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, WeepinbellPoisonPowder_AIEffect db $00 VictreebelLureEffectCommands: - dbw $01, $4740 - dbw $04, $476a - dbw $05, $474b - dbw $08, $4764 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4740 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $476a + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $474b + dbw EFFECTCMDTYPE_UNKNOWN_08, $4764 db $00 VictreebelAcidEffectCommands: - dbw $03, AcidEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, AcidEffect db $00 PinsirIronGripEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 CaterpieStringShotEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 GloomPoisonPowderEffectCommands: - dbw $03, PoisonEffect - dbw $09, GloomPoisonPowder_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, GloomPoisonPowder_AIEffect db $00 GloomFoulOdorEffectCommands: - dbw $03, FoulOdorEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, FoulOdorEffect db $00 KakunaStiffenEffectCommands: - dbw $03, KakunaStiffenEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, KakunaStiffenEffect db $00 KakunaPoisonPowderEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, KakunaPoisonPowder_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, KakunaPoisonPowder_AIEffect db $00 GolbatLeechLifeEffectCommands: - dbw $04, $47bc + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47bc db $00 VenonatStunSporeEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 VenonatLeechLifeEffectCommands: - dbw $04, $47c6 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47c6 db $00 ScytherSwordsDanceEffectCommands: - dbw $03, SwordsDanceEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SwordsDanceEffect db $00 ZubatSupersonicEffectCommands: - dbw $03, ZubatSupersonicEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, ZubatSupersonicEffect db $00 ZubatLeechLifeEffectCommands: - dbw $04, $47e3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $47e3 db $00 BeedrillTwineedleEffectCommands: - dbw $03, Twineedle_MultiplierEffect - dbw $09, Twineedle_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Twineedle_MultiplierEffect + dbw EFFECTCMDTYPE_AI, Twineedle_AIEffect db $00 BeedrillPoisonStingEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, $480d + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, $480d db $00 ExeggcuteHypnosisEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 ExeggcuteLeechSeedEffectCommands: - dbw $04, $4815 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4815 db $00 KoffingFoulGasEffectCommands: - dbw $03, FoulGas_PoisonOrConfusionEffect - dbw $09, FoulGas_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, FoulGas_PoisonOrConfusionEffect + dbw EFFECTCMDTYPE_AI, FoulGas_AIEffect db $00 MetapodStiffenEffectCommands: - dbw $03, MetapodStiffenEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, MetapodStiffenEffect db $00 MetapodStunSporeEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 OddishStunSporeEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 OddishSproutEffectCommands: - dbw $01, $484a - dbw $04, $48cc - dbw $05, $485a - dbw $08, $48b7 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $484a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $48cc + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $485a + dbw EFFECTCMDTYPE_UNKNOWN_08, $48b7 db $00 ExeggutorTeleportEffectCommands: - dbw $01, $48ec - dbw $04, $491a - dbw $05, $48f7 - dbw $08, $490f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $48ec + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $491a + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $48f7 + dbw EFFECTCMDTYPE_UNKNOWN_08, $490f db $00 ExeggutorBigEggsplosionEffectCommands: - dbw $03, BigEggsplosion_MultiplierEffect - dbw $09, BigEggsplosion_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, BigEggsplosion_MultiplierEffect + dbw EFFECTCMDTYPE_AI, BigEggsplosion_AIEffect db $00 NidokingThrashEffectCommands: - dbw $03, Thrash_ModifierEffect - dbw $04, Func_2c982 - dbw $09, Thrash_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Thrash_ModifierEffect + dbw EFFECTCMDTYPE_AFTER_DAMAGE, Func_2c982 + dbw EFFECTCMDTYPE_AI, Thrash_AIEffect db $00 NidokingToxicEffectCommands: - dbw $03, Toxic_DoublePoisonEffect - dbw $09, Toxic_AIEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Toxic_DoublePoisonEffect + dbw EFFECTCMDTYPE_AI, Toxic_AIEffect db $00 NidoqueenBoyfriendsEffectCommands: - dbw $03, $4998 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4998 db $00 NidoranFFurySweepesEffectCommands: - dbw $03, $49c6 - dbw $09, $49be + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $49c6 + dbw EFFECTCMDTYPE_AI, $49be db $00 NidoranFCallForFamilyEffectCommands: - dbw $01, $49db - dbw $04, $4a6e - dbw $05, $49eb - dbw $08, $4a55 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $49db + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4a6e + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $49eb + dbw EFFECTCMDTYPE_UNKNOWN_08, $4a55 db $00 NidoranMHornHazardEffectCommands: - dbw $03, $4a96 - dbw $09, $4a8e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4a96 + dbw EFFECTCMDTYPE_AI, $4a8e db $00 NidorinaSupersonicEffectCommands: - dbw $03, $4aac + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4aac db $00 NidorinaDoubleKickEffectCommands: - dbw $03, $4abb - dbw $09, $4ab3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4abb + dbw EFFECTCMDTYPE_AI, $4ab3 db $00 NidorinoDoubleKickEffectCommands: - dbw $03, $4adb - dbw $09, $4ad3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4adb + dbw EFFECTCMDTYPE_AI, $4ad3 db $00 ButterfreeWhirlwindEffectCommands: - dbw $04, $4b09 - dbw $05, $4af3 - dbw $0a, $4af3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4b09 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $4af3 + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $4af3 db $00 ButterfreeMegaDrainEffectCommands: - dbw $04, $4b0f + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4b0f db $00 ParasSporeEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 ParasectSporeEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 WeedlePoisonStingEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, $4b27 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, $4b27 db $00 IvysaurPoisonPowderEffectCommands: - dbw $03, PoisonEffect - dbw $09, $4b2f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, $4b2f db $00 BulbasaurLeechSeedEffectCommands: - dbw $04, $4b37 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4b37 db $00 VenusaurEnergyTransEffectCommands: - dbw $02, $4b44 - dbw $03, $4b77 - dbw $04, $4bfb - dbw $05, $4b6f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $4b44 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4b77 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4bfb + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $4b6f db $00 GrimerNastyGooEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 GrimerMinimizeEffectCommands: - dbw $03, $4c30 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4c30 db $00 MukToxicGasEffectCommands: - dbw $01, $4c36 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4c36 db $00 MukSludgeEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, $4c38 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, $4c38 db $00 BellsproutCallForFamilyEffectCommands: - dbw $01, $4c40 - dbw $04, $4cc2 - dbw $05, $4c50 - dbw $08, $4cad + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4c40 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4cc2 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $4c50 + dbw EFFECTCMDTYPE_UNKNOWN_08, $4cad db $00 WeezingSmogEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, $4ce2 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, $4ce2 db $00 WeezingSelfdestructEffectCommands: - dbw $04, $4cea + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4cea db $00 VenomothShiftEffectCommands: - dbw $02, $4d09 - dbw $03, $4d5d - dbw $05, $4d21 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $4d09 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4d5d + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $4d21 db $00 VenomothVenomPowderEffectCommands: - dbw $03, $4d8c - dbw $09, $4d84 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4d8c + dbw EFFECTCMDTYPE_AI, $4d84 db $00 TangelaBindEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 TangelaPoisonPowderEffectCommands: - dbw $03, PoisonEffect - dbw $09, $4da0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, $4da0 db $00 VileplumeHealEffectCommands: - dbw $02, $4da8 - dbw $03, $4dc7 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $4da8 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4dc7 db $00 VileplumePetalDanceEffectCommands: - dbw $03, $4e2b - dbw $09, $4e23 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4e2b + dbw EFFECTCMDTYPE_AI, $4e23 db $00 TangelaStunSporeEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 TangelaPoisonWhipEffectCommands: - dbw $03, PoisonEffect - dbw $09, $4e4b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, $4e4b db $00 VenusaurSolarPowerEffectCommands: - dbw $02, $4e53 - dbw $03, $4e82 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $4e53 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4e82 db $00 VenusaurMegaDrainEffectCommands: - dbw $04, $4eb0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4eb0 db $00 OmastarWaterGunEffectCommands: - dbw $03, $4f05 - dbw $09, $4f05 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f05 + dbw EFFECTCMDTYPE_AI, $4f05 db $00 OmastarSpikeCannonEffectCommands: - dbw $03, $4f12 - dbw $09, $4f0a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f12 + dbw EFFECTCMDTYPE_AI, $4f0a db $00 OmanyteClairvoyanceEffectCommands: - dbw $01, $4f2a + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4f2a db $00 OmanyteWaterGunEffectCommands: - dbw $03, $4f2c - dbw $09, $4f2c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f2c + dbw EFFECTCMDTYPE_AI, $4f2c db $00 WartortleWithdrawEffectCommands: - dbw $03, $4f32 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f32 db $00 BlastoiseRainDanceEffectCommands: - dbw $01, $4f46 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4f46 db $00 BlastoiseHydroPumpEffectCommands: - dbw $03, $4f48 - dbw $09, $4f48 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f48 + dbw EFFECTCMDTYPE_AI, $4f48 db $00 GyaradosBubblebeamEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 KinglerFlailEffectCommands: - dbw $03, $4f54 - dbw $09, $4f4e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $4f54 + dbw EFFECTCMDTYPE_AI, $4f4e db $00 KrabbyCallForFamilyEffectCommands: - dbw $01, $4f5d - dbw $04, $4fdf - dbw $05, $4f6d - dbw $08, $4fca + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $4f5d + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $4fdf + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $4f6d + dbw EFFECTCMDTYPE_UNKNOWN_08, $4fca db $00 MagikarpFlailEffectCommands: - dbw $03, $5005 - dbw $09, $4fff + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5005 + dbw EFFECTCMDTYPE_AI, $4fff db $00 PsyduckHeadacheEffectCommands: - dbw $03, $500e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $500e db $00 PsyduckFurySweepesEffectCommands: - dbw $03, $501e - dbw $09, $5016 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $501e + dbw EFFECTCMDTYPE_AI, $5016 db $00 GolduckPsyshockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 GolduckHyperBeamEffectCommands: - dbw $04, $506b - dbw $05, $5033 - dbw $08, $5065 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $506b + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5033 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5065 db $00 SeadraWaterGunEffectCommands: - dbw $03, $5085 - dbw $09, $5085 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5085 + dbw EFFECTCMDTYPE_AI, $5085 db $00 SeadraAgilityEffectCommands: - dbw $03, $508b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $508b db $00 ShellderSupersonicEffectCommands: - dbw $03, $509d + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $509d db $00 ShellderHideInShellEffectCommands: - dbw $03, $50a4 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $50a4 db $00 VaporeonQuickAttackEffectCommands: - dbw $03, $50c0 - dbw $09, $50b8 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $50c0 + dbw EFFECTCMDTYPE_AI, $50b8 db $00 VaporeonWaterGunEffectCommands: - dbw $03, $50d3 - dbw $09, $50d3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $50d3 + dbw EFFECTCMDTYPE_AI, $50d3 db $00 DewgongIceBeamEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 StarmieRecoverEffectCommands: - dbw $01, $50d9 - dbw $02, $50f0 - dbw $04, $5114 - dbw $06, $510e - dbw $08, $5103 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $50d9 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $50f0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5114 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $510e + dbw EFFECTCMDTYPE_UNKNOWN_08, $5103 db $00 StarmieStarFreezeEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 SquirtleBubbleEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 SquirtleWithdrawEffectCommands: - dbw $03, $5120 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5120 db $00 HorseaSmokescreenEffectCommands: - dbw $03, $5134 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5134 db $00 TentacruelSupersonicEffectCommands: - dbw $03, $513a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $513a db $00 TentacruelJellyfishStingEffectCommands: - dbw $03, PoisonEffect - dbw $09, $5141 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, PoisonEffect + dbw EFFECTCMDTYPE_AI, $5141 db $00 PoliwhirlAmnesiaEffectCommands: - dbw $01, $5149 - dbw $02, $516f - dbw $03, $5179 - dbw $08, $5173 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5149 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $516f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5179 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5173 db $00 PoliwhirlDoubleslapEffectCommands: - dbw $03, $51c8 - dbw $09, $51c0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $51c8 + dbw EFFECTCMDTYPE_AI, $51c0 db $00 PoliwrathWaterGunEffectCommands: - dbw $03, $51e0 - dbw $09, $51e0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $51e0 + dbw EFFECTCMDTYPE_AI, $51e0 db $00 PoliwrathWhirlpoolEffectCommands: - dbw $04, $5214 - dbw $05, $51e6 - dbw $08, $520e + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5214 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $51e6 + dbw EFFECTCMDTYPE_UNKNOWN_08, $520e db $00 PoliwagWaterGunEffectCommands: - dbw $03, $5227 - dbw $09, $5227 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5227 + dbw EFFECTCMDTYPE_AI, $5227 db $00 CloysterClampEffectCommands: - dbw $03, $522d + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $522d db $00 CloysterSpikeCannonEffectCommands: - dbw $03, $524e - dbw $09, $5246 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $524e + dbw EFFECTCMDTYPE_AI, $5246 db $00 ArticunoFreezeDryEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 ArticunoBlizzardEffectCommands: - dbw $03, $5266 - dbw $04, $526f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5266 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $526f db $00 TentacoolCowardiceEffectCommands: - dbw $02, $528b - dbw $03, $52c3 - dbw $05, $52ae + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $528b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $52c3 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $52ae db $00 LaprasWaterGunEffectCommands: - dbw $03, $52eb - dbw $09, $52eb + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $52eb + dbw EFFECTCMDTYPE_AI, $52eb db $00 LaprasConfuseRayEffectCommands: - dbw $03, Confusion50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Confusion50PercentEffect db $00 ArticunoQuickfreezeEffectCommands: - dbw $01, $52f1 - dbw $07, $52f3 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $52f1 + dbw EFFECTCMDTYPE_PKMN_POWER_TRIGGER, $52f3 db $00 ArticunoIceBreathEffectCommands: - dbw $03, $5329 - dbw $04, $532e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5329 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $532e db $00 VaporeonFocusEnergyEffectCommands: - dbw $03, $533f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $533f db $00 ArcanineFlamethrowerEffectCommands: - dbw $01, $5363 - dbw $02, $5371 - dbw $06, $5379 - dbw $08, $5375 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5363 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5371 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5379 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5375 db $00 ArcanineTakeDownEffectCommands: - dbw $04, $537f + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $537f db $00 ArcanineQuickAttackEffectCommands: - dbw $03, $538d - dbw $09, $5385 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $538d + dbw EFFECTCMDTYPE_AI, $5385 db $00 ArcanineFlamesOfRageEffectCommands: - dbw $01, $53a0 - dbw $02, $53ae - dbw $03, $53ef - dbw $06, $53de - dbw $08, $53d5 - dbw $09, $53e9 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $53a0 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $53ae + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $53ef + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $53de + dbw EFFECTCMDTYPE_UNKNOWN_08, $53d5 + dbw EFFECTCMDTYPE_AI, $53e9 db $00 RapidashStompEffectCommands: - dbw $03, $5400 - dbw $09, $53f8 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5400 + dbw EFFECTCMDTYPE_AI, $53f8 db $00 RapidashAgilityEffectCommands: - dbw $03, $5413 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5413 db $00 NinetailsLureEffectCommands: - dbw $01, $5425 - dbw $04, $544f - dbw $05, $5430 - dbw $08, $5449 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5425 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $544f + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5430 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5449 db $00 NinetailsFireBlastEffectCommands: - dbw $01, $5463 - dbw $02, $5471 - dbw $06, $5479 - dbw $08, $5475 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5463 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5471 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5479 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5475 db $00 CharmanderEmberEffectCommands: - dbw $01, $547f - dbw $02, $548d - dbw $06, $5495 - dbw $08, $5491 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $547f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $548d + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5495 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5491 db $00 MoltresWildfireEffectCommands: - dbw $01, $549b - dbw $02, $54a9 - dbw $04, $54f4 - dbw $06, $54e1 - dbw $08, $54dd + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $549b + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $54a9 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $54f4 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $54e1 + dbw EFFECTCMDTYPE_UNKNOWN_08, $54dd db $00 Moltres1DiveBombEffectCommands: - dbw $03, $552b - dbw $09, $5523 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $552b + dbw EFFECTCMDTYPE_AI, $5523 db $00 FlareonQuickAttackEffectCommands: - dbw $03, $5549 - dbw $09, $5541 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5549 + dbw EFFECTCMDTYPE_AI, $5541 db $00 FlareonFlamethrowerEffectCommands: - dbw $01, $555c - dbw $02, $556a - dbw $06, $5572 - dbw $08, $556e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $555c + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $556a + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5572 + dbw EFFECTCMDTYPE_UNKNOWN_08, $556e db $00 MagmarFlamethrowerEffectCommands: - dbw $01, $5578 - dbw $02, $5586 - dbw $06, $558e - dbw $08, $558a + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5578 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5586 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $558e + dbw EFFECTCMDTYPE_UNKNOWN_08, $558a db $00 MagmarSmokescreenEffectCommands: - dbw $03, $5594 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5594 db $00 MagmarSmogEffectCommands: - dbw $03, Poison50PercentEffect - dbw $09, $559a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Poison50PercentEffect + dbw EFFECTCMDTYPE_AI, $559a db $00 CharmeleonFlamethrowerEffectCommands: - dbw $01, $55a2 - dbw $02, $55b0 - dbw $06, $55b8 - dbw $08, $55b4 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $55a2 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $55b0 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $55b8 + dbw EFFECTCMDTYPE_UNKNOWN_08, $55b4 db $00 CharizardEnergyBurnEffectCommands: - dbw $01, $55be + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $55be db $00 CharizardFireSpinEffectCommands: - dbw $01, $55c0 - dbw $02, $55cd - dbw $06, $5614 - dbw $08, $5606 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $55c0 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $55cd + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5614 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5606 db $00 VulpixConfuseRayEffectCommands: - dbw $03, Confusion50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Confusion50PercentEffect db $00 FlareonRageEffectCommands: - dbw $03, $563e - dbw $09, $5638 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $563e + dbw EFFECTCMDTYPE_AI, $5638 db $00 NinetailsMixUpEffectCommands: - dbw $04, $5647 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5647 db $00 NinetailsDancingEmbersEffectCommands: - dbw $03, $56ab - dbw $09, $56a3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $56ab + dbw EFFECTCMDTYPE_AI, $56a3 db $00 MoltresFiregiverEffectCommands: - dbw $01, $56c0 - dbw $07, $56c2 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $56c0 + dbw EFFECTCMDTYPE_PKMN_POWER_TRIGGER, $56c2 db $00 Moltres2DiveBombEffectCommands: - dbw $03, $5776 - dbw $09, $576e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5776 + dbw EFFECTCMDTYPE_AI, $576e db $00 AbraPsyshockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 GengarCurseEffectCommands: - dbw $02, $57fc - dbw $03, $58bb - dbw $05, $5834 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $57fc + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $58bb + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5834 db $00 GengarDarkMindEffectCommands: - dbw $04, $593c - dbw $05, $5903 - dbw $08, $592a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $593c + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5903 + dbw EFFECTCMDTYPE_UNKNOWN_08, $592a db $00 GastlySleepingGasEffectCommands: - dbw $03, $594f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $594f db $00 GastlyDestinyBondEffectCommands: - dbw $01, $5956 - dbw $02, $5964 - dbw $03, $5987 - dbw $06, $5981 - dbw $08, $5976 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5956 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5964 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5987 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5981 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5976 db $00 GastlyLickEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 GastlyEnergyConversionEffectCommands: - dbw $01, $598d - dbw $04, $59b4 - dbw $05, $5994 - dbw $08, $599b + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $598d + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $59b4 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5994 + dbw EFFECTCMDTYPE_UNKNOWN_08, $599b db $00 HaunterHypnosisEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 HaunterDreamEaterEffectCommands: - dbw $01, $59d6 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $59d6 db $00 HaunterTransparencyEffectCommands: - dbw $01, $59e5 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $59e5 db $00 HaunterNightmareEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 HypnoProphecyEffectCommands: - dbw $01, $59e7 - dbw $04, $5a41 - dbw $05, $5a00 - dbw $08, $5a3c + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $59e7 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5a41 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5a00 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5a3c db $00 HypnoDarkMindEffectCommands: - dbw $04, $5b64 - dbw $05, $5b2b - dbw $08, $5b52 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5b64 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5b2b + dbw EFFECTCMDTYPE_UNKNOWN_08, $5b52 db $00 DrowzeeConfuseRayEffectCommands: - dbw $03, Confusion50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Confusion50PercentEffect db $00 MrMimeInvisibleWallEffectCommands: - dbw $01, $5b77 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5b77 db $00 MrMimeMeditateEffectCommands: - dbw $03, $5b7f - dbw $09, $5b79 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5b7f + dbw EFFECTCMDTYPE_AI, $5b79 db $00 AlakazamDamageSwapEffectCommands: - dbw $02, $5b8e - dbw $03, $5ba2 - dbw $04, $5c27 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5b8e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5ba2 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5c27 db $00 AlakazamConfuseRayEffectCommands: - dbw $03, Confusion50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Confusion50PercentEffect db $00 MewPsywaveEffectCommands: - dbw $03, $5c49 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5c49 db $00 MewDevolutionBeamEffectCommands: - dbw $01, $5c53 - dbw $02, $5c64 - dbw $03, $5cb6 - dbw $04, $5cbb - dbw $08, $5c9e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5c53 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5c64 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5cb6 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5cbb + dbw EFFECTCMDTYPE_UNKNOWN_08, $5c9e db $00 MewNeutralizingShieldEffectCommands: - dbw $01, $5d79 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5d79 db $00 MewPsyshockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 MewtwoPsychicEffectCommands: - dbw $03, $5d81 - dbw $09, $5d7b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5d81 + dbw EFFECTCMDTYPE_AI, $5d7b db $00 MewtwoBarrierEffectCommands: - dbw $01, $5d8e - dbw $02, $5d9c - dbw $03, $5dbf - dbw $06, $5db9 - dbw $08, $5dae + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5d8e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5d9c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5dbf + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5db9 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5dae db $00 Mewtwo3EnergyAbsorptionEffectCommands: - dbw $01, $5dc5 - dbw $04, $5dec - dbw $05, $5dcc - dbw $08, $5dd3 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5dc5 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5dec + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5dcc + dbw EFFECTCMDTYPE_UNKNOWN_08, $5dd3 db $00 Mewtwo2EnergyAbsorptionEffectCommands: - dbw $01, $5dff - dbw $04, $5e26 - dbw $05, $5e06 - dbw $08, $5e0d + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5dff + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5e26 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5e06 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5e0d db $00 SlowbroStrangeBehaviorEffectCommands: - dbw $02, $5e39 - dbw $03, $5e5b - dbw $04, $5eb3 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5e39 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5e5b + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5eb3 db $00 SlowbroPsyshockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 SlowpokeSpacingOutEffectCommands: - dbw $01, $5ed5 - dbw $03, $5ee0 - dbw $04, $5ef1 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5ed5 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5ee0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5ef1 db $00 SlowpokeScavengeEffectCommands: - dbw $01, $5f05 - dbw $02, $5f1a - dbw $04, $5f5f - dbw $05, $5f46 - dbw $06, $5f40 - dbw $08, $5f2d + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5f05 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5f1a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5f5f + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $5f46 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5f40 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5f2d db $00 SlowpokeAmnesiaEffectCommands: - dbw $01, $5f74 - dbw $02, $5f7b - dbw $03, $5f85 - dbw $08, $5f7f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5f74 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5f7b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5f85 + dbw EFFECTCMDTYPE_UNKNOWN_08, $5f7f db $00 KadabraRecoverEffectCommands: - dbw $01, $5f89 - dbw $02, $5fa0 - dbw $04, $5fc3 - dbw $06, $5fbd - dbw $08, $5fb2 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $5f89 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $5fa0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $5fc3 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $5fbd + dbw EFFECTCMDTYPE_UNKNOWN_08, $5fb2 db $00 JynxDoubleslapEffectCommands: - dbw $03, $5fd7 - dbw $09, $5fcf + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5fd7 + dbw EFFECTCMDTYPE_AI, $5fcf db $00 JynxMeditateEffectCommands: - dbw $03, $5ff2 - dbw $09, $5fec + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $5ff2 + dbw EFFECTCMDTYPE_AI, $5fec db $00 MewMysteryAttackEffectCommands: - dbw $03, $6009 - dbw $04, $603e - dbw $09, $6001 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6009 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $603e + dbw EFFECTCMDTYPE_AI, $6001 db $00 GeodudeStoneBarrageEffectCommands: - dbw $03, $6052 - dbw $09, $604a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6052 + dbw EFFECTCMDTYPE_AI, $604a db $00 OnixHardenEffectCommands: - dbw $03, $6075 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6075 db $00 PrimeapeFurySweepesEffectCommands: - dbw $03, $6083 - dbw $09, $607b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6083 + dbw EFFECTCMDTYPE_AI, $607b db $00 PrimeapeTantrumEffectCommands: - dbw $03, $6099 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6099 db $00 MachampStrikesBackEffectCommands: - dbw $01, $60af + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $60af db $00 KabutoKabutoArmorEffectCommands: - dbw $01, $60b1 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $60b1 db $00 KabutopsAbsorbEffectCommands: - dbw $04, $60b3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $60b3 db $00 CuboneSnivelEffectCommands: - dbw $03, $60cb + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $60cb db $00 CuboneRageEffectCommands: - dbw $03, $60d7 - dbw $09, $60d1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $60d7 + dbw EFFECTCMDTYPE_AI, $60d1 db $00 MarowakBonemerangEffectCommands: - dbw $03, $60e8 - dbw $09, $60e0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $60e8 + dbw EFFECTCMDTYPE_AI, $60e0 db $00 MarowakCallforFriendEffectCommands: - dbw $01, $6100 - dbw $04, $6194 - dbw $05, $6110 - dbw $08, $6177 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6100 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6194 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6110 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6177 db $00 MachokeKarateChopEffectCommands: - dbw $03, $61ba - dbw $09, $61b4 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $61ba + dbw EFFECTCMDTYPE_AI, $61b4 db $00 MachokeSubmissionEffectCommands: - dbw $04, $61d1 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $61d1 db $00 GolemSelfdestructEffectCommands: - dbw $04, $61d7 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $61d7 db $00 GravelerHardenEffectCommands: - dbw $03, $61f6 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $61f6 db $00 RhydonRamEffectCommands: - dbw $04, $6212 - dbw $05, $61fc - dbw $0a, $61fc + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6212 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $61fc + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $61fc db $00 RhyhornLeerEffectCommands: - dbw $03, $621d + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $621d db $00 HitmonleeStretchKickEffectCommands: - dbw $01, $6231 - dbw $04, $625b - dbw $05, $623c - dbw $08, $6255 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6231 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $625b + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $623c + dbw EFFECTCMDTYPE_UNKNOWN_08, $6255 db $00 SandshrewSandAttackEffectCommands: - dbw $03, $626b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $626b db $00 SandslashFurySweepesEffectCommands: - dbw $03, $6279 - dbw $09, $6271 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6279 + dbw EFFECTCMDTYPE_AI, $6271 db $00 DugtrioEarthquakeEffectCommands: - dbw $04, $628f + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $628f db $00 AerodactylPrehistoricPowerEffectCommands: - dbw $01, $629a + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $629a db $00 MankeyPeekEffectCommands: - dbw $02, $629c - dbw $03, $62b4 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $629c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $62b4 db $00 MarowakBoneAttackEffectCommands: - dbw $03, $630f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $630f db $00 MarowakWailEffectCommands: - dbw $01, $631c - dbw $04, $6335 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $631c + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6335 db $00 ElectabuzzThundershockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 ElectabuzzThunderpunchEffectCommands: - dbw $03, $63a1 - dbw $04, $63b0 - dbw $09, $6399 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $63a1 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $63b0 + dbw EFFECTCMDTYPE_AI, $6399 db $00 ElectabuzzLightScreenEffectCommands: - dbw $03, $63ba + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $63ba db $00 ElectabuzzQuickAttackEffectCommands: - dbw $03, $63c8 - dbw $09, $63c0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $63c8 + dbw EFFECTCMDTYPE_AI, $63c0 db $00 MagnemiteThunderWaveEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 MagnemiteSelfdestructEffectCommands: - dbw $04, $63db + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $63db db $00 ZapdosThunderEffectCommands: - dbw $03, $63fa - dbw $04, $6409 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $63fa + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6409 db $00 ZapdosThunderboltEffectCommands: - dbw $03, $6419 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6419 db $00 ZapdosThunderstormEffectCommands: - dbw $04, $6429 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6429 db $00 JolteonQuickAttackEffectCommands: - dbw $03, $64c3 - dbw $09, $64bb + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $64c3 + dbw EFFECTCMDTYPE_AI, $64bb db $00 JolteonPinMissileEffectCommands: - dbw $03, $64de - dbw $09, $64d6 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $64de + dbw EFFECTCMDTYPE_AI, $64d6 db $00 FlyingPikachuThundershockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 FlyingPikachuFlyEffectCommands: - dbw $03, $64fc - dbw $09, $64f4 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $64fc + dbw EFFECTCMDTYPE_AI, $64f4 db $00 PikachuThunderJoltEffectCommands: - dbw $03, $651a - dbw $04, $6529 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $651a + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6529 db $00 PikachuSparkEffectCommands: - dbw $04, $6574 - dbw $05, $6539 - dbw $08, $6562 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6574 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6539 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6562 db $00 Pikachu3GrowlEffectCommands: - dbw $03, $6589 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6589 db $00 Pikachu3ThundershockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 Pikachu4GrowlEffectCommands: - dbw $03, $658f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $658f db $00 Pikachu4ThundershockEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 ElectrodeChainLightningEffectCommands: - dbw $04, $6595 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6595 db $00 RaichuAgilityEffectCommands: - dbw $03, $65dc + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $65dc db $00 RaichuThunderEffectCommands: - dbw $03, $65ee - dbw $04, $65fd + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $65ee + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $65fd db $00 RaichuGigashockEffectCommands: - dbw $04, $671f - dbw $05, $660d - dbw $08, $66c3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $671f + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $660d + dbw EFFECTCMDTYPE_UNKNOWN_08, $66c3 db $00 MagnetonThunderWaveEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 Magneton1SelfdestructEffectCommands: - dbw $04, $6739 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6739 db $00 MagnetonSonicboomEffectCommands: - dbw $03, $6758 - dbw $04, $675e - dbw $09, $6758 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6758 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $675e + dbw EFFECTCMDTYPE_AI, $6758 db $00 Magneton2SelfdestructEffectCommands: - dbw $04, $675f + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $675f db $00 ZapdosPealOfThunderEffectCommands: - dbw $01, $677e - dbw $07, $6780 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $677e + dbw EFFECTCMDTYPE_PKMN_POWER_TRIGGER, $6780 db $00 ZapdosBigThunderEffectCommands: - dbw $04, $67cb + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $67cb db $00 MagnemiteMagneticStormEffectCommands: - dbw $04, $67d5 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $67d5 db $00 ElectrodeSonicboomEffectCommands: - dbw $03, $6870 - dbw $04, $6876 - dbw $09, $6870 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6870 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6876 + dbw EFFECTCMDTYPE_AI, $6870 db $00 ElectrodeEnergySpikeEffectCommands: - dbw $01, $6877 - dbw $04, $68f6 - dbw $05, $687b - dbw $08, $68f1 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6877 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $68f6 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $687b + dbw EFFECTCMDTYPE_UNKNOWN_08, $68f1 db $00 JolteonDoubleKickEffectCommands: - dbw $03, $6938 - dbw $09, $6930 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6938 + dbw EFFECTCMDTYPE_AI, $6930 db $00 JolteonStunNeedleEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 EeveeTailWagEffectCommands: - dbw $03, $694e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $694e db $00 EeveeQuickAttackEffectCommands: - dbw $03, $696a - dbw $09, $6962 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $696a + dbw EFFECTCMDTYPE_AI, $6962 db $00 SpearowMirrorMoveEffectCommands: - dbw $01, $697f - dbw $02, $6981 - dbw $03, $6987 - dbw $04, $6989 - dbw $05, $6983 - dbw $08, $6985 - dbw $09, $697d + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $697f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6981 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6987 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6989 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6983 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6985 + dbw EFFECTCMDTYPE_AI, $697d db $00 FearowAgilityEffectCommands: - dbw $03, $6ab8 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6ab8 db $00 DragoniteStepInEffectCommands: - dbw $02, $6aca - dbw $03, $6ae8 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6aca + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6ae8 db $00 Dragonite2SlamEffectCommands: - dbw $03, $6afe - dbw $09, $6af6 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6afe + dbw EFFECTCMDTYPE_AI, $6af6 db $00 SnorlaxThickSkinnedEffectCommands: - dbw $01, $6b15 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6b15 db $00 SnorlaxBodySlamEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 FarfetchdLeekSlapEffectCommands: - dbw $01, $6b1f - dbw $03, $6b34 - dbw $06, $6b2c - dbw $09, $6b17 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6b1f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6b34 + dbw EFFECTCMDTYPE_DISCARD_ENERGY, $6b2c + dbw EFFECTCMDTYPE_AI, $6b17 db $00 KangaskhanFetchEffectCommands: - dbw $04, $6b40 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6b40 db $00 KangaskhanCometPunchEffectCommands: - dbw $03, $6b65 - dbw $09, $6b5d + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6b65 + dbw EFFECTCMDTYPE_AI, $6b5d db $00 TaurosStompEffectCommands: - dbw $03, $6b83 - dbw $09, $6b7b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6b83 + dbw EFFECTCMDTYPE_AI, $6b7b db $00 TaurosRampageEffectCommands: - dbw $03, $6ba1 - dbw $09, $6b96 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6ba1 + dbw EFFECTCMDTYPE_AI, $6b96 db $00 DoduoFuryAttackEffectCommands: - dbw $03, $6bc2 - dbw $09, $6bba + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6bc2 + dbw EFFECTCMDTYPE_AI, $6bba db $00 DodrioRetreatAidEffectCommands: - dbw $01, $6bd7 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6bd7 db $00 DodrioRageEffectCommands: - dbw $03, $6bdf - dbw $09, $6bd9 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6bdf + dbw EFFECTCMDTYPE_AI, $6bd9 db $00 MeowthPayDayEffectCommands: - dbw $04, $6be8 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6be8 db $00 DragonairSlamEffectCommands: - dbw $03, $6c14 - dbw $09, $6c0c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6c14 + dbw EFFECTCMDTYPE_AI, $6c0c db $00 DragonairHyperBeamEffectCommands: - dbw $04, $6c35 - dbw $05, $6c2c - dbw $08, $6c2f + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6c35 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6c2c + dbw EFFECTCMDTYPE_UNKNOWN_08, $6c2f db $00 ClefableMetronomeEffectCommands: - dbw $01, $6c77 - dbw $02, $6c82 - dbw $08, $6c7e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6c77 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6c82 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6c7e db $00 ClefableMinimizeEffectCommands: - dbw $03, $6c88 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6c88 db $00 PidgeotHurricaneEffectCommands: - dbw $04, $6c8e + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6c8e db $00 PidgeottoWhirlwindEffectCommands: - dbw $04, $6ce9 - dbw $05, $6cd3 - dbw $0a, $6cd3 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6ce9 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6cd3 + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $6cd3 db $00 PidgeottoMirrorMoveEffectCommands: - dbw $01, $6cf2 - dbw $02, $6cf5 - dbw $03, $6cfe - dbw $04, $6d01 - dbw $05, $6cf8 - dbw $08, $6cfb - dbw $09, $6cef + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6cf2 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6cf5 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6cfe + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6d01 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6cf8 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6cfb + dbw EFFECTCMDTYPE_AI, $6cef db $00 ClefairySingEffectCommands: - dbw $03, $6d04 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6d04 db $00 ClefairyMetronomeEffectCommands: - dbw $01, $6d0b - dbw $02, $6d16 - dbw $08, $6d12 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6d0b + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6d16 + dbw EFFECTCMDTYPE_UNKNOWN_08, $6d12 db $00 WigglytuffLullabyEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 WigglytuffDoTheWaveEffectCommands: - dbw $03, $6d87 - dbw $09, $6d87 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6d87 + dbw EFFECTCMDTYPE_AI, $6d87 db $00 JigglypuffLullabyEffectCommands: - dbw $03, SleepEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, SleepEffect db $00 JigglypuffFirstAidEffectCommands: - dbw $01, $6d94 - dbw $04, $6d9f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6d94 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6d9f db $00 JigglypuffDoubleEdgeEffectCommands: - dbw $04, $6da6 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6da6 db $00 PersianPounceEffectCommands: - dbw $03, $6dac + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6dac db $00 LickitungTongueWrapEffectCommands: - dbw $03, Paralysis50PercentEffect + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, Paralysis50PercentEffect db $00 LickitungSupersonicEffectCommands: - dbw $03, $6db2 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6db2 db $00 PidgeyWhirlwindEffectCommands: - dbw $04, $6dcf - dbw $05, $6db9 - dbw $0a, $6db9 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6dcf + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6db9 + dbw EFFECTCMDTYPE_SWITCH_DEFENDING_PKMN, $6db9 db $00 PorygonConversion1EffectCommands: - dbw $01, $6dd5 - dbw $02, $6ded - dbw $04, $6dfb - dbw $08, $6df7 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6dd5 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6ded + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6dfb + dbw EFFECTCMDTYPE_UNKNOWN_08, $6df7 db $00 PorygonConversion2EffectCommands: - dbw $01, $6e1f - dbw $02, $6e31 - dbw $04, $6e5e - dbw $08, $6e3c + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6e1f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6e31 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6e5e + dbw EFFECTCMDTYPE_UNKNOWN_08, $6e3c db $00 ChanseyScrunchEffectCommands: - dbw $03, $6ee7 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6ee7 db $00 ChanseyDoubleEdgeEffectCommands: - dbw $04, $6efb + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6efb db $00 RaticateSuperFangEffectCommands: - dbw $03, $6f07 - dbw $09, $6f01 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6f07 + dbw EFFECTCMDTYPE_AI, $6f01 db $00 TrainerCardAsPokemonEffectCommands: - dbw $02, $6f18 - dbw $03, $6f3c - dbw $05, $6f27 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $6f18 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6f3c + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $6f27 db $00 DragoniteHealingWindEffectCommands: - dbw $01, $6f51 - dbw $07, $6f53 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $6f51 + dbw EFFECTCMDTYPE_PKMN_POWER_TRIGGER, $6f53 db $00 Dragonite1SlamEffectCommands: - dbw $03, $6fa4 - dbw $09, $6f9c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $6fa4 + dbw EFFECTCMDTYPE_AI, $6f9c db $00 MeowthCatPunchEffectCommands: - dbw $04, $6fe0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6fe0 db $00 DittoMorphEffectCommands: - dbw $04, $6ff6 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $6ff6 db $00 PidgeotSlicingWindEffectCommands: - dbw $04, $70bf + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $70bf db $00 PidgeotGaleEffectCommands: - dbw $03, $70d0 - dbw $04, $70d6 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $70d0 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $70d6 db $00 JigglypuffFriendshipSongEffectCommands: - dbw $01, $710d - dbw $04, $7119 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $710d + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $7119 db $00 JigglypuffExpandEffectCommands: - dbw $04, $7153 + dbw EFFECTCMDTYPE_AFTER_DAMAGE, $7153 db $00 DoubleColorlessEnergyEffectCommands: @@ -1416,191 +1426,191 @@ GrassEnergyEffectCommands: db $00 SuperPotionEffectCommands: - dbw $01, $7159 - dbw $02, $7167 - dbw $03, $71b5 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7159 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7167 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $71b5 db $00 ImakuniEffectCommands: - dbw $03, $7216 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7216 db $00 EnergyRemovalEffectCommands: - dbw $01, $7252 - dbw $02, $725f - dbw $03, $7273 - dbw $08, $726f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7252 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $725f + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7273 + dbw EFFECTCMDTYPE_UNKNOWN_08, $726f db $00 EnergyRetrievalEffectCommands: - dbw $01, $728e - dbw $02, $72a0 - dbw $03, $72f8 - dbw $05, $72b9 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $728e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $72a0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $72f8 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $72b9 db $00 EnergySearchEffectCommands: - dbw $01, $731c - dbw $03, $7372 - dbw $05, $7328 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $731c + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7372 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $7328 db $00 ProfessorOakEffectCommands: - dbw $03, $73a1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $73a1 db $00 PotionEffectCommands: - dbw $01, $73ca - dbw $02, $73d1 - dbw $03, $73ef + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $73ca + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $73d1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $73ef db $00 GamblerEffectCommands: - dbw $03, $73f9 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $73f9 db $00 ItemFinderEffectCommands: - dbw $01, $743b - dbw $02, $744a - dbw $03, $7463 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $743b + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $744a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7463 db $00 DefenderEffectCommands: - dbw $02, $7488 - dbw $03, $7499 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7488 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7499 db $00 MysteriousFossilEffectCommands: - dbw $01, $74b3 - dbw $03, $74bf + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $74b3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $74bf db $00 FullHealEffectCommands: - dbw $01, $74c5 - dbw $03, $74d1 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $74c5 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $74d1 db $00 ImposterProfessorOakEffectCommands: - dbw $03, $74e1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $74e1 db $00 ComputerSearchEffectCommands: - dbw $01, $7513 - dbw $02, $752a - dbw $03, $7545 - dbw $05, $752e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7513 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $752a + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7545 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $752e db $00 ClefairyDollEffectCommands: - dbw $01, $7561 - dbw $03, $756d + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7561 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $756d db $00 MrFujiEffectCommands: - dbw $01, $7573 - dbw $02, $757e - dbw $03, $758f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7573 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $757e + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $758f db $00 PlusPowerEffectCommands: - dbw $03, $75e0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $75e0 db $00 SwitchEffectCommands: - dbw $01, $75ee - dbw $02, $75f9 - dbw $03, $760a + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $75ee + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $75f9 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $760a db $00 PokemonCenterEffectCommands: - dbw $01, $7611 - dbw $03, $7618 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7611 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7618 db $00 PokemonFluteEffectCommands: - dbw $01, $7659 - dbw $02, $7672 - dbw $03, $768f + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7659 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7672 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $768f db $00 PokemonBreederEffectCommands: - dbw $01, $76b3 - dbw $02, $76c1 - dbw $03, $76f4 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $76b3 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $76c1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $76f4 db $00 ScoopUpEffectCommands: - dbw $01, $7795 - dbw $02, $77a0 - dbw $03, $77c3 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7795 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $77a0 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $77c3 db $00 PokemonTraderEffectCommands: - dbw $01, $7826 - dbw $02, $7838 - dbw $03, $788d - dbw $05, $7853 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7826 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7838 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $788d + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $7853 db $00 PokedexEffectCommands: - dbw $01, $78e1 - dbw $03, $79aa - dbw $05, $78ed + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $78e1 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $79aa + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $78ed db $00 BillEffectCommands: - dbw $03, $79c4 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $79c4 db $00 LassEffectCommands: - dbw $03, $79e3 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $79e3 db $00 MaintenanceEffectCommands: - dbw $01, $7a70 - dbw $02, $7a7b - dbw $03, $7a85 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7a70 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7a7b + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7a85 db $00 PokeBallEffectCommands: - dbw $01, $7aad - dbw $03, $7b15 - dbw $05, $7ab9 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7aad + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7b15 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $7ab9 db $00 RecycleEffectCommands: - dbw $01, $7b36 - dbw $03, $7b68 - dbw $05, $7b41 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7b36 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7b68 + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $7b41 db $00 ReviveEffectCommands: - dbw $01, $7b80 - dbw $02, $7b93 - dbw $03, $7bb0 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7b80 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7b93 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7bb0 db $00 DevolutionSprayEffectCommands: - dbw $01, $7c0b - dbw $02, $7c24 - dbw $03, $7c99 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7c0b + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7c24 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7c99 db $00 SuperEnergyRemovalEffectCommands: - dbw $01, $7cd0 - dbw $02, $7ce4 - dbw $03, $7d73 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7cd0 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7ce4 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7d73 db $00 SuperEnergyRetrievalEffectCommands: - dbw $01, $7da4 - dbw $02, $7db6 - dbw $03, $7dfa - dbw $05, $7dba + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7da4 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7db6 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7dfa + dbw EFFECTCMDTYPE_REQUIRE_SELECTION, $7dba db $00 GustOfWindEffectCommands: - dbw $01, $7e6e - dbw $02, $7e79 - dbw $03, $7e90 + dbw EFFECTCMDTYPE_INITIAL_EFFECT_1, $7e6e + dbw EFFECTCMDTYPE_INITIAL_EFFECT_2, $7e79 + dbw EFFECTCMDTYPE_BEFORE_DAMAGE, $7e90 db $00 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c7a31d0..c08af4e 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6598,9 +6598,9 @@ AIAction_UseTrainerCard: ; 6a23 (1:6a23) ; for trainer card effects AIAction_TryExecuteEffect: ; 6a35 (1:6a35) - ld a, $06 + ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction - ld a, $03 + ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction call DrawDuelMainScene ldh a, [hTempCardIndex_ff9f] @@ -6646,7 +6646,7 @@ AIAction_Attack: ; 6a4e (1:6a4e) ; 0x6a8c AIAction_AttackEffect: ; 6a8c (1:6a8c) - ld a, $06 + ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage jr c, .confusion_damage @@ -6713,7 +6713,7 @@ AIAction_UsePokemonPower: ; 6ad9 (1:6ad9) AIAction_6b07: ; 6b07 (1:6b07) call Func_7415 - ld a, $03 + ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction ld a, $01 ld [wSkipDuelistIsThinkingDelay], a @@ -6721,7 +6721,7 @@ AIAction_6b07: ; 6b07 (1:6b07) ; 0x6b15 AIAction_6b15: ; 6b15 (1:6b15) - ld a, $04 + ld a, EFFECTCMDTYPE_AFTER_DAMAGE call TryExecuteEffectCommandFunction ld a, $01 ld [wSkipDuelistIsThinkingDelay], a diff --git a/src/engine/bank08.asm b/src/engine/bank08.asm index ca52ca5..a3614af 100644 --- a/src/engine/bank08.asm +++ b/src/engine/bank08.asm @@ -49,7 +49,7 @@ Func_200e5: ; 200e5 (8:40e5) bank1call CheckCantUseTrainerDueToHeadache jp c, $41a8 call LoadNonPokemonCardEffectCommands - ld a, $1 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_1 call TryExecuteEffectCommandFunction jp c, $41a8 farcall $5, $743b diff --git a/src/engine/home.asm b/src/engine/home.asm index ff07a17..6f8f6d5 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -4368,7 +4368,7 @@ Func_161e: ; 161e (0:161e) call DrawWideTextBox_WaitForInput call ExchangeRNG call Func_7415 - ld a, $07 + ld a, EFFECTCMDTYPE_PKMN_POWER_TRIGGER call TryExecuteEffectCommandFunction ret ; 0x16ad @@ -4473,12 +4473,12 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) cp POKEMON_POWER jp z, UsePokemonPower call Func_16f6 - ld a, $1 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_1 call TryExecuteEffectCommandFunction jp c, DrawWideTextBox_WaitForInput_ReturnCarry call CheckSandAttackOrSmokescreenSubstatus jr c, .asm_1766 - ld a, $2 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry call Func_1874 @@ -4487,20 +4487,20 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call Func_1874 call HandleSandAttackOrSmokescreenSubstatus jp c, ClearNonTurnTemporaryDuelvars_ResetCarry - ld a, $2 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry .asm_1777 ld a, $9 call SetAIAction_SerialSendDuelData - ld a, $6 + ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage jp c, DealConfusionDamageToSelf call DrawDuelMainScene_PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG - ld a, $5 + ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction ld a, $a call SetAIAction_SerialSendDuelData @@ -4518,7 +4518,7 @@ Func_179a: ; 179a (0:179a) .asm_17ad xor a ldh [hTempPlayAreaLocation_ff9d], a - ld a, $3 + ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction call ApplyDamageModifiers_DamageToTarget call Func_189d @@ -4562,7 +4562,7 @@ Func_17ed: ; 17ed (0:17ed) Func_17fb: ; 17fb (0:17fb) ld a, [wTempNonTurnDuelistCardID] push af - ld a, $4 + ld a, EFFECTCMDTYPE_AFTER_DAMAGE call TryExecuteEffectCommandFunction pop af ld [wTempNonTurnDuelistCardID], a @@ -4610,10 +4610,10 @@ DealConfusionDamageToSelf: ; 1828 (0:1828) ; use Pokemon Power UsePokemonPower: ; 184b (0:184b) call Func_7415 - ld a, $2 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jr c, DisplayUsePokemonPowerScreen_WaitForInput - ld a, $5 + ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction jr c, ReturnCarry ld a, $c @@ -4621,7 +4621,7 @@ UsePokemonPower: ; 184b (0:184b) call ExchangeRNG ld a, $d call SetAIAction_SerialSendDuelData - ld a, $3 + ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction ld a, $16 call SetAIAction_SerialSendDuelData @@ -4718,7 +4718,7 @@ UseTrainerCard: ; 18f9 (0:18f9) ldh a, [hTempCardIndex_ff98] ldh [hTempCardIndex_ff9f], a call LoadNonPokemonCardEffectCommands - ld a, $01 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_1 call TryExecuteEffectCommandFunction jr nc, .can_use .cant_use @@ -4726,20 +4726,20 @@ UseTrainerCard: ; 18f9 (0:18f9) scf ret .can_use - ld a, $02 + ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jr c, .done ld a, $06 call SetAIAction_SerialSendDuelData call DisplayUsedTrainerCardDetailScreen call ExchangeRNG - ld a, $06 + ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction - ld a, $05 + ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction ld a, $07 call SetAIAction_SerialSendDuelData - ld a, $03 + ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction ldh a, [hTempCardIndex_ff9f] call MoveHandCardToDiscardPile -- cgit v1.2.3 From 0e9c5aafbdf439f9e32fd4b8b484a9c7d188db5e Mon Sep 17 00:00:00 2001 From: xCrystal Date: Mon, 22 Jul 2019 17:08:51 +0200 Subject: Constants and documentation for Opponent actions (AI and Link Opp) --- src/constants/duel_constants.asm | 26 +++++ src/engine/bank01.asm | 219 +++++++++++++++++++++------------------ src/engine/effect_functions.asm | 2 +- src/engine/home.asm | 82 ++++++++------- src/hram.asm | 2 +- src/wram.asm | 2 +- 6 files changed, 193 insertions(+), 140 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 80fe3b0..dd448aa 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -167,6 +167,32 @@ EFFECTCMDTYPE_PKMN_POWER_TRIGGER EQU $07 EFFECTCMDTYPE_AI EQU $09 EFFECTCMDTYPE_UNKNOWN_08 EQU $08 +; OppAction_* constants (OppActionTable) + const_def + const OPPACTION_ERROR ; $00 + const OPPACTION_PLAY_BASIC_PKMN ; $01 + const OPPACTION_EVOLVE_PKMN ; $02 + const OPPACTION_PLAY_ENERGY ; $03 + const OPPACTION_ATTEMPT_RETREAT ; $04 + const OPPACTION_FINISH_NO_ATTACK ; $05 + const OPPACTION_PLAY_TRAINER ; $06 + const OPPACTION_EXECUTE_TRAINER_EFFECTS ; $07 + const OPPACTION_BEGIN_ATTACK ; $08 + const OPPACTION_USE_ATTACK ; $09 + const OPPACTION_DEAL_ATTACK_DAMAGE ; $0a + const OPPACTION_DRAW_CARD ; $0b + const OPPACTION_USE_PKMN_POWER ; $0c + const OPPACTION_EXECUTE_PKMN_POWER_EFFECT ; $0d + const OPPACTION_FORCE_SWITCH_ACTIVE ; $0e + const OPPACTION_NO_ACTION_0F ; $0f + const OPPACTION_NO_ACTION_10 ; $10 + const OPPACTION_TOSS_COIN_A_TIMES ; $11 + const OPPACTION_6B30 ; $12 + const OPPACTION_NO_ACTION_13 ; $13 + const OPPACTION_6B3E ; $14 + const OPPACTION_6B15 ; $15 + const OPPACTION_DUEL_MAIN_SCENE ; $16 + ; wNoDamageOrEffect constants NO_DAMAGE_OR_EFFECT_AGILITY EQU $01 NO_DAMAGE_OR_EFFECT_BARRIER EQU $02 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index c08af4e..f0ac3ae 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -346,7 +346,7 @@ DuelMainInterface: ; 426d (1:426d) cp DUELIST_TYPE_PLAYER jr z, PrintDuelMenuAndHandleInput cp DUELIST_TYPE_LINK_OPP - jp z, Func_6911 + jp z, DoLinkOpponentTurn ; DUELIST_TYPE_AI_OPP xor a ld [wVBlankCounter], a @@ -417,8 +417,8 @@ DuelMenuFunctionTable: ; 42f1 (1:42f1) Func_42fd: ; 42fd (1:42fd) call DrawCardFromDeck call nc, AddCardToHand - ld a, $0b - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DRAW_CARD + call SetOppAction_SerialSendDuelData jp PrintDuelMenuAndHandleInput.menu_items_printed ; 0x430b @@ -532,8 +532,8 @@ DuelMenu_Done: ; 439a (1:439a) call DoPracticeDuelAction ; always jumps on practice duel (no action requires player to select Done) jp c, RestartPracticeDuelTurn - ld a, $05 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_FINISH_NO_ATTACK + call SetOppAction_SerialSendDuelData call ClearNonTurnTemporaryDuelvars ret @@ -559,8 +559,8 @@ DuelMenu_Retreat: ; 43ab (1:43ab) ld [wBenchSelectedPokemon], a ld a, [wBenchSelectedPokemon] ldh [hTempPlayAreaLocation_ffa1], a - ld a, $04 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_ATTEMPT_RETREAT + call SetOppAction_SerialSendDuelData call AttemptRetreat jr nc, .done call DrawDuelMainScene @@ -591,8 +591,8 @@ DuelMenu_Retreat: ; 43ab (1:43ab) call ReturnRetreatCostCardsToArena pop af jp c, DuelMainInterface - ld a, $04 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_ATTEMPT_RETREAT + call SetOppAction_SerialSendDuelData call AttemptRetreat .done @@ -636,18 +636,18 @@ OpenPlayerHandScreen: ; 4436 (1:4436) bit TYPE_TRAINER_F, c jr nz, .trainer_card bit TYPE_ENERGY_F, c - jr nz, UseEnergyCard - call UsePokemonCard + jr nz, PlayEnergyCard + call PlayPokemonCard jr c, ReloadCardListScreen ; jump if card not played jp DuelMainInterface .trainer_card - call UseTrainerCard + call PlayTrainerCard jr c, ReloadCardListScreen ; jump if card not played jp DuelMainInterface -; use the energy card with deck index at hTempCardIndex_ff98 +; play the energy card with deck index at hTempCardIndex_ff98 ; c contains the type of energy card being played -UseEnergyCard: ; 4477 (1:4477) +PlayEnergyCard: ; 4477 (1:4477) ld a, c cp TYPE_ENERGY_WATER jr nz, .not_water_energy @@ -672,8 +672,8 @@ UseEnergyCard: ; 4477 (1:4477) ldh [hTemp_ffa0], a call PutHandCardInPlayArea call PrintPlayAreaCardList_EnableLCD - ld a, $03 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_ENERGY + call SetOppAction_SerialSendDuelData call PrintAttachedEnergyToPokemon jp DuelMainInterface @@ -703,11 +703,11 @@ ReloadCardListScreen: ; 44d2 (1:44d2) jp OpenPlayerHandScreen.handle_input ; 0x44db -; use a basic Pokemon card on the arena or bench, or place an stage 1 or 2 +; place a basic Pokemon card on the arena or bench, or place an stage 1 or 2 ; Pokemon card over a Pokemon card already in play to evolve it. ; the card to use is loaded in wLoadedCard1 and its deck index is at hTempCardIndex_ff98. ; return nc if the card was played, carry if it wasn't. -UsePokemonCard: ; 44db (1:44db) +PlayPokemonCard: ; 44db (1:44db) ld a, [wLoadedCard1Stage] or a ; BASIC jr nz, .try_evolve ; jump if the card being played is a Stage 1 or 2 Pokemon @@ -722,8 +722,8 @@ UsePokemonCard: ; 44db (1:44db) add DUELVARS_ARENA_CARD_STAGE call GetTurnDuelistVariable ld [hl], BASIC - ld a, $01 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_BASIC_PKMN + call SetOppAction_SerialSendDuelData ldh a, [hTempCardIndex_ff98] call LoadCardDataToBuffer1_FromDeckIndex ld a, 20 @@ -793,8 +793,8 @@ UsePokemonCard: ; 44db (1:44db) ldh [hTempPlayAreaLocation_ffa1], a call EvolvePokemonCard jr c, .try_evolve_loop ; jump if evolution wasn't successsful somehow - ld a, $02 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EVOLVE_PKMN + call SetOppAction_SerialSendDuelData call PrintPlayAreaCardList_EnableLCD call PrintPokemonEvolvedIntoPokemon call Func_161e @@ -5795,8 +5795,9 @@ ReturnRetreatCostCardsToArena: ; 6564 (1:6564) jr .loop ; 0x657a -; discard retreat cost energy cards and attempt retreat. +; discard retreat cost energy cards and attempt retreat of the arena card. ; return carry if unable to retreat this turn due to unsuccessful confusion check +; if successful, the retreated card is replaced with a bench Pokemon card AttemptRetreat: ; 657a (1:657a) call DiscardRetreatCostCards ldh a, [hTemp_ffa0] @@ -5934,7 +5935,9 @@ DrawHPBar: ; 6614 (1:6614) ret ; 0x6635 -Func_6635: ; 6635 (1:6635) +; when an opponent's Pokemon card attacks, this displays a screen +; containing the description and information of the used move +DisplayOpponentUsedMoveScreen: ; 6635 (1:6635) call ZeroObjectPositionsAndToggleOAMCopy call EmptyScreen call LoadDuelCardSymbolTiles @@ -6227,10 +6230,11 @@ CheckSkipDelayAllowed: ; 67b2 (1:67b2) ret ; 0x67be -; related to ai taking their turn in a duel -; called multiple times during one ai turn +; related to AI taking their turn in a duel +; called multiple times during one AI turn +; each call results in the execution of an OppActionTable function AIMakeDecision: ; 67be (1:67be) - ldh [hAIActionTableIndex], a + ldh [hOppActionTableIndex], a ld hl, wSkipDuelistIsThinkingDelay ld a, [hl] ld [hl], $0 @@ -6243,13 +6247,13 @@ AIMakeDecision: ; 67be (1:67be) jr c, .delay_loop .skip_delay - ldh a, [hAIActionTableIndex] - ld hl, wAITurnEnded + ldh a, [hOppActionTableIndex] + ld hl, wOpponentTurnEnded ld [hl], 0 - ld hl, AIActionTable + ld hl, OppActionTable call JumpToFunctionInTable ld a, [wDuelFinished] - ld hl, wAITurnEnded + ld hl, wOpponentTurnEnded or [hl] jr nz, .turn_ended ld a, [wSkipDuelistIsThinkingDelay] @@ -6438,12 +6442,14 @@ PrintPokemonEvolvedIntoPokemon: ; 68fa (1:68fa) ret ; 0x6911 -Func_6911: ; 6911 (1:6911) +; handle the opponent's turn in a link duel +; loop until either [wOpponentTurnEnded] or [wDuelFinished] is non-0 +DoLinkOpponentTurn: ; 6911 (1:6911) xor a - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a xor a ld [wSkipDuelistIsThinkingDelay], a -.asm_6919 +.link_opp_turn_loop ld a, [wSkipDuelistIsThinkingDelay] or a jr nz, .asm_6932 @@ -6464,60 +6470,64 @@ Func_6911: ; 6911 (1:6911) jp nz, DuelTransmissionError xor a ld [wSkipDuelistIsThinkingDelay], a - ldh a, [hAIActionTableIndex] + ldh a, [hOppActionTableIndex] cp $17 jp nc, DuelTransmissionError - ld hl, AIActionTable + ld hl, OppActionTable call JumpToFunctionInTable - ld hl, wAITurnEnded + ld hl, wOpponentTurnEnded ld a, [wDuelFinished] or [hl] - jr z, .asm_6919 + jr z, .link_opp_turn_loop ret ; 0x695e -AIActionTable: ; 695e (1:695e) +; actions for the opponent's turn +; on a link duel, this is referenced by DoLinkOpponentTurn in a loop (on each opponent's HandleTurn) +; on a non-link duel (vs AI opponent), this is referenced by AIMakeDecision +OppActionTable: ; 695e (1:695e) dw DuelTransmissionError - dw AIAction_PlayBenchPokemon - dw AIAction_EvolvePokemon - dw AIAction_UseEnergyCard - dw AIAction_TryRetreat - dw AIAction_FinishedTurnNoAttack - dw AIAction_UseTrainerCard - dw AIAction_TryExecuteEffect - dw AIAction_Attack - dw AIAction_AttackEffect - dw AIAction_AttackDamage - dw AIAction_DrawCard - dw AIAction_UsePokemonPower - dw AIAction_6b07 - dw AIAction_ForceOpponentSwitchActive - dw AIAction_NoAction - dw AIAction_NoAction - dw AIAction_TossCoinATimes - dw AIAction_6b30 - dw AIAction_NoAction - dw AIAction_6b3e - dw AIAction_6b15 - dw AIAction_DrawDuelMainScene - -AIAction_DrawCard: ; 698c (1:698c) + dw OppAction_PlayBasicPokemonCard + dw OppAction_EvolvePokemonCard + dw OppAction_PlayEnergyCard + dw OppAction_AttemptRetreat + dw OppAction_FinishTurnWithoutAttacking + dw OppAction_PlayTrainerCard + dw OppAction_ExecuteTrainerCardEffectCommands + dw OppAction_BeginUseAttack + dw OppAction_UseAttack + dw OppAction_DealAttackDamage + dw OppAction_DrawCard + dw OppAction_UsePokemonPower + dw OppAction_ExecutePokemonPowerEffect + dw OppAction_ForceSwitchActive + dw OppAction_NoAction + dw OppAction_NoAction + dw OppAction_TossCoinATimes + dw OppAction_6b30 + dw OppAction_NoAction + dw OppAction_6b3e + dw OppAction_6b15 + dw OppAction_DrawDuelMainScene + +OppAction_DrawCard: ; 698c (1:698c) call DrawCardFromDeck call nc, AddCardToHand ret ; 0x6993 -AIAction_FinishedTurnNoAttack: ; 6993 (1:6993) +OppAction_FinishTurnWithoutAttacking: ; 6993 (1:6993) call DrawDuelMainScene call ClearNonTurnTemporaryDuelvars ldtx hl, FinishedTurnWithoutAttackingText call DrawWideTextBox_WaitForInput ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x69a5 -AIAction_UseEnergyCard: ; 69a5 (1:69a5) +; attach an energy card from hand to the arena or a benched Pokemon +OppAction_PlayEnergyCard: ; 69a5 (1:69a5) ldh a, [hTempPlayAreaLocation_ffa1] ldh [hTempPlayAreaLocation_ff9d], a ld e, a @@ -6534,7 +6544,8 @@ AIAction_UseEnergyCard: ; 69a5 (1:69a5) ret ; 0x69c5 -AIAction_EvolvePokemon: ; 69c5 (1:69c5) +; evolve a Pokemon card in the arena or in the bench +OppAction_EvolvePokemonCard: ; 69c5 (1:69c5) ldh a, [hTempPlayAreaLocation_ffa1] ldh [hTempPlayAreaLocation_ff9d], a ldh a, [hTemp_ffa0] @@ -6548,7 +6559,8 @@ AIAction_EvolvePokemon: ; 69c5 (1:69c5) ret ; 0x69e0 -AIAction_PlayBenchPokemon: ; 69e0 (1:69e0) +; place a basic Pokemon card from hand in the bench +OppAction_PlayBasicPokemonCard: ; 69e0 (1:69e0) ldh a, [hTemp_ffa0] ldh [hTempCardIndex_ff98], a call PutHandPokemonCardInPlayArea @@ -6564,7 +6576,10 @@ AIAction_PlayBenchPokemon: ; 69e0 (1:69e0) ret ; 0x69ff -AIAction_TryRetreat: ; 69ff (1:69ff) +; attempt the retreat of the active Pokemon card +; if successful, discard the required energy cards for retreat and +; swap the retreated card with a Pokemon card from the bench +OppAction_AttemptRetreat: ; 69ff (1:69ff) ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable push af @@ -6586,7 +6601,8 @@ AIAction_TryRetreat: ; 69ff (1:69ff) ret ; 0x6a23 -AIAction_UseTrainerCard: ; 6a23 (1:6a23) +; play trainer card from hand +OppAction_PlayTrainerCard: ; 6a23 (1:6a23) call LoadNonPokemonCardEffectCommands call DisplayUsedTrainerCardDetailScreen call PrintUsedTrainerCardDescription @@ -6596,8 +6612,9 @@ AIAction_UseTrainerCard: ; 6a23 (1:6a23) ret ; 0x6a35 -; for trainer card effects -AIAction_TryExecuteEffect: ; 6a35 (1:6a35) +; execute the effect commands of the trainer card that is being played +; used only for Trainer cards, as a continuation of OppAction_PlayTrainerCard +OppAction_ExecuteTrainerCardEffectCommands: ; 6a35 (1:6a35) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction ld a, EFFECTCMDTYPE_BEFORE_DAMAGE @@ -6610,10 +6627,9 @@ AIAction_TryExecuteEffect: ; 6a35 (1:6a35) ret ; 0x6a4e -; determine if an attack is successful -; if no, end the turn early -; if yes, AIAction_AttackEffect and AIAction_AttackDamage can be called next -AIAction_Attack: ; 6a4e (1:6a4e) +; begin the execution of an attack and handle the attack being +; possibly unsuccessful due to Sand Attack or Smokescreen +OppAction_BeginUseAttack: ; 6a4e (1:6a4e) ldh a, [hTempCardIndex_ff9f] ld d, a ldh a, [hTemp_ffa0] @@ -6623,34 +6639,39 @@ AIAction_Attack: ; 6a4e (1:6a4e) ld a, $01 ld [wSkipDuelistIsThinkingDelay], a call CheckSandAttackOrSmokescreenSubstatus - jr c, .has_status_effect + jr c, .has_status ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and CNF_SLP_PRZ cp CONFUSED - jr z, .has_status_effect + jr z, .has_status call ExchangeRNG ret -.has_status_effect + +; we make it here is attacker is affected by +; Sand Attack, Smokescreen, or confusion +.has_status call DrawDuelMainScene call PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG call HandleSandAttackOrSmokescreenSubstatus - ret nc ; attack is successful + ret nc ; return if attack is successful (won the coin toss) call ClearNonTurnTemporaryDuelvars - ; only end the turn if the attack fails + ; end the turn if the attack fails ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6a8c -AIAction_AttackEffect: ; 6a8c (1:6a8c) +; display the attack used by the opponent, and handle +; EFFECTCMDTYPE_DISCARD_ENERGY and confusion damage to self +OppAction_UseAttack: ; 6a8c (1:6a8c) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage jr c, .confusion_damage - call Func_6635 + call DisplayOpponentUsedMoveScreen call PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG @@ -6659,20 +6680,21 @@ AIAction_AttackEffect: ; 6a8c (1:6a8c) ret .confusion_damage call DealConfusionDamageToSelf - ; only end the turn if the attack fails + ; end the turn if dealing damage to self due to confusion ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6ab1 -AIAction_AttackDamage: ; 6ab1 (1:6ab1) - call Func_179a +OppAction_DealAttackDamage: ; 6ab1 (1:6ab1) + call DealAttackDamage ld a, 1 - ld [wAITurnEnded], a + ld [wOpponentTurnEnded], a ret ; 0x6aba -AIAction_ForceOpponentSwitchActive: ; 6aba (1:6aba) +; force the player to switch the active Pokemon with a benched Pokemon +OppAction_ForceSwitchActive: ; 6aba (1:6aba) ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call SwapTurn @@ -6688,7 +6710,7 @@ AIAction_ForceOpponentSwitchActive: ; 6aba (1:6aba) ret ; 0x6ad9 -AIAction_UsePokemonPower: ; 6ad9 (1:6ad9) +OppAction_UsePokemonPower: ; 6ad9 (1:6ad9) ldh a, [hTempCardIndex_ff9f] ld d, a ld e, $00 @@ -6711,7 +6733,8 @@ AIAction_UsePokemonPower: ; 6ad9 (1:6ad9) ret ; 0x6b07 -AIAction_6b07: ; 6b07 (1:6b07) +; execute the EFFECTCMDTYPE_BEFORE_DAMAGE command of the used Pokemon Power +OppAction_ExecutePokemonPowerEffect: ; 6b07 (1:6b07) call Func_7415 ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction @@ -6720,7 +6743,7 @@ AIAction_6b07: ; 6b07 (1:6b07) ret ; 0x6b15 -AIAction_6b15: ; 6b15 (1:6b15) +OppAction_6b15: ; 6b15 (1:6b15) ld a, EFFECTCMDTYPE_AFTER_DAMAGE call TryExecuteEffectCommandFunction ld a, $01 @@ -6728,12 +6751,12 @@ AIAction_6b15: ; 6b15 (1:6b15) ret ; 0x6b20 -AIAction_DrawDuelMainScene: ; 6b20 (1:6b20) +OppAction_DrawDuelMainScene: ; 6b20 (1:6b20) call DrawDuelMainScene ret ; 0x6b24 -AIAction_TossCoinATimes: ; 6b24 (1:6b24) +OppAction_TossCoinATimes: ; 6b24 (1:6b24) call SerialRecv8Bytes call TossCoinATimes ld a, $01 @@ -6741,7 +6764,7 @@ AIAction_TossCoinATimes: ; 6b24 (1:6b24) ret ; 0x6b30 -AIAction_6b30: ; 6b30 (1:6b30) +OppAction_6b30: ; 6b30 (1:6b30) ldh a, [hWhoseTurn] push af ldh a, [hTemp_ffa0] @@ -6752,7 +6775,7 @@ AIAction_6b30: ; 6b30 (1:6b30) ret ; 0x6b3e -AIAction_6b3e: ; 6b3e (1:6b3e) +OppAction_6b3e: ; 6b3e (1:6b3e) call DrawDuelMainScene ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable @@ -6782,7 +6805,7 @@ AIAction_6b3e: ; 6b3e (1:6b3e) ret ; 0x6b7d -AIAction_NoAction: ; 6b7d (1:6b7d) +OppAction_NoAction: ; 6b7d (1:6b7d) ret ; 0x6b7e diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index c8d8f24..ab7bd38 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -110,7 +110,7 @@ Func_2c08c: push de push af ld a, $11 - call SetAIAction_SerialSendDuelData + call SetOppAction_SerialSendDuelData pop af pop de call SerialSend8Bytes diff --git a/src/engine/home.asm b/src/engine/home.asm index 6f8f6d5..5271270 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2812,19 +2812,21 @@ ExchangeRNG: ; 0f58 (0:0f58) jp c, DuelTransmissionError ret -; sets hAIActionTableIndex to an AI action specified in register a. -; send 10 bytes of data to the other game from hAIActionTableIndex, hTempCardIndex_ff9f, +; sets hOppActionTableIndex to an AI action specified in register a. +; send 10 bytes of data to the other game from hOppActionTableIndex, hTempCardIndex_ff9f, ; hTemp_ffa0, and hTempPlayAreaLocation_ffa1, and hTempRetreatCostCards. ; finally exchange RNG data. -SetAIAction_SerialSendDuelData: ; 0f7f (0:0f7f) +; the receiving side will use this data to read the OPP_ACTION_* value in +; [hOppActionTableIndex] and match it by calling the correspoding OppAction* function +SetOppAction_SerialSendDuelData: ; 0f7f (0:0f7f) push hl push bc - ldh [hAIActionTableIndex], a + ldh [hOppActionTableIndex], a ld a, DUELVARS_DUELIST_TYPE call GetNonTurnDuelistVariable cp DUELIST_TYPE_LINK_OPP jr nz, .not_link - ld hl, hAIActionTableIndex + ld hl, hOppActionTableIndex ld bc, 10 call SerialSendBytes call ExchangeRNG @@ -2834,13 +2836,13 @@ SetAIAction_SerialSendDuelData: ; 0f7f (0:0f7f) ret ; 0xf9b -; receive 10 bytes of data from wSerialRecvBuf and store them into hAIActionTableIndex, +; receive 10 bytes of data from wSerialRecvBuf and store them into hOppActionTableIndex, ; hTempCardIndex_ff9f, hTemp_ffa0, and hTempPlayAreaLocation_ffa1, ; and hTempRetreatCostCards. also exchange RNG data. SerialRecvDuelData: ; 0f9b (0:0f9b) push hl push bc - ld hl, hAIActionTableIndex + ld hl, hOppActionTableIndex ld bc, 10 call SerialRecvBytes call ExchangeRNG @@ -3789,8 +3791,8 @@ EvolvePokemonCard: ; 13a2 (0:13a2) ldh a, [hTempCardIndex_ff98] call PutHandCardInPlayArea ; update the Pokemon's HP with the difference - ldh a, [hTempPlayAreaLocation_ff9d] - ld a, e ; derp + ldh a, [hTempPlayAreaLocation_ff9d] ; derp + ld a, e add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable ld a, [wLoadedCard2HP] @@ -4461,7 +4463,7 @@ Func_16f6: ; 16f6 (0:16f6) bank1call ClearNonTurnTemporaryDuelvars_CopyStatus ret -; use attack or Pokemon Power +; Use an attack (from DuelMenu_Attack) or a Pokemon Power (from DuelMenu_PkmnPower) UseAttackOrPokemonPower: ; 1730 (0:1730) ld a, [wSelectedMoveIndex] ld [wPlayerAttackingMoveIndex], a @@ -4477,22 +4479,22 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call TryExecuteEffectCommandFunction jp c, DrawWideTextBox_WaitForInput_ReturnCarry call CheckSandAttackOrSmokescreenSubstatus - jr c, .asm_1766 + jr c, .sand_attack_smokescreen ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry - call Func_1874 - jr .asm_1777 -.asm_1766 - call Func_1874 + call SendAttackDataToLinkOpponent + jr .next +.sand_attack_smokescreen + call SendAttackDataToLinkOpponent call HandleSandAttackOrSmokescreenSubstatus jp c, ClearNonTurnTemporaryDuelvars_ResetCarry ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jp c, ReturnCarry -.asm_1777 - ld a, $9 - call SetAIAction_SerialSendDuelData +.next + ld a, OPPACTION_USE_ATTACK + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage @@ -4502,20 +4504,19 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call ExchangeRNG ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, $a - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DEAL_ATTACK_DAMAGE + call SetOppAction_SerialSendDuelData ; fallthrough -; deal attack damage -Func_179a: ; 179a (0:179a) +DealAttackDamage: ; 179a (0:179a) call Func_7415 ld a, [wLoadedMoveCategory] and RESIDUAL - jr nz, .asm_17ad + jr nz, .deal_damage call SwapTurn call HandleNoDamageOrEffectSubstatus call SwapTurn -.asm_17ad +.deal_damage xor a ldh [hTempPlayAreaLocation_ff9d], a ld a, EFFECTCMDTYPE_BEFORE_DAMAGE @@ -4616,18 +4617,21 @@ UsePokemonPower: ; 184b (0:184b) ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction jr c, ReturnCarry - ld a, $c - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_USE_PKMN_POWER + call SetOppAction_SerialSendDuelData call ExchangeRNG - ld a, $d - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EXECUTE_PKMN_POWER_EFFECT + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction - ld a, $16 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_DUEL_MAIN_SCENE + call SetOppAction_SerialSendDuelData ret -Func_1874: ; 1874 (0:1874) +; called by UseAttackOrPokemonPower (on an attack only) +; in a link duel, it's used to send the other game data about the +; attack being in use, triggering a call to OppAction_BeginUseAttack in the receiver +SendAttackDataToLinkOpponent: ; 1874 (0:1874) ld a, [wccec] or a ret nz @@ -4641,8 +4645,8 @@ Func_1874: ; 1874 (0:1874) ldh [hTempCardIndex_ff9f], a ld a, [wPlayerAttackingMoveIndex] ldh [hTemp_ffa0], a - ld a, $8 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_BEGIN_ATTACK + call SetOppAction_SerialSendDuelData call ExchangeRNG pop af ldh [hTempCardIndex_ff9f], a @@ -4707,10 +4711,10 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7) ret ; 0x18f9 -; use the trainer card with deck index at hTempCardIndex_ff98. +; play the trainer card with deck index at hTempCardIndex_ff98. ; a trainer card is like a move effect, with its own effect commands. ; return nc if the card was played, carry if it wasn't. -UseTrainerCard: ; 18f9 (0:18f9) +PlayTrainerCard: ; 18f9 (0:18f9) call CheckCantUseTrainerDueToHeadache jr c, .cant_use ldh a, [hWhoseTurn] @@ -4729,16 +4733,16 @@ UseTrainerCard: ; 18f9 (0:18f9) ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction jr c, .done - ld a, $06 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_PLAY_TRAINER + call SetOppAction_SerialSendDuelData call DisplayUsedTrainerCardDetailScreen call ExchangeRNG ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, $07 - call SetAIAction_SerialSendDuelData + ld a, OPPACTION_EXECUTE_TRAINER_EFFECTS + call SetOppAction_SerialSendDuelData ld a, EFFECTCMDTYPE_BEFORE_DAMAGE call TryExecuteEffectCommandFunction ldh a, [hTempCardIndex_ff9f] diff --git a/src/hram.asm b/src/hram.asm index bfdf81a..9cdba06 100644 --- a/src/hram.asm +++ b/src/hram.asm @@ -70,7 +70,7 @@ hTempPlayAreaLocation_ff9d:: ; ff9d ds $1 ; index for AIActionTable -hAIActionTableIndex:: ; ff9e +hOppActionTableIndex:: ; ff9e ds $1 ; deck index of a card (0-59) diff --git a/src/wram.asm b/src/wram.asm index d2821b2..4210cf7 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -730,7 +730,7 @@ wSortCardListByID:: ; cbdf wcbe0:: ; cbe0 ds $1 -wAITurnEnded:: ; cbe1 +wOpponentTurnEnded:: ; cbe1 ds $1 wOppRNG1:: ; cbe2 -- cgit v1.2.3 From a0bb31e3ad38896ae69ff1500346e3f732284773 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Mon, 22 Jul 2019 22:46:14 +0200 Subject: More duel related disassembly and documentation --- src/constants/duel_constants.asm | 10 ++- src/engine/bank01.asm | 152 +++++++++++++++++++++++++++++++++------ src/engine/bank07.asm | 2 +- src/engine/effect_functions.asm | 77 +++++++++++++++++++- src/engine/home.asm | 63 ++++++++-------- src/wram.asm | 13 ++-- 6 files changed, 254 insertions(+), 63 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index dd448aa..0f80a73 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -13,9 +13,10 @@ DUELTYPE_PRACTICE EQU $80 ; for normal duels (vs AI), wDuelType is $80 + [wOpponentDeckID] ; wDuelFinished constants -TURN_PLAYER_WON EQU $1 -TURN_PLAYER_LOST EQU $2 -TURN_PLAYER_TIED EQU $3 +DUEL_NOT_FINISHED EQU $0 +TURN_PLAYER_WON EQU $1 +TURN_PLAYER_LOST EQU $2 +TURN_PLAYER_TIED EQU $3 ; wDuelResult constants DUEL_WIN EQU $0 @@ -244,3 +245,6 @@ SELECT_CHECK EQU $02 const PRACTICEDUEL_REPEAT_INSTRUCTIONS const PRACTICEDUEL_PLAY_STARYU_FROM_BENCH const PRACTICEDUEL_REPLACE_KNOCKED_OUT_POKEMON + +; wAnimationQueue length +ANIMATION_QUEUE_LENGTH EQU 7 diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index f0ac3ae..a0d736c 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -1545,7 +1545,7 @@ Func_49a8: ; 49a8 (1:49a8) call DoFrame call CheckSkipDelayAllowed jr c, .asm_49c6 - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_49b9 .asm_49c6 call Func_3b31 @@ -2258,7 +2258,7 @@ Func_4e98: ; 4e98 (1:4e98) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4edd - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4ed0 .asm_4edd call Func_3b31 @@ -2277,7 +2277,7 @@ Func_4e98: ; 4e98 (1:4e98) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4f28 - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4ef4 ld hl, wNumCardsBeingDrawn inc [hl] @@ -2342,7 +2342,7 @@ Func_4f2d: ; 4f2d (1:4f2d) call DoFrame call CheckSkipDelayAllowed jr c, .asm_4f7d - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_4f70 .asm_4f7d call Func_3b31 @@ -6496,7 +6496,7 @@ OppActionTable: ; 695e (1:695e) dw OppAction_ExecuteTrainerCardEffectCommands dw OppAction_BeginUseAttack dw OppAction_UseAttack - dw OppAction_DealAttackDamage + dw OppAction_PlayAttackAnimation_DealAttackDamage dw OppAction_DrawCard dw OppAction_UsePokemonPower dw OppAction_ExecutePokemonPowerEffect @@ -6679,15 +6679,15 @@ OppAction_UseAttack: ; 6a8c (1:6a8c) ld [wSkipDuelistIsThinkingDelay], a ret .confusion_damage - call DealConfusionDamageToSelf + call HandleConfusionDamageToSelf ; end the turn if dealing damage to self due to confusion ld a, 1 ld [wOpponentTurnEnded], a ret ; 0x6ab1 -OppAction_DealAttackDamage: ; 6ab1 (1:6ab1) - call DealAttackDamage +OppAction_PlayAttackAnimation_DealAttackDamage: ; 6ab1 (1:6ab1) + call PlayAttackAnimation_DealAttackDamage ld a, 1 ld [wOpponentTurnEnded], a ret @@ -7016,7 +7016,7 @@ Func_6cab: ; 6cab (1:6cab) call Func_3b6a .asm_6cd8 call DoFrame - call Func_3b52 + call CheckAnyAnimationPlaying jr c, .asm_6cd8 call Func_6c7e.asm_6c98 ret @@ -7211,7 +7211,102 @@ ApplyStatusConditionToArenaPokemon: ; 6e38 (1:6e38) ; 0x6e49 Func_6e49: ; 6e49 (1:6e49) - INCROM $6e49, $700a + call HandleDestinyBondSubstatus + call ClearDamageReductionSubstatus2OfKnockedOutPokemon + xor a + ld [wcce8], a + call SwapTurn + call Func_6ef6 + call SwapTurn + ld a, [wcce8] + or a + jr z, .asm_6e86 + call $6ff7 + jr c, .asm_6e86 + call $6fc7 + ld c, a + call SwapTurn + call CountPrizes + call SwapTurn + dec a + cp c + jr c, .asm_6e86 + ld a, c + call SwapTurn + call DrawPrizes + call SwapTurn + ld a, $01 + jr .asm_6ecc +.asm_6e86 + call Func_6ef6 + ld a, [wcce8] + cp $01 + jr nz, .asm_6e9f + call SwapTurn + call $6ff7 + call SwapTurn + jr c, .asm_6e9f + ld a, $02 + jr .asm_6ecc +.asm_6e9f + call SwapTurn + call $6eff + call SwapTurn + call $6eff + ld a, [wcce8] + or a + jr nz, .asm_6ec4 + xor a +.asm_6eb2 + push af + call $6f08 + call SwapTurn + call $6f08 + call SwapTurn + call ShiftAllPokemonToFirstPlayAreaSlots + pop af + ret +.asm_6ec4 + ld e, a + ld d, $00 + ld hl, Data_6ed2 + add hl, de + ld a, [hl] +.asm_6ecc + ld [wDuelFinished], a + scf + jr .asm_6eb2 +; 0x6ed2 + +Data_6ed2: ; 6ed2 (1:6ed2) + db DUEL_NOT_FINISHED, TURN_PLAYER_LOST, TURN_PLAYER_WON, TURN_PLAYER_TIED + db TURN_PLAYER_LOST, TURN_PLAYER_LOST, TURN_PLAYER_TIED, TURN_PLAYER_LOST + db TURN_PLAYER_WON, TURN_PLAYER_TIED, TURN_PLAYER_WON, TURN_PLAYER_WON + db TURN_PLAYER_TIED, TURN_PLAYER_LOST, TURN_PLAYER_WON, TURN_PLAYER_TIED + +; clears SUBSTATUS2_REDUCE_BY_20, SUBSTATUS2_POUNCE, SUBSTATUS2_GROWL, +; SUBSTATUS2_TAIL_WAG, and SUBSTATUS2_LEER for each arena Pokemon with 0 HP +ClearDamageReductionSubstatus2OfKnockedOutPokemon: ; 6ee2 (1:6ee2) + call SwapTurn + call .clear + call SwapTurn +.clear + ld a, DUELVARS_ARENA_CARD_HP + call GetNonTurnDuelistVariable + or a + ret nz + call ClearDamageReductionSubstatus2 + ret +; 0x6ef6 + +Func_6ef6: ; 6ef6 (1:6ef6) + call $6fa5 + ld hl, wcce8 + rl [hl] + ret +; 0x6eff + + INCROM $6eff, $700a ; print one of the "There was no effect from" texts depending ; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant) @@ -7391,15 +7486,17 @@ PrizeBitmasks: ; 715a (1:715a) db %0, %1, %11, %111, %1111, %11111, %111111 ; 0x7161 -Func_7161: ; 7161 (1:7161) +; update the turn holder's DUELVARS_PRIZES following that duelist +; drawing a number of prizes equal to register a +DrawPrizes: ; 7161 (1:7161) or a ret z ld c, a call CountPrizes sub c - jr nc, .asm_716b + jr nc, .no_underflow xor a -.asm_716b +.no_underflow ld c, a ld b, $00 ld hl, PrizeBitmasks @@ -7555,7 +7652,7 @@ _TossCoin: ; 71ad (1:71ad) .asm_725e push de call DoFrame - call Func_3b52 + call CheckAnyAnimationPlaying pop de jr c, .asm_725e ld a, e @@ -7709,18 +7806,21 @@ Func_741a: ; 741a (1:741a) xor a ld [wd4b0], a push hl - farcall $6, $4f9c + farcall Func_006_4f9c pop hl jr .loop .done ret ; 0x7469 -Func_7469: ; 7469 (1:7469) +; this is a simple version of PlayAttackAnimation_DealAttackDamage that doesn't +; take into account status conditions, damage modifiers, etc, for damage calculation. +; used for confusion damage to self and for damage to benched Pokemon, for example +PlayAttackAnimation_DealAttackDamageSimple: ; 7469 (1:7469) push hl push de - call Func_7494 - call Func_7484 + call PlayMoveAnimation + call WaitMoveAnimation pop de pop hl call SubstractHP @@ -7735,20 +7835,26 @@ Func_7469: ; 7469 (1:7469) ret ; 0x7484 -Func_7484: ; 7484 (1:7484) +; if [wLoadedMoveAnimation] != 0, wait until the animation is over +WaitMoveAnimation: ; 7484 (1:7484) ld a, [wLoadedMoveAnimation] or a ret z push de -.asm_748a +.anim_loop call DoFrame - call Func_3b52 - jr c, .asm_748a + call CheckAnyAnimationPlaying + jr c, .anim_loop pop de ret ; 0x7494 -Func_7494: ; 7494 (1:7494) +; play move animation +; input: +; - [wLoadedMoveAnimation]: animation to play +; - de: damage dealt by the move (to display the animation with the number) +; - c: a wDamageEffectiveness constant (to print WEAK or RESIST if necessary) +PlayMoveAnimation: ; 7494 (1:7494) ldh a, [hWhoseTurn] push af push hl diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index a79f27a..7c53b96 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -384,7 +384,7 @@ Func_1cb18: ; 1cb18 (7:4b18) ld a, [wd42a] cp $ff call nz, $4cd4 - ld hl, wd423 + ld hl, wAnimationQueue ld c, $07 .asm_1cb3b push bc diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index ab7bd38..116d545 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -109,7 +109,7 @@ Func_2c08a: ; 2c08a (b:408a) Func_2c08c: push de push af - ld a, $11 + ld a, OPPACTION_TOSS_COIN_A_TIMES call SetOppAction_SerialSendDuelData pop af pop de @@ -130,7 +130,39 @@ SetWasUnsuccessful: ; 2c0a2 (b:40a2) ret ; 0x2c0a8 - INCROM $2c0a8, $2c0d4 +Func_2c0a8: ; 2c0a8 (b:40a8) + ldh a, [hTemp_ffa0] + push af + ldh a, [hWhoseTurn] + ldh [hTemp_ffa0], a + ld a, OPPACTION_6B30 + call SetOppAction_SerialSendDuelData + bank1call Func_4f2d + ld c, a + pop af + ldh [hTemp_ffa0], a + ld a, c + ret +; 0x2c0bd + +Func_2c0bd: ; 2c0bd (b:40bd) + call ExchangeRNG + bank1call Func_4f2d + call ShuffleDeck + ret +; 0x2c0c7 + +Func_2c0c7: ; 2c0c7 (b:40c7) + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr z, .player + or a + ret +.player + scf + ret +; 0x2c0d4 ; Sets some flags for AI use ; if target poisoned @@ -184,7 +216,46 @@ Func_2c0fb: ; 2c0fb (b:40fb) ret ; 0x2c10b - INCROM $2c10b, $2c140 +Func_2c10b: ; 2c10b (b:410b) + ldh [hTempPlayAreaLocation_ff9d], a + bank1call Func_61a1 + bank1call PrintPlayAreaCardList_EnableLCD + bank1call Func_6194 + ret +; 0x2c117 + +; deal damage to all the turn holder's benched Pokemon +; input: a = amount of damage to deal to each Pokemon +DealDamageToAllBenchedPokemon: ; 2c117 (b:4117) + ld e, a + ld d, $00 + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + ld b, PLAY_AREA_ARENA + jr .skip_to_bench +.loop + push bc + call DealDamageToPlayAreaPokemon + pop bc +.skip_to_bench + inc b + dec c + jr nz, .loop + ret +; 0x2c12e + +Func_2c12e: ; 2c12e (b:412e) + ld [wLoadedMoveAnimation], a + ldh a, [hTempPlayAreaLocation_ff9d] + ld b, a + ld c, $0 ; neither WEAKNESS nor RESISTANCE + ldh a, [hWhoseTurn] + ld h, a + bank1call PlayMoveAnimation + bank1call WaitMoveAnimation + ret +; 0x2c140 ; apply a status condition of type 1 identified by register a to the target ApplySubstatus1ToDefendingCard: ; 2c140 (b:4140) diff --git a/src/engine/home.asm b/src/engine/home.asm index 5271270..e6247c9 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -3290,8 +3290,8 @@ MoveDiscardPileCardToHand: ; 1182 (0:1182) ret ; 0x11a5 -; return in the z flag whether turn holder's prize a (0-7) has been taken or not -; z: taken, nz: not taken +; return in the z flag whether turn holder's prize a (0-7) has been drawn or not +; z: drawn, nz: not drawn CheckPrizeTaken: ; 11a5 (0:11a5) ld e, a ld d, 0 @@ -4293,9 +4293,9 @@ GetNonTurnDuelistVariable: ; 1611 (0:1611) ldh a, [hWhoseTurn] ld h, OPPONENT_TURN cp PLAYER_TURN - jr z, .asm_161c + jr z, .ok ld h, PLAYER_TURN -.asm_161c +.ok ld a, [hl] ret ; 0x161e @@ -4498,7 +4498,7 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) ld a, EFFECTCMDTYPE_DISCARD_ENERGY call TryExecuteEffectCommandFunction call CheckSelfConfusionDamage - jp c, DealConfusionDamageToSelf + jp c, HandleConfusionDamageToSelf call DrawDuelMainScene_PrintPokemonsAttackText call WaitForWideTextBoxInput call ExchangeRNG @@ -4508,7 +4508,7 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call SetOppAction_SerialSendDuelData ; fallthrough -DealAttackDamage: ; 179a (0:179a) +PlayAttackAnimation_DealAttackDamage: ; 179a (0:179a) call Func_7415 ld a, [wLoadedMoveCategory] and RESIDUAL @@ -4534,9 +4534,9 @@ DealAttackDamage: ; 179a (0:179a) call GetNonTurnDuelistVariable push de push hl - call Func_7494 + call PlayMoveAnimation call Func_741a - call Func_7484 + call WaitMoveAnimation pop hl pop de call SubstractHP @@ -4579,9 +4579,11 @@ DisplayUsePokemonPowerScreen_WaitForInput: ; 1819 (0:1819) push hl call DisplayUsePokemonPowerScreen pop hl +; fallthrough DrawWideTextBox_WaitForInput_ReturnCarry: ; 181e (0:181e) call DrawWideTextBox_WaitForInput +; fallthrough ReturnCarry: ; 1821 (0:1821) scf @@ -4592,7 +4594,9 @@ ClearNonTurnTemporaryDuelvars_ResetCarry: ; 1823 (0:1823) or a ret -DealConfusionDamageToSelf: ; 1828 (0:1828) +; called when attacker deals damage to itself due to confusion +; display the corresponding animation and deal damage to self +HandleConfusionDamageToSelf: ; 1828 (0:1828) bank1call DrawDuelMainScene ld a, 1 ld [wIsDamageToSelf], a @@ -4601,7 +4605,7 @@ DealConfusionDamageToSelf: ; 1828 (0:1828) ld a, $75 ld [wLoadedMoveAnimation], a ld a, 20 ; damage - call Func_195c + call DealConfusionDamageToSelf call Func_1bb4 call Func_6e49 bank1call ClearNonTurnTemporaryDuelvars @@ -4775,8 +4779,7 @@ Func_1955: ; 1955 (0:1955) pop af ; fallthrough -; this function appears to handle dealing damage to self due to confusion -Func_195c: ; 195c (0:195c) +DealConfusionDamageToSelf: ; 195c (0:195c) ld hl, wDamage ld [hli], a ld [hl], 0 @@ -4789,13 +4792,13 @@ Func_195c: ; 195c (0:195c) push af ld a, [wTempTurnDuelistCardID] ld [wTempNonTurnDuelistCardID], a - bank1call ApplyDamageModifiers_DamageToSelf ; switch to bank 1, but call a home func + bank1call ApplyDamageModifiers_DamageToSelf ; this is at bank 0 ld a, [wDamageEffectiveness] ld c, a ld b, $0 ld a, DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable - bank1call Func_7469 + bank1call PlayAttackAnimation_DealAttackDamageSimple call PrintKnockedOutIfHLZero pop af ld [wTempNonTurnDuelistCardID], a @@ -5042,11 +5045,11 @@ PrintKnockedOut: ; 1ad3 (0:1ad3) ret ; 0x1af3 -; seems to be a function to deal damage to a card, but can be used -; to deal damage to a benched Pokemon. +; deal damage to turn holder's Pokemon card at play area location at b (PLAY_AREA_*). +; damage to deal is given in de. ; shows the defending player's play area screen when dealing the damage -; instead of the main duel interface, and has a fixed move animation -Func_1af3: ; 1af3 (0:1af3) +; instead of the main duel interface, and has a fixed move animation. +DealDamageToPlayAreaPokemon: ; 1af3 (0:1af3) ld a, $78 ld [wLoadedMoveAnimation], a ld a, b @@ -5110,7 +5113,7 @@ Func_1af3: ; 1af3 (0:1af3) ld b, a or a ; cp PLAY_AREA_ARENA jr nz, .benched - ; add damage at de to [wDealtDamage] + ; if arena Pokemon, add damage at de to [wDealtDamage] ld hl, wDealtDamage ld a, e add [hl] @@ -5123,7 +5126,7 @@ Func_1af3: ; 1af3 (0:1af3) add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable push af - bank1call Func_7469 + bank1call PlayAttackAnimation_DealAttackDamageSimple pop af or a jr z, .skip_knocked_out @@ -10211,8 +10214,10 @@ IsPrehistoricPowerActive: ; 35b7 (0:35b7) ret ; 0x35c7 -; clears some SUBSTATUS2 conditions from the turn holder's active Pokemon -Func_35c7: ; 35c7 (0:35c7) +; clears some SUBSTATUS2 conditions from the turn holder's active Pokemon. +; more specifically, those conditions that reduce the damage from an attack +; or prevent the opposing Pokemon from attacking the substatus condition inducer. +ClearDamageReductionSubstatus2: ; 35c7 (0:35c7) ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -11215,19 +11220,21 @@ Func_3b31: ; 3b31 (0:3b31) call BankswitchROM ret -Func_3b52: ; 3b52 (0:3b52) +; return nc if wd42a, wd4c0, and wAnimationQueue[] are all equal to $ff +; nc means no animation is playing (or animation(s) has/have ended) +CheckAnyAnimationPlaying: ; 3b52 (0:3b52) push hl push bc ld a, [wd42a] ld hl, wd4c0 and [hl] - ld hl, wd423 - ld c, $7 -.asm_3b60 + ld hl, wAnimationQueue + ld c, ANIMATION_QUEUE_LENGTH +.loop and [hl] inc hl dec c - jr nz, .asm_3b60 + jr nz, .loop cp $ff pop bc pop hl @@ -11250,7 +11257,7 @@ Func_3b6a: ; 3b6a (0:3b6a) ld a, [wd4ac] cp [hl] jr nz, .asm_3b90 - call Func_3b52 + call CheckAnyAnimationPlaying jr nc, .asm_3b95 .asm_3b90 call $4a31 diff --git a/src/wram.asm b/src/wram.asm index 4210cf7..38ebd4a 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -161,7 +161,7 @@ wPlayerArenaCardChangedResistance:: ; c2ea wPlayerArenaCardSubstatus3:: ; c2eb ds $1 -; Each bit represents a prize (1 = not taken ; 0 = taken) +; each bit represents a prize that this duelist can draw (1 = not drawn ; 0 = drawn) wPlayerPrizes:: ; c2ec ds $1 @@ -982,6 +982,7 @@ wIsDamageToSelf:: ; cce6 wcce7:: ; cce7 ds $1 +wcce8:: ; cce8 ds $1 ; used in CopyDeckData @@ -1299,8 +1300,7 @@ wPrizeCardCursorPosition:: wce53:: ; ce53 ds $2 -; same as wDuelInitialPrizes but -; with upper 2 bits set +; same as wDuelInitialPrizes but with upper 2 bits set wDuelInitialPrizesUpperBitsSet:: ; ce55 ds $1 @@ -1990,8 +1990,11 @@ wd421:: ; d421 wd422:: ; d422 ds $1 -wd423:: ; d423 - ds $7 +; holds a list of animations to play +; as long as any of the slot isn't $ff, there's something to play +; it may actually not be a queue +wAnimationQueue:: ; d423 + ds ANIMATION_QUEUE_LENGTH wd42a:: ; d42a ds $1 -- cgit v1.2.3 From 0d2dce27ff7ad77a12f5182bbb8618d871446aa4 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Mon, 22 Jul 2019 22:51:01 +0200 Subject: Fix accidentailly renamed label --- src/constants/duel_constants.asm | 2 +- src/engine/bank01.asm | 4 ++-- src/engine/home.asm | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/constants/duel_constants.asm b/src/constants/duel_constants.asm index 0f80a73..dd61a44 100644 --- a/src/constants/duel_constants.asm +++ b/src/constants/duel_constants.asm @@ -180,7 +180,7 @@ EFFECTCMDTYPE_UNKNOWN_08 EQU $08 const OPPACTION_EXECUTE_TRAINER_EFFECTS ; $07 const OPPACTION_BEGIN_ATTACK ; $08 const OPPACTION_USE_ATTACK ; $09 - const OPPACTION_DEAL_ATTACK_DAMAGE ; $0a + const OPPACTION_ATTACK_ANIM_AND_DAMAGE ; $0a const OPPACTION_DRAW_CARD ; $0b const OPPACTION_USE_PKMN_POWER ; $0c const OPPACTION_EXECUTE_PKMN_POWER_EFFECT ; $0d diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index a0d736c..6058fcd 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -6496,7 +6496,7 @@ OppActionTable: ; 695e (1:695e) dw OppAction_ExecuteTrainerCardEffectCommands dw OppAction_BeginUseAttack dw OppAction_UseAttack - dw OppAction_PlayAttackAnimation_DealAttackDamage + dw OppAction_PlayAttackAnimationDealAttackDamage dw OppAction_DrawCard dw OppAction_UsePokemonPower dw OppAction_ExecutePokemonPowerEffect @@ -6686,7 +6686,7 @@ OppAction_UseAttack: ; 6a8c (1:6a8c) ret ; 0x6ab1 -OppAction_PlayAttackAnimation_DealAttackDamage: ; 6ab1 (1:6ab1) +OppAction_PlayAttackAnimationDealAttackDamage: ; 6ab1 (1:6ab1) call PlayAttackAnimation_DealAttackDamage ld a, 1 ld [wOpponentTurnEnded], a diff --git a/src/engine/home.asm b/src/engine/home.asm index e6247c9..b46bc44 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -4504,7 +4504,7 @@ UseAttackOrPokemonPower: ; 1730 (0:1730) call ExchangeRNG ld a, EFFECTCMDTYPE_REQUIRE_SELECTION call TryExecuteEffectCommandFunction - ld a, OPPACTION_DEAL_ATTACK_DAMAGE + ld a, OPPACTION_ATTACK_ANIM_AND_DAMAGE call SetOppAction_SerialSendDuelData ; fallthrough -- cgit v1.2.3 From b7ee18f262b1d88582fdc55879f1abaad17cc5ce Mon Sep 17 00:00:00 2001 From: xCrystal Date: Tue, 23 Jul 2019 21:03:39 +0200 Subject: Disassemble and document code related to knocking out Pokemon and taking prizes --- src/engine/bank01.asm | 310 +++++++++++++++++++++++++++++++++++++++++++--- src/engine/home.asm | 4 +- src/text/text1.asm | 10 +- src/text/text2.asm | 4 +- src/text/text_offsets.asm | 14 +-- src/wram.asm | 9 +- 6 files changed, 316 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm index 6058fcd..433b120 100644 --- a/src/engine/bank01.asm +++ b/src/engine/bank01.asm @@ -852,7 +852,7 @@ CheckAbleToRetreat: ; 45bb (1:45bb) ret c call CheckIfActiveCardParalyzedOrAsleep ret c - call HasAlivePokemonOnBench + call HasAlivePokemonInBench jr c, .unable_to_retreat ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -2794,7 +2794,7 @@ PracticeDuel_ReplaceKnockedOutPokemon: ; 52b0 (1:52b0) cp PLAY_AREA_BENCH_1 ret z ; if player selected Drowzee instead (which is at PLAY_AREA_BENCH_2) - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ldtx hl, SelectStaryuPracticeDuelText scf ; fallthrough @@ -3700,8 +3700,100 @@ DisplayCardPageOnLeftOrRightPressed: ; 57cd (1:57cd) ret ; 0x57df -Func_57df: - INCROM $57df, $5892 +Func_57df: ; 57df (1:57df) + push hl + call EmptyScreen + lb de, 0, 0 + lb bc, 20, 18 + call DrawRegularTextBox + ld a, 19 + lb de, 1, 1 + call InitTextPrintingInTextbox + call SetNoLineSeparation + pop hl + call ProcessTextFromID + call EnableLCD + call SetOneLineSeparation + call WaitForWideTextBoxInput + ret +; 0x5805 + +Func_5805: ; 5805 (1:5805) + call Func_3b31 + ld a, [wccc8] + ld l, a + ld h, $00 + call LoadTxRam3 + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr nz, .opponent + + ldtx hl, WillDrawNPrizesText + call DrawWideTextBox_WaitForInput + ld a, [wccc8] + call Func_310a + ld hl, hTemp_ffa0 + ld d, [hl] + inc hl + ld e, [hl] + call SerialSend8Bytes +.asm_582f + call ExchangeRNG + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + or a + ret nz + scf + ret + +.opponent + call Func_588a + ldtx hl, WillDrawNPrizesText + call DrawWideTextBox_PrintText + call CountPrizes + ld [wcbfc], a + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opponent + call Func_2bd7 + ld c, DECK_SIZE +.asm_5858 + call DoFrame + dec c + jr nz, .asm_5858 + jr .asm_586f + +.link_opponent + call SerialRecv8Bytes + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + ld [hl], d + ld a, e + cp $ff + call nz, AddCardToHand +.asm_586f + ld a, [wcbfc] + ld hl, wccc8 + cp [hl] + jr nc, .asm_587e + ld l, a + ld h, $00 + call LoadTxRam3 +.asm_587e + farcall Func_82b6 + ldtx hl, DrewNPrizesText + call DrawWideTextBox_WaitForInput + jr .asm_582f +; 0x588a + +Func_588a: ; 588a (1:588a) + ld l, PLAYER_TURN + ldh a, [hWhoseTurn] + ld h, a + jp DrawYourOrOppPlayAreaScreen_Bank0 +; 0x5892 ; display the previous valid card page DisplayPreviousCardPage: ; 5892 (1:5892) @@ -4985,7 +5077,7 @@ PrintPokemonCardLength: ; 5f9a (1:5f9a) ; return carry if the turn holder has any Pokemon with non-zero HP on the bench. ; return how many Pokemon with non-zero HP in b. ; does this by calculating how many Pokemon in play area minus one -HasAlivePokemonOnBench: ; 5fd9 (1:5fd9) +HasAlivePokemonInBench: ; 5fd9 (1:5fd9) ld a, $01 jr _HasAlivePokemonInPlayArea @@ -5186,7 +5278,7 @@ Func_60dd: ; 60dd (1:60dd) and SELECT jr z, .asm_60f2 .asm_6119 - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ld a, $01 ld [wcbd4], a .asm_6121 @@ -6698,7 +6790,7 @@ OppAction_ForceSwitchActive: ; 6aba (1:6aba) ldtx hl, SelectPkmnOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call SwapTurn - call HasAlivePokemonOnBench + call HasAlivePokemonInBench ld a, $01 ld [wcbd4], a .force_selection @@ -7221,9 +7313,9 @@ Func_6e49: ; 6e49 (1:6e49) ld a, [wcce8] or a jr z, .asm_6e86 - call $6ff7 + call Func_6ff7 jr c, .asm_6e86 - call $6fc7 + call CountKnockedOutPokemon ld c, a call SwapTurn call CountPrizes @@ -7233,7 +7325,7 @@ Func_6e49: ; 6e49 (1:6e49) jr c, .asm_6e86 ld a, c call SwapTurn - call DrawPrizes + call TakeAPrizes call SwapTurn ld a, $01 jr .asm_6ecc @@ -7243,25 +7335,25 @@ Func_6e49: ; 6e49 (1:6e49) cp $01 jr nz, .asm_6e9f call SwapTurn - call $6ff7 + call Func_6ff7 call SwapTurn jr c, .asm_6e9f ld a, $02 jr .asm_6ecc .asm_6e9f call SwapTurn - call $6eff + call Func_6eff call SwapTurn - call $6eff + call Func_6eff ld a, [wcce8] or a jr nz, .asm_6ec4 xor a .asm_6eb2 push af - call $6f08 + call MoveAllTurnHolderKnockedOutPokemonToDiscardPile call SwapTurn - call $6f08 + call MoveAllTurnHolderKnockedOutPokemonToDiscardPile call SwapTurn call ShiftAllPokemonToFirstPlayAreaSlots pop af @@ -7300,13 +7392,195 @@ ClearDamageReductionSubstatus2OfKnockedOutPokemon: ; 6ee2 (1:6ee2) ; 0x6ef6 Func_6ef6: ; 6ef6 (1:6ef6) - call $6fa5 + call Func_6fa5 ld hl, wcce8 rl [hl] ret ; 0x6eff - INCROM $6eff, $700a +Func_6eff: ; 6eff (1:6eff) + call ReplaceKnockedOutPokemon + ld hl, wcce8 + rl [hl] + ret +; 0x6f08 + +; for each Pokemon in the turn holder's play area (arena and bench), +; move that card to the discard pile if its HP is 0 +MoveAllTurnHolderKnockedOutPokemonToDiscardPile: ; 6f08 (1:6f08) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld d, a + ld l, DUELVARS_ARENA_CARD_HP + ld e, PLAY_AREA_ARENA +.loop + ld a, [hl] + or a + jr nz, .next + push hl + push de + call MovePlayAreaCardToDiscardPile + pop de + pop hl +.next + inc hl + inc e + dec d + jr nz, .loop + ret +; 0x6f23 + +; have the turn holder replace the arena Pokemon card when it's been knocked out. +; if there are no Pokemon cards in the turn holder's bench, return carry. +ReplaceKnockedOutPokemon: ; 6f23 (1:6f23) + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + or a + ret nz + call ClearAllStatusConditions + call HasAlivePokemonInBench + jr nc, .can_replace_pokemon + +; if we made it here, the duelist can't replace the knocked out Pokemon + bank1call DrawDuelMainScene + ldtx hl, ThereAreNoPokemonInPlayAreaText + call DrawWideTextBox_WaitForInput + call ExchangeRNG + scf + ret + +.can_replace_pokemon + ld a, DUELVARS_DUELIST_TYPE + call GetTurnDuelistVariable + cp DUELIST_TYPE_PLAYER + jr nz, .opponent + +; prompt the player to replace the knocked out Pokemon with one from bench + bank1call DrawDuelMainScene + ldtx hl, SelectPokemonToPlaceInTheArenaText + call DrawWideTextBox_WaitForInput + ld a, $01 + ld [wcbd4], a + ld a, PRACTICEDUEL_PLAY_STARYU_FROM_BENCH + call DoPracticeDuelAction +.select_pokemon + call OpenPlayAreaScreenForSelection + jr c, .select_pokemon + ldh a, [hTempPlayAreaLocation_ff9d] + call SerialSend8Bytes + +; replace the arena Pokemon with the one at location [hTempPlayAreaLocation_ff9d] +.replace_pokemon + call Func_3b31 + ld a, PRACTICEDUEL_REPLACE_KNOCKED_OUT_POKEMON + call DoPracticeDuelAction + jr c, .select_pokemon + ldh a, [hTempPlayAreaLocation_ff9d] + ld d, a + ld e, PLAY_AREA_ARENA + call SwapPlayAreaPokemon + ld a, DUELVARS_ARENA_CARD + call GetTurnDuelistVariable + ldtx hl, DuelistPlacedACardText + bank1call DisplayCardDetailScreen + call ExchangeRNG + or a + ret + +; the AI opponent replaces the knocked out Pokemon with one from bench +.opponent + cp DUELIST_TYPE_LINK_OPP + jr z, .link_opponent + call Func_2bcf + ldh a, [hTemp_ffa0] + ldh [hTempPlayAreaLocation_ff9d], a + jr .replace_pokemon + +; wait for link opponent to replace the knocked out Pokemon with one from bench +.link_opponent + bank1call DrawDuelMainScene + ldtx hl, DuelistIsSelectingPokemonToPlaceInArenaText + call DrawWideTextBox_PrintText + call SerialRecv8Bytes + ldh [hTempPlayAreaLocation_ff9d], a + jr .replace_pokemon +; 0x6fa5 + +Func_6fa5: ; 6fa5 (1:6fa5) + call CountKnockedOutPokemon + ret nc + ; at least one Pokemon knocked out + call SwapTurn + bank1call Func_5805 + call SwapTurn + ret nc + call SwapTurn + bank1call DrawDuelMainScene + ldtx hl, TookAllThePrizesText + call DrawWideTextBox_WaitForInput + call ExchangeRNG + call SwapTurn + scf + ret +; 0x6fc7 + +; return in wccc8 the amount of Pokemon in the turn holder's +; play area that are still there despite having 0 HP. +; that is, the number of Pokemon that have just been knocked out. +; Clefairy Doll and Mysterious Fossil don't count. +CountKnockedOutPokemon: ; 6fc7 (1:6fc7) + ld a, DUELVARS_ARENA_CARD_HP + call GetTurnDuelistVariable + ld d, h + ld e, DUELVARS_ARENA_CARD + ld b, PLAY_AREA_ARENA + ld c, MAX_PLAY_AREA_POKEMON +.loop + ld a, [de] + cp -1 + jr z, .next ; jump if no Pokemon in this location + ld a, [hl] + or a + jr nz, .next ; jump if this Pokemon's HP isn't 0 + ; this Pokemon's HP has just become 0 + ld a, [de] + push de + call GetCardIDFromDeckIndex + call GetCardType + pop de + cp TYPE_TRAINER + jr z, .next ; jump if this is a trainer card (Clefairy Doll or Mysterious Fossil) + inc b +.next + inc hl + inc de + dec c + jr nz, .loop + ld a, b + ld [wccc8], a + or a + ret z + scf + ret +; 0x6ff7 + +Func_6ff7: ; 6ff7 (1:6ff7) + ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA + call GetTurnDuelistVariable + ld c, a + ld l, DUELVARS_ARENA_CARD_HP +.loop + ld a, [hli] + or a + jr nz, .non_zero_hp + dec c + jr nz, .loop + scf + ret +.non_zero_hp + or a + ret +; 0x700a ; print one of the "There was no effect from" texts depending ; on the value at wNoEffectFromStatus (NO_STATUS or a status condition constant) @@ -7488,7 +7762,7 @@ PrizeBitmasks: ; 715a (1:715a) ; update the turn holder's DUELVARS_PRIZES following that duelist ; drawing a number of prizes equal to register a -DrawPrizes: ; 7161 (1:7161) +TakeAPrizes: ; 7161 (1:7161) or a ret z ld c, a diff --git a/src/engine/home.asm b/src/engine/home.asm index b46bc44..6ff4cbb 100644 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -4023,8 +4023,8 @@ PutHandCardInPlayArea: ; 14d2 (0:14d2) ret ; 0x14dd -; move the play area Pokemon card of the turn holder at CARD_LOCATION_PLAY_AREA + a -; to the discard pile +; move the Pokemon card of the turn holder in the +; PLAY_AREA_* location given in e to the discard pile MovePlayAreaCardToDiscardPile: ; 14dd (0:14dd) call EmptyPlayAreaSlot ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA diff --git a/src/text/text1.asm b/src/text/text1.asm index 8789758..075a9ef 100644 --- a/src/text/text1.asm +++ b/src/text/text1.asm @@ -277,15 +277,15 @@ DiscardDescription: ; 36757 (d:6757) line "a Pokémon Power)" done -Text0042: ; 367cc (d:67cc) +WillDrawNPrizesText: ; 367cc (d:67cc) text " will draw Prize(s)." done -Text0043: ; 367e5 (d:67e5) +DrewNPrizesText: ; 367e5 (d:67e5) text " drew Prize(s)." done -Text0044: ; 367f9 (d:67f9) +DuelistPlacedACardText: ; 367f9 (d:67f9) text " placed" line "a ." done @@ -561,12 +561,12 @@ CardsText: ; 36e63 (d:6e63) text "Cards" done -Text007f: ; 36e6a (d:6e6a) +TookAllThePrizesText: ; 36e6a (d:6e6a) text " took" line "all the Prizes!" done -Text0080: ; 36e82 (d:6e82) +ThereAreNoPokemonInPlayAreaText: ; 36e82 (d:6e82) text "There are no Pokémon" line "in 's Play Area!" done diff --git a/src/text/text2.asm b/src/text/text2.asm index 8dac791..97ecf45 100644 --- a/src/text/text2.asm +++ b/src/text/text2.asm @@ -126,12 +126,12 @@ SelectPkmnOnBenchToSwitchWithActiveText: ; 38533 (e:4533) line "to switch with the Active Pokémon." done -Text010f: ; 38575 (e:4575) +SelectPokemonToPlaceInTheArenaText: ; 38575 (e:4575) text "Select a Pokémon to place" line "in the Arena." done -Text0110: ; 3859e (e:459e) +DuelistIsSelectingPokemonToPlaceInArenaText: ; 3859e (e:459e) text " is selecting a Pokémon" line "to place in the Arena." done diff --git a/src/text/text_offsets.asm b/src/text/text_offsets.asm index 6e03ba2..cf89644 100644 --- a/src/text/text_offsets.asm +++ b/src/text/text_offsets.asm @@ -67,9 +67,9 @@ TextOffsets:: ; 34000 (d:4000) textpointer Text003f ; 0x003f textpointer Text0040 ; 0x0040 textpointer DiscardDescription ; 0x0041 - textpointer Text0042 ; 0x0042 - textpointer Text0043 ; 0x0043 - textpointer Text0044 ; 0x0044 + textpointer WillDrawNPrizesText ; 0x0042 + textpointer DrewNPrizesText ; 0x0043 + textpointer DuelistPlacedACardText ; 0x0044 textpointer Text0045 ; 0x0045 textpointer Text0046 ; 0x0046 textpointer Text0047 ; 0x0047 @@ -128,8 +128,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer NoneText ; 0x007c textpointer YesText ; 0x007d textpointer CardsText ; 0x007e - textpointer Text007f ; 0x007f - textpointer Text0080 ; 0x0080 + textpointer TookAllThePrizesText ; 0x007f + textpointer ThereAreNoPokemonInPlayAreaText ; 0x0080 textpointer WasKnockedOutText ; 0x0081 textpointer HavePokemonPowerText ; 0x0082 textpointer UnableToUsePkmnPowerDueToToxicGasText ; 0x0083 @@ -272,8 +272,8 @@ TextOffsets:: ; 34000 (d:4000) textpointer NoDamageOrEffectDueToTransparencyText ; 0x010c textpointer Text010d ; 0x010d textpointer SelectPkmnOnBenchToSwitchWithActiveText ; 0x010e - textpointer Text010f ; 0x010f - textpointer Text0110 ; 0x0110 + textpointer SelectPokemonToPlaceInTheArenaText ; 0x010f + textpointer DuelistIsSelectingPokemonToPlaceInArenaText ; 0x0110 textpointer Text0111 ; 0x0111 textpointer Text0112 ; 0x0112 textpointer Text0113 ; 0x0113 diff --git a/src/wram.asm b/src/wram.asm index 38ebd4a..7399551 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -780,6 +780,8 @@ wcbfa:: ; cbfa wcbfb:: ; cbfb ds $1 +; used by Func_5805 to store the remaining Prizes, so that if more than that +; amount would be taken, only the remaining amount is taken wcbfc:: ; cbfc ds $1 @@ -959,7 +961,12 @@ wSelectedMoveIndex:: ; ccc6 ; if affected by a no damage or effect substatus, this flag indicates what the cause was wNoDamageOrEffect:: ; ccc7 - ds $2 + ds $1 + +; used by CountKnockedOutPokemon and Func_5805 to store the amount +; of prizes to take (equal to the number of Pokemon knocked out) +wccc8:: ; ccc8 + ds $1 ; set to 1 if the coin toss in the confusion check is heads (CheckSelfConfusionDamage) wGotHeadsFromConfusionCheck:: ; ccc9 -- cgit v1.2.3