improved CIA #1 initialization, some cleanups

This commit is contained in:
FeralChild64 committed 2019-10-11 23:02:35 +02:00
1 parent deac5dcb51
commit 0487488751
6 files changed
+32 -31

No files matched your search

+1
View File
@@ -10,6 +10,7 @@ SRCDIR_KERNAL = $(SRCDIR_COMMON) \
c64/kernal/jumptable \ c64/kernal/jumptable \
c64/kernal/iec \ c64/kernal/iec \
c64/kernal/interrupts \ c64/kernal/interrupts \
c64/kernal/keyboard \
c64/kernal/print \ c64/kernal/print \
c64/kernal/screen c64/kernal/screen
+8
View File
@@ -101,6 +101,14 @@ IOINIT:
sta CIA1_CRA sta CIA1_CRA
lda CIA1_ICR lda CIA1_ICR
// Setup the CIA1 for reading the keyboard - 'POKE 56322, 0' on original ROMs proves this
// is done during initialization, not during the interrupt
ldx #$FF
stx CIA1_DDRA // output
ldy #$00
sty CIA1_DDRB // input
// Set DDR on CIA2 for IEC bus, VIC-II banking // Set DDR on CIA2 for IEC bus, VIC-II banking
lda #$3B lda #$3B
sta CIA2_DDRA sta CIA2_DDRA
File renamed without changes.
@@ -34,7 +34,7 @@ SCNKEY:
beq sk_start beq sk_start
dec KOUNT dec KOUNT
// Setup the CIA registers // Setup the CIA registers XXX check whether the C64 does it every time
ldx #$FF ldx #$FF
stx CIA1_DDRA // output stx CIA1_DDRA // output
@@ -45,6 +45,7 @@ SCNKEY:
lda SHFLAG lda SHFLAG
sta LSTSHF sta LSTSHF
ldy #$00
sty SHFLAG sty SHFLAG
// XXX retrieve ALT and NO_SCRL status for C128/C65 keyboards // XXX retrieve ALT and NO_SCRL status for C128/C65 keyboards
@@ -52,6 +53,7 @@ SCNKEY:
// Check for any activity // Check for any activity
sty CIA1_PRA // connect all the lines sty CIA1_PRA // connect all the lines
ldx #$FF
cpx CIA1_PRB cpx CIA1_PRB
beq scnkey_no_keys beq scnkey_no_keys
@@ -60,7 +62,9 @@ SCNKEY:
// Set pointer in KEYTAB // Set pointer in KEYTAB
jsr scnkey_via_keytab jsr scnkey_via_keytab
// XXX scan the keyboard matrix // XXX check for joystick activity
// Scan the keyboard matrix
@@ -31,6 +31,8 @@ scnkey_set_keytab:
adc KEYTAB+1 adc KEYTAB+1
sta KEYTAB+1 sta KEYTAB+1
scnkey_toggle_if_needed: // entry for SCNKEY (TWW/CTR version)
// Check if we should toggle the character set // Check if we should toggle the character set
lda MODE lda MODE
@@ -219,17 +219,14 @@ Main:
sta BufferNew+1 sta BufferNew+1
sta BufferNew+2 sta BufferNew+2
ldx #$ff
stx $dc02 // Port A - Output
ldy #$00
sty $dc03 // Port B - Input
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Port Activity // // Check for Port Activity
sty $dc00 // Connect all Keyboard Rows ldx #$FF
cpx $dc01 ldy #$00
sty CIA1_PRA // Connect all Keyboard Rows
cpx CIA1_PRB
bne skip0 bne skip0
jmp NoActivityDetected jmp NoActivityDetected
@@ -240,7 +237,7 @@ JoystickActivity:
lda #$00 lda #$00
sta SHFLAG sta SHFLAG
lda $dc01 lda CIA1_PRB
and #$03 and #$03
cmp #$01 cmp #$01
bne !+ bne !+
@@ -267,7 +264,7 @@ JoystickActivity:
beq !+ beq !+
jmp skdone jmp skdone
!: !:
lda $dc01 lda CIA1_PRB
and #$0c and #$0c
cmp #$04 cmp #$04
bne !+ bne !+
@@ -293,8 +290,8 @@ skip0:
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Control Port #1 Activity // // Check for Control Port #1 Activity
stx $dc00 // Disconnect all Keyboard Rows stx CIA1_PRA // Disconnect all Keyboard Rows
cpx $dc01 // Only Control Port activity will be detected cpx CIA1_PRB // Only Control Port activity will be detected
bne JoystickActivity bne JoystickActivity
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -303,9 +300,9 @@ skip0:
ldx #7 ldx #7
lda #%11111110 lda #%11111110
next_row: next_row:
sta $dc00 sta CIA1_PRA
pha pha
lda $dc01 lda CIA1_PRB
sta ScanResult,x sta ScanResult,x
pla pla
sec sec
@@ -318,8 +315,8 @@ next_row:
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Control Port #1 Activity (again) // // Check for Control Port #1 Activity (again)
stx $dc00 // Disconnect all Keyboard Rows stx CIA1_PRA // Disconnect all Keyboard Rows
cpx $dc01 // Only Control Port activity will be detected cpx CIA1_PRB // Only Control Port activity will be detected
beq !+ beq !+
jmp ReturnNoKeys jmp ReturnNoKeys
!: !:
@@ -375,19 +372,8 @@ next_row:
ora SHFLAG ora SHFLAG
sta SHFLAG sta SHFLAG
// Chick for shift + Vendor // Handle SHIFT + VENDOR
cmp #$03 jsr scnkey_toggle_if_needed
bne no_case_toggle
lda LSTSHF
cmp #$03
beq no_case_toggle
lda MODE
bne no_case_toggle
lda VIC_YMCSB
eor #$02
sta VIC_YMCSB
no_case_toggle: no_case_toggle: