ca65 V2.17 - Git 582aa41 Main file : metronome.ca65 Current file: metronome.ca65 000000r 1 ; 000000r 1 ; ACORN System 1 Applications: Metronome 000000r 1 ; 000000r 1 ; From the Acorn System 1 User's Manual 000000r 1 ; 000000r 1 ; (Chris Oddy January 2022) 000000r 1 ; 000000r 1 ; entry point $0200 000000r 1 ; 000000r 1 .setcpu "6502" 000000r 1 .listbytes unlimited 000000r 1 ; 000000r 1 REPEAT := $0E 000000r 1 ADDR := $0E22 ; A Data direction register 000000r 1 DISPLAY := $FE0C ; scan the display 000000r 1 WAIT := $FECD ; 300baud wait time 000000r 1 ; 000000r 1 .org $0200 000200 1 ; 000200 1 PERIOD := $20 000200 1 CLRPA6 := $0E06 ; clear bit 6 of PIA 000200 1 SETPA6 := $0E16 ; set bit 6 of PIA 000200 1 ; 000200 1 A9 1F METRO: lda #$1F 000202 1 85 0E sta REPEAT ; set display to single scan 000204 1 A9 40 PULSE: lda #$40 000206 1 8D 22 0E sta ADDR ; define PA6 as output 000209 1 8D 16 0E sta SETPA6 ; use the INS8154 set bit mode 00020C 1 20 CD FE jsr WAIT ; use the 300 baud wait 00020F 1 8D 06 0E sta CLRPA6 ; use the INS8154 clear bit mode 000212 1 A6 20 ldx PERIOD 000214 1 20 0C FE DEL: jsr DISPLAY ; look at keyboard 000217 1 C9 16 cmp #$16 ; up key ? 000219 1 D0 04 bne DOWN ; no 00021B 1 E6 20 inc PERIOD ; decrease PERIOD 00021D 1 B0 E5 bcs PULSE ; carry was set by the compare: always 00021F 1 C9 17 DOWN: cmp #$17 ; down key ? 000221 1 D0 04 bne DELI ; no 000223 1 C6 20 dec PERIOD ; decrease PERIOD 000225 1 B0 DD bcs PULSE ; carry was set by the compare: always 000227 1 A0 0C DELI: ldy #$0C ; cycle time of u1/2 seconds 000229 1 20 CD FE DELJ: jsr WAIT 00022C 1 88 dey 00022D 1 10 FA bpl DELJ 00022F 1 CA dex 000230 1 D0 E2 bne DEL 000232 1 F0 D0 beq PULSE ; end of this period so pulse 000232 1