Users browsing this thread: 1 Guest(s)
terra's magitek

#11
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
You cant just remove the old code, you need to make sure it gets moved elsewhere, then have a jump to that code so you can use the space to add the CMP. Line C1/4D45 is crucial.
  Find
Quote  

#12
Posts: 13
Threads: 3
Thanks Received: 0
Thanks Given: 0
Joined: May 2013
Reputation: 0
Status
None
(06-09-2013, 08:37 PM)Edrin Wrote:
Code:
C1/4D45:    22XXXXXX  JSL XX/XXXX (Where XX/XXXX is the location of the moved code, remember to enter your byte words backwards, so a jump to 12/3456 goes 22 56 34 12)
C1/4D4A:    EA          NOP
C1/4D4B:    EA          NOP
C1/4D4C:    C903      CMP #$03       (Is this Shadow?)
C1/4D4E:    D010        BNE $4D60      (branch if not)

in C1/4d45: 22XXXXXX JSL XX/XXXX

I need put the location where are the terra's magitek attack list no?

Data: Magitek attacks for Terra

C1/910C: 00 01
C1/910E: 02 03
C1/9110: 04 05
C1/9112: 06 07

is this or I'm not understanding well?
  Find
Quote  

#13
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
No, the XX/XXXX is the location of the code we moved out of that space to make room for the CMP. What I'm talking about is for picking who gets the special magitek list.
  Find
Quote  

#14
Posts: 290
Threads: 3
Thanks Received: 40
Thanks Given: 1
Joined: Apr 2012
Reputation: 9
Status
None
I think this is what I would do.

At C1/4D4B, do a JSR to some free space (like at C1/FFE5, although there isn't much there to work with; if this is already used or not enough space, a JSL may be needed, although that uses one more byte than JSR so it would probably go best at C1/4D4A).

Then, at whatever free space you jumped to:

Code:
LDA $2EAE,Y   (displaced code; if you JSL'd from C1/4D4A, you would need a TAY before this instruction)
BEQ $05       (Branch if the character is Terra)
CMP #$03
BNE $01       (Branch if the character is not Shadow)
TDC           (zero A; this will ensure the branch at C1/4D4E is not taken when we return)
RTS           (or RTL if you JSL'd instead)

This can be expanded to include other characters, of course, or use BCC/BCS (instead of BNE) to check a range of characters instead of checking them individually.


GET A SILK BAG FROM THE GRAVEYARD DUCK TO LIVE LONGER.

Brave New World
  Find
Quote  

#15
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
(06-10-2013, 10:27 AM)Synchysi Wrote: I think this is what I would do.

At C1/4D4B, do a JSR to some free space (like at C1/FFE5, although there isn't much there to work with; if this is already used or not enough space, a JSL may be needed, although that uses one more byte than JSR so it would probably go best at C1/4D4A).

Then, at whatever free space you jumped to:

Code:
LDA $2EAE,Y   (displaced code; if you JSL'd from C1/4D4A, you would need a TAY before this instruction)
BEQ $05       (Branch if the character is Terra)
CMP #$03
BNE $01       (Branch if the character is not Shadow)
TDC           (zero A; this will ensure the branch at C1/4D4E is not taken when we return)
RTS           (or RTL if you JSL'd instead)

This can be expanded to include other characters, of course, or use BCC/BCS (instead of BNE) to check a range of characters instead of checking them individually.

I think I like this way better.

Edit: Forget my suggestion. You had it right the first time. This would be the best way if you want to give the special menu to both Terra AND Shadow.
  Find
Quote  

#16
Posts: 13
Threads: 3
Thanks Received: 0
Thanks Given: 0
Joined: May 2013
Reputation: 0
Status
None
that i want is give the special menu to shadow instead of terra
  Find
Quote  

#17
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
If you want Shadow and not Terra, then stick with the way we had it the first time.
  Find
Quote  

#18
Posts: 3
Threads: 0
Thanks Received: 0
Thanks Given: 4
Joined: Apr 2014
Reputation: 0
Status
None
(06-09-2013, 08:37 PM)Edrin Wrote: You are correct, Mad. Its because Terra's sprite ID is 0 that it doesn't need a CMP to have BNE branch properly. There are a bunch of ASL that you can move off to another portion of the code to make it all fit.

this:
Code:
C1/4D45:    0A          ASL A
C1/4D46:     0A          ASL A
C1/4D47:     0A          ASL A
C1/4D48:     0A          ASL A
C1/4D49:    0A          ASL A
C1/4D4A:    A8          TAY
C1/4D4B:    B9AE2E      LDA $2EAE,Y
C1/4D4E:    D010        BNE $4D60      (branch if not Terra)

change to this:
Code:
C1/4D45:    22XXXXXX  JSL XX/XXXX (Where XX/XXXX is the location of the moved code, remember to enter your byte words backwards, so a jump to 12/3456 goes 22 56 34 12)
C1/4D4A:    EA          NOP
C1/4D4B:    EA          NOP
C1/4D4C:    C903      CMP #$03       (Is this Shadow?)
C1/4D4E:    D010        BNE $4D60      (branch if not)

Then just shove off the ASLs and sprite index loading elsewhere:
Code:
XX/XXXX:    0A           ASL A
XX/XXXX:     0A          ASL A
XX/XXXX:     0A          ASL A
XX/XXXX:     0A          ASL A
XX/XXXX:    0A          ASL A
XX/XXXX:    A8          TAY
XX/XXXX:    B9AE2E      LDA $2EAE,Y
XX/XXXX:   6B             RTL

Thanks for this code, Edrin! I got it to work sort of, but I had to add an extra NOP for the bytes to add up:
Code:
C1/4D45:    22XXXXXX  JSL XX/XXXX (Where XX/XXXX is the location of the moved code, remember to enter your byte words backwards, so a jump to 12/3456 goes 22 56 34 12)
*C1/4D49:    EA          NOP
C1/4D4A:    EA          NOP
C1/4D4B:    EA          NOP
C1/4D4C:    C903      CMP #$03       (Is this Shadow?)
C1/4D4E:    D010        BNE $4D60      (branch if not)

But it seems to only change the list of spells displayed. It doesn't change the spells actually selected, if that makes sense. I tested by changing all the standard and Terra magitek spells and found that while it was displaying Terra's abilities, the actual (hidden) selection is standard abilities. So for example I changed the first spell to Quasar in Terra's list using FF3usME. It displayed as Quasar, but it cast fire beam, which I had left as the first spell in the standard magitek list.

I thought it might be an SRAM issue, so I tried saving in game and resetting the emulator. I tried reacquiring Mog to redo the character acquisition events (I was testing on Mog since I had a handy save state). I tried fighting multiple battles. All with the same results - it displays Terra's list but it's only a visual; the actual list it lets you select is the standard list.

So then I changed C1/4D4D to $0E for Vicks and started a fresh game. This is what I found:
Terra - standard list displayed, Terra's list selected (opposite as Mog)
Wedge - Terra's list displayed, standard list selected (same as Mog - but this was unexpected - I thought Wedge would have been unaffected)
Vicks - Terra's list displayed, standard list selected (same as Mog)

Next I changed the byte to $0F for Wedge and started a fresh game. Same exact results.

Next I changed the byte to $00 for Terra, which should produce the same results as an unmodified ROM. Same exact results.

So I think I ruled out SRAM carrying over old data.

I feel like there are two problems. First, it always branches for Terra and never for anyone else. So BNE only fails for Terra. That would mean that the zero flag is set iff Terra. That would mean that CMP sets the zero bit iff Terra. But how is that possible if we're comparing against $0E??? Maybe I'm not jumping code and returning properly? Is the M bit off? It sounds almost like round-off error comparing against zero every time thus only finding equality against Terra's $00.

The second problem is that the actual list selected does not appear to change. Is there perhaps a different part of the code where a second check is done to see which list to pull the spell from? Nothing jumped out at me searching through the various decompiled documents.

This is tested on a fresh unheadered us v1.0 ROM, the only changes being editing the magitek lists via FF3usME and using this IPS data from Edrin's code (braces added for readability):
Code:
[50 41 54 43 48] [01 4D 45] [00 0B] [22 A4 FC 0E EA EA EA C9 0E D0 10] [0E FC A4] [00 0A] [0A 0A 0A 0A 0A A8 B9 AE 2E 6B] [45 4F 46]

Any insight would be greatly appreciated!
  Find
Quote  

#19
Posts: 3
Threads: 0
Thanks Received: 0
Thanks Given: 4
Joined: Apr 2014
Reputation: 0
Status
None
I figured it out! Mostly...
The answer to the second part of my problem is that there's a second section of code that sets the actual spells selected. I modified it the same way as the other section.

So here's Edrin's modified code:
Code:
(This is the section where the visual menu is built.)
C1/4D45:    22 A4 FC 0E  JSL CE/FCA4 (Where 0E/FCA4 is the location of the moved code, remember to enter your byte words backwards, so a jump to 12/3456 goes 22 56 34 12)
C1/4D4A:    EA         NOP            (I added this line. It was missing from the example.)
C1/4D4B:    EA         NOP
C1/4D4B:    EA         NOP
C1/4D4C:    C9 0E     CMP #$0E       (Is this Wedge?) (will change this to Shadow after play testing)
C1/4D4E:    D0 10     BNE $4D60      (branch if not)

(This is the section where the actual selection is built.) (I added this section.)
C1/866D:    22 A4 FC 0E  JSL CE/FCA4 (Where 0E/FCA4 is the location of the moved code, remember to enter your byte words backwards, so a jump to 12/3456 goes 22 56 34 12)
C1/8671:    EA         NOP
C1/8672:    EA         NOP
C1/8673:    EA         NOP
C1/8674:    C9 0E     CMP #$0E       (Is this Wedge?) (will change this to Shadow after play testing)
C1/8676:    D0 08     BNE $8680      (branch if not)

(This is the remote subroutine that gets the active character's number.) (It's conveniently used for both parts above.)
CE/FCA4:    0A         ASL A
CE/FCA5:    0A         ASL A
CE/FCA6:    0A         ASL A
CE/FCA7:    0A         ASL A
CE/FCA8:    0A         ASL A
CE/FCA9:    A8         TAY
CE/FCAA:    B9 AE 2E   LDA $2EAE,Y
CE/FCAD:    6B         RTL

So here are the results of this new code:
Terra - Standard list and standard spells
Wedge - Terra's list and Terra's spells
Vicks - Terra's list and Terra's spells
Mog - Standard list and standard spells

Wedge and Vicks are weird. When I change it to $0F for Vicks, no one gets Terra's list and spells. I guess they are both tied to $0E somehow. That answers the first part of my question in my previous post, kind of...

Because when I change the byte to $0A for Mog, here's what I get:
Terra - Standard list and standard spells
Wedge - Standard list and standard spells
Vicks - Standard list and standard spells
Mog - Terra's list and Terra's spells

So it appears to work properly for Mog. Presumably it will work for Shadow or any of the other main characters.

Thanks, Edrin and the others who contributed in this thread! Hopefully this can benefit someone else as well.
  Find
Quote  

#20
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
It's because its searching for the sprite ID, not the character properties. The imperial Soldier sprite is $0E, hence why Wedge and Vicks get it at the same time. If you want to do it by Actor or Character Properties, you can have it check a different byte in the memory instead.
  Find
Quote  
[-] The following 1 user says Thank You to B-Run for this post:
  • yeoldeusrename (04-11-2014)



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite