I think you are little bit confused about video cards and their capabilities.
Octocontrabass wrote:CGA was capable of 16 colors.
Nope.
CGA: "CGA uses a 16-color gamut, but not all colors are available at all times".
Octocontrabass wrote:EGA was capable of 64 colors, so EGA added an attribute controller
Again, no,
EGA: "EGA produces a display of up to 16 colors". It introduced the palette, which had 2 bits per channel, thus giving 4*4*4 = 64 possible colors, but you could only use 16 of them at any given time.
Octocontrabass wrote:VGA was capable of 262,144 colors, so VGA added a palette controller
Nope and nope. VGA was capable of 256 colors tops, and palette was already introduced with the EGA. It is true that in VGA there's 6 bits per channel, thus giving 64*64*64 = 262,144 possible colors, but just as with CGA and EGA, the VGA card was unable to use all those colors at all times.
It was the SVGA mode (standardized by VESA) that first was capable of displaying 65536 colors (using 16 bits 5/6/5 bits packed pixel format without DAC). And that's still less than 262144!
Octocontrabass wrote:The BIOS sets a CGA-compatible text mode before handing control to your bootloader.
Nope again. BIOS sets a VGA-compatible text mode, which means even though the buffer starts at 0xB8000 as with CGA, the attributes are handled differently for
CGA text mode (CGA had configurable blinking/intensity bit, while VGA has a configurable intensity/font map selector bit, allowing 512 glyphs). And also while the attributes index a 16 colors palette of 2x2x2 channels on EGA, on VGA they index 6x6x6 channels. By programming the DAC, you can have a nice and smooth fade in/out effect in VGA text mode, something impossible with CGA or EGA.
Octocontrabass wrote:This means the attribute controller is configured to map 16 CGA colors to 64 EGA colors, and the palette controller is configured to map 64 EGA colors to 262,144 VGA colors.
This absolutely not true. There are only 16 possible colors in the EGA palette, and 256 in VGA. By default the VGA palette's first 16 color used the same values as the EGA palette's channels shifted by 4 (meaning the first 16 VGA colors looked exactly as the EGA colors), and
the rest had a rainbow-like mapping.
Octocontrabass wrote:Your code doesn't touch the palette controller at all, so it's still set up to output the 64 EGA colors.
Nope, if you don't touch the DAC registers, then VGA is still set up to use all available 256 colors. The default palette is backward compatible with EGA, meaning the first 16 colors encode the same colors. The next 16 colors (16-31) encode a grayscale gradient, not possible with EGA, and colors 32-63 are also different than what the full EGA channels would produce.
Cheers,
bzt