FUNCTION.H 34 KB

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