diff options
author | Rangi42 <remy.oukaour+rangi42@gmail.com> | 2018-02-28 14:18:38 -0500 |
---|---|---|
committer | Rangi42 <remy.oukaour+rangi42@gmail.com> | 2018-02-28 14:18:38 -0500 |
commit | 47cdb5e966d67c3d10cff7c37dcba374a29f43c5 (patch) | |
tree | 4ee983bdc18adeb631031760d41967a4fbf91075 /Automatically-reuse-Repel.md | |
parent | 2e28f37b2361078777a3b4c93857b15105cacc07 (diff) |
Diff lines start with space, +, or -
Diffstat (limited to 'Automatically-reuse-Repel.md')
-rw-r--r-- | Automatically-reuse-Repel.md | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/Automatically-reuse-Repel.md b/Automatically-reuse-Repel.md index 05fecc1..716ef49 100644 --- a/Automatically-reuse-Repel.md +++ b/Automatically-reuse-Repel.md @@ -24,14 +24,14 @@ It's between the `wPlayerData` and `wPlayerDataEnd` labels. That means it's part We need to add a `wRepelType` byte that works the same way. It's just one byte since it stores the item ID. There's free space nearby, so let's use that: ```diff -wLuckyNumberShowFlag:: db ; dc9d + wLuckyNumberShowFlag:: db ; dc9d - ds 1 +wRepelType:: db -wLuckyIDNumber:: dw ; dc9f + wLuckyIDNumber:: dw ; dc9f -wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still active -wBikeStep:: dw -wKurtApricornQuantity:: db + wRepelEffect:: db ; If a Repel is in use, it contains the nr of steps it's still active + wBikeStep:: dw + wKurtApricornQuantity:: db ``` @@ -40,38 +40,38 @@ wKurtApricornQuantity:: db The file that defines item effects is, predictably, [engine/item_effects.asm](../blob/master/engine/item_effects.asm). It turns out that Repel, Super Repel, and Max Repel all use the same code, so we don't have to write anything three times. ```diff -SuperRepelEffect: ; f462 - ld b, 200 - jr UseRepel -; f466 - -MaxRepelEffect: ; f466 - ld b, 250 - jr UseRepel -; f466 - -RepelEffect: ; f46a - ld b, 100 -; f46c - -UseRepel: ; f46c - ld a, [wRepelEffect] - and a - ld hl, TextJump_RepelUsedEarlierIsStillInEffect - jp nz, PrintText - - ld a, b - ld [wRepelEffect], a + SuperRepelEffect: ; f462 + ld b, 200 + jr UseRepel + ; f466 + + MaxRepelEffect: ; f466 + ld b, 250 + jr UseRepel + ; f466 + + RepelEffect: ; f46a + ld b, 100 + ; f46c + + UseRepel: ; f46c + ld a, [wRepelEffect] + and a + ld hl, TextJump_RepelUsedEarlierIsStillInEffect + jp nz, PrintText + + ld a, b + ld [wRepelEffect], a + ld a, [wCurItem] + ld [wRepelType], a - jp UseItemText + jp UseItemText -TextJump_RepelUsedEarlierIsStillInEffect: ; 0xf47d - ; The REPEL used earlier is still in effect. - text_jump Text_RepelUsedEarlierIsStillInEffect - db "@" -; 0xf482 + TextJump_RepelUsedEarlierIsStillInEffect: ; 0xf47d + ; The REPEL used earlier is still in effect. + text_jump Text_RepelUsedEarlierIsStillInEffect + db "@" + ; 0xf482 ``` @@ -80,29 +80,29 @@ TextJump_RepelUsedEarlierIsStillInEffect: ; 0xf47d Edit [engine/events.asm](../blob/master/engine/events.asm): ```diff -DoRepelStep: ; 96bd7 - ld a, [wRepelEffect] - and a - ret z + DoRepelStep: ; 96bd7 + ld a, [wRepelEffect] + and a + ret z - dec a - ld [wRepelEffect], a - ret nz + dec a + ld [wRepelEffect], a + ret nz + ld a, [wRepelType] + ld [wCurItem], a + ld hl, wNumItems + call CheckItem - ld a, BANK(RepelWoreOffScript) - ld hl, RepelWoreOffScript + ld a, BANK(RepelWoreOffScript) + ld hl, RepelWoreOffScript + jr nc, .got_script + ld a, BANK(UseAnotherRepelScript) + ld hl, UseAnotherRepelScript +.got_script - call CallScript - scf - ret -; 96beb + call CallScript + scf + ret + ; 96beb ``` Note that `UseAnotherRepelScript` hasn't been defined yet, so we'll do that next. @@ -113,17 +113,17 @@ Note that `UseAnotherRepelScript` hasn't been defined yet, so we'll do that next Edit [engine/events/misc_scripts_2.asm](../blob/master/engine/events/misc_scripts_2.asm): ```diff -RepelWoreOffScript:: ; 0x13619 - opentext - writetext .text - waitbutton - closetext - end - -.text ; 0x13620 - ; REPEL's effect wore off. - text_jump UnknownText_0x1bd308 - db "@" + RepelWoreOffScript:: ; 0x13619 + opentext + writetext .text + waitbutton + closetext + end + + .text ; 0x13620 + ; REPEL's effect wore off. + text_jump UnknownText_0x1bd308 + db "@" +UseAnotherRepelScript:: + opentext @@ -148,10 +148,10 @@ Again, we have not yet defined `UseAnotherRepelText`, so let's finish up with th Edit [data/text/common_1.asm](../blob/master/data/text/common_1.asm): ```diff -UnknownText_0x1bd308:: - text "REPEL's effect" - line "wore off." - done + UnknownText_0x1bd308:: + text "REPEL's effect" + line "wore off." + done +UseAnotherRepelText:: + text "REPEL's effect" |