As far as games are concerned, VGA normally means 256 colours. Whereas the EGA standard allowed 16 colours to be displayed at the same time out of a possible 64 (2-bits per channel), VGA allows 256 colours to be displayed at the same time out of a possible 262,144 (6-bits per channel.)
Unlike EGA games which rarely changed the palette, almost all VGA games alter the palette to their preferred group of 256 colours. When games store the palette on disk, there are two common layouts used.
The "Classic" format
The classic palette format maps exactly to the VGA registers. Each colour takes up three bytes (one each for red, green and blue) and only the lower six bits of each byte are used (as the VGA only uses six bits per colour.) In practice this means each byte will only contain values between zero and 63 inclusive. (However be aware that some games use values between zero and 64! In these cases 64 should be treated the same as 63, as this is what the VGA does.)
This format is often referred to as 6-bit RGB.
The "Modern" format
Since the widespread use of video cards capable of displaying 24-bit images, 256 colour palettes have been increased to use the full eight bits in each byte for storing colour levels. All this means is that each of the red, green and blue bytes will have the full range of values (0-255) instead of the limited VGA values (0-63).
This format is often referred to as 8-bit RGB.
Some variants of this format pad the values out to 32-bits, and this format is often referred to as 8-bit RGBA. In most cases the fourth byte (A) isn't used and can be ignored.
To easily convert between one format to another, some simple formulae can be used for each of the red, green and blue values:
// 6-bit VGA to 8-bit RGB: eight_bit_value = (six_bit_value * 255) / 63 // 8-bit RGB to 6-bit VGA six_bit_value = (eight_bit_value * 63) / 255
Performing the multiplication before the division removes the need to use floating point numbers and minimises any rounding errors.
More efficient conversions can also be used when speed is more important than code readability:
// 6-bit VGA to 8-bit RGB eight_bit_value = (six_bit_value << 2) | (six_bit_value >> 4) // 8-bit RGB to 6-bit VGA six_bit_value = eight_bit_value >> 2
Note however that the input VGA values may need to be capped to 0x3F (63) as some games output the value 0x40 for 100% instead of 0x3F (TODO: Confirm/link to example). The VGA treats 0x40 the same as 0x3F however (TODO: Confirm).
It is relatively simple to "detect" a VGA palette file, particularly if they are 6-bit RGB as the files will be exactly 768 bytes long - almost no other files are exactly this size. Looking at the palette in a hex editor will often reveal the file starts with three 0x00 bytes, on account of nearly all games using palette index #0 as black. Seeing groups of the same value (e.g. 10 10 10 20 20 20 30 30 30) is also a good indication of a palette with a greyscale section in it, which is another common feature. This can be seen in the very last row of the Hocus Pocus palette above, where the colour varies from black, through grey and up to white.
This program will open a 6 or 8 bit headerless palette file and display swatches for each color, and save a bitmap if you like.