Iím making an ICE raycast engine/game for fun and because I havenít found any other ICE 3D things Very Happy I decided to make a post for it so I can just ask questions here instead of making a bunch of other posts. Iím modeling it pretty close to this (go down to iPhoenixís comment):
https://www.cemetech.net/forum/viewtopic.php?t=9452&view=previous&sid=b6798d59690188fe6aabbb9f068367cd

My first question is how I would do sin in ICE. I need it so I can find how much to increase the rays by (y+sinθ and x+cosθ) In the documentation it says sin( returns root sin? The equation for it is 255*sin(2/256*2*π ) Iím not really sure how that works or what is happening with it at all. How would I get regular sin from it?
Well, the sin() function of ICE return a fixed point number - That is the value of sin multiplied by ~256. That mean that 1.0 =~256, -1.0=~-256.

Since float would be prohibitely slow, integer only computation are much better - you only have to reserve fractionnal bit in your integer to have a fractionnal part (in the sin case, 8 bit are reserved to fractionnal).

Keep in mind that you'll need to take care of possible overflow, and that multiplication of fixed point number is kinda different from multiplying integer since you need to take in account to fractionnal part :

Multipliying two 8.8 fixed point give you a 16.16 fixed point number for example, that you'll need to shift right 8 times to get a 16.8

As for the value inside, it is simply a correspondance between integer and real value, as pi/2 = 64 and so full circle or 2pi is equivalent to 256
Ok that makes sense Smile thanks for helping so fast that was like 1 min haha
The raycast is mostly working except for one part that I donít understand. So I have a list of sin(0), sin(10), sin(20) ... cos(0), cos(10), cos(20) ect. all of these are multiplied by 1,000 and made an int because ICE doesnít work with floats. All of the list stuff works (I tested for a while with everything). I have 4 variables 2 are the real points (testx, testy) they test if there is a wall. the others have the remainder of the sin (remax, remay) As an example: if the angle of the ray is 0 degrees the sin would be 0 (increasing the y by 0) and the cos would be 1 (increasing the x by 1) since everything is times 1,000 it would be remax+1000->remax and remay+0->remay so the ray should not move at all on the y axis. But for me it jumps up and down. If I get rid of the

Code:
If REMAY=<-1000
REMAY+1000→REMAY
TESTY+1→TESTY
End

Everything works perfectly (but if there would be a different angle that would go down, it wouldnít work at all) is there something Iím missing with comparing negative numbers in ICE?

If my explanation wasnít understandable for you, just ask for some more code Razz
IIRC, ICE doesn't have a concept of negative numbers. -1 is treated the same as 16777215, which works fine for addition and multiplication but not comparison. So, in order to compare two numbers which might or might not be negative, you'll have to add some large constant to them.
Wow the raycast part now works 100% Very Happy thatís insane. Also it crazy fast right for what it does even though I havenít optimized at all. Also itís just a bit over 1000 bytes (or whatever it shows in the memory for the ti 84+ CE) now I can start on the actual drawing Laughing
Cool! Do you have any screenshots of it in action?
Itís a bit hard for me to get screenshots because my pc isnít a Mac and I donít feel like using tilp or that stuff for Linux but Iíll be able to get screenshots in a bit (: Also how do you do gif screenshots?
Wut? That won't change anything, you can't screenshot the calc while it's running ASM programs.
The only way would be to screenshot/record CEmu running your program.
Oh Iíll have to try that when I get out of school. That will be really cool if it works.
Before I can get home I have a bunch of free time so I can work on the program a bit. Is there any way to simplify an ICE if statement like in basic? For an example in basic:

Code:
If K=25
D+20→D
End

Optimizes to

Code:
D+20(K=25→D

I already tried to do the exact same thing in ICE but weird things happen
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement