syncing 2.3.0

parent 57a72759
PUAE 2.2.1 beta series
PUAE 2.3.0 beta series
============
PUAE tries to continue where E-UAE left off..
PUAE versioning is based on the merged WinUAE version..
......
......@@ -1717,7 +1717,9 @@ AC_CONFIG_LINKS(src/guidep:src/$GUI_DEP)
AC_CONFIG_FILES([Makefile
src/Makefile
src/dms/Makefile
src/archivers/dms/Makefile
src/archivers/lha/Makefile
src/archivers/zip/Makefile
src/caps/Makefile
src/md-generic/Makefile
src/md-i386-gcc/Makefile
......
......@@ -4,7 +4,7 @@ AM_CPPFLAGS += -I$(top_srcdir)/src/include -I$(top_builddir)/src -I$(top_srcdir)
SUBDIRS = \
tools @MACHDEP@ @THREADDEP@ @GFX_DEP@ @SND_DEP@ @JOY_DEP@ @GUI_DEP@ \
@OSDEP@ keymap dms caps
@OSDEP@ keymap archivers/dms archivers/lha archivers/zip caps
DIST_SUBDIRS = \
md-generic md-68k md-i386-gcc md-ppc md-ppc-gcc md-amd64-gcc \
......@@ -14,7 +14,7 @@ DIST_SUBDIRS = \
gui-none gui-beos gui-cocoa gui-gtk gui-muirexx \
od-generic od-amiga od-beos od-linux od-macosx od-win32 \
td-none td-amigaos td-beos td-posix td-sdl td-win32 \
keymap caps dms
keymap caps archivers/dms archivers/lha archivers/zip
BUILT_SOURCES = \
blit.h blitfunc.h blitfunc.c blittable.c \
......@@ -116,7 +116,6 @@ noinst_HEADERS = \
include/uae_malloc.h \
include/uae_string.h \
include/uae_types.h \
include/unzip.h \
include/version.h \
include/writelog.h \
include/xwin.h include/zfile.h include/diskutil.h \
......@@ -136,7 +135,7 @@ uae_SOURCES = \
blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c \
diskutil.c zfile.c cfgfile.c picasso96.c inputdevice.c \
gfxutil.c audio.c sinctable.c drawing.c consolehook.c \
native2amiga.c disk.c crc32.c savestate.c unzip.c arcadia.c cdtv.c cd32_fmv.c \
native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \
uaeexe.c uaelib.c uaeresource.c fdi2raw.c hotkeys.c amax.c \
ar.c driveclick.c enforcer.c misc.c a2065.c gayle.c ncr_scsi.c \
missing.c readcpu.c
......@@ -158,7 +157,9 @@ uae_DEPENDENCIES = \
@GFX_DEP@/libgfxdep.a \
@GUI_DEP@/libguidep.a \
keymap/libkeymap.a \
dms/libdms.a \
archivers/dms/libdms.a \
archivers/lha/liblha.a \
archivers/zip/libzip.a \
caps/libcaps.a \
blitfunc.o blittable.o \
cpustbl.o cpudefs.o \
......@@ -180,7 +181,9 @@ uae_LDADD = \
@GFX_DEP@/libgfxdep.a \
@GUI_DEP@/libguidep.a \
keymap/libkeymap.a \
dms/libdms.a \
archivers/dms/libdms.a \
archivers/lha/liblha.a \
archivers/zip/libzip.a \
caps/libcaps.a \
blitfunc.o blittable.o \
cpustbl.o cpudefs.o \
......
......@@ -83,13 +83,13 @@ am_uae_OBJECTS = main.$(OBJEXT) newcpu.$(OBJEXT) memory.$(OBJEXT) \
inputdevice.$(OBJEXT) gfxutil.$(OBJEXT) audio.$(OBJEXT) \
sinctable.$(OBJEXT) drawing.$(OBJEXT) consolehook.$(OBJEXT) \
native2amiga.$(OBJEXT) disk.$(OBJEXT) crc32.$(OBJEXT) \
savestate.$(OBJEXT) unzip.$(OBJEXT) arcadia.$(OBJEXT) \
cdtv.$(OBJEXT) cd32_fmv.$(OBJEXT) uaeexe.$(OBJEXT) \
uaelib.$(OBJEXT) uaeresource.$(OBJEXT) fdi2raw.$(OBJEXT) \
hotkeys.$(OBJEXT) amax.$(OBJEXT) ar.$(OBJEXT) \
driveclick.$(OBJEXT) enforcer.$(OBJEXT) misc.$(OBJEXT) \
a2065.$(OBJEXT) gayle.$(OBJEXT) ncr_scsi.$(OBJEXT) \
missing.$(OBJEXT) readcpu.$(OBJEXT)
savestate.$(OBJEXT) arcadia.$(OBJEXT) cdtv.$(OBJEXT) \
cd32_fmv.$(OBJEXT) uaeexe.$(OBJEXT) uaelib.$(OBJEXT) \
uaeresource.$(OBJEXT) fdi2raw.$(OBJEXT) hotkeys.$(OBJEXT) \
amax.$(OBJEXT) ar.$(OBJEXT) driveclick.$(OBJEXT) \
enforcer.$(OBJEXT) misc.$(OBJEXT) a2065.$(OBJEXT) \
gayle.$(OBJEXT) ncr_scsi.$(OBJEXT) missing.$(OBJEXT) \
readcpu.$(OBJEXT)
uae_OBJECTS = $(am_uae_OBJECTS)
SCRIPTS = $(dist_noinst_SCRIPTS)
DEFAULT_INCLUDES = -I.@am__isrc@
......@@ -309,7 +309,7 @@ AM_CPPFLAGS = @UAE_CPPFLAGS@ -I$(top_srcdir)/src/include \
-I$(top_builddir)/src -I$(top_srcdir)/src -I$(top_srcdir)
SUBDIRS = \
tools @MACHDEP@ @THREADDEP@ @GFX_DEP@ @SND_DEP@ @JOY_DEP@ @GUI_DEP@ \
@OSDEP@ keymap dms caps
@OSDEP@ keymap archivers/dms archivers/lha archivers/zip caps
DIST_SUBDIRS = \
md-generic md-68k md-i386-gcc md-ppc md-ppc-gcc md-amd64-gcc \
......@@ -319,7 +319,7 @@ DIST_SUBDIRS = \
gui-none gui-beos gui-cocoa gui-gtk gui-muirexx \
od-generic od-amiga od-beos od-linux od-macosx od-win32 \
td-none td-amigaos td-beos td-posix td-sdl td-win32 \
keymap caps dms
keymap caps archivers/dms archivers/lha archivers/zip
BUILT_SOURCES = \
blit.h blitfunc.h blitfunc.c blittable.c \
......@@ -395,7 +395,6 @@ noinst_HEADERS = \
include/uae_malloc.h \
include/uae_string.h \
include/uae_types.h \
include/unzip.h \
include/version.h \
include/writelog.h \
include/xwin.h include/zfile.h include/diskutil.h \
......@@ -415,7 +414,7 @@ uae_SOURCES = \
blitter.c autoconf.c traps.c ersatz.c keybuf.c expansion.c \
diskutil.c zfile.c cfgfile.c picasso96.c inputdevice.c \
gfxutil.c audio.c sinctable.c drawing.c consolehook.c \
native2amiga.c disk.c crc32.c savestate.c unzip.c arcadia.c cdtv.c cd32_fmv.c \
native2amiga.c disk.c crc32.c savestate.c arcadia.c cdtv.c cd32_fmv.c \
uaeexe.c uaelib.c uaeresource.c fdi2raw.c hotkeys.c amax.c \
ar.c driveclick.c enforcer.c misc.c a2065.c gayle.c ncr_scsi.c \
missing.c readcpu.c
......@@ -437,7 +436,9 @@ uae_DEPENDENCIES = \
@GFX_DEP@/libgfxdep.a \
@GUI_DEP@/libguidep.a \
keymap/libkeymap.a \
dms/libdms.a \
archivers/dms/libdms.a \
archivers/lha/liblha.a \
archivers/zip/libzip.a \
caps/libcaps.a \
blitfunc.o blittable.o \
cpustbl.o cpudefs.o \
......@@ -454,11 +455,13 @@ uae_DEPENDENCIES = \
uae_LDADD = @MACHDEP@/libmachdep.a @JOY_DEP@/libjoydep.a \
@SND_DEP@/libsnddep.a @GFX_DEP@/libgfxdep.a \
@GUI_DEP@/libguidep.a keymap/libkeymap.a dms/libdms.a \
caps/libcaps.a blitfunc.o blittable.o cpustbl.o cpudefs.o \
libcpuemu.a @EXTRAOBJS@ @FILESYSOBJS@ @BSDSOCKOBJS@ @SCSIOBJS@ \
@CDOBJS@ @DEBUGOBJS@ @ASMOBJS@ @THREADDEP@/libthreaddep.a \
@OSDEP@/libosdep.a @UAE_LIBS@ @MATHLIB@
@GUI_DEP@/libguidep.a keymap/libkeymap.a \
archivers/dms/libdms.a archivers/lha/liblha.a \
archivers/zip/libzip.a caps/libcaps.a blitfunc.o blittable.o \
cpustbl.o cpudefs.o libcpuemu.a @EXTRAOBJS@ @FILESYSOBJS@ \
@BSDSOCKOBJS@ @SCSIOBJS@ @CDOBJS@ @DEBUGOBJS@ @ASMOBJS@ \
@THREADDEP@/libthreaddep.a @OSDEP@/libosdep.a @UAE_LIBS@ \
@MATHLIB@ $(am__empty)
readdisk_SOURCES = \
readdisk.c missing.c
......@@ -657,7 +660,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uaeexe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uaelib.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uaeresource.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unzip.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/writelog.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zfile.Po@am__quote@
......
......@@ -1689,3 +1689,4 @@ uae_u8 *restore_cd (int num, uae_u8 *src)
}
#endif
......@@ -416,7 +416,7 @@ static void *cdda_play_func (void *v)
whdr[i].lpData = (LPSTR)px[i];
mmr = waveOutPrepareHeader (cdda_wavehandle, &whdr[i], sizeof (WAVEHDR));
if (mmr != MMSYSERR_NOERROR) {
write_log ("CDDA: waveOutPrepareHeader %d:%d\n", i, mmr);
write_log ("IMAGE CDDA: waveOutPrepareHeader %d:%d\n", i, mmr);
goto end;
}
whdr[i].dwFlags |= WHDR_DONE;
......@@ -813,8 +813,13 @@ static int command_read (int unitnum, uae_u8 *data, int sector, int size)
sector += size;
} else {
offset = 16;
while (size-- > 0) {
zfile_fseek (t->handle, t->offset + sector * t->size + offset, SEEK_SET);
zfile_fread (data, size, 2048, t->handle);
data += 2048;
sector++;
}
}
cdu->cd_last_pos = sector;
return 1;
}
......@@ -866,7 +871,6 @@ static int command_toc (int unitnum, struct cd_toc_head *th)
toc++;
memcpy (&cdu->di.toc, th, sizeof (struct cd_toc_head));
gui_flicker_led (LED_CD, unitnum, 1);
return 1;
}
......@@ -1109,7 +1113,7 @@ static int parseccd (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img)
zimg = zfile_fopen (fname, "rb", ZFD_NORMAL);
if (!zimg) {
write_log ("CCD: can't open '%s'\n", fname);
//return 0;
return 0;
}
ext = _tcsrchr (fname, '.');
if (ext)
......
......@@ -349,13 +349,13 @@ static struct socketbase *alloc_socketbase (TrapContext *context)
/* @@@ free everything */
}
locksigqueue ();
locksigqueue();
if (socketbases)
sb->next = socketbases;
socketbases = sb;
unlocksigqueue ();
unlocksigqueue();
return sb;
}
......@@ -656,8 +656,8 @@ static uae_u32 bsdsocklib_SetDTableSize (SB, int newSize)
return -1;
}
memcpy(newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable));
memcpy(newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable));
memcpy (newdtable, sb->dtable, sb->dtablesize * sizeof(*sb->dtable));
memcpy (newftable, sb->ftable, sb->dtablesize * sizeof(*sb->ftable));
for (i = sb->dtablesize + 1; i < newSize; i++)
newdtable[i] = -1;
......@@ -709,7 +709,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ObtainSocket (TrapContext *context)
if (sd != -1) {
sb->ftable[sd - 1] = sockdata->sockpoolflags[i];
sockdata->sockpoolids[i] = UNIQUE_ID;
return sd-1;
return sd - 1;
}
return -1;
......@@ -770,6 +770,7 @@ static uae_u32 REGPARAM2 bsdsocklib_ReleaseSocket (TrapContext *context)
sockdata->sockpoolflags[i] = flags;
BSDTRACE (("id %d s 0x%x\n", id,s));
} else {
BSDTRACE (("[invalid socket descriptor]\n"));
return -1;
......@@ -1011,7 +1012,7 @@ static uae_u32 REGPARAM2 bsdsocklib_gethostid (TrapContext *context)
return 0x7f000001;
}
const char * const errortexts[] =
static const TCHAR *errortexts[] =
{"No error", "Operation not permitted", "No such file or directory",
"No such process", "Interrupted system call", "Input/output error", "Device not configured",
"Argument list too long", "Exec format error", "Bad file descriptor", "No child processes",
......@@ -1037,32 +1038,32 @@ const char * const errortexts[] =
"RPC prog. not avail", "Program version wrong", "Bad procedure for program", "No locks available",
"Function not implemented", "Inappropriate file type or format", "PError 0"};
uae_u32 errnotextptrs[sizeof (errortexts) / sizeof (*errortexts)];
uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortexts);
static uae_u32 errnotextptrs[sizeof (errortexts) / sizeof (*errortexts)];
static const uae_u32 number_sys_error = sizeof (errortexts) / sizeof (*errortexts);
const char * const herrortexts[] =
{"No error", "Unknown host", "Host name lookup failure", "Unknown server error",
static const TCHAR *herrortexts[] =
{"No error", "Unknown host", "Host name lookup failure", "Unknown server error",
"No address associated with name"};
uae_u32 herrnotextptrs[sizeof (herrortexts) / sizeof (*herrortexts)];
uae_u32 number_host_error = sizeof (herrortexts) / sizeof (*herrortexts);
static uae_u32 herrnotextptrs[sizeof (herrortexts) / sizeof (*herrortexts)];
static const uae_u32 number_host_error = sizeof (herrortexts) / sizeof (*herrortexts);
static const char * const strErr = "Errlist lookup error";
uae_u32 strErrptr;
static const TCHAR * const strErr = "Errlist lookup error";
static uae_u32 strErrptr;
#define TAG_DONE (0L) /* terminates array of TagItems. ti_Data unused */
#define TAG_IGNORE (1L) /* ignore this item, not end of array */
#define TAG_MORE (2L) /* ti_Data is pointer to another array of TagItems */
#define TAG_SKIP (3L) /* skip this and the next ti_Data items */
#define TAG_USER ((uae_u32)(1L<<31))
#define TAG_USER ((uae_u32)(1L << 31))
#define SBTF_VAL 0x0000
#define SBTF_REF 0x8000
#define SBTB_CODE 1
#define SBTS_CODE 0x3FFF
#define SBTM_CODE(tag) ((((UWORD)(tag))>>SBTB_CODE) & SBTS_CODE)
#define SBTM_CODE(tag) ((((UWORD)(tag)) >> SBTB_CODE) & SBTS_CODE)
#define SBTF_GET 0x0
#define SBTF_SET 0x1
#define SBTM_GETREF(code) \
......@@ -1376,6 +1377,7 @@ void bsdlib_reset (void)
SockLibBase = 0;
write_log ("BSDSOCK: cleanup start..\n");
host_sbcleanup (NULL);
for (sb = socketbases; sb; sb = nsb) {
nsb = sb->next;
......@@ -1419,7 +1421,7 @@ static const TrapHandler sockfuncs[] = {
bsdsocklib_GetSocketEvents
};
static const char * const funcnames[] = {
static const TCHAR * const funcnames[] = {
"bsdsocklib_init", "bsdsocklib_Open", "bsdsocklib_Close", "bsdsocklib_Expunge",
"bsdsocklib_socket", "bsdsocklib_bind", "bsdsocklib_listen", "bsdsocklib_accept",
"bsdsocklib_connect", "bsdsocklib_sendto", "bsdsocklib_send", "bsdsocklib_recvfrom", "bsdsocklib_recv",
......
/*
/*
* UAE - The Un*x Amiga Emulator
*
* MC68881 emulation
......
AM_CPPFLAGS = @UAE_CPPFLAGS@
AM_CPPFLAGS += -I$(top_srcdir)/src/include -I$(top_builddir)/src -I$(top_srcdir)/src
AM_CFLAGS = @UAE_CFLAGS@
noinst_LIBRARIES = libdms.a
libdms_a_SOURCES = crc_csum.c getbits.c maketbl.c pfile.c tables.c \
u_deep.c u_heavy.c u_init.c u_medium.c u_quick.c \
u_rle.c
noinst_HEADERS = cdata.h crc_csum.h getbits.h maketbl.h pfile.h tables.h \
u_deep.h u_heavy.h u_init.h u_medium.h u_quick.h u_rle.h
This diff is collapsed.
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Main types of variables used in xDMS, some implementation
* dependant features and other global stuff
*/
#ifndef UCHAR
#define UCHAR unsigned char
#endif
#ifndef USHORT
#define USHORT unsigned short
#endif
#ifndef SHORT
#define SHORT short
#endif
#ifndef ULONG
#define ULONG unsigned long
#endif
#ifndef INLINE
#ifdef __cplusplus
#define INLINE inline
#else
#ifdef __GNUC__
#define INLINE inline
#else
#ifdef __SASC
#define INLINE __inline
#else
#define INLINE static
#endif
#endif
#endif
#endif
#ifndef UNDER_DOS
#ifdef __MSDOS__
#define UNDER_DOS
#else
#ifdef __MSDOS
#define UNDER_DOS
#else
#ifdef _OS2
#define UNDER_DOS
#else
#ifdef _QC
#define UNDER_DOS
#endif
#endif
#endif
#endif
#endif
#ifndef DIR_CHAR
#ifdef UNDER_DOS
/* running under MSDOS or DOS-like OS */
#define DIR_CHAR '\\'
#else
#define DIR_CHAR '/'
#endif
#endif
#define DIR_SEPARATORS ":\\/"
extern UCHAR *dms_text;
extern USHORT dms_lastlen, dms_np;
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* CRC16 & CheckSum16 calculation functions
* CreateCRC was written (aparently) by Bjorn Stenberg
*
*/
#include "cdata.h"
#include "crc_csum.h"
USHORT dms_Calc_CheckSum(UCHAR *mem, ULONG size){
USHORT u=0;
while(size--) u += *mem++;
return (USHORT)(u & 0xffff);
}
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,
0xCC01,0x0CC0,0x0D80,0xCD41,0x0F00,0xCFC1,0xCE81,0x0E40,
0x0A00,0xCAC1,0xCB81,0x0B40,0xC901,0x09C0,0x0880,0xC841,
0xD801,0x18C0,0x1980,0xD941,0x1B00,0xDBC1,0xDA81,0x1A40,
0x1E00,0xDEC1,0xDF81,0x1F40,0xDD01,0x1DC0,0x1C80,0xDC41,
0x1400,0xD4C1,0xD581,0x1540,0xD701,0x17C0,0x1680,0xD641,
0xD201,0x12C0,0x1380,0xD341,0x1100,0xD1C1,0xD081,0x1040,
0xF001,0x30C0,0x3180,0xF141,0x3300,0xF3C1,0xF281,0x3240,
0x3600,0xF6C1,0xF781,0x3740,0xF501,0x35C0,0x3480,0xF441,
0x3C00,0xFCC1,0xFD81,0x3D40,0xFF01,0x3FC0,0x3E80,0xFE41,
0xFA01,0x3AC0,0x3B80,0xFB41,0x3900,0xF9C1,0xF881,0x3840,
0x2800,0xE8C1,0xE981,0x2940,0xEB01,0x2BC0,0x2A80,0xEA41,
0xEE01,0x2EC0,0x2F80,0xEF41,0x2D00,0xEDC1,0xEC81,0x2C40,
0xE401,0x24C0,0x2580,0xE541,0x2700,0xE7C1,0xE681,0x2640,
0x2200,0xE2C1,0xE381,0x2340,0xE101,0x21C0,0x2080,0xE041,
0xA001,0x60C0,0x6180,0xA141,0x6300,0xA3C1,0xA281,0x6240,
0x6600,0xA6C1,0xA781,0x6740,0xA501,0x65C0,0x6480,0xA441,
0x6C00,0xACC1,0xAD81,0x6D40,0xAF01,0x6FC0,0x6E80,0xAE41,
0xAA01,0x6AC0,0x6B80,0xAB41,0x6900,0xA9C1,0xA881,0x6840,
0x7800,0xB8C1,0xB981,0x7940,0xBB01,0x7BC0,0x7A80,0xBA41,
0xBE01,0x7EC0,0x7F80,0xBF41,0x7D00,0xBDC1,0xBC81,0x7C40,
0xB401,0x74C0,0x7580,0xB541,0x7700,0xB7C1,0xB681,0x7640,
0x7200,0xB2C1,0xB381,0x7340,0xB101,0x71C0,0x7080,0xB041,
0x5000,0x90C1,0x9181,0x5140,0x9301,0x53C0,0x5280,0x9241,
0x9601,0x56C0,0x5780,0x9741,0x5500,0x95C1,0x9481,0x5440,
0x9C01,0x5CC0,0x5D80,0x9D41,0x5F00,0x9FC1,0x9E81,0x5E40,
0x5A00,0x9AC1,0x9B81,0x5B40,0x9901,0x59C0,0x5880,0x9841,
0x8801,0x48C0,0x4980,0x8941,0x4B00,0x8BC1,0x8A81,0x4A40,
0x4E00,0x8EC1,0x8F81,0x4F40,0x8D01,0x4DC0,0x4C80,0x8C41,
0x4400,0x84C1,0x8581,0x4540,0x8701,0x47C0,0x4680,0x8641,
0x8201,0x42C0,0x4380,0x8341,0x4100,0x81C1,0x8081,0x4040
};
register USHORT CRC = 0;
while(size--)
CRC = (USHORT) (CRCTab[((CRC ^ *mem++) & 255)] ^ ((CRC >> 8) & 255));
return CRC;
}
USHORT dms_Calc_CheckSum(UCHAR *, ULONG);
USHORT dms_CreateCRC(UCHAR *, ULONG);
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
* Functions/macros to get a variable number of bits
*
*/
#include "cdata.h"
#include "getbits.h"
ULONG dms_mask_bits[]={
0x000000L,0x000001L,0x000003L,0x000007L,0x00000fL,0x00001fL,
0x00003fL,0x00007fL,0x0000ffL,0x0001ffL,0x0003ffL,0x0007ffL,
0x000fffL,0x001fffL,0x003fffL,0x007fffL,0x00ffffL,0x01ffffL,
0x03ffffL,0x07ffffL,0x0fffffL,0x1fffffL,0x3fffffL,0x7fffffL,
0xffffffL
};
UCHAR *dms_indata, dms_bitcount;
ULONG dms_bitbuf;
void initbitbuf(UCHAR *in){
dms_bitbuf = 0;
dms_bitcount = 0;
dms_indata = in;
DROPBITS(0);
}
extern ULONG dms_mask_bits[], dms_bitbuf;
extern UCHAR *dms_indata, dms_bitcount;
#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 *);
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Makes decoding table for Heavy LZH decompression
* From UNIX LHA made by Masaru Oki
*
*/
#include "cdata.h"
#include "maketbl.h"
static SHORT c;
static USHORT n, tblsiz, len, depth, maxdepth, avail;
static USHORT codeword, bit, *tbl, TabErr;
static UCHAR *blen;
static USHORT mktbl(void);
USHORT dms_make_table(USHORT nchar, UCHAR bitlen[],USHORT tablebits, USHORT table[]){
n = avail = nchar;
blen = bitlen;
tbl = table;
tblsiz = (USHORT) (1U << tablebits);
bit = (USHORT) (tblsiz / 2);
maxdepth = (USHORT)(tablebits + 1);
depth = len = 1;
c = -1;
codeword = 0;
TabErr = 0;
mktbl(); /* left subtree */
if (TabErr) return TabErr;
mktbl(); /* right subtree */
if (TabErr) return TabErr;
if (codeword != tblsiz) return 5;
return 0;
}
static USHORT mktbl(void){
USHORT i=0;
if (TabErr) return 0;
if (len == depth) {
while (++c < n)
if (blen[c] == len) {
i = codeword;
codeword += bit;
if (codeword > tblsiz) {
TabErr=1;
return 0;
}
while (i < codeword) tbl[i++] = (USHORT)c;
return (USHORT)c;
}
c = -1;
len++;
bit >>= 1;
}
depth++;
if (depth < maxdepth) {
mktbl();
mktbl();
} else if (depth > 32) {
TabErr = 2;
return 0;
} else {
if ((i = avail++) >= 2 * n - 1) {
TabErr = 3;
return 0;
}
dms_left[i] = mktbl();
dms_right[i] = mktbl();
if (codeword >= tblsiz) {
TabErr = 4;
return 0;
}
if (depth == maxdepth) tbl[codeword++] = i;
}
depth--;
return i;
}
extern USHORT dms_left[], dms_right[];
USHORT dms_make_table(USHORT nchar, UCHAR bitlen[], USHORT tablebits, USHORT table[]);
This diff is collapsed.
/* Functions return codes */
#define NO_PROBLEM 0
#define DMS_FILE_END 1
#define ERR_NOMEMORY 2
#define ERR_CANTOPENIN 3
#define ERR_CANTOPENOUT 4
#define ERR_NOTDMS 5
#define ERR_SREAD 6
#define ERR_HCRC 7
#define ERR_NOTTRACK 8
#define ERR_BIGTRACK 9
#define ERR_THCRC 10
#define ERR_TDCRC 11
#define ERR_CSUM 12
#define ERR_CANTWRITE 13
#define ERR_BADDECR 14
#define ERR_UNKNMODE 15
#define ERR_NOPASSWD 16
#define ERR_BADPASSWD 17
#define ERR_FMS 18
#define ERR_GZIP 19
#define ERR_READDISK 20
/* Command to execute */
#define CMD_VIEW 1
#define CMD_VIEWFULL 2
#define CMD_SHOWDIZ 3
#define CMD_SHOWBANNER 4
#define CMD_TEST 5
#define CMD_UNPACK 6
#define CMD_UNPKGZ 7
#define CMD_EXTRACT 8
#define OPT_VERBOSE 1
#define OPT_QUIET 2
#define DMS_EXTRA_SIZE 10
USHORT DMS_Process_File(struct zfile *, struct zfile *, USHORT, USHORT, USHORT, USHORT, int, struct zfile **extra);
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Tables used in Medium and Deep compression modes
*
*/
#include "cdata.h"
#include "tables.h"
UCHAR d_code[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09,
0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A,
0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B,
0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D,
0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F,
0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11,
0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13,
0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15,
0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17,
0x18, 0x18, 0x19, 0x19, 0x1A, 0x1A, 0x1B, 0x1B,
0x1C, 0x1C, 0x1D, 0x1D, 0x1E, 0x1E, 0x1F, 0x1F,
0x20, 0x20, 0x21, 0x21, 0x22, 0x22, 0x23, 0x23,
0x24, 0x24, 0x25, 0x25, 0x26, 0x26, 0x27, 0x27,
0x28, 0x28, 0x29, 0x29, 0x2A, 0x2A, 0x2B, 0x2B,
0x2C, 0x2C, 0x2D, 0x2D, 0x2E, 0x2E, 0x2F, 0x2F,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
};
UCHAR d_len[256] = {
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
};
extern UCHAR d_code[], d_len[];
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Lempel-Ziv-DynamicHuffman decompression functions used in Deep
* mode.
* Most routines ripped from LZHUF written by Haruyasu Yoshizaki
*
*/
#include <string.h>
#include "cdata.h"
#include "tables.h"
#include "u_deep.h"
#include "getbits.h"
INLINE USHORT DecodeChar(void);
INLINE USHORT DecodePosition(void);
INLINE void update(USHORT c);
static void reconst(void);
USHORT dms_deep_text_loc;
int dms_init_deep_tabs=1;
#define DBITMASK 0x3fff /* uses 16Kb dictionary */
#define F 60 /* lookahead buffer size */
#define THRESHOLD 2
#define N_CHAR (256 - THRESHOLD + F) /* kinds of characters (character code = 0..N_CHAR-1) */
#define T (N_CHAR * 2 - 1) /* size of table */
#define R (T - 1) /* position of root */
#define MAX_FREQ 0x8000 /* updates tree when the */
static USHORT freq[T + 1]; /* frequency table */
static USHORT prnt[T + N_CHAR]; /* pointers to parent nodes, except for the */
/* elements [T..T + N_CHAR - 1] which are used to get */
/* the positions of leaves corresponding to the codes. */
static USHORT son[T]; /* pointers to child nodes (son[], son[] + 1) */
void Init_DEEP_Tabs(void){
USHORT i, j;
for (i = 0; i < N_CHAR; i++) {
freq[i] = 1;
son[i] = (USHORT)(i + T);
prnt[i + T] = i;
}
i = 0; j = N_CHAR;
while (j <= R) {
freq[j] = (USHORT) (freq[i] + freq[i + 1]);
son[j] = i;
prnt[i] = prnt[i + 1] = j;
i += 2; j++;
}
freq[T] = 0xffff;
prnt[R] = 0;
dms_init_deep_tabs = 0;
}
USHORT Unpack_DEEP(UCHAR *in, UCHAR *out, USHORT origsize){
USHORT i, j, c;
UCHAR *outend;
initbitbuf(in);
if (dms_init_deep_tabs) Init_DEEP_Tabs();
outend = out+origsize;
while (out < outend) {
c = DecodeChar();
if (c < 256) {
*out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = (UCHAR)c;
} else {
j = (USHORT) (c - 255 + THRESHOLD);
i = (USHORT) (dms_deep_text_loc - DecodePosition() - 1);
while (j--) *out++ = dms_text[dms_deep_text_loc++ & DBITMASK] = dms_text[i++ & DBITMASK];
}
}
dms_deep_text_loc = (USHORT)((dms_deep_text_loc+60) & DBITMASK);
return 0;
}
INLINE USHORT DecodeChar(void){
USHORT c;
c = son[R];
/* travel from root to leaf, */
/* choosing the smaller child node (son[]) if the read bit is 0, */
/* the bigger (son[]+1} if 1 */
while (c < T) {
c = son[c + GETBITS(1)];
DROPBITS(1);
}
c -= T;
update(c);
return c;
}
INLINE USHORT DecodePosition(void){
USHORT i, j, c;
i = GETBITS(8); DROPBITS(8);
c = (USHORT) (d_code[i] << 8);
j = d_len[i];
i = (USHORT) (((i << j) | GETBITS(j)) & 0xff); DROPBITS(j);
return (USHORT) (c | i) ;
}
/* reconstruction of tree */
static void reconst(void){
USHORT i, j, k, f, l;
/* collect leaf nodes in the first half of the table */
/* and replace the freq by (freq + 1) / 2. */
j = 0;
for (i = 0; i < T; i++) {
if (son[i] >= T) {
freq[j] = (USHORT) ((freq[i] + 1) / 2);
son[j] = son[i];
j++;
}
}
/* begin constructing tree by connecting sons */
for (i = 0, j = N_CHAR; j < T; i += 2, j++) {
k = (USHORT) (i + 1);
f = freq[j] = (USHORT) (freq[i] + freq[k]);
for (k = (USHORT)(j - 1); f < freq[k]; k--);
k++;
l = (USHORT)((j - k) * 2);
memmove(&freq[k + 1], &freq[k], (size_t)l);
freq[k] = f;
memmove(&son[k + 1], &son[k], (size_t)l);
son[k] = i;
}
/* connect prnt */
for (i = 0; i < T; i++) {
if ((k = son[i]) >= T) {
prnt[k] = i;
} else {
prnt[k] = prnt[k + 1] = i;
}
}
}
/* increment frequency of given code by one, and update tree */
INLINE void update(USHORT c){
USHORT i, j, k, l;
if (freq[R] == MAX_FREQ) {
reconst();
}
c = prnt[c + T];
do {
k = ++freq[c];
/* if the order is disturbed, exchange nodes */
if (k > freq[l = (USHORT)(c + 1)]) {
while (k > freq[++l]);
l--;
freq[c] = freq[l];
freq[l] = k;
i = son[c];
prnt[i] = l;
if (i < T) prnt[i + 1] = l;
j = son[l];
son[l] = i;
prnt[j] = c;
if (j < T) prnt[j + 1] = c;
son[c] = j;
c = l;
}
} while ((c = prnt[c]) != 0); /* repeat up to root */
}
USHORT Unpack_DEEP(UCHAR *, UCHAR *, USHORT);
extern int dms_init_deep_tabs;
extern USHORT dms_deep_text_loc;
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Lempel-Ziv-Huffman decompression functions used in Heavy 1 & 2
* compression modes. Based on LZH decompression functions from
* UNIX LHA made by Masaru Oki
*
*/
#include "cdata.h"
#include "u_heavy.h"
#include "getbits.h"
#include "maketbl.h"
#define NC 510
#define NPT 20
#define N1 510
#define OFFSET 253
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 dms_lastlen, dms_np;
USHORT dms_heavy_text_loc;
static USHORT read_tree_c(void);
static USHORT read_tree_p(void);
INLINE USHORT decode_c(void);
INLINE USHORT decode_p(void);
USHORT Unpack_HEAVY(UCHAR *in, UCHAR *out, UCHAR flags, USHORT origsize){
USHORT j, i, c, bitmask;
UCHAR *outend;
/* Heavy 1 uses a 4Kb dictionary, Heavy 2 uses 8Kb */
if (flags & 8) {
dms_np = 15;
bitmask = 0x1fff;
} else {
dms_np = 14;
bitmask = 0x0fff;
}
initbitbuf(in);
if (flags & 2) {
if (read_tree_c()) return 1;
if (read_tree_p()) return 2;
}
outend = out+origsize;
while (out<outend) {
c = decode_c();
if (c < 256) {
*out++ = dms_text[dms_heavy_text_loc++ & bitmask] = (UCHAR)c;
} else {
j = (USHORT) (c - OFFSET);
i = (USHORT) (dms_heavy_text_loc - decode_p() - 1);
while(j--) *out++ = dms_text[dms_heavy_text_loc++ & bitmask] = dms_text[i++ & bitmask];
}
}
return 0;
}
INLINE USHORT decode_c(void){
USHORT i, j, m;
j = c_table[GETBITS(12)];
if (j < N1) {
DROPBITS(c_len[j]);
} else {
DROPBITS(12);
i = GETBITS(16);
m = 0x8000;
do {
if (i & m) j = dms_right[j];
else j = dms_left [j];
m >>= 1;
} while (j >= N1);
DROPBITS(c_len[j] - 12);
}
return j;
}
INLINE USHORT decode_p(void){
USHORT i, j, m;
j = pt_table[GETBITS(8)];
if (j < dms_np) {
DROPBITS(pt_len[j]);
} else {
DROPBITS(8);
i = GETBITS(16);
m = 0x8000;
do {
if (i & m) j = dms_right[j];
else j = dms_left [j];
m >>= 1;
} while (j >= dms_np);
DROPBITS(pt_len[j] - 8);
}
if (j != dms_np-1) {
if (j > 0) {
j = (USHORT)(GETBITS(i=(USHORT)(j-1)) | (1U << (j-1)));
DROPBITS(i);
}
dms_lastlen=j;
}
return dms_lastlen;
}
static USHORT read_tree_c(void){
USHORT i,n;
n = GETBITS(9);
DROPBITS(9);
if (n>0){
for (i=0; i<n; i++) {
c_len[i] = (UCHAR)GETBITS(5);
DROPBITS(5);
}
for (i=n; i<510; i++) c_len[i] = 0;
if (dms_make_table(510,c_len,12,c_table)) return 1;
} else {
n = GETBITS(9);
DROPBITS(9);
for (i=0; i<510; i++) c_len[i] = 0;
for (i=0; i<4096; i++) c_table[i] = n;
}
return 0;
}
static USHORT read_tree_p(void){
USHORT i,n;
n = GETBITS(5);
DROPBITS(5);
if (n>0){
for (i=0; i<n; i++) {
pt_len[i] = (UCHAR)GETBITS(4);
DROPBITS(4);
}
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<dms_np; i++) pt_len[i] = 0;
for (i=0; i<256; i++) pt_table[i] = n;
}
return 0;
}
USHORT Unpack_HEAVY(UCHAR *, UCHAR *, UCHAR, USHORT);
extern USHORT dms_heavy_text_loc;
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Decruncher reinitialization
*
*/
#include <string.h>
#include "cdata.h"
#include "u_init.h"
#include "u_quick.h"
#include "u_medium.h"
#include "u_deep.h"
#include "u_heavy.h"
void Init_Decrunchers(void){
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;
}
void Init_Decrunchers(void);
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Main decompression functions used in MEDIUM mode
*
*/
#include <string.h>
#include "cdata.h"
#include "u_medium.h"
#include "getbits.h"
#include "tables.h"
#define MBITMASK 0x3fff
USHORT dms_medium_text_loc;
USHORT Unpack_MEDIUM(UCHAR *in, UCHAR *out, USHORT origsize){
USHORT i, j, c;
UCHAR u, *outend;
initbitbuf(in);
outend = out+origsize;
while (out < outend) {
if (GETBITS(1)!=0) {
DROPBITS(1);
*out++ = dms_text[dms_medium_text_loc++ & MBITMASK] = (UCHAR)GETBITS(8);
DROPBITS(8);
} else {
DROPBITS(1);
c = GETBITS(8); DROPBITS(8);
j = (USHORT) (d_code[c]+3);
u = d_len[c];
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) (dms_medium_text_loc - c - 1);
while(j--) *out++ = dms_text[dms_medium_text_loc++ & MBITMASK] = dms_text[i++ & MBITMASK];
}
}
dms_medium_text_loc = (USHORT)((dms_medium_text_loc+66) & MBITMASK);
return 0;
}
USHORT Unpack_MEDIUM(UCHAR *, UCHAR *, USHORT);
extern USHORT dms_medium_text_loc;
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
*
*/
#include <string.h>
#include "cdata.h"
#include "u_quick.h"
#include "getbits.h"
#define QBITMASK 0xff
USHORT dms_quick_text_loc;
USHORT Unpack_QUICK(UCHAR *in, UCHAR *out, USHORT origsize){
USHORT i, j;
UCHAR *outend;
initbitbuf(in);
outend = out+origsize;
while (out < outend) {
if (GETBITS(1)!=0) {
DROPBITS(1);
*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) (dms_quick_text_loc - GETBITS(8) - 1); DROPBITS(8);
while(j--) {
*out++ = dms_text[dms_quick_text_loc++ & QBITMASK] = dms_text[i++ & QBITMASK];
}
}
}
dms_quick_text_loc = (USHORT)((dms_quick_text_loc+5) & QBITMASK);
return 0;
}
USHORT Unpack_QUICK(UCHAR *, UCHAR *, USHORT);
extern USHORT dms_quick_text_loc;
/*
* xDMS v1.3 - Portable DMS archive unpacker - Public Domain
* Written by Andre Rodrigues de la Rocha <adlroc@usa.net>
*
* Run Length Encoding decompression function used in most
* modes after decompression by other algorithm
*
*/
#include <string.h>
#include "cdata.h"
#include "u_rle.h"
USHORT Unpack_RLE(UCHAR *in, UCHAR *out, USHORT origsize){
USHORT n;
UCHAR a,b, *outend;
outend = out+origsize;
while (out<outend){
if ((a = *in++) != 0x90)
*out++ = a;
else if (!(b = *in++))
*out++ = a;
else {
a = *in++;
if (b == 0xff) {
n = *in++;
n = (USHORT)((n<<8) + *in++);
} else
n = b;
if (out+n > outend) return 1;
memset(out,a,(size_t) n);
out += n;
}
}
return 0;
}
USHORT Unpack_RLE(UCHAR *, UCHAR *, USHORT);
......@@ -11,6 +11,7 @@ struct zfile {
uae_u8 *data; // unpacked data
int dataseek; // use seek position even if real file
struct zfile *archiveparent; // set if parent is archive and this has not yet been unpacked (datasize < size)
int archiveid;
uae_s64 size; // real size
uae_s64 datasize; // available size (not yet unpacked completely?)
uae_s64 seek; // seek position
......@@ -98,6 +99,7 @@ struct zarchive_info
#define PEEK_BYTES 1024
#define FILE_PEEK 1
#define FILE_DELAYEDOPEN 2
extern int zfile_is_ignore_ext (const TCHAR *name);
......@@ -141,5 +143,6 @@ extern void archive_access_scan (struct zfile *zf, zfile_callback zc, void *user
extern void archive_access_close (void *handle, unsigned int id);
extern struct zfile *archive_getzfile (struct znode *zn, unsigned int id, int flags);
extern struct zfile *archive_unpackzfile (struct zfile *zf);
extern struct zfile *decompress_zfd (struct zfile*);
\ No newline at end of file
......@@ -33,6 +33,7 @@ typedef int (*zfile_callback)(struct zfile*, void*);
extern struct zfile *zfile_fopen (const TCHAR *, const TCHAR *, int mask);
extern struct zfile *zfile_fopen2 (const TCHAR *, const TCHAR *, int mask, int index);
extern struct zfile *zfile_fopen_empty (struct zfile*, const TCHAR *name, uae_u64 size);
extern struct zfile *zfile_fopen_empty2 (struct zfile*, const TCHAR *name);
extern struct zfile *zfile_fopen_data (const TCHAR *name, uae_u64 size, uae_u8 *data);
extern struct zfile *zfile_fopen_parent (struct zfile*, const TCHAR*, uae_u64 offset, uae_u64 size);
......@@ -42,7 +43,7 @@ extern uae_s64 zfile_fseek (struct zfile *z, uae_s64 offset, int mode);
extern uae_s64 zfile_ftell (struct zfile *z);
extern uae_s64 zfile_size (struct zfile *z);
extern size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z);
extern size_t zfile_fwrite (const void *b, size_t l1, size_t l2, struct zfile *z);
extern size_t zfile_fwrite (void *b, size_t l1, size_t l2, struct zfile *z);
extern TCHAR *zfile_fgets (TCHAR *s, int size, struct zfile *z);
extern char *zfile_fgetsa (char *s, int size, struct zfile *z);
extern size_t zfile_fputs (struct zfile *z, TCHAR *s);
......@@ -66,7 +67,6 @@ extern int zfile_is_diskimage (const TCHAR *name);
extern int iszip (struct zfile *z);
extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst);
//extern struct zfile *zuncompress (struct znode*, struct zfile *z, int dodefault, int mask, int *retcode, int index);
static struct zfile *zuncompress (struct zfile *z);
extern void zfile_seterror (const TCHAR *format, ...);
extern TCHAR *zfile_geterror (void);
......@@ -79,6 +79,7 @@ extern TCHAR *zfile_geterror (void);
#define ZFD_CD 32 //cue/iso, cue has priority over iso
#define ZFD_DISKHISTORY 0x100 //allow diskhistory (if disk image)
#define ZFD_CHECKONLY 0x200 //file exists checkc
#define ZFD_DELAYEDOPEN 0x400 //do not unpack, just get metadata
#define ZFD_NORMAL (ZFD_ARCHIVE|ZFD_UNPACK)
#define ZFD_ALL 0x0000ffff
......@@ -101,17 +102,19 @@ extern const TCHAR *uae_ignoreextensions[];
extern const TCHAR *uae_diskimageextensions[];
extern struct zvolume *zfile_fopen_archive (const TCHAR *filename);
extern struct zvolume *zfile_fopen_archive2 (const TCHAR *filename, bool norecurse);
extern struct zvolume *zfile_fopen_archive_root (const TCHAR *filename);
extern void zfile_fclose_archive (struct zvolume *zv);
extern int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp);
extern int zfile_stat_archive (const TCHAR *path, struct _stat64 *statbuf);
extern void *zfile_opendir_archive (const TCHAR *path);
extern void zfile_closedir_archive (void*);
extern int zfile_readdir_archive (void*, TCHAR*);
extern void zfile_resetdir_archive (void*);
extern zfile_fill_file_attrs_archive (const TCHAR *path, int *isdir, int *flags, TCHAR **comment);
extern uae_s64 zfile_lseek_archive (void *d, uae_s64 offset, int whence);
extern unsigned int zfile_read_archive (void *d, void *b, unsigned int size);
extern void zfile_close_archive (void *d);
extern void *zfile_open_archive (const TCHAR *path, int flags);
extern int zfile_exists_archive(const TCHAR *path, const TCHAR *rel);
extern struct zdirectory *zfile_opendir_archive (const TCHAR *path);
extern void zfile_closedir_archive (struct zdirectory *);
extern int zfile_readdir_archive (struct zdirectory *, TCHAR*);
extern int zfile_readdir_archive2 (struct zdirectory *, TCHAR*, bool fullpath);
extern void zfile_resetdir_archive (struct zdirectory *);
extern int zfile_fill_file_attrs_archive (const TCHAR *path, int *isdir, int *flags, TCHAR **comment);
extern uae_s64 zfile_lseek_archive (struct zfile *d, uae_s64 offset, int whence);
extern unsigned int zfile_read_archive (struct zfile *d, void *b, unsigned int size);
extern void zfile_close_archive (struct zfile *d);
extern struct zfile *zfile_open_archive (const TCHAR *path, int flags);
extern int zfile_exists_archive (const TCHAR *path, const TCHAR *rel);
......@@ -973,3 +973,24 @@ void clearallkeys (void)
{
inputdevice_updateconfig (&currprefs);
}
//fsdb_mywin32.c
FILE *my_opentext (const TCHAR *name)
{
FILE *f;
uae_u8 tmp[4];
int v;
f = _tfopen (name, "rb");
if (!f)
return NULL;
v = fread (tmp, 1, 4, f);
fclose (f);
if (v == 4) {
if (tmp[0] == 0xef && tmp[1] == 0xbb && tmp[2] == 0xbf)
return _tfopen (name, "r, ccs=UTF-8");
if (tmp[0] == 0xff && tmp[1] == 0xfe)
return _tfopen (name, "r, ccs=UTF-16LE");
}
return _tfopen (name, "r");
}
......@@ -28,8 +28,8 @@
<key>CFBundleName</key>
<string>PUAE</string>
<key>CFBundleGetInfoString</key>
<string>2.3.0</string>
<string>2.2.0</string>
<key>CFBundleVersion</key>
<string>2.3.0</string>
<string>2.2.0</string>
</dict>
</plist>
......@@ -293,7 +293,7 @@
#define PACKAGE_NAME "PUAE"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "PUAE 2.3.0"
#define PACKAGE_STRING "PUAE 2.2.0"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "puae"
......@@ -302,7 +302,7 @@
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "2.3.0"
#define PACKAGE_VERSION "2.2.0"
/* Define to the necessary symbol if this constant uses a non-standard name on
your system. */
......@@ -395,7 +395,7 @@
/* Version number of package */
#define VERSION "2.3.0"
#define VERSION "2.2.0"
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
significant byte first (like Motorola and SPARC, unlike Intel). */
......
......@@ -445,7 +445,7 @@ configure:4344: $? = 0
configure:4344: result: yes
configure:4350: checking for _doprnt
configure:4350: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/cc0HrNmb.o: In function `main':
/tmp/ccsRj39K.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:67: undefined reference to `_doprnt'
collect2: ld returned 1 exit status
configure:4350: $? = 1
......@@ -533,7 +533,7 @@ configure:4364: $? = 0
configure:4364: result: yes
configure:4364: checking for strcmpi
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccicgnNt.o: In function `main':
/tmp/ccHamKwY.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `strcmpi'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......@@ -613,7 +613,7 @@ configure: failed program was:
configure:4364: result: no
configure:4364: checking for stricmp
configure:4364: gcc -o conftest -g -O2 -Wall -W -Wno-unused conftest.c >&5
/tmp/ccl1sm5w.o: In function `main':
/tmp/ccfzHOQ3.o: In function `main':
/home/gnostic/puaex/src/tools/conftest.c:69: undefined reference to `stricmp'
collect2: ld returned 1 exit status
configure:4364: $? = 1
......@@ -817,7 +817,7 @@ PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
SET_MAKE=''
SHELL='/bin/bash'
SHELL='/bin/sh'
ac_ct_CC='gcc'
ac_cv_c_inline='inline'
bindir='${exec_prefix}/bin'
......
#! /bin/bash
#! /bin/sh
# Generated by configure.
# Run this file to recreate the current configuration.
# Compiler output produced by configure, useful for debugging
......@@ -8,7 +8,7 @@ debug=false
ac_cs_recheck=false
ac_cs_silent=false
SHELL=${CONFIG_SHELL-/bin/bash}
SHELL=${CONFIG_SHELL-/bin/sh}
export SHELL
## -------------------- ##
## M4sh Initialization. ##
......@@ -522,10 +522,10 @@ if $ac_cs_silent; then
fi
if $ac_cs_recheck; then
set X '/bin/bash' './configure' '--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-sdl-sound' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion
set X '/bin/sh' './configure' '--disable-option-checking' '--prefix=/usr/local' '--with-sdl' '--with-sdl-gl' '--with-sdl-gfx' '--with-sdl-sound' '--with-caps' '--with-gayle' '--enable-drvsnd' '--enable-amax' '--enable-cd32' '--enable-scsi-device' '--cache-file=/dev/null' '--srcdir=.' $ac_configure_extra_args --no-create --no-recursion
shift
$as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
CONFIG_SHELL='/bin/bash'
$as_echo "running CONFIG_SHELL=/bin/sh $*" >&6
CONFIG_SHELL='/bin/sh'
export CONFIG_SHELL
exec "$@"
fi
......@@ -685,7 +685,7 @@ S["PACKAGE_VERSION"]=""
S["PACKAGE_TARNAME"]=""
S["PACKAGE_NAME"]=""
S["PATH_SEPARATOR"]=":"
S["SHELL"]="/bin/bash"
S["SHELL"]="/bin/sh"
_ACAWK
cat >>"$tmp/subs1.awk" <<_ACAWK &&
for (key in S) S_is_set[key] = 1
......
......@@ -369,7 +369,7 @@ static uae_u32 REGPARAM2 uaelib_demux2 (TrapContext *context)
#ifndef UAEGFX_INTERNAL
// if (ARG0 >= 16 && ARG0 <= 39)
// return picasso_demux (ARG0, context);
// return picasso_demux (ARG0, context);
#endif
switch (ARG0)
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment