Draw at cursor location

ilennie

New Member
Sep 20, 2019
3
0
1
I want to draw a shape at a specific on screen cursor location.

In GWBASIC there is the DRAW command and the Locate command.

How can u do that in X16?
 

Threesheds

New Member
Sep 20, 2019
3
0
1
I want to draw a shape at a specific on screen cursor location.

In GWBASIC there is the DRAW command and the Locate command.

How can u do that in X16?
I've only just starting learning vera myself, but it depends what drawing mode you're in. If you want to draw with pixels, you need to go into bitmap screen mode (mode 5, 6 or 7). I'm pretty sure there's no DRAW command in X16 BASIC (just like there isn't in vanilla C64 BASIC), so to draw an arbitrary shape you'd need to turn on individual pixels that make up the shape. Bitmap data memory organisation hasn't been explained yet in the vera 0.8 documentation so further than that I don't know, sorry.

Link to vera doc:
Vera 0.8 docs
 

Panda

New Member
In BASIC on the C64 (and currently with the X16) there is no LOCATE command.
instead, you use the print statement with characters that represent cursor movements.

The reverse "S" for example goes HOME (to the top of the screen)
"]" moves the cursor to the right
"Q" moves the cursor down
"|" moves left
There is also a circle character for up

You create these characters when typing in quotes by pressing the HOME key and arrow keys


cursor.png
 
May 22, 2019
409
211
43
Looking at the KERNAL jump table, PLOT is located at $FFF0.
The X register is the row, and the Y register is the column.

When calling machine language routines with SYS in BASIC, we can pre-load the registers by writing values into memory locations 780-783
780: Accumulator (A)
781: X Register
782: Y Register
783: Program Status Byte, aka Flags.

So we can call any KERNAL routine from BASIC, now that we know how to preload the registers.

POKE 781,X: this writes the column to the X register
POKE 782,Y: this writes the row to the Y register
POKE 783,0: Clear the flags. (PLOT uses the carry flag.)
SYS $FFF0: this actually jumps to the jump table entry for the KERNAL PLOT routine, which moves the cursor to an arbitrary point on the screen.
 

Ed Minchau

New Member
Oct 5, 2019
3
4
3
Looking at the KERNAL jump table, PLOT is located at $FFF0.
The X register is the row, and the Y register is the column.

When calling machine language routines with SYS in BASIC, we can pre-load the registers by writing values into memory locations 780-783
780: Accumulator (A)
781: X Register
782: Y Register
783: Program Status Byte, aka Flags.

So we can call any KERNAL routine from BASIC, now that we know how to preload the registers.

POKE 781,X: this writes the column to the X register
POKE 782,Y: this writes the row to the Y register
POKE 783,0: Clear the flags. (PLOT uses the carry flag.)
SYS $FFF0: this actually jumps to the jump table entry for the KERNAL PLOT routine, which moves the cursor to an arbitrary point on the screen.
This is very good to know.
 
  • Like
Reactions: TomXP411
May 22, 2019
409
211
43
Edit to add: this is the sort of thing that should be on an Important Memory Locations list in the programmers reference manual.
Arguably a correct statement. And it is listed in the Commodore 64 Programmer's Reference manual, although it's never really called out in the manual as a way to set the cursor location. In fact, the SYS command really should have been better explained and explored more fully in the C64 reference manual.