Page 1 of 1

Simple Paint App from X-PAD Manual

Posted: Fri Feb 21, 2025 10:34 pm
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

Re: Simple Paint App from X-PAD Manual

Posted: Fri Feb 21, 2025 10:44 pm
by ericomont
And here is a video of Antonio Caballero testing the ugBasic app with the real hardware:
https://streamable.com/8wu18m