1
0
mirror of https://github.com/cc65/cc65.git synced 2024-08-15 21:29:23 +00:00
cc65/libsrc/atari/mcbdefault.s
2014-01-20 23:04:29 +01:00

113 lines
2.7 KiB
ArmAsm

;
; Default mouse callbacks for the Ataris
;
; Christian Groessler, 03.01.2014
;
; derived from Apple2 version by
; Oliver Schmidt, 22.09.2005
;
; All functions in this module should be interrupt safe, because they may
; be called from an interrupt handler
;
.export _mouse_def_callbacks
.importzp tmp4
.import mul40,loc_tmp
.include "atari.inc"
; ------------------------------------------------------------------------
.bss
backup: .res 1
; ------------------------------------------------------------------------
.segment "EXTZP" : zeropage
scrptr: .res 2
; ------------------------------------------------------------------------
.rodata
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
.addr movex
.addr movey
; ------------------------------------------------------------------------
.data
cursor = 11 ; '+' screen code'
; setcursor
getcursor:
column: ldy #$00 ; Patched at runtime
lda (scrptr),y ; Patched at runtime
cmp #cursor
rts
setcursor:
lda #cursor
setscr: sta (scrptr),y ; Patched at runtime
rts
; ------------------------------------------------------------------------
.code
done:
rts
; Hide the mouse cursor.
hide:
jsr getcursor ; Cursor visible at current position?
bne done ; No, we're done
lda backup ; Get character at cursor position
jmp setscr ; Draw character
; Show the mouse cursor.
show:
jsr getcursor ; Cursor visible at current position?
beq done ; Yes, we're done
sta backup ; Save character at cursor position
jmp setcursor ; Draw cursor
; Move the mouse cursor x position to the value in A/X.
movex:
cpx #1
ror a
lsr a ; convert to character position
lsr a
sta column+1
rts
; Move the mouse cursor y position to the value in A/X.
movey:
tax
ldy tmp4 ; mul40 uses tmp4
lda loc_tmp ; and this local variable
pha
txa ; get parameter back
lsr a ; convert y position to character line
lsr a
lsr a
jsr mul40
clc
adc SAVMSC
sta scrptr
txa
adc SAVMSC+1
sta scrptr+1
pla
sta loc_tmp
sty tmp4
rts