Wow this is a huge post.
MUSIC CHANNEL RESETTING?
* Is it smart to cancel out the extra LDA #0s?
As long as you know for sure that A will be 0 -- then yes, getting rid of those LDAs is fine.
* To reset the new Loop Marker variable between song changes, will adding that last line work? Testing indicates no, it doesn't...
$4010 is a DMC register and is completely unrelated to anything you might be interested in. So no, that's not going to do anything.
If you want to zero your loop marker variable, then you would STA (with A=0) to whatever address your loop marker variable(s) are. Which I assume would be:
be some code that resets all the channel data when a song loads --- and if there is it might be easier to just modify that code a bit to fit in your changes. But maybe that code doesn't exist... I didn't see it when I glanced at the code (though I didn't look very long). =/
Very much stumped on how to fix this. Is it as simple as changing AND, or is more code needed?
LDA (lut_WeaponData), Y
STA (btl_ib_charstat_ptr), Y
More code is definitely needed. Your code is very close but not quite right. Remember that the parenthesis in 6502 means indirection, so it's going to try to read a pointer from that address.... and 'lut_WeaponData' is not an address that contains a pointer.
I've added some different comments here, which should help out a bit more:
; At this point, A is the ID of the equipped weapon with the high bit set, or $00 if no weapon
; is equipped. Example:
; A=$00 no weapon
; A=$81 wooden nunchucks
; A=$82 small knife
AND #$7F ; This "chops off" the high bit if a weapon is equipped. So $81 becomes $01, etc.
STA (btl_ib_charstat_ptr), Y ; This writes that value to the btlch_critrate IB stat, which is not the correct value
; Note that you might not want to remove this, though -- as it effectively writes "0"
; if no weapon is equipped, which you want.
AND #$FF ; This isn't really necessary because the above AND 7F took care of it. But you can
; think of this AND as the same as 'CMP #$00'. Basically it's just checking to see
; if a weapon is equipped.
SEC ; subtracts 1 from the equipped weapon ID ... so now it's zero-based ($00 = wooden nunchucks)
JSR GetPointerToWeaponData ; This makes ($88) point to the stats for the equipped weapon.
STA $88 ; The layout of the stats is outlined at the very top of bank_0C.asm. The critical rate
STX $89 ; is index 02, so we'd want to do "LDA ($88),Y" when Y=02 to get the weapon's crit stat
LDA ($88), Y ; <- here, Y=7, which is the palette stat
STA (btl_ib_charstat_ptr), Y ; <- which it then writes to IB palette data
;; <<--- This is where you'll want to put in the Crit stat lookup
;; You have all the info you need. You can use the above palette code as an example -- the crit stat code
;; will look very similar
LDA ($88), Y ; <- Y=6, which is graphic data, etc
PlayerAttackEnemy_Physical (I think my battle freezing has to do with this at the moment.)
I'm not going to go in as much detail on this one.
The parens were giving you an error because lut_WeaponData is not a zero page address, and you can only do indirection (parenthesis) on a zero page address.
Without the parens, your code doesn't make much sense:
LDA lut_WeaponData, Y
;; The above is the same as:
Which will just get you offset 5 of the weapon data... which is zero:
It seems like you're falling into the trap of trying random code and hoping it works. Which is almost certain never
to work. If you find yourself doing this, take a step back -- ask yourself what you want to do... and what code you need to do it. You should have a plan before you write any actual code.
But there's another, more basic question to ask here. Do you understand the difference between "LDA nn, Y" and "LDA (nn), Y"? Can you explain what "LDA (nn),Y" does?
PS: don't feel bad or anything -- I'm not trying to rip on you -- I just want to help you learn =)
Multiple Enemy Hits/Misses Having Chances to Cause Ailments
I'll leave this one alone for now. It's not really a matter of moving any code, it might just be branching at a different time.
But to fix this, you'll need to be able to follow what the code is actually doing in order to figure out how to make it do what you want. Don't just jump straight to the "BUGGED" line... look at the code that leads up to it and see if you can really understand WHY the code is bugged the way it is.
BtlMag_LoadPlayerDefenderStats -- Variable confusion!
btlmag_defender_hitrate: I added this to fix BtlMag_Effect_AttackUp2, but I don't know what address to give it in variables.inc ... Should I use the address used by btlmag_defender_unknownRawInit0?
You can give it anything that is RAM ($0000-07FF range, or $6000-7FFF range) that isn't already used by something else.
Or... if it is used by something else ... just make sure it isn't being used at the same time.
'unknown' stuff is a good candidate for free RAM, but you might want to Ctrl+F to find out any code that references it and get rid of it. Also, you might want to Ctrl+F for the raw address (like $6118 or whatever it is) too, just in case.
I also want to use btlmag_defender_magdef for a spell later. Replace btlmag_defender_morale maybe?
Wait... defender_magdef isn't already there? It should be.
Also defender_morale would likely be used for the FEAR family of spells, so I probably wouldn't replace that. But I wouldn't think you'd need to replace anything in this case.... magdef should definitely be there already.
Problem: In testing, a character has 475 Max HP, but only loses 29 to poison. Shouldn't it be 59?
You're dividing by 16, not by 8. Each shift is a divide by 2, and you're doing 4 of them. 1/2 * 1/2 * 1/2 * 1/2 = 1/16
Also you might want to SEC before the first SBC to prevent the additional -1. But it'd only make 1 HP difference... so whatever.
Will the dead/stone check work? Question: BNE after checking for stone/death first? I figured to use it because it's If YES then exit, while with the poison check, its If NO then exit.
It should. Looks fine to me. =)
Additional Complication: I'd also like this to pop up a few messages to tell the player how much they've been poisoned for. But that's for after I get it working.
Drawing stuff is kind of a nightmare. I don't remember offhand how it all works... I'd have to look it up, and... blech I don't want to do that now.
There are some routines that deal with drawing "Battle Boxes". From what I remember, you'll want to format a string to put in RAM somewhere, then call a routine that draws a battle box and give it a pointer to that string.
See if you can find the code that draws the damage text for attacks and use that as a guide.
So after the STX.. you know the following:
- 'tmp' contains a random number between [0, level+15]
- 'A' contains the player's luck
So it makes sense to CMP them -- but ask yourself if BEQ is what you really want
Doublechecking my Orb Boost Code For Battle!
When you call 'MathBuf_Add', A is the index of the math buffer you'd want to use. If you're modifying spell hit rate, you'd ALWAYS want A=#MATHBUF_HITCHANCE, since that's the index of the buffer that holds the hit chance.X
is the value that actually gets added. The original code is adding btlmag_hitrate. You'll either want to add your orb boost to that value before adding it to the math buffer, or you'd want to add the orb boost separately.
Your code is modifying A.. and thus you are making it add btlmag_hitrate to some other unrelated buffer. Definitely not what you want.
Assuming math_basedamage is the correct buffer (I'm too lazy to check), that all looks good.
The only thing to worry about here is overflow. If the character is at level 50 and has all 4 orbs lit, you'll be adding 105 to the effectivity -- which means you can't have any spell that has base effectivity over 150 or else it will overflow.
Looks good... just with same overflow caveats.
Queston with RandAX: Does this routine pick a number BETWEEN 0 and 200, or is it 0 OR 200?
Between and including whatever values are in A and X. RandAX with A=4 and X=7 will give you either 4, 5, 6, or 7.
It seems like the game has special code for when it hits 200, and that its used for some spells (putting an enemy to sleep/stunning) which seem to have a fairly high fail rate when actually playing the game. Or its a 50/50 fail rate and RNG hates me to the point where I gave up using status spells in games the last 20 years, because they never freakin' work...
IIRC 200 is a "critical miss".... like rolling a natural 1 in D&D. No matter what your stats, if you get that roll, it misses.
But even if you don't get 200, you might still miss. It will then depend on whatever other logic the spell does to determine hit/miss.