TRS-80 COLOUR COMPUTER SPACE ADVENTURES
Six type-in BASIC game programs and three sections about BASIC programming for Tandy Color Computers with only 16K RAM and Extended Color BASIC.
Thank you @MrDave6x09 on the CoCo Discord for the gift of the book!
SPEED UP BUG AND FIX
The introduction to the book lists an incomplete set of commands to implement a “speed up” to avoid the BREAK key checking.
Instead of the lines in the book introduction, add the following lines at the top to disable BREAK key checking and switch the SAM into Address Dependent speed mode:
1 IF PEEK(&H3EB9)<>&H32 THEN CLEAR200,&H3EB0: FOR I=&H82B9 TO &H831E:POKE I-&H4400,PEEK(I):NEXT ELSE 6 2 FORI=0TO2:POKE &H3EBD+I,18:NEXT:I=&H3F1E 3 POKE I,&H26:POKE I+1,3:POKE I+2,&H7E:POKE I+3,&H83:POKE I+4,&H22:POKE I+5,&H7E 4 POKE I+6,&HA4:POKE I+7,&H4C 5 POKE &H019A,&H39:POKE &H019B,&H3E:POKE &H019C,&HB9:POKE &H019A,&H7E 6 POKE 65495,0
Line 1
The IF PEEK checks to see if lines 1-5 have already been run.
If not, clears a section of memory at the top of the 16K RAM and tells BASIC ROM not to use it for variables.
Then it runs a loop to copy the Extended Color BASIC ROM addresses $82B9 through $831E down to addresses $3EB9 to $3F1E.
This copies the Extended Color BASIC command interpreter loop and start of the CSAVE command into RAM to modify it.
Line 2
Line 2 places three No Operation (NOP 0x12 or decimal 18) instructions into the RAM copy of the command interpreter where the “jump to subroutine to check BREAK key” instructions are.
Line 3 and 4
Line 3 and 4 place the following new instructions at the end of the copied BASIC ROM code:
3F1E 26 03 BNE $3F23 ; continuing ROM code - is next letter M for CSAVEM? No ... branch to 3F23 3F20 7E 83 22 JMP $8322 ; yes it was an M, jump to ROM CSAVE 3F23 7E A4 4C JMP $A44C ; no, it was not an M, so jump to where the original ROM code did: A44C
This repatches the end of the CSAVE/CSAVEM check to have new relative addresses and call $A44C if its not CSAVEM or call the rest of the original CSAVE up in ROM if it was a CSAVEM.
Line 5
Line 5 places the following instruction in $019A-$019C, replacing the three “RTS” instructions or JMP instructions originally put there when Color BASIC, Extended Color BASIC, or Disk Extended Color BASIC initialized at power on:
JMP $3E2B ; go execute the patched ROM code in RAM without the BREAK check
This “vectors” BASIC calls to the XVEC20 ROM command interpreter to our new BREAK key-less copy in RAM.
The new patched XVEC20 then does the same work without checking for BREAK and jumps back into ROM when done.
Important Note:
The first POKE &H019A,&H39 is to avoid crashing by undoing changes made to RVEC20 by Extended Color BASIC or Disk Extended Color BASIC ROMs so that the RVEC20 can then be changed without BASIC commands possibly calling a “broken” half-changed RVEC20 in the middle of being changed.
The last POKE on the line puts the JMP in place activating the new RAM patched routine once the rest of RVEC20 is in place.
The first POKE is not redundant. It's a necessary first step finished up by the last POKE.
Line 6
POKE 65495,0 configures the SAM Rate registers for Address Dependent speed mode.
The SAM Address Dependent speed-up switches the SAM clock divider from 16 to 8 when working with addresses from $8000 to $FFFF (ROM).
This runs the MPU at 1.789MHz when running the BASIC interpreter ROM code to speed it up.
But, the SAM kicks back down to the 16 clock divider to refresh RAM addresses in the $0000 to $3FFF (16K) or $0000 to $7FFF (32K) range while running the MPU at 0.89MHz.
And add the following to the last line each program restore the SAM normal speed on exit:
... POKE65494,0:END
Thanks!
Nothing quite like finding and fixing bugs in ~40 year old book code.
Thanks to Erico Montero and William “Lost Wizard” Astle on the Color Computer Discord #basic channel for pointing out this code, and that it had bugs to fix, especially lost wizard for fixing my multiply messed up fixes!
Was fun to decode and understand what was going on and going wrong.
SEE ALSO
https://colorcomputerarchive.com/ in the “Books” section.
https://www.cocopedia.com/wiki/index.php/TRS-80_Colour_Computer_Space_Adventures
Also published as Getting Ahead Space Games for Commodore VIC-20 and Commodore 64.
RTS
Return to Tandy Color Computer