?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ; ProTracker modules player for AY8910/TurboSound
  2.  
  3.         DEVICE ZXSPECTRUM128
  4.         include "../_sdk/sys_h.asm"
  5.         include "playerdefs.asm"
  6.  
  7. MDLADDR = 0x8000
  8. TITLELENGTH = 64
  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.         ld a,c
  18.         cp 'p'
  19.         ret nz
  20.         ld a,d
  21.         cp 't'
  22.         ret nz
  23.         ld a,e
  24.         cp '2'
  25.         jr nz,checkpt3
  26. ;prepare local variables
  27.         ld hl,0
  28.         ld (MUSICTITLEADDR),hl
  29.         ld (MUSICPROGRESSADDR),hl
  30.         ret
  31. checkpt3
  32.         cp '3'
  33.         ret nz
  34. ;prepare local variables
  35.         ld hl,0
  36.         ld (MUSICTITLEADDR),hl
  37.         ld hl,musicprogress+1
  38.         ld (MUSICPROGRESSADDR),hl
  39.         jp initprogress
  40.  
  41. playerinit
  42. ;hl = GPSETTINGS
  43. ;a = player page
  44. ;out: zf=1 if init is successful, hl=init message
  45.         ld (playerpage),a
  46.         ld a,(hl)
  47.         ld (page8000),a
  48.         inc hl
  49.         ld a,(hl)
  50.         ld (pageC000),a
  51.  
  52.         ld hl,initokstr
  53.         xor a
  54.         ret
  55.  
  56. playerdeinit
  57.         ret
  58.  
  59. musicload
  60. ;cde = file extension
  61. ;hl = input file name
  62. ;out: zf=1 if the file is ready for playing, zf=0 otherwise
  63.         ex de,hl
  64.         call openstream_file
  65.         or a
  66.         ret nz
  67.  
  68. page8000=$+1
  69.         ld a,0
  70.         SETPG8000
  71. pageC000=$+1
  72.         ld a,0
  73.         SETPGC000
  74.  
  75.         ld de,MDLADDR
  76.         ld hl,de
  77.         call readstream_file
  78.         push hl
  79.  
  80.         call closestream_file
  81.  
  82.         pop ix
  83.         call getconfig
  84.         ld (SETUP),a
  85.  
  86.         ld de,MDLADDR
  87.         add hl,de
  88.         ex hl,de
  89.         call INIT
  90.  
  91. playerpage=$+1
  92.         ld a,0
  93.         ld hl,PLAY
  94.         OS_SETMUSIC
  95.  
  96.         xor a
  97.         ret
  98.  
  99. musicunload
  100.         ld a,(playerpage)
  101.         ld hl,play_reter
  102.         OS_SETMUSIC
  103.  
  104.         jp MUTE
  105.  
  106. play_reter
  107.         ret
  108.  
  109. musicplay
  110. ;out: zf=0 if still playing, zf=1 otherwise
  111.         YIELD
  112.         YIELD
  113.         YIELD
  114.         YIELD
  115.         YIELD
  116.  
  117.         ld a,(SETUP)
  118.         and 2
  119.         ld a,(VARS1+VRS.CurPos)
  120.         call z,updateprogress
  121.  
  122.         ld a,(SETUP)
  123.         cpl
  124.         and 128
  125.         ret
  126.  
  127. findts
  128. ;ix = file size
  129. ;out: zf = 1 if TS data is found, hl = offset to the second module if available
  130.         ld de,MDLADDR
  131.         add ix,de ;past-the-end address of the data buffer
  132.  
  133.         ld a,'0'
  134.         cp (ix-4)
  135.         ret nz
  136.         ld a,'2'
  137.         cp (ix-3)
  138.         ret nz
  139.         ld a,'T'
  140.         cp (ix-2)
  141.         ret nz
  142.         ld a,'S'
  143.         cp (ix-1)
  144.         ret nz
  145.  
  146.         ld hl,(ix-12)
  147.         ret
  148.  
  149. getconfig
  150. ;ix = file size
  151. ;out: a = player config bits, hl = offset to the second module if available
  152.         ld a,(MDLADDR)
  153.         cp 'V'
  154.         jr z,.ispt3
  155.         cp 'P'
  156.         jr z,.ispt3
  157.         ld a,%00000011 ;PT2
  158.         ret
  159. .ispt3
  160.         ld a,(MDLADDR+101)
  161.         call setprogressdelta
  162. ;set title
  163.         ld hl,titlestr
  164.         ld (MUSICTITLEADDR),hl
  165.         ld de,titlestr+1
  166.         ld bc,TITLELENGTH-1
  167.         ld (hl),' '
  168.         ldir
  169.         xor a
  170.         ld (de),a
  171.         ld hl,titlestr-1
  172.         ld de,MDLADDR+30
  173.         ld bc,68*256+TITLELENGTH
  174. .copytitleloop
  175.         ld a,(de)
  176.         inc de
  177.         cp ' '
  178.         jr nz,$+5
  179.         cp (hl)
  180.         jr z,$+7
  181.         inc hl
  182.         ld (hl),a
  183.         dec c
  184.         jr z,$+4
  185.         djnz .copytitleloop
  186.         call findts
  187.         ld a,%00010001 ;2xPT3
  188.         ret z
  189.         ld a,%00100001 ;PT3
  190.         ret
  191.  
  192.         include "../_sdk/file.asm"
  193.         include "ptsplay/ptsplay.asm"
  194.         include "progress.asm"
  195.  
  196. initokstr
  197.         db "OK\r\n",0
  198. playernamestr
  199.         db "Universal PT2'n'PT3 Turbo Sound",0
  200. end
  201.  
  202. titlestr
  203.         ds TITLELENGTH+1
  204.  
  205.         savebin "pt3.bin",begin,end-begin
  206.