OPTIONS.CPP (46738B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: F:\projects\c&c\vcs\code\options.cpv 2.17 16 Oct 1995 16:51:28 JOE_BOSTIC $ */ 17 /*********************************************************************************************** 18 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : OPTIONS.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : June 8, 1994 * 28 * * 29 * Last Update : June 30, 1995 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. * 34 * OptionsClass::Get_Brightness -- Fetches the current brightness setting. * 35 * OptionsClass::Get_Color -- Fetches the current color setting. * 36 * OptionsClass::Get_Contrast -- Gets the current contrast setting. * 37 * OptionsClass::Get_Game_Speed -- Fetches the current game speed setting. * 38 * OptionsClass::Get_Scroll_Rate -- Fetches the current scroll rate setting. * 39 * OptionsClass::Get_Tint -- Fetches the current tint setting. * 40 * OptionsClass::Load_Settings -- reads options settings from the INI file * 41 * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. * 42 * OptionsClass::One_Time -- This performs any one time initialization for the options class.* 43 * OptionsClass::OptionsClass -- The default constructor for the options class. * 44 * OptionsClass::Process -- Handles all the options graphic interface. * 45 * OptionsClass::Save_Settings -- writes options settings to the INI file * 46 * OptionsClass::Set -- Sets options based on current settings * 47 * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. * 48 * OptionsClass::Set_Color -- Sets the color to the value specified. * 49 * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. * 50 * OptionsClass::Set_Game_Speed -- Sets the game speed as specified. * 51 * OptionsClass::Set_Repeat -- Controls the score repeat option. * 52 * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. * 53 * OptionsClass::Set_Scroll_Rate -- Sets the scroll rate as specified. * 54 * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. * 55 * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. * 56 * OptionsClass::Set_Tint -- Sets the tint setting. * 57 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 58 59 #include "function.h" 60 #include "options.h" 61 62 63 /*********************************************************************************************** 64 * OptionsClass::OptionsClass -- The default constructor for the options class. * 65 * * 66 * This is the constructor for the options class. It handles setting up all the globals * 67 * necessary for the options. This includes setting them to their default state. * 68 * * 69 * INPUT: none * 70 * * 71 * OUTPUT: none * 72 * * 73 * WARNINGS: none * 74 * * 75 * HISTORY: * 76 * 07/21/1994 JLB : Created. * 77 *=============================================================================================*/ 78 OptionsClass::OptionsClass(void) 79 { 80 GameSpeed = TIMER_SECOND / TICKS_PER_SECOND; 81 ScrollRate = TIMER_SECOND / TICKS_PER_SECOND; 82 Volume = 0xE0; 83 ScoreVolume = 0x90; 84 Contrast = 0x80; 85 Color = 0x80; 86 Contrast = 0x80; 87 Tint = 0x80; 88 Brightness = 0x80; 89 AutoScroll = true; 90 #if (GERMAN | FRENCH) 91 IsDeathAnnounce = true; 92 #else 93 IsDeathAnnounce = false; 94 #endif 95 IsScoreRepeat = false; 96 IsScoreShuffle = false; 97 IsFreeScroll = false; 98 } 99 100 101 /*********************************************************************************************** 102 * OptionsClass::One_Time -- This performs any one time initialization for the options class. * 103 * * 104 * This routine should be called only once and it will perform any inializations for the * 105 * options class that is needed. This may include things like file loading and memory * 106 * allocation. * 107 * * 108 * INPUT: none * 109 * * 110 * OUTPUT: none * 111 * * 112 * WARNINGS: Only call this routine once. * 113 * * 114 * HISTORY: * 115 * 07/21/1994 JLB : Created. * 116 *=============================================================================================*/ 117 void OptionsClass::One_Time(void) 118 { 119 Set_Score_Vol(ScoreVolume); 120 } 121 122 123 /*********************************************************************************************** 124 * OptionsClass::Process -- Handles all the options graphic interface. * 125 * * 126 * This routine is the main control for the visual representation of the options * 127 * screen. It handles the visual overlay and the player input. * 128 * * 129 * INPUT: none * 130 * * 131 * OUTPUT: none * 132 * * 133 * WARNINGS: none * 134 * * 135 * HISTORY: * 136 * 07/21/1994 JLB : Created. * 137 *=============================================================================================*/ 138 void OptionsClass::Process(void) 139 { 140 } 141 142 143 /*********************************************************************************************** 144 * OptionsClass::Set_Shuffle -- Controls the play shuffle setting. * 145 * * 146 * This routine will control the score shuffle flag. The setting to use is provided as * 147 * a parameter. When shuffling is on, the score play order is scrambled. * 148 * * 149 * INPUT: on -- Should the shuffle option be activated? * 150 * * 151 * OUTPUT: none * 152 * * 153 * WARNINGS: none * 154 * * 155 * HISTORY: * 156 * 01/19/1995 JLB : Created. * 157 *=============================================================================================*/ 158 void OptionsClass::Set_Shuffle(int on) 159 { 160 IsScoreShuffle = on; 161 } 162 163 164 /*********************************************************************************************** 165 * OptionsClass::Set_Repeat -- Controls the score repeat option. * 166 * * 167 * This routine is used to control whether scores repeat or not. The setting to use for * 168 * the repeat flag is provided as a parameter. * 169 * * 170 * INPUT: on -- Should the scores repeat? * 171 * * 172 * OUTPUT: none * 173 * * 174 * WARNINGS: none * 175 * * 176 * HISTORY: * 177 * 01/19/1995 JLB : Created. * 178 *=============================================================================================*/ 179 void OptionsClass::Set_Repeat(int on) 180 { 181 IsScoreRepeat = on; 182 } 183 184 185 /*********************************************************************************************** 186 * OptionsClass::Set_Score_Volume -- Sets the global score volume to that specified. * 187 * * 188 * This routine will set the global score volume to the value specified. The value ranges * 189 * from zero to 255. * 190 * * 191 * INPUT: volume -- The new volume setting to use for scores. * 192 * * 193 * OUTPUT: none * 194 * * 195 * WARNINGS: none * 196 * * 197 * HISTORY: * 198 * 01/19/1995 JLB : Created. * 199 *=============================================================================================*/ 200 void OptionsClass::Set_Score_Volume(int volume) 201 { 202 volume = Bound(volume, 0, 255); 203 ScoreVolume = volume; 204 Set_Score_Vol(ScoreVolume); 205 } 206 207 208 /*********************************************************************************************** 209 * OptionsClass::Set_Sound_Volume -- Sets the sound effects volume level. * 210 * * 211 * This routine will set the sound effect volume level as indicated. It can generate a * 212 * sound effect for feedback purposes if desired. The volume setting can range from zero * 213 * to 255. The value of 255 is the loudest. * 214 * * 215 * INPUT: volume -- The volume setting to use for the new value. 0 to 255. * 216 * * 217 * feedback -- Should a feedback sound effect be generated? * 218 * * 219 * OUTPUT: none * 220 * * 221 * WARNINGS: none * 222 * * 223 * HISTORY: * 224 * 01/19/1995 JLB : Created. * 225 *=============================================================================================*/ 226 void OptionsClass::Set_Sound_Volume(int volume, int feedback) 227 { 228 volume = Bound(volume, 0, 255); 229 Volume = volume; 230 if (feedback) { 231 Sound_Effect(VOC_BLEEPY3, NULL); 232 } 233 } 234 235 236 /*********************************************************************************************** 237 * OptionsClass::Set_Brightness -- Sets the brightness level to that specified. * 238 * * 239 * This routine will set the current brightness level to the value specified. This value * 240 * can range from zero to 255, with 128 being the normal (default) brightness level. * 241 * * 242 * INPUT: brightness -- The brightness level to set as current. * 243 * * 244 * OUTPUT: none * 245 * * 246 * WARNINGS: none * 247 * * 248 * HISTORY: * 249 * 01/19/1995 JLB : Created. * 250 *=============================================================================================*/ 251 void OptionsClass::Set_Brightness(int brightness) 252 { 253 Brightness = 0x40 + Fixed_To_Cardinal(0x80, brightness); 254 Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast); 255 if (InMainLoop){ 256 Set_Palette(GamePalette); 257 } 258 } 259 260 261 /*********************************************************************************************** 262 * OptionsClass::Get_Brightness -- Fetches the current brightness setting. * 263 * * 264 * This routine will fetch the current setting for the brightness level. The value ranges * 265 * from zero to 255, with 128 being the normal (default) value. * 266 * * 267 * INPUT: none * 268 * * 269 * OUTPUT: Returns with the current brightness setting. * 270 * * 271 * WARNINGS: none * 272 * * 273 * HISTORY: * 274 * 01/19/1995 JLB : Created. * 275 *=============================================================================================*/ 276 int OptionsClass::Get_Brightness(void) const 277 { 278 return(Cardinal_To_Fixed(0x80, Brightness-0x40)); 279 } 280 281 282 /*********************************************************************************************** 283 * OptionsClass::Set_Color -- Sets the color to the value specified. * 284 * * 285 * This routine will set the color value to that specified. The value specified can range * 286 * from zero to 255. The value of 128 is the normal default color setting. * 287 * * 288 * INPUT: color -- The new color value to set as current. * 289 * * 290 * OUTPUT: none * 291 * * 292 * WARNINGS: none * 293 * * 294 * HISTORY: * 295 * 01/19/1995 JLB : Created. * 296 *=============================================================================================*/ 297 void OptionsClass::Set_Color(int color) 298 { 299 Color = color; 300 Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast); 301 if (InMainLoop){ 302 Set_Palette(GamePalette); 303 } 304 } 305 306 307 /*********************************************************************************************** 308 * OptionsClass::Get_Color -- Fetches the current color setting. * 309 * * 310 * This routine will fetch the current color setting. This value ranges from zero to * 311 * 255. * 312 * * 313 * INPUT: none * 314 * * 315 * OUTPUT: Returns with the current color setting. The value of 128 is the normal (default) * 316 * color setting. * 317 * * 318 * WARNINGS: none * 319 * * 320 * HISTORY: * 321 * 01/19/1995 JLB : Created. * 322 *=============================================================================================*/ 323 int OptionsClass::Get_Color(void) const 324 { 325 return(Color); 326 } 327 328 329 /*********************************************************************************************** 330 * OptionsClass::Set_Contrast -- Sets the contrast to the value specified. * 331 * * 332 * This routine will set the constrast to the setting specified. This setting ranges from * 333 * zero to 255. The value o 128 is the normal default value. * 334 * * 335 * INPUT: contrast -- The constrast setting to make as the current setting. * 336 * * 337 * OUTPUT: none * 338 * * 339 * WARNINGS: none * 340 * * 341 * HISTORY: * 342 * 01/19/1995 JLB : Created. * 343 *=============================================================================================*/ 344 void OptionsClass::Set_Contrast(int contrast) 345 { 346 Contrast = 0x40 + Fixed_To_Cardinal(0x80, contrast); 347 Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast); 348 if (InMainLoop){ 349 Set_Palette(GamePalette); 350 } 351 } 352 353 354 /*********************************************************************************************** 355 * OptionsClass::Get_Contrast -- Gets the current contrast setting. * 356 * * 357 * This routine will get the current contrast setting. The value returned is in the range * 358 * of zero to 255. * 359 * * 360 * INPUT: none * 361 * * 362 * OUTPUT: Returns the current contrast setting. A setting of 128 is the normal default value.* 363 * * 364 * WARNINGS: none * 365 * * 366 * HISTORY: * 367 * 01/19/1995 JLB : Created. * 368 *=============================================================================================*/ 369 int OptionsClass::Get_Contrast(void) const 370 { 371 return(Cardinal_To_Fixed(0x80, Contrast-0x40)); 372 } 373 374 375 /*********************************************************************************************** 376 * OptionsClass::Set_Tint -- Sets the tint setting. * 377 * * 378 * This routine will change the current tint setting according to the value specified. * 379 * * 380 * INPUT: tint -- The desired tint setting. This value ranges from zero to 255. * 381 * * 382 * OUTPUT: none * 383 * * 384 * WARNINGS: The value of 128 is the default (normal) tint setting. * 385 * * 386 * HISTORY: * 387 * 01/19/1995 JLB : Created. * 388 *=============================================================================================*/ 389 void OptionsClass::Set_Tint(int tint) 390 { 391 Tint = tint; 392 Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast); 393 if (InMainLoop){ 394 Set_Palette(GamePalette); 395 } 396 } 397 398 399 /*********************************************************************************************** 400 * OptionsClass::Get_Tint -- Fetches the current tint setting. * 401 * * 402 * This fetches the current tint setting. The value is returned as a number between * 403 * zero and 255. This has been adjusted for the valid range allowed. * 404 * * 405 * INPUT: none * 406 * * 407 * OUTPUT: Returns with the current tint setting. Normal tint setting is 128. * 408 * * 409 * WARNINGS: none * 410 * * 411 * HISTORY: * 412 * 01/19/1995 JLB : Created. * 413 *=============================================================================================*/ 414 int OptionsClass::Get_Tint(void) const 415 { 416 return(Tint); 417 } 418 419 420 /*********************************************************************************************** 421 * OptionsClass::Adjust_Palette -- Adjusts the palette according to the settings specified. * 422 * * 423 * This routine is used to adjust the palette according to the settings provided. It is * 424 * used by the options class to monkey with the palette. * 425 * * 426 * INPUT: oldpal -- Pointer to the original (unmodified) palette. * 427 * * 428 * newpal -- The new palette to create according to the settings provided. * 429 * * 430 * brightness -- The brightness level (0..255). * 431 * * 432 * color -- The color level (0..255). * 433 * * 434 * tint -- The tint (hue) level (0..255). * 435 * * 436 * contrast -- The contrast level (0..255). * 437 * * 438 * OUTPUT: none * 439 * * 440 * WARNINGS: none * 441 * * 442 * HISTORY: * 443 * 07/21/1994 JLB : Created. * 444 *=============================================================================================*/ 445 void OptionsClass::Adjust_Palette(void *oldpal, void *newpal, unsigned char brightness, unsigned char color, unsigned char tint, unsigned char contrast) const 446 { 447 // ST - 1/3/2019 10:49AM 448 #if (0) 449 int index; 450 unsigned h,s,v; 451 unsigned r,g,b; 452 453 if (!oldpal || !newpal) return; 454 455 /* 456 ** Adjust for palette. 457 */ 458 for (index = 0; index < 256; index++) { 459 if (/*index == LTGREEN ||*/ index == 255) { 460 memcpy(&((char*)newpal)[index*3], &((char*)oldpal)[index*3], 3); 461 } else { 462 r = ((char*)oldpal)[(index*3)+0]; 463 g = ((char*)oldpal)[(index*3)+1]; 464 b = ((char*)oldpal)[(index*3)+2]; 465 Convert_RGB_To_HSV(r, g, b, &h, &s, &v); 466 467 /* 468 ** Adjust contrast by moving the value toward the center according to the 469 ** percentage indicated. 470 */ 471 int temp; 472 473 temp = (v * brightness) / 0x80; // Brightness 474 temp = Bound(temp, 0, 0xFF); 475 v = temp; 476 temp = (((((int)v) - 0x80) * contrast) / 0x80) + 0x80; // Contrast 477 temp = Bound(temp, 0, 0xFF); 478 v = temp; 479 temp = (s * color) / 0x80; // Color 480 temp = Bound(temp, 0, 0xFF); 481 s = temp; 482 temp = (h * tint) / 0x80; // Tint 483 temp = Bound(temp, 0, 0xFF); 484 h = temp; 485 Convert_HSV_To_RGB(h, s, v, &r, &g, &b); 486 ((char*)newpal)[(index*3)+0] = r; 487 ((char*)newpal)[(index*3)+1] = g; 488 ((char*)newpal)[(index*3)+2] = b; 489 } 490 } 491 #endif 492 } 493 494 495 /*********************************************************************************************** 496 * OptionsClass::Load_Settings -- reads options settings from the INI file * 497 * * 498 * INPUT: * 499 * none. * 500 * * 501 * OUTPUT: * 502 * none. * 503 * * 504 * WARNINGS: * 505 * none. * 506 * * 507 * HISTORY: * 508 * 02/14/1995 BR : Created. * 509 *=============================================================================================*/ 510 void OptionsClass::Load_Settings (void) 511 { 512 char *buffer; // INI staging buffer pointer. 513 514 /* 515 ** Fetch working pointer to the INI staging buffer. Make sure that the buffer 516 ** is cleared out before proceeding. (Don't use the HidPage for this, since 517 ** the HidPage may be needed for various uncompressions during the INI 518 ** parsing.) 519 */ 520 buffer = (char *)_ShapeBuffer; 521 memset(buffer, '\0', _ShapeBufferSize); 522 523 /* 524 ** Create filename and read the file. 525 */ 526 CCFileClass file ("CONQUER.INI"); 527 if (!file.Is_Available()) { 528 return; 529 } else { 530 file.Read(buffer, _ShapeBufferSize-1); 531 } 532 file.Close(); 533 534 /* 535 ** Read in the Options values 536 */ 537 GameSpeed = WWGetPrivateProfileInt("Options", "GameSpeed", 4, buffer); 538 ScrollRate = WWGetPrivateProfileInt("Options", "ScrollRate", 4, buffer); 539 Set_Brightness(WWGetPrivateProfileInt("Options", "Brightness", 0x80, buffer)); 540 Set_Sound_Volume(WWGetPrivateProfileInt("Options", "Volume", 0xA0, buffer),false); 541 Set_Score_Volume(WWGetPrivateProfileInt("Options", "ScoreVolume", 0xFF, buffer)); 542 Set_Contrast(WWGetPrivateProfileInt("Options", "Contrast", 0x80, buffer)); 543 Set_Color(WWGetPrivateProfileInt("Options", "Color", 0x80, buffer)); 544 Set_Tint(WWGetPrivateProfileInt("Options", "Tint", 0x80, buffer)); 545 AutoScroll = WWGetPrivateProfileInt("Options", "AutoScroll", 1, buffer); 546 Set_Repeat(WWGetPrivateProfileInt("Options", "IsScoreRepeat", 0, buffer)); 547 Set_Shuffle(WWGetPrivateProfileInt("Options", "IsScoreShuffle", 0, buffer)); 548 IsDeathAnnounce = WWGetPrivateProfileInt("Options", "DeathAnnounce", 0, buffer); 549 IsFreeScroll = WWGetPrivateProfileInt("Options", "FreeScrolling", 0, buffer); 550 SlowPalette = WWGetPrivateProfileInt("Options", "SlowPalette", 1, buffer); 551 552 char workbuf[128]; 553 554 /* 555 ** Check for and possible enable true object names. 556 */ 557 WWGetPrivateProfileString("Options", "TrueNames", "", workbuf, sizeof(workbuf), buffer); 558 if (Obfuscate(workbuf) == PARM_TRUENAME) { 559 Special.IsNamed = true; 560 } 561 562 /* 563 ** Enable 6 player games if special flag is detected. 564 */ 565 WWGetPrivateProfileString("Options", "Players", "", workbuf, sizeof(workbuf), buffer); 566 if (Obfuscate(workbuf) == PARM_6PLAYER) { 567 MPlayerMax = 6; 568 } 569 570 /* 571 ** Enable three point turning logic as indicated. 572 */ 573 WWGetPrivateProfileString("Options", "Rotation", "", workbuf, sizeof(workbuf), buffer); 574 if (Obfuscate(workbuf) == PARM_3POINT) { 575 Special.IsThreePoint = true; 576 } 577 578 /* 579 ** Allow purchase of the helipad separately from the helicopter. 580 */ 581 WWGetPrivateProfileString("Options", "Helipad", "", workbuf, sizeof(workbuf), buffer); 582 if (Obfuscate(workbuf) == PARM_HELIPAD) { 583 Special.IsSeparate = true; 584 } 585 586 /* 587 ** Allow the MCV to undeploy rather than sell. 588 */ 589 WWGetPrivateProfileString("Options", "MCV", "", workbuf, sizeof(workbuf), buffer); 590 if (Obfuscate(workbuf) == PARM_MCV) { 591 Special.IsMCVDeploy = true; 592 } 593 594 /* 595 ** Allow disabling of building bibs so that tigher building packing can occur. 596 */ 597 WWGetPrivateProfileString("Options", "Bibs", "", workbuf, sizeof(workbuf), buffer); 598 if (Obfuscate(workbuf) == PARM_BIB) { 599 Special.IsRoad = true; 600 } 601 602 /* 603 ** Allow targeting of trees without having to hold down the shift key. 604 */ 605 WWGetPrivateProfileString("Options", "TreeTarget", "", workbuf, sizeof(workbuf), buffer); 606 if (Obfuscate(workbuf) == PARM_TREETARGET) { 607 Special.IsTreeTarget = true; 608 } 609 610 /* 611 ** Allow infantry to fire while moving. Attacker gets advantage with this flag. 612 */ 613 WWGetPrivateProfileString("Options", "Combat", "", workbuf, sizeof(workbuf), buffer); 614 if (Obfuscate(workbuf) == PARM_COMBAT) { 615 Special.IsDefenderAdvantage = false; 616 } 617 618 /* 619 ** Allow custom scores. 620 */ 621 WWGetPrivateProfileString("Options", "Scores", "", workbuf, sizeof(workbuf), buffer); 622 if (Obfuscate(workbuf) == PARM_SCORE) { 623 Special.IsVariation = true; 624 } 625 626 /* 627 ** Smarter self defense logic. Tanks will try to run over adjacent infantry. Buildings 628 ** will automatically return fire if they are fired upon. Infantry will run from an 629 ** incoming explosive (grenade or napalm) or damage that can't be directly addressed. 630 */ 631 WWGetPrivateProfileString("Options", "CombatIQ", "", workbuf, sizeof(workbuf), buffer); 632 if (Obfuscate(workbuf) == PARM_IQ) { 633 Special.IsSmartDefense = true; 634 Special.IsScatter = true; 635 } 636 637 /* 638 ** Enable the infantry squish marks when run over by a vehicle. 639 */ 640 WWGetPrivateProfileString("Options", "Overrun", "", workbuf, sizeof(workbuf), buffer); 641 if (Obfuscate(workbuf) == PARM_SQUISH) { 642 Special.IsGross = true; 643 } 644 645 /* 646 ** Enable the human generated sound effects. 647 */ 648 WWGetPrivateProfileString("Options", "Sounds", "", workbuf, sizeof(workbuf), buffer); 649 if (Obfuscate(workbuf) == PARM_HUMAN) { 650 Special.IsJuvenile = true; 651 } 652 653 /* 654 ** Scrolling is disabled over the tabs with this option. 655 */ 656 WWGetPrivateProfileString("Options", "Scrolling", "", workbuf, sizeof(workbuf), buffer); 657 if (Obfuscate(workbuf) == PARM_SCROLLING) { 658 Special.IsScrollMod = true; 659 } 660 } 661 662 663 /*********************************************************************************************** 664 * OptionsClass::Save_Settings -- writes options settings to the INI file * 665 * * 666 * INPUT: * 667 * none. * 668 * * 669 * OUTPUT: * 670 * none. * 671 * * 672 * WARNINGS: * 673 * none. * 674 * * 675 * HISTORY: * 676 * 02/14/1995 BR : Created. * 677 *=============================================================================================*/ 678 void OptionsClass::Save_Settings (void) 679 { 680 char * buffer; // INI staging buffer pointer. 681 CCFileClass file; 682 683 /* 684 ** Get a working pointer to the INI staging buffer. Make sure that the buffer 685 ** starts cleared out of any data. 686 */ 687 buffer = (char *)_ShapeBuffer; 688 memset(buffer, '\0', _ShapeBufferSize); 689 690 file.Set_Name("CONQUER.INI"); 691 if (file.Is_Available()) { 692 file.Read(buffer, _ShapeBufferSize-1); 693 } 694 695 /* 696 ** Save Options settings 697 */ 698 WWWritePrivateProfileInt("Options", "GameSpeed", GameSpeed, buffer); 699 WWWritePrivateProfileInt("Options", "ScrollRate", ScrollRate, buffer); 700 WWWritePrivateProfileInt("Options", "Brightness", Brightness, buffer); 701 WWWritePrivateProfileInt("Options", "Volume", Volume, buffer); 702 WWWritePrivateProfileInt("Options", "ScoreVolume", ScoreVolume, buffer); 703 WWWritePrivateProfileInt("Options", "Contrast", Contrast, buffer); 704 WWWritePrivateProfileInt("Options", "Color", Color, buffer); 705 WWWritePrivateProfileInt("Options", "Tint", Tint, buffer); 706 WWWritePrivateProfileInt("Options", "AutoScroll", AutoScroll, buffer); 707 WWWritePrivateProfileInt("Options", "IsScoreRepeat", IsScoreRepeat, buffer); 708 WWWritePrivateProfileInt("Options", "IsScoreShuffle", IsScoreShuffle, buffer); 709 WWWritePrivateProfileInt("Options", "DeathAnnounce", IsDeathAnnounce, buffer); 710 WWWritePrivateProfileInt("Options", "FreeScrolling", IsFreeScroll, buffer); 711 712 /* 713 ** Write the INI data out to a file. 714 */ 715 file.Write(buffer,strlen(buffer)); 716 } 717 718 719 /*********************************************************************************************** 720 * OptionsClass::Set -- Sets options based on current settings * 721 * * 722 * Use this routine to adjust the palette or sound settings after a fresh scenario load. * 723 * It assumes the values needed are already loaded into OptionsClass. * 724 * * 725 * INPUT: * 726 * * 727 * OUTPUT: * 728 * * 729 * WARNINGS: * 730 * * 731 * HISTORY: * 732 * 06/24/1995 BRR : Created. * 733 *=============================================================================================*/ 734 void OptionsClass::Set(void) 735 { 736 Set_Brightness(Brightness); 737 Set_Contrast(Contrast); 738 Set_Color(Color); 739 Set_Tint(Tint); 740 Set_Sound_Volume(Volume,false); 741 Set_Score_Volume(ScoreVolume); 742 Set_Repeat(IsScoreRepeat); 743 Set_Shuffle(IsScoreShuffle); 744 } 745 746 747 /*********************************************************************************************** 748 * OptionsClass::Normalize_Delay -- Normalizes delay factor to keep rate constant. * 749 * * 750 * This routine is used to adjust delay factors that MUST be synchronized on all machines * 751 * but should maintain a speed as close to constant as possible. Building animations are * 752 * a good example of this. * 753 * * 754 * INPUT: delay -- The normal delay factor. * 755 * * 756 * OUTPUT: Returns with the delay to use that has been modified so that a reasonably constant * 757 * rate will result. * 758 * * 759 * WARNINGS: This calculation is crude due to the coarse resolution that a 1/15 second timer * 760 * allows. * 761 * * 762 * Use of this routine ASSUMES that the GameSpeed is synchronized on all machines. * 763 * * 764 * HISTORY: * 765 * 06/18/1995 JLB : Created. * 766 * 06/30/1995 JLB : Handles low values in a more consistent manner. * 767 *=============================================================================================*/ 768 int OptionsClass::Normalize_Delay(int delay) const 769 { 770 static int _adjust[][8] = { 771 {2,2,1,1,1,1,1,1}, 772 {3,3,3,2,2,2,1,1}, 773 {5,4,4,3,3,2,2,1}, 774 {7,6,5,4,4,4,3,2} 775 }; 776 if (delay) { 777 if (delay < 5) { 778 delay = _adjust[delay-1][GameSpeed]; 779 } else { 780 delay = ((delay * 8) / (GameSpeed+1)); 781 } 782 } 783 return(delay); 784 } 785 786 787 788 void OptionsClass::Fixup_Palette(void) const 789 { 790 Adjust_Palette(OriginalPalette, GamePalette, Brightness, Color, Tint, Contrast); 791 } 792 793 794 int OptionsClass::Normalize_Sound(int volume) const 795 { 796 return(Fixed_To_Cardinal(volume, Volume)); 797 }