mirror of
https://github.com/cc65/cc65.git
synced 2025-08-08 06:25:17 +00:00
Add setcursor method
This commit is contained in:
@@ -23,9 +23,9 @@
|
|||||||
; definitely not allow direct access to the variables.
|
; definitely not allow direct access to the variables.
|
||||||
;
|
;
|
||||||
|
|
||||||
.export _cursor_visible
|
.export _setcursor
|
||||||
.export _cursorzone
|
|
||||||
.export _gotoxy, _gotox, _gotoy, wherex, wherey
|
.export _gotoxy, _gotox, _gotoy, wherex, wherey
|
||||||
|
.export CURS_X, CURS_Y
|
||||||
.constructor init_cursor
|
.constructor init_cursor
|
||||||
|
|
||||||
.importzp ptr1, sp
|
.importzp ptr1, sp
|
||||||
@@ -36,6 +36,10 @@
|
|||||||
.macpack generic
|
.macpack generic
|
||||||
|
|
||||||
.data
|
.data
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; The variables used by cursor functions
|
||||||
|
;
|
||||||
|
|
||||||
CURS_X:
|
CURS_X:
|
||||||
.byte 0
|
.byte 0
|
||||||
CURS_Y:
|
CURS_Y:
|
||||||
@@ -49,6 +53,18 @@ _cursorzone:
|
|||||||
|
|
||||||
.code
|
.code
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
; Enable/disable cursor
|
||||||
|
;
|
||||||
|
.proc _setcursor
|
||||||
|
|
||||||
|
ldx _cursor_visible
|
||||||
|
sta _cursor_visible
|
||||||
|
txa
|
||||||
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Calculate cursorzone address
|
; Calculate cursorzone address
|
||||||
; You also need to set the cursorzone to point to the correct cursor Header
|
; You also need to set the cursorzone to point to the correct cursor Header
|
||||||
@@ -56,7 +72,8 @@ _cursorzone:
|
|||||||
; Offset to cursor zone 5. To next line offset 11
|
; Offset to cursor zone 5. To next line offset 11
|
||||||
; cursorzone points to _zones + CURS_Y * 11 + 5
|
; cursorzone points to _zones + CURS_Y * 11 + 5
|
||||||
; A = CURS_Y
|
; A = CURS_Y
|
||||||
calccursorzone:
|
.proc calccursorzone
|
||||||
|
|
||||||
jsr pusha0
|
jsr pusha0
|
||||||
lda #11
|
lda #11
|
||||||
jsr tosumula0
|
jsr tosumula0
|
||||||
@@ -71,6 +88,8 @@ calccursorzone:
|
|||||||
sta ptr1+1
|
sta ptr1+1
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Set cursor to Y position.
|
; Set cursor to Y position.
|
||||||
; You also need to set the cursorzone to point to the correct cursor Header
|
; You also need to set the cursorzone to point to the correct cursor Header
|
||||||
@@ -86,7 +105,9 @@ calccursorzone:
|
|||||||
; Enable cursor
|
; Enable cursor
|
||||||
; if showcursor cursorzone[1] = 30
|
; if showcursor cursorzone[1] = 30
|
||||||
;
|
;
|
||||||
_gotoy: pha
|
.proc _gotoy
|
||||||
|
|
||||||
|
pha
|
||||||
lda CURS_Y
|
lda CURS_Y
|
||||||
jsr calccursorzone
|
jsr calccursorzone
|
||||||
ldy #1
|
ldy #1
|
||||||
@@ -96,18 +117,23 @@ _gotoy: pha
|
|||||||
sta CURS_Y
|
sta CURS_Y
|
||||||
jsr calccursorzone
|
jsr calccursorzone
|
||||||
lda _cursor_visible
|
lda _cursor_visible
|
||||||
beq L2
|
beq @L1
|
||||||
lda #30 ; enable cursor
|
lda #30 ; enable cursor
|
||||||
L2: ldy #1
|
@L1: ldy #1
|
||||||
sta (ptr1),y
|
sta (ptr1),y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Set cursor to X position.
|
; Set cursor to X position.
|
||||||
; You also need to set the hpos offset to the correct value on this line
|
; You also need to set the hpos offset to the correct value on this line
|
||||||
; cursorzone[3] = 8 * CURS_X
|
; cursorzone[3] = 8 * CURS_X
|
||||||
;
|
;
|
||||||
_gotox: tay
|
.proc _gotox
|
||||||
|
|
||||||
|
sta CURS_X
|
||||||
|
tay
|
||||||
lda _cursorzone
|
lda _cursorzone
|
||||||
ldx _cursorzone+1
|
ldx _cursorzone+1
|
||||||
sta ptr1
|
sta ptr1
|
||||||
@@ -121,6 +147,8 @@ _gotox: tay
|
|||||||
sta (ptr1),y
|
sta (ptr1),y
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.endproc
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; Set cursor to desired position (X,Y)
|
; Set cursor to desired position (X,Y)
|
||||||
;
|
;
|
||||||
|
Reference in New Issue
Block a user