Coding

 Reply to this postStart new topic

Sanny vs. Native Compiling

Deji
post Sep 10 2012, 03:01 PM
Post #1


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Sanny vs. Native Compiling


It's probably obvious that Sanny Builder won't compile exactly like Rockstar North's compiler did, but what's interesting is the subtle details left out of Sanny Builder's compilations compared to the original main.scm.


Comma Separation?

Let's look at this line.
SET_MENU_COLUMN $1153 0 'DUMMY' 'IE16' 'IE10' 'IE11' 'IE12' 'IE13' 'IE14' 'IE15' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'  // Sunday // Monday // Tuesday // Wednesday // Thursday // Friday // Saturday


Compiled with Sanny, it simply produces:
CODE
DB 08 02 04 12 04 00 09 44 55 4D 4D 59 00 00 00 09 49 45 31 36 00 00 00 00 09 49 45 31 30 00 00 00 00 09 49 45 31 31 00 00 00 00 09 49 45 31 32 00 00 00 00 09 49 45 31 33 00 00 00 00 09 49 45 31 34 00 00 00 00 09 49 45 31 35 00 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00


But the original main.scm, although producing the exact same length in bytes, has a little extra:
CODE
DB 08 02 04 12 04 00 09 44 55 4D 4D 59 00 00 00 09 49 45 31 36 00 2C 00 00 09 49 45 31 30 00 2C 00 00 09 49 45 31 31 00 2C 00 00 09 49 45 31 32 00 2C 00 00 09 49 45 31 33 00 2C 00 00 09 49 45 31 34 00 2C 00 00 09 49 45 31 35 00 2C 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00


See it? Ok, let me point it out.

The first string parameter of the original main.scm produces the following byte sequence:
'DUMMY':
09 44 55 4D 4D 59 00 00 00

Data type, then an 8 byte string. As normal. It's the parameter that sets the menu header. However, all of the next parameters have something extra:
'IE16':
09 49 45 31 36 00 2C 00 00
'IE17':
09 49 45 31 30 00 2C 00 00

The next byte, after the null-terminator is 0x2C, which is the hex code for the ASCII character , (comma).

So, maybe that's just nothing. But I believe it's a further hint to the syntax of the native script. Let's look at some of R*'s other short string uses in the GTA 3 source:
SCRIPT_NAME hj

Here, the string 'hj' is written literally, with no surrounding symbols. This could've maybe been a constant, since the compiled version is in uppercase and their constants weren't case sensitive.

Further below, with a GXT text label, the same thing:
PRINT_WITH_NUMBER HJ_IS cash_reward 2000 1 //"INSANE STUNT BONUS"


However, in other cases brackets surround the identifier. I believe these would be literal strings:
PRINT_HELP ( RCHELP ) //"Press |, or drive the RC car into a vehicle's wheels to detonate"


What about multiple strings?
PRINT_STRING_IN_STRING_NOW F_START PORT_W 5000 1 // The suspect is in the Callahan Point area.


But these seem to be constants, also...

My theory is that the original SET_MENU_COLUMN line would've been something like this:
SET_MENU_COLUMN menu_ie 0 DUMMY (IE16, IE10, IE11, IE12, IE13, IE14, IE15) DUMMY DUMMY DUMMY DUMMY DUMMY


The DUMMY lines don't have commas after them. I believe because DUMMY was a constant, like HJ_IS was. I think they could wrap multiple strings in ( ) and separate them with commas, but the compiler identified them as "IE16,", "IE10," etc. (as compilers often identify things by spaces) and simply inserted a terminator before the comma... That's the theory, anyway.

Though, this means that they would've wasted a byte in every short string. It certainly gives just a bit more of a hint into how their compiler built the main.scm, anyway...


More coming soon...?


--------------------
Go to the top of the page
 
+Quote Post
Michael.Knight1
post Sep 19 2012, 08:21 AM
Post #2


Member

Posts: 130
From: Germany
Joined: 24-March 12



deji can i use hex code in sanny builder as you show now ??

Example :


QUOTE
Let's look at this line.
CODE
SET_MENU_COLUMN $1153 0 'DUMMY' 'IE16' 'IE10' 'IE11' 'IE12' 'IE13' 'IE14' 'IE15' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY'  // Sunday // Monday // Tuesday // Wednesday // Thursday // Friday // Saturday


Compiled with Sanny, it simply produces:
CODE
DB 08 02 04 12 04 00 09 44 55 4D 4D 59 00 00 00 09 49 45 31 36 00 00 00 00 09 49 45 31 30 00 00 00 00 09 49 45 31 31 00 00 00 00 09 49 45 31 32 00 00 00 00 09 49 45 31 33 00 00 00 00 09 49 45 31 34 00 00 00 00 09 49 45 31 35 00 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00


--------------------
Michael Knight A shadowy flight into the dangerous world of a man who does not exist.
Michael Knight, a young loner on a crusade to champion the cause of the innocent, the helpless, the powerless, in a world of criminals who operate above the law.
Go to the top of the page
 
+Quote Post
Deji
post Sep 19 2012, 02:03 PM
Post #3


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



Why would you want to?


--------------------
Go to the top of the page
 
+Quote Post
Michael.Knight1
post Sep 21 2012, 08:10 PM
Post #4


Member

Posts: 130
From: Germany
Joined: 24-March 12



QUOTE (Deji @ Sep 19 2012, 03:03 PM) *
Why would you want to?

just i want to try , i can or no ??
He work like that or there other why of convert scm codes to hex ?? pinch.gif

Example :

CODE
0468: clear_car 0@ last_weapon_damage

To
CODE
30 34 36 38 3A 20 63 6C 65 61 72 5F 63 61 72 20 30 40 20 6C 61 73 74 5F 77 65 61 70 6F 6E 5F 64 61 6D 61 67 65


This post has been edited by Michael.Knight1: Sep 21 2012, 08:11 PM


--------------------
Michael Knight A shadowy flight into the dangerous world of a man who does not exist.
Michael Knight, a young loner on a crusade to champion the cause of the innocent, the helpless, the powerless, in a world of criminals who operate above the law.
Go to the top of the page
 
+Quote Post
Deji
post Sep 21 2012, 08:51 PM
Post #5


Coding like a Rockstar!

Group Icon

Posts: 1,468
From: ???
Joined: 28-May 09



What? Sanny Builder converts code to hex. If you want to look at it, open it in a hex editor.


--------------------
Go to the top of the page
 
+Quote Post
Michael.Knight1
post Sep 21 2012, 09:03 PM
Post #6


Member

Posts: 130
From: Germany
Joined: 24-March 12



QUOTE (Deji @ Sep 21 2012, 09:51 PM) *
What? Sanny Builder converts code to hex. If you want to look at it, open it in a hex editor.

I Can just view ?? so i can to write hex codes in sanny builder ...
Replace Scm Codes With Hex like you write before
QUOTE
Let's look at this line.
SET_MENU_COLUMN $1153 0 'DUMMY' 'IE16' 'IE10' 'IE11' 'IE12' 'IE13' 'IE14' 'IE15' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' 'DUMMY' // Sunday // Monday // Tuesday // Wednesday // Thursday // Friday // Saturday

Compiled with Sanny, it simply produces:
DB 08 02 04 12 04 00 09 44 55 4D 4D 59 00 00 00 09 49 45 31 36 00 00 00 00 09 49 45 31 30 00 00 00 00 09 49 45 31 31 00 00 00 00 09 49 45 31 32 00 00 00 00 09 49 45 31 33 00 00 00 00 09 49 45 31 34 00 00 00 00 09 49 45 31 35 00 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00 09 44 55 4D 4D 59 00 00 00


write hex , no panel codes ninja.gif



--------------------
Michael Knight A shadowy flight into the dangerous world of a man who does not exist.
Michael Knight, a young loner on a crusade to champion the cause of the innocent, the helpless, the powerless, in a world of criminals who operate above the law.
Go to the top of the page
 
+Quote Post
Reply to this postStart new topic

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members: