]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
imported winuaesrc2020b11b.zip
authorToni Wilen <twilen@winuae.net>
Sat, 13 Feb 2010 12:57:53 +0000 (14:57 +0200)
committerToni Wilen <twilen@winuae.net>
Mon, 22 Feb 2010 20:17:35 +0000 (22:17 +0200)
17 files changed:
archivers/dms/cdata.h
archivers/dms/crc_csum.cpp
archivers/dms/crc_csum.h
archivers/dms/getbits.cpp
archivers/dms/getbits.h
archivers/dms/maketbl.cpp
archivers/dms/maketbl.h
archivers/dms/pfile.cpp
archivers/dms/u_deep.cpp
archivers/dms/u_deep.h
archivers/dms/u_heavy.cpp
archivers/dms/u_heavy.h
archivers/dms/u_init.cpp
archivers/dms/u_medium.cpp
archivers/dms/u_medium.h
archivers/dms/u_quick.cpp
archivers/dms/u_quick.h

index b5e77e09609b96a386d81c4f725a9755ae9363f9..4de9b9f99f0e807819c9d2199b2eddb5c0f34770 100644 (file)
@@ -75,6 +75,6 @@
 #define DIR_SEPARATORS ":\\/"
 
 
-extern UCHAR *text;
-
+extern UCHAR *dms_text;
+extern USHORT dms_lastlen, dms_np;
 
index 70337c620e39cddb16a33c04d6636d94c6e84c6d..8147c5b5fff56e6848a7a710d82db39a1111517b 100644 (file)
@@ -14,7 +14,7 @@
 
 
 
-USHORT Calc_CheckSum(UCHAR *mem, ULONG size){
+USHORT dms_Calc_CheckSum(UCHAR *mem, ULONG size){
        USHORT u=0;
 
        while(size--) u += *mem++;
@@ -23,7 +23,7 @@ USHORT Calc_CheckSum(UCHAR *mem, ULONG size){
 
 
 
-USHORT CreateCRC(UCHAR* mem, ULONG size ){
+USHORT dms_CreateCRC(UCHAR* mem, ULONG size ){
        static USHORT CRCTab[256]={
                0x0000,0xC0C1,0xC181,0x0140,0xC301,0x03C0,0x0280,0xC241,
                0xC601,0x06C0,0x0780,0xC741,0x0500,0xC5C1,0xC481,0x0440,
index 0fa92f5052fe1977962ecc9d70780c72adc4bf68..4809fa5b662e8acf4c0ec2d40fc057cb7e502fe8 100644 (file)
@@ -1,4 +1,4 @@
 
-USHORT Calc_CheckSum(UCHAR *, ULONG);
-USHORT CreateCRC(UCHAR *, ULONG);
+USHORT dms_Calc_CheckSum(UCHAR *, ULONG);
+USHORT dms_CreateCRC(UCHAR *, ULONG);
 
index bfaa835cbfb81fe9f9e547af5f8e09c4269cc7e6..e972c7b38c29dc75520e9b4b68688fc18183625d 100644 (file)
@@ -10,7 +10,7 @@
 #include "getbits.h"
 
 
-ULONG mask_bits[]={
+ULONG dms_mask_bits[]={
        0x000000L,0x000001L,0x000003L,0x000007L,0x00000fL,0x00001fL,
        0x00003fL,0x00007fL,0x0000ffL,0x0001ffL,0x0003ffL,0x0007ffL,
        0x000fffL,0x001fffL,0x003fffL,0x007fffL,0x00ffffL,0x01ffffL,
@@ -19,15 +19,15 @@ ULONG mask_bits[]={
 };
 
 
-UCHAR *indata, bitcount;
-ULONG bitbuf;
+UCHAR *dms_indata, dms_bitcount;
+ULONG dms_bitbuf;
 
 
 
 void initbitbuf(UCHAR *in){
-       bitbuf = 0;
-       bitcount = 0;
-       indata = in;
+       dms_bitbuf = 0;
+       dms_bitcount = 0;
+       dms_indata = in;
        DROPBITS(0);
 }
 
index f0c5adde4554dc40ae262a168156539092ce27f4..d6224ec1db80c57f78cff9b6108cbf37b1236091 100644 (file)
@@ -1,9 +1,9 @@
 
-extern ULONG mask_bits[], bitbuf;
-extern UCHAR *indata, bitcount;
+extern ULONG dms_mask_bits[], dms_bitbuf;
+extern UCHAR *dms_indata, dms_bitcount;
 
-#define GETBITS(n) ((USHORT)(bitbuf >> (bitcount-(n))))
-#define DROPBITS(n) {bitbuf &= mask_bits[bitcount-=(n)]; while (bitcount<16) {bitbuf = (bitbuf << 8) | *indata++;  bitcount += 8;}}
+#define GETBITS(n) ((USHORT)(dms_bitbuf >> (dms_bitcount-(n))))
+#define DROPBITS(n) {dms_bitbuf &= dms_mask_bits[dms_bitcount-=(n)]; while (dms_bitcount<16) {dms_bitbuf = (dms_bitbuf << 8) | *dms_indata++;  dms_bitcount += 8;}}
 
 
 void initbitbuf(UCHAR *);
index c735988cea8feb367c5d9a89a0bbabd4f1ccc79a..2e85370f4665795d343b40ec3369dd684c54b3b7 100644 (file)
@@ -23,7 +23,7 @@ static USHORT mktbl(void);
 
 
 
-USHORT make_table(USHORT nchar, UCHAR bitlen[],USHORT tablebits, USHORT table[]){
+USHORT dms_make_table(USHORT nchar, UCHAR bitlen[],USHORT tablebits, USHORT table[]){
        n = avail = nchar;
        blen = bitlen;
        tbl = table;
@@ -77,8 +77,8 @@ static USHORT mktbl(void){
                        TabErr = 3;
                        return 0;
                }
-               left[i] = mktbl();
-               right[i] = mktbl();
+               dms_left[i] = mktbl();
+               dms_right[i] = mktbl();
                if (codeword >= tblsiz) {
                        TabErr = 4;
                        return 0;
index 42abc3e70ae45684ab923b824b16bc65864db8ed..ad3fac6f853b32e446d2d9c012686faad5b6a317 100644 (file)
@@ -1,5 +1,5 @@
 
-extern USHORT left[], right[];
+extern USHORT dms_left[], dms_right[];
 
-USHORT make_table(USHORT nchar, UCHAR bitlen[], USHORT tablebits, USHORT table[]);
+USHORT dms_make_table(USHORT nchar, UCHAR bitlen[], USHORT tablebits, USHORT table[]);
 
index f84b8e9e6c295c7d93ed999775b9f4e42f7031a8..5112a98b2647da9accabe2b85d0250536a04f138 100644 (file)
@@ -47,7 +47,7 @@ static int passfound, passretries;
 static TCHAR modes[7][7]={L"NOCOMP",L"SIMPLE",L"QUICK ",L"MEDIUM",L"DEEP  ",L"HEAVY1",L"HEAVY2"};
 static USHORT PWDCRC;
 
-static UCHAR *text;
+UCHAR *dms_text;
 
 static void log_error(int track)
 {
@@ -91,8 +91,8 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
                free(b1);
                return ERR_NOMEMORY;
        }
-       text = xcalloc(UCHAR,TEMP_BUFFER_LEN);
-       if (!text) {
+       dms_text = xcalloc(UCHAR,TEMP_BUFFER_LEN);
+       if (!dms_text) {
                free(b1);
                free(b2);
                return ERR_NOMEMORY;
@@ -103,7 +103,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
        if (zfile_fread(b1,1,HEADLEN,fi) != HEADLEN) {
                free(b1);
                free(b2);
-               free(text);
+               free(dms_text);
                return ERR_SREAD;
        }
 
@@ -111,17 +111,17 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
                /*  Check the first 4 bytes of file to see if it is "DMS!"  */
                free(b1);
                free(b2);
-               free(text);
+               free(dms_text);
                return ERR_NOTDMS;
        }
 
        hcrc = (USHORT)((b1[HEADLEN-2]<<8) | b1[HEADLEN-1]);
        /* Header CRC */
 
-       if (hcrc != CreateCRC(b1+4,(ULONG)(HEADLEN-6))) {
+       if (hcrc != dms_CreateCRC(b1+4,(ULONG)(HEADLEN-6))) {
                free(b1);
                free(b2);
-               free(text);
+               free(dms_text);
                return ERR_HCRC;
        }
 
@@ -133,7 +133,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
        if (part && from < 30) {
                free(b1);
                free(b2);
-               free(text);
+               free(dms_text);
                return DMS_FILE_END;
        }
 
@@ -221,7 +221,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
                /*  It's not a DMS compressed disk image, but a FMS archive  */
                free(b1);
                free(b2);
-               free(text);
+               free(dms_text);
                return ERR_FMS;
        }
 
@@ -290,7 +290,7 @@ USHORT DMS_Process_File(struct zfile *fi, struct zfile *fo, USHORT cmd, USHORT o
 
        free(b1);
        free(b2);
-       free(text);
+       free(dms_text);
 
        return ret;
 }
@@ -316,7 +316,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR
        /*  Track Header CRC  */
        hcrc = (USHORT)((b1[THLEN-2] << 8) | b1[THLEN-1]);
 
-       if (CreateCRC(b1,(ULONG)(THLEN-2)) != hcrc) return ERR_THCRC;
+       if (dms_CreateCRC(b1,(ULONG)(THLEN-2)) != hcrc) return ERR_THCRC;
 
        number = (USHORT)((b1[2] << 8) | b1[3]);        /*  Number of track  */
        pklen1 = (USHORT)((b1[6] << 8) | b1[7]);        /*  Length of packed track data as in archive  */
@@ -347,7 +347,7 @@ static USHORT Process_Track(struct zfile *fi, struct zfile *fo, UCHAR *b1, UCHAR
 
        if (zfile_fread(b1,1,(size_t)pklen1,fi) != pklen1) return ERR_SREAD;
 
-       if (CreateCRC(b1,(ULONG)pklen1) != dcrc) {
+       if (dms_CreateCRC(b1,(ULONG)pklen1) != dcrc) {
                log_error (number);
                crcerr = 1;
        }
@@ -480,7 +480,7 @@ static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen,
                        dms_decrypt(b1, pklen1, b1);
                r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags);
                if (r == NO_PROBLEM) {
-                       if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen))
+                       if (usum1 == dms_Calc_CheckSum(b2,(ULONG)unpklen))
                                return NO_PROBLEM;
                }
                log_error(number);
@@ -497,7 +497,7 @@ static USHORT Unpack_Track(UCHAR *b1, UCHAR *b2, USHORT pklen2, USHORT unpklen,
        for (;;) {
                r = Unpack_Track_2(b1, b2, pklen2, unpklen, cmode, flags);
                if (r == NO_PROBLEM) {
-                       if (usum1 == Calc_CheckSum(b2,(ULONG)unpklen)) {
+                       if (usum1 == dms_Calc_CheckSum(b2,(ULONG)unpklen)) {
                                passfound = maybeencrypted;
                                if (passfound)
                                        write_log (L"DMS: decryption key = 0x%04X\n", prevpass);
index 45d040ae455604d9c7d70a223211e7fd19239522..1595d77844691cce6cade6253dbbf87e732149a7 100644 (file)
@@ -23,8 +23,8 @@ INLINE void update(USHORT c);
 static void reconst(void);
 
 
-USHORT deep_text_loc;
-int init_deep_tabs=1;
+USHORT dms_deep_text_loc;
+int dms_init_deep_tabs=1;
 
 
 
@@ -66,7 +66,7 @@ void Init_DEEP_Tabs(void){
        freq[T] = 0xffff;
        prnt[R] = 0;
 
-       init_deep_tabs = 0;
+       dms_init_deep_tabs = 0;
 }
 
 
@@ -77,21 +77,21 @@ USHORT Unpack_DEEP(UCHAR *in, UCHAR *out, USHORT origsize){
 
        initbitbuf(in);
 
-       if (init_deep_tabs) Init_DEEP_Tabs();
+       if (dms_init_deep_tabs) Init_DEEP_Tabs();
 
        outend = out+origsize;
        while (out < outend) {
                c = DecodeChar();
                if (c < 256) {
-                       *out++ = text[deep_text_loc++ & DBITMASK] = (UCHAR)c;
+                       *out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = (UCHAR)c;
                } else {
                        j = (USHORT) (c - 255 + THRESHOLD);
-                       i = (USHORT) (deep_text_loc - DecodePosition() - 1);
-                       while (j--) *out++ = text[deep_text_loc++ & DBITMASK] = text[i++ & DBITMASK];
+                       i = (USHORT) (dms_deep_text_loc - DecodePosition() - 1);
+                       while (j--) *out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = dms_text[i++ & DBITMASK];
                }
        }
 
-       deep_text_loc = (USHORT)((deep_text_loc+60) & DBITMASK);
+       dms_deep_text_loc = (USHORT)((dms_deep_text_loc+60) & DBITMASK);
 
        return 0;
 }
index d87be1d998a2471582ee98e1da3d316db333f1e3..ae542ee9a2f5b70e3b93449d3878e76e04b30dfc 100644 (file)
@@ -2,6 +2,6 @@
 
 USHORT Unpack_DEEP(UCHAR *, UCHAR *, USHORT);
 
-extern int init_deep_tabs;
-extern USHORT deep_text_loc;
+extern int dms_init_deep_tabs;
+extern USHORT dms_deep_text_loc;
 
index 42d2eb81a35326e7c9bf90b277490befa24323f0..6ce06c49c3616c1f490e819789b8e6b2da25fdd1 100644 (file)
 #define N1 510
 #define OFFSET 253
 
-static USHORT left[2 * NC - 1], right[2 * NC - 1 + 9];
+USHORT dms_left[2 * NC - 1], dms_right[2 * NC - 1 + 9];
 static UCHAR c_len[NC], pt_len[NPT];
 static USHORT c_table[4096], pt_table[256];
-USHORT lastlen, np;
-USHORT heavy_text_loc;
+USHORT dms_lastlen, dms_np;
+USHORT dms_heavy_text_loc;
 
 
 static USHORT read_tree_c(void);
@@ -42,10 +42,10 @@ USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){
        /*  Heavy 1 uses a 4Kb dictionary,  Heavy 2 uses 8Kb  */
 
        if (flags & 8) {
-               np = 15;
+               dms_np = 15;
                bitmask = 0x1fff;
        } else {
-               np = 14;
+               dms_np = 14;
                bitmask = 0x0fff;
        }
 
@@ -61,11 +61,11 @@ USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){
        while (out<outend) {
                c = decode_c();
                if (c < 256) {
-                       *out++ = text[heavy_text_loc++ & bitmask] = (UCHAR)c;
+                       *out++ = dms_text[dms_heavy_text_loc++ & bitmask] = (UCHAR)c;
                } else {
                        j = (USHORT) (c - OFFSET);
-                       i = (USHORT) (heavy_text_loc - decode_p() - 1);
-                       while(j--) *out++ = text[heavy_text_loc++ & bitmask] = text[i++ & bitmask];
+                       i = (USHORT) (dms_heavy_text_loc - decode_p() - 1);
+                       while(j--) *out++ = dms_text[dms_heavy_text_loc++ & bitmask] = dms_text[i++ & bitmask];
                }
        }
 
@@ -85,8 +85,8 @@ INLINE USHORT decode_c(void){
                i = GETBITS(16);
                m = 0x8000;
                do {
-                       if (i & m) j = right[j];
-                       else              j = left [j];
+                       if (i & m) j = dms_right[j];
+                       else              j = dms_left [j];
                        m >>= 1;
                } while (j >= N1);
                DROPBITS(c_len[j] - 12);
@@ -100,29 +100,29 @@ INLINE USHORT decode_p(void){
        USHORT i, j, m;
 
        j = pt_table[GETBITS(8)];
-       if (j < np) {
+       if (j < dms_np) {
                DROPBITS(pt_len[j]);
        } else {
                DROPBITS(8);
                i = GETBITS(16);
                m = 0x8000;
                do {
-                       if (i & m) j = right[j];
-                       else             j = left [j];
+                       if (i & m) j = dms_right[j];
+                       else             j = dms_left [j];
                        m >>= 1;
-               } while (j >= np);
+               } while (j >= dms_np);
                DROPBITS(pt_len[j] - 8);
        }
 
-       if (j != np-1) {
+       if (j != dms_np-1) {
                if (j > 0) {
                        j = (USHORT)(GETBITS(i=(USHORT)(j-1)) | (1U << (j-1)));
                        DROPBITS(i);
                }
-               lastlen=j;
+               dms_lastlen=j;
        }
 
-       return lastlen;
+       return dms_lastlen;
 
 }
 
@@ -139,7 +139,7 @@ static USHORT read_tree_c(void){
                        DROPBITS(5);
                }
                for (i=n; i<510; i++) c_len[i] = 0;
-               if (make_table(510,c_len,12,c_table)) return 1;
+               if (dms_make_table(510,c_len,12,c_table)) return 1;
        } else {
                n = GETBITS(9);
                DROPBITS(9);
@@ -161,12 +161,12 @@ static USHORT read_tree_p(void){
                        pt_len[i] = (UCHAR)GETBITS(4);
                        DROPBITS(4);
                }
-               for (i=n; i<np; i++) pt_len[i] = 0;
-               if (make_table(np,pt_len,8,pt_table)) return 1;
+               for (i=n; i<dms_np; i++) pt_len[i] = 0;
+               if (dms_make_table(dms_np,pt_len,8,pt_table)) return 1;
        } else {
                n = GETBITS(5);
                DROPBITS(5);
-               for (i=0; i<np; i++) pt_len[i] = 0;
+               for (i=0; i<dms_np; i++) pt_len[i] = 0;
                for (i=0; i<256; i++) pt_table[i] = n;
        }
        return 0;
index 35c77f34821ef093c52999ab834241bd4a58d01a..80f1be83975a94ef2b020a3383442d7d94969040 100644 (file)
@@ -2,5 +2,5 @@
 
 USHORT Unpack_HEAVY(UCHAR *, UCHAR *, UCHAR, USHORT);
 
-extern USHORT heavy_text_loc;
+extern USHORT dms_heavy_text_loc;
 
index 480c2d8d78dabe9e22249a57a206cf32799a3315..dcbaee0180b8dcc20435d4a0670eda0866e8c920 100644 (file)
 #include "u_deep.h"
 #include "u_heavy.h"
 
-extern USHORT lastlen, np;
-
 void Init_Decrunchers(void){
-       quick_text_loc = 251;
-       medium_text_loc = 0x3fbe;
-       heavy_text_loc = 0;
-       deep_text_loc = 0x3fc4;
-       init_deep_tabs = 1;
-       memset(text,0,0x3fc8);
-       lastlen = 0;
-       np = 0;
+       dms_quick_text_loc = 251;
+       dms_medium_text_loc = 0x3fbe;
+       dms_heavy_text_loc = 0;
+       dms_deep_text_loc = 0x3fc4;
+       dms_init_deep_tabs = 1;
+       memset(dms_text,0,0x3fc8);
+       dms_lastlen = 0;
+       dms_np = 0;
 }
 
index cc3e8678477c7567d94a267e6be1d000fa4efeed..e0a771c17254d4155c922ae9b554b901c1b9c16b 100644 (file)
@@ -19,7 +19,7 @@
 #define MBITMASK 0x3fff
 
 
-USHORT medium_text_loc;
+USHORT dms_medium_text_loc;
 
 
 
@@ -34,7 +34,7 @@ USHORT Unpack_MEDIUM(UCHAR *in, UCHAR *out, USHORT origsize){
        while (out < outend) {
                if (GETBITS(1)!=0) {
                        DROPBITS(1);
-                       *out++ = text[medium_text_loc++ & MBITMASK] = (UCHAR)GETBITS(8);
+                       *out++ = dms_text[dms_medium_text_loc++ & MBITMASK] = (UCHAR)GETBITS(8);
                        DROPBITS(8);
                } else {
                        DROPBITS(1);
@@ -44,13 +44,13 @@ USHORT Unpack_MEDIUM(UCHAR *in, UCHAR *out, USHORT origsize){
                        c = (USHORT) (((c << u) | GETBITS(u)) & 0xff);  DROPBITS(u);
                        u = d_len[c];
                        c = (USHORT) ((d_code[c] << 8) | (((c << u) | GETBITS(u)) & 0xff));  DROPBITS(u);
-                       i = (USHORT) (medium_text_loc - c - 1);
+                       i = (USHORT) (dms_medium_text_loc - c - 1);
 
-                       while(j--) *out++ = text[medium_text_loc++ & MBITMASK] = text[i++ & MBITMASK];
+                       while(j--) *out++ = dms_text[dms_medium_text_loc++ & MBITMASK] = dms_text[i++ & MBITMASK];
 
                }
        }
-       medium_text_loc = (USHORT)((medium_text_loc+66) & MBITMASK);
+       dms_medium_text_loc = (USHORT)((dms_medium_text_loc+66) & MBITMASK);
 
        return 0;
 }
index 3c1b4fc2ca03e6f176ce9a1387f56a20beb31191..18c0ce8590ed660b33e9496626d42442ddee5ea0 100644 (file)
@@ -1,5 +1,5 @@
 
 USHORT Unpack_MEDIUM(UCHAR *, UCHAR *, USHORT);
 
-extern USHORT medium_text_loc;
+extern USHORT dms_medium_text_loc;
 
index 74131c265e285eb797c8133ee88415df983fe67f..1cc08cccab7d49a0136dbffcfdf10a04b5962ee4 100644 (file)
@@ -17,7 +17,7 @@
 #define QBITMASK 0xff
 
 
-USHORT quick_text_loc;
+USHORT dms_quick_text_loc;
 
 
 USHORT Unpack_QUICK(UCHAR *in, UCHAR *out, USHORT origsize){
@@ -30,17 +30,17 @@ USHORT Unpack_QUICK(UCHAR *in, UCHAR *out, USHORT origsize){
        while (out < outend) {
                if (GETBITS(1)!=0) {
                        DROPBITS(1);
-                       *out++ = text[quick_text_loc++ & QBITMASK] = (UCHAR)GETBITS(8);  DROPBITS(8);
+                       *out++ = dms_text[dms_quick_text_loc++ & QBITMASK] = (UCHAR)GETBITS(8);  DROPBITS(8);
                } else {
                        DROPBITS(1);
                        j = (USHORT) (GETBITS(2)+2);  DROPBITS(2);
-                       i = (USHORT) (quick_text_loc - GETBITS(8) - 1);  DROPBITS(8);
+                       i = (USHORT) (dms_quick_text_loc - GETBITS(8) - 1);  DROPBITS(8);
                        while(j--) {
-                               *out++ = text[quick_text_loc++ & QBITMASK] = text[i++ & QBITMASK];
+                               *out++ = dms_text[dms_quick_text_loc++ & QBITMASK] = dms_text[i++ & QBITMASK];
                        }
                }
        }
-       quick_text_loc = (USHORT)((quick_text_loc+5) & QBITMASK);
+       dms_quick_text_loc = (USHORT)((dms_quick_text_loc+5) & QBITMASK);
 
        return 0;
 }
index 9518815b38aac0df45b67ee1cac291f2f71c0d6b..2cfdf4afcb054ef1c6ece3f1532c8bb990498265 100644 (file)
@@ -1,5 +1,5 @@
 
 USHORT Unpack_QUICK(UCHAR *, UCHAR *, USHORT);
 
-extern USHORT quick_text_loc;
+extern USHORT dms_quick_text_loc;