| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef __sramstream_h__ |
| 18 |
#define __sramstream_h__ |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
char *hamfake_readLockSRAM(); |
| 24 |
void hamfake_readUnlockSRAM(char *); |
| 25 |
|
| 26 |
char *hamfake_writeLockSRAM(); |
| 27 |
void hamfake_writeUnlockSRAM(char *); |
| 28 |
|
| 29 |
void hamfake_endWritingSession(); |
| 30 |
|
| 31 |
enum COMPRESS_TYPE |
| 32 |
{ |
| 33 |
COMPRESS_NONE, |
| 34 |
COMPRESS_CONSTANT, |
| 35 |
COMPRESS_ZEROTABLE, |
| 36 |
COMPRESS_RLE |
| 37 |
}; |
| 38 |
|
| 39 |
enum PREPROCESS_TYPE |
| 40 |
{ |
| 41 |
PREPROCESS_NONE, |
| 42 |
PREPROCESS_BYTE, |
| 43 |
PREPROCESS_SHORT, |
| 44 |
PREPROCESS_INT |
| 45 |
}; |
| 46 |
|
| 47 |
class SRAMSTREAM |
| 48 |
{ |
| 49 |
public: |
| 50 |
SRAMSTREAM(bool silent); |
| 51 |
~SRAMSTREAM(); |
| 52 |
|
| 53 |
|
| 54 |
void rewind(); |
| 55 |
|
| 56 |
bool writeRaw(const char *data, int numbytes); |
| 57 |
bool readRaw(char *data, int numbytes); |
| 58 |
|
| 59 |
|
| 60 |
bool write(int val, int bits); |
| 61 |
|
| 62 |
bool read(int &val, int bits); |
| 63 |
|
| 64 |
bool uread(int &val, int bits); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
bool readString(char *dst, int maxlen); |
| 70 |
bool writeString(const char *src, int maxlen); |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
bool flush(); |
| 75 |
|
| 76 |
protected: |
| 77 |
void writeToSRAM(char *data, int len); |
| 78 |
void readFromSRAM(char *data, int len); |
| 79 |
|
| 80 |
|
| 81 |
int compress(char *dst, char *src, int blocklen); |
| 82 |
int compressConstant(char *dst, char *src); |
| 83 |
int compressNone(char *dst, char *src, int len, bool header=true); |
| 84 |
int compressZeroTable(char *dst, char *src, PREPROCESS_TYPE preprocess, int len); |
| 85 |
int compressRLE(char *dst, char *src, int len, bool header=true); |
| 86 |
int decompress(char *dst, char *src, int blocklen); |
| 87 |
int decompressConstant(char *dst, char *src, int len); |
| 88 |
int decompressNone(char *dst, char *src, int len); |
| 89 |
int decompressZeroTable(char *dst, char *src, PREPROCESS_TYPE preprocess, int blocklen); |
| 90 |
int decompressRLE(char *dst, char *src, int len); |
| 91 |
|
| 92 |
private: |
| 93 |
int mySRAMPtr; |
| 94 |
int myPos; |
| 95 |
int myBit; |
| 96 |
char myBuffer[1024]; |
| 97 |
int myNumBlocks; |
| 98 |
bool mySilent; |
| 99 |
}; |
| 100 |
|
| 101 |
#endif |