File Name: | Rock climbing blocks |
Submitted: | 30-May-2016 07:38:17 pm by GreenHammerBro |
Authors: | GreenHammerBro |
Act As: | 25 |
Includes GFX: | Yes |
Description: | These are mini ledges that allow the player jump off. To use, make sure you are doing the following: -Not crouching -Holding in the direction of the wall (towards) -Must be touching the wall, a pixel or more from the player's hitbox does not count. |
While they work fine, they lack of some optimization.
In your code you have this:
Code
<check position> <check button> <check ducking>
Which works fine, but checking the position takes more cycles than checking if Mario's ducking or pressing the desired button, it also it's a low priority check because you already know that the block's code run when the offset is triggered.
You could restructure your code in some way that it does the checks that takes less cycles first and/or those checks that should be done first, in your blocks case, you should check the most important check first.
Code
<check ducking> <check button> <check position>
Checking if mario is ducking seems more important than checking if the button is pressed or checking Mario's position in the block, since the block runs its code only when the offset is triggered, so better check the position at last and take care of the rest first.
Another thing is that the math when checking Mario's position could be done in 8-bit and it would still work on screen boundaries (already tested).
There is another optimization that could be done, the CLC : ADC #$0002 on LeftWallEdge.asm could be changed to ORA #$0002, it does the same effect because you already cleared the lower 4 bits of A with the AND #$FFF0.
And at last...
Code
LDA #$00 STA $1693
Why? STZ exists too, bro.