Commodore logo

Commodore GEOS Programming Tips

(last updated 2020-10-20)
Commodore logo
back to main GEOS page
geoProgrammer ad

geoProgrammer ad (click to enlarge)

geoProgrammer cover

geoProgrammer manual cover

This is a collection of GEOS programming tips 'n' tricks that I've collected over the years. I continue to learn this fascinating subject, and new tips are being added as I come across things that I think might be helpful to others.

Assembling and Linking GEOS Applications
General Programming Tips
API usage tips
geoDebugger commands
geoDebugger macros
geoProgrammer Quirks
Compute!'s Gazette geoProgrammer example

Assembling and Linking GEOS Applications

General Programming Tips

API Usage Tips

geoDebugger commands

Here's a handy cheat sheet of geoDebugger commands; see the manual for full descriptions.

geoDebugger macros

geoProgrammer Quirks

Compute!'s Gazette geoProgrammer example

A geoProgrammer sample program was published in the October 1988 issue of Compute!'s Gazette (available on Bombjack). There's a review of geoProgrammer on page 59, and the sample program is on page 76; Bruce Thomas has typed in the source and provided the icons as well. Here is the D64 he sent with all the files on. Note: there's a bug in the program, can you find it? Since I'm sure Bruce put it there on purpose as an exercise for the reader, let's break out geoProgrammer and take up the challenge!
  1. I'm going to assume that you're running GEOS 2.0 and using an REU, which geoDebugger really needs.
  2. Looking at the code, we see that there's an undocumented feature: once you click the icon that appears at start time, you can enter some text in a box that appears on the screen as soon as you hit a key. Try it on the "unfixed" version... you will get a system crash (it works partially under Wheels, but that's another story for another day).
  3. Assemble the source files Ex and ExHdr, then run the linker, passing the file ex.lnk.
  4. Double-click the resulting debugger file CG-Example.dbg to start geoDebugger.
  5. We see from the source code that when the initial icon is pressed at DoIcon1, a key handler is set up with the address of DoKey. Have a quick look at that code by typing  a DoKey and cursoring down until you hit the call to jsr GraphicsString, then hit Return. We're looking at the expansion of the macro LoadW r0,DrawBox.
  6. Type sym DrawBox; we see that the code is passing the correct address to GraphicsString.
  7. OK, let's step through it to see where the problem lies. Set a breakpoint by typing setb DoKey, then go to start the program.
  8. Click the icon to dismiss it, then type a key. The debugger stops at DoKey. So far, so good.
  9. Now step through the code using t (top-step). We're OK until we reach the call to jsr GraphicsString, but then get a crash. Type rboot to reboot GEOS, then restart the debugger as above.
  10. Hmmm, it looks like GraphicsString doesn't like the data we're passing it. Let's examine it by using the command d DrawBox, which will give us a hex hex dump of the table.
  11. Now open your trusty Hitchhiker's Guide to GEOS and find the API docs for GraphicsString. Let's compare the data in the table with what the API is expecting.
  12. 05 means NEWPATTERN, and it's followed by a zero byte for the pattern. No problem there.
  13. The next byte is 56... wait, that's not a valid command! We have found the bug! Looking ahead in the source code, we see a RECTANGLETO command, which should be preceded by a MOVEPENTO command. Maybe that's all that was missing, as the following bytes would then make sense (56 00 and 5A). Comparing the source with the original in the Compute! article, we find that this is indeed the case. Insert the missing line (.byte MOVEPENTO) in the Ex file, reassemble it, and rerun the linker as above. The bug is squashed!
  14. You can find the fixed code (with object files, geoDebugger file, and symbol table) here. For extra credit, try implementing these enhancements:

Not to be outdone, Bruce responded with an enhanced version of the program, which you can find here. Bruce scores the extra credit points (note his use of picW and picH after the icon graphic)! Now who else wants to join the fray? What else can you think of to make this program an even better example of using geoProgrammer?

back to main GEOS page