#39150 - LOst? - Tue Apr 05, 2005 5:34 am
For you people that underastand Outrun game technology, and how to make it come true by using fixed point math, a little help would be nice.
It doesn't matter how much I debug the game, there is a pre-calced table with values it seems to use. Now how do I get from here to there?
Look at this picture I drew so nicely for you:
[Images not permitted - Click here to view it]
What you see is a map on the left, and the display output on the right.
p1 and p2 are simply relative coordinates on the map which is used to get the distance in between them. I get it by doing this:
p2 - p1 = pixel distance
The result is then divided by the distance I want it to be drawn on the display... right?
Let's take a sample. Say p1 = 10 and p2 = 80:
80 - 10 = 70
And the draw distance is 128:
70 / 128 = 0.546875
So the concept is easy, I move the map vertically with the speed of 0.546875 during HBlank. Easy! Well, no. Because how much I try to convert that value into fixed point I fail.
First off, I usually use 8 bits for the decimal point... But maybe that's the problem? Hell I have no idea how to even convert this thing to fixed point. What's the secret? Just a wild guess here:
0.546875 * 256 = 140
140 * 128 = 0x4600 which is 70.0
Why does it work now? Crap >.<;;
Anyway, I need help. I was just lucky this time. Next time I will get into problems so tell me how this should be done from your point of view.
It doesn't matter how much I debug the game, there is a pre-calced table with values it seems to use. Now how do I get from here to there?
Look at this picture I drew so nicely for you:
[Images not permitted - Click here to view it]
What you see is a map on the left, and the display output on the right.
p1 and p2 are simply relative coordinates on the map which is used to get the distance in between them. I get it by doing this:
p2 - p1 = pixel distance
The result is then divided by the distance I want it to be drawn on the display... right?
Let's take a sample. Say p1 = 10 and p2 = 80:
80 - 10 = 70
And the draw distance is 128:
70 / 128 = 0.546875
So the concept is easy, I move the map vertically with the speed of 0.546875 during HBlank. Easy! Well, no. Because how much I try to convert that value into fixed point I fail.
First off, I usually use 8 bits for the decimal point... But maybe that's the problem? Hell I have no idea how to even convert this thing to fixed point. What's the secret? Just a wild guess here:
0.546875 * 256 = 140
140 * 128 = 0x4600 which is 70.0
Why does it work now? Crap >.<;;
Anyway, I need help. I was just lucky this time. Next time I will get into problems so tell me how this should be done from your point of view.