Subversion Repositories NedoOS

Rev

Rev 1637 | Rev 1712 | 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.         inc hl
  103.         ld (hl),0
  104. ;load wavekit
  105.         ld de,0x8000
  106.         call openstream_file
  107.         or a
  108.         ret nz
  109. loadmwkdata
  110.         call mwkload
  111.         push af
  112.         call closestream_file
  113.         pop af
  114.         ret nz
  115. loadmwm
  116.         ld de,(filenameaddr)
  117.         call openstream_file
  118.         or a
  119.         ret nz
  120.         call mwmload
  121.         ret nz
  122.         call closestream_file
  123.  
  124.         call start_music
  125.  
  126.         ld a,255
  127.         ld (xloop),a
  128.  
  129.         xor a
  130.         ret
  131.  
  132. musicunload
  133.         jp stop_music
  134.  
  135. musicplay
  136. ;out: zf=0 if still playing, zf=1 otherwise
  137.         ld a,(play_busy)
  138.         or a
  139.         ret z
  140.         in a,(MOON_STAT)
  141.         rla
  142.         jr nc,musicplay
  143.         call play_int
  144.         ld a,(play_busy)
  145.         or a
  146.         ret
  147.  
  148. strcopy_hltode
  149.         ld a,(hl)
  150.         ld (de),a
  151.         or a
  152.         ret z
  153.         inc hl
  154.         inc de
  155.         jr strcopy_hltode
  156.  
  157. ;c = character
  158. ;hl = poi to filename in string
  159. ;out: de = after last dot or start
  160. findlastchar
  161.         ld d,h
  162.         ld e,l ;de = after last char
  163. findlastchar0
  164.         ld a,(hl)
  165.         inc hl
  166.         or a
  167.         ret z
  168.         cp c
  169.         jr nz,findlastchar0
  170.         jr findlastchar
  171.  
  172. mwknone
  173.         db "NONE    "
  174.  
  175. load_file
  176.         push de
  177.         push ix
  178.         call readstream_file
  179.         pop ix
  180.         pop de
  181.         ret
  182.  
  183. selbank_FE
  184.         SETPG8000
  185.         ret
  186.  
  187.         include "../_sdk/file.asm"
  188.         include "moonsound.asm"
  189.         include "mbwave/basic.asm"
  190.  
  191. end
  192.         savebin "mwm.bin",begin,end-begin
  193.