THAW - Instruction 0x4A

Tutorial forum for Tony Hawk games.
Forum rules
No requests, use other sections for that. TAG your titles [THAW][THUG2] etc.
WhoElseButMe
Posts: 419
Joined: Tue Aug 04, 2009 12:50 am
Location: FL - USA
Contact:

THAW - Instruction 0x4A

Postby WhoElseButMe » Mon Nov 22, 2010 9:00 pm

For those of you having trouble decompiling some THAW scripts I'm here to help you out.

This instruction can be found in THAW+ games and is nothing more than a SectionScript StructureItem
simply put, section scripts are functions, so this is a Function Structure.

You can easily convert these into arguments OR as an old fashioned structure
:i call $something$ arguments... OR
:i $something$:s{
:i :s}
The code after 0x4A might confuse some of you, however, its not that hard to understand.
If you're unfamiliar with THPS byte code's read about them here
I'll start off with the data types you might encounter then we'll move into picking apart a script that uses 0x4A.

THAW Structure Data Types:

Code: Select all

00000100 = floats, if X2 then 2 float values no null, else 3 float values no null

00010000 = Structure Header
   |4byte data type|4byte pointer to first structure item|
00000300 = Structure Integer Item
   |4byte data type|4byte QbKey|4byte integer value|4byte byte count or null if last item|
00000500 = Structure FloatX1 Item
   |4byte data type|4byte QbKey|4byte float value|4byte pointer to the next structure item|
00000700 = Structure String Item
00000900 = Structure StringW Item
   |4byte data type|4byte QbKey|4byte pointer|4byte null|+ your string|4byte byte count or null if last item|
00000B00 = Structure FloatX2 Item
000D0000 = Structure FloatX3 Item
   |4byte data type|4byte QbKey|4byte pointer to the "floats" data type|4byte pointer to the next structure item(the end of this item)|
00001500 = Structure Structure Item
   |4byte data type|4byte pointer to Structure Header|4byte pointer to end of structure|
00001900 = Structure Item Array (array data types apply, see below)
   |4byte data type|4byte QbKey|4byte pointer to the first data type|4byte pointer to the end of the array|
00001B00 = Structure QbKey Item
00003500 = Structure QbKeyString Item
   |4byte data type|4byte QbKey|4byte QbKey|4byte byte count or null if last item|
00000F00 = Structure Script Item (shouldn't see this one inside of a Section Script)

THAW Array Data Types

Code: Select all

00010100 = Array Integer Item
00020100 = Array Float Item
00030100 = Array String Item     // strings are null terminated / null padded if last string
00040100 = Array StringW Item    // strings are null terminated / null padded if last string
000C0100 = Array ArrayItem
000D0100 = Array QbKeyItem
001A0100 = Array QbKeyString Item
001B0100 = Array StringPointer Item
001C0100 = Array QbKeyStringQs Item
   |4byte # of items|4byte pointer to first item|4byte * number of items|doesn't end with null|

000A0100 = Array Structure Item (structure data types apply, see above)
   |4byte # of items|4byte offset to begin structure|->|end null|

Two ways you'll see 0x4A, either staring off the script
something calls this script with arguments
OR directly after a hash | 0116 FFFFFFFF 4A

The 2 bytes directly after 4A are the number of bytes found in the ScriptStructure
Byte count starts with the Structure Header data type.
They're also aligned so a data type will ALWAYS start either @ 0, 4, 8 or C.
This is the reason string's and stringw's don't have a consistent number of null bytes after the string.

I'll pick apart "THAW_RollupDoor_MoveUp" since that script was asked about in another topic.
Example Script

Code: Select all

0116C34AF1744A280000000000000100
08000000001B0000000000006AC9DC42
18000000001B0000D823599DCBC351B3
000000000116285E77D001162BA381EA
4A3800000000010008000000000D0000
00000000180000002800000000010000
00000000000048430000000000050000
BA676B900000003F000000000116C0D0
B58C4A18000000000000010008000000
00030000000000005000000000000000
0116CCCB722A16EC8B72F807161DADBC
911690D8D2A60716DEBC3219160CF131
70072C01160EC6E82D4A300000000100
08000000000700000000000018000000
00000000544841575F526F6C6C757044
6F6F725F4D6F7665557000000124

Translated Script

Code: Select all

0116C34AF174  = :i $C34AF174$
4A            = ScriptStuctItem
2800          = byte count/pointer to the next instruction
000000        = null bytes to the StructHeader, the number of null bytes varies
00000100      = StructHeader - start of the byte count, so count = 4
08000000      = pointer to byte 8; our first structure data type
001B0000      = Structure QbKey Item
00000000      = QbKey 1
6AC9DC42      = QbKey 2
18000000      = pointer to next data type/ byte count 24
001B0000      = Structure QbKey Item
D823599D      = QbKey 1
CBC351B3      = QbKey 2
00000000      = null structure terminator/ byte count 40

0116285E77D0  = :i $285E77D0$
01162BA381EA  = :i $2BA381EA$
4A            = ScriptStuctItem
3800          = byte count/pointer to the next instruction
00            = null bytes to the StructHeader, the number of null bytes varies
00000100      = Structure Header - start of the byte count, so count = 4
08000000      = pointer to byte 8; our first structure data type
000D0000      = Structure FloatX3 Item
00000000      = QbKey
18000000      = pointer to Floats data type
28000000      = pointer to next structure item
00010000      = Floats
00000000      = float value 1
00004843      = float value 2
00000000      = float value 3, no null terminator; byte count 40
00050000      = Structure FloatX1 Item
BA676B90      = QbKey
0000003F      = float value
00000000      = null structure terminator/ byte count 56

0116C0D0B58C  = :i $C0D0B58C$
4A            = ScriptStuctItem
1800          = byte count/pointer to the next instruction
000000        = null bytes to the StructHeader, the number of null bytes varies
00000100      = StructHeader - start of the byte count, so count = 4
08000000      = pointer to byte 8; our first structure data type
00030000      = Structure Integer Item
00000000      = QbKey
50000000      = integer value
00000000      = null structure terminator/ byte count 24

0116CCCB722A  = :i $CCCB722A$
16EC8B72F807161DADBC91 = $EC8B72F8$ = $1DADBC91$
1690D8D2A60716DEBC3219 = $90D8D2A6$ = $DEBC3219$
160CF13170072C = $0CF13170$ = isNull
01160EC6E82D  = :i $0EC6E82D$
4A            = ScriptStuctItem
3000          = byte count/pointer to the next instruction
00000100      = StructHeader - start of the byte count, so count = 4
08000000      = pointer to byte 8; our first structure data type
00070000      = Structure String Item
00000000      = QbKey
18000000      = pointer to the string
00000000      = null
544841575F526F6C6C7570446F6F725F4D6F766555700000 = our string
0124          = :i endfunction

Converted Script as Structure

Code: Select all

:i $PlayStream$:s{
   :i $Gate_open$
:i :s}
:i $Obj_ClearExceptions$
:i $Obj_MoveToRelPos$:s{
   :i %vec3(0.000000,200.000000,0.000000)
   :i $time$ = %f(0.500000)
:i :s}
:i $Obj_SetOuterRadius$:s{
   :i %i(80,00000050)
:i :s}
:i call $Obj_SetException$ arguments
   $ex$ = $ObjectOutOfRadius$$scr$ = $THAW_RollupDoor_Down$$Params$ = isNull
:i $printf$%S(22,"THAW_RollupDoor_MoveUp")
:i endfunction

Converted Script as Arguments

Code: Select all

:i call $PlayStream$ arguments
   $Gate_open$
:i $Obj_ClearExceptions$
:i call $Obj_MoveToRelPos$ arguments
   %vec3(0.000000,200.000000,0.000000)$time$ = %f(0.500000)
:i call $Obj_SetOuterRadius$ arguments
   %i(80,00000050)
:i call $Obj_SetException$ arguments
   $ex$ = $ObjectOutOfRadius$$scr$ = $THAW_RollupDoor_Down$$Params$ = isNull
:i $printf$%S(22,"THAW_RollupDoor_MoveUp")
:i endfunction
Last edited by WhoElseButMe on Tue Nov 23, 2010 8:18 pm, edited 1 time in total.
Image
WhoElseButMe on Nov 26, 2009 wrote:It's that lack of respect amongst their peers and ignorance towards modding etiquette that keeps us who know this stuff well from spreading it like wild fire. We do still enjoy playing the game and if you need to cheat to play a game PLAY SOMETHING ELSE YOU DON'T SUCK AT.
Eraser
Site Admin
Posts: 911
Joined: Tue Apr 21, 2009 4:42 pm
Location: Lithuania
Contact:

Re: THAW - Instruction 0x4A

Postby Eraser » Tue Nov 23, 2010 10:01 am

That's way too advanced stuff, I really tried to understand, but most of it I couldn't. : (
But this is some good educational stuff.
WhoElseButMe
Posts: 419
Joined: Tue Aug 04, 2009 12:50 am
Location: FL - USA
Contact:

Re: THAW - Instruction 0x4A

Postby WhoElseButMe » Tue Nov 23, 2010 9:28 pm

Yeah, it is a bit complex but all THAW scripts are like this. I guess since I've been dealing with the scripts before the easy editor tool it a little easier for me to understand these. The THAWproject will be able to handle these without breaking a sweat.
But if there's anything you'd like to understand better, I'll try my best to explain it better.
Image
WhoElseButMe on Nov 26, 2009 wrote:It's that lack of respect amongst their peers and ignorance towards modding etiquette that keeps us who know this stuff well from spreading it like wild fire. We do still enjoy playing the game and if you need to cheat to play a game PLAY SOMETHING ELSE YOU DON'T SUCK AT.
sMo0g™
Posts: 108
Joined: Fri Nov 20, 2009 1:20 pm
Location: Ukraine
Contact:

Re: THAW - Instruction 0x4A

Postby sMo0g™ » Mon Dec 13, 2010 5:25 pm

Its your tutorial? :DDDD
Or gone?
sMo0g™
Posts: 108
Joined: Fri Nov 20, 2009 1:20 pm
Location: Ukraine
Contact:

Re: THAW - Instruction 0x4A

Postby sMo0g™ » Mon Dec 13, 2010 5:36 pm

i stupid :D
You is gone? XD
WhoElseButMe
Posts: 419
Joined: Tue Aug 04, 2009 12:50 am
Location: FL - USA
Contact:

Re: THAW - Instruction 0x4A

Postby WhoElseButMe » Tue Dec 14, 2010 9:16 pm

sMo0g™ wrote:You is gone? XD

correct
Image
WhoElseButMe on Nov 26, 2009 wrote:It's that lack of respect amongst their peers and ignorance towards modding etiquette that keeps us who know this stuff well from spreading it like wild fire. We do still enjoy playing the game and if you need to cheat to play a game PLAY SOMETHING ELSE YOU DON'T SUCK AT.
quazz
Posts: 185
Joined: Sat May 01, 2010 5:57 pm
Contact:

Re: THAW - Instruction 0x4A

Postby quazz » Tue Dec 14, 2010 9:25 pm

WhoElseButMe wrote:
sMo0g™ wrote:You is gone? XD

correct


It took me a little while to figure that out too.

Return to “Tutorials”

Who is online

Users browsing this forum: No registered users and 16 guests