A86: trig in ASM (vectors and raycasting)


[Prev][Next][Index][Thread]

A86: trig in ASM (vectors and raycasting)




I've done some work in BASIC...I've made a raycasting engine that turns a 2-d
matrix (the map) into a 3d world....very, very slowly of course.  I want to
convert this to ASM.  If you want an ASM program to use degrees fast, you need
to make a table of sine and cosine values (sin 1-360 and cos 1-360).

Here's a simple program in BASIC that simply makes a circle by plotting
several points along the rim of the circle:

:Degree
:AxesOff
:ClDrw
:FnOff
:64->X
:32->Y
:For(A,1,360,5)
:X+cos A->X
:Y+sin A->Y
(In Radian mode, use X+cos ((A*[pi])/180)->X and sin Y+((A*[pi])/180)->Y)
:PxOn(iPart Y, iPart X)
:End

You can also change this program to effectively make it plot a
vector....simply find the X and Y displacements based on the angle you want
the ray to go off in, and use a loop to increase the X and Y variables with
the displacement values. (This is used in raycasting engines to record the
distance to the nearest wall based on the player's position.)

I don't have enough knowledge of z80 ASM to know how to convert this to ASM,
but it should be very easy to do...the hardest, most agonizing part is getting
the sin and cos values into tables...I'm make a header file that contains the
tables...so that everyone can just use the #include pre-processor command to
use the tables in their programs....because the table will have 1080 entries
in it, I'll be making a program in C++ that does this for me.  In fact, I
already have this done, but I don't know how to output values to a file.  (In
C++).  If anyone knows how to output text and values to an external file in
C++, PLEASE let me know ASAP!!

I hope that someone out there will use this knowledge to make a doom-style
game...You can find more information on raycasting techniques, drawing walls,
floors, ceilings, texture mapping, variable wall hieght, and anything you ever
wanted to know about raycasting at:

<A HREF="http://www.ben2.ucla.edu/~permadi/raycast/raycidx.html">
http://www.ben2.ucla.edu/~permadi/raycast/raycidx.html</A>

It doesn't contain any code, it's all about concepts, and it EXTREMELY
helpfull.

I REALLY, hope that someone will use this valuable information to make a doom-
style game in ASM for the ti-86..  I'm sure someone will...eventually.

Hope this helps!  I know wish I knew ti-86 ASM better!

-Dave

P.S. -- If someone would like to help me learn ASM, I'd be very grateful!
Thanks.


Follow-Ups: