Multiple joysticks support added. #142

And small barrel rotate bug fixed.
This commit is contained in:
Pecusx
2022-11-18 23:55:14 +01:00
parent dedfd7a248
commit 2fb40c444f
4 changed files with 27 additions and 17 deletions
+24 -14
View File
@@ -354,8 +354,9 @@ MainGameLoop
jsr SortSequence jsr SortSequence
; Hide all (easier than hide last ;) ) tanks ; Hide all (easier than hide last ;) ) tanks
jsr cleartanks jsr cleartanks ; A=0
sta COLBAKS ; set background color to black sta COLBAKS ; set background color to black
sta JoystickNumber ; set joystick port for player
; here gains and losses should be displayed (dollars) ; here gains and losses should be displayed (dollars)
; finally we have changed our minds and money of players ; finally we have changed our minds and money of players
@@ -1352,27 +1353,28 @@ nextlinedisplay
; bne EndOfCreditsVBI ; bne EndOfCreditsVBI
mwa #Credits DLCreditsAddr mwa #Credits DLCreditsAddr
EndOfCreditsVBI EndOfCreditsVBI
; support for joysticks :)
ldx JoystickNumber
lda STICK0,x
sta STICK0
lda STRIG0,x
sta STRIG0
.IF TARGET = 5200 .IF TARGET = 5200
lda SkStatSimulator lda SkStatSimulator
bmi @+ bmi @+
inc SkStatSimulator inc SkStatSimulator
@ @
lda JoystickNumber ; select port
ora #%00000100 ; Speaker off, Pots enabled
sta CONSOL5200
center = 114 ;Read analog stick and make it look like a digital stick center = 114 ;Read analog stick and make it look like a digital stick
threshold = 60 threshold = 60
lda paddl0 ;Read POT0 value (horizontal position) lda JoystickNumber
asl
tax
lda paddl0,x ;Read POT0 value (horizontal position)
cmp #center+threshold ;Compare with right threshold cmp #center+threshold ;Compare with right threshold
rol stick0 ;Feed carry into digital stick value rol stick0 ;Feed carry into digital stick value
cmp #center-threshold ;Compare with left threshold cmp #center-threshold ;Compare with left threshold
rol stick0 ;Feed carry into digital stick value rol stick0 ;Feed carry into digital stick value
lda paddl1 ;Read POT1 value (vertical position) lda paddl1,x ;Read POT1 value (vertical position)
cmp #center+threshold ;Compare with down threshold cmp #center+threshold ;Compare with down threshold
rol stick0 ;Feed carry into digital stick value rol stick0 ;Feed carry into digital stick value
cmp #center-threshold ;Compare with down threshold cmp #center-threshold ;Compare with down threshold
@@ -1382,8 +1384,10 @@ EndOfCreditsVBI
eor #2+8 eor #2+8
and #$0f and #$0f
sta stick0 sta stick0
mva trig0 strig0 ;Move hardware to shadow ldx JoystickNumber
lda trig0,x
sta strig0 ;Move hardware to shadow
mva chbas chbase mva chbas chbase
@@ -1399,9 +1403,15 @@ EndOfCreditsVBI
pla pla
tax tax
pla pla
rti rti
.ELSE .ELSE
jmp XITVBV ; support for joysticks :)
ldx JoystickNumber
lda STICK0,x
sta STICK0
lda STRIG0,x
sta STRIG0
jmp XITVBV
.ENDIF .ENDIF
.endp .endp
.IF TARGET = 5200 .IF TARGET = 5200
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+3 -3
View File
@@ -1371,8 +1371,8 @@ pressedLeft
INC AngleTable,x INC AngleTable,x
lda AngleTable,x lda AngleTable,x
cmp #180 cmp #180
jne BeforeFire jcc BeforeFire
lda #1 lda #0
sta AngleTable,x sta AngleTable,x
jmp BeforeFire jmp BeforeFire
@@ -1387,7 +1387,7 @@ CTRLPressedLeft
sta AngleTable,x sta AngleTable,x
cmp #180-4 cmp #180-4
jcc BeforeFire jcc BeforeFire
lda #1 lda #0
sta AngleTable,x sta AngleTable,x
jmp BeforeFire jmp BeforeFire