Forums

Sega Master System / Mark III / Game Gear
SG-1000 / SC-3000 / SF-7000 / OMV
Home - Forums - Games - Scans - Maps - Cheats - Credits
Music - Videos - Development - Hacks - Translations - Homebrew

View topic - advanced mathematics for 3d polygons on the SMS

Reply to topic Goto page Previous  1, 2, 3, 4
Author Message
  • Joined: 05 Sep 2013
  • Posts: 3762
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 30, 2022 9:33 am
well, you're lucky anyway there are already three different fp implementations on 16 bit for the Z80, here.

You can do some tests with the one you prefer.

Then remember that computing math is just one part of what's needed, the other (big) part of the work is to draw on screen, you've got to account for some cycles to do that too.

edit: I also found another one here in case anyone needs fp. I have to admit that if the performances stated here are in fact true, this could be pretty interesting (TL;DR - it's just slightly slower than 4.12 fixed point)
  View user's profile Send private message Visit poster's website
  • Site Admin
  • Joined: 19 Oct 1999
  • Posts: 14688
  • Location: London
Reply with quote
Post Posted: Fri Sep 30, 2022 11:15 am
That's a bit annoying/exciting for me as one of my back burner project ideas was to do raytracing and/or Mandelbrot on SMS. Of course, we can do much better than 1bpp graphics.

Being Spectrum-oriented, these libraries may do self-modifying code and may minimise LUT size, which is in opposition to the SMS way of doing things.

It might be interesting to try to support some of these number formats as constants in WLA DX, to avoid things like this:

BALL2C:   DEFW   $3F33,$BF33,$4100   ; 0.6, -0.6, 2
  View user's profile Send private message Visit poster's website
  • Joined: 25 Feb 2006
  • Posts: 863
  • Location: Belo Horizonte, MG, Brazil
Reply with quote
Post Posted: Fri Sep 30, 2022 11:22 am
Maxim wrote
That's a bit annoying/exciting for me as one of my back burner project ideas was to do raytracing and/or Mandelbrot on SMS. Of course, we can do much better than 1bpp graphics.


As long as it's not expected to be real-time, raytracing is doable.
Kinda remembers me of the guys that built a computer inside Minecraft using only Redstone; it is capable of running a Minecraft clone inside Minecraft, but not in real time.
  View user's profile Send private message Visit poster's website
  • Joined: 05 Sep 2013
  • Posts: 3762
  • Location: Stockholm, Sweden
Reply with quote
Post Posted: Fri Sep 30, 2022 11:33 am
Maxim wrote
It might be interesting to try to support some of these number formats as constants in WLA DX


well, if we 'standardize' one float type we could ask for an implementation of .df / .float - but I suspect the issue is in the first part.

edit: or maybe there could be support for different kinds of float and a directive to select the desired kind such as .floatkind <kind> of course one needs to be the 'default' kind when this directive is not specified.

I'm not going to promote this myself though ;)
  View user's profile Send private message Visit poster's website
  • Joined: 31 Dec 2022
  • Posts: 28
Reply with quote
Post Posted: Mon Jan 02, 2023 6:20 pm
Regarding the battle zone ,link posted by segarule above,
sord M5 to master system conversion
that is a impressive looking game (especially since it is restricting
to not using anything more than the TMS9918 mode) but how is it computing and drawing the 3d objects enemies to the screen? Looking at it run in MEKA
I would guess at it is computing the 3D vertexes and lines in real time-but it is probably using a lookup table because computing that many vertex positions using sines or cosines computed in real time on a z80 would likely make the game noticeably slower than it because it 's too many sines or cosines is-it is impressive because it must be cutting up the image into tiles somehow and the game looks good and plays not slow for an 8bit 3D wireframe game.
  View user's profile Send private message
  • Joined: 05 Mar 2022
  • Posts: 129
  • Location: Seabrook, New Hampshire
Reply with quote
advanced mathematics, 3D graphics on SMS
Post Posted: Mon Jan 30, 2023 7:20 am
sverx wrote
Maxim wrote
It might be interesting to try to support some of these number formats as constants in WLA DX


well, if we 'standardize' one float type we could ask for an implementation of .df / .float - but I suspect the issue is in the first part.

edit: or maybe there could be support for different kinds of float and a directive to select the desired kind such as .floatkind <kind> of course one needs to be the 'default' kind when this directive is not specified.

I'm not going to promote this myself though ;)


Thinking outside the box on this (where to place each of an array of sprites), we don't have to have coordinates for every position on a screen. I had thought of a Sprite Track, or every part of the screen where each of those sprites might occur.

So imagine that we have a 64x64 pixel box where the center of each sprite of the stands might be drawn by the VDP. This would be one side of the track or the other in our race track game. The stands might consist of 40-60 sprites that move to the outside as our race car drives past.

For our fixed point number, we have 8-bit numbers in the form of:
123456.78

So each coordinate can subdivide each pixel by four. To get the Index (x-location of box + x-Index of sprite), we would have to round the number off. That's not too difficult if we only round up when the last two bits are one. So:

010101.11
becomes
010110
for the actual x-index, and similarly with the y-index.

Since the earlier proposed sprites look like already perspective-corrected, pre-rendered sprites, we just use the fixed point coordinate system to place them over the top of each other for each frame.

I had earlier conceived of having one program for the straightaways where the emphasis was on the accuracy of the graphics and even streamed a small box of FMV in the upper-center of the screen. By keeping the camera at the middle line of the track, we could use the background tile to draw video, from the game cart, albeit cycling the same frames over and over again to provide the illusion of driving past trees, etc. This would also allow elements like driving past a rotating ferris wheel or other movement in the background.

Then another program for the corners where playability and physics had to take precedence--albeit at the expense of graphic fidelity.

This is the unattainable ideal, in my mind:


Again, the only 16-bit RISC chip available was the 14MHz VDP, and its functionality was limited to drawing sprites over background tiles. At 530,000 instructions per second (give or take on the instruction mix), or 9,000 instructions per frame, we're limited to drawing coordinates, pushing a bit of sound, and polling devices.

Not a machine meant for what I'm trying to do here, but the VDP, Z80, and pre-rendered graphics and FMV on the game cart would make something very cool possible at 30fps.
  View user's profile Send private message
  • Joined: 05 Mar 2022
  • Posts: 129
  • Location: Seabrook, New Hampshire
Reply with quote
advanced mathematics, 3D graphics on SMS
Post Posted: Mon Jan 30, 2023 7:37 am
Or, in a nutshell, the sprites and background tiles would be mostly pre-rendered tiles. The difficulty is figuring out how to place them while also allowing the driver to move around the track. It's not hard to pre-calculate positions and load them into ROM, but the car would be moving to the left and right side of the road, forcing additional computations for sprite placement.

We can't just right-shift everything by a constant when the player moves the car to the left. The amount differs depending on how far down the track the sign/stands/object is and how high it is. So LookUp Tables for a "sprite track" wouldn't be enough. Each sprite used to build an object on one side of the track would require at least two more calculations to get the x- and y-coordinates.

Alternately:
Adventures of Batman & Robin uses horizontal scroll registers which are available on the SMS VDP, and create sidescrolling 3D and parallax effects, but this doesn't have the Wow Factor.


This can also be seen in upsildre's SMS parallax demo.
  View user's profile Send private message
Reply to topic Goto page Previous  1, 2, 3, 4



Back to the top of this page

Back to SMS Power!