Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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...



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.


This is extremely well-written. Kudos!

Basically all 8/16-bit console graphics tricks take advantage of one (or both) of the following two facts:

1. 8-bit and (particularly) 16-bit consoles are built to draw and move 2D tiles crazy fast. If the effect you want can be achieved (or faked) by a series of animated tiles, you can do it. The most obvious example is "segmented" characters (usually bosses, but also the protagonist in Vectorman) that are made up of multiple sprites (tiles) that are animated in such a way as to fake smooth 3D animation

2. The screen is drawn one row at a time. Left to right, top to bottom. Like a typewriter. You get a little bit of processing time after each row, and a little extra time after the last row. You can use this time to tweak things (like, the position of the background, or the position of a sprite) in between rows. This is how you can achieve "line scrolling"

"Simple" line scrolling where you change the background scrolling rate on each horizontal line, for a very smooth effect: https://youtu.be/hIiMz_NUDEw?t=97

More advanced line scrolling where you manipulate both horizontal and vertical scroll in between lines: https://www.youtube.com/watch?v=QN2Yoz0INrI

I am not sure, but I think many of the abstract effects (not the polygon animations, which use tile rendering) in the Over Drive 2 demo that this article discusses are achieved by extremely precise manipulation of sprite positioning and/or scroll registers as in #2 above.


Pointless side fact: It's the first time i ever "read" a word in a Youtube video ID!

> https://youtu.be/hIiMz_NUDEw?t=97


Whoa! Awesome.


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...


Have a look at the annual text mode demo contest http://tmdc.scene.org/


You could also play tricks with the palette, swapping it out at the end of each scanline to get e.g. 64 colors at the same time on EGA.


Thanks for writing this. I didn't really expect that much attention, so I kind of assumed most people reading it are at least somewhat familiar with the graphics hardware of that area. I shouldn't have assumed that :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: