Modding => Help! => Topic started by: Vanya on January 08, 2011, 04:28:10 am
Title: Another ASM question.
Post by: Vanya on January 08, 2011, 04:28:10 am
Is there a simple way (like one line of code) to make the [Weapon] in ability formulas load the correct weapon formula instead of the generic one that is automatically loaded? Or would this be a bigger hack that would require a table for the weapon formulas?
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 08, 2011, 06:06:29 am
No, because the weapon formulas are in a sub-sub-routine of the generic weapon formulas. The weapon number is simply stored as in unit RAM.
Now, what you can do is call the weapon type from unit RAM and then load that specific routine mentioned above, but you'd then skip charge calculations, Zodiac calculations, elemental calculations, and so on.
Title: Re: Another ASM question.
Post by: Vanya on January 10, 2011, 12:59:05 am
Quote...the weapon formulas are in a sub-sub-routine...
You mean it is part of a larger subroutine and isn't isolated on it's own?
Quote...call the weapon type from unit RAM...
Wait a minute. Can you actually load the weapon type directly? I didn't see that value in the formula hacking list on the wiki.
The routine that this bolded line goes to is the normal weapon damage routine used for weapons, right? Couldn't I just make it jump to free space where I can have it load the weapon type based on the equipped weapon and then pass that value to the "Physical Damage Calculation (Weapons)" routine as normal? This is assuming that the problem is that the weapon type value isn't being passed correctly.
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 10, 2011, 02:35:37 am
Vanya, that routine has 10 sub-routines. One of the first ones is the weapon check routine (that loads the non-WP XA stats for all the weapons). Each weapon's formula, then, is a sub-sub-routine under the routine you pointed out. You don't need to write it in manually because it's already there.
Title: Re: Another ASM question.
Post by: Vanya on January 10, 2011, 06:47:04 pm
Then why doesn't it work for abilities? What is going wrong with it? Or am I mistaken in my understanding that for formulas it defaults to the Knight Sword formula?
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 12, 2011, 04:22:30 am
Yeah, the formula is always defaulting to fists and here's why.
Physical Damage Calculation 00188638: 27bdffe8 addiu r29,r29,0xffe8 0018863c: afbf0010 sw r31,0x0010(r29) 00188640: 0c0616a7 jal 0x00185a9c Has a check if your attack is a weapon attack. If not, it defaults to zero, which is the fist formula. 00188644: 00000000 nop 00188648: 0c0617e0 jal 0x00185f80 0018864c: 00000000 nop 00188650: 0c0617e9 jal 0x00185fa4 00188654: 00000000 nop 00188658: 0c0621a9 jal 0x001886a4 0018865c: 00000000 nop 00188660: 0c061bf4 jal 0x00186fd0 00188664: 00000000 nop 00188668: 3c028019 lui r2,0x8019 0018866c: 8c422d90 lw r2,0x2d90(r2) 00188670: 00000000 nop 00188674: 90420000 lbu r2,0x0000(r2) 00188678: 00000000 nop 0018867c: 10400005 beq r2,r0,0x00188694 00188680: 34020001 ori r2,r0,0x0001 00188684: 0c061c3f jal 0x001870fc 00188688: 00000000 nop 0018868c: 0c062130 jal 0x001884c0 00188690: 00000000 nop 00188694: 8fbf0010 lw r31,0x0010(r29) 00188698: 27bd0018 addiu r29,r29,0x0018 0018869c: 03e00008 jr r31
EDIT: Here's an untested ASM hack to fix this. I may have messed up my registers since I wrote this at 4:30 AM, but it should work. Also, I don't exactly remember where my assigned ASM space is, but those niceties can be fixed later.
Title: Re: Another ASM question.
Post by: Celdia on January 12, 2011, 08:35:32 am
Just to pre-empt a bit here...where the hell would we put all this to test it?
Title: Re: Another ASM question.
Post by: Vanya on January 12, 2011, 01:55:47 pm
I believe those addresses are in Battle.bin if I'm not mistaken.
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 12, 2011, 04:13:10 pm
Thanks for pointing out the most obvious error: the first was a RAM offset, and the second was a ROM offset. This just goes to show why I shouldn't code so late in the evening.
The following will now all be written in RAM offsets, since all you have to do to test is to type this into your debugger.
EDIT: I just tested this. At the least, it shouldn't freeze your game and works for normal attacks. What needs to be tested now is: 1) Use 2 different weapons to attack 2) Equip 2 different weapons, but use a hacked Formula 01 spell. It should take the damage formula and WP of the RH weapon. 3) Equip a weapon and shield, but use a hacked Formula 01 spell. It should take the damage formula and WP of the weapon, regardless of which hand it's in or whether the unit has two swords or not.
Title: Re: Another ASM question.
Post by: Vanya on January 12, 2011, 05:08:47 pm
I hope this works because it'll open up the possibility for a bunch of new weapon based attacks that can cause status effects and not be limited to the weapon's normal range.
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 13, 2011, 03:01:30 am
There's actually a bug in the previous one. If you have only a weapon in your left hand, using Formula 01 would still default to fists. This should fix it.
Title: Re: Another ASM question.
Post by: Dokurider on January 13, 2011, 04:20:24 am
Okay so I tested this hack out last night
I patched Cure 1 to Formula 01 and brought three priests to battle, one that was two swording a 6 WP Staff and a 4 WP Staff, had 18 MA, other had just a shield on, had a brave of 75 and a PA of 14, and the last one had a 6 WP staff equipped on the left hand, 15 MA. They all did their normal damage. Patched Cure 1 did fist formula damage.
Title: Re: Another ASM question.
Post by: Vanya on January 13, 2011, 04:36:28 am
Did you try it out the bug-fixed one?
Title: Re: Another ASM question.
Post by: Pride on January 13, 2011, 04:58:47 am
Yes he did, fdc was instructing him in testing it out. Unless fdc was having him test the bugged one (unlikely).
Title: Re: Another ASM question.
Post by: Vanya on January 13, 2011, 02:09:18 pm
I only ask because Doku said "last night" and the bugfix version was only posted an hour before his report.
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 13, 2011, 03:53:33 pm
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 16, 2011, 03:46:28 am
Thanks to Celdia, we've found a bug.
This cannot be used with magic guns because dealt damage = displayed damage x 4 and that the infamous Zodiac glitch occurs with all guns. Fixing the Zodiac glitch is my next priority.
EDIT: No more Zodiac glitch for Weapon Formulas (Fixes 01, 02, 05, 06, 07):
0x185C8C in RAM (or 0x11EC8C in BATTLE.BIN) 1D 64 05 08
Excellent... it's about time someone hammered this one out!
Title: Re: Another ASM question.
Post by: Celdia on January 16, 2011, 10:13:26 am
I am either doing something wrong or I have to rescind my previous statement. This newest fix isn't working. Almost every skill is now showing 00% hit chance on everything or my best yet is 04% hit for 000 damage. One attempt at targeting a unit in combat simply crashed the emulator altogether. Going to try something else for the time being.
Edit: Okay. Went back and rechecked all my work, got things working normally then re-applied your hacks for this. When I tried to target someone with a skill using Formula 01 the game just crashed. I don't know if it will help any but it reads as "Opcode 3f UNK (PC 00159074) (7990,106)" under ePSXe.
Title: Re: Another ASM question.
Post by: formerdeathcorps on January 16, 2011, 04:14:55 pm
EDIT: After more checking, I realized I typed in the wrong ROM offset. It's fixed now, Celdia.