home *** CD-ROM | disk | FTP | other *** search
/ Game Programming - All in One (3rd Edition) / game_prog_all_in_one_3rd_ed.iso / software / Mappy / mappyal / READMEAL.TXT < prev    next >
Encoding:
Text File  |  2003-02-01  |  12.2 KB  |  316 lines

  1. MAPPYAL11D
  2.  
  3. DISCLAIMER:
  4.  
  5.  This software and associated files are provided 'as is'
  6. with no warranty or guarantees of any kind, you use them
  7. at your own risk and in doing so agree that the author is
  8. in no way liable and cannot be held responsible for any
  9. loss of time/data/hair or anything else that may occur
  10. either directly or indirectly from the use of this
  11. software or associated files.
  12.  
  13. ==============================================
  14. http://www.tilemap.co.uk
  15. http://www.geocities.com/SiliconValley/Vista/7336/robmpy.htm
  16. email: mappy@tilemap.co.uk
  17.  
  18.  
  19.  
  20. Just double click or run buildal.bat to make the examples using DJGPP (DOS)
  21. or buildalm.bat for Mingw32 (DevC++ counts too) (Windows)
  22. (if you are compiling with Visual C you'll have to do it yourself). 
  23. Use cursor keys to scroll on examples and ESC to exit.
  24.  
  25.  
  26.  
  27. C++ notes: MappyAL will work fine with C++, but the file 'mappyal.c'
  28. must be compiled as 'C'. With MSVC there is no problem as it uses
  29. the filename extension (.c/.cpp) to determine how to compile, but
  30. IDE's like DevC++ and VIDE don't do this with C++ projects, so 
  31. instead of adding mappyal.c to your list of sourcefiles (like with 
  32. MSVC) be sure you have mappyal.o by running 'buildal.bat', or 
  33. manually compiling with:
  34.  
  35. gcc mappyal.c -O2 -Wall -c -o mappyal.o
  36.  
  37. then adding mappyal.o BEFORE -lalleg in the linking options, with
  38. DevC++ select Project:Project options (Alt+P) and click 'Load object
  39. files' and add mappyal.o, now move the -lalleg text so it is after
  40. the object file, it should look something like:
  41. C:\mapalr11\mappyal.o -lalleg
  42. do not add the file mappyal.c to your sourcefile list
  43.  
  44. Please report any bugs!
  45.  
  46.  
  47.  
  48.  
  49.  
  50. Function reference:
  51. -------------------------------------------------
  52. IMPORTANT: You must have set_gfx_mode BEFORE calling these:
  53.  
  54. Note: 'mapname' can be any FMP file, or FMP file in an Allegro datafile
  55. such as "MYMAP.FMP" or "mpgame.dat#GAMEMAP"
  56.  
  57. int MapLoad (char * mapname);
  58.  
  59. Tries to load the .fmp file specified in mapname, eg.
  60. MapLoad ("MYMAP.FMP");
  61. Returns 0 on success, -1 on failure. You need to call this or MapDecode
  62. before using any of the other map functions. This is the same as the
  63. function MapLoadABM.
  64.  
  65. int MapLoadVRAM (char * mapname);
  66.  
  67. Tries to load the .fmp using video bitmaps to take advantage of hardware
  68. acceleration. If it fails, check maperror for the reason. See pbdemo2.c
  69.  
  70. int MapLoadABM (char * mapname);
  71.  
  72. Loads the .fmp with the graphics in Allegro memory BITMAPs, you can then
  73. get at the graphics with the abmTiles array, eg. if you want to get at 
  74. the third BITMAP, use abmTiles[2]. All calls to MapDraw functions will
  75. then use the allegro blit and masked_blit functions.
  76.  
  77. -------------------------------------------------
  78. int MapDecode (unsigned char * mapmempt);
  79.  
  80. Same as MapLoad, but loads from an area of memory containing an FMP file.
  81. (Useful if your maps are stored compressed, just uncompress to memory and
  82. call MapDecode).
  83.  
  84. int MapDecodeVRAM (unsigned char * mapmempt);
  85.  
  86. See MapLoadVRAM
  87.  
  88. int MapDecodeABM (unsigned char * mapmempt);
  89.  
  90. See MapLoadABM
  91. -------------------------------------------------
  92. int MapGenerateYLookup (void);
  93.  
  94. This is optional, call this after MapLoad or MapDecode (or variant) and
  95. it will generate a lookup table that _may_ slightly speed up the functions
  96. MapGetBlock and MapSetBlock, and allows you to use the maparraypt. If you
  97. use this, you _must_ use MapChangeLayer if you want to swap between layers.
  98. Another advantage is you can access block or anim offsets simply with:
  99. maparraypt[y][x];
  100. Where x is the offset from the left in _BLOCKS_, and y is the offset from
  101. the top in _BLOCKS_. Note you can get the actual block structure with the
  102. functions MapGetBlock and MapSetBlock.
  103. The memory allocated is freed when either MapFreeMem is called, or another
  104. map is loaded.
  105.  
  106. -------------------------------------------------
  107. int MapGetBlockID (int blid, int usernum)
  108.  
  109. returns the number of the first block that matches 'blid' in the field 
  110. specified with usernum (1 to 7, user1 to user7). If no match, returns -1
  111.  
  112. -------------------------------------------------
  113. int MapLoadMAR (char * filename, int layer);
  114. int MapDecodeMAR (unsigned char * marmemory, int layer);
  115.  
  116. Loads a .MAR file into a specified layer. Decode does it from memory, 
  117. you can dealloc that memory afterwards. If you called MapGenerateYLookup,
  118. call it again after this function. Returns -1 on error, 0 on success.
  119.  
  120. -------------------------------------------------
  121. int MapChangeLayer (int)
  122.  
  123. This changes to a different map layer, returns -1 if failed, or the new
  124. layer number if success. See mpgame.c
  125.  
  126. -------------------------------------------------
  127. int MapGetXOffset (int x, int y)
  128. int MapGetYOffset (int x, int y)
  129.  
  130. These functions are handy for translating a pixel coordinate to block
  131. coordinates, especially for non-rectangular blocks (see mousecrd.c).
  132.  
  133. -------------------------------------------------
  134. BLKSTR * MapGetBlockInPixels (int x, int y)
  135.  
  136. Returns a BLKSTR pointer, useful for collision detection and examining a
  137. blockstructure. This is more useful on non-rectangular maps as it is pixel
  138. perfect.
  139.  
  140. -------------------------------------------------
  141. BLKSTR * MapGetBlock (int x, int y);
  142.  
  143. Returns a BLKSTR pointer, useful for collision detection and examining a
  144. blockstructure. Note: the x and y paramaters are the offset from the left
  145. and top of the map in _BLOCKS_ NOT pixels. See mpgame.c for an example.
  146.  
  147. -------------------------------------------------
  148. void MapSetBlockInPixels (int x, int y, int strvalue)
  149.  
  150. The x and y paramaters are the offset from the left and top of the map
  151. in pixels. If strvalue is positive, the cell is set to that block structure.
  152. If strvalue is negative the cell is set to that anim structure-1 (ie if
  153. you want to put anim 3 in, strvalue would be -4).
  154.  
  155. -------------------------------------------------
  156. void MapSetBlock (int x, int y, int strvalue);
  157.  
  158. The x and y paramaters are the offset from the left and top of the map
  159. in _BLOCKS_ NOT pixels. See mpgame.c for an example. If strvalue is
  160. positive, the cell is set to that block structure. If strvalue is
  161. negative the cell is set to that anim structure-1 (ie if you want to
  162. put anim 3 in, strvalue would be -4).
  163.  
  164. -------------------------------------------------
  165. void MapRestore (void);
  166.  
  167. Restores the graphics to video bitmaps in hardware rendering.
  168.  
  169. -------------------------------------------------
  170. void MapCorrectColours (void);
  171.  
  172. NOTE: This function is now redundant and does nothing. Maps are
  173. colour corrected on loading.
  174. -------------------------------------------------
  175. void MapSetPal8 (void);
  176.  
  177. Only useful in 8bit (256 colour) mode. Sets the screen palette to the
  178. values contained int the map file.
  179. -------------------------------------------------
  180. void MapFreeMem (void);
  181.  
  182. When you've had enough of the map, this frees all the memory mappypb
  183. has used.
  184. -------------------------------------------------
  185. void MapInitAnims (void);
  186.  
  187. Call to reset the animated blocks to their defaults
  188. -------------------------------------------------
  189. void MapUpdateAnims (void);
  190.  
  191. Animation control. Call from your game loop, moves blocks to next anim
  192. -------------------------------------------------
  193. void MapDrawBG (BITMAP * mapdestpt, int mapxo, int mapyo, int mapx, int mapy,
  194.     int mapw, int maph);
  195.  
  196. Draws the blocks referenced in bgoff. Will clip the map to the specified area.
  197. Note: the normal clipping on the bitmap is ignored, so trying to draw off the
  198. edges of a bitmap will crash your programme.
  199.  
  200. BITMAP * mapdestpt  pointer to a MEMORY bitmap to draw on (not screen)
  201. int mapxo           offset, in pixels, from left edge of map, this is
  202.                     the first visible column of pixels you are drawing
  203. int mapyo           offset, in pixels, from top edge of map, this is
  204.                     the first visible row of pixels you are drawing
  205. int mapx            offset, in pixels, from left edge of bitmap
  206. int mapy            offset, in pixels, from top edge of bitmap
  207. int mapw            width of area you want to draw
  208. int maph            height of area you want to draw
  209. -------------------------------------------------
  210. void MapDrawBGT (BITMAP * mapdestpt, int mapxo, int mapyo, int mapx, int mapy,
  211.     int mapw, int maph, int mapfg);
  212.  
  213. Same as MapDrawBG, except colour 0 pixels are not drawn (8bit), or pink colour
  214. pixels are not drawn (other depths) (transparent).
  215. -------------------------------------------------
  216. void MapDrawFG (BITMAP * mapdestpt, int mapxo, int mapyo, int mapx, int mapy,
  217.     int mapw, int maph, int mapfg);
  218.  
  219. Same as MapDrawBG, except:
  220.  
  221. int mapfg           The foreground layer you want to draw, 0, 1, or 2
  222. -------------------------------------------------
  223. void MapDrawRow (BITMAP * mapdestpt, int mapxo, int mapyo, int mapx, int mapy,
  224.     int mapw, int maph, int maprw, void (*cellcall) (int cx, int cy, int dx, int dy))
  225.  
  226. Same as MapDrawBG, except:
  227.  
  228. int maprw is the row to draw
  229. cellcall is a callback function for each cell, pass NULL if you are doing your
  230. own depth sorting, or using another system
  231. see isodemo.c for an example of this
  232. -------------------------------------------------
  233. BITMAP * MapMakeParallaxBitmap (BITMAP * sourcebm, int style);
  234.  
  235. Only on regular rectangular maps.
  236. Pass a bitmap you would like to use for the parallax bitmap. Paramater 2
  237. is where you want the bitmap created, 0 means it is created with
  238. 'create_bitmap', 1 means it is created with 'create_video_bitmap'. You
  239. must use this function to make the bitmap you pass to MapDrawParallax.
  240. The source bitmap MUST be a multiple of your block size (ie if you are
  241. using 32*32 blocks, 128*128 and 96*64 are valid, but 100*100 is not).
  242. -------------------------------------------------
  243. void MapDrawParallax (BITMAP * mapdestpt, BITMAP * parbm, int mapxo, int mapyo, int mapx, int mapy,
  244.     int mapw, int maph);
  245.  
  246. This behaves like MapDrawBG etc, except the 'parbm' bitmap is created
  247. with 'MapMakeParallaxBitmap' and this is tiled in the transparent
  248. regions of the map. After calling this you should call 'MapDrawBGT'
  249. instead of 'MapDrawBG' so the parallax layer isn't overwritten.
  250. This is more efficient than drawing the whole screen as it only draws
  251. in areas not obscured by higher layers, there is minimal overdraw
  252. (pixels aren't overwritten by higher layers where possible).
  253. See the source 'pbdemo3.c' for an example.
  254. -------------------------------------------------
  255.  
  256.  
  257. Don't forget to look at the example source code, I've documented them.
  258.  
  259.  
  260. Version Changes:
  261. ================
  262.  
  263. MAPPYAL Release11
  264. Slightly improved docs and examples (C++ and datafile notes)
  265. Used good TEST2.FMP map for pbdemo2
  266. 11B: MapDecode fixed, new URL
  267. 11C: MapLoadVRAM fail when out of VRAM bug fixed
  268. 11D: Colours wrong in 32bit screen mode fixed
  269.  
  270. MAPPYAL Release10
  271. Can draw left/right sides of pillars with MapDrawRow by 
  272. checking 2nd or 3rd boxes in 'others' in MappyWin32
  273.  
  274. MAPPYAL Release9 (skipped)
  275.  
  276. MAPPYAL Release8
  277. MapDrawRow function
  278. pageflip fix for pbdemo2.c
  279.  
  280. MAPPYAL Release7
  281. int MapGetBlockID (int blid, int usernum)
  282. int MapLoadMAR (char * filename, int layer);
  283. int MapDecodeMAR (unsigned char * marmemory, int layer);
  284. (the above functions are untested!)
  285. mapblocksinvidmem, mapblocksinsysmem (num blocks in each)
  286. Added cool proja example
  287.  
  288. MAPPYAL Release6
  289. This is a new streamlined version, much smaller but with the same
  290. functionality. Also has full support for FMP1.0 and non-regular
  291. maps (like isometric and hexagonal).
  292. WARNING: The array values have changed! NOT compatible with Mappy tutorial 1!
  293. They are now an index (0,1,2,3 etc) before they were byte offset (0,32,64 etc)
  294.  
  295. MAPPYAL Release5
  296. Changed Win examples to use Allegro rather than WinAlleg
  297. Added define (RBNOCUSTOMRENDER) in mappyal.c to remove a
  298. big code section if you didn't need it
  299.  
  300. ADDED in release4:
  301. Two parallax functions and a demo to show them (pbdemopx)
  302.  
  303. FIXED in release3:
  304. MapDecode functions now work
  305. Added MapLoadABM and MapDecodeABM functions (see below)
  306. Added MapGenerateYLookup function
  307. Added MapChangeLayer function
  308. Added MapGetBlock function
  309. Added MapSetBlock function
  310. Modified mpgame.c to use new functions
  311.  
  312. FIXED in release2:
  313. 16bit maps (colours were loaded wrong, oops)
  314. MapDrawFG when using software render
  315. Transparency colour when loading high colour map to 8bit
  316.