I've been lurking for a long time, trying to learn ASM. Now is the first time I've genuinely been confused to the point where I don't think I can find any resources to help me about it.
I've been trying to make a relatively simple patch that makes it so that 1. you always throw a carried item in the direction you are holding on the d-pad (to remove spin-jump frame variance jank) and 2. if you are spinning and drop or up-throw an item, you throw it out from the center of mario, a la mario maker.
It all works, however, for some
reason, part of my motified drop code doesn't properly work. The thing is, I basically copy-pasted the code from the the disassembly (from address $01A049, to be specific), so I don't know whats different and why it won't work.
What ends up happening is the item gets places a screen too early when facing right, and magically disappears when facing left. Even without the high-byte addition, the item drops ~32 pixels right of where its supposed to be.
Here's the code in question
DropLow: db $F3, $0D ; Low-byte values, -13 and +13
DropHigh: db $FF, $00 ; High-byte values
LDA $D1 ; Get Mario's x-position
ADC DropLow,y ; Add the relevant value
STA $E4,X ; Set the carried sprite's x-position
LDA $D2 ; \
ADC DropHigh,y ; | Repeat for the high-byte
STA $14E0,X ; /
Thank you in advance for anyone who helps!
Edit: Thank you guys! I guess I have to review addressing a little.