How to change cursor position?

Basic and Machine Language

Moderator: Moderators

adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

How to change cursor position?

Post by adric22 »

I'm having a heck of a time finding this with google. On the C64 there are two locations I can POKE for X,Y coordinates and then execute a SYS command and it will plant the cursor in a particular place for the next print statement. I can't seem to locate the equivalent on the VIC-20. Can somebody help?
rhurst
Omega Star Commander
Posts: 1371
Joined: Thu Jan 31, 2008 2:12 pm
Website: https://robert.hurst-ri.us
Location: Providence, RI
Occupation: Tech & Innovation

Post by rhurst »

Not recalling if I used this myself, but in Programmer's Reference Guide of user callable kernal routines:

PLOT Read/set X,Y cursor position @ $FFF0 (65520)

I believe X = rows, Y = cols in this case, and zero based.
Any technology distinguishable from magic is insufficiently advanced.
https://robert.hurst-ri.us/rob/retrocomputing
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Aren't those kernal calls just the same as on the c64?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Maybe the "poke" locations of the A X Y registers before a SYS isn't?
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

Boray wrote:Maybe the "poke" locations of the A X Y registers before a SYS isn't?
You know what.. I bet you are right.
User avatar
Kweepa
Vic 20 Scientist
Posts: 1316
Joined: Fri Jan 04, 2008 5:11 pm
Location: Austin, Texas
Occupation: Game maker

Post by Kweepa »

I just checked the PRG for each machine, and the memory locations are the same for each.

POKE781,X:POKE782,Y:SYS65520

The only difference is that (X,Y) is (column,row) on the VIC (sensible) and (row,column) on the C64 (stupid). Of course that could be a typo.
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

Kweepa wrote:I just checked the PRG for each machine, and the memory locations are the same for each.

POKE781,X:POKE782,Y:SYS65520

The only difference is that (X,Y) is (column,row) on the VIC (sensible) and (row,column) on the C64 (stupid). Of course that could be a typo.
I bet it is a typo because the last time I used that on the C64, I noticed the X and Y were backwards from what was documented.
User avatar
Pedro Lambrini
Vic 20 Scientist
Posts: 1132
Joined: Mon Dec 01, 2008 11:36 am

Post by Pedro Lambrini »

So, can I ask something?

If you put the above line between two print statements the program would print the first statement in the top left as normal and then the second line would print wherever X and Y are?
"...That of the Eastern tribe being like a multitude of colours as if a rainbow had settled upon its brow..." Daniels 1:3
adric22
Vic 20 Hobbyist
Posts: 143
Joined: Fri Mar 11, 2005 6:54 pm

Post by adric22 »

If you put the above line between two print statements the program would print the first statement in the top left as normal and then the second line would print wherever X and Y are?
Correct. usually this is much faster than trying to have some kind of loop using cursor movements if you need a dynamic way to move things around on the screen.
User avatar
Pedro Lambrini
Vic 20 Scientist
Posts: 1132
Joined: Mon Dec 01, 2008 11:36 am

Post by Pedro Lambrini »

^
Cool. Thank you. :)

I am incredibly bad at programming and have always put cursor key presses in my print statements as I knew of no other way. POKEing just has to run faster than that!
"...That of the Eastern tribe being like a multitude of colours as if a rainbow had settled upon its brow..." Daniels 1:3
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Alternatively you could use the TAB() function combined with a home made function for the y pos:

Code: Select all

10 L$="{home}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}{down}"
20 PRINT LEFT$(L$,12)TAB(11)"HELLO"
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Or maybe this is smaller:

Code: Select all

10 L$="{home}":FORT=1TO22:L$=L$+"{down}":NEXT
20 PRINT LEFT$(L$,12)TAB(11)"HELLO"
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Splitted the following discussion to a new thread:
"Garbage Collect (splitted)"
http://sleepingelephant.com/ipw-web/bul ... hp?p=67886
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
User avatar
Jeff-20
Denial Founder
Posts: 5761
Joined: Wed Dec 31, 1969 6:00 pm

Post by Jeff-20 »

Maybe I am misunderstanding the question, but here's my simple solution:

Code: Select all

1 PRINT SPC(22*Y) SPC(X);
Works for me.
High Scores, Links, and Jeff's Basic Games page.
Boray
Musical Smurf
Posts: 4064
Joined: Mon May 03, 2004 10:47 am

Post by Boray »

Jeff-20 wrote:Maybe I am misunderstanding the question, but here's my simple solution:

Code: Select all

1 PRINT SPC(22*Y) SPC(X);
Works for me.
Oh, so it does! I thought SPC printed a real space. So it seems TAB and SPC is the same function then.
Last edited by Boray on Thu Nov 15, 2012 12:44 pm, edited 1 time in total.
PRG Starter - a VICE helper / Vic Software (Boray Gammon, SD2IEC music player, Vic Disk Menu, Tribbles, Mega Omega, How Many 8K etc.)
Post Reply