First post, by Scali
I was experimenting with tweakmodes in CGA, and found that composite mode apparently had some hardcoded width value, since the scanlines were shifted.
I have located the bug in vga_draw.cpp.
In the function VGA_CheckScanLength(void), there is the following code:
case M_CGA16:
vga.draw.address_add=80;
That is never going to work for tweakmodes, obviously. Replace that with this, and things should be fine:
case M_CGA16:
vga.draw.address_add=vga.draw.blocks;
The weird thing is... the code works properly when composite is not enabled, even though, judging from this, it shouldn't. Haven't found that code yet. Seems odd. For all other modes, the address_add is calculated off vga.draw.blocks anyway, which is properly calculated from the CRTC-values, and as such, responds correctly to tweaks.
Edit: Found why it worked in regular CGA modes...
The 4-colour 320x200 mode is M_TANDY4, not M_CGA4 as I assumed. And the code for M_TANDY4 was already correct.