VGARC add-on for SC114

198 views
Skip to first unread message

Bill Shen

unread,
Mar 13, 2023, 11:53:32 AM3/13/23
to retro-comp
I got a PM wanting to know whether VGARC will work on Z80-based computer.  Well, VGARC was specifically designed for Z*80, so it should work as is, without modifications.  I've done that with my own Z80 SBC as well as on a RC2014Zed clone (a mixture of official RC2014 and third-party boards).  However, I thought it would be an interesting exercise to add VGARC to a third party board that I'm not familiar with and append VGARC software extension to existing third-party software that I'm also not familiar with.  Steve Cousin's SC114 is a popular, minimal, and inexpensive Z80 motherboard that can run CP/M with an addition of a CF board.  It has 4 classic 40-pin RC2014 connectors.  It is very well documented both hardware and software; and I was given two blank SC114 pc boards, so SC114 is the ideal third party target for a VGARC add-on.

Many have built SC114, so I won't get into the built details other than saying it is very easy to build and very well documented, but we've known that all along.  I did make some "adjustments" to the original built:
* Replacing the 27C256 OTP EPROM with programmable and inexpensive W27C512.  I'll need to change the EPROM program many times, so a programmable EPROM is needed.
* Add a MCP130 reset supervisor--it is an easy add because there is a perfect location next to the reset button.
* Lastly and importantly, replace the 7.37MHz oscillator with 14.7MHz.  SC114 is conservatively designed so it will work just fine doubling its system clock.  This has the benefit of doubling the relatively placid serial communication from 9600 bps to 19200 bps.  I'll be uploading lots of software changes and I'm impatient.

Power consumption of SC114 with 14.7MHz system clock is 58mA@5V.  Adding VGARC, PS2 keyboard, and VGA monitor, it is now 290mA@5V.  I got a screenful of noise which is expected.

Lets write a quick routine using SCMonitor and check out the VGARC:

Font table for character 0x0 is 8 bytes located at I/O address 0x0c00.  So to make character 0x0 into a blank 8x8 block, I write zeros to the corresponding font table.  Afterward I'll write 4 lines of character 0x0 and should see 4 blank lines replacing the noisy screen:

;setup font for character 0x0
;character 0 is blank
xor a
ld c,0c
ld b,8
$8005
dec b
out (c),a
jr nz,$8005
;clear out lines 5-8
ld c,1
$800c
out (c),a
djnz $800c
;warm boot SCMonitor
jp 3

Picture shows the result of running above program.

Next post will talk about using SCMoitor to test PS2 keyboard input, generating 60Hz interrupt, and check hardware scrolling function.
  Bill
SC114_VGARC.jpg

Steve Cousins

unread,
Mar 13, 2023, 12:18:04 PM3/13/23
to retro-comp
That's good news thanks Bill. We don't have any openings in our sales team at the moment but our human resources department will be touch when we do :)

Bill Shen

unread,
Mar 13, 2023, 9:29:52 PM3/13/23
to retro-comp
SCMonitor has input and output commands that are useful for testing PS2 interface.  PS2 status is located at I/O address 0xF5 and PS2 data is located at I/O 0xF4.  Bit 0 of PS2 status indicates whether there is a valid keyboard input at PS2 data register such that PS2 status bit0=1 indicates valid data.  So here is a SCMonitor session where I started out with PS2 status bit 0=0, no valid PS2 input; I then pressed the "space" bar which generated scan codes 0x29, 0xF0, 0x29 queued up at the PS2 data register. Reading the PS2 status now showed data is available followed by a read of 0x29 at PS2 data register; reading PS2 status again showed another data is available followed by a read of 0xF0 at PS2 data register; reading PS2 status yet again showed another data is available followed by a read of 0x29 at PS2 data register; and finally reading PS2 status showed no data is available.  So PS2 interface is working.
PS2_space_bar_input.jpg

PS2 status/command register has additional functions when written to.  Bits 0 to 5 are hardware scroll register.  When wrote values 1 to 47 to 0xF5, the screen will scroll up 1 to 47 lines.  Easy to test that by output 1 to 47 to 0xF5 and see the screen scrolled up accordingly.  That checked out.

PS2 status/command register has another function, 60Hz interrupt enable.  Writing 1 to bit 6 will turn on the 60Hz interrupt (interrupt mode 1) synchronous to VGA's vertical blanking interval.  Testing the interrupt function is somewhat elaborated because RST 38 associated with interrupt mode 1 is in EPROM.  Fortunately with SCMonitor  RST38 jumps to RAM location 0xFE15 where I can patch in an interrupt service routine.  Below is a program I created using SCMonitor's assembler.  It has two parts, $8000 set up the font table for character 0x0 as blank; set up Z80's alternate registers for interrupt service use; and then enable the 60hz interrupt.  Part two at $8100 is the interrupt service routine where it switches to alternate registers; decrements a 60-count counter; when counter reaches zero, it is reloaded with 60 and writes a blank character out to cursor and increment the cursor.  The net result is a blank character is written to the monitor once a second and it does.

So VGARC hardware is all working on a SC114.  I've also reached reasonable limit of what can be created using SCMonitor's resident assembler.  Next time I'll write Z80 programs on my PC and serially uploaded to run on SC114.
  Bill

*********************************

;setup font for character 0x0
;character 0 is blank
$8000:

xor a
ld c,0c
ld b,8
$8005
dec b
out (c),a
jr nz,$8005
;set up alternate registers for interrupt service
exx
ld de,$3c
ld bc,1
exx
im 1
ei
;enable 60hz interrupt
ld a,$40
out (0f5),a
jp 3
;interrupt service routine
;use the alternate registers
;change $fe15 to jp $8100
$8100:
exx
dec e
jr nz,$8109
ld e,$3c
out (c),d
inc b
$8109
exx
push af
;clear current interrupt
ld a,$c0
out (0f5),a
pop af
ei
reti

Bill Shen

unread,
Mar 14, 2023, 9:04:16 AM3/14/23
to retro-comp
Here is a test program that clears the screen, loads font table, and displays a banner.  It is assembled on my PC and uploaded to SC114.  This same program with minor tweaks has ran on many other platforms with VGARC.  It worked the same on SC114.

At this point I'm tempted to write some game programs like Tetris and Space Invader for SC114+VGARC, but the original plan is adding PS2 keyboard and video extensions to SCMonitor so it can receive input from either keyboard or serial port and send output to both serial port and video.  The goal is making SC114+VGARC a standalone computer.  

Phil G is working on Zen editor/assembler on RC2014-Z80 forum.  I think Zen is a good fit for diskless SC114+VGARC.

Later on I'll add a CF interface to SC114+VGARC and modify CP/M BIOS to work with video and keyboard so it is a standalone CP/M computer.  Yea, that's the plan...but I know Reality is waiting around some corner to punch me in the face...
  Bill
tstVGARC_SC114.zip
DSC_72270314.jpg

Bill Shen

unread,
Mar 16, 2023, 10:25:31 AM3/16/23
to retro-comp
SCMonitor has a nice table in RAM to patch in extension to various system routines; it is the "kJumpTab" based in RAM starting from 0xFE00.  It is a collection of jumps to internal routines among them is JpConOut at 0xFE1B.  So to patch in VGA extension for console output, it is a matter of saving where JpConOut jumped to and replace with VGA routine that jumps to the original JpConOut after VGA output is done.

The attached code shows the VGA output extension.  It first clears the screen, installs font tables, and replace the original JpConOut destination with VGA extension.  In principle, VGA routine manages a cursor and outputs whatever data meant for serial port out to screen as pointed by the cursor and then return the program back to the original JpConOut so the serial data is also displayed on the terminal console.  Simple, huh? Well, the devil is always in the detail; the VGA extension needs to deal with certain functions that's automatically done in VT52 terminal such as cursor, carriage return, line feed, and scrolling.  These are just the basic functions, there are escape sequences that are above and beyond my simple VGA extension.  And one more problem: VGARC is only 64-character wide, what to do with a line of more than 64 characters?

Currently my solution is this:
* Cursor is a inverse video of the space character.  <-- I think inverse video of existing character may be better solution, it is something to work on.
* Carriage return moves cursor to beginning of a line, but don't write out the cursor symbol so not to erase the first character of a line when the subsequent linefeed is executed.
* Linefeed moves the cursor vertical down one line.  However, if cursor is already at the bottom line, this will cause screen to scroll.
* Scrolling is done with the hardware scroll register followed by blanking out the bottom-most line.  I struggled with the algorithm because it is...strange...but it is working, but I can see myself looking at it a year from now and wonder what I was thinking?
* How to fit 80-column line in 64-column?  Right now I'm just trucating the character after 64th.  I suppose I should provide an option to wrap the extra characters to next line and have to deal with scrolling again.

Pic is the VGA monitor displays SCMonitor commands "help", "dir", "m0" and "basic".  The same screen content is also displayed on my TeraTerm serial terminal except lines greater than 64 characters are not truncated.  BASIC is working because it also uses the jump tables, kJumpTab, for basic I/O.

There are some minor tweaks needed, but I'm charging ahead to PS2 keyboard extension for SCMonitor.
  Bill
SCM_VGA_extension.zip
DSC_72280316.jpg

Bill Shen

unread,
Mar 17, 2023, 2:57:31 PM3/17/23
to retro-comp
Here is completed video/PS2 extension for SCMonitor.  It will now receive input either via TeraTerm terminal or PS2 keyboard that's connected to VGARC; it will output data to both TeraTerm terminal as well as VGA monitor connecting to VGARC.  So it is a standalone Z80 computer but with a serial port connected to host computer for software update.

I took advantage of SCMonitor's "kJumpTab" in RAM to insert the PS2 extension at 0xFE19.  If there is a valide PS2 input, the PS2 extension will return the keyboard value with Z flag cleared.  If PS2 has no valid input, it will jump to the original routine pointed by 0xFE19.

The program is relative small at 400 bytes, but font table is 1K and PS2 scan code lookup table is 256 bytes, so it is over 1.5K.  SCMonitor's EPROM has lots of blank space, so other than a few RAM variables, most of the video/keyboard extension can reside in EPROM.   Phil G's Zen is mostly compatible with SCMonitor, so I plan to include Zen in the updated EPROM.

Pic shows "help", "m0", and "basic" commands issued via PS2 keyboard and displayed on VGA monitor.  I also typed in a short BASIC benchmark on PS2 keyboard but I got tired of typing by line 100, took a picture, then send the remaining BASIC program via TeraTerm and ran it and displayed result on the VGA monitor.

This was great fun.  My software was greatly simplified by the very well structured SCMonitor.  The jump table "kJumpTab" was most helpful and the fact BASIC also used the jump table for I/O means BASIC also work with VGARC's keyboard & video.  Two birds with one stone, most satisfying!  Furthermore, once Zen is integrated into SCMonitor, it will also use VGARC's keyboard & video for I/O, yet retained the ability to load/save via TeraTerm terminal.
  Bill
DSC_72430317.jpg
DSC_72440317.jpg
SCM_VGA_PS2_extension.zip

Bill Shen

unread,
Mar 19, 2023, 7:29:41 PM3/19/23
to retro-comp
I have an updated EPROM for SC114 that contains video/keyboard extension and Zen program as described by Phil G on RC2014-Z80 forum.  I added two entries to SCMonitor's directory so video/keyboard extension can be invoke by entering "videokbd" at SCMonitor prompt and Zen can be invoked by typing "zen" at SCM prompt.

videokbd is running in EPROM at 0x7000 except a dozen of so variables are kept in high RAM 0xFBF0.

Zen, on the other hand, needs to run in RAM.  So to invoke zen, I copied EPROM to high RAM, paged out EPROM and copy high RAM back to same location in RAM.  Did this 8 times to copy the entire SC114 EPROM to 32K RAM and then jump to Zen at 0x5000 which is now running in RAM.

Anyone with SC114 can try this updated EPROM.  VGARC is needed only for videokbd, Zen will run without VGARC.  Instead of using OTP 27C256 EPROM which can only be programmed once, I'd recommend W27C512 which can be re-programmed many times since the current software is bound to change as bugs are discovered.

With VGARC and videokbd extension installed, SCMonitor, BASIC, Zen all can take input from either terminal emulator (TeraTerm) or PS2 keyboard connected to VGARC and output from these three software go to both VGA connected to VGARC as well as the terminal emulator.  It is pretty cool, if I do say so myself.

Next step is plug in a CF adapter to SC114 and get CP/M to work with VGARC.
  Bill
Zen running on SC114.jpg
SC114_with_zen_videokbd.zip
Reply all
Reply to author
Forward
0 new messages