Shop Learn
Minor issue with VGA_640_x_480_8bpp.spin2 and VGA_640_x_480_16bpp.spin2 — Parallax Forums

Minor issue with VGA_640_x_480_8bpp.spin2 and VGA_640_x_480_16bpp.spin2

Dave HeinDave Hein Posts: 6,290
edited 2019-01-20 01:28 in Propeller 2
I created a VGA driver that I use with my C code that is based on VGA_640_x_480_8bpp.spin2, and I ran into a problem with it. In my driver I removed the BMP file that was included with the file, and I use a separate screen buffer at a different location in memory instead. With this change the last two lines of the driver are:
x       res 1
y       res 1

x and y are used to copy the color palette to the LUT memory. The code assumes that x has a value of zero initially. Of course, when you use res you can't guarantee the value of the memory location, so in my code the colors in the LUT memory were offset by some unknown value. I replaced the "res 1" by "long 0" to fix the problem.

BTW, the original code works OK because there is an ORGH after x and y are defined, which causes lots of padding zeroes to be inserted.


  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2019-01-20 04:17
    I include room for the bmp header which includes the palette before the screen buffer so that after opening the file and reading the header you can calculate the offset and simply read the whole bmp file into the screen buffer minus the offset. Then my vga driver reads the palette and intensity every frame so you can also modify these at anytime. Have a look in my includes folder in my p2 Dropbox.
Sign In or Register to comment.