*=$C000 ; ;------------------------------------------------------------------- ;MAIN PROGRAM ; ;Diverts interrupt vector from $EA31 to the read_kb routine SEI ;Disable int to prevent ints while diverting LDA #read_kb ;Divert the interrupt vector (MSB) STA $0315 ; CLI ;Enable the interrupt ; ;Set SID registers (volume, frequency and ADSR of voice 1) LDA #$0F ;Set volume to max (0F) STA $D418 ; LDA #$22 ;Set the frequency of voice 1 STA $D401 ;to $2200 LDA #$00 ; STA $D400 ; STA $D405 ;set A=0, D=0 (voice 1) LDA #$F0 ; STA $D406 ;set S=F, R=0 (voice 1) ; ;other settings STA *$02 ;set starting speed=F0 ; ; ;main routine: read control port 2 and emit dots and dashes ; read_p2 LDA $DC00 ;read control port 2 CMP #$77 ;is the joystick moved right? BNE is_dot ;if not,skip dash and go forward to is_dot ;dash LDA #$11 ;voice1 on(sound) LDY #$FF ;set duration of a dash JSR delay ;emits a dash LDA #$10 ;voice1 off(pause) LDY #$55 ;set duration of a dot JSR delay ;emits a pause lasting a dot JMP read_p2 ;go back to read_p2 ; is_dot CMP #$7B ;is the joystick moved left? BNE read_p2 ;if not, go back to read_p2 ;dot LDA #$11 ;voice1 on(sound) LDY #$55 ;set duration of a dot JSR delay ;emits a dot LDA #$10 ;voice1 off(pause) LDY #$55 ;set duration of a dot JSR delay ;emits a pause lasting a dot JMP read_p2 ;go back to read_p2 ; ; ;------------------------------------------------------------------- ;delay subroutine ; delay STA $D404 ;set/reset voice 1 loop1 LDX *$02 ;read actual speed from $02 loop2 NOP ;wait DEX ;decrement X BNE loop2 ;if X!=0 go back to loop2 DEY ;decrement Y BNE loop1 ;if Y!=0 go back to loop1 RTS ;return from subroutine ; ;------------------------------------------------------------------- ;read keyboard routine (speed setting, executed ad every interrupt) ; read_kb LDA *$CB ;read the keyboard CMP #$28 ;is the key "+" pressed? BNE sk_dec ;if not, skip the dec statement DEC *$02 ;decrement $02 (increment speed) sk_dec CMP #$2B ;is the key "-" pressed? BNE sk_inc ;if not, skip the inc statement INC *$02 ;increment $02 (decrement speed) sk_inc JMP $EA31 ;jump to the original int routine ; ;------------------------------------------------------------------- ; .END