UNIV.H 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 RWS Inc, All Rights Reserved
  4. //
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of version 2 of the GNU General Public License as published by
  7. // the Free Software Foundation
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License along
  15. // with this program; if not, write to the Free Software Foundation, Inc.,
  16. // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. //
  18. //*****************************************************************************
  19. //
  20. // UNIV.H
  21. //
  22. //*****************************************************************************
  23. #ifndef _UNIV_H
  24. #define _UNIV_H
  25. #include "ANIMDATA.H"
  26. #include "PAL.H"
  27. #include "System.h"
  28. #include "BG.H"
  29. #include "ZONE.H"
  30. #include "event.h"
  31. #include "attrib.h"
  32. #define VERTICAL 0
  33. #define HORIZONTAL 1
  34. #define UNIVERSE_CANT_OPEN_FILE 1
  35. #define UNIVERSE_INVALID_WORLD 2
  36. #define UNIVERSE_INVALID_STAGE 3
  37. #define UNIVERSE_INVALID_SECTION 4
  38. #define UNIVERSE_OFFSET_ERROR 5
  39. #define UNIVERSE_INVALID_LEVEL 6
  40. #define UNIVERSE_WRONG_FILETYPE 7
  41. #define UNIVERSE_MAX_FILENAME 32
  42. #define UNIVERSE_MAX_PATHNAME 512
  43. #define UNIVERSE_MAXSTAGES 5
  44. #define UNIVERSE_MAXWORLDS 5
  45. #define UNIVERSE_MAXSECTIONS 10
  46. #define UNIVERSE_MAXLINE 80
  47. typedef short ORIENT;
  48. // Section Structure. This structure contains the actual data that is
  49. // needed to load animations and backgrounds for a particular level. All
  50. // of the other levels are indirection only and are used mainly for logical
  51. // grouping of the levels. This structure contains pointers to the other
  52. // pieces of data including palettes, animations, backgrounds, and events
  53. // along with some size information.
  54. // Here is a sample of the section data in the file
  55. //stage0sect0
  56. // da sprite_pal ;sprite palette
  57. // da monday_anim_set_bld ;sprite build data
  58. // da monday_pal ;background palette
  59. // da meal_bg_set_bld ;background build data
  60. // dw 0 ;bg1 orientation
  61. // dw 1792 ;bg1 width in pixels
  62. // dw 256 ;bg1 height in pixels
  63. // dw 256 ;bg1 horizontal motion ratio*256
  64. // dw 256 ;bg1 vertical motion ratio*256
  65. // dw 2 ;bg1 unit number
  66. // da bg_unit0_attribute ;bg1 unit attribute table
  67. // da brk1_evt ;bg1 event data
  68. typedef struct tag_SECTION
  69. {
  70. PALETTE* pSpritePal; // sprite palette
  71. ANIM* pAnimBuildSet; // animation data
  72. PALETTE* pBackgroundPal; // background palette
  73. BG* pBackgroundBuildSet; // background data
  74. ORIENT orBGOrientation; // vertical or horizontal world flag
  75. short sBGWidth; // background width in pixels
  76. short sBGHeight; // background height in pixels
  77. short sBGHorzMotionRatio; // background horizontal motion ratio*256
  78. short sBGVertMotionRatio; // background vertical motion ratio*256
  79. ATTRIB* pAttribute; // background attribute data
  80. EVENT* pEvent; // background event data
  81. } SECTION;
  82. // Stage Structure. The first word in the struct gives the number of
  83. // sections in the stage. File pointer offsets to each section follow which
  84. // will be resolved to pointers when the data is loaded
  85. // Here is a sample from the file
  86. //stage0
  87. // dw 1
  88. // da stage0sect0
  89. typedef struct tag_STAGE
  90. {
  91. short sNumSections; // Number of sections in this stage
  92. SECTION* apSections[UNIVERSE_MAXSECTIONS];// SECTION's (max set by linker)
  93. } STAGE;
  94. // World Structure. The first word in the struct gives the number of stages
  95. // in this world. File pointer offsets to each stage follow which will
  96. // be resolved to pointers when the data is loaded.
  97. // Here is a sample from the file
  98. //World0
  99. // dw 3
  100. // da stage0
  101. // da stage1
  102. // da stage2
  103. typedef struct tag_WORLD
  104. {
  105. short sNumStages; // Number of stages in this world
  106. STAGE* apStages[UNIVERSE_MAXSTAGES];// STAGE's (max set by linker)
  107. } WORLD;
  108. // Universe Structure. The first word in the struct gives the number of
  109. // worlds in the game, file pointer offsets to each world follow which
  110. // will be resolved to pointers when the data is loaded in.
  111. // Here is a sample from the file
  112. //Universe
  113. // dw 2
  114. // da world0
  115. // da world1
  116. typedef struct tag_UNIVERSE
  117. {
  118. short sNumWorlds; // Number of worlds in the game
  119. WORLD* apWorlds[UNIVERSE_MAXWORLDS];// WORLD's (max set by linker)
  120. } UNIVERSE;
  121. class CUniverse
  122. {
  123. private:
  124. char m_strFileGame[UNIVERSE_MAX_FILENAME]; // Game Info data file
  125. char m_strFileAnim[UNIVERSE_MAX_FILENAME]; // Animation build data
  126. char m_strFileImage[UNIVERSE_MAX_FILENAME]; // Animation Images
  127. char m_strFileZone[UNIVERSE_MAX_FILENAME]; // Zoneset data
  128. char m_strFileBack[UNIVERSE_MAX_FILENAME]; // Background build data
  129. char m_strFileAPal[UNIVERSE_MAX_FILENAME]; // Animation Palette
  130. char m_strFileBPal[UNIVERSE_MAX_FILENAME]; // Background Palette
  131. char m_strFileAttr[UNIVERSE_MAX_FILENAME]; // Background Attribute data
  132. char m_strFileEvent[UNIVERSE_MAX_FILENAME]; // Background Event data
  133. char m_strDataPath[UNIVERSE_MAX_PATHNAME]; // Base path for all data files
  134. short LoadAnimData(); // private function to load animation file
  135. short LoadBackgroundData();// private function to load background file
  136. short LoadAttributeData(); // private function to load attribute file
  137. short LoadEventData(); // private function to load event file
  138. PALETTE* LoadPalette(LPSTR);//private function to load anim/bg palette
  139. void SetAnimOffsets(ANIM*);// resolve Anim offset to pointers
  140. void SetZonesetOffsets(ZONESET*); // resolve Zoneset offsets to pointers
  141. protected:
  142. WORLD* m_pWorld; // ??
  143. STAGE* m_pStage; // ??
  144. SECTION* m_pSection; // ??Pointer to the current section structure
  145. ANIMSET* m_pAnimData; // Pointer to Animation build data
  146. BG* m_pBackData; // Pointer to Background build data
  147. PALETTE* m_pSpritePal; // Pointer to sprite palette
  148. PALETTE* m_pBackgroundPal; // Pointer to background palette
  149. WORD* m_pAttrMap; // Pointer to background attribute map
  150. short m_sMapWidth; // Width of attribute map
  151. CONTOUR* m_pAttrCont; // Pointer to arrays of attribute contours
  152. EVENT* m_pEventData; // Pointer to background event data
  153. IMAGE* m_pImageData; // Pointer to animation images
  154. public:
  155. CUniverse();
  156. ~CUniverse();
  157. // This function loads in a SECTION structure from the game info file.
  158. // Once this function has been called, other modules such as Anim can
  159. // call the other member access function to get pointers to the data.
  160. short SetSection( // Load a section structure from file to memory
  161. short sWorld, // World number
  162. short sStage, // Stage number
  163. short sSection // Section number
  164. );
  165. // These access functions return pointers to various parts of the
  166. // SECTION structure.
  167. ANIMSET* GetAnim() {return m_pAnimData;};
  168. BG* GetBG() {return m_pBackData;}; // Background data
  169. PALETTE* GetAnimPal() {return m_pSpritePal;}; // Animation palette
  170. PALETTE* GetBGPal() {return m_pBackgroundPal;}; // Background palette
  171. EVENT* GetEvents() {return m_pEventData;}; // Event data
  172. void GetAttributes(WORD* pwMap, // Attribute data
  173. CONTOUR* pContour,
  174. short* psWidth)
  175. {
  176. pwMap = m_pAttrMap;
  177. pContour = (CONTOUR*) m_pAttrCont;
  178. *psWidth = m_sMapWidth;
  179. };
  180. };
  181. #endif //_UNIV_H
  182. //*****************************************************************************
  183. // EOF
  184. //*****************************************************************************