I'm fairly close to being able to visualize how the old CGA/MDA cards work with a 6845 work- from the first character of the first row to vertical retrace. However, even after reading the 6845 datasheet, the CGA Adapter Manual, and the 6845/CGA Wikipedia pages, I still have two questions re: the operation of the 6845 (probably related). Specifically, the math isn't adding up for me:
What am I missing?
EDIT: I think I'm going to have to become more intimately familiar with the IBM CGA card circuitry than I ever wanted to. Some things I've noticed about the 6845 on the card: MA13 is a no-connect. MA12 is only enabled if the Graphics Mode in the status register is set. The MSB (Address Line 7 during CAS) of the Video DRAM, which would be normally be provided by MA13, is provided by HCLK. Hmmm...
EDIT2: The 6845's clock speed varies depending on whether the the HiRes Mode in the status register is set- it APPEARS to be halved if HiRes mode is not set. So it seems the answer to my question 2 is that IBM is in fact correct.
- This is how I understand CGA operation: The CGA adapter cheats the 6845, a character-oriented controller, into doing graphics mode by making the 6845 think that it's drawing to a terminal that has characters that are two scanlines high and 100 character rows total before retrace begins (for 200 scanlines). This is done because internally the 6845 cannot support more than 128 character rows, and we need at least 200 scanlines, so 1 scanline/row doesn't work. 16000 bytes / 200 scanlines = 80 bytes per scanline. In this configuration, thanks to the 128 row limit, MA13 is never asserted so RA0 effectively takes over the role of MA13. Unfortunately, since RA0 doesn't increment at the same rate as MA13, this accounts for the framebuffer being split across address ranges.
The above would mean for 320x200 operation, each byte would contain 4 pixels (2 bits/pixel) and 640x200 mode, each bit represents a different pixel (on/off per pixel). Indeed, this checks out with the description of the gfx modes. However, in the CGA Adapter Manual, I see that the 6845 is programmed for 40 horizontal elements/scanline- there's only time for 40 dot-clock events before the display is blanked (display output on 6845 is asserted) and hsync is asserted soon after! I don't see how this reconciles with the description I presented above, but indeed these are the parameters stored in the BIOS ROM, so my math must be off somewhere. What am I missing?
- The CGA Monitor Adapter treats 160x100 (which is a tweaked 40x25 text mode- presumably a typo and they meant 80x25) as having PELs (Picture Elements- pixels?) 2-high by 2-wide. Additionally, both 320x200 and 640x200 are treated as having PELs that are 1-high by 1-wide. What are these dimensions in terms of? scanlines-high and dots-wide? Both 320x200 and 640x200 are programmed using the same exact settings on the 6845, so this makes me think each PEL in 320x200 is 1-high by 2-wide (i.e. each color is held for two dot clocks), and 640x200 as 1-high by 1-wide.
What am I missing?
EDIT: I think I'm going to have to become more intimately familiar with the IBM CGA card circuitry than I ever wanted to. Some things I've noticed about the 6845 on the card: MA13 is a no-connect. MA12 is only enabled if the Graphics Mode in the status register is set. The MSB (Address Line 7 during CAS) of the Video DRAM, which would be normally be provided by MA13, is provided by HCLK. Hmmm...
EDIT2: The 6845's clock speed varies depending on whether the the HiRes Mode in the status register is set- it APPEARS to be halved if HiRes mode is not set. So it seems the answer to my question 2 is that IBM is in fact correct.
Last edited: