Learning Assembly Language on the TRS-80/Tandy Color Computer - Debugging Tools, Program #5
Introduction
This learning journey continues with Program 5 from the Inman book...
Assembly Language Graphics for the TRS-80 Color Computer - by Don Inman and Kurt Inman with Dymax
Did you print the book out yet? Are you using a second monitor to view the book while you code on your other display? Leave a comment below to share how it's going and what's working well for you.
Debugging Tools
The MAME debugger is great! Glen Hewlett's blog has a really good introduction to it, so please go read his post about it if you want more details. I'm not going to explain how to use it here, as Glen does a great job of that already. I'll just say that having the ability to step through your code line by line and see the registers and memory contents changing as you go is an amazing tool to learn how things work and to figure out why your program isn't doing what you expect. As a career programmer/analyst I've used many debuggers over the years in many languages. MAME's debugger has the usual features you'd expect in a debugger like breakpoints and watching for a change in a value. Here we're looking for a change in the contents of a memory location instead of the value of a variable like I'm used to. I'd have been really stuck with getting several of the programs in this book to work without the ability to use a debugger to see what was going on.
New Improved Debugging in MAME?!
On a recent edition of the CoCo Nation show on YouTube, CoCo Town (Dave) appeared on the show and shared the work he's done on enhancing the MAME debugger to display your actual source code listing in the debugger along with your code comments for each line instead of just showing the disassembled contents of memory like MAME currently does.
This feature is not yet available from the official MAME repository - it's not part of the project yet, but a side build (not sure if that's the right terminology, but you get the idea). I haven't tried to install this yet, but I do intend to look into getting this setup sometime soon. It sounds really, really useful!
Other Emulator/Debugger Options
VCC
Of course, MAME isn't your only option for a CoCo emulator with a debugger. VCC had a debugger added to it a few years ago. I haven't used it yet, and couldn't find any good content about it to share here. If anyone has a good video demonstration of it, please comment below. I do remember seeing a video of it in FaceBook before it was officially part of VCC and it did look impressive.
XROAR
XROAR is a well-known and widely used CoCo emulator. It also has a debugger, although I have never used it. Here's a good video demonstrating it for those you want to check it out:
trs80gp
trs80gp is an emulator of a whole bunch of TRS-80 machines, including the CoCo. It runs on Windows, MacOS, Linux and Raspberry Pi.
I found out about this emulator thanks to this really cool blog about disassembling Downland on the CoCo. The writer recommends trs80gp for its excellent debugging features and he used this tool extensively in his fascinating in-depth study of the classic CoCo arcade adventure game, Downland.
I tried out this emulator just a little and did poke around in the debugger. I need to spend more time with it before I comment about it, but I'm sharing it in case anyone else would like to try this alternative.
I'm interested in other TRS-80 machines too, so the fact this program emulates so many TRS-80 machines was interesting to me on its own. I hadn't heard of this emulator before reading that blog post.
Others?
I'm sure there are other debugger options I haven't mentioned here. Feel free to comment below if I'm missing one that you think people should know about and try. Anyway, I should get back to programs from the Inman and Inman book!
Program 5 - Colour Bar
This listing is the first program in the book dealing with graphics modes. There's a good summary of how the various graphics modes work in this chapter that is definitely worth studying now and coming back to again later as a reference.
Labels!
Finally we start to use labels for branch locations in the book! That makes things so much easier to follow.
No tape for me
Of course I didn’t bother to save the program to tape, as the book instructed. I’m doing all of my testing with virtual disk files, using a DECB command to create a disk image file and copy the assembled BIN program to it.
The Listing
Program 5 doesn't do anything too amazing, but with it you'll draw an orange-coloured bar on the screen. It's a building block for more complex and more interesting graphics programs to come soon in this book.
;********************************************
;* Assembly Language Graphics for the TRS-80 Color Computer *
;* by Don and Kurt Inman, 1983 *
;* Program 5 - Colour Bar *
;* 6809 assembly language for Tandy CoCo *
;* David Kroeker, 06-Dec-2025 *
;* Print red colour bar in middle of screen *
;********************************************
ORG $1E00
Start LDA #$E0 ; Select mode 6C (4 colour graphics mode)
STA $FF22 ; Set graphics mode
STA $FFC3 ; Store anything here to force mode change
STA $FFC5 ; Store anything here to force mode change
CLRA ; Clear screen
CLRB ; Clearing both A and B registers prepares us to store D to screen below
LDX #$400 ; Start of graphics memory
Loop1 STD ,X++ ; Clear graphics memory
CMPX #$1C00 ; End of graphics memory
BLO Loop1 ; Loop until all cleared
LDX #$1208 ; First line of colour bar
JSR DisplayBar ; Display line 1 of the colour bar
LDX #$1228 ; Second line of colour bar
JSR DisplayBar ; Display line 2 of the colour bar
LDX #$1248 ; Third line of colour bar
JSR DisplayBar ; Display line 3 of the colour bar
Loop2 JSR $A1B1 ; Wait for a key press (poll keyboard)
CMPA #$58 ; Was 'X' pressed?
BNE Loop2 ; If not, keep waiting
LDA #$60 ; Load space character
LDX #$400 ; Top of screen
Loop3 STA ,X+ ; Clear one character at at time
CMPX #$600 ; End of screen?
BLO Loop3 ; Loop until end of screen
LDA #$00 ; Set mode back to text
STA $FF22 ; Set graphics mode
STA $FFC2 ; Store anything here to force mode change
STA $FFC4 ; Store anything here to force mode change
RTS ; Return from subroutine
DisplayBar
LDB #$08 ; Display 8 bytes
LDA #$55 ; Load red colour. Only need to do this once, so moving Get label to the next line.
Get STA ,X+ ; Store red colour byte
DECB ; Decrement byte counter
BNE Get ; Loop until 8 bytes stored
RTS ; Return from subroutine
END Start
More graphics programs are on the way!
David
14-Dec-2025
Comments
Post a Comment