	;YM plugin script for Gamebase

	;%fp		file pointer (set to 0 at start of script)
	;%lof		length of file in bytes
	;%fn$		filename
	;%ver		version of the script plugin compiler/interpretor

	;%s1$		string 1 in GB window (default to empty string)
	;%s2$		string 2 in GB window (default to empty string)
	;%s3$		string 3 in GB window (default to empty string)
	;%n1		number 1 in GB window (default to 0)
	;%n2		number 2 in GB window (default to 0)

	;Define global variables
	mov 0, %track	
	
	;Define arrays

	; test the file
	mov 0, tst				;prepare null termination detect
	rds 0, %id$				;Read string until null byte
	mov %id$, tst
	bne "SC68 Music-file / (c) (BeN)jamin Gerard / SasHipA-Dev  ", error


lzh_unpack					;YM packed -> YM unpacked

Read_string 4,%id$				;Read YM header

goto error if %id$ <> "YM6!"

Read_null 16					;Skip next 16 bytes

Read_integer 2,%digidrum			;Check how many Digi samples embedded

Loop(%digidrum)					;Loop %digidrum times
	read_integer 4,%digisize		;Find Sample size
	read_null %digisize			;Skip sample data
/Loop

Read_string 0,%Song_Name$			;0 size means read until null byte found
Read_string 0,%Composer_Name$
Read_string 0,%Copyright$

%result$ = "YM file processed successfully"
End

:error
%result$ = "File is not a valid YM6! format"
End