øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.msg19854e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index58c5.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=1883.150e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index58c5.html.zx•g^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈÐ#kOKtext/htmlISO-8859-1gzip8:Ö#kÿÿÿÿÿÿÿÿTue, 10 Mar 2020 05:11:08 GMT0ó°° ®0®P®€§²ð®”g^ÿÿÿÿÿÿÿÿš/#k Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)

Author Topic: Grimoire LD's Notes, Patches, and Hacks (Dark Knight/Paladin Swap In Battle!)  (Read 78658 times)

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #150 on: December 24, 2013, 03:21:55 PM »
From an editing standpoint, I find the initial races to be rather silly and underused. I once did a count and roughly 60% of the enemies in the game (not counting bosses) have a race and those that do are few and far between, here's some info. I wrote up about it a while back...

19 Reptile (+0 Bosses)
14 Mage (+4 Bosses)
13 Zombie (+2 Bosses)
6 Slime (+0 Bosses)
5 Spirit (+0 Bosses)
13 Dragon (+1 Bosses)
8 Giant (+0 Bosses)
9 Robots (+2 Robots)

61 Bosses (give or take the Dummy's)

161 Enemies

20/160 = 1/8
15/160 = 1/11
15/160 = 1/11
06/160 = 1/27
05/160 = 1/27
15/160 = 1/11
08/160 = 1/20
09/160 = 1/19

87/160 Enemies have a Creature Type, and they most comprise a pathetic amount of enemies. I think Races need an overhaul all around or more foes need to be labeled as one of the existing races. And this is where races.dat would come in handy indeed.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #151 on: December 27, 2013, 12:05:41 AM »
So I was finally getting around to looking at Aura, and I have a question - do you want the effect to vary based on the target's wisdom, or based on the caster's wisdom? I think the code you wrote uses the target's, but in the normal context of FFIV, it seems to me it might make more sense based on the caster's. Not a big deal, it's a difference of one byte, but I just thought I'd ask.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #152 on: December 27, 2013, 12:59:58 AM »
Uh... wow, how did I write that whole thing and not even realize how Silly that seems? Yes it's supposed be Caster's Wisdom, not Target's Wisdom, haha! Good catch.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #153 on: December 27, 2013, 12:13:20 PM »
Ok, here's my version of Aura:
Code: [Select]
$03/D8B0 AD 97 26    LDA $2697  [$7E:2697]   ;Load caster's Wisdom into A
$03/D8B3 A2 00 00    LDX #$0000              ;Load 0000 into X
$03/D8B6 C9 50       CMP #$50                ;Compare caster's Wisdom with 50(H), or 80(Dec)
$03/D8B8 90 02       BCC $02    [$D8BC]      ;If it is less, skip the next op
$03/D8BA A9 50       LDA #$50                ;If it is 50 or more, load 50 into A
$03/D8BC C9 14       CMP #$14                ;Compare caster's Wisdom with 14(H), or 20(Dec)
$03/D8BE 90 06       BCC $06    [$D8C6]      ;If it is less, skip ahead to 03/D8C6
$03/D8C0 E8          INX                     ;Increase X by 1
$03/D8C1 38          SEC                     
$03/D8C2 E9 0A       SBC #$0A                ;Subtract 0A, or 10(Dec), from A
$03/D8C4 80 F6       BRA $F6    [$D8BC]      ;Loop back up to 03/D8BC
$03/D8C6 A9 01       LDA #$01                ;load 01 into A
$03/D8C8 E0 00 00    CPX #$0000              ;Compare X with 0000
$03/D8CB F0 05       BEQ $05    [$D8D2]      ;if X is 0000 (first time around, this means caster's wisdom is less than 20), then skip ahead to 03/D8D2
$03/D8CD CA          DEX                     ;Decrease X by 1
$03/D8CE 0A          ASL A                   ;Multiply A by 2, or more appropriately here, shift the bits in A one spot to the left
$03/D8CF 1A          INC A                   ;increase A by 1, or more appropriately here, set A's bit 0 to 1
$03/D8D0 80 F6       BRA $F6    [$D8C8]      ;Loop back up to 03/D8C8
$03/D8D2 0D 1A 27    ORA $271A  [$7E:271A]   ;OR A with Target's "strong against" byte
$03/D8D5 8D 1A 27    STA $271A  [$7E:271A]   ;Store A in target's "strong against" byte
$03/D8D8 60          RTS
It's shorter by 14 bytes.
Also, I used an OR to ensure any current "strong against" data won't be wiped out by the spell. That is, if the target character is already strong against machines, and the caster's Wisdom is only 30, the target will end up strong against Undead, Mages, Slimes and Machines.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #154 on: December 27, 2013, 01:21:42 PM »
This seems pretty good! I especially like the looping matters. My only concern towards this is...

How is it starting in reverse? The Natural Order of Monsters goes... Dragon, Robot, Reptile, Spirit, Giant, Slime, Mage, Zombie...

The way your script seems to work would be to go (Less than 20 Wisdom) Dragon, and the A would be multiplied until at 80 Wisdom Undead is added...

Now, what if this is done instead...?


Code: [Select]
$03/D8C6 A9 80       [b]LDA #$80               ;load 80 into A[/b]
$03/D8C8 E0 00 00    CPX #$0000              ;Compare X with 0000
$03/D8CB F0 05       BEQ $05    [$D8D2]      ;if X is 0000 (first time around, this means caster's wisdom is less than 20), then skip ahead to 03/D8D2
$03/D8CD CA          DEX                     ;Decrease X by 1
$03/D8CE 4A         [b] LSR A                   ;Divide A by 2, or more appropriately here, shift the bits in A one spot to the right[/b]
$03/D8CF 1A          INC A                   ;increase A by 1, or more appropriately here, set A's bit 0 to 1 [b](Not sure what to do with this one in this arrangement)[/b]
$03/D8D0 80 F6       BRA $F6    [$D8C8]      ;Loop back up to 03/D8C8
$03/D8D2 0D 1A 27    ORA $271A  [$7E:271A]   ;OR A with Target's "strong against" byte
$03/D8D5 8D 1A 27    STA $271A  [$7E:271A]   ;Store A in target's "strong against" byte
$03/D8D8 60          RTS

Since the original code you have set up seems to go with the normal order 01 to 80 rather than 80 to 01.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #155 on: December 27, 2013, 02:25:39 PM »
I didn't check the actual effect on live monsters, but the bab-il docs say bit 0 (00000001)=undead and bit 7 (10000000)=dragon, so that's what I wrote. Is creature type actually reversed?

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #156 on: December 27, 2013, 02:35:06 PM »
Indeed, 80 is Undead because its used in a bunch of "If Undead..." checks and it doesn't use CMP 80 but BMI or BPL
.

I think at times Yousei may have been mixing himself up. In one document he has...

bit 0 fire
bit 1 ice
bit 2 lightning
bit 3 darkness
bit 4 sacred
bit 5 spears/arrows
bit 6 drain
bit 7 (for armors) immunity to elements for which the bits are set, otherwise
    unknown

And in another he has...

bit 0: immune to elements
        bit 1: absorbs elements
        bit 2: resists elements
        bit 3: sacred
        bit 4: darkness
        bit 5: lightning
        bit 6: ice
        bit 7: fire

When from a technical standpoint we should know that they are reversed.

80 is Undead, 40 is Mage, etc.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #157 on: December 27, 2013, 03:42:33 PM »
Hmm... then you'd have to LSR A, then ORA #$80 (that'd be the most economical route). It would be an extra byte long, so would affect the operand of a couple of branches, too. I'm doing this on my phone right now. Will update the code when I get home.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #158 on: December 27, 2013, 04:58:55 PM »
Sounds good. Thanks for taking a look at this for me as well. The last thing I want to present is unnecessarily long code.

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #159 on: December 27, 2013, 06:00:03 PM »
The last thing I want to present is unnecessarily long code.
What? You mean you don't want to be like the FFIV developers?
Thanks for taking a look at this for me as well.
Assuming this is not tongue-in-cheek (since you didn't ask, I just kinda butted in), no problem. This kinda stuff is fun for me compared to where I am in my little preview project - writing in character palettes using SNESPal. Ugh!

So here's the updated code. I tested it and it works, though as before, I did not test the resultant character's attacks on the pertinent monsters.
Code: [Select]
$03/D8B0 AD 97 26 LDA $2697  [$7E:2697] ;Load caster's Wisdom into A
$03/D8B3 A2 00 00 LDX #$0000 ;Load 0000 into X
$03/D8B6 C9 50 CMP #$50 ;Compare caster's Wisdom with 50(H), or 80(Dec)
$03/D8B8 90 02 BCC $02    [$D8BC] ;If it is less, skip the next op
$03/D8BA A9 50 LDA #$50 ;If it is 50 or more, load 50 into A
$03/D8BC C9 14 CMP #$14 ;Compare caster's Wisdom with 14(H), or 20(Dec)
$03/D8BE 90 06 BCC $06    [$D8C6] ;If it is less, skip ahead to 03/D8C6
$03/D8C0 E8 INX ;Increase X by 1
$03/D8C1 38 SEC                     
$03/D8C2 E9 0A SBC #$0A ;Subtract 0A, or 10(Dec), from A
$03/D8C4 80 F6 BRA $F6    [$D8BC] ;Loop back up to 03/D8BC
$03/D8C6 A9 80 LDA #$80 ;load 01 into A
$03/D8C8 E0 00 00 CPX #$0000 ;Compare X with 0000
$03/D8CB F0 06 BEQ $06    [$D8D3] ;if X is 0000 (first time around, this means caster's wisdom is less than 20), then skip ahead to 03/D8D3
$03/D8CD CA DEX ;Decrease X by 1
$03/D8CE 4A LSR A ;Divide A by 2, or more appropriately here, shift the bits in A one spot to the right
$03/D8CF 09 80 ORA #$80 ;OR A with 80, or more appropriately here, set A's bit 7 to 1
$03/D8D1 80 F5 BRA $F5    [$D8C8] ;Loop back up to 03/D8C8
$03/D8D3 0D 1A 27 ORA $271A  [$7E:271A] ;OR A with Target's "strong against" byte
$03/D8D6 8D 1A 27 STA $271A  [$7E:271A] ;Store A in target's "strong against" byte
$03/D8D9 60 RTS

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #160 on: December 27, 2013, 06:39:12 PM »
Not tongue-in-cheek at all. As you pointed out above I don't Want to be like the original developers, hehe (speaking of such there is probably a lot of CMP/BEQ combo's in the code that could be covered with a simple TSB, but I've never seen FFIV use a TSB command anywhere despite it appearing the most efficient way to check if a byte reads a specific value.

I'll test this out and tell you how it goes.

Oy, image editing in this game so far has been atrocious for me, outside of your Summon Tutorial I can't really grasp it, nor even figure out how to load the proper palettes in TileMolester if I ever wanted to change a character's sprite. So best of luck with what you're up to. The lack of a decent image editor is one of the things keeping back my hacks.


Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #161 on: December 27, 2013, 06:57:31 PM »
I see... I think you made the same mistake I had.

With less than 20 Wisdom it works flawlessly 80 is added to the value and that is it, but when more than 20...

Code: [Select]
$03/D8B0 AD 97 26 LDA $2697  [$7E:2697] A:0003 X:0020 Y:0000 P:envMxdizc
$03/D8B3 A2 00 00 LDX #$0000 A:0022 X:0020 Y:0000 P:envMxdizc
$03/D8B6 C9 50 CMP #$50 A:0022 X:0000 Y:0000 P:envMxdiZc
$03/D8B8 90 02 BCC $02    [$D8BC] A:0022 X:0000 Y:0000 P:eNvMxdizc
$03/D8BC C9 14 CMP #$14 A:0022 X:0000 Y:0000 P:eNvMxdizc
$03/D8BE 90 06 BCC $06    [$D8C6] A:0022 X:0000 Y:0000 P:envMxdizC
$03/D8C0 E8 INX A:0022 X:0000 Y:0000 P:envMxdizC
$03/D8C1 38 SEC A:0022 X:0001 Y:0000 P:envMxdizC
$03/D8C2 39 0A 80 AND $800A,y[$7E:800A] A:0022 X:0001 Y:0000 P:envMxdizC
$03/D8C5 F6 A9 INC $A9,x  [$00:00AA] A:0000 X:0001 Y:0000 P:envMxdiZC
$03/D8C7 80 E0 BRA $E0    [$D8A9] A:0000 X:0001 Y:0000 P:envMxdizC
$03/D8A9 02 A9 COP #$A9 A:0000 X:0001 Y:0000 P:envMxdizC
$00/FFFF FF 0A 2F 0A SBC $0A2F0A,x[$0A:2F0B] A:0000 X:0001 Y:0000 P:envMxdIzC
$00/0003 80 F2 BRA $F2    [$FFF7] A:00F6 X:0001 Y:0000 P:eNvMxdIzc
$00/FFF7 FF FF FF FF SBC $FFFFFF,x[$FF:0000] A:00F6 X:0001 Y:0000 P:eNvMxdIzc
$00/FFFB FF 00 80 FF SBC $FF8000,x[$FF:8001] A:00EB X:0001 Y:0000 P:eNvMxdIzC
(And so on and so forth in garbage code...)

Your Set Carry Flag is not adequate to change it to read one byte, it will continue to read two bytes. The way I found to get around this is to use..

$03/D8B1   E2 10   SEP #$10   A:0003   X:0020   Y:0000   P:envMxdizc - Set Processor to 8 bit (so X only reads one byte instead of 2)

Then when it is near the end of the script reset it with...

$03/D8E5   C2 10   REP #$10   A:0000   X:0080   Y:0000   P:envMXdiZc - Reset Processor Status from 8-Bit

Unless there is a much simpler way to go about it that I don't know of.

 :edit: Though if this screwed up for me, why did it show up fine for you? You're pulling the raw code from the same place I was I presume, Geiger's emulator.
« Last Edit: December 27, 2013, 07:30:09 PM by Grimoire LD »

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #162 on: December 27, 2013, 07:42:23 PM »
You left out the LDA #$50 at 03/D8BA. I think that might be screwing everything else up.
This code doesn't need to worry about 16/32-bit processor status. It uses the default statuses (stati?) for A (16) and X (32).

 :edit: there's more wrong there. Try recopying the whole code, I think.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #163 on: December 27, 2013, 07:49:42 PM »
Hmm, but as per the code if it reads More than 20 but less than 80 it automatically skips that...


Code: [Select]
$03/D8B0 AD 97 26 LDA $2697  [$7E:2697] A:0003 X:0020 Y:0000 P:envMxdizc
$03/D8B3 A2 00 00 LDX #$0000 A:0022 X:0020 Y:0000 P:envMxdizc
$03/D8B6 C9 50 CMP #$50 A:0022 X:0000 Y:0000 P:envMxdiZc
$03/D8B8 90 02 BCC $02    [$D8BC] A:0022 X:0000 Y:0000 P:eNvMxdizc (Compares it, finds it isn't valid and moves on.
$03/D8BC C9 14 CMP #$14 A:0022 X:0000 Y:0000 P:eNvMxdizc

Oh! I see! Gah! How careless of me... I confused E9 for 39! I blame it on my slight dyslexia.

The copied code ingame does have A950 where it should be.

And there we go... it's working as intended. Eh heh. Sorry about that Chillyfeez, I'm not sure why my mind jumped to the SEC being the culprit.

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: Grimoire LD's Notes, Methods, and Hacks (FFI spell routines in FFIV!)
« Reply #164 on: December 27, 2013, 11:56:15 PM »
From Dragoon-ZERO's Long Range Fix patch, he was helpful enough to include what he changed and what was Originally there in ROM! (Commented for readability)

Code: [Select]
$03/9D90 AD 77 39    LDA $3977  [$7E:3977]   A:001E X:0000 Y:002E P:envMxdIzc - (???)
$03/9D93 29 20       AND #$20                A:0080 X:0000 Y:002E P:eNvMxdIzc - Is it 20? (???)
$03/9D95 D0 07       BNE $07    [$9D9E]      A:0000 X:0000 Y:002E P:envMxdIZc - If not 00 branch to 039D9E.
$03/9D97 AD 9C 28    LDA $289C  [$7E:289C]   A:0000 X:0000 Y:002E P:envMxdIZc - Load (???)
$03/9D9A 29 20       AND #$20                A:00FF X:0000 Y:002E P:eNvMxdIzc - Is it 20?? (???)
$03/9D9C F0 09       BEQ $09    [$9DA7]      A:0020 X:0000 Y:002E P:envMxdIzc - Branch if 00 to 039DA7.
$03/9D9E A0 01 00    LDY #$0001              A:0020 X:0000 Y:002E P:envMxdIzc - Load 0001 into Y.
$03/9DA1 B1 80       LDA ($80),y[$7E:2001]   A:0020 X:0000 Y:0001 P:envMxdIzc - Load A from 7E2000 (+1)  Row/Character ID.
$03/9DA3 09 20       ORA #$20                A:0000 X:0000 Y:0001 P:envMxdIZc - Add 20 if applicable.
$03/9DA5 91 80       STA ($80),y[$7E:2001]   A:0020 X:0000 Y:0001 P:envMxdIzc - Store A in 7E2001.
$03/9DA7 60          RTS                     A:0020 X:0000 Y:0001 P:envMxdIzc - Return.


(Custom Code by Dragoon ZERO)
A0 01 00    LDY #$0001 - Load 1 into Y.
B1 80       LDA ($80),y - Load A from 7E2001.
29 DF       AND #$DF - Add DF (-20) if Applicable.
91 80       STA ($80),y - Store A in 7E2001.
AD 9C 28    LDA $289C - Load (???)
29 20       AND #$20 - Is it 20?
F0 06       BEQ $06 - If so branch.
B1 80       LDA ($80),y - Load 7E2001 into A.
09 20       ORA #$20 - Add 20 into A if applicable.
91 80       STA ($80),y - Store A in 7E2001.
60          RTS - Return

Now that is a fantastic piece of work there!  And that is a place of much interest and if the information for that weapon bit is there, who is to say if the data for the other weapon bits maybe closeby?