RE: MMMMMagic 2.0 - C-Dude - 04-19-2020
(04-19-2020, 06:39 PM)PowerPanda Wrote: I'll be looking into this by myself, but in the event that B-Run sees this and knows the answer offhand....
I would like to add a natural magic list for Relm, and I'd like to have a "starting set" of magic for a new character, Kappa, since Kappa isn't gained until the same point in the story where you can gain Gogo and Umaro. I have checked GrayShadow's patch, but it is completely incompatible with MMMMMagic. How would I modify this patch to add another natural magic list?
I took a quick look at MMMMMagic's disassembly and it looks like it handles natural magic in a relatively vanilla fashion... by which I mean it uses vanilla branching in C0 to build its natural magic lists. Because of this, it should be relatively easy to add additional natMagic users if you have some freespace.
It also does level-based learning in C2, which looks like it uses vanilla "X" register indexing. That can be extended in the same manner Grayshadows did it with the vanilla spell lists.
C0 (Some Vanilla and MMMMMagic)
EDIT: I glassed over a DeMorgan's logic flip. See the lines marked with %%% for the correct hex.
{B0 F2 "BCS" should have been 90 01 "BCC" in Kappa's and Relm's learn freespaces}
EDIT EDIT: PowerPanda found a typo. Two lines should have been 20 13 D6, not 20 30 D6. Argh, I hate when I make dumb typos like that. See lines marked with ###
Code: Teach Natural Abilities learned via Automatic Level-Up
C0/A17F: B90016 LDA $1600,Y (character ID)
C0/A182: C900 CMP #$00 (is character Terra? note there's no need for this CMP here)
C0/A184: F010 BEQ $A196 (branch if so)
C0/A186: C906 CMP #$06 (is character Celes?)
C0/A188: F02E BEQ $A1B8 (branch if so)
C0/A18A: C902 CMP #$02 (is character Cyan?)
C0/A18C: F04C BEQ $A1DA (branch if so)
C0/A18E: C905 CMP #$05 (is character Sabin?)
C0/A190: D003 BNE $A195 (branch if not)
C0/A192: 4C01A2 JMP $A201
C0/A195: 60 RTS
-----
We'll need to put this in a subroutine so we can add more checks.
C0/A17F: 4C XX XX ; JMP to your freespace. Can be done in-line if you've got freespace in C0... otherwise we'll have to get more complex with a JML
[Freespace C0]
B9 00 16 ; LDA $1600,Y [Load the character ID]
C9 0F ; CMP #$0F [Is it Kappa?]
D0 03 ; BNE oneLine [Skip the next line if not]
4C ZZ ZZ ; JMP to Kappa learn freespace
C9 08 ; CMP #$08 [Is it Relm?]
D0 03 ; BNE oneLine [Skip the next line if not]
4C QQ QQ ; JMP to Relm learn freespace
4C 82 A1 ; JMP $A182 [Go back to checking if it's Terra or Celes]
[Kappa learn freespace]
A6 00 LDX $00 ; load natural magic index
**BF 81 E3 EC LDA $ECE381,X ; check level requirement [You need to add this and Relm's table before Terra's and Celes's at this location]
[It's the four lines above wherever this spell list is... I imagine you've relocated it]
D9 08 16 CMP $1608,Y ; compare it to her current level [Make sure Kappa's list has low levels so she starts with most of these spells]
F0 03 BEQ skip the next two lines ; branch if they are the same
%%%90 01 BCC oneLine ; If her level is higher, skip the next line
60 RTS ; If her level is lower, she won't learn any more spells this session, exit.
DA PHX ; backup X
BF 80 E3 EC LDA $ECE380,X ; natural magic spell
EA EA EA NOP ; wait
###20 13 D6 JSR $D613 ; set spell as learned [If not in the C0 bank, this will need to be changed to a JSL, which will in turn change some of our backwards branches]
FA PLX ; restore X
E8 INX ; increase index to next spell
E8 INX ; increase index to next spell
E0 20 00 CPX #$0020 ; have we checked 16 spells yet?
D0 01 BNE skip the next line ; branch if not
60 RTS ;If we've checked 16 spells, exit.
80 DE BRA backwards to ** ; otherwise loop and keep learning
[Relm learn freespace]
A6 00 LDX $00 ; load natural magic index
**BF A1 E3 EC LDA $ECE3A1,X ; check level requirement [Relm's table is between Kappa's and Terra's]
[It's the four lines above wherever this spell list is... I imagine you've relocated it]
D9 08 16 CMP $1608,Y ; compare it to her current level
F0 03 BEQ skip the next two lines ; branch if they are the same
%%%90 01 BCC oneLine ; If her level is higher, skip the next line
60 RTS ; If her level is lower, she won't learn any more spells this session, exit.
DA PHX ; backup X
BF A0 E3 EC LDA $ECE3A0,X ; natural magic spell
EA EA EA NOP ; wait
###20 13 D6 JSR $D613 ; set spell as learned [If not in the C0 bank, this will need to be changed to a JSL, which will in turn change some of our backwards branches]
FA PLX ; restore X
E8 INX ; increase index to next spell
E8 INX ; increase index to next spell
E0 20 00 CPX #$0020 ; have we checked 16 spells yet?
D0 01 BNE skip the next line ; branch if not
60 RTS ;If we've checked 16 spells, exit.
80 DE BRA backwards to ** ; otherwise loop and keep learning
C2 from some Vanilla and MMMMMagic
Since we moved the table backward to make room for and , we need to increase Terra's and Celes's offsets too.
Code: (Handle spells or abilities learned at level-up for character)
C2/61B6: A2 00 00 LDX #$0000 (point to start of Terra's magic learned at
level up block)
C2/61B9: C9 00 CMP #$00 (is it character #0, Terra?)
C2/61BB: F0 3F BEQ $61FC (if yes, branch to see if she learns any spells)
C2/61BD: A2 20 00 LDX #$0020 (point to start of Celes' magic learned at
level up block)
C2/61C0: C9 06 CMP #$06 (is it character #6, Celes?)
C2/61C2: F0 38 BEQ $61FC (if yes, branch to see if she learns any spells)
C2/61C4: A2 00 00 LDX #$0000 (point to start of Cyan's SwdTechs learned
at level up block)
C2/61C7: C9 02 CMP #$02 (if it character #2, Cyan?)
C2/61C9: D0 15 BNE $61E0 (if not, check for Sabin)
--------
Here, we need to make room to check two more characters and make sure our table indices are adjusted accordingly.
C2/61B6: 4C MM MM JMP to C2 Freespace [Hopefully you have some room. Otherwise, we need to use a JML and this will be much more complicated]
...
C2/61BD: A2 60 00 LDX #$0060 (Celes's block now starts at index $60 in the table)
...
...
C2/6201: DF 81 E3 EC CMP $ECE381,X [The spell table got pushed back $40]
...
C2/620A: BF 80 E3 EC LDA $ECE380,X [The spell table got pushed back $40]
[C2 Freespace]
A2 00 00 LDX #$0000 (point to start of the natural magic table, which is Kappa's list)
C9 0F CMP #$0F (is it character #15, Kappa?)
D0 03 BNE skip the next line [if it isn't Kappa, go to the next check]
4C FC 61 JMP $61FC (Go to MMMMMagic's adjusted learn code)
A2 20 00 LDX #$0020 (point to the next entry in the natural magic table, which is Relm's list)
C9 08 CMP #$08 (is it character #08, Relm?)
D0 03 BNE skip the next line [if it isn't Relm, go to the next check]
4C FC 61 JMP $61FC (Go to MMMMMagic's adjusted learn code)
A2 40 00 LDX #$0040 [Now that the table has been enlarged, Terra's section starts at $40]
4C B9 61 JMP $61B9 [Provided all of this is somewhere in C2, this will take us back to the vanilla code and handle the Terra check]
I'm just brainstorming here, so you'll have to try this on a copy of your project to see if it works, but since MMMMMagic seems to be using the vanilla handling for these two natural magic spots I think this will do the trick.
RE: MMMMMagic 2.0 - PowerPanda - 04-23-2020
(04-19-2020, 11:43 PM)C-Dude Wrote: I took a quick look at MMMMMagic's disassembly and it looks like it handles natural magic in a relatively vanilla fashion... by which I mean it uses vanilla branching in C0 to build its natural magic lists. Because of this, it should be relatively easy to add additional natMagic users if you have some freespace.
It also does level-based learning in C2, which looks like it uses vanilla "X" register indexing. That can be extended in the same manner Grayshadows did it with the vanilla spell lists.
I tried out the code today, and it seemed to work exactly as you wrote it. I needed to get the code in BEFORE Relm's actor profile was created, so I've only tested it with Terra and Celes. I'm crossing my fingers and hoping it works perfectly for Relm too.
My magic lists, if anyone is interested.
Code: RELM
01 - Cure
04 - Bolt
08 - Heal
13 - Osmose
18 - Rasp
22 - Bolt 2
26 - Shell
32 - Rflect
38 - Cure 2
43 - Bolt 3
50 - Rfresh (new spell)
56 - Purify (new spell)
67 - Rasp 2 (new spell)
74 - Quick
83 - Trnado (modified spell, making W Wind act like Quake/Flood)
99 - Quake
KAPPA
01 - Imp
05 - Fire
06 - Ice
07 - Bolt
13 - Cure
21 - Fire 2
22 - Ice 2
23 - Bolt 2
29 - Cure 2
33 - Vanish
37 - Blink (new spell)
42 - Fire 3
43 - Ice 3
44 - Bolt 3
50 - Cure 3
60 - Flood (new spell)
So Kappa's list is extremely useful, but not terribly interesting. It's important though, as Kappa is the only magic-learning character that can't join your party until the World of Ruin (and halfway through it, at that). Her gimmick is that she can be either your strongest warrior or your strongest mage, but not at the same time because she can only equip the Imp Armor. You have to use the Imp spell to toggle between forms. Having a character like that not know any magic seemed criminal.
RE: MMMMMagic 2.0 - C-Dude - 04-24-2020
Make a backup of your save file before you get to Thamasa and cross your fingers. When I was first fiddling with Grayshadow's patch I made a lot of mistakes with Strago, which would result in a crash right outside the burning house (when his character profile is created). I've also had some of my hex tweaks completely hose a save file, though never with the spell learning (since no push-pulls were involved).
Alternatively, you might be able to make quick-tests by changing the start event to load Relm or Kappa instead of Terra and launching a new game. Granted that only covers the learning to level 3 (level 4 if you do a few fights), but it'll let you know if my code is workable or not.
That Terra and Celes work is promising, though, because it at least demonstrates that the checks in the freespace are correctly passing over actors 08 and 0f.
RE: MMMMMagic 2.0 - PowerPanda - 04-25-2020
(04-24-2020, 12:39 AM)C-Dude Wrote: Make a backup of your save file before you get to Thamasa and cross your fingers. When I was first fiddling with Grayshadow's patch I made a lot of mistakes with Strago, which would result in a crash right outside the burning house (when his character profile is created). I've also had some of my hex tweaks completely hose a save file, though never with the spell learning (since no push-pulls were involved).
Alternatively, you might be able to make quick-tests by changing the start event to load Relm or Kappa instead of Terra and launching a new game. Granted that only covers the learning to level 3 (level 4 if you do a few fights), but it'll let you know if my code is workable or not.
That Terra and Celes work is promising, though, because it at least demonstrates that the checks in the freespace are correctly passing over actors 08 and 0f.
Yeah, the part in the event code where Relm's profile is created (right as Ultros stomps on you in the Esper Cave) is going to black and crashing. Shoot. I tried the same scene on a backup rom I made before applying the changes, and it worked correctly. I'll take another look at it later.
RE: MMMMMagic 2.0 - C-Dude - 04-25-2020
The good news is it's not a problem in the event code. The bad news is there's a problem in the magic learn on recruitment code. Luckily, since it didn't crash at Terra, Celes, Sabin, or Cyan, we know it's the new code we added for Relm and Kappa. I'm betting it's something in the C0 block, I'm going to look there first.
EDIT: After the three NOPs in the Kappa and Relm freespace, there's a JSR to $D613. This is not a vanilla location; it is a learn command set up by MMMMMagic. If you moved it, those two JSRs need to be repointed (this could be the cause of the crash). I'll continue to look for other potential sources.
Code: EA EA EA 20 13 D6
(occurs twice)
Should point to a block of code that looks like this:
5A 08 48 B9 00 16 E2 30 AA BF 00 00 F3 8F 02 42 00 A9 23 8F 03 42 00 C2 21 A9 89 1A EA EA 6F 16 42 00 85 12 E2 20 7B 68...
I think that might be the problem. Sorry about that. If I worked in ASM instead the pointer could have been a variable and we'd avoid problems like this.
RE: MMMMMagic 2.0 - PowerPanda - 04-25-2020
(04-25-2020, 02:56 PM)C-Dude Wrote: EDIT: After the three NOPs in the Kappa and Relm freespace, there's a JSR to $D613. This is not a vanilla location; it is a learn command set up by MMMMMagic. If you moved it, those two JSRs need to be repointed (this could be the cause of the crash). I'll continue to look for other potential sources.
I actually didn't move any of the C0 stuff, but I was working in hex and not ASM. The hex you have listed above has a typo in it.
Code: 20 30 D6 JSR $D613 ; set spell as learned [If not in the C0 bank, this will need to be changed to a JSL, which will in turn change some of our backwards branches]
It should be 20 13 D6
I have tested it, and it is working. Relm is now in my party, and already knows Cure, Bolt, Osmose, and Rasp. That last one should make her viable for the Floating Continent, if I choose to bring her. Thanks again, C-Dude, for your help. I think I could have gotten there eventually, but with the amount of free time I have these days, it would have taken weeks.
RE: MMMMMagic 2.0 - C-Dude - 04-25-2020
(04-25-2020, 04:51 PM)PowerPanda Wrote: I actually didn't move any of the C0 stuff, but I was working in hex and not ASM. The hex you have listed above has a typo in it.
Code: 20 30 D6 JSR $D613 ; set spell as learned [If not in the C0 bank, this will need to be changed to a JSL, which will in turn change some of our backwards branches]
It should be 20 13 D6
BLARGH, I hate when I mess up stuff like that. Thanks for catching it, I've fixed the original post for people who read through later.
Glad to help. Hopefully this will help others too, who want to use MMMMMagic but with more natural casters.
|