Advertisement
jumpToSubroutine

Musical Keyboard asm6502 (WIP)

Sep 5th, 2020 (edited)
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; 10 SYS (49152)
  2.  
  3. *=$0801
  4.  
  5.         BYTE    $0E, $08, $0A, $00, $9E, $20, $28,  $34, $39, $31, $35, $32, $29, $00, $00, $00
  6. ;----------------------------------------------------------------------------------------------
  7.  
  8. *=$C000
  9.  
  10. DEFM LSA ;Load and set register A
  11.         LDA #$/1
  12.         STA $/2
  13.         ENDM
  14. DEFM SN ;Set note
  15.         LDA #$/1
  16.         STA $D400 ;low byte
  17.         LDA #$/2
  18.         STA $D401 ;high byte
  19.         ENDM
  20. DEFM CKJ ;Check key and jump to label
  21.         CMP #/1
  22.         BEQ /2
  23.         ENDM
  24.  
  25.  
  26. INIT:
  27.  
  28. ;           Val MemAddress
  29.        LSA 44, D400    ;frequency voice1 low byte
  30.        LSA 1D, D401    ;frequency voice1 high byte
  31.        LSA 0F, D418    ;volume
  32.  
  33.        ;ADSR
  34.        LSA 11, D405    ;attack
  35.        LSA F0, D406    ;sustain
  36.  
  37.        ;play note
  38.        LSA 11, D404    ;control register / turn on
  39.        LSA 10, D404    ;control register / turn off
  40.        JMP LOOP
  41.  
  42. LOOP
  43.        LDA 203
  44. ;          Key Note    Key  Note
  45.        CKJ 12, PC      ;Z - C
  46.        CKJ 13, PCS     ;S - C#
  47.        CKJ 23, PD      ;X - D
  48.        CKJ 18, PDS     ;D - D#
  49.        CKJ 20, PE      ;C - E
  50.        CKJ 31, PF      ;V - F
  51.        CKJ 28, PFS     ;G - F#
  52.        CKJ 26, PG      ;B - G
  53.        CKJ 29, PGS     ;H - G#
  54.        CKJ 39, PA      ;N - A  
  55.        CKJ 34, PAS     ;J - A#
  56.        CKJ 36, PB      ;M - B  
  57.        CKJ 64, NOF     ;NaN - NaN
  58.        JMP LOOP
  59.  
  60. NON
  61.        LSA 11, D404 ;gate on
  62.        JMP LOOP
  63. NOF
  64.        LSA 10, D404 ;gate off
  65.        JMP LOOP
  66.  
  67. ;------------------------------------
  68.  
  69. PC
  70.        SN 08, 93
  71.        JMP NON
  72. PCS
  73.        SN 09, 15
  74.        JMP NON
  75. PD
  76.        SN 09, 9F
  77.        JMP NON
  78. PDS
  79.        SN 0A, 32
  80.        JMP NON
  81. PE
  82.        SN 0A, CD
  83.        JMP NON
  84.  
  85. ;JumpExtentions
  86. PF
  87.        JMP PF1
  88. PFS
  89.        JMP PFS1
  90. PG
  91.        JMP PG1
  92. PGS
  93.        JMP PGS1
  94. PA
  95.        JMP PA1
  96. PAS
  97.        JMP PAS1
  98. PB
  99.        JMP PB1
  100. ;-------------
  101.  
  102. PF1
  103.        SN 0B, 72
  104.        JMP NON
  105. PFS1
  106.        SN 0C, 20
  107.        JMP NON
  108.  
  109. PG1
  110.        SN 0C, D8
  111.        JMP NON
  112. PGS1
  113.        SN 0D, 9C
  114.        JMP NON
  115. PA1
  116.        SN 0E, 6B
  117.        JMP NON
  118. PAS1
  119.        SN 0F, 46
  120.        JMP NON
  121. PB1
  122.        SN 10, 2F
  123.        JMP NON
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement