Check for SYS/GL during library init. Reason is that
[AROS.git] / workbench / devs / diskimage / dms / u_medium.c
blob4cb5fe669f28f01b673b6950199ec2e10d57e810
1 /*
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
7 */
9 #include "xdms.h"
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;
16 UWORD i, j, c;
17 UBYTE u, *outend;
19 INITBITBUF(in);
21 outend = out+origsize;
22 while (out < outend) {
23 if (GETBITS(1)!=0) {
24 DROPBITS(1);
25 *out++ = text[medium_text_loc++ & MBITMASK] = (UBYTE)GETBITS(8);
26 DROPBITS(8);
27 } else {
28 DROPBITS(1);
29 c = GETBITS(8); DROPBITS(8);
30 j = (UWORD)(d_code[c]+3);
31 u = d_len[c];
32 c = (UWORD)(((c << u) | GETBITS(u)) & 0xff); DROPBITS(u);
33 u = d_len[c];
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);
43 return 0;