Jump to content
  • 1
K4TFJ

Accessing current cursor position? How?

Question

In BASIC... my goal is to create a status line at bottom of my screen  to update occasionally and I will need to store the current cursor location temporarily while i update the line. Then return to stored cursor location and continue.

I need to locate the current cursor position: HOW???

I am currently using this for positioning:  POKE $30D, ROWPOKE $30E, COL: SYS $FFF0

I don't know if that is the best, but without a LOCATE command... its all I know at the moment.

Enlighten me please!

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I don't know about BASIC, but in Assembly you can call the PLOT kernal routine ($fff0) with the carry bit set:

sec

jsr $fff0

Then, the X and Y registers will contain the coordinates.

Share this post


Link to post
Share on other sites
  • 0

I do not think that BASIC has a function to return the current cursor location, but as SlithyMatt mentions, the KERNAL has an API call that can be used.

Here is a BASIC program that shows how to use the PLOT API call.

Quote

10 A=780:           REM A-REGISTER

20 X=781:           REM X-REGISTER

30 Y=782:           REM Y-REGISTER

40 F=783:           REM FLAGS-REGISTER

50 I=PEEK(F):    REM READ FLAGS

60 I=I AND $FE: REM CLEAR CARRY FLAG TO SET CURSOR POSITION

70 POKE F,I

80 POKE X, 20:  REM MOVE CURSOR TO LINE 20 (X-REGISTER = Y COORDINATE)

90 POKE Y,45:    REM MOVE CURSOR TO COLUMN 45 (Y-REGISTER = X COORDINATE)

100 SYS $FFF0: REM CALL THE PLOT KERNAL API

110 INPUT M$:  REM WAIT FOR USER TO ENTER SOMETHING IN ORDER TO SEE CURSOR HAS MOVED

For further information, you can check out the SYS statement: https://www.c64-wiki.com/wiki/SYS

The PLOT API call: https://cx16.dk/c64-kernal-routines/plot.html

Flag locations in the FLAGS register, see page 8 of the w65c02 datasheet: https://eater.net/datasheets/w65c02s.pdf

 

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

Please review our Terms of Use