I have a couple of comments on your code. First of all, good job so far. It looks like you took care to ensure your PHA/PLAs were balanced, which is where a lot of beginners make mistakes.
1. If you are dealing with the first bank of RAM ($7E0000-$7E7FFF) you can omit the "7E". If you are dealing with the first page of RAM ($7E0000-$7E00FF) you can omit the leading "7E00"
Examples:
LDA $7E1420 (AF 20 14 7E) can be reduced to
LDA $1420 (AD 20 14)
STA $7E0071 (8F 71 00 7E) can become
STA $0071 (8D 71 00) or better yet
STA $71 (85 71)
2. The marked lines can be removed. "BEQ SetTeleport" is not needed, because if the value is #$04 the branch to "Fail" won't be taken and "SetTeleport" is the next section that will execute anyway. The last 3 lines I marked don't seem to do anything, what were you trying to accomplish with them?
Code PHA
LDA $7E1420
CMP #$04
BEQ SetTeleport <---
BNE Fail
SetTeleport
LDA #$05
STA $7E0071
LDA $7E1420 <---
CMP #$04 <---
BEQ Fail <---
Fail
PLA
RTS
3. Overall you seem to be getting the hang of it. This code should work without any problems. It's usually a good idea to say how you are inserting the code (block tool, sprite tool, manually, etc.), whether or not you're using an assembler (and which one), and the raw hex equivalent (if your code is short enough).
Follow Us On