This thread is the place to request help with your custom blocks, sprites, routine hacks, and etc. coding within Super Mario World.
If you are going to answer a question, please make sure you know what you're talking about, and most of all, do NOT respond with things like 'I don't know' or 'Do it yourself'. It's called a 'HELP' thread for a reason.
First of all, there seem to be a mistake in your code, it should be:
AD AF 14 C9 01 F0 01 60 A9 01 8D 93 14 60
About the act like setting, it's stored that way:
-the low byte is at $7E1693
-the high byte is in Y
Edit: seem like GY beat me
It worked fine with the A5, in fact the colors go screwy if I use A9 instead, that's why I used A5. But otherwise, it works fine now. The A5 (that I tried with the code before, but didn't post) needed to be A9 though, as well as me not loading Y =P Thanks.
Yet more trouble with the custom blocks... I have EE 20 14 EE 22 14 AD 20 14 C5 05 F0 01 60 A5 00 8D AF 14 60.
It's supposed to add a Yoshi coin (first two addresses) then switch the ON/OFF position to off, but only if 5 Yoshi Coins have been collected. It doesn't activate the ON/OFF part. What's wrong with the code?
I just want to make sure I'm understanding this right, so I'll use the On/Off switch as an example. Is the format kind of like a true/false thing, 00 being false, and 01 being true? Since that wording was so terrible, I'll give an example:
LDA $14AF ;loads the on/off switch value
CMP #$01 ;checks to see if the switch is ON
and so on.
Basically what I'm asking is .. are the values I write 00 and 01 for situations like this?
Yes. With flag values, you use 00 and 01. I believe it's the same with the Goal Sphere address, where all other values will screw something up.
(I.E. 02+ will make the colors go screwy and other various effects.)
The hex string should end with two 60s the way you wrote your code. That's the only reason I could see it crashing.
However, there is a general problem with the way you are trying to achieve the described behavior. Block code is executed once per frame that Mario touches the block. The controller data is only updated once per frame. For all of those checks, $16 always has the same value.
To fix this, you'd need to use an unused RAM address to keep state in between frames. For example:
Each time the block is executed the address is either incremented or zeroed out. If the counter hits 4, we trigger the exit. There are still several issues with this. First, it requires that the button be tapped four consecutive FRAMES. This is probably not possible since there are about 30 frames per second. Another problem is that when Mario leaves the block, the counter doesn't get reset.
There are solutions to these problems. But I'll let this soak in first. Ask about it if you'd like to know more.
Hmm .. well, I was kind of thrown off by these new codes I haven't seen before. I understand INC slightly, but what exactly does STZ do?
Let's see if I can follow what your code does. Loads the controller data, then checks to see if X was pressed - if it wasn't, it just returns. If it was, it does that STZ command, which I have no idea what it does. If you press it four times, then it teleports you.
Thanks for showing me how to do this, it's really helping.
What the code in my last post does: Load the controller data and check if X has been tapped. If it hasn't, reset the counter and return. If it has, add 1 to the counter. If the counter is not equal to 4, return. If the counter is 4, trigger the exit.