Learning Assembly Language on the TRS-80/Tandy Color Computer - Program #8

 

 Introduction

It's time to try Program 8 from the Inman book, which draws orange dots in all 4 corners of graphics screens 1C, 2C 3C and 6C.

Assembly Language Graphics for the TRS-80 Color Computer - by Don Inman and Kurt Inman with Dymax

Program #8

Program #8 draws orange dotes in the 4 corners of several graphics screens.  It doesn't look very exciting, but it does a good job comparing the various graphics screens, how to switch between them, how data is stored for each of them in memory and how sizes of pixels vary from mode to mode.

A Mistake in the Listing

This listing in the book contains one mistake on page 88:  STA $FFC4 should be STA $FFC5

The full program listing on page 90 is correct, which helped me to verify the problem.  Before I fixed it, the program didn't switch graphic modes for this screen.

;********************************************
;* Assembly Language Graphics for the TRS-80 Color Computer *
;* by Don and Kurt Inman, 1983 *
;* Program 8 - Drawing Four Corner Dots. *
;* 6809 assembly language for Tandy CoCo *
;* David Kroeker, 08-Dec-2025 *
;* Draw dots in all 4 corners of screen, *
;* In all 4 modes, using colour set 1. *
;********************************************


ORG $1E00
; SET GRAPHICS MODE to 1C (64x64), COLOUR SET 1
Start LDA #$88 ; Select mode 1C (low res 4 colour graphics mode), colour set 1
STA $FF22 ; Set graphics mode
STA $FFC1 ; Set V0
; CLEAR GRAPHICS SCREEN
JSR ClearG ; Clear graphics screen subroutine
LDA #$FF ; red colour
; FOUR CORNER DOTS
STA $400 ; Plot dot in upper left corner
STA $40F ; Plot dot in upper right corner
STA $7F0 ; Plot dot in lower left corner
STA $7FF ; Plot dot in lower right corner
JSR Xkey ; Wait for X keypress subroutine
JSR ClearT ; Clear text screen subroutine
STA $FFC0 ; Turn off V0
; SET GRAPHICS MODE to 2C (128x64), COLOUR SET 1
LDA #$A8 ; Select mode 2C (hi res 4 colour graphics mode), colour set 1
STA $FF22 ; Set graphics mode
STA $FFC3 ; Set V1
; CLEAR GRAPHICS SCREEN
JSR ClearG ; Clear graphics screen subroutine
LDA #$FF ; red colour
; FOUR CORNER DOTS
STA $400 ; Plot dot in upper left corner
STA $41F ; Plot dot in upper right corner
STA $BE0 ; Plot dot in lower left corner
STA $BFF ; Plot dot in lower right corner
JSR Xkey ; Wait for X keypress subroutine
JSR ClearT ; Clear text screen subroutine
STA $FFC2 ; Turn off V1
; SET GRAPHICS MODE to 3C (128x96), COLOUR SET 1
LDA #$C8 ; Select mode 3C, colour set 1
STA $FF22 ; Set graphics mode
STA $FFC5 ; Set V2 (book has a typo here, says $FFC4 which will not switch the graphics mode properly)
; CLEAR GRAPHICS SCREEN
JSR ClearG ; Clear graphics screen subroutine
LDA #$FF ; red colour
; FOUR CORNER DOTS
STA $400 ; Plot dot in upper left corner
STA $41F ; Plot dot in upper right corner
STA $FE0 ; Plot dot in lower left corner
STA $FFF ; Plot dot in lower right corner
JSR Xkey ; Wait for X keypress subroutine
JSR ClearT ; Clear text screen subroutine
STA $FFC4 ; Turn off V2
; SET GRAPHICS MODE to 6C (128x192), COLOUR SET 1
LDA #$E8 ; Select mode 6C, colour set 1 (as per pg 59 last 3 bits don't matter, so $E8 or $EB both work fine)
STA $FF22 ; Set graphics mode
STA $FFC3 ; Set V1
STA $FFC5 ; Set V2
; CLEAR GRAPHICS SCREEN
JSR ClearG ; Clear graphics screen subroutine
LDA #$FF ; red colour
; FOUR CORNER DOTS
STA $400 ; Plot dot in upper left corner
STA $41F ; Plot dot in upper right corner
STA $1BE0 ; Plot dot in lower left corner
STA $1BFF ; Plot dot in lower right corner
JSR Xkey ; Wait for X keypress subroutine
JSR ClearT ; Clear text screen subroutine
STA $FFC2 ; Turn off V1
STA $FFC4 ; Turn off V2
RTS ; Return from main program

; CLEAR GRAPHICS SCREEN SUBROUTINE
ClearG CLRA
CLRB
LDX #$400 ; Start of graphics screen memory
Loop1 STD ,X++ ; Clear graphics screen memory
CMPX #$1C00 ; Have we cleared the entire screen?
BLO Loop1 ; If not, keep clearing
RTS ; Return from subroutine

; Look for X keypress to end program
Xkey JSR $A1B1 ; ROM routine to read keystroke
CMPA #$58 ; Did user press X key?
BNE Xkey ; If not, keep checking for X key
RTS ; Return from subroutine
;
; CLEAR TEXT SCREEN SUBROUTINE
ClearT LDA #$60 ; Select text mode
LDX #$400 ; Start of screen memory
Loop2 STA ,X+ ; Clear screen memory
CMPX #$600 ; Have we cleared the entire screen?
BLO Loop2 ; If not, keep clearing
LDA #$00 ; Set mode to text
STA $FF22 ; Set graphics mode to text
RTS ; Return from subroutine

; END OF PROGRAM
END Start

The next couple of graphics programs get more interesting.
David
18-Dec-2025

Comments