Subversion Repositories NedoOS

Rev

Rev 1640 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.         include "playerdefs.asm"
  4.  
  5.         org PLAYERSTART
  6.  
  7. begin   PLAYERHEADER
  8.  
  9. isfilesupported
  10. ;cde = file extension
  11. mwmsupported=$+1
  12.         ld a,'m'
  13.         cp c
  14.         ret nz
  15.         ld hl,'wm'
  16.         sub hl,de
  17.         ret
  18.  
  19. playerinit
  20. ;hl = shared pages
  21. ;a = player page
  22.         ld de,songdata_bank1
  23.         ld bc,3
  24.         ldir
  25.  
  26.         call ismoonsoundpresent
  27.         ret z
  28.         ld (mwmsupported),a ;writes 255 disabling the extension
  29.         ret
  30.  
  31. playerdeinit
  32.         ret
  33.  
  34. musicload
  35. ;de = input file name
  36. ;First try loading wavekit with the same filename as input file.
  37. ;This allows overriding wavekit specified in MWM header without
  38. ;having the file edited.
  39.         ex de,hl
  40.         ld (filenameaddr),hl
  41.         ld c,'.'
  42.         call findlastchar ;out: de = after last dot or start
  43.         ld hl,2
  44.         add hl,de
  45.         ld (hl),'k'
  46. filenameaddr=$+1
  47.         ld de,0
  48.         push hl
  49.         call openstream_file
  50.         pop hl
  51.         ld (hl),'m'
  52.         or a
  53.         jr z,loadmwkdata
  54. ;din't find wavekit so now have to load and parse module header
  55.         ld de,(filenameaddr)
  56.         call openstream_file
  57.         or a
  58.         ret nz
  59.         ld a,(songdata_bank1)
  60.         SETPG8000
  61.         ld de,0x8000
  62.         ld hl,284
  63.         call readstream_file
  64.         call closestream_file
  65. ;check if this is a valid MWM file
  66.         ld de,0x8000
  67.         ld a,8 ;file type 8 = wave user song
  68.         call check_header
  69.         ret nz
  70. ;check if wavekit is needed
  71.         ld hl,0x8114
  72.         ld de,mwknone
  73.         ld b,8
  74.         call chk_headerlus
  75.         jr z,loadmwm
  76. ;build filename
  77.         ld hl,(filenameaddr)
  78.         ld de,0x8000
  79.         call strcopy_hltode
  80.         ld hl,0x8000
  81.         ld c,'/'
  82.         call findlastchar ;out: de = after last slash or start
  83.         ld hl,0x8114
  84.         ld b,8
  85. filenamecopyloop
  86.         ld a,(hl)
  87.         cp ' '
  88.         jr z,donefilenamecopy
  89.         ld (de),a
  90.         inc hl
  91.         inc de
  92.         djnz filenamecopyloop
  93. donefilenamecopy
  94.         ex de,hl
  95.         ld (hl),'.'
  96.         inc hl
  97.         ld (hl),'m'
  98.         inc hl
  99.         ld (hl),'w'
  100.         inc hl
  101.         ld (hl),'k'
  102. ;load wavekit
  103.         ld de,0x8000
  104.         call openstream_file
  105.         or a
  106.         ret nz
  107. loadmwkdata
  108.         call mwkload
  109.         push af
  110.         call closestream_file
  111.         pop af
  112.         ret nz
  113. loadmwm
  114.         ld de,(filenameaddr)
  115.         call openstream_file
  116.         or a
  117.         ret nz
  118.         call mwmload
  119.         ret nz
  120.         call closestream_file
  121.  
  122.         call start_music
  123.  
  124.         ld a,255
  125.         ld (xloop),a
  126.  
  127.         xor a
  128.         ret
  129.  
  130. musicunload
  131.         jp stop_music
  132.  
  133. musicplay
  134. ;out: zf=0 if still playing, zf=1 otherwise
  135.         ld a,(play_busy)
  136.         or a
  137.         ret z
  138.         in a,(MOON_STAT)
  139.         rla
  140.         jr nc,musicplay
  141.         call play_int
  142.         ld a,(play_busy)
  143.         or a
  144.         ret
  145.  
  146. checknone
  147.         ld a,(hl)
  148.         cp 'N'
  149.         ret nz
  150.         inc hl
  151.         ld a,(hl)
  152.         cp 'O'
  153.         ret nz
  154.         inc hl
  155.         ld a,(hl)
  156.         cp 'N'
  157.         ret nz
  158.         inc hl
  159.         ld a,(hl)
  160.         cp 'E'
  161.         ret nz
  162.         inc hl
  163.         ld a,(hl)
  164.         cp ' '
  165.         ret
  166.  
  167. strcopy_hltode
  168.         ld a,(hl)
  169.         ld (de),a
  170.         or a
  171.         ret z
  172.         inc hl
  173.         inc de
  174.         jr strcopy_hltode
  175.  
  176. ;c = character
  177. ;hl = poi to filename in string
  178. ;out: de = after last dot or start
  179. findlastchar
  180.         ld d,h
  181.         ld e,l ;de = after last char
  182. findlastchar0
  183.         ld a,(hl)
  184.         inc hl
  185.         or a
  186.         ret z
  187.         cp c
  188.         jr nz,findlastchar0
  189.         jr findlastchar
  190.  
  191. mwknone
  192.         db "NONE    "
  193.  
  194. load_file
  195.         push de
  196.         push ix
  197.         call readstream_file
  198.         pop ix
  199.         pop de
  200.         ret
  201.  
  202. selbank_FE
  203.         SETPG8000
  204.         ret
  205.  
  206.         include "../_sdk/file.asm"
  207.         include "moonsound.asm"
  208.         include "mbwave/basic.asm"
  209.  
  210. end
  211.         savebin "mwm.bin",begin,end-begin
  212.