Kurt_Woloch Posted May 3, 2014 Share Posted May 3, 2014 (edited) In the last days, I've been reading Lou's Pseudo 3D page after reading up on how Sega's sprite-scaling and drawing hardware works. Lou has provided some case studies there, as well as a snippet out of the disassembled code of Enduro. There's also a thread here on Atariage where he discusses with the author of Road Blasters and S.T.U.N. Runner on the Lynx (Solidcorp) how the pseudo 3D on those games works. This made me curious how Pole Position works, especially how it stores the track information and how the curve is calculated out of it. So I went do study its sourde code which has been released some years ago. While searching for this, I also found an old thread about road drawing code where I put up an experiment on the PC drawing a road in pseudo 3D in Pole Position style. Well, I made some progress this morning in finding out how it all works, and while doing so, I kept adding additional comments to the source code because while it does contain some comments, it's far from explaining how everything works, so I had to figure out quite a bit. One thing that occured to me while looking through the code was that the curves never seem to extend all the way down to the player, but keep hovering in a distance from it while the road in front of the player is always straight. I tried to find out what causes this behavior and found that it's no technical reason, but must be some kind of oversight, or maybe a trade-off against something else. Specifically, in the source code, you find two tables SHIFT1 and SHIFT2 which start out with a bunch of zeroes each. For the 3D effect to work properly, these have to be populated differently, otherwise the bend of the curve would have to exceed a certain angle in order to become visible, which never happens in the lower half of the displayed road. Since I found this out, I tried to correct the tables, and this is how this hack comes about. I also amended the MULTIPLY table since it seemed like the road always straightened out near the horizon even if you were in a curve. This, however, wasn't done in the source code, but via a hex editor in the binary file. The source code wasn't changed at all, it only contains many additional comments now. So I've attached the hacked binary as well as the enhanced source code for you. Pole Position Hack.zip Just to visualize what's changed, here's two pictures of roughly the same place on the street, in the middle of the first curve, one with the original version and one with the hack... Before: After: There's more that could be done, but probably not without some serious reprogramming. Enjoy! Kurt Edited May 3, 2014 by Kurt_Woloch 9 1 Quote Link to comment Share on other sites More sharing options...
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.