Anonymous

Changes

From Final Fantasy Inside

FF7/Coordinates encoding

1,509 bytes added, 17:40, 7 April 2006
no edit summary
Coordinates on the world map are stored on 2 DWords and some basic decoding has to be done before you can manipulate them.

First DWord :
<pre>[1F 1E 1D 1C 1B 1A 19 18:17 16 15 14 13 12 11 10:0F 0E 0D 0C 0B 0A 09 08:07 06 05 04 03 02 01 00]
| DIRECTION/0x10 | OBJECT'S ID | X COORDINATE OF THE OBJECT |</pre>

Second DWord :
<pre>[1F 1E 1D 1C 1B 1A 19 18:17 16 15 14 13 12 11 10:0F 0E 0D 0C 0B 0A 09 08:07 06 05 04 03 02 01 00]
| Z COORDINATE OF THE OBJECT | Y COORDINATE OF THE OBJECT |</pre>

Notes :
* X is an unsigned value ranging from 0 to 0x47FFF
* Y is an unsigned value ranging from 0 to 0x37FFF
* Z is signed
* Direction is multiplied by 0x10 after reading from save-game, but that's not affecting anything so we can think of it as a byte value.


{| border="1" cellspacing="1" cellpadding="3" align="center" style="border: 1px solid black; border-collapse: collapse;"
|+'''Table: Object ID'''
! style="background:rgb(204,204,204)" align="center" | Value
! style="background:rgb(204,204,204)" align="center" | Object
|-
| 0x00
| Party
|-
| 0x03
| Highwind
|-
| 0x05
| Tiny Bronco
|-
| 0x06
| Buggy
|-
| 0x0D
| Submarine
|-
| 0x13
| Chocobo
|-
| 0x1D
| Weapon
|}


== How to decode coordinates in C ==

Assuming ''1st'' and ''2nd'' are respectively the first and second DWords :
<pre>X = 1st & 0x7FFFF
Y = 2nd & 0x3FFFF
Z = 2nd >> 0x12 // shift arithmetic right
ID = (1st >> 0x13) & 0x1F
DIR = (1st >> 0x14) & 0x0FF0</pre>
Anonymous user