Advertisement
Deji

TactileCheat

Jan 18th, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.88 KB | None | 0 0
  1. /*********************************************
  2. * GInput CLEO Extension
  3. * Tactile Cheat Activation
  4. * written by Deji
  5. * http://gtag.gtagaming.com
  6. * Compile with SCRambl (v1.0.41 or later)
  7. *********************************************/
  8.  
  9. #pushcfg "CaseConversion" "NONE"
  10. #register_var 0x8 VAR_INT player
  11. #register_var 0xC VAR_INT scplayer
  12. #define FUNC_AddToCheatString 0x438480
  13. #define FUNC_GetModuleHandle 0x81E406
  14. #define REF_CheatHashes 0x438513
  15.  
  16. // Compile with this set to 1 to enable a list of buttons in the cheat string
  17. #define SHOW_INPUT 0
  18. #if SHOW_INPUT
  19.     #define FUNC_strlen 0x826330
  20.     #define MEM_CheatString 0x969110
  21. #endif
  22.  
  23. /*
  24.     // lecture
  25.     Scripts are run before the game fully starts to do set-ups like in the 'INIT' missions
  26.     or continue to the beginning of a loop in a saved script) until the first WAIT
  27.     So its a good idea to always WAIT, unless we really need that
  28. */
  29. WAIT 0
  30.  
  31. {
  32.     LVAR_INT pCheatTable pTranslation pButtons hGInput GInput_GetSourceButtonInput
  33.     GET_LABEL_POINTER (cheats) pCheatTable
  34.     GET_LABEL_POINTER (buttons) pButtons
  35.     GET_LABEL_POINTER (translation) pTranslation
  36.    
  37.     // Get the module handle for GInput.asi
  38.     CALL_FUNCTION_RETURN (FUNC_GetModuleHandle, 1, 0, STRING:"GInput.asi") hGInput
  39.  
  40.     // If not found, wait to warn the user
  41.     IF hGInput = 0
  42.         WHILE NOT IS_PLAYER_PLAYING (player)
  43.         OR NOT IS_PLAYER_CONTROL_ON (player)
  44.         OR IS_HELP_MESSAGE_BEING_DISPLAYED
  45.             WAIT 0
  46.         ENDWHILE
  47.         PRINT_HELP_STRING "Tactile Cheat Activation~n~~r~Error: GInput.asi not found!"
  48.         TERMINATE_THIS_CUSTOM_SCRIPT
  49.     ENDIF
  50.    
  51.     // Get the only func we need and save it
  52.     GET_DYNAMIC_LIBRARY_PROCEDURE ("_GInput_GetSourceButtonInput@8", hGInput) GInput_GetSourceButtonInput
  53.    
  54. main:
  55.     WAIT 0
  56.    
  57.     IF IS_PLAYER_PLAYING (player)
  58.         LVAR_INT counter pAddr button temp_val1 temp_val2
  59.        
  60.         // Check for button presses
  61.         REPEAT 14 counter
  62.             button = counter + LEFTSHOULDER1
  63.            
  64.             IF NOT button == START
  65.             AND NOT button == SELECT
  66.                 // Will return the exact input of a specific button, disregarding situational mapping
  67.                 CALL_FUNCTION_RETURN (GInput_GetSourceButtonInput, 2, 0, button, player) temp_val1
  68.                
  69.                 // Get the address of the "pressed buttons" array, read the current value, write the new one
  70.                 pAddr = pButtons + counter
  71.                 READ_MEMORY (pAddr, 1, FALSE) temp_val2
  72.                 WRITE_MEMORY (pAddr, 1, temp_val1, FALSE)
  73.                
  74.                 // If it wasn't already in the "pressed buttons" array, add it to the cheat string
  75.                 IF NOT temp_val1 = 0
  76.                 AND temp_val2 = 0
  77.                     // Find the appropriate ASCII character for this button so it can be hashed
  78.                     pAddr = pTranslation + counter
  79.                     READ_MEMORY (pAddr, 1, FALSE) temp_val2
  80.                    
  81.                     // Temporarily replace the cheat hashes array - the cheats will be only usable directly through this script
  82.                     READ_MEMORY (REF_CheatHashes, 4, TRUE) temp_val1
  83.                     WRITE_MEMORY (REF_CheatHashes, 4, pCheatTable, TRUE)
  84.                    
  85.                     // Pass to the func which handles PC cheats - it'll take care of everything (R* used the same method)
  86.                     CALL_FUNCTION (FUNC_AddToCheatString, 1, 1, temp_val2)
  87.                    
  88.                     // Restore the cheat hashes so PC cheats can be entered, other scripts can also have custom cheats, etc.
  89.                     WRITE_MEMORY (REF_CheatHashes, 4, temp_val1, TRUE)
  90.                 ENDIF
  91.             ENDIF
  92.         ENDREPEAT
  93.        
  94.         #if SHOW_INPUT
  95.             // For, like, taking a video of this script and showing how the cheats are being entered...
  96.             LVAR_INT len pCheatText pCheatEnd
  97.            
  98.             // Get the cheat string length and continue if we have anything to print
  99.             CALL_FUNCTION_RETURN (FUNC_strlen, 1, 1, MEM_CheatString) len
  100.             IF len > 0
  101.                 GET_LABEL_POINTER (cheat_text) pCheatText
  102.                
  103.                 // Only show the last 16 buttons
  104.                 IF len > 16
  105.                     len = 16
  106.                 ENDIF
  107.                
  108.                 // The cheat string is in reverse, so start from the end...
  109.                 pCheatEnd = MEM_CheatString + len
  110.                 WHILE pCheatEnd > MEM_CheatString
  111.                     --pCheatEnd
  112.                     --len
  113.                    
  114.                     // [space]
  115.                     WRITE_MEMORY (pCheatText, 1, 0x20, FALSE)
  116.                     ++pCheatText
  117.                    
  118.                     // Read the next/last char
  119.                     READ_MEMORY (pCheatEnd, 1, FALSE) temp_val1
  120.                    
  121.                     // Convert the cheat string char to a GXT symbol - which GInput will convert to a texture
  122.                     IF NOT temp_val1 == 0x31        // 1
  123.                         IF NOT temp_val1 == 0x32        // 2
  124.                             IF NOT temp_val1 == 0x33        // 3
  125.                                 IF NOT temp_val1 == 0x34        // 4
  126.                                     IF NOT temp_val1 == 0x55        // U(p)
  127.                                         IF NOT temp_val1 == 0x44        // D(own)
  128.                                             IF NOT temp_val1 == 0x4C        //  L(eft)
  129.                                                 IF NOT temp_val1 == 0x52        // R(ight)
  130.                                                     IF NOT temp_val1 == 0x53        // S(quare)
  131.                                                         IF NOT temp_val1 == 0x54        // T(riangle)
  132.                                                             IF NOT temp_val1 == 0x58        // X
  133.                                                                 IF NOT temp_val1 == 0x43        // C(ircle)
  134.                                                                     // it looks hideous...
  135.                                                                     //WRITE_MEMORY (pCheatText, 1, temp_val1, FALSE)
  136.                                                                     //++pCheatText
  137.                                                                     --pCheatText
  138.                                                                     GOTO showinput_continue
  139.                                                                 ELSE
  140.                                                                     temp_val2 = 0x6F    // o
  141.                                                                 ENDIF
  142.                                                             ELSE
  143.                                                                 temp_val2 = 0x78    // x
  144.                                                             ENDIF
  145.                                                         ELSE
  146.                                                             temp_val2 = 0x74    // t
  147.                                                         ENDIF
  148.                                                     ELSE
  149.                                                         temp_val2 = 0x71    // q
  150.                                                     ENDIF
  151.                                                 ELSE
  152.                                                     temp_val2 = 0x3E    // r
  153.                                                 ENDIF
  154.                                             ELSE
  155.                                                 temp_val2 = 0x3C    // l
  156.                                             ENDIF
  157.                                         ELSE
  158.                                             temp_val2 = 0x64    // d
  159.                                         ENDIF
  160.                                     ELSE
  161.                                         temp_val2 = 0x75    // u
  162.                                     ENDIF
  163.                                 ELSE
  164.                                     temp_val2 = 0x76    // v
  165.                                 ENDIF
  166.                             ELSE
  167.                                 temp_val2 = 0x6A    // j
  168.                             ENDIF
  169.                         ELSE
  170.                             temp_val2 = 0x6D    // m
  171.                         ENDIF
  172.                     ELSE
  173.                         temp_val2 = 0x6B    // k
  174.                     ENDIF
  175.                    
  176.                     // Concatenate the GXT symbol '~%c~' (where %c is the character we just got above, duh)
  177.                     WRITE_MEMORY (pCheatText, 1, 0x7E, FALSE)
  178.                     ++pCheatText
  179.                     WRITE_MEMORY (pCheatText, 1, temp_val2, FALSE)
  180.                     ++pCheatText
  181.                     WRITE_MEMORY (pCheatText, 1, 0x7E, FALSE)
  182.                     ++pCheatText
  183.                    
  184.                     showinput_continue:
  185.                 ENDWHILE
  186.                
  187.                 // \0 at the end, standard...
  188.                 WRITE_MEMORY (pCheatText, 1, 0, FALSE)
  189.                
  190.                 // Add the text label
  191.                 GET_LABEL_POINTER (cheat_text) pCheatText
  192.                 ADD_TEXT_LABEL ("_TAC", pCheatText)
  193.             ELSE
  194.                 ADD_TEXT_LABEL ("_TAC", "")
  195.             ENDIF
  196.            
  197.             // Print out the list
  198.             USE_TEXT_COMMANDS TRUE
  199.             SET_TEXT_SCALE (2.0, 2.0)
  200.             SET_TEXT_SIZE 1.0
  201.             DISPLAY_TEXT (8.0, 10.0, _TAC)
  202.         #endif
  203.     ENDIF
  204.    
  205.     GOTO main
  206. }
  207.  
  208. #if SHOW_INPUT
  209.     // if we're showing input, this gives us space to fit the GXT keys
  210.     #hex
  211.     cheat_text:
  212.     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     // 32
  213.     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     // 64
  214.     00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00     // 96
  215.     #endhex
  216. #endif
  217.  
  218. // Space to store which buttons are currently held, so we dont repeatedly add it
  219. #hex
  220. buttons:
  221. 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00         // 16
  222. #endhex
  223.  
  224. /*
  225.     GTASA PS2 Cheat Hashes
  226.     Recovered from the PS2 GTASA binary.
  227.     Cheats are encrypted by reversing a string (so the input string doesn't need reversing every time)
  228.     and calculating a CRC hash from it. The string is formatted depending on the buttons to press:
  229.         X = Cross
  230.         T = Triangle
  231.         C = Circle
  232.         S = Square
  233.         U = Up
  234.         D = Down
  235.         L = Left
  236.         R = Right
  237.         1 = L1
  238.         2 = L2
  239.         3 = R1
  240.         4 = R2
  241.     e.g. for the weapon cheat (first in the hash table), hashing "URDLURDL4143" will produce 0x518BAD1E.
  242.    
  243.     GTASA was the first (and perhaps last) game in the series to use hashed cheats. This means that there
  244.     are a huge number of possible combinations (over 200,000 confirmed) which can produce the same hash.
  245. */
  246. #hex
  247. cheats:
  248. 1EAD8B51 FB747986 05027580 A5E57B20 A49EF197    // 0
  249. E56ECF4D 1B17F6D8 30264DA4 021E33D2 292F88AE    // 5
  250. 5402598F C91A176A 0DE5EDB4 A666C4CB E09B9F7F    // 10
  251. 281603F0 0292842A 0D295494 EEEEA1E6 E47DBBE5    // 15
  252. 875C86B1 B76C60D9 1FF833B5 DDA2ECE3 817C02F8    // 20
  253. 2B4F181B 546C6509 B194B562 FBA8B3C9 5213EE53    // 25
  254. E116C1BA BFB3A08F 8A93579C 88F72076 98F427FD    // 30
  255. 70BBE456 B5525F9A 0049BA49 196A8B20 4E854486    // 35
  256. 2013E451 94F19BE8 CF20CCC3 B78FC99B 773B9521    // 40
  257. BDB08091 A965D112 4E6D2E9C F498B87E 490D5A82    // 45
  258. 1CB73F10 B3FB6C9A 4D9A372A 57D0F8A6 33958F68    // 50
  259. 54E44076 599435C3 0DD6D4E1 63C154D3 9B456E4E    // 55
  260. C60903ED 2D27C6F0 4FC21EC3 5FA8EFF3 E5310EB4    // 60
  261. CD041833 0C5FA944 F45180C5 07ECFFF5 AEF732CB    // 65
  262. 2104BCF9 675C20F9 7C374CF2 B4736264 9A2CDF20    // 70
  263. 2053E2CD FC6C817F 45E3CFA3 31830183 E2865BF3    // 75
  264. 9EC12E53 9B1CC977 4E2B51E2 7A2D4EBC 1566F262    // 80
  265. D3576DF9 E11C79D5 333443EB 860376FA 11A7E1AC    // 90
  266. 00000000 00000000 00000000 00000000 00000000    // 95
  267. #endhex
  268. #hex
  269. translation:
  270. // LEFTSHOULDER1-CIRCLE
  271. "1" "2" "3" "4" "U" "D" "L" "R" 00 00 "S" "T" "X" "C" 00
  272. #endhex
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement