trs80music.asm 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. ; playmusic
  2. ; parameters:
  3. ; hl = list of notes to play
  4. ; destroys: a,bc,hl
  5. ; preserves: de,ix
  6. spt_playmusic:
  7. pop hl
  8. ; fall through to playmusic
  9. playmusic: ;music routine
  10. .getnote:
  11. ld c,(hl)
  12. ld a,c
  13. or a
  14. jr z,.end ; zero duration: we are done
  15. inc hl
  16. ld a,(hl)
  17. or a
  18. jr z,.rest ; zero frequency: rest
  19. .cycle: ; tone cycle. First low part of square wave
  20. ld b,(hl)
  21. out (0d4h),a
  22. .loophalf:
  23. nop12
  24. nop12
  25. nop12
  26. djnz .loophalf
  27. bit 1,a
  28. jr nz,.cycle
  29. dec c
  30. jr nz,.cycle
  31. ; ld b,80
  32. ; .between_inner: ; delay between notes
  33. ; nop12
  34. ; djnz .between_inner
  35. jr .nextnote
  36. .rest:
  37. ld b,0
  38. .restloop:
  39. nop12
  40. nop12
  41. djnz .restloop
  42. dec c
  43. jr nz,.rest
  44. .nextnote:
  45. ld a,(hl)
  46. inc hl
  47. jr .getnote
  48. .end:
  49. ld a,080h
  50. out (0d4h),a
  51. ret
  52. tones_welcome:
  53. db $60,$40
  54. db $00,$00 ;end
  55. tones_vram: db $10,$81 ;each note is first byte duration
  56. db $10,$80 ;then next byte frequency -- the higher the second byte, the lower the frequency
  57. db $10,$81
  58. db $10,$80
  59. db $10,$81
  60. db $10,$80
  61. db $10,$81
  62. db $10,$80
  63. ; db $40,$00 ;rest
  64. db $00,$00 ;end
  65. ; tones_vram: db $30,$60
  66. ; db $10,$90 ;each note is first byte duration
  67. ; db $20,$40 ;then next byte frequency -- the higher the second byte, the lower the frequency
  68. ; db $10,$90
  69. ; db $20,$40
  70. ; db $30,$60
  71. ; ; db $30,$50
  72. ; ; db $f0,$c0
  73. ; db $60,$00 ;rest
  74. ; db $00,$00 ;end
  75. ; tones_sad: db $30,$50 ;each note is first byte duration
  76. ; db $30,$60 ;then next byte frequency -- the higher the second byte, the lower the frequency
  77. ; db $30,$70
  78. ; db $30,$80
  79. ; db $30,$90
  80. ; db $30,$a0
  81. ; db $30,$b0
  82. ; db $f0,$c0
  83. ; db $00,$00 ;end
  84. tones_vramgood: db $03,$c0 ;each note is first byte duration
  85. db $03,$b0 ;then next byte frequency -- the higher the second byte, the lower the frequency
  86. db $04,$a0
  87. db $04,$90
  88. db $04,$80
  89. db $05,$70
  90. db $05,$60
  91. db $40,$50
  92. ; db $40,$00 ;rest
  93. db $00,$00 ;end
  94. tones_bitgood: db $40,$30
  95. db $20,$00 ;rest
  96. db $00,$00 ;end
  97. tones_bitbad: db $10,$C0
  98. db $20,$00 ;rest
  99. db $00,$00 ;end
  100. tones_bytegood: db $FF,$30
  101. db $00,$00 ;end
  102. tones_bytebad: db $44,$C0
  103. db $80,$00 ;rest
  104. db $00,$00 ;end