mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
Merge branch 'master' into scripting
Conflicts: src/actor.h src/dobject.h src/dobjgc.cpp src/p_local.h src/thingdef/thingdef_codeptr.cpp
This commit is contained in:
commit
9744b9e0d9
34 changed files with 3972 additions and 3691 deletions
3540
lzma/C/7zArcIn.c
3540
lzma/C/7zArcIn.c
File diff suppressed because it is too large
Load diff
512
lzma/C/7zTypes.h
512
lzma/C/7zTypes.h
|
@ -1,256 +1,256 @@
|
|||
/* 7zTypes.h -- Basic types
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_TYPES_H
|
||||
#define __7Z_TYPES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef EXTERN_C_BEGIN
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_BEGIN extern "C" {
|
||||
#define EXTERN_C_END }
|
||||
#else
|
||||
#define EXTERN_C_BEGIN
|
||||
#define EXTERN_C_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define SZ_OK 0
|
||||
|
||||
#define SZ_ERROR_DATA 1
|
||||
#define SZ_ERROR_MEM 2
|
||||
#define SZ_ERROR_CRC 3
|
||||
#define SZ_ERROR_UNSUPPORTED 4
|
||||
#define SZ_ERROR_PARAM 5
|
||||
#define SZ_ERROR_INPUT_EOF 6
|
||||
#define SZ_ERROR_OUTPUT_EOF 7
|
||||
#define SZ_ERROR_READ 8
|
||||
#define SZ_ERROR_WRITE 9
|
||||
#define SZ_ERROR_PROGRESS 10
|
||||
#define SZ_ERROR_FAIL 11
|
||||
#define SZ_ERROR_THREAD 12
|
||||
|
||||
#define SZ_ERROR_ARCHIVE 16
|
||||
#define SZ_ERROR_NO_ARCHIVE 17
|
||||
|
||||
typedef int SRes;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef DWORD WRes;
|
||||
/* typedef unsigned WRes; */
|
||||
#else
|
||||
typedef int WRes;
|
||||
#endif
|
||||
|
||||
#ifndef RINOK
|
||||
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
||||
#endif
|
||||
|
||||
typedef unsigned char Byte;
|
||||
typedef short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
typedef long Int32;
|
||||
typedef unsigned long UInt32;
|
||||
#else
|
||||
typedef int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
|
||||
#ifdef _SZ_NO_INT_64
|
||||
|
||||
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
|
||||
NOTES: Some code will work incorrectly in that case! */
|
||||
|
||||
typedef long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#define UINT64_CONST(n) n
|
||||
#else
|
||||
typedef long long int Int64;
|
||||
typedef unsigned long long int UInt64;
|
||||
#define UINT64_CONST(n) n ## ULL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||
typedef UInt32 SizeT;
|
||||
#else
|
||||
typedef size_t SizeT;
|
||||
#endif
|
||||
|
||||
typedef int Bool;
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_STD_CALL __stdcall
|
||||
#else
|
||||
#define MY_STD_CALL
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#define MY_NO_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define MY_NO_INLINE
|
||||
#endif
|
||||
|
||||
#define MY_CDECL __cdecl
|
||||
#define MY_FAST_CALL __fastcall
|
||||
|
||||
#else
|
||||
|
||||
#define MY_NO_INLINE
|
||||
#define MY_CDECL
|
||||
#define MY_FAST_CALL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* The following interfaces use first parameter as pointer to structure */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
|
||||
} IByteIn;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Write)(void *p, Byte b);
|
||||
} IByteOut;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||
(output(*size) < input(*size)) is allowed */
|
||||
} ISeqInStream;
|
||||
|
||||
/* it can return SZ_ERROR_INPUT_EOF */
|
||||
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
|
||||
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
|
||||
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t (*Write)(void *p, const void *buf, size_t size);
|
||||
/* Returns: result - the number of actually written bytes.
|
||||
(result < size) means error */
|
||||
} ISeqOutStream;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SZ_SEEK_SET = 0,
|
||||
SZ_SEEK_CUR = 1,
|
||||
SZ_SEEK_END = 2
|
||||
} ESzSeek;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
|
||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||
} ISeekInStream;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Look)(void *p, const void **buf, size_t *size);
|
||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||
(output(*size) > input(*size)) is not allowed
|
||||
(output(*size) < input(*size)) is allowed */
|
||||
SRes (*Skip)(void *p, size_t offset);
|
||||
/* offset must be <= output(*size) of Look */
|
||||
|
||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||
/* reads directly (without buffer). It's same as ISeqInStream::Read */
|
||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||
} ILookInStream;
|
||||
|
||||
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
|
||||
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
|
||||
|
||||
/* reads via ILookInStream::Read */
|
||||
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
|
||||
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
|
||||
|
||||
#define LookToRead_BUF_SIZE (1 << 14)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ILookInStream s;
|
||||
ISeekInStream *realStream;
|
||||
size_t pos;
|
||||
size_t size;
|
||||
Byte buf[LookToRead_BUF_SIZE];
|
||||
} CLookToRead;
|
||||
|
||||
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
||||
void LookToRead_Init(CLookToRead *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ISeqInStream s;
|
||||
ILookInStream *realStream;
|
||||
} CSecToLook;
|
||||
|
||||
void SecToLook_CreateVTable(CSecToLook *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ISeqInStream s;
|
||||
ILookInStream *realStream;
|
||||
} CSecToRead;
|
||||
|
||||
void SecToRead_CreateVTable(CSecToRead *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
|
||||
/* Returns: result. (result != SZ_OK) means break.
|
||||
Value (UInt64)(Int64)-1 for size means unknown value. */
|
||||
} ICompressProgress;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *(*Alloc)(void *p, size_t size);
|
||||
void (*Free)(void *p, void *address); /* address can be 0 */
|
||||
} ISzAlloc;
|
||||
|
||||
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
||||
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define CHAR_PATH_SEPARATOR '\\'
|
||||
#define WCHAR_PATH_SEPARATOR L'\\'
|
||||
#define STRING_PATH_SEPARATOR "\\"
|
||||
#define WSTRING_PATH_SEPARATOR L"\\"
|
||||
|
||||
#else
|
||||
|
||||
#define CHAR_PATH_SEPARATOR '/'
|
||||
#define WCHAR_PATH_SEPARATOR L'/'
|
||||
#define STRING_PATH_SEPARATOR "/"
|
||||
#define WSTRING_PATH_SEPARATOR L"/"
|
||||
|
||||
#endif
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
/* 7zTypes.h -- Basic types
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_TYPES_H
|
||||
#define __7Z_TYPES_H
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef EXTERN_C_BEGIN
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_BEGIN extern "C" {
|
||||
#define EXTERN_C_END }
|
||||
#else
|
||||
#define EXTERN_C_BEGIN
|
||||
#define EXTERN_C_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define SZ_OK 0
|
||||
|
||||
#define SZ_ERROR_DATA 1
|
||||
#define SZ_ERROR_MEM 2
|
||||
#define SZ_ERROR_CRC 3
|
||||
#define SZ_ERROR_UNSUPPORTED 4
|
||||
#define SZ_ERROR_PARAM 5
|
||||
#define SZ_ERROR_INPUT_EOF 6
|
||||
#define SZ_ERROR_OUTPUT_EOF 7
|
||||
#define SZ_ERROR_READ 8
|
||||
#define SZ_ERROR_WRITE 9
|
||||
#define SZ_ERROR_PROGRESS 10
|
||||
#define SZ_ERROR_FAIL 11
|
||||
#define SZ_ERROR_THREAD 12
|
||||
|
||||
#define SZ_ERROR_ARCHIVE 16
|
||||
#define SZ_ERROR_NO_ARCHIVE 17
|
||||
|
||||
typedef int SRes;
|
||||
|
||||
#ifdef _WIN32
|
||||
typedef DWORD WRes;
|
||||
/* typedef unsigned WRes; */
|
||||
#else
|
||||
typedef int WRes;
|
||||
#endif
|
||||
|
||||
#ifndef RINOK
|
||||
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
||||
#endif
|
||||
|
||||
typedef unsigned char Byte;
|
||||
typedef short Int16;
|
||||
typedef unsigned short UInt16;
|
||||
|
||||
#ifdef _LZMA_UINT32_IS_ULONG
|
||||
typedef long Int32;
|
||||
typedef unsigned long UInt32;
|
||||
#else
|
||||
typedef int Int32;
|
||||
typedef unsigned int UInt32;
|
||||
#endif
|
||||
|
||||
#ifdef _SZ_NO_INT_64
|
||||
|
||||
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
|
||||
NOTES: Some code will work incorrectly in that case! */
|
||||
|
||||
typedef long Int64;
|
||||
typedef unsigned long UInt64;
|
||||
|
||||
#else
|
||||
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
||||
typedef __int64 Int64;
|
||||
typedef unsigned __int64 UInt64;
|
||||
#define UINT64_CONST(n) n
|
||||
#else
|
||||
typedef long long int Int64;
|
||||
typedef unsigned long long int UInt64;
|
||||
#define UINT64_CONST(n) n ## ULL
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
||||
typedef UInt32 SizeT;
|
||||
#else
|
||||
typedef size_t SizeT;
|
||||
#endif
|
||||
|
||||
typedef int Bool;
|
||||
#define True 1
|
||||
#define False 0
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
#define MY_STD_CALL __stdcall
|
||||
#else
|
||||
#define MY_STD_CALL
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#define MY_NO_INLINE __declspec(noinline)
|
||||
#else
|
||||
#define MY_NO_INLINE
|
||||
#endif
|
||||
|
||||
#define MY_CDECL __cdecl
|
||||
#define MY_FAST_CALL __fastcall
|
||||
|
||||
#else
|
||||
|
||||
#define MY_NO_INLINE
|
||||
#define MY_CDECL
|
||||
#define MY_FAST_CALL
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* The following interfaces use first parameter as pointer to structure */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */
|
||||
} IByteIn;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void (*Write)(void *p, Byte b);
|
||||
} IByteOut;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||
(output(*size) < input(*size)) is allowed */
|
||||
} ISeqInStream;
|
||||
|
||||
/* it can return SZ_ERROR_INPUT_EOF */
|
||||
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
|
||||
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
|
||||
SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
size_t (*Write)(void *p, const void *buf, size_t size);
|
||||
/* Returns: result - the number of actually written bytes.
|
||||
(result < size) means error */
|
||||
} ISeqOutStream;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SZ_SEEK_SET = 0,
|
||||
SZ_SEEK_CUR = 1,
|
||||
SZ_SEEK_END = 2
|
||||
} ESzSeek;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
|
||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||
} ISeekInStream;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Look)(void *p, const void **buf, size_t *size);
|
||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
||||
(output(*size) > input(*size)) is not allowed
|
||||
(output(*size) < input(*size)) is allowed */
|
||||
SRes (*Skip)(void *p, size_t offset);
|
||||
/* offset must be <= output(*size) of Look */
|
||||
|
||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
||||
/* reads directly (without buffer). It's same as ISeqInStream::Read */
|
||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
||||
} ILookInStream;
|
||||
|
||||
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
|
||||
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
|
||||
|
||||
/* reads via ILookInStream::Read */
|
||||
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
|
||||
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
|
||||
|
||||
#define LookToRead_BUF_SIZE (1 << 14)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ILookInStream s;
|
||||
ISeekInStream *realStream;
|
||||
size_t pos;
|
||||
size_t size;
|
||||
Byte buf[LookToRead_BUF_SIZE];
|
||||
} CLookToRead;
|
||||
|
||||
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
||||
void LookToRead_Init(CLookToRead *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ISeqInStream s;
|
||||
ILookInStream *realStream;
|
||||
} CSecToLook;
|
||||
|
||||
void SecToLook_CreateVTable(CSecToLook *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ISeqInStream s;
|
||||
ILookInStream *realStream;
|
||||
} CSecToRead;
|
||||
|
||||
void SecToRead_CreateVTable(CSecToRead *p);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
|
||||
/* Returns: result. (result != SZ_OK) means break.
|
||||
Value (UInt64)(Int64)-1 for size means unknown value. */
|
||||
} ICompressProgress;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *(*Alloc)(void *p, size_t size);
|
||||
void (*Free)(void *p, void *address); /* address can be 0 */
|
||||
} ISzAlloc;
|
||||
|
||||
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
||||
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define CHAR_PATH_SEPARATOR '\\'
|
||||
#define WCHAR_PATH_SEPARATOR L'\\'
|
||||
#define STRING_PATH_SEPARATOR "\\"
|
||||
#define WSTRING_PATH_SEPARATOR L"\\"
|
||||
|
||||
#else
|
||||
|
||||
#define CHAR_PATH_SEPARATOR '/'
|
||||
#define WCHAR_PATH_SEPARATOR L'/'
|
||||
#define STRING_PATH_SEPARATOR "/"
|
||||
#define WSTRING_PATH_SEPARATOR L"/"
|
||||
|
||||
#endif
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
|
138
lzma/C/BraIA64.c
138
lzma/C/BraIA64.c
|
@ -1,69 +1,69 @@
|
|||
/* BraIA64.c -- Converter for IA-64 code
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Bra.h"
|
||||
|
||||
static const Byte kBranchTable[32] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
4, 4, 6, 6, 0, 0, 7, 7,
|
||||
4, 4, 0, 0, 4, 4, 0, 0
|
||||
};
|
||||
|
||||
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
{
|
||||
SizeT i;
|
||||
if (size < 16)
|
||||
return 0;
|
||||
size -= 16;
|
||||
for (i = 0; i <= size; i += 16)
|
||||
{
|
||||
UInt32 instrTemplate = data[i] & 0x1F;
|
||||
UInt32 mask = kBranchTable[instrTemplate];
|
||||
UInt32 bitPos = 5;
|
||||
int slot;
|
||||
for (slot = 0; slot < 3; slot++, bitPos += 41)
|
||||
{
|
||||
UInt32 bytePos, bitRes;
|
||||
UInt64 instruction, instNorm;
|
||||
int j;
|
||||
if (((mask >> slot) & 1) == 0)
|
||||
continue;
|
||||
bytePos = (bitPos >> 3);
|
||||
bitRes = bitPos & 0x7;
|
||||
instruction = 0;
|
||||
for (j = 0; j < 6; j++)
|
||||
instruction += (UInt64)data[i + j + bytePos] << (8 * j);
|
||||
|
||||
instNorm = instruction >> bitRes;
|
||||
if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
|
||||
{
|
||||
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
|
||||
UInt32 dest;
|
||||
src |= ((UInt32)(instNorm >> 36) & 1) << 20;
|
||||
|
||||
src <<= 4;
|
||||
|
||||
if (encoding)
|
||||
dest = ip + (UInt32)i + src;
|
||||
else
|
||||
dest = src - (ip + (UInt32)i);
|
||||
|
||||
dest >>= 4;
|
||||
|
||||
instNorm &= ~((UInt64)(0x8FFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
|
||||
|
||||
instruction &= (1 << bitRes) - 1;
|
||||
instruction |= (instNorm << bitRes);
|
||||
for (j = 0; j < 6; j++)
|
||||
data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
/* BraIA64.c -- Converter for IA-64 code
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Bra.h"
|
||||
|
||||
static const Byte kBranchTable[32] =
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0,
|
||||
4, 4, 6, 6, 0, 0, 7, 7,
|
||||
4, 4, 0, 0, 4, 4, 0, 0
|
||||
};
|
||||
|
||||
SizeT IA64_Convert(Byte *data, SizeT size, UInt32 ip, int encoding)
|
||||
{
|
||||
SizeT i;
|
||||
if (size < 16)
|
||||
return 0;
|
||||
size -= 16;
|
||||
for (i = 0; i <= size; i += 16)
|
||||
{
|
||||
UInt32 instrTemplate = data[i] & 0x1F;
|
||||
UInt32 mask = kBranchTable[instrTemplate];
|
||||
UInt32 bitPos = 5;
|
||||
int slot;
|
||||
for (slot = 0; slot < 3; slot++, bitPos += 41)
|
||||
{
|
||||
UInt32 bytePos, bitRes;
|
||||
UInt64 instruction, instNorm;
|
||||
int j;
|
||||
if (((mask >> slot) & 1) == 0)
|
||||
continue;
|
||||
bytePos = (bitPos >> 3);
|
||||
bitRes = bitPos & 0x7;
|
||||
instruction = 0;
|
||||
for (j = 0; j < 6; j++)
|
||||
instruction += (UInt64)data[i + j + bytePos] << (8 * j);
|
||||
|
||||
instNorm = instruction >> bitRes;
|
||||
if (((instNorm >> 37) & 0xF) == 0x5 && ((instNorm >> 9) & 0x7) == 0)
|
||||
{
|
||||
UInt32 src = (UInt32)((instNorm >> 13) & 0xFFFFF);
|
||||
UInt32 dest;
|
||||
src |= ((UInt32)(instNorm >> 36) & 1) << 20;
|
||||
|
||||
src <<= 4;
|
||||
|
||||
if (encoding)
|
||||
dest = ip + (UInt32)i + src;
|
||||
else
|
||||
dest = src - (ip + (UInt32)i);
|
||||
|
||||
dest >>= 4;
|
||||
|
||||
instNorm &= ~((UInt64)(0x8FFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0xFFFFF) << 13);
|
||||
instNorm |= ((UInt64)(dest & 0x100000) << (36 - 20));
|
||||
|
||||
instruction &= (1 << bitRes) - 1;
|
||||
instruction |= (instNorm << bitRes);
|
||||
for (j = 0; j < 6; j++)
|
||||
data[i + j + bytePos] = (Byte)(instruction >> (8 * j));
|
||||
}
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
|
|
@ -1,32 +1,32 @@
|
|||
/* Compiler.h
|
||||
2015-08-02 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_COMPILER_H
|
||||
#define __7Z_COMPILER_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define RPC_NO_WINDOWS_H
|
||||
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
|
||||
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#pragma warning(disable : 4996) // This function or variable may be unsafe
|
||||
#else
|
||||
#pragma warning(disable : 4511) // copy constructor could not be generated
|
||||
#pragma warning(disable : 4512) // assignment operator could not be generated
|
||||
#pragma warning(disable : 4514) // unreferenced inline function has been removed
|
||||
#pragma warning(disable : 4702) // unreachable code
|
||||
#pragma warning(disable : 4710) // not inlined
|
||||
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define UNUSED_VAR(x) (void)x;
|
||||
/* #define UNUSED_VAR(x) x=x; */
|
||||
|
||||
#endif
|
||||
/* Compiler.h
|
||||
2015-08-02 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_COMPILER_H
|
||||
#define __7Z_COMPILER_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#ifdef UNDER_CE
|
||||
#define RPC_NO_WINDOWS_H
|
||||
/* #pragma warning(disable : 4115) // '_RPC_ASYNC_STATE' : named type definition in parentheses */
|
||||
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
|
||||
#pragma warning(disable : 4214) // nonstandard extension used : bit field types other than int
|
||||
#endif
|
||||
|
||||
#if _MSC_VER >= 1300
|
||||
#pragma warning(disable : 4996) // This function or variable may be unsafe
|
||||
#else
|
||||
#pragma warning(disable : 4511) // copy constructor could not be generated
|
||||
#pragma warning(disable : 4512) // assignment operator could not be generated
|
||||
#pragma warning(disable : 4514) // unreferenced inline function has been removed
|
||||
#pragma warning(disable : 4702) // unreachable code
|
||||
#pragma warning(disable : 4710) // not inlined
|
||||
#pragma warning(disable : 4786) // identifier was truncated to '255' characters in the debug information
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#define UNUSED_VAR(x) (void)x;
|
||||
/* #define UNUSED_VAR(x) x=x; */
|
||||
|
||||
#endif
|
||||
|
|
128
lzma/C/Delta.c
128
lzma/C/Delta.c
|
@ -1,64 +1,64 @@
|
|||
/* Delta.c -- Delta converter
|
||||
2009-05-26 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Delta.h"
|
||||
|
||||
void Delta_Init(Byte *state)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < DELTA_STATE_SIZE; i++)
|
||||
state[i] = 0;
|
||||
}
|
||||
|
||||
static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < size; i++)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
|
||||
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||
{
|
||||
Byte buf[DELTA_STATE_SIZE];
|
||||
unsigned j = 0;
|
||||
MyMemCpy(buf, state, delta);
|
||||
{
|
||||
SizeT i;
|
||||
for (i = 0; i < size;)
|
||||
{
|
||||
for (j = 0; j < delta && i < size; i++, j++)
|
||||
{
|
||||
Byte b = data[i];
|
||||
data[i] = (Byte)(b - buf[j]);
|
||||
buf[j] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j == delta)
|
||||
j = 0;
|
||||
MyMemCpy(state, buf + j, delta - j);
|
||||
MyMemCpy(state + delta - j, buf, j);
|
||||
}
|
||||
|
||||
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||
{
|
||||
Byte buf[DELTA_STATE_SIZE];
|
||||
unsigned j = 0;
|
||||
MyMemCpy(buf, state, delta);
|
||||
{
|
||||
SizeT i;
|
||||
for (i = 0; i < size;)
|
||||
{
|
||||
for (j = 0; j < delta && i < size; i++, j++)
|
||||
{
|
||||
buf[j] = data[i] = (Byte)(buf[j] + data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j == delta)
|
||||
j = 0;
|
||||
MyMemCpy(state, buf + j, delta - j);
|
||||
MyMemCpy(state + delta - j, buf, j);
|
||||
}
|
||||
/* Delta.c -- Delta converter
|
||||
2009-05-26 : Igor Pavlov : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Delta.h"
|
||||
|
||||
void Delta_Init(Byte *state)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < DELTA_STATE_SIZE; i++)
|
||||
state[i] = 0;
|
||||
}
|
||||
|
||||
static void MyMemCpy(Byte *dest, const Byte *src, unsigned size)
|
||||
{
|
||||
unsigned i;
|
||||
for (i = 0; i < size; i++)
|
||||
dest[i] = src[i];
|
||||
}
|
||||
|
||||
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||
{
|
||||
Byte buf[DELTA_STATE_SIZE];
|
||||
unsigned j = 0;
|
||||
MyMemCpy(buf, state, delta);
|
||||
{
|
||||
SizeT i;
|
||||
for (i = 0; i < size;)
|
||||
{
|
||||
for (j = 0; j < delta && i < size; i++, j++)
|
||||
{
|
||||
Byte b = data[i];
|
||||
data[i] = (Byte)(b - buf[j]);
|
||||
buf[j] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j == delta)
|
||||
j = 0;
|
||||
MyMemCpy(state, buf + j, delta - j);
|
||||
MyMemCpy(state + delta - j, buf, j);
|
||||
}
|
||||
|
||||
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size)
|
||||
{
|
||||
Byte buf[DELTA_STATE_SIZE];
|
||||
unsigned j = 0;
|
||||
MyMemCpy(buf, state, delta);
|
||||
{
|
||||
SizeT i;
|
||||
for (i = 0; i < size;)
|
||||
{
|
||||
for (j = 0; j < delta && i < size; i++, j++)
|
||||
{
|
||||
buf[j] = data[i] = (Byte)(buf[j] + data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (j == delta)
|
||||
j = 0;
|
||||
MyMemCpy(state, buf + j, delta - j);
|
||||
MyMemCpy(state + delta - j, buf, j);
|
||||
}
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
/* Delta.h -- Delta converter
|
||||
2013-01-18 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __DELTA_H
|
||||
#define __DELTA_H
|
||||
|
||||
#include "7zTypes.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define DELTA_STATE_SIZE 256
|
||||
|
||||
void Delta_Init(Byte *state);
|
||||
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
/* Delta.h -- Delta converter
|
||||
2013-01-18 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __DELTA_H
|
||||
#define __DELTA_H
|
||||
|
||||
#include "7zTypes.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define DELTA_STATE_SIZE 256
|
||||
|
||||
void Delta_Init(Byte *state);
|
||||
void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||
void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
|
170
lzma/C/Ppmd.h
170
lzma/C/Ppmd.h
|
@ -1,85 +1,85 @@
|
|||
/* Ppmd.h -- PPMD codec common code
|
||||
2013-01-18 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#ifndef __PPMD_H
|
||||
#define __PPMD_H
|
||||
|
||||
#include "CpuArch.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#ifdef MY_CPU_32BIT
|
||||
#define PPMD_32BIT
|
||||
#endif
|
||||
|
||||
#define PPMD_INT_BITS 7
|
||||
#define PPMD_PERIOD_BITS 7
|
||||
#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))
|
||||
|
||||
#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))
|
||||
#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)
|
||||
#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))
|
||||
#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))
|
||||
|
||||
#define PPMD_N1 4
|
||||
#define PPMD_N2 4
|
||||
#define PPMD_N3 4
|
||||
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
||||
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
|
||||
|
||||
/* SEE-contexts for PPM-contexts with masked symbols */
|
||||
typedef struct
|
||||
{
|
||||
UInt16 Summ; /* Freq */
|
||||
Byte Shift; /* Speed of Freq change; low Shift is for fast change */
|
||||
Byte Count; /* Count to next change of Shift */
|
||||
} CPpmd_See;
|
||||
|
||||
#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
|
||||
{ (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Byte Symbol;
|
||||
Byte Freq;
|
||||
UInt16 SuccessorLow;
|
||||
UInt16 SuccessorHigh;
|
||||
} CPpmd_State;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
CPpmd_State *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_State_Ref;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
void *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_Void_Ref;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
Byte *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_Byte_Ref;
|
||||
|
||||
#define PPMD_SetAllBitsIn256Bytes(p) \
|
||||
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
|
||||
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
/* Ppmd.h -- PPMD codec common code
|
||||
2013-01-18 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#ifndef __PPMD_H
|
||||
#define __PPMD_H
|
||||
|
||||
#include "CpuArch.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#ifdef MY_CPU_32BIT
|
||||
#define PPMD_32BIT
|
||||
#endif
|
||||
|
||||
#define PPMD_INT_BITS 7
|
||||
#define PPMD_PERIOD_BITS 7
|
||||
#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS))
|
||||
|
||||
#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift))
|
||||
#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2)
|
||||
#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob))
|
||||
#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob))
|
||||
|
||||
#define PPMD_N1 4
|
||||
#define PPMD_N2 4
|
||||
#define PPMD_N3 4
|
||||
#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4)
|
||||
#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4)
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */
|
||||
|
||||
/* SEE-contexts for PPM-contexts with masked symbols */
|
||||
typedef struct
|
||||
{
|
||||
UInt16 Summ; /* Freq */
|
||||
Byte Shift; /* Speed of Freq change; low Shift is for fast change */
|
||||
Byte Count; /* Count to next change of Shift */
|
||||
} CPpmd_See;
|
||||
|
||||
#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \
|
||||
{ (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); }
|
||||
|
||||
typedef struct
|
||||
{
|
||||
Byte Symbol;
|
||||
Byte Freq;
|
||||
UInt16 SuccessorLow;
|
||||
UInt16 SuccessorHigh;
|
||||
} CPpmd_State;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
CPpmd_State *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_State_Ref;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
void *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_Void_Ref;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
Byte *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd_Byte_Ref;
|
||||
|
||||
#define PPMD_SetAllBitsIn256Bytes(p) \
|
||||
{ unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \
|
||||
p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }}
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
|
1420
lzma/C/Ppmd7.c
1420
lzma/C/Ppmd7.c
File diff suppressed because it is too large
Load diff
280
lzma/C/Ppmd7.h
280
lzma/C/Ppmd7.h
|
@ -1,140 +1,140 @@
|
|||
/* Ppmd7.h -- PPMdH compression codec
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
/* This code supports virtual RangeDecoder and includes the implementation
|
||||
of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H.
|
||||
If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */
|
||||
|
||||
#ifndef __PPMD7_H
|
||||
#define __PPMD7_H
|
||||
|
||||
#include "Ppmd.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define PPMD7_MIN_ORDER 2
|
||||
#define PPMD7_MAX_ORDER 64
|
||||
|
||||
#define PPMD7_MIN_MEM_SIZE (1 << 11)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
|
||||
|
||||
struct CPpmd7_Context_;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
struct CPpmd7_Context_ *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd7_Context_Ref;
|
||||
|
||||
typedef struct CPpmd7_Context_
|
||||
{
|
||||
UInt16 NumStats;
|
||||
UInt16 SummFreq;
|
||||
CPpmd_State_Ref Stats;
|
||||
CPpmd7_Context_Ref Suffix;
|
||||
} CPpmd7_Context;
|
||||
|
||||
#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CPpmd7_Context *MinContext, *MaxContext;
|
||||
CPpmd_State *FoundState;
|
||||
unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag;
|
||||
Int32 RunLength, InitRL; /* must be 32-bit at least */
|
||||
|
||||
UInt32 Size;
|
||||
UInt32 GlueCount;
|
||||
Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
|
||||
UInt32 AlignOffset;
|
||||
|
||||
Byte Indx2Units[PPMD_NUM_INDEXES];
|
||||
Byte Units2Indx[128];
|
||||
CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
|
||||
Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
|
||||
CPpmd_See DummySee, See[25][16];
|
||||
UInt16 BinSumm[128][64];
|
||||
} CPpmd7;
|
||||
|
||||
void Ppmd7_Construct(CPpmd7 *p);
|
||||
Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);
|
||||
void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc);
|
||||
void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);
|
||||
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
|
||||
|
||||
|
||||
/* ---------- Internal Functions ---------- */
|
||||
|
||||
extern const Byte PPMD7_kExpEscape[16];
|
||||
|
||||
#ifdef PPMD_32BIT
|
||||
#define Ppmd7_GetPtr(p, ptr) (ptr)
|
||||
#define Ppmd7_GetContext(p, ptr) (ptr)
|
||||
#define Ppmd7_GetStats(p, ctx) ((ctx)->Stats)
|
||||
#else
|
||||
#define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs)))
|
||||
#define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs)))
|
||||
#define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats)))
|
||||
#endif
|
||||
|
||||
void Ppmd7_Update1(CPpmd7 *p);
|
||||
void Ppmd7_Update1_0(CPpmd7 *p);
|
||||
void Ppmd7_Update2(CPpmd7 *p);
|
||||
void Ppmd7_UpdateBin(CPpmd7 *p);
|
||||
|
||||
#define Ppmd7_GetBinSumm(p) \
|
||||
&p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \
|
||||
p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \
|
||||
(p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \
|
||||
2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \
|
||||
((p->RunLength >> 26) & 0x20)]
|
||||
|
||||
CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);
|
||||
|
||||
|
||||
/* ---------- Decode ---------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32 (*GetThreshold)(void *p, UInt32 total);
|
||||
void (*Decode)(void *p, UInt32 start, UInt32 size);
|
||||
UInt32 (*DecodeBit)(void *p, UInt32 size0);
|
||||
} IPpmd7_RangeDec;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IPpmd7_RangeDec p;
|
||||
UInt32 Range;
|
||||
UInt32 Code;
|
||||
IByteIn *Stream;
|
||||
} CPpmd7z_RangeDec;
|
||||
|
||||
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);
|
||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);
|
||||
#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
||||
|
||||
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc);
|
||||
|
||||
|
||||
/* ---------- Encode ---------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt64 Low;
|
||||
UInt32 Range;
|
||||
Byte Cache;
|
||||
UInt64 CacheSize;
|
||||
IByteOut *Stream;
|
||||
} CPpmd7z_RangeEnc;
|
||||
|
||||
void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p);
|
||||
void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);
|
||||
|
||||
void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
/* Ppmd7.h -- PPMdH compression codec
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
/* This code supports virtual RangeDecoder and includes the implementation
|
||||
of RangeCoder from 7z, instead of RangeCoder from original PPMd var.H.
|
||||
If you need the compatibility with original PPMd var.H, you can use external RangeDecoder */
|
||||
|
||||
#ifndef __PPMD7_H
|
||||
#define __PPMD7_H
|
||||
|
||||
#include "Ppmd.h"
|
||||
|
||||
EXTERN_C_BEGIN
|
||||
|
||||
#define PPMD7_MIN_ORDER 2
|
||||
#define PPMD7_MAX_ORDER 64
|
||||
|
||||
#define PPMD7_MIN_MEM_SIZE (1 << 11)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
|
||||
|
||||
struct CPpmd7_Context_;
|
||||
|
||||
typedef
|
||||
#ifdef PPMD_32BIT
|
||||
struct CPpmd7_Context_ *
|
||||
#else
|
||||
UInt32
|
||||
#endif
|
||||
CPpmd7_Context_Ref;
|
||||
|
||||
typedef struct CPpmd7_Context_
|
||||
{
|
||||
UInt16 NumStats;
|
||||
UInt16 SummFreq;
|
||||
CPpmd_State_Ref Stats;
|
||||
CPpmd7_Context_Ref Suffix;
|
||||
} CPpmd7_Context;
|
||||
|
||||
#define Ppmd7Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CPpmd7_Context *MinContext, *MaxContext;
|
||||
CPpmd_State *FoundState;
|
||||
unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder, HiBitsFlag;
|
||||
Int32 RunLength, InitRL; /* must be 32-bit at least */
|
||||
|
||||
UInt32 Size;
|
||||
UInt32 GlueCount;
|
||||
Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart;
|
||||
UInt32 AlignOffset;
|
||||
|
||||
Byte Indx2Units[PPMD_NUM_INDEXES];
|
||||
Byte Units2Indx[128];
|
||||
CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES];
|
||||
Byte NS2Indx[256], NS2BSIndx[256], HB2Flag[256];
|
||||
CPpmd_See DummySee, See[25][16];
|
||||
UInt16 BinSumm[128][64];
|
||||
} CPpmd7;
|
||||
|
||||
void Ppmd7_Construct(CPpmd7 *p);
|
||||
Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc);
|
||||
void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc);
|
||||
void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder);
|
||||
#define Ppmd7_WasAllocated(p) ((p)->Base != NULL)
|
||||
|
||||
|
||||
/* ---------- Internal Functions ---------- */
|
||||
|
||||
extern const Byte PPMD7_kExpEscape[16];
|
||||
|
||||
#ifdef PPMD_32BIT
|
||||
#define Ppmd7_GetPtr(p, ptr) (ptr)
|
||||
#define Ppmd7_GetContext(p, ptr) (ptr)
|
||||
#define Ppmd7_GetStats(p, ctx) ((ctx)->Stats)
|
||||
#else
|
||||
#define Ppmd7_GetPtr(p, offs) ((void *)((p)->Base + (offs)))
|
||||
#define Ppmd7_GetContext(p, offs) ((CPpmd7_Context *)Ppmd7_GetPtr((p), (offs)))
|
||||
#define Ppmd7_GetStats(p, ctx) ((CPpmd_State *)Ppmd7_GetPtr((p), ((ctx)->Stats)))
|
||||
#endif
|
||||
|
||||
void Ppmd7_Update1(CPpmd7 *p);
|
||||
void Ppmd7_Update1_0(CPpmd7 *p);
|
||||
void Ppmd7_Update2(CPpmd7 *p);
|
||||
void Ppmd7_UpdateBin(CPpmd7 *p);
|
||||
|
||||
#define Ppmd7_GetBinSumm(p) \
|
||||
&p->BinSumm[Ppmd7Context_OneState(p->MinContext)->Freq - 1][p->PrevSuccess + \
|
||||
p->NS2BSIndx[Ppmd7_GetContext(p, p->MinContext->Suffix)->NumStats - 1] + \
|
||||
(p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol]) + \
|
||||
2 * p->HB2Flag[Ppmd7Context_OneState(p->MinContext)->Symbol] + \
|
||||
((p->RunLength >> 26) & 0x20)]
|
||||
|
||||
CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *scale);
|
||||
|
||||
|
||||
/* ---------- Decode ---------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt32 (*GetThreshold)(void *p, UInt32 total);
|
||||
void (*Decode)(void *p, UInt32 start, UInt32 size);
|
||||
UInt32 (*DecodeBit)(void *p, UInt32 size0);
|
||||
} IPpmd7_RangeDec;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IPpmd7_RangeDec p;
|
||||
UInt32 Range;
|
||||
UInt32 Code;
|
||||
IByteIn *Stream;
|
||||
} CPpmd7z_RangeDec;
|
||||
|
||||
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p);
|
||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p);
|
||||
#define Ppmd7z_RangeDec_IsFinishedOK(p) ((p)->Code == 0)
|
||||
|
||||
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc);
|
||||
|
||||
|
||||
/* ---------- Encode ---------- */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UInt64 Low;
|
||||
UInt32 Range;
|
||||
Byte Cache;
|
||||
UInt64 CacheSize;
|
||||
IByteOut *Stream;
|
||||
} CPpmd7z_RangeEnc;
|
||||
|
||||
void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p);
|
||||
void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p);
|
||||
|
||||
void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol);
|
||||
|
||||
EXTERN_C_END
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,189 +1,189 @@
|
|||
/* Ppmd7Dec.c -- PPMdH Decoder
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Ppmd7.h"
|
||||
|
||||
#define kTopValue (1 << 24)
|
||||
|
||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
unsigned i;
|
||||
p->Code = 0;
|
||||
p->Range = 0xFFFFFFFF;
|
||||
if (p->Stream->Read((void *)p->Stream) != 0)
|
||||
return False;
|
||||
for (i = 0; i < 4; i++)
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
return (p->Code < 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
static UInt32 Range_GetThreshold(void *pp, UInt32 total)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
return (p->Code) / (p->Range /= total);
|
||||
}
|
||||
|
||||
static void Range_Normalize(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
if (p->Range < kTopValue)
|
||||
{
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
p->Range <<= 8;
|
||||
if (p->Range < kTopValue)
|
||||
{
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
p->Range <<= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Range_Decode(void *pp, UInt32 start, UInt32 size)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
p->Code -= start * p->Range;
|
||||
p->Range *= size;
|
||||
Range_Normalize(p);
|
||||
}
|
||||
|
||||
static UInt32 Range_DecodeBit(void *pp, UInt32 size0)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
UInt32 newBound = (p->Range >> 14) * size0;
|
||||
UInt32 symbol;
|
||||
if (p->Code < newBound)
|
||||
{
|
||||
symbol = 0;
|
||||
p->Range = newBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
symbol = 1;
|
||||
p->Code -= newBound;
|
||||
p->Range -= newBound;
|
||||
}
|
||||
Range_Normalize(p);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
p->p.GetThreshold = Range_GetThreshold;
|
||||
p->p.Decode = Range_Decode;
|
||||
p->p.DecodeBit = Range_DecodeBit;
|
||||
}
|
||||
|
||||
|
||||
#define MASK(sym) ((signed char *)charMask)[sym]
|
||||
|
||||
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)
|
||||
{
|
||||
size_t charMask[256 / sizeof(size_t)];
|
||||
if (p->MinContext->NumStats != 1)
|
||||
{
|
||||
CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext);
|
||||
unsigned i;
|
||||
UInt32 count, hiCnt;
|
||||
if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq))
|
||||
{
|
||||
Byte symbol;
|
||||
rc->Decode(rc, 0, s->Freq);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update1_0(p);
|
||||
return symbol;
|
||||
}
|
||||
p->PrevSuccess = 0;
|
||||
i = p->MinContext->NumStats - 1;
|
||||
do
|
||||
{
|
||||
if ((hiCnt += (++s)->Freq) > count)
|
||||
{
|
||||
Byte symbol;
|
||||
rc->Decode(rc, hiCnt - s->Freq, s->Freq);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update1(p);
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
while (--i);
|
||||
if (count >= p->MinContext->SummFreq)
|
||||
return -2;
|
||||
p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];
|
||||
rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt);
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(s->Symbol) = 0;
|
||||
i = p->MinContext->NumStats - 1;
|
||||
do { MASK((--s)->Symbol) = 0; } while (--i);
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt16 *prob = Ppmd7_GetBinSumm(p);
|
||||
if (rc->DecodeBit(rc, *prob) == 0)
|
||||
{
|
||||
Byte symbol;
|
||||
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
|
||||
symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol;
|
||||
Ppmd7_UpdateBin(p);
|
||||
return symbol;
|
||||
}
|
||||
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
|
||||
p->InitEsc = PPMD7_kExpEscape[*prob >> 10];
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0;
|
||||
p->PrevSuccess = 0;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
CPpmd_State *ps[256], *s;
|
||||
UInt32 freqSum, count, hiCnt;
|
||||
CPpmd_See *see;
|
||||
unsigned i, num, numMasked = p->MinContext->NumStats;
|
||||
do
|
||||
{
|
||||
p->OrderFall++;
|
||||
if (!p->MinContext->Suffix)
|
||||
return -1;
|
||||
p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);
|
||||
}
|
||||
while (p->MinContext->NumStats == numMasked);
|
||||
hiCnt = 0;
|
||||
s = Ppmd7_GetStats(p, p->MinContext);
|
||||
i = 0;
|
||||
num = p->MinContext->NumStats - numMasked;
|
||||
do
|
||||
{
|
||||
int k = (int)(MASK(s->Symbol));
|
||||
hiCnt += (s->Freq & k);
|
||||
ps[i] = s++;
|
||||
i -= k;
|
||||
}
|
||||
while (i != num);
|
||||
|
||||
see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);
|
||||
freqSum += hiCnt;
|
||||
count = rc->GetThreshold(rc, freqSum);
|
||||
|
||||
if (count < hiCnt)
|
||||
{
|
||||
Byte symbol;
|
||||
CPpmd_State **pps = ps;
|
||||
for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);
|
||||
s = *pps;
|
||||
rc->Decode(rc, hiCnt - s->Freq, s->Freq);
|
||||
Ppmd_See_Update(see);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update2(p);
|
||||
return symbol;
|
||||
}
|
||||
if (count >= freqSum)
|
||||
return -2;
|
||||
rc->Decode(rc, hiCnt, freqSum - hiCnt);
|
||||
see->Summ = (UInt16)(see->Summ + freqSum);
|
||||
do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);
|
||||
}
|
||||
}
|
||||
/* Ppmd7Dec.c -- PPMdH Decoder
|
||||
2010-03-12 : Igor Pavlov : Public domain
|
||||
This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */
|
||||
|
||||
#include "Precomp.h"
|
||||
|
||||
#include "Ppmd7.h"
|
||||
|
||||
#define kTopValue (1 << 24)
|
||||
|
||||
Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
unsigned i;
|
||||
p->Code = 0;
|
||||
p->Range = 0xFFFFFFFF;
|
||||
if (p->Stream->Read((void *)p->Stream) != 0)
|
||||
return False;
|
||||
for (i = 0; i < 4; i++)
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
return (p->Code < 0xFFFFFFFF);
|
||||
}
|
||||
|
||||
static UInt32 Range_GetThreshold(void *pp, UInt32 total)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
return (p->Code) / (p->Range /= total);
|
||||
}
|
||||
|
||||
static void Range_Normalize(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
if (p->Range < kTopValue)
|
||||
{
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
p->Range <<= 8;
|
||||
if (p->Range < kTopValue)
|
||||
{
|
||||
p->Code = (p->Code << 8) | p->Stream->Read((void *)p->Stream);
|
||||
p->Range <<= 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void Range_Decode(void *pp, UInt32 start, UInt32 size)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
p->Code -= start * p->Range;
|
||||
p->Range *= size;
|
||||
Range_Normalize(p);
|
||||
}
|
||||
|
||||
static UInt32 Range_DecodeBit(void *pp, UInt32 size0)
|
||||
{
|
||||
CPpmd7z_RangeDec *p = (CPpmd7z_RangeDec *)pp;
|
||||
UInt32 newBound = (p->Range >> 14) * size0;
|
||||
UInt32 symbol;
|
||||
if (p->Code < newBound)
|
||||
{
|
||||
symbol = 0;
|
||||
p->Range = newBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
symbol = 1;
|
||||
p->Code -= newBound;
|
||||
p->Range -= newBound;
|
||||
}
|
||||
Range_Normalize(p);
|
||||
return symbol;
|
||||
}
|
||||
|
||||
void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p)
|
||||
{
|
||||
p->p.GetThreshold = Range_GetThreshold;
|
||||
p->p.Decode = Range_Decode;
|
||||
p->p.DecodeBit = Range_DecodeBit;
|
||||
}
|
||||
|
||||
|
||||
#define MASK(sym) ((signed char *)charMask)[sym]
|
||||
|
||||
int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc)
|
||||
{
|
||||
size_t charMask[256 / sizeof(size_t)];
|
||||
if (p->MinContext->NumStats != 1)
|
||||
{
|
||||
CPpmd_State *s = Ppmd7_GetStats(p, p->MinContext);
|
||||
unsigned i;
|
||||
UInt32 count, hiCnt;
|
||||
if ((count = rc->GetThreshold(rc, p->MinContext->SummFreq)) < (hiCnt = s->Freq))
|
||||
{
|
||||
Byte symbol;
|
||||
rc->Decode(rc, 0, s->Freq);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update1_0(p);
|
||||
return symbol;
|
||||
}
|
||||
p->PrevSuccess = 0;
|
||||
i = p->MinContext->NumStats - 1;
|
||||
do
|
||||
{
|
||||
if ((hiCnt += (++s)->Freq) > count)
|
||||
{
|
||||
Byte symbol;
|
||||
rc->Decode(rc, hiCnt - s->Freq, s->Freq);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update1(p);
|
||||
return symbol;
|
||||
}
|
||||
}
|
||||
while (--i);
|
||||
if (count >= p->MinContext->SummFreq)
|
||||
return -2;
|
||||
p->HiBitsFlag = p->HB2Flag[p->FoundState->Symbol];
|
||||
rc->Decode(rc, hiCnt, p->MinContext->SummFreq - hiCnt);
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(s->Symbol) = 0;
|
||||
i = p->MinContext->NumStats - 1;
|
||||
do { MASK((--s)->Symbol) = 0; } while (--i);
|
||||
}
|
||||
else
|
||||
{
|
||||
UInt16 *prob = Ppmd7_GetBinSumm(p);
|
||||
if (rc->DecodeBit(rc, *prob) == 0)
|
||||
{
|
||||
Byte symbol;
|
||||
*prob = (UInt16)PPMD_UPDATE_PROB_0(*prob);
|
||||
symbol = (p->FoundState = Ppmd7Context_OneState(p->MinContext))->Symbol;
|
||||
Ppmd7_UpdateBin(p);
|
||||
return symbol;
|
||||
}
|
||||
*prob = (UInt16)PPMD_UPDATE_PROB_1(*prob);
|
||||
p->InitEsc = PPMD7_kExpEscape[*prob >> 10];
|
||||
PPMD_SetAllBitsIn256Bytes(charMask);
|
||||
MASK(Ppmd7Context_OneState(p->MinContext)->Symbol) = 0;
|
||||
p->PrevSuccess = 0;
|
||||
}
|
||||
for (;;)
|
||||
{
|
||||
CPpmd_State *ps[256], *s;
|
||||
UInt32 freqSum, count, hiCnt;
|
||||
CPpmd_See *see;
|
||||
unsigned i, num, numMasked = p->MinContext->NumStats;
|
||||
do
|
||||
{
|
||||
p->OrderFall++;
|
||||
if (!p->MinContext->Suffix)
|
||||
return -1;
|
||||
p->MinContext = Ppmd7_GetContext(p, p->MinContext->Suffix);
|
||||
}
|
||||
while (p->MinContext->NumStats == numMasked);
|
||||
hiCnt = 0;
|
||||
s = Ppmd7_GetStats(p, p->MinContext);
|
||||
i = 0;
|
||||
num = p->MinContext->NumStats - numMasked;
|
||||
do
|
||||
{
|
||||
int k = (int)(MASK(s->Symbol));
|
||||
hiCnt += (s->Freq & k);
|
||||
ps[i] = s++;
|
||||
i -= k;
|
||||
}
|
||||
while (i != num);
|
||||
|
||||
see = Ppmd7_MakeEscFreq(p, numMasked, &freqSum);
|
||||
freqSum += hiCnt;
|
||||
count = rc->GetThreshold(rc, freqSum);
|
||||
|
||||
if (count < hiCnt)
|
||||
{
|
||||
Byte symbol;
|
||||
CPpmd_State **pps = ps;
|
||||
for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++);
|
||||
s = *pps;
|
||||
rc->Decode(rc, hiCnt - s->Freq, s->Freq);
|
||||
Ppmd_See_Update(see);
|
||||
p->FoundState = s;
|
||||
symbol = s->Symbol;
|
||||
Ppmd7_Update2(p);
|
||||
return symbol;
|
||||
}
|
||||
if (count >= freqSum)
|
||||
return -2;
|
||||
rc->Decode(rc, hiCnt, freqSum - hiCnt);
|
||||
see->Summ = (UInt16)(see->Summ + freqSum);
|
||||
do { MASK(ps[--i]->Symbol) = 0; } while (i != 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* Precomp.h -- StdAfx
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
|
||||
#include "Compiler.h"
|
||||
/* #include "7zTypes.h" */
|
||||
|
||||
#endif
|
||||
/* Precomp.h -- StdAfx
|
||||
2013-11-12 : Igor Pavlov : Public domain */
|
||||
|
||||
#ifndef __7Z_PRECOMP_H
|
||||
#define __7Z_PRECOMP_H
|
||||
|
||||
#include "Compiler.h"
|
||||
/* #include "7zTypes.h" */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -854,7 +854,7 @@ public:
|
|||
bool intersects(AActor *other) const
|
||||
{
|
||||
fixed_t blockdist = radius + other->radius;
|
||||
return ( abs(X() - other->Y()) < blockdist && abs(Y() - other->Y()) < blockdist);
|
||||
return ( abs(X() - other->X()) < blockdist && abs(Y() - other->Y()) < blockdist);
|
||||
}
|
||||
|
||||
// 'absolute' is reserved for a linked portal implementation which needs
|
||||
|
|
|
@ -353,6 +353,7 @@ static void MarkRoot()
|
|||
SectorMarker->SecNum = 0;
|
||||
}
|
||||
Mark(SectorMarker);
|
||||
Mark(interpolator.Head);
|
||||
// Mark action functions
|
||||
if (!FinalGC)
|
||||
{
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#include "decallib.h"
|
||||
#include "p_terrain.h"
|
||||
#include "version.h"
|
||||
#include "p_effect.h"
|
||||
|
||||
#include "g_shared/a_pickups.h"
|
||||
|
||||
|
@ -4463,6 +4464,7 @@ enum EACSFunctions
|
|||
ACSF_GetMaxInventory,
|
||||
ACSF_SetSectorDamage,
|
||||
ACSF_SetSectorTerrain,
|
||||
ACSF_SpawnParticle,
|
||||
|
||||
/* Zandronum's - these must be skipped when we reach 99!
|
||||
-100:ResetMap(0),
|
||||
|
@ -5980,7 +5982,35 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case ACSF_SpawnParticle:
|
||||
{
|
||||
fixed_t x = args[0];
|
||||
fixed_t y = args[1];
|
||||
fixed_t z = args[2];
|
||||
fixed_t xvel = args[3];
|
||||
fixed_t yvel = args[4];
|
||||
fixed_t zvel = args[5];
|
||||
PalEntry color = args[6];
|
||||
int lifetime = args[7];
|
||||
bool fullbright = argCount > 8 ? !!args[8] : false;
|
||||
int startalpha = argCount > 9 ? args[9] : 0xFF; // Byte trans
|
||||
int size = argCount > 10 ? args[10] : 1;
|
||||
int fadestep = argCount > 11 ? args[11] : -1;
|
||||
fixed_t accelx = argCount > 12 ? args[12] : 0;
|
||||
fixed_t accely = argCount > 13 ? args[13] : 0;
|
||||
fixed_t accelz = argCount > 14 ? args[14] : 0;
|
||||
|
||||
startalpha = clamp<int>(startalpha, 0, 0xFF); // Clamp to byte
|
||||
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
|
||||
fadestep = clamp<int>(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic)
|
||||
size = clamp<int>(size, 0, 0xFF); // Clamp to byte
|
||||
|
||||
if (lifetime != 0)
|
||||
P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1345,22 +1345,30 @@ static void HandleReply(player_t *player, bool isconsole, int nodenum, int reply
|
|||
if (reply->NextNode != 0)
|
||||
{
|
||||
int rootnode = npc->ConversationRoot;
|
||||
unsigned next = (unsigned)(rootnode + (reply->NextNode < 0 ? -1 : 1) * reply->NextNode - 1);
|
||||
const bool isNegative = reply->NextNode < 0;
|
||||
const unsigned next = (unsigned)(rootnode + (isNegative ? -1 : 1) * reply->NextNode - 1);
|
||||
|
||||
if (next < StrifeDialogues.Size())
|
||||
{
|
||||
npc->Conversation = StrifeDialogues[next];
|
||||
|
||||
if (gameaction != ga_slideshow)
|
||||
if (isNegative)
|
||||
{
|
||||
P_StartConversation (npc, player->mo, player->ConversationFaceTalker, false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StopSound (npc, CHAN_VOICE);
|
||||
if (gameaction != ga_slideshow)
|
||||
{
|
||||
P_StartConversation (npc, player->mo, player->ConversationFaceTalker, false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StopSound (npc, CHAN_VOICE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf ("Next node %u is invalid, no such dialog page\n", next);
|
||||
}
|
||||
}
|
||||
|
||||
npc->angle = player->ConversationNPCAngle;
|
||||
|
|
|
@ -284,6 +284,31 @@ void P_ThinkParticles ()
|
|||
}
|
||||
}
|
||||
|
||||
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz)
|
||||
{
|
||||
particle_t *particle = NewParticle();
|
||||
|
||||
if (particle)
|
||||
{
|
||||
particle->x = x;
|
||||
particle->y = y;
|
||||
particle->z = z;
|
||||
particle->velx = velx;
|
||||
particle->vely = vely;
|
||||
particle->velz = velz;
|
||||
particle->color = ParticleColor(color);
|
||||
particle->trans = startalpha;
|
||||
if (fadestep < 0) fadestep = FADEFROMTTL(lifetime);
|
||||
particle->fade = fadestep;
|
||||
particle->ttl = lifetime;
|
||||
particle->accx = accelx;
|
||||
particle->accy = accely;
|
||||
particle->accz = accelz;
|
||||
particle->bright = fullbright;
|
||||
particle->size = size;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// P_RunEffects
|
||||
//
|
||||
|
|
|
@ -83,6 +83,7 @@ particle_t *JitterParticle (int ttl);
|
|||
particle_t *JitterParticle (int ttl, double drift);
|
||||
|
||||
void P_ThinkParticles (void);
|
||||
void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t velx, fixed_t vely, fixed_t velz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, BYTE size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz);
|
||||
void P_InitEffects (void);
|
||||
void P_RunEffects (void);
|
||||
|
||||
|
|
|
@ -5270,6 +5270,7 @@ int P_PushDown(AActor *thing, FChangePosition *cpos)
|
|||
void PIT_FloorDrop(AActor *thing, FChangePosition *cpos)
|
||||
{
|
||||
fixed_t oldfloorz = thing->floorz;
|
||||
fixed_t oldz = thing->Z();
|
||||
|
||||
P_AdjustFloorCeil(thing, cpos);
|
||||
|
||||
|
@ -5299,6 +5300,10 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos)
|
|||
P_CheckFakeFloorTriggers(thing, oldz);
|
||||
}
|
||||
}
|
||||
if (thing->player && thing->player->mo == thing)
|
||||
{
|
||||
thing->player->viewz += thing->Z() - oldz;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -5350,6 +5355,10 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos)
|
|||
thing->SetZ(oldz);
|
||||
break;
|
||||
}
|
||||
if (thing->player && thing->player->mo == thing)
|
||||
{
|
||||
thing->player->viewz += thing->Z() - oldz;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -5361,6 +5370,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos)
|
|||
void PIT_CeilingLower(AActor *thing, FChangePosition *cpos)
|
||||
{
|
||||
bool onfloor;
|
||||
fixed_t oldz = thing->Z();
|
||||
|
||||
onfloor = thing->Z() <= thing->floorz;
|
||||
P_AdjustFloorCeil(thing, cpos);
|
||||
|
@ -5397,6 +5407,10 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (thing->player && thing->player->mo == thing)
|
||||
{
|
||||
thing->player->viewz += thing->Z() - oldz;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
@ -5408,6 +5422,7 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos)
|
|||
void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos)
|
||||
{
|
||||
bool isgood = P_AdjustFloorCeil(thing, cpos);
|
||||
fixed_t oldz = thing->Z();
|
||||
|
||||
if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things
|
||||
|
||||
|
@ -5434,6 +5449,10 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos)
|
|||
thing->SetZ( MIN(thing->ceilingz - thing->height, onmobj->Top()));
|
||||
}
|
||||
}
|
||||
if (thing->player && thing->player->mo == thing)
|
||||
{
|
||||
thing->player->viewz += thing->Z() - oldz;
|
||||
}
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
|
|
|
@ -878,6 +878,7 @@ FArchive &operator<< (FArchive &arc, secspecial_t &p)
|
|||
int special;
|
||||
arc << special;
|
||||
sector_t sec;
|
||||
memset(&sec, 0, sizeof(sec));
|
||||
P_InitSectorSpecial(&sec, special, true);
|
||||
sec.GetSpecial(&p);
|
||||
}
|
||||
|
|
|
@ -3350,6 +3350,7 @@ extern polyblock_t **PolyBlockMap;
|
|||
|
||||
void P_FreeLevelData ()
|
||||
{
|
||||
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
||||
Renderer->CleanLevelData();
|
||||
FPolyObj::ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
|
||||
SN_StopAllSequences ();
|
||||
|
@ -3581,7 +3582,6 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
|
||||
// Free all level data from the previous map
|
||||
P_FreeLevelData ();
|
||||
interpolator.ClearInterpolations(); // [RH] Nothing to interpolate on a fresh level.
|
||||
|
||||
MapData *map = P_OpenMapData(lumpname, true);
|
||||
if (map == NULL)
|
||||
|
|
|
@ -1,134 +1,134 @@
|
|||
/*
|
||||
** pathexpander.cpp
|
||||
** Utility class for expanding a given path with a range of directories
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2015 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "pathexpander.h"
|
||||
#include "cmdlib.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
static FString BuildPath(const FString &base, const char *name)
|
||||
{
|
||||
FString current;
|
||||
if (base.IsNotEmpty())
|
||||
{
|
||||
current = base;
|
||||
if (current[current.Len() - 1] != '/') current += '/';
|
||||
}
|
||||
current += name;
|
||||
return current;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// This is meant to find and open files for reading.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
FileReader *PathExpander::openFileReader(const char *name, int *plumpnum)
|
||||
{
|
||||
FileReader *fp;
|
||||
FString current_filename;
|
||||
|
||||
if (!name || !(*name))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* First try the given name */
|
||||
current_filename = name;
|
||||
FixPathSeperator(current_filename);
|
||||
|
||||
|
||||
if (openmode != OM_FILE)
|
||||
{
|
||||
int lumpnum = Wads.CheckNumForFullName(current_filename);
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
fp = Wads.ReopenLumpNum(lumpnum);
|
||||
if (plumpnum) *plumpnum = lumpnum;
|
||||
return fp;
|
||||
}
|
||||
if (openmode == OM_LUMP) // search the path list when not loading the main config
|
||||
{
|
||||
for (unsigned int plp = PathList.Size(); plp-- != 0; )
|
||||
{ /* Try along the path then */
|
||||
current_filename = BuildPath(PathList[plp], name);
|
||||
lumpnum = Wads.CheckNumForFullName(current_filename);
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
fp = Wads.ReopenLumpNum(lumpnum);
|
||||
if (plumpnum) *plumpnum = lumpnum;
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (plumpnum) *plumpnum = -1;
|
||||
|
||||
|
||||
fp = new FileReader;
|
||||
if (fp->Open(current_filename)) return fp;
|
||||
|
||||
if (name[0] != '/')
|
||||
{
|
||||
for (unsigned int plp = PathList.Size(); plp-- != 0; )
|
||||
{ /* Try along the path then */
|
||||
current_filename = BuildPath(PathList[plp], name);
|
||||
if (fp->Open(current_filename)) return fp;
|
||||
}
|
||||
}
|
||||
delete fp;
|
||||
|
||||
/* Nothing could be opened. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This adds a directory to the path list */
|
||||
void PathExpander::addToPathlist(const char *s)
|
||||
{
|
||||
FString copy = s;
|
||||
FixPathSeperator(copy);
|
||||
PathList.Push(copy);
|
||||
}
|
||||
|
||||
void PathExpander::clearPathlist()
|
||||
{
|
||||
PathList.Clear();
|
||||
}
|
||||
/*
|
||||
** pathexpander.cpp
|
||||
** Utility class for expanding a given path with a range of directories
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2015 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include "pathexpander.h"
|
||||
#include "cmdlib.h"
|
||||
#include "w_wad.h"
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
static FString BuildPath(const FString &base, const char *name)
|
||||
{
|
||||
FString current;
|
||||
if (base.IsNotEmpty())
|
||||
{
|
||||
current = base;
|
||||
if (current[current.Len() - 1] != '/') current += '/';
|
||||
}
|
||||
current += name;
|
||||
return current;
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
//
|
||||
// This is meant to find and open files for reading.
|
||||
//
|
||||
//============================================================================
|
||||
|
||||
FileReader *PathExpander::openFileReader(const char *name, int *plumpnum)
|
||||
{
|
||||
FileReader *fp;
|
||||
FString current_filename;
|
||||
|
||||
if (!name || !(*name))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* First try the given name */
|
||||
current_filename = name;
|
||||
FixPathSeperator(current_filename);
|
||||
|
||||
|
||||
if (openmode != OM_FILE)
|
||||
{
|
||||
int lumpnum = Wads.CheckNumForFullName(current_filename);
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
fp = Wads.ReopenLumpNum(lumpnum);
|
||||
if (plumpnum) *plumpnum = lumpnum;
|
||||
return fp;
|
||||
}
|
||||
if (openmode == OM_LUMP) // search the path list when not loading the main config
|
||||
{
|
||||
for (unsigned int plp = PathList.Size(); plp-- != 0; )
|
||||
{ /* Try along the path then */
|
||||
current_filename = BuildPath(PathList[plp], name);
|
||||
lumpnum = Wads.CheckNumForFullName(current_filename);
|
||||
if (lumpnum >= 0)
|
||||
{
|
||||
fp = Wads.ReopenLumpNum(lumpnum);
|
||||
if (plumpnum) *plumpnum = lumpnum;
|
||||
return fp;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (plumpnum) *plumpnum = -1;
|
||||
|
||||
|
||||
fp = new FileReader;
|
||||
if (fp->Open(current_filename)) return fp;
|
||||
|
||||
if (name[0] != '/')
|
||||
{
|
||||
for (unsigned int plp = PathList.Size(); plp-- != 0; )
|
||||
{ /* Try along the path then */
|
||||
current_filename = BuildPath(PathList[plp], name);
|
||||
if (fp->Open(current_filename)) return fp;
|
||||
}
|
||||
}
|
||||
delete fp;
|
||||
|
||||
/* Nothing could be opened. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This adds a directory to the path list */
|
||||
void PathExpander::addToPathlist(const char *s)
|
||||
{
|
||||
FString copy = s;
|
||||
FixPathSeperator(copy);
|
||||
PathList.Push(copy);
|
||||
}
|
||||
|
||||
void PathExpander::clearPathlist()
|
||||
{
|
||||
PathList.Clear();
|
||||
}
|
||||
|
|
|
@ -1,31 +1,31 @@
|
|||
#ifndef __PATHEXPANDER_H
|
||||
#define __PATHEXPANDER_H
|
||||
|
||||
#include "tarray.h"
|
||||
#include "zstring.h"
|
||||
#include "files.h"
|
||||
|
||||
class PathExpander
|
||||
{
|
||||
TArray<FString> PathList;
|
||||
|
||||
public:
|
||||
int openmode;
|
||||
|
||||
enum
|
||||
{
|
||||
OM_FILEORLUMP = 0,
|
||||
OM_LUMP,
|
||||
OM_FILE
|
||||
};
|
||||
|
||||
PathExpander(int om = OM_FILEORLUMP)
|
||||
{
|
||||
openmode = om;
|
||||
}
|
||||
void addToPathlist(const char *s);
|
||||
void clearPathlist();
|
||||
FileReader *openFileReader(const char *name, int *plumpnum);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef __PATHEXPANDER_H
|
||||
#define __PATHEXPANDER_H
|
||||
|
||||
#include "tarray.h"
|
||||
#include "zstring.h"
|
||||
#include "files.h"
|
||||
|
||||
class PathExpander
|
||||
{
|
||||
TArray<FString> PathList;
|
||||
|
||||
public:
|
||||
int openmode;
|
||||
|
||||
enum
|
||||
{
|
||||
OM_FILEORLUMP = 0,
|
||||
OM_LUMP,
|
||||
OM_FILE
|
||||
};
|
||||
|
||||
PathExpander(int om = OM_FILEORLUMP)
|
||||
{
|
||||
openmode = om;
|
||||
}
|
||||
void addToPathlist(const char *s);
|
||||
void clearPathlist();
|
||||
FileReader *openFileReader(const char *name, int *plumpnum);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -157,7 +157,10 @@ public:
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
IMPLEMENT_ABSTRACT_CLASS(DInterpolation)
|
||||
IMPLEMENT_ABSTRACT_POINTY_CLASS(DInterpolation)
|
||||
DECLARE_POINTER(Next)
|
||||
DECLARE_POINTER(Prev)
|
||||
END_POINTERS
|
||||
IMPLEMENT_CLASS(DSectorPlaneInterpolation)
|
||||
IMPLEMENT_CLASS(DSectorScrollInterpolation)
|
||||
IMPLEMENT_CLASS(DWallScrollInterpolation)
|
||||
|
@ -213,9 +216,9 @@ void FInterpolator::UpdateInterpolations()
|
|||
void FInterpolator::AddInterpolation(DInterpolation *interp)
|
||||
{
|
||||
interp->Next = Head;
|
||||
if (Head != NULL) Head->Prev = &interp->Next;
|
||||
if (Head != NULL) Head->Prev = interp;
|
||||
interp->Prev = NULL;
|
||||
Head = interp;
|
||||
interp->Prev = &Head;
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -227,14 +230,19 @@ void FInterpolator::AddInterpolation(DInterpolation *interp)
|
|||
|
||||
void FInterpolator::RemoveInterpolation(DInterpolation *interp)
|
||||
{
|
||||
if (interp->Prev != NULL)
|
||||
if (Head == interp)
|
||||
{
|
||||
*interp->Prev = interp->Next;
|
||||
if (interp->Next != NULL) interp->Next->Prev = interp->Prev;
|
||||
interp->Next = NULL;
|
||||
interp->Prev = NULL;
|
||||
count--;
|
||||
Head = interp->Next;
|
||||
if (Head != NULL) Head->Prev = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (interp->Prev != NULL) interp->Prev->Next = interp->Next;
|
||||
if (interp->Next != NULL) interp->Next->Prev = interp->Prev;
|
||||
}
|
||||
interp->Next = NULL;
|
||||
interp->Prev = NULL;
|
||||
count--;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -285,13 +293,15 @@ void FInterpolator::RestoreInterpolations()
|
|||
|
||||
void FInterpolator::ClearInterpolations()
|
||||
{
|
||||
for (DInterpolation *probe = Head; probe != NULL; )
|
||||
DInterpolation *probe = Head;
|
||||
Head = NULL;
|
||||
while (probe != NULL)
|
||||
{
|
||||
DInterpolation *next = probe->Next;
|
||||
probe->Next = probe->Prev = NULL;
|
||||
probe->Destroy();
|
||||
probe = next;
|
||||
}
|
||||
Head = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -334,10 +344,6 @@ int DInterpolation::AddRef()
|
|||
int DInterpolation::DelRef()
|
||||
{
|
||||
if (refcount > 0) --refcount;
|
||||
if (refcount <= 0 && !(ObjectFlags & OF_EuthanizeMe))
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
return refcount;
|
||||
}
|
||||
|
||||
|
@ -486,9 +492,16 @@ void DSectorPlaneInterpolation::Interpolate(fixed_t smoothratio)
|
|||
bakheight = *pheight;
|
||||
baktexz = sector->GetPlaneTexZ(pos);
|
||||
|
||||
*pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio);
|
||||
sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio));
|
||||
P_RecalculateAttached3DFloors(sector);
|
||||
if (refcount == 0 && oldheight == bakheight)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
*pheight = oldheight + FixedMul(bakheight - oldheight, smoothratio);
|
||||
sector->SetPlaneTexZ(pos, oldtexz + FixedMul(baktexz - oldtexz, smoothratio));
|
||||
P_RecalculateAttached3DFloors(sector);
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -612,8 +625,15 @@ void DSectorScrollInterpolation::Interpolate(fixed_t smoothratio)
|
|||
bakx = sector->GetXOffset(ceiling);
|
||||
baky = sector->GetYOffset(ceiling, false);
|
||||
|
||||
sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio));
|
||||
sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio));
|
||||
if (refcount == 0 && oldx == bakx && oldy == baky)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
sector->SetXOffset(ceiling, oldx + FixedMul(bakx - oldx, smoothratio));
|
||||
sector->SetYOffset(ceiling, oldy + FixedMul(baky - oldy, smoothratio));
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -696,8 +716,15 @@ void DWallScrollInterpolation::Interpolate(fixed_t smoothratio)
|
|||
bakx = side->GetTextureXOffset(part);
|
||||
baky = side->GetTextureYOffset(part);
|
||||
|
||||
side->SetTextureXOffset(part, oldx + FixedMul(bakx - oldx, smoothratio));
|
||||
side->SetTextureYOffset(part, oldy + FixedMul(baky - oldy, smoothratio));
|
||||
if (refcount == 0 && oldx == bakx && oldy == baky)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
side->SetTextureXOffset(part, oldx + FixedMul(bakx - oldx, smoothratio));
|
||||
side->SetTextureYOffset(part, oldy + FixedMul(baky - oldy, smoothratio));
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -788,6 +815,7 @@ void DPolyobjInterpolation::Restore()
|
|||
|
||||
void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
|
||||
{
|
||||
bool changed = false;
|
||||
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
|
||||
{
|
||||
fixed_t *px = &poly->Vertices[i]->x;
|
||||
|
@ -796,15 +824,26 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
|
|||
bakverts[i*2 ] = *px;
|
||||
bakverts[i*2+1] = *py;
|
||||
|
||||
*px = oldverts[i*2 ] + FixedMul(bakverts[i*2 ] - oldverts[i*2 ], smoothratio);
|
||||
*py = oldverts[i*2+1] + FixedMul(bakverts[i*2+1] - oldverts[i*2+1], smoothratio);
|
||||
if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1])
|
||||
{
|
||||
changed = true;
|
||||
*px = oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio);
|
||||
*py = oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio);
|
||||
}
|
||||
}
|
||||
bakcx = poly->CenterSpot.x;
|
||||
bakcy = poly->CenterSpot.y;
|
||||
poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio);
|
||||
poly->CenterSpot.y = bakcy + FixedMul(bakcy - oldcy, smoothratio);
|
||||
if (refcount == 0 && !changed)
|
||||
{
|
||||
Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
bakcx = poly->CenterSpot.x;
|
||||
bakcy = poly->CenterSpot.y;
|
||||
poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio);
|
||||
poly->CenterSpot.y = bakcy + FixedMul(bakcy - oldcy, smoothratio);
|
||||
|
||||
poly->ClearSubsectorLinks();
|
||||
poly->ClearSubsectorLinks();
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -13,12 +13,14 @@ class DInterpolation : public DObject
|
|||
friend struct FInterpolator;
|
||||
|
||||
DECLARE_ABSTRACT_CLASS(DInterpolation, DObject)
|
||||
HAS_OBJECT_POINTERS
|
||||
|
||||
DInterpolation *Next;
|
||||
DInterpolation **Prev;
|
||||
int refcount;
|
||||
TObjPtr<DInterpolation> Next;
|
||||
TObjPtr<DInterpolation> Prev;
|
||||
|
||||
protected:
|
||||
int refcount;
|
||||
|
||||
DInterpolation();
|
||||
|
||||
public:
|
||||
|
@ -40,7 +42,7 @@ public:
|
|||
|
||||
struct FInterpolator
|
||||
{
|
||||
DInterpolation *Head;
|
||||
TObjPtr<DInterpolation> Head;
|
||||
bool didInterp;
|
||||
int count;
|
||||
|
||||
|
|
|
@ -600,9 +600,9 @@ public:
|
|||
protected:
|
||||
void Heapify();
|
||||
|
||||
unsigned int Parent(unsigned int i) { return (i + 1u) / 2u - 1u; }
|
||||
unsigned int Left(unsigned int i) { return (i + 1u) * 2u - 1u; }
|
||||
unsigned int Right(unsigned int i) { return (i + 1u) * 2u; }
|
||||
unsigned int Parent(unsigned int i) const { return (i + 1u) / 2u - 1u; }
|
||||
unsigned int Left(unsigned int i) const { return (i + 1u) * 2u - 1u; }
|
||||
unsigned int Right(unsigned int i) const { return (i + 1u) * 2u; }
|
||||
};
|
||||
|
||||
class HMISong : public MIDIStreamer
|
||||
|
@ -630,7 +630,7 @@ protected:
|
|||
struct TrackInfo;
|
||||
|
||||
void ProcessInitialMetaEvents ();
|
||||
DWORD *SendCommand (DWORD *event, TrackInfo *track, DWORD delay);
|
||||
DWORD *SendCommand (DWORD *event, TrackInfo *track, DWORD delay, ptrdiff_t room, bool &sysex_noroom);
|
||||
TrackInfo *FindNextDue ();
|
||||
|
||||
static DWORD ReadVarLenHMI(TrackInfo *);
|
||||
|
@ -673,7 +673,7 @@ protected:
|
|||
void AdvanceSong(DWORD time);
|
||||
|
||||
void ProcessInitialMetaEvents();
|
||||
DWORD *SendCommand (DWORD *event, EventSource track, DWORD delay);
|
||||
DWORD *SendCommand (DWORD *event, EventSource track, DWORD delay, ptrdiff_t room, bool &sysex_noroom);
|
||||
EventSource FindNextDue();
|
||||
|
||||
BYTE *MusHeader;
|
||||
|
|
|
@ -523,7 +523,12 @@ DWORD *HMISong::MakeEvents(DWORD *events, DWORD *max_event_p, DWORD max_time)
|
|||
// Play all events for this tick.
|
||||
do
|
||||
{
|
||||
DWORD *new_events = SendCommand(events, TrackDue, time);
|
||||
bool sysex_noroom = false;
|
||||
DWORD *new_events = SendCommand(events, TrackDue, time, max_event_p - events, sysex_noroom);
|
||||
if (sysex_noroom)
|
||||
{
|
||||
return events;
|
||||
}
|
||||
TrackDue = FindNextDue();
|
||||
if (new_events != events)
|
||||
{
|
||||
|
@ -568,7 +573,7 @@ void HMISong::AdvanceTracks(DWORD time)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
||||
DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptrdiff_t room, bool &sysex_noroom)
|
||||
{
|
||||
DWORD len;
|
||||
BYTE event, data1 = 0, data2 = 0;
|
||||
|
@ -584,10 +589,20 @@ DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
|||
return events + 3;
|
||||
}
|
||||
|
||||
sysex_noroom = false;
|
||||
size_t start_p = track->TrackP;
|
||||
|
||||
CHECK_FINISHED
|
||||
event = track->TrackBegin[track->TrackP++];
|
||||
CHECK_FINISHED
|
||||
|
||||
// The actual event type will be filled in below. If it's not a NOP,
|
||||
// the events pointer will be advanced once the actual event is written.
|
||||
// Otherwise, we do it at the end of the function.
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
events[2] = MEVT_NOP << 24;
|
||||
|
||||
if (event != MIDI_SYSEX && event != MIDI_META && event != MIDI_SYSEXEND && event != 0xFe)
|
||||
{
|
||||
// Normal short message
|
||||
|
@ -626,17 +641,10 @@ DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
|||
data2 = VolumeControllerChange(event & 15, data2);
|
||||
}
|
||||
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
if (event != MIDI_META)
|
||||
{
|
||||
events[2] = event | (data1<<8) | (data2<<16);
|
||||
}
|
||||
else
|
||||
{
|
||||
events[2] = MEVT_NOP << 24;
|
||||
}
|
||||
events += 3;
|
||||
|
||||
if (ReadVarLen == ReadVarLenHMI && (event & 0x70) == (MIDI_NOTEON & 0x70))
|
||||
{ // HMI note on events include the time until an implied note off event.
|
||||
|
@ -645,13 +653,41 @@ DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Skip SysEx events just because I don't want to bother with them.
|
||||
// The old MIDI player ignored them too, so this won't break
|
||||
// anything that played before.
|
||||
// SysEx events could potentially not have enough room in the buffer...
|
||||
if (event == MIDI_SYSEX || event == MIDI_SYSEXEND)
|
||||
{
|
||||
len = ReadVarLen(track);
|
||||
track->TrackP += len;
|
||||
if (len >= (MAX_EVENTS-1)*3*4)
|
||||
{ // This message will never fit. Throw it away.
|
||||
track->TrackP += len;
|
||||
}
|
||||
else if (len + 12 >= (size_t)room * 4)
|
||||
{ // Not enough room left in this buffer. Backup and wait for the next one.
|
||||
track->TrackP = start_p;
|
||||
sysex_noroom = true;
|
||||
return events;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *msg = (BYTE *)&events[3];
|
||||
if (event == MIDI_SYSEX)
|
||||
{ // Need to add the SysEx marker to the message.
|
||||
events[2] = (MEVT_LONGMSG << 24) | (len + 1);
|
||||
*msg++ = MIDI_SYSEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
events[2] = (MEVT_LONGMSG << 24) | len;
|
||||
}
|
||||
memcpy(msg, &track->TrackBegin[track->TrackP], len);
|
||||
msg += len;
|
||||
// Must pad with 0
|
||||
while ((size_t)msg & 3)
|
||||
{
|
||||
*msg++ = 0;
|
||||
}
|
||||
track->TrackP += len;
|
||||
}
|
||||
}
|
||||
else if (event == MIDI_META)
|
||||
{
|
||||
|
@ -677,7 +713,6 @@ DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
|||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
events[2] = (MEVT_TEMPO << 24) | Tempo;
|
||||
events += 3;
|
||||
break;
|
||||
}
|
||||
track->TrackP += len;
|
||||
|
@ -720,6 +755,18 @@ DWORD *HMISong::SendCommand (DWORD *events, TrackInfo *track, DWORD delay)
|
|||
{
|
||||
track->Delay = ReadVarLen(track);
|
||||
}
|
||||
// Advance events pointer unless this is a non-delaying NOP.
|
||||
if (events[0] != 0 || MEVT_EVENTTYPE(events[2]) != MEVT_NOP)
|
||||
{
|
||||
if (MEVT_EVENTTYPE(events[2]) == MEVT_LONGMSG)
|
||||
{
|
||||
events += 3 + ((MEVT_EVENTPARM(events[2]) + 3) >> 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
events += 3;
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
|
|
|
@ -384,6 +384,11 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
event = track->TrackBegin[track->TrackP++];
|
||||
CHECK_FINISHED
|
||||
|
||||
// The actual event type will be filled in below.
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
events[2] = MEVT_NOP << 24;
|
||||
|
||||
if (event != MIDI_SYSEX && event != MIDI_META && event != MIDI_SYSEXEND)
|
||||
{
|
||||
// Normal short message
|
||||
|
@ -582,17 +587,10 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
break;
|
||||
}
|
||||
}
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
if (event != MIDI_META && (!track->Designated || (track->Designation & DesignationMask)))
|
||||
{
|
||||
events[2] = event | (data1<<8) | (data2<<16);
|
||||
}
|
||||
else
|
||||
{
|
||||
events[2] = MEVT_NOP << 24;
|
||||
}
|
||||
events += 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -612,8 +610,6 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
}
|
||||
else
|
||||
{
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
BYTE *msg = (BYTE *)&events[3];
|
||||
if (event == MIDI_SYSEX)
|
||||
{ // Need to add the SysEx marker to the message.
|
||||
|
@ -631,7 +627,6 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
{
|
||||
*msg++ = 0;
|
||||
}
|
||||
events = (DWORD *)msg;
|
||||
track->TrackP += len;
|
||||
}
|
||||
}
|
||||
|
@ -659,7 +654,6 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
events[2] = (MEVT_TEMPO << 24) | Tempo;
|
||||
events += 3;
|
||||
break;
|
||||
}
|
||||
track->TrackP += len;
|
||||
|
@ -678,6 +672,18 @@ DWORD *MIDISong2::SendCommand (DWORD *events, TrackInfo *track, DWORD delay, ptr
|
|||
{
|
||||
track->Delay = track->ReadVarLen();
|
||||
}
|
||||
// Advance events pointer unless this is a non-delaying NOP.
|
||||
if (events[0] != 0 || MEVT_EVENTTYPE(events[2]) != MEVT_NOP)
|
||||
{
|
||||
if (MEVT_EVENTTYPE(events[2]) == MEVT_LONGMSG)
|
||||
{
|
||||
events += 3 + ((MEVT_EVENTPARM(events[2]) + 3) >> 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
events += 3;
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ WildMIDIDevice::WildMIDIDevice(const char *args)
|
|||
SampleRate = clamp(SampleRate, 11025, 65535);
|
||||
}
|
||||
|
||||
if (args == NULL || *args == 0) args = wildmidi_config;
|
||||
if (args == NULL || *args == 0) args = wildmidi_config;
|
||||
|
||||
if (CurrentConfig.CompareNoCase(args) != 0 || SampleRate != WildMidi_GetSampleRate())
|
||||
{
|
||||
|
|
|
@ -337,7 +337,12 @@ DWORD *XMISong::MakeEvents(DWORD *events, DWORD *max_event_p, DWORD max_time)
|
|||
// Play all events for this tick.
|
||||
do
|
||||
{
|
||||
DWORD *new_events = SendCommand(events, EventDue, time);
|
||||
bool sysex_noroom = false;
|
||||
DWORD *new_events = SendCommand(events, EventDue, time, max_event_p - events, sysex_noroom);
|
||||
if (sysex_noroom)
|
||||
{
|
||||
return events;
|
||||
}
|
||||
EventDue = FindNextDue();
|
||||
if (new_events != events)
|
||||
{
|
||||
|
@ -382,7 +387,7 @@ void XMISong::AdvanceSong(DWORD time)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay)
|
||||
DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay, ptrdiff_t room, bool &sysex_noroom)
|
||||
{
|
||||
DWORD len;
|
||||
BYTE event, data1 = 0, data2 = 0;
|
||||
|
@ -399,10 +404,20 @@ DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay)
|
|||
|
||||
TrackInfo *track = CurrSong;
|
||||
|
||||
sysex_noroom = false;
|
||||
size_t start_p = track->EventP;
|
||||
|
||||
CHECK_FINISHED
|
||||
event = track->EventChunk[track->EventP++];
|
||||
CHECK_FINISHED
|
||||
|
||||
// The actual event type will be filled in below. If it's not a NOP,
|
||||
// the events pointer will be advanced once the actual event is written.
|
||||
// Otherwise, we do it at the end of the function.
|
||||
events[0] = delay;
|
||||
events[1] = 0;
|
||||
events[2] = MEVT_NOP << 24;
|
||||
|
||||
if (event != MIDI_SYSEX && event != MIDI_META && event != MIDI_SYSEXEND)
|
||||
{
|
||||
// Normal short message
|
||||
|
@ -499,10 +514,6 @@ DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay)
|
|||
{
|
||||
events[2] = event | (data1<<8) | (data2<<16);
|
||||
}
|
||||
else
|
||||
{
|
||||
events[2] = MEVT_NOP << 24;
|
||||
}
|
||||
events += 3;
|
||||
|
||||
|
||||
|
@ -513,13 +524,41 @@ DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay)
|
|||
}
|
||||
else
|
||||
{
|
||||
// Skip SysEx events just because I don't want to bother with them.
|
||||
// The old MIDI player ignored them too, so this won't break
|
||||
// anything that played before.
|
||||
// SysEx events could potentially not have enough room in the buffer...
|
||||
if (event == MIDI_SYSEX || event == MIDI_SYSEXEND)
|
||||
{
|
||||
len = track->ReadVarLen ();
|
||||
track->EventP += len;
|
||||
len = track->ReadVarLen();
|
||||
if (len >= (MAX_EVENTS-1)*3*4)
|
||||
{ // This message will never fit. Throw it away.
|
||||
track->EventP += len;
|
||||
}
|
||||
else if (len + 12 >= (size_t)room * 4)
|
||||
{ // Not enough room left in this buffer. Backup and wait for the next one.
|
||||
track->EventP = start_p;
|
||||
sysex_noroom = true;
|
||||
return events;
|
||||
}
|
||||
else
|
||||
{
|
||||
BYTE *msg = (BYTE *)&events[3];
|
||||
if (event == MIDI_SYSEX)
|
||||
{ // Need to add the SysEx marker to the message.
|
||||
events[2] = (MEVT_LONGMSG << 24) | (len + 1);
|
||||
*msg++ = MIDI_SYSEX;
|
||||
}
|
||||
else
|
||||
{
|
||||
events[2] = (MEVT_LONGMSG << 24) | len;
|
||||
}
|
||||
memcpy(msg, &track->EventChunk[track->EventP++], len);
|
||||
msg += len;
|
||||
// Must pad with 0
|
||||
while ((size_t)msg & 3)
|
||||
{
|
||||
*msg++ = 0;
|
||||
}
|
||||
track->EventP += len;
|
||||
}
|
||||
}
|
||||
else if (event == MIDI_META)
|
||||
{
|
||||
|
@ -551,6 +590,18 @@ DWORD *XMISong::SendCommand (DWORD *events, EventSource due, DWORD delay)
|
|||
{
|
||||
track->Delay = track->ReadDelay();
|
||||
}
|
||||
// Advance events pointer unless this is a non-delaying NOP.
|
||||
if (events[0] != 0 || MEVT_EVENTTYPE(events[2]) != MEVT_NOP)
|
||||
{
|
||||
if (MEVT_EVENTTYPE(events[2]) == MEVT_LONGMSG)
|
||||
{
|
||||
events += 3 + ((MEVT_EVENTPARM(events[2]) + 3) >> 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
events += 3;
|
||||
}
|
||||
}
|
||||
return events;
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include "s_sound.h"
|
||||
#include "cmdlib.h"
|
||||
#include "p_lnspec.h"
|
||||
#include "p_effect.h"
|
||||
#include "p_enemy.h"
|
||||
#include "a_action.h"
|
||||
#include "decallib.h"
|
||||
|
@ -2876,6 +2877,42 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnDebris)
|
|||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// A_SpawnParticle
|
||||
//
|
||||
//===========================================================================
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnParticle)
|
||||
{
|
||||
PARAM_ACTION_PROLOGUE;
|
||||
PARAM_FIXED (xoff);
|
||||
PARAM_FIXED (yoff);
|
||||
PARAM_FIXED (zoff);
|
||||
PARAM_FIXED (xvel);
|
||||
PARAM_FIXED (yvel);
|
||||
PARAM_FIXED (zvel);
|
||||
PARAM_COLOR (color);
|
||||
PARAM_INT (lifetime);
|
||||
PARAM_BOOL_OPT (fullbright) { fullbright = false; }
|
||||
PARAM_INT_OPT (startalpha) { startalpha = 255; } // Byte trans
|
||||
PARAM_INT_OPT (size) { size = -1; }
|
||||
PARAM_INT_OPT (fadestep) { fadestep = -1; }
|
||||
PARAM_FIXED_OPT (accelx) { accelx = 0; }
|
||||
PARAM_FIXED_OPT (accely) { accely = 0; }
|
||||
PARAM_FIXED_OPT (accelz) { accelz = 0; }
|
||||
|
||||
startalpha = clamp<int>(startalpha, 0, 0xFF); // Clamp to byte
|
||||
lifetime = clamp<int>(lifetime, 0, 0xFF); // Clamp to byte
|
||||
fadestep = clamp<int>(fadestep, -1, 0xFF); // Clamp to byte inc. -1 (indicating automatic)
|
||||
size = clamp<int>(size, 0, 0xFF); // Clamp to byte
|
||||
|
||||
if (lifetime != 0)
|
||||
{
|
||||
fixedvec3 pos = self->Vec3Offset(xoff, yoff, zoff);
|
||||
P_SpawnParticle(pos.x, pos.y, pos.z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
@ -4580,6 +4617,7 @@ enum T_Flags
|
|||
TF_USEACTORFOG = 0x00000100, // Use the actor's TeleFogSourceType and TeleFogDestType fogs.
|
||||
TF_NOJUMP = 0x00000200, // Don't jump after teleporting.
|
||||
TF_OVERRIDE = 0x00000400, // Ignore NOTELEPORT.
|
||||
TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z).
|
||||
};
|
||||
|
||||
DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
|
||||
|
@ -4644,6 +4682,18 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
|
|||
return numret;
|
||||
}
|
||||
|
||||
// [MC] By default, the function adjusts the actor's Z if it's below the floor or above the ceiling.
|
||||
// This can be an issue as actors designed to maintain specific z positions wind up teleporting
|
||||
// anyway when they should not, such as a floor rising above or ceiling lowering below the position
|
||||
// of the spot.
|
||||
if (flags & TF_SENSITIVEZ)
|
||||
{
|
||||
fixed_t posz = (flags & TF_USESPOTZ) ? spot->Z() : spot->floorz;
|
||||
if ((posz + ref->height > spot->ceilingz) || (posz < spot->floorz))
|
||||
{
|
||||
return numret;
|
||||
}
|
||||
}
|
||||
fixedvec3 prev = ref->Pos();
|
||||
fixed_t aboveFloor = spot->Z() - spot->floorz;
|
||||
fixed_t finalz = spot->floorz + aboveFloor;
|
||||
|
@ -4654,7 +4704,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
|
|||
finalz = spot->floorz;
|
||||
|
||||
//Take precedence and cooperate with telefragging first.
|
||||
bool tele_result = P_TeleportMove(ref, spot->X(), spot->Y(), finalz, flags & TF_TELEFRAG);
|
||||
bool tele_result = P_TeleportMove(ref, spot->X(), spot->Y(), finalz, !!(flags & TF_TELEFRAG));
|
||||
|
||||
if (!tele_result && (flags & TF_FORCED))
|
||||
{
|
||||
|
@ -4695,7 +4745,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Teleport)
|
|||
}
|
||||
|
||||
ref->SetZ((flags & TF_USESPOTZ) ? spot->Z() : ref->floorz, false);
|
||||
self->SetZ((flags & TF_USESPOTZ) ? spot->Z() : self->floorz, false);
|
||||
|
||||
if (!(flags & TF_KEEPANGLE))
|
||||
ref->angle = spot->angle;
|
||||
|
@ -6389,4 +6438,4 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock)
|
|||
ACTION_JUMP(block);
|
||||
}
|
||||
return numret;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
** file_io.cpp
|
||||
** ZDoom compatible file IO interface for WildMIDI
|
||||
** (This file was completely redone to remove the low level IO code references)
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2010 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
/*
|
||||
** file_io.cpp
|
||||
** ZDoom compatible file IO interface for WildMIDI
|
||||
** (This file was completely redone to remove the low level IO code references)
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2010 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
**---------------------------------------------------------------------------
|
||||
**
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -48,36 +48,36 @@ unsigned char *_WM_BufferFile(const char *filename, unsigned long int *size, boo
|
|||
FileReader *fp;
|
||||
int lumpnum;
|
||||
|
||||
if (ismain)
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_FILEORLUMP;
|
||||
wmPathExpander.clearPathlist();
|
||||
#ifdef _WIN32
|
||||
wmPathExpander.addToPathlist("C:\\TIMIDITY");
|
||||
wmPathExpander.addToPathlist("\\TIMIDITY");
|
||||
wmPathExpander.addToPathlist(progdir);
|
||||
#else
|
||||
wmPathExpander.addToPathlist("/usr/local/lib/timidity");
|
||||
wmPathExpander.addToPathlist("/etc/timidity");
|
||||
wmPathExpander.addToPathlist("/etc");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(fp = wmPathExpander.openFileReader(filename, &lumpnum)))
|
||||
return NULL;
|
||||
|
||||
if (ismain)
|
||||
{
|
||||
if (lumpnum > 0)
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_LUMP;
|
||||
wmPathExpander.clearPathlist(); // when reading from a PK3 we don't want to use any external path
|
||||
}
|
||||
else
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_FILE;
|
||||
}
|
||||
}
|
||||
if (ismain)
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_FILEORLUMP;
|
||||
wmPathExpander.clearPathlist();
|
||||
#ifdef _WIN32
|
||||
wmPathExpander.addToPathlist("C:\\TIMIDITY");
|
||||
wmPathExpander.addToPathlist("\\TIMIDITY");
|
||||
wmPathExpander.addToPathlist(progdir);
|
||||
#else
|
||||
wmPathExpander.addToPathlist("/usr/local/lib/timidity");
|
||||
wmPathExpander.addToPathlist("/etc/timidity");
|
||||
wmPathExpander.addToPathlist("/etc");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!(fp = wmPathExpander.openFileReader(filename, &lumpnum)))
|
||||
return NULL;
|
||||
|
||||
if (ismain)
|
||||
{
|
||||
if (lumpnum > 0)
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_LUMP;
|
||||
wmPathExpander.clearPathlist(); // when reading from a PK3 we don't want to use any external path
|
||||
}
|
||||
else
|
||||
{
|
||||
wmPathExpander.openmode = PathExpander::OM_FILE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -202,6 +202,7 @@ ACTOR Actor native //: Thinker
|
|||
action native A_SetScale(float scalex, float scaley = 0, int ptr = AAPTR_DEFAULT);
|
||||
action native A_SetMass(int mass);
|
||||
action native A_SpawnDebris(class<Actor> spawntype, bool transfer_translation = false, float mult_h = 1, float mult_v = 1);
|
||||
action native A_SpawnParticle(float xoff, float yoff, float zoff, float velx, float vely, float velz, color color1, int lifetime, bool fullbright = false, int startalpha = 255, int size = 1, int fadestep = -1, float accelx = 0.0, float accely = 0.0, float accelz = 0.0);
|
||||
action native A_CheckSight(state label);
|
||||
action native A_ExtChase(bool usemelee, bool usemissile, bool playactive = true, bool nightmarefast = false);
|
||||
action native A_DropInventory(class<Inventory> itemtype);
|
||||
|
|
|
@ -208,6 +208,7 @@ enum
|
|||
TF_USEACTORFOG = 0x00000100, // Use the actor's TeleFogSourceType and TeleFogDestType fogs.
|
||||
TF_NOJUMP = 0x00000200, // Don't jump after teleporting.
|
||||
TF_OVERRIDE = 0x00000400, // Ignore NOTELEPORT.
|
||||
TF_SENSITIVEZ = 0x00000800, // Fail if the actor wouldn't fit in the position (for Z).
|
||||
|
||||
TF_KEEPORIENTATION = TF_KEEPVELOCITY|TF_KEEPANGLE,
|
||||
TF_NOFOG = TF_NOSRCFOG|TF_NODESTFOG,
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
|
||||
/***** BFG Scorches ********************************************************/
|
||||
|
||||
decal BFGLightning1
|
||||
{
|
||||
pic BFGLITE1
|
||||
shade "80 80 ff"
|
||||
fullbright
|
||||
randomflipx
|
||||
animator GoAway2
|
||||
lowerdecal BFGScorch
|
||||
}
|
||||
|
||||
decal BFGLightning2
|
||||
{
|
||||
pic BFGLITE2
|
||||
shade "80 80 ff"
|
||||
fullbright
|
||||
randomflipy
|
||||
animator GoAway2
|
||||
lowerdecal BFGScorch
|
||||
}
|
||||
|
||||
decalgroup BFGLightning
|
||||
{
|
||||
BFGLightning1 1
|
||||
BFGLightning2 1
|
||||
}
|
||||
|
||||
|
||||
/***** BFG Scorches ********************************************************/
|
||||
|
||||
decal BFGLightning1
|
||||
{
|
||||
pic BFGLITE1
|
||||
shade "80 80 ff"
|
||||
fullbright
|
||||
randomflipx
|
||||
animator GoAway2
|
||||
lowerdecal BFGScorch
|
||||
}
|
||||
|
||||
decal BFGLightning2
|
||||
{
|
||||
pic BFGLITE2
|
||||
shade "80 80 ff"
|
||||
fullbright
|
||||
randomflipy
|
||||
animator GoAway2
|
||||
lowerdecal BFGScorch
|
||||
}
|
||||
|
||||
decalgroup BFGLightning
|
||||
{
|
||||
BFGLightning1 1
|
||||
BFGLightning2 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue