mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-14 17:14:29 +02:00
#368 add "Swap A B" controls option
This commit is contained in:
@@ -22,6 +22,13 @@
|
|||||||
#define USE_ASM
|
#define USE_ASM
|
||||||
|
|
||||||
#include <tonc.h>
|
#include <tonc.h>
|
||||||
|
#elif defined(__NDS__)
|
||||||
|
#define MODEHW
|
||||||
|
#define USE_DIV_TABLE
|
||||||
|
|
||||||
|
#include <nds.h>
|
||||||
|
#include <fat.h>
|
||||||
|
#include <filesystem.h>
|
||||||
#elif defined(__TNS__)
|
#elif defined(__TNS__)
|
||||||
#define MODE13
|
#define MODE13
|
||||||
#define USE_DIV_TABLE
|
#define USE_DIV_TABLE
|
||||||
@@ -76,9 +83,12 @@
|
|||||||
#include <new>
|
#include <new>
|
||||||
|
|
||||||
#if defined(MODEHW)
|
#if defined(MODEHW)
|
||||||
#ifdef __3DO__
|
#if defined(__3DO__)
|
||||||
#define FRAME_WIDTH 320
|
#define FRAME_WIDTH 320
|
||||||
#define FRAME_HEIGHT 240
|
#define FRAME_HEIGHT 240
|
||||||
|
#elif defined(__NDS__)
|
||||||
|
#define FRAME_WIDTH 256
|
||||||
|
#define FRAME_HEIGHT 192
|
||||||
#endif
|
#endif
|
||||||
#elif defined(MODE4)
|
#elif defined(MODE4)
|
||||||
#define VRAM_WIDTH 120 // in shorts (240 bytes)
|
#define VRAM_WIDTH 120 // in shorts (240 bytes)
|
||||||
@@ -165,10 +175,14 @@ typedef uint32 divTableInt;
|
|||||||
#else
|
#else
|
||||||
typedef signed char int8;
|
typedef signed char int8;
|
||||||
typedef signed short int16;
|
typedef signed short int16;
|
||||||
|
#if !defined(__NDS__)
|
||||||
typedef signed int int32;
|
typedef signed int int32;
|
||||||
|
#endif
|
||||||
typedef unsigned char uint8;
|
typedef unsigned char uint8;
|
||||||
typedef unsigned short uint16;
|
typedef unsigned short uint16;
|
||||||
|
#if !defined(__NDS__)
|
||||||
typedef unsigned int uint32;
|
typedef unsigned int uint32;
|
||||||
|
#endif
|
||||||
typedef uint16 divTableInt;
|
typedef uint16 divTableInt;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -178,7 +192,7 @@ X_INLINE int32 abs(int32 x) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__GBA__)
|
#if defined(__GBA__) || defined(__NDS__)
|
||||||
#define int2str(x,str) itoa(x, str, 10)
|
#define int2str(x,str) itoa(x, str, 10)
|
||||||
#elif defined(__3DO__)
|
#elif defined(__3DO__)
|
||||||
#define int2str(x,str) sprintf(str, "%d", x)
|
#define int2str(x,str) sprintf(str, "%d", x)
|
||||||
@@ -498,10 +512,12 @@ enum InputKey {
|
|||||||
IK_A = (1 << 4),
|
IK_A = (1 << 4),
|
||||||
IK_B = (1 << 5),
|
IK_B = (1 << 5),
|
||||||
IK_C = (1 << 6),
|
IK_C = (1 << 6),
|
||||||
IK_L = (1 << 7),
|
IK_X = (1 << 7),
|
||||||
IK_R = (1 << 8),
|
IK_Y = (1 << 8),
|
||||||
IK_START = (1 << 9),
|
IK_L = (1 << 9),
|
||||||
IK_SELECT = (1 << 10)
|
IK_R = (1 << 10),
|
||||||
|
IK_START = (1 << 11),
|
||||||
|
IK_SELECT = (1 << 12)
|
||||||
};
|
};
|
||||||
|
|
||||||
// action keys (ItemObj::input)
|
// action keys (ItemObj::input)
|
||||||
@@ -991,10 +1007,7 @@ struct Texture
|
|||||||
#else
|
#else
|
||||||
uint16 attribute;
|
uint16 attribute;
|
||||||
uint16 tile;
|
uint16 tile;
|
||||||
uint32 uv0;
|
uint32 uv[4];
|
||||||
uint32 uv1;
|
|
||||||
uint32 uv2;
|
|
||||||
uint32 uv3;
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1668,13 +1681,14 @@ struct SaveGame
|
|||||||
uint8 tracks[64];
|
uint8 tracks[64];
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SETTINGS_VER 2
|
#define SETTINGS_VER 3
|
||||||
#define SETTINGS_SIZE 128
|
#define SETTINGS_SIZE 128
|
||||||
|
|
||||||
struct Settings
|
struct Settings
|
||||||
{
|
{
|
||||||
uint8 version;
|
uint8 version;
|
||||||
uint8 controls_vibration:1;
|
uint8 controls_vibration:1;
|
||||||
|
uint8 controls_swap:1;
|
||||||
uint8 audio_sfx:1;
|
uint8 audio_sfx:1;
|
||||||
uint8 audio_music:1;
|
uint8 audio_music:1;
|
||||||
uint8 video_gamma:5;
|
uint8 video_gamma:5;
|
||||||
@@ -2200,6 +2214,7 @@ enum StringID {
|
|||||||
, STR_OPT_CONTROLS_VIBRATION
|
, STR_OPT_CONTROLS_VIBRATION
|
||||||
, STR_OPT_CONTROLS_RETARGET
|
, STR_OPT_CONTROLS_RETARGET
|
||||||
, STR_OPT_CONTROLS_MULTIAIM
|
, STR_OPT_CONTROLS_MULTIAIM
|
||||||
|
, STR_OPT_CONTROLS_SWAP
|
||||||
// controls
|
// controls
|
||||||
, STR_CTRL_RUN
|
, STR_CTRL_RUN
|
||||||
, STR_CTRL_BACK
|
, STR_CTRL_BACK
|
||||||
|
@@ -151,7 +151,13 @@ void drawText(int32 x, int32 y, const char* text, TextAlign align)
|
|||||||
index = charRemap(c);
|
index = charRemap(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderGlyph(x, y, level.models[ITEM_GLYPHS].start + index);
|
int32 iy = y;
|
||||||
|
|
||||||
|
if (c == 'p') { // TODO investigate!
|
||||||
|
iy--;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderGlyph(x, iy, level.models[ITEM_GLYPHS].start + index);
|
||||||
x += char_width[index] + 1;
|
x += char_width[index] + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -86,6 +86,7 @@ void gameInit(const char* name)
|
|||||||
|
|
||||||
gSettings.version = SETTINGS_VER;
|
gSettings.version = SETTINGS_VER;
|
||||||
gSettings.controls_vibration = 1;
|
gSettings.controls_vibration = 1;
|
||||||
|
gSettings.controls_swap = 0;
|
||||||
gSettings.audio_sfx = 1;
|
gSettings.audio_sfx = 1;
|
||||||
gSettings.audio_music = 1;
|
gSettings.audio_music = 1;
|
||||||
gSettings.video_gamma = 0;
|
gSettings.video_gamma = 0;
|
||||||
|
@@ -84,6 +84,7 @@ enum OptionID
|
|||||||
{
|
{
|
||||||
// controls
|
// controls
|
||||||
OPT_ID_RUMBLE = 0,
|
OPT_ID_RUMBLE = 0,
|
||||||
|
OPT_ID_SWAP = 1,
|
||||||
// audio
|
// audio
|
||||||
OPT_ID_SFX = 0,
|
OPT_ID_SFX = 0,
|
||||||
OPT_ID_MUSIC = 1,
|
OPT_ID_MUSIC = 1,
|
||||||
@@ -783,7 +784,7 @@ struct Inventory
|
|||||||
|
|
||||||
case OPT_SWITCH:
|
case OPT_SWITCH:
|
||||||
{
|
{
|
||||||
if (lara->isKeyHit(IN_ACTION) || lara->isKeyHit(IN_LEFT) || lara->isKeyHit(IN_RIGHT))
|
if (lara->isKeyHit(IN_LEFT) || lara->isKeyHit(IN_RIGHT))
|
||||||
{
|
{
|
||||||
opt.value = !opt.value;
|
opt.value = !opt.value;
|
||||||
}
|
}
|
||||||
@@ -950,6 +951,12 @@ struct Inventory
|
|||||||
osJoyVibrate(0, 0xFF, 0xFF);
|
osJoyVibrate(0, 0xFF, 0xFF);
|
||||||
osSaveSettings();
|
osSaveSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((optionIndex == OPT_ID_SWAP) && (gSettings.controls_swap != opt.value))
|
||||||
|
{
|
||||||
|
gSettings.controls_swap = opt.value;
|
||||||
|
osSaveSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onHome()
|
void onHome()
|
||||||
@@ -1253,6 +1260,7 @@ struct Inventory
|
|||||||
case SLOT_CONTROLS:
|
case SLOT_CONTROLS:
|
||||||
{
|
{
|
||||||
OPTION_SWITCH(STR_OPT_CONTROLS_VIBRATION, gSettings.controls_vibration);
|
OPTION_SWITCH(STR_OPT_CONTROLS_VIBRATION, gSettings.controls_vibration);
|
||||||
|
OPTION_SWITCH(STR_OPT_CONTROLS_SWAP, gSettings.controls_swap);
|
||||||
/*
|
/*
|
||||||
OPTION_SPACE();
|
OPTION_SPACE();
|
||||||
OPTION_CTRL(STR_CTRL_RUN, 0);
|
OPTION_CTRL(STR_CTRL_RUN, 0);
|
||||||
|
@@ -99,6 +99,7 @@ const char* const STR_EN[STR_MAX] = { ""
|
|||||||
, "Rumble"
|
, "Rumble"
|
||||||
, "Retargeting"
|
, "Retargeting"
|
||||||
, "Multi-aiming"
|
, "Multi-aiming"
|
||||||
|
, "Swap A B"
|
||||||
// controls
|
// controls
|
||||||
, "Run"
|
, "Run"
|
||||||
, "Back"
|
, "Back"
|
||||||
|
@@ -377,7 +377,9 @@ struct Lara : ItemObj
|
|||||||
|
|
||||||
void updateCollision()
|
void updateCollision()
|
||||||
{
|
{
|
||||||
updateObjectsCollision();
|
#ifndef __NDS__ // TODO
|
||||||
|
updateObjectsCollision();
|
||||||
|
#endif
|
||||||
|
|
||||||
(this->*cHandlers[state])();
|
(this->*cHandlers[state])();
|
||||||
|
|
||||||
@@ -2724,7 +2726,7 @@ struct Lara : ItemObj
|
|||||||
|
|
||||||
input = 0;
|
input = 0;
|
||||||
|
|
||||||
#ifdef __3DO__
|
#if defined(__3DO__)
|
||||||
if (keys & IK_A) input |= IN_JUMP;
|
if (keys & IK_A) input |= IN_JUMP;
|
||||||
if (keys & IK_B) input |= IN_ACTION;
|
if (keys & IK_B) input |= IN_ACTION;
|
||||||
if (keys & IK_C) input |= IN_WEAPON;
|
if (keys & IK_C) input |= IN_WEAPON;
|
||||||
@@ -2735,8 +2737,18 @@ struct Lara : ItemObj
|
|||||||
if (keys & IK_L) input |= IN_LOOK;
|
if (keys & IK_L) input |= IN_LOOK;
|
||||||
if (keys & IK_R) input |= IN_WALK;
|
if (keys & IK_R) input |= IN_WALK;
|
||||||
}
|
}
|
||||||
#else
|
#elif defined(__GBA__) || defined(_WIN32)
|
||||||
if (keys & IK_A)
|
int32 ikA, ikB;
|
||||||
|
|
||||||
|
if (gSettings.controls_swap) {
|
||||||
|
ikA = IK_A;
|
||||||
|
ikB = IK_B;
|
||||||
|
} else {
|
||||||
|
ikA = IK_B;
|
||||||
|
ikB = IK_A;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keys & ikA)
|
||||||
{
|
{
|
||||||
if (keys & IK_L) {
|
if (keys & IK_L) {
|
||||||
if (extraL->weaponState != WEAPON_STATE_BUSY) {
|
if (extraL->weaponState != WEAPON_STATE_BUSY) {
|
||||||
@@ -2749,7 +2761,7 @@ struct Lara : ItemObj
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keys & IK_B)
|
if (keys & ikB)
|
||||||
{
|
{
|
||||||
if (keys & IK_L) {
|
if (keys & IK_L) {
|
||||||
input |= IN_UP | IN_DOWN;
|
input |= IN_UP | IN_DOWN;
|
||||||
@@ -2766,6 +2778,13 @@ struct Lara : ItemObj
|
|||||||
input |= IN_WALK;
|
input |= IN_WALK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#elif defined(__NDS__)
|
||||||
|
if (keys & IK_A) input |= IN_UP | IN_DOWN;
|
||||||
|
if (keys & IK_B) input |= IN_ACTION;
|
||||||
|
if (keys & IK_X) input |= IN_WEAPON;
|
||||||
|
if (keys & IK_Y) input |= IN_JUMP;
|
||||||
|
if (keys & IK_L) input |= IN_LOOK;
|
||||||
|
if (keys & IK_R) input |= IN_WALK;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (keys & IK_LEFT) input |= IN_LEFT;
|
if (keys & IK_LEFT) input |= IN_LEFT;
|
||||||
|
Reference in New Issue
Block a user