• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
April 19, 2024, 12:38:00 am

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


LastingDawn's ASM Hack(s)

Started by LastingDawn, February 10, 2016, 12:00:47 am

LastingDawn

February 10, 2016, 12:00:47 am Last Edit: February 10, 2016, 02:03:47 pm by LastingDawn
...And making the Diamond Armlet, if equipped, always supply the Rare Item. This is the code I have for it...

00180258: 34050064 ori r5,r0,0x0064             Load 100 into r5   
0018025c: 34040064 ori r4,r0,0x0064            Load 100 into r4
00180260: 9203001C lbu r3,0x001C(r16)         load Accessory
00180264: 10620004 beq r3,r2,0x00180278
00180268: 340200E0 ori r2,r0,0x00E0         branch if Accessory is Diamond Armlet (this doesn't seem to work for me for some reason)
0018026C: 0c017833 jal 0x0005e0cc         check if Random is greater/equal to Chance
00180270: 14400004 bne r2,r0,0x00180284         branch if Value is less than 75.
00180274: 3404004B ori r4,r0,0x004B
-------------------------------------------------------------
00180278: 92220002 lbu r2,0x0002(r17)         load rare item
0018027c: 080600a2 j 0x00180288
00180280: 00000000 nop

Here is the default routine...

http://ffhacktics.com/wiki/Rare/common_item_determination

Is there something I removed I shouldn't have or am I misunderstanding some basic of MIPS?

It was meant to be a simple change, I didn't expect to have this much trouble with it.
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!

Raijinili

You're using the delay slot as if it executes before the previous instruction.

If you do

ori r2,r0,0x0001
beq r2,r3,LABEL
ori r2,r0,0x0002

then r2 is 1 when checking the branch logic.

By the way:
- You don't need to load the 100s. You can load 75 (0x4B) directly.
- Function 0005e0cc takes two parameters, N and D, and returns False D/N of the time. Think of N as the number of sides and D as the difficulty of succeeding.
- Don't put a branch right after a jump (instructions 0018026C-00180270).

This should work (nine lines).
    lbu r3,0x001C(r16)           Load Accessory
    ori r2,r0,0x00E0             r2 = Diamond Armlet
    beq r3,r2,RARE               Branch if Accessory is Diamond Armlet
    ori r4,r0,0x0064             Load 100 into arg0
    jal 0x0005e0cc               r2 = (die100 >= 25)
    ori r5,r0,0x0019             Load 25 into arg1
    bne r2,r0,ENDIF              Branch if roll failed
    lbu r2,0x0003(r17)           load common item
RARE:
    lbu r2,0x0002(r17)           load rare item
ENDIF:


It uses the trick of setting a value in the delay slot, and then overwriting that value if you didn't branch.
  • Modding version: Other/Unknown

LastingDawn

That did the trick!...

For the most part. It seems that somehow the reason I was getting an Escutcheon was because it was reading it as the default common treasure and the rare treasure happened to be a Hidden Knife... This was not the actual items from those spots as you may have guessed.

I don't know where those items are put into... ?register 17? for quick access in the original formula.

00180264: 00408821 addu r17,r2,r0

Might this be the key to that?

I tried to put that at the start of the routine and leave the original common item portion alone, but still the same scenario played out. I didn't change anything but those aforementioned lines so now I am rather confused since all the registers used were those used in the original routine.

EDIT: Do the effects of your changes not actually show until a breakpoint has occurred? Because with the changed data, but without the save state it's acting as nothing has been changed, but only when it breaks and carries on through the custom routine do the effects of the routine show.
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!

Xifanie

Any reason why you just don't just do like everyone else and just set the 100 - Brave item the same as the Brave - 100 one? Do you have any plans for the first byte with it being freed?
  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

LastingDawn

February 10, 2016, 11:17:08 am #4 Last Edit: February 10, 2016, 03:15:07 pm by LastingDawn
Eh, I also wanted the Common Item to be a possibility and wanted to throw in some FFXII functionality (sort of, not really. The concept is the same anyhow)

I thought I had an instruction slot free at first, but I seem to be missing some specific component on how the game actually loads the Move-Find Item item (that's not an awkward phrase or anything).

Aside from that important element it looks to be working right thanks to Raijinili.

EDIT: It is done! Just need to test it outside of a savestate and it will be good to go.

What this hack does explicitly is allow the modder to choose one Accessory to guarantee getting the rare item from a Move-Find Item Panel. In addition it removes the Brave dependence and has a static percentage that is also planned to be set by the player.

By default the values are E0 for Diamond Armlet and 19 (25%) for getting the rare item from a Move-Find Item Panel.

NOTE: This is my first FFT ASM (mostly due to Raijinili's direction) so my syntax or some such may be off, however it patched cleanly for me into the game.


<Patch name="Move-Find Item Conditions becomes XX Accessory = 100% Rare Item. YY% Chance for Rare Item">
<Description>
Default Accessory for receiving the Rare Item from a Move-Find Item Panel 100% of the time is Diamond Armlet.
Default Percentage to receive a Rare Item without special accessory is 25%.
    </Description>
<Location file="BATTLE_BIN" offset="119258">
21884000
1C000392
</Location>
<Variable file="BATTLE_BIN" offset="119260" default="E0" name="XX"/>
   <Location file="BATTLE_BIN" offset="119261">
000234
04006210
64000434
3378010C
</Location>
<Variable file="BATTLE_BIN" offset="119270" default="19" name="YY"/>
   <Location file="BATTLE_BIN" offset="119271">
000534
03004014
02002292
A2000608

       </Location>
  </Patch>
"Moment's anger can revert to joy,
sadness can be turned to delight.
A nation destroyed cannot be restored,
the dead brought back to life."

Art of War

Beta & Gretchen Forever!!!!