Jump to content
IGNORED

How can I tell what character the cursor is on?


phoney

Recommended Posts

I'm writing an app which involves navigating a text cursor freely around the screen with the joystick.

 

I can obviously have the joystick change X and Y values for position, and print an inverse space to be the cursor.

 

But I need to store the character that was previously in the location before I overwrote it with the 'cursor' so I can put it back when I move the 'cursor.'

 

What address do I PEEK to find the character at a particular X and Y location in graphics 0? Thanks.

Link to comment
Share on other sites

Basic has the LOCATE X,Y,C statement that will return what colour/character is at that location.

Otherwise you could just PEEK the memory location.

The formula for would be SC=PEEK(88)+PEEK(89)*256

CA=SC+X+Y*40

 

Note that if you're talking text window with a graphics mode that these won't work, you'd need to refer to the locations relevant to that.

Also - LOCATE will return ASCII code, PEEK will give screen character code which in most cases will be different.

Link to comment
Share on other sites

1 REM *******************************
2 REM PROGRAM  : MOVING CURSOR WITH
3 REM JOYSTICK
4 REM AUTHOR   : ZLATKO BLEHA
5 REM PUBLISHER: MOJ MIKRO MAGAZINE
6 REM ISSUE NO.: 1988, NO.6, PAGE 42
7 REM *******************************
10 FOR A=1600 TO 1653
20 READ B:POKE A,B:C=C+B
30 NEXT A
40 IF C<>5925 THEN ? "*** DATA ERROR *
**":END
50 POKE 512,64:POKE 513,6:POKE 54286,1
92
60 POKE PEEK(560)+PEEK(561)*256+6,130
70 DATA 72,138,72,186,138,72,206,117,6
,208
80 DATA 27,169,4,141,117,6,162,8,189,1
07
90 DATA 6,205,120,2,208,8,189,108,6,14
1
100 DATA 252,2,208,4,202,202,208,236,1
04,170
110 DATA 154,104,170,104,64,7,135,11,1
34
120 DATA 14,142,13,143,4

 

  • Like 1
Link to comment
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.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   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.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...