I'll try to show what I mean with some example data. So take the following data, I am using quotes because code tags destroy the color settings.
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Following is normal LZSS encoding. Everybody who knows LZSS already knows how this works. There are many ways to implement it but I'm just trying to show one way that is pretty clear to see. The red numbers are flagged bits which tell where the control codes are. They are mostly 00 because there are no control codes until the end where the flagged bits are 01 because there is 1 control code after it. The control codes are green and just tell it to write the last 16 bytes again.
00 00 01 02 03 04 05 06 07 00 08 09 0A 0B 0C 0D 0E 0F
00 10 11 12 13 14 15 16 17 00 18 19 1A 1B 1C 1D 1E 1F
00 20 21 22 23 24 25 26 27 00 28 29 2A 2B 2C 2D 2E 2F
00 30 31 32 33 34 35 36 37 00 38 39 3A 3B 3C 3D 3E 3F
00 40 41 42 43 44 45 46 47 00 48 49 4A 4B 4C 4D 4E 4F
01 6F B0
This is my alternate way. The first byte is the pointer colored blue. It's 50 so that means write the next 50 bytes uncompressed then the control code. The total savings here is 10 bytes.
50 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
6F B0
Here is another example with greater compression prospects.
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
Same thing here except the final flagged bits are 07 which is 0000 0111 in binary so there are 3 control codes, 2 bytes each.
00 00 01 02 03 04 05 06 07 00 08 09 0A 0B 0C 0D 0E 0F
00 10 11 12 13 14 15 16 17 00 18 19 1A 1B 1C 1D 1E 1F
00 20 21 22 23 24 25 26 27 00 28 29 2A 2B 2C 2D 2E 2F
00 30 31 32 33 34 35 36 37 00 38 39 3A 3B 3C 3D 3E 3F
00 40 41 42 43 44 45 46 47 00 48 49 4A 4B 4C 4D 4E 4F
07 6F B0 FF F0 5F 80
Here is how mine handles it. Because the next control code will be followed by 2 or more control codes bit 7 will be flagged to tell it to use flagged bits. So subtract 80 to remove bit 7 and the total number of uncompressed bytes is 50. Then the red 07 are the flagged bits telling it to use the next 3 control codes of 2 bytes each. The total savings is 9 bytes here
D0 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
07 6F B0 FF F0 5F 80