I spent some times playing with xenogears field files again.
I managed to understand some new data.
If anyone still remember something - file six in field are scripts.
The first 0x80 bytes are unknown.
After it goes u32 number of entitys.
And after it are 2 bytes offsets to entity scripts entry points. Each entity record are 0x40 bytes long so there can be 32 scripts max.
The first script are called at the beginning of the map (constructor)
The second one are called repeatedly
The third one are the dialog script (called when you try to speak with entity)
Here some script that I already decode... not compleatly maybe =)
0x00 Return();
0x01 JumpTo(u16 address);
address - address in global script offset
0x02 ConditionalJumpTo(u8 offset, u8 databank, u16 value, u8 condition, u16 address);
if condition is wrong then jump
condition - 0x40 - A == B
- 0x41 - A != B
- 0x46 - A & B
address - address in global script offset
0x0B SpriteSet(u8 sprite_id, 80);
0x19 SpriteSetPosition(u16 x, u16 y, C0);
0x20 SpriteSetSolid(u8 type, 80);
type - 0x01 - can go through
- 0x02 - ???
- 0x04 - ???
- 0x08 - can't move
- and different combination of above flags
0x26 Wait(u8 time, 80);
time - the larger value - longer waiting
0x2C SpritePlayAnimation(u8 animation_id);
0x36 VariableSetTrue(u8 offset, u8 databank);
set two bytes from offset to 01 00
0x37 VariableSetFalse(u8 offset, u8 databank);
set two bytes from offset to 00 00
0x4A SpriteGoToPosition(u16 x, u16 y, C0);
0x69 SpriteSetDirection(u8 direction, 80);
direction - 0x00 - north
- 0x01 - north-east
- 0x02 - east
- 0x03 - south-east
- 0x04 - south
- 0x05 - south-west
- 0x06 - west
- 0x07 - north-west
- and so on...
0x6B SpriteRotateClockwise(u8 rotation, 80);
rotation - number of sprite rotation to skip (clockwise)
- 0x00 - stay as we are
- 0x01 - rotate one position clockwise
0x6C SpriteRotateAntiClockwise(u8 rotation, 80);
rotation - number of sprite rotation to skip (anti-clockwise)
- 0x00 - stay as we are
- 0x01 - rotate one position anti-clockwise
0x6F SpriteRotateToEntity(u8 entity_id);
0x98 MapLoad(u16 map_id, u8 location, 80);
0xA8 VariableRandom(u8 offset, u8 databank, u8 max_value, 80);
set two bytes from offset to random value from "00 00" to "max_value 00"
0xB3 FadeOut(u8 time, 80);
time - larger the value - longer the fade
0xB4 FadeIn(u8 time, 80);
time - larger the value - longer the fade
0xB5 CameraSetDirection(u8 direction, 80);
direction - 0x00 - north
- 0x01 - north-east
- 0x02 - east
- 0x03 - south-east
- 0x04 - south
- 0x05 - south-west
- 0x06 - west
- 0x07 - north-west
- and so on...
0xC7 CameraRotate(u8 time, 80);
don't know difference with CameraRotate2();
time - larger the value - longer the rotate
0xC8 CameraRotate2(u8 time, 80);
don't know difference with CameraRotate();
time - larger the value - longer the rotate
0xD2 DialogShow(u8 dialog_id, u16 flags);
flags meaning are dont known
And example script. The main room in Chief Lee house (where the first conversation with Dan is). Entity is Maid that walking in far corner of the room.
// 0x04C5
entity[0F].script[00]()
{
SpriteSet(03, 80);
Return();
}
// 0x04C9
entity[0F].script[01]()
{
VariableRandom(0E, 04, 03, 80);
ConditionalJumpTo(0E, 04, 00 00, 40, E5 04); (#1)
SpriteGoToPosition(86 FF, B9 01, C0);
SpriteSetDirection(00, 80);
Wait(28, 80);
JumpTo(36 05); (#4)
#1 ConditionalJumpTo(0E, 04, 01 00, 40, FC 04); (#2)
SpriteGoToPosition(20 00, B9 01, C0);
SpriteSetDirection(00, 80);
Wait(28, 80);
JumpTo(36 05); (#4)
#2 ConditionalJumpTo(0E, 04, 02 00, 40, 13 05); (#3)
SpriteGoToPosition(4D FF, 56 01, C0);
SpriteSetDirection(06, 80);
Wait(28, 80);
JumpTo(36 05); (#4)
#3 ConditionalJumpTo(0E, 04, 03 00, 40, 36 05); (#4)
SpriteSetDirection(01, 80);
Wait(05, 80);
SpriteSetDirection(00, 80);
Wait(05, 80);
SpriteSetDirection(07, 80);
Wait(05, 80);
SpriteSetDirection(00, 80);
Wait(1E, 80);
JumpTo(36 05); (#4)
#4 04
}
// 0x0537
entity[0F].script[02]()
{
ConditionalJumpTo(02, 04, 00 00, 40, 42 05); (#1)
JumpTo(43 05); (#2)
#1 Return();
#2 SpriteRotateToEntity(01);
DialogShow(22, 00 00);
9C
5D025E
DialogShow(23, 00 00);
9C
2CFF
}
// 0x0554
entity[0F].script[03]()
{
Return();
}
// 0x0555
entity[0F].script[04]()
{
F4005A
92
}
// 0x0559
And one more. Chief Lee itself
Lee
// 0x03AA
entity[0C].script[00]()
{
SpriteSet(04, 80);
SpriteSetSolid(08, 80);
SpriteSetDirection(00, 80);
FE0D0F80
Return();
}
// 0x03B8
entity[0C].script[01]()
{
Return();
}
// 0x03B9
entity[0C].script[02]()
{
VariableSetTrue(02, 04);
SpriteRotateToEntity(01);
ConditionalJumpTo(0C, 04, 00 00, 40, 07 04); (#1)
DialogShow(1A, 00 00);
9C
SpriteRotateClockwise(01, 80);
Wait(05, 80);
SpriteRotateAntiClockwise(01, 80);
Wait(0A, 80);
DialogShow(1B, 00 00);
9C
SpritePlayAnimation(00);
SpriteRotateClockwise(01, 80);
Wait(01, 80);
SpriteRotateClockwise(01, 80);
FE0DFC80
DialogShow(1C, 00 00);
9C
FE0D0F80
Wait(0A, 80);
SpriteRotateToEntity(01);
Wait(0A, 80);
DialogShow(1D, 00 00);
9C
VariableSetTrue(0C, 04)
JumpTo(0C 04); (#2)
#1 DialogShow(1E, 00 00);
9C
#2 SpritePlayAnimation(FF);
370204
}
// 0x0411
entity[0C].script[03]()
{
Return();
}
// 0x0412
entity[0C].script[04]()
{
Wait(14, 80);
A40C00DA00
}
// 0x041A
entity[0C].script[05]()
{
A419008F00
}
// 0x041F
entity[0C].script[06]()
{
ConditionalJumpTo(08, 00, 06 00, 40, 2F 04); (#1)
CameraSetDirection(02, 80);
3C80
JumpTo(54 04); (#4)
#1 ConditionalJumpTo(08, 00, 07 00, 40, 3F 04); (#2)
CameraSetDirection(02,80);
2880
JumpTo(54 04); (#4)
#2 ConditionalJumpTo(08, 00, 05 00, 40, 4F 04); (#3)
CameraSetDirection(02, 80);
2880
JumpTo(54 04); (#4)
#3 CameraSetDirection(02, 80);
1E80
#4 Return();
}
// 0x0455
entity[0C].script[06]()
{
F4005A
SpriteSetDirection(00, 80);
92
}
// 0x045C