PDA

View Full Version : CGA 640x200 (Screen mode 2) - Black & White or Greyscale?



kyodai
April 28th, 2017, 01:14 PM
I guess this is a long shot - not sure if anyone can answer this...

So CGA 640 x 200 mode (SCREEN 2 in BASIC) "should" be 2 color mode. By default Black is background color, white foreground color. By definition it should be possible to set the foreground color to one of 16 CGA palette colors. I've made so many Black&White appz for this mode, but i noticed some games like Kings Quest use shades of grey on a monochrome 640x200 screen. heck even Microsofts "Visual basic 1.0 for DOS" uses grey scale while they say in the HELP text that "SCREEN 2" is only 1-Bit - Black or white. The irony... So how do you actually use greyscale in 640x200 monochrome? Is that some kinda hack that everyone knew back in the days?


Wikipedia has a wondeful example of how my graphics look in 640x200 @ Black&White:

https://upload.wikimedia.org/wikipedia/commons/a/a6/Cga_640x200.png

Scali
April 28th, 2017, 01:19 PM
There are no shades of grey. You only have 1 bit per pixel in 640x200 mode. So it can either be black or white. Or to be more exact, black or foreground colour.
I'm pretty sure that King's Quest has no 640x200 mode, but uses 640x200 mode as its 160x200 composite mode. In which case you get 16 NTSC artifact colours:
http://3.bp.blogspot.com/-5HF7Iwp74Lk/VS6s1IYf7eI/AAAAAAAAAJY/k1mIBF4aAUA/s1600/1k07_cga_composite_solid_colors_1.png
Many games of that era had composite and RGBI modes. And if you start such a game in composite mode on an RGBI screen, you'll just see 640x200 black and white.

commodorejohn
April 28th, 2017, 01:19 PM
Screen 2 gives only two colors. However, they can be any two colors from the 16 in the RGBI palette - so you can have black and white, black and grey, purple and blue if you want.

VB for DOS, though, is a text-mode application, not a bitmapped one. So it has an attribute byte for each character cell, meaning that characters can have any combination of colors 0-7 for the background and 0-15 for the foreground.

kyodai
April 28th, 2017, 01:37 PM
Screen 2 gives only two colors. However, they can be any two colors from the 16 in the RGBI palette - so you can have black and white, black and grey, purple and blue if you want.

VB for DOS, though, is a text-mode application, not a bitmapped one. So it has an attribute byte for each character cell, meaning that characters can have any combination of colors 0-7 for the background and 0-15 for the foreground.


So which mode does VB for DOS use when you run it on a monochrome 640x200 screen? I always found it embarrassing that the editor looked better than the compiled programs... XD But yeah let's not discuss about how bad Visual basic is...

Scali
April 28th, 2017, 01:56 PM
So which mode does VB for DOS use when you run it on a monochrome 640x200 screen? I always found it embarrassing that the editor looked better than the compiled programs... XD But yeah let's not discuss about how bad Visual basic is...

If you're talking about CGA, do monochrome screens even exist? I mean, what's the point of connecting a monochrome screen to a Color Graphics Adapter?
There's MDA and Hercules for that. These have 3 'gray scales indeed'. There's an intensity attribute, so you have black, 'white' (or whatever colour your monitor is), and 'bright white', when intensity is used.

The only 'monochrome' option I know for CGA is the built-in screen for the IBM 5155. In which case we're talking about a screen connected to the composite output of the CGA card, so technically it just gets 16 colours, but it only interprets the luminance of these colours.
I suppose on a colour NTSC display, if you were to disable the colorburst signal, you'd get the same effect: no chrominance, only luminance.
But your effective resolution will be much lower than 640x200 of course.

commodorejohn
April 28th, 2017, 01:59 PM
80-column text mode will display in 640x200 on the CGA, where there isn't a higher-resolution mode available. (In this case, it uses the same 8x8 character set as 40-column mode, only horizontally compressed.) It's only more than 200 lines on MDA systems, EGA with a high-resolution monitor, or VGA.

Re: monitors, I got a CGA display from lutiana that has a switch for black & white, green, or amber display modes :D

kyodai
April 28th, 2017, 02:05 PM
Well actually pretty much all DOS-based palmtops use a 640x200 CGA monochrome screen. Most prominent example would be the famous HP 200LX. Theres a few dozen other ones that use pretty much the same screen, just in a bigger dimension ("Zeos pocket"). The cool thing is that the screens of these keep the aspect ratio so by todays standards you would call them an "Ultra wide screen" i guess...

Some early "laptops" like the "IBM PC convertible" also had the same aspect ratio 640x200 CGA monochrome screen - the IBM was even backlit.

Well when i run Visual Basic for DOS on my HP 100LX it looks like this:

http://www.tankraider.com/userup/1493473321.jpg


So i was just curious how they do the greyscale trick... Is that really just some text mode or so?





This Help text makes me crazy - reading that it only supports Black&White, reading it in 640x200 monochrome greyscale... XD

http://www.tankraider.com/userup/1493430410.jpg

commodorejohn
April 28th, 2017, 02:12 PM
Yep, that's text mode. Notice how each 8x8 cell has only two different colors (or rather, shades of gray) in it?

Scali
April 28th, 2017, 02:14 PM
It's probably just some circuit in the display that remaps the 16 RGBI values of CGA to 16 gray scales.
The CGA adapter doesn't 'know' that it's monochrome, like with the 5155.
The same generally goes for EGA and VGA with monochrome screens. You can just use 'colour' software, and it will map to grayscale, the rest of the system doesn't know about it.
However, EGA and VGA at least have specific configuration settings to act as a 'monochrome' adapter (basically taking the place of an MDA/Hercules adapter, so it can be paired with a 'colour' adapter, for dual-screen). CGA cannot do this, it is always the 'colour' adapter in a system. CGA does support 'monochrome' modes in the sense that you can use certain modes with or without colorburst on composite screens. On an RGBI screen, it doesn't do anything of course.

kyodai
April 28th, 2017, 02:34 PM
OK, now imma be a nitpicker... Some games like the old Sierra games had a CGA monochrome driver that displayed in proper 640x200 Black&White as I'd expect it.

But let's take Prince of Persia for example... There is clearly some greyscale and I'm pretty sure this is not text mode...

Example (Look at the torch to see some true greyscale which is NOT B&W dithering):

http://www.tankraider.com/userup/1493425897.jpg


I have magnified it a bit so you can see it easier:

http://www.tankraider.com/userup/1493469696.jpg


And now to make it even worse - pretty much ALL CGA games work on these 640x200 monochrome devices. And monochrome screens were not really popular back in the days. So is it possible that CGA when you run a different screen mode like 320x200 that the graphics card would force it out on a 640x200 screen just converting it to greyscale and that weird aspect ratio? Is that a standard CGA feature? I am just puzzled how they do this.

Scali
April 28th, 2017, 02:54 PM
But let's take Prince of Persia for example... There is clearly some greyscale and I'm pretty sure this is not text mode...

This means nothing to me, as I have no idea how this screenshot was taken (although it seems to be taken with an emulator, not real hardware, given that it's a pixel-perfect 640x200 image), and what kind of processing was applied where to get to this particular image.
Note however that it is actually a 320x200 grayscale image. On a grid of 640x200, you'll see that every 'pixel' on screen is actually two vertical pixels at 640x200 resolution.
So it looks like just a grayscale mapping of a 320x200 'colour' game.

I think you may be confusing CGA resolution with display resolution.
I mean, any CGA monitor will always be capable of 640x200 resolution. It can also do this in colour, it's just that the CGA card can't drive it. An EGA card can. It gives you 320x200 and 640x200 in 16 colours on your standard IBM 5153 CGA monitor.
Likewise, if you have some kind of LCD screen or whatnot, the pixels are 'fixed'. There's always going to be 640 pixels vertically. In 320x200 mode, it just uses two pixels at a time. So in theory you could have 16 grayscale values in 640x200 mode on that screen, but CGA simply can't drive it in graphics mode, only in text mode.

commodorejohn
April 28th, 2017, 03:27 PM
It's not text mode, no. But it's not 640x200 either - notice how those pixels are actually two pixels wide? That's a 320x200 screen enlarged horizontally.

evildragon
April 28th, 2017, 05:07 PM
Yea, no matter what I try, I can't get Prince of Persia to start in 640x200, it's always 320x200 in 4 colors mode.

evildragon
April 28th, 2017, 05:09 PM
Well actually pretty much all DOS-based palmtops use a 640x200 CGA monochrome screen. Most prominent example would be the famous HP 200LX. Theres a few dozen other ones that use pretty much the same screen, just in a bigger dimension ("Zeos pocket"). The cool thing is that the screens of these keep the aspect ratio so by todays standards you would call them an "Ultra wide screen" i guess...

Some early "laptops" like the "IBM PC convertible" also had the same aspect ratio 640x200 CGA monochrome screen - the IBM was even backlit.

Well when i run Visual Basic for DOS on my HP 100LX it looks like this:

http://www.tankraider.com/userup/1493473321.jpg


So i was just curious how they do the greyscale trick... Is that really just some text mode or so?





This Help text makes me crazy - reading that it only supports Black&White, reading it in 640x200 monochrome greyscale... XD

http://www.tankraider.com/userup/1493430410.jpg

This is definitely text mode here. NOT 640x200 graphics mode. CGA only had 200 lines of resolution because it was 15KHz scan.. Text mode had 640 dots horizontally so this makes sense.

Nothing magical here.

Xacalite
April 28th, 2017, 05:46 PM
The only 'monochrome' option I know for CGA is the built-in screen for the IBM 5155.
There was more, and not just for portables, but for desktops as well.
Eg. Amstrad PC-MM, commonly used with the PC1512 series.
And there was plenty of noname "dual" monochrome monitors, which could sync to both 18 and 15 kHz.

Scali
April 29th, 2017, 01:39 AM
There was more, and not just for portables, but for desktops as well.
Eg. Amstrad PC-MM, commonly used with the PC1512 series.
And there was plenty of noname "dual" monochrome monitors, which could sync to both 18 and 15 kHz.

Yea, but clones can do whatever they want. Eg, my Philips P3105 came with an ATi Small Wonder and an MDA/Hercules-compatible 12" amber screen. The Small Wonder can output CGA on that with 16 shades of amber (using some clever PWM trickery to make the monitor display these shades).
None of this makes it a new/special CGA mode though. The software doesn't know anything about it. Which is probably exactly what is happening with the other examples in this thread.

kyodai
April 30th, 2017, 12:05 AM
Yea, no matter what I try, I can't get Prince of Persia to start in 640x200, it's always 320x200 in 4 colors mode.

So effectively that means that when the computer has a 640x200 resolution screen the horizontal pixels just get doubled and colours converted to Greyscale? I just wonder if it is a special feature of these chipsets for palmtops or something "any" CGA board would do by default.

Interestingly there is a tool called "LXPIC" which can display pictures (like jpeg and stuff) on the 200LX and amazingly in 640x200 in 4 grey shades.

http://hplx.pgdn.de/

But personally i think that is kinda "hack" referencing to the specific hardware, i don't think it will work on other machines like the IBM convertible...

Scali
April 30th, 2017, 01:17 AM
So effectively that means that when the computer has a 640x200 resolution screen the horizontal pixels just get doubled and colours converted to Greyscale? I just wonder if it is a special feature of these chipsets for palmtops or something "any" CGA board would do by default.

Depends on how you look at it. Technically, it's a continuous analog signal, and there isn't really a concept of horizontal 'resolution'. A CGA monitor doesn't 'know' whether it's running in 320x200 or 640x200 mode. The signaling is the same. It's just that in 320x200 mode, the CGA can only change the colour signal 320 times per scanline, where it can change the signal 640 times in 640x200 mode.
So there aren't really any 'pixels', and they don't really get 'doubled'.
There are only sync pulses vertically, and only there would you need a different signal to double scanlines vertically (as VGA does, for example. Any '200' line mode is actually 400 lines, where it sends every scanline in memory twice).

With any kind of LCD/plasma screen, you have a fixed grid of pixels, so you actually have 640 pixels per scanline, and the analog signal needs to be digitized to match the 640 pixels. So it's this digitizing circuit that does the 'magic'.
Back when LCDs became commonplace as regular monitors, they all worked like that initially: VGA is an analog signal, much like the RGBI signal of CGA. So the LCD screens would sync to the signal and digitize it internally (and when the signal didn't map 1:1, they'd also stretch it. They have an internal framebuffer for this, so technically they could also do things like vertical scandoubling for you), then display it on the discrete grid of pixels.
Later we got pure digital signals, like HDMI, DVI and DisplayPort, where the connection is more like a network connection, and you send packets of discrete pixels to the monitor, so you can skip the analog-to-digital conversion. So now you finally have an actual horizontal resolution in your signal, and you are sending actual pixels to the screen.

evildragon
April 30th, 2017, 08:20 AM
Scali, RGBI is actually pretty digital. 4-bit TTL. But yes, you can fit as much horizontal resolution as you want, if you can turn the beam on and off fast enough in each scan.

It's like how 640x480p 60Hz 31.5KHz, and 1280x960i 60Hz 31.5KHz are electrically the same, (and yes I have long proven I can interlace ALL old VGA monitors to 960i), and works just fine, as long as you can actually see the 1280 pixels wide. On color CRT's it's a bit of a challenge with the shadow mask being in the way if it's not fine pitch, but it is there and on monochrome CRT's it's far more readable, if it doesn't smear from unshielded cables, etc.

Scali
April 30th, 2017, 08:34 AM
Scali, RGBI is actually pretty digital. 4-bit TTL.

You don't have to explain to me how it works :)


But yes, you can fit as much horizontal resolution as you want, if you can turn the beam on and off fast enough in each scan.

That's the 'analog' part of it.
Your signals are driving sync and colour circuits directly. Yes, the signals are 'digital' in the sense that they only have two values, usually 0 and +5v, hence TTL.
But they are used as a continuous, 'analog' input signal raster-wise, rather than something that is actually 'digital' in the sense that you have discrete values describing discrete elements (in this case pixels).
VGA is technically the same as CGA this way, except instead of just TTL values for RGBI, they have analog values for RGB (generated by a DAC on the video card), and dropped the separate intensity.
What we consider 'digital' these days is way different from what a CGA RGBI interface is.

The later Commodore Amiga models actually supported super-highres on standard PAL screens, such as 1280x512.

evildragon
April 30th, 2017, 03:49 PM
Huh I can see it that way. I guess without a real dedicated pixel clock there's no real way to call it digital, when there's no true fixed way to map them.

I've done a lot of work on CRT's and video signals in my time, for video production and video generators, etc, but also just flat out messing with old monitors to see what can be done. For example, my Model 25 CRT hooked up to a Dreamcast playing Quake III: https://youtu.be/U7hWvBc3nD4?t=2m51s

Trixter
May 1st, 2017, 06:22 PM
Screen 2 gives only two colors. However, they can be any two colors from the 16 in the RGBI palette - so you can have black and white, black and grey, purple and blue if you want.

Not on a real IBM CGA. In Mode 6 (640x200x2), IBM CGA allows you to use the color select register to pick the foreground color. The background is always black.

On some clones with embedded CGA clone hardware, it was possible to change the 640x200x2 foreground and background color independently of each other; I have vague memories of doing this with OPTIK on my AT&T 6300. But that's not standard.


But personally i think that is kinda "hack" referencing to the specific hardware, i don't think it will work on other machines like the IBM convertible...

Yes, some of this conversation was muddled due to treating the HP 200LX as a true clone when what it actually does is map 320x200x4 to the existing grayscale screen with shades of gray.

commodorejohn
May 1st, 2017, 06:26 PM
Ah, I stand corrected.

Great Hierophant
May 2nd, 2017, 04:35 AM
Huh I can see it that way. I guess without a real dedicated pixel clock there's no real way to call it digital, when there's no true fixed way to map them.


All display adapters use a pixel clock, MDA 16MHz, CGA 14MHz, EGA 18MHz, VGA 25 & 28MHz etc. It is only the digital interfaces which make them readily available to the video output port.

evildragon
May 2nd, 2017, 12:51 PM
All display adapters use a pixel clock, MDA 16MHz, CGA 14MHz, EGA 18MHz, VGA 25 & 28MHz etc. It is only the digital interfaces which make them readily available to the video output port.

That's what I'm referring to, being available on the video port, to get true 1:1 pixel mapping, without having to "match" the phase manually (or automatically like most VGA monitors tried to do).

I guess I need to be more specific since people always look past what I say,. lol.

Scali
May 2nd, 2017, 12:59 PM
That's what I'm referring to, being available on the video port, to get true 1:1 pixel mapping, without having to "match" the phase manually (or automatically like most VGA monitors tried to do).

Yup, 'legacy' display signals only sync with a pulse at the start of each scanline (hsync), and another one at the start of each frame (vsync).
Traditionally, the display expected a fixed frequency for hsync and vsync, and the signal had to be within a certain tolerance, where the display circuitry could sync to it.
With VGA, 'multi-sync' displays were introduced, which could sync to signals in a wide range of frequencies. They have some electronics to measure the vsync and hsync frequencies, and then sync to them (which is why many later multisync monitors have either an LCD panel or an on-screen display which can tell you what frequencies and effective resolution you're using).
For VGA this was more or less required, since even standard VGA has 2 crystals already, and SVGA cards often had 3 or more, to enable higher resolutions and refresh rates.

evildragon
May 2nd, 2017, 02:45 PM
Yup, 'legacy' display signals only sync with a pulse at the start of each scanline (hsync), and another one at the start of each frame (vsync).
Traditionally, the display expected a fixed frequency for hsync and vsync, and the signal had to be within a certain tolerance, where the display circuitry could sync to it.
With VGA, 'multi-sync' displays were introduced, which could sync to signals in a wide range of frequencies. They have some electronics to measure the vsync and hsync frequencies, and then sync to them (which is why many later multisync monitors have either an LCD panel or an on-screen display which can tell you what frequencies and effective resolution you're using).
For VGA this was more or less required, since even standard VGA has 2 crystals already, and SVGA cards often had 3 or more, to enable higher resolutions and refresh rates.

And to top it off, the resolution it displayed was more of a guess. For example, it showed "720x400" a lot of times in the VGA text mode, when only 640 dots are present horizontally. If it had a true pixel clock it could access on the video port, it'd know exactly how many pixels were available.

I have one LCD, an AvidAV, and on DVI, it shows you exactly how many pixels there are, and on VGA, it only guestimates the lines, but never guestimates the horizontal resolution in the OSD.

Fun fact, the model 25 CRT only looks at the vertical sync polarity, and NOT the horizontal, which is why if you modify them with a VGA card, EGA 350 line mode will not work, even though the CRT can sync to it. To make 350 line mode work, you can invert the vertical sync polarity, and then it syncs up, but the picture looks squished vertically as it's 50 lines short of what it now thinks is 400 line mode..

Great Hierophant
May 2nd, 2017, 05:49 PM
Interesting, so that would make a VGA monitor a triple-sync monitor because it has to support 350, 400 and 480 line resolution modes. EGA monitors would be dual sync by supporting 200 and 350 line modes.

evildragon
May 2nd, 2017, 06:07 PM
Interesting, so that would make a VGA monitor a triple-sync monitor because it has to support 350, 400 and 480 line resolution modes. EGA monitors would be dual sync by supporting 200 and 350 line modes.

No, it's still fixed frequency because it goes by the horizontal frequency, 31.5KHz..

The more lines, the slower the vertical.. Which is why 350 and 400 line are 70Hz. On VGA cards there's extra blank lines in 350 line mode to make it really 400 line, but the polarity of the horizontal sync tells the monitor to stretch it vertically based on a separate adjustment POT. 480 lines has 60Hz because like I said, more lines equals slower vertical, if the horizontal isn't changing. (Remember 800x600 at 56Hz? I wish I didn't).

Xacalite
May 2nd, 2017, 07:33 PM
And to top it off, the resolution it displayed was more of a guess. For example, it showed "720x400" a lot of times in the VGA text mode, when only 640 dots are present horizontally.
Yes, a guess, and the logic seems very simple:
- if measured vertical resolution is 350, assume it's 640x350
- if measured vertical resolution is 400, assume it's 720x400
- if measured vertical resolution is 480, assume it's 640x480
- and so on for SVGA resoultions...

But in this case it's correct guess: VGA text mode by default uses 9x16 character box, so 80x25 = 720x400.
However, try setting some 320x200 or 640x200 (using SCREEN 2 in Basic, just to stay on topic :mrgreen: ) mode on VGA, and the monitor will still think it's 720x400.

Edit: note that all that frequency measuring only applies to SVGA monitors, plain VGA monitors don't need to measure anything, as they know the vertical resolution by looking at the polarity of HSYNC/VSYNC signals.

evildragon
May 2nd, 2017, 07:37 PM
You know, it's been a while since I remembered how large the text was, I thought it was 8x16, which would have been 640 dots wide. My memory is fading in that regard. Then again, I run my model 25 in 132x50 in 400 lines using an ATI VGA Wonder card.

Xacalite
May 2nd, 2017, 07:56 PM
You know, it's been a while since I remembered how large the text was, I thought it was 8x16, which would have been 640 dots wide. My memory is fading in that regard. Then again, I run my model 25 in 132x50 in 400 lines using an ATI VGA Wonder card.
If you run that Model 25 with on-board MCGA, the character box will be 8x16 indeed.
On VGA, default is 9x16, but 8x16 is also possible.

evildragon
May 2nd, 2017, 09:47 PM
If you run that Model 25 with on-board MCGA, the character box will be 8x16 indeed.
On VGA, default is 9x16, but 8x16 is also possible.

Correct, and on MCGA, in graphics mode, it's usually 8x8 double scanned to 8x16 (and no you can't cheat it).

Xacalite
May 2nd, 2017, 11:21 PM
Correct, and on MCGA, in graphics mode, it's usually 8x8 double scanned to 8x16 (and no you can't cheat it).
What do you mean?
If you set 320x200 or 640x200 graphics mode, and then output characters using BIOS calls, then indeed, BIOS uses 8x8 font, and the result is double-scanned to 400 lines, exactly as in VGA.
But in 640x480 mode, BIOS should use 8x16 font, shouldn't it?

Scali
May 2nd, 2017, 11:32 PM
Interesting, so that would make a VGA monitor a triple-sync monitor because it has to support 350, 400 and 480 line resolution modes. EGA monitors would be dual sync by supporting 200 and 350 line modes.

Yes, except EGA doesn't really 'sync'... They just invert the polarity for 350-line mode. So it still 'assumes' 200 line or 350 line mode, rather than actually syncing to the signal.

As for VGA... Is there a 350 line mode? I didn't think there was. I thought they just faked it with 400-line mode (there's only two crystals on VGA, so it can only support two pixel clocks... everything else has to be done by changing the number of scanlines and the length of each scanline).

Scali
May 2nd, 2017, 11:34 PM
(Remember 800x600 at 56Hz? I wish I didn't).

I'll give you 1024x768 at 43 Hz... interlaced...

evildragon
May 2nd, 2017, 11:43 PM
I'll give you 1024x768 at 43 Hz... interlaced...

Shh, I had a Cirrus Logic VGA card that did that on my Packard Bell monitor, there's a reason I pretended that didn't exist. ;)

1024x768 at 256 colors too at that.

Xacalite
May 3rd, 2017, 12:07 AM
As for VGA... Is there a 350 line mode? I didn't think there was. I thought they just faked it with 400-line mode (there's only two crystals on VGA, so it can only support two pixel clocks... everything else has to be done by changing the number of scanlines and the length of each scanline).
But yes, from the monitor's point of view, there is a 350 line mode.
Timings are the same as in 400 lines, but the monitor needs to vertically stretch the 350 lines to fill the entire screen area.
From the card's point of view... still yes, as it has to provide the appropriate HSYNC/VSYNC polarity combination on its output.

evildragon
May 3rd, 2017, 09:08 AM
But yes, from the monitor's point of view, there is a 350 line mode.
Timings are the same as in 400 lines, but the monitor needs to vertically stretch the 350 lines to fill the entire screen area.
From the card's point of view... still yes, as it has to provide the appropriate HSYNC/VSYNC polarity combination on its output.

Correct. That's why a model 25-XT CRT (monochrome or color) is incapable of syncing to 350 line, as it doesn't read horizontal sync polarity, only vertical. You can invert the polarity to make it work as it'll think it's 400 line, but it'll look widescreen.