├── LICENSE ├── dlze_fast.asm ├── dlze_small.asm ├── dlzee_fast.asm ├── dlzee_small.asm ├── dlzeee_fast.asm ├── dlzeee_fast2.asm ├── dlzeee_small.asm ├── lzee.c └── readme.md /LICENSE: -------------------------------------------------------------------------------- 1 | LZEe - LZE enhancement for Z80 by uniabis 2 | 3 | LZE 4 | Copyright (C)1995,2008 GORRY. 5 | 6 | License:zlib license or original LZE license 7 | 8 | This software is provided 'as-is', without any express or implied 9 | warranty. In no event will the authors be held liable for any damages 10 | arising from the use of this software. 11 | 12 | Permission is granted to anyone to use this software for any purpose, 13 | including commercial applications, and to alter it and redistribute it 14 | freely, subject to the following restrictions: 15 | 16 | 1. The origin of this software must not be misrepresented; you must not 17 | claim that you wrote the original software. If you use this software 18 | in a product, an acknowledgment in the product documentation would be 19 | appreciated but is not required. 20 | 21 | 2. Altered source versions must be plainly marked as such, and must not be 22 | misrepresented as being the original software. 23 | 24 | 3. This notice may not be removed or altered from any source 25 | distribution. 26 | -------------------------------------------------------------------------------- /dlze_fast.asm: -------------------------------------------------------------------------------- 1 | ; lze depacker for Z80 sjasm 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2019 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | dlze: 28 | ldi 29 | scf 30 | 31 | getbit1: 32 | ld a,(hl) 33 | inc hl 34 | adc a,a 35 | jr nc,dlze_lp1n 36 | 37 | dlze_lp1: 38 | ldi 39 | dlze_lp2: 40 | add a 41 | jr z,getbit1 42 | jr c,dlze_lp1 43 | dlze_lp1n: 44 | add a 45 | call z,getbit 46 | jr c,dlze_far 47 | ld bc,0 48 | 49 | add a 50 | call z,getbit 51 | rl c 52 | 53 | add a 54 | call z,getbit 55 | rl c 56 | 57 | push hl 58 | ld l,(hl) 59 | ld h,-1 60 | 61 | dlze_copy: 62 | inc c 63 | add hl,de 64 | ldir 65 | ldi 66 | pop hl 67 | inc hl 68 | jr dlze_lp2 69 | 70 | dlze_far: 71 | ex af, af';' 72 | ld a,(hl) 73 | inc hl 74 | push hl 75 | ld l,(hl) 76 | ld c,l 77 | rra 78 | rr l 79 | rra 80 | rr l 81 | rra 82 | rr l 83 | or 0e0h 84 | ld h,a 85 | ld a,c 86 | and 7 87 | jr nz,dlze_skip 88 | 89 | pop bc 90 | inc bc 91 | ld a,(bc) 92 | sub 1 93 | ret c 94 | push bc 95 | 96 | dlze_skip: 97 | ld b,0 98 | ld c,a 99 | ex af, af';' 100 | jr dlze_copy 101 | 102 | getbit: 103 | ld a,(hl) 104 | inc hl 105 | adc a 106 | ret 107 | 108 | -------------------------------------------------------------------------------- /dlze_small.asm: -------------------------------------------------------------------------------- 1 | ; lze depacker for Z80 sjasm 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2019 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | ;DEFINE ALLOW_LDIR_UNROLLING 28 | ;DEFINE ALLOW_INLINE_GETBIT 29 | 30 | IFNDEF ALLOW_INLINE_GETBIT 31 | 32 | MACRO GET_BIT 33 | call getbit 34 | ENDM 35 | 36 | ELSE 37 | 38 | MACRO GET_BIT 39 | add a 40 | call z,getbit 41 | ENDM 42 | 43 | ENDIF 44 | 45 | dlze: 46 | ld a,080h 47 | dlze_lp1: 48 | ldi 49 | dlze_lp2: 50 | GET_BIT 51 | jr c,dlze_lp1 52 | 53 | GET_BIT 54 | jr c,dlze_far 55 | ld c,0 56 | 57 | GET_BIT 58 | rl c 59 | GET_BIT 60 | rl c 61 | 62 | push hl 63 | ld l,(hl) 64 | ld h,-1 65 | 66 | dlze_copy: 67 | ld b,0 68 | inc c 69 | add hl,de 70 | IFNDEF ALLOW_LDIR_UNROLLING 71 | inc bc 72 | ldir 73 | ELSE 74 | ldir 75 | ldi 76 | ENDIF 77 | pop hl 78 | inc hl 79 | jr dlze_lp2 80 | 81 | dlze_far: 82 | ex af, af';' 83 | 84 | ld a,(hl) 85 | inc hl 86 | 87 | ld c,(hl) 88 | rra 89 | rr c 90 | rra 91 | rr c 92 | rra 93 | rr c 94 | or 0e0h 95 | ld b,a 96 | 97 | ld a,(hl) 98 | and 7 99 | jr nz,dlze_skip 100 | 101 | inc hl 102 | or (hl) 103 | ret z 104 | dec a 105 | 106 | dlze_skip: 107 | push hl 108 | ld l,c 109 | ld h,b 110 | ld c,a 111 | ex af, af';' 112 | jr dlze_copy 113 | 114 | getbit: 115 | IFNDEF ALLOW_INLINE_GETBIT 116 | add a 117 | ret nz 118 | ENDIF 119 | ld a,(hl) 120 | inc hl 121 | adc a 122 | ret 123 | 124 | -------------------------------------------------------------------------------- /dlzee_fast.asm: -------------------------------------------------------------------------------- 1 | ; lzee depacker for Z80 sjasm 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2019 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | dlze: 28 | ldi 29 | scf 30 | 31 | getbit1: 32 | ld a,(hl) 33 | inc hl 34 | adc a,a 35 | jr nc,dlze_lp1n 36 | 37 | dlze_lp1: 38 | ldi 39 | dlze_lp2: 40 | add a 41 | jr z,getbit1 42 | jr c,dlze_lp1 43 | dlze_lp1n: 44 | add a 45 | call z,getbit 46 | jr c,dlze_far 47 | ld bc,0 48 | 49 | add a 50 | call z,getbit 51 | rl c 52 | 53 | add a 54 | call z,getbit 55 | rl c 56 | 57 | push hl 58 | ld l,(hl) 59 | ld h,-1 60 | 61 | dlze_copy: 62 | inc c 63 | add hl,de 64 | ldir 65 | ldi 66 | pop hl 67 | inc hl 68 | jr dlze_lp2 69 | 70 | dlze_far: 71 | ex af, af';' 72 | ld a,(hl) 73 | inc hl 74 | push hl 75 | ld l,(hl) 76 | ld c,a 77 | or 7 78 | rrca 79 | rrca 80 | rrca 81 | ld h,a 82 | ld a,c 83 | and 7 84 | jr nz,dlze_skip 85 | 86 | pop bc 87 | inc bc 88 | ld a,(bc) 89 | sub 1 90 | ret c 91 | push bc 92 | 93 | dlze_skip: 94 | ld b,0 95 | ld c,a 96 | ex af, af';' 97 | jr dlze_copy 98 | 99 | getbit: 100 | ld a,(hl) 101 | inc hl 102 | adc a 103 | ret 104 | -------------------------------------------------------------------------------- /dlzee_small.asm: -------------------------------------------------------------------------------- 1 | ; lzee depacker for Z80 sjasm 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2019 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | ;DEFINE ALLOW_LDIR_UNROLLING 28 | ;DEFINE ALLOW_INLINE_GETBIT 29 | 30 | IFNDEF ALLOW_INLINE_GETBIT 31 | 32 | MACRO GET_BIT 33 | call getbit 34 | ENDM 35 | 36 | ELSE 37 | 38 | MACRO GET_BIT 39 | add a 40 | call z,getbit 41 | ENDM 42 | 43 | ENDIF 44 | 45 | dlze: 46 | ld a,080h 47 | dlze_lp1: 48 | ldi 49 | dlze_lp2: 50 | GET_BIT 51 | jr c,dlze_lp1 52 | 53 | GET_BIT 54 | jr c,dlze_far 55 | 56 | ld c,0 57 | GET_BIT 58 | rl c 59 | GET_BIT 60 | rl c 61 | 62 | push hl 63 | ld l,(hl) 64 | ld h,-1 65 | 66 | dlze_copy: 67 | ld b,0 68 | inc c 69 | add hl,de 70 | IFNDEF ALLOW_LDIR_UNROLLING 71 | inc bc 72 | 73 | ldir 74 | ELSE 75 | ldir 76 | ldi 77 | ENDIF 78 | pop hl 79 | inc hl 80 | jr dlze_lp2 81 | 82 | dlze_far: 83 | ex af, af';' 84 | 85 | ld a,(hl) 86 | or 7 87 | rrca 88 | rrca 89 | rrca 90 | ld b,a 91 | 92 | ld a,(hl) 93 | inc hl 94 | ld c,(hl) 95 | 96 | and 7 97 | jr nz,dlze_skip 98 | 99 | inc hl 100 | or (hl) 101 | ret z 102 | dec a 103 | 104 | dlze_skip: 105 | push hl 106 | ld l,c 107 | ld h,b 108 | ld c,a 109 | ex af, af';' 110 | jr dlze_copy 111 | 112 | getbit: 113 | IFNDEF ALLOW_INLINE_GETBIT 114 | add a 115 | ret nz 116 | ENDIF 117 | ld a,(hl) 118 | inc hl 119 | adc a 120 | ret 121 | 122 | -------------------------------------------------------------------------------- /dlzeee_fast.asm: -------------------------------------------------------------------------------- 1 | ; LZEee depacker for Z80 sjasm (lzee with f5 option) 87bytes 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2020 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | ;DEFINE OBSOLETED_F4 28 | 29 | dlzeee: 30 | ldi 31 | scf 32 | 33 | getbit1: 34 | ld a,(hl) 35 | inc hl 36 | adc a,a 37 | jr c,dlze_lp1n 38 | 39 | ; DUP 2 40 | ; ldi 41 | ; add a 42 | ; jr c,dlze_lp1n 43 | ; EDUP 44 | 45 | dlze_lp1: 46 | ldi 47 | dlze_lp2: 48 | add a 49 | jr nc,dlze_lp1 50 | jr z,getbit1 51 | dlze_lp1n: 52 | add a 53 | jr c,dlze_far 54 | dlze_near: 55 | ld bc,0 56 | 57 | add a 58 | call z,getbit 59 | rl c 60 | 61 | add a 62 | call z,getbit 63 | rl c 64 | 65 | push hl 66 | ld l,(hl) 67 | ld h,-1 68 | 69 | dlze_copy: 70 | inc c 71 | add hl,de 72 | ldir 73 | ldi 74 | pop hl 75 | inc hl 76 | jr dlze_lp2 77 | 78 | getbit2: 79 | ld a,(hl) 80 | inc hl 81 | adc a,a 82 | jr nc,dlze_near 83 | 84 | dlze_far: 85 | jr z,getbit2 86 | ex af, af';' 87 | ld a,(hl) 88 | inc hl 89 | push hl 90 | ld l,(hl) 91 | ld c,a 92 | or 7 93 | rrca 94 | rrca 95 | rrca 96 | ld h,a 97 | ld a,c 98 | and 7 99 | jr nz,dlze_skip 100 | 101 | pop bc 102 | inc bc 103 | ld a,(bc) 104 | IFNDEF OBSOLETED_F4 105 | or a 106 | ret z 107 | ELSE 108 | sub 1 109 | ret c 110 | ENDIF 111 | push bc 112 | 113 | dlze_skip: 114 | ld b,0 115 | ld c,a 116 | ex af, af';' 117 | jr dlze_copy 118 | 119 | getbit: 120 | ld a,(hl) 121 | inc hl 122 | adc a 123 | ret 124 | -------------------------------------------------------------------------------- /dlzeee_fast2.asm: -------------------------------------------------------------------------------- 1 | ; LZEee depacker for Z80 sjasm (lzee with f5 option) 97bytes 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2020 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | ;DEFINE OBSOLETED_F4 28 | 29 | dlzeee: 30 | ldi 31 | scf 32 | 33 | getbit1: 34 | ld a,(hl) 35 | inc hl 36 | adc a,a 37 | jr c,dlze_lp1n 38 | 39 | DUP 1 40 | ldi 41 | add a 42 | jr c,dlze_lp1n 43 | EDUP 44 | 45 | dlze_lp1: 46 | ldi 47 | dlze_lp2: 48 | add a 49 | jr nc,dlze_lp1 50 | jr z,getbit1 51 | dlze_lp1n: 52 | add a 53 | jr c,dlze_far 54 | dlze_near: 55 | ld bc,080h 56 | 57 | add a 58 | jr z,getbit3 59 | rl c 60 | 61 | add a 62 | jr z,getbit3 63 | dlze_near_end1: 64 | rl c 65 | dlze_near_end2: 66 | 67 | push hl 68 | ld l,(hl) 69 | ld h,-1 70 | 71 | dlze_copy: 72 | inc c 73 | add hl,de 74 | ldir 75 | ldi 76 | pop hl 77 | inc hl 78 | jp dlze_lp2 79 | 80 | getbit2: 81 | ld a,(hl) 82 | inc hl 83 | adc a,a 84 | jr nc,dlze_near 85 | 86 | dlze_far: 87 | jr z,getbit2 88 | ex af, af';' 89 | ld a,(hl) 90 | inc hl 91 | push hl 92 | ld l,(hl) 93 | ld c,a 94 | or 7 95 | rrca 96 | rrca 97 | rrca 98 | ld h,a 99 | ld a,c 100 | and 7 101 | jr nz,dlze_skip 102 | 103 | pop bc 104 | inc bc 105 | ld a,(bc) 106 | IFNDEF OBSOLETED_F4 107 | or a 108 | ret z 109 | ELSE 110 | sub 1 111 | ret c 112 | ENDIF 113 | push bc 114 | 115 | dlze_skip: 116 | ld b,0 117 | ld c,a 118 | ex af, af';' 119 | jr dlze_copy 120 | 121 | getbit3: 122 | ld a,(hl) 123 | inc hl 124 | adc a 125 | rl c 126 | jr nc,dlze_near_end2 127 | add a 128 | jr dlze_near_end1 129 | -------------------------------------------------------------------------------- /dlzeee_small.asm: -------------------------------------------------------------------------------- 1 | ; LZEee depacker for Z80 sjasm (lzee with f5 option) 72bytes 2 | ; 3 | ; license:zlib license 4 | ; 5 | ; Copyright (c) 2020 uniabis 6 | ; 7 | ; This software is provided 'as-is', without any express or implied 8 | ; warranty. In no event will the authors be held liable for any damages 9 | ; arising from the use of this software. 10 | ; 11 | ; Permission is granted to anyone to use this software for any purpose, 12 | ; including commercial applications, and to alter it and redistribute it 13 | ; freely, subject to the following restrictions: 14 | ; 15 | ; 1. The origin of this software must not be misrepresented; you must not 16 | ; claim that you wrote the original software. If you use this software 17 | ; in a product, an acknowledgment in the product documentation would be 18 | ; appreciated but is not required. 19 | ; 20 | ; 2. Altered source versions must be plainly marked as such, and must not be 21 | ; misrepresented as being the original software. 22 | ; 23 | ; 3. This notice may not be removed or altered from any source 24 | ; distribution. 25 | ; 26 | 27 | ;DEFINE OBSOLETED_F4 28 | ;DEFINE ALLOW_LDIR_UNROLLING 29 | ;DEFINE ALLOW_INLINE_GETBIT 30 | 31 | IFNDEF ALLOW_INLINE_GETBIT 32 | 33 | MACRO GET_BIT 34 | call getbit 35 | ENDM 36 | 37 | ELSE 38 | 39 | MACRO GET_BIT 40 | add a 41 | call z,getbit 42 | ENDM 43 | 44 | ENDIF 45 | 46 | dlzeee: 47 | ld a,080h 48 | dlze_lp1: 49 | ldi 50 | dlze_lp2: 51 | GET_BIT 52 | jr nc,dlze_lp1 53 | 54 | GET_BIT 55 | jr c,dlze_far 56 | 57 | ld c,0 58 | GET_BIT 59 | rl c 60 | GET_BIT 61 | rl c 62 | 63 | push hl 64 | ld l,(hl) 65 | ld h,-1 66 | 67 | dlze_copy: 68 | ld b,0 69 | inc c 70 | add hl,de 71 | IFNDEF ALLOW_LDIR_UNROLLING 72 | inc bc 73 | 74 | ldir 75 | ELSE 76 | ldir 77 | ldi 78 | ENDIF 79 | pop hl 80 | inc hl 81 | jr dlze_lp2 82 | 83 | dlze_far: 84 | ex af, af';' 85 | 86 | ld a,(hl) 87 | or 7 88 | rrca 89 | rrca 90 | rrca 91 | ld b,a 92 | 93 | ld a,(hl) 94 | inc hl 95 | ld c,(hl) 96 | 97 | and 7 98 | jr nz,dlze_skip 99 | 100 | inc hl 101 | or (hl) 102 | ret z 103 | IFNDEF OBSOLETED_F4 104 | ELSE 105 | dec a 106 | ENDIF 107 | 108 | dlze_skip: 109 | push hl 110 | ld l,c 111 | ld h,b 112 | ld c,a 113 | ex af, af';' 114 | jr dlze_copy 115 | 116 | getbit: 117 | IFNDEF ALLOW_INLINE_GETBIT 118 | add a 119 | ret nz 120 | ENDIF 121 | ld a,(hl) 122 | inc hl 123 | adc a 124 | ret 125 | 126 | -------------------------------------------------------------------------------- /lzee.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | LZE 4 | Copyright (C)1995,2008 GORRY. 5 | 6 | LZEe - LZE enhancement for Z80 by uniabis 7 | LZEee - LZE extra enhancement for Z80 by uniabis 8 | 9 | License:zlib license or original LZE license 10 | 11 | This software is provided 'as-is', without any express or implied 12 | warranty. In no event will the authors be held liable for any damages 13 | arising from the use of this software. 14 | 15 | Permission is granted to anyone to use this software for any purpose, 16 | including commercial applications, and to alter it and redistribute it 17 | freely, subject to the following restrictions: 18 | 19 | 1. The origin of this software must not be misrepresented; you must not 20 | claim that you wrote the original software. If you use this software 21 | in a product, an acknowledgment in the product documentation would be 22 | appreciated but is not required. 23 | 24 | 2. Altered source versions must be plainly marked as such, and must not be 25 | misrepresented as being the original software. 26 | 27 | 3. This notice may not be removed or altered from any source 28 | distribution. 29 | 30 | */ 31 | /********************************************************************************/ 32 | 33 | #define MACRO 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #ifdef _MSC_VER 41 | /* 42 | cl /O1 /EHs-c- /MD lzee.c 43 | */ 44 | 45 | void _except_handler4_common() 46 | { 47 | abort(); 48 | } 49 | 50 | void *memset(void *buf, int ch, size_t n) 51 | { 52 | unsigned char *ptr = buf; 53 | while (n-- > 0) 54 | { 55 | *(ptr++) = ch; 56 | } 57 | return buf; 58 | } 59 | 60 | void *memcpy(void *buf1, const void *buf2, size_t n) 61 | { 62 | unsigned char *d = buf1; 63 | const unsigned char *s = buf2; 64 | while (n-- > 0) 65 | { 66 | *(d++) = *(s++); 67 | } 68 | return buf1; 69 | } 70 | 71 | #endif 72 | 73 | #define BZCOMPATIBLE 1 /* 0 or 1 */ 74 | #define SPEED 1 /* 0 or 1 */ 75 | /*int Debug=0;*/ 76 | #define Debug 0 77 | /* #define DebugMacro(cond,p) if (cond) p */ 78 | #define DebugMacro(cond,p) 79 | 80 | #define N 16384 81 | #define F 256 82 | 83 | #if SPEED 84 | #define IDX 8192 85 | #else 86 | #define IDX 256 87 | #endif 88 | 89 | #define FMT_LZE 1 90 | #define FMT_LZEE 2 91 | #define FMT_LZEXE 3 92 | #define FMT_LZEEE_OBSOLETED_F4 4 93 | #define FMT_LZEEE_F5 5 94 | 95 | static int fmt = FMT_LZEE; 96 | 97 | FILE *infile; 98 | FILE *outfile; 99 | unsigned long outcount = 0; 100 | unsigned char text[N+F]; 101 | int son[N+1+IDX]; 102 | int dad[N+1+IDX]; 103 | int same[N]; 104 | #define NIL -1 105 | 106 | /********************************************************************************/ 107 | 108 | void error( char *mes ) 109 | { 110 | fputs( mes, stderr ); 111 | fputs( "\n", stderr ); 112 | exit(EXIT_FAILURE); 113 | } 114 | 115 | void init_tree( void ) 116 | { 117 | int i; 118 | 119 | for ( i=0; i99), printf( "Insert Node(%d)\n", r ) ); 138 | 139 | if ( samecount > 0 ) { 140 | same[r] = samecount; 141 | samecount--; 142 | } else { 143 | int i; 144 | unsigned char c; 145 | 146 | p = &text[r]; 147 | c = *(p++); 148 | for ( i=0; i99), printf( "dad[%d]=%d\n", N+1+k, r ) ); 168 | return; 169 | } 170 | son[r] = o; 171 | dad[o] = r; 172 | dad[r] = NIL; 173 | 174 | return; 175 | } 176 | 177 | void delete_node( int p ) 178 | { 179 | int k, q, r; 180 | 181 | DebugMacro( (Debug>99), printf( "Delete Node(%d)\n", p ) ); 182 | #if SPEED 183 | k = (text[p]<<5) ^ (text[p+1] ); 184 | #else 185 | k = text[p]; 186 | #endif 187 | r = N+1+k; 188 | q = dad[r]; 189 | do { 190 | DebugMacro( (Debug>99), printf( "%d\n", q ) ); 191 | if ( q < 0 ) return; /* if ( q == NIL ) return; */ 192 | if ( p == q ) { 193 | if ( dad[q] < 0 ) { /* if ( dad[q] == NIL ) { */ 194 | son[N+1+k] = son[q]; 195 | } else { 196 | son[dad[q]] = son[q]; 197 | } 198 | dad[r] = dad[q]; 199 | DebugMacro( (Debug>99), printf( "dad[%d]=%d\n", r, dad[q] ) ); 200 | dad[q] = NIL; 201 | return; 202 | } 203 | r = q; 204 | q = dad[q]; 205 | } while (!0); 206 | 207 | return; 208 | } 209 | 210 | int get_node( void ) 211 | { 212 | int r, o, m, n; 213 | int mlen; 214 | 215 | DebugMacro( (Debug>99), printf( "Get Node\n" ) ); 216 | mlen = 0; 217 | o = nodeo; 218 | r = noder; 219 | if ( o < 0 ) { /* if ( o == NIL ) { */ 220 | return (mlen); 221 | } 222 | 223 | n = same[r]; 224 | do { 225 | unsigned char *p, *q; 226 | int i; 227 | 228 | m = (r-o) & (N-1); 229 | if ( m > 8192 ) return (mlen); 230 | DebugMacro( (Debug>99), printf( "%d ", o ) ); 231 | i = mlen; 232 | p = &text[r+i+1]; 233 | q = &text[o+i+1]; 234 | if ( i ) { i--; if ( *(--p) != *(--q) ) continue; } 235 | if ( i ) { i--; if ( *(--p) != *(--q) ) continue; } 236 | if ( i ) { i--; if ( *(--p) != *(--q) ) continue; } 237 | if ( i ) { i--; if ( *(--p) != *(--q) ) continue; } 238 | i = n; 239 | if ( i > same[o] ) { 240 | i = same[o]; 241 | } 242 | p = &text[r+i]; 243 | q = &text[o+i]; 244 | if ( *(p++) != *(q++) ) continue; 245 | for ( ; iF ) i=F; 252 | DebugMacro( (Debug>99), printf( "%d\n", i ) ); 253 | if ( mlen < i ) { 254 | matchpos = m; 255 | mlen = i; 256 | if ( i >= F ) return (mlen); 257 | } 258 | } while ( (o=son[o]) >= 0 ); /* } while ( (o=son[o]) != NIL ); */ 259 | 260 | return (mlen); 261 | } 262 | 263 | /********************************************************************************/ 264 | 265 | unsigned int flags; 266 | int flagscnt; 267 | int codeptr, code2size; 268 | 269 | unsigned char code[256], code2[4]; 270 | 271 | void init_putencode( void ) 272 | { 273 | code[0] = 0; 274 | if (fmt == FMT_LZEXE) { 275 | code[1] = 0; 276 | codeptr = 2; 277 | } else { 278 | codeptr = 1; 279 | } 280 | flags = 0; 281 | flagscnt = 0; 282 | } 283 | 284 | void sub_putencode( unsigned char c ) 285 | { 286 | putc( c, outfile ); 287 | } 288 | 289 | static int bitrev( int b ) 290 | { 291 | return ((b & (1 << 7)) >> 7) 292 | | ((b & (1 << 6)) >> 5) 293 | | ((b & (1 << 5)) >> 3) 294 | | ((b & (1 << 4)) >> 1) 295 | | ((b & (1 << 3)) << 1) 296 | | ((b & (1 << 2)) << 3) 297 | | ((b & (1 << 1)) << 5) 298 | | ((b & (1 << 0)) << 7); 299 | } 300 | 301 | int putencode( int r ) 302 | { 303 | int size; 304 | unsigned int fl; 305 | int fc; 306 | int mlen; 307 | int mpos; 308 | 309 | fl = flags; 310 | fc = flagscnt; 311 | mlen = matchlen; 312 | mpos = matchpos; 313 | size = 0; 314 | if ( mlen < 2 ) { 315 | matchlen = 1; 316 | fl = (fl+fl)+((fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) ? 0 : 1); 317 | fc += 1; 318 | code2[0] = text[r]; 319 | code2size = 1; 320 | } else { 321 | if ( ( mlen < 6 ) && ( mpos < 257 ) ) { 322 | fl = (fl<<4)+(mlen-2)+((fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) ? 8 : 0); 323 | fc += 4; 324 | mpos = 256-mpos; 325 | code2[0] = (unsigned char) (mpos); 326 | code2size = 1; 327 | } else if ( mlen > 9 ) { 328 | fl = (fl<<2)+((fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) ? 1 | 2 : 1); 329 | fc += 2; 330 | mpos = 8192-mpos; 331 | if (fmt == FMT_LZEE || fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) { 332 | code2[0] = (unsigned char) (mpos>>5)&0xf8; 333 | code2[1] = (unsigned char) (mpos & 0xff); 334 | } else if ( fmt == FMT_LZEXE ) { 335 | code2[0] = (unsigned char) (mpos & 0xff); 336 | code2[1] = (unsigned char) (mpos>>5)&0xf8; 337 | } else if ( fmt == FMT_LZE ) { 338 | code2[0] = (unsigned char) (mpos>>5)&0xff; 339 | code2[1] = (unsigned char) (mpos<<3); 340 | } 341 | code2[2] = (unsigned char) (mlen-((fmt == FMT_LZEEE_F5) ? 2 : 1)); 342 | code2size = 3; 343 | } else if ( mlen > 2) { 344 | fl = (fl<<2)+((fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) ? 1 | 2 : 1); 345 | fc += 2; 346 | mpos = 8192-mpos; 347 | if (fmt == FMT_LZEE || fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) { 348 | code2[0] = (unsigned char) ((mpos>>5)&0xf8)|(mlen-2); 349 | code2[1] = (unsigned char) (mpos & 0xff); 350 | } else if ( fmt == FMT_LZEXE ) { 351 | code2[0] = (unsigned char) (mpos & 0xff); 352 | code2[1] = (unsigned char) ((mpos>>5)&0xf8)|(mlen-2); 353 | } else if ( fmt == FMT_LZE ) { 354 | code2[0] = (unsigned char) (mpos>>5)&0xff; 355 | code2[1] = (unsigned char) (mpos<<3)|(mlen-2); 356 | } 357 | code2size = 2; 358 | } else { 359 | matchlen = 1; 360 | fl = (fl+fl)+((fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) ? 0 : 1); 361 | fc += 1; 362 | code2[0] = text[r]; 363 | code2size = 1; 364 | } 365 | } 366 | if (fmt == FMT_LZEXE) { 367 | if ( fc >= 16 ) { 368 | int i; 369 | unsigned char *p; 370 | 371 | fc -= 16; 372 | p = &code[0]; 373 | p[0] = bitrev(fl>>(fc + 8)); 374 | p[1] = bitrev(fl>>(fc + 0)); 375 | DebugMacro( (Debug), printf( "output code=" ) ); 376 | for ( i=0; i>(16-fc)); 384 | } 385 | } else { 386 | if ( fc > 8 ) { 387 | int i; 388 | unsigned char *p; 389 | 390 | fc -= 8; 391 | p = &code[0]; 392 | *(p) = (fl>>fc); 393 | DebugMacro( (Debug), printf( "output code=" ) ); 394 | for ( i=0; i>(8-fc)); 402 | } 403 | } 404 | 405 | DebugMacro( (Debug), printf( "store code($%02X)=", codeptr ) ); 406 | { 407 | unsigned char *p, *q; 408 | int i; 409 | 410 | p = &code[codeptr]; 411 | q = &code2[0]; 412 | for ( i=0; i= 16 ) { 440 | flagscnt -= 16; 441 | code[0] = bitrev(flags>>(flagscnt + 8)); 442 | code[1] = bitrev(flags>>(flagscnt + 0)); 443 | DebugMacro( (Debug), printf( "output code=" ) ); 444 | for ( i=0; i>(16-flagscnt)); 452 | } 453 | } else { 454 | if ( flagscnt > 8 ) { 455 | flagscnt -= 8; 456 | code[0] = (flags>>flagscnt); 457 | DebugMacro( (Debug), printf( "output code=" ) ); 458 | for ( i=0; i>(8-flagscnt)); 466 | } 467 | } 468 | DebugMacro( (Debug), printf( "store code($%02X)=", codeptr ) ); 469 | for ( i=0; i 0 ) { 477 | flags<<=(16-flagscnt); 478 | code[0] = bitrev(flags>>(0 + 8)); 479 | code[1] = bitrev(flags>>(0 + 0)); 480 | } 481 | if ( codeptr > 2 ) { 482 | DebugMacro( (Debug), printf( "output code=" ) ); 483 | for ( i=0; i 0 ) { 492 | code[0] = (flags<<(8-flagscnt)); 493 | } 494 | if ( codeptr > 1 ) { 495 | DebugMacro( (Debug), printf( "output code=" ) ); 496 | for ( i=0; i len ) matchlen = len; 556 | outcount += putencode( r ); 557 | 558 | DebugMacro( (Debug), printf( "text[r]=$%02X r=%4d s=%4d matchpos=%4d matchlen=%4d\n", text[r], r, s, matchpos, matchlen ) ); 559 | 560 | matchpos = N+1; 561 | mlen = matchlen; 562 | for ( i=0; i printcount ) { 577 | printf( "%12lu\r", incount ); 578 | printcount += 1024*16; 579 | } 580 | while ( i++ < mlen ) { 581 | if ( ok_delete_node ) { 582 | delete_node(s); 583 | } else { 584 | if ( s == N-F-1 ) ok_delete_node = !0; 585 | } 586 | s = (s+1) & (N-1); 587 | r = (r+1) & (N-1); 588 | if ( --len ) { 589 | insert_node(r); 590 | } 591 | } 592 | } while ( len > 0 ); 593 | 594 | NoEncode:; 595 | outcount += finish_putencode(); 596 | printf( "In : %lu bytes\n", incount ); 597 | printf( "Out: %lu bytes\n", outcount ); 598 | if ( incount != 0 ) { 599 | cr = ( 1000 * outcount + (incount/2) ) / incount; 600 | printf( " Out/In: %lu.%03lu\n", cr/1000, cr%1000 ); 601 | } 602 | } 603 | 604 | void decode( unsigned long int size ) 605 | { 606 | unsigned int flags; 607 | int flagscnt; 608 | int i, j, k, r, c; 609 | unsigned int u; 610 | int bit; 611 | 612 | #define GetBit() \ 613 | if ( fmt == FMT_LZEXE ) { \ 614 | bit = (flags & 1); \ 615 | flags >>= 1; \ 616 | if ((--flagscnt)<=0) { \ 617 | if ((c = getc(infile)) == EOF ) goto Err; \ 618 | flags = c; \ 619 | if ((c = getc(infile)) == EOF ) goto Err; \ 620 | flags |= c << 8; \ 621 | flagscnt = 16; \ 622 | } \ 623 | } else { \ 624 | if ((--flagscnt)<0) { \ 625 | if ((c = getc(infile)) == EOF ) goto Err; \ 626 | DebugMacro( (Debug>99), printf( "\nGetBit($%02X) ", c ) ); \ 627 | flags = c; \ 628 | flagscnt += 8; \ 629 | } \ 630 | bit = ((flags<<=1) & 256 ); \ 631 | } 632 | 633 | flags = 0; 634 | flagscnt = 0; 635 | if ( fmt == FMT_LZEXE ) { 636 | if ((c = getc(infile)) == EOF ) goto Err; 637 | flags = c; 638 | if ((c = getc(infile)) == EOF ) goto Err; 639 | flags |= c << 8; 640 | flagscnt = 16; 641 | } 642 | r = N-F; 643 | #if BZCOMPATIBLE 644 | if ( fmt != FMT_LZEXE ) { 645 | if ((c = getc(infile)) == EOF ) goto Err; 646 | putc( c, outfile ); 647 | text[r++] = c; 648 | r &= (N-1); 649 | } 650 | #endif 651 | do { 652 | GetBit(); 653 | if (fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) bit = !bit; 654 | if (bit) { 655 | /* 1 */ 656 | if ((c = getc(infile)) == EOF ) break; 657 | DebugMacro( (Debug>99), printf( "1($%02X) ", c ) ); 658 | putc( c, outfile ); 659 | DebugMacro( (Debug), printf( "text[r]=$%02X r=%4d \n", c, r ) ); 660 | text[r++] = c; 661 | r &= (N-1); 662 | } else { 663 | GetBit(); 664 | if (bit) { 665 | /* 01 */ 666 | if ((i = getc(infile)) == EOF ) goto Err; 667 | if ((j = getc(infile)) == EOF ) goto Err; 668 | DebugMacro( (Debug>99), printf( "01($%02X,$%02X) ", i, j ) ); 669 | if (fmt == FMT_LZEE || fmt == FMT_LZEEE_OBSOLETED_F4 || fmt == FMT_LZEEE_F5) { 670 | u = ((i & 0xf8)<<5) | j; 671 | j = i & 0x07; 672 | } else if ( fmt == FMT_LZEXE ) { 673 | u = ((j & 0xf8)<<5) | i; 674 | j = j & 0x07; 675 | } else if ( fmt == FMT_LZE ) { 676 | u = ((i<<8) | j)>>3; 677 | j = j & 0x07; 678 | } else { goto Err; } 679 | if ( j == 0 ) { 680 | if ((j = getc(infile)) == EOF ) goto Err; 681 | DebugMacro( (Debug>99), printf( "($%02X) ", j ) ); 682 | if ( j==0 ) goto Quit; 683 | if ( fmt == FMT_LZEXE ) { 684 | if ( j==1 ) continue; 685 | } 686 | j += (fmt == FMT_LZEEE_F5) ? 2 : 1; 687 | } else { 688 | j += 2; 689 | } 690 | i = r-(8192-u); 691 | } else { 692 | /* 00 */ 693 | GetBit(); 694 | j = ( bit ? 2 : 0 ); 695 | GetBit(); 696 | j += ( bit ? 1 : 0 ); 697 | j += 2; 698 | if ((i = getc(infile)) == EOF ) goto Err; 699 | DebugMacro( (Debug>99), printf( "00($%02X) ", i ) ); 700 | i = r-(256-i); 701 | } 702 | for ( k=0; k 1 && (argv[1][0] | 0x20) == 'f') { 751 | int p = 1; 752 | char f; 753 | while ((f = argv[1][p++]) != 0) { 754 | switch ( f ) { 755 | case '1': 756 | fmt = FMT_LZE; 757 | break; 758 | case '2': 759 | fmt = FMT_LZEE; 760 | break; 761 | case '3': 762 | fmt = FMT_LZEXE; 763 | break; 764 | case '4': 765 | fmt = FMT_LZEEE_OBSOLETED_F4; 766 | break; 767 | case '5': 768 | fmt = FMT_LZEEE_F5; 769 | break; 770 | case 'R': 771 | case 'r': 772 | raw = 1; 773 | break; 774 | } 775 | } 776 | argv++; 777 | argc--; 778 | } 779 | 780 | if ( argc != 4 ) Usage(); 781 | infile = fopen( argv[2], "rb" ); 782 | if ( infile == NULL ) error( "Error: Open Input File" ); 783 | outfile = fopen( argv[3], "wb" ); 784 | if ( outfile == NULL ) error( "Error: Open Output File" ); 785 | if ( NULL != ( inbuf = malloc( 16*1024 ) ) ) { 786 | setvbuf( infile, inbuf, _IOFBF, 16*1024 ); 787 | } 788 | if ( NULL != ( outbuf = malloc( 16*1024 ) ) ) { 789 | setvbuf( outfile, outbuf, _IOFBF, 16*1024 ); 790 | } 791 | switch( *argv[1] ) { 792 | case 'E': 793 | if ( !raw ) { 794 | fseek( infile, 0L, SEEK_END ); 795 | size = ftell( infile ); 796 | putc( (int)((size >> 24) & 0xff), outfile ); 797 | putc( (int)((size >> 16) & 0xff), outfile ); 798 | putc( (int)((size >> 8) & 0xff), outfile ); 799 | putc( (int)((size >> 0) & 0xff), outfile ); 800 | rewind( infile ); 801 | } 802 | case 'e': 803 | encode(); 804 | break; 805 | case 'D': 806 | if ( !raw ) { 807 | size = (((unsigned long)getc( infile )) << 24); 808 | size |= (((unsigned long)getc( infile )) << 16); 809 | size |= (((unsigned long)getc( infile )) << 8); 810 | size |= (((unsigned long)getc( infile )) << 0); 811 | } 812 | case 'd': 813 | decode( size ); 814 | break; 815 | } 816 | fclose( infile ); 817 | fclose( outfile ); 818 | printf( "Time: %fs\n", ((double)clock())/CLK_TCK ); 819 | return (EXIT_SUCCESS); 820 | } 821 | 822 |  -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # LZEe - LZE enhancement for Z80 2 | 3 | LZE 4 | Copyright (C)1995,2008 GORRY. 5 | 6 | Porting for Z80 by Kei Moroboshi 2017/SEP. 7 | 8 | LZEe - LZE enhancement for Z80 by uniabis 9 | LZEee - LZE extra enhancement for Z80 by uniabis 10 | 11 | License:zlib license or original LZE license 12 | 13 | ## Description 14 | 15 | [LZEe](https://github.com/uniabis/lzee) is file compressor/decompressor derived from [LZE](http://gorry.haun.org/pw/?lze). 16 | 17 | LZEe is designed to be effective with fast depacking on Z80 machines. 18 | 19 | ## Usage 20 | 21 | ``` 22 | Usage: lzee [option] {command} {infile} {outfile} 23 | 24 | {command} 25 | e : Encode without header 26 | E : Encode with header 27 | d : Decode without header 28 | D : Decode with header 29 | 30 | [option] 31 | f[format]... 32 | 33 | [format] 34 | 1 : lze 35 | 2 : LZEe(default) 36 | 3 : LZEXE 37 | 4 : LZEee f4(obsoleted) 38 | 5 : LZEee f5 39 | r : Force without header 40 | 41 | header is unpacked size in big endian 32bit integer 42 | ``` 43 | 44 | 45 | ## [Benchmarks](https://github.com/uniabis/z80depacker) 46 | 47 | ### Compression rate 48 | 49 | test data:DEOCM-PLD-CV BIOS(16x16KB) 50 | 51 | |Packer|ALL|MEGASDHC.B00|MEGASDHC.B01|MEGASDHC.B02|MEGASDHC.B03|MSX2MAIN.B00|MSX2MAIN.B01|MSXMUSIC.B00|MSX2EXT.B00|KANJJ1.B00|KANJJ1.B01|KANJJ1.B02|KANJJ1.B03|KANJJ1.B04|KANJJ1.B05|KANJJ1.B06|KANJJ1.B07| 52 | |---|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:|---:| 53 | |ApLib
(OaPACK)|161,422
(61.58%)|9,367
(57.17%)|4,926
(30.07%)|12,594
(76.87%)|12,340
(75.32%)|12,835
(78.34%)|13,579
(82.88%)|10,048
(61.33%)|12,361
(75.45%)|6,222
(37.98%)|4,090
(24.96%)|10,834
(66.13%)|10,642
(64.95%)|10,519
(64.20%)|10,453
(63.80%)|10,815
(66.01%)|9,797
(59.80%)| 54 | |Bitbuster Extreme|172,080
(65.64%)|9,830
(60.00%)|5,133
(31.33%)|13,188
(80.49%)|12,856
(78.47%)|13,293
(81.13%)|14,088
(85.99%)|10,551
(64.40%)|13,013
(79.43%)|6,683
(40.79%)|4,507
(27.51%)|11,785
(71.93%)|11,599
(70.79%)|11,542
(70.45%)|11,493
(70.15%)|11,778
(71.89%)|10,741
(65.56%)| 55 | |Exomizer2
(-P0)|160,011
(61.04%)|9,373
(57.21%)|4,902
(29.92%)|12,494
(76.26%)|12,297
(75.05%)|12,740
(77.76%)|13,402
(81.80%)|10,068
(61.45%)|12,351
(75.38%)|6,097
(37.21%)|3,975
(24.26%)|10,688
(65.23%)|10,510
(64.15%)|10,415
(63.57%)|10,348
(63.16%)|10,650
(65.00%)|9,701
(59.21%)| 56 | |Exomizer3
(-P7)|160,007
(61.04%)|9,373
(57.21%)|4,902
(29.92%)|12,494
(76.26%)|12,297
(75.05%)|12,739
(77.75%)|13,402
(81.80%)|10,068
(61.45%)|12,351
(75.38%)|6,097
(37.21%)|3,974
(24.26%)|10,688
(65.23%)|10,509
(64.14%)|10,415
(63.57%)|10,347
(63.15%)|10,650
(65.00%)|9,701
(59.21%)| 57 | |hruST
(oh1c -r)|162,217
(61.88%)|9,369
(57.18%)|4,895
(29.88%)|12,563
(76.68%)|12,282
(74.96%)|12,768
(77.93%)|13,454
(82.12%)|10,079
(61.52%)|12,331
(75.26%)|6,434
(39.27%)|4,230
(25.82%)|10,940
(66.77%)|10,753
(65.63%)|10,679
(65.18%)|10,597
(64.68%)|10,906
(66.56%)|9,937
(60.65%)| 58 | |lz4
(lz4ultra)|191,416
(73.02%)|10,833
(66.12%)|5,794
(35.36%)|14,742
(89.98%)|14,290
(87.22%)|14,837
(90.56%)|15,448
(94.29%)|11,630
(70.98%)|14,578
(88.98%)|8,088
(49.37%)|5,431
(33.15%)|13,003
(79.36%)|12,732
(77.71%)|12,673
(77.35%)|12,535
(76.51%)|12,972
(79.17%)|11,830
(72.20%)| 59 | |lz48|198,227
(75.62%)|10,717
(65.41%)|5,752
(35.11%)|14,588
(89.04%)|14,250
(86.98%)|14,268
(87.08%)|15,305
(93.41%)|12,121
(73.98%)|14,074
(85.90%)|8,167
(49.85%)|5,532
(33.76%)|14,290
(87.22%)|14,024
(85.60%)|13,960
(85.21%)|13,952
(85.16%)|14,179
(86.54%)|13,048
(79.64%)| 60 | |lz49|195,027
(74.40%)|10,628
(64.87%)|5,559
(33.93%)|14,512
(88.57%)|14,030
(85.63%)|14,196
(86.65%)|15,254
(93.10%)|11,980
(73.12%)|13,969
(85.26%)|7,824
(47.75%)|5,240
(31.98%)|13,985
(85.36%)|13,761
(83.99%)|13,717
(83.72%)|13,674
(83.46%)|13,920
(84.96%)|12,778
(77.99%)| 61 | |LZE
(lzee f1r)|174,118
(66.42%)|10,088
(61.57%)|5,459
(33.32%)|13,468
(82.20%)|13,183
(80.46%)|13,694
(83.58%)|14,385
(87.80%)|10,826
(66.08%)|13,299
(81.17%)|7,023
(42.86%)|4,660
(28.44%)|11,692
(71.36%)|11,489
(70.12%)|11,369
(69.39%)|11,279
(68.84%)|11,630
(70.98%)|10,574
(64.54%)| 62 | |LZEee
(lzee f5)|174,118
(66.42%)|10,088
(61.57%)|5,459
(33.32%)|13,468
(82.20%)|13,183
(80.46%)|13,694
(83.58%)|14,385
(87.80%)|10,826
(66.08%)|13,299
(81.17%)|7,023
(42.86%)|4,660
(28.44%)|11,692
(71.36%)|11,489
(70.12%)|11,369
(69.39%)|11,279
(68.84%)|11,630
(70.98%)|10,574
(64.54%)| 63 | |LZEXE
(lzee f3)|174,132
(66.43%)|10,089
(61.58%)|5,460
(33.33%)|13,469
(82.21%)|13,184
(80.47%)|13,695
(83.59%)|14,386
(87.81%)|10,828
(66.09%)|13,300
(81.18%)|7,023
(42.86%)|4,660
(28.44%)|11,692
(71.36%)|11,490
(70.13%)|11,370
(69.40%)|11,280
(68.85%)|11,631
(70.99%)|10,575
(64.54%)| 64 | |lzsa1
(-f1)|182,295
(69.54%)|10,338
(63.10%)|5,391
(32.90%)|14,043
(85.71%)|13,703
(83.64%)|14,087
(85.98%)|14,892
(90.89%)|11,047
(67.43%)|13,719
(83.73%)|7,316
(44.65%)|4,804
(29.32%)|12,544
(76.56%)|12,252
(74.78%)|12,189
(74.40%)|12,075
(73.70%)|12,507
(76.34%)|11,388
(69.51%)| 65 | |lzsa2
(-f2)|167,502
(63.90%)|9,670
(59.02%)|5,091
(31.07%)|13,125
(80.11%)|12,803
(78.14%)|13,291
(81.12%)|14,057
(85.80%)|10,339
(63.10%)|12,806
(78.16%)|6,421
(39.19%)|4,249
(25.93%)|11,288
(68.90%)|11,056
(67.48%)|10,936
(66.75%)|10,848
(66.21%)|11,275
(68.82%)|10,247
(62.54%)| 66 | |megalz|167,609
(63.94%)|9,718
(59.31%)|5,124
(31.27%)|12,965
(79.13%)|12,660
(77.27%)|13,072
(79.79%)|13,917
(84.94%)|10,407
(63.52%)|12,833
(78.33%)|6,514
(39.76%)|4,320
(26.37%)|11,362
(69.35%)|11,161
(68.12%)|11,016
(67.24%)|11,012
(67.21%)|11,281
(68.85%)|10,247
(62.54%)| 67 | |pletter|167,494
(63.89%)|9,706
(59.24%)|5,083
(31.02%)|12,945
(79.01%)|12,700
(77.51%)|13,205
(80.60%)|13,909
(84.89%)|10,466
(63.88%)|12,858
(78.48%)|6,511
(39.74%)|4,269
(26.06%)|11,340
(69.21%)|11,105
(67.78%)|10,992
(67.09%)|10,908
(66.58%)|11,252
(68.68%)|10,245
(62.53%)| 68 | |shrinkler|153,168
(58.43%)|8,984
(54.83%)|4,680
(28.56%)|12,148
(74.15%)|11,916
(72.73%)|12,276
(74.93%)|13,100
(79.96%)|9,536
(58.20%)|11,820
(72.14%)|5,728
(34.96%)|3,700
(22.58%)|10,212
(62.33%)|10,020
(61.16%)|9,876
(60.28%)|9,808
(59.86%)|10,148
(61.94%)|9,216
(56.25%)| 69 | |shrinkler(NP)|152,324
(58.11%)|8,912
(54.39%)|4,644
(28.34%)|12,092
(73.80%)|11,844
(72.29%)|12,176
(74.32%)|13,020
(79.47%)|9,516
(58.08%)|11,772
(71.85%)|5,664
(34.57%)|3,656
(22.31%)|10,164
(62.04%)|9,980
(60.91%)|9,840
(60.06%)|9,756
(59.55%)|10,116
(61.74%)|9,172
(55.98%)| 70 | |zx7|170,296
(64.96%)|9,781
(59.70%)|5,080
(31.01%)|13,104
(79.98%)|12,784
(78.03%)|13,224
(80.71%)|14,021
(85.58%)|10,515
(64.18%)|12,943
(79.00%)|6,532
(39.87%)|4,401
(26.86%)|11,623
(70.94%)|11,436
(69.80%)|11,337
(69.20%)|11,331
(69.16%)|11,612
(70.87%)|10,572
(64.53%)| 71 | |zx7b|170,425
(65.01%)|9,762
(59.58%)|5,091
(31.07%)|13,103
(79.97%)|12,810
(78.19%)|13,248
(80.86%)|14,002
(85.46%)|10,495
(64.06%)|12,964
(79.13%)|6,591
(40.23%)|4,424
(27.00%)|11,629
(70.98%)|11,451
(69.89%)|11,327
(69.13%)|11,341
(69.22%)|11,601
(70.81%)|10,586
(64.61%)| 72 | |zx7mini
(back)|190,540
(72.69%)|10,580
(64.58%)|5,702
(34.80%)|14,358
(87.63%)|14,064
(85.84%)|14,015
(85.54%)|15,267
(93.18%)|12,073
(73.69%)|13,874
(84.68%)|7,390
(45.10%)|4,921
(30.04%)|13,428
(81.96%)|13,182
(80.46%)|13,091
(79.90%)|13,039
(79.58%)|13,311
(81.24%)|12,245
(74.74%)| 73 | 74 | 75 | ### Decompression speed 76 | 77 | test data:DEOCM-PLD-CV BIOS(16x16KB) 78 | 79 | |packer|unpacker|unpacker size|packed size|unpacking clocks| 80 | |---|---|---:|---:|---:| 81 | |ApLib|aplib156b| 156| 161,422
(61.57%)| 59,168,483
(LDIR x 9.81)| 82 | |ApLib|aplib247b| 249| 161,422
(61.57%)| 35,485,949
(LDIR x 5.88)| 83 | |ApLib|aplib247b_180_minimal| 152| 161,422
(61.57%)| 44,514,579
(LDIR x 7.38)| 84 | |ApLib|aplib247b_180_small| 171| 161,422
(61.57%)| 34,169,981
(LDIR x 5.66)| 85 | |ApLib|aplib247b_180_fast| 234| 161,422
(61.57%)| 32,552,096
(LDIR x 5.39)| 86 | |ApLib|unaplib_fast| 235| 161,422
(61.57%)| 29,350,495
(LDIR x 4.86)| 87 | |ApLib|unaplib_fast_180| 233| 161,422
(61.57%)| 29,636,463
(LDIR x 4.91)| 88 | |ApLib|unaplib_small| 139| 161,422
(61.57%)| 45,350,252
(LDIR x 7.52)| 89 | |BitbusterExtreme|debitbust| 89| 172,080
(65.64%)| 35,875,562
(LDIR x 5.95)| 90 | |BitbusterExtreme|debitbustp1| 88| 172,080
(65.64%)| 32,099,423
(LDIR x 5.32)| 91 | |BitbusterExtreme|debitbustp2| 96| 172,080
(65.64%)| 26,884,565
(LDIR x 4.45)| 92 | |Exomizer2|deexo| 169| 160,011
(61.03%)| 108,490,817
(LDIR x 17.99)| 93 | |Exomizer2|deexo_180| 166| 160,011
(61.03%)| 108,490,229
(LDIR x 17.99)| 94 | |Exomizer2|deexo_180_fast_jp| 176| 160,011
(61.03%)| 92,969,945
(LDIR x 15.41)| 95 | |Exomizer2|deexoopt_f3_180_p0| 242| 160,011
(61.03%)| 74,159,660
(LDIR x 12.29)| 96 | |Exomizer3|deexo3p7| 176| 160,007
(61.03%)| 82,034,254
(LDIR x 13.60)| 97 | |Exomizer3|deexo3p7_fast_jp| 181| 160,007
(61.03%)| 70,324,722
(LDIR x 11.66)| 98 | |Exomizer3|deexoopt_p7| 219| 160,007
(61.03%)| 63,745,458
(LDIR x 10.57)| 99 | |Exomizer3|deexoopt_f3_p7| 212| 160,007
(61.03%)| 61,265,322
(LDIR x 10.16)| 100 | |Exomizer3|deexoopt_f3_180_p7| 219| 160,007
(61.03%)| 63,774,934
(LDIR x 10.57)| 101 | |Exomizer3|deexo3| 191| 160,007
(61.03%)| 68,910,122
(LDIR x 11.42)| 102 | |hrust|dehrust_ix| 234| 162,217
(61.88%)| 45,520,962
(LDIR x 7.54)| 103 | |hrust|dehrust_ix_232b| 232| 162,217
(61.88%)| 45,413,861
(LDIR x 7.53)| 104 | |hrust|dehrust_hl| 226| 162,217
(61.88%)| 44,726,210
(LDIR x 7.41)| 105 | |hrust|dehrust_stk| 209| 162,217
(61.88%)| 41,277,317
(LDIR x 6.84)| 106 | |lz4|lz4dec| 97| 191,416
(73.01%)| 10,893,051
(LDIR x 1.80)| 107 | |lz4|unlz4_spke| 103| 191,416
(73.01%)| 10,031,857
(LDIR x 1.66)| 108 | |lz4|unlz4_spke_fast| 96| 191,416
(73.01%)| 9,650,674
(LDIR x 1.60)| 109 | |lz4|unlz4_spke_small| 65| 191,416
(73.01%)| 9,970,571
(LDIR x 1.65)| 110 | |lz48|lz48decrunch\_v006\_| 70| 198,227
(75.61%)| 9,987,125
(LDIR x 1.65)| 111 | |lz48|lz48decrunch_v006__180| 71| 198,227
(75.61%)| 9,503,964
(LDIR x 1.57)| 112 | |lz49|lz49decrunch_v001| 106| 195,027
(74.39%)| 11,349,204
(LDIR x 1.88)| 113 | |lz49|lz49decrunch_v001_180| 101| 195,027
(74.39%)| 11,002,608
(LDIR x 1.82)| 114 | |lze|lzdec| 119| 174,118
(66.42%)| 21,831,226
(LDIR x 3.62)| 115 | |lze|dlze_fast| 90| 174,118
(66.42%)| 17,122,936
(LDIR x 2.83)| 116 | |lze|dlze_small| 79| 174,118
(66.42%)| 21,975,061
(LDIR x 3.64)| 117 | |lzeee|dlzeee_fast| 87| 174,118
(66.42%)| 15,771,965
(LDIR x 2.61)| 118 | |lzeee|dlzeee_fast2| 97| 174,118
(66.42%)| 15,533,041
(LDIR x 2.57)| 119 | |lzeee|dlzeee_small| 72| 174,118
(66.42%)| 21,330,646
(LDIR x 3.53)| 120 | |lzexe|z80unlze| 156| 174,132
(66.42%)| 25,663,296
(LDIR x 4.25)| 121 | |lzexe|z80unlzep2| 133| 174,132
(66.42%)| 23,882,407
(LDIR x 3.96)| 122 | |lzexe|z80unlze_small| 112| 174,132
(66.42%)| 31,984,416
(LDIR x 5.30)| 123 | |lzexe|z80unlzep2_small| 88| 174,132
(66.42%)| 30,313,875
(LDIR x 5.02)| 124 | |lzsa1|unlzsa1_fast| 109| 182,295
(69.54%)| 10,141,189
(LDIR x 1.68)| 125 | |lzsa1|unlzsa1_small| 67| 182,295
(69.54%)| 11,309,112
(LDIR x 1.87)| 126 | |lzsa2|unlzsa2_fast| 216| 167,502
(63.89%)| 15,810,936
(LDIR x 2.62)| 127 | |lzsa2|unlzsa2_fast_180| 214| 167,502
(63.89%)| 16,079,288
(LDIR x 2.66)| 128 | |lzsa2|unlzsa2_small| 139| 167,502
(63.89%)| 17,997,952
(LDIR x 2.98)| 129 | |lzsa2|unlzsa2_small_180| 137| 167,502
(63.89%)| 18,266,304
(LDIR x 3.02)| 130 | |MegaLZ|megalz_dec40| 110| 167,609
(63.93%)| 45,653,296
(LDIR x 7.57)| 131 | |MegaLZ|unmegalz_fast_v2| 233| 167,609
(63.93%)| 20,775,177
(LDIR x 3.44)| 132 | |MegaLZ|unmegalz_fast_v2p1| 229| 167,609
(63.93%)| 20,533,028
(LDIR x 3.40)| 133 | |MegaLZ|unmegalz_small_v2| 92| 167,609
(63.93%)| 32,642,661
(LDIR x 5.41)| 134 | |Pletter|unpletter| 170| 167,494
(63.89%)| 28,812,190
(LDIR x 4.77)| 135 | |Pletter|unpletter_180| 146| 167,494
(63.89%)| 26,619,594
(LDIR x 4.41)| 136 | |Shrinkler|shrinkler_recall_209| 209| 153,168
(58.42%)| 2,648,202,619
(LDIR x 439.21)| 137 | |Shrinkler|shrinkler_recall_209_r800_rom| 207| 153,168
(58.42%)| 2,636,690,003
(LDIR x 437.30)| 138 | |Shrinkler(NP)|deshrink_np| 202| 152,324
(58.10%)| 2,643,754,822
(LDIR x 438.47)| 139 | |Shrinkler(NP)|deshrink_np_r800| 201| 152,324
(58.10%)| 2,632,444,897
(LDIR x 436.60)| 140 | |zx7|dzx7_lom_v1| 214| 170,296
(64.96%)| 23,446,544
(LDIR x 3.88)| 141 | |zx7|dzx7_lom_v1p1| 198| 170,296
(64.96%)| 22,383,853
(LDIR x 3.71)| 142 | |zx7|dzx7_turbo| 88| 170,296
(64.96%)| 27,346,595
(LDIR x 4.53)| 143 | |zx7|dzx7_standard| 69| 170,296
(64.96%)| 36,700,476
(LDIR x 6.08)| 144 | |zx7b|dzx7b_fast| 191| 170,425
(65.01%)| 20,907,617
(LDIR x 3.46)| 145 | |zx7b|dzx7b_fast_r800| 184| 170,425
(65.01%)| 20,659,431
(LDIR x 3.42)| 146 | |zx7b|dzx7b_slow| 64| 170,425
(65.01%)| 33,688,687
(LDIR x 5.58)| 147 | |zx7b|dzx7b_slow_r800| 64| 170,425
(65.01%)| 33,688,687
(LDIR x 5.58)| 148 | |zx7mini|dzx7mini| 39| 190,540
(72.68%)| 20,556,427
(LDIR x 3.40)| 149 | 150 | 151 | ## Original readme 152 | 153 | ``` 154 | ------------------------------------------------------------------------ 155 | lze LZSS亜種データ圧縮/展開ツール 156 | ------------------------------------------------------------------------ 157 | 158 | 159 | ------------------------------------------------------------------------ 160 | ■ 履歴 161 | 162 | ・20080228a 163 | 最初のバージョン。 164 | 165 | ------------------------------------------------------------------------ 166 | ■ 概要 167 | 168 | LZSS亜種圧縮/展開アルゴリズムにより作られたデータ圧縮/展開ツールとデコー 169 | ダです。 170 | デコーダはアセンブラでわずか100ステップ程度で書かれており、非常に高速に 171 | 動作します。 172 | 圧縮データはzipで圧縮した場合の20~30%増程度となります。 173 | 174 | ------------------------------------------------------------------------ 175 | ■ インストール方法 176 | 177 | win32コマンドラインツールとそのソースであり、インストールは特に必要あり 178 | ません。 179 | 180 | ------------------------------------------------------------------------ 181 | ■ 使用方法 182 | 183 | lze.exe e infile outfile 184 | infileを圧縮してoutfileへ出力します。 185 | 186 | lze.exe d infile outfile 187 | 圧縮済みのinfileを展開してoutfileへ出力します。 188 | 189 | lzed.exe infile outfile 190 | 圧縮済みのinfileを展開してoutfileへ出力します。 191 | lzedec.cを使用します。 192 | 193 | ------------------------------------------------------------------------ 194 | ■ ソースと歴史的経緯 195 | 196 | lzedec.c Cによるデコーダ 197 | lzedec_8086.asm MASM(8086)アセンブラによるデコーダ 198 | 入力・出力ともに1セグメント内のみ有効 199 | lzedec_x68k.has has(MC68000)アセンブラによるデコーダ 200 | 201 | デコーダの対象CPUが古いものしかないのは、歴史的理由によるものです。 202 | 203 | lzeの圧縮方式は、TONBE氏のX68000用汎用データ圧縮プログラム「BZ.X」を元に 204 | 作られています。 205 | TONBE氏のBZ.Xは、F&I氏のX68000用実行ファイル圧縮プログラム「lzx」を元に 206 | 作られています。 207 | F&I氏のlzxは、Fabrice Bellard氏のMS-DOS用実行ファイル圧縮プログラム 208 | 「LZEXE」を元に作られています。 209 | これらはいずれもソースコードが公開されておらず、リバースエンジニアリング 210 | によって作られ、実行ファイルのみが公開されてきました。 211 | 212 | 本lzeは、当方の学習用および実務用として1995年に作られたものですが、これ 213 | らの圧縮方式をソースコードとして残しておくために公開するものです。 214 | 215 | ------------------------------------------------------------------------ 216 | ■ その他 217 | 218 | このプログラムおよびソースコードは、一切の制限なく使用・改造・配布等を 219 | 行うことができます。 220 | 221 | -- 222 | Hiroaki GOTO as GORRY : 後藤 浩昭 223 | E-mail: gorry@hauN.org 224 | Homepage: http://GORRY.hauN.org/ 225 | 226 | [EOF] 227 | ``` 228 | --------------------------------------------------------------------------------