2 * xDMS v1.3 - Portable DMS archive unpacker - Public Domain
3 * Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
5 * Main decompression functions used in MEDIUM mode
11 #define MBITMASK 0x3fff
13 UWORD
Unpack_MEDIUM (struct xdms_data
*xdms
, UBYTE
*in
, UBYTE
*out
, UWORD origsize
) {
14 UWORD medium_text_loc
= xdms
->medium_text_loc
;
15 UBYTE
*text
= xdms
->text
;
21 outend
= out
+origsize
;
22 while (out
< outend
) {
25 *out
++ = text
[medium_text_loc
++ & MBITMASK
] = (UBYTE
)GETBITS(8);
29 c
= GETBITS(8); DROPBITS(8);
30 j
= (UWORD
)(d_code
[c
]+3);
32 c
= (UWORD
)(((c
<< u
) | GETBITS(u
)) & 0xff); DROPBITS(u
);
34 c
= (UWORD
)((d_code
[c
] << 8) | (((c
<< u
) | GETBITS(u
)) & 0xff)); DROPBITS(u
);
35 i
= (UWORD
)(medium_text_loc
- c
- 1);
37 while(j
--) *out
++ = text
[medium_text_loc
++ & MBITMASK
] = text
[i
++ & MBITMASK
];
41 xdms
->medium_text_loc
= (UWORD
)((medium_text_loc
+66) & MBITMASK
);