X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fatari%2Fmou%2Fatrtt.s;h=f1f2cde63872bb82d4b1f72719fcbaab8cbfa560;hb=91b9451c60682c0fda984750406d58b1b019f87e;hp=16ed32602872ef219a69db64120e0682b42c3e89;hpb=f1646a369537d11cc8ac75300fb3365f9eac8027;p=cc65 diff --git a/libsrc/atari/mou/atrtt.s b/libsrc/atari/mou/atrtt.s index 16ed32602..f1f2cde63 100644 --- a/libsrc/atari/mou/atrtt.s +++ b/libsrc/atari/mou/atrtt.s @@ -1,5 +1,5 @@ ; -; Mouse driver for Atari Trakball +; Mouse driver for Atari Touch Tablet ; ; Christian Groessler, 2014-01-05 ; @@ -9,11 +9,16 @@ .include "atari.inc" .macpack generic + .macpack module ; ------------------------------------------------------------------------ ; Header. Includes jump table -.segment "JUMPTABLE" +.ifdef __ATARIXL__ + module_header _atrxtt_mou +.else + module_header _atrtt_mou +.endif HEADER: @@ -49,6 +54,8 @@ HEADER: CHIDE: jmp $0000 ; Hide the cursor CSHOW: jmp $0000 ; Show the cursor +CPREP: jmp $0000 ; Prepare to move the cursor +CDRAW: jmp $0000 ; Draw the cursor CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEY: jmp $0000 ; Move the cursor to Y coord @@ -82,13 +89,12 @@ XMax: .res 2 ; X2 value of bounding box YMax: .res 2 ; Y2 value of bounding box Buttons: .res 1 ; Button mask - -visible: .res 1 - ; Default values for above variables .rodata +; (We use ".proc" because we want to define both a label and a scope.) + .proc DefVars .word SCREEN_HEIGHT/2 ; YPos .word SCREEN_WIDTH/2 ; XPos @@ -116,20 +122,14 @@ INSTALL: dex bpl @L1 -; Be sure the mouse cursor is invisible and at the default location. We -; need to do that here, because our mouse interrupt handler doesn't set the -; mouse position if it hasn't changed. +; Make sure the mouse cursor is at the default location. - php - sei - jsr CHIDE lda XPos ldx XPos+1 jsr CMOVEX lda YPos ldx YPos+1 jsr CMOVEY - plp ; Done, return zero (= MOUSE_ERR_OK) @@ -150,8 +150,7 @@ UNINSTALL = HIDE ; Hide cursor on exit ; no special action is required besides hiding the mouse cursor. ; No return code required. -HIDE: dec visible - php +HIDE: php sei jsr CHIDE plp @@ -164,8 +163,7 @@ HIDE: dec visible ; no special action is required besides enabling the mouse cursor. ; No return code required. -SHOW: inc visible - php +SHOW: php sei jsr CSHOW plp @@ -224,14 +222,12 @@ MOVE: php sei ; No interrupts pha - lda visible - beq @nohide txa pha - jsr CHIDE + jsr CPREP pla tax -@nohide:pla + pla sta YPos stx YPos+1 ; New Y position @@ -244,15 +240,11 @@ MOVE: php dey lda (sp),y sta XPos ; New X position - jsr CMOVEX ; Move the cursor - lda visible - beq @Ret - jsr CSHOW -@Ret: plp ; Restore interrupt flag + plp ; Restore interrupt flag rts ;---------------------------------------------------------------------------- @@ -328,17 +320,12 @@ IRQ: ; Check for a pressed button and place the result into Buttons ldx #0 - stx XPos+1 - stx YPos+1 - lda TRIG0 ; joystick #0 trigger - bne @L00 ; not pressed - ldx #MOUSE_BTN_LEFT -@L00: stx Buttons + stx Buttons lda PORTA ; get other buttons eor #255 tax - and #4 + and #5 ; pen button and left button are mapped to left mouse button beq @L01 lda #MOUSE_BTN_LEFT ora Buttons @@ -350,13 +337,29 @@ IRQ: ora Buttons sta Buttons -@L02: lda visible - beq @L03 - jsr CHIDE +; If we read 228 for X or Y positions, we assume the user has lifted the pen +; and don't change the cursor position. + +@L02: lda PADDL0 + cmp #228 + beq @Cont ; CF set if equal + lda PADDL1 + cmp #228 ; CF set if equal + +@Cont: php ; remember CF + jsr CPREP + plp ; restore CF + + bcc @L03 + jmp @Show + +@L03: ldx #0 + stx XPos+1 + stx YPos+1 ; Get cursor position ; ------------------- -; The touchpad is read thru the paddle potentiometers. The possible +; The touch pad is read thru the paddle potentiometers. The possible ; values are 1..228. Since the maximum value is less than the X ; dimension we have to "stretch" this value. In order to use only ; divisions by powers of two, we use the following appoximation: @@ -370,7 +373,7 @@ IRQ: ; X -@L03: ldx PADDL0 ; get X postion + ldx PADDL0 ; get X postion dex ; decrement, since it's 1-based stx XPos txa @@ -472,10 +475,8 @@ IRQ: tya jsr CMOVEY - lda visible - beq @L11 - jsr CSHOW +@Show: jsr CDRAW -@L11: clc ; Interrupt not "handled" + clc ; Interrupt not "handled" rts