Home Web Design Computing Music

CBM 5/6/700 - 500 Hi-Res Graphics

I spent some time investigating the 500's video possibilities initially through BASIC. After that I developed two machine code programs, SPRITE 0400 and SPRITE D000, which provided a simpler interface to the 500's hi-res screen and sprites from BASIC through the use of a SYS call plus some easier to remember 2-character commands. These files, along with programs to use them (plus some original CBM demo files) are available for download in two formats: either as separate programs or as a disk image for use in the Vice emulator. The programs are:

500 HI-RES MODEMy first experimental program for hi-res mode. Not very pretty but it did prove to me that it could be done (however, it doesn't always initialise the hires mode properly on the Vice emulator).
SPRITE 0400
SPRITE D000
The two machine code routines.
DRAW DEMOA hi-res demo program using SPRITE 0400/D000 to plot points and lines.
HIRES DEMOA hi-res demo program using SPRITE 0400/D000 that loads a hi-res (well, it was hi-res back in 1987) image and sprite files.
SPRITES
C.MOON NIGHT
D.MOON NIGHT
P.MOON NIGHT
The files required by the above HIRES DEMO program.
CHAR GENERATORA character generator program to replace the default, built-in character ROM with your own set stored in RAM.
CS.C128 SET
CS.SQUARE
Two character sets that can be loaded by the above program. The first is a copy of the revised C128 set (the 500 had the same set as the C64) and a 'squared'-off set that I created using the above program.
500 DEMOThis is a demo program written (I presume) by Commodore to demonstrate the 500 off. It cycles indefinitely.
COL.B
PIC.01
PIC.02
PIC.03
PIC.04
The picture files required by the above program.

To use the image in Vice start up the emulator with:

  xcbm2 -model 510

The xcbm2 executable will, by default, start up as a 6/700 unless the model parameter is sent). As the 500 was quite a slow beast it is worth setting the emulator to 200% speed.

Next select Device settings from the Settings menu and attach the unzipped image to device 8. Select Drive settings from Settings and select the 8250 drive. Now you should be able to do a DIRECTORY on the default drive and load the files as normal.

If you examine any of the programs that use the SPRITE 0400/D000 files you will see that they always start off with something like:

  10 BANK 15 : IF PEEK (1024) <> 32 THEN BLOAD "SPRITE 0400",B15,P1024
  20 BANK 0 : IF PEEK (55296) <> 76 THEN BLOAD "SPRITE D000",B0,P55296
  30 Q=1024 : SYSQ,GS

Lines 10 and 20 load the two machine code routines and 30 sets Q to the entry point for all the SYS commands before setting up the new screen areas in Bank 0. Once this is done then the text screen no longer uses the Bank 15 memory at $D000 which is now taken over by the second part of the M/C routines. All of the new commands are called by a single SYS command (SYS1024 or, as above, SYSQ) and the two characters following on determine the actual command.

Here is the list of the commands provided:

  • SYSQ,GS This sets up the text and graphic screens in Bank 0. If the reset button is pressed or anything else puts the text screen back into Bank 15 then issue this command again. Note that typing 'X' to exit the machine code monitor also resets the text screen to Bank 15 - exit by using 'G 85C0' instead.
  • SYSQ,GMm Graphic Mode. 'm' is 0 for text mode, 1 for hi-res and 2 for multicolour hi-res mode.
  • SYSQ,GCp,c Graphic Colour where p defines the area to which the colour is to be applied and c is the colour (values 1 to 16). The valid values for p are: 0 = Text/Hi-res background; 1 = Text/Hi-res foreground; 2 = Multicolour background 2; 3 = Multicolour background 3; and 4 = Border colour.
  • SYSQ,GPp,x,y Graphic Plot. Plots point at x,y using colour source p (p = 0 to 3 and is the same as p in the GC command above).
  • SYSQ,SDn,"xxxxxxxxxxxxxx - 126 hex characters - xxxxxxxxxxxx" Sprite define. 'n' is the sprite number. There must be exactly 126 hex (0-9, A-F) characters inside the quotes. Each horizontal sprite line is represented by 6 hex characters.
  • SYSQ,SMn,m Sprite Mode. 'n' is the sprite number (1 to 8). 'm' is 0 (off), 1 (on in normal mode) and 2 (on in multicolour mode).
  • SYSQ,SCn,c Sprite Colour. 'n' is the sprite number. 'c' is the colour (1-16).
  • SYSQ,SLn,x,y Sprite Location. Puts sprite 'n' at location x,y. X is 0-511 and y is 0-255.
  • SYSQ,SRr,r Sets the two sprite multicolour register colours. 'r' is 1-16.
  • SYSQ,SPn,p Priority. Sets sprite 'n' to background (p=1) or foreground (p=0).
  • SYSQ,SXn,x,y Sprite Expand. 'x' and 'y' are 1 for expand (otherwise 0).
  • SYSQ,SE Turns off all sprites.
  • SYSQ,LF List fast. Diverts video output routines to faster code. This is always called by GS.
  • SYSQ,CR Character Set located in Bank 15 (ROM).
  • SYSQ,C0 Character Set located in Bank 0. Must be used for hi-res to work.
  • SYSQ,CT Transfers character set from ROM (Bank 15) to RAM (Bank 0).

The machine code sets up the video as follows:

$C000 - $CFFFCharacter set
$D000 - $D3E7Text screen
$D3F8 - $D3FFSprite mem ptrs (1)
$D400 - $D7E7M-Col colour area
$D7F8 - $D7FFSprite mem ptrs (2)
$D800 - $DBFFReserved for M/C
$DC00 - $DDFFSprite definition area for up to 8 sprites

Each sprite needs a 64-byte area for its definition. There are 256 possible areas in the 16k available to the VIC chip ($C000 - $FFFF). Those at $DC00 to $DDFF are numbered 112 to 119 internally though the SYSQ sprite commands above translate these to 1 to 8. Both sets of memory pointers point to these 8 areas. Set 1 is used when in text mode and the other is for when hi-res is turned on.