Skip to content

Commit

Permalink
Removed the Xbox-specific code
Browse files Browse the repository at this point in the history
I found no trace of the SDL functions used there, nor any documentation
about whether it's supposed to work or if it's even buildable.
  • Loading branch information
mmatyas committed Apr 4, 2024
1 parent a298d62 commit ee58b70
Show file tree
Hide file tree
Showing 25 changed files with 42 additions and 547 deletions.
8 changes: 4 additions & 4 deletions src/common/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ MusicEntry::MusicEntry(const std::string & musicdirectory)

char * pszMusic = strtok(NULL, ",\n");
while (pszMusic) {
std::string sPath = musicdirectory + getDirectorySeperator() + convertPartialPath(std::string(pszMusic));
std::string sPath = musicdirectory + getDirectorySeperator() + pszMusic;

if (File_Exists(sPath.c_str())) {
songFileNames.push_back(sPath);
Expand All @@ -548,7 +548,7 @@ MusicEntry::MusicEntry(const std::string & musicdirectory)
pszMusic = strtok(NULL, ",\n");
}
} else {
std::string sPath = musicdirectory + getDirectorySeperator() + convertPartialPath(std::string(szBuffer));
std::string sPath = musicdirectory + getDirectorySeperator() + szBuffer;

if (File_Exists(sPath.c_str())) {
songFileNames.push_back(sPath);
Expand Down Expand Up @@ -855,7 +855,7 @@ WorldMusicEntry::WorldMusicEntry(const std::string & musicdirectory)
}

if (iAddToCategory > -1 && iAddToCategory <= WORLDMUSICSLEEP) {
std::string sPath = musicdirectory + getDirectorySeperator() + convertPartialPath(std::string(szBuffer));
std::string sPath = musicdirectory + getDirectorySeperator() + szBuffer;

if (File_Exists(sPath.c_str()))
songFileNames[iAddToCategory] = sPath;
Expand All @@ -870,7 +870,7 @@ WorldMusicEntry::WorldMusicEntry(const std::string & musicdirectory)
if (!pszMusic)
continue;

std::string sPath = musicdirectory + getDirectorySeperator() + convertPartialPath(std::string(pszMusic));
std::string sPath = musicdirectory + getDirectorySeperator() + pszMusic;

if (!File_Exists(sPath.c_str()))
continue;
Expand Down
8 changes: 0 additions & 8 deletions src/common/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ CGame::CGame()
else if (!S_ISDIR(st.st_mode)) // inode exist, but not a directory
perror("[error] Could not access settings directory");
#endif

#ifdef _XBOX
//TODO: make this configurable!
//TV's seem to need extra shade
MenuTransparency = 96;
#else
MenuTransparency = 72;
#endif
}
6 changes: 3 additions & 3 deletions src/common/Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CGame {
public:
CGame();

int ScreenWidth = 640;
int ScreenHeight = 480;
int MenuTransparency;
const int ScreenWidth = 640;
const int ScreenHeight = 480;
const int MenuTransparency = 72;
};
66 changes: 1 addition & 65 deletions src/common/GameValues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,6 @@ SDL_KEYTYPE controlkeys[2][2][4][NUM_KEYS] = { { { {SDLK_LEFT, SDLK_RIGHT, SDLK_
{SDLK_p, SDLK_SEMICOLON, SDLK_l, SDLK_QUOTE, SDLK_LEFTBRACKET, SDLK_o, SDLK_UNKNOWN, SDLK_UNKNOWN}
}
},
#ifdef _XBOX
//left, right, jump, down, turbo, powerup, start, cancel
{ { {JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, JOY_HAT_DOWN, 14, 15, 20, 21},
{JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, JOY_HAT_DOWN, 14, 15, 20, 21},
{JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, JOY_HAT_DOWN, 14, 15, 20, 21},
{JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, JOY_HAT_DOWN, 14, 15, 20, 21}
},

//up, down, left, right, select, cancel, random, fast scroll
{ {JOY_HAT_UP, JOY_HAT_DOWN, JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, 21, 14, 15},
{JOY_HAT_UP, JOY_HAT_DOWN, JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, 21, 14, 15},
{JOY_HAT_UP, JOY_HAT_DOWN, JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, 21, 14, 15},
{JOY_HAT_UP, JOY_HAT_DOWN, JOY_HAT_LEFT, JOY_HAT_RIGHT, 12, 21, 14, 15}
}
}
};
#else
//left, right, jump, down, turbo, powerup, start, cancel;
{ { {JOY_STICK_1_LEFT, JOY_STICK_1_RIGHT, JOY_BUTTON_START, JOY_STICK_1_DOWN, JOY_BUTTON_START + 1, JOY_BUTTON_START + 2, JOY_BUTTON_START + 3, JOY_BUTTON_START + 4},
{JOY_STICK_1_LEFT, JOY_STICK_1_RIGHT, JOY_BUTTON_START, JOY_STICK_1_DOWN, JOY_BUTTON_START + 1, JOY_BUTTON_START + 2, JOY_BUTTON_START + 3, JOY_BUTTON_START + 4},
Expand All @@ -78,7 +61,6 @@ SDL_KEYTYPE controlkeys[2][2][4][NUM_KEYS] = { { { {SDLK_LEFT, SDLK_RIGHT, SDLK_
}
}
};
#endif

extern CGameValues game_values;
void ifSoundOnPlay(sfxSound& sfx)
Expand Down Expand Up @@ -115,11 +97,6 @@ void CGameValues::init()
softfilter = 0; //No soft filter by default
aspectratio10x11 = false; //No 10x11 aspect ratio by default

#ifdef _XBOX
SDL_XBOX_SetScreenPosition(screenResizeX, screenResizeY);
SDL_XBOX_SetScreenStretch(screenResizeW, screenResizeH);
#endif

awardstyle = AwardStyle::Fireworks;
spawnstyle = SpawnStyle::Swirl;
tournamentgames = 2;
Expand Down Expand Up @@ -228,12 +205,7 @@ void CGameValues::init()
}

//Set the players input to the default configuration (will be overwritten by options.bin settings)
#ifdef _XBOX
inputConfiguration[iPlayer][1].iDevice = iPlayer;
playerInput.inputControls[iPlayer] = &inputConfiguration[iPlayer][1];
#else
playerInput.inputControls[iPlayer] = &inputConfiguration[iPlayer][0];
#endif
}
}

Expand Down Expand Up @@ -287,21 +259,6 @@ void CGameValues::ReadBinaryConfig() {
return;
}

#ifdef _XBOX
flickerfilter = options.read_i16();
hardwarefilter = options.read_i16();
softfilter = options.read_i16();
aspectratio10x11 = options.read_bool();

screenResizeX = options.read_float();
screenResizeY = options.read_float();
screenResizeW = options.read_float();
screenResizeH = options.read_float();

SDL_XBOX_SetScreenPosition(screenResizeX, screenResizeY);
SDL_XBOX_SetScreenStretch(screenResizeW, screenResizeH);
#endif

spawnstyle = static_cast<SpawnStyle>(options.read_u8());
awardstyle = static_cast<AwardStyle>(options.read_u8());
teamcollision = static_cast<TeamCollisionStyle>(options.read_u8());
Expand Down Expand Up @@ -363,10 +320,6 @@ void CGameValues::ReadBinaryConfig() {
poweruppreset = options.read_i16();
options.read_i16_array((int16_t *)g_iCurrentPowerupPresets, NUM_POWERUP_PRESETS * NUM_POWERUPS);

#ifndef _XBOX
fullscreen = options.read_bool();
#endif

for (short iGameMode = 0; iGameMode < GAMEMODE_LAST; iGameMode++)
gamemodes[iGameMode]->goal = options.read_i16();

Expand Down Expand Up @@ -421,14 +374,10 @@ void CGameValues::ReadBinaryConfig() {
for (short iPlayer = 0; iPlayer < MAX_PLAYERS; iPlayer++) {
short iDevice = controls.read_i16();

#ifdef _XBOX
playerInput.inputControls[iPlayer] = &inputConfiguration[iPlayer][1]; //Always use gamepads as input devices on xbox
#else
if (iDevice >= joystickcount)
iDevice = DEVICE_KEYBOARD;

playerInput.inputControls[iPlayer] = &inputConfiguration[iPlayer][iDevice == DEVICE_KEYBOARD ? 0 : 1];
#endif
}
}
catch (std::exception const& error)
Expand All @@ -448,18 +397,6 @@ void CGameValues::WriteConfig()

options.write_raw(g_iVersion, sizeof(int) * 4);

#ifdef _XBOX
options.write_i16(flickerfilter);
options.write_i16(hardwarefilter);
options.write_i16(softfilter);
options.write_bool(aspectratio10x11);

options.write_float(screenResizeX);
options.write_float(screenResizeY);
options.write_float(screenResizeW);
options.write_float(screenResizeH);
#endif

options.write_u8(static_cast<uint8_t>(spawnstyle));
options.write_u8(static_cast<uint8_t>(awardstyle));
options.write_u8(static_cast<uint8_t>(teamcollision));
Expand Down Expand Up @@ -521,9 +458,8 @@ void CGameValues::WriteConfig()
options.write_i16(poweruppreset);
options.write_raw(&g_iCurrentPowerupPresets, sizeof(short) * NUM_POWERUP_PRESETS * NUM_POWERUPS);

#ifndef _XBOX
options.write_bool(fullscreen);
#endif

//Write out game mode goals
for (short k = 0; k < GAMEMODE_LAST; k++)
options.write_i16(gamemodes[k]->goal);
Expand Down
2 changes: 1 addition & 1 deletion src/common/ResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ bool CResourceManager::LoadGameSounds()
{
game_values.soundcapable = false;

#if !defined(_XBOX) && !defined(__EMSCRIPTEN__) //xbox and emscripten has sound capabilities
#ifndef __EMSCRIPTEN__ // emscripten has sound capabilities
int frequency, channels;
Uint16 format;

Expand Down
10 changes: 5 additions & 5 deletions src/common/TilesetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CTileset::CTileset(const char * szpath)

strcpy(szFile, szpath);
strcat(szFile, "/large.png");
gfx_loadimage(&sSprites[0], convertPartialPath(szFile), false);
gfx_loadimage(&sSprites[0], szFile, false);

sSurfaces[0] = sSprites[0].getSurface(); //optimization for repeat surface use

Expand All @@ -42,20 +42,20 @@ CTileset::CTileset(const char * szpath)

strcpy(szFile, szpath);
strcat(szFile, "/medium.png");
gfx_loadimage(&sSprites[1], convertPartialPath(szFile), false);
gfx_loadimage(&sSprites[1], szFile, false);

sSurfaces[1] = sSprites[1].getSurface();

strcpy(szFile, szpath);
strcat(szFile, "/small.png");
gfx_loadimage(&sSprites[2], convertPartialPath(szFile), false);
gfx_loadimage(&sSprites[2], szFile, false);

sSurfaces[2] = sSprites[2].getSurface();

strcpy(szFile, szpath);
strcat(szFile, "/tileset.tls");

strcpy(szTilesetPath, convertPartialPath(szFile).c_str());
strcpy(szTilesetPath, szFile);
ReadTileTypeFile(szTilesetPath);
}

Expand Down Expand Up @@ -169,7 +169,7 @@ void CTilesetManager::Init(const char * szGfxPack)

//Add in tilesets from the new gfxpack (if the gfxpack isn't "Classic")
if (strcmp(getFileFromPath(szGfxPack).c_str(), "Classic")) {
std::string s = convertPath("gfx/packs/tilesets", szGfxPack) + getDirectorySeperator();
std::string s = convertPath("gfx/packs/tilesets", szGfxPack) + '/';
SimpleDirectoryList dirlist(s);

short iLength = dirlist.GetCount();
Expand Down
20 changes: 8 additions & 12 deletions src/common/dirlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#ifndef LIST_DIRECTORIES_HEADER
#define LIST_DIRECTORIES_HEADER

#ifdef _XBOX
# include <xtl.h>
#else
# ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#include <cstdio>
# else
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <dirent.h>
# endif
#else
# include <sys/types.h>
# include <sys/stat.h>
# include <unistd.h>
# include <dirent.h>
#endif

#include <string>
Expand Down
10 changes: 0 additions & 10 deletions src/common/gfx/gfxSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,17 +300,7 @@ void GraphicsSDL::RecreateWindow(bool fullscreen)
if (fullscreen)
flags |= SDL_FULLSCREEN;

#ifdef _XBOX
if (game_values.aspectratio10x11)
flags |= SDL_10X11PIXELASPECTRATIO;

screen = SDL_SetVideoModeWithFlickerFilter(GFX_SCREEN_W, GFX_SCREEN_H, GFX_BPP,
flags, game_values.flickerfilter, game_values.softfilter);

#else
screen = SDL_SetVideoMode(GFX_SCREEN_W, GFX_SCREEN_H, GFX_BPP, flags);
#endif

if (!screen) {
printf("[gfx] Couldn't create window: %s\n", SDL_GetError());
throw E_CREATE_WINDOW;
Expand Down
59 changes: 6 additions & 53 deletions src/common/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,68 +14,21 @@ CPlayerInput::CPlayerInput()
}
}

iPressedKey = 0;

fUsingMouse = false;
}

void CPlayerInput::CheckIfMouseUsed()
{
#ifndef _XBOX

for (short iGameState = 0; iGameState < 2; iGameState++) {
for (short iPlayer = 0; iPlayer < MAX_PLAYERS; iPlayer++) {
CInputControl * inputControl = &inputControls[iPlayer]->inputGameControls[iGameState];

for (short iKey = 0; iKey < NUM_KEYS; iKey++) {
SDL_KEYTYPE iInputKey = inputControl->keys[iKey];

//Need to reset analog mouse and joystick because there isn't a no longer moving event
if ((iInputKey >= MOUSE_UP && iInputKey <= MOUSE_RIGHT) ||
iInputKey == MOUSE_BUTTON_START + 4 || iInputKey == MOUSE_BUTTON_START + 5) {
fUsingMouse = true;
return;
}
}
}
}

#endif

fUsingMouse = false;
iPressedKey = 0;
}

//Pass in 0 for game and 1 for menu
//Clear old button pushed states
void CPlayerInput::ClearPressedKeys(short iGameState)
{
for (int iPlayer = 0; iPlayer < MAX_PLAYERS; iPlayer++) {
CInputControl * inputControl = &inputControls[iPlayer]->inputGameControls[iGameState];
COutputControl * outputControl = &outputControls[iPlayer];

COutputControl* outputControl = &outputControls[iPlayer];
for (int iKey = 0; iKey < NUM_KEYS; iKey++) {
outputControl->keys[iKey].fPressed = false;

#ifndef _XBOX
if (fUsingMouse) {
SDL_KEYTYPE iInputKey = inputControl->keys[iKey];

//Need to reset analog mouse and joystick because there isn't a no longer moving event
if ((iInputKey >= MOUSE_UP && iInputKey <= MOUSE_RIGHT) /*||
(iInputKey >= JOY_STICK_1_UP && iInputKey <= JOY_STICK_2_RIGHT)*/) {
outputControl->keys[iKey].fDown = false;
}
outputControl->keys[iKey].fPressed = false;
}
}

//Clear mouse scroll inputs (scroll button down/up happen on same frame so it needs special case)
if (iInputKey == MOUSE_BUTTON_START + 4 || iInputKey == MOUSE_BUTTON_START + 5) {
outputControl->keys[iKey].fDown = false;
}
}
#endif
}
}

iPressedKey = 0;
iPressedKey = 0;
}

void CPlayerInput::ClearGameActionKeys()
Expand Down
6 changes: 0 additions & 6 deletions src/common/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ class CPlayerInput
CPlayerInput();
~CPlayerInput(){}

//Called before
void CheckIfMouseUsed();

//Clears key pressed states
void ClearPressedKeys(short iGameState);
void ClearGameActionKeys();
Expand All @@ -126,9 +123,6 @@ class CPlayerInput
COutputControl outputControls[4];

SDL_KEYTYPE iPressedKey;

private:
bool fUsingMouse;
};

#endif // INPUT_H
Loading

0 comments on commit ee58b70

Please sign in to comment.