Kuribo64
Views: 19,855,236 Home | Forums | Uploader | Wiki | Object databases | IRC
Rules/FAQ | Memberlist | Calendar | Stats | Online users | Last posts | Search
03-29-24 08:41 AM
Guest:

0 users reading all button press values? | 1 bot

Main - General SM64DS hacking - all button press values? Hide post layouts | New reply


isceptul
Posted on 03-26-16 03:18 AM Link | #69083
WELP! Didnt want to make a thread, but no one replied in the help thread, soooo...

I'm trying to write ASM for sm64ds and i need the player to be able to perform an action when they press a certain button. All that was given in the asm patch template folder was the button press values for B (0x00F) and the the values for either L or R being pressed (0xF00), i need to know what the rest of the button pressed values are. Thanks in advance!

CodingKoopa
Posted on 03-26-16 01:41 PM (rev. 4 of 03-26-16 10:59 PM) Link | #69087
This is code from the NSMB Hacking Template, but I'm pretty sure that it's applicable to any DS game.
keys.cpp:
#include<nds.h>

static int keys, oldKeys, keysDw;
static bool first = true;

void myScanKeys()
{
first = false;
int keys = ~REG_KEYINPUT;
if(first) oldKeys = keys;
keysDw = keys & ~oldKeys;
oldKeys = keys;
}

int myKeysHeld()
{
return keys;
}
int myKeysDown()
{
return keysDw;
}
keys.h add to SM64DS.h:
//Custom key reading funcs.
void myScanKeys();
int myKeysHeld();
int myKeysDown();
Your code hook:
#include "SM64DS.h"

bool doNothing = false;

void hook_020e50ac()
{
if (CHARACTER == CHAR_Mario)
{
myScanKeys();
if (myKeysDown() & KEY_SELECT);
{
if (isOnGround)
{doNothing = true;
doNothing = false};
else
{Player_PerformAction (MarioActor *, char 0x9A, unsigned int loop_related, unsigned short playspeed_20_12);)}
}
}
}

The possible values are as follows:
KEY_A = BIT(0), //!< Keypad A button.
KEY_B = BIT(1), //!< Keypad B button.
KEY_SELECT = BIT(2), //!< Keypad SELECT button.
KEY_START = BIT(3), //!< Keypad START button.
KEY_RIGHT = BIT(4), //!< Keypad RIGHT button.
KEY_LEFT = BIT(5), //!< Keypad LEFT button.
KEY_UP = BIT(6), //!< Keypad UP button.
KEY_DOWN = BIT(7), //!< Keypad DOWN button.
KEY_R = BIT(8), //!< Right shoulder button.
KEY_L = BIT(9), //!< Left shoulder button.
KEY_X = BIT(10), //!< Keypad X button.
KEY_Y = BIT(11), //!< Keypad Y button.
KEY_TOUCH = BIT(12), //!< Touchscreen pendown.
KEY_LID = BIT(13) //!< Lid state.


____________________
Website | Twitter



Main - General SM64DS hacking - all button press values? Hide post layouts | New reply

Page rendered in 0.044 seconds. (2048KB of memory used)
MySQL - queries: 26, rows: 194/194, time: 0.016 seconds.
[powered by Acmlm] Acmlmboard 2.064 (2018-07-20)
© 2005-2008 Acmlm, Xkeeper, blackhole89 et al.