Jump to content
IGNORED

Raycasting


Asmusr

Recommended Posts

I have been looking into how to implement a raycaster for the F18A GPU since Omega suggested this again the other day. It's definitely something the F18A has the power to do, but as far as I can tell the problem is precision.

 

My starting point was this tutorial, but I find it difficult to fit the calculations into 16 bit. I have implemented the algorithm in Java, and it's working fine with floating point numbers, but when try to change the calculations to use fixed point 16-bit numbers (with 32-bit support for mul and div) I'm getting overflows all the time.

 

I also have the source code for the Wolfie3D raycaster that The Mole made in c. This is working with angles instead of vectors which might be better when you don't have so many bits available. But even though the code is commented I'm not sure how the code is working. Is it something you made yourself is it based on some other work that might have a tutorial?

 

I also tried to make my own algorithm, but, of course, I'm running into all the issues that other people have solved before.

 

So, do you have good references to 8/16-bit code for raycasting?

 

Thanks,

Rasmus

Link to comment
Share on other sites

Wolfie still has a bunch of rounding errors, most noticeable when the occasional gap between wall segments is visible (on corners), and I never really got around to fixing those. One avenue I went down for both speed an accuracy is precalculating look-up tables for all of the trig math.

 

I'm having a hard time remembering exactly, but I believe I mainly relied on two tutorials while developing wolfie. One of them definitely was Lode's raycasting tutorial (the one you linked to in the original post), the other was the almost equally ubiquitous permadi tutorial: http://permadi.com/1996/05/ray-casting-tutorial-table-of-contents/

 

Your second example definitely seems to have the same heritage as wolfie: the algorithm is, at it's core, identical in structure.

Edited by TheMole
Link to comment
Share on other sites

I started by converting Lode's raycaster from c to Java, which I know better. I then wrote a fixed-point library for Java, and made the code run with that. I then went through a lot of pain to make the fixed point calculation work with 16 bits without overflowing too often. I finally converted the Java code to TMS9900/GPU assembly language.

 

It took a lot of debugging, but now I can present this first screen:

 

post-35226-0-53225500-1492296146_thumb.png

 

I only include the code because you cannot move yet, and it's horribly slow - even on the GPU. But I haven't tried to optimize the drawing loop yet. Which is currently done by a call to a procedure using the F18A PIX instruction. I imagine this could be much faster inline.

 

I also want to switch from 256x192 in 4 colors to 128x192 in 16 colors before I try to add textures to the walls.

 

 

 

raycaster.a99

  • Like 8
Link to comment
Share on other sites

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version. And I remember Blake Stone for getting me really motion sick. Suffered a whole afternoon from it. I don't know why it was so bad with this game, but I get that feeling again when I watch your video. OTOH, I can play Skyrim for hours without any problems.

  • Like 2
Link to comment
Share on other sites

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version.

 

You know, I'm up for a little Blake Stone nostalgia. I would not mind a bit if you sent a copy of that via a PM my way... in fact I'd be quite appreciative! :-D I'm thinking it should run under DOSBOX.

Link to comment
Share on other sites

Blake Stone - I've got it still on an archive CD-ROM; I remember those Apogee games you could buy at the supermarket for little money, just a one-level version. And I remember Blake Stone for getting me really motion sick. Suffered a whole afternoon from it. I don't know why it was so bad with this game, but I get that feeling again when I watch your video. OTOH, I can play Skyrim for hours without any problems.

And Duke Nukem, got dizzy a lot. :-D

Link to comment
Share on other sites

 

You know, I'm up for a little Blake Stone nostalgia. I would not mind a bit if you sent a copy of that via a PM my way... in fact I'd be quite appreciative! :-D I'm thinking it should run under DOSBOX.

 

There are lots of abandonware sites where you can download old dos games.

Link to comment
Share on other sites

This is beginning to take shape.

 

It runs more smoothly on real iron than in the video. It seems to run at 60Hz, but only just.

 

I'm using double buffering for the bitmap, and this takes 12 KiB video RAM for half a screen. The 4 bitmaps in 32x32 16 colors take another 2 KiB, so there's only 4 KiB left for the program, the map, and everything else. I don't know if this would be enough for a game.

 

 

 

 

 

 

raycaster80.dsk

F18A Raycaster src.zip

  • Like 7
Link to comment
Share on other sites

This is beginning to take shape.

 

It runs more smoothly on real iron than in the video. It seems to run at 60Hz, but only just.

 

I'm using double buffering for the bitmap, and this takes 12 KiB video RAM for half a screen. The 4 bitmaps in 32x32 16 colors take another 2 KiB, so there's only 4 KiB left for the program, the map, and everything else. I don't know if this would be enough for a game.

 

 

:-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o

Even a PARTIAL Castle Wolfenstein would be a major mind-blower on the TI!!!

:-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o :-o

 

Only 4K left for the program eh? If it's not possible, would you have any objections to SAMS use?

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...