home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
comm
/
misc
/
elcheapofax
/
rcs
/
unpacker.c,v
< prev
Wrap
Text File
|
1993-12-21
|
2KB
|
112 lines
head 1.2;
access;
symbols
OCT93:1.2;
locks;
comment @ * @;
1.2
date 93.06.11.16.33.37; author Rhialto; state Exp;
branches;
next 1.1;
1.1
date 93.06.11.14.53.53; author Rhialto; state Exp;
branches;
next ;
desc
@ILBM CmpByteRun1 unpacker
@
1.2
log
@First real RCS checkin
@
text
@/* $Id$
* $Log$
*/
#include "iffp/ilbm.h"
#include "iffp/packer.h"
/*----------------------------------------------------------------------*
* unpacker.c Convert data from "cmpByteRun1" run compression. 11/15/85
*
* Based on code by Jerry Morrison and Steve Shaw, Electronic Arts.
* This software is in the public domain.
*
* control bytes:
* [0..127] : followed by n+1 bytes of data.
* [-1..-127] : followed by byte to be repeated (-n)+1 times.
* -128 : NOOP.
*
* This version for the Commodore-Amiga computer.
*----------------------------------------------------------------------*/
/*----------- UnPackRow ------------------------------------------------*/
#define UGetByte() (*source++)
#define UPutByte(c) (*dest++ = (c))
/* Given POINTERS to POINTER variables, unpacks one row, updating the source
* and destination pointers until it produces dstBytes bytes.
*/
BOOL UnPackRow(BYTE **pSource, BYTE **pDest, WORD srcBytes0, WORD dstBytes0)
{
register BYTE *source = *pSource;
register BYTE *dest = *pDest;
register WORD n;
register WORD srcBytes = srcBytes0;
register WORD dstBytes = dstBytes0;
BOOL error = TRUE; /* assume error until we make it through the loop */
WORD minus128 = -128; /* get the compiler to generate a CMP.W */
BYTE c;
D(bug("unpackrow: srcBytes0=%ld dstBytes0=%ld\n",srcBytes0, dstBytes0));
while( dstBytes > 0 ) {
if ( (srcBytes -= 1) < 0 ) goto ErrorExit;
n = UGetByte();
if (n >= 0) {
n += 1;
if ( (srcBytes -= n) < 0 ) goto ErrorExit;
if ( (dstBytes -= n) < 0 ) goto ErrorExit;
do { UPutByte(UGetByte()); } while (--n > 0);
}
else if (n != minus128) {
n = -n + 1;
if ( (srcBytes -= 1) < 0 ) goto ErrorExit;
if ( (dstBytes -= n) < 0 ) goto ErrorExit;
c = UGetByte();
do { UPutByte(c); } while (--n > 0);
}
}
error = FALSE; /* success! */
ErrorExit:
*pSource = source; *pDest = dest;
D(bug("unpackrow exit: srcBytes=%ld dstBytes=%ld n=%ld\n",srcBytes, dstBytes, n));
return(error);
}
/* end */
@
1.1
log
@Initial revision
@
text
@d1 3
@