mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-10 16:07:09 -06:00
15.06
This commit is contained in:
committed by
Kornel Lesiński
parent
54490d51d5
commit
cba375916f
@@ -7,10 +7,10 @@
|
||||
|
||||
#include "../../../C/CpuArch.h"
|
||||
|
||||
#include "../../Common/MyTypes.h"
|
||||
#include "../../Common/MyVector.h"
|
||||
|
||||
#define RARVM_STANDARD_FILTERS
|
||||
// #define RARVM_VM_ENABLE
|
||||
|
||||
namespace NCompress {
|
||||
namespace NRar3 {
|
||||
@@ -39,12 +39,12 @@ namespace NVm {
|
||||
inline UInt32 GetValue32(const void *addr) { return GetUi32(addr); }
|
||||
inline void SetValue32(void *addr, UInt32 value) { SetUi32(addr, value); }
|
||||
|
||||
const int kNumRegBits = 3;
|
||||
const unsigned kNumRegBits = 3;
|
||||
const UInt32 kNumRegs = 1 << kNumRegBits;
|
||||
const UInt32 kNumGpRegs = kNumRegs - 1;
|
||||
|
||||
const UInt32 kSpaceSize = 0x40000;
|
||||
const UInt32 kSpaceMask = kSpaceSize -1;
|
||||
const UInt32 kSpaceMask = kSpaceSize - 1;
|
||||
const UInt32 kGlobalOffset = 0x3C000;
|
||||
const UInt32 kGlobalSize = 0x2000;
|
||||
const UInt32 kFixedGlobalSize = 64;
|
||||
@@ -57,6 +57,9 @@ namespace NGlobalOffset
|
||||
const UInt32 kGlobalMemOutSize = 0x30;
|
||||
}
|
||||
|
||||
|
||||
#ifdef RARVM_VM_ENABLE
|
||||
|
||||
enum ECommand
|
||||
{
|
||||
CMD_MOV, CMD_CMP, CMD_ADD, CMD_SUB, CMD_JZ, CMD_JNZ, CMD_INC, CMD_DEC,
|
||||
@@ -89,27 +92,36 @@ struct CCommand
|
||||
COperand Op1, Op2;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct CBlockRef
|
||||
{
|
||||
UInt32 Offset;
|
||||
UInt32 Size;
|
||||
};
|
||||
|
||||
|
||||
class CProgram
|
||||
{
|
||||
#ifdef RARVM_VM_ENABLE
|
||||
void ReadProgram(const Byte *code, UInt32 codeSize);
|
||||
public:
|
||||
CRecordVector<CCommand> Commands;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#ifdef RARVM_STANDARD_FILTERS
|
||||
int StandardFilterIndex;
|
||||
#endif
|
||||
|
||||
bool IsSupported;
|
||||
CRecordVector<Byte> StaticData;
|
||||
|
||||
private:
|
||||
void ReadProgram(const Byte *code, UInt32 codeSize);
|
||||
public:
|
||||
void PrepareProgram(const Byte *code, UInt32 codeSize);
|
||||
bool PrepareProgram(const Byte *code, UInt32 codeSize);
|
||||
};
|
||||
|
||||
|
||||
struct CProgramInitState
|
||||
{
|
||||
UInt32 InitR[kNumGpRegs];
|
||||
@@ -122,6 +134,7 @@ struct CProgramInitState
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CVm
|
||||
{
|
||||
static UInt32 GetValue(bool byteMode, const void *addr)
|
||||
@@ -146,15 +159,18 @@ class CVm
|
||||
void SetBlockPos(UInt32 v) { SetValue(&Mem[kGlobalOffset + NGlobalOffset::kBlockPos], v); }
|
||||
public:
|
||||
static void SetValue(void *addr, UInt32 value) { SetValue(false, addr, value); }
|
||||
|
||||
private:
|
||||
|
||||
#ifdef RARVM_VM_ENABLE
|
||||
UInt32 GetOperand32(const COperand *op) const;
|
||||
void SetOperand32(const COperand *op, UInt32 val);
|
||||
Byte GetOperand8(const COperand *op) const;
|
||||
void SetOperand8(const COperand *op, Byte val);
|
||||
UInt32 GetOperand(bool byteMode, const COperand *op) const;
|
||||
void SetOperand(bool byteMode, const COperand *op, UInt32 val);
|
||||
|
||||
bool ExecuteCode(const CProgram *prg);
|
||||
#endif
|
||||
|
||||
#ifdef RARVM_STANDARD_FILTERS
|
||||
void ExecuteStandardFilter(unsigned filterIndex);
|
||||
@@ -163,6 +179,7 @@ private:
|
||||
Byte *Mem;
|
||||
UInt32 R[kNumRegs + 1]; // R[kNumRegs] = 0 always (speed optimization)
|
||||
UInt32 Flags;
|
||||
|
||||
public:
|
||||
CVm();
|
||||
~CVm();
|
||||
@@ -171,7 +188,6 @@ public:
|
||||
bool Execute(CProgram *prg, const CProgramInitState *initState,
|
||||
CBlockRef &outBlockRef, CRecordVector<Byte> &outGlobalData);
|
||||
const Byte *GetDataPointer(UInt32 offset) const { return Mem + offset; }
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user