Added support for X and Y buttons; Re-mapped B button to the actual B button for controllers; Moved particleFlags code so lua scripts can spawn Mario particles with 'before Mario update' and 'after Mario update' hooks (#5)

This commit is contained in:
PeachyPeach 2022-02-27 23:31:59 +01:00 committed by GitHub
parent 02b3e19e12
commit 0c42836b81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 32 additions and 5 deletions

View file

@ -1769,6 +1769,8 @@
- CONT_TYPE_NORMAL
- CONT_TYPE_VOICE
- CONT_UP
- CONT_X
- CONT_Y
- D_CBUTTONS
- D_JPAD
- L_CBUTTONS
@ -1780,6 +1782,8 @@
- START_BUTTON
- U_CBUTTONS
- U_JPAD
- X_BUTTON
- Y_BUTTON
- Z_TRIG
<br />

View file

@ -123,6 +123,8 @@ typedef struct {
#define CONT_A 0x8000
#define CONT_B 0x4000
#define CONT_X 0x0040
#define CONT_Y 0x0080
#define CONT_G 0x2000
#define CONT_START 0x1000
#define CONT_UP 0x0800
@ -140,6 +142,8 @@ typedef struct {
#define A_BUTTON CONT_A
#define B_BUTTON CONT_B
#define X_BUTTON CONT_X
#define Y_BUTTON CONT_Y
#define L_TRIG CONT_L
#define R_TRIG CONT_R
#define Z_TRIG CONT_G

View file

@ -428,7 +428,7 @@
#define VALID_BUTTONS (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | \
U_JPAD | D_JPAD | L_JPAD | R_JPAD | \
L_TRIG | R_TRIG | \
L_TRIG | R_TRIG | X_BUTTON | Y_BUTTON | \
U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )
#define C_BUTTONS (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )

View file

@ -1467,7 +1467,6 @@ copyPlayerGoto:;
* Handles Mario's input flags as well as a couple timers.
*/
void update_mario_inputs(struct MarioState *m) {
m->particleFlags = 0;
if (m->playerIndex == 0) { m->input = 0; }
u8 localIsPaused = (m->playerIndex == 0) && (sCurrPlayMode == PLAY_MODE_PAUSED || m->freeze > 0);

View file

@ -282,14 +282,16 @@ void bhv_mario_update(void) {
vec3f_copy(gMarioState->marioBodyState->torsoPos, gMarioState->pos);
}
gMarioState->particleFlags = 0;
smlua_call_event_hooks_mario_param(HOOK_BEFORE_MARIO_UPDATE, gMarioState);
u32 particleFlags = 0;
s32 i;
particleFlags = execute_mario_action(gCurrentObject);
gCurrentObject->oMarioParticleFlags = particleFlags;
smlua_call_event_hooks_mario_param(HOOK_MARIO_UPDATE, gMarioState);
particleFlags |= gMarioState->particleFlags;
gCurrentObject->oMarioParticleFlags = particleFlags;
// Mario code updates MarioState's versions of position etc, so we need
// to sync it with the Mario object

View file

@ -62,7 +62,9 @@ unsigned int configEnvVolume = MAX_VOLUME;
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 };
unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1001, 0x1101 };
unsigned int configKeyX[MAX_BINDS] = { 0x0025, 0x1002, VK_INVALID };
unsigned int configKeyY[MAX_BINDS] = { 0x0032, 0x1003, VK_INVALID };
unsigned int configKeyStart[MAX_BINDS] = { 0x0039, 0x1006, VK_INVALID };
unsigned int configKeyL[MAX_BINDS] = { 0x002A, 0x1009, 0x1104 };
unsigned int configKeyR[MAX_BINDS] = { 0x0036, 0x100A, 0x101B };
@ -137,6 +139,8 @@ static const struct ConfigOption options[] = {
{.name = "env_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configEnvVolume},
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
{.name = "key_x", .type = CONFIG_TYPE_BIND, .uintValue = configKeyX},
{.name = "key_y", .type = CONFIG_TYPE_BIND, .uintValue = configKeyY},
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
{.name = "key_l", .type = CONFIG_TYPE_BIND, .uintValue = configKeyL},
{.name = "key_r", .type = CONFIG_TYPE_BIND, .uintValue = configKeyR},

View file

@ -30,6 +30,8 @@ extern unsigned int configSfxVolume;
extern unsigned int configEnvVolume;
extern unsigned int configKeyA[];
extern unsigned int configKeyB[];
extern unsigned int configKeyX[];
extern unsigned int configKeyY[];
extern unsigned int configKeyStart[];
extern unsigned int configKeyL[];
extern unsigned int configKeyR[];

View file

@ -92,6 +92,8 @@ static void keyboard_bindkeys(void) {
keyboard_add_binds(STICK_RIGHT, configKeyStickRight);
keyboard_add_binds(A_BUTTON, configKeyA);
keyboard_add_binds(B_BUTTON, configKeyB);
keyboard_add_binds(X_BUTTON, configKeyX);
keyboard_add_binds(Y_BUTTON, configKeyY);
keyboard_add_binds(Z_TRIG, configKeyZ);
keyboard_add_binds(U_CBUTTONS, configKeyCUp);
keyboard_add_binds(L_CBUTTONS, configKeyCLeft);

View file

@ -88,6 +88,8 @@ static void controller_sdl_bind(void) {
controller_add_binds(A_BUTTON, configKeyA);
controller_add_binds(B_BUTTON, configKeyB);
controller_add_binds(X_BUTTON, configKeyX);
controller_add_binds(Y_BUTTON, configKeyY);
controller_add_binds(Z_TRIG, configKeyZ);
controller_add_binds(STICK_UP, configKeyStickUp);
controller_add_binds(STICK_LEFT, configKeyStickLeft);

View file

@ -75,6 +75,8 @@ static void controller_sdl_bind(void) {
controller_add_binds(A_BUTTON, configKeyA);
controller_add_binds(B_BUTTON, configKeyB);
controller_add_binds(X_BUTTON, configKeyX);
controller_add_binds(Y_BUTTON, configKeyY);
controller_add_binds(Z_TRIG, configKeyZ);
controller_add_binds(STICK_UP, configKeyStickUp);
controller_add_binds(STICK_LEFT, configKeyStickLeft);

View file

@ -21,6 +21,8 @@ void djui_panel_controls_n64_create(struct DjuiBase* caller) {
djui_bind_create(&bindBody->base, "Right", configKeyStickRight);
djui_bind_create(&bindBody->base, "A", configKeyA);
djui_bind_create(&bindBody->base, "B", configKeyB);
djui_bind_create(&bindBody->base, "X", configKeyX);
djui_bind_create(&bindBody->base, "Y", configKeyY);
djui_bind_create(&bindBody->base, "Start", configKeyStart);
djui_bind_create(&bindBody->base, "L", configKeyL);
djui_bind_create(&bindBody->base, "R", configKeyR);

View file

@ -1766,6 +1766,8 @@ char gSmluaConstants[] = ""
"CONT_EEPROM_BUSY = 0x80\n"
"CONT_A = 0x8000\n"
"CONT_B = 0x4000\n"
"CONT_X = 0x0040\n"
"CONT_Y = 0x0080\n"
"CONT_G = 0x2000\n"
"CONT_START = 0x1000\n"
"CONT_UP = 0x0800\n"
@ -1780,6 +1782,8 @@ char gSmluaConstants[] = ""
"CONT_F = 0x0001\n"
"A_BUTTON = CONT_A\n"
"B_BUTTON = CONT_B\n"
"X_BUTTON = CONT_X\n"
"Y_BUTTON = CONT_Y\n"
"L_TRIG = CONT_L\n"
"R_TRIG = CONT_R\n"
"Z_TRIG = CONT_G\n"
@ -2143,7 +2147,7 @@ char gSmluaConstants[] = ""
"ACT_HOLDING_BOWSER = 0x00000391\n"
"ACT_RELEASING_BOWSER = 0x00000392\n"
"END_DEMO = (1 << 7)\n"
"VALID_BUTTONS = (A_BUTTON | B_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"VALID_BUTTONS = (A_BUTTON | B_BUTTON | X_BUTTON | Y_BUTTON | Z_TRIG | START_BUTTON | U_JPAD | D_JPAD | L_JPAD | R_JPAD | L_TRIG | R_TRIG | U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"C_BUTTONS = (U_CBUTTONS | D_CBUTTONS | L_CBUTTONS | R_CBUTTONS )\n"
"HOOK_UPDATE = 0\n"
"HOOK_MARIO_UPDATE = 1\n"