VileR wrote on 2021-09-03, 15:04:
Benedikt wrote on 2021-09-03, 14:34:
mkarcher wrote on 2021-09-03, 13:46:
There were some emulators that (optionally) used different timings, but as I know little is known about their details.
It is not hard to figure out, though, because there are really only three timing variants that make sense, namely the 640x300 mode, the maximally compatible 720x348 mode and a mode that permits 640x400 pixels via interlacing.
The third one would need some kind of CRTC auto-detection, because different CRTC types handle interlacing differently or not at all.
That brings up the question of which CRTC models were used across the rather broad range of HGC and HGC-compatible boards. Any strictly 6845-compatible part should handle interlacing correctly, but of course that had zero importance for CGA and HGC support, so I wouldn't be surprised if some of them didn't bother.
Looking at the HD6845S datasheet, which includes a comparison with the predecessor, the HD6845R, I finally understood how the 640x400 interlaced mode is supposed to work, and that it will fail and can not be adjusted to work on the newer HD6845S chip. Many late CGA/Hercules-on-a-chip clones seem to omit interlacing completely.
The main bottleneck in custom graphics modes on the 6845 is the row counter. This counter counts the current text row number, and it has only 7 bits. In text modes, it doesn't matter, no one seriously wants more than 100 lines of text on a typical 80s monitor. In graphics modes, on the other hand, IBM decided that the "character scan line" output becomes a "bank select" output. The CGA graphics mode runs at 100 rows of characters, each 2 pixels high, so the graphics mode has 2 banks. The standard HGC graphics mode runs at 87 rows of 4 scanlines per character. You can (and the bog standard CGA graphics emulator does) run the HGC in 3-bank mode. If you keep around 348 lines, you get 116 rows of 3 scanlines per character. This fits (including blanking) into the 128 row maximum. But you can't go down to 2 scanlines per character, because the maximum frame length will be around 256 scanlines, and even if the maximum vertical adjust of 31 can be applied, you just get 287 scan lines. The MDA/Hercules monitor won't sync to pictures with 287 lines.
So how does the interlaced 640x400 mode (which displays two 640x200 fields) work then, when we just discovered that we can't generate fields with 200 visible lines at 50Hz? It turns out that in interlace mode the row counter only counts every other text row! This means we can essentially count to 256 instead of 128, enabling us to program modes with just 2 banks per field. This quirk, i.e. counting of line-pairs has been "fixed" in the later HD6845S, so even in interlace modes, you are limited to counting 128 character rows, and you thus can't program a two-bank 640x200 field with correct MDA timings.