Skip to content

Commit 5a1737f

Browse files
author
Krusty/Benediction
committed
add missing files
1 parent 5132a80 commit 5a1737f

12 files changed

Lines changed: 650 additions & 17 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
; Copyright (c) 2025, Milos "baze" Bazelides
2+
; This code is licensed under the BSD 2-Clause License.
3+
4+
; Reverse BX0 decoder (68 bytes with setup, 62 bytes excluding setup).
5+
; This work is inspired by Einar Saukas' ZX0 (https://github.com/einar-saukas/ZX0).
6+
7+
xor a
8+
push af ; Push dummy value onto the stack.
9+
ld hl,SrcAddr
10+
ld de,DstAddr
11+
12+
DecodeLoop call EliasGamma
13+
lddr
14+
rla
15+
jr c,NewOffset
16+
17+
call EliasGamma
18+
19+
RepOffset ex (sp),hl
20+
push hl
21+
add hl,de
22+
lddr
23+
pop hl
24+
ex (sp),hl
25+
rla
26+
jr nc,DecodeLoop
27+
28+
NewOffset pop bc
29+
or a
30+
call EliasGamma
31+
dec c
32+
ret m ; Option to include the end-of-stream marker.
33+
ld b,c
34+
ld c,(hl)
35+
dec hl
36+
rr b
37+
rr c
38+
rra
39+
; inc bc ; Option to extend the offset range.
40+
push bc
41+
call EliasGamma
42+
inc bc
43+
jr RepOffset
44+
45+
EliasGamma ld bc,1
46+
EliasLoop adc a,a
47+
jr nz,NoFetch
48+
sbc a,(hl)
49+
dec hl
50+
rla
51+
NoFetch ret nc
52+
add a,a
53+
rl c
54+
rl b
55+
jr EliasLoop
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
; Copyright (c) 2025, Milos "baze" Bazelides
2+
; This code is licensed under the BSD 2-Clause License.
3+
4+
; Reverse BX2 decoder (57 bytes with setup, 48 bytes excluding setup).
5+
; This work is inspired by Einar Saukas' ZX2 (https://github.com/einar-saukas/ZX2).
6+
7+
xor a
8+
ld b,a
9+
ld c,a
10+
ld hl,SrcAddr
11+
ld de,DstAddr
12+
13+
DecodeLoop call EliasGamma
14+
rla
15+
jr nc,NewOffset
16+
17+
lddr
18+
19+
call EliasGamma
20+
rla
21+
jr c,RepOffset
22+
23+
NewOffset ex af,af'
24+
ld a,(hl)
25+
or a
26+
ret z ; Option to include the end-of-stream marker.
27+
ex af,af'
28+
dec hl
29+
inc bc
30+
31+
RepOffset push hl
32+
ex af,af'
33+
ld h,0
34+
ld l,a
35+
ex af,af'
36+
add hl,de
37+
lddr
38+
pop hl
39+
jr DecodeLoop
40+
41+
EliasGamma inc c
42+
EliasLoop add a,a
43+
jr nz,NoFetch
44+
sbc a,(hl)
45+
dec hl
46+
rla
47+
NoFetch ret nc
48+
add a,a
49+
rl c
50+
rl b
51+
jr EliasLoop
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
; Copyright (c) 2021, Aleksey "introspec" Pichugin, Milos "baze" Bazelides, Pavel "Zilog" Cimbal
2+
; This code is licensed under the BSD 2-Clause License.
3+
4+
; Reverse EF8 decoder (39 bytes with setup, 30 bytes excluding setup).
5+
6+
; If the decoder is launched from ZX Spectrum BASIC, the setup can be optimized by using
7+
; the initial values of BC and A:
8+
9+
; ld h,b
10+
; ld l,b
11+
; ld de,DstAddr
12+
13+
; This reduces the decoder to 34 bytes if these assumptions are met:
14+
15+
; 1) The compressed stream is placed immediately above the entry point.
16+
; 2) The end-of-stream marker is omitted, and the final block overwrites opcodes after LDDR.
17+
; 3) The start address is either #7F80 (BC = #7F80, A = #80) or #BFC0 (BC = #BFC0, A = #C0).
18+
; For the latter, the first literal must be at least 2 bytes long.
19+
20+
ld hl,SrcAddr
21+
ld de,DstAddr
22+
ld a,128
23+
ld c,a
24+
25+
EliasGamma add a,a
26+
rl c
27+
ret z ; Option to include the end-of-stream marker.
28+
DecodeLoop add a,a
29+
jr nz,NoFetch
30+
ld b,a
31+
sbc a,(hl)
32+
dec hl
33+
rla
34+
NoFetch jr c,EliasGamma
35+
rla
36+
jr c,CopyBytes
37+
push hl
38+
ld l,(hl)
39+
ld h,b
40+
add hl,de
41+
; inc hl ; Option to extend the offset range.
42+
inc bc
43+
CopyBytes lddr
44+
inc c
45+
jr c,DecodeLoop
46+
pop hl
47+
dec hl
48+
jr DecodeLoop
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
; Copyright (c) 2017, Milos "baze" Bazelides
2+
; This code is licensed under the BSD 2-Clause License.
3+
4+
; Reverse LZM decoder (27 bytes with setup, 19 bytes excluding setup).
5+
6+
ld hl,SrcAddr
7+
ld de,DstAddr
8+
ld b,0
9+
10+
DecodeLoop ld c,(hl)
11+
dec hl
12+
srl c
13+
ret z ; Option to include the end-of-stream marker.
14+
; inc c ; Option to extend the block length.
15+
jr c,CopyBytes
16+
push hl
17+
ld l,(hl)
18+
ld h,b
19+
add hl,de
20+
; inc hl ; Option to extend the offset range.
21+
CopyBytes lddr
22+
jr c,DecodeLoop
23+
pop hl
24+
dec hl
25+
jr DecodeLoop

0 commit comments

Comments
 (0)