Friday 26 January 2018

Testing 16-colour sprite mode

What originally started out as debuging the 16-colour sprite mode to allow for a more colourful mouse pointer in the MEGA65 configuration program ended up going a bit further.

Daniel wrote a test program for 16 colour sprites to reproduce some strange behaviour that he was seeing. The mistake in the VHDL was simple, and quickly fixed. In the process, we also tweaked the transparent colour selection, so that it is now the foreground colour of the sprite.

Having fixed that and a few other little problems, I wanted to make a more interesting test of the 16-colour sprites.  So I decided it would be fun to animate a well-known 16-colour sprite assembly from the Amiga.

The first step was to produce the sprite data in the correct format. To do this, I added a new mode to the pngprepare program in the MEGA65 source tree, that takes a PNG with 16 or less colours, and produces a nice binary format that can be used natively on the MEGA65, including the palette entries, and information about how tall the sprites are, so that extended height mode can be used.

Then I modified Daniel's program to use that binary format, and to animate the resulting sprites. The result is quite nice:



This uses just two of the eight sprites, side-by-side to get the 32 pixel horizontal resolution.  The sprite itself is at 320x200.

So then I started thinking about using some multiplexing to get more owls on the screen.  I can easily use 3 pairs of sprites to get three owls on without multiplexing (the 4th pair could be used, but I would have to do a bit more palette fiddling, and it is already late). As the owl is $57 pixels tall, and I can have three overlapping owls, this means one every 29 (decimal) rasters.  I could also trim the sprites vertically (at the moment the blank space above and below the own as it moves is part of the sprite, wasting about 50% of the height in any one frame), so it would be quite easy to get more than double this number of owls on the screen.  But, let's have a few more owls anyway, for good measure:


I gave in and did the palette fiddling I mentioned, so there are four pairs of sprites, which are then multiplex 3x over (parts are concealed by the top and bottom borders).  So there are probably 8 or 9 whole 32x86 pixel 16-colour owls worth -- all using the 8 hardware sprites, not Amiga-style BOBs.  It would also be possible to horizontally multiplex the sprites (this is easier on the MEGA65 than on the C64, in part because the CPU is 50x faster, and there is DMA to splat the sprite X positions during a raster line), and the blank space above/below the owls could also be trimmed out to optimise things, allowing fairly easily to have about 4x more owls on the screen if we wanted to.  But I'll leave that fun to someone else...

6 comments:

  1. You cant horizontally multiplex sprites on 64, even with a split and fiddling the X position, I dont believe.

    Anyway, nice demo! :)

    ReplyDelete
    Replies
    1. Yes, I have looked it up myself since. You can apparently get 1/2 of a 9th sprite in the right border, but that is all.

      Delete
  2. Mindblowing ! This is something the community will love !!!!

    ReplyDelete
  3. Can they still be made to appear in the border using the usual trickery?

    ReplyDelete
    Replies
    1. Basically, yes, but remember the VIC-III/IV timing is different. To make life easy, you can simply move the border positions on the MEGA65, so side border knockouts don't need to consume raster time any more.

      Delete
  4. Paul showed me this getting an "overscan" image. Quite impressive.

    ReplyDelete