X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fc64%2Fc64-1351.s;h=e6f57ca0d61ca2f6c3eb0155ab561aa9ac4f942a;hb=c7a33334ba4cec0ccd3ca2bd37168978f0078621;hp=ab4732aaa6a2704c6adc6969caa4ad8f36e5831c;hpb=31595342d64db7c3e9732f9155aeac66bb905f82;p=cc65 diff --git a/libsrc/c64/c64-1351.s b/libsrc/c64/c64-1351.s index ab4732aaa..e6f57ca0d 100644 --- a/libsrc/c64/c64-1351.s +++ b/libsrc/c64/c64-1351.s @@ -2,7 +2,7 @@ ; Driver for the 1351 proportional mouse. Parts of the code are from ; the Commodore 1351 mouse users guide. ; -; Ullrich von Bassewitz, 2003-12-29 +; Ullrich von Bassewitz, 2003-12-29, 2009-09-26 ; .include "zeropage.inc" @@ -29,7 +29,8 @@ HEADER: .addr UNINSTALL .addr HIDE .addr SHOW - .addr BOX + .addr SETBOX + .addr GETBOX .addr MOVE .addr BUTTONS .addr POS @@ -37,6 +38,10 @@ HEADER: .addr IOCTL .addr IRQ +; Mouse driver flags + + .byte MOUSE_FLAG_LATE_IRQ + ; Callback table, set by the kernel before INSTALL is called CHIDE: jmp $0000 ; Hide the cursor @@ -53,7 +58,8 @@ SCREEN_WIDTH = 320 ;---------------------------------------------------------------------------- ; Global variables. The bounding box values are sorted so that they can be -; written with the least effort in the BOX routine, so don't reorder them. +; written with the least effort in the SETBOX and GETBOX routines, so don't +; reorder them. .bss @@ -63,10 +69,10 @@ OldPotY: .res 1 YPos: .res 2 ; Current mouse position, Y XPos: .res 2 ; Current mouse position, X -YMax: .res 2 ; Y2 value of bounding box -XMax: .res 2 ; X2 value of bounding box -YMin: .res 2 ; Y1 value of bounding box XMin: .res 2 ; X1 value of bounding box +YMin: .res 2 ; Y1 value of bounding box +XMax: .res 2 ; X2 value of bounding box +YMax: .res 2 ; Y2 value of bounding box OldValue: .res 1 ; Temp for MoveCheck routine NewValue: .res 1 ; Temp for MoveCheck routine @@ -79,10 +85,10 @@ NewValue: .res 1 ; Temp for MoveCheck routine .byte 0, 0 ; OldPotX/OldPotY .word SCREEN_HEIGHT/2 ; YPos .word SCREEN_WIDTH/2 ; XPos - .word SCREEN_HEIGHT ; YMax - .word SCREEN_WIDTH ; XMax - .word 0 ; YMin .word 0 ; XMin + .word 0 ; YMin + .word SCREEN_WIDTH ; XMax + .word SCREEN_HEIGHT ; YMax .endproc .code @@ -153,21 +159,20 @@ SHOW: sei rts ;---------------------------------------------------------------------------- -; BOX: Set the mouse bounding box. The parameters are passed as they come from -; the C program, that is, maxy in a/x and the other parameters on the stack. -; The C wrapper will remove the parameters from the stack when the driver -; routine returns. +; SETBOX: Set the mouse bounding box. The parameters are passed as they come +; from the C program, that is, a pointer to a mouse_box struct in a/x. ; No checks are done if the mouse is currently inside the box, this is the job ; of the caller. It is not necessary to validate the parameters, trust the ; caller and save some code here. No return code required. -BOX: ldy #5 +SETBOX: sta ptr1 + stx ptr1+1 ; Save data pointer + + ldy #.sizeof (MOUSE_BOX)-1 sei - sta YMax - stx YMax+1 -@L1: lda (sp),y - sta XMax,y +@L1: lda (ptr1),y + sta XMin,y dey bpl @L1 @@ -175,7 +180,27 @@ BOX: ldy #5 rts ;---------------------------------------------------------------------------- -; MOVE: Move the mouse to a new position which is passed in X=ptr1, Y=a/x. +; GETBOX: Return the mouse bounding box. The parameters are passed as they +; come from the C program, that is, a pointer to a mouse_box struct in a/x. + +GETBOX: sta ptr1 + stx ptr1+1 ; Save data pointer + + ldy #.sizeof (MOUSE_BOX)-1 + sei + +@L1: lda XMin,y + sta (ptr1),y + dey + bpl @L1 + + cli + rts + +;---------------------------------------------------------------------------- +; MOVE: Move the mouse to a new position. The position is passed as it comes +; from the C program, that is: X on the stack and Y in a/x. The C wrapper will +; remove the parameter from the stack on return. ; No checks are done if the new position is valid (within the bounding box or ; the screen). No return code required. ; @@ -186,10 +211,13 @@ MOVE: sei ; No interrupts stx YPos+1 ; New Y position jsr CMOVEY ; Set it - lda ptr1 - ldx ptr1+1 - sta XPos - stx XPos+1 ; New X position + ldy #$01 + lda (sp),y + sta XPos+1 + tax + dey + lda (sp),y + sta XPos ; New X position jsr CMOVEX ; Move the cursor @@ -264,7 +292,9 @@ IOCTL: lda #