diff options
author | xCrystal <rgr.crystal@gmail.com> | 2016-03-04 21:38:39 +0100 |
---|---|---|
committer | xCrystal <rgr.crystal@gmail.com> | 2016-03-05 00:21:05 +0100 |
commit | ce16914bb06788557b8ca19132008c34ddb38894 (patch) | |
tree | ba46bab7c584284cfb6a80a27ebebc2fe738a36c /src/engine | |
parent | fb524eaa51f02a4a1fbd54962132dd3c67989ee6 (diff) |
start dissasembling move effect functions
and plenty of other duel related stuff
Diffstat (limited to 'src/engine')
-rwxr-xr-x | src/engine/bank1.asm | 216 | ||||
-rw-r--r-- | src/engine/effect_functions.asm | 95 | ||||
-rwxr-xr-x | src/engine/home.asm | 132 |
3 files changed, 371 insertions, 72 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 6ca20d2..7ab0b22 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -54,9 +54,9 @@ StartDuel: ; 409f (1:409f) ld a, [$cc19] ld [wOpponentDeckId], a call LoadPlayerDeck - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call LoadOpponentDeck - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn jr .asm_40ca ld a, MUSIC_DUELTHEME1 @@ -109,7 +109,7 @@ StartDuel: ; 409f (1:409f) jr z, .asm_4126 .asm_4121 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn jr .mainDuelLoop .asm_4126 @@ -258,9 +258,9 @@ Func_4225: ; 4225 (1:4225) ld a, [$cc0d] cp $00 jr z, Func_4262 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_34e2 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call c, $4b2c jr Func_426d @@ -365,9 +365,9 @@ Func_4320: ; 4320 (1:4320) jp Func_426d Func_4329: ; 4329 (1:4329) - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_4333 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ret Func_4333: ; 4333 (1:4333) @@ -375,9 +375,9 @@ Func_4333: ; 4333 (1:4333) jp $6008 Func_4339: ; 4339 (1:4339) - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call $5550 - jp GetOpposingTurnDuelistVariable_SwapTurn + jp SwapTurn Func_4342: ; 4342 (1:4342) jp $5550 @@ -865,7 +865,7 @@ InitializeDuelVariables: ; 7107 (1:7107) pop af pop hl ld [hl], a - ld bc, DECK_SIZE ; lb bc, DUELVARS_CARD_LOCATIONS, DECK_SIZE + lb bc, DUELVARS_CARD_LOCATIONS, DECK_SIZE ld l, DUELVARS_DECK_CARDS .initDuelVariablesLoop ; zero card locations and cards in hand, and init order of cards in deck @@ -889,7 +889,201 @@ InitializeDuelVariables: ; 7107 (1:7107) ret ; 0x7133 -INCBIN "baserom.gbc",$7133,$7354 - $7133 +INCBIN "baserom.gbc",$7133,$71ad - $7133 + +TossCoin: ; 71ad (1:71ad) + ld [$cd9c], a + ld a, [wcac2] + cp $6 + jr z, .asm_71c1 + xor a + ld [$cd9f], a + call Func_04a2 + call $210f + +.asm_71c1 + ld a, [$cd9f] + or a + jr nz, .asm_71ec + ld a, $6 + ld [wcac2], a + ld de, $000c + ld bc, $1406 + ld hl, $0000 + call DrawLabeledTextBox + call EnableLCD + ld de, $010e + ld a, $13 + call Func_22a6 + ld hl, wCoinTossScreenTextId + ld a, [hli] + ld h, [hl] + ld l, a + call PrintText + +.asm_71ec + ld hl, wCoinTossScreenTextId + xor a + ld [hli], a + ld [hl], a + call EnableLCD + ld a, $f1 + call GetTurnDuelistVariable + ld [$cd9e], a + call Func_0f58 + xor a + ld [$cd9d], a + ld a, [$cd9c] + cp $2 + jr c, .asm_7223 + ld bc, $0f0b + ld a, [$cd9f] + inc a + call $65b7 + ld b, $11 + ld a, $2e + call Func_06c3 + inc b + ld a, [$cd9c] + call $65b7 + +.asm_7223 + call Func_3b21 + ld a, $58 + call Func_3b6a + ld a, [$cd9e] + or a + jr z, .asm_7236 + call $7324 + jr .asm_723c + +.asm_7236 + call WaitForWideTextBoxInput + call $72ff + +.asm_723c + call Func_3b21 + ld d, $5a + ld e, $0 + call UpdateRNGSources + rra + jr c, .asm_724d + ld d, $59 + ld e, $1 + +.asm_724d + ld a, d + call Func_3b6a + ld a, [$cd9e] + or a + jr z, .asm_725e + ld a, e + call $7310 + ld e, a + jr .asm_726c + +.asm_725e + push de + call DoFrame + call Func_3b52 + pop de + jr c, .asm_725e + ld a, e + call $72ff + +.asm_726c + ld b, $5c + ld c, $34 + ld a, e + or a + jr z, .asm_727c + ld b, $5b + ld c, $30 + ld hl, $cd9d + inc [hl] + +.asm_727c + ld a, b + call Func_3b6a + ld a, [$cd9e] + or a + jr z, .asm_728a + ld a, $1 + xor e + ld e, a + +.asm_728a + ld d, $54 + ld a, e + or a + jr nz, .asm_7292 + ld d, $55 + +.asm_7292 + ld a, d + call Func_3796 + ld a, [$cd9c] + dec a + jr z, .asm_72b9 + ld a, c + push af + ld e, $0 + ld a, [$cd9f] +.asm_72a3 + cp $a + jr c, .asm_72ad + inc e + inc e + sub $a + jr .asm_72a3 + +.asm_72ad + add a + ld d, a + ld bc, $0202 + ld hl, $0102 + pop af + call Func_1f5f + +.asm_72b9 + ld hl, $cd9f + inc [hl] + ld a, [$cd9e] + or a + jr z, .asm_72dc + ld a, [hl] + ld hl, $cd9c + cp [hl] + call z, WaitForWideTextBoxInput + call $7324 + ld a, [$cd9c] + ld hl, $cd9d + or [hl] + jr nz, .asm_72e2 + call z, WaitForWideTextBoxInput + jr .asm_72e2 + +.asm_72dc + call WaitForWideTextBoxInput + call $72ff + +.asm_72e2 + call Func_3b31 + ld a, [$cd9f] + ld hl, $cd9c + cp [hl] + jp c, $7204 + call Func_0f58 + call Func_3b31 + call Func_3b21 + ld a, [$cd9d] + or a + ret z + scf + ret +; 0x72ff + +INCBIN "baserom.gbc",$72ff,$7354 - $72ff BuildVersion: ; 7354 (1:7354) db "VER 12/20 09:36",TX_END diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm new file mode 100644 index 0000000..84d3b0b --- /dev/null +++ b/src/engine/effect_functions.asm @@ -0,0 +1,95 @@ +Poison50PercentEffect: ; 2c000 (b:4000) + text_de PoisonCheckText + call DisplayCoinTossScreen2_BankB + ret nc + +PoisonEffect: ; 2c007 (b:4007) + lb bc, $0f, CARD_POISONED + jr applyEffect + + lb bc, $0f, CARD_DOUBLE_POISONED + jr applyEffect + +Paralysis50PercentEffect: ; 2c011 (b:4011) + text_de ParalysisCheckText + call DisplayCoinTossScreen2_BankB + ret nc + lb bc, $f0, CARD_PARALYZED + jr applyEffect + +Confusion50PercentEffect: ; 2c01d (b:401d) + text_de ConfusionCheckText + call DisplayCoinTossScreen2_BankB + ret nc + lb bc, $f0, CARD_CONFUSED + jr applyEffect + + text_de SleepCheckText + call DisplayCoinTossScreen2_BankB + ret nc + +SleepEffect: ; 2c030 (b:4030) + lb bc, $f0, CARD_ASLEEP + jr applyEffect + +applyEffect + ld a, [$ff97] + ld hl, $cc05 + cp [hl] + jr nz, .asm_2c061 + ld a, [wccc4] + cp $cb + jr z, .asm_2c058 + cp $cc + jr z, .asm_2c058 + cp $be + jr nz, .asm_2c061 + call SwapTurn + xor a + call Func_34f0 + call SwapTurn + jr c, .asm_2c061 + +.asm_2c058 + ld a, c + ld [wccf1], a + call Func_2c09c + or a + ret + +.asm_2c061 + ld hl, wcccd + push hl + ld e, [hl] + ld d, $0 + ld hl, $ccce + add hl, de + call SwapTurn + ld a, [$ff97] + ld [hli], a + call SwapTurn + ld [hl], b + inc hl + ld [hl], c + pop hl + inc [hl] + inc [hl] + inc [hl] + scf + ret +; 0x2c07e + +DisplayCoinTossScreen2_BankB: ; 2c07e (b:407e) + call DisplayCoinTossScreen2 + ret +; 0x2c082 + +INCBIN "baserom.gbc",$2c082,$2c09c - $2c082 + +Func_2c09c: ; 2c09c (b:409c) + ld a, $1 + ld [wcced], a + ret +; 0x2c0a2 + +INCBIN "baserom.gbc",$2c0a2,$30000 - $2c0a2 diff --git a/src/engine/home.asm b/src/engine/home.asm index 5a10d44..3875ff7 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -2180,13 +2180,13 @@ Func_100b: ; 100b (0:100b) call LoadDeckCardToDE ld a, e ld [wccc3], a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call LoadDeckCardToDE ld a, e ld [wccc4], a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn pop hl push hl call EnableExtRAM @@ -2531,13 +2531,13 @@ Func_16f6: ; 16f6 (0:16f6) call LoadDeckCardToDE ld a, e ld [wccc3], a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call LoadDeckCardToDE ld a, e ld [wccc4], a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn xor a ld [wccec], a ld [wcccd], a @@ -2595,9 +2595,9 @@ Func_1730: ; 1730 (0:1730) ld a, [wccb1] and $80 jr nz, .asm_17ad - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_3432 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn .asm_17ad xor a ld [$ff9d], a @@ -2749,11 +2749,11 @@ Func_189d: ; 189d (0:189d) ret z .asm_18b9 push de - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn xor a ld [wcceb], a call Func_348a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn pop de ret nc bank1call $4f9d @@ -2775,7 +2775,7 @@ Func_18d7: ; 18d7 (0:18d7) ret .confused ld de, $00f7 - call Func_307d + call DisplayCoinTossScreen2 jr c, .asm_18f7 ld a, $1 ld [wccc9], a @@ -2846,9 +2846,9 @@ Func_1994: ; 1994 (0:1994) call Func_36f7 call Func_1a0e ld b, a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_3730 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn and b jr z, .asm_19dc sla e @@ -2856,9 +2856,9 @@ Func_1994: ; 1994 (0:1994) ld hl, $ccc1 set 1, [hl] .asm_19dc - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_374a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn and b jr z, .asm_19f3 ld hl, $ffe2 @@ -2870,7 +2870,7 @@ Func_1994: ; 1994 (0:1994) .asm_19f3 ld b, CARD_LOCATION_ARENA call ApplyAttachedPluspower - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld b, CARD_LOCATION_ARENA call ApplyAttachedDefender call Func_3244 @@ -2878,7 +2878,7 @@ Func_1994: ; 1994 (0:1994) jr z, .asm_1a0a ld de, $0000 .asm_1a0a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ret Func_1a0e: ; 1a0e (0:1a0e) @@ -3103,10 +3103,11 @@ Func_1bca: ; 1bca (0:1bca) INCBIN "baserom.gbc",$1c05,$1c72 - $1c05 -; returns [([hWhoseTurn] ^ $1) << 8 + a] in a -; i.e. variable a of the player whose turn it is not -; Also: [hWhoseTurn] <-- ([hWhoseTurn] ^ $1) -GetOpposingTurnDuelistVariable_SwapTurn: ; 1c72 (0:1c72) +; returns [hWhoseTurn] <-- ([hWhoseTurn] ^ $1) +; As a side effect, this also returns a duelist variable in a similar manner to +; GetOpposingTurnDuelistVariable, but this function appears to be +; only called to swap the turn value. +SwapTurn: ; 1c72 (0:1c72) push af push hl call GetOpposingTurnDuelistVariable @@ -3205,7 +3206,7 @@ AdjustCoordinatesForWindow: ; 1deb (0:1deb) ret ; Draws a bxc text box at de printing a name in the left side of the top border. -; The name's text offset must be at hl when this function is called. +; The name's text id must be at hl when this function is called. ; Mostly used to print text boxes for talked-to NPCs, but occasionally used in duels as well. DrawLabeledTextBox: ; 1e00 (0:1e00) ld a, [wConsole] @@ -4515,7 +4516,7 @@ Func_2a44: ; 2a44 (0:2a44) pop hl ld a, l or h - jp nz, Func_2e76 + jp nz, PrintTextNoDelay ld hl, $c590 jp Func_21c5 @@ -4528,7 +4529,7 @@ DrawWideTextBox_PrintText: ; 2a59 (0:2a59) call Func_22a6 call EnableLCD pop hl - jp Func_2e41 + jp PrintText ; draws a 12x6 text box aligned to the bottom left of the screen DrawNarrowTextBox: ; 2a6f (0:2a6f) @@ -4673,10 +4674,10 @@ LoadOpponentDeck: ; 2b78 (0:2b78) .normalSamDuel xor a ld [wOpponentDeckId], a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld a, PRACTICE_PLAYER_DECK call LoadDeck - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld hl, wRNG1 ld a, $57 ld [hli], a @@ -4817,12 +4818,12 @@ Func_2c84: ; 2c84 (0:2c84) call Func_2d15 call Func_2cc8 .asm_2c93 - ld a, [wce47] + ld a, [wTextSpeed] ld c, a inc c jr .asm_2cac .asm_2c9a - ld a, [wce47] + ld a, [wTextSpeed] cp $2 jr nc, .asm_2ca7 ld a, [$ff90] @@ -5085,56 +5086,60 @@ Func_2e2c: ; 2e2c (0:2e2c) pop hl ret -Func_2e41: ; 2e41 (0:2e41) +; prints text with id at hl with letter delay in a textbox area +PrintText: ; 2e41 (0:2e41) ld a, l or h - jr z, .asm_2e53 + jr z, .fromRAM ldh a, [hBankROM] push af call ReadTextOffset - call .asm_2e56 + call .printText pop af call BankswitchHome ret -.asm_2e53 +.fromRAM ld hl, $c590 -.asm_2e56 +.printText call Func_2cc8 -.asm_2e59 +.nextTileLoop ldh a, [hButtonsHeld] ld b, a - ld a, [wce47] + ld a, [wTextSpeed] inc a cp $3 - jr nc, .asm_2e6d + jr nc, .applyDelay + ; if text speed is 1, pressing b ignores it bit 1, b - jr nz, .asm_2e70 - jr .asm_2e6d -.asm_2e6a + jr nz, .skipDelay + jr .applyDelay +.textDelayLoop + ; wait a number of frames equal to wTextSpeed between printing each text tile call DoFrame -.asm_2e6d +.applyDelay dec a - jr nz, .asm_2e6a -.asm_2e70 + jr nz, .textDelayLoop +.skipDelay call Func_2d43 - jr nc, .asm_2e59 + jr nc, .nextTileLoop ret -Func_2e76: ; 2e76 (0:2e76) +; prints text with id at hl without letter delay in a textbox area +PrintTextNoDelay: ; 2e76 (0:2e76) ldh a, [hBankROM] push af call ReadTextOffset call Func_2cc8 -.asm_2e7f +.nextTileLoop call Func_2d43 - jr nc, .asm_2e7f + jr nc, .nextTileLoop pop af call BankswitchHome ret ; Prints a name in the left side of the top border of a text box, usually to identify the talked-to NPC. ; input: - ; hl: text offset + ; hl: text id ; de: where to print the name PrintTextBoxBorderLabel: ; 2e89 (0:2e89) ld a, l @@ -5439,28 +5444,33 @@ Func_3061: ; 3061 (0:3061) pop de ret -Func_3071: ; 3071 (0:3071) +; function that executes a coin toss during a duel, +; displaying the result ([O] or [X]) in the top left corner of the screen. +; text at de is printed in a text box during the coin toss. +; returns c if heads, nc if tails. +DisplayCoinTossScreen1: ; 3071 (0:3071) push hl - ld hl, $ce4e + ld hl, wCoinTossScreenTextId ld [hl], e inc hl ld [hl], d rst $18 - xor l - ld [hl], c + dw TossCoin pop hl ret -Func_307d: ; 307d (0:307d) +; function that executes a coin toss during a duel, without displaying the result. +; text at de is printed in a text box during the coin toss. +; returns c if heads, nc if tails. +DisplayCoinTossScreen2: ; 307d (0:307d) push hl - ld hl, $ce4e + ld hl, wCoinTossScreenTextId ld [hl], e inc hl ld [hl], d ld a, $1 rst $18 - xor l - ld [hl], c + dw TossCoin ld hl, $cac2 ld [hl], $0 pop hl @@ -5926,7 +5936,7 @@ Func_33e1: ; 33e1 (0:33e1) Func_3400: ; 3400 (0:3400) call Func_3414 ret nc - call Func_307d + call DisplayCoinTossScreen2 ld [wcc0a], a ccf ret nc @@ -5940,10 +5950,10 @@ Func_3414: ; 3414 (0:3414) call GetTurnDuelistVariable or a ret z - ld de, $00de + text_de SandAttackCheckText cp $2 jr z, .asm_342b - ld de, $00df + text_de SmokescreenCheckText cp $1 jr z, .asm_342b or a @@ -6020,7 +6030,7 @@ Func_348a: ; 348a (0:348a) xor a ld [wcac2], a ld de, $00f6 - call Func_307d + call DisplayCoinTossScreen2 ret nc ld a, $4 ld [wccc7], a @@ -6064,10 +6074,10 @@ Func_3509: ; 3509 (0:3509) ld [wce7c], a call Func_3525 ld c, a - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ld a, [wce7c] call Func_3525 - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn add c or a scf @@ -6171,9 +6181,9 @@ Func_367b: ; 367b (0:367b) ld a, [wccbf] or a ret z - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn call Func_34ef - call GetOpposingTurnDuelistVariable_SwapTurn + call SwapTurn ret c ld hl, $000a call Func_36a2 |