Tiny Basic on the XGS PIC Gamestation-UPDATE

NOTE: please excuse the crudeness of the photos. I am photographing a cheap television screen with my iPhone. I promise better screen caps once I get the video grabber up on the PC I use.

IMG_2370It’s almost ready…XGS ARDBasic 1.0 is about ready to be unleashed on the public. Or, at least, anyone who owns an XGS PIC Gamestation product and would like to program on the device.

Since my last post, I’ve had a whale of a time tracking down a couple of showstopper bugs. Fortunately, I have fixed them and, while there is still a bug or two, I can run the interpreter, reliably, on the device itself.

I have also extended the tiny language to include:

  • primitive, TRS-80 like, graphics
  • sound
  • ability to utilize the SPI port
  • SD card files (Load, Save, Delete and directory listing)
  • Gamepad
  • ability to change foreground and background color for whole screen


IMG_2376So far, however, the graphics are very blocky, 20 across, by 22 down. I guess it is more like the old Vic-20 than the TRS-80.  I have a set of 13 special characters that can be set with the ‘GPRINT’ statement that mimic the character graphics of the TRS-80 Color Computer. I also plan to extend them to include things like a generic figure, plane, car, etc. I cannot go too crazy as it eats up memory.  The new screen oriented statements are:

  • SET x,y – sets a block
  • RESET x,y – turns a block ‘off’
  • LOCATE x,y – puts the next ‘print’ statement location at x and y where y is the ROW and x is COLUMN
  • GPRINT x,y,c – puts one of the 13 special characters at location x,y
  • COLOR f,b – changes the screen foreground color to f and the background to b


The XGS PIC has two gamepad ports. Both are readable via the PAD function. Each button on the gamepad returns a multiple of two, so it is easy to determine which button was pressed. For example, the SELECT button returns 32 for the value, so checking for PAD=32 will let you know if the SELECT was pressed. See the Etch-A-Sketch sample code at the end of this post.


IMG_2378Full documentation will be forthcoming, I am still deciding of a few things but should have some kind of document ready in the coming weeks.  I have added support for the XGS’ SPI port and may add support for other ports as well (like the UART.) I have also changed the RND function, so I need to re-write that part of my document as well. So, holding off on the documentation until I nail down the rest of the design seems prudent.

One thing I plan to do, again, at a later date, is to post technical details about the design and some of the issues I’ve encountered (and how they were resolved) with the XGS and the interpreter. It’s been a ton of fun and loads of learning, or, rather, re-acquainting myself with C. 

In the meantime, I present a sample demo that I threw together. It is a very, very crude Etch-A-Sketch:

100 CLS                         clear the screen
110 PRINT "GAMEPAD DEMO"        show the folks what this is
111 LOCATE 0,22                 move print position to last line
112 PRINT "RED:SET YELLOW:RSET" show what the red and yellow buttons do
120 X=1:Y=1:S=1                 set our pointers to 1
130 P=PAD(0)                    read the gamepad
131 P=PAD(0)                    do this twice to ensure you get a value
135 IF P=0 GOTO 130             if nothing is pressed, loop back
140 IF P=8 Y=Y-1                DOWN was pressed
150 IF P=4 Y=Y+1                UP
160 IF P=1 X=X+1                RIGHT
170 IF P=2 X=X-1                LEFT
180 IF X<1 X=1                  check to see if we are
185 IF X>19 X=19                out of bounds
186 IF Y<1 Y=1
187 IF Y<20 Y=20
200 IF P=64 S=1                 RED means draw
210 IF P=128 S=-1               YELLOW means don’t draw
220 IF S>0 SET X,Y              draw on RED
230 IF S<0 RESET X,Y            don’t draw on YELLOW
240 IF P=32 RUN                 SELECT means start over
250 IF P=16 STOP                START means stop
260 LOCATE 13,0                 put up the cursor location
270 PRINT X,",",Y," "
280 P=0                         reset the gamepad pointer
290 GOTO 130                    do it again

PLEASE NOTE: the comments in the listing above are for the purposes, in this blog, of explaining the code, they are not part of the code.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s