Jump to content

Photo

raycasting with Dpc+


6 replies to this topic

#1 Trip2018 OFFLINE  

Trip2018

    Star Raider

  • 68 posts
  • young nerd
  • Location:nebraska

Posted Wed Jun 20, 2018 10:20 AM

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



#2 Gemintronic ONLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,955 posts

Posted Wed Jun 20, 2018 2:16 PM

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.



#3 Trip2018 OFFLINE  

Trip2018

    Star Raider

  • Topic Starter
  • 68 posts
  • young nerd
  • Location:nebraska

Posted Thu Jun 21, 2018 11:42 AM

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

Also, I never heard of SpiceC.

#4 Gemintronic ONLINE  

Gemintronic

    Jason S. - Lead Developer & CEO

  • 8,955 posts

Posted Thu Jun 21, 2018 11:48 AM

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.



#5 Trip2018 OFFLINE  

Trip2018

    Star Raider

  • Topic Starter
  • 68 posts
  • young nerd
  • Location:nebraska

Posted Thu Jun 21, 2018 3:39 PM

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)?



#6 ZackAttack OFFLINE  

ZackAttack

    Dragonstomper

  • 715 posts
  • Location:Orlando, FL US

Posted Thu Jun 21, 2018 7:21 PM

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;
}


#7 SpiceWare ONLINE  

SpiceWare

    Draconian

  • 12,270 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Fri Jun 22, 2018 7:30 AM

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.






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users