CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

REAL.H (35127B)


      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\function.h_v   2.21   16 Oct 1995 16:46:44   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 : FUNCTION.H                                                   *
     24  *                                                                                             *
     25  *                   Programmer : Joe L. Bostic                                                *
     26  *                                                                                             *
     27  *                   Start Date : May 27, 1994                                                 *
     28  *                                                                                             *
     29  *                  Last Update : May 27, 1994   [JLB]                                         *
     30  *                                                                                             *
     31  *---------------------------------------------------------------------------------------------*
     32  * Functions:                                                                                  *
     33  * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
     34 
     35 #ifndef FUNCTION_H
     36 #define FUNCTION_H
     37 
     38 #ifdef NEVER
     39 Map (screen) class heirarchy.
     40 
     41  MapeditClass (most derived class) -- scenario editor
     42         ³
     43    MouseClass -- handles mouse animation and display control
     44         ³
     45   ScrollClass -- map scroll handler
     46         ³
     47     HelpClass -- pop-up help text handler
     48         ³
     49      TabClass -- file folder tab screen mode control dispatcher
     50         ³
     51  SidebarClass -- displays and controls construction list sidebar
     52         ³
     53    PowerClass -- display power production/consumption bargraph
     54         ³
     55    RadarClass -- displays and controls radar map
     56         ³
     57  DisplayClass -- general tactical map display handler
     58         ³
     59      MapClass -- general tactical map data handler
     60         ³
     61  GScreenClass (pure virtual base class) -- generic screen control
     62 
     63                           AbstractClass
     64                                   ³
     65                                   ³
     66                                   ³
     67                                   ³
     68                             ObjectClass
     69                                   ³
     70        ÚÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄ¿
     71    AnimClass  ³  TemplateClass    ³        ÃÄ FuseClass     ³    TerrainClass
     72               ³                   ³        ÃÄ FlyClass      ³
     73               ³                   ³  BulletClass            ³
     74        OverlayClass        MissionClass               SmudgeClass
     75                                   ³
     76                              RadioClass
     77                                   ³
     78                                   ÃÄ CrewClass
     79                                   ÃÄ FlasherClass
     80                                   ÃÄ StageClass
     81                                   ÃÄ CargoClass
     82                             TechnoClass
     83                                   ³
     84          ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
     85      FootClass                                         BuildingClass
     86          ³
     87          ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
     88     DriveClass  InfantryClass         ÃÄ FlyClass
     89          ³                      AircraftClass
     90    TurretClass
     91          ³
     92    TarComClass
     93          ³
     94      UnitClass
     95 
     96 
     97                             AbstractTypeClass
     98                                     ³
     99                               ObjectTypeClass
    100                                     ³
    101              ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿
    102              ³                      ³            ³                 ³
    103        TechnoTypeClass              ³            ³                 ³
    104              ³                BulletTypeClass    ³                 ³
    105              ³                           TemplateTypeClass         ³
    106     ÚÄÄÄÄÄÄÄÄÁÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿             TerrainTypeClass
    107     ³              ³           ³              ³
    108 UnitTypeClass      ³   BuildingTypeClass      ³
    109                    ³                  InfantryTypeClass
    110            AircraftTypeClass
    111 #endif
    112 
    113 /*
    114 **	The "bool" integral type was defined by the C++ comittee in
    115 **	November of '94. Until the compiler supports this, use the following
    116 **	definition.
    117 */
    118 enum {false=0,true=1};
    119 typedef int bool;
    120 
    121 
    122 
    123 #define _WIN32
    124 #define WIN32	//_LEAN_AND_MEAN
    125 #include <windows.h>
    126 
    127 
    128 /**********************************************************************
    129 **	If the following define is enabled, then the memory checking code
    130 **	will be disabled.
    131 */
    132 #define NOMEMCHECK
    133 
    134 #include	"watcom.h"
    135 #define FILE_H
    136 #define WWMEM_H
    137 #include "compat.h"
    138 #include <wwlib32.h>
    139 #include	"jshell.h"
    140 
    141 #ifdef
    142 #undef
    143 #endif
    144 #ifdef _pascal
    145 #undef	_pascal
    146 #endif
    147 #ifdef pascal
    148 #undef	pascal
    149 #endif
    150 
    151 #define pascal
    152 #define _pascal
    153 #define
    154 
    155 
    156 
    157 
    158 // Should be part of WWLIB.H. This is used in JSHELL.CPP.
    159 typedef struct {
    160 	unsigned char	SourceColor;
    161 	unsigned char	DestColor;
    162 	unsigned char	Fading;
    163 	unsigned char	reserved;
    164 } TLucentType;
    165 
    166 
    167 // Don't complain if these headers aren't referenced.
    168 #include	<string.h>
    169 #include	<stdlib.h>
    170 #include	<stdio.h>
    171 #include	<stddef.h>
    172 #include	<mem.h>
    173 #include	<dos.h>
    174 #include	<direct.h>
    175 #include	<stdarg.h>
    176 #include	<ctype.h>
    177 #include	<assert.h>
    178 #include	<process.h>
    179 #include	<new.h>
    180 
    181 /*
    182 **	VQ player specific includes.
    183 */
    184 #include <vqa32\vqaplay.h>
    185 #include <vqa32\vqafile.h>
    186 
    187 extern bool GameActive;
    188 extern long LParam;
    189 
    190 #include	"vector.h"
    191 #include	"heap.h"
    192 #include	"ccfile.h"
    193 #include	"monoc.h"
    194 #include	"conquer.h"
    195 //#include	"debug.h"
    196 #include "special.h"
    197 #include	"defines.h"
    198 
    199 
    200 /*
    201 **	Greenleaf specific includes.
    202 */
    203 #include <modem.h>
    204 #include <fast.h>
    205 
    206 
    207 extern long Frame;
    208 inline CELL Coord_XCell(COORDINATE coord) {return (CELL)(*(((unsigned char*)&coord)+1));}
    209 inline CELL Coord_YCell(COORDINATE coord) {return (CELL)(*(((unsigned char*)&coord)+3));}
    210 //inline CELL Coord_Cell(COORD coord){return (CELL)(((*(((unsigned short *)&coord)+1) & 0xFF00) >> 2) | *(((unsigned char *)&coord)+1));}
    211 CELL Coord_Cell(COORDINATE coord);
    212 #pragma aux Coord_Cell parm [eax] \
    213 	modify [ebx] \
    214 	value [ax]		= 				\
    215 	"mov	ebx,eax"					\
    216 	"shr	eax,010h"				\
    217 	"xor	al,al"					\
    218 	"shr	eax,2"					\
    219 	"or	al,bh"
    220 
    221 
    222 #include	"facing.h"
    223 #include	"ftimer.h"
    224 #include	"theme.h"
    225 #include	"link.h"
    226 #include	"gadget.h"
    227 #include	"control.h"
    228 #include	"toggle.h"
    229 #include	"checkbox.h"
    230 #include	"shapebtn.h"
    231 #include	"textbtn.h"
    232 #include	"slider.h"
    233 #include "list.h"
    234 #include "cheklist.h"
    235 #include "colrlist.h"
    236 #include	"edit.h"
    237 #include	"gauge.h"
    238 #include	"msgbox.h"
    239 #include	"dial8.h"
    240 #include	"txtlabel.h"
    241 #include	"super.h"
    242 #include	"house.h"
    243 #include	"gscreen.h"
    244 #include	"map.h"
    245 #include	"display.h"
    246 #include	"radar.h"
    247 #include	"power.h"
    248 #include	"sidebar.h"
    249 #include	"tab.h"
    250 #include	"help.h"
    251 #include	"mouse.h"
    252 //#include	"mapedit.h"
    253 #include	"help.h"
    254 #include	"target.h"
    255 #include	"theme.h"
    256 #include	"team.h"				// Team objects.
    257 #include	"teamtype.h"		// Team type objects.
    258 #include	"trigger.h"			// Trigger event objects.
    259 #include	"mapedit.h"			// ???
    260 #include	"abstract.h"
    261 #include "object.h"
    262 #include "mission.h"
    263 #include	"door.h"
    264 #include	"bullet.h"			// Bullet objects.
    265 #include	"terrain.h"			// Terrain objects.
    266 #include	"anim.h"				// Animation objects.
    267 #include	"template.h"		// Icon template objects.
    268 #include	"overlay.h"			// Overlay objects.
    269 #include	"smudge.h"			// Stains on the terrain objects.
    270 #include	"aircraft.h"		// Aircraft objects.
    271 #include	"unit.h"				// Ground unit objects.
    272 #include	"infantry.h"		// Infantry objects.
    273 #include	"credits.h"			// Credit counter class.
    274 #include	"score.h"			// Scoring system class.
    275 #include	"factory.h"			// Production manager class.
    276 #include "intro.h"
    277 #include "ending.h"
    278 #include	"logic.h"
    279 #include	"queue.h"
    280 #include	"event.h"
    281 #include "base.h"				// defines the AI's pre-built base
    282 #include "ipxmgr.h"
    283 #include	"combuf.h"
    284 #include	"connect.h"
    285 #include	"connmgr.h"
    286 #include	"noseqcon.h"
    287 #include "msglist.h"
    288 #include	"nullconn.h"
    289 #include	"nullmgr.h"
    290 #include "phone.h"
    291 #include "loaddlg.h"
    292 #include	"ipxaddr.h"
    293 
    294 /****************************************************************************
    295 **	This is a "node", used for the lists of available games & players.  The
    296 **	'Game' structure is used for games; the 'Player' structure for players.
    297 */
    298 typedef struct NodeNameTag {
    299 	char Name[MPLAYER_NAME_MAX];
    300 	IPXAddressClass Address;
    301 	union {
    302 		struct {
    303 			int Version;
    304 			unsigned char IsOpen;
    305 			unsigned long LastTime;
    306 		} Game;
    307 		struct {
    308 			HousesType House;
    309 			unsigned char Color;
    310 		} Player;
    311 	};
    312 } NodeNameType;
    313 
    314 
    315 #include	"externs.h"
    316 
    317 
    318 extern int Get_CD_Drive(void);
    319 extern void Fatal(char const *message, ...);
    320 
    321 
    322 /*
    323 **	ANIM.CPP
    324 */
    325 void Shorten_Attached_Anims(ObjectClass * obj);
    326 
    327 /*
    328 **	AUDIO.CPP
    329 */
    330 int Sound_Effect(VocType voc, VolType volume, int variation=1, signed short panvalue=0);
    331 void Speak(VoxType voice);
    332 void Speak_AI(void);
    333 void Stop_Speaking(void);
    334 void Sound_Effect(VocType voc, COORDINATE coord=NULL, int variation=1);
    335 bool Is_Speaking(void);
    336 
    337 /*
    338 **	COMBAT.CPP
    339 */
    340 int Modify_Damage(int damage, WarheadType warhead, ArmorType armor, int distance);
    341 void Explosion_Damage(COORDINATE coord, unsigned strength, TechnoClass * source, WarheadType warhead);
    342 
    343 /*
    344 **	CONQUER.CPP
    345 */
    346 void Center_About_Objects(void);
    347 bool Force_CD_Available(int cd);
    348 void Handle_View(int view, int action=0);
    349 void Handle_Team(int team, int action=0);
    350 TechnoTypeClass const * Fetch_Techno_Type(RTTIType type, int id);
    351 char const * Fading_Table_Name(char const * base, TheaterType theater);
    352 void Unselect_All(void);
    353 void Play_Movie(char const * name, ThemeType theme=THEME_NONE, bool clrscrn=true);
    354 bool Main_Loop();
    355 TheaterType Theater_From_Name(char const *name);
    356 //DirType Rotation_Calc(DirType current, DirType desired, int rate);
    357 void Main_Game(int argc, char *argv[]);
    358 long VQ_Call_Back(unsigned char * buffer=NULL, long frame=0);
    359 void Call_Back(void);
    360 char const *Language_Name(char const *basename);
    361 SourceType Source_From_Name(char const *name);
    362 char const *Name_From_Source(SourceType source);
    363 FacingType KN_To_Facing(int input);
    364 void const *Get_Radar_Icon(void const *shapefile, int shapenum, int frames, int zoomfactor);
    365 void CC_Draw_Shape(void const * shapefile, int shapenum, int x, int y, WindowNumberType window, ShapeFlags_Type flags, void const * fadingdata=0, void const * ghostdata=0);
    366 void Go_Editor(bool flag);
    367 long MixFileHandler(VQAHandle *vqa, long action, void *buffer, long nbytes);
    368 
    369 char *CC_Get_Shape_Filename(void const *shapeptr );
    370 void CC_Add_Shape_To_Global(void const *shapeptr, char *filename, char code );
    371 
    372 void Bubba_Print(char *format,...);
    373 
    374 void Heap_Dump_Check( char *string );
    375 void Dump_Heap_Pointers( void );
    376 unsigned long Disk_Space_Available(void);
    377 
    378 void Validate_Error(char *name);
    379 void const * Hires_Retrieve(char *name);
    380 int Get_Resolution_Factor(void);
    381 
    382 
    383 /*
    384 ** INTERPAL.CPP
    385 */
    386 #define SIZE_OF_PALETTE 256
    387 extern	"C" unsigned char *InterpolationPalette;
    388 extern	BOOL	InterpolationPaletteChanged;
    389 extern	void 	Interpolate_2X_Scale( GraphicBufferClass *source, GraphicBufferClass *dest ,char const *palette_file_name);
    390 void Read_Interpolation_Palette (char const *palette_file_name);
    391 void Write_Interpolation_Palette (char const *palette_file_name);
    392 void Increase_Palette_Luminance(unsigned char *InterpolationPalette ,	int RedPercentage ,int GreenPercentage ,int BluePercentage ,int cap);
    393 extern "C"{
    394 	extern unsigned char PaletteInterpolationTable[SIZE_OF_PALETTE][SIZE_OF_PALETTE];
    395 	extern unsigned char *InterpolationPalette;
    396 	void __cdecl Asm_Create_Palette_Interpolation_Table(void);
    397 }
    398 
    399 
    400 /*
    401 **	COORD.CPP
    402 */
    403 void  Move_Point(short &x, short &y, register DirType dir, unsigned short distance);
    404 COORDINATE  Adjacent_Cell(COORDINATE coord, FacingType dir);
    405 COORDINATE  Coord_Move(COORDINATE start, DirType facing, unsigned short distance);
    406 COORDINATE  Coord_Scatter(COORDINATE coord, unsigned distance, bool lock=false);
    407 DirType  Direction(CELL cell1, CELL cell2);
    408 DirType  Direction(COORDINATE coord1, COORDINATE coord2);
    409 DirType  Direction256(COORDINATE coord1, COORDINATE coord2);
    410 DirType  Direction8(COORDINATE coord1, COORDINATE coord2);
    411 int  Distance(CELL coord1, CELL coord2);
    412 int  Distance(COORDINATE coord1, COORDINATE coord2);
    413 short const *  Coord_Spillage_List(COORDINATE coord, int maxsize);
    414 //void Move_Point(unsigned short &x, unsigned short &y, DirType dir, unsigned short distance);
    415 
    416 /*
    417 **	COORDA.CPP
    418 */
    419 //extern "C" {
    420 //unsigned Cardinal_To_Fixed(unsigned base, unsigned cardinal);
    421 //unsigned Fixed_To_Cardinal(unsigned base, unsigned fixed);
    422 //}
    423 
    424 /*
    425 **	DEBUG.CPP
    426 */
    427 void Log_Event(char const *text, ...);
    428 void Debug_Key(unsigned input);
    429 void Self_Regulate(void);
    430 
    431 /*
    432 **	DIALOG.CPP
    433 */
    434 int Format_Window_String(char * string, int maxlinelen, int & width, int & height);
    435 extern void Dialog_Box(int x, int y, int w, int h);
    436 void Conquer_Clip_Text_Print(char const *, unsigned x, unsigned y, unsigned fore, unsigned back=(unsigned)TBLACK, TextPrintType flag=TPF_8POINT|TPF_DROPSHADOW, unsigned width=-1, int const * tabs=0);
    437 void Draw_Box(int x, int y, int w, int h, BoxStyleEnum up, bool filled);
    438 int __cdecl Dialog_Message(char *errormsg, ...);
    439 void Window_Box(WindowNumberType window, BoxStyleEnum style);
    440 void Fancy_Text_Print(char const *text, unsigned x, unsigned y, unsigned fore, unsigned back, TextPrintType flag, ...);
    441 void Fancy_Text_Print(int text, unsigned x, unsigned y, unsigned fore, unsigned back, TextPrintType flag, ...);
    442 void Simple_Text_Print(char const *text, unsigned x, unsigned y, unsigned fore, unsigned back, TextPrintType flag);
    443 
    444 /*
    445 **	DISPLAY.CPP
    446 */
    447 
    448 /*
    449 **	ENDING.CPP
    450 */
    451 void GDI_Ending(void);
    452 void Nod_Ending(void);
    453 
    454 /*
    455 **	EXPAND.CPP
    456 */
    457 bool Expansion_Present(void);
    458 bool Expansion_Dialog(void);
    459 
    460 /*
    461 **	FINDPATH.CPP
    462 */
    463 //PathType * Find_Path(CELL source, CELL dest, FacingType *final_moves, int maxlen, int (*callback)(CELL, FacingType), int threshhold);
    464 int Optimize_Moves(PathType *path, int (*callback)(CELL, FacingType), int threshhold);
    465 
    466 /*
    467 **	GOPTIONS.CPP
    468 */
    469 void Draw_Caption(int text, int x, int y, int w);
    470 
    471 /*
    472 **	INI.CPP
    473 */
    474 void Set_Scenario_Name(char *buf, int scenario, ScenarioPlayerType player, ScenarioDirType dir = SCEN_DIR_NONE, ScenarioVarType var = SCEN_VAR_NONE);
    475 void Write_Scenario_Ini(char *root);
    476 bool Read_Scenario_Ini(char *root, bool fresh=true);
    477 int Scan_Place_Object(ObjectClass *obj, CELL cell);
    478 
    479 //10/28/2019 JAS - Need ability to read scenarios in any directory
    480 bool Read_Scenario_Ini_File(char *scenario_file_name, char* bin_file_name, const char* root, bool fresh);
    481 
    482 //10/14/2019 JAS - Need ability to read the movies out of each scenario file.
    483 bool Read_Movies_From_Scenario_Ini(char *root, bool fresh = true);
    484 
    485 /*
    486 **	INIT.CPP
    487 */
    488 void Uninit_Game(void);
    489 long Obfuscate(char const * string);
    490 void Anim_Init(void);
    491 bool Init_Game(int argc, char *argv[]);
    492 bool Select_Game(bool fade = false);
    493 bool Parse_Command_Line(int argc, char *argv[]);
    494 void Parse_INI_File(void);
    495 int Version_Number(void);
    496 void Save_Recording_Values(void);
    497 void Load_Recording_Values(void);
    498 
    499 /*
    500 ** JSHELL.CPP
    501 */
    502 void * Small_Icon(void const * iconptr, int iconnum);
    503 void Set_Window(int window, int x, int y, int w, int h);
    504 void * Load_Alloc_Data(FileClass &file);
    505 long Load_Uncompress(FileClass &file, BuffType &uncomp_buff, BuffType &dest_buff, void *reserved_data);
    506 long Translucent_Table_Size(int count);
    507 void *Build_Translucent_Table(void const *palette, TLucentType const *control, int count, void *buffer);
    508 void *Conquer_Build_Translucent_Table(void const *palette, TLucentType const *control, int count, void *buffer);
    509 
    510 /*
    511 **	KEYFBUFF.ASM
    512 */
    513 #ifdef __cplusplus
    514 extern "C" {
    515 #endif
    516 long __cdecl Buffer_Frame_To_Page(int x, int y, int w, int h, void *Buffer, GraphicViewPortClass &view, int flags, ...);
    517 #ifdef __cplusplus
    518 }
    519 #endif
    520 
    521 /*
    522 **	KEYFRAME.CPP
    523 */
    524 int Get_Last_Frame_Length(void);
    525 unsigned long Build_Frame(void const *dataptr, unsigned short framenumber, void *buffptr);
    526 unsigned short Get_Build_Frame_Count(void const *dataptr);
    527 unsigned short Get_Build_Frame_X(void const *dataptr);
    528 unsigned short Get_Build_Frame_Y(void const *dataptr);
    529 unsigned short Get_Build_Frame_Width(void const *dataptr);
    530 unsigned short Get_Build_Frame_Height(void const *dataptr);
    531 bool Get_Build_Frame_Palette(void const *dataptr, void *palette);
    532 
    533 /*
    534 **	MAP.CPP
    535 */
    536 int Terrain_Cost(CELL cell, FacingType facing);
    537 int Coord_Spillage_Number(COORDINATE coord, int maxsize);
    538 
    539 /*
    540 **	MENUS.CPP
    541 */
    542 void Setup_Menu(int menu, char const *text[], unsigned long field, int index, int skip);
    543 int Check_Menu(int menu, char const *text[], char *selection, long field, int index);
    544 int Do_Menu(char const **strings, bool blue);
    545 extern int UnknownKey;
    546 int Main_Menu(unsigned long timeout);
    547 
    548 /*
    549 ** MPLAYER.CPP
    550 */
    551 GameType Select_MPlayer_Game (void);
    552 void Read_MultiPlayer_Settings (void);
    553 void Write_MultiPlayer_Settings (void);
    554 void Read_Scenario_Descriptions (void);
    555 void Free_Scenario_Descriptions(void);
    556 void Computer_Message(void);
    557 int Surrender_Dialog(void);
    558 
    559 /*
    560 ** NETDLG.CPP
    561 */
    562 bool Init_Network (void);
    563 void Shutdown_Network (void);
    564 bool Remote_Connect (void);
    565 void Destroy_Connection(int id, int error);
    566 bool Process_Global_Packet(GlobalPacketType *packet, IPXAddressClass *address);
    567 unsigned long Compute_Name_CRC(char *name);
    568 void Net_Reconnect_Dialog(int reconn, int fresh, int oldest_index, unsigned long timeval);
    569 
    570 /*
    571 ** NULLDLG.CPP
    572 */
    573 int Init_Null_Modem( SerialSettingsType *settings );
    574 void Shutdown_Modem( void );
    575 void Modem_Signoff( void );
    576 int Test_Null_Modem( void );
    577 int Reconnect_Modem( void );
    578 void Destroy_Null_Connection(int id, int error);
    579 GameType Select_Serial_Dialog( void );
    580 int Com_Scenario_Dialog(void);
    581 int Com_Show_Scenario_Dialog(void);
    582 
    583 void Smart_Printf( char *format, ... );
    584 void Hex_Dump_Data( char *buffer, int length );
    585 void itoh( int i, char *s);
    586 
    587 /*
    588 **	PROFILE.CPP
    589 */
    590 int WWGetPrivateProfileInt(char const *section, char const *entry, int def, char *profile);
    591 bool WWWritePrivateProfileInt(char const *section, char const *entry, int value, char *profile);
    592 bool WWWritePrivateProfileString(char const *section, char const *entry, char const *string, char *profile);
    593 char * WWGetPrivateProfileString(char const *section, char const *entry, char const *def, char *retbuffer, int retlen, char *profile);
    594 unsigned WWGetPrivateProfileHex (char const *section, char const *entry, char *profile);
    595 
    596 /*
    597 ** QUEUE.CPP
    598 */
    599 bool Queue_Target(TARGET whom, TARGET target);
    600 bool Queue_Destination(TARGET whom, TARGET target);
    601 bool Queue_Mission(TARGET whom, MissionType mission);
    602 bool Queue_Mission(TARGET whom, MissionType mission, TARGET target, TARGET destination);
    603 bool Queue_Options(void);
    604 bool Queue_Exit(void);
    605 void Queue_AI(void);
    606 void Add_CRC(unsigned long *crc, unsigned long val);
    607 
    608 /*
    609 **	RAND.CPP
    610 */
    611 int Sim_IRandom(int minval, int maxval);
    612 int Sim_Random(void);
    613 
    614 /*
    615 **	REINF.CPP
    616 */
    617 bool Do_Reinforcements(TeamTypeClass *team);
    618 bool Create_Special_Reinforcement(HouseClass * house, TechnoTypeClass const * type, TechnoTypeClass const * another, TeamMissionType mission = TMISSION_NONE, int argument =0);
    619 int Create_Air_Reinforcement(HouseClass *house, AircraftType air, int number, MissionType mission, TARGET tarcom, TARGET navcom);
    620 
    621 /*
    622 **	SAVELOAD.CPP
    623 */
    624 bool Load_Misc_Values(FileClass &file);
    625 bool Save_Misc_Values(FileClass &file);
    626 bool Get_Savefile_Info(int id, char *buf, unsigned *scenp, HousesType *housep);
    627 bool Load_Game(int id);
    628 bool Read_Object (void *ptr, int base_size, int class_size, FileClass & file, void * vtable);
    629 bool Save_Game(int id,char *descr);
    630 bool Write_Object (void *ptr, int class_size, FileClass & file);
    631 TARGET TechnoType_To_Target(TechnoTypeClass const * ptr);
    632 TechnoTypeClass const * Target_To_TechnoType(TARGET target);
    633 void * Get_VTable(void *ptr, int base_size);
    634 void Code_All_Pointers(void);
    635 void Decode_All_Pointers(void);
    636 void Dump(void);
    637 void Set_VTable(void *ptr, int base_size, void *vtable);
    638 
    639 /*
    640 ** SCENARIO.CPP
    641 */
    642 bool End_Game(void);
    643 bool Read_Scenario(char *root);
    644 bool Start_Scenario(char *root, bool briefing=true);
    645 HousesType Select_House(void);
    646 void Clear_Scenario(void);
    647 void Do_Briefing(char const * text);
    648 void Do_Lose(void);
    649 void Do_Win(void);
    650 void Do_Restart(void);
    651 void Fill_In_Data(void);
    652 bool Restate_Mission(char const * name, int button1, int button2);
    653 
    654 /*
    655 **	SCORE.CPP
    656 */
    657 void Map_Selection(void);
    658 void Bit_It_In_Scale(int x, int y, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest, GraphicBufferClass *seen , int delay=0, int dagger=0);
    659 void Bit_It_In(int x, int y, int w, int h, GraphicBufferClass *src, GraphicBufferClass *dest, int delay=0, int dagger=0);
    660 void Call_Back_Delay(int time);
    661 int Alloc_Object(ScoreAnimClass *obj);
    662 extern GraphicBufferClass *PseudoSeenBuff;
    663 
    664 void Window_Dialog_Box(HANDLE  hinst, LPCTSTR  lpszTemplate, HWND  hwndOwner, DLGPROC  dlgprc);
    665 
    666 /*
    667 **	SPECIAL.CPP
    668 */
    669 void Special_Dialog(void);
    670 
    671 /*
    672 **	SUPPORT.ASM
    673 */
    674 #ifdef	__cplusplus
    675 extern "C" {
    676 #endif
    677 void __cdecl Remove_From_List(void **list, int *index, void * ptr);
    678 void * __cdecl Conquer_Build_Fading_Table(void const *palette, void *dest, int color, int frac);
    679 void __cdecl Fat_Put_Pixel(int x, int y, int color, int size, GraphicViewPortClass &);
    680 void __cdecl strtrim(char *buffer);
    681 long __cdecl Get_EAX( void );
    682 #ifdef	__cplusplus
    683 }
    684 #endif
    685 
    686 /*
    687 **	TARCOM.CPP
    688 */
    689 
    690 /*
    691 ** TARGET.CPP
    692 */
    693 COORDINATE  As_Movement_Coord(TARGET target);
    694 AircraftClass *  As_Aircraft(TARGET target);
    695 AnimClass *  As_Animation(TARGET target);
    696 BuildingClass *  As_Building(TARGET target);
    697 BulletClass *  As_Bullet(TARGET target);
    698 CELL  As_Cell(TARGET target);
    699 COORDINATE  As_Coord(TARGET target);
    700 InfantryClass *  As_Infantry(TARGET target);
    701 TeamClass *  As_Team(TARGET target);
    702 TeamTypeClass *  As_TeamType(TARGET target);
    703 TechnoClass *  As_Techno(TARGET target);
    704 //TerrainClass * As_Terrain(TARGET target);
    705 TriggerClass *  As_Trigger(TARGET target);
    706 UnitClass *  As_Unit(TARGET target);
    707 bool  Target_Legal(TARGET target);
    708 ObjectClass *  As_Object(TARGET target);
    709 
    710 /*
    711 ** ULOGIC.CPP
    712 */
    713 int Terrain_Cost(CELL cell, FacingType facing);
    714 
    715 /*
    716 **	Inline miscellaneous functions.
    717 */
    718 #define	XYP_COORD(x,y)	(((x)*ICON_LEPTON_W)/CELL_PIXEL_W + ((((y)*ICON_LEPTON_H)/CELL_PIXEL_H)<<16))
    719 inline FacingType Dir_Facing(DirType facing) {return (FacingType)(((unsigned char)(facing+0x10)&0xFF)>>5);}
    720 inline DirType Facing_Dir(FacingType facing) {return (DirType)((int)facing << 5);}
    721 inline int Cell_To_Lepton(int cell) {return cell<<8;}
    722 inline int Lepton_To_Cell(int lepton) {return ((unsigned)(lepton + 0x0080))>>8;}
    723 inline CELL XY_Cell(int x, int y) {return ((CELL)(((y)<<6)|(x)));}
    724 inline COORDINATE XY_Coord(int x, int y) {return ((COORDINATE)MAKE_LONG(y, x));}
    725 inline int Coord_X(COORDINATE coord) {return (short)(LOW_WORD(coord));}
    726 inline int Coord_Y(COORDINATE coord) {return (short)(HIGH_WORD(coord));}
    727 inline int Cell_X(CELL cell) {return (int)(((unsigned)cell) & 0x3F);}
    728 inline int Cell_Y(CELL cell) {return (int)(((unsigned)cell) >> 6);}
    729 inline int Dir_Diff(DirType dir1, DirType dir2) {return (int)(*((signed char*)&dir2) - *((signed char*)&dir1));}
    730 inline CELL Coord_XLepton(COORDINATE coord) {return (CELL)(*((unsigned char*)&coord));}
    731 inline CELL Coord_YLepton(COORDINATE coord) {return (CELL)(*(((unsigned char*)&coord)+2));}
    732 //inline COORD CellXY_Coord(unsigned x, unsigned y) {return (COORD)(MAKE_LONG(y<<8, x<<8));}
    733 inline COORDINATE Coord_Add(COORDINATE coord1, COORDINATE coord2) {return (COORDINATE)MAKE_LONG((*((short*)(&coord1)+1) + *((short*)(&coord2)+1)), (*((short*)(&coord1)) + *((short*)(&coord2))));}
    734 inline COORDINATE Coord_Sub(COORDINATE coord1, COORDINATE coord2) {return (COORDINATE)MAKE_LONG((*((short*)(&coord1)+1) - *((short*)(&coord2)+1)), (*((short*)(&coord1)) - *((short*)(&coord2))));}
    735 inline COORDINATE Coord_Snap(COORDINATE coord) {return (COORDINATE)MAKE_LONG((((*(((unsigned short *)&coord)+1))&0xFF00)|0x80), (((*((unsigned short *)&coord))&0xFF00)|0x80));}
    736 inline COORDINATE Coord_Mid(COORDINATE coord1, COORDINATE coord2) {return (COORDINATE)MAKE_LONG((*((unsigned short *)(&coord1)+1) + *((unsigned short *)(&coord2)+1))>>1, (*((unsigned short *)(&coord1)) + *((unsigned short *)(&coord2)))>>1);}
    737 inline COORDINATE Cell_Coord(CELL cell) {return (COORDINATE) MAKE_LONG( (((cell & 0x0FC0)<<2)|0x80), ((((cell & 0x003F)<<1)+1)<<7) );}
    738 inline COORDINATE XYPixel_Coord(int x, int y) {return ((COORDINATE)MAKE_LONG((int)(((long)y*(long)ICON_LEPTON_H)/(long)ICON_PIXEL_H)/*+LEPTON_OFFSET_Y*/, (int)(((long)x*(long)ICON_LEPTON_W)/(long)ICON_PIXEL_W)/*+LEPTON_OFFSET_X*/));}
    739 //inline int Facing_To_16(int facing) {return Facing16[facing];}
    740 inline int Facing_To_32(DirType facing) {return Facing32[facing];}
    741 inline DirType Direction256(COORDINATE coord1, COORDINATE coord2) {return ((DirType)Desired_Facing256(Coord_X(coord1), Coord_Y(coord1), Coord_X(coord2), Coord_Y(coord2)));}
    742 inline DirType Direction(COORDINATE coord1, COORDINATE coord2) {return ((DirType)Desired_Facing256(Coord_X(coord1), Coord_Y(coord1), Coord_X(coord2), Coord_Y(coord2)));}
    743 inline DirType Direction8(COORDINATE coord1, COORDINATE coord2) {return ((DirType)Desired_Facing8(Coord_X(coord1), Coord_Y(coord1), Coord_X(coord2), Coord_Y(coord2)));}
    744 //inline int Direction16(COORDINATE coord1, COORD coord2) {return (Desired_Facing16(Coord_X(coord1), Coord_Y(coord1), Coord_X(coord2), Coord_Y(coord2)));}
    745 inline DirType Direction(CELL cell1, CELL cell2) {return (DirType)(Desired_Facing8(Cell_X(cell1), Cell_Y(cell1), Cell_X(cell2), Cell_Y(cell2)));}
    746 inline COORDINATE Adjacent_Cell(COORDINATE coord, FacingType dir) {return (Coord_Snap(Coord_Add(AdjacentCoord[dir & 0x07], coord)));}
    747 inline COORDINATE Adjacent_Cell(COORDINATE coord, DirType dir) {return Adjacent_Cell(coord, Dir_Facing(dir));}
    748 inline CELL Adjacent_Cell(CELL cell, FacingType dir) {return (CELL)(cell + AdjacentCell[dir]);}
    749 inline CELL Adjacent_Cell(CELL cell, DirType dir) {return (CELL)(cell + AdjacentCell[Dir_Facing(dir)]);}
    750 inline int Lepton_To_Pixel(int lepton) {return ((lepton * ICON_PIXEL_W) + (ICON_LEPTON_W / 2)) / ICON_LEPTON_W;}
    751 inline int Pixel_To_Lepton(int pixel) {return ((pixel * ICON_LEPTON_W) + (ICON_PIXEL_W / 2)) / ICON_PIXEL_W;}
    752 //inline FacingType Facing_To_8(DirType facing) {return (FacingType)(((unsigned char)(facing|0x10))>>5);}
    753 inline COORDINATE XYP_Coord(int x,int y) {return XY_Coord(Pixel_To_Lepton(x), Pixel_To_Lepton(y));};
    754 inline char const * Text_String(int string) {return(Extract_String(SystemStrings, string));};
    755 
    756 
    757 template<class T> inline T Random_Pick(T a, T b)
    758 {
    759 	return (T)IRandom((int)a, (int)b);
    760 };
    761 
    762 template<class T> inline T Sim_Random_Pick(T a, T b)
    763 {
    764 	return (T)Sim_IRandom((int)a, (int)b);
    765 };
    766 
    767 
    768 #ifdef CHEAT_KEYS
    769 #define Check_Ptr(ptr,file,line)  \
    770 { \
    771 	if (!ptr) { \
    772 		Mono_Clear_Screen(); \
    773 		Mono_Printf("NULL Pointer, Module:%s, line:%d!\n",file,line); \
    774 		Prog_End(); \
    775 		exit(EXIT_SUCCESS); \
    776 	} \
    777 }
    778 #else
    779 #define	Check_Ptr(ptr,file,line)
    780 #endif
    781 
    782 /*
    783 ** These routines are for coding & decoding multiplayer ID's
    784 */
    785 inline PlayerColorType MPlayerID_To_ColorIndex(unsigned short id) {return (PlayerColorType)(id >> 4);}
    786 inline HousesType MPlayerID_To_HousesType(unsigned short id) {return ((HousesType)(id & 0x000f)); }
    787 inline unsigned short Build_MPlayerID(int c_idx, HousesType htype) { return ((c_idx << 4) | htype); }
    788 
    789 
    790 
    791 
    792 //
    793 //  True if we are the currently in focus windows app
    794 //
    795 extern bool GameInFocus;
    796 
    797 extern	int	ScreenWidth;
    798 extern	int	ScreenHeight;
    799 extern "C" void ModeX_Blit (GraphicBufferClass *source);
    800 extern	void Colour_Debug (int call_number);
    801 
    802 
    803 extern	unsigned char 	*InterpolatedPalettes[50];
    804 extern BOOL				PalettesRead;
    805 extern unsigned			PaletteCounter;
    806 
    807 extern "C"{
    808 	extern unsigned char PaletteInterpolationTable[SIZE_OF_PALETTE][SIZE_OF_PALETTE];
    809 	extern unsigned char *InterpolationPalette;
    810 }
    811 
    812 extern void Free_Interpolated_Palettes(void);
    813 extern int Load_Interpolated_Palettes(char const *filename, BOOL add=FALSE);
    814 
    815 
    816 #define	CELL_BLIT_ONLY	1
    817 #define	CELL_DRAW_ONLY	2
    818 
    819 /***********************************************************************************************
    820  * Distance -- Determines the lepton distance between two coordinates.                         *
    821  *                                                                                             *
    822  *    This routine is used to determine the distance between two coordinates. It uses the      *
    823  *    Dragon Strike method of distance determination and thus it is very fast.                 *
    824  *                                                                                             *
    825  * INPUT:   coord1   -- First coordinate.                                                      *
    826  *                                                                                             *
    827  *          coord2   -- Second coordinate.                                                     *
    828  *                                                                                             *
    829  * OUTPUT:  Returns the lepton distance between the two coordinates.                           *
    830  *                                                                                             *
    831  * WARNINGS:   none                                                                            *
    832  *                                                                                             *
    833  * HISTORY:                                                                                    *
    834  *   05/27/1994 JLB : Created.                                                                 *
    835  *=============================================================================================*/
    836 int Distance_Coord(COORDINATE coord1, COORDINATE coord2);
    837 #pragma aux Distance_Coord parm [eax] [ebx] \
    838 	modify [edx ebx] \
    839 	value [eax]		= 				\
    840 	"mov	dx,ax"			\
    841 	"sub	dx,bx"			\
    842 	"jg	okx"				\
    843 	"neg	dx"				\
    844 	"okx:"					\
    845 	"shr	eax,16"			\
    846 	"shr	ebx,16"			\
    847 	"sub	ax,bx"			\
    848 	"jg	oky"				\
    849 	"neg	ax"				\
    850 	"oky:"					\
    851 	"cmp	ax,dx"			\
    852 	"jg	ok"				\
    853 	"xchg	ax,dx"			\
    854 	"ok:"						\
    855 	"shr	dx,1"				\
    856 	"add	ax,dx"
    857 
    858 inline int Distance(COORDINATE coord1, COORDINATE coord2)
    859 {
    860 #ifdef NEVER
    861 	int	diff1, diff2;
    862 
    863 	diff1 = Coord_Y(coord1) - Coord_Y(coord2);
    864 	if (diff1 < 0) diff1 = -diff1;
    865 	diff2 = Coord_X(coord1) - Coord_X(coord2);
    866 	if (diff2 < 0) diff2 = -diff2;
    867 	if (diff1 > diff2) {
    868 		return(diff1 + (diff2>>1));
    869 	}
    870 	return(diff2 + (diff1>>1));
    871 #else
    872 	return(Distance_Coord(coord1, coord2));
    873 #endif
    874 }
    875 
    876 
    877 
    878 /***********************************************************************************************
    879  * Distance -- Determines the cell distance between two cells.                                 *
    880  *                                                                                             *
    881  *    Use this routine to determine the distance between the two cells specified. The distance *
    882  *    is returned in cells.                                                                    *
    883  *                                                                                             *
    884  * INPUT:   cell1, cell2   -- The two cells to determine the distance between.                 *
    885  *                                                                                             *
    886  * OUTPUT:  Returns with the distance between the two cells in units of cell size.             *
    887  *                                                                                             *
    888  * WARNINGS:   none                                                                            *
    889  *                                                                                             *
    890  * HISTORY:                                                                                    *
    891  *   12/23/1994 JLB : Created.                                                                 *
    892  *=============================================================================================*/
    893 inline int Distance(CELL coord1, CELL coord2)
    894 {
    895 	int	diff1, diff2;
    896 
    897 	diff1 = Cell_Y(coord1) - Cell_Y(coord2);
    898 	if (diff1 < 0) diff1 = -diff1;
    899 	diff2 = Cell_X(coord1) - Cell_X(coord2);
    900 	if (diff2 < 0) diff2 = -diff2;
    901 	if (diff1 > diff2) {
    902 		return(diff1 + (diff2>>1));
    903 	}
    904 	return(diff2 + (diff1>>1));
    905 }
    906 
    907 
    908 /***********************************************************************************************
    909  * CellClass::Cell_Number -- Returns the cell ID number for this cell object.                  *
    910  *                                                                                             *
    911  *    Call this routine if you wish to determine what the cell number ID is for the currrent   *
    912  *    cell object. This ID number is the index number into the cell array.                     *
    913  *                                                                                             *
    914  * INPUT:   none                                                                               *
    915  *                                                                                             *
    916  * OUTPUT:  Returns with the cell number for this cell object.                                 *
    917  *                                                                                             *
    918  * WARNINGS:   none                                                                            *
    919  *                                                                                             *
    920  * HISTORY:                                                                                    *
    921  *   03/19/1995 JLB : Created.                                                                 *
    922  *=============================================================================================*/
    923 inline CELL CellClass::Cell_Number(void) const
    924 {
    925 	return(Map.ID(this));
    926 }
    927 
    928 #ifndef NOMEMCHECK
    929 #define NO_INTERCEPT
    930 #include	"memcheck.h"
    931 #endif
    932 
    933 
    934 void WWDOS_Shutdown(void);
    935 
    936 #endif
    937