Author Topic: Make sense work regardless of HP?  (Read 7964 times)

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Make sense work regardless of HP?
« on: 2012-08-17 09:58:17 »
Can this be achieved by simply taking out the part of it's function that displays HP? If I understand it right, the sense fail works that way because it can't accurately display values above FFFF aka 65535.
so it would just display MP and status stuff.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #1 on: 2012-08-17 13:57:59 »
That is a good question. And yeah I guess with a few tweaks it should be possible to FORCE it to always display.  The problem then is it will try to display a HP amount regardless.  I am thinking.  I guess even that could be sorted though.  But then all it will do is display MP and weaknesses.  You'd want it to do both depending on HP. 

I'd say it can be done.  But probably not without extra programming.

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: Make sense work regardless of HP?
« Reply #2 on: 2012-08-17 16:58:30 »
So how does the sense function actually work? How does it feed content into the battle message display buffer?

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #3 on: 2012-08-17 21:14:26 »
Just MP and status weaknesses is actually fine. Sense stops working on bosses for me right after Bottomswell because my overhaul is built around high values.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #4 on: 2012-08-17 21:19:28 »
So how does the sense function actually work? How does it feed content into the battle message display buffer?

I don't know.  It uses kernel2.bin for the text itself, but the values I don't know.  It will be simple to find out by tracing the stuff that happens from the HP check for sense. 


ff7.exe
001C9515=FF
001C9516=FF

Those 2 make the upper limit 65535 for sense.  Look around that area and it should be easy to trace.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #5 on: 2012-08-17 21:42:26 »
something has to point the sense function to those values
what if you change where it points to and how many addresses it points to? Is that even feasible? FFFFFFFF would be enough for just about anything short of hardcore mod super bosses.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Make sense work regardless of HP?
« Reply #6 on: 2012-08-18 02:45:19 »
Don't take this as absolute truth, but I think I looked into this once. IIRC, the text replacement in the string display will only take a maximum of a word value (if it's passed a numerical value). I could be wrong; it's been a long time since I looked at it.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #7 on: 2012-08-18 03:14:41 »
Forcing the function to ignore the HP check or removing the check and the HP display still sounds like it should be doable

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #8 on: 2012-08-18 03:43:56 »
I will have a quick look tomorrow.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #9 on: 2012-08-18 04:45:13 »
Ok to make it always appear, you just make the jb (jump if less or equal) into a jmp.  It will jump all the time.

The problem is any value over 65535 and it will display it wrong.  Once it gets to 65536 it resets to 0 and will do that all the time.  If you have 100,000 HP it is just going to come out with the wrong HP amount until the HP is actually less than 65536.

100,000 will display 100000-65536 =  34464

If you want to test this, change ff7.exe address 001c9519 to EB.  You can also increase the Sense limit if you want, it is currently set to allow 4 bytes (like the maximum enemy HP).
« Last Edit: 2012-08-18 05:23:47 by DLPB »

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #10 on: 2012-08-18 05:28:09 »
well, that's a good step in the right direction
I'll test this later

Bosola

  • Fire hazard!
  • *
  • Posts: 1752
    • View Profile
    • My YouTube Channel
Re: Make sense work regardless of HP?
« Reply #11 on: 2012-08-19 13:58:26 »
Don't take this as absolute truth, but I think I looked into this once. IIRC, the text replacement in the string display will only take a maximum of a word value (if it's passed a numerical value). I could be wrong; it's been a long time since I looked at it.


Do we know how do commands send text to the battle message marquee?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #12 on: 2012-08-20 16:34:55 »
well, that's a good step in the right direction
I'll test this later

Did it work okay?

I am looking at the feasibility of making sense display over 65535, but I am almost certain it will be beyond me without immense work.

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #13 on: 2012-08-20 16:44:15 »
I was absurdly busy so I completely forgot about this
I'll get back to you when I tested it

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #14 on: 2012-08-20 16:59:15 »
I give in trying to make it work over the limit.

00419a62
0041D0D5
00419A62

Those are important parts of how it places the data into the window.. but even if you know how to change it all it is probably more hassle than it is worth. 

At least you can now display the box even when enemy has more than limit.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: Make sense work regardless of HP?
« Reply #15 on: 2012-08-23 20:02:23 »

Do we know how do commands send text to the battle message marquee?

The text is stored at 0x009AD1E0 where I assume it is picked up for later use.

I give in trying to make it work over the limit.

00419a62
0041D0D5
00419A62

Those are important parts of how it places the data into the window.. but even if you know how to change it all it is probably more hassle than it is worth. 

At least you can now display the box even when enemy has more than limit.

You're off by a little bit. The trouble is in 0x0041D090, but the value gets limited further down starting at 0x0041D1B5. and 0x00419A62 is called by text code EB which displays the name of an item, not a number.

I agree with DLPB that it's more trouble than it's worth.
Here's the problem: While examining 0x009AD1E0 during a sense it stored the data like this:
Code: [Select]
ED 00 05            <Name of Actor in slot 5>
EF FF FF            <Letter (blank in this case)>
00                 <Space>
00                 <Space>
2C 45 56 45 4C 1A  "Level:"
EC 00 0E           <Number value 14>
00                 <Space>
FF                 <\n>
28 30 1A           "HP:"
EC 00 C8           <Value: 200>
0F                 "/"
EC 00 C8          <Value: 200>
So as you can probably see, the EC code in this context only takes a WORD value (probably signed or the limit might be 50000). This is the bottleneck of the issue. If this could be expanded to accommodate a DWORD then it would be possible to see HP values upward of 2 Bil.

When the text parser comes across EC the code at 0x00419BA5 is executed. All the text codes (EA - F1) take WORD valued arguments. If the handler for EC could be hooked (like via Aali's driver) then it could extend the value that EC is supplied in order to make it accept a DWORD value. Rewriting the exe is probably out of the question since it's going to require a lot of additional code to work right.

Comes down to five things (in order of complexity starting from most basic):

1. Extend the limit at 0x5CA10F. If you don't want to go through the hassle of the next few steps then you're limited to a 65535 HP cap. That's not so bad, but it doesn't really allow many more enemies to be sensed.
2. The scene.bin might need to be altered. Any String Display AI that might use this function. Occurs in 0% of vanilla-flavored scene.bin, but a custom one might have this.
3. The KERNEL.BIN or kernel2.bin would need to be changed to reflect this. Specifically, the Battle Text. There's only 11 places where this occurs.
4. 0x0041D090 would need to be rewritten to write DWORD values (again, with some kind of hook).
5. The handler for EC should be hooked (it's a jump, not a function call) and extended to allow for the extended text length.

There you go. Problem solved*. :D

*Untested

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: Make sense work regardless of HP?
« Reply #16 on: 2012-08-23 20:12:46 »
Excellent work!

The best way around this is to do what I will be doing, and just design your AI and enemies and character stats etc etc around a 65535 limit.

Breath of Fire III as I always reference on this, did perfectly with a 30000 limit.  The design is easier to change than the sense limit ;)

Tenko Kuugen

  • Public Enemy
  • *
  • Posts: 1416
    • View Profile
    • Twitter
Re: Make sense work regardless of HP?
« Reply #17 on: 2012-08-23 20:29:32 »
yeeeah, no. I'll just stick to "you can't sense bosses and north crater enemies" then. Not knowing elemental weaknesses adds difficulty, i guess? I'm not gonna re-do all of my stuff. Heh.

Thanks for the hard work guys, but this is really more trouble than its worth. Maybe the next crazy idea I have won't require another Ali.