Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    2. News

    1. Red Dead Redemption 2

      1. News
      2. Red Dead Online
      3. The Armadillo Inn
    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

Deji

[REL|SRC] SCRambl

Recommended Posts

Deji

 

SCRambl

 

 

 

Download Current BETA

 

View Project

 

Info

SCRambl is a high-level SCR language assembler with an advanced modular design which allows for a deep level of customisation. Compiled SCR scripts are often used by desktop and game software which read the file and execute the appropriate code internally, allowing an easy lower-level way of creating content. SCRambl supports both headered and headerless script compilations with a wide range of support for changing the way their code is generated. SCRambl also has many preprocessor features including macro support and preprocessor blocks which allow for improved code management and maintainability within large projects.

 

SCR

SCR is a conceptual language based on BASIC, which provides a fully featured scripting environment while maintaining a relatively low learning curve. This language is considered incomplete as many decisions have still not yet been made. SCRambl tries to allow for complete customisation of the SCR syntax through the use of definition files, enabling it to be easily updated, expanded or redone, so much as to allow SCRambl to be used for a wide range of coding styles, optimisation techniques and required usages.

 

Features

  • Fast code parsing & compilation
  • Advanced preprocessor
  • High construct
  • Easy syntax expansion & customisation
  • Deeply customisable compilation
  • Accurate default SCR syntax
  • Fast hashing & lookups
  • Syntax expandable from within scripts
  • Macros, advanced preprocessor logic/integer expressions, preprocessor blocks
  • Fully working string functionality including special character ability using escape sequences
  • String escape sequences
  • Error detection
  • Useful warnings
  • Variable scoping
  • Configurable code optimisations
  • Operators and command overloading
  • Advanced configurable type matching and recognition system
  • File including

Future Features

  • Project support
  • Internal scripting engine
  • More customisability
  • Performance optimisations
  • Customisable header compilation

Examples

I started out by building up SCRambl to build a simple native script, debug.sc, which is found in SA's data folder. Once it got over compiling that, I started to make a dent on compiling some native GTA III scripts, which it got through quite well (though I had to remove III specific commands as I haven't built a catalogue of them yet) but I never finished parsing those fully. Eventually I started writing a short script which I am constantly adding and taking bits from to test individual features (test-script.txt) and decompiling them in Sanny Builder to verify the results.

 

Here are some of the more impressive abilities...

 

In-script Command Registering and Overloading

 

#register_command 0EEE MY_COMMAND(i,f,f)MY_COMMAND(1, 0.5, 0.5)   // compiles 0EE command#register_command 0FFF MY_COMMAND(f,f,f)MY_COMMAND 3.0 1.2 3.2

SCRambl allows you to define new script-specific commands which is great if you do something like hacking in a new opcode using the script or have added new opcodes using another project-specific file which you don't want to keep globally or wish to share easily. Since the command is defined in the script, no one you give the script to will have to edit any of their configuration files in order to add new opcodes. The syntax of the preprocessor command "register_command" is much like the commands.ini syntax with a few restrictions such as not being able to define an unknown/NOP command.

 

You can then use a newly registered command after it has been defined or overload it. The first use of MY_COMMAND compiles the 0EEE opcode, because it uses an integer for the first parameter. The second use compiles the 0FFF opcode, because it has a float instead. SCRambl searches through command overloads to find the most fitting one for the job. If the 0EEE variation didn't exist, writing an integer as the first parameter would compile the 0FFF variation using an integer for the float. You can do the same if the 0FFF variation didn't exist. However, a warning will be produced saying that converting a float to int may result in a loss of data.

 

Native Control Structures

 

VAR_INT counter REPEAT 5 counterWAIT 0ENDREPEAT

 

Decompiled in SB3:

 

:NONAME_7WAIT 0 $PLAYER_CHAR += 1   $PLAYER_CHAR > 5 GOTO_IF_FALSE @NONAME_7

 

Script Constant Support + Local Variable Scope + Arrays + Enumerators + Long Math Lines (lol)

 

#constflval FLOAT 4.0#endconst {    LVAR_INT int_var int_arr[4] int_idx    LVAR_FLOAT float_var    int_arr[int_idx] = 69    // [email protected]([email protected],4i) = 69    int_var = TRUE    // [email protected] = 1    int_var += 5 + 4 + timera + 2 + 1   // >> /*        [email protected] += 9        005A: [email protected] += [email protected] // (int)        [email protected] += 3    */    int_var -= timera    // 005A: [email protected] += [email protected] // (int)    int_var -= PAD1    // usage of an enumerator as a value    int_var = flval    // 0062: [email protected] -= [email protected] // (int) (causes float-to-int warning)    float_var = flval    // [email protected] = 4.0}

 

Built-in Model Constants + Macro's

 

#define DEFAULT_WAIT_TIME (250 + 5)   // obviously DEFAULT_WAIT_TIME will be 255#define INTERRUPT WAIT DEFAULT_WAIT_TIME   // now we can write "WAIT 255" using the macro "INTERRUPT" #define SuperVar LVAR_STRING   // yes, SCRambl will be able to turn SuperVars into a full compiler extension #if (defined(SuperVar)) + 2 == 3    // this returns true, so "WAIT 255" is produced instead of "WAIT 0"INTERRUPT#elseWAIT 0#endif INTERRUPT   // of course, there are much better ways to use macros... SUPERVAR SVar    // guess what? we just declared a SuperVar! easy as 1, 10, 11... get it? #define ADD_MALE_CHAR CREATE_CHAR DEFAULT_MALE_CHAR 0.0 0.0 0.0CREATE_CHAR PEDTYPE_CIVMALE male01 0.0 0.0 0.0 male_charADD_MALE_CHAR male_char

 

Decompiled in SB3:

 

WAIT 255 WAIT 255CREATE_CHAR 4 #MALE01 0.0 0.0 0.0 $PLAYER_ACTOR CREATE_CHAR 4 #MALE01 0.0 0.0 0.0 $PLAYER_ACTOR

 

Pretty cool if I do say so myself...

 

 

The Manual

A manual is provided with each version of SCRambl, which documents the features in that version. The manual comes in HTML format, using JavaScript to make it easier to browse and read. This documentation has been tested working with the latest versions of Mozilla Firefox and Google Chrome.

 

An online copy of the documentation for latest version SCRambl can be found at: https://dl.dropboxusercontent.com/u/46693209/MANUAL.htm

 

 

Manual

View Project (changes)

Edited by Deji

Share this post


Link to post
Share on other sites
Seemann

Thanks for sharing. Wish you were more active on the projects like this one.

 

I've tried to test it and got an error:

http://imgur.com/UYBkgC6

 

I run it with the run.bat, the config.ini contains a proper path to the GTA sa folder.

 

Edited by Seemann

Share this post


Link to post
Share on other sites
Deji
Thanks for sharing. Wish you were more active on the projects like this one.

 

I've tried to test it and got an error:

http://imgur.com/UYBkgC6

 

I run it with the run.bat, the config.ini contains a proper path to the GTA sa folder.

My bad, run.bat has not been updated since early stages. I'd been using Visual Studio's Debugger to run the program post-build. The input file error is simply that it cannot locate the file from the path given in run.bat. I've updated a bunch of files so it is easier to work out of the box and fixed the release version, though if you want the juicy inner details of SCRambl's processing mechanisms (sounds so great when I say it like that), the Debug version is pretty sweet. Checkout the new revision and it should work fine.

Share this post


Link to post
Share on other sites
Seemann

Is there a way to download all the sources in one time rather than dl-ing them one by one file?

Share this post


Link to post
Share on other sites
Deji

 

Is there a way to download all the sources in one time rather than dl-ing them one by one file?

Yes, checkout the code with SVN: https://code.google.com/p/project-scrambl/source/checkout

 

I use TortoiseSVN which has a GUI and context extension... Once installed, right click in any folder in explorer and click "SVN Checkout...". Use Google Code's svn trunk URL and all the files will be sent straight there. I sound like a pro but it took me hours to crack uploading it from scratch, but to be fair, it's pretty stupid that I had to checkout nothingness in order to update it...

 

I amended the first post with some show-off code examples and a features list.

Share this post


Link to post
Share on other sites
LINK/2012

Good to see that a SCR compiler is finally 'out'.

I really wish to contribute to this project (and CLEO too, listen that Seeman!), but since day by day I walk way from modding that may not happen, but I really want and will try to involve myself into it...

 

Share this post


Link to post
Share on other sites
Deji

I've started a TODO list on the Project Page. Will finish later and try to have CASE statement parsing complete.

 

EDIT: Done the TODO list. It's actually amazing, so little left to be done wink.gif

Edited by Deji

Share this post


Link to post
Share on other sites
Deji

Finished CASE statement implementation.

 

Anyone (Silent?) know how functions are made in VCS?

Share this post


Link to post
Share on other sites
Seemann

Functions are supported in LCS too (opcodes 05AE, 05AF). They should work in the same way as the ones in CLEO 3 (0AB1).

Share this post


Link to post
Share on other sites
Deji
Functions are supported in LCS too (opcodes 05AE, 05AF). They should work in the same way as the ones in CLEO 3 (0AB1).

I mean natively though... As far as I know, the CALL commands do not have any parameters aside from the label of the function. I guess the function has to be declared so that the compiler can check number of parameters etc. I was planning to extend this to functions using CLEO too, but with native syntax (and maybe a few extra features too).

 

I think it should be declared something like:

FUNCTION [name] (params in/out? they must need separation by a word or something)

 


ENDFUNCTION

 

Not sure, though.

Share this post


Link to post
Share on other sites
Seemann

 

FUNCTION SQR LVAR_INT ARET A * AENDFUNCTIONLVAR_INT foofoo = SQR 5

 

just an idea

Share this post


Link to post
Share on other sites
Wesser

We should get the cue from other native statements. In my opinion, no construct is used to declare the beginning or the end of a function. It does work like a script, a mission or a trigger, that is it starts by a label. I believe, R* programmers set another type of local for input and output variables, let's call them IVAR and OVAR, whose difference is visibile only to the compiler. Other locals declared with LVAR prefix are interpreted as script variables. Indeed, a problem may arise when parsing them, because you must check for all declared variables as you need to order them by preceding the input values before the returning variables and the script locals, which forces you to make more parses during the compilation (oh well, not necessarily). Anyway, this might be a faithful reproduction of the original function-script:

 

 

Decompiled user posted image user posted image Compiled
CALLA function [{anyvalue0|varname0} ... {anyvalueN|varnameN}]CALLB function [{anyvalue0|varname0} ... {anyvalueN|varnameN}][...]function:{   [{IVAR|OVAR|LVAR}_{vartype} {varname0}[,] [... {varnameN}]]   [...]   //RETURN_TRUE   //RETURN_FALSE   RETURN}

 

{05AE}{05AF}[....] ----[....]{00C5}{00C6}{0051}

 

{037A}{037B}[....] ----[....]{00C5}{00C6}{0051}

 

CALLA function {inputargs} {outputvars} {parentvars} [{anyvalue0|varname0} ... {anyvalueN|varnameN}]CALLB function {inputargs} {outputvars} {parentvars} [{anyvalue0|varname0} ... {anyvalueN|varnameN}][...]function:[...]//RETURN_TRUE//RETURN_FALSERETURN

 

However, the difference between CALLA and CALLB (ofcourse, they are likely definitions) is still unknown. If someone is quite familiar with MIPS assembly may point out the riddle.

Edited by Wesser

Share this post


Link to post
Share on other sites
Silent

 

However, the difference between CALLA and CALLB (ofcourse, they are likely definitions) is still unknown. If someone is quite familiar with MIPS assembly may point out the riddle.

Ur lying tounge2.gif

 

In VCS, 037A calls a function with NOT flag set (return_true/return_false is inverted). 037B is a call without a flag. I believe it applies to LCS 05AE and 05AF aswell. Therefore, I think 037B/05AF was just CALL or CALL_FUNCTION, while 037A/05AE may have been compiled from something like NOT CALL or NOT CALL_FUNCTION. Ot they were just different functions, who knows. They probably were separate, seeing how easy proper NOT flag for calls can be implemented (took me several minutes in VCSPC).

 

The only unknown thing with calls is the 3rd param yet - I would assume it can be ignored though. I've been testing it with VCS and haven't noticed anything interesting.

Edited by SilentPL

Share this post


Link to post
Share on other sites
Deji

Thanks Wesser. That actually reminds me very much of something... I think I recall seeing somewhere where a similar thing was written (god knows where.. maybe it was a dream). Also it makes me realise that "external scripts" are probably written in a similar way. The first couple of LVAR's are usually reserved for particular purposes: trigger entity handles, trigger types.

 

Unfortunately, I didn't build my mind palace until recently, so I will have to bang my head with some books to see if the memory of the code falls out...

Share this post


Link to post
Share on other sites
Wesser

 

In VCS, 037A calls a function with NOT flag set (return_true/return_false is inverted). 037B is a call without a flag. I believe it applies to LCS 05AE and 05AF aswell. Therefore, I think 037B/05AF was just CALL or CALL_FUNCTION, while 037A/05AE may have been compiled from something like NOT CALL or NOT CALL_FUNCTION. Ot they were just different functions, who knows. They probably were separate, seeing how easy proper NOT flag for calls can be implemented (took me several minutes in VCSPC).

As far as I remember, both commands are used as conditions, but 05AF doesn't as procedure in LCS. I probably misunderstand what you are saying, but they might differ according to the truthfulness of the NOT flag. In this regard, a plausible definition of each command would be respectively CALL and CALLNOT. I'm still quite unsure, because in III we have IF/IFNOT and WHILE/WHILENOT which affect the constitution of the whole construct by swapping GOTO_IF_FALSE with GOTO_IF_TRUE.

 

 

The only unknown thing with calls is the 3rd param yet - I would assume it can be ignored though. I've been testing it with VCS and haven't noticed anything interesting.

The third argument helps the game knowing how many locals of the parent script it should save, those which get restored after returning back to the caller.

 

 

It makes me realise that "external scripts" are probably written in a similar way. The first couple of LVAR's are usually reserved for particular purposes: trigger entity handles, trigger types.

Yeah, we can try to move even closer to the truth by getting rid of IVAR type and overwriting OVAR with CVAR or rather RVAR (in this way LVAR and RVAR locals would also acquire the meaning of left and right variables). Doing so, we are able to distinguish every local simply by assuming which couple of them is reserved for the output variables.

Edited by Wesser

Share this post


Link to post
Share on other sites
Ss4gogeta0

devil.gif I know a code monkey that would be interested in experimenting with this... I myself am not much of a coder (I use the DM Language for most of the projects i work on so other than that I am left in the dark...) hmmm maybe i can get off my ass and learn scr...

 

-Inane babble sent from my Ipad....

Share this post


Link to post
Share on other sites
Deji
devil.gif I know a code monkey that would be interested in experimenting with this... I myself am not much of a coder (I use the DM Language for most of the projects i work on so other than that I am left in the dark...) hmmm maybe i can get off my ass and learn scr...

 

-Inane babble sent from my Ipad....

I've been working on "The SCR Manual" for quite a while. It aims to be a tutorial as well as a complete reference of everything SCR.

 

 

In other news, I have implemented the #hex..#endhex construct. Not only does it allow inputting RAW HEX, it supports macros, variables, labels, commands... well, just see for yourself:

SCRambl Code

 

#constDT_DWORD  	INT 1DT_LVAR    INT 3DT_BYTE    INT	4DT_WORD    INT	5DT_TEXTLABEL  INT	9DT_VARLEN_STRING	INT	14#endconst{LVAR_INT scr_lvar#hexSCRIPT_NAME DT_TEXTLABEL 4D41494E00000000 /* 'MAIN' */DO_FADE DT_BYTE 00 DT_BYTE 002C04 DT_WORD 93000D03 DT_WORD BB00GOTO DT_DWORD hex_label0600 DT_LVAR scr_lvar DT_DWORD hex_labelhex_label:PRINTSTRING DT_VARLEN_STRING 08 "SCRambl" 00#endhex}

 

 

Since HEX constructs are not part of native syntax, # is used. This symbol is used to identify compiler specific directives and constructs.

SCRIPT_NAME is replaced with the 2-byte opcode.

DT_TEXTLABEL is a constant which is already defined as 9, so it takes up 1 byte (unlike some of the things you can have in the HEX construct, its size isn't fixed and depends on the data size).

Then proceeds some actual raw HEX input. The preprocessor would reject it if it had an odd number of characters.

Further down, we have a GOTO command with hex_label as the label pointer. It will be replaced with an absolute 4 byte label pointer as usual (in the ASM construct I plan to make label pointers relative).

On the next line, a scr_lvar is used. As you may guess, the replacement will be the 2-byte variable index.

After that is a label. Labels can be written in the HEX struct the same way they can be written in normal code.

Finally, "SCRambl" is a raw character sequence. Strings must be enclosed in quotes in HEX constructs, unlike elsewhere in scripts. No terminator or size specifier is automatically added for these.

 

Note that data types are not included automatically. Same principles you may be used to in Sanny Builder apply in most cases.

 

Decompiled in SB3 (opcodes added for comparison)

 

03A4: SCRIPT_NAME 'MAIN' 016A: DO_FADE 0 0 042C: SET_TOTAL_NUMBER_OF_MISSIONS 147 030D: SET_MAX_PROGRESS 187 0002: GOTO @MAIN_44 0006: [email protected] = -44 :MAIN_440662: PRINTSTRING "SCRambl"

 

 

The only restrictions are that operators cant be used in HEX constructs and overloaded commands won't work as there are no params for the preparser to choose a specific command.

 

So, a very successful new feature implemented. May I point out that now SCRambl has pretty much everything you need to write full-functioning CLEO scripts for San Andreas? I mean, I can't think of anything that's missing yet... yell at me if you find something missing.

Share this post


Link to post
Share on other sites
Ss4gogeta0
May I point out that now SCRambl has pretty much everything you need to write full-functioning CLEO scripts for San Andreas? I mean, I can't think of anything that's missing yet... yell at me if you find something missing.

Hmmm... Is there anyway to impliment some kind of mission builder support?

Share this post


Link to post
Share on other sites
Deji
May I point out that now SCRambl has pretty much everything you need to write full-functioning CLEO scripts for San Andreas? I mean, I can't think of anything that's missing yet... yell at me if you find something missing.

Hmmm... Is there anyway to impliment some kind of mission builder support?

That's the main aim. SCRambl can now compile CLEO scripts which are just headerless scripts like those found in script.img... All we need to do is add support for headered scripts and we'll be able to build SCM files from scratch (not with script.img support though). Then we've just got subscript abilities to add for a higher level of scripting which will result in a fully native experience. After that, I'm thinking of making SCRambl start handling project files, so one file will combine all the scripts you're working on, define the specifics of the project and allow you to combine multiple separate files into full mission scripts including those in script.img.

Share this post


Link to post
Share on other sites
Ss4gogeta0
May I point out that now SCRambl has pretty much everything you need to write full-functioning CLEO scripts for San Andreas? I mean, I can't think of anything that's missing yet... yell at me if you find something missing.

Hmmm... Is there anyway to impliment some kind of mission builder support?

That's the main aim. SCRambl can now compile CLEO scripts which are just headerless scripts like those found in script.img... All we need to do is add support for headered scripts and we'll be able to build SCM files from scratch (not with script.img support though). Then we've just got subscript abilities to add for a higher level of scripting which will result in a fully native experience. After that, I'm thinking of making SCRambl start handling project files, so one file will combine all the scripts you're working on, define the specifics of the project and allow you to combine multiple separate files into full mission scripts including those in script.img.

monocle.gif This would be the perfect tool for Total Conversions... who knows, maybe a number of them will actually come back from development hell...

 

Keep up the good work Deji icon14.gif

 

oh also, think you could take a look at this topic? since you have a fairly decent knowledge of the coding used in San Andreas.

Parallel Execution of GTA

 

 

Share this post


Link to post
Share on other sites
lucky cthulhu

pretty good!

Share this post


Link to post
Share on other sites
Jason Statham

I've tried to compile a test-script.txt but I go an error:

http://imageshack.us/photo/my-images/9/lzoz.jpg/

 

Ok, my bad, I forgot to add a gta sa path to config.ini file xD.

Edited by juarez

Share this post


Link to post
Share on other sites
Deji

Okay, this has me really stumped. From the GTA 3 source we see that scripts have their own file and started by START_NEW_SCRIPT. These .sc files must be compiled to the .scm file in a particular order, but I can't figure out which. I collected this data:

 

(In order of reference)COMMAND - OFFSET - SCRIPT NAMESTART_NEW_SCRIPT - 81837 - ODDVEHSTART_NEW_SCRIPT - 76402 - R3START_NEW_SCRIPT - 75338 - GYMSTART_NEW_SCRIPT - 75007 - SHOOTSTART_NEW_SCRIPT - 80584 - BLOODRSTART_NEW_SCRIPT - 80727 - HOTRSTART_NEW_SCRIPT - 80933 - KICKSSTART_NEW_SCRIPT - 87487 - PSAVE1START_NEW_SCRIPT - 95290 - FLOWSTART_NEW_SCRIPT - 92234 - HELPSTART_NEW_SCRIPT - 85611 - COLLSSTART_NEW_SCRIPT - 98759 - CRANESSTART_NEW_SCRIPT - 83417 - BUY_PROSTART_NEW_SCRIPT - 84314 - VALET_LSTART_NEW_SCRIPT - 84640 - ADPLANESTART_NEW_SCRIPT - 84518 - TRAINSLSTART_NEW_SCRIPT - 83601 - IMPND_LSTART_NEW_SCRIPT - 99724 - OPENUPSTART_NEW_SCRIPT - 81211 - TRI(these are in order, however...)LAUNCH_MISSION - 101930 - (noname 1)LAUNCH_MISSION - 103838 - (noname 2)LAUNCH_MISSION - 106476 - (noname 3)LAUNCH_MISSION - 117407 - (noname 4)LAUNCH_MISSION - 118248 - (noname 5)LAUNCH_MISSION - 120466 - (noname 6)LAUNCH_MISSION - 135692 - APCHECKLAUNCH_MISSION - 139805 - GFINITLAUNCH_MISSION - 154860 - (noname 7)LAUNCH_MISSION - 158295 - (noname 8)LAUNCH_MISSION - 159718 - HJLAUNCH_MISSION - 162112 - CELLFON

 

 

Scripts aren't ordered alphabetical, nor in order of reference.

 

So I don't get how the compiler knows when to compile these scripts. Missions are obviously compiled in the order which they are started in, but the scripts are in a seemingly random order...

 

Luckily, I can assume that this:

 

{58215} 0914: NOP 0 {58219} 0914: NOP 1 {58223} 0914: NOP 2 {58227} 0914: NOP 3 {58231} 0914: NOP 4 {58235} 0914: NOP 5 {58239} 0914: NOP 6 {58243} 0914: NOP 7 {58247} 0914: NOP 8 {58251} 0914: NOP 9 {58255} 0914: NOP 10 {58259} 0914: NOP 11 {58263} 0914: NOP 12...

 

 

Would be written something like:

 

DECLARE_STREAMED_SCRIPT plchute.sccDECLARE_STREAMED_SCRIPT parach.sccDECLARE_STREAMED_SCRIPT cokec.scc

 

 

Otherwise they would be in random order too. I assume the .scc format as miss2 decides between that and .scm format and I reckon they are non-headered (singlefile) scripts. Not used in III/VC but not an idea completely new to SA.

Share this post


Link to post
Share on other sites
Wesser

I really don't see where's the problem, Deji. Scripts are compiled in the order they are put. tounge.gif

 

This is how the SCM is structured internally (after being compiled).

Share this post


Link to post
Share on other sites
Deji
I really don't see where's the problem, Deji. Scripts are compiled in the order they are put. tounge.gif

 

This is how the SCM is structured internally (after being compiled).

Well, first of all, that wiki section makes no mention of scripts (which should come between main and foreign gosub), although it has subscripts, which aren't started by START_NEW_SCRIPT (and are treated as submissions). I already know the structure of the main.scm, I documented that ages ago. But order of the individual files within that structure is a different thing.

 

The scripts which I posted above are not in order, as you can clearly see:

 

START_NEW_SCRIPT - 81837 - ODDVEH - started first

START_NEW_SCRIPT - 76402 - R3 - started second. offset shows it is before ODDVEH

START_NEW_SCRIPT - 75338 - GYM - started third, offset shows it is before R3

START_NEW_SCRIPT - 75007 - SHOOT - started fourth, offset shows it is before SHOOT

START_NEW_SCRIPT - 80584 - BLOODR - started fifth, offset shows it is before ODDVEH

 

Unless all those listed scripts are actually written within the main.sc file which would be weird because 'R3' is on it's own in the III mobile source, there's no straight forward explanation for this.

Share this post


Link to post
Share on other sites
Wesser

I was referring to those scripts which are within a file, it was implied ofcourse. They do not follow any order when compiling (the wiki doesn't mention them for a purpose). For instance, R3 script is placed before ODDVEH but it is started afterwards. However, these are main.sc scripts.

 

 

Unless all those listed scripts are actually written within the main.sc file which would be weird because 'R3' is on it's own in the III mobile source, there's no straight forward explanation for this.

Are you sure? If a remember correctly, main.sc is the only missing file and because of this we cannot have access to R3 script (which is unnamed, though).

Share this post


Link to post
Share on other sites
Deji
I was referring to those scripts which are within a file, it was implied ofcourse. They do not follow any order when compiling (the wiki doesn't mention them for a purpose). For instance, R3 script is placed before ODDVEH but it is started afterwards. However, these are main.sc scripts.

 

 

Unless all those listed scripts are actually written within the main.sc file which would be weird because 'R3' is on it's own in the III mobile source, there's no straight forward explanation for this.

Are you sure? If a remember correctly, main.sc is the only missing file and because of this we cannot have access to R3 script (which is unnamed, though).

Ohh my bad, I was getting HJ and R3 purposes mixed up tounge.gif I'm not able to decompile the III main.scm on this computer. I've already downloaded SA + IDA + a tonne more modding stuff and I have to try and keep the presence of this stuff unknown to the laptop owner tounge2.gif

 

So I guess the main.sc file includes quite a huge portion of game code. I think I have all the knowledge needed to start working on complete MAIN compilation after I'm done trying to implement the assembler feature now smile.gif

 

I might also try to write up a main.sc file for GTAIII based on the III main.scm if I can decompile it.

Share this post


Link to post
Share on other sites
Wesser

I would suggest you to integrate NASM for ASM...ENDASM construct to assembly or disassebly ASM codes. Also, you should create a new section in the header (the game will skip it at the time it parses the GOTO) to store all the labels of ASM and HEX statements to make decompilation possible when these have been present in the source.

 

By the way, coding a self-made assembler and disassembler would be ideal, eh. tounge2.gif

Share this post


Link to post
Share on other sites
Deji
I would suggest you to integrate NASM for ASM...ENDASM construct to assembly or disassebly ASM codes. Also, you should create a new section in the header (the game will skip it at the time it parses the GOTO) to store all the labels of ASM and HEX statements to make decompilation possible when these have been present in the source.

 

By the way, coding a self-made assembler and disassembler would be ideal, eh. tounge2.gif

Creating an assembler would be awesome, but I figure it's harder than it might first seem. Especially to make it fast. I was going to use FASM but I'll have a look at NASM. FASM uses some really strange way of encoding assembly which I'm still having trouble figuring out. With NASM I'm more confused because my tiny windows based brain cant figure out why I've got so many errors/warnings compiling this tounge.gif

Share this post


Link to post
Share on other sites
Deji

Tried creating an assembler, kinda started to doubt my ability when I notice that EVERY BIT in EVERY BYTE can be changed to produce loads of instructions more than just the opcode byte. After I get other things done, I might continue some work towards a custom assembler for SCRambl, but for now I think it's better to just hand the code over to the precompiled nasm.exe file.

 

 

GOTO skip_asmLVAR_INT instruction_ptr, var_ptr, func_ptr#ASMval2change:MOV eax, DWORD 0x0              ; the 0 value will be 4 bytes long - will be replaced by script var base addressMOV ecx, func_ptr                ; will be replaced by 2, the func_ptr LVAR indexMOV eax, [eax+ecx*4]            ; get the pointer to the func_ptr LVAR and read to eaxCALL eax                        ; call the value stored in func_ptr#ENDASMskip_asm:GET_LABEL_POINTER val2change instruction_ptrinstruction_ptr++GET_THIS_SCRIPT_STRUCT var_ptrvar_ptr += 0x3CWRITE_MEMORY instruction_ptr 4 var_ptr FALSE   // write this scripts local var base address to the ASM code

 

 

And that's been done. Now SCRambl has support for #asm..#endasm structs, where assembly code can be written. Labels declared with in the ASM struct are accessible from outside of it as well, however you unfortunately can't reference external labels as-of-yet. I may find a good way to do this in the future, but it requires a tonne of hacky code which may reduce compilation effeciency greatly. Also, unlike all other code in SCRambl, ASM code is not all converted to upper-case by the preprocessor meaning it is case-sensitive. This means that any external references such as variables (which are translated into their respective var indexes) and macros (which I've actually not tested yet, but the chances of them not working are very slim since they are 'fed' through the preprocessor at a very low level). The example code calls the param-less function stored in func_ptr. Not a very useful snippet, but it shows off some features. SCRambl uses The Netwide Assembler for its assembling, so if you have questions about anything from #asm to #endasm, that site is probably where you'll find the answer. SCRambl can Assembl!

 

Now I'm about to do a code cleanup and add some extra quick features (including C-style function-like macros, which WILL be awesome). After that, I want to aim towards releasing a BETA of SCRambl as an SA CLEO script compiler. Lots of testing will need to be done and I hope these features will inspire people to come up with some creative ways to write some technologically advanced scripts, because I've thought of quite a few myself wink.gif

 

 

EDIT: Sorry guys, will probably be inactive again for a while now. I've put up the latest revisions of the source so in the slight chance anyone's up to trying to understand my code and do some stuff, it's all yours! tounge2.gif

Edited by Deji

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 1 User Currently Viewing
    0 Members, 0 Anonymous, 1 Guest

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.