PDA

View Full Version : SCREEN (Graphics) OPTIONS IN BASIC PROGRAM RUNNING ON IBM5155 COMPUTER



Hugo Holden
December 27th, 2015, 06:06 PM
I have an IBM5155 running normally with its IBM CGA graphics card & a CGA monitor. Running the DOS utility CGACAL at the DOS prompt, there is a normal result showing the 16 possible "colors" on the colorbar test pattern. The 5155 computer is running DOS version 3.3 and comes with the BASIC program, it says version A3.3.

Using a modern computer running basic I was able to write a simple BASIC program in Screen 9 mode which pretty well replicates the DOS utility's video image, however when I went to run this simple program in the 5155 in BASIC it reported an illegal function. When I checked I found that the the 5155's BASIC reports an illegal function with any other command entry than screen 0, screen 1 or screen 2. This is pretty limiting for graphics as screen 0 is text only, screen 1 has only 4 "colors" (pink, green white & black) and screen 2 is monochrome.

Since the computer itself & the CGA card & the monitor is capable of supporting 16 colors, why would say "screen 9" or more of the advanced screen options not be allowed from within the BASIC program running on the 5155 ? Could it be the version of BASIC that came with the DOS 3.3? but that seems unlikely since its last listed date is 1987, and is there anything I can do to fix this ? Its odd because these screen commands go back to GW-BASIC. I tried loading QBASIC to the 5155, and it locked it up.

(the other graphics related problem I have, though probably not related, is that the Windows V1.0 I also have running on the 5155 appears in monochrome only and when I adjust the color on the windows preferences panel, it resets the color to zero always and won't produce a color screen image)

krebizfan
December 27th, 2015, 06:23 PM
If the information I have is correct, SCREEN MODE 9 requires EGA with the Enhanced Display and you need the 256kB model to get 16 colors at the same time. This mode goes for 640 x 350 which CGA can't do.

All the early versions of Windows only ran CGA displays in monochrome 640 x 200 mode.

Sorry, you will need a better graphics card and display if you want to have more colors at higher resolutions.

Plasma
December 27th, 2015, 06:41 PM
Under "normal" operation CGA only supports 4 colors in graphics mode, which is why you are limited to screen 0-2 in BASIC. But you can get 16 colors in text mode, which is what CGACAL does (40x25). Screen 0 and then width 40,25 should do it. There is probably something you need to do to enable high intensity background colors but I don't know off the top of my head.

Hugo Holden
December 27th, 2015, 08:08 PM
Thanks, That explains why the windows 1.0 with CGA is in monochrome.

Hugo Holden
December 27th, 2015, 08:10 PM
Thanks, I did not know that the CGACAL did its image in text mode alone, I had assumed it was in a graphics mode, so that explains it.

Hugo Holden
December 27th, 2015, 08:15 PM
krebizfan, Is there a vintage EGA graphics card (256kB model) you could recommend which is known to be suitable for a 5155 ? (I can always get an EGA compatible monitor)

modem7
December 28th, 2015, 01:34 AM
krebizfan, Is there a vintage EGA graphics card (256kB model) you could recommend which is known to be suitable for a 5155 ?
Related thread at [here (http://www.vintage-computer.com/vcforum/showthread.php?14364)]. In particular, see posts #8 and #10.

Hugo Holden
December 28th, 2015, 12:36 PM
Thank you for that link modem7. Very interesting to read about the screen flicker with the internal amber monitor when running an interlaced scan with an EGA card. The orange phosphor must have a shorter persistence than the usual green. I would be very reluctant to want to change it for a green or white crt as the amber gives the 5155 a lot of its character. Very early video arcade games like Atari pong 1972 used non interlaced scans too. The sync generators required far fewer IC's to implement it. By the time their Tank game came out in 1974 though, they had also gone to an interlaced scan for high resolution graphics.

On the topic of CGA monitors I have found something that might help others looking for a CGA compatible monitor. Sony made excellent professional studio video monitors with fine pitch phosphors and Trinitron CRT's (probably the best CRT of all) Some of their monitors have a DB9 connector labelled "Digital RGB" I had one of these monitors in my shed, a PVM 2042QM. Connecting it to the 5155 (required a male to female DB9 cable) gives an identical screen image on the CGACAL utility as an IBM CGA monitor and has no difficulty with the non interlaced scan. So this is an example of a "modern monitor" (probably late 1990's vintage) with a CGA compatible input.

Hugo Holden
December 28th, 2015, 01:47 PM
....I'm not 100% sure if the digital RGB input on the Sony monitor makes use of the intensity control pin (the brown is a bit lighter), so it may not be exactly the same as CGI standard, but overall its very close comparing it to the IBM CGA monitor image.

jmetal88
December 28th, 2015, 01:53 PM
....I'm not 100% sure if the digital RGB input on the Sony monitor makes use of the intensity control pin (the brown is a bit lighter), so it may not be exactly the same as CGI standard, but overall its very close comparing it to the IBM CGA monitor image.

The brown thing is an internal compensation done by IBM (and some other) CGA monitors. The graphics card is actually sending out a signal for dark yellow, which the monitor interprets and displays as brown. Your monitor probably doesn't have any issue with the intensity pin, it just doesn't have the hardware for conversion between dark yellow and brown.

vwestlife
December 28th, 2015, 02:50 PM
Note that on the composite video output, color 6 is also displayed as dark yellow (gold). It is only on an IBM 5153 or compatible RGBI monitor (such as a Tandy CM-5 or CM-11) that color 6 is displayed as brown. In practice, the exact shade you get varies depending on the contrast and tint adjustment of the monitor, and given the abstract nature of CGA graphics, doesn't really matter that much.

Hugo Holden
December 28th, 2015, 07:19 PM
Yes, I looked at the circuit for the IBM5153 monitor and it appears that the green level is reduced by Transistor Q206 and current via R252 when Brown is detected most likely. I would have to put the scope on it to confirm this. It is quite interesting that they built this feature into their monitor. It would be easy enough to add a similar tack on circuit inside the Sony monitor I think.

Trixter
December 28th, 2015, 09:58 PM
Yes, I looked at the circuit for the IBM5153 monitor and it appears that the green level is reduced by Transistor Q206 and current via R252 when Brown is detected most likely. I would have to put the scope on it to confirm this. It is quite interesting that they built this feature into their monitor. It would be easy enough to add a similar tack on circuit inside the Sony monitor I think.

FYI, this was discussed at length previously (http://www.oldskool.org/pc/cgacal), with some schematics.


In practice, the exact shade you get varies depending on the contrast and tint adjustment of the monitor, and given the abstract nature of CGA graphics, doesn't really matter that much.

Oh, I beg to differ (http://8088mph.blogspot.com/2015/04/cga-in-1024-colors-new-mode-illustrated.html) ;-)

vwestlife
December 28th, 2015, 10:26 PM
Oh, I beg to differ (http://8088mph.blogspot.com/2015/04/cga-in-1024-colors-new-mode-illustrated.html) ;-)

The exception does not make the rule. :p

Hugo Holden
December 29th, 2015, 04:17 AM
Trixter,

What a great link and creative work done with the artifact colors, making a defect helpful.

I think the reason behind composite NTSC video being "a less than perfect encoding system" is that the new color video signal had to be backward compatible with existing monochrome TV sets in the early 1950's. They were stuck with a receiver bandwidth in the TV intermediate frequency amplifiers of about 4 MHz. So the burst/color frequency had to be in the frequency spectrum near the upper luminance signal frequencies. The color carrier frequency was chosen so the chrominance and luminance sidebands were interleaved to minimize interference, but there is still some.

After reading the write up I will study the CGA card more, before contemplating replacing it with an EGA card, especially the 160 x 100, 16 color mode. I just have to figure out how to program the mode and color registers properly.

Trixter
December 29th, 2015, 06:51 AM
The exception does not make the rule. :p

Of course; I was being facetious.


the 160 x 100, 16 color mode. I just have to figure out how to program the mode and color registers properly.

Geoffrey Silverton (http://tunneler.org/low-res/) originally taught me how to do it. He lost his source code, but I have it; I've put a copy of it on ftp.oldskool.org (ftp://ftp.oldskool.org/pub/misc/code/LOWRES.ZIP).

Hugo Holden
December 29th, 2015, 01:23 PM
Trixter, Thank you for the link. I can see the files are in Pascal. My 5155 only has BASIC installed on it currently, but I can write to the registers using the OUT command. I saw for sale Version 3 of Turbo Pascal on 5.25 floppys, do you know if that will run on the 5155 ?

Trixter
December 29th, 2015, 01:38 PM
Yes, you can run all version of Turbo Pascal on the 5155, but that's not why I posted the code. The code is very easy to read and understand, and you said you wanted to learn how to make your own 160x100x16 mode in BASIC, so here is some working source code for you to learn from and translate. There are other files in the archive that describe what the code does.

If you WANT to learn Turbo Pascal, I certainly won't stop you :-) but it isn't a requirement for rolling your own 160x100x16 mode.

ropersonline
December 29th, 2015, 02:44 PM
Naive question (and I swear I'm not trolling): Why did Pascal fall out of fashion?

modem7
December 29th, 2015, 03:20 PM
Naive question (and I swear I'm not trolling): Why did Pascal fall out of fashion?
See the active thread at [here (http://www.vintage-computer.com/vcforum/showthread.php?34940-Status-of-Pascal)].

Hugo Holden
December 29th, 2015, 06:31 PM
Since I am just learning to program graphics I should probably stick to BASIC ! I have worked out all the states for the color select register on the CGA card in screen 1 mode (320 x 200 graphics mode), for the 6 control bits and I can write to them to get any of the 8 background colors, intensified or not, the two text colors (yel or white), the selection of which by the 6th bit (or by writing 32 to the register) also flips it between the two color sets, either the Cyan, magenta, white one or the red,green,brown one. And I can get the same results with BASIC OUT commands, writing to the register directly at hex 3D9.
But there is something here I'm not sure of: When I'm in one of the color sets, say green, red, brown so far I have only been able to select from those colors within that set with a BASIC instruction like LINE (X, Y)-(X+A, Y+B),Q,BF say to draw a filled box where Q is either 1, 2 or 3 to select either green red or brown from the color set. There are two bits of a register (called C0 & C1 in the CGA graphics card manual ) that the BASIC command is controlling which I think might be in the 6845 CRT controller register. It is a two step command using address 3D4 and 3D5 but so far I haven't figured out the BASIC syntax (for writing directly to the register with an OUT command) to get the C0,C1 bits to change state....or maybe C0,C1 is elsewhere?

Plasma
December 29th, 2015, 07:31 PM
Have you looked at the COLOR command?

Hugo Holden
December 29th, 2015, 09:17 PM
Yes, the COLOR command has the format in this case of COLOR A,B where A sets the background color and B can either be 0 or 1. Zero (or any even value entered) sets the text to yellow and simultaneously sets the color set to Red,Green,Brown. Setting it to 1 (or any odd number) selects the other color set Cyan,Magenta,white and sets the text to white. By trying to add another parameter to COLOR, like the format A,B,C (used in text modes where A is background,B is text color and C is border) didn't help selecting a color from inside the color set of either group three colors. I need to find the C0,C1 register so I can write to it directly....as noted there is a way to do it with the LINE command in BASIC, but it would be better to know how to modify it directly at the register.

Trixter
December 30th, 2015, 07:06 AM
Here's register programming info for CGA: http://www.seasip.info/VintagePC/cga.html

Hugo Holden
December 30th, 2015, 02:20 PM
Trixter, thanks for that link. Even with that info it doesn't answer my question, so my question might be defective or poorly posed.

I'll explain how I came to this question might help;

I wrote a brief program to draw a box on the screen in 320 x 200 graphics mode, selecting one color from the palette using the LINE command when the box was drawn for each new screen. Then I organised it to cycle through every possible state of the color control register, by writing to its address (decimal values 0 to 63 to manipulate all 6 bits), then with a time delay, so I could see on the screen every possible color combination for background, text and a new drawn graphic. I made a spread sheet for later use.

Of course by the time the count is 32 sent to the color control register, it switches to the alternate palette color, so the new drawn graphic changes to that and at the same time the text color changes from yellow to white and aside from intensifying the graphic & text and cycling through the background colors etc, there is no change in the palette color for the remainder of the count.. from 32 to 63.

Therefore I noticed that while the color control register can switch between alternate palettes, no bit in that register is responsible for selecting the color from within the palette.

Its not clear (to me) from the data on the CGA card registers where the physical register is that selects from the 4 possible states within a palette, exactly how to write to it with an OUT command, and it is not in the color control register it appears.

The BASIC program designers must know because the LINE command enables individual selection of the colors within a Palette at the time the graphic is drawn.

Can you give me an example of how you select between colors within a palette with a processor OUT command ?

Plasma
December 30th, 2015, 02:40 PM
The color used is whatever value you write to video memory. You don't need to "select" a color. If you are using BASIC to draw the graphics, you specify this value with your PSET/LINE/CIRCLE statement. BASIC has an internal "active color" variable so it will remember the last color and use that if you don't specify one.

Hugo Holden
December 30th, 2015, 03:34 PM
Thanks, now I see what is happening!

CP/M User
January 24th, 2016, 10:40 PM
If you WANT to learn Turbo Pascal, I certainly won't stop you :-) but it isn't a requirement for rolling your own 160x100x16 mode.

That's not the code I posted back when this Forum Began. :)

The program I found was originally in BASIC, but reworked it for Turbo Pascal 3.

I found the program here in the Archive (http://www.vintage-computer.com/vcforum/archive/index.php/t-104.html).