Skip to content

Commit

Permalink
Correct Saxman documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Clownacy committed Apr 20, 2022
1 parent 099cd41 commit a3f7a27
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions s2.sounddriver.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3830,30 +3830,30 @@ zSaxmanReadLoop:
exx ; shadow reg set
if OptimiseDriver
srl b ; b >> 1 (just a mask that lets us know when we need to reload)
jr c,.continue ; if next bit of 'b' is set, we still have bits left in 'c', so continue
jr c,.skip_fetching_descriptor ; if next bit of 'b' is set, we still have bits left in 'c', so continue
; If you get here, we're out of bits in 'c'!
call zDecEndOrGetByte ; get next byte -> 'a'
ld c,a ; a -> 'c'
ld b,7Fh ; b = 7Fh (7 new bits in 'c')

.continue:
.skip_fetching_descriptor:
srl c ; test next bit of 'c'
exx ; normal reg set
jr nc,.is_compbit ; if bit not set, it's a compression bit; jump accordingly
jr nc,.is_dictionary_reference ; if bit not set, it's a compression bit; jump accordingly
else
srl c ; c >> 1 (active control byte)
srl b ; b >> 1 (just a mask that lets us know when we need to reload)
bit 0,b ; test next bit of 'b'
jr nz,.continue ; if it's set, we still have bits left in 'c', so continue
jr nz,.skip_fetching_descriptor ; if it's set, we still have bits left in 'c', so continue
; If you get here, we're out of bits in 'c'!
call zDecEndOrGetByte ; get next byte -> 'a'
ld c,a ; a -> 'c'
ld b,0FFh ; b = FFh (8 new bits in 'c')

.continue:
.skip_fetching_descriptor:
bit 0,c ; test next bit of 'c'
exx ; normal reg set
jr z,.is_compbit ; if bit not set, it's a compression bit; jump accordingly
jr z,.is_dictionary_reference ; if bit not set, it's a compression bit; jump accordingly
endif
; If you get here, there's a non-compressed byte
call zDecEndOrGetByte ; get next byte -> 'a'
Expand All @@ -3864,7 +3864,7 @@ zSaxmanReadLoop:
exx ; normal reg set
jr zSaxmanReadLoop ; loop back around...

.is_compbit:
.is_dictionary_reference:
call zDecEndOrGetByte ; get next byte -> 'a'
ld c,a ; a -> 'c' (low byte of target address)
call zDecEndOrGetByte ; get next byte -> 'a'
Expand Down Expand Up @@ -3897,19 +3897,19 @@ zSaxmanReadLoop:
pop hl ; shadow 'de' -> 'hl' (relative pointer, prior to all bytes read, relative)
or a ; Clear carry
sbc hl,bc ; hl -= bc
jr nc,.skipbytes ; if result positive, jump ahead
jr nc,.is_not_zero_fill ; if result positive, jump ahead
ex de,hl ; current output pointer -> 'hl'
ld b,a ; how many bytes to load -> 'b'

.fillzeroloop:
.fill_zero_loop:
ld (hl),0 ; fill in zeroes that many times
inc hl
djnz .fillzeroloop
djnz .fill_zero_loop

ex de,hl ; output pointer updated
jr zSaxmanReadLoop ; loop back around...

.skipbytes:
.is_not_zero_fill:
ld hl,zMusicData ; point at beginning of decompression point
add hl,bc ; move ahead however many bytes
ld c,a
Expand Down

0 comments on commit a3f7a27

Please sign in to comment.