?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ; MoonBlaster Wave modules player
  2.  
  3.         DEVICE ZXSPECTRUM128
  4.         include "../_sdk/sys_h.asm"
  5.         include "playerdefs.asm"
  6.  
  7. MUSICTITLE = 0x80dc
  8.  
  9.         org PLAYERSTART
  10.  
  11. begin   PLAYERHEADER
  12.  
  13. isfilesupported
  14. ;cde = file extension
  15. ;out: zf=1 if this player can handle the file and the sound hardware is available, zf=0 otherwise
  16. mwmsupported=$+1
  17.         ld a,'m'
  18.         cp c
  19.         ret nz
  20.         ld hl,'wm'
  21.         sbc hl,de
  22.         ret nz
  23. ;prepare local variables
  24.         ld (MUSICTITLEADDR),hl
  25.         ld hl,musicprogress+1
  26.         ld (MUSICPROGRESSADDR),hl
  27.         jp initprogress
  28.  
  29. playerinit
  30. ;hl,ix = GPSETTINGS
  31. ;a = player page
  32. ;out: zf=1 if init is successful, hl=init message
  33.         ld de,songdata_bank1
  34.         ld bc,3
  35.         ldir
  36.         ld a,(ix+GPSETTINGS.moonsoundstatus)
  37.         cp 2
  38.         ld hl,initokstr
  39.         ret z
  40.         ld hl,nodevicestr
  41.         ld a,255
  42.         ld (mwmsupported),a ;writes 255 disabling the extension
  43.         ret
  44.  
  45. playerdeinit
  46.         ret
  47.  
  48. musicload
  49. ;cde = file extension
  50. ;hl = input file name
  51. ;out: zf=1 if the file is ready for playing, zf=0 otherwise
  52. ;
  53. ;First try loading wavekit with the same filename as input file.
  54. ;This allows overriding wavekit specified in MWM header without
  55. ;having the file edited.
  56.         ld (filenameaddr),hl
  57.         ld c,'.'
  58.         call findlastchar ;out: de = after last dot or start
  59.         ld hl,2
  60.         add hl,de
  61.         ld (hl),'k'
  62. filenameaddr=$+1
  63.         ld de,0
  64.         push hl
  65.         call openstream_file
  66.         pop hl
  67.         ld (hl),'m'
  68.         or a
  69.         jr z,loadmwkdata
  70. ;didn't find wavekit, so now have to load and parse module header
  71.         ld de,(filenameaddr)
  72.         call openstream_file
  73.         or a
  74.         ret nz
  75.         ld a,(songdata_bank1)
  76.         SETPG8000
  77.         ld de,0x8000
  78.         ld hl,284
  79.         call readstream_file
  80.         call closestream_file
  81. ;check if this is a valid MWM file
  82.         ld de,0x8000
  83.         ld a,8 ;file type 8 = wave user song
  84.         call check_header
  85.         ret nz
  86. ;check if wavekit is needed
  87.         ld hl,0x8114
  88.         ld de,mwknone
  89.         ld b,8
  90.         call chk_headerlus
  91.         jr z,loadmwm
  92. ;build filename
  93.         ld hl,(filenameaddr)
  94.         ld de,0x8000
  95.         call strcopy_hltode
  96.         ld hl,0x8000
  97.         ld c,'/'
  98.         call findlastchar ;out: de = after last slash or start
  99.         ld hl,0x8114
  100.         ld b,8
  101. filenamecopyloop
  102.         ld a,(hl)
  103.         cp ' '
  104.         jr z,donefilenamecopy
  105.         ld (de),a
  106.         inc hl
  107.         inc de
  108.         djnz filenamecopyloop
  109. donefilenamecopy
  110.         ex de,hl
  111.         ld (hl),'.'
  112.         inc hl
  113.         ld (hl),'m'
  114.         inc hl
  115.         ld (hl),'w'
  116.         inc hl
  117.         ld (hl),'k'
  118.         inc hl
  119.         ld (hl),0
  120. ;load wavekit
  121.         ld de,0x8000
  122.         call openstream_file
  123.         or a
  124.         ret nz
  125. loadmwkdata
  126.         call mwkload
  127.         push af
  128.         call closestream_file
  129.         pop af
  130.         ret nz
  131. loadmwm
  132.         ld de,(filenameaddr)
  133.         call openstream_file
  134.         or a
  135.         ret nz
  136.         call mwmload
  137.         ret nz
  138.         call closestream_file
  139.  
  140.         call start_music
  141.  
  142. ;set music length
  143.         ld a,(xloop)
  144.         ld c,a
  145.         ld b,0
  146.         cp 255
  147.         ld a,(xleng)
  148.         jr nc,noloopinmusic
  149. ;the loop is played one additional time
  150.         ld l,a
  151.         ld h,b
  152.         add hl,hl
  153.         sbc hl,bc
  154.         ld a,l
  155.         srl h
  156. noloopinmusic
  157.         rra
  158.         adc a,b
  159.         call setprogressdelta
  160. ;make title avaialable
  161.         ld hl,MUSICTITLE
  162.         ld (MUSICTITLEADDR),hl
  163. ;null terminate string
  164.         xor a
  165.         ld (MUSICTITLE+50),a
  166. ;init progress vars
  167.         ld (lastplaypos),a
  168.         ld (loopcounter),a
  169.         ld hl,0
  170.         ld (playposacc),hl
  171.         ret
  172.  
  173. musicunload
  174.         jp stop_music
  175.  
  176. musicplay
  177. ;out: zf=0 if still playing, zf=1 otherwise
  178.         ld a,(play_busy)
  179.         or a
  180.         ret z
  181.         in a,(MOON_STAT)
  182.         rlca
  183.         jr nc,$-3
  184.         call play_int
  185. ;update progress
  186. lastplaypos=$+1
  187.         ld b,0
  188.         ld a,(play_pos)
  189.         ld (lastplaypos),a
  190.         sub b
  191.         jr z,playposunchanged
  192.         jr nc,loopwasnotencountered
  193.         ld hl,xleng
  194.         add a,(hl)
  195.         ld hl,xloop
  196.         sub (hl)
  197.         ld hl,loopcounter
  198.         inc (hl)
  199. loopwasnotencountered
  200. playposacc=$+1
  201.         ld hl,0
  202.         ld c,a
  203.         ld b,0
  204.         add hl,bc
  205.         ld (playposacc),hl
  206.         ld a,l
  207.         srl h
  208.         rra
  209.         call updateprogress
  210. playposunchanged
  211.         ld a,(play_busy)
  212.         or a
  213.         ret z
  214. loopcounter=$+1
  215.         ld a,0
  216.         cp 2 ;repeat the loop once
  217.         sbc a,a
  218.         ret
  219.  
  220. strcopy_hltode
  221.         ld a,(hl)
  222.         ld (de),a
  223.         or a
  224.         ret z
  225.         inc hl
  226.         inc de
  227.         jr strcopy_hltode
  228.  
  229. ;c = character
  230. ;hl = poi to filename in string
  231. ;out: de = after last dot or start
  232. findlastchar
  233.         ld d,h
  234.         ld e,l ;de = after last char
  235. findlastchar0
  236.         ld a,(hl)
  237.         inc hl
  238.         or a
  239.         ret z
  240.         cp c
  241.         jr nz,findlastchar0
  242.         jr findlastchar
  243.  
  244. load_file
  245.         push de
  246.         push ix
  247.         call readstream_file
  248.         pop ix
  249.         pop de
  250.         ret
  251.  
  252. selbank_FE
  253.         SETPG8000
  254.         ret
  255.  
  256.         include "../_sdk/file.asm"
  257.         include "common/opl4.asm"
  258.         include "mbwave/basic.asm"
  259.         include "progress.asm"
  260.  
  261. initokstr
  262.         db "OK\r\n",0
  263. nodevicestr
  264.         db "no device!\r\n",0
  265. mwknone
  266.         db "NONE    "
  267. playernamestr
  268.         db "Moonblaster Wave Replayer",0
  269. end
  270.  
  271.         savebin "mwm.bin",begin,end-begin
  272.