Code: Select all
;//Routines for tilemapping, by Patori
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Before doing anything, I think that it'd be best to plan
;ahead. hehehe. So anyways, I believe I should discuss the
;program structure, nyo? Ok:
;
;
; char 'F','L','C','L'
; byte width,height
; byte DATA --------------->
; ------------------------->
; ------------------------->
; End, no need for termination bytes, that'd be a waste.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; ///Anyways, the way that the tilemapper would work (or, simply put, it's Algorithm) would be as follows, in poorly written C:
;
; Variables:
; width = the map's width
; height = the map's height
; xentry = xposition to draw from
; yentry = yposition to draw from
; bytetostart = pointer to where to start drawing from
; MAR = Random Access Memory (Level data)
; tempy = temporary y value
; function drawsprite(x pos, y pos, sprite num) = self explanitory
;
; int tileMap(int width, int height,int xentry, int yentry)
; {
; //To calculate the max y.... height-4
; int bytetostart;
; if (yentry > (height-4))
; {
; tempy = height-4;
; }
; else
; {
; tempy = yentry;
; }
; if (yentry < 0)
; {
; yentry = 0;
; }
; if (xentry < 0)
; {
; bytetostart = (yentry*width);
; }
; if (xentry > (width-4))
; {
; bytetostart = (yentry*width) + (width-4);
; }
; if ((xentry < (width-4)) && (xentry > 0))
; {
; bytetostart = (yentry*width) + width;
; }
; //We are pretending that the RAM is a big array called MAR...
; //FIX THIS
; for (int y = 0; y < 4; y++)
; for (int x = 0; x < 4; x++)
; drawSprite((x*16),(y*16),MAR[bytetostart+(y*height)+x]);
; return 0;
; }
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; In theory, (at least in my theory) this will work. I had to re-re-re-code this like 5 or 6 times.
; Pretty much cuz I was an idiot and didn't think to check X Positions or Y Positions... ^*^. I'll let
;Maxcoderz look over it before I convert it into ASM. BTW, units are gonna be loaded in a completely different
;way, they start off as arrays of data structures that will be loaded, and checked for relevence with the current
;viewpoint that is being displayed.
;Well, I'm gonna be really proud if this works :-D
;Looking over this code, I realize that it will take forever, and at least 1-2kb to code this in ASM. *gulp*.
;I WILL FINISH THIS FOR TICALC.ORG POTY 2005.
;
;Maxcoderz people (wow! I'm one of these elitists! yay!): I'm sorry that I have not shown any real work as of late,
;my home life has went down a toilet. We cannot afford internet, my dad looks for scrap steel for a living, and
;I cannot graduate until I can come up with $1.7k for tuition. (To go to this school, costs $7k, I have scholarship for $5k)
;I've been looking for a job as of late, and even when I get one it will be difficult to save up money for internet
;(I need a phone line turned back on first), and I will likely not have much free time when I work. I'm not asking for pity,
; I'm begging for patience and understanding. My life sucks. lol. I'd happy with it though... not really... *goes back to
;being a goth at home*
;
; "It's hard to be a goth when you are an optimist" - A teacher of mine, to me... :-S
;
; my life may turn around. Mrs. Sinha (Java teacher) spoke of a Database developing job over the summer, and I'm filling out
; tons of apps at various places by my school.
Do you think this code'll work? Ideas please?