16 and 256 color BMP Video drivers
Ariba
Posts: 2,690
Here are two drivers that can show a BMP file direct. No bitmap converter or palette extraction is needed.
Just load the BMP to hubram and start the driver.
The BMP file must be uncompressed and the pixel size must fit to the driver.
The first driver supports 16-color BMPs with 384x128 pixels on PAL video.
The second driver supports 256-color BMPs with 256x100 pixels on NTSC video.
Both repeat every line two times so you get 384x256 and 256x200 pixels on screen.
Making other resolutions is easy, I have chosen this sizes because they fit in 24..25 kByte and work therefore with my DE0-Nano.
The drivers work with the CLUT modes of the video generator. First the palette is loaded from hubram to the stackram (CLUT). Then I just read the bitmap data in longs from hubram an feed every long to the video generator, the color lookup is done by the Prop2 hardware. BMP lines are (normally) stored from bottom to top in the file, so the read pointer needs to be modified a bit between the lines.
You will need P2Load to download the bitmaps. The attached ZIP also contains the *.bin files of the drivers, so you don't need to start PNUT to try it out.
The bitmaps must be loaded to a certain address in hub, so that the palette data is long aligned:
$17CA for the first driver, and $16CA for the second driver.
If you have P2Load in the same directory, then just type: (replace <com> with your COM number)
have fun
Andy
Edit: The updated ZIP contains now versions with both resolutions for NTSC, PAL and VGA !
Just load the BMP to hubram and start the driver.
The BMP file must be uncompressed and the pixel size must fit to the driver.
The first driver supports 16-color BMPs with 384x128 pixels on PAL video.
The second driver supports 256-color BMPs with 256x100 pixels on NTSC video.
Both repeat every line two times so you get 384x256 and 256x200 pixels on screen.
Making other resolutions is easy, I have chosen this sizes because they fit in 24..25 kByte and work therefore with my DE0-Nano.
The drivers work with the CLUT modes of the video generator. First the palette is loaded from hubram to the stackram (CLUT). Then I just read the bitmap data in longs from hubram an feed every long to the video generator, the color lookup is done by the Prop2 hardware. BMP lines are (normally) stored from bottom to top in the file, so the read pointer needs to be modified a bit between the lines.
You will need P2Load to download the bitmaps. The attached ZIP also contains the *.bin files of the drivers, so you don't need to start PNUT to try it out.
The bitmaps must be loaded to a certain address in hub, so that the palette data is long aligned:
$17CA for the first driver, and $16CA for the second driver.
If you have P2Load in the same directory, then just type: (replace <com> with your COM number)
p2load -p<com> realmario4.bmp,17CA pal_384x128_clut4.bin p2load -p<com> realmario8.bmp,16CA ntsc_256x100_clut8.bin
have fun
Andy
Edit: The updated ZIP contains now versions with both resolutions for NTSC, PAL and VGA !
Comments
I'll try them tomorrow, I have family over today
Very nice PICTURE. And it fill entire LCD area on my one NOT only small region in midle
Thanks
Picture from my PAL LCD
The NTSC displayed perfectly but I noticed the PAL doesn't.
It's almost as though every horizontal pixel is reversed with the next one like the bits are being sent in the wrong order.
To demonstrate this I did a simple 16 colour bitmap with some text.
16coltest.bmp
It is mainly Chip's work, if you look at the source, the field loop is really straightforward, and the hardware does most of the decoding.
@Coley
It looks like the two 4bit pixels in a byte must then be swapped. This was not visible with the Mario picture. So for the 16-colour mode you can not just feed the video generator with longs from the bitmap. We will need an algorythm that swaps the 2 nibbles in all bytes of the long.
I will look tonight into this.
Andy
PAL_384x128_CLUT4.spin
I have now made both color modes and resolutions for NTSC and PAL. And also both versions for VGA (signaled as 800x600).
You find it all attached to the first post. There is also a picture of a wolf in the ZIP, which is much more challenging for low color modes, than the Mario-picture.
Andy