/* CD-Player server Used to control asimtunes from a cd32-joypad with support for LCD-display */ OPTIONS RESULTS /* Set all stuff up */ IF ~show('l', 'rexxsupport.library') THEN call addlib('rexxsupport.library', 0, -30, 0) IF ~SHOW('Ports','AsimTunes_ARexx') THEN DO ADDRESS 'COMMAND' 'Run "asimcdfs:asimtunes"' 'SYS:RexxC/WaitForPort AsimTunes_ARexx' END ADDRESS 'AsimTunes_ARexx' MYPORT=OPENPORT('CDSERVER') 'set_global_autoplay 0' /* Initialise variables */ current =0 QUIT =0 offset =1 lcd_on =0 NL ='0a'x /* newline */ IF SHOW('Ports','LCDAEMON') THEN DO lcd_on=1; say 'LCDaemon Detected' ADDRESS 'LCDAEMON' 'GETCHARACTERS'; char=RESULT ADDRESS 'LCDAEMON' 'GETLINES'; lines=RESULT say lines say char END /* Main loop */ DO WHILE QUIT=0 call WAITPKT('CDSERVER') Packet = GETPKT('CDSERVER') IF Packet~= null() THEN DO message= getarg(Packet) Say message '=' current IF message = current THEN DO /* Next song, needed to get output to LCDaemon */ 'STOP' message='PLAY' END IF message = "FFW" THEN call FFW IF message = "RWD" THEN call RWD IF message = "STOP" THEN 'STOP' IF message = "NEW" THEN call NEW IF message = "PLAY" THEN DO /* we only do this if LCDaemon is in use */ IF lcd_on THEN DO 'get_track_length' length=RESULT ADDRESS 'COMMAND' 'RUN >NIL: waitarg CDSERVER' length+offset current+1 current=current+1 END 'PLAY' IF lcd_on THEN call LCD END IF message = "QUIT" THEN QUIT =1 call reply(Packet,1) END END call closeport MYPORT exit FFW: 'stop' 'get_num_tracks' total=RESULT 'get_current_track' track=RESULT track=track+1 IF track>total THEN track=1 'set_current_track' track 'get_track_length' length=RESULT message = 'PLAY' RETURN RWD: 'stop' 'get_num_tracks' total=RESULT 'get_current_track' track=RESULT track=track-1 IF trac<0 THEN track=total 'set_current_track' track 'get_track_length' length=RESULT message = 'PLAY' RETURN LCD: /* This is for output to the LCD */ IF SHOW('Ports','AsimTunes_ARexx') THEN DO 'get_disc_title' title=RESULT 'get_track_title' song=RESULT 'get_num_tracks' total=RESULT 'get_current_track' track=RESULT ok=RC END IF ok<1 THEN DO ADDRESS 'LCDAEMON' 'CLEARREXXMESSAGES' lentrack=LENGTH(total||'/'||track) firstline=LEFT(title,char-lentrack) || track ||'/'|| total word=firstline ||' '|| song 'LCDMESSAGE TIME 50000' word ADDRESS 'AsimTunes_ARexx' END IF ok>0 THEN DO ADDRESS 'LCDAEMON' 'CLEARREXXMESSAGES' 'LCDMESSAGE TIME 50000 _No CD Inserted' ADDRESS 'AsimTunes_ARexx' current=current+1 END Say 'LCD output' RETURN NEW: /* This is for output to the LCD when a CD is inserted*/ IF SHOW('Ports','AsimTunes_ARexx') THEN DO 'get_disc_title' title=RESULT 'get_disc_author' author=RESULT 'get_num_tracks' total=RESULT END ADDRESS 'LCDAEMON' 'CLEARREXXMESSAGES' word=author||' '||title||':'|| total 'LCDMESSAGE TIME 50000' word ADDRESS 'AsimTunes_ARexx' Say 'LCD output' RETURN