Tag Archives: Assembly

How to locate and set the cursor on your Commodore C128

Commodore LogoSadly the Commodore machines don’t offer a routine to locate or set the current cursor position via BASIC. There is however a Kernel routine named PLOT which can do this in Machine Language.

Here’s how we can utilise it.

Getting the Cursor Position

This snippet sets the carry flag, calls the PLOT routine at $FFF0 and returns the cursor position in the X and Y registers. We’ll put them in a safe place into $1400 and $1401 to use.

You can call it from BASIC with

Setting the Cursor Position

Call it from BASIC by POKEing your desired coordinates into $1400 and $1401, then call SYS DEC(“1310”).

This snippet will do the reverse of the above: populate the X and Y registers from our safe place and then call PLOT. We clear the carry flag first, because it decides if the position is read (carry clear) or set (carry set).

PLOT should work fine on the C64 and Plus/4 as well but I didn’t get a chance to test it yet.