Showing posts with label IBM PC. Show all posts
Showing posts with label IBM PC. Show all posts

Saturday, July 12, 2014

Pushing the Limits : PC Sound Chip Digitized Sound

The PC Speaker was the most limited of all sound devices for the PC.  Unlike later dedicated sound chips, the timer-driven PC speaker had no programmable capability to change the volume.  The typical PC Speaker outputs a square wave.  A square wave is suitable for representing a musical note, but not digitized audio.  A square wave is notable because the voltage level spends the same amount of time high as it does low.  If the voltage period varies (it spends more time high than low, or vice versa), it is no longer a square wave.  Additionally, if the frequency changes faster than the speaker can cope, you can get intermediate positions in the speaker cone between full expansion and full contraction. The end result is something approximating 6-bit digitized sound.  The quality of the resulting audio varied considerably on the size of the speaker cone (IBM PC=big, Tandy = bigger, PCjr. and some PS/2s = tweeters (bad)).  Some good samples of the digitized PC Speaker can be found on my friend Trixter's page : http://www.oldskool.org/sound/pc

The first practical, widely supported digital audio devices in PC games were the Tandy digital sound chip, known as the PSSJ (parallel, serial, sound and joystick), and the Sound Blaster's DSP (Digital Signal Processor) chip.  Both had access to a hardware interrupt (7 for Tandy, 7 by default for Sound Blaster) and a DMA channel (1 for both) to feed a DAC without requiring much processing time.  There was also a parallel port sound device called the Covox Speech Thing, which required the CPU to feed data bytes to the a resistor network attached to the parallel port.  The result was a crude 8-bit DAC

Between the PC speaker and the DMA-driven Earlier music devices were generally programmable sound generators, essentially using variable frequency square waves and frequency modulated sine waves to produce sounds.  None of them had natural DAC functionality.  However, these could be tweaked to simulate the effect of a crude DAC.

The PCjr. and Tandy 3-Voice chip, the TI SN76496 and its clones, was quite a bit more capable than the PC Speaker.  It had three square wave generators as opposed to the single square wave of the PC Speaker.  Additionally, it had a 4-bit volume control for the chip's output.  This volume control, combined with one of the square waves, could be used as a DAC.  The Game Blaster SAA-1099 chips operated very similarly to the Tandy chip (but with six channels per chip instead of three) and thus were also capable of using this method.  The Adlib YM-3812 chip used two operator frequency modulated sine waves to produce sound.  There are eighteen operators in total, and each could be manipulated via multiple registers.  Each operator has a 6-bit volume control, giving 6-bit DAC functionality.  Similar methods could be used to produce digitized sound as with the less-advanced devices.

As a sidenote, these methods were also used for other, non-PC chips.  Programmgers for the Commodore 64 used such methods to allow the MOS 6581 SID chip to produce an approximation of human voice for the classic game "Impossible Mission" and others.  The impressive digitized sound effects of Dungeon Master for the Atari ST were produced solely by the high-clocked AY-3-8910 clone in that machine, the YM-2149.  The Atari TIA (Quadrun) and POKEY chips could also handle digitized sound.  All these chips have 4-bit volume controls like the TI and Phillips chips, so the same methods can be used to get digitized sound out of them.  The NES 2A03 had a 7-bit DAC that could be fed directly by the processor and could also employ a delta modulation technique for digitized sound.

There are several disadvantages to this method.  First, the result will definitely sound "lo-fi" and is often very quiet.  Second, it requires a lot of processor time, because the processor has to send a lot of data directly to the device to make it work faster than it should.  Third, it requires much more space to store a sample than a chiptune, and in the era of 360KB and 720KB floppy disks, the room for digitized sound was limited.

As far as PC games go, outside digitized PC Speaker, the effect was seldom used.  An early use of the effect was in Imagic's Touchdown Football for the PCjr.  It's digitized voice only played back properly on a PCjr., the faster Tandy 1000 would make the voice sound like a chipmunk.  The game was later ported to Tandy 1000, and the voice played back at the correct speed.

Electronic Arts used Tandy digitized sound in several titles.  Among them are Kings of the Beach, 688 Attack Sub and Skate or Die.  My friend Cloudschatze has some comparison videos between the Tandy 3-voice sound and C64 SID sound on his Youtube Channel, see here : https://www.youtube.com/user/Cloudschatze/videos
Interplay used it for the sound effects in the original 16-color version of Battle Chess.  Epyx's Storm Strike uses for voice samples in at least two places.

Capstone's Bill and Ted's Excellent Adventure utilized it for the Adlib, as did Interplay's/Delphine Software's Another World/Out of this World.  Another World also supported the Sound Blaster, and the sampled sound effects sound far superior with the Sound Blaster.  GameTek's Super Jeopardy supports Adlib for digitized music and it may also support digitized playback with the Innovation SSI-2001, which also used a MOS 6581 SID chip.

Sir-Tech's Wizardry : Bane of the Cosmic Forge and Wizardry : Crusaders of the Dark Savant supports digitized sound through the Adlib, even if Sound Blaster is selected.  The game also supports digitized PC Speaker sound, and in DOSBox, you must select PC Speaker sound.  Crusaders allows you to select a music device independently of the sound device.  Some games, like Budokan, support digitized PC Speaker for sound effects regardless of sound device selected.  Dragon Wars is one of many games that supports digitized PC Speaker sound even though the Tandy 1000 and other sound cards were available by the time of its PC port's release.

Activision's OmniMusic driver, used in F-14 Tomcat, BattleTech: The Crescent Hawk's Revenge and Joe Montana Football, support digitized playback with Adlib, Tandy and Game Blaster.  BattleTech's PC Speaker digitized sound is more limited, because there is no voice in BattleTech whereas there is voice with every other sound chip.

While DOSBox can support digitized PC Speaker music reasonably well, it utterly fails to render digitized Tandy, Adlib or Game Blaster music.  Usually the result is muted, muffled or virtually inaudible.  This is one area where you still need real hardware to hear the music and sound effects as the creators intended.

Saturday, April 26, 2014

Capturing CGA, Tandy/PCjr. and EGA Video

It is not easy to capture true 16-color PC video.

One way to capture it is with a CGA card that has a composite video output.  The IBM PCjr. and Tandy 1000/A/HD/EX/HX/SX/TX also have composite video outputs, as does the IBM PC Convertible with the CGA adapter slice.  Some other laptops like the Tandy 1400LT also have CGA output.  Most EGA cards may have dual RCA jacks, but they are only connected to the EGA expansion feature port.  They are typically useless.

Composite video is necessary when trying to capture CGA artifact color.  Additionally, for capturing 40 column text it is usually adequate.  It is also good at capturing 160x200 graphics, since there is minimal artifacting going on in that mode.  Note that brown is dark yellow with a composite color connection. However, if you are trying to capture "pure" RGB 320x200x4 or 640x200x1, or 320x200x16 or 640x200x4, it is not suitable.  Composite video does not have the bandwidth to show pure colors in these modes.

CGA and its derivatives use digital TTL RGB.  The standard is also known as RGBI, with I standing for intensity.  One pin is devoted to the R, G, B and I signals.  When there is +5v on the line, that color will be displayed.  When there is Ground on the line, that color will not be displayed.  With the Red, Green and Blue signals, this gives you eight combinations, Red, Green, Blue, Cyan, Magenta, Yellow and Black and White.  The Intensity signal varies the strength of the colors, giving you a total of 16 colors.  CGA uses a 15kHz scan line frequency.

Other personal computers of the 1980s that supported RGB output, including the Commodore Amiga, Atari ST and Apple IIgs, support analog RGB output.  Consoles like the Sega Master System, Sega Genesis, Super Nintendo, Atari Jaguar, NEC Turbo Grafx 16, Playstation and an RGB modded NES or N64 also support 15kHz analog RGB.  Almost all arcade machines from the 1980s and into the late 1990s also support it.  With analog RGB output, the strength of each signal is based on the amplitude of a 0.7v Peak to Peak sine wave.  These systems typically use a15kHz scan line frequency.

The only other non-PC compatible device that supports CGA TTL RGBI is the Commodore 128.  Moreover, the C128 only supports this in its native video mode.  When emulating a C64, it uses a palette closer to the C64s.

All capture and conversion devices that advertise "CGA" like the GBS-8220 are using "CGA" only in the sense that they support a 15kHz horizontal scan line rate.  They expect an analog RGB signal.  CGA uses an RGBI signal.  If you connect the pins directly, you will only get 8 colors because it has no idea what to do with the I signal.  A simple passive adapter, like the one shown here, will give you 16 colors : https://sites.google.com/site/h2obsession/CBM/C128/rgbi-to-vga  However, color 6 will be dark yellow when it should be brown.  To get it to show brown, you need an active converter, such as the one here : http://he-insanity.blogspot.com/  That adapter will combine the separate CGA horizontal and vertical synchronization signals, which most 15kHz RGB outputs use.
  You can also purchase a similar kit here : http://www.microbeetechnology.com.au/vga_video_converter.htm but you will have to solder the board.  This has been verified to give a proper brown color.  There is another kit available here : http://gglabs.us/node/1619 which also shows proof of good colors.  There is another kit that is available from b i t - c 1 2 8 . c o m, but it does not give a proper brown.

After you have turned the digital RGB to analog, you will need to use a scan-line doubler to convert it to VGA and a capture card, for which there are many capture devices, or obtain an expensive PCI-E capture card that can handle 15kHz RGB analog video.  I have heard mixed reviews about the quality of the GBS-8220, which upscales 15kHz RGB signals into 31kHz VGA signals and is very common and not too expensive.  One suggestion is to use an XRGB-mini, the Framemeister.  The Framemeister will upscale analog RGB video into 720p, which can be captured by an HDMI capture card.

I would go for the latter, like this one : http://www.solarisjapan.com/sc-512n1-l-dvi-component-hd-and-dvi-capture-board/?setCurrencyId=1  Even though it is ridiculously expensive ($330!), it can handle just about anything, including VGA, HDMI and the like.  The StarTech PEXHDCAP is another PCI-E device that is very versatile and costs less than half as much : http://www.amazon.com/StarTech-com-Express-Video-Capture-1080p/dp/B007U5MGBE

The elgato game capture HD will capture 240p signals, which is essentially 15kHz scan rate video.  However, it only has composite, component and S-Video analog inputs.  You would need an RGB to Component converter for this device.  In essence you would need two converters.

If you want to capture 640x200x16 Tandy or EGA video, you will also need to use this method.  350-line EGA uses an unusual 21.8kHz horizontal refresh rate and 6-bit TTL RGB for a maximum selection of 64 colors.  VGA emulates 350-line EGA more-or-less perfectly and without double scanning.  It is just better to capture it directly from a VGA card.

Sunday, April 20, 2014

Tape Cassette Storage with the IBM PC and PCjr.

IBM include a 5-pin DIN cassette port in the IBM PC Model 5150.  This was intended for systems sold without floppy disk drives, which were still very expensive in 1981.  Until the PC was discontinued in 1987, you could still buy a 5150 from IBM without a floppy disk drive (Model 104).

The 5-pin DIN connector used a TRS-80 cassette cable to connect to a tape recorder deck.  The Radio Shack CCR-81 and 82 came with the cables and had both Mic and Aux input jacks.  IBM never made a cable for the PC, and the only software it ever supplied was IBM PC Diagnostics and Advanced Diagnostics.  Otherwise, use of the cassette port was intended solely for users of Cassette BASIC.  Cassette BASIC, built into the system, used its save and load commands to access the cassette drive.  In this IBM followed other 8-bit microcomputers of the day, as Cassette storage was the cheapest form of storage available for home computing.

When IBM released the XT, it removed the cassette port circuitry but kept Cassette BASIC in ROM for compatibility with Disk BASIC, Advanced BASIC (BASICA) and programs which relied on any of the three.  You could no longer save or load a program in Cassette BASIC.  However, IBM also used the same cassette interface logic for the PCjr.  This time, IBM released a cable to connect to the unique cassette port on the PCjr.

The IBM PC and PCjr. communicate with the cassette deck via Int 15.  At the low level, the audio coming from the deck to the system is digitized and read serially on bit 4 of the 8255 Port C.  Audio generated from the system to the deck is generated by 8253 Timer 2, which also controls the PC Speaker and then sent to the cassette.  The motor is controlled by bit 3 (and bit 4 in the PCjr) of the 8255 Port B.  The BIOS routine writes a 1 bit is with a tone of 1 millisecond (1000Hz), and a 0 bit with a tone of 0.5 millisecond (2000Hz).

To signal the beginning of a program to BASIC, there will be a "leader" of 256 bytes where all the bits are 1, followed by a 0-bit and then ASCII Hex 16.  Then a 256-byte data block will be written, followed by a 2-byte Cyclic Redundancy Check, and then more data + CRC blocks until the whole program has been written.  The maximum size that can be written is probably close to 64K, since that is the absolute maximum size of a BASIC program on the PC.

Typing SAVE"[program name] will save a BASIC program to the cassette.  Typing LOAD"[program name] in Cassette BASIC will instruct BASIC to start the cassette and search for the file.  It is up to the user to remember where the program is located.  If the system cannot "hear" a program, it will eventually quit trying and give the "Device Timeout" error message.  If there is some kind of problem with what it is trying to load, it will say "Device I/O Error."  You should keep the volume as high as possible when recording and playing back.

By using the cassette cable, you can record the output of the IBM PC's Speaker without any other adapter hardware.  You can of course plug the other end of the cable into a PC instead of a recording deck.  It is better to use the audio jack of the PCjr. to record sounds from it, as that jack can record from the PC Speaker, the 3-voice sound chip, the PCjr. Speech Attachment or the audio coming from the cassette.

Using the cassette port is may be a good method to record PC speaker music from a PC, but note that unlike the internal Speaker, the PC will generate a solid tone from the time it signals a system ready beep until software takes control of the PC Speaker.

One program that specifically supports the cassette port is Electronic Arts Music Construction Set.  This program has a setting to output 1 note PC Speaker or 4 note (tweaked) PC Speaker music, and has an option to output it to the internal PC Speaker or the cassette port.  4-voice output may sound better through a powered speaker than the internal speaker, but the basic sound will be the same.

One issue with the PC and PCjr. is that both support being connected to the Mic or Aux input of a tape deck.  The PC does so via a jumper on the system board near the PC Speaker header.  The jumper block is a 2x2 block.  If the jumper is placed across the pins closest to the M silkscreened on the board, then the audio will be sent at a level appropriate for a Mic Input.  If the jumper is placed across the pins closest to the A silkscreened on the board, then the audio will be sent at a level appropriate for a Line Input. The PCjr sends both the Mic and Aux input lines to the C connector, but the official cable only uses the Aux line. Some modern cassette recorders only come with a Mic Input.

Tuesday, March 18, 2014

The Monochrome Experience - CGA, EGA and VGA

A few posts back, I discussed some of the notable features of the Monochrome Display Adapter and Hercules Graphics Card.  In this post, I intend to talk about monochrome graphics on other adapters of the time, namely CGA (and its derivatives Tandy and PCjr.), EGA and VGA.  All these adapters could support monochrome monitors, although they were at their best when connected to color displays.

CGA, Tandy & PCjr.

At first, if you wanted to connect a CGA card to a monochrome monitor, you typically would use a monochrome composite monitor.  The RCA jack on the CGA card would be used.  If you were really lacking for a monitor, a black and white monitor would do in a pinch, but you probably would have to run the composite output of the CGA card through an RF converter box.  The resulting graphics would be nowhere near as sharp as with a straight composite connection.  Lets start with our test images :

Space Quest II - 320x200x4c "RGB" Mode (Mode 4)
Space Quest II - 640x200xMono "Composite Color" Mode (Mode 6 with Composite Color bit set)
Monochrome computer monitors typically would offer a high-contrast color : white on black, green on black or amber on black.  Text was sharp at 40 columns and tolerable at 80 columns, especially when the screen size was 12" or less.  Since composite monitors (in North America) refreshed at 60Hz, there was less need for the long persistence phosphors (and resulting ghosting) that was seen on the 50Hz MDA monitor.

The Compaq Portable used a 9" green composite screen.  The IBM PC Portable used a 9" amber monochrome composite screen connected to a CGA card.  Even though the IBM machine is close to a clone of the Compaq machine (which in turn is a clone of the IBM PC), their monitors are quite different.  The IBM monitor is a bog-standard monochrome composite screen and connects with an internal version of the RCA jack on its CGA card.  For this reason, you will see jailbars on the screen as you would see them on a color screen because the of the NTSC color decoding.

The screen on the Compaq is quite interesting.  The Compaq's video adapter supports both MDA and CGA graphics, and in the 80x25 text mode will act like an MDA card, not a CGA card.  Snow be gone!  The display is a "dual-sync" display apparently capable of accepting both a 15KHz and 18KHz horizontal scan frequency signal.  Otherwise the card acts like a CGA card.  The input must be able to accept the TTL signals from the CGA card and convert them to grayscale.  The resulting image is much sharper than on the IBM card (especially in 640x200 graphics) and will not show jailbars.

Early IBM CGA cards had a very basic monochrome support capability through the composite connector.  Essentially there for the low intensity eight colors would transform into black, gray and white.  For the high intensity colors, the same pattern would be seen, slightly brighter.  Later CGA cards took hue into account when converting RGB colors into luminances, so that there would be a unique shade for each of the 16 colors.  Here is an approximation of how the test images would look with the IBM PC Portable's amber monochrome screen and the early and late CGA cards.

IBM PC Portable with Early CGA Card, 3 Intensities Available
IBM PC Portable with Late CGA Card, 4 Intensities Available (note extra detail on the broom)
CGA Mode 6 was a 640x200 monochrome mode, where the active pixel could be a color, but the background color would always be black.  Any of the 16 CGA colors could be used, but typically the color would be white/light gray or white/high intensity white.  The IBM PC BIOS did not support selecting the foreground color in this mode, to do this you had to use the Color Select register.  It was not typically used because most CGA games preferred the more colorful if lower resolution Modes 4 & 5.  Often, if you saw these graphics, it was intended for color composite graphics.  The Wizardry games have intentional support for this mode, as do other games like SimCity, which benefits more from a high resolution than colorful graphics.

When the Color Composite bit was set in the Mode Control register, on a color composite monitor, the mode would display artifact colors.  On an RGB or monochrome composite monitor, the color composite bit made no difference to the graphics in a real CGA card.

CGA Mode 5 was a 320x200 color mode on an RGBI monitor, which a palette of cyan, red and white (intensity selectable).  On a composite monitor, whether color or monochrome, it displayed 2-3 (early CGA) or 4 (late CGA) shades of intensity, no color.  Mode 5 would typically be supported as an option if the game supported Mode 4 color graphics or Mode 6 color composite graphics or Tandy/EGA/MCGA/VGA.

Eventually, there would be monochrome TTL monitors that would accept a CGA signal.  In this case, the monitor converts RGBI into intensities of one color. Early LCDs were also monochrome devices, and brightness levels for each individual pixel were usually limited to on and off, although the IBM PC Convertible did advertise three levels of brightness for the CGA 4-color graphics modes.  The PC Convertible's LCD had a native resolution of 640x200 and stretched 320x200 graphics modes horizontally by two.  The aspect ratio would seem wrong except for applications intended for the Convertible's screen (typically from IBM).  Here are approximations of how the test graphics would look on the Convertible's LCD screen :

640x200xMono Color Composite Mode (Mode 6 with Composite Color bit set)

320x200x4 RGB Mode (Mode 4)
Tandy and PCjr always displayed 16 intensities of one color when displayed on a monochrome composite monitor.  It looks something like this :


EGA

IBM's EGA card could be connected to a color RGBI TTL monitor like the 5153 and support 8x8 text (Modes 0/1 and 2/3) and  color 200 line modes (Modes 4, 5, 6, D & E).  It could also a high resolution 6-bit RGB TTL monitor like the 5154 and support 8x14 text, color 200 and 350 line graphics modes (mode 10).  Finally, it could be connected to a monochrome TTL monitor like the 5151 and support text at 9x16 (Mode 7) just like an MDA card, and additionally supported a 640x350 line monochrome graphics mode (Mode F).  A real MDA monitor must be connected to use Mode F, which was similar to the Hercules Graphics in that it allowed each pixel to be turned on or off.  It did not work in the same way as Hercules, and far fewer games supported it.  While Hercules graphics were 720x348 pixels, usually only 640 horizontal pixels were actively used in Hercules as it was much easier to convert from 320 pixel graphics modes, so Hercules did not often have an advantage in resolution.  However, since IBM derived the graphics mode from the text mode, each individual pixel can be made to blink or display in intense video.  I do not know of any game which may have supported this functionality.  Mode F is the only graphics mode supported when the EGA is connected to an MDA monitor.

Microsoft Flight Simulator 3 - 640x350x16c Mode 10
Microsoft Flight Simulator 3 - 640x350xMono Mode 0F
In order to use an MDA monitor with an EGA card, the dipswitches or jumpers on the card must be set correctly.  Switch 3 must be ON, switches 2 & 4 must be OFF.  The EGA card, when connected to an MDA monitor, can be used with a CGA or a secondary EGA card connected to a color monitor.

Even though EGA can be connected to an MDA monitor and at first glance look identical to the MDA's text mode, using unusual text character attributes can show differences compared to the MDA.  This can be seen in 101 Monochrome Mazes, a game IBM released strictly for the MDA.  When you run this game on an EGA or VGA card, you will not see exactly the same "graphics".  This game uses text attributes that fall outside the canonical 16 IBM valid MDA attribute choices for the EGA and VGA.  Compare the following :

101 Monochrome Mazes MDA

101 Monochrome Mazes EGA/VGA
MCGA/VGA

When IBM released its PS/2 computers, it advertised monochrome analog high scan-rate monitors like the 8503 alongside more expensive RGB color analog high scan-rate (VGA) 8512 or 8513 monitors.  Systems with built in monitors like the PS/2 Model 25 could be ordered with a monochrome or color monitor.  The price difference was several hundred dollars at the beginning, so monochrome monitors were much more attractive for certain business and educational purchasers.

IBM's early VGA monitors designated four pins in the HD-15 VGA monitor connector to inform the card whether it was a mono or a color monitor.  Three of the bits would inform the VGA whether a monochrome monitor, a color monitor or an 8514 monitor was being used.  Later, these bits would be reused.  A real IBM monochrome monitor and VGA would output pixel information on the green pin only.

VGA used an 18-bit color  palette, with 6-bits for red, 6-bits for green and 6-bits for blue.  Each pixel on the screen could be set to any of 256 colors from the 18-bit palette.  When the monitor informs the card that it is a mono card, the VGA will convert the 18-bit color value into a 6-bit grayscale value by color summing the R, G and B values.  In this manner, 64 intensities of the monitor color could be displayed using the 256 color graphics mode 13.  In other modes, which support no more than 16 colors on screen at any one time, up to 16 grayscale shades would be available from the 64 that the monochrome monitor and the VGA could display.

Conquests of the Longbow - 320x200x256c Mode 13 Color
Conquests of the Longbow - 320x200x"256c"Mode 13 Grayscale
By the late 80s and early 90s, monochrome plasma displays were common on laptops, and this design allowed them to give some definition to what would otherwise have been color graphics.  However, this display technology was somewhat limited, as the gas plasma display in the IBM PS/2 Model P70 (a luggable) could only manage 16 shades of the orange color of that display.  In 320x200, IBM would selectively dither a 2x2 block of pixels (remember that the display stretches 320x200 to 640x400) to simulate the 64 intensities that should be available.

Some VGA games, including many of Sierra's SCI engine adventure games, had a driver which Sierra claimed would allow for up to 256 shades of "gray".  This was nonsense, the hardware was limited to 64 shades of gray due to the 6-bits per color regardless of being displayed on a monochrome or color VGA monitor.  This driver would show the same graphics whether used on a color or a monochrome VGA monitor.  However, the advantage to using this driver on a monochrome monitor is that by using only the grayscale options in the full VGA color palette, Sierra could ensure a good representation of the color graphics in grayscale and need not subject its color graphics to the VGA conversion formula.

Nonetheless, Sierra's driver did a very good job of preserving the detail of the color graphics for those forced to use color screens.   Pinball Fantasies also supported a "mono" graphics display setting, using up to 64 grayscale shades in the Mode X modes it supports, 320x240 amd 360x350.

Pinball Fantasies - 320x240x256c Mode X Color
Pinball Fantasies - 320x240x"256c" Mode X Grayscale (note the loss of detail on the table art)

Saturday, March 8, 2014

Joystick Problems with DOS and Approaches to the Problem

IBM's Game Control Adapter was designed as something of an afterthought, a simple to use expansion card (for a programmer) as a way to provide for connecting a low-priority input device.  It sat at port 201, supported four digital inputs, intended for buttons and four analog inputs, intended for paddles or joystick axes.

When it was released as one of the original expansion cards for the new IBM PC, it was perfectly adequate for the time.  The Apple II joystick port operated in the same way but only supported three buttons.  The Tandy Color Computer also supported four analog axes and four buttons, and its joysticks were later used in the mostly-PC compatible Tandy 1000 line.  The Commodore VIC-20 only supported one Atari-style joystick or two Atari-style paddles.  Only the Atari 400 and 800, with their four joystick ports, supported more game inputs.

In IBM's design, a joystick is a pair of potentiometers which are turned by moving the joystick.  Each three-terminal, 100 kOhm potentiometer is connected through the joystick cable to a +5v line and a capacitor on the game control adapter.  This capacitor is tied to an input on the NE558 Timer IC.  The Timer compares the capacitance on its input with a reference capacitance, and outputs a 1 when the capacitance is not equal and a 0 when the capacitance is equal.  The resistance value from the potentiometer determines how quickly the capacitor on the input will be charged.  If the capacitor is turned to a lower resistance, the capacitor charges more quickly, and if turned to a higher resistance, the capacitor charges more slowly.

When the programmer wants to read the joystick position, he writes to port 201.  This discharges the capacitors.  Then the programmer reads and reads port 201 until there is a 1 for the axis he is trying to measure.  The time taken for the value to become a 0 represents the position of the joystick.  Many games have joystick calibration prompts requiring the player to move his stick to its maximum positions and its center to obtain the timing required to properly calibrate the stick.

Eventually the limits of the design began to emerge.  The first was that the joystick had to be read several times to get an accurate measurement of the stick's position.  This took a substantial portion of a 4.77MHz  8088 CPU's time.  However, when there was only one CPU and one speed used in PC and compatibles, this was just an inconvenience, because the timing would be equivalent on all machines.  For many simpler games, which relied on digital controls, fine measurement of the joystick axes was not an issue.  However, when faster CPUs and clock speed began to emerge, joystick routines would consequently run faster.  Thus routines would take 20% of the CPU's time an 8088 may only take 10% or less of the CPU's time on the more efficient 286.  When CPU speeds began increasing to 6MHz, 8MHz and beyond, routines that were designed for the IBM PC would complete themselves far too quickly to get an accurate read of the joystick.

A second issue with the inherent accuracy of the components used to determine the joystick's position. Linear potentiometers such as used in the PC are not known for their rigorous accuracy.  While the adjustment dials on each axis can help, they can shift or loosen over time.  Moreover, the housings containing the resistive element and wiper are not hermetically sealed or anything close to it.  Dust and dirt and oils over time can seep in and cause jittery or inaccurate reads.  Wear on the resistive element can make it harder for the stick to give an accurate resistance.

IBM gave a formula to measure the time the stick would take to charge the capacitor at any given resistance (0-100).  When it released the IBM PC AT, with its 6MHz 80286 CPU, it introduced Int 15, subfunction 84 to give a BIOS routine to read the joystick.  Unfortunately, the clone PC makers had already spent substantial time and money cloning the original IBM PC BIOS, and this new BIOS call did not necessarily make it into every clone.  Tandy 1000s do not support it.  The advantage of the function was to give reliable reads because the routine was tied to the processor and speed(s) which the system board was designed to run.

Other companies tried to offer solutions to these problems.  Tandy 1000 joysticks used the design from the Tandy Color Computer.  Instead of using the potentiometers as variable resistors, Tandy uses them as voltage dividers by connecting the third terminal to ground.  Inside the machine, the voltage is compared to a voltage ramp which, when port 201 is written to, is charged from 0v to +5v in a set period of time.  When the voltage ramp is greater than the voltage from the joystick, a 0 is reported.  This method has been said to give more precise and less jittery results than the timer-resistance method used on a true PC.

The Amstrad PC-1512 gave a unique solution to the joystick problem.  It supported one Atari-style digital joystick with two buttons.  This joystick plugged into the keyboard.  The directionals and buttons for the joystick were assigned to unique keyboard scancodes 7C-77.  However, when reported by the BIOS, pressing the directionals would give scancodes assigned to the cursor keys on the numeric keypad.  Since many, many games used the keypad cursor control keys for movement, this was a highly compatible way to implement digital input.  It would not work if the program read directly from the keyboard input port instead of the BIOS unless the program was Amstrad-aware.  The two joystick buttons could be assigned to represent any key through the use of a program which would write to the Amstrad's non-volatile RAM.  This memory would retain the buttons' settings until the next time the buttons' settings were changed.

When the Sound Blaster came along, it implemented a standard joystick port.  Until the Sound Blaster 16, the port did not change.  In the Sound Blaster 16, the old DIP-style NE558 timer was replaced with surface mounted components, which presumably have lower latencies which work better with faster processors. The Gravis Ultrasound implemented a hardware version of a speed adjustable gameport, and came with a program to adjust the sensitivity of the gameport without the use of an external dial or jumper.

Other companies made speed-adjustable gameports.  In these gameports, a dial would be routed outside the computer to adjust the speed of the gameport.  In the Thrustmaster ACM Game Card, the dial was a potentiometer which would adjust the resistance going to the reference capacitor.  The ACM Game Card had a second joystick interface at port 209, requiring a second NE558.  The dial controls the resistance for both reference capacitors.

The Gravis Gamepad was very popular in the early 90s because it provided four buttons and a NES-style D-pad.  However, inside the Gravis Gamepad were transistors to convert the digital values of a D-pad into the analog resistance values expected by the PC gameport.  Essentially pressing one side of the pad would give the maximum resistance value of the axis, the other side would give the minimum resistance value and not pressing the pad would give the middle of the resistance value.

Later joysticks, like the Gravis Gamepad Pro and the Microsoft Sidewinder gamepads would give options for truly digital controller with more than four buttons.  These sticks would use the gameport to send binary codes to the program.  The downside is that a DOS program had to have specific support for the gamepad, or the digital functionality of the gamepad would only work in Windows 95 with a driver.

Another late innovation was to take inspiration from computer ball mice.  Computer mice and trackballs use optical rotary encoders to track movement, just like the dials on most arcade machines, the Atari driving controller and the N64 thumbstick.  Reading from the encoders is much more reliable than the timer-potentiometer method and not prone to speed sensitive issues or the same kind of wear.  The Microsoft Sidewinder 3D Pro had this function and many buttons, but unless a DOS program understood it, it had to emulate the analog potentiometer method

Once IBM ceded leadership of the PC market, no other company came up with a standardized digital gameport solution.  Eventually, USB input devices of all kinds, gamepads, joysticks, driving wheels, rudder pedals, throttles, yokes put all the speed issues to software.  However, USB really didn't catch on until Windows 98, so for almost twenty years game players had to deal with the analog gameport.

Saturday, March 1, 2014

Evolution of 8088 PCs

From the first IBM PCs, there was a steady stream of innovation and improvements to PC compatible computers using an 8088 CPU.  However, there were also some bumps along the way.  In this entry, I will try to identify many of the positive and negative features of the main 8088 members of the IBM PC and Tandy 1000 families.

1.  IBM PC Model 5150 First Version

IBM PC BIOS 1st & 2nd Revision - The original PC BIOS was the byword for compatibility.  

Chassis - two full height drive bays, unique system board mounting, 13" maximum expansion board length, PC cone speaker.  

System Board & Expansion Cards - Use of off the shelf components or TTL logic chips, configuration by two rows of dipswitches.

Power Supply - The form factor would be the same for the IBM PC/XT and this established a standard "AT Power Connector", passthrough port for monochrome monitor

Expansion Slots - The 8-bit PC or XT slot was introduced.  Five slots were better than most other home computers at the time.  However, the floppy disk controller, the video card and memory cards each took up a slot, so expansion was limited.  

Cassette Interface - Important for saving programs in Cassette BASIC, used in Music Construction Set.  5-pin DIN connector, used TRS-80 cassette cables

Diskette Drive Adapter - Standard equipment, supports all double density drives, 34-pin card edge connector.

Diskette Drive (Single Sided) - Tandon TM100-1s were used in the beginning, supporting 160KB or 180KB per side.  4-pin molex connector used.

System Board Memory - 16-64KB on the motherboard, 16KB minimum, expandable to 544KB via expansion slot memory upgrades, first bank soldered, remaining three banks socketed.

System ROM - 6 x 8KB sockets, five used for BASIC and BIOS.  Empty socket, but requires an adapter for EPROMs.

IBM PC-DOS 1.0 - Included Disk BASIC and Advanced BASIC, loads COMMAND.COM, IBMIO.COM and IBMDOS.COM.  

Asychronous Communications Adapter - 8250B UART serial port, switchable between COM1 and COM2, DB-25 male connector.  Most can work in XT Slot 8.

Printer Adapter - Printer port, 378H (or 278H with modification), DB-25 connector female connector

Game Control Adapter - DA-15 female connector, joystick support (third party), four axes and four buttons.

Monochrome Display and Printer Adapter - DE-9 female display connector, 80-column text, 9x14 character cell, TTL monochrome displays only

IBM PC Display Model 5151 - Display for the above adapter and later Hercules Graphics Card, powered through PC power supply, long persistence phosphor, monochrome green screen, brightness and contrast controls.

Color/Graphics Adapter - CGA, 16 colors selectable, 4-color palettes, 40 & 80 column text mode, composite color output, artifact color, 320x200 and 640x200 graphics modes, RCA composite video jack, light pen support, RF switchbox (third party) support

Math Coprocessor - Unidentified at first, empty 40-pin socket for 8087 upgrade.  

IBM PC Keyboard - 83-key first standard keyboard, Function keys on side, buckling spring technology, 5-pin DIN connector

IBM Graphics Printer Model 5152 - Epson MX-80 clone, parallel printer, dot matrix printer

2.  IBM PC Second Version

IBM PC BIOS 3rd Revision - Fixed bugs, added support for 640KB of memory, bootable option ROMs

IBM PC-DOS 1.1 - Double sided disk drive support, used Tandon TM100-2As.

Double sided disk drives - 320K and 360K per disk supported

System Board Memory - 64KB to 256KB on system board, now expandable to 640KB via expansion slot upgrades

Bootable ROM - Devices can have a boot ROM and the BIOS will allow the device to install its own boot handler, booting directly to a hard drive now possible.  EGA and VGA support possible.

3.  IBM PC/XT Model 5160

System Board - Configuration now only by one bank of dipswitches.  Memory autodetected, tested and counted at bootup.  Faster bootup compared with PC.

Cassette Interface - Eliminated, making Cassette BASIC vestigial for programs that require it

IBM PC Color Display Model 5153 - Official CGA monitor (.31 dot pitch), 16 color support (intensity bit not properly supported on some third party monitors), color #6 brown, 14/13" viewable screen, vertical hold and size controls.  

IBM Expansion Unit Model 5161 - Adds seven more ISA slots, and official method to add hard disk drive to PC (whose power supply was not considered to output sufficient power to supply hard drive requirements)

IBM Graphics Printer Model 2 - Printer capable of supporting all IBM Extended ASCII characters.  Earlier printer did not.

Expansion Slots - Standard 8 expansion slots, distance between slots standardized for what would become known as ISA slots.  Slot 8 is on custom bus and only works with special cards (like the Async card).  Only 6 slots can support full length cards due to the case.  

Revised Expansion Card Brackets - Early PC brackets are black and color and are wider than later silver brackets.  This can be a problem using cards side by side in later systems.

Power Supply - 130W, sufficient to support a hard drive and more

Fixed Disk Adapter - Built around Xebec chips, standardized XT hard drive controllers, including XT-IDE drives, supports two MFM drives, slow 6:1 interleave.    

Fixed Disk - 10MB Seagate ST-412, Cylinder/Head/Sector addressing, MFM, Full Height.

System Board Memory - Same four banks as IBM PC, but all four banks socketed

IBM PC-DOS 2.0 - 9 sector floppy disks supported for 180KB per side or 360KB per disk, device driver support, revised file handling system, hard disk support (15MB maximum)

ROM Sockets - Support Standard 32KB EPROMS for 64KB ROM (only 40KB used on XT first BIOS)

Secret Memory Expansion - By adding a 74LS158 chip to socket U84, jumpering E2 and replacing the 64Kx1 RAM chips in banks 0 and 1 with 256Kx1 chips, you can have 640KB on the motherboard.  Later XTs come with the mod.

4.  IBM PC Portable

Composite Monochrome Monitor - 5" amber screen, composite connection to CGA card

Half-Height Diskette Drive - Two supported

Portability - For 1983, this meant a sturdy handle, a slightly modified keyboard that could attach to the chassis, and a power plug.  System weighed almost 40 pounds.  Only two full length cards supported

5.  IBM PCjr. Model 4860

Cartridge Slots - For games and software, up to 64KB for each cartridge, two supported.  Also used for Cartridge BASIC.  Only appears on PCjr. and JX.  

Sidecar Expansion Bus - Attach expansion boards without having to open computer, including parallel port and memory expansions.  It lengthens the physical footprint of the system.

Cordless Keyboard - IR keyboard powered by 4xAA batteries and allowing for cordless operation 20-feet away, line of sight must be maintained, keyboard cord optional.  

Internal Modem - 300 baud Novation non-Hayes compatible modem.  Special internal slot connector, standard RJ-45 port.

System Board Memory - 64KB on motherboard, 64KB via internal expansion card, up to 736KB total via sidecar.  System designed for 128KB, program must support extra RAM (Flight Simulator 2.0) or DOS must have a device driver to load more RAM

Enhanced CGA - Adds 160x200x16, 320x200x16 and 640x200x4 modes, but only BIOS level CGA compatibility

IBM PCjr. 3-Voice Sound - 3 square wave channels plus noise, 11-bit frequency selection, 4-bit volume control per channel, periodic and white noise selectable at four frequencies.  Requires external speaker of some kind

System Configuration - Totally jumperless and dipswitchless, internal expansion cards and external IBM expansions automatically detected, memory detected (up to 640KB) and configured via software

Diskette Drive Controller - Only one drive supported, accessed at different ports, uses 34-pin header

Proprietary Expansion - External ports use unique BERG connectors.  

Cassette Interface - Last PC compatible system to include a cassette interface.  Only official IBM cassette cable is for the PCjr.

TV Connector - Only official IBM RF switchbox is for the PCjr.

Joysticks - Gameport on systemboard, supports two joysticks without a y-adapter.  Only official IBM Joystick of the PC line is for the PCjr.  Joysticks function the same as PC joysticks, just have a different connector.

Serial Port - Includes 8250B Serial Port, official IBM DB-25 adapter available.  Uses COM2 resources, 278H/03I, but BIOS calls it COM1 if internal modem is not installed.

Power & Cooling - 33W power card came first, followed by 45W card.  45W sufficient to power three sidecars.  Only system here able to be run silently without risking overheating the power supply since the fan cools the disk inside the disk drive.  

IBM PCjr. Color Display Model 4863 - Higher dot pitch (.42) than the PC Color Display, but also includes a speaker and uses the PCjr. video connector.

IBM Compact Printer - IBM's official serial printer, uses PCjr. serial connector, can use an adapter for any serial port, low cost thermal printer, surprisingly decent.  

IBM PCjr. Speech Attachment - IBM's implementation of TI's Speak and Spell technology and more. Built in vocabulary.  Capable of recording and playback of digitized sound.  Later emulated by many devices.  

Compatibility - Compatible with most IBM software, but notable exceptions include Microsoft Decathalon, 101 Monochrome Mazes and Microsoft Flight Simulator 1.x.  Usually not so compatible with 3rd party software not written to take the PCjr. into consideration.  

IBM PC-DOS 2.1 - Adds full BASIC support for PCjr's advanced graphics and sound, but requires Cartridge BASIC to work at all.

6.  Tandy 1000 Model 25-1000

Expansion Slots - 3 standard XT slots, but only 10" cards or shorter supported

PCjr. Features - Brought over the Enhanced CGA and 3-Voice sound from the PCjr.

Compatibility Improvements - Unlike the PCjr., the Tandy 1000 could run most PC software that accessed the hardware directly.  

Tandy 1000 Keyboard - 90 keys, including separate cursor keys and F11 and F12 keys, but support for these keys was hit or miss.  

DMA & Memory Upgrades - Upgradeable to 384KB and DMA with one Board, 640KB with a second board.  Full DMA support compared to PCjr (which only allowed DMA for floppy, and available via 3rd party upgrades only)

Printer Port - Built in, but limited and uses card edge connector

Power Supply - 54W, considered adequate for two drives and three expansion cards

Tandy CM-2 High Resolution RGBI Color Monitor - Later known as the CM-10 and CM-11, this was the Tandy equilavent of the IBM PC Color Display, although the dot pitch (.43) is not quite as sharp as IBM's (.31)

Tandy MS-DOS 2.11 - GW-BASIC supports enhanced graphics and sound of the Tandy 1000s, no FDISK to partition hard drive.

7.  Tandy 1000A Model 25-1000A

Coprocessor - Adds 8087 Math Coprocessor Support

286 Express Upgrade - Compatible without special daughter board the plain 1000 requires.

8.  Tandy 1000HD Model 25-1000HD

Fixed Disk Drive - 10MB half-height model and Xebec controller that could use IRQ2.  IRQ5 is standard on XTs, but the Tandy uses it for a vertical retrace interrupt.

DMA & Memory - Came with one board that gave DMA and allowed you to upgrade to 640KB with one board, also supplied a PLUS connector (see below) to add another expansion device like a serial card without taking up another slot.  

Tandy CM-4 RGBI Color Monitor - Low cost RGBI monitor with a large dot pitch (.62).  Not recommended for 640x200 graphics.  

9.  IBM PC/XT Revised

101-Key Keyboard - IBM made Model M keyboards work quite reliably on an XT with 2nd and 3rd BIOS.  On a first BIOS XT or any PC, the odds are much lower that it will work at all.

Improved Drive Support - BIOS support in 2nd and 3rd BIOS for 3.5" double density and 5.25" high density drives, but a third party floppy controller is required for the latter.  

System Board Memory - Supports 640KB on the motherboard without modification.

Mounting Hardware - IBM supplied late XTs in a dual half-height floppy configuration and included mounting hardware to fit them inside a full height bay.  

10.  IBM PC Convertible Model 5140

LCD Display - Simulates something like a 2-color CGA display, but in 320x200 (stretched to double width) can manage four intensities of color.  Also can emulate the MDA.  

Diskette Drives - IBM's introduction of 3.5" double density disk drives.  Would take until the PS/2 for 3.5" disks to fully catch on.  

Keyboard - 78 key keyboard, functions similar to PCjr. keyboard but improved by using IRQ1 for keyboard interrupt and not using CPU to deserialize scancodes.  

Internal Modem - Slot inside for 1200 baud version of PCjr. modem, may or may not be Hayes compatible.

Expansion Bus - XT bus with multiplexed address and data lines.  

Battery Operation - Uses CMOS 8088 CPU, SRAM to save power and allow for battery operation, system can be suspended indefinitely.   

Attachable Printer - Thermal printer, more advanced than PC Compact Printer.

Display Slice - Provides full CGA compatibility to external RGBI monitor.  Connector supports IBM PCjr. Display or IBM PC Convertible Color Display Model 5145.  RCA jack can be used with color composite monitor.  IBM also introduced the 9" IBM PC Convertible Monochrome Display with green phosphor.  

Portability - Although still large and bulky by modern standards, this is a true laptop.

Convertibility - Can remove LCD to place unit underneath standalone monitor.  

11.  Tandy 1000 EX Model 25-1050

Dual Speed CPU - 7.16MHz/4.77MHz, selectable at bootup or via Tandy MS-DOS Mode command.

Slimline - Takes up less desk space and the keyboard is built into the system unit just like an Apple IIc.  (Does not apply to SX) 

Selectable Boot Drive - You could boot to the internal 5.25" floppy drive on an external 3.5" floppy drive 

Expansion Bus - Uses a 62-pin version of the XT expansion bus, cards (called PLUS cards) stack onto each other, but must be short.  (Does not apply to SX)

DMA and RAM Expansion - One PLUS card upgrades system to DMA and allows for 640KB

External Drive Connector - For connecting a second 5.25" floppy drive or a 3.5" floppy drive

Earphone Connector and Volume control - When you want a quiet PC (not on SX)

12.  Tandy 1000 SX Model 25-1051, 1052, 1054

Dual Floppy Drives - 2x360KB Floppy drives on Model 25-1051 and 1054, boot floppy can be selected on bootup.

Expansion Slots - Five expansion slots provided without any need for memory expansion

Memory Expansion - Upgrade from 384KB to 640KB with 8 x 256Kx1 chips

DMA - Included on all machines (optional on EX and HX)

286 Express - Official 286 speed upgrade, 8KB cache that can be disabled, supports 80287 coprocessor.  Software controlled. 8088 still available for programs that will not run on a 286 or on the faster speed

Tandy MS-DOS 3.2 - Supports 3.5" drives, FDISK partitioning, 3 extra 32MB DOS partitions using MLPART (non-standard)

Power Supply - 65W, considered adequate for two drives and five expansion cards

13.  Tandy 1000 HX Model 25-1053 (all the EX features plus) :

Boot Speed and Menu - Nearly instant boot to an optional menu where you can select the boot device (floppy, DOS, Deskmate)

EEPROM - Save settings permanently without dipswitches or jumpers.

DOS-in-ROM - Enough DOS 2.11 is on the system that you will not usually need to insert a DOS disk when loading programs off floppies.  Disabled if a hard drive is installed.  Also supports 3.5" disk drives natively, which regular DOS 2.11 cannot.

Power-in-drive cable - No separate molex or mini-molex connector required.  A headache for wanting to use standard drives.

Thursday, February 20, 2014

Monochrome & Hercules Graphics Aspect Ratio and Scaling

The IBM Monochrome Display and Printer Adapter output 80-column text with a 9x14 cell size.  This gives 720x350 pixels.  The Hercules Graphics Card is a clone which adds a 720x348 graphics mode.  The aspect ratio of the graphics mode, with perfectly square pixels, is 2.07 : 1.  However, the IBM Personal Computer (Monochrome) Display 5151 has a less horizontally rectangular tube that measures about 9.5 inches by 6.5 inches from one edge of the screen to the other.  The diagonal display measures about 11.5 inches.  This would give an aspect ratio of 1.46 : 1.

The active display area does not reach the edges of the monitor.  I measure it to be about 8.75 inches by 5.5 inches.  This gives an aspect ratio of 1.59 : 1.  The graphics mode loses two lines and thus the aspect ratio is a sliver wider.  Coincidentally, this is the square pixel ratio of CGA 320x200. There are no horizontal or vertical size or hold adjustment knobs on the monitor, only brightness and contrast.  Here is a screenshot showing, somewhat faintly, the visible screen area on a 5151 :


DOSBox can take screenshots of the Hercules Graphics mode.  Here is one such screenshot, untouched : 


While it is a bit squashed, doubling the vertical resolution (720x696), as some Mobygames screenshots do, is just not appropriate.  If you do that, you will have an aspect ratio of 1.03 :1.  As you can see from the image of the real monitor, the visible screen area is not a nearly-perfect square or anything near it.  

While it is not perfect, the best compromise is to increase the vertical size of a screenshot by 25% using nearest neighbor interpolation.  If you resize the screenshot to 720x435, you get this result :


This gives a 1.66 : 1 aspect ratio, which is far, far closer to the ideal ratio while keeping upscaling artifacts to a minimum.  

Starflight's effective resolution is 160x200, which is fairly common with older games.  If you use a game that has a native 320x200 resolution, the artifacts can be a little more visible : 

Maniac Mansion Enhanced Version - Original
Maniac Mansion Enhanced Version - Resized
Leisure Suit Larry 3 - Original
Leisure Suit Larry 3 - Resized
One issue to note is that most PC games use a native 320x200 resolution, and their Hercules drivers often leave noticeably large borders.  Many, if not most games use double the horizontal resolution to 640 pixels, using an algorithm similar to what they would use for 640x200 CGA graphics.  Starflight's effective resolution with Hercules is 640x200.  The regular 16-color resolution of Maniac Mansion's graphics window is 320x128, so with Hercules they simply doubled it to 640x256.  The text size remains 8x8, so there is an unused section at the bottom of the frame.  Sierra did something similar with their AGI games.  Their graphics window is 320x168, so with Hercules they doubled that to 640x336 and used the extra 12 lines for the status bar.  Instead of keeping the 8x8 font, they used an 8x12 font unique to the Hercules driver.  Typing pauses the action like SCI games, whereas it does not in all other graphics modes.

For Leisure Suit Larry 3 and other SCI0 games, the native graphics area is 320x190 in 16-color modes with the status bar taking up the remaining 10 lines. They could not double up on the graphics because they only have 348 lines to use.  What Sierra did here is to increase the horizontal resolution of the whole screen to 640 and the vertical resolution to 300, effecting a 150% increase in the vertical resolution (including the status bar).  Every other line is repeated.  This may not give the nicest look, this was probably the simplest approach to take, which was important when dealing with taxed 8086 and 286 machines.  Also, there is is no way to decrease the brightness of each individual lit pixel, so traditional filtering techniques will not work.

Here are a few more screenshots showing how non-native Hercules games fit within the screen :





Tuesday, November 19, 2013

M.U.L.E. - The PC Port on Real Hardware

1985 was the last year that IBM was known to have published any games for its IBM PC family.  It had seen games as one of the things that consumers could do with their PCs, and had released Microsoft Adventure at the launch of the original IBM PC Model 5150.  However, by 1985 IBM no longer looked to the home consumer market as a primary market, and thus the number of games it published dwindled to nothing.  One of the last titles it published was a port of Electronic Arts and Ozark Softscape's classic M.U.L.E.  This port was ported by K-Byte Software and released very quietly.  In fact, until 2012, no one had probably played it for 15 years.  It remained a mystery and completely unavailable until someone opened up a box of old IBM games, found it, became aware of its significance and allowed it to be cracked and distributed.  The story is recited here : http://www.worldofmule.net/tiki-index.php?page=IBM+PC  Others have analyzed it for differences between it and the Atari 400/800 original and Commodore 64 port, read here : http://bringerp.free.fr/forum/viewtopic.php?f=1&t=166  In this port I will discuss how it actually plays on the systems it was intended for.

Speed

M.U.L.E. for the IBM PC requires 128KB of RAM and a CGA card.  It only supports PC speaker sound and music and one physical joystick.  The cover explicitly lists the IBM PC (Model 5150) IBM PC/XT, IBM PC Portable and IBM PCjr. as supported systems.  Note that it does not mention the IBM PC AT, which was released in 1984 and used a 6MHz 80286 CPU.  This game is speed sensitive and the game will probably run to fast on the AT, which is roughly three times as fast as the PC or XT.  Running on more modestly upgraded or faster systems, like a V20 IBM PC, XT or PCjr. or a Tandy 1000EX, SX or HX at 7.16MHz will not give such a noticeable effect on speed to make the game unplayable.

On the packaging, there is no explicit mention of the IBM Personal Computer AT.  This is probably not an oversight, as some other IBM released games from 1984-85 explicitly included the AT in the list of supported systems on the box.  The AT was released in 1984 and thus its omission was almost certainly intentional.  (K-Byte does not seem like an outfit that could afford an AT).  The game adjusts its speed for a PCjr., so if you have an exotic speedup method in your PCjr. (V20 is fine), the game will probably run too fast.

Graphics

IBM PC with CGA on an RGB Monitor



On an IBM PC, XT or 100% compatible system with a CGA card, the game will use the 320x200 Mode 4, Palette 0 (cyan, magenta, white) in low intensity with a bright white background/border.  While the game is playable on an RGB monitor, it was clearly meant to be connected to a TV or color composite monitor.  Instead of stripey cyan and magenta graphics for the four players and their plots, composite color gives brown-gold, orange, red and light blue.  It seems clear that a late CGA card was intended because the text (white/light gray against bright white) on a real color composite monitor or TV is almost totally illegible with an early CGA card (without adjustments to the brightness and contrast).  EGA and VGA cards probably will not display the intended colors.

IBM PC with Old CGA on a Composite Monitor 



It was a long-standing myth that this game was either released solely for the PCjr. or took advantage of the PCjr.'s advanced graphics and sound capabilities compared to the IBM PC with CGA and PC Speaker.  The sound is exactly the same on either the IBM PC or PCjr.

IBM PC with New CGA on a Composite Monitor



On an IBM PCjr., the game uses a 320x200 resolution four color mode with colors similar to CGA.  The bright white background is the same, but the RGB colors are now light cyan, light magenta and white.  The pixel patterns are not the same as with a non-PCjr., but still show that the game was meant to be displayed on a color composite monitor or TV.  The PCjr. artifact colors the programmers chose are not as distinct as on a CGA card, there are two shades of magenta or purple and two shades of cyan or blue-green to choose from.

IBM PCjr. with an RGB Monitor



Control

This section requires a digression.  When M.U.L.E. was released for the Atari home computer systems in 1983, officially it could only run on the Atari 800 with 48KB of RAM.  The Atari 400 was not easily upgradeable to 48KB (but when upgraded was indistinguishable from an 800 to software) and the 1200XL, 600XL, 800XL and later machines only had two joystick ports.  For the Atari original, there was no keyboard control of the characters.  At least one joystick was required, and a pair of paddles could be used by two players in the auctions.  If there were fewer joysticks than human players, the players had to share the joystick for each player's main turn.

IBM PCjr. on a Composite Monitor



The Commodore 64 only had two joystick ports, and its port of MULE did not support paddles.  Thus, players three and four had to use a pair of keyboard keys during the auctions, and the joysticks had to be shared during the player's main turns.

The IBM port only supported one joystick, notwithstanding the IBM Game Control Adapter could support two joysticks with a Y-splitter and the IBM PCjr. had two distinct joystick ports.  Unlike the Atari and Commodore versions, it did not require a joystick to play the game.  If you did not have a joystick, the arrow keys could be used to control the player during his or her main turn.  Only the main four cardinal directions could be used, the "diagonals", 1, 3, 7 and 9, do nothing on the PC keyboard.  The PCjr.'s keyboard has no numberpad, only dedicated cursor keys.

For the auction phase, the keyboard controls for each player on the IBM PC are as follows :

Player -  1  2  3  4

Up     - F1  W  O  

Down   - F5  X  .  

On the PCjr., the keyboard controls are different, due to the differing layout of the PCjr.'s keyboard :

Player -  1  2  3  4

Up     -  W  Y  [  

Down   -  Z  B  /  

There is a game crashing bug when selecting joystick control with four planeteers.  The Alt key is pressed to determine which player will use the joystick.  However, if players 1-3 use the joystick, the game will not allow you to press key to select player 4.  Player 4 must use the joystick in this case.

This game was designed for the IBM PC 83-key keyboard.  On the 83-key keyboard, Player 1's auction up key, F1 is above the down key, F5, by one key, just like the keys for Players 2-4.  On a 101-key keyboard, F1 is three keys to the left of F5.  This arrangement simply does not work well with three other people.

The keyboard handling takes some getting used to.  The Enter key corresponds to the joystick button.  When doing anything requiring a button press like selecting a land plot, beginning your turn or installing a M.U.L.E., it is best to hold the button down until the game acknowledges the input.

The Alt key functions essentially as a speedup key in the game.  It can end auctions after everybody has bought and sold what they can.  It can bypass the summary screen and the chance animations.

The Esc key acts as a pause key.  Unfortunately, it will cause the game to freeze on a Tandy 1000 90-key keyboard.  If you are going to play M.U.L.E. on a Tandy 1000, I would advise using the joystick and setting the speed machine to slow (if an EX, HX, SX or faster) at boot time.  On the Tandy 1000 90-key keyboard, the Esc key is right below the F1 key, making it too easy to press if you are controlling Player 1.  The composite colors on a Tandy with an RCA video jack (TX or earlier) will look different than on an IBM PC with a CGA card.

Finally, the game can be saved in progress by pressing Ctrl-Q.  This does not appear to be a feature of the earlier versions.

Saturday, November 2, 2013

IBM PC Color Composite Graphics

In one of my recent posts, I discussed artifact color composite graphics as demonstrated by all computers which were intended to use them.  In this post, I want to focus on artifact color composite graphics as available on the IBM PC and compatible systems.

IBM PC CGA Color Composite Graphics

First, I would like to address some myths.  The first myth is that only a few games used composite color. Well over 100 games have been confirmed to use composite color.  The second myth is that virtually all of them used the 640x200 graphics mode.  In fact, many, many games used composite color, although many looked acceptable on an RGB monitor, and just as many games used 320x200 graphics mode and color composite graphics as those that used the 640x200 graphics mode.  Here are a list of games that are known to use composite artifact color graphics and the type of graphics they use :

Game Title Composite Color Type
Adventure in Serenia 320
Agent USA 320
Alphabet Zoo 320
Ancient Art of War 320
Archon: The Light and the Dark 320
Battle of Antietam 320
BC's Quest for Tires 640
Below the Root 320
Beneath Apple Manor 320
Black Cauldron, The 640
Blue Angels: Formation Flight Simulation 640
Borrowed Time 320
Boulderdash 320
Boulderdash II 320
Bruce Lee 640
BurgerTime 640
Buzzard Bait 320
California Games 640
Championship Baseball 640
Championship Golf: The Great Courses of the World - Volume One: Pebble Beach 320
Chuck Yeager's Advanced Flight Trainer 640
Crossfire 320
Demon's Forge 320
Dino Eggs 320
Donald Duck's Playground 640
Drag Race Eliminator 320
Dragon Wars 320
Exodus : Ultima III 320
Fooblitzky 320
Football 640
Freddy's Rescue Roundup 320
Frogger II: Three Deep 640
Gamma Force in Pit of a Thousand Screams 320
Gertrude's Puzzles 320
Gertrude's Secrets 320
Gettysburg: The Turning Point 320
Gold Rush 640
Indianapolis 500: The Simulation 640
J-Bird 640
Jumpman 640
Jungle Hunt 320
King's Quest 640
King's Quest II : Romancing the Throne 640
King's Quest III : To Heir is Human 640
King's Quest IV : The Perils of Rosella (AGI) 640
Lane Mastodon vs. the Blubbermen 320
Leisure Suit Larry in the Land of the Lounge Lizards 640
Lost Tomb 320
M.U.L.E. 320
Manhunter : New York 640
Manhunter 2 : San Francisco 640
Maniac Mansion (Low-Res) 320
MasterType 320
Mean 18 640
Mickey's Space Adventure 640
MicroLeague Baseball 320
MicroLeague Baseball II 320
Microsoft Decathlon 320
Microsoft Flight Simulator (v1.0) 640
Microsoft Flight Simulator (v2.0) 640
Mindshadow 320
Mixed-Up Mother Goose 640
Mr. Cool 320
Ms. Pac-Man 640
Murder on the Zinderneuf 320
Night Mission Pinball 640
Night Mission Pinball (v3.0) 640
Oil's Well 640
Pits & Stones ?
Pitstop II 640
Roadwar 2000 320
Roadwar Europa 320
Robot Odyssey 320
Rocky's Boots 320
Shamus 320
Sierra Championship Boxing 320
Solo Flight 320
Space Quest : Chapter I : The Sarien Encounter 640
Space Quest II : Vohaul's Revenge 640
Spy Hunter 320
Starflight 640
Strip Poker: A Sizzling Game of Chance 320
Sub Mission 320
Super Zaxxon 640
Superbowl Sunday 640
Tales of the Unknown: Volume I - The Bard's Tale 640
Tapper 640
Tass Times in Tonetown 320
The Bard's Tale II: The Destiny Knight 640
The Bard's Tale III: Thief of Fate 640
The Fourth Protocol 320
The Oregon Trail 320
The Seven Cities of Gold 640
The Tracer Sanction 320
The World's Greatest Baseball Game 640
Think Quick! 320
Transylvania 320
Troll's Tale 640
Ultima II : Revenge of the Enchantress 320
Ultima IV : Quest of the Avatar 320
Ulysses and the Golden Fleece 320
Wasteland 640
Where in the U.S.A. is Carmen Sandiego? 320
Where in the World is Carmen Sandiego? 320
Wilderness: A Survival Adventure 320
Winnie the Pooh in the Hundred Acre Wood 640
Wizard of Id's WizType 640
Zak McKracken and the Alien Mindbenders (Low-Res) 320
ZorkQuest: Assault on Egreth Castle 320
ZorkQuest: The Crystal of Doom 320

The advantage to using the 640x200 graphics mode is that a good color palette is available using white as the foreground color.  White or light gray, rather than high intensity or bright white was used because the brightness level was more tolerable on composite devices.  The disadvantages are that the game must support two completely different sets of graphics, otherwise users of RGB monitors would feel left out. Additionally, most games used an algorithm that requires extra coding and CPU time to implement for either the RGB or color composite mode.

The advantage to using 320x200 graphics is that only one set of graphics, or in a few cases two sets of very similar graphics, need be used.  Both users of composite monitors and RGB monitors can be satisfied, although the result may not be as impressive as tailoring graphics to either RGB or composite monitors.  The disadvantage is that the graphics designer has to cope with both direct and artifact colors, often giving a fuzzy image.  With the green/red/brown palette, the results often look somewhat garish and it was seldom intended to be used for composite color graphics.  Often that palette, many times with a blue background, would be used for the RGB graphics selection.  The colors choices available in the 320x200 modes are not as flexible as they would be in the 640x200 mode.

320x200 Palette 1 High Intensity Composite Color Graphics from L to R : RGB, Old CGA, New CGA, PCjr., Tandy
320x200 Palette 0 High Intensity Composite Color Graphics from L to R : RGB, Old CGA, New CGA, PCjr., Tandy
The above palettes do not quite give the full array of color combinations which the CGA card is capable. Although the palette choices in the 320x200 modes are limited, the background & border color can be freely selected from the full 16 colors which the CGA can display.  Similarly, the foreground color in the 640x200 mode can be set to any of the 16 colors CGA can display.  These color choices will affect the resulting artifact colors available.

640x200 Color Composite Graphics from L to R : Old CGA, New CGA, PCjr., Tandy
While color composite graphics may appear to be one way to display graphics, in reality there are three major types of color composite graphics.  First there are those generated by the IBM PC Color/Graphics Display Adapter and 100% compatible adapters.  Within this type there are two subtypes, early cards and late cards with minor differences between them.  Second, there are those generated by the IBM PCjr.  Third, there are those generated by the Tandy 1000 computers.

IBM CGA cards, Catalog Part Number 1504910 come with Card and PCB numbers

Card           PCB
1804456
1804464
1804472
1501486     1501453
1501981     1501982
6278550     6133807?
6447058

Cards 1804456 to 1501486 are early CGA cards.  1501981 to 6447058 re late CGA cards. The 180xxxx cards have the black brackets on them which the very earliest IBM PC cards had.  Later cards use a silver bracket appropriate for an IBM PC, XT or any compatible machine.  The major physical differences between the two versions of these can be seen here :

Old CGA vs. New CGA, note the increased number of resistors on the New CGA card (courtesy of minuszerodegrees.net)
An old CGA card will have either 7, 8 or 12 resistors, a new CGA card will have 15.  Note also in the above photo that the old card has a Motorola MC6845 and the new card has a Hitachi HD6845.  While the two work identically for typical software, demos may require one or the other.  The party-version of the 8088MPH demo only looks correct with an MC6845.  The final version looks correct with either chip.

Old cards seem to come exclusively with MC6845s, while new cards will use either chip.  Old cards always seem to use a green PCB color, but new cards almost always use a brown PCB color.

One of the chief differences between these cards is the number of shades of gray it can produce when connected to a monochrome composite monitor or B&W TV set through an RF modulator.  Old cards can produce two shades of gray plus black, while new cards can produce 15 shades of gray plus black in black and white modes.  Many computer users had to use monochrome green, amber or white monitors back in the day, and the increase in shades of gray meant that more detail could be seen in the graphics.  With the old cards, you had black for black and gray, white for white and bright white and gray for all other colors.  This is found in CGA Mode 5, which on an RGB monitor gives a cyan, red and white palette but on a color composite monitor will give either black and white (2 colors) or black, dark gray, light gray and white (4 colors).

Colorwise, new CGA was adjusted to more closely adhere to the NTSC standard.  It will appear more consistently across different monitors than old CGA.  There are differences between the saturation and brightness between the colors output by old and new CGA.  Newer monitors may make the image too dark with old CGA, requiring the user to increase the brightness level of his monitor.  There is a test program that can tell you which type of CGA card you may have.  Here are the screenshots of it showing how it informs you of the type you may have :



Old CGA has a raster bendiness issue with certain computers, and the black and white modes may not always eliminate all colors.  Running the signal through a powered RF modulator like the Recoton Video RF Modulator V647 should eliminate the bendy horizontal sections of the picture without reducing the video quality (assuming you are not modulating an audio signal with the video.)

Unlike the Apple II, where the pixels being output in the high resolution and double high resolution modes were either white or black, on the PC the pixels being put out have direct color.  The six colors in between black and white, without accounting for intensity, are generated by adjusting the phase of the 3.58MHz color burst signal for the hue and the amplitude of that signal for the brightness.  Unlike on an RGB TTL monitors from IBM, color #6 is dark yellow, not brown, because a color composite monitor or TV does not have circuitry built inside it to detect color #6 and turn it to brown.

For direct or chroma colors, both the old and new CGA cards look similar to the RGB colors, but there are minor differences between them.  The PCjr. and Tandy 1000 show direct or chroma colors identically with the new CGA cards.  Here are the 16 direct or chroma colors :

Rows 1 & 4 : RGB CGA Colors, Rows 2 & 5 : Old CGA Direct Colors, Rows 2 & 6 : New CGA, Tandy and PCjr. Direct Colors
For at least two games, Microsoft Decathlon and Championship Golf, the earlier card makes it much easier to read text than the later card.  Championship Golf may require the brightness controls to be turned down on the monitor.  Other games designed for old CGA are Sorcerer of Claymorgue Castle. Tournament Tennis, Quadrel and Willow look better with new CGA.

320x200 Palette 1 Color Composite Graphics Example - Adventure in Serenia New CGA
Some games like Donkey Kong, Boulderdash II, I, Damiano: The Wizard of Partestrada and Turbo Champions look like they support color composite graphics due to the vertical striped pattern graphics seen in some screens or tiles, but they really do an overall poor job on a color composite monitor. It is suspected that the ports did not convert the graphics with a great deal of thought.

320x200 Palette 0 Color Composite Graphics Example - Jungle Hunt (Note the Diving Bar, New CGA)
Pitfall 2 is an interesting piece of software when it comes to color composite mode support.  If you press 1 at the text screen, you will see 640x200 graphics with green as the foreground color on an RGB monitor.  I know of no game other than this that uses any foreground color other than white for 640x200 color composite graphics.  Obviously, this gives the graphics a greenish hue on a color composite monitor.  If you press 2 at the text readability screen, you will get 320x200 graphics with intense palette 0.  However, the road and the mountains have vertical stripes, which suggest that this mode is also intended to be used with a color composite monitor.  However, the stripes are there as a crude dithering effect, as using this mode on a color composite monitor makes the text very difficult to read.  The Fourth Protocol allows the user full control over the CGA card, and has a stripey pattern for 640x200 graphics that make them look tolerable with a color composite monitor.  It may be limited to the title screen, however, because the in-game graphics appear to always be 320x200, with the pixels doubled in a 640x200 mode.

640x200 Color Composite Graphics Example #1 - Pitstop II, New CGA
Color composite graphics were not limited to booters.  Sierra supported it in every AGI engine game it released, from King's Quest to Manhunter II : San Francisco.  Interplay supported it in The Bard's Tale 1-3, Dragon Wars and Wasteland.  No doubt their Apple II origins contributed to this.  Interestingly, in Wasteland you must select the graphics adapter in the install program, which then converts the graphics from 16-color to composite color as it installs.  To use another graphics adapter, you have to reinstall the game.  Considering its support for every other type of graphics adapter on the market, the color composite support in Lucasarts' Maniac Mansion and Zak McKracken is uncharacteristically poor.

640x200 Color Composite Graphics Example #2, - King's Quest, Old CGA
Tandy 1000 Composite Color Graphics

Tandy can only show the same direct or chroma colors as CGA, but the Tandy 1000 artifact colors are different.  Changing the hue adjust will be sufficient to change Tandy colors to late CGA colors in DOSBox, and vice versa, but only in the 640x200 mode.  A hue adjustment in the 640x200 mode of 120 degrees will give a good Tandy palette.  You can only approximate the palette colors for the 320x200 modes.  Games that are not "Tandy-aware" with their color composite graphics will show different colors. This occurs either with either 320x200 or 640x200 graphics.

Blue Angels: Formation Flight Simulation is the only game known where the color composite graphics look correct on the Tandy 1000 but do not look right on the IBM CGA cards.  It also apparently was developed on a system with a comb filter.  For a 1989 game, this would not have been difficult to find, but comb filters were not used on the composite color monitor and TVs of the early 1980s when most of the composite color CGA games were developed.  Many early 1980s games look better on monitors without comb filters.  Compare these two screenshots :

IBM CGA Composite
Tandy 1000 Composite
In the Tandy extended modes 160x200x16, 320x200x16 and 640x200x4, you will see color on a color composite monitor or TV.  In the 160x200x16 mode, there is no real artifact color since the pixel clock and the color burst frequencies are the same, 3.58MHz.  The graphics look blocky in this mode, but reasonably sharp.  Maniac Mansion on the Tandy 1000, using the Tandy graphics setting, would look very similar to how it looks on the Commodore 64, although there are color differences and the text is blockier.

Indianapolis 500 specifically supported both IBM and Tandy color composite graphics with different command line arguments so that the colors would look correct regardless of system.  However, the colors in each mode are not identical.  The command line switch /c1 will give colors appropriate for a CGA card, and switch /c2 will give colors appropriate for a Tandy graphics adapter.

Indianapolis 500 - The Simulation 640x200 RGB CGA
Indianapolis 500 - The Simulation 640x200 RGB Tandy
Indianapolis 500 - The Simulation Color Composite Early CGA
Indianapolis 500 - The Simulation Color Composite Late CGA

In modes using true 320x200 graphics (the AGI games use the 320x200 16 color graphics mode, but the effective graphics resolution is 160x200, at least for graphics above the command line), you can see color, but detail is lost, unintended artifacts that look like Hanover bars appear, and the game usually looks bad.  As far as 640x200x4 graphics go, no game is known to use that graphics mode.

Indianapolis 500 - The Simulation Color Composite Tandy (Simulated)
On a monochrome composite monitors or B&W TV sets, 16 shades of gray are always visible with Tandy 1000 or PCjrs.

IBM PCjr. Color Composite Graphics

The PCjr. does support color composite artifact colors, but the artifact colors are different from the CGA cards and the Tandy 1000.  Again this is due not to differences in the phase of the color burst but the pixel clock delay compared with the CGA cards.  In the 320x200 mode, there is a pixel clock delay of 120 degrees compared with the CGA cards.  PCjr. color composite graphics can appear quite different to CGA color composite graphics.

Below the Root sounds best (at least the opening song does) when run on an IBM PCjr. and the direct colors when the game is run on a PCjr. were tweaked to look very appropriate for a color composite monitor with artifact color.  Ditto for The Seven Cities of Gold, except it uses 640x200-based color composite graphics.

IBM PC CGA RGB
IBM PCjr. RGB

IBM PC CGA Old Composite

IBM PC CGA New Composite
IBM PCjr Composite

As explained in the prior blog entry, the PCjr's default 320x200 palette is not identical to the CGA's default cyan, magenta and white palette.  The PCjr. intentionally uses high intensity white instead, causing brightness and saturation differences.

Below the Root 320x200 Color Composite Late CGA
Below the Root 320x200 Color Composite Early CGA

Below the Root 320x200 Color Composite PCjr.

Wilderness : A Survival Adventure may show the best composite color results using the PCjr., but the underlying patterns are not changed for the machine.  Frogger II is PCjr. aware and shows good composite or RGB colors either with CGA or PCjr.  A late version of Pitstop II has direct support for the PCjr.'s 160x200x16 mode, so it will always look better than the CGA with or without color composite graphics.  Ditto for Murder on the Zinderneuf, all versions use 160x200x16 on the PCjr.  Several other games just use 160x200x16 on the PCjr. because it looks excellent on an RGB or color composite monitor.

BC's Quest for Tires uses 320x200 composite color graphics on the PCjr. but 640x200 composite color graphics on the PC.  Microsoft Flight Simulator 2.xx uses 640x200 composite color graphics for the PC and PCjr., but the patterns are different for each.  There was a version of Ultima II for the PCjr. that uses appropriate composite color 320x200 graphics.  M.U.L.E. also uses 320x200 composite color graphics.

Current SVNs of DOSBox emulate old and new CGA with the cga machine type, 640x200 and 320x200 color composite graphics but does not emulate color composite graphics with the tandy or pcjr machine types.

Other computers may have inaccurate CGA artifact colors.  The Columbia Data Products 1600 (one of the very first PC clones) came with a CGA clone card that is almost as off as the Tandy or PCjr.  A hue adjustment of 315 degrees will get something like its palette in 640x200 mode.  Here are the games that intentionally support composite color on an IBM PCjr. with the type of composite color they use :

Game Title Composite Color Type
BC's Quest for Tires 320
Below the Root 320
M.U.L.E. 320
Ultima II : Revenge of the Enchantress PCjr. Version 320
Frogger II: Three Deep 640
Microsoft Flight Simulator (v2.0) 640
The Seven Cities of Gold 640

Lode Runner : Support for All Composite Color Types

Lode Runner for the PC always looks best in composite color mode, despite using the 320x200 resolution. Only the in-game border and certain objects on the screen really take advantage of composite color, but the solid objects always look appropriate regardless of monitor.

When first released for the PC, the game only supported the IBM PC and CGA.  A second release added PCjr. support by adjusting the patterns for the composite color objects.  A final release under the Tandy label retained the PC and PCjr.'s respective patterns but adjusted the patterns again when it detected a Tandy 1000 machine.  Here are correct screenshots for the CGA, PCjr. and Tandy both in RGB and Composite :
IBM PC CGA RGB
IBM PC Old CGA Composite
IBM PC New CGA Composite
IBM PCjr RGB
IBM PCjr Composite
Tandy 1000 RGB
Tandy 1000 Composite

Limitations of the Tint Control

NTSC color TVs and monitors have a tint (hue) control dial, buttons or function.  The tint control is intended to adjust for phase errors in a transmitted broadcast signal.  The tint control adjusts the phase of the TV's reference color burst signal slightly toward the green or red end of the spectrum.  The color burst is intended to have a phase of 180 degrees, and by using the tint control, you can adjust the TV's phase by about 40 degrees from the official phase.  This was important during the era of broadcast TV before cable became ubiquitous.  Here is an NTSC color wheel to give you an idea of where the colors fall by degrees :


Unfortunately, for Tandy and PCjr. display adapters, 40 degrees is not sufficient to turn Tandy or PCjr composite colors into CGA colors.  Relative to late CGA, assuming its color burst is near 180 degrees, 640x200 Tandy is at 300 degrees and 640x200 PCjr. is at 120 degrees.  In the 640x200 mode, you can get somewhat close to the CGA colors at the extreme end of the tint control (green for PCjr, red for Tandy), but in 320x200 mode, you really won't.  In DOSBox, F11 and Alt F11 emulate the function of the tint control.

This blog entry gives a very readable overview of how composite CGA works : http://8088mph.blogspot.com/2015/04/cga-in-1024-colors-new-mode-illustrated.html