diff --git a/ACME_Lib/cbm/c64/cia1.a b/ACME_Lib/cbm/c64/cia1.a index 53cdb61..3fcf34a 100644 --- a/ACME_Lib/cbm/c64/cia1.a +++ b/ACME_Lib/cbm/c64/cia1.a @@ -6,11 +6,26 @@ lib_cbm_c64_cia1_a = 1 !source ; chip stuff (same for both cias) ; stuff for cia 1 only: !addr cia1_base = $dc00 - cia1_pra = cia1_base + cia_port_a ; PA0..PA4 are joy port 2 PA6+PA7 select paddle port(s) - cia1_prb = cia1_base + cia_port_b ; PB0..PB4 are joy port 1 - ; both ports are used for keyboard matrix - cia1_ddra = cia1_base + cia_data_direction_a - cia1_ddrb = cia1_base + cia_data_direction_b + ; both port A and port B are connected to the keyboard matrix. + ; in addition to that, they are used for: + cia1_pra = cia1_base + cia_port_a + ; %7....... writing 0 selects paddles at port 1 + ; %.6...... writing 0 selects paddles at port 2 + ; %...4.... reading 0 means JOY2_BUTTON + ; %....3... reading 0 means JOY2_RIGHT + ; %.....2.. reading 0 means JOY2_LEFT + ; %......1. reading 0 means JOY2_DOWN + ; %.......0 reading 0 means JOY2_UP + ; kernal's keyboard scanner writes values where a single bit is cleared, going from lsb to msb. + ; so most of the time, the last value written will be $7f. + cia1_prb = cia1_base + cia_port_b + ; %...4.... reading 0 means JOY1_BUTTON + ; %....3... reading 0 means JOY1_RIGHT + ; %.....2.. reading 0 means JOY1_LEFT + ; %......1. reading 0 means JOY1_DOWN + ; %.......0 reading 0 means JOY1_UP + cia1_ddra = cia1_base + cia_data_direction_a ; kernal writes $ff to set to output for keyboard scanner + cia1_ddrb = cia1_base + cia_data_direction_b ; kernal writes $00 to set to input for keyboard scanner cia1_ta_lo = cia1_base + cia_timer_a_low cia1_ta_hi = cia1_base + cia_timer_a_high cia1_tb_lo = cia1_base + cia_timer_b_low diff --git a/ACME_Lib/cbm/c64/cia2.a b/ACME_Lib/cbm/c64/cia2.a index 1eee23e..a127876 100644 --- a/ACME_Lib/cbm/c64/cia2.a +++ b/ACME_Lib/cbm/c64/cia2.a @@ -15,8 +15,16 @@ lib_cbm_c64_cia2_a = 1 ; %.....2.. PA2 (pin M at user port, 0 means GND) ; %......10 VIC bank (gets inverted, so value %11 means address $0000) cia2_prb = cia2_base + cia_port_b - cia2_ddra = cia2_base + cia_data_direction_a - cia2_ddrb = cia2_base + cia_data_direction_b + ; %7....... PB7 (pin L at user port, 0 means GND) + ; %.6...... PB6 (pin K at user port, 0 means GND) + ; %..5..... PB5 (pin J at user port, 0 means GND) + ; %...4.... PB4 (pin H at user port, 0 means GND) + ; %....3... PB3 (pin F at user port, 0 means GND) + ; %.....2.. PB2 (pin E at user port, 0 means GND) + ; %......1. PB1 (pin D at user port, 0 means GND) + ; %.......0 PB0 (pin C at user port, 0 means GND) + cia2_ddra = cia2_base + cia_data_direction_a ; kernal writes $3f + cia2_ddrb = cia2_base + cia_data_direction_b ; kernal writes $00 (all input) cia2_ta_lo = cia2_base + cia_timer_a_low cia2_ta_hi = cia2_base + cia_timer_a_high cia2_tb_lo = cia2_base + cia_timer_b_low