Page 1 of 1

CGA mode select register (3D8h) inaccuracy

Posted: Wed 02 Jan, 2019 4:30 pm
by VileR
While playing with some display-related code I noted a couple of discrepancies between PCem v14 and the real hardware. Both have to do with CGA register 3D8h, specifically bit 3 (+VIDEO):
  1. If this bit is modified in mid-frame, on an IBM CGA board the change takes effect immediately (at the current beam position).
    This is similar to how certain games modify the color select register (3D9h) for extended-palette tricks, as in California Games or Frogger. PCem emulates this behavior for 3D9h, but not for 3D8h as far as I can tell.
     
  2. If data is sent to the CRTC while this bit is set to 0 (video off), PCem seems to turn the video back on, as if it was set to 1.
    I haven't ascertained exactly which CRTC registers trigger this behavior when written, but that doesn't happen on (IBM) CGA hardware, where there's no interdependence between the registers on the MC6845 and the CGA 'proper'.
I could probably provide some sample code for testing, in case it'd be helpful.

Re: CGA mode select register (3D8h) inaccuracy

Posted: Wed 02 Jan, 2019 6:56 pm
by omarsis81
Maybe the same that happens here
viewtopic.php?f=3&t=500

Re: CGA mode select register (3D8h) inaccuracy

Posted: Wed 02 Jan, 2019 9:56 pm
by VileR
omarsis81 wrote: Wed 02 Jan, 2019 6:56 pm Maybe the same that happens here
viewtopic.php?f=3&t=500
Hmm, nah- that thread seems to be about composite color reproduction (unless I'm missing something)... this is unrelated.

Actually, the issues I mentioned above don't matter for any game/demo that I know of, so far. But I'm working on some neat stuff that relies on this functionality, and having the correct behavior in PCem would be convenient for quick testing. :)

Re: CGA mode select register (3D8h) inaccuracy

Posted: Thu 03 Jan, 2019 9:46 pm
by SA1988
May you please provide some sample code? Just asking :)

Re: CGA mode select register (3D8h) inaccuracy

Posted: Sun 13 Jan, 2019 8:08 pm
by VileR
Sorry for taking a while, but here' s a program that at least checks for issue #1 described above. It shows a test screen for 4 seconds - the +VIDEO bit in the Mode Control register is cleared after the first row of text, so nothing should be visible below it.
 
RASTTEST.zip
Test if disabling register 3D8h bit 3 in mid-frame is supported
(400 Bytes) Downloaded 343 times
 
Left: results in PCem
Right: results in DOSBox (and on real hardware with an IBM CGA)
 
cga_emu.png
cga_emu.png (4.57 KiB) Viewed 8667 times

Re: CGA mode select register (3D8h) inaccuracy

Posted: Sun 13 Jan, 2019 10:00 pm
by SarahWalker
PCem doesn't currently emulate 3d8h bit 3 at all, so it's not entirely surprising it doesn't work. Should be pretty trivial to add...

Re: CGA mode select register (3D8h) inaccuracy

Posted: Sun 13 Jan, 2019 10:13 pm
by SarahWalker
Added to the stock CGA at rev 1207.

Re: CGA mode select register (3D8h) inaccuracy

Posted: Tue 15 Jan, 2019 6:59 pm
by VileR
Brilliant, much obliged.