1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-08 15:29:37 +00:00

Merge pull request #628 from ops/VIAFIX_PET

Pet: Add missing VIA register names
This commit is contained in:
Oliver Schmidt 2018-04-23 15:58:13 +02:00 committed by GitHub
commit fe33a39d6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 16 deletions

View File

@ -61,8 +61,22 @@ NMIVec := $0094
; ---------------------------------------------------------------------------
; I/O: 6522 VIA2
VIA := $E840
VIA_PRB := $E840
VIA_PRA := $E841
VIA_DDRB := $E842
VIA_DDRA := $E843
VIA := $E840 ; VIA base address
VIA_PB := VIA+$0 ; Port register B
VIA_PA1 := VIA+$1 ; Port register A
VIA_PRB := VIA+$0 ; *** Deprecated ***
VIA_PRA := VIA+$1 ; *** Deprecated ***
VIA_DDRB := VIA+$2 ; Data direction register B
VIA_DDRA := VIA+$3 ; Data direction register A
VIA_T1CL := VIA+$4 ; Timer 1, low byte
VIA_T1CH := VIA+$5 ; Timer 1, high byte
VIA_T1LL := VIA+$6 ; Timer 1 latch, low byte
VIA_T1LH := VIA+$7 ; Timer 1 latch, high byte
VIA_T2CL := VIA+$8 ; Timer 2, low byte
VIA_T2CH := VIA+$9 ; Timer 2, high byte
VIA_SR := VIA+$A ; Shift register
VIA_CR := VIA+$B ; Auxiliary control register
VIA_PCR := VIA+$C ; Peripheral control register
VIA_IFR := VIA+$D ; Interrupt flag register
VIA_IER := VIA+$E ; Interrupt enable register
VIA_PA2 := VIA+$F ; Port register A w/o handshake

View File

@ -10,6 +10,7 @@
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "pet.inc"
.macpack module
@ -40,10 +41,6 @@
JOY_COUNT = 2 ; Number of joysticks we support
VIA_PRA := $E841 ; Port register A
VIA_DDRA := $E843 ; Data direction register A
.code
; ------------------------------------------------------------------------
@ -89,9 +86,9 @@ READ: lda #%10000000 ; via port A Data-Direction
; Read joystick 1
joy1: lda #$80 ; via port A read/write
sta VIA_PRA ; (output one at PA7)
sta VIA_PA1 ; (output one at PA7)
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #$1f ; get bit 4-0 (PA4-PA0)
eor #$1f
rts
@ -99,13 +96,13 @@ joy1: lda #$80 ; via port A read/write
; Read joystick 2
joy2: lda #$00 ; via port A read/write
sta VIA_PRA ; (output zero at PA7)
sta VIA_PA1 ; (output zero at PA7)
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #$0f ; get bit 3-0 (PA3-PA0)
sta tmp1 ; joy 4 directions
lda VIA_PRA ; via port A read/write
lda VIA_PA1 ; via port A read/write
and #%00100000 ; get bit 5 (PA5)
lsr
ora tmp1

View File

@ -85,7 +85,7 @@ READ:
joy1:
lda #0
sta VIA_DDRA
lda VIA_PRA
lda VIA_PA1
and #$0f
cmp #$0c
bne @notc1
@ -102,7 +102,7 @@ joy1:
joy2:
lda #0
sta VIA_DDRA
lda VIA_PRA
lda VIA_PA1
lsr
lsr
lsr