Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C64 Basic cursor positioning?

3,726 views
Skip to first unread message

Tim D. Childs

unread,
Oct 18, 1994, 12:27:05 PM10/18/94
to
I'm helping a friend port a basic program to his C64, and we need to be able
to position the cursor (same as LOCATE in MS-Basic or HTAB and VTAB on the Apple][).
C64 basic doesn't seem to have any such command built in.
I'm sure there must be a technique to do that. Can anyone help? Thanks in advance.

Wonderbar

unread,
Oct 18, 1994, 1:40:04 PM10/18/94
to

On the 64, you use the cursor keys to move the cursor. For example,
suppose you want to move the cursor 5 lines down and 5 columns across:

10 PRINT "{CLR}":REM HIT THE CLEAR KEY, AN INVERSE HEART WILL SHOW UP
BETWEEN THE QUOTES.
20 PRINT "{5 CRSR-DOWN}{5 CRSR-RIGHT}THIS IS 5 DOWN AND 5 ACROSS.":REM
HIT THE CURSOR DOWN KEY 5 TIMES AND THE CURSOR RIGHT KEY FIVE TIMES.

10 inverse characters will appear in the quotes next to the text. When
you run the program, the cursor will move as desired and the text will
show up in the correct position.
--
Casey Vanlandingham (cvan...@iastate.edu)
Welch 1258 Ayres
Ames, IA 50013-0018 515-294-7770

Nhat-Viet Phi

unread,
Oct 18, 1994, 10:29:05 PM10/18/94
to
Tim D. Childs (t...@pilot.msu.edu) wrote:

: I'm helping a friend port a basic program to his C64, and we need to be able


Hey, hey, hey!! Look what I found in the June 1992 issue of COMPUTE
Magazine, Gazette edition! (page G-24, "Programmer's Page" column)

POKE 211,C (moves cursor to specified Column, 0-79)
POKE 214,R (moves cursor to specified Row, 0-24)


Nhat-Viet Phi
nhat...@nucleus.com
Calgary, Alberta, Canada

Marko Mäkelä

unread,
Oct 23, 1994, 5:14:45 PM10/23/94
to
>>>>> "Nhat-Viet" == Nhat-Viet Phi <nhat...@nucleus.com> writes:

Nhat-Viet> Hey, hey, hey!! Look what I found in the June 1992 issue of
Nhat-Viet> COMPUTE Magazine, Gazette edition! (page G-24,
Nhat-Viet> "Programmer's Page" column)

Nhat-Viet> POKE 211,C (moves cursor to specified Column, 0-79)
Nhat-Viet> POKE 214,R (moves cursor to specified Row, 0-24)

Yes, but you must PRINT a carriage return after that, or the ($D1) and
($F3) pointers won't be changed. So, that's why you must make
POKE 214,(R-1)AND255:PRINT:POKE 211,C instead, as I suggested before.


Marko

Marko Mäkelä

unread,
Oct 21, 1994, 5:44:18 AM10/21/94
to
>>>>> "Wonderbar" == Wonderbar <cvan...@iastate.edu> writes:

Wonderbar> In <380t0p$14...@msuinfo.cl.msu.edu> t...@pilot.msu.edu (Tim


Wonderbar> D. Childs) writes:
>> I'm helping a friend port a basic program to his C64, and we need
>> to be able to position the cursor (same as LOCATE in MS-Basic or
>> HTAB and VTAB on the Apple][). C64 basic doesn't seem to have any
>> such command built in. I'm sure there must be a technique to do
>> that. Can anyone help? Thanks in advance.

Wonderbar> On the 64, you use the cursor keys to move the cursor. For
Wonderbar> example, suppose you want to move the cursor 5 lines down
Wonderbar> and 5 columns across:

But this method does not work if you want to use variables, like
"locate x,y". Of course you could define X$ a string of 39 crsr-rights
and Y$ a string of 24 crsr-downs and then do

print"{home}"left$(x$,x)left$(y$,y);

to get to the correct position (the top left corner is x=y=0), but
this is slow, as we all know how the Microsoft-programmed C= basic
handles strings.

The best way is to use the machine language, the PLOT function.
Load the Y coordinate to the X register and the X coordinate to
the Y register (again the top left corner is x=y=0), and clear the
Carry flag before calling $FFF0. Well, actually you can do this
even faster by pokeing the values to $d3 and $d6, like this:

poke214,(y-1)and255:print:poke211,x

But I just found out that this only works on the c64 (and the vic-20),
not in the c128 mode. Anyway, on the C128 you can do

bank15:sys65520,dummy,y,x,0

to do the same thing.


Marko

Daryl King

unread,
Nov 1, 1994, 5:59:10 AM11/1/94
to

Here's a technique out of Compute's "Mapping the 64".

POKE 781,VER:POKE 782,HOR:POKE 783,0:SYS 65520

Address 781 is where the .X register value is retrieved from before a SYS
command
Address 782 is for the .Y register and 783 is for the .P (status) register.

SYS 65520 calls the PLOT routine.

Deltar :)

Paul Lee

unread,
Dec 28, 2022, 2:37:10 PM12/28/22
to
This is such a late response, but if you are still there Marko, thank you so much. I was tearing my hair out, when my code was not setting the row. (but it was working everywhere else). You are a star!
0 new messages