diff options
author | mid-kid <esteve.varela@gmail.com> | 2019-07-15 18:39:07 +0200 |
---|---|---|
committer | mid-kid <esteve.varela@gmail.com> | 2019-07-15 18:39:07 +0200 |
commit | dfe1bf53ae800043fb59246a89de2dd81736f6fe (patch) | |
tree | 11484483d497e115b5731c064eb116737dffbaf0 | |
parent | 926ac952dbe30e2dac188e013febf215416a71ac (diff) |
Fix diffs
-rw-r--r-- | Add-a-new-text-scrolling-speed.md | 165 |
1 files changed, 83 insertions, 82 deletions
diff --git a/Add-a-new-text-scrolling-speed.md b/Add-a-new-text-scrolling-speed.md index 1ce0d84..44a2d79 100644 --- a/Add-a-new-text-scrolling-speed.md +++ b/Add-a-new-text-scrolling-speed.md @@ -1,4 +1,4 @@ -This tutorial details how to add an additional text speed option. As an example we'll implement an option for instant text. +This tutorial details how to add an additional text speed option to the options screen. As an example we'll implement an option for instant text. ## Contents @@ -13,18 +13,18 @@ This tutorial details how to add an additional text speed option. As an example Edit [constants/wram_constants.asm](../blob/master/constants/wram_constants.asm): ```diff -; wOptions:: ; cfcc -TEXT_DELAY_MASK EQU %111 - const_def 4 - const NO_TEXT_SCROLL ; 4 - const STEREO ; 5 - const BATTLE_SHIFT ; 6 - const BATTLE_SCENE ; 7 - + ; wOptions:: ; cfcc + TEXT_DELAY_MASK EQU %111 + const_def 4 + const NO_TEXT_SCROLL ; 4 + const STEREO ; 5 + const BATTLE_SHIFT ; 6 + const BATTLE_SCENE ; 7 + +TEXT_DELAY_NONE EQU %000 ; 0 -TEXT_DELAY_FAST EQU %001 ; 1 -TEXT_DELAY_MED EQU %011 ; 3 -TEXT_DELAY_SLOW EQU %101 ; 5 + TEXT_DELAY_FAST EQU %001 ; 1 + TEXT_DELAY_MED EQU %011 ; 3 + TEXT_DELAY_SLOW EQU %101 ; 5 ``` As you can see we defined `TEXT_DELAY_NONE` as 0, which will print all characters with 0 frame delay. @@ -35,102 +35,103 @@ As you can see we defined `TEXT_DELAY_NONE` as 0, which will print all character Edit [engine/menus/options_menu.asm](../blob/master/engine/menu/options_menu.asm): ```diff -.Pointers: - dw Options_TextSpeed - ... - - const_def - const OPT_TEXT_SPEED_FAST ; 0 - const OPT_TEXT_SPEED_MED ; 1 - const OPT_TEXT_SPEED_SLOW ; 2 + .Pointers: + dw Options_TextSpeed + ... + + const_def + const OPT_TEXT_SPEED_FAST ; 0 + const OPT_TEXT_SPEED_MED ; 1 + const OPT_TEXT_SPEED_SLOW ; 2 + const OPT_TEXT_SPEED_NONE ; 3 - -Options_TextSpeed: - call GetTextSpeed - ldh a, [hJoyPressed] - bit D_LEFT_F, a - jr nz, .LeftPressed - bit D_RIGHT_F, a - jr z, .NonePressed - ld a, c ; right pressed + + Options_TextSpeed: + call GetTextSpeed + ldh a, [hJoyPressed] + bit D_LEFT_F, a + jr nz, .LeftPressed + bit D_RIGHT_F, a + jr z, .NonePressed + ld a, c ; right pressed - cp OPT_TEXT_SPEED_SLOW -+ cp OPT_TEXT_SPEED_NONE - jr c, .Increase -... - -.LeftPressed: - ld a, c - and a - jr nz, .Decrease - ld c, OPT_TEXT_SPEED_NONE + 1 ++ cp OPT_TEXT_SPEED_NONE + jr c, .Increase + ... + + .LeftPressed: + ld a, c + and a + jr nz, .Decrease + ld c, OPT_TEXT_SPEED_NONE + 1 ``` This will make it cycleable in the options menu but it won't actually work quite yet. We still need to define its string and load the correct previous & next value into registers, otherwise it won't display the selected value correctly. ```diff -.Strings: -; entries correspond to OPT_TEXT_SPEED_* constants - dw .Fast - dw .Mid - dw .Slow -+ dw .None - -.Fast: db "FAST@" -.Mid: db "MID @" -.Slow: db "SLOW@" + .Strings: + ; entries correspond to OPT_TEXT_SPEED_* constants + dw .Fast + dw .Mid + dw .Slow ++ dw .None + + .Fast: db "FAST@" + .Mid: db "MID @" + .Slow: db "SLOW@" +.None: db "NONE@" - -GetTextSpeed: -; converts TEXT_DELAY_* value in a to OPT_TEXT_SPEED_* value in c, -; with previous/next TEXT_DELAY_* values in d/e - ld a, [wOptions] - and TEXT_DELAY_MASK - cp TEXT_DELAY_SLOW - jr z, .slow - cp TEXT_DELAY_FAST - jr z, .fast + + GetTextSpeed: + ; converts TEXT_DELAY_* value in a to OPT_TEXT_SPEED_* value in c, + ; with previous/next TEXT_DELAY_* values in d/e + ld a, [wOptions] + and TEXT_DELAY_MASK + cp TEXT_DELAY_SLOW + jr z, .slow + cp TEXT_DELAY_FAST + jr z, .fast + cp TEXT_DELAY_NONE + jr z, .none - ; none of the above - ld c, OPT_TEXT_SPEED_MED - lb de, TEXT_DELAY_FAST, TEXT_DELAY_SLOW - ret - -.slow - ld c, OPT_TEXT_SPEED_SLOW -- lb de, TEXT_DELAY_MED, TEXT_DELAY_FAST + ; none of the above + ld c, OPT_TEXT_SPEED_MED + lb de, TEXT_DELAY_FAST, TEXT_DELAY_SLOW + ret + + .slow + ld c, OPT_TEXT_SPEED_SLOW +- lb de, TEXT_DELAY_MED, TEXT_DELAY_FAST + lb de, TEXT_DELAY_MED, TEXT_DELAY_NONE - ret - -.fast - ld c, OPT_TEXT_SPEED_FAST -- lb de, TEXT_DELAY_SLOW, TEXT_DELAY_MED + ret + + .fast + ld c, OPT_TEXT_SPEED_FAST +- lb de, TEXT_DELAY_SLOW, TEXT_DELAY_MED + lb de, TEXT_DELAY_NONE, TEXT_DELAY_MED + ret + +.none + ld c, OPT_TEXT_SPEED_NONE + lb de, TEXT_DELAY_SLOW, TEXT_DELAY_FAST - ret + ret ``` Note how `lb de, <previous>, <next>` correspond to the order defined with the `OPT_TEXT_SPEED_<speed>` constants. If your custom text speed is not 0 like mine you're done. -## 3. Fix text speed while holding a or b -There is one last quirk that needs fixing. When you hold a or b while text is scrolling it does so at `TEXT_DELAY_FAST`. Since our custom text speed is faster than that we need to modify that piece of code. +## 3. Fix text speed while holding A or B + +There is one last quirk that needs fixing. When you hold the A or B buttons while text is scrolling it does so at `TEXT_DELAY_FAST`. Since our custom text speed is faster than that we need to make sure this doesn't happen. Edit [home/print_text.asm](../blob/master/home/print_text.asm): ```diff -PrintLetterDelay:: - ... - -; text speed - ld a, [wOptions] - and %111 + PrintLetterDelay:: + ... + + ; text speed + ld a, [wOptions] + and %111 + jr z, .end - jr .updatedelay + jr .updatedelay ``` -And there you go. +And there you go.
\ No newline at end of file |