{ SPX Library Version 2.0 Copyright 1993 Scott D. Ramsay } SPX_GEO is the geomorph "tile map" handling unit. It allows you to scroll large maps. The maps are composed of sprites that are aligned next to each other like a tile floor. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ type Pmorph = ^Tmorph; Tmorph = object VARIABLES: gosx,gofsy:byte: Used internally. Indicates the pixel offset of the map; ts:byte: Used internally. Indicates the sprite size of the tiles in shifted bits. ie. 4x4 tile ts=2 8x8 tile ts=3 16x16 tile ts=4 32x32 tile ts=5 gv_width: Width of sprites to display. (in tiles amount); gv_height: Height of sprites to display. (in tiles); gmx,gmy: Width and height of geomorph (in tiles); gsx,gsy: Width and height of tile (in pixels); hvx,hvy: Used internally; = gv_width div 2,gv_height div 2; smapx,smapy: Top-left corner region of geomorph; --------------------------------------------------- constructor Tmorph.init(geomx,geomy,gvw,gvh,scrx,scry:integer); Sets up the object. GEOMX: Width of geomorph (in tiles); GEOMY: Height of geomorph (in tiles); GVW: Width of tiles to display (in tiles); GVH: Height of tiles to display (in tiles); SCRX,SCRY: Top-left corner region of geommorph --------------------------------------------------- destructor Tmorph.done; virtual; Deallocates the object --------------------------------------------------- function Tmorph.geomap(x,y:integer):integer;virtual; Returns the tile number at the (X,Y) coordinate. X,Y: Tile positon of geomorph (in tiles) OVERRIDE: Always --------------------------------------------------- procedure Tmorph.drawmap(vx,vy:integer);virtual; Displays the geomorph on the active page. VX,VY: Center position area of geomorph to display. (in pixels) VX is usually in the range 0..geomorph_width*sprite_width-1 VY is usually in the range 0..geomorph_height*sprite_height-1 NOTES: To use, geomorh tiles width and height must be the same, and must be: 4x4, 8x8, 16x16, 32x32 etc. Change the variable (ts) to reflect sprite size 4x4 tile ts=2 8x8 tile ts=3 16x16 tile ts=4 32x32 tile ts=5 --------------------------------------------------- procedure Tmorph.drawmap_wd(vx,vy:integer);virtual; Same as Tmorph.drawmap. Displays the geomorph on the active page. Faster calcuations than Tmorph.drawmap VX,VY: Center position area of geomorph to display. (in pixels) VX is usually in the range 0..geomorph_width*sprite_width-1 VY is usually in the range 0..geomorph_height*sprite_height-1 NOTES: To use, geomorh tiles width and height must be the same, and must be: 4x4, 8x8, 16x16, 32x32 etc. change the variable (ts) to reflect sprite size 4x4 tile ts=2 8x8 tile ts=3 16x16 tile ts=4 32x32 tile ts=5 --------------------------------------------------- procedure Tmorph.drawmap_n16(vx,vy:integer);virtual; Same as drawmap. Displays the geomorph on the active page VX,VY: Center position area of geomorph to display. (in pixels) VX is usually in the range 0..geomorph_width*sprite_width-1 VY is usually in the range 0..geomorph_height*sprite_height-1 Tiles width and height can be any size Change the variables (gsx),(gsy) to the tile's width and height. --------------------------------------------------- procedure Tmorph.placegeo(x,y,geonum:integer);virtual; Called from Tmorph.drawmap/drawmap_n16. Displays a tile on the screen. X,Y: Top-left position of tile to display; GEONUM: Tile number to display OVERRIDE: Often Usually your override procedure would look something like: procedure TMyMorph.placegeo(x,y,geonum); begin fput(x,y,geo_tiles[geonum]^); end; --------------------------------------------------- procedure Tmorph.placegeo_wd(nd:word;geonum:integer);virtual; Called from Tmorph.drawmap_wd. Displays tile on the screen. ND: Offset of the top-left position of tile to display; GEONUM: Tile number to display OVERRIDE: Often --------------------------------------------------- procedure Tmorph.nogogeo_wd(nd:word);virtual; Called from Tmorph.drawmap_wd. Is called when a tile is out of range. --------------------------------------------------- procedure Tmorph.nogogeo(x,y:integer);virtual; Called from Tmorph.drawmap/drawmap_n16. Is called when a tile is out of range. --------------------------------------------------- procedure Tmorph.pre_map; virtual; Called before each drawing of the geomorph. --------------------------------------------------- procedure Tmorph.post_map; virtual; Called after each drawing of the geomorph. ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ type PHexMorph = ^THexMorph; THexMorph = object(Tmorph) This desendant of Tmorph allows for irregular spacing of the tile map. VARIABLES: oddy,oddx: Sets the (x,y) offset position of the odd columns evenx,eveny: Sets the (x,y) offset position of the even columns By default the above variables are set to zero. (will function like a Tmorph object) ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ function loadGMP(f:string;var piclist,map):integer; Load a .GMP file from disk. F: DOS file name of GMP file to load; PICLIST: Array of pointer to hold the tiles; MAP: Array of byte or word to hold the map Returns the number of tiles in the GMP file. The example below loads a 100,100 GMP file: const gmx = 100; gmy = 100; var geo_tiles : array[1..100] of pointer; MyMap : array[0..gmy-1,0..gmx-1] of byte; geos : integer; begin geos := LoadGMP('MyGMP.GMP',geo_tiles,MyMap); end;