- always use page 6 for P/M mouse cursor

- make cursor character of text mode callback configurable
- change default cursor character of text mode callback from 'plus' to 'diamond'
- set P/M callback as default
This commit is contained in:
Christian Groessler 2014-04-11 23:46:53 +02:00
parent 661203a89a
commit 526b440b24
5 changed files with 257 additions and 220 deletions

View file

@ -1,126 +1,8 @@
; ;
; Default mouse callbacks for the Ataris ; This file defines the default mouse callback
;
; 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 .import _mouse_pm_callbacks
.importzp tmp4 .export _mouse_def_callbacks
.import mul40,loc_tmp
.include "atari.inc" _mouse_def_callbacks := _mouse_pm_callbacks
; ------------------------------------------------------------------------
.bss
backup: .res 1
visible:.res 1
; ------------------------------------------------------------------------
.segment "EXTZP" : zeropage
scrptr: .res 2
; ------------------------------------------------------------------------
.rodata
; Callback structure
_mouse_def_callbacks:
.addr hide
.addr show
.addr prep
.addr draw
.addr movex
.addr movey
; ------------------------------------------------------------------------
.data
cursor = 11 ; '+' screen code'
; setcursor
getcursor:
column: ldy #$00 ; Patched at runtime
lda (scrptr),y
rts
setcursor:
column2:ldy #$00 ; Patched at runtime
sta (scrptr),y
rts
; ------------------------------------------------------------------------
.code
done:
rts
; Hide the mouse cursor.
hide:
dec visible
prep:
jsr getcursor ; Get character at cursor position
cmp #cursor ; "mouse" character
bne overwr ; no, probably program has overwritten it
lda backup ;
jmp setcursor ; Draw character
overwr: sta backup
rts
; Show the mouse cursor.
show:
inc visible
draw:
lda visible
beq done
jsr getcursor ; Cursor visible at current position?
sta backup ; Save character at cursor position
lda #cursor
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
sta column2+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

View file

@ -0,0 +1,32 @@
;
; P/M mouse shape default definition
;
; Christian Groessler, 11.04.2014
;
; Note that the height of the mouse cursor must not exceed 32
; lines, otherwise the display routines won't do The Right
; Thing(tm).
;
.export mouse_pm_bits
.export mouse_pm_height : absolute
.export mouse_pm_hotspot_x : absolute
.export mouse_pm_hotspot_y : absolute
.data
mouse_pm_bits:
.byte %11110000
.byte %11000000
.byte %10100000
.byte %10010000
.byte %10001000
.byte %00000100
.byte %00000010
mouse_pm_height = * - mouse_pm_bits
; hot spot is upper left corner
mouse_pm_hotspot_x = 0
mouse_pm_hotspot_y = 0

View file

@ -1,42 +1,48 @@
; ;
; P/M mouse callbacks for the Ataris ; P/M mouse callbacks for the Ataris
; ;
; Christian Groessler, 07.04.2014 ; Christian Groessler, 11.04.2014
; ;
; All functions in this module should be interrupt safe, because they may ; All functions in this module should be interrupt safe, because they may
; be called from an interrupt handler ; be called from an interrupt handler
; ;
.include "atari.inc" .include "atari.inc"
.importzp sp .importzp sp
.export _mouse_pm_callbacks
.constructor pm_init,27 .constructor pm_init,27
.destructor pm_down,7 .destructor pm_down,7
.export _mouse_pm_callbacks
; get mouse shape data
.import mouse_pm_bits
.import mouse_pm_height
.import mouse_pm_hotspot_x
.import mouse_pm_hotspot_y
; P/M definitions. The first value can be changed to adjust the number ; P/M definitions. The first value can be changed to adjust the number
; of the P/M used for the mouse. All others depend on this value. ; of the P/M used for the mouse. All others depend on this value.
; Valid P/M numbers are 0 to 4. When 4 is used, the missiles are used ; Valid P/M numbers are 0 to 4. When 4 is used, the missiles are used
; as a player. ; as a player.
MOUSE_PM_NUM = 4 ; P/M used for the mouse MOUSE_PM_NUM = 2 ; P/M used for the mouse
MOUSE_PM_BASE = pm_base MOUSE_PM_BASE = pm_base ; ZP location pointing to the hw area used by the selected P/M
.if MOUSE_PM_NUM = 4 .if MOUSE_PM_NUM = 4
MOUSE_PM_RAW = 0 MOUSE_PM_RAW = 0 ; MOUSE_PM_RAW is the hardware P/M number for MOUSE_PM_NUM
.macro set_mouse_x .macro set_mouse_x
; assume CF = 0 ; assume CF = 0
sta HPOSM3 sta HPOSM3
adc #2 adc #2
sta HPOSM2 sta HPOSM2
adc #2 adc #2
sta HPOSM1 sta HPOSM1
adc #2 adc #2
sta HPOSM0 sta HPOSM0
.endmacro .endmacro
.else .else
MOUSE_PM_RAW = MOUSE_PM_NUM + 1 MOUSE_PM_RAW = MOUSE_PM_NUM + 1
.macro set_mouse_x .macro set_mouse_x
sta HPOSP0 + MOUSE_PM_NUM sta HPOSP0 + MOUSE_PM_NUM
.endmacro .endmacro
.endif .endif
@ -57,7 +63,8 @@ _mouse_pm_callbacks:
.bss .bss
omy: .res 1 ; Old Mouse Y position omy: .res 1 ; old Mouse Y position
colhlp: .res 1 ; helper variable to set P/M color
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@ -72,7 +79,7 @@ pm_base:.res 2
; Hide the mouse cursor. ; Hide the mouse cursor.
hide: lda #0 hide: lda #0
sta GRACTL sta GRACTL
rts rts
; Show the mouse cursor. ; Show the mouse cursor.
show: show:
@ -82,88 +89,100 @@ show:
lda #1 lda #1
.endif .endif
sta GRACTL sta GRACTL
;rts ;rts ; optimized out
prep: prep:
draw: draw:
rts rts
; Move the mouse cursor x position to the value in A/X. ; Move the mouse cursor x position to the value in A/X.
movex: cpx #1 movex: cpx #1
ror a ror a
clc clc
adc #48 adc #48
set_mouse_x sbc #<(mouse_pm_hotspot_x - 1)
rts set_mouse_x
jmp update_colors
; Move the mouse cursor y position to the value in A/X. ; Move the mouse cursor y position to the value in A/X.
movey: clc movey: clc
adc #32 adc #32
pha sbc #<(mouse_pm_hotspot_y - 1)
pha
lda omy lda omy
jsr clr_pm ; remove player at old position jsr clr_pm ; remove player at old position
jsr update_colors
pla pla
sta omy sta omy
;jmp set_pm ; put player to new position ;jmp set_pm ; put player to new position
; fall thru
; Set P/M data from 'mouse_bits' ; Set P/M data from 'mouse_pm_bits'
set_pm: tay set_pm: tay
ldx #0 ldx #0
set_l: lda mouse_bits,x set_l: lda mouse_pm_bits,x
sta (MOUSE_PM_BASE),y sta (MOUSE_PM_BASE),y
inx inx
iny iny
cpx #mouse_height beq set_end
cpx #<mouse_pm_height
bcc set_l bcc set_l
rts set_end:rts
; Clear (zero) P/M data ; Clear (zero) P/M data
clr_pm: ldx #mouse_height clr_pm: ldx #<mouse_pm_height
tay tay
lda #0 lda #0
clr_l: sta (MOUSE_PM_BASE),y clr_l: sta (MOUSE_PM_BASE),y
iny iny
beq clr_end
dex dex
bne clr_l bne clr_l
clr_end:rts
pm_down = hide
; this assumes a GRAPHICS 0 screen
update_colors:
lda COLOR2 ; get background color
and #$F0
sta colhlp
lda COLOR1
and #$0F
ora colhlp
.if MOUSE_PM_NUM = 4
sta PCOLR0
sta PCOLR1
sta PCOLR2
sta PCOLR3
sta SIZEM
.else
sta PCOLR0 + MOUSE_PM_NUM
sta SIZEP0 + MOUSE_PM_NUM
.endif
rts rts
pm_down = hide
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
.segment "INIT" .segment "INIT"
pm_init:lda #0 pm_init:lda #0
sta sp sta MOUSE_PM_BASE
sta MOUSE_PM_BASE ldx #6 ; page 6
lda sp+1 stx MOUSE_PM_BASE+1
and #7 ; offset within 2K tay
cmp #3 + MOUSE_PM_RAW + 1 ; can we use it? @iniloo:sta (MOUSE_PM_BASE),y
bcc @decr ; no iny
bne @iniloo
lda sp+1 .if 0 ; enable if not using page 6 for P/M data
and #$F8 lda MOUSE_PM_BASE+1
@set: adc #3 + MOUSE_PM_RAW - 1 ; CF is set, so adding MOUSE_PM_RAW + 3 and #$F8
sta MOUSE_PM_BASE+1 .endif
sta sp+1 sta PMBASE
bne @cont
@decr: lda sp+1
and #$F8
sbc #8 - 1 ; CF is clear, subtracts 8
bcs @set ; jump always
@cont: lda #0
tay
@iniloo:sta (MOUSE_PM_BASE),y
iny
bne @iniloo
lda MOUSE_PM_BASE+1
and #$F8
sta PMBASE
lda #62 lda #62
sta SDMCTL sta SDMCTL
@ -171,34 +190,4 @@ pm_init:lda #0
lda #1 + 16 lda #1 + 16
sta GPRIOR sta GPRIOR
lda #0 jmp update_colors
.if MOUSE_PM_NUM = 4
sta PCOLR0
sta PCOLR1
sta PCOLR2
sta PCOLR3
sta SIZEM
.else
sta PCOLR0 + MOUSE_PM_NUM
sta SIZEP0 + MOUSE_PM_NUM
.endif
rts
; ------------------------------------------------------------------------
.data
mouse_bits:
.byte %11110000
.byte %11000000
.byte %10100000
.byte %10010000
.byte %10001000
.byte %00000100
.byte %00000010
; .byte %00000000
mouse_height = * - mouse_bits

View file

@ -0,0 +1,9 @@
;
; Default text mode mouse cursor character
;
; Christian Groessler, 11.04.2014
;
.export mouse_txt_char : absolute
mouse_txt_char = 96 ; 'diamond' screen code

125
libsrc/atari/mcbtxtchar.s Normal file
View file

@ -0,0 +1,125 @@
;
; Text mode character 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_txt_callbacks
.importzp tmp4
.import mul40,loc_tmp
.import mouse_txt_char ; screen code of mouse cursor
.include "atari.inc"
; ------------------------------------------------------------------------
.bss
backup: .res 1
visible:.res 1
; ------------------------------------------------------------------------
.segment "EXTZP" : zeropage
scrptr: .res 2
; ------------------------------------------------------------------------
.rodata
; Callback structure
_mouse_txt_callbacks:
.addr hide
.addr show
.addr prep
.addr draw
.addr movex
.addr movey
; ------------------------------------------------------------------------
.data
; setcursor
getcursor:
column: ldy #$00 ; Patched at runtime
lda (scrptr),y
rts
setcursor:
column2:ldy #$00 ; Patched at runtime
sta (scrptr),y
rts
; ------------------------------------------------------------------------
.code
done:
rts
; Hide the mouse cursor.
hide:
dec visible
prep:
jsr getcursor ; Get character at cursor position
cmp #<mouse_txt_char; "mouse" character
bne overwr ; no, probably program has overwritten it
lda backup ;
jmp setcursor ; Draw character
overwr: sta backup
rts
; Show the mouse cursor.
show:
inc visible
draw:
lda visible
beq done
jsr getcursor ; Cursor visible at current position?
sta backup ; Save character at cursor position
lda #<mouse_txt_char
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
sta column2+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