rlm@1: #ifndef VBA_CHEATSEARCH_H
rlm@1: #define VBA_CHEATSEARCH_H
rlm@1: 
rlm@1: #if _MSC_VER > 1000
rlm@1: #pragma once
rlm@1: #endif // _MSC_VER > 1000
rlm@1: 
rlm@1: #include "../Port.h"
rlm@1: 
rlm@1: struct CheatSearchBlock
rlm@1: {
rlm@1: 	u8 *data;
rlm@1: 	int size;
rlm@1: 	u32 offset;
rlm@1: 	u8 *saved;
rlm@1: 	u8 *bits;
rlm@1: };
rlm@1: 
rlm@1: struct CheatSearchData
rlm@1: {
rlm@1: 	int count;
rlm@1: 	CheatSearchBlock *blocks;
rlm@1: };
rlm@1: 
rlm@1: enum
rlm@1: {
rlm@1: 	SEARCH_EQ,
rlm@1: 	SEARCH_NE,
rlm@1: 	SEARCH_LT,
rlm@1: 	SEARCH_LE,
rlm@1: 	SEARCH_GT,
rlm@1: 	SEARCH_GE
rlm@1: };
rlm@1: 
rlm@1: enum
rlm@1: {
rlm@1: 	BITS_8,
rlm@1: 	BITS_16,
rlm@1: 	BITS_32
rlm@1: };
rlm@1: 
rlm@1: #define SET_BIT(bits, off) \
rlm@1:     (bits)[(off) >> 3] |= (1 << ((off) & 7))
rlm@1: 
rlm@1: #define CLEAR_BIT(bits, off) \
rlm@1:     (bits)[(off) >> 3] &= ~(1 << ((off) & 7))
rlm@1: 
rlm@1: #define IS_BIT_SET(bits, off) \
rlm@1:     (bits)[(off) >> 3] & (1 << ((off) & 7))
rlm@1: 
rlm@1: extern CheatSearchData cheatSearchData;
rlm@1: extern void cheatSearchSetSavedAndBits(CheatSearchBlock *block);
rlm@1: extern void cheatSearchZeroBlock(CheatSearchBlock *block);
rlm@1: extern void cheatSearchCleanup(CheatSearchData *cs);
rlm@1: extern void cheatSearchStart(const CheatSearchData *cs);
rlm@1: extern void cheatSearch(const CheatSearchData *cs, int compare, int size,
rlm@1:                         bool isSigned);
rlm@1: extern void cheatSearchValue(const CheatSearchData *cs, int compare, int size,
rlm@1:                              bool isSigned, u32 value);
rlm@1: extern int cheatSearchGetCount(const CheatSearchData *cs, int size);
rlm@1: extern void cheatSearchUpdateValues(const CheatSearchData *cs);
rlm@1: extern s32 cheatSearchSignedRead(u8 *data, int off, int size);
rlm@1: extern u32 cheatSearchRead(u8 *data, int off, int size);
rlm@1: 
rlm@1: #endif // VBA_CHEATSEARCH_H