| 1 | /* |
| 2 | * OpenTyrian: A modern cross-platform port of Tyrian |
| 3 | * Copyright (C) 2007-2009 The OpenTyrian Development Team |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License |
| 7 | * as published by the Free Software Foundation; either version 2 |
| 8 | * of the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | #include "game_menu.h" |
| 20 | |
| 21 | #include "backgrnd.h" |
| 22 | #include "config.h" |
| 23 | #include "file.h" |
| 24 | #include "fonthand.h" |
| 25 | #include "joystick.h" |
| 26 | #include "keyboard.h" |
| 27 | #include "loudness.h" |
| 28 | #include "mainint.h" |
| 29 | #include "mouse.h" |
| 30 | #include "musmast.h" |
| 31 | #include "network.h" |
| 32 | #include "nortsong.h" |
| 33 | #include "nortvars.h" |
| 34 | #include "params.h" |
| 35 | #include "pcxmast.h" |
| 36 | #include "picload.h" |
| 37 | #include "player.h" |
| 38 | #include "shots.h" |
| 39 | #include "sprite.h" |
| 40 | #include "tyrian2.h" |
| 41 | #include "varz.h" |
| 42 | #include "vga256d.h" |
| 43 | #include "video.h" |
| 44 | |
| 45 | #include <assert.h> |
| 46 | |
| 47 | enum |
| 48 | { |
| 49 | MENU_FULL_GAME = 0, |
| 50 | MENU_UPGRADES = 1, |
| 51 | MENU_OPTIONS = 2, |
| 52 | MENU_PLAY_NEXT_LEVEL = 3, |
| 53 | MENU_UPGRADE_SUB = 4, |
| 54 | MENU_KEYBOARD_CONFIG = 5, |
| 55 | MENU_LOAD_SAVE = 6, |
| 56 | MENU_DATA_CUBES = 7, |
| 57 | MENU_DATA_CUBE_SUB = 8, |
| 58 | MENU_2_PLAYER_ARCADE = 9, |
| 59 | MENU_1_PLAYER_ARCADE = 10, // Also networked games. |
| 60 | MENU_LIMITED_OPTIONS = 11, // Hides save/load menus. |
| 61 | MENU_JOYSTICK_CONFIG = 12, |
| 62 | MENU_SUPER_TYRIAN = 13, |
| 63 | }; |
| 64 | |
| 65 | /*** Structs ***/ |
| 66 | struct cube_struct |
| 67 | { |
| 68 | char title[81]; |
| 69 | char header[13]; |
| 70 | int face_sprite; |
| 71 | char text[90][36]; |
| 72 | int last_line; |
| 73 | }; |
| 74 | |
| 75 | /*** Globals ***/ |
| 76 | static int joystick_config = 0; // which joystick is being configured in menu |
| 77 | |
| 78 | static JE_word yLoc; |
| 79 | static JE_shortint yChg; |
| 80 | static int newPal, curPal, oldPal; |
| 81 | static JE_boolean quikSave; |
| 82 | static JE_byte oldMenu; |
| 83 | static JE_boolean backFromHelp; |
| 84 | static JE_integer lastDirection; |
| 85 | static JE_boolean firstMenu9, paletteChanged; |
| 86 | static JE_MenuChoiceType menuChoices; |
| 87 | static JE_integer col, colC; |
| 88 | static JE_byte lastCurSel; |
| 89 | static JE_integer curMenu; |
| 90 | static JE_byte curSel[MENU_MAX]; /* [1..maxmenu] */ |
| 91 | static JE_byte curItemType, curItem, cursor; |
| 92 | static JE_boolean leftPower, rightPower, rightPowerAfford; |
| 93 | static JE_byte currentCube; |
| 94 | static JE_boolean keyboardUsed; |
| 95 | |
| 96 | static JE_byte planetAni, planetAniWait; |
| 97 | static JE_byte currentDotNum, currentDotWait; |
| 98 | static JE_real navX, navY, newNavX, newNavY; |
| 99 | static JE_integer tempNavX, tempNavY; |
| 100 | static JE_byte planetDots[5]; /* [1..5] */ |
| 101 | static JE_integer planetDotX[5][10], planetDotY[5][10]; /* [1..5, 1..10] */ |
| 102 | static PlayerItems old_items[2]; // TODO: should not be global if possible |
| 103 | |
| 104 | static struct cube_struct cube[4]; |
| 105 | |
| 106 | static const JE_MenuChoiceType menuChoicesDefault = { 7, 9, 8, 0, 0, 11, (SAVE_FILES_NUM / 2) + 2, 0, 0, 6, 4, 6, 7, 5 }; |
| 107 | static const JE_byte menuEsc[MENU_MAX] = { 0, 1, 1, 1, 2, 3, 3, 1, 8, 0, 0, 11, 3, 0 }; |
| 108 | static const JE_byte itemAvailMap[7] = { 1, 2, 3, 9, 4, 6, 7 }; |
| 109 | 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 }; |
| 110 | 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 }; |
| 111 | static const uint cube_line_chars = sizeof(*cube->text) - 1; |
| 112 | static const uint cube_line_width = 150; |
| 113 | |
| 114 | /*** Functions ***/ |
| 115 | static Uint8 *playeritem_map(PlayerItems *items, uint i) |
| 116 | { |
| 117 | Uint8 *const map[] = |
| 118 | { |
| 119 | &items->ship, |
| 120 | &items->weapon[FRONT_WEAPON].id, |
| 121 | &items->weapon[REAR_WEAPON].id, |
| 122 | &items->shield, |
| 123 | &items->generator, |
| 124 | &items->sidekick[LEFT_SIDEKICK], |
| 125 | &items->sidekick[RIGHT_SIDEKICK], |
| 126 | }; |
| 127 | assert(i < COUNTOF(map)); |
| 128 | return map[i]; |
| 129 | } |
| 130 | |
| 131 | JE_longint JE_cashLeft(void) |
| 132 | { |
| 133 | JE_longint tempL = player[0].cash; |
| 134 | JE_word itemNum = *playeritem_map(&player[0].items, curSel[MENU_UPGRADES] - 2); |
| 135 | |
| 136 | tempL -= JE_getCost(curSel[MENU_UPGRADES], itemNum); |
| 137 | |
| 138 | tempW = 0; |
| 139 | |
| 140 | switch (curSel[MENU_UPGRADES]) |
| 141 | { |
| 142 | case 3: |
| 143 | case 4: |
| 144 | for (uint i = 1; i < player[0].items.weapon[curSel[MENU_UPGRADES]-3].power; ++i) |
| 145 | { |
| 146 | tempW += weaponPort[itemNum].cost * i; |
| 147 | tempL -= tempW; |
| 148 | } |
| 149 | break; |
| 150 | } |
| 151 | |
| 152 | return tempL; |
| 153 | } |
| 154 | |
| 155 | void JE_itemScreen(void) |
| 156 | { |
| 157 | bool quit = false; |
| 158 | |
| 159 | if (shopSpriteSheet.data == NULL) |
| 160 | JE_loadCompShapes(&shopSpriteSheet, '1'); |
| 161 | |
| 162 | load_cubes(); |
| 163 | |
| 164 | VGAScreen = VGAScreenSeg; |
| 165 | |
| 166 | memcpy(menuChoices, menuChoicesDefault, sizeof(menuChoices)); |
| 167 | |
| 168 | play_song(songBuy); |
| 169 | |
| 170 | JE_loadPic(VGAScreen, 1, false); |
| 171 | |
| 172 | curPal = 1; |
| 173 | newPal = 0; |
| 174 | |
| 175 | JE_showVGA(); |
| 176 | |
| 177 | set_palette(colors, 0, 255); |
| 178 | |
| 179 | col = 1; |
| 180 | gameLoaded = false; |
| 181 | curItemType = 1; |
| 182 | cursor = 1; |
| 183 | curItem = 0; |
| 184 | |
| 185 | for (unsigned int i = 0; i < COUNTOF(curSel); ++i) |
| 186 | curSel[i] = 2; |
| 187 | |
| 188 | curMenu = MENU_FULL_GAME; |
| 189 | |
| 190 | int temp_weapon_power[7]; // assumes there'll never be more than 6 weapons to choose from, 7th is "Done" |
| 191 | |
| 192 | /* JE: (* Check for where Pitems and Select match up - if no match then add to the itemavail list *) */ |
| 193 | for (int i = 0; i < 7; i++) |
| 194 | { |
| 195 | int item = *playeritem_map(&player[0].last_items, i); |
| 196 | |
| 197 | int slot = 0; |
| 198 | |
| 199 | for (; slot < itemAvailMax[itemAvailMap[i]-1]; ++slot) |
| 200 | { |
| 201 | if (itemAvail[itemAvailMap[i]-1][slot] == item) |
| 202 | break; |
| 203 | } |
| 204 | |
| 205 | if (slot == itemAvailMax[itemAvailMap[i]-1]) |
| 206 | { |
| 207 | itemAvail[itemAvailMap[i]-1][slot] = item; |
| 208 | itemAvailMax[itemAvailMap[i]-1]++; |
| 209 | } |
| 210 | } |
| 211 | |
| 212 | memcpy(VGAScreen2->pixels, VGAScreen->pixels, VGAScreen2->pitch * VGAScreen2->h); |
| 213 | |
| 214 | keyboardUsed = false; |
| 215 | firstMenu9 = false; |
| 216 | backFromHelp = false; |
| 217 | |
| 218 | /* JE: Sort items in merchant inventory */ |
| 219 | for (int x = 0; x < 9; x++) |
| 220 | { |
| 221 | if (itemAvailMax[x] > 1) |
| 222 | { |
| 223 | for (temp = 0; temp < itemAvailMax[x] - 1; temp++) |
| 224 | { |
| 225 | for (temp2 = temp; temp2 < itemAvailMax[x]; temp2++) |
| 226 | { |
| 227 | if (itemAvail[x][temp] == 0 || (itemAvail[x][temp] > itemAvail[x][temp2] && itemAvail[x][temp2] != 0)) |
| 228 | { |
| 229 | temp3 = itemAvail[x][temp]; |
| 230 | itemAvail[x][temp] = itemAvail[x][temp2]; |
| 231 | itemAvail[x][temp2] = temp3; |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | do |
| 239 | { |
| 240 | quit = false; |
| 241 | |
| 242 | JE_getShipInfo(); |
| 243 | |
| 244 | if (curMenu == MENU_FULL_GAME) |
| 245 | { |
| 246 | if (twoPlayerMode) |
| 247 | curMenu = MENU_2_PLAYER_ARCADE; |
| 248 | |
| 249 | if (isNetworkGame || onePlayerAction) |
| 250 | curMenu = MENU_1_PLAYER_ARCADE; |
| 251 | |
| 252 | if (superTyrian) |
| 253 | curMenu = MENU_SUPER_TYRIAN; |
| 254 | } |
| 255 | |
| 256 | paletteChanged = false; |
| 257 | |
| 258 | leftPower = false; |
| 259 | rightPower = false; |
| 260 | |
| 261 | /* SYN: note reindexing... "firstMenu9" refers to Menu 8 here :( */ |
| 262 | if (curMenu != MENU_DATA_CUBE_SUB || firstMenu9) |
| 263 | { |
| 264 | memcpy(VGAScreen->pixels, VGAScreen2->pixels, VGAScreen->pitch * VGAScreen->h); |
| 265 | } |
| 266 | |
| 267 | if (curMenu == MENU_UPGRADES && |
| 268 | (curSel[curMenu] == 3 || curSel[curMenu] == 4)) |
| 269 | { |
| 270 | // reset temp_weapon_power[] every time we select upgrading front or back |
| 271 | const uint item = player[0].items.weapon[curSel[MENU_UPGRADES] - 3].id, |
| 272 | item_power = player[0].items.weapon[curSel[MENU_UPGRADES] - 3].power, |
| 273 | i = curSel[MENU_UPGRADES] - 2; // 1 or 2 (front or rear) |
| 274 | |
| 275 | // set power level of owned weapon |
| 276 | for (int slot = 0; slot < itemAvailMax[itemAvailMap[i]-1]; ++slot) |
| 277 | { |
| 278 | if (itemAvail[itemAvailMap[i]-1][slot] == item) |
| 279 | temp_weapon_power[slot] = item_power; |
| 280 | else |
| 281 | temp_weapon_power[slot] = 1; |
| 282 | } |
| 283 | |
| 284 | // set power level for "Done" |
| 285 | temp_weapon_power[itemAvailMax[itemAvailMap[i]-1]] = item_power; |
| 286 | } |
| 287 | |
| 288 | if (curMenu == MENU_PLAY_NEXT_LEVEL) |
| 289 | { |
| 290 | planetAni = 0; |
| 291 | keyboardUsed = false; |
| 292 | currentDotNum = 0; |
| 293 | currentDotWait = 8; |
| 294 | planetAniWait = 3; |
| 295 | JE_updateNavScreen(); |
| 296 | } |
| 297 | |
| 298 | /* Draw menu title for everything but upgrade ship submenus */ |
| 299 | if (curMenu != MENU_UPGRADE_SUB) |
| 300 | { |
| 301 | JE_drawMenuHeader(); |
| 302 | } |
| 303 | |
| 304 | /* Draw menu choices for simple menus */ |
| 305 | if ((curMenu >= MENU_FULL_GAME && curMenu <= MENU_PLAY_NEXT_LEVEL) || |
| 306 | (curMenu >= MENU_2_PLAYER_ARCADE && curMenu <= MENU_LIMITED_OPTIONS) || |
| 307 | curMenu == MENU_SUPER_TYRIAN) |
| 308 | { |
| 309 | JE_drawMenuChoices(); |
| 310 | } |
| 311 | |
| 312 | /* Data cube icons */ |
| 313 | if (curMenu == MENU_FULL_GAME) |
| 314 | { |
| 315 | for (int i = 1; i <= cubeMax; i++) |
| 316 | { |
| 317 | blit_sprite_dark(VGAScreen, 190 + i * 18 + 2, 37 + 1, OPTION_SHAPES, 34, false); |
| 318 | blit_sprite(VGAScreen, 190 + i * 18, 37, OPTION_SHAPES, 34); // data cube |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | /* load/save menu */ |
| 323 | if (curMenu == MENU_LOAD_SAVE) |
| 324 | { |
| 325 | int min, max; |
| 326 | |
| 327 | if (twoPlayerMode) |
| 328 | { |
| 329 | min = 13; |
| 330 | max = 24; |
| 331 | } |
| 332 | else |
| 333 | { |
| 334 | min = 2; |
| 335 | max = 13; |
| 336 | } |
| 337 | |
| 338 | for (int x = min; x <= max; x++) |
| 339 | { |
| 340 | /* Highlight if current selection */ |
| 341 | temp2 = (x - min + 2 == curSel[curMenu]) ? 15 : 28; |
| 342 | |
| 343 | /* Write save game slot */ |
| 344 | if (x == max) |
| 345 | strcpy(tempStr, miscText[6-1]); |
| 346 | else if (saveFiles[x-2].level == 0) |
| 347 | strcpy(tempStr, miscText[3-1]); |
| 348 | else |
| 349 | strcpy(tempStr, saveFiles[x-2].name); |
| 350 | |
| 351 | int tempY = 38 + (x - min)*11; |
| 352 | |
| 353 | JE_textShade(VGAScreen, 163, tempY, tempStr, temp2 / 16, temp2 % 16 - 8, DARKEN); |
| 354 | |
| 355 | if (x < max) /* x == max isn't a save slot */ |
| 356 | { |
| 357 | /* Highlight if current selection */ |
| 358 | temp2 = (x - min + 2 == curSel[curMenu]) ? 252 : 250; |
| 359 | |
| 360 | if (saveFiles[x-2].level == 0) |
| 361 | { |
| 362 | strcpy(tempStr, "-----"); /* Empty save slot */ |
| 363 | } |
| 364 | else |
| 365 | { |
| 366 | char buf[20]; |
| 367 | |
| 368 | strcpy(tempStr, saveFiles[x-2].levelName); |
| 369 | |
| 370 | snprintf(buf, sizeof buf, "%s%d", miscTextB[1-1], saveFiles[x-2].episode); |
| 371 | JE_textShade(VGAScreen, 297, tempY, buf, temp2 / 16, temp2 % 16 - 8, DARKEN); |
| 372 | } |
| 373 | |
| 374 | JE_textShade(VGAScreen, 245, tempY, tempStr, temp2 / 16, temp2 % 16 - 8, DARKEN); |
| 375 | } |
| 376 | |
| 377 | JE_drawMenuHeader(); |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | if (curMenu == MENU_KEYBOARD_CONFIG) |
| 382 | { |
| 383 | for (int x = 2; x <= 11; x++) |
| 384 | { |
| 385 | if (x == curSel[curMenu]) |
| 386 | { |
| 387 | temp2 = 15; |
| 388 | } |
| 389 | else |
| 390 | { |
| 391 | temp2 = 28; |
| 392 | } |
| 393 | |
| 394 | JE_textShade(VGAScreen, 166, 38 + (x - 2)*12, menuInt[curMenu + 1][x-1], temp2 / 16, temp2 % 16 - 8, DARKEN); |
| 395 | |
| 396 | if (x < 10) /* 10 = reset to defaults, 11 = done */ |
| 397 | { |
| 398 | temp2 = (x == curSel[curMenu]) ? 252 : 250; |
| 399 | JE_textShade(VGAScreen, 236, 38 + (x - 2)*12, SDL_GetScancodeName(keySettings[x-2]), temp2 / 16, temp2 % 16 - 8, DARKEN); |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | menuChoices[MENU_KEYBOARD_CONFIG] = 11; |
| 404 | } |
| 405 | |
| 406 | if (curMenu == MENU_JOYSTICK_CONFIG) |
| 407 | { |
| 408 | const char *const menu_item[] = |
| 409 | { |
| 410 | "JOYSTICK", |
| 411 | "ANALOG AXES", |
| 412 | " SENSITIVITY", |
| 413 | " THRESHOLD", |
| 414 | menuInt[6][1], |
| 415 | menuInt[6][4], |
| 416 | menuInt[6][2], |
| 417 | menuInt[6][3], |
| 418 | menuInt[6][5], |
| 419 | menuInt[6][6], |
| 420 | menuInt[6][7], |
| 421 | menuInt[6][8], |
| 422 | "MENU", |
| 423 | "PAUSE", |
| 424 | menuInt[6][9], |
| 425 | menuInt[6][10] |
| 426 | }; |
| 427 | |
| 428 | for (uint i = 0; i < COUNTOF(menu_item); i++) |
| 429 | { |
| 430 | int temp = (i == curSel[curMenu] - 2u) ? 15 : 28; |
| 431 | |
| 432 | JE_textShade(VGAScreen, 166, 38 + i * 8, menu_item[i], temp / 16, temp % 16 - 8, DARKEN); |
| 433 | |
| 434 | temp = (i == curSel[curMenu] - 2u) ? 252 : 250; |
| 435 | |
| 436 | char value[30] = ""; |
| 437 | if (joysticks == 0 && i < 14) // no joysticks, everything disabled |
| 438 | { |
| 439 | sprintf(value, "-"); |
| 440 | } |
| 441 | else if (i == 0) // joystick number |
| 442 | { |
| 443 | sprintf(value, "%d", joystick_config + 1); |
| 444 | } |
| 445 | else if (i == 1) // joystick is analog |
| 446 | { |
| 447 | sprintf(value, "%s", joystick[joystick_config].analog ? "TRUE" : "FALSE"); |
| 448 | } |
| 449 | else if (i < 4) // joystick analog settings |
| 450 | { |
| 451 | if (!joystick[joystick_config].analog) |
| 452 | temp -= 3; |
| 453 | sprintf(value, "%d", i == 2 ? joystick[joystick_config].sensitivity : joystick[joystick_config].threshold); |
| 454 | } |
| 455 | else if (i < 14) // assignments |
| 456 | { |
| 457 | joystick_assignments_to_string(value, sizeof(value), joystick[joystick_config].assignment[i - 4]); |
| 458 | } |
| 459 | |
| 460 | JE_textShade(VGAScreen, 236, 38 + i * 8, value, temp / 16, temp % 16 - 8, DARKEN); |
| 461 | } |
| 462 | |
| 463 | menuChoices[curMenu] = COUNTOF(menu_item) + 1; |
| 464 | } |
| 465 | |
| 466 | if (curMenu == MENU_UPGRADE_SUB) |
| 467 | { |
| 468 | /* Move cursor until we hit either "Done" or a weapon the player can afford */ |
| 469 | while (curSel[MENU_UPGRADE_SUB] < menuChoices[MENU_UPGRADE_SUB] && |
| 470 | JE_getCost(curSel[MENU_UPGRADES], itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][curSel[MENU_UPGRADE_SUB]-2]) > player[0].cash) |
| 471 | { |
| 472 | curSel[MENU_UPGRADE_SUB] += lastDirection; |
| 473 | if (curSel[MENU_UPGRADE_SUB] < 2) |
| 474 | curSel[MENU_UPGRADE_SUB] = menuChoices[MENU_UPGRADE_SUB]; |
| 475 | else if (curSel[MENU_UPGRADE_SUB] > menuChoices[MENU_UPGRADE_SUB]) |
| 476 | curSel[MENU_UPGRADE_SUB] = 2; |
| 477 | } |
| 478 | |
| 479 | if (curSel[MENU_UPGRADE_SUB] == menuChoices[MENU_UPGRADE_SUB]) |
| 480 | { |
| 481 | /* If cursor on "Done", use previous weapon */ |
| 482 | *playeritem_map(&player[0].items, curSel[MENU_UPGRADES] - 2) = *playeritem_map(&old_items[0], curSel[MENU_UPGRADES] - 2); |
| 483 | } |
| 484 | else |
| 485 | { |
| 486 | /* Otherwise display the selected weapon */ |
| 487 | *playeritem_map(&player[0].items, curSel[MENU_UPGRADES] - 2) = itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][curSel[MENU_UPGRADE_SUB]-2]; |
| 488 | } |
| 489 | |
| 490 | /* Get power level info for front and rear weapons */ |
| 491 | if ((curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4) && // front or rear weapon |
| 492 | curSel[MENU_UPGRADE_SUB] < menuChoices[MENU_UPGRADE_SUB] && // not "Done" |
| 493 | itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][curSel[MENU_UPGRADE_SUB]-2] != 0) // not "None" |
| 494 | { |
| 495 | const uint port = curSel[MENU_UPGRADES] - 3, // 0 or 1 (front or back) |
| 496 | item_level = player[0].items.weapon[port].power; |
| 497 | |
| 498 | // calculate upgradeCost |
| 499 | JE_getCost(curSel[MENU_UPGRADES], itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][curSel[MENU_UPGRADE_SUB]-2]); |
| 500 | |
| 501 | leftPower = item_level > 1; // can downgrade |
| 502 | rightPower = item_level < 11; // can upgrade |
| 503 | |
| 504 | if (rightPower) |
| 505 | rightPowerAfford = JE_cashLeft() >= upgradeCost; // can afford upgrade |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | /* Nothing else can be upgraded / downgraded */ |
| 510 | leftPower = false; |
| 511 | rightPower = false; |
| 512 | } |
| 513 | |
| 514 | /* submenu title e.g., "Left Sidekick" */ |
| 515 | JE_dString(VGAScreen, 74 + JE_fontCenter(menuInt[2][curSel[MENU_UPGRADES]-1], FONT_SHAPES), 10, menuInt[2][curSel[MENU_UPGRADES]-1], FONT_SHAPES); |
| 516 | |
| 517 | /* Iterate through all submenu options */ |
| 518 | for (tempW = 1; tempW < menuChoices[curMenu]; tempW++) |
| 519 | { |
| 520 | int tempY = 40 + (tempW-1) * 26; /* Calculate y position */ |
| 521 | uint temp_cost; |
| 522 | |
| 523 | /* Is this a item or None/DONE? */ |
| 524 | if (tempW < menuChoices[MENU_UPGRADE_SUB] - 1) |
| 525 | { |
| 526 | /* Get base cost for choice */ |
| 527 | temp_cost = JE_getCost(curSel[MENU_UPGRADES], itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][tempW-1]); |
| 528 | } |
| 529 | else |
| 530 | { |
| 531 | /* "None" is free :) */ |
| 532 | temp_cost = 0; |
| 533 | } |
| 534 | |
| 535 | int afford_shade = (temp_cost > player[0].cash) ? 4 : 0; // can player afford current weapon at all |
| 536 | |
| 537 | temp = itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][tempW-1]; /* Item ID */ |
| 538 | switch (curSel[MENU_UPGRADES]-1) |
| 539 | { |
| 540 | case 1: /* ship */ |
| 541 | if (temp > 90) |
| 542 | snprintf(tempStr, sizeof(tempStr), "Custom Ship %d", temp - 90); |
| 543 | else |
| 544 | strcpy(tempStr, ships[temp].name); |
| 545 | break; |
| 546 | case 2: /* front and rear weapon */ |
| 547 | case 3: |
| 548 | strcpy(tempStr, weaponPort[temp].name); |
| 549 | break; |
| 550 | case 4: /* shields */ |
| 551 | strcpy(tempStr, shields[temp].name); |
| 552 | break; |
| 553 | case 5: /* generator */ |
| 554 | strcpy(tempStr, powerSys[temp].name); |
| 555 | break; |
| 556 | case 6: /* sidekicks */ |
| 557 | case 7: |
| 558 | strcpy(tempStr, options[temp].name); |
| 559 | break; |
| 560 | } |
| 561 | if (tempW == curSel[curMenu]-1) |
| 562 | temp2 = 15; |
| 563 | else |
| 564 | temp2 = 28; |
| 565 | |
| 566 | JE_getShipInfo(); |
| 567 | |
| 568 | /* item-owned marker */ |
| 569 | if (temp == *playeritem_map(&old_items[0], curSel[MENU_UPGRADES] - 2) && temp != 0 && tempW != menuChoices[curMenu]-1) |
| 570 | { |
| 571 | fill_rectangle_xy(VGAScreen, 160, tempY+7, 300, tempY+11, 227); |
| 572 | blit_sprite2(VGAScreen, 298, tempY+2, shopSpriteSheet, 247); |
| 573 | } |
| 574 | |
| 575 | /* Draw DONE */ |
| 576 | if (tempW == menuChoices[curMenu]-1) |
| 577 | { |
| 578 | strcpy(tempStr, miscText[13]); |
| 579 | } |
| 580 | JE_textShade(VGAScreen, 185, tempY, tempStr, temp2 / 16, temp2 % 16 - 8 - afford_shade, DARKEN); |
| 581 | |
| 582 | /* Draw icon if not DONE. NOTE: None is a normal item with a blank icon. */ |
| 583 | if (tempW < menuChoices[curMenu]-1) |
| 584 | { |
| 585 | JE_drawItem(curSel[MENU_UPGRADES]-1, temp, 160, tempY-4); |
| 586 | } |
| 587 | |
| 588 | /* Make selected text brighter */ |
| 589 | temp2 = (tempW == curSel[curMenu]-1) ? 15 : 28; |
| 590 | |
| 591 | /* Draw Cost: if it's not the DONE option */ |
| 592 | if (tempW != menuChoices[curMenu]-1) |
| 593 | { |
| 594 | char buf[20]; |
| 595 | |
| 596 | snprintf(buf, sizeof buf, "Cost: %d", temp_cost); |
| 597 | JE_textShade(VGAScreen, 187, tempY+10, buf, temp2 / 16, temp2 % 16 - 8 - afford_shade, DARKEN); |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | /* Draw current money and shield/armor bars, when appropriate */ |
| 603 | if (((curMenu <= MENU_OPTIONS || |
| 604 | curMenu == MENU_KEYBOARD_CONFIG || |
| 605 | curMenu == MENU_LOAD_SAVE || |
| 606 | curMenu >= MENU_1_PLAYER_ARCADE) && |
| 607 | !twoPlayerMode) || |
| 608 | (curMenu == MENU_UPGRADE_SUB && |
| 609 | (curSel[MENU_UPGRADES] >= 1 && curSel[MENU_UPGRADES] <= 6))) |
| 610 | { |
| 611 | if (curMenu != MENU_UPGRADE_SUB) |
| 612 | { |
| 613 | char buf[20]; |
| 614 | |
| 615 | snprintf(buf, sizeof buf, "%lu", player[0].cash); |
| 616 | JE_textShade(VGAScreen, 65, 173, buf, 1, 6, DARKEN); |
| 617 | } |
| 618 | JE_barDrawShadow(VGAScreen, 42, 152, 3, 14, player[0].armor, 2, 13); |
| 619 | JE_barDrawShadow(VGAScreen, 104, 152, 2, 14, shields[player[0].items.shield].mpwr * 2, 2, 13); |
| 620 | } |
| 621 | |
| 622 | /* Draw crap on the left side of the screen, i.e. two player scores, ship graphic, etc. */ |
| 623 | if ((curMenu >= MENU_FULL_GAME && curMenu <= MENU_OPTIONS) || |
| 624 | curMenu == MENU_KEYBOARD_CONFIG || |
| 625 | curMenu == MENU_LOAD_SAVE || |
| 626 | curMenu >= MENU_2_PLAYER_ARCADE || |
| 627 | (curMenu == MENU_UPGRADE_SUB && |
| 628 | (curSel[MENU_UPGRADES] == 2 || curSel[MENU_UPGRADES] == 5))) |
| 629 | { |
| 630 | if (twoPlayerMode) |
| 631 | { |
| 632 | char buf[50]; |
| 633 | |
| 634 | for (uint i = 0; i < 2; ++i) |
| 635 | { |
| 636 | snprintf(buf, sizeof(buf), "%s %lu", miscText[40 + i], player[i].cash); |
| 637 | JE_textShade(VGAScreen, 25, 50 + 10 * i, buf, 15, 0, FULL_SHADE); |
| 638 | } |
| 639 | } |
| 640 | else if (superArcadeMode != SA_NONE || superTyrian) |
| 641 | { |
| 642 | helpBoxColor = 15; |
| 643 | helpBoxBrightness = 4; |
| 644 | if (!superTyrian) |
| 645 | JE_helpBox(VGAScreen, 35, 25, superShips[superArcadeMode], 18); |
| 646 | else |
| 647 | JE_helpBox(VGAScreen, 35, 25, superShips[SA+3], 18); |
| 648 | helpBoxBrightness = 1; |
| 649 | |
| 650 | JE_textShade(VGAScreen, 25, 50, superShips[SA+1], 15, 0, FULL_SHADE); |
| 651 | JE_helpBox(VGAScreen, 25, 60, weaponPort[player[0].items.weapon[FRONT_WEAPON].id].name, 22); |
| 652 | JE_textShade(VGAScreen, 25, 120, superShips[SA+2], 15, 0, FULL_SHADE); |
| 653 | JE_helpBox(VGAScreen, 25, 130, special[player[0].items.special].name, 22); |
| 654 | } |
| 655 | else |
| 656 | { |
| 657 | draw_ship_illustration(); |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | /* Changing the volume? */ |
| 662 | if (curMenu == MENU_OPTIONS || |
| 663 | curMenu == MENU_LIMITED_OPTIONS) |
| 664 | { |
| 665 | JE_barDrawShadow(VGAScreen, 225, 70, 1, music_disabled ? 12 : 16, tyrMusicVolume / 12, 3, 13); |
| 666 | JE_barDrawShadow(VGAScreen, 225, 86, 1, samples_disabled ? 12 : 16, fxVolume / 12, 3, 13); |
| 667 | } |
| 668 | |
| 669 | /* "firstmenu9" refers to menu 8 because of reindexing */ |
| 670 | if (curMenu == MENU_DATA_CUBES || |
| 671 | (curMenu == MENU_DATA_CUBE_SUB && (firstMenu9 || backFromHelp))) |
| 672 | { |
| 673 | firstMenu9 = false; |
| 674 | menuChoices[MENU_DATA_CUBES] = cubeMax + 2; |
| 675 | fill_rectangle_xy(VGAScreen, 1, 1, 145, 170, 0); |
| 676 | |
| 677 | blit_sprite(VGAScreenSeg, 1, 1, OPTION_SHAPES, 20); /* Portrait area background */ |
| 678 | |
| 679 | if (curMenu == MENU_DATA_CUBES) |
| 680 | { |
| 681 | if (cubeMax == 0) |
| 682 | { |
| 683 | JE_helpBox(VGAScreen, 166, 80, miscText[16 - 1], 30); |
| 684 | tempW = 160; |
| 685 | temp2 = 252; |
| 686 | } |
| 687 | else |
| 688 | { |
| 689 | for (int x = 1; x <= cubeMax; x++) |
| 690 | { |
| 691 | JE_drawCube(VGAScreenSeg, 166, 38 + (x - 1) * 28, 13, 0); |
| 692 | if (x + 1 == curSel[curMenu]) |
| 693 | { |
| 694 | temp2 = 252; |
| 695 | } |
| 696 | else |
| 697 | { |
| 698 | temp2 = 250; |
| 699 | } |
| 700 | |
| 701 | helpBoxColor = temp2 / 16; |
| 702 | helpBoxBrightness = (temp2 % 16) - 8; |
| 703 | helpBoxShadeType = DARKEN; |
| 704 | JE_helpBox(VGAScreen, 192, 44 + (x - 1) * 28, cube[x - 1].title, 24); |
| 705 | } |
| 706 | int x = cubeMax + 1; |
| 707 | if (x + 1 == curSel[curMenu]) |
| 708 | { |
| 709 | temp2 = 252; |
| 710 | } |
| 711 | else |
| 712 | { |
| 713 | temp2 = 250; |
| 714 | } |
| 715 | tempW = 44 + (x - 1) * 28; |
| 716 | } |
| 717 | |
| 718 | JE_textShade(VGAScreen, 172, tempW, miscText[6 - 1], temp2 / 16, (temp2 % 16) - 8, DARKEN); |
| 719 | } |
| 720 | |
| 721 | if (curSel[MENU_DATA_CUBES] < menuChoices[MENU_DATA_CUBES]) |
| 722 | { |
| 723 | const int face_sprite = cube[curSel[MENU_DATA_CUBES] - 2].face_sprite; |
| 724 | |
| 725 | if (face_sprite != -1) |
| 726 | { |
| 727 | const int face_x = 77 - (sprite(FACE_SHAPES, face_sprite)->width / 2), |
| 728 | face_y = 92 - (sprite(FACE_SHAPES, face_sprite)->height / 2); |
| 729 | |
| 730 | blit_sprite(VGAScreenSeg, face_x, face_y, FACE_SHAPES, face_sprite); // datacube face |
| 731 | |
| 732 | // modify palette for face |
| 733 | paletteChanged = true; |
| 734 | temp2 = facepal[face_sprite]; |
| 735 | newPal = 0; |
| 736 | |
| 737 | for (temp = 1; temp <= 255 - (3 * 16); temp++) |
| 738 | colors[temp] = palettes[temp2][temp]; |
| 739 | } |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | /* 2 player input devices */ |
| 744 | if (curMenu == MENU_2_PLAYER_ARCADE) |
| 745 | { |
| 746 | for (uint i = 0; i < COUNTOF(inputDevice); i++) |
| 747 | { |
| 748 | if (inputDevice[i] > 2 + joysticks) |
| 749 | inputDevice[i] = inputDevice[i == 0 ? 1 : 0] == 1 ? 2 : 1; |
| 750 | |
| 751 | char temp[64]; |
| 752 | if (joysticks > 1 && inputDevice[i] > 2) |
| 753 | sprintf(temp, "%s %d", inputDevices[2], inputDevice[i] - 2); |
| 754 | else |
| 755 | sprintf(temp, "%s", inputDevices[inputDevice[i] - 1]); |
| 756 | JE_dString(VGAScreen, 186, 38 + 2 * (i + 1) * 16, temp, SMALL_FONT_SHAPES); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | /* JE: { - Step VI - Help text for current cursor location } */ |
| 761 | |
| 762 | flash = false; |
| 763 | |
| 764 | /* JE: {Reset player weapons} */ |
| 765 | memset(shotMultiPos, 0, sizeof(shotMultiPos)); |
| 766 | |
| 767 | JE_drawScore(); |
| 768 | |
| 769 | JE_drawMainMenuHelpText(); |
| 770 | |
| 771 | if (newPal > 0) /* can't reindex this :( */ |
| 772 | { |
| 773 | curPal = newPal; |
| 774 | memcpy(colors, palettes[newPal - 1], sizeof(colors)); |
| 775 | set_palette(palettes[newPal - 1], 0, 255); |
| 776 | newPal = 0; |
| 777 | } |
| 778 | |
| 779 | /* datacube title under face */ |
| 780 | if ((curMenu == MENU_DATA_CUBES || curMenu == MENU_DATA_CUBE_SUB) && |
| 781 | curSel[MENU_DATA_CUBES] < menuChoices[MENU_DATA_CUBES]) |
| 782 | { |
| 783 | JE_textShade(VGAScreen, 75 - JE_textWidth(cube[curSel[MENU_DATA_CUBES] - 2].header, TINY_FONT) / 2, 173, cube[curSel[MENU_DATA_CUBES] - 2].header, 14, 3, DARKEN); |
| 784 | } |
| 785 | |
| 786 | /* SYN: Everything above was just drawing the screen. In the rest of it, we process |
| 787 | any user input (and do a few other things) */ |
| 788 | |
| 789 | /* SYN: Let's start by getting fresh events from SDL */ |
| 790 | service_SDL_events(true); |
| 791 | |
| 792 | if (constantPlay) |
| 793 | { |
| 794 | mainLevel = mapSection[mapPNum-1]; |
| 795 | jumpSection = true; |
| 796 | } |
| 797 | else |
| 798 | { |
| 799 | do |
| 800 | { |
| 801 | /* Inner loop -- this handles animations on menus that need them and handles |
| 802 | some keyboard events. Events it can't handle end the loop and fall through |
| 803 | to the main keyboard handler below. |
| 804 | |
| 805 | Also, I think all timing is handled in here. Somehow. */ |
| 806 | |
| 807 | NETWORK_KEEP_ALIVE(); |
| 808 | |
| 809 | mouseCursor = MOUSE_POINTER_NORMAL; |
| 810 | |
| 811 | col += colC; |
| 812 | if (col < -2 || col > 6) |
| 813 | { |
| 814 | colC = (-1 * colC); |
| 815 | } |
| 816 | |
| 817 | // data cube reading |
| 818 | if (curMenu == MENU_DATA_CUBE_SUB) |
| 819 | { |
| 820 | if (mouseX > 164 && mouseX < 299 && mouseY > 47 && mouseY < 153) |
| 821 | { |
| 822 | if (mouseY > 100) |
| 823 | mouseCursor = MOUSE_POINTER_DOWN; |
| 824 | else |
| 825 | mouseCursor = MOUSE_POINTER_UP; |
| 826 | } |
| 827 | |
| 828 | fill_rectangle_xy(VGAScreen, 160, 49, 310, 158, 228); |
| 829 | if (yLoc + yChg < 0) |
| 830 | { |
| 831 | yChg = 0; |
| 832 | yLoc = 0; |
| 833 | } |
| 834 | |
| 835 | yLoc += yChg; |
| 836 | temp = yLoc / 12; |
| 837 | temp2 = yLoc % 12; |
| 838 | tempW = 38 + 12 - temp2; |
| 839 | temp3 = cube[curSel[MENU_DATA_CUBES] - 2].last_line; |
| 840 | |
| 841 | for (int x = temp + 1; x <= temp + 10; x++) |
| 842 | { |
| 843 | if (x <= temp3) |
| 844 | { |
| 845 | JE_outTextAndDarken(VGAScreen, 161, tempW, cube[curSel[MENU_DATA_CUBES] - 2].text[x-1], 14, 3, TINY_FONT); |
| 846 | tempW += 12; |
| 847 | } |
| 848 | } |
| 849 | |
| 850 | fill_rectangle_xy(VGAScreen, 160, 39, 310, 48, 228); |
| 851 | fill_rectangle_xy(VGAScreen, 160, 157, 310, 166, 228); |
| 852 | |
| 853 | int percent_read = (cube[currentCube].last_line <= 9) |
| 854 | ? 100 |
| 855 | : (yLoc * 100) / ((cube[currentCube].last_line - 9) * 12); |
| 856 | |
| 857 | char buf[55]; |
| 858 | snprintf(buf, sizeof(buf), "%s %d%%", miscText[11], percent_read); |
| 859 | JE_outTextAndDarken(VGAScreen, 176, 160, buf, 14, 1, TINY_FONT); |
| 860 | |
| 861 | JE_dString(VGAScreen, 260, 160, miscText[12], SMALL_FONT_SHAPES); |
| 862 | |
| 863 | if (temp2 == 0) |
| 864 | yChg = 0; |
| 865 | |
| 866 | JE_mouseStart(); |
| 867 | |
| 868 | JE_showVGA(); |
| 869 | |
| 870 | if (backFromHelp) |
| 871 | { |
| 872 | fade_palette(colors, 10, 0, 255); |
| 873 | backFromHelp = false; |
| 874 | } |
| 875 | JE_mouseReplace(); |
| 876 | |
| 877 | setDelay(1); |
| 878 | } |
| 879 | else |
| 880 | { |
| 881 | /* current menu is not 8 (read data cube) */ |
| 882 | |
| 883 | if (curMenu == MENU_PLAY_NEXT_LEVEL) |
| 884 | { |
| 885 | JE_updateNavScreen(); |
| 886 | JE_drawMainMenuHelpText(); |
| 887 | JE_drawMenuHeader(); |
| 888 | JE_drawMenuChoices(); |
| 889 | if (extraGame) |
| 890 | JE_dString(VGAScreen, 170, 140, miscText[68 - 1], FONT_SHAPES); |
| 891 | } |
| 892 | |
| 893 | if (curMenu == MENU_DATA_CUBES && |
| 894 | curSel[MENU_DATA_CUBES] < menuChoices[MENU_DATA_CUBES]) |
| 895 | { |
| 896 | /* Draw flashy cube */ |
| 897 | blit_sprite_hv_blend(VGAScreenSeg, 166, 38 + (curSel[MENU_DATA_CUBES] - 2) * 28, OPTION_SHAPES, 25, 13, col); |
| 898 | } |
| 899 | |
| 900 | /* IF (curmenu = 5) AND (cursel [2] IN [3, 4, 6, 7, 8]) */ |
| 901 | if (curMenu == MENU_UPGRADE_SUB && |
| 902 | (curSel[MENU_UPGRADES] == 3 || |
| 903 | curSel[MENU_UPGRADES] == 4 || |
| 904 | (curSel[MENU_UPGRADES] >= 6 && |
| 905 | curSel[MENU_UPGRADES] <= 8))) |
| 906 | { |
| 907 | setDelay(3); |
| 908 | JE_weaponSimUpdate(); |
| 909 | JE_drawScore(); |
| 910 | service_SDL_events(false); |
| 911 | |
| 912 | if (newPal > 0) |
| 913 | { |
| 914 | curPal = newPal; |
| 915 | set_palette(palettes[newPal - 1], 0, 255); |
| 916 | newPal = 0; |
| 917 | } |
| 918 | |
| 919 | JE_mouseStart(); |
| 920 | |
| 921 | if (paletteChanged) |
| 922 | { |
| 923 | set_palette(colors, 0, 255); |
| 924 | paletteChanged = false; |
| 925 | } |
| 926 | |
| 927 | JE_showVGA(); /* SYN: This is where it updates the screen for the weapon sim */ |
| 928 | |
| 929 | if (backFromHelp) |
| 930 | { |
| 931 | fade_palette(colors, 10, 0, 255); |
| 932 | backFromHelp = false; |
| 933 | } |
| 934 | |
| 935 | JE_mouseReplace(); |
| 936 | |
| 937 | } |
| 938 | else /* current menu is anything but weapon sim or datacube */ |
| 939 | { |
| 940 | setDelay(2); |
| 941 | |
| 942 | JE_drawScore(); |
| 943 | |
| 944 | if (newPal > 0) |
| 945 | { |
| 946 | curPal = newPal; |
| 947 | set_palette(palettes[newPal - 1], 0, 255); |
| 948 | newPal = 0; |
| 949 | } |
| 950 | |
| 951 | JE_mouseStart(); |
| 952 | |
| 953 | if (paletteChanged) |
| 954 | { |
| 955 | set_palette(colors, 0, 255); |
| 956 | paletteChanged = false; |
| 957 | } |
| 958 | |
| 959 | JE_showVGA(); /* SYN: This is the where the screen updates for most menus */ |
| 960 | |
| 961 | JE_mouseReplace(); |
| 962 | |
| 963 | if (backFromHelp) |
| 964 | { |
| 965 | fade_palette(colors, 10, 0, 255); |
| 966 | backFromHelp = false; |
| 967 | } |
| 968 | |
| 969 | } |
| 970 | } |
| 971 | |
| 972 | wait_delay(); |
| 973 | |
| 974 | push_joysticks_as_keyboard(); |
| 975 | service_SDL_events(false); |
| 976 | mouseButton = JE_mousePosition(&mouseX, &mouseY); |
| 977 | inputDetected = newkey || mouseButton > 0; |
| 978 | |
| 979 | if (curMenu != MENU_LOAD_SAVE) |
| 980 | { |
| 981 | if (keysactive[SDL_SCANCODE_S] && (keysactive[SDL_SCANCODE_LALT] || keysactive[SDL_SCANCODE_RALT])) |
| 982 | { |
| 983 | if (curMenu == MENU_DATA_CUBE_SUB || |
| 984 | curMenu == MENU_DATA_CUBES) |
| 985 | { |
| 986 | curMenu = MENU_FULL_GAME; |
| 987 | } |
| 988 | quikSave = true; |
| 989 | oldMenu = curMenu; |
| 990 | curMenu = MENU_LOAD_SAVE; |
| 991 | performSave = true; |
| 992 | newPal = 1; |
| 993 | oldPal = curPal; |
| 994 | } |
| 995 | if (keysactive[SDL_SCANCODE_L] && (keysactive[SDL_SCANCODE_LALT] || keysactive[SDL_SCANCODE_RALT])) |
| 996 | { |
| 997 | if (curMenu == MENU_DATA_CUBE_SUB || |
| 998 | curMenu == MENU_DATA_CUBES) |
| 999 | { |
| 1000 | curMenu = MENU_FULL_GAME; |
| 1001 | } |
| 1002 | quikSave = true; |
| 1003 | oldMenu = curMenu; |
| 1004 | curMenu = MENU_LOAD_SAVE; |
| 1005 | performSave = false; |
| 1006 | newPal = 1; |
| 1007 | oldPal = curPal; |
| 1008 | } |
| 1009 | } |
| 1010 | |
| 1011 | if (curMenu == MENU_DATA_CUBE_SUB) |
| 1012 | { |
| 1013 | if (mouseButton > 0 && mouseCursor != MOUSE_POINTER_NORMAL) |
| 1014 | { |
| 1015 | inputDetected = false; |
| 1016 | if (mouseCursor == MOUSE_POINTER_UP) |
| 1017 | yChg = -1; |
| 1018 | else |
| 1019 | yChg = 1; |
| 1020 | } |
| 1021 | |
| 1022 | if (keysactive[SDL_SCANCODE_PAGEUP]) |
| 1023 | { |
| 1024 | yChg = -2; |
| 1025 | inputDetected = false; |
| 1026 | } |
| 1027 | if (keysactive[SDL_SCANCODE_PAGEDOWN]) |
| 1028 | { |
| 1029 | yChg = 2; |
| 1030 | inputDetected = false; |
| 1031 | } |
| 1032 | |
| 1033 | bool joystick_up = false, joystick_down = false; |
| 1034 | for (int j = 0; j < joysticks; j++) |
| 1035 | { |
| 1036 | joystick_up |= joystick[j].direction[0]; |
| 1037 | joystick_down |= joystick[j].direction[2]; |
| 1038 | } |
| 1039 | |
| 1040 | if (keysactive[SDL_SCANCODE_UP] || joystick_up) |
| 1041 | { |
| 1042 | yChg = -1; |
| 1043 | inputDetected = false; |
| 1044 | } |
| 1045 | |
| 1046 | if (keysactive[SDL_SCANCODE_DOWN] || joystick_down) |
| 1047 | { |
| 1048 | yChg = 1; |
| 1049 | inputDetected = false; |
| 1050 | } |
| 1051 | |
| 1052 | if (yChg < 0 && yLoc == 0) |
| 1053 | { |
| 1054 | yChg = 0; |
| 1055 | } |
| 1056 | if (yChg > 0 && (yLoc / 12) > cube[currentCube].last_line - 10) |
| 1057 | { |
| 1058 | yChg = 0; |
| 1059 | } |
| 1060 | } |
| 1061 | |
| 1062 | } while (!inputDetected); |
| 1063 | } |
| 1064 | |
| 1065 | keyboardUsed = false; |
| 1066 | |
| 1067 | /* The rest of this just grabs input events, handles them, then proceeds on. */ |
| 1068 | |
| 1069 | if (mouseButton > 0) |
| 1070 | { |
| 1071 | lastDirection = 1; |
| 1072 | |
| 1073 | mouseButton = JE_mousePosition(&mouseX, &mouseY); |
| 1074 | |
| 1075 | if (curMenu == MENU_DATA_CUBES && cubeMax == 0) |
| 1076 | { |
| 1077 | curMenu = MENU_FULL_GAME; |
| 1078 | JE_playSampleNum(S_SPRING); |
| 1079 | newPal = 1; |
| 1080 | JE_wipeKey(); |
| 1081 | } |
| 1082 | |
| 1083 | if (curMenu == MENU_DATA_CUBE_SUB) |
| 1084 | { |
| 1085 | if ((mouseX > 258) && (mouseX < 290) && (mouseY > 159) && (mouseY < 171)) |
| 1086 | { |
| 1087 | curMenu = MENU_DATA_CUBES; |
| 1088 | JE_playSampleNum(S_SPRING); |
| 1089 | } |
| 1090 | } |
| 1091 | |
| 1092 | if (curMenu == MENU_OPTIONS || |
| 1093 | curMenu == MENU_LIMITED_OPTIONS) |
| 1094 | { |
| 1095 | if ((mouseX >= (225 - 4)) && (mouseY >= 70) && (mouseY <= 82)) |
| 1096 | { |
| 1097 | if (music_disabled) |
| 1098 | { |
| 1099 | music_disabled = false; |
| 1100 | restart_song(); |
| 1101 | } |
| 1102 | |
| 1103 | curSel[MENU_OPTIONS] = 4; |
| 1104 | |
| 1105 | tyrMusicVolume = (mouseX - (225 - 4)) / 4 * 12; |
| 1106 | if (tyrMusicVolume > 255) |
| 1107 | tyrMusicVolume = 255; |
| 1108 | } |
| 1109 | |
| 1110 | if ((mouseX >= (225 - 4)) && (mouseY >= 86) && (mouseY <= 98)) |
| 1111 | { |
| 1112 | samples_disabled = false; |
| 1113 | |
| 1114 | curSel[MENU_OPTIONS] = 5; |
| 1115 | |
| 1116 | fxVolume = (mouseX - (225 - 4)) / 4 * 12; |
| 1117 | if (fxVolume > 255) |
| 1118 | fxVolume = 255; |
| 1119 | } |
| 1120 | |
| 1121 | set_volume(tyrMusicVolume, fxVolume); |
| 1122 | |
| 1123 | JE_playSampleNum(S_CURSOR); |
| 1124 | } |
| 1125 | |
| 1126 | if (mouseY > 20 && |
| 1127 | mouseX > 170 && |
| 1128 | mouseX < 308 && |
| 1129 | curMenu != MENU_DATA_CUBE_SUB) |
| 1130 | { |
| 1131 | const JE_byte mouseSelectionY[MENU_MAX] = { 16, 16, 16, 16, 26, 12, 11, 28, 0, 16, 16, 16, 8, 16 }; |
| 1132 | |
| 1133 | int selection = (mouseY - 38) / mouseSelectionY[curMenu]+2; |
| 1134 | |
| 1135 | if (curMenu == MENU_2_PLAYER_ARCADE) |
| 1136 | { |
| 1137 | if (selection > 5) |
| 1138 | selection--; |
| 1139 | if (selection > 3) |
| 1140 | selection--; |
| 1141 | } |
| 1142 | |
| 1143 | if (curMenu == MENU_FULL_GAME) |
| 1144 | { |
| 1145 | if (selection > 7) |
| 1146 | selection = 7; |
| 1147 | } |
| 1148 | |
| 1149 | // is play next level screen? |
| 1150 | if (curMenu == MENU_PLAY_NEXT_LEVEL) |
| 1151 | { |
| 1152 | if (selection == menuChoices[curMenu] + 1) |
| 1153 | selection = menuChoices[curMenu]; |
| 1154 | } |
| 1155 | |
| 1156 | if (selection <= menuChoices[curMenu]) |
| 1157 | { |
| 1158 | if (curMenu == MENU_UPGRADE_SUB && |
| 1159 | selection == menuChoices[MENU_UPGRADE_SUB]) |
| 1160 | { |
| 1161 | player[0].cash = JE_cashLeft(); |
| 1162 | curMenu = MENU_UPGRADES; |
| 1163 | JE_playSampleNum(S_ITEM); |
| 1164 | } |
| 1165 | else |
| 1166 | { |
| 1167 | JE_playSampleNum(S_CLICK); |
| 1168 | if (curSel[curMenu] == selection) |
| 1169 | { |
| 1170 | JE_menuFunction(curSel[curMenu]); |
| 1171 | } |
| 1172 | else |
| 1173 | { |
| 1174 | if (curMenu == MENU_UPGRADE_SUB && |
| 1175 | JE_getCost(curSel[MENU_UPGRADES], itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][selection-2]) > player[0].cash) |
| 1176 | { |
| 1177 | JE_playSampleNum(S_CLINK); |
| 1178 | } |
| 1179 | else |
| 1180 | { |
| 1181 | if (curSel[MENU_UPGRADES] == 4) |
| 1182 | player[0].weapon_mode = 1; |
| 1183 | |
| 1184 | curSel[curMenu] = selection; |
| 1185 | } |
| 1186 | |
| 1187 | // in front or rear weapon upgrade screen? |
| 1188 | if (curMenu == MENU_UPGRADE_SUB && |
| 1189 | (curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4)) |
| 1190 | { |
| 1191 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1192 | } |
| 1193 | } |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | wait_noinput(false, true, false); |
| 1198 | } |
| 1199 | |
| 1200 | if (curMenu == MENU_UPGRADE_SUB && |
| 1201 | (curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4)) |
| 1202 | { |
| 1203 | if ((mouseX >= 23) && (mouseX <= 36) && (mouseY >= 149) && (mouseY <= 168)) |
| 1204 | { |
| 1205 | JE_playSampleNum(S_CURSOR); |
| 1206 | switch (curSel[MENU_UPGRADES]) |
| 1207 | { |
| 1208 | case 3: |
| 1209 | case 4: |
| 1210 | if (leftPower) |
| 1211 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = --temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1212 | else |
| 1213 | JE_playSampleNum(S_CLINK); |
| 1214 | |
| 1215 | break; |
| 1216 | } |
| 1217 | wait_noinput(false, true, false); |
| 1218 | } |
| 1219 | |
| 1220 | if ((mouseX >= 119) && (mouseX <= 131) && (mouseY >= 149) && (mouseY <= 168)) |
| 1221 | { |
| 1222 | JE_playSampleNum(S_CURSOR); |
| 1223 | switch (curSel[MENU_UPGRADES]) |
| 1224 | { |
| 1225 | case 3: |
| 1226 | case 4: |
| 1227 | if (rightPower && rightPowerAfford) |
| 1228 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = ++temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1229 | else |
| 1230 | JE_playSampleNum(S_CLINK); |
| 1231 | |
| 1232 | break; |
| 1233 | } |
| 1234 | wait_noinput(false, true, false); |
| 1235 | } |
| 1236 | } |
| 1237 | } |
| 1238 | else if (newkey) |
| 1239 | { |
| 1240 | switch (lastkey_scan) |
| 1241 | { |
| 1242 | case SDL_SCANCODE_SLASH: |
| 1243 | // if in rear weapon upgrade screen |
| 1244 | if (curMenu == MENU_UPGRADE_SUB && curSel[MENU_UPGRADES] == 4) |
| 1245 | { |
| 1246 | // cycle weapon modes |
| 1247 | if (++player[0].weapon_mode > weaponPort[player[0].items.weapon[REAR_WEAPON].id].opnum) |
| 1248 | player[0].weapon_mode = 1; |
| 1249 | } |
| 1250 | break; |
| 1251 | |
| 1252 | case SDL_SCANCODE_SPACE: |
| 1253 | case SDL_SCANCODE_RETURN: |
| 1254 | keyboardUsed = true; |
| 1255 | |
| 1256 | // if front or rear weapon, update "Done" power level |
| 1257 | if (curMenu == MENU_UPGRADE_SUB && (curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4)) |
| 1258 | temp_weapon_power[itemAvailMax[itemAvailMap[curSel[MENU_UPGRADES]-2]-1]] = player[0].items.weapon[curSel[MENU_UPGRADES]-3].power; |
| 1259 | |
| 1260 | JE_menuFunction(curSel[curMenu]); |
| 1261 | break; |
| 1262 | |
| 1263 | case SDL_SCANCODE_ESCAPE: |
| 1264 | keyboardUsed = true; |
| 1265 | |
| 1266 | JE_playSampleNum(S_SPRING); |
| 1267 | if (curMenu == MENU_LOAD_SAVE && quikSave) |
| 1268 | { |
| 1269 | curMenu = oldMenu; |
| 1270 | newPal = oldPal; |
| 1271 | } |
| 1272 | else if (menuEsc[curMenu] == 0) |
| 1273 | { |
| 1274 | if (JE_quitRequest()) |
| 1275 | { |
| 1276 | gameLoaded = true; |
| 1277 | mainLevel = 0; |
| 1278 | } |
| 1279 | } |
| 1280 | else |
| 1281 | { |
| 1282 | if (curMenu == MENU_UPGRADE_SUB) // leaving upgrade menu without buying |
| 1283 | { |
| 1284 | player[0].items = old_items[0]; |
| 1285 | curSel[MENU_UPGRADE_SUB] = lastCurSel; |
| 1286 | player[0].cash = JE_cashLeft(); |
| 1287 | } |
| 1288 | |
| 1289 | if (curMenu != MENU_DATA_CUBE_SUB) |
| 1290 | newPal = 1; |
| 1291 | |
| 1292 | curMenu = menuEsc[curMenu] - 1; |
| 1293 | } |
| 1294 | break; |
| 1295 | |
| 1296 | case SDL_SCANCODE_F1: |
| 1297 | if (!isNetworkGame) |
| 1298 | { |
| 1299 | fade_black(10); |
| 1300 | JE_helpSystem(2); |
| 1301 | |
| 1302 | play_song(songBuy); |
| 1303 | |
| 1304 | JE_loadPic(VGAScreen, 1, false); |
| 1305 | newPal = 1; |
| 1306 | |
| 1307 | switch (curMenu) |
| 1308 | { |
| 1309 | case 3: |
| 1310 | newPal = 18; |
| 1311 | break; |
| 1312 | case 7: |
| 1313 | case 8: |
| 1314 | break; |
| 1315 | } |
| 1316 | |
| 1317 | memcpy(VGAScreen2->pixels, VGAScreen->pixels, VGAScreen2->pitch * VGAScreen2->h); |
| 1318 | |
| 1319 | curPal = newPal; |
| 1320 | memcpy(colors, palettes[newPal-1], sizeof(colors)); |
| 1321 | JE_showVGA(); |
| 1322 | newPal = 0; |
| 1323 | backFromHelp = true; |
| 1324 | } |
| 1325 | break; |
| 1326 | |
| 1327 | case SDL_SCANCODE_UP: |
| 1328 | keyboardUsed = true; |
| 1329 | lastDirection = -1; |
| 1330 | |
| 1331 | if (curMenu != MENU_DATA_CUBE_SUB) |
| 1332 | JE_playSampleNum(S_CURSOR); |
| 1333 | |
| 1334 | curSel[curMenu]--; |
| 1335 | if (curSel[curMenu] < 2) |
| 1336 | curSel[curMenu] = menuChoices[curMenu]; |
| 1337 | |
| 1338 | // if in front or rear weapon upgrade screen |
| 1339 | if (curMenu == MENU_UPGRADE_SUB && |
| 1340 | (curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4)) |
| 1341 | { |
| 1342 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1343 | if (curSel[MENU_UPGRADES] == 4) |
| 1344 | player[0].weapon_mode = 1; |
| 1345 | } |
| 1346 | |
| 1347 | // if joystick config, skip disabled items when digital |
| 1348 | if (curMenu == MENU_JOYSTICK_CONFIG && |
| 1349 | joysticks > 0 && |
| 1350 | !joystick[joystick_config].analog && |
| 1351 | curSel[curMenu] == 5) |
| 1352 | { |
| 1353 | curSel[curMenu] = 3; |
| 1354 | } |
| 1355 | |
| 1356 | break; |
| 1357 | |
| 1358 | case SDL_SCANCODE_DOWN: |
| 1359 | keyboardUsed = true; |
| 1360 | lastDirection = 1; |
| 1361 | |
| 1362 | if (curMenu != MENU_DATA_CUBE_SUB) |
| 1363 | JE_playSampleNum(S_CURSOR); |
| 1364 | |
| 1365 | curSel[curMenu]++; |
| 1366 | if (curSel[curMenu] > menuChoices[curMenu]) |
| 1367 | curSel[curMenu] = 2; |
| 1368 | |
| 1369 | // if in front or rear weapon upgrade screen |
| 1370 | if (curMenu == MENU_UPGRADE_SUB && |
| 1371 | (curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4)) |
| 1372 | { |
| 1373 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1374 | if (curSel[MENU_UPGRADES] == 4) |
| 1375 | player[0].weapon_mode = 1; |
| 1376 | } |
| 1377 | |
| 1378 | // if in joystick config, skip disabled items when digital |
| 1379 | if (curMenu == MENU_JOYSTICK_CONFIG && |
| 1380 | joysticks > 0 && |
| 1381 | !joystick[joystick_config].analog && |
| 1382 | curSel[curMenu] == 4) |
| 1383 | { |
| 1384 | curSel[curMenu] = 6; |
| 1385 | } |
| 1386 | |
| 1387 | break; |
| 1388 | |
| 1389 | case SDL_SCANCODE_HOME: |
| 1390 | if (curMenu == MENU_DATA_CUBE_SUB) |
| 1391 | yLoc = 0; |
| 1392 | break; |
| 1393 | |
| 1394 | case SDL_SCANCODE_END: |
| 1395 | if (curMenu == MENU_DATA_CUBE_SUB) |
| 1396 | yLoc = (cube[currentCube].last_line - 9) * 12; |
| 1397 | break; |
| 1398 | |
| 1399 | case SDL_SCANCODE_LEFT: |
| 1400 | if (curMenu == MENU_JOYSTICK_CONFIG) |
| 1401 | { |
| 1402 | if (joysticks > 0) |
| 1403 | { |
| 1404 | switch (curSel[curMenu]) |
| 1405 | { |
| 1406 | case 2: |
| 1407 | if (joystick_config == 0) |
| 1408 | joystick_config = joysticks; |
| 1409 | joystick_config--; |
| 1410 | break; |
| 1411 | case 3: |
| 1412 | joystick[joystick_config].analog = !joystick[joystick_config].analog; |
| 1413 | break; |
| 1414 | case 4: |
| 1415 | if (joystick[joystick_config].sensitivity == 0) |
| 1416 | joystick[joystick_config].sensitivity = 10; |
| 1417 | else |
| 1418 | joystick[joystick_config].sensitivity--; |
| 1419 | break; |
| 1420 | case 5: |
| 1421 | if (joystick[joystick_config].threshold == 0) |
| 1422 | joystick[joystick_config].threshold = 10; |
| 1423 | else |
| 1424 | joystick[joystick_config].threshold--; |
| 1425 | break; |
| 1426 | default: |
| 1427 | break; |
| 1428 | } |
| 1429 | } |
| 1430 | } |
| 1431 | |
| 1432 | if (curMenu == MENU_2_PLAYER_ARCADE) |
| 1433 | { |
| 1434 | switch (curSel[curMenu]) |
| 1435 | { |
| 1436 | case 3: |
| 1437 | case 4: |
| 1438 | JE_playSampleNum(S_CURSOR); |
| 1439 | |
| 1440 | int temp = curSel[curMenu] - 3; |
| 1441 | do |
| 1442 | { |
| 1443 | if (joysticks == 0) |
| 1444 | inputDevice[temp == 0 ? 1 : 0] = inputDevice[temp]; // swap controllers |
| 1445 | if (inputDevice[temp] <= 1) |
| 1446 | inputDevice[temp] = 2 + joysticks; |
| 1447 | else |
| 1448 | inputDevice[temp]--; |
| 1449 | } while (inputDevice[temp] == inputDevice[temp == 0 ? 1 : 0]); |
| 1450 | break; |
| 1451 | } |
| 1452 | } |
| 1453 | |
| 1454 | if (curMenu == MENU_OPTIONS || |
| 1455 | curMenu == MENU_UPGRADE_SUB || |
| 1456 | curMenu == MENU_LIMITED_OPTIONS) |
| 1457 | { |
| 1458 | JE_playSampleNum(S_CURSOR); |
| 1459 | } |
| 1460 | |
| 1461 | switch (curMenu) |
| 1462 | { |
| 1463 | case 2: |
| 1464 | case 11: |
| 1465 | switch (curSel[curMenu]) |
| 1466 | { |
| 1467 | case 4: |
| 1468 | JE_changeVolume(&tyrMusicVolume, -12, &fxVolume, 0); |
| 1469 | if (music_disabled) |
| 1470 | { |
| 1471 | music_disabled = false; |
| 1472 | restart_song(); |
| 1473 | } |
| 1474 | break; |
| 1475 | case 5: |
| 1476 | JE_changeVolume(&tyrMusicVolume, 0, &fxVolume, -12); |
| 1477 | samples_disabled = false; |
| 1478 | break; |
| 1479 | } |
| 1480 | break; |
| 1481 | case 4: |
| 1482 | switch (curSel[MENU_UPGRADES]) |
| 1483 | { |
| 1484 | case 3: |
| 1485 | case 4: |
| 1486 | if (leftPower) |
| 1487 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = --temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1488 | else |
| 1489 | JE_playSampleNum(S_CLINK); |
| 1490 | |
| 1491 | break; |
| 1492 | } |
| 1493 | break; |
| 1494 | } |
| 1495 | break; |
| 1496 | |
| 1497 | case SDL_SCANCODE_RIGHT: |
| 1498 | if (curMenu == MENU_JOYSTICK_CONFIG) |
| 1499 | { |
| 1500 | if (joysticks > 0) |
| 1501 | { |
| 1502 | switch (curSel[curMenu]) |
| 1503 | { |
| 1504 | case 2: |
| 1505 | joystick_config++; |
| 1506 | joystick_config %= joysticks; |
| 1507 | break; |
| 1508 | case 3: |
| 1509 | joystick[joystick_config].analog = !joystick[joystick_config].analog; |
| 1510 | break; |
| 1511 | case 4: |
| 1512 | joystick[joystick_config].sensitivity++; |
| 1513 | joystick[joystick_config].sensitivity %= 11; |
| 1514 | break; |
| 1515 | case 5: |
| 1516 | joystick[joystick_config].threshold++; |
| 1517 | joystick[joystick_config].threshold %= 11; |
| 1518 | break; |
| 1519 | default: |
| 1520 | break; |
| 1521 | } |
| 1522 | } |
| 1523 | } |
| 1524 | |
| 1525 | if (curMenu == MENU_2_PLAYER_ARCADE) |
| 1526 | { |
| 1527 | switch (curSel[curMenu]) |
| 1528 | { |
| 1529 | case 3: |
| 1530 | case 4: |
| 1531 | JE_playSampleNum(S_CURSOR); |
| 1532 | |
| 1533 | int temp = curSel[curMenu] - 3; |
| 1534 | do |
| 1535 | { |
| 1536 | if (joysticks == 0) |
| 1537 | inputDevice[temp == 0 ? 1 : 0] = inputDevice[temp]; // swap controllers |
| 1538 | if (inputDevice[temp] >= 2 + joysticks) |
| 1539 | inputDevice[temp] = 1; |
| 1540 | else |
| 1541 | inputDevice[temp]++; |
| 1542 | } while (inputDevice[temp] == inputDevice[temp == 0 ? 1 : 0]); |
| 1543 | break; |
| 1544 | } |
| 1545 | } |
| 1546 | |
| 1547 | if (curMenu == MENU_OPTIONS || |
| 1548 | curMenu == MENU_UPGRADE_SUB || |
| 1549 | curMenu == MENU_LIMITED_OPTIONS) |
| 1550 | { |
| 1551 | JE_playSampleNum(S_CURSOR); |
| 1552 | } |
| 1553 | |
| 1554 | switch (curMenu) |
| 1555 | { |
| 1556 | case 2: |
| 1557 | case 11: |
| 1558 | switch (curSel[curMenu]) |
| 1559 | { |
| 1560 | case 4: |
| 1561 | JE_changeVolume(&tyrMusicVolume, 12, &fxVolume, 0); |
| 1562 | if (music_disabled) |
| 1563 | { |
| 1564 | music_disabled = false; |
| 1565 | restart_song(); |
| 1566 | } |
| 1567 | break; |
| 1568 | case 5: |
| 1569 | JE_changeVolume(&tyrMusicVolume, 0, &fxVolume, 12); |
| 1570 | samples_disabled = false; |
| 1571 | break; |
| 1572 | } |
| 1573 | break; |
| 1574 | case 4: |
| 1575 | switch (curSel[MENU_UPGRADES]) |
| 1576 | { |
| 1577 | case 3: |
| 1578 | case 4: |
| 1579 | if (rightPower && rightPowerAfford) |
| 1580 | player[0].items.weapon[curSel[MENU_UPGRADES]-3].power = ++temp_weapon_power[curSel[MENU_UPGRADE_SUB]-2]; |
| 1581 | else |
| 1582 | JE_playSampleNum(S_CLINK); |
| 1583 | |
| 1584 | break; |
| 1585 | } |
| 1586 | break; |
| 1587 | } |
| 1588 | break; |
| 1589 | |
| 1590 | default: |
| 1591 | break; |
| 1592 | } |
| 1593 | } |
| 1594 | |
| 1595 | } while (!(quit || gameLoaded || jumpSection)); |
| 1596 | |
| 1597 | #ifdef WITH_NETWORK |
| 1598 | if (!quit && isNetworkGame) |
| 1599 | { |
| 1600 | JE_barShade(VGAScreen, 3, 3, 316, 196); |
| 1601 | JE_barShade(VGAScreen, 1, 1, 318, 198); |
| 1602 | JE_dString(VGAScreen, 10, 160, "Waiting for other player.", SMALL_FONT_SHAPES); |
| 1603 | |
| 1604 | network_prepare(PACKET_WAITING); |
| 1605 | network_send(4); // PACKET_WAITING |
| 1606 | |
| 1607 | while (true) |
| 1608 | { |
| 1609 | service_SDL_events(false); |
| 1610 | JE_showVGA(); |
| 1611 | |
| 1612 | if (packet_in[0] && SDLNet_Read16(&packet_in[0]->data[0]) == PACKET_WAITING) |
| 1613 | { |
| 1614 | network_update(); |
| 1615 | break; |
| 1616 | } |
| 1617 | |
| 1618 | network_update(); |
| 1619 | network_check(); |
| 1620 | |
| 1621 | SDL_Delay(16); |
| 1622 | } |
| 1623 | |
| 1624 | network_state_reset(); |
| 1625 | } |
| 1626 | |
| 1627 | if (isNetworkGame) |
| 1628 | { |
| 1629 | while (!network_is_sync()) |
| 1630 | { |
| 1631 | service_SDL_events(false); |
| 1632 | JE_showVGA(); |
| 1633 | |
| 1634 | network_check(); |
| 1635 | SDL_Delay(16); |
| 1636 | } |
| 1637 | } |
| 1638 | #endif |
| 1639 | |
| 1640 | if (gameLoaded) |
| 1641 | fade_black(10); |
| 1642 | } |
| 1643 | |
| 1644 | void draw_ship_illustration(void) |
| 1645 | { |
| 1646 | // full of evil hardcoding |
| 1647 | |
| 1648 | // ship |
| 1649 | { |
| 1650 | assert(player[0].items.ship > 0); |
| 1651 | |
| 1652 | const int sprite_id = (player[0].items.ship < COUNTOF(ships)) // shipedit ships get a default |
| 1653 | ? ships[player[0].items.ship].bigshipgraphic - 1 |
| 1654 | : 31; |
| 1655 | |
| 1656 | const int ship_x[6] = { 31, 0, 0, 0, 35, 31 }, |
| 1657 | ship_y[6] = { 36, 0, 0, 0, 33, 35 }; |
| 1658 | |
| 1659 | const int x = ship_x[sprite_id - 27], |
| 1660 | y = ship_y[sprite_id - 27]; |
| 1661 | |
| 1662 | blit_sprite(VGAScreenSeg, x, y, OPTION_SHAPES, sprite_id); |
| 1663 | } |
| 1664 | |
| 1665 | // generator |
| 1666 | { |
| 1667 | assert(player[0].items.generator > 0 && player[0].items.generator < 7); |
| 1668 | |
| 1669 | const int sprite_id = (player[0].items.generator == 1) // generator 1 and generator 2 have the same sprite |
| 1670 | ? player[0].items.generator + 15 |
| 1671 | : player[0].items.generator + 14; |
| 1672 | |
| 1673 | const int generator_x[5] = { 62, 64, 67, 66, 63 }, |
| 1674 | generator_y[5] = { 84, 85, 86, 84, 97 }; |
| 1675 | const int x = generator_x[sprite_id - 16], |
| 1676 | y = generator_y[sprite_id - 16]; |
| 1677 | |
| 1678 | blit_sprite(VGAScreenSeg, x, y, WEAPON_SHAPES, sprite_id); |
| 1679 | } |
| 1680 | |
| 1681 | const int weapon_sprites[43] = |
| 1682 | { |
| 1683 | -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, |
| 1684 | 9, 10, 11, 21, 5, 13, -1, 14, 15, 0, |
| 1685 | 14, 9, 8, 2, 15, 0, 13, 0, 8, 8, |
| 1686 | 11, 1, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1687 | 0, 2, 1 |
| 1688 | }; |
| 1689 | |
| 1690 | // front weapon |
| 1691 | if (player[0].items.weapon[FRONT_WEAPON].id > 0) |
| 1692 | { |
| 1693 | const int front_weapon_xy_list[43] = |
| 1694 | { |
| 1695 | -1, 4, 9, 3, 8, 2, 5, 10, 1, -1, |
| 1696 | -1, -1, -1, 7, 8, -1, -1, 0, -1, 4, |
| 1697 | 0, -1, -1, 3, -1, 4, -1, 4, -1, -1, |
| 1698 | -1, 9, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1699 | 0, 3, 9 |
| 1700 | }; |
| 1701 | |
| 1702 | const int front_weapon_x[12] = { 59, 66, 66, 54, 61, 51, 58, 51, 61, 52, 53, 58 }; |
| 1703 | const int front_weapon_y[12] = { 38, 53, 41, 36, 48, 35, 41, 35, 53, 41, 39, 31 }; |
| 1704 | const int x = front_weapon_x[front_weapon_xy_list[player[0].items.weapon[FRONT_WEAPON].id]], |
| 1705 | y = front_weapon_y[front_weapon_xy_list[player[0].items.weapon[FRONT_WEAPON].id]]; |
| 1706 | |
| 1707 | blit_sprite(VGAScreenSeg, x, y, WEAPON_SHAPES, weapon_sprites[player[0].items.weapon[FRONT_WEAPON].id]); // ship illustration: front weapon |
| 1708 | } |
| 1709 | |
| 1710 | // rear weapon |
| 1711 | if (player[0].items.weapon[REAR_WEAPON].id > 0) |
| 1712 | { |
| 1713 | const int rear_weapon_xy_list[43] = |
| 1714 | { |
| 1715 | -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, |
| 1716 | 1, 2, 3, -1, 4, 5, -1, -1, 6, -1, |
| 1717 | -1, 1, 0, -1, 6, -1, 5, -1, 0, 0, |
| 1718 | 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 1719 | 0, -1, -1 |
| 1720 | }; |
| 1721 | |
| 1722 | const int rear_weapon_x[7] = { 41, 27, 49, 43, 51, 39, 41 }; |
| 1723 | const int rear_weapon_y[7] = { 92, 92, 113, 102, 97, 96, 76 }; |
| 1724 | const int x = rear_weapon_x[rear_weapon_xy_list[player[0].items.weapon[REAR_WEAPON].id]], |
| 1725 | y = rear_weapon_y[rear_weapon_xy_list[player[0].items.weapon[REAR_WEAPON].id]]; |
| 1726 | |
| 1727 | blit_sprite(VGAScreenSeg, x, y, WEAPON_SHAPES, weapon_sprites[player[0].items.weapon[REAR_WEAPON].id]); |
| 1728 | } |
| 1729 | |
| 1730 | // sidekicks |
| 1731 | JE_drawItem(6, player[0].items.sidekick[LEFT_SIDEKICK], 3, 84); |
| 1732 | JE_drawItem(7, player[0].items.sidekick[RIGHT_SIDEKICK], 129, 84); |
| 1733 | |
| 1734 | // shield |
| 1735 | blit_sprite_hv(VGAScreenSeg, 28, 23, OPTION_SHAPES, 26, 15, shields[player[0].items.shield].mpwr - 10); |
| 1736 | } |
| 1737 | |
| 1738 | void load_cubes(void) |
| 1739 | { |
| 1740 | for (int cube_slot = 0; cube_slot < cubeMax; ++cube_slot) |
| 1741 | { |
| 1742 | memset(cube[cube_slot].text, 0, sizeof(cube->text)); |
| 1743 | |
| 1744 | load_cube(cube_slot, cubeList[cube_slot]); |
| 1745 | } |
| 1746 | } |
| 1747 | |
| 1748 | bool load_cube(int cube_slot, int cube_index) |
| 1749 | { |
| 1750 | FILE *f = dir_fopen_die(data_dir(), cube_file, "rb"); |
| 1751 | |
| 1752 | char buf[256]; |
| 1753 | |
| 1754 | // seek to the cube |
| 1755 | while (cube_index > 0) |
| 1756 | { |
| 1757 | read_encrypted_pascal_string(buf, sizeof(buf), f); |
| 1758 | if (buf[0] == '*') |
| 1759 | --cube_index; |
| 1760 | } |
| 1761 | |
| 1762 | str_pop_int(&buf[4], &cube[cube_slot].face_sprite); |
| 1763 | --cube[cube_slot].face_sprite; |
| 1764 | |
| 1765 | read_encrypted_pascal_string(cube[cube_slot].title, sizeof(cube[cube_slot].title), f); |
| 1766 | read_encrypted_pascal_string(cube[cube_slot].header, sizeof(cube[cube_slot].header), f); |
| 1767 | |
| 1768 | uint line = 0, line_chars = 0, line_width = 0; |
| 1769 | |
| 1770 | // for each line of decrypted text, split the line into words |
| 1771 | // and add them individually to the lines of wrapped text |
| 1772 | for (; ; ) |
| 1773 | { |
| 1774 | read_encrypted_pascal_string(buf, sizeof(buf), f); |
| 1775 | |
| 1776 | // end of data |
| 1777 | if (buf[0] == '*') |
| 1778 | break; |
| 1779 | |
| 1780 | // new paragraph |
| 1781 | if (strlen(buf) == 0) |
| 1782 | { |
| 1783 | if (line_chars == 0) |
| 1784 | line += 4; // subsequent new paragaphs indicate 4-line break |
| 1785 | else |
| 1786 | ++line; |
| 1787 | line_chars = 0; |
| 1788 | line_width = 0; |
| 1789 | |
| 1790 | continue; |
| 1791 | } |
| 1792 | |
| 1793 | uint word_start = 0; |
| 1794 | for (uint i = 0; ; ++i) |
| 1795 | { |
| 1796 | bool end_of_line = (buf[i] == '\0'), |
| 1797 | end_of_word = end_of_line || (buf[i] == ' '); |
| 1798 | |
| 1799 | if (end_of_word) |
| 1800 | { |
| 1801 | buf[i] = '\0'; |
| 1802 | |
| 1803 | char *word = &buf[word_start]; |
| 1804 | word_start = i + 1; |
| 1805 | |
| 1806 | uint word_chars = strlen(word), |
| 1807 | word_width = JE_textWidth(word, TINY_FONT); |
| 1808 | |
| 1809 | // word won't fit; no can do |
| 1810 | if (word_chars > cube_line_chars || word_width > cube_line_width) |
| 1811 | break; |
| 1812 | |
| 1813 | bool prepend_space = true; |
| 1814 | |
| 1815 | line_chars += word_chars + (prepend_space ? 1 : 0); |
| 1816 | line_width += word_width + (prepend_space ? 6 : 0); |
| 1817 | |
| 1818 | // word won't fit on current line; use next |
| 1819 | if (line_chars > cube_line_chars || line_width > cube_line_width) |
| 1820 | { |
| 1821 | ++line; |
| 1822 | line_chars = word_chars; |
| 1823 | line_width = word_width; |
| 1824 | |
| 1825 | prepend_space = false; |
| 1826 | } |
| 1827 | |
| 1828 | // append word |
| 1829 | if (line < COUNTOF(cube->text)) |
| 1830 | { |
| 1831 | if (prepend_space) |
| 1832 | strcat(cube[cube_slot].text[line], " "); |
| 1833 | strcat(cube[cube_slot].text[line], word); |
| 1834 | |
| 1835 | // track last line with text |
| 1836 | cube[cube_slot].last_line = line + 1; |
| 1837 | } |
| 1838 | } |
| 1839 | |
| 1840 | if (end_of_line) |
| 1841 | break; |
| 1842 | } |
| 1843 | } |
| 1844 | |
| 1845 | fclose(f); |
| 1846 | |
| 1847 | return true; |
| 1848 | } |
| 1849 | |
| 1850 | void JE_drawItem(JE_byte itemType, JE_word itemNum, JE_word x, JE_word y) |
| 1851 | { |
| 1852 | JE_word tempW = 0; |
| 1853 | |
| 1854 | if (itemNum > 0) |
| 1855 | { |
| 1856 | switch (itemType) |
| 1857 | { |
| 1858 | case 2: |
| 1859 | case 3: |
| 1860 | tempW = weaponPort[itemNum].itemgraphic; |
| 1861 | break; |
| 1862 | case 5: |
| 1863 | tempW = powerSys[itemNum].itemgraphic; |
| 1864 | break; |
| 1865 | case 6: |
| 1866 | case 7: |
| 1867 | tempW = options[itemNum].itemgraphic; |
| 1868 | break; |
| 1869 | case 4: |
| 1870 | tempW = shields[itemNum].itemgraphic; |
| 1871 | break; |
| 1872 | } |
| 1873 | |
| 1874 | if (itemType == 1) |
| 1875 | { |
| 1876 | if (itemNum > 90) |
| 1877 | { |
| 1878 | shipGrPtr = &spriteSheet9; |
| 1879 | shipGr = JE_SGr(itemNum - 90, &shipGrPtr); |
| 1880 | blit_sprite2x2(VGAScreen, x, y, *shipGrPtr, shipGr); |
| 1881 | } |
| 1882 | else |
| 1883 | { |
| 1884 | blit_sprite2x2(VGAScreen, x, y, spriteSheet9, ships[itemNum].shipgraphic); |
| 1885 | } |
| 1886 | } |
| 1887 | else if (tempW > 0) |
| 1888 | { |
| 1889 | blit_sprite2x2(VGAScreen, x, y, shopSpriteSheet, tempW); |
| 1890 | } |
| 1891 | } |
| 1892 | } |
| 1893 | |
| 1894 | void JE_drawMenuHeader(void) |
| 1895 | { |
| 1896 | switch (curMenu) |
| 1897 | { |
| 1898 | case MENU_DATA_CUBE_SUB: |
| 1899 | strcpy(tempStr, cube[curSel[MENU_DATA_CUBES]-2].header); |
| 1900 | break; |
| 1901 | case MENU_DATA_CUBES: |
| 1902 | strcpy(tempStr, menuInt[1][1]); |
| 1903 | break; |
| 1904 | case MENU_LOAD_SAVE: |
| 1905 | strcpy(tempStr, menuInt[3][performSave + 1]); |
| 1906 | break; |
| 1907 | default: |
| 1908 | strcpy(tempStr, menuInt[curMenu + 1][0]); |
| 1909 | break; |
| 1910 | } |
| 1911 | JE_dString(VGAScreen, 74 + JE_fontCenter(tempStr, FONT_SHAPES), 10, tempStr, FONT_SHAPES); |
| 1912 | } |
| 1913 | |
| 1914 | void JE_drawMenuChoices(void) |
| 1915 | { |
| 1916 | JE_byte x; |
| 1917 | char *str; |
| 1918 | |
| 1919 | for (x = 2; x <= menuChoices[curMenu]; x++) |
| 1920 | { |
| 1921 | int tempY = 38 + (x-1) * 16; |
| 1922 | |
| 1923 | if (curMenu == MENU_FULL_GAME) |
| 1924 | { |
| 1925 | if (x == 7) |
| 1926 | { |
| 1927 | tempY += 16; |
| 1928 | } |
| 1929 | } |
| 1930 | |
| 1931 | if (curMenu == MENU_2_PLAYER_ARCADE) |
| 1932 | { |
| 1933 | if (x > 3) |
| 1934 | { |
| 1935 | tempY += 16; |
| 1936 | } |
| 1937 | if (x > 4) |
| 1938 | { |
| 1939 | tempY += 16; |
| 1940 | } |
| 1941 | } |
| 1942 | |
| 1943 | if (!(curMenu == MENU_PLAY_NEXT_LEVEL && |
| 1944 | x == menuChoices[curMenu])) |
| 1945 | { |
| 1946 | tempY -= 16; |
| 1947 | } |
| 1948 | |
| 1949 | str = malloc(strlen(menuInt[curMenu + 1][x-1])+2); |
| 1950 | if (curSel[curMenu] == x) |
| 1951 | { |
| 1952 | str[0] = '~'; |
| 1953 | strcpy(str+1, menuInt[curMenu + 1][x-1]); |
| 1954 | } |
| 1955 | else |
| 1956 | { |
| 1957 | strcpy(str, menuInt[curMenu + 1][x-1]); |
| 1958 | } |
| 1959 | JE_dString(VGAScreen, 166, tempY, str, SMALL_FONT_SHAPES); |
| 1960 | free(str); |
| 1961 | } |
| 1962 | } |
| 1963 | |
| 1964 | void JE_updateNavScreen(void) |
| 1965 | { |
| 1966 | JE_byte x; |
| 1967 | |
| 1968 | /* minor issues: */ |
| 1969 | /* TODO: The scroll to the new planet is too fast, I think */ |
| 1970 | /* TODO: The starting coordinates for the scrolling effect may be wrong, the |
| 1971 | yellowish planet below Tyrian isn't visible for as many frames as in the |
| 1972 | original. */ |
| 1973 | |
| 1974 | tempNavX = roundf(navX); |
| 1975 | tempNavY = roundf(navY); |
| 1976 | fill_rectangle_xy(VGAScreen, 19, 16, 135, 169, 2); |
| 1977 | JE_drawNavLines(true); |
| 1978 | JE_drawNavLines(false); |
| 1979 | JE_drawDots(); |
| 1980 | |
| 1981 | for (x = 0; x < 11; x++) |
| 1982 | JE_drawPlanet(x); |
| 1983 | |
| 1984 | for (x = 0; x < menuChoices[MENU_PLAY_NEXT_LEVEL]-1; x++) |
| 1985 | { |
| 1986 | if (mapPlanet[x] > 11) |
| 1987 | JE_drawPlanet(mapPlanet[x] - 1); |
| 1988 | } |
| 1989 | |
| 1990 | if (mapOrigin > 11) |
| 1991 | JE_drawPlanet(mapOrigin - 1); |
| 1992 | |
| 1993 | blit_sprite(VGAScreenSeg, 0, 0, OPTION_SHAPES, 28); // navigation screen interface |
| 1994 | |
| 1995 | if (curSel[MENU_PLAY_NEXT_LEVEL] < menuChoices[MENU_PLAY_NEXT_LEVEL]) |
| 1996 | { |
| 1997 | const unsigned int origin_x_offset = sprite(PLANET_SHAPES, PGR[mapOrigin-1]-1)->width / 2, |
| 1998 | origin_y_offset = sprite(PLANET_SHAPES, PGR[mapOrigin-1]-1)->height / 2, |
| 1999 | dest_x_offset = sprite(PLANET_SHAPES, PGR[mapPlanet[curSel[MENU_PLAY_NEXT_LEVEL]-2] - 1]-1)->width / 2, |
| 2000 | dest_y_offset = sprite(PLANET_SHAPES, PGR[mapPlanet[curSel[MENU_PLAY_NEXT_LEVEL]-2] - 1]-1)->height / 2; |
| 2001 | |
| 2002 | newNavX = (planetX[mapOrigin-1] - origin_x_offset |
| 2003 | + planetX[mapPlanet[curSel[MENU_PLAY_NEXT_LEVEL]-2] - 1] - dest_x_offset) / 2.0f; |
| 2004 | newNavY = (planetY[mapOrigin-1] - origin_y_offset |
| 2005 | + planetY[mapPlanet[curSel[MENU_PLAY_NEXT_LEVEL]-2] - 1] - dest_y_offset) / 2.0f; |
| 2006 | } |
| 2007 | |
| 2008 | navX = navX + (newNavX - navX) / 2.0f; |
| 2009 | navY = navY + (newNavY - navY) / 2.0f; |
| 2010 | |
| 2011 | if (fabsf(newNavX - navX) < 1) |
| 2012 | navX = newNavX; |
| 2013 | if (fabsf(newNavY - navY) < 1) |
| 2014 | navY = newNavY; |
| 2015 | |
| 2016 | fill_rectangle_xy(VGAScreen, 314, 0, 319, 199, 230); |
| 2017 | |
| 2018 | if (planetAniWait > 0) |
| 2019 | { |
| 2020 | planetAniWait--; |
| 2021 | } |
| 2022 | else |
| 2023 | { |
| 2024 | planetAni++; |
| 2025 | if (planetAni > 14) |
| 2026 | planetAni = 0; |
| 2027 | planetAniWait = 3; |
| 2028 | } |
| 2029 | |
| 2030 | if (currentDotWait > 0) |
| 2031 | { |
| 2032 | currentDotWait--; |
| 2033 | } |
| 2034 | else |
| 2035 | { |
| 2036 | if (currentDotNum < planetDots[curSel[MENU_PLAY_NEXT_LEVEL]-2]) |
| 2037 | currentDotNum++; |
| 2038 | currentDotWait = 5; |
| 2039 | } |
| 2040 | } |
| 2041 | |
| 2042 | void JE_drawLines(SDL_Surface *surface, JE_boolean dark) |
| 2043 | { |
| 2044 | JE_byte x, y; |
| 2045 | JE_integer tempX, tempY; |
| 2046 | JE_integer tempX2, tempY2; |
| 2047 | JE_word tempW, tempW2; |
| 2048 | |
| 2049 | tempX2 = -10; |
| 2050 | tempY2 = 0; |
| 2051 | |
| 2052 | tempW = 0; |
| 2053 | for (x = 0; x < 20; x++) |
| 2054 | { |
| 2055 | tempW += 15; |
| 2056 | tempX = tempW - tempX2; |
| 2057 | |
| 2058 | if (tempX > 18 && tempX < 135) |
| 2059 | { |
| 2060 | if (dark) |
| 2061 | JE_rectangle(surface, tempX + 1, 0, tempX + 1, 199, 32+3); |
| 2062 | else |
| 2063 | JE_rectangle(surface, tempX, 0, tempX, 199, 32+5); |
| 2064 | } |
| 2065 | } |
| 2066 | |
| 2067 | tempW = 0; |
| 2068 | for (y = 0; y < 20; y++) |
| 2069 | { |
| 2070 | tempW += 15; |
| 2071 | tempY = tempW - tempY2; |
| 2072 | |
| 2073 | if (tempY > 15 && tempY < 169) |
| 2074 | { |
| 2075 | if (dark) |
| 2076 | JE_rectangle(surface, 0, tempY + 1, 319, tempY + 1, 32+3); |
| 2077 | else |
| 2078 | JE_rectangle(surface, 0, tempY, 319, tempY, 32+5); |
| 2079 | |
| 2080 | tempW2 = 0; |
| 2081 | |
| 2082 | for (x = 0; x < 20; x++) |
| 2083 | { |
| 2084 | tempW2 += 15; |
| 2085 | tempX = tempW2 - tempX2; |
| 2086 | if (tempX > 18 && tempX < 135) |
| 2087 | { |
| 2088 | JE_pix3(surface, tempX, tempY, 32+6); |
| 2089 | } |
| 2090 | } |
| 2091 | } |
| 2092 | } |
| 2093 | } |
| 2094 | |
| 2095 | /* SYN: This was originally PROC drawlines... yes, there were two different procs called |
| 2096 | drawlines in different scopes in the same file. Dammit, Jason, why do you do this to me? */ |
| 2097 | |
| 2098 | void JE_drawNavLines(JE_boolean dark) |
| 2099 | { |
| 2100 | JE_byte x, y; |
| 2101 | JE_integer tempX, tempY; |
| 2102 | JE_integer tempX2, tempY2; |
| 2103 | JE_word tempW, tempW2; |
| 2104 | |
| 2105 | tempX2 = tempNavX >> 1; |
| 2106 | tempY2 = tempNavY >> 1; |
| 2107 | |
| 2108 | tempW = 0; |
| 2109 | for (x = 1; x <= 20; x++) |
| 2110 | { |
| 2111 | tempW += 15; |
| 2112 | tempX = tempW - tempX2; |
| 2113 | |
| 2114 | if (tempX > 18 && tempX < 135) |
| 2115 | { |
| 2116 | if (dark) |
| 2117 | JE_rectangle(VGAScreen, tempX + 1, 16, tempX + 1, 169, 1); |
| 2118 | else |
| 2119 | JE_rectangle(VGAScreen, tempX, 16, tempX, 169, 5); |
| 2120 | } |
| 2121 | } |
| 2122 | |
| 2123 | tempW = 0; |
| 2124 | for (y = 1; y <= 20; y++) |
| 2125 | { |
| 2126 | tempW += 15; |
| 2127 | tempY = tempW - tempY2; |
| 2128 | |
| 2129 | if (tempY > 15 && tempY < 169) |
| 2130 | { |
| 2131 | if (dark) |
| 2132 | JE_rectangle(VGAScreen, 19, tempY + 1, 135, tempY + 1, 1); |
| 2133 | else |
| 2134 | JE_rectangle(VGAScreen, 8, tempY, 160, tempY, 5); |
| 2135 | |
| 2136 | tempW2 = 0; |
| 2137 | |
| 2138 | for (x = 0; x < 20; x++) |
| 2139 | { |
| 2140 | tempW2 += 15; |
| 2141 | tempX = tempW2 - tempX2; |
| 2142 | if (tempX > 18 && tempX < 135) |
| 2143 | JE_pix3(VGAScreen, tempX, tempY, 7); |
| 2144 | } |
| 2145 | } |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | void JE_drawDots(void) |
| 2150 | { |
| 2151 | JE_byte x, y; |
| 2152 | JE_integer tempX, tempY; |
| 2153 | |
| 2154 | for (x = 0; x < mapPNum; x++) |
| 2155 | { |
| 2156 | for (y = 0; y < planetDots[x]; y++) |
| 2157 | { |
| 2158 | tempX = planetDotX[x][y] - tempNavX + 66 - 2; |
| 2159 | tempY = planetDotY[x][y] - tempNavY + 85 - 2; |
| 2160 | if (tempX > 0 && tempX < 140 && tempY > 0 && tempY < 168) |
| 2161 | blit_sprite(VGAScreenSeg, tempX, tempY, OPTION_SHAPES, (x == curSel[MENU_PLAY_NEXT_LEVEL]-2 && y < currentDotNum) ? 30 : 29); // navigation dots |
| 2162 | } |
| 2163 | } |
| 2164 | } |
| 2165 | |
| 2166 | void JE_drawPlanet(JE_byte planetNum) |
| 2167 | { |
| 2168 | JE_integer tempZ = PGR[planetNum]-1, |
| 2169 | tempX = planetX[planetNum] + 66 - tempNavX - sprite(PLANET_SHAPES, tempZ)->width / 2, |
| 2170 | tempY = planetY[planetNum] + 85 - tempNavY - sprite(PLANET_SHAPES, tempZ)->height / 2; |
| 2171 | |
| 2172 | if (tempX > -7 && tempX + sprite(PLANET_SHAPES, tempZ)->width < 170 && tempY > 0 && tempY < 160) |
| 2173 | { |
| 2174 | if (PAni[planetNum]) |
| 2175 | tempZ += planetAni; |
| 2176 | |
| 2177 | blit_sprite_dark(VGAScreenSeg, tempX + 3, tempY + 3, PLANET_SHAPES, tempZ, false); |
| 2178 | blit_sprite(VGAScreenSeg, tempX, tempY, PLANET_SHAPES, tempZ); // planets |
| 2179 | } |
| 2180 | } |
| 2181 | |
| 2182 | void JE_scaleBitmap(SDL_Surface *dst_bitmap, const SDL_Surface *src_bitmap, int x1, int y1, int x2, int y2) |
| 2183 | { |
| 2184 | /* This function scales one screen and writes the result to another. |
| 2185 | * The only code that calls it is the code run when you select 'ship |
| 2186 | * specs' from the main menu. |
| 2187 | * |
| 2188 | * Originally this used fixed point math. I haven't seen that in ages :). |
| 2189 | * But we're well past the point of needing that.*/ |
| 2190 | |
| 2191 | assert(src_bitmap != NULL && dst_bitmap != NULL); |
| 2192 | assert(x1 >= 0 && y1 >= 0 && x2 < src_bitmap->pitch && y2 < src_bitmap->h); |
| 2193 | |
| 2194 | int w = x2 - x1 + 1, |
| 2195 | h = y2 - y1 + 1; |
| 2196 | float base_skip_w = src_bitmap->pitch / (float)w, |
| 2197 | base_skip_h = src_bitmap->h / (float)h; |
| 2198 | float cumulative_skip_w, cumulative_skip_h; |
| 2199 | |
| 2200 | //Okay, it's time to loop through and add bits of A to a rectangle in B |
| 2201 | Uint8 *dst = dst_bitmap->pixels; /* 8-bit specific */ |
| 2202 | const Uint8 *src, *src_w; /* 8-bit specific */ |
| 2203 | |
| 2204 | dst += y1 * dst_bitmap->pitch + x1; |
| 2205 | cumulative_skip_h = 0; |
| 2206 | |
| 2207 | for (int i = 0; i < h; i++) |
| 2208 | { |
| 2209 | //this sets src to the beginning of our desired line |
| 2210 | src = src_w = (Uint8 *)(src_bitmap->pixels) + (src_bitmap->w * ((unsigned int)cumulative_skip_h)); |
| 2211 | cumulative_skip_h += base_skip_h; |
| 2212 | cumulative_skip_w = 0; |
| 2213 | |
| 2214 | for (int j = 0; j < w; j++) |
| 2215 | { |
| 2216 | //copy and move pointers |
| 2217 | *dst = *src; |
| 2218 | dst++; |
| 2219 | |
| 2220 | cumulative_skip_w += base_skip_w; |
| 2221 | src = src_w + ((unsigned int)cumulative_skip_w); //value is floored |
| 2222 | } |
| 2223 | |
| 2224 | dst += dst_bitmap->pitch - w; |
| 2225 | } |
| 2226 | } |
| 2227 | |
| 2228 | void JE_initWeaponView(void) |
| 2229 | { |
| 2230 | fill_rectangle_xy(VGAScreen, 8, 8, 144, 177, 0); |
| 2231 | |
| 2232 | player[0].sidekick[LEFT_SIDEKICK].x = 72 - 15; |
| 2233 | player[0].sidekick[LEFT_SIDEKICK].y = 120; |
| 2234 | player[0].sidekick[RIGHT_SIDEKICK].x = 72 + 15; |
| 2235 | player[0].sidekick[RIGHT_SIDEKICK].y = 120; |
| 2236 | |
| 2237 | player[0].x = 72; |
| 2238 | player[0].y = 110; |
| 2239 | player[0].delta_x_shot_move = 0; |
| 2240 | player[0].delta_y_shot_move = 0; |
| 2241 | player[0].last_x_explosion_follow = 72; |
| 2242 | player[0].last_y_explosion_follow = 110; |
| 2243 | power = 500; |
| 2244 | lastPower = 500; |
| 2245 | |
| 2246 | memset(shotAvail, 0, sizeof(shotAvail)); |
| 2247 | |
| 2248 | memset(shotRepeat, 1, sizeof(shotRepeat)); |
| 2249 | memset(shotMultiPos, 0, sizeof(shotMultiPos)); |
| 2250 | |
| 2251 | initialize_starfield(); |
| 2252 | } |
| 2253 | |
| 2254 | void JE_computeDots(void) |
| 2255 | { |
| 2256 | JE_integer tempX, tempY; |
| 2257 | JE_longint distX, distY; |
| 2258 | JE_byte x, y; |
| 2259 | |
| 2260 | for (x = 0; x < mapPNum; x++) |
| 2261 | { |
| 2262 | distX = (int)(planetX[mapPlanet[x]-1]) - (int)(planetX[mapOrigin-1]); |
| 2263 | distY = (int)(planetY[mapPlanet[x]-1]) - (int)(planetY[mapOrigin-1]); |
| 2264 | tempX = abs(distX) + abs(distY); |
| 2265 | |
| 2266 | if (tempX != 0) |
| 2267 | planetDots[x] = roundf(sqrtf(sqrtf((distX * distX) + (distY * distY)))) - 1; |
| 2268 | else |
| 2269 | planetDots[x] = 0; |
| 2270 | |
| 2271 | if (planetDots[x] > 10) |
| 2272 | planetDots[x] = 10; |
| 2273 | |
| 2274 | for (y = 0; y < planetDots[x]; y++) |
| 2275 | { |
| 2276 | tempX = JE_partWay(planetX[mapOrigin-1], planetX[mapPlanet[x]-1], planetDots[x], y); |
| 2277 | tempY = JE_partWay(planetY[mapOrigin-1], planetY[mapPlanet[x]-1], planetDots[x], y); |
| 2278 | /* ??? Why does it use temp? =P */ |
| 2279 | planetDotX[x][y] = tempX; |
| 2280 | planetDotY[x][y] = tempY; |
| 2281 | } |
| 2282 | } |
| 2283 | } |
| 2284 | |
| 2285 | JE_integer JE_partWay(JE_integer start, JE_integer finish, JE_byte dots, JE_byte dist) |
| 2286 | { |
| 2287 | return (finish - start) / (dots + 2) * (dist + 1) + start; |
| 2288 | } |
| 2289 | |
| 2290 | void JE_doShipSpecs(void) |
| 2291 | { |
| 2292 | /* This function is called whenever you select 'ship specs' in the |
| 2293 | * game menu. It draws the nice green tech screen and scales it onto |
| 2294 | * the main window. To do this we need two temp buffers, so we're going |
| 2295 | * to use VGAScreen and game_screen for the purpose (making things more |
| 2296 | * complex than they would be if we just malloc'd, but faster) |
| 2297 | * |
| 2298 | * Originally the whole system was pretty oddly designed. So I changed it. |
| 2299 | * Currently drawFunkyScreen creates the image, scaleInPicture draws it, |
| 2300 | * and doFunkyScreen ties everything together. Before it was more like |
| 2301 | * an oddly designed, unreusable, global sharing hierarchy. */ |
| 2302 | |
| 2303 | //create the image we want |
| 2304 | wait_noinput(true, true, true); |
| 2305 | JE_drawShipSpecs(game_screen, VGAScreen2); |
| 2306 | |
| 2307 | //reset VGAScreen2, which we clobbered |
| 2308 | JE_loadPic(VGAScreen2, 1, false); |
| 2309 | |
| 2310 | //draw it |
| 2311 | JE_playSampleNum(S_SPRING); |
| 2312 | JE_scaleInPicture(VGAScreen, game_screen); |
| 2313 | wait_input(true, true, true); |
| 2314 | } |
| 2315 | |
| 2316 | void JE_drawMainMenuHelpText(void) |
| 2317 | { |
| 2318 | char tempStr[67]; |
| 2319 | JE_byte temp; |
| 2320 | |
| 2321 | temp = curSel[curMenu] - 2; |
| 2322 | if (curMenu == MENU_JOYSTICK_CONFIG) // joystick settings menu help |
| 2323 | { |
| 2324 | const int help[16] = { 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 24, 11 }; |
| 2325 | memcpy(tempStr, mainMenuHelp[help[curSel[curMenu] - 2]], sizeof(tempStr)); |
| 2326 | } |
| 2327 | else if (curMenu < MENU_PLAY_NEXT_LEVEL || |
| 2328 | curMenu == MENU_2_PLAYER_ARCADE || |
| 2329 | curMenu > MENU_1_PLAYER_ARCADE) |
| 2330 | { |
| 2331 | memcpy(tempStr, mainMenuHelp[(menuHelp[curMenu][temp])-1], sizeof(tempStr)); |
| 2332 | } |
| 2333 | else if (curMenu == MENU_KEYBOARD_CONFIG && |
| 2334 | curSel[MENU_KEYBOARD_CONFIG] == 10) |
| 2335 | { |
| 2336 | memcpy(tempStr, mainMenuHelp[25-1], sizeof(tempStr)); |
| 2337 | } |
| 2338 | else if (leftPower || rightPower) |
| 2339 | { |
| 2340 | memcpy(tempStr, mainMenuHelp[24-1], sizeof(tempStr)); |
| 2341 | } |
| 2342 | else if (temp == menuChoices[curMenu] - 2 || |
| 2343 | (curMenu == MENU_DATA_CUBES && cubeMax == 0)) |
| 2344 | { |
| 2345 | memcpy(tempStr, mainMenuHelp[12-1], sizeof(tempStr)); |
| 2346 | } |
| 2347 | else |
| 2348 | { |
| 2349 | memcpy(tempStr, mainMenuHelp[17 + curMenu - 3], sizeof(tempStr)); |
| 2350 | } |
| 2351 | |
| 2352 | JE_textShade(VGAScreen, 10, 187, tempStr, 14, 1, DARKEN); |
| 2353 | } |
| 2354 | |
| 2355 | JE_boolean JE_quitRequest(void) |
| 2356 | { |
| 2357 | bool quit_selected = true, done = false; |
| 2358 | |
| 2359 | JE_clearKeyboard(); |
| 2360 | JE_wipeKey(); |
| 2361 | wait_noinput(true, true, true); |
| 2362 | |
| 2363 | JE_barShade(VGAScreen, 65, 55, 255, 155); |
| 2364 | |
| 2365 | while (!done) |
| 2366 | { |
| 2367 | Uint8 col = 8; |
| 2368 | int colC = 1; |
| 2369 | |
| 2370 | do |
| 2371 | { |
| 2372 | service_SDL_events(true); |
| 2373 | setDelay(4); |
| 2374 | |
| 2375 | blit_sprite(VGAScreen, 50, 50, OPTION_SHAPES, 35); // message box |
| 2376 | JE_textShade(VGAScreen, 70, 60, miscText[28], 0, 5, FULL_SHADE); |
| 2377 | JE_helpBox(VGAScreen, 70, 90, miscText[30], 30); |
| 2378 | |
| 2379 | col += colC; |
| 2380 | if (col > 8 || col < 2) |
| 2381 | colC = -colC; |
| 2382 | |
| 2383 | int temp_x, temp_c; |
| 2384 | |
| 2385 | temp_x = 54 + 45 - (JE_textWidth(miscText[9], FONT_SHAPES) / 2); |
| 2386 | temp_c = quit_selected ? col - 12 : -5; |
| 2387 | |
| 2388 | JE_outTextAdjust(VGAScreen, temp_x, 128, miscText[9], 15, temp_c, FONT_SHAPES, true); |
| 2389 | |
| 2390 | temp_x = 149 + 45 - (JE_textWidth(miscText[10], FONT_SHAPES) / 2); |
| 2391 | temp_c = !quit_selected ? col - 12 : -5; |
| 2392 | |
| 2393 | JE_outTextAdjust(VGAScreen, temp_x, 128, miscText[10], 15, temp_c, FONT_SHAPES, true); |
| 2394 | |
| 2395 | if (has_mouse) |
| 2396 | { |
| 2397 | JE_mouseStart(); |
| 2398 | JE_showVGA(); |
| 2399 | JE_mouseReplace(); |
| 2400 | } |
| 2401 | else |
| 2402 | { |
| 2403 | JE_showVGA(); |
| 2404 | } |
| 2405 | |
| 2406 | wait_delay(); |
| 2407 | |
| 2408 | push_joysticks_as_keyboard(); |
| 2409 | service_SDL_events(false); |
| 2410 | |
| 2411 | } while (!newkey && !mousedown); |
| 2412 | |
| 2413 | if (mousedown) |
| 2414 | { |
| 2415 | if (lastmouse_y > 123 && lastmouse_y < 149) |
| 2416 | { |
| 2417 | if (lastmouse_x > 56 && lastmouse_x < 142) |
| 2418 | { |
| 2419 | quit_selected = true; |
| 2420 | done = true; |
| 2421 | } |
| 2422 | else if (lastmouse_x > 151 && lastmouse_x < 237) |
| 2423 | { |
| 2424 | quit_selected = false; |
| 2425 | done = true; |
| 2426 | } |
| 2427 | } |
| 2428 | mousedown = false; |
| 2429 | } |
| 2430 | else if (newkey) |
| 2431 | { |
| 2432 | switch (lastkey_scan) |
| 2433 | { |
| 2434 | case SDL_SCANCODE_LEFT: |
| 2435 | case SDL_SCANCODE_RIGHT: |
| 2436 | case SDL_SCANCODE_TAB: |
| 2437 | quit_selected = !quit_selected; |
| 2438 | JE_playSampleNum(S_CURSOR); |
| 2439 | break; |
| 2440 | case SDL_SCANCODE_RETURN: |
| 2441 | case SDL_SCANCODE_SPACE: |
| 2442 | done = true; |
| 2443 | break; |
| 2444 | case SDL_SCANCODE_ESCAPE: |
| 2445 | quit_selected = false; |
| 2446 | done = true; |
| 2447 | break; |
| 2448 | default: |
| 2449 | break; |
| 2450 | } |
| 2451 | } |
| 2452 | } |
| 2453 | |
| 2454 | JE_playSampleNum(quit_selected ? S_SPRING : S_CLICK); |
| 2455 | |
| 2456 | #ifdef WITH_NETWORK |
| 2457 | if (isNetworkGame && quit_selected) |
| 2458 | { |
| 2459 | network_prepare(PACKET_QUIT); |
| 2460 | network_send(4); // PACKET QUIT |
| 2461 | |
| 2462 | network_tyrian_halt(0, true); |
| 2463 | } |
| 2464 | #endif |
| 2465 | |
| 2466 | return quit_selected; |
| 2467 | } |
| 2468 | |
| 2469 | void JE_genItemMenu(JE_byte itemNum) |
| 2470 | { |
| 2471 | menuChoices[MENU_UPGRADE_SUB] = itemAvailMax[itemAvailMap[itemNum - 2] - 1] + 2; |
| 2472 | |
| 2473 | temp3 = 2; |
| 2474 | temp2 = *playeritem_map(&player[0].items, itemNum - 2); |
| 2475 | |
| 2476 | strcpy(menuInt[5][0], menuInt[2][itemNum - 1]); |
| 2477 | |
| 2478 | for (tempW = 0; tempW < itemAvailMax[itemAvailMap[itemNum - 2] - 1]; tempW++) |
| 2479 | { |
| 2480 | temp = itemAvail[itemAvailMap[itemNum - 2] - 1][tempW]; |
| 2481 | switch (itemNum) |
| 2482 | { |
| 2483 | case 2: |
| 2484 | strcpy(tempStr, ships[temp].name); |
| 2485 | break; |
| 2486 | case 3: |
| 2487 | case 4: |
| 2488 | strcpy(tempStr, weaponPort[temp].name); |
| 2489 | break; |
| 2490 | case 5: |
| 2491 | strcpy(tempStr, shields[temp].name); |
| 2492 | break; |
| 2493 | case 6: |
| 2494 | strcpy(tempStr, powerSys[temp].name); |
| 2495 | break; |
| 2496 | case 7: |
| 2497 | case 8: |
| 2498 | strcpy(tempStr, options[temp].name); |
| 2499 | break; |
| 2500 | } |
| 2501 | if (temp == temp2) |
| 2502 | { |
| 2503 | temp3 = tempW + 2; |
| 2504 | } |
| 2505 | strcpy(menuInt[5][tempW], tempStr); |
| 2506 | } |
| 2507 | |
| 2508 | strcpy(menuInt[5][tempW], miscText[13]); |
| 2509 | |
| 2510 | curSel[MENU_UPGRADE_SUB] = temp3; |
| 2511 | } |
| 2512 | |
| 2513 | void JE_scaleInPicture(SDL_Surface *dst, const SDL_Surface *src) |
| 2514 | { |
| 2515 | for (int i = 2; i <= 160; i += 2) |
| 2516 | { |
| 2517 | if (JE_anyButton()) |
| 2518 | break; |
| 2519 | |
| 2520 | JE_scaleBitmap(dst, src, 160 - i, 0, 160 + i - 1, 100 + roundf(i * 0.625f) - 1); |
| 2521 | JE_showVGA(); |
| 2522 | |
| 2523 | SDL_Delay(1); |
| 2524 | } |
| 2525 | } |
| 2526 | |
| 2527 | void JE_drawScore(void) |
| 2528 | { |
| 2529 | char cl[24]; |
| 2530 | if (curMenu == MENU_UPGRADE_SUB) |
| 2531 | { |
| 2532 | sprintf(cl, "%d", JE_cashLeft()); |
| 2533 | JE_textShade(VGAScreen, 65, 173, cl, 1, 6, DARKEN); |
| 2534 | } |
| 2535 | } |
| 2536 | |
| 2537 | void JE_menuFunction(JE_byte select) |
| 2538 | { |
| 2539 | JE_byte x; |
| 2540 | JE_word curSelect; |
| 2541 | |
| 2542 | col = 0; |
| 2543 | colC = -1; |
| 2544 | JE_playSampleNum(S_CLICK); |
| 2545 | |
| 2546 | curSelect = curSel[curMenu]; |
| 2547 | |
| 2548 | switch (curMenu) |
| 2549 | { |
| 2550 | case MENU_FULL_GAME: |
| 2551 | switch (select) |
| 2552 | { |
| 2553 | case 2: //cubes |
| 2554 | curMenu = MENU_DATA_CUBES; |
| 2555 | curSel[MENU_DATA_CUBES] = 2; |
| 2556 | break; |
| 2557 | case 3: //shipspecs |
| 2558 | JE_doShipSpecs(); |
| 2559 | break; |
| 2560 | case 4://upgradeship |
| 2561 | curMenu = MENU_UPGRADES; |
| 2562 | break; |
| 2563 | case 5: //options |
| 2564 | curMenu = MENU_OPTIONS; |
| 2565 | break; |
| 2566 | case 6: //nextlevel |
| 2567 | curMenu = MENU_PLAY_NEXT_LEVEL; |
| 2568 | newPal = 18; |
| 2569 | JE_computeDots(); |
| 2570 | navX = planetX[mapOrigin - 1]; |
| 2571 | navY = planetY[mapOrigin - 1]; |
| 2572 | newNavX = navX; |
| 2573 | newNavY = navY; |
| 2574 | menuChoices[MENU_PLAY_NEXT_LEVEL] = mapPNum + 2; |
| 2575 | curSel[MENU_PLAY_NEXT_LEVEL] = 2; |
| 2576 | strcpy(menuInt[4][0], "Next Level"); |
| 2577 | for (x = 0; x < mapPNum; x++) |
| 2578 | { |
| 2579 | temp = mapPlanet[x]; |
| 2580 | strcpy(menuInt[4][x + 1], pName[temp - 1]); |
| 2581 | } |
| 2582 | strcpy(menuInt[4][x + 1], miscText[5]); |
| 2583 | break; |
| 2584 | case 7: //quit |
| 2585 | if (JE_quitRequest()) |
| 2586 | { |
| 2587 | gameLoaded = true; |
| 2588 | mainLevel = 0; |
| 2589 | } |
| 2590 | break; |
| 2591 | } |
| 2592 | break; |
| 2593 | |
| 2594 | case MENU_UPGRADES: |
| 2595 | if (select == 9) //done |
| 2596 | { |
| 2597 | curMenu = MENU_FULL_GAME; |
| 2598 | } |
| 2599 | else // selected item to upgrade |
| 2600 | { |
| 2601 | old_items[0] = player[0].items; |
| 2602 | |
| 2603 | lastDirection = 1; |
| 2604 | JE_genItemMenu(select); |
| 2605 | JE_initWeaponView(); |
| 2606 | curMenu = MENU_UPGRADE_SUB; |
| 2607 | lastCurSel = curSel[MENU_UPGRADE_SUB]; |
| 2608 | player[0].cash = player[0].cash * 2 - JE_cashLeft(); |
| 2609 | } |
| 2610 | break; |
| 2611 | |
| 2612 | case MENU_OPTIONS: |
| 2613 | switch (select) |
| 2614 | { |
| 2615 | case 2: |
| 2616 | curMenu = MENU_LOAD_SAVE; |
| 2617 | performSave = false; |
| 2618 | quikSave = false; |
| 2619 | break; |
| 2620 | case 3: |
| 2621 | curMenu = MENU_LOAD_SAVE; |
| 2622 | performSave = true; |
| 2623 | quikSave = false; |
| 2624 | break; |
| 2625 | case 6: |
| 2626 | curMenu = MENU_JOYSTICK_CONFIG; |
| 2627 | break; |
| 2628 | case 7: |
| 2629 | curMenu = MENU_KEYBOARD_CONFIG; |
| 2630 | break; |
| 2631 | case 8: |
| 2632 | curMenu = MENU_FULL_GAME; |
| 2633 | break; |
| 2634 | } |
| 2635 | break; |
| 2636 | |
| 2637 | case MENU_PLAY_NEXT_LEVEL: |
| 2638 | if (select == menuChoices[MENU_PLAY_NEXT_LEVEL]) //exit |
| 2639 | { |
| 2640 | curMenu = MENU_FULL_GAME; |
| 2641 | newPal = 1; |
| 2642 | } |
| 2643 | else |
| 2644 | { |
| 2645 | mainLevel = mapSection[curSelect - 2]; |
| 2646 | jumpSection = true; |
| 2647 | } |
| 2648 | break; |
| 2649 | |
| 2650 | case MENU_UPGRADE_SUB: |
| 2651 | if (curSel[MENU_UPGRADE_SUB] < menuChoices[MENU_UPGRADE_SUB]) |
| 2652 | { |
| 2653 | // select done |
| 2654 | curSel[MENU_UPGRADE_SUB] = menuChoices[MENU_UPGRADE_SUB]; |
| 2655 | } |
| 2656 | else // if done is selected |
| 2657 | { |
| 2658 | JE_playSampleNum(S_ITEM); |
| 2659 | |
| 2660 | player[0].cash = JE_cashLeft(); |
| 2661 | curMenu = MENU_UPGRADES; |
| 2662 | } |
| 2663 | break; |
| 2664 | |
| 2665 | case MENU_KEYBOARD_CONFIG: |
| 2666 | if (curSelect == 10) /* reset to defaults */ |
| 2667 | { |
| 2668 | memcpy(keySettings, defaultKeySettings, sizeof(keySettings)); |
| 2669 | } |
| 2670 | else if (curSelect == 11) /* done */ |
| 2671 | { |
| 2672 | curMenu = isNetworkGame |
| 2673 | ? MENU_LIMITED_OPTIONS |
| 2674 | : MENU_OPTIONS; |
| 2675 | } |
| 2676 | else /* change key */ |
| 2677 | { |
| 2678 | temp2 = 254; |
| 2679 | int tempY = 38 + (curSelect - 2) * 12; |
| 2680 | JE_textShade(VGAScreen, 236, tempY, SDL_GetScancodeName(keySettings[curSelect-2]), (temp2 / 16), (temp2 % 16) - 8, DARKEN); |
| 2681 | JE_showVGA(); |
| 2682 | |
| 2683 | wait_noinput(true, true, true); |
| 2684 | |
| 2685 | col = 248; |
| 2686 | colC = 1; |
| 2687 | |
| 2688 | do |
| 2689 | { |
| 2690 | setDelay(1); |
| 2691 | |
| 2692 | col += colC; |
| 2693 | if (col < 243 || col > 248) |
| 2694 | { |
| 2695 | colC *= -1; |
| 2696 | } |
| 2697 | JE_rectangle(VGAScreen, 230, tempY - 2, 300, tempY + 7, col); |
| 2698 | |
| 2699 | poll_joysticks(); |
| 2700 | service_SDL_events(true); |
| 2701 | |
| 2702 | JE_showVGA(); |
| 2703 | |
| 2704 | wait_delay(); |
| 2705 | } while (!newkey && !mousedown && !joydown); |
| 2706 | |
| 2707 | if (newkey) |
| 2708 | { |
| 2709 | // already used? then swap |
| 2710 | for (uint i = 0; i < COUNTOF(keySettings); ++i) |
| 2711 | { |
| 2712 | if (keySettings[i] == lastkey_scan) |
| 2713 | { |
| 2714 | keySettings[i] = keySettings[curSelect-2]; |
| 2715 | break; |
| 2716 | } |
| 2717 | } |
| 2718 | |
| 2719 | if (lastkey_scan != SDL_SCANCODE_ESCAPE && // reserved for menu |
| 2720 | lastkey_scan != SDL_SCANCODE_F11 && // reserved for gamma |
| 2721 | lastkey_scan != SDL_SCANCODE_P) // reserved for pause |
| 2722 | { |
| 2723 | JE_playSampleNum(S_CLICK); |
| 2724 | keySettings[curSelect-2] = lastkey_scan; |
| 2725 | ++curSelect; |
| 2726 | } |
| 2727 | |
| 2728 | JE_wipeKey(); |
| 2729 | } |
| 2730 | } |
| 2731 | break; |
| 2732 | |
| 2733 | case MENU_LOAD_SAVE: |
| 2734 | if (curSelect == 13) |
| 2735 | { |
| 2736 | if (quikSave) |
| 2737 | { |
| 2738 | curMenu = oldMenu; |
| 2739 | newPal = oldPal; |
| 2740 | } |
| 2741 | else |
| 2742 | { |
| 2743 | curMenu = MENU_OPTIONS; |
| 2744 | } |
| 2745 | } |
| 2746 | else |
| 2747 | { |
| 2748 | if (twoPlayerMode) |
| 2749 | temp = 11; |
| 2750 | else |
| 2751 | temp = 0; |
| 2752 | JE_operation(curSelect - 1 + temp); |
| 2753 | if (quikSave) |
| 2754 | { |
| 2755 | curMenu = oldMenu; |
| 2756 | newPal = oldPal; |
| 2757 | } |
| 2758 | } |
| 2759 | break; |
| 2760 | |
| 2761 | case MENU_DATA_CUBES: |
| 2762 | if (curSelect == menuChoices[curMenu]) |
| 2763 | { |
| 2764 | curMenu = MENU_FULL_GAME; |
| 2765 | newPal = 1; |
| 2766 | } |
| 2767 | else |
| 2768 | { |
| 2769 | if (cubeMax > 0) |
| 2770 | { |
| 2771 | firstMenu9 = true; |
| 2772 | curMenu = MENU_DATA_CUBE_SUB; |
| 2773 | yLoc = 0; |
| 2774 | yChg = 0; |
| 2775 | currentCube = curSel[MENU_DATA_CUBES] - 2; |
| 2776 | } |
| 2777 | else |
| 2778 | { |
| 2779 | curMenu = MENU_FULL_GAME; |
| 2780 | newPal = 1; |
| 2781 | } |
| 2782 | } |
| 2783 | break; |
| 2784 | |
| 2785 | case MENU_DATA_CUBE_SUB: |
| 2786 | curMenu = MENU_DATA_CUBES; |
| 2787 | break; |
| 2788 | |
| 2789 | case MENU_2_PLAYER_ARCADE: |
| 2790 | switch (curSel[curMenu]) |
| 2791 | { |
| 2792 | case 2: |
| 2793 | mainLevel = mapSection[mapPNum-1]; |
| 2794 | jumpSection = true; |
| 2795 | break; |
| 2796 | case 3: |
| 2797 | case 4: |
| 2798 | JE_playSampleNum(S_CURSOR); |
| 2799 | |
| 2800 | int temp = curSel[curMenu] - 3; |
| 2801 | do |
| 2802 | { |
| 2803 | if (joysticks == 0) |
| 2804 | inputDevice[temp == 0 ? 1 : 0] = inputDevice[temp]; // swap controllers |
| 2805 | if (inputDevice[temp] >= 2 + joysticks) |
| 2806 | inputDevice[temp] = 1; |
| 2807 | else |
| 2808 | inputDevice[temp]++; |
| 2809 | } while (inputDevice[temp] == inputDevice[temp == 0 ? 1 : 0]); |
| 2810 | break; |
| 2811 | case 5: |
| 2812 | curMenu = MENU_OPTIONS; |
| 2813 | break; |
| 2814 | case 6: |
| 2815 | if (JE_quitRequest()) |
| 2816 | { |
| 2817 | gameLoaded = true; |
| 2818 | mainLevel = 0; |
| 2819 | } |
| 2820 | break; |
| 2821 | } |
| 2822 | break; |
| 2823 | |
| 2824 | case MENU_1_PLAYER_ARCADE: |
| 2825 | switch (curSel[curMenu]) |
| 2826 | { |
| 2827 | case 2: |
| 2828 | mainLevel = mapSection[mapPNum-1]; |
| 2829 | jumpSection = true; |
| 2830 | break; |
| 2831 | case 3: |
| 2832 | curMenu = isNetworkGame |
| 2833 | ? MENU_LIMITED_OPTIONS |
| 2834 | : MENU_OPTIONS; |
| 2835 | break; |
| 2836 | case 4: |
| 2837 | if (JE_quitRequest()) |
| 2838 | { |
| 2839 | gameLoaded = true; |
| 2840 | mainLevel = 0; |
| 2841 | } |
| 2842 | break; |
| 2843 | } |
| 2844 | break; |
| 2845 | |
| 2846 | case MENU_LIMITED_OPTIONS: |
| 2847 | switch (select) |
| 2848 | { |
| 2849 | case 2: |
| 2850 | curMenu = MENU_JOYSTICK_CONFIG; |
| 2851 | break; |
| 2852 | case 3: |
| 2853 | curMenu = MENU_KEYBOARD_CONFIG; |
| 2854 | break; |
| 2855 | case 6: |
| 2856 | curMenu = MENU_1_PLAYER_ARCADE; |
| 2857 | break; |
| 2858 | } |
| 2859 | break; |
| 2860 | |
| 2861 | case MENU_JOYSTICK_CONFIG: |
| 2862 | if (joysticks == 0 && select != 17) |
| 2863 | break; |
| 2864 | |
| 2865 | switch (select) |
| 2866 | { |
| 2867 | case 2: |
| 2868 | joystick_config++; |
| 2869 | joystick_config %= joysticks; |
| 2870 | break; |
| 2871 | case 3: |
| 2872 | joystick[joystick_config].analog = !joystick[joystick_config].analog; |
| 2873 | break; |
| 2874 | case 4: |
| 2875 | if (joystick[joystick_config].analog) |
| 2876 | { |
| 2877 | joystick[joystick_config].sensitivity++; |
| 2878 | joystick[joystick_config].sensitivity %= 11; |
| 2879 | } |
| 2880 | break; |
| 2881 | case 5: |
| 2882 | if (joystick[joystick_config].analog) |
| 2883 | { |
| 2884 | joystick[joystick_config].threshold++; |
| 2885 | joystick[joystick_config].threshold %= 11; |
| 2886 | } |
| 2887 | break; |
| 2888 | case 16: |
| 2889 | reset_joystick_assignments(joystick_config); |
| 2890 | break; |
| 2891 | case 17: |
| 2892 | curMenu = isNetworkGame |
| 2893 | ? MENU_LIMITED_OPTIONS |
| 2894 | : MENU_OPTIONS; |
| 2895 | break; |
| 2896 | default: |
| 2897 | if (joysticks == 0) |
| 2898 | break; |
| 2899 | |
| 2900 | // int temp = 254; |
| 2901 | // JE_textShade(VGAScreen, 236, 38 + i * 8, value, temp / 16, temp % 16 - 8, DARKEN); |
| 2902 | |
| 2903 | JE_rectangle(VGAScreen, 235, 21 + select * 8, 310, 30 + select * 8, 248); |
| 2904 | |
| 2905 | Joystick_assignment temp; |
| 2906 | if (detect_joystick_assignment(joystick_config, &temp)) |
| 2907 | { |
| 2908 | // if the detected assignment was already set, unset it |
| 2909 | for (uint i = 0; i < COUNTOF(*joystick->assignment); i++) |
| 2910 | { |
| 2911 | if (joystick_assignment_cmp(&temp, &joystick[joystick_config].assignment[select - 6][i])) |
| 2912 | { |
| 2913 | joystick[joystick_config].assignment[select - 6][i].type = NONE; |
| 2914 | goto joystick_assign_done; |
| 2915 | } |
| 2916 | } |
| 2917 | |
| 2918 | // if there is an empty assignment, set it |
| 2919 | for (uint i = 0; i < COUNTOF(*joystick->assignment); i++) |
| 2920 | { |
| 2921 | if (joystick[joystick_config].assignment[select - 6][i].type == NONE) |
| 2922 | { |
| 2923 | joystick[joystick_config].assignment[select - 6][i] = temp; |
| 2924 | goto joystick_assign_done; |
| 2925 | } |
| 2926 | } |
| 2927 | |
| 2928 | // if no assignments are empty, shift them all forward and set the last one |
| 2929 | for (uint i = 0; i < COUNTOF(*joystick->assignment); i++) |
| 2930 | { |
| 2931 | if (i == COUNTOF(*joystick->assignment) - 1) |
| 2932 | joystick[joystick_config].assignment[select - 6][i] = temp; |
| 2933 | else |
| 2934 | joystick[joystick_config].assignment[select - 6][i] = joystick[joystick_config].assignment[select - 6][i + 1]; |
| 2935 | } |
| 2936 | |
| 2937 | joystick_assign_done: |
| 2938 | curSelect++; |
| 2939 | |
| 2940 | poll_joysticks(); |
| 2941 | } |
| 2942 | } |
| 2943 | break; |
| 2944 | |
| 2945 | case MENU_SUPER_TYRIAN: |
| 2946 | switch (curSel[curMenu]) |
| 2947 | { |
| 2948 | case 2: |
| 2949 | mainLevel = mapSection[mapPNum-1]; |
| 2950 | jumpSection = true; |
| 2951 | break; |
| 2952 | case 3: |
| 2953 | JE_doShipSpecs(); |
| 2954 | break; |
| 2955 | case 4: |
| 2956 | curMenu = MENU_OPTIONS; |
| 2957 | break; |
| 2958 | case 5: |
| 2959 | if (JE_quitRequest()) |
| 2960 | { |
| 2961 | if (isNetworkGame) |
| 2962 | { |
| 2963 | JE_tyrianHalt(0); |
| 2964 | } |
| 2965 | gameLoaded = true; |
| 2966 | mainLevel = 0; |
| 2967 | } |
| 2968 | } |
| 2969 | break; |
| 2970 | } |
| 2971 | |
| 2972 | old_items[0] = player[0].items; |
| 2973 | } |
| 2974 | |
| 2975 | void JE_drawShipSpecs(SDL_Surface * screen, SDL_Surface * temp_screen) |
| 2976 | { |
| 2977 | /* In this function we create our ship description image. |
| 2978 | * |
| 2979 | * We use a temp screen for convenience. Bad design maybe (Jason!), |
| 2980 | * but it'll be okay (and the alternative is malloc/a large stack) */ |
| 2981 | |
| 2982 | int temp_x = 0, temp_y = 0, temp_index; |
| 2983 | Uint8 *src, *dst; |
| 2984 | |
| 2985 | //first, draw the text and other assorted flavoring. |
| 2986 | JE_clr256(screen); |
| 2987 | JE_drawLines(screen, true); |
| 2988 | JE_drawLines(screen, false); |
| 2989 | JE_rectangle(screen, 0, 0, 319, 199, 37); |
| 2990 | JE_rectangle(screen, 1, 1, 318, 198, 35); |
| 2991 | |
| 2992 | verticalHeight = 9; |
| 2993 | JE_outText(screen, 10, 2, ships[player[0].items.ship].name, 12, 3); |
| 2994 | JE_helpBox(screen, 100, 20, shipInfo[player[0].items.ship-1][0], 40); |
| 2995 | JE_helpBox(screen, 100, 100, shipInfo[player[0].items.ship-1][1], 40); |
| 2996 | verticalHeight = 7; |
| 2997 | |
| 2998 | JE_outText(screen, JE_fontCenter(miscText[4], TINY_FONT), 190, miscText[4], 12, 2); |
| 2999 | |
| 3000 | //now draw the green ship over that. |
| 3001 | //This hardcoded stuff is for positioning our little ship graphic |
| 3002 | if (player[0].items.ship > 90) |
| 3003 | { |
| 3004 | temp_index = 32; |
| 3005 | } |
| 3006 | else if (player[0].items.ship > 0) |
| 3007 | { |
| 3008 | temp_index = ships[player[0].items.ship].bigshipgraphic; |
| 3009 | } |
| 3010 | else |
| 3011 | { |
| 3012 | temp_index = ships[old_items[0].ship].bigshipgraphic; |
| 3013 | } |
| 3014 | |
| 3015 | switch (temp_index) |
| 3016 | { |
| 3017 | case 32: |
| 3018 | temp_x = 35; |
| 3019 | temp_y = 33; |
| 3020 | break; |
| 3021 | case 28: |
| 3022 | temp_x = 31; |
| 3023 | temp_y = 36; |
| 3024 | break; |
| 3025 | case 33: |
| 3026 | temp_x = 31; |
| 3027 | temp_y = 35; |
| 3028 | break; |
| 3029 | default: |
| 3030 | assert(0); |
| 3031 | } |
| 3032 | temp_x -= 30; |
| 3033 | |
| 3034 | //draw the ship into our temp buffer. |
| 3035 | JE_clr256(temp_screen); |
| 3036 | blit_sprite(temp_screen, temp_x, temp_y, OPTION_SHAPES, temp_index - 1); // ship illustration |
| 3037 | |
| 3038 | /* But wait! Our ship is fully colored, not green! |
| 3039 | * With a little work we could get the sprite dimensions and greenify |
| 3040 | * the area it resides in. For now, let's just greenify the (almost |
| 3041 | * entirely) black screen. |
| 3042 | |
| 3043 | * We can't work in place. In fact we'll need to overlay the result |
| 3044 | * To avoid our temp screen dependence this has been rewritten to |
| 3045 | * only write one line at a time.*/ |
| 3046 | dst = screen->pixels; |
| 3047 | src = temp_screen->pixels; |
| 3048 | for (int y = 0; y < screen->h; y++) |
| 3049 | { |
| 3050 | for (int x = 0; x < screen->pitch; x++) |
| 3051 | { |
| 3052 | int avg = 0; |
| 3053 | if (y > 0) |
| 3054 | avg += *(src - screen->pitch) & 0x0f; |
| 3055 | if (y < screen->h - 1) |
| 3056 | avg += *(src + screen->pitch) & 0x0f; |
| 3057 | if (x > 0) |
| 3058 | avg += *(src - 1) & 0x0f; |
| 3059 | if (x < screen->pitch - 1) |
| 3060 | avg += *(src + 1) & 0x0f; |
| 3061 | avg /= 4; |
| 3062 | |
| 3063 | if ((*src & 0x0f) > avg) |
| 3064 | *dst = (*src & 0x0f) | 0xc0; |
| 3065 | //else |
| 3066 | // *dst = 0; |
| 3067 | |
| 3068 | src++; |
| 3069 | dst++; |
| 3070 | } |
| 3071 | } |
| 3072 | } |
| 3073 | |
| 3074 | void JE_weaponSimUpdate(void) |
| 3075 | { |
| 3076 | char buf[32]; |
| 3077 | |
| 3078 | JE_weaponViewFrame(); |
| 3079 | |
| 3080 | if ((curSel[MENU_UPGRADES] == 3 || curSel[MENU_UPGRADES] == 4) && // front or rear weapon |
| 3081 | curSel[MENU_UPGRADE_SUB] < menuChoices[MENU_UPGRADE_SUB] && // not "Done" |
| 3082 | itemAvail[itemAvailMap[curSel[MENU_UPGRADES]-2]-1][curSel[MENU_UPGRADE_SUB]-2] != 0) // not "None" |
| 3083 | { |
| 3084 | if (leftPower) |
| 3085 | { |
| 3086 | sprintf(buf, "%d", downgradeCost); |
| 3087 | JE_outText(VGAScreen, 26, 137, buf, 1, 4); |
| 3088 | } |
| 3089 | else |
| 3090 | { |
| 3091 | blit_sprite(VGAScreenSeg, 24, 149, OPTION_SHAPES, 13); // downgrade disabled |
| 3092 | } |
| 3093 | |
| 3094 | if (rightPower) |
| 3095 | { |
| 3096 | if (!rightPowerAfford) |
| 3097 | { |
| 3098 | sprintf(buf, "%d", upgradeCost); |
| 3099 | JE_outText(VGAScreen, 108, 137, buf, 7, 4); |
| 3100 | blit_sprite(VGAScreenSeg, 119, 149, OPTION_SHAPES, 14); // upgrade disabled |
| 3101 | } |
| 3102 | else |
| 3103 | { |
| 3104 | sprintf(buf, "%d", upgradeCost); |
| 3105 | JE_outText(VGAScreen, 108, 137, buf, 1, 4); |
| 3106 | } |
| 3107 | } |
| 3108 | else |
| 3109 | { |
| 3110 | blit_sprite(VGAScreenSeg, 119, 149, OPTION_SHAPES, 14); // upgrade disabled |
| 3111 | } |
| 3112 | |
| 3113 | temp = player[0].items.weapon[curSel[MENU_UPGRADES]-3].power; |
| 3114 | |
| 3115 | for (int x = 1; x <= temp; x++) |
| 3116 | { |
| 3117 | fill_rectangle_xy(VGAScreen, 39 + x * 6, 151, 39 + x * 6 + 4, 151, 251); |
| 3118 | JE_pix(VGAScreen, 39 + x * 6, 151, 252); |
| 3119 | fill_rectangle_xy(VGAScreen, 39 + x * 6, 152, 39 + x * 6 + 4, 164, 250); |
| 3120 | fill_rectangle_xy(VGAScreen, 39 + x * 6, 165, 39 + x * 6 + 4, 165, 249); |
| 3121 | } |
| 3122 | |
| 3123 | sprintf(buf, "POWER: %d", temp); |
| 3124 | JE_outText(VGAScreen, 58, 137, buf, 15, 4); |
| 3125 | } |
| 3126 | else |
| 3127 | { |
| 3128 | leftPower = false; |
| 3129 | rightPower = false; |
| 3130 | blit_sprite(VGAScreenSeg, 20, 146, OPTION_SHAPES, 17); // hide power level interface |
| 3131 | } |
| 3132 | |
| 3133 | JE_drawItem(1, player[0].items.ship, player[0].x - 5, player[0].y - 7); |
| 3134 | } |
| 3135 | |
| 3136 | void JE_weaponViewFrame(void) |
| 3137 | { |
| 3138 | fill_rectangle_xy(VGAScreen, 8, 8, 143, 182, 0); |
| 3139 | |
| 3140 | /* JE: (* Port Configuration Display *) |
| 3141 | (* drawportconfigbuttons;*/ |
| 3142 | |
| 3143 | update_and_draw_starfield(VGAScreen, 1); |
| 3144 | |
| 3145 | mouseX = player[0].x; |
| 3146 | mouseY = player[0].y; |
| 3147 | |
| 3148 | // create shots in weapon simulator |
| 3149 | for (uint i = 0; i < 2; ++i) |
| 3150 | { |
| 3151 | if (shotRepeat[i] > 0) |
| 3152 | { |
| 3153 | --shotRepeat[i]; |
| 3154 | } |
| 3155 | else |
| 3156 | { |
| 3157 | const uint item = player[0].items.weapon[i].id, |
| 3158 | item_power = player[0].items.weapon[i].power - 1, |
| 3159 | item_mode = (i == REAR_WEAPON) ? player[0].weapon_mode - 1 : 0; |
| 3160 | |
| 3161 | b = player_shot_create(item, i, player[0].x, player[0].y, mouseX, mouseY, weaponPort[item].op[item_mode][item_power], 1); |
| 3162 | } |
| 3163 | } |
| 3164 | |
| 3165 | if (options[player[0].items.sidekick[LEFT_SIDEKICK]].wport > 0) |
| 3166 | { |
| 3167 | if (shotRepeat[SHOT_LEFT_SIDEKICK] > 0) |
| 3168 | { |
| 3169 | --shotRepeat[SHOT_LEFT_SIDEKICK]; |
| 3170 | } |
| 3171 | else |
| 3172 | { |
| 3173 | const uint item = player[0].items.sidekick[LEFT_SIDEKICK]; |
| 3174 | const int x = player[0].sidekick[LEFT_SIDEKICK].x, |
| 3175 | y = player[0].sidekick[LEFT_SIDEKICK].y; |
| 3176 | |
| 3177 | b = player_shot_create(options[item].wport, SHOT_LEFT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1); |
| 3178 | } |
| 3179 | } |
| 3180 | |
| 3181 | if (options[player[0].items.sidekick[RIGHT_SIDEKICK]].tr == 2) |
| 3182 | { |
| 3183 | player[0].sidekick[RIGHT_SIDEKICK].x = player[0].x; |
| 3184 | player[0].sidekick[RIGHT_SIDEKICK].y = MAX(10, player[0].y - 20); |
| 3185 | } |
| 3186 | else |
| 3187 | { |
| 3188 | player[0].sidekick[RIGHT_SIDEKICK].x = 72 + 15; |
| 3189 | player[0].sidekick[RIGHT_SIDEKICK].y = 120; |
| 3190 | } |
| 3191 | |
| 3192 | if (options[player[0].items.sidekick[RIGHT_SIDEKICK]].wport > 0) |
| 3193 | { |
| 3194 | if (shotRepeat[SHOT_RIGHT_SIDEKICK] > 0) |
| 3195 | { |
| 3196 | --shotRepeat[SHOT_RIGHT_SIDEKICK]; |
| 3197 | } |
| 3198 | else |
| 3199 | { |
| 3200 | const uint item = player[0].items.sidekick[RIGHT_SIDEKICK]; |
| 3201 | const int x = player[0].sidekick[RIGHT_SIDEKICK].x, |
| 3202 | y = player[0].sidekick[RIGHT_SIDEKICK].y; |
| 3203 | |
| 3204 | b = player_shot_create(options[item].wport, SHOT_RIGHT_SIDEKICK, x, y, mouseX, mouseY, options[item].wpnum, 1); |
| 3205 | } |
| 3206 | } |
| 3207 | |
| 3208 | simulate_player_shots(); |
| 3209 | |
| 3210 | blit_sprite(VGAScreenSeg, 0, 0, OPTION_SHAPES, 12); // upgrade interface |
| 3211 | |
| 3212 | /*========================Power Bar=========================*/ |
| 3213 | |
| 3214 | power += powerAdd; |
| 3215 | if (power > 900) |
| 3216 | power = 900; |
| 3217 | |
| 3218 | temp = power / 10; |
| 3219 | |
| 3220 | for (temp = 147 - temp; temp <= 146; temp++) |
| 3221 | { |
| 3222 | temp2 = 113 + (146 - temp) / 9 + 2; |
| 3223 | temp3 = (temp + 1) % 6; |
| 3224 | if (temp3 == 1) |
| 3225 | temp2 += 3; |
| 3226 | else if (temp3 != 0) |
| 3227 | temp2 += 2; |
| 3228 | |
| 3229 | JE_pix(VGAScreen, 141, temp, temp2 - 3); |
| 3230 | JE_pix(VGAScreen, 142, temp, temp2 - 3); |
| 3231 | JE_pix(VGAScreen, 143, temp, temp2 - 2); |
| 3232 | JE_pix(VGAScreen, 144, temp, temp2 - 1); |
| 3233 | fill_rectangle_xy(VGAScreen, 145, temp, 149, temp, temp2); |
| 3234 | |
| 3235 | if (temp2 - 3 < 112) |
| 3236 | temp2++; |
| 3237 | } |
| 3238 | |
| 3239 | temp = 147 - (power / 10); |
| 3240 | temp2 = 113 + (146 - temp) / 9 + 4; |
| 3241 | |
| 3242 | JE_pix(VGAScreen, 141, temp - 1, temp2 - 1); |
| 3243 | JE_pix(VGAScreen, 142, temp - 1, temp2 - 1); |
| 3244 | JE_pix(VGAScreen, 143, temp - 1, temp2 - 1); |
| 3245 | JE_pix(VGAScreen, 144, temp - 1, temp2 - 1); |
| 3246 | |
| 3247 | fill_rectangle_xy(VGAScreen, 145, temp-1, 149, temp-1, temp2); |
| 3248 | |
| 3249 | lastPower = temp; |
| 3250 | |
| 3251 | //JE_waitFrameCount(); TODO: didn't do anything? |
| 3252 | } |