1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-06 01:29:31 +00:00

Atari, Atari5200: disable "attract mode" on mouse or joystick input

Fixes #736.
This commit is contained in:
Christian Groessler 2018-09-04 23:08:38 +02:00 committed by Oliver Schmidt
parent 70a131e09a
commit d199ca1460
6 changed files with 111 additions and 41 deletions

View File

@ -95,6 +95,8 @@ COUNT:
;
READJOY:
and #JOY_COUNT-1 ; fix joystick number
tax ; Joystick number into X
asl a
asl a
asl a
@ -110,5 +112,14 @@ READJOY:
asl a
ora PORTA ; add position information
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
.bss
oldval: .res JOY_COUNT

View File

@ -93,8 +93,8 @@ _400800:
;
READJOY:
and #3 ; fix joystick number
tax ; Joystick number (0-3) into X
and #JOY_COUNT-1 ; fix joystick number
tax ; Joystick number into X
; Read joystick
@ -105,5 +105,14 @@ READJOY:
asl a
ora STICK0,x ; add position information
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
.bss
oldval: .res JOY_COUNT

View File

@ -89,6 +89,8 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
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
@ -336,9 +338,24 @@ IRQ:
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
lda Temp ; Read joystick #0
@ChkCnt:lda Temp ; Read joystick #0
and #(JOY::LEFT | JOY::RIGHT)
beq @SkipX ;
@ -437,4 +454,3 @@ IRQ:
@SkipY: jsr CDRAW
clc ; Interrupt not "handled"
rts

View File

@ -126,6 +126,7 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
Buttons: .res 1 ; Button mask
OldButton: .res 1 ; previous buttons
XPosWrk: .res 2
YPosWrk: .res 2
@ -496,6 +497,8 @@ IRQ: lda PORTA ; mouse port contents
cmp old_porta_vbi
beq @L3 ; no motion
lda #0
sta ATRACT ; disable "attract mode"
; Turn mouse polling IRQ back on
@ -544,25 +547,34 @@ IRQ: lda PORTA ; mouse port contents
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
lda XPosWrk+1
@L5: lda XPosWrk+1
ldy XPosWrk
tax
cpy XMin
sbc XMin+1
bpl @L5
bpl @L6
ldy XMin
ldx XMin+1
jmp @L6
jmp @L7
@L5: txa
@L6: txa
cpy XMax
sbc XMax+1
bmi @L6
bmi @L7
ldy XMax
ldx XMax+1
@L6: sty XPos
@L7: sty XPos
stx XPos+1
tya
jsr CMOVEX
@ -574,18 +586,18 @@ IRQ: lda PORTA ; mouse port contents
tax
cpy YMin
sbc YMin+1
bpl @L7
bpl @L8
ldy YMin
ldx YMin+1
jmp @L8
jmp @L9
@L7: txa
@L8: txa
cpy YMax
sbc YMax+1
bmi @L8
bmi @L9
ldy YMax
ldx YMax+1
@L8: sty YPos
@L9: sty YPos
stx YPos+1
tya
jsr CMOVEY
@ -595,10 +607,10 @@ IRQ: lda PORTA ; mouse port contents
.ifdef DEBUG
; print on upper right corner 'E' or 'D', indicating the IRQ is enabled or disabled
ldy irq_enabled
beq @L9
beq @L10
lda #37 ; screen code for 'E'
.byte $2c ; bit opcode, eats next 2 bytes
@L9: lda #36 ; screen code for 'D'
@L10: lda #36 ; screen code for 'D'
ldy #39
sta (SAVMSC),y
.endif

View File

@ -88,6 +88,7 @@ YMin: .res 2 ; Y1 value of bounding box
XMax: .res 2 ; X2 value of bounding box
YMax: .res 2 ; Y2 value of bounding box
Buttons: .res 1 ; Button mask
OldButton: .res 1 ; previous buttons
; Default values for above variables
@ -337,10 +338,19 @@ IRQ:
ora 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
; and don't change the cursor position.
@L02: lda PADDL0
@L03: lda PADDL0
cmp #228
beq @Cont ; CF set if equal
lda PADDL1
@ -350,12 +360,13 @@ IRQ:
jsr CPREP
plp ; restore CF
bcc @L03
bcc @L04
jmp @Show
@L03: ldx #0
@L04: ldx #0
stx XPos+1
stx YPos+1
stx ATRACT ; disable "attract mode"
; Get cursor position
; -------------------
@ -382,9 +393,9 @@ IRQ:
clc
adc XPos
sta XPos
bcc @L04
bcc @L05
inc XPos+1
@L04: txa
@L05: txa
lsr a ; port value / 4
lsr a ; port value / 8
tax
@ -393,18 +404,18 @@ IRQ:
stx XPos
sbc XPos
sta XPos
bcs @L05
bcs @L06
dec XPos+1
@L05: txa
@L06: txa
lsr a ; port value / 16
lsr a ; port value / 32
clc
adc XPos
sta XPos
bcc @L06
bcc @L07
inc XPos+1
@L06: tay
@L07: tay
lda XPos+1
tax
@ -412,18 +423,18 @@ IRQ:
cpy XMin
sbc XMin+1
bpl @L07
bpl @L08
ldy XMin
ldx XMin+1
jmp @L08
@L07: txa
jmp @L09
@L08: txa
cpy XMax
sbc XMax+1
bmi @L08
bmi @L09
ldy XMax
ldx XMax+1
@L08: sty XPos
@L09: sty XPos
stx XPos+1
; Move the mouse pointer to the new X pos
@ -456,18 +467,18 @@ IRQ:
cpy YMin
sbc YMin+1
bpl @L09
bpl @L10
ldy YMin
ldx YMin+1
jmp @L10
@L09: txa
jmp @L11
@L10: txa
cpy YMax
sbc YMax+1
bmi @L10
bmi @L11
ldy YMax
ldx YMax+1
@L10: sty YPos
@L11: sty YPos
stx YPos+1
; Move the mouse pointer to the new X pos
@ -479,4 +490,3 @@ IRQ:
clc ; Interrupt not "handled"
rts

View File

@ -82,6 +82,7 @@ SENSIVITY = 16
READJOY:
and #3 ; put joystick number in range, just in case
sta jsnum ; remember joystick number
tay
asl a
tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
@ -89,7 +90,7 @@ READJOY:
lda #0 ; Initialize return value
cmp TRIG0,y
bne @notrg
lda #$10 ; JOY_BTN
ora #$10 ; JOY_BTN
; Read joystick
@ -119,4 +120,15 @@ READJOY:
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