?login_element?

Subversion Repositories NedoOS

Rev

Rev 1876 | Blame | Compare with Previous | Last modification | View Log | Download

  1.     macro GS_WaitCommand
  2. .wait
  3.     in a, (GeneralSound.CMD)
  4.     rrca
  5.     jr c, .wait
  6.     endm
  7.  
  8.     macro GS_WaitData
  9. .wait
  10.     in a, (GeneralSound.CMD)
  11.     rlca
  12.     jr c, .wait
  13.     endm
  14.  
  15.     macro GS_SendCommand nn
  16.     ld a, nn : out (GeneralSound.CMD), a
  17.     endm
  18.  
  19.     module GeneralSound
  20. ;; Control ports
  21. CMD  = 187
  22. DATA = 179
  23.  
  24. ;; Commands
  25. CMD_WARM_RESET      = #F3
  26. CMD_COLD_RESET      = #F4
  27. CMD_LOAD_MODULE     = #30
  28. CMD_PLAY_MODULE     = #31
  29. CMD_STOP_MODULE     = #32
  30. CMD_CONTINUE_MODULE = #33
  31. CMD_OPEN_STREAM     = #D1
  32. CMD_CLOSE_STREAM    = #D2
  33.  
  34. ; A - 0 warm reset, other - cold
  35. init:
  36.     and a : jr nz, .cold
  37.     GS_SendCommand CMD_WARM_RESET
  38.     ret
  39. .cold
  40.     GS_SendCommand CMD_COLD_RESET
  41.     ret
  42.  
  43. ;; Initializes loading module
  44. loadModule:
  45.     GS_SendCommand CMD_LOAD_MODULE
  46.     GS_WaitCommand
  47.     GS_SendCommand CMD_OPEN_STREAM
  48.     GS_WaitCommand
  49.     ret
  50.  
  51. ;; Use it for streaming mod file
  52. sendByte:
  53.     out (DATA), a
  54.     GS_WaitData
  55.     ret
  56.  
  57. ;; Call it when module was loaded
  58. finishLoadingModule:
  59.     GS_SendCommand CMD_CLOSE_STREAM
  60.     GS_WaitCommand
  61. rewind:
  62.     ld a, 1 : out (DATA), a
  63.     GS_SendCommand CMD_PLAY_MODULE
  64.     GS_WaitCommand
  65.     ld a, 1, (state),a
  66.     ret
  67.  
  68. ;; Works like pause too
  69. stopModule:
  70.     xor a : ld (state), a
  71.     GS_SendCommand CMD_STOP_MODULE
  72.     ret
  73.  
  74. continueModule:
  75.     ld a, 1 : ld (state), a
  76.     GS_SendCommand CMD_CONTINUE_MODULE
  77.     ret
  78.  
  79. ; Pauses resumes
  80. toggleModule:
  81.     call Console.waitForKeyUp
  82.     ld a, (state) : and a
  83.     jr z, continueModule
  84.     jr stopModule
  85.  
  86. state db 0
  87.     endmodule