Monday, May 6, 2019

40 column RGB screen for Commodore 64 mode on 128

RGB64 is a solution for a problem almost no one has -- use the C128 RGBI screen for C64 mode text programs and editing in 40 columns!  Now you can go back to using one monitor for both, and without using a hardware switch.  Well, as long as you're not using any graphics or pokes to video memory.   If you are editing or running a simple text BASIC program, you can use RGB64 to mirror your screen between both monitors.  As a bonus, you can run in fast mode 2MHz, because the RGBI screen runs independently from the VIC that could only access video memory at 1MHz.  Another bonus is that the extra keys of the C128 keyboard are supported as well.




Your Commodore 128 has an 80-column RGBI screen, and a 40-column Composite screen.  One of the original dual monitor systems!   So you probably prefer the RGBI screen for the C128 mode, and you're usually stuck using composite output (or worse, TV signal) for the C64 mode.  And that means you gotta have one or more monitors that support both.   Well not anymore!   You can now downscale your 80-column monitor to 40-columns for simple Commodore 64 programs.

How does it work?  It copies the C64 ROMs to RAM, and patches them to include routines to initialize and update the RGBI screen with a 40 column image matching the text output to the VIC screen.  It also copies the C64 character ROMs to 8563 VDC RAM.  Then switches to C64 mode.  No going back until you press the Reset switch.

So maybe you didn't know the 8563 VDC could do 40 columns, because hey, it was included in the Commodore 128 to do 80 columns.  Well, you know it can do graphics, and interlaced modes for higher resolutions.  Did you know it can do 50 lines of text?  Did you know it can do 8x16 pixel characters as well?  In addition to all that, it can also double the width of the pixels, so presto, with a few more adjustments it can also do 40 columns instead of 80.

KEYBOARD SUPPORT

  • HELP will copy the VIC Composite screen to the VDC RGBI screen (in case of pokes)
  • ALT will toggle Fast mode (2MHz)
  • C128 extended keys are supported including dedicated cursor keys and numeric keypad, even CAPS LOCK

WARNINGS (Sorry the lawyers in my head make me put these in)

  • Warning!  This code has been tested solely on a NTSC C128D 8563 rev2, and with VICE 3.3.  PAL, rev0, and rev1 chips may not be supported.  I didn't even test with a true Commodore monitor, but a compatible (Thomson 4120 switchable RGBI/Luma+Chroma).
  • Warning! I haven't tested on a real Commodore 128 since 1990 or so.  (But it's only 8 feet away from me, I guess I could plug it in again, but that requires effort.)
  • Warning! And I will not be responsible if this program kills your monitor.  Gee I sure hope it doesn't.
  • Warning! All the ROMs (BASIC and KERNAL) are now in RAM.  One wrong poke, and poof system locks up or worse.   Then again, it's a fun environment to hack the ROMs with.
  • Warning! Uses $991C-$99D2 for RGB64 machine language component.
  • Warning! RGB64 is probably not compatible with the other software you use.
  • Recommend you try RGB64 in Vice (emulation).  Emulation should be easier on your monitor.  And if it doesn't work, those bits can simply be recycled into something else.
The reason I built this was that about 30 years ago my monitor was on the fritz, I sent it for repair, and had no good composite monitor.  I did have an amber monochrome monitor.  My development system relied on The Fast Assembler (Thanks Yves Han!) which ran in C64 mode, so only 40-column mode.  I had been using the 50 line mode of the VDC 8563 and in messing around with the settings, found the 40 column mode too.   Turned out the monitor had an extra circuit board with edge connector that came loose and only needed to be re-plugged into the main circuit board, so the need for this utility was short lived.  But I got a kick out of writing it, and wanted to share it.

The code is mostly original from about 30 years ago except for some updates today to carve my name in it  with URL.  Gotta take credit for the hard work, right?  

Where the magic happened -- my Computer Workstation
Links:
RGB64 Disk image (.D64), mount and type: RUN"RGB" from C128
Source Disk image (.D64) including The Fast Assembler plus ScrollEdit with RGB64 patches.
RGB64 Decompilation, Annotated (.PDF)
Hackaday posted a short article about this project!

4 comments:

  1. Very cool hack! That Thomson 4120 can supposedly do EGA, as well, by the way.

    ReplyDelete
  2. BTW, I was at first thinking it was only for BASIC programs, due to your intro, but was pleased to see it will work with all text-mode programs, such as assemblers and other utilities. I'm curious how text mode games that don't use sprites would behave. Ultima II is supposedly such a program. Let us know if you try it. Or, perhaps I'll try and let you know here.

    ReplyDelete
  3. LOL, I see I commented on the Hackaday article about this over a year ago.

    ReplyDelete
  4. Oh, I definitely did EGA with my 386/33 and that monitor. We've been places!

    Anything that writes to the screen with Commodore Kernel calls, and uses BASIC exclusively should be fine. The problem is POKEing to video memory isn't intercepted, but you can press HELP to refresh the screen in an occasion or two. Also due to how it is implemented, it uses memory that might conflict with other programs that expect to get it all.

    The better way for 80 column support is just create a monochrome cable, and switch the input on your monitor.

    Thanks for your feedback!

    ReplyDelete