
Pushing Polygons on the Mega Drive - jix
https://jix.one/pushing-polygons-on-the-mega-drive/
======
mambodog
The use of vector graphics instead of 3d rendering or bitmap video seems
reminiscent of the techniques which allowed Another World to achieve the
fidelity it did on the consoles of that era:
[https://www.youtube.com/watch?v=X7GVubkh4TE](https://www.youtube.com/watch?v=X7GVubkh4TE)

Tech overview:
[http://fabiensanglard.net/anotherWorld_code_review/](http://fabiensanglard.net/anotherWorld_code_review/)

~~~
JohnBooty
Hahaha. I came here to post this. The intro to Flashback (same team) uses a
similar strategy and I think is maybe even a little more impressive.

[https://www.youtube.com/watch?v=ClBaKXB2KqE](https://www.youtube.com/watch?v=ClBaKXB2KqE)

~~~
krige
Actually not the same team, just the same publisher that capitalized on AW's
success. Eric Chahi himself, the one-man-army responsible for Another World,
only did Heart of Darkness afterwards.

~~~
agumonkey
When you think Chahi basically developped its own little flash framework 15
year prior on a crippled system, all for its own game. Madness.

~~~
vanderZwan
Not uncommon at the time though - Jordan Mechner did something similar. His
journals are absolute treasures, by the way:

[http://www.jordanmechner.com/backstage/journals/](http://www.jordanmechner.com/backstage/journals/)

EDIT: Well, maybe I speak too soon. Chahi and Mechner don't exactly represent
the average developer - they both are polymaths and were capable of combining
their broad interests in amazing and creative ways.

~~~
agumonkey
They seem to have that non specific problem solving skills.

------
niftich
The imprecise overruns because you'll draw over it is a clever optimization.

It's interesting to compare and contrast these techniques from other excellent
sources, like _Michael Abrash 's Graphics Programming Black Book, Special
Edition_ [1].

Thought my technical knowledge topped out somewhere in the middle of the
'Quickly Drawing Tiles' section, the prose and algorithmic detail is lovely,
the rationales and code is welcome, and the visualization is excellent.

[1] [http://www.jagregory.com/abrash-black-book/#chapter-40-of-
so...](http://www.jagregory.com/abrash-black-book/#chapter-40-of-songs-taxes-
and-the-simplicity-of-complex-polygons)

~~~
zeta0134
Quickly drawing tiles is one of those sections that's really only going to
make sense if you've ever done development work on a tile-mapped videogame
console, as the mode is quite rare in other applications.

A "tile" is nothing more than an index into a collection of 8x8 graphics
squares. If you've played any retro-styled games you've seen the effects of
this. They were a great way to deal with memory constraints back in the day,
as you reduce 64 pixels worth of on-screen data to a small handful of bytes,
describing the index of the tile, and often other attributes like the palette
to use, or whether to mirror the tile in a given direction.

Since the Mega Drive can _only_ draw tile-mapped graphics, and has no direct
bitmap modes, it makes sense for the rasterization engine in this demo to take
full advantage of the hardware. When he talks about drawing an entire 8x8 tile
with a one-word write, he means quickly setting the index in this way.
Somewhere in memory, he's created 16 solid-color 8x8 tiles, one for each of
the palette colors. Then, if any group of 8x8 pixels in a row would be the
same color and they're aligned with one of the tiles, he can just point that
tile at one of this solid-color indices, and move on. Part of the magic of his
algorithm is quickly identifying (in advance) which tiles the megadrive can be
quickly drawn with this technique, and which tiles (at polygon edges) need to
be drawn more slowly in software.

~~~
derefr
Hey now, your average IBM PC has a tile-mapped display mode, too: we just
usually call it "text", and the tiles "characters". :)

But the text-mode 'font' (i.e. the tileset) was often able to be written to,
to achieve fast arbitrary-tile drawing results exactly like those of your
average game console.

[https://en.wikipedia.org/wiki/Text_mode#User-
defined_charact...](https://en.wikipedia.org/wiki/Text_mode#User-
defined_characters)

~~~
z303
Have a look at the annual text mode demo contest
[http://tmdc.scene.org/](http://tmdc.scene.org/)

------
Sniffnoy
You want to go one further... according to this interview[1], Yuji Naka
actually wrote a 3D graphics engine for the Master System! :) It was very low
resolution, of course, but...

[1]
[http://segaretro.org/Interview:_Mark_Cerny_(2006-12-05)_by_S...](http://segaretro.org/Interview:_Mark_Cerny_\(2006-12-05\)_by_Sega-16)

~~~
0xcde4c3db
According to another interview that I can't find at the moment, he also wrote
a Famicom emulator for the Mega Drive, which might have been the first
Famicom/NES emulator ever written.

------
jix
Author here, happy to answer any questions you might have.

~~~
Nition
I had a couple of games on Mega Drive that did basic 3D, or seemed to. One was
F1, where a few objects seemed to be true 3D. See the overbridge at 59s and
then the long tunnel at 1:01 here for instance:
[https://youtu.be/qofonsN3Nwc?t=57](https://youtu.be/qofonsN3Nwc?t=57) The
long tunnel is made of several short tunnels.

The other was Gunstar Heroes, where the first boss is made of 3D cubes. See
here at 4:00:
[https://youtu.be/9v3B1hzMwnQ?t=240](https://youtu.be/9v3B1hzMwnQ?t=240)

I'm just interested if you know or can guess anything about how the "3D" might
have been done in those.

~~~
MBCook
I don't know about the F1 game but I can take a guess on Gunstar Heroes.

I noticed the cubes are always aligned perfectly to the axis. And they have an
isomorphic projection so the cube is always the same height (although that
shouldn't be strictly necessary) as it's rotating. I also noticed the cubes
never seem to get smaller if they are closer to the background.

Because of this you could just have a series of sprites each showing the cube
in a different angle of rotation.

Now all you need to do is properly position a bunch of sprite (16 cubes +
head) and it looks like a bunch of cubes that are actually drawn in 3-D. It
wouldn't surprise me if they have some small table of the X/Y positions of the
cubes precomputed so they don't have to do that in real time.

In fact since every cube is always rotated at the same angle you could just
have one sprite in the system table and update it every frame.

That's my guess anyway. Clever sprite trickery.

It wouldn't surprise me if F1 uses something closer to what is described in
the article (although much less capable).

~~~
niftich
Your analysis appears correct, as several sources write that Gunstar Heroes
uses multi-sprite bosses [1][2].

F1 on the Mega Drive owes its existence to an earlier game for the Atari ST,
_Vroom_ [5]. The brainchild behind that game, "Dan McRae", talks in a video
interview [3] about how he arrived at that particular version of the game from
his earlier revisions on older platforms -- where techniques shown in Lou's
Pseudo 3d Page [4] apply, to more advanced techniques [6] similar to the ones
presented in this submission.

F1 on the Mega Drive was done by the same dev studio that collaborated with
McRae on Vroom, and at least one of the same programmers, but presumably had
to do some advanced tilemap trickery specific to the console. Unfortunately,
compared to other games in this series, there is very little information on
the technical aspects of the Mega Drive version.

[1]
[http://www.hardcoregaming101.net/gunstarheroes/gunstarheroes...](http://www.hardcoregaming101.net/gunstarheroes/gunstarheroes.htm)
[2] [http://www.racketboy.com/retro/sega/genesis/best-sega-
genesi...](http://www.racketboy.com/retro/sega/genesis/best-sega-genesis-
graphics-sound) [3] [https://youtu.be/ZTd-fFScLGA](https://youtu.be/ZTd-
fFScLGA) [4]
[http://www.extentofthejam.com/pseudo/](http://www.extentofthejam.com/pseudo/)
[5] [https://youtu.be/ZTd-fFScLGA?t=7m33s](https://youtu.be/ZTd-
fFScLGA?t=7m33s) [6] [https://youtu.be/ZTd-
fFScLGA?t=10m28s](https://youtu.be/ZTd-fFScLGA?t=10m28s)

~~~
Nition
Thanks for that information, that's still really interesting. And wow, Vroom
looks exactly like F1: I even see many of the exact same track assets.

------
kutkloon7
Nice article. I got a bit lost at the section explaining the left-to-right
technique, and wanted to ask about that here, but now I see there's pseudocode
and even illustration of the technique. Great that you've gone through the
effort to add those, they are really useful to clarify and take away any
misconceptions.

------
kelvin0
OK, for those ignorant like me:

Mega Drive == Sega Genesis.

I loved that console, impressive feat indeed!

------
busterarm
Absolutely freakin' mind-blowing demo. Super impressed.

