goeiecool9999

vader jakob

Mar 5th, 2021 (edited)
959
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. INESMAP 0
  2. INESPRG 1
  3.  
  4. seqTimer equ 0
  5. sequenceIdx equ 1
  6.  
  7. ORG $8000
  8.  
  9.  
  10. timerL:
  11. DB $47, $17, $e9, $bf, $96, $70, $4c, $2a, $0a, $ec, $cf, $b4, $9b, $83, $6c, $57, $43, $30, $1e, $0d, $fd, $ee, $df, $d2, $c5
  12. silentL:
  13. DB $01
  14.  
  15. timerH:
  16. DB $03, $03, $02, $02, $02, $02, $02, $02, $02, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $01, $00, $00, $00, $00, $00, $00
  17.  
  18. silent equ #silentL-timerL
  19.  
  20. song:
  21. DB 12,14,16,12,12,14,16,12,16,17,19,silent,16,17,19,silent,19,21,19,17,16,silent,12,silent,19,21,19,17,16,silent,12,silent,12,silent,7,silent,12,silent,silent,silent,12,silent,7,silent,12,silent,silent,silent
  22. songLen=$-song
  23.  
  24. main:
  25.     SEI
  26.  
  27. ;enable pulse channel
  28.     LDA #$01
  29.     STA $4015
  30.  
  31. ;set volume and duty cycle
  32.     LDA #$bf
  33.     STA $4000
  34.  
  35. ;disable sweep
  36.     LDA #$08
  37.     STA $4001
  38.  
  39.     CLI
  40.    
  41.  
  42. end:
  43.     JMP end
  44.  
  45. IRQ:
  46. ;check if frame interrupt
  47.     LDA $4015
  48.     AND #$40
  49.     BEQ ++
  50.  
  51. ;decrement and jump if timer not run out
  52.     DEC seqTimer
  53.     BPL ++
  54.  
  55. ;reset counter
  56.     LDA #$20
  57.     STA seqTimer
  58.  
  59. ;timer action
  60.  
  61.     LDY sequenceIdx
  62.  
  63. ;check OOB
  64.     LDA #songLen
  65.     CMP sequenceIdx
  66.     BNE +
  67.     LDY #$0
  68.  
  69.  +  LDX song, y
  70.  
  71. ;get timer value from table
  72.     LDA timerL,x
  73.     STA $4002
  74.  
  75.     LDA timerH,x
  76.     STA $4003
  77.  
  78.     INY
  79.     STY sequenceIdx
  80.  
  81.    
  82. ++  RTI
  83.  
  84. NMI:
  85.     RTI
  86.  
  87. PAD $BFFA
  88. DW NMI
  89.  
  90. PAD $BFFC, $80
  91. DW main
  92.  
  93. PAD $BFFE
  94. DW IRQ
  95.  
RAW Paste Data