Written by Coelurus   http://seawasp.hjorten.nu/~coelurus
                      thorntwig@telia.com


         RAYCASTING EXAMPLE
        ====================

My first asm-program on TI-calculators (on ANY equipment) really... Hehe,
an advanced math-based game. Strange, but that's the way I am...
Just a funny project I had in mind:

        Make a simplified Wolfenstein-style game for
        TI83/TI83 PLUS calculators!

Note that this is still a demo. You can just walk around. The graphics is
poor, but you just might see the wall-like contours...

You are free to make whatever you want with it. Remember, if you use my code,
I don't mind if you give me some credit...


Files:
------
raycast.txt     This info file

raycast.83p     TI83 file to download
raycast.8xp     TI83+ file to download

raycast.z80     Sourcecode
extras.inc      Include file with keycodes (you need ion.inc too!)


Requirements:
-------------
TI83(+)
ION


Install:
--------
Install ION and run it. Run "A" and then "Raycast demo!".


Run:
----

How do you run it? Well, just walk around with your arrow keys. To sidestep,
press [Y=] or [WINDOW]. To get out of it, press [DEL]. That's all!


         Description
        =============

I'm sure some of you want to know how this program works. Just to be nice,
I brought you the entire sourcecode. All in asm, just to get the speed!

Let's break down the name, raycast. We get "ray" and "cast". Things start to
get clear. What we do is cast rays in front of the player. When a ray hits a
wall, we draw the wall section:

         _________  Walls
        |\   |
        |  \  |
        |-__ \ |
        |   -- * player
        |

        Walls

The middle line is the direction of the player, the other mark the FOV
(Field Of View). Pseudo-code:

        copy player direction to ray angle
        angle - 48 (FOV / 2), so that we start from one side of the display

        for column = 0 to 95
                copy player location to ray location
                get stepping variables from angle

                repeat
                        update ray location with stepping variables
                until a wall is hit

                calculate wall height depending on distance

                draw wall section at column

                increase angle
        end for

I've tweaked my code a bit. I store all distances in a Z buffer. After all
rays have been casted, I draw the walls. This will make implementing sprites
etc easier.

This is the simpliest and worst way to make raycasting, but it works well.
If you wanna learn real raycasting, try get another doc on it, I don't
explain it very well in here. Go to my homepage (address always found at top
of file) and get full explanation, complete djgpp c-sourcecode etc.

TODO:
For you who want to improve my code, here are some tips:

Optimize the code
        A lot of calls made, why not remove 'em?
Make a fast fisheye removal
        Tried it, was too slow so I skipped it in this demo.
Use a better-looking technique
        Tried the Wolfenstein-technique, needed greater registers.
Add more features
        Missions, enemies, weapons etc. My future work.
Level editor
        Level-loading would be nice too...
Multi-player?

If you've got some info on this, but don't want to program it in, why not
give me an E-Mail?
