Users browsing this thread: 1 Guest(s)
Learning Magic

#1
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
What section of code defines each actors learned magic is located? I want to expand the number of characters that can learn magic by moving the location in the RAM where all of that is stored. To do that I need to find where magic is learned and where it is pointed to from the menu/battle menu. I can't seem to find any of this in FF3info.

note: I already know where to find naturally learned magic.
  Find
Quote  

#2
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(06-28-2012, 12:34 PM)Edrin Wrote: What section of code defines each actors learned magic is located? I want to expand the number of characters that can learn magic by moving the location in the RAM where all of that is stored. To do that I need to find where magic is learned and where it is pointed to from the menu/battle menu. I can't seem to find any of this in FF3info.

note: I already know where to find naturally learned magic.

Everything is update in a few long routines around C2/5E26 along with experience, morph gauge and other stuff. I'm not sure of your question but maybe you are looking for this:

Code:
C2/5E60: 20 83 62     JSR $6283   (Stores address for spells known by character in $F4)

As for moving stuff in the RAM, you need at least 54 bytes to give magic learning to another characters. You have the unused Swtech naming RAM and along with other small unused spot, you might have enough place for an extra character. The problem is your RAM will not be consecutive and you will need to add code to write in the right spot depending on the character and even depending on the magic number in your extra character. This complicate the thing. You could use some unused treasure chest RAM too. This can give you a rough idea of what is available:

Code:
$1600-$1FFF : Data that is stored to Save-RAM
------------------------------------------------

$1600-$184F : Character data (592 bytes, 37 bytes each character)
$1600: Outside battle character Sprite set
$1601: Outside battle character Level adjustment factor (among other things)
$1602: Outside battle character Name (6 bytes)
$1608: Outside battle character unmodified Level
$1609: Outside battle character unmodified Current HP (2 bytes)
$160B: Outside battle character unmodified Max HP (2 bytes)
$160D: Outside battle character unmodified Current MP (2 bytes)
$160F: Outside battle character unmodified Max MP (2 bytes)
$1611: Outside battle character XP (3 bytes)
$1614: Outside battle character Statuses (2 bytes)
$1616: Outside battle character Commands (4 bytes)
$161A: Outside battle character Vigor
$161B: Outside battle character Speed
$161C: Outside battle character Stamina
$161D: Outside battle character Magic Power
$161E: Outside battle character Esper equipped
$161F: Outside battle character Right hand
$1620: Outside battle character Left hand
$1621: Outside battle character Helmet
$1622: Outside battle character Armor
$1623: Outside battle character Relic 1
$1624: Outside battle character Relic 2
(note that the above structure repeats for each character)
$1850-$185F: Setup of current parties (16 bytes)
$1860-$1862: Gold (3 bytes)
$1863-$1865: Game Time (3 bytes)
$1866-$1868: Steps (3 Bytes)
$1869-$1968: Items possessed (256 bytes)
$1969-$1A68: Item quantities (256 bytes)
$1A69-$1A6C: Espers possessed (4 bytes)
$1A6D: Active party
$1A6E-$1CF5: Percentage learned of spells by characters (54 spells X 12 characters = 648 bytes) (#$FF = known)
$1CF6: Time Morph will last
$1CF7: Known sword techs??
$1CF8-$1D27: Sword tech names (48 bytes) (Seems to be a holdover from FF6j, I dunno)
$1D28: BlitzList Sabin's blitzes. Each bit is a blitz; 1 is acquired, 0 isn't.
$1D29-$1D2B: Known lores (3 bytes, 1 bit per lore)
$1D2C-$1D4B: Known rages (32 bytes, 1 bit per rage)
$1D4C: Known dances (1 bit for each dance)
$1D4D: (Bit 7 = 1: Short command set, 6-4: Battle speed, 3 = 1: Wait battle mode, 2-0: Message speed)
$1D4E: (Bit 7 = 1: Reequip empty, 6 = 1: Cursor memory, 5 = 1: Sound mono, 4 = 1: Gauge off, 3-0: Wallpaper)
$1D4F-$1D53 : Not sure...
$1D54: Config (Magic order, among other things)
$1D55-$1D56: Font color
$1D57-$1DC6: Colors for each wallpaper component (7 components X 8 wallpapers X 2 bytes each = 112 bytes)
$1DC7: Number of saves (likely to be two bytes)
$1DC9-$1DDC: List of 20 permanently-stored battle variables
$1DD0: Bit 0 = Fanatics’ Tower
$1DD1: Bit 2 = Morph Available
$1DD3-$1DD4: Doom Gaze’s HP
$1DD5: Battles fought with the cursed shield
$1DDD-$1E1C: Monster formations beaten (to fight on veldt) (64 bytes)
$1E1D-1E3F: (35 bytes which appear to be unused, at least in my save files)
$1E40-$1E6F: Treasure chests opened (Only the first 33 bytes are known to be used)
$1E70-$1E7F: Unused (at least all my save files have this filled with 55h, indicating that it is never disturbed [and I have a lot a save files])
$1E80-$1F5F: Event bits
$1F60: Map XY position (2 bytes)
$1F62: Airship’s XY position (2 bytes)
$1F6D: RndCounter Acts just like $72.
$1F80: Song? (Needs verification)
$1FC2-$1FD1: Event words
$1FF9 : Which monster is it
$1FFE: SRAM Checksum (2 bytes)
  Find
Quote  

#3
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
(06-28-2012, 07:01 PM)Madsiur Wrote:
(06-28-2012, 12:34 PM)Edrin Wrote: What section of code defines each actors learned magic is located? I want to expand the number of characters that can learn magic by moving the location in the RAM where all of that is stored. To do that I need to find where magic is learned and where it is pointed to from the menu/battle menu. I can't seem to find any of this in FF3info.

note: I already know where to find naturally learned magic.

Everything is update in a few long routines around C2/5E26 along with experience, morph gauge and other stuff. I'm not sure of your question but maybe you are looking for this:

Code:
C2/5E60: 20 83 62     JSR $6283   (Stores address for spells known by character in $F4)

As for moving stuff in the RAM, you need at least 54 bytes to give magic learning to another characters. You have the unused Swtech naming RAM and along with other small unused spot, you might have enough place for an extra character. The problem is your RAM will not be consecutive and you will need to add code to write in the right spot depending on the character and even depending on the magic number in your extra character. This complicate the thing. You could use some unused treasure chest RAM too. This can give you a rough idea of what is available:

Code:
$1600-$1FFF : Data that is stored to Save-RAM
------------------------------------------------

$1600-$184F : Character data (592 bytes, 37 bytes each character)
$1600: Outside battle character Sprite set
$1601: Outside battle character Level adjustment factor (among other things)
$1602: Outside battle character Name (6 bytes)
$1608: Outside battle character unmodified Level
$1609: Outside battle character unmodified Current HP (2 bytes)
$160B: Outside battle character unmodified Max HP (2 bytes)
$160D: Outside battle character unmodified Current MP (2 bytes)
$160F: Outside battle character unmodified Max MP (2 bytes)
$1611: Outside battle character XP (3 bytes)
$1614: Outside battle character Statuses (2 bytes)
$1616: Outside battle character Commands (4 bytes)
$161A: Outside battle character Vigor
$161B: Outside battle character Speed
$161C: Outside battle character Stamina
$161D: Outside battle character Magic Power
$161E: Outside battle character Esper equipped
$161F: Outside battle character Right hand
$1620: Outside battle character Left hand
$1621: Outside battle character Helmet
$1622: Outside battle character Armor
$1623: Outside battle character Relic 1
$1624: Outside battle character Relic 2
(note that the above structure repeats for each character)
$1850-$185F: Setup of current parties (16 bytes)
$1860-$1862: Gold (3 bytes)
$1863-$1865: Game Time (3 bytes)
$1866-$1868: Steps (3 Bytes)
$1869-$1968: Items possessed (256 bytes)
$1969-$1A68: Item quantities (256 bytes)
$1A69-$1A6C: Espers possessed (4 bytes)
$1A6D: Active party
$1A6E-$1CF5: Percentage learned of spells by characters (54 spells X 12 characters = 648 bytes) (#$FF = known)
$1CF6: Time Morph will last
$1CF7: Known sword techs??
$1CF8-$1D27: Sword tech names (48 bytes) (Seems to be a holdover from FF6j, I dunno)
$1D28: BlitzList Sabin's blitzes. Each bit is a blitz; 1 is acquired, 0 isn't.
$1D29-$1D2B: Known lores (3 bytes, 1 bit per lore)
$1D2C-$1D4B: Known rages (32 bytes, 1 bit per rage)
$1D4C: Known dances (1 bit for each dance)
$1D4D: (Bit 7 = 1: Short command set, 6-4: Battle speed, 3 = 1: Wait battle mode, 2-0: Message speed)
$1D4E: (Bit 7 = 1: Reequip empty, 6 = 1: Cursor memory, 5 = 1: Sound mono, 4 = 1: Gauge off, 3-0: Wallpaper)
$1D4F-$1D53 : Not sure...
$1D54: Config (Magic order, among other things)
$1D55-$1D56: Font color
$1D57-$1DC6: Colors for each wallpaper component (7 components X 8 wallpapers X 2 bytes each = 112 bytes)
$1DC7: Number of saves (likely to be two bytes)
$1DC9-$1DDC: List of 20 permanently-stored battle variables
$1DD0: Bit 0 = Fanatics’ Tower
$1DD1: Bit 2 = Morph Available
$1DD3-$1DD4: Doom Gaze’s HP
$1DD5: Battles fought with the cursed shield
$1DDD-$1E1C: Monster formations beaten (to fight on veldt) (64 bytes)
$1E1D-1E3F: (35 bytes which appear to be unused, at least in my save files)
$1E40-$1E6F: Treasure chests opened (Only the first 33 bytes are known to be used)
$1E70-$1E7F: Unused (at least all my save files have this filled with 55h, indicating that it is never disturbed [and I have a lot a save files])
$1E80-$1F5F: Event bits
$1F60: Map XY position (2 bytes)
$1F62: Airship’s XY position (2 bytes)
$1F6D: RndCounter Acts just like $72.
$1F80: Song? (Needs verification)
$1FC2-$1FD1: Event words
$1FF9 : Which monster is it
$1FFE: SRAM Checksum (2 bytes)

I think I understand. I was simply looking at the RAM map and noticing large chunks of unusued RAM, but what actually gets put into a game save is a totally different story... I don't suppose there's a way to change the size of the save file. Sigh, there goes my plan to have a billion characters with magic all their own...
  Find
Quote  

#4
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(06-28-2012, 08:19 PM)Edrin Wrote: I think I understand. I was simply looking at the RAM map and noticing large chunks of unusued RAM, but what actually gets put into a game save is a totally different story... I don't suppose there's a way to change the size of the save file. Sigh, there goes my plan to have a billion characters with magic all their own...

There was actually an interesting discussion about expanding the SRAM or using more RAM, I'll let you judge of the feasibility of the idea:

http://mnrogar.slickproductions.org/phpB...?f=3&t=437
  Find
Quote  

#5
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Wow, that's really cool stuff. I'm still pretty new to hacking, and I think doing that much work for the little bit I want to do with it is beyond the scope of the project I'm working on, but maybe once I get some more ASM experience under my belt I will give it another whirl. Thanks Mad.
  Find
Quote  

#6
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Ok, so what about editing the current code to reuse the same 12 lists by using the remainder of the actor number devided by twelve to choose what address to look for? Shared magic is better than none. All I need is the location of the code for both read and write for battle and menu. I think I can figure out the rest.
  Find
Quote  

#7
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(06-30-2012, 10:49 PM)Edrin Wrote: Ok, so what about editing the current code to reuse the same 12 lists by using the remainder of the actor number devided by twelve to choose what address to look for? Shared magic is better than none. All I need is the location of the code for both read and write for battle and menu. I think I can figure out the rest.

I think you will have to change code in 3 places. First, you will ne to change when the magic list is populated for battle (bank C2). Second you will need to change when the magic is saved after a battle (bank C2) and third, when magic is read for the menu outside battle (bank C3).

Here is your entrance door for saving magic. Routines $6283 and$ 602A are where those changes need to be I think but I haven't found explicitly where is it read and save to the RAM:

Code:
C2/5E60: 20 83 62     JSR $6283   (Stores address for spells known by character in $F4)
C2/5E63: BE 10 30     LDX $3010,Y (get offset to character info block)
C2/5E66: 5A           PHY
C2/5E67: 20 EF 5F     JSR $5FEF   (Cursed Shield check)
C2/5E6A: BD 1E 16     LDA $161E,X (Esper equipped)
C2/5E6D: 30 03        BMI $5E72   (Branch if no esper equipped)
C2/5E6F: 20 2A 60     JSR $602A   (Learn spells taught by esper)


I'm still not sure but this is partially where the magic menu might be populated:

Code:
C2/56DC: C2 21        REP #$21     (Set 16-bit A, clear Carry)
C2/56DE: 69 6E 1A     ADC #$1A6E
C2/56E1: 85 F0        STA $F0

As for bank C3 I found not 1 but 2 places where magic spell list is read:

Code:
Get spell's learned amount, or, if it's Gogo, branch below to check everybody
else in the party.
C3/50A2:    85E0        STA $E0
C3/50A4:    20DD4E      JSR $4EDD
C3/50A7:    B90000      LDA $0000,Y
C3/50AA:    C90C        CMP #$0C
C3/50AC:    F017        BEQ $50C5     (Branch if it's Gogo)
C3/50AE:    8D0242      STA $4202
C3/50B1:    A936        LDA #$36
C3/50B3:    8D0342      STA $4203
C3/50B6:    7B          TDC
C3/50B7:    A5E0        LDA $E0
C3/50B9:    C220        REP #$20      (16 bit memory/accum.)
C3/50BB:    6D1642      ADC $4216
C3/50BE:    AA          TAX
C3/50BF:    E220        SEP #$20      (8 bit memory/accum.)
C3/50C1:    BD6E1A      LDA $1A6E,X
C3/50C4:    60          RTS

Code:
Determine if a character actually knows magic
C3/0D2B:    AD691A      LDA $1A69      (from C3/0CB7)
C3/0D2E:    0D6A1A      ORA $1A6A
C3/0D31:    0D6B1A      ORA $1A6B
C3/0D34:    0D6C1A      ORA $1A6C
C3/0D37:    D02A        BNE $0D63      (branch if you have at least one esper)
C3/0D39:    A667        LDX $67
C3/0D3B:    7B          TDC
C3/0D3C:    BD0000      LDA $0000,X    (character ID)
C3/0D3F:    C90C        CMP #$0C
C3/0D41:    F020        BEQ $0D63      (Branch if it's Gogo)
C3/0D43:    B01C        BCS $0D61      (Branch if it's Umaro or higher)
C3/0D45:    8D0242      STA $4202      (we're here if character is below Gogo, and you have no espers)
C3/0D48:    A936        LDA #$36
C3/0D4A:    8D0342      STA $4203      (#$36 as multiplier)
C3/0D4D:    EA          NOP
C3/0D4E:    EA          NOP
C3/0D4F:    EA          NOP
C3/0D50:    A03600      LDY #$0036     (TAY?)
C3/0D53:    AE1642      LDX $4216      (load character * spell total)
C3/0D56:    BD6E1A      LDA $1A6E,X    (load spell at X)
C3/0D59:    C9FF        CMP #$FF       (learned it?)
C3/0D5B:    F006        BEQ $0D63      (branch if so)
C3/0D5D:    E8          INX
C3/0D5E:    88          DEY
C3/0D5F:    D0F5        BNE $0D56      (branch if we haven't checked every spell)
C3/0D61:    18          CLC            (used by C3/0C6C, says that this character doesn't know magic)
C3/0D62:    60          RTS

I found all that code by doing a search for "1A6E" in bank C2 and C3, which is the starting offset of the magic list for character 00. I can't really help you more than this, as I am a bit unfamiliar with all that code.
  Find
Quote  

#8
Posts: 763
Threads: 83
Thanks Received: 55
Thanks Given: 7
Joined: Apr 2015
Reputation: 22
Status
Obliviscence
Thanks again, Mad. I should have thought of using that to help me search. Is FF3info the only doc we have to help with finding stuff? I am slowly accumulating more data as I find things relevant to my hacking hijinx, but I feel like I always have to ask. Any other tricks you use to find specific code? Also, why are you the only person who helps? Lol.

I will dive back into my coding tutorials tomorrow to see if I can't get this working. At least for saving magic I can just run the calc on the loaded actor number to find the list I want, might have to ditch the cursed shield to make it fit, or dish off the calc to another section of code... but it shouldn't be too hard.
  Find
Quote  

#9
Posts: 831
Threads: 41
Thanks Received: 16
Thanks Given: 12
Joined: Nov 2009
Reputation: 18
Status
None
(07-01-2012, 10:09 PM)Edrin Wrote: Is FF3info the only doc we have to help with finding stuff?
There are several documents to help you in your hacking needs, including the dis-assemblies by the guys at slickproductions. We usually search over the code at banks C1, C2 and C3 for our specific needs.

Links:
C1 Bank
C2 Bank
C3 Bank

(07-01-2012, 10:09 PM)Edrin Wrote: Any other tricks you use to find specific code?
When browsing the code, some of it is documented. Knowing what you're exactly looking for sometimes helps. For example, if you're looking into renaming magitek attacks, a quick search over the word "magitek" will yield some results.

(07-01-2012, 10:09 PM)Edrin Wrote: Also, why are you the only person who helps? Lol.
There are more of us around, with different skills and specialties. I specialize in creating custom events, in and out of battle; Nattak specializes in composing custom music; and Madsiur specializes in programming. I can help on programming to a certain extent, while Nattak can help on event editing to a certain extent as well. And there are many guys around that are able to create sprites.
Quote  

#10
Posts: 3,970
Threads: 279
Thanks Received: 236
Thanks Given: 58
Joined: Oct 2011
Reputation: 65
Status
Tissue-aware
(07-01-2012, 10:09 PM)Edrin Wrote: Also, why are you the only person who helps?

You could try also people at slick productions for assembly/coding help. They have some knowledgeable people in that department. There is also the Mnrogar Forum, but it is close to registration. I suggest you make searches in both forums for thing you don't know, sometime it can be quicker than asking here, and you could be surprise of what you could find as good infos. I'm the only one answering code related question because I am with Angelo, the only two that can understand ASM, and not even in totality.

(07-01-2012, 10:09 PM)Edrin Wrote: I will dive back into my coding tutorials tomorrow to see if I can't get this working. At least for saving magic I can just run the calc on the loaded actor number to find the list I want, might have to ditch the cursed shield to make it fit, or dish off the calc to another section of code... but it shouldn't be too hard.

A JSR instruction and putting your new code at the end of the bank where there is some free space could do the job. This way you could keep the cursed shield. You just have to end you block of code with a RTS instruction. Here's 2 good link about ASM instructions. One complement the other:

http://www14.brinkster.com/assassin17/thegun.htm
http://www.defence-force.org/computing/o.../annexe_2/
  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite