CGA mode select register (3D8h) inaccuracy

Support and general discussion.
Post Reply
User avatar
VileR
Posts: 10
Joined: Sun 23 Dec, 2018 6:18 pm

CGA mode select register (3D8h) inaccuracy

Post 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.
User avatar
omarsis81
Posts: 945
Joined: Thu 17 Dec, 2015 6:20 pm

Re: CGA mode select register (3D8h) inaccuracy

Post by omarsis81 »

Maybe the same that happens here
viewtopic.php?f=3&t=500
User avatar
VileR
Posts: 10
Joined: Sun 23 Dec, 2018 6:18 pm

Re: CGA mode select register (3D8h) inaccuracy

Post 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. :)
SA1988
Posts: 274
Joined: Wed 30 Apr, 2014 9:38 am

Re: CGA mode select register (3D8h) inaccuracy

Post by SA1988 »

May you please provide some sample code? Just asking :)
User avatar
VileR
Posts: 10
Joined: Sun 23 Dec, 2018 6:18 pm

Re: CGA mode select register (3D8h) inaccuracy

Post 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 8668 times
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: CGA mode select register (3D8h) inaccuracy

Post 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...
User avatar
SarahWalker
Site Admin
Posts: 2054
Joined: Thu 24 Apr, 2014 4:18 pm

Re: CGA mode select register (3D8h) inaccuracy

Post by SarahWalker »

Added to the stock CGA at rev 1207.
User avatar
VileR
Posts: 10
Joined: Sun 23 Dec, 2018 6:18 pm

Re: CGA mode select register (3D8h) inaccuracy

Post by VileR »

Brilliant, much obliged.
Post Reply