Author Topic: FF7 Field Messages  (Read 5347 times)

Wutai Clan

  • *
  • Posts: 115
    • View Profile
FF7 Field Messages
« on: 2011-04-18 20:35:44 »
I've located a function for displaying messages in game, the problem is, it seems to use some lookup table for getting the text to display.

The function takes two numeric(?) values(WORD), it appears to be based on location, and index(within a text file), can anyone shed some light on where this data is coming from?

Example:

Value1: 0 (Kalm Outdoors ?)
Value2: 34 (Index?)

"Maybe a little too convenient."

---

I need to understand how the "file" or whatever works, so I can open my own windows, and make them work properly.

I'm guessing, the file(or whatever), must have some sort of positional data for the window, but, it could be figuring out where to display the message dynamically, based on character location, message length, etc,.

Anything you can tell me about this, will help me get a custom message system setup.

---

Btw, I've tested this, and i can open a message window, however, I can't populate it with text, so this info will definitely help.
« Last Edit: 2011-04-19 00:31:51 by Wutai Clan »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: FF7 Field Messages
« Reply #1 on: 2011-04-24 08:09:18 »
Hi,

The 0x40 (MESSAGE) Opcode (info here) displays a message Y (in your case 34) in window X (in your case - 0). Window is created with 0x50 (WINDOW) Opcode (info here).

The messages are held in script file (info here) - more precisely, in it's dialog subsection. Each script file corresponds to one location in game (in your example it's elmtow - Kalm "town"). Every time a location changes, new script file is loaded into memory and provides a look-up table for the messages - so all you have to do is to request a dialog with specific ID and point to a (previously created) window and it will show-up. As simple as that.

To create custom messages on-the-fly (without modifying field.lgp), you can:
 - Possess an unused Message-Id and use it to feed any text data to a requested window (all you have to do is to redirect one ID in the look-up function to a memory address of your choice).
 - Copy the 0x40 function and only patch the lookup call (so it actually returns your pointer) - you'll have your own function, independant of the original one.
 - Make a distinction on the higher byte of Window-Id or Message-Id. Game only uses 8 lower bits, but it's still pushing to stack 16-bit or even 32-bit values (years have passed since I looked at it, but it's 32-bit executable, so we can safely assume that pushing 8-bit values to stack is not actually a case here). So, use a standard 0x40 function, but feed it with values like 0x102 as Message-Id - patch the lookup function to make a distinction between 0x00-0xFF Messages and 0x100-0xFFFF Messages - in the first case, work as always - in the second case, return a Message from YOUR lookup table.

dziugo

Aali

  • *
  • Posts: 1196
    • View Profile
Re: FF7 Field Messages
« Reply #2 on: 2011-04-24 10:39:20 »
Completely offtopic:
dziugo, you're still around :o
I thought we had lost you completely, are you doing any work on FF7 these days?

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: FF7 Field Messages
« Reply #3 on: 2011-04-24 10:48:27 »
Hi Aali :)

I've been checking these boards from time to time, mostly unlogged, just to see what's going on (btw. gratz on your Graphics driver ;)), but never actually felt the urge to post anything back. Now that the FF7 VoiceOverProject has been revived (again), I'm back, just to show that I'm on (the) board.

No time to do anything new, though... Wish I had... Saw few interesting ideas that could easily be done, but... No time for new things...

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: FF7 Field Messages
« Reply #4 on: 2011-04-25 18:22:15 »
Thanks dziugo, I'll have to go over that data, sounds like it will do exactly what I want. :)

If I can get custom messages, and even better, custom option windows(like, when the game gives you a choice.), I should be able to make new in-game configs for a lot of the stuff I'm creating. (Though, it really depends on how far I can push the system, regardless, custom messages, are cool enough.)

Anyways, thanks again, and sorry about the delayed response, I got busy with other stuff, decoding, trying to learn some new hooking techniques, etc, so I just hadn't checked this post for awhile.
« Last Edit: 2011-04-25 18:29:12 by Wutai Clan »

dziugo

  • *
  • Posts: 1470
    • View Profile
    • A new copy of FF7 thanks to Salk. Pack (zip/rar/etc) your saved game before sending it to me.
Re: FF7 Field Messages
« Reply #5 on: 2011-04-25 19:26:30 »
No biggie ;) It's your time, and I was out anyways ;)

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: FF7 Field Messages
« Reply #6 on: 2011-04-25 21:13:07 »
No biggie ;) It's your time, and I was out anyways ;)

:)

Anyways, having some trouble decoding the message system.

This function opens a blank window, it takes two args, one controls whether the window is on top\bottom of the screen, the other seems to effect size, but only to an extent. ?

Open Window = 00631586

This one can close the window, it takes one arg, that represents a window position, top\bottom, so if you open a top window, you call this with a matching arg to close a top window.

Close Window = 00632EB8

I've found the text scroll value, it represents the current carret position of scroll text.. (Or the current index of the letter in the string it's printing, however you want to see it.)

Text Scroll = 00CFF5CA

But, I can't seem to find where it's storing the text.. What I want to do, is just open a window, and directly feed a string into the variable that normally get's populated with text. (This would bypass a lot of issues, though, I still need to load it into the window system, so it responds to key presses, right now the opened windows are unresponsive, and I have to force them closed.)

There are like 10(so far, may be more) functions in the .exe dealing with dialog, so I'm trying to decode them, but it's going slow.
« Last Edit: 2011-04-25 21:15:24 by Wutai Clan »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: FF7 Field Messages
« Reply #7 on: 2011-04-26 05:13:22 »
Ones we found:

006F5AD4 < spacing of dialogue  (there are 2 of these, 1 is lower down.  Identical value.  You need to change both. for that)

006EC28B < X of first line.

00630ceb  < sets the dialogue line height

006318e5 < sets the window height.

006EC285 < Y of all lines

00632cb3 < works out how many lines there should be  from box height.

00630ea6, 00631b31 and 006311f7 < as above.  There are 6 of these in all.  As far as I can tell, 3 for WM and 3 for field.  Identical code. Easy to find.

I have probably missed some, but any case the game writes the window sizes from 1 piece of code 006318e5 I think from there (cant check, ive closed ff7 down). That one is the height.  The others are nearby.

The data is stored temporarily at another location, and is used for both field and WM. You can change those easily at run time.  If you cannot find those I will be back tomorrow.

edit.  Ok I loaded it for you:

The window size data is at mov ax,[ecx+00CFF5C2]

ecx+00CFF5C2

so check near 00CFF5C2 and you will find the runtime values for windows.







« Last Edit: 2011-04-26 05:16:11 by DLPB »

Wutai Clan

  • *
  • Posts: 115
    • View Profile
Re: FF7 Field Messages
« Reply #8 on: 2011-04-26 07:52:22 »
Ones we found:

006F5AD4 < spacing of dialogue  (there are 2 of these, 1 is lower down.  Identical value.  You need to change both. for that)

006EC28B < X of first line.

00630ceb  < sets the dialogue line height

006318e5 < sets the window height.

006EC285 < Y of all lines

00632cb3 < works out how many lines there should be  from box height.

00630ea6, 00631b31 and 006311f7 < as above.  There are 6 of these in all.  As far as I can tell, 3 for WM and 3 for field.  Identical code. Easy to find.

I have probably missed some, but any case the game writes the window sizes from 1 piece of code 006318e5 I think from there (cant check, ive closed ff7 down). That one is the height.  The others are nearby.

The data is stored temporarily at another location, and is used for both field and WM. You can change those easily at run time.  If you cannot find those I will be back tomorrow.

edit.  Ok I loaded it for you:

The window size data is at mov ax,[ecx+00CFF5C2]

ecx+00CFF5C2

so check near 00CFF5C2 and you will find the runtime values for windows.

Nice, I'll have to check it out after I get some sleep, been a long day,. I've been decoding functions, vars, and I'm still learning some new hacking tricks, I also did a bit of refactoring on my project files in VC++, etc,. (It's very hard to find info on doing some stuff, and the ppl who do know, are being evasive about it.)

Anyways, thanks, I appreciate it. :)

--

Btw, I checked that value you listed, and you are correct, It's right on top of the values I decoded, so I'll have to load that whole range into MHS, and just watch them while in dialog, to figure em' out quicker. :D
« Last Edit: 2011-04-26 08:05:19 by Wutai Clan »