Skip to content

Commit

Permalink
Saturn: Use custom defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
UnknownShadow200 committed Jul 23, 2024
1 parent 57e37e0 commit 47fdeb1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
13 changes: 3 additions & 10 deletions src/ExtMath.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,22 +187,15 @@ static CC_INLINE int isin_s4(int x) {
return (c >= 0) ? y : (-y);
}

static CC_INLINE int isin(int x) {
return isin_s4(x);
}

static CC_INLINE int icos(int x) {
return isin_s4(x + (1 << ISIN_QN));
}

float Math_SinF(float angle) {
int raw = (int)(angle * MATH_RAD2DEG * 4096 / 360);
return isin(raw) / 4096.0f;
return isin_s4(raw) / 4096.0f;
}

float Math_CosF(float angle) {
int raw = (int)(angle * MATH_RAD2DEG * 4096 / 360);
return icos(raw) / 4096.0f;
raw += (1 << ISIN_QN); // add offset to calculate cos(x) instead of sin(x)
return isin_s4(raw) / 4096.0f;
}

#else
Expand Down
23 changes: 22 additions & 1 deletion src/Window_Saturn.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,27 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
/*########################################################################################################################*
*-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/
static const BindMapping saturn_defaults[BIND_COUNT] = {
[BIND_LOOK_UP] = { CCPAD_4, CCPAD_UP },
[BIND_LOOK_DOWN] = { CCPAD_4, CCPAD_DOWN },
[BIND_LOOK_LEFT] = { CCPAD_4, CCPAD_LEFT },
[BIND_LOOK_RIGHT] = { CCPAD_4, CCPAD_RIGHT },
[BIND_FORWARD] = { CCPAD_UP, 0 },
[BIND_BACK] = { CCPAD_DOWN, 0 },
[BIND_LEFT] = { CCPAD_LEFT, 0 },
[BIND_RIGHT] = { CCPAD_RIGHT, 0 },
[BIND_JUMP] = { CCPAD_1, 0 },
[BIND_SET_SPAWN] = { CCPAD_START, 0 },
[BIND_INVENTORY] = { CCPAD_3, 0 },
[BIND_SPEED] = { CCPAD_2, CCPAD_L},
[BIND_NOCLIP] = { CCPAD_2, CCPAD_3},
[BIND_FLY] = { CCPAD_2, CCPAD_R },
[BIND_FLY_UP] = { CCPAD_2, CCPAD_UP },
[BIND_FLY_DOWN] = { CCPAD_2, CCPAD_DOWN },
[BIND_DELETE_BLOCK] = { CCPAD_L, 0 },
[BIND_PLACE_BLOCK] = { CCPAD_R, 0 }
};

void Gamepads_Init(void) {
Input.Sources |= INPUT_SOURCE_GAMEPAD;
smpc_peripheral_init();
Expand Down Expand Up @@ -129,7 +150,7 @@ static smpc_peripheral_digital_t dig_state;
static smpc_peripheral_analog_t ana_state;

void Gamepads_Process(float delta) {
int port = Gamepad_Connect(0x5A, PadBind_Defaults);
int port = Gamepad_Connect(0x5A, saturn_defaults);
smpc_peripheral_process();

smpc_peripheral_digital_port(1, &dig_state);
Expand Down

0 comments on commit 47fdeb1

Please sign in to comment.