Skip to content

Commit

Permalink
Read ALL strings from T2K data files
Browse files Browse the repository at this point in the history
* High Score names (teams and solo)
* Licensing info on title screen
* Mouse settings menu implemented
* Super Tyrian text
  • Loading branch information
KScl committed Jul 31, 2020
1 parent 10a5752 commit 73eab84
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 102 deletions.
129 changes: 59 additions & 70 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ const DosKeySettings defaultDosKeySettings =
72, 80, 75, 77, 57, 28, 29, 56
};

const MouseSettings defaultMouseSettings =
{
1, 4, 5
};

const KeySettings defaultKeySettings =
{
SDL_SCANCODE_UP,
Expand All @@ -77,74 +82,24 @@ static const char *const keySettingNames[] =
"right sidekick",
};

const char defaultHighScoreNames[34][23] = /* [1..34] of string [22] */
{/*1P*/
/*TYR*/ "The Prime Chair", /*13*/
"Transon Lohk",
"Javi Onukala",
"Mantori",
"Nortaneous",
"Dougan",
"Reid",
"General Zinglon",
"Late Gyges Phildren",
"Vykromod",
"Beppo",
"Borogar",
"ShipMaster Carlos",

/*OTHER*/ "Jill", /*5*/
"Darcy",
"Jake Stone",
"Malvineous Havershim",
"Marta Louise Velasquez",

/*JAZZ*/ "Jazz Jackrabbit", /*3*/
"Eva Earlong",
"Devan Shell",

/*OMF*/ "Crystal Devroe", /*11*/
"Steffan Tommas",
"Milano Angston",
"Christian",
"Shirro",
"Jean-Paul",
"Ibrahim Hothe",
"Angel",
"Cossette Akira",
"Raven",
"Hans Kreissack",

/*DARE*/ "Tyler", /*2*/
"Rennis the Rat Guard"
static const char *const mouseSettingNames[] =
{
"left mouse",
"right mouse",
"middle mouse",
};

const char defaultTeamNames[22][25] = /* [1..22] of string [24] */
static const char *const mouseSettingValues[] =
{
"Jackrabbits",
"Team Tyrian",
"The Elam Brothers",
"Dare to Dream Team",
"Pinball Freaks",
"Extreme Pinball Freaks",
"Team Vykromod",
"Epic All-Stars",
"Hans Keissack's WARriors",
"Team Overkill",
"Pied Pipers",
"Gencore Growlers",
"Microsol Masters",
"Beta Warriors",
"Team Loco",
"The Shellians",
"Jungle Jills",
"Murderous Malvineous",
"The Traffic Department",
"Clan Mikal",
"Clan Patrok",
"Carlos' Crawlers"
"fire main weapon",
"fire left sidekick",
"fire right sidekick",
"fire both sidekicks",
"change rear mode",
};

char defaultHighScoreNames[39][23]; /* [1..39] of string [22] */
char defaultTeamNames[10][25]; /* [1..22] of string [24] */

const JE_EditorItemAvailType initialItemAvail =
{
Expand Down Expand Up @@ -199,6 +154,9 @@ JE_byte mainLevel, nextLevel, saveLevel; /*Current Level #*/
DosKeySettings dosKeySettings;
KeySettings keySettings;

/* Mouse settings */
MouseSettings mouseSettings;

/* Configuration */
JE_shortint levelFilter, levelFilterNew, levelBrightness, levelBrightnessChg;
JE_boolean filtrationAvail, filterActive, filterFade, filterFadeStart;
Expand Down Expand Up @@ -233,7 +191,7 @@ JE_boolean explosionTransparent,

JE_byte soundEffects; // dummy value for config
JE_byte versionNum; /* SW 1.0 and SW/Reg 1.1 = 0 or 1
* EA 1.2 = 2 */
* EA 1.2 = 2 T2K = 3*/

JE_byte fastPlay;
JE_boolean pentiumMode;
Expand Down Expand Up @@ -303,6 +261,28 @@ bool load_opentyrian_config( void )
}
}

memcpy(mouseSettings, defaultMouseSettings, sizeof(mouseSettings));

section = config_find_section(config, "mouse", NULL);
if (section != NULL)
{
for (size_t i = 0; i < COUNTOF(mouseSettings); ++i)
{
const char *mouseValue;
if (config_get_string_option(section, mouseSettingNames[i], &mouseValue))
{
for (size_t val = 1; val <= COUNTOF(mouseSettingValues); ++val)
{
if (strcmp(mouseValue, mouseSettingValues[val - 1]))
continue;

mouseSettings[i] = val;
break;
}
}
}
}

fclose(file);

return true;
Expand Down Expand Up @@ -341,11 +321,19 @@ bool save_opentyrian_config( void )
#else
mkdir(get_user_directory());
#endif

// Tyrian 2000 doesn't save mouse settings, so we do it ourselves
section = config_find_or_add_section(config, "mouse", NULL);
if (section == NULL)
exit(EXIT_FAILURE); // out of memory

for (size_t i = 0; i < COUNTOF(mouseSettings); ++i)
config_set_string_option(section, mouseSettingNames[i], mouseSettingValues[mouseSettings[i] - 1]);

FILE *file = dir_fopen(get_user_directory(), "opentyrian.cfg", "w");
if (file == NULL)
return false;

config_write(config, file);

#if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE
Expand Down Expand Up @@ -834,6 +822,7 @@ void JE_loadConfiguration( void )
gammaCorrection = 0;
processorType = 3;
gameSpeed = 4;
versionNum = 3;
}

load_opentyrian_config();
Expand Down Expand Up @@ -978,9 +967,9 @@ void JE_loadConfiguration( void )
if (z % 6 > 2)
{
saveFiles[z].highScore2 = ((mt_rand() % 20) + 1) * 1000;
strcpy(saveFiles[z].highScoreName, defaultTeamNames[mt_rand() % 22]);
strcpy(saveFiles[z].highScoreName, defaultTeamNames[mt_rand() % COUNTOF(defaultTeamNames)]);
} else {
strcpy(saveFiles[z].highScoreName, defaultHighScoreNames[mt_rand() % 34]);
strcpy(saveFiles[z].highScoreName, defaultHighScoreNames[mt_rand() % COUNTOF(defaultHighScoreNames)]);
}
}

Expand All @@ -990,7 +979,7 @@ void JE_loadConfiguration( void )
{
// Timed Battle scores
t2kHighScores[z][y].score = ((mt_rand() % 50) + 1) * 100;
strcpy(t2kHighScores[z][y].playerName, defaultHighScoreNames[mt_rand() % 34]);
strcpy(t2kHighScores[z][y].playerName, defaultHighScoreNames[mt_rand() % COUNTOF(defaultHighScoreNames)]);
}
}
for (z = 10; z < 20; ++z)
Expand All @@ -1000,9 +989,9 @@ void JE_loadConfiguration( void )
// Main Game scores
t2kHighScores[z][y].score = ((mt_rand() % 20) + 1) * 1000;
if (z & 1)
strcpy(t2kHighScores[z][y].playerName, defaultTeamNames[mt_rand() % 22]);
strcpy(t2kHighScores[z][y].playerName, defaultTeamNames[mt_rand() % COUNTOF(defaultTeamNames)]);
else
strcpy(t2kHighScores[z][y].playerName, defaultHighScoreNames[mt_rand() % 34]);
strcpy(t2kHighScores[z][y].playerName, defaultHighScoreNames[mt_rand() % COUNTOF(defaultHighScoreNames)]);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ typedef JE_byte DosKeySettings[8]; // fka KeySettingType

typedef SDL_Scancode KeySettings[8];

typedef JE_byte MouseSettings[3];

typedef JE_byte JE_PItemsType[12]; /* [1..12] */

typedef JE_byte JE_EditorItemAvailType[100]; /* [1..100] */
Expand Down Expand Up @@ -103,8 +105,9 @@ extern T2KHighScoreType t2kHighScores[20][3];
extern const JE_byte cryptKey[10];
extern const DosKeySettings defaultDosKeySettings; // fka defaultKeySettings
extern const KeySettings defaultKeySettings;
extern const char defaultHighScoreNames[34][23];
extern const char defaultTeamNames[22][25];
extern const MouseSettings defaultMouseSettings;
extern char defaultHighScoreNames[39][23];
extern char defaultTeamNames[10][25];
extern const JE_EditorItemAvailType initialItemAvail;
extern JE_boolean smoothies[9];
extern JE_byte starShowVGASpecialCode;
Expand Down Expand Up @@ -137,6 +140,7 @@ extern char lastLevelName[11], levelName[11];
extern JE_byte mainLevel, nextLevel, saveLevel;
extern DosKeySettings dosKeySettings; // fka keySettings
extern KeySettings keySettings;
extern MouseSettings mouseSettings;
extern JE_shortint levelFilter, levelFilterNew, levelBrightness, levelBrightnessChg;
extern JE_boolean filtrationAvail, filterActive, filterFade, filterFadeStart;
extern JE_boolean gameJustLoaded;
Expand Down
44 changes: 38 additions & 6 deletions src/game_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ enum
MENU_LIMITED_OPTIONS = 11, // Hides save/load menus.
MENU_JOYSTICK_CONFIG = 12,
MENU_SUPER_TYRIAN = 13,
MENU_MOUSE_CONFIG = 14, // T2000
};

/*** Structs ***/
Expand Down Expand Up @@ -104,8 +105,8 @@ static PlayerItems old_items[2]; // TODO: should not be global if possible

static struct cube_struct cube[4];

static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 9, 0, 0, 11, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 };
static const JE_byte menuEsc[MENU_MAX] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0 };
static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 9, 0, 0, 11, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5, 6 };
static const JE_byte menuEsc[MENU_MAX] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0, 2 };
static const JE_byte itemAvailMap[7] = { 1, 2, 3, 9, 4, 6, 7 };
static const JE_word planetX[21] = { 200, 150, 240, 300, 270, 280, 320, 260, 220, 150, 160, 210, 80, 240, 220, 180, 310, 330, 150, 240, 200 };
static const JE_word planetY[21] = { 40, 90, 90, 80, 170, 30, 50, 130, 120, 150, 220, 200, 80, 50, 160, 10, 55, 55, 90, 90, 40 };
Expand Down Expand Up @@ -307,11 +308,20 @@ void JE_itemScreen( void )
/* Draw menu choices for simple menus */
if ((curMenu >= MENU_FULL_GAME && curMenu <= MENU_PLAY_NEXT_LEVEL) ||
(curMenu >= MENU_2_PLAYER_ARCADE && curMenu <= MENU_LIMITED_OPTIONS) ||
curMenu == MENU_SUPER_TYRIAN)
curMenu >= MENU_SUPER_TYRIAN)
{
JE_drawMenuChoices();
}

if (curMenu == MENU_MOUSE_CONFIG)
{
for (int i = 0; i < 3; ++i)
{
int tempY = 51 + i * 24;
JE_textShade(VGAScreen, 215, tempY, joyButtonNames[mouseSettings[i] - 1], 15, 2, PART_SHADE);
}
}

/* Data cube icons */
if (curMenu == MENU_FULL_GAME)
{
Expand Down Expand Up @@ -1155,7 +1165,7 @@ void JE_itemScreen( void )
mouseX < 308 &&
curMenu != MENU_DATA_CUBE_SUB)
{
const JE_byte mouseSelectionY[MENU_MAX] = { 16, 16, 16, 16, 26, 12, 11, 28, 0, 16, 16, 16, 8, 16 };
const JE_byte mouseSelectionY[MENU_MAX] = { 16, 16, 16, 16, 26, 12, 11, 28, 0, 16, 16, 16, 8, 16, 24 };

int selection = (mouseY - 38) / mouseSelectionY[curMenu]+2;

Expand Down Expand Up @@ -1983,6 +1993,11 @@ void JE_drawMenuChoices( void )
tempY -= 16;
}

if (curMenu == MENU_MOUSE_CONFIG)
{
tempY += (x-2) * 8;
}

str = malloc(strlen(menuInt[curMenu + 1][x-1])+2);
if (curSel[curMenu] == x)
{
Expand Down Expand Up @@ -2783,8 +2798,7 @@ void JE_menuFunction( JE_byte select )
curMenu = MENU_KEYBOARD_CONFIG;
break;
case 8:
// TODO Mouse settings menu
JE_playSampleNum(S_SPRING);
curMenu = MENU_MOUSE_CONFIG;
break;
case 9:
curMenu = MENU_FULL_GAME;
Expand Down Expand Up @@ -3119,6 +3133,24 @@ void JE_menuFunction( JE_byte select )
}
}
break;

case MENU_MOUSE_CONFIG:
switch(curSel[curMenu])
{
case 2:
case 3:
case 4:
temp = curSel[curMenu] - 2;
if (++mouseSettings[temp] > 5)
mouseSettings[temp] = 1;
break;
case 5:
memcpy(mouseSettings, defaultMouseSettings, sizeof(mouseSettings));
break;
case 6:
curMenu = MENU_OPTIONS;
break;
}
}

old_items[0] = player[0].items;
Expand Down
Loading

0 comments on commit 73eab84

Please sign in to comment.