?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.         include "playerdefs.asm"
  4.  
  5. NUM_PLAYERS = 4
  6. SFN_SIZE = 13
  7. FILE_DATA_SIZE = 52 ;keep in sync with getfiledataoffset
  8. FILE_DISPLAY_INFO_OFFSET = 0
  9. FILE_DISPLAY_INFO_SIZE = 38
  10. FILE_NAME_OFFSET = FILE_DISPLAY_INFO_OFFSET+FILE_DISPLAY_INFO_SIZE
  11. FILE_NAME_SIZE = SFN_SIZE
  12. FILE_ATTRIB_OFFSET = FILE_NAME_OFFSET+FILE_NAME_SIZE
  13. FILE_ATTRIB_SIZE = 1
  14. BROWSER_FILE_COUNT=180
  15. PLAYLIST_FILE_COUNT=40
  16. PANELCOLOR = 0x4f
  17. CURSORCOLOR = 0x28
  18. PANELFILECOLOR = 0x0f
  19. PANELDIRCOLOR = 0x4f
  20. PANELDRIVECOLOR = 0x4b
  21. FILE_LINE_COUNT = 22
  22. FILES_WINDOW_X = 0
  23. FILE_ATTRIB_MUSIC = 255
  24. FILE_ATTRIB_PARENT_DIR = 0
  25. FILE_ATTRIB_DRIVE = 1
  26. FILE_ATTRIB_FOLDER = 2
  27. PLAYLIST_VERSION = 1
  28.  
  29.         org PROGSTART
  30.  
  31. mainbegin
  32.         ld sp,0x4000
  33.         OS_HIDEFROMPARENT
  34.         ld e,6 ;textmode
  35.         OS_SETGFX
  36.         ld e,7
  37.         OS_CLS
  38.  
  39.         OS_GETMAINPAGES ;out: d,e,h,l=pages in 0000,4000,8000,c000, c=flags, b=id
  40.         ld (sharedpages),hl
  41.         ld a,e
  42.         ld (sharedpages+2),a
  43.         ld d,b
  44.         call closeexistingplayer
  45.  
  46.         ld de,currentfolder
  47.         OS_GETPATH
  48.         ld hl,(currentfolder+2)
  49.         ld a,l
  50.         xor '/'
  51.         or h
  52.         jr nz,$+5
  53.         ld (currentfolder+2),a
  54.  
  55.         OS_SETSYSDRV
  56.         call loadplayers
  57.         ld hl,playersloaderrorstr
  58.         jp nz,printerrorandexit
  59.  
  60.         ld ix,browserpanel
  61.         call clearpanel
  62.         ld ix,playlistpanel
  63.         call clearpanel
  64.         or 255 ;set zf=0
  65.         call setcurrentpanel
  66.  
  67.         ld de,defaultplaylistfilename
  68.         call loadplaylist
  69.  
  70.         ld hl,COMMANDLINE
  71.         call skipword_hl
  72.         call skipspaces_hl
  73.         ld a,(hl)
  74.         or a
  75.         call nz,setcurrentfolder
  76.         push hl
  77.         call changetocurrentfolder
  78.         pop de
  79.         ld hl,chdirfailedstr
  80.         jp nz,printerrorandexit
  81.         push de
  82.         call createfileslist
  83.         pop de
  84.         ld a,(de)
  85.         or a
  86.         call nz,findfile
  87.         ld (browserpanel.currentfileindex),a
  88.         push af
  89.         call drawui
  90.         pop af
  91.         call c,startplaying
  92.  
  93. playloop
  94. isplaying=$+1
  95.         ld a,0
  96.         or a
  97.         jr z,checkmsgs
  98.         call musicplay
  99.         call z,playnextfile
  100.         call updateprogressbar
  101.  
  102. checkmsgs
  103.         ld a,(COMMANDLINE)
  104.         or a
  105.         ld a,key_esc
  106.         jr z,closeplayer
  107.         OS_GETKEY
  108.         call tolower
  109. closeplayer
  110.         ld hl,playloop
  111.         push hl
  112. currentmsgtable=$+1
  113.         ld hl,mainmsgtable
  114.         ld de,3
  115.         ld b,(hl)
  116.         inc hl
  117. checkmsgloop
  118.         cp (hl)
  119.         jr z,processmsg
  120.         add hl,de
  121.         djnz checkmsgloop
  122.         ret
  123.  
  124. processmsg
  125.         inc hl
  126.         ld e,(hl)
  127.         inc hl
  128.         ld d,(hl)
  129.         ex de,hl
  130.         jp (hl)
  131.  
  132. printerrorandexit
  133.         call print_hl
  134.         ld hl,pressanykeystr
  135.         call print_hl
  136.         YIELDGETKEYLOOP
  137.         QUIT
  138.  
  139. mainmsgtable
  140.         db (mainmsghandlers_end-mainmsghandlers_start)/3
  141. mainmsghandlers_start
  142.         db 0             : dw nokey
  143.         db key_redraw    : dw redraw
  144.         db key_up        : dw goprevfile
  145.         db key_down      : dw gonextfile
  146.         db key_enter     : dw startplaying
  147.         db key_esc       : dw exitplayer
  148.         db ' '           : dw addtoplaylist
  149.         db key_tab       : dw switchpanels
  150.         db key_backspace : dw clearplaylist
  151.         db key_home      : dw gotop
  152.         db key_end       : dw golastfile
  153.         db key_left      : dw gopageup
  154.         db key_right     : dw gopagedown
  155.         db key_pgup      : dw gopageup
  156.         db key_pgdown    : dw gopagedown
  157.         db 's'           : dw onhotkeyS
  158. mainmsghandlers_end
  159.  
  160. playmsgtable
  161.         db (playmsghandlers_end-playmsghandlers_start)/3
  162. playmsghandlers_start
  163.         db key_redraw    : dw redraw
  164.         db ' '           : dw playnextfile
  165.         db key_esc       : dw stopplaying
  166. playmsghandlers_end
  167.  
  168. nokey
  169.         YIELD
  170.         ret
  171.  
  172. gotop
  173.         ld ix,(currentpaneladdr)
  174.         xor a
  175.         ld (ix+PANEL.currentfileindex),a
  176.         ld (ix+PANEL.firstfiletoshow),a
  177.         jp drawcurrentpanelfilelist
  178.  
  179. clearplaylist
  180.         ld ix,playlistpanel
  181.         call clearpanel
  182.         jp drawplaylistwindow
  183.  
  184. playnextfile
  185.         ld ix,(currentpaneladdr)
  186.         call setnextfileindex
  187.         jp c,startplaying
  188.         xor a
  189.         ld (ix+PANEL.currentfileindex),a
  190.         ld (ix+PANEL.firstfiletoshow),a
  191.         ld hl,(currentpaneladdr)
  192.         ld de,PANEL.fileslist+FILE_ATTRIB_OFFSET
  193.         add hl,de
  194.         ld e,FILE_DATA_SIZE
  195. .wraploop
  196.         ld a,(hl)
  197.         cp FILE_ATTRIB_MUSIC
  198.         jp z,startplaying
  199.         add hl,de
  200.         inc (ix+PANEL.currentfileindex)
  201.         jr .wraploop
  202.  
  203. switchpanels
  204.         ld a,(browserpanel.isinactive)
  205.         or a
  206. setcurrentpanel
  207.         ld a,255
  208.         ld (browserpanel.isinactive),a
  209.         ld (playlistpanel.isinactive),a
  210.         call nz,getbrowserpanelparams
  211.         call z,getplaylistpanelparams
  212.         ld (currentpaneladdr),ix
  213.         ld (currentpanelpos),de
  214.         ld (ix+PANEL.isinactive),0
  215.         call drawbrowserfileslist
  216.         jp drawplaylistfileslist
  217.  
  218. addtoplaylist
  219.         ld a,(browserpanel.isinactive)
  220.         or a
  221.         jr nz,removefromplaylist
  222.         ld hl,currentfolder
  223.         ld de,fullpathbuffer
  224.         call strcopy_hltode
  225.         ld a,'/'
  226.         ld (de),a
  227.         inc de
  228.         push de
  229.         ld a,(browserpanel.currentfileindex)
  230.         call getfiledataoffset
  231.         ld de,browserpanel.fileslist+FILE_ATTRIB_OFFSET
  232.         add hl,de
  233.         ld a,(hl)
  234.         ld de,FILE_NAME_OFFSET-FILE_ATTRIB_OFFSET
  235.         add hl,de
  236.         pop de
  237.         cp FILE_ATTRIB_MUSIC
  238.         ret nz
  239.         call strcopy_hltode
  240.         ld hl,fullpathbuffer+FILE_DATA_SIZE-2
  241.         sub hl,de
  242.         ret c
  243.         jr z,skippadding
  244.         ld bc,hl
  245.         ld hl,de
  246.         inc de
  247.         ldir
  248.         dec de
  249. skippadding
  250.         inc de
  251.         ld a,255
  252.         ld (de),a
  253.         ld hl,playlistpanel.filecount
  254.         ld a,(hl)
  255.         cp PLAYLIST_FILE_COUNT
  256.         ret nc
  257.         inc (hl)
  258.         call getfiledataoffset
  259.         ld de,playlistpanel.fileslist
  260.         add hl,de
  261.         ex de,hl
  262.         ld hl,fullpathbuffer
  263.         ld bc,FILE_DATA_SIZE
  264.         ldir
  265.         jp drawplaylistfileslist
  266.  
  267. removefromplaylist
  268.         ld a,(playlistpanel.filecount)
  269.         or a
  270.         ret z
  271.         dec a
  272.         jp z,clearplaylist
  273.         ld (playlistpanel.filecount),a
  274.         ld b,a
  275.         ld a,(playlistpanel.currentfileindex)
  276.         cp b
  277.         jr nz,.movetail
  278.         dec a
  279.         ld (playlistpanel.currentfileindex),a
  280.         jp drawplaylistwindow
  281. .movetail
  282.         call getfiledataoffset
  283.         ld de,playlistpanel.fileslist
  284.         add hl,de
  285.         ex de,hl
  286.         ld hl,playlistpanel.fileslist+FILE_DATA_SIZE*(PLAYLIST_FILE_COUNT-1)
  287.         sub hl,de
  288.         ld bc,hl
  289.         ld hl,FILE_DATA_SIZE
  290.         add hl,de
  291.         ldir
  292.         jp drawplaylistwindow
  293.  
  294. exitplayer
  295.         pop hl
  296.         call stopplaying
  297.         ld hl,playerpages
  298.         ld b,NUM_PLAYERS
  299. playerdeinitloop
  300.         push bc
  301.         push hl
  302.         ld a,(hl)
  303.         SETPG4000
  304.         call playerdeinit
  305.         pop hl
  306.         pop bc
  307.         inc hl
  308.         djnz playerdeinitloop
  309. ;save playlist
  310.         ld a,255
  311.         ld (playlistpanel.isinactive),a
  312.         OS_SETSYSDRV
  313.         ld de,defaultplaylistfilename
  314.         call saveplaylist
  315.         QUIT
  316.  
  317. saveplaylist
  318. ;de = filename
  319.         push de
  320.         call openstream_file
  321.         pop de
  322.         or a
  323.         jr z,.openedfile
  324.         OS_CREATEHANDLE
  325.         or a
  326.         ret nz
  327.         ld a,b
  328.         ld (filehandle),a
  329. .openedfile
  330.         ld a,(filehandle)
  331.         ld b,a
  332.         ld de,playlistdatastart
  333.         ld hl,playlistdatasize
  334.         OS_WRITEHANDLE
  335.         call closestream_file
  336.         xor a
  337.         ret
  338.  
  339. onhotkeyS
  340.         ld de,playlistfilename
  341.         call saveplaylist
  342.         ld de,playlistfilename
  343.         jp createfilelistandchangesel
  344.  
  345. startplaying
  346.         call stopplaying
  347.         ld ix,(currentpaneladdr)
  348.         ld a,(ix+PANEL.filecount)
  349.         or a
  350.         ret z
  351.         ld a,(ix+PANEL.currentfileindex)
  352.         call getfiledataoffset
  353.         ld a,ixl
  354.         add PANEL.fileslist+FILE_ATTRIB_OFFSET
  355.         ld e,a
  356.         adc a,ixh
  357.         sub e
  358.         ld d,a
  359.         add hl,de
  360.         ld a,(hl)
  361.         cp FILE_ATTRIB_PARENT_DIR
  362.         jp z,changetoparentdir
  363.         cp FILE_ATTRIB_FOLDER
  364.         jp z,changetofolder
  365.         cp FILE_ATTRIB_DRIVE
  366.         jr z,changedrive
  367.         cp FILE_ATTRIB_MUSIC
  368.         ret nz
  369.         ld a,(browserpanel.isinactive)
  370.         or a
  371.         ld de,FILE_NAME_OFFSET-FILE_ATTRIB_OFFSET
  372.         jr z,$+5
  373.         ld de,FILE_DISPLAY_INFO_OFFSET-FILE_ATTRIB_OFFSET
  374.         add hl,de
  375.         ld (.filename),hl
  376.         call getfileextension
  377.         ld (.filext2),de
  378.         ld (.filext1),bc
  379.         call isfileplaylist
  380.         jp z,.loadplaylist
  381.         call findsupportedplayer
  382.         ret nz
  383.         call drawplayerwindow
  384. .filext1=$+1
  385.         ld bc,0
  386. .filext2=$+1
  387.         ld de,0
  388. .filename=$+1
  389.         ld hl,0
  390.         call musicload
  391.         jp nz,drawui
  392.         ld hl,playmsgtable
  393.         ld (currentmsgtable),hl
  394.         ld a,1
  395.         ld (isplaying),a
  396.         call drawsongtitle
  397.         jp drawprogress
  398. .loadplaylist
  399.         ld de,(.filename)
  400.         call loadplaylist
  401.         call drawplaylistwindow
  402.         xor a
  403.         call setcurrentpanel
  404.         jp startplaying
  405.  
  406. changedrive
  407.         ld de,FILE_NAME_OFFSET-FILE_ATTRIB_OFFSET
  408.         add hl,de
  409.         push hl
  410.         ld de,(currentfolder)
  411.         push de
  412.         ld de,currentfolder
  413.         ldi
  414.         ldi
  415.         call changetocurrentfolder
  416.         pop hl
  417.         pop de
  418.         jp z,createfilelistandchangesel
  419.         ld (currentfolder),hl
  420.         ret
  421.  
  422. changetoparentdir
  423.         ld hl,currentfolder
  424.         ld c,'/'
  425.         call findlastchar ;out: de = after last slash or start
  426.         push de
  427.         dec de
  428.         xor a
  429.         ld (de),a
  430.         call changetocurrentfolder
  431.         pop de
  432.         jp createfilelistandchangesel
  433.  
  434. createfilelistandchangesel
  435. ;de = selection filename
  436.         push de
  437.         call createfileslist
  438.         pop de
  439.         call findfile
  440.         ld (browserpanel.currentfileindex),a
  441.         sub FILE_LINE_COUNT-1
  442.         jp c,drawbrowserwindow
  443.         ld hl,browserpanel.firstfiletoshow
  444.         cp (hl)
  445.         jp c,drawbrowserwindow
  446.         ld (hl),a
  447.         jp drawbrowserwindow
  448.  
  449. changetofolder
  450.         ld de,FILE_NAME_OFFSET-FILE_ATTRIB_OFFSET
  451.         add hl,de
  452.         ld de,currentfolder-1
  453. .findzeroloop
  454.         inc de
  455.         ld a,(de)
  456.         or a
  457.         jr nz,.findzeroloop
  458.         ld a,'/'
  459.         ld (de),a
  460.         inc de
  461.         call strcopy_hltode
  462.         call changetocurrentfolder
  463.         call createfileslist
  464.         xor a
  465.         ld (browserpanel.currentfileindex),a
  466.         jp drawbrowserwindow
  467.  
  468. stopplaying
  469.         ld a,(isplaying)
  470.         or a
  471.         ret z
  472.         call musicunload
  473.         ld hl,mainmsgtable
  474.         ld (currentmsgtable),hl
  475.         xor a
  476.         ld (isplaying),a
  477.         jp drawui
  478.  
  479. setnextfileindex
  480. ;ix = current panel
  481. ;out: cf=0 if at the end of file list, c1=1 otherwise
  482.         ld a,(ix+PANEL.currentfileindex)
  483.         inc a
  484.         cp (ix+PANEL.filecount)
  485.         ret nc
  486.         ld (ix+PANEL.currentfileindex),a
  487.         sub FILE_LINE_COUNT-1
  488.         ret c
  489.         cp (ix+PANEL.firstfiletoshow)
  490.         ret c
  491.         ld (ix+PANEL.firstfiletoshow),a
  492.         scf
  493.         ret
  494.  
  495. golastfile
  496.         ld ix,(currentpaneladdr)
  497.         call setnextfileindex
  498.         jr c,$-3
  499.         jp drawcurrentpanelfilelist
  500.  
  501. gopagedown     
  502.         ld ix,(currentpaneladdr)
  503.         ld b,FILE_LINE_COUNT
  504.         call setnextfileindex
  505.         djnz $-3
  506.         jp drawcurrentpanelfilelist
  507.  
  508. gonextfile
  509.         ld ix,(currentpaneladdr)
  510.         call setnextfileindex
  511.         ret nc
  512.         jp drawcurrentpanelfilelist
  513.  
  514. setprevfileindex
  515. ;ix = current panel
  516.         ld a,(ix+PANEL.currentfileindex)
  517.         or a
  518.         ret z
  519.         dec a
  520.         ld (ix+PANEL.currentfileindex),a
  521.         cp (ix+PANEL.firstfiletoshow)
  522.         ret nc
  523.         ld (ix+PANEL.firstfiletoshow),a
  524.         ret
  525.  
  526. goprevfile
  527.         ld ix,(currentpaneladdr)
  528.         call setprevfileindex
  529.         jp drawcurrentpanelfilelist
  530.  
  531. gopageup
  532.         ld ix,(currentpaneladdr)
  533.         ld b,FILE_LINE_COUNT
  534.         call setprevfileindex
  535.         djnz $-3
  536.         jp drawcurrentpanelfilelist
  537.  
  538. loadplaylist
  539. ;de = filename
  540.         call openstream_file
  541.         or a
  542.         jr nz,initemptyplaylist
  543.         ld de,playlistdatastart
  544.         ld hl,playlistdatasize
  545.         call readstream_file
  546.         call closestream_file
  547.         ld de,PLAYLIST_VERSION
  548.         ld hl,(playlistpanelversion)
  549.         sub hl,de
  550.         ret z
  551. initemptyplaylist
  552.         ld hl,PLAYLIST_VERSION
  553.         ld (playlistpanelversion),hl
  554.         ld ix,playlistpanel
  555.         jr clearpanel
  556.  
  557. clearpanel
  558. ;ix = panel
  559.         xor a
  560.         ld (ix+PANEL.filecount),a
  561.         ld (ix+PANEL.currentfileindex),a
  562.         ld (ix+PANEL.firstfiletoshow),a
  563.         ret
  564.  
  565. changetocurrentfolder
  566. ;out: zf=1 if succeeded, zf=0 otherwise
  567.         ld hl,(currentfolder+2)
  568.         push hl
  569.         ld a,l
  570.         or a
  571.         jr nz,$+8
  572.         ld hl,'/'
  573.         ld (currentfolder+2),hl
  574.         ld de,currentfolder
  575.         OS_CHDIR
  576.         pop hl
  577.         ld (currentfolder+2),hl
  578.         or a
  579.         ret
  580.  
  581. setcurrentfolder
  582. ;out: hl = file name only
  583.         push hl
  584.         ld c,'/'
  585.         call findlastchar ;out: de = after last slash or start
  586.         pop bc
  587.         ld hl,de
  588.         sub hl,bc
  589.         ex hl,de
  590.         ret z
  591. ;copy file path
  592.         ld hl,bc
  593.         ld bc,de
  594.         ld de,currentfolder
  595.         ldir
  596.         dec de
  597.         xor a
  598.         ld (de),a
  599.         ret
  600.  
  601. findfile
  602. ;de = file name
  603. ;out: a = file index, cf=1 if file was found
  604.         ld a,(browserpanel.filecount)
  605.         or a
  606.         ret z
  607.         ld b,a
  608.         ld c,0
  609.         ld hl,browserpanel.fileslist+FILE_NAME_OFFSET
  610. .searchloop
  611.         push bc
  612.         push de
  613.         push hl
  614.         call stricmp
  615.         pop hl
  616.         ld de,FILE_DATA_SIZE
  617.         add hl,de
  618.         pop de
  619.         pop bc
  620.         scf
  621.         ld a,c
  622.         ret z
  623.         inc c
  624.         djnz .searchloop
  625.         xor a
  626.         ret
  627.  
  628. stricmp
  629. ;hl = string1 addr
  630. ;de = string2 addr
  631. ;out: zf=1 if equal
  632.         ld a,(hl)
  633.         call tolower
  634.         ld c,a
  635.         ld a,(de)
  636.         call tolower
  637.         ld b,a
  638.         or c
  639.         ret z
  640.         ld a,b
  641.         cp c
  642.         ret nz
  643.         cp 1
  644.         ret c
  645.         inc hl
  646.         inc de
  647.         jr stricmp
  648.  
  649. getmusicprogress
  650. ;out: zf=0 and a=progress if progress is available, zf=1 and a=255 otherwise
  651.         ld hl,(MUSICPROGRESSADDR)
  652.         ld a,l
  653.         or h
  654.         ld a,255
  655.         ret z
  656.         ld a,(hl)
  657.         ret
  658.  
  659. drawplayerwindow
  660.         ld de,PANELCOLOR
  661.         OS_SETCOLOR
  662.         call getmusicprogress
  663.         ld (musicprogress),a
  664.         ld de,8*256+6
  665.         ld bc,66*256+4
  666.         ld a,8
  667.         jr nz,$+10
  668.         ld de,8*256+12
  669.         ld bc,54*256+3
  670.         ld a,14
  671.         ld (playerwindowtitlepos),a
  672.         ld (songtitlepos),a
  673.         call drawwindow
  674.         ld de,CURSORCOLOR
  675.         OS_SETCOLOR
  676. playerwindowtitlepos=$+1
  677.         ld de,8*256+0
  678.         OS_SETXY
  679.         ld hl,playingstr
  680.         call print_hl
  681.         call drawsongtitle
  682.         ld a,(isplaying)
  683.         or a
  684.         call nz,drawprogress
  685.         ret
  686.  
  687. drawsongtitle
  688.         ld de,PANELDIRCOLOR
  689.         OS_SETCOLOR
  690. songtitlepos=$+1
  691.         ld de,10*256+0
  692.         OS_SETXY
  693.         ld hl,(MUSICTITLEADDR)
  694.         ld a,l
  695.         or h
  696.         jp nz,print_hl
  697.         ld ix,(currentpaneladdr)
  698.         ld a,(ix+PANEL.currentfileindex)
  699.         call getfiledataoffset
  700.         ld a,ixl
  701.         add PANEL.fileslist+FILE_DISPLAY_INFO_OFFSET
  702.         ld e,a
  703.         adc a,ixh
  704.         sub e
  705.         ld d,a
  706.         add hl,de
  707.         jp print_hl
  708.  
  709. drawprogress
  710.         ld a,(musicprogress)
  711.         cp 255
  712.         ret z
  713.         ld de,11*256+8
  714.         OS_SETXY
  715.         ld a,(musicprogress)
  716.         ld c,a
  717.         or a
  718.         jr z,.drawremaining
  719.         ld b,a
  720. .drawdoneloop
  721.         push bc
  722.         ld a,178
  723.         PRCHAR
  724.         pop bc
  725.         djnz .drawdoneloop
  726. .drawremaining
  727.         ld a,64
  728.         sub c
  729.         ret z
  730.         ld b,a
  731. .drawremainingloop
  732.         push bc
  733.         ld a,176
  734.         PRCHAR
  735.         pop bc
  736.         djnz .drawremainingloop
  737.         ret
  738.  
  739. updateprogressbar
  740.         call getmusicprogress
  741.         ret z
  742.         ld d,a
  743.         ld hl,musicprogress
  744.         ld e,(hl)
  745.         sub e
  746.         ret z
  747.         ld (hl),d
  748.         push af
  749.         ld hl,11*256+8
  750.         ld d,0
  751.         add hl,de
  752.         ex de,hl
  753.         OS_SETXY
  754.         pop bc
  755. .drawloop
  756.         push bc
  757.         ld a,178
  758.         PRCHAR
  759.         pop bc
  760.         djnz .drawloop
  761.         ret
  762.  
  763. drawwindowline
  764. ;d = left char
  765. ;e = right char
  766. ;c = middle char
  767. ;b = middle char count
  768.         ld a,d
  769.         push de
  770.         push bc
  771.         PRCHAR
  772.         pop bc
  773. .drawloop
  774.         push bc
  775.         ld a,c
  776.         PRCHAR
  777.         pop bc
  778.         djnz .drawloop
  779.         pop de
  780.         ld a,e
  781.         PRCHAR
  782.         ret
  783.  
  784. drawwindow
  785. ;e = left coord
  786. ;d = top coord
  787. ;b = client area width
  788. ;c = client area height
  789. ;top line
  790.         push de
  791.         push bc
  792.         OS_SETXY
  793.         pop bc
  794.         push bc
  795.         ld de,0xc9bb
  796.         ld c,0xcd
  797.         call drawwindowline
  798.         pop bc
  799.         pop de
  800.         inc d
  801. ;client area
  802. .drawloop
  803.         push de
  804.         push bc
  805.         OS_SETXY
  806.         pop bc
  807.         push bc
  808.         ld de,0xbaba
  809.         ld c,0x20
  810.         call drawwindowline
  811.         pop bc
  812.         pop de
  813.         inc d
  814.         dec c
  815.         jr nz,.drawloop
  816. ;bottom line
  817.         push bc
  818.         OS_SETXY
  819.         pop bc
  820.         ld de,0xc8bc
  821.         ld c,0xcd
  822.         jp drawwindowline
  823.  
  824. getfiledataoffset
  825. ;a = index
  826. ;out: hl = index * FILE_DATA_SIZE
  827.         ld l,a
  828.         ld h,0
  829.         ld de,hl
  830.         add hl,hl
  831.         add hl,hl
  832.         ex de,hl
  833.         add hl,de
  834.         ex de,hl
  835.         add hl,hl
  836.         add hl,de
  837.         add hl,hl
  838.         add hl,hl
  839.         ret
  840.  
  841. getfileinfocolor
  842. ;c = file index
  843. ;hl = file data address
  844. currentfileindex=$+1
  845.         ld a,0
  846.         cp c
  847.         ld de,CURSORCOLOR
  848.         ret z
  849.         ld a,(ix+FILE_ATTRIB_OFFSET-FILE_DISPLAY_INFO_OFFSET)
  850.         cp FILE_ATTRIB_MUSIC
  851.         ld de,PANELFILECOLOR
  852.         ret z
  853.         cp FILE_ATTRIB_DRIVE
  854.         ld de,PANELDRIVECOLOR
  855.         ret z
  856. ;FILE_ATTRIB_PARENT_DIR or FILE_ATTRIB_FOLDER
  857.         ld de,PANELDIRCOLOR
  858.         ret
  859.  
  860. printfilesinfos
  861. ;ix = struct PANEL
  862. ;e = left coord
  863. ;d = top coord
  864. ;b = line count
  865. ;c = first file index
  866.         ld a,(ix+PANEL.currentfileindex)
  867.         or (ix+PANEL.isinactive)
  868.         ld (currentfileindex),a
  869.         ld a,(ix+PANEL.filecount)
  870.         ld (.currentfilecount),a
  871.         push de
  872.         ld a,c
  873.         call getfiledataoffset
  874.         ld de,ix
  875.         add hl,de
  876.         ld de,FILE_DISPLAY_INFO_OFFSET+PANEL.fileslist
  877.         add hl,de
  878.         pop de
  879. .filesloop
  880.         ld a,c
  881. .currentfilecount=$+1
  882.         cp 0
  883.         ret nc
  884.         push de
  885.         push hl
  886.         push bc
  887.         OS_SETXY
  888.         pop bc
  889.         pop ix
  890.         push bc
  891.         push ix
  892.         call getfileinfocolor
  893.         OS_SETCOLOR
  894.         pop hl
  895.         pop bc
  896.         push bc
  897.         ld b,FILE_DISPLAY_INFO_SIZE
  898. .printdisplaystringloop
  899.         push bc
  900.         push hl
  901.         ld a,(hl)
  902.         or a
  903.         jr nz,$+4
  904.         ld a,' '
  905.         PRCHAR
  906.         pop hl
  907.         pop bc
  908.         inc hl
  909.         djnz .printdisplaystringloop
  910.         ld de,FILE_DATA_SIZE-FILE_DISPLAY_INFO_SIZE
  911.         add hl,de
  912.         pop bc
  913.         pop de
  914.         inc c
  915.         inc d
  916.         djnz .filesloop
  917.         ret
  918.  
  919. getbrowserpanelparams
  920.         ld ix,browserpanel
  921.         ld de,256+1+FILES_WINDOW_X
  922.         ret
  923.  
  924. drawbrowserfileslist
  925.         call getbrowserpanelparams
  926.         ld b,FILE_LINE_COUNT
  927.         ld c,(ix+PANEL.firstfiletoshow)
  928.         jp printfilesinfos
  929.  
  930. getplaylistpanelparams
  931.         ld ix,playlistpanel
  932.         ld de,256+FILE_DISPLAY_INFO_SIZE+3+FILES_WINDOW_X
  933.         ret
  934.  
  935. drawplaylistfileslist
  936.         call getplaylistpanelparams
  937.         ld b,FILE_LINE_COUNT
  938.         ld c,(ix+PANEL.firstfiletoshow)
  939.         jp printfilesinfos
  940.  
  941. drawcurrentpanelfilelist
  942. currentpaneladdr=$+2
  943.         ld ix,0
  944. currentpanelpos=$+1
  945.         ld de,0
  946.         ld b,FILE_LINE_COUNT
  947.         ld c,(ix+PANEL.firstfiletoshow)
  948.         jp printfilesinfos
  949.  
  950. drawbrowserwindow
  951.         ld de,PANELCOLOR
  952.         OS_SETCOLOR
  953.         ld de,FILES_WINDOW_X
  954.         ld bc,FILE_DISPLAY_INFO_SIZE*256+FILE_LINE_COUNT
  955.         call drawwindow
  956.         ld de,CURSORCOLOR
  957.         OS_SETCOLOR
  958.         ld de,FILES_WINDOW_X+2
  959.         OS_SETXY
  960.         ld hl,currentfolder
  961.         call print_hl
  962.         jp drawbrowserfileslist
  963.  
  964. drawplaylistwindow
  965.         ld de,PANELCOLOR
  966.         OS_SETCOLOR
  967.         ld de,FILES_WINDOW_X+FILE_DISPLAY_INFO_SIZE+2
  968.         ld bc,FILE_DISPLAY_INFO_SIZE*256+FILE_LINE_COUNT
  969.         call drawwindow
  970.         ld de,CURSORCOLOR
  971.         OS_SETCOLOR
  972.         ld de,FILES_WINDOW_X+FILE_DISPLAY_INFO_SIZE+4
  973.         OS_SETXY
  974.         ld hl,playliststr
  975.         call print_hl
  976.         jr drawplaylistfileslist
  977.  
  978. redraw
  979.         ld e,7
  980.         OS_CLS
  981. drawui
  982.         call drawbrowserwindow
  983.         call drawplaylistwindow
  984.         ld de,0x7
  985.         OS_SETCOLOR
  986.         ld de,24*256+3
  987.         OS_SETXY
  988.         ld hl,hotkeystr
  989.         call print_hl
  990.         ld a,(isplaying)
  991.         or a
  992.         ret z
  993.         jp drawplayerwindow
  994.  
  995. skipword_hl
  996.         ld a,(hl)
  997.         or a
  998.         ret z
  999.         cp ' '
  1000.         ret z
  1001.         inc hl
  1002.         jr skipword_hl
  1003.  
  1004. skipspaces_hl
  1005.         ld a,(hl)
  1006.         cp ' '
  1007.         ret nz
  1008.         inc hl
  1009.         jr skipspaces_hl
  1010.  
  1011. print_hl
  1012.         ld a,(hl)
  1013.         or a
  1014.         ret z
  1015.         push hl
  1016.         PRCHAR
  1017.         pop hl
  1018.         inc hl
  1019.         jp print_hl
  1020.  
  1021. strcopy_hltode
  1022.         ld a,(hl)
  1023.         ld (de),a
  1024.         or a
  1025.         ret z
  1026.         inc hl
  1027.         inc de
  1028.         jr strcopy_hltode
  1029.  
  1030. ;c = character
  1031. ;hl = poi to filename in string
  1032. ;out: de = after last char or start
  1033. findlastchar
  1034.         ld d,h
  1035.         ld e,l ;de = after last char
  1036. findlastchar0
  1037.         ld a,(hl)
  1038.         inc hl
  1039.         or a
  1040.         ret z
  1041.         cp c
  1042.         jr nz,findlastchar0
  1043.         jr findlastchar
  1044.  
  1045. tolower
  1046.         cp 'A'
  1047.         ret c
  1048.         cp 'Z'+1
  1049.         ret nc
  1050.         add 32
  1051.         ret
  1052.  
  1053. pressanykeystr
  1054.         db "!\r\nPress any key to exit...\r\n",0
  1055. playersfilename
  1056.         db "gp/gp.plr",0
  1057. defaultplaylistfilename
  1058.         db "gp/"
  1059. playlistfilename
  1060.         db "playlist.gpl",0
  1061. playersloaderrorstr
  1062.         db "Failed to load gp/gp.plr from OS folder",0
  1063. chdirfailedstr
  1064.         db "Unable to change directory",0
  1065. playliststr
  1066.         db "Playlist",0
  1067. playingstr
  1068.         db "Playing...",0
  1069. closingplayerstr
  1070.         db "Closing old player instance...\r\n",0
  1071. emptystr
  1072.         db 0
  1073. initializing1str
  1074.         db "Initializing ",0
  1075. initializing2str
  1076.         db "...",0
  1077. hotkeystr
  1078.         db "Arrows=Navigate  Enter=Play  Tab=Panel  Space=Add/Remove  S=Save Playlist",0
  1079. drivedata
  1080.         db "E: - IDE Master p.1                   E:",0,0,0,0,0,0,0,0,0,0,0,FILE_ATTRIB_DRIVE
  1081.         db "F: - IDE Master p.2                   F:",0,0,0,0,0,0,0,0,0,0,0,FILE_ATTRIB_DRIVE
  1082.         db "M: - SD Z-controller                  M:",0,0,0,0,0,0,0,0,0,0,0,FILE_ATTRIB_DRIVE
  1083.         db "O: - USB ZX-NetUsb                    O:",0,0,0,0,0,0,0,0,0,0,0,FILE_ATTRIB_DRIVE
  1084. drivedataend
  1085.  
  1086.         macro loadplayer playerpage,playersize
  1087.         OS_NEWPAGE
  1088.         ld a,e
  1089.         ld (playerpage),a
  1090.         SETPG4000
  1091.  
  1092.         ld de,0x4000
  1093.         ld hl,playersize
  1094.         call readstream_file
  1095.  
  1096.         ld hl,initializing1str
  1097.         call print_hl
  1098.         ld hl,(PLAYERNAMESTRADDR)
  1099.         call print_hl
  1100.         ld hl,initializing2str
  1101.         call print_hl
  1102.  
  1103.         ld hl,sharedpages
  1104.         ld a,(playerpage)
  1105.         call playerinit
  1106.         call print_hl
  1107.         endm
  1108.  
  1109. loadplayers
  1110.         ld de,playersfilename
  1111.         call openstream_file
  1112.         or a
  1113.         ret nz
  1114.  
  1115.         loadplayer playerpages+0,mwmend-mwmstart
  1116.         loadplayer playerpages+1,pt3end-pt3start
  1117.         loadplayer playerpages+2,mp3end-mp3start
  1118.         loadplayer playerpages+3,vgmend-vgmstart
  1119.  
  1120.         call closestream_file
  1121.         xor a
  1122.         ret
  1123.  
  1124. getfileextension
  1125. ;hl = file name
  1126. ;out: cde = file extension
  1127.         ld c,'.'
  1128.         call findlastchar ;out: de = after last dot or start
  1129.         ex de,hl
  1130.         ld a,(hl)
  1131.         call tolower
  1132.         ld c,a
  1133.         inc hl
  1134.         ld a,(hl)
  1135.         call tolower
  1136.         ld d,a
  1137.         inc hl
  1138.         ld a,(hl)
  1139.         call tolower
  1140.         ld e,a
  1141.         ret
  1142.  
  1143. isfileplaylist
  1144. ;cde = file extension
  1145. ;out: zf=1 if playlist, zf=0 otherwise
  1146.         ld a,c
  1147.         cp 'g'
  1148.         ret nz
  1149.         ld a,d
  1150.         cp 'p'
  1151.         ret nz
  1152.         ld a,e
  1153.         cp 'l'
  1154.         ret
  1155.  
  1156. findsupportedplayer
  1157. ;cde = file extension
  1158.         ld hl,playerpages
  1159.         ld b,NUM_PLAYERS
  1160. .findplayerloop
  1161.         push hl
  1162.         push bc
  1163.         ld a,(hl)
  1164.         SETPG4000
  1165.         pop bc
  1166.         call isfilesupported
  1167.         pop hl
  1168.         ret z
  1169.         inc hl
  1170.         djnz .findplayerloop
  1171.         dec b ;set zf=0
  1172.         ret
  1173.  
  1174. createfileslist
  1175.         ld de,emptystr
  1176.         OS_OPENDIR
  1177.  
  1178.         ld a,(sharedpages)
  1179.         SETPG8000
  1180.         ld a,(sharedpages+1)
  1181.         SETPGC000
  1182.  
  1183.         xor a
  1184.         ld (browserpanel.currentfileindex),a
  1185.         ld (browserpanel.firstfiletoshow),a
  1186.  
  1187.         ld hl,currentfolder+2
  1188.         cp (hl)
  1189.         ld hl,0x8000
  1190.         jr nz,.startloop
  1191.         ex de,hl
  1192.         ld hl,drivedata
  1193.         ld bc,drivedataend-drivedata
  1194.         ldir
  1195.         ex de,hl
  1196.         ld a,(drivedataend-drivedata)/FILE_DATA_SIZE
  1197. .startloop
  1198.         ld (browserpanel.filecount),a
  1199. .fileenumloop
  1200.         ld (.filedataaddr),hl
  1201. .skiptonextfile
  1202.         ld de,filinfo
  1203.         OS_READDIR
  1204.         or a
  1205.         jp nz,.sortfiles
  1206. ;skip '.' folder
  1207.         ld hl,(filinfo+FILINFO_FNAME)
  1208.         ld a,l
  1209.         xor '.'
  1210.         or h
  1211.         jr z,.skiptonextfile
  1212. ;skip findsupportedplayer for folders
  1213.         ld a,(filinfo+FILINFO_FATTRIB)
  1214.         and FATTRIB_DIR
  1215.         jr nz,.foundfileordir
  1216.         ld hl,filinfo+FILINFO_FNAME
  1217.         call getfileextension
  1218.         call isfileplaylist
  1219.         jr z,.foundfileordir
  1220.         call findsupportedplayer
  1221.         jr nz,.skiptonextfile
  1222. ;we've got either a playable file or a folder
  1223. .foundfileordir
  1224. .filedataaddr=$+1
  1225.         ld de,0
  1226.         ld hl,FILE_NAME_OFFSET
  1227.         add hl,de
  1228.         ex de,hl
  1229.         ld hl,filinfo+FILINFO_FNAME
  1230.         ld bc,9*256+SFN_SIZE
  1231. .copysfnloop
  1232.         ld a,(hl)
  1233.         cp '.'
  1234.         jr z,.foundsfnext
  1235.         or a
  1236.         jr z,.sfntailloop
  1237.         call tolower
  1238.         ld (de),a
  1239.         inc hl
  1240.         inc de
  1241.         dec c
  1242.         dec b
  1243.         jr .copysfnloop
  1244. ;this is a folder, pad it to SFN_SIZE with zeros
  1245. .sfntailloop
  1246.         ld (de),a
  1247.         inc de
  1248.         dec c
  1249.         jr nz,.sfntailloop
  1250.         jr .donesfncopy
  1251. ;format SFN as 8.3 fixed-position array padding with '*' if necessary
  1252. ;this is needed for sorting
  1253. .foundsfnext
  1254.         ld a,'*'
  1255. .sfntailloop1
  1256.         ld (de),a
  1257.         inc de
  1258.         djnz .sfntailloop1
  1259.         dec de
  1260. ;copy dot, extension, zero terminator
  1261.         ld b,5
  1262. .sfntailloop2
  1263.         ld a,(hl)
  1264.         call tolower
  1265.         ld (de),a
  1266.         inc hl
  1267.         inc de
  1268.         djnz .sfntailloop2
  1269. .donesfncopy
  1270. ;fill display name
  1271.         ld hl,FILE_DISPLAY_INFO_OFFSET-FILE_NAME_OFFSET-SFN_SIZE
  1272.         add hl,de
  1273.         ex de,hl
  1274.         ld hl,filinfo+FILINFO_LNAME
  1275.         ld a,(hl)
  1276.         or a
  1277.         jr nz,$+5
  1278.         ld hl,filinfo+FILINFO_FNAME
  1279.         ld bc,(FILE_DISPLAY_INFO_SIZE-1)*256+255
  1280. .copylfnloop
  1281.         ldi
  1282.         dec b
  1283.         jr z,.lfncopydone
  1284.         ld a,(hl)
  1285.         or a
  1286.         jr nz,.copylfnloop
  1287. .filltailloop
  1288.         ld (de),a
  1289.         inc de
  1290.         djnz .filltailloop
  1291. .lfncopydone
  1292.         xor a
  1293.         ld (de),a
  1294. ;set atrribute data
  1295.         call getfileattrib
  1296.         ld hl,FILE_ATTRIB_OFFSET-FILE_DISPLAY_INFO_OFFSET-FILE_DISPLAY_INFO_SIZE+1
  1297.         add hl,de
  1298.         ld (hl),a
  1299.         ld de,FILE_DATA_SIZE-FILE_ATTRIB_OFFSET
  1300.         add hl,de
  1301. ;check if we have space for more files
  1302.         ld a,(browserpanel.filecount)
  1303.         inc a
  1304.         ld (browserpanel.filecount),a
  1305.         cp BROWSER_FILE_COUNT
  1306.         jp c,.fileenumloop
  1307. .sortfiles
  1308.         ld a,(browserpanel.filecount)
  1309.         or a
  1310.         ret z
  1311.         ld c,a
  1312.         ld b,0
  1313.         ld a,12
  1314.         ld ix,fileextsortkeyoffsets
  1315.         ld hl,0x8000
  1316.         ld de,FILE_DATA_SIZE
  1317.         ld iy,browserpanel.fileslist
  1318.         call radixsort
  1319. ;remove '*' padding restoring SFN to original null-terminated string form
  1320.         ld a,(browserpanel.filecount)
  1321.         ld b,a
  1322.         ld hl,browserpanel.fileslist+FILE_NAME_OFFSET
  1323. .removepaddingnextfile
  1324.         ld de,hl
  1325.         push hl
  1326. .removepaddingloop
  1327.         ld a,(hl)
  1328.         inc hl
  1329.         cp '*'
  1330.         jr z,.removepaddingloop
  1331.         ld (de),a
  1332.         inc de
  1333.         or a
  1334.         jr nz,.removepaddingloop
  1335.         pop hl
  1336.         ld de,FILE_DATA_SIZE
  1337.         add hl,de
  1338.         djnz .removepaddingnextfile
  1339.         ret
  1340.  
  1341. getfileattrib
  1342. ;out: a = attribute value
  1343.         ld a,(filinfo+FILINFO_FATTRIB)
  1344.         and FATTRIB_DIR
  1345.         ld a,FILE_ATTRIB_MUSIC
  1346.         ret z
  1347.         ld hl,(filinfo+FILINFO_FNAME)
  1348.         ld bc,'..'
  1349.         sub hl,bc
  1350.         ld a,FILE_ATTRIB_PARENT_DIR
  1351.         ret z
  1352.         ld a,FILE_ATTRIB_FOLDER
  1353.         ret
  1354.  
  1355. fileextsortkeyoffsets
  1356.         dw FILE_NAME_OFFSET+7, FILE_NAME_OFFSET+6, FILE_NAME_OFFSET+5
  1357.         dw FILE_NAME_OFFSET+4, FILE_NAME_OFFSET+3, FILE_NAME_OFFSET+2
  1358.         dw FILE_NAME_OFFSET+1, FILE_NAME_OFFSET+0
  1359.         dw FILE_NAME_OFFSET+11, FILE_NAME_OFFSET+10, FILE_NAME_OFFSET+9
  1360.         dw FILE_ATTRIB_OFFSET
  1361.  
  1362.         macro jumpindirect addr
  1363.         push hl
  1364.         ld hl,(addr)
  1365.         ex (sp),hl
  1366.         ret
  1367.         endm
  1368.  
  1369. playerinit      jumpindirect PLAYERINITPROCADDR
  1370. playerdeinit    jumpindirect PLAYERDEINITPROCADDR
  1371. musicload       jumpindirect MUSICLOADPROCADDR
  1372. musicunload     jumpindirect MUSICUNLOADPROCADDR
  1373. musicplay       jumpindirect MUSICPLAYPROCADDR
  1374. isfilesupported jumpindirect ISFILESUPPORTEDPROCADDR
  1375.  
  1376.         include "../_sdk/file.asm"
  1377.         include "radixsort.asm"
  1378.  
  1379. closeexistingplayer
  1380. ;d = current pid
  1381.         ld e,1
  1382. .searchloop
  1383.         ld a,e
  1384.         cp d
  1385.         jr z,.nextprocess
  1386.         push de
  1387.         OS_GETAPPMAINPAGES ;d,e,h,l=pages in 0000,4000,8000,c000
  1388.         or a
  1389.         ld a,d
  1390.         pop de
  1391.         jr nz,.nextprocess
  1392.         push de
  1393.         SETPGC000
  1394.         ld hl,0xc000+COMMANDLINE
  1395.         ld de,0x8000
  1396.         ld bc,COMMANDLINE_sz
  1397.         ldir
  1398.         ld hl,0x8000
  1399.         call skipword_hl
  1400.         ld (hl),0
  1401.         ld hl,0x8000
  1402.         ld c,'/'
  1403.         call findlastchar ;out: de = after last slash or start
  1404.         call isplayer
  1405.         pop de
  1406.         jr z,.foundplayer
  1407. .nextprocess
  1408.         inc e
  1409.         ld a,e
  1410.         inc a
  1411.         jr nz,.searchloop
  1412.         ret
  1413. .foundplayer
  1414.         xor a
  1415.         ld (0xc000+COMMANDLINE),a
  1416.         push de
  1417.         ld hl,closingplayerstr
  1418.         call print_hl
  1419.         pop de
  1420. .waitloop
  1421.         push de
  1422.         YIELD
  1423.         YIELD
  1424.         YIELD
  1425.         YIELD
  1426.         OS_GETAPPMAINPAGES
  1427.         pop de
  1428.         or a
  1429.         jr z,.waitloop
  1430.         ret
  1431.  
  1432. isplayer
  1433. ;de = command line file name
  1434. ;out: zf=1 if gp, zf=0 otherwise
  1435.         ld a,(de)
  1436.         call tolower
  1437.         cp 'g'
  1438.         ret nz
  1439.         inc de
  1440.         ld a,(de)
  1441.         call tolower
  1442.         cp 'p'
  1443.         ret nz
  1444.         inc de
  1445.         ld a,(de)
  1446.         or a
  1447.         ret z
  1448.         cp '.'
  1449.         ret
  1450. mainend
  1451.  
  1452. sharedpages
  1453.         ds 3
  1454. playerpages
  1455.         ds NUM_PLAYERS
  1456. filinfo
  1457.         ds FILINFO_sz
  1458. currentfolder
  1459.         ds MAXPATH_sz
  1460. fullpathbuffer
  1461.         ds MAXPATH_sz
  1462.  
  1463.         struct PANEL
  1464. filecount ds 1
  1465. currentfileindex ds 1
  1466. firstfiletoshow ds 1
  1467. isinactive ds 1
  1468. fileslist ds FILE_DATA_SIZE
  1469.         ends
  1470.  
  1471. browserpanel PANEL
  1472.         ds FILE_DATA_SIZE*(BROWSER_FILE_COUNT-1)
  1473.  
  1474. playlistdatastart=$
  1475. playlistpanelversion ds 2
  1476. playlistpanel PANEL
  1477.         ds FILE_DATA_SIZE*(PLAYLIST_FILE_COUNT-1)
  1478. playlistdatasize=$-playlistdatastart
  1479.  
  1480. musicprogress ds 1
  1481.  
  1482. page0dataend = $
  1483.  
  1484.         ASSERT page0dataend <= 0x3d00 ;reserve 768 bytes for stack
  1485.  
  1486. plrbegin
  1487. mwmstart
  1488.         incbin "mwm.bin"
  1489. mwmend
  1490. pt3start
  1491.         incbin "pt3.bin"
  1492. pt3end
  1493. mp3start
  1494.         incbin "mp3.bin"
  1495. mp3end
  1496. vgmstart
  1497.         incbin "vgm.bin"
  1498. vgmend
  1499. plrend
  1500.  
  1501.         savebin "gp.com",mainbegin,mainend-mainbegin
  1502.         savebin "gp.plr",plrbegin,plrend-plrbegin
  1503.