Language…
15 users online:  Anorakun, bradcomp, Cardioid, DanMario24YT, DasFueller, Green, GRIMMKIN, Kwat1, Rykon-V73, Serena,  Shoujo, SMW Magic, Tulip Time Scholarship Games, vktr,  yoshi3706 - Guests: 283 - Bots: 357
Users: 64,795 (2,373 active)
Latest user: mathew

Automatic ON/OFF Switch Triggering - Koopster

File Name:Automatic ON/OFF Switch Triggering
Submitted:2013-03-10 12:20:43 by Koopster
Rating:0.0
Authors:Koopster
Tool:Romi's Spritetool
Type:Generator
Dynamic:No
Disassembly:No
Includes GFX:No
Description:This generator makes the ON/OFF switch trigger automatically. By default, it triggers on each 6 SMW seconds (or $FF frames). You can customize the triggering time by changing the frames value on the ASM file.

Made on EvilGuy's request.
Tags:automatic, switch, trigger
Download:Download - 477 bytes
7 downloads

Code
dcb "INIT"
dcb "MAIN"

LDA $13
AND $FF		; Frames until switch triggers
BNE Return
LDA #$0B
STA $1DF9
LDA $14AF
EOR #$01
STA $14AF

Return:
RTL

  • AND $FF will read from RAM address $FF, which is freeram or used by LM for some undocumented purpose (I don't know which). You want #$FF.
  • You're using $13. You want $14 in almost every situation, or the timer will run while the game is paused, while Mario is being hurt, and a bunch of similar situations.
  • The comment's suggests that #$C0 would be a valid value - it's not, it'd make the switch go completely crazy for 64 frames and then stand still for 192 frames. You want to mention that the only valid values are #$00, #$01, #$03, #$07, #$0F, #$1F, #$3F, #$7F and #$FF; alternatively you can use a RAM address and make your own timer. Unfortunately, the generators don't seem to have any dedicated RAM addresses, so I'd recommend making this a normal sprite if you're going to use this method.
Fix these and it should be approvable. There are few places to hide unobvious bugs in a code this small.
<blm> zsnes users are the flatearthers of emulation