Generic Maze Program Example 1
- From: Tim Trussell <tgtrussell@xxxxxxxxxxx>
- Date: Sun, 27 Sep 2009 16:09:50 -0700 (PDT)
---[ Generic Maze Program Example 1 ]-----------------[09/27/2009]---
by Timothy Trussell
---------------------------------------------------------------------
---[Note]------------------------------------------------------------
This code is meant for use with the 32Forth system.
This is the DOS DPMI version of the compiler in Rick van Norman's
OS2FORTH.ZIP package, available on the Taygeta Scientific site:
ftp://ftp.taygeta.com/pub/Forth/Compilers/native/OS-2/os2forth.zip
--------------------------------------------------------[End Note]---
I came across this code when I was examining different methods of
trying to display polygons using different methods. In this case, it
was the concept of Ray Tracing that I was looking into, and things
like the painters algorithm, which led into looking at things like
Wolfenstein3D and DOOM.
The original code for this was done by Larry Myers, who had posted it
looking for help on problems he was encountering with his code. He
called it his "Wolf-3D Generic engine", and after looking at it, you
will agree that it's pretty generic.
This is simply a straightforward conversion, to allow me to look at
some of the different aspects of the code. It is NOT expected to be
fully functional, let alone without bugs or other problems, and the
things that Larry was looking for help with are (I expect) still in
place, waiting for some help.
There are any number of changes that would need to be effected to let
this code become useable for anything beyond what it currently does.
At the moment, it's depressingly slow. Really. Normally, I have to
put into place calls to a wait-for-retrace routine to intentionally
slow down the animation speeds to let them be viewed at a proper rate
but not this little gem.
I have to attribute part of this this to a bottleneck in the fill
routine that Larry used. It appears that his fill routine goes from
left to the right, filling each "polygon" with vertical lines.
I might get adventuresome and recode those for use with a polygon
fill routine that should be a bit more efficient.
On line 387, I have a conditional compilation flag for selecting
the use of a Floating Point processor call to perform a Square
Root calculation (if set to 1 [IF]), or the use of a FORTH code
version (if set to 0 [IF]). Try both, recompiling for each, to
see the difference in speed. To actually see the speed change,
press the #5 key on the numeric keypad.
There are only three assembly routines in this code - the two for
drawing Horizontal and Vertical lines, and the one that blits the
double buffer to the video display screen.
Frankly, the compiled .EXE file that Larry provided runs very much
faster and smoother than my code, though the smoothness may be
because I don't play around with intercepting and recoding the
keyboard interrupt vectors, so the entry of direction commands are
delayed by the BIOS.
In fact, I included a bit of code so that if you press the #5 key
on the numeric keypad the program will do a circle to the left for
a number of calls (6400 actually) to the turn-left function. In this
instance, the program runs pretty smoothly (but still not blazing).
I have some code examples that do more than this, and include the
use of textured fills, and go way too fast for viewing.
The key commands are:
Keyboard control:
Esc - Exits program
Right - Turns right 4 degrees
Left - Turns left 4 degrees
Up - Moves forward 2 units
Home - Moves forward 128 units
PgUp - Moves forward 20 units
End - Moves backwards 128 units
PgDn - Moves backwards 20 units
Center - Spins the viewpoint clockwise with no
input delays
all using the numeric keypad - so ensure you have the NumLock on, as
I am looking for the NUMBERS on the keypad, 1..9.
---[Finishing Up]----------------------------------------------------
So, this represents a stepping stone in learning something more about
graphics that can be done.
------------------------------------------------------[End Maze 1]---
.
- Prev by Date: Re: If you write code, read this.
- Next by Date: Generic Maze Program Code Addendum 1
- Previous by thread: AMPLE ( Programming music in FORTH) ?
- Next by thread: Generic Maze Program Code Addendum 1
- Index(es):
Relevant Pages
|
Loading