2020-10-25 15:17:26 +01:00
# include "pch.h"
# include "pinball.h"
2020-11-05 16:44:34 +01:00
# include "memory.h"
2020-12-03 15:47:36 +01:00
# include "winmain.h"
2020-10-25 15:17:26 +01:00
2021-08-27 12:29:41 +02:00
// Todo: load translations from file
std : : map < uint32_t , LPCSTR > rc_strings
{
{ 0 , " Replay Awarded " } ,
{ 1 , " Ball Locked " } ,
{ 2 , " Center Post \n %ld " } ,
{ 3 , " Bonus Awarded \n %ld " } ,
{ 4 , " Bonus Activated " } ,
{ 5 , " Weapons Upgraded " } ,
{ 6 , " Engine Upgraded " } ,
{ 7 , " Bonus up 1 Million " } ,
{ 8 , " Extra Ball Available \n %ld " } ,
{ 9 , " Extra Ball " } ,
{ 10 , " Reflex Shot Award \n %ld " } ,
{ 11 , " Final Battle Won " } ,
{ 12 , " Hyperspace Bonus \n %ld " } ,
{ 13 , " Hyperspace Bonus Available " } ,
{ 14 , " Jackpot Awarded \n %ld " } ,
{ 15 , " Jackpot Activated " } ,
{ 16 , " Multiball " } ,
{ 17 , " Ramp Bonus Awarded " } ,
{ 18 , " Light Added " } ,
{ 19 , " Ramp Bonus On " } ,
{ 20 , " Light Reset Off " } ,
{ 21 , " Skill Shot \n %ld " } ,
{ 22 , " Game Paused \n F3 to Resume " } ,
{ 23 , " Continue Play " } ,
{ 24 , " F2 Starts New Game " } ,
{ 25 , " Careful... " } ,
{ 26 , " Player 1 " } ,
{ 27 , " Player 2 " } ,
{ 28 , " Player 3 " } ,
{ 29 , " Player 4 " } ,
{ 30 , " Demo \n Player 1 " } ,
{ 31 , " Demo \n Player 2 " } ,
{ 32 , " Demo \n Player 3 " } ,
{ 33 , " Demo \n Player 4 " } ,
{ 34 , " Game Over " } ,
{ 35 , " TILT! " } ,
{ 36 , " This program requires an 80386 or later CPU. " } ,
{ 37 , " 80386 Required " } ,
{ 38 , " 3D Pinball for Windows - Space Cadet " } ,
{
39 ,
" One or more of the player controls is set to the same key, \n for best performance use unique keys for each control. "
} ,
{ 40 , " Clear High Scores? " } ,
{ 41 , " Confirm " } ,
{ 42 , " WAVEMIX.INF is missing - it must be in the pinball directory! " } ,
{ 43 , " Warning: " } ,
{ 44 , " Ship Re-Fueled " } ,
{ 45 , " Gravity Well " } ,
{ 46 , " Time Warp Forward " } ,
{ 47 , " Time Warp Backward " } ,
{ 48 , " Maelstrom! " } ,
{ 49 , " Wormhole " } ,
{ 50 , " Awaiting Deployment " } ,
{ 51 , " Flags Upgraded " } ,
{ 52 , " Bonus Hold " } ,
{ 53 , " Level One Commation " } ,
{ 54 , " Level Two Commation " } ,
{ 55 , " Level Three Commation " } ,
{ 56 , " Field Multiplier 2x " } ,
{ 57 , " Field Multiplier 3x " } ,
{ 58 , " Field Multiplier 5x " } ,
{ 59 , " Field Multiplier 10x " } ,
{ 60 , " Target Practice " } ,
{ 61 , " Launch Training " } ,
{ 62 , " Re-Entry Training " } ,
{ 63 , " Science " } ,
{ 64 , " Stray Comet " } ,
{ 65 , " Black Hole " } ,
{ 66 , " Space Radiation " } ,
{ 67 , " Bug Hunt " } ,
{ 68 , " Alien Menace " } ,
{ 69 , " Rescue " } ,
{ 70 , " Satellite Retrieval " } ,
{ 71 , " Recon " } ,
{ 72 , " Doomsday Machine " } ,
{ 73 , " Cosmic Plague " } ,
{ 74 , " Secret " } ,
{ 75 , " Time Warp " } ,
{ 76 , " Maelstrom " } ,
{ 77 , " Mission Accepted \n %ld " } ,
{ 78 , " Mission Completed \n %ld " } ,
{ 79 , " %s Mission Selected " } ,
{ 80 , " Black Hole \n %ld " } ,
{ 81 , " Gravity Normalized \n %ld " } ,
{ 82 , " Gravity Well \n %ld " } ,
{ 83 , " Promotion to %s " } ,
{ 84 , " Cadet " } ,
{ 85 , " Ensign " } ,
{ 86 , " Lieutenant " } ,
{ 87 , " Captain " } ,
{ 88 , " Lt Commander " } ,
{ 89 , " Commander " } ,
{ 90 , " Commodore " } ,
{ 91 , " Admiral " } ,
{ 92 , " Fleet Admiral " } ,
{ 93 , " Wormhole Opened " } ,
{ 94 , " Crash Bonus \n %ld " } ,
{ 95 , " Replay Ball " } ,
{ 96 , " Re-Deploy " } ,
{ 97 , " Player 1 Shoot Again " } ,
{ 98 , " Player 2 Shoot Again " } ,
{ 99 , " Player 3 Shoot Again " } ,
{ 100 , " Player 4 Shoot Again " } ,
{
101 ,
" This 3D Pinball Table was created for Microsoft by Maxis. \n For more information call (800)-336-2947 \n (US and Canadian customers only). \n Copyright (c) 1995 Maxis. "
} ,
{ 102 , " 3D Pinball Table created for Microsoft by Maxis. Copyright (c) 1995 Maxis. " } ,
{ 103 , " About 3D Pinball " } ,
{ 104 , " Hit Mission Targets To Select Mission " } ,
{ 105 , " Re-Fuel Ship " } ,
{ 106 , " Launch Ramp To Accept %s Mission " } ,
{ 107 , " Attack Bumpers Hits \n Left: %d " } ,
{ 108 , " Target Training Passed " } ,
{ 109 , " Mission Aborted " } ,
{ 110 , " Launches Left: %d " } ,
{ 111 , " Launch Training Passed " } ,
{ 112 , " Re-Entries Left: %d " } ,
{ 113 , " Re-Entry Training Passed " } ,
{ 114 , " Drop Targets \n Left: %d " } ,
{ 115 , " Science Mission Completed " } ,
{ 116 , " Warning -- Low Fuel " } ,
{ 117 , " Fill Right Hazard Banks " } ,
{ 118 , " Hyperspace Launch " } ,
{ 119 , " Comet Destroyed " } ,
{ 120 , " Enter Wormhole " } ,
{ 121 , " Radiation Eliminated " } ,
{ 122 , " Upgrade Launch Bumpers " } ,
{ 123 , " Enter Black Hole " } ,
{ 124 , " Black Hole Eliminated " } ,
{ 125 , " Targets \n Left: %d " } ,
{ 126 , " Xenomorphs Destroyed " } ,
{ 127 , " Upgrade Flags " } ,
{ 128 , " Hyperspace Launch " } ,
{ 129 , " Survivors Rescued " } ,
{ 130 , " Aliens Repelled " } ,
{ 131 , " Hit Fuel Targets " } ,
{ 132 , " Remote Attack Bumper Hits \n Left: %d " } ,
{ 133 , " Satellite Repaired " } ,
{ 134 , " Lane Passes \n Left: %d " } ,
{ 135 , " Shoot Ball Up Fuel Chute " } ,
{ 136 , " Survey Complete " } ,
{ 137 , " Out Lane Passes \n Left: %d " } ,
{ 138 , " Doomsday Machine Destroyed " } ,
{ 139 , " Roll Flags: %d " } ,
{ 140 , " Hit Space Warp Rollover " } ,
{ 141 , " Plague Eliminated " } ,
{ 142 , " Hit Yellow Wormhole " } ,
{ 143 , " Hit Red Wormhole " } ,
{ 144 , " Hit Green Wormhole " } ,
{ 145 , " Plans Recovered " } ,
{ 146 , " Rebound Hits \n Left: %d " } ,
{ 147 , " Hit Hyperspace Chute or Launch Ramp " } ,
{ 148 , " Drop Target Hits \n Left: %d " } ,
{ 149 , " Spot Target Hits \n Left: %d " } ,
{ 150 , " Lanes Passes \n Left: %d " } ,
{ 151 , " Shoot Ball Up Fuel Chute " } ,
{ 152 , " Hit Launch Ramp " } ,
{ 153 , " Hit Flags " } ,
{ 154 , " Hit Worm Hole " } ,
{ 155 , " Hyperspace Chute to Maelstrom " } ,
{ 156 , " pinball.mid " } ,
{ 158 , " 1 UseBitmapFont " } ,
{ 159 , " 90 Left Flipper Key " } ,
{ 160 , " 191 Right Flipper Key " } ,
{ 161 , " 32 Plunger Key " } ,
{ 162 , " 88 Bump Left Key " } ,
{ 163 , " 190 Bump Right Key " } ,
{ 164 , " 38 Bump Bottom Key " } ,
{ 165 , " Software \\ Microsoft \\ Plus! \\ Pinball " } ,
{ 166 , " SpaceCadet " } ,
{ 167 , " 1c7c22a0-9576-11ce-bf80-444553540000 " } ,
{ 168 , " PINBALL.DAT " } ,
{ 169 , " Space Cadet " } ,
{ 170 , " Error: " } ,
{ 171 , " Unable to find other tables. " } ,
{ 172 , " 3D Pinball \n Space Cadet " } ,
{ 173 , " Promotion to %s " } ,
{ 174 , " Demotion to %s " } ,
{ 175 , " Upgrade Attack Bumpers " } ,
{ 176 , " Fill Left Hazard Banks " } ,
{ 177 , " HIGH SCORE " } ,
{ 178 , " pinball.chm " } ,
{ 179 , " Not enough memory to run 3D Pinball. " } ,
{ 180 , " Player 1's Score \n %ld " } ,
{ 181 , " Player 2's Score \n %ld " } ,
{ 182 , " Player 3's Score \n %ld " } ,
{ 183 , " Player 4's Score \n %ld " } ,
{ 184 , " High Score 1 \n %ld " } ,
{ 185 , " High Score 2 \n %ld " } ,
{ 186 , " High Score 3 \n %ld " } ,
{ 187 , " High Score 4 \n %ld " } ,
{ 188 , " High Score 5 \n %ld " } ,
{ 189 , " 255 255 255 (R G B default font color) " } ,
{ 2030 , " Use &Maximum Resolution (640 x 480) " } ,
{ 2031 , " Use &Maximum Resolution (800 x 600) " } ,
{ 2032 , " Use &Maximum Resolution (1024 x 768) " }
} ;
int LoadStringL ( HINSTANCE hInstance , UINT uID , LPSTR lpBuffer , int cchBufferMax )
{
auto str = rc_strings . find ( uID ) ;
if ( str = = rc_strings . end ( ) )
{
return 0 ;
}
lstrcpyA ( lpBuffer , str - > second ) ;
return 1 ;
}
2020-10-25 15:17:26 +01:00
2020-11-01 16:45:29 +01:00
int pinball : : quickFlag = 0 ;
2020-11-04 14:22:52 +01:00
TTextBox * pinball : : InfoTextBox ;
TTextBox * pinball : : MissTextBox ;
char pinball : : getRcBuffer [ 6 * 256 ] ;
int pinball : : rc_string_slot = 0 ;
2020-11-06 14:56:32 +01:00
int pinball : : LeftShift = - 1 ;
int pinball : : RightShift = - 1 ;
2020-11-04 14:22:52 +01:00
char * pinball : : get_rc_string ( int uID , int a2 )
{
char * result = & getRcBuffer [ 256 * rc_string_slot ] ;
2021-08-27 12:29:41 +02:00
if ( ! LoadStringL ( winmain : : hinst , uID , & getRcBuffer [ 256 * rc_string_slot ] , 255 ) )
2020-11-04 14:22:52 +01:00
* result = 0 ;
if ( + + rc_string_slot > = 6 )
rc_string_slot = 0 ;
return result ;
}
2020-11-06 14:56:32 +01:00
int pinball : : get_rc_int ( int uID , int * dst )
{
2020-12-04 16:35:47 +01:00
char buffer [ 255 ] ;
2021-08-27 12:29:41 +02:00
int result = LoadStringL ( winmain : : hinst , uID , buffer , 255 ) ;
2020-11-06 14:56:32 +01:00
if ( ! result )
return result ;
* dst = atoi ( buffer ) ;
return 1 ;
}
void pinball : : FindShiftKeys ( )
{
2020-12-27 16:19:36 +01:00
signed int i ;
2021-01-29 14:42:05 +01:00
int rightShift ;
2020-12-27 16:19:36 +01:00
CHAR stringBuf [ 20 ] ;
2020-11-06 14:56:32 +01:00
RightShift = - 1 ;
LeftShift = - 1 ;
for ( i = 0 ; i < 256 ; + + i )
{
if ( MapVirtualKeyA ( i , 1u ) = = 16 )
{
LeftShift = i ;
break ;
}
}
while ( + + i < 256 )
{
if ( MapVirtualKeyA ( i , 1u ) = = 16 )
{
RightShift = i ;
break ;
}
}
if ( ! GetKeyNameTextA ( LeftShift < < 16 , stringBuf , 19 ) | | ! _strnicmp ( stringBuf , " right " , 5u ) )
{
rightShift = RightShift ;
}
else
{
rightShift = LeftShift ;
LeftShift = RightShift ;
RightShift = rightShift ;
}
if ( GetKeyNameTextA ( rightShift < < 16 , stringBuf , 19 ) )
{
if ( _strnicmp ( stringBuf , " left " , 4u ) ! = 0 )
{
auto tmp = LeftShift ;
LeftShift = RightShift ;
RightShift = tmp ;
}
}
}
2021-01-29 14:42:05 +01:00
void pinball : : adjust_priority ( int priority )
2020-11-06 14:56:32 +01:00
{
2021-01-29 14:42:05 +01:00
auto thread = GetCurrentThread ( ) ;
2020-11-06 14:56:32 +01:00
switch ( priority )
{
case - 2 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , - 2 ) ;
break ;
2020-11-06 14:56:32 +01:00
case - 1 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , - 1 ) ;
break ;
2020-11-06 14:56:32 +01:00
case 0 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , 0 ) ;
break ;
2020-11-06 14:56:32 +01:00
case 1 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , 1 ) ;
break ;
2020-11-06 14:56:32 +01:00
case 2 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , 2 ) ;
break ;
2020-11-06 14:56:32 +01:00
case 3 :
2021-01-29 14:42:05 +01:00
SetThreadPriority ( thread , 15 ) ;
break ;
default :
2020-11-06 14:56:32 +01:00
break ;
}
}
2020-11-29 16:50:49 +01:00
int pinball : : make_path_name ( LPSTR lpFilename , LPCSTR lpString2 , int nSize )
{
int nameSize = GetModuleFileNameA ( nullptr , lpFilename , nSize ) ;
if ( ! nameSize | | nameSize = = nSize )
return 1 ;
for ( CHAR * i = & lpFilename [ nameSize ] ; i > lpFilename ; - - i )
{
if ( * i = = ' \\ ' | | * i = = ' : ' )
{
i [ 1 ] = 0 ;
break ;
}
- - nameSize ;
}
if ( nameSize + 13 < nSize )
{
lstrcatA ( lpFilename , lpString2 ) ;
return 0 ;
}
lstrcatA ( lpFilename , " ? " ) ;
return 1 ;
}