home *** CD-ROM | disk | FTP | other *** search
- Unit GMorph; { Geo Morph }
-
- { GMorph version 1.0 Copyright (C) 1992 Scott D. Ramsay }
-
- { This unit is specifically for Mode 13h (320x200x256). It is a }
- { lot faster than using the BGI drivers (VGA256.BGI). Majority of }
- { the code is written using BASM. This will work on 286 machines or }
- { higher. "I don't know about the P5 chip though." ;) }
- { This unit does tile based maps like the Ultima games, and number- }
- { ous share-ware games. However this unit allows for transparent }
- { tiles, and mutiple background and tile maps as of right now the }
- { tiles can only be 16x16. Resaon being it allows for fast math }
- { just using shifts, for calcuations. Therefore no Longints, or Reals }
- { are used. The code is really, really, really fast for no extra }
- { backgrounds. and not transparent sprite tiles }
- { I don't remember where I heard the term GEOMORPH. Probably on }
- { the net. Anyway it refers to the tile map sprites to create the }
- { illusion of landscapes. This works great for side or top view }
- { multi-scrolling games. Like: Ultima-top view and Super Mario-side. }
- { Next time you look at Mario. Look carefully at the screen. Every- }
- { thing is in blocks. }
- { GMORPH.TPU can be used freely in commerical and non-commerical }
- { programs. As long as you don't give yourself credit for writing }
- { this portion of the code. When distributing it (free only), please }
- { include all files and samples so others may enjoy using the code. }
- { Enjoy. }
-
- { Please bear with my comments. I'm not a tech-writer. You're more }
- { than welcome to modify the comments in this file for people to }
- { understand. }
-
- Interface
-
- type
- Pmorph = ^Tmorph;
- Tmorph = object
- gofsx,gofsy, { geo unaligned offset }
- { gofsx,gofsy = (0,0) if perfect }
- { aligned }
- gv_width,gv_height : byte; { Width and height in Num of geos }
- { to calc, display. }
- { gv_width=0..19 }
- { gv_height=0..11 }
- gmx,gmy, { map dimensions }
- smapx,smapy : integer; { top-left positon to display map }
- { recommend smx = 16..304 }
- { smy = 16..184 }
- { once again, I don't boundry }
- { check (I want speed). The }
- { smaller window allows for drawn }
- { sprites not to exceede page }
- { boundry. sorry no full screen }
- { tile maps. I don't even recall }
- { ever seeing one? }
-
- constructor init(geomx,geomy,gvw,gvh,scrx,scry:integer);
- destructor done; virtual;
- function geomap(x,y:integer):integer;virtual;
- procedure drawmap(vx,vy:integer;var geos);virtual;
- procedure placegeo(x,y,geonum:integer;var geos);virtual;
- procedure pre_map; virtual;
- procedure post_map; virtual;
- end;
-
-
- { See Implementation section for description of functions }
-
- Implementation
-
- Uses VgaKern,MiscFunc;
-
- (***********************************************************************)
- constructor tmorph.init(geomx,geomy,gvw,gvh,scrx,scry:integer);
- { I'll show you this method, It inits values }
- begin
- gmx := geomx; gmy := geomy;
- gv_width := gvw; gv_height := gvh;
- smapx := scrx; smapy := scry;
- end;
-
- (***********************************************************************)
- destructor tmorph.done;
-
- Doesn't do much, cleanup
-
- (***********************************************************************)
- procedure tmorph.pre_map;
-
- Uses this to display, images, backgrounds before map is drawn.
- To give appearance of behind.
-
- Must Overide to use. Does nothing now.
-
- (***********************************************************************)
- procedure tmorph.post_map;
-
- Uses this to display, images, backgrounds after map is drawn.
- To give appearance of infront of map.
-
- Must Overide to use. Does nothing now.
-
- (***********************************************************************)
- procedure tmorph.placegeo(x,y,geonum:integer;var geos);
-
- Places a geo/sprite on the current page at (x,y), geonum
- is the corresponding map number for the specified position.
- (Geos) is the VSP list from Tmorph.DrawMap.
-
- example of PlaceGeo override:
-
- procedure TMyMorph.placegeo(x,y,geonum:integer;var geos);
- var
- vsplist : array[0..16000] of pointer absolute geos;
- begin
- if geonum<>0 { geonum = 0, no geomorph at map location }
- then fbitdraw(x,y,vsplist[geonum-1]^);
-
- - or -
-
- FastWput(x,y,MyVSPlist[geonum]^); { <- fastest geo map }
- end;
-
- { I love using ABSOLUTE, and no-type parameters }
-
- (***********************************************************************)
- function tmorph.geomap(x,y:integer):integer;
-
- Called by tmorph.drawmap.
-
- Override this method to return the map number at (x,y);
-
- example:
-
- var
- MyMap : array[0..ysize,0..xsize] of integer;
-
- function TMyMorph.GeoMap(x,y:integer):integer;
- begin
- GeoMap := MyMap[y,x];
- end;
-
-
- (***********************************************************************)
- procedure tmorph.drawmap(vx,vy:integer;var geos);
-
- The main guts method. Call this to update your map.
- calls: tmorph.pre_map
- tmorph.placegeo
- tmorph.post_map
-
-
- VX,VY : is the user position
- geos : is the VSPlist
-
- note: VX,VY is always center of the display.
-
- (vx,vy) is in actual coordantes.
- For example, if your geomorph map is 100 geos wide and 50 geos
- high, the actual coordante range for VX=0..1600,VY=0..800
- (100*16),(50*16) because each geomorph is is a 16x16 box.
- Using this method panning can be done down to the pixel level.
-
- (***********************************************************************)
-
-
- If you have any problems, e-mail at:
-
- ramsays@express.digex.com
-
- Sorry, I don't have permanent snail-mail address yet. I just moved
- to the Washington DC area.
-
- The TPU units can be used with in your programs. With out giving
- me credit. If you want the source code, more samples or swap-talk,
- just e-mail me. I'll give sample use-code for free. Actual TPU-source
- code prices can be discussed.
-
- Also, I have completed the following programs.
-
- GEOMAKER Makes tile-maps quickly.
- VSPMAKER Makes the VSP files.
- BKMAKER A drawing program that can read
- VEW files (my own raw format)
- PTR files (my own compressed format)
- GIF files
- PCX files
-
- The three above programs are specifically designed for the 320x200x256
- (game development). I'll upload them when I think they are ready
- to go. (Bout a week)
-
- (Artwork samples done by me. Freeware. Knock your-self out.
- Plug. Highly recommended. For game programmers, try to get
- Animator Pro by Autodesk. This is an excellent program for
- imaging, sprites and so forth. Very similar to the Animator,
- but has better graphic features. The 3D models are created
- with 3D studio by Autodesk then ported to Animator Pro, then
- scaled down/converted to my VSP files. If you can blow a
- few thousand bucks, buy the 3D studio. You can do some amazing
- 3D animations. I can't afford it, I use it at work.)
-
-
- Scott D. Ramsay