Author Topic: "Open Item Window Searching for XX"  (Read 749 times)

chillyfeez

  • FF4 Hacker
  • *
  • Posts: 1,285
  • Gender: Male
  • Go ahead, ask me about Angel Feathers!
    • View Profile
"Open Item Window Searching for XX"
« on: March 09, 2016, 09:00:08 PM »
Little discovery here.
I was trying to fix the little (sort of) oddity in TfW whereby the entire stock of Job Cards would be wiped out when using one.
Well, this was happening because I was using the "remove item from inventory" instruction, which removes all of one inventory instance of an item (so if you have 2 x 99 of item XX, you will lose 99 of them). The thing is, I was using that because I thought I had to, because otherwise the item wouldn't go away at all.
But here's the catch - in TfW, the Job Card replaces the Troia Pass. Turns out, there's a special case exception in the "Open Item Window Searching for XX" event instruction routine that skips over the part of the routine that reduces the inventory by one. You therefore get to keep your Troia pass for repeated use. It's also entirely possible to change which item has the special case exception, so maybe you want to keep the Legend sword instead, or (yay, cheating!) keep your Pink Tail. All you have to change is one byte.
In ROM without header:
00/6B3E    C9 EC   CMP #$EC; compare A to EC (Pass)
Just change that EC to the item # of whichever Item you want to keep upon use.

But wait - there's more!
Turns out we never really needed that single special case instruction for item EC at all, because a few opcodes later, we have this:
00/6B46   C9 ED  CMP #$ED; Compare A to ED (the next item after the Pass, whatever it is)
00/6B48   B0 18  BCS $18; If it is that or higher, skip the -1 portion if the routine

So all we have to do is change that ED to EC, and then that part of the routine includes the Pass, and we can comfortably change the routine to make an exception for a different item without losing the Pass.
Or, in my case, I can wedge in a subroutine jump where that Pass exception was!
 :shadow:

Grimoire LD

  • FF4 Hacker
  • *
  • Posts: 1,684
    • View Profile
Re: "Open Item Window Searching for XX"
« Reply #1 on: March 10, 2016, 10:51:01 AM »
The "GET RID OF ALL" part of remove item from inventory always bothered me, when I was working on Combat Boost I had to tackle that problem when I was dealing with the Blacksmith. I think I found the same information you did, if not a variant of it.

Bahamut ZERO

  • Cagnazzo
  • *
  • Posts: 347
  • Gender: Male
  • If ye're takin a beatin, hop in de back row!
    • View Profile
Re: "Open Item Window Searching for XX"
« Reply #2 on: June 02, 2016, 05:24:25 PM »
...Huh. This is very interesting.

Up til now, I always assumed that any Key Item would need the "remove item" command to actually remove it from the inventory. But then again, that was from me looking at events and always seeing that command being used right after  an "look for item" command.

Makes me wonder... if the Troia pass can only be removed from the inventory through that command, would it stay in the inventory if it were also a usable item, such as the Whistle, and used from the normal item screen? I'm gonna play around and find out if that's (hopefully) the case, since the pass in my project is a lump of gold that's a rare drop from monsters and doesn't necessarily need that special exception anyway. :D

EDIT: I've debunked my own wonderings - a usable Tool item such as the whistle is still removed when used normally via the item screen. Was worth a try though!
« Last Edit: June 02, 2016, 05:36:25 PM by Bahamut ZERO »
I update my graphics thread on almost a daily basis, so keep an eye out for new stuff!