Shop OBEX P1 Docs P2 Docs Learn Events
How to set X and Y positions with VGA_text object ***SOLVED*** — Parallax Forums

How to set X and Y positions with VGA_text object ***SOLVED***

CrosswindsCrosswinds Posts: 182
edited 2010-04-18 00:08 in Propeller 1
Hello.

Im currently using VGA_text object in my project.

And the only thing that im missing now is to move around the text "cursor" on the screen.




For example

first i print "hello" in the top left corner (thats simple)


But then i want to move the cursor so that i can print "everyone"in the bottom right corner,(or somewere else for that matter[noparse]:)[/noparse])


Thanks


Post Edited (Crosswinds) : 4/17/2010 7:41:37 PM GMT

Comments

  • James NewmanJames Newman Posts: 133
    edited 2010-04-17 17:20
    Look at VGA_Text.spin. The 'out' function provides this functionality, and is well documented in the source.
  • CrosswindsCrosswinds Posts: 182
    edited 2010-04-17 17:25
    Hello James, thank you for your answer.


    Yes i have seen this, but i cant figure out how to use it actually..

    it says:

    $0A = set X position (X follows)
    $0B = set Y position (Y follows)

    But what should the syntax look like?


    For example:

    vga.out($0A) send $0A to it, but where, and how should i enter the X position?
  • JRetSapDoogJRetSapDoog Posts: 954
    edited 2010-04-17 19:17
    Hi, Crosswinds. You've probably figured this out already, but you send the X value immediately afterwards, and similarly for the y-axis. In other words, the $0A and $0B values "prime" the procedure to respectfully expect the X and Y coordinates immediately afterwards (i.e., failure to follow through and send a coordinate value after sending either $0A or $0B would be a logic error).

    So, for example, to move the cursor to row 5, column 10, for an object named vga you'd issue: vga.out($0A); vga.out(10); vga.out($0B); vga.out(5), with those instructions on four separate lines (decimal or hex can be used for the coordinates). That should (don't have a test board handy, ha) set the cursor such that the next vga.out printing instruction should take place at the set cursor position. Regarding the documentation, in that the procedure only takes one parameter/argument, you have to use a second .out instruction to send the coordinate. Again, the procudure will remember that you've sent either $0A or $0B and be expecting the actual coordinate value. Incidentally, as I recall, you can set the X- and Y-coordinates independently. That is, nothing compells you to set both at (nearly) the same time. They are set independently. If you only change one, the other will retain its value. Onward and upwards.
  • James NewmanJames Newman Posts: 133
    edited 2010-04-17 19:25
    Yep, this is a snippet of code from an old project:
    'display.out($0A) 'Set X
    'display.out(0)
    'display.out($0B) 'Set Y
    'display.out(2)

    That set the draw location to 0,2 so I could draw an alert. Right afterwards is a display.str(). It was commented out in favor of some constants that defined where the alert was located, along with some logic to center it.
  • CrosswindsCrosswinds Posts: 182
    edited 2010-04-17 19:39
    Thanks guys! That is exactly what i was looking for!


    Case solved [noparse]:)[/noparse]
  • GiemmeGiemme Posts: 85
    edited 2010-04-18 00:08
    Hi Crosswinds

    I wrote this small subroutine to use it everywhere in the programm:

    PUB Plot (x,y)
    display.out($0A) 'Set X
    display.out(x)
    display.out($0B) 'Set Y
    display.out(y)

    Regards
    Gianni
Sign In or Register to comment.