global.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. /* -*- mode: c; tab-width: 4; c-basic-offset: 3; c-file-style: "linux" -*- */
  2. //
  3. // Copyright (c) 2009, Wei Mingzhi <whistler_wmz@users.sf.net>.
  4. // All rights reserved.
  5. //
  6. // This file is part of SDLPAL.
  7. //
  8. // SDLPAL is free software: you can redistribute it and/or modify
  9. // it under the terms of the GNU General Public License as published by
  10. // the Free Software Foundation, either version 3 of the License, or
  11. // (at your option) any later version.
  12. //
  13. // This program is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. // GNU General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU General Public License
  19. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. //
  21. // Modified by Lou Yihua <louyihua@21cn.com> with Unicode support, 2015
  22. //
  23. #ifndef GLOBAL_H
  24. #define GLOBAL_H
  25. #include "common.h"
  26. #include "palcommon.h"
  27. #include "map.h"
  28. #include "ui.h"
  29. #ifdef __cplusplus
  30. extern "C"
  31. {
  32. #endif
  33. //
  34. // SOME NOTES ON "AUTO SCRIPT" AND "TRIGGER SCRIPT":
  35. //
  36. // Auto scripts are executed automatically in each frame.
  37. //
  38. // Trigger scripts are only executed when the event is triggered (player touched
  39. // an event object, player triggered an event script by pressing Spacebar).
  40. //
  41. // maximum number of players in party
  42. #define MAX_PLAYERS_IN_PARTY 3
  43. // total number of possible player roles
  44. #define MAX_PLAYER_ROLES 6
  45. // totally number of playable player roles
  46. #define MAX_PLAYABLE_PLAYER_ROLES 5
  47. // maximum entries of inventory
  48. #define MAX_INVENTORY 256
  49. // maximum items in a store
  50. #define MAX_STORE_ITEM 9
  51. // total number of magic attributes
  52. #define NUM_MAGIC_ELEMENTAL 5
  53. // maximum number of enemies in a team
  54. #define MAX_ENEMIES_IN_TEAM 5
  55. // maximum number of equipments for a player
  56. #define MAX_PLAYER_EQUIPMENTS 6
  57. // maximum number of magics for a player
  58. #define MAX_PLAYER_MAGICS 32
  59. // maximum number of scenes
  60. #define MAX_SCENES 300
  61. // maximum number of objects
  62. #define MAX_OBJECTS 600
  63. // maximum number of event objects (should be somewhat more than the original,
  64. // as there are some modified versions which has more)
  65. #define MAX_EVENT_OBJECTS 5500
  66. // maximum number of effective poisons to players
  67. #define MAX_POISONS 16
  68. // maximum number of level
  69. #define MAX_LEVELS 99
  70. #define OBJECT_ITEM_START 0x3D
  71. #define OBJECT_ITEM_END 0x126
  72. #define OBJECT_MAGIC_START 0x127
  73. #define OBJECT_MAGIC_END 0x18D
  74. #define MINIMAL_WORD_COUNT (MAX_OBJECTS + 12)
  75. // status of characters
  76. typedef enum tagSTATUS
  77. {
  78. kStatusConfused = 0, // attack friends randomly
  79. kStatusParalyzedOrSlow, // paralyzed or slower
  80. kStatusSleep, // not allowed to move
  81. kStatusSilence, // cannot use magic
  82. kStatusPuppet, // for dead players only, continue attacking
  83. kStatusBravery, // more power for physical attacks
  84. kStatusProtect, // more defense value
  85. kStatusHaste, // faster
  86. kStatusDualAttack, // dual attack
  87. kStatusAll
  88. } STATUS;
  89. #define kStatusSlow kStatusParalyzedOrSlow
  90. #define kStatusParalyzed (gConfig.fIsClassic ? kStatusParalyzedOrSlow : kStatusSleep)
  91. // body parts of equipments
  92. typedef enum tagBODYPART
  93. {
  94. kBodyPartHead = 0,
  95. kBodyPartBody,
  96. kBodyPartShoulder,
  97. kBodyPartHand,
  98. kBodyPartFeet,
  99. kBodyPartWear,
  100. kBodyPartExtra,
  101. } BODYPART;
  102. // state of event object, used by the sState field of the EVENTOBJECT struct
  103. typedef enum tagOBJECTSTATE
  104. {
  105. kObjStateHidden = 0,
  106. kObjStateNormal = 1,
  107. kObjStateBlocker = 2
  108. } OBJECTSTATE, *LPOBJECTSTATE;
  109. typedef enum tagTRIGGERMODE
  110. {
  111. kTriggerNone = 0,
  112. kTriggerSearchNear = 1,
  113. kTriggerSearchNormal = 2,
  114. kTriggerSearchFar = 3,
  115. kTriggerTouchNear = 4,
  116. kTriggerTouchNormal = 5,
  117. kTriggerTouchFar = 6,
  118. kTriggerTouchFarther = 7,
  119. kTriggerTouchFarthest = 8
  120. } TRIGGERMODE;
  121. typedef struct tagEVENTOBJECT
  122. {
  123. SHORT sVanishTime; // vanish time (?)
  124. WORD x; // X coordinate on the map
  125. WORD y; // Y coordinate on the map
  126. SHORT sLayer; // layer value
  127. WORD wTriggerScript; // Trigger script entry
  128. WORD wAutoScript; // Auto script entry
  129. SHORT sState; // state of this object
  130. WORD wTriggerMode; // trigger mode
  131. WORD wSpriteNum; // number of the sprite
  132. USHORT nSpriteFrames; // total number of frames of the sprite
  133. WORD wDirection; // direction
  134. WORD wCurrentFrameNum; // current frame number
  135. USHORT nScriptIdleFrame; // count of idle frames, used by trigger script
  136. WORD wSpritePtrOffset; // FIXME: ???
  137. USHORT nSpriteFramesAuto; // total number of frames of the sprite, used by auto script
  138. WORD wScriptIdleFrameCountAuto; // count of idle frames, used by auto script
  139. } EVENTOBJECT, *LPEVENTOBJECT;
  140. typedef struct tagSCENE
  141. {
  142. WORD wMapNum; // number of the map
  143. WORD wScriptOnEnter; // when entering this scene, execute script from here
  144. WORD wScriptOnTeleport; // when teleporting out of this scene, execute script from here
  145. WORD wEventObjectIndex; // event objects in this scene begins from number wEventObjectIndex + 1
  146. } SCENE, *LPSCENE;
  147. // object including system strings, players, items, magics, enemies and poison scripts.
  148. // system strings and players
  149. typedef struct tagOBJECT_PLAYER
  150. {
  151. WORD wReserved[2]; // always zero
  152. WORD wScriptOnFriendDeath; // when friends in party dies, execute script from here
  153. WORD wScriptOnDying; // when dying, execute script from here
  154. } OBJECT_PLAYER;
  155. typedef enum tagITEMFLAG
  156. {
  157. kItemFlagUsable = (1 << 0),
  158. kItemFlagEquipable = (1 << 1),
  159. kItemFlagThrowable = (1 << 2),
  160. kItemFlagConsuming = (1 << 3),
  161. kItemFlagApplyToAll = (1 << 4),
  162. kItemFlagSellable = (1 << 5),
  163. kItemFlagEquipableByPlayerRole_First = (1 << 6)
  164. } ITEMFLAG;
  165. // items
  166. typedef struct tagOBJECT_ITEM_DOS
  167. {
  168. WORD wBitmap; // bitmap number in BALL.MKF
  169. WORD wPrice; // price
  170. WORD wScriptOnUse; // script executed when using this item
  171. WORD wScriptOnEquip; // script executed when equipping this item
  172. WORD wScriptOnThrow; // script executed when throwing this item to enemy
  173. WORD wFlags; // flags
  174. } OBJECT_ITEM_DOS;
  175. // items
  176. typedef struct tagOBJECT_ITEM
  177. {
  178. WORD wBitmap; // bitmap number in BALL.MKF
  179. WORD wPrice; // price
  180. WORD wScriptOnUse; // script executed when using this item
  181. WORD wScriptOnEquip; // script executed when equipping this item
  182. WORD wScriptOnThrow; // script executed when throwing this item to enemy
  183. WORD wScriptDesc; // description script
  184. WORD wFlags; // flags
  185. } OBJECT_ITEM;
  186. typedef enum tagMAGICFLAG
  187. {
  188. kMagicFlagUsableOutsideBattle = (1 << 0),
  189. kMagicFlagUsableInBattle = (1 << 1),
  190. kMagicFlagUsableToEnemy = (1 << 3),
  191. kMagicFlagApplyToAll = (1 << 4),
  192. } MAGICFLAG;
  193. // magics
  194. typedef struct tagOBJECT_MAGIC_DOS
  195. {
  196. WORD wMagicNumber; // magic number, according to DATA.MKF #3
  197. WORD wReserved1; // always zero
  198. WORD wScriptOnSuccess; // when magic succeed, execute script from here
  199. WORD wScriptOnUse; // when use this magic, execute script from here
  200. WORD wReserved2; // always zero
  201. WORD wFlags; // flags
  202. } OBJECT_MAGIC_DOS;
  203. // magics
  204. typedef struct tagOBJECT_MAGIC
  205. {
  206. WORD wMagicNumber; // magic number, according to DATA.MKF #3
  207. WORD wReserved1; // always zero
  208. WORD wScriptOnSuccess; // when magic succeed, execute script from here
  209. WORD wScriptOnUse; // when use this magic, execute script from here
  210. WORD wScriptDesc; // description script
  211. WORD wReserved2; // always zero
  212. WORD wFlags; // flags
  213. } OBJECT_MAGIC;
  214. // enemies
  215. typedef struct tagOBJECT_ENEMY
  216. {
  217. WORD wEnemyID; // ID of the enemy, according to DATA.MKF #1.
  218. // Also indicates the bitmap number in ABC.MKF.
  219. WORD wResistanceToSorcery; // resistance to sorcery and poison (0 min, 10 max)
  220. WORD wScriptOnTurnStart; // script executed when turn starts
  221. WORD wScriptOnBattleEnd; // script executed when battle ends
  222. WORD wScriptOnReady; // script executed when the enemy is ready
  223. } OBJECT_ENEMY;
  224. // poisons (scripts executed in each round)
  225. typedef struct tagOBJECT_POISON
  226. {
  227. WORD wPoisonLevel; // level of the poison
  228. WORD wColor; // color of avatars
  229. WORD wPlayerScript; // script executed when player has this poison (per round)
  230. WORD wReserved; // always zero
  231. WORD wEnemyScript; // script executed when enemy has this poison (per round)
  232. } OBJECT_POISON;
  233. typedef union tagOBJECT_DOS
  234. {
  235. WORD rgwData[6];
  236. OBJECT_PLAYER player;
  237. OBJECT_ITEM_DOS item;
  238. OBJECT_MAGIC_DOS magic;
  239. OBJECT_ENEMY enemy;
  240. OBJECT_POISON poison;
  241. } OBJECT_DOS, *LPOBJECT_DOS;
  242. typedef union tagOBJECT
  243. {
  244. WORD rgwData[7];
  245. OBJECT_PLAYER player;
  246. OBJECT_ITEM item;
  247. OBJECT_MAGIC magic;
  248. OBJECT_ENEMY enemy;
  249. OBJECT_POISON poison;
  250. } OBJECT, *LPOBJECT;
  251. typedef struct tagSCRIPTENTRY
  252. {
  253. WORD wOperation; // operation code
  254. WORD rgwOperand[3]; // operands
  255. } SCRIPTENTRY, *LPSCRIPTENTRY;
  256. typedef struct tagINVENTORY
  257. {
  258. WORD wItem; // item object code
  259. USHORT nAmount; // amount of this item
  260. USHORT nAmountInUse; // in-use amount of this item
  261. } INVENTORY, *LPINVENTORY;
  262. typedef struct tagSTORE
  263. {
  264. WORD rgwItems[MAX_STORE_ITEM];
  265. } STORE, *LPSTORE;
  266. typedef struct tagENEMY
  267. {
  268. WORD wIdleFrames; // total number of frames when idle
  269. WORD wMagicFrames; // total number of frames when using magics
  270. WORD wAttackFrames; // total number of frames when doing normal attack
  271. WORD wIdleAnimSpeed; // speed of the animation when idle
  272. WORD wActWaitFrames; // FIXME: ???
  273. WORD wYPosOffset;
  274. WORD wAttackSound; // sound played when this enemy uses normal attack
  275. WORD wActionSound; // FIXME: ???
  276. WORD wMagicSound; // sound played when this enemy uses magic
  277. WORD wDeathSound; // sound played when this enemy dies
  278. WORD wCallSound; // sound played when entering the battle
  279. WORD wHealth; // total HP of the enemy
  280. WORD wExp; // How many EXPs we'll get for beating this enemy
  281. WORD wCash; // how many cashes we'll get for beating this enemy
  282. WORD wLevel; // this enemy's level
  283. WORD wMagic; // this enemy's magic number
  284. WORD wMagicRate; // chance for this enemy to use magic
  285. WORD wAttackEquivItem; // equivalence item of this enemy's normal attack
  286. WORD wAttackEquivItemRate;// chance for equivalence item
  287. WORD wStealItem; // which item we'll get when stealing from this enemy
  288. USHORT nStealItem; // total amount of the items which can be stolen
  289. WORD wAttackStrength; // normal attack strength
  290. WORD wMagicStrength; // magical attack strength
  291. WORD wDefense; // resistance to all kinds of attacking
  292. WORD wDexterity; // dexterity
  293. WORD wFleeRate; // chance for successful fleeing
  294. WORD wPoisonResistance; // resistance to poison
  295. WORD wElemResistance[NUM_MAGIC_ELEMENTAL]; // resistance to elemental magics
  296. WORD wPhysicalResistance; // resistance to physical attack
  297. WORD wDualMove; // whether this enemy can do dual move or not
  298. WORD wCollectValue; // value for collecting this enemy for items
  299. } ENEMY, *LPENEMY;
  300. typedef struct tagENEMYTEAM
  301. {
  302. WORD rgwEnemy[MAX_ENEMIES_IN_TEAM];
  303. } ENEMYTEAM, *LPENEMYTEAM;
  304. typedef WORD PLAYERS[MAX_PLAYER_ROLES];
  305. typedef struct tagPLAYERROLES
  306. {
  307. PLAYERS rgwAvatar; // avatar (shown in status view)
  308. PLAYERS rgwSpriteNumInBattle; // sprite displayed in battle (in F.MKF)
  309. PLAYERS rgwSpriteNum; // sprite displayed in normal scene (in MGO.MKF)
  310. PLAYERS rgwName; // name of player class (in WORD.DAT)
  311. PLAYERS rgwAttackAll; // whether player can attack everyone in a bulk or not
  312. PLAYERS rgwUnknown1; // FIXME: ???
  313. PLAYERS rgwLevel; // level
  314. PLAYERS rgwMaxHP; // maximum HP
  315. PLAYERS rgwMaxMP; // maximum MP
  316. PLAYERS rgwHP; // current HP
  317. PLAYERS rgwMP; // current MP
  318. WORD rgwEquipment[MAX_PLAYER_EQUIPMENTS][MAX_PLAYER_ROLES]; // equipments
  319. PLAYERS rgwAttackStrength; // normal attack strength
  320. PLAYERS rgwMagicStrength; // magical attack strength
  321. PLAYERS rgwDefense; // resistance to all kinds of attacking
  322. PLAYERS rgwDexterity; // dexterity
  323. PLAYERS rgwFleeRate; // chance of successful fleeing
  324. PLAYERS rgwPoisonResistance; // resistance to poison
  325. WORD rgwElementalResistance[NUM_MAGIC_ELEMENTAL][MAX_PLAYER_ROLES]; // resistance to elemental magics
  326. PLAYERS rgwUnknown2; // FIXME: ???
  327. PLAYERS rgwUnknown3; // FIXME: ???
  328. PLAYERS rgwUnknown4; // FIXME: ???
  329. PLAYERS rgwCoveredBy; // who will cover me when I am low of HP or not sane
  330. WORD rgwMagic[MAX_PLAYER_MAGICS][MAX_PLAYER_ROLES]; // magics
  331. PLAYERS rgwWalkFrames; // walk frame (???)
  332. PLAYERS rgwCooperativeMagic; // cooperative magic
  333. PLAYERS rgwUnknown5; // FIXME: ???
  334. PLAYERS rgwUnknown6; // FIXME: ???
  335. PLAYERS rgwDeathSound; // sound played when player dies
  336. PLAYERS rgwAttackSound; // sound played when player attacks
  337. PLAYERS rgwWeaponSound; // weapon sound (???)
  338. PLAYERS rgwCriticalSound; // sound played when player make critical hits
  339. PLAYERS rgwMagicSound; // sound played when player is casting a magic
  340. PLAYERS rgwCoverSound; // sound played when player cover others
  341. PLAYERS rgwDyingSound; // sound played when player is dying
  342. } PLAYERROLES, *LPPLAYERROLES;
  343. typedef enum tagMAGIC_TYPE
  344. {
  345. kMagicTypeNormal = 0,
  346. kMagicTypeAttackAll = 1, // draw the effect on each of the enemies
  347. kMagicTypeAttackWhole = 2, // draw the effect on the whole enemy team
  348. kMagicTypeAttackField = 3, // draw the effect on the battle field
  349. kMagicTypeApplyToPlayer = 4, // the magic is used on one player
  350. kMagicTypeApplyToParty = 5, // the magic is used on the whole party
  351. kMagicTypeTrance = 8, // trance the player
  352. kMagicTypeSummon = 9, // summon
  353. } MAGIC_TYPE;
  354. typedef struct tagMAGIC
  355. {
  356. WORD wEffect; // effect sprite
  357. WORD wType; // type of this magic
  358. WORD wXOffset;
  359. WORD wYOffset;
  360. WORD wSummonEffect; // summon effect sprite (in F.MKF)
  361. WORD wSpeed; // speed of the effect
  362. WORD wKeepEffect; // FIXME: ???
  363. WORD wSoundDelay; // delay of the SFX
  364. WORD wEffectTimes; // total times of effect
  365. WORD wShake; // shake screen
  366. WORD wWave; // wave screen
  367. WORD wUnknown; // FIXME: ???
  368. WORD wCostMP; // MP cost
  369. WORD wBaseDamage; // base damage
  370. WORD wElemental; // elemental (0 = No Elemental, last = poison)
  371. WORD wSound; // sound played when using this magic
  372. } MAGIC, *LPMAGIC;
  373. typedef struct tagBATTLEFIELD
  374. {
  375. WORD wScreenWave; // level of screen waving
  376. SHORT rgsMagicEffect[NUM_MAGIC_ELEMENTAL]; // effect of attributed magics
  377. } BATTLEFIELD, *LPBATTLEFIELD;
  378. // magics learned when level up
  379. typedef struct tagLEVELUPMAGIC
  380. {
  381. WORD wLevel; // level reached
  382. WORD wMagic; // magic learned
  383. } LEVELUPMAGIC, *LPLEVELUPMAGIC;
  384. typedef struct tagLEVELUPMAGIC_ALL
  385. {
  386. LEVELUPMAGIC m[MAX_PLAYABLE_PLAYER_ROLES];
  387. } LEVELUPMAGIC_ALL, *LPLEVELUPMAGIC_ALL;
  388. typedef struct tagPALPOS
  389. {
  390. WORD x;
  391. WORD y;
  392. } PALPOS;
  393. typedef struct tagENEMYPOS
  394. {
  395. PALPOS pos[MAX_ENEMIES_IN_TEAM][MAX_ENEMIES_IN_TEAM];
  396. } ENEMYPOS, *LPENEMYPOS;
  397. // Exp. points needed for the next level
  398. typedef WORD LEVELUPEXP, *LPLEVELUPEXP;
  399. // game data which is available in data files.
  400. typedef struct tagGAMEDATA
  401. {
  402. LPEVENTOBJECT lprgEventObject;
  403. int nEventObject;
  404. SCENE rgScene[MAX_SCENES];
  405. OBJECT rgObject[MAX_OBJECTS];
  406. LPSCRIPTENTRY lprgScriptEntry;
  407. int nScriptEntry;
  408. LPSTORE lprgStore;
  409. int nStore;
  410. LPENEMY lprgEnemy;
  411. int nEnemy;
  412. LPENEMYTEAM lprgEnemyTeam;
  413. int nEnemyTeam;
  414. PLAYERROLES PlayerRoles;
  415. LPMAGIC lprgMagic;
  416. int nMagic;
  417. LPBATTLEFIELD lprgBattleField;
  418. int nBattleField;
  419. LPLEVELUPMAGIC_ALL lprgLevelUpMagic;
  420. int nLevelUpMagic;
  421. ENEMYPOS EnemyPos;
  422. LEVELUPEXP rgLevelUpExp[MAX_LEVELS + 1];
  423. WORD rgwBattleEffectIndex[10][2];
  424. } GAMEDATA, *LPGAMEDATA;
  425. typedef struct tagFILES
  426. {
  427. FILE *fpFBP; // battlefield background images
  428. FILE *fpMGO; // sprites in scenes
  429. FILE *fpBALL; // item bitmaps
  430. FILE *fpDATA; // misc data
  431. FILE *fpF; // player sprites during battle
  432. FILE *fpFIRE; // fire effect sprites
  433. FILE *fpRGM; // character face bitmaps
  434. FILE *fpSSS; // script data
  435. } FILES, *LPFILES;
  436. // player party
  437. typedef struct tagPARTY
  438. {
  439. WORD wPlayerRole; // player role
  440. SHORT x, y; // position
  441. WORD wFrame; // current frame number
  442. WORD wImageOffset; // FIXME: ???
  443. } PARTY, *LPPARTY;
  444. // player trail, used for other party members to follow the main party member
  445. typedef struct tagTRAIL
  446. {
  447. WORD x, y; // position
  448. WORD wDirection; // direction
  449. } TRAIL, *LPTRAIL;
  450. typedef struct tagEXPERIENCE
  451. {
  452. WORD wExp; // current experience points
  453. WORD wReserved;
  454. WORD wLevel; // current level
  455. WORD wCount;
  456. } EXPERIENCE, *LPEXPERIENCE;
  457. typedef struct tagALLEXPERIENCE
  458. {
  459. EXPERIENCE rgPrimaryExp[MAX_PLAYER_ROLES];
  460. EXPERIENCE rgHealthExp[MAX_PLAYER_ROLES];
  461. EXPERIENCE rgMagicExp[MAX_PLAYER_ROLES];
  462. EXPERIENCE rgAttackExp[MAX_PLAYER_ROLES];
  463. EXPERIENCE rgMagicPowerExp[MAX_PLAYER_ROLES];
  464. EXPERIENCE rgDefenseExp[MAX_PLAYER_ROLES];
  465. EXPERIENCE rgDexterityExp[MAX_PLAYER_ROLES];
  466. EXPERIENCE rgFleeExp[MAX_PLAYER_ROLES];
  467. } ALLEXPERIENCE, *LPALLEXPERIENCE;
  468. typedef struct tagPOISONSTATUS
  469. {
  470. WORD wPoisonID; // kind of the poison
  471. WORD wPoisonScript; // script entry
  472. } POISONSTATUS, *LPPOISONSTATUS;
  473. typedef enum tagMUSICTYPE
  474. {
  475. MUSIC_RIX,
  476. MUSIC_MIDI,
  477. MUSIC_MP3,
  478. MUSIC_OGG,
  479. MUSIC_SDLCD
  480. } MUSICTYPE, *LPMUSICTYPE;
  481. typedef enum tagOPLTYPE
  482. {
  483. OPL_DOSBOX_OLD,
  484. OPL_DOSBOX,
  485. OPL_MAME
  486. } OPLTYPE, *LPOPLTYPE;
  487. typedef struct tagGLOBALVARS
  488. {
  489. FILES f;
  490. GAMEDATA g;
  491. int iCurMainMenuItem; // current main menu item number
  492. int iCurSystemMenuItem; // current system menu item number
  493. int iCurInvMenuItem; // current inventory menu item number
  494. int iCurPlayingRNG; // current playing RNG animation
  495. BYTE bCurrentSaveSlot; // current save slot (1-5)
  496. BOOL fInMainGame; // TRUE if in main game
  497. BOOL fGameStart; // TRUE if the has just started
  498. BOOL fEnteringScene; // TRUE if entering a new scene
  499. BOOL fNeedToFadeIn; // TRUE if need to fade in when drawing scene
  500. BOOL fInBattle; // TRUE if in battle
  501. BOOL fAutoBattle; // TRUE if auto-battle
  502. BYTE bBattleSpeed; // Battle Speed (1 = Fastest, 5 = Slowest)
  503. WORD wLastUnequippedItem; // last unequipped item
  504. PLAYERROLES rgEquipmentEffect[MAX_PLAYER_EQUIPMENTS + 1]; // equipment effects
  505. WORD rgPlayerStatus[MAX_PLAYER_ROLES][kStatusAll]; // player status
  506. PAL_POS viewport; // viewport coordination
  507. PAL_POS partyoffset;
  508. WORD wLayer;
  509. WORD wMaxPartyMemberIndex;// max index of members in party (0 to MAX_PLAYERS_IN_PARTY - 1)
  510. PARTY rgParty[MAX_PLAYABLE_PLAYER_ROLES]; // player party
  511. TRAIL rgTrail[MAX_PLAYABLE_PLAYER_ROLES]; // player trail
  512. WORD wPartyDirection; // direction of the party
  513. WORD wNumScene; // current scene number
  514. WORD wNumPalette; // current palette number
  515. BOOL fNightPalette; // TRUE if use the darker night palette
  516. WORD wNumMusic; // current music number
  517. WORD wNumBattleMusic; // current music number in battle
  518. WORD wNumBattleField; // current battle field number
  519. WORD wCollectValue; // value of "collected" items
  520. WORD wScreenWave; // level of screen waving
  521. SHORT sWaveProgression;
  522. WORD wChaseRange;
  523. WORD wChasespeedChangeCycles;
  524. USHORT nFollower;
  525. DWORD dwCash; // amount of cash
  526. ALLEXPERIENCE Exp; // experience status
  527. POISONSTATUS rgPoisonStatus[MAX_POISONS][MAX_PLAYABLE_PLAYER_ROLES]; // poison status
  528. INVENTORY rgInventory[MAX_INVENTORY]; // inventory status
  529. LPWSTR *rgObjectDesc[MAX_OBJECTS];
  530. DWORD dwFrameNum;
  531. } GLOBALVARS, *LPGLOBALVARS;
  532. extern GLOBALVARS * const gpGlobals;
  533. typedef struct tagSCREENLAYOUT
  534. {
  535. PAL_POS EquipImageBox;
  536. PAL_POS EquipRoleListBox;
  537. PAL_POS EquipItemName;
  538. PAL_POS EquipItemAmount;
  539. PAL_POS EquipLabels[MAX_PLAYER_EQUIPMENTS];
  540. PAL_POS EquipNames[MAX_PLAYER_EQUIPMENTS];
  541. PAL_POS EquipStatusLabels[5];
  542. PAL_POS EquipStatusValues[5];
  543. PAL_POS RoleName;
  544. PAL_POS RoleImage;
  545. PAL_POS RoleExpLabel;
  546. PAL_POS RoleLevelLabel;
  547. PAL_POS RoleHPLabel;
  548. PAL_POS RoleMPLabel;
  549. PAL_POS RoleStatusLabels[5];
  550. PAL_POS RoleCurrExp;
  551. PAL_POS RoleNextExp;
  552. PAL_POS RoleExpSlash;
  553. PAL_POS RoleLevel;
  554. PAL_POS RoleCurHP;
  555. PAL_POS RoleMaxHP;
  556. PAL_POS RoleHPSlash;
  557. PAL_POS RoleCurMP;
  558. PAL_POS RoleMaxMP;
  559. PAL_POS RoleMPSlash;
  560. PAL_POS RoleStatusValues[5];
  561. PAL_POS RoleEquipImageBoxes[MAX_PLAYER_EQUIPMENTS];
  562. PAL_POS RoleEquipNames[MAX_PLAYER_EQUIPMENTS];
  563. PAL_POS RolePoisonNames[MAX_POISONS];
  564. } SCREENLAYOUT;
  565. typedef struct tagCONFIGURATION
  566. {
  567. union {
  568. SCREENLAYOUT ScreenLayout;
  569. PAL_POS ScreenLayoutArray[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  570. };
  571. enum {
  572. USE_8x8_FONT = 1,
  573. DISABLE_SHADOW = 2,
  574. } ScreenLayoutFlag[sizeof(SCREENLAYOUT) / sizeof(PAL_POS)];
  575. /* Configurable options */
  576. char *pszMsgName;
  577. char *pszDescFile;
  578. #if USE_RIX_EXTRA_INIT
  579. uint32_t *pExtraFMRegs;
  580. uint8_t *pExtraFMVals;
  581. uint32_t dwExtraLength;
  582. #endif
  583. CODEPAGE iCodePage;
  584. DWORD dwWordLength;
  585. DWORD dwExtraMagicDescLines;
  586. DWORD dwExtraItemDescLines;
  587. DWORD dwScreenWidth;
  588. DWORD dwScreenHeight;
  589. double dSurroundOPLOffset;
  590. INT iAudioChannels;
  591. INT iSampleRate;
  592. INT iOPLSampleRate;
  593. INT iResampleQuality;
  594. INT iVolume;
  595. MUSICTYPE eMusicType;
  596. MUSICTYPE eCDType;
  597. OPLTYPE eOPLType;
  598. WORD wAudioBufferSize;
  599. BOOL fIsWIN95;
  600. BOOL fUseEmbeddedFonts;
  601. BOOL fUseSurroundOPL;
  602. #if SDL_VERSION_ATLEAST(2,0,0)
  603. BOOL fKeepAspectRatio;
  604. #else
  605. BOOL fFullScreen;
  606. #endif
  607. BOOL fEnableJoyStick;
  608. BOOL fUseCustomScreenLayout;
  609. BOOL fIsClassic;
  610. } CONFIGURATION, *LPCONFIGURATION;
  611. extern CONFIGURATION gConfig;
  612. INT
  613. PAL_InitGlobals(
  614. VOID
  615. );
  616. VOID
  617. PAL_FreeGlobals(
  618. VOID
  619. );
  620. VOID
  621. PAL_SaveGame(
  622. LPCSTR szFileName,
  623. WORD wSavedTimes
  624. );
  625. VOID
  626. PAL_InitGameData(
  627. INT iSaveSlot
  628. );
  629. BOOL
  630. PAL_AddItemToInventory(
  631. WORD wObjectID,
  632. INT iNum
  633. );
  634. BOOL
  635. PAL_IncreaseHPMP(
  636. WORD wPlayerRole,
  637. SHORT sHP,
  638. SHORT sMP
  639. );
  640. INT
  641. PAL_GetItemAmount(
  642. WORD wItem
  643. );
  644. VOID
  645. PAL_UpdateEquipments(
  646. VOID
  647. );
  648. VOID
  649. PAL_CompressInventory(
  650. VOID
  651. );
  652. VOID
  653. PAL_RemoveEquipmentEffect(
  654. WORD wPlayerRole,
  655. WORD wEquipPart
  656. );
  657. VOID
  658. PAL_AddPoisonForPlayer(
  659. WORD wPlayerRole,
  660. WORD wPoisonID
  661. );
  662. VOID
  663. PAL_CurePoisonByKind(
  664. WORD wPlayerRole,
  665. WORD wPoisonID
  666. );
  667. VOID
  668. PAL_CurePoisonByLevel(
  669. WORD wPlayerRole,
  670. WORD wMaxLevel
  671. );
  672. BOOL
  673. PAL_IsPlayerPoisonedByLevel(
  674. WORD wPlayerRole,
  675. WORD wMinLevel
  676. );
  677. BOOL
  678. PAL_IsPlayerPoisonedByKind(
  679. WORD wPlayerRole,
  680. WORD wPoisonID
  681. );
  682. WORD
  683. PAL_GetPlayerAttackStrength(
  684. WORD wPlayerRole
  685. );
  686. WORD
  687. PAL_GetPlayerMagicStrength(
  688. WORD wPlayerRole
  689. );
  690. WORD
  691. PAL_GetPlayerDefense(
  692. WORD wPlayerRole
  693. );
  694. WORD
  695. PAL_GetPlayerDexterity(
  696. WORD wPlayerRole
  697. );
  698. WORD
  699. PAL_GetPlayerFleeRate(
  700. WORD wPlayerRole
  701. );
  702. WORD
  703. PAL_GetPlayerPoisonResistance(
  704. WORD wPlayerRole
  705. );
  706. WORD
  707. PAL_GetPlayerElementalResistance(
  708. WORD wPlayerRole,
  709. INT iAttrib
  710. );
  711. WORD
  712. PAL_GetPlayerBattleSprite(
  713. WORD wPlayerRole
  714. );
  715. WORD
  716. PAL_GetPlayerCooperativeMagic(
  717. WORD wPlayerRole
  718. );
  719. BOOL
  720. PAL_PlayerCanAttackAll(
  721. WORD wPlayerRole
  722. );
  723. BOOL
  724. PAL_AddMagic(
  725. WORD wPlayerRole,
  726. WORD wMagic
  727. );
  728. VOID
  729. PAL_RemoveMagic(
  730. WORD wPlayerRole,
  731. WORD wMagic
  732. );
  733. VOID
  734. PAL_SetPlayerStatus(
  735. WORD wPlayerRole,
  736. WORD wStatusID,
  737. WORD wNumRound
  738. );
  739. VOID
  740. PAL_RemovePlayerStatus(
  741. WORD wPlayerRole,
  742. WORD wStatusID
  743. );
  744. VOID
  745. PAL_ClearAllPlayerStatus(
  746. VOID
  747. );
  748. VOID
  749. PAL_PlayerLevelUp(
  750. WORD wPlayerRole,
  751. WORD wNumLevel
  752. );
  753. #ifdef __cplusplus
  754. }
  755. #endif
  756. #endif