REAL.H 34 KB

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