Advertisement
aNdy-AL-Cosine

6502 Keycheck

Jan 2nd, 2019
663
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Labels
  2.  
  3. PRA  =  $dc00            ; CIA#1 (Port Register A)
  4. PRB  =  $dc01            ; CIA#1 (Port Register B)
  5.  
  6. ; main loop to detect keypresses
  7.  
  8. keycheck   
  9.         lda #$7f        ; test $DC00 bit row 7 ($7F)
  10.         sta PRA
  11.         lda PRB
  12.        
  13.         cmp #$fe        ; key '1' pressed?
  14.         beq playtune1   ; then play tune 1 routine
  15.        
  16.         cmp #$f7        ; key '2' pressed?
  17.         beq playtune2   ; then play tune 2 routine
  18.  
  19.                         ; now swap to different row!
  20.         lda #$fd        ; test $DC00 bit row 1 ($fd)
  21.         sta PRA
  22.         lda PRB
  23.        
  24.         cmp #$fe        ; key '3' pressed?
  25.         beq playtune3   ; then play tune 3 routine
  26.        
  27.         jmp keycheck
  28.  
  29. ;routines to play each tune after keypress detection
  30.                
  31. playtune1
  32.         lda #$00        ; set tune 1
  33.         jsr music+$00   ; reinitialise player
  34.         jmp keycheck    ; back to keycheck loop
  35.        
  36. playtune2
  37.         lda #$01        ; set tune 2
  38.         jsr music+$00   ; reinitialise player
  39.         jmp keycheck    ; back to keycheck loop
  40.  
  41. playtune3
  42.         lda #$02        ; set tune 3
  43.         jsr music+$00   ; reinitialise player
  44.         jmp keycheck    ; back to keycheck loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement