Page 1 of 1

What files are the scripts and how are they formatted.

Posted: Sat Feb 10, 2018 4:23 pm
by ^Ripper
How does this PSX game tick.
Inner working explained through (poor) reverse engineering.

!!! Important !!!

This information will change as i figure out more.
Some info maybe incomplete, incorrect or outdated.


The scripts are found in the .LDP files located in the M3, M4, M5 and M6 folders.
They reside at the end of the file.
I have only decoded the script part of the files.

Decoding the actual script data:
(I have a working decoder/encoder/script editor, so this is just informational)

Game text is located at the end of the .LDR file in chunks of 2048 bytes depending on required space.
Header/index/entry data is in 4 byte chunks.

[12 byte header][index][entries]

Header:
Chunk 1 XX XX 00 00 <- XX = Little endian unsigned short: The total size.
Chunk 2 XX XX 00 00 <- XX = Little endian unsigned short: The largest entry size.
Chunk 3 XX XX YY YY <- XX = Little endian unsigned short: The amount of entries. YY = Unknown atm, and is usually the same number. (Default entry?)

Index:
Each index entry uses two 4 byte chunks: XX XX 00 00 YY YY 00 00 <- XX = Little endian unsigned short: Start adress of entry, YY = Little endian unsigned short: Size of entry.

Entry:
Entry size is in 4 byte chunks and always dividable by 4! It has trailing 00's when needed.
If the entry is perfectly dividable, add a blank 4 byte 00 00 00 00 chunk.
Entry consists of a leading identification chunk 07 00 00 00 (encoded text) / 05 00 00 00 (decoded text), followed by the text and terminated with 0A 0A and trailing 00's when needed.
Text part is encoded! Flip bits 1,5,6 out of 8 to get the real data!
Game text does not have to be re-encoded when updated, it will use decoded entries just fine.
Also, an entry cannot be on the boundry of two 2048 byte chunks.
If that occurs, then 0 pad the remaining bytes and start the next entry on the next 2048 chunk.
This due to the game loading each chunk when needed and it will only partially load the entry.

Irregularities in Chunk 3 of the Header in some files:
These should be left alone or be fixed manually back after rebuild!

Code: Select all

MP012_0.LDP - 15 - 14
MP014_1.LDP - 21 - 22
MP031_0.LDP - 3 - 1
MP036_18.LDP - 49 - 50
MP038_23.LDP - 55 - 54
MP055_11.LDP - 44 - 43
MP055_12.LDP - 23 - 22
MP055_14.LDP - 31 - 29
MP066_1.LDP - 14 - 13
MP216_0.LDP - 22 - 21
MP220_1.LDP - 23 - 24
MP221_0.LDP - 55 - 54
MP251_2.LDP - 93 - 95
MP251_3.LDP - 93 - 95
MP580_1.LDP - 74 - 81
MP580_2.LDP - 75 - 81
MP583_2.LDP - 14 - 12
MP624_0.LDP - 33 - 32
MP624_1.LDP - 33 - 32
MP723_1.LDP - 52 - 50
MP723_4.LDP - 25 - 23
MP723_5.LDP - 23 - 21
MP726_0.LDP - 10 - 9
Text formatting:
(this is ongoing, as i havent found all the formatting tags yet!)

Special tags

WP-xxx-yyy / WP+xxx+xxx

Window Position measured from top-left of the first character.
A character = 16x16 pixels standard or 12x16 when BL1216 is used.
First is the X offset (- is to the left), second the Y (+ is to the bottom.
X = 242 max, Y = 108 max for top-left corner.

WSxxyy

Window Size measured in character width.
xx = characters per line and yy = amount of lines.
xx = 25 / yy = 2 for a standard window on BL1616 and xx = 33 / yy = 2 on BL1216.
30 characters wide is the visual limit on BL1616 standard and 40 on BL1216 standard.

BLxxyy

Character width / ???
xx = character render width, yy = ??.
1616 is default and must be declared in the beginning after WS.
1216 is the best spacing for western characters and provide more space on each line. 33 characters instead of 25.
Use WS

gx

Margin-left for the next character.
x = 0-9 where g0 is the default value.

cxxx

Color tag for next character only.
xxx = shorthand hex color like f30(red).
The following are used in-game: c0f3, c86f, ce5c, cf0d, cf30, cff0.

CSA0

Automatic text advance with timer.
A0 = ... seconds ????

w+xx

Line start indent spaces.
Adds a space where xx is the amount of spaces.
The following are used in-game: w+01 and w+02

b0-b7 + br

Text color out of a loaded pallette.
First 8 are "safe" colors and br(78) looks like an end tag that returns to default color.

\\

Line break
Issued after the max amount of characters reached as a forced return.

@@

Pause text and empty text window.
When the lines of the text windows are used up or you want to start with a clean text window.
Text continues after pressing the dedicated key.

s3 + sr

text fade-in instead of each character appearing.
s3 = 3 seconds, t0 = instant text due to fading, a1 = ?, n1 = ?.
sr is return to default.

t0 + tr

Text speed where 0 is instant and 9 is slow character printing on screen.
tr is return to default.

a0 + ar

??
ar is return to default.

n0 + nr

??
nr is return to default.

[0 , [1 , etc

Menu option
2 bytes followed by a blank space 8140 for 1 character padding to accomodate the choice arrow!

[DD0 , [DD1 , etc

Selected menu option.
4 bytes followed by a blank space 8140!

i0xx

??? last tag after a menu. xx used are 10, 25, 30
If it is in the source text use it!

BKAx

??

BKCxxx

Text box background color.
xxx is a shorthand hex color of the semi transparent background.

FRAx

???

FRCx

Text box foreground color (border).
Color x is a color from "a" palette.
Only values "1" and "3" are used in the game.

Dump of all unique lowercase ascii control codes

Code: Select all

@@
@@WP-200+042WS2503t0b2
@@WP-200+050WS2503t0b2
@@b2
@@b3
@@b5
@@b6
@@s3t0a1n1
@@s3t1a1n1
@@s3t7a1n1
@@s4t2a1n2b2
@@srtrarnrb2
BKC333FRC1
BKC333FRC1WP-200+058b3
BKC333FRC1WS2503b3
BKC333FRC1b3
BKC333FRC1b3b3
CSA0t7b2
WP-024-008WS0502CSA0FRA0BKAfBKC888BL1601t0n1cff0a1t0
WP-032+050WS0603t0[0
WP-032-008WS0401FRA0BKC000s3t0a1n1
WP-032-008WS0401FRAfBKC000s3t0a1n1
WP-048-016WS0502BKC933t0
WP-054-008WS0601BKC933t0
WP-064-008WS0802CSA0FRA0BKAfBKC888BL1601t0n1cff0a1
WP-072+008WS0906t0
WP-072+008WS0906t0[0
WP-072+024WS0905t0[0
WP-072+040WS0904t0[0
WP-072-008WS0902CSA0FRA0BKAfBKC888BL1601t0n1cff0a1t0
WP-072-008WS0906t0[0
WP-072-008WS0907t0[0
WP-072-024WS0907t0[0
WP-072-024WS0908t0[0
WP-078-016WS0902BKC933t0
WP-096+024WS1203t0b2
WP-096+050WS1203t0[0
WP-104+000WS1306t0[0
WP-104+002WS1306t0[0
WP-104+018WS1305t0[0
WP-104+034WS1304t0[0
WP-104+050WS1303t0[0
WP-104+066WS1301t0[0
WP-104+066WS1302t0[0
WP-104-014WS1307t0[0
WP-112+024WS1403t0b2
WP-112+040WS1404t0[0
WP-120+002WS1506t0[0
WP-136+024WS1703t0
WP-160-008WS2001FRA0BKC000s3t0a1n1
WP-160-024WS1903BKC933t0
WP-184+074WS2302FRA0BKC002t0b5
WP-200+018WS2505t0b2
WP-200+020WS2503FRC3BKC000
WP-200+024WS2505
WP-200+026WS2504t0b2
WP-200+034WS2504t0b2
WP-200+042WS2503t0b2
WP-200+042WS2504t0b2
WP-200+050WS2503BKC333FRC1b3
WP-200+050WS2503b2
WP-200+050WS2503b3
WP-200+050WS2503s3t0a1n1
WP-200+050WS2503t0b2
WP-200-014WS2507t0b2
WP-200-082BKC333FRC1s3t0a1n1
WS2501b3
WS2503BKC333FRC1
WS2503BKC333FRC1BKC333FRC1b2
WS2503BKC333FRC1b2
WS2503BKC333FRC1b3
WS2503b2
WS2503b3
WS2503b3b3
WS2503b5
WS2503s3t0a1n1
WS2504b3
\\
\\[1
\\[2
\\[3
\\[4
\\[5
\\[6
\\[7
\\[DD1
\\br
\\cf0d
\\cf30
\\i010
\\n0c006afg1
\\w+01[0
\\w+01[DD1
\\w+02[2
\\w+02[3
\\w+02[4
\\w+02[5
\\w+02[DD2
\\w+02[DD3
\\w+02[DD4
\\w+02[DD5
\\w+03t0i030
b2
b3
b3s3t0a1n1
b5
b6
br
br\\[0
brcf30
brt6
brt7
brt8
brt9
c0f3
c86f
ce5c
cf0d
cf30
i010
i010WP-072+008WS0906t0
i010WP-096+024WS1203t0b2
i010WP-112+024WS1403t0b2
i010WP-120+002WS1506t0[0
i010WP-120+050WS1503t0[0
i010WP-120+050WS1603t0[0
i010WP-128-008WS1607t0[0
i010WP-136+024WS1703t0
i010WP-144+024WS1803t0
i010WP-200+020WS2503FRC3BKC000
i010WP-200+024WS2505
i010WP-200+050WS2503t0b2
i010WS2503b3
i010WS2503b5
i010WS2504b3
i010b2
i010b3
i010s3t0a1n1
i025
i030t0
s3t0a1n1
s3t0a1n1b3
s3t1a1n1
s3t7a1n1
s4t2a1n2b2
t0
t0i030
tr
w+02[1
w+02[DD1
Game menu texts are in the /NOR/ folder and can reside in every .E file.