Jump to content


Vertical bars demo

8 replies to this topic

#1 Asmusr OFFLINE  


    River Patroller

  • 2,747 posts
  • Location:Denmark

Posted Mon Feb 20, 2017 3:29 PM

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


Attached File  320px-Vertical_Raster_Bars.png   27.96KB   5 downloads


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:


Attached File  vertbars1.png   875bytes   4 downloads


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:


Attached File  screenshot2.png   4.67KB   3 downloads



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.

Attached Files

#2 Lee Stewart OFFLINE  

Lee Stewart

    River Patroller

  • 3,690 posts
  • Location:Silver Run, Maryland

Posted Mon Feb 20, 2017 3:46 PM

Very nice, indeed, Rasmus.



#3 ti99iuc OFFLINE  



  • 1,431 posts
  • Location:Italy

Posted Mon Feb 20, 2017 3:47 PM

:thumbsup:   cool !!

#4 fabrice montupet OFFLINE  

fabrice montupet


  • 346 posts
  • Location:Burgundy - France

Posted Tue Feb 21, 2017 5:59 PM

Hypnotic and excellent! 

#5 arcadeshopper OFFLINE  


    River Patroller

  • 3,332 posts
  • Location:Portland, Oregon USA

Posted Tue Feb 21, 2017 6:31 PM

wowza   very nifty




  • 600 posts
  • Location:The Great White North

Posted Thu Mar 23, 2017 10:22 PM

How do I run VERTBARS.DSK on Classic99?





Edit Never mind. ... Read the menus.  DUH

Edited by TheBF, Thu Mar 23, 2017 10:41 PM.

#7 gregallenwarner OFFLINE  


    Chopper Commander

  • 185 posts

Posted Tue Mar 28, 2017 11:15 AM

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.

#8 Asmusr OFFLINE  


    River Patroller

  • Topic Starter
  • 2,747 posts
  • Location:Denmark

Posted Tue Mar 28, 2017 12:03 PM

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.

#9 speccery OFFLINE  



  • 337 posts

Posted Fri Mar 31, 2017 4:23 AM

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!

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users