diff --git a/src/fixed/common.h b/src/fixed/common.h index 36c8b55..b01d2e3 100644 --- a/src/fixed/common.h +++ b/src/fixed/common.h @@ -22,6 +22,13 @@ #define USE_ASM #include +#elif defined(__NDS__) + #define MODEHW + #define USE_DIV_TABLE + + #include + #include + #include #elif defined(__TNS__) #define MODE13 #define USE_DIV_TABLE @@ -76,9 +83,12 @@ #include #if defined(MODEHW) - #ifdef __3DO__ + #if defined(__3DO__) #define FRAME_WIDTH 320 #define FRAME_HEIGHT 240 + #elif defined(__NDS__) + #define FRAME_WIDTH 256 + #define FRAME_HEIGHT 192 #endif #elif defined(MODE4) #define VRAM_WIDTH 120 // in shorts (240 bytes) @@ -165,10 +175,14 @@ typedef uint32 divTableInt; #else typedef signed char int8; typedef signed short int16; +#if !defined(__NDS__) typedef signed int int32; +#endif typedef unsigned char uint8; typedef unsigned short uint16; +#if !defined(__NDS__) typedef unsigned int uint32; +#endif typedef uint16 divTableInt; #endif @@ -178,7 +192,7 @@ X_INLINE int32 abs(int32 x) { } #endif -#if defined(__GBA__) +#if defined(__GBA__) || defined(__NDS__) #define int2str(x,str) itoa(x, str, 10) #elif defined(__3DO__) #define int2str(x,str) sprintf(str, "%d", x) @@ -498,10 +512,12 @@ enum InputKey { IK_A = (1 << 4), IK_B = (1 << 5), IK_C = (1 << 6), - IK_L = (1 << 7), - IK_R = (1 << 8), - IK_START = (1 << 9), - IK_SELECT = (1 << 10) + IK_X = (1 << 7), + IK_Y = (1 << 8), + IK_L = (1 << 9), + IK_R = (1 << 10), + IK_START = (1 << 11), + IK_SELECT = (1 << 12) }; // action keys (ItemObj::input) @@ -991,10 +1007,7 @@ struct Texture #else uint16 attribute; uint16 tile; - uint32 uv0; - uint32 uv1; - uint32 uv2; - uint32 uv3; + uint32 uv[4]; #endif }; @@ -1668,13 +1681,14 @@ struct SaveGame uint8 tracks[64]; }; -#define SETTINGS_VER 2 +#define SETTINGS_VER 3 #define SETTINGS_SIZE 128 struct Settings { uint8 version; uint8 controls_vibration:1; + uint8 controls_swap:1; uint8 audio_sfx:1; uint8 audio_music:1; uint8 video_gamma:5; @@ -2200,6 +2214,7 @@ enum StringID { , STR_OPT_CONTROLS_VIBRATION , STR_OPT_CONTROLS_RETARGET , STR_OPT_CONTROLS_MULTIAIM + , STR_OPT_CONTROLS_SWAP // controls , STR_CTRL_RUN , STR_CTRL_BACK diff --git a/src/fixed/draw.h b/src/fixed/draw.h index c2bdc8f..25e5faf 100644 --- a/src/fixed/draw.h +++ b/src/fixed/draw.h @@ -151,7 +151,13 @@ void drawText(int32 x, int32 y, const char* text, TextAlign align) 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; } } diff --git a/src/fixed/game.h b/src/fixed/game.h index 1357cd3..0ed55a4 100644 --- a/src/fixed/game.h +++ b/src/fixed/game.h @@ -86,6 +86,7 @@ void gameInit(const char* name) gSettings.version = SETTINGS_VER; gSettings.controls_vibration = 1; + gSettings.controls_swap = 0; gSettings.audio_sfx = 1; gSettings.audio_music = 1; gSettings.video_gamma = 0; diff --git a/src/fixed/inventory.h b/src/fixed/inventory.h index 19d630c..9314aab 100644 --- a/src/fixed/inventory.h +++ b/src/fixed/inventory.h @@ -84,6 +84,7 @@ enum OptionID { // controls OPT_ID_RUMBLE = 0, + OPT_ID_SWAP = 1, // audio OPT_ID_SFX = 0, OPT_ID_MUSIC = 1, @@ -783,7 +784,7 @@ struct Inventory 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; } @@ -950,6 +951,12 @@ struct Inventory osJoyVibrate(0, 0xFF, 0xFF); osSaveSettings(); } + + if ((optionIndex == OPT_ID_SWAP) && (gSettings.controls_swap != opt.value)) + { + gSettings.controls_swap = opt.value; + osSaveSettings(); + } } void onHome() @@ -1253,6 +1260,7 @@ struct Inventory case SLOT_CONTROLS: { OPTION_SWITCH(STR_OPT_CONTROLS_VIBRATION, gSettings.controls_vibration); + OPTION_SWITCH(STR_OPT_CONTROLS_SWAP, gSettings.controls_swap); /* OPTION_SPACE(); OPTION_CTRL(STR_CTRL_RUN, 0); diff --git a/src/fixed/lang/en.h b/src/fixed/lang/en.h index fb145de..e9eeb6d 100644 --- a/src/fixed/lang/en.h +++ b/src/fixed/lang/en.h @@ -99,6 +99,7 @@ const char* const STR_EN[STR_MAX] = { "" , "Rumble" , "Retargeting" , "Multi-aiming" + , "Swap A B" // controls , "Run" , "Back" diff --git a/src/fixed/lara.h b/src/fixed/lara.h index 6513327..e2891f9 100644 --- a/src/fixed/lara.h +++ b/src/fixed/lara.h @@ -377,7 +377,9 @@ struct Lara : ItemObj void updateCollision() { - updateObjectsCollision(); + #ifndef __NDS__ // TODO + updateObjectsCollision(); + #endif (this->*cHandlers[state])(); @@ -2724,7 +2726,7 @@ struct Lara : ItemObj input = 0; - #ifdef __3DO__ + #if defined(__3DO__) if (keys & IK_A) input |= IN_JUMP; if (keys & IK_B) input |= IN_ACTION; if (keys & IK_C) input |= IN_WEAPON; @@ -2735,8 +2737,18 @@ struct Lara : ItemObj if (keys & IK_L) input |= IN_LOOK; if (keys & IK_R) input |= IN_WALK; } - #else - if (keys & IK_A) + #elif defined(__GBA__) || defined(_WIN32) + 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 (extraL->weaponState != WEAPON_STATE_BUSY) { @@ -2749,7 +2761,7 @@ struct Lara : ItemObj } } - if (keys & IK_B) + if (keys & ikB) { if (keys & IK_L) { input |= IN_UP | IN_DOWN; @@ -2766,6 +2778,13 @@ struct Lara : ItemObj 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 if (keys & IK_LEFT) input |= IN_LEFT;