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/iec \
c64/kernal/interrupts \
c64/kernal/keyboard \
c64/kernal/print \
c64/kernal/screen
+8
View File
@@ -101,6 +101,14 @@ IOINIT:
sta CIA1_CRA
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
lda #$3B
sta CIA2_DDRA
File renamed without changes.
@@ -34,7 +34,7 @@ SCNKEY:
beq sk_start
dec KOUNT
// Setup the CIA registers
// Setup the CIA registers XXX check whether the C64 does it every time
ldx #$FF
stx CIA1_DDRA // output
@@ -45,6 +45,7 @@ SCNKEY:
lda SHFLAG
sta LSTSHF
ldy #$00
sty SHFLAG
// XXX retrieve ALT and NO_SCRL status for C128/C65 keyboards
@@ -52,6 +53,7 @@ SCNKEY:
// Check for any activity
sty CIA1_PRA // connect all the lines
ldx #$FF
cpx CIA1_PRB
beq scnkey_no_keys
@@ -60,7 +62,9 @@ SCNKEY:
// Set pointer in 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
sta KEYTAB+1
scnkey_toggle_if_needed: // entry for SCNKEY (TWW/CTR version)
// Check if we should toggle the character set
lda MODE
@@ -218,18 +218,15 @@ Main:
sta BufferNew+0
sta BufferNew+1
sta BufferNew+2
ldx #$ff
stx $dc02 // Port A - Output
ldy #$00
sty $dc03 // Port B - Input
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Port Activity
sty $dc00 // Connect all Keyboard Rows
cpx $dc01
ldx #$FF
ldy #$00
sty CIA1_PRA // Connect all Keyboard Rows
cpx CIA1_PRB
bne skip0
jmp NoActivityDetected
@@ -240,7 +237,7 @@ JoystickActivity:
lda #$00
sta SHFLAG
lda $dc01
lda CIA1_PRB
and #$03
cmp #$01
bne !+
@@ -267,7 +264,7 @@ JoystickActivity:
beq !+
jmp skdone
!:
lda $dc01
lda CIA1_PRB
and #$0c
cmp #$04
bne !+
@@ -293,8 +290,8 @@ skip0:
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Control Port #1 Activity
stx $dc00 // Disconnect all Keyboard Rows
cpx $dc01 // Only Control Port activity will be detected
stx CIA1_PRA // Disconnect all Keyboard Rows
cpx CIA1_PRB // Only Control Port activity will be detected
bne JoystickActivity
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -303,9 +300,9 @@ skip0:
ldx #7
lda #%11111110
next_row:
sta $dc00
sta CIA1_PRA
pha
lda $dc01
lda CIA1_PRB
sta ScanResult,x
pla
sec
@@ -318,8 +315,8 @@ next_row:
// //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// // Check for Control Port #1 Activity (again)
stx $dc00 // Disconnect all Keyboard Rows
cpx $dc01 // Only Control Port activity will be detected
stx CIA1_PRA // Disconnect all Keyboard Rows
cpx CIA1_PRB // Only Control Port activity will be detected
beq !+
jmp ReturnNoKeys
!:
@@ -375,19 +372,8 @@ next_row:
ora SHFLAG
sta SHFLAG
// Chick for shift + Vendor
cmp #$03
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
// Handle SHIFT + VENDOR
jsr scnkey_toggle_if_needed
no_case_toggle: