REM > Layers.QTM.Source REM > © Chris Rutter, 1996 ON ERROR OSCLI("Error "+REPORT$+" at line "+STR$(ERL)) DIM code% 32*1024 FOR pass%=4 TO 6 STEP 2 O%=code% P%=0 [ Opt pass% Equs "QTML" Equd 007 Equd title Equd author Equd 127 Equd recognise_filetypes Equd title ;QTMPlayer will automatically load and kill our module .jump_table LdmFd r13!,{Pc} ;no start code LdmFd r13!,{Pc} ;no initialise code B finalise Equd 0 ;search through list of filetypes B examine Equd 0 ;reserve OS_File,5 filesize amount of memory B play_sample B sound_quality B tss B sample_length B current_position B last_position B set_position B song_author B song_name B song_duration B play_file B pause B restart B stop B set_volume B read_volume B read_sample_name .title FNstring("QTMTracker") .author FNstring("Stephen Harrison") .finalise Swi "XQTM_Clear" LdmFd r13!,{Pc} .recognise_filetypes Equd &cb6 Equd &cc5 Equd &001 Equd -1 .examine ;called when the Tracker layer claims filetype 0xcb6 Mov r0,#1 ;r1=file handle already Mov r2,#0 Swi "XOS_Args" ;set file position pointer to zero LdmVsFd r13!,{Pc} Mov r0,#4 Mov r2,r12 ;r12=workspace address (256 bytes long) Mov r3,#4 ;read in one word Swi "XOS_GBPB" LdmVsFd r13!,{Pc} Ldr r0,[r12] ;load in the word we read Ldr r1,musx Teq r0,r1 MovNe r0,#1 MovEq r0,#0 ;if the file starts with anything apart from "MUSX LdmFd r13!,{Pc} ;assume it's ours .musx Equs "MUSX" .play_sample Mov r3,r2 ;volume Mov r2,r1 ;note Mov r1,r0 ;sample Mov r0,#1 ;channel Swi "XQTM_PlaySample" FNend .sound_quality Swi "XQTM_SetSampleSpeed" FNend .tss Teq r0,#1 BEq tss_on .tss_off Mvn r0,#0 Mov r1,#0 Mvn r2,#0 Swi "XQTM_SoundControl" FNend .tss_on Mvn r0,#0 Mov r1,#1 Mvn r2,#0 Swi "XQTM_SoundControl" FNend .sample_length Swi "XQTM_ReadSampleTable" Mov r0,r1 FNend .current_position Mvn r0,#0 Mvn r1,#0 Swi "XQTM_Pos" MovVs r0,#0 FNend .last_position Swi "XQTM_ReadSongLength" MovVs r0,#0 FNend .set_position Swi "XQTM_Pos" FNend .song_author Swi "XQTM_Info" MovVc r0,r1 FNend .song_name Swi "XQTM_Info" FNend .song_duration Swi "XQTM_ReadPlayingTime" MovVc r0,r2 FNend .play_file Teq r3,#0 ;WORK-AROUND for QTMTracker bug AdrEq r0,error_zerolength LdmEqFd r13!,{r14} OrrEqS Pc,r14,#1<<28 Mov r2,#0 Mov r3,#0 Swi "XQTM_Load" SwiVc "XQTM_Start" MvnVc r0,#0 FNend .pause Swi "XQTM_Pause" FNend .restart Swi "XQTM_Start" FNend .stop Swi "XQTM_Stop" FNend .set_volume Swi "XQTM_Volume" FNend .read_volume Mvn r0,#0 Swi "XQTM_Volume" FNend .read_sample_name Swi "XQTM_ReadSampleTable" FNend .error_zerolength Equd 0 Equs "QTMTracker will crash if asked to load a zero-length file, so QTMPlayer has a work-around for this"+CHR$0 Align ] NEXT pass% SYS "OS_File",10,".Code",&FFD,,code%,O% END DEF FNstring(string$) [ Opt pass% Equs string$ Equb 0 Align ] =pass% DEF FNend [ Opt pass% LdmFd r13!,{Pc} ] =pass%