SA ScrDebug
Information | Screenshot | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
DownloadDisclaimer: GTAG cannot be held responsible for any user submitted files. | Rating | |||||||||||||||||||||
| ||||||||||||||||||||||
Title | SA ScrDebug | |||||||||||||||||||||
Author | Deji | |||||||||||||||||||||
Games | ![]() | |||||||||||||||||||||
Version | 0.5 | |||||||||||||||||||||
Summary | Rockstar-style script debugging reimplementation. | |||||||||||||||||||||
Rating | 5 (2 votes) | |||||||||||||||||||||
Submitted | 29 Jun 2011 | |||||||||||||||||||||
Updated | 20 Sep 2012 |
Description |
---|
ScrDebug Description During the development of GTA: San Andreas, Rockstar North used many features built-in to their scripting engine to aid debugging of scripts. Hacks, hidden modes, teleportation cheats, mission skippers, they had used them all. Obviously these features had to be locked away before San Andreas was released. This mods purpose is to re-implement them. Little is known of Rockstars original debugging opcodes aside from what can be found in the GTA IV natives list and their usage within the main.scm and scripts in the script.img archive. However, I believe ScrDebug reimplements most opcodes with near exact functionality (if not, better). There are several reasons to use this mod. One is that it enables certain "cheats" while playing San Andreas (gaining lives in arcade games, auto-aiming in pool game, skipping missions, increasing stats etc). Another is that, with some edits of SCM, it can be made to output information about SA Levels never before understood (see sapool.log in the ScrDebug folder). But the best reason is for debugging of your own script mods. You can happily setup debug scripts and leave the debug code in there. The debug code is only enabled for those who have ScrDebug, thus not ruining a mod users gameplay with unexpected happenings. Even if you do want to remove the debug code after, most of these additional opcodes are very handy. Compatibility This mod supports the following .exe's:
Configuration An INI is included with this mod for customisation. You can toggle each opcode individually All opcodes are enabled by default. Feel free to disable opcodes when required. There are two sections for opcodes. RsOpcodes contains opcodes that aim to simulate Rockstar's original debugging opcodes. NewOpcodes contains completely new opcodes which previously acted as NOP's (although similar opcodes may have existed of Rockstars). In the Debug section, these settings exist:
New Opcodes 00CC 00CC - BREAKPOINT [No params] When executed, the game will minimize and be frozen in it's current state. A HTML file named CRunningScript (open it in your web browser) will be placed in the SADebug folder which contains a list of the script variables (or mission variables, if a mission ran this opcode) and other information about the current script. Global Variables 2-1023 are also currently outputted (I will increase the range in a later version). Information about the script object will also be written, including the address of it and the IP address, with which Cheat Engine can be used to further inspect the script. RsOpcodes 0052 0052 - PRINTVECTOR 98@ 100@ $TEMPVAR_FLOAT_3 99@ 100@ $TEMPVAR_FLOAT_3 [In] Float value [In] Float value [In] Float value [In] Float value [In] Float value [In] Float value Calculates the vector (difference between two 3D coord points) and prints the result on-screen. 03A7 03A7 - SAVE_INT_TO_DEBUG_FILE $CURRENT_WANTED_LIST [In] Int value This opcode saves a number to the debug file, duh. Rockstar would have used it to check that values were correct. 03A8 03A8 - SAVE_FLOAT_TO_DEBUG_FILE 208@ [In] Float value Just like 03A7 but for float numbers. 03A9 03A9 - SAVE_NEWLINE_TO_DEBUG_FILE [No params] Writes a newline to the debug file. 05B6 05B6 - SAVE_STRING_TO_DEBUG_FILE 1 // CURRENT_WANTED_LIST = [In] void This saves a string to the debug file. The value is an immediate 128 byte sequence. Unfortunately, Sanny removes this and replaces it with an integer, which refers to a place within it's debug.bin file - change that file if you wish to output strings. It's not easy, though. In the example, it outputs "CURRENT_WANTED_LIST = " to the debug file. This goes right before the 03A7 example seen above. After that comes 03A9. So if the value of $CURRENT_WANTED_LIST was 2, it would output CURRENT_WANTED_LIST = 2 To a line in the debug file. Effective. 065D PRINTINT $6443 "M_STAGE" [In] Int value [In] 40 character string This prints an integer, followed by a string, on-screen (a space is added between the string and integer automatically). 065E 065E - PRINTFLOAT "CHIP_SET_Z" $9387 [In] 40 character string [In] Float value This prints a float, followed by a string, on-screen (a space is added between the string and integer automatically). 0661 0661: "Message" Prints a debug help message. This may have originally been a variation of PRINTSTRING, but as it's unused in the main.scm I decided to give a slightly different function for it. 0662 PRINTSTRING "AAAAAAAAA" [In] 40 character string This prints a string on-screen. There can be a total of 12 strings printed onscreen at any time. The list of recent strings will appear at the side of the screen. This can be altered in the INI. 0663 PRINTINT "IGFIDX" $GIRLFRIEND [In] 40 character string [In] Int value This prints a string, followed by an integer on-screen (a space is added between the string and integer automatically). 0664 PRINTFLOAT "CHIP_SET_Z" $9387 [In] 40 character string [In] Float value Like 0663 but with a float instead of an integer. 0735 IS_KEYBOARD_KEY_PRESSED 0x31 [In] See here: http://gtagmodding.com/forums/index.php?showtopic=590 (also supports common ASCII keycodes) This opcode is found to have the functionality of a keypress opcode. It tests if a key is being pressed. Most values found in the main.scm relate to ASCII keycodes exactly ("S" is used to skip most missions, number keys used to go to different mission stages, etc). However, there are certain values found in the main.scm which do not relate to any ASCII keycode. I would assume either Rockstar had special values for certain keys or an alternate form of input was used while testing. Also consider that they would've developed SA with a PS2 Debugging Unit, so god knows what special hardware they could've hooked up to it... 0736 IS_KEYBOARD_KEY_JUST_PRESSED 0x20 [In] See here: http://gtagmodding.com/forums/index.php?showtopic=590 (also supports common ASCII keycodes) This opcode is like 0735. However when the key is pressed, this opcode only returns true once. Thus preventing looping of any key. So if the code was set to do something when that key was pressed, it would only happen once per press. Very useful. Especially over 0AB0. 086A PRINTNL? [No params] This opcode clears all the printed debug messages. 091A 091A - STORE_DEBUG_COMMAND (GET_CONSOLE_COMMAND? GET_BUFFERED_ASCII?) [Out] 16 character string (v$ or @v) This opcode returns the last 16 characters of entered cheat input. It's unknown how the input was originally produced, but the use is easily determinable from an exerpt of the GFAGNT script in the main.scm 08F8: show_update_stats 1 0004: $GF_WAIT_TIME = 500 0051: return // a label would have been here, and a GOSUB to it would have been called elsewhere 091A: store_debug_command v$1221 if 8846: not is_string_null v$1221 then 06D1: v$1225 = "DOCOOCHIE" // coochie == denise if 08F9: compare_string v$1225 v$1221 then So somehow, the developers could input text and it could be recieved via 091A (and maybe elsewhere within the EXE?) in order to activate cheats within the scripts. The only use of this that still exists is in the GFAGNT script, but as that part of the script is never executed, main.scm modification is required to unlock the commands. Or maybe they DID just use cheat input. If so, they would've had to have had another key somewhere to run 091B to clear the cheat string in case they made a typo while entering the cheat string. 091B CLEAR_DEBUG_COMMAND (RESET_CONSOLE_COMMAND?) [No params] Clears the cheat code input. RESET_CONSOLE_COMMAND is a NULL GTA4 native command name. A lot of NULL GTA4 functions are names of commands that existed in GTASA, however many aren't. Since this is the only remotely relatable name for 091B, and fits in with 091A, it gives room to believe that there could have been "console commands" used to trigger these cheats. But, maybe not. Changes ScrDebug 0.1b1 - Fixed some stability issues with text draw by clearing printed text on game restart. ScrDebug 0.1b2 - Fixed all remaining stability issues with text draw by moving function position. - Altered text style to look more like the debug text seen in early GTA:SA screenshots. ScrDebug 0.2 - Added 086A - Fixed bug where one of the debug messages would remain after game restart. - Added 00CC ScrDebug 0.3 - Extended 00CC - Debug file name now chosen automatically based on script name (each script gets its own log file) ScrDebug 0.4 - Added 091A - Added 091B ScrDebug 0.5 - Added 0052 - Added 065D - Added 065E SCM Features One of the things that made me finally update ScrDebug to add 091A and 091B were because I wanted them for the Black Market mod. But I also realised how many debugging features in the SCM were still completely locked away, even with this mod. Perhaps one day I'll try to create a version of the main.scm which unlocks all of these without the need to start a new game. But for now, I'll just show you how to enable the most relevant one. To enable cheat commands in the GFAGNT script WITHOUT having to start a new game, decompile the main.scm and make the following modifications... Replace (offset = 141299): ADD_BLIP_FOR_COORD 0.0 0.0 0.0 $GirlMarker[5] With: HEX 00 00 00 00 00 00 00 00 00 00 00 00 00 END Find (offset = 141401): :GFAGNT_335 WAIT $GF_WAIT_TIME Add BELOW: GOSUB @GFAGNT_DEBUG Find (offset = 152385): 091A: NOP v$1221 Add ABOVE: :GFAGNT_DEBUG To use the offsets, decompile the main.scm with "CODE_OFFSETS" enabled in SB's Debug Options and use Ctrl+F (Find) to search for the line via it's offset, e.g. "{141299}". |