Advertisement
jbshelton

Sample player subroutine concept for GB/C MOD player

Feb 10th, 2021 (edited)
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ld a, [sample_buffer+] ;LUT for volumes integrated in buffer
  2. ld d, a
  3. ld a, [sample_buffer+] ;pregenerated buffer by software frequency generator, 8 bit samples for ease of use
  4. srl a
  5. ld e, a
  6. ld a, [de] (to get the final amplitude)
  7. sub $40
  8. jr nc, nocomplement1
  9. cpl
  10. inc a ;because SM83 doesn't have the Z80's neg
  11. nocomplement1:
  12. push af
  13. ld a, [sample_buffer+]
  14. ld d, a
  15. ld a, [sample_buffer+]
  16. srl a
  17. ld e, a
  18. ld a, [de]
  19. sub $40
  20. jr nc, nocomplement2
  21. cpl
  22. inc a
  23. nocomplement2:
  24. ld b, a
  25. pop af
  26. add b
  27. add $80
  28. ld d, amplitude_LUT
  29. ld e, a
  30. ld a, [de]
  31. ld b, a
  32. or $0f
  33. ldh [rNRx2], a
  34. ld a, $80
  35. ldh [rNRx4], a
  36. ld a, b
  37. and $f0
  38. ld b, a
  39. swap b
  40. or b
  41. ldh [rNR50], a
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement