EASy68K
http://www.easy68k.com/EASy68Kforum/

Position cursor
http://www.easy68k.com/EASy68Kforum/viewtopic.php?f=6&t=1595
Page 1 of 1

Author:  OutBlast00 [ Sat Jun 10, 2017 3:58 am ]
Post subject:  Position cursor

For a school project I need to create a program that does the following; Write a code segment that places a text string starting at the screen coordinates 25,15 (X,Y). Try modifying this code to repeatedly place a text string one line lower and one character to the right.

Begin
X = 25
Y = 15

Place cursor at 25,15
Print text string

While (X <= 30 and Y <= 20)
Print text string
X = X + 1
Y = Y + 1

Print Done message

This is what I have done so far, the only problem that I have is to be able to move the cursor position. When I input my x and Y, my cursor only moves in the row line and not in the column line.

Code:
Begin     
        move.w    #$2500,d1
        move.b    #$15,d1
        bsr     cursor
        lea     prompt6,a1
        bsr     print_string
        add.b  #$1,d1
        bra Begin
While
        cmp.w     #$3000,d1
        BLE       AND
        bra       done
AND
        *move.b    #$15,d1
        CMP.b     #$20,d1
        ble     message
        bra     done
       
       
message
          lea     prompt7,a1      * This is the number entered for variable A
          bsr     print_string
          *move.w  #$ff00,d1
          *bsr     cursor
          bra     addition   
Done
             
          lea     prompt8,a1      * This is the number entered for variable A
          bsr     print_string

addition
          add.w  #$100,d1
          add.b  #$1,d1
          bra    While

cursor
        movem.l d0-d7/a0-a6,-(sp)    * save registers
        move    #curs,d0             * place cursor     
        trap    #15                  * trap for I/O
        movem.l (sp)+,d0-d7/a0-a6    * restore registers
        rts

Author:  profkelly [ Sat Jun 10, 2017 12:00 pm ]
Post subject:  Re: Position cursor

Try to avoid using the BRA instruction, use structured loops instead (WHILE, FOR, REPEAT) it makes the code much easier to read and debug.

COMMENTS, COMMENTS, COMMENTS.

The first 'bra Begin' creates an infinite loop.

Author:  OutBlast00 [ Sat Jun 10, 2017 1:14 pm ]
Post subject:  Re: Position cursor

The bra A was something I was trying to make my cursor change position but was not supposed to be in my program.My cursor only moves down, it doesn't move to the right. How can I make my cursor move to the right and at the same time going down a row?

Author:  OutBlast00 [ Sat Jun 10, 2017 1:47 pm ]
Post subject:  Re: Position cursor

Can someone give me an example of how to move the cursor position on the X axis?

Author:  profkelly [ Sat Jun 10, 2017 9:53 pm ]
Post subject:  Re: Position cursor

Code:
*-----------------------------------------------------------
* Title      : Demo of Trap Task #11, Cursor Position
* Written by : Charles Kelly
* Date       : June-10-2017
* Description: Moves the cursor and displays some text.
*-----------------------------------------------------------
    ORG    $1000
START:
    * The high byte of D1.W holds the COL number (0-255).
    * The low byte of D1.W holds the ROW number (0-128).
    * 0,0 is top left.
    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$0A0A,D1   ; Column 10, Row 10.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'A',D1     ; Letter 'A'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay
   
    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$140A,D1   ; Column 20, Row 10.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'B',D1     ; Letter 'B'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$1414,D1   ; Column 20, Row 20.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'C',D1     ; Letter 'C'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    move.b  #11,D0      ; Cursor Position trap task.
    move.w  #$0A14,D1   ; Column 10, Row 20.
    trap    #15         ; Move cursor.
    move.b  #6,D0       ; Display ASCII character from D1.b
    move.b  #'D',D1     ; Letter 'D'
    trap    #15         ; Display char
    move.b  #23,D0      ; Delay n/100 second. D1.L = n
    move.l  #100,D1     ; 1 second delay
    trap    #15         ; Perform delay

    * Clear screen
    move.b  #11,D0      ; Clear screen
    move.w  #$FF00,D1
    trap    #15         ; Perform clear
   
    bra     START       ; <<<<< INFINITE LOOP >>>>>   

    SIMHALT             ; halt simulator

* Variables and constants

    END    START        ; last line of source

Author:  OutBlast00 [ Sun Jun 11, 2017 1:22 am ]
Post subject:  Re: Position cursor

Thank you very much !!!!!!

Author:  OutBlast00 [ Sun Jun 11, 2017 5:28 am ]
Post subject:  Re: Position cursor

What do I need to do if I wanna print a string of letter starting at that cursor position?

Author:  OutBlast00 [ Sun Jun 11, 2017 4:14 pm ]
Post subject:  Re: Position cursor

I did figure it out thank you everything

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/