Author Topic: Learned spells not being added to list  (Read 10006 times)

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #15 on: September 09, 2008, 11:04:20 AM »
I believe it I got it working. I could have just adjusted the limits of which spells are added to which list, but the problem was that in my hack I don't have the spells grouped by kind, due to necessary out-of-battle effects. Instead, I think I came up with a rather elegant solution, better than the original one. I changed the coding so that the check now looks at the spell name: if it begins with a white magic sphere it will be added to the top list, if it begins with a gray magic sphere it will be added to the third list, and if it begins with anything else it will be added to the second list. (Coincidentally, this works for the magic in my hack and the original game, which was nice.) So, it should work for white, black, ninja, and call magic. I created three IPS patches (FF2 1.0, FF2 1.1, FF4), which I'll release on RHDN if someone can test them and verify that they work. As usual, they're all headered.

 :cookie: for me, for creativity and for remembering to create three patches this time  :happy:

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Learned spells not being added to list
« Reply #16 on: September 09, 2008, 11:08:25 AM »
Sounds good, but does that even account for spell animation?
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Learned spells not being added to list
« Reply #17 on: September 09, 2008, 11:19:57 AM »
Looks like it's working fine now, but you may wish to include a disassembly when you release it for anyone who needs to make changes. If I wanted to use this in my hack I'd have to check my magic names from the menu, rather than the place they were originally, I sacrificed icons on the battle names for longer names. Not to mention I moved the icons to the end of the font to free up more tiles for use in dialogue.

This was a really cool way to fix it, I wouldn't have thought to do this, and it should be fairly easy to expand if anyone wants to have more spell types that get added to one of the lists.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #18 on: September 09, 2008, 11:22:00 AM »
Quote
Sounds good, but does that even account for spell animation?

I'm not sure what you mean by spell animation. Do you mean the spell visual effects? Or its battle effects? Either way, the spell effects are unchanged no matter what the spell is named. It's up to the hacker to make sure the name begins with the right colored sphere to add to the correct list. This just gives people the ability to choose which lists spells go to, rather than have it be based on spell number.

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Learned spells not being added to list
« Reply #19 on: September 09, 2008, 11:24:30 AM »
Quote
Sounds good, but does that even account for spell animation?

I'm not sure what you mean by spell animation. Do you mean the spell visual effects? Or its battle effects? Either way, the spell effects are unchanged no matter what the spell is named. It's up to the hacker to make sure the name begins with the right colored sphere to add to the correct list. This just gives people the ability to choose which lists spells go to, rather than have it be based on spell number.

I'm talking about the animation one uses for White, Black, and Summon magic. If for some reason you have a White magic spell in the middle of the monster spell lists, the game will use the Black Magic animation by default.
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #20 on: September 09, 2008, 11:28:19 AM »
Looks like it's working fine now, but you may wish to include a disassembly when you release it for anyone who needs to make changes. If I wanted to use this in my hack I'd have to check my magic names from the menu, rather than the place they were originally, I sacrificed icons on the battle names for longer names. Not to mention I moved the icons to the end of the font to free up more tiles for use in dialogue.

I agree -- I was planning on adding the disassembly, since it's not quite contained within the original routine. I had to use some of the extra space at 1F420, which is OK for people who aren't adding routines, but for others (like me) they'll have to move that extra code around to another space. I'll do the write-up for it sometime today and post it to RHDN and here.

Per your situation: I had originally considered a table that looks up which spells should go in which list. I discarded that idea when I thought of my name-based idea, but for your hack that might be the way to go. It shouldn't be too hard to replace the call to the spell names with a call to a table. You can take a look at the routine later at see what you think.

I'm talking about the animation one uses for White, Black, and Summon magic. If for some reason you have a White magic spell in the middle of the monster spell lists, the game will use the Black Magic animation by default.

Yeah, you're right that that's off. That's coded separately, within the spell subroutine. I just ignored that part for my hack, but I'll take a look later and see if I can do the same thing there.

One thing that doesn't work out of the box: any of the spells after 48 (the monster spells) don't really work for normal spell usage because the name data gets out of sync. If somebody could adjust the spell names one way or the other (normal spells to 8 letters or monster spells to 6 letters) then it would be viable.

One more caveat I forgot to mention: you can't add two spells of different lists at the same level. For example, trying to learn Cure and Fire at level 2 will only add Cure. This limitation exists in the original game, and wasn't something I saw an easy work-around for.
« Last Edit: September 09, 2008, 11:37:58 AM by Phoenix »

Deathlike2

  • Moderator
  • *
  • Posts: 3,538
  • I'm looking at you, bitch!
    • View Profile
Re: Learned spells not being added to list
« Reply #21 on: September 09, 2008, 11:44:18 AM »
One more caveat I forgot to mention: you can't add two spells of different lists at the same level. For example, trying to learn Cure and Fire at level 2 will only add Cure. This limitation exists in the original game, and wasn't something I saw an easy work-around for.

I thought Rydia learned them at the same level.. but usually she gains 2 levels while at level 1 and I tend to forget which came first... oh well.

At least the game allows for learning 2 spells of the same list at the same level (Palom does this)...

As an aside, I've often wondered why Tellah and FuSoYa never gained any spells this way.. I guess that could be why. Rydia doesn't learn too many spells to exploit this either...
Working on the next Yet To Be Named FF4 "Hardtype" Hack Download Latest: v1.48

Video Demos: #1 #2 #3

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Learned spells not being added to list
« Reply #22 on: September 09, 2008, 11:55:17 AM »
One thing that doesn't work out of the box: any of the spells after 48 (the monster spells) don't really work for normal spell usage because the name data gets out of sync. If somebody could adjust the spell names one way or the other (normal spells to 8 letters or monster spells to 6 letters) then it would be viable.

Going with six character names for the enemy skills would be the best option, there's simply no room in the battle magic menu to have longer names than that without completely rearranging the thing. If you start the six character names right where the normal magic leaves off they'll be loaded in the menu fine, then you just need to change the code that prints the spell name in the window during usage:

Code: [Select]
$02/CB69 4C 95 CB    JMP $CB95  [$7E:CB95]   A:0040 X:0004 Y:6400 P:envMxdiZC
$02/CB95 AD C8 34    LDA $34C8  [$7E:34C8]   A:0040 X:0004 Y:6400 P:envMxdiZC
$02/CB98 D0 01       BNE $01    [$CB9B]      A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9B C9 48       CMP #$48                A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9D 90 25       BCC $25    [$CBC4]      A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9F 38          SEC                     A:0064 X:0004 Y:6400 P:envMxdizC
$02/CBA0 E9 48       SBC #$48                A:0064 X:0004 Y:6400 P:envMxdizC
$02/CBA2 85 26       STA $26    [$00:0026]   A:001C X:0004 Y:6400 P:envMxdizC
$02/CBA4 A9 08       LDA #$08                A:001C X:0004 Y:6400 P:envMxdizC
$02/CBA6 85 28       STA $28    [$00:0028]   A:0008 X:0004 Y:6400 P:envMxdizC
$02/CBA8 20 60 85    JSR $8560  [$02:8560]   A:0008 X:0004 Y:6400 P:envMxdizC

$02/CBAB A6 2A       LDX $2A    [$00:002A]   A:001C X:0004 Y:6400 P:envMxdizc
$02/CBAD 7B          TDC                     A:001C X:00E0 Y:6400 P:envMxdizc
$02/CBAE A8          TAY                     A:0000 X:00E0 Y:6400 P:envMxdiZc
$02/CBAF BF B0 8A 0F LDA $0F8AB0,x[$0F:8B90] A:0000 X:00E0 Y:0000 P:envMxdiZc
$02/CBB3 99 FD 74    STA $74FD,y[$7E:74FD]   A:0051 X:00E0 Y:0000 P:envMxdizc
$02/CBB6 C8          INY                     A:0051 X:00E0 Y:0000 P:envMxdizc
$02/CBB7 E8          INX                     A:0051 X:00E0 Y:0001 P:envMxdizc
$02/CBB8 C0 08 00    CPY #$0008              A:0051 X:00E1 Y:0001 P:envMxdizc
$02/CBBB D0 F2       BNE $F2    [$CBAF]      A:0051 X:00E1 Y:0001 P:eNvMxdizc
$02/CBBD 7B          TDC                     A:00FF X:00E8 Y:0008 P:envMxdiZC
$02/CBBE 99 FD 74    STA $74FD,y[$7E:7505]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/CBC1 4C A0 BC    JMP $BCA0  [$7E:BCA0]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA0 AD C0 6C    LDA $6CC0  [$7E:6CC0]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA3 F0 03       BEQ $03    [$BCA8]      A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA8 4C 60 93    JMP $9360  [$7E:9360]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/9360 20 CA 92    JSR $92CA  [$02:92CA]   A:0000 X:00E8 Y:0008 P:envMxdiZC

I'd just find some empty space large enough to contain the eight character list and change the offset it's looking at, but you could easy load the six character names here too.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #23 on: September 09, 2008, 12:01:12 PM »
I thought Rydia learned them at the same level.. but usually she gains 2 levels while at level 1 and I tend to forget which came first... oh well.

Yeah, I thought so too. At first I thought my hack had broken this behavior, but I went back and confirmed it in the original. Not a big deal really, since no characters really needs to learn spells that quickly, which is why I didn't pursue trying to fix it.

Quote from: Dragonsbrethren
Going with six character names for the enemy skills would be the best option, there's simply no room in the battle magic menu to have longer names than that without completely rearranging the thing. If you start the six character names right where the normal magic leaves off they'll be loaded in the menu fine, then you just need to change the code that prints the spell name in the window during usage:

I'm fine with the behavior as is, but I'll take a look at the code you posted later and see what to change. Or is the code you posted already changed?

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Learned spells not being added to list
« Reply #24 on: September 09, 2008, 12:04:18 PM »
I'm fine with the behavior as is, but I'll take a look at the code you posted later and see what to change. Or is the code you posted already changed?

No, that's just the unchanged routine.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #25 on: September 09, 2008, 11:43:57 PM »
I submitted the patches to RHDN. Here's the disassembly I posted for the readme:

Code: [Select]
2v1.0 2v1.1 4j Hex Data ASM Interpretation
----- ----- ----- -------- ------------------
1F334 1F349 1F34E BD 60 15 Load A with 1 byte at $7E:1560+X ; \
1F337 1F34C 1F351 D0 2D Branch to 1F366 if zero flag is clear ;  |
1F339 1F34E 1F353 B9 1C 29 Load A with 1 byte at $7E:291C+Y ;  | load A with the spell number
1F33C 1F351 1F356 85 B9 Store A to $00:D+$B9 ;  |
1F33E 1F353 1F358 C9 FF Compare A with #FF ;  |
1F340 1F355 1F35A F0 2D Branch to 1F36F if zero flag is set ; /
1F342 1F357 1F35C 20 20 F2 Jump to subroutine at 1F420 ; load A with first letter of spell name
1F345 1F35A 1F35F C9 40 Compare A with #40 ; if A isn't 40 (i.e. white magic),
1F347 1F35C 1F361 D0 06 Branch to 1F34F if zero flag is clear ;    branch to next check
1F349 1F35E 1F363 A5 B3 Load A with 1 byte at $00:D+$B3 ; else if A is 40 and the spell list isn't 0,
1F34B 1F360 1F365 D0 19 Branch to 1F366 if zero flag is clear ;    skip past adding the spell
1F34D 1F362 1F367 80 11 Branch to 1F360 ;    otherwise add the spell to the first list
1F34F 1F364 1F369 C9 41 Compare A with #41 ; if A isn't 41 (i.e. call magic),
1F351 1F366 1F36B D0 08 Branch to 1F35B if zero flag is clear ;    branch to next check
1F353 1F368 1F36D A5 B3 Load A with 1 byte at $00:D+$B3 ; else if A is 41
1F355 1F36A 1F36F C9 02 Compare A with #02 ; and the spell list isn't 2,
1F357 1F36C 1F371 D0 0D Branch to 1F366 if zero flag is clear ;    skip past adding the spell
1F359 1F36E 1F373 80 05 Branch to 1F360 ;    otherwise add the spell to the third list
1F35B 1F370 1F375 A5 B3 Load A with 1 byte at $00:D+$B3 ; if A is anything else
1F35D 1F372 1F377 3A Decrement A ; and the spell list isn't 1,
1F35E 1F373 1F378 D0 06 Branch to 1F366 if zero flag is clear ;    skip past adding the spell
1F360 1F375 1F37A A5 B9 Load A with 1 byte at $00:D+$B9 ; \
1F362 1F377 1F37C 9D 60 15 Store A to $7E:1560+X ;  |
1F365 1F37A 1F37F C8 Increment Y ;  |
1F366 1F37B 1F380 E8 Increment X ;  | otherwise, add the spell to the
1F367 1F37C 1F381 E6 B7 Increment 1 byte at $00:D+$B7 ;  | list and repeat if necessary
1F369 1F37E 1F383 A5 B7 Load A with 1 byte at $00:D+$B7 ;  |
1F36B 1F380 1F385 C9 18 Compare A with #18 ;  |
1F36D 1F382 1F387 D0 C5 Branch to 1F334 if zero flag is clear ; /
1F36F 1F384 1F389 60 Return from subroutine ; return


1F420 DA Push X (2 bytes) onto stack ; \
1F421 85 DF Store A to $00:D+$DF ;  |
1F423 A9 06 Load A with #06 ;  |
1F425 85 E1 Store A to $00:D+$E1 ;  | loads A with the first letter
1F427 20 E0 83 Jump to subroutine at 185E0 ;  | of the spell name (40 for
1F42A A6 E3 Load X with 2 bytes at $00:D+$E3 ;  | white magic, 41 for call magic)
1F42C BF 00 89 0F Load A with 1 byte at 78B00+X ;  |
1F430 FA Pull 2 bytes from stack and store in X ;  |
1F431 60 Return from subroutine ; /

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Learned spells not being added to list
« Reply #26 on: September 09, 2008, 11:49:36 PM »
Approved it, along with your edits. Thanks for the disassembly, if I decide to mix up the magic in my hack it looks like it'll be very easy to adapt it to my changes.

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Learned spells not being added to list
« Reply #27 on: September 10, 2008, 12:00:07 AM »
Glad to be of help.

Thanks for the code on enemy magic length. I think the only change needed is at 14D9C (headered v1.0), changing it to the first spell number you want to use with 8-letter spells. This will actually help out for my hack, because I was using the first 5 spells of the enemy magic and had to work around the name problem.

DarknessSavior

  • FF4 Hacker
  • *
  • Posts: 26
    • View Profile
Re: Learned spells not being added to list
« Reply #28 on: September 12, 2008, 10:19:05 AM »
One thing that doesn't work out of the box: any of the spells after 48 (the monster spells) don't really work for normal spell usage because the name data gets out of sync. If somebody could adjust the spell names one way or the other (normal spells to 8 letters or monster spells to 6 letters) then it would be viable.

Going with six character names for the enemy skills would be the best option, there's simply no room in the battle magic menu to have longer names than that without completely rearranging the thing. If you start the six character names right where the normal magic leaves off they'll be loaded in the menu fine, then you just need to change the code that prints the spell name in the window during usage:

Code: [Select]
$02/CB69 4C 95 CB    JMP $CB95  [$7E:CB95]   A:0040 X:0004 Y:6400 P:envMxdiZC
$02/CB95 AD C8 34    LDA $34C8  [$7E:34C8]   A:0040 X:0004 Y:6400 P:envMxdiZC
$02/CB98 D0 01       BNE $01    [$CB9B]      A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9B C9 48       CMP #$48                A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9D 90 25       BCC $25    [$CBC4]      A:0064 X:0004 Y:6400 P:envMxdizC
$02/CB9F 38          SEC                     A:0064 X:0004 Y:6400 P:envMxdizC
$02/CBA0 E9 48       SBC #$48                A:0064 X:0004 Y:6400 P:envMxdizC
$02/CBA2 85 26       STA $26    [$00:0026]   A:001C X:0004 Y:6400 P:envMxdizC
$02/CBA4 A9 08       LDA #$08                A:001C X:0004 Y:6400 P:envMxdizC
$02/CBA6 85 28       STA $28    [$00:0028]   A:0008 X:0004 Y:6400 P:envMxdizC
$02/CBA8 20 60 85    JSR $8560  [$02:8560]   A:0008 X:0004 Y:6400 P:envMxdizC

$02/CBAB A6 2A       LDX $2A    [$00:002A]   A:001C X:0004 Y:6400 P:envMxdizc
$02/CBAD 7B          TDC                     A:001C X:00E0 Y:6400 P:envMxdizc
$02/CBAE A8          TAY                     A:0000 X:00E0 Y:6400 P:envMxdiZc
$02/CBAF BF B0 8A 0F LDA $0F8AB0,x[$0F:8B90] A:0000 X:00E0 Y:0000 P:envMxdiZc
$02/CBB3 99 FD 74    STA $74FD,y[$7E:74FD]   A:0051 X:00E0 Y:0000 P:envMxdizc
$02/CBB6 C8          INY                     A:0051 X:00E0 Y:0000 P:envMxdizc
$02/CBB7 E8          INX                     A:0051 X:00E0 Y:0001 P:envMxdizc
$02/CBB8 C0 08 00    CPY #$0008              A:0051 X:00E1 Y:0001 P:envMxdizc
$02/CBBB D0 F2       BNE $F2    [$CBAF]      A:0051 X:00E1 Y:0001 P:eNvMxdizc
$02/CBBD 7B          TDC                     A:00FF X:00E8 Y:0008 P:envMxdiZC
$02/CBBE 99 FD 74    STA $74FD,y[$7E:7505]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/CBC1 4C A0 BC    JMP $BCA0  [$7E:BCA0]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA0 AD C0 6C    LDA $6CC0  [$7E:6CC0]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA3 F0 03       BEQ $03    [$BCA8]      A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/BCA8 4C 60 93    JMP $9360  [$7E:9360]   A:0000 X:00E8 Y:0008 P:envMxdiZC
$02/9360 20 CA 92    JSR $92CA  [$02:92CA]   A:0000 X:00E8 Y:0008 P:envMxdiZC

I'd just find some empty space large enough to contain the eight character list and change the offset it's looking at, but you could easy load the six character names here too.

*buzzer*

I've got eight character spells (that includes the magic-type icon), and I didn't rearrange a thing:



All you have to do is change the fixed length load from $06 to $08, move the list to some empty space in the ROM, and change the assembly to reflect those changes.

~DS

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Learned spells not being added to list
« Reply #29 on: September 12, 2008, 04:14:45 PM »
Going with six character names for the enemy skills would be the best option, there's simply no room in the battle magic menu to have longer names than that without completely rearranging the thing.