-; we must use an irq here since we need timers
-; which otherwhise would conflict with system-irq
-pollirq:
- ; cia 2 setup
-
- ldy #$00 ; port b direction
- sty $dd03 ; => input
-
- sty $dd05 ; cia2 timer a highbyte
- sty $dc05 ; cia1 timer a highbyte
- iny
- sty $dd04 ; cia2 timer a lowbyte
- sty $dc04 ; cia1 timer a lowbyte
-
- lda #%00010001
- sta $dd0e ; control register a
- ; timer: start
- ; continous
- ; forced load
- ; serial port: input
-
- ; cia 1 setup
- lda #%01010001
- sta $dc0e ; control register a
- ; timer: start
- ; continous
- ; forced load
- ; serial port: output
-
-
- ; read directions 3
- lda $dd01 ;read cia 2 port b
- and #$0f
- sta temp3
-
- ; read button 3
- lda $dd02 ;cia 2 port a
- and #%11111011 ;data direction
- sta $dd02 ;=> bit 2 input
-
- lda $dd00 ;read cia 2 p.A
- and #%00000100 ;check bit 2
- asl a
- asl a
- ora temp3
- sta temp3
-
- ; read directions 4
- lda $dd01 ;read cia 2 port b
- lsr a
- lsr a
- lsr a
- lsr a
- sta temp4
-
- ; read button 4
- ldx #$ff ;serial data register
- stx $dc0c;=> writing $ff causes
- ;cia to output some
- ;count signals at cnt1
-
- ldx $dd0c ;read cia 2 serial in
- beq fire ;button press if zero
-
- lda temp4
- ora #%00010000
- sta temp4
+; IRQ entry point. Is called from the C layer as a subroutine in the
+; interrupt.
+
+IRQ: ; cia 2 setup
+
+ ldy #$00 ; port b direction
+ sty $dd03 ; => input
+
+ sty $dd05 ; cia2 timer a highbyte
+ sty $dc05 ; cia1 timer a highbyte
+ iny
+ sty $dd04 ; cia2 timer a lowbyte
+ sty $dc04 ; cia1 timer a lowbyte
+
+ lda #%00010001
+ sta $dd0e ; control register a
+ ; timer: start
+ ; continous
+ ; forced load
+ ; serial port: input
+
+ ; cia 1 setup
+ lda #%01010001
+ sta $dc0e ; control register a
+ ; timer: start
+ ; continous
+ ; forced load
+ ; serial port: output
+
+ ; read directions 3
+ lda $dd01 ;read cia 2 port b
+ and #$0f
+ sta temp3
+
+ ; read button 3
+ lda $dd02 ;cia 2 port a
+ and #%11111011 ;data direction
+ sta $dd02 ;=> bit 2 input
+
+ lda $dd00 ;read cia 2 p.A
+ and #%00000100 ;check bit 2
+ asl a
+ asl a
+ ora temp3
+ sta temp3
+
+ ; read directions 4
+ lda $dd01 ;read cia 2 port b
+ lsr a
+ lsr a
+ lsr a
+ lsr a
+ sta temp4
+
+ ; read button 4
+ ldx #$ff ;serial data register
+ stx $dc0c ;=> writing $ff causes
+ ;cia to output some
+ ;count signals at cnt1
+
+ ldx $dd0c ;read cia 2 serial in
+ beq fire ;button press if zero
+
+ lda temp4
+ ora #%00010000
+ sta temp4