Users browsing this thread: 1 Guest(s)
MMMMMagic 2.0

#21
Posts: 377
Threads: 34
Thanks Received: 10
Thanks Given: 7
Joined: Dec 2018
Reputation: 18
Status
Moog
(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 Kappa!  and Surprised , 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.
  Find
Quote  
[-] The following 1 user says Thank You to C-Dude for this post:
  • PowerPanda (04-20-2020)



Messages In This Thread
MMMMMagic 2.0 - by B-Run - 09-17-2016, 09:48 PM
RE: MMMMMagic 2.0 - by B-Run - 09-18-2016, 02:19 PM
RE: MMMMMagic 2.0 - by madsiur - 09-18-2016, 02:36 PM
RE: MMMMMagic 2.0 - by Lockirby2 - 09-18-2016, 04:44 PM
RE: MMMMMagic 2.0 - by Timbo - 03-07-2017, 09:46 AM
RE: MMMMMagic 2.0 - by B-Run - 03-07-2017, 11:23 AM
RE: MMMMMagic 2.0 - by Timbo - 03-07-2017, 12:02 PM
RE: MMMMMagic 2.0 - by B-Run - 03-07-2017, 02:39 PM
RE: MMMMMagic 2.0 - by Blunderpuggs - 12-24-2017, 03:50 PM
RE: MMMMMagic 2.0 - by B-Run - 05-14-2018, 08:34 PM
RE: MMMMMagic 2.0 - by PowerPanda - 07-29-2018, 11:30 PM
RE: MMMMMagic 2.0 - by madsiur - 07-29-2018, 11:41 PM
RE: MMMMMagic 2.0 - by GrayShadows - 07-30-2018, 01:01 AM
RE: MMMMMagic 2.0 - by PowerPanda - 07-30-2018, 10:16 AM
RE: MMMMMagic 2.0 - by OG Cole-Slaw - 07-30-2018, 11:50 AM
RE: MMMMMagic 2.0 - by PowerPanda - 07-30-2018, 11:16 PM
RE: MMMMMagic 2.0 - by madsiur - 07-31-2018, 12:08 AM
RE: MMMMMagic 2.0 - by PowerPanda - 07-31-2018, 02:45 PM
RE: MMMMMagic 2.0 - by B-Run - 10-13-2018, 05:01 PM
RE: MMMMMagic 2.0 - by PowerPanda - 04-19-2020, 06:39 PM
RE: MMMMMagic 2.0 - by C-Dude - 04-19-2020, 11:43 PM
RE: MMMMMagic 2.0 - by PowerPanda - 04-23-2020, 11:46 PM
RE: MMMMMagic 2.0 - by C-Dude - 04-24-2020, 12:39 AM
RE: MMMMMagic 2.0 - by PowerPanda - 04-25-2020, 11:40 AM
RE: MMMMMagic 2.0 - by C-Dude - 04-25-2020, 02:56 PM
RE: MMMMMagic 2.0 - by PowerPanda - 04-25-2020, 04:51 PM
RE: MMMMMagic 2.0 - by C-Dude - 04-25-2020, 09:08 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite