?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ; FT2-compatible .mod player for MoonSound
  2.  
  3.         DEVICE ZXSPECTRUM128
  4.         include "../_sdk/sys_h.asm"
  5.         include "playerdefs.asm"
  6.  
  7. TITLELENGTH = 64
  8. MEMORYSTREAMMAXPAGES = 20
  9.  
  10.         org PLAYERSTART
  11.  
  12. begin   PLAYERHEADER
  13.  
  14. isfilesupported
  15. ;cde = file extension
  16. ;out: zf=1 if this player can handle the file and the sound hardware is available, zf=0 otherwise
  17. modsupported=$+1
  18.         ld a,'m'
  19.         cp c
  20.         ret nz
  21.         ld a,'o'
  22.         cp d
  23.         ret nz
  24.         ld a,'d'
  25.         cp e
  26.         ret nz
  27.         ld hl,0
  28.         ld (MUSICTITLEADDR),hl
  29.         ld hl,musicprogress+1
  30.         ld (MUSICPROGRESSADDR),hl
  31.         jp initprogress
  32.  
  33. playerinit
  34. ;hl = GPSETTINGS
  35. ;a = player page
  36. ;out: zf=1 if init is successful, hl=init message
  37.         ld a,(hl)
  38.         ld (modfilebufferpage),a
  39.         call setdefaultpanning
  40.         ld ix,modplayer
  41.         call opl4initwave
  42.         jr nz,.error
  43. ;init period lookup
  44.         OS_NEWPAGE
  45.         or a
  46.         ld hl,outofmemorystr
  47.         jr nz,.error
  48.         ld a,e
  49.         ld (modperiodlookuppage),a
  50.         SETPGC000
  51. ;       call modinitperiodlookup
  52. ;load the table from disk, modinitperiodlookup is very slow on ATM2
  53.         ld hl,modperiodopl4
  54.         ld de,0xc000
  55.         ld bc,modperiodopl4_end-modperiodopl4
  56.         ldir
  57.         ld hl,initokstr
  58.         xor a
  59.         ret
  60. .error
  61.         ld a,255
  62.         ld (modsupported),a ;writes 255 disabling the extension
  63.         ret
  64.  
  65. setdefaultpanning
  66. ;hl = GPSETTINGS
  67.         push hl
  68.         pop ix
  69.         ld de,(ix+GPSETTINGS.moonmoddefaultpanning)
  70.         ld a,d
  71.         or e
  72.         ret z
  73.         ld b,4
  74.         ld hl,moddefaultpanning
  75. .setpanningloop
  76.         ld a,(de)
  77.         sub 'A'
  78.         jr nc,$+4
  79.         add a,'A'-'0'-10
  80.         add a,10
  81.         and 15
  82.         ld (hl),a
  83.         inc hl
  84.         inc de
  85.         djnz .setpanningloop
  86.         ret
  87.  
  88. playerdeinit
  89. modperiodlookuppage=$+1
  90.         ld e,0
  91.         OS_DELPAGE
  92.         ret
  93.  
  94. musicload
  95. ;cde = file extension
  96. ;hl = input file name
  97. ;out: zf=1 if the file is ready for playing, zf=0 otherwise
  98.         ex de,hl
  99.         call modload
  100.         ret nz
  101.         ld a,(modinfo.songlength)
  102.         call setprogressdelta
  103.         ld hl,titlestr
  104.         ld (MUSICTITLEADDR),hl
  105.         ld de,0xc000
  106.         ld b,TITLELENGTH+1
  107. .copytitleloop
  108.         ld a,(de)
  109.         ld (hl),a
  110.         inc de
  111.         inc hl
  112.         dec b
  113.         or a
  114.         jr nz,.copytitleloop
  115.         dec hl
  116. .filltitleloop
  117.         ld (hl),' '
  118.         inc hl
  119.         djnz .filltitleloop
  120.         ld (hl),0
  121.         xor a
  122.         ld (currentposition),a
  123.         ret
  124.  
  125. musicunload
  126.         jp modunload
  127.  
  128. musicplay
  129. ;out: zf=0 if still playing, zf=1 otherwise
  130.         call modplay
  131.         ld a,(modplayer.patterntableindex)
  132.         call updateprogress
  133. ;check if the position is increasing monotonically
  134.         ld a,(modplayer.patterntableindex)
  135.         ld hl,currentposition
  136.         cp (hl)
  137.         ld (hl),a
  138.         ccf
  139.         sbc a
  140.         ret
  141.  
  142.         include "../_sdk/file.asm"
  143.         include "common/memorystream.asm"
  144.         include "common/opl4utils.asm"
  145.         include "common/muldiv.asm"
  146.         include "moonmod/mod.asm"
  147.         include "progress.asm"
  148.  
  149. playernamestr
  150.         db "MoonSound MOD Player",0
  151. outofmemorystr
  152.         db "Out of memory!",0
  153.  
  154. modinfo MODINFO
  155. modwaveheaderbuffer = $
  156. modplayer MODPLAYER
  157. titlestr ds TITLELENGTH+1
  158. currentposition ds 1
  159. modfilebufferpage ds 1
  160.  
  161. modperiodopl4
  162.         incbin "moonmod/modperiodopl4.bin"
  163. modperiodopl4_end
  164. end
  165.  
  166.         org MODHEADERADDR
  167. modheader MODHEADER
  168.  
  169.         assert MODWAVEHEADERBUFFERSIZE <= MODPLAYER
  170.  
  171.         savebin "moonmod.bin",begin,end-begin
  172.