Simple Paint App from X-PAD Manual

Got code snippets to share? This is the place for you!
Brani di codice da condividere? Questo è il posto per te!
Avez-vous des extraits de code à partager ? C'est l'endroit pour vous !
Post Reply
User avatar
ericomont
Posts: 20
Joined: Sun Oct 08, 2023 11:31 am

Simple Paint App from X-PAD Manual

Post by ericomont »

Hello chaps.

This is an X-PAD, a pen tablet for the TRS-80 Color Computer (COCO):
Image

It works similar to modern Wacom Tablets and has quite a nice precision and resolution.
This Disk Extended Color Basic (DECB) program from the manual shows how one can do a simple paint app using it.
Image

So the native DECB program is using a bunch of PEEks to pool some memory location for the X, Y coordinates and the pen's pressure (S).
We can PEEK in ugBasic so why not convert this code?

Here it is, I'm creating labels so to keep to the original code structure (numbered lines) but keep in mind this should be re-written to make use of modern basic techniques and controls available on ugBasic. It works both ways though :)

Code: Select all

SCREEN #14:COLOR #0, #5			:'Set graphic resolution 256x192x2, CSS1
x=0:y=0:s=0:x1=0:y1=0			:'Declare variables: X and Y coords, pressure and older coords values

CLS BLACK				:'Clear the screen 
LINE 0,8 TO 256,8			:'Draw a top line to split HUD from draw area

subread:
GOSUB xread				:'Read tablet coords and pressure
IF s<>3 THEN GOTO subread		:'Cycle if pen is hovering

POINT AT(x,y)				:'Draw a point on the pen coords

coordcap:
x1=x:y1=y				:'Get old pen coords
GOSUB xread				:'Read tablet coords and pressure

IF s<>3 THEN GOTO subread		:'Return to first cycle if pen is hovering
LINE x1,y1 TO x,y,0			:'Draw a line from old to new coords
GOTO coordcap				:'Cycle

xread:
x=PEEK(65376)				:'Read tablet coords and pressure
y=PEEK(65377)
s=PEEK(65378)

LOCATE 0,0:PRINT "x=";x;" "		:'Print HUD
LOCATE 5,0:PRINT " y=";y;" "
LOCATE 11,0:PRINT " s=";s;
RETURN
Last edited by ericomont on Fri Feb 21, 2025 10:48 pm, edited 1 time in total.
User avatar
ericomont
Posts: 20
Joined: Sun Oct 08, 2023 11:31 am

Re: Simple Paint App from X-PAD Manual

Post by ericomont »

And here is a video of Antonio Caballero testing the ugBasic app with the real hardware:
https://streamable.com/8wu18m
Post Reply