Author Topic: How to Correctly Place Objects In A Field  (Read 11704 times)

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
How to Correctly Place Objects In A Field
« on: 2013-04-10 19:48:45 »
I am creating a program that will tell you your X Y Z and Triangle position.

The X Y and Triangle ID are updated to their correct save values every time you open a menu (the correct values are placed starting at 00DC08D2).  So, if I wanted to do this a nice basic way, I would stand where I want the object, open menu, and record the X Y T. 

See post 2.

There has to be an easier way to correctly place objects, surely?
« Last Edit: 2013-04-10 21:35:10 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #1 on: 2013-04-10 20:09:41 »
00DC08D2 gives X Y and Triangle ID.  Not X Y Z.  Black Chocobo needs updating too.  The question now is, where does Z fit into things :P I shall find out.

edit

X, Y and Z in real-time are 4 byte values.  As you walk, these are updated immediately.  The game performs a shift to the right of 0C on these values, and these are the values the game saves and uses (for example in field scripts). 

X, Y, Z: 4 bytes in realtime, 2 bytes in menu.
Triangle ID: 2 bytes.

X is updated in real-time at 00CC167C written from 00408168.
In menu, its position in memory is 00DC08D2.

Y is updated in real-time at 00CC1680 written from 00408184.
In menu, its position in memory is 00DC08D4.

Z is updated in real-time at 00CC1684 written from 0063762D, 00635147, 006359C9
I do not see it in menu memory.  Is this value saved?

Triangle ID is updated in real-time at 00CC16E8 written from 004081A1.
In menu, its position in memory is 00DC08D6.

« Last Edit: 2013-04-11 14:27:18 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #2 on: 2013-04-10 21:07:28 »
Since you know where to find these values for the PC version, would you mind providing the values for X/Y/Triangle upon entering a specific field, so I can lazily identify where they're stored in the PSX version?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #3 on: 2013-04-10 21:12:23 »
The best way is to use Black Chocobo... it can place you anywhere you want and tells you the exact X Y and Triangle (which BC has mistakenly called Z) values.

If you need me to tell you exact coords for certain places, I don't really have the time.  But if you have PC version it would not be that difficult to find based on this method.

NFITC1 may be able to shed some light on what I have found.

I'm close now to working a very easy way to place objects correctly in ff7.  If all goes well I can just create a shitty program that tells you current X Y Z and triangle position of where your character is standing.,

edit.  It shouldn't be a problem for me to create this program :)  Let's see!
« Last Edit: 2013-04-10 21:34:42 by DLPB »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #4 on: 2013-04-10 22:40:04 »
Ok so I have created a program that will update the X Y Z T for you as you walk about.  I will do some testing and then release.  This should make it 100x easier to place objects into game.

Edit

yup.  Aside from needing a little change here and there, the program allows you to easily place models/items and so forth into the game.
« Last Edit: 2013-04-10 23:20:25 by DLPB »

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #5 on: 2013-04-11 01:20:52 »
Since you know where to find these values for the PC version, would you mind providing the values for X/Y/Triangle upon entering a specific field, so I can lazily identify where they're stored in the PSX version?
If you take a known fixed location (IE the game stuffs you at that location) and then get his memory dump you can use PSX utilis to scan the memory for a match.

I believe the GTE (PS1) uses data with a 12bit fractions in it's engine (hence why it appears shifted by 12 then they force it to an integer value).
It might take a few tries but it has a somehat fair chance of success.
You might also want to look at the PS1 cheat codes and see if anything is available in them similiar

Cyb

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #6 on: 2013-04-11 15:44:29 »
The best way is to use Black Chocobo... it can place you anywhere you want and tells you the exact X Y and Triangle (which BC has mistakenly called Z) values.

If you need me to tell you exact coords for certain places, I don't really have the time.  But if you have PC version it would not be that difficult to find based on this method.

Actually, I was just hoping you'd already recorded something like the initial X/Y/Z/T for Cloud's first placement in MD1STIN (first field in the game). Presumably, the values are the same between PC and PSX versions, so I could simply do a RAM dump and search for those values, rather than hacking coordinate mods using a GS-style hacking utility (CEP/PEC, TSearch, RenegadeEX, ArtMoney, MHS, etc), then determining whether or not the resulting addresses were indeed the ones that contained the values to be recorded upon saving, and in the same format (there are likely multiple places where field coordinates are stored; my experience in RAM-hacking PSX games has been that this is often the case).

As I said, this would make it easier to identify these addresses quickly and with minimal effort, rather than spending time and effort reinventing the wheel. Afterward, others might benefit from knowing where in memory these values are stored for the PSX version.

I think my work in reversing FF7 makes clear that I don't expect anyone to carry my weight or run around taking coordinate samples for me. I just wanted a single sample that would be identical between versions, so I could bridge the gap and make this work of yours useful for both PC and PSX. If grabbing a single set of values for me is a big effort you don't have time for, then I'll just go to the proportionally larger effort of doing it myself on PSX, or, as you said, digging around in Black Chocobo and performing comparisons using the values found there. No matter.


If you take a known fixed location (IE the game stuffs you at that location) and then get his memory dump you can use PSX utilis to scan the memory for a match.

I believe the GTE (PS1) uses data with a 12bit fractions in it's engine (hence why it appears shifted by 12 then they force it to an integer value).
It might take a few tries but it has a somehat fair chance of success.
You might also want to look at the PS1 cheat codes and see if anything is available in them similiar

Cyb

Yep; that would be my second choice. I'm fairly familiar with PS1 cheats, having founded GameHacking.org as GSHI in 1999, back when we exclusively hacked GameShark codes :)  My FF7 codes, along with those of many others, can be found here: http://gamehacking.org/?game=88853  (although we're in the middle of a database revamp, so there's a little tidying up underway still)

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #7 on: 2013-04-11 16:04:08 »
Give me some locations that the game moves you to and I will let you know (now tat I have created  a program to do it all for me).

The problem is, I can't see where in script the initial character placements are (when you enter a field.  Not when you load save, that works fine).  When game tells character to move to X Y Z T, that's all there... but when you move to a location, I can't find the starting point in script.

Not that you will need that anyway... you just need to know X Y Z T values of current position.
« Last Edit: 2013-04-11 16:10:22 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #8 on: 2013-04-11 16:19:01 »
Thanks. Any simple one would do. Pick a town, enter it, don't move, go into the menu, let me know what the coordinate values are. I'll do the same in the PSX version, take a RAM dump, find those values, and we'll know where it's stored in PSX memory. It could then either be used standalone by those who only own/use the PSX version and want to identify coordinates for a mod, or perhaps I can scheme up a method of automating the process a little more for PSX users, such as a GS code that copies the values from those addresses and displays them in numeric format instead of other values normally shown in-game in the menu.

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #9 on: 2013-04-11 16:35:57 »
Ok let's see:

Code: [Select]
Entering Costa Del Sol from world map

X: -1125
Y: -223
Z: -143
T: 43

Code: [Select]
Costa Del Sol Beach
Cloud walks to

X: -554
Y: 662
Z: -3
T: 34

You can see this with Makou Reactor too, del3, Group 5, Script 3
Move field Model (X=-554, Y=662)

Code: [Select]
Chocobo Farm
From the right.

X: 1263
Y: 1465
Z: 3
T: 79
Code: [Select]
Chocobo Stables (with Chole etc)

X: -1
Y: -1091
Z: 2
T: 24

Code: [Select]
Chocobo Inn (where you can sleep)

X: 154
Y: -160
Z: 0
T: 60

AS HEX in real-time:

Code: [Select]
Entering Costa Del Sol from world map

X: 00 B0 B9 FF
Y: 00 10 F2 FF
Z: 00 10 F7 FF
T: 2B 00

Code: [Select]
Costa Del Sol Beach
Cloud walks to

X: 00 60 DD FF
Y: 00 60 29 00
Z: 00 D0 FF FF
T: 22 00

You can see this with Makou Reactor too, del3, Group 5, Script 3
Move field Model (X=-554, Y=662)

Code: [Select]
Chocobo Farm
From the right.

X: 00 F0 4E 00
Y: 00 90 5B 00
Z: 00 30 00 00
T: 4F 00
Code: [Select]
Chocobo Stables (with Chole etc)

X: 00 F0 FF FF
Y: 00 D0 BB FF
Z: 00 20 00 00
T: 18 00

Code: [Select]
Chocobo Inn (where you can sleep)

X: 00 A0 09 00
Y: 00 00 F6 FF
Z: 00 00 00 00
T: 3C 00
« Last Edit: 2013-04-11 19:57:03 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #10 on: 2013-04-11 16:49:30 »
Any chance you can provide the original hex values?

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #11 on: 2013-04-11 16:52:58 »
The original Hex Values can easily be derived from those values (using Calc or something), they are exact. If you don't like negative numbers, work with the positive ones.  The X Y Z will be right near each other.

One moment... I forgot about the right shifting. I will recreate it later with the original real time hex values.  The ones above should work when you open menu.

The triangle ID above are exact and will work.  Convert to hex and go hunt for those for now.
« Last Edit: 2013-04-11 16:56:27 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #12 on: 2013-04-11 16:57:13 »
Cool; thanks. I'll go RAM diving when I get home from work :)

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #13 on: 2013-04-11 17:07:07 »
Z is updated in real-time at 00CC1684 written from 0063762D, 00635147, 006359C9
I do not see it in menu memory.  Is this value saved?

This is probably related to the same issue on the world map (inability to save while on bridges, since the game wouldn't know whether you were on the bridge or on the land below when it tried to load your save later). Thus the answer would seem to be "no", though I've done no research to verify this.

Edit: ...which begs the question - is there any spot in a field in which you can normally save, which is directly above another spot at which you can normally walk? If not, I wonder what would happen if I activated Save Anywhere via a GameShark code, then saved in a spot directly above another spot, and tried to load the save...now I'm curious.
« Last Edit: 2013-04-11 17:09:36 by Lazy Bastard »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #14 on: 2013-04-11 18:28:52 »
The Z of the world map is saved, because you can save almost anywhere, even hills, that have a large Z.  The Z of world map changes quite a lot due to the small bumps and hills.  The Z of world map is 100% necessary.

The issue with field is, the Z may be able to be calculated on load, using X Y and T.   Therefore, it wouldn't need to be saved.  (Obviously, placing items and so forth require all 4).
« Last Edit: 2013-04-11 18:32:04 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #15 on: 2013-04-11 19:15:47 »
Ah; I assumed the world map Z coordinate would either behave the same way you predicted the field Z coordinate would behave (base the model's Z coordinate on the only possible Z coordinate at a given X/Y), which would explain the issue with bridges/etc. However, the hypothesis in this thread seems more satisfying: http://forums.qhimm.com/index.php?topic=12568.15

Also (although they appear to have made a mistake concerning triangle values in fields), Black Chocobo's savemap documentation refers specifically to "Z location on world map".

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #16 on: 2013-04-11 19:57:23 »
I have updated post above with hex values.

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #17 on: 2013-04-11 22:05:02 »
Nice; thanks :)

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #18 on: 2013-04-12 00:25:13 »
OK, found the corresponding addresses for the PSX version.

X: 0x80074F34 (4 bytes)
Y: 0x80074F38 (4 bytes)
Z: 0x80074F3C (4 bytes)
T: 0x80074F9A (2 bytes)

Perhaps those will be useful to someone (they'll certainly be useful to me). I'll play around with creating a button-activated code to copy the value of each in turn to something raw and numerical, such as gil, for those who don't feel like looking around in memory all the time.
« Last Edit: 2013-04-12 00:36:17 by Lazy Bastard »

DLPB_

  • Banned
  • *
  • Posts: 11006
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #19 on: 2013-04-12 00:26:57 »
Cheers for those.  Nice to see how there is actually a logical order there.  in PC, the T is separated by quite a distance.

Remember to divide those values by 4096 (sar 0C) to get to the number the script will use.
« Last Edit: 2013-04-12 00:39:58 by DLPB »

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #20 on: 2013-04-12 00:37:13 »
Heh, actually, I've corrected myself above. I guess it's been a long day, and my brain isn't processing data as accurately as usual :)

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #21 on: 2013-04-12 02:23:39 »
Well, I made a GameShark code that should allow you to print the value of X, Y, Z, or T in place of your current Gil, but it's a bit unwieldy, and about halfway through, I decided I would only finish it because I'd already gone to the trouble of starting it, heh. Here:

L1 - X, L2 - Y, R1 - Z, R2 - T

8009D264 0000

C009AC5C 0004
C2074F34 0004
8009D260 0000

C009AC5C 0001
C2074F38 0004
8009D260 0000

C009AC5C 0008
C2074F3C 0004
8009D260 0000

C009AC5C 0002
C2074F9A 0002
8009D260 0000

Values will be displayed in decimal, so you'll have to convert to hex, then convert from little endian to big endian. If preferred, you could always eliminate the step of endian-ness conversion by replacing the 4, 4, 4, and 2-byte Copy Bytes codes with 16 individual 1-byte Copy Bytes codes, arranged in the right order.

Two immediate problems (aside from the ridiculous hassle this would be to use in the first place) are that some values are so large they run into the word "Gil" and become unreadable, and some emulators don't seem to support the C0 and C2 code types properly.

If you'd rather just keep track of a single variable (X, or Y, or whatever) at a time, simply do something like:

C2074F34 0004
8009D260 0000

...which will force your gil to always reflect your X coordinate.

Using gil as a storage point is just what I came up with on the spot. Anything else would do, as long as there's an easy way to convert it to hex (so, Time would be a bad choice).

At this point, it looks like it would be easier for PSX modders to just use an emulator with a live debugger, (pSX, for example), and just monitor the addresses I mentioned a few posts earlier for their values at a given spot.
« Last Edit: 2013-04-12 13:22:07 by Lazy Bastard »

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: How to Correctly Place Objects In A Field
« Reply #22 on: 2013-04-12 21:01:59 »
Yep; that would be my second choice. I'm fairly familiar with PS1 cheats, having founded GameHacking.org as GSHI in 1999, back when we exclusively hacked GameShark codes :)  My FF7 codes, along with those of many others, can be found here: http://gamehacking.org/?game=88853  (although we're in the middle of a database revamp, so there's a little tidying up underway still)
That explains your familiarity with the format data. I remember once joining game hacking ... I think I was working on CC codes that didn't have to do with cheating (LOL). :D I know I'm odd (that's what people tell me anyhow).

Erstwhile adding models to the field is a rather fun idea. I suppose if one made a large blank tiled background ... nevermind :D

Cyb

Lazy Bastard

  • *
  • Posts: 290
  • I may be lazy, but I can...zzzZZZzzzZZZzzz...
    • View Profile
    • GameHacking.org
Re: How to Correctly Place Objects In A Field
« Reply #23 on: 2013-04-12 21:08:52 »
I remember once joining game hacking ... I think I was working on CC codes that didn't have to do with cheating (LOL). :D I know I'm odd (that's what people tell me anyhow).

:) The best codes are unrelated to cheating (unlocking hidden/disabled features, hijacking other models/sprites, making yourself a giant...the same sorts of things modders love to do, but with RAM).