Jump to content
IGNORED

Vertical bars demo


Asmusr

Recommended Posts

The vertical bars is a classic demo effect. Here's an example of how it could look on the Amiga:

 

post-35226-0-56978600-1487621494_thumb.png

 

The traditional way of drawing the effect requires a palette based screen mode where the palette has as many entries as the horizontal resolution of the image. The screen is set up in advance by drawing vertical, pixel thin lines from the top to the bottom of the screen. The leftmost line in drawn using palette entry 0, the one next to it using palette entry 1, and so on until the rightmost line is drawn using the last entry of the palette.

 

To draw a frame you start at vertical refresh by resetting all colors in a palette to the background color. Before the first scanline is drawn you 'light up' some of the palette entries next to each other to draw a horizontal slice of a bar. Because of the vertical lines in the image, the bar slice will be repeated at each subsequent scanline of the image. At the next scanline you move the position, i.e. the start palette index, a little (often following a sine wave) and draw another bar slice, and so on until you either decide to stop or reach the bottom of the screen. Note that because you change the palette as the screen is drawn, changes made at a given vertical position on the screen will not affect scanlines above it.

 

With the recent 'discovery' of scanline effects on the TI, is it possible to implement this effect? We don't have a real palette based mode, and yet we do have the color sets of graphics mode 1. There are 32 color sets available, and each has both a background and a foreground color available, giving us a resolution of 64 palette entries. This is still only one entry per 4 horizontal pixels (4 x 64 = 256), but it's better than nothing.

 

To prepare the screen we redefine the first character in each color set (0, 8, 16, ..., 248) to a pattern that has half foreground and half background color. We then draw vertical 'lines' on the screen using each of the 32 characters, like this:

 

post-35226-0-21758600-1487624280_thumb.png

 

By changing the 32 bytes of the color table we can now change the color of each vertical line individually.

 

Now we're ready to go. We wait for vertical refresh and set the entire color table to black. We draw a bar slice by setting a few entries in the color table to other colors than black. To detect which scanline we have reached we place 5 invisible sprites on the desired scanline and poll the 5th sprite flag until it is set. To quickly set up the sprites, we can prepare the sprite attribute tables in VDP RAM in advance so we only have to set one register. To move the bar slices we have a sine table prepared in advanced.

 

If everything runs from scratchpad we have time to draw 2 bars slices of 6 colors (or 3 bytes) every 4 scanlines. The result looks like this:

 

post-35226-0-70154900-1487625242_thumb.png

 

 

It's a bit flickering and not very pretty, but now there's one less thing the TI-99/4A can't do. :)

 

Could it be done using multicolor mode instead, without any scanline tricks? Possible, but I think it would be pretty slow.

 

The music is "Let's kill the rainforest" by Rushjet. I hope it's OK I have used it for this demo. It fits well with the intense display.

VERTBARS.dsk

Vertbars source.zip

  • Like 10
Link to comment
Share on other sites

  • 1 month later...

Can you explain this recent "discovery" of scanline effects in more detail? What was discovered about the TI that lets you do this? I was under the impression that the video hardware did not issue scanline interrupts, only field interrupts 50/60 times a second.

 

The recent "discovery" was that you can determine the vertical position of the "bean" within a reasonable precision (one scanline or so) using the 5th sprite flag. You simply place 5 sprites on the screen at the position where you want to do something, and then start polling the VDP status for the flag. When you have done something, you move the sprites further down the screen to the next position where you want to do something, and start polling again. You could also use the collision flag for the same effect, but I found it to be less reliable on real hardware.

  • Like 3
Link to comment
Share on other sites

This is just an awesome demo, and again demonstrates creativity and deep skill with programming. Great job!

In fact the idea was so cool, that I wanted to get it running on my TMS99105+FPGA system. I had not implemented support for the fifth sprite per scan line detection in my TMS9918 implementation, so I quickly added that. As I was doing the change, I realised I had not touched the VHDL design overall for nearly 3 months. Unbelievable, something must be wrong with me. At least I can say that I did not have easy to use test material for that (lame excuse). Now the demo runs:

TMS99105 + FPGA system emulating TI-99/4A running vertical bars demo by Asmusr

I suppose it is safe to say the fifth sprite detection now works - probably with some off by one errors. There seems to be occasional flicker, perhaps towards the end of the frame an off by one error causes an entire frame to be missed.

In the FPGA implementation I had already in the past cheated a little bit, in that my TMS9918 implementation exposes 12 extra memory mapped registers to the CPU. These include the horizontal and vertical position of the VGA scan. As an additional exercise I'll probably try to modify your code slightly to use that register instead of the sprites. The TMS99105 also runs so much faster that it can probably do things even with the 5th sprite based scan line detection at smaller intervals. Having written this, it is very cool that the original hardware can do this effect!

  • Like 7
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...