File Name: | Better Password System |
Submitted: | by cthulhu |
Authors: | cthulhu |
Type: | Level |
Includes GFX: | No |
Includes Hijack: | No |
Featured: | No |
Description: | Requested by Anorakun Unlike the previous password system, the main feature of this one is the support for all buttons individually and not shared. Also included is the ability to have multiple rewards, instead of just one. Predefined rewards include: - Give the player lives - Give the player a powerup - Give the player star power - Give the player coins - Trigger ON/OFF - Trigger Blue PSwitch - Trigger Silver PSwitch - Kill the player - Hurt the player - Kill all sprites on screen - Spawn a sprite or custom sprite - Use screen exit - Display Message #1, #2, or the yoshi message - End the level normally or key styled - Custom Code Changelog v1.4: - Fixed the Start button from freezing the game (pausing) during passwords |
Screenshots: | ![]() |
In particular, it's this code which stands out so much:
Code
success: LDY !extra : CPY.b #!totalRewards : BEQ ExitX ; compare extra to the rewards, if equal all rewards given LDA Rewards,Y : CMP #$00 : BEQ Custom ; i'm sure everything to the left explains what it does LDA Rewards,Y : CMP #$01 : BEQ GiveThings LDA Rewards,Y : CMP #$02 : BEQ PowerupStuff LDA Rewards,Y : CMP #$03 : BEQ PowerupStuff_starman LDA Rewards,Y : CMP #$04 : BEQ GiveThings_coins LDA Rewards,Y : CMP #$05 : BEQ Triggers LDA Rewards,Y : CMP #$06 : BEQ Triggers_bpow LDA Rewards,Y : CMP #$07 : BEQ Triggers_spow LDA Rewards,Y : CMP #$08 : BEQ PowerupStuff_kill LDA Rewards,Y : CMP #$09 : BEQ PowerupStuff_hurt LDA Rewards,Y : CMP #$0A : BEQ SpriteStuff LDA Rewards,Y : CMP #$0B : BEQ SpriteStuff_normal LDA Rewards,Y : CMP #$0C : BEQ SpriteStuff_custom LDA Rewards,Y : CMP #$0D : BEQ LevelStuff LDA Rewards,Y : CMP #$0E : BEQ MessageStuff LDA Rewards,Y : CMP #$0F : BEQ MessageStuff_two LDA Rewards,Y : CMP #$10 : BEQ LevelStuff_exit LDA Rewards,Y : CMP #$11 : BEQ LevelStuff_key LDA Rewards,Y : CMP #$12 : BEQ MessageStuff_yoshi RTL ; terminator 2 is the superior film
This huge list of comparison and branch instructions looks to me like resolved macros but can actually be optimised in multiple ways, from the least to major offense:
CMP #$00
is generally unnecessary unless you know that a different register has been used before (e.g.LDA $00 : ... : CMP #$00
is fine.- You always use
LDA Rewards,Y
again when the content doesn't change. - Most importantly, the branch instructions are all unnecessary! The easiest method is to use something like ExecutePtr (takes A as input and is followed by a list of code pointers) or
JSR (Pointers,x)
(takes a list of code pointers and is indexed by X where X is input * 2) which is much shorter and cleaner than the current method.
In particular, this will fix the branch out of range issue since these opcodes are jumps and thus have got no limit inside a bank.
JSR (Pointers,x)
), lack of defines to certain settings (in particular everything related to sound because of AMK's remappings), the option to affect onscreen sprites with the silver p-switch effect (right now, they only affect newly spawned sprites), allow the option to not kill every onscreen sprite with the kill sprite commando (could be e.g. immunity to the goal), defining the total amount of sprite slots despite existing defines within UberASM and redefining the mapping despite that it also is already defined within UberASM.Edit: Also forgot to mention the tools I used:
- Lunar Magic v3.30
- SA-1 Pack v1.40
- UberASM Tool v1.40
- BSNES v115