global.h 27 KB

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