[stella] Auto detecting paddles in port 1 or port 2
Dennis Debro
dennis at debrofamily.com
Wed Dec 26 06:06:13 CST 2007
Hi there,
I know this is an old thread (almost a year now) but I found this recently
in Astroblast. It's similar to what Thomas used to detect paddles.
I guess I need to brush up on my 2600 games. I didn't know Astroblast
supported both paddles and joysticks.
DetermineControllerType
lda #DUMP_PORTS | DISABLE_TIA
sta VBLANK
ldx #0
.waitForCapacitorCharge
bit INPT0 ; check paddle 0 value
bpl LFB88 ; branch if capacitor not charged
dex
bne .waitForCapacitorCharge
beq .setControllerTypeToPaddles ; unconditional branch
LFB88:
lda #DISABLE_TIA
sta VBLANK ; disable TIA (i.e. D1 = 1)
ldx #32 ; wait ~538 scanlines (i.e. ~2 frames)
.outerLoopWait
ldy #0
.innerLoopWait
iny
bne .innerLoopWait
dex
bne .outerLoopWait
bit INPT0 ; check paddle 0 value
bpl .doneDetermineControllerType ; branch if capacitor not charged
.setControllerTypeToPaddles
lda gameState ; get current game state value
ora #USING_PADDLES
sta gameState ; set game state to USING_PADDLES
.doneDetermineControllerType
rts
Take care,
Dennis
More information about the Stella
mailing list