;	GLUE MASTER'S SMALLER SIZE TUNE PLAYER
;	THIS MODULE-CONVERTER IS CREATED 31/8-90
;	IT'S FOR THE DRUM-EXPANSION...

SOURCE=		$30000
DEST=		$40000

S:
	MOVEM.L	D0-D7/A0-A6,-(A7)
	LEA SOURCE,A0
	LEA DEST,A1
	LEA HEXTAB,A4

	MOVE.B #'M',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'_',(A1)+
	MOVE.B #'S',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'N',(A1)+
	MOVE.B #'G',(A1)+
	MOVE.B #':',(A1)+
	MOVE.B #$0A,(A1)+
	MOVE.B #$09,(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'C',(A1)+
	MOVE.B #'.',(A1)+
	MOVE.B #'B',(A1)+
	MOVE.B #' ',(A1)+

	ADD.L #[20+[31*30]+1+1],A0	;START OF SONGDATA
	MOVE.B -2(A0),D6		;SONGLEN

	MOVE.L A0,A2	;USED TO COPY SONG
	CLR.B D5
	CLR.W D4
	SUB.B #1,D6
	AND.W #$00FF,D6
NEXTSTEP:
	MOVE.B 1(A0,D6.W),D0
	MOVE.B (A2)+,D1
	MOVE.B #'$',(A1)+
	MOVE.B D1,D2
	ROL.B #4,D2
	AND.W #$000F,D2
	AND.W #$000F,D1
	MOVE.B 0(A4,D2.W),(A1)+		;SONG DATA
	MOVE.B 0(A4,D1.W),(A1)+		;TO ASCII IN HEX
	MOVE.B #',',(A1)+
	CMP.B D5,D0
	BLS.S NOTHIGHER

	MOVE.B D0,D5
NOTHIGHER:
	DBF D6,NEXTSTEP		;HOGSTA PATTERN I D5

	MOVE.B #$0A,-1(A1)	;LF ISTALLET FOR KOMMA

	MOVE.B #$0A,(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'_',(A1)+
	MOVE.B #'S',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'N',(A1)+
	MOVE.B #'G',(A1)+
	MOVE.B #'E',(A1)+
	MOVE.B #'N',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #':',(A1)+
	MOVE.B #$0A,(A1)+
	MOVE.B #$09,(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'C',(A1)+
	MOVE.B #'.',(A1)+
	MOVE.B #'B',(A1)+
	MOVE.B #' ',(A1)+
	MOVE.B #'$',(A1)+
	MOVE.B #'F',(A1)+
	MOVE.B #'F',(A1)+
	MOVE.B #$0A,(A1)+

	ADD.L #[128+4],A0

	LEA OLDPERIODS,A2
	LEA NEWNOTES,A3

	MOVEQ #-1,D4		;BEFORE FIRST PATTERN
PATTERNMAKE:
	ADD.B #1,D4
	MOVE.B #$0A,(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'_',(A1)+
	MOVE.B #'P',(A1)+
	MOVE.B #'A',(A1)+
	MOVE.B #'T',(A1)+
	MOVE.B D4,D7
	MOVE.B D7,D2
	ROR.B #4,D2
	AND.W #$000F,D2
	AND.W #$000F,D7
	MOVE.B 0(A4,D2.W),(A1)+		;PATTERN NUMBER
	MOVE.B 0(A4,D7.W),(A1)+		;TO ASCII IN HEX
	MOVE.B #':',(A1)+
	MOVE.B #$0A,(A1)+

	MOVE.W #63,D6
LINECREATE:
	MOVE.W D6,$DFF180

	MOVE.B #9,(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'C',(A1)+
	MOVE.B #'.',(A1)+
	MOVE.B #'B',(A1)+
	MOVE.B #9,(A1)+

	BSR GETPERMAKNOT

	MOVE.B #9,(A1)+
	MOVE.B #',',(A1)+
	ADD.W #4,A0

	BSR GETPERMAKNOT

	MOVE.B #9,(A1)+
	MOVE.B #',',(A1)+
	ADD.W #4,A0

	BSR GETPERMAKNOT

	MOVE.B #9,(A1)+
	MOVE.B #',',(A1)+
	ADD.W #4,A0

GETDRUMS:
	MOVE.B 2(A0),D0		;INSTR. NR.

	TST.B D0
	BEQ.L NODRUM
	CMP.B #$50,D0
	BEQ.L BDRUM
	CMP.B #$60,D0
	BEQ.L SDRUM
	CMP.B #$90,D0
	BEQ.L T1DRUM
	CMP.B #$A0,D0
	BEQ.L T2DRUM
	CMP.B #$B0,D0
	BEQ.S T3DRUM
	CMP.B #$C0,D0
	BEQ.S T4DRUM
	CMP.B #$70,D0
	BEQ.S HCDRUM
	CMP.B #$80,D0
;	BEQ.S HODRUM

HODRUM:
	MOVE.B #'H',(A1)+
	MOVE.B #'O',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.L DRUMGOT

HCDRUM:
	MOVE.B #'H',(A1)+
	MOVE.B #'C',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.L DRUMGOT

T4DRUM:
	MOVE.B #'T',(A1)+
	MOVE.B #'4',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.L DRUMGOT

T3DRUM:
	MOVE.B #'T',(A1)+
	MOVE.B #'3',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.S DRUMGOT

T2DRUM:
	MOVE.B #'T',(A1)+
	MOVE.B #'2',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.S DRUMGOT

T1DRUM:
	MOVE.B #'T',(A1)+
	MOVE.B #'1',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.S DRUMGOT

SDRUM:
	MOVE.B #'S',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.S DRUMGOT

BDRUM:
	MOVE.B #'B',(A1)+
	MOVE.B #'D',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'U',(A1)+
	MOVE.B #'M',(A1)+
	MOVE.B #$0A,(A1)+
	BRA.S DRUMGOT

NODRUM:
	MOVE.B #'W',(A1)+
	MOVE.B #$0A,(A1)+

DRUMGOT:
	ADD.W #4,A0

	DBF D6,LINECREATE
	DBF D5,PATTERNMAKE

	SUB.L #DEST,A1
	MOVE.L A1,DESTLEN
	MOVEM.L	(A7)+,D0-D7/A0-A6
	MOVEQ #0,D0
	RTS

;;;;;;;;;;;;;;
;;;;;; SUB
GETPERMAKNOT:
	MOVE.W 2(A0),D0
	AND.W #$0F00,D0
	CMP.W #$0C00,D0
	BNE.S NOTBREAK
	MOVE.B #'B',(A1)+
	MOVE.B #'R',(A1)+
	MOVE.B #'K',(A1)+
	BRA.S EMPTY

NOTBREAK:
	MOVE.W (A0),D0
	MOVE.W #0,D7
NEXTPER:
	MOVE.W (A2,D7.W),D1
	CMP.B D1,D0
	BEQ.S FOUNDPER

	ADD.W #2,D7
	BRA.S NEXTPER
FOUNDPER:
	MOVE.B 0(A3,D7.W),(A1)+
	MOVE.B 1(A3,D7.W),D7
	CMP.B #'W',D7
	BEQ.S EMPTY
	MOVE.B D7,(A1)+

EMPTY:
	RTS


;;;;;;;;;;;;;;;;; DATA

NEWNOTES:
	DC.B 'ZB','SB','XB','DB','CB','VB','GB','BB','HB','NB','JB'
	DC.B 'MB','ZC','SC','XC','DC','CC','VC','GC','BC','HC','NC'
	DC.B 'JC','MC','ZD','SD','XD','DD','CD','VD','GD','BD','HD'
	DC.B 'ND','JD','MD','WW'

EVEN
OLDPERIODS:
	DC.W $0358,$0328,$02FA,$02D0,$02A6,$0280,$025C,$023A,$021A,$01FC,$01E0
	DC.W $01C5,$01AC,$0194,$017D,$0168,$0153,$0140,$012E,$011D,$010D,$00FE
	DC.W $00F0,$00E2,$00D6,$00CA,$00BE,$00B4,$00AA,$00A0,$0097,$008F,$0087
	DC.W $007F,$0078,$0071,$0000

HEXTAB:
	DC.B '0123456789ABCDEF'
EVEN
DESTLEN:
	DC.L 0

