Users browsing this thread: 1 Guest(s)
Casting Spells Taught by Espers - RESOLVED!

#7
Posts: 89
Threads: 11
Thanks Received: 3
Thanks Given: 1
Joined: Dec 2015
Reputation: 3
Status
Debrave
No, I'm not bumping this for no reason or to ask for help. Instead I would like to give an update. I finally got this to work in battle.

What took so long, aside from the fact that I hadn't been working on it consistently? The fact that I did not truly understand the code.

I presumed that once I was able to get the game to recognize when an Esper was equipped and to react accordingly, I could simply copy and paste from the code I had already generated. After all, if the second loop could be trained to remove spells, I thought it would be trivial to get the first loop to do the same.

I was completely wrong.

It was only after spending a considerable amount of time did I realize it was not possible to copy and paste completely from my modified code because my modified code was for a 16-bit X and Y.  By contrast, the original loop that sets all the spells known by all characters uses an 8-bit X and Y. Yes, assassin tried to explain the difference between the magic building loops in battle, but I did not fully grasp the implications.

(04-13-2017, 06:50 AM)B-Run Wrote:
(04-13-2017, 12:07 AM)Turbotastic Wrote: The only thing I won't like is that Gogo will still get the benefit of using spells that aren't fully learned by other characters. Since Gogo can mimic everything, though, there's no reason to restrict him aside from balance.

This won't only give him the spells not fully learned... it will give him ALL spells, whether you have aquired the esper for them or not. Or whether anyone on your team knows it at any percent or not. He basically comes as a Magic God. You will want to fix this, if for no other reason than that in menus Gogo will still only get cumulative magic. But that'll be another whole can of worms for your patch when you get to menu magic.

Indeed. I was aware I was only 1/4 of the way there, but I thought I had conquered the hardest 1/4, so I was looking ahead to where I am now. I needed to disable the first restriction loop to see if this could be done at all. At the time, I was presuming that I could simply use the same exact lines for the first loop as I was working my way backwards.  I was working from the least amount of restrictions then seeing if I could then slowly increase them.

  1. See if I could enable spells a character does not know by interrupting the reduction process 
  2. See if I could get spells to show based on whether an Esper was equipped
  3. See if I could restrict the spells that show when equipped
Since I did this for the per-character loop, I thought the process would be identical for the "spells known by any character" loop. The problem is I didn't understand the context of the code for the initial loop to realize why I couldn't.

Now, for posterity sake, I am going to post the code I came up with below. Yes, it is ugly, redundant, and inefficient. Yes, I authorize anyone to make improvements. I claim no ownership and want no credit; B-Run did most of the work for me in this thread, and everyone else helped so much that this is the community's work. Thank you all.

Here is the changed code:


Code:
C255A3:         4C9464                 JMP $6494  ; Jump to new code
C255A6:         EA                     NOP        ; Blank out existing code remnant


Code:
C25708:        4C6964            JMP $6469  ; Jump to new code
C2570B:        EA            NOP        ; Blank out existing code remnant
C2570C:        EA            NOP        ; Blank out existing code remnant
C2570D:        EA            NOP        ; Blank out existing code remnant


Code:
C26469:        B1F0            LDA ($F0),y
C2646B:        1A            INC a
C2646C:        F022            BEQ $6490
C2646E:        A5F7            LDA $F7
C26470:        3018            BMI $648A
C26472:        DA            PHX
C26473:        5A            PHY
C26474:        209362            JSR $6293
C26477:        A00500            LDY #$0005
C2647A:        7B            TDC
C2647B:        BF016ED8        LDA $D86E01,x
C2647F:        C301            CMP $01,s
C26481:        F00B            BEQ $648E
C26483:        E8            INX
C26484:        E8            INX
C26485:        88            DEY
C26486:        D0F3            BNE $647B
C26488:        7A            PLY
C26489:        FA            PLX
C2648A:        7A            PLY
C2648B:        4C0E57            JMP $570E
C2648E:        7A            PLY
C2648F:        FA            PLX
C26490:        7A            PLY
C26491:        4C1657            JMP $5716

Code:
C26494:        C9FF            CMP #$FF       ; Original comparison, just displaced
C26496:        D003            BNE $649B      ; If the spell is not known, skip over the next instrucion
C26498:        4CA755            JMP $55A7      ; If the spell is known, go back to the normal code
C2649B:        C210            REP #$10       ; SUPER IMPORTANT You HAVE to change to 16-Bit X and Y here
C2649D:        5A            PHY            ; Push Y to the stack, because you need Y to load the comparison
C2649E:        BC1030            LDY $3010,x    ; Offset to character info block
C264A1:        B91E16            LDA $161E,y    ; Get equipped Esper
C264A4:        3025            BMI $64CB      ; Value is minus if no equipped Esper
C264A6:        7A            PLY            ; Pull Y from the stack, you need to put X there first and you're going to need
C264A7:        DA            PHX            ; Push X to the stack. You're going to need the original value
C264A8:        5A            PHY            ; Push Y to the stack so it's on top        
C264A9:        209362            JSR $6293      ; Multiplication subroutine so X points to the right location
C264AC:        A00500            LDY #$0005     ; Set up for a 5-iteration loop since each Esper can have 5 spells
C264AF:        7B            TDC            ; Clear A
C264B0:        BF016ED8        LDA $D86E01,x  ; Look up the spell taught by the equipped Esper
C264B4:        C301            CMP $01,s      ; Compare the index with the
C264B6:        F00C            BEQ $64C4      ; If they're the same, break the loop and
C264B8:        E8            INX            ; If they're not the same, decement X
C264B9:        E8            INX            ; Lower X again since the spells are two apart
C264BA:        88            DEY            ; Time to remove one from the loop
C264BB:        D0F3            BNE $64B0      ; As long as Y is not zero, there's still another chance
C264BD:        7A            PLY            ; If you got here, it means the spell's not taught, get Y from the stack
C264BE:        FA            PLX            ; Get X from the stack
C264BF:        E210            SEP #$10       ; SUPER IMPORTANT because unlike the other loop, X and Y are 8-Bit
C264C1:        4CAB55            JMP $55AB      ; Nope, the spell is not learned, jump back up to the code
C264C4:        7A            PLY            ; If you got here, the spell is there, so get Y from the stack
C264C5:        FA            PLX            ; Get X from the stack
C264C6:        E210            SEP #$10       ; SUPER IMPORTANT because unlike the other loop, X and Y are 8-Bit
C264C8:        4CA755            JMP $55A7      ; Jump to "Yes, the spell is known" code
C264CB:        7A            PLY            ; Pull Y from the stack since there was no Esper
C264CC:        E210            SEP #$10       ; SUPER IMPORTANT because unlike the other loop, X and Y are 8-Bit
C264CE:        4CAB55            JMP $55AB      ; No, spell is not known, jump back to loop.

To anyone getting any ideas of incorporating this code in a patch (and it's not patch-ready, especially since it only affects in-battle magic), note that this uses the C2 free space, so keep this in mind when checking for patch compatibility.

And now I've reached the other can of worms at C3 and menu magic...oh my...where are these spells even being PULLED from?

At last, my mindless rant is done.
  Find
Quote  
[-] The following 2 users say Thank You to Turbotastic for this post:
  • Robo Jesus (03-25-2018), seibaby (08-09-2017)



Messages In This Thread
RE: Troubleshooting Code - by B-Run - 04-05-2017, 09:39 PM
RE: Troubleshooting Code - by Turbotastic - 04-13-2017, 12:07 AM
RE: Troubleshooting Code - by madsiur - 04-13-2017, 12:38 AM
RE: Troubleshooting Code - by seibaby - 04-13-2017, 04:20 AM
RE: Troubleshooting Code - by B-Run - 04-13-2017, 06:50 AM
RE: Troubleshooting Code - by Turbotastic - 08-06-2017, 10:30 PM
RE: Troubleshooting Code - by seibaby - 12-10-2017, 10:09 AM
RE: Troubleshooting Code - by seibaby - 08-09-2017, 06:44 PM
RE: Troubleshooting Code - by Turbotastic - 08-10-2017, 07:02 PM
RE: Troubleshooting Code - by seibaby - 08-27-2017, 01:05 PM
RE: Troubleshooting Code - by Turbotastic - 08-28-2017, 07:08 PM
RE: Troubleshooting Code - by Turbotastic - 12-10-2017, 01:42 PM
RE: Troubleshooting Code - by Turbotastic - 03-25-2018, 07:50 AM
RE: Troubleshooting Code - by Turbotastic - 03-29-2018, 11:43 PM
RE: Troubleshooting Code - by madsiur - 03-30-2018, 01:08 AM
RE: Troubleshooting Code - by Turbotastic - 03-30-2018, 01:36 PM

Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite