Difference between revisions of "TRACKERS MB SRC EN SNGDECR"

From MSX MUSIC WIKI
Jump to: navigation, search
(Created page with ";--- MoonBlaster song decruncher --- ; ; Storage of song data: Only zeros crunched. ; All values above 242 = 1 or more zeros, so max. 13 sngdecrc: ld a,sngpag ; SNGPAG = ma...")
 
 
Line 1: Line 1:
;--- MoonBlaster song decruncher ---
+
;--- MoonBlaster song decruncher ---
;
+
;
; Storage of song data: Only zeros crunched.  
+
; Storage of song data: Only zeros crunched.  
; All values above 242 = 1 or more zeros, so max. 13
+
; All values above 242 = 1 or more zeros, so max. 13
 
+
 
+
sngdecrc: ld a,sngpag ; SNGPAG = mapperbank with ONGECRUNCHTE
+
sngdecrc: ld a,sngpag ; SNGPAG = mapperbank with ONGECRUNCHTE
out (0feh),a ; songdata
+
out (0feh),a ; songdata
 
+
ld hl,08000h ; move the settings
+
ld hl,08000h ; move the settings
ld de,08000h+200
+
ld de,08000h+200
ld bc,376 ; number of bytes v. div. settings
+
ld bc,376 ; number of bytes v. div. settings
sngdecrl1: call copybyte
+
sngdecrl1: call copybyte
inc hl
+
inc hl
inc de
+
inc de
dec bc
+
dec bc
ld a,b
+
ld a,b
or c
+
or c
jr nz,sngdecrl1
+
jr nz,sngdecrl1
 
+
ld a,em1pag ; EM1PAG = mapperbank with GECRUNCHTE
+
ld a,em1pag ; EM1PAG = mapperbank with GECRUNCHTE
out (0feh),a ; songdata
+
out (0feh),a ; songdata
ld a,(08000h) ; last position
+
ld a,(08000h) ; last position
inc a
+
inc a
ld b,a
+
ld b,a
push bc ; move pat/pos data
+
push bc ; move pat/pos data
ld de,08000h
+
ld de,08000h
sngdecrl2: call copybyte
+
sngdecrl2: call copybyte
inc hl
+
inc hl
inc de
+
inc de
djnz sngdecrl2
+
djnz sngdecrl2
pop bc
+
pop bc
 
+
push hl
+
push hl
ld e,1
+
ld e,1
ld hl,08000h
+
ld hl,08000h
sngdecrl3: ld a,(hl)
+
sngdecrl3: ld a,(hl)
cp e
+
cp e
jr c,sngdecrl4
+
jr c,sngdecrl4
ld e,a
+
ld e,a
sngdecrl4: inc hl
+
sngdecrl4: inc hl
djnz sngdecrl3
+
djnz sngdecrl3
 
+
ld d,0
+
ld d,0
pop hl
+
pop hl
add hl,de
+
add hl,de
add hl,de ; skip pattern adress
+
add hl,de ; skip pattern adress
 
+
ld a,em1pag
+
ld a,em1pag
out (0feh),a
+
out (0feh),a
 
+
ld de,08240h ; real decreases of song data
+
ld de,08240h ; real decreases of song data
ld bc,03dc0h ; !maximale! number of bytes
+
ld bc,03dc0h ; !maximale! number of bytes
sngdecrl6: ld a,(hl)
+
sngdecrl6: ld a,(hl)
or a
+
or a
jr z,sngdecrend ; found an end marker? gone earlier!
+
jr z,sngdecrend ; found an end marker? gone earlier!
cp 243
+
cp 243
jr nc,sngdecrl7 ; crunched data? then decrease!
+
jr nc,sngdecrl7 ; crunched data? then decrease!
call wrtbyte
+
call wrtbyte
sngdecrl9: inc hl
+
sngdecrl9: inc hl
dec bc
+
dec bc
ld a,b
+
ld a,b
or c
+
or c
jr nz,sngdecrl6
+
jr nz,sngdecrl6
sngdecrend: ld a,sngpag ; end of decrunch
+
sngdecrend: ld a,sngpag ; end of decrunch
out (0feh),a
+
out (0feh),a
ret
+
ret
 
+
sngdecrl7: push bc ; decreasing series zeros
+
sngdecrl7: push bc ; decreasing series zeros
sub 242
+
sub 242
ld b,a
+
ld b,a
sngdecrl8: xor a
+
sngdecrl8: xor a
call wrtbyte
+
call wrtbyte
djnz sngdecrl8
+
djnz sngdecrl8
pop bc
+
pop bc
jr sngdecrl9
+
jr sngdecrl9
 
+
 
+
 
+
;--- copy data byte from one mapper bank to another ---
+
;--- copy data byte from one mapper bank to another ---
 
+
copybyte: ld a,em1pag
+
copybyte: ld a,em1pag
out (0feh),a
+
out (0feh),a
ld a,(hl)
+
ld a,(hl)
ex af,af'
+
ex af,af'
ld a,sngpag
+
ld a,sngpag
out (0feh),a
+
out (0feh),a
ex af,af'
+
ex af,af'
ld (de),a
+
ld (de),a
ret
+
ret
 
+
;--- write decrunched databyte ---
+
;--- write decrunched databyte ---
 
+
wrtbyte: ex af,af'
+
wrtbyte: ex af,af'
ld a,sngpag
+
ld a,sngpag
out (0feh),a
+
out (0feh),a
ex af,af'
+
ex af,af'
ld (de),a
+
ld (de),a
ld a,em1pag
+
ld a,em1pag
out (0feh),a
+
out (0feh),a
inc de
+
inc de
                ret
+
                ret
 
+
������������������������������������������������������������������������������������������������������������������
+
������������������������������������������������������������������������������������������������������������������

Latest revision as of 08:24, 17 July 2019

;--- MoonBlaster song decruncher ---
;
; Storage of song data: Only zeros crunched. 
; All values above 242 = 1 or more zeros, so max. 13


sngdecrc:	ld	a,sngpag	; SNGPAG = mapperbank with ONGECRUNCHTE
	out	(0feh),a	; songdata

	ld	hl,08000h	; move the settings
	ld	de,08000h+200
	ld	bc,376	; number of bytes v. div. settings
sngdecrl1:	call	copybyte
	inc	hl
	inc	de
	dec	bc
	ld	a,b
	or	c
	jr	nz,sngdecrl1

	ld	a,em1pag	; EM1PAG = mapperbank with GECRUNCHTE
	out	(0feh),a	; songdata
	ld	a,(08000h)	; last position
	inc	a
	ld	b,a
	push	bc	; move pat/pos data
	ld	de,08000h
sngdecrl2:	call	copybyte
	inc	hl
	inc	de
	djnz	sngdecrl2
	pop	bc

	push	hl
	ld	e,1
	ld	hl,08000h
sngdecrl3:	ld	a,(hl)
	cp	e
	jr	c,sngdecrl4
	ld	e,a
sngdecrl4:	inc	hl
	djnz	sngdecrl3

	ld	d,0
	pop	hl
	add	hl,de
	add	hl,de	; skip pattern adress

	ld	a,em1pag
	out	(0feh),a

	ld	de,08240h	; real decreases of song data
	ld	bc,03dc0h	; !maximale! number of bytes
sngdecrl6:	ld	a,(hl)
	or	a
	jr	z,sngdecrend	; found an end marker? gone earlier!
	cp	243
	jr	nc,sngdecrl7	; crunched data? then decrease!
	call	wrtbyte
sngdecrl9:	inc	hl
	dec	bc
	ld	a,b
	or	c
	jr	nz,sngdecrl6
sngdecrend:	ld	a,sngpag	; end of decrunch
	out	(0feh),a
	ret

sngdecrl7:	push	bc	; decreasing series zeros
	sub	242
	ld	b,a
sngdecrl8:	xor	a
	call	wrtbyte
	djnz	sngdecrl8
	pop	bc
	jr	sngdecrl9



;--- copy data byte from one mapper bank to another ---

copybyte:	ld	a,em1pag
	out	(0feh),a
	ld	a,(hl)
	ex	af,af'
	ld	a,sngpag
	out	(0feh),a
	ex	af,af'
	ld	(de),a
	ret

;--- write decrunched databyte ---

wrtbyte:	ex	af,af'
	ld	a,sngpag
	out	(0feh),a
	ex	af,af'
	ld	(de),a
	ld	a,em1pag
	out	(0feh),a
	inc	de
                ret

������������������������������������������������������������������������������������������������������������������