Jump to content
Sign in to follow this  
Trip2018

raycasting with Dpc+

Recommended Posts

I would like to make a Raycaster for a game i'm working on but all the engines I found didn't work, are in assembly and hard to implement, or just don't suit my needs.

 

Needs:

Interactive sprites that move around the map

doors (windows maybe) and changing walls

on/off toggle to switch between main game and a screen/menu

 

what do you think?

I know how to scale sprites and provide layering.

 

However I'm confused as to how I can accomplish the calculations needed.

 

Thx. :D

Share this post


Link to post
Share on other sites

I know in the standard batari BASIC kernels pfpixel commands are "slow". The 2600 doesn't have a frame-buffer per se to draw those rays. Not sure if those pfixel commands are present/working in DPC+ anyway. You're better off waiting for SpiceC so you can offload the calculations onto the ARM.

Share this post


Link to post
Share on other sites

I think somewhere on RandomTerrain's bB commands page that dpc+ pfpixel has three arguments, y, x1, x2.

 

Also, I never heard of SpiceC.

Share this post


Link to post
Share on other sites

I think somewhere on RandomTerrain's bB commands page that dpc+ pfpixel has three arguments, y, x1, x2.

 

Also, I never heard of SpiceC.

 

SpiceC is an upcoming C compiler for DPC+. Not out yet.

 

If pfpixel works for DPC+ then, well.. there you go! I'd start testing out using that command to plot pixels where you hit a ray.

 

My hunch is that you need to resort to straight assembly. There's a game called Merlin's Walls that just barely does it.. and, it has to do it sideways.

Share this post


Link to post
Share on other sites

First:

I think somewhere on RandomTerrain's bB commands page that dpc+ pfpixel has three arguments, y, x1, x2.

I meant x, y1, y2 :P

Second:

I'm taking some info from this and this

Both require trigonometry and square roots. Is that even achievable in bB (or the 2600 in general)?

Share this post


Link to post
Share on other sites

Both require trigonometry and square roots. Is that even achievable in bB (or the 2600 in general)?

I was playing around with ray casting the other day. The algorithm I used was based on this article. The equation with sqrt is simplified so that sqrt is not actually required.

 

For sin() I just created a lookup table with 128 elements. This is easier than using radians or degrees because a simple bitwise and with $7F will always convert an angle to the proper range. cos() can be accomplished with the same table. You just have to offset by 1/4 rotation before anding with $7F.

vec2 rotate(int direction, vec2 vec)
{
	f32 s = SineLookup[direction & 0x7f];
	f32 c = SineLookup[((direction + 32) & 0x7f)];

	vec2 v =
	{
		F32Add(F32Mul(c, vec.x), F32Mul(s, vec.y)),
		F32Add(F32Mul(F32Mul(F32(-1), s), vec.x), F32Mul(c, vec.y))
	};
	return v;
}

Share this post


Link to post
Share on other sites

SpiceC is an upcoming C compiler for DPC+. Not out yet.

Close, for CDF not DPC+ :)

 

Also, I never heard of SpiceC.

 

If you might be interested then follow my blog series on SpiceC. There's just a few entries so far as RL intervened - we learned another definition for TIA (dad's doing much better now) and took a vacation for a road trip to Wisconsin. I'll be returning to work on SpiceC next month.

  • Like 5

Share this post


Link to post
Share on other sites

[NON PROGRAMMER TAKING HERE] you know for the amount of raycasting games on the vcs , im suprised we havent yet had a port of 'doom' or the doom-style, as opposed to simple maze style games- recently i got a rom off here that is similar to a doom style game, but with a smaller portion of the screen for viewing, while the rest of the screen is for other things, it looks pretty good though. but i mean what about a full screen raycasting shooter---

Share this post


Link to post
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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...