Users browsing this thread: 1 Guest(s)
I need help with a 'mystery' code located in my project's F0 bank

#1
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
Hello,

For the past ten years or so, I've been working on a personal project for the game which has grown exponentially beyond my initial ambitions. My latest such ambition is to properly expand the dialog of the game and re-do the script. As I have also used an obsolete version of Fantasy VI: Restored Ability Names as a base, which relocates spell, esper and skill names to the F0 Bank where FF3usME places expanded dialog, I am in trouble, because the expanded script will eat all of my spell names and class names.

This will require me to either completely re-direct the relevant pointers for spell stuff, or learn how to use Kruptar (Atlas does not seem to work on my PC). I'm hell bent on re-directing those pointers for now, because Kruptar is very much out of my league. as I am unfortunately strictly an amateur. I think I'm determined enough to figure this out...eventually.

But (this is the important part!) I've run into a snag: there are 54 bytes located in the F0 bank, starting at 00303600 and ending at 303635, which I can not account for...except in that, as the first thing I tried to do was over-write them all with commands FF, they are apparently vital to opening the menu! Whatever this line of code is, it is now essential, but I will have to move it if I am to proceed this way, as the extended dialog will eat that too. Here is the code:


Code:
00303600 - C2 20 B9 00 00 29 FF 00 0A AA BF 00 63 F0 AA A0
00303610 - 10 00 A9 00 00 E2 20 BF 00 00 F0 F0 09 8D 80 21
00303620 - E8 88 F0 0E 80 F1 C8 88 F0 08 A9 FF 8D 80 21 88
00303630 - D0 FA 9C 80 21 6B

Compounding this mystery, I've also managed to lose all of my documentation associated with this project, and it is only because of sharing copies of the ROM with friends that the project itself has not been lost completely. So I have no idea where this code comes from. I am at something of a loss. I suspect that this line of code may have to do with the restored character class names, as that is the next thing in the code, but I cannot be sure. I also believe that a line in the code, located at 0003F2A6, may be a pointer to this line of code, as it does not appear in a raw version of the rom, and reads...


Code:
22 00 34 F0

...which seems to be a three byte jump routine, to the F0 bank at 00303600 (it is a headered ROM). But I could be completely off base. Can anybody make sense of this?

Any and all assistance would be welcome. I can even whip up a quick patch of my work so far if you want to try a hands-on approach.
  Find
Quote  

#2
Posts: 48
Threads: 7
Thanks Received: 0
Thanks Given: 0
Joined: Dec 2017
Reputation: 0
Status
None
Hello. When I disassemble the code, it looks like this:

Code:
m=false,x=false

start=F0/3600
 REP #$20      
 LDA $0000,Y  
 AND #$00FF    
 ASL          
 TAX          
 LDA $F06300,X
 TAX          
 LDY #$10      
 BRK          
 LDA #$0000    
 SEP #$20      

label_3617
 LDA $F00000,X
 BEQ label_3626
 STA $2180    
 INX          
 DEY          
 BEQ label_3632
 BRA label_3617

label_3626
 INY          
 DEY          
 BEQ label_3632
 LDA #$FF      

label_362C
 STA $2180    
 DEY          
 BNE label_362C

label_3632
 STZ $2180    
 RTL          

end=F0/3636

The RAM address $2180 has to do with skills being learned. From the wiki:


Quote:$208E-$21C9 Character Spell Lists (4 * 79 items [1 esper + 54 spells + 24 lores], 4 bytes each)

Also, it seems you have two tables containing values, one at F0/0000 and one at F0/6300. That's the preliminary information I can provide without my first coffee in the morning.
  Find
Quote  

#3
Posts: 173
Threads: 23
Thanks Received: 20
Thanks Given: 6
Joined: Feb 2016
Reputation: 8
Status
Enlight
This is a new subroutine for the character class names. Angelo moved it in later versions to F2/3400.


I pulled the following from my own update's readme:

Code:
Original:
 C3/6282: F0 5D       BEQ $62E1    ; Branch if no status effect
 C3/6284: 64 F1       STZ $F1
Modified:
 C3/6282: 4C91F0      JMP $F091    ; Break out of status effect check
 C3/6285: EA          NOP          ; Operation moved from C3/6284 to C3/F093


New Subroutine C3/F091
 C3/F091: F0 05       BEQ $F098    ; Branch if no status effect, from C3/6282
 C3/F093: 64 F1       STZ $F1      ; Operation from C3/6284
 C3/F095: 4C 86 62    JMP $6286    ; Return to status effect check
 C3/F098: A9 FF       LDA #$FF     ; Print space before job name (for alignment)
 C3/F09A: 8D 80 21    STA $2180    ; (Writes space to WRAM)
 C3/F09D  4C A3 F0    JMP $F0A3    ; Jump to code for printing the job name
 C3/F0A0: EA          NOP
 C3/F0A1: EA          NOP
 C3/F0A2: EA          NOP


New Subroutines & Data (Angelo)

 C3/F0A3: B9 00 00     LDA $0000,Y
 C3/F0A6: 22 00 34 F2  JSL $F23400  ; New subroutine in F2 bank for class names
 C3/F0AA: 4C 05 35     JMP $3505

And a the subroutine itself from my notes...
Code:
New Subroutine F2/3400:
F2/3400: C2 20       REP #$20
F2/3402: B9 00 00    LDA $0000,y
F2/3405: 29 FF 00    AND #$00FF
F2/3408: 0A          ASL A
F2/3409: AA          TAX
F2/340A: BF 00 63 F2 LDA $F26300,x  <-- class names
F2/340E: AA          TAX
F2/340F: A0 10 00    LDY #$0010
F2/3412: A9 00 00    LDA #$0000
F2/3415: E2 20       SEP #$20
F2/3417: BF 00 00 F2 LDA $F20000,x
F2/341B: F0 09       BEQ $3426
F2/341D: 8D 80 21    STA $2180
F2/3420: E8          INX
F2/3421: 88          DEY
F2/3422: F0 0E       BEQ $3432
F2/3424: 80 F1       BRA $3417
F2/3426: C8          INY
F2/3427: 88          DEY
F2/3428: F0 08       BEQ $3432
F2/342A: A9 FF       LDA #$FF
F2/342C: 8D 80 21    STA $2180
F2/342F: 88          DEY
F2/3430: D0 FA       BNE $342C
F2/3432: 9C 80 21    STZ $2180
F2/3435: 6B          RTL

Hope that helps!
Quote  
[-] The following 2 users say Thank You to SilentEnigma for this post:
  • Marketa Lazarova (08-08-2021), NPCnextdoor (08-08-2021)

#4
Posts: 32
Threads: 4
Thanks Received: 0
Thanks Given: 0
Joined: Mar 2012
Reputation: 0
Status
None
I'll say it was helpful! I think I may be able to get this to work after all; especially using the readme from your update. Its too late for me to apply the update itself (and I did try - disaster!) but I think I can work with what I have.

One more little nibble of concern. This following line of code appears at address 30C400, and its the only other portion of F0 bank I can't account for...


Code:
48 A5 E8 C9 38 F0 02 80 0F A5 E7 C9 82 90 09 A9
46 85 E8 68 A9 70 80 04 68 18 65 E7 85 E7 6B FF

...I picked at it a little, and have decided it has something to do with the display of status effects in menus in the context of the class subroutine, as changing the data causes the game to crash when the menu is called up while under the influence of a status effect, or when changing status effects in the menu. As it appears rather late in F0 bank, it may not actually ever get over-written, but I don't know where it is, nor where it is referenced to from the rest of the data. I can't seem to find any reference to it in your readme or anything identical or similar to it in the original data.
  Find
Quote  

#5
Posts: 173
Threads: 23
Thanks Received: 20
Thanks Given: 6
Joined: Feb 2016
Reputation: 8
Status
Enlight
This is indeed a subroutine that has to do with class names, which get overridden whenever status icons display in the same space (as you may know). Not sure when it gets called, though, so I cannot confirm or deny your specific findings.
Later versions of Angelo's patch again moved it from the $F0 bank to the $F2 bank.
...So in my copy it shows up at 32C400 (headered file) = F2/C200.

Code:
Original
C3/3497: 65 E7        ADC $E7
C3/3499: 85 E7        STA $E7
Modified
C3/3497: 22 00 C2 F2  JSL $F2C200

I think the above is the only reference you will need to fix when you move the data.
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite