mirror of
https://github.com/cc65/cc65.git
synced 2025-08-16 12:27:49 +00:00
Atari, Atari5200: disable "attract mode" on mouse or joystick input
Fixes #736.
This commit is contained in:
committed by
Oliver Schmidt
parent
70a131e09a
commit
d199ca1460
@@ -95,6 +95,8 @@ COUNT:
|
|||||||
;
|
;
|
||||||
|
|
||||||
READJOY:
|
READJOY:
|
||||||
|
and #JOY_COUNT-1 ; fix joystick number
|
||||||
|
tax ; Joystick number into X
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
asl a
|
asl a
|
||||||
@@ -110,5 +112,14 @@ READJOY:
|
|||||||
asl a
|
asl a
|
||||||
ora PORTA ; add position information
|
ora PORTA ; add position information
|
||||||
eor #$1F
|
eor #$1F
|
||||||
ldx #0 ; fix X
|
cmp oldval,x
|
||||||
|
beq :+
|
||||||
|
sta oldval,x
|
||||||
|
ldx #0
|
||||||
|
stx ATRACT ; we have interaction, disable "attract mode"
|
||||||
|
: ldx #0 ; fix X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
oldval: .res JOY_COUNT
|
||||||
|
@@ -93,8 +93,8 @@ _400800:
|
|||||||
;
|
;
|
||||||
|
|
||||||
READJOY:
|
READJOY:
|
||||||
and #3 ; fix joystick number
|
and #JOY_COUNT-1 ; fix joystick number
|
||||||
tax ; Joystick number (0-3) into X
|
tax ; Joystick number into X
|
||||||
|
|
||||||
; Read joystick
|
; Read joystick
|
||||||
|
|
||||||
@@ -105,5 +105,14 @@ READJOY:
|
|||||||
asl a
|
asl a
|
||||||
ora STICK0,x ; add position information
|
ora STICK0,x ; add position information
|
||||||
eor #$1F
|
eor #$1F
|
||||||
ldx #0 ; fix X
|
cmp oldval,x
|
||||||
|
beq :+
|
||||||
|
sta oldval,x
|
||||||
|
ldx #0
|
||||||
|
stx ATRACT ; we have interaction, disable "attract mode"
|
||||||
|
: ldx #0 ; fix X
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
oldval: .res JOY_COUNT
|
||||||
|
@@ -89,6 +89,8 @@ YMin: .res 2 ; Y1 value of bounding box
|
|||||||
XMax: .res 2 ; X2 value of bounding box
|
XMax: .res 2 ; X2 value of bounding box
|
||||||
YMax: .res 2 ; Y2 value of bounding box
|
YMax: .res 2 ; Y2 value of bounding box
|
||||||
Buttons: .res 1 ; Button mask
|
Buttons: .res 1 ; Button mask
|
||||||
|
OldDir: .res 1 ; previous direction bits
|
||||||
|
OldButton: .res 1 ; previous buttons
|
||||||
|
|
||||||
|
|
||||||
Temp: .res 1 ; Temporary value used in the int handler
|
Temp: .res 1 ; Temporary value used in the int handler
|
||||||
@@ -336,9 +338,24 @@ IRQ:
|
|||||||
|
|
||||||
jsr CPREP
|
jsr CPREP
|
||||||
|
|
||||||
|
; Check if user activity occurred, and if yes, disable "attract mode"
|
||||||
|
|
||||||
|
lda Buttons
|
||||||
|
cmp OldButton
|
||||||
|
beq @ChkDir
|
||||||
|
sta OldButton
|
||||||
|
lda #0
|
||||||
|
sta ATRACT ; disable "attract mode"
|
||||||
|
@ChkDir:lda Temp
|
||||||
|
cmp OldDir
|
||||||
|
beq @ChkCnt
|
||||||
|
sta OldDir
|
||||||
|
lda #0
|
||||||
|
sta ATRACT
|
||||||
|
|
||||||
; Check left/right
|
; Check left/right
|
||||||
|
|
||||||
lda Temp ; Read joystick #0
|
@ChkCnt:lda Temp ; Read joystick #0
|
||||||
and #(JOY::LEFT | JOY::RIGHT)
|
and #(JOY::LEFT | JOY::RIGHT)
|
||||||
beq @SkipX ;
|
beq @SkipX ;
|
||||||
|
|
||||||
@@ -437,4 +454,3 @@ IRQ:
|
|||||||
@SkipY: jsr CDRAW
|
@SkipY: jsr CDRAW
|
||||||
clc ; Interrupt not "handled"
|
clc ; Interrupt not "handled"
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
@@ -126,6 +126,7 @@ YMin: .res 2 ; Y1 value of bounding box
|
|||||||
XMax: .res 2 ; X2 value of bounding box
|
XMax: .res 2 ; X2 value of bounding box
|
||||||
YMax: .res 2 ; Y2 value of bounding box
|
YMax: .res 2 ; Y2 value of bounding box
|
||||||
Buttons: .res 1 ; Button mask
|
Buttons: .res 1 ; Button mask
|
||||||
|
OldButton: .res 1 ; previous buttons
|
||||||
|
|
||||||
XPosWrk: .res 2
|
XPosWrk: .res 2
|
||||||
YPosWrk: .res 2
|
YPosWrk: .res 2
|
||||||
@@ -496,6 +497,8 @@ IRQ: lda PORTA ; mouse port contents
|
|||||||
|
|
||||||
cmp old_porta_vbi
|
cmp old_porta_vbi
|
||||||
beq @L3 ; no motion
|
beq @L3 ; no motion
|
||||||
|
lda #0
|
||||||
|
sta ATRACT ; disable "attract mode"
|
||||||
|
|
||||||
; Turn mouse polling IRQ back on
|
; Turn mouse polling IRQ back on
|
||||||
|
|
||||||
@@ -544,25 +547,34 @@ IRQ: lda PORTA ; mouse port contents
|
|||||||
|
|
||||||
jsr CPREP
|
jsr CPREP
|
||||||
|
|
||||||
|
; Disable "attract mode" if button status has changed
|
||||||
|
|
||||||
|
lda Buttons
|
||||||
|
cmp OldButton
|
||||||
|
beq @L5
|
||||||
|
sta OldButton
|
||||||
|
lda #0
|
||||||
|
sta ATRACT
|
||||||
|
|
||||||
; Limit the X coordinate to the bounding box
|
; Limit the X coordinate to the bounding box
|
||||||
|
|
||||||
lda XPosWrk+1
|
@L5: lda XPosWrk+1
|
||||||
ldy XPosWrk
|
ldy XPosWrk
|
||||||
tax
|
tax
|
||||||
cpy XMin
|
cpy XMin
|
||||||
sbc XMin+1
|
sbc XMin+1
|
||||||
bpl @L5
|
bpl @L6
|
||||||
ldy XMin
|
ldy XMin
|
||||||
ldx XMin+1
|
ldx XMin+1
|
||||||
jmp @L6
|
jmp @L7
|
||||||
|
|
||||||
@L5: txa
|
@L6: txa
|
||||||
cpy XMax
|
cpy XMax
|
||||||
sbc XMax+1
|
sbc XMax+1
|
||||||
bmi @L6
|
bmi @L7
|
||||||
ldy XMax
|
ldy XMax
|
||||||
ldx XMax+1
|
ldx XMax+1
|
||||||
@L6: sty XPos
|
@L7: sty XPos
|
||||||
stx XPos+1
|
stx XPos+1
|
||||||
tya
|
tya
|
||||||
jsr CMOVEX
|
jsr CMOVEX
|
||||||
@@ -574,18 +586,18 @@ IRQ: lda PORTA ; mouse port contents
|
|||||||
tax
|
tax
|
||||||
cpy YMin
|
cpy YMin
|
||||||
sbc YMin+1
|
sbc YMin+1
|
||||||
bpl @L7
|
bpl @L8
|
||||||
ldy YMin
|
ldy YMin
|
||||||
ldx YMin+1
|
ldx YMin+1
|
||||||
jmp @L8
|
jmp @L9
|
||||||
|
|
||||||
@L7: txa
|
@L8: txa
|
||||||
cpy YMax
|
cpy YMax
|
||||||
sbc YMax+1
|
sbc YMax+1
|
||||||
bmi @L8
|
bmi @L9
|
||||||
ldy YMax
|
ldy YMax
|
||||||
ldx YMax+1
|
ldx YMax+1
|
||||||
@L8: sty YPos
|
@L9: sty YPos
|
||||||
stx YPos+1
|
stx YPos+1
|
||||||
tya
|
tya
|
||||||
jsr CMOVEY
|
jsr CMOVEY
|
||||||
@@ -595,10 +607,10 @@ IRQ: lda PORTA ; mouse port contents
|
|||||||
.ifdef DEBUG
|
.ifdef DEBUG
|
||||||
; print on upper right corner 'E' or 'D', indicating the IRQ is enabled or disabled
|
; print on upper right corner 'E' or 'D', indicating the IRQ is enabled or disabled
|
||||||
ldy irq_enabled
|
ldy irq_enabled
|
||||||
beq @L9
|
beq @L10
|
||||||
lda #37 ; screen code for 'E'
|
lda #37 ; screen code for 'E'
|
||||||
.byte $2c ; bit opcode, eats next 2 bytes
|
.byte $2c ; bit opcode, eats next 2 bytes
|
||||||
@L9: lda #36 ; screen code for 'D'
|
@L10: lda #36 ; screen code for 'D'
|
||||||
ldy #39
|
ldy #39
|
||||||
sta (SAVMSC),y
|
sta (SAVMSC),y
|
||||||
.endif
|
.endif
|
||||||
|
@@ -88,6 +88,7 @@ YMin: .res 2 ; Y1 value of bounding box
|
|||||||
XMax: .res 2 ; X2 value of bounding box
|
XMax: .res 2 ; X2 value of bounding box
|
||||||
YMax: .res 2 ; Y2 value of bounding box
|
YMax: .res 2 ; Y2 value of bounding box
|
||||||
Buttons: .res 1 ; Button mask
|
Buttons: .res 1 ; Button mask
|
||||||
|
OldButton: .res 1 ; previous buttons
|
||||||
|
|
||||||
; Default values for above variables
|
; Default values for above variables
|
||||||
|
|
||||||
@@ -337,10 +338,19 @@ IRQ:
|
|||||||
ora Buttons
|
ora Buttons
|
||||||
sta Buttons
|
sta Buttons
|
||||||
|
|
||||||
|
; Check if button status changed, and disable "attract mode" if yes
|
||||||
|
|
||||||
|
@L02: lda Buttons
|
||||||
|
cmp OldButton
|
||||||
|
beq @L03
|
||||||
|
sta OldButton
|
||||||
|
lda #0
|
||||||
|
sta ATRACT
|
||||||
|
|
||||||
; If we read 228 for X or Y positions, we assume the user has lifted the pen
|
; If we read 228 for X or Y positions, we assume the user has lifted the pen
|
||||||
; and don't change the cursor position.
|
; and don't change the cursor position.
|
||||||
|
|
||||||
@L02: lda PADDL0
|
@L03: lda PADDL0
|
||||||
cmp #228
|
cmp #228
|
||||||
beq @Cont ; CF set if equal
|
beq @Cont ; CF set if equal
|
||||||
lda PADDL1
|
lda PADDL1
|
||||||
@@ -350,12 +360,13 @@ IRQ:
|
|||||||
jsr CPREP
|
jsr CPREP
|
||||||
plp ; restore CF
|
plp ; restore CF
|
||||||
|
|
||||||
bcc @L03
|
bcc @L04
|
||||||
jmp @Show
|
jmp @Show
|
||||||
|
|
||||||
@L03: ldx #0
|
@L04: ldx #0
|
||||||
stx XPos+1
|
stx XPos+1
|
||||||
stx YPos+1
|
stx YPos+1
|
||||||
|
stx ATRACT ; disable "attract mode"
|
||||||
|
|
||||||
; Get cursor position
|
; Get cursor position
|
||||||
; -------------------
|
; -------------------
|
||||||
@@ -382,9 +393,9 @@ IRQ:
|
|||||||
clc
|
clc
|
||||||
adc XPos
|
adc XPos
|
||||||
sta XPos
|
sta XPos
|
||||||
bcc @L04
|
bcc @L05
|
||||||
inc XPos+1
|
inc XPos+1
|
||||||
@L04: txa
|
@L05: txa
|
||||||
lsr a ; port value / 4
|
lsr a ; port value / 4
|
||||||
lsr a ; port value / 8
|
lsr a ; port value / 8
|
||||||
tax
|
tax
|
||||||
@@ -393,18 +404,18 @@ IRQ:
|
|||||||
stx XPos
|
stx XPos
|
||||||
sbc XPos
|
sbc XPos
|
||||||
sta XPos
|
sta XPos
|
||||||
bcs @L05
|
bcs @L06
|
||||||
dec XPos+1
|
dec XPos+1
|
||||||
@L05: txa
|
@L06: txa
|
||||||
lsr a ; port value / 16
|
lsr a ; port value / 16
|
||||||
lsr a ; port value / 32
|
lsr a ; port value / 32
|
||||||
clc
|
clc
|
||||||
adc XPos
|
adc XPos
|
||||||
sta XPos
|
sta XPos
|
||||||
bcc @L06
|
bcc @L07
|
||||||
inc XPos+1
|
inc XPos+1
|
||||||
|
|
||||||
@L06: tay
|
@L07: tay
|
||||||
lda XPos+1
|
lda XPos+1
|
||||||
tax
|
tax
|
||||||
|
|
||||||
@@ -412,18 +423,18 @@ IRQ:
|
|||||||
|
|
||||||
cpy XMin
|
cpy XMin
|
||||||
sbc XMin+1
|
sbc XMin+1
|
||||||
bpl @L07
|
bpl @L08
|
||||||
ldy XMin
|
ldy XMin
|
||||||
ldx XMin+1
|
ldx XMin+1
|
||||||
jmp @L08
|
jmp @L09
|
||||||
@L07: txa
|
@L08: txa
|
||||||
|
|
||||||
cpy XMax
|
cpy XMax
|
||||||
sbc XMax+1
|
sbc XMax+1
|
||||||
bmi @L08
|
bmi @L09
|
||||||
ldy XMax
|
ldy XMax
|
||||||
ldx XMax+1
|
ldx XMax+1
|
||||||
@L08: sty XPos
|
@L09: sty XPos
|
||||||
stx XPos+1
|
stx XPos+1
|
||||||
|
|
||||||
; Move the mouse pointer to the new X pos
|
; Move the mouse pointer to the new X pos
|
||||||
@@ -456,18 +467,18 @@ IRQ:
|
|||||||
|
|
||||||
cpy YMin
|
cpy YMin
|
||||||
sbc YMin+1
|
sbc YMin+1
|
||||||
bpl @L09
|
bpl @L10
|
||||||
ldy YMin
|
ldy YMin
|
||||||
ldx YMin+1
|
ldx YMin+1
|
||||||
jmp @L10
|
jmp @L11
|
||||||
@L09: txa
|
@L10: txa
|
||||||
|
|
||||||
cpy YMax
|
cpy YMax
|
||||||
sbc YMax+1
|
sbc YMax+1
|
||||||
bmi @L10
|
bmi @L11
|
||||||
ldy YMax
|
ldy YMax
|
||||||
ldx YMax+1
|
ldx YMax+1
|
||||||
@L10: sty YPos
|
@L11: sty YPos
|
||||||
stx YPos+1
|
stx YPos+1
|
||||||
|
|
||||||
; Move the mouse pointer to the new X pos
|
; Move the mouse pointer to the new X pos
|
||||||
@@ -479,4 +490,3 @@ IRQ:
|
|||||||
|
|
||||||
clc ; Interrupt not "handled"
|
clc ; Interrupt not "handled"
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
@@ -82,6 +82,7 @@ SENSIVITY = 16
|
|||||||
|
|
||||||
READJOY:
|
READJOY:
|
||||||
and #3 ; put joystick number in range, just in case
|
and #3 ; put joystick number in range, just in case
|
||||||
|
sta jsnum ; remember joystick number
|
||||||
tay
|
tay
|
||||||
asl a
|
asl a
|
||||||
tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
|
tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
|
||||||
@@ -89,7 +90,7 @@ READJOY:
|
|||||||
lda #0 ; Initialize return value
|
lda #0 ; Initialize return value
|
||||||
cmp TRIG0,y
|
cmp TRIG0,y
|
||||||
bne @notrg
|
bne @notrg
|
||||||
lda #$10 ; JOY_BTN
|
ora #$10 ; JOY_BTN
|
||||||
|
|
||||||
; Read joystick
|
; Read joystick
|
||||||
|
|
||||||
@@ -119,4 +120,15 @@ READJOY:
|
|||||||
|
|
||||||
ora #2 ; JOY_DOWN
|
ora #2 ; JOY_DOWN
|
||||||
|
|
||||||
@done: rts
|
@done: ldx #0
|
||||||
|
ldy jsnum
|
||||||
|
cmp oldval,y
|
||||||
|
beq @ret
|
||||||
|
sta oldval,y
|
||||||
|
stx ATRACT
|
||||||
|
@ret: rts
|
||||||
|
|
||||||
|
.bss
|
||||||
|
|
||||||
|
oldval:.res 4
|
||||||
|
jsnum: .res 1
|
||||||
|
Reference in New Issue
Block a user