Difference between revisions of "00E2"
m |
m |
||
Line 1: | Line 1: | ||
− | {{Icon|3}} '''GET_PAD_STATE''' | + | {{Icon|3}} {{Icon|SA}} '''GET_PAD_STATE''' |
<hr /> | <hr /> | ||
'''Description''' | '''Description''' | ||
− | : Gets the | + | : Gets the state of the button |
'''Syntax''' | '''Syntax''' | ||
: 00E2: get_player [''int1''] key [''int2''] state_to [''var''] | : 00E2: get_player [''int1''] key [''int2''] state_to [''var''] | ||
Line 11: | Line 11: | ||
:: [[00E1|Button index]] | :: [[00E1|Button index]] | ||
: [''var''] | : [''var''] | ||
− | :: Variable to store the | + | :: Variable to store the state |
− | This opcode gets the | + | This opcode gets the state of the button. It returns a value between 0 and 255, 255 meaning the button is completely pressed down. For left and right sticks (buttons 0 to 3), it returns a value between -128 and 128, -128 meaning the stick is completely pressed one way and 128 meaning the stick is completely pressed the other way. |
== For Vice City == | == For Vice City == | ||
− | This opcode does not exist in Vice City but it is possible to retrieve the | + | This opcode does not exist in Vice City but it is possible to retrieve the state of the button in the same manner as GTA III. The following example, using Sanny Builder with [[CLEO]] for Vice City in an external script (not the main one) and tested on US v1.0, retrieves the value of the state of the button for pad 0. |
<syntaxhighlight lang="scm"> | <syntaxhighlight lang="scm"> | ||
:opcode_00E2 | :opcode_00E2 | ||
Line 22: | Line 22: | ||
0@ *= 2 // offset in memory | 0@ *= 2 // offset in memory | ||
0@ += 0x7DBCB0 // add to base memory location | 0@ += 0x7DBCB0 // add to base memory location | ||
− | 05E0: 0@ = read_memory 0@ size 2 virtual_protect 1 // retrieve | + | 05E0: 0@ = read_memory 0@ size 2 virtual_protect 1 // retrieve state of button |
05F6: ret 1 0@ | 05F6: ret 1 0@ | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 35: | Line 35: | ||
== See also == | == See also == | ||
− | * [[0494]], an alternative to getting | + | * [[0494]], an alternative to getting state of the stick (buttons 0 to 3) |
[[Category:OpCodes]] | [[Category:OpCodes]] | ||
[[Category:Code Snippets]] | [[Category:Code Snippets]] |
Revision as of 19:09, 11 January 2015
Description
- Gets the state of the button
Syntax
- 00E2: get_player [int1] key [int2] state_to [var]
Parameter
- [int1]
- Pad, normally 0 for pad 1 (player 1), 1 for pad 2 (player 2)
- [int2]
- [var]
- Variable to store the state
This opcode gets the state of the button. It returns a value between 0 and 255, 255 meaning the button is completely pressed down. For left and right sticks (buttons 0 to 3), it returns a value between -128 and 128, -128 meaning the stick is completely pressed one way and 128 meaning the stick is completely pressed the other way.
For Vice City
This opcode does not exist in Vice City but it is possible to retrieve the state of the button in the same manner as GTA III. The following example, using Sanny Builder with CLEO for Vice City in an external script (not the main one) and tested on US v1.0, retrieves the value of the state of the button for pad 0.
:opcode_00E2
// 0@ - input param (button)
0@ *= 2 // offset in memory
0@ += 0x7DBCB0 // add to base memory location
05E0: 0@ = read_memory 0@ size 2 virtual_protect 1 // retrieve state of button
05F6: ret 1 0@
Use this line as a substitute for opcode 00E2. This can be placed anywhere within the external script:
05F5: call_scm_func @opcode_00E2 inputs 1 button [button] result [variable]
Note that this code's result does not distinguish between a dword (4 bytes) or a word (2 bytes), meaning that a pressed left or right stick can be interpreted as a dword value of 65408, which is a word value of -128 (0xFF80 in hex).
Keywords
get, button, key, press, pressed, keypress
See also
- 0494, an alternative to getting state of the stick (buttons 0 to 3)