:+ means "the next nameless label". :- means "the previous nameless label"
: ; <- a nameless label
JMP :- ; <- jumps back to that label (infinite loop)
;;;; the above code is the same as this:
Part of what I'm not getting is that it seems to me going to $3FFDD or $03FFDD, that's at least 3 bytes?
Don't confuse ROM offsets with CPU addresses.
All CPU addresses in Bank F fall between the range $C000-FFFF
All CPU addresses in all other banks fall between the range $8000-BFFF
The game will "swap" different banks in at different times, so the same address might refer to a different offset in the ROM at a different time depending on which bank is selected.
Though.. Bank F never moves. So Anything you put in Bank F will always be accessible, and it's address will never change.
* Is ADC adding to the base effectivity, or over-writing it?
ADC performs addition. It reads a byte from whatever value/address you give it, adds that value to the contents of the A register, and stores the resulting sum in the A register.
What you do with the sum after that depends entirely on what you do with the A register.
* Since BEQ :+ doesn't want to work, what's the best way to check you have an item before applying the boost?
BEQ will work... you just have to give it a label to jump to. See notes above.
* Since this JSR is set in the battle part, will it not work if you cast healing spells outside of battle?
Unfortunately, In-battle and Out-of-battle magic has entirely different code. So yeah you'll have to make changes elsewhere if you want to change out-of-battle magic behavior.
* LDA (btl_magdataptr), Y ; What exactly is this doing? Is it doing math, adding (X) to Y? Or is it saying (X) = Y? Or something completely different?GENERAL EXPLANATION
LDA (some_address), Y performs an "indirect indexed" read. This effectively let's you read from an address a pointer points to.
What this means is as follows:
1) read 2 bytes from the given 'some_address'. Let's call these 2 bytes 'ptr'
2) Add the contents of the Y register to 'ptr'. Let's call this sum 'final_addr'
3) Read 1 byte from 'final_addr'. Put the result in A
For example, say these locations in memory contain the given values:
memory | value
Y reg | $0C
$0010 | $80
$0011 | $60
$608C | $AA
LDA ($10),Y will do the following:
- read the pointer '$6080' from the given address '$0010'
- Add Y to it, giving $608C'
- Read from that address (getting '$AA'), and putting that value in A.SPECIFIC EXPLANATION
'btl_magdataptr' is a pointer which points to a block of magic data.
Y is [presumably] an index that indicates which data you want to read from that block. In this case, since you are doing 'LDY #MAGDATA_EFFECTIVITY', Y is the index to the spell's effectivity.
So in this case.... LDY (btl_magdataptr),Y would read the effectivity for the current spell, and put that value in A.
Continuing with / elaboring on what KingMike is saying.... let's look at your code:
LDY #MAGDATA_EFFECTIVITY ; put effectivity index in Y
LDA (btl_magdataptr), Y ; put spell effectivity in A
LDA item_lute ; put quantity of lutes in A (spell effectivity is no longer in A)
ADC #$45 ; Add $45 to A (A is now quantity of lutes+$45)
LDA item_tnt ; put quantity of TNTs in A (A no longer contains lutes+$45)
ADC #$95 ; Add $95 to A (A is now quantity of TNT+$95)
STA btlmag_effectivity ; Write A to btlmag_effectively, basicaly indicating you want to use that value as the spell's effectivity
As you can see from the comments... most of this code is useless, as it's loading A with some value, only to immediately discard it and load A with something else.
The end result of this is that your magic will always have an effectivity of $95... or $96 if they currently have the TNT.