It is currently Sat Dec 07, 2019 12:51 pm

 All times are UTC

 Page 1 of 1 [ 8 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: Position cursorPosted: Sat Jun 10, 2017 3:58 am

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
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
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
Done

lea     prompt8,a1      * This is the number entered for variable A
bsr     print_string

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

Top

 Post subject: Re: Position cursorPosted: Sat Jun 10, 2017 12:00 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1108
Try to avoid using the BRA instruction, use structured loops instead (WHILE, FOR, REPEAT) it makes the code much easier to read and debug.

The first 'bra Begin' creates an infinite loop.

_________________
Prof. Kelly

Top

 Post subject: Re: Position cursorPosted: Sat Jun 10, 2017 1:14 pm

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
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?

Top

 Post subject: Re: Position cursorPosted: Sat Jun 10, 2017 1:47 pm

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
Can someone give me an example of how to move the cursor position on the X axis?

Top

 Post subject: Re: Position cursorPosted: Sat Jun 10, 2017 9:53 pm

Joined: Thu Dec 16, 2004 6:42 pm
Posts: 1108
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

_________________
Prof. Kelly

Top

 Post subject: Re: Position cursorPosted: Sun Jun 11, 2017 1:22 am

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
Thank you very much !!!!!!

Top

 Post subject: Re: Position cursorPosted: Sun Jun 11, 2017 5:28 am

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
What do I need to do if I wanna print a string of letter starting at that cursor position?

Top

 Post subject: Re: Position cursorPosted: Sun Jun 11, 2017 4:14 pm

Joined: Sat Jun 10, 2017 3:49 am
Posts: 6
I did figure it out thank you everything

Top

 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Page 1 of 1 [ 8 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: profkelly and 8 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ EASy68K Forum    FAQ    Latest Features    EASy68K Questions    68000 Programming Questions    Wish List    Wishes Granted    Undocumented Features    Documented Features    General Discussion    EASy68K Projects