global.h 28 KB

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