diff --git a/.clang-format b/.clang-format index a494e220..314f9f67 100644 --- a/.clang-format +++ b/.clang-format @@ -1,84 +1,90 @@ --- -AccessModifierOffset: 0 -AlignAfterOpenBracket: true +Language: Cpp +# BasedOnStyle: WebKit +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign AlignConsecutiveAssignments: false -#uncomment for clang 3.9 -#AlignConsecutiveDeclarations: false +AlignConsecutiveDeclarations: false AlignEscapedNewlinesLeft: false -AlignOperands: true -AlignTrailingComments: true +AlignOperands: false +AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false -AllowShortFunctionsOnASingleLine: None +AllowShortFunctionsOnASingleLine: All AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false -# AlwaysBreakAfterDefinitionReturnType: None -#uncomment for clang 3.9 -#AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: false -BinPackArguments: false +BinPackArguments: true BinPackParameters: true -# BraceWrapping: (not set since BreakBeforeBraces is not Custom) -BreakBeforeBinaryOperators: None -# BreakAfterJavaFieldAnnotations: (not java) -BreakBeforeBinaryOperators: None -BreakBeforeBraces: Linux +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: true + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: All +BreakBeforeBraces: WebKit BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false -#uncomment for clang 3.9 -#BreakStringLiterals: false -ColumnLimit: 100 -CommentPragmas: '\*\<' +BreakConstructorInitializersBeforeComma: true +ColumnLimit: 0 +CommentPragmas: '^ IWYU pragma:' ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 4 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false DerivePointerAlignment: false -DisableFormat: false +DisableFormat: false ExperimentalAutoDetectBinPacking: false -ForEachMacros: [ NC_LIST_FOREACH ] -#Uncomment for clang 3.9 -#IncludeCategories: -# - Regex: '^"' -# Priority: 1 -# IncludeIsMainRegex: (project doesn't use a main includes that can add other includes via regex) +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 IndentCaseLabels: false -IndentWidth: 8 +IndentWidth: 4 IndentWrappedFunctionNames: false -# JavaScriptQuotes: (not javascript) -KeepEmptyLinesAtTheStartOfBlocks: false -Language: Cpp +KeepEmptyLinesAtTheStartOfBlocks: true MacroBlockBegin: '' MacroBlockEnd: '' MaxEmptyLinesToKeep: 1 -NamespaceIndentation: None -# ObjCBlockIndentWidth: (not objc) -# ObjCSpaceAfterProperty: (not objc) -# ObjCSpaceBeforeProtocolList: (not objc) -PenaltyBreakBeforeFirstCallParameter: 400 -PenaltyBreakComment: 0 -# PenaltyBreakFirstLessLess: (not cpp) -PenaltyBreakString: 500 -PenaltyExcessCharacter: 10000 -PenaltyReturnTypeOnItsOwnLine: 600 -PointerAlignment: Right -#uncomment for clang 3.9 -#ReflowComments: true -#uncomment for clang 3.9 -#SortIncludes: true +NamespaceIndentation: Inner +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: true +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 60 +PointerAlignment: Left +ReflowComments: true +SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 -SpacesInAngles: false +SpacesInAngles: false +SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false -# SpacesInContainerLiterals: (not objc or javascript) SpacesInParentheses: false SpacesInSquareBrackets: false -Standard: Cpp11 +Standard: Cpp03 TabWidth: 8 UseTab: Never ... + diff --git a/fex/7z_C/7z.h b/fex/7z_C/7z.h index 01c4cac6..ec966b36 100644 --- a/fex/7z_C/7z.h +++ b/fex/7z_C/7z.h @@ -13,66 +13,62 @@ EXTERN_C_BEGIN extern Byte k7zSignature[k7zSignatureSize]; #define k7zMajorVersion 0 -enum EIdEnum -{ - k7zIdEnd, - k7zIdHeader, - k7zIdArchiveProperties, - k7zIdAdditionalStreamsInfo, - k7zIdMainStreamsInfo, - k7zIdFilesInfo, - k7zIdPackInfo, - k7zIdUnpackInfo, - k7zIdSubStreamsInfo, - k7zIdSize, - k7zIdCRC, - k7zIdFolder, - k7zIdCodersUnpackSize, - k7zIdNumUnpackStream, - k7zIdEmptyStream, - k7zIdEmptyFile, - k7zIdAnti, - k7zIdName, - k7zIdCTime, - k7zIdATime, - k7zIdMTime, - k7zIdWinAttributes, - k7zIdComment, - k7zIdEncodedHeader, - k7zIdStartPos, - k7zIdDummy +enum EIdEnum { + k7zIdEnd, + k7zIdHeader, + k7zIdArchiveProperties, + k7zIdAdditionalStreamsInfo, + k7zIdMainStreamsInfo, + k7zIdFilesInfo, + k7zIdPackInfo, + k7zIdUnpackInfo, + k7zIdSubStreamsInfo, + k7zIdSize, + k7zIdCRC, + k7zIdFolder, + k7zIdCodersUnpackSize, + k7zIdNumUnpackStream, + k7zIdEmptyStream, + k7zIdEmptyFile, + k7zIdAnti, + k7zIdName, + k7zIdCTime, + k7zIdATime, + k7zIdMTime, + k7zIdWinAttributes, + k7zIdComment, + k7zIdEncodedHeader, + k7zIdStartPos, + k7zIdDummy }; -typedef struct -{ - UInt32 NumInStreams; - UInt32 NumOutStreams; - UInt64 MethodID; - CBuf Props; +typedef struct { + UInt32 NumInStreams; + UInt32 NumOutStreams; + UInt64 MethodID; + CBuf Props; } CSzCoderInfo; void SzCoderInfo_Init(CSzCoderInfo *p); void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); -typedef struct -{ - UInt32 InIndex; - UInt32 OutIndex; +typedef struct { + UInt32 InIndex; + UInt32 OutIndex; } CSzBindPair; -typedef struct -{ - CSzCoderInfo *Coders; - CSzBindPair *BindPairs; - UInt32 *PackStreams; - UInt64 *UnpackSizes; - UInt32 NumCoders; - UInt32 NumBindPairs; - UInt32 NumPackStreams; - int UnpackCRCDefined; - UInt32 UnpackCRC; +typedef struct { + CSzCoderInfo *Coders; + CSzBindPair *BindPairs; + UInt32 *PackStreams; + UInt64 *UnpackSizes; + UInt32 NumCoders; + UInt32 NumBindPairs; + UInt32 NumPackStreams; + int UnpackCRCDefined; + UInt32 UnpackCRC; - UInt32 NumUnpackStreams; + UInt32 NumUnpackStreams; } CSzFolder; void SzFolder_Init(CSzFolder *p); @@ -81,48 +77,43 @@ int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex); UInt32 SzFolder_GetNumOutStreams(CSzFolder *p); UInt64 SzFolder_GetUnpackSize(CSzFolder *p); -SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *stream, UInt64 startPos, - Byte *outBuffer, size_t outSize, ISzAlloc *allocMain); +SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, ILookInStream *stream, + UInt64 startPos, Byte *outBuffer, size_t outSize, ISzAlloc *allocMain); -typedef struct -{ - UInt32 Low; - UInt32 High; +typedef struct { + UInt32 Low; + UInt32 High; } CNtfsFileTime; -typedef struct -{ - CNtfsFileTime MTime; - UInt64 Size; - UInt32 Crc; - UInt32 Attrib; - Byte HasStream; - Byte IsDir; - Byte IsAnti; - Byte CrcDefined; - Byte MTimeDefined; - Byte AttribDefined; +typedef struct { + CNtfsFileTime MTime; + UInt64 Size; + UInt32 Crc; + UInt32 Attrib; + Byte HasStream; + Byte IsDir; + Byte IsAnti; + Byte CrcDefined; + Byte MTimeDefined; + Byte AttribDefined; } CSzFileItem; void SzFile_Init(CSzFileItem *p); -typedef struct -{ - UInt64 *PackSizes; - Byte *PackCRCsDefined; - UInt32 *PackCRCs; - CSzFolder *Folders; - CSzFileItem *Files; - UInt32 NumPackStreams; - UInt32 NumFolders; - UInt32 NumFiles; +typedef struct { + UInt64 *PackSizes; + Byte *PackCRCsDefined; + UInt32 *PackCRCs; + CSzFolder *Folders; + CSzFileItem *Files; + UInt32 NumPackStreams; + UInt32 NumFolders; + UInt32 NumFiles; } CSzAr; void SzAr_Init(CSzAr *p); void SzAr_Free(CSzAr *p, ISzAlloc *alloc); - /* SzExtract extracts file from archive @@ -136,27 +127,26 @@ void SzAr_Free(CSzAr *p, ISzAlloc *alloc); *outBufferSize You can consider "*outBuffer" as cache of solid block. If your archive is solid, it will increase decompression speed. - + If you use external function, you can declare these 3 cache variables (blockIndex, outBuffer, outBufferSize) as static in that external function. - + Free *outBuffer and set *outBuffer to 0, if you want to flush cache. */ -typedef struct -{ - CSzAr db; - - UInt64 startPosAfterHeader; - UInt64 dataPos; +typedef struct { + CSzAr db; - UInt32 *FolderStartPackStreamIndex; - UInt64 *PackStreamStartPositions; - UInt32 *FolderStartFileIndex; - UInt32 *FileIndexToFolderIndexMap; + UInt64 startPosAfterHeader; + UInt64 dataPos; - size_t *FileNameOffsets; /* in 2-byte steps */ - CBuf FileNames; /* UTF-16-LE */ + UInt32 *FolderStartPackStreamIndex; + UInt64 *PackStreamStartPositions; + UInt32 *FolderStartFileIndex; + UInt32 *FileIndexToFolderIndexMap; + + size_t *FileNameOffsets; /* in 2-byte steps */ + CBuf FileNames; /* UTF-16-LE */ } CSzArEx; void SzArEx_Init(CSzArEx *p); @@ -172,18 +162,15 @@ if dest != NULL, the return value specifies the number of 16-bit characters that size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest); -SRes SzArEx_Extract( - const CSzArEx *db, - ILookInStream *inStream, - UInt32 fileIndex, /* index of file */ - UInt32 *blockIndex, /* index of solid block */ - Byte **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - +SRes SzArEx_Extract(const CSzArEx *db, ILookInStream *inStream, UInt32 fileIndex, /* index of file + */ + UInt32 *blockIndex, /* index of solid block */ + Byte **outBuffer, /* pointer to pointer to output buffer (allocated with + allocMain) */ + size_t *outBufferSize, /* buffer size for output buffer */ + size_t *offset, /* offset of stream for required file in *outBuffer */ + size_t *outSizeProcessed, /* size of file in *outBuffer */ + ISzAlloc *allocMain, ISzAlloc *allocTemp); /* SzArEx_Open Errors: diff --git a/fex/7z_C/7zAlloc.c b/fex/7z_C/7zAlloc.c index 964b28db..edb5e534 100644 --- a/fex/7z_C/7zAlloc.c +++ b/fex/7z_C/7zAlloc.c @@ -20,57 +20,55 @@ int g_allocCountTemp = 0; void *SzAlloc(void *p, size_t size) { - p = p; - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); - g_allocCount++; - #endif - return malloc(size); + p = p; + if (size == 0) + return 0; +#ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc %10d bytes; count = %10d", size, g_allocCount); + g_allocCount++; +#endif + return malloc(size); } void SzFree(void *p, void *address) { - p = p; - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCount--; - fprintf(stderr, "\nFree; count = %10d", g_allocCount); - } - #endif - free(address); + p = p; +#ifdef _SZ_ALLOC_DEBUG + if (address != 0) { + g_allocCount--; + fprintf(stderr, "\nFree; count = %10d", g_allocCount); + } +#endif + free(address); } void *SzAllocTemp(void *p, size_t size) { - p = p; - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); - g_allocCountTemp++; - #ifdef _WIN32 - return HeapAlloc(GetProcessHeap(), 0, size); - #endif - #endif - return malloc(size); + p = p; + if (size == 0) + return 0; +#ifdef _SZ_ALLOC_DEBUG + fprintf(stderr, "\nAlloc_temp %10d bytes; count = %10d", size, g_allocCountTemp); + g_allocCountTemp++; +#ifdef _WIN32 + return HeapAlloc(GetProcessHeap(), 0, size); +#endif +#endif + return malloc(size); } void SzFreeTemp(void *p, void *address) { - p = p; - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - { - g_allocCountTemp--; - fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); - } - #ifdef _WIN32 - HeapFree(GetProcessHeap(), 0, address); - return; - #endif - #endif - free(address); + p = p; +#ifdef _SZ_ALLOC_DEBUG + if (address != 0) { + g_allocCountTemp--; + fprintf(stderr, "\nFree_temp; count = %10d", g_allocCountTemp); + } +#ifdef _WIN32 + HeapFree(GetProcessHeap(), 0, address); + return; +#endif +#endif + free(address); } diff --git a/fex/7z_C/7zBuf.c b/fex/7z_C/7zBuf.c index 14e7f4e2..b9c94564 100644 --- a/fex/7z_C/7zBuf.c +++ b/fex/7z_C/7zBuf.c @@ -7,30 +7,28 @@ Public domain */ void Buf_Init(CBuf *p) { - p->data = 0; - p->size = 0; + p->data = 0; + p->size = 0; } int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) { - p->size = 0; - if (size == 0) - { - p->data = 0; - return 1; - } - p->data = (Byte *)alloc->Alloc(alloc, size); - if (p->data != 0) - { - p->size = size; - return 1; - } - return 0; + p->size = 0; + if (size == 0) { + p->data = 0; + return 1; + } + p->data = (Byte *)alloc->Alloc(alloc, size); + if (p->data != 0) { + p->size = size; + return 1; + } + return 0; } void Buf_Free(CBuf *p, ISzAlloc *alloc) { - alloc->Free(alloc, p->data); - p->data = 0; - p->size = 0; + alloc->Free(alloc, p->data); + p->data = 0; + p->size = 0; } diff --git a/fex/7z_C/7zBuf.h b/fex/7z_C/7zBuf.h index e9f2f316..5f0b9673 100644 --- a/fex/7z_C/7zBuf.h +++ b/fex/7z_C/7zBuf.h @@ -10,21 +10,19 @@ extern "C" { #endif -typedef struct -{ - Byte *data; - size_t size; +typedef struct { + Byte *data; + size_t size; } CBuf; void Buf_Init(CBuf *p); int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); void Buf_Free(CBuf *p, ISzAlloc *alloc); -typedef struct -{ - Byte *data; - size_t size; - size_t pos; +typedef struct { + Byte *data; + size_t size; + size_t pos; } CDynBuf; void DynBuf_Construct(CDynBuf *p); diff --git a/fex/7z_C/7zCrc.c b/fex/7z_C/7zCrc.c index a9208496..57c8bcbb 100644 --- a/fex/7z_C/7zCrc.c +++ b/fex/7z_C/7zCrc.c @@ -12,7 +12,8 @@ #define CRC_NUM_TABLES 1 #endif -typedef UInt32 (MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, const UInt32 *table); +typedef UInt32(MY_FAST_CALL *CRC_FUNC)(UInt32 v, const void *data, size_t size, + const UInt32 *table); static CRC_FUNC g_CrcUpdate; UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; @@ -23,10 +24,10 @@ UInt32 g_CrcTable[256 * CRC_NUM_TABLES]; static UInt32 MY_FAST_CALL CrcUpdateT1(UInt32 v, const void *data, size_t size, const UInt32 *table) { - const Byte *p = (const Byte *)data; - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; + const Byte *p = (const Byte *)data; + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; } #else @@ -38,37 +39,35 @@ UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const U UInt32 MY_FAST_CALL CrcUpdate(UInt32 v, const void *data, size_t size) { - return g_CrcUpdate(v, data, size, g_CrcTable); + return g_CrcUpdate(v, data, size, g_CrcTable); } UInt32 MY_FAST_CALL CrcCalc(const void *data, size_t size) { - return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; + return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; } void MY_FAST_CALL CrcGenerateTable() { - UInt32 i; - for (i = 0; i < 256; i++) - { - UInt32 r = i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); - g_CrcTable[i] = r; - } - #if CRC_NUM_TABLES == 1 - g_CrcUpdate = CrcUpdateT1; - #else - for (; i < 256 * CRC_NUM_TABLES; i++) - { - UInt32 r = g_CrcTable[i - 256]; - g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); - } - g_CrcUpdate = CrcUpdateT4; - #ifdef MY_CPU_X86_OR_AMD64 - if (!CPU_Is_InOrder()) - g_CrcUpdate = CrcUpdateT8; - #endif - #endif + UInt32 i; + for (i = 0; i < 256; i++) { + UInt32 r = i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); + g_CrcTable[i] = r; + } +#if CRC_NUM_TABLES == 1 + g_CrcUpdate = CrcUpdateT1; +#else + for (; i < 256 * CRC_NUM_TABLES; i++) { + UInt32 r = g_CrcTable[i - 256]; + g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); + } + g_CrcUpdate = CrcUpdateT4; +#ifdef MY_CPU_X86_OR_AMD64 + if (!CPU_Is_InOrder()) + g_CrcUpdate = CrcUpdateT8; +#endif +#endif } diff --git a/fex/7z_C/7zCrcOpt.c b/fex/7z_C/7zCrcOpt.c index 6c766a20..84d8b84f 100644 --- a/fex/7z_C/7zCrcOpt.c +++ b/fex/7z_C/7zCrcOpt.c @@ -9,26 +9,22 @@ UInt32 MY_FAST_CALL CrcUpdateT4(UInt32 v, const void *data, size_t size, const UInt32 *table) { - const Byte *p = (const Byte *)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - v ^= *(const UInt32 *)p; - v = - table[0x300 + (v & 0xFF)] ^ - table[0x200 + ((v >> 8) & 0xFF)] ^ - table[0x100 + ((v >> 16) & 0xFF)] ^ - table[0x000 + ((v >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; + const Byte *p = (const Byte *)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + for (; size >= 4; size -= 4, p += 4) { + v ^= *(const UInt32 *)p; + v = table[0x300 + (v & 0xFF)] ^ table[0x200 + ((v >> 8) & 0xFF)] ^ + table[0x100 + ((v >> 16) & 0xFF)] ^ table[0x000 + ((v >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; } UInt32 MY_FAST_CALL CrcUpdateT8(UInt32 v, const void *data, size_t size, const UInt32 *table) { - return CrcUpdateT4(v, data, size, table); + return CrcUpdateT4(v, data, size, table); } #endif diff --git a/fex/7z_C/7zDec.c b/fex/7z_C/7zDec.c index a79ed5bc..6993438a 100644 --- a/fex/7z_C/7zDec.c +++ b/fex/7z_C/7zDec.c @@ -10,461 +10,456 @@ #include "Bcj2.h" #include "Bra.h" #include "CpuArch.h" -#include "LzmaDec.h" #include "Lzma2Dec.h" +#include "LzmaDec.h" #ifdef _7ZIP_PPMD_SUPPPORT #include "Ppmd7.h" #endif #define k_Copy 0 #define k_LZMA2 0x21 -#define k_LZMA 0x30101 -#define k_BCJ 0x03030103 -#define k_PPC 0x03030205 -#define k_ARM 0x03030501 -#define k_ARMT 0x03030701 +#define k_LZMA 0x30101 +#define k_BCJ 0x03030103 +#define k_PPC 0x03030205 +#define k_ARM 0x03030501 +#define k_ARMT 0x03030701 #define k_SPARC 0x03030805 -#define k_BCJ2 0x0303011B +#define k_BCJ2 0x0303011B #ifdef _7ZIP_PPMD_SUPPPORT #define k_PPMD 0x30401 -typedef struct -{ - IByteIn p; - const Byte *cur; - const Byte *end; - const Byte *begin; - UInt64 processed; - Bool extra; - SRes res; - ILookInStream *inStream; +typedef struct { + IByteIn p; + const Byte *cur; + const Byte *end; + const Byte *begin; + UInt64 processed; + Bool extra; + SRes res; + ILookInStream *inStream; } CByteInToLook; static Byte ReadByte(void *pp) { - CByteInToLook *p = (CByteInToLook *)pp; - if (p->cur != p->end) - return *p->cur++; - if (p->res == SZ_OK) - { - size_t size = p->cur - p->begin; - p->processed += size; - p->res = p->inStream->Skip(p->inStream, size); - size = (1 << 25); - p->res = p->inStream->Look(p->inStream, (const void **)&p->begin, &size); - p->cur = p->begin; - p->end = p->begin + size; - if (size != 0) - return *p->cur++;; - } - p->extra = True; - return 0; + CByteInToLook *p = (CByteInToLook *)pp; + if (p->cur != p->end) + return *p->cur++; + if (p->res == SZ_OK) { + size_t size = p->cur - p->begin; + p->processed += size; + p->res = p->inStream->Skip(p->inStream, size); + size = (1 << 25); + p->res = p->inStream->Look(p->inStream, (const void **)&p->begin, &size); + p->cur = p->begin; + p->end = p->begin + size; + if (size != 0) + return *p->cur++; + ; + } + p->extra = True; + return 0; } static SRes SzDecodePpmd(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) + Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) { - CPpmd7 ppmd; - CByteInToLook s; - SRes res = SZ_OK; + CPpmd7 ppmd; + CByteInToLook s; + SRes res = SZ_OK; - s.p.Read = ReadByte; - s.inStream = inStream; - s.begin = s.end = s.cur = NULL; - s.extra = False; - s.res = SZ_OK; - s.processed = 0; + s.p.Read = ReadByte; + s.inStream = inStream; + s.begin = s.end = s.cur = NULL; + s.extra = False; + s.res = SZ_OK; + s.processed = 0; - if (coder->Props.size != 5) - return SZ_ERROR_UNSUPPORTED; + if (coder->Props.size != 5) + return SZ_ERROR_UNSUPPORTED; - { - unsigned order = coder->Props.data[0]; - UInt32 memSize = GetUi32(coder->Props.data + 1); - if (order < PPMD7_MIN_ORDER || - order > PPMD7_MAX_ORDER || - memSize < PPMD7_MIN_MEM_SIZE || - memSize > PPMD7_MAX_MEM_SIZE) - return SZ_ERROR_UNSUPPORTED; - Ppmd7_Construct(&ppmd); - if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) - return SZ_ERROR_MEM; - Ppmd7_Init(&ppmd, order); - } - { - CPpmd7z_RangeDec rc; - Ppmd7z_RangeDec_CreateVTable(&rc); - rc.Stream = &s.p; - if (!Ppmd7z_RangeDec_Init(&rc)) - res = SZ_ERROR_DATA; - else if (s.extra) - res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); - else - { - SizeT i; - for (i = 0; i < outSize; i++) - { - int sym = Ppmd7_DecodeSymbol(&ppmd, &rc.p); - if (s.extra || sym < 0) - break; - outBuffer[i] = (Byte)sym; - } - if (i != outSize) - res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); - else if (s.processed + (s.cur - s.begin) != inSize || !Ppmd7z_RangeDec_IsFinishedOK(&rc)) - res = SZ_ERROR_DATA; - } - } - Ppmd7_Free(&ppmd, allocMain); - return res; + { + unsigned order = coder->Props.data[0]; + UInt32 memSize = GetUi32(coder->Props.data + 1); + if (order < PPMD7_MIN_ORDER || order > PPMD7_MAX_ORDER || + memSize < PPMD7_MIN_MEM_SIZE || memSize > PPMD7_MAX_MEM_SIZE) + return SZ_ERROR_UNSUPPORTED; + Ppmd7_Construct(&ppmd); + if (!Ppmd7_Alloc(&ppmd, memSize, allocMain)) + return SZ_ERROR_MEM; + Ppmd7_Init(&ppmd, order); + } + { + CPpmd7z_RangeDec rc; + Ppmd7z_RangeDec_CreateVTable(&rc); + rc.Stream = &s.p; + if (!Ppmd7z_RangeDec_Init(&rc)) + res = SZ_ERROR_DATA; + else if (s.extra) + res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); + else { + SizeT i; + for (i = 0; i < outSize; i++) { + int sym = Ppmd7_DecodeSymbol(&ppmd, &rc.p); + if (s.extra || sym < 0) + break; + outBuffer[i] = (Byte)sym; + } + if (i != outSize) + res = (s.res != SZ_OK ? s.res : SZ_ERROR_DATA); + else if (s.processed + (s.cur - s.begin) != inSize || + !Ppmd7z_RangeDec_IsFinishedOK(&rc)) + res = SZ_ERROR_DATA; + } + } + Ppmd7_Free(&ppmd, allocMain); + return res; } #endif - static SRes SzDecodeLzma(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) + Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) { - CLzmaDec state; - SRes res = SZ_OK; + CLzmaDec state; + SRes res = SZ_OK; - LzmaDec_Construct(&state); - RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain)); - state.dic = outBuffer; - state.dicBufSize = outSize; - LzmaDec_Init(&state); + LzmaDec_Construct(&state); + RINOK(LzmaDec_AllocateProbs(&state, + coder->Props.data, + (unsigned)coder->Props.size, + allocMain)); + state.dic = outBuffer; + state.dicBufSize = outSize; + LzmaDec_Init(&state); - for (;;) - { - Byte *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; + for (;;) { + Byte *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; - { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos; - ELzmaStatus status; - res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos)) - { - if (state.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK && - status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } + { + SizeT inProcessed = (SizeT)lookahead, dicPos = state.dicPos; + ELzmaStatus status; + res = LzmaDec_DecodeToDic(&state, + outSize, + inBuf, + &inProcessed, + LZMA_FINISH_END, + &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.dicPos == state.dicBufSize || + (inProcessed == 0 && dicPos == state.dicPos)) { + if (state.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK && + status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } - LzmaDec_FreeProbs(&state, allocMain); - return res; + LzmaDec_FreeProbs(&state, allocMain); + return res; } static SRes SzDecodeLzma2(CSzCoderInfo *coder, UInt64 inSize, ILookInStream *inStream, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) + Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain) { - CLzma2Dec state; - SRes res = SZ_OK; + CLzma2Dec state; + SRes res = SZ_OK; - Lzma2Dec_Construct(&state); - if (coder->Props.size != 1) - return SZ_ERROR_DATA; - RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); - state.decoder.dic = outBuffer; - state.decoder.dicBufSize = outSize; - Lzma2Dec_Init(&state); + Lzma2Dec_Construct(&state); + if (coder->Props.size != 1) + return SZ_ERROR_DATA; + RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); + state.decoder.dic = outBuffer; + state.decoder.dicBufSize = outSize; + Lzma2Dec_Init(&state); - for (;;) - { - Byte *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; + for (;;) { + Byte *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; - { - SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos; - ELzmaStatus status; - res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos)) - { - if (state.decoder.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } + { + SizeT inProcessed = (SizeT)lookahead, dicPos = state.decoder.dicPos; + ELzmaStatus status; + res = Lzma2Dec_DecodeToDic(&state, + outSize, + inBuf, + &inProcessed, + LZMA_FINISH_END, + &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.decoder.dicPos == state.decoder.dicBufSize || + (inProcessed == 0 && dicPos == state.decoder.dicPos)) { + if (state.decoder.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } - Lzma2Dec_FreeProbs(&state, allocMain); - return res; + Lzma2Dec_FreeProbs(&state, allocMain); + return res; } static SRes SzDecodeCopy(UInt64 inSize, ILookInStream *inStream, Byte *outBuffer) { - while (inSize > 0) - { - void *inBuf; - size_t curSize = (1 << 18); - if (curSize > inSize) - curSize = (size_t)inSize; - RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); - if (curSize == 0) - return SZ_ERROR_INPUT_EOF; - memcpy(outBuffer, inBuf, curSize); - outBuffer += curSize; - inSize -= curSize; - RINOK(inStream->Skip((void *)inStream, curSize)); - } - return SZ_OK; + while (inSize > 0) { + void *inBuf; + size_t curSize = (1 << 18); + if (curSize > inSize) + curSize = (size_t)inSize; + RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); + if (curSize == 0) + return SZ_ERROR_INPUT_EOF; + memcpy(outBuffer, inBuf, curSize); + outBuffer += curSize; + inSize -= curSize; + RINOK(inStream->Skip((void *)inStream, curSize)); + } + return SZ_OK; } static Bool IS_MAIN_METHOD(UInt32 m) { - switch(m) - { - case k_Copy: - case k_LZMA: - case k_LZMA2: - #ifdef _7ZIP_PPMD_SUPPPORT - case k_PPMD: - #endif - return True; - } - return False; + switch (m) { + case k_Copy: + case k_LZMA: + case k_LZMA2: +#ifdef _7ZIP_PPMD_SUPPPORT + case k_PPMD: +#endif + return True; + } + return False; } static Bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) { - return - c->NumInStreams == 1 && - c->NumOutStreams == 1 && - c->MethodID <= (UInt32)0xFFFFFFFF && - IS_MAIN_METHOD((UInt32)c->MethodID); + return c->NumInStreams == 1 && c->NumOutStreams == 1 && c->MethodID <= (UInt32)0xFFFFFFFF && + IS_MAIN_METHOD((UInt32)c->MethodID); } #define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) static SRes CheckSupportedFolder(const CSzFolder *f) { - if (f->NumCoders < 1 || f->NumCoders > 4) - return SZ_ERROR_UNSUPPORTED; - if (!IS_SUPPORTED_CODER(&f->Coders[0])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumCoders == 1) - { - if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - if (f->NumCoders == 2) - { - CSzCoderInfo *c = &f->Coders[1]; - if (c->MethodID > (UInt32)0xFFFFFFFF || - c->NumInStreams != 1 || - c->NumOutStreams != 1 || - f->NumPackStreams != 1 || - f->PackStreams[0] != 0 || - f->NumBindPairs != 1 || - f->BindPairs[0].InIndex != 1 || - f->BindPairs[0].OutIndex != 0) - return SZ_ERROR_UNSUPPORTED; - switch ((UInt32)c->MethodID) - { - case k_BCJ: - case k_ARM: - break; - default: + if (f->NumCoders < 1 || f->NumCoders > 4) + return SZ_ERROR_UNSUPPORTED; + if (!IS_SUPPORTED_CODER(&f->Coders[0])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumCoders == 1) { + if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + if (f->NumCoders == 2) { + CSzCoderInfo *c = &f->Coders[1]; + if (c->MethodID > (UInt32)0xFFFFFFFF || c->NumInStreams != 1 || + c->NumOutStreams != 1 || f->NumPackStreams != 1 || f->PackStreams[0] != 0 || + f->NumBindPairs != 1 || f->BindPairs[0].InIndex != 1 || + f->BindPairs[0].OutIndex != 0) + return SZ_ERROR_UNSUPPORTED; + switch ((UInt32)c->MethodID) { + case k_BCJ: + case k_ARM: + break; + default: + return SZ_ERROR_UNSUPPORTED; + } + return SZ_OK; + } + if (f->NumCoders == 4) { + if (!IS_SUPPORTED_CODER(&f->Coders[1]) || !IS_SUPPORTED_CODER(&f->Coders[2]) || + !IS_BCJ2(&f->Coders[3])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumPackStreams != 4 || f->PackStreams[0] != 2 || f->PackStreams[1] != 6 || + f->PackStreams[2] != 1 || f->PackStreams[3] != 0 || f->NumBindPairs != 3 || + f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || + f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || + f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } return SZ_ERROR_UNSUPPORTED; - } - return SZ_OK; - } - if (f->NumCoders == 4) - { - if (!IS_SUPPORTED_CODER(&f->Coders[1]) || - !IS_SUPPORTED_CODER(&f->Coders[2]) || - !IS_BCJ2(&f->Coders[3])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumPackStreams != 4 || - f->PackStreams[0] != 2 || - f->PackStreams[1] != 6 || - f->PackStreams[2] != 1 || - f->PackStreams[3] != 0 || - f->NumBindPairs != 3 || - f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || - f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || - f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - return SZ_ERROR_UNSUPPORTED; } static UInt64 GetSum(const UInt64 *values, UInt32 index) { - UInt64 sum = 0; - UInt32 i; - for (i = 0; i < index; i++) - sum += values[i]; - return sum; + UInt64 sum = 0; + UInt32 i; + for (i = 0; i < index; i++) + sum += values[i]; + return sum; } -#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; +#define CASE_BRA_CONV(isa) \ + case k_##isa: \ + isa##_Convert(outBuffer, outSize, 0, 0); \ + break; static SRes SzFolder_Decode2(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, SizeT outSize, ISzAlloc *allocMain, - Byte *tempBuf[]) + ILookInStream *inStream, UInt64 startPos, Byte *outBuffer, + SizeT outSize, ISzAlloc *allocMain, Byte *tempBuf[]) { - UInt32 ci; - SizeT tempSizes[3] = { 0, 0, 0}; - SizeT tempSize3 = 0; - Byte *tempBuf3 = 0; + UInt32 ci; + SizeT tempSizes[3] = { 0, 0, 0 }; + SizeT tempSize3 = 0; + Byte *tempBuf3 = 0; - RINOK(CheckSupportedFolder(folder)); + RINOK(CheckSupportedFolder(folder)); - for (ci = 0; ci < folder->NumCoders; ci++) - { - CSzCoderInfo *coder = &folder->Coders[ci]; + for (ci = 0; ci < folder->NumCoders; ci++) { + CSzCoderInfo *coder = &folder->Coders[ci]; - if (IS_MAIN_METHOD((UInt32)coder->MethodID)) - { - UInt32 si = 0; - UInt64 offset; - UInt64 inSize; - Byte *outBufCur = outBuffer; - SizeT outSizeCur = outSize; - if (folder->NumCoders == 4) - { - UInt32 indices[] = { 3, 2, 0 }; - UInt64 unpackSize = folder->UnpackSizes[ci]; - si = indices[ci]; - if (ci < 2) - { - Byte *temp; - outSizeCur = (SizeT)unpackSize; - if (outSizeCur != unpackSize) - return SZ_ERROR_MEM; - temp = (Byte *)IAlloc_Alloc(allocMain, outSizeCur); - if (temp == 0 && outSizeCur != 0) - return SZ_ERROR_MEM; - outBufCur = tempBuf[1 - ci] = temp; - tempSizes[1 - ci] = outSizeCur; + if (IS_MAIN_METHOD((UInt32)coder->MethodID)) { + UInt32 si = 0; + UInt64 offset; + UInt64 inSize; + Byte *outBufCur = outBuffer; + SizeT outSizeCur = outSize; + if (folder->NumCoders == 4) { + UInt32 indices[] = { 3, 2, 0 }; + UInt64 unpackSize = folder->UnpackSizes[ci]; + si = indices[ci]; + if (ci < 2) { + Byte *temp; + outSizeCur = (SizeT)unpackSize; + if (outSizeCur != unpackSize) + return SZ_ERROR_MEM; + temp = (Byte *)IAlloc_Alloc(allocMain, outSizeCur); + if (temp == 0 && outSizeCur != 0) + return SZ_ERROR_MEM; + outBufCur = tempBuf[1 - ci] = temp; + tempSizes[1 - ci] = outSizeCur; + } else if (ci == 2) { + if (unpackSize > outSize) /* check it */ + return SZ_ERROR_PARAM; + tempBuf3 = outBufCur = + outBuffer + (outSize - (size_t)unpackSize); + tempSize3 = outSizeCur = (SizeT)unpackSize; + } else + return SZ_ERROR_UNSUPPORTED; + } + offset = GetSum(packSizes, si); + inSize = packSizes[si]; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + + if (coder->MethodID == k_Copy) { + if (inSize != outSizeCur) /* check it */ + return SZ_ERROR_DATA; + RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); + } else if (coder->MethodID == k_LZMA) { + RINOK(SzDecodeLzma(coder, + inSize, + inStream, + outBufCur, + outSizeCur, + allocMain)); + } else if (coder->MethodID == k_LZMA2) { + RINOK(SzDecodeLzma2(coder, + inSize, + inStream, + outBufCur, + outSizeCur, + allocMain)); + } else { +#ifdef _7ZIP_PPMD_SUPPPORT + RINOK(SzDecodePpmd(coder, + inSize, + inStream, + outBufCur, + outSizeCur, + allocMain)); +#else + return SZ_ERROR_UNSUPPORTED; +#endif + } + } else if (coder->MethodID == k_BCJ2) { + UInt64 offset = GetSum(packSizes, 1); + UInt64 s3Size = packSizes[1]; + SRes res; + if (ci != 3) + return SZ_ERROR_UNSUPPORTED; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + tempSizes[2] = (SizeT)s3Size; + if (tempSizes[2] != s3Size) + return SZ_ERROR_MEM; + tempBuf[2] = (Byte *)IAlloc_Alloc(allocMain, tempSizes[2]); + if (tempBuf[2] == 0 && tempSizes[2] != 0) + return SZ_ERROR_MEM; + res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); + RINOK(res) + + res = Bcj2_Decode(tempBuf3, + tempSize3, + tempBuf[0], + tempSizes[0], + tempBuf[1], + tempSizes[1], + tempBuf[2], + tempSizes[2], + outBuffer, + outSize); + RINOK(res) + } else { + if (ci != 1) + return SZ_ERROR_UNSUPPORTED; + switch (coder->MethodID) { + case k_BCJ: { + UInt32 state; + x86_Convert_Init(state); + x86_Convert(outBuffer, outSize, 0, &state, 0); + break; + } + CASE_BRA_CONV(ARM) + default: + return SZ_ERROR_UNSUPPORTED; + } + } } - else if (ci == 2) - { - if (unpackSize > outSize) /* check it */ - return SZ_ERROR_PARAM; - tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); - tempSize3 = outSizeCur = (SizeT)unpackSize; - } - else - return SZ_ERROR_UNSUPPORTED; - } - offset = GetSum(packSizes, si); - inSize = packSizes[si]; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - - if (coder->MethodID == k_Copy) - { - if (inSize != outSizeCur) /* check it */ - return SZ_ERROR_DATA; - RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); - } - else if (coder->MethodID == k_LZMA) - { - RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else if (coder->MethodID == k_LZMA2) - { - RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else - { - #ifdef _7ZIP_PPMD_SUPPPORT - RINOK(SzDecodePpmd(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - #else - return SZ_ERROR_UNSUPPORTED; - #endif - } - } - else if (coder->MethodID == k_BCJ2) - { - UInt64 offset = GetSum(packSizes, 1); - UInt64 s3Size = packSizes[1]; - SRes res; - if (ci != 3) - return SZ_ERROR_UNSUPPORTED; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - tempSizes[2] = (SizeT)s3Size; - if (tempSizes[2] != s3Size) - return SZ_ERROR_MEM; - tempBuf[2] = (Byte *)IAlloc_Alloc(allocMain, tempSizes[2]); - if (tempBuf[2] == 0 && tempSizes[2] != 0) - return SZ_ERROR_MEM; - res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); - RINOK(res) - - res = Bcj2_Decode( - tempBuf3, tempSize3, - tempBuf[0], tempSizes[0], - tempBuf[1], tempSizes[1], - tempBuf[2], tempSizes[2], - outBuffer, outSize); - RINOK(res) - } - else - { - if (ci != 1) - return SZ_ERROR_UNSUPPORTED; - switch(coder->MethodID) - { - case k_BCJ: - { - UInt32 state; - x86_Convert_Init(state); - x86_Convert(outBuffer, outSize, 0, &state, 0); - break; - } - CASE_BRA_CONV(ARM) - default: - return SZ_ERROR_UNSUPPORTED; - } - } - } - return SZ_OK; + return SZ_OK; } -SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, - ILookInStream *inStream, UInt64 startPos, - Byte *outBuffer, size_t outSize, ISzAlloc *allocMain) +SRes SzFolder_Decode(const CSzFolder *folder, const UInt64 *packSizes, ILookInStream *inStream, + UInt64 startPos, Byte *outBuffer, size_t outSize, ISzAlloc *allocMain) { - Byte *tempBuf[3] = { 0, 0, 0}; - int i; - SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, - outBuffer, (SizeT)outSize, allocMain, tempBuf); - for (i = 0; i < 3; i++) - IAlloc_Free(allocMain, tempBuf[i]); - return res; + Byte *tempBuf[3] = { 0, 0, 0 }; + int i; + SRes res = SzFolder_Decode2(folder, + packSizes, + inStream, + startPos, + outBuffer, + (SizeT)outSize, + allocMain, + tempBuf); + for (i = 0; i < 3; i++) + IAlloc_Free(allocMain, tempBuf[i]); + return res; } diff --git a/fex/7z_C/7zIn.c b/fex/7z_C/7zIn.c index ec93a43f..9619fcc9 100644 --- a/fex/7z_C/7zIn.c +++ b/fex/7z_C/7zIn.c @@ -7,151 +7,153 @@ #include "7zCrc.h" #include "CpuArch.h" -Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; +Byte k7zSignature[k7zSignatureSize] = { '7', 'z', 0xBC, 0xAF, 0x27, 0x1C }; -#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } +#define RINOM(x) \ + { \ + if ((x) == 0) \ + return SZ_ERROR_MEM; \ + } #define NUM_FOLDER_CODERS_MAX 32 #define NUM_CODER_STREAMS_MAX 32 void SzCoderInfo_Init(CSzCoderInfo *p) { - Buf_Init(&p->Props); + Buf_Init(&p->Props); } void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc) { - Buf_Free(&p->Props, alloc); - SzCoderInfo_Init(p); + Buf_Free(&p->Props, alloc); + SzCoderInfo_Init(p); } void SzFolder_Init(CSzFolder *p) { - p->Coders = 0; - p->BindPairs = 0; - p->PackStreams = 0; - p->UnpackSizes = 0; - p->NumCoders = 0; - p->NumBindPairs = 0; - p->NumPackStreams = 0; - p->UnpackCRCDefined = 0; - p->UnpackCRC = 0; - p->NumUnpackStreams = 0; + p->Coders = 0; + p->BindPairs = 0; + p->PackStreams = 0; + p->UnpackSizes = 0; + p->NumCoders = 0; + p->NumBindPairs = 0; + p->NumPackStreams = 0; + p->UnpackCRCDefined = 0; + p->UnpackCRC = 0; + p->NumUnpackStreams = 0; } void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) { - UInt32 i; - if (p->Coders) - for (i = 0; i < p->NumCoders; i++) - SzCoderInfo_Free(&p->Coders[i], alloc); - IAlloc_Free(alloc, p->Coders); - IAlloc_Free(alloc, p->BindPairs); - IAlloc_Free(alloc, p->PackStreams); - IAlloc_Free(alloc, p->UnpackSizes); - SzFolder_Init(p); + UInt32 i; + if (p->Coders) + for (i = 0; i < p->NumCoders; i++) + SzCoderInfo_Free(&p->Coders[i], alloc); + IAlloc_Free(alloc, p->Coders); + IAlloc_Free(alloc, p->BindPairs); + IAlloc_Free(alloc, p->PackStreams); + IAlloc_Free(alloc, p->UnpackSizes); + SzFolder_Init(p); } UInt32 SzFolder_GetNumOutStreams(CSzFolder *p) { - UInt32 result = 0; - UInt32 i; - for (i = 0; i < p->NumCoders; i++) - result += p->Coders[i].NumOutStreams; - return result; + UInt32 result = 0; + UInt32 i; + for (i = 0; i < p->NumCoders; i++) + result += p->Coders[i].NumOutStreams; + return result; } int SzFolder_FindBindPairForInStream(CSzFolder *p, UInt32 inStreamIndex) { - UInt32 i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].InIndex == inStreamIndex) - return i; - return -1; + UInt32 i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].InIndex == inStreamIndex) + return i; + return -1; } - int SzFolder_FindBindPairForOutStream(CSzFolder *p, UInt32 outStreamIndex) { - UInt32 i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].OutIndex == outStreamIndex) - return i; - return -1; + UInt32 i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].OutIndex == outStreamIndex) + return i; + return -1; } UInt64 SzFolder_GetUnpackSize(CSzFolder *p) { - int i = (int)SzFolder_GetNumOutStreams(p); - if (i == 0) - return 0; - for (i--; i >= 0; i--) - if (SzFolder_FindBindPairForOutStream(p, i) < 0) - return p->UnpackSizes[i]; - /* throw 1; */ - return 0; + int i = (int)SzFolder_GetNumOutStreams(p); + if (i == 0) + return 0; + for (i--; i >= 0; i--) + if (SzFolder_FindBindPairForOutStream(p, i) < 0) + return p->UnpackSizes[i]; + /* throw 1; */ + return 0; } void SzFile_Init(CSzFileItem *p) { - p->HasStream = 1; - p->IsDir = 0; - p->IsAnti = 0; - p->CrcDefined = 0; - p->MTimeDefined = 0; + p->HasStream = 1; + p->IsDir = 0; + p->IsAnti = 0; + p->CrcDefined = 0; + p->MTimeDefined = 0; } void SzAr_Init(CSzAr *p) { - p->PackSizes = 0; - p->PackCRCsDefined = 0; - p->PackCRCs = 0; - p->Folders = 0; - p->Files = 0; - p->NumPackStreams = 0; - p->NumFolders = 0; - p->NumFiles = 0; + p->PackSizes = 0; + p->PackCRCsDefined = 0; + p->PackCRCs = 0; + p->Folders = 0; + p->Files = 0; + p->NumPackStreams = 0; + p->NumFolders = 0; + p->NumFiles = 0; } void SzAr_Free(CSzAr *p, ISzAlloc *alloc) { - UInt32 i; - if (p->Folders) - for (i = 0; i < p->NumFolders; i++) - SzFolder_Free(&p->Folders[i], alloc); + UInt32 i; + if (p->Folders) + for (i = 0; i < p->NumFolders; i++) + SzFolder_Free(&p->Folders[i], alloc); - IAlloc_Free(alloc, p->PackSizes); - IAlloc_Free(alloc, p->PackCRCsDefined); - IAlloc_Free(alloc, p->PackCRCs); - IAlloc_Free(alloc, p->Folders); - IAlloc_Free(alloc, p->Files); - SzAr_Init(p); + IAlloc_Free(alloc, p->PackSizes); + IAlloc_Free(alloc, p->PackCRCsDefined); + IAlloc_Free(alloc, p->PackCRCs); + IAlloc_Free(alloc, p->Folders); + IAlloc_Free(alloc, p->Files); + SzAr_Init(p); } - void SzArEx_Init(CSzArEx *p) { - SzAr_Init(&p->db); - p->FolderStartPackStreamIndex = 0; - p->PackStreamStartPositions = 0; - p->FolderStartFileIndex = 0; - p->FileIndexToFolderIndexMap = 0; - p->FileNameOffsets = 0; - Buf_Init(&p->FileNames); + SzAr_Init(&p->db); + p->FolderStartPackStreamIndex = 0; + p->PackStreamStartPositions = 0; + p->FolderStartFileIndex = 0; + p->FileIndexToFolderIndexMap = 0; + p->FileNameOffsets = 0; + Buf_Init(&p->FileNames); } void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) { - IAlloc_Free(alloc, p->FolderStartPackStreamIndex); - IAlloc_Free(alloc, p->PackStreamStartPositions); - IAlloc_Free(alloc, p->FolderStartFileIndex); - IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); + IAlloc_Free(alloc, p->FolderStartPackStreamIndex); + IAlloc_Free(alloc, p->PackStreamStartPositions); + IAlloc_Free(alloc, p->FolderStartFileIndex); + IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); - IAlloc_Free(alloc, p->FileNameOffsets); - Buf_Free(&p->FileNames, alloc); + IAlloc_Free(alloc, p->FileNameOffsets); + Buf_Free(&p->FileNames, alloc); - SzAr_Free(&p->db, alloc); - SzArEx_Init(p); + SzAr_Free(&p->db, alloc); + SzArEx_Init(p); } /* @@ -173,97 +175,93 @@ UInt64 GetFilePackSize(int fileIndex) const } */ -#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \ - if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; } +#define MY_ALLOC(T, p, size, alloc) \ + { \ + if ((size) == 0) \ + p = 0; \ + else if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) \ + return SZ_ERROR_MEM; \ + } static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) { - UInt32 startPos = 0; - UInt64 startPosSize = 0; - UInt32 i; - UInt32 folderIndex = 0; - UInt32 indexInFolder = 0; - MY_ALLOC(UInt32, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); - for (i = 0; i < p->db.NumFolders; i++) - { - p->FolderStartPackStreamIndex[i] = startPos; - startPos += p->db.Folders[i].NumPackStreams; - } + UInt32 startPos = 0; + UInt64 startPosSize = 0; + UInt32 i; + UInt32 folderIndex = 0; + UInt32 indexInFolder = 0; + MY_ALLOC(UInt32, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); + for (i = 0; i < p->db.NumFolders; i++) { + p->FolderStartPackStreamIndex[i] = startPos; + startPos += p->db.Folders[i].NumPackStreams; + } - MY_ALLOC(UInt64, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); + MY_ALLOC(UInt64, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); - for (i = 0; i < p->db.NumPackStreams; i++) - { - p->PackStreamStartPositions[i] = startPosSize; - startPosSize += p->db.PackSizes[i]; - } + for (i = 0; i < p->db.NumPackStreams; i++) { + p->PackStreamStartPositions[i] = startPosSize; + startPosSize += p->db.PackSizes[i]; + } - MY_ALLOC(UInt32, p->FolderStartFileIndex, p->db.NumFolders, alloc); - MY_ALLOC(UInt32, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); + MY_ALLOC(UInt32, p->FolderStartFileIndex, p->db.NumFolders, alloc); + MY_ALLOC(UInt32, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); - for (i = 0; i < p->db.NumFiles; i++) - { - CSzFileItem *file = p->db.Files + i; - int emptyStream = !file->HasStream; - if (emptyStream && indexInFolder == 0) - { - p->FileIndexToFolderIndexMap[i] = (UInt32)-1; - continue; - } - if (indexInFolder == 0) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: Loop for skipping empty folders - */ - for (;;) - { - if (folderIndex >= p->db.NumFolders) - return SZ_ERROR_ARCHIVE; - p->FolderStartFileIndex[folderIndex] = i; - if (p->db.Folders[folderIndex].NumUnpackStreams != 0) - break; - folderIndex++; - } - } - p->FileIndexToFolderIndexMap[i] = folderIndex; - if (emptyStream) - continue; - indexInFolder++; - if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) - { - folderIndex++; - indexInFolder = 0; - } - } - return SZ_OK; + for (i = 0; i < p->db.NumFiles; i++) { + CSzFileItem *file = p->db.Files + i; + int emptyStream = !file->HasStream; + if (emptyStream && indexInFolder == 0) { + p->FileIndexToFolderIndexMap[i] = (UInt32)-1; + continue; + } + if (indexInFolder == 0) { + /* + v3.13 incorrectly worked with empty folders + v4.07: Loop for skipping empty folders + */ + for (;;) { + if (folderIndex >= p->db.NumFolders) + return SZ_ERROR_ARCHIVE; + p->FolderStartFileIndex[folderIndex] = i; + if (p->db.Folders[folderIndex].NumUnpackStreams != 0) + break; + folderIndex++; + } + } + p->FileIndexToFolderIndexMap[i] = folderIndex; + if (emptyStream) + continue; + indexInFolder++; + if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) { + folderIndex++; + indexInFolder = 0; + } + } + return SZ_OK; } - UInt64 SzArEx_GetFolderStreamPos(const CSzArEx *p, UInt32 folderIndex, UInt32 indexInFolder) { - return p->dataPos + - p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; + return p->dataPos + + p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + + indexInFolder]; } int SzArEx_GetFolderFullPackSize(const CSzArEx *p, UInt32 folderIndex, UInt64 *resSize) { - UInt32 packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; - CSzFolder *folder = p->db.Folders + folderIndex; - UInt64 size = 0; - UInt32 i; - for (i = 0; i < folder->NumPackStreams; i++) - { - UInt64 t = size + p->db.PackSizes[packStreamIndex + i]; - if (t < size) /* check it */ - return SZ_ERROR_FAIL; - size = t; - } - *resSize = size; - return SZ_OK; + UInt32 packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; + CSzFolder *folder = p->db.Folders + folderIndex; + UInt64 size = 0; + UInt32 i; + for (i = 0; i < folder->NumPackStreams; i++) { + UInt64 t = size + p->db.PackSizes[packStreamIndex + i]; + if (t < size) /* check it */ + return SZ_ERROR_FAIL; + size = t; + } + *resSize = size; + return SZ_OK; } - /* SRes SzReadTime(const CObjectVector &dataVector, CObjectVector &files, UInt64 type) @@ -300,1103 +298,1015 @@ SRes SzReadTime(const CObjectVector &dataVector, static int TestSignatureCandidate(Byte *testBytes) { - size_t i; - for (i = 0; i < k7zSignatureSize; i++) - if (testBytes[i] != k7zSignature[i]) - return 0; - return 1; + size_t i; + for (i = 0; i < k7zSignatureSize; i++) + if (testBytes[i] != k7zSignature[i]) + return 0; + return 1; } -typedef struct _CSzState -{ - Byte *Data; - size_t Size; -}CSzData; +typedef struct _CSzState { + Byte *Data; + size_t Size; +} CSzData; static SRes SzReadByte(CSzData *sd, Byte *b) { - if (sd->Size == 0) - return SZ_ERROR_ARCHIVE; - sd->Size--; - *b = *sd->Data++; - return SZ_OK; + if (sd->Size == 0) + return SZ_ERROR_ARCHIVE; + sd->Size--; + *b = *sd->Data++; + return SZ_OK; } static SRes SzReadBytes(CSzData *sd, Byte *data, size_t size) { - size_t i; - for (i = 0; i < size; i++) - { - RINOK(SzReadByte(sd, data + i)); - } - return SZ_OK; + size_t i; + for (i = 0; i < size; i++) { + RINOK(SzReadByte(sd, data + i)); + } + return SZ_OK; } static SRes SzReadUInt32(CSzData *sd, UInt32 *value) { - int i; - *value = 0; - for (i = 0; i < 4; i++) - { - Byte b; - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt32)(b) << (8 * i)); - } - return SZ_OK; + int i; + *value = 0; + for (i = 0; i < 4; i++) { + Byte b; + RINOK(SzReadByte(sd, &b)); + *value |= ((UInt32)(b) << (8 * i)); + } + return SZ_OK; } static SRes SzReadNumber(CSzData *sd, UInt64 *value) { - Byte firstByte; - Byte mask = 0x80; - int i; - RINOK(SzReadByte(sd, &firstByte)); - *value = 0; - for (i = 0; i < 8; i++) - { - Byte b; - if ((firstByte & mask) == 0) - { - UInt64 highPart = firstByte & (mask - 1); - *value += (highPart << (8 * i)); - return SZ_OK; - } - RINOK(SzReadByte(sd, &b)); - *value |= ((UInt64)b << (8 * i)); - mask >>= 1; - } - return SZ_OK; + Byte firstByte; + Byte mask = 0x80; + int i; + RINOK(SzReadByte(sd, &firstByte)); + *value = 0; + for (i = 0; i < 8; i++) { + Byte b; + if ((firstByte & mask) == 0) { + UInt64 highPart = firstByte & (mask - 1); + *value += (highPart << (8 * i)); + return SZ_OK; + } + RINOK(SzReadByte(sd, &b)); + *value |= ((UInt64)b << (8 * i)); + mask >>= 1; + } + return SZ_OK; } static SRes SzReadNumber32(CSzData *sd, UInt32 *value) { - UInt64 value64; - RINOK(SzReadNumber(sd, &value64)); - if (value64 >= 0x80000000) - return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2))) - return SZ_ERROR_UNSUPPORTED; - *value = (UInt32)value64; - return SZ_OK; + UInt64 value64; + RINOK(SzReadNumber(sd, &value64)); + if (value64 >= 0x80000000) + return SZ_ERROR_UNSUPPORTED; + if (value64 >= ((UInt64)(1) << ((sizeof(size_t) - 1) * 8 + 2))) + return SZ_ERROR_UNSUPPORTED; + *value = (UInt32)value64; + return SZ_OK; } static SRes SzReadID(CSzData *sd, UInt64 *value) { - return SzReadNumber(sd, value); + return SzReadNumber(sd, value); } static SRes SzSkeepDataSize(CSzData *sd, UInt64 size) { - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - sd->Size -= (size_t)size; - sd->Data += (size_t)size; - return SZ_OK; + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + sd->Size -= (size_t)size; + sd->Data += (size_t)size; + return SZ_OK; } static SRes SzSkeepData(CSzData *sd) { - UInt64 size; - RINOK(SzReadNumber(sd, &size)); - return SzSkeepDataSize(sd, size); + UInt64 size; + RINOK(SzReadNumber(sd, &size)); + return SzSkeepDataSize(sd, size); } static SRes SzReadArchiveProperties(CSzData *sd) { - for (;;) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - SzSkeepData(sd); - } - return SZ_OK; + for (;;) { + UInt64 type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + SzSkeepData(sd); + } + return SZ_OK; } static SRes SzWaitAttribute(CSzData *sd, UInt64 attribute) { - for (;;) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == attribute) - return SZ_OK; - if (type == k7zIdEnd) - return SZ_ERROR_ARCHIVE; - RINOK(SzSkeepData(sd)); - } + for (;;) { + UInt64 type; + RINOK(SzReadID(sd, &type)); + if (type == attribute) + return SZ_OK; + if (type == k7zIdEnd) + return SZ_ERROR_ARCHIVE; + RINOK(SzSkeepData(sd)); + } } static SRes SzReadBoolVector(CSzData *sd, size_t numItems, Byte **v, ISzAlloc *alloc) { - Byte b = 0; - Byte mask = 0; - size_t i; - MY_ALLOC(Byte, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - { - if (mask == 0) - { - RINOK(SzReadByte(sd, &b)); - mask = 0x80; - } - (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0); - mask >>= 1; - } - return SZ_OK; + Byte b = 0; + Byte mask = 0; + size_t i; + MY_ALLOC(Byte, *v, numItems, alloc); + for (i = 0; i < numItems; i++) { + if (mask == 0) { + RINOK(SzReadByte(sd, &b)); + mask = 0x80; + } + (*v)[i] = (Byte)(((b & mask) != 0) ? 1 : 0); + mask >>= 1; + } + return SZ_OK; } static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, Byte **v, ISzAlloc *alloc) { - Byte allAreDefined; - size_t i; - RINOK(SzReadByte(sd, &allAreDefined)); - if (allAreDefined == 0) - return SzReadBoolVector(sd, numItems, v, alloc); - MY_ALLOC(Byte, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - (*v)[i] = 1; - return SZ_OK; + Byte allAreDefined; + size_t i; + RINOK(SzReadByte(sd, &allAreDefined)); + if (allAreDefined == 0) + return SzReadBoolVector(sd, numItems, v, alloc); + MY_ALLOC(Byte, *v, numItems, alloc); + for (i = 0; i < numItems; i++) + (*v)[i] = 1; + return SZ_OK; } -static SRes SzReadHashDigests( - CSzData *sd, - size_t numItems, - Byte **digestsDefined, - UInt32 **digests, - ISzAlloc *alloc) +static SRes SzReadHashDigests(CSzData *sd, size_t numItems, Byte **digestsDefined, UInt32 **digests, + ISzAlloc *alloc) { - size_t i; - RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); - MY_ALLOC(UInt32, *digests, numItems, alloc); - for (i = 0; i < numItems; i++) - if ((*digestsDefined)[i]) - { - RINOK(SzReadUInt32(sd, (*digests) + i)); - } - return SZ_OK; + size_t i; + RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); + MY_ALLOC(UInt32, *digests, numItems, alloc); + for (i = 0; i < numItems; i++) + if ((*digestsDefined)[i]) { + RINOK(SzReadUInt32(sd, (*digests) + i)); + } + return SZ_OK; } -static SRes SzReadPackInfo( - CSzData *sd, - UInt64 *dataOffset, - UInt32 *numPackStreams, - UInt64 **packSizes, - Byte **packCRCsDefined, - UInt32 **packCRCs, - ISzAlloc *alloc) +static SRes SzReadPackInfo(CSzData *sd, UInt64 *dataOffset, UInt32 *numPackStreams, + UInt64 **packSizes, Byte **packCRCsDefined, UInt32 **packCRCs, + ISzAlloc *alloc) { - UInt32 i; - RINOK(SzReadNumber(sd, dataOffset)); - RINOK(SzReadNumber32(sd, numPackStreams)); + UInt32 i; + RINOK(SzReadNumber(sd, dataOffset)); + RINOK(SzReadNumber32(sd, numPackStreams)); - RINOK(SzWaitAttribute(sd, k7zIdSize)); + RINOK(SzWaitAttribute(sd, k7zIdSize)); - MY_ALLOC(UInt64, *packSizes, (size_t)*numPackStreams, alloc); + MY_ALLOC(UInt64, *packSizes, (size_t)*numPackStreams, alloc); - for (i = 0; i < *numPackStreams; i++) - { - RINOK(SzReadNumber(sd, (*packSizes) + i)); - } + for (i = 0; i < *numPackStreams; i++) { + RINOK(SzReadNumber(sd, (*packSizes) + i)); + } - for (;;) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - if (type == k7zIdCRC) - { - RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, alloc)); - continue; - } - RINOK(SzSkeepData(sd)); - } - if (*packCRCsDefined == 0) - { - MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, alloc); - MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, alloc); - for (i = 0; i < *numPackStreams; i++) - { - (*packCRCsDefined)[i] = 0; - (*packCRCs)[i] = 0; - } - } - return SZ_OK; + for (;;) { + UInt64 type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + if (type == k7zIdCRC) { + RINOK(SzReadHashDigests(sd, + (size_t)*numPackStreams, + packCRCsDefined, + packCRCs, + alloc)); + continue; + } + RINOK(SzSkeepData(sd)); + } + if (*packCRCsDefined == 0) { + MY_ALLOC(Byte, *packCRCsDefined, (size_t)*numPackStreams, alloc); + MY_ALLOC(UInt32, *packCRCs, (size_t)*numPackStreams, alloc); + for (i = 0; i < *numPackStreams; i++) { + (*packCRCsDefined)[i] = 0; + (*packCRCs)[i] = 0; + } + } + return SZ_OK; } static SRes SzReadSwitch(CSzData *sd) { - Byte external; - RINOK(SzReadByte(sd, &external)); - return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; + Byte external; + RINOK(SzReadByte(sd, &external)); + return (external == 0) ? SZ_OK : SZ_ERROR_UNSUPPORTED; } static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) { - UInt32 numCoders, numBindPairs, numPackStreams, i; - UInt32 numInStreams = 0, numOutStreams = 0; - - RINOK(SzReadNumber32(sd, &numCoders)); - if (numCoders > NUM_FOLDER_CODERS_MAX) - return SZ_ERROR_UNSUPPORTED; - folder->NumCoders = numCoders; - - MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); + UInt32 numCoders, numBindPairs, numPackStreams, i; + UInt32 numInStreams = 0, numOutStreams = 0; - for (i = 0; i < numCoders; i++) - SzCoderInfo_Init(folder->Coders + i); + RINOK(SzReadNumber32(sd, &numCoders)); + if (numCoders > NUM_FOLDER_CODERS_MAX) + return SZ_ERROR_UNSUPPORTED; + folder->NumCoders = numCoders; - for (i = 0; i < numCoders; i++) - { - Byte mainByte; - CSzCoderInfo *coder = folder->Coders + i; - { - unsigned idSize, j; - Byte longID[15]; - RINOK(SzReadByte(sd, &mainByte)); - idSize = (unsigned)(mainByte & 0xF); - RINOK(SzReadBytes(sd, longID, idSize)); - if (idSize > sizeof(coder->MethodID)) - return SZ_ERROR_UNSUPPORTED; - coder->MethodID = 0; - for (j = 0; j < idSize; j++) - coder->MethodID |= (UInt64)longID[idSize - 1 - j] << (8 * j); + MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); - if ((mainByte & 0x10) != 0) - { - RINOK(SzReadNumber32(sd, &coder->NumInStreams)); - RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); - if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || - coder->NumOutStreams > NUM_CODER_STREAMS_MAX) - return SZ_ERROR_UNSUPPORTED; - } - else - { - coder->NumInStreams = 1; - coder->NumOutStreams = 1; - } - if ((mainByte & 0x20) != 0) - { - UInt64 propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) - return SZ_ERROR_MEM; - RINOK(SzReadBytes(sd, coder->Props.data, (size_t)propertiesSize)); - } - } - while ((mainByte & 0x80) != 0) - { - RINOK(SzReadByte(sd, &mainByte)); - RINOK(SzSkeepDataSize(sd, (mainByte & 0xF))); - if ((mainByte & 0x10) != 0) - { - UInt32 n; - RINOK(SzReadNumber32(sd, &n)); - RINOK(SzReadNumber32(sd, &n)); - } - if ((mainByte & 0x20) != 0) - { - UInt64 propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - RINOK(SzSkeepDataSize(sd, propertiesSize)); - } - } - numInStreams += coder->NumInStreams; - numOutStreams += coder->NumOutStreams; - } + for (i = 0; i < numCoders; i++) + SzCoderInfo_Init(folder->Coders + i); - if (numOutStreams == 0) - return SZ_ERROR_UNSUPPORTED; + for (i = 0; i < numCoders; i++) { + Byte mainByte; + CSzCoderInfo *coder = folder->Coders + i; + { + unsigned idSize, j; + Byte longID[15]; + RINOK(SzReadByte(sd, &mainByte)); + idSize = (unsigned)(mainByte & 0xF); + RINOK(SzReadBytes(sd, longID, idSize)); + if (idSize > sizeof(coder->MethodID)) + return SZ_ERROR_UNSUPPORTED; + coder->MethodID = 0; + for (j = 0; j < idSize; j++) + coder->MethodID |= (UInt64)longID[idSize - 1 - j] << (8 * j); - folder->NumBindPairs = numBindPairs = numOutStreams - 1; - MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); - - for (i = 0; i < numBindPairs; i++) - { - CSzBindPair *bp = folder->BindPairs + i; - RINOK(SzReadNumber32(sd, &bp->InIndex)); - RINOK(SzReadNumber32(sd, &bp->OutIndex)); - } - - if (numInStreams < numBindPairs) - return SZ_ERROR_UNSUPPORTED; - - folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; - MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackStreams, alloc); - - if (numPackStreams == 1) - { - for (i = 0; i < numInStreams ; i++) - if (SzFolder_FindBindPairForInStream(folder, i) < 0) - break; - if (i == numInStreams) - return SZ_ERROR_UNSUPPORTED; - folder->PackStreams[0] = i; - } - else - for (i = 0; i < numPackStreams; i++) - { - RINOK(SzReadNumber32(sd, folder->PackStreams + i)); - } - return SZ_OK; -} - -static SRes SzReadUnpackInfo( - CSzData *sd, - UInt32 *numFolders, - CSzFolder **folders, /* for alloc */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - UInt32 i; - RINOK(SzWaitAttribute(sd, k7zIdFolder)); - RINOK(SzReadNumber32(sd, numFolders)); - { - RINOK(SzReadSwitch(sd)); - - MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); - - for (i = 0; i < *numFolders; i++) - SzFolder_Init((*folders) + i); - - for (i = 0; i < *numFolders; i++) - { - RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); - } - } - - RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); - - for (i = 0; i < *numFolders; i++) - { - UInt32 j; - CSzFolder *folder = (*folders) + i; - UInt32 numOutStreams = SzFolder_GetNumOutStreams(folder); - - MY_ALLOC(UInt64, folder->UnpackSizes, (size_t)numOutStreams, alloc); - - for (j = 0; j < numOutStreams; j++) - { - RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); - } - } - - for (;;) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - SRes res; - Byte *crcsDefined = 0; - UInt32 *crcs = 0; - res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < *numFolders; i++) - { - CSzFolder *folder = (*folders) + i; - folder->UnpackCRCDefined = crcsDefined[i]; - folder->UnpackCRC = crcs[i]; + if ((mainByte & 0x10) != 0) { + RINOK(SzReadNumber32(sd, &coder->NumInStreams)); + RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); + if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || + coder->NumOutStreams > NUM_CODER_STREAMS_MAX) + return SZ_ERROR_UNSUPPORTED; + } else { + coder->NumInStreams = 1; + coder->NumOutStreams = 1; + } + if ((mainByte & 0x20) != 0) { + UInt64 propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) + return SZ_ERROR_MEM; + RINOK(SzReadBytes(sd, coder->Props.data, (size_t)propertiesSize)); + } + } + while ((mainByte & 0x80) != 0) { + RINOK(SzReadByte(sd, &mainByte)); + RINOK(SzSkeepDataSize(sd, (mainByte & 0xF))); + if ((mainByte & 0x10) != 0) { + UInt32 n; + RINOK(SzReadNumber32(sd, &n)); + RINOK(SzReadNumber32(sd, &n)); + } + if ((mainByte & 0x20) != 0) { + UInt64 propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + RINOK(SzSkeepDataSize(sd, propertiesSize)); + } + } + numInStreams += coder->NumInStreams; + numOutStreams += coder->NumOutStreams; } - } - IAlloc_Free(allocTemp, crcs); - IAlloc_Free(allocTemp, crcsDefined); - RINOK(res); - continue; - } - RINOK(SzSkeepData(sd)); - } -} -static SRes SzReadSubStreamsInfo( - CSzData *sd, - UInt32 numFolders, - CSzFolder *folders, - UInt32 *numUnpackStreams, - UInt64 **unpackSizes, - Byte **digestsDefined, - UInt32 **digests, - ISzAlloc *allocTemp) -{ - UInt64 type = 0; - UInt32 i; - UInt32 si = 0; - UInt32 numDigests = 0; + if (numOutStreams == 0) + return SZ_ERROR_UNSUPPORTED; - for (i = 0; i < numFolders; i++) - folders[i].NumUnpackStreams = 1; - *numUnpackStreams = numFolders; + folder->NumBindPairs = numBindPairs = numOutStreams - 1; + MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); - for (;;) - { - RINOK(SzReadID(sd, &type)); - if (type == k7zIdNumUnpackStream) - { - *numUnpackStreams = 0; - for (i = 0; i < numFolders; i++) - { - UInt32 numStreams; - RINOK(SzReadNumber32(sd, &numStreams)); - folders[i].NumUnpackStreams = numStreams; - *numUnpackStreams += numStreams; - } - continue; - } - if (type == k7zIdCRC || type == k7zIdSize) - break; - if (type == k7zIdEnd) - break; - RINOK(SzSkeepData(sd)); - } - - if (*numUnpackStreams == 0) - { - *unpackSizes = 0; - *digestsDefined = 0; - *digests = 0; - } - else - { - *unpackSizes = (UInt64 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt64)); - RINOM(*unpackSizes); - *digestsDefined = (Byte *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(Byte)); - RINOM(*digestsDefined); - *digests = (UInt32 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt32)); - RINOM(*digests); - } - - for (i = 0; i < numFolders; i++) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: we check that folder is empty - */ - UInt64 sum = 0; - UInt32 j; - UInt32 numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams == 0) - continue; - if (type == k7zIdSize) - for (j = 1; j < numSubstreams; j++) - { - UInt64 size; - RINOK(SzReadNumber(sd, &size)); - (*unpackSizes)[si++] = size; - sum += size; - } - (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; - } - if (type == k7zIdSize) - { - RINOK(SzReadID(sd, &type)); - } - - for (i = 0; i < *numUnpackStreams; i++) - { - (*digestsDefined)[i] = 0; - (*digests)[i] = 0; - } - - - for (i = 0; i < numFolders; i++) - { - UInt32 numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) - numDigests += numSubstreams; - } - - - si = 0; - for (;;) - { - if (type == k7zIdCRC) - { - int digestIndex = 0; - Byte *digestsDefined2 = 0; - UInt32 *digests2 = 0; - SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < numFolders; i++) - { - CSzFolder *folder = folders + i; - UInt32 numSubstreams = folder->NumUnpackStreams; - if (numSubstreams == 1 && folder->UnpackCRCDefined) - { - (*digestsDefined)[si] = 1; - (*digests)[si] = folder->UnpackCRC; - si++; - } - else - { - UInt32 j; - for (j = 0; j < numSubstreams; j++, digestIndex++) - { - (*digestsDefined)[si] = digestsDefined2[digestIndex]; - (*digests)[si] = digests2[digestIndex]; - si++; - } - } + for (i = 0; i < numBindPairs; i++) { + CSzBindPair *bp = folder->BindPairs + i; + RINOK(SzReadNumber32(sd, &bp->InIndex)); + RINOK(SzReadNumber32(sd, &bp->OutIndex)); } - } - IAlloc_Free(allocTemp, digestsDefined2); - IAlloc_Free(allocTemp, digests2); - RINOK(res); - } - else if (type == k7zIdEnd) - return SZ_OK; - else - { - RINOK(SzSkeepData(sd)); - } - RINOK(SzReadID(sd, &type)); - } -} + if (numInStreams < numBindPairs) + return SZ_ERROR_UNSUPPORTED; -static SRes SzReadStreamsInfo( - CSzData *sd, - UInt64 *dataOffset, - CSzAr *p, - UInt32 *numUnpackStreams, - UInt64 **unpackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - for (;;) - { - UInt64 type; - RINOK(SzReadID(sd, &type)); - if ((UInt64)(int)type != type) - return SZ_ERROR_UNSUPPORTED; - switch((int)type) - { - case k7zIdEnd: + folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; + MY_ALLOC(UInt32, folder->PackStreams, (size_t)numPackStreams, alloc); + + if (numPackStreams == 1) { + for (i = 0; i < numInStreams; i++) + if (SzFolder_FindBindPairForInStream(folder, i) < 0) + break; + if (i == numInStreams) + return SZ_ERROR_UNSUPPORTED; + folder->PackStreams[0] = i; + } else + for (i = 0; i < numPackStreams; i++) { + RINOK(SzReadNumber32(sd, folder->PackStreams + i)); + } return SZ_OK; - case k7zIdPackInfo: - { - RINOK(SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, - &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc)); - break; - } - case k7zIdUnpackInfo: - { - RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); - break; - } - case k7zIdSubStreamsInfo: - { - RINOK(SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, - numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp)); - break; - } - default: - return SZ_ERROR_UNSUPPORTED; - } - } +} + +static SRes SzReadUnpackInfo(CSzData *sd, UInt32 *numFolders, CSzFolder **folders, /* for alloc */ + ISzAlloc *alloc, ISzAlloc *allocTemp) +{ + UInt32 i; + RINOK(SzWaitAttribute(sd, k7zIdFolder)); + RINOK(SzReadNumber32(sd, numFolders)); + { + RINOK(SzReadSwitch(sd)); + + MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); + + for (i = 0; i < *numFolders; i++) + SzFolder_Init((*folders) + i); + + for (i = 0; i < *numFolders; i++) { + RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); + } + } + + RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); + + for (i = 0; i < *numFolders; i++) { + UInt32 j; + CSzFolder *folder = (*folders) + i; + UInt32 numOutStreams = SzFolder_GetNumOutStreams(folder); + + MY_ALLOC(UInt64, folder->UnpackSizes, (size_t)numOutStreams, alloc); + + for (j = 0; j < numOutStreams; j++) { + RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); + } + } + + for (;;) { + UInt64 type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + return SZ_OK; + if (type == k7zIdCRC) { + SRes res; + Byte *crcsDefined = 0; + UInt32 *crcs = 0; + res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); + if (res == SZ_OK) { + for (i = 0; i < *numFolders; i++) { + CSzFolder *folder = (*folders) + i; + folder->UnpackCRCDefined = crcsDefined[i]; + folder->UnpackCRC = crcs[i]; + } + } + IAlloc_Free(allocTemp, crcs); + IAlloc_Free(allocTemp, crcsDefined); + RINOK(res); + continue; + } + RINOK(SzSkeepData(sd)); + } +} + +static SRes SzReadSubStreamsInfo(CSzData *sd, UInt32 numFolders, CSzFolder *folders, + UInt32 *numUnpackStreams, UInt64 **unpackSizes, + Byte **digestsDefined, UInt32 **digests, ISzAlloc *allocTemp) +{ + UInt64 type = 0; + UInt32 i; + UInt32 si = 0; + UInt32 numDigests = 0; + + for (i = 0; i < numFolders; i++) + folders[i].NumUnpackStreams = 1; + *numUnpackStreams = numFolders; + + for (;;) { + RINOK(SzReadID(sd, &type)); + if (type == k7zIdNumUnpackStream) { + *numUnpackStreams = 0; + for (i = 0; i < numFolders; i++) { + UInt32 numStreams; + RINOK(SzReadNumber32(sd, &numStreams)); + folders[i].NumUnpackStreams = numStreams; + *numUnpackStreams += numStreams; + } + continue; + } + if (type == k7zIdCRC || type == k7zIdSize) + break; + if (type == k7zIdEnd) + break; + RINOK(SzSkeepData(sd)); + } + + if (*numUnpackStreams == 0) { + *unpackSizes = 0; + *digestsDefined = 0; + *digests = 0; + } else { + *unpackSizes = + (UInt64 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt64)); + RINOM(*unpackSizes); + *digestsDefined = + (Byte *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(Byte)); + RINOM(*digestsDefined); + *digests = + (UInt32 *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(UInt32)); + RINOM(*digests); + } + + for (i = 0; i < numFolders; i++) { + /* + v3.13 incorrectly worked with empty folders + v4.07: we check that folder is empty + */ + UInt64 sum = 0; + UInt32 j; + UInt32 numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams == 0) + continue; + if (type == k7zIdSize) + for (j = 1; j < numSubstreams; j++) { + UInt64 size; + RINOK(SzReadNumber(sd, &size)); + (*unpackSizes)[si++] = size; + sum += size; + } + (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; + } + if (type == k7zIdSize) { + RINOK(SzReadID(sd, &type)); + } + + for (i = 0; i < *numUnpackStreams; i++) { + (*digestsDefined)[i] = 0; + (*digests)[i] = 0; + } + + for (i = 0; i < numFolders; i++) { + UInt32 numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) + numDigests += numSubstreams; + } + + si = 0; + for (;;) { + if (type == k7zIdCRC) { + int digestIndex = 0; + Byte *digestsDefined2 = 0; + UInt32 *digests2 = 0; + SRes res = SzReadHashDigests(sd, + numDigests, + &digestsDefined2, + &digests2, + allocTemp); + if (res == SZ_OK) { + for (i = 0; i < numFolders; i++) { + CSzFolder *folder = folders + i; + UInt32 numSubstreams = folder->NumUnpackStreams; + if (numSubstreams == 1 && folder->UnpackCRCDefined) { + (*digestsDefined)[si] = 1; + (*digests)[si] = folder->UnpackCRC; + si++; + } else { + UInt32 j; + for (j = 0; j < numSubstreams; j++, digestIndex++) { + (*digestsDefined)[si] = + digestsDefined2[digestIndex]; + (*digests)[si] = digests2[digestIndex]; + si++; + } + } + } + } + IAlloc_Free(allocTemp, digestsDefined2); + IAlloc_Free(allocTemp, digests2); + RINOK(res); + } else if (type == k7zIdEnd) + return SZ_OK; + else { + RINOK(SzSkeepData(sd)); + } + RINOK(SzReadID(sd, &type)); + } +} + +static SRes SzReadStreamsInfo(CSzData *sd, UInt64 *dataOffset, CSzAr *p, UInt32 *numUnpackStreams, + UInt64 **unpackSizes, /* allocTemp */ + Byte **digestsDefined, /* allocTemp */ + UInt32 **digests, /* allocTemp */ + ISzAlloc *alloc, ISzAlloc *allocTemp) +{ + for (;;) { + UInt64 type; + RINOK(SzReadID(sd, &type)); + if ((UInt64)(int)type != type) + return SZ_ERROR_UNSUPPORTED; + switch ((int)type) { + case k7zIdEnd: + return SZ_OK; + case k7zIdPackInfo: { + RINOK(SzReadPackInfo(sd, + dataOffset, + &p->NumPackStreams, + &p->PackSizes, + &p->PackCRCsDefined, + &p->PackCRCs, + alloc)); + break; + } + case k7zIdUnpackInfo: { + RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); + break; + } + case k7zIdSubStreamsInfo: { + RINOK(SzReadSubStreamsInfo(sd, + p->NumFolders, + p->Folders, + numUnpackStreams, + unpackSizes, + digestsDefined, + digests, + allocTemp)); + break; + } + default: + return SZ_ERROR_UNSUPPORTED; + } + } } size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) { - size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - if (dest != 0) - { - size_t i; - const Byte *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); - for (i = 0; i < len; i++) - dest[i] = GetUi16(src + i * 2); - } - return len; + size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; + if (dest != 0) { + size_t i; + const Byte *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); + for (i = 0; i < len; i++) + dest[i] = GetUi16(src + i * 2); + } + return len; } static SRes SzReadFileNames(const Byte *p, size_t size, UInt32 numFiles, size_t *sizes) { - UInt32 i; - size_t pos = 0; - for (i = 0; i < numFiles; i++) - { - sizes[i] = pos; - for (;;) - { - if (pos >= size) - return SZ_ERROR_ARCHIVE; - if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) - break; - pos++; - } - pos++; - } - sizes[i] = pos; - return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; -} - -static SRes SzReadHeader2( - CSzArEx *p, /* allocMain */ - CSzData *sd, - UInt64 **unpackSizes, /* allocTemp */ - Byte **digestsDefined, /* allocTemp */ - UInt32 **digests, /* allocTemp */ - Byte **emptyStreamVector, /* allocTemp */ - Byte **emptyFileVector, /* allocTemp */ - Byte **lwtVector, /* allocTemp */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - UInt64 type; - UInt32 numUnpackStreams = 0; - UInt32 numFiles = 0; - CSzFileItem *files = 0; - UInt32 numEmptyStreams = 0; - UInt32 i; - - RINOK(SzReadID(sd, &type)); - - if (type == k7zIdArchiveProperties) - { - RINOK(SzReadArchiveProperties(sd)); - RINOK(SzReadID(sd, &type)); - } - - - if (type == k7zIdMainStreamsInfo) - { - RINOK(SzReadStreamsInfo(sd, - &p->dataPos, - &p->db, - &numUnpackStreams, - unpackSizes, - digestsDefined, - digests, allocMain, allocTemp)); - p->dataPos += p->startPosAfterHeader; - RINOK(SzReadID(sd, &type)); - } - - if (type == k7zIdEnd) - return SZ_OK; - if (type != k7zIdFilesInfo) - return SZ_ERROR_ARCHIVE; - - RINOK(SzReadNumber32(sd, &numFiles)); - p->db.NumFiles = numFiles; - - MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); - - p->db.Files = files; - for (i = 0; i < numFiles; i++) - SzFile_Init(files + i); - - for (;;) - { - UInt64 type; - UInt64 size; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(SzReadNumber(sd, &size)); - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - if ((UInt64)(int)type != type) - { - RINOK(SzSkeepDataSize(sd, size)); - } - else - switch((int)type) - { - case k7zIdName: - { - size_t namesSize; - RINOK(SzReadSwitch(sd)); - namesSize = (size_t)size - 1; - if ((namesSize & 1) != 0) - return SZ_ERROR_ARCHIVE; - if (!Buf_Create(&p->FileNames, namesSize, allocMain)) - return SZ_ERROR_MEM; - MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); - memcpy(p->FileNames.data, sd->Data, namesSize); - RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets)) - RINOK(SzSkeepDataSize(sd, namesSize)); - break; - } - case k7zIdEmptyStream: - { - RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); - numEmptyStreams = 0; - for (i = 0; i < numFiles; i++) - if ((*emptyStreamVector)[i]) - numEmptyStreams++; - break; - } - case k7zIdEmptyFile: - { - RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp)); - break; - } - case k7zIdWinAttributes: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); - for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - Byte defined = (*lwtVector)[i]; - f->AttribDefined = defined; - f->Attrib = 0; - if (defined) - { - RINOK(SzReadUInt32(sd, &f->Attrib)); - } + UInt32 i; + size_t pos = 0; + for (i = 0; i < numFiles; i++) { + sizes[i] = pos; + for (;;) { + if (pos >= size) + return SZ_ERROR_ARCHIVE; + if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) + break; + pos++; + } + pos++; } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - case k7zIdMTime: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); + sizes[i] = pos; + return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; +} + +static SRes SzReadHeader2(CSzArEx *p, /* allocMain */ + CSzData *sd, UInt64 **unpackSizes, /* allocTemp */ + Byte **digestsDefined, /* allocTemp */ + UInt32 **digests, /* allocTemp */ + Byte **emptyStreamVector, /* allocTemp */ + Byte **emptyFileVector, /* allocTemp */ + Byte **lwtVector, /* allocTemp */ + ISzAlloc *allocMain, ISzAlloc *allocTemp) +{ + UInt64 type; + UInt32 numUnpackStreams = 0; + UInt32 numFiles = 0; + CSzFileItem *files = 0; + UInt32 numEmptyStreams = 0; + UInt32 i; + + RINOK(SzReadID(sd, &type)); + + if (type == k7zIdArchiveProperties) { + RINOK(SzReadArchiveProperties(sd)); + RINOK(SzReadID(sd, &type)); + } + + if (type == k7zIdMainStreamsInfo) { + RINOK(SzReadStreamsInfo(sd, + &p->dataPos, + &p->db, + &numUnpackStreams, + unpackSizes, + digestsDefined, + digests, + allocMain, + allocTemp)); + p->dataPos += p->startPosAfterHeader; + RINOK(SzReadID(sd, &type)); + } + + if (type == k7zIdEnd) + return SZ_OK; + if (type != k7zIdFilesInfo) + return SZ_ERROR_ARCHIVE; + + RINOK(SzReadNumber32(sd, &numFiles)); + p->db.NumFiles = numFiles; + + MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); + + p->db.Files = files; for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - Byte defined = (*lwtVector)[i]; - f->MTimeDefined = defined; - f->MTime.Low = f->MTime.High = 0; - if (defined) - { - RINOK(SzReadUInt32(sd, &f->MTime.Low)); - RINOK(SzReadUInt32(sd, &f->MTime.High)); - } + SzFile_Init(files + i); + + for (;;) { + UInt64 type; + UInt64 size; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + RINOK(SzReadNumber(sd, &size)); + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + if ((UInt64)(int)type != type) { + RINOK(SzSkeepDataSize(sd, size)); + } else + switch ((int)type) { + case k7zIdName: { + size_t namesSize; + RINOK(SzReadSwitch(sd)); + namesSize = (size_t)size - 1; + if ((namesSize & 1) != 0) + return SZ_ERROR_ARCHIVE; + if (!Buf_Create(&p->FileNames, namesSize, allocMain)) + return SZ_ERROR_MEM; + MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); + memcpy(p->FileNames.data, sd->Data, namesSize); + RINOK(SzReadFileNames(sd->Data, + namesSize >> 1, + numFiles, + p->FileNameOffsets)) + RINOK(SzSkeepDataSize(sd, namesSize)); + break; + } + case k7zIdEmptyStream: { + RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); + numEmptyStreams = 0; + for (i = 0; i < numFiles; i++) + if ((*emptyStreamVector)[i]) + numEmptyStreams++; + break; + } + case k7zIdEmptyFile: { + RINOK(SzReadBoolVector(sd, + numEmptyStreams, + emptyFileVector, + allocTemp)); + break; + } + case k7zIdWinAttributes: { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) { + CSzFileItem *f = &files[i]; + Byte defined = (*lwtVector)[i]; + f->AttribDefined = defined; + f->Attrib = 0; + if (defined) { + RINOK(SzReadUInt32(sd, &f->Attrib)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + case k7zIdMTime: { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) { + CSzFileItem *f = &files[i]; + Byte defined = (*lwtVector)[i]; + f->MTimeDefined = defined; + f->MTime.Low = f->MTime.High = 0; + if (defined) { + RINOK(SzReadUInt32(sd, &f->MTime.Low)); + RINOK(SzReadUInt32(sd, &f->MTime.High)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + default: { + RINOK(SzSkeepDataSize(sd, size)); + } + } } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - default: - { - RINOK(SzSkeepDataSize(sd, size)); - } - } - } - { - UInt32 emptyFileIndex = 0; - UInt32 sizeIndex = 0; - for (i = 0; i < numFiles; i++) - { - CSzFileItem *file = files + i; - file->IsAnti = 0; - if (*emptyStreamVector == 0) - file->HasStream = 1; - else - file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); - if (file->HasStream) - { - file->IsDir = 0; - file->Size = (*unpackSizes)[sizeIndex]; - file->Crc = (*digests)[sizeIndex]; - file->CrcDefined = (Byte)(*digestsDefined)[sizeIndex]; - sizeIndex++; - } - else - { - if (*emptyFileVector == 0) - file->IsDir = 1; - else - file->IsDir = (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); - emptyFileIndex++; - file->Size = 0; - file->Crc = 0; - file->CrcDefined = 0; - } - } - } - return SzArEx_Fill(p, allocMain); -} - -static SRes SzReadHeader( - CSzArEx *p, - CSzData *sd, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - UInt64 *unpackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; - Byte *emptyStreamVector = 0; - Byte *emptyFileVector = 0; - Byte *lwtVector = 0; - SRes res = SzReadHeader2(p, sd, - &unpackSizes, &digestsDefined, &digests, - &emptyStreamVector, &emptyFileVector, &lwtVector, - allocMain, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - IAlloc_Free(allocTemp, emptyStreamVector); - IAlloc_Free(allocTemp, emptyFileVector); - IAlloc_Free(allocTemp, lwtVector); - return res; -} - -static SRes SzReadAndDecodePackedStreams2( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - UInt64 baseOffset, - CSzAr *p, - UInt64 **unpackSizes, - Byte **digestsDefined, - UInt32 **digests, - ISzAlloc *allocTemp) -{ - - UInt32 numUnpackStreams = 0; - UInt64 dataStartPos; - CSzFolder *folder; - UInt64 unpackSize; - SRes res; - - RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, - &numUnpackStreams, unpackSizes, digestsDefined, digests, - allocTemp, allocTemp)); - - dataStartPos += baseOffset; - if (p->NumFolders != 1) - return SZ_ERROR_ARCHIVE; - - folder = p->Folders; - unpackSize = SzFolder_GetUnpackSize(folder); - - RINOK(LookInStream_SeekTo(inStream, dataStartPos)); - - if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) - return SZ_ERROR_MEM; - - res = SzFolder_Decode(folder, p->PackSizes, - inStream, dataStartPos, - outBuffer->data, (size_t)unpackSize, allocTemp); - RINOK(res); - if (folder->UnpackCRCDefined) - if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) - return SZ_ERROR_CRC; - return SZ_OK; -} - -static SRes SzReadAndDecodePackedStreams( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - UInt64 baseOffset, - ISzAlloc *allocTemp) -{ - CSzAr p; - UInt64 *unpackSizes = 0; - Byte *digestsDefined = 0; - UInt32 *digests = 0; - SRes res; - SzAr_Init(&p); - res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, - &p, &unpackSizes, &digestsDefined, &digests, - allocTemp); - SzAr_Free(&p, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - return res; -} - -static SRes SzArEx_Open2( - CSzArEx *p, - ILookInStream *inStream, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - Byte header[k7zStartHeaderSize]; - Int64 startArcPos; - UInt64 nextHeaderOffset, nextHeaderSize; - size_t nextHeaderSizeT; - UInt32 nextHeaderCRC; - CBuf buffer; - SRes res; - - startArcPos = 0; - RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); - - RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); - - if (!TestSignatureCandidate(header)) - return SZ_ERROR_NO_ARCHIVE; - if (header[6] != k7zMajorVersion) - return SZ_ERROR_UNSUPPORTED; - - nextHeaderOffset = GetUi64(header + 12); - nextHeaderSize = GetUi64(header + 20); - nextHeaderCRC = GetUi32(header + 28); - - p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; - - if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) - return SZ_ERROR_CRC; - - nextHeaderSizeT = (size_t)nextHeaderSize; - if (nextHeaderSizeT != nextHeaderSize) - return SZ_ERROR_MEM; - if (nextHeaderSizeT == 0) - return SZ_OK; - if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || - nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) - return SZ_ERROR_NO_ARCHIVE; - - { - Int64 pos = 0; - RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); - if ((UInt64)pos < startArcPos + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) - return SZ_ERROR_INPUT_EOF; - } - - RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); - - if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) - return SZ_ERROR_MEM; - - res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); - if (res == SZ_OK) - { - res = SZ_ERROR_ARCHIVE; - if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) - { - CSzData sd; - UInt64 type; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - if (res == SZ_OK) - { - if (type == k7zIdEncodedHeader) { - CBuf outBuffer; - Buf_Init(&outBuffer); - res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, p->startPosAfterHeader, allocTemp); - if (res != SZ_OK) - Buf_Free(&outBuffer, allocTemp); - else - { - Buf_Free(&buffer, allocTemp); - buffer.data = outBuffer.data; - buffer.size = outBuffer.size; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - } + UInt32 emptyFileIndex = 0; + UInt32 sizeIndex = 0; + for (i = 0; i < numFiles; i++) { + CSzFileItem *file = files + i; + file->IsAnti = 0; + if (*emptyStreamVector == 0) + file->HasStream = 1; + else + file->HasStream = (Byte)((*emptyStreamVector)[i] ? 0 : 1); + if (file->HasStream) { + file->IsDir = 0; + file->Size = (*unpackSizes)[sizeIndex]; + file->Crc = (*digests)[sizeIndex]; + file->CrcDefined = (Byte)(*digestsDefined)[sizeIndex]; + sizeIndex++; + } else { + if (*emptyFileVector == 0) + file->IsDir = 1; + else + file->IsDir = + (Byte)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); + emptyFileIndex++; + file->Size = 0; + file->Crc = 0; + file->CrcDefined = 0; + } + } } - } - if (res == SZ_OK) - { - if (type == k7zIdHeader) - res = SzReadHeader(p, &sd, allocMain, allocTemp); - else - res = SZ_ERROR_UNSUPPORTED; - } - } - } - Buf_Free(&buffer, allocTemp); - return res; + return SzArEx_Fill(p, allocMain); +} + +static SRes SzReadHeader(CSzArEx *p, CSzData *sd, ISzAlloc *allocMain, ISzAlloc *allocTemp) +{ + UInt64 *unpackSizes = 0; + Byte *digestsDefined = 0; + UInt32 *digests = 0; + Byte *emptyStreamVector = 0; + Byte *emptyFileVector = 0; + Byte *lwtVector = 0; + SRes res = SzReadHeader2(p, + sd, + &unpackSizes, + &digestsDefined, + &digests, + &emptyStreamVector, + &emptyFileVector, + &lwtVector, + allocMain, + allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + IAlloc_Free(allocTemp, emptyStreamVector); + IAlloc_Free(allocTemp, emptyFileVector); + IAlloc_Free(allocTemp, lwtVector); + return res; +} + +static SRes SzReadAndDecodePackedStreams2(ILookInStream *inStream, CSzData *sd, CBuf *outBuffer, + UInt64 baseOffset, CSzAr *p, UInt64 **unpackSizes, + Byte **digestsDefined, UInt32 **digests, + ISzAlloc *allocTemp) +{ + UInt32 numUnpackStreams = 0; + UInt64 dataStartPos; + CSzFolder *folder; + UInt64 unpackSize; + SRes res; + + RINOK(SzReadStreamsInfo(sd, + &dataStartPos, + p, + &numUnpackStreams, + unpackSizes, + digestsDefined, + digests, + allocTemp, + allocTemp)); + + dataStartPos += baseOffset; + if (p->NumFolders != 1) + return SZ_ERROR_ARCHIVE; + + folder = p->Folders; + unpackSize = SzFolder_GetUnpackSize(folder); + + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); + + if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) + return SZ_ERROR_MEM; + + res = SzFolder_Decode(folder, + p->PackSizes, + inStream, + dataStartPos, + outBuffer->data, + (size_t)unpackSize, + allocTemp); + RINOK(res); + if (folder->UnpackCRCDefined) + if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) + return SZ_ERROR_CRC; + return SZ_OK; +} + +static SRes SzReadAndDecodePackedStreams(ILookInStream *inStream, CSzData *sd, CBuf *outBuffer, + UInt64 baseOffset, ISzAlloc *allocTemp) +{ + CSzAr p; + UInt64 *unpackSizes = 0; + Byte *digestsDefined = 0; + UInt32 *digests = 0; + SRes res; + SzAr_Init(&p); + res = SzReadAndDecodePackedStreams2(inStream, + sd, + outBuffer, + baseOffset, + &p, + &unpackSizes, + &digestsDefined, + &digests, + allocTemp); + SzAr_Free(&p, allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + return res; +} + +static SRes SzArEx_Open2(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + Byte header[k7zStartHeaderSize]; + Int64 startArcPos; + UInt64 nextHeaderOffset, nextHeaderSize; + size_t nextHeaderSizeT; + UInt32 nextHeaderCRC; + CBuf buffer; + SRes res; + + startArcPos = 0; + RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); + + RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); + + if (!TestSignatureCandidate(header)) + return SZ_ERROR_NO_ARCHIVE; + if (header[6] != k7zMajorVersion) + return SZ_ERROR_UNSUPPORTED; + + nextHeaderOffset = GetUi64(header + 12); + nextHeaderSize = GetUi64(header + 20); + nextHeaderCRC = GetUi32(header + 28); + + p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; + + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) + return SZ_ERROR_CRC; + + nextHeaderSizeT = (size_t)nextHeaderSize; + if (nextHeaderSizeT != nextHeaderSize) + return SZ_ERROR_MEM; + if (nextHeaderSizeT == 0) + return SZ_OK; + if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || + nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) + return SZ_ERROR_NO_ARCHIVE; + + { + Int64 pos = 0; + RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); + if ((UInt64)pos < startArcPos + nextHeaderOffset || + (UInt64)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (UInt64)pos < + startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + return SZ_ERROR_INPUT_EOF; + } + + RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); + + if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) + return SZ_ERROR_MEM; + + res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); + if (res == SZ_OK) { + res = SZ_ERROR_ARCHIVE; + if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) { + CSzData sd; + UInt64 type; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + if (res == SZ_OK) { + if (type == k7zIdEncodedHeader) { + CBuf outBuffer; + Buf_Init(&outBuffer); + res = SzReadAndDecodePackedStreams(inStream, + &sd, + &outBuffer, + p->startPosAfterHeader, + allocTemp); + if (res != SZ_OK) + Buf_Free(&outBuffer, allocTemp); + else { + Buf_Free(&buffer, allocTemp); + buffer.data = outBuffer.data; + buffer.size = outBuffer.size; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + } + } + } + if (res == SZ_OK) { + if (type == k7zIdHeader) + res = SzReadHeader(p, &sd, allocMain, allocTemp); + else + res = SZ_ERROR_UNSUPPORTED; + } + } + } + Buf_Free(&buffer, allocTemp); + return res; } SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp) { - SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); - if (res != SZ_OK) - SzArEx_Free(p, allocMain); - return res; + SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); + if (res != SZ_OK) + SzArEx_Free(p, allocMain); + return res; } -SRes SzArEx_Extract( - const CSzArEx *p, - ILookInStream *inStream, - UInt32 fileIndex, - UInt32 *blockIndex, - Byte **outBuffer, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) +SRes SzArEx_Extract(const CSzArEx *p, ILookInStream *inStream, UInt32 fileIndex, UInt32 *blockIndex, + Byte **outBuffer, size_t *outBufferSize, size_t *offset, + size_t *outSizeProcessed, ISzAlloc *allocMain, ISzAlloc *allocTemp) { - UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; - SRes res = SZ_OK; - *offset = 0; - *outSizeProcessed = 0; - if (folderIndex == (UInt32)-1) - { - IAlloc_Free(allocMain, *outBuffer); - *blockIndex = folderIndex; - *outBuffer = 0; - *outBufferSize = 0; - return SZ_OK; - } - - if (*outBuffer == 0 || *blockIndex != folderIndex) - { - CSzFolder *folder = p->db.Folders + folderIndex; - UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder); - size_t unpackSize = (size_t)unpackSizeSpec; - UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); - - if (unpackSize != unpackSizeSpec) - return SZ_ERROR_MEM; - *blockIndex = folderIndex; - IAlloc_Free(allocMain, *outBuffer); - *outBuffer = 0; - - RINOK(LookInStream_SeekTo(inStream, startOffset)); - - if (res == SZ_OK) - { - *outBufferSize = unpackSize; - if (unpackSize != 0) - { - *outBuffer = (Byte *)IAlloc_Alloc(allocMain, unpackSize); - if (*outBuffer == 0) - res = SZ_ERROR_MEM; - } - if (res == SZ_OK) - { - res = SzFolder_Decode(folder, - p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], - inStream, startOffset, - *outBuffer, unpackSize, allocTemp); - if (res == SZ_OK) - { - if (folder->UnpackCRCDefined) - { - if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC) - res = SZ_ERROR_CRC; - } + UInt32 folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; + SRes res = SZ_OK; + *offset = 0; + *outSizeProcessed = 0; + if (folderIndex == (UInt32)-1) { + IAlloc_Free(allocMain, *outBuffer); + *blockIndex = folderIndex; + *outBuffer = 0; + *outBufferSize = 0; + return SZ_OK; } - } - } - } - if (res == SZ_OK) - { - UInt32 i; - CSzFileItem *fileItem = p->db.Files + fileIndex; - *offset = 0; - for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) - *offset += (UInt32)p->db.Files[i].Size; - *outSizeProcessed = (size_t)fileItem->Size; - if (*offset + *outSizeProcessed > *outBufferSize) - return SZ_ERROR_FAIL; - if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) - res = SZ_ERROR_CRC; - } - return res; + + if (*outBuffer == 0 || *blockIndex != folderIndex) { + CSzFolder *folder = p->db.Folders + folderIndex; + UInt64 unpackSizeSpec = SzFolder_GetUnpackSize(folder); + size_t unpackSize = (size_t)unpackSizeSpec; + UInt64 startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); + + if (unpackSize != unpackSizeSpec) + return SZ_ERROR_MEM; + *blockIndex = folderIndex; + IAlloc_Free(allocMain, *outBuffer); + *outBuffer = 0; + + RINOK(LookInStream_SeekTo(inStream, startOffset)); + + if (res == SZ_OK) { + *outBufferSize = unpackSize; + if (unpackSize != 0) { + *outBuffer = (Byte *)IAlloc_Alloc(allocMain, unpackSize); + if (*outBuffer == 0) + res = SZ_ERROR_MEM; + } + if (res == SZ_OK) { + res = + SzFolder_Decode(folder, + p->db.PackSizes + + p->FolderStartPackStreamIndex[folderIndex], + inStream, + startOffset, + *outBuffer, + unpackSize, + allocTemp); + if (res == SZ_OK) { + if (folder->UnpackCRCDefined) { + if (CrcCalc(*outBuffer, unpackSize) != + folder->UnpackCRC) + res = SZ_ERROR_CRC; + } + } + } + } + } + if (res == SZ_OK) { + UInt32 i; + CSzFileItem *fileItem = p->db.Files + fileIndex; + *offset = 0; + for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) + *offset += (UInt32)p->db.Files[i].Size; + *outSizeProcessed = (size_t)fileItem->Size; + if (*offset + *outSizeProcessed > *outBufferSize) + return SZ_ERROR_FAIL; + if (fileItem->CrcDefined && + CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) + res = SZ_ERROR_CRC; + } + return res; } diff --git a/fex/7z_C/7zStream.c b/fex/7z_C/7zStream.c index 0ebb7b5f..5e9743a8 100644 --- a/fex/7z_C/7zStream.c +++ b/fex/7z_C/7zStream.c @@ -7,163 +7,157 @@ SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) { - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((Byte *)buf + processed); - size -= processed; - } - return SZ_OK; + while (size != 0) { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((Byte *)buf + processed); + size -= processed; + } + return SZ_OK; } SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) { - return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); + return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); } SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf) { - size_t processed = 1; - RINOK(stream->Read(stream, buf, &processed)); - return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; + size_t processed = 1; + RINOK(stream->Read(stream, buf, &processed)); + return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; } SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) { - Int64 t = offset; - return stream->Seek(stream, &t, SZ_SEEK_SET); + Int64 t = offset; + return stream->Seek(stream, &t, SZ_SEEK_SET); } SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) { - const void *lookBuf; - if (*size == 0) - return SZ_OK; - RINOK(stream->Look(stream, &lookBuf, size)); - memcpy(buf, lookBuf, *size); - return stream->Skip(stream, *size); + const void *lookBuf; + if (*size == 0) + return SZ_OK; + RINOK(stream->Look(stream, &lookBuf, size)); + memcpy(buf, lookBuf, *size); + return stream->Skip(stream, *size); } SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) { - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((Byte *)buf + processed); - size -= processed; - } - return SZ_OK; + while (size != 0) { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((Byte *)buf + processed); + size -= processed; + } + return SZ_OK; } SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) { - return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); + return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); } static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) { - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - size2 = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, &size2); - p->size = size2; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) { + p->pos = 0; + size2 = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, &size2); + p->size = size2; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; } static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) { - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - if (*size > LookToRead_BUF_SIZE) - *size = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, size); - size2 = p->size = *size; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) { + p->pos = 0; + if (*size > LookToRead_BUF_SIZE) + *size = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, size); + size2 = p->size = *size; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; } static SRes LookToRead_Skip(void *pp, size_t offset) { - CLookToRead *p = (CLookToRead *)pp; - p->pos += offset; - return SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + p->pos += offset; + return SZ_OK; } static SRes LookToRead_Read(void *pp, void *buf, size_t *size) { - CLookToRead *p = (CLookToRead *)pp; - size_t rem = p->size - p->pos; - if (rem == 0) - return p->realStream->Read(p->realStream, buf, size); - if (rem > *size) - rem = *size; - memcpy(buf, p->buf + p->pos, rem); - p->pos += rem; - *size = rem; - return SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t rem = p->size - p->pos; + if (rem == 0) + return p->realStream->Read(p->realStream, buf, size); + if (rem > *size) + rem = *size; + memcpy(buf, p->buf + p->pos, rem); + p->pos += rem; + *size = rem; + return SZ_OK; } static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin) { - CLookToRead *p = (CLookToRead *)pp; - p->pos = p->size = 0; - return p->realStream->Seek(p->realStream, pos, origin); + CLookToRead *p = (CLookToRead *)pp; + p->pos = p->size = 0; + return p->realStream->Seek(p->realStream, pos, origin); } void LookToRead_CreateVTable(CLookToRead *p, int lookahead) { - p->s.Look = lookahead ? - LookToRead_Look_Lookahead : - LookToRead_Look_Exact; - p->s.Skip = LookToRead_Skip; - p->s.Read = LookToRead_Read; - p->s.Seek = LookToRead_Seek; + p->s.Look = lookahead ? LookToRead_Look_Lookahead : LookToRead_Look_Exact; + p->s.Skip = LookToRead_Skip; + p->s.Read = LookToRead_Read; + p->s.Seek = LookToRead_Seek; } void LookToRead_Init(CLookToRead *p) { - p->pos = p->size = 0; + p->pos = p->size = 0; } static SRes SecToLook_Read(void *pp, void *buf, size_t *size) { - CSecToLook *p = (CSecToLook *)pp; - return LookInStream_LookRead(p->realStream, buf, size); + CSecToLook *p = (CSecToLook *)pp; + return LookInStream_LookRead(p->realStream, buf, size); } void SecToLook_CreateVTable(CSecToLook *p) { - p->s.Read = SecToLook_Read; + p->s.Read = SecToLook_Read; } static SRes SecToRead_Read(void *pp, void *buf, size_t *size) { - CSecToRead *p = (CSecToRead *)pp; - return p->realStream->Read(p->realStream, buf, size); + CSecToRead *p = (CSecToRead *)pp; + return p->realStream->Read(p->realStream, buf, size); } void SecToRead_CreateVTable(CSecToRead *p) { - p->s.Read = SecToRead_Read; + p->s.Read = SecToRead_Read; } diff --git a/fex/7z_C/Bcj2.c b/fex/7z_C/Bcj2.c index 20199ce5..9516bd6a 100644 --- a/fex/7z_C/Bcj2.c +++ b/fex/7z_C/Bcj2.c @@ -9,7 +9,7 @@ #define CProb UInt16 #endif -#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) +#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1)&0xF0) == 0x80) #define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) #define kNumTopBits 24 @@ -20,113 +20,132 @@ #define kNumMoveBits 5 #define RC_READ_BYTE (*buffer++) -#define RC_TEST { if (buffer == bufferLim) return SZ_ERROR_DATA; } -#define RC_INIT2 code = 0; range = 0xFFFFFFFF; \ - { int i; for (i = 0; i < 5; i++) { RC_TEST; code = (code << 8) | RC_READ_BYTE; }} +#define RC_TEST \ + { \ + if (buffer == bufferLim) \ + return SZ_ERROR_DATA; \ + } +#define RC_INIT2 \ + code = 0; \ + range = 0xFFFFFFFF; \ + { \ + int i; \ + for (i = 0; i < 5; i++) { \ + RC_TEST; \ + code = (code << 8) | RC_READ_BYTE; \ + } \ + } -#define NORMALIZE if (range < kTopValue) { RC_TEST; range <<= 8; code = (code << 8) | RC_READ_BYTE; } +#define NORMALIZE \ + if (range < kTopValue) { \ + RC_TEST; \ + range <<= 8; \ + code = (code << 8) | RC_READ_BYTE; \ + } -#define IF_BIT_0(p) ttt = *(p); bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define UPDATE_0(p) range = bound; *(p) = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); NORMALIZE; -#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CProb)(ttt - (ttt >> kNumMoveBits)); NORMALIZE; +#define IF_BIT_0(p) \ + ttt = *(p); \ + bound = (range >> kNumBitModelTotalBits) * ttt; \ + if (code < bound) +#define UPDATE_0(p) \ + range = bound; \ + *(p) = (CProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); \ + NORMALIZE; +#define UPDATE_1(p) \ + range -= bound; \ + code -= bound; \ + *(p) = (CProb)(ttt - (ttt >> kNumMoveBits)); \ + NORMALIZE; -int Bcj2_Decode( - const Byte *buf0, SizeT size0, - const Byte *buf1, SizeT size1, - const Byte *buf2, SizeT size2, - const Byte *buf3, SizeT size3, - Byte *outBuf, SizeT outSize) +int Bcj2_Decode(const Byte *buf0, SizeT size0, const Byte *buf1, SizeT size1, const Byte *buf2, + SizeT size2, const Byte *buf3, SizeT size3, Byte *outBuf, SizeT outSize) { - CProb p[256 + 2]; - SizeT inPos = 0, outPos = 0; + CProb p[256 + 2]; + SizeT inPos = 0, outPos = 0; - const Byte *buffer, *bufferLim; - UInt32 range, code; - Byte prevByte = 0; + const Byte *buffer, *bufferLim; + UInt32 range, code; + Byte prevByte = 0; - unsigned int i; - for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) - p[i] = kBitModelTotal >> 1; + unsigned int i; + for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) + p[i] = kBitModelTotal >> 1; - buffer = buf3; - bufferLim = buffer + size3; - RC_INIT2 + buffer = buf3; + bufferLim = buffer + size3; + RC_INIT2 - if (outSize == 0) - return SZ_OK; + if (outSize == 0) + return SZ_OK; - for (;;) - { - Byte b; - CProb *prob; - UInt32 bound; - UInt32 ttt; + for (;;) { + Byte b; + CProb *prob; + UInt32 bound; + UInt32 ttt; - SizeT limit = size0 - inPos; - if (outSize - outPos < limit) - limit = outSize - outPos; - while (limit != 0) - { - Byte b = buf0[inPos]; - outBuf[outPos++] = b; - if (IsJ(prevByte, b)) - break; - inPos++; - prevByte = b; - limit--; - } + SizeT limit = size0 - inPos; + if (outSize - outPos < limit) + limit = outSize - outPos; + while (limit != 0) { + Byte b = buf0[inPos]; + outBuf[outPos++] = b; + if (IsJ(prevByte, b)) + break; + inPos++; + prevByte = b; + limit--; + } - if (limit == 0 || outPos == outSize) - break; + if (limit == 0 || outPos == outSize) + break; - b = buf0[inPos++]; + b = buf0[inPos++]; - if (b == 0xE8) - prob = p + prevByte; - else if (b == 0xE9) - prob = p + 256; - else - prob = p + 257; + if (b == 0xE8) + prob = p + prevByte; + else if (b == 0xE9) + prob = p + 256; + else + prob = p + 257; - IF_BIT_0(prob) - { - UPDATE_0(prob) - prevByte = b; - } - else - { - UInt32 dest; - const Byte *v; - UPDATE_1(prob) - if (b == 0xE8) - { - v = buf1; - if (size1 < 4) - return SZ_ERROR_DATA; - buf1 += 4; - size1 -= 4; - } - else - { - v = buf2; - if (size2 < 4) - return SZ_ERROR_DATA; - buf2 += 4; - size2 -= 4; - } - dest = (((UInt32)v[0] << 24) | ((UInt32)v[1] << 16) | - ((UInt32)v[2] << 8) | ((UInt32)v[3])) - ((UInt32)outPos + 4); - outBuf[outPos++] = (Byte)dest; - if (outPos == outSize) - break; - outBuf[outPos++] = (Byte)(dest >> 8); - if (outPos == outSize) - break; - outBuf[outPos++] = (Byte)(dest >> 16); - if (outPos == outSize) - break; - outBuf[outPos++] = prevByte = (Byte)(dest >> 24); - } - } - return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; + IF_BIT_0(prob) + { + UPDATE_0(prob) + prevByte = b; + } + else + { + UInt32 dest; + const Byte *v; + UPDATE_1(prob) + if (b == 0xE8) { + v = buf1; + if (size1 < 4) + return SZ_ERROR_DATA; + buf1 += 4; + size1 -= 4; + } else { + v = buf2; + if (size2 < 4) + return SZ_ERROR_DATA; + buf2 += 4; + size2 -= 4; + } + dest = (((UInt32)v[0] << 24) | ((UInt32)v[1] << 16) | ((UInt32)v[2] << 8) | + ((UInt32)v[3])) - + ((UInt32)outPos + 4); + outBuf[outPos++] = (Byte)dest; + if (outPos == outSize) + break; + outBuf[outPos++] = (Byte)(dest >> 8); + if (outPos == outSize) + break; + outBuf[outPos++] = (Byte)(dest >> 16); + if (outPos == outSize) + break; + outBuf[outPos++] = prevByte = (Byte)(dest >> 24); + } + } + return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; } diff --git a/fex/7z_C/Bcj2.h b/fex/7z_C/Bcj2.h index dbc05414..af2569ef 100644 --- a/fex/7z_C/Bcj2.h +++ b/fex/7z_C/Bcj2.h @@ -24,12 +24,8 @@ Returns: SZ_ERROR_DATA - Data error */ -int Bcj2_Decode( - const Byte *buf0, SizeT size0, - const Byte *buf1, SizeT size1, - const Byte *buf2, SizeT size2, - const Byte *buf3, SizeT size3, - Byte *outBuf, SizeT outSize); +int Bcj2_Decode(const Byte *buf0, SizeT size0, const Byte *buf1, SizeT size1, const Byte *buf2, + SizeT size2, const Byte *buf3, SizeT size3, Byte *outBuf, SizeT outSize); #ifdef __cplusplus } diff --git a/fex/7z_C/Bra.c b/fex/7z_C/Bra.c index 2e47b141..93f2ff66 100644 --- a/fex/7z_C/Bra.c +++ b/fex/7z_C/Bra.c @@ -5,129 +5,116 @@ SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { - SizeT i; - if (size < 4) - return 0; - size -= 4; - ip += 8; - for (i = 0; i <= size; i += 4) - { - if (data[i + 3] == 0xEB) - { - UInt32 dest; - UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | (data[i + 0]); - src <<= 2; - if (encoding) - dest = ip + (UInt32)i + src; - else - dest = src - (ip + (UInt32)i); - dest >>= 2; - data[i + 2] = (Byte)(dest >> 16); - data[i + 1] = (Byte)(dest >> 8); - data[i + 0] = (Byte)dest; - } - } - return i; + SizeT i; + if (size < 4) + return 0; + size -= 4; + ip += 8; + for (i = 0; i <= size; i += 4) { + if (data[i + 3] == 0xEB) { + UInt32 dest; + UInt32 src = ((UInt32)data[i + 2] << 16) | ((UInt32)data[i + 1] << 8) | + (data[i + 0]); + src <<= 2; + if (encoding) + dest = ip + (UInt32)i + src; + else + dest = src - (ip + (UInt32)i); + dest >>= 2; + data[i + 2] = (Byte)(dest >> 16); + data[i + 1] = (Byte)(dest >> 8); + data[i + 0] = (Byte)dest; + } + } + return i; } SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { - SizeT i; - if (size < 4) - return 0; - size -= 4; - ip += 4; - for (i = 0; i <= size; i += 2) - { - if ((data[i + 1] & 0xF8) == 0xF0 && - (data[i + 3] & 0xF8) == 0xF8) - { - UInt32 dest; - UInt32 src = - (((UInt32)data[i + 1] & 0x7) << 19) | - ((UInt32)data[i + 0] << 11) | - (((UInt32)data[i + 3] & 0x7) << 8) | - (data[i + 2]); - - src <<= 1; - if (encoding) - dest = ip + (UInt32)i + src; - else - dest = src - (ip + (UInt32)i); - dest >>= 1; - - data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); - data[i + 0] = (Byte)(dest >> 11); - data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); - data[i + 2] = (Byte)dest; - i += 2; - } - } - return i; + SizeT i; + if (size < 4) + return 0; + size -= 4; + ip += 4; + for (i = 0; i <= size; i += 2) { + if ((data[i + 1] & 0xF8) == 0xF0 && (data[i + 3] & 0xF8) == 0xF8) { + UInt32 dest; + UInt32 src = (((UInt32)data[i + 1] & 0x7) << 19) | + ((UInt32)data[i + 0] << 11) | + (((UInt32)data[i + 3] & 0x7) << 8) | (data[i + 2]); + + src <<= 1; + if (encoding) + dest = ip + (UInt32)i + src; + else + dest = src - (ip + (UInt32)i); + dest >>= 1; + + data[i + 1] = (Byte)(0xF0 | ((dest >> 19) & 0x7)); + data[i + 0] = (Byte)(dest >> 11); + data[i + 3] = (Byte)(0xF8 | ((dest >> 8) & 0x7)); + data[i + 2] = (Byte)dest; + i += 2; + } + } + return i; } SizeT PPC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { - SizeT i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) - { - UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) | - ((UInt32)data[i + 1] << 16) | - ((UInt32)data[i + 2] << 8) | - ((UInt32)data[i + 3] & (~3)); - - UInt32 dest; - if (encoding) - dest = ip + (UInt32)i + src; - else - dest = src - (ip + (UInt32)i); - data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3)); - data[i + 1] = (Byte)(dest >> 16); - data[i + 2] = (Byte)(dest >> 8); - data[i + 3] &= 0x3; - data[i + 3] |= dest; - } - } - return i; + SizeT i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) { + if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) { + UInt32 src = ((UInt32)(data[i + 0] & 3) << 24) | + ((UInt32)data[i + 1] << 16) | ((UInt32)data[i + 2] << 8) | + ((UInt32)data[i + 3] & (~3)); + + UInt32 dest; + if (encoding) + dest = ip + (UInt32)i + src; + else + dest = src - (ip + (UInt32)i); + data[i + 0] = (Byte)(0x48 | ((dest >> 24) & 0x3)); + data[i + 1] = (Byte)(dest >> 16); + data[i + 2] = (Byte)(dest >> 8); + data[i + 3] &= 0x3; + data[i + 3] |= dest; + } + } + return i; } SizeT SPARC_Convert(Byte *data, SizeT size, UInt32 ip, int encoding) { - UInt32 i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || - (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) - { - UInt32 src = - ((UInt32)data[i + 0] << 24) | - ((UInt32)data[i + 1] << 16) | - ((UInt32)data[i + 2] << 8) | - ((UInt32)data[i + 3]); - UInt32 dest; - - src <<= 2; - if (encoding) - dest = ip + i + src; - else - dest = src - (ip + i); - dest >>= 2; - - dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; + UInt32 i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) { + if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || + (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) { + UInt32 src = ((UInt32)data[i + 0] << 24) | ((UInt32)data[i + 1] << 16) | + ((UInt32)data[i + 2] << 8) | ((UInt32)data[i + 3]); + UInt32 dest; - data[i + 0] = (Byte)(dest >> 24); - data[i + 1] = (Byte)(dest >> 16); - data[i + 2] = (Byte)(dest >> 8); - data[i + 3] = (Byte)dest; - } - } - return i; + src <<= 2; + if (encoding) + dest = ip + i + src; + else + dest = src - (ip + i); + dest >>= 2; + + dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | + 0x40000000; + + data[i + 0] = (Byte)(dest >> 24); + data[i + 1] = (Byte)(dest >> 16); + data[i + 2] = (Byte)(dest >> 8); + data[i + 3] = (Byte)dest; + } + } + return i; } diff --git a/fex/7z_C/Bra.h b/fex/7z_C/Bra.h index 5748c1c0..bf4770f5 100644 --- a/fex/7z_C/Bra.h +++ b/fex/7z_C/Bra.h @@ -13,23 +13,23 @@ extern "C" { /* These functions convert relative addresses to absolute addresses in CALL instructions to increase the compression ratio. - + In: data - data buffer size - size of data ip - current virtual Instruction Pinter (IP) value state - state variable for x86 converter encoding - 0 (for decoding), 1 (for encoding) - + Out: state - state variable for x86 converter Returns: The number of processed bytes. If you call these functions with multiple calls, you must start next call with first byte after block of processed bytes. - + Type Endian Alignment LookAhead - + x86 little 1 4 ARMT little 2 2 ARM little 4 0 @@ -53,7 +53,10 @@ in CALL instructions to increase the compression ratio. } */ -#define x86_Convert_Init(state) { state = 0; } +#define x86_Convert_Init(state) \ + { \ + state = 0; \ + } SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding); SizeT ARM_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); SizeT ARMT_Convert(Byte *data, SizeT size, UInt32 ip, int encoding); diff --git a/fex/7z_C/Bra86.c b/fex/7z_C/Bra86.c index 1ee0e709..4761a758 100644 --- a/fex/7z_C/Bra86.c +++ b/fex/7z_C/Bra86.c @@ -5,81 +5,74 @@ #define Test86MSByte(b) ((b) == 0 || (b) == 0xFF) -const Byte kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; -const Byte kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; +const Byte kMaskToAllowedStatus[8] = { 1, 1, 1, 0, 1, 0, 0, 0 }; +const Byte kMaskToBitNumber[8] = { 0, 1, 2, 2, 3, 3, 3, 3 }; SizeT x86_Convert(Byte *data, SizeT size, UInt32 ip, UInt32 *state, int encoding) { - SizeT bufferPos = 0, prevPosT; - UInt32 prevMask = *state & 0x7; - if (size < 5) - return 0; - ip += 5; - prevPosT = (SizeT)0 - 1; + SizeT bufferPos = 0, prevPosT; + UInt32 prevMask = *state & 0x7; + if (size < 5) + return 0; + ip += 5; + prevPosT = (SizeT)0 - 1; - for (;;) - { - Byte *p = data + bufferPos; - Byte *limit = data + size - 4; - for (; p < limit; p++) - if ((*p & 0xFE) == 0xE8) - break; - bufferPos = (SizeT)(p - data); - if (p >= limit) - break; - prevPosT = bufferPos - prevPosT; - if (prevPosT > 3) - prevMask = 0; - else - { - prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; - if (prevMask != 0) - { - Byte b = p[4 - kMaskToBitNumber[prevMask]]; - if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b)) - { - prevPosT = bufferPos; - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - continue; + for (;;) { + Byte *p = data + bufferPos; + Byte *limit = data + size - 4; + for (; p < limit; p++) + if ((*p & 0xFE) == 0xE8) + break; + bufferPos = (SizeT)(p - data); + if (p >= limit) + break; + prevPosT = bufferPos - prevPosT; + if (prevPosT > 3) + prevMask = 0; + else { + prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; + if (prevMask != 0) { + Byte b = p[4 - kMaskToBitNumber[prevMask]]; + if (!kMaskToAllowedStatus[prevMask] || Test86MSByte(b)) { + prevPosT = bufferPos; + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + continue; + } + } + } + prevPosT = bufferPos; + + if (Test86MSByte(p[4])) { + UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | + ((UInt32)p[2] << 8) | ((UInt32)p[1]); + UInt32 dest; + for (;;) { + Byte b; + int index; + if (encoding) + dest = (ip + (UInt32)bufferPos) + src; + else + dest = src - (ip + (UInt32)bufferPos); + if (prevMask == 0) + break; + index = kMaskToBitNumber[prevMask] * 8; + b = (Byte)(dest >> (24 - index)); + if (!Test86MSByte(b)) + break; + src = dest ^ ((1 << (32 - index)) - 1); + } + p[4] = (Byte)(~(((dest >> 24) & 1) - 1)); + p[3] = (Byte)(dest >> 16); + p[2] = (Byte)(dest >> 8); + p[1] = (Byte)dest; + bufferPos += 5; + } else { + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + } } - } - } - prevPosT = bufferPos; - - if (Test86MSByte(p[4])) - { - UInt32 src = ((UInt32)p[4] << 24) | ((UInt32)p[3] << 16) | ((UInt32)p[2] << 8) | ((UInt32)p[1]); - UInt32 dest; - for (;;) - { - Byte b; - int index; - if (encoding) - dest = (ip + (UInt32)bufferPos) + src; - else - dest = src - (ip + (UInt32)bufferPos); - if (prevMask == 0) - break; - index = kMaskToBitNumber[prevMask] * 8; - b = (Byte)(dest >> (24 - index)); - if (!Test86MSByte(b)) - break; - src = dest ^ ((1 << (32 - index)) - 1); - } - p[4] = (Byte)(~(((dest >> 24) & 1) - 1)); - p[3] = (Byte)(dest >> 16); - p[2] = (Byte)(dest >> 8); - p[1] = (Byte)dest; - bufferPos += 5; - } - else - { - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - } - } - prevPosT = bufferPos - prevPosT; - *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); - return bufferPos; + prevPosT = bufferPos - prevPosT; + *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); + return bufferPos; } diff --git a/fex/7z_C/CpuArch.c b/fex/7z_C/CpuArch.c index 689109ea..46ad0713 100644 --- a/fex/7z_C/CpuArch.c +++ b/fex/7z_C/CpuArch.c @@ -12,162 +12,157 @@ #if defined(USE_ASM) && !defined(MY_CPU_AMD64) static UInt32 CheckFlag(UInt32 flag) { - #ifdef _MSC_VER - __asm pushfd; - __asm pop EAX; - __asm mov EDX, EAX; - __asm xor EAX, flag; - __asm push EAX; - __asm popfd; - __asm pushfd; - __asm pop EAX; - __asm xor EAX, EDX; - __asm push EDX; - __asm popfd; - __asm and flag, EAX; - #else - __asm__ __volatile__ ( - "pushf\n\t" - "pop %%EAX\n\t" - "movl %%EAX,%%EDX\n\t" - "xorl %0,%%EAX\n\t" - "push %%EAX\n\t" - "popf\n\t" - "pushf\n\t" - "pop %%EAX\n\t" - "xorl %%EDX,%%EAX\n\t" - "push %%EDX\n\t" - "popf\n\t" - "andl %%EAX, %0\n\t": - "=c" (flag) : "c" (flag)); - #endif - return flag; +#ifdef _MSC_VER + __asm pushfd; + __asm pop EAX; + __asm mov EDX, EAX; + __asm xor EAX, flag; + __asm push EAX; + __asm popfd; + __asm pushfd; + __asm pop EAX; + __asm xor EAX, EDX; + __asm push EDX; + __asm popfd; + __asm and flag, EAX; +#else + __asm__ __volatile__( + "pushf\n\t" + "pop %%EAX\n\t" + "movl %%EAX,%%EDX\n\t" + "xorl %0,%%EAX\n\t" + "push %%EAX\n\t" + "popf\n\t" + "pushf\n\t" + "pop %%EAX\n\t" + "xorl %%EDX,%%EAX\n\t" + "push %%EDX\n\t" + "popf\n\t" + "andl %%EAX, %0\n\t" + : "=c"(flag) + : "c"(flag)); +#endif + return flag; } -#define CHECK_CPUID_IS_SUPPORTED if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) return False; +#define CHECK_CPUID_IS_SUPPORTED \ + if (CheckFlag(1 << 18) == 0 || CheckFlag(1 << 21) == 0) \ + return False; #else #define CHECK_CPUID_IS_SUPPORTED #endif static void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d) { - #ifdef USE_ASM +#ifdef USE_ASM - #ifdef _MSC_VER +#ifdef _MSC_VER - UInt32 a2, b2, c2, d2; - __asm xor EBX, EBX; - __asm xor ECX, ECX; - __asm xor EDX, EDX; - __asm mov EAX, function; - __asm cpuid; - __asm mov a2, EAX; - __asm mov b2, EBX; - __asm mov c2, ECX; - __asm mov d2, EDX; + UInt32 a2, b2, c2, d2; + __asm xor EBX, EBX; + __asm xor ECX, ECX; + __asm xor EDX, EDX; + __asm mov EAX, function; + __asm cpuid; + __asm mov a2, EAX; + __asm mov b2, EBX; + __asm mov c2, ECX; + __asm mov d2, EDX; - *a = a2; - *b = b2; - *c = c2; - *d = d2; + *a = a2; + *b = b2; + *c = c2; + *d = d2; - #else +#else - // Mac cross-compile compiler: - // can't find register in class 'BREG' while reloading 'asm' - // so use class 'r' register var binding - register _b asm("%bx"); - __asm__ __volatile__ ( - "cpuid" - : "=a" (*a) , - "=r" (_b) , - "=c" (*c) , - "=d" (*d) - : "0" (function)) ; - *b = _b; + // Mac cross-compile compiler: + // can't find register in class 'BREG' while reloading 'asm' + // so use class 'r' register var binding + register _b asm("%bx"); + __asm__ __volatile__("cpuid" : "=a"(*a), "=r"(_b), "=c"(*c), "=d"(*d) : "0"(function)); + *b = _b; - #endif - - #else +#endif - int CPUInfo[4]; - __cpuid(CPUInfo, function); - *a = CPUInfo[0]; - *b = CPUInfo[1]; - *c = CPUInfo[2]; - *d = CPUInfo[3]; +#else - #endif + int CPUInfo[4]; + __cpuid(CPUInfo, function); + *a = CPUInfo[0]; + *b = CPUInfo[1]; + *c = CPUInfo[2]; + *d = CPUInfo[3]; + +#endif } Bool x86cpuid_CheckAndRead(Cx86cpuid *p) { - CHECK_CPUID_IS_SUPPORTED - MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]); - MyCPUID(1, &p->ver, &p->b, &p->c, &p->d); - return True; + CHECK_CPUID_IS_SUPPORTED + MyCPUID(0, &p->maxFunc, &p->vendor[0], &p->vendor[2], &p->vendor[1]); + MyCPUID(1, &p->ver, &p->b, &p->c, &p->d); + return True; } -static UInt32 kVendors[][3] = -{ - { 0x756E6547, 0x49656E69, 0x6C65746E}, - { 0x68747541, 0x69746E65, 0x444D4163}, - { 0x746E6543, 0x48727561, 0x736C7561} -}; +static UInt32 kVendors[][3] = { { 0x756E6547, 0x49656E69, 0x6C65746E }, + { 0x68747541, 0x69746E65, 0x444D4163 }, + { 0x746E6543, 0x48727561, 0x736C7561 } }; int x86cpuid_GetFirm(const Cx86cpuid *p) { - unsigned i; - for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) - { - const UInt32 *v = kVendors[i]; - if (v[0] == p->vendor[0] && - v[1] == p->vendor[1] && - v[2] == p->vendor[2]) - return (int)i; - } - return -1; + unsigned i; + for (i = 0; i < sizeof(kVendors) / sizeof(kVendors[i]); i++) { + const UInt32 *v = kVendors[i]; + if (v[0] == p->vendor[0] && v[1] == p->vendor[1] && v[2] == p->vendor[2]) + return (int)i; + } + return -1; } Bool CPU_Is_InOrder() { - Cx86cpuid p; - int firm; - UInt32 family, model; - if (!x86cpuid_CheckAndRead(&p)) - return True; - family = x86cpuid_GetFamily(&p); - model = x86cpuid_GetModel(&p); - firm = x86cpuid_GetFirm(&p); - switch (firm) - { - case CPU_FIRM_INTEL: return (family < 6 || (family == 6 && model == 0x100C)); - case CPU_FIRM_AMD: return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); - case CPU_FIRM_VIA: return (family < 6 || (family == 6 && model < 0xF)); - } - return True; + Cx86cpuid p; + int firm; + UInt32 family, model; + if (!x86cpuid_CheckAndRead(&p)) + return True; + family = x86cpuid_GetFamily(&p); + model = x86cpuid_GetModel(&p); + firm = x86cpuid_GetFirm(&p); + switch (firm) { + case CPU_FIRM_INTEL: + return (family < 6 || (family == 6 && model == 0x100C)); + case CPU_FIRM_AMD: + return (family < 5 || (family == 5 && (model < 6 || model == 0xA))); + case CPU_FIRM_VIA: + return (family < 6 || (family == 6 && model < 0xF)); + } + return True; } #if !defined(MY_CPU_AMD64) && defined(_WIN32) static Bool CPU_Sys_Is_SSE_Supported() { - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - if (!GetVersionEx(&vi)) - return False; - return (vi.dwMajorVersion >= 5); + OSVERSIONINFO vi; + vi.dwOSVersionInfoSize = sizeof(vi); + if (!GetVersionEx(&vi)) + return False; + return (vi.dwMajorVersion >= 5); } -#define CHECK_SYS_SSE_SUPPORT if (!CPU_Sys_Is_SSE_Supported()) return False; +#define CHECK_SYS_SSE_SUPPORT \ + if (!CPU_Sys_Is_SSE_Supported()) \ + return False; #else #define CHECK_SYS_SSE_SUPPORT #endif Bool CPU_Is_Aes_Supported() { - Cx86cpuid p; - CHECK_SYS_SSE_SUPPORT - if (!x86cpuid_CheckAndRead(&p)) - return False; - return (p.c >> 25) & 1; + Cx86cpuid p; + CHECK_SYS_SSE_SUPPORT + if (!x86cpuid_CheckAndRead(&p)) + return False; + return (p.c >> 25) & 1; } #endif diff --git a/fex/7z_C/CpuArch.h b/fex/7z_C/CpuArch.h index 01930c7e..16299073 100644 --- a/fex/7z_C/CpuArch.h +++ b/fex/7z_C/CpuArch.h @@ -10,7 +10,8 @@ EXTERN_C_BEGIN /* MY_CPU_LE means that CPU is LITTLE ENDIAN. -If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE ENDIAN). +If MY_CPU_LE is not defined, we don't know about that property of platform (it can be LITTLE +ENDIAN). MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. @@ -48,7 +49,8 @@ If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of pla #define MY_CPU_LE_UNALIGN #endif -#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__) +#if defined(MY_CPU_X86_OR_AMD64) || defined(MY_CPU_ARM_LE) || defined(MY_CPU_IA64_LE) || \ + defined(__ARMEL__) || defined(__MIPSEL__) || defined(__LITTLE_ENDIAN__) #define MY_CPU_LE #endif @@ -73,27 +75,34 @@ Stop_Compiling_Bad_Endian #define GetUi16(p) (((const Byte *)(p))[0] | ((UInt16)((const Byte *)(p))[1] << 8)) -#define GetUi32(p) ( \ - ((const Byte *)(p))[0] | \ - ((UInt32)((const Byte *)(p))[1] << 8) | \ - ((UInt32)((const Byte *)(p))[2] << 16) | \ - ((UInt32)((const Byte *)(p))[3] << 24)) +#define GetUi32(p) \ + (((const Byte *)(p))[0] | ((UInt32)((const Byte *)(p))[1] << 8) | \ + ((UInt32)((const Byte *)(p))[2] << 16) | ((UInt32)((const Byte *)(p))[3] << 24)) #define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32)) -#define SetUi16(p, d) { UInt32 _x_ = (d); \ - ((Byte *)(p))[0] = (Byte)_x_; \ - ((Byte *)(p))[1] = (Byte)(_x_ >> 8); } +#define SetUi16(p, d) \ + { \ + UInt32 _x_ = (d); \ + ((Byte *)(p))[0] = (Byte)_x_; \ + ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \ + } -#define SetUi32(p, d) { UInt32 _x_ = (d); \ - ((Byte *)(p))[0] = (Byte)_x_; \ - ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \ - ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \ - ((Byte *)(p))[3] = (Byte)(_x_ >> 24); } +#define SetUi32(p, d) \ + { \ + UInt32 _x_ = (d); \ + ((Byte *)(p))[0] = (Byte)_x_; \ + ((Byte *)(p))[1] = (Byte)(_x_ >> 8); \ + ((Byte *)(p))[2] = (Byte)(_x_ >> 16); \ + ((Byte *)(p))[3] = (Byte)(_x_ >> 24); \ + } -#define SetUi64(p, d) { UInt64 _x64_ = (d); \ - SetUi32(p, (UInt32)_x64_); \ - SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); } +#define SetUi64(p, d) \ + { \ + UInt64 _x64_ = (d); \ + SetUi32(p, (UInt32)_x64_); \ + SetUi32(((Byte *)(p)) + 4, (UInt32)(_x64_ >> 32)); \ + } #endif @@ -106,11 +115,9 @@ Stop_Compiling_Bad_Endian #else -#define GetBe32(p) ( \ - ((UInt32)((const Byte *)(p))[0] << 24) | \ - ((UInt32)((const Byte *)(p))[1] << 16) | \ - ((UInt32)((const Byte *)(p))[2] << 8) | \ - ((const Byte *)(p))[3] ) +#define GetBe32(p) \ + (((UInt32)((const Byte *)(p))[0] << 24) | ((UInt32)((const Byte *)(p))[1] << 16) | \ + ((UInt32)((const Byte *)(p))[2] << 8) | ((const Byte *)(p))[3]) #define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4)) @@ -118,25 +125,18 @@ Stop_Compiling_Bad_Endian #define GetBe16(p) (((UInt16)((const Byte *)(p))[0] << 8) | ((const Byte *)(p))[1]) - #ifdef MY_CPU_X86_OR_AMD64 -typedef struct -{ - UInt32 maxFunc; - UInt32 vendor[3]; - UInt32 ver; - UInt32 b; - UInt32 c; - UInt32 d; + typedef struct { + UInt32 maxFunc; + UInt32 vendor[3]; + UInt32 ver; + UInt32 b; + UInt32 c; + UInt32 d; } Cx86cpuid; -enum -{ - CPU_FIRM_INTEL, - CPU_FIRM_AMD, - CPU_FIRM_VIA -}; +enum { CPU_FIRM_INTEL, CPU_FIRM_AMD, CPU_FIRM_VIA }; Bool x86cpuid_CheckAndRead(Cx86cpuid *p); int x86cpuid_GetFirm(const Cx86cpuid *p); diff --git a/fex/7z_C/Lzma2Dec.c b/fex/7z_C/Lzma2Dec.c index 7ea1cc95..309a5fd2 100644 --- a/fex/7z_C/Lzma2Dec.c +++ b/fex/7z_C/Lzma2Dec.c @@ -36,7 +36,7 @@ #define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) #define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p) & 1)) << ((p) / 2 + 11)) +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((UInt32)2 | ((p)&1)) << ((p) / 2 + 11)) #ifdef SHOW_DEBUG_INFO #define PRF(x) x @@ -44,313 +44,301 @@ #define PRF(x) #endif -typedef enum -{ - LZMA2_STATE_CONTROL, - LZMA2_STATE_UNPACK0, - LZMA2_STATE_UNPACK1, - LZMA2_STATE_PACK0, - LZMA2_STATE_PACK1, - LZMA2_STATE_PROP, - LZMA2_STATE_DATA, - LZMA2_STATE_DATA_CONT, - LZMA2_STATE_FINISHED, - LZMA2_STATE_ERROR +typedef enum { + LZMA2_STATE_CONTROL, + LZMA2_STATE_UNPACK0, + LZMA2_STATE_UNPACK1, + LZMA2_STATE_PACK0, + LZMA2_STATE_PACK1, + LZMA2_STATE_PROP, + LZMA2_STATE_DATA, + LZMA2_STATE_DATA_CONT, + LZMA2_STATE_FINISHED, + LZMA2_STATE_ERROR } ELzma2State; static SRes Lzma2Dec_GetOldProps(Byte prop, Byte *props) { - UInt32 dicSize; - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); - props[0] = (Byte)LZMA2_LCLP_MAX; - props[1] = (Byte)(dicSize); - props[2] = (Byte)(dicSize >> 8); - props[3] = (Byte)(dicSize >> 16); - props[4] = (Byte)(dicSize >> 24); - return SZ_OK; + UInt32 dicSize; + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); + props[0] = (Byte)LZMA2_LCLP_MAX; + props[1] = (Byte)(dicSize); + props[2] = (Byte)(dicSize >> 8); + props[3] = (Byte)(dicSize >> 16); + props[4] = (Byte)(dicSize >> 24); + return SZ_OK; } SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc) { - Byte props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); + Byte props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); } SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc) { - Byte props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); + Byte props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); } void Lzma2Dec_Init(CLzma2Dec *p) { - p->state = LZMA2_STATE_CONTROL; - p->needInitDic = True; - p->needInitState = True; - p->needInitProp = True; - LzmaDec_Init(&p->decoder); + p->state = LZMA2_STATE_CONTROL; + p->needInitDic = True; + p->needInitState = True; + p->needInitProp = True; + LzmaDec_Init(&p->decoder); } static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, Byte b) { - switch(p->state) - { - case LZMA2_STATE_CONTROL: - p->control = b; - PRF(printf("\n %4X ", p->decoder.dicPos)); - PRF(printf(" %2X", b)); - if (p->control == 0) - return LZMA2_STATE_FINISHED; - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if ((p->control & 0x7F) > 2) - return LZMA2_STATE_ERROR; - p->unpackSize = 0; - } - else - p->unpackSize = (UInt32)(p->control & 0x1F) << 16; - return LZMA2_STATE_UNPACK0; - - case LZMA2_STATE_UNPACK0: - p->unpackSize |= (UInt32)b << 8; - return LZMA2_STATE_UNPACK1; - - case LZMA2_STATE_UNPACK1: - p->unpackSize |= (UInt32)b; - p->unpackSize++; - PRF(printf(" %8d", p->unpackSize)); - return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - - case LZMA2_STATE_PACK0: - p->packSize = (UInt32)b << 8; - return LZMA2_STATE_PACK1; + switch (p->state) { + case LZMA2_STATE_CONTROL: + p->control = b; + PRF(printf("\n %4X ", p->decoder.dicPos)); + PRF(printf(" %2X", b)); + if (p->control == 0) + return LZMA2_STATE_FINISHED; + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) { + if ((p->control & 0x7F) > 2) + return LZMA2_STATE_ERROR; + p->unpackSize = 0; + } else + p->unpackSize = (UInt32)(p->control & 0x1F) << 16; + return LZMA2_STATE_UNPACK0; - case LZMA2_STATE_PACK1: - p->packSize |= (UInt32)b; - p->packSize++; - PRF(printf(" %8d", p->packSize)); - return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: - (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); + case LZMA2_STATE_UNPACK0: + p->unpackSize |= (UInt32)b << 8; + return LZMA2_STATE_UNPACK1; - case LZMA2_STATE_PROP: - { - int lc, lp; - if (b >= (9 * 5 * 5)) + case LZMA2_STATE_UNPACK1: + p->unpackSize |= (UInt32)b; + p->unpackSize++; + PRF(printf(" %8d", p->unpackSize)); + return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; + + case LZMA2_STATE_PACK0: + p->packSize = (UInt32)b << 8; + return LZMA2_STATE_PACK1; + + case LZMA2_STATE_PACK1: + p->packSize |= (UInt32)b; + p->packSize++; + PRF(printf(" %8d", p->packSize)); + return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) + ? LZMA2_STATE_PROP + : (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); + + case LZMA2_STATE_PROP: { + int lc, lp; + if (b >= (9 * 5 * 5)) + return LZMA2_STATE_ERROR; + lc = b % 9; + b /= 9; + p->decoder.prop.pb = b / 5; + lp = b % 5; + if (lc + lp > LZMA2_LCLP_MAX) + return LZMA2_STATE_ERROR; + p->decoder.prop.lc = lc; + p->decoder.prop.lp = lp; + p->needInitProp = False; + return LZMA2_STATE_DATA; + } + } return LZMA2_STATE_ERROR; - lc = b % 9; - b /= 9; - p->decoder.prop.pb = b / 5; - lp = b % 5; - if (lc + lp > LZMA2_LCLP_MAX) - return LZMA2_STATE_ERROR; - p->decoder.prop.lc = lc; - p->decoder.prop.lp = lp; - p->needInitProp = False; - return LZMA2_STATE_DATA; - } - } - return LZMA2_STATE_ERROR; } static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const Byte *src, SizeT size) { - memcpy(p->dic + p->dicPos, src, size); - p->dicPos += size; - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) - p->checkDicSize = p->prop.dicSize; - p->processedPos += (UInt32)size; + memcpy(p->dic + p->dicPos, src, size); + p->dicPos += size; + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) + p->checkDicSize = p->prop.dicSize; + p->processedPos += (UInt32)size; } void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState); -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT inSize = *srcLen; - *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; + SizeT inSize = *srcLen; + *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; - while (p->state != LZMA2_STATE_FINISHED) - { - SizeT dicPos = p->decoder.dicPos; - if (p->state == LZMA2_STATE_ERROR) - return SZ_ERROR_DATA; - if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; + while (p->state != LZMA2_STATE_FINISHED) { + SizeT dicPos = p->decoder.dicPos; + if (p->state == LZMA2_STATE_ERROR) + return SZ_ERROR_DATA; + if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) { + if (*srcLen == inSize) { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + (*srcLen)++; + p->state = Lzma2Dec_UpdateState(p, *src++); + continue; + } + { + SizeT destSizeCur = dicLimit - dicPos; + SizeT srcSizeCur = inSize - *srcLen; + ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; + + if (p->unpackSize <= destSizeCur) { + destSizeCur = (SizeT)p->unpackSize; + curFinishMode = LZMA_FINISH_END; + } + + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) { + if (*srcLen == inSize) { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + if (p->state == LZMA2_STATE_DATA) { + Bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); + if (initDic) + p->needInitProp = p->needInitState = True; + else if (p->needInitDic) + return SZ_ERROR_DATA; + p->needInitDic = False; + LzmaDec_InitDicAndState(&p->decoder, initDic, False); + } + + if (srcSizeCur > destSizeCur) + srcSizeCur = destSizeCur; + + if (srcSizeCur == 0) + return SZ_ERROR_DATA; + + LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->unpackSize -= (UInt32)srcSizeCur; + p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL + : LZMA2_STATE_DATA_CONT; + } else { + SizeT outSizeProcessed; + SRes res; + + if (p->state == LZMA2_STATE_DATA) { + int mode = LZMA2_GET_LZMA_MODE(p); + Bool initDic = (mode == 3); + Bool initState = (mode > 0); + if ((!initDic && p->needInitDic) || + (!initState && p->needInitState)) + return SZ_ERROR_DATA; + + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); + p->needInitDic = False; + p->needInitState = False; + p->state = LZMA2_STATE_DATA_CONT; + } + if (srcSizeCur > p->packSize) + srcSizeCur = (SizeT)p->packSize; + + res = LzmaDec_DecodeToDic(&p->decoder, + dicPos + destSizeCur, + src, + &srcSizeCur, + curFinishMode, + status); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->packSize -= (UInt32)srcSizeCur; + + outSizeProcessed = p->decoder.dicPos - dicPos; + p->unpackSize -= (UInt32)outSizeProcessed; + + RINOK(res); + if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) + return res; + + if (srcSizeCur == 0 && outSizeProcessed == 0) { + if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || + p->unpackSize != 0 || p->packSize != 0) + return SZ_ERROR_DATA; + p->state = LZMA2_STATE_CONTROL; + } + if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) + *status = LZMA_STATUS_NOT_FINISHED; + } + } + } + *status = LZMA_STATUS_FINISHED_WITH_MARK; return SZ_OK; - } - (*srcLen)++; - p->state = Lzma2Dec_UpdateState(p, *src++); - continue; - } - { - SizeT destSizeCur = dicLimit - dicPos; - SizeT srcSizeCur = inSize - *srcLen; - ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - - if (p->unpackSize <= destSizeCur) - { - destSizeCur = (SizeT)p->unpackSize; - curFinishMode = LZMA_FINISH_END; - } +} - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + SizeT outSize = *destLen, inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) { + SizeT srcSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->decoder.dicPos == p->decoder.dicBufSize) + p->decoder.dicPos = 0; + dicPos = p->decoder.dicPos; + if (outSize > p->decoder.dicBufSize - dicPos) { + outSizeCur = p->decoder.dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } else { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); + src += srcSizeCur; + inSize -= srcSizeCur; + *srcLen += srcSizeCur; + outSizeCur = p->decoder.dicPos - dicPos; + memcpy(dest, p->decoder.dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; } +} - if (p->state == LZMA2_STATE_DATA) - { - Bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); - if (initDic) - p->needInitProp = p->needInitState = True; - else if (p->needInitDic) - return SZ_ERROR_DATA; - p->needInitDic = False; - LzmaDec_InitDicAndState(&p->decoder, initDic, False); - } - - if (srcSizeCur > destSizeCur) - srcSizeCur = destSizeCur; - - if (srcSizeCur == 0) - return SZ_ERROR_DATA; - - LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->unpackSize -= (UInt32)srcSizeCur; - p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; - } - else - { - SizeT outSizeProcessed; +SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, Byte prop, + ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) +{ + CLzma2Dec decoder; SRes res; + SizeT outSize = *destLen, inSize = *srcLen; + Byte props[LZMA_PROPS_SIZE]; - if (p->state == LZMA2_STATE_DATA) - { - int mode = LZMA2_GET_LZMA_MODE(p); - Bool initDic = (mode == 3); - Bool initState = (mode > 0); - if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) - return SZ_ERROR_DATA; - - LzmaDec_InitDicAndState(&p->decoder, initDic, initState); - p->needInitDic = False; - p->needInitState = False; - p->state = LZMA2_STATE_DATA_CONT; - } - if (srcSizeCur > p->packSize) - srcSizeCur = (SizeT)p->packSize; - - res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->packSize -= (UInt32)srcSizeCur; + Lzma2Dec_Construct(&decoder); - outSizeProcessed = p->decoder.dicPos - dicPos; - p->unpackSize -= (UInt32)outSizeProcessed; + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + decoder.decoder.dic = dest; + decoder.decoder.dicBufSize = outSize; - RINOK(res); - if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) - return res; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); - if (srcSizeCur == 0 && outSizeProcessed == 0) - { - if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || - p->unpackSize != 0 || p->packSize != 0) - return SZ_ERROR_DATA; - p->state = LZMA2_STATE_CONTROL; - } - if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) - *status = LZMA_STATUS_NOT_FINISHED; - } - } - } - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; -} - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT outSize = *destLen, inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - SizeT srcSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->decoder.dicPos == p->decoder.dicBufSize) - p->decoder.dicPos = 0; - dicPos = p->decoder.dicPos; - if (outSize > p->decoder.dicBufSize - dicPos) - { - outSizeCur = p->decoder.dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); - src += srcSizeCur; - inSize -= srcSizeCur; - *srcLen += srcSizeCur; - outSizeCur = p->decoder.dicPos - dicPos; - memcpy(dest, p->decoder.dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzma2Dec decoder; - SRes res; - SizeT outSize = *destLen, inSize = *srcLen; - Byte props[LZMA_PROPS_SIZE]; - - Lzma2Dec_Construct(&decoder); - - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - decoder.decoder.dic = dest; - decoder.decoder.dicBufSize = outSize; - - RINOK(Lzma2Dec_GetOldProps(prop, props)); - RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); - - *srcLen = inSize; - res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); - *destLen = decoder.decoder.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - LzmaDec_FreeProbs(&decoder.decoder, alloc); - return res; + *srcLen = inSize; + res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); + *destLen = decoder.decoder.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + LzmaDec_FreeProbs(&decoder.decoder, alloc); + return res; } diff --git a/fex/7z_C/Lzma2Dec.h b/fex/7z_C/Lzma2Dec.h index 6bc07bbc..570cedbb 100644 --- a/fex/7z_C/Lzma2Dec.h +++ b/fex/7z_C/Lzma2Dec.h @@ -12,16 +12,15 @@ extern "C" { /* ---------- State Interface ---------- */ -typedef struct -{ - CLzmaDec decoder; - UInt32 packSize; - UInt32 unpackSize; - int state; - Byte control; - Bool needInitDic; - Bool needInitState; - Bool needInitProp; +typedef struct { + CLzmaDec decoder; + UInt32 packSize; + UInt32 unpackSize; + int state; + Byte control; + Bool needInitDic; + Bool needInitState; + Bool needInitProp; } CLzma2Dec; #define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) @@ -32,7 +31,6 @@ SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); SRes Lzma2Dec_Allocate(CLzma2Dec *p, Byte prop, ISzAlloc *alloc); void Lzma2Dec_Init(CLzma2Dec *p); - /* finishMode: It has meaning only if the decoding reaches output limit (*destLen or dicLimit). @@ -48,12 +46,11 @@ Returns: SZ_ERROR_DATA - Data error */ -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status); +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- One Call Interface ---------- */ @@ -74,8 +71,8 @@ Returns: SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). */ -SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - Byte prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); +SRes Lzma2Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, Byte prop, + ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); #ifdef __cplusplus } diff --git a/fex/7z_C/LzmaDec.c b/fex/7z_C/LzmaDec.c index 2036761b..2be5d8bc 100644 --- a/fex/7z_C/LzmaDec.c +++ b/fex/7z_C/LzmaDec.c @@ -14,48 +14,109 @@ #define RC_INIT_SIZE 5 -#define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } +#define NORMALIZE \ + if (range < kTopValue) { \ + range <<= 8; \ + code = (code << 8) | (*buf++); \ + } -#define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) -#define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); -#define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ - { UPDATE_0(p); i = (i + i); A0; } else \ - { UPDATE_1(p); i = (i + i) + 1; A1; } -#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) +#define IF_BIT_0(p) \ + ttt = *(p); \ + NORMALIZE; \ + bound = (range >> kNumBitModelTotalBits) * ttt; \ + if (code < bound) +#define UPDATE_0(p) \ + range = bound; \ + *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define UPDATE_1(p) \ + range -= bound; \ + code -= bound; \ + *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); +#define GET_BIT2(p, i, A0, A1) \ + IF_BIT_0(p) \ + { \ + UPDATE_0(p); \ + i = (i + i); \ + A0; \ + } \ + else \ + { \ + UPDATE_1(p); \ + i = (i + i) + 1; \ + A1; \ + } +#define GET_BIT(p, i) GET_BIT2(p, i, ;, ;) -#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } -#define TREE_DECODE(probs, limit, i) \ - { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } +#define TREE_GET_BIT(probs, i) \ + { \ + GET_BIT((probs + i), i); \ + } +#define TREE_DECODE(probs, limit, i) \ + { \ + i = 1; \ + do { \ + TREE_GET_BIT(probs, i); \ + } while (i < limit); \ + i -= limit; \ + } /* #define _LZMA_SIZE_OPT */ #ifdef _LZMA_SIZE_OPT #define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) #else -#define TREE_6_DECODE(probs, i) \ - { i = 1; \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - i -= 0x40; } +#define TREE_6_DECODE(probs, i) \ + { \ + i = 1; \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + i -= 0x40; \ + } #endif -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } +#define NORMALIZE_CHECK \ + if (range < kTopValue) { \ + if (buf >= bufLimit) \ + return DUMMY_ERROR; \ + range <<= 8; \ + code = (code << 8) | (*buf++); \ + } -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) +#define IF_BIT_0_CHECK(p) \ + ttt = *(p); \ + NORMALIZE_CHECK; \ + bound = (range >> kNumBitModelTotalBits) * ttt; \ + if (code < bound) #define UPDATE_0_CHECK range = bound; -#define UPDATE_1_CHECK range -= bound; code -= bound; -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ - { UPDATE_0_CHECK; i = (i + i); A0; } else \ - { UPDATE_1_CHECK; i = (i + i) + 1; A1; } -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) -#define TREE_DECODE_CHECK(probs, limit, i) \ - { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } - +#define UPDATE_1_CHECK \ + range -= bound; \ + code -= bound; +#define GET_BIT2_CHECK(p, i, A0, A1) \ + IF_BIT_0_CHECK(p) \ + { \ + UPDATE_0_CHECK; \ + i = (i + i); \ + A0; \ + } \ + else \ + { \ + UPDATE_1_CHECK; \ + i = (i + i) + 1; \ + A1; \ + } +#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ;, ;) +#define TREE_DECODE_CHECK(probs, limit, i) \ + { \ + i = 1; \ + do { \ + GET_BIT_CHECK(probs + i, i) \ + } while (i < limit); \ + i -= limit; \ + } #define kNumPosBitsMax 4 #define kNumPosStatesMax (1 << kNumPosBitsMax) @@ -74,7 +135,6 @@ #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) #define kNumLenProbs (LenHigh + kLenNumHighSymbols) - #define kNumStates 12 #define kNumLitStates 7 @@ -89,7 +149,8 @@ #define kAlignTableSize (1 << kNumAlignBits) #define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) +#define kMatchSpecLenStart \ + (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) #define IsMatch 0 #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) @@ -115,885 +176,845 @@ StopCompilingDueBUG #define LZMA_DIC_MIN (1 << 12) -/* First LZMA-symbol is always decoded. -And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization -Out: - Result: - SZ_OK - OK - SZ_ERROR_DATA - Error - p->remainLen: - < kMatchSpecLenStart : normal remain - = kMatchSpecLenStart : finished - = kMatchSpecLenStart + 1 : Flush marker - = kMatchSpecLenStart + 2 : State Init Marker -*/ + /* First LZMA-symbol is always decoded. + And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization + Out: + Result: + SZ_OK - OK + SZ_ERROR_DATA - Error + p->remainLen: + < kMatchSpecLenStart : normal remain + = kMatchSpecLenStart : finished + = kMatchSpecLenStart + 1 : Flush marker + = kMatchSpecLenStart + 2 : State Init Marker + */ -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) + static int MY_FAST_CALL + LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) { - CLzmaProb *probs = p->probs; + CLzmaProb *probs = p->probs; - unsigned state = p->state; - UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; - unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; - unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; - unsigned lc = p->prop.lc; + unsigned state = p->state; + UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; + unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; + unsigned lc = p->prop.lc; - Byte *dic = p->dic; - SizeT dicBufSize = p->dicBufSize; - SizeT dicPos = p->dicPos; - - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; - unsigned len = 0; + Byte *dic = p->dic; + SizeT dicBufSize = p->dicBufSize; + SizeT dicPos = p->dicPos; - const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; + UInt32 processedPos = p->processedPos; + UInt32 checkDicSize = p->checkDicSize; + unsigned len = 0; - do - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = processedPos & pbMask; + const Byte *buf = p->buf; + UInt32 range = p->range; + UInt32 code = p->code; - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0(prob) - { - unsigned symbol; - UPDATE_0(prob); - prob = probs + Literal; - if (checkDicSize != 0 || processedPos != 0) - prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + - (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); + do { + CLzmaProb *prob; + UInt32 bound; + unsigned ttt; + unsigned posState = processedPos & pbMask; - if (state < kNumLitStates) - { - state -= (state < 4) ? state : 3; - symbol = 1; - do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; - symbol = 1; - do - { - unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - dic[dicPos++] = (Byte)symbol; - processedPos++; - continue; - } - else - { - UPDATE_1(prob); - prob = probs + IsRep + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - state += kNumStates; - prob = probs + LenCoder; - } - else - { - UPDATE_1(prob); - if (checkDicSize == 0 && processedPos == 0) - return SZ_ERROR_DATA; - prob = probs + IsRepG0 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0(prob) - { - UPDATE_0(prob); - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - processedPos++; - state = state < kNumLitStates ? 9 : 11; - continue; - } - UPDATE_1(prob); - } - else - { - UInt32 distance; - UPDATE_1(prob); - prob = probs + IsRepG1 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep1; - } - else - { - UPDATE_1(prob); - prob = probs + IsRepG2 + state; - IF_BIT_0(prob) - { - UPDATE_0(prob); - distance = rep2; - } - else - { - UPDATE_1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = (1 << kLenNumLowBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenChoice2; - IF_BIT_0(probLen) - { - UPDATE_0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = (1 << kLenNumMidBits); - } - else - { - UPDATE_1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = (1 << kLenNumHighBits); - } - } - TREE_DECODE(probLen, limit, len); - len += offset; - } + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + IF_BIT_0(prob) + { + unsigned symbol; + UPDATE_0(prob); + prob = probs + Literal; + if (checkDicSize != 0 || processedPos != 0) + prob += + (LZMA_LIT_SIZE * + (((processedPos & lpMask) << lc) + + (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); - if (state >= kNumStates) - { - UInt32 distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance); - if (distance >= kStartPosModelIndex) - { - unsigned posSlot = (unsigned)distance; - int numDirectBits = (int)(((distance >> 1) - 1)); - distance = (2 | (distance & 1)); - if (posSlot < kEndPosModelIndex) - { - distance <<= numDirectBits; - prob = probs + SpecPos + distance - posSlot - 1; - { - UInt32 mask = 1; - unsigned i = 1; - do - { - GET_BIT2(prob + i, i, ; , distance |= mask); - mask <<= 1; - } - while (--numDirectBits != 0); - } - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE - range >>= 1; - - { - UInt32 t; - code -= range; - t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ - distance = (distance << 1) + (t + 1); - code += range & t; - } - /* - distance <<= 1; - if (code >= range) - { - code -= range; - distance |= 1; - } - */ - } - while (--numDirectBits != 0); - prob = probs + Align; - distance <<= kNumAlignBits; - { - unsigned i = 1; - GET_BIT2(prob + i, i, ; , distance |= 1); - GET_BIT2(prob + i, i, ; , distance |= 2); - GET_BIT2(prob + i, i, ; , distance |= 4); - GET_BIT2(prob + i, i, ; , distance |= 8); - } - if (distance == (UInt32)0xFFFFFFFF) - { - len += kMatchSpecLenStart; - state -= kNumStates; - break; - } - } - } - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance + 1; - if (checkDicSize == 0) - { - if (distance >= processedPos) - return SZ_ERROR_DATA; - } - else if (distance >= checkDicSize) - return SZ_ERROR_DATA; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - } + if (state < kNumLitStates) { + state -= (state < 4) ? state : 3; + symbol = 1; + do { + GET_BIT(prob + symbol, symbol) + } while (symbol < 0x100); + } else { + unsigned matchByte = + p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + unsigned offs = 0x100; + state -= (state < 10) ? 3 : 6; + symbol = 1; + do { + unsigned bit; + CLzmaProb *probLit; + matchByte <<= 1; + bit = (matchByte & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) + } while (symbol < 0x100); + } + dic[dicPos++] = (Byte)symbol; + processedPos++; + continue; + } + else + { + UPDATE_1(prob); + prob = probs + IsRep + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + state += kNumStates; + prob = probs + LenCoder; + } + else + { + UPDATE_1(prob); + if (checkDicSize == 0 && processedPos == 0) + return SZ_ERROR_DATA; + prob = probs + IsRepG0 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + + posState; + IF_BIT_0(prob) + { + UPDATE_0(prob); + dic[dicPos] = + dic[(dicPos - rep0) + + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + processedPos++; + state = state < kNumLitStates ? 9 : 11; + continue; + } + UPDATE_1(prob); + } + else + { + UInt32 distance; + UPDATE_1(prob); + prob = probs + IsRepG1 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + distance = rep1; + } + else + { + UPDATE_1(prob); + prob = probs + IsRepG2 + state; + IF_BIT_0(prob) + { + UPDATE_0(prob); + distance = rep2; + } + else + { + UPDATE_1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = probs + RepLenCoder; + } + { + unsigned limit, offset; + CLzmaProb *probLen = prob + LenChoice; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + limit = (1 << kLenNumLowBits); + } + else + { + UPDATE_1(probLen); + probLen = prob + LenChoice2; + IF_BIT_0(probLen) + { + UPDATE_0(probLen); + probLen = + prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + limit = (1 << kLenNumMidBits); + } + else + { + UPDATE_1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + limit = (1 << kLenNumHighBits); + } + } + TREE_DECODE(probLen, limit, len); + len += offset; + } - len += kMatchMinLen; + if (state >= kNumStates) { + UInt32 distance; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) + << kNumPosSlotBits); + TREE_6_DECODE(prob, distance); + if (distance >= kStartPosModelIndex) { + unsigned posSlot = (unsigned)distance; + int numDirectBits = (int)(((distance >> 1) - 1)); + distance = (2 | (distance & 1)); + if (posSlot < kEndPosModelIndex) { + distance <<= numDirectBits; + prob = probs + SpecPos + distance - posSlot - 1; + { + UInt32 mask = 1; + unsigned i = 1; + do { + GET_BIT2(prob + i, i, + ; + , distance |= mask); + mask <<= 1; + } while (--numDirectBits != 0); + } + } else { + numDirectBits -= kNumAlignBits; + do { + NORMALIZE + range >>= 1; - if (limit == dicPos) - return SZ_ERROR_DATA; - { - SizeT rem = limit - dicPos; - unsigned curLen = ((rem < len) ? (unsigned)rem : len); - SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); + { + UInt32 t; + code -= range; + t = (0 - + ((UInt32)code >> + 31)); /* (UInt32)((Int32)code + >> 31) */ + distance = + (distance << 1) + (t + 1); + code += range & t; + } + /* + distance <<= 1; + if (code >= range) + { + code -= range; + distance |= 1; + } + */ + } while (--numDirectBits != 0); + prob = probs + Align; + distance <<= kNumAlignBits; + { + unsigned i = 1; + GET_BIT2(prob + i, i, ;, distance |= 1); + GET_BIT2(prob + i, i, ;, distance |= 2); + GET_BIT2(prob + i, i, ;, distance |= 4); + GET_BIT2(prob + i, i, ;, distance |= 8); + } + if (distance == (UInt32)0xFFFFFFFF) { + len += kMatchSpecLenStart; + state -= kNumStates; + break; + } + } + } + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance + 1; + if (checkDicSize == 0) { + if (distance >= processedPos) + return SZ_ERROR_DATA; + } else if (distance >= checkDicSize) + return SZ_ERROR_DATA; + state = (state < kNumStates + kNumLitStates) ? kNumLitStates + : kNumLitStates + 3; + } - processedPos += curLen; + len += kMatchMinLen; - len -= curLen; - if (pos + curLen <= dicBufSize) - { - Byte *dest = dic + dicPos; - ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const Byte *lim = dest + curLen; - dicPos += curLen; - do - *(dest) = (Byte)*(dest + src); - while (++dest != lim); - } - else - { - do - { - dic[dicPos++] = dic[pos]; - if (++pos == dicBufSize) - pos = 0; - } - while (--curLen != 0); - } - } - } - } - while (dicPos < limit && buf < bufLimit); - NORMALIZE; - p->buf = buf; - p->range = range; - p->code = code; - p->remainLen = len; - p->dicPos = dicPos; - p->processedPos = processedPos; - p->reps[0] = rep0; - p->reps[1] = rep1; - p->reps[2] = rep2; - p->reps[3] = rep3; - p->state = state; + if (limit == dicPos) + return SZ_ERROR_DATA; + { + SizeT rem = limit - dicPos; + unsigned curLen = ((rem < len) ? (unsigned)rem : len); + SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); - return SZ_OK; + processedPos += curLen; + + len -= curLen; + if (pos + curLen <= dicBufSize) { + Byte *dest = dic + dicPos; + ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; + const Byte *lim = dest + curLen; + dicPos += curLen; + do + *(dest) = (Byte) * (dest + src); + while (++dest != lim); + } else { + do { + dic[dicPos++] = dic[pos]; + if (++pos == dicBufSize) + pos = 0; + } while (--curLen != 0); + } + } + } + } while (dicPos < limit && buf < bufLimit); + NORMALIZE; + p->buf = buf; + p->range = range; + p->code = code; + p->remainLen = len; + p->dicPos = dicPos; + p->processedPos = processedPos; + p->reps[0] = rep0; + p->reps[1] = rep1; + p->reps[2] = rep2; + p->reps[3] = rep3; + p->state = state; + + return SZ_OK; } static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) { - if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) - { - Byte *dic = p->dic; - SizeT dicPos = p->dicPos; - SizeT dicBufSize = p->dicBufSize; - unsigned len = p->remainLen; - UInt32 rep0 = p->reps[0]; - if (limit - dicPos < len) - len = (unsigned)(limit - dicPos); + if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) { + Byte *dic = p->dic; + SizeT dicPos = p->dicPos; + SizeT dicBufSize = p->dicBufSize; + unsigned len = p->remainLen; + UInt32 rep0 = p->reps[0]; + if (limit - dicPos < len) + len = (unsigned)(limit - dicPos); - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) + p->checkDicSize = p->prop.dicSize; - p->processedPos += len; - p->remainLen -= len; - while (len-- != 0) - { - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - } - p->dicPos = dicPos; - } + p->processedPos += len; + p->remainLen -= len; + while (len-- != 0) { + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + } + p->dicPos = dicPos; + } } static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) { - do - { - SizeT limit2 = limit; - if (p->checkDicSize == 0) - { - UInt32 rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit2 = p->dicPos + rem; - } - RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); - if (p->processedPos >= p->prop.dicSize) - p->checkDicSize = p->prop.dicSize; - LzmaDec_WriteRem(p, limit); - } - while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); + do { + SizeT limit2 = limit; + if (p->checkDicSize == 0) { + UInt32 rem = p->prop.dicSize - p->processedPos; + if (limit - p->dicPos > rem) + limit2 = p->dicPos + rem; + } + RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); + if (p->processedPos >= p->prop.dicSize) + p->checkDicSize = p->prop.dicSize; + LzmaDec_WriteRem(p, limit); + } while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); - if (p->remainLen > kMatchSpecLenStart) - { - p->remainLen = kMatchSpecLenStart; - } - return 0; + if (p->remainLen > kMatchSpecLenStart) { + p->remainLen = kMatchSpecLenStart; + } + return 0; } -typedef enum -{ - DUMMY_ERROR, /* unexpected end of input stream */ - DUMMY_LIT, - DUMMY_MATCH, - DUMMY_REP +typedef enum { + DUMMY_ERROR, /* unexpected end of input stream */ + DUMMY_LIT, + DUMMY_MATCH, + DUMMY_REP } ELzmaDummy; static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) { - UInt32 range = p->range; - UInt32 code = p->code; - const Byte *bufLimit = buf + inSize; - CLzmaProb *probs = p->probs; - unsigned state = p->state; - ELzmaDummy res; + UInt32 range = p->range; + UInt32 code = p->code; + const Byte *bufLimit = buf + inSize; + CLzmaProb *probs = p->probs; + unsigned state = p->state; + ELzmaDummy res; - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK - - /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ - - prob = probs + Literal; - if (p->checkDicSize != 0 || p->processedPos != 0) - prob += (LZMA_LIT_SIZE * - ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + - (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); - - if (state < kNumLitStates) - { - unsigned symbol = 1; - do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchByte = p->dic[p->dicPos - p->reps[0] + - ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; - unsigned offs = 0x100; - unsigned symbol = 1; - do { - unsigned bit; - CLzmaProb *probLit; - matchByte <<= 1; - bit = (matchByte & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - res = DUMMY_LIT; - } - else - { - unsigned len; - UPDATE_1_CHECK; + CLzmaProb *prob; + UInt32 bound; + unsigned ttt; + unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - prob = probs + IsRep + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - state = 0; - prob = probs + LenCoder; - res = DUMMY_MATCH; - } - else - { - UPDATE_1_CHECK; - res = DUMMY_REP; - prob = probs + IsRepG0 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - NORMALIZE_CHECK; - return DUMMY_REP; - } - else - { - UPDATE_1_CHECK; - } - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG1 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG2 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - } - } - } - state = kNumStates; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - CLzmaProb *probLen = prob + LenChoice; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenChoice2; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = 1 << kLenNumMidBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = 1 << kLenNumHighBits; - } - } - TREE_DECODE_CHECK(probLen, limit, len); - len += offset; - } + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK - if (state < 4) - { - unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); + /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ - /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ + prob = probs + Literal; + if (p->checkDicSize != 0 || p->processedPos != 0) + prob += + (LZMA_LIT_SIZE * + ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) + << p->prop.lc) + + (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> + (8 - p->prop.lc)))); - if (posSlot < kEndPosModelIndex) - { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE_CHECK - range >>= 1; - code -= range & (((code - range) >> 31) - 1); - /* if (code >= range) code -= range; */ - } - while (--numDirectBits != 0); - prob = probs + Align; - numDirectBits = kNumAlignBits; - } - { - unsigned i = 1; - do - { - GET_BIT_CHECK(prob + i, i); - } - while (--numDirectBits != 0); - } + if (state < kNumLitStates) { + unsigned symbol = 1; + do { + GET_BIT_CHECK(prob + symbol, symbol) + } while (symbol < 0x100); + } else { + unsigned matchByte = + p->dic[p->dicPos - p->reps[0] + + ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; + unsigned offs = 0x100; + unsigned symbol = 1; + do { + unsigned bit; + CLzmaProb *probLit; + matchByte <<= 1; + bit = (matchByte & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) + } while (symbol < 0x100); + } + res = DUMMY_LIT; + } + else + { + unsigned len; + UPDATE_1_CHECK; + + prob = probs + IsRep + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + state = 0; + prob = probs + LenCoder; + res = DUMMY_MATCH; + } + else + { + UPDATE_1_CHECK; + res = DUMMY_REP; + prob = probs + IsRepG0 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + NORMALIZE_CHECK; + return DUMMY_REP; + } + else + { + UPDATE_1_CHECK; + } + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG1 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG2 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + } + } + } + state = kNumStates; + prob = probs + RepLenCoder; + } + { + unsigned limit, offset; + CLzmaProb *probLen = prob + LenChoice; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + limit = 1 << kLenNumLowBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenChoice2; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = + prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + limit = 1 << kLenNumMidBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + limit = 1 << kLenNumHighBits; + } + } + TREE_DECODE_CHECK(probLen, limit, len); + len += offset; + } + + if (state < 4) { + unsigned posSlot; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) + << kNumPosSlotBits); + TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) { + int numDirectBits = ((posSlot >> 1) - 1); + + /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ + + if (posSlot < kEndPosModelIndex) { + prob = probs + SpecPos + + ((2 | (posSlot & 1)) << numDirectBits) - + posSlot - 1; + } else { + numDirectBits -= kNumAlignBits; + do { + NORMALIZE_CHECK + range >>= 1; + code -= + range & (((code - range) >> 31) - 1); + /* if (code >= range) code -= range; */ + } while (--numDirectBits != 0); + prob = probs + Align; + numDirectBits = kNumAlignBits; + } + { + unsigned i = 1; + do { + GET_BIT_CHECK(prob + i, i); + } while (--numDirectBits != 0); + } + } + } + } } - } - } - } - NORMALIZE_CHECK; - return res; + NORMALIZE_CHECK; + return res; } - static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) { - p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); - p->range = 0xFFFFFFFF; - p->needFlush = 0; + p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | + ((UInt32)data[4]); + p->range = 0xFFFFFFFF; + p->needFlush = 0; } void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) { - p->needFlush = 1; - p->remainLen = 0; - p->tempBufSize = 0; + p->needFlush = 1; + p->remainLen = 0; + p->tempBufSize = 0; - if (initDic) - { - p->processedPos = 0; - p->checkDicSize = 0; - p->needInitState = 1; - } - if (initState) - p->needInitState = 1; + if (initDic) { + p->processedPos = 0; + p->checkDicSize = 0; + p->needInitState = 1; + } + if (initState) + p->needInitState = 1; } void LzmaDec_Init(CLzmaDec *p) { - p->dicPos = 0; - LzmaDec_InitDicAndState(p, True, True); + p->dicPos = 0; + LzmaDec_InitDicAndState(p, True, True); } static void LzmaDec_InitStateReal(CLzmaDec *p) { - UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); - UInt32 i; - CLzmaProb *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - p->needInitState = 0; + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); + UInt32 i; + CLzmaProb *probs = p->probs; + for (i = 0; i < numProbs; i++) + probs[i] = kBitModelTotal >> 1; + p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; + p->state = 0; + p->needInitState = 0; } SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) + ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT inSize = *srcLen; - (*srcLen) = 0; - LzmaDec_WriteRem(p, dicLimit); - - *status = LZMA_STATUS_NOT_SPECIFIED; + SizeT inSize = *srcLen; + (*srcLen) = 0; + LzmaDec_WriteRem(p, dicLimit); - while (p->remainLen != kMatchSpecLenStart) - { - int checkEndMarkNow; + *status = LZMA_STATUS_NOT_SPECIFIED; - if (p->needFlush != 0) - { - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (p->tempBuf[0] != 0) - return SZ_ERROR_DATA; + while (p->remainLen != kMatchSpecLenStart) { + int checkEndMarkNow; - LzmaDec_InitRc(p, p->tempBuf); - p->tempBufSize = 0; - } + if (p->needFlush != 0) { + for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) + p->tempBuf[p->tempBufSize++] = *src++; + if (p->tempBufSize < RC_INIT_SIZE) { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (p->tempBuf[0] != 0) + return SZ_ERROR_DATA; - checkEndMarkNow = 0; - if (p->dicPos >= dicLimit) - { - if (p->remainLen == 0 && p->code == 0) - { - *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; - return SZ_OK; - } - if (finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->remainLen != 0) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - checkEndMarkNow = 1; - } + LzmaDec_InitRc(p, p->tempBuf); + p->tempBufSize = 0; + } - if (p->needInitState) - LzmaDec_InitStateReal(p); - - if (p->tempBufSize == 0) - { - SizeT processed; - const Byte *bufLimit; - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, src, inSize); - if (dummyRes == DUMMY_ERROR) - { - memcpy(p->tempBuf, src, inSize); - p->tempBufSize = (unsigned)inSize; - (*srcLen) += inSize; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - bufLimit = src; + checkEndMarkNow = 0; + if (p->dicPos >= dicLimit) { + if (p->remainLen == 0 && p->code == 0) { + *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; + return SZ_OK; + } + if (finishMode == LZMA_FINISH_ANY) { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->remainLen != 0) { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + checkEndMarkNow = 1; + } + + if (p->needInitState) + LzmaDec_InitStateReal(p); + + if (p->tempBufSize == 0) { + SizeT processed; + const Byte *bufLimit; + if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) { + int dummyRes = LzmaDec_TryDummy(p, src, inSize); + if (dummyRes == DUMMY_ERROR) { + memcpy(p->tempBuf, src, inSize); + p->tempBufSize = (unsigned)inSize; + (*srcLen) += inSize; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + bufLimit = src; + } else + bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; + p->buf = src; + if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) + return SZ_ERROR_DATA; + processed = (SizeT)(p->buf - src); + (*srcLen) += processed; + src += processed; + inSize -= processed; + } else { + unsigned rem = p->tempBufSize, lookAhead = 0; + while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) + p->tempBuf[rem++] = src[lookAhead++]; + p->tempBufSize = rem; + if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) { + int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); + if (dummyRes == DUMMY_ERROR) { + (*srcLen) += lookAhead; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + } + p->buf = p->tempBuf; + if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) + return SZ_ERROR_DATA; + lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); + (*srcLen) += lookAhead; + src += lookAhead; + inSize -= lookAhead; + p->tempBufSize = 0; + } } - else - bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - p->buf = src; - if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) - return SZ_ERROR_DATA; - processed = (SizeT)(p->buf - src); - (*srcLen) += processed; - src += processed; - inSize -= processed; - } - else - { - unsigned rem = p->tempBufSize, lookAhead = 0; - while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) - p->tempBuf[rem++] = src[lookAhead++]; - p->tempBufSize = rem; - if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); - if (dummyRes == DUMMY_ERROR) - { - (*srcLen) += lookAhead; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - } - p->buf = p->tempBuf; - if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) - return SZ_ERROR_DATA; - lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); - (*srcLen) += lookAhead; - src += lookAhead; - inSize -= lookAhead; - p->tempBufSize = 0; - } - } - if (p->code == 0) - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; + if (p->code == 0) + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; } -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) { - SizeT outSize = *destLen; - SizeT inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - SizeT inSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->dicPos == p->dicBufSize) - p->dicPos = 0; - dicPos = p->dicPos; - if (outSize > p->dicBufSize - dicPos) - { - outSizeCur = p->dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } + SizeT outSize = *destLen; + SizeT inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) { + SizeT inSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->dicPos == p->dicBufSize) + p->dicPos = 0; + dicPos = p->dicPos; + if (outSize > p->dicBufSize - dicPos) { + outSizeCur = p->dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } else { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); - src += inSizeCur; - inSize -= inSizeCur; - *srcLen += inSizeCur; - outSizeCur = p->dicPos - dicPos; - memcpy(dest, p->dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } + res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); + src += inSizeCur; + inSize -= inSizeCur; + *srcLen += inSizeCur; + outSizeCur = p->dicPos - dicPos; + memcpy(dest, p->dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } } void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) { - alloc->Free(alloc, p->probs); - p->probs = 0; + alloc->Free(alloc, p->probs); + p->probs = 0; } static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) { - alloc->Free(alloc, p->dic); - p->dic = 0; + alloc->Free(alloc, p->dic); + p->dic = 0; } void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) { - LzmaDec_FreeProbs(p, alloc); - LzmaDec_FreeDict(p, alloc); + LzmaDec_FreeProbs(p, alloc); + LzmaDec_FreeDict(p, alloc); } SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) { - UInt32 dicSize; - Byte d; - - if (size < LZMA_PROPS_SIZE) - return SZ_ERROR_UNSUPPORTED; - else - dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); - - if (dicSize < LZMA_DIC_MIN) - dicSize = LZMA_DIC_MIN; - p->dicSize = dicSize; + UInt32 dicSize; + Byte d; - d = data[0]; - if (d >= (9 * 5 * 5)) - return SZ_ERROR_UNSUPPORTED; + if (size < LZMA_PROPS_SIZE) + return SZ_ERROR_UNSUPPORTED; + else + dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | + ((UInt32)data[4] << 24); - p->lc = d % 9; - d /= 9; - p->pb = d / 5; - p->lp = d % 5; + if (dicSize < LZMA_DIC_MIN) + dicSize = LZMA_DIC_MIN; + p->dicSize = dicSize; - return SZ_OK; + d = data[0]; + if (d >= (9 * 5 * 5)) + return SZ_ERROR_UNSUPPORTED; + + p->lc = d % 9; + d /= 9; + p->pb = d / 5; + p->lp = d % 5; + + return SZ_OK; } static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) { - UInt32 numProbs = LzmaProps_GetNumProbs(propNew); - if (p->probs == 0 || numProbs != p->numProbs) - { - LzmaDec_FreeProbs(p, alloc); - p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); - p->numProbs = numProbs; - if (p->probs == 0) - return SZ_ERROR_MEM; - } - return SZ_OK; + UInt32 numProbs = LzmaProps_GetNumProbs(propNew); + if (p->probs == 0 || numProbs != p->numProbs) { + LzmaDec_FreeProbs(p, alloc); + p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); + p->numProbs = numProbs; + if (p->probs == 0) + return SZ_ERROR_MEM; + } + return SZ_OK; } SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) { - CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - p->prop = propNew; - return SZ_OK; + CLzmaProps propNew; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + p->prop = propNew; + return SZ_OK; } SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) { - CLzmaProps propNew; - SizeT dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - dicBufSize = propNew.dicSize; - if (p->dic == 0 || dicBufSize != p->dicBufSize) - { - LzmaDec_FreeDict(p, alloc); - p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); - if (p->dic == 0) - { - LzmaDec_FreeProbs(p, alloc); - return SZ_ERROR_MEM; - } - } - p->dicBufSize = dicBufSize; - p->prop = propNew; - return SZ_OK; + CLzmaProps propNew; + SizeT dicBufSize; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + dicBufSize = propNew.dicSize; + if (p->dic == 0 || dicBufSize != p->dicBufSize) { + LzmaDec_FreeDict(p, alloc); + p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); + if (p->dic == 0) { + LzmaDec_FreeProbs(p, alloc); + return SZ_ERROR_MEM; + } + } + p->dicBufSize = dicBufSize; + p->prop = propNew; + return SZ_OK; } -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc) +SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, + unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) { - CLzmaDec p; - SRes res; - SizeT inSize = *srcLen; - SizeT outSize = *destLen; - *srcLen = *destLen = 0; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; + CLzmaDec p; + SRes res; + SizeT inSize = *srcLen; + SizeT outSize = *destLen; + *srcLen = *destLen = 0; + if (inSize < RC_INIT_SIZE) + return SZ_ERROR_INPUT_EOF; - LzmaDec_Construct(&p); - res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); - if (res != 0) - return res; - p.dic = dest; - p.dicBufSize = outSize; + LzmaDec_Construct(&p); + res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); + if (res != 0) + return res; + p.dic = dest; + p.dicBufSize = outSize; - LzmaDec_Init(&p); - - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); + LzmaDec_Init(&p); - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; + *srcLen = inSize; + res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - (*destLen) = p.dicPos; - LzmaDec_FreeProbs(&p, alloc); - return res; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + (*destLen) = p.dicPos; + LzmaDec_FreeProbs(&p, alloc); + return res; } diff --git a/fex/7z_C/LzmaDec.h b/fex/7z_C/LzmaDec.h index bf7f084b..7a4d9f7c 100644 --- a/fex/7z_C/LzmaDec.h +++ b/fex/7z_C/LzmaDec.h @@ -20,15 +20,13 @@ extern "C" { #define CLzmaProb UInt16 #endif - /* ---------- LZMA Properties ---------- */ #define LZMA_PROPS_SIZE 5 -typedef struct _CLzmaProps -{ - unsigned lc, lp, pb; - UInt32 dicSize; +typedef struct _CLzmaProps { + unsigned lc, lp, pb; + UInt32 dicSize; } CLzmaProps; /* LzmaProps_Decode - decodes properties @@ -39,7 +37,6 @@ Returns: SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); - /* ---------- LZMA Decoder state ---------- */ /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. @@ -47,28 +44,31 @@ SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); #define LZMA_REQUIRED_INPUT_MAX 20 -typedef struct -{ - CLzmaProps prop; - CLzmaProb *probs; - Byte *dic; - const Byte *buf; - UInt32 range, code; - SizeT dicPos; - SizeT dicBufSize; - UInt32 processedPos; - UInt32 checkDicSize; - unsigned state; - UInt32 reps[4]; - unsigned remainLen; - int needFlush; - int needInitState; - UInt32 numProbs; - unsigned tempBufSize; - Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; +typedef struct { + CLzmaProps prop; + CLzmaProb *probs; + Byte *dic; + const Byte *buf; + UInt32 range, code; + SizeT dicPos; + SizeT dicBufSize; + UInt32 processedPos; + UInt32 checkDicSize; + unsigned state; + UInt32 reps[4]; + unsigned remainLen; + int needFlush; + int needInitState; + UInt32 numProbs; + unsigned tempBufSize; + Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; } CLzmaDec; -#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } +#define LzmaDec_Construct(p) \ + { \ + (p)->dic = 0; \ + (p)->probs = 0; \ + } void LzmaDec_Init(CLzmaDec *p); @@ -76,10 +76,9 @@ void LzmaDec_Init(CLzmaDec *p); 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ -typedef enum -{ - LZMA_FINISH_ANY, /* finish at any point */ - LZMA_FINISH_END /* block must be finished at the end */ +typedef enum { + LZMA_FINISH_ANY, /* finish at any point */ + LZMA_FINISH_END /* block must be finished at the end */ } ELzmaFinishMode; /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! @@ -97,18 +96,17 @@ typedef enum 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. You must use correct finish mode in that case. */ -typedef enum -{ - LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ - LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ - LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ +typedef enum { + LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ + LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ + LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ + LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished + without end mark */ } ELzmaStatus; /* ELzmaStatus is used only as output value for function call */ - /* ---------- Interfaces ---------- */ /* There are 3 levels of interfaces: @@ -118,7 +116,6 @@ typedef enum You can select any of these interfaces, but don't mix functions from different groups for same object. */ - /* There are two variants to allocate state for Dictionary Interface: 1) LzmaDec_Allocate / LzmaDec_Free 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs @@ -130,7 +127,7 @@ LzmaDec_Allocate* can return: SZ_ERROR_MEM - Memory allocation error SZ_ERROR_UNSUPPORTED - Unsupported properties */ - + SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); @@ -159,7 +156,7 @@ void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); */ /* LzmaDec_DecodeToDic - + The decoding to internal dictionary buffer (CLzmaDec::dic). You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! @@ -178,9 +175,8 @@ Returns: SZ_ERROR_DATA - Data error */ -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - +SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- Buffer Interface ---------- */ @@ -195,9 +191,8 @@ finishMode: LZMA_FINISH_END - Stream must be finished after (*destLen). */ -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, - const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status); /* ---------- One Call Interface ---------- */ @@ -220,9 +215,9 @@ Returns: SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). */ -SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, - const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc); +SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, + unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, + ISzAlloc *alloc); #ifdef __cplusplus } diff --git a/fex/7z_C/Ppmd.h b/fex/7z_C/Ppmd.h index 14344a71..32066347 100644 --- a/fex/7z_C/Ppmd.h +++ b/fex/7z_C/Ppmd.h @@ -5,13 +5,13 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ #ifndef __PPMD_H #define __PPMD_H -#include "Types.h" #include "CpuArch.h" +#include "Types.h" EXTERN_C_BEGIN #ifdef MY_CPU_32BIT - #define PPMD_32BIT +#define PPMD_32BIT #endif #define PPMD_INT_BITS 7 @@ -21,7 +21,7 @@ EXTERN_C_BEGIN #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_UPDATE_PROB_1(prob) ((prob)-PPMD_GET_MEAN(prob)) #define PPMD_N1 4 #define PPMD_N2 4 @@ -30,52 +30,58 @@ EXTERN_C_BEGIN #define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) /* 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 */ +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++); } +#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; +typedef struct { + Byte Symbol; + Byte Freq; + UInt16 SuccessorLow; + UInt16 SuccessorHigh; } CPpmd_State; typedef - #ifdef PPMD_32BIT +#ifdef PPMD_32BIT CPpmd_State * - #else +#else UInt32 - #endif - CPpmd_State_Ref; +#endif + CPpmd_State_Ref; typedef - #ifdef PPMD_32BIT +#ifdef PPMD_32BIT void * - #else +#else UInt32 - #endif - CPpmd_Void_Ref; +#endif + CPpmd_Void_Ref; typedef - #ifdef PPMD_32BIT +#ifdef PPMD_32BIT Byte * - #else +#else UInt32 - #endif - CPpmd_Byte_Ref; +#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; }} +#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 diff --git a/fex/7z_C/Ppmd7.c b/fex/7z_C/Ppmd7.c index 4b160cf0..97240070 100644 --- a/fex/7z_C/Ppmd7.c +++ b/fex/7z_C/Ppmd7.c @@ -7,19 +7,20 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ #include "Ppmd7.h" const Byte PPMD7_kExpEscape[16] = { 25, 14, 9, 7, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2, 2 }; -static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051}; +static const UInt16 kInitBinEsc[] = + { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x5ABC, 0x6632, 0x6051 }; #define MAX_FREQ 124 #define UNIT_SIZE 12 -#define U2B(nu) ((UInt32)(nu) * UNIT_SIZE) -#define U2I(nu) (p->Units2Indx[(nu) - 1]) +#define U2B(nu) ((UInt32)(nu)*UNIT_SIZE) +#define U2I(nu) (p->Units2Indx[(nu)-1]) #define I2U(indx) (p->Indx2Units[indx]) #ifdef PPMD_32BIT - #define REF(ptr) (ptr) +#define REF(ptr) (ptr) #else - #define REF(ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) +#define REF(ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) #endif #define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr)) @@ -29,680 +30,638 @@ static const UInt16 kInitBinEsc[] = { 0x3CDD, 0x1F3F, 0x59BF, 0x48F3, 0x64A1, 0x #define ONE_STATE(ctx) Ppmd7Context_OneState(ctx) #define SUFFIX(ctx) CTX((ctx)->Suffix) -typedef CPpmd7_Context * CTX_PTR; +typedef CPpmd7_Context *CTX_PTR; struct CPpmd7_Node_; typedef - #ifdef PPMD_32BIT +#ifdef PPMD_32BIT struct CPpmd7_Node_ * - #else +#else UInt32 - #endif - CPpmd7_Node_Ref; +#endif + CPpmd7_Node_Ref; -typedef struct CPpmd7_Node_ -{ - UInt16 Stamp; /* must be at offset 0 as CPpmd7_Context::NumStats. Stamp=0 means free */ - UInt16 NU; - CPpmd7_Node_Ref Next; /* must be at offset >= 4 */ - CPpmd7_Node_Ref Prev; +typedef struct CPpmd7_Node_ { + UInt16 Stamp; /* must be at offset 0 as CPpmd7_Context::NumStats. Stamp=0 means free */ + UInt16 NU; + CPpmd7_Node_Ref Next; /* must be at offset >= 4 */ + CPpmd7_Node_Ref Prev; } CPpmd7_Node; #ifdef PPMD_32BIT - #define NODE(ptr) (ptr) +#define NODE(ptr) (ptr) #else - #define NODE(offs) ((CPpmd7_Node *)(p->Base + (offs))) +#define NODE(offs) ((CPpmd7_Node *)(p->Base + (offs))) #endif void Ppmd7_Construct(CPpmd7 *p) { - unsigned i, k, m; + unsigned i, k, m; - p->Base = 0; + p->Base = 0; - for (i = 0, k = 0; i < PPMD_NUM_INDEXES; i++) - { - unsigned step = (i >= 12 ? 4 : (i >> 2) + 1); - do { p->Units2Indx[k++] = (Byte)i; } while(--step); - p->Indx2Units[i] = (Byte)k; - } + for (i = 0, k = 0; i < PPMD_NUM_INDEXES; i++) { + unsigned step = (i >= 12 ? 4 : (i >> 2) + 1); + do { + p->Units2Indx[k++] = (Byte)i; + } while (--step); + p->Indx2Units[i] = (Byte)k; + } - p->NS2BSIndx[0] = (0 << 1); - p->NS2BSIndx[1] = (1 << 1); - memset(p->NS2BSIndx + 2, (2 << 1), 9); - memset(p->NS2BSIndx + 11, (3 << 1), 256 - 11); + p->NS2BSIndx[0] = (0 << 1); + p->NS2BSIndx[1] = (1 << 1); + memset(p->NS2BSIndx + 2, (2 << 1), 9); + memset(p->NS2BSIndx + 11, (3 << 1), 256 - 11); - for (i = 0; i < 3; i++) - p->NS2Indx[i] = (Byte)i; - for (m = i, k = 1; i < 256; i++) - { - p->NS2Indx[i] = (Byte)m; - if (--k == 0) - k = (++m) - 2; - } + for (i = 0; i < 3; i++) + p->NS2Indx[i] = (Byte)i; + for (m = i, k = 1; i < 256; i++) { + p->NS2Indx[i] = (Byte)m; + if (--k == 0) + k = (++m) - 2; + } - memset(p->HB2Flag, 0, 0x40); - memset(p->HB2Flag + 0x40, 8, 0x100 - 0x40); + memset(p->HB2Flag, 0, 0x40); + memset(p->HB2Flag + 0x40, 8, 0x100 - 0x40); } void Ppmd7_Free(CPpmd7 *p, ISzAlloc *alloc) { - alloc->Free(alloc, p->Base); - p->Size = 0; - p->Base = 0; + alloc->Free(alloc, p->Base); + p->Size = 0; + p->Base = 0; } Bool Ppmd7_Alloc(CPpmd7 *p, UInt32 size, ISzAlloc *alloc) { - if (p->Base == 0 || p->Size != size) - { - Ppmd7_Free(p, alloc); - p->AlignOffset = - #ifdef PPMD_32BIT - (4 - size) & 3; - #else - 4 - (size & 3); - #endif - if ((p->Base = (Byte *)alloc->Alloc(alloc, p->AlignOffset + size - #ifndef PPMD_32BIT - + UNIT_SIZE - #endif - )) == 0) - return False; - p->Size = size; - } - return True; + if (p->Base == 0 || p->Size != size) { + Ppmd7_Free(p, alloc); + p->AlignOffset = +#ifdef PPMD_32BIT + (4 - size) & 3; +#else + 4 - (size & 3); +#endif + if ((p->Base = (Byte *)alloc->Alloc(alloc, + p->AlignOffset + size +#ifndef PPMD_32BIT + + + UNIT_SIZE +#endif + )) == 0) + return False; + p->Size = size; + } + return True; } static void InsertNode(CPpmd7 *p, void *node, unsigned indx) { - *((CPpmd_Void_Ref *)node) = p->FreeList[indx]; - p->FreeList[indx] = REF(node); + *((CPpmd_Void_Ref *)node) = p->FreeList[indx]; + p->FreeList[indx] = REF(node); } static void *RemoveNode(CPpmd7 *p, unsigned indx) { - CPpmd_Void_Ref *node = (CPpmd_Void_Ref *)Ppmd7_GetPtr(p, p->FreeList[indx]); - p->FreeList[indx] = *node; - return node; + CPpmd_Void_Ref *node = (CPpmd_Void_Ref *)Ppmd7_GetPtr(p, p->FreeList[indx]); + p->FreeList[indx] = *node; + return node; } static void SplitBlock(CPpmd7 *p, void *ptr, unsigned oldIndx, unsigned newIndx) { - unsigned i, nu = I2U(oldIndx) - I2U(newIndx); - ptr = (Byte *)ptr + U2B(I2U(newIndx)); - if (I2U(i = U2I(nu)) != nu) - { - unsigned k = I2U(--i); - InsertNode(p, ((Byte *)ptr) + U2B(k), nu - k - 1); - } - InsertNode(p, ptr, i); + unsigned i, nu = I2U(oldIndx) - I2U(newIndx); + ptr = (Byte *)ptr + U2B(I2U(newIndx)); + if (I2U(i = U2I(nu)) != nu) { + unsigned k = I2U(--i); + InsertNode(p, ((Byte *)ptr) + U2B(k), nu - k - 1); + } + InsertNode(p, ptr, i); } static void GlueFreeBlocks(CPpmd7 *p) { - #ifdef PPMD_32BIT - CPpmd7_Node headItem; - CPpmd7_Node_Ref head = &headItem; - #else - CPpmd7_Node_Ref head = p->AlignOffset + p->Size; - #endif - - CPpmd7_Node_Ref n = head; - unsigned i; +#ifdef PPMD_32BIT + CPpmd7_Node headItem; + CPpmd7_Node_Ref head = &headItem; +#else + CPpmd7_Node_Ref head = p->AlignOffset + p->Size; +#endif - p->GlueCount = 255; + CPpmd7_Node_Ref n = head; + unsigned i; - /* create doubly-linked list of free blocks */ - for (i = 0; i < PPMD_NUM_INDEXES; i++) - { - UInt16 nu = I2U(i); - CPpmd7_Node_Ref next = (CPpmd7_Node_Ref)p->FreeList[i]; - p->FreeList[i] = 0; - while (next != 0) - { - CPpmd7_Node *node = NODE(next); - node->Next = n; - n = NODE(n)->Prev = next; - next = *(const CPpmd7_Node_Ref *)node; - node->Stamp = 0; - node->NU = (UInt16)nu; - } - } - NODE(head)->Stamp = 1; - NODE(head)->Next = n; - NODE(n)->Prev = head; - if (p->LoUnit != p->HiUnit) - ((CPpmd7_Node *)p->LoUnit)->Stamp = 1; - - /* Glue free blocks */ - while (n != head) - { - CPpmd7_Node *node = NODE(n); - UInt32 nu = (UInt32)node->NU; - for (;;) - { - CPpmd7_Node *node2 = NODE(n) + nu; - nu += node2->NU; - if (node2->Stamp != 0 || nu >= 0x10000) - break; - NODE(node2->Prev)->Next = node2->Next; - NODE(node2->Next)->Prev = node2->Prev; - node->NU = (UInt16)nu; - } - n = node->Next; - } - - /* Fill lists of free blocks */ - for (n = NODE(head)->Next; n != head;) - { - CPpmd7_Node *node = NODE(n); - unsigned nu; - CPpmd7_Node_Ref next = node->Next; - for (nu = node->NU; nu > 128; nu -= 128, node += 128) - InsertNode(p, node, PPMD_NUM_INDEXES - 1); - if (I2U(i = U2I(nu)) != nu) - { - unsigned k = I2U(--i); - InsertNode(p, node + k, nu - k - 1); - } - InsertNode(p, node, i); - n = next; - } + p->GlueCount = 255; + + /* create doubly-linked list of free blocks */ + for (i = 0; i < PPMD_NUM_INDEXES; i++) { + UInt16 nu = I2U(i); + CPpmd7_Node_Ref next = (CPpmd7_Node_Ref)p->FreeList[i]; + p->FreeList[i] = 0; + while (next != 0) { + CPpmd7_Node *node = NODE(next); + node->Next = n; + n = NODE(n)->Prev = next; + next = *(const CPpmd7_Node_Ref *)node; + node->Stamp = 0; + node->NU = (UInt16)nu; + } + } + NODE(head)->Stamp = 1; + NODE(head)->Next = n; + NODE(n)->Prev = head; + if (p->LoUnit != p->HiUnit) + ((CPpmd7_Node *)p->LoUnit)->Stamp = 1; + + /* Glue free blocks */ + while (n != head) { + CPpmd7_Node *node = NODE(n); + UInt32 nu = (UInt32)node->NU; + for (;;) { + CPpmd7_Node *node2 = NODE(n) + nu; + nu += node2->NU; + if (node2->Stamp != 0 || nu >= 0x10000) + break; + NODE(node2->Prev)->Next = node2->Next; + NODE(node2->Next)->Prev = node2->Prev; + node->NU = (UInt16)nu; + } + n = node->Next; + } + + /* Fill lists of free blocks */ + for (n = NODE(head)->Next; n != head;) { + CPpmd7_Node *node = NODE(n); + unsigned nu; + CPpmd7_Node_Ref next = node->Next; + for (nu = node->NU; nu > 128; nu -= 128, node += 128) + InsertNode(p, node, PPMD_NUM_INDEXES - 1); + if (I2U(i = U2I(nu)) != nu) { + unsigned k = I2U(--i); + InsertNode(p, node + k, nu - k - 1); + } + InsertNode(p, node, i); + n = next; + } } static void *AllocUnitsRare(CPpmd7 *p, unsigned indx) { - unsigned i; - void *retVal; - if (p->GlueCount == 0) - { - GlueFreeBlocks(p); - if (p->FreeList[indx] != 0) - return RemoveNode(p, indx); - } - i = indx; - do - { - if (++i == PPMD_NUM_INDEXES) - { - UInt32 numBytes = U2B(I2U(indx)); - p->GlueCount--; - return ((UInt32)(p->UnitsStart - p->Text) > numBytes) ? (p->UnitsStart -= numBytes) : (NULL); - } - } - while (p->FreeList[i] == 0); - retVal = RemoveNode(p, i); - SplitBlock(p, retVal, i, indx); - return retVal; + unsigned i; + void *retVal; + if (p->GlueCount == 0) { + GlueFreeBlocks(p); + if (p->FreeList[indx] != 0) + return RemoveNode(p, indx); + } + i = indx; + do { + if (++i == PPMD_NUM_INDEXES) { + UInt32 numBytes = U2B(I2U(indx)); + p->GlueCount--; + return ((UInt32)(p->UnitsStart - p->Text) > numBytes) + ? (p->UnitsStart -= numBytes) + : (NULL); + } + } while (p->FreeList[i] == 0); + retVal = RemoveNode(p, i); + SplitBlock(p, retVal, i, indx); + return retVal; } static void *AllocUnits(CPpmd7 *p, unsigned indx) { - UInt32 numBytes; - if (p->FreeList[indx] != 0) - return RemoveNode(p, indx); - numBytes = U2B(I2U(indx)); - if (numBytes <= (UInt32)(p->HiUnit - p->LoUnit)) - { - void *retVal = p->LoUnit; - p->LoUnit += numBytes; - return retVal; - } - return AllocUnitsRare(p, indx); + UInt32 numBytes; + if (p->FreeList[indx] != 0) + return RemoveNode(p, indx); + numBytes = U2B(I2U(indx)); + if (numBytes <= (UInt32)(p->HiUnit - p->LoUnit)) { + void *retVal = p->LoUnit; + p->LoUnit += numBytes; + return retVal; + } + return AllocUnitsRare(p, indx); } -#define MyMem12Cpy(dest, src, num) \ - { UInt32 *d = (UInt32 *)dest; const UInt32 *s = (const UInt32 *)src; UInt32 n = num; \ - do { d[0] = s[0]; d[1] = s[1]; d[2] = s[2]; s += 3; d += 3; } while(--n); } +#define MyMem12Cpy(dest, src, num) \ + { \ + UInt32 *d = (UInt32 *)dest; \ + const UInt32 *s = (const UInt32 *)src; \ + UInt32 n = num; \ + do { \ + d[0] = s[0]; \ + d[1] = s[1]; \ + d[2] = s[2]; \ + s += 3; \ + d += 3; \ + } while (--n); \ + } static void *ShrinkUnits(CPpmd7 *p, void *oldPtr, unsigned oldNU, unsigned newNU) { - unsigned i0 = U2I(oldNU); - unsigned i1 = U2I(newNU); - if (i0 == i1) - return oldPtr; - if (p->FreeList[i1] != 0) - { - void *ptr = RemoveNode(p, i1); - MyMem12Cpy(ptr, oldPtr, newNU); - InsertNode(p, oldPtr, i0); - return ptr; - } - SplitBlock(p, oldPtr, i0, i1); - return oldPtr; + unsigned i0 = U2I(oldNU); + unsigned i1 = U2I(newNU); + if (i0 == i1) + return oldPtr; + if (p->FreeList[i1] != 0) { + void *ptr = RemoveNode(p, i1); + MyMem12Cpy(ptr, oldPtr, newNU); + InsertNode(p, oldPtr, i0); + return ptr; + } + SplitBlock(p, oldPtr, i0, i1); + return oldPtr; } #define SUCCESSOR(p) ((CPpmd_Void_Ref)((p)->SuccessorLow | ((UInt32)(p)->SuccessorHigh << 16))) static void SetSuccessor(CPpmd_State *p, CPpmd_Void_Ref v) { - (p)->SuccessorLow = (UInt16)((UInt32)(v) & 0xFFFF); - (p)->SuccessorHigh = (UInt16)(((UInt32)(v) >> 16) & 0xFFFF); + (p)->SuccessorLow = (UInt16)((UInt32)(v)&0xFFFF); + (p)->SuccessorHigh = (UInt16)(((UInt32)(v) >> 16) & 0xFFFF); } static void RestartModel(CPpmd7 *p) { - unsigned i, k, m; + unsigned i, k, m; - memset(p->FreeList, 0, sizeof(p->FreeList)); - p->Text = p->Base + p->AlignOffset; - p->HiUnit = p->Text + p->Size; - p->LoUnit = p->UnitsStart = p->HiUnit - p->Size / 8 / UNIT_SIZE * 7 * UNIT_SIZE; - p->GlueCount = 0; + memset(p->FreeList, 0, sizeof(p->FreeList)); + p->Text = p->Base + p->AlignOffset; + p->HiUnit = p->Text + p->Size; + p->LoUnit = p->UnitsStart = p->HiUnit - p->Size / 8 / UNIT_SIZE * 7 * UNIT_SIZE; + p->GlueCount = 0; - p->OrderFall = p->MaxOrder; - p->RunLength = p->InitRL = -(Int32)((p->MaxOrder < 12) ? p->MaxOrder : 12) - 1; - p->PrevSuccess = 0; + p->OrderFall = p->MaxOrder; + p->RunLength = p->InitRL = -(Int32)((p->MaxOrder < 12) ? p->MaxOrder : 12) - 1; + p->PrevSuccess = 0; - p->MinContext = p->MaxContext = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */ - p->MinContext->Suffix = 0; - p->MinContext->NumStats = 256; - p->MinContext->SummFreq = 256 + 1; - p->FoundState = (CPpmd_State *)p->LoUnit; /* AllocUnits(p, PPMD_NUM_INDEXES - 1); */ - p->LoUnit += U2B(256 / 2); - p->MinContext->Stats = REF(p->FoundState); - for (i = 0; i < 256; i++) - { - CPpmd_State *s = &p->FoundState[i]; - s->Symbol = (Byte)i; - s->Freq = 1; - SetSuccessor(s, 0); - } + p->MinContext = p->MaxContext = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */ + p->MinContext->Suffix = 0; + p->MinContext->NumStats = 256; + p->MinContext->SummFreq = 256 + 1; + p->FoundState = (CPpmd_State *)p->LoUnit; /* AllocUnits(p, PPMD_NUM_INDEXES - 1); */ + p->LoUnit += U2B(256 / 2); + p->MinContext->Stats = REF(p->FoundState); + for (i = 0; i < 256; i++) { + CPpmd_State *s = &p->FoundState[i]; + s->Symbol = (Byte)i; + s->Freq = 1; + SetSuccessor(s, 0); + } - for (i = 0; i < 128; i++) - for (k = 0; k < 8; k++) - { - UInt16 *dest = p->BinSumm[i] + k; - UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 2)); - for (m = 0; m < 64; m += 8) - dest[m] = val; - } - - for (i = 0; i < 25; i++) - for (k = 0; k < 16; k++) - { - CPpmd_See *s = &p->See[i][k]; - s->Summ = (UInt16)((5 * i + 10) << (s->Shift = PPMD_PERIOD_BITS - 4)); - s->Count = 4; - } + for (i = 0; i < 128; i++) + for (k = 0; k < 8; k++) { + UInt16 *dest = p->BinSumm[i] + k; + UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 2)); + for (m = 0; m < 64; m += 8) + dest[m] = val; + } + + for (i = 0; i < 25; i++) + for (k = 0; k < 16; k++) { + CPpmd_See *s = &p->See[i][k]; + s->Summ = (UInt16)((5 * i + 10) << (s->Shift = PPMD_PERIOD_BITS - 4)); + s->Count = 4; + } } void Ppmd7_Init(CPpmd7 *p, unsigned maxOrder) { - p->MaxOrder = maxOrder; - RestartModel(p); - p->DummySee.Shift = PPMD_PERIOD_BITS; - p->DummySee.Summ = 0; /* unused */ - p->DummySee.Count = 64; /* unused */ + p->MaxOrder = maxOrder; + RestartModel(p); + p->DummySee.Shift = PPMD_PERIOD_BITS; + p->DummySee.Summ = 0; /* unused */ + p->DummySee.Count = 64; /* unused */ } static CTX_PTR CreateSuccessors(CPpmd7 *p, Bool skip) { - CPpmd_State upState; - CTX_PTR c = p->MinContext; - CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); - CPpmd_State *ps[PPMD7_MAX_ORDER]; - unsigned numPs = 0; - - if (!skip) - ps[numPs++] = p->FoundState; - - while (c->Suffix) - { - CPpmd_Void_Ref successor; - CPpmd_State *s; - c = SUFFIX(c); - if (c->NumStats != 1) - { - for (s = STATS(c); s->Symbol != p->FoundState->Symbol; s++); - } - else - s = ONE_STATE(c); - successor = SUCCESSOR(s); - if (successor != upBranch) - { - c = CTX(successor); - if (numPs == 0) - return c; - break; - } - ps[numPs++] = s; - } - - upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch); - SetSuccessor(&upState, upBranch + 1); - - if (c->NumStats == 1) - upState.Freq = ONE_STATE(c)->Freq; - else - { - UInt32 cf, s0; - CPpmd_State *s; - for (s = STATS(c); s->Symbol != upState.Symbol; s++); - cf = s->Freq - 1; - s0 = c->SummFreq - c->NumStats - cf; - upState.Freq = (Byte)(1 + ((2 * cf <= s0) ? (5 * cf > s0) : ((2 * cf + 3 * s0 - 1) / (2 * s0)))); - } + CPpmd_State upState; + CTX_PTR c = p->MinContext; + CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); + CPpmd_State *ps[PPMD7_MAX_ORDER]; + unsigned numPs = 0; - do - { - /* Create Child */ - CTX_PTR c1; /* = AllocContext(p); */ - if (p->HiUnit != p->LoUnit) - c1 = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); - else if (p->FreeList[0] != 0) - c1 = (CTX_PTR)RemoveNode(p, 0); - else - { - c1 = (CTX_PTR)AllocUnitsRare(p, 0); - if (!c1) - return NULL; - } - c1->NumStats = 1; - *ONE_STATE(c1) = upState; - c1->Suffix = REF(c); - SetSuccessor(ps[--numPs], REF(c1)); - c = c1; - } - while (numPs != 0); - - return c; + if (!skip) + ps[numPs++] = p->FoundState; + + while (c->Suffix) { + CPpmd_Void_Ref successor; + CPpmd_State *s; + c = SUFFIX(c); + if (c->NumStats != 1) { + for (s = STATS(c); s->Symbol != p->FoundState->Symbol; s++) + ; + } else + s = ONE_STATE(c); + successor = SUCCESSOR(s); + if (successor != upBranch) { + c = CTX(successor); + if (numPs == 0) + return c; + break; + } + ps[numPs++] = s; + } + + upState.Symbol = *(const Byte *)Ppmd7_GetPtr(p, upBranch); + SetSuccessor(&upState, upBranch + 1); + + if (c->NumStats == 1) + upState.Freq = ONE_STATE(c)->Freq; + else { + UInt32 cf, s0; + CPpmd_State *s; + for (s = STATS(c); s->Symbol != upState.Symbol; s++) + ; + cf = s->Freq - 1; + s0 = c->SummFreq - c->NumStats - cf; + upState.Freq = (Byte)( + 1 + ((2 * cf <= s0) ? (5 * cf > s0) : ((2 * cf + 3 * s0 - 1) / (2 * s0)))); + } + + do { + /* Create Child */ + CTX_PTR c1; /* = AllocContext(p); */ + if (p->HiUnit != p->LoUnit) + c1 = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); + else if (p->FreeList[0] != 0) + c1 = (CTX_PTR)RemoveNode(p, 0); + else { + c1 = (CTX_PTR)AllocUnitsRare(p, 0); + if (!c1) + return NULL; + } + c1->NumStats = 1; + *ONE_STATE(c1) = upState; + c1->Suffix = REF(c); + SetSuccessor(ps[--numPs], REF(c1)); + c = c1; + } while (numPs != 0); + + return c; } static void SwapStates(CPpmd_State *t1, CPpmd_State *t2) { - CPpmd_State tmp = *t1; - *t1 = *t2; - *t2 = tmp; + CPpmd_State tmp = *t1; + *t1 = *t2; + *t2 = tmp; } static void UpdateModel(CPpmd7 *p) { - CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState); - CTX_PTR c; - unsigned s0, ns; - - if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) - { - c = SUFFIX(p->MinContext); - - if (c->NumStats == 1) - { - CPpmd_State *s = ONE_STATE(c); - if (s->Freq < 32) - s->Freq++; - } - else - { - CPpmd_State *s = STATS(c); - if (s->Symbol != p->FoundState->Symbol) - { - do { s++; } while (s->Symbol != p->FoundState->Symbol); - if (s[0].Freq >= s[-1].Freq) - { - SwapStates(&s[0], &s[-1]); - s--; - } - } - if (s->Freq < MAX_FREQ - 9) - { - s->Freq += 2; - c->SummFreq += 2; - } - } - } + CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState); + CTX_PTR c; + unsigned s0, ns; - if (p->OrderFall == 0) - { - p->MinContext = p->MaxContext = CreateSuccessors(p, True); - if (p->MinContext == 0) - { - RestartModel(p); - return; - } - SetSuccessor(p->FoundState, REF(p->MinContext)); - return; - } - - *p->Text++ = p->FoundState->Symbol; - successor = REF(p->Text); - if (p->Text >= p->UnitsStart) - { - RestartModel(p); - return; - } - - if (fSuccessor) - { - if (fSuccessor <= successor) - { - CTX_PTR cs = CreateSuccessors(p, False); - if (cs == NULL) - { - RestartModel(p); - return; - } - fSuccessor = REF(cs); - } - if (--p->OrderFall == 0) - { - successor = fSuccessor; - p->Text -= (p->MaxContext != p->MinContext); - } - } - else - { - SetSuccessor(p->FoundState, successor); - fSuccessor = REF(p->MinContext); - } - - s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1); - - for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c)) - { - unsigned ns1; - UInt32 cf, sf; - if ((ns1 = c->NumStats) != 1) - { - if ((ns1 & 1) == 0) - { - /* Expand for one UNIT */ - unsigned oldNU = ns1 >> 1; - unsigned i = U2I(oldNU); - if (i != U2I(oldNU + 1)) - { - void *ptr = AllocUnits(p, i + 1); - void *oldPtr; - if (!ptr) - { - RestartModel(p); - return; - } - oldPtr = STATS(c); - MyMem12Cpy(ptr, oldPtr, oldNU); - InsertNode(p, oldPtr, i); - c->Stats = STATS_REF(ptr); + if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) { + c = SUFFIX(p->MinContext); + + if (c->NumStats == 1) { + CPpmd_State *s = ONE_STATE(c); + if (s->Freq < 32) + s->Freq++; + } else { + CPpmd_State *s = STATS(c); + if (s->Symbol != p->FoundState->Symbol) { + do { + s++; + } while (s->Symbol != p->FoundState->Symbol); + if (s[0].Freq >= s[-1].Freq) { + SwapStates(&s[0], &s[-1]); + s--; + } + } + if (s->Freq < MAX_FREQ - 9) { + s->Freq += 2; + c->SummFreq += 2; + } + } } - } - c->SummFreq = (UInt16)(c->SummFreq + (2 * ns1 < ns) + 2 * ((4 * ns1 <= ns) & (c->SummFreq <= 8 * ns1))); - } - else - { - CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0); - if (!s) - { - RestartModel(p); - return; - } - *s = *ONE_STATE(c); - c->Stats = REF(s); - if (s->Freq < MAX_FREQ / 4 - 1) - s->Freq <<= 1; - else - s->Freq = MAX_FREQ - 4; - c->SummFreq = (UInt16)(s->Freq + p->InitEsc + (ns > 3)); - } - cf = 2 * (UInt32)p->FoundState->Freq * (c->SummFreq + 6); - sf = (UInt32)s0 + c->SummFreq; - if (cf < 6 * sf) - { - cf = 1 + (cf > sf) + (cf >= 4 * sf); - c->SummFreq += 3; - } - else - { - cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf); - c->SummFreq = (UInt16)(c->SummFreq + cf); - } - { - CPpmd_State *s = STATS(c) + ns1; - SetSuccessor(s, successor); - s->Symbol = p->FoundState->Symbol; - s->Freq = (Byte)cf; - c->NumStats = (UInt16)(ns1 + 1); - } - } - p->MaxContext = p->MinContext = CTX(fSuccessor); + + if (p->OrderFall == 0) { + p->MinContext = p->MaxContext = CreateSuccessors(p, True); + if (p->MinContext == 0) { + RestartModel(p); + return; + } + SetSuccessor(p->FoundState, REF(p->MinContext)); + return; + } + + *p->Text++ = p->FoundState->Symbol; + successor = REF(p->Text); + if (p->Text >= p->UnitsStart) { + RestartModel(p); + return; + } + + if (fSuccessor) { + if (fSuccessor <= successor) { + CTX_PTR cs = CreateSuccessors(p, False); + if (cs == NULL) { + RestartModel(p); + return; + } + fSuccessor = REF(cs); + } + if (--p->OrderFall == 0) { + successor = fSuccessor; + p->Text -= (p->MaxContext != p->MinContext); + } + } else { + SetSuccessor(p->FoundState, successor); + fSuccessor = REF(p->MinContext); + } + + s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - (p->FoundState->Freq - 1); + + for (c = p->MaxContext; c != p->MinContext; c = SUFFIX(c)) { + unsigned ns1; + UInt32 cf, sf; + if ((ns1 = c->NumStats) != 1) { + if ((ns1 & 1) == 0) { + /* Expand for one UNIT */ + unsigned oldNU = ns1 >> 1; + unsigned i = U2I(oldNU); + if (i != U2I(oldNU + 1)) { + void *ptr = AllocUnits(p, i + 1); + void *oldPtr; + if (!ptr) { + RestartModel(p); + return; + } + oldPtr = STATS(c); + MyMem12Cpy(ptr, oldPtr, oldNU); + InsertNode(p, oldPtr, i); + c->Stats = STATS_REF(ptr); + } + } + c->SummFreq = (UInt16)(c->SummFreq + (2 * ns1 < ns) + + 2 * ((4 * ns1 <= ns) & (c->SummFreq <= 8 * ns1))); + } else { + CPpmd_State *s = (CPpmd_State *)AllocUnits(p, 0); + if (!s) { + RestartModel(p); + return; + } + *s = *ONE_STATE(c); + c->Stats = REF(s); + if (s->Freq < MAX_FREQ / 4 - 1) + s->Freq <<= 1; + else + s->Freq = MAX_FREQ - 4; + c->SummFreq = (UInt16)(s->Freq + p->InitEsc + (ns > 3)); + } + cf = 2 * (UInt32)p->FoundState->Freq * (c->SummFreq + 6); + sf = (UInt32)s0 + c->SummFreq; + if (cf < 6 * sf) { + cf = 1 + (cf > sf) + (cf >= 4 * sf); + c->SummFreq += 3; + } else { + cf = 4 + (cf >= 9 * sf) + (cf >= 12 * sf) + (cf >= 15 * sf); + c->SummFreq = (UInt16)(c->SummFreq + cf); + } + { + CPpmd_State *s = STATS(c) + ns1; + SetSuccessor(s, successor); + s->Symbol = p->FoundState->Symbol; + s->Freq = (Byte)cf; + c->NumStats = (UInt16)(ns1 + 1); + } + } + p->MaxContext = p->MinContext = CTX(fSuccessor); } - + static void Rescale(CPpmd7 *p) { - unsigned i, adder, sumFreq, escFreq; - CPpmd_State *stats = STATS(p->MinContext); - CPpmd_State *s = p->FoundState; - { - CPpmd_State tmp = *s; - for (; s != stats; s--) - s[0] = s[-1]; - *s = tmp; - } - escFreq = p->MinContext->SummFreq - s->Freq; - s->Freq += 4; - adder = (p->OrderFall != 0); - s->Freq = (Byte)((s->Freq + adder) >> 1); - sumFreq = s->Freq; - - i = p->MinContext->NumStats - 1; - do - { - escFreq -= (++s)->Freq; - s->Freq = (Byte)((s->Freq + adder) >> 1); - sumFreq += s->Freq; - if (s[0].Freq > s[-1].Freq) - { - CPpmd_State *s1 = s; - CPpmd_State tmp = *s1; - do - s1[0] = s1[-1]; - while (--s1 != stats && tmp.Freq > s1[-1].Freq); - *s1 = tmp; - } - } - while (--i); - - if (s->Freq == 0) - { - unsigned numStats = p->MinContext->NumStats; - unsigned n0, n1; - do { i++; } while ((--s)->Freq == 0); - escFreq += i; - p->MinContext->NumStats = (UInt16)(p->MinContext->NumStats - i); - if (p->MinContext->NumStats == 1) - { - CPpmd_State tmp = *stats; - do - { - tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); - escFreq >>= 1; - } - while (escFreq > 1); - InsertNode(p, stats, U2I(((numStats + 1) >> 1))); - *(p->FoundState = ONE_STATE(p->MinContext)) = tmp; - return; - } - n0 = (numStats + 1) >> 1; - n1 = (p->MinContext->NumStats + 1) >> 1; - if (n0 != n1) - p->MinContext->Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1)); - } - p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); - p->FoundState = STATS(p->MinContext); + unsigned i, adder, sumFreq, escFreq; + CPpmd_State *stats = STATS(p->MinContext); + CPpmd_State *s = p->FoundState; + { + CPpmd_State tmp = *s; + for (; s != stats; s--) + s[0] = s[-1]; + *s = tmp; + } + escFreq = p->MinContext->SummFreq - s->Freq; + s->Freq += 4; + adder = (p->OrderFall != 0); + s->Freq = (Byte)((s->Freq + adder) >> 1); + sumFreq = s->Freq; + + i = p->MinContext->NumStats - 1; + do { + escFreq -= (++s)->Freq; + s->Freq = (Byte)((s->Freq + adder) >> 1); + sumFreq += s->Freq; + if (s[0].Freq > s[-1].Freq) { + CPpmd_State *s1 = s; + CPpmd_State tmp = *s1; + do + s1[0] = s1[-1]; + while (--s1 != stats && tmp.Freq > s1[-1].Freq); + *s1 = tmp; + } + } while (--i); + + if (s->Freq == 0) { + unsigned numStats = p->MinContext->NumStats; + unsigned n0, n1; + do { + i++; + } while ((--s)->Freq == 0); + escFreq += i; + p->MinContext->NumStats = (UInt16)(p->MinContext->NumStats - i); + if (p->MinContext->NumStats == 1) { + CPpmd_State tmp = *stats; + do { + tmp.Freq = (Byte)(tmp.Freq - (tmp.Freq >> 1)); + escFreq >>= 1; + } while (escFreq > 1); + InsertNode(p, stats, U2I(((numStats + 1) >> 1))); + *(p->FoundState = ONE_STATE(p->MinContext)) = tmp; + return; + } + n0 = (numStats + 1) >> 1; + n1 = (p->MinContext->NumStats + 1) >> 1; + if (n0 != n1) + p->MinContext->Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1)); + } + p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); + p->FoundState = STATS(p->MinContext); } CPpmd_See *Ppmd7_MakeEscFreq(CPpmd7 *p, unsigned numMasked, UInt32 *escFreq) { - CPpmd_See *see; - unsigned nonMasked = p->MinContext->NumStats - numMasked; - if (p->MinContext->NumStats != 256) - { - see = p->See[p->NS2Indx[nonMasked - 1]] + - (nonMasked < (unsigned)SUFFIX(p->MinContext)->NumStats - p->MinContext->NumStats) + - 2 * (p->MinContext->SummFreq < 11 * p->MinContext->NumStats) + - 4 * (numMasked > nonMasked) + - p->HiBitsFlag; - { - unsigned r = (see->Summ >> see->Shift); - see->Summ = (UInt16)(see->Summ - r); - *escFreq = r + (r == 0); - } - } - else - { - see = &p->DummySee; - *escFreq = 1; - } - return see; + CPpmd_See *see; + unsigned nonMasked = p->MinContext->NumStats - numMasked; + if (p->MinContext->NumStats != 256) { + see = p->See[p->NS2Indx[nonMasked - 1]] + + (nonMasked < + (unsigned)SUFFIX(p->MinContext)->NumStats - p->MinContext->NumStats) + + 2 * (p->MinContext->SummFreq < 11 * p->MinContext->NumStats) + + 4 * (numMasked > nonMasked) + p->HiBitsFlag; + { + unsigned r = (see->Summ >> see->Shift); + see->Summ = (UInt16)(see->Summ - r); + *escFreq = r + (r == 0); + } + } else { + see = &p->DummySee; + *escFreq = 1; + } + return see; } static void NextContext(CPpmd7 *p) { - CTX_PTR c = CTX(SUCCESSOR(p->FoundState)); - if (p->OrderFall == 0 && (Byte *)c > p->Text) - p->MinContext = p->MaxContext = c; - else - UpdateModel(p); + CTX_PTR c = CTX(SUCCESSOR(p->FoundState)); + if (p->OrderFall == 0 && (Byte *)c > p->Text) + p->MinContext = p->MaxContext = c; + else + UpdateModel(p); } void Ppmd7_Update1(CPpmd7 *p) { - CPpmd_State *s = p->FoundState; - s->Freq += 4; - p->MinContext->SummFreq += 4; - if (s[0].Freq > s[-1].Freq) - { - SwapStates(&s[0], &s[-1]); - p->FoundState = --s; - if (s->Freq > MAX_FREQ) - Rescale(p); - } - NextContext(p); + CPpmd_State *s = p->FoundState; + s->Freq += 4; + p->MinContext->SummFreq += 4; + if (s[0].Freq > s[-1].Freq) { + SwapStates(&s[0], &s[-1]); + p->FoundState = --s; + if (s->Freq > MAX_FREQ) + Rescale(p); + } + NextContext(p); } void Ppmd7_Update1_0(CPpmd7 *p) { - p->PrevSuccess = (2 * p->FoundState->Freq > p->MinContext->SummFreq); - p->RunLength += p->PrevSuccess; - p->MinContext->SummFreq += 4; - if ((p->FoundState->Freq += 4) > MAX_FREQ) - Rescale(p); - NextContext(p); + p->PrevSuccess = (2 * p->FoundState->Freq > p->MinContext->SummFreq); + p->RunLength += p->PrevSuccess; + p->MinContext->SummFreq += 4; + if ((p->FoundState->Freq += 4) > MAX_FREQ) + Rescale(p); + NextContext(p); } void Ppmd7_UpdateBin(CPpmd7 *p) { - p->FoundState->Freq = (Byte)(p->FoundState->Freq + (p->FoundState->Freq < 128 ? 1: 0)); - p->PrevSuccess = 1; - p->RunLength++; - NextContext(p); + p->FoundState->Freq = (Byte)(p->FoundState->Freq + (p->FoundState->Freq < 128 ? 1 : 0)); + p->PrevSuccess = 1; + p->RunLength++; + NextContext(p); } void Ppmd7_Update2(CPpmd7 *p) { - p->MinContext->SummFreq += 4; - if ((p->FoundState->Freq += 4) > MAX_FREQ) - Rescale(p); - p->RunLength = p->InitRL; - UpdateModel(p); + p->MinContext->SummFreq += 4; + if ((p->FoundState->Freq += 4) > MAX_FREQ) + Rescale(p); + p->RunLength = p->InitRL; + UpdateModel(p); } diff --git a/fex/7z_C/Ppmd7.h b/fex/7z_C/Ppmd7.h index 56e81eb1..eccf6664 100644 --- a/fex/7z_C/Ppmd7.h +++ b/fex/7z_C/Ppmd7.h @@ -22,41 +22,39 @@ EXTERN_C_BEGIN struct CPpmd7_Context_; typedef - #ifdef PPMD_32BIT +#ifdef PPMD_32BIT struct CPpmd7_Context_ * - #else +#else UInt32 - #endif - CPpmd7_Context_Ref; +#endif + CPpmd7_Context_Ref; -typedef struct CPpmd7_Context_ -{ - UInt16 NumStats; - UInt16 SummFreq; - CPpmd_State_Ref Stats; - CPpmd7_Context_Ref Suffix; +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 */ +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; + 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]; + 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); @@ -65,19 +63,18 @@ 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) +#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))) +#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); @@ -85,31 +82,29 @@ 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)] +#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); +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; +typedef struct { + IPpmd7_RangeDec p; + UInt32 Range; + UInt32 Code; + IByteIn *Stream; } CPpmd7z_RangeDec; void Ppmd7z_RangeDec_CreateVTable(CPpmd7z_RangeDec *p); @@ -118,16 +113,14 @@ Bool Ppmd7z_RangeDec_Init(CPpmd7z_RangeDec *p); int Ppmd7_DecodeSymbol(CPpmd7 *p, IPpmd7_RangeDec *rc); - /* ---------- Encode ---------- */ -typedef struct -{ - UInt64 Low; - UInt32 Range; - Byte Cache; - UInt64 CacheSize; - IByteOut *Stream; +typedef struct { + UInt64 Low; + UInt32 Range; + Byte Cache; + UInt64 CacheSize; + IByteOut *Stream; } CPpmd7z_RangeEnc; void Ppmd7z_RangeEnc_Init(CPpmd7z_RangeEnc *p); @@ -136,5 +129,5 @@ void Ppmd7z_RangeEnc_FlushData(CPpmd7z_RangeEnc *p); void Ppmd7_EncodeSymbol(CPpmd7 *p, CPpmd7z_RangeEnc *rc, int symbol); EXTERN_C_END - + #endif diff --git a/fex/7z_C/Ppmd7Dec.c b/fex/7z_C/Ppmd7Dec.c index d6608e8b..c4884145 100644 --- a/fex/7z_C/Ppmd7Dec.c +++ b/fex/7z_C/Ppmd7Dec.c @@ -8,180 +8,165 @@ This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ 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); + 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); + 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; - } - } + 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); + 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; + 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; + 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); - } + 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); + } } diff --git a/fex/7z_C/Types.h b/fex/7z_C/Types.h index 7732c240..0d083c0f 100644 --- a/fex/7z_C/Types.h +++ b/fex/7z_C/Types.h @@ -49,7 +49,12 @@ typedef int WRes; #endif #ifndef RINOK -#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } +#define RINOK(x) \ + { \ + int __result__ = (x); \ + if (__result__ != 0) \ + return __result__; \ + } #endif typedef unsigned char Byte; @@ -81,7 +86,7 @@ typedef unsigned __int64 UInt64; #else typedef long long int Int64; typedef unsigned long long int UInt64; -#define UINT64_CONST(n) n ## ULL +#define UINT64_CONST(n) n##ULL #endif #endif @@ -96,7 +101,6 @@ typedef int Bool; #define True 1 #define False 0 - #ifdef _WIN32 #define MY_STD_CALL __stdcall #else @@ -121,24 +125,20 @@ typedef int Bool; #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 */ +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); +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 */ +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 */ @@ -146,38 +146,30 @@ 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 */ +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 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); +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 */ +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); + 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); @@ -189,45 +181,40 @@ 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]; +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; +typedef struct { + ISeqInStream s; + ILookInStream *realStream; } CSecToLook; void SecToLook_CreateVTable(CSecToLook *p); -typedef struct -{ - ISeqInStream s; - ILookInStream *realStream; +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. */ +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 */ +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) diff --git a/fex/fex/Binary_Extractor.h b/fex/fex/Binary_Extractor.h index 339a0873..af772ca7 100644 --- a/fex/fex/Binary_Extractor.h +++ b/fex/fex/Binary_Extractor.h @@ -6,21 +6,22 @@ #include "File_Extractor.h" -class Binary_Extractor : public File_Extractor { -public: - Binary_Extractor(); - virtual ~Binary_Extractor(); +class Binary_Extractor : public File_Extractor +{ + public: + Binary_Extractor(); + virtual ~Binary_Extractor(); -protected: - virtual blargg_err_t open_path_v(); - virtual blargg_err_t open_v(); - virtual void close_v(); - - virtual blargg_err_t next_v(); - virtual blargg_err_t rewind_v(); + protected: + virtual blargg_err_t open_path_v(); + virtual blargg_err_t open_v(); + virtual void close_v(); - virtual blargg_err_t stat_v(); - virtual blargg_err_t extract_v( void*, int ); + virtual blargg_err_t next_v(); + virtual blargg_err_t rewind_v(); + + virtual blargg_err_t stat_v(); + virtual blargg_err_t extract_v(void *, int); }; #endif diff --git a/fex/fex/Data_Reader.h b/fex/fex/Data_Reader.h index be206f7b..6c0bbc8d 100644 --- a/fex/fex/Data_Reader.h +++ b/fex/fex/Data_Reader.h @@ -16,249 +16,278 @@ something compiler-specific, and change all places file sizes or offsets are used. */ // Supports reading and finding out how many bytes are remaining -class Data_Reader { -public: +class Data_Reader +{ + public: + // Reads min(*n,remain()) bytes and sets *n to this number, thus trying to read more + // tham remain() bytes doesn't result in error, just *n being set to remain(). + blargg_err_t read_avail(void *p, int *n); + blargg_err_t read_avail(void *p, long *n); - // Reads min(*n,remain()) bytes and sets *n to this number, thus trying to read more - // tham remain() bytes doesn't result in error, just *n being set to remain(). - blargg_err_t read_avail( void* p, int* n ); - blargg_err_t read_avail( void* p, long* n ); + // Reads exactly n bytes, or returns error if they couldn't ALL be read. + // Reading past end of file results in blargg_err_file_eof. + blargg_err_t read(void *p, int n); - // Reads exactly n bytes, or returns error if they couldn't ALL be read. - // Reading past end of file results in blargg_err_file_eof. - blargg_err_t read( void* p, int n ); + // Number of bytes remaining until end of file + int remain() const + { + return remain_; + } - // Number of bytes remaining until end of file - int remain() const { return remain_; } + // Reads and discards n bytes. Skipping past end of file results in blargg_err_file_eof. + blargg_err_t skip(int n); - // Reads and discards n bytes. Skipping past end of file results in blargg_err_file_eof. - blargg_err_t skip( int n ); - - virtual ~Data_Reader() { } + virtual ~Data_Reader() + { + } -private: - // noncopyable - Data_Reader( const Data_Reader& ); - Data_Reader& operator = ( const Data_Reader& ); + private: + // noncopyable + Data_Reader(const Data_Reader &); + Data_Reader &operator=(const Data_Reader &); -// Derived interface -protected: - Data_Reader() : remain_( 0 ) { } - - // Sets remain - void set_remain( int n ) { assert( n >= 0 ); remain_ = n; } - - // Do same as read(). Guaranteed that 0 < n <= remain(). Value of remain() is updated - // AFTER this call succeeds, not before. set_remain() should NOT be called from this. - virtual blargg_err_t read_v( void*, int n ) BLARGG_PURE( { (void)n; return blargg_ok; } ) - - // Do same as skip(). Guaranteed that 0 < n <= remain(). Default just reads data - // and discards it. Value of remain() is updated AFTER this call succeeds, not - // before. set_remain() should NOT be called from this. - virtual blargg_err_t skip_v( int n ); + // Derived interface + protected: + Data_Reader() : remain_(0) + { + } -// Implementation -public: - BLARGG_DISABLE_NOTHROW - -private: - int remain_; + // Sets remain + void set_remain(int n) + { + assert(n >= 0); + remain_ = n; + } + + // Do same as read(). Guaranteed that 0 < n <= remain(). Value of remain() is updated + // AFTER this call succeeds, not before. set_remain() should NOT be called from this. + virtual blargg_err_t read_v(void *, int n) BLARGG_PURE({ + (void)n; + return blargg_ok; + }) + + // Do same as skip(). Guaranteed that 0 < n <= remain(). Default just reads data + // and discards it. Value of remain() is updated AFTER this call succeeds, not + // before. set_remain() should NOT be called from this. + virtual blargg_err_t skip_v(int n); + + // Implementation + public: + BLARGG_DISABLE_NOTHROW + + private: + int remain_; }; - // Supports seeking in addition to Data_Reader operations -class File_Reader : public Data_Reader { -public: +class File_Reader : public Data_Reader +{ + public: + // Size of file + int size() const + { + return size_; + } - // Size of file - int size() const { return size_; } + // Current position in file + int tell() const + { + return size_ - remain(); + } - // Current position in file - int tell() const { return size_ - remain(); } + // Goes to new position + blargg_err_t seek(int); - // Goes to new position - blargg_err_t seek( int ); + // Derived interface + protected: + // Sets size and resets position + void set_size(int n) + { + size_ = n; + Data_Reader::set_remain(n); + } + void set_size(long n) + { + set_size(STATIC_CAST(int, n)); + } -// Derived interface -protected: - // Sets size and resets position - void set_size( int n ) { size_ = n; Data_Reader::set_remain( n ); } - void set_size( long n ) { set_size( STATIC_CAST(int, n) ); } - - // Sets reported position - void set_tell( int i ) { assert( 0 <= i && i <= size_ ); Data_Reader::set_remain( size_ - i ); } - - // Do same as seek(). Guaranteed that 0 <= n <= size(). Value of tell() is updated - // AFTER this call succeeds, not before. set_* functions should NOT be called from this. - virtual blargg_err_t seek_v( int n ) BLARGG_PURE( { (void)n; return blargg_ok; } ) - -// Implementation -protected: - File_Reader() : size_( 0 ) { } - - virtual blargg_err_t skip_v( int ); + // Sets reported position + void set_tell(int i) + { + assert(0 <= i && i <= size_); + Data_Reader::set_remain(size_ - i); + } -private: - int size_; - - void set_remain(); // avoid accidental use of set_remain + // Do same as seek(). Guaranteed that 0 <= n <= size(). Value of tell() is updated + // AFTER this call succeeds, not before. set_* functions should NOT be called from this. + virtual blargg_err_t seek_v(int n) BLARGG_PURE({ + (void)n; + return blargg_ok; + }) + + // Implementation + protected : File_Reader() + : size_(0) + { + } + + virtual blargg_err_t skip_v(int); + + private: + int size_; + + void set_remain(); // avoid accidental use of set_remain }; - // Reads from file on disk -class Std_File_Reader : public File_Reader { -public: +class Std_File_Reader : public File_Reader +{ + public: + // Opens file + blargg_err_t open(const char path[]); - // Opens file - blargg_err_t open( const char path [] ); - - // Closes file if one was open - void close(); + // Closes file if one was open + void close(); - // Switches to unbuffered mode. Useful if buffering is already being - // done at a higher level. - void make_unbuffered(); + // Switches to unbuffered mode. Useful if buffering is already being + // done at a higher level. + void make_unbuffered(); -// Implementation -public: - Std_File_Reader(); - virtual ~Std_File_Reader(); - -protected: - virtual blargg_err_t read_v( void*, int ); - virtual blargg_err_t seek_v( int ); + // Implementation + public: + Std_File_Reader(); + virtual ~Std_File_Reader(); -private: - void* file_; + protected: + virtual blargg_err_t read_v(void *, int); + virtual blargg_err_t seek_v(int); + + private: + void *file_; }; - // Treats range of memory as a file -class Mem_File_Reader : public File_Reader { -public: +class Mem_File_Reader : public File_Reader +{ + public: + Mem_File_Reader(const void *begin, long size); - Mem_File_Reader( const void* begin, long size ); + // Implementation + protected: + virtual blargg_err_t read_v(void *, int); + virtual blargg_err_t seek_v(int); -// Implementation -protected: - virtual blargg_err_t read_v( void*, int ); - virtual blargg_err_t seek_v( int ); - -private: - const char* const begin; + private: + const char *const begin; }; - // Allows only count bytes to be read from reader passed -class Subset_Reader : public Data_Reader { -public: +class Subset_Reader : public Data_Reader +{ + public: + Subset_Reader(Data_Reader *, int count); - Subset_Reader( Data_Reader*, int count ); + // Implementation + protected: + virtual blargg_err_t read_v(void *, int); -// Implementation -protected: - virtual blargg_err_t read_v( void*, int ); - -private: - Data_Reader* const in; + private: + Data_Reader *const in; }; - // Joins already-read header and remaining data into original file. // Meant for cases where you've already read header and don't want // to seek and re-read data (for efficiency). -class Remaining_Reader : public Data_Reader { -public: +class Remaining_Reader : public Data_Reader +{ + public: + Remaining_Reader(void const *header, int header_size, Data_Reader *); - Remaining_Reader( void const* header, int header_size, Data_Reader* ); + // Implementation + protected: + virtual blargg_err_t read_v(void *, int); -// Implementation -protected: - virtual blargg_err_t read_v( void*, int ); - -private: - Data_Reader* const in; - void const* header; - int header_remain; + private: + Data_Reader *const in; + void const *header; + int header_remain; }; - // Invokes callback function to read data -extern "C" { // necessary to be usable from C - typedef const char* (*callback_reader_func_t)( - void* user_data, // Same value passed to constructor - void* out, // Buffer to place data into - int count // Number of bytes to read - ); +extern "C" { // necessary to be usable from C +typedef const char *(*callback_reader_func_t)(void *user_data, // Same value passed to constructor + void *out, // Buffer to place data into + int count // Number of bytes to read + ); } -class Callback_Reader : public Data_Reader { -public: - typedef callback_reader_func_t callback_t; - Callback_Reader( callback_t, long size, void* user_data ); - -// Implementation -protected: - virtual blargg_err_t read_v( void*, int ); +class Callback_Reader : public Data_Reader +{ + public: + typedef callback_reader_func_t callback_t; + Callback_Reader(callback_t, long size, void *user_data); -private: - callback_t const callback; - void* const user_data; + // Implementation + protected: + virtual blargg_err_t read_v(void *, int); + + private: + callback_t const callback; + void *const user_data; }; - // Invokes callback function to read data -extern "C" { // necessary to be usable from C - typedef const char* (*callback_file_reader_func_t)( - void* user_data, // Same value passed to constructor - void* out, // Buffer to place data into - int count, // Number of bytes to read - int pos // Position in file to read from - ); +extern "C" { // necessary to be usable from C +typedef const char *(*callback_file_reader_func_t)(void *user_data, // Same value passed to + // constructor + void *out, // Buffer to place data into + int count, // Number of bytes to read + int pos // Position in file to read from + ); } -class Callback_File_Reader : public File_Reader { -public: - typedef callback_file_reader_func_t callback_t; - Callback_File_Reader( callback_t, long size, void* user_data ); - -// Implementation -protected: - virtual blargg_err_t read_v( void*, int ); - virtual blargg_err_t seek_v( int ); +class Callback_File_Reader : public File_Reader +{ + public: + typedef callback_file_reader_func_t callback_t; + Callback_File_Reader(callback_t, long size, void *user_data); -private: - callback_t const callback; - void* const user_data; + // Implementation + protected: + virtual blargg_err_t read_v(void *, int); + virtual blargg_err_t seek_v(int); + + private: + callback_t const callback; + void *const user_data; }; - #ifdef HAVE_ZLIB_H // Reads file compressed with gzip (or uncompressed) -class Gzip_File_Reader : public File_Reader { -public: +class Gzip_File_Reader : public File_Reader +{ + public: + // Opens possibly gzipped file + blargg_err_t open(const char path[]); - // Opens possibly gzipped file - blargg_err_t open( const char path [] ); - - // Closes file if one was open - void close(); + // Closes file if one was open + void close(); -// Implementation -public: - Gzip_File_Reader(); - ~Gzip_File_Reader(); - -protected: - virtual blargg_err_t read_v( void*, int ); - virtual blargg_err_t seek_v( int ); - -private: - // void* so "zlib.h" doesn't have to be included here - void* file_; + // Implementation + public: + Gzip_File_Reader(); + ~Gzip_File_Reader(); + + protected: + virtual blargg_err_t read_v(void *, int); + virtual blargg_err_t seek_v(int); + + private: + // void* so "zlib.h" doesn't have to be included here + void *file_; }; #endif -char* blargg_to_utf8( const wchar_t* ); -wchar_t* blargg_to_wide( const char* ); +char *blargg_to_utf8(const wchar_t *); +wchar_t *blargg_to_wide(const char *); #endif diff --git a/fex/fex/File_Extractor.h b/fex/fex/File_Extractor.h index ad25d5f8..496a29c4 100644 --- a/fex/fex/File_Extractor.h +++ b/fex/fex/File_Extractor.h @@ -4,188 +4,239 @@ #ifndef FILE_EXTRACTOR_H #define FILE_EXTRACTOR_H -#include "blargg_common.h" #include "Data_Reader.h" +#include "blargg_common.h" #include "fex.h" struct fex_t : private Data_Reader { -public: - virtual ~fex_t(); - -// Open/close + public: + virtual ~fex_t(); - // Opens archive from custom data source. Keeps pointer until close(). - blargg_err_t open( File_Reader* input, const char* path = NULL ); - - // Takes ownership of File_Reader* passed to open(), so that close() - // will delete it. - void own_file() { own_file_ = reader_; } - - // See fex.h - blargg_err_t open( const char path [] ); - fex_type_t type() const { return type_; } - void close(); + // Open/close -// Scanning + // Opens archive from custom data source. Keeps pointer until close(). + blargg_err_t open(File_Reader *input, const char *path = NULL); - // See fex.h - bool done() const { return done_; } - blargg_err_t next(); - blargg_err_t rewind(); - fex_pos_t tell_arc() const; - blargg_err_t seek_arc( fex_pos_t ); + // Takes ownership of File_Reader* passed to open(), so that close() + // will delete it. + void own_file() + { + own_file_ = reader_; + } -// Info + // See fex.h + blargg_err_t open(const char path[]); + fex_type_t type() const + { + return type_; + } + void close(); - // See fex.h - const char* name() const { return name_; } - const wchar_t* wname() const { return wname_; } - blargg_err_t stat(); - int size() const { assert( stat_called ); return size_; } - unsigned int dos_date() const { return date_; } - unsigned int crc32() const { return crc32_; } - -// Extraction + // Scanning - // Data_Reader to current file's data, so standard Data_Reader interface can - // be used, rather than having to treat archives specially. stat() must have - // been called. - Data_Reader& reader() { assert( stat_called ); return *this; } + // See fex.h + bool done() const + { + return done_; + } + blargg_err_t next(); + blargg_err_t rewind(); + fex_pos_t tell_arc() const; + blargg_err_t seek_arc(fex_pos_t); - // See fex.h - blargg_err_t data( const void** data_out ); - int tell() const { return size_ - remain(); } - -// Derived interface -protected: - - // Sets type of object - fex_t( fex_type_t ); - - // Path to archive file, or "" if none supplied - const char* arc_path() const { return path_.begin(); } - - // Opens archive file if it's not already. If unbuffered is true, opens file - // without any buffering. - blargg_err_t open_arc_file( bool unbuffered = false ); - - // Archive file - File_Reader& arc() const { return *reader_; } - - // Sets current file name - void set_name( const char name [], const wchar_t* wname = NULL ); - - // Sets current file information - void set_info( int size, unsigned date = 0, unsigned crc = 0 ); - -// User overrides + // Info - // Overrides must do indicated task. Non-pure functions have reasonable default - // implementation. Overrides should avoid calling public functions like - // next() and rewind(). - - // Open archive using file_path(). OK to delay actual file opening until later. - // Default just calls open_arc_file(), then open_v(). - virtual blargg_err_t open_path_v(); - - // Open archive using file() for source data. If unsupported, return error. - virtual blargg_err_t open_v() BLARGG_PURE( ; ) - - // Go to next file in archive and call set_name() and optionally set_info() - virtual blargg_err_t next_v() BLARGG_PURE( ; ) - - // Go back to first file in archive - virtual blargg_err_t rewind_v() BLARGG_PURE( ; ) - - // Close archive. Called even if open_path_v() or open_v() return unsuccessfully. - virtual void close_v() BLARGG_PURE( ; ) - - // Clear any fields related to current file - virtual void clear_file_v() { } - - // Call set_info() if not already called by next_v() - virtual blargg_err_t stat_v() { return blargg_ok; } - - // Return value that allows later return to this file. Result must be >= 0. - virtual fex_pos_t tell_arc_v() const; - - // Return to previously saved position - virtual blargg_err_t seek_arc_v( fex_pos_t ); - - // One or both of the following must be overridden - - // Provide pointer to data for current file in archive - virtual blargg_err_t data_v( const void** out ); - - // Extract next n bytes - virtual blargg_err_t extract_v( void* out, int n ); - -// Implementation -public: - BLARGG_DISABLE_NOTHROW + // See fex.h + const char *name() const + { + return name_; + } + const wchar_t *wname() const + { + return wname_; + } + blargg_err_t stat(); + int size() const + { + assert(stat_called); + return size_; + } + unsigned int dos_date() const + { + return date_; + } + unsigned int crc32() const + { + return crc32_; + } -private: - fex_type_t const type_; - - // Archive file - blargg_vector path_; - File_Reader* reader_; - File_Reader* own_file_; - bool opened_; - - // Position in archive - fex_pos_t tell_; // only used by default implementation of tell/seek - bool done_; - - // Info for current file in archive - const char* name_; - const wchar_t* wname_; - unsigned date_; - unsigned crc32_; - int size_; - bool stat_called; - - // Current file contents - void const* data_ptr_; // NULL if not read into memory - blargg_vector own_data_; + // Extraction - bool opened() const { return opened_; } - void clear_file(); - void close_(); - blargg_err_t set_path( const char* path ); - blargg_err_t rewind_file(); - blargg_err_t next_(); - - // Data_Reader overrides - // TODO: override skip_v? - virtual blargg_err_t read_v( void* out, int n ); + // Data_Reader to current file's data, so standard Data_Reader interface can + // be used, rather than having to treat archives specially. stat() must have + // been called. + Data_Reader &reader() + { + assert(stat_called); + return *this; + } + + // See fex.h + blargg_err_t data(const void **data_out); + int tell() const + { + return size_ - remain(); + } + + // Derived interface + protected: + // Sets type of object + fex_t(fex_type_t); + + // Path to archive file, or "" if none supplied + const char *arc_path() const + { + return path_.begin(); + } + + // Opens archive file if it's not already. If unbuffered is true, opens file + // without any buffering. + blargg_err_t open_arc_file(bool unbuffered = false); + + // Archive file + File_Reader &arc() const + { + return *reader_; + } + + // Sets current file name + void set_name(const char name[], const wchar_t *wname = NULL); + + // Sets current file information + void set_info(int size, unsigned date = 0, unsigned crc = 0); + + // User overrides + + // Overrides must do indicated task. Non-pure functions have reasonable default + // implementation. Overrides should avoid calling public functions like + // next() and rewind(). + + // Open archive using file_path(). OK to delay actual file opening until later. + // Default just calls open_arc_file(), then open_v(). + virtual blargg_err_t open_path_v(); + + // Open archive using file() for source data. If unsupported, return error. + virtual blargg_err_t open_v() BLARGG_PURE(;) + + // Go to next file in archive and call set_name() and optionally set_info() + virtual blargg_err_t next_v() BLARGG_PURE(;) + + // Go back to first file in archive + virtual blargg_err_t rewind_v() BLARGG_PURE(;) + + // Close archive. Called even if open_path_v() or open_v() return unsuccessfully. + virtual void close_v() BLARGG_PURE(;) + + // Clear any fields related to current file + virtual void clear_file_v() + { + } + + // Call set_info() if not already called by next_v() + virtual blargg_err_t stat_v() + { + return blargg_ok; + } + + // Return value that allows later return to this file. Result must be >= 0. + virtual fex_pos_t tell_arc_v() const; + + // Return to previously saved position + virtual blargg_err_t seek_arc_v(fex_pos_t); + + // One or both of the following must be overridden + + // Provide pointer to data for current file in archive + virtual blargg_err_t data_v(const void **out); + + // Extract next n bytes + virtual blargg_err_t extract_v(void *out, int n); + + // Implementation + public: + BLARGG_DISABLE_NOTHROW + + private: + fex_type_t const type_; + + // Archive file + blargg_vector path_; + File_Reader *reader_; + File_Reader *own_file_; + bool opened_; + + // Position in archive + fex_pos_t tell_; // only used by default implementation of tell/seek + bool done_; + + // Info for current file in archive + const char *name_; + const wchar_t *wname_; + unsigned date_; + unsigned crc32_; + int size_; + bool stat_called; + + // Current file contents + void const *data_ptr_; // NULL if not read into memory + blargg_vector own_data_; + + bool opened() const + { + return opened_; + } + void clear_file(); + void close_(); + blargg_err_t set_path(const char *path); + blargg_err_t rewind_file(); + blargg_err_t next_(); + + // Data_Reader overrides + // TODO: override skip_v? + virtual blargg_err_t read_v(void *out, int n); }; -struct fex_type_t_ +struct fex_type_t_ { + const char *extension; + File_Extractor *(*new_fex)(); + const char *name; + blargg_err_t (*init)(); // Called by fex_init(). Can be NULL. +}; + +extern const fex_type_t_ fex_7z_type[1], fex_gz_type[1], fex_rar_type[1], fex_zip_type[1], + fex_bin_type[1]; + +inline blargg_err_t File_Extractor::open_v() { - const char* extension; - File_Extractor* (*new_fex)(); - const char* name; - blargg_err_t (*init)(); // Called by fex_init(). Can be NULL. -}; - -extern const fex_type_t_ - fex_7z_type [1], - fex_gz_type [1], - fex_rar_type [1], - fex_zip_type [1], - fex_bin_type [1]; - -inline blargg_err_t File_Extractor::open_v() { return blargg_ok; } -inline blargg_err_t File_Extractor::next_v() { return blargg_ok; } -inline blargg_err_t File_Extractor::rewind_v() { return blargg_ok; } -inline void File_Extractor::close_v() { } + return blargg_ok; +} +inline blargg_err_t File_Extractor::next_v() +{ + return blargg_ok; +} +inline blargg_err_t File_Extractor::rewind_v() +{ + return blargg_ok; +} +inline void File_Extractor::close_v() +{ +} // Default to Std_File_Reader for archive access #ifndef FEX_FILE_READER - #define FEX_FILE_READER Std_File_Reader -#elif defined (FEX_FILE_READER_INCLUDE) - #include FEX_FILE_READER_INCLUDE +#define FEX_FILE_READER Std_File_Reader +#elif defined(FEX_FILE_READER_INCLUDE) +#include FEX_FILE_READER_INCLUDE #endif #endif diff --git a/fex/fex/Gzip_Extractor.h b/fex/fex/Gzip_Extractor.h index 814dc9b3..d598ab2f 100644 --- a/fex/fex/Gzip_Extractor.h +++ b/fex/fex/Gzip_Extractor.h @@ -8,27 +8,28 @@ #include "File_Extractor.h" #include "Gzip_Reader.h" -class Gzip_Extractor : public File_Extractor { -public: - Gzip_Extractor(); - virtual ~Gzip_Extractor(); +class Gzip_Extractor : public File_Extractor +{ + public: + Gzip_Extractor(); + virtual ~Gzip_Extractor(); -protected: - virtual blargg_err_t open_path_v(); - virtual blargg_err_t open_v(); - virtual void close_v(); - - virtual blargg_err_t next_v(); - virtual blargg_err_t rewind_v(); + protected: + virtual blargg_err_t open_path_v(); + virtual blargg_err_t open_v(); + virtual void close_v(); - virtual blargg_err_t stat_v(); - virtual blargg_err_t extract_v( void*, int ); - -private: - Gzip_Reader gr; - blargg_vector name; - - void set_info_(); + virtual blargg_err_t next_v(); + virtual blargg_err_t rewind_v(); + + virtual blargg_err_t stat_v(); + virtual blargg_err_t extract_v(void *, int); + + private: + Gzip_Reader gr; + blargg_vector name; + + void set_info_(); }; #endif diff --git a/fex/fex/Gzip_Reader.h b/fex/fex/Gzip_Reader.h index a9b2d6a9..22f3b968 100644 --- a/fex/fex/Gzip_Reader.h +++ b/fex/fex/Gzip_Reader.h @@ -7,40 +7,53 @@ #include "Data_Reader.h" #include "Zlib_Inflater.h" -class Gzip_Reader : public Data_Reader { -public: - // Keeps pointer to reader until close(). If - blargg_err_t open( File_Reader* ); - - // True if file is open - bool opened() const { return in != NULL; } - - // Frees memory - void close(); - - // True if file is compressed - bool deflated() const { return inflater.deflated(); } - - // CRC-32 of data, of 0 if unavailable - unsigned int crc32() const { return crc32_; } - - // Number of bytes read since opening - int tell() const { return size_ - remain(); } +class Gzip_Reader : public Data_Reader +{ + public: + // Keeps pointer to reader until close(). If + blargg_err_t open(File_Reader *); -public: - Gzip_Reader(); - virtual ~Gzip_Reader(); - -protected: - virtual blargg_err_t read_v( void*, int ); + // True if file is open + bool opened() const + { + return in != NULL; + } -private: - File_Reader* in; - unsigned crc32_; - int size_; - Zlib_Inflater inflater; + // Frees memory + void close(); - blargg_err_t calc_size(); + // True if file is compressed + bool deflated() const + { + return inflater.deflated(); + } + + // CRC-32 of data, of 0 if unavailable + unsigned int crc32() const + { + return crc32_; + } + + // Number of bytes read since opening + int tell() const + { + return size_ - remain(); + } + + public: + Gzip_Reader(); + virtual ~Gzip_Reader(); + + protected: + virtual blargg_err_t read_v(void *, int); + + private: + File_Reader *in; + unsigned crc32_; + int size_; + Zlib_Inflater inflater; + + blargg_err_t calc_size(); }; #endif diff --git a/fex/fex/Rar_Extractor.h b/fex/fex/Rar_Extractor.h index 9a74dea3..ac1c12a9 100644 --- a/fex/fex/Rar_Extractor.h +++ b/fex/fex/Rar_Extractor.h @@ -7,37 +7,37 @@ #include "File_Extractor.h" #include "unrar/unrar.h" -class Rar_Extractor : public File_Extractor { -public: - Rar_Extractor(); - virtual ~Rar_Extractor(); +class Rar_Extractor : public File_Extractor +{ + public: + Rar_Extractor(); + virtual ~Rar_Extractor(); - struct read_callback_t - { - const char* err; - int pos; - File_Reader* in; - }; - -protected: - virtual blargg_err_t open_v(); - virtual void close_v(); - - virtual blargg_err_t next_v(); - virtual blargg_err_t rewind_v(); - virtual fex_pos_t tell_arc_v() const; - virtual blargg_err_t seek_arc_v( fex_pos_t ); + struct read_callback_t { + const char *err; + int pos; + File_Reader *in; + }; - virtual blargg_err_t data_v( void const** ); - virtual blargg_err_t extract_v( void*, int ); - -private: - unrar_t* unrar; - read_callback_t reader; - - blargg_err_t convert_err( unrar_err_t ); - blargg_err_t skip_unextractables(); - blargg_err_t next_raw(); + protected: + virtual blargg_err_t open_v(); + virtual void close_v(); + + virtual blargg_err_t next_v(); + virtual blargg_err_t rewind_v(); + virtual fex_pos_t tell_arc_v() const; + virtual blargg_err_t seek_arc_v(fex_pos_t); + + virtual blargg_err_t data_v(void const **); + virtual blargg_err_t extract_v(void *, int); + + private: + unrar_t *unrar; + read_callback_t reader; + + blargg_err_t convert_err(unrar_err_t); + blargg_err_t skip_unextractables(); + blargg_err_t next_raw(); }; #endif diff --git a/fex/fex/Zip7_Extractor.h b/fex/fex/Zip7_Extractor.h index a1d7e01c..b7b70362 100644 --- a/fex/fex/Zip7_Extractor.h +++ b/fex/fex/Zip7_Extractor.h @@ -8,31 +8,32 @@ struct Zip7_Extractor_Impl; -class Zip7_Extractor : public File_Extractor { -public: - Zip7_Extractor(); - virtual ~Zip7_Extractor(); +class Zip7_Extractor : public File_Extractor +{ + public: + Zip7_Extractor(); + virtual ~Zip7_Extractor(); -protected: - virtual blargg_err_t open_v(); - virtual void close_v(); - - virtual blargg_err_t next_v(); - virtual blargg_err_t rewind_v(); - virtual fex_pos_t tell_arc_v() const; - virtual blargg_err_t seek_arc_v( fex_pos_t ); + protected: + virtual blargg_err_t open_v(); + virtual void close_v(); - virtual blargg_err_t data_v( void const** out ); - - bool utf16ToUtf8( unsigned char* dest, size_t* destLen, const short* src, size_t srcLen ); - -private: - Zip7_Extractor_Impl* impl; - int index; - blargg_vector name8; - blargg_vector name16; - - blargg_err_t zip7_err( int err ); + virtual blargg_err_t next_v(); + virtual blargg_err_t rewind_v(); + virtual fex_pos_t tell_arc_v() const; + virtual blargg_err_t seek_arc_v(fex_pos_t); + + virtual blargg_err_t data_v(void const **out); + + bool utf16ToUtf8(unsigned char *dest, size_t *destLen, const short *src, size_t srcLen); + + private: + Zip7_Extractor_Impl *impl; + int index; + blargg_vector name8; + blargg_vector name16; + + blargg_err_t zip7_err(int err); }; #endif diff --git a/fex/fex/Zip_Extractor.h b/fex/fex/Zip_Extractor.h index 9742df99..1b115380 100644 --- a/fex/fex/Zip_Extractor.h +++ b/fex/fex/Zip_Extractor.h @@ -7,39 +7,40 @@ #include "File_Extractor.h" #include "Zlib_Inflater.h" -class Zip_Extractor : public File_Extractor { -public: - Zip_Extractor(); - virtual ~Zip_Extractor(); +class Zip_Extractor : public File_Extractor +{ + public: + Zip_Extractor(); + virtual ~Zip_Extractor(); -protected: - virtual blargg_err_t open_path_v(); - virtual blargg_err_t open_v(); - virtual void close_v(); - - virtual void clear_file_v(); - virtual blargg_err_t next_v(); - virtual blargg_err_t rewind_v(); - virtual fex_pos_t tell_arc_v() const; - virtual blargg_err_t seek_arc_v( fex_pos_t ); - - virtual blargg_err_t extract_v( void*, int ); + protected: + virtual blargg_err_t open_path_v(); + virtual blargg_err_t open_v(); + virtual void close_v(); -private: - blargg_vector catalog; - int catalog_begin; // offset of first catalog entry in file (to detect corruption) - int catalog_pos; // position of current entry in catalog - int raw_remain; // bytes remaining to be read from zip file for current file - unsigned crc; // ongoing CRC of extracted bytes - unsigned correct_crc; - bool file_deflated; - Zlib_Inflater buf; + virtual void clear_file_v(); + virtual blargg_err_t next_v(); + virtual blargg_err_t rewind_v(); + virtual fex_pos_t tell_arc_v() const; + virtual blargg_err_t seek_arc_v(fex_pos_t); - blargg_err_t fill_buf( int offset, int buf_size, int initial_read ); - blargg_err_t update_info( bool advance_first ); - blargg_err_t first_read( int count ); - void reorder_entry_header( int offset ); - static blargg_err_t inflater_read( void* data, void* out, int* count ); + virtual blargg_err_t extract_v(void *, int); + + private: + blargg_vector catalog; + int catalog_begin; // offset of first catalog entry in file (to detect corruption) + int catalog_pos; // position of current entry in catalog + int raw_remain; // bytes remaining to be read from zip file for current file + unsigned crc; // ongoing CRC of extracted bytes + unsigned correct_crc; + bool file_deflated; + Zlib_Inflater buf; + + blargg_err_t fill_buf(int offset, int buf_size, int initial_read); + blargg_err_t update_info(bool advance_first); + blargg_err_t first_read(int count); + void reorder_entry_header(int offset); + static blargg_err_t inflater_read(void *data, void *out, int *count); }; #endif diff --git a/fex/fex/Zlib_Inflater.h b/fex/fex/Zlib_Inflater.h index a585b080..d1901422 100644 --- a/fex/fex/Zlib_Inflater.h +++ b/fex/fex/Zlib_Inflater.h @@ -4,67 +4,78 @@ #ifndef ZLIB_INFLATER_H #define ZLIB_INFLATER_H -#include "blargg_common.h" #include "Data_Reader.h" +#include "blargg_common.h" #include "zlib.h" -class Zlib_Inflater { -public: +class Zlib_Inflater +{ + public: + // Reads at most min(*count,bytes_until_eof()) bytes into *out and set *count + // to that number, or returns error if that many can't be read. + typedef blargg_err_t (*callback_t)(void *user_data, void *out, int *count); - // Reads at most min(*count,bytes_until_eof()) bytes into *out and set *count - // to that number, or returns error if that many can't be read. - typedef blargg_err_t (*callback_t)( void* user_data, void* out, int* count ); + // Begins by setting callback and filling buffer. Default buffer is 16K and + // filled to 4K, or specify buf_size and initial_read for custom buffer size + // and how much to read initially. + blargg_err_t begin(callback_t, void *user_data, int buf_size = 0, int initial_read = 0); - // Begins by setting callback and filling buffer. Default buffer is 16K and - // filled to 4K, or specify buf_size and initial_read for custom buffer size - // and how much to read initially. - blargg_err_t begin( callback_t, void* user_data, - int buf_size = 0, int initial_read = 0 ); + // Data read into buffer by begin() + const unsigned char *data() const + { + return zbuf.next_in; + } + int filled() const + { + return zbuf.avail_in; + } - // Data read into buffer by begin() - const unsigned char* data() const { return zbuf.next_in; } - int filled() const { return zbuf.avail_in; } + // Begins inflation using specified mode. Using mode_auto selects between + // mode_copy and mode_ungz by examining first two bytes of buffer. Use + // buf_offset to specify where data begins in buffer, in case there is + // header data that should be skipped. + enum mode_t { mode_copy, mode_ungz, mode_raw_deflate, mode_auto }; + blargg_err_t set_mode(mode_t, int buf_offset = 0); - // Begins inflation using specified mode. Using mode_auto selects between - // mode_copy and mode_ungz by examining first two bytes of buffer. Use - // buf_offset to specify where data begins in buffer, in case there is - // header data that should be skipped. - enum mode_t { mode_copy, mode_ungz, mode_raw_deflate, mode_auto }; - blargg_err_t set_mode( mode_t, int buf_offset = 0 ); + // True if set_mode() has been called with mode_ungz or mode_raw_deflate + bool deflated() const + { + return deflated_; + } - // True if set_mode() has been called with mode_ungz or mode_raw_deflate - bool deflated() const { return deflated_; } + // Reads/inflates at most *count_io bytes into *out and sets *count_io to actual + // number of bytes read (less than requested if end of data was reached). + // Buffers source data internally, even in copy mode, so input file can be + // unbuffered without sacrificing performance. + blargg_err_t read(void *out, int *count_io); - // Reads/inflates at most *count_io bytes into *out and sets *count_io to actual - // number of bytes read (less than requested if end of data was reached). - // Buffers source data internally, even in copy mode, so input file can be - // unbuffered without sacrificing performance. - blargg_err_t read( void* out, int* count_io ); + // Total number of bytes read since begin() + int tell() const + { + return zbuf.total_out; + } - // Total number of bytes read since begin() - int tell() const { return zbuf.total_out; } + // Ends inflation and frees memory + void end(); - // Ends inflation and frees memory - void end(); + private: + // noncopyable + Zlib_Inflater(const Zlib_Inflater &); + Zlib_Inflater &operator=(const Zlib_Inflater &); -private: - // noncopyable - Zlib_Inflater( const Zlib_Inflater& ); - Zlib_Inflater& operator = ( const Zlib_Inflater& ); + // Implementation + public: + Zlib_Inflater(); + ~Zlib_Inflater(); -// Implementation -public: - Zlib_Inflater(); - ~Zlib_Inflater(); + private: + z_stream_s zbuf; + blargg_vector buf; + bool deflated_; + callback_t callback; + void *user_data; -private: - z_stream_s zbuf; - blargg_vector buf; - bool deflated_; - callback_t callback; - void* user_data; - - blargg_err_t fill_buf( int count ); + blargg_err_t fill_buf(int count); }; #endif diff --git a/fex/fex/blargg_common.h b/fex/fex/blargg_common.h index 8c22fef9..6b5370b6 100644 --- a/fex/fex/blargg_common.h +++ b/fex/fex/blargg_common.h @@ -5,57 +5,55 @@ #ifndef BLARGG_COMMON_H #define BLARGG_COMMON_H -#include #include #include +#include -typedef const char* blargg_err_t; // 0 on success, otherwise error string +typedef const char *blargg_err_t; // 0 on success, otherwise error string // Success; no error int const blargg_ok = 0; // BLARGG_RESTRICT: equivalent to C99's restrict, where supported #if __GNUC__ >= 3 || _MSC_VER >= 1100 - #define BLARGG_RESTRICT __restrict +#define BLARGG_RESTRICT __restrict #else - #define BLARGG_RESTRICT +#define BLARGG_RESTRICT #endif #if __cplusplus >= 199711 - #define BLARGG_MUTABLE mutable +#define BLARGG_MUTABLE mutable #else - #define BLARGG_MUTABLE +#define BLARGG_MUTABLE #endif /* BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant). I don't just use 'abcd' because that's implementation-dependent. */ -#define BLARGG_4CHAR( a, b, c, d ) \ - ((a&0xFF)*0x1000000 + (b&0xFF)*0x10000 + (c&0xFF)*0x100 + (d&0xFF)) +#define BLARGG_4CHAR(a, b, c, d) \ + ((a & 0xFF) * 0x1000000 + (b & 0xFF) * 0x10000 + (c & 0xFF) * 0x100 + (d & 0xFF)) /* BLARGG_STATIC_ASSERT( expr ): Generates compile error if expr is 0. Can be used at file, function, or class scope. */ #ifdef _MSC_VER - // MSVC6 (_MSC_VER < 1300) __LINE__ fails when /Zl is specified - #define BLARGG_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) +// MSVC6 (_MSC_VER < 1300) __LINE__ fails when /Zl is specified +#define BLARGG_STATIC_ASSERT(expr) void blargg_failed_(int(*arg)[2 / (int)!!(expr)-1]) #else - // Others fail when declaring same function multiple times in class, - // so differentiate them by line - #define BLARGG_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) +// Others fail when declaring same function multiple times in class, +// so differentiate them by line +#define BLARGG_STATIC_ASSERT(expr) void blargg_failed_(int(*arg)[2 / !!(expr)-1][__LINE__]) #endif /* Pure virtual functions cause a vtable entry to a "called pure virtual" error handler, requiring linkage to the C++ runtime library. This macro is used in place of the "= 0", and simply expands to its argument. During development, it expands to "= 0", allowing detection of missing overrides. */ -#define BLARGG_PURE( def ) def +#define BLARGG_PURE(def) def /* My code depends on ASCII anywhere a character or string constant is compared with data read from a file, and anywhere file data is read and treated as a string. */ -#if '\n'!=0x0A || ' '!=0x20 || '0'!=0x30 || 'A'!=0x41 || 'a'!=0x61 - #error "ASCII character set required" +#if '\n' != 0x0A || ' ' != 0x20 || '0' != 0x30 || 'A' != 0x41 || 'a' != 0x61 +#error "ASCII character set required" #endif /* My code depends on int being at least 32 bits. Almost everything these days @@ -64,12 +62,12 @@ to test with. The issue can't be gotten around by using a suitable blargg_int everywhere either, because int is often converted to implicitly when doing arithmetic on smaller types. */ #if UINT_MAX < 0xFFFFFFFF - #error "int must be at least 32 bits" +#error "int must be at least 32 bits" #endif // In case compiler doesn't support these properly. Used rarely. -#define STATIC_CAST(T,expr) static_cast (expr) -#define CONST_CAST( T,expr) const_cast (expr) +#define STATIC_CAST(T, expr) static_cast(expr) +#define CONST_CAST(T, expr) const_cast(expr) // User configuration can override the above macros if necessary #include "blargg_config.h" @@ -78,17 +76,17 @@ arithmetic on smaller types. */ future version. In GCC, we can let the compiler warn. In other compilers, we strip it out unless BLARGG_LEGACY is true. */ #if BLARGG_LEGACY - // Allow old client code to work without warnings - #define BLARGG_DEPRECATED_TEXT( text ) text - #define BLARGG_DEPRECATED( text ) text +// Allow old client code to work without warnings +#define BLARGG_DEPRECATED_TEXT(text) text +#define BLARGG_DEPRECATED(text) text #elif __GNUC__ >= 4 - // In GCC, we can mark declarations and let the compiler warn - #define BLARGG_DEPRECATED_TEXT( text ) text - #define BLARGG_DEPRECATED( text ) __attribute__ ((deprecated)) text +// In GCC, we can mark declarations and let the compiler warn +#define BLARGG_DEPRECATED_TEXT(text) text +#define BLARGG_DEPRECATED(text) __attribute__((deprecated)) text #else - // By default, deprecated items are removed, to avoid use in new code - #define BLARGG_DEPRECATED_TEXT( text ) - #define BLARGG_DEPRECATED( text ) +// By default, deprecated items are removed, to avoid use in new code +#define BLARGG_DEPRECATED_TEXT(text) +#define BLARGG_DEPRECATED(text) #endif /* BOOST::int8_t, BOOST::int32_t, etc. @@ -97,20 +95,18 @@ for prividing the definitions. If I'm defining them, they must be scoped or else they could conflict with the standard ones at global scope. Even if HAVE_STDINT_H isn't defined, I can't assume the typedefs won't exist at global scope already. */ -#if defined (HAVE_STDINT_H) || \ - UCHAR_MAX != 0xFF || USHRT_MAX != 0xFFFF || UINT_MAX != 0xFFFFFFFF - #include - #define BOOST +#if defined(HAVE_STDINT_H) || UCHAR_MAX != 0xFF || USHRT_MAX != 0xFFFF || UINT_MAX != 0xFFFFFFFF +#include +#define BOOST #else - struct BOOST - { - typedef signed char int8_t; - typedef unsigned char uint8_t; - typedef short int16_t; - typedef unsigned short uint16_t; - typedef int int32_t; - typedef unsigned int uint32_t; - }; +struct BOOST { + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; +}; #endif /* My code is not written with exceptions in mind, so either uses new (nothrow) @@ -121,81 +117,120 @@ interface, I override operator new to use malloc. */ // BLARGG_DISABLE_NOTHROW is put inside classes #ifndef BLARGG_DISABLE_NOTHROW - // throw spec mandatory in ISO C++ if NULL can be returned - #if __cplusplus >= 199711 || __GNUC__ >= 3 || _MSC_VER >= 1300 - #define BLARGG_THROWS_NOTHING throw () - #else - #define BLARGG_THROWS_NOTHING - #endif - - #define BLARGG_DISABLE_NOTHROW \ - void* operator new ( size_t s ) BLARGG_THROWS_NOTHING { return malloc( s ); }\ - void operator delete( void* p ) BLARGG_THROWS_NOTHING { free( p ); } - - #define BLARGG_NEW new +// throw spec mandatory in ISO C++ if NULL can be returned +#if __cplusplus >= 199711 || __GNUC__ >= 3 || _MSC_VER >= 1300 +#define BLARGG_THROWS_NOTHING throw() #else - // BLARGG_NEW is used in place of new in library code - #include - #define BLARGG_NEW new (std::nothrow) +#define BLARGG_THROWS_NOTHING #endif - class blargg_vector_ { - protected: - void* begin_; - size_t size_; - void init(); - blargg_err_t resize_( size_t n, size_t elem_size ); - public: - size_t size() const { return size_; } - void clear(); - }; +#define BLARGG_DISABLE_NOTHROW \ + void *operator new(size_t s) BLARGG_THROWS_NOTHING \ + { \ + return malloc(s); \ + } \ + void operator delete(void *p)BLARGG_THROWS_NOTHING \ + { \ + free(p); \ + } + +#define BLARGG_NEW new +#else +// BLARGG_NEW is used in place of new in library code +#include +#define BLARGG_NEW new (std::nothrow) +#endif + +class blargg_vector_ +{ + protected: + void *begin_; + size_t size_; + void init(); + blargg_err_t resize_(size_t n, size_t elem_size); + + public: + size_t size() const + { + return size_; + } + void clear(); +}; // Very lightweight vector for POD types (no constructor/destructor) -template -class blargg_vector : public blargg_vector_ { - union T_must_be_pod { T t; }; // fails if T is not POD -public: - blargg_vector() { init(); } - ~blargg_vector() { clear(); } - - blargg_err_t resize( size_t n ) { return resize_( n, sizeof (T) ); } - - T* begin() { return static_cast (begin_); } - const T* begin() const { return static_cast (begin_); } - - T* end() { return static_cast (begin_) + size_; } - const T* end() const { return static_cast (begin_) + size_; } - - T& operator [] ( size_t n ) - { - assert( n < size_ ); - return static_cast (begin_) [n]; - } - - const T& operator [] ( size_t n ) const - { - assert( n < size_ ); - return static_cast (begin_) [n]; - } +template class blargg_vector : public blargg_vector_ +{ + union T_must_be_pod { + T t; + }; // fails if T is not POD + public: + blargg_vector() + { + init(); + } + ~blargg_vector() + { + clear(); + } + + blargg_err_t resize(size_t n) + { + return resize_(n, sizeof(T)); + } + + T *begin() + { + return static_cast(begin_); + } + const T *begin() const + { + return static_cast(begin_); + } + + T *end() + { + return static_cast(begin_) + size_; + } + const T *end() const + { + return static_cast(begin_) + size_; + } + + T &operator[](size_t n) + { + assert(n < size_); + return static_cast(begin_)[n]; + } + + const T &operator[](size_t n) const + { + assert(n < size_); + return static_cast(begin_)[n]; + } }; // Callback function with user data. // blargg_callback set_callback; // for user, this acts like... // void set_callback( T func, void* user_data = NULL ); // ...this // To call function, do set_callback.f( .. set_callback.data ... ); -template -struct blargg_callback -{ - T f; - void* data; - blargg_callback() { f = NULL; } - void operator () ( T callback, void* user_data = NULL ) { f = callback; data = user_data; } +template struct blargg_callback { + T f; + void *data; + blargg_callback() + { + f = NULL; + } + void operator()(T callback, void *user_data = NULL) + { + f = callback; + data = user_data; + } }; -BLARGG_DEPRECATED( typedef signed int blargg_long; ) -BLARGG_DEPRECATED( typedef unsigned int blargg_ulong; ) +BLARGG_DEPRECATED(typedef signed int blargg_long;) +BLARGG_DEPRECATED(typedef unsigned int blargg_ulong;) #if BLARGG_LEGACY - #define BOOST_STATIC_ASSERT BLARGG_STATIC_ASSERT +#define BOOST_STATIC_ASSERT BLARGG_STATIC_ASSERT #endif #endif diff --git a/fex/fex/blargg_config.h b/fex/fex/blargg_config.h index 2282f1db..fb56d5aa 100644 --- a/fex/fex/blargg_config.h +++ b/fex/fex/blargg_config.h @@ -18,14 +18,11 @@ //#define BLARGG_BUILD_DLL 1 // Support only the listed archive types. Remove any you don't need. -#define FEX_TYPE_LIST \ - fex_7z_type,\ - fex_gz_type,\ - fex_zip_type, +#define FEX_TYPE_LIST fex_7z_type, fex_gz_type, fex_zip_type, // Use standard config.h if present #ifdef HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif #endif diff --git a/fex/fex/blargg_endian.h b/fex/fex/blargg_endian.h index c32c12f5..20b34227 100644 --- a/fex/fex/blargg_endian.h +++ b/fex/fex/blargg_endian.h @@ -7,179 +7,214 @@ #include "blargg_common.h" // BLARGG_CPU_CISC: Defined if CPU has very few general-purpose registers (< 16) -#if defined (__i386__) || defined (__x86_64__) || defined (_M_IX86) || defined (_M_X64) - #define BLARGG_CPU_X86 1 - #define BLARGG_CPU_CISC 1 +#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) +#define BLARGG_CPU_X86 1 +#define BLARGG_CPU_CISC 1 #endif -#if defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) || \ - defined (__POWERPC__) || defined (__powerc) - #define BLARGG_CPU_POWERPC 1 - #define BLARGG_CPU_RISC 1 +#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || defined(__POWERPC__) || \ + defined(__powerc) +#define BLARGG_CPU_POWERPC 1 +#define BLARGG_CPU_RISC 1 #endif // BLARGG_BIG_ENDIAN, BLARGG_LITTLE_ENDIAN: Determined automatically, otherwise only // one may be #defined to 1. Only needed if something actually depends on byte order. -#if !defined (BLARGG_BIG_ENDIAN) && !defined (BLARGG_LITTLE_ENDIAN) +#if !defined(BLARGG_BIG_ENDIAN) && !defined(BLARGG_LITTLE_ENDIAN) #ifdef __GLIBC__ - // GCC handles this for us - #include - #if __BYTE_ORDER == __LITTLE_ENDIAN - #define BLARGG_LITTLE_ENDIAN 1 - #elif __BYTE_ORDER == __BIG_ENDIAN - #define BLARGG_BIG_ENDIAN 1 - #endif +// GCC handles this for us +#include +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define BLARGG_LITTLE_ENDIAN 1 +#elif __BYTE_ORDER == __BIG_ENDIAN +#define BLARGG_BIG_ENDIAN 1 +#endif #else -#if defined (LSB_FIRST) || defined (__LITTLE_ENDIAN__) || BLARGG_CPU_X86 || \ - (defined (LITTLE_ENDIAN) && LITTLE_ENDIAN+0 != 1234) - #define BLARGG_LITTLE_ENDIAN 1 +#if defined(LSB_FIRST) || defined(__LITTLE_ENDIAN__) || BLARGG_CPU_X86 || \ + (defined(LITTLE_ENDIAN) && LITTLE_ENDIAN + 0 != 1234) +#define BLARGG_LITTLE_ENDIAN 1 #endif -#if defined (MSB_FIRST) || defined (__BIG_ENDIAN__) || defined (WORDS_BIGENDIAN) || \ - defined (__sparc__) || BLARGG_CPU_POWERPC || \ - (defined (BIG_ENDIAN) && BIG_ENDIAN+0 != 4321) - #define BLARGG_BIG_ENDIAN 1 -#elif !defined (__mips__) - // No endian specified; assume little-endian, since it's most common - #define BLARGG_LITTLE_ENDIAN 1 +#if defined(MSB_FIRST) || defined(__BIG_ENDIAN__) || defined(WORDS_BIGENDIAN) || \ + defined(__sparc__) || BLARGG_CPU_POWERPC || (defined(BIG_ENDIAN) && BIG_ENDIAN + 0 != 4321) +#define BLARGG_BIG_ENDIAN 1 +#elif !defined(__mips__) +// No endian specified; assume little-endian, since it's most common +#define BLARGG_LITTLE_ENDIAN 1 #endif #endif #endif #if BLARGG_LITTLE_ENDIAN && BLARGG_BIG_ENDIAN - #undef BLARGG_LITTLE_ENDIAN - #undef BLARGG_BIG_ENDIAN +#undef BLARGG_LITTLE_ENDIAN +#undef BLARGG_BIG_ENDIAN #endif inline void blargg_verify_byte_order() { - #ifndef NDEBUG - #if BLARGG_BIG_ENDIAN - volatile int i = 1; - assert( *(volatile char*) &i == 0 ); - #elif BLARGG_LITTLE_ENDIAN - volatile int i = 1; - assert( *(volatile char*) &i != 0 ); - #endif - #endif +#ifndef NDEBUG +#if BLARGG_BIG_ENDIAN + volatile int i = 1; + assert(*(volatile char *)&i == 0); +#elif BLARGG_LITTLE_ENDIAN + volatile int i = 1; + assert(*(volatile char *)&i != 0); +#endif +#endif } -inline unsigned get_le16( void const* p ) +inline unsigned get_le16(void const *p) { - return (unsigned) ((unsigned char const*) p) [1] << 8 | - (unsigned) ((unsigned char const*) p) [0]; + return (unsigned)((unsigned char const *)p)[1] << 8 | + (unsigned)((unsigned char const *)p)[0]; } -inline unsigned get_be16( void const* p ) +inline unsigned get_be16(void const *p) { - return (unsigned) ((unsigned char const*) p) [0] << 8 | - (unsigned) ((unsigned char const*) p) [1]; + return (unsigned)((unsigned char const *)p)[0] << 8 | + (unsigned)((unsigned char const *)p)[1]; } -inline unsigned get_le32( void const* p ) +inline unsigned get_le32(void const *p) { - return (unsigned) ((unsigned char const*) p) [3] << 24 | - (unsigned) ((unsigned char const*) p) [2] << 16 | - (unsigned) ((unsigned char const*) p) [1] << 8 | - (unsigned) ((unsigned char const*) p) [0]; + return (unsigned)((unsigned char const *)p)[3] << 24 | + (unsigned)((unsigned char const *)p)[2] << 16 | + (unsigned)((unsigned char const *)p)[1] << 8 | + (unsigned)((unsigned char const *)p)[0]; } -inline unsigned get_be32( void const* p ) +inline unsigned get_be32(void const *p) { - return (unsigned) ((unsigned char const*) p) [0] << 24 | - (unsigned) ((unsigned char const*) p) [1] << 16 | - (unsigned) ((unsigned char const*) p) [2] << 8 | - (unsigned) ((unsigned char const*) p) [3]; + return (unsigned)((unsigned char const *)p)[0] << 24 | + (unsigned)((unsigned char const *)p)[1] << 16 | + (unsigned)((unsigned char const *)p)[2] << 8 | + (unsigned)((unsigned char const *)p)[3]; } -inline void set_le16( void* p, unsigned n ) +inline void set_le16(void *p, unsigned n) { - ((unsigned char*) p) [1] = (unsigned char) (n >> 8); - ((unsigned char*) p) [0] = (unsigned char) n; + ((unsigned char *)p)[1] = (unsigned char)(n >> 8); + ((unsigned char *)p)[0] = (unsigned char)n; } -inline void set_be16( void* p, unsigned n ) +inline void set_be16(void *p, unsigned n) { - ((unsigned char*) p) [0] = (unsigned char) (n >> 8); - ((unsigned char*) p) [1] = (unsigned char) n; + ((unsigned char *)p)[0] = (unsigned char)(n >> 8); + ((unsigned char *)p)[1] = (unsigned char)n; } -inline void set_le32( void* p, unsigned n ) +inline void set_le32(void *p, unsigned n) { - ((unsigned char*) p) [0] = (unsigned char) n; - ((unsigned char*) p) [1] = (unsigned char) (n >> 8); - ((unsigned char*) p) [2] = (unsigned char) (n >> 16); - ((unsigned char*) p) [3] = (unsigned char) (n >> 24); + ((unsigned char *)p)[0] = (unsigned char)n; + ((unsigned char *)p)[1] = (unsigned char)(n >> 8); + ((unsigned char *)p)[2] = (unsigned char)(n >> 16); + ((unsigned char *)p)[3] = (unsigned char)(n >> 24); } -inline void set_be32( void* p, unsigned n ) +inline void set_be32(void *p, unsigned n) { - ((unsigned char*) p) [3] = (unsigned char) n; - ((unsigned char*) p) [2] = (unsigned char) (n >> 8); - ((unsigned char*) p) [1] = (unsigned char) (n >> 16); - ((unsigned char*) p) [0] = (unsigned char) (n >> 24); + ((unsigned char *)p)[3] = (unsigned char)n; + ((unsigned char *)p)[2] = (unsigned char)(n >> 8); + ((unsigned char *)p)[1] = (unsigned char)(n >> 16); + ((unsigned char *)p)[0] = (unsigned char)(n >> 24); } #if BLARGG_NONPORTABLE - // Optimized implementation if byte order is known - #if BLARGG_LITTLE_ENDIAN - #define GET_LE16( addr ) (*(BOOST::uint16_t const*) (addr)) - #define GET_LE32( addr ) (*(BOOST::uint32_t const*) (addr)) - #define SET_LE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) - #define SET_LE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) - #elif BLARGG_BIG_ENDIAN - #define GET_BE16( addr ) (*(BOOST::uint16_t const*) (addr)) - #define GET_BE32( addr ) (*(BOOST::uint32_t const*) (addr)) - #define SET_BE16( addr, data ) (void) (*(BOOST::uint16_t*) (addr) = (data)) - #define SET_BE32( addr, data ) (void) (*(BOOST::uint32_t*) (addr) = (data)) +// Optimized implementation if byte order is known +#if BLARGG_LITTLE_ENDIAN +#define GET_LE16(addr) (*(BOOST::uint16_t const *)(addr)) +#define GET_LE32(addr) (*(BOOST::uint32_t const *)(addr)) +#define SET_LE16(addr, data) (void)(*(BOOST::uint16_t *)(addr) = (data)) +#define SET_LE32(addr, data) (void)(*(BOOST::uint32_t *)(addr) = (data)) +#elif BLARGG_BIG_ENDIAN +#define GET_BE16(addr) (*(BOOST::uint16_t const *)(addr)) +#define GET_BE32(addr) (*(BOOST::uint32_t const *)(addr)) +#define SET_BE16(addr, data) (void)(*(BOOST::uint16_t *)(addr) = (data)) +#define SET_BE32(addr, data) (void)(*(BOOST::uint32_t *)(addr) = (data)) - #if BLARGG_CPU_POWERPC - // PowerPC has special byte-reversed instructions - #if defined (__MWERKS__) - #define GET_LE16( addr ) (__lhbrx( addr, 0 )) - #define GET_LE32( addr ) (__lwbrx( addr, 0 )) - #define SET_LE16( addr, in ) (__sthbrx( in, addr, 0 )) - #define SET_LE32( addr, in ) (__stwbrx( in, addr, 0 )) - #elif defined (__GNUC__) - #define GET_LE16( addr ) ({unsigned short ppc_lhbrx_; __asm__ volatile( "lhbrx %0,0,%1" : "=r" (ppc_lhbrx_) : "r" (addr) : "memory" ); ppc_lhbrx_;}) - #define GET_LE32( addr ) ({unsigned short ppc_lwbrx_; __asm__ volatile( "lwbrx %0,0,%1" : "=r" (ppc_lwbrx_) : "r" (addr) : "memory" ); ppc_lwbrx_;}) - #define SET_LE16( addr, in ) ({__asm__ volatile( "sthbrx %0,0,%1" : : "r" (in), "r" (addr) : "memory" );}) - #define SET_LE32( addr, in ) ({__asm__ volatile( "stwbrx %0,0,%1" : : "r" (in), "r" (addr) : "memory" );}) - #endif - #endif - #endif +#if BLARGG_CPU_POWERPC +// PowerPC has special byte-reversed instructions +#if defined(__MWERKS__) +#define GET_LE16(addr) (__lhbrx(addr, 0)) +#define GET_LE32(addr) (__lwbrx(addr, 0)) +#define SET_LE16(addr, in) (__sthbrx(in, addr, 0)) +#define SET_LE32(addr, in) (__stwbrx(in, addr, 0)) +#elif defined(__GNUC__) +#define GET_LE16(addr) \ + ({ \ + unsigned short ppc_lhbrx_; \ + __asm__ volatile("lhbrx %0,0,%1" : "=r"(ppc_lhbrx_) : "r"(addr) : "memory"); \ + ppc_lhbrx_; \ + }) +#define GET_LE32(addr) \ + ({ \ + unsigned short ppc_lwbrx_; \ + __asm__ volatile("lwbrx %0,0,%1" : "=r"(ppc_lwbrx_) : "r"(addr) : "memory"); \ + ppc_lwbrx_; \ + }) +#define SET_LE16(addr, in) \ + ({ __asm__ volatile("sthbrx %0,0,%1" : : "r"(in), "r"(addr) : "memory"); }) +#define SET_LE32(addr, in) \ + ({ __asm__ volatile("stwbrx %0,0,%1" : : "r"(in), "r"(addr) : "memory"); }) +#endif +#endif +#endif #endif #ifndef GET_LE16 - #define GET_LE16( addr ) get_le16( addr ) - #define SET_LE16( addr, data ) set_le16( addr, data ) +#define GET_LE16(addr) get_le16(addr) +#define SET_LE16(addr, data) set_le16(addr, data) #endif #ifndef GET_LE32 - #define GET_LE32( addr ) get_le32( addr ) - #define SET_LE32( addr, data ) set_le32( addr, data ) +#define GET_LE32(addr) get_le32(addr) +#define SET_LE32(addr, data) set_le32(addr, data) #endif #ifndef GET_BE16 - #define GET_BE16( addr ) get_be16( addr ) - #define SET_BE16( addr, data ) set_be16( addr, data ) +#define GET_BE16(addr) get_be16(addr) +#define SET_BE16(addr, data) set_be16(addr, data) #endif #ifndef GET_BE32 - #define GET_BE32( addr ) get_be32( addr ) - #define SET_BE32( addr, data ) set_be32( addr, data ) +#define GET_BE32(addr) get_be32(addr) +#define SET_BE32(addr, data) set_be32(addr, data) #endif // auto-selecting versions -inline void set_le( BOOST::uint16_t* p, unsigned n ) { SET_LE16( p, n ); } -inline void set_le( BOOST::uint32_t* p, unsigned n ) { SET_LE32( p, n ); } -inline void set_be( BOOST::uint16_t* p, unsigned n ) { SET_BE16( p, n ); } -inline void set_be( BOOST::uint32_t* p, unsigned n ) { SET_BE32( p, n ); } -inline unsigned get_le( BOOST::uint16_t const* p ) { return GET_LE16( p ); } -inline unsigned get_le( BOOST::uint32_t const* p ) { return GET_LE32( p ); } -inline unsigned get_be( BOOST::uint16_t const* p ) { return GET_BE16( p ); } -inline unsigned get_be( BOOST::uint32_t const* p ) { return GET_BE32( p ); } +inline void set_le(BOOST::uint16_t *p, unsigned n) +{ + SET_LE16(p, n); +} +inline void set_le(BOOST::uint32_t *p, unsigned n) +{ + SET_LE32(p, n); +} +inline void set_be(BOOST::uint16_t *p, unsigned n) +{ + SET_BE16(p, n); +} +inline void set_be(BOOST::uint32_t *p, unsigned n) +{ + SET_BE32(p, n); +} +inline unsigned get_le(BOOST::uint16_t const *p) +{ + return GET_LE16(p); +} +inline unsigned get_le(BOOST::uint32_t const *p) +{ + return GET_LE32(p); +} +inline unsigned get_be(BOOST::uint16_t const *p) +{ + return GET_BE16(p); +} +inline unsigned get_be(BOOST::uint32_t const *p) +{ + return GET_BE32(p); +} #endif diff --git a/fex/fex/blargg_errors.h b/fex/fex/blargg_errors.h index 9c5206d5..58762079 100644 --- a/fex/fex/blargg_errors.h +++ b/fex/fex/blargg_errors.h @@ -5,10 +5,10 @@ #define BLARGG_ERRORS_H #ifndef BLARGG_COMMON_H - #include "blargg_common.h" +#include "blargg_common.h" #endif -typedef const char blargg_err_def_t []; +typedef const char blargg_err_def_t[]; // Basic errors extern blargg_err_def_t blargg_err_generic; @@ -26,55 +26,55 @@ extern blargg_err_def_t blargg_err_file_full; extern blargg_err_def_t blargg_err_file_eof; // File high-level -extern blargg_err_def_t blargg_err_file_type; // wrong file type +extern blargg_err_def_t blargg_err_file_type; // wrong file type extern blargg_err_def_t blargg_err_file_feature; extern blargg_err_def_t blargg_err_file_corrupt; // C string describing error, or "" if err == NULL -const char* blargg_err_str( blargg_err_t err ); +const char *blargg_err_str(blargg_err_t err); // True iff error is of given type, or false if err == NULL -bool blargg_is_err_type( blargg_err_t, const char type [] ); +bool blargg_is_err_type(blargg_err_t, const char type[]); // Details of error without describing main cause, or "" if err == NULL -const char* blargg_err_details( blargg_err_t err ); +const char *blargg_err_details(blargg_err_t err); // Converts error string to integer code using mapping table. Calls blargg_is_err_type() // for each str and returns code on first match. Returns 0 if err == NULL. struct blargg_err_to_code_t { - const char* str; - int code; + const char *str; + int code; }; -int blargg_err_to_code( blargg_err_t err, blargg_err_to_code_t const [] ); +int blargg_err_to_code(blargg_err_t err, blargg_err_to_code_t const[]); // Converts error code back to string. If code == 0, returns NULL. If not in table, // returns blargg_err_generic. -blargg_err_t blargg_code_to_err( int code, blargg_err_to_code_t const [] ); +blargg_err_t blargg_code_to_err(int code, blargg_err_to_code_t const[]); // Generates error string literal with details of cause -#define BLARGG_ERR( type, str ) (type "; " str) +#define BLARGG_ERR(type, str) (type "; " str) // Extra space to make it clear when blargg_err_str() isn't called to get // printable version of error. At some point, I might prefix error strings // with a code, to speed conversion to a code. -#define BLARGG_ERR_TYPE( str ) " " str +#define BLARGG_ERR_TYPE(str) " " str // Error types to pass to BLARGG_ERR macro -#define BLARGG_ERR_GENERIC BLARGG_ERR_TYPE( "operation failed" ) -#define BLARGG_ERR_MEMORY BLARGG_ERR_TYPE( "out of memory" ) -#define BLARGG_ERR_CALLER BLARGG_ERR_TYPE( "internal usage bug" ) -#define BLARGG_ERR_INTERNAL BLARGG_ERR_TYPE( "internal bug" ) -#define BLARGG_ERR_LIMITATION BLARGG_ERR_TYPE( "exceeded limitation" ) +#define BLARGG_ERR_GENERIC BLARGG_ERR_TYPE("operation failed") +#define BLARGG_ERR_MEMORY BLARGG_ERR_TYPE("out of memory") +#define BLARGG_ERR_CALLER BLARGG_ERR_TYPE("internal usage bug") +#define BLARGG_ERR_INTERNAL BLARGG_ERR_TYPE("internal bug") +#define BLARGG_ERR_LIMITATION BLARGG_ERR_TYPE("exceeded limitation") -#define BLARGG_ERR_FILE_MISSING BLARGG_ERR_TYPE( "file not found" ) -#define BLARGG_ERR_FILE_READ BLARGG_ERR_TYPE( "couldn't open file" ) -#define BLARGG_ERR_FILE_WRITE BLARGG_ERR_TYPE( "couldn't modify file" ) -#define BLARGG_ERR_FILE_IO BLARGG_ERR_TYPE( "read/write error" ) -#define BLARGG_ERR_FILE_FULL BLARGG_ERR_TYPE( "disk full" ) -#define BLARGG_ERR_FILE_EOF BLARGG_ERR_TYPE( "truncated file" ) +#define BLARGG_ERR_FILE_MISSING BLARGG_ERR_TYPE("file not found") +#define BLARGG_ERR_FILE_READ BLARGG_ERR_TYPE("couldn't open file") +#define BLARGG_ERR_FILE_WRITE BLARGG_ERR_TYPE("couldn't modify file") +#define BLARGG_ERR_FILE_IO BLARGG_ERR_TYPE("read/write error") +#define BLARGG_ERR_FILE_FULL BLARGG_ERR_TYPE("disk full") +#define BLARGG_ERR_FILE_EOF BLARGG_ERR_TYPE("truncated file") -#define BLARGG_ERR_FILE_TYPE BLARGG_ERR_TYPE( "wrong file type" ) -#define BLARGG_ERR_FILE_FEATURE BLARGG_ERR_TYPE( "unsupported file feature" ) -#define BLARGG_ERR_FILE_CORRUPT BLARGG_ERR_TYPE( "corrupt file" ) +#define BLARGG_ERR_FILE_TYPE BLARGG_ERR_TYPE("wrong file type") +#define BLARGG_ERR_FILE_FEATURE BLARGG_ERR_TYPE("unsupported file feature") +#define BLARGG_ERR_FILE_CORRUPT BLARGG_ERR_TYPE("corrupt file") #endif diff --git a/fex/fex/blargg_source.h b/fex/fex/blargg_source.h index 659f34c5..1b24dac8 100644 --- a/fex/fex/blargg_source.h +++ b/fex/fex/blargg_source.h @@ -8,12 +8,12 @@ global namespace with unprefixed names. */ #define BLARGG_SOURCE_H #ifndef BLARGG_COMMON_H // optimization only - #include "blargg_common.h" +#include "blargg_common.h" #endif #include "blargg_errors.h" -#include /* memcpy(), memset(), memmove() */ #include /* offsetof() */ +#include /* memcpy(), memset(), memmove() */ /* The following four macros are for debugging only. Some or all might be defined to do nothing, depending on the circumstances. Described is what @@ -33,82 +33,94 @@ control of the module. A failed requirement probably indicates a bug in YOUR code. void require( bool expr ); */ -#undef require -#define require( expr ) assert( expr ) +#undef require +#define require(expr) assert(expr) /* Like printf() except output goes to debugging console/file. void dprintf( const char format [], ... ); */ -static inline void blargg_dprintf_( const char [], ... ) { } -#undef dprintf -#define dprintf (1) ? (void) 0 : blargg_dprintf_ +static inline void blargg_dprintf_(const char[], ...) +{ +} +#undef dprintf +#define dprintf (1) ? (void)0 : blargg_dprintf_ /* If expr is false, prints file and line number to debug console/log, then continues execution normally. Meant for flagging potential problems or things that should be looked into, but that aren't serious problems. void check( bool expr ); */ -#undef check -#define check( expr ) ((void) 0) +#undef check +#define check(expr) ((void)0) /* If expr yields non-NULL error string, returns it from current function, otherwise continues normally. */ -#undef RETURN_ERR -#define RETURN_ERR( expr ) \ - do {\ - blargg_err_t blargg_return_err_ = (expr);\ - if ( blargg_return_err_ )\ - return blargg_return_err_;\ - } while ( 0 ) +#undef RETURN_ERR +#define RETURN_ERR(expr) \ + do { \ + blargg_err_t blargg_return_err_ = (expr); \ + if (blargg_return_err_) \ + return blargg_return_err_; \ + } while (0) /* If ptr is NULL, returns out-of-memory error, otherwise continues normally. */ -#undef CHECK_ALLOC -#define CHECK_ALLOC( ptr ) \ - do {\ - if ( !(ptr) )\ - return blargg_err_memory;\ - } while ( 0 ) +#undef CHECK_ALLOC +#define CHECK_ALLOC(ptr) \ + do { \ + if (!(ptr)) \ + return blargg_err_memory; \ + } while (0) /* The usual min/max functions for built-in types. template T min( T x, T y ) { return x < y ? x : y; } template T max( T x, T y ) { return x > y ? x : y; } */ -#define BLARGG_DEF_MIN_MAX( type ) \ - static inline type blargg_min( type x, type y ) { if ( y < x ) x = y; return x; }\ - static inline type blargg_max( type x, type y ) { if ( x < y ) x = y; return x; } +#define BLARGG_DEF_MIN_MAX(type) \ + static inline type blargg_min(type x, type y) \ + { \ + if (y < x) \ + x = y; \ + return x; \ + } \ + static inline type blargg_max(type x, type y) \ + { \ + if (x < y) \ + x = y; \ + return x; \ + } -BLARGG_DEF_MIN_MAX( int ) -BLARGG_DEF_MIN_MAX( unsigned ) -BLARGG_DEF_MIN_MAX( long ) -BLARGG_DEF_MIN_MAX( unsigned long ) -BLARGG_DEF_MIN_MAX( float ) -BLARGG_DEF_MIN_MAX( double ) +BLARGG_DEF_MIN_MAX(int) +BLARGG_DEF_MIN_MAX(unsigned) +BLARGG_DEF_MIN_MAX(long) +BLARGG_DEF_MIN_MAX(unsigned long) +BLARGG_DEF_MIN_MAX(float) +BLARGG_DEF_MIN_MAX(double) -#undef min +#undef min #define min blargg_min -#undef max +#undef max #define max blargg_max // typedef unsigned char byte; typedef unsigned char blargg_byte; -#undef byte +#undef byte #define byte blargg_byte #ifndef BLARGG_EXPORT - #if defined (_WIN32) && BLARGG_BUILD_DLL - #define BLARGG_EXPORT __declspec(dllexport) - #elif defined (__GNUC__) - // can always set visibility, even when not building DLL - #define BLARGG_EXPORT __attribute__ ((visibility ("default"))) - #else - #define BLARGG_EXPORT - #endif +#if defined(_WIN32) && BLARGG_BUILD_DLL +#define BLARGG_EXPORT __declspec(dllexport) +#elif defined(__GNUC__) +// can always set visibility, even when not building DLL +#define BLARGG_EXPORT __attribute__((visibility("default"))) +#else +#define BLARGG_EXPORT +#endif #endif #if BLARGG_LEGACY - #define BLARGG_CHECK_ALLOC CHECK_ALLOC - #define BLARGG_RETURN_ERR RETURN_ERR +#define BLARGG_CHECK_ALLOC CHECK_ALLOC +#define BLARGG_RETURN_ERR RETURN_ERR #endif // Called after failed operation when overall operation may still complete OK. @@ -119,7 +131,7 @@ typedef unsigned char blargg_byte; /* BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf etc. and check */ #ifdef BLARGG_SOURCE_BEGIN - #include BLARGG_SOURCE_BEGIN +#include BLARGG_SOURCE_BEGIN #endif #endif diff --git a/fex/fex/fex.h b/fex/fex/fex.h index 8b6173ae..1f6d5418 100644 --- a/fex/fex/fex.h +++ b/fex/fex/fex.h @@ -7,10 +7,9 @@ #include #ifdef __cplusplus - extern "C" { +extern "C" { #endif - /** First parameter of most functions is fex_t*, or const fex_t* if nothing is changed. Once one of these functions returns an error, the archive should not be used any further, other than to close it. One exception is @@ -20,185 +19,175 @@ typedef struct fex_t fex_t; /** Pointer to error, or NULL if function was successful. See error functions below. */ #ifndef fex_err_t /* (#ifndef allows better testing of library) */ - typedef const char* fex_err_t; +typedef const char *fex_err_t; #endif - /**** File types ****/ /** Archive file type identifier. Can also hold NULL. */ -typedef const struct fex_type_t_* fex_type_t; +typedef const struct fex_type_t_ *fex_type_t; /** Array of supported types, with NULL at end */ -const fex_type_t* fex_type_list( void ); +const fex_type_t *fex_type_list(void); /** Name of this archive type, e.g. "ZIP archive", "file" */ -const char* fex_type_name( fex_type_t ); +const char *fex_type_name(fex_type_t); /** Usual file extension for type, e.g. ".zip", ".7z". For binary file type, returns "", since it can open any file. */ -const char* fex_type_extension( fex_type_t ); - +const char *fex_type_extension(fex_type_t); /**** Wide-character file paths ****/ /** Converts wide-character path to form suitable for use with fex functions. */ -char* fex_wide_to_path( const wchar_t* wide ); +char *fex_wide_to_path(const wchar_t *wide); /** Frees converted path. OK to pass NULL. */ -void fex_free_path( char* ); - +void fex_free_path(char *); /**** Identification ****/ /** True if str ends in extension. If extension is "", always returns true. Converts str to lowercase before comparison, so extension should ALREADY be lowercase (i.e. pass ".zip", NOT ".ZIP"). */ -int fex_has_extension( const char str [], const char extension [] ); +int fex_has_extension(const char str[], const char extension[]); /** Determines type based on first fex_identify_header_size bytes of file. Returns usual file extension this should have (e.g. ".zip", ".gz", etc.). Returns "" if file header is not recognized. */ -const char* fex_identify_header( const void* header ); +const char *fex_identify_header(const void *header); enum { fex_identify_header_size = 16 }; /** Determines type based on extension of a file path, or just a lone extension (must include '.', e.g. ".zip", NOT just "zip"). Returns NULL if extension is for an unsupported type (e.g. ".lzh"). */ -fex_type_t fex_identify_extension( const char path_or_extension [] ); +fex_type_t fex_identify_extension(const char path_or_extension[]); /** Determines type based on filename extension and/or file header. Sets *out to determined type, or NULL if type is not supported. */ -fex_err_t fex_identify_file( fex_type_t* out, const char path [] ); +fex_err_t fex_identify_file(fex_type_t *out, const char path[]); /** Type of an already-opened archive */ -fex_type_t fex_type( const fex_t* ); - +fex_type_t fex_type(const fex_t *); /**** Open/close ****/ /** Initializes static tables used by library. Automatically called by fex_open(). OK to call more than once. */ -fex_err_t fex_init( void ); +fex_err_t fex_init(void); /** Opens archive and points *out at it. If error, sets *out to NULL. */ -fex_err_t fex_open( fex_t** out, const char path [] ); +fex_err_t fex_open(fex_t **out, const char path[]); /** Opens archive of specified type and sets *out. Returns error if file is not of that archive type. If error, sets *out to NULL. */ -fex_err_t fex_open_type( fex_t** out, const char path [], fex_type_t ); +fex_err_t fex_open_type(fex_t **out, const char path[], fex_type_t); /** Closes archive and frees memory. OK to pass NULL. */ -void fex_close( fex_t* ); - +void fex_close(fex_t *); /**** Scanning ****/ /** True if at end of archive. Must be called after fex_open() or fex_rewind(), as an archive might contain no files. */ -int fex_done( const fex_t* ); +int fex_done(const fex_t *); /** Goes to next file in archive. If there are no more files, fex_done() will now return true. */ -fex_err_t fex_next( fex_t* ); +fex_err_t fex_next(fex_t *); /** Goes back to first file in archive, as if it were just opened with fex_open() */ -fex_err_t fex_rewind( fex_t* ); +fex_err_t fex_rewind(fex_t *); /** Saved position in archive. Can also store zero. */ typedef int fex_pos_t; /** Position of current file in archive. Never returns zero. */ -fex_pos_t fex_tell_arc( const fex_t* ); +fex_pos_t fex_tell_arc(const fex_t *); /** Returns to file at previously-saved position */ -fex_err_t fex_seek_arc( fex_t*, fex_pos_t ); - +fex_err_t fex_seek_arc(fex_t *, fex_pos_t); /**** Info ****/ /** Name of current file */ -const char* fex_name( const fex_t* ); +const char *fex_name(const fex_t *); /** Wide-character name of current file, or NULL if unavailable */ -const wchar_t* fex_wname( const fex_t* ); +const wchar_t *fex_wname(const fex_t *); /** Makes further information available for file */ -fex_err_t fex_stat( fex_t* ); +fex_err_t fex_stat(fex_t *); /** Size of current file. fex_stat() or fex_data() must have been called. */ -int fex_size( const fex_t* ); +int fex_size(const fex_t *); /** Modification date of current file (MS-DOS format), or 0 if unavailable. fex_stat() must have been called. */ -unsigned int fex_dos_date( const fex_t* ); +unsigned int fex_dos_date(const fex_t *); /** CRC-32 checksum of current file's contents, or 0 if unavailable. Doesn't require calculation; simply gets it from file's header. fex_stat() must have been called. */ -unsigned int fex_crc32( const fex_t* ); - +unsigned int fex_crc32(const fex_t *); /**** Extraction ****/ /** Reads n bytes from current file. Reading past end of file results in fex_err_file_eof. */ -fex_err_t fex_read( fex_t*, void* out, int n ); +fex_err_t fex_read(fex_t *, void *out, int n); /** Number of bytes read from current file */ -int fex_tell( const fex_t* ); +int fex_tell(const fex_t *); /** Points *out at current file's data in memory. Pointer is valid until fex_next(), fex_rewind(), fex_seek_arc(), or fex_close() is called. Pointer must NOT be freed(); library frees it automatically. If error, sets *out to NULL. */ -fex_err_t fex_data( fex_t*, const void** out ); - +fex_err_t fex_data(fex_t *, const void **out); /**** Errors ****/ /** Error string associated with err. Returns "" if err is NULL. Returns err unchanged if it isn't a fex_err_t returned by library. */ -const char* fex_err_str( fex_err_t err ); +const char *fex_err_str(fex_err_t err); /** Details of error beyond main cause, or "" if none or err is NULL. Returns err unchanged if it isn't a fex_err_t returned by library. */ -const char* fex_err_details( fex_err_t err ); +const char *fex_err_details(fex_err_t err); /** Numeric code corresponding to err. Returns fex_ok if err is NULL. Returns fex_err_generic if err isn't a fex_err_t returned by library. */ -int fex_err_code( fex_err_t err ); +int fex_err_code(fex_err_t err); -enum { - fex_ok = 0,/**< Successful call. Guaranteed to be zero. */ - fex_err_generic = 0x01,/**< Error of unspecified type */ - fex_err_memory = 0x02,/**< Out of memory */ - fex_err_caller = 0x03,/**< Caller called function with bad args */ - fex_err_internal = 0x04,/**< Internal problem, bug, etc. */ - fex_err_limitation = 0x05,/**< Exceeded program limit */ - - fex_err_file_missing = 0x20,/**< File not found at specified path */ - fex_err_file_read = 0x21,/**< Couldn't open file for reading */ - fex_err_file_io = 0x23,/**< Read/write error */ - fex_err_file_eof = 0x25,/**< Tried to read past end of file */ - - fex_err_file_type = 0x30,/**< File is of wrong type */ - fex_err_file_feature = 0x32,/**< File requires unsupported feature */ - fex_err_file_corrupt = 0x33 /**< File is corrupt */ +enum { fex_ok = 0, /**< Successful call. Guaranteed to be zero. */ + fex_err_generic = 0x01, /**< Error of unspecified type */ + fex_err_memory = 0x02, /**< Out of memory */ + fex_err_caller = 0x03, /**< Caller called function with bad args */ + fex_err_internal = 0x04, /**< Internal problem, bug, etc. */ + fex_err_limitation = 0x05, /**< Exceeded program limit */ + + fex_err_file_missing = 0x20, /**< File not found at specified path */ + fex_err_file_read = 0x21, /**< Couldn't open file for reading */ + fex_err_file_io = 0x23, /**< Read/write error */ + fex_err_file_eof = 0x25, /**< Tried to read past end of file */ + + fex_err_file_type = 0x30, /**< File is of wrong type */ + fex_err_file_feature = 0x32, /**< File requires unsupported feature */ + fex_err_file_corrupt = 0x33 /**< File is corrupt */ }; /** fex_err_t corresponding to numeric code. Note that this might not recover the original fex_err_t before it was converted to a numeric code; in particular, fex_err_details(fex_code_to_err(code)) will be "" in most cases. */ -fex_err_t fex_code_to_err( int code ); - +fex_err_t fex_code_to_err(int code); /* Deprecated */ typedef fex_t File_Extractor; #ifdef __cplusplus - } +} #endif #endif diff --git a/src/AutoBuild.h b/src/AutoBuild.h index d95a571e..9b25996d 100644 --- a/src/AutoBuild.h +++ b/src/AutoBuild.h @@ -20,10 +20,10 @@ #ifndef __AUTOBUILD_H__ #define __AUTOBUILD_H__ #include "version.h" -//change the FALSE to TRUE for autoincrement of build number +// change the FALSE to TRUE for autoincrement of build number #define INCREMENT_VERSION FALSE -#define FILEVER 2,0,0,600 -#define PRODUCTVER 2,0,0,600 -#define STRFILEVER "2, 0, 0, 600\0" -#define STRPRODUCTVER "2, 0, 0, 600\0" +#define FILEVER 2, 0, 0, 600 +#define PRODUCTVER 2, 0, 0, 600 +#define STRFILEVER "2, 0, 0, 600\0" +#define STRPRODUCTVER "2, 0, 0, 600\0" #endif //__AUTOBUILD_H__ diff --git a/src/NLS.h b/src/NLS.h index f8e903e8..4ecdd1d7 100644 --- a/src/NLS.h +++ b/src/NLS.h @@ -1,45 +1,45 @@ #define N_(String) (String) -#define MSG_UNSUPPORTED_VBA_SGM 1 -#define MSG_CANNOT_LOAD_SGM 2 -#define MSG_SAVE_GAME_NOT_USING_BIOS 3 -#define MSG_SAVE_GAME_USING_BIOS 4 -#define MSG_UNSUPPORTED_SAVE_TYPE 5 -#define MSG_CANNOT_OPEN_FILE 6 -#define MSG_BAD_ZIP_FILE 7 -#define MSG_NO_IMAGE_ON_ZIP 8 -#define MSG_ERROR_OPENING_IMAGE 9 -#define MSG_ERROR_READING_IMAGE 10 -#define MSG_UNSUPPORTED_BIOS_FUNCTION 11 -#define MSG_INVALID_BIOS_FILE_SIZE 12 -#define MSG_INVALID_CHEAT_CODE 13 -#define MSG_UNKNOWN_ARM_OPCODE 14 -#define MSG_UNKNOWN_THUMB_OPCODE 15 -#define MSG_ERROR_CREATING_FILE 16 -#define MSG_FAILED_TO_READ_SGM 17 -#define MSG_FAILED_TO_READ_RTC 18 -#define MSG_UNSUPPORTED_VB_SGM 19 -#define MSG_CANNOT_LOAD_SGM_FOR 20 -#define MSG_ERROR_OPENING_IMAGE_FROM 21 -#define MSG_ERROR_READING_IMAGE_FROM 22 -#define MSG_UNSUPPORTED_ROM_SIZE 23 -#define MSG_UNSUPPORTED_RAM_SIZE 24 -#define MSG_UNKNOWN_CARTRIDGE_TYPE 25 -#define MSG_MAXIMUM_NUMBER_OF_CHEATS 26 -#define MSG_INVALID_GAMESHARK_CODE 27 -#define MSG_INVALID_GAMEGENIE_CODE 28 -#define MSG_INVALID_CHEAT_TO_REMOVE 29 -#define MSG_INVALID_CHEAT_CODE_ADDRESS 30 +#define MSG_UNSUPPORTED_VBA_SGM 1 +#define MSG_CANNOT_LOAD_SGM 2 +#define MSG_SAVE_GAME_NOT_USING_BIOS 3 +#define MSG_SAVE_GAME_USING_BIOS 4 +#define MSG_UNSUPPORTED_SAVE_TYPE 5 +#define MSG_CANNOT_OPEN_FILE 6 +#define MSG_BAD_ZIP_FILE 7 +#define MSG_NO_IMAGE_ON_ZIP 8 +#define MSG_ERROR_OPENING_IMAGE 9 +#define MSG_ERROR_READING_IMAGE 10 +#define MSG_UNSUPPORTED_BIOS_FUNCTION 11 +#define MSG_INVALID_BIOS_FILE_SIZE 12 +#define MSG_INVALID_CHEAT_CODE 13 +#define MSG_UNKNOWN_ARM_OPCODE 14 +#define MSG_UNKNOWN_THUMB_OPCODE 15 +#define MSG_ERROR_CREATING_FILE 16 +#define MSG_FAILED_TO_READ_SGM 17 +#define MSG_FAILED_TO_READ_RTC 18 +#define MSG_UNSUPPORTED_VB_SGM 19 +#define MSG_CANNOT_LOAD_SGM_FOR 20 +#define MSG_ERROR_OPENING_IMAGE_FROM 21 +#define MSG_ERROR_READING_IMAGE_FROM 22 +#define MSG_UNSUPPORTED_ROM_SIZE 23 +#define MSG_UNSUPPORTED_RAM_SIZE 24 +#define MSG_UNKNOWN_CARTRIDGE_TYPE 25 +#define MSG_MAXIMUM_NUMBER_OF_CHEATS 26 +#define MSG_INVALID_GAMESHARK_CODE 27 +#define MSG_INVALID_GAMEGENIE_CODE 28 +#define MSG_INVALID_CHEAT_TO_REMOVE 29 +#define MSG_INVALID_CHEAT_CODE_ADDRESS 30 #define MSG_UNSUPPORTED_CHEAT_LIST_VERSION 31 -#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32 -#define MSG_INVALID_GSA_CODE 33 -#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34 -#define MSG_UNSUPPORTED_SNAPSHOT_FILE 35 -#define MSG_UNSUPPORTED_ARM_MODE 36 -#define MSG_UNSUPPORTED_CODE_FILE 37 -#define MSG_GBA_CODE_WARNING 38 -#define MSG_INVALID_CBA_CODE 39 -#define MSG_CBA_CODE_WARNING 40 -#define MSG_OUT_OF_MEMORY 41 -#define MSG_WRONG_GAMESHARK_CODE 42 -#define MSG_UNSUPPORTED_GAMESHARK_CODE 43 +#define MSG_UNSUPPORTED_CHEAT_LIST_TYPE 32 +#define MSG_INVALID_GSA_CODE 33 +#define MSG_CANNOT_IMPORT_SNAPSHOT_FOR 34 +#define MSG_UNSUPPORTED_SNAPSHOT_FILE 35 +#define MSG_UNSUPPORTED_ARM_MODE 36 +#define MSG_UNSUPPORTED_CODE_FILE 37 +#define MSG_GBA_CODE_WARNING 38 +#define MSG_INVALID_CBA_CODE 39 +#define MSG_CBA_CODE_WARNING 40 +#define MSG_OUT_OF_MEMORY 41 +#define MSG_WRONG_GAMESHARK_CODE 42 +#define MSG_UNSUPPORTED_GAMESHARK_CODE 43 diff --git a/src/System.h b/src/System.h index ec8c7e62..9d682fba 100644 --- a/src/System.h +++ b/src/System.h @@ -10,46 +10,46 @@ class SoundDriver; struct EmulatedSystem { - // main emulation function - void (*emuMain)(int); - // reset emulator - void (*emuReset)(); - // clean up memory - void (*emuCleanUp)(); - // load battery file - bool (*emuReadBattery)(const char *); - // write battery file - bool (*emuWriteBattery)(const char *); + // main emulation function + void (*emuMain)(int); + // reset emulator + void (*emuReset)(); + // clean up memory + void (*emuCleanUp)(); + // load battery file + bool (*emuReadBattery)(const char *); + // write battery file + bool (*emuWriteBattery)(const char *); #ifdef __LIBRETRO__ - // load state - bool (*emuReadState)(const u8*, unsigned); - // load state - unsigned (*emuWriteState)(u8*, unsigned); + // load state + bool (*emuReadState)(const u8 *, unsigned); + // load state + unsigned (*emuWriteState)(u8 *, unsigned); #else - // load state - bool (*emuReadState)(const char *); - // save state - bool (*emuWriteState)(const char *); + // load state + bool (*emuReadState)(const char *); + // save state + bool (*emuWriteState)(const char *); #endif - // load memory state (rewind) - bool (*emuReadMemState)(char *, int); - // write memory state (rewind) - bool (*emuWriteMemState)(char *, int, long&); - // write PNG file - bool (*emuWritePNG)(const char *); - // write BMP file - bool (*emuWriteBMP)(const char *); - // emulator update CPSR (ARM only) - void (*emuUpdateCPSR)(); - // emulator has debugger - bool emuHasDebugger; - // clock ticks to emulate - int emuCount; + // load memory state (rewind) + bool (*emuReadMemState)(char *, int); + // write memory state (rewind) + bool (*emuWriteMemState)(char *, int, long &); + // write PNG file + bool (*emuWritePNG)(const char *); + // write BMP file + bool (*emuWriteBMP)(const char *); + // emulator update CPSR (ARM only) + void (*emuUpdateCPSR)(); + // emulator has debugger + bool emuHasDebugger; + // clock ticks to emulate + int emuCount; }; -extern void log(const char *,...); +extern void log(const char *, ...); extern bool systemPauseOnFrame(); -extern void systemGbPrint(u8 *,int,int,int,int,int); +extern void systemGbPrint(u8 *, int, int, int, int, int); extern void systemScreenCapture(int); extern void systemDrawScreen(); // updates the joystick data @@ -59,8 +59,8 @@ extern u32 systemReadJoypad(int); extern u32 systemGetClock(); extern void systemMessage(int, const char *, ...); extern void systemSetTitle(const char *); -extern SoundDriver * systemSoundInit(); -extern void systemOnWriteDataToSoundBuffer(const u16 * finalWave, int length); +extern SoundDriver *systemSoundInit(); +extern void systemOnWriteDataToSoundBuffer(const u16 *finalWave, int length); extern void systemOnSoundShutdown(); extern void systemScreenMessage(const char *); extern void systemUpdateMotionSensor(); @@ -81,7 +81,7 @@ extern bool Sm60FPS_CanSkipFrame(); extern void Sm60FPS_Sleep(); extern void DbgMsg(const char *msg, ...); extern void (*dbgOutput)(const char *s, u32 addr); -extern void (*dbgSignal)(int sig,int number); +extern void (*dbgSignal)(int sig, int number); extern u16 systemColorMap16[0x10000]; extern u32 systemColorMap32[0x10000]; extern u16 systemGbPalette[24]; @@ -95,4 +95,4 @@ extern int systemSaveUpdateCounter; extern int systemSpeed; #define SYSTEM_SAVE_UPDATED 30 #define SYSTEM_SAVE_NOT_UPDATED 0 -#endif // SYSTEM_H +#endif // SYSTEM_H diff --git a/src/Util.cpp b/src/Util.cpp index 44b37bea..b5dc04c9 100644 --- a/src/Util.cpp +++ b/src/Util.cpp @@ -4,11 +4,11 @@ #include #ifndef _WIN32 -#include #include +#include #else // _WIN32 -#include #include +#include #endif // _WIN32 #include @@ -19,14 +19,14 @@ extern "C" { } #endif -#include "System.h" #include "NLS.h" +#include "System.h" #include "Util.h" +#include "common/Port.h" #include "gba/Flash.h" #include "gba/GBA.h" #include "gba/Globals.h" #include "gba/RTC.h" -#include "common/Port.h" #include "fex/fex.h" @@ -34,8 +34,8 @@ extern "C" { #include "common/memgzio.h" } -#include "gba/gbafilter.h" #include "gb/gbGlobals.h" +#include "gba/gbafilter.h" #ifndef _MSC_VER #define _stricmp strcasecmp @@ -49,472 +49,446 @@ extern int systemBlueShift; extern u16 systemColorMap16[0x10000]; extern u32 systemColorMap32[0x10000]; -static int (ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL; -static int (ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL; -static int (ZEXPORT *utilGzCloseFunc)(gzFile) = NULL; -static z_off_t (ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL; +static int(ZEXPORT *utilGzWriteFunc)(gzFile, const voidp, unsigned int) = NULL; +static int(ZEXPORT *utilGzReadFunc)(gzFile, voidp, unsigned int) = NULL; +static int(ZEXPORT *utilGzCloseFunc)(gzFile) = NULL; +static z_off_t(ZEXPORT *utilGzSeekFunc)(gzFile, z_off_t, int) = NULL; bool FileExists(const char *filename) { #ifdef _WIN32 - return (_access(filename, 0) != -1); + return (_access(filename, 0) != -1); #else - struct stat buffer; - return (stat(filename, &buffer) == 0); + struct stat buffer; + return (stat(filename, &buffer) == 0); #endif } -void utilReadScreenPixels(u8* dest, int w, int h) +void utilReadScreenPixels(u8 *dest, int w, int h) { - u8* b = dest; - int sizeX = w; - int sizeY = h; - switch (systemColorDepth) { - case 16: - { - u16 *p = (u16 *) (pix + (w + 2) * 2); // skip first black line - for (int y = 0; y < sizeY; y++) { - for (int x = 0; x < sizeX; x++) { - u16 v = *p++; + u8 *b = dest; + int sizeX = w; + int sizeY = h; + switch (systemColorDepth) { + case 16: { + u16 *p = (u16 *)(pix + (w + 2) * 2); // skip first black line + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u16 v = *p++; - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B - } - p++; // skip black pixel for filters - p++; // skip black pixel for filters - } - } - break; - case 24: - { - u8 *pixU8 = (u8 *) pix; - for (int y = 0; y < sizeY; y++) { - for (int x = 0; x < sizeX; x++) { - if (systemRedShift < systemBlueShift) { - *b++ = *pixU8++; // R - *b++ = *pixU8++; // G - *b++ = *pixU8++; // B - } - else { - int blue = *pixU8++; - int green = *pixU8++; - int red = *pixU8++; + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + } + } break; + case 24: { + u8 *pixU8 = (u8 *)pix; + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + if (systemRedShift < systemBlueShift) { + *b++ = *pixU8++; // R + *b++ = *pixU8++; // G + *b++ = *pixU8++; // B + } else { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; - *b++ = red; - *b++ = green; - *b++ = blue; - } - } - } - } - break; - case 32: - { - u32 *pixU32 = (u32 *) (pix + 4 * (w + 1)); - for (int y = 0; y < sizeY; y++) { - for (int x = 0; x < sizeX; x++) { - u32 v = *pixU32++; - *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R - } - pixU32++; - } - } - break; - } + *b++ = red; + *b++ = green; + *b++ = blue; + } + } + } + } break; + case 32: { + u32 *pixU32 = (u32 *)(pix + 4 * (w + 1)); + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + pixU32++; + } + } break; + } } bool utilWritePNGFile(const char *fileName, int w, int h, u8 *pix) { #ifndef NO_PNG - u8 writeBuffer[512 * 3]; + u8 writeBuffer[512 * 3]; - FILE *fp = fopen(fileName,"wb"); + FILE *fp = fopen(fileName, "wb"); - if(!fp) { - systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); - return false; - } - - png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, - NULL, - NULL, - NULL); - if(!png_ptr) { - fclose(fp); - return false; - } - - png_infop info_ptr = png_create_info_struct(png_ptr); - - if(!info_ptr) { - png_destroy_write_struct(&png_ptr,NULL); - fclose(fp); - return false; - } - - if(setjmp(png_jmpbuf(png_ptr))) { - png_destroy_write_struct(&png_ptr,NULL); - fclose(fp); - return false; - } - - png_init_io(png_ptr,fp); - - png_set_IHDR(png_ptr, - info_ptr, - w, - h, - 8, - PNG_COLOR_TYPE_RGB, - PNG_INTERLACE_NONE, - PNG_COMPRESSION_TYPE_DEFAULT, - PNG_FILTER_TYPE_DEFAULT); - - png_write_info(png_ptr,info_ptr); - - u8 *b = writeBuffer; - - int sizeX = w; - int sizeY = h; - - switch(systemColorDepth) { - case 16: - { - u16 *p = (u16 *)(pix+(w+2)*2); // skip first black line - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - u16 v = *p++; - - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + if (!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); + return false; } - p++; // skip black pixel for filters - p++; // skip black pixel for filters - png_write_row(png_ptr,writeBuffer); - b = writeBuffer; - } - } - break; - case 24: - { - u8 *pixU8 = (u8 *)pix; - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - if(systemRedShift < systemBlueShift) { - *b++ = *pixU8++; // R - *b++ = *pixU8++; // G - *b++ = *pixU8++; // B - } else { - int blue = *pixU8++; - int green = *pixU8++; - int red = *pixU8++; - - *b++ = red; - *b++ = green; - *b++ = blue; - } + png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (!png_ptr) { + fclose(fp); + return false; } - png_write_row(png_ptr,writeBuffer); - b = writeBuffer; - } - } - break; - case 32: - { - u32 *pixU32 = (u32 *)(pix+4*(w+1)); - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - u32 v = *pixU32++; + png_infop info_ptr = png_create_info_struct(png_ptr); - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + if (!info_ptr) { + png_destroy_write_struct(&png_ptr, NULL); + fclose(fp); + return false; } - pixU32++; - png_write_row(png_ptr,writeBuffer); + if (setjmp(png_jmpbuf(png_ptr))) { + png_destroy_write_struct(&png_ptr, NULL); + fclose(fp); + return false; + } - b = writeBuffer; - } - } - break; - } + png_init_io(png_ptr, fp); - png_write_end(png_ptr, info_ptr); + png_set_IHDR(png_ptr, + info_ptr, + w, + h, + 8, + PNG_COLOR_TYPE_RGB, + PNG_INTERLACE_NONE, + PNG_COMPRESSION_TYPE_DEFAULT, + PNG_FILTER_TYPE_DEFAULT); - png_destroy_write_struct(&png_ptr, &info_ptr); + png_write_info(png_ptr, info_ptr); - fclose(fp); + u8 *b = writeBuffer; - return true; + int sizeX = w; + int sizeY = h; + + switch (systemColorDepth) { + case 16: { + u16 *p = (u16 *)(pix + (w + 2) * 2); // skip first black line + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u16 v = *p++; + + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + png_write_row(png_ptr, writeBuffer); + + b = writeBuffer; + } + } break; + case 24: { + u8 *pixU8 = (u8 *)pix; + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + if (systemRedShift < systemBlueShift) { + *b++ = *pixU8++; // R + *b++ = *pixU8++; // G + *b++ = *pixU8++; // B + } else { + int blue = *pixU8++; + int green = *pixU8++; + int red = *pixU8++; + + *b++ = red; + *b++ = green; + *b++ = blue; + } + } + png_write_row(png_ptr, writeBuffer); + + b = writeBuffer; + } + } break; + case 32: { + u32 *pixU32 = (u32 *)(pix + 4 * (w + 1)); + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + } + pixU32++; + + png_write_row(png_ptr, writeBuffer); + + b = writeBuffer; + } + } break; + } + + png_write_end(png_ptr, info_ptr); + + png_destroy_write_struct(&png_ptr, &info_ptr); + + fclose(fp); + + return true; #else - return false; + return false; #endif } void utilPutDword(u8 *p, u32 value) { - *p++ = value & 255; - *p++ = (value >> 8) & 255; - *p++ = (value >> 16) & 255; - *p = (value >> 24) & 255; + *p++ = value & 255; + *p++ = (value >> 8) & 255; + *p++ = (value >> 16) & 255; + *p = (value >> 24) & 255; } void utilPutWord(u8 *p, u16 value) { - *p++ = value & 255; - *p = (value >> 8) & 255; + *p++ = value & 255; + *p = (value >> 8) & 255; } bool utilWriteBMPFile(const char *fileName, int w, int h, u8 *pix) { - u8 writeBuffer[512 * 3]; + u8 writeBuffer[512 * 3]; - FILE *fp = fopen(fileName,"wb"); + FILE *fp = fopen(fileName, "wb"); - if(!fp) { - systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); - return false; - } - - struct { - u8 ident[2]; - u8 filesize[4]; - u8 reserved[4]; - u8 dataoffset[4]; - u8 headersize[4]; - u8 width[4]; - u8 height[4]; - u8 planes[2]; - u8 bitsperpixel[2]; - u8 compression[4]; - u8 datasize[4]; - u8 hres[4]; - u8 vres[4]; - u8 colors[4]; - u8 importantcolors[4]; - // u8 pad[2]; - } bmpheader; - memset(&bmpheader, 0, sizeof(bmpheader)); - - bmpheader.ident[0] = 'B'; - bmpheader.ident[1] = 'M'; - - u32 fsz = sizeof(bmpheader) + w*h*3; - utilPutDword(bmpheader.filesize, fsz); - utilPutDword(bmpheader.dataoffset, 0x36); - utilPutDword(bmpheader.headersize, 0x28); - utilPutDword(bmpheader.width, w); - utilPutDword(bmpheader.height, h); - utilPutDword(bmpheader.planes, 1); - utilPutDword(bmpheader.bitsperpixel, 24); - utilPutDword(bmpheader.datasize, 3*w*h); - - fwrite(&bmpheader, 1, sizeof(bmpheader), fp); - - u8 *b = writeBuffer; - - int sizeX = w; - int sizeY = h; - - switch(systemColorDepth) { - case 16: - { - u16 *p = (u16 *)(pix+(w+2)*(h)*2); // skip first black line - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - u16 v = *p++; - - *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + if (!fp) { + systemMessage(MSG_ERROR_CREATING_FILE, N_("Error creating file %s"), fileName); + return false; } - p++; // skip black pixel for filters - p++; // skip black pixel for filters - p -= 2*(w+2); - fwrite(writeBuffer, 1, 3*w, fp); - b = writeBuffer; - } - } - break; - case 24: - { - u8 *pixU8 = (u8 *)pix+3*w*(h-1); - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - if(systemRedShift > systemBlueShift) { - *b++ = *pixU8++; // B - *b++ = *pixU8++; // G - *b++ = *pixU8++; // R - } else { - int red = *pixU8++; - int green = *pixU8++; - int blue = *pixU8++; + struct { + u8 ident[2]; + u8 filesize[4]; + u8 reserved[4]; + u8 dataoffset[4]; + u8 headersize[4]; + u8 width[4]; + u8 height[4]; + u8 planes[2]; + u8 bitsperpixel[2]; + u8 compression[4]; + u8 datasize[4]; + u8 hres[4]; + u8 vres[4]; + u8 colors[4]; + u8 importantcolors[4]; + // u8 pad[2]; + } bmpheader; + memset(&bmpheader, 0, sizeof(bmpheader)); - *b++ = blue; - *b++ = green; - *b++ = red; - } + bmpheader.ident[0] = 'B'; + bmpheader.ident[1] = 'M'; + + u32 fsz = sizeof(bmpheader) + w * h * 3; + utilPutDword(bmpheader.filesize, fsz); + utilPutDword(bmpheader.dataoffset, 0x36); + utilPutDword(bmpheader.headersize, 0x28); + utilPutDword(bmpheader.width, w); + utilPutDword(bmpheader.height, h); + utilPutDword(bmpheader.planes, 1); + utilPutDword(bmpheader.bitsperpixel, 24); + utilPutDword(bmpheader.datasize, 3 * w * h); + + fwrite(&bmpheader, 1, sizeof(bmpheader), fp); + + u8 *b = writeBuffer; + + int sizeX = w; + int sizeY = h; + + switch (systemColorDepth) { + case 16: { + u16 *p = (u16 *)(pix + (w + 2) * (h)*2); // skip first black line + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u16 v = *p++; + + *b++ = ((v >> systemBlueShift) & 0x01f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + p++; // skip black pixel for filters + p++; // skip black pixel for filters + p -= 2 * (w + 2); + fwrite(writeBuffer, 1, 3 * w, fp); + + b = writeBuffer; + } + } break; + case 24: { + u8 *pixU8 = (u8 *)pix + 3 * w * (h - 1); + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + if (systemRedShift > systemBlueShift) { + *b++ = *pixU8++; // B + *b++ = *pixU8++; // G + *b++ = *pixU8++; // R + } else { + int red = *pixU8++; + int green = *pixU8++; + int blue = *pixU8++; + + *b++ = blue; + *b++ = green; + *b++ = red; + } + } + pixU8 -= 2 * 3 * w; + fwrite(writeBuffer, 1, 3 * w, fp); + + b = writeBuffer; + } + } break; + case 32: { + u32 *pixU32 = (u32 *)(pix + 4 * (w + 1) * (h)); + for (int y = 0; y < sizeY; y++) { + for (int x = 0; x < sizeX; x++) { + u32 v = *pixU32++; + + *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B + *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G + *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R + } + pixU32++; + pixU32 -= 2 * (w + 1); + + fwrite(writeBuffer, 1, 3 * w, fp); + + b = writeBuffer; + } + } break; } - pixU8 -= 2*3*w; - fwrite(writeBuffer, 1, 3*w, fp); - b = writeBuffer; - } - } - break; - case 32: - { - u32 *pixU32 = (u32 *)(pix+4*(w+1)*(h)); - for(int y = 0; y < sizeY; y++) { - for(int x = 0; x < sizeX; x++) { - u32 v = *pixU32++; + fclose(fp); - *b++ = ((v >> systemBlueShift) & 0x001f) << 3; // B - *b++ = ((v >> systemGreenShift) & 0x001f) << 3; // G - *b++ = ((v >> systemRedShift) & 0x001f) << 3; // R - } - pixU32++; - pixU32 -= 2*(w+1); - - fwrite(writeBuffer, 1, 3*w, fp); - - b = writeBuffer; - } - } - break; - } - - fclose(fp); - - return true; + return true; } extern bool cpuIsMultiBoot; -bool utilIsGBAImage(const char * file) +bool utilIsGBAImage(const char *file) { - cpuIsMultiBoot = false; - if(strlen(file) > 4) { - const char * p = strrchr(file,'.'); + cpuIsMultiBoot = false; + if (strlen(file) > 4) { + const char *p = strrchr(file, '.'); - if(p != NULL) { - if((_stricmp(p, ".agb") == 0) || - (_stricmp(p, ".gba") == 0) || - (_stricmp(p, ".bin") == 0) || - (_stricmp(p, ".elf") == 0)) - return true; - if(_stricmp(p, ".mb") == 0) { - cpuIsMultiBoot = true; - return true; - } - } - } + if (p != NULL) { + if ((_stricmp(p, ".agb") == 0) || (_stricmp(p, ".gba") == 0) || + (_stricmp(p, ".bin") == 0) || (_stricmp(p, ".elf") == 0)) + return true; + if (_stricmp(p, ".mb") == 0) { + cpuIsMultiBoot = true; + return true; + } + } + } - return false; + return false; } -bool utilIsGBImage(const char * file) +bool utilIsGBImage(const char *file) { - if(strlen(file) > 4) { - const char * p = strrchr(file,'.'); + if (strlen(file) > 4) { + const char *p = strrchr(file, '.'); - if(p != NULL) { - if((_stricmp(p, ".dmg") == 0) || - (_stricmp(p, ".gb") == 0) || - (_stricmp(p, ".gbc") == 0) || - (_stricmp(p, ".cgb") == 0) || - (_stricmp(p, ".sgb") == 0)) - return true; - } - } + if (p != NULL) { + if ((_stricmp(p, ".dmg") == 0) || (_stricmp(p, ".gb") == 0) || + (_stricmp(p, ".gbc") == 0) || (_stricmp(p, ".cgb") == 0) || + (_stricmp(p, ".sgb") == 0)) + return true; + } + } - return false; + return false; } bool utilIsGzipFile(const char *file) { - if(strlen(file) > 3) { - const char * p = strrchr(file,'.'); + if (strlen(file) > 3) { + const char *p = strrchr(file, '.'); - if(p != NULL) { - if(_stricmp(p, ".gz") == 0) - return true; - if(_stricmp(p, ".z") == 0) - return true; - } - } + if (p != NULL) { + if (_stricmp(p, ".gz") == 0) + return true; + if (_stricmp(p, ".z") == 0) + return true; + } + } - return false; + return false; } // strip .gz or .z off end void utilStripDoubleExtension(const char *file, char *buffer) { - if(buffer != file) // allows conversion in place - strcpy(buffer, file); + if (buffer != file) // allows conversion in place + strcpy(buffer, file); - if(utilIsGzipFile(file)) { - char *p = strrchr(buffer, '.'); + if (utilIsGzipFile(file)) { + char *p = strrchr(buffer, '.'); - if(p) - *p = 0; - } + if (p) + *p = 0; + } } // Opens and scans archive using accept(). Returns fex_t if found. // If error or not found, displays message and returns NULL. -static fex_t* scan_arc(const char *file, bool (*accept)(const char *), - char (&buffer) [2048] ) +static fex_t *scan_arc(const char *file, bool (*accept)(const char *), char (&buffer)[2048]) { - fex_t* fe; - fex_err_t err = fex_open( &fe, file ); - if(!fe) - { - systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s: %s"), file, err); - return NULL; - } + fex_t *fe; + fex_err_t err = fex_open(&fe, file); + if (!fe) { + systemMessage(MSG_CANNOT_OPEN_FILE, N_("Cannot open file %s: %s"), file, err); + return NULL; + } - // Scan filenames - bool found=false; - while(!fex_done(fe)) { - strncpy(buffer,fex_name(fe),sizeof buffer); - buffer [sizeof buffer-1] = '\0'; + // Scan filenames + bool found = false; + while (!fex_done(fe)) { + strncpy(buffer, fex_name(fe), sizeof buffer); + buffer[sizeof buffer - 1] = '\0'; - utilStripDoubleExtension(buffer, buffer); + utilStripDoubleExtension(buffer, buffer); - if(accept(buffer)) { - found = true; - break; - } + if (accept(buffer)) { + found = true; + break; + } - fex_err_t err = fex_next(fe); - if(err) { - systemMessage(MSG_BAD_ZIP_FILE, N_("Cannot read archive %s: %s"), file, err); - fex_close(fe); - return NULL; - } - } + fex_err_t err = fex_next(fe); + if (err) { + systemMessage(MSG_BAD_ZIP_FILE, + N_("Cannot read archive %s: %s"), + file, + err); + fex_close(fe); + return NULL; + } + } - if(!found) { - systemMessage(MSG_NO_IMAGE_ON_ZIP, - N_("No image found in file %s"), file); - fex_close(fe); - return NULL; - } - return fe; + if (!found) { + systemMessage(MSG_NO_IMAGE_ON_ZIP, N_("No image found in file %s"), file); + fex_close(fe); + return NULL; + } + return fe; } static bool utilIsImage(const char *file) { - return utilIsGBAImage(file) || utilIsGBImage(file); + return utilIsGBAImage(file) || utilIsGBImage(file); } #ifdef WIN32 @@ -525,350 +499,347 @@ IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048]); IMAGE_TYPE utilFindType(const char *file) { - char buffer [2048]; - return utilFindType(file, buffer); + char buffer[2048]; + return utilFindType(file, buffer); } IMAGE_TYPE utilFindType(const char *file, char (&buffer)[2048]) { #ifdef WIN32 - DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, file, -1, NULL, 0); - wchar_t *pwText; - pwText = new wchar_t[dwNum]; - if(!pwText) - { - return IMAGE_UNKNOWN; - } - MultiByteToWideChar (CP_ACP, 0, file, -1, pwText, dwNum ); - char* file_conv = fex_wide_to_path( pwText); -// if ( !utilIsImage( file_conv ) ) // TODO: utilIsArchive() instead? -// { - fex_t* fe = scan_arc(file_conv,utilIsImage,buffer); - if(!fe) - return IMAGE_UNKNOWN; - fex_close(fe); - file = buffer; -// } - free(file_conv); + DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0); + wchar_t *pwText; + pwText = new wchar_t[dwNum]; + if (!pwText) { + return IMAGE_UNKNOWN; + } + MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum); + char *file_conv = fex_wide_to_path(pwText); + // if ( !utilIsImage( file_conv ) ) // TODO: utilIsArchive() instead? + // { + fex_t *fe = scan_arc(file_conv, utilIsImage, buffer); + if (!fe) + return IMAGE_UNKNOWN; + fex_close(fe); + file = buffer; + // } + free(file_conv); #else -// if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead? -// { - fex_t* fe = scan_arc(file,utilIsImage,buffer); - if(!fe) - return IMAGE_UNKNOWN; - fex_close(fe); - file = buffer; + // if ( !utilIsImage( file ) ) // TODO: utilIsArchive() instead? + // { + fex_t *fe = scan_arc(file, utilIsImage, buffer); + if (!fe) + return IMAGE_UNKNOWN; + fex_close(fe); + file = buffer; // } #endif - return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB; + return utilIsGBAImage(file) ? IMAGE_GBA : IMAGE_GB; } static int utilGetSize(int size) { - int res = 1; - while(res < size) - res <<= 1; - return res; + int res = 1; + while (res < size) + res <<= 1; + return res; } -u8 *utilLoad(const char *file, - bool (*accept)(const char *), - u8 *data, - int &size) +u8 *utilLoad(const char *file, bool (*accept)(const char *), u8 *data, int &size) { - // find image file - char buffer [2048]; + // find image file + char buffer[2048]; #ifdef WIN32 - DWORD dwNum = MultiByteToWideChar (CP_ACP, 0, file, -1, NULL, 0); - wchar_t *pwText; - pwText = new wchar_t[dwNum]; - if(!pwText) - { - return NULL; - } - MultiByteToWideChar (CP_ACP, 0, file, -1, pwText, dwNum ); - char* file_conv = fex_wide_to_path( pwText); - delete []pwText; - fex_t *fe = scan_arc(file_conv,accept,buffer); - if(!fe) - return NULL; - free(file_conv); + DWORD dwNum = MultiByteToWideChar(CP_ACP, 0, file, -1, NULL, 0); + wchar_t *pwText; + pwText = new wchar_t[dwNum]; + if (!pwText) { + return NULL; + } + MultiByteToWideChar(CP_ACP, 0, file, -1, pwText, dwNum); + char *file_conv = fex_wide_to_path(pwText); + delete[] pwText; + fex_t *fe = scan_arc(file_conv, accept, buffer); + if (!fe) + return NULL; + free(file_conv); #else - fex_t *fe = scan_arc(file,accept,buffer); - if(!fe) - return NULL; + fex_t *fe = scan_arc(file, accept, buffer); + if (!fe) + return NULL; #endif - // Allocate space for image - fex_err_t err = fex_stat(fe); - int fileSize = fex_size(fe); - if(size == 0) - size = fileSize; + // Allocate space for image + fex_err_t err = fex_stat(fe); + int fileSize = fex_size(fe); + if (size == 0) + size = fileSize; - u8 *image = data; + u8 *image = data; - if(image == NULL) { - // allocate buffer memory if none was passed to the function - image = (u8 *)malloc(utilGetSize(size)); - if(image == NULL) { - fex_close(fe); - systemMessage(MSG_OUT_OF_MEMORY, N_("Failed to allocate memory for %s"), - "data"); - return NULL; - } - size = fileSize; - } + if (image == NULL) { + // allocate buffer memory if none was passed to the function + image = (u8 *)malloc(utilGetSize(size)); + if (image == NULL) { + fex_close(fe); + systemMessage(MSG_OUT_OF_MEMORY, + N_("Failed to allocate memory for %s"), + "data"); + return NULL; + } + size = fileSize; + } - // Read image - int read = fileSize <= size ? fileSize : size; // do not read beyond file - err = fex_read(fe, image, read); - fex_close(fe); - if(err) { - systemMessage(MSG_ERROR_READING_IMAGE, - N_("Error reading image from %s: %s"), buffer, err); - if(data == NULL) - free(image); - return NULL; - } + // Read image + int read = fileSize <= size ? fileSize : size; // do not read beyond file + err = fex_read(fe, image, read); + fex_close(fe); + if (err) { + systemMessage(MSG_ERROR_READING_IMAGE, + N_("Error reading image from %s: %s"), + buffer, + err); + if (data == NULL) + free(image); + return NULL; + } - size = fileSize; + size = fileSize; - return image; + return image; } -void replaceAll(std::string& str, const std::string& from, const std::string& to) { - if (from.empty()) - return; - size_t start_pos = 0; - while ((start_pos = str.find(from, start_pos)) != std::string::npos) { - str.replace(start_pos, from.length(), to); - start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx' - } -} - -void utilExtract(const char* filepath, const char* filename) +void replaceAll(std::string &str, const std::string &from, const std::string &to) { - fex_t* fex; - std::string archive_name(filepath); - archive_name.append(filename); + if (from.empty()) + return; + size_t start_pos = 0; + while ((start_pos = str.find(from, start_pos)) != std::string::npos) { + str.replace(start_pos, from.length(), to); + start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with + // 'yx' + } +} - fex_open(&fex, archive_name.c_str()); - while (!fex_done(fex)) - { - std::string extracted_filename(filepath); - extracted_filename.append(fex_name(fex)); +void utilExtract(const char *filepath, const char *filename) +{ + fex_t *fex; + std::string archive_name(filepath); + archive_name.append(filename); + + fex_open(&fex, archive_name.c_str()); + while (!fex_done(fex)) { + std::string extracted_filename(filepath); + extracted_filename.append(fex_name(fex)); #ifdef WIN32 - replaceAll(extracted_filename, "/", "\\"); + replaceAll(extracted_filename, "/", "\\"); #endif - std::string new_dir(filepath); - new_dir.append(fex_name(fex)); + std::string new_dir(filepath); + new_dir.append(fex_name(fex)); #ifdef WIN32 - replaceAll(new_dir, "/", "\\"); + replaceAll(new_dir, "/", "\\"); #endif - new_dir = new_dir.substr(0, new_dir.find_last_of("\\")); - if (!FileExists(new_dir.c_str())) - mkdir(new_dir.c_str() + new_dir = new_dir.substr(0, new_dir.find_last_of("\\")); + if (!FileExists(new_dir.c_str())) + mkdir(new_dir.c_str() #ifndef WIN32 - ,0777 + , + 0777 #endif - ); + ); - if (FileExists(extracted_filename.c_str())) - { - std::string new_name(filepath); - new_name.append("old-"); - new_name.append(fex_name(fex)); + if (FileExists(extracted_filename.c_str())) { + std::string new_name(filepath); + new_name.append("old-"); + new_name.append(fex_name(fex)); #ifdef WIN32 - replaceAll(new_name, "/", "\\"); + replaceAll(new_name, "/", "\\"); #endif - remove(new_name.c_str()); - rename(extracted_filename.c_str(), new_name.c_str()); - } - - FILE *extracted_file = fopen(extracted_filename.c_str(), "wb"); - const void* p; - fex_data(fex, &p); - fwrite(p, fex_size(fex), 1, extracted_file); - fclose(extracted_file); - fex_next(fex); - } - fex_close(fex); + remove(new_name.c_str()); + rename(extracted_filename.c_str(), new_name.c_str()); + } + FILE *extracted_file = fopen(extracted_filename.c_str(), "wb"); + const void *p; + fex_data(fex, &p); + fwrite(p, fex_size(fex), 1, extracted_file); + fclose(extracted_file); + fex_next(fex); + } + fex_close(fex); } void utilWriteInt(gzFile gzFile, int i) { - utilGzWrite(gzFile, &i, sizeof(int)); + utilGzWrite(gzFile, &i, sizeof(int)); } int utilReadInt(gzFile gzFile) { - int i = 0; - utilGzRead(gzFile, &i, sizeof(int)); - return i; + int i = 0; + utilGzRead(gzFile, &i, sizeof(int)); + return i; } -void utilReadData(gzFile gzFile, variable_desc* data) +void utilReadData(gzFile gzFile, variable_desc *data) { - while(data->address) { - utilGzRead(gzFile, data->address, data->size); - data++; - } + while (data->address) { + utilGzRead(gzFile, data->address, data->size); + data++; + } } -void utilReadDataSkip(gzFile gzFile, variable_desc* data) +void utilReadDataSkip(gzFile gzFile, variable_desc *data) { - while(data->address) { - utilGzSeek(gzFile, data->size, SEEK_CUR); - data++; - } + while (data->address) { + utilGzSeek(gzFile, data->size, SEEK_CUR); + data++; + } } void utilWriteData(gzFile gzFile, variable_desc *data) { - while(data->address) { - utilGzWrite(gzFile, data->address, data->size); - data++; - } + while (data->address) { + utilGzWrite(gzFile, data->address, data->size); + data++; + } } gzFile utilGzOpen(const char *file, const char *mode) { - utilGzWriteFunc = (int (ZEXPORT *)(gzFile, void * const, unsigned int))gzwrite; - utilGzReadFunc = gzread; - utilGzCloseFunc = gzclose; - utilGzSeekFunc = gzseek; + utilGzWriteFunc = (int(ZEXPORT *)(gzFile, void *const, unsigned int))gzwrite; + utilGzReadFunc = gzread; + utilGzCloseFunc = gzclose; + utilGzSeekFunc = gzseek; - return gzopen(file, mode); + return gzopen(file, mode); } gzFile utilMemGzOpen(char *memory, int available, const char *mode) { - utilGzWriteFunc = memgzwrite; - utilGzReadFunc = memgzread; - utilGzCloseFunc = memgzclose; - utilGzSeekFunc = memgzseek; + utilGzWriteFunc = memgzwrite; + utilGzReadFunc = memgzread; + utilGzCloseFunc = memgzclose; + utilGzSeekFunc = memgzseek; - return memgzopen(memory, available, mode); + return memgzopen(memory, available, mode); } int utilGzWrite(gzFile file, const voidp buffer, unsigned int len) { - return utilGzWriteFunc(file, buffer, len); + return utilGzWriteFunc(file, buffer, len); } int utilGzRead(gzFile file, voidp buffer, unsigned int len) { - return utilGzReadFunc(file, buffer, len); + return utilGzReadFunc(file, buffer, len); } int utilGzClose(gzFile file) { - return utilGzCloseFunc(file); + return utilGzCloseFunc(file); } z_off_t utilGzSeek(gzFile file, z_off_t offset, int whence) { - return utilGzSeekFunc(file, offset, whence); + return utilGzSeekFunc(file, offset, whence); } long utilGzMemTell(gzFile file) { - return memtell(file); + return memtell(file); } void utilGBAFindSave(const int size) { - u32 *p = (u32 *)&rom[0]; - u32 *end = (u32 *)(&rom[0] + size); - int detectedSaveType = 0; - int flashSize = 0x10000; - bool rtcFound = false; + u32 *p = (u32 *)&rom[0]; + u32 *end = (u32 *)(&rom[0] + size); + int detectedSaveType = 0; + int flashSize = 0x10000; + bool rtcFound = false; - while(p < end) { - u32 d = READ32LE(p); + while (p < end) { + u32 d = READ32LE(p); - if(d == 0x52504545) { - if(memcmp(p, "EEPROM_", 7) == 0) { - if(detectedSaveType == 0 || detectedSaveType == 4) - detectedSaveType = 1; - } - } else if (d == 0x4D415253) { - if(memcmp(p, "SRAM_", 5) == 0) { - if(detectedSaveType == 0 || detectedSaveType == 1 || detectedSaveType == 4) - detectedSaveType = 2; - } - } else if (d == 0x53414C46) { - if(memcmp(p, "FLASH1M_", 8) == 0) { - if(detectedSaveType == 0) { - detectedSaveType = 3; - flashSize = 0x20000; + if (d == 0x52504545) { + if (memcmp(p, "EEPROM_", 7) == 0) { + if (detectedSaveType == 0 || detectedSaveType == 4) + detectedSaveType = 1; + } + } else if (d == 0x4D415253) { + if (memcmp(p, "SRAM_", 5) == 0) { + if (detectedSaveType == 0 || detectedSaveType == 1 || + detectedSaveType == 4) + detectedSaveType = 2; + } + } else if (d == 0x53414C46) { + if (memcmp(p, "FLASH1M_", 8) == 0) { + if (detectedSaveType == 0) { + detectedSaveType = 3; + flashSize = 0x20000; + } + } else if (memcmp(p, "FLASH512_", 9) == 0) { + if (detectedSaveType == 0) { + detectedSaveType = 3; + flashSize = 0x10000; + } + } else if (memcmp(p, "FLASH", 5) == 0) { + if (detectedSaveType == 0) { + detectedSaveType = 4; + flashSize = 0x10000; + } + } + } else if (d == 0x52494953) { + if (memcmp(p, "SIIRTC_V", 8) == 0) + rtcFound = true; + } + p++; } - } else if (memcmp(p, "FLASH512_", 9) == 0) { - if (detectedSaveType == 0) { - detectedSaveType = 3; - flashSize = 0x10000; - } - } else if(memcmp(p, "FLASH", 5) == 0) { - if(detectedSaveType == 0) { - detectedSaveType = 4; - flashSize = 0x10000; + // if no matches found, then set it to NONE + if (detectedSaveType == 0) { + detectedSaveType = 5; } - } - } else if (d == 0x52494953) { - if(memcmp(p, "SIIRTC_V", 8) == 0) - rtcFound = true; - } - p++; - } - // if no matches found, then set it to NONE - if(detectedSaveType == 0) { - detectedSaveType = 5; - } - if(detectedSaveType == 4) { - detectedSaveType = 3; - } - rtcEnable(rtcFound); - rtcEnableRumble(!rtcFound); - saveType = detectedSaveType; - flashSetSize(flashSize); + if (detectedSaveType == 4) { + detectedSaveType = 3; + } + rtcEnable(rtcFound); + rtcEnableRumble(!rtcFound); + saveType = detectedSaveType; + flashSetSize(flashSize); } void utilUpdateSystemColorMaps(bool lcd) { - switch(systemColorDepth) { - case 16: - { - for(int i = 0; i < 0x10000; i++) { - systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | - (((i & 0x3e0) >> 5) << systemGreenShift) | - (((i & 0x7c00) >> 10) << systemBlueShift); - } - if (lcd) gbafilter_pal(systemColorMap16, 0x10000); - } - break; - case 24: - case 32: - { - for(int i = 0; i < 0x10000; i++) { - systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | - (((i & 0x3e0) >> 5) << systemGreenShift) | - (((i & 0x7c00) >> 10) << systemBlueShift); - } - if (lcd) gbafilter_pal32(systemColorMap32, 0x10000); - } - break; - } + switch (systemColorDepth) { + case 16: { + for (int i = 0; i < 0x10000; i++) { + systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + if (lcd) + gbafilter_pal(systemColorMap16, 0x10000); + } break; + case 24: + case 32: { + for (int i = 0; i < 0x10000; i++) { + systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | + (((i & 0x3e0) >> 5) << systemGreenShift) | + (((i & 0x7c00) >> 10) << systemBlueShift); + } + if (lcd) + gbafilter_pal32(systemColorMap32, 0x10000); + } break; + } } // Check for existence of file. -bool utilFileExists( const char *filename ) +bool utilFileExists(const char *filename) { - FILE *f = fopen( filename, "r" ); - if( f == NULL ) { - return false; - } else { - fclose( f ); - return true; - } + FILE *f = fopen(filename, "r"); + if (f == NULL) { + return false; + } else { + fclose(f); + return true; + } } diff --git a/src/Util.h b/src/Util.h index 2f30b9c3..37cdeb03 100644 --- a/src/Util.h +++ b/src/Util.h @@ -3,21 +3,17 @@ #include "System.h" -enum IMAGE_TYPE { - IMAGE_UNKNOWN = -1, - IMAGE_GBA = 0, - IMAGE_GB = 1 -}; +enum IMAGE_TYPE { IMAGE_UNKNOWN = -1, IMAGE_GBA = 0, IMAGE_GB = 1 }; // save game typedef struct { - void *address; - int size; + void *address; + int size; } variable_desc; bool FileExists(const char *filename); -void utilReadScreenPixels(u8* dest, int w, int h); +void utilReadScreenPixels(u8 *dest, int w, int h); bool utilWritePNGFile(const char *, int, int, u8 *); bool utilWriteBMPFile(const char *, int, int, u8 *); void utilApplyIPS(const char *ips, uint8_t **rom, int *size); @@ -27,24 +23,23 @@ bool utilIsGzipFile(const char *); bool utilIsZipFile(const char *); void utilStripDoubleExtension(const char *, char *); IMAGE_TYPE utilFindType(const char *); -uint8_t *utilLoad(const char *, bool (*)(const char*), uint8_t *, int &); -void utilExtract(const char* filepath, const char* filename); +uint8_t *utilLoad(const char *, bool (*)(const char *), uint8_t *, int &); +void utilExtract(const char *filepath, const char *filename); void utilPutDword(uint8_t *, uint32_t); void utilPutWord(uint8_t *, uint16_t); void utilGBAFindSave(const int); void utilUpdateSystemColorMaps(bool lcd = false); -bool utilFileExists( const char *filename ); - +bool utilFileExists(const char *filename); #ifdef __LIBRETRO__ -void utilWriteIntMem(uint8_t *& data, int); -void utilWriteMem(uint8_t *& data, const void *in_data, unsigned size); -void utilWriteDataMem(uint8_t *& data, variable_desc *); +void utilWriteIntMem(uint8_t *&data, int); +void utilWriteMem(uint8_t *&data, const void *in_data, unsigned size); +void utilWriteDataMem(uint8_t *&data, variable_desc *); -int utilReadIntMem(const uint8_t *& data); -void utilReadMem(void *buf, const uint8_t *& data, unsigned size); -void utilReadDataMem(const uint8_t *& data, variable_desc *); +int utilReadIntMem(const uint8_t *&data); +void utilReadMem(void *buf, const uint8_t *&data, unsigned size); +void utilReadDataMem(const uint8_t *&data, variable_desc *); #else gzFile utilGzOpen(const char *file, const char *mode); gzFile utilMemGzOpen(char *memory, int available, const char *mode); @@ -60,5 +55,4 @@ int utilReadInt(gzFile); void utilWriteInt(gzFile, int); #endif - #endif // UTIL_H diff --git a/src/apu/Blip_Buffer.h b/src/apu/Blip_Buffer.h index 699bff7d..d55047bc 100644 --- a/src/apu/Blip_Buffer.h +++ b/src/apu/Blip_Buffer.h @@ -4,15 +4,15 @@ #ifndef BLIP_BUFFER_H #define BLIP_BUFFER_H - // internal - #include - #if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF - typedef long blip_long; - typedef unsigned long blip_ulong; - #else - typedef int blip_long; - typedef unsigned blip_ulong; - #endif +// internal +#include +#if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF +typedef long blip_long; +typedef unsigned long blip_ulong; +#else +typedef int blip_long; +typedef unsigned blip_ulong; +#endif // Time unit at source clock rate typedef blip_long blip_time_t; @@ -23,475 +23,559 @@ enum { blip_sample_max = 32767 }; struct blip_buffer_state_t; -class Blip_Buffer { -public: - typedef const char* blargg_err_t; +class Blip_Buffer +{ + public: + typedef const char *blargg_err_t; - // Sets output sample rate and buffer length in milliseconds (1/1000 sec, defaults - // to 1/4 second) and clears buffer. If there isn't enough memory, leaves buffer - // untouched and returns "Out of memory", otherwise returns NULL. - blargg_err_t set_sample_rate( long samples_per_sec, int msec_length = 1000 / 4 ); + // Sets output sample rate and buffer length in milliseconds (1/1000 sec, defaults + // to 1/4 second) and clears buffer. If there isn't enough memory, leaves buffer + // untouched and returns "Out of memory", otherwise returns NULL. + blargg_err_t set_sample_rate(long samples_per_sec, int msec_length = 1000 / 4); - // Sets number of source time units per second - void clock_rate( long clocks_per_sec ); + // Sets number of source time units per second + void clock_rate(long clocks_per_sec); - // Ends current time frame of specified duration and makes its samples available - // (along with any still-unread samples) for reading with read_samples(). Begins - // a new time frame at the end of the current frame. - void end_frame( blip_time_t time ); + // Ends current time frame of specified duration and makes its samples available + // (along with any still-unread samples) for reading with read_samples(). Begins + // a new time frame at the end of the current frame. + void end_frame(blip_time_t time); - // Reads at most 'max_samples' out of buffer into 'dest', removing them from - // the buffer. Returns number of samples actually read and removed. If stereo is - // true, increments 'dest' one extra time after writing each sample, to allow - // easy interleving of two channels into a stereo output buffer. - long read_samples( blip_sample_t* dest, long max_samples, int stereo = 0 ); + // Reads at most 'max_samples' out of buffer into 'dest', removing them from + // the buffer. Returns number of samples actually read and removed. If stereo is + // true, increments 'dest' one extra time after writing each sample, to allow + // easy interleving of two channels into a stereo output buffer. + long read_samples(blip_sample_t *dest, long max_samples, int stereo = 0); -// Additional features + // Additional features - // Removes all available samples and clear buffer to silence. If 'entire_buffer' is - // false, just clears out any samples waiting rather than the entire buffer. - void clear( int entire_buffer = 1 ); + // Removes all available samples and clear buffer to silence. If 'entire_buffer' is + // false, just clears out any samples waiting rather than the entire buffer. + void clear(int entire_buffer = 1); - // Number of samples available for reading with read_samples() - long samples_avail() const; + // Number of samples available for reading with read_samples() + long samples_avail() const; - // Removes 'count' samples from those waiting to be read - void remove_samples( long count ); + // Removes 'count' samples from those waiting to be read + void remove_samples(long count); - // Sets frequency high-pass filter frequency, where higher values reduce bass more - void bass_freq( int frequency ); + // Sets frequency high-pass filter frequency, where higher values reduce bass more + void bass_freq(int frequency); - // Current output sample rate - long sample_rate() const; + // Current output sample rate + long sample_rate() const; - // Length of buffer in milliseconds - int length() const; + // Length of buffer in milliseconds + int length() const; - // Number of source time units per second - long clock_rate() const; + // Number of source time units per second + long clock_rate() const; -// Experimental features + // Experimental features - // Saves state, including high-pass filter and tails of last deltas. - // All samples must have been read from buffer before calling this. - void save_state( blip_buffer_state_t* out ); + // Saves state, including high-pass filter and tails of last deltas. + // All samples must have been read from buffer before calling this. + void save_state(blip_buffer_state_t *out); - // Loads state. State must have been saved from Blip_Buffer with same - // settings during same run of program. States can NOT be stored on disk. - // Clears buffer before loading state. - void load_state( blip_buffer_state_t const& in ); + // Loads state. State must have been saved from Blip_Buffer with same + // settings during same run of program. States can NOT be stored on disk. + // Clears buffer before loading state. + void load_state(blip_buffer_state_t const &in); - // Number of samples delay from synthesis to samples read out - int output_latency() const; + // Number of samples delay from synthesis to samples read out + int output_latency() const; - // Counts number of clocks needed until 'count' samples will be available. - // If buffer can't even hold 'count' samples, returns number of clocks until - // buffer becomes full. - blip_time_t count_clocks( long count ) const; + // Counts number of clocks needed until 'count' samples will be available. + // If buffer can't even hold 'count' samples, returns number of clocks until + // buffer becomes full. + blip_time_t count_clocks(long count) const; - // Number of raw samples that can be mixed within frame of specified duration. - long count_samples( blip_time_t duration ) const; + // Number of raw samples that can be mixed within frame of specified duration. + long count_samples(blip_time_t duration) const; - // Mixes in 'count' samples from 'buf_in' - void mix_samples( blip_sample_t const* buf_in, long count ); + // Mixes in 'count' samples from 'buf_in' + void mix_samples(blip_sample_t const *buf_in, long count); + // Signals that sound has been added to buffer. Could be done automatically in + // Blip_Synth, but that would affect performance more, as you can arrange that + // this is called only once per time frame rather than for every delta. + void set_modified() + { + modified_ = this; + } - // Signals that sound has been added to buffer. Could be done automatically in - // Blip_Synth, but that would affect performance more, as you can arrange that - // this is called only once per time frame rather than for every delta. - void set_modified() { modified_ = this; } + // not documented yet + blip_ulong unsettled() const; + Blip_Buffer *clear_modified() + { + Blip_Buffer *b = modified_; + modified_ = 0; + return b; + } + void remove_silence(long count); + typedef blip_ulong blip_resampled_time_t; + blip_resampled_time_t resampled_duration(int t) const + { + return t * factor_; + } + blip_resampled_time_t resampled_time(blip_time_t t) const + { + return t * factor_ + offset_; + } + blip_resampled_time_t clock_rate_factor(long clock_rate) const; - // not documented yet - blip_ulong unsettled() const; - Blip_Buffer* clear_modified() { Blip_Buffer* b = modified_; modified_ = 0; return b; } - void remove_silence( long count ); - typedef blip_ulong blip_resampled_time_t; - blip_resampled_time_t resampled_duration( int t ) const { return t * factor_; } - blip_resampled_time_t resampled_time( blip_time_t t ) const { return t * factor_ + offset_; } - blip_resampled_time_t clock_rate_factor( long clock_rate ) const; -public: - Blip_Buffer(); - ~Blip_Buffer(); + public: + Blip_Buffer(); + ~Blip_Buffer(); - // Deprecated - typedef blip_resampled_time_t resampled_time_t; - blargg_err_t sample_rate( long r ) { return set_sample_rate( r ); } - blargg_err_t sample_rate( long r, int msec ) { return set_sample_rate( r, msec ); } -private: - // noncopyable - Blip_Buffer( const Blip_Buffer& ); - Blip_Buffer& operator = ( const Blip_Buffer& ); -public: - typedef blip_long buf_t_; - blip_ulong factor_; - blip_resampled_time_t offset_; - buf_t_* buffer_; - blip_long buffer_size_; - blip_long reader_accum_; - int bass_shift_; -private: - long sample_rate_; - long clock_rate_; - int bass_freq_; - int length_; - Blip_Buffer* modified_; // non-zero = true (more optimal than using bool, heh) - friend class Blip_Reader; + // Deprecated + typedef blip_resampled_time_t resampled_time_t; + blargg_err_t sample_rate(long r) + { + return set_sample_rate(r); + } + blargg_err_t sample_rate(long r, int msec) + { + return set_sample_rate(r, msec); + } + + private: + // noncopyable + Blip_Buffer(const Blip_Buffer &); + Blip_Buffer &operator=(const Blip_Buffer &); + + public: + typedef blip_long buf_t_; + blip_ulong factor_; + blip_resampled_time_t offset_; + buf_t_ *buffer_; + blip_long buffer_size_; + blip_long reader_accum_; + int bass_shift_; + + private: + long sample_rate_; + long clock_rate_; + int bass_freq_; + int length_; + Blip_Buffer *modified_; // non-zero = true (more optimal than using bool, heh) + friend class Blip_Reader; }; #ifdef HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif // Number of bits in resample ratio fraction. Higher values give a more accurate ratio // but reduce maximum buffer size. #ifndef BLIP_BUFFER_ACCURACY - #define BLIP_BUFFER_ACCURACY 16 +#define BLIP_BUFFER_ACCURACY 16 #endif // Number bits in phase offset. Fewer than 6 bits (64 phase offsets) results in // noticeable broadband noise when synthesizing high frequency square waves. // Affects size of Blip_Synth objects since they store the waveform directly. #ifndef BLIP_PHASE_BITS - #if BLIP_BUFFER_FAST - #define BLIP_PHASE_BITS 8 - #else - #define BLIP_PHASE_BITS 6 - #endif +#if BLIP_BUFFER_FAST +#define BLIP_PHASE_BITS 8 +#else +#define BLIP_PHASE_BITS 6 +#endif #endif - // Internal - typedef blip_ulong blip_resampled_time_t; - int const blip_widest_impulse_ = 16; - int const blip_buffer_extra_ = blip_widest_impulse_ + 2; - int const blip_res = 1 << BLIP_PHASE_BITS; - class blip_eq_t; +// Internal +typedef blip_ulong blip_resampled_time_t; +int const blip_widest_impulse_ = 16; +int const blip_buffer_extra_ = blip_widest_impulse_ + 2; +int const blip_res = 1 << BLIP_PHASE_BITS; +class blip_eq_t; - class Blip_Synth_Fast_ { - public: - Blip_Buffer* buf; - int last_amp; - int delta_factor; +class Blip_Synth_Fast_ +{ + public: + Blip_Buffer *buf; + int last_amp; + int delta_factor; - void volume_unit( double ); - Blip_Synth_Fast_(); - void treble_eq( blip_eq_t const& ) { } - }; + void volume_unit(double); + Blip_Synth_Fast_(); + void treble_eq(blip_eq_t const &) + { + } +}; - class Blip_Synth_ { - public: - Blip_Buffer* buf; - int last_amp; - int delta_factor; +class Blip_Synth_ +{ + public: + Blip_Buffer *buf; + int last_amp; + int delta_factor; - void volume_unit( double ); - Blip_Synth_( short* impulses, int width ); - void treble_eq( blip_eq_t const& ); - private: - double volume_unit_; - short* const impulses; - int const width; - blip_long kernel_unit; - int impulses_size() const { return blip_res / 2 * width + 1; } - void adjust_impulse(); - }; + void volume_unit(double); + Blip_Synth_(short *impulses, int width); + void treble_eq(blip_eq_t const &); + + private: + double volume_unit_; + short *const impulses; + int const width; + blip_long kernel_unit; + int impulses_size() const + { + return blip_res / 2 * width + 1; + } + void adjust_impulse(); +}; // Quality level, better = slower. In general, use blip_good_quality. -const int blip_med_quality = 8; +const int blip_med_quality = 8; const int blip_good_quality = 12; const int blip_high_quality = 16; // Range specifies the greatest expected change in amplitude. Calculate it // by finding the difference between the maximum and minimum expected // amplitudes (max - min). -template -class Blip_Synth { -public: - // Sets overall volume of waveform - void volume( double v ) { impl.volume_unit( v * (1.0 / (range < 0 ? -range : range)) ); } +template class Blip_Synth +{ + public: + // Sets overall volume of waveform + void volume(double v) + { + impl.volume_unit(v * (1.0 / (range < 0 ? -range : range))); + } - // Configures low-pass filter (see blip_buffer.txt) - void treble_eq( blip_eq_t const& eq ) { impl.treble_eq( eq ); } + // Configures low-pass filter (see blip_buffer.txt) + void treble_eq(blip_eq_t const &eq) + { + impl.treble_eq(eq); + } - // Gets/sets Blip_Buffer used for output - Blip_Buffer* output() const { return impl.buf; } - void output( Blip_Buffer* b ) { impl.buf = b; impl.last_amp = 0; } + // Gets/sets Blip_Buffer used for output + Blip_Buffer *output() const + { + return impl.buf; + } + void output(Blip_Buffer *b) + { + impl.buf = b; + impl.last_amp = 0; + } - // Updates amplitude of waveform at given time. Using this requires a separate - // Blip_Synth for each waveform. - void update( blip_time_t time, int amplitude ); + // Updates amplitude of waveform at given time. Using this requires a separate + // Blip_Synth for each waveform. + void update(blip_time_t time, int amplitude); -// Low-level interface + // Low-level interface - // Adds an amplitude transition of specified delta, optionally into specified buffer - // rather than the one set with output(). Delta can be positive or negative. - // The actual change in amplitude is delta * (volume / range) - void offset( blip_time_t, int delta, Blip_Buffer* ) const; - void offset( blip_time_t t, int delta ) const { offset( t, delta, impl.buf ); } + // Adds an amplitude transition of specified delta, optionally into specified buffer + // rather than the one set with output(). Delta can be positive or negative. + // The actual change in amplitude is delta * (volume / range) + void offset(blip_time_t, int delta, Blip_Buffer *) const; + void offset(blip_time_t t, int delta) const + { + offset(t, delta, impl.buf); + } - // Works directly in terms of fractional output samples. Contact author for more info. - void offset_resampled( blip_resampled_time_t, int delta, Blip_Buffer* ) const; + // Works directly in terms of fractional output samples. Contact author for more info. + void offset_resampled(blip_resampled_time_t, int delta, Blip_Buffer *) const; - // Same as offset(), except code is inlined for higher performance - void offset_inline( blip_time_t t, int delta, Blip_Buffer* buf ) const { - offset_resampled( t * buf->factor_ + buf->offset_, delta, buf ); - } - void offset_inline( blip_time_t t, int delta ) const { - offset_resampled( t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf ); - } + // Same as offset(), except code is inlined for higher performance + void offset_inline(blip_time_t t, int delta, Blip_Buffer *buf) const + { + offset_resampled(t * buf->factor_ + buf->offset_, delta, buf); + } + void offset_inline(blip_time_t t, int delta) const + { + offset_resampled(t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf); + } -private: + private: #if BLIP_BUFFER_FAST - Blip_Synth_Fast_ impl; + Blip_Synth_Fast_ impl; #else - Blip_Synth_ impl; - typedef short imp_t; - imp_t impulses [blip_res * (quality / 2) + 1]; -public: - Blip_Synth() : impl( impulses, quality ) { } + Blip_Synth_ impl; + typedef short imp_t; + imp_t impulses[blip_res * (quality / 2) + 1]; + + public: + Blip_Synth() : impl(impulses, quality) + { + } #endif }; // Low-pass equalization parameters -class blip_eq_t { -public: - // Logarithmic rolloff to treble dB at half sampling rate. Negative values reduce - // treble, small positive values (0 to 5.0) increase treble. - blip_eq_t( double treble_db = 0 ); +class blip_eq_t +{ + public: + // Logarithmic rolloff to treble dB at half sampling rate. Negative values reduce + // treble, small positive values (0 to 5.0) increase treble. + blip_eq_t(double treble_db = 0); - // See blip_buffer.txt - blip_eq_t( double treble, long rolloff_freq, long sample_rate, long cutoff_freq = 0 ); + // See blip_buffer.txt + blip_eq_t(double treble, long rolloff_freq, long sample_rate, long cutoff_freq = 0); -private: - double treble; - long rolloff_freq; - long sample_rate; - long cutoff_freq; - void generate( float* out, int count ) const; - friend class Blip_Synth_; + private: + double treble; + long rolloff_freq; + long sample_rate; + long cutoff_freq; + void generate(float *out, int count) const; + friend class Blip_Synth_; }; int const blip_sample_bits = 30; // Dummy Blip_Buffer to direct sound output to, for easy muting without // having to stop sound code. -class Silent_Blip_Buffer : public Blip_Buffer { - buf_t_ buf [blip_buffer_extra_ + 1]; -public: - // The following cannot be used (an assertion will fail if attempted): - blargg_err_t set_sample_rate( long samples_per_sec, int msec_length ); - blip_time_t count_clocks( long count ) const; - void mix_samples( blip_sample_t const* buf, long count ); +class Silent_Blip_Buffer : public Blip_Buffer +{ + buf_t_ buf[blip_buffer_extra_ + 1]; - Silent_Blip_Buffer(); + public: + // The following cannot be used (an assertion will fail if attempted): + blargg_err_t set_sample_rate(long samples_per_sec, int msec_length); + blip_time_t count_clocks(long count) const; + void mix_samples(blip_sample_t const *buf, long count); + + Silent_Blip_Buffer(); }; - #if __GNUC__ >= 3 || _MSC_VER >= 1100 - #define BLIP_RESTRICT __restrict - #else - #define BLIP_RESTRICT - #endif +#if __GNUC__ >= 3 || _MSC_VER >= 1100 +#define BLIP_RESTRICT __restrict +#else +#define BLIP_RESTRICT +#endif // Optimized reading from Blip_Buffer, for use in custom sample output // Begins reading from buffer. Name should be unique to the current block. -#define BLIP_READER_BEGIN( name, blip_buffer ) \ - const Blip_Buffer::buf_t_* BLIP_RESTRICT name##_reader_buf = (blip_buffer).buffer_;\ - blip_long name##_reader_accum = (blip_buffer).reader_accum_ +#define BLIP_READER_BEGIN(name, blip_buffer) \ + const Blip_Buffer::buf_t_ *BLIP_RESTRICT name##_reader_buf = (blip_buffer).buffer_; \ + blip_long name##_reader_accum = (blip_buffer).reader_accum_ // Gets value to pass to BLIP_READER_NEXT() -#define BLIP_READER_BASS( blip_buffer ) ((blip_buffer).bass_shift_) +#define BLIP_READER_BASS(blip_buffer) ((blip_buffer).bass_shift_) // Constant value to use instead of BLIP_READER_BASS(), for slightly more optimal // code at the cost of having no bass control int const blip_reader_default_bass = 9; // Current sample -#define BLIP_READER_READ( name ) (name##_reader_accum >> (blip_sample_bits - 16)) +#define BLIP_READER_READ(name) (name##_reader_accum >> (blip_sample_bits - 16)) // Current raw sample in full internal resolution -#define BLIP_READER_READ_RAW( name ) (name##_reader_accum) +#define BLIP_READER_READ_RAW(name) (name##_reader_accum) // Advances to next sample -#define BLIP_READER_NEXT( name, bass ) \ - (void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass))) +#define BLIP_READER_NEXT(name, bass) \ + (void)(name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass))) // Ends reading samples from buffer. The number of samples read must now be removed // using Blip_Buffer::remove_samples(). -#define BLIP_READER_END( name, blip_buffer ) \ - (void) ((blip_buffer).reader_accum_ = name##_reader_accum) - +#define BLIP_READER_END(name, blip_buffer) (void)((blip_buffer).reader_accum_ = name##_reader_accum) // experimental -#define BLIP_READER_ADJ_( name, offset ) (name##_reader_buf += offset) +#define BLIP_READER_ADJ_(name, offset) (name##_reader_buf += offset) -blip_long const blip_reader_idx_factor = sizeof (Blip_Buffer::buf_t_); +blip_long const blip_reader_idx_factor = sizeof(Blip_Buffer::buf_t_); -#define BLIP_READER_NEXT_IDX_( name, bass, idx ) {\ - name##_reader_accum -= name##_reader_accum >> (bass);\ - name##_reader_accum += name##_reader_buf [(idx)];\ -} +#define BLIP_READER_NEXT_IDX_(name, bass, idx) \ + { \ + name##_reader_accum -= name##_reader_accum >> (bass); \ + name##_reader_accum += name##_reader_buf[(idx)]; \ + } -#define BLIP_READER_NEXT_RAW_IDX_( name, bass, idx ) {\ - name##_reader_accum -= name##_reader_accum >> (bass);\ - name##_reader_accum +=\ - *(Blip_Buffer::buf_t_ const*) ((char const*) name##_reader_buf + (idx));\ -} +#define BLIP_READER_NEXT_RAW_IDX_(name, bass, idx) \ + { \ + name##_reader_accum -= name##_reader_accum >> (bass); \ + name##_reader_accum += \ + *(Blip_Buffer::buf_t_ const *)((char const *)name##_reader_buf + (idx)); \ + } // Compatibility with older version const long blip_unscaled = 65535; -const int blip_low_quality = blip_med_quality; +const int blip_low_quality = blip_med_quality; const int blip_best_quality = blip_high_quality; // Deprecated; use BLIP_READER macros as follows: // Blip_Reader r; r.begin( buf ); -> BLIP_READER_BEGIN( r, buf ); -// int bass = r.begin( buf ) -> BLIP_READER_BEGIN( r, buf ); int bass = BLIP_READER_BASS( buf ); +// int bass = r.begin( buf ) -> BLIP_READER_BEGIN( r, buf ); int bass = BLIP_READER_BASS( buf +// ); // r.read() -> BLIP_READER_READ( r ) // r.read_raw() -> BLIP_READER_READ_RAW( r ) // r.next( bass ) -> BLIP_READER_NEXT( r, bass ) // r.next() -> BLIP_READER_NEXT( r, blip_reader_default_bass ) // r.end( buf ) -> BLIP_READER_END( r, buf ) -class Blip_Reader { -public: - int begin( Blip_Buffer& ); - blip_long read() const { return accum >> (blip_sample_bits - 16); } - blip_long read_raw() const { return accum; } - void next( int bass_shift = 9 ) { accum += *buf++ - (accum >> bass_shift); } - void end( Blip_Buffer& b ) { b.reader_accum_ = accum; } -private: - const Blip_Buffer::buf_t_* buf; - blip_long accum; +class Blip_Reader +{ + public: + int begin(Blip_Buffer &); + blip_long read() const + { + return accum >> (blip_sample_bits - 16); + } + blip_long read_raw() const + { + return accum; + } + void next(int bass_shift = 9) + { + accum += *buf++ - (accum >> bass_shift); + } + void end(Blip_Buffer &b) + { + b.reader_accum_ = accum; + } + + private: + const Blip_Buffer::buf_t_ *buf; + blip_long accum; }; -#if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ - defined (__x86_64__) || defined (__ia64__) || defined (__i386__) - #define BLIP_CLAMP_( in ) in < -0x8000 || 0x7FFF < in +#if defined(_M_IX86) || defined(_M_IA64) || defined(__i486__) || defined(__x86_64__) || \ + defined(__ia64__) || defined(__i386__) +#define BLIP_CLAMP_(in) in < -0x8000 || 0x7FFF < in #else - #define BLIP_CLAMP_( in ) (blip_sample_t) in != in +#define BLIP_CLAMP_(in) (blip_sample_t) in != in #endif // Clamp sample to blip_sample_t range -#define BLIP_CLAMP( sample, out )\ - { if ( BLIP_CLAMP_( (sample) ) ) (out) = ((sample) >> 24) ^ 0x7FFF; } +#define BLIP_CLAMP(sample, out) \ + { \ + if (BLIP_CLAMP_((sample))) \ + (out) = ((sample) >> 24) ^ 0x7FFF; \ + } -struct blip_buffer_state_t -{ - blip_resampled_time_t offset_; - blip_long reader_accum_; - blip_long buf [blip_buffer_extra_]; +struct blip_buffer_state_t { + blip_resampled_time_t offset_; + blip_long reader_accum_; + blip_long buf[blip_buffer_extra_]; }; // End of public interface #ifndef assert - #include +#include #endif -template -inline void Blip_Synth::offset_resampled( blip_resampled_time_t time, - int delta, Blip_Buffer* blip_buf ) const +template +inline void Blip_Synth::offset_resampled(blip_resampled_time_t time, int delta, + Blip_Buffer *blip_buf) const { - // If this assertion fails, it means that an attempt was made to add a delta - // at a negative time or past the end of the buffer. - assert( (blip_long) (time >> BLIP_BUFFER_ACCURACY) < blip_buf->buffer_size_ ); + // If this assertion fails, it means that an attempt was made to add a delta + // at a negative time or past the end of the buffer. + assert((blip_long)(time >> BLIP_BUFFER_ACCURACY) < blip_buf->buffer_size_); - delta *= impl.delta_factor; - blip_long* BLIP_RESTRICT buf = blip_buf->buffer_ + (time >> BLIP_BUFFER_ACCURACY); - int phase = (int) (time >> (BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS) & (blip_res - 1)); + delta *= impl.delta_factor; + blip_long *BLIP_RESTRICT buf = blip_buf->buffer_ + (time >> BLIP_BUFFER_ACCURACY); + int phase = (int)(time >> (BLIP_BUFFER_ACCURACY - BLIP_PHASE_BITS) & (blip_res - 1)); #if BLIP_BUFFER_FAST - blip_long left = buf [0] + delta; + blip_long left = buf[0] + delta; - // Kind of crappy, but doing shift after multiply results in overflow. - // Alternate way of delaying multiply by delta_factor results in worse - // sub-sample resolution. - blip_long right = (delta >> BLIP_PHASE_BITS) * phase; - left -= right; - right += buf [1]; + // Kind of crappy, but doing shift after multiply results in overflow. + // Alternate way of delaying multiply by delta_factor results in worse + // sub-sample resolution. + blip_long right = (delta >> BLIP_PHASE_BITS) * phase; + left -= right; + right += buf[1]; - buf [0] = left; - buf [1] = right; + buf[0] = left; + buf[1] = right; #else - int const fwd = (blip_widest_impulse_ - quality) / 2; - int const rev = fwd + quality - 2; - int const mid = quality / 2 - 1; + int const fwd = (blip_widest_impulse_ - quality) / 2; + int const rev = fwd + quality - 2; + int const mid = quality / 2 - 1; - imp_t const* BLIP_RESTRICT imp = impulses + blip_res - phase; + imp_t const *BLIP_RESTRICT imp = impulses + blip_res - phase; - #if defined (_M_IX86) || defined (_M_IA64) || defined (__i486__) || \ - defined (__x86_64__) || defined (__ia64__) || defined (__i386__) +#if defined(_M_IX86) || defined(_M_IA64) || defined(__i486__) || defined(__x86_64__) || \ + defined(__ia64__) || defined(__i386__) - // this straight forward version gave in better code on GCC for x86 +// this straight forward version gave in better code on GCC for x86 - #define ADD_IMP( out, in ) \ - buf [out] += (blip_long) imp [blip_res * (in)] * delta +#define ADD_IMP(out, in) buf[out] += (blip_long)imp[blip_res * (in)] * delta - #define BLIP_FWD( i ) {\ - ADD_IMP( fwd + i, i );\ - ADD_IMP( fwd + 1 + i, i + 1 );\ - } - #define BLIP_REV( r ) {\ - ADD_IMP( rev - r, r + 1 );\ - ADD_IMP( rev + 1 - r, r );\ - } +#define BLIP_FWD(i) \ + { \ + ADD_IMP(fwd + i, i); \ + ADD_IMP(fwd + 1 + i, i + 1); \ + } +#define BLIP_REV(r) \ + { \ + ADD_IMP(rev - r, r + 1); \ + ADD_IMP(rev + 1 - r, r); \ + } - BLIP_FWD( 0 ) - if ( quality > 8 ) BLIP_FWD( 2 ) - if ( quality > 12 ) BLIP_FWD( 4 ) - { - ADD_IMP( fwd + mid - 1, mid - 1 ); - ADD_IMP( fwd + mid , mid ); - imp = impulses + phase; - } - if ( quality > 12 ) BLIP_REV( 6 ) - if ( quality > 8 ) BLIP_REV( 4 ) - BLIP_REV( 2 ) + BLIP_FWD(0) + if (quality > 8) + BLIP_FWD(2) + if (quality > 12) + BLIP_FWD(4) + { + ADD_IMP(fwd + mid - 1, mid - 1); + ADD_IMP(fwd + mid, mid); + imp = impulses + phase; + } + if (quality > 12) + BLIP_REV(6) + if (quality > 8) + BLIP_REV(4) + BLIP_REV(2) - ADD_IMP( rev , 1 ); - ADD_IMP( rev + 1, 0 ); + ADD_IMP(rev, 1); + ADD_IMP(rev + 1, 0); - #undef ADD_IMP +#undef ADD_IMP - #else +#else - // for RISC processors, help compiler by reading ahead of writes +// for RISC processors, help compiler by reading ahead of writes - #define BLIP_FWD( i ) {\ - blip_long t0 = i0 * delta + buf [fwd + i];\ - blip_long t1 = imp [blip_res * (i + 1)] * delta + buf [fwd + 1 + i];\ - i0 = imp [blip_res * (i + 2)];\ - buf [fwd + i] = t0;\ - buf [fwd + 1 + i] = t1;\ - } - #define BLIP_REV( r ) {\ - blip_long t0 = i0 * delta + buf [rev - r];\ - blip_long t1 = imp [blip_res * r] * delta + buf [rev + 1 - r];\ - i0 = imp [blip_res * (r - 1)];\ - buf [rev - r] = t0;\ - buf [rev + 1 - r] = t1;\ - } +#define BLIP_FWD(i) \ + { \ + blip_long t0 = i0 * delta + buf[fwd + i]; \ + blip_long t1 = imp[blip_res * (i + 1)] * delta + buf[fwd + 1 + i]; \ + i0 = imp[blip_res * (i + 2)]; \ + buf[fwd + i] = t0; \ + buf[fwd + 1 + i] = t1; \ + } +#define BLIP_REV(r) \ + { \ + blip_long t0 = i0 * delta + buf[rev - r]; \ + blip_long t1 = imp[blip_res * r] * delta + buf[rev + 1 - r]; \ + i0 = imp[blip_res * (r - 1)]; \ + buf[rev - r] = t0; \ + buf[rev + 1 - r] = t1; \ + } - blip_long i0 = *imp; - BLIP_FWD( 0 ) - if ( quality > 8 ) BLIP_FWD( 2 ) - if ( quality > 12 ) BLIP_FWD( 4 ) - { - blip_long t0 = i0 * delta + buf [fwd + mid - 1]; - blip_long t1 = imp [blip_res * mid] * delta + buf [fwd + mid ]; - imp = impulses + phase; - i0 = imp [blip_res * mid]; - buf [fwd + mid - 1] = t0; - buf [fwd + mid ] = t1; - } - if ( quality > 12 ) BLIP_REV( 6 ) - if ( quality > 8 ) BLIP_REV( 4 ) - BLIP_REV( 2 ) + blip_long i0 = *imp; + BLIP_FWD(0) + if (quality > 8) + BLIP_FWD(2) + if (quality > 12) + BLIP_FWD(4) + { + blip_long t0 = i0 * delta + buf[fwd + mid - 1]; + blip_long t1 = imp[blip_res * mid] * delta + buf[fwd + mid]; + imp = impulses + phase; + i0 = imp[blip_res * mid]; + buf[fwd + mid - 1] = t0; + buf[fwd + mid] = t1; + } + if (quality > 12) + BLIP_REV(6) + if (quality > 8) + BLIP_REV(4) + BLIP_REV(2) - blip_long t0 = i0 * delta + buf [rev ]; - blip_long t1 = *imp * delta + buf [rev + 1]; - buf [rev ] = t0; - buf [rev + 1] = t1; - #endif + blip_long t0 = i0 * delta + buf[rev]; + blip_long t1 = *imp * delta + buf[rev + 1]; + buf[rev] = t0; + buf[rev + 1] = t1; +#endif #endif } @@ -499,55 +583,79 @@ inline void Blip_Synth::offset_resampled( blip_resampled_time_t t #undef BLIP_FWD #undef BLIP_REV -template +template #if BLIP_BUFFER_FAST - inline +inline #endif -void Blip_Synth::offset( blip_time_t t, int delta, Blip_Buffer* buf ) const + void + Blip_Synth::offset(blip_time_t t, int delta, Blip_Buffer *buf) const { - offset_resampled( t * buf->factor_ + buf->offset_, delta, buf ); + offset_resampled(t * buf->factor_ + buf->offset_, delta, buf); } -template +template #if BLIP_BUFFER_FAST - inline +inline #endif -void Blip_Synth::update( blip_time_t t, int amp ) + void + Blip_Synth::update(blip_time_t t, int amp) { - int delta = amp - impl.last_amp; - impl.last_amp = amp; - offset_resampled( t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf ); + int delta = amp - impl.last_amp; + impl.last_amp = amp; + offset_resampled(t * impl.buf->factor_ + impl.buf->offset_, delta, impl.buf); } -inline blip_eq_t::blip_eq_t( double t ) : - treble( t ), rolloff_freq( 0 ), sample_rate( 44100 ), cutoff_freq( 0 ) { } -inline blip_eq_t::blip_eq_t( double t, long rf, long sr, long cf ) : - treble( t ), rolloff_freq( rf ), sample_rate( sr ), cutoff_freq( cf ) { } - -inline int Blip_Buffer::length() const { return length_; } -inline long Blip_Buffer::samples_avail() const { return (long) (offset_ >> BLIP_BUFFER_ACCURACY); } -inline long Blip_Buffer::sample_rate() const { return sample_rate_; } -inline int Blip_Buffer::output_latency() const { return blip_widest_impulse_ / 2; } -inline long Blip_Buffer::clock_rate() const { return clock_rate_; } -inline void Blip_Buffer::clock_rate( long cps ) { factor_ = clock_rate_factor( clock_rate_ = cps ); } - -inline int Blip_Reader::begin( Blip_Buffer& blip_buf ) +inline blip_eq_t::blip_eq_t(double t) + : treble(t), rolloff_freq(0), sample_rate(44100), cutoff_freq(0) +{ +} +inline blip_eq_t::blip_eq_t(double t, long rf, long sr, long cf) + : treble(t), rolloff_freq(rf), sample_rate(sr), cutoff_freq(cf) { - buf = blip_buf.buffer_; - accum = blip_buf.reader_accum_; - return blip_buf.bass_shift_; } -inline void Blip_Buffer::remove_silence( long count ) +inline int Blip_Buffer::length() const { - // fails if you try to remove more samples than available - assert( count <= samples_avail() ); - offset_ -= (blip_resampled_time_t) count << BLIP_BUFFER_ACCURACY; + return length_; +} +inline long Blip_Buffer::samples_avail() const +{ + return (long)(offset_ >> BLIP_BUFFER_ACCURACY); +} +inline long Blip_Buffer::sample_rate() const +{ + return sample_rate_; +} +inline int Blip_Buffer::output_latency() const +{ + return blip_widest_impulse_ / 2; +} +inline long Blip_Buffer::clock_rate() const +{ + return clock_rate_; +} +inline void Blip_Buffer::clock_rate(long cps) +{ + factor_ = clock_rate_factor(clock_rate_ = cps); +} + +inline int Blip_Reader::begin(Blip_Buffer &blip_buf) +{ + buf = blip_buf.buffer_; + accum = blip_buf.reader_accum_; + return blip_buf.bass_shift_; +} + +inline void Blip_Buffer::remove_silence(long count) +{ + // fails if you try to remove more samples than available + assert(count <= samples_avail()); + offset_ -= (blip_resampled_time_t)count << BLIP_BUFFER_ACCURACY; } inline blip_ulong Blip_Buffer::unsettled() const { - return reader_accum_ >> (blip_sample_bits - 16); + return reader_accum_ >> (blip_sample_bits - 16); } int const blip_max_length = 0; diff --git a/src/apu/Effects_Buffer.h b/src/apu/Effects_Buffer.h index 790325d9..8d220c90 100644 --- a/src/apu/Effects_Buffer.h +++ b/src/apu/Effects_Buffer.h @@ -8,136 +8,154 @@ // See Simple_Effects_Buffer (below) for a simpler interface -class Effects_Buffer : public Multi_Buffer { -public: - // To reduce memory usage, fewer buffers can be used (with a best-fit - // approach if there are too few), and maximum echo delay can be reduced - Effects_Buffer( int max_bufs = 32, long echo_size = 24 * 1024L ); +class Effects_Buffer : public Multi_Buffer +{ + public: + // To reduce memory usage, fewer buffers can be used (with a best-fit + // approach if there are too few), and maximum echo delay can be reduced + Effects_Buffer(int max_bufs = 32, long echo_size = 24 * 1024L); - struct pan_vol_t - { - float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal - float pan; // -1.0 = left, 0.0 = center, +1.0 = right - }; + struct pan_vol_t { + float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal + float pan; // -1.0 = left, 0.0 = center, +1.0 = right + }; - // Global configuration - struct config_t - { - bool enabled; // false = disable all effects + // Global configuration + struct config_t { + bool enabled; // false = disable all effects - // Current sound is echoed at adjustable left/right delay, - // with reduced treble and volume (feedback). - float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent - int delay [2]; // left, right delays (msec) - float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony - pan_vol_t side_chans [2]; // left and right side channel volume and pan - }; - config_t& config() { return config_; } + // Current sound is echoed at adjustable left/right delay, + // with reduced treble and volume (feedback). + float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent + int delay[2]; // left, right delays (msec) + float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony + pan_vol_t side_chans[2]; // left and right side channel volume and pan + }; + config_t &config() + { + return config_; + } - // Limits of delay (msec) - int min_delay() const; - int max_delay() const; + // Limits of delay (msec) + int min_delay() const; + int max_delay() const; - // Per-channel configuration. Two or more channels with matching parameters are - // optimized to internally use the same buffer. - struct chan_config_t : pan_vol_t - { - // (inherited from pan_vol_t) - //float vol; // these only affect center channel - //float pan; - bool surround; // if true, negates left volume to put sound in back - bool echo; // false = channel doesn't have any echo - }; - chan_config_t& chan_config( int i ) { return chans [i + extra_chans].cfg; } + // Per-channel configuration. Two or more channels with matching parameters are + // optimized to internally use the same buffer. + struct chan_config_t : pan_vol_t { + // (inherited from pan_vol_t) + // float vol; // these only affect center channel + // float pan; + bool surround; // if true, negates left volume to put sound in back + bool echo; // false = channel doesn't have any echo + }; + chan_config_t &chan_config(int i) + { + return chans[i + extra_chans].cfg; + } - // Apply any changes made to config() and chan_config() - virtual void apply_config(); + // Apply any changes made to config() and chan_config() + virtual void apply_config(); -public: - ~Effects_Buffer(); - blargg_err_t set_sample_rate( long samples_per_sec, int msec = blip_default_length ); - blargg_err_t set_channel_count( int, int const* = 0 ); - void clock_rate( long ); - void bass_freq( int ); - void clear(); - channel_t channel( int ); - void end_frame( blip_time_t ); - long read_samples( blip_sample_t*, long ); - long samples_avail() const { return (bufs [0].samples_avail() - mixer.samples_read) * 2; } - enum { stereo = 2 }; - typedef blargg_long fixed_t; -protected: - enum { extra_chans = stereo * stereo }; -private: - config_t config_; - long clock_rate_; - int bass_freq_; + public: + ~Effects_Buffer(); + blargg_err_t set_sample_rate(long samples_per_sec, int msec = blip_default_length); + blargg_err_t set_channel_count(int, int const * = 0); + void clock_rate(long); + void bass_freq(int); + void clear(); + channel_t channel(int); + void end_frame(blip_time_t); + long read_samples(blip_sample_t *, long); + long samples_avail() const + { + return (bufs[0].samples_avail() - mixer.samples_read) * 2; + } + enum { stereo = 2 }; + typedef blargg_long fixed_t; - blargg_long echo_size; + protected: + enum { extra_chans = stereo * stereo }; - struct chan_t - { - fixed_t vol [stereo]; - chan_config_t cfg; - channel_t channel; - }; - blargg_vector chans; + private: + config_t config_; + long clock_rate_; + int bass_freq_; - struct buf_t : Tracked_Blip_Buffer - { - fixed_t vol [stereo]; - bool echo; + blargg_long echo_size; - void* operator new ( size_t, void* p ) { return p; } - void operator delete ( void* ) { } + struct chan_t { + fixed_t vol[stereo]; + chan_config_t cfg; + channel_t channel; + }; + blargg_vector chans; - ~buf_t() { } - }; - buf_t* bufs; - int bufs_size; - int bufs_max; // bufs_size <= bufs_max, to limit memory usage - Stereo_Mixer mixer; + struct buf_t : Tracked_Blip_Buffer { + fixed_t vol[stereo]; + bool echo; - struct { - long delay [stereo]; - fixed_t treble; - fixed_t feedback; - fixed_t low_pass [stereo]; - } s; + void *operator new(size_t, void *p) + { + return p; + } + void operator delete(void *) + { + } - blargg_vector echo; - blargg_long echo_pos; + ~buf_t() + { + } + }; + buf_t *bufs; + int bufs_size; + int bufs_max; // bufs_size <= bufs_max, to limit memory usage + Stereo_Mixer mixer; - bool no_effects; - bool no_echo; + struct { + long delay[stereo]; + fixed_t treble; + fixed_t feedback; + fixed_t low_pass[stereo]; + } s; - void assign_buffers(); - void clear_echo(); - void mix_effects( blip_sample_t* out, int pair_count ); - blargg_err_t new_bufs( int size ); - void delete_bufs(); + blargg_vector echo; + blargg_long echo_pos; + + bool no_effects; + bool no_echo; + + void assign_buffers(); + void clear_echo(); + void mix_effects(blip_sample_t *out, int pair_count); + blargg_err_t new_bufs(int size); + void delete_bufs(); }; // Simpler interface and lower memory usage -class Simple_Effects_Buffer : public Effects_Buffer { -public: - struct config_t - { - bool enabled; // false = disable all effects - float echo; // 0.0 = none, 1.0 = lots - float stereo; // 0.0 = channels in center, 1.0 = channels on left/right - bool surround; // true = put some channels in back - }; - config_t& config() { return config_; } +class Simple_Effects_Buffer : public Effects_Buffer +{ + public: + struct config_t { + bool enabled; // false = disable all effects + float echo; // 0.0 = none, 1.0 = lots + float stereo; // 0.0 = channels in center, 1.0 = channels on left/right + bool surround; // true = put some channels in back + }; + config_t &config() + { + return config_; + } - // Apply any changes made to config() - void apply_config(); + // Apply any changes made to config() + void apply_config(); -public: - Simple_Effects_Buffer(); -private: - config_t config_; - void chan_config(); // hide + public: + Simple_Effects_Buffer(); + + private: + config_t config_; + void chan_config(); // hide }; #endif diff --git a/src/apu/Gb_Apu.h b/src/apu/Gb_Apu.h index 3f132096..7e9eff90 100644 --- a/src/apu/Gb_Apu.h +++ b/src/apu/Gb_Apu.h @@ -8,175 +8,185 @@ struct gb_apu_state_t; -class Gb_Apu { -public: -// Basics +class Gb_Apu +{ + public: + // Basics - // Clock rate that sound hardware runs at. - enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; + // Clock rate that sound hardware runs at. + enum { clock_rate = 4194304 * GB_APU_OVERCLOCK }; - // Sets buffer(s) to generate sound into. If left and right are NULL, output is mono. - // If all are NULL, no output is generated but other emulation still runs. - // If chan is specified, only that channel's output is changed, otherwise all are. - enum { osc_count = 4 }; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise - void set_output( Blip_Buffer* center, Blip_Buffer* left = NULL, Blip_Buffer* right = NULL, - int chan = osc_count ); + // Sets buffer(s) to generate sound into. If left and right are NULL, output is mono. + // If all are NULL, no output is generated but other emulation still runs. + // If chan is specified, only that channel's output is changed, otherwise all are. + enum { osc_count = 4 }; // 0: Square 1, 1: Square 2, 2: Wave, 3: Noise + void set_output(Blip_Buffer *center, Blip_Buffer *left = NULL, Blip_Buffer *right = NULL, + int chan = osc_count); - // Resets hardware to initial power on state BEFORE boot ROM runs. Mode selects - // sound hardware. Additional AGB wave features are enabled separately. - enum mode_t { - mode_dmg, // Game Boy monochrome - mode_cgb, // Game Boy Color - mode_agb // Game Boy Advance - }; - void reset( mode_t mode = mode_cgb, bool agb_wave = false ); + // Resets hardware to initial power on state BEFORE boot ROM runs. Mode selects + // sound hardware. Additional AGB wave features are enabled separately. + enum mode_t { + mode_dmg, // Game Boy monochrome + mode_cgb, // Game Boy Color + mode_agb // Game Boy Advance + }; + void reset(mode_t mode = mode_cgb, bool agb_wave = false); - // Reads and writes must be within the start_addr to end_addr range, inclusive. - // Addresses outside this range are not mapped to the sound hardware. - enum { start_addr = 0xFF10 }; - enum { end_addr = 0xFF3F }; - enum { register_count = end_addr - start_addr + 1 }; + // Reads and writes must be within the start_addr to end_addr range, inclusive. + // Addresses outside this range are not mapped to the sound hardware. + enum { start_addr = 0xFF10 }; + enum { end_addr = 0xFF3F }; + enum { register_count = end_addr - start_addr + 1 }; - // Times are specified as the number of clocks since the beginning of the - // current time frame. + // Times are specified as the number of clocks since the beginning of the + // current time frame. - // Emulates CPU write of data to addr at specified time. - void write_register( blip_time_t time, unsigned addr, int data ); + // Emulates CPU write of data to addr at specified time. + void write_register(blip_time_t time, unsigned addr, int data); - // Emulates CPU read from addr at specified time. - int read_register( blip_time_t time, unsigned addr ); + // Emulates CPU read from addr at specified time. + int read_register(blip_time_t time, unsigned addr); - // Emulates sound hardware up to specified time, ends current time frame, then - // starts a new frame at time 0. - void end_frame( blip_time_t frame_length ); + // Emulates sound hardware up to specified time, ends current time frame, then + // starts a new frame at time 0. + void end_frame(blip_time_t frame_length); -// Sound adjustments + // Sound adjustments - // Sets overall volume, where 1.0 is normal. - void volume( double ); + // Sets overall volume, where 1.0 is normal. + void volume(double); - // If true, reduces clicking by disabling DAC biasing. Note that this reduces - // emulation accuracy, since the clicks are authentic. - void reduce_clicks( bool reduce = true ); + // If true, reduces clicking by disabling DAC biasing. Note that this reduces + // emulation accuracy, since the clicks are authentic. + void reduce_clicks(bool reduce = true); - // Sets treble equalization. - void treble_eq( blip_eq_t const& ); + // Sets treble equalization. + void treble_eq(blip_eq_t const &); - // Treble and bass values for various hardware. - enum { - speaker_treble = -47, // speaker on system - speaker_bass = 2000, - dmg_treble = 0, // headphones on each system - dmg_bass = 30, - cgb_treble = 0, - cgb_bass = 300, // CGB has much less bass - agb_treble = 0, - agb_bass = 30 - }; + // Treble and bass values for various hardware. + enum { speaker_treble = -47, // speaker on system + speaker_bass = 2000, + dmg_treble = 0, // headphones on each system + dmg_bass = 30, + cgb_treble = 0, + cgb_bass = 300, // CGB has much less bass + agb_treble = 0, + agb_bass = 30 }; - // Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the - // tempo in a game music player. - void set_tempo( double ); + // Sets frame sequencer rate, where 1.0 is normal. Meant for adjusting the + // tempo in a game music player. + void set_tempo(double); -// Save states + // Save states - // Saves full emulation state to state_out. Data format is portable and - // includes some extra space to avoid expansion in case more state needs - // to be stored in the future. - void save_state( gb_apu_state_t* state_out ); + // Saves full emulation state to state_out. Data format is portable and + // includes some extra space to avoid expansion in case more state needs + // to be stored in the future. + void save_state(gb_apu_state_t *state_out); - // Loads state. You should call reset() BEFORE this. - blargg_err_t load_state( gb_apu_state_t const& in ); + // Loads state. You should call reset() BEFORE this. + blargg_err_t load_state(gb_apu_state_t const &in); -public: - Gb_Apu(); + public: + Gb_Apu(); - // Use set_output() in place of these - BLARGG_DEPRECATED void output ( Blip_Buffer* c ) { set_output( c, c, c ); } - BLARGG_DEPRECATED void output ( Blip_Buffer* c, Blip_Buffer* l, Blip_Buffer* r ) { set_output( c, l, r ); } - BLARGG_DEPRECATED void osc_output( int i, Blip_Buffer* c ) { set_output( c, c, c, i ); } - BLARGG_DEPRECATED void osc_output( int i, Blip_Buffer* c, Blip_Buffer* l, Blip_Buffer* r ) { set_output( c, l, r, i ); } + // Use set_output() in place of these + BLARGG_DEPRECATED void output(Blip_Buffer *c) + { + set_output(c, c, c); + } + BLARGG_DEPRECATED void output(Blip_Buffer *c, Blip_Buffer *l, Blip_Buffer *r) + { + set_output(c, l, r); + } + BLARGG_DEPRECATED void osc_output(int i, Blip_Buffer *c) + { + set_output(c, c, c, i); + } + BLARGG_DEPRECATED void osc_output(int i, Blip_Buffer *c, Blip_Buffer *l, Blip_Buffer *r) + { + set_output(c, l, r, i); + } -private: - // noncopyable - Gb_Apu( const Gb_Apu& ); - Gb_Apu& operator = ( const Gb_Apu& ); + private: + // noncopyable + Gb_Apu(const Gb_Apu &); + Gb_Apu &operator=(const Gb_Apu &); - Gb_Osc* oscs [osc_count]; - blip_time_t last_time; // time sound emulator has been run to - blip_time_t frame_period; // clocks between each frame sequencer step - double volume_; - bool reduce_clicks_; + Gb_Osc *oscs[osc_count]; + blip_time_t last_time; // time sound emulator has been run to + blip_time_t frame_period; // clocks between each frame sequencer step + double volume_; + bool reduce_clicks_; - Gb_Sweep_Square square1; - Gb_Square square2; - Gb_Wave wave; - Gb_Noise noise; - blip_time_t frame_time; // time of next frame sequencer action - int frame_phase; // phase of next frame sequencer step - enum { regs_size = register_count + 0x10 }; - BOOST::uint8_t regs [regs_size];// last values written to registers + Gb_Sweep_Square square1; + Gb_Square square2; + Gb_Wave wave; + Gb_Noise noise; + blip_time_t frame_time; // time of next frame sequencer action + int frame_phase; // phase of next frame sequencer step + enum { regs_size = register_count + 0x10 }; + BOOST::uint8_t regs[regs_size]; // last values written to registers - // large objects after everything else - Gb_Osc::Good_Synth good_synth; - Gb_Osc::Med_Synth med_synth; + // large objects after everything else + Gb_Osc::Good_Synth good_synth; + Gb_Osc::Med_Synth med_synth; - void reset_lengths(); - void reset_regs(); - int calc_output( int osc ) const; - void apply_stereo(); - void apply_volume(); - void synth_volume( int ); - void run_until_( blip_time_t ); - void run_until( blip_time_t ); - void silence_osc( Gb_Osc& ); - void write_osc( int index, int reg, int old_data, int data ); - const char* save_load( gb_apu_state_t*, bool save ); - void save_load2( gb_apu_state_t*, bool save ); - friend class Gb_Apu_Tester; + void reset_lengths(); + void reset_regs(); + int calc_output(int osc) const; + void apply_stereo(); + void apply_volume(); + void synth_volume(int); + void run_until_(blip_time_t); + void run_until(blip_time_t); + void silence_osc(Gb_Osc &); + void write_osc(int index, int reg, int old_data, int data); + const char *save_load(gb_apu_state_t *, bool save); + void save_load2(gb_apu_state_t *, bool save); + friend class Gb_Apu_Tester; }; // Format of save state. Should be stable across versions of the library, // with earlier versions properly opening later save states. Includes some // room for expansion so the state size shouldn't increase. -struct gb_apu_state_t -{ +struct gb_apu_state_t { #if GB_APU_CUSTOM_STATE - // Values stored as plain int so your code can read/write them easily. - // Structure can NOT be written to disk, since format is not portable. - typedef int val_t; + // Values stored as plain int so your code can read/write them easily. + // Structure can NOT be written to disk, since format is not portable. + typedef int val_t; #else - // Values written in portable little-endian format, allowing structure - // to be written directly to disk. - typedef unsigned char val_t [4]; + // Values written in portable little-endian format, allowing structure + // to be written directly to disk. + typedef unsigned char val_t[4]; #endif - enum { format0 = 0x50414247 }; + enum { format0 = 0x50414247 }; - val_t format; // format of all following data - val_t version; // later versions just add fields to end + val_t format; // format of all following data + val_t version; // later versions just add fields to end - unsigned char regs [0x40]; - val_t frame_time; - val_t frame_phase; + unsigned char regs[0x40]; + val_t frame_time; + val_t frame_phase; - val_t sweep_freq; - val_t sweep_delay; - val_t sweep_enabled; - val_t sweep_neg; - val_t noise_divider; - val_t wave_buf; + val_t sweep_freq; + val_t sweep_delay; + val_t sweep_enabled; + val_t sweep_neg; + val_t noise_divider; + val_t wave_buf; - val_t delay [4]; - val_t length_ctr [4]; - val_t phase [4]; - val_t enabled [4]; + val_t delay[4]; + val_t length_ctr[4]; + val_t phase[4]; + val_t enabled[4]; - val_t env_delay [3]; - val_t env_volume [3]; - val_t env_enabled [3]; + val_t env_delay[3]; + val_t env_volume[3]; + val_t env_enabled[3]; - val_t unused [13]; // for future expansion + val_t unused[13]; // for future expansion }; #endif diff --git a/src/apu/Gb_Oscs.h b/src/apu/Gb_Oscs.h index 52459bea..3cf3812a 100644 --- a/src/apu/Gb_Oscs.h +++ b/src/apu/Gb_Oscs.h @@ -4,188 +4,228 @@ #ifndef GB_OSCS_H #define GB_OSCS_H -#include "blargg_common.h" #include "Blip_Buffer.h" +#include "blargg_common.h" #ifndef GB_APU_OVERCLOCK - #define GB_APU_OVERCLOCK 1 +#define GB_APU_OVERCLOCK 1 #endif #if GB_APU_OVERCLOCK & (GB_APU_OVERCLOCK - 1) - #error "GB_APU_OVERCLOCK must be a power of 2" +#error "GB_APU_OVERCLOCK must be a power of 2" #endif -class Gb_Osc { -protected: - - // 11-bit frequency in NRx3 and NRx4 - int frequency() const { return (regs [4] & 7) * 0x100 + regs [3]; } - - void update_amp( blip_time_t, int new_amp ); - int write_trig( int frame_phase, int max_len, int old_data ); -public: - - enum { clk_mul = GB_APU_OVERCLOCK }; - enum { dac_bias = 7 }; - - Blip_Buffer* outputs [4];// NULL, right, left, center - Blip_Buffer* output; // where to output sound - BOOST::uint8_t* regs; // osc's 5 registers - int mode; // mode_dmg, mode_cgb, mode_agb - int dac_off_amp;// amplitude when DAC is off - int last_amp; // current amplitude in Blip_Buffer - typedef Blip_Synth Good_Synth; - typedef Blip_Synth Med_Synth; - Good_Synth const* good_synth; - Med_Synth const* med_synth; - - int delay; // clocks until frequency timer expires - int length_ctr; // length counter - unsigned phase; // waveform phase (or equivalent) - bool enabled; // internal enabled flag - - void clock_length(); - void reset(); -}; - -class Gb_Env : public Gb_Osc { -public: - Gb_Env() : env_enabled(false), env_delay(0) {} - int env_delay; - int volume; - bool env_enabled; - - void clock_envelope(); - bool write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - env_delay = 0; - volume = 0; - Gb_Osc::reset(); - } -protected: - // Non-zero if DAC is enabled - int dac_enabled() const { return regs [2] & 0xF8; } -private: - void zombie_volume( int old, int data ); - int reload_env_timer(); -}; - -class Gb_Square : public Gb_Env { -public: - bool write_register( int frame_phase, int reg, int old_data, int data ); - void run( blip_time_t, blip_time_t ); - - void reset() - { - Gb_Env::reset(); - delay = 0x40000000; // TODO: something less hacky (never clocked until first trigger) - } -private: - // Frequency timer period - int period() const { return (2048 - frequency()) * (4 * clk_mul); } -}; - -class Gb_Sweep_Square : public Gb_Square { -public: - int sweep_freq; - int sweep_delay; - bool sweep_enabled; - bool sweep_neg; - - void clock_sweep(); - void write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - sweep_freq = 0; - sweep_delay = 0; - sweep_enabled = false; - sweep_neg = false; - Gb_Square::reset(); - } -private: - enum { period_mask = 0x70 }; - enum { shift_mask = 0x07 }; - - void calc_sweep( bool update ); - void reload_sweep_timer(); -}; - -class Gb_Noise : public Gb_Env { -public: - - int divider; // noise has more complex frequency divider setup - - void run( blip_time_t, blip_time_t ); - void write_register( int frame_phase, int reg, int old_data, int data ); - - void reset() - { - divider = 0; - Gb_Env::reset(); - delay = 4 * clk_mul; // TODO: remove? - } -private: - enum { period2_mask = 0x1FFFF }; - - int period2_index() const { return regs [3] >> 4; } - int period2( int base = 8 ) const { return base << period2_index(); } - unsigned lfsr_mask() const { return (regs [3] & 0x08) ? ~0x4040 : ~0x4000; } -}; - -class Gb_Wave : public Gb_Osc { -public: - int sample_buf; // last wave RAM byte read (hardware has this as well) - - void write_register( int frame_phase, int reg, int old_data, int data ); - void run( blip_time_t, blip_time_t ); - - // Reads/writes wave RAM - int read( unsigned addr ) const; - void write( unsigned addr, int data ); - - void reset() - { - sample_buf = 0; - Gb_Osc::reset(); - } - -private: - enum { bank40_mask = 0x40 }; - enum { bank_size = 32 }; - - int agb_mask; // 0xFF if AGB features enabled, 0 otherwise - BOOST::uint8_t* wave_ram; // 32 bytes (64 nybbles), stored in APU - - friend class Gb_Apu; - - // Frequency timer period - int period() const { return (2048 - frequency()) * (2 * clk_mul); } - - // Non-zero if DAC is enabled - int dac_enabled() const { return regs [0] & 0x80; } - - void corrupt_wave(); - - BOOST::uint8_t* wave_bank() const { return &wave_ram [(~regs [0] & bank40_mask) >> 2 & agb_mask]; } - - // Wave index that would be accessed, or -1 if no access would occur - int access( unsigned addr ) const; -}; - -inline int Gb_Wave::read( unsigned addr ) const +class Gb_Osc { - int index = access( addr ); - return (index < 0 ? 0xFF : wave_bank() [index]); + protected: + // 11-bit frequency in NRx3 and NRx4 + int frequency() const + { + return (regs[4] & 7) * 0x100 + regs[3]; + } + + void update_amp(blip_time_t, int new_amp); + int write_trig(int frame_phase, int max_len, int old_data); + + public: + enum { clk_mul = GB_APU_OVERCLOCK }; + enum { dac_bias = 7 }; + + Blip_Buffer *outputs[4]; // NULL, right, left, center + Blip_Buffer *output; // where to output sound + BOOST::uint8_t *regs; // osc's 5 registers + int mode; // mode_dmg, mode_cgb, mode_agb + int dac_off_amp; // amplitude when DAC is off + int last_amp; // current amplitude in Blip_Buffer + typedef Blip_Synth Good_Synth; + typedef Blip_Synth Med_Synth; + Good_Synth const *good_synth; + Med_Synth const *med_synth; + + int delay; // clocks until frequency timer expires + int length_ctr; // length counter + unsigned phase; // waveform phase (or equivalent) + bool enabled; // internal enabled flag + + void clock_length(); + void reset(); +}; + +class Gb_Env : public Gb_Osc +{ + public: + Gb_Env() : env_enabled(false), env_delay(0) + { + } + int env_delay; + int volume; + bool env_enabled; + + void clock_envelope(); + bool write_register(int frame_phase, int reg, int old_data, int data); + + void reset() + { + env_delay = 0; + volume = 0; + Gb_Osc::reset(); + } + + protected: + // Non-zero if DAC is enabled + int dac_enabled() const + { + return regs[2] & 0xF8; + } + + private: + void zombie_volume(int old, int data); + int reload_env_timer(); +}; + +class Gb_Square : public Gb_Env +{ + public: + bool write_register(int frame_phase, int reg, int old_data, int data); + void run(blip_time_t, blip_time_t); + + void reset() + { + Gb_Env::reset(); + delay = 0x40000000; // TODO: something less hacky (never clocked until first + // trigger) + } + + private: + // Frequency timer period + int period() const + { + return (2048 - frequency()) * (4 * clk_mul); + } +}; + +class Gb_Sweep_Square : public Gb_Square +{ + public: + int sweep_freq; + int sweep_delay; + bool sweep_enabled; + bool sweep_neg; + + void clock_sweep(); + void write_register(int frame_phase, int reg, int old_data, int data); + + void reset() + { + sweep_freq = 0; + sweep_delay = 0; + sweep_enabled = false; + sweep_neg = false; + Gb_Square::reset(); + } + + private: + enum { period_mask = 0x70 }; + enum { shift_mask = 0x07 }; + + void calc_sweep(bool update); + void reload_sweep_timer(); +}; + +class Gb_Noise : public Gb_Env +{ + public: + int divider; // noise has more complex frequency divider setup + + void run(blip_time_t, blip_time_t); + void write_register(int frame_phase, int reg, int old_data, int data); + + void reset() + { + divider = 0; + Gb_Env::reset(); + delay = 4 * clk_mul; // TODO: remove? + } + + private: + enum { period2_mask = 0x1FFFF }; + + int period2_index() const + { + return regs[3] >> 4; + } + int period2(int base = 8) const + { + return base << period2_index(); + } + unsigned lfsr_mask() const + { + return (regs[3] & 0x08) ? ~0x4040 : ~0x4000; + } +}; + +class Gb_Wave : public Gb_Osc +{ + public: + int sample_buf; // last wave RAM byte read (hardware has this as well) + + void write_register(int frame_phase, int reg, int old_data, int data); + void run(blip_time_t, blip_time_t); + + // Reads/writes wave RAM + int read(unsigned addr) const; + void write(unsigned addr, int data); + + void reset() + { + sample_buf = 0; + Gb_Osc::reset(); + } + + private: + enum { bank40_mask = 0x40 }; + enum { bank_size = 32 }; + + int agb_mask; // 0xFF if AGB features enabled, 0 otherwise + BOOST::uint8_t *wave_ram; // 32 bytes (64 nybbles), stored in APU + + friend class Gb_Apu; + + // Frequency timer period + int period() const + { + return (2048 - frequency()) * (2 * clk_mul); + } + + // Non-zero if DAC is enabled + int dac_enabled() const + { + return regs[0] & 0x80; + } + + void corrupt_wave(); + + BOOST::uint8_t *wave_bank() const + { + return &wave_ram[(~regs[0] & bank40_mask) >> 2 & agb_mask]; + } + + // Wave index that would be accessed, or -1 if no access would occur + int access(unsigned addr) const; +}; + +inline int Gb_Wave::read(unsigned addr) const +{ + int index = access(addr); + return (index < 0 ? 0xFF : wave_bank()[index]); } -inline void Gb_Wave::write( unsigned addr, int data ) +inline void Gb_Wave::write(unsigned addr, int data) { - int index = access( addr ); - if ( index >= 0 ) - wave_bank() [index] = data;; + int index = access(addr); + if (index >= 0) + wave_bank()[index] = data; + ; } #endif diff --git a/src/apu/Multi_Buffer.h b/src/apu/Multi_Buffer.h index d22075d0..ec8f7970 100644 --- a/src/apu/Multi_Buffer.h +++ b/src/apu/Multi_Buffer.h @@ -4,202 +4,296 @@ #ifndef MULTI_BUFFER_H #define MULTI_BUFFER_H -#include "blargg_common.h" #include "Blip_Buffer.h" +#include "blargg_common.h" // Interface to one or more Blip_Buffers mapped to one or more channels // consisting of left, center, and right buffers. -class Multi_Buffer { -public: - Multi_Buffer( int samples_per_frame ); - virtual ~Multi_Buffer() { } +class Multi_Buffer +{ + public: + Multi_Buffer(int samples_per_frame); + virtual ~Multi_Buffer() + { + } - // Sets the number of channels available and optionally their types - // (type information used by Effects_Buffer) - enum { type_index_mask = 0xFF }; - enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; - virtual blargg_err_t set_channel_count( int, int const* types = 0 ); - int channel_count() const { return channel_count_; } + // Sets the number of channels available and optionally their types + // (type information used by Effects_Buffer) + enum { type_index_mask = 0xFF }; + enum { wave_type = 0x100, noise_type = 0x200, mixed_type = wave_type | noise_type }; + virtual blargg_err_t set_channel_count(int, int const *types = 0); + int channel_count() const + { + return channel_count_; + } - // Gets indexed channel, from 0 to channel count - 1 - struct channel_t { - Blip_Buffer* center; - Blip_Buffer* left; - Blip_Buffer* right; - }; - virtual channel_t channel( int index ) BLARGG_PURE( ; ) + // Gets indexed channel, from 0 to channel count - 1 + struct channel_t { + Blip_Buffer *center; + Blip_Buffer *left; + Blip_Buffer *right; + }; + virtual channel_t channel(int index) BLARGG_PURE(;) - // See Blip_Buffer.h - virtual blargg_err_t set_sample_rate( long rate, int msec = blip_default_length ) BLARGG_PURE( ; ) - virtual void clock_rate( long ) BLARGG_PURE( { } ) - virtual void bass_freq( int ) BLARGG_PURE( { } ) - virtual void clear() BLARGG_PURE( { } ) - long sample_rate() const; + // See Blip_Buffer.h + virtual blargg_err_t set_sample_rate(long rate, int msec = blip_default_length) + BLARGG_PURE(;) virtual void clock_rate(long) + BLARGG_PURE({}) virtual void bass_freq(int) BLARGG_PURE({}) virtual void clear() + BLARGG_PURE({}) long sample_rate() const; - // Length of buffer, in milliseconds - int length() const; + // Length of buffer, in milliseconds + int length() const; - // See Blip_Buffer.h - virtual void end_frame( blip_time_t ) BLARGG_PURE( { } ) + // See Blip_Buffer.h + virtual void end_frame(blip_time_t) BLARGG_PURE({}) - // Number of samples per output frame (1 = mono, 2 = stereo) - int samples_per_frame() const; + // Number of samples per output frame (1 = mono, 2 = stereo) + int samples_per_frame() const; - // Count of changes to channel configuration. Incremented whenever - // a change is made to any of the Blip_Buffers for any channel. - unsigned channels_changed_count() { return channels_changed_count_; } + // Count of changes to channel configuration. Incremented whenever + // a change is made to any of the Blip_Buffers for any channel. + unsigned channels_changed_count() + { + return channels_changed_count_; + } - // See Blip_Buffer.h - virtual long read_samples( blip_sample_t*, long ) BLARGG_PURE( { return 0; } ) - virtual long samples_avail() const BLARGG_PURE( { return 0; } ) + // See Blip_Buffer.h + virtual long read_samples(blip_sample_t *, long) + BLARGG_PURE({ return 0; }) virtual long samples_avail() const BLARGG_PURE({ return 0; }) -public: - BLARGG_DISABLE_NOTHROW - void disable_immediate_removal() { immediate_removal_ = false; } -protected: - bool immediate_removal() const { return immediate_removal_; } - int const* channel_types() const { return channel_types_; } - void channels_changed() { channels_changed_count_++; } -private: - // noncopyable - Multi_Buffer( const Multi_Buffer& ); - Multi_Buffer& operator = ( const Multi_Buffer& ); + public : BLARGG_DISABLE_NOTHROW void disable_immediate_removal() + { + immediate_removal_ = false; + } - unsigned channels_changed_count_; - long sample_rate_; - int length_; - int channel_count_; - int const samples_per_frame_; - int const* channel_types_; - bool immediate_removal_; + protected: + bool immediate_removal() const + { + return immediate_removal_; + } + int const *channel_types() const + { + return channel_types_; + } + void channels_changed() + { + channels_changed_count_++; + } + + private: + // noncopyable + Multi_Buffer(const Multi_Buffer &); + Multi_Buffer &operator=(const Multi_Buffer &); + + unsigned channels_changed_count_; + long sample_rate_; + int length_; + int channel_count_; + int const samples_per_frame_; + int const *channel_types_; + bool immediate_removal_; }; // Uses a single buffer and outputs mono samples. -class Mono_Buffer : public Multi_Buffer { - Blip_Buffer buf; - channel_t chan; -public: - // Buffer used for all channels - Blip_Buffer* center() { return &buf; } +class Mono_Buffer : public Multi_Buffer +{ + Blip_Buffer buf; + channel_t chan; -public: - Mono_Buffer(); - ~Mono_Buffer(); - blargg_err_t set_sample_rate( long rate, int msec = blip_default_length ); - void clock_rate( long rate ) { buf.clock_rate( rate ); } - void bass_freq( int freq ) { buf.bass_freq( freq ); } - void clear() { buf.clear(); } - long samples_avail() const { return buf.samples_avail(); } - long read_samples( blip_sample_t* p, long s ) { return buf.read_samples( p, s ); } - channel_t channel( int ) { return chan; } - void end_frame( blip_time_t t ) { buf.end_frame( t ); } + public: + // Buffer used for all channels + Blip_Buffer *center() + { + return &buf; + } + + public: + Mono_Buffer(); + ~Mono_Buffer(); + blargg_err_t set_sample_rate(long rate, int msec = blip_default_length); + void clock_rate(long rate) + { + buf.clock_rate(rate); + } + void bass_freq(int freq) + { + buf.bass_freq(freq); + } + void clear() + { + buf.clear(); + } + long samples_avail() const + { + return buf.samples_avail(); + } + long read_samples(blip_sample_t *p, long s) + { + return buf.read_samples(p, s); + } + channel_t channel(int) + { + return chan; + } + void end_frame(blip_time_t t) + { + buf.end_frame(t); + } }; - class Tracked_Blip_Buffer : public Blip_Buffer { - public: - // Non-zero if buffer still has non-silent samples in it. Requires that you call - // set_modified() appropriately. - blip_ulong non_silent() const; +class Tracked_Blip_Buffer : public Blip_Buffer +{ + public: + // Non-zero if buffer still has non-silent samples in it. Requires that you call + // set_modified() appropriately. + blip_ulong non_silent() const; - // remove_samples( samples_avail() ) - void remove_all_samples(); + // remove_samples( samples_avail() ) + void remove_all_samples(); - public: - BLARGG_DISABLE_NOTHROW + public: + BLARGG_DISABLE_NOTHROW - long read_samples( blip_sample_t*, long ); - void remove_silence( long ); - void remove_samples( long ); - Tracked_Blip_Buffer(); - void clear(); - void end_frame( blip_time_t ); - private: - blip_long last_non_silence; - void remove_( long ); - }; + long read_samples(blip_sample_t *, long); + void remove_silence(long); + void remove_samples(long); + Tracked_Blip_Buffer(); + void clear(); + void end_frame(blip_time_t); - class Stereo_Mixer { - public: - Tracked_Blip_Buffer* bufs [3]; - blargg_long samples_read; + private: + blip_long last_non_silence; + void remove_(long); +}; - Stereo_Mixer() : samples_read( 0 ) { } - void read_pairs( blip_sample_t* out, int count ); - private: - void mix_mono ( blip_sample_t* out, int pair_count ); - void mix_stereo( blip_sample_t* out, int pair_count ); - }; +class Stereo_Mixer +{ + public: + Tracked_Blip_Buffer *bufs[3]; + blargg_long samples_read; + + Stereo_Mixer() : samples_read(0) + { + } + void read_pairs(blip_sample_t *out, int count); + + private: + void mix_mono(blip_sample_t *out, int pair_count); + void mix_stereo(blip_sample_t *out, int pair_count); +}; // Uses three buffers (one for center) and outputs stereo sample pairs. -class Stereo_Buffer : public Multi_Buffer { -public: +class Stereo_Buffer : public Multi_Buffer +{ + public: + // Buffers used for all channels + Blip_Buffer *center() + { + return &bufs[2]; + } + Blip_Buffer *left() + { + return &bufs[0]; + } + Blip_Buffer *right() + { + return &bufs[1]; + } - // Buffers used for all channels - Blip_Buffer* center() { return &bufs [2]; } - Blip_Buffer* left() { return &bufs [0]; } - Blip_Buffer* right() { return &bufs [1]; } + public: + Stereo_Buffer(); + ~Stereo_Buffer(); + blargg_err_t set_sample_rate(long, int msec = blip_default_length); + void clock_rate(long); + void bass_freq(int); + void clear(); + channel_t channel(int) + { + return chan; + } + void end_frame(blip_time_t); -public: - Stereo_Buffer(); - ~Stereo_Buffer(); - blargg_err_t set_sample_rate( long, int msec = blip_default_length ); - void clock_rate( long ); - void bass_freq( int ); - void clear(); - channel_t channel( int ) { return chan; } - void end_frame( blip_time_t ); + long samples_avail() const + { + return (bufs[0].samples_avail() - mixer.samples_read) * 2; + } + long read_samples(blip_sample_t *, long); - long samples_avail() const { return (bufs [0].samples_avail() - mixer.samples_read) * 2; } - long read_samples( blip_sample_t*, long ); - -private: - enum { bufs_size = 3 }; - typedef Tracked_Blip_Buffer buf_t; - buf_t bufs [bufs_size]; - Stereo_Mixer mixer; - channel_t chan; - long samples_avail_; + private: + enum { bufs_size = 3 }; + typedef Tracked_Blip_Buffer buf_t; + buf_t bufs[bufs_size]; + Stereo_Mixer mixer; + channel_t chan; + long samples_avail_; }; // Silent_Buffer generates no samples, useful where no sound is wanted -class Silent_Buffer : public Multi_Buffer { - channel_t chan; -public: - Silent_Buffer(); - blargg_err_t set_sample_rate( long rate, int msec = blip_default_length ); - void clock_rate( long ) { } - void bass_freq( int ) { } - void clear() { } - channel_t channel( int ) { return chan; } - void end_frame( blip_time_t ) { } - long samples_avail() const { return 0; } - long read_samples( blip_sample_t*, long ) { return 0; } +class Silent_Buffer : public Multi_Buffer +{ + channel_t chan; + + public: + Silent_Buffer(); + blargg_err_t set_sample_rate(long rate, int msec = blip_default_length); + void clock_rate(long) + { + } + void bass_freq(int) + { + } + void clear() + { + } + channel_t channel(int) + { + return chan; + } + void end_frame(blip_time_t) + { + } + long samples_avail() const + { + return 0; + } + long read_samples(blip_sample_t *, long) + { + return 0; + } }; - -inline blargg_err_t Multi_Buffer::set_sample_rate( long rate, int msec ) +inline blargg_err_t Multi_Buffer::set_sample_rate(long rate, int msec) { - sample_rate_ = rate; - length_ = msec; - return 0; + sample_rate_ = rate; + length_ = msec; + return 0; } -inline blargg_err_t Silent_Buffer::set_sample_rate( long rate, int msec ) +inline blargg_err_t Silent_Buffer::set_sample_rate(long rate, int msec) { - return Multi_Buffer::set_sample_rate( rate, msec ); + return Multi_Buffer::set_sample_rate(rate, msec); } -inline int Multi_Buffer::samples_per_frame() const { return samples_per_frame_; } - -inline long Multi_Buffer::sample_rate() const { return sample_rate_; } - -inline int Multi_Buffer::length() const { return length_; } - -inline blargg_err_t Multi_Buffer::set_channel_count( int n, int const* types ) +inline int Multi_Buffer::samples_per_frame() const { - channel_count_ = n; - channel_types_ = types; - return 0; + return samples_per_frame_; +} + +inline long Multi_Buffer::sample_rate() const +{ + return sample_rate_; +} + +inline int Multi_Buffer::length() const +{ + return length_; +} + +inline blargg_err_t Multi_Buffer::set_channel_count(int n, int const *types) +{ + channel_count_ = n; + channel_types_ = types; + return 0; } #endif diff --git a/src/apu/blargg_common.h b/src/apu/blargg_common.h index 1203d387..5335bb28 100644 --- a/src/apu/blargg_common.h +++ b/src/apu/blargg_common.h @@ -5,10 +5,10 @@ #ifndef BLARGG_COMMON_H #define BLARGG_COMMON_H -#include -#include #include #include +#include +#include #undef BLARGG_COMMON_H // allow blargg_config.h to #include blargg_common.h @@ -18,188 +18,212 @@ // BLARGG_RESTRICT: equivalent to restrict, where supported #if __GNUC__ >= 3 || _MSC_VER >= 1100 - #define BLARGG_RESTRICT __restrict +#define BLARGG_RESTRICT __restrict #else - #define BLARGG_RESTRICT +#define BLARGG_RESTRICT #endif // STATIC_CAST(T,expr): Used in place of static_cast (expr) // CONST_CAST( T,expr): Used in place of const_cast (expr) #ifndef STATIC_CAST - #if __GNUC__ >= 4 - #define STATIC_CAST(T,expr) static_cast (expr) - #define CONST_CAST( T,expr) const_cast (expr) - #else - #define STATIC_CAST(T,expr) ((T) (expr)) - #define CONST_CAST( T,expr) ((T) (expr)) - #endif +#if __GNUC__ >= 4 +#define STATIC_CAST(T, expr) static_cast(expr) +#define CONST_CAST(T, expr) const_cast(expr) +#else +#define STATIC_CAST(T, expr) ((T)(expr)) +#define CONST_CAST(T, expr) ((T)(expr)) +#endif #endif // blargg_err_t (0 on success, otherwise error string) #ifndef blargg_err_t - typedef const char* blargg_err_t; +typedef const char *blargg_err_t; #endif // blargg_vector - very lightweight vector of POD types (no constructor/destructor) -template -class blargg_vector { - T* begin_; - size_t size_; -public: - blargg_vector() : begin_( 0 ), size_( 0 ) { } - ~blargg_vector() { free( begin_ ); } - size_t size() const { return size_; } - T* begin() const { return begin_; } - T* end() const { return begin_ + size_; } - blargg_err_t resize( size_t n ) - { - // TODO: blargg_common.cpp to hold this as an outline function, ugh - void* p = realloc( begin_, n * sizeof (T) ); - if ( p ) - begin_ = (T*) p; - else if ( n > size_ ) // realloc failure only a problem if expanding - return "Out of memory"; - size_ = n; - return 0; - } - void clear() { void* p = begin_; begin_ = 0; size_ = 0; free( p ); } - T& operator [] ( size_t n ) const - { - assert( n <= size_ ); // <= to allow past-the-end value - return begin_ [n]; - } +template class blargg_vector +{ + T *begin_; + size_t size_; + + public: + blargg_vector() : begin_(0), size_(0) + { + } + ~blargg_vector() + { + free(begin_); + } + size_t size() const + { + return size_; + } + T *begin() const + { + return begin_; + } + T *end() const + { + return begin_ + size_; + } + blargg_err_t resize(size_t n) + { + // TODO: blargg_common.cpp to hold this as an outline function, ugh + void *p = realloc(begin_, n * sizeof(T)); + if (p) + begin_ = (T *)p; + else if (n > size_) // realloc failure only a problem if expanding + return "Out of memory"; + size_ = n; + return 0; + } + void clear() + { + void *p = begin_; + begin_ = 0; + size_ = 0; + free(p); + } + T &operator[](size_t n) const + { + assert(n <= size_); // <= to allow past-the-end value + return begin_[n]; + } }; #ifndef BLARGG_DISABLE_NOTHROW - // throw spec mandatory in ISO C++ if operator new can return NULL - #if __cplusplus >= 199711 || __GNUC__ >= 3 - #define BLARGG_THROWS( spec ) throw spec - #else - #define BLARGG_THROWS( spec ) - #endif - #define BLARGG_DISABLE_NOTHROW \ - void* operator new ( size_t s ) BLARGG_THROWS(()) { return malloc( s ); }\ - void operator delete ( void* p ) { free( p ); } - #define BLARGG_NEW new +// throw spec mandatory in ISO C++ if operator new can return NULL +#if __cplusplus >= 199711 || __GNUC__ >= 3 +#define BLARGG_THROWS(spec) throw spec #else - #include - #define BLARGG_NEW new (std::nothrow) +#define BLARGG_THROWS(spec) +#endif +#define BLARGG_DISABLE_NOTHROW \ + void *operator new(size_t s) BLARGG_THROWS(()) \ + { \ + return malloc(s); \ + } \ + void operator delete(void *p) \ + { \ + free(p); \ + } +#define BLARGG_NEW new +#else +#include +#define BLARGG_NEW new (std::nothrow) #endif // BLARGG_4CHAR('a','b','c','d') = 'abcd' (four character integer constant) -#define BLARGG_4CHAR( a, b, c, d ) \ - ((a&0xFF)*0x1000000 + (b&0xFF)*0x10000 + (c&0xFF)*0x100 + (d&0xFF)) +#define BLARGG_4CHAR(a, b, c, d) \ + ((a & 0xFF) * 0x1000000 + (b & 0xFF) * 0x10000 + (c & 0xFF) * 0x100 + (d & 0xFF)) // BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0. #ifndef BOOST_STATIC_ASSERT - #ifdef _MSC_VER - // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] ) - #else - // Some other compilers fail when declaring same function multiple times in class, - // so differentiate them by line - #define BOOST_STATIC_ASSERT( expr ) \ - void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] ) - #endif +#ifdef _MSC_VER +// MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified +#define BOOST_STATIC_ASSERT(expr) void blargg_failed_(int(*arg)[2 / (int)!!(expr)-1]) +#else +// Some other compilers fail when declaring same function multiple times in class, +// so differentiate them by line +#define BOOST_STATIC_ASSERT(expr) void blargg_failed_(int(*arg)[2 / !!(expr)-1][__LINE__]) +#endif #endif // BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1, // compiler is assumed to support bool. If undefined, availability is determined. #ifndef BLARGG_COMPILER_HAS_BOOL - #if defined (__MWERKS__) - #if !__option(bool) - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (_MSC_VER) - #if _MSC_VER < 1100 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif - #elif defined (__GNUC__) - // supports bool - #elif __cplusplus < 199711 - #define BLARGG_COMPILER_HAS_BOOL 0 - #endif +#if defined(__MWERKS__) +#if !__option(bool) +#define BLARGG_COMPILER_HAS_BOOL 0 #endif -#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL - // If you get errors here, modify your blargg_config.h file - typedef int bool; - const bool true = 1; - const bool false = 0; +#elif defined(_MSC_VER) +#if _MSC_VER < 1100 +#define BLARGG_COMPILER_HAS_BOOL 0 +#endif +#elif defined(__GNUC__) +// supports bool +#elif __cplusplus < 199711 +#define BLARGG_COMPILER_HAS_BOOL 0 +#endif +#endif +#if defined(BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL +// If you get errors here, modify your blargg_config.h file +typedef int bool; +const bool true = 1; +const bool false = 0; #endif // blargg_long/blargg_ulong = at least 32 bits, int if it's big enough #if INT_MAX < 0x7FFFFFFF || LONG_MAX == 0x7FFFFFFF - typedef long blargg_long; +typedef long blargg_long; #else - typedef int blargg_long; +typedef int blargg_long; #endif #if UINT_MAX < 0xFFFFFFFF || ULONG_MAX == 0xFFFFFFFF - typedef unsigned long blargg_ulong; +typedef unsigned long blargg_ulong; #else - typedef unsigned blargg_ulong; +typedef unsigned blargg_ulong; #endif // BOOST::int8_t etc. // HAVE_STDINT_H: If defined, use for int8_t etc. -#if defined (HAVE_STDINT_H) - #include - #define BOOST +#if defined(HAVE_STDINT_H) +#include +#define BOOST // HAVE_INTTYPES_H: If defined, use for int8_t etc. -#elif defined (HAVE_INTTYPES_H) - #include - #define BOOST +#elif defined(HAVE_INTTYPES_H) +#include +#define BOOST #else - struct BOOST - { - #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F - typedef signed char int8_t; - typedef unsigned char uint8_t; - #else - // No suitable 8-bit type available - typedef struct see_blargg_common_h int8_t; - typedef struct see_blargg_common_h uint8_t; - #endif +struct BOOST { +#if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F + typedef signed char int8_t; + typedef unsigned char uint8_t; +#else + // No suitable 8-bit type available + typedef struct see_blargg_common_h int8_t; + typedef struct see_blargg_common_h uint8_t; +#endif - #if USHRT_MAX == 0xFFFF - typedef short int16_t; - typedef unsigned short uint16_t; - #else - // No suitable 16-bit type available - typedef struct see_blargg_common_h int16_t; - typedef struct see_blargg_common_h uint16_t; - #endif +#if USHRT_MAX == 0xFFFF + typedef short int16_t; + typedef unsigned short uint16_t; +#else + // No suitable 16-bit type available + typedef struct see_blargg_common_h int16_t; + typedef struct see_blargg_common_h uint16_t; +#endif - #if ULONG_MAX == 0xFFFFFFFF - typedef long int32_t; - typedef unsigned long uint32_t; - #elif UINT_MAX == 0xFFFFFFFF - typedef int int32_t; - typedef unsigned int uint32_t; - #else - // No suitable 32-bit type available - typedef struct see_blargg_common_h int32_t; - typedef struct see_blargg_common_h uint32_t; - #endif - }; +#if ULONG_MAX == 0xFFFFFFFF + typedef long int32_t; + typedef unsigned long uint32_t; +#elif UINT_MAX == 0xFFFFFFFF + typedef int int32_t; + typedef unsigned int uint32_t; +#else + // No suitable 32-bit type available + typedef struct see_blargg_common_h int32_t; + typedef struct see_blargg_common_h uint32_t; +#endif +}; #endif #if __GNUC__ >= 3 - #define BLARGG_DEPRECATED __attribute__ ((deprecated)) +#define BLARGG_DEPRECATED __attribute__((deprecated)) #else - #define BLARGG_DEPRECATED +#define BLARGG_DEPRECATED #endif // Use in place of "= 0;" for a pure virtual, since these cause calls to std C++ lib. // During development, BLARGG_PURE( x ) expands to = 0; // virtual int func() BLARGG_PURE( { return 0; } ) #ifndef BLARGG_PURE - #define BLARGG_PURE( def ) def +#define BLARGG_PURE(def) def #endif #endif diff --git a/src/apu/blargg_config.h b/src/apu/blargg_config.h index 961e0453..11da34af 100644 --- a/src/apu/blargg_config.h +++ b/src/apu/blargg_config.h @@ -27,7 +27,7 @@ // Use standard config.h if present #ifdef HAVE_CONFIG_H - #include "config.h" +#include "config.h" #endif #endif diff --git a/src/apu/blargg_source.h b/src/apu/blargg_source.h index ddef37d6..4c205ebe 100644 --- a/src/apu/blargg_source.h +++ b/src/apu/blargg_source.h @@ -24,60 +24,78 @@ unprefixed names. */ // of the module. A failed requirement probably indicates a bug in YOUR code. // // void require( bool expr ); -#undef require -#define require( expr ) assert( expr ) +#undef require +#define require(expr) assert(expr) // Like printf() except output goes to debugging console/file. // // void dprintf( const char* format, ... ); -static inline void blargg_dprintf_( const char*, ... ) { } -#undef dprintf -#define dprintf (1) ? (void) 0 : blargg_dprintf_ +static inline void blargg_dprintf_(const char *, ...) +{ +} +#undef dprintf +#define dprintf (1) ? (void)0 : blargg_dprintf_ // If expr is false, prints file and line number to debug console/log, then // continues execution normally. Meant for flagging potential problems or things // that should be looked into, but that aren't serious problems. // // void check( bool expr ); -#undef check -#define check( expr ) ((void) 0) +#undef check +#define check(expr) ((void)0) // If expr yields non-NULL error string, returns it from current function, // otherwise continues normally. -#undef RETURN_ERR -#define RETURN_ERR( expr ) do { \ - blargg_err_t blargg_return_err_ = (expr); \ - if ( blargg_return_err_ ) return blargg_return_err_; \ - } while ( 0 ) +#undef RETURN_ERR +#define RETURN_ERR(expr) \ + do { \ + blargg_err_t blargg_return_err_ = (expr); \ + if (blargg_return_err_) \ + return blargg_return_err_; \ + } while (0) // If ptr is NULL, returns "Out of memory" error string, otherwise continues normally. -#undef CHECK_ALLOC -#define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) +#undef CHECK_ALLOC +#define CHECK_ALLOC(ptr) \ + do { \ + if ((ptr) == 0) \ + return "Out of memory"; \ + } while (0) // The usual min/max functions for built-in types. // // template T min( T x, T y ) { return x < y ? x : y; } // template T max( T x, T y ) { return x > y ? x : y; } -#define BLARGG_DEF_MIN_MAX( type ) \ - static inline type blargg_min( type x, type y ) { if ( y < x ) x = y; return x; }\ - static inline type blargg_max( type x, type y ) { if ( x < y ) x = y; return x; } +#define BLARGG_DEF_MIN_MAX(type) \ + static inline type blargg_min(type x, type y) \ + { \ + if (y < x) \ + x = y; \ + return x; \ + } \ + static inline type blargg_max(type x, type y) \ + { \ + if (x < y) \ + x = y; \ + return x; \ + } -BLARGG_DEF_MIN_MAX( int ) -BLARGG_DEF_MIN_MAX( unsigned ) -BLARGG_DEF_MIN_MAX( long ) -BLARGG_DEF_MIN_MAX( unsigned long ) -BLARGG_DEF_MIN_MAX( float ) -BLARGG_DEF_MIN_MAX( double ) +BLARGG_DEF_MIN_MAX(int) +BLARGG_DEF_MIN_MAX(unsigned) +BLARGG_DEF_MIN_MAX(long) +BLARGG_DEF_MIN_MAX(unsigned long) +BLARGG_DEF_MIN_MAX(float) +BLARGG_DEF_MIN_MAX(double) -#undef min +#undef min #define min blargg_min -#undef max +#undef max #define max blargg_max // typedef unsigned char byte; typedef unsigned char blargg_byte; -#undef byte +#undef byte #define byte blargg_byte // deprecated @@ -86,7 +104,7 @@ typedef unsigned char blargg_byte; // BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check #ifdef BLARGG_SOURCE_BEGIN - #include BLARGG_SOURCE_BEGIN +#include BLARGG_SOURCE_BEGIN #endif #endif diff --git a/src/common/ConfigManager.h b/src/common/ConfigManager.h index 320d6829..826a6237 100644 --- a/src/common/ConfigManager.h +++ b/src/common/ConfigManager.h @@ -2,16 +2,16 @@ #define _CONFIGMANAGER_H #pragma once -#include #include "../sdl/filters.h" +#include #ifndef __GNUC__ -# define HAVE_DECL_GETOPT 0 -# define __STDC__ 1 -# include "getopt.h" +#define HAVE_DECL_GETOPT 0 +#define __STDC__ 1 +#include "getopt.h" #else // ! __GNUC__ -# define HAVE_DECL_GETOPT 1 -# include +#define HAVE_DECL_GETOPT 1 +#include #endif // ! __GNUC__ #define MAX_CHEATS 16384 @@ -21,20 +21,20 @@ extern bool mirroringEnable; extern bool parseDebug; extern bool speedHack; extern bool speedup; -extern char* rewindMemory; -extern const char* aviRecordDir; -extern const char* biosFileNameGB; -extern const char* biosFileNameGBA; -extern const char* biosFileNameGBC; -extern const char* loadDotCodeFile; -extern const char* saveDotCodeFile; -extern const char* linkHostAddr; -extern const char* movieRecordDir; -extern const char* romDirGB; -extern const char* romDirGBA; -extern const char* romDirGBC; -extern const char* soundRecordDir; -extern int* rewindSerials; +extern char *rewindMemory; +extern const char *aviRecordDir; +extern const char *biosFileNameGB; +extern const char *biosFileNameGBA; +extern const char *biosFileNameGBC; +extern const char *loadDotCodeFile; +extern const char *saveDotCodeFile; +extern const char *linkHostAddr; +extern const char *movieRecordDir; +extern const char *romDirGB; +extern const char *romDirGBA; +extern const char *romDirGBC; +extern const char *soundRecordDir; +extern int *rewindSerials; extern int active; extern int agbPrint; extern int autoFire; @@ -100,7 +100,7 @@ extern int rewindPos; extern int rewindSaveNeeded; extern int rewindTimer; extern int rewindTopPos; -//extern int romSize; +// extern int romSize; extern int rtcEnabled; extern int saveType; extern int screenMessage; @@ -140,8 +140,7 @@ extern u32 movieNextJoypad; extern int throttle; extern int preparedCheats; -extern const char* preparedCheatCodes[MAX_CHEATS]; - +extern const char *preparedCheatCodes[MAX_CHEATS]; // allow up to 100 IPS/UPS/PPF patches given on commandline #define PATCH_MAX_NUM 100 @@ -153,11 +152,10 @@ extern int mouseCounter; extern FilterFunc filterFunction; extern IFBFilterFunc ifbFunction; - -extern char* homeDir; -extern const char* screenShotDir; -extern const char* saveDir; -extern const char* batteryDir; +extern char *homeDir; +extern const char *screenShotDir; +extern const char *saveDir; +extern const char *batteryDir; // Directory within homedir to use for default save location. #define DOT_DIR ".vbam" @@ -165,13 +163,13 @@ extern const char* batteryDir; void SetHome(char *_arg0); void SaveConfigFile(); void CloseConfig(); -u32 ReadPrefHex(const char* pref_key, int default_value); -u32 ReadPrefHex(const char* pref_key); -u32 ReadPref(const char* pref_key, int default_value); -u32 ReadPref(const char* pref_key); -const char* ReadPrefString(const char* pref_key, const char* default_value); -const char* ReadPrefString(const char* pref_key); -void LoadConfigFile(int argc, char ** argv); +u32 ReadPrefHex(const char *pref_key, int default_value); +u32 ReadPrefHex(const char *pref_key); +u32 ReadPref(const char *pref_key, int default_value); +u32 ReadPref(const char *pref_key); +const char *ReadPrefString(const char *pref_key, const char *default_value); +const char *ReadPrefString(const char *pref_key); +void LoadConfigFile(int argc, char **argv); void LoadConfig(); -int ReadOpts(int argc, char ** argv); +int ReadOpts(int argc, char **argv); #endif diff --git a/src/common/Port.h b/src/common/Port.h index 0e134a24..fbb52bb6 100644 --- a/src/common/Port.h +++ b/src/common/Port.h @@ -16,53 +16,47 @@ // swaps a 16-bit value static inline u16 swap16(u16 v) { - return (v<<8)|(v>>8); + return (v << 8) | (v >> 8); } // swaps a 32-bit value static inline u32 swap32(u32 v) { - return (v<<24)|((v<<8)&0xff0000)|((v>>8)&0xff00)|(v>>24); + return (v << 24) | ((v << 8) & 0xff0000) | ((v >> 8) & 0xff00) | (v >> 24); } #ifdef WORDS_BIGENDIAN #if defined(__GNUC__) && defined(__ppc__) -#define READ16LE(base) \ - ({ unsigned short lhbrxResult; \ - __asm__ ("lhbrx %0, 0, %1" : "=r" (lhbrxResult) : "r" (base) : "memory"); \ - lhbrxResult; }) +#define READ16LE(base) \ + ({ \ + unsigned short lhbrxResult; \ + __asm__("lhbrx %0, 0, %1" : "=r"(lhbrxResult) : "r"(base) : "memory"); \ + lhbrxResult; \ + }) -#define READ32LE(base) \ - ({ unsigned long lwbrxResult; \ - __asm__ ("lwbrx %0, 0, %1" : "=r" (lwbrxResult) : "r" (base) : "memory"); \ - lwbrxResult; }) +#define READ32LE(base) \ + ({ \ + unsigned long lwbrxResult; \ + __asm__("lwbrx %0, 0, %1" : "=r"(lwbrxResult) : "r"(base) : "memory"); \ + lwbrxResult; \ + }) -#define WRITE16LE(base, value) \ - __asm__ ("sthbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") +#define WRITE16LE(base, value) __asm__("sthbrx %0, 0, %1" : : "r"(value), "r"(base) : "memory") -#define WRITE32LE(base, value) \ - __asm__ ("stwbrx %0, 0, %1" : : "r" (value), "r" (base) : "memory") +#define WRITE32LE(base, value) __asm__("stwbrx %0, 0, %1" : : "r"(value), "r"(base) : "memory") #else -#define READ16LE(x) \ - swap16(*((u16 *)(x))) -#define READ32LE(x) \ - swap32(*((u32 *)(x))) -#define WRITE16LE(x,v) \ - *((u16 *)x) = swap16((v)) -#define WRITE32LE(x,v) \ - *((u32 *)x) = swap32((v)) +#define READ16LE(x) swap16(*((u16 *)(x))) +#define READ32LE(x) swap32(*((u32 *)(x))) +#define WRITE16LE(x, v) *((u16 *)x) = swap16((v)) +#define WRITE32LE(x, v) *((u32 *)x) = swap32((v)) #endif #else -#define READ16LE(x) \ - *((u16 *)x) -#define READ32LE(x) \ - *((u32 *)x) -#define WRITE16LE(x,v) \ - *((u16 *)x) = (v) -#define WRITE32LE(x,v) \ - *((u32 *)x) = (v) +#define READ16LE(x) *((u16 *)x) +#define READ32LE(x) *((u32 *)x) +#define WRITE16LE(x, v) *((u16 *)x) = (v) +#define WRITE32LE(x, v) *((u32 *)x) = (v) #endif #endif // PORT_H diff --git a/src/common/RingBuffer.h b/src/common/RingBuffer.h index 7228684d..455540fd 100644 --- a/src/common/RingBuffer.h +++ b/src/common/RingBuffer.h @@ -20,93 +20,100 @@ #define RINGBUFFER_H #include "array.h" -#include #include +#include #include -template -class RingBuffer { - Array buf; - std::size_t sz; - std::size_t rpos; - std::size_t wpos; +template class RingBuffer +{ + Array buf; + std::size_t sz; + std::size_t rpos; + std::size_t wpos; -public: - RingBuffer(const std::size_t sz_in = 0) : sz(0), rpos(0), wpos(0) { reset(sz_in); } + public: + RingBuffer(const std::size_t sz_in = 0) : sz(0), rpos(0), wpos(0) + { + reset(sz_in); + } - std::size_t avail() const { - return (wpos < rpos ? 0 : sz) + rpos - wpos - 1; - } + std::size_t avail() const + { + return (wpos < rpos ? 0 : sz) + rpos - wpos - 1; + } - void clear() { - wpos = rpos = 0; - } + void clear() + { + wpos = rpos = 0; + } - void fill(T value); + void fill(T value); - void read(T *out, std::size_t num); + void read(T *out, std::size_t num); - void reset(std::size_t sz_in); + void reset(std::size_t sz_in); - std::size_t size() const { - return sz - 1; - } + std::size_t size() const + { + return sz - 1; + } - std::size_t used() const { - return (wpos < rpos ? sz : 0) + wpos - rpos; - } + std::size_t used() const + { + return (wpos < rpos ? sz : 0) + wpos - rpos; + } - void write(const T *in, std::size_t num); + void write(const T *in, std::size_t num); }; -template -void RingBuffer::fill(const T value) { - std::fill(buf + 0, buf + sz, value); - rpos = 0; - wpos = sz - 1; +template void RingBuffer::fill(const T value) +{ + std::fill(buf + 0, buf + sz, value); + rpos = 0; + wpos = sz - 1; } -template -void RingBuffer::read(T *out, std::size_t num) { - if (rpos + num > sz) { - const std::size_t n = sz - rpos; +template void RingBuffer::read(T *out, std::size_t num) +{ + if (rpos + num > sz) { + const std::size_t n = sz - rpos; - std::memcpy(out, buf + rpos, n * sizeof(T)); + std::memcpy(out, buf + rpos, n * sizeof(T)); - rpos = 0; - num -= n; - out += n; - } + rpos = 0; + num -= n; + out += n; + } - std::memcpy(out, buf + rpos, num * sizeof(T)); + std::memcpy(out, buf + rpos, num * sizeof(T)); - if ((rpos += num) == sz) - rpos = 0; + if ((rpos += num) == sz) + rpos = 0; } -template -void RingBuffer::reset(const std::size_t sz_in) { - sz = sz_in + 1; - rpos = wpos = 0; - buf.reset(sz_in ? sz : 0); +template void RingBuffer::reset(const std::size_t sz_in) +{ + sz = sz_in + 1; + rpos = wpos = 0; + buf.reset(sz_in ? sz : 0); } -template -void RingBuffer::write(const T *in, std::size_t num) { - if (wpos + num > sz) { - const std::size_t n = sz - wpos; +template void RingBuffer::write(const T *in, std::size_t num) +{ + if (wpos + num > sz) { + const std::size_t n = sz - wpos; - std::memcpy(buf + wpos, in, n * sizeof(T)); + std::memcpy(buf + wpos, in, n * sizeof(T)); - wpos = 0; - num -= n; - in += n; - } + wpos = 0; + num -= n; + in += n; + } - std::memcpy(buf + wpos, in, num * sizeof(T)); + std::memcpy(buf + wpos, in, num * sizeof(T)); - if ((wpos += num) == sz) - wpos = 0; + if ((wpos += num) == sz) + wpos = 0; } #endif diff --git a/src/common/SoundDriver.h b/src/common/SoundDriver.h index f39de279..df7ec3ae 100644 --- a/src/common/SoundDriver.h +++ b/src/common/SoundDriver.h @@ -26,40 +26,39 @@ */ class SoundDriver { -public: + public: + /** + * Destructor. Free the resources allocated by the sound driver. + */ + virtual ~SoundDriver(){}; - /** - * Destructor. Free the resources allocated by the sound driver. - */ - virtual ~SoundDriver() { }; + /** + * Initialize the sound driver. + * @param sampleRate In Hertz + */ + virtual bool init(long sampleRate) = 0; - /** - * Initialize the sound driver. - * @param sampleRate In Hertz - */ - virtual bool init(long sampleRate) = 0; + /** + * Tell the driver that the sound stream has paused + */ + virtual void pause() = 0; - /** - * Tell the driver that the sound stream has paused - */ - virtual void pause() = 0; + /** + * Reset the sound driver + */ + virtual void reset() = 0; - /** - * Reset the sound driver - */ - virtual void reset() = 0; + /** + * Tell the driver that the sound stream has resumed + */ + virtual void resume() = 0; - /** - * Tell the driver that the sound stream has resumed - */ - virtual void resume() = 0; + /** + * Write length bytes of data from the finalWave buffer to the driver output buffer. + */ + virtual void write(u16 *finalWave, int length) = 0; - /** - * Write length bytes of data from the finalWave buffer to the driver output buffer. - */ - virtual void write(u16 * finalWave, int length) = 0; - - virtual void setThrottle(unsigned short throttle) { }; + virtual void setThrottle(unsigned short throttle){}; }; #endif // __VBA_SOUND_DRIVER_H__ diff --git a/src/common/SoundSDL.h b/src/common/SoundSDL.h index b196e282..4f9cfb94 100644 --- a/src/common/SoundSDL.h +++ b/src/common/SoundSDL.h @@ -18,40 +18,40 @@ #ifndef __VBA_SOUND_SDL_H__ #define __VBA_SOUND_SDL_H__ -#include "SoundDriver.h" #include "RingBuffer.h" +#include "SoundDriver.h" #include -class SoundSDL: public SoundDriver +class SoundSDL : public SoundDriver { -public: - SoundSDL(); - virtual ~SoundSDL(); + public: + SoundSDL(); + virtual ~SoundSDL(); - virtual bool init(long sampleRate); - virtual void pause(); - virtual void reset(); - virtual void resume(); - virtual void write(u16 * finalWave, int length); + virtual bool init(long sampleRate); + virtual void pause(); + virtual void reset(); + virtual void resume(); + virtual void write(u16 *finalWave, int length); -private: - RingBuffer _rbuf; + private: + RingBuffer _rbuf; - SDL_mutex * _mutex; - SDL_sem *_semBufferFull; - SDL_sem *_semBufferEmpty; - SDL_AudioDeviceID _dev; + SDL_mutex *_mutex; + SDL_sem *_semBufferFull; + SDL_sem *_semBufferEmpty; + SDL_AudioDeviceID _dev; - int current_rate; + int current_rate; - bool _initialized; + bool _initialized; - // Defines what delay in seconds we keep in the sound buffer - static const float _delay; + // Defines what delay in seconds we keep in the sound buffer + static const float _delay; - static void soundCallback(void *data, u8 *stream, int length); - virtual void read(u16 * stream, int length); + static void soundCallback(void *data, u8 *stream, int length); + virtual void read(u16 *stream, int length); }; #endif // __VBA_SOUND_SDL_H__ diff --git a/src/common/array.h b/src/common/array.h index a5f36e69..048eb7f0 100644 --- a/src/common/array.h +++ b/src/common/array.h @@ -1,45 +1,54 @@ #ifndef ARRAY_H #define ARRAY_H -#include #include +#include -template -class Array +template class Array { - public: - typedef T value_type; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T &reference; - typedef const T &const_reference; - typedef T *pointer; - typedef const T *const_pointer; - typedef T *iterator; - typedef const T *const_iterator; - typedef std::reverse_iterator reverse_iterator; - typedef std::reverse_iterator const_reverse_iterator; + public: + typedef T value_type; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef T &reference; + typedef const T &const_reference; + typedef T *pointer; + typedef const T *const_pointer; + typedef T *iterator; + typedef const T *const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; - private: - pointer m_p; - size_type m_size; + private: + pointer m_p; + size_type m_size; - public: + public: + Array(size_type size = 0) : m_p(size ? new value_type[size] : 0), m_size(size) + { + } - Array(size_type size = 0) : m_p(size ? new value_type[size] : 0), m_size(size) {} + void reset(size_t size) + { + delete[] this->m_p; + this->m_p = size ? new value_type[size] : 0; + this->m_size = size; + } - void reset(size_t size) - { - delete[] this->m_p; - this->m_p = size ? new value_type[size] : 0; - this->m_size = size; - } + size_type size() const + { + return (this->m_size); + } - size_type size() const { return(this->m_size); } + operator pointer() + { + return (this->m_p); + } + operator const_pointer() const + { + return (this->m_p); + } - operator pointer() { return(this->m_p); } - operator const_pointer() const { return(this->m_p); } - - ///TODO: Add more functions from here: http://en.cppreference.com/w/cpp/container/array + /// TODO: Add more functions from here: http://en.cppreference.com/w/cpp/container/array }; #endif diff --git a/src/common/dictionary.c b/src/common/dictionary.c index f5699328..cd1b9ce0 100644 --- a/src/common/dictionary.c +++ b/src/common/dictionary.c @@ -21,13 +21,13 @@ //#include /** Maximum value size for integers and doubles. */ -#define MAXVALSZ 1024 +#define MAXVALSZ 1024 /** Minimal allocated number of entries in a dictionary */ -#define DICTMINSZ 128 +#define DICTMINSZ 128 /** Invalid key token */ -#define DICT_INVALID_KEY ((char*)-1) +#define DICT_INVALID_KEY ((char *)-1) /*--------------------------------------------------------------------------- Private functions @@ -35,17 +35,17 @@ /* Doubles the allocated size associated to a pointer */ /* 'size' is the current allocated size. */ -static void * mem_double(void * ptr, int size) +static void *mem_double(void *ptr, int size) { - void * newptr ; - - newptr = calloc(2*size, 1); - if (newptr==NULL) { - return NULL ; - } - memcpy(newptr, ptr, size); - free(ptr); - return newptr ; + void *newptr; + + newptr = calloc(2 * size, 1); + if (newptr == NULL) { + return NULL; + } + memcpy(newptr, ptr, size); + free(ptr); + return newptr; } /*-------------------------------------------------------------------------*/ @@ -58,16 +58,16 @@ static void * mem_double(void * ptr, int size) for systems that do not have it. */ /*--------------------------------------------------------------------------*/ -static char * xstrdup(const char * s) +static char *xstrdup(const char *s) { - char * t ; - if (!s) - return NULL ; - t = (char*)malloc(strlen(s)+1) ; - if (t) { - strcpy(t,s); - } - return t ; + char *t; + if (!s) + return NULL; + t = (char *)malloc(strlen(s) + 1); + if (t) { + strcpy(t, s); + } + return t; } /*--------------------------------------------------------------------------- @@ -85,22 +85,22 @@ static char * xstrdup(const char * s) by comparing the key itself in last resort. */ /*--------------------------------------------------------------------------*/ -unsigned dictionary_hash(const char * key) +unsigned dictionary_hash(const char *key) { - int len ; - unsigned hash ; - int i ; + int len; + unsigned hash; + int i; - len = strlen(key); - for (hash=0, i=0 ; i>6) ; - } - hash += (hash <<3); - hash ^= (hash >>11); - hash += (hash <<15); - return hash ; + len = strlen(key); + for (hash = 0, i = 0; i < len; i++) { + hash += (unsigned)key[i]; + hash += (hash << 10); + hash ^= (hash >> 6); + } + hash += (hash << 3); + hash ^= (hash >> 11); + hash += (hash << 15); + return hash; } /*-------------------------------------------------------------------------*/ @@ -114,21 +114,22 @@ unsigned dictionary_hash(const char * key) dictionary, give size=0. */ /*--------------------------------------------------------------------------*/ -dictionary * dictionary_new(int size) +dictionary *dictionary_new(int size) { - dictionary * d ; + dictionary *d; - /* If no size was specified, allocate space for DICTMINSZ */ - if (sizesize = size ; - d->val = (char **)calloc(size, sizeof(char*)); - d->key = (char **)calloc(size, sizeof(char*)); - d->hash = (unsigned int *)calloc(size, sizeof(unsigned)); - return d ; + if (!(d = (dictionary *)calloc(1, sizeof(dictionary)))) { + return NULL; + } + d->size = size; + d->val = (char **)calloc(size, sizeof(char *)); + d->key = (char **)calloc(size, sizeof(char *)); + d->hash = (unsigned int *)calloc(size, sizeof(unsigned)); + return d; } /*-------------------------------------------------------------------------*/ @@ -140,22 +141,23 @@ dictionary * dictionary_new(int size) Deallocate a dictionary object and all memory associated to it. */ /*--------------------------------------------------------------------------*/ -void dictionary_del(dictionary * d) +void dictionary_del(dictionary *d) { - int i ; + int i; - if (d==NULL) return ; - for (i=0 ; isize ; i++) { - if (d->key[i]!=NULL) - free(d->key[i]); - if (d->val[i]!=NULL) - free(d->val[i]); - } - free(d->val); - free(d->key); - free(d->hash); - free(d); - return ; + if (d == NULL) + return; + for (i = 0; i < d->size; i++) { + if (d->key[i] != NULL) + free(d->key[i]); + if (d->val[i] != NULL) + free(d->val[i]); + } + free(d->val); + free(d->key); + free(d->hash); + free(d); + return; } /*-------------------------------------------------------------------------*/ @@ -172,24 +174,24 @@ void dictionary_del(dictionary * d) dictionary object, you should not try to free it or modify it. */ /*--------------------------------------------------------------------------*/ -const char * dictionary_get(dictionary * d, const char * key, const char * def) +const char *dictionary_get(dictionary *d, const char *key, const char *def) { - unsigned hash ; - int i ; + unsigned hash; + int i; - hash = dictionary_hash(key); - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - /* Compare hash */ - if (hash==d->hash[i]) { - /* Compare string, to avoid hash collisions */ - if (!strcmp(key, d->key[i])) { - return d->val[i] ; - } + hash = dictionary_hash(key); + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + /* Compare hash */ + if (hash == d->hash[i]) { + /* Compare string, to avoid hash collisions */ + if (!strcmp(key, d->key[i])) { + return d->val[i]; + } + } } - } - return def ; + return def; } /*-------------------------------------------------------------------------*/ @@ -218,60 +220,61 @@ const char * dictionary_get(dictionary * d, const char * key, const char * def) This function returns non-zero in case of failure. */ /*--------------------------------------------------------------------------*/ -int dictionary_set(dictionary * d, const char * key, const char * val) +int dictionary_set(dictionary *d, const char *key, const char *val) { - int i ; - unsigned hash ; + int i; + unsigned hash; - if (d==NULL || key==NULL) return -1 ; - - /* Compute hash for this key */ - hash = dictionary_hash(key) ; - /* Find if value is already in dictionary */ - if (d->n>0) { - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - if (hash==d->hash[i]) { /* Same hash value */ - if (!strcmp(key, d->key[i])) { /* Same key */ - /* Found a value: modify and return */ - if (d->val[i]!=NULL) - free(d->val[i]); - d->val[i] = val ? xstrdup(val) : NULL ; - /* Value has been modified: return */ - return 0 ; + if (d == NULL || key == NULL) + return -1; + + /* Compute hash for this key */ + hash = dictionary_hash(key); + /* Find if value is already in dictionary */ + if (d->n > 0) { + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + if (hash == d->hash[i]) { /* Same hash value */ + if (!strcmp(key, d->key[i])) { /* Same key */ + /* Found a value: modify and return */ + if (d->val[i] != NULL) + free(d->val[i]); + d->val[i] = val ? xstrdup(val) : NULL; + /* Value has been modified: return */ + return 0; + } + } } - } } - } - /* Add a new value */ - /* See if dictionary needs to grow */ - if (d->n==d->size) { - - /* Reached maximum size: reallocate dictionary */ - d->val = (char **)mem_double(d->val, d->size * sizeof(char*)) ; - d->key = (char **)mem_double(d->key, d->size * sizeof(char*)) ; - d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)) ; - if ((d->val==NULL) || (d->key==NULL) || (d->hash==NULL)) { - /* Cannot grow dictionary */ - return -1 ; + /* Add a new value */ + /* See if dictionary needs to grow */ + if (d->n == d->size) { + /* Reached maximum size: reallocate dictionary */ + d->val = (char **)mem_double(d->val, d->size * sizeof(char *)); + d->key = (char **)mem_double(d->key, d->size * sizeof(char *)); + d->hash = (unsigned int *)mem_double(d->hash, d->size * sizeof(unsigned)); + if ((d->val == NULL) || (d->key == NULL) || (d->hash == NULL)) { + /* Cannot grow dictionary */ + return -1; + } + /* Double size */ + d->size *= 2; } - /* Double size */ - d->size *= 2 ; - } - /* Insert key in the first empty slot. Start at d->n and wrap at - d->size. Because d->n < d->size this will necessarily - terminate. */ - for (i=d->n ; d->key[i] ; ) { - if(++i == d->size) i = 0; - } - /* Copy key */ - d->key[i] = xstrdup(key); - d->val[i] = val ? xstrdup(val) : NULL ; - d->hash[i] = hash; - d->n ++ ; - return 0 ; + /* Insert key in the first empty slot. Start at d->n and wrap at + d->size. Because d->n < d->size this will necessarily + terminate. */ + for (i = d->n; d->key[i];) { + if (++i == d->size) + i = 0; + } + /* Copy key */ + d->key[i] = xstrdup(key); + d->val[i] = val ? xstrdup(val) : NULL; + d->hash[i] = hash; + d->n++; + return 0; } /*-------------------------------------------------------------------------*/ @@ -285,41 +288,41 @@ int dictionary_set(dictionary * d, const char * key, const char * val) key cannot be found. */ /*--------------------------------------------------------------------------*/ -void dictionary_unset(dictionary * d, const char * key) +void dictionary_unset(dictionary *d, const char *key) { - unsigned hash ; - int i ; + unsigned hash; + int i; - if (key == NULL) { - return; - } - - hash = dictionary_hash(key); - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - /* Compare hash */ - if (hash==d->hash[i]) { - /* Compare string, to avoid hash collisions */ - if (!strcmp(key, d->key[i])) { - /* Found key */ - break ; - } + if (key == NULL) { + return; } - } - if (i>=d->size) - /* Key not found */ - return ; - free(d->key[i]); - d->key[i] = NULL ; - if (d->val[i]!=NULL) { - free(d->val[i]); - d->val[i] = NULL ; - } - d->hash[i] = 0 ; - d->n -- ; - return ; + hash = dictionary_hash(key); + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + /* Compare hash */ + if (hash == d->hash[i]) { + /* Compare string, to avoid hash collisions */ + if (!strcmp(key, d->key[i])) { + /* Found key */ + break; + } + } + } + if (i >= d->size) + /* Key not found */ + return; + + free(d->key[i]); + d->key[i] = NULL; + if (d->val[i] != NULL) { + free(d->val[i]); + d->val[i] = NULL; + } + d->hash[i] = 0; + d->n--; + return; } /*-------------------------------------------------------------------------*/ @@ -334,65 +337,63 @@ void dictionary_unset(dictionary * d, const char * key) output file pointers. */ /*--------------------------------------------------------------------------*/ -void dictionary_dump(dictionary * d, FILE * out) +void dictionary_dump(dictionary *d, FILE *out) { - int i ; + int i; - if (d==NULL || out==NULL) return ; - if (d->n<1) { - fprintf(out, "empty dictionary\n"); - return ; - } - for (i=0 ; isize ; i++) { - if (d->key[i]) { - fprintf(out, "%20s\t[%s]\n", - d->key[i], - d->val[i] ? d->val[i] : "UNDEF"); + if (d == NULL || out == NULL) + return; + if (d->n < 1) { + fprintf(out, "empty dictionary\n"); + return; } - } - return ; + for (i = 0; i < d->size; i++) { + if (d->key[i]) { + fprintf(out, "%20s\t[%s]\n", d->key[i], d->val[i] ? d->val[i] : "UNDEF"); + } + } + return; } - /* Test code */ #ifdef TESTDIC #define NVALS 20000 int main(int argc, char *argv[]) { - dictionary * d ; - char * val ; - int i ; - char cval[90] ; + dictionary *d; + char *val; + int i; + char cval[90]; - /* Allocate dictionary */ - printf("allocating...\n"); - d = dictionary_new(0); - - /* Set values in dictionary */ - printf("setting %d values...\n", NVALS); - for (i=0 ; in != 0) { - printf("error deleting values\n"); - } - printf("deallocating...\n"); - dictionary_del(d); - return 0 ; + printf("getting %d values...\n", NVALS); + for (i = 0; i < NVALS; i++) { + sprintf(cval, "%04d", i); + val = dictionary_get(d, cval, DICT_INVALID_KEY); + if (val == DICT_INVALID_KEY) { + printf("cannot get value for key [%s]\n", cval); + } + } + printf("unsetting %d values...\n", NVALS); + for (i = 0; i < NVALS; i++) { + sprintf(cval, "%04d", i); + dictionary_unset(d, cval); + } + if (d->n != 0) { + printf("error deleting values\n"); + } + printf("deallocating...\n"); + dictionary_del(d); + return 0; } #endif /* vim: set ts=4 et sw=4 tw=75 */ diff --git a/src/common/dictionary.h b/src/common/dictionary.h index aea60cac..1260646a 100644 --- a/src/common/dictionary.h +++ b/src/common/dictionary.h @@ -27,7 +27,6 @@ New types ---------------------------------------------------------------------------*/ - /*-------------------------------------------------------------------------*/ /** @brief Dictionary object @@ -39,13 +38,12 @@ */ /*-------------------------------------------------------------------------*/ typedef struct _dictionary_ { - int n ; /** Number of entries in dictionary */ - int size ; /** Storage size */ - char ** val ; /** List of string values */ - char ** key ; /** List of string keys */ - unsigned * hash ; /** List of hash values for keys */ -} dictionary ; - + int n; /** Number of entries in dictionary */ + int size; /** Storage size */ + char **val; /** List of string values */ + char **key; /** List of string keys */ + unsigned *hash; /** List of hash values for keys */ +} dictionary; /*--------------------------------------------------------------------------- Function prototypes @@ -63,7 +61,7 @@ typedef struct _dictionary_ { by comparing the key itself in last resort. */ /*--------------------------------------------------------------------------*/ -unsigned dictionary_hash(const char * key); +unsigned dictionary_hash(const char *key); /*-------------------------------------------------------------------------*/ /** @@ -76,7 +74,7 @@ unsigned dictionary_hash(const char * key); dictionary, give size=0. */ /*--------------------------------------------------------------------------*/ -dictionary * dictionary_new(int size); +dictionary *dictionary_new(int size); /*-------------------------------------------------------------------------*/ /** @@ -87,7 +85,7 @@ dictionary * dictionary_new(int size); Deallocate a dictionary object and all memory associated to it. */ /*--------------------------------------------------------------------------*/ -void dictionary_del(dictionary * vd); +void dictionary_del(dictionary *vd); /*-------------------------------------------------------------------------*/ /** @@ -103,8 +101,7 @@ void dictionary_del(dictionary * vd); dictionary object, you should not try to free it or modify it. */ /*--------------------------------------------------------------------------*/ -const char * dictionary_get(dictionary * d, const char * key, const char * def); - +const char *dictionary_get(dictionary *d, const char *key, const char *def); /*-------------------------------------------------------------------------*/ /** @@ -132,7 +129,7 @@ const char * dictionary_get(dictionary * d, const char * key, const char * def); This function returns non-zero in case of failure. */ /*--------------------------------------------------------------------------*/ -int dictionary_set(dictionary * vd, const char * key, const char * val); +int dictionary_set(dictionary *vd, const char *key, const char *val); /*-------------------------------------------------------------------------*/ /** @@ -145,8 +142,7 @@ int dictionary_set(dictionary * vd, const char * key, const char * val); key cannot be found. */ /*--------------------------------------------------------------------------*/ -void dictionary_unset(dictionary * d, const char * key); - +void dictionary_unset(dictionary *d, const char *key); /*-------------------------------------------------------------------------*/ /** @@ -160,6 +156,6 @@ void dictionary_unset(dictionary * d, const char * key); output file pointers. */ /*--------------------------------------------------------------------------*/ -void dictionary_dump(dictionary * d, FILE * out); +void dictionary_dump(dictionary *d, FILE *out); #endif diff --git a/src/common/ffmpeg.h b/src/common/ffmpeg.h index f27bb3d7..6455eda7 100644 --- a/src/common/ffmpeg.h +++ b/src/common/ffmpeg.h @@ -19,40 +19,43 @@ // return codes // probably ought to put in own namespace, but this is good enough enum MediaRet { - MRET_OK, // no errors - MRET_ERR_NOMEM, // error allocating buffers or structures - MRET_ERR_NOCODEC, // error opening codec - MRET_ERR_FERR, // error writing output file - MRET_ERR_RECORDING, // attempt to start recording when already doing it - MRET_ERR_FMTGUESS, // can't guess format from file name - MRET_ERR_BUFSIZE // buffer overflow (fatal) + MRET_OK, // no errors + MRET_ERR_NOMEM, // error allocating buffers or structures + MRET_ERR_NOCODEC, // error opening codec + MRET_ERR_FERR, // error writing output file + MRET_ERR_RECORDING, // attempt to start recording when already doing it + MRET_ERR_FMTGUESS, // can't guess format from file name + MRET_ERR_BUFSIZE // buffer overflow (fatal) }; class MediaRecorder { -public: - MediaRecorder(); - virtual ~MediaRecorder(); + public: + MediaRecorder(); + virtual ~MediaRecorder(); - // start audio+video (also video-only codecs) - MediaRet Record(const char *fname, int width, int height, int depth); - // start audio only - MediaRet Record(const char *fname); - // stop both - void Stop(); - bool IsRecording() { return oc != NULL; } - // add a frame of video; width+height+depth already given - // assumes a 1-pixel border on top & right - // always assumes being passed 1/60th of a second of video - MediaRet AddFrame(const u8 *vid); - // add a frame of audio; uses current sample rate to know length - // always assumes being passed 1/60th of a second of audio. - MediaRet AddFrame(const u16 *aud); + // start audio+video (also video-only codecs) + MediaRet Record(const char *fname, int width, int height, int depth); + // start audio only + MediaRet Record(const char *fname); + // stop both + void Stop(); + bool IsRecording() + { + return oc != NULL; + } + // add a frame of video; width+height+depth already given + // assumes a 1-pixel border on top & right + // always assumes being passed 1/60th of a second of video + MediaRet AddFrame(const u8 *vid); + // add a frame of audio; uses current sample rate to know length + // always assumes being passed 1/60th of a second of audio. + MediaRet AddFrame(const u16 *aud); -private: - static bool did_init; + private: + static bool did_init; - // these are to avoid polluting things with avcodec includes +// these are to avoid polluting things with avcodec includes #ifndef priv_AVFormatContext #define priv_AVFormatContext void #define priv_AVStream void @@ -61,19 +64,19 @@ private: #define priv_SwsContext void #define priv_PixelFormat int #endif - priv_AVFormatContext *oc; - priv_AVStream *vid_st, *aud_st; - u8 *audio_buf, *video_buf; - u16 *audio_buf2; - int frame_len, sample_len, in_audio_buf2; - int linesize, pixsize; - priv_PixelFormat pixfmt; - priv_AVFrame *pic, *convpic; - priv_SwsContext *converter; - - MediaRet setup_sound_stream(const char *fname, priv_AVOutputFormat *fmt); - MediaRet setup_video_stream(const char *fname, int w, int h, int d); - MediaRet finish_setup(const char *fname); + priv_AVFormatContext *oc; + priv_AVStream *vid_st, *aud_st; + u8 *audio_buf, *video_buf; + u16 *audio_buf2; + int frame_len, sample_len, in_audio_buf2; + int linesize, pixsize; + priv_PixelFormat pixfmt; + priv_AVFrame *pic, *convpic; + priv_SwsContext *converter; + + MediaRet setup_sound_stream(const char *fname, priv_AVOutputFormat *fmt); + MediaRet setup_video_stream(const char *fname, int w, int h, int d); + MediaRet finish_setup(const char *fname); }; #endif /* WX_FFMPEG_H */ diff --git a/src/common/iniparser.c b/src/common/iniparser.c index e89695c8..5ffe7b5e 100644 --- a/src/common/iniparser.c +++ b/src/common/iniparser.c @@ -7,12 +7,12 @@ */ /*--------------------------------------------------------------------------*/ /*---------------------------- Includes ------------------------------------*/ -#include #include "iniparser.h" +#include /*---------------------------- Defines -------------------------------------*/ -#define ASCIILINESZ (1024) -#define INI_INVALID_KEY ((char*)-1) +#define ASCIILINESZ (1024) +#define INI_INVALID_KEY ((char *)-1) /*--------------------------------------------------------------------------- Private to this module @@ -21,13 +21,13 @@ * This enum stores the status for each parsed line (internal use only). */ typedef enum _line_status_ { - LINE_UNPROCESSED, - LINE_ERROR, - LINE_EMPTY, - LINE_COMMENT, - LINE_SECTION, - LINE_VALUE -} line_status ; + LINE_UNPROCESSED, + LINE_ERROR, + LINE_EMPTY, + LINE_COMMENT, + LINE_SECTION, + LINE_VALUE +} line_status; /*-------------------------------------------------------------------------*/ /** @@ -41,21 +41,22 @@ typedef enum _line_status_ { allocated, it will be modified at each function call (not re-entrant). */ /*--------------------------------------------------------------------------*/ -static char * strlwc(const char * s) +static char *strlwc(const char *s) { - static char l[ASCIILINESZ+1]; - int i ; + static char l[ASCIILINESZ + 1]; + int i; - if (s==NULL) return NULL ; - memset(l, 0, ASCIILINESZ+1); - i=0 ; - while (s[i] && i l) { - if (!isspace((int)*(last-1))) - break ; - last -- ; - } - *last = (char)0; - return (char*)l ; + static char l[ASCIILINESZ + 1]; + char *last; + + if (s == NULL) + return NULL; + + while (isspace((int)*s) && *s) + s++; + memset(l, 0, ASCIILINESZ + 1); + strcpy(l, s); + last = l + strlen(l); + while (last > l) { + if (!isspace((int)*(last - 1))) + break; + last--; + } + *last = (char)0; + return (char *)l; } /*-------------------------------------------------------------------------*/ @@ -110,21 +113,22 @@ static char * strstrip(const char * s) This function returns -1 in case of error. */ /*--------------------------------------------------------------------------*/ -int iniparser_getnsec(dictionary * d) +int iniparser_getnsec(dictionary *d) { - int i ; - int nsec ; + int i; + int nsec; - if (d==NULL) return -1 ; - nsec=0 ; - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - if (strchr(d->key[i], ':')==NULL) { - nsec ++ ; + if (d == NULL) + return -1; + nsec = 0; + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + if (strchr(d->key[i], ':') == NULL) { + nsec++; + } } - } - return nsec ; + return nsec; } /*-------------------------------------------------------------------------*/ @@ -141,26 +145,27 @@ int iniparser_getnsec(dictionary * d) This function returns NULL in case of error. */ /*--------------------------------------------------------------------------*/ -char * iniparser_getsecname(dictionary * d, int n) +char *iniparser_getsecname(dictionary *d, int n) { - int i ; - int foundsec ; + int i; + int foundsec; - if (d==NULL || n<0) return NULL ; - foundsec=0 ; - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - if (strchr(d->key[i], ':')==NULL) { - foundsec++ ; - if (foundsec>n) - break ; + if (d == NULL || n < 0) + return NULL; + foundsec = 0; + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + if (strchr(d->key[i], ':') == NULL) { + foundsec++; + if (foundsec > n) + break; + } } - } - if (foundsec<=n) { - return NULL ; - } - return d->key[i] ; + if (foundsec <= n) { + return NULL; + } + return d->key[i]; } /*-------------------------------------------------------------------------*/ @@ -176,21 +181,22 @@ char * iniparser_getsecname(dictionary * d, int n) purposes mostly. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump(dictionary * d, FILE * f) +void iniparser_dump(dictionary *d, FILE *f) { - int i ; + int i; - if (d==NULL || f==NULL) return ; - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - if (d->val[i]!=NULL) { - fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]); - } else { - fprintf(f, "[%s]=UNDEF\n", d->key[i]); + if (d == NULL || f == NULL) + return; + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + if (d->val[i] != NULL) { + fprintf(f, "[%s]=[%s]\n", d->key[i], d->val[i]); + } else { + fprintf(f, "[%s]=UNDEF\n", d->key[i]); + } } - } - return ; + return; } /*-------------------------------------------------------------------------*/ @@ -204,36 +210,36 @@ void iniparser_dump(dictionary * d, FILE * f) It is Ok to specify @c stderr or @c stdout as output files. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump_ini(dictionary * d, FILE * f) +void iniparser_dump_ini(dictionary *d, FILE *f) { - int i ; - int nsec ; - char * secname ; + int i; + int nsec; + char *secname; - if (d==NULL || f==NULL) return ; + if (d == NULL || f == NULL) + return; - nsec = iniparser_getnsec(d); - if (nsec<1) { - /* No section in file: dump all keys as they are */ - fprintf(f, "[preferences]\n"); - for (i=0 ; isize ; i++) { - if (d->key[i]==NULL) - continue ; - if (!strncmp(d->key[i], "preferences:", strlen("preferences:"))) { - fprintf(f, - "%s=%s\n", - d->key[i]+strlen("preferences:"), - d->val[i] ? d->val[i] : ""); - - } + nsec = iniparser_getnsec(d); + if (nsec < 1) { + /* No section in file: dump all keys as they are */ + fprintf(f, "[preferences]\n"); + for (i = 0; i < d->size; i++) { + if (d->key[i] == NULL) + continue; + if (!strncmp(d->key[i], "preferences:", strlen("preferences:"))) { + fprintf(f, + "%s=%s\n", + d->key[i] + strlen("preferences:"), + d->val[i] ? d->val[i] : ""); + } + } + fprintf(f, "\n"); + return; } - fprintf(f, "\n"); - return ; + for (i = 0; i < nsec; i++) { + secname = iniparser_getsecname(d, i); + iniparser_dumpsection_ini(d, secname, f); } - for (i=0 ; isize ; j++) { - if (d->key[j]==NULL) - continue ; - if (!strncmp(d->key[j], keym, seclen+1)) { - fprintf(f, - "%s=%s\n", - d->key[j]+seclen+1, - d->val[j] ? d->val[j] : ""); + seclen = (int)strlen(s); + // fprintf(f, "\n[%s]\n", s); + fprintf(f, "[%s]\n", s); + sprintf(keym, "%s:", s); + for (j = 0; j < d->size; j++) { + if (d->key[j] == NULL) + continue; + if (!strncmp(d->key[j], keym, seclen + 1)) { + fprintf(f, "%s=%s\n", d->key[j] + seclen + 1, d->val[j] ? d->val[j] : ""); + } } - } - fprintf(f, "\n"); - return ; + fprintf(f, "\n"); + return; } /*-------------------------------------------------------------------------*/ @@ -283,29 +288,30 @@ void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f) @return Number of keys in section */ /*--------------------------------------------------------------------------*/ -int iniparser_getsecnkeys(dictionary * d, char * s) +int iniparser_getsecnkeys(dictionary *d, char *s) { - int seclen, nkeys ; - char keym[ASCIILINESZ+1]; - int j ; + int seclen, nkeys; + char keym[ASCIILINESZ + 1]; + int j; - nkeys = 0; + nkeys = 0; - if (d==NULL) return nkeys; - if (! iniparser_find_entry(d, s)) return nkeys; + if (d == NULL) + return nkeys; + if (!iniparser_find_entry(d, s)) + return nkeys; - seclen = (int)strlen(s); - sprintf(keym, "%s:", s); + seclen = (int)strlen(s); + sprintf(keym, "%s:", s); - for (j=0 ; jsize ; j++) { - if (d->key[j]==NULL) - continue ; - if (!strncmp(d->key[j], keym, seclen+1)) - nkeys++; - } - - return nkeys; + for (j = 0; j < d->size; j++) { + if (d->key[j] == NULL) + continue; + if (!strncmp(d->key[j], keym, seclen + 1)) + nkeys++; + } + return nkeys; } /*-------------------------------------------------------------------------*/ @@ -318,44 +324,44 @@ int iniparser_getsecnkeys(dictionary * d, char * s) This function queries a dictionary and finds all keys in a given section. Each pointer in the returned char pointer-to-pointer is pointing to a string allocated in the dictionary; do not free or modify them. - + This function returns NULL in case of error. */ /*--------------------------------------------------------------------------*/ -char ** iniparser_getseckeys(dictionary * d, char * s) +char **iniparser_getseckeys(dictionary *d, char *s) { + char **keys; - char **keys; + int i, j; + char keym[ASCIILINESZ + 1]; + int seclen, nkeys; - int i, j ; - char keym[ASCIILINESZ+1]; - int seclen, nkeys ; + keys = NULL; - keys = NULL; + if (d == NULL) + return keys; + if (!iniparser_find_entry(d, s)) + return keys; - if (d==NULL) return keys; - if (! iniparser_find_entry(d, s)) return keys; + nkeys = iniparser_getsecnkeys(d, s); - nkeys = iniparser_getsecnkeys(d, s); + keys = (char **)malloc(nkeys * sizeof(char *)); - keys = (char**) malloc(nkeys*sizeof(char*)); + seclen = (int)strlen(s); + sprintf(keym, "%s:", s); - seclen = (int)strlen(s); - sprintf(keym, "%s:", s); - - i = 0; + i = 0; - for (j=0 ; jsize ; j++) { - if (d->key[j]==NULL) - continue ; - if (!strncmp(d->key[j], keym, seclen+1)) { - keys[i] = d->key[j]; - i++; + for (j = 0; j < d->size; j++) { + if (d->key[j] == NULL) + continue; + if (!strncmp(d->key[j], keym, seclen + 1)) { + keys[i] = d->key[j]; + i++; + } } - } - - return keys; + return keys; } /*-------------------------------------------------------------------------*/ @@ -373,17 +379,17 @@ char ** iniparser_getseckeys(dictionary * d, char * s) the dictionary, do not free or modify it. */ /*--------------------------------------------------------------------------*/ -const char * iniparser_getstring(dictionary * d, const char * key, const char * def) +const char *iniparser_getstring(dictionary *d, const char *key, const char *def) { - char * lc_key ; - const char * sval ; + char *lc_key; + const char *sval; - if (d==NULL || key==NULL) - return def ; + if (d == NULL || key == NULL) + return def; - lc_key = strlwc(key); - sval = dictionary_get(d, lc_key, def); - return sval ; + lc_key = strlwc(key); + sval = dictionary_get(d, lc_key, def); + return sval; } /*-------------------------------------------------------------------------*/ @@ -413,13 +419,14 @@ const char * iniparser_getstring(dictionary * d, const char * key, const char * Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int iniparser_getint(dictionary * d, const char * key, int notfound) +int iniparser_getint(dictionary *d, const char *key, int notfound) { - const char *str; + const char *str; - str = iniparser_getstring(d, key, INI_INVALID_KEY); - if (str==INI_INVALID_KEY) return notfound ; - return (int)strtol(str, NULL, 0); + str = iniparser_getstring(d, key, INI_INVALID_KEY); + if (str == INI_INVALID_KEY) + return notfound; + return (int)strtol(str, NULL, 0); } /*-------------------------------------------------------------------------*/ @@ -435,13 +442,14 @@ int iniparser_getint(dictionary * d, const char * key, int notfound) the notfound value is returned. */ /*--------------------------------------------------------------------------*/ -double iniparser_getdouble(dictionary * d, const char * key, double notfound) +double iniparser_getdouble(dictionary *d, const char *key, double notfound) { - const char *str; + const char *str; - str = iniparser_getstring(d, key, INI_INVALID_KEY); - if (str==INI_INVALID_KEY) return notfound ; - return atof(str); + str = iniparser_getstring(d, key, INI_INVALID_KEY); + if (str == INI_INVALID_KEY) + return notfound; + return atof(str); } /*-------------------------------------------------------------------------*/ @@ -476,21 +484,22 @@ double iniparser_getdouble(dictionary * d, const char * key, double notfound) necessarily have to be 0 or 1. */ /*--------------------------------------------------------------------------*/ -int iniparser_getboolean(dictionary * d, const char * key, int notfound) +int iniparser_getboolean(dictionary *d, const char *key, int notfound) { - const char * c; - int ret ; + const char *c; + int ret; - c = iniparser_getstring(d, key, INI_INVALID_KEY); - if (c==INI_INVALID_KEY) return notfound ; - if (c[0]=='y' || c[0]=='Y' || c[0]=='1' || c[0]=='t' || c[0]=='T') { - ret = 1 ; - } else if (c[0]=='n' || c[0]=='N' || c[0]=='0' || c[0]=='f' || c[0]=='F') { - ret = 0 ; - } else { - ret = notfound ; - } - return ret; + c = iniparser_getstring(d, key, INI_INVALID_KEY); + if (c == INI_INVALID_KEY) + return notfound; + if (c[0] == 'y' || c[0] == 'Y' || c[0] == '1' || c[0] == 't' || c[0] == 'T') { + ret = 1; + } else if (c[0] == 'n' || c[0] == 'N' || c[0] == '0' || c[0] == 'f' || c[0] == 'F') { + ret = 0; + } else { + ret = notfound; + } + return ret; } /*-------------------------------------------------------------------------*/ @@ -505,16 +514,13 @@ int iniparser_getboolean(dictionary * d, const char * key, int notfound) of querying for the presence of sections in a dictionary. */ /*--------------------------------------------------------------------------*/ -int iniparser_find_entry( - dictionary * ini, - const char * entry -) +int iniparser_find_entry(dictionary *ini, const char *entry) { - int found=0 ; - if (iniparser_getstring(ini, entry, INI_INVALID_KEY)!=INI_INVALID_KEY) { - found = 1 ; - } - return found ; + int found = 0; + if (iniparser_getstring(ini, entry, INI_INVALID_KEY) != INI_INVALID_KEY) { + found = 1; + } + return found; } /*-------------------------------------------------------------------------*/ @@ -530,9 +536,9 @@ int iniparser_find_entry( It is Ok to set val to NULL. */ /*--------------------------------------------------------------------------*/ -int iniparser_set(dictionary * ini, const char * entry, const char * val) +int iniparser_set(dictionary *ini, const char *entry, const char *val) { - return dictionary_set(ini, strlwc(entry), val) ; + return dictionary_set(ini, strlwc(entry), val); } /*-------------------------------------------------------------------------*/ @@ -545,9 +551,9 @@ int iniparser_set(dictionary * ini, const char * entry, const char * val) If the given entry can be found, it is deleted from the dictionary. */ /*--------------------------------------------------------------------------*/ -void iniparser_unset(dictionary * ini, const char * entry) +void iniparser_unset(dictionary *ini, const char *entry) { - dictionary_unset(ini, strlwc(entry)); + dictionary_unset(ini, strlwc(entry)); } /*-------------------------------------------------------------------------*/ @@ -560,64 +566,60 @@ void iniparser_unset(dictionary * ini, const char * entry) @return line_status value */ /*--------------------------------------------------------------------------*/ -static line_status iniparser_line( - const char * input_line, - char * section, - char * key, - char * value) -{ - line_status sta ; - char line[ASCIILINESZ+1]; - int len ; +static line_status iniparser_line(const char *input_line, char *section, char *key, char *value) +{ + line_status sta; + char line[ASCIILINESZ + 1]; + int len; - strcpy(line, strstrip(input_line)); - len = (int)strlen(line); + strcpy(line, strstrip(input_line)); + len = (int)strlen(line); - sta = LINE_UNPROCESSED ; - if (len<1) { - /* Empty line */ - sta = LINE_EMPTY ; - } else if (line[0]=='#' || line[0]==';') { - /* Comment line */ - sta = LINE_COMMENT ; - } else if (line[0]=='[' && line[len-1]==']') { - /* Section name */ - sscanf(line, "[%[^]]", section); - strcpy(section, strstrip(section)); - strcpy(section, strlwc(section)); - sta = LINE_SECTION ; - } else if (sscanf (line, "%[^=] = \"%[^\"]\"", key, value) == 2 - || sscanf (line, "%[^=] = '%[^\']'", key, value) == 2 - || sscanf (line, "%[^=] = %[^;#]", key, value) == 2) { - /* Usual key=value, with or without comments */ - strcpy(key, strstrip(key)); - strcpy(key, strlwc(key)); - strcpy(value, strstrip(value)); - /* - * sscanf cannot handle '' or "" as empty values - * this is done here - */ - if (!strcmp(value, "\"\"") || (!strcmp(value, "''"))) { - value[0]=0 ; + sta = LINE_UNPROCESSED; + if (len < 1) { + /* Empty line */ + sta = LINE_EMPTY; + } else if (line[0] == '#' || line[0] == ';') { + /* Comment line */ + sta = LINE_COMMENT; + } else if (line[0] == '[' && line[len - 1] == ']') { + /* Section name */ + sscanf(line, "[%[^]]", section); + strcpy(section, strstrip(section)); + strcpy(section, strlwc(section)); + sta = LINE_SECTION; + } else if (sscanf(line, "%[^=] = \"%[^\"]\"", key, value) == 2 || + sscanf(line, "%[^=] = '%[^\']'", key, value) == 2 || + sscanf(line, "%[^=] = %[^;#]", key, value) == 2) { + /* Usual key=value, with or without comments */ + strcpy(key, strstrip(key)); + strcpy(key, strlwc(key)); + strcpy(value, strstrip(value)); + /* + * sscanf cannot handle '' or "" as empty values + * this is done here + */ + if (!strcmp(value, "\"\"") || (!strcmp(value, "''"))) { + value[0] = 0; + } + sta = LINE_VALUE; + } else if (sscanf(line, "%[^=] = %[;#]", key, value) == 2 || + sscanf(line, "%[^=] %[=]", key, value) == 2) { + /* + * Special cases: + * key= + * key=; + * key=# + */ + strcpy(key, strstrip(key)); + strcpy(key, strlwc(key)); + value[0] = 0; + sta = LINE_VALUE; + } else { + /* Generate syntax error */ + sta = LINE_ERROR; } - sta = LINE_VALUE ; - } else if (sscanf(line, "%[^=] = %[;#]", key, value)==2 - || sscanf(line, "%[^=] %[=]", key, value) == 2) { - /* - * Special cases: - * key= - * key=; - * key=# - */ - strcpy(key, strstrip(key)); - strcpy(key, strlwc(key)); - value[0]=0 ; - sta = LINE_VALUE ; - } else { - /* Generate syntax error */ - sta = LINE_ERROR ; - } - return sta ; + return sta; } /*-------------------------------------------------------------------------*/ @@ -634,110 +636,107 @@ static line_status iniparser_line( The returned dictionary must be freed using iniparser_freedict(). */ /*--------------------------------------------------------------------------*/ -dictionary * iniparser_load(const char * ininame) +dictionary *iniparser_load(const char *ininame) { - FILE * in ; + FILE *in; - char line [ASCIILINESZ+1] ; - char section [ASCIILINESZ+1] ; - char key [ASCIILINESZ+1] ; - char tmp [ASCIILINESZ+1] ; - char val [ASCIILINESZ+1] ; + char line[ASCIILINESZ + 1]; + char section[ASCIILINESZ + 1]; + char key[ASCIILINESZ + 1]; + char tmp[ASCIILINESZ + 1]; + char val[ASCIILINESZ + 1]; - int last=0 ; - int len ; - int lineno=0 ; - int errs=0; + int last = 0; + int len; + int lineno = 0; + int errs = 0; - dictionary * dict ; + dictionary *dict; - if ((in=fopen(ininame, "r"))==NULL) { - fprintf(stderr, "iniparser: cannot open %s\n", ininame); - return NULL ; - } - - dict = dictionary_new(0) ; - if (!dict) { - fclose(in); - return NULL ; - } - - memset(line, 0, ASCIILINESZ); - memset(section, 0, ASCIILINESZ); - memset(key, 0, ASCIILINESZ); - memset(val, 0, ASCIILINESZ); - last=0 ; - - while (fgets(line+last, ASCIILINESZ-last, in)!=NULL) { - lineno++ ; - len = (int)strlen(line)-1; - if (len==0) - continue; - /* Safety check against buffer overflows */ - if (line[len]!='\n') { - fprintf(stderr, - "iniparser: input line too long in %s (%d)\n", - ininame, - lineno); - dictionary_del(dict); - fclose(in); - return NULL ; + if ((in = fopen(ininame, "r")) == NULL) { + fprintf(stderr, "iniparser: cannot open %s\n", ininame); + return NULL; } - /* Get rid of \n and spaces at end of line */ - while ((len>=0) && - ((line[len]=='\n') || (isspace(line[len])))) { - line[len]=0 ; - len-- ; + + dict = dictionary_new(0); + if (!dict) { + fclose(in); + return NULL; } - /* Detect multi-line */ - if (line[len]=='\\') { - /* Multi-line value */ - last=len ; - continue ; - } else { - last=0 ; - } - switch (iniparser_line(line, section, key, val)) { - case LINE_EMPTY: - case LINE_COMMENT: - break ; - case LINE_SECTION: - errs = dictionary_set(dict, section, NULL); - break ; - - case LINE_VALUE: - if (strlen(section)) - sprintf(tmp, "%s:%s", section, key); - else - sprintf(tmp, "preferences:%s", key); - errs = dictionary_set(dict, tmp, val) ; - break ; - - case LINE_ERROR: - fprintf(stderr, "iniparser: syntax error in %s (%d):\n", - ininame, - lineno); - fprintf(stderr, "-> %s\n", line); - errs++ ; - break; - - default: - break ; - } memset(line, 0, ASCIILINESZ); - last=0; - if (errs<0) { - fprintf(stderr, "iniparser: memory allocation failure\n"); - break ; + memset(section, 0, ASCIILINESZ); + memset(key, 0, ASCIILINESZ); + memset(val, 0, ASCIILINESZ); + last = 0; + + while (fgets(line + last, ASCIILINESZ - last, in) != NULL) { + lineno++; + len = (int)strlen(line) - 1; + if (len == 0) + continue; + /* Safety check against buffer overflows */ + if (line[len] != '\n') { + fprintf(stderr, + "iniparser: input line too long in %s (%d)\n", + ininame, + lineno); + dictionary_del(dict); + fclose(in); + return NULL; + } + /* Get rid of \n and spaces at end of line */ + while ((len >= 0) && ((line[len] == '\n') || (isspace(line[len])))) { + line[len] = 0; + len--; + } + /* Detect multi-line */ + if (line[len] == '\\') { + /* Multi-line value */ + last = len; + continue; + } else { + last = 0; + } + switch (iniparser_line(line, section, key, val)) { + case LINE_EMPTY: + case LINE_COMMENT: + break; + + case LINE_SECTION: + errs = dictionary_set(dict, section, NULL); + break; + + case LINE_VALUE: + if (strlen(section)) + sprintf(tmp, "%s:%s", section, key); + else + sprintf(tmp, "preferences:%s", key); + errs = dictionary_set(dict, tmp, val); + break; + + case LINE_ERROR: + fprintf(stderr, "iniparser: syntax error in %s (%d):\n", ininame, lineno); + fprintf(stderr, "-> %s\n", line); + errs++; + break; + + default: + break; + } + memset(line, 0, ASCIILINESZ); + last = 0; + if (errs < 0) { + fprintf(stderr, "iniparser: memory allocation failure\n"); + break; + } } - } - if (errs) { - dictionary_del(dict); - dict = NULL ; - } - fclose(in); - return dict ; + if (errs) { + dictionary_del(dict); + dict = NULL; + } + fclose(in); + return dict; } /*-------------------------------------------------------------------------*/ @@ -751,9 +750,9 @@ dictionary * iniparser_load(const char * ininame) gets out of the current context. */ /*--------------------------------------------------------------------------*/ -void iniparser_freedict(dictionary * d) +void iniparser_freedict(dictionary *d) { - dictionary_del(d); + dictionary_del(d); } /* vim: set ts=4 et sw=4 tw=75 */ diff --git a/src/common/iniparser.h b/src/common/iniparser.h index 8459212b..91e44fc6 100644 --- a/src/common/iniparser.h +++ b/src/common/iniparser.h @@ -46,8 +46,7 @@ */ /*--------------------------------------------------------------------------*/ -int iniparser_getnsec(dictionary * d); - +int iniparser_getnsec(dictionary *d); /*-------------------------------------------------------------------------*/ /** @@ -64,8 +63,7 @@ int iniparser_getnsec(dictionary * d); */ /*--------------------------------------------------------------------------*/ -char * iniparser_getsecname(dictionary * d, int n); - +char *iniparser_getsecname(dictionary *d, int n); /*-------------------------------------------------------------------------*/ /** @@ -79,7 +77,7 @@ char * iniparser_getsecname(dictionary * d, int n); */ /*--------------------------------------------------------------------------*/ -void iniparser_dump_ini(dictionary * d, FILE * f); +void iniparser_dump_ini(dictionary *d, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -94,7 +92,7 @@ void iniparser_dump_ini(dictionary * d, FILE * f); */ /*--------------------------------------------------------------------------*/ -void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f); +void iniparser_dumpsection_ini(dictionary *d, char *s, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -109,7 +107,7 @@ void iniparser_dumpsection_ini(dictionary * d, char * s, FILE * f); purposes mostly. */ /*--------------------------------------------------------------------------*/ -void iniparser_dump(dictionary * d, FILE * f); +void iniparser_dump(dictionary *d, FILE *f); /*-------------------------------------------------------------------------*/ /** @@ -119,7 +117,7 @@ void iniparser_dump(dictionary * d, FILE * f); @return Number of keys in section */ /*--------------------------------------------------------------------------*/ -int iniparser_getsecnkeys(dictionary * d, char * s); +int iniparser_getsecnkeys(dictionary *d, char *s); /*-------------------------------------------------------------------------*/ /** @@ -135,7 +133,7 @@ int iniparser_getsecnkeys(dictionary * d, char * s); This function returns NULL in case of error. */ /*--------------------------------------------------------------------------*/ -char ** iniparser_getseckeys(dictionary * d, char * s); +char **iniparser_getseckeys(dictionary *d, char *s); /*-------------------------------------------------------------------------*/ /** @@ -152,7 +150,7 @@ char ** iniparser_getseckeys(dictionary * d, char * s); the dictionary, do not free or modify it. */ /*--------------------------------------------------------------------------*/ -const char * iniparser_getstring(dictionary * d, const char * key, const char * def); +const char *iniparser_getstring(dictionary *d, const char *key, const char *def); /*-------------------------------------------------------------------------*/ /** @@ -181,7 +179,7 @@ const char * iniparser_getstring(dictionary * d, const char * key, const char * Credits: Thanks to A. Becker for suggesting strtol() */ /*--------------------------------------------------------------------------*/ -int iniparser_getint(dictionary * d, const char * key, int notfound); +int iniparser_getint(dictionary *d, const char *key, int notfound); /*-------------------------------------------------------------------------*/ /** @@ -196,7 +194,7 @@ int iniparser_getint(dictionary * d, const char * key, int notfound); the notfound value is returned. */ /*--------------------------------------------------------------------------*/ -double iniparser_getdouble(dictionary * d, const char * key, double notfound); +double iniparser_getdouble(dictionary *d, const char *key, double notfound); /*-------------------------------------------------------------------------*/ /** @@ -230,8 +228,7 @@ double iniparser_getdouble(dictionary * d, const char * key, double notfound); necessarily have to be 0 or 1. */ /*--------------------------------------------------------------------------*/ -int iniparser_getboolean(dictionary * d, const char * key, int notfound); - +int iniparser_getboolean(dictionary *d, const char *key, int notfound); /*-------------------------------------------------------------------------*/ /** @@ -246,8 +243,7 @@ int iniparser_getboolean(dictionary * d, const char * key, int notfound); It is Ok to set val to NULL. */ /*--------------------------------------------------------------------------*/ -int iniparser_set(dictionary * ini, const char * entry, const char * val); - +int iniparser_set(dictionary *ini, const char *entry, const char *val); /*-------------------------------------------------------------------------*/ /** @@ -259,7 +255,7 @@ int iniparser_set(dictionary * ini, const char * entry, const char * val); If the given entry can be found, it is deleted from the dictionary. */ /*--------------------------------------------------------------------------*/ -void iniparser_unset(dictionary * ini, const char * entry); +void iniparser_unset(dictionary *ini, const char *entry); /*-------------------------------------------------------------------------*/ /** @@ -273,7 +269,7 @@ void iniparser_unset(dictionary * ini, const char * entry); of querying for the presence of sections in a dictionary. */ /*--------------------------------------------------------------------------*/ -int iniparser_find_entry(dictionary * ini, const char * entry) ; +int iniparser_find_entry(dictionary *ini, const char *entry); /*-------------------------------------------------------------------------*/ /** @@ -289,7 +285,7 @@ int iniparser_find_entry(dictionary * ini, const char * entry) ; The returned dictionary must be freed using iniparser_freedict(). */ /*--------------------------------------------------------------------------*/ -dictionary * iniparser_load(const char * ininame); +dictionary *iniparser_load(const char *ininame); /*-------------------------------------------------------------------------*/ /** @@ -302,6 +298,6 @@ dictionary * iniparser_load(const char * ininame); gets out of the current context. */ /*--------------------------------------------------------------------------*/ -void iniparser_freedict(dictionary * d); +void iniparser_freedict(dictionary *d); #endif diff --git a/src/common/memgzio.c b/src/common/memgzio.c index 8d225d3d..5184653d 100644 --- a/src/common/memgzio.c +++ b/src/common/memgzio.c @@ -11,11 +11,11 @@ /* @(#) $Id$ */ -#include +#include #include +#include #include #include -#include #include "memgzio.h" @@ -24,7 +24,7 @@ #endif #ifndef DEF_MEM_LEVEL -# define DEF_MEM_LEVEL 8 +#define DEF_MEM_LEVEL 8 #endif #ifndef OS_CODE @@ -35,188 +35,187 @@ #define zmemcpy memcpy #endif - /*struct internal_state {int dummy;};*/ /* for buggy compilers */ #ifndef Z_BUFSIZE -# ifdef MAXSEG_64K -# define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ -# else -# define Z_BUFSIZE 16384 -# endif +#ifdef MAXSEG_64K +#define Z_BUFSIZE 4096 /* minimize memory usage for 16-bit DOS */ +#else +#define Z_BUFSIZE 16384 +#endif #endif #ifndef Z_PRINTF_BUFSIZE -# define Z_PRINTF_BUFSIZE 4096 +#define Z_PRINTF_BUFSIZE 4096 #endif #define ALLOC(size) malloc(size) -#define TRYFREE(p) {if (p) free(p);} +#define TRYFREE(p) \ + { \ + if (p) \ + free(p); \ + } -static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ +static int gz_magic[2] = { 0x1f, 0x8b }; /* gzip magic header */ /* gzip flag byte */ -#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ -#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ -#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ -#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ -#define COMMENT 0x10 /* bit 4 set: file comment present */ -#define RESERVED 0xE0 /* bits 5..7: reserved */ +#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ +#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ +#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ +#define ORIG_NAME 0x08 /* bit 3 set: original file name present */ +#define COMMENT 0x10 /* bit 4 set: file comment present */ +#define RESERVED 0xE0 /* bits 5..7: reserved */ typedef struct _MemFile { - char *memory; - char *next; - int available; - int error; - char mode; + char *memory; + char *next; + int available; + int error; + char mode; } MEMFILE; typedef struct mem_stream { - z_stream stream; - int z_err; /* error code for last stream operation */ - int z_eof; /* set if end of input file */ - MEMFILE *file; /* memoru file */ - Byte *inbuf; /* input buffer */ - Byte *outbuf; /* output buffer */ - uLong crc; /* crc32 of uncompressed data */ - char *msg; /* error message */ - int transparent; /* 1 if input file is not a .gz file */ - char mode; /* 'w' or 'r' */ - long startpos; /* start of compressed data in file (header skipped) */ + z_stream stream; + int z_err; /* error code for last stream operation */ + int z_eof; /* set if end of input file */ + MEMFILE *file; /* memoru file */ + Byte *inbuf; /* input buffer */ + Byte *outbuf; /* output buffer */ + uLong crc; /* crc32 of uncompressed data */ + char *msg; /* error message */ + int transparent; /* 1 if input file is not a .gz file */ + char mode; /* 'w' or 'r' */ + long startpos; /* start of compressed data in file (header skipped) */ } mem_stream; - -local gzFile gz_open OF((char *memory, const int available, const char *mode)); -local int do_flush OF((gzFile file, int flush)); -local int get_byte OF((mem_stream *s)); -local void check_header OF((mem_stream *s)); -local int destroy OF((mem_stream *s)); -local void putLong OF((MEMFILE *file, uLong x)); -local uLong getLong OF((mem_stream *s)); +local gzFile gz_open OF((char *memory, const int available, const char *mode)); +local int do_flush OF((gzFile file, int flush)); +local int get_byte OF((mem_stream * s)); +local void check_header OF((mem_stream * s)); +local int destroy OF((mem_stream * s)); +local void putLong OF((MEMFILE * file, uLong x)); +local uLong getLong OF((mem_stream * s)); local MEMFILE *memOpen(char *memory, int available, char mode) { - MEMFILE *f; + MEMFILE *f; - if(available <= 8) - return NULL; + if (available <= 8) + return NULL; - if(mode != 'w' && mode != 'r') - return NULL; + if (mode != 'w' && mode != 'r') + return NULL; - f = (MEMFILE *)malloc(sizeof(MEMFILE)); + f = (MEMFILE *)malloc(sizeof(MEMFILE)); - f->memory = memory; - f->mode = mode; - f->error = 0; + f->memory = memory; + f->mode = mode; + f->error = 0; - if(mode == 'w') { - f->available = available - 8; - f->next = memory + 8; - memory[0] = 'V'; - memory[1] = 'B'; - memory[2] = 'A'; - memory[3] = ' '; - *((int *)(memory+4)) = 0; - } else { - if(memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' || - memory[3] != ' ') { - free(f); - return NULL; - } - f->available = *((int *)(memory+4)); - f->next = memory+8; - } + if (mode == 'w') { + f->available = available - 8; + f->next = memory + 8; + memory[0] = 'V'; + memory[1] = 'B'; + memory[2] = 'A'; + memory[3] = ' '; + *((int *)(memory + 4)) = 0; + } else { + if (memory[0] != 'V' || memory[1] != 'B' || memory[2] != 'A' || memory[3] != ' ') { + free(f); + return NULL; + } + f->available = *((int *)(memory + 4)); + f->next = memory + 8; + } - return f; + return f; } -local size_t memWrite(const void *buffer, size_t size, size_t count, - MEMFILE *file) +local size_t memWrite(const void *buffer, size_t size, size_t count, MEMFILE *file) { - size_t total = size*count; + size_t total = size * count; - if(file->mode != 'w') { - file->error = 1; - return 0; - } + if (file->mode != 'w') { + file->error = 1; + return 0; + } - if(total > (size_t)file->available) { - total = file->available; - } - memcpy(file->next, buffer, total); - file->available -= (int)total; - file->next += total; - return total; + if (total > (size_t)file->available) { + total = file->available; + } + memcpy(file->next, buffer, total); + file->available -= (int)total; + file->next += total; + return total; } -local size_t memRead(void *buffer, size_t size, size_t count, - MEMFILE *file) +local size_t memRead(void *buffer, size_t size, size_t count, MEMFILE *file) { - size_t total = size*count; + size_t total = size * count; - if(file->mode != 'r') { - file->error = 1; - return 0; - } + if (file->mode != 'r') { + file->error = 1; + return 0; + } - if(file->available == 0) - return -1; + if (file->available == 0) + return -1; - if(total > (size_t)file->available) { - total = file->available; - } - memcpy(buffer, file->next, total); - file->available -= (int)total; - file->next += total; - return total; + if (total > (size_t)file->available) { + total = file->available; + } + memcpy(buffer, file->next, total); + file->available -= (int)total; + file->next += total; + return total; } local int memPutc(int c, MEMFILE *file) { - if(file->mode != 'w') { - file->error = 1; - return -1; - } + if (file->mode != 'w') { + file->error = 1; + return -1; + } - if(file->available >= 1) { - *file->next++ = c; - file->available--; - } else - return -1; + if (file->available >= 1) { + *file->next++ = c; + file->available--; + } else + return -1; - return c; + return c; } local long memTell(MEMFILE *f) { - return (long)(f->next - f->memory) - 8; + return (long)(f->next - f->memory) - 8; } local int memError(MEMFILE *f) { - return f->error; + return f->error; } local int memClose(MEMFILE *f) { - if(f->mode == 'w') { - *((int *)(f->memory+4)) = memTell(f); - } - free(f); - return 0; + if (f->mode == 'w') { + *((int *)(f->memory + 4)) = memTell(f); + } + free(f); + return 0; } local int memPrintf(MEMFILE *f, const char *format, ...) { - char buffer[80]; - va_list list; - int len; + char buffer[80]; + va_list list; + int len; - va_start(list, format); - len = vsprintf(buffer, format, list); - va_end(list); + va_start(list, format); + len = vsprintf(buffer, format, list); + va_end(list); - return (int)memWrite(buffer, 1, len, f); + return (int)memWrite(buffer, 1, len, f); } /* =========================================================================== @@ -228,115 +227,131 @@ local int memPrintf(MEMFILE *f, const char *format, ...) can be checked to distinguish the two cases (if errno is zero, the zlib error is Z_MEM_ERROR). */ -local gzFile gz_open (memory, available, mode) - char *memory; - const int available; - const char *mode; +local gzFile gz_open(memory, available, mode) char *memory; +const int available; +const char *mode; { - int err; - int level = Z_DEFAULT_COMPRESSION; /* compression level */ - int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ - char *p = (char*)mode; - mem_stream *s; - char fmode[80]; /* copy of mode, without the compression level */ - char *m = fmode; + int err; + int level = Z_DEFAULT_COMPRESSION; /* compression level */ + int strategy = Z_DEFAULT_STRATEGY; /* compression strategy */ + char *p = (char *)mode; + mem_stream *s; + char fmode[80]; /* copy of mode, without the compression level */ + char *m = fmode; - s = (mem_stream *)ALLOC(sizeof(mem_stream)); - if (!s) return Z_NULL; + s = (mem_stream *)ALLOC(sizeof(mem_stream)); + if (!s) + return Z_NULL; - s->stream.zalloc = (alloc_func)0; - s->stream.zfree = (free_func)0; - s->stream.opaque = (voidpf)0; - s->stream.next_in = s->inbuf = Z_NULL; - s->stream.next_out = s->outbuf = Z_NULL; - s->stream.avail_in = s->stream.avail_out = 0; - s->z_err = Z_OK; - s->z_eof = 0; - s->crc = crc32(0L, Z_NULL, 0); - s->msg = NULL; - s->transparent = 0; - s->file = NULL; + s->stream.zalloc = (alloc_func)0; + s->stream.zfree = (free_func)0; + s->stream.opaque = (voidpf)0; + s->stream.next_in = s->inbuf = Z_NULL; + s->stream.next_out = s->outbuf = Z_NULL; + s->stream.avail_in = s->stream.avail_out = 0; + s->z_err = Z_OK; + s->z_eof = 0; + s->crc = crc32(0L, Z_NULL, 0); + s->msg = NULL; + s->transparent = 0; + s->file = NULL; - s->mode = '\0'; - do { - if (*p == 'r') s->mode = 'r'; - if (*p == 'w' || *p == 'a') s->mode = 'w'; - if (*p >= '0' && *p <= '9') { - level = *p - '0'; - } else if (*p == 'f') { - strategy = Z_FILTERED; - } else if (*p == 'h') { - strategy = Z_HUFFMAN_ONLY; - } else { - *m++ = *p; /* copy the mode */ - } - } while (*p++ && m != fmode + sizeof(fmode)); - if (s->mode == '\0') return destroy(s), (gzFile)Z_NULL; + s->mode = '\0'; + do { + if (*p == 'r') + s->mode = 'r'; + if (*p == 'w' || *p == 'a') + s->mode = 'w'; + if (*p >= '0' && *p <= '9') { + level = *p - '0'; + } else if (*p == 'f') { + strategy = Z_FILTERED; + } else if (*p == 'h') { + strategy = Z_HUFFMAN_ONLY; + } else { + *m++ = *p; /* copy the mode */ + } + } while (*p++ && m != fmode + sizeof(fmode)); + if (s->mode == '\0') + return destroy(s), (gzFile)Z_NULL; - if (s->mode == 'w') { + if (s->mode == 'w') { #ifdef NO_DEFLATE - err = Z_STREAM_ERROR; + err = Z_STREAM_ERROR; #else - err = deflateInit2(&(s->stream), level, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, strategy); - /* windowBits is passed < 0 to suppress zlib header */ + err = deflateInit2(&(s->stream), + level, + Z_DEFLATED, + -MAX_WBITS, + DEF_MEM_LEVEL, + strategy); + /* windowBits is passed < 0 to suppress zlib header */ - s->stream.next_out = s->outbuf = (Byte*)ALLOC(Z_BUFSIZE); + s->stream.next_out = s->outbuf = (Byte *)ALLOC(Z_BUFSIZE); #endif - if (err != Z_OK || s->outbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; + if (err != Z_OK || s->outbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } + } else { + s->stream.next_in = s->inbuf = (Byte *)ALLOC(Z_BUFSIZE); + + err = inflateInit2(&(s->stream), -MAX_WBITS); + /* windowBits is passed < 0 to tell that there is no zlib header. + * Note that in this case inflate *requires* an extra "dummy" byte + * after the compressed stream in order to complete decompression and + * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are + * present after the compressed stream. + */ + if (err != Z_OK || s->inbuf == Z_NULL) { + return destroy(s), (gzFile)Z_NULL; + } } - } else { - s->stream.next_in = s->inbuf = (Byte*)ALLOC(Z_BUFSIZE); + s->stream.avail_out = Z_BUFSIZE; - err = inflateInit2(&(s->stream), -MAX_WBITS); - /* windowBits is passed < 0 to tell that there is no zlib header. - * Note that in this case inflate *requires* an extra "dummy" byte - * after the compressed stream in order to complete decompression and - * return Z_STREAM_END. Here the gzip CRC32 ensures that 4 bytes are - * present after the compressed stream. - */ - if (err != Z_OK || s->inbuf == Z_NULL) { - return destroy(s), (gzFile)Z_NULL; + errno = 0; + s->file = memOpen(memory, available, s->mode); + + if (s->file == NULL) { + return destroy(s), (gzFile)Z_NULL; } - } - s->stream.avail_out = Z_BUFSIZE; - errno = 0; - s->file = memOpen(memory, available, s->mode); + if (s->mode == 'w') { + /* Write a very simple .gz header: + */ + memPrintf(s->file, + "%c%c%c%c%c%c%c%c%c%c", + gz_magic[0], + gz_magic[1], + Z_DEFLATED, + 0 /*flags*/, + 0, + 0, + 0, + 0 /*time*/, + 0 /*xflags*/, + OS_CODE); + s->startpos = 10L; + /* We use 10L instead of ftell(s->file) to because ftell causes an + * fflush on some systems. This version of the library doesn't use + * startpos anyway in write mode, so this initialization is not + * necessary. + */ + } else { + check_header(s); /* skip the .gz header */ + s->startpos = (memTell(s->file) - s->stream.avail_in); + } - if (s->file == NULL) { - return destroy(s), (gzFile)Z_NULL; - } - - if (s->mode == 'w') { - /* Write a very simple .gz header: - */ - memPrintf(s->file, "%c%c%c%c%c%c%c%c%c%c", gz_magic[0], gz_magic[1], - Z_DEFLATED, 0 /*flags*/, 0,0,0,0 /*time*/, 0 /*xflags*/, OS_CODE); - s->startpos = 10L; - /* We use 10L instead of ftell(s->file) to because ftell causes an - * fflush on some systems. This version of the library doesn't use - * startpos anyway in write mode, so this initialization is not - * necessary. - */ - } else { - check_header(s); /* skip the .gz header */ - s->startpos = (memTell(s->file) - s->stream.avail_in); - } - - return (gzFile)s; + return (gzFile)s; } /* =========================================================================== Opens a gzip (.gz) file for reading or writing. */ -gzFile ZEXPORT memgzopen (memory, available, mode) - char *memory; - int available; - const char *mode; +gzFile ZEXPORT memgzopen(memory, available, mode) char *memory; +int available; +const char *mode; { - return gz_open (memory, available, mode); + return gz_open(memory, available, mode); } /* =========================================================================== @@ -344,22 +359,23 @@ gzFile ZEXPORT memgzopen (memory, available, mode) for end of file. IN assertion: the stream s has been sucessfully opened for reading. */ -local int get_byte(s) - mem_stream *s; +local int get_byte(s) mem_stream *s; { - if (s->z_eof) return EOF; - if (s->stream.avail_in == 0) { - errno = 0; - s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (memError(s->file)) s->z_err = Z_ERRNO; - return EOF; - } - s->stream.next_in = s->inbuf; - } - s->stream.avail_in--; - return *(s->stream.next_in)++; + if (s->z_eof) + return EOF; + if (s->stream.avail_in == 0) { + errno = 0; + s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (memError(s->file)) + s->z_err = Z_ERRNO; + return EOF; + } + s->stream.next_in = s->inbuf; + } + s->stream.avail_in--; + return *(s->stream.next_in)++; } /* =========================================================================== @@ -371,350 +387,361 @@ local int get_byte(s) s->stream.avail_in is zero for the first time, but may be non-zero for concatenated .gz files. */ -local void check_header(s) - mem_stream *s; +local void check_header(s) mem_stream *s; { - int method; /* method byte */ - int flags; /* flags byte */ - uInt len; - int c; + int method; /* method byte */ + int flags; /* flags byte */ + uInt len; + int c; - /* Check the gzip magic header */ - for (len = 0; len < 2; len++) { - c = get_byte(s); - if (c != gz_magic[len]) { - if (len != 0) s->stream.avail_in++, s->stream.next_in--; - if (c != EOF) { - s->stream.avail_in++, s->stream.next_in--; - s->transparent = 1; - } - s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; - return; - } - } - method = get_byte(s); - flags = get_byte(s); - if (method != Z_DEFLATED || (flags & RESERVED) != 0) { - s->z_err = Z_DATA_ERROR; - return; - } + /* Check the gzip magic header */ + for (len = 0; len < 2; len++) { + c = get_byte(s); + if (c != gz_magic[len]) { + if (len != 0) + s->stream.avail_in++, s->stream.next_in--; + if (c != EOF) { + s->stream.avail_in++, s->stream.next_in--; + s->transparent = 1; + } + s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END; + return; + } + } + method = get_byte(s); + flags = get_byte(s); + if (method != Z_DEFLATED || (flags & RESERVED) != 0) { + s->z_err = Z_DATA_ERROR; + return; + } - /* Discard time, xflags and OS code: */ - for (len = 0; len < 6; len++) (void)get_byte(s); + /* Discard time, xflags and OS code: */ + for (len = 0; len < 6; len++) + (void)get_byte(s); - if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ - len = (uInt)get_byte(s); - len += ((uInt)get_byte(s))<<8; - /* len is garbage if EOF but the loop below will quit anyway */ - while (len-- != 0 && get_byte(s) != EOF) ; - } - if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ - while ((c = get_byte(s)) != 0 && c != EOF) ; - } - if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ - for (len = 0; len < 2; len++) (void)get_byte(s); - } - s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; + if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */ + len = (uInt)get_byte(s); + len += ((uInt)get_byte(s)) << 8; + /* len is garbage if EOF but the loop below will quit anyway */ + while (len-- != 0 && get_byte(s) != EOF) + ; + } + if ((flags & ORIG_NAME) != 0) { /* skip the original file name */ + while ((c = get_byte(s)) != 0 && c != EOF) + ; + } + if ((flags & COMMENT) != 0) { /* skip the .gz file comment */ + while ((c = get_byte(s)) != 0 && c != EOF) + ; + } + if ((flags & HEAD_CRC) != 0) { /* skip the header crc */ + for (len = 0; len < 2; len++) + (void)get_byte(s); + } + s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK; } - /* =========================================================================== - * Cleanup then free the given mem_stream. Return a zlib error code. - Try freeing in the reverse order of allocations. - */ -local int destroy (s) - mem_stream *s; +/* =========================================================================== +* Cleanup then free the given mem_stream. Return a zlib error code. + Try freeing in the reverse order of allocations. +*/ +local int destroy(s) mem_stream *s; { - int err = Z_OK; + int err = Z_OK; - if (!s) return Z_STREAM_ERROR; + if (!s) + return Z_STREAM_ERROR; - TRYFREE(s->msg); + TRYFREE(s->msg); - if (s->stream.state != NULL) { - if (s->mode == 'w') { + if (s->stream.state != NULL) { + if (s->mode == 'w') { #ifdef NO_DEFLATE - err = Z_STREAM_ERROR; + err = Z_STREAM_ERROR; #else - err = deflateEnd(&(s->stream)); + err = deflateEnd(&(s->stream)); #endif - } else if (s->mode == 'r') { - err = inflateEnd(&(s->stream)); - } - } - if (s->file != NULL && memClose(s->file)) { + } else if (s->mode == 'r') { + err = inflateEnd(&(s->stream)); + } + } + if (s->file != NULL && memClose(s->file)) { #ifdef ESPIPE - if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ + if (errno != ESPIPE) /* fclose is broken for pipes in HP/UX */ #endif - err = Z_ERRNO; - } - if (s->z_err < 0) err = s->z_err; + err = Z_ERRNO; + } + if (s->z_err < 0) + err = s->z_err; - TRYFREE(s->inbuf); - TRYFREE(s->outbuf); - TRYFREE(s); - return err; + TRYFREE(s->inbuf); + TRYFREE(s->outbuf); + TRYFREE(s); + return err; } /* =========================================================================== Reads the given number of uncompressed bytes from the compressed file. gzread returns the number of bytes actually read (0 for end of file). */ -int ZEXPORT memgzread (file, buf, len) - gzFile file; - voidp buf; - unsigned len; +int ZEXPORT memgzread(file, buf, len) gzFile file; +voidp buf; +unsigned len; { - mem_stream *s = (mem_stream*)file; - Bytef *start = (Bytef*)buf; /* starting point for crc computation */ - Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ + mem_stream *s = (mem_stream *)file; + Bytef *start = (Bytef *)buf; /* starting point for crc computation */ + Byte *next_out; /* == stream.next_out but not forced far (for MSDOS) */ - if (s == NULL || s->mode != 'r') return Z_STREAM_ERROR; + if (s == NULL || s->mode != 'r') + return Z_STREAM_ERROR; - if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1; - if (s->z_err == Z_STREAM_END) return 0; /* EOF */ + if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) + return -1; + if (s->z_err == Z_STREAM_END) + return 0; /* EOF */ - next_out = (Byte*)buf; - s->stream.next_out = (Bytef*)buf; - s->stream.avail_out = len; + next_out = (Byte *)buf; + s->stream.next_out = (Bytef *)buf; + s->stream.avail_out = len; - while (s->stream.avail_out != 0) { + while (s->stream.avail_out != 0) { + if (s->transparent) { + /* Copy first the lookahead bytes: */ + uInt n = s->stream.avail_in; + if (n > s->stream.avail_out) + n = s->stream.avail_out; + if (n > 0) { + zmemcpy(s->stream.next_out, s->stream.next_in, n); + next_out += n; + s->stream.next_out = next_out; + s->stream.next_in += n; + s->stream.avail_out -= n; + s->stream.avail_in -= n; + } + if (s->stream.avail_out > 0) { + s->stream.avail_out -= + (uInt)memRead(next_out, 1, s->stream.avail_out, s->file); + } + len -= s->stream.avail_out; + s->stream.total_in += (uLong)len; + s->stream.total_out += (uLong)len; + if (len == 0) + s->z_eof = 1; + return (int)len; + } + if (s->stream.avail_in == 0 && !s->z_eof) { + errno = 0; + s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file); + if (s->stream.avail_in == 0) { + s->z_eof = 1; + if (memError(s->file)) { + s->z_err = Z_ERRNO; + break; + } + } + s->stream.next_in = s->inbuf; + } + s->z_err = inflate(&(s->stream), Z_NO_FLUSH); - if (s->transparent) { - /* Copy first the lookahead bytes: */ - uInt n = s->stream.avail_in; - if (n > s->stream.avail_out) n = s->stream.avail_out; - if (n > 0) { - zmemcpy(s->stream.next_out, s->stream.next_in, n); - next_out += n; - s->stream.next_out = next_out; - s->stream.next_in += n; - s->stream.avail_out -= n; - s->stream.avail_in -= n; - } - if (s->stream.avail_out > 0) { - s->stream.avail_out -= (uInt)memRead(next_out, 1, s->stream.avail_out, s->file); - } - len -= s->stream.avail_out; - s->stream.total_in += (uLong)len; - s->stream.total_out += (uLong)len; - if (len == 0) s->z_eof = 1; - return (int)len; - } - if (s->stream.avail_in == 0 && !s->z_eof) { + if (s->z_err == Z_STREAM_END) { + /* Check CRC and original size */ + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); + start = s->stream.next_out; - errno = 0; - s->stream.avail_in = (uInt)memRead(s->inbuf, 1, Z_BUFSIZE, s->file); - if (s->stream.avail_in == 0) { - s->z_eof = 1; - if (memError(s->file)) { - s->z_err = Z_ERRNO; - break; - } - } - s->stream.next_in = s->inbuf; + if (getLong(s) != s->crc) { + s->z_err = Z_DATA_ERROR; + } else { + (void)getLong(s); + /* The uncompressed length returned by above getlong() may + * be different from s->stream.total_out) in case of + * concatenated .gz files. Check for such files: + */ + check_header(s); + if (s->z_err == Z_OK) { + uLong total_in = s->stream.total_in; + uLong total_out = s->stream.total_out; + + inflateReset(&(s->stream)); + s->stream.total_in = total_in; + s->stream.total_out = total_out; + s->crc = crc32(0L, Z_NULL, 0); + } + } + } + if (s->z_err != Z_OK || s->z_eof) + break; } - s->z_err = inflate(&(s->stream), Z_NO_FLUSH); + s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - if (s->z_err == Z_STREAM_END) { - /* Check CRC and original size */ - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - start = s->stream.next_out; - - if (getLong(s) != s->crc) { - s->z_err = Z_DATA_ERROR; - } else { - (void)getLong(s); - /* The uncompressed length returned by above getlong() may - * be different from s->stream.total_out) in case of - * concatenated .gz files. Check for such files: - */ - check_header(s); - if (s->z_err == Z_OK) { - uLong total_in = s->stream.total_in; - uLong total_out = s->stream.total_out; - - inflateReset(&(s->stream)); - s->stream.total_in = total_in; - s->stream.total_out = total_out; - s->crc = crc32(0L, Z_NULL, 0); - } - } - } - if (s->z_err != Z_OK || s->z_eof) break; - } - s->crc = crc32(s->crc, start, (uInt)(s->stream.next_out - start)); - - return (int)(len - s->stream.avail_out); + return (int)(len - s->stream.avail_out); } - #ifndef NO_DEFLATE /* =========================================================================== Writes the given number of uncompressed bytes into the compressed file. gzwrite returns the number of bytes actually written (0 in case of error). */ -int ZEXPORT memgzwrite (file, buf, len) - gzFile file; - const voidp buf; - unsigned len; +int ZEXPORT memgzwrite(file, buf, len) gzFile file; +const voidp buf; +unsigned len; { - mem_stream *s = (mem_stream*)file; + mem_stream *s = (mem_stream *)file; - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + if (s == NULL || s->mode != 'w') + return Z_STREAM_ERROR; - s->stream.next_in = (Bytef*)buf; - s->stream.avail_in = len; + s->stream.next_in = (Bytef *)buf; + s->stream.avail_in = len; - while (s->stream.avail_in != 0) { - - if (s->stream.avail_out == 0) { - - s->stream.next_out = s->outbuf; - if (memWrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { - s->z_err = Z_ERRNO; - break; - } - s->stream.avail_out = Z_BUFSIZE; + while (s->stream.avail_in != 0) { + if (s->stream.avail_out == 0) { + s->stream.next_out = s->outbuf; + if (memWrite(s->outbuf, 1, Z_BUFSIZE, s->file) != Z_BUFSIZE) { + s->z_err = Z_ERRNO; + break; + } + s->stream.avail_out = Z_BUFSIZE; + } + s->z_err = deflate(&(s->stream), Z_NO_FLUSH); + if (s->z_err != Z_OK) + break; } - s->z_err = deflate(&(s->stream), Z_NO_FLUSH); - if (s->z_err != Z_OK) break; - } - s->crc = crc32(s->crc, (const Bytef *)buf, len); + s->crc = crc32(s->crc, (const Bytef *)buf, len); - return (int)(len - s->stream.avail_in); + return (int)(len - s->stream.avail_in); } #endif /* =========================================================================== Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. */ -local int do_flush (file, flush) - gzFile file; - int flush; +local int do_flush(file, flush) gzFile file; +int flush; { - uInt len; - int done = 0; - mem_stream *s = (mem_stream*)file; + uInt len; + int done = 0; + mem_stream *s = (mem_stream *)file; - if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; + if (s == NULL || s->mode != 'w') + return Z_STREAM_ERROR; - s->stream.avail_in = 0; /* should be zero already anyway */ + s->stream.avail_in = 0; /* should be zero already anyway */ - for (;;) { - len = Z_BUFSIZE - s->stream.avail_out; + for (;;) { + len = Z_BUFSIZE - s->stream.avail_out; - if (len != 0) { - if ((uInt)memWrite(s->outbuf, 1, len, s->file) != len) { - s->z_err = Z_ERRNO; - return Z_ERRNO; - } - s->stream.next_out = s->outbuf; - s->stream.avail_out = Z_BUFSIZE; + if (len != 0) { + if ((uInt)memWrite(s->outbuf, 1, len, s->file) != len) { + s->z_err = Z_ERRNO; + return Z_ERRNO; + } + s->stream.next_out = s->outbuf; + s->stream.avail_out = Z_BUFSIZE; + } + if (done) + break; + s->z_err = deflate(&(s->stream), flush); + + /* Ignore the second of two consecutive flushes: */ + if (len == 0 && s->z_err == Z_BUF_ERROR) + s->z_err = Z_OK; + + /* deflate has finished flushing only when it hasn't used up + * all the available space in the output buffer: + */ + done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); + + if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) + break; } - if (done) break; - s->z_err = deflate(&(s->stream), flush); - - /* Ignore the second of two consecutive flushes: */ - if (len == 0 && s->z_err == Z_BUF_ERROR) s->z_err = Z_OK; - - /* deflate has finished flushing only when it hasn't used up - * all the available space in the output buffer: - */ - done = (s->stream.avail_out != 0 || s->z_err == Z_STREAM_END); - - if (s->z_err != Z_OK && s->z_err != Z_STREAM_END) break; - } - return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; + return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } /* =========================================================================== Outputs a long in LSB order to the given file */ -local void putLong (file, x) - MEMFILE *file; - uLong x; +local void putLong(file, x) MEMFILE *file; +uLong x; { - int n; - for (n = 0; n < 4; n++) { - memPutc((int)(x & 0xff), file); - x >>= 8; - } + int n; + for (n = 0; n < 4; n++) { + memPutc((int)(x & 0xff), file); + x >>= 8; + } } /* =========================================================================== Reads a long in LSB order from the given mem_stream. Sets z_err in case of error. */ -local uLong getLong (s) - mem_stream *s; +local uLong getLong(s) mem_stream *s; { - uLong x = (uLong)get_byte(s); - int c; + uLong x = (uLong)get_byte(s); + int c; - x += ((uLong)get_byte(s))<<8; - x += ((uLong)get_byte(s))<<16; - c = get_byte(s); - if (c == EOF) s->z_err = Z_DATA_ERROR; - x += ((uLong)c)<<24; - return x; + x += ((uLong)get_byte(s)) << 8; + x += ((uLong)get_byte(s)) << 16; + c = get_byte(s); + if (c == EOF) + s->z_err = Z_DATA_ERROR; + x += ((uLong)c) << 24; + return x; } /* =========================================================================== Flushes all pending output if necessary, closes the compressed file and deallocates all the (de)compression state. */ -int ZEXPORT memgzclose (file) - gzFile file; +int ZEXPORT memgzclose(file) gzFile file; { - int err; - mem_stream *s = (mem_stream*)file; + int err; + mem_stream *s = (mem_stream *)file; - if (s == NULL) return Z_STREAM_ERROR; + if (s == NULL) + return Z_STREAM_ERROR; - if (s->mode == 'w') { + if (s->mode == 'w') { #ifdef NO_DEFLATE - return Z_STREAM_ERROR; + return Z_STREAM_ERROR; #else - err = do_flush (file, Z_FINISH); - if (err != Z_OK) return destroy((mem_stream*)file); + err = do_flush(file, Z_FINISH); + if (err != Z_OK) + return destroy((mem_stream *)file); - putLong (s->file, s->crc); - putLong (s->file, s->stream.total_in); + putLong(s->file, s->crc); + putLong(s->file, s->stream.total_in); #endif - } - return destroy((mem_stream*)file); + } + return destroy((mem_stream *)file); } -long ZEXPORT memtell(file) - gzFile file; +long ZEXPORT memtell(file) gzFile file; { - do_flush (file, Z_FULL_FLUSH); // makes memtell to tell truth - mem_stream *s = (mem_stream*)file; + do_flush(file, Z_FULL_FLUSH); // makes memtell to tell truth + mem_stream *s = (mem_stream *)file; - if (s == NULL) return Z_STREAM_ERROR; + if (s == NULL) + return Z_STREAM_ERROR; - return memTell(s->file); + return memTell(s->file); } z_off_t ZEXPORT memgzseek(gzFile file, z_off_t off, int whence) { - char buf[80]; + char buf[80]; - if(whence != SEEK_CUR) { - fputs("FIXME: memgzio does not support seeking\n", stderr); - exit(1); - } + if (whence != SEEK_CUR) { + fputs("FIXME: memgzio does not support seeking\n", stderr); + exit(1); + } - // this is inefficient, but the best I can do without actually reading - // the above code - while(off > 0) { - int r = memgzread(file, buf, off > 80 ? 80 : off); - if(r <= 0) - return -1; - off -= r; - } - return memtell(file); + // this is inefficient, but the best I can do without actually reading + // the above code + while (off > 0) { + int r = memgzread(file, buf, off > 80 ? 80 : off); + if (r <= 0) + return -1; + off -= r; + } + return memtell(file); } diff --git a/src/filters/hq/c/hq3x_pattern.h b/src/filters/hq/c/hq3x_pattern.h index d1180390..1202fe89 100644 --- a/src/filters/hq/c/hq3x_pattern.h +++ b/src/filters/hq/c/hq3x_pattern.h @@ -1,7 +1,7 @@ /* VisualBoyAdvance - a Game Boy & Game Boy Advance emulator - Copyright (C) 1999 - 2003 Forgotten + Copyright (C) 1999 - 2003 Forgotten Copyright (C) 2003 - 2004 Forgotten and the VBA development team Copyright (C) 2005 - 2006 VBA development team @@ -21,8 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -switch(pattern) -{ +switch (pattern) { case 0: case 1: case 4: @@ -38,3602 +37,2913 @@ case 133: case 164: case 161: case 37: -case 165: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } +case 165: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} case 2: case 34: case 130: -case 162: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } +case 162: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} case 16: case 17: case 48: -case 49: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } +case 49: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} case 64: case 65: case 68: -case 69: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } +case 69: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} case 8: case 12: case 136: -case 140: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } +case 140: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} case 3: case 35: case 131: -case 163: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } +case 163: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} case 6: case 38: case 134: -case 166: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } +case 166: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} case 20: case 21: case 52: -case 53: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1U - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } +case 53: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} case 144: case 145: case 176: -case 177: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1D - break; - } +case 177: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; +} case 192: case 193: case 196: -case 197: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } +case 197: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} case 96: case 97: case 100: -case 101: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } +case 101: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} case 40: case 44: case 168: -case 172: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1D - PIXEL21_1 - PIXEL22_2 - break; - } +case 172: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; +} case 9: case 13: case 137: -case 141: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } +case 141: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} case 18: -case 50: - { - PIXEL00_1M +case 50: { + PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_1M - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_1M + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} case 80: -case 81: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_1M - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } +case 81: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_1M + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} case 72: -case 76: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_1M - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } +case 76: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_1M + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} case 10: -case 138: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } -case 66: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 24: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } +case 138: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} +case 66: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 24: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} case 7: case 39: -case 135: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } +case 135: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} case 148: case 149: -case 180: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1U - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1D - break; - } +case 180: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; +} case 224: case 228: -case 225: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } +case 225: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} case 41: case 169: -case 45: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1D - PIXEL21_1 - PIXEL22_2 - break; - } -case 22: -case 54: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } -case 208: -case 209: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 104: -case 108: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 11: -case 139: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } -case 19: -case 51: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL12_C - } - else - { - PIXEL00_2 - PIXEL01_6 - PIXEL02_5 - PIXEL12_1 - } - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } -case 146: -case 178: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_1M - PIXEL12_C - PIXEL22_1D - } - else - { - PIXEL01_1 - PIXEL02_5 - PIXEL12_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - break; - } -case 84: -case 85: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL02_1U - PIXEL12_C - PIXEL21_C - PIXEL22_1M - } - else - { - PIXEL02_2 - PIXEL12_6 - PIXEL21_1 - PIXEL22_5 - } - PIXEL00_2 - PIXEL01_1 - PIXEL10_1 - PIXEL11 - PIXEL20_1M - break; - } -case 112: -case 113: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - } - else - { - PIXEL12_1 - PIXEL20_2 - PIXEL21_6 - PIXEL22_5 - } - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - break; - } -case 200: -case 204: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - } - else - { - PIXEL10_1 - PIXEL20_5 - PIXEL21_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - break; - } -case 73: -case 77: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_1U - PIXEL10_C - PIXEL20_1M - PIXEL21_C - } - else - { - PIXEL00_2 - PIXEL10_6 - PIXEL20_5 - PIXEL21_1 - } - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - PIXEL22_1M - break; - } -case 42: -case 170: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - PIXEL01_C - PIXEL10_C - PIXEL20_1D - } - else - { - PIXEL00_5 - PIXEL01_1 - PIXEL10_6 - PIXEL20_2 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL21_1 - PIXEL22_2 - break; - } -case 14: -case 142: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_C - } - else - { - PIXEL00_5 - PIXEL01_6 - PIXEL02_2 - PIXEL10_1 - } - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } -case 67: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 70: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 28: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 152: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 194: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 98: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 56: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 25: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 26: -case 31: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL10_3 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL02_4 - PIXEL12_3 - } - PIXEL11 - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 82: -case 214: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - } - else - { - PIXEL01_3 - PIXEL02_4 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 88: -case 248: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - } - else - { - PIXEL10_3 - PIXEL20_4 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL22_4 - } - break; - } -case 74: -case 107: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - } - else - { - PIXEL00_4 - PIXEL01_3 - } - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 27: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 86: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_1 - PIXEL11 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 216: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 106: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 30: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_C - PIXEL11 - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 210: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 120: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 75: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 29: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1M - break; - } -case 198: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 184: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 99: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 57: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 71: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 156: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 226: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } -case 60: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 195: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 102: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 153: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 58: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 83: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 92: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 202: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 78: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1M - break; - } -case 154: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 114: - { - PIXEL00_1M - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 89: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 90: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 55: -case 23: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_1L - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL00_2 - PIXEL01_6 - PIXEL02_5 - PIXEL12_1 - } - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - PIXEL22_1M - break; - } -case 182: -case 150: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - PIXEL22_1D - } - else - { - PIXEL01_1 - PIXEL02_5 - PIXEL12_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL10_1 - PIXEL11 - PIXEL20_2 - PIXEL21_1 - break; - } -case 213: -case 212: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL02_1U - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL02_2 - PIXEL12_6 - PIXEL21_1 - PIXEL22_5 - } - PIXEL00_2 - PIXEL01_1 - PIXEL10_1 - PIXEL11 - PIXEL20_1M - break; - } -case 241: -case 240: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL20_1L - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_1 - PIXEL20_2 - PIXEL21_6 - PIXEL22_5 - } - PIXEL00_2 - PIXEL01_1 - PIXEL02_1M - PIXEL10_1 - PIXEL11 - break; - } -case 236: -case 232: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - PIXEL22_1R - } - else - { - PIXEL10_1 - PIXEL20_5 - PIXEL21_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - break; - } -case 109: -case 105: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_1U - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL00_2 - PIXEL10_6 - PIXEL20_5 - PIXEL21_1 - } - PIXEL01_1 - PIXEL02_2 - PIXEL11 - PIXEL12_1 - PIXEL22_1M - break; - } -case 171: -case 43: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - PIXEL20_1D - } - else - { - PIXEL00_5 - PIXEL01_1 - PIXEL10_6 - PIXEL20_2 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL21_1 - PIXEL22_2 - break; - } -case 143: -case 15: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL02_1R - PIXEL10_C - } - else - { - PIXEL00_5 - PIXEL01_6 - PIXEL02_2 - PIXEL10_1 - } - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_1 - PIXEL22_2 - break; - } -case 124: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 203: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 62: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_C - PIXEL11 - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 211: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 118: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_1 - PIXEL11 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 217: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 110: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 155: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 188: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 185: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 61: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 157: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 103: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 227: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } -case 230: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } -case 199: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 220: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 158: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_C - PIXEL11 - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 234: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1M - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1R - break; - } -case 242: - { - PIXEL00_1M - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL20_1L - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 59: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 121: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 87: - { - PIXEL00_1L - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_1 - PIXEL11 - PIXEL20_1M - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 79: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1R - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1M - break; - } -case 122: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 94: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_C - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 218: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 91: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 229: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_2 - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } -case 167: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_2 - PIXEL21_1 - PIXEL22_2 - break; - } -case 173: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1D - PIXEL21_1 - PIXEL22_2 - break; - } -case 181: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1U - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1D - break; - } -case 186: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 115: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 93: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 206: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 205: -case 201: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_1M - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 174: -case 46: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_1M - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1D - PIXEL21_1 - PIXEL22_2 - break; - } -case 179: -case 147: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_1M - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1D - break; - } -case 117: -case 116: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1U - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_1M - } - else - { - PIXEL22_2 - } - break; - } -case 189: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 231: - { - PIXEL00_1L - PIXEL01_C - PIXEL02_1R - PIXEL10_1 - PIXEL11 - PIXEL12_1 - PIXEL20_1L - PIXEL21_C - PIXEL22_1R - break; - } -case 126: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_4 - PIXEL12_3 - } - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 219: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL01_3 - PIXEL10_3 - } - PIXEL02_1M - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 125: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_1U - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL00_2 - PIXEL10_6 - PIXEL20_5 - PIXEL21_1 - } - PIXEL01_1 - PIXEL02_1U - PIXEL11 - PIXEL12_C - PIXEL22_1M - break; - } -case 221: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL02_1U - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL02_2 - PIXEL12_6 - PIXEL21_1 - PIXEL22_5 - } - PIXEL00_1U - PIXEL01_1 - PIXEL10_C - PIXEL11 - PIXEL20_1M - break; - } -case 207: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL02_1R - PIXEL10_C - } - else - { - PIXEL00_5 - PIXEL01_6 - PIXEL02_2 - PIXEL10_1 - } - PIXEL11 - PIXEL12_1 - PIXEL20_1M - PIXEL21_C - PIXEL22_1R - break; - } -case 238: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - PIXEL22_1R - } - else - { - PIXEL10_1 - PIXEL20_5 - PIXEL21_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL01_C - PIXEL02_1R - PIXEL11 - PIXEL12_1 - break; - } -case 190: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - PIXEL22_1D - } - else - { - PIXEL01_1 - PIXEL02_5 - PIXEL12_6 - PIXEL22_2 - } - PIXEL00_1M - PIXEL10_C - PIXEL11 - PIXEL20_1D - PIXEL21_1 - break; - } -case 187: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - PIXEL20_1D - } - else - { - PIXEL00_5 - PIXEL01_1 - PIXEL10_6 - PIXEL20_2 - } - PIXEL02_1M - PIXEL11 - PIXEL12_C - PIXEL21_1 - PIXEL22_1D - break; - } -case 243: - { - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL20_1L - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_1 - PIXEL20_2 - PIXEL21_6 - PIXEL22_5 - } - PIXEL00_1L - PIXEL01_C - PIXEL02_1M - PIXEL10_1 - PIXEL11 - break; - } -case 119: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_1L - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL00_2 - PIXEL01_6 - PIXEL02_5 - PIXEL12_1 - } - PIXEL10_1 - PIXEL11 - PIXEL20_1L - PIXEL21_C - PIXEL22_1M - break; - } -case 237: -case 233: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_2 - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 175: -case 47: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - PIXEL20_1D - PIXEL21_1 - PIXEL22_2 - break; - } -case 183: -case 151: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_2 - PIXEL21_1 - PIXEL22_1D - break; - } -case 245: -case 244: - { - PIXEL00_2 - PIXEL01_1 - PIXEL02_1U - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } -case 250: - { - PIXEL00_1M - PIXEL01_C - PIXEL02_1M - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - } - else - { - PIXEL10_3 - PIXEL20_4 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL22_4 - } - break; - } -case 123: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - } - else - { - PIXEL00_4 - PIXEL01_3 - } - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 95: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL10_3 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL02_4 - PIXEL12_3 - } - PIXEL11 - PIXEL20_1M - PIXEL21_C - PIXEL22_1M - break; - } -case 222: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - } - else - { - PIXEL01_3 - PIXEL02_4 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 252: - { - PIXEL00_1M - PIXEL01_1 - PIXEL02_1U - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - } - else - { - PIXEL10_3 - PIXEL20_4 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } -case 249: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1M - PIXEL10_C - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL22_4 - } - break; - } -case 235: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - } - else - { - PIXEL00_4 - PIXEL01_3 - } - PIXEL02_1M - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 111: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 63: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL02_4 - PIXEL12_3 - } - PIXEL10_C - PIXEL11 - PIXEL20_1D - PIXEL21_1 - PIXEL22_1M - break; - } -case 159: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL10_3 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL11 - PIXEL12_C - PIXEL20_1M - PIXEL21_1 - PIXEL22_1D - break; - } -case 215: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 246: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - } - else - { - PIXEL01_3 - PIXEL02_4 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } -case 254: - { - PIXEL00_1M - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - } - else - { - PIXEL01_3 - PIXEL02_4 - } - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - } - else - { - PIXEL10_3 - PIXEL20_4 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL21_3 - PIXEL22_2 - } - break; - } -case 253: - { - PIXEL00_1U - PIXEL01_1 - PIXEL02_1U - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } -case 251: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - } - else - { - PIXEL00_4 - PIXEL01_3 - } - PIXEL02_1M - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL10_C - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL10_3 - PIXEL20_2 - PIXEL21_3 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL12_C - PIXEL22_C - } - else - { - PIXEL12_3 - PIXEL22_4 - } - break; - } -case 239: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - PIXEL02_1R - PIXEL10_C - PIXEL11 - PIXEL12_1 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - PIXEL22_1R - break; - } -case 127: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL01_C - PIXEL10_C - } - else - { - PIXEL00_2 - PIXEL01_3 - PIXEL10_3 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL02_4 - PIXEL12_3 - } - PIXEL11 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - PIXEL21_C - } - else - { - PIXEL20_4 - PIXEL21_3 - } - PIXEL22_1M - break; - } -case 191: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - PIXEL20_1D - PIXEL21_1 - PIXEL22_1D - break; - } -case 223: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - PIXEL10_C - } - else - { - PIXEL00_4 - PIXEL10_3 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL01_C - PIXEL02_C - PIXEL12_C - } - else - { - PIXEL01_3 - PIXEL02_2 - PIXEL12_3 - } - PIXEL11 - PIXEL20_1M - if (Diff(yuv[6], yuv[8])) - { - PIXEL21_C - PIXEL22_C - } - else - { - PIXEL21_3 - PIXEL22_4 - } - break; - } -case 247: - { - PIXEL00_1L - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL10_1 - PIXEL11 - PIXEL12_C - PIXEL20_1L - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } -case 255: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_C - } - else - { - PIXEL00_2 - } - PIXEL01_C - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_C - } - else - { - PIXEL02_2 - } - PIXEL10_C - PIXEL11 - PIXEL12_C - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_C - } - else - { - PIXEL20_2 - } - PIXEL21_C - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_C - } - else - { - PIXEL22_2 - } - break; - } +case 45: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; +} +case 22: +case 54: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} +case 208: +case 209: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 104: +case 108: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 11: +case 139: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} +case 19: +case 51: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL12_C + } else { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} +case 146: +case 178: { + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_1M + PIXEL12_C + PIXEL22_1D + } else { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + break; +} +case 84: +case 85: { + if (Diff(yuv[6], yuv[8])) { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_1M + } else { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL10_1 + PIXEL11 + PIXEL20_1M + break; +} +case 112: +case 113: { + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + } else { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; +} +case 200: +case 204: { + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + } else { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + break; +} +case 73: +case 77: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_1U + PIXEL10_C + PIXEL20_1M + PIXEL21_C + } else { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + PIXEL22_1M + break; +} +case 42: +case 170: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } else { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL21_1 + PIXEL22_2 + break; +} +case 14: +case 142: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } else { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} +case 67: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 70: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 28: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 152: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 194: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 98: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 56: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 25: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 26: +case 31: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + PIXEL12_C + } else { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 82: +case 214: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + } else { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL21_C + PIXEL22_C + } else { + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 88: +case 248: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + } else { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL22_4 + } + break; +} +case 74: +case 107: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + } else { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + PIXEL21_C + } else { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 27: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 86: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 216: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 106: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 30: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 210: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 120: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 75: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 29: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1M + break; +} +case 198: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 184: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 99: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 57: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 71: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 156: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 226: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} +case 60: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 195: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 102: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 153: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 58: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 83: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 92: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 202: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 78: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1M + break; +} +case 154: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 114: { + PIXEL00_1M + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 89: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 90: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 55: +case 23: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_1L + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + PIXEL22_1M + break; +} +case 182: +case 150: { + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + PIXEL22_1D + } else { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_1 + PIXEL11 + PIXEL20_2 + PIXEL21_1 + break; +} +case 213: +case 212: { + if (Diff(yuv[6], yuv[8])) { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL10_1 + PIXEL11 + PIXEL20_1M + break; +} +case 241: +case 240: { + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_2 + PIXEL01_1 + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; +} +case 236: +case 232: { + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + PIXEL22_1R + } else { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + break; +} +case 109: +case 105: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_1U + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_2 + PIXEL11 + PIXEL12_1 + PIXEL22_1M + break; +} +case 171: +case 43: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } else { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL21_1 + PIXEL22_2 + break; +} +case 143: +case 15: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } else { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_1 + PIXEL22_2 + break; +} +case 124: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 203: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 62: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 211: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 118: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 217: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 110: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 155: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 188: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 185: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 61: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 157: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 103: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 227: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} +case 230: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} +case 199: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 220: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 158: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 234: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1M + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1R + break; +} +case 242: { + PIXEL00_1M + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 59: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 121: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 87: { + PIXEL00_1L + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1M + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 79: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1R + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1M + break; +} +case 122: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 94: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 218: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 91: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 229: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_2 + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} +case 167: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_2 + PIXEL21_1 + PIXEL22_2 + break; +} +case 173: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; +} +case 181: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; +} +case 186: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 115: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 93: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 206: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 205: +case 201: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_1M + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 174: +case 46: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_1M + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; +} +case 179: +case 147: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_1M + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; +} +case 117: +case 116: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_1M + } else { + PIXEL22_2 + } + break; +} +case 189: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 231: { + PIXEL00_1L + PIXEL01_C + PIXEL02_1R + PIXEL10_1 + PIXEL11 + PIXEL12_1 + PIXEL20_1L + PIXEL21_C + PIXEL22_1R + break; +} +case 126: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 219: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL01_3 + PIXEL10_3 + } + PIXEL02_1M + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 125: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_1U + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL00_2 + PIXEL10_6 + PIXEL20_5 + PIXEL21_1 + } + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + PIXEL22_1M + break; +} +case 221: { + if (Diff(yuv[6], yuv[8])) { + PIXEL02_1U + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL02_2 + PIXEL12_6 + PIXEL21_1 + PIXEL22_5 + } + PIXEL00_1U + PIXEL01_1 + PIXEL10_C + PIXEL11 + PIXEL20_1M + break; +} +case 207: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL02_1R + PIXEL10_C + } else { + PIXEL00_5 + PIXEL01_6 + PIXEL02_2 + PIXEL10_1 + } + PIXEL11 + PIXEL12_1 + PIXEL20_1M + PIXEL21_C + PIXEL22_1R + break; +} +case 238: { + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + PIXEL22_1R + } else { + PIXEL10_1 + PIXEL20_5 + PIXEL21_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL01_C + PIXEL02_1R + PIXEL11 + PIXEL12_1 + break; +} +case 190: { + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + PIXEL22_1D + } else { + PIXEL01_1 + PIXEL02_5 + PIXEL12_6 + PIXEL22_2 + } + PIXEL00_1M + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + break; +} +case 187: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + PIXEL20_1D + } else { + PIXEL00_5 + PIXEL01_1 + PIXEL10_6 + PIXEL20_2 + } + PIXEL02_1M + PIXEL11 + PIXEL12_C + PIXEL21_1 + PIXEL22_1D + break; +} +case 243: { + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL20_1L + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_1 + PIXEL20_2 + PIXEL21_6 + PIXEL22_5 + } + PIXEL00_1L + PIXEL01_C + PIXEL02_1M + PIXEL10_1 + PIXEL11 + break; +} +case 119: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_1L + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL00_2 + PIXEL01_6 + PIXEL02_5 + PIXEL12_1 + } + PIXEL10_1 + PIXEL11 + PIXEL20_1L + PIXEL21_C + PIXEL22_1M + break; +} +case 237: +case 233: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_2 + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 175: +case 47: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + PIXEL20_1D + PIXEL21_1 + PIXEL22_2 + break; +} +case 183: +case 151: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_2 + PIXEL21_1 + PIXEL22_1D + break; +} +case 245: +case 244: { + PIXEL00_2 + PIXEL01_1 + PIXEL02_1U + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} +case 250: { + PIXEL00_1M + PIXEL01_C + PIXEL02_1M + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + } else { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL22_4 + } + break; +} +case 123: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + } else { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + PIXEL21_C + } else { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 95: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + PIXEL12_C + } else { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + PIXEL21_C + PIXEL22_1M + break; +} +case 222: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + } else { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL21_C + PIXEL22_C + } else { + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 252: { + PIXEL00_1M + PIXEL01_1 + PIXEL02_1U + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + } else { + PIXEL10_3 + PIXEL20_4 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} +case 249: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1M + PIXEL10_C + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL22_4 + } + break; +} +case 235: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + } else { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 111: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + PIXEL21_C + } else { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 63: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + PIXEL12_C + } else { + PIXEL02_4 + PIXEL12_3 + } + PIXEL10_C + PIXEL11 + PIXEL20_1D + PIXEL21_1 + PIXEL22_1M + break; +} +case 159: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL10_3 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL11 + PIXEL12_C + PIXEL20_1M + PIXEL21_1 + PIXEL22_1D + break; +} +case 215: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL21_C + PIXEL22_C + } else { + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 246: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + } else { + PIXEL01_3 + PIXEL02_4 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} +case 254: { + PIXEL00_1M + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + } else { + PIXEL01_3 + PIXEL02_4 + } + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + } else { + PIXEL10_3 + PIXEL20_4 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL21_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL21_3 + PIXEL22_2 + } + break; +} +case 253: { + PIXEL00_1U + PIXEL01_1 + PIXEL02_1U + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} +case 251: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + } else { + PIXEL00_4 + PIXEL01_3 + } + PIXEL02_1M + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL10_C + PIXEL20_C + PIXEL21_C + } else { + PIXEL10_3 + PIXEL20_2 + PIXEL21_3 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL12_C + PIXEL22_C + } else { + PIXEL12_3 + PIXEL22_4 + } + break; +} +case 239: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + PIXEL02_1R + PIXEL10_C + PIXEL11 + PIXEL12_1 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + PIXEL22_1R + break; +} +case 127: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL01_C + PIXEL10_C + } else { + PIXEL00_2 + PIXEL01_3 + PIXEL10_3 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + PIXEL12_C + } else { + PIXEL02_4 + PIXEL12_3 + } + PIXEL11 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + PIXEL21_C + } else { + PIXEL20_4 + PIXEL21_3 + } + PIXEL22_1M + break; +} +case 191: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + PIXEL20_1D + PIXEL21_1 + PIXEL22_1D + break; +} +case 223: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + PIXEL10_C + } else { + PIXEL00_4 + PIXEL10_3 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL01_C + PIXEL02_C + PIXEL12_C + } else { + PIXEL01_3 + PIXEL02_2 + PIXEL12_3 + } + PIXEL11 + PIXEL20_1M + if (Diff(yuv[6], yuv[8])) { + PIXEL21_C + PIXEL22_C + } else { + PIXEL21_3 + PIXEL22_4 + } + break; +} +case 247: { + PIXEL00_1L + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL10_1 + PIXEL11 + PIXEL12_C + PIXEL20_1L + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} +case 255: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_C + } else { + PIXEL00_2 + } + PIXEL01_C + if (Diff(yuv[2], yuv[6])) { + PIXEL02_C + } else { + PIXEL02_2 + } + PIXEL10_C + PIXEL11 + PIXEL12_C + if (Diff(yuv[8], yuv[4])) { + PIXEL20_C + } else { + PIXEL20_2 + } + PIXEL21_C + if (Diff(yuv[6], yuv[8])) { + PIXEL22_C + } else { + PIXEL22_2 + } + break; +} } diff --git a/src/filters/hq/c/hq4x_pattern.h b/src/filters/hq/c/hq4x_pattern.h index 6bef3c7e..e98ad857 100644 --- a/src/filters/hq/c/hq4x_pattern.h +++ b/src/filters/hq/c/hq4x_pattern.h @@ -1,7 +1,7 @@ /* VisualBoyAdvance - a Game Boy & Game Boy Advance emulator - Copyright (C) 1999 - 2003 Forgotten + Copyright (C) 1999 - 2003 Forgotten Copyright (C) 2003 - 2004 Forgotten and the VBA development team Copyright (C) 2005 - 2006 VBA development team @@ -21,8 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -switch(pattern) -{ +switch (pattern) { case 0: case 1: case 4: @@ -38,4960 +37,4271 @@ case 133: case 164: case 161: case 37: -case 165: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } +case 165: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} case 2: case 34: case 130: -case 162: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } +case 162: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} case 16: case 17: case 48: -case 49: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } +case 49: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} case 64: case 65: case 68: -case 69: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } +case 69: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} case 8: case 12: case 136: -case 140: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } +case 140: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} case 3: case 35: case 131: -case 163: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } +case 163: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} case 6: case 38: case 134: -case 166: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } +case 166: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} case 20: case 21: case 52: -case 53: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } +case 53: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} case 144: case 145: case 176: -case 177: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } +case 177: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} case 192: case 193: case 196: -case 197: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } +case 197: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} case 96: case 97: case 100: -case 101: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } +case 101: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} case 40: case 44: case 168: -case 172: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } +case 172: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} case 9: case 13: case 137: -case 141: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } +case 141: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} case 18: -case 50: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL12_0 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } +case 50: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL12_0 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} case 80: -case 81: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } +case 81: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} case 72: -case 76: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_50 - PIXEL21_0 - PIXEL30_50 - PIXEL31_50 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } +case 76: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_50 + PIXEL21_0 + PIXEL30_50 + PIXEL31_50 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} case 10: -case 138: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } -case 66: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 24: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } +case 138: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 66: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 24: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} case 7: case 39: -case 135: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } +case 135: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} case 148: case 149: -case 180: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } +case 180: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} case 224: case 228: -case 225: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } +case 225: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} case 41: case 169: -case 45: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 22: -case 54: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } -case 208: -case 209: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 104: -case 108: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 11: -case 139: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } -case 19: -case 51: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } -case 146: -case 178: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; - } -case 84: -case 85: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(yuv[6], yuv[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } -case 112: -case 113: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } -case 200: -case 204: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } -case 73: -case 77: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 42: -case 170: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 14: -case 142: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } -case 67: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 70: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 28: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 152: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 194: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 98: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 56: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 25: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 26: -case 31: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 82: -case 214: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 88: -case 248: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } -case 74: -case 107: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 27: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 86: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 216: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 106: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 30: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 210: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 120: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 75: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 29: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_61 - PIXEL32_61 - PIXEL33_80 - break; - } -case 198: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 184: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_61 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 99: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 57: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 71: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_30 - PIXEL23_61 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 156: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 226: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_61 - PIXEL11_30 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } -case 60: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 195: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 102: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 153: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 58: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 83: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_61 - PIXEL21_30 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 92: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 202: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } -case 78: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 154: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 114: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } -case 89: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 90: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 55: -case 23: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_30 - PIXEL23_10 - PIXEL30_20 - PIXEL31_60 - PIXEL32_61 - PIXEL33_80 - break; - } -case 182: -case 150: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - break; - } -case 213: -case 212: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - if (Diff(yuv[6], yuv[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL20_61 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } -case 241: -case 240: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_61 - PIXEL03_80 - PIXEL10_60 - PIXEL11_70 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } -case 236: -case 232: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_60 - PIXEL03_20 - PIXEL10_10 - PIXEL11_30 - PIXEL12_70 - PIXEL13_60 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } -case 109: -case 105: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 171: -case 43: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - PIXEL11_0 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 143: -case 15: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_70 - PIXEL23_60 - PIXEL30_80 - PIXEL31_61 - PIXEL32_60 - PIXEL33_20 - break; - } -case 124: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 203: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 62: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 211: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 118: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 217: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 110: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 155: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 188: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 185: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 61: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 157: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 103: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_61 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 227: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_61 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } -case 230: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_61 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } -case 199: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_61 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 220: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } -case 158: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 234: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_61 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } -case 242: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_61 - PIXEL11_30 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_82 - PIXEL31_32 - break; - } -case 59: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL11_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 121: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 87: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL20_61 - PIXEL21_30 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 79: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_32 - PIXEL03_82 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 122: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 94: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL12_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 218: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } -case 91: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL11_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 229: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_60 - PIXEL03_20 - PIXEL10_60 - PIXEL11_70 - PIXEL12_70 - PIXEL13_60 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } -case 167: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_60 - PIXEL21_70 - PIXEL22_70 - PIXEL23_60 - PIXEL30_20 - PIXEL31_60 - PIXEL32_60 - PIXEL33_20 - break; - } -case 173: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 181: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } -case 186: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 115: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } -case 93: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - break; - } -case 206: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } -case 205: -case 201: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - } - else - { - PIXEL20_12 - PIXEL21_0 - PIXEL30_20 - PIXEL31_11 - } - PIXEL22_31 - PIXEL23_81 - PIXEL32_31 - PIXEL33_81 - break; - } -case 174: -case 46: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_80 - PIXEL01_10 - PIXEL10_10 - PIXEL11_30 - } - else - { - PIXEL00_20 - PIXEL01_12 - PIXEL10_11 - PIXEL11_0 - } - PIXEL02_32 - PIXEL03_82 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 179: -case 147: - { - PIXEL00_81 - PIXEL01_31 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - } - else - { - PIXEL02_11 - PIXEL03_20 - PIXEL12_0 - PIXEL13_12 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } -case 117: -case 116: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - } - else - { - PIXEL22_0 - PIXEL23_11 - PIXEL32_12 - PIXEL33_20 - } - PIXEL30_82 - PIXEL31_32 - break; - } -case 189: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 231: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_32 - PIXEL03_82 - PIXEL10_81 - PIXEL11_31 - PIXEL12_32 - PIXEL13_82 - PIXEL20_82 - PIXEL21_32 - PIXEL22_31 - PIXEL23_81 - PIXEL30_82 - PIXEL31_32 - PIXEL32_31 - PIXEL33_81 - break; - } -case 126: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 219: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 125: - { - if (Diff(yuv[8], yuv[4])) - { - PIXEL00_82 - PIXEL10_32 - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL00_11 - PIXEL10_13 - PIXEL20_83 - PIXEL21_70 - PIXEL30_50 - PIXEL31_21 - } - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 221: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - if (Diff(yuv[6], yuv[8])) - { - PIXEL03_81 - PIXEL13_31 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL03_12 - PIXEL13_14 - PIXEL22_70 - PIXEL23_83 - PIXEL32_21 - PIXEL33_50 - } - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL20_10 - PIXEL21_30 - PIXEL30_80 - PIXEL31_10 - break; - } -case 207: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - } - else - { - PIXEL00_50 - PIXEL01_83 - PIXEL02_13 - PIXEL03_11 - PIXEL10_21 - PIXEL11_70 - } - PIXEL12_32 - PIXEL13_82 - PIXEL20_10 - PIXEL21_30 - PIXEL22_31 - PIXEL23_81 - PIXEL30_80 - PIXEL31_10 - PIXEL32_31 - PIXEL33_81 - break; - } -case 238: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_32 - PIXEL03_82 - PIXEL10_10 - PIXEL11_30 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL21_0 - PIXEL30_0 - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - } - else - { - PIXEL20_21 - PIXEL21_70 - PIXEL30_50 - PIXEL31_83 - PIXEL32_14 - PIXEL33_12 - } - PIXEL22_31 - PIXEL23_81 - break; - } -case 190: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - PIXEL23_32 - PIXEL33_82 - } - else - { - PIXEL02_21 - PIXEL03_50 - PIXEL12_70 - PIXEL13_83 - PIXEL23_13 - PIXEL33_11 - } - PIXEL10_10 - PIXEL11_30 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - break; - } -case 187: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - PIXEL11_0 - PIXEL20_31 - PIXEL30_81 - } - else - { - PIXEL00_50 - PIXEL01_21 - PIXEL10_83 - PIXEL11_70 - PIXEL20_14 - PIXEL30_12 - } - PIXEL02_10 - PIXEL03_80 - PIXEL12_30 - PIXEL13_10 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 243: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_10 - PIXEL03_80 - PIXEL10_81 - PIXEL11_31 - PIXEL12_30 - PIXEL13_10 - PIXEL20_82 - PIXEL21_32 - if (Diff(yuv[6], yuv[8])) - { - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL22_70 - PIXEL23_21 - PIXEL30_11 - PIXEL31_13 - PIXEL32_83 - PIXEL33_50 - } - break; - } -case 119: - { - if (Diff(yuv[2], yuv[6])) - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - PIXEL03_0 - PIXEL12_0 - PIXEL13_0 - } - else - { - PIXEL00_12 - PIXEL01_14 - PIXEL02_83 - PIXEL03_50 - PIXEL12_70 - PIXEL13_21 - } - PIXEL10_81 - PIXEL11_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_30 - PIXEL23_10 - PIXEL30_82 - PIXEL31_32 - PIXEL32_10 - PIXEL33_80 - break; - } -case 237: -case 233: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_60 - PIXEL03_20 - PIXEL10_32 - PIXEL11_32 - PIXEL12_70 - PIXEL13_60 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } -case 175: -case 47: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_31 - PIXEL21_31 - PIXEL22_70 - PIXEL23_60 - PIXEL30_81 - PIXEL31_81 - PIXEL32_60 - PIXEL33_20 - break; - } -case 183: -case 151: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_60 - PIXEL21_70 - PIXEL22_32 - PIXEL23_32 - PIXEL30_20 - PIXEL31_60 - PIXEL32_82 - PIXEL33_82 - break; - } -case 245: -case 244: - { - PIXEL00_20 - PIXEL01_60 - PIXEL02_81 - PIXEL03_81 - PIXEL10_60 - PIXEL11_70 - PIXEL12_31 - PIXEL13_31 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 250: - { - PIXEL00_80 - PIXEL01_10 - PIXEL02_10 - PIXEL03_80 - PIXEL10_10 - PIXEL11_30 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - break; - } -case 123: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 95: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL11_0 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_30 - PIXEL23_10 - PIXEL30_80 - PIXEL31_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 222: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 252: - { - PIXEL00_80 - PIXEL01_61 - PIXEL02_81 - PIXEL03_81 - PIXEL10_10 - PIXEL11_30 - PIXEL12_31 - PIXEL13_31 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 249: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_61 - PIXEL03_80 - PIXEL10_32 - PIXEL11_32 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; - } -case 235: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_61 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } -case 111: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_61 - PIXEL32_10 - PIXEL33_80 - break; - } -case 63: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_30 - PIXEL23_10 - PIXEL30_81 - PIXEL31_81 - PIXEL32_61 - PIXEL33_80 - break; - } -case 159: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_32 - PIXEL23_32 - PIXEL30_80 - PIXEL31_61 - PIXEL32_82 - PIXEL33_82 - break; - } -case 215: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_61 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 246: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_61 - PIXEL11_30 - PIXEL12_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 254: - { - PIXEL00_80 - PIXEL01_10 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_10 - PIXEL11_30 - PIXEL12_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 253: - { - PIXEL00_82 - PIXEL01_82 - PIXEL02_81 - PIXEL03_81 - PIXEL10_32 - PIXEL11_32 - PIXEL12_31 - PIXEL13_31 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 251: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_10 - PIXEL03_80 - PIXEL11_0 - PIXEL12_30 - PIXEL13_10 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - break; - } -case 239: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_32 - PIXEL03_82 - PIXEL10_0 - PIXEL11_0 - PIXEL12_32 - PIXEL13_82 - PIXEL20_0 - PIXEL21_0 - PIXEL22_31 - PIXEL23_81 - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_31 - PIXEL33_81 - break; - } -case 127: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL02_0 - PIXEL03_0 - PIXEL13_0 - } - else - { - PIXEL02_50 - PIXEL03_50 - PIXEL13_50 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL20_0 - PIXEL30_0 - PIXEL31_0 - } - else - { - PIXEL20_50 - PIXEL30_50 - PIXEL31_50 - } - PIXEL21_0 - PIXEL22_30 - PIXEL23_10 - PIXEL32_10 - PIXEL33_80 - break; - } -case 191: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_31 - PIXEL21_31 - PIXEL22_32 - PIXEL23_32 - PIXEL30_81 - PIXEL31_81 - PIXEL32_82 - PIXEL33_82 - break; - } -case 223: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - PIXEL01_0 - PIXEL10_0 - } - else - { - PIXEL00_50 - PIXEL01_50 - PIXEL10_50 - } - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_10 - PIXEL21_30 - PIXEL22_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL23_0 - PIXEL32_0 - PIXEL33_0 - } - else - { - PIXEL23_50 - PIXEL32_50 - PIXEL33_50 - } - PIXEL30_80 - PIXEL31_10 - break; - } -case 247: - { - PIXEL00_81 - PIXEL01_31 - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_81 - PIXEL11_31 - PIXEL12_0 - PIXEL13_0 - PIXEL20_82 - PIXEL21_32 - PIXEL22_0 - PIXEL23_0 - PIXEL30_82 - PIXEL31_32 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } -case 255: - { - if (Diff(yuv[4], yuv[2])) - { - PIXEL00_0 - } - else - { - PIXEL00_20 - } - PIXEL01_0 - PIXEL02_0 - if (Diff(yuv[2], yuv[6])) - { - PIXEL03_0 - } - else - { - PIXEL03_20 - } - PIXEL10_0 - PIXEL11_0 - PIXEL12_0 - PIXEL13_0 - PIXEL20_0 - PIXEL21_0 - PIXEL22_0 - PIXEL23_0 - if (Diff(yuv[8], yuv[4])) - { - PIXEL30_0 - } - else - { - PIXEL30_20 - } - PIXEL31_0 - PIXEL32_0 - if (Diff(yuv[6], yuv[8])) - { - PIXEL33_0 - } - else - { - PIXEL33_20 - } - break; - } +case 45: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 22: +case 54: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 208: +case 209: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 104: +case 108: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 11: +case 139: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 19: +case 51: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 146: +case 178: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL23_32 + PIXEL33_82 + } else { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; +} +case 84: +case 85: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(yuv[6], yuv[8])) { + PIXEL03_81 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 112: +case 113: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; +} +case 200: +case 204: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + } else { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; +} +case 73: +case 77: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_82 + PIXEL10_32 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 42: +case 170: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL30_81 + } else { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 14: +case 142: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 67: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 70: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 28: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 152: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 194: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 98: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 56: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 25: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 26: +case 31: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 82: +case 214: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 88: +case 248: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 74: +case 107: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 27: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 86: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 216: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 106: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 30: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 210: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 120: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 75: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 29: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_61 + PIXEL32_61 + PIXEL33_80 + break; +} +case 198: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 184: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_61 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 99: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 57: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 71: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_30 + PIXEL23_61 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 156: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 226: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_61 + PIXEL11_30 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 60: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 195: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 102: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 153: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 58: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 83: { + PIXEL00_81 + PIXEL01_31 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_61 + PIXEL21_30 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 92: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 202: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 78: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 154: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 114: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 89: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 90: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 55: +case 23: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } else { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_30 + PIXEL23_10 + PIXEL30_20 + PIXEL31_60 + PIXEL32_61 + PIXEL33_80 + break; +} +case 182: +case 150: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } else { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + break; +} +case 213: +case 212: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + if (Diff(yuv[6], yuv[8])) { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL20_61 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 241: +case 240: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_61 + PIXEL03_80 + PIXEL10_60 + PIXEL11_70 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; +} +case 236: +case 232: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_60 + PIXEL03_20 + PIXEL10_10 + PIXEL11_30 + PIXEL12_70 + PIXEL13_60 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } else { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; +} +case 109: +case 105: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 171: +case 43: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } else { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 143: +case 15: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } else { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_70 + PIXEL23_60 + PIXEL30_80 + PIXEL31_61 + PIXEL32_60 + PIXEL33_20 + break; +} +case 124: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 203: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 62: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 211: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 118: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 217: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 110: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 155: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 188: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 185: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 61: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 157: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 103: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_61 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 227: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_61 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 230: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_61 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 199: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_61 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 220: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 158: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 234: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_61 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 242: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_61 + PIXEL11_30 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 59: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 121: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 87: { + PIXEL00_81 + PIXEL01_31 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL20_61 + PIXEL21_30 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 79: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_32 + PIXEL03_82 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 122: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 94: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL12_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 218: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 91: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL11_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 229: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_60 + PIXEL03_20 + PIXEL10_60 + PIXEL11_70 + PIXEL12_70 + PIXEL13_60 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 167: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_60 + PIXEL21_70 + PIXEL22_70 + PIXEL23_60 + PIXEL30_20 + PIXEL31_60 + PIXEL32_60 + PIXEL33_20 + break; +} +case 173: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 181: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 186: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 115: { + PIXEL00_81 + PIXEL01_31 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 93: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + break; +} +case 206: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 205: +case 201: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + } else { + PIXEL20_12 + PIXEL21_0 + PIXEL30_20 + PIXEL31_11 + } + PIXEL22_31 + PIXEL23_81 + PIXEL32_31 + PIXEL33_81 + break; +} +case 174: +case 46: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_80 + PIXEL01_10 + PIXEL10_10 + PIXEL11_30 + } else { + PIXEL00_20 + PIXEL01_12 + PIXEL10_11 + PIXEL11_0 + } + PIXEL02_32 + PIXEL03_82 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 179: +case 147: { + PIXEL00_81 + PIXEL01_31 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + } else { + PIXEL02_11 + PIXEL03_20 + PIXEL12_0 + PIXEL13_12 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 117: +case 116: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + } else { + PIXEL22_0 + PIXEL23_11 + PIXEL32_12 + PIXEL33_20 + } + PIXEL30_82 + PIXEL31_32 + break; +} +case 189: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 231: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_32 + PIXEL03_82 + PIXEL10_81 + PIXEL11_31 + PIXEL12_32 + PIXEL13_82 + PIXEL20_82 + PIXEL21_32 + PIXEL22_31 + PIXEL23_81 + PIXEL30_82 + PIXEL31_32 + PIXEL32_31 + PIXEL33_81 + break; +} +case 126: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 219: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 125: { + if (Diff(yuv[8], yuv[4])) { + PIXEL00_82 + PIXEL10_32 + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL00_11 + PIXEL10_13 + PIXEL20_83 + PIXEL21_70 + PIXEL30_50 + PIXEL31_21 + } + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 221: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + if (Diff(yuv[6], yuv[8])) { + PIXEL03_81 + PIXEL13_31 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL03_12 + PIXEL13_14 + PIXEL22_70 + PIXEL23_83 + PIXEL32_21 + PIXEL33_50 + } + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL20_10 + PIXEL21_30 + PIXEL30_80 + PIXEL31_10 + break; +} +case 207: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + } else { + PIXEL00_50 + PIXEL01_83 + PIXEL02_13 + PIXEL03_11 + PIXEL10_21 + PIXEL11_70 + } + PIXEL12_32 + PIXEL13_82 + PIXEL20_10 + PIXEL21_30 + PIXEL22_31 + PIXEL23_81 + PIXEL30_80 + PIXEL31_10 + PIXEL32_31 + PIXEL33_81 + break; +} +case 238: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_32 + PIXEL03_82 + PIXEL10_10 + PIXEL11_30 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL21_0 + PIXEL30_0 + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + } else { + PIXEL20_21 + PIXEL21_70 + PIXEL30_50 + PIXEL31_83 + PIXEL32_14 + PIXEL33_12 + } + PIXEL22_31 + PIXEL23_81 + break; +} +case 190: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + PIXEL23_32 + PIXEL33_82 + } else { + PIXEL02_21 + PIXEL03_50 + PIXEL12_70 + PIXEL13_83 + PIXEL23_13 + PIXEL33_11 + } + PIXEL10_10 + PIXEL11_30 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + break; +} +case 187: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + PIXEL11_0 + PIXEL20_31 + PIXEL30_81 + } else { + PIXEL00_50 + PIXEL01_21 + PIXEL10_83 + PIXEL11_70 + PIXEL20_14 + PIXEL30_12 + } + PIXEL02_10 + PIXEL03_80 + PIXEL12_30 + PIXEL13_10 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 243: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_10 + PIXEL03_80 + PIXEL10_81 + PIXEL11_31 + PIXEL12_30 + PIXEL13_10 + PIXEL20_82 + PIXEL21_32 + if (Diff(yuv[6], yuv[8])) { + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL22_70 + PIXEL23_21 + PIXEL30_11 + PIXEL31_13 + PIXEL32_83 + PIXEL33_50 + } + break; +} +case 119: { + if (Diff(yuv[2], yuv[6])) { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + PIXEL03_0 + PIXEL12_0 + PIXEL13_0 + } else { + PIXEL00_12 + PIXEL01_14 + PIXEL02_83 + PIXEL03_50 + PIXEL12_70 + PIXEL13_21 + } + PIXEL10_81 + PIXEL11_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_30 + PIXEL23_10 + PIXEL30_82 + PIXEL31_32 + PIXEL32_10 + PIXEL33_80 + break; +} +case 237: +case 233: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_60 + PIXEL03_20 + PIXEL10_32 + PIXEL11_32 + PIXEL12_70 + PIXEL13_60 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 175: +case 47: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_31 + PIXEL21_31 + PIXEL22_70 + PIXEL23_60 + PIXEL30_81 + PIXEL31_81 + PIXEL32_60 + PIXEL33_20 + break; +} +case 183: +case 151: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_60 + PIXEL21_70 + PIXEL22_32 + PIXEL23_32 + PIXEL30_20 + PIXEL31_60 + PIXEL32_82 + PIXEL33_82 + break; +} +case 245: +case 244: { + PIXEL00_20 + PIXEL01_60 + PIXEL02_81 + PIXEL03_81 + PIXEL10_60 + PIXEL11_70 + PIXEL12_31 + PIXEL13_31 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 250: { + PIXEL00_80 + PIXEL01_10 + PIXEL02_10 + PIXEL03_80 + PIXEL10_10 + PIXEL11_30 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + break; +} +case 123: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 95: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL11_0 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_30 + PIXEL23_10 + PIXEL30_80 + PIXEL31_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 222: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 252: { + PIXEL00_80 + PIXEL01_61 + PIXEL02_81 + PIXEL03_81 + PIXEL10_10 + PIXEL11_30 + PIXEL12_31 + PIXEL13_31 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 249: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_61 + PIXEL03_80 + PIXEL10_32 + PIXEL11_32 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + break; +} +case 235: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_61 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 111: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_61 + PIXEL32_10 + PIXEL33_80 + break; +} +case 63: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_30 + PIXEL23_10 + PIXEL30_81 + PIXEL31_81 + PIXEL32_61 + PIXEL33_80 + break; +} +case 159: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_32 + PIXEL23_32 + PIXEL30_80 + PIXEL31_61 + PIXEL32_82 + PIXEL33_82 + break; +} +case 215: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_61 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 246: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_61 + PIXEL11_30 + PIXEL12_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 254: { + PIXEL00_80 + PIXEL01_10 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_10 + PIXEL11_30 + PIXEL12_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 253: { + PIXEL00_82 + PIXEL01_82 + PIXEL02_81 + PIXEL03_81 + PIXEL10_32 + PIXEL11_32 + PIXEL12_31 + PIXEL13_31 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 251: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_10 + PIXEL03_80 + PIXEL11_0 + PIXEL12_30 + PIXEL13_10 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + break; +} +case 239: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_32 + PIXEL03_82 + PIXEL10_0 + PIXEL11_0 + PIXEL12_32 + PIXEL13_82 + PIXEL20_0 + PIXEL21_0 + PIXEL22_31 + PIXEL23_81 + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_31 + PIXEL33_81 + break; +} +case 127: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL02_0 + PIXEL03_0 + PIXEL13_0 + } else { + PIXEL02_50 + PIXEL03_50 + PIXEL13_50 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL20_0 + PIXEL30_0 + PIXEL31_0 + } else { + PIXEL20_50 + PIXEL30_50 + PIXEL31_50 + } + PIXEL21_0 + PIXEL22_30 + PIXEL23_10 + PIXEL32_10 + PIXEL33_80 + break; +} +case 191: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_31 + PIXEL21_31 + PIXEL22_32 + PIXEL23_32 + PIXEL30_81 + PIXEL31_81 + PIXEL32_82 + PIXEL33_82 + break; +} +case 223: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + PIXEL01_0 + PIXEL10_0 + } else { + PIXEL00_50 + PIXEL01_50 + PIXEL10_50 + } + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_10 + PIXEL21_30 + PIXEL22_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL23_0 + PIXEL32_0 + PIXEL33_0 + } else { + PIXEL23_50 + PIXEL32_50 + PIXEL33_50 + } + PIXEL30_80 + PIXEL31_10 + break; +} +case 247: { + PIXEL00_81 + PIXEL01_31 + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL10_81 + PIXEL11_31 + PIXEL12_0 + PIXEL13_0 + PIXEL20_82 + PIXEL21_32 + PIXEL22_0 + PIXEL23_0 + PIXEL30_82 + PIXEL31_32 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} +case 255: { + if (Diff(yuv[4], yuv[2])) { + PIXEL00_0 + } else { + PIXEL00_20 + } + PIXEL01_0 + PIXEL02_0 + if (Diff(yuv[2], yuv[6])) { + PIXEL03_0 + } else { + PIXEL03_20 + } + PIXEL10_0 + PIXEL11_0 + PIXEL12_0 + PIXEL13_0 + PIXEL20_0 + PIXEL21_0 + PIXEL22_0 + PIXEL23_0 + if (Diff(yuv[8], yuv[4])) { + PIXEL30_0 + } else { + PIXEL30_20 + } + PIXEL31_0 + PIXEL32_0 + if (Diff(yuv[6], yuv[8])) { + PIXEL33_0 + } else { + PIXEL33_20 + } + break; +} } diff --git a/src/filters/hq/c/hq_base.h b/src/filters/hq/c/hq_base.h index b63c6144..784b8d21 100644 --- a/src/filters/hq/c/hq_base.h +++ b/src/filters/hq/c/hq_base.h @@ -18,289 +18,339 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - hq filter by Maxim Stepin ( http://hiend3d.com ) + hq filter by Maxim Stepin ( http://hiend3d.com ) */ - #ifdef _16BIT #ifdef _32BIT #error _16BIT and _32BIT defined at the same time! #endif #endif - #ifdef _16BIT -#define SIZE_PIXEL 2 // 16bit = 2 bytes -#define COLORTYPE unsigned short -#define RGBtoYUV RGBtoYUV_16 -#define Interp1 Interp1_16 -#define Interp2 Interp2_16 -#define Interp3 Interp3_16 -#define Interp4 Interp4_16 -#define Interp5 Interp5_16 -#define Interp6 Interp6_16 -#define Interp7 Interp7_16 -#define Interp8 Interp8_16 +#define SIZE_PIXEL 2 // 16bit = 2 bytes +#define COLORTYPE unsigned short +#define RGBtoYUV RGBtoYUV_16 +#define Interp1 Interp1_16 +#define Interp2 Interp2_16 +#define Interp3 Interp3_16 +#define Interp4 Interp4_16 +#define Interp5 Interp5_16 +#define Interp6 Interp6_16 +#define Interp7 Interp7_16 +#define Interp8 Interp8_16 #endif - #ifdef _32BIT -#define SIZE_PIXEL 4 // 32bit = 4 bytes -#define COLORTYPE unsigned int -#define RGBtoYUV RGBtoYUV_32 -#define Interp1 Interp1_32 -#define Interp2 Interp2_32 -#define Interp3 Interp3_32 -#define Interp4 Interp4_32 -#define Interp5 Interp5_32 -#define Interp6 Interp6_32 -#define Interp7 Interp7_32 -#define Interp8 Interp8_32 +#define SIZE_PIXEL 4 // 32bit = 4 bytes +#define COLORTYPE unsigned int +#define RGBtoYUV RGBtoYUV_32 +#define Interp1 Interp1_32 +#define Interp2 Interp2_32 +#define Interp3 Interp3_32 +#define Interp4 Interp4_32 +#define Interp5 Interp5_32 +#define Interp6 Interp6_32 +#define Interp7 Interp7_32 +#define Interp8 Interp8_32 #endif - #ifdef _HQ3X #define _MAGNIFICATION 3 -#define PIXEL00_1M Interp1( pOut, c[5], c[1] ); -#define PIXEL00_1U Interp1( pOut, c[5], c[2] ); -#define PIXEL00_1L Interp1( pOut, c[5], c[4] ); -#define PIXEL00_2 Interp2( pOut, c[5], c[4], c[2] ); -#define PIXEL00_4 Interp4( pOut, c[5], c[4], c[2] ); -#define PIXEL00_5 Interp5( pOut, c[4], c[2] ); -#define PIXEL00_C *((COLORTYPE*)(pOut)) = c[5]; +#define PIXEL00_1M Interp1(pOut, c[5], c[1]); +#define PIXEL00_1U Interp1(pOut, c[5], c[2]); +#define PIXEL00_1L Interp1(pOut, c[5], c[4]); +#define PIXEL00_2 Interp2(pOut, c[5], c[4], c[2]); +#define PIXEL00_4 Interp4(pOut, c[5], c[4], c[2]); +#define PIXEL00_5 Interp5(pOut, c[4], c[2]); +#define PIXEL00_C *((COLORTYPE *)(pOut)) = c[5]; -#define PIXEL01_1 Interp1( pOut+SIZE_PIXEL, c[5], c[2] ); -#define PIXEL01_3 Interp3( pOut+SIZE_PIXEL, c[5], c[2] ); -#define PIXEL01_6 Interp1( pOut+SIZE_PIXEL, c[2], c[5] ); -#define PIXEL01_C *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5]; +#define PIXEL01_1 Interp1(pOut + SIZE_PIXEL, c[5], c[2]); +#define PIXEL01_3 Interp3(pOut + SIZE_PIXEL, c[5], c[2]); +#define PIXEL01_6 Interp1(pOut + SIZE_PIXEL, c[2], c[5]); +#define PIXEL01_C *((COLORTYPE *)(pOut + SIZE_PIXEL)) = c[5]; -#define PIXEL02_1M Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3] ); -#define PIXEL02_1U Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2] ); -#define PIXEL02_1R Interp1( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); -#define PIXEL02_2 Interp2( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] ); -#define PIXEL02_4 Interp4( pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6] ); -#define PIXEL02_5 Interp5( pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6] ); -#define PIXEL02_C *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; +#define PIXEL02_1M Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[3]); +#define PIXEL02_1U Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL02_1R Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL02_2 Interp2(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2], c[6]); +#define PIXEL02_4 Interp4(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2], c[6]); +#define PIXEL02_5 Interp5(pOut + SIZE_PIXEL + SIZE_PIXEL, c[2], c[6]); +#define PIXEL02_C *((COLORTYPE *)(pOut + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; -#define PIXEL10_1 Interp1( pOut+dstPitch, c[5], c[4] ); -#define PIXEL10_3 Interp3( pOut+dstPitch, c[5], c[4] ); -#define PIXEL10_6 Interp1( pOut+dstPitch, c[4], c[5] ); -#define PIXEL10_C *((COLORTYPE*)(pOut+dstPitch)) = c[5]; +#define PIXEL10_1 Interp1(pOut + dstPitch, c[5], c[4]); +#define PIXEL10_3 Interp3(pOut + dstPitch, c[5], c[4]); +#define PIXEL10_6 Interp1(pOut + dstPitch, c[4], c[5]); +#define PIXEL10_C *((COLORTYPE *)(pOut + dstPitch)) = c[5]; -#define PIXEL11 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5]; +#define PIXEL11 *((COLORTYPE *)(pOut + dstPitch + SIZE_PIXEL)) = c[5]; -#define PIXEL12_1 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); -#define PIXEL12_3 Interp3( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); -#define PIXEL12_6 Interp1( pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5] ); -#define PIXEL12_C *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; +#define PIXEL12_1 Interp1(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL12_3 Interp3(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL12_6 Interp1(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5]); +#define PIXEL12_C *((COLORTYPE *)(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; -#define PIXEL20_1M Interp1( pOut+dstPitch+dstPitch, c[5], c[7] ); -#define PIXEL20_1D Interp1( pOut+dstPitch+dstPitch, c[5], c[8] ); -#define PIXEL20_1L Interp1( pOut+dstPitch+dstPitch, c[5], c[4] ); -#define PIXEL20_2 Interp2( pOut+dstPitch+dstPitch, c[5], c[8], c[4] ); -#define PIXEL20_4 Interp4( pOut+dstPitch+dstPitch, c[5], c[8], c[4] ); -#define PIXEL20_5 Interp5( pOut+dstPitch+dstPitch, c[8], c[4] ); -#define PIXEL20_C *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5]; +#define PIXEL20_1M Interp1(pOut + dstPitch + dstPitch, c[5], c[7]); +#define PIXEL20_1D Interp1(pOut + dstPitch + dstPitch, c[5], c[8]); +#define PIXEL20_1L Interp1(pOut + dstPitch + dstPitch, c[5], c[4]); +#define PIXEL20_2 Interp2(pOut + dstPitch + dstPitch, c[5], c[8], c[4]); +#define PIXEL20_4 Interp4(pOut + dstPitch + dstPitch, c[5], c[8], c[4]); +#define PIXEL20_5 Interp5(pOut + dstPitch + dstPitch, c[8], c[4]); +#define PIXEL20_C *((COLORTYPE *)(pOut + dstPitch + dstPitch)) = c[5]; -#define PIXEL21_1 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] ); -#define PIXEL21_3 Interp3( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8] ); -#define PIXEL21_6 Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5] ); -#define PIXEL21_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5]; +#define PIXEL21_1 Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8]); +#define PIXEL21_3 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8]); +#define PIXEL21_6 Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[8], c[5]); +#define PIXEL21_C *((COLORTYPE *)(pOut + dstPitch + dstPitch + SIZE_PIXEL)) = c[5]; -#define PIXEL22_1M Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9] ); -#define PIXEL22_1D Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8] ); -#define PIXEL22_1R Interp1( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6] ); -#define PIXEL22_2 Interp2( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] ); -#define PIXEL22_4 Interp4( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8] ); -#define PIXEL22_5 Interp5( pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8] ); -#define PIXEL22_C *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; +#define PIXEL22_1M Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[9]); +#define PIXEL22_1D Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8]); +#define PIXEL22_1R Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL22_2 Interp2(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[8]); +#define PIXEL22_4 Interp4(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[8]); +#define PIXEL22_5 Interp5(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[6], c[8]); +#define PIXEL22_C *((COLORTYPE *)(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; #endif // #ifdef _HQ3X - - #ifdef _HQ4X #define _MAGNIFICATION 4 -#define PIXEL00_0 *((COLORTYPE*)(pOut)) = c[5]; -#define PIXEL00_11 Interp1(pOut, c[5], c[4]); -#define PIXEL00_12 Interp1(pOut, c[5], c[2]); -#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); -#define PIXEL00_50 Interp5(pOut, c[2], c[4]); -#define PIXEL00_80 Interp8(pOut, c[5], c[1]); -#define PIXEL00_81 Interp8(pOut, c[5], c[4]); -#define PIXEL00_82 Interp8(pOut, c[5], c[2]); +#define PIXEL00_0 *((COLORTYPE *)(pOut)) = c[5]; +#define PIXEL00_11 Interp1(pOut, c[5], c[4]); +#define PIXEL00_12 Interp1(pOut, c[5], c[2]); +#define PIXEL00_20 Interp2(pOut, c[5], c[2], c[4]); +#define PIXEL00_50 Interp5(pOut, c[2], c[4]); +#define PIXEL00_80 Interp8(pOut, c[5], c[1]); +#define PIXEL00_81 Interp8(pOut, c[5], c[4]); +#define PIXEL00_82 Interp8(pOut, c[5], c[2]); -#define PIXEL01_0 *((COLORTYPE*)(pOut+SIZE_PIXEL)) = c[5]; -#define PIXEL01_10 Interp1(pOut+SIZE_PIXEL, c[5], c[1]); -#define PIXEL01_12 Interp1(pOut+SIZE_PIXEL, c[5], c[2]); -#define PIXEL01_14 Interp1(pOut+SIZE_PIXEL, c[2], c[5]); -#define PIXEL01_21 Interp2(pOut+SIZE_PIXEL, c[2], c[5], c[4]); -#define PIXEL01_31 Interp3(pOut+SIZE_PIXEL, c[5], c[4]); -#define PIXEL01_50 Interp5(pOut+SIZE_PIXEL, c[2], c[5]); -#define PIXEL01_60 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[4]); -#define PIXEL01_61 Interp6(pOut+SIZE_PIXEL, c[5], c[2], c[1]); -#define PIXEL01_82 Interp8(pOut+SIZE_PIXEL, c[5], c[2]); -#define PIXEL01_83 Interp8(pOut+SIZE_PIXEL, c[2], c[4]); +#define PIXEL01_0 *((COLORTYPE *)(pOut + SIZE_PIXEL)) = c[5]; +#define PIXEL01_10 Interp1(pOut + SIZE_PIXEL, c[5], c[1]); +#define PIXEL01_12 Interp1(pOut + SIZE_PIXEL, c[5], c[2]); +#define PIXEL01_14 Interp1(pOut + SIZE_PIXEL, c[2], c[5]); +#define PIXEL01_21 Interp2(pOut + SIZE_PIXEL, c[2], c[5], c[4]); +#define PIXEL01_31 Interp3(pOut + SIZE_PIXEL, c[5], c[4]); +#define PIXEL01_50 Interp5(pOut + SIZE_PIXEL, c[2], c[5]); +#define PIXEL01_60 Interp6(pOut + SIZE_PIXEL, c[5], c[2], c[4]); +#define PIXEL01_61 Interp6(pOut + SIZE_PIXEL, c[5], c[2], c[1]); +#define PIXEL01_82 Interp8(pOut + SIZE_PIXEL, c[5], c[2]); +#define PIXEL01_83 Interp8(pOut + SIZE_PIXEL, c[2], c[4]); -#define PIXEL02_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL02_10 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]); -#define PIXEL02_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL02_13 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]); -#define PIXEL02_21 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5], c[6]); -#define PIXEL02_32 Interp3(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL02_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[5]); -#define PIXEL02_60 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]); -#define PIXEL02_61 Interp6(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[3]); -#define PIXEL02_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL02_83 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]); +#define PIXEL02_0 *((COLORTYPE *)(pOut + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL02_10 Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[3]); +#define PIXEL02_11 Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL02_13 Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL, c[2], c[5]); +#define PIXEL02_21 Interp2(pOut + SIZE_PIXEL + SIZE_PIXEL, c[2], c[5], c[6]); +#define PIXEL02_32 Interp3(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL02_50 Interp5(pOut + SIZE_PIXEL + SIZE_PIXEL, c[2], c[5]); +#define PIXEL02_60 Interp6(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2], c[6]); +#define PIXEL02_61 Interp6(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2], c[3]); +#define PIXEL02_81 Interp8(pOut + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL02_83 Interp8(pOut + SIZE_PIXEL + SIZE_PIXEL, c[2], c[6]); -#define PIXEL03_0 *((COLORTYPE*)(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL03_11 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL03_12 Interp1(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL03_20 Interp2(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2], c[6]); -#define PIXEL03_50 Interp5(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[2], c[6]); -#define PIXEL03_80 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]); -#define PIXEL03_81 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL03_82 Interp8(pOut+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); +#define PIXEL03_0 *((COLORTYPE *)(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL03_11 Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL03_12 Interp1(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL03_20 Interp2(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2], c[6]); +#define PIXEL03_50 Interp5(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[2], c[6]); +#define PIXEL03_80 Interp8(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[3]); +#define PIXEL03_81 Interp8(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL03_82 Interp8(pOut + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); -#define PIXEL10_0 *((COLORTYPE*)(pOut+dstPitch)) = c[5]; -#define PIXEL10_10 Interp1(pOut+dstPitch, c[5], c[1]); -#define PIXEL10_11 Interp1(pOut+dstPitch, c[5], c[4]); -#define PIXEL10_13 Interp1(pOut+dstPitch, c[4], c[5]); -#define PIXEL10_21 Interp2(pOut+dstPitch, c[4], c[5], c[2]); -#define PIXEL10_32 Interp3(pOut+dstPitch, c[5], c[2]); -#define PIXEL10_50 Interp5(pOut+dstPitch, c[4], c[5]); -#define PIXEL10_60 Interp6(pOut+dstPitch, c[5], c[4], c[2]); -#define PIXEL10_61 Interp6(pOut+dstPitch, c[5], c[4], c[1]); -#define PIXEL10_81 Interp8(pOut+dstPitch, c[5], c[4]); -#define PIXEL10_83 Interp8(pOut+dstPitch, c[4], c[2]); +#define PIXEL10_0 *((COLORTYPE *)(pOut + dstPitch)) = c[5]; +#define PIXEL10_10 Interp1(pOut + dstPitch, c[5], c[1]); +#define PIXEL10_11 Interp1(pOut + dstPitch, c[5], c[4]); +#define PIXEL10_13 Interp1(pOut + dstPitch, c[4], c[5]); +#define PIXEL10_21 Interp2(pOut + dstPitch, c[4], c[5], c[2]); +#define PIXEL10_32 Interp3(pOut + dstPitch, c[5], c[2]); +#define PIXEL10_50 Interp5(pOut + dstPitch, c[4], c[5]); +#define PIXEL10_60 Interp6(pOut + dstPitch, c[5], c[4], c[2]); +#define PIXEL10_61 Interp6(pOut + dstPitch, c[5], c[4], c[1]); +#define PIXEL10_81 Interp8(pOut + dstPitch, c[5], c[4]); +#define PIXEL10_83 Interp8(pOut + dstPitch, c[4], c[2]); -#define PIXEL11_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL)) = c[5]; -#define PIXEL11_30 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[1]); -#define PIXEL11_31 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[4]); -#define PIXEL11_32 Interp3(pOut+dstPitch+SIZE_PIXEL, c[5], c[2]); -#define PIXEL11_70 Interp7(pOut+dstPitch+SIZE_PIXEL, c[5], c[4], c[2]); +#define PIXEL11_0 *((COLORTYPE *)(pOut + dstPitch + SIZE_PIXEL)) = c[5]; +#define PIXEL11_30 Interp3(pOut + dstPitch + SIZE_PIXEL, c[5], c[1]); +#define PIXEL11_31 Interp3(pOut + dstPitch + SIZE_PIXEL, c[5], c[4]); +#define PIXEL11_32 Interp3(pOut + dstPitch + SIZE_PIXEL, c[5], c[2]); +#define PIXEL11_70 Interp7(pOut + dstPitch + SIZE_PIXEL, c[5], c[4], c[2]); -#define PIXEL12_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL12_30 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]); -#define PIXEL12_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL12_32 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL12_70 Interp7(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]); +#define PIXEL12_0 *((COLORTYPE *)(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL12_30 Interp3(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[3]); +#define PIXEL12_31 Interp3(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL12_32 Interp3(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL12_70 Interp7(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[2]); -#define PIXEL13_0 *((COLORTYPE*)(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL13_10 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[3]); -#define PIXEL13_12 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL13_14 Interp1(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]); -#define PIXEL13_21 Interp2(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[2]); -#define PIXEL13_31 Interp3(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[2]); -#define PIXEL13_50 Interp5(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]); -#define PIXEL13_60 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[2]); -#define PIXEL13_61 Interp6(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[3]); -#define PIXEL13_82 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL13_83 Interp8(pOut+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[2]); +#define PIXEL13_0 *((COLORTYPE *)(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL13_10 Interp1(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[3]); +#define PIXEL13_12 Interp1(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL13_14 Interp1(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5]); +#define PIXEL13_21 \ + Interp2(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5], c[2]); +#define PIXEL13_31 Interp3(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[2]); +#define PIXEL13_50 Interp5(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5]); +#define PIXEL13_60 \ + Interp6(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[2]); +#define PIXEL13_61 \ + Interp6(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[3]); +#define PIXEL13_82 Interp8(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL13_83 Interp8(pOut + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[2]); -#define PIXEL20_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch)) = c[5]; -#define PIXEL20_10 Interp1(pOut+dstPitch+dstPitch, c[5], c[7]); -#define PIXEL20_12 Interp1(pOut+dstPitch+dstPitch, c[5], c[4]); -#define PIXEL20_14 Interp1(pOut+dstPitch+dstPitch, c[4], c[5]); -#define PIXEL20_21 Interp2(pOut+dstPitch+dstPitch, c[4], c[5], c[8]); -#define PIXEL20_31 Interp3(pOut+dstPitch+dstPitch, c[5], c[8]); -#define PIXEL20_50 Interp5(pOut+dstPitch+dstPitch, c[4], c[5]); -#define PIXEL20_60 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[8]); -#define PIXEL20_61 Interp6(pOut+dstPitch+dstPitch, c[5], c[4], c[7]); -#define PIXEL20_82 Interp8(pOut+dstPitch+dstPitch, c[5], c[4]); -#define PIXEL20_83 Interp8(pOut+dstPitch+dstPitch, c[4], c[8]); +#define PIXEL20_0 *((COLORTYPE *)(pOut + dstPitch + dstPitch)) = c[5]; +#define PIXEL20_10 Interp1(pOut + dstPitch + dstPitch, c[5], c[7]); +#define PIXEL20_12 Interp1(pOut + dstPitch + dstPitch, c[5], c[4]); +#define PIXEL20_14 Interp1(pOut + dstPitch + dstPitch, c[4], c[5]); +#define PIXEL20_21 Interp2(pOut + dstPitch + dstPitch, c[4], c[5], c[8]); +#define PIXEL20_31 Interp3(pOut + dstPitch + dstPitch, c[5], c[8]); +#define PIXEL20_50 Interp5(pOut + dstPitch + dstPitch, c[4], c[5]); +#define PIXEL20_60 Interp6(pOut + dstPitch + dstPitch, c[5], c[4], c[8]); +#define PIXEL20_61 Interp6(pOut + dstPitch + dstPitch, c[5], c[4], c[7]); +#define PIXEL20_82 Interp8(pOut + dstPitch + dstPitch, c[5], c[4]); +#define PIXEL20_83 Interp8(pOut + dstPitch + dstPitch, c[4], c[8]); -#define PIXEL21_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL)) = c[5]; -#define PIXEL21_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]); -#define PIXEL21_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]); -#define PIXEL21_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]); -#define PIXEL21_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4], c[8]); -#define PIXEL22_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL22_30 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]); -#define PIXEL22_31 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL22_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); -#define PIXEL22_70 Interp7(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]); +#define PIXEL21_0 *((COLORTYPE *)(pOut + dstPitch + dstPitch + SIZE_PIXEL)) = c[5]; +#define PIXEL21_30 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[7]); +#define PIXEL21_31 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8]); +#define PIXEL21_32 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[4]); +#define PIXEL21_70 Interp7(pOut + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[4], c[8]); +#define PIXEL22_0 *((COLORTYPE *)(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL22_30 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[9]); +#define PIXEL22_31 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL22_32 Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8]); +#define PIXEL22_70 Interp7(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6], c[8]); -#define PIXEL23_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL23_10 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]); -#define PIXEL23_11 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL23_13 Interp1(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]); -#define PIXEL23_21 Interp2(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5], c[8]); -#define PIXEL23_32 Interp3(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); -#define PIXEL23_50 Interp5(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[5]); -#define PIXEL23_60 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[8]); -#define PIXEL23_61 Interp6(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6], c[9]); -#define PIXEL23_81 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL23_83 Interp8(pOut+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[6], c[8]); +#define PIXEL23_0 \ + *((COLORTYPE *)(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL23_10 \ + Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[9]); +#define PIXEL23_11 \ + Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL23_13 \ + Interp1(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5]); +#define PIXEL23_21 \ + Interp2(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[6], \ + c[5], \ + c[8]); +#define PIXEL23_32 \ + Interp3(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8]); +#define PIXEL23_50 \ + Interp5(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[5]); +#define PIXEL23_60 \ + Interp6(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[6], \ + c[8]); +#define PIXEL23_61 \ + Interp6(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[6], \ + c[9]); +#define PIXEL23_81 \ + Interp8(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL23_83 \ + Interp8(pOut + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, c[6], c[8]); -#define PIXEL30_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch)) = c[5]; -#define PIXEL30_11 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]); -#define PIXEL30_12 Interp1(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]); -#define PIXEL30_20 Interp2(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8], c[4]); -#define PIXEL30_50 Interp5(pOut+dstPitch+dstPitch+dstPitch, c[8], c[4]); -#define PIXEL30_80 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[7]); -#define PIXEL30_81 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[8]); -#define PIXEL30_82 Interp8(pOut+dstPitch+dstPitch+dstPitch, c[5], c[4]); +#define PIXEL30_0 *((COLORTYPE *)(pOut + dstPitch + dstPitch + dstPitch)) = c[5]; +#define PIXEL30_11 Interp1(pOut + dstPitch + dstPitch + dstPitch, c[5], c[8]); +#define PIXEL30_12 Interp1(pOut + dstPitch + dstPitch + dstPitch, c[5], c[4]); +#define PIXEL30_20 Interp2(pOut + dstPitch + dstPitch + dstPitch, c[5], c[8], c[4]); +#define PIXEL30_50 Interp5(pOut + dstPitch + dstPitch + dstPitch, c[8], c[4]); +#define PIXEL30_80 Interp8(pOut + dstPitch + dstPitch + dstPitch, c[5], c[7]); +#define PIXEL30_81 Interp8(pOut + dstPitch + dstPitch + dstPitch, c[5], c[8]); +#define PIXEL30_82 Interp8(pOut + dstPitch + dstPitch + dstPitch, c[5], c[4]); -#define PIXEL31_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL)) = c[5]; -#define PIXEL31_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[7]); -#define PIXEL31_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]); -#define PIXEL31_13 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]); -#define PIXEL31_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5], c[4]); -#define PIXEL31_32 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[4]); -#define PIXEL31_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[5]); -#define PIXEL31_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[4]); -#define PIXEL31_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8], c[7]); -#define PIXEL31_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[5], c[8]); -#define PIXEL31_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL, c[8], c[4]); +#define PIXEL31_0 *((COLORTYPE *)(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL)) = c[5]; +#define PIXEL31_10 Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[7]); +#define PIXEL31_11 Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8]); +#define PIXEL31_13 Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[8], c[5]); +#define PIXEL31_21 Interp2(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[8], c[5], c[4]); +#define PIXEL31_32 Interp3(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[4]); +#define PIXEL31_50 Interp5(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[8], c[5]); +#define PIXEL31_60 Interp6(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8], c[4]); +#define PIXEL31_61 Interp6(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8], c[7]); +#define PIXEL31_81 Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[5], c[8]); +#define PIXEL31_83 Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL, c[8], c[4]); -#define PIXEL32_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL32_10 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]); -#define PIXEL32_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); -#define PIXEL32_14 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]); -#define PIXEL32_21 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5], c[6]); -#define PIXEL32_31 Interp3(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL32_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[5]); -#define PIXEL32_60 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]); -#define PIXEL32_61 Interp6(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[9]); -#define PIXEL32_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); -#define PIXEL32_83 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]); +#define PIXEL32_0 \ + *((COLORTYPE *)(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL)) = c[5]; +#define PIXEL32_10 \ + Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[9]); +#define PIXEL32_12 \ + Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8]); +#define PIXEL32_14 \ + Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[8], c[5]); +#define PIXEL32_21 \ + Interp2(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[8], c[5], c[6]); +#define PIXEL32_31 \ + Interp3(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[6]); +#define PIXEL32_50 \ + Interp5(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[8], c[5]); +#define PIXEL32_60 \ + Interp6(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8], c[6]); +#define PIXEL32_61 \ + Interp6(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8], c[9]); +#define PIXEL32_82 \ + Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[5], c[8]); +#define PIXEL32_83 \ + Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL, c[8], c[6]); -#define PIXEL33_0 *((COLORTYPE*)(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL)) = c[5]; -#define PIXEL33_11 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL33_12 Interp1(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); -#define PIXEL33_20 Interp2(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8], c[6]); -#define PIXEL33_50 Interp5(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[8], c[6]); -#define PIXEL33_80 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[9]); -#define PIXEL33_81 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[6]); -#define PIXEL33_82 Interp8(pOut+dstPitch+dstPitch+dstPitch+SIZE_PIXEL+SIZE_PIXEL+SIZE_PIXEL, c[5], c[8]); +#define PIXEL33_0 \ + *((COLORTYPE *)(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + \ + SIZE_PIXEL)) = c[5]; +#define PIXEL33_11 \ + Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[6]); +#define PIXEL33_12 \ + Interp1(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[8]); +#define PIXEL33_20 \ + Interp2(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[8], \ + c[6]); +#define PIXEL33_50 \ + Interp5(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[8], \ + c[6]); +#define PIXEL33_80 \ + Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[9]); +#define PIXEL33_81 \ + Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[6]); +#define PIXEL33_82 \ + Interp8(pOut + dstPitch + dstPitch + dstPitch + SIZE_PIXEL + SIZE_PIXEL + SIZE_PIXEL, \ + c[5], \ + c[8]); #endif // #ifdef _HQ4X - - // function header #ifdef _16BIT - #ifdef _HQ3X - void hq3x16( - #endif - #ifdef _HQ4X +#ifdef _HQ3X + void hq3x16( +#endif +#ifdef _HQ4X void hq4x16( - #endif +#endif #endif #ifdef _32BIT - #ifdef _HQ3X +#ifdef _HQ3X void hq3x32( - #endif - #ifdef _HQ4X +#endif +#ifdef _HQ4X void hq4x32( - #endif +#endif #endif unsigned char *pIn, unsigned int srcPitch, @@ -308,100 +358,93 @@ unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres ) { - unsigned int yuv[10] = {0}; // yuv[0] not used - // yuv[1-9] allows reusage of calculated YUV values - int x, y; - unsigned int linePlus, lineMinus; + unsigned int yuv[10] = { 0 }; // yuv[0] not used + // yuv[1-9] allows reusage of calculated YUV values + int x, y; + unsigned int linePlus, lineMinus; - COLORTYPE c[10]; // c[0] not used - // +----+----+----+ - // | | | | - // | c1 | c2 | c3 | - // +----+----+----+ - // | | | | - // | c4 | c5 | c6 | - // +----+----+----+ - // | | | | - // | c7 | c8 | c9 | - // +----+----+----+ + COLORTYPE c[10]; // c[0] not used + // +----+----+----+ + // | | | | + // | c1 | c2 | c3 | + // +----+----+----+ + // | | | | + // | c4 | c5 | c6 | + // +----+----+----+ + // | | | | + // | c7 | c8 | c9 | + // +----+----+----+ - for (y=0; y0) - { - // upper border possible: - c[1] = *((COLORTYPE*)(pIn - lineMinus - SIZE_PIXEL)); + if (x > 0) { + // upper border possible: + c[1] = *((COLORTYPE *)(pIn - lineMinus - SIZE_PIXEL)); - c[4] = *((COLORTYPE*)(pIn - SIZE_PIXEL)); + c[4] = *((COLORTYPE *)(pIn - SIZE_PIXEL)); - // lower border possible: - c[7] = *((COLORTYPE*)(pIn + linePlus - SIZE_PIXEL)); - } - else - { // left border - c[1] = c[2]; - c[4] = c[5]; - c[7] = c[8]; - } + // lower border possible: + c[7] = *((COLORTYPE *)(pIn + linePlus - SIZE_PIXEL)); + } else { // left border + c[1] = c[2]; + c[4] = c[5]; + c[7] = c[8]; + } - if (x 0x00300000 ) || - ( abs_32((yuv[5] & 0x0000FF00) - (yuv[k] & 0x0000FF00)) > 0x00000700 ) || - ( abs_32((yuv[5] & 0x000000FF) - (yuv[k] & 0x000000FF)) > 0x00000006 ) - ) { - pattern |= flag; - } - } - flag <<= 1; - } + if ((abs_32((yuv[5] & 0x00FF0000) - (yuv[k] & 0x00FF0000)) > + 0x00300000) || + (abs_32((yuv[5] & 0x0000FF00) - (yuv[k] & 0x0000FF00)) > + 0x00000700) || + (abs_32((yuv[5] & 0x000000FF) - (yuv[k] & 0x000000FF)) > + 0x00000006)) { + pattern |= flag; + } + } + flag <<= 1; + } #ifdef _HQ3X #include "hq3x_pattern.h" @@ -411,28 +454,28 @@ int Xres, int Yres ) #include "hq4x_pattern.h" #endif - pIn += SIZE_PIXEL; - pOut += _MAGNIFICATION * SIZE_PIXEL; - } - pIn += srcPitch - ( Xres * SIZE_PIXEL ); - pOut += dstPitch - ( _MAGNIFICATION * Xres * SIZE_PIXEL ); - pOut += ( _MAGNIFICATION - 1 ) * dstPitch; - } + pIn += SIZE_PIXEL; + pOut += _MAGNIFICATION * SIZE_PIXEL; + } + pIn += srcPitch - (Xres * SIZE_PIXEL); + pOut += dstPitch - (_MAGNIFICATION * Xres * SIZE_PIXEL); + pOut += (_MAGNIFICATION - 1) * dstPitch; + } } #ifdef _32BIT - #ifdef _HQ3X +#ifdef _HQ3X void hq3x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) { - hq3x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); + hq3x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); } - #endif - #ifdef _HQ4X +#endif +#ifdef _HQ4X void hq4x32_32(unsigned char *pIn, unsigned int srcPitch, unsigned char *, unsigned char *pOut, unsigned int dstPitch, int Xres, int Yres) { - hq4x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); + hq4x32(pIn, srcPitch, 0, pOut, dstPitch, Xres, Yres); } - #endif +#endif #endif #undef SIZE_PIXEL diff --git a/src/filters/hq/c/hq_shared.h b/src/filters/hq/c/hq_shared.h index 850a56c7..b7122ac6 100644 --- a/src/filters/hq/c/hq_shared.h +++ b/src/filters/hq/c/hq_shared.h @@ -18,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - hq filter by Maxim Stepin ( http://hiend3d.com ) + hq filter by Maxim Stepin ( http://hiend3d.com ) */ #ifdef RGB555 @@ -52,394 +52,218 @@ #define RBSHIFT4MASK 0x000F81F0 #endif - // we only need the 32bit version because our YUV format has 32bits -#define abs_32( value ) ( ( value ) & 0x7FFFFFFF ) +#define abs_32(value) ((value)&0x7FFFFFFF) - -inline bool Diff( unsigned int YUV1, unsigned int YUV2 ) +inline bool Diff(unsigned int YUV1, unsigned int YUV2) { - if( YUV1 == YUV2 ) return false; // Save some processing power + if (YUV1 == YUV2) + return false; // Save some processing power - return - ( abs_32((YUV1 & 0x00FF0000) - (YUV2 & 0x00FF0000)) > 0x00300000 ) || - ( abs_32((YUV1 & 0x0000FF00) - (YUV2 & 0x0000FF00)) > 0x00000700 ) || - ( abs_32((YUV1 & 0x000000FF) - (YUV2 & 0x000000FF)) > 0x00000006 ); + return (abs_32((YUV1 & 0x00FF0000) - (YUV2 & 0x00FF0000)) > 0x00300000) || + (abs_32((YUV1 & 0x0000FF00) - (YUV2 & 0x0000FF00)) > 0x00000700) || + (abs_32((YUV1 & 0x000000FF) - (YUV2 & 0x000000FF)) > 0x00000006); } - - // =============== // 32bit routines: // =============== // ( c1*3 + c2 ) / 4 // hq3x, hq4x -#define Interp1_32( pc, c1, c2 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 3 ) + \ - ( (c2) & 0x00FF00 ) \ - ) & 0x0003FC00 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 3 ) + \ - ( (c2) & 0xFF00FF ) \ - ) & 0x03FC03FC ) \ - ) >> 2 \ -) - +#define Interp1_32(pc, c1, c2) \ + (*((unsigned int *)(pc)) = \ + ((c1) == (c2)) ? c1 : ((((((c1)&0x00FF00) * 3) + ((c2)&0x00FF00)) & 0x0003FC00) + \ + (((((c1)&0xFF00FF) * 3) + ((c2)&0xFF00FF)) & 0x03FC03FC)) >> \ + 2) // ( c1*2 + c2 + c3 ) / 4 // hq3x, hq4x -#define Interp2_32( pc, c1, c2, c3 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 2 ) + \ - ( (c2) & 0x00FF00 ) + \ - ( (c3) & 0x00FF00 ) \ - ) & 0x0003FC00 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 2 ) + \ - ( (c2) & 0xFF00FF ) + \ - ( (c3) & 0xFF00FF ) \ - ) & 0x03FC03FC ) \ - ) >> 2 \ -) - +#define Interp2_32(pc, c1, c2, c3) \ + (*((unsigned int *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&0x00FF00) * 2) + ((c2)&0x00FF00) + ((c3)&0x00FF00)) & 0x0003FC00) + \ + (((((c1)&0xFF00FF) * 2) + ((c2)&0xFF00FF) + ((c3)&0xFF00FF)) & 0x03FC03FC)) >> \ + 2) // ( c1*7 + c2 ) / 8 // hq3x, hq4x -#define Interp3_32( pc, c1, c2 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 7 ) + \ - ( (c2) & 0x00FF00 ) \ - ) & 0x0007F800 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 7 ) + \ - ( (c2) & 0xFF00FF ) \ - ) & 0x07F807F8 ) \ - ) >> 3 \ -) - +#define Interp3_32(pc, c1, c2) \ + (*((unsigned int *)(pc)) = \ + ((c1) == (c2)) ? c1 : ((((((c1)&0x00FF00) * 7) + ((c2)&0x00FF00)) & 0x0007F800) + \ + (((((c1)&0xFF00FF) * 7) + ((c2)&0xFF00FF)) & 0x07F807F8)) >> \ + 3) // ( c1*2 + (c2+c3)*7 ) / 16 // hq3x, not used by hq4x -#define Interp4_32( pc, c1, c2, c3 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( ( ( (c1) & 0x00FF00 ) * 2 ) + ( ( ( (c2) & 0x00FF00 ) + ( (c3) & 0x00FF00 ) ) * 7 ) ) & 0x000FF000 ) + \ - ( ( ( ( (c1) & 0xFF00FF ) * 2 ) + ( ( ( (c2) & 0xFF00FF ) + ( (c3) & 0xFF00FF ) ) * 7 ) ) & 0x0FF00FF0 ) \ - ) >> 4 \ -) - +#define Interp4_32(pc, c1, c2, c3) \ + (*((unsigned int *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&0x00FF00) * 2) + ((((c2)&0x00FF00) + ((c3)&0x00FF00)) * 7)) & \ + 0x000FF000) + \ + (((((c1)&0xFF00FF) * 2) + ((((c2)&0xFF00FF) + ((c3)&0xFF00FF)) * 7)) & \ + 0x0FF00FF0)) >> \ + 4) // ( c1 + c2 ) / 2 // hq3x, hq4x -#define Interp5_32( pc, c1, c2 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( (c1) & 0x00FF00 ) + \ - ( (c2) & 0x00FF00 ) \ - ) & 0x0001FE00 ) \ - + \ - ( ( \ - ( (c1) & 0xFF00FF ) + \ - ( (c2) & 0xFF00FF ) \ - ) & 0x01FE01FE ) \ - ) >> 1 \ -) - +#define Interp5_32(pc, c1, c2) \ + (*((unsigned int *)(pc)) = \ + ((c1) == (c2)) ? c1 : (((((c1)&0x00FF00) + ((c2)&0x00FF00)) & 0x0001FE00) + \ + ((((c1)&0xFF00FF) + ((c2)&0xFF00FF)) & 0x01FE01FE)) >> \ + 1) // ( c1*5 + c2*2 + c3 ) / 8 // hq4x -#define Interp6_32( pc, c1, c2, c3 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 5 ) + \ - ( ( (c2) & 0x00FF00 ) * 2 ) + \ - ( (c3) & 0x00FF00 ) \ - ) & 0x0007F800 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 5 ) + \ - ( ( (c2) & 0xFF00FF ) * 2 ) + \ - ( (c3) & 0xFF00FF ) \ - ) & 0x07F807F8 ) \ - ) >> 3 \ -) - +#define Interp6_32(pc, c1, c2, c3) \ + (*((unsigned int *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&0x00FF00) * 5) + (((c2)&0x00FF00) * 2) + ((c3)&0x00FF00)) & \ + 0x0007F800) + \ + (((((c1)&0xFF00FF) * 5) + (((c2)&0xFF00FF) * 2) + ((c3)&0xFF00FF)) & \ + 0x07F807F8)) >> \ + 3) // ( c1*6 + c2 + c3 ) / 8 // hq4x -#define Interp7_32( pc, c1, c2, c3 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 6 ) + \ - ( (c2) & 0x00FF00 ) + \ - ( (c3) & 0x00FF00 ) \ - ) & 0x0007F800 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 6 ) + \ - ( (c2) & 0xFF00FF ) + \ - ( (c3) & 0xFF00FF ) \ - ) & 0x07F807F8 ) \ - ) >> 3 \ -) - +#define Interp7_32(pc, c1, c2, c3) \ + (*((unsigned int *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&0x00FF00) * 6) + ((c2)&0x00FF00) + ((c3)&0x00FF00)) & 0x0007F800) + \ + (((((c1)&0xFF00FF) * 6) + ((c2)&0xFF00FF) + ((c3)&0xFF00FF)) & 0x07F807F8)) >> \ + 3) // ( c1*5 + c2*3 ) / 8 // hq4x -#define Interp8_32( pc, c1, c2 ) \ -( \ - *( (unsigned int *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & 0x00FF00 ) * 5 ) + \ - ( ( (c2) & 0x00FF00 ) * 3 ) \ - ) & 0x0007F800 ) \ - + \ - ( ( \ - ( ( (c1) & 0xFF00FF ) * 5 ) + \ - ( ( (c2) & 0xFF00FF ) * 3 ) \ - ) & 0x07F807F8 ) \ - ) >> 3 \ -) - +#define Interp8_32(pc, c1, c2) \ + (*((unsigned int *)(pc)) = \ + ((c1) == (c2)) ? c1 \ + : ((((((c1)&0x00FF00) * 5) + (((c2)&0x00FF00) * 3)) & 0x0007F800) + \ + (((((c1)&0xFF00FF) * 5) + (((c2)&0xFF00FF) * 3)) & 0x07F807F8)) >> \ + 3) // 32 bit input color // 0x00YYUUVV return value -inline unsigned int RGBtoYUV_32( unsigned int c ) +inline unsigned int RGBtoYUV_32(unsigned int c) { - // Division through 3 slows down the emulation about 10% !!! + // Division through 3 slows down the emulation about 10% !!! - register unsigned char r, g, b; - b = c & 0x0000FF; - g = ( c & 0x00FF00 ) >> 8; - r = c >> 16; - return ( (r + g + b) << 14 ) + - ( ( r - b + 512 ) << 4 ) + - ( ( 2*g - r - b ) >> 3 ) + 128; + register unsigned char r, g, b; + b = c & 0x0000FF; + g = (c & 0x00FF00) >> 8; + r = c >> 16; + return ((r + g + b) << 14) + ((r - b + 512) << 4) + ((2 * g - r - b) >> 3) + 128; - // unoptimized: - //unsigned char r, g, b, Y, u, v; - //b = (c & 0x000000FF); - //g = (c & 0x0000FF00) >> 8; - //r = (c & 0x00FF0000) >> 16; - //Y = (r + g + b) >> 2; - //u = 128 + ((r - b) >> 2); - //v = 128 + ((-r + 2*g -b)>>3); - //return (Y<<16) + (u<<8) + v; + // unoptimized: + // unsigned char r, g, b, Y, u, v; + // b = (c & 0x000000FF); + // g = (c & 0x0000FF00) >> 8; + // r = (c & 0x00FF0000) >> 16; + // Y = (r + g + b) >> 2; + // u = 128 + ((r - b) >> 2); + // v = 128 + ((-r + 2*g -b)>>3); + // return (Y<<16) + (u<<8) + v; } - - // =============== // 16bit routines: // =============== // ( c1*3 + c2 ) / 4 // hq3x, hq4x -#define Interp1_16( pc, c1, c2 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 3 ) + \ - ( (c2) & GMASK ) \ - ) & GSHIFT2MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 3 ) + \ - ( (c2) & RBMASK ) \ - ) & RBSHIFT2MASK ) \ - ) >> 2 \ -) - +#define Interp1_16(pc, c1, c2) \ + (*((unsigned short *)(pc)) = \ + ((c1) == (c2)) ? c1 : ((((((c1)&GMASK) * 3) + ((c2)&GMASK)) & GSHIFT2MASK) + \ + (((((c1)&RBMASK) * 3) + ((c2)&RBMASK)) & RBSHIFT2MASK)) >> \ + 2) // ( c1*2 + c2 + c3 ) / 4 // hq3x, hq4x -#define Interp2_16( pc, c1, c2, c3 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 2 ) + \ - ( (c2) & GMASK ) + \ - ( (c3) & GMASK ) \ - ) & GSHIFT2MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 2 ) + \ - ( (c2) & RBMASK ) + \ - ( (c3) & RBMASK ) \ - ) & RBSHIFT2MASK ) \ - ) >> 2 \ -) - +#define Interp2_16(pc, c1, c2, c3) \ + (*((unsigned short *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&GMASK) * 2) + ((c2)&GMASK) + ((c3)&GMASK)) & GSHIFT2MASK) + \ + (((((c1)&RBMASK) * 2) + ((c2)&RBMASK) + ((c3)&RBMASK)) & RBSHIFT2MASK)) >> \ + 2) // ( c1*7 + c2 ) / 8 // hq3x, hq4x -#define Interp3_16( pc, c1, c2 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 7 ) + \ - ( (c2) & GMASK ) \ - ) & GSHIFT3MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 7 ) + \ - ( (c2) & RBMASK ) \ - ) & RBSHIFT3MASK ) \ - ) >> 3 \ -) - +#define Interp3_16(pc, c1, c2) \ + (*((unsigned short *)(pc)) = \ + ((c1) == (c2)) ? c1 : ((((((c1)&GMASK) * 7) + ((c2)&GMASK)) & GSHIFT3MASK) + \ + (((((c1)&RBMASK) * 7) + ((c2)&RBMASK)) & RBSHIFT3MASK)) >> \ + 3) // ( c1*2 + (c2+c3)*7 ) / 16 // hq3x, not used by hq4x -#define Interp4_16( pc, c1, c2, c3 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( ( ( (c1) & GMASK ) * 2 ) + ( ( ( (c2) & GMASK ) + ( (c3) & GMASK ) ) * 7 ) ) & GSHIFT4MASK ) + \ - ( ( ( ( (c1) & RBMASK ) * 2 ) + ( ( ( (c2) & RBMASK ) + ( (c3) & RBMASK ) ) * 7 ) ) & RBSHIFT4MASK ) \ - ) >> 4 \ -) - +#define Interp4_16(pc, c1, c2, c3) \ + (*((unsigned short *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&GMASK) * 2) + ((((c2)&GMASK) + ((c3)&GMASK)) * 7)) & GSHIFT4MASK) + \ + (((((c1)&RBMASK) * 2) + ((((c2)&RBMASK) + ((c3)&RBMASK)) * 7)) & \ + RBSHIFT4MASK)) >> \ + 4) // ( c1 + c2 ) / 2 // hq3x, hq4x -#define Interp5_16( pc, c1, c2 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( (c1) & GMASK ) + \ - ( (c2) & GMASK ) \ - ) & GSHIFT1MASK ) \ - + \ - ( ( \ - ( (c1) & RBMASK ) + \ - ( (c2) & RBMASK ) \ - ) & RBSHIFT1MASK ) \ - ) >> 1 \ -) - +#define Interp5_16(pc, c1, c2) \ + (*((unsigned short *)(pc)) = \ + ((c1) == (c2)) ? c1 : (((((c1)&GMASK) + ((c2)&GMASK)) & GSHIFT1MASK) + \ + ((((c1)&RBMASK) + ((c2)&RBMASK)) & RBSHIFT1MASK)) >> \ + 1) // ( c1*5 + c2*2 + c3 ) / 8 // hq4x -#define Interp6_16( pc, c1, c2, c3 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 5 ) + \ - ( ( (c2) & GMASK ) * 2 ) + \ - ( (c3) & GMASK ) \ - ) & GSHIFT3MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 5 ) + \ - ( ( (c2) & RBMASK ) * 2 ) + \ - ( (c3) & RBMASK ) \ - ) & RBSHIFT3MASK ) \ - ) >> 3 \ -) - +#define Interp6_16(pc, c1, c2, c3) \ + (*((unsigned short *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&GMASK) * 5) + (((c2)&GMASK) * 2) + ((c3)&GMASK)) & GSHIFT3MASK) + \ + (((((c1)&RBMASK) * 5) + (((c2)&RBMASK) * 2) + ((c3)&RBMASK)) & \ + RBSHIFT3MASK)) >> \ + 3) // ( c1*6 + c2 + c3 ) / 8 // hq4x -#define Interp7_16( pc, c1, c2, c3 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( ( (c1) == (c2) ) == (c3) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 6 ) + \ - ( (c2) & GMASK ) + \ - ( (c3) & GMASK ) \ - ) & GSHIFT3MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 6 ) + \ - ( (c2) & RBMASK ) + \ - ( (c3) & RBMASK ) \ - ) & RBSHIFT3MASK ) \ - ) >> 3 \ -) - +#define Interp7_16(pc, c1, c2, c3) \ + (*((unsigned short *)(pc)) = \ + (((c1) == (c2)) == (c3)) \ + ? c1 \ + : ((((((c1)&GMASK) * 6) + ((c2)&GMASK) + ((c3)&GMASK)) & GSHIFT3MASK) + \ + (((((c1)&RBMASK) * 6) + ((c2)&RBMASK) + ((c3)&RBMASK)) & RBSHIFT3MASK)) >> \ + 3) // ( c1*5 + c2*3 ) / 8 // hq4x -#define Interp8_16( pc, c1, c2 ) \ -( \ - *( (unsigned short *)(pc) ) = \ - ( (c1) == (c2) ) ? c1 : \ - ( \ - ( ( \ - ( ( (c1) & GMASK ) * 5 ) + \ - ( ( (c2) & GMASK ) * 3 ) \ - ) & GSHIFT3MASK ) \ - + \ - ( ( \ - ( ( (c1) & RBMASK ) * 5 ) + \ - ( ( (c2) & RBMASK ) * 3 ) \ - ) & RBSHIFT3MASK ) \ - ) >> 3 \ -) - +#define Interp8_16(pc, c1, c2) \ + (*((unsigned short *)(pc)) = \ + ((c1) == (c2)) ? c1 \ + : ((((((c1)&GMASK) * 5) + (((c2)&GMASK) * 3)) & GSHIFT3MASK) + \ + (((((c1)&RBMASK) * 5) + (((c2)&RBMASK) * 3)) & RBSHIFT3MASK)) >> \ + 3) // 16 bit input color // 0x00YYUUVV return value -inline unsigned int RGBtoYUV_16( unsigned short c ) +inline unsigned int RGBtoYUV_16(unsigned short c) { - // Division through 3 slows down the emulation about 10% !!! + // Division through 3 slows down the emulation about 10% !!! - register unsigned char r, g, b; + register unsigned char r, g, b; #ifdef RGB555 - r = ( c & 0x7C00 ) >> 7; - g = ( c & 0x03E0 ) >> 2; - b = ( c & 0x001F ) << 3; + r = (c & 0x7C00) >> 7; + g = (c & 0x03E0) >> 2; + b = (c & 0x001F) << 3; #else - r = ( c & 0xF800 ) >> 8; - g = ( c & 0x07E0 ) >> 3; - b = ( c & 0x001F ) << 3; + r = (c & 0xF800) >> 8; + g = (c & 0x07E0) >> 3; + b = (c & 0x001F) << 3; #endif - return ( (r + g + b) << 14 ) + - ( ( r - b + 512 ) << 4 ) + - ( ( 2*g - r - b ) >> 3 ) + 128; + return ((r + g + b) << 14) + ((r - b + 512) << 4) + ((2 * g - r - b) >> 3) + 128; } diff --git a/src/filters/hq2x.h b/src/filters/hq2x.h index 49c0b268..00a78dc2 100644 --- a/src/filters/hq2x.h +++ b/src/filters/hq2x.h @@ -1,1824 +1,1676 @@ -case 0 : -case 1 : -case 4 : -case 5 : -case 32 : -case 33 : -case 36 : -case 37 : -case 128 : -case 129 : -case 132 : -case 133 : -case 160 : -case 161 : -case 164 : -case 165 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 2 : -case 34 : -case 130 : -case 162 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 3 : -case 35 : -case 131 : -case 163 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 6 : -case 38 : -case 134 : -case 166 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 7 : -case 39 : -case 135 : -case 167 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I211(4, 3, 7); - P3 = I211(4, 5, 7); -} break; -case 8 : -case 12 : -case 136 : -case 140 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 9 : -case 13 : -case 137 : -case 141 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); -} break; -case 10 : -case 138 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 11 : -case 139 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 15 : -case 143 : -{ - P2 = I31(4, 6); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 16 : -case 17 : -case 48 : -case 49 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 18 : -case 50 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 19 : -case 51 : -{ - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = I31(4, 2); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 20 : -case 21 : -case 52 : -case 53 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); -} break; -case 22 : -case 54 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 23 : -case 55 : -{ - P2 = I211(4, 3, 7); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 24 : -case 66 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 25 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 26 : -case 31 : -case 95 : -{ - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 27 : -case 75 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 28 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 29 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 30 : -case 86 : -{ - P0 = I31(4, 0); - P2 = I31(4, 6); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 40 : -case 44 : -case 168 : -case 172 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 41 : -case 45 : -case 169 : -case 173 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); -} break; -case 42 : -case 170 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 43 : -case 171 : -{ - P1 = I31(4, 2); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 46 : -case 174 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = I31(4, 5); - P2 = I31(4, 7); - P3 = I211(4, 5, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 56 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 57 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 58 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 59 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 60 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 61 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 8); -} break; -case 62 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 63 : -{ - P2 = I31(4, 7); - P3 = I31(4, 8); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 64 : -case 65 : -case 68 : -case 69 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 67 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 70 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 71 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 8); -} break; -case 72 : -case 76 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 73 : -case 77 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = I31(4, 6); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 74 : -case 107 : -case 123 : -{ - P1 = I31(4, 2); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 78 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 79 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 81 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 82 : -case 214 : -case 222 : -{ - P0 = I31(4, 0); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 83 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 84 : -case 85 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = I31(4, 8); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 87 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 89 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 90 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 91 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 92 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 93 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 94 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 96 : -case 97 : -case 100 : -case 101 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 98 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 99 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 102 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 103 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 8); -} break; -case 104 : -case 108 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 105 : -case 109 : -{ - P1 = I211(4, 1, 5); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 106 : -case 120 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 110 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 111 : -{ - P1 = I31(4, 5); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 113 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = I31(4, 8); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 114 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 115 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 116 : -case 117 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 118 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - P3 = I31(4, 8); - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 119 : -{ - P2 = I31(4, 3); - P3 = I31(4, 8); - if (MUR) { - P0 = I31(4, 3); - P1 = IC(4); - } else { - P0 = I521(4, 1, 3); - P1 = I332(1, 5, 4); - } -} break; -case 121 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } -} break; -case 122 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = I31(4, 8); - } else { - P3 = I611(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 124 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } -} break; -case 125 : -{ - P1 = I31(4, 1); - P3 = I31(4, 8); - if (MDL) { - P0 = I31(4, 1); - P2 = IC(4); - } else { - P0 = I521(4, 3, 1); - P2 = I332(3, 7, 4); - } -} break; -case 126 : -{ - P0 = I31(4, 0); - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 127 : -{ - P3 = I31(4, 8); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 144 : -case 145 : -case 176 : -case 177 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 146 : -case 178 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (MUR) { - P1 = I31(4, 2); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 147 : -case 179 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 148 : -case 149 : -case 180 : -case 181 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); -} break; -case 150 : -case 182 : -{ - P0 = I31(4, 0); - P2 = I211(4, 3, 7); - if (MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 151 : -case 183 : -{ - P0 = I31(4, 3); - P2 = I211(4, 3, 7); - P3 = I31(4, 7); - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 152 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 153 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 154 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 155 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 156 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 157 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 6); - P3 = I31(4, 7); -} break; -case 158 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 159 : -{ - P2 = I31(4, 6); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 184 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 185 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 186 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 187 : -{ - P1 = I31(4, 2); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - P2 = I31(4, 7); - } else { - P0 = I332(1, 3, 4); - P2 = I521(4, 3, 7); - } -} break; -case 188 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 189 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - P2 = I31(4, 7); - P3 = I31(4, 7); -} break; -case 190 : -{ - P0 = I31(4, 0); - P2 = I31(4, 7); - if (MUR) { - P1 = IC(4); - P3 = I31(4, 7); - } else { - P1 = I332(1, 5, 4); - P3 = I521(4, 5, 7); - } -} break; -case 191 : -{ - P2 = I31(4, 7); - P3 = I31(4, 7); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 192 : -case 193 : -case 196 : -case 197 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 194 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 195 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 198 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 199 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 6); - P3 = I31(4, 5); -} break; -case 200 : -case 204 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (MDL) { - P2 = I31(4, 6); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 201 : -case 205 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } -} break; -case 202 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 203 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - P3 = I31(4, 5); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 206 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 207 : -{ - P2 = I31(4, 6); - P3 = I31(4, 5); - if (MUL) { - P0 = IC(4); - P1 = I31(4, 5); - } else { - P0 = I332(1, 3, 4); - P1 = I521(4, 1, 5); - } -} break; -case 208 : -case 209 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 210 : -case 216 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 211 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 212 : -case 213 : -{ - P0 = I211(4, 1, 3); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 215 : -{ - P0 = I31(4, 3); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 217 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 218 : -{ - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 219 : -{ - P1 = I31(4, 2); - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 220 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = I31(4, 6); - } else { - P2 = I611(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 221 : -{ - P0 = I31(4, 1); - P2 = I31(4, 6); - if (MDR) { - P1 = I31(4, 1); - P3 = IC(4); - } else { - P1 = I521(4, 5, 1); - P3 = I332(5, 7, 4); - } -} break; -case 223 : -{ - P2 = I31(4, 6); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 224 : -case 225 : -case 228 : -case 229 : -{ - P0 = I211(4, 1, 3); - P1 = I211(4, 1, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 226 : -{ - P0 = I31(4, 0); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 227 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 230 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 231 : -{ - P0 = I31(4, 3); - P1 = I31(4, 5); - P2 = I31(4, 3); - P3 = I31(4, 5); -} break; -case 232 : -case 236 : -{ - P0 = I31(4, 0); - P1 = I211(4, 1, 5); - if (MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 233 : -case 237 : -{ - P0 = I31(4, 1); - P1 = I211(4, 1, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } -} break; -case 234 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = I31(4, 0); - } else { - P0 = I611(4, 1, 3); - } -} break; -case 235 : -{ - P1 = I31(4, 2); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 238 : -{ - P0 = I31(4, 0); - P1 = I31(4, 5); - if (MDL) { - P2 = IC(4); - P3 = I31(4, 5); - } else { - P2 = I332(3, 7, 4); - P3 = I521(4, 7, 5); - } -} break; -case 239 : -{ - P1 = I31(4, 5); - P3 = I31(4, 5); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 240 : -case 241 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 242 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUR) { - P1 = I31(4, 2); - } else { - P1 = I611(4, 1, 5); - } -} break; -case 243 : -{ - P0 = I31(4, 3); - P1 = I31(4, 2); - if (MDR) { - P2 = I31(4, 3); - P3 = IC(4); - } else { - P2 = I521(4, 7, 3); - P3 = I332(5, 7, 4); - } -} break; -case 244 : -case 245 : -{ - P0 = I211(4, 1, 3); - P1 = I31(4, 1); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 246 : -{ - P0 = I31(4, 0); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 247 : -{ - P0 = I31(4, 3); - P2 = I31(4, 3); - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 249 : -{ - P0 = I31(4, 1); - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } -} break; -case 251 : -{ - P1 = I31(4, 2); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 252 : -{ - P0 = I31(4, 0); - P1 = I31(4, 1); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 253 : -{ - P0 = I31(4, 1); - P1 = I31(4, 1); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } -} break; -case 254 : -{ - P0 = I31(4, 0); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 255 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } +case 0: +case 1: +case 4: +case 5: +case 32: +case 33: +case 36: +case 37: +case 128: +case 129: +case 132: +case 133: +case 160: +case 161: +case 164: +case 165: { + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 2: +case 34: +case 130: +case 162: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 3: +case 35: +case 131: +case 163: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 6: +case 38: +case 134: +case 166: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 7: +case 39: +case 135: +case 167: { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I211(4, 3, 7); + P3 = I211(4, 5, 7); +} break; +case 8: +case 12: +case 136: +case 140: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); +} break; +case 9: +case 13: +case 137: +case 141: { + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); +} break; +case 10: +case 138: { + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 11: +case 139: { + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 14: +case 142: { + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 15: +case 143: { + P2 = I31(4, 6); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 16: +case 17: +case 48: +case 49: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); +} break; +case 18: +case 50: { + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 19: +case 51: { + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = I31(4, 2); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 20: +case 21: +case 52: +case 53: { + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); +} break; +case 22: +case 54: { + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 23: +case 55: { + P2 = I211(4, 3, 7); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 24: +case 66: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 25: { + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 26: +case 31: +case 95: { + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 27: +case 75: { + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 28: { + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 29: { + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 30: +case 86: { + P0 = I31(4, 0); + P2 = I31(4, 6); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 40: +case 44: +case 168: +case 172: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); +} break; +case 41: +case 45: +case 169: +case 173: { + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); +} break; +case 42: +case 170: { + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 43: +case 171: { + P1 = I31(4, 2); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 46: +case 174: { + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 47: +case 175: { + P1 = I31(4, 5); + P2 = I31(4, 7); + P3 = I211(4, 5, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 56: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 57: { + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 58: { + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 59: { + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 60: { + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 61: { + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 8); +} break; +case 62: { + P0 = I31(4, 0); + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 63: { + P2 = I31(4, 7); + P3 = I31(4, 8); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 64: +case 65: +case 68: +case 69: { + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 67: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 70: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 71: { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 8); +} break; +case 72: +case 76: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 73: +case 77: { + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = I31(4, 6); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 74: +case 107: +case 123: { + P1 = I31(4, 2); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 78: { + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 79: { + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 80: +case 81: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 82: +case 214: +case 222: { + P0 = I31(4, 0); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 83: { + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 84: +case 85: { + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = I31(4, 8); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 87: { + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 88: +case 248: +case 250: { + P0 = I31(4, 0); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 89: { + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 90: { + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 91: { + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 92: { + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 93: { + P0 = I31(4, 1); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 94: { + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 96: +case 97: +case 100: +case 101: { + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 98: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 99: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 102: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 103: { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 8); +} break; +case 104: +case 108: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 105: +case 109: { + P1 = I211(4, 1, 5); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 106: +case 120: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 110: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 111: { + P1 = I31(4, 5); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 112: +case 113: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = I31(4, 8); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 114: { + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 115: { + P0 = I31(4, 3); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 116: +case 117: { + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 118: { + P0 = I31(4, 0); + P2 = I31(4, 3); + P3 = I31(4, 8); + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 119: { + P2 = I31(4, 3); + P3 = I31(4, 8); + if (MUR) { + P0 = I31(4, 3); + P1 = IC(4); + } else { + P0 = I521(4, 1, 3); + P1 = I332(1, 5, 4); + } +} break; +case 121: { + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } +} break; +case 122: { + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = I31(4, 8); + } else { + P3 = I611(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 124: { + P0 = I31(4, 0); + P1 = I31(4, 1); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } +} break; +case 125: { + P1 = I31(4, 1); + P3 = I31(4, 8); + if (MDL) { + P0 = I31(4, 1); + P2 = IC(4); + } else { + P0 = I521(4, 3, 1); + P2 = I332(3, 7, 4); + } +} break; +case 126: { + P0 = I31(4, 0); + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 127: { + P3 = I31(4, 8); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 144: +case 145: +case 176: +case 177: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 146: +case 178: { + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (MUR) { + P1 = I31(4, 2); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 147: +case 179: { + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 148: +case 149: +case 180: +case 181: { + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); +} break; +case 150: +case 182: { + P0 = I31(4, 0); + P2 = I211(4, 3, 7); + if (MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 151: +case 183: { + P0 = I31(4, 3); + P2 = I211(4, 3, 7); + P3 = I31(4, 7); + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 152: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 153: { + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 154: { + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 155: { + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 156: { + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 157: { + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 6); + P3 = I31(4, 7); +} break; +case 158: { + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 159: { + P2 = I31(4, 6); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 184: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 185: { + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 186: { + P2 = I31(4, 7); + P3 = I31(4, 7); + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 187: { + P1 = I31(4, 2); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + P2 = I31(4, 7); + } else { + P0 = I332(1, 3, 4); + P2 = I521(4, 3, 7); + } +} break; +case 188: { + P0 = I31(4, 0); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 189: { + P0 = I31(4, 1); + P1 = I31(4, 1); + P2 = I31(4, 7); + P3 = I31(4, 7); +} break; +case 190: { + P0 = I31(4, 0); + P2 = I31(4, 7); + if (MUR) { + P1 = IC(4); + P3 = I31(4, 7); + } else { + P1 = I332(1, 5, 4); + P3 = I521(4, 5, 7); + } +} break; +case 191: { + P2 = I31(4, 7); + P3 = I31(4, 7); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 192: +case 193: +case 196: +case 197: { + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 194: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 195: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 198: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 199: { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 6); + P3 = I31(4, 5); +} break; +case 200: +case 204: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (MDL) { + P2 = I31(4, 6); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 201: +case 205: { + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } +} break; +case 202: { + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 203: { + P1 = I31(4, 2); + P2 = I31(4, 6); + P3 = I31(4, 5); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 206: { + P1 = I31(4, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 207: { + P2 = I31(4, 6); + P3 = I31(4, 5); + if (MUL) { + P0 = IC(4); + P1 = I31(4, 5); + } else { + P0 = I332(1, 3, 4); + P1 = I521(4, 1, 5); + } +} break; +case 208: +case 209: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 210: +case 216: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 211: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 212: +case 213: { + P0 = I211(4, 1, 3); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 215: { + P0 = I31(4, 3); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 217: { + P0 = I31(4, 1); + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 218: { + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 219: { + P1 = I31(4, 2); + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 220: { + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = I31(4, 6); + } else { + P2 = I611(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 221: { + P0 = I31(4, 1); + P2 = I31(4, 6); + if (MDR) { + P1 = I31(4, 1); + P3 = IC(4); + } else { + P1 = I521(4, 5, 1); + P3 = I332(5, 7, 4); + } +} break; +case 223: { + P2 = I31(4, 6); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 224: +case 225: +case 228: +case 229: { + P0 = I211(4, 1, 3); + P1 = I211(4, 1, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 226: { + P0 = I31(4, 0); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 227: { + P0 = I31(4, 3); + P1 = I31(4, 2); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 230: { + P0 = I31(4, 0); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 231: { + P0 = I31(4, 3); + P1 = I31(4, 5); + P2 = I31(4, 3); + P3 = I31(4, 5); +} break; +case 232: +case 236: { + P0 = I31(4, 0); + P1 = I211(4, 1, 5); + if (MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 233: +case 237: { + P0 = I31(4, 1); + P1 = I211(4, 1, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } +} break; +case 234: { + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = I31(4, 0); + } else { + P0 = I611(4, 1, 3); + } +} break; +case 235: { + P1 = I31(4, 2); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 238: { + P0 = I31(4, 0); + P1 = I31(4, 5); + if (MDL) { + P2 = IC(4); + P3 = I31(4, 5); + } else { + P2 = I332(3, 7, 4); + P3 = I521(4, 7, 5); + } +} break; +case 239: { + P1 = I31(4, 5); + P3 = I31(4, 5); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 240: +case 241: { + P0 = I211(4, 1, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 242: { + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUR) { + P1 = I31(4, 2); + } else { + P1 = I611(4, 1, 5); + } +} break; +case 243: { + P0 = I31(4, 3); + P1 = I31(4, 2); + if (MDR) { + P2 = I31(4, 3); + P3 = IC(4); + } else { + P2 = I521(4, 7, 3); + P3 = I332(5, 7, 4); + } +} break; +case 244: +case 245: { + P0 = I211(4, 1, 3); + P1 = I31(4, 1); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 246: { + P0 = I31(4, 0); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 247: { + P0 = I31(4, 3); + P2 = I31(4, 3); + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 249: { + P0 = I31(4, 1); + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } +} break; +case 251: { + P1 = I31(4, 2); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 252: { + P0 = I31(4, 0); + P1 = I31(4, 1); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 253: { + P0 = I31(4, 1); + P1 = I31(4, 1); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } +} break; +case 254: { + P0 = I31(4, 0); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 255: { + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } } break; diff --git a/src/filters/interp.h b/src/filters/interp.h index 57a329c1..0a269847 100644 --- a/src/filters/interp.h +++ b/src/filters/interp.h @@ -35,7 +35,6 @@ #include - typedef uint16_t interp_uint16; typedef uint32_t interp_uint32; @@ -53,80 +52,102 @@ static unsigned interp_bits_per_pixel; static inline u16 interp_16_521(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*2 + INTERP_16_MASK_1(p3)*1) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*2 + INTERP_16_MASK_2(p3)*1) / 8); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 5 + INTERP_16_MASK_1(p2) * 2 + + INTERP_16_MASK_1(p3) * 1) / + 8) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 5 + INTERP_16_MASK_2(p2) * 2 + + INTERP_16_MASK_2(p3) * 1) / + 8); } static inline u16 interp_16_332(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)*2) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)*2) / 8); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 3 + INTERP_16_MASK_1(p2) * 3 + + INTERP_16_MASK_1(p3) * 2) / + 8) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 3 + INTERP_16_MASK_2(p2) * 3 + + INTERP_16_MASK_2(p3) * 2) / + 8); } static inline u16 interp_16_611(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8); + return INTERP_16_MASK_1( + (INTERP_16_MASK_1(p1) * 6 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 8) | + INTERP_16_MASK_2( + (INTERP_16_MASK_2(p1) * 6 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 8); } static inline u16 interp_16_71(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*7 + INTERP_16_MASK_1(p2)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*7 + INTERP_16_MASK_2(p2)) / 8); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 7 + INTERP_16_MASK_1(p2)) / 8) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 7 + INTERP_16_MASK_2(p2)) / 8); } static inline u16 interp_16_211(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4); + return INTERP_16_MASK_1( + (INTERP_16_MASK_1(p1) * 2 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 4) | + INTERP_16_MASK_2( + (INTERP_16_MASK_2(p1) * 2 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 4); } static inline u16 interp_16_772(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1(((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2))*7 + INTERP_16_MASK_1(p3)*2) / 16) - | INTERP_16_MASK_2(((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2))*7 + INTERP_16_MASK_2(p3)*2) / 16); + return INTERP_16_MASK_1( + ((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) * 7 + INTERP_16_MASK_1(p3) * 2) / + 16) | + INTERP_16_MASK_2( + ((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) * 7 + INTERP_16_MASK_2(p3) * 2) / + 16); } static inline u16 interp_16_11(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) + INTERP_16_MASK_1(p2)) / 2) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) + INTERP_16_MASK_2(p2)) / 2); } static inline u16 interp_16_31(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*3 + INTERP_16_MASK_1(p2)) / 4) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*3 + INTERP_16_MASK_2(p2)) / 4); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 3 + INTERP_16_MASK_1(p2)) / 4) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 3 + INTERP_16_MASK_2(p2)) / 4); } static inline u16 interp_16_1411(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16); + return INTERP_16_MASK_1( + (INTERP_16_MASK_1(p1) * 14 + INTERP_16_MASK_1(p2) + INTERP_16_MASK_1(p3)) / 16) | + INTERP_16_MASK_2( + (INTERP_16_MASK_2(p1) * 14 + INTERP_16_MASK_2(p2) + INTERP_16_MASK_2(p3)) / 16); } static inline u16 interp_16_431(u16 p1, u16 p2, u16 p3) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*4 + INTERP_16_MASK_1(p2)*3 + INTERP_16_MASK_1(p3)) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*4 + INTERP_16_MASK_2(p2)*3 + INTERP_16_MASK_2(p3)) / 8); + return INTERP_16_MASK_1( + (INTERP_16_MASK_1(p1) * 4 + INTERP_16_MASK_1(p2) * 3 + INTERP_16_MASK_1(p3)) / + 8) | + INTERP_16_MASK_2( + (INTERP_16_MASK_2(p1) * 4 + INTERP_16_MASK_2(p2) * 3 + INTERP_16_MASK_2(p3)) / + 8); } static inline u16 interp_16_53(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*5 + INTERP_16_MASK_1(p2)*3) / 8) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*5 + INTERP_16_MASK_2(p2)*3) / 8); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 5 + INTERP_16_MASK_1(p2) * 3) / 8) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 5 + INTERP_16_MASK_2(p2) * 3) / 8); } static inline u16 interp_16_151(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*15 + INTERP_16_MASK_1(p2)) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*15 + INTERP_16_MASK_2(p2)) / 16); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 15 + INTERP_16_MASK_1(p2)) / 16) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 15 + INTERP_16_MASK_2(p2)) / 16); } static inline u16 interp_16_97(u16 p1, u16 p2) { - return INTERP_16_MASK_1((INTERP_16_MASK_1(p1)*9 + INTERP_16_MASK_1(p2)*7) / 16) - | INTERP_16_MASK_2((INTERP_16_MASK_2(p1)*9 + INTERP_16_MASK_2(p2)*7) / 16); + return INTERP_16_MASK_1((INTERP_16_MASK_1(p1) * 9 + INTERP_16_MASK_1(p2) * 7) / 16) | + INTERP_16_MASK_2((INTERP_16_MASK_2(p1) * 9 + INTERP_16_MASK_2(p2) * 7) / 16); } #define INTERP_32_MASK_1(v) (v & 0xFF00FF) @@ -134,169 +155,191 @@ static inline u16 interp_16_97(u16 p1, u16 p2) static inline u32 interp_32_521(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*2 + INTERP_32_MASK_1(p3)*1) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*2 + INTERP_32_MASK_2(p3)*1) / 8); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 5 + INTERP_32_MASK_1(p2) * 2 + + INTERP_32_MASK_1(p3) * 1) / + 8) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 5 + INTERP_32_MASK_2(p2) * 2 + + INTERP_32_MASK_2(p3) * 1) / + 8); } static inline u32 interp_32_332(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)*2) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)*2) / 8); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 3 + INTERP_32_MASK_1(p2) * 3 + + INTERP_32_MASK_1(p3) * 2) / + 8) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 3 + INTERP_32_MASK_2(p2) * 3 + + INTERP_32_MASK_2(p3) * 2) / + 8); } static inline u32 interp_32_211(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4); + return INTERP_32_MASK_1( + (INTERP_32_MASK_1(p1) * 2 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 4) | + INTERP_32_MASK_2( + (INTERP_32_MASK_2(p1) * 2 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 4); } static inline u32 interp_32_611(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8); + return INTERP_32_MASK_1( + (INTERP_32_MASK_1(p1) * 6 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 8) | + INTERP_32_MASK_2( + (INTERP_32_MASK_2(p1) * 6 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 8); } static inline u32 interp_32_71(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*7 + INTERP_32_MASK_1(p2)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*7 + INTERP_32_MASK_2(p2)) / 8); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 7 + INTERP_32_MASK_1(p2)) / 8) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 7 + INTERP_32_MASK_2(p2)) / 8); } static inline u32 interp_32_772(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1(((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2))*7 + INTERP_32_MASK_1(p3)*2) / 16) - | INTERP_32_MASK_2(((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2))*7 + INTERP_32_MASK_2(p3)*2) / 16); + return INTERP_32_MASK_1( + ((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) * 7 + INTERP_32_MASK_1(p3) * 2) / + 16) | + INTERP_32_MASK_2( + ((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) * 7 + INTERP_32_MASK_2(p3) * 2) / + 16); } static inline u32 interp_32_11(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) + INTERP_32_MASK_1(p2)) / 2) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) + INTERP_32_MASK_2(p2)) / 2); } static inline u32 interp_32_31(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*3 + INTERP_32_MASK_1(p2)) / 4) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*3 + INTERP_32_MASK_2(p2)) / 4); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 3 + INTERP_32_MASK_1(p2)) / 4) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 3 + INTERP_32_MASK_2(p2)) / 4); } static inline u32 interp_32_1411(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16); + return INTERP_32_MASK_1( + (INTERP_32_MASK_1(p1) * 14 + INTERP_32_MASK_1(p2) + INTERP_32_MASK_1(p3)) / 16) | + INTERP_32_MASK_2( + (INTERP_32_MASK_2(p1) * 14 + INTERP_32_MASK_2(p2) + INTERP_32_MASK_2(p3)) / 16); } static inline u32 interp_32_431(u32 p1, u32 p2, u32 p3) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*4 + INTERP_32_MASK_1(p2)*3 + INTERP_32_MASK_1(p3)) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*4 + INTERP_32_MASK_2(p2)*3 + INTERP_32_MASK_2(p3)) / 8); + return INTERP_32_MASK_1( + (INTERP_32_MASK_1(p1) * 4 + INTERP_32_MASK_1(p2) * 3 + INTERP_32_MASK_1(p3)) / + 8) | + INTERP_32_MASK_2( + (INTERP_32_MASK_2(p1) * 4 + INTERP_32_MASK_2(p2) * 3 + INTERP_32_MASK_2(p3)) / + 8); } static inline u32 interp_32_53(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*5 + INTERP_32_MASK_1(p2)*3) / 8) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*5 + INTERP_32_MASK_2(p2)*3) / 8); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 5 + INTERP_32_MASK_1(p2) * 3) / 8) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 5 + INTERP_32_MASK_2(p2) * 3) / 8); } static inline u32 interp_32_151(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*15 + INTERP_32_MASK_1(p2)) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*15 + INTERP_32_MASK_2(p2)) / 16); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 15 + INTERP_32_MASK_1(p2)) / 16) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 15 + INTERP_32_MASK_2(p2)) / 16); } static inline u32 interp_32_97(u32 p1, u32 p2) { - return INTERP_32_MASK_1((INTERP_32_MASK_1(p1)*9 + INTERP_32_MASK_1(p2)*7) / 16) - | INTERP_32_MASK_2((INTERP_32_MASK_2(p1)*9 + INTERP_32_MASK_2(p2)*7) / 16); + return INTERP_32_MASK_1((INTERP_32_MASK_1(p1) * 9 + INTERP_32_MASK_1(p2) * 7) / 16) | + INTERP_32_MASK_2((INTERP_32_MASK_2(p1) * 9 + INTERP_32_MASK_2(p2) * 7) / 16); } /***************************************************************************/ /* diff */ -#define INTERP_Y_LIMIT (0x30*4) -#define INTERP_U_LIMIT (0x07*4) -#define INTERP_V_LIMIT (0x06*8) +#define INTERP_Y_LIMIT (0x30 * 4) +#define INTERP_U_LIMIT (0x07 * 4) +#define INTERP_V_LIMIT (0x06 * 8) static int interp_16_diff(u16 p1, u16 p2) { - int r, g, b; - int y, u, v; + int r, g, b; + int y, u, v; - if (p1 == p2) - return 0; + if (p1 == p2) + return 0; - if (interp_bits_per_pixel == 16) { - b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; - g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3; - r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; - } else { - b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; - g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2; - r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7; - } + if (interp_bits_per_pixel == 16) { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x7E0) - (p2 & 0x7E0)) >> 3; + r = (int)((p1 & 0xF800) - (p2 & 0xF800)) >> 8; + } else { + b = (int)((p1 & 0x1F) - (p2 & 0x1F)) << 3; + g = (int)((p1 & 0x3E0) - (p2 & 0x3E0)) >> 2; + r = (int)((p1 & 0x7C00) - (p2 & 0x7C00)) >> 7; + } - y = r + g + b; - u = r - b; - v = -r + 2*g - b; + y = r + g + b; + u = r - b; + v = -r + 2 * g - b; - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; - return 0; + return 0; } static int interp_32_diff(u32 p1, u32 p2) { - int r, g, b; - int y, u, v; + int r, g, b; + int y, u, v; - if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) - return 0; + if ((p1 & 0xF8F8F8) == (p2 & 0xF8F8F8)) + return 0; - b = (int)((p1 & 0xFF) - (p2 & 0xFF)); - g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; - r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; + b = (int)((p1 & 0xFF) - (p2 & 0xFF)); + g = (int)((p1 & 0xFF00) - (p2 & 0xFF00)) >> 8; + r = (int)((p1 & 0xFF0000) - (p2 & 0xFF0000)) >> 16; - y = r + g + b; - u = r - b; - v = -r + 2*g - b; + y = r + g + b; + u = r - b; + v = -r + 2 * g - b; - if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) - return 1; + if (y < -INTERP_Y_LIMIT || y > INTERP_Y_LIMIT) + return 1; - if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) - return 1; + if (u < -INTERP_U_LIMIT || u > INTERP_U_LIMIT) + return 1; - if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) - return 1; + if (v < -INTERP_V_LIMIT || v > INTERP_V_LIMIT) + return 1; - return 0; + return 0; } static void interp_set(unsigned bits_per_pixel) { - interp_bits_per_pixel = bits_per_pixel; + interp_bits_per_pixel = bits_per_pixel; - switch (bits_per_pixel) { - case 15 : - interp_mask[0] = 0x7C1F; - interp_mask[1] = 0x03E0; - break; - case 16 : - interp_mask[0] = 0xF81F; - interp_mask[1] = 0x07E0; - break; - case 32 : - interp_mask[0] = 0xFF00FF; - interp_mask[1] = 0x00FF00; - break; - } + switch (bits_per_pixel) { + case 15: + interp_mask[0] = 0x7C1F; + interp_mask[1] = 0x03E0; + break; + case 16: + interp_mask[0] = 0xF81F; + interp_mask[1] = 0x07E0; + break; + case 32: + interp_mask[0] = 0xFF00FF; + interp_mask[1] = 0x00FF00; + break; + } } #endif diff --git a/src/filters/lq2x.h b/src/filters/lq2x.h index 094c2b5a..00275203 100644 --- a/src/filters/lq2x.h +++ b/src/filters/lq2x.h @@ -1,1284 +1,1205 @@ -case 0 : -case 2 : -case 4 : -case 6 : -case 8 : -case 12 : -case 16 : -case 20 : -case 24 : -case 28 : -case 32 : -case 34 : -case 36 : -case 38 : -case 40 : -case 44 : -case 48 : -case 52 : -case 56 : -case 60 : -case 64 : -case 66 : -case 68 : -case 70 : -case 96 : -case 98 : -case 100 : -case 102 : -case 128 : -case 130 : -case 132 : -case 134 : -case 136 : -case 140 : -case 144 : -case 148 : -case 152 : -case 156 : -case 160 : -case 162 : -case 164 : -case 166 : -case 168 : -case 172 : -case 176 : -case 180 : -case 184 : -case 188 : -case 192 : -case 194 : -case 196 : -case 198 : -case 224 : -case 226 : -case 228 : -case 230 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); -} break; -case 1 : -case 5 : -case 9 : -case 13 : -case 17 : -case 21 : -case 25 : -case 29 : -case 33 : -case 37 : -case 41 : -case 45 : -case 49 : -case 53 : -case 57 : -case 61 : -case 65 : -case 69 : -case 97 : -case 101 : -case 129 : -case 133 : -case 137 : -case 141 : -case 145 : -case 149 : -case 153 : -case 157 : -case 161 : -case 165 : -case 169 : -case 173 : -case 177 : -case 181 : -case 185 : -case 189 : -case 193 : -case 197 : -case 225 : -case 229 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - P3 = IC(1); -} break; -case 3 : -case 35 : -case 67 : -case 99 : -case 131 : -case 163 : -case 195 : -case 227 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); -} break; -case 7 : -case 39 : -case 71 : -case 103 : -case 135 : -case 167 : -case 199 : -case 231 : -{ - P0 = IC(3); - P1 = IC(3); - P2 = IC(3); - P3 = IC(3); -} break; -case 10 : -case 138 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 11 : -case 27 : -case 75 : -case 139 : -case 155 : -case 203 : -{ - P1 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 14 : -case 142 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - P1 = IC(0); - } else { - P0 = I332(1, 3, 0); - P1 = I31(0, 1); - } -} break; -case 15 : -case 143 : -case 207 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - P1 = IC(4); - } else { - P0 = I332(1, 3, 4); - P1 = I31(4, 1); - } -} break; -case 18 : -case 22 : -case 30 : -case 50 : -case 54 : -case 62 : -case 86 : -case 118 : -{ - P0 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 19 : -case 51 : -{ - P2 = IC(2); - P3 = IC(2); - if (MUR) { - P0 = IC(2); - P1 = IC(2); - } else { - P0 = I31(2, 1); - P1 = I332(1, 5, 2); - } -} break; -case 23 : -case 55 : -case 119 : -{ - P2 = IC(3); - P3 = IC(3); - if (MUR) { - P0 = IC(3); - P1 = IC(3); - } else { - P0 = I31(3, 1); - P1 = I332(1, 5, 3); - } -} break; -case 26 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 31 : -case 95 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 42 : -case 170 : -{ - P1 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - P2 = IC(0); - } else { - P0 = I332(1, 3, 0); - P2 = I31(0, 3); - } -} break; -case 43 : -case 171 : -case 187 : -{ - P1 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - P2 = IC(2); - } else { - P0 = I332(1, 3, 2); - P2 = I31(2, 3); - } -} break; -case 46 : -case 174 : -{ - P1 = IC(0); - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 47 : -case 175 : -{ - P1 = IC(4); - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 58 : -case 154 : -case 186 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 59 : -{ - P2 = IC(2); - P3 = IC(2); - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 63 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 72 : -case 76 : -case 104 : -case 106 : -case 108 : -case 110 : -case 120 : -case 124 : -{ - P0 = IC(0); - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } -} break; -case 73 : -case 77 : -case 105 : -case 109 : -case 125 : -{ - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P0 = IC(1); - P2 = IC(1); - } else { - P0 = I31(1, 3); - P2 = I332(3, 7, 1); - } -} break; -case 74 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I211(0, 1, 3); - } -} break; -case 78 : -case 202 : -case 206 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 79 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I611(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } -} break; -case 80 : -case 208 : -case 210 : -case 216 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 81 : -case 209 : -case 217 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 82 : -case 214 : -case 222 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 83 : -case 115 : -{ - P0 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 84 : -case 212 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P1 = IC(0); - P3 = IC(0); - } else { - P1 = I31(0, 5); - P3 = I332(5, 7, 0); - } -} break; -case 85 : -case 213 : -case 221 : -{ - P0 = IC(1); - P2 = IC(1); - if (MDR) { - P1 = IC(1); - P3 = IC(1); - } else { - P1 = I31(1, 5); - P3 = I332(5, 7, 1); - } -} break; -case 87 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I611(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I211(3, 1, 5); - } -} break; -case 88 : -case 248 : -case 250 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 89 : -case 93 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 90 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 91 : -{ - if (MDL) { - P2 = IC(2); - } else { - P2 = I611(2, 3, 7); - } - if (MDR) { - P3 = IC(2); - } else { - P3 = I611(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 92 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } -} break; -case 94 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 107 : -case 123 : -{ - P1 = IC(2); - P3 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I211(2, 3, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 111 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 112 : -case 240 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDR) { - P2 = IC(0); - P3 = IC(0); - } else { - P2 = I31(0, 7); - P3 = I332(5, 7, 0); - } -} break; -case 113 : -case 241 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDR) { - P2 = IC(1); - P3 = IC(1); - } else { - P2 = I31(1, 7); - P3 = I332(5, 7, 1); - } -} break; -case 114 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 116 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } -} break; -case 117 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 121 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I211(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I611(1, 5, 7); - } -} break; -case 122 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I611(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 126 : -{ - P0 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 127 : -{ - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I211(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I211(4, 1, 5); - } -} break; -case 146 : -case 150 : -case 178 : -case 182 : -case 190 : -{ - P0 = IC(0); - P2 = IC(0); - if (MUR) { - P1 = IC(0); - P3 = IC(0); - } else { - P1 = I332(1, 5, 0); - P3 = I31(0, 5); - } -} break; -case 147 : -case 179 : -{ - P0 = IC(2); - P2 = IC(2); - P3 = IC(2); - if (MUR) { - P1 = IC(2); - } else { - P1 = I611(2, 1, 5); - } -} break; -case 151 : -case 183 : -{ - P0 = IC(3); - P2 = IC(3); - P3 = IC(3); - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 158 : -{ - P2 = IC(0); - P3 = IC(0); - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 159 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 191 : -{ - P2 = IC(4); - P3 = IC(4); - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 200 : -case 204 : -case 232 : -case 236 : -case 238 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - P3 = IC(0); - } else { - P2 = I332(3, 7, 0); - P3 = I31(0, 7); - } -} break; -case 201 : -case 205 : -{ - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I611(1, 3, 7); - } -} break; -case 211 : -{ - P0 = IC(2); - P1 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } -} break; -case 215 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I211(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 218 : -{ - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 219 : -{ - P1 = IC(2); - P2 = IC(2); - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 220 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I611(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } -} break; -case 223 : -{ - P2 = IC(4); - if (MDR) { - P3 = IC(4); - } else { - P3 = I211(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I211(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } -} break; -case 233 : -case 237 : -{ - P0 = IC(1); - P1 = IC(1); - P3 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } -} break; -case 234 : -{ - P1 = IC(0); - P3 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MUL) { - P0 = IC(0); - } else { - P0 = I611(0, 1, 3); - } -} break; -case 235 : -{ - P1 = IC(2); - P3 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 239 : -{ - P1 = IC(4); - P3 = IC(4); - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } -} break; -case 242 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I211(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I611(0, 1, 5); - } -} break; -case 243 : -{ - P0 = IC(2); - P1 = IC(2); - if (MDR) { - P2 = IC(2); - P3 = IC(2); - } else { - P2 = I31(2, 7); - P3 = I332(5, 7, 2); - } -} break; -case 244 : -{ - P0 = IC(0); - P1 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } -} break; -case 245 : -{ - P0 = IC(1); - P1 = IC(1); - P2 = IC(1); - if (MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } -} break; -case 246 : -{ - P0 = IC(0); - P2 = IC(0); - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 247 : -{ - P0 = IC(3); - P2 = IC(3); - if (MDR) { - P3 = IC(3); - } else { - P3 = I1411(3, 5, 7); - } - if (MUR) { - P1 = IC(3); - } else { - P1 = I1411(3, 1, 5); - } -} break; -case 249 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I211(1, 5, 7); - } -} break; -case 251 : -{ - P1 = IC(2); - if (MDL) { - P2 = IC(2); - } else { - P2 = I1411(2, 3, 7); - } - if (MDR) { - P3 = IC(2); - } else { - P3 = I211(2, 5, 7); - } - if (MUL) { - P0 = IC(2); - } else { - P0 = I211(2, 1, 3); - } -} break; -case 252 : -{ - P0 = IC(0); - P1 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } -} break; -case 253 : -{ - P0 = IC(1); - P1 = IC(1); - if (MDL) { - P2 = IC(1); - } else { - P2 = I1411(1, 3, 7); - } - if (MDR) { - P3 = IC(1); - } else { - P3 = I1411(1, 5, 7); - } -} break; -case 254 : -{ - P0 = IC(0); - if (MDL) { - P2 = IC(0); - } else { - P2 = I211(0, 3, 7); - } - if (MDR) { - P3 = IC(0); - } else { - P3 = I1411(0, 5, 7); - } - if (MUR) { - P1 = IC(0); - } else { - P1 = I211(0, 1, 5); - } -} break; -case 255 : -{ - if (MDL) { - P2 = IC(4); - } else { - P2 = I1411(4, 3, 7); - } - if (MDR) { - P3 = IC(4); - } else { - P3 = I1411(4, 5, 7); - } - if (MUL) { - P0 = IC(4); - } else { - P0 = I1411(4, 1, 3); - } - if (MUR) { - P1 = IC(4); - } else { - P1 = I1411(4, 1, 5); - } +case 0: +case 2: +case 4: +case 6: +case 8: +case 12: +case 16: +case 20: +case 24: +case 28: +case 32: +case 34: +case 36: +case 38: +case 40: +case 44: +case 48: +case 52: +case 56: +case 60: +case 64: +case 66: +case 68: +case 70: +case 96: +case 98: +case 100: +case 102: +case 128: +case 130: +case 132: +case 134: +case 136: +case 140: +case 144: +case 148: +case 152: +case 156: +case 160: +case 162: +case 164: +case 166: +case 168: +case 172: +case 176: +case 180: +case 184: +case 188: +case 192: +case 194: +case 196: +case 198: +case 224: +case 226: +case 228: +case 230: { + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); +} break; +case 1: +case 5: +case 9: +case 13: +case 17: +case 21: +case 25: +case 29: +case 33: +case 37: +case 41: +case 45: +case 49: +case 53: +case 57: +case 61: +case 65: +case 69: +case 97: +case 101: +case 129: +case 133: +case 137: +case 141: +case 145: +case 149: +case 153: +case 157: +case 161: +case 165: +case 169: +case 173: +case 177: +case 181: +case 185: +case 189: +case 193: +case 197: +case 225: +case 229: { + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + P3 = IC(1); +} break; +case 3: +case 35: +case 67: +case 99: +case 131: +case 163: +case 195: +case 227: { + P0 = IC(2); + P1 = IC(2); + P2 = IC(2); + P3 = IC(2); +} break; +case 7: +case 39: +case 71: +case 103: +case 135: +case 167: +case 199: +case 231: { + P0 = IC(3); + P1 = IC(3); + P2 = IC(3); + P3 = IC(3); +} break; +case 10: +case 138: { + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } +} break; +case 11: +case 27: +case 75: +case 139: +case 155: +case 203: { + P1 = IC(2); + P2 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 14: +case 142: { + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + P1 = IC(0); + } else { + P0 = I332(1, 3, 0); + P1 = I31(0, 1); + } +} break; +case 15: +case 143: +case 207: { + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + P1 = IC(4); + } else { + P0 = I332(1, 3, 4); + P1 = I31(4, 1); + } +} break; +case 18: +case 22: +case 30: +case 50: +case 54: +case 62: +case 86: +case 118: { + P0 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 19: +case 51: { + P2 = IC(2); + P3 = IC(2); + if (MUR) { + P0 = IC(2); + P1 = IC(2); + } else { + P0 = I31(2, 1); + P1 = I332(1, 5, 2); + } +} break; +case 23: +case 55: +case 119: { + P2 = IC(3); + P3 = IC(3); + if (MUR) { + P0 = IC(3); + P1 = IC(3); + } else { + P0 = I31(3, 1); + P1 = I332(1, 5, 3); + } +} break; +case 26: { + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 31: +case 95: { + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 42: +case 170: { + P1 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + P2 = IC(0); + } else { + P0 = I332(1, 3, 0); + P2 = I31(0, 3); + } +} break; +case 43: +case 171: +case 187: { + P1 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + P2 = IC(2); + } else { + P0 = I332(1, 3, 2); + P2 = I31(2, 3); + } +} break; +case 46: +case 174: { + P1 = IC(0); + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 47: +case 175: { + P1 = IC(4); + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 58: +case 154: +case 186: { + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 59: { + P2 = IC(2); + P3 = IC(2); + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 63: { + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 72: +case 76: +case 104: +case 106: +case 108: +case 110: +case 120: +case 124: { + P0 = IC(0); + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } +} break; +case 73: +case 77: +case 105: +case 109: +case 125: { + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P0 = IC(1); + P2 = IC(1); + } else { + P0 = I31(1, 3); + P2 = I332(3, 7, 1); + } +} break; +case 74: { + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I211(0, 1, 3); + } +} break; +case 78: +case 202: +case 206: { + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 79: { + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I611(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } +} break; +case 80: +case 208: +case 210: +case 216: { + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 81: +case 209: +case 217: { + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I211(1, 5, 7); + } +} break; +case 82: +case 214: +case 222: { + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 83: +case 115: { + P0 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I611(2, 5, 7); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 84: +case 212: { + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P1 = IC(0); + P3 = IC(0); + } else { + P1 = I31(0, 5); + P3 = I332(5, 7, 0); + } +} break; +case 85: +case 213: +case 221: { + P0 = IC(1); + P2 = IC(1); + if (MDR) { + P1 = IC(1); + P3 = IC(1); + } else { + P1 = I31(1, 5); + P3 = I332(5, 7, 1); + } +} break; +case 87: { + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I611(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I211(3, 1, 5); + } +} break; +case 88: +case 248: +case 250: { + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 89: +case 93: { + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I611(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 90: { + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 91: { + if (MDL) { + P2 = IC(2); + } else { + P2 = I611(2, 3, 7); + } + if (MDR) { + P3 = IC(2); + } else { + P3 = I611(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 92: { + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } +} break; +case 94: { + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 107: +case 123: { + P1 = IC(2); + P3 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I211(2, 3, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 111: { + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 112: +case 240: { + P0 = IC(0); + P1 = IC(0); + if (MDR) { + P2 = IC(0); + P3 = IC(0); + } else { + P2 = I31(0, 7); + P3 = I332(5, 7, 0); + } +} break; +case 113: +case 241: { + P0 = IC(1); + P1 = IC(1); + if (MDR) { + P2 = IC(1); + P3 = IC(1); + } else { + P2 = I31(1, 7); + P3 = I332(5, 7, 1); + } +} break; +case 114: { + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 116: { + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } +} break; +case 117: { + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 121: { + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I211(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I611(1, 5, 7); + } +} break; +case 122: { + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I611(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 126: { + P0 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 127: { + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I211(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I211(4, 1, 5); + } +} break; +case 146: +case 150: +case 178: +case 182: +case 190: { + P0 = IC(0); + P2 = IC(0); + if (MUR) { + P1 = IC(0); + P3 = IC(0); + } else { + P1 = I332(1, 5, 0); + P3 = I31(0, 5); + } +} break; +case 147: +case 179: { + P0 = IC(2); + P2 = IC(2); + P3 = IC(2); + if (MUR) { + P1 = IC(2); + } else { + P1 = I611(2, 1, 5); + } +} break; +case 151: +case 183: { + P0 = IC(3); + P2 = IC(3); + P3 = IC(3); + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 158: { + P2 = IC(0); + P3 = IC(0); + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 159: { + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 191: { + P2 = IC(4); + P3 = IC(4); + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 200: +case 204: +case 232: +case 236: +case 238: { + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + P3 = IC(0); + } else { + P2 = I332(3, 7, 0); + P3 = I31(0, 7); + } +} break; +case 201: +case 205: { + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I611(1, 3, 7); + } +} break; +case 211: { + P0 = IC(2); + P1 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } +} break; +case 215: { + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I211(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 218: { + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 219: { + P1 = IC(2); + P2 = IC(2); + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 220: { + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I611(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } +} break; +case 223: { + P2 = IC(4); + if (MDR) { + P3 = IC(4); + } else { + P3 = I211(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I211(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } +} break; +case 233: +case 237: { + P0 = IC(1); + P1 = IC(1); + P3 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } +} break; +case 234: { + P1 = IC(0); + P3 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MUL) { + P0 = IC(0); + } else { + P0 = I611(0, 1, 3); + } +} break; +case 235: { + P1 = IC(2); + P3 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I1411(2, 3, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 239: { + P1 = IC(4); + P3 = IC(4); + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } +} break; +case 242: { + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I211(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I611(0, 1, 5); + } +} break; +case 243: { + P0 = IC(2); + P1 = IC(2); + if (MDR) { + P2 = IC(2); + P3 = IC(2); + } else { + P2 = I31(2, 7); + P3 = I332(5, 7, 2); + } +} break; +case 244: { + P0 = IC(0); + P1 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } +} break; +case 245: { + P0 = IC(1); + P1 = IC(1); + P2 = IC(1); + if (MDR) { + P3 = IC(1); + } else { + P3 = I1411(1, 5, 7); + } +} break; +case 246: { + P0 = IC(0); + P2 = IC(0); + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 247: { + P0 = IC(3); + P2 = IC(3); + if (MDR) { + P3 = IC(3); + } else { + P3 = I1411(3, 5, 7); + } + if (MUR) { + P1 = IC(3); + } else { + P1 = I1411(3, 1, 5); + } +} break; +case 249: { + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I211(1, 5, 7); + } +} break; +case 251: { + P1 = IC(2); + if (MDL) { + P2 = IC(2); + } else { + P2 = I1411(2, 3, 7); + } + if (MDR) { + P3 = IC(2); + } else { + P3 = I211(2, 5, 7); + } + if (MUL) { + P0 = IC(2); + } else { + P0 = I211(2, 1, 3); + } +} break; +case 252: { + P0 = IC(0); + P1 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } +} break; +case 253: { + P0 = IC(1); + P1 = IC(1); + if (MDL) { + P2 = IC(1); + } else { + P2 = I1411(1, 3, 7); + } + if (MDR) { + P3 = IC(1); + } else { + P3 = I1411(1, 5, 7); + } +} break; +case 254: { + P0 = IC(0); + if (MDL) { + P2 = IC(0); + } else { + P2 = I211(0, 3, 7); + } + if (MDR) { + P3 = IC(0); + } else { + P3 = I1411(0, 5, 7); + } + if (MUR) { + P1 = IC(0); + } else { + P1 = I211(0, 1, 5); + } +} break; +case 255: { + if (MDL) { + P2 = IC(4); + } else { + P2 = I1411(4, 3, 7); + } + if (MDR) { + P3 = IC(4); + } else { + P3 = I1411(4, 5, 7); + } + if (MUL) { + P0 = IC(4); + } else { + P0 = I1411(4, 1, 3); + } + if (MUR) { + P1 = IC(4); + } else { + P1 = I1411(4, 1, 5); + } } break; diff --git a/src/filters/xBRZ/config.h b/src/filters/xBRZ/config.h index 96b168af..8159e51b 100644 --- a/src/filters/xBRZ/config.h +++ b/src/filters/xBRZ/config.h @@ -16,25 +16,23 @@ #ifndef XBRZ_CONFIG_HEADER_284578425345 #define XBRZ_CONFIG_HEADER_284578425345 -//do NOT include any headers here! used by xBRZ_dll!!! +// do NOT include any headers here! used by xBRZ_dll!!! namespace xbrz { -struct ScalerCfg -{ - ScalerCfg() : - luminanceWeight(1), - equalColorTolerance(30), - dominantDirectionThreshold(3.6), - steepDirectionThreshold(2.2), - newTestAttribute(0) {} +struct ScalerCfg { + ScalerCfg() + : luminanceWeight(1), equalColorTolerance(30), dominantDirectionThreshold(3.6), + steepDirectionThreshold(2.2), newTestAttribute(0) + { + } - double luminanceWeight; - double equalColorTolerance; - double dominantDirectionThreshold; - double steepDirectionThreshold; - double newTestAttribute; //unused; test new parameters + double luminanceWeight; + double equalColorTolerance; + double dominantDirectionThreshold; + double steepDirectionThreshold; + double newTestAttribute; // unused; test new parameters }; } -#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/filters/xBRZ/xbrz.h b/src/filters/xBRZ/xbrz.h index 896574aa..7bc9590b 100644 --- a/src/filters/xBRZ/xbrz.h +++ b/src/filters/xBRZ/xbrz.h @@ -16,10 +16,10 @@ #ifndef XBRZ_HEADER_3847894708239054 #define XBRZ_HEADER_3847894708239054 -#include //size_t -#include //uint32_t -#include #include "config.h" +#include //size_t +#include +#include //uint32_t namespace xbrz { @@ -38,57 +38,64 @@ http://board.byuu.org/viewtopic.php?f=10&t=2248 - support scaling up to 6xBRZ */ -enum ColorFormat //from high bits -> low bits, 8 bit per channel -{ - RGB, //8 bit for each red, green, blue, upper 8 bits unused - ARGB, //including alpha channel, BGRA byte order on little-endian machines +enum ColorFormat // from high bits -> low bits, 8 bit per channel +{ RGB, // 8 bit for each red, green, blue, upper 8 bits unused + ARGB, // including alpha channel, BGRA byte order on little-endian machines }; /* --> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally processing a half-open slice of rows [yFirst, yLast) only +-> map source (srcWidth * srcHeight) to target (scale * width x scale * height) image, optionally +processing a half-open slice of rows [yFirst, yLast) only -> support for source/target pitch in bytes! --> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no need to run xBRZ on the complete image: - Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the additional range the xBRZ algorithm is using during analysis) - Caveat: If there are multiple changed slices, make sure they do not overlap after adding these additional rows in order to avoid a memory race condition +-> if your emulator changes only a few image slices during each cycle (e.g. DOSBox) then there's no +need to run xBRZ on the complete image: + Just make sure you enlarge the source image slice by 2 rows on top and 2 on bottom (this is the +additional range the xBRZ algorithm is using during analysis) + Caveat: If there are multiple changed slices, make sure they do not overlap after adding these +additional rows in order to avoid a memory race condition in the target image data if you are using multiple threads for processing each enlarged slice! -THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, yLast) ranges do not overlap! - - there is a minor inefficiency for the first row of a slice, so avoid processing single rows only; suggestion: process 8-16 rows at least +THREAD-SAFETY: - parts of the same image may be scaled by multiple threads as long as the [yFirst, +yLast) ranges do not overlap! + - there is a minor inefficiency for the first row of a slice, so avoid processing +single rows only; suggestion: process 8-16 rows at least */ -void scale(size_t factor, //valid range: 2 - 6 - const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, - uint32_t* trg, int trgPitch, - ColorFormat colFmt, - const ScalerCfg& cfg = ScalerCfg(), - int yFirst = 0, int yLast = std::numeric_limits::max()); //slice of source image +void scale(size_t factor, // valid range: 2 - 6 + const uint32_t *src, int srcWidth, int srcHeight, int srcPitch, uint32_t *trg, + int trgPitch, ColorFormat colFmt, const ScalerCfg &cfg = ScalerCfg(), int yFirst = 0, + int yLast = std::numeric_limits::max()); // slice of source image -void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, - uint32_t* trg, int trgWidth, int trgHeight); +void nearestNeighborScale(const uint32_t *src, int srcWidth, int srcHeight, uint32_t *trg, + int trgWidth, int trgHeight); -enum SliceType -{ - NN_SCALE_SLICE_SOURCE, - NN_SCALE_SLICE_TARGET, +enum SliceType { + NN_SCALE_SLICE_SOURCE, + NN_SCALE_SLICE_TARGET, }; -void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, int srcPitch, //pitch in bytes! - uint32_t* trg, int trgWidth, int trgHeight, int trgPitch, - SliceType st, int yFirst, int yLast); - -//parameter tuning -bool equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, double equalColorTolerance); - - - +void nearestNeighborScale(const uint32_t *src, int srcWidth, int srcHeight, + int srcPitch, // pitch in bytes! + uint32_t *trg, int trgWidth, int trgHeight, int trgPitch, SliceType st, + int yFirst, int yLast); +// parameter tuning +bool equalColorTest(uint32_t col1, uint32_t col2, ColorFormat colFmt, double luminanceWeight, + double equalColorTolerance); //########################### implementation ########################### -inline -void nearestNeighborScale(const uint32_t* src, int srcWidth, int srcHeight, - uint32_t* trg, int trgWidth, int trgHeight) +inline void nearestNeighborScale(const uint32_t *src, int srcWidth, int srcHeight, uint32_t *trg, + int trgWidth, int trgHeight) { - nearestNeighborScale(src, srcWidth, srcHeight, srcWidth * sizeof(uint32_t), - trg, trgWidth, trgHeight, trgWidth * sizeof(uint32_t), - NN_SCALE_SLICE_TARGET, 0, trgHeight); + nearestNeighborScale(src, + srcWidth, + srcHeight, + srcWidth * sizeof(uint32_t), + trg, + trgWidth, + trgHeight, + trgWidth * sizeof(uint32_t), + NN_SCALE_SLICE_TARGET, + 0, + trgHeight); } } diff --git a/src/gb/gb.h b/src/gb/gb.h index d14a0e53..9501d820 100644 --- a/src/gb/gb.h +++ b/src/gb/gb.h @@ -7,14 +7,14 @@ #define Z_FLAG 0x80 typedef union { - struct { + struct { #ifdef WORDS_BIGENDIAN - u8 B1, B0; + u8 B1, B0; #else - u8 B0,B1; + u8 B0, B1; #endif - } B; - u16 W; + } B; + u16 W; } gbRegister; extern gbRegister AF, BC, DE, HL, SP, PC; @@ -30,12 +30,12 @@ bool gbIsGameboyRom(const char *); void gbGetHardwareType(); void gbReset(); void gbCleanUp(); -void gbCPUInit(const char *,bool); +void gbCPUInit(const char *, bool); bool gbWriteBatteryFile(const char *); bool gbWriteBatteryFile(const char *, bool); bool gbReadBatteryFile(const char *); bool gbWriteSaveState(const char *); -bool gbWriteMemSaveState(char *, int, long&); +bool gbWriteMemSaveState(char *, int, long &); bool gbReadSaveState(const char *); bool gbReadMemSaveState(char *, int); void gbSgbRenderBorder(); diff --git a/src/gb/gbCheats.h b/src/gb/gbCheats.h index 74c6a5a3..bc4798bf 100644 --- a/src/gb/gbCheats.h +++ b/src/gb/gbCheats.h @@ -5,18 +5,18 @@ #include "../common/ConfigManager.h" struct gbXxCheat { - char cheatDesc[100]; - char cheatCode[20]; + char cheatDesc[100]; + char cheatCode[20]; }; struct gbCheat { - char cheatCode[20]; - char cheatDesc[32]; - u16 address; - int code; - u8 compare; - u8 value; - bool enabled; + char cheatCode[20]; + char cheatDesc[32]; + u16 address; + int code; + u8 compare; + u8 value; + bool enabled; }; void gbCheatsSaveGame(gzFile); @@ -26,8 +26,8 @@ void gbCheatsSaveCheatList(const char *); bool gbCheatsLoadCheatList(const char *); bool gbCheatReadGSCodeFile(const char *); -bool gbAddGsCheat(const char *, const char*); -bool gbAddGgCheat(const char *, const char*); +bool gbAddGsCheat(const char *, const char *); +bool gbAddGgCheat(const char *, const char *); void gbCheatRemove(int); void gbCheatRemoveAll(); void gbCheatEnable(int); @@ -37,7 +37,6 @@ void gbCheatWrite(bool); bool gbVerifyGsCode(const char *code); bool gbVerifyGgCode(const char *code); - extern int gbCheatNumber; extern gbCheat gbCheatList[MAX_CHEATS]; extern bool gbCheatMap[0x10000]; diff --git a/src/gb/gbCodes.h b/src/gb/gbCodes.h index 9c30d05e..fa7be0f2 100644 --- a/src/gb/gbCodes.h +++ b/src/gb/gbCodes.h @@ -1,1424 +1,1419 @@ - case 0x00: - // NOP - break; - case 0x01: - // LD BC, NNNN - BC.B.B0=gbReadOpcode(PC.W++); - BC.B.B1=gbReadOpcode(PC.W++); - break; - case 0x02: - // LD (BC),A - gbWriteMemory(BC.W,AF.B.B1); - break; - case 0x03: - // INC BC - BC.W++; - break; - case 0x04: - // INC B - BC.B.B1++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| (BC.B.B1&0x0F? 0:H_FLAG); - break; - case 0x05: - // DEC B - BC.B.B1--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B1]| - ((BC.B.B1&0x0F)==0x0F? H_FLAG:0); - break; - case 0x06: - // LD B, NN - BC.B.B1=gbReadOpcode(PC.W++); - break; - case 0x07: - // RLCA - tempValue=AF.B.B1&0x80? C_FLAG:0; - AF.B.B1=(AF.B.B1<<1)|(AF.B.B1>>7); - AF.B.B0=tempValue; - break; - case 0x08: - // LD (NNNN), SP - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(tempRegister.W++,SP.B.B0); - gbWriteMemory(tempRegister.W,SP.B.B1); - break; - case 0x09: - // ADD HL,BC - tempRegister.W=(HL.W+BC.W)&0xFFFF; - AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^BC.W^tempRegister.W)&0x1000? H_FLAG:0)| - (((long)HL.W+(long)BC.W)&0x10000? C_FLAG:0); - HL.W=tempRegister.W; - break; - case 0x0a: - // LD A,(BC) - AF.B.B1=gbReadMemory(BC.W); - break; - case 0x0b: - // DEC BC - BC.W--; - break; - case 0x0c: - // INC C - BC.B.B0++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]| (BC.B.B0&0x0F? 0:H_FLAG); - break; - case 0x0d: - // DEC C - BC.B.B0--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[BC.B.B0]| - ((BC.B.B0&0x0F)==0x0F? H_FLAG:0); - break; - case 0x0e: - // LD C, NN - BC.B.B0=gbReadOpcode(PC.W++); - break; - case 0x0f: - // RRCA - tempValue=AF.B.B1&0x01; - AF.B.B1=(AF.B.B1>>1)|(tempValue? 0x80:0); - AF.B.B0=(tempValue<<4); - break; - case 0x10: - // STOP - opcode = gbReadOpcode(PC.W++); - if(gbCgbMode) { - if(gbMemory[0xff4d] & 1) { +case 0x00: +// NOP +break; +case 0x01: +// LD BC, NNNN +BC.B.B0 = gbReadOpcode(PC.W++); +BC.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x02: +// LD (BC),A +gbWriteMemory(BC.W, AF.B.B1); +break; +case 0x03: +// INC BC +BC.W++; +break; +case 0x04: +// INC B +BC.B.B1++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B1] | (BC.B.B1 & 0x0F ? 0 : H_FLAG); +break; +case 0x05: +// DEC B +BC.B.B1--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B1] | ((BC.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x06: +// LD B, NN +BC.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x07: +// RLCA +tempValue = AF.B.B1 & 0x80 ? C_FLAG : 0; +AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B1 >> 7); +AF.B.B0 = tempValue; +break; +case 0x08: +// LD (NNNN), SP +tempRegister.B.B0 = gbReadOpcode(PC.W++); +tempRegister.B.B1 = gbReadOpcode(PC.W++); +gbWriteMemory(tempRegister.W++, SP.B.B0); +gbWriteMemory(tempRegister.W, SP.B.B1); +break; +case 0x09: +// ADD HL,BC +tempRegister.W = (HL.W + BC.W) & 0xFFFF; +AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ BC.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | + (((long)HL.W + (long)BC.W) & 0x10000 ? C_FLAG : 0); +HL.W = tempRegister.W; +break; +case 0x0a: +// LD A,(BC) +AF.B.B1 = gbReadMemory(BC.W); +break; +case 0x0b: +// DEC BC +BC.W--; +break; +case 0x0c: +// INC C +BC.B.B0++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B0] | (BC.B.B0 & 0x0F ? 0 : H_FLAG); +break; +case 0x0d: +// DEC C +BC.B.B0--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[BC.B.B0] | ((BC.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x0e: +// LD C, NN +BC.B.B0 = gbReadOpcode(PC.W++); +break; +case 0x0f: +// RRCA +tempValue = AF.B.B1 & 0x01; +AF.B.B1 = (AF.B.B1 >> 1) | (tempValue ? 0x80 : 0); +AF.B.B0 = (tempValue << 4); +break; +case 0x10: +// STOP +opcode = gbReadOpcode(PC.W++); +if (gbCgbMode) { + if (gbMemory[0xff4d] & 1) { + gbSpeedSwitch(); + // clockTicks += 228*144-(gbSpeed ? 62 : 63); - gbSpeedSwitch(); - //clockTicks += 228*144-(gbSpeed ? 62 : 63); - - if(gbSpeed == 0) - gbMemory[0xff4d] = 0x00; - else - gbMemory[0xff4d] = 0x80; - } - } - break; - case 0x11: - // LD DE, NNNN - DE.B.B0=gbReadOpcode(PC.W++); - DE.B.B1=gbReadOpcode(PC.W++); - break; - case 0x12: - // LD (DE),A - gbWriteMemory(DE.W,AF.B.B1); - break; - case 0x13: - // INC DE - DE.W++; - break; - case 0x14: - // INC D - DE.B.B1++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]| (DE.B.B1&0x0F? 0:H_FLAG); - break; - case 0x15: - // DEC D - DE.B.B1--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B1]| - ((DE.B.B1&0x0F)==0x0F? H_FLAG:0); - break; - case 0x16: - // LD D,NN - DE.B.B1=gbReadOpcode(PC.W++); - break; - case 0x17: - // RLA - tempValue=AF.B.B1&0x80? C_FLAG:0; - AF.B.B1=(AF.B.B1<<1)|((AF.B.B0&C_FLAG)>>4); - AF.B.B0=tempValue; - break; - case 0x18: - // JR NN - PC.W+=(s8)gbReadOpcode(PC.W)+1; - break; - case 0x19: - // ADD HL,DE - tempRegister.W=(HL.W+DE.W)&0xFFFF; - AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^DE.W^tempRegister.W)&0x1000? H_FLAG:0)| - (((long)HL.W+(long)DE.W)&0x10000? C_FLAG:0); - HL.W=tempRegister.W; - break; - case 0x1a: - // LD A,(DE) - AF.B.B1=gbReadMemory(DE.W); - break; - case 0x1b: - // DEC DE - DE.W--; - break; - case 0x1c: - // INC E - DE.B.B0++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]| (DE.B.B0&0x0F? 0:H_FLAG); - break; - case 0x1d: - // DEC E - DE.B.B0--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[DE.B.B0]| - ((DE.B.B0&0x0F)==0x0F? H_FLAG:0); - break; - case 0x1e: - // LD E,NN - DE.B.B0=gbReadOpcode(PC.W++); - break; - case 0x1f: - // RRA - tempValue=AF.B.B1&0x01; - AF.B.B1=(AF.B.B1>>1)|(AF.B.B0&C_FLAG? 0x80:0); - AF.B.B0=(tempValue<<4); - break; - case 0x20: - // JR NZ,NN - if(AF.B.B0&Z_FLAG) - PC.W++; - else { - PC.W+=(s8)gbReadOpcode(PC.W)+1; - clockTicks++; - } - break; - case 0x21: - // LD HL,NNNN - HL.B.B0=gbReadOpcode(PC.W++); - HL.B.B1=gbReadOpcode(PC.W++); - break; - case 0x22: - // LDI (HL),A - gbWriteMemory(HL.W++,AF.B.B1); - break; - case 0x23: - // INC HL - HL.W++; - break; - case 0x24: - // INC H - HL.B.B1++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]| (HL.B.B1&0x0F? 0:H_FLAG); - break; - case 0x25: - // DEC H - HL.B.B1--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B1]| - ((HL.B.B1&0x0F)==0x0F? H_FLAG:0); - break; - case 0x26: - // LD H,NN - HL.B.B1=gbReadOpcode(PC.W++); - break; - case 0x27: - // DAA - tempRegister.W=AF.B.B1; - tempRegister.W|=(AF.B.B0&(C_FLAG|H_FLAG|N_FLAG))<<4; - AF.W=DAATable[tempRegister.W]; - break; - case 0x28: - // JR Z,NN - if(AF.B.B0&Z_FLAG) { - PC.W+=(s8)gbReadOpcode(PC.W)+1; - clockTicks++; - } else - PC.W++; - break; - case 0x29: - // ADD HL,HL - tempRegister.W=(HL.W+HL.W)&0xFFFF; AF.B.B0= (AF.B.B0 & Z_FLAG)| - ((HL.W^HL.W^tempRegister.W)&0x1000? H_FLAG:0)| - (((long)HL.W+(long)HL.W)&0x10000? C_FLAG:0); - HL.W=tempRegister.W; - break; - case 0x2a: - // LDI A,(HL) - AF.B.B1 = gbReadMemory(HL.W++); - break; - case 0x2b: - // DEC HL - HL.W--; - break; - case 0x2c: - // INC L - HL.B.B0++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]| (HL.B.B0&0x0F? 0:H_FLAG); - break; - case 0x2d: - // DEC L - HL.B.B0--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[HL.B.B0]| - ((HL.B.B0&0x0F)==0x0F? H_FLAG:0); - break; - case 0x2e: - // LD L,NN - HL.B.B0=gbReadOpcode(PC.W++); - break; - case 0x2f: - // CPL - AF.B.B1 ^= 255; - AF.B.B0|=N_FLAG|H_FLAG; - break; - case 0x30: - // JR NC,NN - if(AF.B.B0&C_FLAG) - PC.W++; - else { - PC.W+=(s8)gbReadOpcode(PC.W)+1; - clockTicks++; - } - break; - case 0x31: - // LD SP,NNNN - SP.B.B0=gbReadOpcode(PC.W++); - SP.B.B1=gbReadOpcode(PC.W++); - break; - case 0x32: - // LDD (HL),A - gbWriteMemory(HL.W--,AF.B.B1); - break; - case 0x33: - // INC SP - SP.W++; - break; - case 0x34: - // INC (HL) - tempValue=gbReadMemory(HL.W)+1; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[tempValue]| (tempValue&0x0F? 0:H_FLAG); - gbWriteMemory(HL.W,tempValue); - break; - case 0x35: - // DEC (HL) - tempValue=gbReadMemory(HL.W)-1; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[tempValue]| - ((tempValue&0x0F)==0x0F? H_FLAG:0);gbWriteMemory(HL.W,tempValue); - break; - case 0x36: - // LD (HL),NN - gbWriteMemory(HL.W,gbReadOpcode(PC.W++)); - break; - case 0x37: - // SCF - AF.B.B0 = (AF.B.B0 & Z_FLAG) | C_FLAG; - break; + if (gbSpeed == 0) + gbMemory[0xff4d] = 0x00; + else + gbMemory[0xff4d] = 0x80; + } +} +break; +case 0x11: +// LD DE, NNNN +DE.B.B0 = gbReadOpcode(PC.W++); +DE.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x12: +// LD (DE),A +gbWriteMemory(DE.W, AF.B.B1); +break; +case 0x13: +// INC DE +DE.W++; +break; +case 0x14: +// INC D +DE.B.B1++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B1] | (DE.B.B1 & 0x0F ? 0 : H_FLAG); +break; +case 0x15: +// DEC D +DE.B.B1--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B1] | ((DE.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x16: +// LD D,NN +DE.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x17: +// RLA +tempValue = AF.B.B1 & 0x80 ? C_FLAG : 0; +AF.B.B1 = (AF.B.B1 << 1) | ((AF.B.B0 & C_FLAG) >> 4); +AF.B.B0 = tempValue; +break; +case 0x18: +// JR NN +PC.W += (s8)gbReadOpcode(PC.W) + 1; +break; +case 0x19: +// ADD HL,DE +tempRegister.W = (HL.W + DE.W) & 0xFFFF; +AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ DE.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | + (((long)HL.W + (long)DE.W) & 0x10000 ? C_FLAG : 0); +HL.W = tempRegister.W; +break; +case 0x1a: +// LD A,(DE) +AF.B.B1 = gbReadMemory(DE.W); +break; +case 0x1b: +// DEC DE +DE.W--; +break; +case 0x1c: +// INC E +DE.B.B0++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B0] | (DE.B.B0 & 0x0F ? 0 : H_FLAG); +break; +case 0x1d: +// DEC E +DE.B.B0--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[DE.B.B0] | ((DE.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x1e: +// LD E,NN +DE.B.B0 = gbReadOpcode(PC.W++); +break; +case 0x1f: +// RRA +tempValue = AF.B.B1 & 0x01; +AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); +AF.B.B0 = (tempValue << 4); +break; +case 0x20: +// JR NZ,NN +if (AF.B.B0 & Z_FLAG) + PC.W++; +else { + PC.W += (s8)gbReadOpcode(PC.W) + 1; + clockTicks++; +} +break; +case 0x21: +// LD HL,NNNN +HL.B.B0 = gbReadOpcode(PC.W++); +HL.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x22: +// LDI (HL),A +gbWriteMemory(HL.W++, AF.B.B1); +break; +case 0x23: +// INC HL +HL.W++; +break; +case 0x24: +// INC H +HL.B.B1++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B1] | (HL.B.B1 & 0x0F ? 0 : H_FLAG); +break; +case 0x25: +// DEC H +HL.B.B1--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B1] | ((HL.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x26: +// LD H,NN +HL.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x27: +// DAA +tempRegister.W = AF.B.B1; +tempRegister.W |= (AF.B.B0 & (C_FLAG | H_FLAG | N_FLAG)) << 4; +AF.W = DAATable[tempRegister.W]; +break; +case 0x28: +// JR Z,NN +if (AF.B.B0 & Z_FLAG) { + PC.W += (s8)gbReadOpcode(PC.W) + 1; + clockTicks++; +} else + PC.W++; +break; +case 0x29: +// ADD HL,HL +tempRegister.W = (HL.W + HL.W) & 0xFFFF; +AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ HL.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | + (((long)HL.W + (long)HL.W) & 0x10000 ? C_FLAG : 0); +HL.W = tempRegister.W; +break; +case 0x2a: +// LDI A,(HL) +AF.B.B1 = gbReadMemory(HL.W++); +break; +case 0x2b: +// DEC HL +HL.W--; +break; +case 0x2c: +// INC L +HL.B.B0++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B0] | (HL.B.B0 & 0x0F ? 0 : H_FLAG); +break; +case 0x2d: +// DEC L +HL.B.B0--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[HL.B.B0] | ((HL.B.B0 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x2e: +// LD L,NN +HL.B.B0 = gbReadOpcode(PC.W++); +break; +case 0x2f: +// CPL +AF.B.B1 ^= 255; +AF.B.B0 |= N_FLAG | H_FLAG; +break; +case 0x30: +// JR NC,NN +if (AF.B.B0 & C_FLAG) + PC.W++; +else { + PC.W += (s8)gbReadOpcode(PC.W) + 1; + clockTicks++; +} +break; +case 0x31: +// LD SP,NNNN +SP.B.B0 = gbReadOpcode(PC.W++); +SP.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x32: +// LDD (HL),A +gbWriteMemory(HL.W--, AF.B.B1); +break; +case 0x33: +// INC SP +SP.W++; +break; +case 0x34: +// INC (HL) +tempValue = gbReadMemory(HL.W) + 1; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[tempValue] | (tempValue & 0x0F ? 0 : H_FLAG); +gbWriteMemory(HL.W, tempValue); +break; +case 0x35: +// DEC (HL) +tempValue = gbReadMemory(HL.W) - 1; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[tempValue] | ((tempValue & 0x0F) == 0x0F ? H_FLAG : 0); +gbWriteMemory(HL.W, tempValue); +break; +case 0x36: +// LD (HL),NN +gbWriteMemory(HL.W, gbReadOpcode(PC.W++)); +break; +case 0x37: +// SCF +AF.B.B0 = (AF.B.B0 & Z_FLAG) | C_FLAG; +break; case 0x38: - // JR C,NN - if(AF.B.B0&C_FLAG) { - PC.W+=(s8)gbReadOpcode(PC.W)+1; - clockTicks ++; - } else - PC.W++; - break; - case 0x39: - // ADD HL,SP - tempRegister.W=(HL.W+SP.W)&0xFFFF; - AF.B.B0= (AF.B.B0 & Z_FLAG)| ((HL.W^SP.W^tempRegister.W)&0x1000? H_FLAG:0)| - (((long)HL.W+(long)SP.W)&0x10000? C_FLAG:0); - HL.W=tempRegister.W; - break; - case 0x3a: - // LDD A,(HL) - AF.B.B1 = gbReadMemory(HL.W--); - break; - case 0x3b: - // DEC SP - SP.W--; - break; - case 0x3c: - // INC A - AF.B.B1++; - AF.B.B0= (AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]| (AF.B.B1&0x0F? 0:H_FLAG); - break; - case 0x3d: - // DEC A - AF.B.B1--; - AF.B.B0= N_FLAG|(AF.B.B0 & C_FLAG)|ZeroTable[AF.B.B1]| - ((AF.B.B1&0x0F)==0x0F? H_FLAG:0); - break; - case 0x3e: - // LD A,NN - AF.B.B1=gbReadOpcode(PC.W++); - break; - case 0x3f: - // CCF - AF.B.B0^=C_FLAG;AF.B.B0&=~(N_FLAG|H_FLAG); - break; - case 0x40: - // LD B,B - BC.B.B1=BC.B.B1; - break; - case 0x41: - // LD B,C - BC.B.B1=BC.B.B0; - break; - case 0x42: - // LD B,D - BC.B.B1=DE.B.B1; - break; - case 0x43: - // LD B,E - BC.B.B1=DE.B.B0; - break; - case 0x44: - // LD B,H - BC.B.B1=HL.B.B1; - break; - case 0x45: - // LD B,L - BC.B.B1=HL.B.B0; - break; - case 0x46: - // LD B,(HL) - BC.B.B1=gbReadMemory(HL.W); - break; - case 0x47: - // LD B,A - BC.B.B1=AF.B.B1; - break; - case 0x48: - // LD C,B - BC.B.B0=BC.B.B1; - break; - case 0x49: - // LD C,C - BC.B.B0=BC.B.B0; - break; - case 0x4a: - // LD C,D - BC.B.B0=DE.B.B1; - break; - case 0x4b: - // LD C,E - BC.B.B0=DE.B.B0; - break; - case 0x4c: - // LD C,H - BC.B.B0=HL.B.B1; - break; - case 0x4d: - // LD C,L - BC.B.B0=HL.B.B0; - break; - case 0x4e: - // LD C,(HL) - BC.B.B0=gbReadMemory(HL.W); - break; - case 0x4f: - // LD C,A - BC.B.B0=AF.B.B1; - break; - case 0x50: - // LD D,B - DE.B.B1=BC.B.B1; - break; - case 0x51: - // LD D,C - DE.B.B1=BC.B.B0; - break; - case 0x52: - // LD D,D - DE.B.B1=DE.B.B1; - break; - case 0x53: - // LD D,E - DE.B.B1=DE.B.B0; - break; - case 0x54: - // LD D,H - DE.B.B1=HL.B.B1; - break; - case 0x55: - // LD D,L - DE.B.B1=HL.B.B0; - break; - case 0x56: - // LD D,(HL) - DE.B.B1=gbReadMemory(HL.W); - break; - case 0x57: - // LD D,A - DE.B.B1=AF.B.B1; - break; - case 0x58: - // LD E,B - DE.B.B0=BC.B.B1; - break; - case 0x59: - // LD E,C - DE.B.B0=BC.B.B0; - break; - case 0x5a: - // LD E,D - DE.B.B0=DE.B.B1; - break; - case 0x5b: - // LD E,E - DE.B.B0=DE.B.B0; - break; - case 0x5c: - // LD E,H - DE.B.B0=HL.B.B1; - break; - case 0x5d: - // LD E,L - DE.B.B0=HL.B.B0; - break; - case 0x5e: - // LD E,(HL) - DE.B.B0=gbReadMemory(HL.W); - break; - case 0x5f: - // LD E,A - DE.B.B0=AF.B.B1; - break; - case 0x60: - // LD H,B - HL.B.B1=BC.B.B1; - break; - case 0x61: - // LD H,C - HL.B.B1=BC.B.B0; - break; - case 0x62: - // LD H,D - HL.B.B1=DE.B.B1; - break; - case 0x63: - // LD H,E - HL.B.B1=DE.B.B0; - break; - case 0x64: - // LD H,H - HL.B.B1=HL.B.B1; - break; - case 0x65: - // LD H,L - HL.B.B1=HL.B.B0; - break; - case 0x66: - // LD H,(HL) - HL.B.B1=gbReadMemory(HL.W); - break; - case 0x67: - // LD H,A - HL.B.B1=AF.B.B1; - break; - case 0x68: - // LD L,B - HL.B.B0=BC.B.B1; - break; - case 0x69: - // LD L,C - HL.B.B0=BC.B.B0; - break; - case 0x6a: - // LD L,D - HL.B.B0=DE.B.B1; - break; - case 0x6b: - // LD L,E - HL.B.B0=DE.B.B0; - break; - case 0x6c: - // LD L,H - HL.B.B0=HL.B.B1; - break; - case 0x6d: - // LD L,L - HL.B.B0=HL.B.B0; - break; - case 0x6e: - // LD L,(HL) - HL.B.B0=gbReadMemory(HL.W); - break; - case 0x6f: - // LD L,A - HL.B.B0=AF.B.B1; - break; - case 0x70: - // LD (HL),B - gbWriteMemory(HL.W,BC.B.B1); - break; - case 0x71: - // LD (HL),C - gbWriteMemory(HL.W,BC.B.B0); - break; - case 0x72: - // LD (HL),D - gbWriteMemory(HL.W,DE.B.B1); - break; - case 0x73: - // LD (HL),E - gbWriteMemory(HL.W,DE.B.B0); - break; - case 0x74: - // LD (HL),H - gbWriteMemory(HL.W,HL.B.B1); - break; - case 0x75: - // LD (HL),L - gbWriteMemory(HL.W,HL.B.B0); - break; - case 0x76: - // HALT - // If an EI is pending, the interrupts are triggered before Halt state !! - // Fix Torpedo Range's intro. - if (IFF & 0x40) - { - IFF &= ~0x70; - IFF |=1; - PC.W--; - } - else - { - // if (IE & IF) and interrupts are disabeld, - // Halt is cancelled. - if ((register_IE & register_IF & 0x1f) && !(IFF & 1)) - { - IFF|=2; - } - else - IFF |= 0x80; - } - break; - case 0x77: - // LD (HL),A - gbWriteMemory(HL.W,AF.B.B1); - break; - case 0x78: - // LD A,B - AF.B.B1=BC.B.B1; - break; - case 0x79: - // LD A,C - AF.B.B1=BC.B.B0; - break; - case 0x7a: - // LD A,D - AF.B.B1=DE.B.B1; - break; - case 0x7b: - // LD A,E - AF.B.B1=DE.B.B0; - break; - case 0x7c: - // LD A,H - AF.B.B1=HL.B.B1; - break; - case 0x7d: - // LD A,L - AF.B.B1=HL.B.B0; - break; - case 0x7e: - // LD A,(HL) - AF.B.B1=gbReadMemory(HL.W); - break; - case 0x7f: - // LD A,A - AF.B.B1=AF.B.B1; - break; - case 0x80: - // ADD B - tempRegister.W=AF.B.B1+BC.B.B1; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x81: - // ADD C - tempRegister.W=AF.B.B1+BC.B.B0; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x82: - // ADD D - tempRegister.W=AF.B.B1+DE.B.B1; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x83: - // ADD E - tempRegister.W=AF.B.B1+DE.B.B0; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x84: - // ADD H - tempRegister.W=AF.B.B1+HL.B.B1; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x85: - // ADD L - tempRegister.W=AF.B.B1+HL.B.B0; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x86: - // ADD (HL) - tempValue=gbReadMemory(HL.W); - tempRegister.W=AF.B.B1+tempValue; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x87: - // ADD A - tempRegister.W=AF.B.B1+AF.B.B1; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x88: - // ADC B: - tempRegister.W=AF.B.B1+BC.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x89: - // ADC C - tempRegister.W=AF.B.B1+BC.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x8a: - // ADC D - tempRegister.W=AF.B.B1+DE.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x8b: - // ADC E - tempRegister.W=AF.B.B1+DE.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x8c: - // ADC H - tempRegister.W=AF.B.B1+HL.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); AF.B.B1=tempRegister.B.B0; - break; - case 0x8d: - // ADC L - tempRegister.W=AF.B.B1+HL.B.B0+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x8e: - // ADC (HL) - tempValue=gbReadMemory(HL.W); - tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x8f: - // ADC A - tempRegister.W=AF.B.B1+AF.B.B1+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x90: - // SUB B - tempRegister.W=AF.B.B1-BC.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x91: - // SUB C - tempRegister.W=AF.B.B1-BC.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x92: - // SUB D - tempRegister.W=AF.B.B1-DE.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x93: - // SUB E - tempRegister.W=AF.B.B1-DE.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x94: - // SUB H - tempRegister.W=AF.B.B1-HL.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x95: - // SUB L - tempRegister.W=AF.B.B1-HL.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x96: - // SUB (HL) - tempValue=gbReadMemory(HL.W); - tempRegister.W=AF.B.B1-tempValue; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x97: - // SUB A - AF.B.B1=0; - AF.B.B0=N_FLAG|Z_FLAG; - break; - case 0x98: - // SBC B - tempRegister.W=AF.B.B1-BC.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x99: - // SBC C - tempRegister.W=AF.B.B1-BC.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9a: - // SBC D - tempRegister.W=AF.B.B1-DE.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9b: - // SBC E - tempRegister.W=AF.B.B1-DE.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9c: - // SBC H - tempRegister.W=AF.B.B1-HL.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9d: - // SBC L - tempRegister.W=AF.B.B1-HL.B.B0-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9e: - // SBC (HL) - tempValue=gbReadMemory(HL.W); - tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0x9f: - // SBC A - tempRegister.W=AF.B.B1-AF.B.B1-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^AF.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0xa0: - // AND B - AF.B.B1&=BC.B.B1; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa1: - // AND C - AF.B.B1&=BC.B.B0; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa2: - // AND_D - AF.B.B1&=DE.B.B1; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa3: - // AND E - AF.B.B1&=DE.B.B0; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa4: - // AND H - AF.B.B1&=HL.B.B1; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa5: - // AND L - AF.B.B1&=HL.B.B0; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa6: - // AND (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B1&=tempValue; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa7: - // AND A - AF.B.B1&=AF.B.B1; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xa8: - // XOR B - AF.B.B1^=BC.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xa9: - // XOR C - AF.B.B1^=BC.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xaa: - // XOR D - AF.B.B1^=DE.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xab: - // XOR E - AF.B.B1^=DE.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xac: - // XOR H - AF.B.B1^=HL.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xad: - // XOR L - AF.B.B1^=HL.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xae: - // XOR (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B1^=tempValue; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xaf: - // XOR A - AF.B.B1=0; - AF.B.B0=Z_FLAG; - break; - case 0xb0: - // OR B - AF.B.B1|=BC.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb1: - // OR C - AF.B.B1|=BC.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb2: - // OR D - AF.B.B1|=DE.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb3: - // OR E - AF.B.B1|=DE.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb4: - // OR H - AF.B.B1|=HL.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb5: - // OR L - AF.B.B1|=HL.B.B0; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb6: - // OR (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B1|=tempValue; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb7: - // OR A - AF.B.B1|=AF.B.B1; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xb8: - // CP B: - tempRegister.W=AF.B.B1-BC.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xb9: - // CP C - tempRegister.W=AF.B.B1-BC.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^BC.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xba: - // CP D - tempRegister.W=AF.B.B1-DE.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xbb: - // CP E - tempRegister.W=AF.B.B1-DE.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^DE.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xbc: - // CP H - tempRegister.W=AF.B.B1-HL.B.B1; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B1^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xbd: - // CP L - tempRegister.W=AF.B.B1-HL.B.B0; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^HL.B.B0^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xbe: - // CP (HL) - tempValue=gbReadMemory(HL.W); - tempRegister.W=AF.B.B1-tempValue; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xbf: - // CP A - AF.B.B0=N_FLAG|Z_FLAG; - break; - case 0xc0: - // RET NZ - if(!(AF.B.B0&Z_FLAG)) { - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - clockTicks += 3; - } - break; - case 0xc1: - // POP BC - BC.B.B0=gbReadMemory(SP.W++); - BC.B.B1=gbReadMemory(SP.W++); - break; - case 0xc2: - // JP NZ,NNNN - if(AF.B.B0&Z_FLAG) - PC.W+=2; - else { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W); - PC.W=tempRegister.W; - clockTicks++; - } - break; - case 0xc3: - // JP NNNN - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W); - PC.W=tempRegister.W; - break; - case 0xc4: - // CALL NZ,NNNN - if(AF.B.B0&Z_FLAG) - PC.W+=2; - else { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=tempRegister.W; - clockTicks += 3; - } - break; - case 0xc5: - // PUSH BC - gbWriteMemory(--SP.W,BC.B.B1); - gbWriteMemory(--SP.W,BC.B.B0); - break; - case 0xc6: - // ADD NN - tempValue=gbReadOpcode(PC.W++); - tempRegister.W=AF.B.B1+tempValue; - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10 ? H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0xc7: - // RST 00 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0000; - break; - case 0xc8: - // RET Z - if(AF.B.B0&Z_FLAG) { - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - clockTicks += 3; - } - break; - case 0xc9: - // RET - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - break; - case 0xca: - // JP Z,NNNN - if(AF.B.B0&Z_FLAG) { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W); - PC.W=tempRegister.W; - clockTicks++; - } else - PC.W+=2; - break; - // CB done outside - case 0xcc: - // CALL Z,NNNN - if(AF.B.B0&Z_FLAG) { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=tempRegister.W; - clockTicks += 3; - } else - PC.W+=2; - break; - case 0xcd: - // CALL NNNN - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=tempRegister.W; - break; - case 0xce: - // ADC NN - tempValue=gbReadOpcode(PC.W++); - tempRegister.W=AF.B.B1+tempValue+(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= (tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0xcf: - // RST 08 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0008; - break; - case 0xd0: - // RET NC - if(!(AF.B.B0&C_FLAG)) { - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - clockTicks += 3; - } - break; - case 0xd1: - // POP DE - DE.B.B0=gbReadMemory(SP.W++); - DE.B.B1=gbReadMemory(SP.W++); - break; - case 0xd2: - // JP NC,NNNN - if(AF.B.B0&C_FLAG) - PC.W+=2; - else { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W); - PC.W=tempRegister.W; - clockTicks++; - } - break; - // D3 illegal - case 0xd3: - PC.W--; - IFF = 0; - break; - case 0xd4: - // CALL NC,NNNN - if(AF.B.B0&C_FLAG) - PC.W+=2; - else { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=tempRegister.W; - clockTicks += 3; - } - break; - case 0xd5: - // PUSH DE - gbWriteMemory(--SP.W,DE.B.B1); - gbWriteMemory(--SP.W,DE.B.B0); - break; - case 0xd6: - // SUB NN - tempValue=gbReadOpcode(PC.W++); - tempRegister.W=AF.B.B1-tempValue; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0xd7: - // RST 10 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0010; - break; - case 0xd8: - // RET C - if(AF.B.B0&C_FLAG) { - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - clockTicks += 3; - } - break; - case 0xd9: - // RETI - PC.B.B0=gbReadMemory(SP.W++); - PC.B.B1=gbReadMemory(SP.W++); - IFF |= 0x01; - break; - case 0xda: - // JP C,NNNN - if(AF.B.B0&C_FLAG) { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W); - PC.W=tempRegister.W; - clockTicks++; - } else - PC.W+=2; - break; - // DB illegal - case 0xdb: - PC.W--; - IFF = 0; - break; - case 0xdc: - // CALL C,NNNN - if(AF.B.B0&C_FLAG) { - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=tempRegister.W; - clockTicks += 3; - } else - PC.W+=2; - break; - // DD illegal - case 0xdd: - PC.W--; - IFF = 0; - break; - case 0xde: - // SBC NN - tempValue=gbReadOpcode(PC.W++); - tempRegister.W=AF.B.B1-tempValue-(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - AF.B.B1=tempRegister.B.B0; - break; - case 0xdf: - // RST 18 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0018; - break; - case 0xe0: - // LD (FF00+NN),A - gbWriteMemory(0xff00 + gbReadOpcode(PC.W++),AF.B.B1); - break; - case 0xe1: - // POP HL - HL.B.B0=gbReadMemory(SP.W++); - HL.B.B1=gbReadMemory(SP.W++); - break; - case 0xe2: - // LD (FF00+C),A - gbWriteMemory(0xff00 + BC.B.B0,AF.B.B1); - break; - // E3 illegal - // E4 illegal - case 0xe3: - case 0xe4: - PC.W--; - IFF = 0; - break; - case 0xe5: - // PUSH HL - gbWriteMemory(--SP.W,HL.B.B1); - gbWriteMemory(--SP.W,HL.B.B0); - break; - case 0xe6: - // AND NN - tempValue=gbReadOpcode(PC.W++); - AF.B.B1&=tempValue; - AF.B.B0=H_FLAG|ZeroTable[AF.B.B1]; - break; - case 0xe7: - // RST 20 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0020; - break; - case 0xe8: - // ADD SP,NN - offset = (s8)gbReadOpcode(PC.W++); - tempRegister.W = SP.W + offset; - AF.B.B0 = ((SP.W^offset^tempRegister.W)&0x100? C_FLAG : 0) | - ((SP.W^offset^tempRegister.W)& 0x10? H_FLAG : 0); - SP.W = tempRegister.W; - break; - case 0xe9: - // LD PC,HL - PC.W=HL.W; - break; - case 0xea: - // LD (NNNN),A - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - gbWriteMemory(tempRegister.W,AF.B.B1); - break; - // EB illegal - // EC illegal - // ED illegal - case 0xeb: - case 0xec: - case 0xed: - PC.W--; - IFF = 0; - break; - case 0xee: - // XOR NN - tempValue=gbReadOpcode(PC.W++); - AF.B.B1^=tempValue; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xef: - // RST 28 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0028; - break; - case 0xf0: - // LD A,(FF00+NN) - AF.B.B1 = gbReadMemory(0xff00+gbReadOpcode(PC.W++)); - break; - case 0xf1: - // POP AF - AF.B.B0=gbReadMemory(SP.W++)&0xF0; - AF.B.B1=gbReadMemory(SP.W++); - break; - case 0xf2: - // LD A,(FF00+C) - AF.B.B1 = gbReadMemory(0xff00+BC.B.B0); - break; - case 0xf3: - // DI - // IFF&=0xFE; - IFF|=0x08; - break; - // F4 illegal - case 0xf4: - PC.W--; - IFF = 0; - break; - case 0xf5: - // PUSH AF - gbWriteMemory(--SP.W,AF.B.B1); - gbWriteMemory(--SP.W,AF.B.B0); - break; - case 0xf6: - // OR NN - tempValue=gbReadOpcode(PC.W++); - AF.B.B1|=tempValue; - AF.B.B0=ZeroTable[AF.B.B1]; - break; - case 0xf7: - // RST 30 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0030; - break; - case 0xf8: - // LD HL,SP+NN - offset = (s8)gbReadOpcode(PC.W++); - tempRegister.W = SP.W + offset; - AF.B.B0 = ((SP.W^offset^tempRegister.W)&0x100? C_FLAG : 0) | - ((SP.W^offset^tempRegister.W)& 0x10? H_FLAG : 0); - HL.W = tempRegister.W; - break; - case 0xf9: - // LD SP,HL - SP.W=HL.W; - break; - case 0xfa: - // LD A,(NNNN) - tempRegister.B.B0=gbReadOpcode(PC.W++); - tempRegister.B.B1=gbReadOpcode(PC.W++); - AF.B.B1=gbReadMemory(tempRegister.W); - break; - case 0xfb: - // EI - if (!(IFF & 0x30)) - // If an EI is executed right before HALT, - // the interrupts are triggered before the Halt state !! - // Fix Torpedo Range Intro. - // IFF |= 0x10 : 1 ticks before the EI enables the interrupts - // IFF |= 0x40 : marks that an EI is being executed. - IFF|=0x50; - break; - // FC illegal (FC = breakpoint) - case 0xfc: - breakpoint = true; - break; - // FD illegal - case 0xfd: - PC.W--; - IFF = 0; - break; - case 0xfe: - // CP NN - tempValue=gbReadOpcode(PC.W++); - tempRegister.W=AF.B.B1-tempValue; - AF.B.B0= N_FLAG|(tempRegister.B.B1?C_FLAG:0)|ZeroTable[tempRegister.B.B0]| - ((AF.B.B1^tempValue^tempRegister.B.B0)&0x10?H_FLAG:0); - break; - case 0xff: - // RST 38 - gbWriteMemory(--SP.W,PC.B.B1); - gbWriteMemory(--SP.W,PC.B.B0); - PC.W=0x0038; - break; - default: - if (gbSystemMessage == false) - { - systemMessage(0, N_("Unknown opcode %02x at %04x"), - gbReadOpcode(PC.W-1),PC.W-1); - gbSystemMessage =true; - } - return; +// JR C,NN +if (AF.B.B0 & C_FLAG) { + PC.W += (s8)gbReadOpcode(PC.W) + 1; + clockTicks++; +} else + PC.W++; +break; +case 0x39: +// ADD HL,SP +tempRegister.W = (HL.W + SP.W) & 0xFFFF; +AF.B.B0 = (AF.B.B0 & Z_FLAG) | ((HL.W ^ SP.W ^ tempRegister.W) & 0x1000 ? H_FLAG : 0) | + (((long)HL.W + (long)SP.W) & 0x10000 ? C_FLAG : 0); +HL.W = tempRegister.W; +break; +case 0x3a: +// LDD A,(HL) +AF.B.B1 = gbReadMemory(HL.W--); +break; +case 0x3b: +// DEC SP +SP.W--; +break; +case 0x3c: +// INC A +AF.B.B1++; +AF.B.B0 = (AF.B.B0 & C_FLAG) | ZeroTable[AF.B.B1] | (AF.B.B1 & 0x0F ? 0 : H_FLAG); +break; +case 0x3d: +// DEC A +AF.B.B1--; +AF.B.B0 = + N_FLAG | (AF.B.B0 & C_FLAG) | ZeroTable[AF.B.B1] | ((AF.B.B1 & 0x0F) == 0x0F ? H_FLAG : 0); +break; +case 0x3e: +// LD A,NN +AF.B.B1 = gbReadOpcode(PC.W++); +break; +case 0x3f: +// CCF +AF.B.B0 ^= C_FLAG; +AF.B.B0 &= ~(N_FLAG | H_FLAG); +break; +case 0x40: +// LD B,B +BC.B.B1 = BC.B.B1; +break; +case 0x41: +// LD B,C +BC.B.B1 = BC.B.B0; +break; +case 0x42: +// LD B,D +BC.B.B1 = DE.B.B1; +break; +case 0x43: +// LD B,E +BC.B.B1 = DE.B.B0; +break; +case 0x44: +// LD B,H +BC.B.B1 = HL.B.B1; +break; +case 0x45: +// LD B,L +BC.B.B1 = HL.B.B0; +break; +case 0x46: +// LD B,(HL) +BC.B.B1 = gbReadMemory(HL.W); +break; +case 0x47: +// LD B,A +BC.B.B1 = AF.B.B1; +break; +case 0x48: +// LD C,B +BC.B.B0 = BC.B.B1; +break; +case 0x49: +// LD C,C +BC.B.B0 = BC.B.B0; +break; +case 0x4a: +// LD C,D +BC.B.B0 = DE.B.B1; +break; +case 0x4b: +// LD C,E +BC.B.B0 = DE.B.B0; +break; +case 0x4c: +// LD C,H +BC.B.B0 = HL.B.B1; +break; +case 0x4d: +// LD C,L +BC.B.B0 = HL.B.B0; +break; +case 0x4e: +// LD C,(HL) +BC.B.B0 = gbReadMemory(HL.W); +break; +case 0x4f: +// LD C,A +BC.B.B0 = AF.B.B1; +break; +case 0x50: +// LD D,B +DE.B.B1 = BC.B.B1; +break; +case 0x51: +// LD D,C +DE.B.B1 = BC.B.B0; +break; +case 0x52: +// LD D,D +DE.B.B1 = DE.B.B1; +break; +case 0x53: +// LD D,E +DE.B.B1 = DE.B.B0; +break; +case 0x54: +// LD D,H +DE.B.B1 = HL.B.B1; +break; +case 0x55: +// LD D,L +DE.B.B1 = HL.B.B0; +break; +case 0x56: +// LD D,(HL) +DE.B.B1 = gbReadMemory(HL.W); +break; +case 0x57: +// LD D,A +DE.B.B1 = AF.B.B1; +break; +case 0x58: +// LD E,B +DE.B.B0 = BC.B.B1; +break; +case 0x59: +// LD E,C +DE.B.B0 = BC.B.B0; +break; +case 0x5a: +// LD E,D +DE.B.B0 = DE.B.B1; +break; +case 0x5b: +// LD E,E +DE.B.B0 = DE.B.B0; +break; +case 0x5c: +// LD E,H +DE.B.B0 = HL.B.B1; +break; +case 0x5d: +// LD E,L +DE.B.B0 = HL.B.B0; +break; +case 0x5e: +// LD E,(HL) +DE.B.B0 = gbReadMemory(HL.W); +break; +case 0x5f: +// LD E,A +DE.B.B0 = AF.B.B1; +break; +case 0x60: +// LD H,B +HL.B.B1 = BC.B.B1; +break; +case 0x61: +// LD H,C +HL.B.B1 = BC.B.B0; +break; +case 0x62: +// LD H,D +HL.B.B1 = DE.B.B1; +break; +case 0x63: +// LD H,E +HL.B.B1 = DE.B.B0; +break; +case 0x64: +// LD H,H +HL.B.B1 = HL.B.B1; +break; +case 0x65: +// LD H,L +HL.B.B1 = HL.B.B0; +break; +case 0x66: +// LD H,(HL) +HL.B.B1 = gbReadMemory(HL.W); +break; +case 0x67: +// LD H,A +HL.B.B1 = AF.B.B1; +break; +case 0x68: +// LD L,B +HL.B.B0 = BC.B.B1; +break; +case 0x69: +// LD L,C +HL.B.B0 = BC.B.B0; +break; +case 0x6a: +// LD L,D +HL.B.B0 = DE.B.B1; +break; +case 0x6b: +// LD L,E +HL.B.B0 = DE.B.B0; +break; +case 0x6c: +// LD L,H +HL.B.B0 = HL.B.B1; +break; +case 0x6d: +// LD L,L +HL.B.B0 = HL.B.B0; +break; +case 0x6e: +// LD L,(HL) +HL.B.B0 = gbReadMemory(HL.W); +break; +case 0x6f: +// LD L,A +HL.B.B0 = AF.B.B1; +break; +case 0x70: +// LD (HL),B +gbWriteMemory(HL.W, BC.B.B1); +break; +case 0x71: +// LD (HL),C +gbWriteMemory(HL.W, BC.B.B0); +break; +case 0x72: +// LD (HL),D +gbWriteMemory(HL.W, DE.B.B1); +break; +case 0x73: +// LD (HL),E +gbWriteMemory(HL.W, DE.B.B0); +break; +case 0x74: +// LD (HL),H +gbWriteMemory(HL.W, HL.B.B1); +break; +case 0x75: +// LD (HL),L +gbWriteMemory(HL.W, HL.B.B0); +break; +case 0x76: +// HALT +// If an EI is pending, the interrupts are triggered before Halt state !! +// Fix Torpedo Range's intro. +if (IFF & 0x40) { + IFF &= ~0x70; + IFF |= 1; + PC.W--; +} else { + // if (IE & IF) and interrupts are disabeld, + // Halt is cancelled. + if ((register_IE & register_IF & 0x1f) && !(IFF & 1)) { + IFF |= 2; + } else + IFF |= 0x80; +} +break; +case 0x77: +// LD (HL),A +gbWriteMemory(HL.W, AF.B.B1); +break; +case 0x78: +// LD A,B +AF.B.B1 = BC.B.B1; +break; +case 0x79: +// LD A,C +AF.B.B1 = BC.B.B0; +break; +case 0x7a: +// LD A,D +AF.B.B1 = DE.B.B1; +break; +case 0x7b: +// LD A,E +AF.B.B1 = DE.B.B0; +break; +case 0x7c: +// LD A,H +AF.B.B1 = HL.B.B1; +break; +case 0x7d: +// LD A,L +AF.B.B1 = HL.B.B0; +break; +case 0x7e: +// LD A,(HL) +AF.B.B1 = gbReadMemory(HL.W); +break; +case 0x7f: +// LD A,A +AF.B.B1 = AF.B.B1; +break; +case 0x80: +// ADD B +tempRegister.W = AF.B.B1 + BC.B.B1; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x81: +// ADD C +tempRegister.W = AF.B.B1 + BC.B.B0; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x82: +// ADD D +tempRegister.W = AF.B.B1 + DE.B.B1; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x83: +// ADD E +tempRegister.W = AF.B.B1 + DE.B.B0; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x84: +// ADD H +tempRegister.W = AF.B.B1 + HL.B.B1; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x85: +// ADD L +tempRegister.W = AF.B.B1 + HL.B.B0; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x86: +// ADD (HL) +tempValue = gbReadMemory(HL.W); +tempRegister.W = AF.B.B1 + tempValue; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x87: +// ADD A +tempRegister.W = AF.B.B1 + AF.B.B1; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x88: +// ADC B: +tempRegister.W = AF.B.B1 + BC.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x89: +// ADC C +tempRegister.W = AF.B.B1 + BC.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8a: +// ADC D +tempRegister.W = AF.B.B1 + DE.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8b: +// ADC E +tempRegister.W = AF.B.B1 + DE.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8c: +// ADC H +tempRegister.W = AF.B.B1 + HL.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8d: +// ADC L +tempRegister.W = AF.B.B1 + HL.B.B0 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8e: +// ADC (HL) +tempValue = gbReadMemory(HL.W); +tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x8f: +// ADC A +tempRegister.W = AF.B.B1 + AF.B.B1 + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x90: +// SUB B +tempRegister.W = AF.B.B1 - BC.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x91: +// SUB C +tempRegister.W = AF.B.B1 - BC.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x92: +// SUB D +tempRegister.W = AF.B.B1 - DE.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x93: +// SUB E +tempRegister.W = AF.B.B1 - DE.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x94: +// SUB H +tempRegister.W = AF.B.B1 - HL.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x95: +// SUB L +tempRegister.W = AF.B.B1 - HL.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x96: +// SUB (HL) +tempValue = gbReadMemory(HL.W); +tempRegister.W = AF.B.B1 - tempValue; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x97: +// SUB A +AF.B.B1 = 0; +AF.B.B0 = N_FLAG | Z_FLAG; +break; +case 0x98: +// SBC B +tempRegister.W = AF.B.B1 - BC.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x99: +// SBC C +tempRegister.W = AF.B.B1 - BC.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9a: +// SBC D +tempRegister.W = AF.B.B1 - DE.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9b: +// SBC E +tempRegister.W = AF.B.B1 - DE.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9c: +// SBC H +tempRegister.W = AF.B.B1 - HL.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9d: +// SBC L +tempRegister.W = AF.B.B1 - HL.B.B0 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9e: +// SBC (HL) +tempValue = gbReadMemory(HL.W); +tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0x9f: +// SBC A +tempRegister.W = AF.B.B1 - AF.B.B1 - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ AF.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0xa0: +// AND B +AF.B.B1 &= BC.B.B1; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa1: +// AND C +AF.B.B1 &= BC.B.B0; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa2: +// AND_D +AF.B.B1 &= DE.B.B1; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa3: +// AND E +AF.B.B1 &= DE.B.B0; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa4: +// AND H +AF.B.B1 &= HL.B.B1; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa5: +// AND L +AF.B.B1 &= HL.B.B0; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa6: +// AND (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B1 &= tempValue; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa7: +// AND A +AF.B.B1 &= AF.B.B1; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xa8: +// XOR B +AF.B.B1 ^= BC.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xa9: +// XOR C +AF.B.B1 ^= BC.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xaa: +// XOR D +AF.B.B1 ^= DE.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xab: +// XOR E +AF.B.B1 ^= DE.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xac: +// XOR H +AF.B.B1 ^= HL.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xad: +// XOR L +AF.B.B1 ^= HL.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xae: +// XOR (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B1 ^= tempValue; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xaf: +// XOR A +AF.B.B1 = 0; +AF.B.B0 = Z_FLAG; +break; +case 0xb0: +// OR B +AF.B.B1 |= BC.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb1: +// OR C +AF.B.B1 |= BC.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb2: +// OR D +AF.B.B1 |= DE.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb3: +// OR E +AF.B.B1 |= DE.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb4: +// OR H +AF.B.B1 |= HL.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb5: +// OR L +AF.B.B1 |= HL.B.B0; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb6: +// OR (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B1 |= tempValue; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb7: +// OR A +AF.B.B1 |= AF.B.B1; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xb8: +// CP B: +tempRegister.W = AF.B.B1 - BC.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xb9: +// CP C +tempRegister.W = AF.B.B1 - BC.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ BC.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xba: +// CP D +tempRegister.W = AF.B.B1 - DE.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xbb: +// CP E +tempRegister.W = AF.B.B1 - DE.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ DE.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xbc: +// CP H +tempRegister.W = AF.B.B1 - HL.B.B1; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B1 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xbd: +// CP L +tempRegister.W = AF.B.B1 - HL.B.B0; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ HL.B.B0 ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xbe: +// CP (HL) +tempValue = gbReadMemory(HL.W); +tempRegister.W = AF.B.B1 - tempValue; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xbf: +// CP A +AF.B.B0 = N_FLAG | Z_FLAG; +break; +case 0xc0: +// RET NZ +if (!(AF.B.B0 & Z_FLAG)) { + PC.B.B0 = gbReadMemory(SP.W++); + PC.B.B1 = gbReadMemory(SP.W++); + clockTicks += 3; +} +break; +case 0xc1: +// POP BC +BC.B.B0 = gbReadMemory(SP.W++); +BC.B.B1 = gbReadMemory(SP.W++); +break; +case 0xc2: +// JP NZ,NNNN +if (AF.B.B0 & Z_FLAG) + PC.W += 2; +else { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W); + PC.W = tempRegister.W; + clockTicks++; +} +break; +case 0xc3: +// JP NNNN +tempRegister.B.B0 = gbReadOpcode(PC.W++); +tempRegister.B.B1 = gbReadOpcode(PC.W); +PC.W = tempRegister.W; +break; +case 0xc4: +// CALL NZ,NNNN +if (AF.B.B0 & Z_FLAG) + PC.W += 2; +else { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W++); + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + PC.W = tempRegister.W; + clockTicks += 3; +} +break; +case 0xc5: +// PUSH BC +gbWriteMemory(--SP.W, BC.B.B1); +gbWriteMemory(--SP.W, BC.B.B0); +break; +case 0xc6: +// ADD NN +tempValue = gbReadOpcode(PC.W++); +tempRegister.W = AF.B.B1 + tempValue; +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0xc7: +// RST 00 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0000; +break; +case 0xc8: +// RET Z +if (AF.B.B0 & Z_FLAG) { + PC.B.B0 = gbReadMemory(SP.W++); + PC.B.B1 = gbReadMemory(SP.W++); + clockTicks += 3; +} +break; +case 0xc9: +// RET +PC.B.B0 = gbReadMemory(SP.W++); +PC.B.B1 = gbReadMemory(SP.W++); +break; +case 0xca: +// JP Z,NNNN +if (AF.B.B0 & Z_FLAG) { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W); + PC.W = tempRegister.W; + clockTicks++; +} else + PC.W += 2; +break; +// CB done outside +case 0xcc: +// CALL Z,NNNN +if (AF.B.B0 & Z_FLAG) { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W++); + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + PC.W = tempRegister.W; + clockTicks += 3; +} else + PC.W += 2; +break; +case 0xcd: +// CALL NNNN +tempRegister.B.B0 = gbReadOpcode(PC.W++); +tempRegister.B.B1 = gbReadOpcode(PC.W++); +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = tempRegister.W; +break; +case 0xce: +// ADC NN +tempValue = gbReadOpcode(PC.W++); +tempRegister.W = AF.B.B1 + tempValue + (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0xcf: +// RST 08 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0008; +break; +case 0xd0: +// RET NC +if (!(AF.B.B0 & C_FLAG)) { + PC.B.B0 = gbReadMemory(SP.W++); + PC.B.B1 = gbReadMemory(SP.W++); + clockTicks += 3; +} +break; +case 0xd1: +// POP DE +DE.B.B0 = gbReadMemory(SP.W++); +DE.B.B1 = gbReadMemory(SP.W++); +break; +case 0xd2: +// JP NC,NNNN +if (AF.B.B0 & C_FLAG) + PC.W += 2; +else { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W); + PC.W = tempRegister.W; + clockTicks++; +} +break; +// D3 illegal +case 0xd3: +PC.W--; +IFF = 0; +break; +case 0xd4: +// CALL NC,NNNN +if (AF.B.B0 & C_FLAG) + PC.W += 2; +else { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W++); + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + PC.W = tempRegister.W; + clockTicks += 3; +} +break; +case 0xd5: +// PUSH DE +gbWriteMemory(--SP.W, DE.B.B1); +gbWriteMemory(--SP.W, DE.B.B0); +break; +case 0xd6: +// SUB NN +tempValue = gbReadOpcode(PC.W++); +tempRegister.W = AF.B.B1 - tempValue; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0xd7: +// RST 10 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0010; +break; +case 0xd8: +// RET C +if (AF.B.B0 & C_FLAG) { + PC.B.B0 = gbReadMemory(SP.W++); + PC.B.B1 = gbReadMemory(SP.W++); + clockTicks += 3; +} +break; +case 0xd9: +// RETI +PC.B.B0 = gbReadMemory(SP.W++); +PC.B.B1 = gbReadMemory(SP.W++); +IFF |= 0x01; +break; +case 0xda: +// JP C,NNNN +if (AF.B.B0 & C_FLAG) { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W); + PC.W = tempRegister.W; + clockTicks++; +} else + PC.W += 2; +break; +// DB illegal +case 0xdb: +PC.W--; +IFF = 0; +break; +case 0xdc: +// CALL C,NNNN +if (AF.B.B0 & C_FLAG) { + tempRegister.B.B0 = gbReadOpcode(PC.W++); + tempRegister.B.B1 = gbReadOpcode(PC.W++); + gbWriteMemory(--SP.W, PC.B.B1); + gbWriteMemory(--SP.W, PC.B.B0); + PC.W = tempRegister.W; + clockTicks += 3; +} else + PC.W += 2; +break; +// DD illegal +case 0xdd: +PC.W--; +IFF = 0; +break; +case 0xde: +// SBC NN +tempValue = gbReadOpcode(PC.W++); +tempRegister.W = AF.B.B1 - tempValue - (AF.B.B0 & C_FLAG ? 1 : 0); +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +AF.B.B1 = tempRegister.B.B0; +break; +case 0xdf: +// RST 18 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0018; +break; +case 0xe0: +// LD (FF00+NN),A +gbWriteMemory(0xff00 + gbReadOpcode(PC.W++), AF.B.B1); +break; +case 0xe1: +// POP HL +HL.B.B0 = gbReadMemory(SP.W++); +HL.B.B1 = gbReadMemory(SP.W++); +break; +case 0xe2: +// LD (FF00+C),A +gbWriteMemory(0xff00 + BC.B.B0, AF.B.B1); +break; +// E3 illegal +// E4 illegal +case 0xe3: +case 0xe4: +PC.W--; +IFF = 0; +break; +case 0xe5: +// PUSH HL +gbWriteMemory(--SP.W, HL.B.B1); +gbWriteMemory(--SP.W, HL.B.B0); +break; +case 0xe6: +// AND NN +tempValue = gbReadOpcode(PC.W++); +AF.B.B1 &= tempValue; +AF.B.B0 = H_FLAG | ZeroTable[AF.B.B1]; +break; +case 0xe7: +// RST 20 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0020; +break; +case 0xe8: +// ADD SP,NN +offset = (s8)gbReadOpcode(PC.W++); +tempRegister.W = SP.W + offset; +AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? C_FLAG : 0) | + ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? H_FLAG : 0); +SP.W = tempRegister.W; +break; +case 0xe9: +// LD PC,HL +PC.W = HL.W; +break; +case 0xea: +// LD (NNNN),A +tempRegister.B.B0 = gbReadOpcode(PC.W++); +tempRegister.B.B1 = gbReadOpcode(PC.W++); +gbWriteMemory(tempRegister.W, AF.B.B1); +break; +// EB illegal +// EC illegal +// ED illegal +case 0xeb: +case 0xec: +case 0xed: +PC.W--; +IFF = 0; +break; +case 0xee: +// XOR NN +tempValue = gbReadOpcode(PC.W++); +AF.B.B1 ^= tempValue; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xef: +// RST 28 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0028; +break; +case 0xf0: +// LD A,(FF00+NN) +AF.B.B1 = gbReadMemory(0xff00 + gbReadOpcode(PC.W++)); +break; +case 0xf1: +// POP AF +AF.B.B0 = gbReadMemory(SP.W++) & 0xF0; +AF.B.B1 = gbReadMemory(SP.W++); +break; +case 0xf2: +// LD A,(FF00+C) +AF.B.B1 = gbReadMemory(0xff00 + BC.B.B0); +break; +case 0xf3: +// DI +// IFF&=0xFE; +IFF |= 0x08; +break; +// F4 illegal +case 0xf4: +PC.W--; +IFF = 0; +break; +case 0xf5: +// PUSH AF +gbWriteMemory(--SP.W, AF.B.B1); +gbWriteMemory(--SP.W, AF.B.B0); +break; +case 0xf6: +// OR NN +tempValue = gbReadOpcode(PC.W++); +AF.B.B1 |= tempValue; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0xf7: +// RST 30 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0030; +break; +case 0xf8: +// LD HL,SP+NN +offset = (s8)gbReadOpcode(PC.W++); +tempRegister.W = SP.W + offset; +AF.B.B0 = ((SP.W ^ offset ^ tempRegister.W) & 0x100 ? C_FLAG : 0) | + ((SP.W ^ offset ^ tempRegister.W) & 0x10 ? H_FLAG : 0); +HL.W = tempRegister.W; +break; +case 0xf9: +// LD SP,HL +SP.W = HL.W; +break; +case 0xfa: +// LD A,(NNNN) +tempRegister.B.B0 = gbReadOpcode(PC.W++); +tempRegister.B.B1 = gbReadOpcode(PC.W++); +AF.B.B1 = gbReadMemory(tempRegister.W); +break; +case 0xfb: +// EI +if (!(IFF & 0x30)) + // If an EI is executed right before HALT, + // the interrupts are triggered before the Halt state !! + // Fix Torpedo Range Intro. + // IFF |= 0x10 : 1 ticks before the EI enables the interrupts + // IFF |= 0x40 : marks that an EI is being executed. + IFF |= 0x50; +break; +// FC illegal (FC = breakpoint) +case 0xfc: +breakpoint = true; +break; +// FD illegal +case 0xfd: +PC.W--; +IFF = 0; +break; +case 0xfe: +// CP NN +tempValue = gbReadOpcode(PC.W++); +tempRegister.W = AF.B.B1 - tempValue; +AF.B.B0 = N_FLAG | (tempRegister.B.B1 ? C_FLAG : 0) | ZeroTable[tempRegister.B.B0] | + ((AF.B.B1 ^ tempValue ^ tempRegister.B.B0) & 0x10 ? H_FLAG : 0); +break; +case 0xff: +// RST 38 +gbWriteMemory(--SP.W, PC.B.B1); +gbWriteMemory(--SP.W, PC.B.B0); +PC.W = 0x0038; +break; +default: +if (gbSystemMessage == false) { + systemMessage(0, N_("Unknown opcode %02x at %04x"), gbReadOpcode(PC.W - 1), PC.W - 1); + gbSystemMessage = true; +} +return; diff --git a/src/gb/gbCodesCB.h b/src/gb/gbCodesCB.h index 880fe5e4..02ff0561 100644 --- a/src/gb/gbCodesCB.h +++ b/src/gb/gbCodesCB.h @@ -1,1272 +1,1270 @@ - case 0x00: - // RLC B - AF.B.B0 = (BC.B.B1 & 0x80)?C_FLAG:0; - BC.B.B1 = (BC.B.B1<<1) | (BC.B.B1>>7); - AF.B.B0 |= ZeroTable[BC.B.B1]; - break; - case 0x01: - // RLC C - AF.B.B0 = (BC.B.B0 & 0x80)?C_FLAG:0; - BC.B.B0 = (BC.B.B0<<1) | (BC.B.B0>>7); - AF.B.B0 |= ZeroTable[BC.B.B0]; - break; - case 0x02: - // RLC D - AF.B.B0 = (DE.B.B1 & 0x80)?C_FLAG:0; - DE.B.B1 = (DE.B.B1<<1) | (DE.B.B1>>7); - AF.B.B0 |= ZeroTable[DE.B.B1]; - break; - case 0x03: - // RLC E - AF.B.B0 = (DE.B.B0 & 0x80)?C_FLAG:0; - DE.B.B0 = (DE.B.B0<<1) | (DE.B.B0>>7); - AF.B.B0 |= ZeroTable[DE.B.B0]; - break; - case 0x04: - // RLC H - AF.B.B0 = (HL.B.B1 & 0x80)?C_FLAG:0; - HL.B.B1 = (HL.B.B1<<1) | (HL.B.B1>>7); - AF.B.B0 |= ZeroTable[HL.B.B1]; - break; - case 0x05: - // RLC L - AF.B.B0 = (HL.B.B0 & 0x80)?C_FLAG:0; - HL.B.B0 = (HL.B.B0<<1) | (HL.B.B0>>7); - AF.B.B0 |= ZeroTable[HL.B.B0]; - break; - case 0x06: - // RLC (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0 = (tempValue & 0x80)?C_FLAG:0; - tempValue = (tempValue<<1) | (tempValue>>7); - AF.B.B0 |= ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x07: - // RLC A - AF.B.B0 = (AF.B.B1 & 0x80)?C_FLAG:0; - AF.B.B1 = (AF.B.B1<<1) | (AF.B.B1>>7); - AF.B.B0 |= ZeroTable[AF.B.B1]; - break; - case 0x08: - // RRC B - AF.B.B0=(BC.B.B1&0x01 ? C_FLAG : 0); - BC.B.B1=(BC.B.B1>>1)|(BC.B.B1<<7); - AF.B.B0|=ZeroTable[BC.B.B1]; - break; - case 0x09: - // RRC C - AF.B.B0=(BC.B.B0&0x01 ? C_FLAG : 0); - BC.B.B0=(BC.B.B0>>1)|(BC.B.B0<<7); - AF.B.B0|=ZeroTable[BC.B.B0]; - break; - case 0x0a: - // RRC D - AF.B.B0=(DE.B.B1&0x01 ? C_FLAG : 0); - DE.B.B1=(DE.B.B1>>1)|(DE.B.B1<<7); - AF.B.B0|=ZeroTable[DE.B.B1]; - break; - case 0x0b: - // RRC E - AF.B.B0=(DE.B.B0&0x01 ? C_FLAG : 0); - DE.B.B0=(DE.B.B0>>1)|(DE.B.B0<<7); - AF.B.B0|=ZeroTable[DE.B.B0]; - break; - case 0x0c: - // RRC H - AF.B.B0=(HL.B.B1&0x01 ? C_FLAG : 0); - HL.B.B1=(HL.B.B1>>1)|(HL.B.B1<<7); - AF.B.B0|=ZeroTable[HL.B.B1]; - break; - case 0x0d: - // RRC L - AF.B.B0=(HL.B.B0&0x01 ? C_FLAG : 0); - HL.B.B0=(HL.B.B0>>1)|(HL.B.B0<<7); - AF.B.B0|=ZeroTable[HL.B.B0]; - break; - case 0x0e: - // RRC (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(tempValue&0x01 ? C_FLAG : 0); - tempValue=(tempValue>>1)|(tempValue<<7); - AF.B.B0|=ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x0f: - // RRC A - AF.B.B0=(AF.B.B1&0x01 ? C_FLAG : 0); - AF.B.B1=(AF.B.B1>>1)|(AF.B.B1<<7); - AF.B.B0|=ZeroTable[AF.B.B1]; - break; - case 0x10: - // RL B - if(BC.B.B1&0x80) { - BC.B.B1=(BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG; - } else { - BC.B.B1=(BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[BC.B.B1]; - } - break; - case 0x11: - // RL C - if(BC.B.B0&0x80) { - BC.B.B0=(BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG; - } else { - BC.B.B0=(BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[BC.B.B0]; - } - break; - case 0x12: - // RL D - if(DE.B.B1&0x80) { - DE.B.B1=(DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG; - } else { - DE.B.B1=(DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[DE.B.B1]; - } - break; - case 0x13: - // RL E - if(DE.B.B0&0x80) { - DE.B.B0=(DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG; - } else { - DE.B.B0=(DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[DE.B.B0]; - } - break; - case 0x14: - // RL H - if(HL.B.B1&0x80) { - HL.B.B1=(HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG; - } else { - HL.B.B1=(HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[HL.B.B1]; - } - break; - case 0x15: - // RL L - if(HL.B.B0&0x80) { - HL.B.B0=(HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG; - } else { - HL.B.B0=(HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[HL.B.B0]; - } - break; - case 0x16: - // RL (HL) - tempValue=gbReadMemory(HL.W); - if(tempValue&0x80) { - tempValue=(tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[tempValue]|C_FLAG; - } else { - tempValue=(tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[tempValue]; - } - gbWriteMemory(HL.W,tempValue); - break; - case 0x17: - // RL A - if(AF.B.B1&0x80) { - AF.B.B1=(AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG; - } else { - AF.B.B1=(AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0); - AF.B.B0=ZeroTable[AF.B.B1]; - } - break; - case 0x18: - // RR B - if(BC.B.B1&0x01) { - BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG; - } else { - BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[BC.B.B1]; - } - break; - case 0x19: - // RR C - if(BC.B.B0&0x01) { - BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG; - } else { - BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[BC.B.B0]; - } - break; - case 0x1a: - // RR D - if(DE.B.B1&0x01) { - DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG; - } else { - DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[DE.B.B1]; - } - break; - case 0x1b: - // RR E - if(DE.B.B0&0x01) { - DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG; - } else { - DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[DE.B.B0]; - } - break; - case 0x1c: - // RR H - if(HL.B.B1&0x01) { - HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG; - } else { - HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[HL.B.B1]; - } - break; - case 0x1d: - // RR L - if(HL.B.B0&0x01) { - HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG; - } else { - HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[HL.B.B0]; - } - break; - case 0x1e: - // RR (HL) - tempValue=gbReadMemory(HL.W); - if(tempValue&0x01) { - tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[tempValue]|C_FLAG; - } else { - tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[tempValue]; - } - gbWriteMemory(HL.W,tempValue); - break; - case 0x1f: - // RR A - if(AF.B.B1&0x01) { - AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG; - } else { - AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0); - AF.B.B0=ZeroTable[AF.B.B1]; - } - break; - case 0x20: - // SLA B - AF.B.B0=(BC.B.B1&0x80?C_FLAG : 0); - BC.B.B1<<=1; - AF.B.B0|=ZeroTable[BC.B.B1]; - break; - case 0x21: - // SLA C - AF.B.B0=(BC.B.B0&0x80?C_FLAG : 0); - BC.B.B0<<=1; - AF.B.B0|=ZeroTable[BC.B.B0]; - break; - case 0x22: - // SLA D - AF.B.B0=(DE.B.B1&0x80?C_FLAG : 0); - DE.B.B1<<=1; - AF.B.B0|=ZeroTable[DE.B.B1]; - break; - case 0x23: - // SLA E - AF.B.B0=(DE.B.B0&0x80?C_FLAG : 0); - DE.B.B0<<=1; - AF.B.B0|=ZeroTable[DE.B.B0]; - break; - case 0x24: - // SLA H - AF.B.B0=(HL.B.B1&0x80?C_FLAG : 0); - HL.B.B1<<=1; - AF.B.B0|=ZeroTable[HL.B.B1]; - break; - case 0x25: - // SLA L - AF.B.B0=(HL.B.B0&0x80?C_FLAG : 0); - HL.B.B0<<=1; - AF.B.B0|=ZeroTable[HL.B.B0]; - break; - case 0x26: - // SLA (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(tempValue&0x80?C_FLAG : 0); - tempValue<<=1; - AF.B.B0|=ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x27: - // SLA A - AF.B.B0=(AF.B.B1&0x80?C_FLAG : 0); - AF.B.B1<<=1; - AF.B.B0|=ZeroTable[AF.B.B1]; - break; - case 0x28: - // SRA B - AF.B.B0=(BC.B.B1&0x01 ? C_FLAG: 0); - BC.B.B1=(BC.B.B1>>1)|(BC.B.B1&0x80); - AF.B.B0|=ZeroTable[BC.B.B1]; - break; - case 0x29: - // SRA C - AF.B.B0=(BC.B.B0&0x01 ? C_FLAG: 0); - BC.B.B0=(BC.B.B0>>1)|(BC.B.B0&0x80); - AF.B.B0|=ZeroTable[BC.B.B0]; - break; - case 0x2a: - // SRA D - AF.B.B0=(DE.B.B1&0x01 ? C_FLAG: 0); - DE.B.B1=(DE.B.B1>>1)|(DE.B.B1&0x80); - AF.B.B0|=ZeroTable[DE.B.B1]; - break; - case 0x2b: - // SRA E - AF.B.B0=(DE.B.B0&0x01 ? C_FLAG: 0); - DE.B.B0=(DE.B.B0>>1)|(DE.B.B0&0x80); - AF.B.B0|=ZeroTable[DE.B.B0]; - break; - case 0x2c: - // SRA H - AF.B.B0=(HL.B.B1&0x01 ? C_FLAG: 0); - HL.B.B1=(HL.B.B1>>1)|(HL.B.B1&0x80); - AF.B.B0|=ZeroTable[HL.B.B1]; - break; - case 0x2d: - // SRA L - AF.B.B0=(HL.B.B0&0x01 ? C_FLAG: 0); - HL.B.B0=(HL.B.B0>>1)|(HL.B.B0&0x80); - AF.B.B0|=ZeroTable[HL.B.B0]; - break; - case 0x2e: - // SRA (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(tempValue&0x01 ? C_FLAG: 0); - tempValue=(tempValue>>1)|(tempValue&0x80); - AF.B.B0|=ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x2f: - // SRA A - AF.B.B0=(AF.B.B1&0x01 ? C_FLAG: 0); - AF.B.B1=(AF.B.B1>>1)|(AF.B.B1&0x80); - AF.B.B0|=ZeroTable[AF.B.B1]; - break; - case 0x30: - // SWAP B - BC.B.B1 = (BC.B.B1&0xf0)>>4 | (BC.B.B1&0x0f)<<4; - AF.B.B0 = ZeroTable[BC.B.B1]; - break; - case 0x31: - // SWAP C - BC.B.B0 = (BC.B.B0&0xf0)>>4 | (BC.B.B0&0x0f)<<4; - AF.B.B0 = ZeroTable[BC.B.B0]; - break; - case 0x32: - // SWAP D - DE.B.B1 = (DE.B.B1&0xf0)>>4 | (DE.B.B1&0x0f)<<4; - AF.B.B0 = ZeroTable[DE.B.B1]; - break; - case 0x33: - // SWAP E - DE.B.B0 = (DE.B.B0&0xf0)>>4 | (DE.B.B0&0x0f)<<4; - AF.B.B0 = ZeroTable[DE.B.B0]; - break; - case 0x34: - // SWAP H - HL.B.B1 = (HL.B.B1&0xf0)>>4 | (HL.B.B1&0x0f)<<4; - AF.B.B0 = ZeroTable[HL.B.B1]; - break; - case 0x35: - // SWAP L - HL.B.B0 = (HL.B.B0&0xf0)>>4 | (HL.B.B0&0x0f)<<4; - AF.B.B0 = ZeroTable[HL.B.B0]; - break; - case 0x36: - // SWAP (HL) - tempValue=gbReadMemory(HL.W); - tempValue = (tempValue&0xf0)>>4 | (tempValue&0x0f)<<4; - AF.B.B0 = ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x37: - // SWAP A - AF.B.B1 = (AF.B.B1&0xf0)>>4 | (AF.B.B1&0x0f)<<4; - AF.B.B0 = ZeroTable[AF.B.B1]; - break; - case 0x38: - // SRL B - AF.B.B0=(BC.B.B1&0x01)?C_FLAG:0; - BC.B.B1>>=1; - AF.B.B0|=ZeroTable[BC.B.B1]; - break; - case 0x39: - // SRL C - AF.B.B0=(BC.B.B0&0x01)?C_FLAG:0; - BC.B.B0>>=1; - AF.B.B0|=ZeroTable[BC.B.B0]; - break; - case 0x3a: - // SRL D - AF.B.B0=(DE.B.B1&0x01)?C_FLAG:0; - DE.B.B1>>=1; - AF.B.B0|=ZeroTable[DE.B.B1]; - break; - case 0x3b: - // SRL E - AF.B.B0=(DE.B.B0&0x01)?C_FLAG:0; - DE.B.B0>>=1; - AF.B.B0|=ZeroTable[DE.B.B0]; - break; - case 0x3c: - // SRL H - AF.B.B0=(HL.B.B1&0x01)?C_FLAG:0; - HL.B.B1>>=1; - AF.B.B0|=ZeroTable[HL.B.B1]; - break; - case 0x3d: - // SRL L - AF.B.B0=(HL.B.B0&0x01)?C_FLAG:0; - HL.B.B0>>=1; - AF.B.B0|=ZeroTable[HL.B.B0]; - break; - case 0x3e: - // SRL (HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(tempValue&0x01)?C_FLAG:0; - tempValue>>=1; - AF.B.B0|=ZeroTable[tempValue]; - gbWriteMemory(HL.W,tempValue); - break; - case 0x3f: - // SRL A - AF.B.B0=(AF.B.B1&0x01)?C_FLAG:0; - AF.B.B1>>=1; - AF.B.B0|=ZeroTable[AF.B.B1]; - break; - case 0x40: - // BIT 0,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<0)? 0:Z_FLAG); - break; - case 0x41: - // BIT 0,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<0)? 0:Z_FLAG); - break; - case 0x42: - // BIT 0,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<0)? 0:Z_FLAG); - break; - case 0x43: - // BIT 0,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<0)? 0:Z_FLAG); - break; - case 0x44: - // BIT 0,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<0)? 0:Z_FLAG); - break; - case 0x45: - // BIT 0,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<0)? 0:Z_FLAG); - break; - case 0x46: - // BIT 0,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<0)? 0:Z_FLAG); - break; - case 0x47: - // BIT 0,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<0)? 0:Z_FLAG); - break; - case 0x48: - // BIT 1,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<1)? 0:Z_FLAG); - break; - case 0x49: - // BIT 1,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<1)? 0:Z_FLAG); - break; - case 0x4a: - // BIT 1,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<1)? 0:Z_FLAG); - break; - case 0x4b: - // BIT 1,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<1)? 0:Z_FLAG); - break; - case 0x4c: - // BIT 1,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<1)? 0:Z_FLAG); - break; - case 0x4d: - // BIT 1,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<1)? 0:Z_FLAG); - break; - case 0x4e: - // BIT 1,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<1)? 0:Z_FLAG); - break; - case 0x4f: - // BIT 1,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<1)? 0:Z_FLAG); - break; - case 0x50: - // BIT 2,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<2)? 0:Z_FLAG); - break; - case 0x51: - // BIT 2,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<2)? 0:Z_FLAG); - break; - case 0x52: - // BIT 2,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<2)? 0:Z_FLAG); - break; - case 0x53: - // BIT 2,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<2)? 0:Z_FLAG); - break; - case 0x54: - // BIT 2,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<2)? 0:Z_FLAG); - break; - case 0x55: - // BIT 2,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<2)? 0:Z_FLAG); - break; - case 0x56: - // BIT 2,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<2)? 0:Z_FLAG); - break; - case 0x57: - // BIT 2,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<2)? 0:Z_FLAG); - break; - case 0x58: - // BIT 3,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<3)? 0:Z_FLAG); - break; - case 0x59: - // BIT 3,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<3)? 0:Z_FLAG); - break; - case 0x5a: - // BIT 3,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<3)? 0:Z_FLAG); - break; - case 0x5b: - // BIT 3,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<3)? 0:Z_FLAG); - break; - case 0x5c: - // BIT 3,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<3)? 0:Z_FLAG); - break; - case 0x5d: - // BIT 3,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<3)? 0:Z_FLAG); - break; - case 0x5e: - // BIT 3,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<3)? 0:Z_FLAG); - break; - case 0x5f: - // BIT 3,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<3)? 0:Z_FLAG); - break; - case 0x60: - // BIT 4,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<4)? 0:Z_FLAG); - break; - case 0x61: - // BIT 4,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<4)? 0:Z_FLAG); - break; - case 0x62: - // BIT 4,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<4)? 0:Z_FLAG); - break; - case 0x63: - // BIT 4,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<4)? 0:Z_FLAG); - break; - case 0x64: - // BIT 4,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<4)? 0:Z_FLAG); - break; - case 0x65: - // BIT 4,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<4)? 0:Z_FLAG); - break; - case 0x66: - // BIT 4,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<4)? 0:Z_FLAG); - break; - case 0x67: - // BIT 4,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<4)? 0:Z_FLAG); - break; - case 0x68: - // BIT 5,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<5)? 0:Z_FLAG); - break; - case 0x69: - // BIT 5,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<5)? 0:Z_FLAG); - break; - case 0x6a: - // BIT 5,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<5)? 0:Z_FLAG); - break; - case 0x6b: - // BIT 5,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<5)? 0:Z_FLAG); - break; - case 0x6c: - // BIT 5,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<5)? 0:Z_FLAG); - break; - case 0x6d: - // BIT 5,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<5)? 0:Z_FLAG); - break; - case 0x6e: - // BIT 5,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<5)? 0:Z_FLAG); - break; - case 0x6f: - // BIT 5,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<5)? 0:Z_FLAG); - break; - case 0x70: - // BIT 6,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<6)? 0:Z_FLAG); - break; - case 0x71: - // BIT 6,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<6)? 0:Z_FLAG); - break; - case 0x72: - // BIT 6,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<6)? 0:Z_FLAG); - break; - case 0x73: - // BIT 6,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<6)? 0:Z_FLAG); - break; - case 0x74: - // BIT 6,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<6)? 0:Z_FLAG); - break; - case 0x75: - // BIT 6,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<6)? 0:Z_FLAG); - break; - case 0x76: - // BIT 6,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<6)? 0:Z_FLAG); - break; - case 0x77: - // BIT 6,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<6)? 0:Z_FLAG); - break; - case 0x78: - // BIT 7,B - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<7)? 0:Z_FLAG); - break; - case 0x79: - // BIT 7,C - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<7)? 0:Z_FLAG); - break; - case 0x7a: - // BIT 7,D - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<7)? 0:Z_FLAG); - break; - case 0x7b: - // BIT 7,E - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<7)? 0:Z_FLAG); - break; - case 0x7c: - // BIT 7,H - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<7)? 0:Z_FLAG); - break; - case 0x7d: - // BIT 7,L - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<7)? 0:Z_FLAG); - break; - case 0x7e: - // BIT 7,(HL) - tempValue=gbReadMemory(HL.W); - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<7)? 0:Z_FLAG); - break; - case 0x7f: - // BIT 7,A - AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<7)? 0:Z_FLAG); - break; - case 0x80: - // RES 0,B - BC.B.B1&=~(1<<0); - break; - case 0x81: - // RES 0,C - BC.B.B0&=~(1<<0); - break; - case 0x82: - // RES 0,D - DE.B.B1&=~(1<<0); - break; - case 0x83: - // RES 0,E - DE.B.B0&=~(1<<0); - break; - case 0x84: - // RES 0,H - HL.B.B1&=~(1<<0); - break; - case 0x85: - // RES 0,L - HL.B.B0&=~(1<<0); - break; - case 0x86: - // RES 0,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<0); - gbWriteMemory(HL.W,tempValue); - break; - case 0x87: - // RES 0,A - AF.B.B1&=~(1<<0); - break; - case 0x88: - // RES 1,B - BC.B.B1&=~(1<<1); - break; - case 0x89: - // RES 1,C - BC.B.B0&=~(1<<1); - break; - case 0x8a: - // RES 1,D - DE.B.B1&=~(1<<1); - break; - case 0x8b: - // RES 1,E - DE.B.B0&=~(1<<1); - break; - case 0x8c: - // RES 1,H - HL.B.B1&=~(1<<1); - break; - case 0x8d: - // RES 1,L - HL.B.B0&=~(1<<1); - break; - case 0x8e: - // RES 1,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<1); - gbWriteMemory(HL.W,tempValue); - break; - case 0x8f: - // RES 1,A - AF.B.B1&=~(1<<1); - break; - case 0x90: - // RES 2,B - BC.B.B1&=~(1<<2); - break; - case 0x91: - // RES 2,C - BC.B.B0&=~(1<<2); - break; - case 0x92: - // RES 2,D - DE.B.B1&=~(1<<2); - break; - case 0x93: - // RES 2,E - DE.B.B0&=~(1<<2); - break; - case 0x94: - // RES 2,H - HL.B.B1&=~(1<<2); - break; - case 0x95: - // RES 2,L - HL.B.B0&=~(1<<2); - break; - case 0x96: - // RES 2,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<2); - gbWriteMemory(HL.W,tempValue); - break; - case 0x97: - // RES 2,A - AF.B.B1&=~(1<<2); - break; - case 0x98: - // RES 3,B - BC.B.B1&=~(1<<3); - break; - case 0x99: - // RES 3,C - BC.B.B0&=~(1<<3); - break; - case 0x9a: - // RES 3,D - DE.B.B1&=~(1<<3); - break; - case 0x9b: - // RES 3,E - DE.B.B0&=~(1<<3); - break; - case 0x9c: - // RES 3,H - HL.B.B1&=~(1<<3); - break; - case 0x9d: - // RES 3,L - HL.B.B0&=~(1<<3); - break; - case 0x9e: - // RES 3,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<3); - gbWriteMemory(HL.W,tempValue); - break; - case 0x9f: - // RES 3,A - AF.B.B1&=~(1<<3); - break; - case 0xa0: - // RES 4,B - BC.B.B1&=~(1<<4); - break; - case 0xa1: - // RES 4,C - BC.B.B0&=~(1<<4); - break; - case 0xa2: - // RES 4,D - DE.B.B1&=~(1<<4); - break; - case 0xa3: - // RES 4,E - DE.B.B0&=~(1<<4); - break; - case 0xa4: - // RES 4,H - HL.B.B1&=~(1<<4); - break; - case 0xa5: - // RES 4,L - HL.B.B0&=~(1<<4); - break; - case 0xa6: - // RES 4,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<4); - gbWriteMemory(HL.W,tempValue); - break; - case 0xa7: - // RES 4,A - AF.B.B1&=~(1<<4); - break; - case 0xa8: - // RES 5,B - BC.B.B1&=~(1<<5); - break; - case 0xa9: - // RES 5,C - BC.B.B0&=~(1<<5); - break; - case 0xaa: - // RES 5,D - DE.B.B1&=~(1<<5); - break; - case 0xab: - // RES 5,E - DE.B.B0&=~(1<<5); - break; - case 0xac: - // RES 5,H - HL.B.B1&=~(1<<5); - break; - case 0xad: - // RES 5,L - HL.B.B0&=~(1<<5); - break; - case 0xae: - // RES 5,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<5); - gbWriteMemory(HL.W,tempValue); - break; - case 0xaf: - // RES 5,A - AF.B.B1&=~(1<<5); - break; - case 0xb0: - // RES 6,B - BC.B.B1&=~(1<<6); - break; - case 0xb1: - // RES 6,C - BC.B.B0&=~(1<<6); - break; - case 0xb2: - // RES 6,D - DE.B.B1&=~(1<<6); - break; - case 0xb3: - // RES 6,E - DE.B.B0&=~(1<<6); - break; - case 0xb4: - // RES 6,H - HL.B.B1&=~(1<<6); - break; - case 0xb5: - // RES 6,L - HL.B.B0&=~(1<<6); - break; - case 0xb6: - // RES 6,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<6); - gbWriteMemory(HL.W,tempValue); - break; - case 0xb7: - // RES 6,A - AF.B.B1&=~(1<<6); - break; - case 0xb8: - // RES 7,B - BC.B.B1&=~(1<<7); - break; - case 0xb9: - // RES 7,C - BC.B.B0&=~(1<<7); - break; - case 0xba: - // RES 7,D - DE.B.B1&=~(1<<7); - break; - case 0xbb: - // RES 7,E - DE.B.B0&=~(1<<7); - break; - case 0xbc: - // RES 7,H - HL.B.B1&=~(1<<7); - break; - case 0xbd: - // RES 7,L - HL.B.B0&=~(1<<7); - break; - case 0xbe: - // RES 7,(HL) - tempValue=gbReadMemory(HL.W); - tempValue&=~(1<<7); - gbWriteMemory(HL.W,tempValue); - break; - case 0xbf: - // RES 7,A - AF.B.B1&=~(1<<7); - break; - case 0xc0: - // SET 0,B - BC.B.B1|=1<<0; - break; - case 0xc1: - // SET 0,C - BC.B.B0|=1<<0; - break; - case 0xc2: - // SET 0,D - DE.B.B1|=1<<0; - break; - case 0xc3: - // SET 0,E - DE.B.B0|=1<<0; - break; - case 0xc4: - // SET 0,H - HL.B.B1|=1<<0; - break; - case 0xc5: - // SET 0,L - HL.B.B0|=1<<0; - break; - case 0xc6: - // SET 0,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<0; - gbWriteMemory(HL.W,tempValue); - break; - case 0xc7: - // SET 0,A - AF.B.B1|=1<<0; - break; - case 0xc8: - // SET 1,B - BC.B.B1|=1<<1; - break; - case 0xc9: - // SET 1,C - BC.B.B0|=1<<1; - break; - case 0xca: - // SET 1,D - DE.B.B1|=1<<1; - break; - case 0xcb: - // SET 1,E - DE.B.B0|=1<<1; - break; - case 0xcc: - // SET 1,H - HL.B.B1|=1<<1; - break; - case 0xcd: - // SET 1,L - HL.B.B0|=1<<1; - break; - case 0xce: - // SET 1,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<1; - gbWriteMemory(HL.W,tempValue); - break; - case 0xcf: - // SET 1,A - AF.B.B1|=1<<1; - break; - case 0xd0: - // SET 2,B - BC.B.B1|=1<<2; - break; - case 0xd1: - // SET 2,C - BC.B.B0|=1<<2; - break; - case 0xd2: - // SET 2,D - DE.B.B1|=1<<2; - break; - case 0xd3: - // SET 2,E - DE.B.B0|=1<<2; - break; - case 0xd4: - // SET 2,H - HL.B.B1|=1<<2; - break; - case 0xd5: - // SET 2,L - HL.B.B0|=1<<2; - break; - case 0xd6: - // SET 2,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<2; - gbWriteMemory(HL.W,tempValue); - break; - case 0xd7: - // SET 2,A - AF.B.B1|=1<<2; - break; - case 0xd8: - // SET 3,B - BC.B.B1|=1<<3; - break; - case 0xd9: - // SET 3,C - BC.B.B0|=1<<3; - break; - case 0xda: - // SET 3,D - DE.B.B1|=1<<3; - break; - case 0xdb: - // SET 3,E - DE.B.B0|=1<<3; - break; - case 0xdc: - // SET 3,H - HL.B.B1|=1<<3; - break; - case 0xdd: - // SET 3,L - HL.B.B0|=1<<3; - break; - case 0xde: - // SET 3,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<3; - gbWriteMemory(HL.W,tempValue); - break; - case 0xdf: - // SET 3,A - AF.B.B1|=1<<3; - break; - case 0xe0: - // SET 4,B - BC.B.B1|=1<<4; - break; - case 0xe1: - // SET 4,C - BC.B.B0|=1<<4; - break; - case 0xe2: - // SET 4,D - DE.B.B1|=1<<4; - break; - case 0xe3: - // SET 4,E - DE.B.B0|=1<<4; - break; - case 0xe4: - // SET 4,H - HL.B.B1|=1<<4; - break; - case 0xe5: - // SET 4,L - HL.B.B0|=1<<4; - break; - case 0xe6: - // SET 4,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<4; - gbWriteMemory(HL.W,tempValue); - break; - case 0xe7: - // SET 4,A - AF.B.B1|=1<<4; - break; - case 0xe8: - // SET 5,B - BC.B.B1|=1<<5; - break; - case 0xe9: - // SET 5,C - BC.B.B0|=1<<5; - break; - case 0xea: - // SET 5,D - DE.B.B1|=1<<5; - break; - case 0xeb: - // SET 5,E - DE.B.B0|=1<<5; - break; - case 0xec: - // SET 5,H - HL.B.B1|=1<<5; - break; - case 0xed: - // SET 5,L - HL.B.B0|=1<<5; - break; - case 0xee: - // SET 5,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<5; - gbWriteMemory(HL.W,tempValue); - break; - case 0xef: - // SET 5,A - AF.B.B1|=1<<5; - break; - case 0xf0: - // SET 6,B - BC.B.B1|=1<<6; - break; - case 0xf1: - // SET 6,C - BC.B.B0|=1<<6; - break; - case 0xf2: - // SET 6,D - DE.B.B1|=1<<6; - break; - case 0xf3: - // SET 6,E - DE.B.B0|=1<<6; - break; - case 0xf4: - // SET 6,H - HL.B.B1|=1<<6; - break; - case 0xf5: - // SET 6,L - HL.B.B0|=1<<6; - break; - case 0xf6: - // SET 6,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<6; - gbWriteMemory(HL.W,tempValue); - break; - case 0xf7: - // SET 6,A - AF.B.B1|=1<<6; - break; - case 0xf8: - // SET 7,B - BC.B.B1|=1<<7; - break; - case 0xf9: - // SET 7,C - BC.B.B0|=1<<7; - break; - case 0xfa: - // SET 7,D - DE.B.B1|=1<<7; - break; - case 0xfb: - // SET 7,E - DE.B.B0|=1<<7; - break; - case 0xfc: - // SET 7,H - HL.B.B1|=1<<7; - break; - case 0xfd: - // SET 7,L - HL.B.B0|=1<<7; - break; - case 0xfe: - // SET 7,(HL) - tempValue=gbReadMemory(HL.W); - tempValue|=1<<7; - gbWriteMemory(HL.W,tempValue); - break; - case 0xff: - // SET 7,A - AF.B.B1|=1<<7; - break; - default: - if (gbSystemMessage == false) - { - systemMessage(0, N_("Unknown opcode %02x at %04x"), - gbReadOpcode(PC.W-1),PC.W-1); - gbSystemMessage =true; - } - return; +case 0x00: +// RLC B +AF.B.B0 = (BC.B.B1 & 0x80) ? C_FLAG : 0; +BC.B.B1 = (BC.B.B1 << 1) | (BC.B.B1 >> 7); +AF.B.B0 |= ZeroTable[BC.B.B1]; +break; +case 0x01: +// RLC C +AF.B.B0 = (BC.B.B0 & 0x80) ? C_FLAG : 0; +BC.B.B0 = (BC.B.B0 << 1) | (BC.B.B0 >> 7); +AF.B.B0 |= ZeroTable[BC.B.B0]; +break; +case 0x02: +// RLC D +AF.B.B0 = (DE.B.B1 & 0x80) ? C_FLAG : 0; +DE.B.B1 = (DE.B.B1 << 1) | (DE.B.B1 >> 7); +AF.B.B0 |= ZeroTable[DE.B.B1]; +break; +case 0x03: +// RLC E +AF.B.B0 = (DE.B.B0 & 0x80) ? C_FLAG : 0; +DE.B.B0 = (DE.B.B0 << 1) | (DE.B.B0 >> 7); +AF.B.B0 |= ZeroTable[DE.B.B0]; +break; +case 0x04: +// RLC H +AF.B.B0 = (HL.B.B1 & 0x80) ? C_FLAG : 0; +HL.B.B1 = (HL.B.B1 << 1) | (HL.B.B1 >> 7); +AF.B.B0 |= ZeroTable[HL.B.B1]; +break; +case 0x05: +// RLC L +AF.B.B0 = (HL.B.B0 & 0x80) ? C_FLAG : 0; +HL.B.B0 = (HL.B.B0 << 1) | (HL.B.B0 >> 7); +AF.B.B0 |= ZeroTable[HL.B.B0]; +break; +case 0x06: +// RLC (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (tempValue & 0x80) ? C_FLAG : 0; +tempValue = (tempValue << 1) | (tempValue >> 7); +AF.B.B0 |= ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x07: +// RLC A +AF.B.B0 = (AF.B.B1 & 0x80) ? C_FLAG : 0; +AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B1 >> 7); +AF.B.B0 |= ZeroTable[AF.B.B1]; +break; +case 0x08: +// RRC B +AF.B.B0 = (BC.B.B1 & 0x01 ? C_FLAG : 0); +BC.B.B1 = (BC.B.B1 >> 1) | (BC.B.B1 << 7); +AF.B.B0 |= ZeroTable[BC.B.B1]; +break; +case 0x09: +// RRC C +AF.B.B0 = (BC.B.B0 & 0x01 ? C_FLAG : 0); +BC.B.B0 = (BC.B.B0 >> 1) | (BC.B.B0 << 7); +AF.B.B0 |= ZeroTable[BC.B.B0]; +break; +case 0x0a: +// RRC D +AF.B.B0 = (DE.B.B1 & 0x01 ? C_FLAG : 0); +DE.B.B1 = (DE.B.B1 >> 1) | (DE.B.B1 << 7); +AF.B.B0 |= ZeroTable[DE.B.B1]; +break; +case 0x0b: +// RRC E +AF.B.B0 = (DE.B.B0 & 0x01 ? C_FLAG : 0); +DE.B.B0 = (DE.B.B0 >> 1) | (DE.B.B0 << 7); +AF.B.B0 |= ZeroTable[DE.B.B0]; +break; +case 0x0c: +// RRC H +AF.B.B0 = (HL.B.B1 & 0x01 ? C_FLAG : 0); +HL.B.B1 = (HL.B.B1 >> 1) | (HL.B.B1 << 7); +AF.B.B0 |= ZeroTable[HL.B.B1]; +break; +case 0x0d: +// RRC L +AF.B.B0 = (HL.B.B0 & 0x01 ? C_FLAG : 0); +HL.B.B0 = (HL.B.B0 >> 1) | (HL.B.B0 << 7); +AF.B.B0 |= ZeroTable[HL.B.B0]; +break; +case 0x0e: +// RRC (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (tempValue & 0x01 ? C_FLAG : 0); +tempValue = (tempValue >> 1) | (tempValue << 7); +AF.B.B0 |= ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x0f: +// RRC A +AF.B.B0 = (AF.B.B1 & 0x01 ? C_FLAG : 0); +AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B1 << 7); +AF.B.B0 |= ZeroTable[AF.B.B1]; +break; +case 0x10: +// RL B +if (BC.B.B1 & 0x80) { + BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[BC.B.B1] | C_FLAG; +} else { + BC.B.B1 = (BC.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[BC.B.B1]; +} +break; +case 0x11: +// RL C +if (BC.B.B0 & 0x80) { + BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[BC.B.B0] | C_FLAG; +} else { + BC.B.B0 = (BC.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[BC.B.B0]; +} +break; +case 0x12: +// RL D +if (DE.B.B1 & 0x80) { + DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[DE.B.B1] | C_FLAG; +} else { + DE.B.B1 = (DE.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[DE.B.B1]; +} +break; +case 0x13: +// RL E +if (DE.B.B0 & 0x80) { + DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[DE.B.B0] | C_FLAG; +} else { + DE.B.B0 = (DE.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[DE.B.B0]; +} +break; +case 0x14: +// RL H +if (HL.B.B1 & 0x80) { + HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[HL.B.B1] | C_FLAG; +} else { + HL.B.B1 = (HL.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[HL.B.B1]; +} +break; +case 0x15: +// RL L +if (HL.B.B0 & 0x80) { + HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[HL.B.B0] | C_FLAG; +} else { + HL.B.B0 = (HL.B.B0 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[HL.B.B0]; +} +break; +case 0x16: +// RL (HL) +tempValue = gbReadMemory(HL.W); +if (tempValue & 0x80) { + tempValue = (tempValue << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[tempValue] | C_FLAG; +} else { + tempValue = (tempValue << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[tempValue]; +} +gbWriteMemory(HL.W, tempValue); +break; +case 0x17: +// RL A +if (AF.B.B1 & 0x80) { + AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[AF.B.B1] | C_FLAG; +} else { + AF.B.B1 = (AF.B.B1 << 1) | (AF.B.B0 & C_FLAG ? 1 : 0); + AF.B.B0 = ZeroTable[AF.B.B1]; +} +break; +case 0x18: +// RR B +if (BC.B.B1 & 0x01) { + BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[BC.B.B1] | C_FLAG; +} else { + BC.B.B1 = (BC.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[BC.B.B1]; +} +break; +case 0x19: +// RR C +if (BC.B.B0 & 0x01) { + BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[BC.B.B0] | C_FLAG; +} else { + BC.B.B0 = (BC.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[BC.B.B0]; +} +break; +case 0x1a: +// RR D +if (DE.B.B1 & 0x01) { + DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[DE.B.B1] | C_FLAG; +} else { + DE.B.B1 = (DE.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[DE.B.B1]; +} +break; +case 0x1b: +// RR E +if (DE.B.B0 & 0x01) { + DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[DE.B.B0] | C_FLAG; +} else { + DE.B.B0 = (DE.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[DE.B.B0]; +} +break; +case 0x1c: +// RR H +if (HL.B.B1 & 0x01) { + HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[HL.B.B1] | C_FLAG; +} else { + HL.B.B1 = (HL.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[HL.B.B1]; +} +break; +case 0x1d: +// RR L +if (HL.B.B0 & 0x01) { + HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[HL.B.B0] | C_FLAG; +} else { + HL.B.B0 = (HL.B.B0 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[HL.B.B0]; +} +break; +case 0x1e: +// RR (HL) +tempValue = gbReadMemory(HL.W); +if (tempValue & 0x01) { + tempValue = (tempValue >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[tempValue] | C_FLAG; +} else { + tempValue = (tempValue >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[tempValue]; +} +gbWriteMemory(HL.W, tempValue); +break; +case 0x1f: +// RR A +if (AF.B.B1 & 0x01) { + AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[AF.B.B1] | C_FLAG; +} else { + AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B0 & C_FLAG ? 0x80 : 0); + AF.B.B0 = ZeroTable[AF.B.B1]; +} +break; +case 0x20: +// SLA B +AF.B.B0 = (BC.B.B1 & 0x80 ? C_FLAG : 0); +BC.B.B1 <<= 1; +AF.B.B0 |= ZeroTable[BC.B.B1]; +break; +case 0x21: +// SLA C +AF.B.B0 = (BC.B.B0 & 0x80 ? C_FLAG : 0); +BC.B.B0 <<= 1; +AF.B.B0 |= ZeroTable[BC.B.B0]; +break; +case 0x22: +// SLA D +AF.B.B0 = (DE.B.B1 & 0x80 ? C_FLAG : 0); +DE.B.B1 <<= 1; +AF.B.B0 |= ZeroTable[DE.B.B1]; +break; +case 0x23: +// SLA E +AF.B.B0 = (DE.B.B0 & 0x80 ? C_FLAG : 0); +DE.B.B0 <<= 1; +AF.B.B0 |= ZeroTable[DE.B.B0]; +break; +case 0x24: +// SLA H +AF.B.B0 = (HL.B.B1 & 0x80 ? C_FLAG : 0); +HL.B.B1 <<= 1; +AF.B.B0 |= ZeroTable[HL.B.B1]; +break; +case 0x25: +// SLA L +AF.B.B0 = (HL.B.B0 & 0x80 ? C_FLAG : 0); +HL.B.B0 <<= 1; +AF.B.B0 |= ZeroTable[HL.B.B0]; +break; +case 0x26: +// SLA (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (tempValue & 0x80 ? C_FLAG : 0); +tempValue <<= 1; +AF.B.B0 |= ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x27: +// SLA A +AF.B.B0 = (AF.B.B1 & 0x80 ? C_FLAG : 0); +AF.B.B1 <<= 1; +AF.B.B0 |= ZeroTable[AF.B.B1]; +break; +case 0x28: +// SRA B +AF.B.B0 = (BC.B.B1 & 0x01 ? C_FLAG : 0); +BC.B.B1 = (BC.B.B1 >> 1) | (BC.B.B1 & 0x80); +AF.B.B0 |= ZeroTable[BC.B.B1]; +break; +case 0x29: +// SRA C +AF.B.B0 = (BC.B.B0 & 0x01 ? C_FLAG : 0); +BC.B.B0 = (BC.B.B0 >> 1) | (BC.B.B0 & 0x80); +AF.B.B0 |= ZeroTable[BC.B.B0]; +break; +case 0x2a: +// SRA D +AF.B.B0 = (DE.B.B1 & 0x01 ? C_FLAG : 0); +DE.B.B1 = (DE.B.B1 >> 1) | (DE.B.B1 & 0x80); +AF.B.B0 |= ZeroTable[DE.B.B1]; +break; +case 0x2b: +// SRA E +AF.B.B0 = (DE.B.B0 & 0x01 ? C_FLAG : 0); +DE.B.B0 = (DE.B.B0 >> 1) | (DE.B.B0 & 0x80); +AF.B.B0 |= ZeroTable[DE.B.B0]; +break; +case 0x2c: +// SRA H +AF.B.B0 = (HL.B.B1 & 0x01 ? C_FLAG : 0); +HL.B.B1 = (HL.B.B1 >> 1) | (HL.B.B1 & 0x80); +AF.B.B0 |= ZeroTable[HL.B.B1]; +break; +case 0x2d: +// SRA L +AF.B.B0 = (HL.B.B0 & 0x01 ? C_FLAG : 0); +HL.B.B0 = (HL.B.B0 >> 1) | (HL.B.B0 & 0x80); +AF.B.B0 |= ZeroTable[HL.B.B0]; +break; +case 0x2e: +// SRA (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (tempValue & 0x01 ? C_FLAG : 0); +tempValue = (tempValue >> 1) | (tempValue & 0x80); +AF.B.B0 |= ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x2f: +// SRA A +AF.B.B0 = (AF.B.B1 & 0x01 ? C_FLAG : 0); +AF.B.B1 = (AF.B.B1 >> 1) | (AF.B.B1 & 0x80); +AF.B.B0 |= ZeroTable[AF.B.B1]; +break; +case 0x30: +// SWAP B +BC.B.B1 = (BC.B.B1 & 0xf0) >> 4 | (BC.B.B1 & 0x0f) << 4; +AF.B.B0 = ZeroTable[BC.B.B1]; +break; +case 0x31: +// SWAP C +BC.B.B0 = (BC.B.B0 & 0xf0) >> 4 | (BC.B.B0 & 0x0f) << 4; +AF.B.B0 = ZeroTable[BC.B.B0]; +break; +case 0x32: +// SWAP D +DE.B.B1 = (DE.B.B1 & 0xf0) >> 4 | (DE.B.B1 & 0x0f) << 4; +AF.B.B0 = ZeroTable[DE.B.B1]; +break; +case 0x33: +// SWAP E +DE.B.B0 = (DE.B.B0 & 0xf0) >> 4 | (DE.B.B0 & 0x0f) << 4; +AF.B.B0 = ZeroTable[DE.B.B0]; +break; +case 0x34: +// SWAP H +HL.B.B1 = (HL.B.B1 & 0xf0) >> 4 | (HL.B.B1 & 0x0f) << 4; +AF.B.B0 = ZeroTable[HL.B.B1]; +break; +case 0x35: +// SWAP L +HL.B.B0 = (HL.B.B0 & 0xf0) >> 4 | (HL.B.B0 & 0x0f) << 4; +AF.B.B0 = ZeroTable[HL.B.B0]; +break; +case 0x36: +// SWAP (HL) +tempValue = gbReadMemory(HL.W); +tempValue = (tempValue & 0xf0) >> 4 | (tempValue & 0x0f) << 4; +AF.B.B0 = ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x37: +// SWAP A +AF.B.B1 = (AF.B.B1 & 0xf0) >> 4 | (AF.B.B1 & 0x0f) << 4; +AF.B.B0 = ZeroTable[AF.B.B1]; +break; +case 0x38: +// SRL B +AF.B.B0 = (BC.B.B1 & 0x01) ? C_FLAG : 0; +BC.B.B1 >>= 1; +AF.B.B0 |= ZeroTable[BC.B.B1]; +break; +case 0x39: +// SRL C +AF.B.B0 = (BC.B.B0 & 0x01) ? C_FLAG : 0; +BC.B.B0 >>= 1; +AF.B.B0 |= ZeroTable[BC.B.B0]; +break; +case 0x3a: +// SRL D +AF.B.B0 = (DE.B.B1 & 0x01) ? C_FLAG : 0; +DE.B.B1 >>= 1; +AF.B.B0 |= ZeroTable[DE.B.B1]; +break; +case 0x3b: +// SRL E +AF.B.B0 = (DE.B.B0 & 0x01) ? C_FLAG : 0; +DE.B.B0 >>= 1; +AF.B.B0 |= ZeroTable[DE.B.B0]; +break; +case 0x3c: +// SRL H +AF.B.B0 = (HL.B.B1 & 0x01) ? C_FLAG : 0; +HL.B.B1 >>= 1; +AF.B.B0 |= ZeroTable[HL.B.B1]; +break; +case 0x3d: +// SRL L +AF.B.B0 = (HL.B.B0 & 0x01) ? C_FLAG : 0; +HL.B.B0 >>= 1; +AF.B.B0 |= ZeroTable[HL.B.B0]; +break; +case 0x3e: +// SRL (HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (tempValue & 0x01) ? C_FLAG : 0; +tempValue >>= 1; +AF.B.B0 |= ZeroTable[tempValue]; +gbWriteMemory(HL.W, tempValue); +break; +case 0x3f: +// SRL A +AF.B.B0 = (AF.B.B1 & 0x01) ? C_FLAG : 0; +AF.B.B1 >>= 1; +AF.B.B0 |= ZeroTable[AF.B.B1]; +break; +case 0x40: +// BIT 0,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x41: +// BIT 0,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x42: +// BIT 0,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x43: +// BIT 0,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x44: +// BIT 0,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x45: +// BIT 0,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x46: +// BIT 0,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x47: +// BIT 0,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 0) ? 0 : Z_FLAG); +break; +case 0x48: +// BIT 1,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x49: +// BIT 1,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4a: +// BIT 1,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4b: +// BIT 1,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4c: +// BIT 1,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4d: +// BIT 1,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4e: +// BIT 1,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x4f: +// BIT 1,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 1) ? 0 : Z_FLAG); +break; +case 0x50: +// BIT 2,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x51: +// BIT 2,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x52: +// BIT 2,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x53: +// BIT 2,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x54: +// BIT 2,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x55: +// BIT 2,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x56: +// BIT 2,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x57: +// BIT 2,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 2) ? 0 : Z_FLAG); +break; +case 0x58: +// BIT 3,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x59: +// BIT 3,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5a: +// BIT 3,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5b: +// BIT 3,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5c: +// BIT 3,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5d: +// BIT 3,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5e: +// BIT 3,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x5f: +// BIT 3,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 3) ? 0 : Z_FLAG); +break; +case 0x60: +// BIT 4,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x61: +// BIT 4,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x62: +// BIT 4,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x63: +// BIT 4,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x64: +// BIT 4,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x65: +// BIT 4,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x66: +// BIT 4,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x67: +// BIT 4,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 4) ? 0 : Z_FLAG); +break; +case 0x68: +// BIT 5,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x69: +// BIT 5,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6a: +// BIT 5,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6b: +// BIT 5,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6c: +// BIT 5,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6d: +// BIT 5,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6e: +// BIT 5,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x6f: +// BIT 5,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 5) ? 0 : Z_FLAG); +break; +case 0x70: +// BIT 6,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x71: +// BIT 6,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x72: +// BIT 6,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x73: +// BIT 6,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x74: +// BIT 6,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x75: +// BIT 6,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x76: +// BIT 6,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x77: +// BIT 6,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 6) ? 0 : Z_FLAG); +break; +case 0x78: +// BIT 7,B +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B1 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x79: +// BIT 7,C +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (BC.B.B0 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7a: +// BIT 7,D +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B1 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7b: +// BIT 7,E +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (DE.B.B0 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7c: +// BIT 7,H +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B1 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7d: +// BIT 7,L +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (HL.B.B0 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7e: +// BIT 7,(HL) +tempValue = gbReadMemory(HL.W); +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (tempValue & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x7f: +// BIT 7,A +AF.B.B0 = (AF.B.B0 & C_FLAG) | H_FLAG | (AF.B.B1 & (1 << 7) ? 0 : Z_FLAG); +break; +case 0x80: +// RES 0,B +BC.B.B1 &= ~(1 << 0); +break; +case 0x81: +// RES 0,C +BC.B.B0 &= ~(1 << 0); +break; +case 0x82: +// RES 0,D +DE.B.B1 &= ~(1 << 0); +break; +case 0x83: +// RES 0,E +DE.B.B0 &= ~(1 << 0); +break; +case 0x84: +// RES 0,H +HL.B.B1 &= ~(1 << 0); +break; +case 0x85: +// RES 0,L +HL.B.B0 &= ~(1 << 0); +break; +case 0x86: +// RES 0,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 0); +gbWriteMemory(HL.W, tempValue); +break; +case 0x87: +// RES 0,A +AF.B.B1 &= ~(1 << 0); +break; +case 0x88: +// RES 1,B +BC.B.B1 &= ~(1 << 1); +break; +case 0x89: +// RES 1,C +BC.B.B0 &= ~(1 << 1); +break; +case 0x8a: +// RES 1,D +DE.B.B1 &= ~(1 << 1); +break; +case 0x8b: +// RES 1,E +DE.B.B0 &= ~(1 << 1); +break; +case 0x8c: +// RES 1,H +HL.B.B1 &= ~(1 << 1); +break; +case 0x8d: +// RES 1,L +HL.B.B0 &= ~(1 << 1); +break; +case 0x8e: +// RES 1,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 1); +gbWriteMemory(HL.W, tempValue); +break; +case 0x8f: +// RES 1,A +AF.B.B1 &= ~(1 << 1); +break; +case 0x90: +// RES 2,B +BC.B.B1 &= ~(1 << 2); +break; +case 0x91: +// RES 2,C +BC.B.B0 &= ~(1 << 2); +break; +case 0x92: +// RES 2,D +DE.B.B1 &= ~(1 << 2); +break; +case 0x93: +// RES 2,E +DE.B.B0 &= ~(1 << 2); +break; +case 0x94: +// RES 2,H +HL.B.B1 &= ~(1 << 2); +break; +case 0x95: +// RES 2,L +HL.B.B0 &= ~(1 << 2); +break; +case 0x96: +// RES 2,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 2); +gbWriteMemory(HL.W, tempValue); +break; +case 0x97: +// RES 2,A +AF.B.B1 &= ~(1 << 2); +break; +case 0x98: +// RES 3,B +BC.B.B1 &= ~(1 << 3); +break; +case 0x99: +// RES 3,C +BC.B.B0 &= ~(1 << 3); +break; +case 0x9a: +// RES 3,D +DE.B.B1 &= ~(1 << 3); +break; +case 0x9b: +// RES 3,E +DE.B.B0 &= ~(1 << 3); +break; +case 0x9c: +// RES 3,H +HL.B.B1 &= ~(1 << 3); +break; +case 0x9d: +// RES 3,L +HL.B.B0 &= ~(1 << 3); +break; +case 0x9e: +// RES 3,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 3); +gbWriteMemory(HL.W, tempValue); +break; +case 0x9f: +// RES 3,A +AF.B.B1 &= ~(1 << 3); +break; +case 0xa0: +// RES 4,B +BC.B.B1 &= ~(1 << 4); +break; +case 0xa1: +// RES 4,C +BC.B.B0 &= ~(1 << 4); +break; +case 0xa2: +// RES 4,D +DE.B.B1 &= ~(1 << 4); +break; +case 0xa3: +// RES 4,E +DE.B.B0 &= ~(1 << 4); +break; +case 0xa4: +// RES 4,H +HL.B.B1 &= ~(1 << 4); +break; +case 0xa5: +// RES 4,L +HL.B.B0 &= ~(1 << 4); +break; +case 0xa6: +// RES 4,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 4); +gbWriteMemory(HL.W, tempValue); +break; +case 0xa7: +// RES 4,A +AF.B.B1 &= ~(1 << 4); +break; +case 0xa8: +// RES 5,B +BC.B.B1 &= ~(1 << 5); +break; +case 0xa9: +// RES 5,C +BC.B.B0 &= ~(1 << 5); +break; +case 0xaa: +// RES 5,D +DE.B.B1 &= ~(1 << 5); +break; +case 0xab: +// RES 5,E +DE.B.B0 &= ~(1 << 5); +break; +case 0xac: +// RES 5,H +HL.B.B1 &= ~(1 << 5); +break; +case 0xad: +// RES 5,L +HL.B.B0 &= ~(1 << 5); +break; +case 0xae: +// RES 5,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 5); +gbWriteMemory(HL.W, tempValue); +break; +case 0xaf: +// RES 5,A +AF.B.B1 &= ~(1 << 5); +break; +case 0xb0: +// RES 6,B +BC.B.B1 &= ~(1 << 6); +break; +case 0xb1: +// RES 6,C +BC.B.B0 &= ~(1 << 6); +break; +case 0xb2: +// RES 6,D +DE.B.B1 &= ~(1 << 6); +break; +case 0xb3: +// RES 6,E +DE.B.B0 &= ~(1 << 6); +break; +case 0xb4: +// RES 6,H +HL.B.B1 &= ~(1 << 6); +break; +case 0xb5: +// RES 6,L +HL.B.B0 &= ~(1 << 6); +break; +case 0xb6: +// RES 6,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 6); +gbWriteMemory(HL.W, tempValue); +break; +case 0xb7: +// RES 6,A +AF.B.B1 &= ~(1 << 6); +break; +case 0xb8: +// RES 7,B +BC.B.B1 &= ~(1 << 7); +break; +case 0xb9: +// RES 7,C +BC.B.B0 &= ~(1 << 7); +break; +case 0xba: +// RES 7,D +DE.B.B1 &= ~(1 << 7); +break; +case 0xbb: +// RES 7,E +DE.B.B0 &= ~(1 << 7); +break; +case 0xbc: +// RES 7,H +HL.B.B1 &= ~(1 << 7); +break; +case 0xbd: +// RES 7,L +HL.B.B0 &= ~(1 << 7); +break; +case 0xbe: +// RES 7,(HL) +tempValue = gbReadMemory(HL.W); +tempValue &= ~(1 << 7); +gbWriteMemory(HL.W, tempValue); +break; +case 0xbf: +// RES 7,A +AF.B.B1 &= ~(1 << 7); +break; +case 0xc0: +// SET 0,B +BC.B.B1 |= 1 << 0; +break; +case 0xc1: +// SET 0,C +BC.B.B0 |= 1 << 0; +break; +case 0xc2: +// SET 0,D +DE.B.B1 |= 1 << 0; +break; +case 0xc3: +// SET 0,E +DE.B.B0 |= 1 << 0; +break; +case 0xc4: +// SET 0,H +HL.B.B1 |= 1 << 0; +break; +case 0xc5: +// SET 0,L +HL.B.B0 |= 1 << 0; +break; +case 0xc6: +// SET 0,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 0; +gbWriteMemory(HL.W, tempValue); +break; +case 0xc7: +// SET 0,A +AF.B.B1 |= 1 << 0; +break; +case 0xc8: +// SET 1,B +BC.B.B1 |= 1 << 1; +break; +case 0xc9: +// SET 1,C +BC.B.B0 |= 1 << 1; +break; +case 0xca: +// SET 1,D +DE.B.B1 |= 1 << 1; +break; +case 0xcb: +// SET 1,E +DE.B.B0 |= 1 << 1; +break; +case 0xcc: +// SET 1,H +HL.B.B1 |= 1 << 1; +break; +case 0xcd: +// SET 1,L +HL.B.B0 |= 1 << 1; +break; +case 0xce: +// SET 1,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 1; +gbWriteMemory(HL.W, tempValue); +break; +case 0xcf: +// SET 1,A +AF.B.B1 |= 1 << 1; +break; +case 0xd0: +// SET 2,B +BC.B.B1 |= 1 << 2; +break; +case 0xd1: +// SET 2,C +BC.B.B0 |= 1 << 2; +break; +case 0xd2: +// SET 2,D +DE.B.B1 |= 1 << 2; +break; +case 0xd3: +// SET 2,E +DE.B.B0 |= 1 << 2; +break; +case 0xd4: +// SET 2,H +HL.B.B1 |= 1 << 2; +break; +case 0xd5: +// SET 2,L +HL.B.B0 |= 1 << 2; +break; +case 0xd6: +// SET 2,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 2; +gbWriteMemory(HL.W, tempValue); +break; +case 0xd7: +// SET 2,A +AF.B.B1 |= 1 << 2; +break; +case 0xd8: +// SET 3,B +BC.B.B1 |= 1 << 3; +break; +case 0xd9: +// SET 3,C +BC.B.B0 |= 1 << 3; +break; +case 0xda: +// SET 3,D +DE.B.B1 |= 1 << 3; +break; +case 0xdb: +// SET 3,E +DE.B.B0 |= 1 << 3; +break; +case 0xdc: +// SET 3,H +HL.B.B1 |= 1 << 3; +break; +case 0xdd: +// SET 3,L +HL.B.B0 |= 1 << 3; +break; +case 0xde: +// SET 3,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 3; +gbWriteMemory(HL.W, tempValue); +break; +case 0xdf: +// SET 3,A +AF.B.B1 |= 1 << 3; +break; +case 0xe0: +// SET 4,B +BC.B.B1 |= 1 << 4; +break; +case 0xe1: +// SET 4,C +BC.B.B0 |= 1 << 4; +break; +case 0xe2: +// SET 4,D +DE.B.B1 |= 1 << 4; +break; +case 0xe3: +// SET 4,E +DE.B.B0 |= 1 << 4; +break; +case 0xe4: +// SET 4,H +HL.B.B1 |= 1 << 4; +break; +case 0xe5: +// SET 4,L +HL.B.B0 |= 1 << 4; +break; +case 0xe6: +// SET 4,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 4; +gbWriteMemory(HL.W, tempValue); +break; +case 0xe7: +// SET 4,A +AF.B.B1 |= 1 << 4; +break; +case 0xe8: +// SET 5,B +BC.B.B1 |= 1 << 5; +break; +case 0xe9: +// SET 5,C +BC.B.B0 |= 1 << 5; +break; +case 0xea: +// SET 5,D +DE.B.B1 |= 1 << 5; +break; +case 0xeb: +// SET 5,E +DE.B.B0 |= 1 << 5; +break; +case 0xec: +// SET 5,H +HL.B.B1 |= 1 << 5; +break; +case 0xed: +// SET 5,L +HL.B.B0 |= 1 << 5; +break; +case 0xee: +// SET 5,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 5; +gbWriteMemory(HL.W, tempValue); +break; +case 0xef: +// SET 5,A +AF.B.B1 |= 1 << 5; +break; +case 0xf0: +// SET 6,B +BC.B.B1 |= 1 << 6; +break; +case 0xf1: +// SET 6,C +BC.B.B0 |= 1 << 6; +break; +case 0xf2: +// SET 6,D +DE.B.B1 |= 1 << 6; +break; +case 0xf3: +// SET 6,E +DE.B.B0 |= 1 << 6; +break; +case 0xf4: +// SET 6,H +HL.B.B1 |= 1 << 6; +break; +case 0xf5: +// SET 6,L +HL.B.B0 |= 1 << 6; +break; +case 0xf6: +// SET 6,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 6; +gbWriteMemory(HL.W, tempValue); +break; +case 0xf7: +// SET 6,A +AF.B.B1 |= 1 << 6; +break; +case 0xf8: +// SET 7,B +BC.B.B1 |= 1 << 7; +break; +case 0xf9: +// SET 7,C +BC.B.B0 |= 1 << 7; +break; +case 0xfa: +// SET 7,D +DE.B.B1 |= 1 << 7; +break; +case 0xfb: +// SET 7,E +DE.B.B0 |= 1 << 7; +break; +case 0xfc: +// SET 7,H +HL.B.B1 |= 1 << 7; +break; +case 0xfd: +// SET 7,L +HL.B.B0 |= 1 << 7; +break; +case 0xfe: +// SET 7,(HL) +tempValue = gbReadMemory(HL.W); +tempValue |= 1 << 7; +gbWriteMemory(HL.W, tempValue); +break; +case 0xff: +// SET 7,A +AF.B.B1 |= 1 << 7; +break; +default: +if (gbSystemMessage == false) { + systemMessage(0, N_("Unknown opcode %02x at %04x"), gbReadOpcode(PC.W - 1), PC.W - 1); + gbSystemMessage = true; +} +return; diff --git a/src/gb/gbGlobals.h b/src/gb/gbGlobals.h index c7b71d4e..1fafb75a 100644 --- a/src/gb/gbGlobals.h +++ b/src/gb/gbGlobals.h @@ -43,8 +43,8 @@ extern u8 gbSCXLine[300]; // gbBgpLine is used for the emulation of the // Prehistorik Man's title screen scroller. extern u8 gbBgpLine[300]; -extern u8 gbObp0Line [300]; -extern u8 gbObp1Line [300]; +extern u8 gbObp0Line[300]; +extern u8 gbObp1Line[300]; // gbSpritesTicks is used for the emulation of Parodius' Laser Beam. extern u8 gbSpritesTicks[300]; diff --git a/src/gb/gbMemory.h b/src/gb/gbMemory.h index 7c35c48c..ad737e96 100644 --- a/src/gb/gbMemory.h +++ b/src/gb/gbMemory.h @@ -4,134 +4,134 @@ #include struct mapperMBC1 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperMemoryModel; - int mapperROMHighAddress; - int mapperRAMAddress; - int mapperRomBank0Remapping; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperMemoryModel; + int mapperROMHighAddress; + int mapperRAMAddress; + int mapperRomBank0Remapping; }; struct mapperMBC2 { - int mapperRAMEnable; - int mapperROMBank; + int mapperRAMEnable; + int mapperROMBank; }; struct mapperMBC3 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperRAMAddress; - int mapperClockLatch; - int mapperClockRegister; - int mapperSeconds; - int mapperMinutes; - int mapperHours; - int mapperDays; - int mapperControl; - int mapperLSeconds; - int mapperLMinutes; - int mapperLHours; - int mapperLDays; - int mapperLControl; - time_t mapperLastTime; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int mapperClockLatch; + int mapperClockRegister; + int mapperSeconds; + int mapperMinutes; + int mapperHours; + int mapperDays; + int mapperControl; + int mapperLSeconds; + int mapperLMinutes; + int mapperLHours; + int mapperLDays; + int mapperLControl; + time_t mapperLastTime; }; struct mapperMBC5 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperROMHighAddress; - int mapperRAMAddress; - int isRumbleCartridge; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperROMHighAddress; + int mapperRAMAddress; + int isRumbleCartridge; }; struct mapperMBC7 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperRAMAddress; - int cs; - int sk; - int state; - int buffer; - int idle; - int count; - int code; - int address; - int writeEnable; - int value; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int cs; + int sk; + int state; + int buffer; + int idle; + int count; + int code; + int address; + int writeEnable; + int value; }; struct mapperHuC1 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperMemoryModel; - int mapperROMHighAddress; - int mapperRAMAddress; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperMemoryModel; + int mapperROMHighAddress; + int mapperRAMAddress; }; struct mapperHuC3 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperRAMAddress; - int mapperAddress; - int mapperRAMFlag; - int mapperRAMValue; - int mapperRegister1; - int mapperRegister2; - int mapperRegister3; - int mapperRegister4; - int mapperRegister5; - int mapperRegister6; - int mapperRegister7; - int mapperRegister8; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int mapperAddress; + int mapperRAMFlag; + int mapperRAMValue; + int mapperRegister1; + int mapperRegister2; + int mapperRegister3; + int mapperRegister4; + int mapperRegister5; + int mapperRegister6; + int mapperRegister7; + int mapperRegister8; }; struct mapperTAMA5 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperRAMAddress; - int mapperRamByteSelect; - int mapperCommandNumber; - int mapperLastCommandNumber; - int mapperCommands[0x10]; - int mapperRegister; - int mapperClockLatch; - int mapperClockRegister; - int mapperSeconds; - int mapperMinutes; - int mapperHours; - int mapperDays; - int mapperMonths; - int mapperYears; - int mapperControl; - int mapperLSeconds; - int mapperLMinutes; - int mapperLHours; - int mapperLDays; - int mapperLMonths; - int mapperLYears; - int mapperLControl; - time_t mapperLastTime; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperRAMAddress; + int mapperRamByteSelect; + int mapperCommandNumber; + int mapperLastCommandNumber; + int mapperCommands[0x10]; + int mapperRegister; + int mapperClockLatch; + int mapperClockRegister; + int mapperSeconds; + int mapperMinutes; + int mapperHours; + int mapperDays; + int mapperMonths; + int mapperYears; + int mapperControl; + int mapperLSeconds; + int mapperLMinutes; + int mapperLHours; + int mapperLDays; + int mapperLMonths; + int mapperLYears; + int mapperLControl; + time_t mapperLastTime; }; struct mapperMMM01 { - int mapperRAMEnable; - int mapperROMBank; - int mapperRAMBank; - int mapperMemoryModel; - int mapperROMHighAddress; - int mapperRAMAddress; - int mapperRomBank0Remapping; + int mapperRAMEnable; + int mapperROMBank; + int mapperRAMBank; + int mapperMemoryModel; + int mapperROMHighAddress; + int mapperRAMAddress; + int mapperRomBank0Remapping; }; struct mapperGS3 { - int mapperROMBank; + int mapperROMBank; }; extern mapperMBC1 gbDataMBC1; @@ -144,35 +144,35 @@ extern mapperTAMA5 gbDataTAMA5; extern mapperMMM01 gbDataMMM01; extern mapperGS3 gbDataGS3; -void mapperMBC1ROM(u16,u8); -void mapperMBC1RAM(u16,u8); +void mapperMBC1ROM(u16, u8); +void mapperMBC1RAM(u16, u8); u8 mapperMBC1ReadRAM(u16); -void mapperMBC2ROM(u16,u8); -void mapperMBC2RAM(u16,u8); -void mapperMBC3ROM(u16,u8); -void mapperMBC3RAM(u16,u8); +void mapperMBC2ROM(u16, u8); +void mapperMBC2RAM(u16, u8); +void mapperMBC3ROM(u16, u8); +void mapperMBC3RAM(u16, u8); u8 mapperMBC3ReadRAM(u16); -void mapperMBC5ROM(u16,u8); -void mapperMBC5RAM(u16,u8); +void mapperMBC5ROM(u16, u8); +void mapperMBC5RAM(u16, u8); u8 mapperMBC5ReadRAM(u16); -void mapperMBC7ROM(u16,u8); -void mapperMBC7RAM(u16,u8); +void mapperMBC7ROM(u16, u8); +void mapperMBC7RAM(u16, u8); u8 mapperMBC7ReadRAM(u16); -void mapperHuC1ROM(u16,u8); -void mapperHuC1RAM(u16,u8); -void mapperHuC3ROM(u16,u8); -void mapperHuC3RAM(u16,u8); +void mapperHuC1ROM(u16, u8); +void mapperHuC1RAM(u16, u8); +void mapperHuC3ROM(u16, u8); +void mapperHuC3RAM(u16, u8); u8 mapperHuC3ReadRAM(u16); -void mapperTAMA5RAM(u16,u8); +void mapperTAMA5RAM(u16, u8); u8 mapperTAMA5ReadRAM(u16); void memoryUpdateTAMA5Clock(); -void mapperMMM01ROM(u16,u8); -void mapperMMM01RAM(u16,u8); -void mapperGGROM(u16,u8); -void mapperGS3ROM(u16,u8); -//extern void (*mapper)(u16,u8); -//extern void (*mapperRAM)(u16,u8); -//extern u8 (*mapperReadRAM)(u16); +void mapperMMM01ROM(u16, u8); +void mapperMMM01RAM(u16, u8); +void mapperGGROM(u16, u8); +void mapperGS3ROM(u16, u8); +// extern void (*mapper)(u16,u8); +// extern void (*mapperRAM)(u16,u8); +// extern u8 (*mapperReadRAM)(u16); extern void memoryUpdateMapMBC1(); extern void memoryUpdateMapMBC2(); diff --git a/src/gb/gbSGB.h b/src/gb/gbSGB.h index 00ccbdb9..b5adbbe2 100644 --- a/src/gb/gbSGB.h +++ b/src/gb/gbSGB.h @@ -11,13 +11,13 @@ void gbSgbSaveGame(gzFile); void gbSgbReadGame(gzFile, int version); void gbSgbRenderBorder(); -extern u8 gbSgbATF[20*18]; +extern u8 gbSgbATF[20 * 18]; extern int gbSgbMode; extern int gbSgbMask; extern int gbSgbMultiplayer; -extern u8 gbSgbNextController; +extern u8 gbSgbNextController; extern int gbSgbPacketTimeout; -extern u8 gbSgbReadingController; +extern u8 gbSgbReadingController; extern int gbSgbFourPlayers; #endif // GBSGB_H diff --git a/src/gb/gbSound.h b/src/gb/gbSound.h index 47ecf2e4..9272cb36 100644 --- a/src/gb/gbSound.h +++ b/src/gb/gbSound.h @@ -7,28 +7,26 @@ //// GB sound options -void gbSoundSetSampleRate( long sampleRate ); +void gbSoundSetSampleRate(long sampleRate); // Manages declicking mode. When enabled, clicks are reduced. Note that clicks // are normal for GB and GBC sound hardware. -void gbSoundSetDeclicking( bool enable ); +void gbSoundSetDeclicking(bool enable); bool gbSoundGetDeclicking(); // Effects configuration -struct gb_effects_config_t -{ - bool enabled; // false = disable all effects +struct gb_effects_config_t { + bool enabled; // false = disable all effects - float echo; // 0.0 = none, 1.0 = lots - float stereo; // 0.0 = channels in center, 1.0 = channels on left/right - bool surround; // true = put some channels in back + float echo; // 0.0 = none, 1.0 = lots + float stereo; // 0.0 = channels in center, 1.0 = channels on left/right + bool surround; // true = put some channels in back }; // Changes effects configuration -void gbSoundConfigEffects( gb_effects_config_t const& ); +void gbSoundConfigEffects(gb_effects_config_t const &); extern gb_effects_config_t gb_effects_config; // current configuration - //// GB sound emulation // GB sound registers @@ -58,19 +56,19 @@ extern gb_effects_config_t gb_effects_config; // current configuration void gbSoundReset(); // Emulates write to sound hardware -void gbSoundEvent( u16 address, int data ); +void gbSoundEvent(u16 address, int data); #define SOUND_EVENT gbSoundEvent // Emulates read from sound hardware -u8 gbSoundRead( u16 address ); +u8 gbSoundRead(u16 address); // Notifies emulator that SOUND_CLOCK_TICKS clocks have passed void gbSoundTick(); -extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to gbSoundTick() -extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick() will be called +extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to gbSoundTick() +extern int soundTicks; // Number of 16.8 MHz clocks until gbSoundTick() will be called // Saves/loads emulator state -void gbSoundSaveGame( gzFile out ); -void gbSoundReadGame( int version, gzFile in ); +void gbSoundSaveGame(gzFile out); +void gbSoundReadGame(int version, gzFile in); #endif // GBSOUND_H diff --git a/src/gba/BreakpointStructures.h b/src/gba/BreakpointStructures.h index 32203ace..7f2f025e 100644 --- a/src/gba/BreakpointStructures.h +++ b/src/gba/BreakpointStructures.h @@ -3,71 +3,68 @@ #include "../common/Types.h" -#define readWord(addr) \ - ((map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])+\ - ((map[(addr+1)>>24].address[(addr+1) & map[(addr+1)>>24].mask])<<8)+\ - ((map[(addr+2)>>24].address[(addr+2) & map[(addr+2)>>24].mask])<<16)+\ - ((map[(addr+3)>>24].address[(addr+3) & map[(addr+3)>>24].mask])<<24)) +#define readWord(addr) \ + ((map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + \ + ((map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8) + \ + ((map[(addr + 2) >> 24].address[(addr + 2) & map[(addr + 2) >> 24].mask]) << 16) + \ + ((map[(addr + 3) >> 24].address[(addr + 3) & map[(addr + 3) >> 24].mask]) << 24)) -#define readHalfWord(addr) \ - ((&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])+\ - ((&map[(addr+1)>>24].address[(addr+1) & map[(addr+1)>>24].mask])<<8)) +#define readHalfWord(addr) \ + ((&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask]) + \ + ((&map[(addr + 1) >> 24].address[(addr + 1) & map[(addr + 1) >> 24].mask]) << 8)) -#define readByte(addr) \ - map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] +#define readByte(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] - -struct ConditionalBreakNode{ - char* address; - char* value; - u8 cond_flags; - u8 exp_type_flags; - struct ConditionalBreakNode* next; +struct ConditionalBreakNode { + char *address; + char *value; + u8 cond_flags; + u8 exp_type_flags; + struct ConditionalBreakNode *next; }; -struct ConditionalBreak{ - u32 break_address; - u8 type_flags; - struct ConditionalBreakNode* firstCond; - struct ConditionalBreak* next; +struct ConditionalBreak { + u32 break_address; + u8 type_flags; + struct ConditionalBreakNode *firstCond; + struct ConditionalBreak *next; }; -extern struct ConditionalBreak* conditionals[16]; +extern struct ConditionalBreak *conditionals[16]; -//conditional break manipulators -//case '*': flag = 0xf; break; -//case 't': flag = 0x8; break; // thumb -//case 'a': flag = 0x4; break; // arm -//case 'x': flag = 0xC; break; -//case 'r': flag = 0x2; break; // mem read -//case 'w': flag = 0x1; break; // mem write -//case 'i': flag = 0x3; break; -struct ConditionalBreak* addConditionalBreak(u32 address, u8 flag); +// conditional break manipulators +// case '*': flag = 0xf; break; +// case 't': flag = 0x8; break; // thumb +// case 'a': flag = 0x4; break; // arm +// case 'x': flag = 0xC; break; +// case 'r': flag = 0x2; break; // mem read +// case 'w': flag = 0x1; break; // mem write +// case 'i': flag = 0x3; break; +struct ConditionalBreak *addConditionalBreak(u32 address, u8 flag); int removeConditionalBreakNo(u32 address, u8 number); int removeFlagFromConditionalBreakNo(u32 address, u8 number, u8 flag); int removeConditionalWithAddress(u32 address); int removeConditionalWithFlag(u8 flag, bool orMode); int removeConditionalWithAddressAndFlag(u32 address, u8 flag, bool orMode); -//void freeConditionalBreak(struct ConditionalBreak* toFree); +// void freeConditionalBreak(struct ConditionalBreak* toFree); -void addCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toAdd); -//bool removeCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toDel); -//bool removeCondition(u32 address, u8 flags, u8 num); +void addCondition(struct ConditionalBreak *base, struct ConditionalBreakNode *toAdd); +// bool removeCondition(struct ConditionalBreak* base, struct ConditionalBreakNode* toDel); +// bool removeCondition(u32 address, u8 flags, u8 num); -void freeConditionalNode(struct ConditionalBreakNode* toDel); +void freeConditionalNode(struct ConditionalBreakNode *toDel); +void parseAndCreateConditionalBreaks(u32 address, u8 flags, char **exp, int n); -void parseAndCreateConditionalBreaks(u32 address, u8 flags, char** exp, int n); - -bool isCorrectBreak(struct ConditionalBreak* toTest, u8 accessType); +bool isCorrectBreak(struct ConditionalBreak *toTest, u8 accessType); bool doesBreak(u32 address, u8 allowedFlags); -bool doBreak(struct ConditionalBreak* toTest); +bool doBreak(struct ConditionalBreak *toTest); -//printing the structure(AKA list Breaks) -//void printConditionalBreak(struct ConditionalBreak* toPrint, bool printAddress); -//void printAllConditionals(); -//u8 printConditionalsFromAddress(u32 address); -//void printAllFlagConditionals(u8 flag, bool orMode); -//void printAllFlagConditionalsWithAddress(u32 address, u8 flag, bool orMode); +// printing the structure(AKA list Breaks) +// void printConditionalBreak(struct ConditionalBreak* toPrint, bool printAddress); +// void printAllConditionals(); +// u8 printConditionalsFromAddress(u32 address); +// void printAllFlagConditionals(u8 flag, bool orMode); +// void printAllFlagConditionalsWithAddress(u32 address, u8 flag, bool orMode); #endif \ No newline at end of file diff --git a/src/gba/CheatSearch.h b/src/gba/CheatSearch.h index 4f6cccd5..77d5c227 100644 --- a/src/gba/CheatSearch.h +++ b/src/gba/CheatSearch.h @@ -4,41 +4,27 @@ #include "../System.h" struct CheatSearchBlock { - int size; - u32 offset; - u8 *bits; - u8 *data; - u8 *saved; + int size; + u32 offset; + u8 *bits; + u8 *data; + u8 *saved; }; struct CheatSearchData { - int count; - CheatSearchBlock *blocks; + int count; + CheatSearchBlock *blocks; }; -enum { - SEARCH_EQ, - SEARCH_NE, - SEARCH_LT, - SEARCH_LE, - SEARCH_GT, - SEARCH_GE -}; +enum { SEARCH_EQ, SEARCH_NE, SEARCH_LT, SEARCH_LE, SEARCH_GT, SEARCH_GE }; -enum { - BITS_8, - BITS_16, - BITS_32 -}; +enum { BITS_8, BITS_16, BITS_32 }; -#define SET_BIT(bits,off) \ - (bits)[(off) >> 3] |= (1 << ((off) & 7)) +#define SET_BIT(bits, off) (bits)[(off) >> 3] |= (1 << ((off)&7)) -#define CLEAR_BIT(bits, off) \ - (bits)[(off) >> 3] &= ~(1 << ((off) & 7)) +#define CLEAR_BIT(bits, off) (bits)[(off) >> 3] &= ~(1 << ((off)&7)) -#define IS_BIT_SET(bits, off) \ - (bits)[(off) >> 3] & (1 << ((off) & 7)) +#define IS_BIT_SET(bits, off) (bits)[(off) >> 3] & (1 << ((off)&7)) extern CheatSearchData cheatSearchData; diff --git a/src/gba/Cheats.h b/src/gba/Cheats.h index f67b2261..cc7c96a5 100644 --- a/src/gba/Cheats.h +++ b/src/gba/Cheats.h @@ -4,19 +4,20 @@ #include "../common/ConfigManager.h" struct CheatsData { - int code; - int size; - int status; - bool enabled; - u32 rawaddress; - u32 address; - u32 value; - u32 oldValue; - char codestring[20]; - char desc[32]; + int code; + int size; + int status; + bool enabled; + u32 rawaddress; + u32 address; + u32 value; + u32 oldValue; + char codestring[20]; + char desc[32]; }; -void cheatsAdd(const char *codeStr, const char *desc, u32 rawaddress, u32 address, u32 value, int code, int size); +void cheatsAdd(const char *codeStr, const char *desc, u32 rawaddress, u32 address, u32 value, + int code, int size); void cheatsAddCheatCode(const char *code, const char *desc); void cheatsAddGSACode(const char *code, const char *desc, bool v3); void cheatsAddCBACode(const char *code, const char *desc); diff --git a/src/gba/EEprom.h b/src/gba/EEprom.h index 7ec94842..a6d9323c 100644 --- a/src/gba/EEprom.h +++ b/src/gba/EEprom.h @@ -2,7 +2,7 @@ #define EEPROM_H #ifdef __LIBRETRO__ -extern void eepromSaveGame(u8* &data); +extern void eepromSaveGame(u8 *&data); extern void eepromReadGame(const u8 *&data, int version); #else extern void eepromSaveGame(gzFile _gzFile); @@ -21,10 +21,10 @@ extern u8 eepromData[0x2000]; extern bool eepromInUse; extern int eepromSize; -#define EEPROM_IDLE 0 -#define EEPROM_READADDRESS 1 -#define EEPROM_READDATA 2 -#define EEPROM_READDATA2 3 -#define EEPROM_WRITEDATA 4 +#define EEPROM_IDLE 0 +#define EEPROM_READADDRESS 1 +#define EEPROM_READDATA 2 +#define EEPROM_READDATA2 3 +#define EEPROM_WRITEDATA 4 #endif // EEPROM_H diff --git a/src/gba/Flash.h b/src/gba/Flash.h index 33104290..f24780c1 100644 --- a/src/gba/Flash.h +++ b/src/gba/Flash.h @@ -4,8 +4,8 @@ #define FLASH_128K_SZ 0x20000 #ifdef __LIBRETRO__ -extern void flashSaveGame(u8 *& data); -extern void flashReadGame(const u8 *& data, int); +extern void flashSaveGame(u8 *&data); +extern void flashReadGame(const u8 *&data, int); #else extern void flashSaveGame(gzFile _gzFile); extern void flashReadGame(gzFile _gzFile, int version); diff --git a/src/gba/GBA.h b/src/gba/GBA.h index 31c6ea83..3152135d 100644 --- a/src/gba/GBA.h +++ b/src/gba/GBA.h @@ -15,46 +15,46 @@ const u64 TICKS_PER_SECOND = 16777216; #define SAVE_GAME_VERSION_8 8 #define SAVE_GAME_VERSION_9 9 #define SAVE_GAME_VERSION_10 10 -#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10 +#define SAVE_GAME_VERSION SAVE_GAME_VERSION_10 typedef struct { - u8 *address; - u32 mask; + u8 *address; + u32 mask; #ifdef BKPT_SUPPORT - u8 *breakPoints; - u8 *searchMatch; - u8* trace; - u32 size; + u8 *breakPoints; + u8 *searchMatch; + u8 *trace; + u32 size; #endif } memoryMap; typedef union { - struct { + struct { #ifdef WORDS_BIGENDIAN - u8 B3; - u8 B2; - u8 B1; - u8 B0; + u8 B3; + u8 B2; + u8 B1; + u8 B0; #else - u8 B0; - u8 B1; - u8 B2; - u8 B3; + u8 B0; + u8 B1; + u8 B2; + u8 B3; #endif - } B; - struct { + } B; + struct { #ifdef WORDS_BIGENDIAN - u16 W1; - u16 W0; + u16 W1; + u16 W0; #else - u16 W0; - u16 W1; + u16 W0; + u16 W1; #endif - } W; + } W; #ifdef WORDS_BIGENDIAN - volatile u32 I; + volatile u32 I; #else - u32 I; + u32 I; #endif } reg_pair; @@ -64,7 +64,7 @@ extern memoryMap map[256]; extern u8 biosProtected[4]; -extern void (*cpuSaveGameFunc)(u32,u8); +extern void (*cpuSaveGameFunc)(u32, u8); #ifdef BKPT_SUPPORT extern u8 freezeWorkRAM[0x40000]; @@ -73,7 +73,7 @@ extern u8 freezeVRAM[0x18000]; extern u8 freezeOAM[0x400]; extern u8 freezePRAM[0x400]; extern bool debugger_last; -extern int oldreg[18]; +extern int oldreg[18]; extern char oldbuffer[10]; extern bool debugger; #endif @@ -93,7 +93,7 @@ extern void CPUUpdateRenderBuffers(bool); extern bool CPUReadMemState(char *, int); extern bool CPUWriteMemState(char *, int); #ifdef __LIBRETRO__ -extern bool CPUReadState(const u8*, unsigned); +extern bool CPUReadState(const u8 *, unsigned); extern unsigned int CPUWriteState(u8 *data, unsigned int size); #else extern bool CPUReadState(const char *); @@ -103,12 +103,12 @@ extern int CPULoadRom(const char *); extern int CPULoadRomData(const char *data, int size); extern void doMirroring(bool); extern void CPUUpdateRegister(u32, u16); -extern void applyTimer (); -extern void CPUInit(const char *,bool); +extern void applyTimer(); +extern void CPUInit(const char *, bool); void SetSaveType(int st); extern void CPUReset(); extern void CPULoop(int); -extern void CPUCheckDMA(int,int); +extern void CPUCheckDMA(int, int); extern bool CPUIsGBAImage(const char *); extern bool CPUIsZipFile(const char *); #ifdef PROFILING @@ -117,39 +117,39 @@ extern void cpuProfil(profile_segment *seg); extern void cpuEnableProfiling(int hz); #endif -const char* GetLoadDotCodeFile(); -const char* GetSaveDotCodeFile(); +const char *GetLoadDotCodeFile(); +const char *GetSaveDotCodeFile(); void SetLoadDotCodeFile(const char *szFile); void SetSaveDotCodeFile(const char *szFile); extern struct EmulatedSystem GBASystem; -#define R13_IRQ 18 -#define R14_IRQ 19 +#define R13_IRQ 18 +#define R14_IRQ 19 #define SPSR_IRQ 20 -#define R13_USR 26 -#define R14_USR 27 -#define R13_SVC 28 -#define R14_SVC 29 +#define R13_USR 26 +#define R14_USR 27 +#define R13_SVC 28 +#define R14_SVC 29 #define SPSR_SVC 30 -#define R13_ABT 31 -#define R14_ABT 32 +#define R13_ABT 31 +#define R14_ABT 32 #define SPSR_ABT 33 -#define R13_UND 34 -#define R14_UND 35 +#define R13_UND 34 +#define R14_UND 35 #define SPSR_UND 36 -#define R8_FIQ 37 -#define R9_FIQ 38 -#define R10_FIQ 39 -#define R11_FIQ 40 -#define R12_FIQ 41 -#define R13_FIQ 42 -#define R14_FIQ 43 +#define R8_FIQ 37 +#define R9_FIQ 38 +#define R10_FIQ 39 +#define R11_FIQ 40 +#define R12_FIQ 41 +#define R13_FIQ 42 +#define R14_FIQ 43 #define SPSR_FIQ 44 #include "Cheats.h" -#include "Globals.h" #include "EEprom.h" #include "Flash.h" +#include "Globals.h" #endif // GBA_H diff --git a/src/gba/GBAGfx.h b/src/gba/GBAGfx.h index e90ef43a..a5860c52 100644 --- a/src/gba/GBAGfx.h +++ b/src/gba/GBAGfx.h @@ -13,38 +13,13 @@ extern void gfxDrawTextScreen(u16, u16, u16, u32 *); #else static void gfxDrawTextScreen(u16, u16, u16, u32 *); #endif -static void gfxDrawRotScreen(u16, - u16, u16, - u16, u16, - u16, u16, - u16, u16, - int&, int&, - int, - u32*); -static void gfxDrawRotScreen16Bit(u16, - u16, u16, - u16, u16, - u16, u16, - u16, u16, - int&, int&, - int, - u32*); -static void gfxDrawRotScreen256(u16, - u16, u16, - u16, u16, - u16, u16, - u16, u16, - int&, int&, - int, - u32*); -static void gfxDrawRotScreen16Bit160(u16, - u16, u16, - u16, u16, - u16, u16, - u16, u16, - int&, int&, - int, - u32*); +static void gfxDrawRotScreen(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int, u32 *); +static void gfxDrawRotScreen16Bit(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int, + u32 *); +static void gfxDrawRotScreen256(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int, + u32 *); +static void gfxDrawRotScreen16Bit160(u16, u16, u16, u16, u16, u16, u16, u16, u16, int &, int &, int, + u32 *); static void gfxDrawSprites(u32 *); static void gfxIncreaseBrightness(u32 *line, int coeff); static void gfxDecreaseBrightness(u32 *line, int coeff); @@ -97,1487 +72,1682 @@ extern int gfxLastVCOUNT; static inline void gfxClearArray(u32 *array) { - for(int i = 0; i < 240; i++) { - *array++ = 0x80000000; - } + for (int i = 0; i < 240; i++) { + *array++ = 0x80000000; + } } #ifndef TILED_RENDERING -static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, - u32 *line) +static inline void gfxDrawTextScreen(u16 control, u16 hofs, u16 vofs, u32 *line) { - u16 *palette = (u16 *)paletteRAM; - u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; - u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800]; - u32 prio = ((control & 3)<<25) + 0x1000000; - int sizeX = 256; - int sizeY = 256; - switch((control >> 14) & 3) { - case 0: - break; - case 1: - sizeX = 512; - break; - case 2: - sizeY = 512; - break; - case 3: - sizeX = 512; - sizeY = 512; - break; - } - - int maskX = sizeX-1; - int maskY = sizeY-1; - - bool mosaicOn = (control & 0x40) ? true : false; - - int xxx = hofs & maskX; - int yyy = (vofs + VCOUNT) & maskY; - int mosaicX = (MOSAIC & 0x000F)+1; - int mosaicY = ((MOSAIC & 0x00F0)>>4)+1; - - if(mosaicOn) { - if((VCOUNT % mosaicY) != 0) { - mosaicY = VCOUNT - (VCOUNT % mosaicY); - yyy = (vofs + mosaicY) & maskY; - } - } - - if(yyy > 255 && sizeY > 256) { - yyy &= 255; - screenBase += 0x400; - if(sizeX > 256) - screenBase += 0x400; - } - - int yshift = ((yyy>>3)<<5); - if((control) & 0x80) { - u16 *screenSource = screenBase + 0x400 * (xxx>>8) + ((xxx & 255)>>3) + yshift; - for(int x = 0; x < 240; x++) { - u16 data = READ16LE(screenSource); - - int tile = data & 0x3FF; - int tileX = (xxx & 7); - int tileY = yyy & 7; - - if(tileX == 7) - screenSource++; - - if(data & 0x0400) - tileX = 7 - tileX; - if(data & 0x0800) - tileY = 7 - tileY; - - u8 color = charBase[tile * 64 + tileY * 8 + tileX]; - - line[x] = color ? (READ16LE(&palette[color]) | prio): 0x80000000; - - xxx++; - if(xxx == 256) { - if(sizeX > 256) - screenSource = screenBase + 0x400 + yshift; - else { - screenSource = screenBase + yshift; - xxx = 0; + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u16 *screenBase = (u16 *)&vram[((control >> 8) & 0x1f) * 0x800]; + u32 prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 256; + int sizeY = 256; + switch ((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = 512; + break; + case 2: + sizeY = 512; + break; + case 3: + sizeX = 512; + sizeY = 512; + break; } - } else if(xxx >= sizeX) { - xxx = 0; - screenSource = screenBase + yshift; - } - } - } else { - u16 *screenSource = screenBase + 0x400*(xxx>>8)+((xxx&255)>>3) + - yshift; - for(int x = 0; x < 240; x++) { - u16 data = READ16LE(screenSource); - int tile = data & 0x3FF; - int tileX = (xxx & 7); - int tileY = yyy & 7; + int maskX = sizeX - 1; + int maskY = sizeY - 1; - if(tileX == 7) - screenSource++; + bool mosaicOn = (control & 0x40) ? true : false; - if(data & 0x0400) - tileX = 7 - tileX; - if(data & 0x0800) - tileY = 7 - tileY; + int xxx = hofs & maskX; + int yyy = (vofs + VCOUNT) & maskY; + int mosaicX = (MOSAIC & 0x000F) + 1; + int mosaicY = ((MOSAIC & 0x00F0) >> 4) + 1; - u8 color = charBase[(tile<<5) + (tileY<<2) + (tileX>>1)]; - - if(tileX & 1) { - color = (color >> 4); - } else { - color &= 0x0F; - } - - int pal = (data>>8) & 0xF0; - line[x] = color ? (READ16LE(&palette[pal + color])|prio): 0x80000000; - - xxx++; - if(xxx == 256) { - if(sizeX > 256) - screenSource = screenBase + 0x400 + yshift; - else { - screenSource = screenBase + yshift; - xxx = 0; + if (mosaicOn) { + if ((VCOUNT % mosaicY) != 0) { + mosaicY = VCOUNT - (VCOUNT % mosaicY); + yyy = (vofs + mosaicY) & maskY; + } } - } else if(xxx >= sizeX) { - xxx = 0; - screenSource = screenBase + yshift; - } - } - } - if(mosaicOn) { - if(mosaicX > 1) { - int m = 1; - for(int i = 0; i < 239; i++) { - line[i+1] = line[i]; - m++; - if(m == mosaicX) { - m = 1; - i++; + + if (yyy > 255 && sizeY > 256) { + yyy &= 255; + screenBase += 0x400; + if (sizeX > 256) + screenBase += 0x400; + } + + int yshift = ((yyy >> 3) << 5); + if ((control)&0x80) { + u16 *screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift; + for (int x = 0; x < 240; x++) { + u16 data = READ16LE(screenSource); + + int tile = data & 0x3FF; + int tileX = (xxx & 7); + int tileY = yyy & 7; + + if (tileX == 7) + screenSource++; + + if (data & 0x0400) + tileX = 7 - tileX; + if (data & 0x0800) + tileY = 7 - tileY; + + u8 color = charBase[tile * 64 + tileY * 8 + tileX]; + + line[x] = color ? (READ16LE(&palette[color]) | prio) : 0x80000000; + + xxx++; + if (xxx == 256) { + if (sizeX > 256) + screenSource = screenBase + 0x400 + yshift; + else { + screenSource = screenBase + yshift; + xxx = 0; + } + } else if (xxx >= sizeX) { + xxx = 0; + screenSource = screenBase + yshift; + } + } + } else { + u16 *screenSource = screenBase + 0x400 * (xxx >> 8) + ((xxx & 255) >> 3) + yshift; + for (int x = 0; x < 240; x++) { + u16 data = READ16LE(screenSource); + + int tile = data & 0x3FF; + int tileX = (xxx & 7); + int tileY = yyy & 7; + + if (tileX == 7) + screenSource++; + + if (data & 0x0400) + tileX = 7 - tileX; + if (data & 0x0800) + tileY = 7 - tileY; + + u8 color = charBase[(tile << 5) + (tileY << 2) + (tileX >> 1)]; + + if (tileX & 1) { + color = (color >> 4); + } else { + color &= 0x0F; + } + + int pal = (data >> 8) & 0xF0; + line[x] = color ? (READ16LE(&palette[pal + color]) | prio) : 0x80000000; + + xxx++; + if (xxx == 256) { + if (sizeX > 256) + screenSource = screenBase + 0x400 + yshift; + else { + screenSource = screenBase + yshift; + xxx = 0; + } + } else if (xxx >= sizeX) { + xxx = 0; + screenSource = screenBase + yshift; + } + } + } + if (mosaicOn) { + if (mosaicX > 1) { + int m = 1; + for (int i = 0; i < 239; i++) { + line[i + 1] = line[i]; + m++; + if (m == mosaicX) { + m = 1; + i++; + } + } + } } - } - } - } } #endif -static inline void gfxDrawRotScreen(u16 control, - u16 x_l, u16 x_h, - u16 y_l, u16 y_h, - u16 pa, u16 pb, - u16 pc, u16 pd, - int& currentX, int& currentY, - int changed, - u32 *line) +static inline void gfxDrawRotScreen(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, u16 pb, + u16 pc, u16 pd, int ¤tX, int ¤tY, int changed, + u32 *line) { - u16 *palette = (u16 *)paletteRAM; - u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; - u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800]; - int prio = ((control & 3) << 25) + 0x1000000; + u16 *palette = (u16 *)paletteRAM; + u8 *charBase = &vram[((control >> 2) & 0x03) * 0x4000]; + u8 *screenBase = (u8 *)&vram[((control >> 8) & 0x1f) * 0x800]; + int prio = ((control & 3) << 25) + 0x1000000; - int sizeX = 128; - int sizeY = 128; - switch((control >> 14) & 3) { - case 0: - break; - case 1: - sizeX = sizeY = 256; - break; - case 2: - sizeX = sizeY = 512; - break; - case 3: - sizeX = sizeY = 1024; - break; - } - - int maskX = sizeX-1; - int maskY = sizeY-1; - - int yshift = ((control >> 14) & 3)+4; - - int dx = pa & 0x7FFF; - if(pa & 0x8000) - dx |= 0xFFFF8000; - int dmx = pb & 0x7FFF; - if(pb & 0x8000) - dmx |= 0xFFFF8000; - int dy = pc & 0x7FFF; - if(pc & 0x8000) - dy |= 0xFFFF8000; - int dmy = pd & 0x7FFF; - if(pd & 0x8000) - dmy |= 0xFFFF8000; - - if(VCOUNT == 0) - changed = 3; - - if(changed & 1) { - currentX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - currentX |= 0xF8000000; - } else { - currentX += dmx; - } - - if(changed & 2) { - currentY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - currentY |= 0xF8000000; - } else { - currentY += dmy; - } - - int realX = currentX; - int realY = currentY; - - if(control & 0x40) { - int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; - int y = (VCOUNT % mosaicY); - realX -= y*dmx; - realY -= y*dmy; - } - - if(control & 0x2000) { - for(int x = 0; x < 240; x++) { - int xxx = (realX >> 8) & maskX; - int yyy = (realY >> 8) & maskY; - - int tile = screenBase[(xxx>>3) + ((yyy>>3)<> 8); - int yyy = (realY >> 8); - - if(xxx < 0 || - yyy < 0 || - xxx >= sizeX || - yyy >= sizeY) { - line[x] = 0x80000000; - } else { - int tile = screenBase[(xxx>>3) + ((yyy>>3)< 1) { - int m = 1; - for(int i = 0; i < 239; i++) { - line[i+1] = line[i]; - m++; - if(m == mosaicX) { - m = 1; - i++; + int sizeX = 128; + int sizeY = 128; + switch ((control >> 14) & 3) { + case 0: + break; + case 1: + sizeX = sizeY = 256; + break; + case 2: + sizeX = sizeY = 512; + break; + case 3: + sizeX = sizeY = 1024; + break; + } + + int maskX = sizeX - 1; + int maskY = sizeY - 1; + + int yshift = ((control >> 14) & 3) + 4; + + int dx = pa & 0x7FFF; + if (pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if (pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if (pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFF; + if (pd & 0x8000) + dmy |= 0xFFFF8000; + + if (VCOUNT == 0) + changed = 3; + + if (changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if (changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if (control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0) >> 4) + 1; + int y = (VCOUNT % mosaicY); + realX -= y * dmx; + realY -= y * dmy; + } + + if (control & 0x2000) { + for (int x = 0; x < 240; x++) { + int xxx = (realX >> 8) & maskX; + int yyy = (realY >> 8) & maskY; + + int tile = screenBase[(xxx >> 3) + ((yyy >> 3) << yshift)]; + + int tileX = (xxx & 7); + int tileY = yyy & 7; + + u8 color = charBase[(tile << 6) + (tileY << 3) + tileX]; + + line[x] = color ? (READ16LE(&palette[color]) | prio) : 0x80000000; + + realX += dx; + realY += dy; + } + } else { + for (int x = 0; x < 240; x++) { + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + if (xxx < 0 || yyy < 0 || xxx >= sizeX || yyy >= sizeY) { + line[x] = 0x80000000; + } else { + int tile = screenBase[(xxx >> 3) + ((yyy >> 3) << yshift)]; + + int tileX = (xxx & 7); + int tileY = yyy & 7; + + u8 color = charBase[(tile << 6) + (tileY << 3) + tileX]; + + line[x] = color ? (READ16LE(&palette[color]) | prio) : 0x80000000; + } + realX += dx; + realY += dy; + } + } + + if (control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if (mosaicX > 1) { + int m = 1; + for (int i = 0; i < 239; i++) { + line[i + 1] = line[i]; + m++; + if (m == mosaicX) { + m = 1; + i++; + } + } + } } - } - } - } } -static inline void gfxDrawRotScreen16Bit(u16 control, - u16 x_l, u16 x_h, - u16 y_l, u16 y_h, - u16 pa, u16 pb, - u16 pc, u16 pd, - int& currentX, int& currentY, - int changed, - u32 *line) +static inline void gfxDrawRotScreen16Bit(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, + u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY, + int changed, u32 *line) { - u16 *screenBase = (u16 *)&vram[0]; - int prio = ((control & 3) << 25) + 0x1000000; - int sizeX = 240; - int sizeY = 160; + u16 *screenBase = (u16 *)&vram[0]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 240; + int sizeY = 160; - int startX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - startX |= 0xF8000000; - int startY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - startY |= 0xF8000000; + int startX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + startY |= 0xF8000000; - int dx = pa & 0x7FFF; - if(pa & 0x8000) - dx |= 0xFFFF8000; - int dmx = pb & 0x7FFF; - if(pb & 0x8000) - dmx |= 0xFFFF8000; - int dy = pc & 0x7FFF; - if(pc & 0x8000) - dy |= 0xFFFF8000; - int dmy = pd & 0x7FFF; - if(pd & 0x8000) - dmy |= 0xFFFF8000; + int dx = pa & 0x7FFF; + if (pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if (pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if (pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFF; + if (pd & 0x8000) + dmy |= 0xFFFF8000; - if(VCOUNT == 0) - changed = 3; + if (VCOUNT == 0) + changed = 3; - if(changed & 1) { - currentX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - currentX |= 0xF8000000; - } else - currentX += dmx; + if (changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + currentX |= 0xF8000000; + } else + currentX += dmx; - if(changed & 2) { - currentY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - currentY |= 0xF8000000; - } else { - currentY += dmy; - } - - int realX = currentX; - int realY = currentY; - - if(control & 0x40) { - int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; - int y = (VCOUNT % mosaicY); - realX -= y*dmx; - realY -= y*dmy; - } - - int xxx = (realX >> 8); - int yyy = (realY >> 8); - - for(int x = 0; x < 240; x++) { - if(xxx < 0 || - yyy < 0 || - xxx >= sizeX || - yyy >= sizeY) { - line[x] = 0x80000000; - } else { - line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); - } - realX += dx; - realY += dy; - - xxx = (realX >> 8); - yyy = (realY >> 8); - } - - if(control & 0x40) { - int mosaicX = (MOSAIC & 0xF) + 1; - if(mosaicX > 1) { - int m = 1; - for(int i = 0; i < 239; i++) { - line[i+1] = line[i]; - m++; - if(m == mosaicX) { - m = 1; - i++; + if (changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if (control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0) >> 4) + 1; + int y = (VCOUNT % mosaicY); + realX -= y * dmx; + realY -= y * dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for (int x = 0; x < 240; x++) { + if (xxx < 0 || yyy < 0 || xxx >= sizeX || yyy >= sizeY) { + line[x] = 0x80000000; + } else { + line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if (control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if (mosaicX > 1) { + int m = 1; + for (int i = 0; i < 239; i++) { + line[i + 1] = line[i]; + m++; + if (m == mosaicX) { + m = 1; + i++; + } + } + } } - } - } - } } -static inline void gfxDrawRotScreen256(u16 control, - u16 x_l, u16 x_h, - u16 y_l, u16 y_h, - u16 pa, u16 pb, - u16 pc, u16 pd, - int ¤tX, int& currentY, - int changed, - u32 *line) +static inline void gfxDrawRotScreen256(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, + u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY, + int changed, u32 *line) { - u16 *palette = (u16 *)paletteRAM; - u8 *screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000]; - int prio = ((control & 3) << 25) + 0x1000000; - int sizeX = 240; - int sizeY = 160; + u16 *palette = (u16 *)paletteRAM; + u8 *screenBase = (DISPCNT & 0x0010) ? &vram[0xA000] : &vram[0x0000]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 240; + int sizeY = 160; - int startX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - startX |= 0xF8000000; - int startY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - startY |= 0xF8000000; + int startX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + startY |= 0xF8000000; - int dx = pa & 0x7FFF; - if(pa & 0x8000) - dx |= 0xFFFF8000; - int dmx = pb & 0x7FFF; - if(pb & 0x8000) - dmx |= 0xFFFF8000; - int dy = pc & 0x7FFF; - if(pc & 0x8000) - dy |= 0xFFFF8000; - int dmy = pd & 0x7FFF; - if(pd & 0x8000) - dmy |= 0xFFFF8000; + int dx = pa & 0x7FFF; + if (pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if (pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if (pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFF; + if (pd & 0x8000) + dmy |= 0xFFFF8000; - if(VCOUNT == 0) - changed = 3; + if (VCOUNT == 0) + changed = 3; - if(changed & 1) { - currentX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - currentX |= 0xF8000000; - } else { - currentX += dmx; - } - - if(changed & 2) { - currentY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - currentY |= 0xF8000000; - } else { - currentY += dmy; - } - - int realX = currentX; - int realY = currentY; - - if(control & 0x40) { - int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; - int y = VCOUNT - (VCOUNT % mosaicY); - realX = startX + y*dmx; - realY = startY + y*dmy; - } - - int xxx = (realX >> 8); - int yyy = (realY >> 8); - - for(int x = 0; x < 240; x++) { - if(xxx < 0 || - yyy < 0 || - xxx >= sizeX || - yyy >= sizeY) { - line[x] = 0x80000000; - } else { - u8 color = screenBase[yyy * 240 + xxx]; - - line[x] = color ? (READ16LE(&palette[color])|prio): 0x80000000; - } - realX += dx; - realY += dy; - - xxx = (realX >> 8); - yyy = (realY >> 8); - } - - if(control & 0x40) { - int mosaicX = (MOSAIC & 0xF) + 1; - if(mosaicX > 1) { - int m = 1; - for(int i = 0; i < 239; i++) { - line[i+1] = line[i]; - m++; - if(m == mosaicX) { - m = 1; - i++; + if (changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if (changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if (control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0) >> 4) + 1; + int y = VCOUNT - (VCOUNT % mosaicY); + realX = startX + y * dmx; + realY = startY + y * dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for (int x = 0; x < 240; x++) { + if (xxx < 0 || yyy < 0 || xxx >= sizeX || yyy >= sizeY) { + line[x] = 0x80000000; + } else { + u8 color = screenBase[yyy * 240 + xxx]; + + line[x] = color ? (READ16LE(&palette[color]) | prio) : 0x80000000; + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if (control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if (mosaicX > 1) { + int m = 1; + for (int i = 0; i < 239; i++) { + line[i + 1] = line[i]; + m++; + if (m == mosaicX) { + m = 1; + i++; + } + } + } } - } - } - } } -static inline void gfxDrawRotScreen16Bit160(u16 control, - u16 x_l, u16 x_h, - u16 y_l, u16 y_h, - u16 pa, u16 pb, - u16 pc, u16 pd, - int& currentX, int& currentY, - int changed, - u32 *line) +static inline void gfxDrawRotScreen16Bit160(u16 control, u16 x_l, u16 x_h, u16 y_l, u16 y_h, u16 pa, + u16 pb, u16 pc, u16 pd, int ¤tX, int ¤tY, + int changed, u32 *line) { - u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] : - (u16 *)&vram[0]; - int prio = ((control & 3) << 25) + 0x1000000; - int sizeX = 160; - int sizeY = 128; + u16 *screenBase = (DISPCNT & 0x0010) ? (u16 *)&vram[0xa000] : (u16 *)&vram[0]; + int prio = ((control & 3) << 25) + 0x1000000; + int sizeX = 160; + int sizeY = 128; - int startX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - startX |= 0xF8000000; - int startY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - startY |= 0xF8000000; + int startX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + startX |= 0xF8000000; + int startY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + startY |= 0xF8000000; - int dx = pa & 0x7FFF; - if(pa & 0x8000) - dx |= 0xFFFF8000; - int dmx = pb & 0x7FFF; - if(pb & 0x8000) - dmx |= 0xFFFF8000; - int dy = pc & 0x7FFF; - if(pc & 0x8000) - dy |= 0xFFFF8000; - int dmy = pd & 0x7FFF; - if(pd & 0x8000) - dmy |= 0xFFFF8000; + int dx = pa & 0x7FFF; + if (pa & 0x8000) + dx |= 0xFFFF8000; + int dmx = pb & 0x7FFF; + if (pb & 0x8000) + dmx |= 0xFFFF8000; + int dy = pc & 0x7FFF; + if (pc & 0x8000) + dy |= 0xFFFF8000; + int dmy = pd & 0x7FFF; + if (pd & 0x8000) + dmy |= 0xFFFF8000; - if(VCOUNT == 0) - changed = 3; + if (VCOUNT == 0) + changed = 3; - if(changed & 1) { - currentX = (x_l) | ((x_h & 0x07FF)<<16); - if(x_h & 0x0800) - currentX |= 0xF8000000; - } else { - currentX += dmx; - } - - if(changed & 2) { - currentY = (y_l) | ((y_h & 0x07FF)<<16); - if(y_h & 0x0800) - currentY |= 0xF8000000; - } else { - currentY += dmy; - } - - int realX = currentX; - int realY = currentY; - - if(control & 0x40) { - int mosaicY = ((MOSAIC & 0xF0)>>4) + 1; - int y = VCOUNT - (VCOUNT % mosaicY); - realX = startX + y*dmx; - realY = startY + y*dmy; - } - - int xxx = (realX >> 8); - int yyy = (realY >> 8); - - for(int x = 0; x < 240; x++) { - if(xxx < 0 || - yyy < 0 || - xxx >= sizeX || - yyy >= sizeY) { - line[x] = 0x80000000; - } else { - line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); - } - realX += dx; - realY += dy; - - xxx = (realX >> 8); - yyy = (realY >> 8); - } - - if(control & 0x40) { - int mosaicX = (MOSAIC & 0xF) + 1; - if(mosaicX > 1) { - int m = 1; - for(int i = 0; i < 239; i++) { - line[i+1] = line[i]; - m++; - if(m == mosaicX) { - m = 1; - i++; + if (changed & 1) { + currentX = (x_l) | ((x_h & 0x07FF) << 16); + if (x_h & 0x0800) + currentX |= 0xF8000000; + } else { + currentX += dmx; + } + + if (changed & 2) { + currentY = (y_l) | ((y_h & 0x07FF) << 16); + if (y_h & 0x0800) + currentY |= 0xF8000000; + } else { + currentY += dmy; + } + + int realX = currentX; + int realY = currentY; + + if (control & 0x40) { + int mosaicY = ((MOSAIC & 0xF0) >> 4) + 1; + int y = VCOUNT - (VCOUNT % mosaicY); + realX = startX + y * dmx; + realY = startY + y * dmy; + } + + int xxx = (realX >> 8); + int yyy = (realY >> 8); + + for (int x = 0; x < 240; x++) { + if (xxx < 0 || yyy < 0 || xxx >= sizeX || yyy >= sizeY) { + line[x] = 0x80000000; + } else { + line[x] = (READ16LE(&screenBase[yyy * sizeX + xxx]) | prio); + } + realX += dx; + realY += dy; + + xxx = (realX >> 8); + yyy = (realY >> 8); + } + + if (control & 0x40) { + int mosaicX = (MOSAIC & 0xF) + 1; + if (mosaicX > 1) { + int m = 1; + for (int i = 0; i < 239; i++) { + line[i + 1] = line[i]; + m++; + if (m == mosaicX) { + m = 1; + i++; + } + } + } } - } - } - } } static inline void gfxDrawSprites(u32 *lineOBJ) { - // lineOBJpix is used to keep track of the drawn OBJs - // and to stop drawing them if the 'maximum number of OBJ per line' - // has been reached. - int lineOBJpix = (DISPCNT & 0x20) ? 954 : 1226; - int m=0; - gfxClearArray(lineOBJ); - if(layerEnable & 0x1000) { - u16 *sprites = (u16 *)oam; - u16 *spritePalette = &((u16 *)paletteRAM)[256]; - int mosaicY = ((MOSAIC & 0xF000)>>12) + 1; - int mosaicX = ((MOSAIC & 0xF00)>>8) + 1; - for(int x = 0; x < 128 ; x++) { - u16 a0 = READ16LE(sprites++); - u16 a1 = READ16LE(sprites++); - u16 a2 = READ16LE(sprites++); - sprites++; + // lineOBJpix is used to keep track of the drawn OBJs + // and to stop drawing them if the 'maximum number of OBJ per line' + // has been reached. + int lineOBJpix = (DISPCNT & 0x20) ? 954 : 1226; + int m = 0; + gfxClearArray(lineOBJ); + if (layerEnable & 0x1000) { + u16 *sprites = (u16 *)oam; + u16 *spritePalette = &((u16 *)paletteRAM)[256]; + int mosaicY = ((MOSAIC & 0xF000) >> 12) + 1; + int mosaicX = ((MOSAIC & 0xF00) >> 8) + 1; + for (int x = 0; x < 128; x++) { + u16 a0 = READ16LE(sprites++); + u16 a1 = READ16LE(sprites++); + u16 a2 = READ16LE(sprites++); + sprites++; - lineOBJpixleft[x]=lineOBJpix; + lineOBJpixleft[x] = lineOBJpix; - lineOBJpix-=2; - if (lineOBJpix<=0) - continue; + lineOBJpix -= 2; + if (lineOBJpix <= 0) + continue; - if ((a0 & 0x0c00) == 0x0c00) - a0 &=0xF3FF; + if ((a0 & 0x0c00) == 0x0c00) + a0 &= 0xF3FF; - if ((a0>>14) == 3) - { - a0 &= 0x3FFF; - a1 &= 0x3FFF; - } + if ((a0 >> 14) == 3) { + a0 &= 0x3FFF; + a1 &= 0x3FFF; + } - int sizeX = 8<<(a1>>14); - int sizeY = sizeX; + int sizeX = 8 << (a1 >> 14); + int sizeY = sizeX; - if ((a0>>14) & 1) - { - if (sizeX<32) - sizeX<<=1; - if (sizeY>8) - sizeY>>=1; - } - else if ((a0>>14) & 2) - { - if (sizeX>8) - sizeX>>=1; - if (sizeY<32) - sizeY<<=1; - } + if ((a0 >> 14) & 1) { + if (sizeX < 32) + sizeX <<= 1; + if (sizeY > 8) + sizeY >>= 1; + } else if ((a0 >> 14) & 2) { + if (sizeX > 8) + sizeX >>= 1; + if (sizeY < 32) + sizeY <<= 1; + } #ifdef SPRITE_DEBUG - int maskX = sizeX-1; - int maskY = sizeY-1; + int maskX = sizeX - 1; + int maskY = sizeY - 1; #endif - int sy = (a0 & 255); - int sx = (a1 & 0x1FF); + int sy = (a0 & 255); + int sx = (a1 & 0x1FF); - // computes ticks used by OBJ-WIN if OBJWIN is enabled - if (((a0 & 0x0c00) == 0x0800) && (layerEnable & 0x8000)) - { - if ((a0 & 0x0300) == 0x0300) - { - sizeX<<=1; - sizeY<<=1; - } - if((sy+sizeY) > 256) - sy -= 256; - if ((sx+sizeX)> 512) - sx-=512; - if (sx<0) - { - sizeX+=sx; - sx = 0; - } - else if ((sx+sizeX)>240) - sizeX=240-sx; - if ((VCOUNT>=sy) && (VCOUNT 256) + sy -= 256; + if ((sx + sizeX) > 512) + sx -= 512; + if (sx < 0) { + sizeX += sx; + sx = 0; + } else if ((sx + sizeX) > 240) + sizeX = 240 - sx; + if ((VCOUNT >= sy) && (VCOUNT < sy + sizeY) && (sx < 240)) { + if (a0 & 0x0100) + lineOBJpix -= 8 + 2 * sizeX; + else + lineOBJpix -= sizeX - 2; + } + continue; + } + // else ignores OBJ-WIN if OBJWIN is disabled, and ignored disabled OBJ + else if (((a0 & 0x0c00) == 0x0800) || ((a0 & 0x0300) == 0x0200)) + continue; - if (lineOBJpix<0) - continue; + if (lineOBJpix < 0) + continue; + if (a0 & 0x0100) { + int fieldX = sizeX; + int fieldY = sizeY; + if (a0 & 0x0200) { + fieldX <<= 1; + fieldY <<= 1; + } + if ((sy + fieldY) > 256) + sy -= 256; + int t = VCOUNT - sy; + if ((t >= 0) && (t < fieldY)) { + int startpix = 0; + if ((sx + fieldX) > 512) { + startpix = 512 - sx; + } + if (lineOBJpix > 0) + if ((sx < 240) || startpix) { + lineOBJpix -= 8; + // int t2 = t - (fieldY >> 1); + int rot = (a1 >> 9) & 0x1F; + u16 *OAM = (u16 *)oam; + int dx = READ16LE(&OAM[3 + (rot << 4)]); + if (dx & 0x8000) + dx |= 0xFFFF8000; + int dmx = READ16LE(&OAM[7 + (rot << 4)]); + if (dmx & 0x8000) + dmx |= 0xFFFF8000; + int dy = READ16LE(&OAM[11 + (rot << 4)]); + if (dy & 0x8000) + dy |= 0xFFFF8000; + int dmy = READ16LE(&OAM[15 + (rot << 4)]); + if (dmy & 0x8000) + dmy |= 0xFFFF8000; + if (a0 & 0x1000) { + t -= (t % mosaicY); + } - if(a0 & 0x0100) { - int fieldX = sizeX; - int fieldY = sizeY; - if(a0 & 0x0200) { - fieldX <<= 1; - fieldY <<= 1; - } - if((sy+fieldY) > 256) - sy -= 256; - int t = VCOUNT - sy; - if((t >= 0) && (t < fieldY)) { - int startpix = 0; - if ((sx+fieldX)> 512) - { - startpix=512-sx; - } - if (lineOBJpix>0) - if((sx < 240) || startpix) { - lineOBJpix-=8; - // int t2 = t - (fieldY >> 1); - int rot = (a1 >> 9) & 0x1F; - u16 *OAM = (u16 *)oam; - int dx = READ16LE(&OAM[3 + (rot << 4)]); - if(dx & 0x8000) - dx |= 0xFFFF8000; - int dmx = READ16LE(&OAM[7 + (rot << 4)]); - if(dmx & 0x8000) - dmx |= 0xFFFF8000; - int dy = READ16LE(&OAM[11 + (rot << 4)]); - if(dy & 0x8000) - dy |= 0xFFFF8000; - int dmy = READ16LE(&OAM[15 + (rot << 4)]); - if(dmy & 0x8000) - dmy |= 0xFFFF8000; + int realX = ((sizeX) << 7) - + (fieldX >> 1) * dx - + (fieldY >> 1) * dmx + t * dmx; + int realY = ((sizeY) << 7) - + (fieldX >> 1) * dy - + (fieldY >> 1) * dmy + t * dmy; - if(a0 & 0x1000) { - t -= (t % mosaicY); - } + u32 prio = (((a2 >> 10) & 3) << 25) | + ((a0 & 0x0c00) << 6); - int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx - + t * dmx; - int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy - + t * dmy; + if (a0 & 0x2000) { + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + int inc = 32; + if (DISPCNT & 0x40) + inc = sizeX >> 2; + else + c &= 0x3FE; + for (int x = 0; x < fieldX; x++) { + if (x >= startpix) + lineOBJpix -= 2; + if (lineOBJpix < 0) + continue; + int xxx = realX >> 8; + int yyy = realY >> 8; - u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); + if (xxx < 0 || + xxx >= sizeX || + yyy < 0 || + yyy >= sizeY || + sx >= 240) + ; + else { + u32 color = vram + [0x10000 + + ((((c + + (yyy >> + 3) * + inc) + << 5) + + ((yyy & 7) + << 3) + + ((xxx >> 3) + << 6) + + (xxx & 7)) & + 0x7FFF)]; + if ((color == 0) && + (((prio >> 25) & + 3) < + ((lineOBJ + [sx] >> + 25) & + 3))) { + lineOBJ[sx] = + (lineOBJ + [sx] & + 0xF9FFFFFF) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } else if ( + (color) && + (prio < + (lineOBJ[sx] & + 0xFF000000))) { + lineOBJ[sx] = + READ16LE( + &spritePalette + [color]) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } - if(a0 & 0x2000) { - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - int inc = 32; - if(DISPCNT & 0x40) - inc = sizeX >> 2; - else - c &= 0x3FE; - for(int x = 0; x < fieldX; x++) { - if (x >= startpix) - lineOBJpix-=2; - if (lineOBJpix<0) - continue; - int xxx = realX >> 8; - int yyy = realY >> 8; - - if(xxx < 0 || xxx >= sizeX || - yyy < 0 || yyy >= sizeY || - sx >= 240); - else { - u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) - + ((yyy & 7)<<3) + ((xxx >> 3)<<6) + - (xxx & 7))&0x7FFF)]; - if ((color==0) && (((prio >> 25)&3) < - ((lineOBJ[sx]>>25)&3))) { - lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { - lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } - - if (a0 & 0x1000) { - m++; - if (m==mosaicX) - m=0; - } + if (a0 & 0x1000) { + m++; + if (m == + mosaicX) + m = 0; + } #ifdef SPRITE_DEBUG - if(t == 0 || t == maskY || x == 0 || x == maskX) - lineOBJ[sx] = 0x001F; + if (t == 0 || + t == maskY || + x == 0 || + x == maskX) + lineOBJ[sx] = + 0x001F; #endif - } - sx = (sx+1)&511; - realX += dx; - realY += dy; - } - } else { - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; + } + sx = (sx + 1) & 511; + realX += dx; + realY += dy; + } + } else { + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; - int inc = 32; - if(DISPCNT & 0x40) - inc = sizeX >> 3; - int palette = (a2 >> 8) & 0xF0; - for(int x = 0; x < fieldX; x++) { - if (x >= startpix) - lineOBJpix-=2; - if (lineOBJpix<0) - continue; - int xxx = realX >> 8; - int yyy = realY >> 8; - if(xxx < 0 || xxx >= sizeX || - yyy < 0 || yyy >= sizeY || - sx >= 240); - else { - u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) - + ((yyy & 7)<<2) + ((xxx >> 3)<<5) + - ((xxx & 7)>>1))&0x7FFF)]; - if(xxx & 1) - color >>= 4; - else - color &= 0x0F; + int inc = 32; + if (DISPCNT & 0x40) + inc = sizeX >> 3; + int palette = (a2 >> 8) & 0xF0; + for (int x = 0; x < fieldX; x++) { + if (x >= startpix) + lineOBJpix -= 2; + if (lineOBJpix < 0) + continue; + int xxx = realX >> 8; + int yyy = realY >> 8; + if (xxx < 0 || + xxx >= sizeX || + yyy < 0 || + yyy >= sizeY || + sx >= 240) + ; + else { + u32 color = vram + [0x10000 + + ((((c + + (yyy >> + 3) * + inc) + << 5) + + ((yyy & 7) + << 2) + + ((xxx >> 3) + << 5) + + ((xxx & 7) >> + 1)) & + 0x7FFF)]; + if (xxx & 1) + color >>= 4; + else + color &= + 0x0F; - if ((color==0) && (((prio >> 25)&3) < - ((lineOBJ[sx]>>25)&3))) { - lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { - lineOBJ[sx] = READ16LE(&spritePalette[palette+color]) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } - } - if((a0 & 0x1000) && m) { - m++; - if (m==mosaicX) - m=0; - } + if ((color == 0) && + (((prio >> 25) & + 3) < + ((lineOBJ + [sx] >> + 25) & + 3))) { + lineOBJ[sx] = + (lineOBJ + [sx] & + 0xF9FFFFFF) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } else if ( + (color) && + (prio < + (lineOBJ[sx] & + 0xFF000000))) { + lineOBJ[sx] = + READ16LE( + &spritePalette + [palette + + color]) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } + } + if ((a0 & 0x1000) && m) { + m++; + if (m == mosaicX) + m = 0; + } #ifdef SPRITE_DEBUG - if(t == 0 || t == maskY || x == 0 || x == maskX) - lineOBJ[sx] = 0x001F; + if (t == 0 || t == maskY || + x == 0 || x == maskX) + lineOBJ[sx] = + 0x001F; #endif - sx = (sx+1)&511; - realX += dx; - realY += dy; + sx = (sx + 1) & 511; + realX += dx; + realY += dy; + } + } + } + } + } else { + if (sy + sizeY > 256) + sy -= 256; + int t = VCOUNT - sy; + if ((t >= 0) && (t < sizeY)) { + int startpix = 0; + if ((sx + sizeX) > 512) { + startpix = 512 - sx; + } + if ((sx < 240) || startpix) { + lineOBJpix += 2; + if (a0 & 0x2000) { + if (a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; - } - } - } + int inc = 32; + if (DISPCNT & 0x40) { + inc = sizeX >> 2; + } else { + c &= 0x3FE; + } + int xxx = 0; + if (a1 & 0x1000) + xxx = sizeX - 1; + + if (a0 & 0x1000) { + t -= (t % mosaicY); + } + + int address = + 0x10000 + + ((((c + (t >> 3) * inc) << 5) + + ((t & 7) << 3) + ((xxx >> 3) << 6) + + (xxx & 7)) & + 0x7FFF); + + if (a1 & 0x1000) + xxx = 7; + u32 prio = (((a2 >> 10) & 3) << 25) | + ((a0 & 0x0c00) << 6); + + for (int xx = 0; xx < sizeX; xx++) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = vram[address]; + if ((color == 0) && + (((prio >> 25) & 3) < + ((lineOBJ[sx] >> 25) & + 3))) { + lineOBJ[sx] = + (lineOBJ[sx] & + 0xF9FFFFFF) | + prio; + if ((a0 & 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } else if ((color) && + (prio < + (lineOBJ[sx] & + 0xFF000000))) { + lineOBJ[sx] = + READ16LE( + &spritePalette + [color]) | + prio; + if ((a0 & 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } + + if (a0 & 0x1000) { + m++; + if (m == mosaicX) + m = 0; + } + +#ifdef SPRITE_DEBUG + if (t == 0 || t == maskY || + xx == 0 || xx == maskX) + lineOBJ[sx] = + 0x001F; +#endif + } + + sx = (sx + 1) & 511; + if (a1 & 0x1000) { + xxx--; + address--; + if (xxx == -1) { + address -= 56; + xxx = 7; + } + if (address < 0x10000) + address += 0x8000; + } else { + xxx++; + address++; + if (xxx == 8) { + address += 56; + xxx = 0; + } + if (address > 0x17fff) + address -= 0x8000; + } + } + } else { + if (a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if (DISPCNT & 0x40) { + inc = sizeX >> 3; + } + int xxx = 0; + if (a1 & 0x1000) + xxx = sizeX - 1; + + if (a0 & 0x1000) { + t -= (t % mosaicY); + } + + int address = + 0x10000 + + ((((c + (t >> 3) * inc) << 5) + + ((t & 7) << 2) + ((xxx >> 3) << 5) + + ((xxx & 7) >> 1)) & + 0x7FFF); + u32 prio = (((a2 >> 10) & 3) << 25) | + ((a0 & 0x0c00) << 6); + int palette = (a2 >> 8) & 0xF0; + if (a1 & 0x1000) { + xxx = 7; + for (int xx = sizeX - 1; xx >= 0; + xx--) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = + vram[address]; + if (xx & 1) { + color = + (color >> + 4); + } else + color &= + 0x0F; + + if ((color == 0) && + (((prio >> 25) & + 3) < + ((lineOBJ + [sx] >> + 25) & + 3))) { + lineOBJ[sx] = + (lineOBJ + [sx] & + 0xF9FFFFFF) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } else if ( + (color) && + (prio < + (lineOBJ[sx] & + 0xFF000000))) { + lineOBJ[sx] = + READ16LE( + &spritePalette + [palette + + color]) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } + } + if (a0 & 0x1000) { + m++; + if (m == mosaicX) + m = 0; + } +#ifdef SPRITE_DEBUG + if (t == 0 || t == maskY || + xx == 0 || xx == maskX) + lineOBJ[sx] = + 0x001F; +#endif + sx = (sx + 1) & 511; + xxx--; + if (!(xx & 1)) + address--; + if (xxx == -1) { + xxx = 7; + address -= 28; + } + if (address < 0x10000) + address += 0x8000; + } + } else { + for (int xx = 0; xx < sizeX; xx++) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = + vram[address]; + if (xx & 1) { + color = + (color >> + 4); + } else + color &= + 0x0F; + + if ((color == 0) && + (((prio >> 25) & + 3) < + ((lineOBJ + [sx] >> + 25) & + 3))) { + lineOBJ[sx] = + (lineOBJ + [sx] & + 0xF9FFFFFF) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } else if ( + (color) && + (prio < + (lineOBJ[sx] & + 0xFF000000))) { + lineOBJ[sx] = + READ16LE( + &spritePalette + [palette + + color]) | + prio; + if ((a0 & + 0x1000) && + m) + lineOBJ[sx] = + (lineOBJ + [sx - + 1] & + 0xF9FFFFFF) | + prio; + } + } + if (a0 & 0x1000) { + m++; + if (m == mosaicX) + m = 0; + } +#ifdef SPRITE_DEBUG + if (t == 0 || t == maskY || + xx == 0 || xx == maskX) + lineOBJ[sx] = + 0x001F; +#endif + sx = (sx + 1) & 511; + xxx++; + if (xx & 1) + address++; + if (xxx == 8) { + address += 28; + xxx = 0; + } + if (address > 0x17fff) + address -= 0x8000; + } + } + } + } + } + } + } } - } else { - if(sy+sizeY > 256) - sy -= 256; - int t = VCOUNT - sy; - if((t >= 0) && (t < sizeY)) { - int startpix = 0; - if ((sx+sizeX)> 512) - { - startpix=512-sx; - } - if((sx < 240) || startpix) { - lineOBJpix+=2; - if(a0 & 0x2000) { - if(a1 & 0x2000) - t = sizeY - t - 1; - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - - int inc = 32; - if(DISPCNT & 0x40) { - inc = sizeX >> 2; - } else { - c &= 0x3FE; - } - int xxx = 0; - if(a1 & 0x1000) - xxx = sizeX-1; - - if(a0 & 0x1000) { - t -= (t % mosaicY); - } - - int address = 0x10000 + ((((c+ (t>>3) * inc) << 5) - + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7)) & 0x7FFF); - - if(a1 & 0x1000) - xxx = 7; - u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); - - for(int xx = 0; xx < sizeX; xx++) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if ((color==0) && (((prio >> 25)&3) < - ((lineOBJ[sx]>>25)&3))) { - lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { - lineOBJ[sx] = READ16LE(&spritePalette[color]) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } - - if (a0 & 0x1000) { - m++; - if (m==mosaicX) - m=0; - } - -#ifdef SPRITE_DEBUG - if(t == 0 || t == maskY || xx == 0 || xx == maskX) - lineOBJ[sx] = 0x001F; -#endif - } - - sx = (sx+1) & 511; - if(a1 & 0x1000) { - xxx--; - address--; - if(xxx == -1) { - address -= 56; - xxx = 7; - } - if(address < 0x10000) - address += 0x8000; - } else { - xxx++; - address++; - if(xxx == 8) { - address += 56; - xxx = 0; - } - if(address > 0x17fff) - address -= 0x8000; - } - } - } else { - if(a1 & 0x2000) - t = sizeY - t - 1; - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - - int inc = 32; - if(DISPCNT & 0x40) { - inc = sizeX >> 3; - } - int xxx = 0; - if(a1 & 0x1000) - xxx = sizeX - 1; - - if(a0 & 0x1000) { - t -= (t % mosaicY); - } - - int address = 0x10000 + ((((c + (t>>3) * inc)<<5) - + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7FFF); - u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); - int palette = (a2 >> 8) & 0xF0; - if(a1 & 0x1000) { - xxx = 7; - for(int xx = sizeX - 1; xx >= 0; xx--) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if(xx & 1) { - color = (color >> 4); - } else - color &= 0x0F; - - if ((color==0) && (((prio >> 25)&3) < - ((lineOBJ[sx]>>25)&3))) { - lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { - lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } - } - if (a0 & 0x1000) { - m++; - if (m==mosaicX) - m=0; - } -#ifdef SPRITE_DEBUG - if(t == 0 || t == maskY || xx == 0 || xx == maskX) - lineOBJ[sx] = 0x001F; -#endif - sx = (sx+1) & 511; - xxx--; - if(!(xx & 1)) - address--; - if(xxx == -1) { - xxx = 7; - address -= 28; - } - if(address < 0x10000) - address += 0x8000; - } - } else { - for(int xx = 0; xx < sizeX; xx++) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if(xx & 1) { - color = (color >> 4); - } else - color &= 0x0F; - - if ((color==0) && (((prio >> 25)&3) < - ((lineOBJ[sx]>>25)&3))) { - lineOBJ[sx] = (lineOBJ[sx] & 0xF9FFFFFF) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - } else if((color) && (prio < (lineOBJ[sx]&0xFF000000))) { - lineOBJ[sx] = READ16LE(&spritePalette[palette + color]) | prio; - if((a0 & 0x1000) && m) - lineOBJ[sx]=(lineOBJ[sx-1] & 0xF9FFFFFF) | prio; - - } - } - if (a0 & 0x1000) { - m++; - if (m==mosaicX) - m=0; - } -#ifdef SPRITE_DEBUG - if(t == 0 || t == maskY || xx == 0 || xx == maskX) - lineOBJ[sx] = 0x001F; -#endif - sx = (sx+1) & 511; - xxx++; - if(xx & 1) - address++; - if(xxx == 8) { - address += 28; - xxx = 0; - } - if(address > 0x17fff) - address -= 0x8000; - } - } - } - } - } - } - } - } } static inline void gfxDrawOBJWin(u32 *lineOBJWin) { - gfxClearArray(lineOBJWin); - if((layerEnable & 0x9000) == 0x9000) { - u16 *sprites = (u16 *)oam; - // u16 *spritePalette = &((u16 *)paletteRAM)[256]; - for(int x = 0; x < 128 ; x++) { - int lineOBJpix = lineOBJpixleft[x]; - u16 a0 = READ16LE(sprites++); - u16 a1 = READ16LE(sprites++); - u16 a2 = READ16LE(sprites++); - sprites++; + gfxClearArray(lineOBJWin); + if ((layerEnable & 0x9000) == 0x9000) { + u16 *sprites = (u16 *)oam; + // u16 *spritePalette = &((u16 *)paletteRAM)[256]; + for (int x = 0; x < 128; x++) { + int lineOBJpix = lineOBJpixleft[x]; + u16 a0 = READ16LE(sprites++); + u16 a1 = READ16LE(sprites++); + u16 a2 = READ16LE(sprites++); + sprites++; - if (lineOBJpix<=0) - continue; + if (lineOBJpix <= 0) + continue; - // ignores non OBJ-WIN and disabled OBJ-WIN - if(((a0 & 0x0c00) != 0x0800) || ((a0 & 0x0300) == 0x0200)) - continue; + // ignores non OBJ-WIN and disabled OBJ-WIN + if (((a0 & 0x0c00) != 0x0800) || ((a0 & 0x0300) == 0x0200)) + continue; - if ((a0 & 0x0c00) == 0x0c00) - a0 &=0xF3FF; + if ((a0 & 0x0c00) == 0x0c00) + a0 &= 0xF3FF; - if ((a0>>14) == 3) - { - a0 &= 0x3FFF; - a1 &= 0x3FFF; - } + if ((a0 >> 14) == 3) { + a0 &= 0x3FFF; + a1 &= 0x3FFF; + } - int sizeX = 8<<(a1>>14); - int sizeY = sizeX; + int sizeX = 8 << (a1 >> 14); + int sizeY = sizeX; - if ((a0>>14) & 1) - { - if (sizeX<32) - sizeX<<=1; - if (sizeY>8) - sizeY>>=1; - } - else if ((a0>>14) & 2) - { - if (sizeX>8) - sizeX>>=1; - if (sizeY<32) - sizeY<<=1; - } + if ((a0 >> 14) & 1) { + if (sizeX < 32) + sizeX <<= 1; + if (sizeY > 8) + sizeY >>= 1; + } else if ((a0 >> 14) & 2) { + if (sizeX > 8) + sizeX >>= 1; + if (sizeY < 32) + sizeY <<= 1; + } - int sy = (a0 & 255); + int sy = (a0 & 255); - if(a0 & 0x0100) { - int fieldX = sizeX; - int fieldY = sizeY; - if(a0 & 0x0200) { - fieldX <<= 1; - fieldY <<= 1; + if (a0 & 0x0100) { + int fieldX = sizeX; + int fieldY = sizeY; + if (a0 & 0x0200) { + fieldX <<= 1; + fieldY <<= 1; + } + if ((sy + fieldY) > 256) + sy -= 256; + int t = VCOUNT - sy; + if ((t >= 0) && (t < fieldY)) { + int sx = (a1 & 0x1FF); + int startpix = 0; + if ((sx + fieldX) > 512) { + startpix = 512 - sx; + } + if ((sx < 240) || startpix) { + lineOBJpix -= 8; + // int t2 = t - (fieldY >> 1); + int rot = (a1 >> 9) & 0x1F; + u16 *OAM = (u16 *)oam; + int dx = READ16LE(&OAM[3 + (rot << 4)]); + if (dx & 0x8000) + dx |= 0xFFFF8000; + int dmx = READ16LE(&OAM[7 + (rot << 4)]); + if (dmx & 0x8000) + dmx |= 0xFFFF8000; + int dy = READ16LE(&OAM[11 + (rot << 4)]); + if (dy & 0x8000) + dy |= 0xFFFF8000; + int dmy = READ16LE(&OAM[15 + (rot << 4)]); + if (dmy & 0x8000) + dmy |= 0xFFFF8000; + + int realX = ((sizeX) << 7) - (fieldX >> 1) * dx - + (fieldY >> 1) * dmx + t * dmx; + int realY = ((sizeY) << 7) - (fieldX >> 1) * dy - + (fieldY >> 1) * dmy + t * dmy; + + // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & + // 0x0c00)<<6); + + if (a0 & 0x2000) { + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + int inc = 32; + if (DISPCNT & 0x40) + inc = sizeX >> 2; + else + c &= 0x3FE; + for (int x = 0; x < fieldX; x++) { + if (x >= startpix) + lineOBJpix -= 2; + if (lineOBJpix < 0) + continue; + int xxx = realX >> 8; + int yyy = realY >> 8; + + if (xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY || + sx >= 240) { + } else { + u32 color = vram + [0x10000 + + ((((c + + (yyy >> 3) * inc) + << 5) + + ((yyy & 7) << 3) + + ((xxx >> 3) << 6) + + (xxx & 7)) & + 0x7fff)]; + if (color) { + lineOBJWin[sx] = 1; + } + } + sx = (sx + 1) & 511; + realX += dx; + realY += dy; + } + } else { + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if (DISPCNT & 0x40) + inc = sizeX >> 3; + // int palette = (a2 >> 8) & 0xF0; + for (int x = 0; x < fieldX; x++) { + if (x >= startpix) + lineOBJpix -= 2; + if (lineOBJpix < 0) + continue; + int xxx = realX >> 8; + int yyy = realY >> 8; + + // if(x == 0 || x == + // (sizeX-1) || + // t == 0 || t == + // (sizeY-1)) { + // lineOBJ[sx] = + // 0x001F | prio; + // } else { + if (xxx < 0 || xxx >= sizeX || + yyy < 0 || yyy >= sizeY || + sx >= 240) { + } else { + u32 color = vram + [0x10000 + + ((((c + + (yyy >> 3) * inc) + << 5) + + ((yyy & 7) << 2) + + ((xxx >> 3) << 5) + + ((xxx & 7) >> 1)) & + 0x7fff)]; + if (xxx & 1) + color >>= 4; + else + color &= 0x0F; + + if (color) { + lineOBJWin[sx] = 1; + } + } + // } + sx = (sx + 1) & 511; + realX += dx; + realY += dy; + } + } + } + } + } else { + if ((sy + sizeY) > 256) + sy -= 256; + int t = VCOUNT - sy; + if ((t >= 0) && (t < sizeY)) { + int sx = (a1 & 0x1FF); + int startpix = 0; + if ((sx + sizeX) > 512) { + startpix = 512 - sx; + } + if ((sx < 240) || startpix) { + lineOBJpix += 2; + if (a0 & 0x2000) { + if (a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if (DISPCNT & 0x40) { + inc = sizeX >> 2; + } else { + c &= 0x3FE; + } + int xxx = 0; + if (a1 & 0x1000) + xxx = sizeX - 1; + int address = + 0x10000 + + ((((c + (t >> 3) * inc) << 5) + + ((t & 7) << 3) + ((xxx >> 3) << 6) + + (xxx & 7)) & + 0x7fff); + if (a1 & 0x1000) + xxx = 7; + // u32 prio = (((a2 >> 10) & 3) << 25) | + // ((a0 & 0x0c00)<<6); + for (int xx = 0; xx < sizeX; xx++) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = vram[address]; + if (color) { + lineOBJWin[sx] = 1; + } + } + + sx = (sx + 1) & 511; + if (a1 & 0x1000) { + xxx--; + address--; + if (xxx == -1) { + address -= 56; + xxx = 7; + } + if (address < 0x10000) + address += 0x8000; + } else { + xxx++; + address++; + if (xxx == 8) { + address += 56; + xxx = 0; + } + if (address > 0x17fff) + address -= 0x8000; + } + } + } else { + if (a1 & 0x2000) + t = sizeY - t - 1; + int c = (a2 & 0x3FF); + if ((DISPCNT & 7) > 2 && (c < 512)) + continue; + + int inc = 32; + if (DISPCNT & 0x40) { + inc = sizeX >> 3; + } + int xxx = 0; + if (a1 & 0x1000) + xxx = sizeX - 1; + int address = + 0x10000 + + ((((c + (t >> 3) * inc) << 5) + + ((t & 7) << 2) + ((xxx >> 3) << 5) + + ((xxx & 7) >> 1)) & + 0x7fff); + // u32 prio = (((a2 >> 10) & 3) << 25) | + // ((a0 & 0x0c00)<<6); + // int palette = (a2 >> 8) & 0xF0; + if (a1 & 0x1000) { + xxx = 7; + for (int xx = sizeX - 1; xx >= 0; + xx--) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = + vram[address]; + if (xx & 1) { + color = + (color >> + 4); + } else + color &= + 0x0F; + + if (color) { + lineOBJWin + [sx] = + 1; + } + } + sx = (sx + 1) & 511; + xxx--; + if (!(xx & 1)) + address--; + if (xxx == -1) { + xxx = 7; + address -= 28; + } + if (address < 0x10000) + address += 0x8000; + } + } else { + for (int xx = 0; xx < sizeX; xx++) { + if (xx >= startpix) + lineOBJpix--; + if (lineOBJpix < 0) + continue; + if (sx < 240) { + u8 color = + vram[address]; + if (xx & 1) { + color = + (color >> + 4); + } else + color &= + 0x0F; + + if (color) { + lineOBJWin + [sx] = + 1; + } + } + sx = (sx + 1) & 511; + xxx++; + if (xx & 1) + address++; + if (xxx == 8) { + address += 28; + xxx = 0; + } + if (address > 0x17fff) + address -= 0x8000; + } + } + } + } + } + } + } } - if((sy+fieldY) > 256) - sy -= 256; - int t = VCOUNT - sy; - if((t >= 0) && (t < fieldY)) { - int sx = (a1 & 0x1FF); - int startpix = 0; - if ((sx+fieldX)> 512) - { - startpix=512-sx; - } - if((sx < 240) || startpix) { - lineOBJpix-=8; - // int t2 = t - (fieldY >> 1); - int rot = (a1 >> 9) & 0x1F; - u16 *OAM = (u16 *)oam; - int dx = READ16LE(&OAM[3 + (rot << 4)]); - if(dx & 0x8000) - dx |= 0xFFFF8000; - int dmx = READ16LE(&OAM[7 + (rot << 4)]); - if(dmx & 0x8000) - dmx |= 0xFFFF8000; - int dy = READ16LE(&OAM[11 + (rot << 4)]); - if(dy & 0x8000) - dy |= 0xFFFF8000; - int dmy = READ16LE(&OAM[15 + (rot << 4)]); - if(dmy & 0x8000) - dmy |= 0xFFFF8000; - - int realX = ((sizeX) << 7) - (fieldX >> 1)*dx - (fieldY>>1)*dmx - + t * dmx; - int realY = ((sizeY) << 7) - (fieldX >> 1)*dy - (fieldY>>1)*dmy - + t * dmy; - - // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); - - if(a0 & 0x2000) { - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - int inc = 32; - if(DISPCNT & 0x40) - inc = sizeX >> 2; - else - c &= 0x3FE; - for(int x = 0; x < fieldX; x++) { - if (x >= startpix) - lineOBJpix-=2; - if (lineOBJpix<0) - continue; - int xxx = realX >> 8; - int yyy = realY >> 8; - - if(xxx < 0 || xxx >= sizeX || - yyy < 0 || yyy >= sizeY || - sx >= 240) { - } else { - u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) - + ((yyy & 7)<<3) + ((xxx >> 3)<<6) + - (xxx & 7))&0x7fff)]; - if(color) { - lineOBJWin[sx] = 1; - } - } - sx = (sx+1)&511; - realX += dx; - realY += dy; - } - } else { - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - - int inc = 32; - if(DISPCNT & 0x40) - inc = sizeX >> 3; - // int palette = (a2 >> 8) & 0xF0; - for(int x = 0; x < fieldX; x++) { - if (x >= startpix) - lineOBJpix-=2; - if (lineOBJpix<0) - continue; - int xxx = realX >> 8; - int yyy = realY >> 8; - - // if(x == 0 || x == (sizeX-1) || - // t == 0 || t == (sizeY-1)) { - // lineOBJ[sx] = 0x001F | prio; - // } else { - if(xxx < 0 || xxx >= sizeX || - yyy < 0 || yyy >= sizeY || - sx >= 240) { - } else { - u32 color = vram[0x10000 + ((((c + (yyy>>3) * inc)<<5) - + ((yyy & 7)<<2) + ((xxx >> 3)<<5) + - ((xxx & 7)>>1))&0x7fff)]; - if(xxx & 1) - color >>= 4; - else - color &= 0x0F; - - if(color) { - lineOBJWin[sx] = 1; - } - } - // } - sx = (sx+1)&511; - realX += dx; - realY += dy; - } - } - } - } - } else { - if((sy+sizeY) > 256) - sy -= 256; - int t = VCOUNT - sy; - if((t >= 0) && (t < sizeY)) { - int sx = (a1 & 0x1FF); - int startpix = 0; - if ((sx+sizeX)> 512) - { - startpix=512-sx; - } - if((sx < 240) || startpix) { - lineOBJpix+=2; - if(a0 & 0x2000) { - if(a1 & 0x2000) - t = sizeY - t - 1; - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - - int inc = 32; - if(DISPCNT & 0x40) { - inc = sizeX >> 2; - } else { - c &= 0x3FE; - } - int xxx = 0; - if(a1 & 0x1000) - xxx = sizeX-1; - int address = 0x10000 + ((((c+ (t>>3) * inc) << 5) - + ((t & 7) << 3) + ((xxx>>3)<<6) + (xxx & 7))&0x7fff); - if(a1 & 0x1000) - xxx = 7; - // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); - for(int xx = 0; xx < sizeX; xx++) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if(color) { - lineOBJWin[sx] = 1; - } - } - - sx = (sx+1) & 511; - if(a1 & 0x1000) { - xxx--; - address--; - if(xxx == -1) { - address -= 56; - xxx = 7; - } - if(address < 0x10000) - address += 0x8000; - } else { - xxx++; - address++; - if(xxx == 8) { - address += 56; - xxx = 0; - } - if(address > 0x17fff) - address -= 0x8000; - } - } - } else { - if(a1 & 0x2000) - t = sizeY - t - 1; - int c = (a2 & 0x3FF); - if((DISPCNT & 7) > 2 && (c < 512)) - continue; - - int inc = 32; - if(DISPCNT & 0x40) { - inc = sizeX >> 3; - } - int xxx = 0; - if(a1 & 0x1000) - xxx = sizeX - 1; - int address = 0x10000 + ((((c + (t>>3) * inc)<<5) - + ((t & 7)<<2) + ((xxx>>3)<<5) + ((xxx & 7) >> 1))&0x7fff); - // u32 prio = (((a2 >> 10) & 3) << 25) | ((a0 & 0x0c00)<<6); - // int palette = (a2 >> 8) & 0xF0; - if(a1 & 0x1000) { - xxx = 7; - for(int xx = sizeX - 1; xx >= 0; xx--) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if(xx & 1) { - color = (color >> 4); - } else - color &= 0x0F; - - if(color) { - lineOBJWin[sx] = 1; - } - } - sx = (sx+1) & 511; - xxx--; - if(!(xx & 1)) - address--; - if(xxx == -1) { - xxx = 7; - address -= 28; - } - if(address < 0x10000) - address += 0x8000; - } - } else { - for(int xx = 0; xx < sizeX; xx++) { - if (xx >= startpix) - lineOBJpix--; - if (lineOBJpix<0) - continue; - if(sx < 240) { - u8 color = vram[address]; - if(xx & 1) { - color = (color >> 4); - } else - color &= 0x0F; - - if(color) { - lineOBJWin[sx] = 1; - } - } - sx = (sx+1) & 511; - xxx++; - if(xx & 1) - address++; - if(xxx == 8) { - address += 28; - xxx = 0; - } - if(address > 0x17fff) - address -= 0x8000; - } - } - } - } - } - } - } - } } static inline u32 gfxIncreaseBrightness(u32 color, int coeff) { - color &= 0xffff; - color = ((color << 16) | color) & 0x3E07C1F; + color &= 0xffff; + color = ((color << 16) | color) & 0x3E07C1F; - color = color + (((0x3E07C1F - color) * coeff) >> 4); - color &= 0x3E07C1F; + color = color + (((0x3E07C1F - color) * coeff) >> 4); + color &= 0x3E07C1F; - return (color >> 16) | color; + return (color >> 16) | color; } static inline void gfxIncreaseBrightness(u32 *line, int coeff) { - for(int x = 0; x < 240; x++) { - u32 color = *line; - int r = (color & 0x1F); - int g = ((color >> 5) & 0x1F); - int b = ((color >> 10) & 0x1F); + for (int x = 0; x < 240; x++) { + u32 color = *line; + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); - r = r + (((31 - r) * coeff) >> 4); - g = g + (((31 - g) * coeff) >> 4); - b = b + (((31 - b) * coeff) >> 4); - if(r > 31) - r = 31; - if(g > 31) - g = 31; - if(b > 31) - b = 31; - *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; - } + r = r + (((31 - r) * coeff) >> 4); + g = g + (((31 - g) * coeff) >> 4); + b = b + (((31 - b) * coeff) >> 4); + if (r > 31) + r = 31; + if (g > 31) + g = 31; + if (b > 31) + b = 31; + *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } } static inline u32 gfxDecreaseBrightness(u32 color, int coeff) { - color &= 0xffff; - color = ((color << 16) | color) & 0x3E07C1F; + color &= 0xffff; + color = ((color << 16) | color) & 0x3E07C1F; - color = color - (((color * coeff) >> 4) & 0x3E07C1F); + color = color - (((color * coeff) >> 4) & 0x3E07C1F); - return (color >> 16) | color; + return (color >> 16) | color; } static inline void gfxDecreaseBrightness(u32 *line, int coeff) { - for(int x = 0; x < 240; x++) { - u32 color = *line; - int r = (color & 0x1F); - int g = ((color >> 5) & 0x1F); - int b = ((color >> 10) & 0x1F); + for (int x = 0; x < 240; x++) { + u32 color = *line; + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); - r = r - ((r * coeff) >> 4); - g = g - ((g * coeff) >> 4); - b = b - ((b * coeff) >> 4); - if(r < 0) - r = 0; - if(g < 0) - g = 0; - if(b < 0) - b = 0; - *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; - } + r = r - ((r * coeff) >> 4); + g = g - ((g * coeff) >> 4); + b = b - ((b * coeff) >> 4); + if (r < 0) + r = 0; + if (g < 0) + g = 0; + if (b < 0) + b = 0; + *line++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } } static inline u32 gfxAlphaBlend(u32 color, u32 color2, int ca, int cb) { - if(color < 0x80000000) { - color&=0xffff; - color2&=0xffff; + if (color < 0x80000000) { + color &= 0xffff; + color2 &= 0xffff; - color = ((color << 16) | color) & 0x03E07C1F; - color2 = ((color2 << 16) | color2) & 0x03E07C1F; - color = ((color * ca) + (color2 * cb)) >> 4; + color = ((color << 16) | color) & 0x03E07C1F; + color2 = ((color2 << 16) | color2) & 0x03E07C1F; + color = ((color * ca) + (color2 * cb)) >> 4; - if ((ca + cb)>16) - { - if (color & 0x20) - color |= 0x1f; - if (color & 0x8000) - color |= 0x7C00; - if (color & 0x4000000) - color |= 0x03E00000; - } + if ((ca + cb) > 16) { + if (color & 0x20) + color |= 0x1f; + if (color & 0x8000) + color |= 0x7C00; + if (color & 0x4000000) + color |= 0x03E00000; + } - color &= 0x03E07C1F; - color = (color >> 16) | color; - } - return color; + color &= 0x03E07C1F; + color = (color >> 16) | color; + } + return color; } static inline void gfxAlphaBlend(u32 *ta, u32 *tb, int ca, int cb) { - for(int x = 0; x < 240; x++) { - u32 color = *ta; - if(color < 0x80000000) { - int r = (color & 0x1F); - int g = ((color >> 5) & 0x1F); - int b = ((color >> 10) & 0x1F); - u32 color2 = (*tb++); - int r0 = (color2 & 0x1F); - int g0 = ((color2 >> 5) & 0x1F); - int b0 = ((color2 >> 10) & 0x1F); + for (int x = 0; x < 240; x++) { + u32 color = *ta; + if (color < 0x80000000) { + int r = (color & 0x1F); + int g = ((color >> 5) & 0x1F); + int b = ((color >> 10) & 0x1F); + u32 color2 = (*tb++); + int r0 = (color2 & 0x1F); + int g0 = ((color2 >> 5) & 0x1F); + int b0 = ((color2 >> 10) & 0x1F); - r = ((r * ca) + (r0 * cb)) >> 4; - g = ((g * ca) + (g0 * cb)) >> 4; - b = ((b * ca) + (b0 * cb)) >> 4; + r = ((r * ca) + (r0 * cb)) >> 4; + g = ((g * ca) + (g0 * cb)) >> 4; + b = ((b * ca) + (b0 * cb)) >> 4; - if(r > 31) - r = 31; - if(g > 31) - g = 31; - if(b > 31) - b = 31; + if (r > 31) + r = 31; + if (g > 31) + g = 31; + if (b > 31) + b = 31; - *ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; - } else { - ta++; - tb++; - } - } + *ta++ = (color & 0xFFFF0000) | (b << 10) | (g << 5) | r; + } else { + ta++; + tb++; + } + } } #endif // GFX_H diff --git a/src/gba/GBALink.h b/src/gba/GBALink.h index f33f2c08..ba8725d1 100644 --- a/src/gba/GBALink.h +++ b/src/gba/GBALink.h @@ -4,28 +4,21 @@ /** * Link modes to be passed to InitLink */ -enum LinkMode -{ - LINK_DISCONNECTED, - LINK_CABLE_IPC, - LINK_CABLE_SOCKET, - LINK_RFU_IPC, - LINK_RFU_SOCKET, - LINK_GAMECUBE_DOLPHIN, - LINK_GAMEBOY_IPC, - LINK_GAMEBOY_SOCKET +enum LinkMode { + LINK_DISCONNECTED, + LINK_CABLE_IPC, + LINK_CABLE_SOCKET, + LINK_RFU_IPC, + LINK_RFU_SOCKET, + LINK_GAMECUBE_DOLPHIN, + LINK_GAMEBOY_IPC, + LINK_GAMEBOY_SOCKET }; /** * State of the connection attempt */ -enum ConnectionState -{ - LINK_OK, - LINK_ERROR, - LINK_NEEDS_UPDATE, - LINK_ABORT -}; +enum ConnectionState { LINK_OK, LINK_ERROR, LINK_NEEDS_UPDATE, LINK_ABORT }; /** * Initialize GBA linking @@ -41,7 +34,7 @@ extern ConnectionState InitLink(LinkMode mode); * @param message Information message * @param size Maximum message size */ -extern ConnectionState ConnectLinkUpdate(char * const message, size_t size); +extern ConnectionState ConnectLinkUpdate(char *const message, size_t size); /** * Get the currently enabled link mode @@ -80,7 +73,7 @@ extern bool SetLinkServerHost(const char *host); * If in gamecube mode, returns the IP adress of the dolphin host * */ -extern void GetLinkServerHost(char * const host, size_t size); +extern void GetLinkServerHost(char *const host, size_t size); /** * Set the value in milliseconds of the timeout after which a connection is @@ -141,56 +134,58 @@ extern void CleanLocalLink(); extern const char *MakeInstanceFilename(const char *Input); // register definitions -#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode -#define COMM_SIODATA32_H 0x122 // Higher 16bit on Normal mode -#define COMM_SIOCNT 0x128 -#define COMM_SIODATA8 0x12a // 8bit on Normal/UART mode, (up to 4x8bit with FIFO) -#define COMM_SIOMLT_SEND 0x12a // SIOMLT_SEND (16bit R/W) on MultiPlayer mode (local outgoing) -#define COMM_SIOMULTI0 0x120 // SIOMULTI0 (16bit) on MultiPlayer mode (Parent/Master) -#define COMM_SIOMULTI1 0x122 // SIOMULTI1 (16bit) on MultiPlayer mode (Child1/Slave1) -#define COMM_SIOMULTI2 0x124 // SIOMULTI2 (16bit) on MultiPlayer mode (Child2/Slave2) -#define COMM_SIOMULTI3 0x126 // SIOMULTI3 (16bit) on MultiPlayer mode (Child3/Slave3) -#define COMM_RCNT 0x134 // SIO Mode (4bit data) on GeneralPurpose mode -#define COMM_IR 0x136 // Infrared Register (16bit) 1bit data at a time(LED On/Off)? -#define COMM_JOYCNT 0x140 -#define COMM_JOY_RECV_L 0x150 // Send/Receive 8bit Lower first then 8bit Higher -#define COMM_JOY_RECV_H 0x152 -#define COMM_JOY_TRANS_L 0x154 // Send/Receive 8bit Lower first then 8bit Higher -#define COMM_JOY_TRANS_H 0x156 -#define COMM_JOYSTAT 0x158 // Send/Receive 8bit lower only +#define COMM_SIODATA32_L 0x120 // Lower 16bit on Normal mode +#define COMM_SIODATA32_H 0x122 // Higher 16bit on Normal mode +#define COMM_SIOCNT 0x128 +#define COMM_SIODATA8 0x12a // 8bit on Normal/UART mode, (up to 4x8bit with FIFO) +#define COMM_SIOMLT_SEND 0x12a // SIOMLT_SEND (16bit R/W) on MultiPlayer mode (local outgoing) +#define COMM_SIOMULTI0 0x120 // SIOMULTI0 (16bit) on MultiPlayer mode (Parent/Master) +#define COMM_SIOMULTI1 0x122 // SIOMULTI1 (16bit) on MultiPlayer mode (Child1/Slave1) +#define COMM_SIOMULTI2 0x124 // SIOMULTI2 (16bit) on MultiPlayer mode (Child2/Slave2) +#define COMM_SIOMULTI3 0x126 // SIOMULTI3 (16bit) on MultiPlayer mode (Child3/Slave3) +#define COMM_RCNT 0x134 // SIO Mode (4bit data) on GeneralPurpose mode +#define COMM_IR 0x136 // Infrared Register (16bit) 1bit data at a time(LED On/Off)? +#define COMM_JOYCNT 0x140 +#define COMM_JOY_RECV_L 0x150 // Send/Receive 8bit Lower first then 8bit Higher +#define COMM_JOY_RECV_H 0x152 +#define COMM_JOY_TRANS_L 0x154 // Send/Receive 8bit Lower first then 8bit Higher +#define COMM_JOY_TRANS_H 0x156 +#define COMM_JOYSTAT 0x158 // Send/Receive 8bit lower only -#define JOYSTAT_RECV 2 -#define JOYSTAT_SEND 8 +#define JOYSTAT_RECV 2 +#define JOYSTAT_SEND 8 -#define JOYCNT_RESET 1 -#define JOYCNT_RECV_COMPLETE 2 -#define JOYCNT_SEND_COMPLETE 4 -#define JOYCNT_INT_ENABLE 0x40 +#define JOYCNT_RESET 1 +#define JOYCNT_RECV_COMPLETE 2 +#define JOYCNT_SEND_COMPLETE 4 +#define JOYCNT_INT_ENABLE 0x40 -#define LINK_PARENTLOST 0x80 +#define LINK_PARENTLOST 0x80 -#define UNSUPPORTED -1 -#define MULTIPLAYER 0 -#define NORMAL8 1 -#define NORMAL32 2 // wireless use normal32 also -#define UART 3 -#define JOYBUS 4 -#define GP 5 -#define INFRARED 6 // Infrared Register at 4000136h +#define UNSUPPORTED -1 +#define MULTIPLAYER 0 +#define NORMAL8 1 +#define NORMAL32 2 // wireless use normal32 also +#define UART 3 +#define JOYBUS 4 +#define GP 5 +#define INFRARED 6 // Infrared Register at 4000136h -#define RFU_INIT 0 -#define RFU_COMM 1 -#define RFU_SEND 2 -#define RFU_RECV 3 +#define RFU_INIT 0 +#define RFU_COMM 1 +#define RFU_SEND 2 +#define RFU_RECV 3 -#define RF_RECVCMD 0x278 // Unknown, Seems to be related to Wireless Adapter(RF_RCNT or armMode/CPSR or CMD sent by the adapter when RF_SIOCNT=0x83 or when RCNT=0x80aX?) -#define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?) +#define RF_RECVCMD \ + 0x278 // Unknown, Seems to be related to Wireless Adapter(RF_RCNT or armMode/CPSR or CMD + // sent by the adapter when RF_SIOCNT=0x83 or when RCNT=0x80aX?) +#define RF_CNT 0x27a // Unknown, Seems to be related to Wireless Adapter(RF_SIOCNT?) typedef struct { - u8 len; //data len in 32bit words - u8 gbaid; //source id - u32 time; //linktime - u32 data[255]; + u8 len; // data len in 32bit words + u8 gbaid; // source id + u32 time; // linktime + u32 data[255]; } rfu_datarec; extern u8 gbSIO_SC; @@ -198,11 +193,11 @@ extern bool LinkIsWaiting; extern bool LinkFirstTime; extern bool EmuReseted; extern void gbInitLink(); -extern u8 gbStartLink(u8 b); -extern u16 gbLinkUpdate(u8 b, int gbSerialOn); +extern u8 gbStartLink(u8 b); +extern u16 gbLinkUpdate(u8 b, int gbSerialOn); extern void gbInitLinkIPC(); -extern u8 gbStartLinkIPC(u8 b); -extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn); +extern u8 gbStartLinkIPC(u8 b); +extern u16 gbLinkUpdateIPC(u8 b, int gbSerialOn); extern void BootLink(int m_type, const char *host, int timeout, bool m_hacks, int m_numplayers); diff --git a/src/gba/GBASockClient.h b/src/gba/GBASockClient.h index 5b113201..73252029 100644 --- a/src/gba/GBASockClient.h +++ b/src/gba/GBASockClient.h @@ -1,28 +1,28 @@ #pragma once -#include #include "../common/Types.h" +#include class GBASockClient { -public: - GBASockClient(sf::IpAddress _server_addr); - ~GBASockClient(); + public: + GBASockClient(sf::IpAddress _server_addr); + ~GBASockClient(); - bool Connect(sf::IpAddress server_addr); - void Send(std::vector data); - char ReceiveCmd(char* data_in, bool block); - void ReceiveClock(bool block); + bool Connect(sf::IpAddress server_addr); + void Send(std::vector data); + char ReceiveCmd(char *data_in, bool block); + void ReceiveClock(bool block); - void ClockSync(u32 ticks); - void Disconnect(); - bool IsDisconnected(); + void ClockSync(u32 ticks); + void Disconnect(); + bool IsDisconnected(); -private: - sf::IpAddress server_addr; - sf::TcpSocket client; - sf::TcpSocket clock_client; + private: + sf::IpAddress server_addr; + sf::TcpSocket client; + sf::TcpSocket clock_client; - s32 clock_sync; - bool is_disconnected; + s32 clock_sync; + bool is_disconnected; }; diff --git a/src/gba/GBAcpu.h b/src/gba/GBAcpu.h index 3b22e007..dc651cd3 100644 --- a/src/gba/GBAcpu.h +++ b/src/gba/GBAcpu.h @@ -6,41 +6,38 @@ extern int thumbExecute(); #ifdef __GNUC__ #ifndef __APPLE__ -# define INSN_REGPARM __attribute__((regparm(1))) +#define INSN_REGPARM __attribute__((regparm(1))) #else -# define INSN_REGPARM /*nothing*/ +#define INSN_REGPARM /*nothing*/ #endif -# define LIKELY(x) __builtin_expect(!!(x),1) -# define UNLIKELY(x) __builtin_expect(!!(x),0) +#define LIKELY(x) __builtin_expect(!!(x), 1) +#define UNLIKELY(x) __builtin_expect(!!(x), 0) #else -# define INSN_REGPARM /*nothing*/ -# define LIKELY(x) (x) -# define UNLIKELY(x) (x) +#define INSN_REGPARM /*nothing*/ +#define LIKELY(x) (x) +#define UNLIKELY(x) (x) #endif -#define UPDATE_REG(address, value)\ - {\ - WRITE16LE(((u16 *)&ioMem[address]),value);\ - }\ +#define UPDATE_REG(address, value) \ + { \ + WRITE16LE(((u16 *)&ioMem[address]), value); \ + } -#define ARM_PREFETCH \ - {\ - cpuPrefetch[0] = CPUReadMemoryQuick(armNextPC);\ - cpuPrefetch[1] = CPUReadMemoryQuick(armNextPC+4);\ - } +#define ARM_PREFETCH \ + { \ + cpuPrefetch[0] = CPUReadMemoryQuick(armNextPC); \ + cpuPrefetch[1] = CPUReadMemoryQuick(armNextPC + 4); \ + } -#define THUMB_PREFETCH \ - {\ - cpuPrefetch[0] = CPUReadHalfWordQuick(armNextPC);\ - cpuPrefetch[1] = CPUReadHalfWordQuick(armNextPC+2);\ - } +#define THUMB_PREFETCH \ + { \ + cpuPrefetch[0] = CPUReadHalfWordQuick(armNextPC); \ + cpuPrefetch[1] = CPUReadHalfWordQuick(armNextPC + 2); \ + } -#define ARM_PREFETCH_NEXT \ - cpuPrefetch[1] = CPUReadMemoryQuick(armNextPC+4); - -#define THUMB_PREFETCH_NEXT\ - cpuPrefetch[1] = CPUReadHalfWordQuick(armNextPC+2); +#define ARM_PREFETCH_NEXT cpuPrefetch[1] = CPUReadMemoryQuick(armNextPC + 4); +#define THUMB_PREFETCH_NEXT cpuPrefetch[1] = CPUReadHalfWordQuick(armNextPC + 2); extern int SWITicks; extern u32 mastercode; @@ -66,222 +63,182 @@ extern void CPUUndefinedException(); extern void CPUSoftwareInterrupt(); extern void CPUSoftwareInterrupt(int comment); - // Waitstates when accessing data inline int dataTicksAccess16(u32 address) // DATA 8/16bits NON SEQ { - int addr = (address>>24)&15; - int value = memoryWait[addr]; + int addr = (address >> 24) & 15; + int value = memoryWait[addr]; - if ((addr>=0x08) || (addr < 0x02)) - { - busPrefetchCount=0; - busPrefetch=false; - } - else if (busPrefetch) - { - int waitState = value; - if (!waitState) - waitState = 1; - busPrefetchCount = ((busPrefetchCount+1)<= 0x08) || (addr < 0x02)) { + busPrefetchCount = 0; + busPrefetch = false; + } else if (busPrefetch) { + int waitState = value; + if (!waitState) + waitState = 1; + busPrefetchCount = ((busPrefetchCount + 1) << waitState) - 1; + } - return value; + return value; } inline int dataTicksAccess32(u32 address) // DATA 32bits NON SEQ { - int addr = (address>>24)&15; - int value = memoryWait32[addr]; + int addr = (address >> 24) & 15; + int value = memoryWait32[addr]; - if ((addr>=0x08) || (addr < 0x02)) - { - busPrefetchCount=0; - busPrefetch=false; - } - else if (busPrefetch) - { - int waitState = value; - if (!waitState) - waitState = 1; - busPrefetchCount = ((busPrefetchCount+1)<= 0x08) || (addr < 0x02)) { + busPrefetchCount = 0; + busPrefetch = false; + } else if (busPrefetch) { + int waitState = value; + if (!waitState) + waitState = 1; + busPrefetchCount = ((busPrefetchCount + 1) << waitState) - 1; + } - return value; + return value; } -inline int dataTicksAccessSeq16(u32 address)// DATA 8/16bits SEQ +inline int dataTicksAccessSeq16(u32 address) // DATA 8/16bits SEQ { - int addr = (address>>24)&15; - int value = memoryWaitSeq[addr]; + int addr = (address >> 24) & 15; + int value = memoryWaitSeq[addr]; - if ((addr>=0x08) || (addr < 0x02)) - { - busPrefetchCount=0; - busPrefetch=false; - } - else if (busPrefetch) - { - int waitState = value; - if (!waitState) - waitState = 1; - busPrefetchCount = ((busPrefetchCount+1)<= 0x08) || (addr < 0x02)) { + busPrefetchCount = 0; + busPrefetch = false; + } else if (busPrefetch) { + int waitState = value; + if (!waitState) + waitState = 1; + busPrefetchCount = ((busPrefetchCount + 1) << waitState) - 1; + } - return value; + return value; } -inline int dataTicksAccessSeq32(u32 address)// DATA 32bits SEQ +inline int dataTicksAccessSeq32(u32 address) // DATA 32bits SEQ { - int addr = (address>>24)&15; - int value = memoryWaitSeq32[addr]; + int addr = (address >> 24) & 15; + int value = memoryWaitSeq32[addr]; - if ((addr>=0x08) || (addr < 0x02)) - { - busPrefetchCount=0; - busPrefetch=false; - } - else if (busPrefetch) - { - int waitState = value; - if (!waitState) - waitState = 1; - busPrefetchCount = ((busPrefetchCount+1)<= 0x08) || (addr < 0x02)) { + busPrefetchCount = 0; + busPrefetch = false; + } else if (busPrefetch) { + int waitState = value; + if (!waitState) + waitState = 1; + busPrefetchCount = ((busPrefetchCount + 1) << waitState) - 1; + } - return value; + return value; } - // Waitstates when executing opcode inline int codeTicksAccess16(u32 address) // THUMB NON SEQ { - int addr = (address>>24)&15; + int addr = (address >> 24) & 15; - if ((addr>=0x08) && (addr<=0x0D)) - { - if (busPrefetchCount&0x1) - { - if (busPrefetchCount&0x2) - { - busPrefetchCount = ((busPrefetchCount&0xFF)>>2) | (busPrefetchCount&0xFFFFFF00); - return 0; - } - busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00); - return memoryWaitSeq[addr]-1; - } - else - { - busPrefetchCount=0; - return memoryWait[addr]; - } - } - else - { - busPrefetchCount = 0; - return memoryWait[addr]; - } + if ((addr >= 0x08) && (addr <= 0x0D)) { + if (busPrefetchCount & 0x1) { + if (busPrefetchCount & 0x2) { + busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | + (busPrefetchCount & 0xFFFFFF00); + return 0; + } + busPrefetchCount = + ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00); + return memoryWaitSeq[addr] - 1; + } else { + busPrefetchCount = 0; + return memoryWait[addr]; + } + } else { + busPrefetchCount = 0; + return memoryWait[addr]; + } } inline int codeTicksAccess32(u32 address) // ARM NON SEQ { - int addr = (address>>24)&15; + int addr = (address >> 24) & 15; - if ((addr>=0x08) && (addr<=0x0D)) - { - if (busPrefetchCount&0x1) - { - if (busPrefetchCount&0x2) - { - busPrefetchCount = ((busPrefetchCount&0xFF)>>2) | (busPrefetchCount&0xFFFFFF00); - return 0; - } - busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00); - return memoryWaitSeq[addr] - 1; - } - else - { - busPrefetchCount = 0; - return memoryWait32[addr]; - } - } - else - { - busPrefetchCount = 0; - return memoryWait32[addr]; - } + if ((addr >= 0x08) && (addr <= 0x0D)) { + if (busPrefetchCount & 0x1) { + if (busPrefetchCount & 0x2) { + busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | + (busPrefetchCount & 0xFFFFFF00); + return 0; + } + busPrefetchCount = + ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00); + return memoryWaitSeq[addr] - 1; + } else { + busPrefetchCount = 0; + return memoryWait32[addr]; + } + } else { + busPrefetchCount = 0; + return memoryWait32[addr]; + } } inline int codeTicksAccessSeq16(u32 address) // THUMB SEQ { - int addr = (address>>24)&15; + int addr = (address >> 24) & 15; - if ((addr>=0x08) && (addr<=0x0D)) - { - if (busPrefetchCount&0x1) - { - busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00); - return 0; - } - else - if (busPrefetchCount>0xFF) - { - busPrefetchCount=0; - return memoryWait[addr]; - } - else - return memoryWaitSeq[addr]; - } - else - { - busPrefetchCount = 0; - return memoryWaitSeq[addr]; - } + if ((addr >= 0x08) && (addr <= 0x0D)) { + if (busPrefetchCount & 0x1) { + busPrefetchCount = + ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00); + return 0; + } else if (busPrefetchCount > 0xFF) { + busPrefetchCount = 0; + return memoryWait[addr]; + } else + return memoryWaitSeq[addr]; + } else { + busPrefetchCount = 0; + return memoryWaitSeq[addr]; + } } inline int codeTicksAccessSeq32(u32 address) // ARM SEQ { - int addr = (address>>24)&15; + int addr = (address >> 24) & 15; - if ((addr>=0x08) && (addr<=0x0D)) - { - if (busPrefetchCount&0x1) - { - if (busPrefetchCount&0x2) - { - busPrefetchCount = ((busPrefetchCount&0xFF)>>2) | (busPrefetchCount&0xFFFFFF00); - return 0; - } - busPrefetchCount = ((busPrefetchCount&0xFF)>>1) | (busPrefetchCount&0xFFFFFF00); - return memoryWaitSeq[addr]; - } - else - if (busPrefetchCount>0xFF) - { - busPrefetchCount=0; - return memoryWait32[addr]; - } - else - return memoryWaitSeq32[addr]; - } - else - { - return memoryWaitSeq32[addr]; - } + if ((addr >= 0x08) && (addr <= 0x0D)) { + if (busPrefetchCount & 0x1) { + if (busPrefetchCount & 0x2) { + busPrefetchCount = ((busPrefetchCount & 0xFF) >> 2) | + (busPrefetchCount & 0xFFFFFF00); + return 0; + } + busPrefetchCount = + ((busPrefetchCount & 0xFF) >> 1) | (busPrefetchCount & 0xFFFFFF00); + return memoryWaitSeq[addr]; + } else if (busPrefetchCount > 0xFF) { + busPrefetchCount = 0; + return memoryWait32[addr]; + } else + return memoryWaitSeq32[addr]; + } else { + return memoryWaitSeq32[addr]; + } } - // Emulates the Cheat System (m) code inline void cpuMasterCodeCheck() { - if((mastercode) && (mastercode == armNextPC)) - { - u32 joy = 0; - if(systemReadJoypads()) - joy = systemReadJoypad(-1); - u32 ext = (joy >> 10); - cpuTotalTicks += cheatsCheckKeys(P1^0x3FF, ext); - } + if ((mastercode) && (mastercode == armNextPC)) { + u32 joy = 0; + if (systemReadJoypads()) + joy = systemReadJoypad(-1); + u32 ext = (joy >> 10); + cpuTotalTicks += cheatsCheckKeys(P1 ^ 0x3FF, ext); + } } #endif // GBACPU_H diff --git a/src/gba/GBAinline.h b/src/gba/GBAinline.h index 90ab21f9..22ee01c6 100644 --- a/src/gba/GBAinline.h +++ b/src/gba/GBAinline.h @@ -3,11 +3,11 @@ #include "../System.h" #include "../common/Port.h" +#include "GBALink.h" +#include "GBAcpu.h" #include "RTC.h" #include "Sound.h" #include "agbprint.h" -#include "GBAcpu.h" -#include "GBALink.h" #include "remote.h" extern const u32 objTilesAddress[3]; @@ -36,781 +36,786 @@ extern int timer3Ticks; extern int timer3ClockReload; extern int cpuTotalTicks; -#define CPUReadByteQuick(addr) \ - map[(addr)>>24].address[(addr) & map[(addr)>>24].mask] +#define CPUReadByteQuick(addr) map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask] -#define CPUReadHalfWordQuick(addr) \ - READ16LE(((u16*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) +#define CPUReadHalfWordQuick(addr) \ + READ16LE(((u16 *)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])) -#define CPUReadMemoryQuick(addr) \ - READ32LE(((u32*)&map[(addr)>>24].address[(addr) & map[(addr)>>24].mask])) +#define CPUReadMemoryQuick(addr) \ + READ32LE(((u32 *)&map[(addr) >> 24].address[(addr)&map[(addr) >> 24].mask])) extern u32 myROM[]; static inline u32 CPUReadMemory(u32 address) { #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnRead(address, 2)){ - //CPU_BREAK_LOOP_2; - } - } -#endif - u32 value; - u32 oldAddress = address; - - if(address & 3) { - address &= ~0x03; - } - - switch(address >> 24) { - case 0: - if(reg[15].I >> 24) { - if(address < 0x4000) { -#ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal word read from bios: %08x at %08x\n", address, armMode ? - armNextPC - 4 : armNextPC - 2); + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnRead(address, 2)) { + // CPU_BREAK_LOOP_2; + } } #endif + u32 value; + u32 oldAddress = address; - value = READ32LE(((u32 *)&biosProtected)); - } - else goto unreadable; - } else - value = READ32LE(((u32 *)&bios[address & 0x3FFC])); - break; - case 2: - value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC])); - break; - case 3: - value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC])); - break; - case 4: - if((address < 0x4000400) && ioReadable[address & 0x3fc]) { - if(ioReadable[(address & 0x3fc) + 2]) { - value = READ32LE(((u32 *)&ioMem[address & 0x3fC])); - if ((address & 0x3fc) == COMM_JOY_RECV_L) - UPDATE_REG(COMM_JOYSTAT, READ16LE(&ioMem[COMM_JOYSTAT]) & ~JOYSTAT_RECV); - } else { - value = READ16LE(((u16 *)&ioMem[address & 0x3fc])); - } - } - else - goto unreadable; - break; - case 5: - value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC])); - break; - case 6: - address = (address & 0x1fffc); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - { - value = 0; - break; - } - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; - value = READ32LE(((u32 *)&vram[address])); - break; - case 7: - value = READ32LE(((u32 *)&oam[address & 0x3FC])); - break; - case 8: - case 9: - case 10: - case 11: - case 12: - value = READ32LE(((u32 *)&rom[address&0x1FFFFFC])); - break; - case 13: - if(cpuEEPROMEnabled) - // no need to swap this - return eepromRead(address); - goto unreadable; - case 14: - case 15: - if(cpuFlashEnabled | cpuSramEnabled) - { // no need to swap this - #ifdef __libretro__ - return flashRead(address); - #else - value = flashRead(address) * 0x01010101; - #endif - } - break; - // default - default: -unreadable: + if (address & 3) { + address &= ~0x03; + } + + switch (address >> 24) { + case 0: + if (reg[15].I >> 24) { + if (address < 0x4000) { #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal word read: %08x at %08x\n", address, armMode ? - armNextPC - 4 : armNextPC - 2); - } + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal word read from bios: %08x at %08x\n", + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - if(cpuDmaHack) { - value = cpuDmaLast; - } else { - if(armState) { - return CPUReadMemoryQuick(reg[15].I); - } else { - return CPUReadHalfWordQuick(reg[15].I) | - CPUReadHalfWordQuick(reg[15].I) << 16; - } - } - break; - } - if(oldAddress & 3) { + value = READ32LE(((u32 *)&biosProtected)); + } else + goto unreadable; + } else + value = READ32LE(((u32 *)&bios[address & 0x3FFC])); + break; + case 2: + value = READ32LE(((u32 *)&workRAM[address & 0x3FFFC])); + break; + case 3: + value = READ32LE(((u32 *)&internalRAM[address & 0x7ffC])); + break; + case 4: + if ((address < 0x4000400) && ioReadable[address & 0x3fc]) { + if (ioReadable[(address & 0x3fc) + 2]) { + value = READ32LE(((u32 *)&ioMem[address & 0x3fC])); + if ((address & 0x3fc) == COMM_JOY_RECV_L) + UPDATE_REG(COMM_JOYSTAT, + READ16LE(&ioMem[COMM_JOYSTAT]) & ~JOYSTAT_RECV); + } else { + value = READ16LE(((u16 *)&ioMem[address & 0x3fc])); + } + } else + goto unreadable; + break; + case 5: + value = READ32LE(((u32 *)&paletteRAM[address & 0x3fC])); + break; + case 6: + address = (address & 0x1fffc); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) { + value = 0; + break; + } + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; + value = READ32LE(((u32 *)&vram[address])); + break; + case 7: + value = READ32LE(((u32 *)&oam[address & 0x3FC])); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + value = READ32LE(((u32 *)&rom[address & 0x1FFFFFC])); + break; + case 13: + if (cpuEEPROMEnabled) + // no need to swap this + return eepromRead(address); + goto unreadable; + case 14: + case 15: + if (cpuFlashEnabled | cpuSramEnabled) { // no need to swap this +#ifdef __libretro__ + return flashRead(address); +#else + value = flashRead(address) * 0x01010101; +#endif + } + break; + // default + default: + unreadable: +#ifdef GBA_LOGGING + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal word read: %08x at %08x\n", + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } +#endif + if (cpuDmaHack) { + value = cpuDmaLast; + } else { + if (armState) { + return CPUReadMemoryQuick(reg[15].I); + } else { + return CPUReadHalfWordQuick(reg[15].I) | + CPUReadHalfWordQuick(reg[15].I) << 16; + } + } + break; + } + + if (oldAddress & 3) { #ifdef C_CORE - int shift = (oldAddress & 3) << 3; - value = (value >> shift) | (value << (32 - shift)); + int shift = (oldAddress & 3) << 3; + value = (value >> shift) | (value << (32 - shift)); #else #ifdef __GNUC__ - asm("and $3, %%ecx;" - "shl $3 ,%%ecx;" - "ror %%cl, %0" - : "=r" (value) - : "r" (value), "c" (oldAddress)); + asm("and $3, %%ecx;" + "shl $3 ,%%ecx;" + "ror %%cl, %0" + : "=r"(value) + : "r"(value), "c"(oldAddress)); #else - __asm { + __asm { mov ecx, oldAddress; and ecx, 3; shl ecx, 3; ror [dword ptr value], cl; - } + } #endif #endif - } + } #ifdef GBA_LOGGING - if(oldAddress & 3) { - if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { - log("Unaligned word read from: %08x at %08x (%08x)\n", oldAddress, armMode ? - armNextPC - 4 : armNextPC - 2, value); - } - } + if (oldAddress & 3) { + if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned word read from: %08x at %08x (%08x)\n", + oldAddress, + armMode ? armNextPC - 4 : armNextPC - 2, + value); + } + } #endif - return value; + return value; } static inline u32 CPUReadHalfWord(u32 address) { #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnRead(address, 1)){ - //CPU_BREAK_LOOP_2; - } - } -#endif - - u32 value; - u32 oldAddress = address; - - if(address & 1) { - address &= ~0x01; - } - - switch(address >> 24) { - case 0: - if (reg[15].I >> 24) { - if(address < 0x4000) { -#ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal halfword read from bios: %08x at %08x\n", oldAddress, armMode ? - armNextPC - 4 : armNextPC - 2); + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnRead(address, 1)) { + // CPU_BREAK_LOOP_2; + } } #endif - value = READ16LE(((u16 *)&biosProtected[address&2])); - } else goto unreadable; - } else - value = READ16LE(((u16 *)&bios[address & 0x3FFE])); - break; - case 2: - value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE])); - break; - case 3: - value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe])); - break; - case 4: - if((address < 0x4000400) && ioReadable[address & 0x3fe]) - { - value = READ16LE(((u16 *)&ioMem[address & 0x3fe])); - if (((address & 0x3fe)>0xFF) && ((address & 0x3fe)<0x10E)) - { - if (((address & 0x3fe) == 0x100) && timer0On) - value = 0xFFFF - ((timer0Ticks-cpuTotalTicks) >> timer0ClockReload); - else - if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4)) - value = 0xFFFF - ((timer1Ticks-cpuTotalTicks) >> timer1ClockReload); - else - if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4)) - value = 0xFFFF - ((timer2Ticks-cpuTotalTicks) >> timer2ClockReload); - else - if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4)) - value = 0xFFFF - ((timer3Ticks-cpuTotalTicks) >> timer3ClockReload); - } - } - else if((address < 0x4000400) && ioReadable[address & 0x3fc]) - { - value = 0; - } - else goto unreadable; - break; - case 5: - value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe])); - break; - case 6: - address = (address & 0x1fffe); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - { - value = 0; - break; - } - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; - value = READ16LE(((u16 *)&vram[address])); - break; - case 7: - value = READ16LE(((u16 *)&oam[address & 0x3fe])); - break; - case 8: - case 9: - case 10: - case 11: - case 12: - if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) - value = rtcRead(address); - else - value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE])); - break; - case 13: - if(cpuEEPROMEnabled) - // no need to swap this - return eepromRead(address); - goto unreadable; - case 14: - case 15: - if(cpuFlashEnabled | cpuSramEnabled) - // no need to swap this - { - #ifdef __libretro__ - return flashRead(address); - #else - value = flashRead(address) * 0x0101; - #endif - } - // default - default: -unreadable: - if(cpuDmaHack) { - value = cpuDmaLast & 0xFFFF; - } else { - if(armState) { - value = CPUReadHalfWordQuick(reg[15].I + (address & 2)); - } else { - value = CPUReadHalfWordQuick(reg[15].I); - } - } + + u32 value; + u32 oldAddress = address; + + if (address & 1) { + address &= ~0x01; + } + + switch (address >> 24) { + case 0: + if (reg[15].I >> 24) { + if (address < 0x4000) { #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal halfword read: %08x at %08x (%08x)\n", oldAddress, reg[15].I, value); - } + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal halfword read from bios: %08x at %08x\n", + oldAddress, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - return value; - } + value = READ16LE(((u16 *)&biosProtected[address & 2])); + } else + goto unreadable; + } else + value = READ16LE(((u16 *)&bios[address & 0x3FFE])); + break; + case 2: + value = READ16LE(((u16 *)&workRAM[address & 0x3FFFE])); + break; + case 3: + value = READ16LE(((u16 *)&internalRAM[address & 0x7ffe])); + break; + case 4: + if ((address < 0x4000400) && ioReadable[address & 0x3fe]) { + value = READ16LE(((u16 *)&ioMem[address & 0x3fe])); + if (((address & 0x3fe) > 0xFF) && ((address & 0x3fe) < 0x10E)) { + if (((address & 0x3fe) == 0x100) && timer0On) + value = 0xFFFF - ((timer0Ticks - cpuTotalTicks) >> + timer0ClockReload); + else if (((address & 0x3fe) == 0x104) && timer1On && !(TM1CNT & 4)) + value = 0xFFFF - ((timer1Ticks - cpuTotalTicks) >> + timer1ClockReload); + else if (((address & 0x3fe) == 0x108) && timer2On && !(TM2CNT & 4)) + value = 0xFFFF - ((timer2Ticks - cpuTotalTicks) >> + timer2ClockReload); + else if (((address & 0x3fe) == 0x10C) && timer3On && !(TM3CNT & 4)) + value = 0xFFFF - ((timer3Ticks - cpuTotalTicks) >> + timer3ClockReload); + } + } else if ((address < 0x4000400) && ioReadable[address & 0x3fc]) { + value = 0; + } else + goto unreadable; + break; + case 5: + value = READ16LE(((u16 *)&paletteRAM[address & 0x3fe])); + break; + case 6: + address = (address & 0x1fffe); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) { + value = 0; + break; + } + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; + value = READ16LE(((u16 *)&vram[address])); + break; + case 7: + value = READ16LE(((u16 *)&oam[address & 0x3fe])); + break; + case 8: + case 9: + case 10: + case 11: + case 12: + if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) + value = rtcRead(address); + else + value = READ16LE(((u16 *)&rom[address & 0x1FFFFFE])); + break; + case 13: + if (cpuEEPROMEnabled) + // no need to swap this + return eepromRead(address); + goto unreadable; + case 14: + case 15: + if (cpuFlashEnabled | cpuSramEnabled) + // no need to swap this + { +#ifdef __libretro__ + return flashRead(address); +#else + value = flashRead(address) * 0x0101; +#endif + } + // default + default: + unreadable: + if (cpuDmaHack) { + value = cpuDmaLast & 0xFFFF; + } else { + if (armState) { + value = CPUReadHalfWordQuick(reg[15].I + (address & 2)); + } else { + value = CPUReadHalfWordQuick(reg[15].I); + } + } +#ifdef GBA_LOGGING + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal halfword read: %08x at %08x (%08x)\n", + oldAddress, + reg[15].I, + value); + } +#endif + return value; + } - if(oldAddress & 1) { - value = (value >> 8) | (value << 24); - #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { - log("Unaligned halfword read from: %08x at %08x (%08x)\n", oldAddress, armMode ? - armNextPC - 4 : armNextPC - 2, value); - } - #endif - } + if (oldAddress & 1) { + value = (value >> 8) | (value << 24); +#ifdef GBA_LOGGING + if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned halfword read from: %08x at %08x (%08x)\n", + oldAddress, + armMode ? armNextPC - 4 : armNextPC - 2, + value); + } +#endif + } - return value; + return value; } static inline s16 CPUReadHalfWordSigned(u32 address) { - s32 value = (s32)CPUReadHalfWord(address); - if((address & 1)) - { + s32 value = (s32)CPUReadHalfWord(address); + if ((address & 1)) { #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { - log("Unaligned signed halfword read from: %08x at %08x (%08x)\n", address, armMode ? - armNextPC - 4 : armNextPC - 2, value); - } + if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned signed halfword read from: %08x at %08x (%08x)\n", + address, + armMode ? armNextPC - 4 : armNextPC - 2, + value); + } #endif - } - return (s16)value; + } + return (s16)value; } static inline u8 CPUReadByte(u32 address) { #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnRead(address, 0)){ - //CPU_BREAK_LOOP_2; - } - } -#endif - - switch(address >> 24) { - case 0: - if (reg[15].I >> 24) { - if(address < 0x4000) { -#ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal byte read from bios: %08x at %08x\n", address, armMode ? - armNextPC - 4 : armNextPC - 2); + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakReadCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnRead(address, 0)) { + // CPU_BREAK_LOOP_2; + } } #endif - return biosProtected[address & 3]; - } else goto unreadable; - } - return bios[address & 0x3FFF]; - case 2: - return workRAM[address & 0x3FFFF]; - case 3: - return internalRAM[address & 0x7fff]; - case 4: - if((address < 0x4000400) && ioReadable[address & 0x3ff]) - return ioMem[address & 0x3ff]; - else goto unreadable; - case 5: - return paletteRAM[address & 0x3ff]; - case 6: - address = (address & 0x1ffff); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - return 0; - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; - return vram[address]; - case 7: - return oam[address & 0x3ff]; - case 8: - case 9: - case 10: - case 11: - case 12: - return rom[address & 0x1FFFFFF]; - case 13: - if(cpuEEPROMEnabled) - return eepromRead(address); - goto unreadable; - case 14: - case 15: - if (cpuSramEnabled | cpuFlashEnabled) - return flashRead(address); - switch(address & 0x00008f00) { - case 0x8200: - return systemGetSensorX() & 255; - case 0x8300: - return (systemGetSensorX() >> 8)|0x80; - case 0x8400: - return systemGetSensorY() & 255; - case 0x8500: - return systemGetSensorY() >> 8; - } - // default - default: -unreadable: + switch (address >> 24) { + case 0: + if (reg[15].I >> 24) { + if (address < 0x4000) { #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_READ) { - log("Illegal byte read: %08x at %08x\n", address, armMode ? - armNextPC - 4 : armNextPC - 2); - } + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal byte read from bios: %08x at %08x\n", + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - if(cpuDmaHack) { - return cpuDmaLast & 0xFF; - } else { - if(armState) { - return CPUReadByteQuick(reg[15].I + (address & 3)); - } else { - return CPUReadByteQuick(reg[15].I + (address & 1)); - } - } - } + return biosProtected[address & 3]; + } else + goto unreadable; + } + return bios[address & 0x3FFF]; + case 2: + return workRAM[address & 0x3FFFF]; + case 3: + return internalRAM[address & 0x7fff]; + case 4: + if ((address < 0x4000400) && ioReadable[address & 0x3ff]) + return ioMem[address & 0x3ff]; + else + goto unreadable; + case 5: + return paletteRAM[address & 0x3ff]; + case 6: + address = (address & 0x1ffff); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) + return 0; + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; + return vram[address]; + case 7: + return oam[address & 0x3ff]; + case 8: + case 9: + case 10: + case 11: + case 12: + return rom[address & 0x1FFFFFF]; + case 13: + if (cpuEEPROMEnabled) + return eepromRead(address); + goto unreadable; + case 14: + case 15: + if (cpuSramEnabled | cpuFlashEnabled) + return flashRead(address); + + switch (address & 0x00008f00) { + case 0x8200: + return systemGetSensorX() & 255; + case 0x8300: + return (systemGetSensorX() >> 8) | 0x80; + case 0x8400: + return systemGetSensorY() & 255; + case 0x8500: + return systemGetSensorY() >> 8; + } + // default + default: + unreadable: +#ifdef GBA_LOGGING + if (systemVerbose & VERBOSE_ILLEGAL_READ) { + log("Illegal byte read: %08x at %08x\n", + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } +#endif + if (cpuDmaHack) { + return cpuDmaLast & 0xFF; + } else { + if (armState) { + return CPUReadByteQuick(reg[15].I + (address & 3)); + } else { + return CPUReadByteQuick(reg[15].I + (address & 1)); + } + } + } } static inline void CPUWriteMemory(u32 address, u32 value) { - #ifdef GBA_LOGGING - if(address & 3) { - if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { - log("Unaligned word write: %08x to %08x from %08x\n", - value, - address, - armMode ? armNextPC - 4 : armNextPC - 2); - } - } + if (address & 3) { + if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned word write: %08x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } + } #endif #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnWrite(address, value, 1)){ - //CPU_BREAK_LOOP_2; - } - } + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnWrite(address, value, 1)) { + // CPU_BREAK_LOOP_2; + } + } #endif - address &= 0xFFFFFFFC; + address &= 0xFFFFFFFC; - switch(address >> 24) { - case 0x02: + switch (address >> 24) { + case 0x02: #ifdef BKPT_SUPPORT - if(*((u32 *)&freezeWorkRAM[address & 0x3FFFC])) - cheatsWriteMemory(address & 0x203FFFC, - value); - else + if (*((u32 *)&freezeWorkRAM[address & 0x3FFFC])) + cheatsWriteMemory(address & 0x203FFFC, value); + else #endif - WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value); - break; - case 0x03: + WRITE32LE(((u32 *)&workRAM[address & 0x3FFFC]), value); + break; + case 0x03: #ifdef BKPT_SUPPORT - if(*((u32 *)&freezeInternalRAM[address & 0x7ffc])) - cheatsWriteMemory(address & 0x3007FFC, - value); - else + if (*((u32 *)&freezeInternalRAM[address & 0x7ffc])) + cheatsWriteMemory(address & 0x3007FFC, value); + else #endif - WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value); - break; - case 0x04: - if(address < 0x4000400) { - CPUUpdateRegister((address & 0x3FC), value & 0xFFFF); - CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16)); - } else goto unwritable; - break; - case 0x05: + WRITE32LE(((u32 *)&internalRAM[address & 0x7ffC]), value); + break; + case 0x04: + if (address < 0x4000400) { + CPUUpdateRegister((address & 0x3FC), value & 0xFFFF); + CPUUpdateRegister((address & 0x3FC) + 2, (value >> 16)); + } else + goto unwritable; + break; + case 0x05: #ifdef BKPT_SUPPORT - if(*((u32 *)&freezePRAM[address & 0x3fc])) - cheatsWriteMemory(address & 0x70003FC, - value); - else + if (*((u32 *)&freezePRAM[address & 0x3fc])) + cheatsWriteMemory(address & 0x70003FC, value); + else #endif - WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value); - break; - case 0x06: - address = (address & 0x1fffc); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - return; - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; + WRITE32LE(((u32 *)&paletteRAM[address & 0x3FC]), value); + break; + case 0x06: + address = (address & 0x1fffc); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) + return; + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; #ifdef BKPT_SUPPORT - if(*((u32 *)&freezeVRAM[address])) - cheatsWriteMemory(address + 0x06000000, value); - else + if (*((u32 *)&freezeVRAM[address])) + cheatsWriteMemory(address + 0x06000000, value); + else #endif - WRITE32LE(((u32 *)&vram[address]), value); - break; - case 0x07: + WRITE32LE(((u32 *)&vram[address]), value); + break; + case 0x07: #ifdef BKPT_SUPPORT - if(*((u32 *)&freezeOAM[address & 0x3fc])) - cheatsWriteMemory(address & 0x70003FC, - value); - else + if (*((u32 *)&freezeOAM[address & 0x3fc])) + cheatsWriteMemory(address & 0x70003FC, value); + else #endif - WRITE32LE(((u32 *)&oam[address & 0x3fc]), value); - break; - case 0x0D: - if(cpuEEPROMEnabled) { - eepromWrite(address, value); - break; - } - goto unwritable; - case 0x0E: - case 0x0F: - if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) { - (*cpuSaveGameFunc)(address, (u8)value); - break; - } - // default - default: -unwritable: + WRITE32LE(((u32 *)&oam[address & 0x3fc]), value); + break; + case 0x0D: + if (cpuEEPROMEnabled) { + eepromWrite(address, value); + break; + } + goto unwritable; + case 0x0E: + case 0x0F: + if ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) { + (*cpuSaveGameFunc)(address, (u8)value); + break; + } + // default + default: + unwritable: #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { - log("Illegal word write: %08x to %08x from %08x\n", - value, - address, - armMode ? armNextPC - 4 : armNextPC - 2); - } + if (systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal word write: %08x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - break; - } + break; + } } static inline void CPUWriteHalfWord(u32 address, u16 value) { #ifdef GBA_LOGGING - if(address & 1) { - if(systemVerbose & VERBOSE_UNALIGNED_MEMORY) { - log("Unaligned halfword write: %04x to %08x from %08x\n", - value, - address, - armMode ? armNextPC - 4 : armNextPC - 2); - } - } + if (address & 1) { + if (systemVerbose & VERBOSE_UNALIGNED_MEMORY) { + log("Unaligned halfword write: %04x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } + } #endif #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnWrite(address, value, 1)){ - //CPU_BREAK_LOOP_2; - } - } + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnWrite(address, value, 1)) { + // CPU_BREAK_LOOP_2; + } + } #endif - address &= 0xFFFFFFFE; + address &= 0xFFFFFFFE; - switch(address >> 24) { - case 2: + switch (address >> 24) { + case 2: #ifdef BKPT_SUPPORT - if(*((u16 *)&freezeWorkRAM[address & 0x3FFFE])) - cheatsWriteHalfWord(address & 0x203FFFE, - value); - else + if (*((u16 *)&freezeWorkRAM[address & 0x3FFFE])) + cheatsWriteHalfWord(address & 0x203FFFE, value); + else #endif - WRITE16LE(((u16 *)&workRAM[address & 0x3FFFE]),value); - break; - case 3: + WRITE16LE(((u16 *)&workRAM[address & 0x3FFFE]), value); + break; + case 3: #ifdef BKPT_SUPPORT - if(*((u16 *)&freezeInternalRAM[address & 0x7ffe])) - cheatsWriteHalfWord(address & 0x3007ffe, - value); - else + if (*((u16 *)&freezeInternalRAM[address & 0x7ffe])) + cheatsWriteHalfWord(address & 0x3007ffe, value); + else #endif - WRITE16LE(((u16 *)&internalRAM[address & 0x7ffe]), value); - break; - case 4: - if(address < 0x4000400) - CPUUpdateRegister(address & 0x3fe, value); - else goto unwritable; - break; - case 5: + WRITE16LE(((u16 *)&internalRAM[address & 0x7ffe]), value); + break; + case 4: + if (address < 0x4000400) + CPUUpdateRegister(address & 0x3fe, value); + else + goto unwritable; + break; + case 5: #ifdef BKPT_SUPPORT - if(*((u16 *)&freezePRAM[address & 0x03fe])) - cheatsWriteHalfWord(address & 0x70003fe, - value); - else + if (*((u16 *)&freezePRAM[address & 0x03fe])) + cheatsWriteHalfWord(address & 0x70003fe, value); + else #endif - WRITE16LE(((u16 *)&paletteRAM[address & 0x3fe]), value); - break; - case 6: - address = (address & 0x1fffe); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - return; - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; + WRITE16LE(((u16 *)&paletteRAM[address & 0x3fe]), value); + break; + case 6: + address = (address & 0x1fffe); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) + return; + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; #ifdef BKPT_SUPPORT - if(*((u16 *)&freezeVRAM[address])) - cheatsWriteHalfWord(address + 0x06000000, - value); - else + if (*((u16 *)&freezeVRAM[address])) + cheatsWriteHalfWord(address + 0x06000000, value); + else #endif - WRITE16LE(((u16 *)&vram[address]), value); - break; - case 7: + WRITE16LE(((u16 *)&vram[address]), value); + break; + case 7: #ifdef BKPT_SUPPORT - if(*((u16 *)&freezeOAM[address & 0x03fe])) - cheatsWriteHalfWord(address & 0x70003fe, - value); - else + if (*((u16 *)&freezeOAM[address & 0x03fe])) + cheatsWriteHalfWord(address & 0x70003fe, value); + else #endif - WRITE16LE(((u16 *)&oam[address & 0x3fe]), value); - break; - case 8: - case 9: - if(address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) { - if(!rtcWrite(address, value)) - goto unwritable; - } else if(!agbPrintWrite(address, value)) goto unwritable; - break; - case 13: - if(cpuEEPROMEnabled) { - eepromWrite(address, (u8)value); - break; - } - goto unwritable; - case 14: - case 15: - if((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) { - (*cpuSaveGameFunc)(address, (u8)value); - break; - } - goto unwritable; - default: -unwritable: + WRITE16LE(((u16 *)&oam[address & 0x3fe]), value); + break; + case 8: + case 9: + if (address == 0x80000c4 || address == 0x80000c6 || address == 0x80000c8) { + if (!rtcWrite(address, value)) + goto unwritable; + } else if (!agbPrintWrite(address, value)) + goto unwritable; + break; + case 13: + if (cpuEEPROMEnabled) { + eepromWrite(address, (u8)value); + break; + } + goto unwritable; + case 14: + case 15: + if ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled) { + (*cpuSaveGameFunc)(address, (u8)value); + break; + } + goto unwritable; + default: + unwritable: #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { - log("Illegal halfword write: %04x to %08x from %08x\n", - value, - address, - armMode ? armNextPC - 4 : armNextPC - 2); - } + if (systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal halfword write: %04x to %08x from %08x\n", + value, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - break; - } + break; + } } static inline void CPUWriteByte(u32 address, u8 b) { #ifdef BKPT_SUPPORT - memoryMap *m = &map[address >> 24]; - if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { - if (debuggerBreakOnWrite(address, b, 1)){ - //CPU_BREAK_LOOP_2; - } - } -#endif - - switch(address >> 24) { - case 2: -#ifdef BKPT_SUPPORT - if(freezeWorkRAM[address & 0x3FFFF]) - cheatsWriteByte(address & 0x203FFFF, b); - else -#endif - workRAM[address & 0x3FFFF] = b; - break; - case 3: -#ifdef BKPT_SUPPORT - if(freezeInternalRAM[address & 0x7fff]) - cheatsWriteByte(address & 0x3007fff, b); - else -#endif - internalRAM[address & 0x7fff] = b; - break; - case 4: - if(address < 0x4000400) { - switch(address & 0x3FF) { - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x68: - case 0x69: - case 0x6c: - case 0x6d: - case 0x70: - case 0x71: - case 0x72: - case 0x73: - case 0x74: - case 0x75: - case 0x78: - case 0x79: - case 0x7c: - case 0x7d: - case 0x80: - case 0x81: - case 0x84: - case 0x85: - case 0x90: - case 0x91: - case 0x92: - case 0x93: - case 0x94: - case 0x95: - case 0x96: - case 0x97: - case 0x98: - case 0x99: - case 0x9a: - case 0x9b: - case 0x9c: - case 0x9d: - case 0x9e: - case 0x9f: - soundEvent(address&0xFF, b); - break; - case 0x301: // HALTCNT, undocumented - if(b == 0x80) - stopState = true; - holdState = 1; - holdType = -1; - cpuNextEvent = cpuTotalTicks; - break; - default: // every other register - u32 lowerBits = address & 0x3fe; - if(address & 1) { - CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0x00FF) | (b << 8)); - } else { - CPUUpdateRegister(lowerBits, (READ16LE(&ioMem[lowerBits]) & 0xFF00) | b); + memoryMap *m = &map[address >> 24]; + if (m->breakPoints && BreakWriteCheck(m->breakPoints, address & m->mask)) { + if (debuggerBreakOnWrite(address, b, 1)) { + // CPU_BREAK_LOOP_2; + } } - } - break; - } else goto unwritable; - break; - case 5: - // no need to switch - *((u16 *)&paletteRAM[address & 0x3FE]) = (b << 8) | b; - break; - case 6: - address = (address & 0x1fffe); - if (((DISPCNT & 7) >2) && ((address & 0x1C000) == 0x18000)) - return; - if ((address & 0x18000) == 0x18000) - address &= 0x17fff; +#endif - // no need to switch - // byte writes to OBJ VRAM are ignored - if ((address) < objTilesAddress[((DISPCNT&7)+1)>>2]) - { + switch (address >> 24) { + case 2: #ifdef BKPT_SUPPORT - if(freezeVRAM[address]) - cheatsWriteByte(address + 0x06000000, b); - else + if (freezeWorkRAM[address & 0x3FFFF]) + cheatsWriteByte(address & 0x203FFFF, b); + else #endif - *((u16 *)&vram[address]) = (b << 8) | b; - } - break; - case 7: - // no need to switch - // byte writes to OAM are ignored - // *((u16 *)&oam[address & 0x3FE]) = (b << 8) | b; - break; - case 13: - if(cpuEEPROMEnabled) { - eepromWrite(address, b); - break; - } - goto unwritable; - case 14: - case 15: - if ((saveType != 5) && ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled)) { + workRAM[address & 0x3FFFF] = b; + break; + case 3: +#ifdef BKPT_SUPPORT + if (freezeInternalRAM[address & 0x7fff]) + cheatsWriteByte(address & 0x3007fff, b); + else +#endif + internalRAM[address & 0x7fff] = b; + break; + case 4: + if (address < 0x4000400) { + switch (address & 0x3FF) { + case 0x60: + case 0x61: + case 0x62: + case 0x63: + case 0x64: + case 0x65: + case 0x68: + case 0x69: + case 0x6c: + case 0x6d: + case 0x70: + case 0x71: + case 0x72: + case 0x73: + case 0x74: + case 0x75: + case 0x78: + case 0x79: + case 0x7c: + case 0x7d: + case 0x80: + case 0x81: + case 0x84: + case 0x85: + case 0x90: + case 0x91: + case 0x92: + case 0x93: + case 0x94: + case 0x95: + case 0x96: + case 0x97: + case 0x98: + case 0x99: + case 0x9a: + case 0x9b: + case 0x9c: + case 0x9d: + case 0x9e: + case 0x9f: + soundEvent(address & 0xFF, b); + break; + case 0x301: // HALTCNT, undocumented + if (b == 0x80) + stopState = true; + holdState = 1; + holdType = -1; + cpuNextEvent = cpuTotalTicks; + break; + default: // every other register + u32 lowerBits = address & 0x3fe; + if (address & 1) { + CPUUpdateRegister(lowerBits, + (READ16LE(&ioMem[lowerBits]) & 0x00FF) | + (b << 8)); + } else { + CPUUpdateRegister(lowerBits, + (READ16LE(&ioMem[lowerBits]) & 0xFF00) | + b); + } + } + break; + } else + goto unwritable; + break; + case 5: + // no need to switch + *((u16 *)&paletteRAM[address & 0x3FE]) = (b << 8) | b; + break; + case 6: + address = (address & 0x1fffe); + if (((DISPCNT & 7) > 2) && ((address & 0x1C000) == 0x18000)) + return; + if ((address & 0x18000) == 0x18000) + address &= 0x17fff; - //if(!cpuEEPROMEnabled && (cpuSramEnabled | cpuFlashEnabled)) { + // no need to switch + // byte writes to OBJ VRAM are ignored + if ((address) < objTilesAddress[((DISPCNT & 7) + 1) >> 2]) { +#ifdef BKPT_SUPPORT + if (freezeVRAM[address]) + cheatsWriteByte(address + 0x06000000, b); + else +#endif + *((u16 *)&vram[address]) = (b << 8) | b; + } + break; + case 7: + // no need to switch + // byte writes to OAM are ignored + // *((u16 *)&oam[address & 0x3FE]) = (b << 8) | b; + break; + case 13: + if (cpuEEPROMEnabled) { + eepromWrite(address, b); + break; + } + goto unwritable; + case 14: + case 15: + if ((saveType != 5) && ((!eepromInUse) | cpuSramEnabled | cpuFlashEnabled)) { + // if(!cpuEEPROMEnabled && (cpuSramEnabled | cpuFlashEnabled)) { - (*cpuSaveGameFunc)(address, b); - break; - } - // default - default: -unwritable: + (*cpuSaveGameFunc)(address, b); + break; + } + // default + default: + unwritable: #ifdef GBA_LOGGING - if(systemVerbose & VERBOSE_ILLEGAL_WRITE) { - log("Illegal byte write: %02x to %08x from %08x\n", - b, - address, - armMode ? armNextPC - 4 : armNextPC -2 ); - } + if (systemVerbose & VERBOSE_ILLEGAL_WRITE) { + log("Illegal byte write: %02x to %08x from %08x\n", + b, + address, + armMode ? armNextPC - 4 : armNextPC - 2); + } #endif - break; - } + break; + } } #endif // GBAINLINE_H diff --git a/src/gba/Globals.h b/src/gba/Globals.h index 044a75e1..e460d85d 100644 --- a/src/gba/Globals.h +++ b/src/gba/Globals.h @@ -4,17 +4,17 @@ #include "../common/Types.h" #include "GBA.h" -#define VERBOSE_SWI 1 -#define VERBOSE_UNALIGNED_MEMORY 2 -#define VERBOSE_ILLEGAL_WRITE 4 -#define VERBOSE_ILLEGAL_READ 8 -#define VERBOSE_DMA0 16 -#define VERBOSE_DMA1 32 -#define VERBOSE_DMA2 64 -#define VERBOSE_DMA3 128 -#define VERBOSE_UNDEFINED 256 -#define VERBOSE_AGBPRINT 512 -#define VERBOSE_SOUNDOUTPUT 1024 +#define VERBOSE_SWI 1 +#define VERBOSE_UNALIGNED_MEMORY 2 +#define VERBOSE_ILLEGAL_WRITE 4 +#define VERBOSE_ILLEGAL_READ 8 +#define VERBOSE_DMA0 16 +#define VERBOSE_DMA1 32 +#define VERBOSE_DMA2 64 +#define VERBOSE_DMA3 128 +#define VERBOSE_UNDEFINED 256 +#define VERBOSE_AGBPRINT 512 +#define VERBOSE_SOUNDOUTPUT 1024 extern reg_pair reg[45]; extern bool ioReadable[0x400]; diff --git a/src/gba/Sound.h b/src/gba/Sound.h index 47750a77..e916169e 100644 --- a/src/gba/Sound.h +++ b/src/gba/Sound.h @@ -15,7 +15,7 @@ bool soundInit(); void soundSetThrottle(unsigned short throttle); // Manages sound volume, where 1.0 is normal -void soundSetVolume( float ); +void soundSetVolume(float); float soundGetVolume(); // Manages muting bitmask. The bits control the following channels: @@ -25,8 +25,8 @@ float soundGetVolume(); // 0x008 Noise // 0x100 PCM 1 // 0x200 PCM 2 -void soundSetEnable( int mask ); -int soundGetEnable(); +void soundSetEnable(int mask); +int soundGetEnable(); // Pauses/resumes system sound output void soundPause(); @@ -45,7 +45,6 @@ void soundSetSampleRate(long sampleRate); extern bool soundInterpolation; // 1 if PCM should have low-pass filtering extern float soundFiltering; // 0.0 = none, 1.0 = max - //// GBA sound emulation // GBA sound registers @@ -59,31 +58,31 @@ extern float soundFiltering; // 0.0 = none, 1.0 = max void soundReset(); // Emulates write to sound hardware -void soundEvent( u32 addr, u8 data ); -void soundEvent( u32 addr, u16 data ); // TODO: error-prone to overload like this +void soundEvent(u32 addr, u8 data); +void soundEvent(u32 addr, u16 data); // TODO: error-prone to overload like this // Notifies emulator that a timer has overflowed -void soundTimerOverflow( int which ); +void soundTimerOverflow(int which); // Notifies emulator that PCM rate may have changed void interp_rate(); // Notifies emulator that SOUND_CLOCK_TICKS clocks have passed void psoundTickfn(); -extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to soundTick() -extern int soundTicks; // Number of 16.8 MHz clocks until soundTick() will be called +extern int SOUND_CLOCK_TICKS; // Number of 16.8 MHz clocks between calls to soundTick() +extern int soundTicks; // Number of 16.8 MHz clocks until soundTick() will be called // Saves/loads emulator state #ifdef __LIBRETRO__ -void soundSaveGame( u8 *& ); -void soundReadGame(const u8*& in, int version ); +void soundSaveGame(u8 *&); +void soundReadGame(const u8 *&in, int version); #else -void soundSaveGame( gzFile ); -void soundReadGame( gzFile, int version ); +void soundSaveGame(gzFile); +void soundReadGame(gzFile, int version); #endif class Multi_Buffer; -void flush_samples(Multi_Buffer * buffer); +void flush_samples(Multi_Buffer *buffer); #endif // SOUND_H diff --git a/src/gba/elf.h b/src/gba/elf.h index 6c28e6cb..4fdab0aa 100644 --- a/src/gba/elf.h +++ b/src/gba/elf.h @@ -1,256 +1,252 @@ #ifndef ELF_H #define ELF_H -enum LocationType { - LOCATION_register, - LOCATION_memory, - LOCATION_value -}; +enum LocationType { LOCATION_register, LOCATION_memory, LOCATION_value }; -#define DW_ATE_boolean 0x02 -#define DW_ATE_signed 0x05 -#define DW_ATE_unsigned 0x07 +#define DW_ATE_boolean 0x02 +#define DW_ATE_signed 0x05 +#define DW_ATE_unsigned 0x07 #define DW_ATE_unsigned_char 0x08 struct ELFHeader { - u32 magic; - u8 clazz; - u8 data; - u8 version; - u8 pad[9]; - u16 e_type; - u16 e_machine; - u32 e_version; - u32 e_entry; - u32 e_phoff; - u32 e_shoff; - u32 e_flags; - u16 e_ehsize; - u16 e_phentsize; - u16 e_phnum; - u16 e_shentsize; - u16 e_shnum; - u16 e_shstrndx; + u32 magic; + u8 clazz; + u8 data; + u8 version; + u8 pad[9]; + u16 e_type; + u16 e_machine; + u32 e_version; + u32 e_entry; + u32 e_phoff; + u32 e_shoff; + u32 e_flags; + u16 e_ehsize; + u16 e_phentsize; + u16 e_phnum; + u16 e_shentsize; + u16 e_shnum; + u16 e_shstrndx; }; struct ELFProgramHeader { - u32 type; - u32 offset; - u32 vaddr; - u32 paddr; - u32 filesz; - u32 memsz; - u32 flags; - u32 align; + u32 type; + u32 offset; + u32 vaddr; + u32 paddr; + u32 filesz; + u32 memsz; + u32 flags; + u32 align; }; struct ELFSectionHeader { - u32 name; - u32 type; - u32 flags; - u32 addr; - u32 offset; - u32 size; - u32 link; - u32 info; - u32 addralign; - u32 entsize; + u32 name; + u32 type; + u32 flags; + u32 addr; + u32 offset; + u32 size; + u32 link; + u32 info; + u32 addralign; + u32 entsize; }; struct ELFSymbol { - u32 name; - u32 value; - u32 size; - u8 info; - u8 other; - u16 shndx; + u32 name; + u32 value; + u32 size; + u8 info; + u8 other; + u16 shndx; }; struct ELFBlock { - int length; - u8 *data; + int length; + u8 *data; }; struct ELFAttr { - u32 name; - u32 form; - union { - u32 value; - char *string; - u8 *data; - bool flag; - ELFBlock *block; - }; + u32 name; + u32 form; + union { + u32 value; + char *string; + u8 *data; + bool flag; + ELFBlock *block; + }; }; struct ELFAbbrev { - u32 number; - u32 tag; - bool hasChildren; - int numAttrs; - ELFAttr *attrs; - ELFAbbrev *next; + u32 number; + u32 tag; + bool hasChildren; + int numAttrs; + ELFAttr *attrs; + ELFAbbrev *next; }; enum TypeEnum { - TYPE_base, - TYPE_pointer, - TYPE_function, - TYPE_void, - TYPE_array, - TYPE_struct, - TYPE_reference, - TYPE_enum, - TYPE_union + TYPE_base, + TYPE_pointer, + TYPE_function, + TYPE_void, + TYPE_array, + TYPE_struct, + TYPE_reference, + TYPE_enum, + TYPE_union }; struct Type; struct Object; struct FunctionType { - Type *returnType; - Object *args; + Type *returnType; + Object *args; }; struct Member { - char *name; - Type *type; - int bitSize; - int bitOffset; - int byteSize; - ELFBlock *location; + char *name; + Type *type; + int bitSize; + int bitOffset; + int byteSize; + ELFBlock *location; }; struct Struct { - int memberCount; - Member *members; + int memberCount; + Member *members; }; struct Array { - Type *type; - int maxBounds; - int *bounds; + Type *type; + int maxBounds; + int *bounds; }; struct EnumMember { - char *name; - u32 value; + char *name; + u32 value; }; struct Enum { - int count; - EnumMember *members; + int count; + EnumMember *members; }; struct Type { - u32 offset; - TypeEnum type; - const char *name; - int encoding; - int size; - int bitSize; - union { - Type *pointer; - FunctionType *function; - Array *array; - Struct *structure; - Enum *enumeration; - }; - Type *next; + u32 offset; + TypeEnum type; + const char *name; + int encoding; + int size; + int bitSize; + union { + Type *pointer; + FunctionType *function; + Array *array; + Struct *structure; + Enum *enumeration; + }; + Type *next; }; struct Object { - char *name; - int file; - int line; - bool external; - Type *type; - ELFBlock *location; - u32 startScope; - u32 endScope; - Object *next; + char *name; + int file; + int line; + bool external; + Type *type; + ELFBlock *location; + u32 startScope; + u32 endScope; + Object *next; }; struct Function { - char *name; - u32 lowPC; - u32 highPC; - int file; - int line; - bool external; - Type *returnType; - Object *parameters; - Object *variables; - ELFBlock *frameBase; - Function *next; + char *name; + u32 lowPC; + u32 highPC; + int file; + int line; + bool external; + Type *returnType; + Object *parameters; + Object *variables; + ELFBlock *frameBase; + Function *next; }; struct LineInfoItem { - u32 address; - char *file; - int line; + u32 address; + char *file; + int line; }; struct LineInfo { - int fileCount; - char **files; - int number; - LineInfoItem *lines; + int fileCount; + char **files; + int number; + LineInfoItem *lines; }; struct ARange { - u32 lowPC; - u32 highPC; + u32 lowPC; + u32 highPC; }; struct ARanges { - u32 offset; - int count; - ARange *ranges; + u32 offset; + int count; + ARange *ranges; }; struct CompileUnit { - u32 length; - u8 *top; - u32 offset; - ELFAbbrev **abbrevs; - ARanges *ranges; - char *name; - char *compdir; - u32 lowPC; - u32 highPC; - bool hasLineInfo; - u32 lineInfo; - LineInfo *lineInfoTable; - Function *functions; - Function *lastFunction; - Object *variables; - Type *types; - CompileUnit *next; + u32 length; + u8 *top; + u32 offset; + ELFAbbrev **abbrevs; + ARanges *ranges; + char *name; + char *compdir; + u32 lowPC; + u32 highPC; + bool hasLineInfo; + u32 lineInfo; + LineInfo *lineInfoTable; + Function *functions; + Function *lastFunction; + Object *variables; + Type *types; + CompileUnit *next; }; struct DebugInfo { - u8 *debugfile; - u8 *abbrevdata; - u8 *debugdata; - u8 *infodata; - int numRanges; - ARanges *ranges; + u8 *debugfile; + u8 *abbrevdata; + u8 *debugdata; + u8 *infodata; + int numRanges; + ARanges *ranges; }; struct Symbol { - const char *name; - int type; - int binding; - u32 address; - u32 value; - u32 size; + const char *name; + int type; + int binding; + u32 address; + u32 value; + u32 size; }; extern u32 elfReadLEB128(u8 *, int *); extern s32 elfReadSignedLEB128(u8 *, int *); extern bool elfRead(const char *, int &, FILE *f); -extern bool elfGetSymbolAddress(const char *,u32 *, u32 *, int *); +extern bool elfGetSymbolAddress(const char *, u32 *, u32 *, int *); extern const char *elfGetAddressSymbol(u32); extern const char *elfGetSymbol(int, u32 *, u32 *, int *); extern void elfCleanUp(); diff --git a/src/gba/ereader.h b/src/gba/ereader.h index aff1c17e..b541e979 100644 --- a/src/gba/ereader.h +++ b/src/gba/ereader.h @@ -3,8 +3,7 @@ extern char filebuffer[]; int OpenDotCodeFile(void); int CheckEReaderRegion(void); -int LoadDotCodeData(int size, u32* DCdata, unsigned long MEM1, unsigned long MEM2); +int LoadDotCodeData(int size, u32 *DCdata, unsigned long MEM1, unsigned long MEM2); void EReaderWriteMemory(u32 address, u32 value); void BIOS_EReader_ScanCard(int swi_num); - diff --git a/src/gba/gbafilter.h b/src/gba/gbafilter.h index 18ff53d3..5927aca7 100644 --- a/src/gba/gbafilter.h +++ b/src/gba/gbafilter.h @@ -1,5 +1,5 @@ #include "../System.h" -void gbafilter_pal(u16 * buf, int count); -void gbafilter_pal32(u32 * buf, int count); -void gbafilter_pad(u8 * buf, int count); +void gbafilter_pal(u16 *buf, int count); +void gbafilter_pal32(u32 *buf, int count); +void gbafilter_pad(u8 *buf, int count); diff --git a/src/gba/remote.h b/src/gba/remote.h index 97e4ce02..38c7a2fb 100644 --- a/src/gba/remote.h +++ b/src/gba/remote.h @@ -4,40 +4,33 @@ #include "../common/Types.h" #include "GBA.h" -#define BitSet(array, bit) \ - ((u8 *)(array))[(bit) >> 3] |= (1 << ((bit) & 7)) +#define BitSet(array, bit) ((u8 *)(array))[(bit) >> 3] |= (1 << ((bit)&7)) -#define BitClear(array, bit) \ - ((u8 *)(array))[(bit) >> 3] &= ~(1 << ((bit) & 7)) +#define BitClear(array, bit) ((u8 *)(array))[(bit) >> 3] &= ~(1 << ((bit)&7)) -#define BitGet(array, bit) \ - ((u8)((array)[(bit) >> 3]) & (u8)(1 <<((bit) & 7))) +#define BitGet(array, bit) ((u8)((array)[(bit) >> 3]) & (u8)(1 << ((bit)&7))) -#define BreakSet(array, addr, flag) \ - ((u8 *)(array))[(addr)>>1] |= ((addr&1) ? (flag<<4) : (flag&0xf)) +#define BreakSet(array, addr, flag) \ + ((u8 *)(array))[(addr) >> 1] |= ((addr & 1) ? (flag << 4) : (flag & 0xf)) -#define BreakClear(array, addr, flag) \ - ((u8 *)(array))[(addr)>>1] &= ~((addr&1) ? (flag<<4) : (flag&0xf)) +#define BreakClear(array, addr, flag) \ + ((u8 *)(array))[(addr) >> 1] &= ~((addr & 1) ? (flag << 4) : (flag & 0xf)) -//check -#define BreakThumbCheck(array, addr) \ - ((u8 *)(array))[(addr)>>1] &((addr&1) ? 0x80 : 0x8 ) +// check +#define BreakThumbCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x80 : 0x8) -#define BreakARMCheck(array, addr) \ - ((u8 *)(array))[(addr)>>1] & ((addr&1) ? 0x40 : 0x4 ) +#define BreakARMCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x40 : 0x4) -#define BreakReadCheck(array, addr) \ - ((u8 *)(array))[(addr)>>1] & ((addr&1) ? 0x20 : 0x2 ) +#define BreakReadCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x20 : 0x2) -#define BreakWriteCheck(array, addr) \ - ((u8 *)(array))[(addr)>>1] & ((addr&1) ? 0x10 : 0x1 ) +#define BreakWriteCheck(array, addr) ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? 0x10 : 0x1) -#define BreakCheck(array, addr, flag) \ - ((u8 *)(array))[(addr)>>1] & ((addr&1) ? (flag<<4) : (flag&0xf)) +#define BreakCheck(array, addr, flag) \ + ((u8 *)(array))[(addr) >> 1] & ((addr & 1) ? (flag << 4) : (flag & 0xf)) extern bool debugger; -extern bool dexp_eval(char *, u32*); +extern bool dexp_eval(char *, u32 *); extern void dexp_setVar(char *, u32); extern void dexp_listVars(); extern void dexp_saveVars(char *); @@ -50,26 +43,26 @@ bool debuggerBreakOnWrite(u32 address, u32 value, int size); void debuggerBreakOnWrite(u32 address, u32 oldvalue, u32 value, int size, int t); bool debuggerBreakOnRead(u32 address, int size); -struct regBreak{ - //u8 regNum; /No longer needed - // bit 0 = equal - // bit 1 = greater - // bit 2 = smaller - // bit 3 = signed - u8 flags; - u32 intVal; - struct regBreak* next; +struct regBreak { + // u8 regNum; /No longer needed + // bit 0 = equal + // bit 1 = greater + // bit 2 = smaller + // bit 3 = signed + u8 flags; + u32 intVal; + struct regBreak *next; }; -extern u8 lowRegBreakCounter[4]; //(r0-r3) -extern u8 medRegBreakCounter[4]; //(r4-r7) -extern u8 highRegBreakCounter[4]; //(r8-r11) +extern u8 lowRegBreakCounter[4]; //(r0-r3) +extern u8 medRegBreakCounter[4]; //(r4-r7) +extern u8 highRegBreakCounter[4]; //(r8-r11) extern u8 statusRegBreakCounter[4]; //(r12-r15) extern bool enableRegBreak; -extern regBreak* breakRegList[16]; +extern regBreak *breakRegList[16]; extern void breakReg_check(int i); -struct regBreak* getFromBreakRegList(u8 regnum, int location); +struct regBreak *getFromBreakRegList(u8 regnum, int location); void clearBreakRegList(); void clearParticularRegListBreaks(int reg); diff --git a/src/gtk/cheatedit.h b/src/gtk/cheatedit.h index 5b677161..5b77006c 100644 --- a/src/gtk/cheatedit.h +++ b/src/gtk/cheatedit.h @@ -29,57 +29,50 @@ namespace VBA { - -enum ECheatType -{ - CheatGeneric, - CheatGSA, - CheatCBA, - CheatGS, - CheatGG -}; +enum ECheatType { CheatGeneric, CheatGSA, CheatCBA, CheatGS, CheatGG }; class EditCheatCodeColumns : public Gtk::TreeModel::ColumnRecord { - public: - EditCheatCodeColumns() - { - add(uText); - add(iType); - } + public: + EditCheatCodeColumns() + { + add(uText); + add(iType); + } - ~EditCheatCodeColumns() {} + ~EditCheatCodeColumns() + { + } - Gtk::TreeModelColumn uText; - Gtk::TreeModelColumn iType; + Gtk::TreeModelColumn uText; + Gtk::TreeModelColumn iType; }; class CheatEditDialog : public Gtk::Dialog { -public: - CheatEditDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); - Glib::RefPtr vGetCode(); - Glib::ustring vGetDesc(); - ECheatType vGetType(); - void vSetWindow(VBA::Window * _poWindow); + public: + CheatEditDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); + Glib::RefPtr vGetCode(); + Glib::ustring vGetDesc(); + ECheatType vGetType(); + void vSetWindow(VBA::Window *_poWindow); -private: - void vOnApply(); - void vOnCancel(); + private: + void vOnApply(); + void vOnCancel(); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Gtk::Entry * m_poCheatDescEntry; - Gtk::ComboBox * m_poCheatTypeComboBox; - Gtk::TextView * m_poCheatInputTextView; - Gtk::Button * m_poCheatApplyButton; - Gtk::Button * m_poCheatCancelButton; - Glib::RefPtr m_poCheatInputBuffer; - Glib::RefPtr m_poCheatTypeStore; - EditCheatCodeColumns m_oTypeModel; + Gtk::Entry *m_poCheatDescEntry; + Gtk::ComboBox *m_poCheatTypeComboBox; + Gtk::TextView *m_poCheatInputTextView; + Gtk::Button *m_poCheatApplyButton; + Gtk::Button *m_poCheatCancelButton; + Glib::RefPtr m_poCheatInputBuffer; + Glib::RefPtr m_poCheatTypeStore; + EditCheatCodeColumns m_oTypeModel; }; } // namespace VBA - #endif diff --git a/src/gtk/cheatlist.h b/src/gtk/cheatlist.h index b8f85da6..7f11104d 100644 --- a/src/gtk/cheatlist.h +++ b/src/gtk/cheatlist.h @@ -27,65 +27,66 @@ namespace VBA { - class ListCheatCodeColumns : public Gtk::TreeModel::ColumnRecord { - public: - ListCheatCodeColumns() - { - add(iIndex); - add(bEnabled); - add(uDesc); - } + public: + ListCheatCodeColumns() + { + add(iIndex); + add(bEnabled); + add(uDesc); + } - ~ListCheatCodeColumns() {} + ~ListCheatCodeColumns() + { + } - Gtk::TreeModelColumn iIndex; - Gtk::TreeModelColumn bEnabled; - Gtk::TreeModelColumn uDesc; + Gtk::TreeModelColumn iIndex; + Gtk::TreeModelColumn bEnabled; + Gtk::TreeModelColumn uDesc; }; class CheatListDialog : public Gtk::Dialog { -public: - CheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); - void vSetWindow(VBA::Window * _poWindow); + public: + CheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); + void vSetWindow(VBA::Window *_poWindow); -protected: - virtual void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr buffer) = 0; - virtual bool vCheatListOpen(const char *file) = 0; - virtual void vCheatListSave(const char *file) = 0; - virtual void vRemoveCheat(int index) = 0; - virtual void vRemoveAllCheats() = 0; - virtual void vToggleCheat(int index, bool enable) = 0; - virtual void vUpdateList(int previous = 0) = 0; + protected: + virtual void vAddCheat(Glib::ustring sDesc, ECheatType type, + Glib::RefPtr buffer) = 0; + virtual bool vCheatListOpen(const char *file) = 0; + virtual void vCheatListSave(const char *file) = 0; + virtual void vRemoveCheat(int index) = 0; + virtual void vRemoveAllCheats() = 0; + virtual void vToggleCheat(int index, bool enable) = 0; + virtual void vUpdateList(int previous = 0) = 0; - Glib::RefPtr m_poCheatListStore; - ListCheatCodeColumns m_oRecordModel; + Glib::RefPtr m_poCheatListStore; + ListCheatCodeColumns m_oRecordModel; -private: - void vOnCheatListOpen(); - void vOnCheatListSave(); - void vOnCheatAdd(); - void vOnCheatRemove(); - void vOnCheatRemoveAll(); - void vOnCheatMarkAll(); - void vOnCheatToggled(Glib::ustring const& string_path); + private: + void vOnCheatListOpen(); + void vOnCheatListSave(); + void vOnCheatAdd(); + void vOnCheatRemove(); + void vOnCheatRemoveAll(); + void vOnCheatMarkAll(); + void vOnCheatToggled(Glib::ustring const &string_path); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Gtk::ToolButton * m_poCheatOpenButton; - Gtk::ToolButton * m_poCheatSaveButton; - Gtk::ToolButton * m_poCheatAddButton; - Gtk::ToolButton * m_poCheatRemoveButton; - Gtk::ToolButton * m_poCheatRemoveAllButton; - Gtk::ToolButton * m_poCheatMarkAllButton; - Gtk::TreeView * m_poCheatTreeView; - - bool bMark; + Gtk::ToolButton *m_poCheatOpenButton; + Gtk::ToolButton *m_poCheatSaveButton; + Gtk::ToolButton *m_poCheatAddButton; + Gtk::ToolButton *m_poCheatRemoveButton; + Gtk::ToolButton *m_poCheatRemoveAllButton; + Gtk::ToolButton *m_poCheatMarkAllButton; + Gtk::TreeView *m_poCheatTreeView; + + bool bMark; }; } // namespace VBA - #endif diff --git a/src/gtk/configfile.h b/src/gtk/configfile.h index e14034be..b8f42e60 100644 --- a/src/gtk/configfile.h +++ b/src/gtk/configfile.h @@ -27,176 +27,182 @@ namespace VBA { namespace Config { - class NotFound { -public: - virtual ~NotFound() {} + public: + virtual ~NotFound() + { + } -protected: - NotFound() {} + protected: + NotFound() + { + } }; class SectionNotFound : public NotFound { -public: - SectionNotFound(const std::string & _rsName) : - m_sName(_rsName) - { - } - virtual ~SectionNotFound() {} + public: + SectionNotFound(const std::string &_rsName) : m_sName(_rsName) + { + } + virtual ~SectionNotFound() + { + } - inline std::string sGetName() const { return m_sName; } + inline std::string sGetName() const + { + return m_sName; + } -private: - std::string m_sName; + private: + std::string m_sName; }; class KeyNotFound : public NotFound { -public: - KeyNotFound(const std::string & _rsSection, const std::string & _rsKey) : - m_sSection(_rsSection), - m_sKey(_rsKey) - { - } - virtual ~KeyNotFound() {} + public: + KeyNotFound(const std::string &_rsSection, const std::string &_rsKey) + : m_sSection(_rsSection), m_sKey(_rsKey) + { + } + virtual ~KeyNotFound() + { + } - inline std::string sGetSection() const { return m_sSection; } - inline std::string sGetKey() const { return m_sKey; } + inline std::string sGetSection() const + { + return m_sSection; + } + inline std::string sGetKey() const + { + return m_sKey; + } -private: - std::string m_sSection; - std::string m_sKey; + private: + std::string m_sSection; + std::string m_sKey; }; class Line { -public: - Line(const std::string & _rsKey, const std::string & _rsValue); + public: + Line(const std::string &_rsKey, const std::string &_rsValue); - std::string m_sKey; - std::string m_sValue; + std::string m_sKey; + std::string m_sValue; }; class Section : private std::list { -public: - explicit Section(const std::string & _rsName); + public: + explicit Section(const std::string &_rsName); - inline std::string sGetName() const { return m_sName; } + inline std::string sGetName() const + { + return m_sName; + } - bool bKeyExists(const std::string & _rsKey); - void vSetKey(const std::string & _rsKey, const std::string & _rsValue); - std::string sGetKey(const std::string & _rsKey) const; - void vRemoveKey(const std::string & _rsKey); + bool bKeyExists(const std::string &_rsKey); + void vSetKey(const std::string &_rsKey, const std::string &_rsValue); + std::string sGetKey(const std::string &_rsKey) const; + void vRemoveKey(const std::string &_rsKey); - template - void vSetKey(const std::string & _rsKey, const T & _rValue); + template void vSetKey(const std::string &_rsKey, const T &_rValue); - template - T oGetKey(const std::string & _rsKey) const; + template T oGetKey(const std::string &_rsKey) const; - // read only - typedef std::list::const_iterator const_iterator; - inline const_iterator begin() const - { - return std::list::begin(); - } - inline const_iterator end() const - { - return std::list::end(); - } + // read only + typedef std::list::const_iterator const_iterator; + inline const_iterator begin() const + { + return std::list::begin(); + } + inline const_iterator end() const + { + return std::list::end(); + } -private: - inline iterator begin() - { - return std::list::begin(); - } - inline iterator end() - { - return std::list::end(); - } + private: + inline iterator begin() + { + return std::list::begin(); + } + inline iterator end() + { + return std::list::end(); + } - std::string m_sName; + std::string m_sName; }; class File : private std::list
{ -public: - File(); - File(const std::string & _rsFile); - virtual ~File(); + public: + File(); + File(const std::string &_rsFile); + virtual ~File(); - bool bSectionExists(const std::string & _rsName); - Section * poAddSection(const std::string & _rsName); - Section * poGetSection(const std::string & _rsName); - void vRemoveSection(const std::string & _rsName); - void vLoad(const std::string & _rsFile, - bool _bAddSection = true, - bool _bAddKey = true); - void vSave(const std::string & _rsFile); - void vClear(); + bool bSectionExists(const std::string &_rsName); + Section *poAddSection(const std::string &_rsName); + Section *poGetSection(const std::string &_rsName); + void vRemoveSection(const std::string &_rsName); + void vLoad(const std::string &_rsFile, bool _bAddSection = true, bool _bAddKey = true); + void vSave(const std::string &_rsFile); + void vClear(); - // read only - typedef std::list
::const_iterator const_iterator; - inline const_iterator begin() const - { - return std::list
::begin(); - } - inline const_iterator end() const - { - return std::list
::end(); - } + // read only + typedef std::list
::const_iterator const_iterator; + inline const_iterator begin() const + { + return std::list
::begin(); + } + inline const_iterator end() const + { + return std::list
::end(); + } -private: - inline iterator begin() - { - return std::list
::begin(); - } - inline iterator end() - { - return std::list
::end(); - } + private: + inline iterator begin() + { + return std::list
::begin(); + } + inline iterator end() + { + return std::list
::end(); + } }; // debug -std::ostream & operator<<(std::ostream & _roOut, const File & _roConfig); +std::ostream &operator<<(std::ostream &_roOut, const File &_roConfig); -template -void Section::vSetKey(const std::string & _rsKey, const T & _rValue) +template void Section::vSetKey(const std::string &_rsKey, const T &_rValue) { - std::ostringstream oOut; - oOut << _rValue; - for (iterator it = begin(); it != end(); it++) - { - if (it->m_sKey == _rsKey) - { - it->m_sValue = oOut.str(); - return; - } - } - push_back(Line(_rsKey, oOut.str())); + std::ostringstream oOut; + oOut << _rValue; + for (iterator it = begin(); it != end(); it++) { + if (it->m_sKey == _rsKey) { + it->m_sValue = oOut.str(); + return; + } + } + push_back(Line(_rsKey, oOut.str())); } -template -T Section::oGetKey(const std::string & _rsKey) const +template T Section::oGetKey(const std::string &_rsKey) const { - T oValue; - for (const_iterator it = begin(); it != end(); it++) - { - if (it->m_sKey == _rsKey) - { - std::istringstream oIn(it->m_sValue); - oIn >> oValue; - return oValue; - } - } - throw KeyNotFound(m_sName, _rsKey); + T oValue; + for (const_iterator it = begin(); it != end(); it++) { + if (it->m_sKey == _rsKey) { + std::istringstream oIn(it->m_sValue); + oIn >> oValue; + return oValue; + } + } + throw KeyNotFound(m_sName, _rsKey); } } // namespace Config } // namespace VBA - #endif // __VBA_CONFIGFILE_H__ diff --git a/src/gtk/directoriesconfig.h b/src/gtk/directoriesconfig.h index 74477842..119f9bdf 100644 --- a/src/gtk/directoriesconfig.h +++ b/src/gtk/directoriesconfig.h @@ -20,37 +20,34 @@ #define __VBA_DIRECTORIESCONFIG_H__ #include +#include #include #include -#include #include "configfile.h" namespace VBA { - class DirectoriesConfigDialog : public Gtk::Dialog { -public: - DirectoriesConfigDialog(Config::Section * _poConfig); + public: + DirectoriesConfigDialog(Config::Section *_poConfig); -protected: - void on_response(int response_id); + protected: + void on_response(int response_id); -private: - struct SDirEntry - { - const char * m_csKey; - const char * m_csLabel; - const char * m_csFileChooserButton; - }; + private: + struct SDirEntry { + const char *m_csKey; + const char *m_csLabel; + const char *m_csFileChooserButton; + }; - Config::Section * m_poConfig; - static const SDirEntry m_astDirs[]; - Gtk::FileChooserButton * m_poButtons[6]; + Config::Section *m_poConfig; + static const SDirEntry m_astDirs[]; + Gtk::FileChooserButton *m_poButtons[6]; }; } // namespace VBA - #endif // __VBA_DIRECTORIESCONFIG_H__ diff --git a/src/gtk/displayconfig.h b/src/gtk/displayconfig.h index 59a973da..12c0809e 100644 --- a/src/gtk/displayconfig.h +++ b/src/gtk/displayconfig.h @@ -19,9 +19,9 @@ #ifndef __VBA_DISPLAYCONFIG_H__ #define __VBA_DISPLAYCONFIG_H__ -#include #include #include +#include #include #include "configfile.h" @@ -29,31 +29,29 @@ namespace VBA { - class DisplayConfigDialog : public Gtk::Dialog { -public: - DisplayConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + DisplayConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); - void vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow); + void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow); -private: - void vOnFilterChanged(); - void vOnFilterIBChanged(); - void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput); - void vOnScaleChanged(); + private: + void vOnFilterChanged(); + void vOnFilterIBChanged(); + void vOnOutputChanged(VBA::Window::EVideoOutput _eOutput); + void vOnScaleChanged(); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Config::Section * m_poConfig; - Gtk::ComboBox * m_poFiltersComboBox; - Gtk::ComboBox * m_poIBFiltersComboBox; - Gtk::ComboBox * m_poDefaultScaleComboBox; - Gtk::RadioButton * m_poOutputOpenGLRadioButton; - Gtk::RadioButton * m_poOutputCairoRadioButton; + Config::Section *m_poConfig; + Gtk::ComboBox *m_poFiltersComboBox; + Gtk::ComboBox *m_poIBFiltersComboBox; + Gtk::ComboBox *m_poDefaultScaleComboBox; + Gtk::RadioButton *m_poOutputOpenGLRadioButton; + Gtk::RadioButton *m_poOutputCairoRadioButton; }; } // namespace VBA - #endif // __VBA_DISPLAYCONFIG_H__ diff --git a/src/gtk/filters.h b/src/gtk/filters.h index 0986a40f..664f65d5 100644 --- a/src/gtk/filters.h +++ b/src/gtk/filters.h @@ -26,51 +26,43 @@ int Init_2xSaI(u32); namespace VBA { - typedef void (*Filter)(u8 *, u32, u8 *, u8 *, u32, int, int); typedef void (*FilterIB)(u8 *, u32, int, int); -enum EFilter -{ - FirstFilter, - FilterNone = FirstFilter, - Filter2xSaI, - FilterSuper2xSaI, - FilterSuperEagle, - FilterPixelate, - FilterAdMame2x, - FilterBilinear, - FilterBilinearPlus, - FilterScanlines, - FilterScanlinesTV, - FilterHq2x, - FilterLq2x, - FilterxBRZ2x, - LastFilter = FilterxBRZ2x +enum EFilter { + FirstFilter, + FilterNone = FirstFilter, + Filter2xSaI, + FilterSuper2xSaI, + FilterSuperEagle, + FilterPixelate, + FilterAdMame2x, + FilterBilinear, + FilterBilinearPlus, + FilterScanlines, + FilterScanlinesTV, + FilterHq2x, + FilterLq2x, + FilterxBRZ2x, + LastFilter = FilterxBRZ2x }; -enum EFilterIB -{ - FirstFilterIB, - FilterIBNone = FirstFilterIB, - FilterIBSmart, - FilterIBMotionBlur, - LastFilterIB = FilterIBMotionBlur +enum EFilterIB { + FirstFilterIB, + FilterIBNone = FirstFilterIB, + FilterIBSmart, + FilterIBMotionBlur, + LastFilterIB = FilterIBMotionBlur }; -enum EFilterDepth -{ - FilterDepth16, - FilterDepth32 -}; +enum EFilterDepth { FilterDepth16, FilterDepth32 }; Filter pvGetFilter(EFilter _eFilter, EFilterDepth _eDepth); -const char* pcsGetFilterName(const EFilter _eFilter); +const char *pcsGetFilterName(const EFilter _eFilter); FilterIB pvGetFilterIB(EFilterIB _eFilterIB, EFilterDepth _eDepth); -const char* pcsGetFilterIBName(const EFilterIB _eFilterIB); +const char *pcsGetFilterIBName(const EFilterIB _eFilterIB); } // namespace VBA - #endif // __VBA_FILTERS_H__ diff --git a/src/gtk/gameboyadvancecheatlist.h b/src/gtk/gameboyadvancecheatlist.h index 26770241..2bef2e3d 100644 --- a/src/gtk/gameboyadvancecheatlist.h +++ b/src/gtk/gameboyadvancecheatlist.h @@ -27,23 +27,22 @@ namespace VBA { - class GameBoyAdvanceCheatListDialog : public CheatListDialog { -public: - GameBoyAdvanceCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + GameBoyAdvanceCheatListDialog(GtkDialog *_pstDialog, + const Glib::RefPtr &refBuilder); -protected: - void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr buffer); - bool vCheatListOpen(const char *file); - void vCheatListSave(const char *file); - void vRemoveCheat(int index); - void vRemoveAllCheats(); - void vToggleCheat(int index, bool enable); - void vUpdateList(int previous = 0); + protected: + void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr buffer); + bool vCheatListOpen(const char *file); + void vCheatListSave(const char *file); + void vRemoveCheat(int index); + void vRemoveAllCheats(); + void vToggleCheat(int index, bool enable); + void vUpdateList(int previous = 0); }; } // namespace VBA - #endif diff --git a/src/gtk/gameboyadvanceconfig.h b/src/gtk/gameboyadvanceconfig.h index 9b6b8dc2..88f70013 100644 --- a/src/gtk/gameboyadvanceconfig.h +++ b/src/gtk/gameboyadvanceconfig.h @@ -28,32 +28,31 @@ namespace VBA { - class GameBoyAdvanceConfigDialog : public Gtk::Dialog { -public: - GameBoyAdvanceConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + GameBoyAdvanceConfigDialog(GtkDialog *_pstDialog, + const Glib::RefPtr &refBuilder); - void vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow); + void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow); -private: - void vOnSaveTypeChanged(); - void vOnFlashSizeChanged(); - void vOnUseBiosChanged(); - void vOnBiosSelectionChanged(); - void vOnEnableRTCChanged(); + private: + void vOnSaveTypeChanged(); + void vOnFlashSizeChanged(); + void vOnUseBiosChanged(); + void vOnBiosSelectionChanged(); + void vOnEnableRTCChanged(); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Config::Section * m_poConfig; - Gtk::ComboBox * m_poSaveTypeComboBox; - Gtk::ComboBox * m_poFlashSizeComboBox; - Gtk::CheckButton * m_poBiosCheckButton; - Gtk::FileChooserButton * m_poBiosFileChooserButton; - Gtk::CheckButton * m_poRTCCheckButton; + Config::Section *m_poConfig; + Gtk::ComboBox *m_poSaveTypeComboBox; + Gtk::ComboBox *m_poFlashSizeComboBox; + Gtk::CheckButton *m_poBiosCheckButton; + Gtk::FileChooserButton *m_poBiosFileChooserButton; + Gtk::CheckButton *m_poRTCCheckButton; }; } // namespace VBA - #endif // __VBA_GAMEBOYADVANCECONFIG_H__ diff --git a/src/gtk/gameboycheatlist.h b/src/gtk/gameboycheatlist.h index 5f9a9a9c..7f9057b2 100644 --- a/src/gtk/gameboycheatlist.h +++ b/src/gtk/gameboycheatlist.h @@ -24,23 +24,21 @@ namespace VBA { - class GameBoyCheatListDialog : public CheatListDialog { -public: - GameBoyCheatListDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + GameBoyCheatListDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); -protected: - void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr buffer); - bool vCheatListOpen(const char *file); - void vCheatListSave(const char *file); - void vRemoveCheat(int index); - void vRemoveAllCheats(); - void vToggleCheat(int index, bool enable); - void vUpdateList(int previous = 0); + protected: + void vAddCheat(Glib::ustring sDesc, ECheatType type, Glib::RefPtr buffer); + bool vCheatListOpen(const char *file); + void vCheatListSave(const char *file); + void vRemoveCheat(int index); + void vRemoveAllCheats(); + void vToggleCheat(int index, bool enable); + void vUpdateList(int previous = 0); }; } // namespace VBA - #endif diff --git a/src/gtk/gameboyconfig.h b/src/gtk/gameboyconfig.h index ecdff901..4225e348 100644 --- a/src/gtk/gameboyconfig.h +++ b/src/gtk/gameboyconfig.h @@ -28,32 +28,30 @@ namespace VBA { - class GameBoyConfigDialog : public Gtk::Dialog { -public: - GameBoyConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + GameBoyConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); - void vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow); + void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow); -private: - void vOnSystemChanged(); - void vOnBorderChanged(); - void vOnPrinterChanged(); - void vOnUseBootRomChanged(); - void vOnBootRomSelectionChanged(); + private: + void vOnSystemChanged(); + void vOnBorderChanged(); + void vOnPrinterChanged(); + void vOnUseBootRomChanged(); + void vOnBootRomSelectionChanged(); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Config::Section * m_poConfig; - Gtk::ComboBox * m_poSystemComboBox; - Gtk::CheckButton * m_poBorderCheckButton; - Gtk::CheckButton * m_poPrinterCheckButton; - Gtk::CheckButton * m_poBootRomCheckButton; - Gtk::FileChooserButton * m_poBootRomFileChooserButton; + Config::Section *m_poConfig; + Gtk::ComboBox *m_poSystemComboBox; + Gtk::CheckButton *m_poBorderCheckButton; + Gtk::CheckButton *m_poPrinterCheckButton; + Gtk::CheckButton *m_poBootRomCheckButton; + Gtk::FileChooserButton *m_poBootRomFileChooserButton; }; } // namespace VBA - #endif // __VBA_GAMEBOYCONFIG_H__ diff --git a/src/gtk/generalconfig.h b/src/gtk/generalconfig.h index edad6079..4aecc2a8 100644 --- a/src/gtk/generalconfig.h +++ b/src/gtk/generalconfig.h @@ -20,39 +20,35 @@ #define __VBA_GENERALCONFIG_H__ #include -#include #include +#include #include "configfile.h" #include "window.h" namespace VBA { - class PreferencesDialog : public Gtk::Dialog { -public: - PreferencesDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + PreferencesDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); - void vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow); + void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow); -private: - void vOnPauseWhenInactiveChanged(); - void vOnFrameskipChanged(); - void vOnSpeedIndicatorChanged(); + private: + void vOnPauseWhenInactiveChanged(); + void vOnFrameskipChanged(); + void vOnSpeedIndicatorChanged(); + VBA::Window *m_poWindow; - VBA::Window * m_poWindow; - - Config::Section * m_poConfig; - Gtk::CheckButton * m_poPauseWhenInactiveCheckButton; - Gtk::CheckButton * m_poFrameSkipAutomaticCheckButton; - Gtk::SpinButton * m_poFrameSkipLevelSpinButton; - Gtk::ComboBox * m_poSpeedIndicatorComboBox; - + Config::Section *m_poConfig; + Gtk::CheckButton *m_poPauseWhenInactiveCheckButton; + Gtk::CheckButton *m_poFrameSkipAutomaticCheckButton; + Gtk::SpinButton *m_poFrameSkipLevelSpinButton; + Gtk::ComboBox *m_poSpeedIndicatorComboBox; }; } // namespace VBA - #endif // __VBA_GENERALCONFIG_H__ diff --git a/src/gtk/intl.h b/src/gtk/intl.h index 039261bf..c681b20b 100644 --- a/src/gtk/intl.h +++ b/src/gtk/intl.h @@ -21,16 +21,15 @@ #define __VBA_INTL_H__ #ifdef ENABLE_NLS -# include +#include #else -# define _(String) (String) -# define N_(String) (String) -# define textdomain(String) (String) -# define gettext(String) (String) -# define dgettext(Domain,String) (String) -# define dcgettext(Domain,String,Type) (String) -# define bindtextdomain(Domain,Directory) (Domain) +#define _(String) (String) +#define N_(String) (String) +#define textdomain(String) (String) +#define gettext(String) (String) +#define dgettext(Domain, String) (String) +#define dcgettext(Domain, String, Type) (String) +#define bindtextdomain(Domain, Directory) (Domain) #endif - #endif // __VBA_INTL_H__ diff --git a/src/gtk/joypadconfig.h b/src/gtk/joypadconfig.h index 7b621604..2535f326 100644 --- a/src/gtk/joypadconfig.h +++ b/src/gtk/joypadconfig.h @@ -22,65 +22,62 @@ #include -#include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include #include "../sdl/inputSDL.h" #include "configfile.h" namespace VBA { - class JoypadConfigDialog : public Gtk::Dialog { -public: - JoypadConfigDialog(Config::Section * _poConfig); - virtual ~JoypadConfigDialog(); + public: + JoypadConfigDialog(Config::Section *_poConfig); + virtual ~JoypadConfigDialog(); -protected: - bool bOnEntryFocusIn(GdkEventFocus * _pstEvent, guint _uiEntry); - bool bOnEntryFocusOut(GdkEventFocus * _pstEvent); + protected: + bool bOnEntryFocusIn(GdkEventFocus *_pstEvent, guint _uiEntry); + bool bOnEntryFocusOut(GdkEventFocus *_pstEvent); - void vOnInputEvent(const SDL_Event &event); - bool on_key_press_event(GdkEventKey * _pstEvent); - void on_response(int response_id); + void vOnInputEvent(const SDL_Event &event); + bool on_key_press_event(GdkEventKey *_pstEvent); + void on_response(int response_id); -private: - struct SJoypadKey - { - const EKey m_eKeyFlag; - const char * m_csKeyName; - }; + private: + struct SJoypadKey { + const EKey m_eKeyFlag; + const char *m_csKeyName; + }; - Gtk::HBox m_oTitleHBox; - Gtk::Label m_oTitleLabel; - Gtk::ComboBoxText m_oTitleCombo; - Gtk::HSeparator m_oSeparator; - Gtk::CheckButton m_oDefaultJoypad; - Gtk::Table m_oTable; - Gtk::Button * m_poOkButton; - std::vector m_oEntries; - gint m_iCurrentEntry; - bool m_bUpdating; - static const SJoypadKey m_astKeys[]; - sigc::connection m_oConfigSig; - SDL_Event m_oPreviousEvent; - EPad m_ePad; - Config::Section * m_poConfig; + Gtk::HBox m_oTitleHBox; + Gtk::Label m_oTitleLabel; + Gtk::ComboBoxText m_oTitleCombo; + Gtk::HSeparator m_oSeparator; + Gtk::CheckButton m_oDefaultJoypad; + Gtk::Table m_oTable; + Gtk::Button *m_poOkButton; + std::vector m_oEntries; + gint m_iCurrentEntry; + bool m_bUpdating; + static const SJoypadKey m_astKeys[]; + sigc::connection m_oConfigSig; + SDL_Event m_oPreviousEvent; + EPad m_ePad; + Config::Section *m_poConfig; - bool bOnConfigIdle(); - void vOnJoypadSelect(); - void vOnDefaultJoypadSelect(); - void vUpdateEntries(); - void vEmptyEventQueue(); + bool bOnConfigIdle(); + void vOnJoypadSelect(); + void vOnDefaultJoypadSelect(); + void vUpdateEntries(); + void vEmptyEventQueue(); }; } // namespace VBA - #endif // __VBA_JOYPADCONFIG_H__ diff --git a/src/gtk/screenarea-cairo.h b/src/gtk/screenarea-cairo.h index 60b3ed83..bb4ba81a 100644 --- a/src/gtk/screenarea-cairo.h +++ b/src/gtk/screenarea-cairo.h @@ -24,29 +24,27 @@ namespace VBA { - class ScreenAreaCairo : public ScreenArea { -public: - ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1); - void vDrawPixels(u8 * _puiData); - void vDrawBlackScreen(); + public: + ScreenAreaCairo(int _iWidth, int _iHeight, int _iScale = 1); + void vDrawPixels(u8 *_puiData); + void vDrawBlackScreen(); -protected: + protected: #if !GTK_CHECK_VERSION(3, 0, 0) - bool on_expose_event(GdkEventExpose * _pstEvent); + bool on_expose_event(GdkEventExpose *_pstEvent); #else - bool on_draw(const Cairo::RefPtr &poContext); + bool on_draw(const Cairo::RefPtr &poContext); #endif - void vOnWidgetResize(); + void vOnWidgetResize(); -private: - double m_dScaleFactor; - int m_iAreaTop; - int m_iAreaLeft; + private: + double m_dScaleFactor; + int m_iAreaTop; + int m_iAreaLeft; }; } // namespace VBA - #endif // __VBA_SCREENAREA_CAIRO_H__ diff --git a/src/gtk/screenarea-opengl.h b/src/gtk/screenarea-opengl.h index acb0b014..0d15cb6b 100644 --- a/src/gtk/screenarea-opengl.h +++ b/src/gtk/screenarea-opengl.h @@ -25,29 +25,26 @@ namespace VBA { - -class ScreenAreaGl : public ScreenArea, - public Gtk::GL::Widget +class ScreenAreaGl : public ScreenArea, public Gtk::GL::Widget { -public: - ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1); - void vDrawPixels(u8 * _puiData); - void vDrawBlackScreen(); + public: + ScreenAreaGl(int _iWidth, int _iHeight, int _iScale = 1); + void vDrawPixels(u8 *_puiData); + void vDrawBlackScreen(); -protected: - void on_realize(); - bool on_expose_event(GdkEventExpose * _pstEvent); - void vOnWidgetResize(); + protected: + void on_realize(); + bool on_expose_event(GdkEventExpose *_pstEvent); + void vOnWidgetResize(); -private: - GLuint m_uiScreenTexture; - int m_iTextureSize; + private: + GLuint m_uiScreenTexture; + int m_iTextureSize; - void vUpdateTexture(); - void vOnSizeUpdated(); + void vUpdateTexture(); + void vOnSizeUpdated(); }; } // namespace VBA - #endif // __VBA_SCREENAREA_OPENGL_H__ diff --git a/src/gtk/screenarea.h b/src/gtk/screenarea.h index 8c6224a4..0d96de9c 100644 --- a/src/gtk/screenarea.h +++ b/src/gtk/screenarea.h @@ -20,68 +20,68 @@ #ifndef __VBA_SCREENAREA_H__ #define __VBA_SCREENAREA_H__ -#include #include +#include #include "filters.h" namespace VBA { - class ScreenArea : public Gtk::DrawingArea { -public: - ScreenArea(int _iWidth, int _iHeight, int _iScale = 1); - virtual ~ScreenArea(); + public: + ScreenArea(int _iWidth, int _iHeight, int _iScale = 1); + virtual ~ScreenArea(); - void vSetSize(int _iWidth, int _iHeight); - void vSetScale(int _iScale); - void vSetFilter(EFilter _eFilter); - void vSetFilterIB(EFilterIB _eFilterIB); - void vSetEnableRender(bool _bEnable); - virtual void vDrawPixels(u8 * _puiData); - virtual void vDrawBlackScreen() = 0; + void vSetSize(int _iWidth, int _iHeight); + void vSetScale(int _iScale); + void vSetFilter(EFilter _eFilter); + void vSetFilterIB(EFilterIB _eFilterIB); + void vSetEnableRender(bool _bEnable); + virtual void vDrawPixels(u8 *_puiData); + virtual void vDrawBlackScreen() = 0; -protected: - virtual bool on_motion_notify_event(GdkEventMotion * _pstEvent); - virtual bool on_enter_notify_event(GdkEventCrossing * _pstEvent); - virtual bool on_leave_notify_event(GdkEventCrossing * _pstEvent); - virtual bool on_configure_event(GdkEventConfigure * event); - virtual bool bOnCursorTimeout(); - virtual void vOnSizeUpdated() {} + protected: + virtual bool on_motion_notify_event(GdkEventMotion *_pstEvent); + virtual bool on_enter_notify_event(GdkEventCrossing *_pstEvent); + virtual bool on_leave_notify_event(GdkEventCrossing *_pstEvent); + virtual bool on_configure_event(GdkEventConfigure *event); + virtual bool bOnCursorTimeout(); + virtual void vOnSizeUpdated() + { + } - int m_iWidth; - int m_iHeight; - int m_iScale; - int m_iFilterScale; - int m_iAreaWidth; - int m_iAreaHeight; - Filter m_vFilter2x; - FilterIB m_vFilterIB; - u32 * m_puiPixels; - u8 * m_puiDelta; - int m_iScaledWidth; - int m_iScaledHeight; - bool m_bEnableRender; + int m_iWidth; + int m_iHeight; + int m_iScale; + int m_iFilterScale; + int m_iAreaWidth; + int m_iAreaHeight; + Filter m_vFilter2x; + FilterIB m_vFilterIB; + u32 *m_puiPixels; + u8 *m_puiDelta; + int m_iScaledWidth; + int m_iScaledHeight; + bool m_bEnableRender; - bool m_bShowCursor; + bool m_bShowCursor; #if !GTK_CHECK_VERSION(3, 0, 0) - Gdk::Cursor * m_poEmptyCursor; + Gdk::Cursor *m_poEmptyCursor; #else - Glib::RefPtr m_poEmptyCursor; + Glib::RefPtr m_poEmptyCursor; #endif - sigc::connection m_oCursorSig; + sigc::connection m_oCursorSig; - void vUpdateSize(); - virtual void vOnWidgetResize() = 0; - void vStartCursorTimeout(); - void vStopCursorTimeout(); - void vHideCursor(); - void vShowCursor(); + void vUpdateSize(); + virtual void vOnWidgetResize() = 0; + void vStartCursorTimeout(); + void vStopCursorTimeout(); + void vHideCursor(); + void vShowCursor(); }; } // namespace VBA - #endif // __VBA_SCREENAREA_H__ diff --git a/src/gtk/soundconfig.h b/src/gtk/soundconfig.h index e4445a90..bc480cee 100644 --- a/src/gtk/soundconfig.h +++ b/src/gtk/soundconfig.h @@ -19,35 +19,33 @@ #ifndef __VBA_SOUNDCONFIG_H__ #define __VBA_SOUNDCONFIG_H__ -#include #include #include +#include #include "configfile.h" #include "window.h" namespace VBA { - class SoundConfigDialog : public Gtk::Dialog { -public: - SoundConfigDialog(GtkDialog* _pstDialog, const Glib::RefPtr& refBuilder); + public: + SoundConfigDialog(GtkDialog *_pstDialog, const Glib::RefPtr &refBuilder); - void vSetConfig(Config::Section * _poConfig, VBA::Window * _poWindow); + void vSetConfig(Config::Section *_poConfig, VBA::Window *_poWindow); -private: - void vOnVolumeChanged(); - void vOnRateChanged(); + private: + void vOnVolumeChanged(); + void vOnRateChanged(); - VBA::Window * m_poWindow; + VBA::Window *m_poWindow; - Config::Section * m_poConfig; - Gtk::ComboBox * m_poVolumeComboBox; - Gtk::ComboBox * m_poRateComboBox; + Config::Section *m_poConfig; + Gtk::ComboBox *m_poVolumeComboBox; + Gtk::ComboBox *m_poRateComboBox; }; } // namespace VBA - #endif // __VBA_SOUNDCONFIG_H__ diff --git a/src/gtk/tools.h b/src/gtk/tools.h index ab292691..e8b7ab14 100644 --- a/src/gtk/tools.h +++ b/src/gtk/tools.h @@ -20,26 +20,20 @@ #ifndef __VBA_TOOLS_H__ #define __VBA_TOOLS_H__ +#include #include #include -#include namespace VBA { +std::string sCutSuffix(const std::string &_rsString, const std::string &_rsSep = "."); -std::string sCutSuffix(const std::string & _rsString, - const std::string & _rsSep = "."); +Glib::ustring sCutSuffix(const Glib::ustring &_rsString, const Glib::ustring &_rsSep = "."); -Glib::ustring sCutSuffix(const Glib::ustring & _rsString, - const Glib::ustring & _rsSep = "."); - -bool bHasSuffix(const Glib::ustring & _rsString, - const Glib::ustring & _rsSuffix, +bool bHasSuffix(const Glib::ustring &_rsString, const Glib::ustring &_rsSuffix, bool _bCaseSensitive = true); - -void vTokenize(Glib::ustring source, std::vector& tokens); +void vTokenize(Glib::ustring source, std::vector &tokens); } - #endif // __VBA_TOOLS_H__ diff --git a/src/gtk/window.h b/src/gtk/window.h index be69f4a2..b161da83 100644 --- a/src/gtk/window.h +++ b/src/gtk/window.h @@ -20,279 +20,247 @@ #ifndef __VBA_WINDOW_H__ #define __VBA_WINDOW_H__ -#include +#include #include #include #include #include -#include +#include #include "../System.h" #include "../sdl/inputSDL.h" #include "configfile.h" -#include "screenarea.h" #include "filters.h" +#include "screenarea.h" namespace VBA { - class Window : public Gtk::Window { - friend class Gtk::Builder; + friend class Gtk::Builder; -public: - virtual ~Window(); + public: + virtual ~Window(); - inline static Window * poGetInstance() { return m_poInstance; } - static std::string sGetUiFilePath(const std::string &_sFileName); + inline static Window *poGetInstance() + { + return m_poInstance; + } + static std::string sGetUiFilePath(const std::string &_sFileName); - enum ECartridge - { - CartridgeNone, - CartridgeGB, - CartridgeGBA - }; + enum ECartridge { CartridgeNone, CartridgeGB, CartridgeGBA }; - enum EVideoOutput - { - OutputCairo, - OutputOpenGL - }; - - enum EEmulatorType - { - EmulatorAuto, - EmulatorCGB, - EmulatorSGB, - EmulatorGB, - EmulatorGBA, - EmulatorSGB2 - }; + enum EVideoOutput { OutputCairo, OutputOpenGL }; - enum ESaveType - { - SaveAuto, - SaveEEPROM, - SaveSRAM, - SaveFlash, - SaveEEPROMSensor, - SaveNone - }; + enum EEmulatorType { + EmulatorAuto, + EmulatorCGB, + EmulatorSGB, + EmulatorGB, + EmulatorGBA, + EmulatorSGB2 + }; - // GB/GBA screen sizes - const int m_iGBScreenWidth; - const int m_iGBScreenHeight; - const int m_iSGBScreenWidth; - const int m_iSGBScreenHeight; - const int m_iGBAScreenWidth; - const int m_iGBAScreenHeight; + enum ESaveType { SaveAuto, SaveEEPROM, SaveSRAM, SaveFlash, SaveEEPROMSensor, SaveNone }; - bool bLoadROM(const std::string & _rsFile); - void vPopupError(const char * _csFormat, ...); - void vPopupErrorV(const char * _csFormat, va_list _args); - void vDrawScreen(); - void vComputeFrameskip(int _iRate); - void vShowSpeed(int _iSpeed); - void vCaptureScreen(int _iNum); - void vApplyConfigFilter(); - void vApplyConfigFilterIB(); - void vApplyConfigScreenArea(); - void vApplyConfigMute(); - void vApplyConfigVolume(); - void vApplyConfigSoundSampleRate(); - void vApplyConfigGBSystem(); - void vApplyConfigGBBorder(); - void vApplyConfigGBPrinter(); - void vApplyConfigGBASaveType(); - void vApplyConfigGBAFlashSize(); - void vApplyConfigGBARTC(); - void vApplyConfigFrameskip(); - void vApplyConfigShowSpeed(); - void vApplyPerGameConfig(); - void vUpdateScreen(); + // GB/GBA screen sizes + const int m_iGBScreenWidth; + const int m_iGBScreenHeight; + const int m_iSGBScreenWidth; + const int m_iSGBScreenHeight; + const int m_iGBAScreenWidth; + const int m_iGBAScreenHeight; - inline ECartridge eGetCartridge() const { return m_eCartridge; } + bool bLoadROM(const std::string &_rsFile); + void vPopupError(const char *_csFormat, ...); + void vPopupErrorV(const char *_csFormat, va_list _args); + void vDrawScreen(); + void vComputeFrameskip(int _iRate); + void vShowSpeed(int _iSpeed); + void vCaptureScreen(int _iNum); + void vApplyConfigFilter(); + void vApplyConfigFilterIB(); + void vApplyConfigScreenArea(); + void vApplyConfigMute(); + void vApplyConfigVolume(); + void vApplyConfigSoundSampleRate(); + void vApplyConfigGBSystem(); + void vApplyConfigGBBorder(); + void vApplyConfigGBPrinter(); + void vApplyConfigGBASaveType(); + void vApplyConfigGBAFlashSize(); + void vApplyConfigGBARTC(); + void vApplyConfigFrameskip(); + void vApplyConfigShowSpeed(); + void vApplyPerGameConfig(); + void vUpdateScreen(); -protected: - Window(GtkWindow * _pstWindow, - const Glib::RefPtr & _poXml); + inline ECartridge eGetCartridge() const + { + return m_eCartridge; + } - enum EShowSpeed - { - ShowNone, - ShowPercentage, - ShowDetailed - }; + protected: + Window(GtkWindow *_pstWindow, const Glib::RefPtr &_poXml); - enum ESoundStatus - { - SoundOff, - SoundMute, - SoundOn - }; + enum EShowSpeed { ShowNone, ShowPercentage, ShowDetailed }; - enum EColorFormat - { - ColorFormatRGB, - ColorFormatBGR - }; + enum ESoundStatus { SoundOff, SoundMute, SoundOn }; - virtual void vOnMenuEnter(); - virtual void vOnMenuExit(); - virtual void vOnFileOpen(); - virtual void vOnFileLoad(); - virtual void vOnFileSave(); - virtual void vOnLoadGameMostRecent(); - virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem * _poCMI); - void vOnLoadGame(int _iSlot); - virtual void vOnSaveGameOldest(); - void vOnSaveGame(int _iSlot); - virtual void vOnFilePauseToggled(Gtk::CheckMenuItem * _poCMI); - virtual void vOnFileReset(); - virtual void vOnRecentFile(); - virtual void vOnFileScreenCapture(); - virtual void vOnFileClose(); - virtual void vOnFileExit(); - virtual void vOnVideoFullscreen(); - virtual void vOnDirectories(); - virtual void vOnGeneralConfigure(); - virtual void vOnJoypadConfigure(); - virtual void vOnDisplayConfigure(); - virtual void vOnSoundConfigure(); - virtual void vOnGameBoyConfigure(); - virtual void vOnGameBoyAdvanceConfigure(); - virtual void vOnCheatList(); - virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem * _poCMI); - virtual void vOnHelpAbout(); - virtual bool bOnEmuIdle(); - virtual bool bOnEmuSaveStateRewind(); - virtual bool bOnEmuRewind(); + enum EColorFormat { ColorFormatRGB, ColorFormatBGR }; - virtual bool on_focus_in_event(GdkEventFocus * _pstEvent); - virtual bool on_focus_out_event(GdkEventFocus * _pstEvent); - virtual bool on_key_press_event(GdkEventKey * _pstEvent); - virtual bool on_key_release_event(GdkEventKey * _pstEvent); - virtual bool on_window_state_event(GdkEventWindowState* _pstEvent); + virtual void vOnMenuEnter(); + virtual void vOnMenuExit(); + virtual void vOnFileOpen(); + virtual void vOnFileLoad(); + virtual void vOnFileSave(); + virtual void vOnLoadGameMostRecent(); + virtual void vOnLoadGameAutoToggled(Gtk::CheckMenuItem *_poCMI); + void vOnLoadGame(int _iSlot); + virtual void vOnSaveGameOldest(); + void vOnSaveGame(int _iSlot); + virtual void vOnFilePauseToggled(Gtk::CheckMenuItem *_poCMI); + virtual void vOnFileReset(); + virtual void vOnRecentFile(); + virtual void vOnFileScreenCapture(); + virtual void vOnFileClose(); + virtual void vOnFileExit(); + virtual void vOnVideoFullscreen(); + virtual void vOnDirectories(); + virtual void vOnGeneralConfigure(); + virtual void vOnJoypadConfigure(); + virtual void vOnDisplayConfigure(); + virtual void vOnSoundConfigure(); + virtual void vOnGameBoyConfigure(); + virtual void vOnGameBoyAdvanceConfigure(); + virtual void vOnCheatList(); + virtual void vOnCheatDisableToggled(Gtk::CheckMenuItem *_poCMI); + virtual void vOnHelpAbout(); + virtual bool bOnEmuIdle(); + virtual bool bOnEmuSaveStateRewind(); + virtual bool bOnEmuRewind(); -private: - // Config limits - const int m_iFrameskipMin; - const int m_iFrameskipMax; - const int m_iScaleMin; - const int m_iScaleMax; - const int m_iShowSpeedMin; - const int m_iShowSpeedMax; - const int m_iSaveTypeMin; - const int m_iSaveTypeMax; - const int m_iSoundSampleRateMin; - const int m_iSoundSampleRateMax; - const float m_fSoundVolumeMin; - const float m_fSoundVolumeMax; - const int m_iEmulatorTypeMin; - const int m_iEmulatorTypeMax; - const int m_iFilter2xMin; - const int m_iFilter2xMax; - const int m_iFilterIBMin; - const int m_iFilterIBMax; - const EPad m_iJoypadMin; - const EPad m_iJoypadMax; - const int m_iVideoOutputMin; - const int m_iVideoOutputMax; + virtual bool on_focus_in_event(GdkEventFocus *_pstEvent); + virtual bool on_focus_out_event(GdkEventFocus *_pstEvent); + virtual bool on_key_press_event(GdkEventKey *_pstEvent); + virtual bool on_key_release_event(GdkEventKey *_pstEvent); + virtual bool on_window_state_event(GdkEventWindowState *_pstEvent); - static Window * m_poInstance; + private: + // Config limits + const int m_iFrameskipMin; + const int m_iFrameskipMax; + const int m_iScaleMin; + const int m_iScaleMax; + const int m_iShowSpeedMin; + const int m_iShowSpeedMax; + const int m_iSaveTypeMin; + const int m_iSaveTypeMax; + const int m_iSoundSampleRateMin; + const int m_iSoundSampleRateMax; + const float m_fSoundVolumeMin; + const float m_fSoundVolumeMax; + const int m_iEmulatorTypeMin; + const int m_iEmulatorTypeMax; + const int m_iFilter2xMin; + const int m_iFilter2xMax; + const int m_iFilterIBMin; + const int m_iFilterIBMax; + const EPad m_iJoypadMin; + const EPad m_iJoypadMax; + const int m_iVideoOutputMin; + const int m_iVideoOutputMax; - Glib::RefPtr m_poXml; + static Window *m_poInstance; - std::string m_sUserDataDir; - std::string m_sConfigFile; - Config::File m_oConfig; - Config::Section * m_poDirConfig; - Config::Section * m_poCoreConfig; - Config::Section * m_poDisplayConfig; - Config::Section * m_poSoundConfig; - Config::Section * m_poInputConfig; + Glib::RefPtr m_poXml; - Gtk::FileChooserDialog * m_poFileOpenDialog; + std::string m_sUserDataDir; + std::string m_sConfigFile; + Config::File m_oConfig; + Config::Section *m_poDirConfig; + Config::Section *m_poCoreConfig; + Config::Section *m_poDisplayConfig; + Config::Section *m_poSoundConfig; + Config::Section *m_poInputConfig; - ScreenArea * m_poScreenArea; - Gtk::CheckMenuItem * m_poFilePauseItem; - Gtk::MenuBar * m_poMenuBar; + Gtk::FileChooserDialog *m_poFileOpenDialog; - struct SGameSlot - { - bool m_bEmpty; - std::string m_sFile; - time_t m_uiTime; - }; + ScreenArea *m_poScreenArea; + Gtk::CheckMenuItem *m_poFilePauseItem; + Gtk::MenuBar *m_poMenuBar; - struct SJoypadKey - { - const char * m_csKey; - const EKey m_eKeyFlag; - }; + struct SGameSlot { + bool m_bEmpty; + std::string m_sFile; + time_t m_uiTime; + }; - static const SJoypadKey m_astJoypad[]; + struct SJoypadKey { + const char *m_csKey; + const EKey m_eKeyFlag; + }; - Gtk::MenuItem * m_apoLoadGameItem[10]; - Gtk::MenuItem * m_apoSaveGameItem[10]; - SGameSlot m_astGameSlot[10]; + static const SJoypadKey m_astJoypad[]; - Glib::RefPtr m_poRecentManager; - Gtk::MenuItem * m_poRecentMenu; - Gtk::RecentChooserMenu * m_poRecentChooserMenu; + Gtk::MenuItem *m_apoLoadGameItem[10]; + Gtk::MenuItem *m_apoSaveGameItem[10]; + SGameSlot m_astGameSlot[10]; - std::list m_listSensitiveWhenPlaying; + Glib::RefPtr m_poRecentManager; + Gtk::MenuItem *m_poRecentMenu; + Gtk::RecentChooserMenu *m_poRecentChooserMenu; - sigc::connection m_oEmuSig, m_oEmuRewindSig; + std::list m_listSensitiveWhenPlaying; - int m_bFullscreen; - int m_iScreenWidth; - int m_iScreenHeight; - int m_iFrameCount; + sigc::connection m_oEmuSig, m_oEmuRewindSig; - std::string m_sRomFile; - ECartridge m_eCartridge; - EmulatedSystem m_stEmulator; - bool m_bPaused; - bool m_bWasEmulating; - bool m_bAutoFrameskip; - EShowSpeed m_eShowSpeed; + int m_bFullscreen; + int m_iScreenWidth; + int m_iScreenHeight; + int m_iFrameCount; + std::string m_sRomFile; + ECartridge m_eCartridge; + EmulatedSystem m_stEmulator; + bool m_bPaused; + bool m_bWasEmulating; + bool m_bAutoFrameskip; + EShowSpeed m_eShowSpeed; - /* State saving into memory & rewind to saved state */ - u16 m_state_count_max; - u16 m_rewind_interval; - static const u32 SZSTATE = 1024*512; - std::deque m_rewind_load_q; - char *m_psavestate; + /* State saving into memory & rewind to saved state */ + u16 m_state_count_max; + u16 m_rewind_interval; + static const u32 SZSTATE = 1024 * 512; + std::deque m_rewind_load_q; + char *m_psavestate; - void vInitSystem(); - void vUnInitSystem(); - void vInitSDL(); - void vInitConfig(); - void vCheckConfig(); - void vInitColors(EColorFormat _eColorFormat); - void vLoadConfig(const std::string & _rsFile); - void vSaveConfig(const std::string & _rsFile); - void vHistoryAdd(const std::string & _rsFile); - void vApplyConfigJoypads(); - void vSaveJoypadsToConfig(); - void vDrawDefaultScreen(); - void vSetDefaultTitle(); - void vCreateFileOpenDialog(); - void vLoadBattery(); - void vLoadCheats(); - void vSaveBattery(); - void vSaveCheats(); - void vStartEmu(); - void vStopEmu(); - void vUpdateGameSlots(); - void vToggleFullscreen(); - void vSDLPollEvents(); + void vInitSystem(); + void vUnInitSystem(); + void vInitSDL(); + void vInitConfig(); + void vCheckConfig(); + void vInitColors(EColorFormat _eColorFormat); + void vLoadConfig(const std::string &_rsFile); + void vSaveConfig(const std::string &_rsFile); + void vHistoryAdd(const std::string &_rsFile); + void vApplyConfigJoypads(); + void vSaveJoypadsToConfig(); + void vDrawDefaultScreen(); + void vSetDefaultTitle(); + void vCreateFileOpenDialog(); + void vLoadBattery(); + void vLoadCheats(); + void vSaveBattery(); + void vSaveCheats(); + void vStartEmu(); + void vStopEmu(); + void vUpdateGameSlots(); + void vToggleFullscreen(); + void vSDLPollEvents(); }; } // namespace VBA - #endif // __VBA_WINDOW_H__ diff --git a/src/libretro/SoundRetro.h b/src/libretro/SoundRetro.h index 3aa3774e..1cc404a4 100644 --- a/src/libretro/SoundRetro.h +++ b/src/libretro/SoundRetro.h @@ -20,17 +20,17 @@ #include "../common/SoundDriver.h" -class SoundRetro: public SoundDriver +class SoundRetro : public SoundDriver { -public: - SoundRetro(); - virtual ~SoundRetro(); + public: + SoundRetro(); + virtual ~SoundRetro(); - virtual bool init(long sampleRate); - virtual void pause(); - virtual void reset(); - virtual void resume(); - virtual void write(u16 * finalWave, int length); + virtual bool init(long sampleRate); + virtual void pause(); + virtual void reset(); + virtual void resume(); + virtual void write(u16 *finalWave, int length); }; #endif // __VBA_SOUND_RETRO_H__ diff --git a/src/libretro/gbaconv/gbaconv.c b/src/libretro/gbaconv/gbaconv.c index ae73a6cc..f8ccb61e 100644 --- a/src/libretro/gbaconv/gbaconv.c +++ b/src/libretro/gbaconv/gbaconv.c @@ -1,216 +1,198 @@ -#include #include +#include #ifndef __CELLOS_LV2__ #include #endif -#include #include -#include #include +#include +#include -enum save_type -{ - EEPROM_512B, - EEPROM_8K, - FLASH_64K, - FLASH_128K, - SAVE_UNKNOWN -}; +enum save_type { EEPROM_512B, EEPROM_8K, FLASH_64K, FLASH_128K, SAVE_UNKNOWN }; static const char *save_type_to_string(enum save_type type) { - switch (type) - { - case EEPROM_512B: - return "EEPROM 4kbit"; - case EEPROM_8K: - return "EEPROM 64kbit"; - case FLASH_64K: - return "FLASH 512kbit"; - case FLASH_128K: - return "FLASH 1MBit"; + switch (type) { + case EEPROM_512B: + return "EEPROM 4kbit"; + case EEPROM_8K: + return "EEPROM 64kbit"; + case FLASH_64K: + return "FLASH 512kbit"; + case FLASH_128K: + return "FLASH 1MBit"; - default: - return "Unknown type"; - } + default: + return "Unknown type"; + } } static bool scan_section(const uint8_t *data, unsigned size) { - for (unsigned i = 0; i < size; i++) - { - if (data[i] != 0xff) - return true; - } + for (unsigned i = 0; i < size; i++) { + if (data[i] != 0xff) + return true; + } - return false; + return false; } static enum save_type detect_save_type(const uint8_t *data, unsigned size) { - if (size == 512) - return EEPROM_512B; - if (size == 0x2000) - return EEPROM_8K; - if (size == 0x10000) - return FLASH_64K; - if (size == 0x20000) - return FLASH_128K; + if (size == 512) + return EEPROM_512B; + if (size == 0x2000) + return EEPROM_8K; + if (size == 0x10000) + return FLASH_64K; + if (size == 0x20000) + return FLASH_128K; - if (size == (0x20000 + 0x2000)) - { - if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000)) - return FLASH_64K; - if (scan_section(data, 0x20000)) - return FLASH_128K; + if (size == (0x20000 + 0x2000)) { + if (scan_section(data, 0x10000) && !scan_section(data + 0x10000, 0x10000)) + return FLASH_64K; + if (scan_section(data, 0x20000)) + return FLASH_128K; - if (scan_section(data + 0x20000, 512) && !scan_section(data + 0x20000 + 512, 0x20000 - 512)) - return EEPROM_512B; - if (scan_section(data + 0x20000, 0x2000)) - return EEPROM_8K; - } + if (scan_section(data + 0x20000, 512) && + !scan_section(data + 0x20000 + 512, 0x20000 - 512)) + return EEPROM_512B; + if (scan_section(data + 0x20000, 0x2000)) + return EEPROM_8K; + } - return SAVE_UNKNOWN; + return SAVE_UNKNOWN; } static void dump_srm(FILE *file, const uint8_t *data, enum save_type type) { - void *buf = malloc(0x20000 + 0x2000); - memset(buf, 0xff, 0x20000 + 0x2000); + void *buf = malloc(0x20000 + 0x2000); + memset(buf, 0xff, 0x20000 + 0x2000); - switch (type) - { - case EEPROM_512B: - fwrite(buf, 1, 0x20000, file); - fwrite(data, 1, 512, file); - fwrite(buf, 1, 0x2000 - 512, file); - break; + switch (type) { + case EEPROM_512B: + fwrite(buf, 1, 0x20000, file); + fwrite(data, 1, 512, file); + fwrite(buf, 1, 0x2000 - 512, file); + break; - case EEPROM_8K: - fwrite(buf, 1, 0x20000, file); - fwrite(data, 1, 0x2000, file); - break; + case EEPROM_8K: + fwrite(buf, 1, 0x20000, file); + fwrite(data, 1, 0x2000, file); + break; - case FLASH_64K: - fwrite(data, 1, 0x10000, file); - fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file); - break; + case FLASH_64K: + fwrite(data, 1, 0x10000, file); + fwrite(buf, 1, 0x20000 + 0x2000 - 0x10000, file); + break; - case FLASH_128K: - fwrite(data, 1, 0x20000, file); - fwrite(buf, 1, 0x2000, file); - break; + case FLASH_128K: + fwrite(data, 1, 0x20000, file); + fwrite(buf, 1, 0x2000, file); + break; - default: - break; - } + default: + break; + } - free(buf); + free(buf); } static void dump_sav(FILE *file, const uint8_t *data, enum save_type type) { - switch (type) - { - case EEPROM_512B: - fwrite(data + 0x20000, 1, 512, file); - break; + switch (type) { + case EEPROM_512B: + fwrite(data + 0x20000, 1, 512, file); + break; - case EEPROM_8K: - fwrite(data + 0x20000, 1, 0x2000, file); - break; + case EEPROM_8K: + fwrite(data + 0x20000, 1, 0x2000, file); + break; - case FLASH_64K: - fwrite(data, 1, 0x10000, file); - break; + case FLASH_64K: + fwrite(data, 1, 0x10000, file); + break; - case FLASH_128K: - fwrite(data, 1, 0x20000, file); - break; + case FLASH_128K: + fwrite(data, 1, 0x20000, file); + break; - default: - break; - } + default: + break; + } } // One shot cowboy code :) int main(int argc, char *argv[]) { - if (argc != 2) - { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; - } + if (argc != 2) { + fprintf(stderr, "Usage: %s \n", argv[0]); + return 1; + } - FILE *file = fopen(argv[1], "rb"); - if (!file) - { - fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]); - goto error; - } + FILE *file = fopen(argv[1], "rb"); + if (!file) { + fprintf(stderr, "Failed to open file \"%s\"\n", argv[1]); + goto error; + } - fseek(file, 0, SEEK_END); - long len = ftell(file); - rewind(file); + fseek(file, 0, SEEK_END); + long len = ftell(file); + rewind(file); - uint8_t *buffer = malloc(len); - if (!buffer) - { - fprintf(stderr, "Failed to allocate memory!\n"); - goto error; - } - fread(buffer, 1, len, file); - fclose(file); - file = NULL; + uint8_t *buffer = malloc(len); + if (!buffer) { + fprintf(stderr, "Failed to allocate memory!\n"); + goto error; + } + fread(buffer, 1, len, file); + fclose(file); + file = NULL; - char *out_path = strdup(argv[1]); - char *split = strrchr(out_path, '.'); - const char *ext = NULL; + char *out_path = strdup(argv[1]); + char *split = strrchr(out_path, '.'); + const char *ext = NULL; - if (split) - { - *split = '\0'; - ext = split + 1; + if (split) { + *split = '\0'; + ext = split + 1; - if (strcasecmp(ext, "srm") == 0) - strcat(out_path, ".sav"); - else if (strlen(ext) >= 3) - strcat(out_path, ".srm"); - else - ext = NULL; - } + if (strcasecmp(ext, "srm") == 0) + strcat(out_path, ".sav"); + else if (strlen(ext) >= 3) + strcat(out_path, ".srm"); + else + ext = NULL; + } - if (!ext) - { - fprintf(stderr, "Cannot detect extension!\n"); - goto error; - } + if (!ext) { + fprintf(stderr, "Cannot detect extension!\n"); + goto error; + } - enum save_type type = detect_save_type(buffer, len); - printf("Detected save type: %s\n", save_type_to_string(type)); + enum save_type type = detect_save_type(buffer, len); + printf("Detected save type: %s\n", save_type_to_string(type)); - if (type == SAVE_UNKNOWN) - { - fprintf(stderr, "Cannot infer save type ...\n"); - goto error; - } + if (type == SAVE_UNKNOWN) { + fprintf(stderr, "Cannot infer save type ...\n"); + goto error; + } - file = fopen(out_path, "wb"); - if (!file) - goto error; + file = fopen(out_path, "wb"); + if (!file) + goto error; - if (len == (0x20000 + 0x2000)) - dump_sav(file, buffer, type); - else - dump_srm(file, buffer, type); - fclose(file); + if (len == (0x20000 + 0x2000)) + dump_sav(file, buffer, type); + else + dump_srm(file, buffer, type); + fclose(file); - return 0; + return 0; error: - if (file) - fclose(file); - return 1; + if (file) + fclose(file); + return 1; } - diff --git a/src/libretro/libretro.h b/src/libretro/libretro.h index 16c274a1..6edd8e00 100755 --- a/src/libretro/libretro.h +++ b/src/libretro/libretro.h @@ -5,17 +5,21 @@ * --------------------------------------------------------------------------------------- * * Permission is hereby granted, free of charge, - * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to any person obtaining a copy of this software and associated documentation files (the + * "Software"), * to deal in the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, - * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * and to permit persons to whom the Software is furnished to do so, subject to the following + * conditions: * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ @@ -23,9 +27,9 @@ #ifndef LIBRETRO_H__ #define LIBRETRO_H__ -#include -#include #include +#include +#include #ifdef __cplusplus extern "C" { @@ -43,70 +47,70 @@ extern "C" { #endif #endif -/* Used for checking API/ABI mismatches that can break libretro +/* Used for checking API/ABI mismatches that can break libretro * implementations. * It is not incremented for compatible changes to the API. */ -#define RETRO_API_VERSION 1 +#define RETRO_API_VERSION 1 /* * Libretro's fundamental device abstractions. * * Libretro's input system consists of some standardized device types, - * such as a joypad (with/without analog), mouse, keyboard, lightgun + * such as a joypad (with/without analog), mouse, keyboard, lightgun * and a pointer. * - * The functionality of these devices are fixed, and individual cores + * The functionality of these devices are fixed, and individual cores * map their own concept of a controller to libretro's abstractions. - * This makes it possible for frontends to map the abstract types to a - * real input device, and not having to worry about binding input + * This makes it possible for frontends to map the abstract types to a + * real input device, and not having to worry about binding input * correctly to arbitrary controller layouts. */ -#define RETRO_DEVICE_TYPE_SHIFT 8 -#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1) +#define RETRO_DEVICE_TYPE_SHIFT 8 +#define RETRO_DEVICE_MASK ((1 << RETRO_DEVICE_TYPE_SHIFT) - 1) #define RETRO_DEVICE_SUBCLASS(base, id) (((id + 1) << RETRO_DEVICE_TYPE_SHIFT) | base) /* Input disabled. */ -#define RETRO_DEVICE_NONE 0 +#define RETRO_DEVICE_NONE 0 -/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo - * controller, but with additional L2/R2/L3/R3 buttons, similar to a +/* The JOYPAD is called RetroPad. It is essentially a Super Nintendo + * controller, but with additional L2/R2/L3/R3 buttons, similar to a * PS1 DualShock. */ -#define RETRO_DEVICE_JOYPAD 1 +#define RETRO_DEVICE_JOYPAD 1 /* The mouse is a simple mouse, similar to Super Nintendo's mouse. * X and Y coordinates are reported relatively to last poll (poll callback). - * It is up to the libretro implementation to keep track of where the mouse + * It is up to the libretro implementation to keep track of where the mouse * pointer is supposed to be on the screen. - * The frontend must make sure not to interfere with its own hardware + * The frontend must make sure not to interfere with its own hardware * mouse pointer. */ -#define RETRO_DEVICE_MOUSE 2 +#define RETRO_DEVICE_MOUSE 2 /* KEYBOARD device lets one poll for raw key pressed. - * It is poll based, so input callback will return with the current + * It is poll based, so input callback will return with the current * pressed state. * For event/text based keyboard input, see * RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. */ -#define RETRO_DEVICE_KEYBOARD 3 +#define RETRO_DEVICE_KEYBOARD 3 /* Lightgun X/Y coordinates are reported relatively to last poll, * similar to mouse. */ -#define RETRO_DEVICE_LIGHTGUN 4 +#define RETRO_DEVICE_LIGHTGUN 4 /* The ANALOG device is an extension to JOYPAD (RetroPad). * Similar to DualShock it adds two analog sticks. - * This is treated as a separate device type as it returns values in the + * This is treated as a separate device type as it returns values in the * full analog range of [-0x8000, 0x7fff]. Positive X axis is right. * Positive Y axis is down. * Only use ANALOG type when polling for analog values of the axes. */ -#define RETRO_DEVICE_ANALOG 5 +#define RETRO_DEVICE_ANALOG 5 /* Abstracts the concept of a pointing mechanism, e.g. touch. - * This allows libretro to query in absolute coordinates where on the + * This allows libretro to query in absolute coordinates where on the * screen a mouse (or something similar) is being placed. * For a touch centric device, coordinates reported are the coordinates * of the press. @@ -114,841 +118,848 @@ extern "C" { * Coordinates in X and Y are reported as: * [-0x7fff, 0x7fff]: -0x7fff corresponds to the far left/top of the screen, * and 0x7fff corresponds to the far right/bottom of the screen. - * The "screen" is here defined as area that is passed to the frontend and + * The "screen" is here defined as area that is passed to the frontend and * later displayed on the monitor. * * The frontend is free to scale/resize this screen as it sees fit, however, - * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the + * (X, Y) = (-0x7fff, -0x7fff) will correspond to the top-left pixel of the * game image, etc. * - * To check if the pointer coordinates are valid (e.g. a touch display + * To check if the pointer coordinates are valid (e.g. a touch display * actually being touched), PRESSED returns 1 or 0. * - * If using a mouse on a desktop, PRESSED will usually correspond to the + * If using a mouse on a desktop, PRESSED will usually correspond to the * left mouse button, but this is a frontend decision. * PRESSED will only return 1 if the pointer is inside the game screen. * - * For multi-touch, the index variable can be used to successively query + * For multi-touch, the index variable can be used to successively query * more presses. * If index = 0 returns true for _PRESSED, coordinates can be extracted - * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with + * with _X, _Y for index = 0. One can then query _PRESSED, _X, _Y with * index = 1, and so on. - * Eventually _PRESSED will return false for an index. No further presses + * Eventually _PRESSED will return false for an index. No further presses * are registered at this point. */ -#define RETRO_DEVICE_POINTER 6 +#define RETRO_DEVICE_POINTER 6 /* Buttons for the RetroPad (JOYPAD). - * The placement of these is equivalent to placements on the + * The placement of these is equivalent to placements on the * Super Nintendo controller. * L2/R2/L3/R3 buttons correspond to the PS1 DualShock. */ -#define RETRO_DEVICE_ID_JOYPAD_B 0 -#define RETRO_DEVICE_ID_JOYPAD_Y 1 -#define RETRO_DEVICE_ID_JOYPAD_SELECT 2 -#define RETRO_DEVICE_ID_JOYPAD_START 3 -#define RETRO_DEVICE_ID_JOYPAD_UP 4 -#define RETRO_DEVICE_ID_JOYPAD_DOWN 5 -#define RETRO_DEVICE_ID_JOYPAD_LEFT 6 -#define RETRO_DEVICE_ID_JOYPAD_RIGHT 7 -#define RETRO_DEVICE_ID_JOYPAD_A 8 -#define RETRO_DEVICE_ID_JOYPAD_X 9 -#define RETRO_DEVICE_ID_JOYPAD_L 10 -#define RETRO_DEVICE_ID_JOYPAD_R 11 -#define RETRO_DEVICE_ID_JOYPAD_L2 12 -#define RETRO_DEVICE_ID_JOYPAD_R2 13 -#define RETRO_DEVICE_ID_JOYPAD_L3 14 -#define RETRO_DEVICE_ID_JOYPAD_R3 15 +#define RETRO_DEVICE_ID_JOYPAD_B 0 +#define RETRO_DEVICE_ID_JOYPAD_Y 1 +#define RETRO_DEVICE_ID_JOYPAD_SELECT 2 +#define RETRO_DEVICE_ID_JOYPAD_START 3 +#define RETRO_DEVICE_ID_JOYPAD_UP 4 +#define RETRO_DEVICE_ID_JOYPAD_DOWN 5 +#define RETRO_DEVICE_ID_JOYPAD_LEFT 6 +#define RETRO_DEVICE_ID_JOYPAD_RIGHT 7 +#define RETRO_DEVICE_ID_JOYPAD_A 8 +#define RETRO_DEVICE_ID_JOYPAD_X 9 +#define RETRO_DEVICE_ID_JOYPAD_L 10 +#define RETRO_DEVICE_ID_JOYPAD_R 11 +#define RETRO_DEVICE_ID_JOYPAD_L2 12 +#define RETRO_DEVICE_ID_JOYPAD_R2 13 +#define RETRO_DEVICE_ID_JOYPAD_L3 14 +#define RETRO_DEVICE_ID_JOYPAD_R3 15 /* Index / Id values for ANALOG device. */ -#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 -#define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1 -#define RETRO_DEVICE_ID_ANALOG_X 0 -#define RETRO_DEVICE_ID_ANALOG_Y 1 +#define RETRO_DEVICE_INDEX_ANALOG_LEFT 0 +#define RETRO_DEVICE_INDEX_ANALOG_RIGHT 1 +#define RETRO_DEVICE_ID_ANALOG_X 0 +#define RETRO_DEVICE_ID_ANALOG_Y 1 /* Id values for MOUSE. */ -#define RETRO_DEVICE_ID_MOUSE_X 0 -#define RETRO_DEVICE_ID_MOUSE_Y 1 -#define RETRO_DEVICE_ID_MOUSE_LEFT 2 -#define RETRO_DEVICE_ID_MOUSE_RIGHT 3 -#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4 -#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5 -#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6 +#define RETRO_DEVICE_ID_MOUSE_X 0 +#define RETRO_DEVICE_ID_MOUSE_Y 1 +#define RETRO_DEVICE_ID_MOUSE_LEFT 2 +#define RETRO_DEVICE_ID_MOUSE_RIGHT 3 +#define RETRO_DEVICE_ID_MOUSE_WHEELUP 4 +#define RETRO_DEVICE_ID_MOUSE_WHEELDOWN 5 +#define RETRO_DEVICE_ID_MOUSE_MIDDLE 6 /* Id values for LIGHTGUN types. */ -#define RETRO_DEVICE_ID_LIGHTGUN_X 0 -#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 -#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 -#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 -#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 -#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 -#define RETRO_DEVICE_ID_LIGHTGUN_START 6 +#define RETRO_DEVICE_ID_LIGHTGUN_X 0 +#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 +#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 +#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 +#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 +#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 +#define RETRO_DEVICE_ID_LIGHTGUN_START 6 /* Id values for POINTER. */ -#define RETRO_DEVICE_ID_POINTER_X 0 -#define RETRO_DEVICE_ID_POINTER_Y 1 -#define RETRO_DEVICE_ID_POINTER_PRESSED 2 +#define RETRO_DEVICE_ID_POINTER_X 0 +#define RETRO_DEVICE_ID_POINTER_Y 1 +#define RETRO_DEVICE_ID_POINTER_PRESSED 2 /* Returned from retro_get_region(). */ -#define RETRO_REGION_NTSC 0 -#define RETRO_REGION_PAL 1 +#define RETRO_REGION_NTSC 0 +#define RETRO_REGION_PAL 1 /* Id values for LANGUAGE */ -enum retro_language -{ - RETRO_LANGUAGE_ENGLISH = 0, - RETRO_LANGUAGE_JAPANESE = 1, - RETRO_LANGUAGE_FRENCH = 2, - RETRO_LANGUAGE_SPANISH = 3, - RETRO_LANGUAGE_GERMAN = 4, - RETRO_LANGUAGE_ITALIAN = 5, - RETRO_LANGUAGE_DUTCH = 6, - RETRO_LANGUAGE_PORTUGUESE = 7, - RETRO_LANGUAGE_RUSSIAN = 8, - RETRO_LANGUAGE_KOREAN = 9, - RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10, - RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11, - RETRO_LANGUAGE_LAST, +enum retro_language { + RETRO_LANGUAGE_ENGLISH = 0, + RETRO_LANGUAGE_JAPANESE = 1, + RETRO_LANGUAGE_FRENCH = 2, + RETRO_LANGUAGE_SPANISH = 3, + RETRO_LANGUAGE_GERMAN = 4, + RETRO_LANGUAGE_ITALIAN = 5, + RETRO_LANGUAGE_DUTCH = 6, + RETRO_LANGUAGE_PORTUGUESE = 7, + RETRO_LANGUAGE_RUSSIAN = 8, + RETRO_LANGUAGE_KOREAN = 9, + RETRO_LANGUAGE_CHINESE_TRADITIONAL = 10, + RETRO_LANGUAGE_CHINESE_SIMPLIFIED = 11, + RETRO_LANGUAGE_LAST, - /* Ensure sizeof(enum) == sizeof(int) */ - RETRO_LANGUAGE_DUMMY = INT_MAX + /* Ensure sizeof(enum) == sizeof(int) */ + RETRO_LANGUAGE_DUMMY = INT_MAX }; /* Passed to retro_get_memory_data/size(). - * If the memory type doesn't apply to the + * If the memory type doesn't apply to the * implementation NULL/0 can be returned. */ -#define RETRO_MEMORY_MASK 0xff +#define RETRO_MEMORY_MASK 0xff /* Regular save RAM. This RAM is usually found on a game cartridge, * backed up by a battery. * If save game data is too complex for a single memory buffer, * the SAVE_DIRECTORY (preferably) or SYSTEM_DIRECTORY environment * callback can be used. */ -#define RETRO_MEMORY_SAVE_RAM 0 +#define RETRO_MEMORY_SAVE_RAM 0 /* Some games have a built-in clock to keep track of time. * This memory is usually just a couple of bytes to keep track of time. */ -#define RETRO_MEMORY_RTC 1 +#define RETRO_MEMORY_RTC 1 /* System ram lets a frontend peek into a game systems main RAM. */ -#define RETRO_MEMORY_SYSTEM_RAM 2 +#define RETRO_MEMORY_SYSTEM_RAM 2 /* Video ram lets a frontend peek into a game systems video RAM (VRAM). */ -#define RETRO_MEMORY_VIDEO_RAM 3 +#define RETRO_MEMORY_VIDEO_RAM 3 /* Keysyms used for ID in input state callback when polling RETRO_KEYBOARD. */ -enum retro_key -{ - RETROK_UNKNOWN = 0, - RETROK_FIRST = 0, - RETROK_BACKSPACE = 8, - RETROK_TAB = 9, - RETROK_CLEAR = 12, - RETROK_RETURN = 13, - RETROK_PAUSE = 19, - RETROK_ESCAPE = 27, - RETROK_SPACE = 32, - RETROK_EXCLAIM = 33, - RETROK_QUOTEDBL = 34, - RETROK_HASH = 35, - RETROK_DOLLAR = 36, - RETROK_AMPERSAND = 38, - RETROK_QUOTE = 39, - RETROK_LEFTPAREN = 40, - RETROK_RIGHTPAREN = 41, - RETROK_ASTERISK = 42, - RETROK_PLUS = 43, - RETROK_COMMA = 44, - RETROK_MINUS = 45, - RETROK_PERIOD = 46, - RETROK_SLASH = 47, - RETROK_0 = 48, - RETROK_1 = 49, - RETROK_2 = 50, - RETROK_3 = 51, - RETROK_4 = 52, - RETROK_5 = 53, - RETROK_6 = 54, - RETROK_7 = 55, - RETROK_8 = 56, - RETROK_9 = 57, - RETROK_COLON = 58, - RETROK_SEMICOLON = 59, - RETROK_LESS = 60, - RETROK_EQUALS = 61, - RETROK_GREATER = 62, - RETROK_QUESTION = 63, - RETROK_AT = 64, - RETROK_LEFTBRACKET = 91, - RETROK_BACKSLASH = 92, - RETROK_RIGHTBRACKET = 93, - RETROK_CARET = 94, - RETROK_UNDERSCORE = 95, - RETROK_BACKQUOTE = 96, - RETROK_a = 97, - RETROK_b = 98, - RETROK_c = 99, - RETROK_d = 100, - RETROK_e = 101, - RETROK_f = 102, - RETROK_g = 103, - RETROK_h = 104, - RETROK_i = 105, - RETROK_j = 106, - RETROK_k = 107, - RETROK_l = 108, - RETROK_m = 109, - RETROK_n = 110, - RETROK_o = 111, - RETROK_p = 112, - RETROK_q = 113, - RETROK_r = 114, - RETROK_s = 115, - RETROK_t = 116, - RETROK_u = 117, - RETROK_v = 118, - RETROK_w = 119, - RETROK_x = 120, - RETROK_y = 121, - RETROK_z = 122, - RETROK_DELETE = 127, +enum retro_key { + RETROK_UNKNOWN = 0, + RETROK_FIRST = 0, + RETROK_BACKSPACE = 8, + RETROK_TAB = 9, + RETROK_CLEAR = 12, + RETROK_RETURN = 13, + RETROK_PAUSE = 19, + RETROK_ESCAPE = 27, + RETROK_SPACE = 32, + RETROK_EXCLAIM = 33, + RETROK_QUOTEDBL = 34, + RETROK_HASH = 35, + RETROK_DOLLAR = 36, + RETROK_AMPERSAND = 38, + RETROK_QUOTE = 39, + RETROK_LEFTPAREN = 40, + RETROK_RIGHTPAREN = 41, + RETROK_ASTERISK = 42, + RETROK_PLUS = 43, + RETROK_COMMA = 44, + RETROK_MINUS = 45, + RETROK_PERIOD = 46, + RETROK_SLASH = 47, + RETROK_0 = 48, + RETROK_1 = 49, + RETROK_2 = 50, + RETROK_3 = 51, + RETROK_4 = 52, + RETROK_5 = 53, + RETROK_6 = 54, + RETROK_7 = 55, + RETROK_8 = 56, + RETROK_9 = 57, + RETROK_COLON = 58, + RETROK_SEMICOLON = 59, + RETROK_LESS = 60, + RETROK_EQUALS = 61, + RETROK_GREATER = 62, + RETROK_QUESTION = 63, + RETROK_AT = 64, + RETROK_LEFTBRACKET = 91, + RETROK_BACKSLASH = 92, + RETROK_RIGHTBRACKET = 93, + RETROK_CARET = 94, + RETROK_UNDERSCORE = 95, + RETROK_BACKQUOTE = 96, + RETROK_a = 97, + RETROK_b = 98, + RETROK_c = 99, + RETROK_d = 100, + RETROK_e = 101, + RETROK_f = 102, + RETROK_g = 103, + RETROK_h = 104, + RETROK_i = 105, + RETROK_j = 106, + RETROK_k = 107, + RETROK_l = 108, + RETROK_m = 109, + RETROK_n = 110, + RETROK_o = 111, + RETROK_p = 112, + RETROK_q = 113, + RETROK_r = 114, + RETROK_s = 115, + RETROK_t = 116, + RETROK_u = 117, + RETROK_v = 118, + RETROK_w = 119, + RETROK_x = 120, + RETROK_y = 121, + RETROK_z = 122, + RETROK_DELETE = 127, - RETROK_KP0 = 256, - RETROK_KP1 = 257, - RETROK_KP2 = 258, - RETROK_KP3 = 259, - RETROK_KP4 = 260, - RETROK_KP5 = 261, - RETROK_KP6 = 262, - RETROK_KP7 = 263, - RETROK_KP8 = 264, - RETROK_KP9 = 265, - RETROK_KP_PERIOD = 266, - RETROK_KP_DIVIDE = 267, - RETROK_KP_MULTIPLY = 268, - RETROK_KP_MINUS = 269, - RETROK_KP_PLUS = 270, - RETROK_KP_ENTER = 271, - RETROK_KP_EQUALS = 272, + RETROK_KP0 = 256, + RETROK_KP1 = 257, + RETROK_KP2 = 258, + RETROK_KP3 = 259, + RETROK_KP4 = 260, + RETROK_KP5 = 261, + RETROK_KP6 = 262, + RETROK_KP7 = 263, + RETROK_KP8 = 264, + RETROK_KP9 = 265, + RETROK_KP_PERIOD = 266, + RETROK_KP_DIVIDE = 267, + RETROK_KP_MULTIPLY = 268, + RETROK_KP_MINUS = 269, + RETROK_KP_PLUS = 270, + RETROK_KP_ENTER = 271, + RETROK_KP_EQUALS = 272, - RETROK_UP = 273, - RETROK_DOWN = 274, - RETROK_RIGHT = 275, - RETROK_LEFT = 276, - RETROK_INSERT = 277, - RETROK_HOME = 278, - RETROK_END = 279, - RETROK_PAGEUP = 280, - RETROK_PAGEDOWN = 281, + RETROK_UP = 273, + RETROK_DOWN = 274, + RETROK_RIGHT = 275, + RETROK_LEFT = 276, + RETROK_INSERT = 277, + RETROK_HOME = 278, + RETROK_END = 279, + RETROK_PAGEUP = 280, + RETROK_PAGEDOWN = 281, - RETROK_F1 = 282, - RETROK_F2 = 283, - RETROK_F3 = 284, - RETROK_F4 = 285, - RETROK_F5 = 286, - RETROK_F6 = 287, - RETROK_F7 = 288, - RETROK_F8 = 289, - RETROK_F9 = 290, - RETROK_F10 = 291, - RETROK_F11 = 292, - RETROK_F12 = 293, - RETROK_F13 = 294, - RETROK_F14 = 295, - RETROK_F15 = 296, + RETROK_F1 = 282, + RETROK_F2 = 283, + RETROK_F3 = 284, + RETROK_F4 = 285, + RETROK_F5 = 286, + RETROK_F6 = 287, + RETROK_F7 = 288, + RETROK_F8 = 289, + RETROK_F9 = 290, + RETROK_F10 = 291, + RETROK_F11 = 292, + RETROK_F12 = 293, + RETROK_F13 = 294, + RETROK_F14 = 295, + RETROK_F15 = 296, - RETROK_NUMLOCK = 300, - RETROK_CAPSLOCK = 301, - RETROK_SCROLLOCK = 302, - RETROK_RSHIFT = 303, - RETROK_LSHIFT = 304, - RETROK_RCTRL = 305, - RETROK_LCTRL = 306, - RETROK_RALT = 307, - RETROK_LALT = 308, - RETROK_RMETA = 309, - RETROK_LMETA = 310, - RETROK_LSUPER = 311, - RETROK_RSUPER = 312, - RETROK_MODE = 313, - RETROK_COMPOSE = 314, + RETROK_NUMLOCK = 300, + RETROK_CAPSLOCK = 301, + RETROK_SCROLLOCK = 302, + RETROK_RSHIFT = 303, + RETROK_LSHIFT = 304, + RETROK_RCTRL = 305, + RETROK_LCTRL = 306, + RETROK_RALT = 307, + RETROK_LALT = 308, + RETROK_RMETA = 309, + RETROK_LMETA = 310, + RETROK_LSUPER = 311, + RETROK_RSUPER = 312, + RETROK_MODE = 313, + RETROK_COMPOSE = 314, - RETROK_HELP = 315, - RETROK_PRINT = 316, - RETROK_SYSREQ = 317, - RETROK_BREAK = 318, - RETROK_MENU = 319, - RETROK_POWER = 320, - RETROK_EURO = 321, - RETROK_UNDO = 322, + RETROK_HELP = 315, + RETROK_PRINT = 316, + RETROK_SYSREQ = 317, + RETROK_BREAK = 318, + RETROK_MENU = 319, + RETROK_POWER = 320, + RETROK_EURO = 321, + RETROK_UNDO = 322, - RETROK_LAST, + RETROK_LAST, - RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ + RETROK_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ }; -enum retro_mod -{ - RETROKMOD_NONE = 0x0000, +enum retro_mod { + RETROKMOD_NONE = 0x0000, - RETROKMOD_SHIFT = 0x01, - RETROKMOD_CTRL = 0x02, - RETROKMOD_ALT = 0x04, - RETROKMOD_META = 0x08, + RETROKMOD_SHIFT = 0x01, + RETROKMOD_CTRL = 0x02, + RETROKMOD_ALT = 0x04, + RETROKMOD_META = 0x08, - RETROKMOD_NUMLOCK = 0x10, - RETROKMOD_CAPSLOCK = 0x20, - RETROKMOD_SCROLLOCK = 0x40, + RETROKMOD_NUMLOCK = 0x10, + RETROKMOD_CAPSLOCK = 0x20, + RETROKMOD_SCROLLOCK = 0x40, - RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ + RETROKMOD_DUMMY = INT_MAX /* Ensure sizeof(enum) == sizeof(int) */ }; -/* If set, this call is not part of the public libretro API yet. It can +/* If set, this call is not part of the public libretro API yet. It can * change or be removed at any time. */ #define RETRO_ENVIRONMENT_EXPERIMENTAL 0x10000 /* Environment callback to be used internally in frontend. */ #define RETRO_ENVIRONMENT_PRIVATE 0x20000 /* Environment commands. */ -#define RETRO_ENVIRONMENT_SET_ROTATION 1 /* const unsigned * -- - * Sets screen rotation of graphics. - * Is only implemented if rotation can be accelerated by hardware. - * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, - * 270 degrees counter-clockwise respectively. - */ -#define RETRO_ENVIRONMENT_GET_OVERSCAN 2 /* bool * -- - * Boolean value whether or not the implementation should use overscan, - * or crop away overscan. - */ -#define RETRO_ENVIRONMENT_GET_CAN_DUPE 3 /* bool * -- - * Boolean value whether or not frontend supports frame duping, - * passing NULL to video frame callback. - */ +#define RETRO_ENVIRONMENT_SET_ROTATION \ + 1 /* const unsigned * -- \ + * Sets screen rotation of graphics. \ + * Is only implemented if rotation can be accelerated by hardware. \ + * Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, \ + * 270 degrees counter-clockwise respectively. \ + */ +#define RETRO_ENVIRONMENT_GET_OVERSCAN \ + 2 /* bool * -- \ + * Boolean value whether or not the implementation should use overscan, \ + * or crop away overscan. \ + */ +#define RETRO_ENVIRONMENT_GET_CAN_DUPE \ + 3 /* bool * -- \ + * Boolean value whether or not frontend supports frame duping, \ + * passing NULL to video frame callback. \ + */ - /* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), - * and reserved to avoid possible ABI clash. - */ +/* Environ 4, 5 are no longer supported (GET_VARIABLE / SET_VARIABLES), + * and reserved to avoid possible ABI clash. + */ -#define RETRO_ENVIRONMENT_SET_MESSAGE 6 /* const struct retro_message * -- - * Sets a message to be displayed in implementation-specific manner - * for a certain amount of 'frames'. - * Should not be used for trivial messages, which should simply be - * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a - * fallback, stderr). - */ -#define RETRO_ENVIRONMENT_SHUTDOWN 7 /* N/A (NULL) -- - * Requests the frontend to shutdown. - * Should only be used if game has a specific - * way to shutdown the game from a menu item or similar. - */ +#define RETRO_ENVIRONMENT_SET_MESSAGE \ + 6 /* const struct retro_message * -- \ + * Sets a message to be displayed in implementation-specific manner \ + * for a certain amount of 'frames'. \ + * Should not be used for trivial messages, which should simply be \ + * logged via RETRO_ENVIRONMENT_GET_LOG_INTERFACE (or as a \ + * fallback, stderr). \ + */ +#define RETRO_ENVIRONMENT_SHUTDOWN \ + 7 /* N/A (NULL) -- \ + * Requests the frontend to shutdown. \ + * Should only be used if game has a specific \ + * way to shutdown the game from a menu item or similar. \ + */ #define RETRO_ENVIRONMENT_SET_PERFORMANCE_LEVEL 8 - /* const unsigned * -- - * Gives a hint to the frontend how demanding this implementation - * is on a system. E.g. reporting a level of 2 means - * this implementation should run decently on all frontends - * of level 2 and up. - * - * It can be used by the frontend to potentially warn - * about too demanding implementations. - * - * The levels are "floating". - * - * This function can be called on a per-game basis, - * as certain games an implementation can play might be - * particularly demanding. - * If called, it should be called in retro_load_game(). - */ +/* const unsigned * -- + * Gives a hint to the frontend how demanding this implementation + * is on a system. E.g. reporting a level of 2 means + * this implementation should run decently on all frontends + * of level 2 and up. + * + * It can be used by the frontend to potentially warn + * about too demanding implementations. + * + * The levels are "floating". + * + * This function can be called on a per-game basis, + * as certain games an implementation can play might be + * particularly demanding. + * If called, it should be called in retro_load_game(). + */ #define RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY 9 - /* const char ** -- - * Returns the "system" directory of the frontend. - * This directory can be used to store system specific - * content such as BIOSes, configuration data, etc. - * The returned value can be NULL. - * If so, no such directory is defined, - * and it's up to the implementation to find a suitable directory. - * - * NOTE: Some cores used this folder also for "save" data such as - * memory cards, etc, for lack of a better place to put it. - * This is now discouraged, and if possible, cores should try to - * use the new GET_SAVE_DIRECTORY. - */ +/* const char ** -- + * Returns the "system" directory of the frontend. + * This directory can be used to store system specific + * content such as BIOSes, configuration data, etc. + * The returned value can be NULL. + * If so, no such directory is defined, + * and it's up to the implementation to find a suitable directory. + * + * NOTE: Some cores used this folder also for "save" data such as + * memory cards, etc, for lack of a better place to put it. + * This is now discouraged, and if possible, cores should try to + * use the new GET_SAVE_DIRECTORY. + */ #define RETRO_ENVIRONMENT_SET_PIXEL_FORMAT 10 - /* const enum retro_pixel_format * -- - * Sets the internal pixel format used by the implementation. - * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555. - * This pixel format however, is deprecated (see enum retro_pixel_format). - * If the call returns false, the frontend does not support this pixel - * format. - * - * This function should be called inside retro_load_game() or - * retro_get_system_av_info(). - */ +/* const enum retro_pixel_format * -- + * Sets the internal pixel format used by the implementation. + * The default pixel format is RETRO_PIXEL_FORMAT_0RGB1555. + * This pixel format however, is deprecated (see enum retro_pixel_format). + * If the call returns false, the frontend does not support this pixel + * format. + * + * This function should be called inside retro_load_game() or + * retro_get_system_av_info(). + */ #define RETRO_ENVIRONMENT_SET_INPUT_DESCRIPTORS 11 - /* const struct retro_input_descriptor * -- - * Sets an array of retro_input_descriptors. - * It is up to the frontend to present this in a usable way. - * The array is terminated by retro_input_descriptor::description - * being set to NULL. - * This function can be called at any time, but it is recommended - * to call it as early as possible. - */ +/* const struct retro_input_descriptor * -- + * Sets an array of retro_input_descriptors. + * It is up to the frontend to present this in a usable way. + * The array is terminated by retro_input_descriptor::description + * being set to NULL. + * This function can be called at any time, but it is recommended + * to call it as early as possible. + */ #define RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK 12 - /* const struct retro_keyboard_callback * -- - * Sets a callback function used to notify core about keyboard events. - */ +/* const struct retro_keyboard_callback * -- + * Sets a callback function used to notify core about keyboard events. + */ #define RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE 13 - /* const struct retro_disk_control_callback * -- - * Sets an interface which frontend can use to eject and insert - * disk images. - * This is used for games which consist of multiple images and - * must be manually swapped out by the user (e.g. PSX). - */ +/* const struct retro_disk_control_callback * -- + * Sets an interface which frontend can use to eject and insert + * disk images. + * This is used for games which consist of multiple images and + * must be manually swapped out by the user (e.g. PSX). + */ #define RETRO_ENVIRONMENT_SET_HW_RENDER 14 - /* struct retro_hw_render_callback * -- - * Sets an interface to let a libretro core render with - * hardware acceleration. - * Should be called in retro_load_game(). - * If successful, libretro cores will be able to render to a - * frontend-provided framebuffer. - * The size of this framebuffer will be at least as large as - * max_width/max_height provided in get_av_info(). - * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or - * NULL to retro_video_refresh_t. - */ +/* struct retro_hw_render_callback * -- + * Sets an interface to let a libretro core render with + * hardware acceleration. + * Should be called in retro_load_game(). + * If successful, libretro cores will be able to render to a + * frontend-provided framebuffer. + * The size of this framebuffer will be at least as large as + * max_width/max_height provided in get_av_info(). + * If HW rendering is used, pass only RETRO_HW_FRAME_BUFFER_VALID or + * NULL to retro_video_refresh_t. + */ #define RETRO_ENVIRONMENT_GET_VARIABLE 15 - /* struct retro_variable * -- - * Interface to acquire user-defined information from environment - * that cannot feasibly be supported in a multi-system way. - * 'key' should be set to a key which has already been set by - * SET_VARIABLES. - * 'data' will be set to a value or NULL. - */ +/* struct retro_variable * -- + * Interface to acquire user-defined information from environment + * that cannot feasibly be supported in a multi-system way. + * 'key' should be set to a key which has already been set by + * SET_VARIABLES. + * 'data' will be set to a value or NULL. + */ #define RETRO_ENVIRONMENT_SET_VARIABLES 16 - /* const struct retro_variable * -- - * Allows an implementation to signal the environment - * which variables it might want to check for later using - * GET_VARIABLE. - * This allows the frontend to present these variables to - * a user dynamically. - * This should be called as early as possible (ideally in - * retro_set_environment). - * - * 'data' points to an array of retro_variable structs - * terminated by a { NULL, NULL } element. - * retro_variable::key should be namespaced to not collide - * with other implementations' keys. E.g. A core called - * 'foo' should use keys named as 'foo_option'. - * retro_variable::value should contain a human readable - * description of the key as well as a '|' delimited list - * of expected values. - * - * The number of possible options should be very limited, - * i.e. it should be feasible to cycle through options - * without a keyboard. - * - * First entry should be treated as a default. - * - * Example entry: - * { "foo_option", "Speed hack coprocessor X; false|true" } - * - * Text before first ';' is description. This ';' must be - * followed by a space, and followed by a list of possible - * values split up with '|'. - * - * Only strings are operated on. The possible values will - * generally be displayed and stored as-is by the frontend. - */ +/* const struct retro_variable * -- + * Allows an implementation to signal the environment + * which variables it might want to check for later using + * GET_VARIABLE. + * This allows the frontend to present these variables to + * a user dynamically. + * This should be called as early as possible (ideally in + * retro_set_environment). + * + * 'data' points to an array of retro_variable structs + * terminated by a { NULL, NULL } element. + * retro_variable::key should be namespaced to not collide + * with other implementations' keys. E.g. A core called + * 'foo' should use keys named as 'foo_option'. + * retro_variable::value should contain a human readable + * description of the key as well as a '|' delimited list + * of expected values. + * + * The number of possible options should be very limited, + * i.e. it should be feasible to cycle through options + * without a keyboard. + * + * First entry should be treated as a default. + * + * Example entry: + * { "foo_option", "Speed hack coprocessor X; false|true" } + * + * Text before first ';' is description. This ';' must be + * followed by a space, and followed by a list of possible + * values split up with '|'. + * + * Only strings are operated on. The possible values will + * generally be displayed and stored as-is by the frontend. + */ #define RETRO_ENVIRONMENT_GET_VARIABLE_UPDATE 17 - /* bool * -- - * Result is set to true if some variables are updated by - * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. - * Variables should be queried with GET_VARIABLE. - */ +/* bool * -- + * Result is set to true if some variables are updated by + * frontend since last call to RETRO_ENVIRONMENT_GET_VARIABLE. + * Variables should be queried with GET_VARIABLE. + */ #define RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME 18 - /* const bool * -- - * If true, the libretro implementation supports calls to - * retro_load_game() with NULL as argument. - * Used by cores which can run without particular game data. - * This should be called within retro_set_environment() only. - */ +/* const bool * -- + * If true, the libretro implementation supports calls to + * retro_load_game() with NULL as argument. + * Used by cores which can run without particular game data. + * This should be called within retro_set_environment() only. + */ #define RETRO_ENVIRONMENT_GET_LIBRETRO_PATH 19 - /* const char ** -- - * Retrieves the absolute path from where this libretro - * implementation was loaded. - * NULL is returned if the libretro was loaded statically - * (i.e. linked statically to frontend), or if the path cannot be - * determined. - * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can - * be loaded without ugly hacks. - */ - - /* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. - * It was not used by any known core at the time, - * and was removed from the API. */ -#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22 - /* const struct retro_audio_callback * -- - * Sets an interface which is used to notify a libretro core about audio - * being available for writing. - * The callback can be called from any thread, so a core using this must - * have a thread safe audio implementation. - * It is intended for games where audio and video are completely - * asynchronous and audio can be generated on the fly. - * This interface is not recommended for use with emulators which have - * highly synchronous audio. - * - * The callback only notifies about writability; the libretro core still - * has to call the normal audio callbacks - * to write audio. The audio callbacks must be called from within the - * notification callback. - * The amount of audio data to write is up to the implementation. - * Generally, the audio callback will be called continously in a loop. - * - * Due to thread safety guarantees and lack of sync between audio and - * video, a frontend can selectively disallow this interface based on - * internal configuration. A core using this interface must also - * implement the "normal" audio interface. - * - * A libretro core using SET_AUDIO_CALLBACK should also make use of - * SET_FRAME_TIME_CALLBACK. - */ -#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21 - /* const struct retro_frame_time_callback * -- - * Lets the core know how much time has passed since last - * invocation of retro_run(). - * The frontend can tamper with the timing to fake fast-forward, - * slow-motion, frame stepping, etc. - * In this case the delta time will use the reference value - * in frame_time_callback.. - */ -#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23 - /* struct retro_rumble_interface * -- - * Gets an interface which is used by a libretro core to set - * state of rumble motors in controllers. - * A strong and weak motor is supported, and they can be - * controlled indepedently. - */ -#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 - /* uint64_t * -- - * Gets a bitmask telling which device type are expected to be - * handled properly in a call to retro_input_state_t. - * Devices which are not handled or recognized always return - * 0 in retro_input_state_t. - * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG). - * Should only be called in retro_run(). - */ -#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* struct retro_sensor_interface * -- - * Gets access to the sensor interface. - * The purpose of this interface is to allow - * setting state related to sensors such as polling rate, - * enabling/disable it entirely, etc. - * Reading sensor state is done via the normal - * input_state_callback API. - */ -#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* struct retro_camera_callback * -- - * Gets an interface to a video camera driver. - * A libretro core can use this interface to get access to a - * video camera. - * New video frames are delivered in a callback in same - * thread as retro_run(). - * - * GET_CAMERA_INTERFACE should be called in retro_load_game(). - * - * Depending on the camera implementation used, camera frames - * will be delivered as a raw framebuffer, - * or as an OpenGL texture directly. - * - * The core has to tell the frontend here which types of - * buffers can be handled properly. - * An OpenGL texture can only be handled when using a - * libretro GL core (SET_HW_RENDER). - * It is recommended to use a libretro GL core when - * using camera interface. - * - * The camera is not started automatically. The retrieved start/stop - * functions must be used to explicitly - * start and stop the camera driver. - */ -#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27 - /* struct retro_log_callback * -- - * Gets an interface for logging. This is useful for - * logging in a cross-platform way - * as certain platforms cannot use use stderr for logging. - * It also allows the frontend to - * show logging information in a more suitable way. - * If this interface is not used, libretro cores should - * log to stderr as desired. - */ -#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28 - /* struct retro_perf_callback * -- - * Gets an interface for performance counters. This is useful - * for performance logging in a cross-platform way and for detecting - * architecture-specific features, such as SIMD support. - */ -#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29 - /* struct retro_location_callback * -- - * Gets access to the location interface. - * The purpose of this interface is to be able to retrieve - * location-based information from the host device, - * such as current latitude / longitude. - */ -#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 - /* const char ** -- - * Returns the "content" directory of the frontend. - * This directory can be used to store specific assets that the - * core relies upon, such as art assets, - * input data, etc etc. - * The returned value can be NULL. - * If so, no such directory is defined, - * and it's up to the implementation to find a suitable directory. - */ -#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31 - /* const char ** -- - * Returns the "save" directory of the frontend. - * This directory can be used to store SRAM, memory cards, - * high scores, etc, if the libretro core - * cannot use the regular memory interface (retro_get_memory_data()). - * - * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for - * similar things before. - * They should still check GET_SYSTEM_DIRECTORY if they want to - * be backwards compatible. - * The path here can be NULL. It should only be non-NULL if the - * frontend user has set a specific save path. - */ -#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32 - /* const struct retro_system_av_info * -- - * Sets a new av_info structure. This can only be called from - * within retro_run(). - * This should *only* be used if the core is completely altering the - * internal resolutions, aspect ratios, timings, sampling rate, etc. - * Calling this can require a full reinitialization of video/audio - * drivers in the frontend, - * - * so it is important to call it very sparingly, and usually only with - * the users explicit consent. - * An eventual driver reinitialize will happen so that video and - * audio callbacks - * happening after this call within the same retro_run() call will - * target the newly initialized driver. - * - * This callback makes it possible to support configurable resolutions - * in games, which can be useful to - * avoid setting the "worst case" in max_width/max_height. - * - * ***HIGHLY RECOMMENDED*** Do not call this callback every time - * resolution changes in an emulator core if it's - * expected to be a temporary change, for the reasons of possible - * driver reinitialization. - * This call is not a free pass for not trying to provide - * correct values in retro_get_system_av_info(). If you need to change - * things like aspect ratio or nominal width/height, - * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant - * of SET_SYSTEM_AV_INFO. - * - * If this returns false, the frontend does not acknowledge a - * changed av_info struct. - */ -#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33 - /* const struct retro_get_proc_address_interface * -- - * Allows a libretro core to announce support for the - * get_proc_address() interface. - * This interface allows for a standard way to extend libretro where - * use of environment calls are too indirect, - * e.g. for cases where the frontend wants to call directly into the core. - * - * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK - * **MUST** be called from within retro_set_environment(). - */ -#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34 - /* const struct retro_subsystem_info * -- - * This environment call introduces the concept of libretro "subsystems". - * A subsystem is a variant of a libretro core which supports - * different kinds of games. - * The purpose of this is to support e.g. emulators which might - * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo. - * It can also be used to pick among subsystems in an explicit way - * if the libretro implementation is a multi-system emulator itself. - * - * Loading a game via a subsystem is done with retro_load_game_special(), - * and this environment call allows a libretro core to expose which - * subsystems are supported for use with retro_load_game_special(). - * A core passes an array of retro_game_special_info which is terminated - * with a zeroed out retro_game_special_info struct. - * - * If a core wants to use this functionality, SET_SUBSYSTEM_INFO - * **MUST** be called from within retro_set_environment(). - */ -#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35 - /* const struct retro_controller_info * -- - * This environment call lets a libretro core tell the frontend - * which controller types are recognized in calls to - * retro_set_controller_port_device(). - * - * Some emulators such as Super Nintendo - * support multiple lightgun types which must be specifically - * selected from. - * It is therefore sometimes necessary for a frontend to be able - * to tell the core about a special kind of input device which is - * not covered by the libretro input API. - * - * In order for a frontend to understand the workings of an input device, - * it must be a specialized type - * of the generic device types already defined in the libretro API. - * - * Which devices are supported can vary per input port. - * The core must pass an array of const struct retro_controller_info which - * is terminated with a blanked out struct. Each element of the struct - * corresponds to an ascending port index to - * retro_set_controller_port_device(). - * Even if special device types are set in the libretro core, - * libretro should only poll input based on the base input device types. - */ -#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL) - /* const struct retro_memory_map * -- - * This environment call lets a libretro core tell the frontend - * about the memory maps this core emulates. - * This can be used to implement, for example, cheats in a core-agnostic way. - * - * Should only be used by emulators; it doesn't make much sense for - * anything else. - * It is recommended to expose all relevant pointers through - * retro_get_memory_* as well. - * - * Can be called from retro_init and retro_load_game. - */ -#define RETRO_ENVIRONMENT_SET_GEOMETRY 37 - /* const struct retro_game_geometry * -- - * This environment call is similar to SET_SYSTEM_AV_INFO for changing - * video parameters, but provides a guarantee that drivers will not be - * reinitialized. - * This can only be called from within retro_run(). - * - * The purpose of this call is to allow a core to alter nominal - * width/heights as well as aspect ratios on-the-fly, which can be - * useful for some emulators to change in run-time. - * - * max_width/max_height arguments are ignored and cannot be changed - * with this call as this could potentially require a reinitialization or a - * non-constant time operation. - * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required. - * - * A frontend must guarantee that this environment call completes in - * constant time. - */ -#define RETRO_ENVIRONMENT_GET_USERNAME 38 - /* const char ** - * Returns the specified username of the frontend, if specified by the user. - * This username can be used as a nickname for a core that has online facilities - * or any other mode where personalization of the user is desirable. - * The returned value can be NULL. - * If this environ callback is used by a core that requires a valid username, - * a default username should be specified by the core. - */ -#define RETRO_ENVIRONMENT_GET_LANGUAGE 39 - /* unsigned * -- - * Returns the specified language of the frontend, if specified by the user. - * It can be used by the core for localization purposes. - */ +/* const char ** -- + * Retrieves the absolute path from where this libretro + * implementation was loaded. + * NULL is returned if the libretro was loaded statically + * (i.e. linked statically to frontend), or if the path cannot be + * determined. + * Mostly useful in cooperation with SET_SUPPORT_NO_GAME as assets can + * be loaded without ugly hacks. + */ -#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ -#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ -#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */ -#define RETRO_MEMDESC_ALIGN_4 (2 << 16) -#define RETRO_MEMDESC_ALIGN_8 (3 << 16) -#define RETRO_MEMDESC_MINSIZE_2 (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */ +/* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK. + * It was not used by any known core at the time, + * and was removed from the API. */ +#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22 +/* const struct retro_audio_callback * -- + * Sets an interface which is used to notify a libretro core about audio + * being available for writing. + * The callback can be called from any thread, so a core using this must + * have a thread safe audio implementation. + * It is intended for games where audio and video are completely + * asynchronous and audio can be generated on the fly. + * This interface is not recommended for use with emulators which have + * highly synchronous audio. + * + * The callback only notifies about writability; the libretro core still + * has to call the normal audio callbacks + * to write audio. The audio callbacks must be called from within the + * notification callback. + * The amount of audio data to write is up to the implementation. + * Generally, the audio callback will be called continously in a loop. + * + * Due to thread safety guarantees and lack of sync between audio and + * video, a frontend can selectively disallow this interface based on + * internal configuration. A core using this interface must also + * implement the "normal" audio interface. + * + * A libretro core using SET_AUDIO_CALLBACK should also make use of + * SET_FRAME_TIME_CALLBACK. + */ +#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21 +/* const struct retro_frame_time_callback * -- + * Lets the core know how much time has passed since last + * invocation of retro_run(). + * The frontend can tamper with the timing to fake fast-forward, + * slow-motion, frame stepping, etc. + * In this case the delta time will use the reference value + * in frame_time_callback.. + */ +#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23 +/* struct retro_rumble_interface * -- + * Gets an interface which is used by a libretro core to set + * state of rumble motors in controllers. + * A strong and weak motor is supported, and they can be + * controlled indepedently. + */ +#define RETRO_ENVIRONMENT_GET_INPUT_DEVICE_CAPABILITIES 24 +/* uint64_t * -- + * Gets a bitmask telling which device type are expected to be + * handled properly in a call to retro_input_state_t. + * Devices which are not handled or recognized always return + * 0 in retro_input_state_t. + * Example bitmask: caps = (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG). + * Should only be called in retro_run(). + */ +#define RETRO_ENVIRONMENT_GET_SENSOR_INTERFACE (25 | RETRO_ENVIRONMENT_EXPERIMENTAL) +/* struct retro_sensor_interface * -- + * Gets access to the sensor interface. + * The purpose of this interface is to allow + * setting state related to sensors such as polling rate, + * enabling/disable it entirely, etc. + * Reading sensor state is done via the normal + * input_state_callback API. + */ +#define RETRO_ENVIRONMENT_GET_CAMERA_INTERFACE (26 | RETRO_ENVIRONMENT_EXPERIMENTAL) +/* struct retro_camera_callback * -- + * Gets an interface to a video camera driver. + * A libretro core can use this interface to get access to a + * video camera. + * New video frames are delivered in a callback in same + * thread as retro_run(). + * + * GET_CAMERA_INTERFACE should be called in retro_load_game(). + * + * Depending on the camera implementation used, camera frames + * will be delivered as a raw framebuffer, + * or as an OpenGL texture directly. + * + * The core has to tell the frontend here which types of + * buffers can be handled properly. + * An OpenGL texture can only be handled when using a + * libretro GL core (SET_HW_RENDER). + * It is recommended to use a libretro GL core when + * using camera interface. + * + * The camera is not started automatically. The retrieved start/stop + * functions must be used to explicitly + * start and stop the camera driver. + */ +#define RETRO_ENVIRONMENT_GET_LOG_INTERFACE 27 +/* struct retro_log_callback * -- + * Gets an interface for logging. This is useful for + * logging in a cross-platform way + * as certain platforms cannot use use stderr for logging. + * It also allows the frontend to + * show logging information in a more suitable way. + * If this interface is not used, libretro cores should + * log to stderr as desired. + */ +#define RETRO_ENVIRONMENT_GET_PERF_INTERFACE 28 +/* struct retro_perf_callback * -- + * Gets an interface for performance counters. This is useful + * for performance logging in a cross-platform way and for detecting + * architecture-specific features, such as SIMD support. + */ +#define RETRO_ENVIRONMENT_GET_LOCATION_INTERFACE 29 +/* struct retro_location_callback * -- + * Gets access to the location interface. + * The purpose of this interface is to be able to retrieve + * location-based information from the host device, + * such as current latitude / longitude. + */ +#define RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY 30 +/* const char ** -- + * Returns the "content" directory of the frontend. + * This directory can be used to store specific assets that the + * core relies upon, such as art assets, + * input data, etc etc. + * The returned value can be NULL. + * If so, no such directory is defined, + * and it's up to the implementation to find a suitable directory. + */ +#define RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY 31 +/* const char ** -- + * Returns the "save" directory of the frontend. + * This directory can be used to store SRAM, memory cards, + * high scores, etc, if the libretro core + * cannot use the regular memory interface (retro_get_memory_data()). + * + * NOTE: libretro cores used to check GET_SYSTEM_DIRECTORY for + * similar things before. + * They should still check GET_SYSTEM_DIRECTORY if they want to + * be backwards compatible. + * The path here can be NULL. It should only be non-NULL if the + * frontend user has set a specific save path. + */ +#define RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO 32 +/* const struct retro_system_av_info * -- + * Sets a new av_info structure. This can only be called from + * within retro_run(). + * This should *only* be used if the core is completely altering the + * internal resolutions, aspect ratios, timings, sampling rate, etc. + * Calling this can require a full reinitialization of video/audio + * drivers in the frontend, + * + * so it is important to call it very sparingly, and usually only with + * the users explicit consent. + * An eventual driver reinitialize will happen so that video and + * audio callbacks + * happening after this call within the same retro_run() call will + * target the newly initialized driver. + * + * This callback makes it possible to support configurable resolutions + * in games, which can be useful to + * avoid setting the "worst case" in max_width/max_height. + * + * ***HIGHLY RECOMMENDED*** Do not call this callback every time + * resolution changes in an emulator core if it's + * expected to be a temporary change, for the reasons of possible + * driver reinitialization. + * This call is not a free pass for not trying to provide + * correct values in retro_get_system_av_info(). If you need to change + * things like aspect ratio or nominal width/height, + * use RETRO_ENVIRONMENT_SET_GEOMETRY, which is a softer variant + * of SET_SYSTEM_AV_INFO. + * + * If this returns false, the frontend does not acknowledge a + * changed av_info struct. + */ +#define RETRO_ENVIRONMENT_SET_PROC_ADDRESS_CALLBACK 33 +/* const struct retro_get_proc_address_interface * -- + * Allows a libretro core to announce support for the + * get_proc_address() interface. + * This interface allows for a standard way to extend libretro where + * use of environment calls are too indirect, + * e.g. for cases where the frontend wants to call directly into the core. + * + * If a core wants to expose this interface, SET_PROC_ADDRESS_CALLBACK + * **MUST** be called from within retro_set_environment(). + */ +#define RETRO_ENVIRONMENT_SET_SUBSYSTEM_INFO 34 +/* const struct retro_subsystem_info * -- + * This environment call introduces the concept of libretro "subsystems". + * A subsystem is a variant of a libretro core which supports + * different kinds of games. + * The purpose of this is to support e.g. emulators which might + * have special needs, e.g. Super Nintendo's Super GameBoy, Sufami Turbo. + * It can also be used to pick among subsystems in an explicit way + * if the libretro implementation is a multi-system emulator itself. + * + * Loading a game via a subsystem is done with retro_load_game_special(), + * and this environment call allows a libretro core to expose which + * subsystems are supported for use with retro_load_game_special(). + * A core passes an array of retro_game_special_info which is terminated + * with a zeroed out retro_game_special_info struct. + * + * If a core wants to use this functionality, SET_SUBSYSTEM_INFO + * **MUST** be called from within retro_set_environment(). + */ +#define RETRO_ENVIRONMENT_SET_CONTROLLER_INFO 35 +/* const struct retro_controller_info * -- + * This environment call lets a libretro core tell the frontend + * which controller types are recognized in calls to + * retro_set_controller_port_device(). + * + * Some emulators such as Super Nintendo + * support multiple lightgun types which must be specifically + * selected from. + * It is therefore sometimes necessary for a frontend to be able + * to tell the core about a special kind of input device which is + * not covered by the libretro input API. + * + * In order for a frontend to understand the workings of an input device, + * it must be a specialized type + * of the generic device types already defined in the libretro API. + * + * Which devices are supported can vary per input port. + * The core must pass an array of const struct retro_controller_info which + * is terminated with a blanked out struct. Each element of the struct + * corresponds to an ascending port index to + * retro_set_controller_port_device(). + * Even if special device types are set in the libretro core, + * libretro should only poll input based on the base input device types. + */ +#define RETRO_ENVIRONMENT_SET_MEMORY_MAPS (36 | RETRO_ENVIRONMENT_EXPERIMENTAL) +/* const struct retro_memory_map * -- + * This environment call lets a libretro core tell the frontend + * about the memory maps this core emulates. + * This can be used to implement, for example, cheats in a core-agnostic way. + * + * Should only be used by emulators; it doesn't make much sense for + * anything else. + * It is recommended to expose all relevant pointers through + * retro_get_memory_* as well. + * + * Can be called from retro_init and retro_load_game. + */ +#define RETRO_ENVIRONMENT_SET_GEOMETRY 37 +/* const struct retro_game_geometry * -- + * This environment call is similar to SET_SYSTEM_AV_INFO for changing + * video parameters, but provides a guarantee that drivers will not be + * reinitialized. + * This can only be called from within retro_run(). + * + * The purpose of this call is to allow a core to alter nominal + * width/heights as well as aspect ratios on-the-fly, which can be + * useful for some emulators to change in run-time. + * + * max_width/max_height arguments are ignored and cannot be changed + * with this call as this could potentially require a reinitialization or a + * non-constant time operation. + * If max_width/max_height are to be changed, SET_SYSTEM_AV_INFO is required. + * + * A frontend must guarantee that this environment call completes in + * constant time. + */ +#define RETRO_ENVIRONMENT_GET_USERNAME 38 +/* const char ** + * Returns the specified username of the frontend, if specified by the user. + * This username can be used as a nickname for a core that has online facilities + * or any other mode where personalization of the user is desirable. + * The returned value can be NULL. + * If this environ callback is used by a core that requires a valid username, + * a default username should be specified by the core. + */ +#define RETRO_ENVIRONMENT_GET_LANGUAGE 39 +/* unsigned * -- + * Returns the specified language of the frontend, if specified by the user. + * It can be used by the core for localization purposes. + */ + +#define RETRO_MEMDESC_CONST \ + (1 << 0) /* The frontend will never change this memory area once retro_load_game has \ + returned. */ +#define RETRO_MEMDESC_BIGENDIAN \ + (1 << 1) /* The memory area contains big endian data. Default is little endian. */ +#define RETRO_MEMDESC_ALIGN_2 \ + (1 << 16) /* All memory access in this area is aligned to their own size, or 2, \ + whichever is smaller. */ +#define RETRO_MEMDESC_ALIGN_4 (2 << 16) +#define RETRO_MEMDESC_ALIGN_8 (3 << 16) +#define RETRO_MEMDESC_MINSIZE_2 \ + (1 << 24) /* All memory in this region is accessed at least 2 bytes at the time. */ #define RETRO_MEMDESC_MINSIZE_4 (2 << 24) #define RETRO_MEMDESC_MINSIZE_8 (3 << 24) -struct retro_memory_descriptor -{ - uint64_t flags; +struct retro_memory_descriptor { + uint64_t flags; - /* Pointer to the start of the relevant ROM or RAM chip. - * It's strongly recommended to use 'offset' if possible, rather than - * doing math on the pointer. - * - * If the same byte is mapped my multiple descriptors, their descriptors - * must have the same pointer. - * If 'start' does not point to the first byte in the pointer, put the - * difference in 'offset' instead. - * - * May be NULL if there's nothing usable here (e.g. hardware registers and - * open bus). No flags should be set if the pointer is NULL. - * It's recommended to minimize the number of descriptors if possible, - * but not mandatory. */ - void *ptr; - size_t offset; + /* Pointer to the start of the relevant ROM or RAM chip. + * It's strongly recommended to use 'offset' if possible, rather than + * doing math on the pointer. + * + * If the same byte is mapped my multiple descriptors, their descriptors + * must have the same pointer. + * If 'start' does not point to the first byte in the pointer, put the + * difference in 'offset' instead. + * + * May be NULL if there's nothing usable here (e.g. hardware registers and + * open bus). No flags should be set if the pointer is NULL. + * It's recommended to minimize the number of descriptors if possible, + * but not mandatory. */ + void *ptr; + size_t offset; - /* This is the location in the emulated address space - * where the mapping starts. */ - size_t start; + /* This is the location in the emulated address space + * where the mapping starts. */ + size_t start; - /* Which bits must be same as in 'start' for this mapping to apply. - * The first memory descriptor to claim a certain byte is the one - * that applies. - * A bit which is set in 'start' must also be set in this. - * Can be zero, in which case each byte is assumed mapped exactly once. - * In this case, 'len' must be a power of two. */ - size_t select; + /* Which bits must be same as in 'start' for this mapping to apply. + * The first memory descriptor to claim a certain byte is the one + * that applies. + * A bit which is set in 'start' must also be set in this. + * Can be zero, in which case each byte is assumed mapped exactly once. + * In this case, 'len' must be a power of two. */ + size_t select; - /* If this is nonzero, the set bits are assumed not connected to the - * memory chip's address pins. */ - size_t disconnect; + /* If this is nonzero, the set bits are assumed not connected to the + * memory chip's address pins. */ + size_t disconnect; - /* This one tells the size of the current memory area. - * If, after start+disconnect are applied, the address is higher than - * this, the highest bit of the address is cleared. - * - * If the address is still too high, the next highest bit is cleared. - * Can be zero, in which case it's assumed to be infinite (as limited - * by 'select' and 'disconnect'). */ - size_t len; + /* This one tells the size of the current memory area. + * If, after start+disconnect are applied, the address is higher than + * this, the highest bit of the address is cleared. + * + * If the address is still too high, the next highest bit is cleared. + * Can be zero, in which case it's assumed to be infinite (as limited + * by 'select' and 'disconnect'). */ + size_t len; - /* To go from emulated address to physical address, the following - * order applies: - * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. - * - * The address space name must consist of only a-zA-Z0-9_-, - * should be as short as feasible (maximum length is 8 plus the NUL), - * and may not be any other address space plus one or more 0-9A-F - * at the end. - * However, multiple memory descriptors for the same address space is - * allowed, and the address space name can be empty. NULL is treated - * as empty. - * - * Address space names are case sensitive, but avoid lowercase if possible. - * The same pointer may exist in multiple address spaces. - * - * Examples: - * blank+blank - valid (multiple things may be mapped in the same namespace) - * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace) - * 'A'+'B' - valid (neither is a prefix of each other) - * 'S'+blank - valid ('S' is not in 0-9A-F) - * 'a'+blank - valid ('a' is not in 0-9A-F) - * 'a'+'A' - valid (neither is a prefix of each other) - * 'AR'+blank - valid ('R' is not in 0-9A-F) - * 'ARB'+blank - valid (the B can't be part of the address either, because - * there is no namespace 'AR') - * blank+'B' - not valid, because it's ambigous which address space B1234 - * would refer to. - * The length can't be used for that purpose; the frontend may want - * to append arbitrary data to an address, without a separator. */ - const char *addrspace; + /* To go from emulated address to physical address, the following + * order applies: + * Subtract 'start', pick off 'disconnect', apply 'len', add 'offset'. + * + * The address space name must consist of only a-zA-Z0-9_-, + * should be as short as feasible (maximum length is 8 plus the NUL), + * and may not be any other address space plus one or more 0-9A-F + * at the end. + * However, multiple memory descriptors for the same address space is + * allowed, and the address space name can be empty. NULL is treated + * as empty. + * + * Address space names are case sensitive, but avoid lowercase if possible. + * The same pointer may exist in multiple address spaces. + * + * Examples: + * blank+blank - valid (multiple things may be mapped in the same namespace) + * 'Sp'+'Sp' - valid (multiple things may be mapped in the same namespace) + * 'A'+'B' - valid (neither is a prefix of each other) + * 'S'+blank - valid ('S' is not in 0-9A-F) + * 'a'+blank - valid ('a' is not in 0-9A-F) + * 'a'+'A' - valid (neither is a prefix of each other) + * 'AR'+blank - valid ('R' is not in 0-9A-F) + * 'ARB'+blank - valid (the B can't be part of the address either, because + * there is no namespace 'AR') + * blank+'B' - not valid, because it's ambigous which address space B1234 + * would refer to. + * The length can't be used for that purpose; the frontend may want + * to append arbitrary data to an address, without a separator. */ + const char *addrspace; }; -/* The frontend may use the largest value of 'start'+'select' in a +/* The frontend may use the largest value of 'start'+'select' in a * certain namespace to infer the size of the address space. * - * If the address space is larger than that, a mapping with .ptr=NULL - * should be at the end of the array, with .select set to all ones for + * If the address space is larger than that, a mapping with .ptr=NULL + * should be at the end of the array, with .select set to all ones for * as long as the address space is big. * * Sample descriptors (minus .ptr, and RETRO_MEMFLAG_ on the flags): * SNES WRAM: * .start=0x7E0000, .len=0x20000 - * (Note that this must be mapped before the ROM in most cases; some of the - * ROM mappers + * (Note that this must be mapped before the ROM in most cases; some of the + * ROM mappers * try to claim $7E0000, or at least $7E8000.) * SNES SPC700 RAM: * .addrspace="S", .len=0x10000 @@ -957,7 +968,7 @@ struct retro_memory_descriptor * .flags=MIRROR, .start=0x800000, .select=0xC0E000, .len=0x2000 * SNES WRAM mirrors, alternate equivalent descriptor: * .flags=MIRROR, .select=0x40E000, .disconnect=~0x1FFF - * (Various similar constructions can be created by combining parts of + * (Various similar constructions can be created by combining parts of * the above two.) * SNES LoROM (512KB, mirrored a couple of times): * .flags=CONST, .start=0x008000, .select=0x408000, .disconnect=0x8000, .len=512*1024 @@ -975,93 +986,87 @@ struct retro_memory_descriptor * .len can be implied by .select in many of them, but was included for clarity. */ -struct retro_memory_map -{ - const struct retro_memory_descriptor *descriptors; - unsigned num_descriptors; +struct retro_memory_map { + const struct retro_memory_descriptor *descriptors; + unsigned num_descriptors; }; -struct retro_controller_description -{ - /* Human-readable description of the controller. Even if using a generic - * input device type, this can be set to the particular device type the - * core uses. */ - const char *desc; +struct retro_controller_description { + /* Human-readable description of the controller. Even if using a generic + * input device type, this can be set to the particular device type the + * core uses. */ + const char *desc; - /* Device type passed to retro_set_controller_port_device(). If the device - * type is a sub-class of a generic input device type, use the - * RETRO_DEVICE_SUBCLASS macro to create an ID. - * - * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */ - unsigned id; + /* Device type passed to retro_set_controller_port_device(). If the device + * type is a sub-class of a generic input device type, use the + * RETRO_DEVICE_SUBCLASS macro to create an ID. + * + * E.g. RETRO_DEVICE_SUBCLASS(RETRO_DEVICE_JOYPAD, 1). */ + unsigned id; }; -struct retro_controller_info -{ - const struct retro_controller_description *types; - unsigned num_types; +struct retro_controller_info { + const struct retro_controller_description *types; + unsigned num_types; }; -struct retro_subsystem_memory_info -{ - /* The extension associated with a memory type, e.g. "psram". */ - const char *extension; +struct retro_subsystem_memory_info { + /* The extension associated with a memory type, e.g. "psram". */ + const char *extension; - /* The memory type for retro_get_memory(). This should be at - * least 0x100 to avoid conflict with standardized - * libretro memory types. */ - unsigned type; + /* The memory type for retro_get_memory(). This should be at + * least 0x100 to avoid conflict with standardized + * libretro memory types. */ + unsigned type; }; -struct retro_subsystem_rom_info -{ - /* Describes what the content is (SGB BIOS, GB ROM, etc). */ - const char *desc; +struct retro_subsystem_rom_info { + /* Describes what the content is (SGB BIOS, GB ROM, etc). */ + const char *desc; - /* Same definition as retro_get_system_info(). */ - const char *valid_extensions; + /* Same definition as retro_get_system_info(). */ + const char *valid_extensions; - /* Same definition as retro_get_system_info(). */ - bool need_fullpath; + /* Same definition as retro_get_system_info(). */ + bool need_fullpath; - /* Same definition as retro_get_system_info(). */ - bool block_extract; + /* Same definition as retro_get_system_info(). */ + bool block_extract; - /* This is set if the content is required to load a game. - * If this is set to false, a zeroed-out retro_game_info can be passed. */ - bool required; + /* This is set if the content is required to load a game. + * If this is set to false, a zeroed-out retro_game_info can be passed. */ + bool required; - /* Content can have multiple associated persistent - * memory types (retro_get_memory()). */ - const struct retro_subsystem_memory_info *memory; - unsigned num_memory; + /* Content can have multiple associated persistent + * memory types (retro_get_memory()). */ + const struct retro_subsystem_memory_info *memory; + unsigned num_memory; }; -struct retro_subsystem_info -{ - /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */ - const char *desc; +struct retro_subsystem_info { + /* Human-readable string of the subsystem type, e.g. "Super GameBoy" */ + const char *desc; - /* A computer friendly short string identifier for the subsystem type. - * This name must be [a-z]. - * E.g. if desc is "Super GameBoy", this can be "sgb". - * This identifier can be used for command-line interfaces, etc. - */ - const char *ident; + /* A computer friendly short string identifier for the subsystem type. + * This name must be [a-z]. + * E.g. if desc is "Super GameBoy", this can be "sgb". + * This identifier can be used for command-line interfaces, etc. + */ + const char *ident; - /* Infos for each content file. The first entry is assumed to be the - * "most significant" content for frontend purposes. - * E.g. with Super GameBoy, the first content should be the GameBoy ROM, - * as it is the most "significant" content to a user. - * If a frontend creates new file paths based on the content used - * (e.g. savestates), it should use the path for the first ROM to do so. */ - const struct retro_subsystem_rom_info *roms; + /* Infos for each content file. The first entry is assumed to be the + * "most significant" content for frontend purposes. + * E.g. with Super GameBoy, the first content should be the GameBoy ROM, + * as it is the most "significant" content to a user. + * If a frontend creates new file paths based on the content used + * (e.g. savestates), it should use the path for the first ROM to do so. */ + const struct retro_subsystem_rom_info *roms; - /* Number of content files associated with a subsystem. */ - unsigned num_roms; - - /* The type passed to retro_load_game_special(). */ - unsigned id; + /* Number of content files associated with a subsystem. */ + unsigned num_roms; + + /* The type passed to retro_load_game_special(). */ + unsigned id; }; typedef void (*retro_proc_address_t)(void); @@ -1070,73 +1075,68 @@ typedef void (*retro_proc_address_t)(void); * (None here so far). * * Get a symbol from a libretro core. - * Cores should only return symbols which are actual + * Cores should only return symbols which are actual * extensions to the libretro API. * - * Frontends should not use this to obtain symbols to standard + * Frontends should not use this to obtain symbols to standard * libretro entry points (static linking or dlsym). * - * The symbol name must be equal to the function name, + * The symbol name must be equal to the function name, * e.g. if void retro_foo(void); exists, the symbol must be called "retro_foo". * The returned function pointer must be cast to the corresponding type. */ typedef retro_proc_address_t (*retro_get_proc_address_t)(const char *sym); -struct retro_get_proc_address_interface -{ - retro_get_proc_address_t get_proc_address; +struct retro_get_proc_address_interface { + retro_get_proc_address_t get_proc_address; }; -enum retro_log_level -{ - RETRO_LOG_DEBUG = 0, - RETRO_LOG_INFO, - RETRO_LOG_WARN, - RETRO_LOG_ERROR, +enum retro_log_level { + RETRO_LOG_DEBUG = 0, + RETRO_LOG_INFO, + RETRO_LOG_WARN, + RETRO_LOG_ERROR, - RETRO_LOG_DUMMY = INT_MAX + RETRO_LOG_DUMMY = INT_MAX }; /* Logging function. Takes log level argument as well. */ -typedef void (*retro_log_printf_t)(enum retro_log_level level, - const char *fmt, ...); +typedef void (*retro_log_printf_t)(enum retro_log_level level, const char *fmt, ...); -struct retro_log_callback -{ - retro_log_printf_t log; +struct retro_log_callback { + retro_log_printf_t log; }; /* Performance related functions */ /* ID values for SIMD CPU features */ -#define RETRO_SIMD_SSE (1 << 0) -#define RETRO_SIMD_SSE2 (1 << 1) -#define RETRO_SIMD_VMX (1 << 2) -#define RETRO_SIMD_VMX128 (1 << 3) -#define RETRO_SIMD_AVX (1 << 4) -#define RETRO_SIMD_NEON (1 << 5) -#define RETRO_SIMD_SSE3 (1 << 6) -#define RETRO_SIMD_SSSE3 (1 << 7) -#define RETRO_SIMD_MMX (1 << 8) -#define RETRO_SIMD_MMXEXT (1 << 9) -#define RETRO_SIMD_SSE4 (1 << 10) -#define RETRO_SIMD_SSE42 (1 << 11) -#define RETRO_SIMD_AVX2 (1 << 12) -#define RETRO_SIMD_VFPU (1 << 13) -#define RETRO_SIMD_PS (1 << 14) -#define RETRO_SIMD_AES (1 << 15) +#define RETRO_SIMD_SSE (1 << 0) +#define RETRO_SIMD_SSE2 (1 << 1) +#define RETRO_SIMD_VMX (1 << 2) +#define RETRO_SIMD_VMX128 (1 << 3) +#define RETRO_SIMD_AVX (1 << 4) +#define RETRO_SIMD_NEON (1 << 5) +#define RETRO_SIMD_SSE3 (1 << 6) +#define RETRO_SIMD_SSSE3 (1 << 7) +#define RETRO_SIMD_MMX (1 << 8) +#define RETRO_SIMD_MMXEXT (1 << 9) +#define RETRO_SIMD_SSE4 (1 << 10) +#define RETRO_SIMD_SSE42 (1 << 11) +#define RETRO_SIMD_AVX2 (1 << 12) +#define RETRO_SIMD_VFPU (1 << 13) +#define RETRO_SIMD_PS (1 << 14) +#define RETRO_SIMD_AES (1 << 15) typedef uint64_t retro_perf_tick_t; typedef int64_t retro_time_t; -struct retro_perf_counter -{ - const char *ident; - retro_perf_tick_t start; - retro_perf_tick_t total; - retro_perf_tick_t call_cnt; +struct retro_perf_counter { + const char *ident; + retro_perf_tick_t start; + retro_perf_tick_t total; + retro_perf_tick_t call_cnt; - bool registered; + bool registered; }; /* Returns current time in microseconds. @@ -1145,7 +1145,7 @@ struct retro_perf_counter typedef retro_time_t (*retro_perf_get_time_usec_t)(void); /* A simple counter. Usually nanoseconds, but can also be CPU cycles. - * Can be used directly if desired (when creating a more sophisticated + * Can be used directly if desired (when creating a more sophisticated * performance counter system). * */ typedef retro_perf_tick_t (*retro_perf_get_counter_t)(void); @@ -1159,9 +1159,9 @@ typedef uint64_t (*retro_get_cpu_features_t)(void); typedef void (*retro_perf_log_t)(void); /* Register a performance counter. - * ident field must be set with a discrete value and other values in + * ident field must be set with a discrete value and other values in * retro_perf_counter must be 0. - * Registering can be called multiple times. To avoid calling to + * Registering can be called multiple times. To avoid calling to * frontend redundantly, you can check registered field first. */ typedef void (*retro_perf_register_t)(struct retro_perf_counter *counter); @@ -1174,7 +1174,8 @@ typedef void (*retro_perf_stop_t)(struct retro_perf_counter *counter); /* For convenience it can be useful to wrap register, start and stop in macros. * E.g.: * #ifdef LOG_PERFORMANCE - * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if (!name.registered) perf_cb.perf_register(&(name)) + * #define RETRO_PERFORMANCE_INIT(perf_cb, name) static struct retro_perf_counter name = {#name}; if + * (!name.registered) perf_cb.perf_register(&(name)) * #define RETRO_PERFORMANCE_START(perf_cb, name) perf_cb.perf_start(&(name)) * #define RETRO_PERFORMANCE_STOP(perf_cb, name) perf_cb.perf_stop(&(name)) * #else @@ -1204,27 +1205,25 @@ typedef void (*retro_perf_stop_t)(struct retro_perf_counter *counter); * } */ -struct retro_perf_callback -{ - retro_perf_get_time_usec_t get_time_usec; - retro_get_cpu_features_t get_cpu_features; +struct retro_perf_callback { + retro_perf_get_time_usec_t get_time_usec; + retro_get_cpu_features_t get_cpu_features; - retro_perf_get_counter_t get_perf_counter; - retro_perf_register_t perf_register; - retro_perf_start_t perf_start; - retro_perf_stop_t perf_stop; - retro_perf_log_t perf_log; + retro_perf_get_counter_t get_perf_counter; + retro_perf_register_t perf_register; + retro_perf_start_t perf_start; + retro_perf_stop_t perf_stop; + retro_perf_log_t perf_log; }; /* FIXME: Document the sensor API and work out behavior. * It will be marked as experimental until then. */ -enum retro_sensor_action -{ - RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, - RETRO_SENSOR_ACCELEROMETER_DISABLE, +enum retro_sensor_action { + RETRO_SENSOR_ACCELEROMETER_ENABLE = 0, + RETRO_SENSOR_ACCELEROMETER_DISABLE, - RETRO_SENSOR_DUMMY = INT_MAX + RETRO_SENSOR_DUMMY = INT_MAX }; /* Id values for SENSOR types. */ @@ -1232,23 +1231,21 @@ enum retro_sensor_action #define RETRO_SENSOR_ACCELEROMETER_Y 1 #define RETRO_SENSOR_ACCELEROMETER_Z 2 -typedef bool (*retro_set_sensor_state_t)(unsigned port, - enum retro_sensor_action action, unsigned rate); +typedef bool (*retro_set_sensor_state_t)(unsigned port, enum retro_sensor_action action, + unsigned rate); typedef float (*retro_sensor_get_input_t)(unsigned port, unsigned id); -struct retro_sensor_interface -{ - retro_set_sensor_state_t set_sensor_state; - retro_sensor_get_input_t get_sensor_input; +struct retro_sensor_interface { + retro_set_sensor_state_t set_sensor_state; + retro_sensor_get_input_t get_sensor_input; }; -enum retro_camera_buffer -{ - RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0, - RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER, +enum retro_camera_buffer { + RETRO_CAMERA_BUFFER_OPENGL_TEXTURE = 0, + RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER, - RETRO_CAMERA_BUFFER_DUMMY = INT_MAX + RETRO_CAMERA_BUFFER_DUMMY = INT_MAX }; /* Starts the camera driver. Can only be called in retro_run(). */ @@ -1257,7 +1254,7 @@ typedef bool (*retro_camera_start_t)(void); /* Stops the camera driver. Can only be called in retro_run(). */ typedef void (*retro_camera_stop_t)(void); -/* Callback which signals when the camera driver is initialized +/* Callback which signals when the camera driver is initialized * and/or deinitialized. * retro_camera_start_t can be called in initialized callback. */ @@ -1267,61 +1264,61 @@ typedef void (*retro_camera_lifetime_status_t)(void); * Width, height and pitch are similar to retro_video_refresh_t. * First pixel is top-left origin. */ -typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, - unsigned width, unsigned height, size_t pitch); +typedef void (*retro_camera_frame_raw_framebuffer_t)(const uint32_t *buffer, unsigned width, + unsigned height, size_t pitch); /* A callback for when OpenGL textures are used. * * texture_id is a texture owned by camera driver. - * Its state or content should be considered immutable, except for things like + * Its state or content should be considered immutable, except for things like * texture filtering and clamping. * * texture_target is the texture target for the GL texture. - * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly + * These can include e.g. GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE, and possibly * more depending on extensions. * - * affine points to a packed 3x3 column-major matrix used to apply an affine + * affine points to a packed 3x3 column-major matrix used to apply an affine * transform to texture coordinates. (affine_matrix * vec3(coord_x, coord_y, 1.0)) - * After transform, normalized texture coord (0, 0) should be bottom-left + * After transform, normalized texture coord (0, 0) should be bottom-left * and (1, 1) should be top-right (or (width, height) for RECTANGLE). * - * GL-specific typedefs are avoided here to avoid relying on gl.h in + * GL-specific typedefs are avoided here to avoid relying on gl.h in * the API definition. */ -typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, - unsigned texture_target, const float *affine); +typedef void (*retro_camera_frame_opengl_texture_t)(unsigned texture_id, unsigned texture_target, + const float *affine); -struct retro_camera_callback -{ - /* Set by libretro core. - * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). - */ - uint64_t caps; +struct retro_camera_callback { + /* Set by libretro core. + * Example bitmask: caps = (1 << RETRO_CAMERA_BUFFER_OPENGL_TEXTURE) | (1 << + * RETRO_CAMERA_BUFFER_RAW_FRAMEBUFFER). + */ + uint64_t caps; - unsigned width; /* Desired resolution for camera. Is only used as a hint. */ - unsigned height; - retro_camera_start_t start; /* Set by frontend. */ - retro_camera_stop_t stop; /* Set by frontend. */ + unsigned width; /* Desired resolution for camera. Is only used as a hint. */ + unsigned height; + retro_camera_start_t start; /* Set by frontend. */ + retro_camera_stop_t stop; /* Set by frontend. */ - /* Set by libretro core if raw framebuffer callbacks will be used. */ - retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; - /* Set by libretro core if OpenGL texture callbacks will be used. */ - retro_camera_frame_opengl_texture_t frame_opengl_texture; + /* Set by libretro core if raw framebuffer callbacks will be used. */ + retro_camera_frame_raw_framebuffer_t frame_raw_framebuffer; + /* Set by libretro core if OpenGL texture callbacks will be used. */ + retro_camera_frame_opengl_texture_t frame_opengl_texture; - /* Set by libretro core. Called after camera driver is initialized and - * ready to be started. - * Can be NULL, in which this callback is not called. - */ - retro_camera_lifetime_status_t initialized; + /* Set by libretro core. Called after camera driver is initialized and + * ready to be started. + * Can be NULL, in which this callback is not called. + */ + retro_camera_lifetime_status_t initialized; - /* Set by libretro core. Called right before camera driver is - * deinitialized. - * Can be NULL, in which this callback is not called. - */ - retro_camera_lifetime_status_t deinitialized; + /* Set by libretro core. Called right before camera driver is + * deinitialized. + * Can be NULL, in which this callback is not called. + */ + retro_camera_lifetime_status_t deinitialized; }; -/* Sets the interval of time and/or distance at which to update/poll +/* Sets the interval of time and/or distance at which to update/poll * location-based data. * * To ensure compatibility with all location-based implementations, @@ -1330,104 +1327,98 @@ struct retro_camera_callback * interval_ms is the interval expressed in milliseconds. * interval_distance is the distance interval expressed in meters. */ -typedef void (*retro_location_set_interval_t)(unsigned interval_ms, - unsigned interval_distance); +typedef void (*retro_location_set_interval_t)(unsigned interval_ms, unsigned interval_distance); /* Start location services. The device will start listening for changes to the - * current location at regular intervals (which are defined with + * current location at regular intervals (which are defined with * retro_location_set_interval_t). */ typedef bool (*retro_location_start_t)(void); -/* Stop location services. The device will stop listening for changes +/* Stop location services. The device will stop listening for changes * to the current location. */ typedef void (*retro_location_stop_t)(void); -/* Get the position of the current location. Will set parameters to +/* Get the position of the current location. Will set parameters to * 0 if no new location update has happened since the last time. */ -typedef bool (*retro_location_get_position_t)(double *lat, double *lon, - double *horiz_accuracy, double *vert_accuracy); +typedef bool (*retro_location_get_position_t)(double *lat, double *lon, double *horiz_accuracy, + double *vert_accuracy); -/* Callback which signals when the location driver is initialized +/* Callback which signals when the location driver is initialized * and/or deinitialized. * retro_location_start_t can be called in initialized callback. */ typedef void (*retro_location_lifetime_status_t)(void); -struct retro_location_callback -{ - retro_location_start_t start; - retro_location_stop_t stop; - retro_location_get_position_t get_position; - retro_location_set_interval_t set_interval; +struct retro_location_callback { + retro_location_start_t start; + retro_location_stop_t stop; + retro_location_get_position_t get_position; + retro_location_set_interval_t set_interval; - retro_location_lifetime_status_t initialized; - retro_location_lifetime_status_t deinitialized; + retro_location_lifetime_status_t initialized; + retro_location_lifetime_status_t deinitialized; }; -enum retro_rumble_effect -{ - RETRO_RUMBLE_STRONG = 0, - RETRO_RUMBLE_WEAK = 1, +enum retro_rumble_effect { + RETRO_RUMBLE_STRONG = 0, + RETRO_RUMBLE_WEAK = 1, - RETRO_RUMBLE_DUMMY = INT_MAX + RETRO_RUMBLE_DUMMY = INT_MAX }; -/* Sets rumble state for joypad plugged in port 'port'. +/* Sets rumble state for joypad plugged in port 'port'. * Rumble effects are controlled independently, * and setting e.g. strong rumble does not override weak rumble. * Strength has a range of [0, 0xffff]. * - * Returns true if rumble state request was honored. + * Returns true if rumble state request was honored. * Calling this before first retro_run() is likely to return false. */ -typedef bool (*retro_set_rumble_state_t)(unsigned port, - enum retro_rumble_effect effect, uint16_t strength); +typedef bool (*retro_set_rumble_state_t)(unsigned port, enum retro_rumble_effect effect, + uint16_t strength); -struct retro_rumble_interface -{ - retro_set_rumble_state_t set_rumble_state; +struct retro_rumble_interface { + retro_set_rumble_state_t set_rumble_state; }; /* Notifies libretro that audio data should be written. */ typedef void (*retro_audio_callback_t)(void); -/* True: Audio driver in frontend is active, and callback is +/* True: Audio driver in frontend is active, and callback is * expected to be called regularily. - * False: Audio driver in frontend is paused or inactive. - * Audio callback will not be called until set_state has been + * False: Audio driver in frontend is paused or inactive. + * Audio callback will not be called until set_state has been * called with true. * Initial state is false (inactive). */ typedef void (*retro_audio_set_state_callback_t)(bool enabled); -struct retro_audio_callback -{ - retro_audio_callback_t callback; - retro_audio_set_state_callback_t set_state; +struct retro_audio_callback { + retro_audio_callback_t callback; + retro_audio_set_state_callback_t set_state; }; -/* Notifies a libretro core of time spent since last invocation +/* Notifies a libretro core of time spent since last invocation * of retro_run() in microseconds. * * It will be called right before retro_run() every frame. - * The frontend can tamper with timing to support cases like + * The frontend can tamper with timing to support cases like * fast-forward, slow-motion and framestepping. * * In those scenarios the reference frame time value will be used. */ typedef int64_t retro_usec_t; typedef void (*retro_frame_time_callback_t)(retro_usec_t usec); -struct retro_frame_time_callback -{ - retro_frame_time_callback_t callback; - /* Represents the time of one frame. It is computed as - * 1000000 / fps, but the implementation will resolve the - * rounding to ensure that framestepping, etc is exact. */ - retro_usec_t reference; +struct retro_frame_time_callback { + retro_frame_time_callback_t callback; + /* Represents the time of one frame. It is computed as + * 1000000 / fps, but the implementation will resolve the + * rounding to ensure that framestepping, etc is exact. */ + retro_usec_t reference; }; /* Pass this to retro_video_refresh_t if rendering to hardware. * Passing NULL to retro_video_refresh_t is still a frame dupe as normal. * */ -#define RETRO_HW_FRAME_BUFFER_VALID ((void*)-1) +#define RETRO_HW_FRAME_BUFFER_VALID ((void *)-1) /* Invalidates the current HW context. * Any GL state is lost, and must not be deinitialized explicitly. @@ -1435,7 +1426,7 @@ struct retro_frame_time_callback * it should implement context_destroy callback. * If called, all GPU resources must be reinitialized. * Usually called when frontend reinits video driver. - * Also called first time video driver is initialized, + * Also called first time video driver is initialized, * allowing libretro core to initialize resources. */ typedef void (*retro_hw_context_reset_t)(void); @@ -1448,104 +1439,102 @@ typedef uintptr_t (*retro_hw_get_current_framebuffer_t)(void); /* Get a symbol from HW context. */ typedef retro_proc_address_t (*retro_hw_get_proc_address_t)(const char *sym); -enum retro_hw_context_type -{ - RETRO_HW_CONTEXT_NONE = 0, - /* OpenGL 2.x. Driver can choose to use latest compatibility context. */ - RETRO_HW_CONTEXT_OPENGL = 1, - /* OpenGL ES 2.0. */ - RETRO_HW_CONTEXT_OPENGLES2 = 2, - /* Modern desktop core GL context. Use version_major/ - * version_minor fields to set GL version. */ - RETRO_HW_CONTEXT_OPENGL_CORE = 3, - /* OpenGL ES 3.0 */ - RETRO_HW_CONTEXT_OPENGLES3 = 4, - /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3, - * use the corresponding enums directly. */ - RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, +enum retro_hw_context_type { + RETRO_HW_CONTEXT_NONE = 0, + /* OpenGL 2.x. Driver can choose to use latest compatibility context. */ + RETRO_HW_CONTEXT_OPENGL = 1, + /* OpenGL ES 2.0. */ + RETRO_HW_CONTEXT_OPENGLES2 = 2, + /* Modern desktop core GL context. Use version_major/ + * version_minor fields to set GL version. */ + RETRO_HW_CONTEXT_OPENGL_CORE = 3, + /* OpenGL ES 3.0 */ + RETRO_HW_CONTEXT_OPENGLES3 = 4, + /* OpenGL ES 3.1+. Set version_major/version_minor. For GLES2 and GLES3, + * use the corresponding enums directly. */ + RETRO_HW_CONTEXT_OPENGLES_VERSION = 5, - RETRO_HW_CONTEXT_DUMMY = INT_MAX + RETRO_HW_CONTEXT_DUMMY = INT_MAX }; -struct retro_hw_render_callback -{ - /* Which API to use. Set by libretro core. */ - enum retro_hw_context_type context_type; +struct retro_hw_render_callback { + /* Which API to use. Set by libretro core. */ + enum retro_hw_context_type context_type; - /* Called when a context has been created or when it has been reset. - * An OpenGL context is only valid after context_reset() has been called. - * - * When context_reset is called, OpenGL resources in the libretro - * implementation are guaranteed to be invalid. - * - * It is possible that context_reset is called multiple times during an - * application lifecycle. - * If context_reset is called without any notification (context_destroy), - * the OpenGL context was lost and resources should just be recreated - * without any attempt to "free" old resources. - */ - retro_hw_context_reset_t context_reset; + /* Called when a context has been created or when it has been reset. + * An OpenGL context is only valid after context_reset() has been called. + * + * When context_reset is called, OpenGL resources in the libretro + * implementation are guaranteed to be invalid. + * + * It is possible that context_reset is called multiple times during an + * application lifecycle. + * If context_reset is called without any notification (context_destroy), + * the OpenGL context was lost and resources should just be recreated + * without any attempt to "free" old resources. + */ + retro_hw_context_reset_t context_reset; - /* Set by frontend. */ - retro_hw_get_current_framebuffer_t get_current_framebuffer; + /* Set by frontend. */ + retro_hw_get_current_framebuffer_t get_current_framebuffer; - /* Set by frontend. */ - retro_hw_get_proc_address_t get_proc_address; + /* Set by frontend. */ + retro_hw_get_proc_address_t get_proc_address; - /* Set if render buffers should have depth component attached. */ - bool depth; + /* Set if render buffers should have depth component attached. */ + bool depth; - /* Set if stencil buffers should be attached. */ - bool stencil; + /* Set if stencil buffers should be attached. */ + bool stencil; - /* If depth and stencil are true, a packed 24/8 buffer will be added. - * Only attaching stencil is invalid and will be ignored. */ + /* If depth and stencil are true, a packed 24/8 buffer will be added. + * Only attaching stencil is invalid and will be ignored. */ - /* Use conventional bottom-left origin convention. If false, - * standard libretro top-left origin semantics are used. */ - bool bottom_left_origin; - - /* Major version number for core GL context or GLES 3.1+. */ - unsigned version_major; + /* Use conventional bottom-left origin convention. If false, + * standard libretro top-left origin semantics are used. */ + bool bottom_left_origin; - /* Minor version number for core GL context or GLES 3.1+. */ - unsigned version_minor; + /* Major version number for core GL context or GLES 3.1+. */ + unsigned version_major; - /* If this is true, the frontend will go very far to avoid - * resetting context in scenarios like toggling fullscreen, etc. - */ - bool cache_context; + /* Minor version number for core GL context or GLES 3.1+. */ + unsigned version_minor; - /* The reset callback might still be called in extreme situations - * such as if the context is lost beyond recovery. - * - * For optimal stability, set this to false, and allow context to be - * reset at any time. - */ - - /* A callback to be called before the context is destroyed in a - * controlled way by the frontend. */ - retro_hw_context_reset_t context_destroy; + /* If this is true, the frontend will go very far to avoid + * resetting context in scenarios like toggling fullscreen, etc. + */ + bool cache_context; - /* OpenGL resources can be deinitialized cleanly at this step. - * context_destroy can be set to NULL, in which resources will - * just be destroyed without any notification. - * - * Even when context_destroy is non-NULL, it is possible that - * context_reset is called without any destroy notification. - * This happens if context is lost by external factors (such as - * notified by GL_ARB_robustness). - * - * In this case, the context is assumed to be already dead, - * and the libretro implementation must not try to free any OpenGL - * resources in the subsequent context_reset. - */ + /* The reset callback might still be called in extreme situations + * such as if the context is lost beyond recovery. + * + * For optimal stability, set this to false, and allow context to be + * reset at any time. + */ - /* Creates a debug context. */ - bool debug_context; + /* A callback to be called before the context is destroyed in a + * controlled way by the frontend. */ + retro_hw_context_reset_t context_destroy; + + /* OpenGL resources can be deinitialized cleanly at this step. + * context_destroy can be set to NULL, in which resources will + * just be destroyed without any notification. + * + * Even when context_destroy is non-NULL, it is possible that + * context_reset is called without any destroy notification. + * This happens if context is lost by external factors (such as + * notified by GL_ARB_robustness). + * + * In this case, the context is assumed to be already dead, + * and the libretro implementation must not try to free any OpenGL + * resources in the subsequent context_reset. + */ + + /* Creates a debug context. */ + bool debug_context; }; -/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. +/* Callback type passed in RETRO_ENVIRONMENT_SET_KEYBOARD_CALLBACK. * Called by the frontend in response to keyboard events. * down is set if the key is being pressed, or false if it is being released. * keycode is the RETROK value of the char. @@ -1553,33 +1542,32 @@ struct retro_hw_render_callback * key_modifiers is a set of RETROKMOD values or'ed together. * * The pressed/keycode state can be indepedent of the character. - * It is also possible that multiple characters are generated from a + * It is also possible that multiple characters are generated from a * single keypress. * Keycode events should be treated separately from character events. * However, when possible, the frontend should try to synchronize these. * If only a character is posted, keycode should be RETROK_UNKNOWN. * - * Similarily if only a keycode event is generated with no corresponding + * Similarily if only a keycode event is generated with no corresponding * character, character should be 0. */ -typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, - uint32_t character, uint16_t key_modifiers); +typedef void (*retro_keyboard_event_t)(bool down, unsigned keycode, uint32_t character, + uint16_t key_modifiers); -struct retro_keyboard_callback -{ - retro_keyboard_event_t callback; +struct retro_keyboard_callback { + retro_keyboard_event_t callback; }; /* Callbacks for RETRO_ENVIRONMENT_SET_DISK_CONTROL_INTERFACE. - * Should be set for implementations which can swap out multiple disk + * Should be set for implementations which can swap out multiple disk * images in runtime. * * If the implementation can do this automatically, it should strive to do so. * However, there are cases where the user must manually do so. * - * Overview: To swap a disk image, eject the disk image with + * Overview: To swap a disk image, eject the disk image with * set_eject_state(true). - * Set the disk index with set_image_index(index). Insert the disk again + * Set the disk index with set_image_index(index). Insert the disk again * with set_eject_state(false). */ @@ -1597,7 +1585,7 @@ typedef bool (*retro_get_eject_state_t)(void); typedef unsigned (*retro_get_image_index_t)(void); /* Sets image index. Can only be called when disk is ejected. - * The implementation supports setting "no disk" by using an + * The implementation supports setting "no disk" by using an * index >= get_num_images(). */ typedef bool (*retro_set_image_index_t)(unsigned index); @@ -1611,195 +1599,184 @@ struct retro_game_info; * Arguments to pass in info have same requirements as retro_load_game(). * Virtual disk tray must be ejected when calling this. * - * Replacing a disk image with info = NULL will remove the disk image + * Replacing a disk image with info = NULL will remove the disk image * from the internal list. * As a result, calls to get_image_index() can change. * - * E.g. replace_image_index(1, NULL), and previous get_image_index() + * E.g. replace_image_index(1, NULL), and previous get_image_index() * returned 4 before. * Index 1 will be removed, and the new index is 3. */ -typedef bool (*retro_replace_image_index_t)(unsigned index, - const struct retro_game_info *info); +typedef bool (*retro_replace_image_index_t)(unsigned index, const struct retro_game_info *info); /* Adds a new valid index (get_num_images()) to the internal disk list. * This will increment subsequent return values from get_num_images() by 1. - * This image index cannot be used until a disk image has been set + * This image index cannot be used until a disk image has been set * with replace_image_index. */ typedef bool (*retro_add_image_index_t)(void); -struct retro_disk_control_callback -{ - retro_set_eject_state_t set_eject_state; - retro_get_eject_state_t get_eject_state; +struct retro_disk_control_callback { + retro_set_eject_state_t set_eject_state; + retro_get_eject_state_t get_eject_state; - retro_get_image_index_t get_image_index; - retro_set_image_index_t set_image_index; - retro_get_num_images_t get_num_images; + retro_get_image_index_t get_image_index; + retro_set_image_index_t set_image_index; + retro_get_num_images_t get_num_images; - retro_replace_image_index_t replace_image_index; - retro_add_image_index_t add_image_index; + retro_replace_image_index_t replace_image_index; + retro_add_image_index_t add_image_index; }; -enum retro_pixel_format -{ - /* 0RGB1555, native endian. - * 0 bit must be set to 0. - * This pixel format is default for compatibility concerns only. - * If a 15/16-bit pixel format is desired, consider using RGB565. */ - RETRO_PIXEL_FORMAT_0RGB1555 = 0, +enum retro_pixel_format { + /* 0RGB1555, native endian. + * 0 bit must be set to 0. + * This pixel format is default for compatibility concerns only. + * If a 15/16-bit pixel format is desired, consider using RGB565. */ + RETRO_PIXEL_FORMAT_0RGB1555 = 0, - /* XRGB8888, native endian. - * X bits are ignored. */ - RETRO_PIXEL_FORMAT_XRGB8888 = 1, + /* XRGB8888, native endian. + * X bits are ignored. */ + RETRO_PIXEL_FORMAT_XRGB8888 = 1, - /* RGB565, native endian. - * This pixel format is the recommended format to use if a 15/16-bit - * format is desired as it is the pixel format that is typically - * available on a wide range of low-power devices. - * - * It is also natively supported in APIs like OpenGL ES. */ - RETRO_PIXEL_FORMAT_RGB565 = 2, + /* RGB565, native endian. + * This pixel format is the recommended format to use if a 15/16-bit + * format is desired as it is the pixel format that is typically + * available on a wide range of low-power devices. + * + * It is also natively supported in APIs like OpenGL ES. */ + RETRO_PIXEL_FORMAT_RGB565 = 2, - /* Ensure sizeof() == sizeof(int). */ - RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX + /* Ensure sizeof() == sizeof(int). */ + RETRO_PIXEL_FORMAT_UNKNOWN = INT_MAX }; -struct retro_message -{ - const char *msg; /* Message to be displayed. */ - unsigned frames; /* Duration in frames of message. */ +struct retro_message { + const char *msg; /* Message to be displayed. */ + unsigned frames; /* Duration in frames of message. */ }; /* Describes how the libretro implementation maps a libretro input bind * to its internal input system through a human readable string. * This string can be used to better let a user configure input. */ -struct retro_input_descriptor -{ - /* Associates given parameters with a description. */ - unsigned port; - unsigned device; - unsigned index; - unsigned id; +struct retro_input_descriptor { + /* Associates given parameters with a description. */ + unsigned port; + unsigned device; + unsigned index; + unsigned id; - /* Human readable description for parameters. - * The pointer must remain valid until - * retro_unload_game() is called. */ - const char *description; + /* Human readable description for parameters. + * The pointer must remain valid until + * retro_unload_game() is called. */ + const char *description; }; -struct retro_system_info -{ - /* All pointers are owned by libretro implementation, and pointers must - * remain valid until retro_deinit() is called. */ +struct retro_system_info { + /* All pointers are owned by libretro implementation, and pointers must + * remain valid until retro_deinit() is called. */ - const char *library_name; /* Descriptive name of library. Should not - * contain any version numbers, etc. */ - const char *library_version; /* Descriptive version of core. */ + const char *library_name; /* Descriptive name of library. Should not + * contain any version numbers, etc. */ + const char *library_version; /* Descriptive version of core. */ - const char *valid_extensions; /* A string listing probably content - * extensions the core will be able to - * load, separated with pipe. - * I.e. "bin|rom|iso". - * Typically used for a GUI to filter - * out extensions. */ + const char *valid_extensions; /* A string listing probably content + * extensions the core will be able to + * load, separated with pipe. + * I.e. "bin|rom|iso". + * Typically used for a GUI to filter + * out extensions. */ - /* If true, retro_load_game() is guaranteed to provide a valid pathname - * in retro_game_info::path. - * ::data and ::size are both invalid. - * - * If false, ::data and ::size are guaranteed to be valid, but ::path - * might not be valid. - * - * This is typically set to true for libretro implementations that must - * load from file. - * Implementations should strive for setting this to false, as it allows - * the frontend to perform patching, etc. */ - bool need_fullpath; + /* If true, retro_load_game() is guaranteed to provide a valid pathname + * in retro_game_info::path. + * ::data and ::size are both invalid. + * + * If false, ::data and ::size are guaranteed to be valid, but ::path + * might not be valid. + * + * This is typically set to true for libretro implementations that must + * load from file. + * Implementations should strive for setting this to false, as it allows + * the frontend to perform patching, etc. */ + bool need_fullpath; - /* If true, the frontend is not allowed to extract any archives before - * loading the real content. - * Necessary for certain libretro implementations that load games - * from zipped archives. */ - bool block_extract; + /* If true, the frontend is not allowed to extract any archives before + * loading the real content. + * Necessary for certain libretro implementations that load games + * from zipped archives. */ + bool block_extract; }; -struct retro_game_geometry -{ - unsigned base_width; /* Nominal video width of game. */ - unsigned base_height; /* Nominal video height of game. */ - unsigned max_width; /* Maximum possible width of game. */ - unsigned max_height; /* Maximum possible height of game. */ +struct retro_game_geometry { + unsigned base_width; /* Nominal video width of game. */ + unsigned base_height; /* Nominal video height of game. */ + unsigned max_width; /* Maximum possible width of game. */ + unsigned max_height; /* Maximum possible height of game. */ - float aspect_ratio; /* Nominal aspect ratio of game. If - * aspect_ratio is <= 0.0, an aspect ratio - * of base_width / base_height is assumed. - * A frontend could override this setting, - * if desired. */ + float aspect_ratio; /* Nominal aspect ratio of game. If + * aspect_ratio is <= 0.0, an aspect ratio + * of base_width / base_height is assumed. + * A frontend could override this setting, + * if desired. */ }; -struct retro_system_timing -{ - double fps; /* FPS of video content. */ - double sample_rate; /* Sampling rate of audio. */ +struct retro_system_timing { + double fps; /* FPS of video content. */ + double sample_rate; /* Sampling rate of audio. */ }; -struct retro_system_av_info -{ - struct retro_game_geometry geometry; - struct retro_system_timing timing; +struct retro_system_av_info { + struct retro_game_geometry geometry; + struct retro_system_timing timing; }; -struct retro_variable -{ - /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. - * If NULL, obtains the complete environment string if more - * complex parsing is necessary. - * The environment string is formatted as key-value pairs - * delimited by semicolons as so: - * "key1=value1;key2=value2;..." - */ - const char *key; - - /* Value to be obtained. If key does not exist, it is set to NULL. */ - const char *value; +struct retro_variable { + /* Variable to query in RETRO_ENVIRONMENT_GET_VARIABLE. + * If NULL, obtains the complete environment string if more + * complex parsing is necessary. + * The environment string is formatted as key-value pairs + * delimited by semicolons as so: + * "key1=value1;key2=value2;..." + */ + const char *key; + + /* Value to be obtained. If key does not exist, it is set to NULL. */ + const char *value; }; -struct retro_game_info -{ - const char *path; /* Path to game, UTF-8 encoded. - * Usually used as a reference. - * May be NULL if rom was loaded from stdin - * or similar. - * retro_system_info::need_fullpath guaranteed - * that this path is valid. */ - const void *data; /* Memory buffer of loaded game. Will be NULL - * if need_fullpath was set. */ - size_t size; /* Size of memory buffer. */ - const char *meta; /* String of implementation specific meta-data. */ +struct retro_game_info { + const char *path; /* Path to game, UTF-8 encoded. + * Usually used as a reference. + * May be NULL if rom was loaded from stdin + * or similar. + * retro_system_info::need_fullpath guaranteed + * that this path is valid. */ + const void *data; /* Memory buffer of loaded game. Will be NULL + * if need_fullpath was set. */ + size_t size; /* Size of memory buffer. */ + const char *meta; /* String of implementation specific meta-data. */ }; /* Callbacks */ -/* Environment callback. Gives implementations a way of performing +/* Environment callback. Gives implementations a way of performing * uncommon tasks. Extensible. */ typedef bool (*retro_environment_t)(unsigned cmd, void *data); -/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian +/* Render a frame. Pixel format is 15-bit 0RGB1555 native endian * unless changed (see RETRO_ENVIRONMENT_SET_PIXEL_FORMAT). * * Width and height specify dimensions of buffer. * Pitch specifices length in bytes between two lines in buffer. * - * For performance reasons, it is highly recommended to have a frame + * For performance reasons, it is highly recommended to have a frame * that is packed in memory, i.e. pitch == width * byte_per_pixel. - * Certain graphic APIs, such as OpenGL ES, do not like textures + * Certain graphic APIs, such as OpenGL ES, do not like textures * that are not packed in memory. */ -typedef void (*retro_video_refresh_t)(const void *data, unsigned width, - unsigned height, size_t pitch); +typedef void (*retro_video_refresh_t)(const void *data, unsigned width, unsigned height, + size_t pitch); -/* Renders a single audio frame. Should only be used if implementation +/* Renders a single audio frame. Should only be used if implementation * generates a single sample at a time. * Format is signed 16-bit native endian. */ @@ -1811,26 +1788,24 @@ typedef void (*retro_audio_sample_t)(int16_t left, int16_t right); * I.e. int16_t buf[4] = { l, r, l, r }; would be 2 frames. * Only one of the audio callbacks must ever be used. */ -typedef size_t (*retro_audio_sample_batch_t)(const int16_t *data, - size_t frames); +typedef size_t (*retro_audio_sample_batch_t)(const int16_t *data, size_t frames); /* Polls input. */ typedef void (*retro_input_poll_t)(void); -/* Queries for input for player 'port'. device will be masked with +/* Queries for input for player 'port'. device will be masked with * RETRO_DEVICE_MASK. * - * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that + * Specialization of devices such as RETRO_DEVICE_JOYPAD_MULTITAP that * have been set with retro_set_controller_port_device() * will still use the higher level RETRO_DEVICE_JOYPAD to request input. */ -typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device, - unsigned index, unsigned id); +typedef int16_t (*retro_input_state_t)(unsigned port, unsigned device, unsigned index, unsigned id); -/* Sets callbacks. retro_set_environment() is guaranteed to be called +/* Sets callbacks. retro_set_environment() is guaranteed to be called * before retro_init(). * - * The rest of the set_* functions are guaranteed to have been called + * The rest of the set_* functions are guaranteed to have been called * before the first call to retro_run() is made. */ void retro_set_environment(retro_environment_t); void retro_set_video_refresh(retro_video_refresh_t); @@ -1847,26 +1822,26 @@ void retro_deinit(void); * when the API is revised. */ unsigned retro_api_version(void); -/* Gets statically known system info. Pointers provided in *info +/* Gets statically known system info. Pointers provided in *info * must be statically allocated. * Can be called at any time, even before retro_init(). */ void retro_get_system_info(struct retro_system_info *info); /* Gets information about system audio/video timings and geometry. * Can be called only after retro_load_game() has successfully completed. - * NOTE: The implementation of this function might not initialize every + * NOTE: The implementation of this function might not initialize every * variable if needed. - * E.g. geom.aspect_ratio might not be initialized if core doesn't + * E.g. geom.aspect_ratio might not be initialized if core doesn't * desire a particular aspect ratio. */ void retro_get_system_av_info(struct retro_system_av_info *info); /* Sets device to be used for player 'port'. - * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all + * By default, RETRO_DEVICE_JOYPAD is assumed to be plugged into all * available ports. - * Setting a particular device type is not a guarantee that libretro cores - * will only poll input based on that particular device type. It is only a - * hint to the libretro core when a core cannot automatically detect the - * appropriate input device type on its own. It is also relevant when a + * Setting a particular device type is not a guarantee that libretro cores + * will only poll input based on that particular device type. It is only a + * hint to the libretro core when a core cannot automatically detect the + * appropriate input device type on its own. It is also relevant when a * core can change its behavior depending on device type. */ void retro_set_controller_port_device(unsigned port, unsigned device); @@ -1875,18 +1850,18 @@ void retro_reset(void); /* Runs the game for one video frame. * During retro_run(), input_poll callback must be called at least once. - * + * * If a frame is not rendered for reasons where a game "dropped" a frame, - * this still counts as a frame, and retro_run() should explicitly dupe + * this still counts as a frame, and retro_run() should explicitly dupe * a frame if GET_CAN_DUPE returns true. * In this case, the video callback can take a NULL argument for data. */ void retro_run(void); -/* Returns the amount of data the implementation requires to serialize +/* Returns the amount of data the implementation requires to serialize * internal state (save states). - * Between calls to retro_load_game() and retro_unload_game(), the - * returned size is never allowed to be larger than a previous returned + * Between calls to retro_load_game() and retro_unload_game(), the + * returned size is never allowed to be larger than a previous returned * value, to ensure that the frontend can allocate a save state buffer once. */ size_t retro_serialize_size(void); @@ -1904,10 +1879,8 @@ bool retro_load_game(const struct retro_game_info *game); /* Loads a "special" kind of game. Should not be used, * except in extreme cases. */ -bool retro_load_game_special( - unsigned game_type, - const struct retro_game_info *info, size_t num_info -); +bool retro_load_game_special(unsigned game_type, const struct retro_game_info *info, + size_t num_info); /* Unloads a currently loaded game. */ void retro_unload_game(void); diff --git a/src/libretro/msvc/msvc-2003-xbox1/stdint.h b/src/libretro/msvc/msvc-2003-xbox1/stdint.h index 9d8fe7b0..78c4f689 100644 --- a/src/libretro/msvc/msvc-2003-xbox1/stdint.h +++ b/src/libretro/msvc/msvc-2003-xbox1/stdint.h @@ -1,38 +1,38 @@ // ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 +// // Copyright (c) 2006-2008 Alexander Chemeris -// +// // 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 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, +// 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. -// +// /////////////////////////////////////////////////////////////////////////////// #ifndef __RARCH_STDINT_H #define __RARCH_STDINT_H #if _MSC_VER && (_MSC_VER < 1600) -//pre-MSVC 2010 needs an implementation of stdint.h +// pre-MSVC 2010 needs an implementation of stdint.h #if _MSC_VER > 1000 #pragma once @@ -47,20 +47,19 @@ #ifdef __cplusplus extern "C" { #endif -# include +#include #ifdef __cplusplus } #endif // Define _W64 macros to mark types changing their size, like intptr_t. #ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif +#if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 +#define _W64 __w64 +#else +#define _W64 +#endif #endif - // 7.18.1 Integer types @@ -70,179 +69,177 @@ extern "C" { // realize that, e.g. char has the same size as __int8 // so we give up on __intX for them. #if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; +typedef signed char int8_t; +typedef signed short int16_t; +typedef signed int int32_t; +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; #else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; +typedef signed __int8 int8_t; +typedef signed __int16 int16_t; +typedef signed __int32 int32_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; #endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; // 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; +typedef int8_t int_least8_t; +typedef int16_t int_least16_t; +typedef int32_t int_least32_t; +typedef int64_t int_least64_t; +typedef uint8_t uint_least8_t; +typedef uint16_t uint_least16_t; +typedef uint32_t uint_least32_t; +typedef uint64_t uint_least64_t; // 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; +typedef int8_t int_fast8_t; +typedef int16_t int_fast16_t; +typedef int32_t int_fast32_t; +typedef int64_t int_fast64_t; +typedef uint8_t uint_fast8_t; +typedef uint16_t uint_fast16_t; +typedef uint32_t uint_fast32_t; +typedef uint64_t uint_fast64_t; // 7.18.1.4 Integer types capable of holding object pointers #ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; +typedef signed __int64 intptr_t; +typedef unsigned __int64 uintptr_t; +#else // _WIN64 ][ +typedef _W64 signed int intptr_t; +typedef _W64 unsigned int uintptr_t; #endif // _WIN64 ] // 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - +typedef int64_t intmax_t; +typedef uint64_t uintmax_t; // 7.18.2 Limits of specified-width integer types -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and + // footnote 221 at page 259 // 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX +#define INT8_MIN ((int8_t)_I8_MIN) +#define INT8_MAX _I8_MAX +#define INT16_MIN ((int16_t)_I16_MIN) +#define INT16_MAX _I16_MAX +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#define UINT8_MAX _UI8_MAX +#define UINT16_MAX _UI16_MAX +#define UINT32_MAX _UI32_MAX +#define UINT64_MAX _UI64_MAX // 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX +#define INT_LEAST8_MIN INT8_MIN +#define INT_LEAST8_MAX INT8_MAX +#define INT_LEAST16_MIN INT16_MIN +#define INT_LEAST16_MAX INT16_MAX +#define INT_LEAST32_MIN INT32_MIN +#define INT_LEAST32_MAX INT32_MAX +#define INT_LEAST64_MIN INT64_MIN +#define INT_LEAST64_MAX INT64_MAX +#define UINT_LEAST8_MAX UINT8_MAX +#define UINT_LEAST16_MAX UINT16_MAX +#define UINT_LEAST32_MAX UINT32_MAX +#define UINT_LEAST64_MAX UINT64_MAX // 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX +#define INT_FAST8_MIN INT8_MIN +#define INT_FAST8_MAX INT8_MAX +#define INT_FAST16_MIN INT16_MIN +#define INT_FAST16_MAX INT16_MAX +#define INT_FAST32_MIN INT32_MIN +#define INT_FAST32_MAX INT32_MAX +#define INT_FAST64_MIN INT64_MIN +#define INT_FAST64_MAX INT64_MAX +#define UINT_FAST8_MAX UINT8_MAX +#define UINT_FAST16_MAX UINT16_MAX +#define UINT_FAST32_MAX UINT32_MAX +#define UINT_FAST64_MAX UINT64_MAX // 7.18.2.4 Limits of integer types capable of holding object pointers #ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX +#define INTPTR_MIN INT64_MIN +#define INTPTR_MAX INT64_MAX +#define UINTPTR_MAX UINT64_MAX #else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX +#define INTPTR_MIN INT32_MIN +#define INTPTR_MAX INT32_MAX +#define UINTPTR_MAX UINT32_MAX #endif // _WIN64 ] // 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX +#define INTMAX_MIN INT64_MIN +#define INTMAX_MAX INT64_MAX +#define UINTMAX_MAX UINT64_MAX // 7.18.3 Limits of other integer types #ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] +#define PTRDIFF_MIN _I64_MIN +#define PTRDIFF_MAX _I64_MAX +#else // _WIN64 ][ +#define PTRDIFF_MIN _I32_MIN +#define PTRDIFF_MAX _I32_MAX +#endif // _WIN64 ] -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX +#define SIG_ATOMIC_MIN INT_MIN +#define SIG_ATOMIC_MAX INT_MAX #ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] +#ifdef _WIN64 // [ +#define SIZE_MAX _UI64_MAX +#else // _WIN64 ][ +#define SIZE_MAX _UI32_MAX +#endif // _WIN64 ] #endif // SIZE_MAX ] // WCHAR_MIN and WCHAR_MAX are also defined in #ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] +#define WCHAR_MIN 0 +#endif // WCHAR_MIN ] #ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] +#define WCHAR_MAX _UI16_MAX +#endif // WCHAR_MAX ] -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX +#define WINT_MIN 0 +#define WINT_MAX _UI16_MAX #endif // __STDC_LIMIT_MACROS ] - // 7.18.4 Limits of other integer types #if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 // 7.18.4.1 Macros for minimum-width integer constants -#define INT8_C(val) val##i8 +#define INT8_C(val) val##i8 #define INT16_C(val) val##i16 #define INT32_C(val) val##i32 #define INT64_C(val) val##i64 -#define UINT8_C(val) val##ui8 +#define UINT8_C(val) val##ui8 #define UINT16_C(val) val##ui16 #define UINT32_C(val) val##ui32 #define UINT64_C(val) val##ui64 // 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C +#define INTMAX_C INT64_C +#define UINTMAX_C UINT64_C #endif // __STDC_CONSTANT_MACROS ] #else -//sanity for everything else +// sanity for everything else #include #endif diff --git a/src/sdl/debugger.h b/src/sdl/debugger.h index ec4ceab2..be352bf4 100644 --- a/src/sdl/debugger.h +++ b/src/sdl/debugger.h @@ -19,4 +19,4 @@ extern void debuggerMain(); extern void debuggerOutput(const char *, u32); -extern void debuggerSignal(int,int); +extern void debuggerSignal(int, int); diff --git a/src/sdl/expr.cpp.h b/src/sdl/expr.cpp.h index ea22694e..efd39a2b 100644 --- a/src/sdl/expr.cpp.h +++ b/src/sdl/expr.cpp.h @@ -35,18 +35,18 @@ /* Tokens. */ #ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - TOKEN_IDENTIFIER = 258, - TOKEN_DOT = 259, - TOKEN_STAR = 260, - TOKEN_ARROW = 261, - TOKEN_ADDR = 262, - TOKEN_SIZEOF = 263, - TOKEN_NUMBER = 264 - }; +#define YYTOKENTYPE +/* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ +enum yytokentype { + TOKEN_IDENTIFIER = 258, + TOKEN_DOT = 259, + TOKEN_STAR = 260, + TOKEN_ARROW = 261, + TOKEN_ADDR = 262, + TOKEN_SIZEOF = 263, + TOKEN_NUMBER = 264 +}; #endif /* Tokens. */ #define TOKEN_IDENTIFIER 258 @@ -57,15 +57,11 @@ #define TOKEN_SIZEOF 263 #define TOKEN_NUMBER 264 - - - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +#if !defined YYSTYPE && !defined YYSTYPE_IS_DECLARED typedef int YYSTYPE; -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -# define YYSTYPE_IS_TRIVIAL 1 +#define yystype YYSTYPE /* obsolescent; will be withdrawn */ +#define YYSTYPE_IS_DECLARED 1 +#define YYSTYPE_IS_TRIVIAL 1 #endif extern YYSTYPE yylval; - diff --git a/src/sdl/exprNode.h b/src/sdl/exprNode.h index 5b505d72..0c87699f 100644 --- a/src/sdl/exprNode.h +++ b/src/sdl/exprNode.h @@ -18,17 +18,17 @@ // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. struct Node { - Type *type; - u32 location; - u32 objLocation; - LocationType locType; - int value; - int index; - const char *name; - Node *expression; - Member *member; - void (*print)(Node *); - bool (*resolve)(Node *, Function *f, CompileUnit *u); + Type *type; + u32 location; + u32 objLocation; + LocationType locType; + int value; + int index; + const char *name; + Node *expression; + Member *member; + void (*print)(Node *); + bool (*resolve)(Node *, Function *f, CompileUnit *u); }; extern void exprNodeCleanUp(); diff --git a/src/sdl/filters.h b/src/sdl/filters.h index 8c0f8b36..06145704 100644 --- a/src/sdl/filters.h +++ b/src/sdl/filters.h @@ -21,17 +21,39 @@ #include "../System.h" - // - // Screen filters - // +// +// Screen filters +// // List of available filters -enum Filter { kStretch1x, kStretch2x, k2xSaI, kSuper2xSaI, kSuperEagle, kPixelate, - kAdMame2x, kBilinear, kBilinearPlus, kScanlines, kScanlinesTV, - klq2x, khq2x, xbrz2x, kStretch3x, khq3x, xbrz3x, kStretch4x, khq4x, xbrz4x, xbrz5x, xbrz6x, kInvalidFilter }; +enum Filter { + kStretch1x, + kStretch2x, + k2xSaI, + kSuper2xSaI, + kSuperEagle, + kPixelate, + kAdMame2x, + kBilinear, + kBilinearPlus, + kScanlines, + kScanlinesTV, + klq2x, + khq2x, + xbrz2x, + kStretch3x, + khq3x, + xbrz3x, + kStretch4x, + khq4x, + xbrz4x, + xbrz5x, + xbrz6x, + kInvalidFilter +}; // Function pointer type for a filter function -typedef void(*FilterFunc)(u8*, u32, u8*, u8*, u32, int, int); +typedef void (*FilterFunc)(u8 *, u32, u8 *, u8 *, u32, int, int); // Initialize a filter and get the corresponding filter function pointer FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth); @@ -40,22 +62,22 @@ FilterFunc initFilter(const int f, const int colorDepth, const int srcWidth); int getFilterEnlargeFactor(const int f); // Get the display name for a filter -char* getFilterName(const int f); +char *getFilterName(const int f); - // - // Interframe filters - // +// +// Interframe filters +// // List of available IFB filters enum IFBFilter { kIFBNone, kIBMotionBlur, kIBSmart, kInvalidIFBFilter }; // Function pointer type for an IFB filter function -typedef void(*IFBFilterFunc)(u8*, u32, int, int); +typedef void (*IFBFilterFunc)(u8 *, u32, int, int); // Initialize an IFB filter and get the corresponding filter function pointer IFBFilterFunc initIFBFilter(const int f, const int colorDepth); // Get the display name for an IFB filter -char* getIFBFilterName(const IFBFilter f); +char *getIFBFilterName(const IFBFilter f); #endif // VBA_SDL_FILTERS_H diff --git a/src/sdl/getopt.c b/src/sdl/getopt.c index 3d3cfe94..01fd9735 100644 --- a/src/sdl/getopt.c +++ b/src/sdl/getopt.c @@ -4,7 +4,7 @@ before changing it! Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98 - Free Software Foundation, Inc. + Free Software Foundation, Inc. NOTE: This source is derived from an old version taken from the GNU C Library (glibc). @@ -23,23 +23,23 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + /* This tells Alpha OSF/1 not to define a getopt prototype in . Ditto for AIX 3.2 and . */ #ifndef _NO_PROTO -# define _NO_PROTO +#define _NO_PROTO #endif #ifdef HAVE_CONFIG_H -# include +#include #endif #if !defined __STDC__ || !__STDC__ /* This is a separate conditional since some stdc systems reject `defined (const)'. */ -# ifndef const -# define const -# endif +#ifndef const +#define const +#endif #endif #include @@ -54,40 +54,39 @@ #define GETOPT_INTERFACE_VERSION 2 #if !defined _LIBC && defined __GLIBC__ && __GLIBC__ >= 2 -# include -# if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION -# define ELIDE_CODE -# endif +#include +#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION +#define ELIDE_CODE +#endif #endif #ifndef ELIDE_CODE - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ -#ifdef __GNU_LIBRARY__ +#ifdef __GNU_LIBRARY__ /* Don't include stdlib.h for non-GNU C libraries because some of them contain conflicting prototypes for getopt. */ -# include -# include -#endif /* GNU C library. */ +#include +#include +#endif /* GNU C library. */ #ifdef VMS -# include -# if HAVE_STRING_H - 0 -# include -# endif +#include +#if HAVE_STRING_H - 0 +#include +#endif #endif #ifndef _ /* This is for other GNU distributions with internationalized messages. When compiling libc, the _ macro is predefined. */ -# ifdef HAVE_LIBINTL_H -# include -# define _(msgid) gettext (msgid) -# else -# define _(msgid) (msgid) -# endif +#ifdef HAVE_LIBINTL_H +#include +#define _(msgid) gettext(msgid) +#else +#define _(msgid) (msgid) +#endif #endif #ifdef _WIN32 @@ -188,50 +187,44 @@ int optopt = '?'; of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return -1 with `optind' != ARGC. */ -static enum -{ - REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER -} ordering; +static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; /* Value of POSIXLY_CORRECT environment variable. */ static char *posixly_correct; - -#ifdef __GNU_LIBRARY__ + +#ifdef __GNU_LIBRARY__ /* We want to avoid inclusion of string.h with non-GNU libraries because there are many ways it can cause trouble. On some systems, it contains special magic macros that don't work in GCC. */ -# include -# define my_index strchr +#include +#define my_index strchr #else -# if HAVE_STRING_H -# include -# else -# if HAVE_STRINGS_H -# include -# endif -# endif +#if HAVE_STRING_H +#include +#else +#if HAVE_STRINGS_H +#include +#endif +#endif /* Avoid depending on library functions or files whose names are inconsistent. */ #ifndef getenv -extern char *getenv (); +extern char *getenv(); #endif -static char * -my_index (str, chr) - const char *str; - int chr; +static char *my_index(str, chr) const char *str; +int chr; { - while (*str) - { - if (*str == chr) - return (char *) str; - str++; - } - return 0; + while (*str) { + if (*str == chr) + return (char *)str; + str++; + } + return 0; } /* If using GCC, we can safely declare strlen this way. @@ -239,15 +232,15 @@ my_index (str, chr) #ifdef __GNUC__ /* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h. That was relevant to code that was here before. */ -# if (!defined __STDC__ || !__STDC__) && !defined strlen +#if (!defined __STDC__ || !__STDC__) && !defined strlen /* gcc with -traditional declares the built-in strlen to return int, and has done so at least since version 2.4.5. -- rms. */ -extern int strlen (const char *); -# endif /* not __STDC__ */ +extern int strlen(const char *); +#endif /* not __STDC__ */ #endif /* __GNUC__ */ #endif /* not __GNU_LIBRARY__ */ - + /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have @@ -273,29 +266,26 @@ static char *const *original_argv; /* Make sure the environment variable bash 2.0 puts in the environment is valid for the getopt call we must make sure that the ARGV passed to getopt is that one passed to the process. */ -static void -__attribute__ ((unused)) -store_args_and_env (int argc, char *const *argv) +static void __attribute__((unused)) store_args_and_env(int argc, char *const *argv) { - /* XXX This is no good solution. We should rather copy the args so - that we can compare them later. But we must not use malloc(3). */ - original_argc = argc; - original_argv = argv; + /* XXX This is no good solution. We should rather copy the args so + that we can compare them later. But we must not use malloc(3). */ + original_argc = argc; + original_argv = argv; } -# ifdef text_set_element -text_set_element (__libc_subinit, store_args_and_env); -# endif /* text_set_element */ +#ifdef text_set_element +text_set_element(__libc_subinit, store_args_and_env); +#endif /* text_set_element */ -# define SWAP_FLAGS(ch1, ch2) \ - if (nonoption_flags_len > 0) \ - { \ - char __tmp = __getopt_nonoption_flags[ch1]; \ - __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ - __getopt_nonoption_flags[ch2] = __tmp; \ - } -#else /* !_LIBC */ -# define SWAP_FLAGS(ch1, ch2) -#endif /* _LIBC */ +#define SWAP_FLAGS(ch1, ch2) \ + if (nonoption_flags_len > 0) { \ + char __tmp = __getopt_nonoption_flags[ch1]; \ + __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \ + __getopt_nonoption_flags[ch2] = __tmp; \ + } +#else /* !_LIBC */ +#define SWAP_FLAGS(ch1, ch2) +#endif /* _LIBC */ /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) @@ -307,160 +297,140 @@ text_set_element (__libc_subinit, store_args_and_env); the new indices of the non-options in ARGV after they are moved. */ #if defined __STDC__ && __STDC__ -static void exchange (char **); +static void exchange(char **); #endif -static void -exchange (argv) - char **argv; +static void exchange(argv) char **argv; { - int bottom = first_nonopt; - int middle = last_nonopt; - int top = optind; - char *tem; + int bottom = first_nonopt; + int middle = last_nonopt; + int top = optind; + char *tem; - /* Exchange the shorter segment with the far end of the longer segment. - That puts the shorter segment into the right place. - It leaves the longer segment in the right place overall, - but it consists of two parts that need to be swapped next. */ +/* Exchange the shorter segment with the far end of the longer segment. + That puts the shorter segment into the right place. + It leaves the longer segment in the right place overall, + but it consists of two parts that need to be swapped next. */ #ifdef _LIBC - /* First make sure the handling of the `__getopt_nonoption_flags' - string can work normally. Our top argument must be in the range - of the string. */ - if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) - { - /* We must extend the array. The user plays games with us and - presents new arguments. */ - char *new_str = malloc (top + 1); - if (new_str == NULL) - nonoption_flags_len = nonoption_flags_max_len = 0; - else - { - memset (__mempcpy (new_str, __getopt_nonoption_flags, - nonoption_flags_max_len), - '\0', top + 1 - nonoption_flags_max_len); - nonoption_flags_max_len = top + 1; - __getopt_nonoption_flags = new_str; - } - } + /* First make sure the handling of the `__getopt_nonoption_flags' + string can work normally. Our top argument must be in the range + of the string. */ + if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len) { + /* We must extend the array. The user plays games with us and + presents new arguments. */ + char *new_str = malloc(top + 1); + if (new_str == NULL) + nonoption_flags_len = nonoption_flags_max_len = 0; + else { + memset(__mempcpy(new_str, + __getopt_nonoption_flags, + nonoption_flags_max_len), + '\0', + top + 1 - nonoption_flags_max_len); + nonoption_flags_max_len = top + 1; + __getopt_nonoption_flags = new_str; + } + } #endif - while (top > middle && middle > bottom) - { - if (top - middle > middle - bottom) - { - /* Bottom segment is the short one. */ - int len = middle - bottom; - register int i; + while (top > middle && middle > bottom) { + if (top - middle > middle - bottom) { + /* Bottom segment is the short one. */ + int len = middle - bottom; + register int i; - /* Swap it with the top part of the top segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[top - (middle - bottom) + i]; - argv[top - (middle - bottom) + i] = tem; - SWAP_FLAGS (bottom + i, top - (middle - bottom) + i); - } - /* Exclude the moved bottom segment from further swapping. */ - top -= len; - } - else - { - /* Top segment is the short one. */ - int len = top - middle; - register int i; + /* Swap it with the top part of the top segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = argv[top - (middle - bottom) + i]; + argv[top - (middle - bottom) + i] = tem; + SWAP_FLAGS(bottom + i, top - (middle - bottom) + i); + } + /* Exclude the moved bottom segment from further swapping. */ + top -= len; + } else { + /* Top segment is the short one. */ + int len = top - middle; + register int i; - /* Swap it with the bottom part of the bottom segment. */ - for (i = 0; i < len; i++) - { - tem = argv[bottom + i]; - argv[bottom + i] = argv[middle + i]; - argv[middle + i] = tem; - SWAP_FLAGS (bottom + i, middle + i); - } - /* Exclude the moved top segment from further swapping. */ - bottom += len; - } - } + /* Swap it with the bottom part of the bottom segment. */ + for (i = 0; i < len; i++) { + tem = argv[bottom + i]; + argv[bottom + i] = argv[middle + i]; + argv[middle + i] = tem; + SWAP_FLAGS(bottom + i, middle + i); + } + /* Exclude the moved top segment from further swapping. */ + bottom += len; + } + } - /* Update records for the slots the non-options now occupy. */ + /* Update records for the slots the non-options now occupy. */ - first_nonopt += (optind - last_nonopt); - last_nonopt = optind; + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; } /* Initialize the internal data when the first call is made. */ #if defined __STDC__ && __STDC__ -static const char *_getopt_initialize (int, char *const *, const char *); +static const char *_getopt_initialize(int, char *const *, const char *); #endif -static const char * -_getopt_initialize (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; +static const char *_getopt_initialize(argc, argv, optstring) int argc; +char *const *argv; +const char *optstring; { - /* Start processing options with ARGV-element 1 (since ARGV-element 0 - is the program name); the sequence of previously skipped - non-option ARGV-elements is empty. */ + /* Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ - first_nonopt = last_nonopt = optind; + first_nonopt = last_nonopt = optind; - nextchar = NULL; + nextchar = NULL; - posixly_correct = getenv ("POSIXLY_CORRECT"); + posixly_correct = getenv("POSIXLY_CORRECT"); - /* Determine how to handle the ordering of options and nonoptions. */ + /* Determine how to handle the ordering of options and nonoptions. */ - if (optstring[0] == '-') - { - ordering = RETURN_IN_ORDER; - ++optstring; - } - else if (optstring[0] == '+') - { - ordering = REQUIRE_ORDER; - ++optstring; - } - else if (posixly_correct != NULL) - ordering = REQUIRE_ORDER; - else - ordering = PERMUTE; + if (optstring[0] == '-') { + ordering = RETURN_IN_ORDER; + ++optstring; + } else if (optstring[0] == '+') { + ordering = REQUIRE_ORDER; + ++optstring; + } else if (posixly_correct != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; #ifdef _LIBC - if (posixly_correct == NULL - && argc == original_argc && argv == original_argv) - { - if (nonoption_flags_max_len == 0) - { - if (__getopt_nonoption_flags == NULL - || __getopt_nonoption_flags[0] == '\0') - nonoption_flags_max_len = -1; - else - { - const char *orig_str = __getopt_nonoption_flags; - int len = nonoption_flags_max_len = strlen (orig_str); - if (nonoption_flags_max_len < argc) - nonoption_flags_max_len = argc; - __getopt_nonoption_flags = - (char *) malloc (nonoption_flags_max_len); - if (__getopt_nonoption_flags == NULL) - nonoption_flags_max_len = -1; - else - memset (__mempcpy (__getopt_nonoption_flags, orig_str, len), - '\0', nonoption_flags_max_len - len); - } - } - nonoption_flags_len = nonoption_flags_max_len; - } - else - nonoption_flags_len = 0; + if (posixly_correct == NULL && argc == original_argc && argv == original_argv) { + if (nonoption_flags_max_len == 0) { + if (__getopt_nonoption_flags == NULL || __getopt_nonoption_flags[0] == '\0') + nonoption_flags_max_len = -1; + else { + const char *orig_str = __getopt_nonoption_flags; + int len = nonoption_flags_max_len = strlen(orig_str); + if (nonoption_flags_max_len < argc) + nonoption_flags_max_len = argc; + __getopt_nonoption_flags = (char *)malloc(nonoption_flags_max_len); + if (__getopt_nonoption_flags == NULL) + nonoption_flags_max_len = -1; + else + memset(__mempcpy(__getopt_nonoption_flags, orig_str, len), + '\0', + nonoption_flags_max_len - len); + } + } + nonoption_flags_len = nonoption_flags_max_len; + } else + nonoption_flags_len = 0; #endif - return optstring; + return optstring; } - + /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. @@ -517,544 +487,504 @@ _getopt_initialize (argc, argv, optstring) If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ -int -_getopt_internal (argc, argv, optstring, longopts, longind, long_only) - int argc; - char *const *argv; - const char *optstring; - const struct option *longopts; - int *longind; - int long_only; +int _getopt_internal(argc, argv, optstring, longopts, longind, long_only) int argc; +char *const *argv; +const char *optstring; +const struct option *longopts; +int *longind; +int long_only; { - optarg = NULL; + optarg = NULL; - if (optind == 0 || !__getopt_initialized) - { - if (optind == 0) - optind = 1; /* Don't scan ARGV[0], the program name. */ - optstring = _getopt_initialize (argc, argv, optstring); - __getopt_initialized = 1; - } + if (optind == 0 || !__getopt_initialized) { + if (optind == 0) + optind = 1; /* Don't scan ARGV[0], the program name. */ + optstring = _getopt_initialize(argc, argv, optstring); + __getopt_initialized = 1; + } - /* Test whether ARGV[optind] points to a non-option argument. - Either it does not have option syntax, or there is an environment flag - from the shell indicating it is not an option. The later information - is only used when the used in the GNU libc. */ +/* Test whether ARGV[optind] points to a non-option argument. + Either it does not have option syntax, or there is an environment flag + from the shell indicating it is not an option. The later information + is only used when the used in the GNU libc. */ #ifdef _LIBC -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \ - || (optind < nonoption_flags_len \ - && __getopt_nonoption_flags[optind] == '1')) +#define NONOPTION_P \ + (argv[optind][0] != '-' || argv[optind][1] == '\0' || \ + (optind < nonoption_flags_len && __getopt_nonoption_flags[optind] == '1')) #else -# define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') +#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0') #endif - if (nextchar == NULL || *nextchar == '\0') - { - /* Advance to the next ARGV-element. */ + if (nextchar == NULL || *nextchar == '\0') { + /* Advance to the next ARGV-element. */ - /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been - moved back by the user (who may also have changed the arguments). */ - if (last_nonopt > optind) - last_nonopt = optind; - if (first_nonopt > optind) - first_nonopt = optind; + /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been + moved back by the user (who may also have changed the arguments). */ + if (last_nonopt > optind) + last_nonopt = optind; + if (first_nonopt > optind) + first_nonopt = optind; - if (ordering == PERMUTE) - { - /* If we have just processed some options following some non-options, - exchange them so that the options come first. */ + if (ordering == PERMUTE) { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (last_nonopt != optind) - first_nonopt = optind; + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange((char **)argv); + else if (last_nonopt != optind) + first_nonopt = optind; - /* Skip any additional non-options - and extend the range of non-options previously skipped. */ + /* Skip any additional non-options + and extend the range of non-options previously skipped. */ - while (optind < argc && NONOPTION_P) - optind++; - last_nonopt = optind; - } + while (optind < argc && NONOPTION_P) + optind++; + last_nonopt = optind; + } - /* The special ARGV-element `--' means premature end of options. - Skip it like a null option, - then exchange with previous non-options as if it were an option, - then skip everything else like a non-option. */ + /* The special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ - if (optind != argc && !strcmp (argv[optind], "--")) - { - optind++; + if (optind != argc && !strcmp(argv[optind], "--")) { + optind++; - if (first_nonopt != last_nonopt && last_nonopt != optind) - exchange ((char **) argv); - else if (first_nonopt == last_nonopt) - first_nonopt = optind; - last_nonopt = argc; + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange((char **)argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; - optind = argc; - } + optind = argc; + } - /* If we have done all the ARGV-elements, stop the scan - and back over any non-options that we skipped and permuted. */ + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ - if (optind == argc) - { - /* Set the next-arg-index to point at the non-options - that we previously skipped, so the caller will digest them. */ - if (first_nonopt != last_nonopt) - optind = first_nonopt; - return -1; - } + if (optind == argc) { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } - /* If we have come to a non-option and did not permute it, - either stop the scan or describe it to the caller and pass it by. */ + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ - if (NONOPTION_P) - { - if (ordering == REQUIRE_ORDER) - return -1; - optarg = argv[optind++]; - return 1; - } + if (NONOPTION_P) { + if (ordering == REQUIRE_ORDER) + return -1; + optarg = argv[optind++]; + return 1; + } - /* We have found another option-ARGV-element. - Skip the initial punctuation. */ + /* We have found another option-ARGV-element. + Skip the initial punctuation. */ - nextchar = (argv[optind] + 1 - + (longopts != NULL && argv[optind][1] == '-')); - } + nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); + } - /* Decode the current option-ARGV-element. */ + /* Decode the current option-ARGV-element. */ - /* Check whether the ARGV-element is a long option. + /* Check whether the ARGV-element is a long option. - If long_only and the ARGV-element has the form "-f", where f is - a valid short option, don't consider it an abbreviated form of - a long option that starts with f. Otherwise there would be no - way to give the -f short option. + If long_only and the ARGV-element has the form "-f", where f is + a valid short option, don't consider it an abbreviated form of + a long option that starts with f. Otherwise there would be no + way to give the -f short option. - On the other hand, if there's a long option "fubar" and - the ARGV-element is "-fu", do consider that an abbreviation of - the long option, just like "--fu", and not "-f" with arg "u". + On the other hand, if there's a long option "fubar" and + the ARGV-element is "-fu", do consider that an abbreviation of + the long option, just like "--fu", and not "-f" with arg "u". - This distinction seems to be the most useful approach. */ + This distinction seems to be the most useful approach. */ - if (longopts != NULL - && (argv[optind][1] == '-' - || (long_only && (argv[optind][2] || !my_index (optstring, argv[optind][1]))))) - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = -1; - int option_index; + if (longopts != NULL && + (argv[optind][1] == '-' || + (long_only && (argv[optind][2] || !my_index(optstring, argv[optind][1]))))) { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = -1; + int option_index; - for (nameend = nextchar; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; + for (nameend = nextchar; *nameend && *nameend != '='; nameend++) + /* Do nothing. */; - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) - == (unsigned int) strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, nextchar, nameend - nextchar)) { + if ((unsigned int)(nameend - nextchar) == + (unsigned int)strlen(p->name)) { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } else if (pfound == NULL) { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } else + /* Second or later nonexact match found. */ + ambig = 1; + } - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `%s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - optopt = 0; - return '?'; - } + if (ambig && !exact) { + if (opterr) + fprintf(stderr, + _("%s: option `%s' is ambiguous\n"), + argv[0], + argv[optind]); + nextchar += strlen(nextchar); + optind++; + optopt = 0; + return '?'; + } - if (pfound != NULL) - { - option_index = indfound; - optind++; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - { - if (argv[optind - 1][1] == '-') - /* --option */ - fprintf (stderr, - _("%s: option `--%s' doesn't allow an argument\n"), - argv[0], pfound->name); - else - /* +option or -option */ - fprintf (stderr, - _("%s: option `%c%s' doesn't allow an argument\n"), - argv[0], argv[optind - 1][0], pfound->name); + if (pfound != NULL) { + option_index = indfound; + optind++; + if (*nameend) { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else { + if (opterr) { + if (argv[optind - 1][1] == '-') + /* --option */ + fprintf(stderr, + _("%s: option `--%s' doesn't allow " + "an argument\n"), + argv[0], + pfound->name); + else + /* +option or -option */ + fprintf(stderr, + _("%s: option `%c%s' doesn't allow " + "an argument\n"), + argv[0], + argv[optind - 1][0], + pfound->name); - nextchar += strlen (nextchar); + nextchar += strlen(nextchar); - optopt = pfound->val; - return '?'; - } - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - optopt = pfound->val; - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } + optopt = pfound->val; + return '?'; + } + } + } else if (pfound->has_arg == 1) { + if (optind < argc) + optarg = argv[optind++]; + else { + if (opterr) + fprintf(stderr, + _("%s: option `%s' requires an argument\n"), + argv[0], + argv[optind - 1]); + nextchar += strlen(nextchar); + optopt = pfound->val; + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen(nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } - /* Can't find it as a long option. If this is not getopt_long_only, - or the option starts with '--' or is not a valid short - option, then it's an error. - Otherwise interpret it as a short option. */ - if (!long_only || argv[optind][1] == '-' - || my_index (optstring, *nextchar) == NULL) - { - if (opterr) - { - if (argv[optind][1] == '-') - /* --option */ - fprintf (stderr, _("%s: unrecognized option `--%s'\n"), - argv[0], nextchar); - else - /* +option or -option */ - fprintf (stderr, _("%s: unrecognized option `%c%s'\n"), - argv[0], argv[optind][0], nextchar); - } - nextchar = (char *) ""; - optind++; - optopt = 0; - return '?'; - } - } + /* Can't find it as a long option. If this is not getopt_long_only, + or the option starts with '--' or is not a valid short + option, then it's an error. + Otherwise interpret it as a short option. */ + if (!long_only || argv[optind][1] == '-' || + my_index(optstring, *nextchar) == NULL) { + if (opterr) { + if (argv[optind][1] == '-') + /* --option */ + fprintf(stderr, + _("%s: unrecognized option `--%s'\n"), + argv[0], + nextchar); + else + /* +option or -option */ + fprintf(stderr, + _("%s: unrecognized option `%c%s'\n"), + argv[0], + argv[optind][0], + nextchar); + } + nextchar = (char *)""; + optind++; + optopt = 0; + return '?'; + } + } - /* Look at and handle the next short option-character. */ + /* Look at and handle the next short option-character. */ - { - char c = *nextchar++; - char *temp = my_index (optstring, c); + { + char c = *nextchar++; + char *temp = my_index(optstring, c); - /* Increment `optind' when we start to process its last character. */ - if (*nextchar == '\0') - ++optind; + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; - if (temp == NULL || c == ':') - { - if (opterr) - { - if (posixly_correct) - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: illegal option -- %c\n"), - argv[0], c); - else - fprintf (stderr, _("%s: invalid option -- %c\n"), - argv[0], c); - } - optopt = c; - return '?'; - } - /* Convenience. Treat POSIX -W foo same as long option --foo */ - if (temp[0] == 'W' && temp[1] == ';') - { - char *nameend; - const struct option *p; - const struct option *pfound = NULL; - int exact = 0; - int ambig = 0; - int indfound = 0; - int option_index; + if (temp == NULL || c == ':') { + if (opterr) { + if (posixly_correct) + /* 1003.2 specifies the format of this message. */ + fprintf(stderr, + _("%s: illegal option -- %c\n"), + argv[0], + c); + else + fprintf(stderr, + _("%s: invalid option -- %c\n"), + argv[0], + c); + } + optopt = c; + return '?'; + } + /* Convenience. Treat POSIX -W foo same as long option --foo */ + if (temp[0] == 'W' && temp[1] == ';') { + char *nameend; + const struct option *p; + const struct option *pfound = NULL; + int exact = 0; + int ambig = 0; + int indfound = 0; + int option_index; - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - return c; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; + /* This is an option that requires an argument. */ + if (*nextchar != '\0') { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } else if (optind == argc) { + if (opterr) { + /* 1003.2 specifies the format of this message. */ + fprintf(stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], + c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + return c; + } else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; - /* optarg is now the argument, see if it's in the - table of longopts. */ + /* optarg is now the argument, see if it's in the + table of longopts. */ - for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) - /* Do nothing. */ ; + for (nextchar = nameend = optarg; *nameend && *nameend != '='; nameend++) + /* Do nothing. */; - /* Test all long options for either exact match - or abbreviated matches. */ - for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (!strncmp (p->name, nextchar, nameend - nextchar)) - { - if ((unsigned int) (nameend - nextchar) == strlen (p->name)) - { - /* Exact match found. */ - pfound = p; - indfound = option_index; - exact = 1; - break; - } - else if (pfound == NULL) - { - /* First nonexact match found. */ - pfound = p; - indfound = option_index; - } - else - /* Second or later nonexact match found. */ - ambig = 1; - } - if (ambig && !exact) - { - if (opterr) - fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"), - argv[0], argv[optind]); - nextchar += strlen (nextchar); - optind++; - return '?'; - } - if (pfound != NULL) - { - option_index = indfound; - if (*nameend) - { - /* Don't test has_arg with >, because some C compilers don't - allow it to be used on enums. */ - if (pfound->has_arg) - optarg = nameend + 1; - else - { - if (opterr) - fprintf (stderr, _("\ + /* Test all long options for either exact match + or abbreviated matches. */ + for (p = longopts, option_index = 0; p->name; p++, option_index++) + if (!strncmp(p->name, nextchar, nameend - nextchar)) { + if ((unsigned int)(nameend - nextchar) == strlen(p->name)) { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } else if (pfound == NULL) { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } else + /* Second or later nonexact match found. */ + ambig = 1; + } + if (ambig && !exact) { + if (opterr) + fprintf(stderr, + _("%s: option `-W %s' is ambiguous\n"), + argv[0], + argv[optind]); + nextchar += strlen(nextchar); + optind++; + return '?'; + } + if (pfound != NULL) { + option_index = indfound; + if (*nameend) { + /* Don't test has_arg with >, because some C compilers don't + allow it to be used on enums. */ + if (pfound->has_arg) + optarg = nameend + 1; + else { + if (opterr) + fprintf(stderr, + _("\ %s: option `-W %s' doesn't allow an argument\n"), - argv[0], pfound->name); + argv[0], + pfound->name); - nextchar += strlen (nextchar); - return '?'; - } - } - else if (pfound->has_arg == 1) - { - if (optind < argc) - optarg = argv[optind++]; - else - { - if (opterr) - fprintf (stderr, - _("%s: option `%s' requires an argument\n"), - argv[0], argv[optind - 1]); - nextchar += strlen (nextchar); - return optstring[0] == ':' ? ':' : '?'; - } - } - nextchar += strlen (nextchar); - if (longind != NULL) - *longind = option_index; - if (pfound->flag) - { - *(pfound->flag) = pfound->val; - return 0; - } - return pfound->val; - } - nextchar = NULL; - return 'W'; /* Let the application handle it. */ - } - if (temp[1] == ':') - { - if (temp[2] == ':') - { - /* This is an option that accepts an argument optionally. */ - if (*nextchar != '\0') - { - optarg = nextchar; - optind++; - } - else - optarg = NULL; - nextchar = NULL; - } - else - { - /* This is an option that requires an argument. */ - if (*nextchar != '\0') - { - optarg = nextchar; - /* If we end this ARGV-element by taking the rest as an arg, - we must advance to the next element now. */ - optind++; - } - else if (optind == argc) - { - if (opterr) - { - /* 1003.2 specifies the format of this message. */ - fprintf (stderr, - _("%s: option requires an argument -- %c\n"), - argv[0], c); - } - optopt = c; - if (optstring[0] == ':') - c = ':'; - else - c = '?'; - } - else - /* We already incremented `optind' once; - increment it again when taking next ARGV-elt as argument. */ - optarg = argv[optind++]; - nextchar = NULL; - } - } - return c; - } + nextchar += strlen(nextchar); + return '?'; + } + } else if (pfound->has_arg == 1) { + if (optind < argc) + optarg = argv[optind++]; + else { + if (opterr) + fprintf(stderr, + _("%s: option `%s' requires an " + "argument\n"), + argv[0], + argv[optind - 1]); + nextchar += strlen(nextchar); + return optstring[0] == ':' ? ':' : '?'; + } + } + nextchar += strlen(nextchar); + if (longind != NULL) + *longind = option_index; + if (pfound->flag) { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + nextchar = NULL; + return 'W'; /* Let the application handle it. */ + } + if (temp[1] == ':') { + if (temp[2] == ':') { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != '\0') { + optarg = nextchar; + optind++; + } else + optarg = NULL; + nextchar = NULL; + } else { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } else if (optind == argc) { + if (opterr) { + /* 1003.2 specifies the format of this message. */ + fprintf( + stderr, + _("%s: option requires an argument -- %c\n"), + argv[0], + c); + } + optopt = c; + if (optstring[0] == ':') + c = ':'; + else + c = '?'; + } else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. + */ + optarg = argv[optind++]; + nextchar = NULL; + } + } + return c; + } } -int -getopt (argc, argv, optstring) - int argc; - char *const *argv; - const char *optstring; +int getopt(argc, argv, optstring) int argc; +char *const *argv; +const char *optstring; { - return _getopt_internal (argc, argv, optstring, - (const struct option *) 0, - (int *) 0, - 0); + return _getopt_internal(argc, argv, optstring, (const struct option *)0, (int *)0, 0); } -#endif /* Not ELIDE_CODE. */ - +#endif /* Not ELIDE_CODE. */ + #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ -int -main (argc, argv) - int argc; - char **argv; +int main(argc, argv) int argc; +char **argv; { - int c; - int digit_optind = 0; + int c; + int digit_optind = 0; - while (1) - { - int this_option_optind = optind ? optind : 1; + while (1) { + int this_option_optind = optind ? optind : 1; - c = getopt (argc, argv, "abc:d:0123456789"); - if (c == -1) - break; + c = getopt(argc, argv, "abc:d:0123456789"); + if (c == -1) + break; - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; + switch (c) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf("option %c\n", c); + break; - case 'a': - printf ("option a\n"); - break; + case 'a': + printf("option a\n"); + break; - case 'b': - printf ("option b\n"); - break; + case 'b': + printf("option b\n"); + break; - case 'c': - printf ("option c with value `%s'\n", optarg); - break; + case 'c': + printf("option c with value `%s'\n", optarg); + break; - case '?': - break; + case '?': + break; - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } + default: + printf("?? getopt returned character code 0%o ??\n", c); + } + } - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } + if (optind < argc) { + printf("non-option ARGV-elements: "); + while (optind < argc) + printf("%s ", argv[optind++]); + printf("\n"); + } - exit (0); + exit(0); } #endif /* TEST */ diff --git a/src/sdl/getopt.h b/src/sdl/getopt.h index cb5feba1..2e4235a8 100644 --- a/src/sdl/getopt.h +++ b/src/sdl/getopt.h @@ -23,7 +23,7 @@ #ifndef _GETOPT_H #define _GETOPT_H 1 -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif @@ -79,62 +79,58 @@ extern int optopt; one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ -struct option -{ -#if defined (__STDC__) && __STDC__ - const char *name; +struct option { +#if defined(__STDC__) && __STDC__ + const char *name; #else - char *name; + char *name; #endif - /* has_arg can't be an enum because some compilers complain about - type mismatches in all the code that assumes it is an int. */ - int has_arg; - int *flag; - int val; + /* has_arg can't be an enum because some compilers complain about + type mismatches in all the code that assumes it is an int. */ + int has_arg; + int *flag; + int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ -#define no_argument 0 -#define required_argument 1 -#define optional_argument 2 +#define no_argument 0 +#define required_argument 1 +#define optional_argument 2 -#if defined (__STDC__) && __STDC__ +#if defined(__STDC__) && __STDC__ /* HAVE_DECL_* is a three-state macro: undefined, 0 or 1. If it is undefined, we haven't run the autoconf check so provide the declaration without arguments. If it is 0, we checked and failed to find the declaration so provide a fully prototyped one. If it is 1, we found it so don't provide any declaration at all. */ -#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT) +#if defined(__GNU_LIBRARY__) || (defined(HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT) /* Many other libraries have conflicting prototypes for getopt, with differences in the consts, in stdlib.h. To avoid compilation errors, only prototype getopt for the GNU C library. */ -extern int getopt (int argc, char *const *argv, const char *shortopts); +extern int getopt(int argc, char *const *argv, const char *shortopts); #else /* not __GNU_LIBRARY__ */ -# if !defined (HAVE_DECL_GETOPT) -extern int getopt (); -# endif +#if !defined(HAVE_DECL_GETOPT) +extern int getopt(); +#endif #endif /* __GNU_LIBRARY__ */ -extern int getopt_long (int argc, char *const *argv, const char *shortopts, - const struct option *longopts, int *longind); -extern int getopt_long_only (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind); +extern int getopt_long(int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ -extern int _getopt_internal (int argc, char *const *argv, - const char *shortopts, - const struct option *longopts, int *longind, - int long_only); -#else /* not __STDC__ */ -extern int getopt (); -extern int getopt_long (); -extern int getopt_long_only (); +extern int _getopt_internal(int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind, int long_only); +#else /* not __STDC__ */ +extern int getopt(); +extern int getopt_long(); +extern int getopt_long_only(); -extern int _getopt_internal (); +extern int _getopt_internal(); #endif /* __STDC__ */ -#ifdef __cplusplus +#ifdef __cplusplus } #endif diff --git a/src/sdl/getopt1.c b/src/sdl/getopt1.c index a3637c2d..31933ec0 100644 --- a/src/sdl/getopt1.c +++ b/src/sdl/getopt1.c @@ -19,7 +19,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + #ifdef HAVE_CONFIG_H #include #endif @@ -54,26 +54,23 @@ #ifndef ELIDE_CODE - /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #include #endif -#ifndef NULL +#ifndef NULL #define NULL 0 #endif -int -getopt_long (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; +int getopt_long(argc, argv, options, long_options, opt_index) int argc; +char *const *argv; +const char *options; +const struct option *long_options; +int *opt_index; { - return _getopt_internal (argc, argv, options, long_options, opt_index, 0); + return _getopt_internal(argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. @@ -81,110 +78,98 @@ getopt_long (argc, argv, options, long_options, opt_index) but does match a short option, it is parsed as a short option instead. */ -int -getopt_long_only (argc, argv, options, long_options, opt_index) - int argc; - char *const *argv; - const char *options; - const struct option *long_options; - int *opt_index; +int getopt_long_only(argc, argv, options, long_options, opt_index) int argc; +char *const *argv; +const char *options; +const struct option *long_options; +int *opt_index; { - return _getopt_internal (argc, argv, options, long_options, opt_index, 1); + return _getopt_internal(argc, argv, options, long_options, opt_index, 1); } +#endif /* Not ELIDE_CODE. */ -#endif /* Not ELIDE_CODE. */ - #ifdef TEST #include -int -main (argc, argv) - int argc; - char **argv; +int main(argc, argv) int argc; +char **argv; { - int c; - int digit_optind = 0; + int c; + int digit_optind = 0; - while (1) - { - int this_option_optind = optind ? optind : 1; - int option_index = 0; - static struct option long_options[] = - { - {"add", 1, 0, 0}, - {"append", 0, 0, 0}, - {"delete", 1, 0, 0}, - {"verbose", 0, 0, 0}, - {"create", 0, 0, 0}, - {"file", 1, 0, 0}, - {0, 0, 0, 0} - }; + while (1) { + int this_option_optind = optind ? optind : 1; + int option_index = 0; + static struct option long_options[] = { { "add", 1, 0, 0 }, + { "append", 0, 0, 0 }, + { "delete", 1, 0, 0 }, + { "verbose", 0, 0, 0 }, + { "create", 0, 0, 0 }, + { "file", 1, 0, 0 }, + { 0, 0, 0, 0 } }; - c = getopt_long (argc, argv, "abc:d:0123456789", - long_options, &option_index); - if (c == -1) - break; + c = getopt_long(argc, argv, "abc:d:0123456789", long_options, &option_index); + if (c == -1) + break; - switch (c) - { - case 0: - printf ("option %s", long_options[option_index].name); - if (optarg) - printf (" with arg %s", optarg); - printf ("\n"); - break; + switch (c) { + case 0: + printf("option %s", long_options[option_index].name); + if (optarg) + printf(" with arg %s", optarg); + printf("\n"); + break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (digit_optind != 0 && digit_optind != this_option_optind) - printf ("digits occur in two different argv-elements.\n"); - digit_optind = this_option_optind; - printf ("option %c\n", c); - break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf("option %c\n", c); + break; - case 'a': - printf ("option a\n"); - break; + case 'a': + printf("option a\n"); + break; - case 'b': - printf ("option b\n"); - break; + case 'b': + printf("option b\n"); + break; - case 'c': - printf ("option c with value `%s'\n", optarg); - break; + case 'c': + printf("option c with value `%s'\n", optarg); + break; - case 'd': - printf ("option d with value `%s'\n", optarg); - break; + case 'd': + printf("option d with value `%s'\n", optarg); + break; - case '?': - break; + case '?': + break; - default: - printf ("?? getopt returned character code 0%o ??\n", c); - } - } + default: + printf("?? getopt returned character code 0%o ??\n", c); + } + } - if (optind < argc) - { - printf ("non-option ARGV-elements: "); - while (optind < argc) - printf ("%s ", argv[optind++]); - printf ("\n"); - } + if (optind < argc) { + printf("non-option ARGV-elements: "); + while (optind < argc) + printf("%s ", argv[optind++]); + printf("\n"); + } - exit (0); + exit(0); } #endif /* TEST */ diff --git a/src/sdl/inputSDL.h b/src/sdl/inputSDL.h index cf930724..5d5764f1 100644 --- a/src/sdl/inputSDL.h +++ b/src/sdl/inputSDL.h @@ -21,30 +21,23 @@ #include enum EKey { - KEY_LEFT, - KEY_RIGHT, - KEY_UP, - KEY_DOWN, - KEY_BUTTON_A, - KEY_BUTTON_B, - KEY_BUTTON_START, - KEY_BUTTON_SELECT, - KEY_BUTTON_L, - KEY_BUTTON_R, - KEY_BUTTON_SPEED, - KEY_BUTTON_CAPTURE, - KEY_BUTTON_AUTO_A, - KEY_BUTTON_AUTO_B + KEY_LEFT, + KEY_RIGHT, + KEY_UP, + KEY_DOWN, + KEY_BUTTON_A, + KEY_BUTTON_B, + KEY_BUTTON_START, + KEY_BUTTON_SELECT, + KEY_BUTTON_L, + KEY_BUTTON_R, + KEY_BUTTON_SPEED, + KEY_BUTTON_CAPTURE, + KEY_BUTTON_AUTO_A, + KEY_BUTTON_AUTO_B }; -enum EPad { - PAD_MAIN, - PAD_1 = PAD_MAIN, - PAD_2, - PAD_3, - PAD_4, - PAD_DEFAULT -}; +enum EPad { PAD_MAIN, PAD_1 = PAD_MAIN, PAD_2, PAD_3, PAD_4, PAD_DEFAULT }; /** * Init the joysticks needed by the keymap. Verify that the keymap is compatible diff --git a/src/version.h b/src/version.h index 2c911271..c7882428 100644 --- a/src/version.h +++ b/src/version.h @@ -45,15 +45,18 @@ #define VBA_COMPILER "" #define VBA_COMPILER_DETAIL " msvc " _Py_STRINGIZE(_MSC_VER) #define _Py_STRINGIZE(X) _Py_STRINGIZE1((X)) -#define _Py_STRINGIZE1(X) _Py_STRINGIZE2 ## X +#define _Py_STRINGIZE1(X) _Py_STRINGIZE2##X #define _Py_STRINGIZE2(X) #X -//re: http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5 +// re: +// http://72.14.203.104/search?q=cache:HG-okth5NGkJ:mail.python.org/pipermail/python-checkins/2002-November/030704.html+_msc_ver+compiler+version+string&hl=en&gl=us&ct=clnk&cd=5 #else // TODO: make for others compilers #define VBA_COMPILER "" #define VBA_COMPILER_DETAIL "" #endif -#define VBA_VERSION_STRING " " "2.0.0" VBA_SUBVERSION_STRING VBA_FEATURE_STRING VBA_COMPILER +#define VBA_VERSION_STRING \ + " " \ + "2.0.0" VBA_SUBVERSION_STRING VBA_FEATURE_STRING VBA_COMPILER #define VBA_NAME_AND_VERSION " " VBA_NAME VBA_VERSION_STRING #define VBA_NAME_AND_SUBVERSION " " VBA_NAME VBA_SUBVERSION_STRING diff --git a/src/win32/AVIWrite.h b/src/win32/AVIWrite.h index 5b7adb0e..01a74397 100644 --- a/src/win32/AVIWrite.h +++ b/src/win32/AVIWrite.h @@ -1,32 +1,33 @@ #include - // info: recreate the whole AVIWrite object if any method fails class AVIWrite { -public: - AVIWrite(); - virtual ~AVIWrite(); + public: + AVIWrite(); + virtual ~AVIWrite(); - bool CreateAVIFile( LPCTSTR filename ); - bool CreateVideoStream( LONG imageWidth, LONG imageHeight, WORD colorBits, DWORD framesPerSecond, HWND parentWnd ); - bool CreateAudioStream( WORD channelCount, DWORD sampleRate, WORD sampleBits, HWND parentWnd ); - bool AddVideoFrame( LPVOID imageData ); - bool AddAudioFrame( LPVOID soundData ); + bool CreateAVIFile(LPCTSTR filename); + bool CreateVideoStream(LONG imageWidth, LONG imageHeight, WORD colorBits, + DWORD framesPerSecond, HWND parentWnd); + bool CreateAudioStream(WORD channelCount, DWORD sampleRate, WORD sampleBits, + HWND parentWnd); + bool AddVideoFrame(LPVOID imageData); + bool AddAudioFrame(LPVOID soundData); -private: - bool m_failed; - PAVIFILE m_file; - PAVISTREAM m_videoStream; - PAVISTREAM m_audioStream; - AVICOMPRESSOPTIONS m_videoCompSettings; - AVICOMPRESSOPTIONS m_audioCompSettings; - PAVISTREAM m_videoCompressed; - PAVISTREAM m_audioCompressed; - DWORD m_frameRate; - LONG m_frameCounter; - LONG m_sampleCounter; - LONG m_videoFrameSize; - LONG m_audioFrameSize; - WORD m_audioBlockAlign; + private: + bool m_failed; + PAVIFILE m_file; + PAVISTREAM m_videoStream; + PAVISTREAM m_audioStream; + AVICOMPRESSOPTIONS m_videoCompSettings; + AVICOMPRESSOPTIONS m_audioCompSettings; + PAVISTREAM m_videoCompressed; + PAVISTREAM m_audioCompressed; + DWORD m_frameRate; + LONG m_frameCounter; + LONG m_sampleCounter; + LONG m_videoFrameSize; + LONG m_audioFrameSize; + WORD m_audioBlockAlign; }; diff --git a/src/win32/AboutDialog.h b/src/win32/AboutDialog.h index d09b08ec..7f2fe04c 100644 --- a/src/win32/AboutDialog.h +++ b/src/win32/AboutDialog.h @@ -1,24 +1,23 @@ #pragma once -#include "stdafx.h" #include "Hyperlink.h" #include "resource.h" - +#include "stdafx.h" class AboutDialog : public CDialog { -public: - AboutDialog(CWnd* pParent = NULL); - enum { IDD = IDD_ABOUT }; + public: + AboutDialog(CWnd *pParent = NULL); + enum { IDD = IDD_ABOUT }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); - virtual BOOL OnInitDialog(); - DECLARE_MESSAGE_MAP() + protected: + virtual void DoDataExchange(CDataExchange *pDX); + virtual BOOL OnInitDialog(); + DECLARE_MESSAGE_MAP() -private: - Hyperlink m_link; - Hyperlink m_translator; - CString m_version; - CString m_date; + private: + Hyperlink m_link; + Hyperlink m_translator; + CString m_version; + CString m_date; }; diff --git a/src/win32/AccelEditor.h b/src/win32/AccelEditor.h index 142148c8..982d0454 100644 --- a/src/win32/AccelEditor.h +++ b/src/win32/AccelEditor.h @@ -15,46 +15,44 @@ class AccelEditor : public ResizeDlg { - // Construction - public: - CAcceleratorManager mgr; - void InitCommands(); - AccelEditor(CWnd* pParent = NULL); // standard constructor + // Construction + public: + CAcceleratorManager mgr; + void InitCommands(); + AccelEditor(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AccelEditor) - enum { IDD = IDD_ACCEL_EDITOR }; - CListBox m_currents; - CStatic m_alreadyAffected; - CListBox m_commands; - CKeyboardEdit m_key; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AccelEditor) + enum { IDD = IDD_ACCEL_EDITOR }; + CListBox m_currents; + CStatic m_alreadyAffected; + CListBox m_commands; + CKeyboardEdit m_key; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AccelEditor) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AccelEditor) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AccelEditor) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnSelchangeCommands(); + afx_msg void OnReset(); + afx_msg void OnAssign(); + afx_msg void OnRemove(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AccelEditor) - virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnOk(); - afx_msg void OnSelchangeCommands(); - afx_msg void OnReset(); - afx_msg void OnAssign(); - afx_msg void OnRemove(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_ACCELEDITOR_H__66F5C854_E28E_40D1_B763_1850374B46A2__INCLUDED_) diff --git a/src/win32/AcceleratorManager.h b/src/win32/AcceleratorManager.h index 30703a65..27d2263f 100644 --- a/src/win32/AcceleratorManager.h +++ b/src/win32/AcceleratorManager.h @@ -32,112 +32,117 @@ #pragma once #endif // _MSC_VER >= 1000 - - #include "CmdAccelOb.h" - // Helper map -#include // MFC Templates extension +#include // MFC Templates extension #ifndef CMapStringToWord -typedef CMap< CString, LPCSTR, WORD, WORD& > CMapStringToWord; +typedef CMap CMapStringToWord; #endif #ifndef CMapWordToCCmdAccelOb -typedef CMap< WORD, WORD&, CCmdAccelOb*, CCmdAccelOb*& > CMapWordToCCmdAccelOb; +typedef CMap CMapWordToCCmdAccelOb; #endif - ////////////////////////////////////////////////////////////////////// // // -class CAcceleratorManager : public CObject { - friend class AccelEditor; - public: - CAcceleratorManager(); - virtual ~CAcceleratorManager(); +class CAcceleratorManager : public CObject +{ + friend class AccelEditor; - // Operations - public: - void UpdateMenu(HMENU menu); - void UpdateMenu(); - // Connection to the main application wnd - void Connect(CWnd *pWnd, bool bAutoSave = true); - // In/Out with the registry - bool Load(HKEY hRegKey, LPCTSTR szRegKey); - bool Load(); - bool Write(); - // Get the initials accels, not the user's - bool Default(); - // Save a copy in the 2 maps called xxxSaved, which are used in case - // of Default(), to reload the defaults accels. - bool CreateDefaultTable(); - bool IsDefaultTableAvailable() {return m_bDefaultTable;} - bool IsMapStringCommandsEmpty() { - if (m_mapAccelString.IsEmpty()) - return true; - else - return false; - } + public: + CAcceleratorManager(); + virtual ~CAcceleratorManager(); - // Registry access configuration - bool GetRegKey(HKEY& hRegKey, CString &szRegKey); - bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey); - bool IsAutoSave() {return m_bAutoSave;} - void SetAutoSave(bool bAutoSave) {m_bAutoSave = bAutoSave;} + // Operations + public: + void UpdateMenu(HMENU menu); + void UpdateMenu(); + // Connection to the main application wnd + void Connect(CWnd *pWnd, bool bAutoSave = true); + // In/Out with the registry + bool Load(HKEY hRegKey, LPCTSTR szRegKey); + bool Load(); + bool Write(); + // Get the initials accels, not the user's + bool Default(); + // Save a copy in the 2 maps called xxxSaved, which are used in case + // of Default(), to reload the defaults accels. + bool CreateDefaultTable(); + bool IsDefaultTableAvailable() + { + return m_bDefaultTable; + } + bool IsMapStringCommandsEmpty() + { + if (m_mapAccelString.IsEmpty()) + return true; + else + return false; + } - // Helper fct, used for new menus strings - bool GetStringFromACCEL(ACCEL* pACCEL, CString& szAccel); - bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString& szAccel); + // Registry access configuration + bool GetRegKey(HKEY &hRegKey, CString &szRegKey); + bool SetRegKey(HKEY hRegKey, LPCTSTR szRegKey); + bool IsAutoSave() + { + return m_bAutoSave; + } + void SetAutoSave(bool bAutoSave) + { + m_bAutoSave = bAutoSave; + } - // Update the ACCELS table in the application, from the specified - // datas in the manager. - bool UpdateWndTable(); + // Helper fct, used for new menus strings + bool GetStringFromACCEL(ACCEL *pACCEL, CString &szAccel); + bool GetStringFromACCEL(BYTE cVirt, WORD nCode, CString &szAccel); - // Modification helper fcts - bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, - LPCTSTR szCommand, bool bLocked = false); - bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true); - bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand); + // Update the ACCELS table in the application, from the specified + // datas in the manager. + bool UpdateWndTable(); - bool DeleteEntry(LPCTSTR szCommand); - bool DeleteEntry(WORD wIDCommand); - bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract); + // Modification helper fcts + bool SetAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract, LPCTSTR szCommand, + bool bLocked = false); + bool AddCommandAccel(WORD wIDCommand, LPCTSTR szCommand, bool bLocked = true); + bool CreateEntry(WORD wIDCommand, LPCTSTR szCommand); - // Affectation operator - CAcceleratorManager& operator=(const CAcceleratorManager& accelmgr); + bool DeleteEntry(LPCTSTR szCommand); + bool DeleteEntry(WORD wIDCommand); + bool DeleteAccel(BYTE cVirt, WORD wIDCommand, WORD wNewCaract); - public: + // Affectation operator + CAcceleratorManager &operator=(const CAcceleratorManager &accelmgr); + + public: #ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; + virtual void AssertValid() const; + virtual void Dump(CDumpContext &dc) const; #endif - protected: - // Erase all the datas - void Reset(); - // Internal affect fct. - bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, - LPCTSTR szCommand, bool bLocked); + protected: + // Erase all the datas + void Reset(); + // Internal affect fct. + bool AddAccel(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked); - // Attributes - protected: - CWnd *m_pWndConnected; + // Attributes + protected: + CWnd *m_pWndConnected; - // User datas - CMapStringToWord m_mapAccelString; - CMapWordToCCmdAccelOb m_mapAccelTable; - // Default datas - CMapWordToCCmdAccelOb m_mapAccelTableSaved; - bool m_bDefaultTable; - - // Where the users datas will be saved in the registry - HKEY m_hRegKey; - CString m_szRegKey; - // if true, there is an auto-save in the registry, when the destructor is called - bool m_bAutoSave; + // User datas + CMapStringToWord m_mapAccelString; + CMapWordToCCmdAccelOb m_mapAccelTable; + // Default datas + CMapWordToCCmdAccelOb m_mapAccelTableSaved; + bool m_bDefaultTable; + // Where the users datas will be saved in the registry + HKEY m_hRegKey; + CString m_szRegKey; + // if true, there is an auto-save in the registry, when the destructor is called + bool m_bAutoSave; }; - #endif // !defined(AFX_ACCELERATORMANAGER_H__A6D76F4B_26C6_11D2_BE72_006097AC8D00__INCLUDED_) diff --git a/src/win32/Associate.h b/src/win32/Associate.h index 1b1daee9..f34ac295 100644 --- a/src/win32/Associate.h +++ b/src/win32/Associate.h @@ -12,44 +12,42 @@ class Associate : public CDialog { - // Construction - public: - Associate(CWnd* pParent = NULL); // standard constructor + // Construction + public: + Associate(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(Associate) - enum { IDD = IDD_ASSOCIATIONS }; - BOOL m_agb; - BOOL m_bin; - BOOL m_cgb; - BOOL m_dmg; - BOOL m_gb; - BOOL m_gba; - BOOL m_gbc; - BOOL m_sgb; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(Associate) + enum { IDD = IDD_ASSOCIATIONS }; + BOOL m_agb; + BOOL m_bin; + BOOL m_cgb; + BOOL m_dmg; + BOOL m_gb; + BOOL m_gba; + BOOL m_gbc; + BOOL m_sgb; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Associate) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(Associate) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(Associate) - virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnOk(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(Associate) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_ASSOCIATE_H__3326525B_B405_40A7_82C4_B2594669A930__INCLUDED_) diff --git a/src/win32/AudioCoreSettingsDlg.h b/src/win32/AudioCoreSettingsDlg.h index 4ce69d25..521df124 100644 --- a/src/win32/AudioCoreSettingsDlg.h +++ b/src/win32/AudioCoreSettingsDlg.h @@ -4,44 +4,45 @@ class AudioCoreSettingsDlg : public CDialog { - DECLARE_DYNAMIC(AudioCoreSettingsDlg) + DECLARE_DYNAMIC(AudioCoreSettingsDlg) -public: - bool m_enabled; - bool m_surround; - bool m_declicking; - bool m_sound_interpolation; - float m_echo; - float m_stereo; - float m_volume; - float m_sound_filtering; - unsigned int m_sample_rate; + public: + bool m_enabled; + bool m_surround; + bool m_declicking; + bool m_sound_interpolation; + float m_echo; + float m_stereo; + float m_volume; + float m_sound_filtering; + unsigned int m_sample_rate; - AudioCoreSettingsDlg(CWnd* pParent = NULL); // standard constructor - virtual ~AudioCoreSettingsDlg(); + AudioCoreSettingsDlg(CWnd *pParent = NULL); // standard constructor + virtual ~AudioCoreSettingsDlg(); - virtual BOOL OnInitDialog(); - virtual BOOL PreTranslateMessage(MSG* pMsg); - afx_msg void OnBnClickedDefaultVolume(); + virtual BOOL OnInitDialog(); + virtual BOOL PreTranslateMessage(MSG *pMsg); + afx_msg void OnBnClickedDefaultVolume(); -// Dialog Data - enum { IDD = IDD_AUDIO_CORE_SETTINGS }; + // Dialog Data + enum { IDD = IDD_AUDIO_CORE_SETTINGS }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - afx_msg BOOL OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult); // Retrieve text for ToolTip + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + afx_msg BOOL OnTtnNeedText(UINT id, NMHDR *pNMHDR, LRESULT *pResult); // Retrieve text for + // ToolTip - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP() -private: - CButton enhance_sound; - CButton surround; - CButton declicking; - CButton sound_interpolation; - CSliderCtrl echo; - CSliderCtrl stereo; - CSliderCtrl volume; - CSliderCtrl sound_filtering; - CToolTipCtrl *toolTip; - CComboBox sample_rate; + private: + CButton enhance_sound; + CButton surround; + CButton declicking; + CButton sound_interpolation; + CSliderCtrl echo; + CSliderCtrl stereo; + CSliderCtrl volume; + CSliderCtrl sound_filtering; + CToolTipCtrl *toolTip; + CComboBox sample_rate; }; diff --git a/src/win32/BIOSDialog.h b/src/win32/BIOSDialog.h index ea3ced58..57a499d9 100644 --- a/src/win32/BIOSDialog.h +++ b/src/win32/BIOSDialog.h @@ -1,37 +1,37 @@ #pragma once - // BIOSDialog dialog class BIOSDialog : public CDialog { - DECLARE_DYNAMIC(BIOSDialog) + DECLARE_DYNAMIC(BIOSDialog) -public: - BIOSDialog(CWnd* pParent = NULL); // standard constructor - virtual ~BIOSDialog(); + public: + BIOSDialog(CWnd *pParent = NULL); // standard constructor + virtual ~BIOSDialog(); -// Dialog Data - enum { IDD = IDD_BIOS }; + // Dialog Data + enum { IDD = IDD_BIOS }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support - DECLARE_MESSAGE_MAP() -private: - CEdit m_editGB; - CEdit m_editGBC; - CEdit m_editGBA; - bool fileExists(CString& file); - afx_msg void OnBnClickedSelectGbBiosPath(); - afx_msg void OnBnClickedSelectGbcBiosPath(); - afx_msg void OnBnClickedSelectGbaBiosPath(); -public: - BOOL m_enableBIOS_GB; - BOOL m_enableBIOS_GBC; - BOOL m_enableBIOS_GBA; - BOOL m_skipLogo; - CString m_pathGB; - CString m_pathGBC; - CString m_pathGBA; + DECLARE_MESSAGE_MAP() + private: + CEdit m_editGB; + CEdit m_editGBC; + CEdit m_editGBA; + bool fileExists(CString &file); + afx_msg void OnBnClickedSelectGbBiosPath(); + afx_msg void OnBnClickedSelectGbcBiosPath(); + afx_msg void OnBnClickedSelectGbaBiosPath(); + + public: + BOOL m_enableBIOS_GB; + BOOL m_enableBIOS_GBC; + BOOL m_enableBIOS_GBA; + BOOL m_skipLogo; + CString m_pathGB; + CString m_pathGBC; + CString m_pathGBA; }; diff --git a/src/win32/BitmapControl.h b/src/win32/BitmapControl.h index 085d18f1..1d007646 100644 --- a/src/win32/BitmapControl.h +++ b/src/win32/BitmapControl.h @@ -1,76 +1,76 @@ #if !defined(AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_) #define AFX_BITMAPCONTROL_H__2434AADB_B6A5_4E43_AA16_7B65B6F7FA26__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // BitmapControl.h : header file // #ifndef WM_MAPINFO -#define WM_MAPINFO WM_APP+101 +#define WM_MAPINFO WM_APP + 101 #endif #ifndef WM_BITMAPCLICK -#define WM_BITMAPCLICK WM_APP+102 +#define WM_BITMAPCLICK WM_APP + 102 #endif ///////////////////////////////////////////////////////////////////////////// // BitmapControl view class BitmapControl : public CScrollView { - public: - BitmapControl(); // protected constructor used by dynamic creation - protected: - DECLARE_DYNCREATE(BitmapControl) + public: + BitmapControl(); // protected constructor used by dynamic creation + protected: + DECLARE_DYNCREATE(BitmapControl) - // Attributes - public: + // Attributes + public: + // Operations + public: + void setStretch(bool b); + void refresh(); + void setSize(int w1, int h1); + void setSelectedRectangle(int x, int y, int width, int height); + void setData(u8 *d); + void setBmpInfo(BITMAPINFO *info); + static bool isRegistered; - // Operations - public: - void setStretch(bool b); - void refresh(); - void setSize(int w1, int h1); - void setSelectedRectangle(int x, int y, int width, int height); - void setData(u8 *d); - void setBmpInfo(BITMAPINFO *info); - static bool isRegistered; + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(BitmapControl) + protected: + virtual void OnDraw(CDC *pDC); // overridden to draw this view + virtual void OnInitialUpdate(); // first time after construct + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BitmapControl) - protected: - virtual void OnDraw(CDC* pDC); // overridden to draw this view - virtual void OnInitialUpdate(); // first time after construct - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + public: + bool getStretch(); + virtual ~BitmapControl(); - // Implementation - public: - bool getStretch(); - virtual ~BitmapControl(); - protected: + protected: #ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; + virtual void AssertValid() const; + virtual void Dump(CDumpContext &dc) const; #endif - // Generated message map functions - //{{AFX_MSG(BitmapControl) - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - private: - void registerClass(); - bool stretch; - u8 colors[3*64]; - BITMAPINFO *bmpInfo; - u8 * data; - int h; - int w; - RECT boxreigon; + // Generated message map functions + //{{AFX_MSG(BitmapControl) + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void registerClass(); + bool stretch; + u8 colors[3 * 64]; + BITMAPINFO *bmpInfo; + u8 *data; + int h; + int w; + RECT boxreigon; }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/BugReport.h b/src/win32/BugReport.h index 179df29b..9b36df87 100644 --- a/src/win32/BugReport.h +++ b/src/win32/BugReport.h @@ -31,38 +31,37 @@ class BugReport : public CDialog { - // Construction - public: - BugReport(CWnd* pParent = NULL); // standard constructor + // Construction + public: + BugReport(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(BugReport) - enum { IDD = IDD_BUG_REPORT }; - CEdit m_report; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(BugReport) + enum { IDD = IDD_BUG_REPORT }; + CEdit m_report; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(BugReport) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(BugReport) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + CString createReport(); - // Implementation - protected: - CString createReport(); + // Generated message map functions + //{{AFX_MSG(BugReport) + afx_msg void OnCopy(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Generated message map functions - //{{AFX_MSG(BugReport) - afx_msg void OnCopy(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_BUGREPORT_H__DE7BC381_E45D_4200_910C_E5378E6364C9__INCLUDED_) diff --git a/src/win32/CmdAccelOb.h b/src/win32/CmdAccelOb.h index d473220c..a5aa4690 100644 --- a/src/win32/CmdAccelOb.h +++ b/src/win32/CmdAccelOb.h @@ -28,86 +28,84 @@ #ifndef __CMDACCEL_OB_INCLUDE #define __CMDACCEL_OB_INCLUDE -#include // MFC Templates extension +#include // MFC Templates extension //////////////////////////////////////////////////////////////////////// // // typedef struct tagMAPVIRTKEYS { - WORD wKey; - TCHAR szKey[15]; + WORD wKey; + TCHAR szKey[15]; } MAPVIRTKEYS, *PMAPVIRTKEYS; +//////////////////////////////////////////////////////////////////////// +// +// +#define sizetable(table) (sizeof(table) / sizeof(table[0])) //////////////////////////////////////////////////////////////////////// // // -#define sizetable(table) (sizeof(table)/sizeof(table[0])) +class CAccelsOb : public CObject +{ + public: + CAccelsOb(); + CAccelsOb(CAccelsOb *pFrom); + CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false); + CAccelsOb(LPACCEL pACCEL); + public: + CAccelsOb &operator=(const CAccelsOb &from); -//////////////////////////////////////////////////////////////////////// -// -// -class CAccelsOb : public CObject { - public: - CAccelsOb(); - CAccelsOb(CAccelsOb* pFrom); - CAccelsOb(BYTE cVirt, WORD wKey, bool bLocked = false); - CAccelsOb(LPACCEL pACCEL); + void GetString(CString &szBuffer); + bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift); + DWORD GetData(); + bool SetData(DWORD dwDatas); - public: - CAccelsOb& operator=(const CAccelsOb& from); - - void GetString(CString& szBuffer); - bool IsEqual(WORD wKey, bool bCtrl, bool bAlt, bool bShift); - DWORD GetData(); - bool SetData(DWORD dwDatas); - - public: + public: #ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; + virtual void AssertValid() const; + virtual void Dump(CDumpContext &dc) const; #endif - public: - BYTE m_cVirt; - WORD m_wKey; - bool m_bLocked; + public: + BYTE m_cVirt; + WORD m_wKey; + bool m_bLocked; }; - ////////////////////////////////////////////////////////////////////// // // -class CCmdAccelOb : public CObject { - public: - CCmdAccelOb(); - CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand); - CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, bool bLocked = false); - ~CCmdAccelOb(); +class CCmdAccelOb : public CObject +{ + public: + CCmdAccelOb(); + CCmdAccelOb(WORD wIDCommand, LPCTSTR szCommand); + CCmdAccelOb(BYTE cVirt, WORD wIDCommand, WORD wKey, LPCTSTR szCommand, + bool bLocked = false); + ~CCmdAccelOb(); - public: - void Add(CAccelsOb* pAccel); - void Add(BYTE cVirt, WORD wKey, bool bLocked = false); - void Reset(); - void DeleteUserAccels(); + public: + void Add(CAccelsOb *pAccel); + void Add(BYTE cVirt, WORD wKey, bool bLocked = false); + void Reset(); + void DeleteUserAccels(); - CCmdAccelOb& operator=(const CCmdAccelOb& from); - public: + CCmdAccelOb &operator=(const CCmdAccelOb &from); + + public: #ifdef _DEBUG - virtual void AssertValid() const; - virtual void Dump(CDumpContext& dc) const; + virtual void AssertValid() const; + virtual void Dump(CDumpContext &dc) const; #endif - public: - WORD m_wIDCommand; - CString m_szCommand; + public: + WORD m_wIDCommand; + CString m_szCommand; - CList< CAccelsOb*, CAccelsOb*& > m_Accels; + CList m_Accels; }; - //////////////////////////////////////////////////////////////////////// #endif // __CMDACCEL_OB_INCLUDE - - diff --git a/src/win32/ColorButton.h b/src/win32/ColorButton.h index 69dd58ff..5e6adea8 100644 --- a/src/win32/ColorButton.h +++ b/src/win32/ColorButton.h @@ -1,7 +1,7 @@ #if !defined(AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_) #define AFX_COLORBUTTON_H__DF02109B_B91C_49FD_954F_74A48B83C314__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -13,41 +13,42 @@ class ColorButton : public CButton { - // Construction - public: - ColorButton(); + // Construction + public: + ColorButton(); - // Attributes - public: - // Operations - static bool isRegistered; - public: - void PreSubclassWindow(); - void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); + // Attributes + public: + // Operations + static bool isRegistered; - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ColorButton) - //}}AFX_VIRTUAL + public: + void PreSubclassWindow(); + void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct); - // Implementation - public: - void setColor(u16 c); - u16 color; - virtual ~ColorButton(); + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ColorButton) + //}}AFX_VIRTUAL - void registerClass(); + // Implementation + public: + void setColor(u16 c); + u16 color; + virtual ~ColorButton(); - // Generated message map functions - protected: - //{{AFX_MSG(ColorButton) - // NOTE - the ClassWizard will add and remove member functions here. - //}}AFX_MSG + void registerClass(); - DECLARE_MESSAGE_MAP() - }; + // Generated message map functions + protected: + //{{AFX_MSG(ColorButton) + // NOTE - the ClassWizard will add and remove member functions here. + //}}AFX_MSG - ///////////////////////////////////////////////////////////////////////////// + DECLARE_MESSAGE_MAP() +}; + +///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/src/win32/ColorControl.h b/src/win32/ColorControl.h index 42cc3653..78970837 100644 --- a/src/win32/ColorControl.h +++ b/src/win32/ColorControl.h @@ -1,7 +1,7 @@ #if !defined(AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_) #define AFX_COLORCONTROL_H__747E1E47_DDFA_4D67_B337_A473F2BACB86__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -13,38 +13,37 @@ class ColorControl : public CWnd { - // Construction - public: - ColorControl(); + // Construction + public: + ColorControl(); - // Attributes - public: - // Operations - static bool isRegistered; + // Attributes + public: + // Operations + static bool isRegistered; - // Operations - public: + // Operations + public: + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ColorControl) + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ColorControl) - //}}AFX_VIRTUAL + // Implementation + public: + void setColor(u16 c); + u16 color; + virtual ~ColorControl(); - // Implementation - public: - void setColor(u16 c); - u16 color; - virtual ~ColorControl(); - - // Generated message map functions - protected: - //{{AFX_MSG(ColorControl) - afx_msg void OnPaint(); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - private: - void registerClass(); + // Generated message map functions + protected: + //{{AFX_MSG(ColorControl) + afx_msg void OnPaint(); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void registerClass(); }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/Directories.h b/src/win32/Directories.h index 5cb8bc82..b0d5958b 100644 --- a/src/win32/Directories.h +++ b/src/win32/Directories.h @@ -1,34 +1,33 @@ #pragma once - class Directories : public CDialog { -public: - Directories(CWnd* pParent = NULL); - enum { IDD = IDD_DIRECTORIES }; + public: + Directories(CWnd *pParent = NULL); + enum { IDD = IDD_DIRECTORIES }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnInitDialog(); - afx_msg void OnBatteryDir(); - afx_msg void OnCaptureDir(); - afx_msg void OnGbromDir(); - afx_msg void OnGbcromDir(); - afx_msg void OnRomDir(); - afx_msg void OnSaveDir(); - virtual void OnCancel(); - virtual void OnOK(); - DECLARE_MESSAGE_MAP() + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual BOOL OnInitDialog(); + afx_msg void OnBatteryDir(); + afx_msg void OnCaptureDir(); + afx_msg void OnGbromDir(); + afx_msg void OnGbcromDir(); + afx_msg void OnRomDir(); + afx_msg void OnSaveDir(); + virtual void OnCancel(); + virtual void OnOK(); + DECLARE_MESSAGE_MAP() -private: - CEdit m_savePath; - CEdit m_romPath; - CEdit m_gbcromPath; - CEdit m_gbromPath; - CEdit m_capturePath; - CEdit m_batteryPath; - CString initialFolderDir; + private: + CEdit m_savePath; + CEdit m_romPath; + CEdit m_gbcromPath; + CEdit m_gbromPath; + CEdit m_capturePath; + CEdit m_batteryPath; + CString initialFolderDir; - CString browseForDir(CString title); - bool directoryDoesExist(const char *directory); + CString browseForDir(CString title); + bool directoryDoesExist(const char *directory); }; diff --git a/src/win32/Disassemble.h b/src/win32/Disassemble.h index 6015f77b..f6acf443 100644 --- a/src/win32/Disassemble.h +++ b/src/win32/Disassemble.h @@ -7,69 +7,67 @@ // Disassemble.h : header file // +#include "../System.h" // Added by ClassView #include "IUpdate.h" #include "ResizeDlg.h" -#include "../System.h" // Added by ClassView ///////////////////////////////////////////////////////////////////////////// // Disassemble dialog class Disassemble : public ResizeDlg, IUpdateListener { - // Construction - public: - virtual void update(); - void refresh(); - int count; - bool autoUpdate; - u32 address; - Disassemble(CWnd* pParent = NULL); // standard constructor + // Construction + public: + virtual void update(); + void refresh(); + int count; + bool autoUpdate; + u32 address; + Disassemble(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(Disassemble) - enum { IDD = IDD_DISASSEMBLE }; - CEdit m_address; - CListBox m_list; - BOOL m_c; - BOOL m_f; - BOOL m_i; - BOOL m_n; - BOOL m_t; - BOOL m_v; - BOOL m_z; - int mode; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(Disassemble) + enum { IDD = IDD_DISASSEMBLE }; + CEdit m_address; + CListBox m_list; + BOOL m_c; + BOOL m_f; + BOOL m_i; + BOOL m_n; + BOOL m_t; + BOOL m_v; + BOOL m_z; + int mode; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Disassemble) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(Disassemble) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(Disassemble) + afx_msg void OnAutoUpdate(); + afx_msg void OnAutomatic(); + afx_msg void OnArm(); + afx_msg void OnClose(); + afx_msg void OnGo(); + afx_msg void OnGopc(); + afx_msg void OnNext(); + afx_msg void OnRefresh(); + afx_msg void OnThumb(); + virtual BOOL OnInitDialog(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(Disassemble) - afx_msg void OnAutoUpdate(); - afx_msg void OnAutomatic(); - afx_msg void OnArm(); - afx_msg void OnClose(); - afx_msg void OnGo(); - afx_msg void OnGopc(); - afx_msg void OnNext(); - afx_msg void OnRefresh(); - afx_msg void OnThumb(); - virtual BOOL OnInitDialog(); - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_DISASSEMBLE_H__CA10E857_7D76_4B19_A62B_D0677040FD0F__INCLUDED_) diff --git a/src/win32/Display.h b/src/win32/Display.h index 9e66ce93..c716046f 100644 --- a/src/win32/Display.h +++ b/src/win32/Display.h @@ -2,98 +2,98 @@ #include -enum DISPLAY_TYPE { - DIRECT_3D = 0, - OPENGL = 1 +enum DISPLAY_TYPE { DIRECT_3D = 0, OPENGL = 1 }; + +class IDisplay +{ + public: + IDisplay(){}; + virtual ~IDisplay(){}; + + struct VIDEO_MODE { + unsigned int adapter; + unsigned int width; + unsigned int height; + unsigned int bitDepth; + unsigned int frequency; + }; + + virtual bool initialize() = 0; + virtual void cleanup() = 0; + virtual void render() = 0; + virtual void clear() = 0; + virtual bool changeRenderSize(int w, int h) + { + return true; + }; + virtual void resize(int w, int h){}; + virtual void setOption(const char *option, int value){}; + virtual DISPLAY_TYPE getType() = 0; + virtual bool selectFullScreenMode(VIDEO_MODE &mode) = 0; }; -class IDisplay { - public: - IDisplay() {}; - virtual ~IDisplay() {}; - - struct VIDEO_MODE - { - unsigned int adapter; - unsigned int width; - unsigned int height; - unsigned int bitDepth; - unsigned int frequency; - }; - - virtual bool initialize() = 0; - virtual void cleanup() = 0; - virtual void render() = 0; - virtual void clear() = 0; - virtual bool changeRenderSize(int w, int h) { return true; }; - virtual void resize(int w, int h) {}; - virtual void setOption(const char *option, int value) {}; - virtual DISPLAY_TYPE getType() = 0; - virtual bool selectFullScreenMode( VIDEO_MODE &mode ) = 0; -}; - - -inline void cpyImg32( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height ) +inline void cpyImg32(unsigned char *dst, unsigned int dstPitch, unsigned char *src, + unsigned int srcPitch, unsigned short width, unsigned short height) { - // fast, iterative C version - // copies an width*height array of visible pixels from src to dst - // srcPitch and dstPitch are the number of garbage bytes after a scanline - register unsigned short lineSize = width<<2; + // fast, iterative C version + // copies an width*height array of visible pixels from src to dst + // srcPitch and dstPitch are the number of garbage bytes after a scanline + register unsigned short lineSize = width << 2; - while( height-- ) { - memcpy( dst, src, lineSize ); - src += srcPitch; - dst += dstPitch; - } + while (height--) { + memcpy(dst, src, lineSize); + src += srcPitch; + dst += dstPitch; + } } - -inline void cpyImg32bmp( unsigned char *dst, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height ) +inline void cpyImg32bmp(unsigned char *dst, unsigned char *src, unsigned int srcPitch, + unsigned short width, unsigned short height) { - // dst will be an upside down bitmap with 24bit colors - // pix must contain 32bit colors (XRGB) - unsigned short srcLineSize = width<<2; - dst += height * width * 3; // move to the last scanline - register unsigned char r, g, b; + // dst will be an upside down bitmap with 24bit colors + // pix must contain 32bit colors (XRGB) + unsigned short srcLineSize = width << 2; + dst += height * width * 3; // move to the last scanline + register unsigned char r, g, b; - while( height-- ) { - unsigned short x = width; - src += srcLineSize; - while( x-- ) { - --src; // ignore one of 4 bytes - b = *--src; - g = *--src; - r = *--src; - *--dst = b; - *--dst = g; - *--dst = r; - } - src += srcPitch; - } + while (height--) { + unsigned short x = width; + src += srcLineSize; + while (x--) { + --src; // ignore one of 4 bytes + b = *--src; + g = *--src; + r = *--src; + *--dst = b; + *--dst = g; + *--dst = r; + } + src += srcPitch; + } } - -inline void cpyImg16( unsigned char *dst, unsigned int dstPitch, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height ) +inline void cpyImg16(unsigned char *dst, unsigned int dstPitch, unsigned char *src, + unsigned int srcPitch, unsigned short width, unsigned short height) { - register unsigned short lineSize = width<<1; + register unsigned short lineSize = width << 1; - while( height-- ) { - memcpy( dst, src, lineSize ); - src += srcPitch; - dst += dstPitch; - } + while (height--) { + memcpy(dst, src, lineSize); + src += srcPitch; + dst += dstPitch; + } } - -inline void cpyImg16bmp( unsigned char *dst, unsigned char *src, unsigned int srcPitch, unsigned short width, unsigned short height ) +inline void cpyImg16bmp(unsigned char *dst, unsigned char *src, unsigned int srcPitch, + unsigned short width, unsigned short height) { - // dst will be an upside down bitmap with 16bit colors - register unsigned short lineSize = width<<1; - dst += ( height - 1 ) * lineSize; // move to the last scanline + // dst will be an upside down bitmap with 16bit colors + register unsigned short lineSize = width << 1; + dst += (height - 1) * lineSize; // move to the last scanline - while( height-- ) { - memcpy( dst, src, lineSize ); - src += srcPitch; - dst -= lineSize; - } + while (height--) { + memcpy(dst, src, lineSize); + src += srcPitch; + dst -= lineSize; + } } diff --git a/src/win32/ExportGSASnapshot.h b/src/win32/ExportGSASnapshot.h index d4721054..758f1fc1 100644 --- a/src/win32/ExportGSASnapshot.h +++ b/src/win32/ExportGSASnapshot.h @@ -12,40 +12,39 @@ class ExportGSASnapshot : public CDialog { - // Construction - public: - ExportGSASnapshot(CString filename, CString title,CWnd* pParent = NULL); // standard constructor + // Construction + public: + ExportGSASnapshot(CString filename, CString title, CWnd *pParent = NULL); // standard + // constructor - // Dialog Data - //{{AFX_DATA(ExportGSASnapshot) - enum { IDD = IDD_EXPORT_SPS }; - CString m_desc; - CString m_notes; - CString m_title; - //}}AFX_DATA - CString m_filename; + // Dialog Data + //{{AFX_DATA(ExportGSASnapshot) + enum { IDD = IDD_EXPORT_SPS }; + CString m_desc; + CString m_notes; + CString m_title; + //}}AFX_DATA + CString m_filename; + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ExportGSASnapshot) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ExportGSASnapshot) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(ExportGSASnapshot) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(ExportGSASnapshot) - virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnOk(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_EXPORTGSASNAPSHOT_H__ADF8566A_C64D_43CF_9CD2_A290370BA4F1__INCLUDED_) diff --git a/src/win32/FileDlg.h b/src/win32/FileDlg.h index d4b3ebd6..2d5e46da 100644 --- a/src/win32/FileDlg.h +++ b/src/win32/FileDlg.h @@ -8,9 +8,9 @@ // struct OPENFILENAMEEX : public OPENFILENAME { - void * pvReserved; - DWORD dwReserved; - DWORD FlagsEx; + void *pvReserved; + DWORD dwReserved; + DWORD FlagsEx; }; ///////////////////////////////////////////////////////////////////////////// @@ -18,27 +18,28 @@ struct OPENFILENAMEEX : public OPENFILENAME { class FileDlg { - private: - CString m_file; - CString m_filter; - public: - OPENFILENAMEEX m_ofn; - int DoModal(); - LPCTSTR GetPathName(); - virtual int getFilterIndex(); - virtual void OnTypeChange(HWND hwnd); - FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter, - int filterIndex, LPCTSTR ext, LPCTSTR *exts, LPCTSTR initialDir, - LPCTSTR title, bool save); - virtual ~FileDlg(); + private: + CString m_file; + CString m_filter; - protected: - bool isSave; - LPCTSTR *extensions; + public: + OPENFILENAMEEX m_ofn; + int DoModal(); + LPCTSTR GetPathName(); + virtual int getFilterIndex(); + virtual void OnTypeChange(HWND hwnd); + FileDlg(CWnd *parent, LPCTSTR file, LPCTSTR filter, int filterIndex, LPCTSTR ext, + LPCTSTR *exts, LPCTSTR initialDir, LPCTSTR title, bool save); + virtual ~FileDlg(); - protected: - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + protected: + bool isSave; + LPCTSTR *extensions; + + protected: + //{{AFX_INSERT_LOCATION}} + // Microsoft Visual C++ will insert additional declarations immediately before the previous + // line. }; #endif // !defined(AFX_FILEDLG_H__7E4F8B92_1B63_4126_8261_D9334C645940__INCLUDED_) diff --git a/src/win32/FullscreenSettings.h b/src/win32/FullscreenSettings.h index ef63c1c4..5cd5e3e6 100644 --- a/src/win32/FullscreenSettings.h +++ b/src/win32/FullscreenSettings.h @@ -2,9 +2,8 @@ #include "Display.h" - #ifndef NO_D3D -#pragma comment( lib, "d3d9" ) +#pragma comment(lib, "d3d9") #ifdef _DEBUG #define D3D_DEBUG_INFO #endif @@ -12,50 +11,49 @@ #include #endif - // FullscreenSettings dialog class FullscreenSettings : public CDialog { - DECLARE_DYNAMIC(FullscreenSettings) + DECLARE_DYNAMIC(FullscreenSettings) -public: - FullscreenSettings(CWnd* pParent = NULL); // standard constructor - virtual ~FullscreenSettings(); + public: + FullscreenSettings(CWnd *pParent = NULL); // standard constructor + virtual ~FullscreenSettings(); -// Dialog Data - enum { IDD = IDD_FULLSCREEN }; + // Dialog Data + enum { IDD = IDD_FULLSCREEN }; - // Call this function to select the API for the display mode enumeration. - void setAPI( DISPLAY_TYPE type ); - afx_msg void OnCbnSelchangeComboDevice(); - afx_msg void OnCbnSelchangeComboColorDepth(); - afx_msg void OnCbnSelchangeComboResolution(); + // Call this function to select the API for the display mode enumeration. + void setAPI(DISPLAY_TYPE type); + afx_msg void OnCbnSelchangeComboDevice(); + afx_msg void OnCbnSelchangeComboColorDepth(); + afx_msg void OnCbnSelchangeComboResolution(); - unsigned int m_device; - unsigned int m_colorDepth; - unsigned int m_width; - unsigned int m_height; - unsigned int m_refreshRate; + unsigned int m_device; + unsigned int m_colorDepth; + unsigned int m_width; + unsigned int m_height; + unsigned int m_refreshRate; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void OnOK(); + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void OnOK(); - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP() -private: - DISPLAY_TYPE api; - bool failed; + private: + DISPLAY_TYPE api; + bool failed; #ifndef NO_D3D - LPDIRECT3D9 pD3D; + LPDIRECT3D9 pD3D; #endif - virtual BOOL OnInitDialog(); + virtual BOOL OnInitDialog(); - CComboBox combo_device; - CComboBox combo_resolution; - CComboBox combo_color_depth; - CComboBox combo_refresh_rate; + CComboBox combo_device; + CComboBox combo_resolution; + CComboBox combo_color_depth; + CComboBox combo_refresh_rate; }; diff --git a/src/win32/GBACheats.h b/src/win32/GBACheats.h index b2d2fd95..9dac21ae 100644 --- a/src/win32/GBACheats.h +++ b/src/win32/GBACheats.h @@ -1,7 +1,7 @@ #if !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_) #define AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -12,62 +12,60 @@ // GBACheatSearch dialog struct WinCheatsData { - u32 addr; - char address[9]; - char oldValue[12]; - char newValue[12]; + u32 addr; + char address[9]; + char oldValue[12]; + char newValue[12]; }; class GBACheatSearch : public CDialog { - // Construction - public: - afx_msg void OnSizeType(UINT id); - afx_msg void OnNumberType(UINT id); - afx_msg void OnSearchType(UINT id); - afx_msg void OnValueType(UINT id); - void addChange(int index, u32 address, u32 oldValue, u32 newValue); - GBACheatSearch(CWnd* pParent = NULL); // standard constructor - ~GBACheatSearch(); + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + afx_msg void OnSearchType(UINT id); + afx_msg void OnValueType(UINT id); + void addChange(int index, u32 address, u32 oldValue, u32 newValue); + GBACheatSearch(CWnd *pParent = NULL); // standard constructor + ~GBACheatSearch(); - // Dialog Data - //{{AFX_DATA(GBACheatSearch) - enum { IDD = IDD_CHEATS }; - CEdit m_value; - CListCtrl m_list; - int valueType; - int sizeType; - int searchType; - int numberType; - BOOL updateValues; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBACheatSearch) + enum { IDD = IDD_CHEATS }; + CEdit m_value; + CListCtrl m_list; + int valueType; + int sizeType; + int searchType; + int numberType; + BOOL updateValues; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBACheatSearch) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBACheatSearch) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBACheatSearch) - afx_msg void OnOk(); - afx_msg void OnStart(); - afx_msg void OnSearch(); - afx_msg void OnAddCheat(); - afx_msg void OnUpdate(); - afx_msg void OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - private: - void addChanges(bool showMsgs); - WinCheatsData *data; + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBACheatSearch) + afx_msg void OnOk(); + afx_msg void OnStart(); + afx_msg void OnSearch(); + afx_msg void OnAddCheat(); + afx_msg void OnUpdate(); + afx_msg void OnGetdispinfoCheatList(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnItemchangedCheatList(NMHDR *pNMHDR, LRESULT *pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + void addChanges(bool showMsgs); + WinCheatsData *data; }; ///////////////////////////////////////////////////////////////////////////// @@ -75,198 +73,188 @@ class GBACheatSearch : public CDialog class AddCheat : public CDialog { - // Construction - public: - bool addCheat(); - afx_msg void OnSizeType(UINT id); - afx_msg void OnNumberType(UINT id); - u32 address; - AddCheat(u32 address, CWnd* pParent = NULL); // standard constructor + // Construction + public: + bool addCheat(); + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + u32 address; + AddCheat(u32 address, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddCheat) - enum { IDD = IDD_ADD_CHEAT }; - CEdit m_value; - CEdit m_desc; - CEdit m_address; - int sizeType; - int numberType; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddCheat) + enum { IDD = IDD_ADD_CHEAT }; + CEdit m_value; + CEdit m_desc; + CEdit m_address; + int sizeType; + int numberType; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCheat) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddCheat) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AddCheat) - afx_msg void OnOk(); - afx_msg void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - ///////////////////////////////////////////////////////////////////////////// + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AddCheat) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +///////////////////////////////////////////////////////////////////////////// // GBACheatList dialog class GBACheatList : public CDialog { - // Construction - public: - void refresh(); - bool duringRefresh; - bool restoreValues; + // Construction + public: + void refresh(); + bool duringRefresh; + bool restoreValues; - GBACheatList(CWnd* pParent = NULL); // standard constructor + GBACheatList(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GBACheatList) - enum { IDD = IDD_CHEAT_LIST }; - CButton m_restore; - CListCtrl m_list; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBACheatList) + enum { IDD = IDD_CHEAT_LIST }; + CButton m_restore; + CListCtrl m_list; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBACheatList) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBACheatList) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBACheatList) - afx_msg void OnAddCheat(); - afx_msg void OnAddCode(); - afx_msg void OnAddCodebreaker(); - afx_msg void OnAddGameshark(); - afx_msg void OnEnable(); - afx_msg void OnRemove(); - afx_msg void OnRemoveAll(); - afx_msg void OnRestore(); - afx_msg void OnOk(); - afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - ///////////////////////////////////////////////////////////////////////////// + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBACheatList) + afx_msg void OnAddCheat(); + afx_msg void OnAddCode(); + afx_msg void OnAddCodebreaker(); + afx_msg void OnAddGameshark(); + afx_msg void OnEnable(); + afx_msg void OnRemove(); + afx_msg void OnRemoveAll(); + afx_msg void OnRestore(); + afx_msg void OnOk(); + afx_msg void OnItemchangedCheatList(NMHDR *pNMHDR, LRESULT *pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +///////////////////////////////////////////////////////////////////////////// // AddGSACode dialog class AddGSACode : public CDialog { - // Construction - public: - AddGSACode(CWnd* pParent = NULL); // standard constructor + // Construction + public: + AddGSACode(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddGSACode) - enum { IDD = IDD_ADD_CHEAT_DLG }; - CEdit m_desc; - CEdit m_code; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddGSACode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGSACode) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddGSACode) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AddGSACode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AddGSACode) - afx_msg void OnOk(); - afx_msg void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // AddCBACode dialog class AddCBACode : public CDialog { - // Construction - public: - AddCBACode(CWnd* pParent = NULL); // standard constructor + // Construction + public: + AddCBACode(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddCBACode) - enum { IDD = IDD_ADD_CHEAT_DLG }; - CEdit m_desc; - CEdit m_code; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddCBACode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCBACode) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddCBACode) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AddCBACode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AddCBACode) - afx_msg void OnOk(); - afx_msg void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // AddCheatCode dialog class AddCheatCode : public CDialog { - // Construction - public: - AddCheatCode(CWnd* pParent = NULL); // standard constructor + // Construction + public: + AddCheatCode(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddCheatCode) - enum { IDD = IDD_ADD_CHEAT_DLG }; - CEdit m_desc; - CEdit m_code; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddCheatCode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddCheatCode) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddCheatCode) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AddCheatCode) - afx_msg void OnOk(); - afx_msg void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AddCheatCode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBACHEATS_H__FC31D47D_52C8_42B2_95C7_7C3FD09316A4__INCLUDED_) diff --git a/src/win32/GBCheatsDlg.h b/src/win32/GBCheatsDlg.h index 8bb65949..e74ce27b 100644 --- a/src/win32/GBCheatsDlg.h +++ b/src/win32/GBCheatsDlg.h @@ -11,63 +11,62 @@ // GBCheatSearch dialog struct WinGbCheatsData { - int bank; - u16 addr; - char address[9]; - char oldValue[12]; - char newValue[12]; + int bank; + u16 addr; + char address[9]; + char oldValue[12]; + char newValue[12]; }; class GBCheatSearch : public CDialog { - // Construction - public: - afx_msg void OnSizeType(UINT id); - afx_msg void OnNumberType(UINT id); - afx_msg void OnSearchType(UINT id); - afx_msg void OnValueType(UINT id); - void addChanges(bool showMsg); - void addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue); - int getBank(u16 addr, int j); - GBCheatSearch(CWnd* pParent = NULL); // standard constructor - ~GBCheatSearch(); + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + afx_msg void OnSearchType(UINT id); + afx_msg void OnValueType(UINT id); + void addChanges(bool showMsg); + void addChange(int index, int bank, u16 address, int offset, u32 oldValue, u32 newValue); + int getBank(u16 addr, int j); + GBCheatSearch(CWnd *pParent = NULL); // standard constructor + ~GBCheatSearch(); - // Dialog Data - //{{AFX_DATA(GBCheatSearch) - enum { IDD = IDD_CHEATS }; - CEdit m_value; - CListCtrl m_list; - int searchType; - int numberType; - int sizeType; - BOOL updateValues; - int valueType; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBCheatSearch) + enum { IDD = IDD_CHEATS }; + CEdit m_value; + CListCtrl m_list; + int searchType; + int numberType; + int sizeType; + BOOL updateValues; + int valueType; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBCheatSearch) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBCheatSearch) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + WinGbCheatsData *data; - // Implementation - protected: - WinGbCheatsData *data; - - // Generated message map functions - //{{AFX_MSG(GBCheatSearch) - afx_msg void OnOk(); - afx_msg void OnAddCheat(); - afx_msg void OnSearch(); - afx_msg void OnStart(); - afx_msg void OnUpdate(); - virtual BOOL OnInitDialog(); - afx_msg void OnGetdispinfoCheatList(NMHDR* pNMHDR, LRESULT* pResult); - afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Generated message map functions + //{{AFX_MSG(GBCheatSearch) + afx_msg void OnOk(); + afx_msg void OnAddCheat(); + afx_msg void OnSearch(); + afx_msg void OnStart(); + afx_msg void OnUpdate(); + virtual BOOL OnInitDialog(); + afx_msg void OnGetdispinfoCheatList(NMHDR *pNMHDR, LRESULT *pResult); + afx_msg void OnItemchangedCheatList(NMHDR *pNMHDR, LRESULT *pResult); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// @@ -75,129 +74,126 @@ class GBCheatSearch : public CDialog class AddGBCheat : public CDialog { - // Construction - public: - afx_msg void OnSizeType(UINT id); - afx_msg void OnNumberType(UINT id); - bool addCheat(); - AddGBCheat(u32 addr, CWnd* pParent = NULL); // standard constructor + // Construction + public: + afx_msg void OnSizeType(UINT id); + afx_msg void OnNumberType(UINT id); + bool addCheat(); + AddGBCheat(u32 addr, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddGBCheat) - enum { IDD = IDD_ADD_CHEAT }; - CEdit m_value; - CEdit m_address; - CEdit m_desc; - int sizeType; - int numberType; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddGBCheat) + enum { IDD = IDD_ADD_CHEAT }; + CEdit m_value; + CEdit m_address; + CEdit m_desc; + int sizeType; + int numberType; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGBCheat) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddGBCheat) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + LONG_PTR address; - // Implementation - protected: - LONG_PTR address; - - // Generated message map functions - //{{AFX_MSG(AddGBCheat) - afx_msg void OnCancel(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - ///////////////////////////////////////////////////////////////////////////// + // Generated message map functions + //{{AFX_MSG(AddGBCheat) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +///////////////////////////////////////////////////////////////////////////// // GBCheatList dialog class GBCheatList : public CDialog { - // Construction - public: - void refresh(); - bool duringRefresh; - GBCheatList(CWnd* pParent = NULL); // standard constructor + // Construction + public: + void refresh(); + bool duringRefresh; + GBCheatList(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GBCheatList) - enum { IDD = IDD_GB_CHEAT_LIST }; - CListCtrl m_list; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBCheatList) + enum { IDD = IDD_GB_CHEAT_LIST }; + CListCtrl m_list; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBCheatList) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBCheatList) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBCheatList) - afx_msg void OnOk(); - afx_msg void OnAddGgCheat(); - afx_msg void OnAddGsCheat(); - afx_msg void OnEnable(); - afx_msg void OnRemove(); - afx_msg void OnRemoveAll(); - afx_msg void OnItemchangedCheatList(NMHDR* pNMHDR, LRESULT* pResult); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult); + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBCheatList) + afx_msg void OnOk(); + afx_msg void OnAddGgCheat(); + afx_msg void OnAddGsCheat(); + afx_msg void OnEnable(); + afx_msg void OnRemove(); + afx_msg void OnRemoveAll(); + afx_msg void OnItemchangedCheatList(NMHDR *pNMHDR, LRESULT *pResult); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + afx_msg void OnNMDblclkCheatList(NMHDR *pNMHDR, LRESULT *pResult); }; - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // AddGBCode dialog class AddGBCode : public CDialog { - // Construction - public: - AddGBCode(bool (*verify)(const char *, const char *),int, const char *, CWnd* pParent = NULL); // standard constructor + // Construction + public: + AddGBCode(bool (*verify)(const char *, const char *), int, const char *, + CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(AddGBCode) - enum { IDD = IDD_ADD_CHEAT_DLG }; - CEdit m_desc; - CEdit m_code; - CString m_descVal; - CString m_codeVal; - bool m_onlyOneLine; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(AddGBCode) + enum { IDD = IDD_ADD_CHEAT_DLG }; + CEdit m_desc; + CEdit m_code; + CString m_descVal; + CString m_codeVal; + bool m_onlyOneLine; + //}}AFX_DATA - int addLength; - CString addTitle; - bool (*addVerify)(const char *, const char*); + int addLength; + CString addTitle; + bool (*addVerify)(const char *, const char *); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(AddGBCode) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(AddGBCode) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(AddGBCode) - afx_msg void OnOk(); - afx_msg void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(AddGBCode) + afx_msg void OnOk(); + afx_msg void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBCHEATSDLG_H__8ECCB04A_AB75_4552_8625_C6FBF30A95D9__INCLUDED_) diff --git a/src/win32/GBColorDlg.h b/src/win32/GBColorDlg.h index bb9198b5..a20761f3 100644 --- a/src/win32/GBColorDlg.h +++ b/src/win32/GBColorDlg.h @@ -1,8 +1,8 @@ #if !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_) #define AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_ -#include "ColorButton.h" // Added by ClassView -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView +#include "ColorButton.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -14,49 +14,47 @@ class GBColorDlg : public CDialog { - // Construction - public: - int getWhich(); - afx_msg void OnColorClicked(UINT id); - u16 * getColors(); - void setWhich(int w); - u16 colors[24]; - ColorButton colorControls[8]; - GBColorDlg(CWnd* pParent = NULL); // standard constructor + // Construction + public: + int getWhich(); + afx_msg void OnColorClicked(UINT id); + u16 *getColors(); + void setWhich(int w); + u16 colors[24]; + ColorButton colorControls[8]; + GBColorDlg(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GBColorDlg) - enum { IDD = IDD_GB_COLORS }; - CComboBox m_predefined; - int which; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBColorDlg) + enum { IDD = IDD_GB_COLORS }; + CComboBox m_predefined; + int which; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBColorDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBColorDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBColorDlg) + afx_msg void OnDefault(); + afx_msg void OnReset(); + afx_msg void OnUser1(); + afx_msg void OnUser2(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + afx_msg void OnSelchangePredefined(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBColorDlg) - afx_msg void OnDefault(); - afx_msg void OnReset(); - afx_msg void OnUser1(); - afx_msg void OnUser2(); - afx_msg void OnCancel(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - afx_msg void OnSelchangePredefined(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBCOLORDLG_H__8D6126EF_06BB_48CF_ABB3_2CC4B1B60358__INCLUDED_) diff --git a/src/win32/GBDisassemble.h b/src/win32/GBDisassemble.h index bc57b0ee..f1602ef2 100644 --- a/src/win32/GBDisassemble.h +++ b/src/win32/GBDisassemble.h @@ -1,7 +1,7 @@ #if !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_) #define AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -16,55 +16,53 @@ class GBDisassemble : public ResizeDlg, IUpdateListener { - // Construction - public: - void refresh(); - u16 lastAddress; - int count; - bool autoUpdate; - u16 address; - GBDisassemble(CWnd* pParent = NULL); // standard constructor + // Construction + public: + void refresh(); + u16 lastAddress; + int count; + bool autoUpdate; + u16 address; + GBDisassemble(CWnd *pParent = NULL); // standard constructor - virtual void update(); + virtual void update(); - // Dialog Data - //{{AFX_DATA(GBDisassemble) - enum { IDD = IDD_GB_DISASSEMBLE }; - CEdit m_address; - CListBox m_list; - BOOL m_c; - BOOL m_h; - BOOL m_n; - BOOL m_z; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBDisassemble) + enum { IDD = IDD_GB_DISASSEMBLE }; + CEdit m_address; + CListBox m_list; + BOOL m_c; + BOOL m_h; + BOOL m_n; + BOOL m_z; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBDisassemble) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBDisassemble) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBDisassemble) + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void OnNext(); + afx_msg void OnGo(); + afx_msg void OnGopc(); + afx_msg void OnAutoUpdate(); + virtual BOOL OnInitDialog(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBDisassemble) - afx_msg void OnClose(); - afx_msg void OnRefresh(); - afx_msg void OnNext(); - afx_msg void OnGo(); - afx_msg void OnGopc(); - afx_msg void OnAutoUpdate(); - virtual BOOL OnInitDialog(); - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBDISASSEMBLE_H__3EFD5B47_6DBF_4F63_8F91_A9511EC590EB__INCLUDED_) diff --git a/src/win32/GBMapView.h b/src/win32/GBMapView.h index b91c18fb..7944331a 100644 --- a/src/win32/GBMapView.h +++ b/src/win32/GBMapView.h @@ -7,77 +7,75 @@ // GBMapView.h : header file // +#include "../System.h" // Added by ClassView #include "BitmapControl.h" #include "ColorControl.h" -#include "ZoomControl.h" -#include "ResizeDlg.h" #include "IUpdate.h" -#include "../System.h" // Added by ClassView +#include "ResizeDlg.h" +#include "ZoomControl.h" ///////////////////////////////////////////////////////////////////////////// // GBMapView dialog class GBMapView : public ResizeDlg, IUpdateListener { - private: - BITMAPINFO bmpInfo; - u8 *data; - int bank; - int bg; - int w; - int h; - BitmapControl mapView; - ZoomControl mapViewZoom; - ColorControl color; - bool autoUpdate; - // Construction - public: - afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); - u32 GetClickAddress(int x, int y); - void update(); - void paint(); - void render(); - void savePNG(const char *name); - void saveBMP(const char *name); - ~GBMapView(); - GBMapView(CWnd* pParent = NULL); // standard constructor + private: + BITMAPINFO bmpInfo; + u8 *data; + int bank; + int bg; + int w; + int h; + BitmapControl mapView; + ZoomControl mapViewZoom; + ColorControl color; + bool autoUpdate; + // Construction + public: + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + u32 GetClickAddress(int x, int y); + void update(); + void paint(); + void render(); + void savePNG(const char *name); + void saveBMP(const char *name); + ~GBMapView(); + GBMapView(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GBMapView) - enum { IDD = IDD_GB_MAP_VIEW }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBMapView) + enum { IDD = IDD_GB_MAP_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBMapView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBMapView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBMapView) + afx_msg void OnSave(); + afx_msg void OnRefresh(); + virtual BOOL OnInitDialog(); + afx_msg void OnBg0(); + afx_msg void OnBg1(); + afx_msg void OnBank0(); + afx_msg void OnBank1(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBMapView) - afx_msg void OnSave(); - afx_msg void OnRefresh(); - virtual BOOL OnInitDialog(); - afx_msg void OnBg0(); - afx_msg void OnBg1(); - afx_msg void OnBank0(); - afx_msg void OnBank1(); - afx_msg void OnStretch(); - afx_msg void OnAutoUpdate(); - afx_msg void OnClose(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBMAPVIEW_H__4CD23D38_F2CD_4B95_AE76_2781591DD077__INCLUDED_) diff --git a/src/win32/GBMemoryViewerDlg.h b/src/win32/GBMemoryViewerDlg.h index f0f8e67e..1f3ec41a 100644 --- a/src/win32/GBMemoryViewerDlg.h +++ b/src/win32/GBMemoryViewerDlg.h @@ -6,15 +6,16 @@ #endif // _MSC_VER > 1000 // GBMemoryViewerDlg.h : header file // +#include "IUpdate.h" #include "MemoryViewer.h" #include "ResizeDlg.h" -#include "IUpdate.h" -class GBMemoryViewer : public MemoryViewer { - public: - GBMemoryViewer(); - virtual void readData(u32, int, u8 *); - virtual void editData(u32, int, int, u32); +class GBMemoryViewer : public MemoryViewer +{ + public: + GBMemoryViewer(); + virtual void readData(u32, int, u8 *); + virtual void editData(u32, int, int, u32); }; ///////////////////////////////////////////////////////////////////////////// @@ -22,54 +23,52 @@ class GBMemoryViewer : public MemoryViewer { class GBMemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg { - GBMemoryViewer m_viewer; - bool autoUpdate; - // Construction - public: - void setCurrentAddress(u32 address); - GBMemoryViewerDlg(CWnd* pParent = NULL); // standard constructor + GBMemoryViewer m_viewer; + bool autoUpdate; + // Construction + public: + void setCurrentAddress(u32 address); + GBMemoryViewerDlg(CWnd *pParent = NULL); // standard constructor - virtual void update(); + virtual void update(); - // Dialog Data - //{{AFX_DATA(GBMemoryViewerDlg) - enum { IDD = IDD_MEM_VIEWER }; - CEdit m_current; - CEdit m_address; - CComboBox m_addresses; - int m_size; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBMemoryViewerDlg) + enum { IDD = IDD_MEM_VIEWER }; + CEdit m_current; + CEdit m_address; + CComboBox m_addresses; + int m_size; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBMemoryViewerDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBMemoryViewerDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBMemoryViewerDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void On8Bit(); + afx_msg void On16Bit(); + afx_msg void On32Bit(); + afx_msg void OnAutoUpdate(); + afx_msg void OnGo(); + afx_msg void OnSelchangeAddresses(); + afx_msg void OnSave(); + afx_msg void OnLoad(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBMemoryViewerDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnClose(); - afx_msg void OnRefresh(); - afx_msg void On8Bit(); - afx_msg void On16Bit(); - afx_msg void On32Bit(); - afx_msg void OnAutoUpdate(); - afx_msg void OnGo(); - afx_msg void OnSelchangeAddresses(); - afx_msg void OnSave(); - afx_msg void OnLoad(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBMEMORYVIEWERDLG_H__23AD2804_EFA5_4900_AEC5_47196A41C50D__INCLUDED_) diff --git a/src/win32/GBOamView.h b/src/win32/GBOamView.h index 8a98e0a5..802d40bf 100644 --- a/src/win32/GBOamView.h +++ b/src/win32/GBOamView.h @@ -8,8 +8,8 @@ // #include "BitmapControl.h" -#include "ZoomControl.h" #include "ColorControl.h" +#include "ZoomControl.h" #include "IUpdate.h" #include "ResizeDlg.h" @@ -19,66 +19,63 @@ class GBOamView : public ResizeDlg, IUpdateListener { - private: - BITMAPINFO bmpInfo; - u8 *data; - int w; - int h; - int number; - bool autoUpdate; - BitmapControl oamView; - ZoomControl oamZoom; - ColorControl color; + private: + BITMAPINFO bmpInfo; + u8 *data; + int w; + int h; + int number; + bool autoUpdate; + BitmapControl oamView; + ZoomControl oamZoom; + ColorControl color; + // Construction + public: + void updateScrollInfo(); + void save(); + void savePNG(const char *name); + void saveBMP(const char *name); + void render(); + void setAttributes(int y, int x, int tile, int flags); + void paint(); + ~GBOamView(); + GBOamView(CWnd *pParent = NULL); // standard constructor - // Construction - public: - void updateScrollInfo(); - void save(); - void savePNG(const char *name); - void saveBMP(const char *name); - void render(); - void setAttributes(int y, int x, int tile, int flags); - void paint(); - ~GBOamView(); - GBOamView(CWnd* pParent = NULL); // standard constructor + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual void update(); - afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); - virtual void update(); + // Dialog Data + //{{AFX_DATA(GBOamView) + enum { IDD = IDD_GB_OAM_VIEW }; + CEdit m_sprite; + BOOL m_stretch; + //}}AFX_DATA - // Dialog Data - //{{AFX_DATA(GBOamView) - enum { IDD = IDD_GB_OAM_VIEW }; - CEdit m_sprite; - BOOL m_stretch; - //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBOamView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBOamView) + virtual BOOL OnInitDialog(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnChangeSprite(); + afx_msg void OnClose(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBOamView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBOamView) - virtual BOOL OnInitDialog(); - afx_msg void OnStretch(); - afx_msg void OnAutoUpdate(); - afx_msg void OnChangeSprite(); - afx_msg void OnClose(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBOAMVIEW_H__FE8105E6_9693_479A_8C57_DEEA1B2EA3D6__INCLUDED_) diff --git a/src/win32/GBPaletteView.h b/src/win32/GBPaletteView.h index 9f2b51f9..b66fea9f 100644 --- a/src/win32/GBPaletteView.h +++ b/src/win32/GBPaletteView.h @@ -12,9 +12,10 @@ #include "PaletteViewControl.h" #include "ResizeDlg.h" -class GBPaletteViewControl : public PaletteViewControl { - public: - virtual void updatePalette(); +class GBPaletteViewControl : public PaletteViewControl +{ + public: + virtual void updatePalette(); }; ///////////////////////////////////////////////////////////////////////////// @@ -22,50 +23,49 @@ class GBPaletteViewControl : public PaletteViewControl { class GBPaletteView : public ResizeDlg, IUpdateListener { - private: - GBPaletteViewControl paletteView; - GBPaletteViewControl paletteViewOBJ; - ColorControl colorControl; - bool autoUpdate; - // Construction - public: - void save(int which); - GBPaletteView(CWnd* pParent = NULL); // standard constructor - virtual ~GBPaletteView(); + private: + GBPaletteViewControl paletteView; + GBPaletteViewControl paletteViewOBJ; + ColorControl colorControl; + bool autoUpdate; + // Construction + public: + void save(int which); + GBPaletteView(CWnd *pParent = NULL); // standard constructor + virtual ~GBPaletteView(); - // Dialog Data - //{{AFX_DATA(GBPaletteView) - enum { IDD = IDD_GB_PALETTE_VIEW }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBPaletteView) + enum { IDD = IDD_GB_PALETTE_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBPaletteView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBPaletteView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + virtual void update(); - virtual void update(); + // Implementation + protected: + afx_msg virtual LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); + // Generated message map functions + //{{AFX_MSG(GBPaletteView) + virtual BOOL OnInitDialog(); + afx_msg void OnSaveBg(); + afx_msg void OnSaveObj(); + afx_msg void OnRefresh2(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - afx_msg virtual LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); - // Generated message map functions - //{{AFX_MSG(GBPaletteView) - virtual BOOL OnInitDialog(); - afx_msg void OnSaveBg(); - afx_msg void OnSaveObj(); - afx_msg void OnRefresh2(); - afx_msg void OnAutoUpdate(); - afx_msg void OnClose(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBPALETTEVIEW_H__F909FF55_3021_4301_B017_0C2C9D8D8C08__INCLUDED_) diff --git a/src/win32/GBPrinterDlg.h b/src/win32/GBPrinterDlg.h index fd4261a3..14c13f4d 100644 --- a/src/win32/GBPrinterDlg.h +++ b/src/win32/GBPrinterDlg.h @@ -12,52 +12,50 @@ class GBPrinterDlg : public CDialog { - private: - u8 bitmapHeader[sizeof(BITMAPINFO)+4*sizeof(RGBQUAD)]; - BITMAPINFO *bitmap; - u8 *bitmapData; - int scale; - // Construction - public: - void processData(u8 *data); - void saveAsPNG(const char *name); - void saveAsBMP(const char *name); - GBPrinterDlg(CWnd* pParent = NULL); // standard constructor - ~GBPrinterDlg(); + private: + u8 bitmapHeader[sizeof(BITMAPINFO) + 4 * sizeof(RGBQUAD)]; + BITMAPINFO *bitmap; + u8 *bitmapData; + int scale; + // Construction + public: + void processData(u8 *data); + void saveAsPNG(const char *name); + void saveAsBMP(const char *name); + GBPrinterDlg(CWnd *pParent = NULL); // standard constructor + ~GBPrinterDlg(); - // Dialog Data - //{{AFX_DATA(GBPrinterDlg) - enum { IDD = IDD_GB_PRINTER }; - int m_scale; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBPrinterDlg) + enum { IDD = IDD_GB_PRINTER }; + int m_scale; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBPrinterDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBPrinterDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GBPrinterDlg) + afx_msg void OnSave(); + afx_msg void OnPrint(); + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void On1x(); + afx_msg void On2x(); + afx_msg void On3x(); + afx_msg void On4x(); + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GBPrinterDlg) - afx_msg void OnSave(); - afx_msg void OnPrint(); - virtual BOOL OnInitDialog(); - afx_msg void OnOk(); - afx_msg void On1x(); - afx_msg void On2x(); - afx_msg void On3x(); - afx_msg void On4x(); - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBPRINTER_H__3180CC5A_1F9D_47E5_B044_407442CB40A4__INCLUDED_) diff --git a/src/win32/GBTileView.h b/src/win32/GBTileView.h index b3974d9a..29261a3e 100644 --- a/src/win32/GBTileView.h +++ b/src/win32/GBTileView.h @@ -17,69 +17,68 @@ class GBTileView : public ResizeDlg, IUpdateListener { - int charBase; - int palette; - int bank; - BitmapControl tileView; - BITMAPINFO bmpInfo; - u8 *data; - ZoomControl zoom; - ColorControl color; - int w; - int h; - bool autoUpdate; - // Construction - public: - void paint(); - void render(); - void renderTile(int tile, int x, int y, u8 *charBase); - void savePNG(const char *name); - void saveBMP(const char *name); - GBTileView(CWnd* pParent = NULL); // standard constructor - virtual ~GBTileView(); + int charBase; + int palette; + int bank; + BitmapControl tileView; + BITMAPINFO bmpInfo; + u8 *data; + ZoomControl zoom; + ColorControl color; + int w; + int h; + bool autoUpdate; + // Construction + public: + void paint(); + void render(); + void renderTile(int tile, int x, int y, u8 *charBase); + void savePNG(const char *name); + void saveBMP(const char *name); + GBTileView(CWnd *pParent = NULL); // standard constructor + virtual ~GBTileView(); - virtual void update(); + virtual void update(); - // Dialog Data - //{{AFX_DATA(GBTileView) - enum { IDD = IDD_GB_TILE_VIEWER }; - CSliderCtrl m_slider; - int m_charBase; - int m_bank; - BOOL m_stretch; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GBTileView) + enum { IDD = IDD_GB_TILE_VIEWER }; + CSliderCtrl m_slider; + int m_charBase; + int m_bank; + BOOL m_stretch; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GBTileView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GBTileView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); - // Implementation - protected: - virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); - virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + // Generated message map functions + //{{AFX_MSG(GBTileView) + afx_msg void OnSave(); + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnAutoUpdate(); + afx_msg void OnCharbase0(); + afx_msg void OnCharbase1(); + afx_msg void OnBank0(); + afx_msg void OnBank1(); + afx_msg void OnStretch(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Generated message map functions - //{{AFX_MSG(GBTileView) - afx_msg void OnSave(); - virtual BOOL OnInitDialog(); - afx_msg void OnClose(); - afx_msg void OnAutoUpdate(); - afx_msg void OnCharbase0(); - afx_msg void OnCharbase1(); - afx_msg void OnBank0(); - afx_msg void OnBank1(); - afx_msg void OnStretch(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GBTILEVIEW_H__C8C8DEBB_17ED_4C5C_9DBE_D730A49B312C__INCLUDED_) diff --git a/src/win32/GDBConnection.h b/src/win32/GDBConnection.h index 723804f3..5dba77da 100644 --- a/src/win32/GDBConnection.h +++ b/src/win32/GDBConnection.h @@ -14,82 +14,78 @@ class GDBPortDlg : public CDialog { - int port; - SOCKET sock; - // Construction - public: - SOCKET getSocket(); - int getPort(); - GDBPortDlg(CWnd* pParent = NULL); // standard constructor + int port; + SOCKET sock; + // Construction + public: + SOCKET getSocket(); + int getPort(); + GDBPortDlg(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GDBPortDlg) - enum { IDD = IDD_GDB_PORT }; - CEdit m_port; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GDBPortDlg) + enum { IDD = IDD_GDB_PORT }; + CEdit m_port; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GDBPortDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GDBPortDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GDBPortDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void OnCancel(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GDBPortDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnOk(); - afx_msg void OnCancel(); - afx_msg void OnClose(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // GDBWaitingDlg dialog class GDBWaitingDlg : public CDialog { - int port; - SOCKET listenSocket; - SOCKET sock; - // Construction - public: - SOCKET getSocket(); - SOCKET getListenSocket(); - afx_msg LRESULT OnSocketAccept(WPARAM wParam, LPARAM lParam); - GDBWaitingDlg(int p, CWnd* pParent = NULL); // standard constructor + int port; + SOCKET listenSocket; + SOCKET sock; + // Construction + public: + SOCKET getSocket(); + SOCKET getListenSocket(); + afx_msg LRESULT OnSocketAccept(WPARAM wParam, LPARAM lParam); + GDBWaitingDlg(int p, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GDBWaitingDlg) - enum { IDD = IDD_GDB_WAITING }; - CStatic m_port; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GDBWaitingDlg) + enum { IDD = IDD_GDB_WAITING }; + CStatic m_port; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GDBWaitingDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GDBWaitingDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GDBWaitingDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnClose(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GDBWaitingDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GDBCONNECTION_H__DD73B298_E1A7_4A46_B282_E7A2B37FC9D9__INCLUDED_) diff --git a/src/win32/GSACodeSelect.h b/src/win32/GSACodeSelect.h index a0a5959a..e64dc73d 100644 --- a/src/win32/GSACodeSelect.h +++ b/src/win32/GSACodeSelect.h @@ -12,39 +12,37 @@ class GSACodeSelect : public CDialog { - // Construction - public: - GSACodeSelect(FILE *file, CWnd* pParent = NULL); // standard constructor + // Construction + public: + GSACodeSelect(FILE *file, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(GSACodeSelect) - enum { IDD = IDD_CODE_SELECT }; - CListBox m_games; - //}}AFX_DATA - FILE *m_file; + // Dialog Data + //{{AFX_DATA(GSACodeSelect) + enum { IDD = IDD_CODE_SELECT }; + CListBox m_games; + //}}AFX_DATA + FILE *m_file; + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GSACodeSelect) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GSACodeSelect) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GSACodeSelect) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnSelchangeGameList(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(GSACodeSelect) - afx_msg void OnCancel(); - afx_msg void OnOk(); - afx_msg void OnSelchangeGameList(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_GSACODESELECT_H__189BD94D_288F_4E2A_9395_EAB16F104D87__INCLUDED_) diff --git a/src/win32/GameOverrides.h b/src/win32/GameOverrides.h index 3fe6b232..4abd4866 100644 --- a/src/win32/GameOverrides.h +++ b/src/win32/GameOverrides.h @@ -31,41 +31,39 @@ class GameOverrides : public CDialog { -// Construction -public: - GameOverrides(CWnd* pParent = NULL); // standard constructor + // Construction + public: + GameOverrides(CWnd *pParent = NULL); // standard constructor -// Dialog Data - //{{AFX_DATA(GameOverrides) - enum { IDD = IDD_GAME_OVERRIDES }; - CEdit m_name; - CComboBox m_mirroring; - CComboBox m_flashSize; - CComboBox m_saveType; - CComboBox m_rtc; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(GameOverrides) + enum { IDD = IDD_GAME_OVERRIDES }; + CEdit m_name; + CComboBox m_mirroring; + CComboBox m_flashSize; + CComboBox m_saveType; + CComboBox m_rtc; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(GameOverrides) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(GameOverrides) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(GameOverrides) - virtual void OnOK(); - afx_msg void OnDefaults(); - virtual void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - CEdit m_comment; + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(GameOverrides) + virtual void OnOK(); + afx_msg void OnDefaults(); + virtual void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + CEdit m_comment; }; //{{AFX_INSERT_LOCATION}} diff --git a/src/win32/Hyperlink.h b/src/win32/Hyperlink.h index 6fcf0114..07bd97d1 100644 --- a/src/win32/Hyperlink.h +++ b/src/win32/Hyperlink.h @@ -12,40 +12,38 @@ class Hyperlink : public CStatic { -// Construction -public: - Hyperlink(); + // Construction + public: + Hyperlink(); -// Attributes -public: + // Attributes + public: + // Operations + public: + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Hyperlink) + protected: + virtual void PreSubclassWindow(); + //}}AFX_VIRTUAL -// Operations -public: + // Implementation + public: + bool m_over; + HCURSOR m_cursor; + afx_msg void OnClicked(); + CFont m_underlineFont; + virtual ~Hyperlink(); -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(Hyperlink) - protected: - virtual void PreSubclassWindow(); - //}}AFX_VIRTUAL + // Generated message map functions + protected: + //{{AFX_MSG(Hyperlink) + afx_msg HBRUSH CtlColor(CDC *pDC, UINT nCtlColor); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + //}}AFX_MSG -// Implementation -public: - bool m_over; - HCURSOR m_cursor; - afx_msg void OnClicked(); - CFont m_underlineFont; - virtual ~Hyperlink(); - - // Generated message map functions -protected: - //{{AFX_MSG(Hyperlink) - afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - //}}AFX_MSG - - DECLARE_MESSAGE_MAP() + DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/IOViewer.h b/src/win32/IOViewer.h index a6782d18..7b135a91 100644 --- a/src/win32/IOViewer.h +++ b/src/win32/IOViewer.h @@ -7,54 +7,52 @@ // IOViewer.h : header file // -#include "ResizeDlg.h" #include "IUpdate.h" +#include "ResizeDlg.h" ///////////////////////////////////////////////////////////////////////////// // IOViewer dialog class IOViewer : public ResizeDlg, IUpdateListener { - // Construction - public: - void update(); - void bitChange(); - bool autoUpdate; - int selected; - IOViewer(CWnd* pParent = NULL); // standard constructor + // Construction + public: + void update(); + void bitChange(); + bool autoUpdate; + int selected; + IOViewer(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(IOViewer) - enum { IDD = IDD_IO_VIEWER }; - CStatic m_value; - CComboBox m_address; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(IOViewer) + enum { IDD = IDD_IO_VIEWER }; + CStatic m_value; + CComboBox m_address; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(IOViewer) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(IOViewer) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(IOViewer) + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void OnAutoUpdate(); + afx_msg void OnSelchangeAddresses(); + virtual BOOL OnInitDialog(); + afx_msg void OnApply(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(IOViewer) - afx_msg void OnClose(); - afx_msg void OnRefresh(); - afx_msg void OnAutoUpdate(); - afx_msg void OnSelchangeAddresses(); - virtual BOOL OnInitDialog(); - afx_msg void OnApply(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_IOVIEWER_H__9C266B78_FC02_4572_9062_0241802B0E76__INCLUDED_) diff --git a/src/win32/IOViewerRegs.h b/src/win32/IOViewerRegs.h index ba3c27dd..79595d6c 100644 --- a/src/win32/IOViewerRegs.h +++ b/src/win32/IOViewerRegs.h @@ -1,2068 +1,1708 @@ struct IOData { - u16 *address; - u16 offset; - char *name; - u16 write; - char *bits[16]; + u16 *address; + u16 offset; + char *name; + u16 write; + char *bits[16]; }; -const IOData ioViewRegisters[] = { - { - &DISPCNT, 0, "0x4000000-DISPCNT", 0xFFF7, - { - "", - "", - "BG Mode (3 bits)", - "CGB Mode", - "Display Frame", - "H-Blank Interval OBJ processing", - "OBJ Character mapping", - "Forced blank", - "BG0", - "BG1", - "BG2", - "BG3", - "OBJ", - "WIN0", - "WIN1", - "OBJWIN" - } - }, - { - &DISPSTAT, 4, "0x4000004-DISPSTAT", 0xFF38, - { - "V-Blank Status", - "H-Blank Status", - "VCOUNT Evaluation", - "V-Blank Interrupt Enable", - "H-Blank Interrupt Enable", - "VCOUNT Match Interrupt Enable", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "VCOUNT setting (8 bits)" - } - }, - { - &VCOUNT, 6, "0x4000006-VCOUNT", 0x0000, - { - "", - "", - "", - "", - "", - "", - "", - "VCOUNT (8 bits)", - "", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG0CNT, 8, "0x4000008-BG0CNT", 0xDFCF, - { - "", - "Priority (2 bits)", - "", - "Char base (2 bits)", - "", - "", - "Mosaic", - "16/256 colors", - "", - "", - "", - "", - "Screen Base Block (5 bits)", - "", - "", - "Size (2 bits)" - } - }, - { - &BG1CNT, 0xA, "0x400000A-BG1CNT", 0xDFCF, - { - "", - "Priority (2 bits)", - "", - "Char base (2 bits)", - "", - "", - "Mosaic", - "16/256 colors", - "", - "", - "", - "", - "Screen Base Block (5 bits)", - "", - "", - "Size (2 bits)" - } - }, - { - &BG2CNT, 0xC, "0x400000C-BG2CNT", 0xFFCF, - { - "", - "Priority (2 bits)", - "", - "Char base (2 bits)", - "", - "", - "Mosaic", - "16/256 colors", - "", - "", - "", - "", - "Screen Base Block (5 bits)", - "Area Overflow", - "", - "Size (2 bits)" - } - }, - { - &BG3CNT, 0xE, "0x400000E-BG3CNT", 0xFFCF, - { - "", - "Priority (2 bits)", - "", - "Char base (2 bits)", - "", - "", - "Mosaic", - "16/256 colors", - "", - "", - "", - "", - "Screen Base Block (5 bits)", - "Area Overflow", - "", - "Size (2 bits)" - } - }, - { - &BG0HOFS, 0x10, "0x4000010-BG0HOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Horizontal Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG0VOFS, 0x12, "0x4000012-BG0VOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Vertical Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG1HOFS, 0x14, "0x4000014-BG1HOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Horizontal Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG1VOFS, 0x16, "0x4000016-BG1VOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Vertical Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG2HOFS, 0x18, "0x4000018-BG2HOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Horizontal Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG2VOFS, 0x1A, "0x400001A-BG2VOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Vertical Offset (9 bits, W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG3HOFS, 0x1C, "0x400001C-BG3HOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Horizontal Offset (9 bits,W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG3VOFS, 0x1E, "0x400001E-BG3VOFS", 0x01FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "Vertical Offset (9 bits,W)", - "", - "", - "", - "", - "", - "", - "" - } - }, - { - &BG2PA, 0x20, "0x4000020-BG2PA", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dx (16 bits,W)" - } - }, - { - &BG2PB, 0x22, "0x4000022-BG2PB", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dmx (16 bits,W)" - } - }, - { - &BG2PC, 0x24, "0x4000024-BG2PC", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dy (16 bits,W)" - } - }, - { - &BG2PD, 0x26, "0x4000026-BG2PD", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dmy (16 bits,W)" - } - }, - { - &BG2X_L, 0x28, "0x4000028-BG2X_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "X low bits (16 bits,W)" - } - }, - { - &BG2X_H, 0x2A, "0x400002A-BG2X_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "X high bits (12 bits,W)", - "", - "", - "", - "", - } - }, - { - &BG2Y_L, 0x2C, "0x400002C-BG2Y_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Y low bits (16 bits,W)" - } - }, - { - &BG2Y_H, 0x2E, "0x400002E-BG2Y_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Y hight bits (12 bits,W)", - "", - "", - "", - "", - } - }, - { - &BG3PA, 0x30, "0x4000030-BG3PA", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dx (16 bits,W)" - } - }, - { - &BG3PB, 0x32, "0x4000032-BG3PB", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dmx (16 bits,W)" - } - }, - { - &BG3PC, 0x34, "0x4000034-BG3PC", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dy (16 bits,W)" - } - }, - { - &BG3PD, 0x36, "0x4000036-BG3PD", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "dmy (16 bits,W)" - } - }, - { - &BG3X_L, 0x38, "0x4000038-BG3X_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "X low bits (16 bits,W)" - } - }, - { - &BG3X_H, 0x3A, "0x400003A-BG3X_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "X hight bits (12 bits,W)", - "", - "", - "", - "", - } - }, - { - &BG3Y_L, 0x3C, "0x400003C-BG3Y_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Y low bits (16 bits,W)" - } - }, - { - &BG3Y_H, 0x3E, "0x400003E-BG3Y_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Y hight bits (12 bits,W)", - "", - "", - "", - "", - } - }, - { - &WIN0H, 0x40, "0x4000040-WIN0H", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Win 0 lower-right X (8 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "Win 0 upper-left X (8 bits,W)", - } - }, - { - &WIN1H, 0x42, "0x4000042-WIN1H", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Win 1 lower-right X (8 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "Win 1 upper-left (8 bits,W)", - } - }, - { - &WIN0V, 0x44, "0x4000044-WIN0V", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Win 0 lower-right Y (8 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "Win 0 upper-left Y (8 bits,W)", - } - }, - { - &WIN1V, 0x46, "0x4000046-WIN1V", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Win 1 lower-right Y (8 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "Win 1 upper-left Y (8 bits,W)", - } - }, - { - &WININ, 0x48, "0x4000048-WININ", 0x3F3F, - { - "WIN0 BG0", - "WIN0 BG1", - "WIN0 BG2", - "WIN0 BG3", - "WIN0 OBJ", - "WIN0 Special FX", - "", - "", - "WIN1 BG0", - "WIN1 BG1", - "WIN1 BG2", - "WIN1 BG3", - "WIN1 OBJ", - "WIN1 Special FX", - "", - "", - } - }, - { - &WINOUT, 0x4A, "0x400004A-WINOUT", 0x3F3F, - { - "WIN0/1 BG0", - "WIN0/1 BG1", - "WIN0/1 BG2", - "WIN0/1 BG3", - "WIN0/1 OBJ", - "WIN0/1 Special FX", - "", - "", - "OBJWIN BG0", - "OBJWIN BG1", - "OBJWIN BG2", - "OBJWIN BG3", - "OBJWIN OBJ", - "OBJWIN Special FX", - "", - "", - } - }, - { - &MOSAIC, 0x4C, "0x400004C-MOSAIC", 0xFFFF, - { - "", - "", - "", - "BG H Size (4 bits,W)", - "", - "", - "", - "BG V Size (4 bits,W)", - "", - "", - "", - "OBJ H Size (4 bits,W)", - "", - "", - "", - "OBJ V Size (4 bits,W)", - } - }, - { - &BLDMOD, 0x50, "0x4000050-BLDMOD", 0x3FFF, - { - "1st BG0", - "1st BG1", - "1st BG2", - "1st BG3", - "1st OBJ", - "1st BD", - "", - "FX Type (2 bits)", - "2nd BG0", - "2nd BG1", - "2nd BG2", - "2nd BG3", - "2nd OBJ", - "2nd BD", - "", - "", - } - }, - { - &COLEV, 0x52, "0x4000052-COLEV", 0x1F1F, - { - "", - "", - "", - "", - "Coefficient EVA (5 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "Coefficient EVB (5 bits,W)", - "", - "", - "", - } - }, - { - &COLY, 0x54, "0x4000054-COLEY", 0x001F, - { - "", - "", - "", - "", - "Coefficient EVY (5 bits,W)", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x60, "0x4000060-SG10_L", 0x007F, - { - "", - "", - "Sweep Shifts (3 bits)", - "Sweep addition/decrease", - "", - "", - "Sweep Time (3 bits)", - "", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x62, "0x4000062-SG10_H", 0xFFFF, - { - "", - "", - "", - "", - "", - "Sound Length (6 bits,W)", - "", - "Waveform Type (2 bits)", - "", - "", - "Envelope Steps (3 bits)", - "Envelope Attenuate/Amplify", - "", - "", - "", - "Envelope Initial Value", - } - }, - { - NULL, 0x64, "0x4000064-SG11", 0xC7FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Frequency (11 bits,W)", - "", - "", - "", - "Sound Continuous/Counter", - "Initialization (W)", - } - }, - { - NULL, 0x68, "0x4000068-SG20", 0xFFFF, - { - "", - "", - "", - "", - "", - "Sound Length (6 bits,W)", - "", - "Waveform Type (2 bits)", - "", - "", - "Envelope Steps (3 bits)", - "Envelope Attenuate/Amplify", - "", - "", - "", - "Envelope Initial Value", - } - }, - { - NULL, 0x6C, "0x400006C-SG21", 0xC7FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Frequency (11 bits,W)", - "", - "", - "", - "Sound Continuous/Counter", - "Initialization (W)", - } - }, - { - NULL, 0x70, "0x4000070-SG30_L", 0x00E0, - { - "", - "", - "", - "", - "", - "Waveform 32/64 Steps", - "Waveform Bank 0/1", - "Sound Output", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x72, "0x4000072-SG30_H", 0xE0FF, - { - "", - "", - "", - "", - "", - "", - "", - "Sound Length (8 bits,W)", - "", - "", - "", - "", - "", - "", - "Output Level (2 bits)", - "Forced 3/4 Output Level", - } - }, - { - NULL, 0x74, "0x4000074-SG31", 0xC7FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Frequency (11 bits,W)", - "", - "", - "", - "Sound Continuous/Counter", - "Initialization (W)", - } - }, - { - NULL, 0x78, "0x4000078-SG40", 0xFF3F, - { - "", - "", - "", - "", - "", - "Sound Length (6 bits,W)", - "", - "", - "", - "", - "Envelope Steps (3 bits)", - "Envelope Attenuate/Amplify", - "", - "", - "", - "Envelope Initial Value", - } - }, - { - NULL, 0x7C, "0x400007C-SG41", 0xC0FF, - { - "", - "", - "Dividing Ratio Freq. (3 bits)", - "Counter 15/7 Steps", - "", - "", - "", - "Counter Shift Clock (4 bits)", - "", - "", - "", - "", - "", - "", - "Sound Continuous/Counter", - "Initialization (W)", - } - }, - { - NULL, 0x80, "0x4000080-SGCNT0_L", 0xFF77, - { - "", - "", - "Right Volume (3 bits)", - "", - "", - "", - "Left Volume (3 bits)", - "", - "Channel 1->Right", - "Channel 2->Right", - "Channel 3->Right", - "Channel 4->Right", - "Channel 1->Left", - "Channel 2->Left", - "Channel 3->Left", - "Channel 4->Left", - } - }, - { - NULL, 0x82, "0x4000082-SGCNT0_H", 0xFF0F, - { - "", - "Sound 1-4 Volume (2 bits)", - "DMA Sound A Volume", - "DMA Sound B Volume", - "", - "", - "", - "", - "DMA Sound A->Right", - "DMA Sound A->Left", - "DMA Sound A Timer", - "DMA Sound A Reset FIFO", - "DMA Sound B->Right", - "DMA Sound B->Left", - "DMA Sound B Timer", - "DMA Sound B Reset FIFO", - } - }, - { - NULL, 0x84, "0x4000084-SGCNT1", 0x0080, - { - "Sound 1 On", - "Sound 2 On", - "Sound 3 On", - "Sound 4 On", - "", - "", - "", - "Master Sound Enable", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x88, "0x4000088-SGBIAS", 0xC3FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Bias Level (10 bits)", - "", - "", - "", - "", - "", - "Sampling Rate (2 bits)", - } - }, - { - NULL, 0xA0, "0x40000A0-SIGFIFOA_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Data 0 (8 bits)", - "", - "", - "", - "", - "", - "", - "", - "Data 1 (8 bits)", - } - }, - { - NULL, 0xA2, "0x40000A2-SIGFIFOA_H", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Data 2 (8 bits)", - "", - "", - "", - "", - "", - "", - "", - "Data 3 (8 bits)", - } - }, - { - NULL, 0xA4, "0x40000A4-SIGFIFOB_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Data 0 (8 bits)", - "", - "", - "", - "", - "", - "", - "", - "Data 1 (8 bits)", - } - }, - { - NULL, 0xA6, "0x40000A6-SIGFIFOB_H", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "Data 2 (8 bits)", - "", - "", - "", - "", - "", - "", - "", - "Data 3 (8 bits)", - } - }, - { - &DM0SAD_L, 0xB0, "0x40000B0-DM0SAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (lower 16 bits)", - } - }, - { - &DM0SAD_H, 0xB2, "0x40000B2-DM0SAD_H", 0x07FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (upper 11 bits)", - "", - "", - "", - "", - "", - } - }, - { - &DM0DAD_L, 0xB4, "0x40000B4-DM0DAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (lower 16 bits)", - } - }, - { - &DM0DAD_H, 0xB6, "0x40000B6-DM0DAD_H", 0x07FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (upper 11 bits)", - "", - "", - "", - "", - "", - } - }, - { - &DM0CNT_L, 0xB8, "0x40000B8-DM0CNT_L", 0x3FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Count (14 bits)", - "", - "", - } - }, - { - &DM0CNT_H, 0xBA, "0x40000BA-DM0CNT_H", 0xF7E0, - { - "", - "", - "", - "", - "", - "", - "Destination Address Control (2 bits)", - "", - "Source Address Control (2 bits)", - "Repeat", - "Transfer Type", - "", - "", - "Start Timing (2 bits)", - "Interrupt Request", - "Enable", - } - }, - { - &DM1SAD_L, 0xBC, "0x40000BC-DM1SAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (lower 16 bits)", - } - }, - { - &DM1SAD_H, 0xBE, "0x40000BE-DM1SAD_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (upper 12 bits)", - "", - "", - "", - "", - } - }, - { - &DM1DAD_L, 0xC0, "0x40000C0-DM1DAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (lower 16 bits)", - } - }, - { - &DM1DAD_H, 0xC2, "0x40000C2-DM1DAD_H", 0x07FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (upper 11 bits)", - "", - "", - "", - "", - "", - } - }, - { - &DM1CNT_L, 0xC4, "0x40000C4-DM1CNT_L", 0x3FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Count (14 bits)", - "", - "", - } - }, - { - &DM1CNT_H, 0xC6, "0x40000C6-DM1CNT_H", 0xF7E0, - { - "", - "", - "", - "", - "", - "", - "Destination Address Control (2 bits)", - "", - "Source Address Control (2 bits)", - "Repeat", - "Transfer Type", - "", - "", - "Start Timing (2 bits)", - "Interrupt Request", - "Enable", - } - }, - { - &DM2SAD_L, 0xC8, "0x40000C8-DM2SAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (lower 16 bits)", - } - }, - { - &DM2SAD_H, 0xCA, "0x40000CA-DM2SAD_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (upper 12 bits)", - "", - "", - "", - "", - } - }, - { - &DM2DAD_L, 0xCC, "0x40000CC-DM2DAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (lower 16 bits)", - } - }, - { - &DM2DAD_H, 0xCE, "0x40000CE-DM2DAD_H", 0x07FF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (upper 11 bits)", - "", - "", - "", - "", - "", - } - }, - { - &DM2CNT_L, 0xD0, "0x40000D0-DM2CNT_L", 0x3FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Count (14 bits)", - "", - "", - } - }, - { - &DM2CNT_H, 0xD2, "0x40000D2-DM2CNT_H", 0xF7E0, - { - "", - "", - "", - "", - "", - "", - "Destination Address Control (2 bits)", - "", - "Source Address Control (2 bits)", - "Repeat", - "Transfer Type", - "", - "", - "Start Timing (2 bits)", - "Interrupt Request", - "Enable", - } - }, - { - &DM3SAD_L, 0xD4, "0x40000D4-DM3SAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (lower 16 bits)", - } - }, - { - &DM3SAD_H, 0xD6, "0x40000D6-DM3SAD_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Source Address (upper 12 bits)", - "", - "", - "", - "", - } - }, - { - &DM3DAD_L, 0xD8, "0x40000D8-DM3DAD_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (lower 16 bits)", - } - }, - { - &DM3DAD_H, 0xDA, "0x40000DA-DM3DAD_H", 0x0FFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Destination Address (upper 12 bits)", - "", - "", - "", - "", - } - }, - { - &DM3CNT_L, 0xDC, "0x40000DC-DM3CNT_L", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Count (16 bits)", - } - }, - { - &DM3CNT_H, 0xDE, "0x40000DE-DM3CNT_H", 0xFFE0, - { - "", - "", - "", - "", - "", - "", - "Destination Address Control (2 bits)", - "", - "Source Address Control (2 bits)", - "Repeat", - "Transfer Type", - "Game Pak Data Request", - "", - "Start Timing (2 bits)", - "Interrupt Request", - "Enable", - } - }, - { - &TM0D, 0x100, "0x4000100-TM0D", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Timer Counter (16 bits)", - } - }, - { - &TM0CNT, 0x102, "0x4000102-TM0CNT", 0x00C7, - { - "", - "Scalar Selection (2 bits)", - "Count Up", - "", - "", - "", - "Interrupt Request", - "Enable", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - &TM1D, 0x104, "0x4000104-TM1D", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Timer Counter (16 bits)", - } - }, - { - &TM1CNT, 0x106, "0x4000106-TM1CNT", 0x00C7, - { - "", - "Scalar Selection (2 bits)", - "Count Up", - "", - "", - "", - "Interrupt Request", - "Enable", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - &TM2D, 0x108, "0x4000108-TM2D", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Timer Counter (16 bits)", - } - }, - { - &TM2CNT, 0x10A, "0x400010A-TM2CNT", 0x00C7, - { - "", - "Scalar Selection (2 bits)", - "Count Up", - "", - "", - "", - "Interrupt Request", - "Enable", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - &TM3D, 0x10C, "0x400010C-TM3D", 0xFFFF, - { - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Timer Counter (16 bits)", - } - }, - { - &TM3CNT, 0x10E, "0x400010E-TM3CNT", 0x00C7, - { - "", - "Scalar Selection (2 bits)", - "Count Up", - "", - "", - "", - "Interrupt Request", - "Enable", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - &P1, 0x130, "0x4000130-P1", 0x03FF, - { - "A", - "B", - "Select", - "Start", - "Right", - "Left", - "Up", - "Down", - "Shoulder Right", - "Shoulder Left", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x132, "0x4000132-P1CNT", 0xC3FF, - { - "A", - "B", - "Select", - "Start", - "Right", - "Left", - "Up", - "Down", - "Shoulder Right", - "Shoulder Left", - "", - "", - "", - "", - "Interrupt Request", - "Interrupt Condition", - } - }, - { - &IE, 0x200, "0x4000200-IE", 0x3FFF, - { - "VBlank", - "HBlank", - "VCount", - "Timer 0", - "Timer 1", - "Timer 2", - "Timer 3", - "Serial", - "DMA 0", - "DMA 1", - "DMA 2", - "DMA 3", - "Keypad", - "Game Pak", - "", - "", - } - }, - { - &IF, 0x202, "0x4000202-IF", 0x0000, - { - "VBlank", - "HBlank", - "VCount", - "Timer 0", - "Timer 1", - "Timer 2", - "Timer 3", - "Serial", - "DMA 0", - "DMA 1", - "DMA 2", - "DMA 3", - "Keypad", - "Game Pak", - "", - "", - } - }, - { - NULL, 0x204, "0x4000204-WAITCNT", 0x5FFF, - { - "", - "SRAM Wait Control (2 bits)", - "", - "Wait State 0 First Access (2 bits)", - "Wait State 0 Second Access", - "", - "Wait State 1 First Access (2 bits)", - "Wait State 1 Second Access", - "", - "Wait State 2 First Access (2 bits)", - "Wait State 2 Second Access", - "", - "PHI Terminal Output (2 bits)", - "", - "Game Pak Prefetch Buffer", - "Game Pak Type Flag", - } - }, - { - &IME, 0x208, "0x4000208-IME", 0x0001, - { - "Master Interrupt Enable", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - } - }, - { - NULL, 0x300, "0x4000300-HALTCNT", 0x8001, - { - "First Boot", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "Power Down", - } - }, -}; +const IOData ioViewRegisters[] = + { + { &DISPCNT, + 0, + "0x4000000-DISPCNT", + 0xFFF7, + { "", + "", + "BG Mode (3 bits)", + "CGB Mode", + "Display Frame", + "H-Blank Interval OBJ processing", + "OBJ Character mapping", + "Forced blank", + "BG0", + "BG1", + "BG2", + "BG3", + "OBJ", + "WIN0", + "WIN1", + "OBJWIN" } }, + { &DISPSTAT, + 4, + "0x4000004-DISPSTAT", + 0xFF38, + { "V-Blank Status", + "H-Blank Status", + "VCOUNT Evaluation", + "V-Blank Interrupt Enable", + "H-Blank Interrupt Enable", + "VCOUNT Match Interrupt Enable", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "VCOUNT setting (8 bits)" } }, + { &VCOUNT, + 6, + "0x4000006-VCOUNT", + 0x0000, + { "", "", "", "", "", "", "", "VCOUNT (8 bits)", "", "", "", "", "", "", "", "" } }, + { &BG0CNT, + 8, + "0x4000008-BG0CNT", + 0xDFCF, + { "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "", + "", + "Size (2 bits)" } }, + { &BG1CNT, + 0xA, + "0x400000A-BG1CNT", + 0xDFCF, + { "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "", + "", + "Size (2 bits)" } }, + { &BG2CNT, + 0xC, + "0x400000C-BG2CNT", + 0xFFCF, + { "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "Area Overflow", + "", + "Size (2 bits)" } }, + { &BG3CNT, + 0xE, + "0x400000E-BG3CNT", + 0xFFCF, + { "", + "Priority (2 bits)", + "", + "Char base (2 bits)", + "", + "", + "Mosaic", + "16/256 colors", + "", + "", + "", + "", + "Screen Base Block (5 bits)", + "Area Overflow", + "", + "Size (2 bits)" } }, + { &BG0HOFS, + 0x10, + "0x4000010-BG0HOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG0VOFS, + 0x12, + "0x4000012-BG0VOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG1HOFS, + 0x14, + "0x4000014-BG1HOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG1VOFS, + 0x16, + "0x4000016-BG1VOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG2HOFS, + 0x18, + "0x4000018-BG2HOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG2VOFS, + 0x1A, + "0x400001A-BG2VOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits, W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG3HOFS, + 0x1C, + "0x400001C-BG3HOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Horizontal Offset (9 bits,W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG3VOFS, + 0x1E, + "0x400001E-BG3VOFS", + 0x01FF, + { "", + "", + "", + "", + "", + "", + "", + "", + "Vertical Offset (9 bits,W)", + "", + "", + "", + "", + "", + "", + "" } }, + { &BG2PA, + 0x20, + "0x4000020-BG2PA", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dx (16 bits,W)" } }, + { &BG2PB, + 0x22, + "0x4000022-BG2PB", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dmx (16 bits,W)" } }, + { &BG2PC, + 0x24, + "0x4000024-BG2PC", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dy (16 bits,W)" } }, + { &BG2PD, + 0x26, + "0x4000026-BG2PD", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dmy (16 bits,W)" } }, + { &BG2X_L, + 0x28, + "0x4000028-BG2X_L", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "X low bits (16 bits,W)" } }, + { &BG2X_H, + 0x2A, + "0x400002A-BG2X_H", + 0x0FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "X high bits (12 bits,W)", "", "", "", "", + } }, + { &BG2Y_L, + 0x2C, + "0x400002C-BG2Y_L", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Y low bits (16 bits,W)" } }, + { &BG2Y_H, + 0x2E, + "0x400002E-BG2Y_H", + 0x0FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "Y hight bits (12 bits,W)", "", "", "", "", + } }, + { &BG3PA, + 0x30, + "0x4000030-BG3PA", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dx (16 bits,W)" } }, + { &BG3PB, + 0x32, + "0x4000032-BG3PB", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dmx (16 bits,W)" } }, + { &BG3PC, + 0x34, + "0x4000034-BG3PC", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dy (16 bits,W)" } }, + { &BG3PD, + 0x36, + "0x4000036-BG3PD", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "dmy (16 bits,W)" } }, + { &BG3X_L, + 0x38, + "0x4000038-BG3X_L", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "X low bits (16 bits,W)" } }, + { &BG3X_H, + 0x3A, + "0x400003A-BG3X_H", + 0x0FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "X hight bits (12 bits,W)", "", "", "", "", + } }, + { &BG3Y_L, + 0x3C, + "0x400003C-BG3Y_L", + 0xFFFF, + { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Y low bits (16 bits,W)" } }, + { &BG3Y_H, + 0x3E, + "0x400003E-BG3Y_H", + 0x0FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "Y hight bits (12 bits,W)", "", "", "", "", + } }, + { &WIN0H, + 0x40, + "0x4000040-WIN0H", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 0 lower-right X (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 0 upper-left X (8 bits,W)", + } }, + { &WIN1H, + 0x42, + "0x4000042-WIN1H", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 1 lower-right X (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 1 upper-left (8 bits,W)", + } }, + { &WIN0V, + 0x44, + "0x4000044-WIN0V", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 0 lower-right Y (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 0 upper-left Y (8 bits,W)", + } }, + { &WIN1V, + 0x46, + "0x4000046-WIN1V", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Win 1 lower-right Y (8 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Win 1 upper-left Y (8 bits,W)", + } }, + { &WININ, + 0x48, + "0x4000048-WININ", + 0x3F3F, + { + "WIN0 BG0", + "WIN0 BG1", + "WIN0 BG2", + "WIN0 BG3", + "WIN0 OBJ", + "WIN0 Special FX", + "", + "", + "WIN1 BG0", + "WIN1 BG1", + "WIN1 BG2", + "WIN1 BG3", + "WIN1 OBJ", + "WIN1 Special FX", + "", + "", + } }, + { &WINOUT, + 0x4A, + "0x400004A-WINOUT", + 0x3F3F, + { + "WIN0/1 BG0", + "WIN0/1 BG1", + "WIN0/1 BG2", + "WIN0/1 BG3", + "WIN0/1 OBJ", + "WIN0/1 Special FX", + "", + "", + "OBJWIN BG0", + "OBJWIN BG1", + "OBJWIN BG2", + "OBJWIN BG3", + "OBJWIN OBJ", + "OBJWIN Special FX", + "", + "", + } }, + { &MOSAIC, + 0x4C, + "0x400004C-MOSAIC", + 0xFFFF, + { + "", + "", + "", + "BG H Size (4 bits,W)", + "", + "", + "", + "BG V Size (4 bits,W)", + "", + "", + "", + "OBJ H Size (4 bits,W)", + "", + "", + "", + "OBJ V Size (4 bits,W)", + } }, + { &BLDMOD, + 0x50, + "0x4000050-BLDMOD", + 0x3FFF, + { + "1st BG0", + "1st BG1", + "1st BG2", + "1st BG3", + "1st OBJ", + "1st BD", + "", + "FX Type (2 bits)", + "2nd BG0", + "2nd BG1", + "2nd BG2", + "2nd BG3", + "2nd OBJ", + "2nd BD", + "", + "", + } }, + { &COLEV, + 0x52, + "0x4000052-COLEV", + 0x1F1F, + { + "", + "", + "", + "", + "Coefficient EVA (5 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "Coefficient EVB (5 bits,W)", + "", + "", + "", + } }, + { &COLY, + 0x54, + "0x4000054-COLEY", + 0x001F, + { + "", + "", + "", + "", + "Coefficient EVY (5 bits,W)", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { NULL, + 0x60, + "0x4000060-SG10_L", + 0x007F, + { + "", + "", + "Sweep Shifts (3 bits)", + "Sweep addition/decrease", + "", + "", + "Sweep Time (3 bits)", + "", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { NULL, + 0x62, + "0x4000062-SG10_H", + 0xFFFF, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "Waveform Type (2 bits)", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } }, + { NULL, + 0x64, + "0x4000064-SG11", + 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } }, + { NULL, + 0x68, + "0x4000068-SG20", + 0xFFFF, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "Waveform Type (2 bits)", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } }, + { NULL, + 0x6C, + "0x400006C-SG21", + 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } }, + { NULL, + 0x70, + "0x4000070-SG30_L", + 0x00E0, + { + "", + "", + "", + "", + "", + "Waveform 32/64 Steps", + "Waveform Bank 0/1", + "Sound Output", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { NULL, + 0x72, + "0x4000072-SG30_H", + 0xE0FF, + { + "", + "", + "", + "", + "", + "", + "", + "Sound Length (8 bits,W)", + "", + "", + "", + "", + "", + "", + "Output Level (2 bits)", + "Forced 3/4 Output Level", + } }, + { NULL, + 0x74, + "0x4000074-SG31", + 0xC7FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Frequency (11 bits,W)", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } }, + { NULL, + 0x78, + "0x4000078-SG40", + 0xFF3F, + { + "", + "", + "", + "", + "", + "Sound Length (6 bits,W)", + "", + "", + "", + "", + "Envelope Steps (3 bits)", + "Envelope Attenuate/Amplify", + "", + "", + "", + "Envelope Initial Value", + } }, + { NULL, + 0x7C, + "0x400007C-SG41", + 0xC0FF, + { + "", + "", + "Dividing Ratio Freq. (3 bits)", + "Counter 15/7 Steps", + "", + "", + "", + "Counter Shift Clock (4 bits)", + "", + "", + "", + "", + "", + "", + "Sound Continuous/Counter", + "Initialization (W)", + } }, + { NULL, + 0x80, + "0x4000080-SGCNT0_L", + 0xFF77, + { + "", + "", + "Right Volume (3 bits)", + "", + "", + "", + "Left Volume (3 bits)", + "", + "Channel 1->Right", + "Channel 2->Right", + "Channel 3->Right", + "Channel 4->Right", + "Channel 1->Left", + "Channel 2->Left", + "Channel 3->Left", + "Channel 4->Left", + } }, + { NULL, + 0x82, + "0x4000082-SGCNT0_H", + 0xFF0F, + { + "", + "Sound 1-4 Volume (2 bits)", + "DMA Sound A Volume", + "DMA Sound B Volume", + "", + "", + "", + "", + "DMA Sound A->Right", + "DMA Sound A->Left", + "DMA Sound A Timer", + "DMA Sound A Reset FIFO", + "DMA Sound B->Right", + "DMA Sound B->Left", + "DMA Sound B Timer", + "DMA Sound B Reset FIFO", + } }, + { NULL, + 0x84, + "0x4000084-SGCNT1", + 0x0080, + { + "Sound 1 On", + "Sound 2 On", + "Sound 3 On", + "Sound 4 On", + "", + "", + "", + "Master Sound Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { NULL, + 0x88, + "0x4000088-SGBIAS", + 0xC3FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Bias Level (10 bits)", + "", + "", + "", + "", + "", + "Sampling Rate (2 bits)", + } }, + { NULL, + 0xA0, + "0x40000A0-SIGFIFOA_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 0 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 1 (8 bits)", + } }, + { NULL, + 0xA2, + "0x40000A2-SIGFIFOA_H", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 2 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 3 (8 bits)", + } }, + { NULL, + 0xA4, + "0x40000A4-SIGFIFOB_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 0 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 1 (8 bits)", + } }, + { NULL, + 0xA6, + "0x40000A6-SIGFIFOB_H", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "Data 2 (8 bits)", + "", + "", + "", + "", + "", + "", + "", + "Data 3 (8 bits)", + } }, + { &DM0SAD_L, + 0xB0, + "0x40000B0-DM0SAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } }, + { &DM0SAD_H, + 0xB2, + "0x40000B2-DM0SAD_H", + 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 11 bits)", + "", + "", + "", + "", + "", + } }, + { &DM0DAD_L, + 0xB4, + "0x40000B4-DM0DAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } }, + { &DM0DAD_H, + 0xB6, + "0x40000B6-DM0DAD_H", + 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } }, + { &DM0CNT_L, + 0xB8, + "0x40000B8-DM0CNT_L", + 0x3FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "Count (14 bits)", "", "", + } }, + { &DM0CNT_H, + 0xBA, + "0x40000BA-DM0CNT_H", + 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } }, + { &DM1SAD_L, + 0xBC, + "0x40000BC-DM1SAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } }, + { &DM1SAD_H, + 0xBE, + "0x40000BE-DM1SAD_H", + 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } }, + { &DM1DAD_L, + 0xC0, + "0x40000C0-DM1DAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } }, + { &DM1DAD_H, + 0xC2, + "0x40000C2-DM1DAD_H", + 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } }, + { &DM1CNT_L, + 0xC4, + "0x40000C4-DM1CNT_L", + 0x3FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "Count (14 bits)", "", "", + } }, + { &DM1CNT_H, + 0xC6, + "0x40000C6-DM1CNT_H", + 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } }, + { &DM2SAD_L, + 0xC8, + "0x40000C8-DM2SAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } }, + { &DM2SAD_H, + 0xCA, + "0x40000CA-DM2SAD_H", + 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } }, + { &DM2DAD_L, + 0xCC, + "0x40000CC-DM2DAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } }, + { &DM2DAD_H, + 0xCE, + "0x40000CE-DM2DAD_H", + 0x07FF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 11 bits)", + "", + "", + "", + "", + "", + } }, + { &DM2CNT_L, + 0xD0, + "0x40000D0-DM2CNT_L", + 0x3FFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "Count (14 bits)", "", "", + } }, + { &DM2CNT_H, + 0xD2, + "0x40000D2-DM2CNT_H", + 0xF7E0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } }, + { &DM3SAD_L, + 0xD4, + "0x40000D4-DM3SAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (lower 16 bits)", + } }, + { &DM3SAD_H, + 0xD6, + "0x40000D6-DM3SAD_H", + 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Source Address (upper 12 bits)", + "", + "", + "", + "", + } }, + { &DM3DAD_L, + 0xD8, + "0x40000D8-DM3DAD_L", + 0xFFFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (lower 16 bits)", + } }, + { &DM3DAD_H, + 0xDA, + "0x40000DA-DM3DAD_H", + 0x0FFF, + { + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "", + "Destination Address (upper 12 bits)", + "", + "", + "", + "", + } }, + { &DM3CNT_L, + 0xDC, + "0x40000DC-DM3CNT_L", + 0xFFFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Count (16 bits)", + } }, + { &DM3CNT_H, + 0xDE, + "0x40000DE-DM3CNT_H", + 0xFFE0, + { + "", + "", + "", + "", + "", + "", + "Destination Address Control (2 bits)", + "", + "Source Address Control (2 bits)", + "Repeat", + "Transfer Type", + "Game Pak Data Request", + "", + "Start Timing (2 bits)", + "Interrupt Request", + "Enable", + } }, + { &TM0D, + 0x100, + "0x4000100-TM0D", + 0xFFFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Timer Counter (16 bits)", + } }, + { &TM0CNT, + 0x102, + "0x4000102-TM0CNT", + 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { &TM1D, + 0x104, + "0x4000104-TM1D", + 0xFFFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Timer Counter (16 bits)", + } }, + { &TM1CNT, + 0x106, + "0x4000106-TM1CNT", + 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { &TM2D, + 0x108, + "0x4000108-TM2D", + 0xFFFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Timer Counter (16 bits)", + } }, + { &TM2CNT, + 0x10A, + "0x400010A-TM2CNT", + 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { &TM3D, + 0x10C, + "0x400010C-TM3D", + 0xFFFF, + { + "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Timer Counter (16 bits)", + } }, + { &TM3CNT, + 0x10E, + "0x400010E-TM3CNT", + 0x00C7, + { + "", + "Scalar Selection (2 bits)", + "Count Up", + "", + "", + "", + "Interrupt Request", + "Enable", + "", + "", + "", + "", + "", + "", + "", + "", + } }, + { &P1, + 0x130, + "0x4000130-P1", + 0x03FF, + { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "Shoulder Right", + "Shoulder Left", + "", + "", + "", + "", + "", + "", + } }, + { NULL, + 0x132, + "0x4000132-P1CNT", + 0xC3FF, + { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "Shoulder Right", + "Shoulder Left", + "", + "", + "", + "", + "Interrupt Request", + "Interrupt Condition", + } }, + { &IE, + 0x200, + "0x4000200-IE", + 0x3FFF, + { + "VBlank", + "HBlank", + "VCount", + "Timer 0", + "Timer 1", + "Timer 2", + "Timer 3", + "Serial", + "DMA 0", + "DMA 1", + "DMA 2", + "DMA 3", + "Keypad", + "Game Pak", + "", + "", + } }, + { &IF, + 0x202, + "0x4000202-IF", + 0x0000, + { + "VBlank", + "HBlank", + "VCount", + "Timer 0", + "Timer 1", + "Timer 2", + "Timer 3", + "Serial", + "DMA 0", + "DMA 1", + "DMA 2", + "DMA 3", + "Keypad", + "Game Pak", + "", + "", + } }, + { NULL, + 0x204, + "0x4000204-WAITCNT", + 0x5FFF, + { + "", + "SRAM Wait Control (2 bits)", + "", + "Wait State 0 First Access (2 bits)", + "Wait State 0 Second Access", + "", + "Wait State 1 First Access (2 bits)", + "Wait State 1 Second Access", + "", + "Wait State 2 First Access (2 bits)", + "Wait State 2 Second Access", + "", + "PHI Terminal Output (2 bits)", + "", + "Game Pak Prefetch Buffer", + "Game Pak Type Flag", + } }, + { &IME, + 0x208, + "0x4000208-IME", + 0x0001, + { + "Master Interrupt Enable", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", + } }, + { NULL, + 0x300, + "0x4000300-HALTCNT", + 0x8001, + { + "First Boot", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "Power Down", + } }, + }; diff --git a/src/win32/IUpdate.h b/src/win32/IUpdate.h index a11a266c..ddadf601 100644 --- a/src/win32/IUpdate.h +++ b/src/win32/IUpdate.h @@ -1,8 +1,9 @@ #ifndef VBA_WIN32_IUPDATE_H #define VBA_WIN32_IUPDATE_H -class IUpdateListener { - public: - virtual void update()=0; +class IUpdateListener +{ + public: + virtual void update() = 0; }; #endif diff --git a/src/win32/Input.h b/src/win32/Input.h index 7fe3c5fe..5d358426 100644 --- a/src/win32/Input.h +++ b/src/win32/Input.h @@ -6,41 +6,45 @@ #define JOYPADS 4 #define MOTION_KEYS 4 #define KEYS_PER_PAD 13 -#define MOTION(i) ((JOYPADS*KEYS_PER_PAD)+i) -#define JOYPAD(i,j) ((i*KEYS_PER_PAD)+j) +#define MOTION(i) ((JOYPADS * KEYS_PER_PAD) + i) +#define JOYPAD(i, j) ((i * KEYS_PER_PAD) + j) #define DEVICEOF(key) (key >> 8) #define KEYOF(key) (key & 255) -typedef CList KeyList; +typedef CList KeyList; -enum { - KEY_LEFT, KEY_RIGHT, - KEY_UP, KEY_DOWN, - KEY_BUTTON_A, KEY_BUTTON_B, - KEY_BUTTON_START, KEY_BUTTON_SELECT, - KEY_BUTTON_L, KEY_BUTTON_R, - KEY_BUTTON_SPEED, KEY_BUTTON_CAPTURE, - KEY_BUTTON_GS -}; - -class Input { - - public: - KeyList joypaddata[JOYPADS * KEYS_PER_PAD + MOTION_KEYS]; - - Input() {}; - virtual ~Input() {}; - - virtual bool initialize() = 0; - - virtual bool readDevices() = 0; - virtual u32 readDevice(int which) = 0; - virtual CString getKeyName(LONG_PTR key) = 0; - virtual void checkKeys() = 0; - virtual void checkMotionKeys() = 0; - virtual void checkDevices() = 0; - virtual void activate() = 0; - virtual void loadSettings() = 0; - virtual void saveSettings() = 0; +enum { KEY_LEFT, + KEY_RIGHT, + KEY_UP, + KEY_DOWN, + KEY_BUTTON_A, + KEY_BUTTON_B, + KEY_BUTTON_START, + KEY_BUTTON_SELECT, + KEY_BUTTON_L, + KEY_BUTTON_R, + KEY_BUTTON_SPEED, + KEY_BUTTON_CAPTURE, + KEY_BUTTON_GS }; + +class Input +{ + public: + KeyList joypaddata[JOYPADS * KEYS_PER_PAD + MOTION_KEYS]; + + Input(){}; + virtual ~Input(){}; + + virtual bool initialize() = 0; + + virtual bool readDevices() = 0; + virtual u32 readDevice(int which) = 0; + virtual CString getKeyName(LONG_PTR key) = 0; + virtual void checkKeys() = 0; + virtual void checkMotionKeys() = 0; + virtual void checkDevices() = 0; + virtual void activate() = 0; + virtual void loadSettings() = 0; + virtual void saveSettings() = 0; }; diff --git a/src/win32/Joypad.h b/src/win32/Joypad.h index 3af4c071..e2bfb991 100644 --- a/src/win32/Joypad.h +++ b/src/win32/Joypad.h @@ -13,138 +13,133 @@ class JoypadEditControl : public CEdit { - // Construction -public: + // Construction + public: + JoypadEditControl(); - JoypadEditControl(); + KeyList m_Keys; - KeyList m_Keys; + // Attributes + public: + // Operations + public: + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(JoypadEditControl) + //}}AFX_VIRTUAL - // Attributes - public: + // Implementation + public: + virtual BOOL PreTranslateMessage(MSG *pMsg); + afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam); + virtual ~JoypadEditControl(); - // Operations - public: + // Generated message map functions + protected: + DECLARE_MESSAGE_MAP() +}; - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(JoypadEditControl) - //}}AFX_VIRTUAL - - // Implementation - public: - virtual BOOL PreTranslateMessage(MSG *pMsg); - afx_msg LRESULT OnJoyConfig(WPARAM wParam, LPARAM lParam); - virtual ~JoypadEditControl(); - - // Generated message map functions - protected: - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // JoypadConfig dialog class JoypadConfig : public CDialog { - // Construction - public: - void assignKey(int id, LONG_PTR key); - JoypadConfig(int w, CWnd* pParent = NULL); // standard constructor + // Construction + public: + void assignKey(int id, LONG_PTR key); + JoypadConfig(int w, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(JoypadConfig) - enum { IDD = IDD_CONFIG }; - JoypadEditControl up; - JoypadEditControl speed; - JoypadEditControl right; - JoypadEditControl left; - JoypadEditControl down; - JoypadEditControl capture; - JoypadEditControl buttonStart; - JoypadEditControl buttonSelect; - JoypadEditControl buttonR; - JoypadEditControl buttonL; - JoypadEditControl buttonGS; - JoypadEditControl buttonB; - JoypadEditControl buttonA; + // Dialog Data + //{{AFX_DATA(JoypadConfig) + enum { IDD = IDD_CONFIG }; + JoypadEditControl up; + JoypadEditControl speed; + JoypadEditControl right; + JoypadEditControl left; + JoypadEditControl down; + JoypadEditControl capture; + JoypadEditControl buttonStart; + JoypadEditControl buttonSelect; + JoypadEditControl buttonR; + JoypadEditControl buttonL; + JoypadEditControl buttonGS; + JoypadEditControl buttonB; + JoypadEditControl buttonA; - //}}AFX_DATA + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(JoypadConfig) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(JoypadConfig) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + UINT_PTR timerId; + int which; - // Implementation - protected: - UINT_PTR timerId; - int which; - - // Generated message map functions - //{{AFX_MSG(JoypadConfig) - afx_msg void OnCancel(); - afx_msg void OnOk(); - afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnDestroy(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedAppendmode(); - afx_msg void OnBnClickedClearAll(); + // Generated message map functions + //{{AFX_MSG(JoypadConfig) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnDestroy(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + afx_msg void OnBnClickedAppendmode(); + afx_msg void OnBnClickedClearAll(); }; - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // MotionConfig dialog class MotionConfig : public CDialog { - // Construction - public: - void assignKeys(); - void assignKey(int id, int key); - MotionConfig(CWnd* pParent = NULL); // standard constructor + // Construction + public: + void assignKeys(); + void assignKey(int id, int key); + MotionConfig(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(MotionConfig) - enum { IDD = IDD_MOTION_CONFIG }; - JoypadEditControl up; - JoypadEditControl right; - JoypadEditControl left; - JoypadEditControl down; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(MotionConfig) + enum { IDD = IDD_MOTION_CONFIG }; + JoypadEditControl up; + JoypadEditControl right; + JoypadEditControl left; + JoypadEditControl down; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MotionConfig) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MotionConfig) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(MotionConfig) + afx_msg void OnCancel(); + afx_msg void OnOk(); + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); + afx_msg void OnDestroy(); + virtual BOOL OnInitDialog(); + afx_msg void OnTimer(UINT_PTR nIDEvent); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + UINT_PTR timerId; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(MotionConfig) - afx_msg void OnCancel(); - afx_msg void OnOk(); - afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); - afx_msg void OnDestroy(); - virtual BOOL OnInitDialog(); - afx_msg void OnTimer(UINT_PTR nIDEvent); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - private: - UINT_PTR timerId; -public: - afx_msg void OnBnClickedAppendmode(); + public: + afx_msg void OnBnClickedAppendmode(); }; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/src/win32/KeyboardEdit.h b/src/win32/KeyboardEdit.h index 10092d79..875f3950 100644 --- a/src/win32/KeyboardEdit.h +++ b/src/win32/KeyboardEdit.h @@ -39,49 +39,50 @@ class CKeyboardEdit : public CEdit { - // Construction - public: - CKeyboardEdit(); + // Construction + public: + CKeyboardEdit(); - // Attributes - public: - bool m_bKeyDefined; + // Attributes + public: + bool m_bKeyDefined; - WORD m_wVirtKey; - bool m_bCtrlPressed; - bool m_bAltPressed; - bool m_bShiftPressed; + WORD m_wVirtKey; + bool m_bCtrlPressed; + bool m_bAltPressed; + bool m_bShiftPressed; - // Operations - public: - bool GetAccelKey(WORD& wVirtKey, bool& bCtrl, bool& bAlt, bool& bShift); - void ResetKey (); + // Operations + public: + bool GetAccelKey(WORD &wVirtKey, bool &bCtrl, bool &bAlt, bool &bShift); + void ResetKey(); - protected: - void DisplayKeyboardString (); + protected: + void DisplayKeyboardString(); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(CKeyboardEdit) - public: - virtual BOOL PreTranslateMessage(MSG* pMsg); - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(CKeyboardEdit) + public: + virtual BOOL PreTranslateMessage(MSG *pMsg); + //}}AFX_VIRTUAL - // Implementation - public: - virtual ~CKeyboardEdit(); + // Implementation + public: + virtual ~CKeyboardEdit(); - // Generated message map functions - protected: - //{{AFX_MSG(CKeyboardEdit) - //}}AFX_MSG + // Generated message map functions + protected: + //{{AFX_MSG(CKeyboardEdit) + //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; + DECLARE_MESSAGE_MAP() +}; - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} -// Microsoft Developer Studio will insert additional declarations immediately before the previous line. +// Microsoft Developer Studio will insert additional declarations immediately before the previous +// line. #endif // !defined(AFX_KEYBOARDEDIT_H__88E35AB0_2E23_11D2_BA24_0060B0B5E151__INCLUDED_) diff --git a/src/win32/LangSelect.h b/src/win32/LangSelect.h index ca601c73..97e1c0a7 100644 --- a/src/win32/LangSelect.h +++ b/src/win32/LangSelect.h @@ -12,38 +12,36 @@ class LangSelect : public CDialog { - // Construction - public: - LangSelect(CWnd* pParent = NULL); // standard constructor + // Construction + public: + LangSelect(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(LangSelect) - enum { IDD = IDD_LANG_SELECT }; - CEdit m_langString; - CStatic m_langName; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(LangSelect) + enum { IDD = IDD_LANG_SELECT }; + CEdit m_langString; + CStatic m_langName; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(LangSelect) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LangSelect) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(LangSelect) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(LangSelect) - afx_msg void OnCancel(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_LANGSELECT_H__63619E13_A375_4ED4_952F_DCF8998C2914__INCLUDED_) diff --git a/src/win32/LinkOptions.h b/src/win32/LinkOptions.h index f1a33a6b..9f604437 100644 --- a/src/win32/LinkOptions.h +++ b/src/win32/LinkOptions.h @@ -5,82 +5,77 @@ class LinkOptions : public CDialog { -// Construction -public: - LinkOptions(CWnd* pParent = NULL); // standard constructor -// Dialog Data - //{{AFX_DATA(LinkOptions) - enum { IDD = IDD_LINKTAB }; - int m_type; - CEdit m_timeout; - CComboBox m_mode; - CEdit m_serverip; - BOOL m_server; - //}}AFX_DATA + // Construction + public: + LinkOptions(CWnd *pParent = NULL); // standard constructor + // Dialog Data + //{{AFX_DATA(LinkOptions) + enum { IDD = IDD_LINKTAB }; + int m_type; + CEdit m_timeout; + CComboBox m_mode; + CEdit m_serverip; + BOOL m_server; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(LinkOptions) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(LinkOptions) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + void AddMode(LPCTSTR name, int value); + void UpdateAvailability(); -// Implementation -protected: - - void AddMode(LPCTSTR name, int value); - void UpdateAvailability(); - - // Generated message map functions - //{{AFX_MSG(LinkOptions) - afx_msg void OnCbnSelchangeLinkMode(); - virtual BOOL OnInitDialog(); - afx_msg void OnOk(); - afx_msg void OnCancel(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedLinkServer(); - afx_msg void OnBnClickedLinkClient(); + // Generated message map functions + //{{AFX_MSG(LinkOptions) + afx_msg void OnCbnSelchangeLinkMode(); + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void OnCancel(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + afx_msg void OnBnClickedLinkServer(); + afx_msg void OnBnClickedLinkClient(); }; - ///////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////// // ServerWait dialog class ServerWait : public CDialog { -// Construction -public: - ServerWait(CWnd* pParent = NULL); // standard constructor + // Construction + public: + ServerWait(CWnd *pParent = NULL); // standard constructor -// Dialog Data - //{{AFX_DATA(ServerWait) - enum { IDD = IDD_SERVERWAIT }; - CProgressCtrl m_prgctrl; - CString m_serveraddress; - CString m_plconn[3]; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(ServerWait) + enum { IDD = IDD_SERVERWAIT }; + CProgressCtrl m_prgctrl; + CString m_serveraddress; + CString m_plconn[3]; + //}}AFX_DATA - bool m_userAborted; + bool m_userAborted; -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ServerWait) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - afx_msg void OnCancel(); - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ServerWait) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + afx_msg void OnCancel(); + //}}AFX_VIRTUAL -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(ServerWait) - // NOTE: the ClassWizard will add member functions here - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(ServerWait) + // NOTE: the ClassWizard will add member functions here + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; - diff --git a/src/win32/LoadOAL.h b/src/win32/LoadOAL.h index 59aa3044..a4727061 100644 --- a/src/win32/LoadOAL.h +++ b/src/win32/LoadOAL.h @@ -21,144 +21,150 @@ // Complete list of functions available in AL 1.0 implementations -typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability ); -typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability ); -typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability ); -typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param ); -typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); -typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); -typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); -typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); -typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param ); -typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param ); -typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param ); -typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param ); -typedef ALenum (ALAPIENTRY *LPALGETERROR)( void ); -typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); -typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); -typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); -typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); -typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); -typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value ); -typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); -typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); -typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); -typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); -typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); -typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); -typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid ); -typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); -typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); -typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); -typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); -typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); -typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); -typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); -typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); -typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); -typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); -typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid ); -typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid ); -typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid ); -typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid ); -typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); -typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); -typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); -typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); -typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid ); -typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); -typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); -typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); -typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); -typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); -typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); +typedef void(ALAPIENTRY *LPALENABLE)(ALenum capability); +typedef void(ALAPIENTRY *LPALDISABLE)(ALenum capability); +typedef ALboolean(ALAPIENTRY *LPALISENABLED)(ALenum capability); +typedef const ALchar *(ALAPIENTRY *LPALGETSTRING)(ALenum param); +typedef void(ALAPIENTRY *LPALGETBOOLEANV)(ALenum param, ALboolean *data); +typedef void(ALAPIENTRY *LPALGETINTEGERV)(ALenum param, ALint *data); +typedef void(ALAPIENTRY *LPALGETFLOATV)(ALenum param, ALfloat *data); +typedef void(ALAPIENTRY *LPALGETDOUBLEV)(ALenum param, ALdouble *data); +typedef ALboolean(ALAPIENTRY *LPALGETBOOLEAN)(ALenum param); +typedef ALint(ALAPIENTRY *LPALGETINTEGER)(ALenum param); +typedef ALfloat(ALAPIENTRY *LPALGETFLOAT)(ALenum param); +typedef ALdouble(ALAPIENTRY *LPALGETDOUBLE)(ALenum param); +typedef ALenum(ALAPIENTRY *LPALGETERROR)(void); +typedef ALboolean(ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar *extname); +typedef void *(ALAPIENTRY *LPALGETPROCADDRESS)(const ALchar *fname); +typedef ALenum(ALAPIENTRY *LPALGETENUMVALUE)(const ALchar *ename); +typedef void(ALAPIENTRY *LPALLISTENERF)(ALenum param, ALfloat value); +typedef void(ALAPIENTRY *LPALLISTENER3F)(ALenum param, ALfloat value1, ALfloat value2, + ALfloat value3); +typedef void(ALAPIENTRY *LPALLISTENERFV)(ALenum param, const ALfloat *values); +typedef void(ALAPIENTRY *LPALLISTENERI)(ALenum param, ALint value); +typedef void(ALAPIENTRY *LPALGETLISTENERF)(ALenum param, ALfloat *value); +typedef void(ALAPIENTRY *LPALGETLISTENER3F)(ALenum param, ALfloat *value1, ALfloat *value2, + ALfloat *value3); +typedef void(ALAPIENTRY *LPALGETLISTENERFV)(ALenum param, ALfloat *values); +typedef void(ALAPIENTRY *LPALGETLISTENERI)(ALenum param, ALint *value); +typedef void(ALAPIENTRY *LPALGENSOURCES)(ALsizei n, ALuint *sources); +typedef void(ALAPIENTRY *LPALDELETESOURCES)(ALsizei n, const ALuint *sources); +typedef ALboolean(ALAPIENTRY *LPALISSOURCE)(ALuint sid); +typedef void(ALAPIENTRY *LPALSOURCEF)(ALuint sid, ALenum param, ALfloat value); +typedef void(ALAPIENTRY *LPALSOURCE3F)(ALuint sid, ALenum param, ALfloat value1, ALfloat value2, + ALfloat value3); +typedef void(ALAPIENTRY *LPALSOURCEFV)(ALuint sid, ALenum param, const ALfloat *values); +typedef void(ALAPIENTRY *LPALSOURCEI)(ALuint sid, ALenum param, ALint value); +typedef void(ALAPIENTRY *LPALGETSOURCEF)(ALuint sid, ALenum param, ALfloat *value); +typedef void(ALAPIENTRY *LPALGETSOURCE3F)(ALuint sid, ALenum param, ALfloat *value1, + ALfloat *value2, ALfloat *value3); +typedef void(ALAPIENTRY *LPALGETSOURCEFV)(ALuint sid, ALenum param, ALfloat *values); +typedef void(ALAPIENTRY *LPALGETSOURCEI)(ALuint sid, ALenum param, ALint *value); +typedef void(ALAPIENTRY *LPALSOURCEPLAYV)(ALsizei ns, const ALuint *sids); +typedef void(ALAPIENTRY *LPALSOURCESTOPV)(ALsizei ns, const ALuint *sids); +typedef void(ALAPIENTRY *LPALSOURCEREWINDV)(ALsizei ns, const ALuint *sids); +typedef void(ALAPIENTRY *LPALSOURCEPAUSEV)(ALsizei ns, const ALuint *sids); +typedef void(ALAPIENTRY *LPALSOURCEPLAY)(ALuint sid); +typedef void(ALAPIENTRY *LPALSOURCESTOP)(ALuint sid); +typedef void(ALAPIENTRY *LPALSOURCEREWIND)(ALuint sid); +typedef void(ALAPIENTRY *LPALSOURCEPAUSE)(ALuint sid); +typedef void(ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, + const ALuint *bids); +typedef void(ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids); +typedef void(ALAPIENTRY *LPALGENBUFFERS)(ALsizei n, ALuint *buffers); +typedef void(ALAPIENTRY *LPALDELETEBUFFERS)(ALsizei n, const ALuint *buffers); +typedef ALboolean(ALAPIENTRY *LPALISBUFFER)(ALuint bid); +typedef void(ALAPIENTRY *LPALBUFFERDATA)(ALuint bid, ALenum format, const ALvoid *data, + ALsizei size, ALsizei freq); +typedef void(ALAPIENTRY *LPALGETBUFFERF)(ALuint bid, ALenum param, ALfloat *value); +typedef void(ALAPIENTRY *LPALGETBUFFERI)(ALuint bid, ALenum param, ALint *value); +typedef void(ALAPIENTRY *LPALDOPPLERFACTOR)(ALfloat value); +typedef void(ALAPIENTRY *LPALDOPPLERVELOCITY)(ALfloat value); +typedef void(ALAPIENTRY *LPALDISTANCEMODEL)(ALenum distanceModel); -typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); -typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); -typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); -typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); -typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid ); -typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); -typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); -typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); -typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device ); -typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); -typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); -typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); -typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); -typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); +typedef ALCcontext *(ALCAPIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean(ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); +typedef void(ALCAPIENTRY *LPALCPROCESSCONTEXT)(ALCcontext *context); +typedef void(ALCAPIENTRY *LPALCSUSPENDCONTEXT)(ALCcontext *context); +typedef void(ALCAPIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); +typedef ALCcontext *(ALCAPIENTRY *LPALCGETCURRENTCONTEXT)(ALCvoid); +typedef ALCdevice *(ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)(ALCcontext *context); +typedef ALCdevice *(ALCAPIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); +typedef ALCboolean(ALCAPIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); +typedef ALCenum(ALCAPIENTRY *LPALCGETERROR)(ALCdevice *device); +typedef ALCboolean(ALCAPIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, const ALCchar *extname); +typedef void *(ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname); +typedef ALCenum(ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname); +typedef const ALCchar *(ALCAPIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); +typedef void(ALCAPIENTRY *LPALCGETINTEGERV)(ALCdevice *device, ALCenum param, ALCsizei size, + ALCint *dest); -typedef struct -{ - LPALENABLE alEnable; - LPALDISABLE alDisable; - LPALISENABLED alIsEnabled; - LPALGETBOOLEAN alGetBoolean; - LPALGETINTEGER alGetInteger; - LPALGETFLOAT alGetFloat; - LPALGETDOUBLE alGetDouble; - LPALGETBOOLEANV alGetBooleanv; - LPALGETINTEGERV alGetIntegerv; - LPALGETFLOATV alGetFloatv; - LPALGETDOUBLEV alGetDoublev; - LPALGETSTRING alGetString; - LPALGETERROR alGetError; - LPALISEXTENSIONPRESENT alIsExtensionPresent; - LPALGETPROCADDRESS alGetProcAddress; - LPALGETENUMVALUE alGetEnumValue; - LPALLISTENERI alListeneri; - LPALLISTENERF alListenerf; - LPALLISTENER3F alListener3f; - LPALLISTENERFV alListenerfv; - LPALGETLISTENERI alGetListeneri; - LPALGETLISTENERF alGetListenerf; - LPALGETLISTENER3F alGetListener3f; - LPALGETLISTENERFV alGetListenerfv; - LPALGENSOURCES alGenSources; - LPALDELETESOURCES alDeleteSources; - LPALISSOURCE alIsSource; - LPALSOURCEI alSourcei; - LPALSOURCEF alSourcef; - LPALSOURCE3F alSource3f; - LPALSOURCEFV alSourcefv; - LPALGETSOURCEI alGetSourcei; - LPALGETSOURCEF alGetSourcef; - LPALGETSOURCEFV alGetSourcefv; - LPALSOURCEPLAYV alSourcePlayv; - LPALSOURCESTOPV alSourceStopv; - LPALSOURCEPLAY alSourcePlay; - LPALSOURCEPAUSE alSourcePause; - LPALSOURCESTOP alSourceStop; - LPALGENBUFFERS alGenBuffers; - LPALDELETEBUFFERS alDeleteBuffers; - LPALISBUFFER alIsBuffer; - LPALBUFFERDATA alBufferData; - LPALGETBUFFERI alGetBufferi; - LPALGETBUFFERF alGetBufferf; - LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers; - LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers; - LPALDISTANCEMODEL alDistanceModel; - LPALDOPPLERFACTOR alDopplerFactor; - LPALDOPPLERVELOCITY alDopplerVelocity; - LPALCGETSTRING alcGetString; - LPALCGETINTEGERV alcGetIntegerv; - LPALCOPENDEVICE alcOpenDevice; - LPALCCLOSEDEVICE alcCloseDevice; - LPALCCREATECONTEXT alcCreateContext; - LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; - LPALCPROCESSCONTEXT alcProcessContext; - LPALCGETCURRENTCONTEXT alcGetCurrentContext; - LPALCGETCONTEXTSDEVICE alcGetContextsDevice; - LPALCSUSPENDCONTEXT alcSuspendContext; - LPALCDESTROYCONTEXT alcDestroyContext; - LPALCGETERROR alcGetError; - LPALCISEXTENSIONPRESENT alcIsExtensionPresent; - LPALCGETPROCADDRESS alcGetProcAddress; - LPALCGETENUMVALUE alcGetEnumValue; +typedef struct { + LPALENABLE alEnable; + LPALDISABLE alDisable; + LPALISENABLED alIsEnabled; + LPALGETBOOLEAN alGetBoolean; + LPALGETINTEGER alGetInteger; + LPALGETFLOAT alGetFloat; + LPALGETDOUBLE alGetDouble; + LPALGETBOOLEANV alGetBooleanv; + LPALGETINTEGERV alGetIntegerv; + LPALGETFLOATV alGetFloatv; + LPALGETDOUBLEV alGetDoublev; + LPALGETSTRING alGetString; + LPALGETERROR alGetError; + LPALISEXTENSIONPRESENT alIsExtensionPresent; + LPALGETPROCADDRESS alGetProcAddress; + LPALGETENUMVALUE alGetEnumValue; + LPALLISTENERI alListeneri; + LPALLISTENERF alListenerf; + LPALLISTENER3F alListener3f; + LPALLISTENERFV alListenerfv; + LPALGETLISTENERI alGetListeneri; + LPALGETLISTENERF alGetListenerf; + LPALGETLISTENER3F alGetListener3f; + LPALGETLISTENERFV alGetListenerfv; + LPALGENSOURCES alGenSources; + LPALDELETESOURCES alDeleteSources; + LPALISSOURCE alIsSource; + LPALSOURCEI alSourcei; + LPALSOURCEF alSourcef; + LPALSOURCE3F alSource3f; + LPALSOURCEFV alSourcefv; + LPALGETSOURCEI alGetSourcei; + LPALGETSOURCEF alGetSourcef; + LPALGETSOURCEFV alGetSourcefv; + LPALSOURCEPLAYV alSourcePlayv; + LPALSOURCESTOPV alSourceStopv; + LPALSOURCEPLAY alSourcePlay; + LPALSOURCEPAUSE alSourcePause; + LPALSOURCESTOP alSourceStop; + LPALGENBUFFERS alGenBuffers; + LPALDELETEBUFFERS alDeleteBuffers; + LPALISBUFFER alIsBuffer; + LPALBUFFERDATA alBufferData; + LPALGETBUFFERI alGetBufferi; + LPALGETBUFFERF alGetBufferf; + LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers; + LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers; + LPALDISTANCEMODEL alDistanceModel; + LPALDOPPLERFACTOR alDopplerFactor; + LPALDOPPLERVELOCITY alDopplerVelocity; + LPALCGETSTRING alcGetString; + LPALCGETINTEGERV alcGetIntegerv; + LPALCOPENDEVICE alcOpenDevice; + LPALCCLOSEDEVICE alcCloseDevice; + LPALCCREATECONTEXT alcCreateContext; + LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; + LPALCPROCESSCONTEXT alcProcessContext; + LPALCGETCURRENTCONTEXT alcGetCurrentContext; + LPALCGETCONTEXTSDEVICE alcGetContextsDevice; + LPALCSUSPENDCONTEXT alcSuspendContext; + LPALCDESTROYCONTEXT alcDestroyContext; + LPALCGETERROR alcGetError; + LPALCISEXTENSIONPRESENT alcIsExtensionPresent; + LPALCGETPROCADDRESS alcGetProcAddress; + LPALCGETENUMVALUE alcGetEnumValue; } OPENALFNTABLE, *LPOPENALFNTABLE; #endif diff --git a/src/win32/Logging.h b/src/win32/Logging.h index 23ab2ec0..005ae94e 100644 --- a/src/win32/Logging.h +++ b/src/win32/Logging.h @@ -2,61 +2,60 @@ #include "ResizeDlg.h" - ///////////////////////////////////////////////////////////////////////////// // Logging dialog class Logging : public ResizeDlg { -public: - void log(const char *); - void clearLog(); - Logging(CWnd* pParent = NULL); // standard constructor - - // Dialog Data - enum { IDD = IDD_LOGGING }; - CEdit m_log; - BOOL m_swi; - BOOL m_unaligned_access; - BOOL m_illegal_write; - BOOL m_illegal_read; - BOOL m_dma0; - BOOL m_dma1; - BOOL m_dma2; - BOOL m_dma3; - BOOL m_agbprint; - BOOL m_undefined; - BOOL m_sound_output; + public: + void log(const char *); + void clearLog(); + Logging(CWnd *pParent = NULL); // standard constructor -// Overrides -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); + // Dialog Data + enum { IDD = IDD_LOGGING }; + CEdit m_log; + BOOL m_swi; + BOOL m_unaligned_access; + BOOL m_illegal_write; + BOOL m_illegal_read; + BOOL m_dma0; + BOOL m_dma1; + BOOL m_dma2; + BOOL m_dma3; + BOOL m_agbprint; + BOOL m_undefined; + BOOL m_sound_output; -protected: - afx_msg void OnOk(); - afx_msg void OnClear(); - afx_msg void OnVerboseAgbprint(); - afx_msg void OnVerboseDma0(); - afx_msg void OnVerboseDma1(); - afx_msg void OnVerboseDma2(); - afx_msg void OnVerboseDma3(); - afx_msg void OnVerboseIllegalRead(); - afx_msg void OnVerboseIllegalWrite(); - afx_msg void OnVerboseSwi(); - afx_msg void OnVerboseUnalignedAccess(); - afx_msg void OnVerboseUndefined(); - afx_msg void OnVerboseSoundoutput(); - afx_msg void OnSave(); - afx_msg void OnClose(); - afx_msg void OnErrspaceLog(); - afx_msg void OnMaxtextLog(); - virtual BOOL OnInitDialog(); + // Overrides + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); - DECLARE_MESSAGE_MAP() -public: - static Logging *instance; - static CString text; + protected: + afx_msg void OnOk(); + afx_msg void OnClear(); + afx_msg void OnVerboseAgbprint(); + afx_msg void OnVerboseDma0(); + afx_msg void OnVerboseDma1(); + afx_msg void OnVerboseDma2(); + afx_msg void OnVerboseDma3(); + afx_msg void OnVerboseIllegalRead(); + afx_msg void OnVerboseIllegalWrite(); + afx_msg void OnVerboseSwi(); + afx_msg void OnVerboseUnalignedAccess(); + afx_msg void OnVerboseUndefined(); + afx_msg void OnVerboseSoundoutput(); + afx_msg void OnSave(); + afx_msg void OnClose(); + afx_msg void OnErrspaceLog(); + afx_msg void OnMaxtextLog(); + virtual BOOL OnInitDialog(); + + DECLARE_MESSAGE_MAP() + public: + static Logging *instance; + static CString text; }; void toolsLogging(); diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index 1b7627df..2ecd741f 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -1,369 +1,367 @@ #pragma once -#include "stdafx.h" #include "VBA.h" - +#include "stdafx.h" class MainWnd : public CWnd { -public: - MainWnd(); - virtual ~MainWnd(); + public: + MainWnd(); + virtual ~MainWnd(); - HCURSOR arrow; - HACCEL m_hAccelTable; + HCURSOR arrow; + HACCEL m_hAccelTable; - bool FileRun(); - bool BiosRun(); - void winMouseOn(); - void screenCapture(int captureNumber); - bool fileOpenSelect( int system ); - void updateSoundChannels(UINT nID); - bool fileImportGSACodeFile(CString& fileName); - bool writeSaveGame(const char *name); - bool loadSaveGame(const char *name); - CString winLoadFilter(UINT id); - void winLoadCheatList(const char *name); - void winLoadCheatListDefault(); - void readBatteryFile(); - void writeBatteryFile(); - bool isDriveRoot(CString& file); - CString getDirFromFile(CString& file); - void winSaveCheatList(const char *name); - void winSaveCheatListDefault(); + bool FileRun(); + bool BiosRun(); + void winMouseOn(); + void screenCapture(int captureNumber); + bool fileOpenSelect(int system); + void updateSoundChannels(UINT nID); + bool fileImportGSACodeFile(CString &fileName); + bool writeSaveGame(const char *name); + bool loadSaveGame(const char *name); + CString winLoadFilter(UINT id); + void winLoadCheatList(const char *name); + void winLoadCheatListDefault(); + void readBatteryFile(); + void writeBatteryFile(); + bool isDriveRoot(CString &file); + CString getDirFromFile(CString &file); + void winSaveCheatList(const char *name); + void winSaveCheatListDefault(); -private: - bool fileExists( LPCTSTR lpFileName ); + private: + bool fileExists(LPCTSTR lpFileName); + DECLARE_MESSAGE_MAP() - DECLARE_MESSAGE_MAP() + protected: + virtual BOOL PreTranslateMessage(MSG *pMsg); -protected: - virtual BOOL PreTranslateMessage(MSG* pMsg); + afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM); + afx_msg void OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI); + afx_msg void OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsJoypadAutofire(UINT nID); + afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsJoypadDefault(UINT nID); + afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsFilterIFB(UINT nID); + afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsFilter(UINT nID); + afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsPriority(UINT nID); + afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI); + afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID); + afx_msg void OnSystemMinimize(); + afx_msg void OnUpdateVideoLayer(CCmdUI *pCmdUI); + afx_msg BOOL OnVideoLayer(UINT nID); + afx_msg void OnVideoLayerReset(); + afx_msg BOOL OnOptionVideoSize(UINT nID); + afx_msg BOOL OnOptionsFrameskip(UINT nID); + afx_msg void OnClose(); + afx_msg void OnHelpAbout(); + afx_msg void OnHelpFaq(); + afx_msg void OnFileOpenGBA(); + afx_msg void OnFileOpenGBC(); + afx_msg void OnFileOpenGB(); + afx_msg void OnFileLoadDotCode(); + afx_msg void OnFileSaveDotCode(); + afx_msg void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex, BOOL bSysMenu); + afx_msg void OnFilePause(); + afx_msg void OnUpdateFilePause(CCmdUI *pCmdUI); + afx_msg void OnFileReset(); + afx_msg void OnUpdateFileReset(CCmdUI *pCmdUI); + afx_msg void OnUpdateFileRecentFreeze(CCmdUI *pCmdUI); + afx_msg void OnFileRecentReset(); + afx_msg void OnFileRecentFreeze(); + afx_msg void OnFileExit(); + afx_msg void OnFileClose(); + afx_msg void OnUpdateFileClose(CCmdUI *pCmdUI); + afx_msg void OnFileLoad(); + afx_msg void OnUpdateFileLoad(CCmdUI *pCmdUI); + afx_msg void OnFileSave(); + afx_msg void OnUpdateFileSave(CCmdUI *pCmdUI); + afx_msg void OnFileImportBatteryfile(); + afx_msg void OnUpdateFileImportBatteryfile(CCmdUI *pCmdUI); + afx_msg void OnFileImportGamesharkcodefile(); + afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI *pCmdUI); + afx_msg void OnFileImportGamesharksnapshot(); + afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI *pCmdUI); + afx_msg void OnFileExportBatteryfile(); + afx_msg void OnUpdateFileExportBatteryfile(CCmdUI *pCmdUI); + afx_msg void OnFileExportGamesharksnapshot(); + afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI *pCmdUI); + afx_msg void OnFileScreencapture(); + afx_msg void OnUpdateFileScreencapture(CCmdUI *pCmdUI); + afx_msg void OnFileRominformation(); + afx_msg void OnUpdateFileRominformation(CCmdUI *pCmdUI); + afx_msg void OnFileTogglemenu(); + afx_msg void OnUpdateFileTogglemenu(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI *pCmdUI); + afx_msg void OnOptionsFrameskipThrottleNothrottle(); + afx_msg void OnOptionsFrameskipThrottle25(); + afx_msg void OnOptionsFrameskipThrottle50(); + afx_msg void OnOptionsFrameskipThrottle100(); + afx_msg void OnOptionsFrameskipThrottle150(); + afx_msg void OnOptionsFrameskipThrottle200(); + afx_msg void OnOptionsFrameskipThrottleOther(); + afx_msg void OnOptionsFrameskipAutomatic(); + afx_msg void OnUpdateOptionsFrameskipAutomatic(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoVsync(); + afx_msg void OnUpdateOptionsVideoVsync(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX1(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX2(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX3(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX4(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX5(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsVideoX6(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoFullscreen(); + afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI *pCmdUI); + afx_msg void OnMove(int x, int y); + afx_msg void OnSize(UINT nType, int cx, int cy); + afx_msg void OnOptionsVideoDisablesfx(); + afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoFullscreenstretchtofit(); + afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRendermethodDirectdraw(); + afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRendermethodDirect3d(); + afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRendermethodOpengl(); + afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoTriplebuffering(); + afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsD3dnofilter(); + afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsD3dbilinear(); + afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlnearest(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoRenderoptionsGlbilinear(); + afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI *pCmdUI); + afx_msg void OnContextMenu(CWnd *pWnd, CPoint point); + afx_msg void OnOptionsEmulatorAssociate(); + afx_msg void OnOptionsEmulatorDirectories(); + afx_msg void OnOptionsEmulatorDisablestatusmessages(); + afx_msg void OnUpdateOptionsEmulatorDisablestatusmessages(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorPausewheninactive(); + afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSpeeduptoggle(); + afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorAutomaticallyApplyPatchFiles(); + afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorAgbprint(); + afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorRealtimeclock(); + afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorRewindinterval(); + afx_msg void OnOptionsEmulatorSavetypeAutomatic(); + afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeEeprom(); + afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeSram(); + afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeEepromsensor(); + afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeNone(); + afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash512k(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeFlash1m(); + afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorSavetypeDetectNow(); + afx_msg void OnUpdateOptionsEmulatorSavetypeDetectNow(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorPngformat(); + afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI *pCmdUI); + afx_msg void OnOptionsEmulatorBmpformat(); + afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundChannel1(); + afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundChannel2(); + afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundChannel3(); + afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundChannel4(); + afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundDirectsounda(); + afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundDirectsoundb(); + afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyBorder(); + afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyPrinter(); + afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyBorderAutomatic(); + afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyAutomatic(); + afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyGba(); + afx_msg void OnUpdateOptionsGameboyGba(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyCgb(); + afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboySgb(); + afx_msg void OnUpdateOptionsGameboySgb(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboySgb2(); + afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyGb(); + afx_msg void OnUpdateOptionsGameboyGb(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyRealcolors(); + afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyGameboycolors(); + afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI *pCmdUI); + afx_msg void OnOptionsGameboyColors(); + afx_msg void OnOptionsFilterDisablemmx(); + afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI *pCmdUI); + afx_msg void OnOptionsLanguageSystem(); + afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI *pCmdUI); + afx_msg void OnOptionsLanguageEnglish(); + afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI *pCmdUI); + afx_msg void OnOptionsLanguageOther(); + afx_msg void OnUpdateOptionsLanguageOther(CCmdUI *pCmdUI); + afx_msg void OnOptionsJoypadConfigure1(); + afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI *pCmdUI); + afx_msg void OnOptionsJoypadConfigure2(); + afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI *pCmdUI); + afx_msg void OnOptionsJoypadConfigure3(); + afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI *pCmdUI); + afx_msg void OnOptionsJoypadConfigure4(); + afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI *pCmdUI); + afx_msg void OnOptionsJoypadMotionconfigure(); + afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI *pCmdUI); + afx_msg void OnCheatsSearchforcheats(); + afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI *pCmdUI); + afx_msg void OnCheatsCheatlist(); + afx_msg void OnUpdateCheatsCheatlist(CCmdUI *pCmdUI); + afx_msg void OnCheatsAutomaticsaveloadcheats(); + afx_msg void OnCheatsLoadcheatlist(); + afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI *pCmdUI); + afx_msg void OnCheatsSavecheatlist(); + afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI *pCmdUI); + afx_msg void OnToolsDisassemble(); + afx_msg void OnUpdateToolsDisassemble(CCmdUI *pCmdUI); + afx_msg void OnToolsLogging(); + afx_msg void OnUpdateToolsLogging(CCmdUI *pCmdUI); + afx_msg void OnToolsIoviewer(); + afx_msg void OnUpdateToolsIoviewer(CCmdUI *pCmdUI); + afx_msg void OnToolsMapview(); + afx_msg void OnUpdateToolsMapview(CCmdUI *pCmdUI); + afx_msg void OnToolsMemoryviewer(); + afx_msg void OnUpdateToolsMemoryviewer(CCmdUI *pCmdUI); + afx_msg void OnToolsOamviewer(); + afx_msg void OnUpdateToolsOamviewer(CCmdUI *pCmdUI); + afx_msg void OnToolsPaletteview(); + afx_msg void OnUpdateToolsPaletteview(CCmdUI *pCmdUI); + afx_msg void OnToolsTileviewer(); + afx_msg void OnUpdateToolsTileviewer(CCmdUI *pCmdUI); + afx_msg void OnDebugNextframe(); + afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI *pCmdUI); + afx_msg void OnToolsDebugConfigurePort(); + afx_msg void OnUpdateToolsDebugConfigurePort(CCmdUI *pCmdUI); + afx_msg void OnToolsDebugBreakOnLoad(); + afx_msg void OnUpdateToolsDebugBreakOnLoad(CCmdUI *pCmdUI); + afx_msg void OnToolsDebugBreak(); + afx_msg void OnUpdateToolsDebugBreak(CCmdUI *pCmdUI); + afx_msg void OnToolsDebugDisconnect(); + afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundStartrecording(); + afx_msg void OnUpdateOptionsSoundStartrecording(CCmdUI *pCmdUI); + afx_msg void OnOptionsSoundStoprecording(); + afx_msg void OnUpdateOptionsSoundStoprecording(CCmdUI *pCmdUI); + afx_msg void OnToolsRecordStartavirecording(); + afx_msg void OnUpdateToolsRecordStartavirecording(CCmdUI *pCmdUI); + afx_msg void OnToolsRecordStopavirecording(); + afx_msg void OnUpdateToolsRecordStopavirecording(CCmdUI *pCmdUI); + afx_msg void OnPaint(); + afx_msg void OnToolsRecordStartmovierecording(); + afx_msg void OnUpdateToolsRecordStartmovierecording(CCmdUI *pCmdUI); + afx_msg void OnToolsRecordStopmovierecording(); + afx_msg void OnUpdateToolsRecordStopmovierecording(CCmdUI *pCmdUI); + afx_msg void OnToolsPlayStartmovieplaying(); + afx_msg void OnUpdateToolsPlayStartmovieplaying(CCmdUI *pCmdUI); + afx_msg void OnToolsPlayStopmovieplaying(); + afx_msg void OnUpdateToolsPlayStopmovieplaying(CCmdUI *pCmdUI); + afx_msg void OnToolsRewind(); + afx_msg void OnUpdateToolsRewind(CCmdUI *pCmdUI); + afx_msg void OnToolsCustomize(); + afx_msg void OnUpdateToolsCustomize(CCmdUI *pCmdUI); + afx_msg void OnHelpBugreport(); + afx_msg void OnMouseMove(UINT nFlags, CPoint point); + afx_msg void OnInitMenu(CMenu *pMenu); + afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); + afx_msg void OnDropFiles(HDROP hDropInfo); + afx_msg void OnFileSavegameOldestslot(); + afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI *pCmdUI); + afx_msg void OnFileLoadgameMostrecent(); + afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI *pCmdUI); + afx_msg void OnFileLoadgameAutoloadmostrecent(); + afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI *pCmdUI); + afx_msg void OnCheatsDisablecheats(); + afx_msg void OnUpdateCheatsDisablecheats(CCmdUI *pCmdUI); + afx_msg void OnOptionsVideoFullscreenmaxscale(); + afx_msg void OnOptionsSelectPlugin(); + afx_msg void OnOptionsEmulatorGameoverrides(); + afx_msg void OnUpdateOptionsEmulatorGameoverrides(CCmdUI *pCmdUI); + afx_msg void OnHelpGnupubliclicense(); + afx_msg BOOL OnFileRecentFile(UINT nID); + afx_msg BOOL OnFileLoadSlot(UINT nID); + afx_msg BOOL OnFileSaveSlot(UINT nID); + afx_msg void OnOptionsSoundHardwareacceleration(); + afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI); + afx_msg void OnLinkOptions(); - afx_msg LRESULT OnMySysCommand(WPARAM, LPARAM); - afx_msg void OnUpdateFileLoadGameSlot(CCmdUI *pCmdUI); - afx_msg void OnUpdateFileSaveGameSlot(CCmdUI *pCmdUI); - afx_msg void OnUpdateOptionsJoypadAutofire(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsJoypadAutofire(UINT nID); - afx_msg void OnUpdateOptionsJoypadDefault(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsJoypadDefault(UINT nID); - afx_msg void OnUpdateOptionsFilterIFB(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsFilterIFB(UINT nID); - afx_msg void OnUpdateOptionsFilter(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsFilter(UINT nID); - afx_msg void OnUpdateOptionsPriority(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsPriority(UINT nID); - afx_msg void OnUpdateOptionsEmulatorShowSpeed(CCmdUI *pCmdUI); - afx_msg BOOL OnOptionsEmulatorShowSpeed(UINT nID); - afx_msg void OnSystemMinimize(); - afx_msg void OnUpdateVideoLayer(CCmdUI* pCmdUI); - afx_msg BOOL OnVideoLayer(UINT nID); - afx_msg void OnVideoLayerReset(); - afx_msg BOOL OnOptionVideoSize(UINT nID); - afx_msg BOOL OnOptionsFrameskip(UINT nID); - afx_msg void OnClose(); - afx_msg void OnHelpAbout(); - afx_msg void OnHelpFaq(); - afx_msg void OnFileOpenGBA(); - afx_msg void OnFileOpenGBC(); - afx_msg void OnFileOpenGB(); - afx_msg void OnFileLoadDotCode(); - afx_msg void OnFileSaveDotCode(); - afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); - afx_msg void OnFilePause(); - afx_msg void OnUpdateFilePause(CCmdUI* pCmdUI); - afx_msg void OnFileReset(); - afx_msg void OnUpdateFileReset(CCmdUI* pCmdUI); - afx_msg void OnUpdateFileRecentFreeze(CCmdUI* pCmdUI); - afx_msg void OnFileRecentReset(); - afx_msg void OnFileRecentFreeze(); - afx_msg void OnFileExit(); - afx_msg void OnFileClose(); - afx_msg void OnUpdateFileClose(CCmdUI* pCmdUI); - afx_msg void OnFileLoad(); - afx_msg void OnUpdateFileLoad(CCmdUI* pCmdUI); - afx_msg void OnFileSave(); - afx_msg void OnUpdateFileSave(CCmdUI* pCmdUI); - afx_msg void OnFileImportBatteryfile(); - afx_msg void OnUpdateFileImportBatteryfile(CCmdUI* pCmdUI); - afx_msg void OnFileImportGamesharkcodefile(); - afx_msg void OnUpdateFileImportGamesharkcodefile(CCmdUI* pCmdUI); - afx_msg void OnFileImportGamesharksnapshot(); - afx_msg void OnUpdateFileImportGamesharksnapshot(CCmdUI* pCmdUI); - afx_msg void OnFileExportBatteryfile(); - afx_msg void OnUpdateFileExportBatteryfile(CCmdUI* pCmdUI); - afx_msg void OnFileExportGamesharksnapshot(); - afx_msg void OnUpdateFileExportGamesharksnapshot(CCmdUI* pCmdUI); - afx_msg void OnFileScreencapture(); - afx_msg void OnUpdateFileScreencapture(CCmdUI* pCmdUI); - afx_msg void OnFileRominformation(); - afx_msg void OnUpdateFileRominformation(CCmdUI* pCmdUI); - afx_msg void OnFileTogglemenu(); - afx_msg void OnUpdateFileTogglemenu(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottleNothrottle(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottle25(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottle50(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottle100(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottle150(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottle200(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsFrameskipThrottleOther(CCmdUI* pCmdUI); - afx_msg void OnOptionsFrameskipThrottleNothrottle(); - afx_msg void OnOptionsFrameskipThrottle25(); - afx_msg void OnOptionsFrameskipThrottle50(); - afx_msg void OnOptionsFrameskipThrottle100(); - afx_msg void OnOptionsFrameskipThrottle150(); - afx_msg void OnOptionsFrameskipThrottle200(); - afx_msg void OnOptionsFrameskipThrottleOther(); - afx_msg void OnOptionsFrameskipAutomatic(); - afx_msg void OnUpdateOptionsFrameskipAutomatic(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip0(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip1(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip2(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip3(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip4(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip5(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip6(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip7(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip8(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoFrameskip9(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoVsync(); - afx_msg void OnUpdateOptionsVideoVsync(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX1(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX2(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX3(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX4(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX5(CCmdUI* pCmdUI); - afx_msg void OnUpdateOptionsVideoX6(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoFullscreen(); - afx_msg void OnUpdateOptionsVideoFullscreen(CCmdUI* pCmdUI); - afx_msg void OnMove(int x, int y); - afx_msg void OnSize(UINT nType, int cx, int cy); - afx_msg void OnOptionsVideoDisablesfx(); - afx_msg void OnUpdateOptionsVideoDisablesfx(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoFullscreenstretchtofit(); - afx_msg void OnUpdateOptionsVideoFullscreenstretchtofit(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRendermethodDirectdraw(); - afx_msg void OnUpdateOptionsVideoRendermethodDirectdraw(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRendermethodDirect3d(); - afx_msg void OnUpdateOptionsVideoRendermethodDirect3d(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRendermethodOpengl(); - afx_msg void OnUpdateOptionsVideoRendermethodOpengl(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoTriplebuffering(); - afx_msg void OnUpdateOptionsVideoTriplebuffering(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRenderoptionsD3dnofilter(); - afx_msg void OnUpdateOptionsVideoRenderoptionsD3dnofilter(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRenderoptionsD3dbilinear(); - afx_msg void OnUpdateOptionsVideoRenderoptionsD3dbilinear(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRenderoptionsGlnearest(); - afx_msg void OnUpdateOptionsVideoRenderoptionsGlnearest(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoRenderoptionsGlbilinear(); - afx_msg void OnUpdateOptionsVideoRenderoptionsGlbilinear(CCmdUI* pCmdUI); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); - afx_msg void OnOptionsEmulatorAssociate(); - afx_msg void OnOptionsEmulatorDirectories(); - afx_msg void OnOptionsEmulatorDisablestatusmessages(); - afx_msg void OnUpdateOptionsEmulatorDisablestatusmessages(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorPausewheninactive(); - afx_msg void OnUpdateOptionsEmulatorPausewheninactive(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSpeeduptoggle(); - afx_msg void OnUpdateOptionsEmulatorSpeeduptoggle(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorAutomaticallyApplyPatchFiles(); - afx_msg void OnUpdateOptionsEmulatorAutomaticallyipspatch(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorAgbprint(); - afx_msg void OnUpdateOptionsEmulatorAgbprint(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorRealtimeclock(); - afx_msg void OnUpdateOptionsEmulatorRealtimeclock(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorRewindinterval(); - afx_msg void OnOptionsEmulatorSavetypeAutomatic(); - afx_msg void OnUpdateOptionsEmulatorSavetypeAutomatic(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeEeprom(); - afx_msg void OnUpdateOptionsEmulatorSavetypeEeprom(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeSram(); - afx_msg void OnUpdateOptionsEmulatorSavetypeSram(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeFlash(); - afx_msg void OnUpdateOptionsEmulatorSavetypeFlash(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeEepromsensor(); - afx_msg void OnUpdateOptionsEmulatorSavetypeEepromsensor(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeNone(); - afx_msg void OnUpdateOptionsEmulatorSavetypeNone(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeFlash512k(); - afx_msg void OnUpdateOptionsEmulatorSavetypeFlash512k(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeFlash1m(); - afx_msg void OnUpdateOptionsEmulatorSavetypeFlash1m(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorSavetypeDetectNow(); - afx_msg void OnUpdateOptionsEmulatorSavetypeDetectNow(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorPngformat(); - afx_msg void OnUpdateOptionsEmulatorPngformat(CCmdUI* pCmdUI); - afx_msg void OnOptionsEmulatorBmpformat(); - afx_msg void OnUpdateOptionsEmulatorBmpformat(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundChannel1(); - afx_msg void OnUpdateOptionsSoundChannel1(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundChannel2(); - afx_msg void OnUpdateOptionsSoundChannel2(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundChannel3(); - afx_msg void OnUpdateOptionsSoundChannel3(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundChannel4(); - afx_msg void OnUpdateOptionsSoundChannel4(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundDirectsounda(); - afx_msg void OnUpdateOptionsSoundDirectsounda(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundDirectsoundb(); - afx_msg void OnUpdateOptionsSoundDirectsoundb(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyBorder(); - afx_msg void OnUpdateOptionsGameboyBorder(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyPrinter(); - afx_msg void OnUpdateOptionsGameboyPrinter(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyBorderAutomatic(); - afx_msg void OnUpdateOptionsGameboyBorderAutomatic(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyAutomatic(); - afx_msg void OnUpdateOptionsGameboyAutomatic(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyGba(); - afx_msg void OnUpdateOptionsGameboyGba(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyCgb(); - afx_msg void OnUpdateOptionsGameboyCgb(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboySgb(); - afx_msg void OnUpdateOptionsGameboySgb(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboySgb2(); - afx_msg void OnUpdateOptionsGameboySgb2(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyGb(); - afx_msg void OnUpdateOptionsGameboyGb(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyRealcolors(); - afx_msg void OnUpdateOptionsGameboyRealcolors(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyGameboycolors(); - afx_msg void OnUpdateOptionsGameboyGameboycolors(CCmdUI* pCmdUI); - afx_msg void OnOptionsGameboyColors(); - afx_msg void OnOptionsFilterDisablemmx(); - afx_msg void OnUpdateOptionsFilterDisablemmx(CCmdUI* pCmdUI); - afx_msg void OnOptionsLanguageSystem(); - afx_msg void OnUpdateOptionsLanguageSystem(CCmdUI* pCmdUI); - afx_msg void OnOptionsLanguageEnglish(); - afx_msg void OnUpdateOptionsLanguageEnglish(CCmdUI* pCmdUI); - afx_msg void OnOptionsLanguageOther(); - afx_msg void OnUpdateOptionsLanguageOther(CCmdUI* pCmdUI); - afx_msg void OnOptionsJoypadConfigure1(); - afx_msg void OnUpdateOptionsJoypadConfigure1(CCmdUI* pCmdUI); - afx_msg void OnOptionsJoypadConfigure2(); - afx_msg void OnUpdateOptionsJoypadConfigure2(CCmdUI* pCmdUI); - afx_msg void OnOptionsJoypadConfigure3(); - afx_msg void OnUpdateOptionsJoypadConfigure3(CCmdUI* pCmdUI); - afx_msg void OnOptionsJoypadConfigure4(); - afx_msg void OnUpdateOptionsJoypadConfigure4(CCmdUI* pCmdUI); - afx_msg void OnOptionsJoypadMotionconfigure(); - afx_msg void OnUpdateOptionsJoypadMotionconfigure(CCmdUI* pCmdUI); - afx_msg void OnCheatsSearchforcheats(); - afx_msg void OnUpdateCheatsSearchforcheats(CCmdUI* pCmdUI); - afx_msg void OnCheatsCheatlist(); - afx_msg void OnUpdateCheatsCheatlist(CCmdUI* pCmdUI); - afx_msg void OnCheatsAutomaticsaveloadcheats(); - afx_msg void OnCheatsLoadcheatlist(); - afx_msg void OnUpdateCheatsLoadcheatlist(CCmdUI* pCmdUI); - afx_msg void OnCheatsSavecheatlist(); - afx_msg void OnUpdateCheatsSavecheatlist(CCmdUI* pCmdUI); - afx_msg void OnToolsDisassemble(); - afx_msg void OnUpdateToolsDisassemble(CCmdUI* pCmdUI); - afx_msg void OnToolsLogging(); - afx_msg void OnUpdateToolsLogging(CCmdUI* pCmdUI); - afx_msg void OnToolsIoviewer(); - afx_msg void OnUpdateToolsIoviewer(CCmdUI* pCmdUI); - afx_msg void OnToolsMapview(); - afx_msg void OnUpdateToolsMapview(CCmdUI* pCmdUI); - afx_msg void OnToolsMemoryviewer(); - afx_msg void OnUpdateToolsMemoryviewer(CCmdUI* pCmdUI); - afx_msg void OnToolsOamviewer(); - afx_msg void OnUpdateToolsOamviewer(CCmdUI* pCmdUI); - afx_msg void OnToolsPaletteview(); - afx_msg void OnUpdateToolsPaletteview(CCmdUI* pCmdUI); - afx_msg void OnToolsTileviewer(); - afx_msg void OnUpdateToolsTileviewer(CCmdUI* pCmdUI); - afx_msg void OnDebugNextframe(); - afx_msg void OnUpdateCheatsAutomaticsaveloadcheats(CCmdUI* pCmdUI); - afx_msg void OnToolsDebugConfigurePort(); - afx_msg void OnUpdateToolsDebugConfigurePort(CCmdUI* pCmdUI); - afx_msg void OnToolsDebugBreakOnLoad(); - afx_msg void OnUpdateToolsDebugBreakOnLoad(CCmdUI* pCmdUI); - afx_msg void OnToolsDebugBreak(); - afx_msg void OnUpdateToolsDebugBreak(CCmdUI* pCmdUI); - afx_msg void OnToolsDebugDisconnect(); - afx_msg void OnUpdateToolsDebugDisconnect(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundStartrecording(); - afx_msg void OnUpdateOptionsSoundStartrecording(CCmdUI* pCmdUI); - afx_msg void OnOptionsSoundStoprecording(); - afx_msg void OnUpdateOptionsSoundStoprecording(CCmdUI* pCmdUI); - afx_msg void OnToolsRecordStartavirecording(); - afx_msg void OnUpdateToolsRecordStartavirecording(CCmdUI* pCmdUI); - afx_msg void OnToolsRecordStopavirecording(); - afx_msg void OnUpdateToolsRecordStopavirecording(CCmdUI* pCmdUI); - afx_msg void OnPaint(); - afx_msg void OnToolsRecordStartmovierecording(); - afx_msg void OnUpdateToolsRecordStartmovierecording(CCmdUI* pCmdUI); - afx_msg void OnToolsRecordStopmovierecording(); - afx_msg void OnUpdateToolsRecordStopmovierecording(CCmdUI* pCmdUI); - afx_msg void OnToolsPlayStartmovieplaying(); - afx_msg void OnUpdateToolsPlayStartmovieplaying(CCmdUI* pCmdUI); - afx_msg void OnToolsPlayStopmovieplaying(); - afx_msg void OnUpdateToolsPlayStopmovieplaying(CCmdUI* pCmdUI); - afx_msg void OnToolsRewind(); - afx_msg void OnUpdateToolsRewind(CCmdUI* pCmdUI); - afx_msg void OnToolsCustomize(); - afx_msg void OnUpdateToolsCustomize(CCmdUI* pCmdUI); - afx_msg void OnHelpBugreport(); - afx_msg void OnMouseMove(UINT nFlags, CPoint point); - afx_msg void OnInitMenu(CMenu* pMenu); - afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized); - afx_msg void OnDropFiles(HDROP hDropInfo); - afx_msg void OnFileSavegameOldestslot(); - afx_msg void OnUpdateFileSavegameOldestslot(CCmdUI* pCmdUI); - afx_msg void OnFileLoadgameMostrecent(); - afx_msg void OnUpdateFileLoadgameMostrecent(CCmdUI* pCmdUI); - afx_msg void OnFileLoadgameAutoloadmostrecent(); - afx_msg void OnUpdateFileLoadgameAutoloadmostrecent(CCmdUI* pCmdUI); - afx_msg void OnCheatsDisablecheats(); - afx_msg void OnUpdateCheatsDisablecheats(CCmdUI* pCmdUI); - afx_msg void OnOptionsVideoFullscreenmaxscale(); - afx_msg void OnOptionsSelectPlugin(); - afx_msg void OnOptionsEmulatorGameoverrides(); - afx_msg void OnUpdateOptionsEmulatorGameoverrides(CCmdUI* pCmdUI); - afx_msg void OnHelpGnupubliclicense(); - afx_msg BOOL OnFileRecentFile(UINT nID); - afx_msg BOOL OnFileLoadSlot(UINT nID); - afx_msg BOOL OnFileSaveSlot(UINT nID); - afx_msg void OnOptionsSoundHardwareacceleration(); - afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI); - afx_msg void OnLinkOptions(); + afx_msg void OnOutputapiDirectsound(); + afx_msg void OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI); - afx_msg void OnOutputapiDirectsound(); - afx_msg void OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI); + afx_msg void OnOutputapiOpenal(); + afx_msg void OnUpdateOutputapiOpenal(CCmdUI *pCmdUI); + afx_msg void OnOutputapiOalconfiguration(); + afx_msg void OnUpdateOutputapiOalconfiguration(CCmdUI *pCmdUI); - afx_msg void OnOutputapiOpenal(); - afx_msg void OnUpdateOutputapiOpenal(CCmdUI *pCmdUI); - afx_msg void OnOutputapiOalconfiguration(); - afx_msg void OnUpdateOutputapiOalconfiguration(CCmdUI *pCmdUI); + afx_msg void OnOutputapiXaudio2(); + afx_msg void OnUpdateOutputapiXaudio2(CCmdUI *pCmdUI); + afx_msg void OnOutputapiXaudio2config(); + afx_msg void OnUpdateOutputapiXaudio2config(CCmdUI *pCmdUI); - afx_msg void OnOutputapiXaudio2(); - afx_msg void OnUpdateOutputapiXaudio2(CCmdUI *pCmdUI); - afx_msg void OnOutputapiXaudio2config(); - afx_msg void OnUpdateOutputapiXaudio2config(CCmdUI *pCmdUI); + afx_msg void OnRenderapiD3dmotionblur(); + afx_msg void OnUpdateRenderapiD3dmotionblur(CCmdUI *pCmdUI); + afx_msg void OnPixelfilterMultiThreading(); - afx_msg void OnRenderapiD3dmotionblur(); - afx_msg void OnUpdateRenderapiD3dmotionblur(CCmdUI *pCmdUI); - afx_msg void OnPixelfilterMultiThreading(); + afx_msg void OnMoving(UINT fwSide, LPRECT pRect); + afx_msg void OnSizing(UINT fwSide, LPRECT pRect); + afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnWindowPosChanging(WINDOWPOS *lpwndpos); + afx_msg void OnEmulatorBiosfiles(); + afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point); + afx_msg void OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI); + afx_msg void OnUpdateOptionsSelectPlugin(CCmdUI *pCmdUI); - afx_msg void OnMoving(UINT fwSide, LPRECT pRect); - afx_msg void OnSizing(UINT fwSide, LPRECT pRect); - afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); - afx_msg void OnWindowPosChanging(WINDOWPOS* lpwndpos); - afx_msg void OnEmulatorBiosfiles(); - afx_msg void OnNcRButtonDown(UINT nHitTest, CPoint point); - afx_msg void OnUpdatePixelfilterMultiThreading(CCmdUI *pCmdUI); - afx_msg void OnUpdateOptionsSelectPlugin(CCmdUI *pCmdUI); + afx_msg void OnLoadgameDonotchangebatterysave(); + afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI); + afx_msg void OnLoadgameDonotchangecheatlist(); + afx_msg void OnUpdateLoadgameDonotchangecheatlist(CCmdUI *pCmdUI); - afx_msg void OnLoadgameDonotchangebatterysave(); - afx_msg void OnUpdateLoadgameDonotchangebatterysave(CCmdUI *pCmdUI); - afx_msg void OnLoadgameDonotchangecheatlist(); - afx_msg void OnUpdateLoadgameDonotchangecheatlist(CCmdUI *pCmdUI); + afx_msg void OnEnterSizeMove(); - afx_msg void OnEnterSizeMove(); - - afx_msg void OnAudioCoreSettings(); - afx_msg void OnUpdateAudioCoreSettings(CCmdUI *pCmdUI); + afx_msg void OnAudioCoreSettings(); + afx_msg void OnUpdateAudioCoreSettings(CCmdUI *pCmdUI); }; diff --git a/src/win32/MapView.h b/src/win32/MapView.h index a19af6ba..69fa13cf 100644 --- a/src/win32/MapView.h +++ b/src/win32/MapView.h @@ -7,97 +7,95 @@ // MapView.h : header file // +#include "../System.h" // Added by ClassView #include "BitmapControl.h" #include "ColorControl.h" -#include "ZoomControl.h" -#include "ResizeDlg.h" #include "IUpdate.h" -#include "../System.h" // Added by ClassView +#include "ResizeDlg.h" +#include "ZoomControl.h" ///////////////////////////////////////////////////////////////////////////// // MapView dialog class MapView : public ResizeDlg, IUpdateListener { - private: - BITMAPINFO bmpInfo; - u8 *data; - int frame; - u16 control; - int bg; - int w; - int h; - BitmapControl mapView; - ZoomControl mapViewZoom; - ColorControl color; - bool autoUpdate; + private: + BITMAPINFO bmpInfo; + u8 *data; + int frame; + u16 control; + int bg; + int w; + int h; + BitmapControl mapView; + ZoomControl mapViewZoom; + ColorControl color; + bool autoUpdate; - // Construction - public: - void savePNG(const char *name); - void saveBMP(const char *name); - afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); - afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); - u32 GetClickAddress(int x, int y); - u32 GetTextClickAddress(u32 base, int x, int y); - void update(); - void enableButtons(int mode); - void paint(); - void renderMode5(); - void renderMode4(); - void renderMode3(); - void renderMode2(); - void renderMode1(); - void renderMode0(); - void renderRotScreen(u16 control); - void renderTextScreen(u16 control); - MapView(CWnd* pParent = NULL); // standard constructor - ~MapView(); + // Construction + public: + void savePNG(const char *name); + void saveBMP(const char *name); + afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + u32 GetClickAddress(int x, int y); + u32 GetTextClickAddress(u32 base, int x, int y); + void update(); + void enableButtons(int mode); + void paint(); + void renderMode5(); + void renderMode4(); + void renderMode3(); + void renderMode2(); + void renderMode1(); + void renderMode0(); + void renderRotScreen(u16 control); + void renderTextScreen(u16 control); + MapView(CWnd *pParent = NULL); // standard constructor + ~MapView(); - // Dialog Data - //{{AFX_DATA(MapView) - enum { IDD = IDD_MAP_VIEW }; - CStatic m_numcolors; - CStatic m_mode; - CStatic m_overflow; - CStatic m_mosaic; - CStatic m_priority; - CStatic m_dim; - CStatic m_charbase; - CStatic m_mapbase; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(MapView) + enum { IDD = IDD_MAP_VIEW }; + CStatic m_numcolors; + CStatic m_mode; + CStatic m_overflow; + CStatic m_mosaic; + CStatic m_priority; + CStatic m_dim; + CStatic m_charbase; + CStatic m_mapbase; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MapView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MapView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(MapView) + afx_msg void OnRefresh(); + virtual BOOL OnInitDialog(); + afx_msg void OnFrame0(); + afx_msg void OnFrame1(); + afx_msg void OnBg0(); + afx_msg void OnBg1(); + afx_msg void OnBg2(); + afx_msg void OnBg3(); + afx_msg void OnStretch(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + afx_msg void OnSave(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(MapView) - afx_msg void OnRefresh(); - virtual BOOL OnInitDialog(); - afx_msg void OnFrame0(); - afx_msg void OnFrame1(); - afx_msg void OnBg0(); - afx_msg void OnBg1(); - afx_msg void OnBg2(); - afx_msg void OnBg3(); - afx_msg void OnStretch(); - afx_msg void OnAutoUpdate(); - afx_msg void OnClose(); - afx_msg void OnSave(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MAPVIEW_H__20F40C77_8E10_44B7_BB49_7865F73C3E75__INCLUDED_) diff --git a/src/win32/MaxScale.h b/src/win32/MaxScale.h index ba8cbe90..cf5298a4 100644 --- a/src/win32/MaxScale.h +++ b/src/win32/MaxScale.h @@ -12,34 +12,32 @@ class MaxScale : public CDialog { -// Construction -public: - MaxScale(CWnd* pParent = NULL); // standard constructor + // Construction + public: + MaxScale(CWnd *pParent = NULL); // standard constructor -// Dialog Data - //{{AFX_DATA(MaxScale) - enum { IDD = IDD_MAX_SCALE }; - CEdit m_value; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(MaxScale) + enum { IDD = IDD_MAX_SCALE }; + CEdit m_value; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MaxScale) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MaxScale) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(MaxScale) - afx_msg void OnCancel(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(MaxScale) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} diff --git a/src/win32/MemoryViewer.h b/src/win32/MemoryViewer.h index 6f5d06b6..164b6801 100644 --- a/src/win32/MemoryViewer.h +++ b/src/win32/MemoryViewer.h @@ -1,7 +1,7 @@ #if !defined(AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_) #define AFX_MEMORYVIEWER_H__52C50474_5399_4D0B_A3E4_4C52C4E0EAA0__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -11,80 +11,80 @@ ///////////////////////////////////////////////////////////////////////////// // MemoryViewer window -class IMemoryViewerDlg { - public: - virtual void setCurrentAddress(u32 address)=0; +class IMemoryViewerDlg +{ + public: + virtual void setCurrentAddress(u32 address) = 0; }; class MemoryViewer : public CWnd { - u32 address; - int addressSize; - int dataSize; - bool hasCaret; - int caretWidth; - int caretHeight; - HFONT font; - CSize fontSize; - u32 editAddress; - int editNibble; - int maxNibble; - int displayedLines; - int beginAscii; - int beginHex; - bool editAscii; - IMemoryViewerDlg *dlg; + u32 address; + int addressSize; + int dataSize; + bool hasCaret; + int caretWidth; + int caretHeight; + HFONT font; + CSize fontSize; + u32 editAddress; + int editNibble; + int maxNibble; + int displayedLines; + int beginAscii; + int beginHex; + bool editAscii; + IMemoryViewerDlg *dlg; - static bool isRegistered; - // Construction - public: - MemoryViewer(); + static bool isRegistered; + // Construction + public: + MemoryViewer(); - // Attributes - public: + // Attributes + public: + // Operations + public: + virtual void readData(u32, int, u8 *) = 0; + virtual void editData(u32, int, int, u32) = 0; - // Operations - public: - virtual void readData(u32,int,u8 *) = 0; - virtual void editData(u32,int,int,u32)=0; + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewer) + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MemoryViewer) - //}}AFX_VIRTUAL + // Implementation + public: + int getSize(); + u32 getCurrentAddress(); + void setAddressSize(int s); + void registerClass(); + void beep(); + bool OnEditInput(UINT c); + void moveAddress(s32 offset, int nibbleOff); + void setCaretPos(); + void destroyEditCaret(); + void createEditCaret(int w, int h); + void updateScrollInfo(int lines); + void setSize(int s); + void setAddress(u32 a); + void setDialog(IMemoryViewerDlg *d); + virtual ~MemoryViewer(); - // Implementation - public: - int getSize(); - u32 getCurrentAddress(); - void setAddressSize(int s); - void registerClass(); - void beep(); - bool OnEditInput(UINT c); - void moveAddress(s32 offset, int nibbleOff); - void setCaretPos(); - void destroyEditCaret(); - void createEditCaret(int w, int h); - void updateScrollInfo(int lines); - void setSize(int s); - void setAddress(u32 a); - void setDialog(IMemoryViewerDlg *d); - virtual ~MemoryViewer(); - - // Generated message map functions - protected: - //{{AFX_MSG(MemoryViewer) - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnPaint(); - afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - afx_msg UINT OnGetDlgCode(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg void OnSetFocus(CWnd* pOldWnd); - afx_msg void OnKillFocus(CWnd* pNewWnd); - afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - afx_msg LRESULT OnWMChar(WPARAM wParam, LPARAM lParam); + // Generated message map functions + protected: + //{{AFX_MSG(MemoryViewer) + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnPaint(); + afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + afx_msg UINT OnGetDlgCode(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnSetFocus(CWnd *pOldWnd); + afx_msg void OnKillFocus(CWnd *pNewWnd); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + afx_msg LRESULT OnWMChar(WPARAM wParam, LPARAM lParam); }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/MemoryViewerAddressSize.h b/src/win32/MemoryViewerAddressSize.h index 51af50f4..681fa6da 100644 --- a/src/win32/MemoryViewerAddressSize.h +++ b/src/win32/MemoryViewerAddressSize.h @@ -1,7 +1,7 @@ #if !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_) #define AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 @@ -13,44 +13,43 @@ class MemoryViewerAddressSize : public CDialog { - u32 address; - int size; - // Construction - public: - int getSize(); - u32 getAddress(); - void setSize(int s); - void setAddress(u32 a); - MemoryViewerAddressSize(u32 a=0xffffff, int s=-1, CWnd* pParent = NULL); // standard constructor + u32 address; + int size; + // Construction + public: + int getSize(); + u32 getAddress(); + void setSize(int s); + void setAddress(u32 a); + MemoryViewerAddressSize(u32 a = 0xffffff, int s = -1, CWnd *pParent = NULL); // standard + // constructor - // Dialog Data - //{{AFX_DATA(MemoryViewerAddressSize) - enum { IDD = IDD_ADDR_SIZE }; - CEdit m_size; - CEdit m_address; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(MemoryViewerAddressSize) + enum { IDD = IDD_ADDR_SIZE }; + CEdit m_size; + CEdit m_address; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewerAddressSize) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MemoryViewerAddressSize) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(MemoryViewerAddressSize) + virtual BOOL OnInitDialog(); + afx_msg void OnOk(); + afx_msg void OnCancel(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(MemoryViewerAddressSize) - virtual BOOL OnInitDialog(); - afx_msg void OnOk(); - afx_msg void OnCancel(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MEMORYVIEWERADDRESSSIZE_H__04605262_2B1D_4EED_A467_B6C56AC2CACD__INCLUDED_) diff --git a/src/win32/MemoryViewerDlg.h b/src/win32/MemoryViewerDlg.h index 96559f64..2a1598e5 100644 --- a/src/win32/MemoryViewerDlg.h +++ b/src/win32/MemoryViewerDlg.h @@ -7,15 +7,16 @@ // MemoryViewerDlg.h : header file // +#include "IUpdate.h" #include "MemoryViewer.h" #include "ResizeDlg.h" -#include "IUpdate.h" -class GBAMemoryViewer : public MemoryViewer { - public: - GBAMemoryViewer(); - virtual void readData(u32, int, u8 *); - virtual void editData(u32,int,int,u32); +class GBAMemoryViewer : public MemoryViewer +{ + public: + GBAMemoryViewer(); + virtual void readData(u32, int, u8 *); + virtual void editData(u32, int, int, u32); }; ///////////////////////////////////////////////////////////////////////////// @@ -23,53 +24,51 @@ class GBAMemoryViewer : public MemoryViewer { class MemoryViewerDlg : public ResizeDlg, IUpdateListener, IMemoryViewerDlg { - GBAMemoryViewer m_viewer; - // Construction - public: - void setCurrentAddress(u32 address); - bool autoUpdate; - void update(); - MemoryViewerDlg(CWnd* pParent = NULL); // standard constructor + GBAMemoryViewer m_viewer; + // Construction + public: + void setCurrentAddress(u32 address); + bool autoUpdate; + void update(); + MemoryViewerDlg(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(MemoryViewerDlg) - enum { IDD = IDD_MEM_VIEWER }; - CEdit m_current; - CEdit m_address; - CComboBox m_addresses; - int m_size; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(MemoryViewerDlg) + enum { IDD = IDD_MEM_VIEWER }; + CEdit m_current; + CEdit m_address; + CComboBox m_addresses; + int m_size; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(MemoryViewerDlg) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(MemoryViewerDlg) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(MemoryViewerDlg) + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnRefresh(); + afx_msg void On8Bit(); + afx_msg void On16Bit(); + afx_msg void On32Bit(); + afx_msg void OnAutoUpdate(); + afx_msg void OnGo(); + afx_msg void OnSelchangeAddresses(); + afx_msg void OnSave(); + afx_msg void OnLoad(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(MemoryViewerDlg) - virtual BOOL OnInitDialog(); - afx_msg void OnClose(); - afx_msg void OnRefresh(); - afx_msg void On8Bit(); - afx_msg void On16Bit(); - afx_msg void On32Bit(); - afx_msg void OnAutoUpdate(); - afx_msg void OnGo(); - afx_msg void OnSelchangeAddresses(); - afx_msg void OnSave(); - afx_msg void OnLoad(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_MEMORYVIEWERDLG_H__15046D5B_D5A2_4C49_A969_2A77F803F2F1__INCLUDED_) diff --git a/src/win32/OALConfig.h b/src/win32/OALConfig.h index 4cdea3db..ab15d2ae 100644 --- a/src/win32/OALConfig.h +++ b/src/win32/OALConfig.h @@ -3,38 +3,38 @@ #pragma once // OpenAL +#include "LoadOAL.h" #include #include -#include "LoadOAL.h" - // OALConfig dialog class OALConfig : public CDialog { - DECLARE_DYNAMIC(OALConfig) + DECLARE_DYNAMIC(OALConfig) -public: - OALConfig(CWnd* pParent = NULL); // standard constructor - virtual ~OALConfig(); + public: + OALConfig(CWnd *pParent = NULL); // standard constructor + virtual ~OALConfig(); -// Dialog Data - enum { IDD = IDD_OAL_CONFIG }; + // Dialog Data + enum { IDD = IDD_OAL_CONFIG }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual BOOL OnInitDialog(); + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual BOOL OnInitDialog(); - DECLARE_MESSAGE_MAP() -private: - OPENALFNTABLE ALFunction; - CComboBox m_cbDevice; - CSliderCtrl m_sliderBufferCount; - CStatic m_bufferInfo; -public: - CString selectedDevice; - int bufferCount; - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); + DECLARE_MESSAGE_MAP() + private: + OPENALFNTABLE ALFunction; + CComboBox m_cbDevice; + CSliderCtrl m_sliderBufferCount; + CStatic m_bufferInfo; + + public: + CString selectedDevice; + int bufferCount; + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); }; #endif diff --git a/src/win32/OamView.h b/src/win32/OamView.h index 97bb074f..34160f4d 100644 --- a/src/win32/OamView.h +++ b/src/win32/OamView.h @@ -1,59 +1,60 @@ #pragma once +#include "BitmapControl.h" #include "IUpdate.h" #include "ResizeDlg.h" -#include "resource.h" -#include "BitmapControl.h" #include "gba/Globals.h" +#include "resource.h" // OamView dialog class OamViewable { -public: - BITMAPINFO bmpInfo; - BitmapControl oamView; - u8* data; - OamViewable(int index, CDialog* parent); - int w; - int h; - ~OamViewable(); + public: + BITMAPINFO bmpInfo; + BitmapControl oamView; + u8 *data; + OamViewable(int index, CDialog *parent); + int w; + int h; + ~OamViewable(); }; class OamView : public ResizeDlg, IUpdateListener { - DECLARE_DYNAMIC(OamView) -public: - void savePNG(const char *name); - void saveBMP(const char *name); - void render(); - void setAttributes(u16 a0, u16 a1, u16 a2); - void paint(); + DECLARE_DYNAMIC(OamView) + public: + void savePNG(const char *name); + void saveBMP(const char *name); + void render(); + void setAttributes(u16 a0, u16 a1, u16 a2); + void paint(); - virtual ~OamView(); - OamView(CWnd* pParent = NULL); // standard constructor + virtual ~OamView(); + OamView(CWnd *pParent = NULL); // standard constructor - virtual void update(); - // Dialog Data - enum { IDD = IDD_OAM_VIEW }; -private: - OamViewable* oamViews[128]; - BITMAPINFO bmpInfo; - u8* data_screen; - BitmapControl oamScreen; - BitmapControl oamPreview; - void UpdateOAM(int index); - int selectednumber; - bool autoUpdate; + virtual void update(); + // Dialog Data + enum { IDD = IDD_OAM_VIEW }; -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + private: + OamViewable *oamViews[128]; + BITMAPINFO bmpInfo; + u8 *data_screen; + BitmapControl oamScreen; + BitmapControl oamPreview; + void UpdateOAM(int index); + int selectednumber; + bool autoUpdate; - virtual BOOL OnInitDialog(); - afx_msg void OnAutoUpdate(); - afx_msg void OnClose(); - afx_msg void OnSave(); - afx_msg LRESULT OnOAMClick(WPARAM wParam, LPARAM lParam); - afx_msg void OnListDoubleClick(); + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support - DECLARE_MESSAGE_MAP() -public: + virtual BOOL OnInitDialog(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + afx_msg void OnSave(); + afx_msg LRESULT OnOAMClick(WPARAM wParam, LPARAM lParam); + afx_msg void OnListDoubleClick(); + + DECLARE_MESSAGE_MAP() + public: }; \ No newline at end of file diff --git a/src/win32/PaletteView.h b/src/win32/PaletteView.h index 7122da97..8a035524 100644 --- a/src/win32/PaletteView.h +++ b/src/win32/PaletteView.h @@ -11,9 +11,10 @@ #include "PaletteViewControl.h" #include "ResizeDlg.h" -class GBAPaletteViewControl : public PaletteViewControl { - public: - virtual void updatePalette(); +class GBAPaletteViewControl : public PaletteViewControl +{ + public: + virtual void updatePalette(); }; ///////////////////////////////////////////////////////////////////////////// @@ -21,53 +22,51 @@ class GBAPaletteViewControl : public PaletteViewControl { class PaletteView : public ResizeDlg, IUpdateListener { - private: - GBAPaletteViewControl paletteView; - GBAPaletteViewControl paletteViewOBJ; - ColorControl colorControl; - bool autoUpdate; - // Construction - public: - void save(int which); - PaletteView(CWnd* pParent = NULL); // standard constructor - ~PaletteView(); - afx_msg LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); + private: + GBAPaletteViewControl paletteView; + GBAPaletteViewControl paletteViewOBJ; + ColorControl colorControl; + bool autoUpdate; + // Construction + public: + void save(int which); + PaletteView(CWnd *pParent = NULL); // standard constructor + ~PaletteView(); + afx_msg LRESULT OnPalInfo(WPARAM wParam, LPARAM lParam); - // Dialog Data - //{{AFX_DATA(PaletteView) - enum { IDD = IDD_PALETTE_VIEW }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(PaletteView) + enum { IDD = IDD_PALETTE_VIEW }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(PaletteView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PaletteView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + virtual void update(); - virtual void update(); - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(PaletteView) - virtual BOOL OnInitDialog(); - afx_msg void OnSaveBg(); - afx_msg void OnSaveObj(); - afx_msg void OnRefresh2(); - afx_msg void OnAutoUpdate(); - afx_msg void OnClose(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -public: - afx_msg void OnBnClickedChangeBackdrop(); + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(PaletteView) + virtual BOOL OnInitDialog(); + afx_msg void OnSaveBg(); + afx_msg void OnSaveObj(); + afx_msg void OnRefresh2(); + afx_msg void OnAutoUpdate(); + afx_msg void OnClose(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + public: + afx_msg void OnBnClickedChangeBackdrop(); }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_PALETTEVIEW1_H__0873E3FF_9486_4B2C_8EF0_59C3B4F47162__INCLUDED_) diff --git a/src/win32/PaletteViewControl.h b/src/win32/PaletteViewControl.h index ac84e12e..34dc1f85 100644 --- a/src/win32/PaletteViewControl.h +++ b/src/win32/PaletteViewControl.h @@ -6,64 +6,63 @@ #endif // _MSC_VER > 1000 // PaletteViewControl.h : header file // -#define WM_PALINFO WM_APP+1 +#define WM_PALINFO WM_APP + 1 ///////////////////////////////////////////////////////////////////////////// // PaletteViewControl window class PaletteViewControl : public CWnd { - int w; - int h; - int colors; - u8 *data; - BITMAPINFO bmpInfo; - static bool isRegistered; - int selected; - protected: - u16 palette[256]; - int paletteAddress; - // Construction - public: - PaletteViewControl(); + int w; + int h; + int colors; + u8 *data; + BITMAPINFO bmpInfo; + static bool isRegistered; + int selected; - virtual void updatePalette()=0; + protected: + u16 palette[256]; + int paletteAddress; + // Construction + public: + PaletteViewControl(); - // Attributes - public: + virtual void updatePalette() = 0; - // Operations - public: + // Attributes + public: + // Operations + public: + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(PaletteViewControl) + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(PaletteViewControl) - //}}AFX_VIRTUAL + // Implementation + public: + void registerClass(); + void refresh(); + void render(u16 color, int x, int y); + void setSelected(int s); + void setPaletteAddress(int address); + bool saveJASCPAL(const char *name); + bool saveMSPAL(const char *name); + bool saveAdobe(const char *name); + void init(int c, int w, int h); + virtual ~PaletteViewControl(); - // Implementation - public: - void registerClass(); - void refresh(); - void render(u16 color, int x, int y); - void setSelected(int s); - void setPaletteAddress(int address); - bool saveJASCPAL(const char *name); - bool saveMSPAL(const char *name); - bool saveAdobe(const char *name); - void init(int c, int w, int h); - virtual ~PaletteViewControl(); + // Generated message map functions + protected: + //{{AFX_MSG(PaletteViewControl) + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + afx_msg void OnPaint(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Generated message map functions - protected: - //{{AFX_MSG(PaletteViewControl) - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - afx_msg void OnPaint(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. diff --git a/src/win32/Reg.h b/src/win32/Reg.h index e095c747..467854b3 100644 --- a/src/win32/Reg.h +++ b/src/win32/Reg.h @@ -4,15 +4,16 @@ extern bool regEnabled; char *regQueryStringValue(const char *key, char *def); -DWORD regQueryDwordValue(const char *key, DWORD def, bool force=false); +DWORD regQueryDwordValue(const char *key, DWORD def, bool force = false); BOOL regQueryBinaryValue(const char *key, char *value, int count); -void regSetStringValue(const char *key,const char *value); -void regSetDwordValue(const char *key,DWORD value,bool force=false); +void regSetStringValue(const char *key, const char *value); +void regSetDwordValue(const char *key, DWORD value, bool force = false); void regSetBinaryValue(const char *key, char *value, int count); void regDeleteValue(char *key); void regInit(const char *, bool force = false); void regShutdown(); -bool regCreateFileType( const char *ext, const char *type ); -bool regAssociateType( const char *type, const char *desc, const char *application, const char *icon = NULL ); +bool regCreateFileType(const char *ext, const char *type); +bool regAssociateType(const char *type, const char *desc, const char *application, + const char *icon = NULL); void regExportSettingsToINI(); #endif // VBA_REG_H diff --git a/src/win32/ResizeDlg.h b/src/win32/ResizeDlg.h index eeb61585..1fe193d5 100644 --- a/src/win32/ResizeDlg.h +++ b/src/win32/ResizeDlg.h @@ -3,38 +3,42 @@ #ifndef _INC_TCHAR #include -#endif // _INC_TCHAR +#endif // _INC_TCHAR // // Predefined sizing information -#define DS_MoveX 1 -#define DS_MoveY 2 -#define DS_SizeX 4 -#define DS_SizeY 8 +#define DS_MoveX 1 +#define DS_MoveY 2 +#define DS_SizeX 4 +#define DS_SizeY 8 -typedef struct DialogSizerSizingItem // sdi +typedef struct DialogSizerSizingItem // sdi { - UINT uControlID; - UINT uSizeInfo; + UINT uControlID; + UINT uSizeInfo; } DialogSizerSizingItem; -#define DIALOG_SIZER_START( name ) DialogSizerSizingItem name[] = { -#define DIALOG_SIZER_ENTRY( controlID, flags ) { controlID, flags }, -#define DIALOG_SIZER_END() { 0xFFFFFFFF, 0xFFFFFFFF } }; +#define DIALOG_SIZER_START(name) DialogSizerSizingItem name[] = { +#define DIALOG_SIZER_ENTRY(controlID, flags) { controlID, flags }, +#define DIALOG_SIZER_END() \ + { \ + 0xFFFFFFFF, 0xFFFFFFFF \ + } \ + } \ + ; -class ResizeDlg : public CDialog { - void *dd; - public: - ResizeDlg(UINT id, CWnd *parent = NULL); +class ResizeDlg : public CDialog +{ + void *dd; - void *AddDialogData(); - BOOL SetData(const DialogSizerSizingItem *psd, - BOOL bShowSizingGrip, - HKEY hkRootSave, - LPCTSTR pcszName, - SIZE *psizeMax); - void UpdateWindowSize(const int cx, const int cy, HWND); + public: + ResizeDlg(UINT id, CWnd *parent = NULL); - virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *); + void *AddDialogData(); + BOOL SetData(const DialogSizerSizingItem *psd, BOOL bShowSizingGrip, HKEY hkRootSave, + LPCTSTR pcszName, SIZE *psizeMax); + void UpdateWindowSize(const int cx, const int cy, HWND); + + virtual BOOL OnWndMsg(UINT, WPARAM, LPARAM, LRESULT *); }; #endif diff --git a/src/win32/RewindInterval.h b/src/win32/RewindInterval.h index 8cbe2441..6286a06b 100644 --- a/src/win32/RewindInterval.h +++ b/src/win32/RewindInterval.h @@ -12,38 +12,36 @@ class RewindInterval : public CDialog { - // Construction - public: - int interval; - RewindInterval(int interval, CWnd* pParent = NULL); // standard constructor + // Construction + public: + int interval; + RewindInterval(int interval, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(RewindInterval) - enum { IDD = IDD_REWIND_INTERVAL }; - CEdit m_interval; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(RewindInterval) + enum { IDD = IDD_REWIND_INTERVAL }; + CEdit m_interval; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RewindInterval) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(RewindInterval) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(RewindInterval) + afx_msg void OnCancel(); + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(RewindInterval) - afx_msg void OnCancel(); - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_REWINDINTERVAL_H__C95AFF44_1F64_44C8_BAAB_A54B982D28EA__INCLUDED_) diff --git a/src/win32/RomInfo.h b/src/win32/RomInfo.h index 804dbcb4..48192224 100644 --- a/src/win32/RomInfo.h +++ b/src/win32/RomInfo.h @@ -12,71 +12,67 @@ class RomInfoGB : public CDialog { - // Construction - public: - RomInfoGB(u8 *rom, CWnd* pParent = NULL); // standard constructor + // Construction + public: + RomInfoGB(u8 *rom, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(RomInfoGB) - enum { IDD = IDD_GB_ROM_INFO }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(RomInfoGB) + enum { IDD = IDD_GB_ROM_INFO }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RomInfoGB) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL + u8 *rom; - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(RomInfoGB) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - u8 *rom; + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(RomInfoGB) + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(RomInfoGB) - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - ///////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////// // RomInfoGBA dialog class RomInfoGBA : public CDialog { - // Construction - public: - RomInfoGBA(u8 *rom, CWnd* pParent = NULL); // standard constructor + // Construction + public: + RomInfoGBA(u8 *rom, CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(RomInfoGBA) - enum { IDD = IDD_GBA_ROM_INFO }; - // NOTE: the ClassWizard will add data members here - //}}AFX_DATA - u8 *rom; + // Dialog Data + //{{AFX_DATA(RomInfoGBA) + enum { IDD = IDD_GBA_ROM_INFO }; + // NOTE: the ClassWizard will add data members here + //}}AFX_DATA + u8 *rom; + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(RomInfoGBA) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(RomInfoGBA) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(RomInfoGBA) - afx_msg void OnOk(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(RomInfoGBA) + afx_msg void OnOk(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_ROMINFO_H__9888A45C_3E71_4C0F_B119_EFC74DFF8CD3__INCLUDED_) diff --git a/src/win32/SelectPlugin.h b/src/win32/SelectPlugin.h index 005fb60f..8232046c 100644 --- a/src/win32/SelectPlugin.h +++ b/src/win32/SelectPlugin.h @@ -9,44 +9,41 @@ ///////////////////////////////////////////////////////////////////////////// // SelectPlugin dialog -struct PluginDesc -{ - char sFile[MAX_PATH]; - char sDesc[60]; +struct PluginDesc { + char sFile[MAX_PATH]; + char sDesc[60]; }; class SelectPlugin : public CDialog { -// Construction -public: - SelectPlugin(CWnd* pParent = NULL); // standard constructor - size_t EnumPlugins(); - bool GetPluginDesc(const char *sRpi, PluginDesc *pDesc); + // Construction + public: + SelectPlugin(CWnd *pParent = NULL); // standard constructor + size_t EnumPlugins(); + bool GetPluginDesc(const char *sRpi, PluginDesc *pDesc); -// Dialog Data - //{{AFX_DATA(SelectPlugin) - enum { IDD = IDD_SELECT_PLUGIN }; - CComboBox m_comboPlugin; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(SelectPlugin) + enum { IDD = IDD_SELECT_PLUGIN }; + CComboBox m_comboPlugin; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(SelectPlugin) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL -// Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(SelectPlugin) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL - -// Implementation -protected: - - // Generated message map functions - //{{AFX_MSG(SelectPlugin) - virtual void OnOK(); - virtual void OnCancel(); - virtual BOOL OnInitDialog(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(SelectPlugin) + virtual void OnOK(); + virtual void OnCancel(); + virtual BOOL OnInitDialog(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() }; //{{AFX_INSERT_LOCATION}} diff --git a/src/win32/StringTokenizer.h b/src/win32/StringTokenizer.h index 6b8eb133..f38073e1 100644 --- a/src/win32/StringTokenizer.h +++ b/src/win32/StringTokenizer.h @@ -7,15 +7,15 @@ class StringTokenizer { - public: - const char * next(); - StringTokenizer(CString str, CString token); - virtual ~StringTokenizer(); + public: + const char *next(); + StringTokenizer(CString str, CString token); + virtual ~StringTokenizer(); - private: - CString m_token; - CString m_delim; - CString m_right; + private: + CString m_token; + CString m_delim; + CString m_right; }; #endif // !defined(AFX_STRINGTOKENIZER_H__1AB4CD12_6B7A_49E4_A87F_75D3DC3FF20F__INCLUDED_) diff --git a/src/win32/Throttle.h b/src/win32/Throttle.h index 0a9dfd2b..1a7661e5 100644 --- a/src/win32/Throttle.h +++ b/src/win32/Throttle.h @@ -12,37 +12,35 @@ class Throttle : public CDialog { - // Construction - public: - Throttle(CWnd* pParent = NULL); // standard constructor + // Construction + public: + Throttle(CWnd *pParent = NULL); // standard constructor - // Dialog Data - //{{AFX_DATA(Throttle) - enum { IDD = IDD_THROTTLE }; - int m_throttle; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(Throttle) + enum { IDD = IDD_THROTTLE }; + int m_throttle; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(Throttle) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(Throttle) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //}}AFX_VIRTUAL + // Implementation + protected: + // Generated message map functions + //{{AFX_MSG(Throttle) + virtual BOOL OnInitDialog(); + afx_msg void OnCancel(); + afx_msg void OnOk(); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Implementation - protected: - - // Generated message map functions - //{{AFX_MSG(Throttle) - virtual BOOL OnInitDialog(); - afx_msg void OnCancel(); - afx_msg void OnOk(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_THROTTLE_H__5F03B6E9_0C43_4933_A7BC_1618428C2B7F__INCLUDED_) diff --git a/src/win32/TileView.h b/src/win32/TileView.h index 0c082efe..8ae8c29d 100644 --- a/src/win32/TileView.h +++ b/src/win32/TileView.h @@ -18,73 +18,72 @@ class TileView : public ResizeDlg, IUpdateListener { - int charBase; - int is256Colors; - int palette; - BitmapControl tileView; - BITMAPINFO bmpInfo; - u8 *data; - ZoomControl zoom; - ColorControl color; - int w; - int h; - bool autoUpdate; - // Construction - public: - void paint(); - void render(); - void renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette); - void renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette); - void savePNG(const char *name); - void saveBMP(const char *name); - TileView(CWnd* pParent = NULL); // standard constructor - virtual ~TileView(); + int charBase; + int is256Colors; + int palette; + BitmapControl tileView; + BITMAPINFO bmpInfo; + u8 *data; + ZoomControl zoom; + ColorControl color; + int w; + int h; + bool autoUpdate; + // Construction + public: + void paint(); + void render(); + void renderTile16(int tile, int x, int y, u8 *charBase, u16 *palette); + void renderTile256(int tile, int x, int y, u8 *charBase, u16 *palette); + void savePNG(const char *name); + void saveBMP(const char *name); + TileView(CWnd *pParent = NULL); // standard constructor + virtual ~TileView(); - virtual void update(); + virtual void update(); - // Dialog Data - //{{AFX_DATA(TileView) - enum { IDD = IDD_TILE_VIEWER }; - CSliderCtrl m_slider; - int m_colors; - int m_charBase; - BOOL m_stretch; - //}}AFX_DATA + // Dialog Data + //{{AFX_DATA(TileView) + enum { IDD = IDD_TILE_VIEWER }; + CSliderCtrl m_slider; + int m_colors; + int m_charBase; + BOOL m_stretch; + //}}AFX_DATA + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(TileView) + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support + virtual void PostNcDestroy(); + //}}AFX_VIRTUAL - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(TileView) - protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - virtual void PostNcDestroy(); - //}}AFX_VIRTUAL + // Implementation + protected: + virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); + virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); - // Implementation - protected: - virtual afx_msg LRESULT OnMapInfo(WPARAM wParam, LPARAM lParam); - virtual afx_msg LRESULT OnColInfo(WPARAM wParam, LPARAM lParam); + // Generated message map functions + //{{AFX_MSG(TileView) + afx_msg void OnSave(); + virtual BOOL OnInitDialog(); + afx_msg void OnClose(); + afx_msg void OnAutoUpdate(); + afx_msg void On16Colors(); + afx_msg void On256Colors(); + afx_msg void OnCharbase0(); + afx_msg void OnCharbase1(); + afx_msg void OnCharbase2(); + afx_msg void OnCharbase3(); + afx_msg void OnCharbase4(); + afx_msg void OnStretch(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() +}; - // Generated message map functions - //{{AFX_MSG(TileView) - afx_msg void OnSave(); - virtual BOOL OnInitDialog(); - afx_msg void OnClose(); - afx_msg void OnAutoUpdate(); - afx_msg void On16Colors(); - afx_msg void On256Colors(); - afx_msg void OnCharbase0(); - afx_msg void OnCharbase1(); - afx_msg void OnCharbase2(); - afx_msg void OnCharbase3(); - afx_msg void OnCharbase4(); - afx_msg void OnStretch(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - }; - - //{{AFX_INSERT_LOCATION}} - // Microsoft Visual C++ will insert additional declarations immediately before the previous line. +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_TILEVIEW_H__055751EC_2DF3_495B_B643_29025465CD2E__INCLUDED_) diff --git a/src/win32/VBA.h b/src/win32/VBA.h index 2dbde545..59946fef 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -6,52 +6,76 @@ #include "resource.h" +#include "../System.h" +#include "../Util.h" #include "AcceleratorManager.h" #include "Display.h" -#include "Input.h" #include "IUpdate.h" -#include "../System.h" +#include "Input.h" #include "common/ConfigManager.h" -#include "../Util.h" ///////////////////////////////////////////////////////////////////////////// // VBA: // See VBA.cpp for the implementation of this class // -enum VIDEO_SIZE{ - VIDEO_1X, VIDEO_2X, VIDEO_3X, VIDEO_4X, VIDEO_5X, VIDEO_6X, - VIDEO_320x240, VIDEO_640x480, VIDEO_800x600, VIDEO_1024x768, VIDEO_1280x1024, - VIDEO_OTHER +enum VIDEO_SIZE { + VIDEO_1X, + VIDEO_2X, + VIDEO_3X, + VIDEO_4X, + VIDEO_5X, + VIDEO_6X, + VIDEO_320x240, + VIDEO_640x480, + VIDEO_800x600, + VIDEO_1024x768, + VIDEO_1280x1024, + VIDEO_OTHER }; -enum pixelFilterType -{ - FILTER_NONE, +enum pixelFilterType { + FILTER_NONE, - FILTER_SIMPLE2X, FILTER_PIXELATE, FILTER_TVMODE, FILTER_SCANLINES, - FILTER_PLUGIN, - FILTER_BILINEAR, FILTER_BILINEARPLUS, FILTER_MAMESCALE2X, - FILTER_2XSAI, FILTER_SUPER2XSAI, FILTER_SUPEREAGLE, FILTER_LQ2X, FILTER_HQ2X, FILTER_XBRZ2X, + FILTER_SIMPLE2X, + FILTER_PIXELATE, + FILTER_TVMODE, + FILTER_SCANLINES, + FILTER_PLUGIN, + FILTER_BILINEAR, + FILTER_BILINEARPLUS, + FILTER_MAMESCALE2X, + FILTER_2XSAI, + FILTER_SUPER2XSAI, + FILTER_SUPEREAGLE, + FILTER_LQ2X, + FILTER_HQ2X, + FILTER_XBRZ2X, - FILTER_SIMPLE3X, FILTER_HQ3X, FILTER_XBRZ3X, + FILTER_SIMPLE3X, + FILTER_HQ3X, + FILTER_XBRZ3X, - FILTER_SIMPLE4X, FILTER_HQ4X, FILTER_XBRZ4X, + FILTER_SIMPLE4X, + FILTER_HQ4X, + FILTER_XBRZ4X, - FILTER_XBRZ5X, + FILTER_XBRZ5X, - FILTER_XBRZ6X, + FILTER_XBRZ6X, - FILTER_LAST = FILTER_XBRZ6X + FILTER_LAST = FILTER_XBRZ6X }; enum AUDIO_API { - DIRECTSOUND = 0 + DIRECTSOUND = 0 #ifndef NO_OAL - , OPENAL_SOUND = 1 + , + OPENAL_SOUND = 1 #endif #ifndef NO_XAUDIO2 - , XAUDIO2 = 2 + , + XAUDIO2 = 2 #endif }; @@ -62,136 +86,136 @@ class WavWriter; class VBA : public CWinApp { - public: - CMenu m_menu; - HMENU menu; - HMENU popup; + public: + CMenu m_menu; + HMENU menu; + HMENU popup; - AVIWrite *aviRecorder; + AVIWrite *aviRecorder; - char *rewindMemory; - char pluginName[MAX_PATH]; - CString aviRecordName; - CString biosFileNameGB; - CString biosFileNameGBA; - CString biosFileNameGBC; - CString languageName; - CString linkHostAddr; - CString recentFiles[10]; - CString screenMessageBuffer; - CString soundRecordName; - DISPLAY_TYPE renderMethod; - DWORD screenMessageTime; - FILE *movieFile; - FILE *winout; - HMODULE languageModule; - IDisplay *display; - IMAGE_TYPE cartridgeType; + char *rewindMemory; + char pluginName[MAX_PATH]; + CString aviRecordName; + CString biosFileNameGB; + CString biosFileNameGBA; + CString biosFileNameGBC; + CString languageName; + CString linkHostAddr; + CString recentFiles[10]; + CString screenMessageBuffer; + CString soundRecordName; + DISPLAY_TYPE renderMethod; + DWORD screenMessageTime; + FILE *movieFile; + FILE *winout; + HMODULE languageModule; + IDisplay *display; + IMAGE_TYPE cartridgeType; - bool soundInitialized; + bool soundInitialized; - Input *input; + Input *input; - u8 *delta[257 * 244 * 4]; - unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect - unsigned int skipAudioFrames; - void(*filterFunction)(u8*, u32, u8*, u8*, u32, int, int); - void(*ifbFunction)(u8*, u32, int, int); - WavWriter *soundRecorder; + u8 *delta[257 * 244 * 4]; + unsigned int maxCpuCores; // maximum number of CPU cores VBA should use, 0 means auto-detect + unsigned int skipAudioFrames; + void (*filterFunction)(u8 *, u32, u8 *, u8 *, u32, int, int); + void (*ifbFunction)(u8 *, u32, int, int); + WavWriter *soundRecorder; - bool changingVideoSize; - AUDIO_API audioAPI; + bool changingVideoSize; + AUDIO_API audioAPI; #ifndef NO_OAL - TCHAR *oalDevice; - int oalBufferCount; + TCHAR *oalDevice; + int oalBufferCount; #endif #ifndef NO_XAUDIO2 - UINT32 xa2Device; - UINT32 xa2BufferCount; - bool xa2Upmixing; + UINT32 xa2Device; + UINT32 xa2BufferCount; + bool xa2Upmixing; #endif #ifndef NO_D3D - int d3dFilter; - bool d3dMotionBlur; + int d3dFilter; + bool d3dMotionBlur; #endif - bool iconic; - bool painting; - int romSize; - VIDEO_SIZE lastWindowed; - VIDEO_SIZE lastFullscreen; + bool iconic; + bool painting; + int romSize; + VIDEO_SIZE lastWindowed; + VIDEO_SIZE lastFullscreen; - CList updateList; - int updateCount; + CList updateList; + int updateCount; - CAcceleratorManager winAccelMgr; - HACCEL hAccel; + CAcceleratorManager winAccelMgr; + HACCEL hAccel; - RECT rect; - RECT dest; + RECT rect; + RECT dest; - struct EmulatedSystem emulator; + struct EmulatedSystem emulator; - CString szFile; - CString filename; - CString dir; + CString szFile; + CString filename; + CString dir; - CString loadDotCodeFile; - CString saveDotCodeFile; + CString loadDotCodeFile; + CString saveDotCodeFile; - CString wndClass; + CString wndClass; - public: - VBA(); - ~VBA(); + public: + VBA(); + ~VBA(); - void adjustDestRect(); - void updateIFB(); - void updateFilter(); - void updateThrottle( unsigned short throttle ); - void updateMenuBar(); - void winAddUpdateListener(IUpdateListener *l); - void winRemoveUpdateListener(IUpdateListener *l); - CString winLoadFilter(UINT id); + void adjustDestRect(); + void updateIFB(); + void updateFilter(); + void updateThrottle(unsigned short throttle); + void updateMenuBar(); + void winAddUpdateListener(IUpdateListener *l); + void winRemoveUpdateListener(IUpdateListener *l); + CString winLoadFilter(UINT id); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(VBA) - public: - virtual BOOL InitInstance(); - virtual BOOL OnIdle(LONG lCount); - //}}AFX_VIRTUAL + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(VBA) + public: + virtual BOOL InitInstance(); + virtual BOOL OnIdle(LONG lCount); + //}}AFX_VIRTUAL - // Implementation + // Implementation - public: - void saveSettings(); - void movieReadNext(); - bool initInput(); - HMODULE winLoadLanguage(const char *name); - void winSetLanguageOption(int option, bool force); + public: + void saveSettings(); + void movieReadNext(); + bool initInput(); + HMODULE winLoadLanguage(const char *name); + void winSetLanguageOption(int option, bool force); #ifdef MMX - bool detectMMX(); + bool detectMMX(); #endif - void updatePriority(); - void directXMessage(const char *msg); - void shutdownDisplay(); - bool preInitialize(); - bool updateRenderMethod0(bool force); - bool updateRenderMethod(bool force); - bool initDisplay(); - void updateWindowSize(int value); - void updateVideoSize(UINT id); - void updateFrameSkip(); - void loadSettings(); - void addRecentFile(CString file); + void updatePriority(); + void directXMessage(const char *msg); + void shutdownDisplay(); + bool preInitialize(); + bool updateRenderMethod0(bool force); + bool updateRenderMethod(bool force); + bool initDisplay(); + void updateWindowSize(int value); + void updateVideoSize(UINT id); + void updateFrameSkip(); + void loadSettings(); + void addRecentFile(CString file); - private: - unsigned int detectCpuCores(); + private: + unsigned int detectCpuCores(); }; - extern VBA theApp; - extern int emulating; +extern VBA theApp; +extern int emulating; #ifdef MMX - extern "C" bool cpu_mmx; +extern "C" bool cpu_mmx; #endif diff --git a/src/win32/WavWriter.h b/src/win32/WavWriter.h index 1738c572..dca13e42 100644 --- a/src/win32/WavWriter.h +++ b/src/win32/WavWriter.h @@ -9,21 +9,21 @@ class WavWriter { - private: - FILE *m_file; - int m_len; - long m_posSize; + private: + FILE *m_file; + int m_len; + long m_posSize; - public: - WavWriter(); - ~WavWriter(); + public: + WavWriter(); + ~WavWriter(); - bool Open(const char *name); - void SetFormat(const WAVEFORMATEX *format); - void AddSound(const u8 *data, int len); + bool Open(const char *name); + void SetFormat(const WAVEFORMATEX *format); + void AddSound(const u8 *data, int len); - private: - void Close(); + private: + void Close(); }; #endif // !defined(AFX_WAVWRITER_H__BE6C9DE9_60E7_4192_9797_8C7F55B3CE46__INCLUDED_) diff --git a/src/win32/WinHelper.h b/src/win32/WinHelper.h index a4ae88a5..06a4313e 100644 --- a/src/win32/WinHelper.h +++ b/src/win32/WinHelper.h @@ -17,216 +17,357 @@ #ifndef FASTCALL #define FASTCALL -#endif // FASTCALL +#endif // FASTCALL extern void AssertFailed(char *, int, char *); extern void ApiFailure(char *, int, char *); #define R_VERIFY(a) R_ASSERT(a) -#define R_ASSERT(a) \ - do {\ - if(!(a)) {\ - AssertFailed(__FILE__, __LINE__, #a);\ - }\ - } while(0); +#define R_ASSERT(a) \ + do { \ + if (!(a)) { \ + AssertFailed(__FILE__, __LINE__, #a); \ + } \ + } while (0); -#define VAPI(a) \ - do { \ - if(!(a)) {\ - ApiFailure(__FILE__, __LINE__, #a); \ - }\ - } while (0); +#define VAPI(a) \ + do { \ + if (!(a)) { \ + ApiFailure(__FILE__, __LINE__, #a); \ + } \ + } while (0); -#define ASSERT_VALID_HWND(a) ASSERT( ::IsWindow(a) ) +#define ASSERT_VALID_HWND(a) ASSERT(::IsWindow(a)) namespace WinHelper { - - class CSize : public tagSIZE - // - // Wrapper for the SIZE structure - { - public: - inline CSize() {}; - inline explicit CSize( const SIZE &size ) { cx = size.cx; cy = size.cy; } - inline explicit CSize( long nSizeX, long nSizeY ) { cx = nSizeX; cy = nSizeY; } - inline void Set( long nSizeX, long nSizeY ) { cx = nSizeX; cy = nSizeY; } - inline operator LPSIZE() { return this; }; - - inline bool operator !=( const SIZE &size ) const { return cx != size.cx || cy != size.cy;} - inline CSize & operator =( const SIZE &size ) { cx = size.cx; cy = size.cy; return *this; } - inline void Empty() { cx = cy = 0; } - }; - - - class CRect : public tagRECT - // - // Wrapper for a RECT structure - { - public: - inline CRect() {} - // Initialisation constructor - inline explicit CRect( const RECT& rhs ) { Set( rhs.left, rhs.top, rhs.right, rhs.bottom );} - inline CRect(int xLeft, int yTop, int xRight, int yBottom) { Set( xLeft, yTop, xRight, yBottom ); } - // Get the width of the rectangle - inline int Width() const { return right - left; } - // Get the height of the rectangle - inline int Height() const { return bottom - top; } - // overloaded operator so you don't have to do &rc anymore - inline operator LPCRECT() const { return this; }; - inline operator LPRECT() { return this; }; - // Return the SIZE of the rectangle; - inline CSize Size() const { CSize s( Width(), Height() ); return s; } - // Return the top left of the rectangle - inline POINT TopLeft() const { POINT pt = { left, top }; return pt; } - // Return the bottom right of the rectangle - inline POINT BottomRight() const { POINT pt = { right, bottom }; return pt; } - // Set the rectangles left, top, right and bottom - inline void Set( int xLeft, int yTop, int xRight, int yBottom) { top = yTop; bottom = yBottom; right = xRight; left = xLeft; } - // Return true if the rectangle contains all zeros - inline bool IsEmpty() const { return left == 0 && right == 0 && top == 0 && bottom == 0 ? true : false; } - // Zero out our rectangle - inline void Empty() { left = right = top = bottom = 0; } - // Set the size of the rect but leave the top left position untouched. - inline void SetSize( const CSize &size ) { bottom = top + size.cy; right = left + size.cx; } - inline void SetSize( const SIZE &size ) { bottom = top + size.cy; right = left + size.cx; } - inline void SetSize( int cx, int cy ) { bottom = top + cy; right = left + cx; } - // Move the rectangle by an offset - inline void Offset( int cx, int cy ) +class CSize : public tagSIZE +// +// Wrapper for the SIZE structure +{ + public: + inline CSize(){}; + inline explicit CSize(const SIZE &size) { - top+=cy; - bottom+=cy; - right+=cx; - left+=cx; + cx = size.cx; + cy = size.cy; } - // Inflate the rectangle by the cx and cy, use negative to shrink the rectangle - inline void Inflate( int cx, int cy ) + inline explicit CSize(long nSizeX, long nSizeY) { - top-=cy; - bottom+=cy; - right+=cx; - left-=cx; + cx = nSizeX; + cy = nSizeY; } - // Assignment from a RECT - inline CRect &operator = ( const RECT&rhs ) + inline void Set(long nSizeX, long nSizeY) { - left = rhs.left; top = rhs.top; - right = rhs.right; bottom = rhs.bottom; - return *this; + cx = nSizeX; + cy = nSizeY; + } + inline operator LPSIZE() + { + return this; + }; + + inline bool operator!=(const SIZE &size) const + { + return cx != size.cx || cy != size.cy; + } + inline CSize &operator=(const SIZE &size) + { + cx = size.cx; + cy = size.cy; + return *this; + } + inline void Empty() + { + cx = cy = 0; + } +}; + +class CRect : public tagRECT +// +// Wrapper for a RECT structure +{ + public: + inline CRect() + { + } + // Initialisation constructor + inline explicit CRect(const RECT &rhs) + { + Set(rhs.left, rhs.top, rhs.right, rhs.bottom); + } + inline CRect(int xLeft, int yTop, int xRight, int yBottom) + { + Set(xLeft, yTop, xRight, yBottom); + } + // Get the width of the rectangle + inline int Width() const + { + return right - left; + } + // Get the height of the rectangle + inline int Height() const + { + return bottom - top; + } + // overloaded operator so you don't have to do &rc anymore + inline operator LPCRECT() const + { + return this; + }; + inline operator LPRECT() + { + return this; + }; + // Return the SIZE of the rectangle; + inline CSize Size() const + { + CSize s(Width(), Height()); + return s; + } + // Return the top left of the rectangle + inline POINT TopLeft() const + { + POINT pt = { left, top }; + return pt; + } + // Return the bottom right of the rectangle + inline POINT BottomRight() const + { + POINT pt = { right, bottom }; + return pt; + } + // Set the rectangles left, top, right and bottom + inline void Set(int xLeft, int yTop, int xRight, int yBottom) + { + top = yTop; + bottom = yBottom; + right = xRight; + left = xLeft; + } + // Return true if the rectangle contains all zeros + inline bool IsEmpty() const + { + return left == 0 && right == 0 && top == 0 && bottom == 0 ? true : false; + } + // Zero out our rectangle + inline void Empty() + { + left = right = top = bottom = 0; + } + // Set the size of the rect but leave the top left position untouched. + inline void SetSize(const CSize &size) + { + bottom = top + size.cy; + right = left + size.cx; + } + inline void SetSize(const SIZE &size) + { + bottom = top + size.cy; + right = left + size.cx; + } + inline void SetSize(int cx, int cy) + { + bottom = top + cy; + right = left + cx; + } + // Move the rectangle by an offset + inline void Offset(int cx, int cy) + { + top += cy; + bottom += cy; + right += cx; + left += cx; + } + // Inflate the rectangle by the cx and cy, use negative to shrink the rectangle + inline void Inflate(int cx, int cy) + { + top -= cy; + bottom += cy; + right += cx; + left -= cx; + } + // Assignment from a RECT + inline CRect &operator=(const RECT &rhs) + { + left = rhs.left; + top = rhs.top; + right = rhs.right; + bottom = rhs.bottom; + return *this; } - // Return true if the point passed is within the rectangle - inline bool PtInRect( const POINT &pt ) const { return ( pt.x >= left && pt.x < right && pt.y >=top && pt.y < bottom ); } - // Return true if the rectangle passed overlaps this rectangle - inline bool Intersect( const RECT &rc ) const { return ( rc.left < right && rc.right > left && rc.top < bottom && rc.bottom > top ); } - }; + // Return true if the point passed is within the rectangle + inline bool PtInRect(const POINT &pt) const + { + return (pt.x >= left && pt.x < right && pt.y >= top && pt.y < bottom); + } + // Return true if the rectangle passed overlaps this rectangle + inline bool Intersect(const RECT &rc) const + { + return (rc.left < right && rc.right > left && rc.top < bottom && rc.bottom > top); + } +}; +class CPoint : public tagPOINT +// +// Wrapper for the POINT structure +{ + public: + inline CPoint(){}; + inline CPoint(LPARAM lParam) + { + x = LOWORD(lParam); + y = HIWORD(lParam); + } + inline CPoint(int nX, int nY) + { + x = nX; + y = nY; + } + inline CPoint(const POINT &pt) + { + x = pt.x; + y = pt.y; + } + inline bool operator==(const CPoint &rhs) const + { + return x == rhs.x && y == rhs.y; + } + inline bool operator!=(const CPoint &rhs) const + { + return x != rhs.x || y != rhs.y; + } + inline operator LPPOINT() + { + return this; + } +}; - class CPoint : public tagPOINT - // - // Wrapper for the POINT structure - { - public: - inline CPoint() {}; - inline CPoint( LPARAM lParam ) { x = LOWORD( lParam ); y = HIWORD(lParam); } - inline CPoint( int nX, int nY ) { x = nX; y = nY; } - inline CPoint( const POINT &pt ) { x = pt.x; y = pt.y; } - inline bool operator == ( const CPoint &rhs ) const { return x == rhs.x && y == rhs.y; } - inline bool operator != ( const CPoint &rhs ) const { return x != rhs.x || y != rhs.y; } - inline operator LPPOINT () { return this; } - }; +class CScrollInfo : public tagSCROLLINFO +{ + public: + CScrollInfo(UINT fPassedMask) + { + cbSize = sizeof(tagSCROLLINFO); + fMask = fPassedMask; + } +}; +class CCriticalSection +// +// Simple crtical section handler/wrapper +{ + public: + inline CCriticalSection() + { + ::InitializeCriticalSection(&m_sect); + } + inline ~CCriticalSection() + { + ::DeleteCriticalSection(&m_sect); + } - class CScrollInfo : public tagSCROLLINFO - { - public: - CScrollInfo( UINT fPassedMask ) { cbSize = sizeof( tagSCROLLINFO ); fMask = fPassedMask; } - }; + // Blocking lock. + inline void Lock() + { + ::EnterCriticalSection(&m_sect); + } + // Unlock + inline void Unlock() + { + ::LeaveCriticalSection(&m_sect); + } - - class CCriticalSection - // - // Simple crtical section handler/wrapper - { - public: - inline CCriticalSection() { ::InitializeCriticalSection(&m_sect); } - inline ~CCriticalSection() { ::DeleteCriticalSection(&m_sect); } - - // Blocking lock. - inline void Lock() { ::EnterCriticalSection(&m_sect); } - // Unlock - inline void Unlock() { ::LeaveCriticalSection(&m_sect); } - - class CLock + class CLock // // Simple lock class for the critcal section { - public: - inline CLock( CCriticalSection § ) : m_sect( sect ) { m_sect.Lock(); } - inline ~CLock() { m_sect.Unlock(); } - private: - CCriticalSection &m_sect; + public: + inline CLock(CCriticalSection §) : m_sect(sect) + { + m_sect.Lock(); + } + inline ~CLock() + { + m_sect.Unlock(); + } - CLock(); - CLock( const CLock &); - CLock& operator =( const CLock &); + private: + CCriticalSection &m_sect; + + CLock(); + CLock(const CLock &); + CLock &operator=(const CLock &); }; - private: - CRITICAL_SECTION m_sect; + private: + CRITICAL_SECTION m_sect; - CCriticalSection( const CCriticalSection & ); - CCriticalSection& operator =( const CCriticalSection & ); - }; + CCriticalSection(const CCriticalSection &); + CCriticalSection &operator=(const CCriticalSection &); +}; - -#define ZeroStructure( t ) ZeroMemory( &t, sizeof( t ) ) -#define countof( t ) (sizeof( (t) ) / sizeof( (t)[0] ) ) +#define ZeroStructure(t) ZeroMemory(&t, sizeof(t)) +#define countof(t) (sizeof((t)) / sizeof((t)[0])) #define UNREF(P) UNREFERENCED_PARAMETER(P) - inline bool IsShiftPressed() - { - return GetKeyState(VK_SHIFT) & 0x8000 ? true : false; - } +inline bool IsShiftPressed() +{ + return GetKeyState(VK_SHIFT) & 0x8000 ? true : false; +} - inline bool IsAltPressed() - { - return GetKeyState(VK_MENU) & 0x8000 ? true : false; - } +inline bool IsAltPressed() +{ + return GetKeyState(VK_MENU) & 0x8000 ? true : false; +} - inline bool IsControlPressed() - { - return GetKeyState(VK_CONTROL) & 0x8000 ? true : false; - } +inline bool IsControlPressed() +{ + return GetKeyState(VK_CONTROL) & 0x8000 ? true : false; +} - inline HICON LoadIcon16x16( HINSTANCE hInst, UINT uID ) - // - // Load a 16x16 icon from the same resource as the other size icons. - { - return reinterpret_cast( ::LoadImage( hInst, MAKEINTRESOURCE( uID ), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR ) ); - } +inline HICON LoadIcon16x16(HINSTANCE hInst, UINT uID) +// +// Load a 16x16 icon from the same resource as the other size icons. +{ + return reinterpret_cast( + ::LoadImage(hInst, MAKEINTRESOURCE(uID), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR)); +} - - class CDeferWindowPos - // - // Wrapper for the Begin, Defer and End WindowPos functions. Nothing glamorous. - { - public: - inline CDeferWindowPos( const int nWindows = 1 ) : m_hdlDef( ::BeginDeferWindowPos( nWindows ) ) {} - inline ~CDeferWindowPos() { R_VERIFY( ::EndDeferWindowPos( m_hdlDef ) ); } - inline HDWP DeferWindowPos( HWND hWnd, HWND hWndInsertAfter , int x, int y, int cx, int cy, UINT uFlags ) +class CDeferWindowPos +// +// Wrapper for the Begin, Defer and End WindowPos functions. Nothing glamorous. +{ + public: + inline CDeferWindowPos(const int nWindows = 1) : m_hdlDef(::BeginDeferWindowPos(nWindows)) { - return ::DeferWindowPos( m_hdlDef, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags ); } - inline HDWP DeferWindowPos( HWND hWnd, HWND hWndInsertAfter, const CRect &rc, UINT uFlags ) + inline ~CDeferWindowPos() { - return ::DeferWindowPos( m_hdlDef, hWnd, hWndInsertAfter, rc.left, rc.top, rc.Width(), rc.Height(), uFlags ); + R_VERIFY(::EndDeferWindowPos(m_hdlDef)); + } + inline HDWP DeferWindowPos(HWND hWnd, HWND hWndInsertAfter, int x, int y, int cx, int cy, + UINT uFlags) + { + return ::DeferWindowPos(m_hdlDef, hWnd, hWndInsertAfter, x, y, cx, cy, uFlags); + } + inline HDWP DeferWindowPos(HWND hWnd, HWND hWndInsertAfter, const CRect &rc, UINT uFlags) + { + return ::DeferWindowPos(m_hdlDef, + hWnd, + hWndInsertAfter, + rc.left, + rc.top, + rc.Width(), + rc.Height(), + uFlags); } - private: - HDWP m_hdlDef; - }; + private: + HDWP m_hdlDef; +}; -} // WinHelper +} // WinHelper -#endif //WINHELPER_H +#endif // WINHELPER_H diff --git a/src/win32/WinResUtil.h b/src/win32/WinResUtil.h index 5b79cbd3..2ba90c2c 100644 --- a/src/win32/WinResUtil.h +++ b/src/win32/WinResUtil.h @@ -1,12 +1,7 @@ extern HMENU winResLoadMenu(LPCTSTR menuName); -extern int winResDialogBox(LPCTSTR boxName, - HWND parent, - DLGPROC dlgProc); +extern int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc); -extern int winResDialogBox(LPCTSTR boxName, - HWND parent, - DLGPROC dlgProc, - LPARAM lParam); +extern int winResDialogBox(LPCTSTR boxName, HWND parent, DLGPROC dlgProc, LPARAM lParam); extern CString winResLoadString(UINT id); diff --git a/src/win32/XAudio2_Config.h b/src/win32/XAudio2_Config.h index 4614baf5..9ade1f7b 100644 --- a/src/win32/XAudio2_Config.h +++ b/src/win32/XAudio2_Config.h @@ -2,36 +2,34 @@ #pragma once - class XAudio2_Config : public CDialog { - DECLARE_DYNAMIC(XAudio2_Config) - DECLARE_MESSAGE_MAP() + DECLARE_DYNAMIC(XAudio2_Config) + DECLARE_MESSAGE_MAP() -public: - UINT32 m_selected_device_index; - UINT32 m_buffer_count; - bool m_enable_upmixing; + public: + UINT32 m_selected_device_index; + UINT32 m_buffer_count; + bool m_enable_upmixing; -private: - CComboBox m_combo_dev; - CSliderCtrl m_slider_buffer; - CStatic m_info_buffer; - CButton m_check_upmix; + private: + CComboBox m_combo_dev; + CSliderCtrl m_slider_buffer; + CStatic m_info_buffer; + CButton m_check_upmix; + public: + XAudio2_Config(CWnd *pParent = NULL); // standard constructor + virtual ~XAudio2_Config(); -public: - XAudio2_Config(CWnd* pParent = NULL); // standard constructor - virtual ~XAudio2_Config(); + // Dialog Data + enum { IDD = IDD_XAUDIO2_CONFIG }; -// Dialog Data - enum { IDD = IDD_XAUDIO2_CONFIG }; + virtual BOOL OnInitDialog(); + afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar *pScrollBar); - virtual BOOL OnInitDialog(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); - -protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + protected: + virtual void DoDataExchange(CDataExchange *pDX); // DDX/DDV support }; #endif diff --git a/src/win32/ZoomControl.h b/src/win32/ZoomControl.h index fedb548b..001cf09b 100644 --- a/src/win32/ZoomControl.h +++ b/src/win32/ZoomControl.h @@ -1,14 +1,14 @@ #if !defined(AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_) #define AFX_ZOOMCONTROL_H__BC193230_D2D6_4240_93AE_28C2EF2C641A__INCLUDED_ -#include "../System.h" // Added by ClassView +#include "../System.h" // Added by ClassView #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // ZoomControl.h : header file // #ifndef WM_COLINFO -#define WM_COLINFO WM_APP+100 +#define WM_COLINFO WM_APP + 100 #endif ///////////////////////////////////////////////////////////////////////////// @@ -16,39 +16,37 @@ class ZoomControl : public CWnd { - // Construction - public: - ZoomControl(); + // Construction + public: + ZoomControl(); - // Attributes - public: + // Attributes + public: + // Operations + public: + // Overrides + // ClassWizard generated virtual function overrides + //{{AFX_VIRTUAL(ZoomControl) + //}}AFX_VIRTUAL - // Operations - public: + // Implementation + public: + void setColors(const u8 *c); + static bool isRegistered; + virtual ~ZoomControl(); - // Overrides - // ClassWizard generated virtual function overrides - //{{AFX_VIRTUAL(ZoomControl) - //}}AFX_VIRTUAL - - // Implementation - public: - void setColors(const u8 *c); - static bool isRegistered; - virtual ~ZoomControl(); - - // Generated message map functions - protected: - //{{AFX_MSG(ZoomControl) - afx_msg void OnPaint(); - afx_msg void OnLButtonDown(UINT nFlags, CPoint point); - afx_msg BOOL OnEraseBkgnd(CDC* pDC); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() - private: - int selected; - u8 colors[3*64]; - void registerClass(); + // Generated message map functions + protected: + //{{AFX_MSG(ZoomControl) + afx_msg void OnPaint(); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg BOOL OnEraseBkgnd(CDC *pDC); + //}}AFX_MSG + DECLARE_MESSAGE_MAP() + private: + int selected; + u8 colors[3 * 64]; + void registerClass(); }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/glfont.c b/src/win32/glfont.c index 4cf7bbb9..42cc88cb 100644 --- a/src/win32/glfont.c +++ b/src/win32/glfont.c @@ -1,156 +1,152 @@ #ifndef NO_OGL //********************************************************* -//GLFONT.CPP -- glFont routines -//Copyright (c) 1998 Brad Fish -//See glFont.txt for terms of use -//November 10, 1998 +// GLFONT.CPP -- glFont routines +// Copyright (c) 1998 Brad Fish +// See glFont.txt for terms of use +// November 10, 1998 //********************************************************* -#include -#include -#include -#include -#include #include "glfont.h" +#include +#include +#include +#include +#include //********************************************************* -//Variables +// Variables //********************************************************* -//Current font +// Current font GLFONT *glFont; //********************************************************* -//Functions +// Functions //********************************************************* -int glFontCreate (GLFONT *Font, char *Buffer, int Tex) +int glFontCreate(GLFONT *Font, char *Buffer, int Tex) { - char *TexBytes; - int Num; + char *TexBytes; + int Num; - //Read glFont structure - memcpy(Font, Buffer, sizeof(GLFONT)); - Buffer+=sizeof(GLFONT); + // Read glFont structure + memcpy(Font, Buffer, sizeof(GLFONT)); + Buffer += sizeof(GLFONT); - //Save texture number - Font->Tex = Tex; + // Save texture number + Font->Tex = Tex; - //Get number of characters - Num = Font->IntEnd - Font->IntStart + 1; + // Get number of characters + Num = Font->IntEnd - Font->IntStart + 1; - //Allocate memory for characters - if ((Font->Char = (GLFONTCHAR *)malloc( - sizeof(GLFONTCHAR) * Num)) == NULL) - return FALSE; + // Allocate memory for characters + if ((Font->Char = (GLFONTCHAR *)malloc(sizeof(GLFONTCHAR) * Num)) == NULL) + return FALSE; - //Read glFont characters - memcpy(Font->Char, Buffer, sizeof(GLFONTCHAR)*Num); - Buffer+=sizeof(GLFONTCHAR)*Num; + // Read glFont characters + memcpy(Font->Char, Buffer, sizeof(GLFONTCHAR) * Num); + Buffer += sizeof(GLFONTCHAR) * Num; - //Get texture size - Num = Font->TexWidth * Font->TexHeight * 2; + // Get texture size + Num = Font->TexWidth * Font->TexHeight * 2; - //Allocate memory for texture data - if ((TexBytes = (char *)malloc(Num)) == NULL) - return FALSE; + // Allocate memory for texture data + if ((TexBytes = (char *)malloc(Num)) == NULL) + return FALSE; - //Read texture data - memcpy(TexBytes, Buffer, sizeof(char)*Num); - Buffer+=sizeof(char)*Num; + // Read texture data + memcpy(TexBytes, Buffer, sizeof(char) * Num); + Buffer += sizeof(char) * Num; - //Set texture attributes - glBindTexture(GL_TEXTURE_2D, Font->Tex); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, - GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, - GL_CLAMP); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_MODULATE); + // Set texture attributes + glBindTexture(GL_TEXTURE_2D, Font->Tex); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - //Create texture - glTexImage2D(GL_TEXTURE_2D, 0, 2, Font->TexWidth, - Font->TexHeight, 0, GL_LUMINANCE_ALPHA, - GL_UNSIGNED_BYTE, (void *)TexBytes); + // Create texture + glTexImage2D(GL_TEXTURE_2D, + 0, + 2, + Font->TexWidth, + Font->TexHeight, + 0, + GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE, + (void *)TexBytes); - //Clean up - free(TexBytes); + // Clean up + free(TexBytes); - //Return pointer to new font - return TRUE; + // Return pointer to new font + return TRUE; } //********************************************************* -void glFontDestroy (GLFONT *Font) +void glFontDestroy(GLFONT *Font) { - //Free character memory - free(Font->Char); + // Free character memory + free(Font->Char); } //********************************************************* -void glFontBegin (GLFONT *Font) +void glFontBegin(GLFONT *Font) { - //Save pointer to font structure - if (Font->Char != NULL) - glFont = Font; - else - glFont = NULL; + // Save pointer to font structure + if (Font->Char != NULL) + glFont = Font; + else + glFont = NULL; - //Bind to font texture - glBindTexture(GL_TEXTURE_2D, Font->Tex); + // Bind to font texture + glBindTexture(GL_TEXTURE_2D, Font->Tex); } //********************************************************* -void glFontEnd (void) +void glFontEnd(void) { - //Font no longer current - glFont = NULL; + // Font no longer current + glFont = NULL; } //********************************************************* -void glFontTextOut (char *String, float x, float y, - float z) +void glFontTextOut(char *String, float x, float y, float z) { - int Length, i; - GLFONTCHAR *Char; + int Length, i; + GLFONTCHAR *Char; - //Return if we don't have a valid glFont - if (glFont == NULL) - return; + // Return if we don't have a valid glFont + if (glFont == NULL) + return; - //Get length of string - Length = strlen(String); + // Get length of string + Length = strlen(String); - //Begin rendering quads - glBegin(GL_QUADS); + // Begin rendering quads + glBegin(GL_QUADS); - //Loop through characters - for (i = 0; i < Length; i++) - { - //Get pointer to glFont character - Char = &glFont->Char[(int)String[i] - - glFont->IntStart]; + // Loop through characters + for (i = 0; i < Length; i++) { + // Get pointer to glFont character + Char = &glFont->Char[(int)String[i] - glFont->IntStart]; - //Specify vertices and texture coordinates - glTexCoord2f(Char->tx1, Char->ty1); - glVertex3f(x, y - Char->dy, z); - glTexCoord2f(Char->tx1, Char->ty2); - glVertex3f(x, y, z); - glTexCoord2f(Char->tx2, Char->ty2); - glVertex3f(x + Char->dx, y, z); - glTexCoord2f(Char->tx2, Char->ty1); - glVertex3f(x + Char->dx, y - Char->dy, z); + // Specify vertices and texture coordinates + glTexCoord2f(Char->tx1, Char->ty1); + glVertex3f(x, y - Char->dy, z); + glTexCoord2f(Char->tx1, Char->ty2); + glVertex3f(x, y, z); + glTexCoord2f(Char->tx2, Char->ty2); + glVertex3f(x + Char->dx, y, z); + glTexCoord2f(Char->tx2, Char->ty1); + glVertex3f(x + Char->dx, y - Char->dy, z); - //Move to next character - x += Char->dx; - } + // Move to next character + x += Char->dx; + } - //Stop rendering quads - glEnd(); + // Stop rendering quads + glEnd(); } //********************************************************* -//End of file - +// End of file #endif // NO_OGL diff --git a/src/win32/glfont.h b/src/win32/glfont.h index a477ec22..e26cba03 100644 --- a/src/win32/glfont.h +++ b/src/win32/glfont.h @@ -3,66 +3,63 @@ #ifndef NO_OGL //********************************************************* -//GLFONT.H -- Header for GLFONT.CPP -//Copyright (c) 1998 Brad Fish -//See glFont.txt for terms of use -//November 10, 1998 +// GLFONT.H -- Header for GLFONT.CPP +// Copyright (c) 1998 Brad Fish +// See glFont.txt for terms of use +// November 10, 1998 //********************************************************* #ifndef TRUE -#define TRUE 1 +#define TRUE 1 #endif #ifndef FALSE -#define FALSE 0 +#define FALSE 0 #endif //********************************************************* -//Structures +// Structures //********************************************************* -//glFont character structure -typedef struct -{ - float dx, dy; - float tx1, ty1; - float tx2, ty2; +// glFont character structure +typedef struct { + float dx, dy; + float tx1, ty1; + float tx2, ty2; } GLFONTCHAR; -//glFont structure -typedef struct -{ - int Tex; - int TexWidth, TexHeight; - int IntStart, IntEnd; - GLFONTCHAR *Char; +// glFont structure +typedef struct { + int Tex; + int TexWidth, TexHeight; + int IntStart, IntEnd; + GLFONTCHAR *Char; } GLFONT; //********************************************************* -//Function Declarations +// Function Declarations //********************************************************* -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif -//Creates a glFont +// Creates a glFont int glFontCreate(GLFONT *Font, char *Buffer, int Tex); -//Deletes a glFont -void glFontDestroy (GLFONT *Font); +// Deletes a glFont +void glFontDestroy(GLFONT *Font); -//Needs to be called before text output -void glFontBegin (GLFONT *Font); +// Needs to be called before text output +void glFontBegin(GLFONT *Font); -//Needs to be called after text output -void glFontEnd (void); +// Needs to be called after text output +void glFontEnd(void); -//Draws text with a glFont -void glFontTextOut (char *String, float x, float y, - float z); +// Draws text with a glFont +void glFontTextOut(char *String, float x, float y, float z); //********************************************************* -#ifdef __cplusplus +#ifdef __cplusplus } #endif -//End of file +// End of file #endif // NO_OGL diff --git a/src/win32/gzglfont.h b/src/win32/gzglfont.h index 30cc19e2..45e87e23 100644 --- a/src/win32/gzglfont.h +++ b/src/win32/gzglfont.h @@ -4,260 +4,189 @@ #define GZGLFONT_SIZE 35096 - -unsigned char gzglfont[]= - { - '\x1F', '\x8B', '\x08', '\x08', '\x72', '\x0F', '\x39', '\x47', - '\x00', '\x0B', '\x76', '\x65', '\x72', '\x64', '\x61', '\x6E', - '\x61', '\x00', '\xED', '\x97', '\xBF', '\x6B', '\x5C', '\x47', - '\x10', '\xC7', '\x2F', '\x21', '\x04', '\x27', '\x90', '\x20', - '\x82', '\x08', '\x21', '\x08', '\x21', '\x82', '\x62', '\x5C', - '\x19', '\x21', '\x8C', '\xAB', '\xDC', '\x7B', '\x42', '\x11', - '\x21', '\x0E', '\xC6', '\x1C', '\xAA', '\x0E', '\x05', '\x82', - '\x30', '\x42', '\xA8', '\x88', '\x85', '\x50', '\x11', '\x4C', - '\x9A', '\xB8', '\x70', '\x91', '\xC2', '\x85', '\x50', '\x95', - '\xC2', '\x85', '\x0A', '\x15', '\x29', '\x55', '\x08', '\xBB', - '\x49', '\xE1', '\x22', '\x4D', '\x7A', '\x17', '\x02', '\xBB', - '\x50', '\xE1', '\x22', '\x85', '\x0A', '\xFD', '\x01', '\x81', - '\xCB', '\xED', '\x7B', '\x73', '\x7E', '\xBB', '\xB3', '\x33', - '\xB3', '\xF3', '\x7E', '\xDC', '\xE9', '\x7C', '\xB7', '\x03', - '\xB2', '\xDF', '\x7D', '\x6E', '\xDE', '\xCE', '\x7C', '\x67', - '\x67', '\x7F', '\x5C', '\xAB', '\xD5', '\x6A', '\x3D', '\x82', - '\xBF', '\x85', '\xFE', '\xDF', '\x6F', '\xFD', '\xBF', '\x87', - '\x9F', '\x7C', '\xFB', '\xDE', '\xD7', '\x77', '\x3E', '\x4B', - '\xFB', '\x8F', '\x2B', '\xAD', '\xC2', '\xDA', '\xAD', '\xD6', - '\x79', '\x7B', '\xF7', '\xD5', '\x6D', '\xE0', '\x0B', '\xED', - '\x1C', '\x1F', '\x65', '\xBC', '\x3F', '\x02', '\xF0', '\x13', - '\xE0', '\x33', '\x49', '\xEE', '\xFF', '\x0C', '\xF8', '\x17', - '\x49', '\xCE', '\x77', '\x32', '\x7E', '\xE7', '\xF0', '\x18', - '\xF8', '\x1E', '\xF0', '\xA7', '\x19', '\x3F', '\x5C', '\xFC', - '\x68', '\xA5', '\xD7', '\xEB', '\xF5', '\xBF', '\x3B', '\x02', - '\xFE', '\x1A', '\x8D', '\x73', '\x0E', '\xFC', '\x83', '\xD4', - '\xF0', '\x22', '\xCF', '\x0F', '\xD3', '\x9C', '\x7F', '\x9A', - '\xBA', '\xF9', '\xCC', '\x00', '\x9F', '\x47', '\x7C', '\x01', - '\xF8', '\xCD', '\xD4', '\xCD', '\x67', '\x09', '\xF8', '\x6A', - '\xEA', '\xC6', '\x5D', '\x03', '\xDE', '\x45', '\x71', '\x37', - '\x80', '\xDF', '\xCF', '\xF8', '\xF3', '\x07', '\x3F', '\x02', - '\xDF', '\x02', '\xBE', '\x87', '\xFC', '\xF7', '\x81', '\xFF', - '\x0A', '\xFC', '\xD0', '\xAA', '\xF3', '\xA5', '\xC9', '\xAF', - '\x6D', '\x6A', '\x54', '\xE4', '\x73', '\xD0', '\xCE', '\xB9', - '\xA9', '\xA7', '\xCD', '\x4D', '\x3D', '\x0D', '\xDF', '\x44', - '\x7C', '\x07', '\xF8', '\x1F', '\x88', '\x3F', '\x05', '\xFE', - '\x02', '\xF1', '\xBF', '\x81', '\xFF', '\x8B', '\xF8', '\x05', - '\xF0', '\x6B', '\xA9', '\xCB', '\x3F', '\x4E', '\x73', '\x3E', - '\x87', '\xF8', '\x3C', '\xF0', '\x25', '\xC4', '\x97', '\x81', - '\xAF', '\x21', '\xFE', '\x1D', '\xF0', '\x6E', '\xC6', '\x8B', - '\xBE', '\xDA', '\x00', '\xBE', '\x85', '\xF8', '\x36', '\xF0', - '\x3D', '\xE0', '\xCF', '\xAC', '\xBA', '\x99', '\x1E', '\x32', - '\x7D', '\x78', '\x62', '\x71', '\xD3', '\x87', '\x86', '\xDF', - '\x48', '\x5C', '\xBE', '\x94', '\xE4', '\xFC', '\x51', '\xC6', - '\x8B', '\x7E', '\x78', '\x0C', '\xFC', '\x28', '\xE3', '\xCF', - '\x1F', '\xBC', '\x02', '\x7E', '\x0C', '\xFC', '\x65', '\xC6', - '\x8B', '\xFC', '\xCF', '\x80', '\xFF', '\x87', '\x78', '\x2B', - '\xCD', '\xB9', '\x99', '\x6F', '\x9B', '\xCF', '\x02', '\xBF', - '\x9E', '\xBA', '\xF9', '\xDC', '\x00', '\xFE', '\x4D', '\xC6', - '\x8B', '\x7E', '\x48', '\x80', '\xDF', '\x43', '\xBC', '\x03', - '\x7C', '\x13', '\x8D', '\x73', '\x1F', '\xF8', '\x2F', '\x88', - '\x1B', '\x3B', '\x85', '\xFA', '\x5C', '\x24', '\x45', '\x7F', - '\x9A', '\xFA', '\x18', '\x7E', '\x2D', '\xC9', '\xE7', '\xFA', - '\xED', '\x7A', '\x49', '\x72', '\xFE', '\x7D', '\xC6', '\x8B', - '\xFC', '\x3B', '\xC0', '\x9F', '\x64', '\xBC', '\xC8', '\xE7', - '\x00', '\xF8', '\x49', '\xC6', '\x0F', '\x17', '\xFF', '\x01', - '\x7E', '\x0A', '\xFC', '\x3C', '\xE3', '\x45', '\x3E', '\x6F', - '\x80', '\x9B', '\xF5', '\x6A', '\xFB', '\x9B', '\x3E', '\x33', - '\x7C', '\x3E', '\x75', '\xE3', '\x2E', '\x00', '\x5F', '\x46', - '\xFE', '\xB7', '\x80', '\xFF', '\x80', '\xFC', '\xEF', '\x02', - '\xFF', '\x09', '\xF1', '\x4D', '\xE0', '\xFB', '\xA9', '\x9B', - '\x7F', '\xB6', '\xEE', '\x92', '\x7C', '\xDD', '\xCD', '\xA6', - '\x45', '\x9E', '\xD9', '\xBA', '\x4B', '\xF2', '\x75', '\x36', - '\x9B', '\x5A', '\xF9', '\x24', '\x39', '\xDF', '\x49', '\xF2', - '\x39', '\xCD', '\xC6', '\x58', '\xC9', '\x6B', '\x7F', '\x09', - '\x75', '\xB0', '\xFD', '\x4F', '\x81', '\x9F', '\x25', '\xEE', - '\xF8', '\xAF', '\x81', '\xBF', '\x9F', '\x1A', '\x5E', '\xE4', - '\x63', '\xF6', '\xB5', '\x4B', '\x18', '\x7B', '\x36', '\x2D', - '\xE6', '\xEB', '\x73', '\xE0', '\x5F', '\x21', '\xFF', '\x45', - '\xE0', '\xB7', '\x90', '\xFF', '\x6D', '\xE0', '\xAB', '\xA9', - '\x1B', '\x77', '\x0D', '\x78', '\x37', '\x75', '\xF3', '\xDC', - '\x00', '\xFE', '\x33', '\xE2', '\xC6', '\x4C', '\x6C', '\x53', - '\x8F', '\x65', '\x2B', '\xAE', '\xE9', '\x27', '\xC3', '\x67', - '\x12', '\x97', '\x9B', '\x7A', '\x19', '\xDE', '\x85', '\x39', - '\x1B', '\xF4', '\xD5', '\x26', '\xF0', '\x27', '\xC8', '\xFF', - '\x00', '\xF8', '\x09', '\xE2', '\xA7', '\xC0', '\x5F', '\x66', - '\xBC', '\xD8', '\x07', '\xCE', '\x80', '\x5F', '\x20', '\xFF', - '\x4B', '\xE0', '\xA6', '\x8F', '\x6C', '\x6E', '\xF6', '\x2B', - '\xC3', '\xBF', '\x04', '\x3E', '\xD8', '\x87', '\xE7', '\x80', - '\x2F', '\xA6', '\xEE', '\xF8', '\xD7', '\x81', '\x2F', '\xA1', - '\x71', '\x96', '\x81', '\xAF', '\xA2', '\x71', '\xD6', '\x80', - '\xDF', '\xCD', '\x78', '\xB1', '\x6F', '\xDC', '\x03', '\xBE', - '\x8D', '\xC6', '\xD9', '\x01', '\xFE', '\x10', '\x71', '\x63', - '\x66', '\x0E', '\x4D', '\x1F', '\x76', '\xEC', '\xFA', '\xB4', - '\x73', '\x6E', '\xD6', '\xA9', '\xCD', '\x67', '\x60', '\xCE', - '\x3B', '\x19', '\x2F', '\xE6', '\xBD', '\x0B', '\xFC', '\x71', - '\x92', '\xEF', '\x15', '\x83', '\xFA', '\xFF', '\x0E', '\xFC', - '\x38', '\xE3', '\x85', '\xDE', '\x3F', '\x81', '\xFF', '\x85', - '\xC6', '\x7F', '\x01', '\xFC', '\x1C', '\xF1', '\x37', '\xC0', - '\x4D', '\xDF', '\x76', '\x2C', '\xBD', '\xA6', '\x6F', '\x0D', - '\x9F', '\x4B', '\x5D', '\xFF', '\x79', '\xE0', '\x37', '\x11', - '\x5F', '\x02', '\xBE', '\x92', '\xBA', '\x79', '\xAE', '\x02', - '\xEF', '\x64', '\x7F', '\x45', '\x1F', '\xAE', '\x03', '\xDF', - '\x4A', '\x5D', '\xBD', '\xDB', '\xC0', '\xF7', '\x91', '\xBF', - '\xB1', '\x75', '\xE8', '\xDB', '\x5D', '\xAB', '\xFF', '\x4D', - '\xDF', '\x1A', '\x6E', '\xD6', '\xF1', '\xAE', '\x95', '\xBF', - '\x39', '\x27', '\xD6', '\xA1', '\x6E', '\xBB', '\x69', '\x2B', - '\x5A', '\x34', '\xC2', '\xFA', '\x77', '\xD3', '\xDE', '\xE0', - '\xDF', '\xB0', '\x6F', '\x53', '\xF1', '\x34', '\x9F', '\x9A', - '\x8B', '\x29', '\xE5', '\x40', '\xEB', '\xCF', '\x3F', '\xE1', - '\xD8', '\xFE', '\x67', '\x77', '\x24', '\x2A', '\x0E', '\xF5', - '\x0E', '\xF5', '\x4C', '\x91', '\x3C', '\xB3', '\xE6', '\x6B', - '\x50', '\x45', '\x7F', '\xEF', '\xAD', '\x71', '\x6F', '\xD2', - '\x5A', '\xFC', '\x91', '\xF5', '\xFA', '\xE9', '\x0A', '\xD6', - '\xAF', '\x87', '\xDC', '\xED', '\x3D', '\xC7', '\xEC', '\x37', - '\xDC', '\xAA', '\xB8', '\xFA', '\xE8', '\xD9', '\x97', '\x62', - '\xD1', '\xDF', '\xF8', '\x2B', '\x62', '\xDC', '\xF4', '\xBB', - '\xA3', '\xD8', '\xFA', '\xE5', '\xFE', '\xD0', '\x65', '\x81', - '\x57', '\x14', '\xD5', '\xFF', '\xC3', '\xD5', '\x2F', '\x77', - '\x3F', '\xAD', '\xCF', '\x7E', '\x72', '\x3D', '\x06', '\x63', - '\x71', '\xFD', '\x11', '\xA2', '\xD4', '\x7A', '\xC0', '\x99', - '\xF8', '\xDF', '\x4B', '\xEA', '\x64', '\xFD', '\x5C', '\x04', - '\xAE', '\x02', '\xF6', '\xBA', '\xC0', '\xFB', '\x81', '\x5B', - '\x1F', '\x5D', '\x16', '\xE1', '\xEC', '\x87', '\x73', '\x26', - '\xD8', '\xF1', '\xB9', '\x0A', '\x73', '\xFD', '\x2C', '\xE9', - '\xE7', '\x15', '\x5D', '\x9D', '\x7E', '\x39', '\x06', '\xB5', - '\x9F', '\xB9', '\x6B', '\x9C', '\xCE', '\x86', '\xD3', '\x5F', - '\x4E', '\x69', '\x15', '\xFD', '\xE5', '\x2A', '\x5C', '\x45', - '\x3F', '\x75', '\xFE', '\xF9', '\xD9', '\x70', '\x6B', '\x46', - '\xAF', '\x55', '\xA3', '\x5E', '\x33', '\x4E', '\x9D', '\xD1', - '\xA4', '\x38', '\x4D', '\x8E', '\x36', '\x7C', '\xFD', '\x4D', - '\x5B', '\xF3', '\x51', '\xFC', '\x7E', '\xA9', '\x36', '\x4A', - '\x53', '\xF9', '\x44', '\x8B', '\x36', '\xE9', '\x36', '\xAA', - '\xDD', '\x62', '\x5C', '\xCD', '\xBF', '\xC1', '\x85', '\xF7', - '\x61', '\xCA', '\x4F', '\x3A', '\x11', '\x43', '\x37', '\x47', - '\xFF', '\xA6', '\xDA', '\xEB', '\x51', '\x7E', '\xE5', '\xE2', - '\x6A', '\x0C', '\x8F', '\x4E', '\x53', '\x6E', '\x5F', '\x96', - '\x9F', '\xEC', '\xF7', '\xE9', '\x88', '\x12', '\x2B', '\x1B', - '\xAD', '\xFE', '\x59', '\x29', '\x6B', '\x08', '\xBD', '\x4D', - '\x33', '\xFF', '\xB6', '\x13', '\xEE', '\xAE', '\x32', '\xF9', - '\x85', '\x2A', '\x11', '\xAA', '\xCA', '\xD5', '\xE8', '\xE7', - '\x7B', '\xBD', '\x6C', '\x7E', '\xF5', '\xF4', '\x87', '\xFB', - '\x5A', '\x1A', '\x85', '\xEE', '\x74', '\xAC', '\x3E', '\xFC', - '\xB6', '\x3E', '\x2E', '\x5D', '\x3B', '\x29', '\x47', '\xD9', - '\xEA', '\xE8', '\x0F', '\xF7', '\x84', '\xF6', '\xF7', '\x8E', - '\x36', '\x2E', '\x3F', '\xC3', '\x5C', '\xF7', '\xC8', '\xC6', - '\x47', '\x0B', '\xEB', '\xE7', '\xA3', '\xB9', '\xA3', '\x68', - '\x3A', '\x9B', '\x8B', '\xAB', '\xCF', '\x4F', '\xCE', '\x88', - '\xB3', '\xEA', '\xFA', '\xA5', '\x7A', '\xC8', '\xB5', '\x92', - '\x55', '\x57', '\xD7', '\x4F', '\xC7', '\xD0', '\xEF', '\xAD', - '\x05', '\xC1', '\xB3', '\xE5', '\xCF', '\x21', '\x3D', '\xAF', - '\x9A', '\x99', '\x0E', '\xC7', '\x90', '\xB2', '\x93', '\xDF', - '\xA5', '\xDF', '\xE4', '\xF5', '\x97', '\xEF', '\x97', '\x77', - '\xD1', '\xA2', '\xFE', '\xAB', '\xCE', '\x20', '\x5A', '\xB4', - '\x68', '\x93', '\x69', '\xD4', '\x79', '\x27', '\x9D', '\x82', - '\xA1', '\x33', '\x8F', '\x7A', '\x9F', '\x3A', '\x6B', '\x43', - '\xA7', '\x72', '\x38', '\x0A', '\x8E', '\x19', '\xD2', '\xC9', - '\x53', '\xEE', '\xB4', '\xC5', '\x31', '\xB9', '\x53', '\x9A', - '\x3B', '\xBB', '\xCB', '\xFE', '\xAE', '\xE1', '\x6A', '\x2E', - '\x6B', '\xD0', '\x9E', '\x83', '\xBA', '\x73', '\x74', '\xF0', - '\x6B', '\x2F', '\x67', '\xBE', '\x2E', '\x4A', '\x41', '\xE8', - '\xB6', '\x42', '\x7F', '\xAF', '\xD1', '\x1F', '\x56', '\xC6', - '\x77', '\x1F', '\xD7', '\x99', '\x72', '\x76', '\x58', '\x27', - '\xCE', '\x7C', '\x9C', '\xF4', '\xEB', '\xE6', '\x5D', '\x7E', - '\x0B', '\x7F', '\x2A', '\xAB', '\x1F', '\xD7', '\xB9', '\x9C', - '\x7E', '\xF7', '\x6D', '\x9A', '\x68', '\x95', '\x68', '\xAD', - '\x59', '\xFD', '\xFC', '\x13', '\x1D', '\xA3', '\xDA', '\xFC', - '\xD3', '\xDD', '\xCC', '\xBF', '\xE3', '\xCF', '\x0B', '\x9F', - '\x9D', '\xFB', '\x3D', '\xA7', '\x9F', '\x1A', '\x75', '\x74', - '\xFA', '\xE5', '\xDC', '\x75', '\x7D', '\xA0', '\xAB', '\x9F', - '\xBD', '\xFF', '\xE9', '\xE7', '\x9A', '\xF3', '\xD4', '\xF9', - '\x49', '\x19', '\xEA', '\xD7', '\x02', '\xFF', '\x9D', '\xF4', - '\xBD', '\xAF', '\x9F', '\x3B', '\x29', '\x69', '\x35', '\x54', - '\x9F', '\x51', '\xB5', '\xF3', '\xFD', '\xA4', '\x7E', '\xA2', - '\x46', '\xD3', '\xCD', '\x72', '\x13', '\x36', '\xDA', '\x68', - '\xD1', '\xA2', '\x45', '\x8B', '\x16', '\xAD', '\xAC', '\xF1', - '\xE7', '\x33', '\x75', '\x46', '\x51', '\x7E', '\xFE', '\x38', - '\x14', '\xE1', '\x3C', '\xE9', '\xD3', '\x8C', '\x62', '\xF4', - '\xF9', '\x18', '\xF6', '\x95', '\x4F', '\x3E', '\x5A', '\xBF', - '\xAC', '\x67', '\xF0', '\x14', '\xF6', '\x77', '\x2B', '\xE8', - '\x3F', '\xFB', '\x77', '\x63', '\x7E', '\xDC', '\x6A', '\x94', - '\x8E', '\xD5', '\x84', '\x7E', '\x6E', '\x7E', '\xC3', '\xFA', - '\xE5', '\xFB', '\x5D', '\x58', '\x49', '\x75', '\x5F', '\xDF', - '\xAA', '\xEA', '\xA7', '\xFA', '\x11', '\xFB', '\x17', '\x95', - '\xC2', '\x8A', '\x47', '\xAB', '\x5F', '\xBE', '\xF3', '\xBA', - '\xA6', '\xD7', '\xCF', '\x7D', '\xAB', '\xD1', '\x6F', '\xAF', - '\xA1', '\x66', '\xF5', '\xFB', '\x73', '\x43', '\x31', '\x3A', - '\xEF', '\xE6', '\xE7', '\x9F', '\xDA', '\x2B', '\xF0', '\x2A', - '\x2A', '\xAF', '\x49', '\xAE', '\x15', '\xAD', '\x94', '\xAB', - '\x40', '\x55', '\xFD', '\x9A', '\xF5', '\xDF', '\x94', '\x7E', - '\x29', '\xE7', '\xD0', '\xBE', '\x2C', '\x65', '\x88', '\x69', - '\x39', '\xFD', '\x61', '\x7F', '\xEE', '\x6D', '\x9B', '\xE9', - '\xF7', '\x74', '\x39', '\x17', '\x8E', '\xEA', '\x47', '\xE2', - '\x3A', '\x5C', '\xEA', '\x3F', '\xBA', '\x4F', '\xDD', '\x95', - '\xCD', '\x67', '\x44', '\xCD', '\x24', '\xEE', '\x53', '\x3A', - '\xEB', '\xB0', '\x2F', '\x95', '\x19', '\x35', '\xCE', '\xBB', - '\x6C', '\x93', '\xA8', '\xA9', '\x9C', '\x4D', '\xEA', '\xCC', - '\x46', '\x8B', '\x36', '\xCD', '\xE6', '\xAE', '\x6B', '\xFA', - '\x2C', '\x6E', '\x62', '\xDD', '\xF7', '\x90', '\xE1', '\x68', - '\xDC', '\x49', '\x57', '\xFF', '\x49', '\xBE', '\xE3', '\x69', - '\xCE', '\x40', '\x4C', '\xAB', '\xD7', '\x43', '\x7B', '\x8A', - '\x36', '\xF9', '\x24', '\xE7', '\xAF', '\xD1', '\xE6', '\x67', - '\x5D', '\xB5', '\x02', '\xC3', '\xD1', '\x2F', '\xDF', '\x93', - '\xE9', '\x9E', '\xA6', '\x33', '\x0A', '\xEB', '\xE7', '\x47', - '\xD5', '\x98', '\x46', '\xBF', '\x4E', '\x0D', '\x95', '\xB7', - '\x6E', '\xED', '\xCA', '\x1D', '\x2F', '\xEB', '\x97', '\x2A', - '\xA7', '\xB1', '\xBA', '\xFA', '\x0B', '\x45', '\x1A', '\xFD', - '\xE5', '\x7E', '\xD3', '\x94', '\x21', '\x55', '\xAD', '\xBE', - '\xFE', '\xFC', '\xB9', '\xBA', '\xFE', '\xF0', '\x7C', '\x5F', - '\xBD', '\x7E', '\xA9', '\x9B', '\xE9', '\x6F', '\xE9', '\x9E', - '\xA8', '\xA6', '\xBF', '\xC9', '\xFD', '\x5E', '\x1E', '\xB9', - '\xBC', '\xFE', '\xD0', '\x38', '\xA1', '\xCC', '\x75', '\x73', - '\x3B', '\x2A', '\xFD', '\xD4', '\x79', '\x6C', '\x73', '\xFE', - '\xDD', '\x3A', '\xFA', '\xDD', '\x78', '\xA3', '\xD5', '\x3F', - '\x7E', '\x46', '\x6B', '\xE3', '\xFB', '\x74', '\xD2', '\x8C', - '\xEA', '\x3E', '\xEA', '\xC6', '\x18', '\x1E', '\x81', '\xEE', - '\xE4', '\x68', '\xD1', '\xA2', '\xE5', '\xA6', '\x59', '\x1B', - '\xFA', '\xF5', '\xA3', '\x59', '\x95', '\xDA', '\x37', '\xE9', - '\xB3', '\x45', '\x77', '\x5A', '\x96', '\xB1', '\xF0', '\xFB', - '\xCD', '\xE8', '\x0F', '\xD7', '\x86', '\x27', '\xC3', '\xD4', - '\x1F', '\xB6', '\xAB', '\xD1', '\xAF', '\xF5', '\x6B', '\x5E', - '\x3F', '\x3E', '\x33', '\xA8', '\x53', '\x24', '\xEC', '\xE3', - '\xDF', '\x69', '\xCA', '\x7C', '\xF6', '\xCF', '\x3B', '\x97', - '\x52', '\x1D', '\x91', '\x3F', '\xF9', '\x1E', '\xB4', '\x02', - '\x4D', '\x15', '\x34', '\x31', '\x65', '\x0F', '\xBA', '\x73', - '\xAB', '\xFA', '\x53', '\xBF', '\x2A', '\xFC', '\x3A', '\xD9', - '\xFF', '\x73', '\xA3', '\x87', '\x94', '\x6B', '\x6B', '\x5E', - '\x4F', '\x4F', '\x35', '\xFD', '\x6E', '\x74', '\x7E', '\x8C', - '\x6A', '\xFA', '\xCB', '\xE6', '\xC6', '\x7B', '\xD0', '\x55', - '\x9C', '\x1E', '\xFD', '\xF4', '\xB8', '\xF5', '\xF5', '\x87', - '\xCE', '\x86', '\x51', '\xEA', '\x0F', '\x45', '\x1C', '\x78', - '\x34', '\xAB', '\x5F', '\xDA', '\xFF', '\xEA', '\xEA', '\xD7', - '\xEC', '\xCD', '\x7E', '\x1F', '\xFA', '\x3E', '\xD4', '\x67', - '\x39', '\x46', '\x19', '\xFD', '\x1A', '\x95', '\x55', '\xF5', - '\x8F', '\xCE', '\xB4', '\xF9', '\x8C', '\x5B', '\xDE', '\xF5', - '\xCD', '\xEF', '\x28', '\xD9', '\x73', '\xF8', '\x19', '\x45', - '\x8B', '\x16', '\x6D', '\x32', '\x8C', '\x3A', '\xAD', '\x46', - '\x19', '\x7B', '\x54', '\xB1', '\xB4', '\x19', '\x44', '\xFD', - '\x5C', '\x4E', '\xE1', '\x7B', '\x0C', '\x77', '\x57', '\xF1', - '\xEF', '\x47', '\xBE', '\xAF', '\xE6', '\x26', '\x52', '\xC7', - '\x97', '\xCF', '\x57', '\xA7', '\xBF', '\x89', '\x98', '\x78', - '\x6C', '\x5C', '\xCD', '\xE1', '\xEA', '\xA7', '\xF4', '\x8D', - '\x42', '\x3F', '\x3F', '\x76', '\x73', '\xFA', '\xF9', '\x3B', - '\x34', '\x9F', '\x01', '\xEE', '\x85', '\xE1', '\xEB', '\xC7', - '\x31', '\x43', '\xF9', '\xD2', '\x9A', '\x06', '\x7E', '\x9A', - '\xEA', '\xFA', '\x1E', '\x52', '\x37', '\x0C', '\x5F', '\x3F', - '\xFF', '\xAD', '\x46', '\xBF', '\xAD', '\x80', '\xFE', '\x26', - '\x4C', '\x42', '\x6A', '\xC7', '\x5F', '\xBF', '\xF4', '\x1C', - '\xEE', '\x9E', '\xAA', '\xFA', '\xEB', '\xEC', '\xFF', '\xB2', - '\x9E', '\x32', '\xFB', '\x73', '\x19', '\xFD', '\x5C', '\xF4', - '\x6A', '\xFB', '\x9F', '\x6F', '\x72', '\xA5', '\x74', '\x63', - '\x0C', '\xD7', '\xC2', '\x79', '\x4C', '\xB2', '\x7E', '\x5D', - '\x16', '\xE1', '\x8E', '\x88', '\x16', '\x2D', '\x1A', '\x77', - '\x5F', '\x9A', '\x2E', '\x9B', '\xF6', '\x0A', '\x44', '\xFD', - '\x51', '\x3F', '\xF7', '\x79', '\x3A', '\x2A', '\xE3', '\xDE', - '\x58', '\x8B', '\x7F', '\xA7', '\x43', '\x3F', '\xBE', '\x2B', - '\xD9', '\xFF', '\x4F', '\xAF', '\xFE', '\xE9', '\xD9', '\x17', - '\xA6', '\x45', '\x27', '\x67', '\x51', '\xFF', '\xF4', '\xEA', - '\x8F', '\xF7', '\xDF', '\x68', '\xD1', '\xA2', '\x45', '\x8B', - '\x16', '\x2D', '\x5A', '\xB4', '\xE9', '\xB1', '\xFF', '\x01', - '\xF1', '\xAA', '\xBA', '\x4E', '\x18', '\x89', '\x00', '\x00' - }; +unsigned char gzglfont[] = + { '\x1F', '\x8B', '\x08', '\x08', '\x72', '\x0F', '\x39', '\x47', '\x00', '\x0B', '\x76', + '\x65', '\x72', '\x64', '\x61', '\x6E', '\x61', '\x00', '\xED', '\x97', '\xBF', '\x6B', + '\x5C', '\x47', '\x10', '\xC7', '\x2F', '\x21', '\x04', '\x27', '\x90', '\x20', '\x82', + '\x08', '\x21', '\x08', '\x21', '\x82', '\x62', '\x5C', '\x19', '\x21', '\x8C', '\xAB', + '\xDC', '\x7B', '\x42', '\x11', '\x21', '\x0E', '\xC6', '\x1C', '\xAA', '\x0E', '\x05', + '\x82', '\x30', '\x42', '\xA8', '\x88', '\x85', '\x50', '\x11', '\x4C', '\x9A', '\xB8', + '\x70', '\x91', '\xC2', '\x85', '\x50', '\x95', '\xC2', '\x85', '\x0A', '\x15', '\x29', + '\x55', '\x08', '\xBB', '\x49', '\xE1', '\x22', '\x4D', '\x7A', '\x17', '\x02', '\xBB', + '\x50', '\xE1', '\x22', '\x85', '\x0A', '\xFD', '\x01', '\x81', '\xCB', '\xED', '\x7B', + '\x73', '\x7E', '\xBB', '\xB3', '\x33', '\xB3', '\xF3', '\x7E', '\xDC', '\xE9', '\x7C', + '\xB7', '\x03', '\xB2', '\xDF', '\x7D', '\x6E', '\xDE', '\xCE', '\x7C', '\x67', '\x67', + '\x7F', '\x5C', '\xAB', '\xD5', '\x6A', '\x3D', '\x82', '\xBF', '\x85', '\xFE', '\xDF', + '\x6F', '\xFD', '\xBF', '\x87', '\x9F', '\x7C', '\xFB', '\xDE', '\xD7', '\x77', '\x3E', + '\x4B', '\xFB', '\x8F', '\x2B', '\xAD', '\xC2', '\xDA', '\xAD', '\xD6', '\x79', '\x7B', + '\xF7', '\xD5', '\x6D', '\xE0', '\x0B', '\xED', '\x1C', '\x1F', '\x65', '\xBC', '\x3F', + '\x02', '\xF0', '\x13', '\xE0', '\x33', '\x49', '\xEE', '\xFF', '\x0C', '\xF8', '\x17', + '\x49', '\xCE', '\x77', '\x32', '\x7E', '\xE7', '\xF0', '\x18', '\xF8', '\x1E', '\xF0', + '\xA7', '\x19', '\x3F', '\x5C', '\xFC', '\x68', '\xA5', '\xD7', '\xEB', '\xF5', '\xBF', + '\x3B', '\x02', '\xFE', '\x1A', '\x8D', '\x73', '\x0E', '\xFC', '\x83', '\xD4', '\xF0', + '\x22', '\xCF', '\x0F', '\xD3', '\x9C', '\x7F', '\x9A', '\xBA', '\xF9', '\xCC', '\x00', + '\x9F', '\x47', '\x7C', '\x01', '\xF8', '\xCD', '\xD4', '\xCD', '\x67', '\x09', '\xF8', + '\x6A', '\xEA', '\xC6', '\x5D', '\x03', '\xDE', '\x45', '\x71', '\x37', '\x80', '\xDF', + '\xCF', '\xF8', '\xF3', '\x07', '\x3F', '\x02', '\xDF', '\x02', '\xBE', '\x87', '\xFC', + '\xF7', '\x81', '\xFF', '\x0A', '\xFC', '\xD0', '\xAA', '\xF3', '\xA5', '\xC9', '\xAF', + '\x6D', '\x6A', '\x54', '\xE4', '\x73', '\xD0', '\xCE', '\xB9', '\xA9', '\xA7', '\xCD', + '\x4D', '\x3D', '\x0D', '\xDF', '\x44', '\x7C', '\x07', '\xF8', '\x1F', '\x88', '\x3F', + '\x05', '\xFE', '\x02', '\xF1', '\xBF', '\x81', '\xFF', '\x8B', '\xF8', '\x05', '\xF0', + '\x6B', '\xA9', '\xCB', '\x3F', '\x4E', '\x73', '\x3E', '\x87', '\xF8', '\x3C', '\xF0', + '\x25', '\xC4', '\x97', '\x81', '\xAF', '\x21', '\xFE', '\x1D', '\xF0', '\x6E', '\xC6', + '\x8B', '\xBE', '\xDA', '\x00', '\xBE', '\x85', '\xF8', '\x36', '\xF0', '\x3D', '\xE0', + '\xCF', '\xAC', '\xBA', '\x99', '\x1E', '\x32', '\x7D', '\x78', '\x62', '\x71', '\xD3', + '\x87', '\x86', '\xDF', '\x48', '\x5C', '\xBE', '\x94', '\xE4', '\xFC', '\x51', '\xC6', + '\x8B', '\x7E', '\x78', '\x0C', '\xFC', '\x28', '\xE3', '\xCF', '\x1F', '\xBC', '\x02', + '\x7E', '\x0C', '\xFC', '\x65', '\xC6', '\x8B', '\xFC', '\xCF', '\x80', '\xFF', '\x87', + '\x78', '\x2B', '\xCD', '\xB9', '\x99', '\x6F', '\x9B', '\xCF', '\x02', '\xBF', '\x9E', + '\xBA', '\xF9', '\xDC', '\x00', '\xFE', '\x4D', '\xC6', '\x8B', '\x7E', '\x48', '\x80', + '\xDF', '\x43', '\xBC', '\x03', '\x7C', '\x13', '\x8D', '\x73', '\x1F', '\xF8', '\x2F', + '\x88', '\x1B', '\x3B', '\x85', '\xFA', '\x5C', '\x24', '\x45', '\x7F', '\x9A', '\xFA', + '\x18', '\x7E', '\x2D', '\xC9', '\xE7', '\xFA', '\xED', '\x7A', '\x49', '\x72', '\xFE', + '\x7D', '\xC6', '\x8B', '\xFC', '\x3B', '\xC0', '\x9F', '\x64', '\xBC', '\xC8', '\xE7', + '\x00', '\xF8', '\x49', '\xC6', '\x0F', '\x17', '\xFF', '\x01', '\x7E', '\x0A', '\xFC', + '\x3C', '\xE3', '\x45', '\x3E', '\x6F', '\x80', '\x9B', '\xF5', '\x6A', '\xFB', '\x9B', + '\x3E', '\x33', '\x7C', '\x3E', '\x75', '\xE3', '\x2E', '\x00', '\x5F', '\x46', '\xFE', + '\xB7', '\x80', '\xFF', '\x80', '\xFC', '\xEF', '\x02', '\xFF', '\x09', '\xF1', '\x4D', + '\xE0', '\xFB', '\xA9', '\x9B', '\x7F', '\xB6', '\xEE', '\x92', '\x7C', '\xDD', '\xCD', + '\xA6', '\x45', '\x9E', '\xD9', '\xBA', '\x4B', '\xF2', '\x75', '\x36', '\x9B', '\x5A', + '\xF9', '\x24', '\x39', '\xDF', '\x49', '\xF2', '\x39', '\xCD', '\xC6', '\x58', '\xC9', + '\x6B', '\x7F', '\x09', '\x75', '\xB0', '\xFD', '\x4F', '\x81', '\x9F', '\x25', '\xEE', + '\xF8', '\xAF', '\x81', '\xBF', '\x9F', '\x1A', '\x5E', '\xE4', '\x63', '\xF6', '\xB5', + '\x4B', '\x18', '\x7B', '\x36', '\x2D', '\xE6', '\xEB', '\x73', '\xE0', '\x5F', '\x21', + '\xFF', '\x45', '\xE0', '\xB7', '\x90', '\xFF', '\x6D', '\xE0', '\xAB', '\xA9', '\x1B', + '\x77', '\x0D', '\x78', '\x37', '\x75', '\xF3', '\xDC', '\x00', '\xFE', '\x33', '\xE2', + '\xC6', '\x4C', '\x6C', '\x53', '\x8F', '\x65', '\x2B', '\xAE', '\xE9', '\x27', '\xC3', + '\x67', '\x12', '\x97', '\x9B', '\x7A', '\x19', '\xDE', '\x85', '\x39', '\x1B', '\xF4', + '\xD5', '\x26', '\xF0', '\x27', '\xC8', '\xFF', '\x00', '\xF8', '\x09', '\xE2', '\xA7', + '\xC0', '\x5F', '\x66', '\xBC', '\xD8', '\x07', '\xCE', '\x80', '\x5F', '\x20', '\xFF', + '\x4B', '\xE0', '\xA6', '\x8F', '\x6C', '\x6E', '\xF6', '\x2B', '\xC3', '\xBF', '\x04', + '\x3E', '\xD8', '\x87', '\xE7', '\x80', '\x2F', '\xA6', '\xEE', '\xF8', '\xD7', '\x81', + '\x2F', '\xA1', '\x71', '\x96', '\x81', '\xAF', '\xA2', '\x71', '\xD6', '\x80', '\xDF', + '\xCD', '\x78', '\xB1', '\x6F', '\xDC', '\x03', '\xBE', '\x8D', '\xC6', '\xD9', '\x01', + '\xFE', '\x10', '\x71', '\x63', '\x66', '\x0E', '\x4D', '\x1F', '\x76', '\xEC', '\xFA', + '\xB4', '\x73', '\x6E', '\xD6', '\xA9', '\xCD', '\x67', '\x60', '\xCE', '\x3B', '\x19', + '\x2F', '\xE6', '\xBD', '\x0B', '\xFC', '\x71', '\x92', '\xEF', '\x15', '\x83', '\xFA', + '\xFF', '\x0E', '\xFC', '\x38', '\xE3', '\x85', '\xDE', '\x3F', '\x81', '\xFF', '\x85', + '\xC6', '\x7F', '\x01', '\xFC', '\x1C', '\xF1', '\x37', '\xC0', '\x4D', '\xDF', '\x76', + '\x2C', '\xBD', '\xA6', '\x6F', '\x0D', '\x9F', '\x4B', '\x5D', '\xFF', '\x79', '\xE0', + '\x37', '\x11', '\x5F', '\x02', '\xBE', '\x92', '\xBA', '\x79', '\xAE', '\x02', '\xEF', + '\x64', '\x7F', '\x45', '\x1F', '\xAE', '\x03', '\xDF', '\x4A', '\x5D', '\xBD', '\xDB', + '\xC0', '\xF7', '\x91', '\xBF', '\xB1', '\x75', '\xE8', '\xDB', '\x5D', '\xAB', '\xFF', + '\x4D', '\xDF', '\x1A', '\x6E', '\xD6', '\xF1', '\xAE', '\x95', '\xBF', '\x39', '\x27', + '\xD6', '\xA1', '\x6E', '\xBB', '\x69', '\x2B', '\x5A', '\x34', '\xC2', '\xFA', '\x77', + '\xD3', '\xDE', '\xE0', '\xDF', '\xB0', '\x6F', '\x53', '\xF1', '\x34', '\x9F', '\x9A', + '\x8B', '\x29', '\xE5', '\x40', '\xEB', '\xCF', '\x3F', '\xE1', '\xD8', '\xFE', '\x67', + '\x77', '\x24', '\x2A', '\x0E', '\xF5', '\x0E', '\xF5', '\x4C', '\x91', '\x3C', '\xB3', + '\xE6', '\x6B', '\x50', '\x45', '\x7F', '\xEF', '\xAD', '\x71', '\x6F', '\xD2', '\x5A', + '\xFC', '\x91', '\xF5', '\xFA', '\xE9', '\x0A', '\xD6', '\xAF', '\x87', '\xDC', '\xED', + '\x3D', '\xC7', '\xEC', '\x37', '\xDC', '\xAA', '\xB8', '\xFA', '\xE8', '\xD9', '\x97', + '\x62', '\xD1', '\xDF', '\xF8', '\x2B', '\x62', '\xDC', '\xF4', '\xBB', '\xA3', '\xD8', + '\xFA', '\xE5', '\xFE', '\xD0', '\x65', '\x81', '\x57', '\x14', '\xD5', '\xFF', '\xC3', + '\xD5', '\x2F', '\x77', '\x3F', '\xAD', '\xCF', '\x7E', '\x72', '\x3D', '\x06', '\x63', + '\x71', '\xFD', '\x11', '\xA2', '\xD4', '\x7A', '\xC0', '\x99', '\xF8', '\xDF', '\x4B', + '\xEA', '\x64', '\xFD', '\x5C', '\x04', '\xAE', '\x02', '\xF6', '\xBA', '\xC0', '\xFB', + '\x81', '\x5B', '\x1F', '\x5D', '\x16', '\xE1', '\xEC', '\x87', '\x73', '\x26', '\xD8', + '\xF1', '\xB9', '\x0A', '\x73', '\xFD', '\x2C', '\xE9', '\xE7', '\x15', '\x5D', '\x9D', + '\x7E', '\x39', '\x06', '\xB5', '\x9F', '\xB9', '\x6B', '\x9C', '\xCE', '\x86', '\xD3', + '\x5F', '\x4E', '\x69', '\x15', '\xFD', '\xE5', '\x2A', '\x5C', '\x45', '\x3F', '\x75', + '\xFE', '\xF9', '\xD9', '\x70', '\x6B', '\x46', '\xAF', '\x55', '\xA3', '\x5E', '\x33', + '\x4E', '\x9D', '\xD1', '\xA4', '\x38', '\x4D', '\x8E', '\x36', '\x7C', '\xFD', '\x4D', + '\x5B', '\xF3', '\x51', '\xFC', '\x7E', '\xA9', '\x36', '\x4A', '\x53', '\xF9', '\x44', + '\x8B', '\x36', '\xE9', '\x36', '\xAA', '\xDD', '\x62', '\x5C', '\xCD', '\xBF', '\xC1', + '\x85', '\xF7', '\x61', '\xCA', '\x4F', '\x3A', '\x11', '\x43', '\x37', '\x47', '\xFF', + '\xA6', '\xDA', '\xEB', '\x51', '\x7E', '\xE5', '\xE2', '\x6A', '\x0C', '\x8F', '\x4E', + '\x53', '\x6E', '\x5F', '\x96', '\x9F', '\xEC', '\xF7', '\xE9', '\x88', '\x12', '\x2B', + '\x1B', '\xAD', '\xFE', '\x59', '\x29', '\x6B', '\x08', '\xBD', '\x4D', '\x33', '\xFF', + '\xB6', '\x13', '\xEE', '\xAE', '\x32', '\xF9', '\x85', '\x2A', '\x11', '\xAA', '\xCA', + '\xD5', '\xE8', '\xE7', '\x7B', '\xBD', '\x6C', '\x7E', '\xF5', '\xF4', '\x87', '\xFB', + '\x5A', '\x1A', '\x85', '\xEE', '\x74', '\xAC', '\x3E', '\xFC', '\xB6', '\x3E', '\x2E', + '\x5D', '\x3B', '\x29', '\x47', '\xD9', '\xEA', '\xE8', '\x0F', '\xF7', '\x84', '\xF6', + '\xF7', '\x8E', '\x36', '\x2E', '\x3F', '\xC3', '\x5C', '\xF7', '\xC8', '\xC6', '\x47', + '\x0B', '\xEB', '\xE7', '\xA3', '\xB9', '\xA3', '\x68', '\x3A', '\x9B', '\x8B', '\xAB', + '\xCF', '\x4F', '\xCE', '\x88', '\xB3', '\xEA', '\xFA', '\xA5', '\x7A', '\xC8', '\xB5', + '\x92', '\x55', '\x57', '\xD7', '\x4F', '\xC7', '\xD0', '\xEF', '\xAD', '\x05', '\xC1', + '\xB3', '\xE5', '\xCF', '\x21', '\x3D', '\xAF', '\x9A', '\x99', '\x0E', '\xC7', '\x90', + '\xB2', '\x93', '\xDF', '\xA5', '\xDF', '\xE4', '\xF5', '\x97', '\xEF', '\x97', '\x77', + '\xD1', '\xA2', '\xFE', '\xAB', '\xCE', '\x20', '\x5A', '\xB4', '\x68', '\x93', '\x69', + '\xD4', '\x79', '\x27', '\x9D', '\x82', '\xA1', '\x33', '\x8F', '\x7A', '\x9F', '\x3A', + '\x6B', '\x43', '\xA7', '\x72', '\x38', '\x0A', '\x8E', '\x19', '\xD2', '\xC9', '\x53', + '\xEE', '\xB4', '\xC5', '\x31', '\xB9', '\x53', '\x9A', '\x3B', '\xBB', '\xCB', '\xFE', + '\xAE', '\xE1', '\x6A', '\x2E', '\x6B', '\xD0', '\x9E', '\x83', '\xBA', '\x73', '\x74', + '\xF0', '\x6B', '\x2F', '\x67', '\xBE', '\x2E', '\x4A', '\x41', '\xE8', '\xB6', '\x42', + '\x7F', '\xAF', '\xD1', '\x1F', '\x56', '\xC6', '\x77', '\x1F', '\xD7', '\x99', '\x72', + '\x76', '\x58', '\x27', '\xCE', '\x7C', '\x9C', '\xF4', '\xEB', '\xE6', '\x5D', '\x7E', + '\x0B', '\x7F', '\x2A', '\xAB', '\x1F', '\xD7', '\xB9', '\x9C', '\x7E', '\xF7', '\x6D', + '\x9A', '\x68', '\x95', '\x68', '\xAD', '\x59', '\xFD', '\xFC', '\x13', '\x1D', '\xA3', + '\xDA', '\xFC', '\xD3', '\xDD', '\xCC', '\xBF', '\xE3', '\xCF', '\x0B', '\x9F', '\x9D', + '\xFB', '\x3D', '\xA7', '\x9F', '\x1A', '\x75', '\x74', '\xFA', '\xE5', '\xDC', '\x75', + '\x7D', '\xA0', '\xAB', '\x9F', '\xBD', '\xFF', '\xE9', '\xE7', '\x9A', '\xF3', '\xD4', + '\xF9', '\x49', '\x19', '\xEA', '\xD7', '\x02', '\xFF', '\x9D', '\xF4', '\xBD', '\xAF', + '\x9F', '\x3B', '\x29', '\x69', '\x35', '\x54', '\x9F', '\x51', '\xB5', '\xF3', '\xFD', + '\xA4', '\x7E', '\xA2', '\x46', '\xD3', '\xCD', '\x72', '\x13', '\x36', '\xDA', '\x68', + '\xD1', '\xA2', '\x45', '\x8B', '\x16', '\xAD', '\xAC', '\xF1', '\xE7', '\x33', '\x75', + '\x46', '\x51', '\x7E', '\xFE', '\x38', '\x14', '\xE1', '\x3C', '\xE9', '\xD3', '\x8C', + '\x62', '\xF4', '\xF9', '\x18', '\xF6', '\x95', '\x4F', '\x3E', '\x5A', '\xBF', '\xAC', + '\x67', '\xF0', '\x14', '\xF6', '\x77', '\x2B', '\xE8', '\x3F', '\xFB', '\x77', '\x63', + '\x7E', '\xDC', '\x6A', '\x94', '\x8E', '\xD5', '\x84', '\x7E', '\x6E', '\x7E', '\xC3', + '\xFA', '\xE5', '\xFB', '\x5D', '\x58', '\x49', '\x75', '\x5F', '\xDF', '\xAA', '\xEA', + '\xA7', '\xFA', '\x11', '\xFB', '\x17', '\x95', '\xC2', '\x8A', '\x47', '\xAB', '\x5F', + '\xBE', '\xF3', '\xBA', '\xA6', '\xD7', '\xCF', '\x7D', '\xAB', '\xD1', '\x6F', '\xAF', + '\xA1', '\x66', '\xF5', '\xFB', '\x73', '\x43', '\x31', '\x3A', '\xEF', '\xE6', '\xE7', + '\x9F', '\xDA', '\x2B', '\xF0', '\x2A', '\x2A', '\xAF', '\x49', '\xAE', '\x15', '\xAD', + '\x94', '\xAB', '\x40', '\x55', '\xFD', '\x9A', '\xF5', '\xDF', '\x94', '\x7E', '\x29', + '\xE7', '\xD0', '\xBE', '\x2C', '\x65', '\x88', '\x69', '\x39', '\xFD', '\x61', '\x7F', + '\xEE', '\x6D', '\x9B', '\xE9', '\xF7', '\x74', '\x39', '\x17', '\x8E', '\xEA', '\x47', + '\xE2', '\x3A', '\x5C', '\xEA', '\x3F', '\xBA', '\x4F', '\xDD', '\x95', '\xCD', '\x67', + '\x44', '\xCD', '\x24', '\xEE', '\x53', '\x3A', '\xEB', '\xB0', '\x2F', '\x95', '\x19', + '\x35', '\xCE', '\xBB', '\x6C', '\x93', '\xA8', '\xA9', '\x9C', '\x4D', '\xEA', '\xCC', + '\x46', '\x8B', '\x36', '\xCD', '\xE6', '\xAE', '\x6B', '\xFA', '\x2C', '\x6E', '\x62', + '\xDD', '\xF7', '\x90', '\xE1', '\x68', '\xDC', '\x49', '\x57', '\xFF', '\x49', '\xBE', + '\xE3', '\x69', '\xCE', '\x40', '\x4C', '\xAB', '\xD7', '\x43', '\x7B', '\x8A', '\x36', + '\xF9', '\x24', '\xE7', '\xAF', '\xD1', '\xE6', '\x67', '\x5D', '\xB5', '\x02', '\xC3', + '\xD1', '\x2F', '\xDF', '\x93', '\xE9', '\x9E', '\xA6', '\x33', '\x0A', '\xEB', '\xE7', + '\x47', '\xD5', '\x98', '\x46', '\xBF', '\x4E', '\x0D', '\x95', '\xB7', '\x6E', '\xED', + '\xCA', '\x1D', '\x2F', '\xEB', '\x97', '\x2A', '\xA7', '\xB1', '\xBA', '\xFA', '\x0B', + '\x45', '\x1A', '\xFD', '\xE5', '\x7E', '\xD3', '\x94', '\x21', '\x55', '\xAD', '\xBE', + '\xFE', '\xFC', '\xB9', '\xBA', '\xFE', '\xF0', '\x7C', '\x5F', '\xBD', '\x7E', '\xA9', + '\x9B', '\xE9', '\x6F', '\xE9', '\x9E', '\xA8', '\xA6', '\xBF', '\xC9', '\xFD', '\x5E', + '\x1E', '\xB9', '\xBC', '\xFE', '\xD0', '\x38', '\xA1', '\xCC', '\x75', '\x73', '\x3B', + '\x2A', '\xFD', '\xD4', '\x79', '\x6C', '\x73', '\xFE', '\xDD', '\x3A', '\xFA', '\xDD', + '\x78', '\xA3', '\xD5', '\x3F', '\x7E', '\x46', '\x6B', '\xE3', '\xFB', '\x74', '\xD2', + '\x8C', '\xEA', '\x3E', '\xEA', '\xC6', '\x18', '\x1E', '\x81', '\xEE', '\xE4', '\x68', + '\xD1', '\xA2', '\xE5', '\xA6', '\x59', '\x1B', '\xFA', '\xF5', '\xA3', '\x59', '\x95', + '\xDA', '\x37', '\xE9', '\xB3', '\x45', '\x77', '\x5A', '\x96', '\xB1', '\xF0', '\xFB', + '\xCD', '\xE8', '\x0F', '\xD7', '\x86', '\x27', '\xC3', '\xD4', '\x1F', '\xB6', '\xAB', + '\xD1', '\xAF', '\xF5', '\x6B', '\x5E', '\x3F', '\x3E', '\x33', '\xA8', '\x53', '\x24', + '\xEC', '\xE3', '\xDF', '\x69', '\xCA', '\x7C', '\xF6', '\xCF', '\x3B', '\x97', '\x52', + '\x1D', '\x91', '\x3F', '\xF9', '\x1E', '\xB4', '\x02', '\x4D', '\x15', '\x34', '\x31', + '\x65', '\x0F', '\xBA', '\x73', '\xAB', '\xFA', '\x53', '\xBF', '\x2A', '\xFC', '\x3A', + '\xD9', '\xFF', '\x73', '\xA3', '\x87', '\x94', '\x6B', '\x6B', '\x5E', '\x4F', '\x4F', + '\x35', '\xFD', '\x6E', '\x74', '\x7E', '\x8C', '\x6A', '\xFA', '\xCB', '\xE6', '\xC6', + '\x7B', '\xD0', '\x55', '\x9C', '\x1E', '\xFD', '\xF4', '\xB8', '\xF5', '\xF5', '\x87', + '\xCE', '\x86', '\x51', '\xEA', '\x0F', '\x45', '\x1C', '\x78', '\x34', '\xAB', '\x5F', + '\xDA', '\xFF', '\xEA', '\xEA', '\xD7', '\xEC', '\xCD', '\x7E', '\x1F', '\xFA', '\x3E', + '\xD4', '\x67', '\x39', '\x46', '\x19', '\xFD', '\x1A', '\x95', '\x55', '\xF5', '\x8F', + '\xCE', '\xB4', '\xF9', '\x8C', '\x5B', '\xDE', '\xF5', '\xCD', '\xEF', '\x28', '\xD9', + '\x73', '\xF8', '\x19', '\x45', '\x8B', '\x16', '\x6D', '\x32', '\x8C', '\x3A', '\xAD', + '\x46', '\x19', '\x7B', '\x54', '\xB1', '\xB4', '\x19', '\x44', '\xFD', '\x5C', '\x4E', + '\xE1', '\x7B', '\x0C', '\x77', '\x57', '\xF1', '\xEF', '\x47', '\xBE', '\xAF', '\xE6', + '\x26', '\x52', '\xC7', '\x97', '\xCF', '\x57', '\xA7', '\xBF', '\x89', '\x98', '\x78', + '\x6C', '\x5C', '\xCD', '\xE1', '\xEA', '\xA7', '\xF4', '\x8D', '\x42', '\x3F', '\x3F', + '\x76', '\x73', '\xFA', '\xF9', '\x3B', '\x34', '\x9F', '\x01', '\xEE', '\x85', '\xE1', + '\xEB', '\xC7', '\x31', '\x43', '\xF9', '\xD2', '\x9A', '\x06', '\x7E', '\x9A', '\xEA', + '\xFA', '\x1E', '\x52', '\x37', '\x0C', '\x5F', '\x3F', '\xFF', '\xAD', '\x46', '\xBF', + '\xAD', '\x80', '\xFE', '\x26', '\x4C', '\x42', '\x6A', '\xC7', '\x5F', '\xBF', '\xF4', + '\x1C', '\xEE', '\x9E', '\xAA', '\xFA', '\xEB', '\xEC', '\xFF', '\xB2', '\x9E', '\x32', + '\xFB', '\x73', '\x19', '\xFD', '\x5C', '\xF4', '\x6A', '\xFB', '\x9F', '\x6F', '\x72', + '\xA5', '\x74', '\x63', '\x0C', '\xD7', '\xC2', '\x79', '\x4C', '\xB2', '\x7E', '\x5D', + '\x16', '\xE1', '\x8E', '\x88', '\x16', '\x2D', '\x1A', '\x77', '\x5F', '\x9A', '\x2E', + '\x9B', '\xF6', '\x0A', '\x44', '\xFD', '\x51', '\x3F', '\xF7', '\x79', '\x3A', '\x2A', + '\xE3', '\xDE', '\x58', '\x8B', '\x7F', '\xA7', '\x43', '\x3F', '\xBE', '\x2B', '\xD9', + '\xFF', '\x4F', '\xAF', '\xFE', '\xE9', '\xD9', '\x17', '\xA6', '\x45', '\x27', '\x67', + '\x51', '\xFF', '\xF4', '\xEA', '\x8F', '\xF7', '\xDF', '\x68', '\xD1', '\xA2', '\x45', + '\x8B', '\x16', '\x2D', '\x5A', '\xB4', '\xE9', '\xB1', '\xFF', '\x01', '\xF1', '\xAA', + '\xBA', '\x4E', '\x18', '\x89', '\x00', '\x00' }; #endif // NO_OGL diff --git a/src/win32/resource.h b/src/win32/resource.h index eae315e6..797c2fbd 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -2,862 +2,862 @@ // Microsoft Visual C++ generated include file. // Used by VBA.rc // -#define IDS_UNSUPPORTED_VBA_SGM 1 -#define IDS_CANNOT_LOAD_SGM 2 -#define IDS_SAVE_GAME_NOT_USING_BIOS 3 -#define IDC_DEFAULTS 3 -#define IDS_SAVE_GAME_USING_BIOS 4 -#define IDS_UNSUPPORTED_SAVE_TYPE 5 -#define IDS_CANNOT_OPEN_FILE 6 -#define IDS_BAD_ZIP_FILE 7 -#define IDS_NO_IMAGE_ON_ZIP 8 -#define IDS_ERROR_OPENING_IMAGE 9 -#define IDS_ERROR_READING_IMAGE 10 -#define IDS_UNSUPPORTED_BIOS_FUNCTION 11 -#define IDS_INVALID_BIOS_FILE_SIZE 12 -#define IDS_INVALID_CHEAT_CODE 13 -#define IDS_UNKNOWN_ARM_OPCDOE 14 -#define IDS_UNKNOWN_THUMB_OPCODE 15 -#define IDS_ERROR_CREATING_FILE 16 -#define IDS_FAILED_TO_READ_SGM 17 -#define IDS_FAILED_TO_READ_RTC 18 -#define IDS_UNSUPPORTED_VB_SGM 19 -#define IDS_CANNOT_LOAD_SGM_FOR 20 -#define IDS_ERROR_OPENING_IMAGE_FROM 21 -#define IDS_ERROR_READING_IMAGE_FROM 22 -#define IDS_UNSUPPORTED_ROM_SIZE 23 -#define IDS_UNSUPPORTED_RAM_SIZE 24 -#define IDS_UNKNOWN_CARTRIDGE_TYPE 25 -#define IDS_MAXIMUM_NUMBER_OF_CHEATS 26 -#define IDS_INVALID_GAMESHARK_CODE 27 -#define IDS_INVALID_GAMEGENIE_CODE 28 -#define IDS_INVALID_CHEAT_TO_REMOVE 29 -#define IDS_INVALID_CHEAT_CODE_ADDRESS 30 +#define IDS_UNSUPPORTED_VBA_SGM 1 +#define IDS_CANNOT_LOAD_SGM 2 +#define IDS_SAVE_GAME_NOT_USING_BIOS 3 +#define IDC_DEFAULTS 3 +#define IDS_SAVE_GAME_USING_BIOS 4 +#define IDS_UNSUPPORTED_SAVE_TYPE 5 +#define IDS_CANNOT_OPEN_FILE 6 +#define IDS_BAD_ZIP_FILE 7 +#define IDS_NO_IMAGE_ON_ZIP 8 +#define IDS_ERROR_OPENING_IMAGE 9 +#define IDS_ERROR_READING_IMAGE 10 +#define IDS_UNSUPPORTED_BIOS_FUNCTION 11 +#define IDS_INVALID_BIOS_FILE_SIZE 12 +#define IDS_INVALID_CHEAT_CODE 13 +#define IDS_UNKNOWN_ARM_OPCDOE 14 +#define IDS_UNKNOWN_THUMB_OPCODE 15 +#define IDS_ERROR_CREATING_FILE 16 +#define IDS_FAILED_TO_READ_SGM 17 +#define IDS_FAILED_TO_READ_RTC 18 +#define IDS_UNSUPPORTED_VB_SGM 19 +#define IDS_CANNOT_LOAD_SGM_FOR 20 +#define IDS_ERROR_OPENING_IMAGE_FROM 21 +#define IDS_ERROR_READING_IMAGE_FROM 22 +#define IDS_UNSUPPORTED_ROM_SIZE 23 +#define IDS_UNSUPPORTED_RAM_SIZE 24 +#define IDS_UNKNOWN_CARTRIDGE_TYPE 25 +#define IDS_MAXIMUM_NUMBER_OF_CHEATS 26 +#define IDS_INVALID_GAMESHARK_CODE 27 +#define IDS_INVALID_GAMEGENIE_CODE 28 +#define IDS_INVALID_CHEAT_TO_REMOVE 29 +#define IDS_INVALID_CHEAT_CODE_ADDRESS 30 #define IDS_UNSUPPORTED_CHEAT_LIST_VERSION 31 #define IDS_UNSUPPORTED_CHEAT_LIST_TYPE 32 -#define IDS_INVALID_GSA_CODE 33 -#define IDS_CANNOT_IMPORT_SNAPSHOT_FOR 34 -#define IDS_UNSUPPORTED_SNAPSHOT_FILE 35 -#define IDS_UNSUPPORTED_ARM_MODE 36 -#define IDS_UNSUPPORTED_CODE_FILE 37 -#define IDS_GSA_CODE_WARNING 38 -#define IDS_INVALID_CBA_CODE 39 -#define IDS_CBA_CODE_WARNING 40 -#define IDS_OUT_OF_MEMORY 41 -#define IDS_WRONG_GAMESHARK_CODE 42 -#define IDS_TOOLTIP_DEFAULT_VOLUME 42 -#define IDS_UNSUPPORTED_GAMESHARK_CODE 43 -#define IDS_TOOLTIP_ENHANCE_SOUND 43 -#define IDS_TOOLTIP_SURROUND 44 -#define IDS_TOOLTIP_DECLICKING 45 -#define IDS_FILTER_COMPRESSED_FILES 46 -#define IDI_MAINICON 101 -#define IDD_REGISTERS 102 -#define IDD_DEBUG 103 -#define IDR_MENU 104 -#define IDD_ABOUT 105 -#define IDR_ACCELERATOR 106 -#define IDD_CHEATS 107 -#define IDD_ADD_CHEAT 108 -#define IDD_DIRECTORIES 109 -#define IDD_CONFIG 110 -#define IDD_GS 111 -#define IDD_GG 112 -#define IDD_CHEAT_LIST 113 -#define IDD_ASSOCIATIONS 114 -#define IDR_GB_PRINTER 115 -#define IDD_GBA_ROM_INFO 116 -#define IDD_GB_ROM_INFO 117 -#define IDD_GB_CHEAT_LIST 118 -#define IDD_ADD_CHEAT_DLG 119 -#define IDD_GB_PRINTER 120 -#define IDD_MOTION_CONFIG 121 -#define IDD_LANG_SELECT 122 -#define IDD_CODE_SELECT 123 -#define IDD_OPENDLG 124 -#define IDD_MAP_VIEW 126 -#define IDD_PALETTE_VIEW 127 -#define IDD_MEM_VIEWER 128 -#define IDD_OAM_VIEW 130 -#define IDD_ACCEL_EDITOR 131 -#define IDD_TILE_VIEWER 132 -#define IDD_GB_COLORS 133 -#define IDD_DISASSEMBLE 134 -#define IDD_GDB_PORT 135 -#define IDD_GDB_WAITING 136 -#define IDD_LOGGING 137 -#define IDD_EXPORT_SPS 138 -#define IDD_ADDR_SIZE 139 -#define IDD_MODES 140 -#define IDD_THROTTLE 143 -#define IDD_GB_DISASSEMBLE 144 -#define IDD_GB_OAM_VIEW 145 -#define IDD_GB_TILE_VIEWER 146 -#define IDD_GB_MAP_VIEW 147 -#define IDD_GB_PALETTE_VIEW 148 -#define IDD_MODE_CONFIRM 149 -#define IDD_REWIND_INTERVAL 150 -#define IDD_IO_VIEWER 151 -#define IDD_MAX_SCALE 154 -#define IDD_GAME_OVERRIDES 156 -#define IDD_SELECT 159 -#define IDD_SELECT_PLUGIN 159 -#define IDD_OAL_CONFIG 160 -#define IDD_BIOS 161 -#define IDD_FULLSCREEN 162 -#define IDD_XAUDIO2_CONFIG 163 -#define IDD_AUDIO_CORE_SETTINGS 164 -#define IDC_R0 1000 -#define IDC_EDIT_UP 1000 -#define IDC_R1 1001 -#define IDC_EDIT_DOWN 1001 -#define IDC_R2 1002 -#define IDC_EDIT_LEFT 1002 -#define IDC_R3 1003 -#define IDC_EDIT_RIGHT 1003 -#define IDC_R4 1004 -#define IDC_EDIT_BUTTON_A 1004 -#define IDC_R5 1005 -#define IDC_EDIT_BUTTON_B 1005 -#define IDC_R6 1006 -#define IDC_EDIT_BUTTON_SELECT 1006 -#define IDC_R7 1007 -#define IDC_EDIT_BUTTON_START 1007 -#define IDC_R8 1008 -#define ID_OK 1008 -#define IDC_R9 1009 -#define ID_CANCEL 1009 -#define ID_SAVE 1009 -#define IDC_R10 1010 -#define IDC_EDIT_SPEED 1010 -#define IDC_R11 1011 -#define IDC_EDIT_CAPTURE 1011 -#define IDC_R12 1012 -#define IDC_EDIT_BUTTON_L 1012 -#define IDC_R13 1013 -#define IDC_EDIT_BUTTON_GS 1013 -#define IDC_R14 1014 -#define IDC_EDIT_BUTTON_R 1014 -#define IDC_R15 1015 -#define IDC_R16 1016 -#define IDC_R17 1017 -#define IDC_N_FLAG 1018 -#define IDC_ROM_DIR 1018 -#define IDC_Z_FLAG 1019 -#define IDC_NEXT 1019 -#define IDC_BATTERY_DIR 1019 -#define IDC_C_FLAG 1020 -#define IDC_CONTINUE 1020 -#define IDC_SAVE_DIR 1020 -#define IDC_V_FLAG 1021 -#define IDC_CAPTURE_DIR 1021 -#define IDC_CHEAT_LIST 1021 -#define IDC_IRQ 1022 -#define IDC_ROM_PATH 1022 -#define IDC_START 1022 -#define IDC_T_FLAG 1023 -#define IDC_BATTERY_PATH 1023 -#define IDC_SEARCH 1023 -#define IDS_DIRECTX_7_REQUIRED 1024 -#define IDC_SAVE_PATH 1024 -#define IDC_ADD_CHEAT 1024 -#define IDC_M4 1025 -#define IDC_CAPTURE_PATH 1025 -#define IDC_OLD_VALUE 1025 -#define IDC_ADD_GS_CHEAT 1025 -#define IDS_DISABLING_VIDEO_MEMORY 1025 -#define IDC_ADD_GAMESHARK 1025 -#define IDC_M3 1026 -#define IDC_SPECIFIC_VALUE 1026 -#define IDS_SETTING_WILL_BE_EFFECTIVE 1026 -#define IDC_GBROM_DIR 1026 -#define IDC_M2 1027 -#define IDS_DISABLING_EMULATION_ONLY 1027 -#define IDC_GBROM_PATH 1027 -#define IDC_M1 1028 -#define IDC_SIZE_8 1028 -#define IDS_FAILED_TO_OPEN_FILE 1028 -#define IDC_ROM_DIR_RESET 1028 -#define IDC_M0 1029 -#define IDC_SIZE_16 1029 -#define IDS_FAILED_TO_READ_ZIP_DIR 1029 -#define IDC_GBROM_DIR_RESET 1029 -#define IDC_SIZE_32 1030 -#define IDS_UNSUPPORTED_FILE_TYPE 1030 -#define IDC_BATTERY_DIR_RESET 1030 -#define IDC_EQ 1031 -#define IDS_CANNOT_CREATE_DIRECTSOUND 1031 -#define IDC_SAVE_DIR_RESET 1031 -#define IDC_NE 1032 -#define IDS_CANNOT_SETCOOPERATIVELEVEL 1032 -#define IDC_CAPTURE_DIR_RESET 1032 -#define IDC_LT 1033 -#define IDS_CANNOT_CREATESOUNDBUFFER 1033 -#define IDC_GBCROM_PATH 1033 -#define IDC_LE 1034 -#define IDS_CANNOT_SETFORMAT_PRIMARY 1034 -#define IDC_GBCROM_DIR 1034 -#define IDC_GT 1035 +#define IDS_INVALID_GSA_CODE 33 +#define IDS_CANNOT_IMPORT_SNAPSHOT_FOR 34 +#define IDS_UNSUPPORTED_SNAPSHOT_FILE 35 +#define IDS_UNSUPPORTED_ARM_MODE 36 +#define IDS_UNSUPPORTED_CODE_FILE 37 +#define IDS_GSA_CODE_WARNING 38 +#define IDS_INVALID_CBA_CODE 39 +#define IDS_CBA_CODE_WARNING 40 +#define IDS_OUT_OF_MEMORY 41 +#define IDS_WRONG_GAMESHARK_CODE 42 +#define IDS_TOOLTIP_DEFAULT_VOLUME 42 +#define IDS_UNSUPPORTED_GAMESHARK_CODE 43 +#define IDS_TOOLTIP_ENHANCE_SOUND 43 +#define IDS_TOOLTIP_SURROUND 44 +#define IDS_TOOLTIP_DECLICKING 45 +#define IDS_FILTER_COMPRESSED_FILES 46 +#define IDI_MAINICON 101 +#define IDD_REGISTERS 102 +#define IDD_DEBUG 103 +#define IDR_MENU 104 +#define IDD_ABOUT 105 +#define IDR_ACCELERATOR 106 +#define IDD_CHEATS 107 +#define IDD_ADD_CHEAT 108 +#define IDD_DIRECTORIES 109 +#define IDD_CONFIG 110 +#define IDD_GS 111 +#define IDD_GG 112 +#define IDD_CHEAT_LIST 113 +#define IDD_ASSOCIATIONS 114 +#define IDR_GB_PRINTER 115 +#define IDD_GBA_ROM_INFO 116 +#define IDD_GB_ROM_INFO 117 +#define IDD_GB_CHEAT_LIST 118 +#define IDD_ADD_CHEAT_DLG 119 +#define IDD_GB_PRINTER 120 +#define IDD_MOTION_CONFIG 121 +#define IDD_LANG_SELECT 122 +#define IDD_CODE_SELECT 123 +#define IDD_OPENDLG 124 +#define IDD_MAP_VIEW 126 +#define IDD_PALETTE_VIEW 127 +#define IDD_MEM_VIEWER 128 +#define IDD_OAM_VIEW 130 +#define IDD_ACCEL_EDITOR 131 +#define IDD_TILE_VIEWER 132 +#define IDD_GB_COLORS 133 +#define IDD_DISASSEMBLE 134 +#define IDD_GDB_PORT 135 +#define IDD_GDB_WAITING 136 +#define IDD_LOGGING 137 +#define IDD_EXPORT_SPS 138 +#define IDD_ADDR_SIZE 139 +#define IDD_MODES 140 +#define IDD_THROTTLE 143 +#define IDD_GB_DISASSEMBLE 144 +#define IDD_GB_OAM_VIEW 145 +#define IDD_GB_TILE_VIEWER 146 +#define IDD_GB_MAP_VIEW 147 +#define IDD_GB_PALETTE_VIEW 148 +#define IDD_MODE_CONFIRM 149 +#define IDD_REWIND_INTERVAL 150 +#define IDD_IO_VIEWER 151 +#define IDD_MAX_SCALE 154 +#define IDD_GAME_OVERRIDES 156 +#define IDD_SELECT 159 +#define IDD_SELECT_PLUGIN 159 +#define IDD_OAL_CONFIG 160 +#define IDD_BIOS 161 +#define IDD_FULLSCREEN 162 +#define IDD_XAUDIO2_CONFIG 163 +#define IDD_AUDIO_CORE_SETTINGS 164 +#define IDC_R0 1000 +#define IDC_EDIT_UP 1000 +#define IDC_R1 1001 +#define IDC_EDIT_DOWN 1001 +#define IDC_R2 1002 +#define IDC_EDIT_LEFT 1002 +#define IDC_R3 1003 +#define IDC_EDIT_RIGHT 1003 +#define IDC_R4 1004 +#define IDC_EDIT_BUTTON_A 1004 +#define IDC_R5 1005 +#define IDC_EDIT_BUTTON_B 1005 +#define IDC_R6 1006 +#define IDC_EDIT_BUTTON_SELECT 1006 +#define IDC_R7 1007 +#define IDC_EDIT_BUTTON_START 1007 +#define IDC_R8 1008 +#define ID_OK 1008 +#define IDC_R9 1009 +#define ID_CANCEL 1009 +#define ID_SAVE 1009 +#define IDC_R10 1010 +#define IDC_EDIT_SPEED 1010 +#define IDC_R11 1011 +#define IDC_EDIT_CAPTURE 1011 +#define IDC_R12 1012 +#define IDC_EDIT_BUTTON_L 1012 +#define IDC_R13 1013 +#define IDC_EDIT_BUTTON_GS 1013 +#define IDC_R14 1014 +#define IDC_EDIT_BUTTON_R 1014 +#define IDC_R15 1015 +#define IDC_R16 1016 +#define IDC_R17 1017 +#define IDC_N_FLAG 1018 +#define IDC_ROM_DIR 1018 +#define IDC_Z_FLAG 1019 +#define IDC_NEXT 1019 +#define IDC_BATTERY_DIR 1019 +#define IDC_C_FLAG 1020 +#define IDC_CONTINUE 1020 +#define IDC_SAVE_DIR 1020 +#define IDC_V_FLAG 1021 +#define IDC_CAPTURE_DIR 1021 +#define IDC_CHEAT_LIST 1021 +#define IDC_IRQ 1022 +#define IDC_ROM_PATH 1022 +#define IDC_START 1022 +#define IDC_T_FLAG 1023 +#define IDC_BATTERY_PATH 1023 +#define IDC_SEARCH 1023 +#define IDS_DIRECTX_7_REQUIRED 1024 +#define IDC_SAVE_PATH 1024 +#define IDC_ADD_CHEAT 1024 +#define IDC_M4 1025 +#define IDC_CAPTURE_PATH 1025 +#define IDC_OLD_VALUE 1025 +#define IDC_ADD_GS_CHEAT 1025 +#define IDS_DISABLING_VIDEO_MEMORY 1025 +#define IDC_ADD_GAMESHARK 1025 +#define IDC_M3 1026 +#define IDC_SPECIFIC_VALUE 1026 +#define IDS_SETTING_WILL_BE_EFFECTIVE 1026 +#define IDC_GBROM_DIR 1026 +#define IDC_M2 1027 +#define IDS_DISABLING_EMULATION_ONLY 1027 +#define IDC_GBROM_PATH 1027 +#define IDC_M1 1028 +#define IDC_SIZE_8 1028 +#define IDS_FAILED_TO_OPEN_FILE 1028 +#define IDC_ROM_DIR_RESET 1028 +#define IDC_M0 1029 +#define IDC_SIZE_16 1029 +#define IDS_FAILED_TO_READ_ZIP_DIR 1029 +#define IDC_GBROM_DIR_RESET 1029 +#define IDC_SIZE_32 1030 +#define IDS_UNSUPPORTED_FILE_TYPE 1030 +#define IDC_BATTERY_DIR_RESET 1030 +#define IDC_EQ 1031 +#define IDS_CANNOT_CREATE_DIRECTSOUND 1031 +#define IDC_SAVE_DIR_RESET 1031 +#define IDC_NE 1032 +#define IDS_CANNOT_SETCOOPERATIVELEVEL 1032 +#define IDC_CAPTURE_DIR_RESET 1032 +#define IDC_LT 1033 +#define IDS_CANNOT_CREATESOUNDBUFFER 1033 +#define IDC_GBCROM_PATH 1033 +#define IDC_LE 1034 +#define IDS_CANNOT_SETFORMAT_PRIMARY 1034 +#define IDC_GBCROM_DIR 1034 +#define IDC_GT 1035 #define IDS_CANNOT_CREATESOUNDBUFFER_SEC 1035 -#define IDC_GE 1036 -#define IDS_CANNOT_PLAY_PRIMARY 1036 -#define IDC_SIGNED 1037 -#define IDS_SEARCH_PRODUCED_TOO_MANY 1037 -#define IDC_UNSIGNED 1038 -#define IDS_NUMBER_CANNOT_BE_EMPTY 1038 -#define IDS_INVALID_ADDRESS 1039 -#define IDC_HEXADECIMAL 1040 -#define IDS_MISALIGNED_HALFWORD 1040 -#define IDC_VALUE 1041 -#define IDS_MISALIGNED_WORD 1041 -#define IDC_ADDRESS 1042 -#define IDS_VALUE_CANNOT_BE_EMPTY 1042 -#define IDS_ERROR_ON_STARTDOC 1043 -#define IDC_R 1043 -#define IDS_ERROR_ON_STARTPAGE 1044 -#define IDC_G 1044 -#define IDS_ERROR_PRINTING_ON_STRETCH 1045 -#define IDC_B 1045 -#define IDC_UPDATE 1046 -#define IDS_ERROR_ON_ENDPAGE 1046 -#define IDC_TILE_NUM 1046 -#define IDC_GGDESC 1047 -#define IDS_ERROR_ON_ENDDOC 1047 -#define IDC_FLIP 1047 -#define IDC_GGCODE 1048 -#define IDS_ERROR 1048 -#define IDC_PALETTE_NUM 1048 -#define IDC_GGADD 1049 -#define IDS_JOY_LEFT 1049 -#define IDC_GGDEL 1050 -#define IDS_JOY_RIGHT 1050 -#define IDC_GGLIST 1051 -#define IDS_JOY_UP 1051 -#define IDC_GGRES 1052 -#define IDS_JOY_DOWN 1052 -#define IDC_GGQUIT 1053 -#define IDS_JOY_BUTTON 1053 -#define IDC_GSDESC 1054 -#define IDS_SELECT_ROM_DIR 1054 -#define IDC_GSCODE 1055 -#define IDS_SELECT_BATTERY_DIR 1055 -#define IDC_GSADD 1056 -#define IDS_SELECT_SAVE_DIR 1056 -#define IDC_GSDEL 1057 -#define IDS_SELECT_CAPTURE_DIR 1057 -#define IDC_GSLIST 1058 -#define IDS_SELECT_BIOS_FILE 1058 -#define IDC_GSRES 1059 -#define IDS_RESET 1059 -#define IDC_GSQUIT 1060 -#define IDS_AUTOFIRE_A_DISABLED 1060 -#define IDC_FREEZE 1061 -#define IDS_AUTOFIRE_A 1061 -#define IDS_AUTOFIRE_B_DISABLED 1062 -#define IDS_AUTOFIRE_B 1063 -#define IDS_AUTOFIRE_L_DISABLED 1064 -#define IDS_AUTOFIRE_L 1065 -#define IDS_AUTOFIRE_R_DISABLED 1066 -#define IDC_REMOVE 1067 -#define IDS_AUTOFIRE_R 1067 -#define IDC_REMOVE_ALL 1068 -#define IDS_SELECT_ROM 1068 -#define IDS_SELECT_SAVE_GAME_NAME 1069 -#define IDC_ENABLE 1070 -#define IDS_LOADED_STATE 1070 -#define IDS_LOADED_STATE_N 1071 -#define IDS_WROTE_STATE 1072 -#define IDS_WROTE_STATE_N 1073 -#define IDC_RESTORE 1074 -#define IDS_LOADED_BATTERY 1074 -#define IDC_GBA 1075 -#define IDS_SELECT_CAPTURE_NAME 1075 -#define IDC_AGB 1076 -#define IDS_SCREEN_CAPTURE 1076 -#define IDC_BIN 1077 -#define IDS_ADDRESS 1077 -#define IDC_GB 1078 -#define IDS_OLD_VALUE 1078 -#define IDC_SGB 1079 -#define IDC_ROM_TITLE 1079 -#define IDS_NEW_VALUE 1079 -#define IDC_CGB 1080 -#define IDC_ROM_GAME_CODE 1080 -#define IDS_ADD_CHEAT_CODE 1080 -#define IDC_GBC 1081 -#define IDC_ROM_MAKER_CODE 1081 -#define IDS_CODE 1081 -#define IDC_DMG 1082 -#define IDC_ROM_UNIT_CODE 1082 -#define IDS_DESCRIPTION 1082 -#define IDC_ROM_DEVICE_TYPE 1083 -#define IDS_STATUS 1083 -#define IDC_ROM_VERSION 1084 -#define IDS_ADD_GG_CODE 1084 -#define IDC_ROM_CRC 1085 -#define IDS_ADD_GS_CODE 1085 -#define IDC_ROM_COLOR 1086 -#define IDC_CODE 1086 -#define IDS_POCKET_PRINTER 1086 -#define IDC_ROM_MAKER_NAME 1086 -#define IDC_ROM_SIZE 1087 -#define IDC_DESC 1087 -#define IDS_UNKNOWN 1087 -#define IDC_ROM_RAM_SIZE 1088 -#define IDC_ADD_GG_CHEAT 1088 -#define IDS_NONE 1088 -#define IDC_ROM_DEST_CODE 1089 -#define IDC_GB_PRINTER 1089 -#define IDS_FAILED_TO_LOAD_LIBRARY 1089 -#define IDC_ROM_LIC_CODE 1090 -#define IDC_1X 1090 -#define IDS_FAILED_TO_GET_LOCINFO 1090 -#define IDC_ROM_CHECKSUM 1091 -#define IDC_2X 1091 -#define IDS_SELECT_CHEAT_LIST_NAME 1091 -#define IDC_3X 1092 -#define IDS_FILTER_BIOS 1092 -#define IDC_4X 1093 -#define IDS_FILTER_GBAROM 1093 -#define IDC_ROM_MAKER_NAME2 1093 -#define ID_PRINT 1094 -#define IDS_FILTER_SGM 1094 -#define IDC_ADD_GSA 1095 -#define IDC_ADD_CODE 1095 -#define IDS_FILTER_CHEAT_LIST 1095 -#define IDC_TRANSLATION_BY 1096 -#define IDS_FILTER_PNG 1096 -#define IDC_LANG_STRING 1097 -#define IDS_LOADED_CHEATS 1097 -#define IDC_LANG_NAME 1098 -#define IDS_ERROR_DISP_COLOR 1098 -#define IDS_ADD_GSA_CODE 1099 -#define IDC_GAME_LIST 1099 -#define IDS_FILTER_SPS 1100 -#define IDS_SELECT_SNAPSHOT_FILE 1101 -#define IDC_ADD_CODEBREAKER 1101 -#define IDS_FILTER_SAV 1102 -#define IDS_SELECT_BATTERY_FILE 1103 -#define IDS_FILTER_GBS 1104 -#define IDS_FILTER_GCF 1105 -#define IDS_SELECT_CODE_FILE 1106 -#define IDS_SAVE_WILL_BE_LOST 1107 -#define IDS_CONFIRM_ACTION 1108 -#define IDS_CODES_WILL_BE_LOST 1109 -#define IDS_FILTER_SPC 1110 -#define IDS_ADD_CBA_CODE 1111 -#define IDS_FILTER_WAV 1112 -#define IDS_SELECT_WAV_NAME 1113 -#define IDC_FRAME_0 1113 -#define IDS_FILTER_GBROM 1114 -#define IDC_FRAME_1 1114 -#define IDC_BG0 1115 -#define IDS_FILTER_PAL 1115 -#define IDC_BG1 1116 -#define IDS_SELECT_PALETTE_NAME 1116 -#define IDC_BG2 1117 -#define IDS_SEARCH_PRODUCED_NO_RESULTS 1117 -#define IDC_BG3 1118 -#define IDS_ERROR_BINDING 1118 -#define IDS_ERROR_LISTENING 1119 -#define IDS_ERROR_CREATING_SOCKET 1120 -#define IDS_ACK_NOT_RECEIVED 1121 -#define IDS_ERROR_NOT_GBA_IMAGE 1122 -#define IDS_EEPROM_NOT_SUPPORTED 1123 -#define IDC_MAP_VIEW 1124 -#define IDS_FILTER_DUMP 1124 -#define IDC_PALETTE_VIEW 1125 -#define IDS_SELECT_DUMP_FILE 1125 -#define IDC_PALETTE_VIEW_OBJ 1126 -#define IDC_REFRESH 1126 -#define IDS_FILTER_AVI 1126 -#define IDC_SAVE 1127 -#define IDC_GOPC 1127 -#define IDS_SELECT_AVI_NAME 1127 -#define IDC_APPLY 1127 -#define IDS_INVALID_THROTTLE_VALUE 1128 -#define IDC_REFRESH2 1129 -#define IDS_FILTER_INI 1129 -#define IDS_SELECT_SKIN_FILE 1130 -#define IDC_CLOSE 1131 -#define IDS_FILTER_VMV 1131 -#define IDS_SELECT_MOVIE_NAME 1132 -#define IDS_BUG_REPORT 1133 -#define IDS_UNSUPPORTED_MOVIE_VERSION 1134 -#define IDS_END_OF_MOVIE 1135 -#define IDC_COLOR 1136 -#define IDS_INVALID_INTERVAL_VALUE 1136 -#define IDC_SAVE_BG 1137 -#define IDS_REGISTRY 1137 -#define IDC_SAVE_OBJ 1138 -#define IDC_MAP_VIEW_ZOOM 1138 -#define IDS_MOVIE_PLAY 1138 -#define IDS_FILTER_GSVSPS 1139 -#define IDC_VIEWER 1140 -#define IDC_CHANGE_BACKDROP 1140 -#define IDC_ADDRESSES 1141 -#define IDC_GO 1143 -#define IDC_8_BIT 1144 -#define IDC_16_BIT 1145 -#define IDC_32_BIT 1146 -#define IDC_OAM_VIEW 1147 -#define IDC_OAM_VIEW_ZOOM 1148 -#define IDC_SPRITE 1150 -#define IDC_POS 1151 -#define IDC_MODE 1152 -#define IDC_COLORS 1153 -#define IDC_MAPBASE 1153 -#define IDC_PALETTE 1154 -#define IDC_CHARBASE 1154 -#define IDC_TILE 1155 -#define IDC_DIM 1155 -#define IDC_PRIO 1156 -#define IDC_NUMCOLORS 1156 -#define IDC_SCROLLBAR 1157 -#define IDC_PRIORITY 1157 -#define IDC_MOSAIC 1158 -#define IDC_SIZE2 1159 -#define IDC_OVERFLOW 1159 -#define IDC_ROT 1160 -#define IDC_FLAGS 1161 -#define IDC_COMMANDS 1162 -#define IDC_BANK 1162 -#define IDC_CURRENTS 1163 -#define IDC_ASSIGN 1164 -#define IDC_RESET 1165 -#define IDC_EDIT_KEY 1166 -#define IDC_ALREADY_AFFECTED 1167 -#define IDC_TILE_VIEW 1168 -#define IDC_16_COLORS 1169 -#define IDC_256_COLORS 1170 -#define IDC_CHARBASE_0 1173 -#define IDC_CHARBASE_1 1174 -#define IDC_CHARBASE_2 1175 -#define IDC_CHARBASE_3 1176 -#define IDC_PALETTE_SLIDER 1177 -#define IDC_CHARBASE_4 1178 -#define IDC_COLOR_BG0 1178 -#define IDC_COLOR_BG1 1179 -#define IDC_URL 1179 -#define IDC_COLOR_BG2 1180 -#define IDC_STRETCH 1180 -#define IDC_COLOR_BG3 1181 -#define IDC_COLOR_OB0 1182 -#define IDC_COLOR_OB1 1183 -#define IDC_COLOR_OB2 1184 -#define IDC_COLOR_OB3 1185 -#define IDC_TRANSLATOR_URL 1186 -#define IDC_STATIC1 1187 -#define IDC_STATIC2 1188 -#define IDC_STATIC3 1189 -#define IDC_STATIC4 1190 -#define IDC_DEFAULT 1191 -#define IDC_USER1 1192 -#define IDC_USER2 1193 -#define IDC_DISASSEMBLE 1196 -#define IDC_AUTOMATIC 1199 -#define IDC_ARM 1200 -#define IDC_THUMB 1201 -#define IDC_AUTO_UPDATE 1204 -#define IDC_N 1210 -#define IDC_Z 1211 -#define IDC_C 1212 -#define IDC_V 1213 -#define IDC_F 1214 -#define IDC_I 1215 -#define IDC_T 1216 -#define IDC_PORT 1217 -#define IDC_VSCROLL 1218 -#define IDC_VERSION 1219 -#define IDC_VERSION2 1220 -#define IDC_DATE 1220 -#define IDC_VERBOSE_SWI 1223 -#define IDC_VERBOSE_UNALIGNED_ACCESS 1224 -#define IDC_VERBOSE_ILLEGAL_WRITE 1225 -#define IDC_VERBOSE_ILLEGAL_READ 1226 -#define IDC_LOG 1227 -#define IDC_CLEAR 1228 -#define IDC_VERBOSE_DMA0 1229 -#define IDC_VERBOSE_DMA1 1230 -#define IDC_TILE_NUMBER 1230 -#define IDC_VERBOSE_DMA2 1231 -#define IDC_XY 1231 -#define IDC_VERBOSE_DMA3 1232 -#define IDC_VERBOSE_UNDEFINED 1233 -#define IDC_TITLE 1234 -#define IDC_VERBOSE_AGBPRINT 1234 -#define IDC_CURRENT_ADDRESS 1235 -#define IDC_VERBOSE_AGBPRINT2 1235 -#define IDC_VERBOSE_SOUNDOUTPUT 1235 -#define IDC_NOTES 1236 -#define IDC_CURRENT_ADDRESS_LABEL 1236 -#define IDC_LOAD 1238 -#define IDC_SIZE_CONTROL 1240 -#define IDC_MODES 1240 -#define IDC_DRIVERS 1241 -#define IDC_THROTTLE 1242 -#define IDC_H 1243 -#define IDC_OAP 1244 -#define IDC_BANK_0 1245 -#define IDC_BANK_1 1246 -#define IDC_TIMER 1247 -#define IDC_INTERVAL 1248 -#define IDC_BIT_0 1250 -#define IDC_BIT_1 1251 -#define IDC_PREDEFINED 1251 -#define IDC_BIT_2 1252 -#define IDC_BIT_3 1253 -#define IDC_BIT_4 1254 -#define IDC_NAME 1254 -#define IDC_BIT_5 1255 -#define IDC_RTC 1255 -#define IDC_BIT_6 1256 -#define IDC_SAVE_TYPE 1256 -#define IDC_BIT_7 1257 -#define IDC_FLASH_SIZE 1257 -#define IDC_BIT_8 1258 -#define IDC_COMMENT 1258 -#define IDC_BIT_9 1259 -#define IDC_BIT_10 1260 -#define IDC_BIT_11 1261 -#define IDC_BIT_12 1262 -#define IDC_BIT_13 1263 -#define IDC_BIT_14 1264 -#define IDC_BIT_15 1265 -#define IDC_MIRRORING 1266 -#define IDC_LY 1267 -#define IDC_APPENDMODE 1268 -#define IDC_DEVICE 1269 -#define IDC_SLIDER_BUFFERCOUNT 1270 -#define IDC_BUFFERINFO 1271 -#define IDC_GB_BIOS_PATH 1272 -#define IDC_GBA_BIOS_PATH 1273 -#define IDC_SKIP_BOOT_LOGO 1274 -#define IDC_ENABLE_GB_BIOS 1275 -#define IDC_ENABLE_GBA_BIOS 1276 -#define IDC_SELECT_GB_BIOS_PATH 1277 -#define IDC_SELECT_GBA_BIOS_PATH 1278 -#define IDC_CLEAR_ALL 1278 -#define IDC_GBC_BIOS_PATH 1279 -#define IDC_COMBO_RESOLUTION 1280 -#define IDC_ENABLE_GBC_BIOS 1280 -#define IDC_COMBO_COLOR_DEPTH 1281 -#define IDC_SELECT_GB_BIOS_PATH2 1281 -#define IDC_SELECT_GBC_BIOS_PATH 1281 -#define IDC_COMBO_REFRESH_RATE 1282 -#define IDC_COMBO_DEVICE 1283 -#define IDC_CHECK1 1284 -#define IDC_CHECK_UPMIX 1284 -#define IDC_ENHANCE_SOUND 1284 -#define IDC_COMBO_DEV 1285 -#define IDC_SOUND_INTERPOLATION 1285 -#define IDC_SLIDER_BUFFER 1286 -#define IDC_INFO_BUFFER 1287 -#define IDC_SURROUND 1288 -#define IDC_ECHO 1289 -#define IDC_STEREO 1290 -#define IDC_SLIDER2 1291 -#define IDC_VOLUME 1291 -#define IDC_DEFAULT_VOLUME 1292 -#define IDC_DECLICKING 1293 -#define IDC_SOUND_FILTERING 1294 -#define IDC_COMBO1 1296 -#define IDC_SAMPLE_RATE 1296 -#define IDC_OAM1 1299 -#define IDC_OAM2 1300 -#define IDC_OAM3 1301 -#define IDC_OAM4 1302 -#define IDC_OAM5 1303 -#define IDC_OAM6 1304 -#define IDC_OAM7 1305 -#define IDC_OAM8 1306 -#define IDC_OAM9 1307 -#define IDC_OAM10 1308 -#define IDC_OAM11 1309 -#define IDC_OAM12 1310 -#define IDC_OAM13 1311 -#define IDC_OAM14 1312 -#define IDC_OAM15 1313 -#define IDC_OAM16 1314 -#define IDC_OAM17 1315 -#define IDC_OAM18 1316 -#define IDC_OAM19 1317 -#define IDC_OAM20 1318 -#define IDC_OAM21 1319 -#define IDC_OAM22 1320 -#define IDC_OAM23 1321 -#define IDC_OAM24 1322 -#define IDC_OAM25 1323 -#define IDC_OAM26 1324 -#define IDC_OAM27 1325 -#define IDC_OAM28 1326 -#define IDC_OAM29 1327 -#define IDC_OAM30 1328 -#define IDC_OAM31 1329 -#define IDC_OAM32 1330 -#define IDC_OAM33 1331 -#define IDC_OAM34 1332 -#define IDC_OAM35 1333 -#define IDC_OAM36 1334 -#define IDC_OAM37 1335 -#define IDC_OAM38 1336 -#define IDC_OAM39 1337 -#define IDC_OAM40 1338 -#define IDC_OAM41 1339 -#define IDC_OAM42 1340 -#define IDC_OAM43 1341 -#define IDC_OAM44 1342 -#define IDC_OAM45 1343 -#define IDC_OAM46 1344 -#define IDC_OAM47 1345 -#define IDC_OAM48 1346 -#define IDC_OAM49 1347 -#define IDC_OAM50 1348 -#define IDC_OAM51 1349 -#define IDC_OAM52 1350 -#define IDC_OAM53 1351 -#define IDC_OAM54 1352 -#define IDC_OAM55 1353 -#define IDC_OAM56 1354 -#define IDC_OAM57 1355 -#define IDC_OAM58 1356 -#define IDC_OAM59 1357 -#define IDC_OAM60 1358 -#define IDC_OAM61 1359 -#define IDC_OAM62 1360 -#define IDC_OAM63 1361 -#define IDC_OAM64 1362 -#define IDC_OAM65 1363 -#define IDC_OAM66 1364 -#define IDC_OAM67 1365 -#define IDC_OAM68 1366 -#define IDC_OAM69 1367 -#define IDC_OAM70 1368 -#define IDC_OAM71 1369 -#define IDC_OAM72 1370 -#define IDC_OAM73 1371 -#define IDC_OAM74 1372 -#define IDC_OAM75 1373 -#define IDC_OAM76 1374 -#define IDC_OAM77 1375 -#define IDC_OAM78 1376 -#define IDC_OAM79 1377 -#define IDC_OAM80 1378 -#define IDC_OAM81 1379 -#define IDC_OAM82 1380 -#define IDC_OAM83 1381 -#define IDC_OAM84 1382 -#define IDC_OAM85 1383 -#define IDC_OAM86 1384 -#define IDC_OAM87 1385 -#define IDC_OAM88 1386 -#define IDC_OAM89 1387 -#define IDC_OAM90 1388 -#define IDC_OAM91 1389 -#define IDC_OAM92 1390 -#define IDC_OAM93 1391 -#define IDC_OAM94 1392 -#define IDC_OAM95 1393 -#define IDC_OAM96 1394 -#define IDC_OAM97 1395 -#define IDC_OAM98 1396 -#define IDC_OAM99 1397 -#define IDC_OAM100 1398 -#define IDC_OAM101 1399 -#define IDC_OAM102 1400 -#define IDC_OAM103 1401 -#define IDC_OAM104 1402 -#define IDC_OAM105 1403 -#define IDC_OAM106 1404 -#define IDC_OAM107 1405 -#define IDC_OAM108 1406 -#define IDC_OAM109 1407 -#define IDC_OAM110 1408 -#define IDC_OAM111 1409 -#define IDC_OAM112 1410 -#define IDC_OAM113 1411 -#define IDC_OAM114 1412 -#define IDC_OAM115 1413 -#define IDC_OAM116 1414 -#define IDC_OAM117 1415 -#define IDC_OAM118 1416 -#define IDC_OAM119 1417 -#define IDC_OAM120 1418 -#define IDC_OAM121 1419 -#define IDC_OAM122 1420 -#define IDC_OAM123 1421 -#define IDC_OAM124 1422 -#define IDC_OAM125 1423 -#define IDC_OAM126 1424 -#define IDC_OAM127 1425 -#define IDC_OAM128 1426 -#define IDC_OAMSCREEN 1427 -#define IDC_OAMATTRIBUTELIST 1428 -#define IDC_OAMPREVIEW 1429 -#define IDC_LINK_MODE 1430 -#define IDC_LINK_WITH 1431 -#define IDC_STATIC_TIMEOUT 1432 -#define IDC_LINK_SERVER 1433 -#define IDC_LINK_CLIENT 1434 -#define IDC_GROUP_NETWORK 1435 -#define IDC_LINK_ROLE 1436 +#define IDC_GE 1036 +#define IDS_CANNOT_PLAY_PRIMARY 1036 +#define IDC_SIGNED 1037 +#define IDS_SEARCH_PRODUCED_TOO_MANY 1037 +#define IDC_UNSIGNED 1038 +#define IDS_NUMBER_CANNOT_BE_EMPTY 1038 +#define IDS_INVALID_ADDRESS 1039 +#define IDC_HEXADECIMAL 1040 +#define IDS_MISALIGNED_HALFWORD 1040 +#define IDC_VALUE 1041 +#define IDS_MISALIGNED_WORD 1041 +#define IDC_ADDRESS 1042 +#define IDS_VALUE_CANNOT_BE_EMPTY 1042 +#define IDS_ERROR_ON_STARTDOC 1043 +#define IDC_R 1043 +#define IDS_ERROR_ON_STARTPAGE 1044 +#define IDC_G 1044 +#define IDS_ERROR_PRINTING_ON_STRETCH 1045 +#define IDC_B 1045 +#define IDC_UPDATE 1046 +#define IDS_ERROR_ON_ENDPAGE 1046 +#define IDC_TILE_NUM 1046 +#define IDC_GGDESC 1047 +#define IDS_ERROR_ON_ENDDOC 1047 +#define IDC_FLIP 1047 +#define IDC_GGCODE 1048 +#define IDS_ERROR 1048 +#define IDC_PALETTE_NUM 1048 +#define IDC_GGADD 1049 +#define IDS_JOY_LEFT 1049 +#define IDC_GGDEL 1050 +#define IDS_JOY_RIGHT 1050 +#define IDC_GGLIST 1051 +#define IDS_JOY_UP 1051 +#define IDC_GGRES 1052 +#define IDS_JOY_DOWN 1052 +#define IDC_GGQUIT 1053 +#define IDS_JOY_BUTTON 1053 +#define IDC_GSDESC 1054 +#define IDS_SELECT_ROM_DIR 1054 +#define IDC_GSCODE 1055 +#define IDS_SELECT_BATTERY_DIR 1055 +#define IDC_GSADD 1056 +#define IDS_SELECT_SAVE_DIR 1056 +#define IDC_GSDEL 1057 +#define IDS_SELECT_CAPTURE_DIR 1057 +#define IDC_GSLIST 1058 +#define IDS_SELECT_BIOS_FILE 1058 +#define IDC_GSRES 1059 +#define IDS_RESET 1059 +#define IDC_GSQUIT 1060 +#define IDS_AUTOFIRE_A_DISABLED 1060 +#define IDC_FREEZE 1061 +#define IDS_AUTOFIRE_A 1061 +#define IDS_AUTOFIRE_B_DISABLED 1062 +#define IDS_AUTOFIRE_B 1063 +#define IDS_AUTOFIRE_L_DISABLED 1064 +#define IDS_AUTOFIRE_L 1065 +#define IDS_AUTOFIRE_R_DISABLED 1066 +#define IDC_REMOVE 1067 +#define IDS_AUTOFIRE_R 1067 +#define IDC_REMOVE_ALL 1068 +#define IDS_SELECT_ROM 1068 +#define IDS_SELECT_SAVE_GAME_NAME 1069 +#define IDC_ENABLE 1070 +#define IDS_LOADED_STATE 1070 +#define IDS_LOADED_STATE_N 1071 +#define IDS_WROTE_STATE 1072 +#define IDS_WROTE_STATE_N 1073 +#define IDC_RESTORE 1074 +#define IDS_LOADED_BATTERY 1074 +#define IDC_GBA 1075 +#define IDS_SELECT_CAPTURE_NAME 1075 +#define IDC_AGB 1076 +#define IDS_SCREEN_CAPTURE 1076 +#define IDC_BIN 1077 +#define IDS_ADDRESS 1077 +#define IDC_GB 1078 +#define IDS_OLD_VALUE 1078 +#define IDC_SGB 1079 +#define IDC_ROM_TITLE 1079 +#define IDS_NEW_VALUE 1079 +#define IDC_CGB 1080 +#define IDC_ROM_GAME_CODE 1080 +#define IDS_ADD_CHEAT_CODE 1080 +#define IDC_GBC 1081 +#define IDC_ROM_MAKER_CODE 1081 +#define IDS_CODE 1081 +#define IDC_DMG 1082 +#define IDC_ROM_UNIT_CODE 1082 +#define IDS_DESCRIPTION 1082 +#define IDC_ROM_DEVICE_TYPE 1083 +#define IDS_STATUS 1083 +#define IDC_ROM_VERSION 1084 +#define IDS_ADD_GG_CODE 1084 +#define IDC_ROM_CRC 1085 +#define IDS_ADD_GS_CODE 1085 +#define IDC_ROM_COLOR 1086 +#define IDC_CODE 1086 +#define IDS_POCKET_PRINTER 1086 +#define IDC_ROM_MAKER_NAME 1086 +#define IDC_ROM_SIZE 1087 +#define IDC_DESC 1087 +#define IDS_UNKNOWN 1087 +#define IDC_ROM_RAM_SIZE 1088 +#define IDC_ADD_GG_CHEAT 1088 +#define IDS_NONE 1088 +#define IDC_ROM_DEST_CODE 1089 +#define IDC_GB_PRINTER 1089 +#define IDS_FAILED_TO_LOAD_LIBRARY 1089 +#define IDC_ROM_LIC_CODE 1090 +#define IDC_1X 1090 +#define IDS_FAILED_TO_GET_LOCINFO 1090 +#define IDC_ROM_CHECKSUM 1091 +#define IDC_2X 1091 +#define IDS_SELECT_CHEAT_LIST_NAME 1091 +#define IDC_3X 1092 +#define IDS_FILTER_BIOS 1092 +#define IDC_4X 1093 +#define IDS_FILTER_GBAROM 1093 +#define IDC_ROM_MAKER_NAME2 1093 +#define ID_PRINT 1094 +#define IDS_FILTER_SGM 1094 +#define IDC_ADD_GSA 1095 +#define IDC_ADD_CODE 1095 +#define IDS_FILTER_CHEAT_LIST 1095 +#define IDC_TRANSLATION_BY 1096 +#define IDS_FILTER_PNG 1096 +#define IDC_LANG_STRING 1097 +#define IDS_LOADED_CHEATS 1097 +#define IDC_LANG_NAME 1098 +#define IDS_ERROR_DISP_COLOR 1098 +#define IDS_ADD_GSA_CODE 1099 +#define IDC_GAME_LIST 1099 +#define IDS_FILTER_SPS 1100 +#define IDS_SELECT_SNAPSHOT_FILE 1101 +#define IDC_ADD_CODEBREAKER 1101 +#define IDS_FILTER_SAV 1102 +#define IDS_SELECT_BATTERY_FILE 1103 +#define IDS_FILTER_GBS 1104 +#define IDS_FILTER_GCF 1105 +#define IDS_SELECT_CODE_FILE 1106 +#define IDS_SAVE_WILL_BE_LOST 1107 +#define IDS_CONFIRM_ACTION 1108 +#define IDS_CODES_WILL_BE_LOST 1109 +#define IDS_FILTER_SPC 1110 +#define IDS_ADD_CBA_CODE 1111 +#define IDS_FILTER_WAV 1112 +#define IDS_SELECT_WAV_NAME 1113 +#define IDC_FRAME_0 1113 +#define IDS_FILTER_GBROM 1114 +#define IDC_FRAME_1 1114 +#define IDC_BG0 1115 +#define IDS_FILTER_PAL 1115 +#define IDC_BG1 1116 +#define IDS_SELECT_PALETTE_NAME 1116 +#define IDC_BG2 1117 +#define IDS_SEARCH_PRODUCED_NO_RESULTS 1117 +#define IDC_BG3 1118 +#define IDS_ERROR_BINDING 1118 +#define IDS_ERROR_LISTENING 1119 +#define IDS_ERROR_CREATING_SOCKET 1120 +#define IDS_ACK_NOT_RECEIVED 1121 +#define IDS_ERROR_NOT_GBA_IMAGE 1122 +#define IDS_EEPROM_NOT_SUPPORTED 1123 +#define IDC_MAP_VIEW 1124 +#define IDS_FILTER_DUMP 1124 +#define IDC_PALETTE_VIEW 1125 +#define IDS_SELECT_DUMP_FILE 1125 +#define IDC_PALETTE_VIEW_OBJ 1126 +#define IDC_REFRESH 1126 +#define IDS_FILTER_AVI 1126 +#define IDC_SAVE 1127 +#define IDC_GOPC 1127 +#define IDS_SELECT_AVI_NAME 1127 +#define IDC_APPLY 1127 +#define IDS_INVALID_THROTTLE_VALUE 1128 +#define IDC_REFRESH2 1129 +#define IDS_FILTER_INI 1129 +#define IDS_SELECT_SKIN_FILE 1130 +#define IDC_CLOSE 1131 +#define IDS_FILTER_VMV 1131 +#define IDS_SELECT_MOVIE_NAME 1132 +#define IDS_BUG_REPORT 1133 +#define IDS_UNSUPPORTED_MOVIE_VERSION 1134 +#define IDS_END_OF_MOVIE 1135 +#define IDC_COLOR 1136 +#define IDS_INVALID_INTERVAL_VALUE 1136 +#define IDC_SAVE_BG 1137 +#define IDS_REGISTRY 1137 +#define IDC_SAVE_OBJ 1138 +#define IDC_MAP_VIEW_ZOOM 1138 +#define IDS_MOVIE_PLAY 1138 +#define IDS_FILTER_GSVSPS 1139 +#define IDC_VIEWER 1140 +#define IDC_CHANGE_BACKDROP 1140 +#define IDC_ADDRESSES 1141 +#define IDC_GO 1143 +#define IDC_8_BIT 1144 +#define IDC_16_BIT 1145 +#define IDC_32_BIT 1146 +#define IDC_OAM_VIEW 1147 +#define IDC_OAM_VIEW_ZOOM 1148 +#define IDC_SPRITE 1150 +#define IDC_POS 1151 +#define IDC_MODE 1152 +#define IDC_COLORS 1153 +#define IDC_MAPBASE 1153 +#define IDC_PALETTE 1154 +#define IDC_CHARBASE 1154 +#define IDC_TILE 1155 +#define IDC_DIM 1155 +#define IDC_PRIO 1156 +#define IDC_NUMCOLORS 1156 +#define IDC_SCROLLBAR 1157 +#define IDC_PRIORITY 1157 +#define IDC_MOSAIC 1158 +#define IDC_SIZE2 1159 +#define IDC_OVERFLOW 1159 +#define IDC_ROT 1160 +#define IDC_FLAGS 1161 +#define IDC_COMMANDS 1162 +#define IDC_BANK 1162 +#define IDC_CURRENTS 1163 +#define IDC_ASSIGN 1164 +#define IDC_RESET 1165 +#define IDC_EDIT_KEY 1166 +#define IDC_ALREADY_AFFECTED 1167 +#define IDC_TILE_VIEW 1168 +#define IDC_16_COLORS 1169 +#define IDC_256_COLORS 1170 +#define IDC_CHARBASE_0 1173 +#define IDC_CHARBASE_1 1174 +#define IDC_CHARBASE_2 1175 +#define IDC_CHARBASE_3 1176 +#define IDC_PALETTE_SLIDER 1177 +#define IDC_CHARBASE_4 1178 +#define IDC_COLOR_BG0 1178 +#define IDC_COLOR_BG1 1179 +#define IDC_URL 1179 +#define IDC_COLOR_BG2 1180 +#define IDC_STRETCH 1180 +#define IDC_COLOR_BG3 1181 +#define IDC_COLOR_OB0 1182 +#define IDC_COLOR_OB1 1183 +#define IDC_COLOR_OB2 1184 +#define IDC_COLOR_OB3 1185 +#define IDC_TRANSLATOR_URL 1186 +#define IDC_STATIC1 1187 +#define IDC_STATIC2 1188 +#define IDC_STATIC3 1189 +#define IDC_STATIC4 1190 +#define IDC_DEFAULT 1191 +#define IDC_USER1 1192 +#define IDC_USER2 1193 +#define IDC_DISASSEMBLE 1196 +#define IDC_AUTOMATIC 1199 +#define IDC_ARM 1200 +#define IDC_THUMB 1201 +#define IDC_AUTO_UPDATE 1204 +#define IDC_N 1210 +#define IDC_Z 1211 +#define IDC_C 1212 +#define IDC_V 1213 +#define IDC_F 1214 +#define IDC_I 1215 +#define IDC_T 1216 +#define IDC_PORT 1217 +#define IDC_VSCROLL 1218 +#define IDC_VERSION 1219 +#define IDC_VERSION2 1220 +#define IDC_DATE 1220 +#define IDC_VERBOSE_SWI 1223 +#define IDC_VERBOSE_UNALIGNED_ACCESS 1224 +#define IDC_VERBOSE_ILLEGAL_WRITE 1225 +#define IDC_VERBOSE_ILLEGAL_READ 1226 +#define IDC_LOG 1227 +#define IDC_CLEAR 1228 +#define IDC_VERBOSE_DMA0 1229 +#define IDC_VERBOSE_DMA1 1230 +#define IDC_TILE_NUMBER 1230 +#define IDC_VERBOSE_DMA2 1231 +#define IDC_XY 1231 +#define IDC_VERBOSE_DMA3 1232 +#define IDC_VERBOSE_UNDEFINED 1233 +#define IDC_TITLE 1234 +#define IDC_VERBOSE_AGBPRINT 1234 +#define IDC_CURRENT_ADDRESS 1235 +#define IDC_VERBOSE_AGBPRINT2 1235 +#define IDC_VERBOSE_SOUNDOUTPUT 1235 +#define IDC_NOTES 1236 +#define IDC_CURRENT_ADDRESS_LABEL 1236 +#define IDC_LOAD 1238 +#define IDC_SIZE_CONTROL 1240 +#define IDC_MODES 1240 +#define IDC_DRIVERS 1241 +#define IDC_THROTTLE 1242 +#define IDC_H 1243 +#define IDC_OAP 1244 +#define IDC_BANK_0 1245 +#define IDC_BANK_1 1246 +#define IDC_TIMER 1247 +#define IDC_INTERVAL 1248 +#define IDC_BIT_0 1250 +#define IDC_BIT_1 1251 +#define IDC_PREDEFINED 1251 +#define IDC_BIT_2 1252 +#define IDC_BIT_3 1253 +#define IDC_BIT_4 1254 +#define IDC_NAME 1254 +#define IDC_BIT_5 1255 +#define IDC_RTC 1255 +#define IDC_BIT_6 1256 +#define IDC_SAVE_TYPE 1256 +#define IDC_BIT_7 1257 +#define IDC_FLASH_SIZE 1257 +#define IDC_BIT_8 1258 +#define IDC_COMMENT 1258 +#define IDC_BIT_9 1259 +#define IDC_BIT_10 1260 +#define IDC_BIT_11 1261 +#define IDC_BIT_12 1262 +#define IDC_BIT_13 1263 +#define IDC_BIT_14 1264 +#define IDC_BIT_15 1265 +#define IDC_MIRRORING 1266 +#define IDC_LY 1267 +#define IDC_APPENDMODE 1268 +#define IDC_DEVICE 1269 +#define IDC_SLIDER_BUFFERCOUNT 1270 +#define IDC_BUFFERINFO 1271 +#define IDC_GB_BIOS_PATH 1272 +#define IDC_GBA_BIOS_PATH 1273 +#define IDC_SKIP_BOOT_LOGO 1274 +#define IDC_ENABLE_GB_BIOS 1275 +#define IDC_ENABLE_GBA_BIOS 1276 +#define IDC_SELECT_GB_BIOS_PATH 1277 +#define IDC_SELECT_GBA_BIOS_PATH 1278 +#define IDC_CLEAR_ALL 1278 +#define IDC_GBC_BIOS_PATH 1279 +#define IDC_COMBO_RESOLUTION 1280 +#define IDC_ENABLE_GBC_BIOS 1280 +#define IDC_COMBO_COLOR_DEPTH 1281 +#define IDC_SELECT_GB_BIOS_PATH2 1281 +#define IDC_SELECT_GBC_BIOS_PATH 1281 +#define IDC_COMBO_REFRESH_RATE 1282 +#define IDC_COMBO_DEVICE 1283 +#define IDC_CHECK1 1284 +#define IDC_CHECK_UPMIX 1284 +#define IDC_ENHANCE_SOUND 1284 +#define IDC_COMBO_DEV 1285 +#define IDC_SOUND_INTERPOLATION 1285 +#define IDC_SLIDER_BUFFER 1286 +#define IDC_INFO_BUFFER 1287 +#define IDC_SURROUND 1288 +#define IDC_ECHO 1289 +#define IDC_STEREO 1290 +#define IDC_SLIDER2 1291 +#define IDC_VOLUME 1291 +#define IDC_DEFAULT_VOLUME 1292 +#define IDC_DECLICKING 1293 +#define IDC_SOUND_FILTERING 1294 +#define IDC_COMBO1 1296 +#define IDC_SAMPLE_RATE 1296 +#define IDC_OAM1 1299 +#define IDC_OAM2 1300 +#define IDC_OAM3 1301 +#define IDC_OAM4 1302 +#define IDC_OAM5 1303 +#define IDC_OAM6 1304 +#define IDC_OAM7 1305 +#define IDC_OAM8 1306 +#define IDC_OAM9 1307 +#define IDC_OAM10 1308 +#define IDC_OAM11 1309 +#define IDC_OAM12 1310 +#define IDC_OAM13 1311 +#define IDC_OAM14 1312 +#define IDC_OAM15 1313 +#define IDC_OAM16 1314 +#define IDC_OAM17 1315 +#define IDC_OAM18 1316 +#define IDC_OAM19 1317 +#define IDC_OAM20 1318 +#define IDC_OAM21 1319 +#define IDC_OAM22 1320 +#define IDC_OAM23 1321 +#define IDC_OAM24 1322 +#define IDC_OAM25 1323 +#define IDC_OAM26 1324 +#define IDC_OAM27 1325 +#define IDC_OAM28 1326 +#define IDC_OAM29 1327 +#define IDC_OAM30 1328 +#define IDC_OAM31 1329 +#define IDC_OAM32 1330 +#define IDC_OAM33 1331 +#define IDC_OAM34 1332 +#define IDC_OAM35 1333 +#define IDC_OAM36 1334 +#define IDC_OAM37 1335 +#define IDC_OAM38 1336 +#define IDC_OAM39 1337 +#define IDC_OAM40 1338 +#define IDC_OAM41 1339 +#define IDC_OAM42 1340 +#define IDC_OAM43 1341 +#define IDC_OAM44 1342 +#define IDC_OAM45 1343 +#define IDC_OAM46 1344 +#define IDC_OAM47 1345 +#define IDC_OAM48 1346 +#define IDC_OAM49 1347 +#define IDC_OAM50 1348 +#define IDC_OAM51 1349 +#define IDC_OAM52 1350 +#define IDC_OAM53 1351 +#define IDC_OAM54 1352 +#define IDC_OAM55 1353 +#define IDC_OAM56 1354 +#define IDC_OAM57 1355 +#define IDC_OAM58 1356 +#define IDC_OAM59 1357 +#define IDC_OAM60 1358 +#define IDC_OAM61 1359 +#define IDC_OAM62 1360 +#define IDC_OAM63 1361 +#define IDC_OAM64 1362 +#define IDC_OAM65 1363 +#define IDC_OAM66 1364 +#define IDC_OAM67 1365 +#define IDC_OAM68 1366 +#define IDC_OAM69 1367 +#define IDC_OAM70 1368 +#define IDC_OAM71 1369 +#define IDC_OAM72 1370 +#define IDC_OAM73 1371 +#define IDC_OAM74 1372 +#define IDC_OAM75 1373 +#define IDC_OAM76 1374 +#define IDC_OAM77 1375 +#define IDC_OAM78 1376 +#define IDC_OAM79 1377 +#define IDC_OAM80 1378 +#define IDC_OAM81 1379 +#define IDC_OAM82 1380 +#define IDC_OAM83 1381 +#define IDC_OAM84 1382 +#define IDC_OAM85 1383 +#define IDC_OAM86 1384 +#define IDC_OAM87 1385 +#define IDC_OAM88 1386 +#define IDC_OAM89 1387 +#define IDC_OAM90 1388 +#define IDC_OAM91 1389 +#define IDC_OAM92 1390 +#define IDC_OAM93 1391 +#define IDC_OAM94 1392 +#define IDC_OAM95 1393 +#define IDC_OAM96 1394 +#define IDC_OAM97 1395 +#define IDC_OAM98 1396 +#define IDC_OAM99 1397 +#define IDC_OAM100 1398 +#define IDC_OAM101 1399 +#define IDC_OAM102 1400 +#define IDC_OAM103 1401 +#define IDC_OAM104 1402 +#define IDC_OAM105 1403 +#define IDC_OAM106 1404 +#define IDC_OAM107 1405 +#define IDC_OAM108 1406 +#define IDC_OAM109 1407 +#define IDC_OAM110 1408 +#define IDC_OAM111 1409 +#define IDC_OAM112 1410 +#define IDC_OAM113 1411 +#define IDC_OAM114 1412 +#define IDC_OAM115 1413 +#define IDC_OAM116 1414 +#define IDC_OAM117 1415 +#define IDC_OAM118 1416 +#define IDC_OAM119 1417 +#define IDC_OAM120 1418 +#define IDC_OAM121 1419 +#define IDC_OAM122 1420 +#define IDC_OAM123 1421 +#define IDC_OAM124 1422 +#define IDC_OAM125 1423 +#define IDC_OAM126 1424 +#define IDC_OAM127 1425 +#define IDC_OAM128 1426 +#define IDC_OAMSCREEN 1427 +#define IDC_OAMATTRIBUTELIST 1428 +#define IDC_OAMPREVIEW 1429 +#define IDC_LINK_MODE 1430 +#define IDC_LINK_WITH 1431 +#define IDC_STATIC_TIMEOUT 1432 +#define IDC_LINK_SERVER 1433 +#define IDC_LINK_CLIENT 1434 +#define IDC_GROUP_NETWORK 1435 +#define IDC_LINK_ROLE 1436 -#define IDS_OAL_NODEVICE 2000 -#define IDS_OAL_NODLL 2001 -#define IDS_AVI_CANNOT_CREATE_AVI 2002 -#define IDS_AVI_CANNOT_CREATE_VIDEO 2003 -#define IDS_AVI_CANNOT_CREATE_AUDIO 2004 -#define IDS_AVI_CANNOT_WRITE_VIDEO 2005 -#define IDS_AVI_CANNOT_WRITE_AUDIO 2006 -#define IDS_FILTER_GBCROM 2007 -#define IDS_COM_FAILURE 2008 -#define IDS_XAUDIO2_FAILURE 2009 +#define IDS_OAL_NODEVICE 2000 +#define IDS_OAL_NODLL 2001 +#define IDS_AVI_CANNOT_CREATE_AVI 2002 +#define IDS_AVI_CANNOT_CREATE_VIDEO 2003 +#define IDS_AVI_CANNOT_CREATE_AUDIO 2004 +#define IDS_AVI_CANNOT_WRITE_VIDEO 2005 +#define IDS_AVI_CANNOT_WRITE_AUDIO 2006 +#define IDS_FILTER_GBCROM 2007 +#define IDS_COM_FAILURE 2008 +#define IDS_XAUDIO2_FAILURE 2009 #define IDS_XAUDIO2_CANNOT_CREATE_MASTERINGVOICE 2010 #define IDS_XAUDIO2_CANNOT_CREATE_SOURCEVOICE 2011 #define IDS_XAUDIO2_CANNOT_ENUMERATE_DEVICES 2012 -#define IDS_CHEATS_DISABLED 2013 -#define IDS_CHEATS_ENABLED 2014 -#define ID_HELP_ABOUT 40001 -#define ID_FILE_EXIT 40002 -#define ID_OPTIONS_VIDEO_FRAMESKIP_0 40003 -#define ID_OPTIONS_VIDEO_FRAMESKIP_1 40004 -#define ID_OPTIONS_VIDEO_FRAMESKIP_2 40005 -#define ID_OPTIONS_VIDEO_FRAMESKIP_3 40006 -#define ID_OPTIONS_VIDEO_FRAMESKIP_4 40007 -#define ID_OPTIONS_VIDEO_FRAMESKIP_5 40008 -#define ID_OPTIONS_VIDEO_VSYNC 40009 -#define ID_OPTIONS_VIDEO_X1 40010 -#define ID_OPTIONS_VIDEO_X2 40011 -#define ID_OPTIONS_VIDEO_X3 40012 -#define ID_OPTIONS_VIDEO_X4 40013 -#define ID_OPTIONS_VIDEO_X5 40014 -#define ID_OPTIONS_VIDEO_X6 40015 -#define ID_OPTIONS_JOYPAD 40016 -#define ID_FILE_RESET 40018 -#define ID_FILE_LOAD 40019 -#define ID_OPTIONS_SOUND_DIRECTSOUNDA 40020 -#define ID_OPTIONS_SOUND_DIRECTSOUNDB 40021 -#define ID_OPTIONS_SOUND_CHANNEL1 40025 -#define ID_OPTIONS_SOUND_CHANNEL2 40026 -#define ID_OPTIONS_SOUND_CHANNEL3 40027 -#define ID_OPTIONS_SOUND_CHANNEL4 40028 +#define IDS_CHEATS_DISABLED 2013 +#define IDS_CHEATS_ENABLED 2014 +#define ID_HELP_ABOUT 40001 +#define ID_FILE_EXIT 40002 +#define ID_OPTIONS_VIDEO_FRAMESKIP_0 40003 +#define ID_OPTIONS_VIDEO_FRAMESKIP_1 40004 +#define ID_OPTIONS_VIDEO_FRAMESKIP_2 40005 +#define ID_OPTIONS_VIDEO_FRAMESKIP_3 40006 +#define ID_OPTIONS_VIDEO_FRAMESKIP_4 40007 +#define ID_OPTIONS_VIDEO_FRAMESKIP_5 40008 +#define ID_OPTIONS_VIDEO_VSYNC 40009 +#define ID_OPTIONS_VIDEO_X1 40010 +#define ID_OPTIONS_VIDEO_X2 40011 +#define ID_OPTIONS_VIDEO_X3 40012 +#define ID_OPTIONS_VIDEO_X4 40013 +#define ID_OPTIONS_VIDEO_X5 40014 +#define ID_OPTIONS_VIDEO_X6 40015 +#define ID_OPTIONS_JOYPAD 40016 +#define ID_FILE_RESET 40018 +#define ID_FILE_LOAD 40019 +#define ID_OPTIONS_SOUND_DIRECTSOUNDA 40020 +#define ID_OPTIONS_SOUND_DIRECTSOUNDB 40021 +#define ID_OPTIONS_SOUND_CHANNEL1 40025 +#define ID_OPTIONS_SOUND_CHANNEL2 40026 +#define ID_OPTIONS_SOUND_CHANNEL3 40027 +#define ID_OPTIONS_SOUND_CHANNEL4 40028 #define ID_OPTIONS_EMULATOR_USEBIOSFILE 40029 #define ID_OPTIONS_EMULATOR_SELECTBIOSFILE 40030 -#define ID_CHEATS_SEARCHFORCHEATS 40031 -#define ID_CHEATS_ADDCHEAT 40032 -#define ID_OPTIONS_VIDEO_DISABLESFX 40033 -#define ID_OPTIONS_GAMEBOY_BORDER 40034 -#define ID_FILE_SAVEGAME_SLOT1 40035 -#define ID_FILE_SAVEGAME_SLOT2 40036 -#define ID_FILE_SAVEGAME_SLOT3 40037 -#define ID_FILE_SAVEGAME_SLOT4 40038 -#define ID_FILE_SAVEGAME_SLOT5 40039 -#define ID_FILE_SAVEGAME_SLOT6 40040 -#define ID_FILE_SAVEGAME_SLOT7 40041 -#define ID_FILE_SAVEGAME_SLOT8 40042 -#define ID_FILE_SAVEGAME_SLOT9 40043 -#define ID_FILE_SAVEGAME_SLOT10 40044 -#define ID_FILE_LOADGAME_SLOT1 40045 -#define ID_FILE_LOADGAME_SLOT2 40046 -#define ID_FILE_LOADGAME_SLOT3 40047 -#define ID_FILE_LOADGAME_SLOT4 40048 -#define ID_FILE_LOADGAME_SLOT5 40049 -#define ID_FILE_LOADGAME_SLOT6 40050 -#define ID_FILE_LOADGAME_SLOT7 40051 -#define ID_FILE_LOADGAME_SLOT8 40052 -#define ID_FILE_LOADGAME_SLOT9 40053 -#define ID_FILE_LOADGAME_SLOT10 40054 -#define ID_OPTIONS_GAMEBOY_AUTOMATIC 40057 -#define ID_OPTIONS_GAMEBOY_CGB 40058 -#define ID_OPTIONS_GAMEBOY_GBA 40059 -#define ID_OPTIONS_GAMEBOY_SGB 40060 -#define ID_OPTIONS_GAMEBOY_GB 40062 -#define ID_OPTIONS_GAMEBOY_REALCOLORS 40063 +#define ID_CHEATS_SEARCHFORCHEATS 40031 +#define ID_CHEATS_ADDCHEAT 40032 +#define ID_OPTIONS_VIDEO_DISABLESFX 40033 +#define ID_OPTIONS_GAMEBOY_BORDER 40034 +#define ID_FILE_SAVEGAME_SLOT1 40035 +#define ID_FILE_SAVEGAME_SLOT2 40036 +#define ID_FILE_SAVEGAME_SLOT3 40037 +#define ID_FILE_SAVEGAME_SLOT4 40038 +#define ID_FILE_SAVEGAME_SLOT5 40039 +#define ID_FILE_SAVEGAME_SLOT6 40040 +#define ID_FILE_SAVEGAME_SLOT7 40041 +#define ID_FILE_SAVEGAME_SLOT8 40042 +#define ID_FILE_SAVEGAME_SLOT9 40043 +#define ID_FILE_SAVEGAME_SLOT10 40044 +#define ID_FILE_LOADGAME_SLOT1 40045 +#define ID_FILE_LOADGAME_SLOT2 40046 +#define ID_FILE_LOADGAME_SLOT3 40047 +#define ID_FILE_LOADGAME_SLOT4 40048 +#define ID_FILE_LOADGAME_SLOT5 40049 +#define ID_FILE_LOADGAME_SLOT6 40050 +#define ID_FILE_LOADGAME_SLOT7 40051 +#define ID_FILE_LOADGAME_SLOT8 40052 +#define ID_FILE_LOADGAME_SLOT9 40053 +#define ID_FILE_LOADGAME_SLOT10 40054 +#define ID_OPTIONS_GAMEBOY_AUTOMATIC 40057 +#define ID_OPTIONS_GAMEBOY_CGB 40058 +#define ID_OPTIONS_GAMEBOY_GBA 40059 +#define ID_OPTIONS_GAMEBOY_SGB 40060 +#define ID_OPTIONS_GAMEBOY_GB 40062 +#define ID_OPTIONS_GAMEBOY_REALCOLORS 40063 #define ID_OPTIONS_GAMEBOY_GAMEBOYCOLORS 40064 -#define ID_CHEATS_GAMEBOY 40065 -#define ID_OPTIONS_SOUND_11KHZ 40067 -#define ID_OPTIONS_SOUND_22KHZ 40068 -#define ID_OPTIONS_SOUND_44KHZ 40069 +#define ID_CHEATS_GAMEBOY 40065 +#define ID_OPTIONS_SOUND_11KHZ 40067 +#define ID_OPTIONS_SOUND_22KHZ 40068 +#define ID_OPTIONS_SOUND_44KHZ 40069 #define ID_OPTIONS_VIDEO_DDRAWEMULATIONONLY 40070 #define ID_OPTIONS_VIDEO_DDRAWUSEVIDEOMEMORY 40071 -#define ID_OPTIONS_PRIORITY_HIGHEST 40072 +#define ID_OPTIONS_PRIORITY_HIGHEST 40072 #define ID_OPTIONS_PRIORITY_ABOVENORMAL 40073 -#define ID_OPTIONS_PRIORITY_NORMAL 40074 +#define ID_OPTIONS_PRIORITY_NORMAL 40074 #define ID_OPTIONS_PRIORITY_BELOWNORMAL 40075 #define ID_OPTIONS_VIDEO_FULLSCREEN320X240 40076 #define ID_OPTIONS_VIDEO_FULLSCREEN640X480 40077 -#define ID_OPTIONS_FILTER_NORMAL 40078 -#define ID_OPTIONS_FILTER_2XSAI 40079 -#define ID_OPTIONS_FILTER_SUPER2XSAI 40081 -#define ID_OPTIONS_FILTER_SUPEREAGLE 40082 -#define ID_OPTIONS_FILTER_TVMODE 40083 -#define ID_CHEATS_CHEATLIST 40084 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_A 40085 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_B 40086 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_L 40087 -#define ID_OPTIONS_JOYPAD_AUTOFIRE_R 40088 +#define ID_OPTIONS_FILTER_NORMAL 40078 +#define ID_OPTIONS_FILTER_2XSAI 40079 +#define ID_OPTIONS_FILTER_SUPER2XSAI 40081 +#define ID_OPTIONS_FILTER_SUPEREAGLE 40082 +#define ID_OPTIONS_FILTER_TVMODE 40083 +#define ID_CHEATS_CHEATLIST 40084 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_A 40085 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_B 40086 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_L 40087 +#define ID_OPTIONS_JOYPAD_AUTOFIRE_R 40088 #define ID_OPTIONS_VIDEO_FULLSCREENSTRETCHTOFIT 40089 -#define ID_OPTIONS_EMULATOR_ASSOCIATE 40091 -#define ID_OPTIONS_FILTER_DISABLEMMX 40093 -#define ID_FILE_ROMINFORMATION 40100 -#define ID_CHEATS_ADDCHEATCODE 40101 +#define ID_OPTIONS_EMULATOR_ASSOCIATE 40091 +#define ID_OPTIONS_FILTER_DISABLEMMX 40093 +#define ID_FILE_ROMINFORMATION 40100 +#define ID_CHEATS_ADDCHEATCODE 40101 #define ID_OPTIONS_EMULATOR_DISABLESTATUSMESSAGES 40102 #define ID_OPTIONS_JOYPAD_MOTIONCONFIGURE 40103 -#define ID_FILE_SCREENCAPTURE 40104 -#define ID_OPTIONS_LANGUAGE_SYSTEM 40105 -#define ID_OPTIONS_LANGUAGE_ENGLISH 40106 -#define ID_OPTIONS_LANGUAGE_OTHER 40107 -#define ID_OPTIONS_GAMEBOY_PRINTER 40108 -#define ID_FILE_RECENT_RESET 40109 -#define ID_CHEATS_SAVECHEATLIST 40110 -#define ID_CHEATS_LOADCHEATLIST 40111 +#define ID_FILE_SCREENCAPTURE 40104 +#define ID_OPTIONS_LANGUAGE_SYSTEM 40105 +#define ID_OPTIONS_LANGUAGE_ENGLISH 40106 +#define ID_OPTIONS_LANGUAGE_OTHER 40107 +#define ID_OPTIONS_GAMEBOY_PRINTER 40108 +#define ID_FILE_RECENT_RESET 40109 +#define ID_CHEATS_SAVECHEATLIST 40110 +#define ID_CHEATS_LOADCHEATLIST 40111 #define ID_CHEATS_AUTOMATICSAVELOADCHEATS 40112 #define ID_FILE_IMPORT_GAMESHARKSNAPSHOT 40115 -#define ID_FILE_IMPORT_BATTERYFILE 40116 +#define ID_FILE_IMPORT_BATTERYFILE 40116 #define ID_FILE_IMPORT_GAMESHARKCODEFILE 40117 -#define ID_FILE_EXPORT_BATTERYFILE 40118 +#define ID_FILE_EXPORT_BATTERYFILE 40118 #define ID_OPTIONS_FILTER16BIT_PIXELATEEXPERIMENTAL 40121 #define ID_OPTIONS_FILTER16BIT_MOTIONBLUREXPERIMENTAL 40122 #define ID_OPTIONS_EMULATOR_PAUSEWHENINACTIVE 40124 #define ID_OPTIONS_SOUND_STARTRECORDING 40125 -#define ID_OPTIONS_SOUND_STOPRECORDING 40126 -#define ID_OPTIONS_VIDEO_LAYERS_BG0 40127 -#define ID_OPTIONS_VIDEO_LAYERS_BG1 40128 -#define ID_OPTIONS_VIDEO_LAYERS_BG2 40129 -#define ID_OPTIONS_VIDEO_LAYERS_BG3 40130 -#define ID_OPTIONS_VIDEO_LAYERS_OBJ 40131 -#define ID_OPTIONS_VIDEO_LAYERS_WIN0 40132 -#define ID_OPTIONS_VIDEO_LAYERS_WIN1 40133 -#define ID_OPTIONS_VIDEO_LAYERS_OBJWIN 40134 -#define ID_FILE_OPEN_GB 40135 -#define ID_DEBUG_NEXTFRAME 40137 -#define ID_TOOLS_MAPVIEW 40138 -#define ID_TOOLS_PALETTEVIEW 40139 -#define ID_OPTIONS_EMULATOR_PNGFORMAT 40140 -#define ID_OPTIONS_EMULATOR_BMPFORMAT 40141 -#define ID_TOOLS_MEMORYVIEWER 40143 -#define ID_TOOLS_OAMVIEWER 40144 -#define ID_TOOLS_CUSTOMIZE 40145 -#define ID_TOOLS_TILEVIEWER 40146 -#define ID_OPTIONS_GAMEBOY_COLORS 40147 -#define ID_TOOLS_DISASSEMBLE 40151 -#define ID_TOOLS_DEBUG_GDB 40152 -#define ID_TOOLS_DEBUG_CONFIGUREPORT 40153 -#define ID_TOOLS_DEBUG_BREAKONLOAD 40159 -#define ID_TOOLS_DEBUG_DISCONNECT 40154 -#define ID_TOOLS_DEBUG_BREAK 40155 -#define ID_TOOLS_LOGGING 40156 -#define ID_OPTIONS_EMULATOR_SPEEDHACK 40157 +#define ID_OPTIONS_SOUND_STOPRECORDING 40126 +#define ID_OPTIONS_VIDEO_LAYERS_BG0 40127 +#define ID_OPTIONS_VIDEO_LAYERS_BG1 40128 +#define ID_OPTIONS_VIDEO_LAYERS_BG2 40129 +#define ID_OPTIONS_VIDEO_LAYERS_BG3 40130 +#define ID_OPTIONS_VIDEO_LAYERS_OBJ 40131 +#define ID_OPTIONS_VIDEO_LAYERS_WIN0 40132 +#define ID_OPTIONS_VIDEO_LAYERS_WIN1 40133 +#define ID_OPTIONS_VIDEO_LAYERS_OBJWIN 40134 +#define ID_FILE_OPEN_GB 40135 +#define ID_DEBUG_NEXTFRAME 40137 +#define ID_TOOLS_MAPVIEW 40138 +#define ID_TOOLS_PALETTEVIEW 40139 +#define ID_OPTIONS_EMULATOR_PNGFORMAT 40140 +#define ID_OPTIONS_EMULATOR_BMPFORMAT 40141 +#define ID_TOOLS_MEMORYVIEWER 40143 +#define ID_TOOLS_OAMVIEWER 40144 +#define ID_TOOLS_CUSTOMIZE 40145 +#define ID_TOOLS_TILEVIEWER 40146 +#define ID_OPTIONS_GAMEBOY_COLORS 40147 +#define ID_TOOLS_DISASSEMBLE 40151 +#define ID_TOOLS_DEBUG_GDB 40152 +#define ID_TOOLS_DEBUG_CONFIGUREPORT 40153 +#define ID_TOOLS_DEBUG_BREAKONLOAD 40159 +#define ID_TOOLS_DEBUG_DISCONNECT 40154 +#define ID_TOOLS_DEBUG_BREAK 40155 +#define ID_TOOLS_LOGGING 40156 +#define ID_OPTIONS_EMULATOR_SPEEDHACK 40157 #define ID_OPTIONS_EMULATOR_SPEEDUPTOGGLE 40158 #define ID_OPTIONS_FILTER16BIT_ADVANCEMAMESCALE2X 40160 #define ID_OPTIONS_FILTER16BIT_SIMPLE2X 40161 -#define ID_FILE_RECENT_FREEZE 40162 +#define ID_FILE_RECENT_FREEZE 40162 #define ID_FILE_EXPORT_GAMESHARKSNAPSHOT 40163 #define ID_OPTIONS_VIDEO_FULLSCREEN800X600 40164 -#define ID_OPTIONS_VIDEO_FRAMESKIP_6 40165 -#define ID_OPTIONS_VIDEO_FRAMESKIP_7 40166 -#define ID_OPTIONS_VIDEO_FRAMESKIP_8 40167 -#define ID_OPTIONS_VIDEO_FRAMESKIP_9 40168 +#define ID_OPTIONS_VIDEO_FRAMESKIP_6 40165 +#define ID_OPTIONS_VIDEO_FRAMESKIP_7 40166 +#define ID_OPTIONS_VIDEO_FRAMESKIP_8 40167 +#define ID_OPTIONS_VIDEO_FRAMESKIP_9 40168 #define ID_OPTIONS_EMULATOR_SAVETYPE_AUTOMATIC 40169 #define ID_OPTIONS_EMULATOR_SAVETYPE_EEPROM 40170 #define ID_OPTIONS_EMULATOR_SAVETYPE_SRAM 40171 @@ -868,28 +868,28 @@ #define ID_OPTIONS_EMULATOR_AUTOMATICALLYAPPLYPATCHFILES 40176 #define ID_TOOLS_RECORD_STARTAVIRECORDING 40178 #define ID_TOOLS_RECORD_STOPAVIRECORDING 40179 -#define ID_OPTIONS_FILTER_BILINEAR 40186 -#define ID_OPTIONS_FILTER_BILINEARPLUS 40187 +#define ID_OPTIONS_FILTER_BILINEAR 40186 +#define ID_OPTIONS_FILTER_BILINEARPLUS 40187 #define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_NONE 40188 #define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_MOTIONBLUR 40189 #define ID_OPTIONS_FILTER_INTERFRAMEBLENDING_SMART 40190 -#define ID_OPTIONS_VIDEO_FULLSCREEN 40191 +#define ID_OPTIONS_VIDEO_FULLSCREEN 40191 #define ID_OPTIONS_VIDEO_TRIPLEBUFFERING 40192 -#define ID_OPTIONS_FRAMESKIP_AUTOMATIC 40194 +#define ID_OPTIONS_FRAMESKIP_AUTOMATIC 40194 #define ID_OPTIONS_EMULATOR_SHOWSPEED_NONE 40195 #define ID_OPTIONS_EMULATOR_SHOWSPEED_PERCENTAGE 40196 #define ID_OPTIONS_EMULATOR_SHOWSPEED_DETAILED 40197 #define ID_OPTIONS_EMULATOR_SHOWSPEED_TRANSPARENT 40198 -#define ID_OPTIONS_JOYPAD_CONFIGURE_1 40199 -#define ID_OPTIONS_JOYPAD_CONFIGURE_2 40200 -#define ID_OPTIONS_JOYPAD_CONFIGURE_3 40201 -#define ID_OPTIONS_JOYPAD_CONFIGURE_4 40202 +#define ID_OPTIONS_JOYPAD_CONFIGURE_1 40199 +#define ID_OPTIONS_JOYPAD_CONFIGURE_2 40200 +#define ID_OPTIONS_JOYPAD_CONFIGURE_3 40201 +#define ID_OPTIONS_JOYPAD_CONFIGURE_4 40202 #define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_1 40208 #define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_2 40209 #define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_3 40210 #define ID_OPTIONS_JOYPAD_DEFAULTJOYPAD_4 40211 #define ID_OPTIONS_EMULATOR_STORESETTINGSINREGISTRY 40214 -#define ID_FILE_EXPORT_SETTINGSTOINI 40215 +#define ID_FILE_EXPORT_SETTINGSTOINI 40215 #define ID_OPTIONS_FRAMESKIP_THROTTLE_NOTHROTTLE 40216 #define ID_OPTIONS_FRAMESKIP_THROTTLE_50 40217 #define ID_OPTIONS_FRAMESKIP_THROTTLE_150 40218 @@ -897,7 +897,7 @@ #define ID_OPTIONS_FRAMESKIP_THROTTLE_25 40220 #define ID_OPTIONS_FRAMESKIP_THROTTLE_OTHER 40221 #define ID_OPTIONS_FRAMESKIP_THROTTLE_100 40222 -#define ID_OPTIONS_FILTER_SCANLINES 40223 +#define ID_OPTIONS_FILTER_SCANLINES 40223 #define ID_OPTIONS_VIDEO_RENDERMETHOD_GDI 40228 #define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECTDRAW 40229 #define ID_OPTIONS_VIDEO_RENDERMETHOD_DIRECT3D 40230 @@ -910,122 +910,122 @@ #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLBILINEAR 40238 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLTRIANGLE 40239 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLQUADS 40240 -#define ID_OPTIONS_EMULATOR_AGBPRINT 40247 +#define ID_OPTIONS_EMULATOR_AGBPRINT 40247 #define ID_OPTIONS_EMULATOR_REALTIMECLOCK 40248 -#define ID_OPTIONS_GAMEBOY_SGB2 40249 -#define ID_SYSTEM_MINIMIZE 40250 +#define ID_OPTIONS_GAMEBOY_SGB2 40249 +#define ID_SYSTEM_MINIMIZE 40250 #define ID_TOOLS_RECORD_STARTMOVIERECORDING 40251 #define ID_TOOLS_RECORD_STOPMOVIERECORDING 40252 #define ID_TOOLS_PLAY_STARTMOVIEPLAYING 40253 -#define ID_TOOLS_PLAY_STOPMOVIEPLAYING 40254 +#define ID_TOOLS_PLAY_STOPMOVIEPLAYING 40254 #define ID_OPTIONS_GAMEBOY_BORDERAUTOMATIC 40256 -#define ID_OPTIONS_EMULATOR_REWIND 40257 -#define ID_TOOLS_REWIND 40258 -#define ID_OPTIONS_EMULATOR_SKIPBIOS 40259 -#define ID_HELP_BUGREPORT 40260 -#define ID_HELP_FAQ 40261 +#define ID_OPTIONS_EMULATOR_REWIND 40257 +#define ID_TOOLS_REWIND 40258 +#define ID_OPTIONS_EMULATOR_SKIPBIOS 40259 +#define ID_HELP_BUGREPORT 40260 +#define ID_HELP_FAQ 40261 #define ID_OPTIONS_EMULATOR_REWINDINTERVAL 40262 -#define ID_FILE_TOGGLEMENU 40263 +#define ID_FILE_TOGGLEMENU 40263 #define ID_OPTIONS_EMULATOR_SAVETYPE_NONE 40264 -#define ID_TOOLS_IOVIEWER 40266 -#define ID_FILE_LOADGAME_MOSTRECENT 40267 -#define ID_FILE_SAVEGAME_OLDESTSLOT 40268 +#define ID_TOOLS_IOVIEWER 40266 +#define ID_FILE_LOADGAME_MOSTRECENT 40267 +#define ID_FILE_SAVEGAME_OLDESTSLOT 40268 #define ID_FILE_LOADGAME_AUTOLOADMOSTRECENT 40269 -#define ID_CHEATS_DISABLECHEATS 40272 +#define ID_CHEATS_DISABLECHEATS 40272 #define ID_OPTIONS_VIDEO_FULLSCREENMAXSCALE 40273 -#define ID_OPTIONS_FILTER_HQ2X 40274 -#define ID_OPTIONS_FILTER_LQ2X 40275 +#define ID_OPTIONS_FILTER_HQ2X 40274 +#define ID_OPTIONS_FILTER_LQ2X 40275 #define ID_OPTIONS_EMULATOR_GAMEOVERRIDES 40276 -#define ID_HELP_GNUPUBLICLICENSE 40277 +#define ID_HELP_GNUPUBLICLICENSE 40277 #define ID_OPTIONS_SOUND_HARDWAREACCELERATION 40281 #define ID_OPTIONS_VIDEO_FULLSCREEN1024X768 40282 #define ID_OPTIONS_VIDEO_FULLSCREEN1280X1024 40283 -#define ID_OPTIONS_FILTER_SIMPLE3X 40287 -#define ID_OPTIONS_FILTER_SIMPLE4X 40288 -#define ID_OPTIONS_FILTER_HQ3X 40290 -#define ID_OPTIONS_FILTER_HQ4X 40291 -#define ID_VIDEO_WINDOWED 40292 -#define ID_VIDEO_FULL 40293 +#define ID_OPTIONS_FILTER_SIMPLE3X 40287 +#define ID_OPTIONS_FILTER_SIMPLE4X 40288 +#define ID_OPTIONS_FILTER_HQ3X 40290 +#define ID_OPTIONS_FILTER_HQ4X 40291 +#define ID_VIDEO_WINDOWED 40292 +#define ID_VIDEO_FULL 40293 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_NONE 40294 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_LINEAR 40295 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_CUBIC 40296 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_FIR 40297 #define ID_OPTIONS_SOUND_PCMINTERPOLATION_LIBRESAMPLE 40298 -#define IDD_LINKTAB 40301 -#define IDD_SERVERWAIT 40304 -#define IDC_TAB1 40305 -#define IDC_LINK_SINGLE 40306 -#define IDC_LINK_TIMEOUT 40307 -#define IDC_LINK_DISCONNECTED 40307 -#define IDC_LINK_LAN 40308 -#define IDC_LINK2P 40309 -#define IDC_LINK_RFU 40309 -#define IDC_LINK_GAMECUBE 40310 -#define IDC_SSPEED 40311 -#define IDC_SERVERIP 40313 -#define IDC_CLINKIP 40314 -#define ID_OPTIONS_LINK_OPTIONS 40318 -#define ID_OPTIONS_LINK_LOG 40319 +#define IDD_LINKTAB 40301 +#define IDD_SERVERWAIT 40304 +#define IDC_TAB1 40305 +#define IDC_LINK_SINGLE 40306 +#define IDC_LINK_TIMEOUT 40307 +#define IDC_LINK_DISCONNECTED 40307 +#define IDC_LINK_LAN 40308 +#define IDC_LINK2P 40309 +#define IDC_LINK_RFU 40309 +#define IDC_LINK_GAMECUBE 40310 +#define IDC_SSPEED 40311 +#define IDC_SERVERIP 40313 +#define IDC_CLINKIP 40314 +#define ID_OPTIONS_LINK_OPTIONS 40318 +#define ID_OPTIONS_LINK_LOG 40319 #define ID_OPTIONS_LINK_WIRELESSADAPTER 40320 -#define IDC_LINKTIMEOUT 40321 -#define IDC_AUTOLINK 40322 -#define IDC_SERVERWAIT 40323 -#define IDC_LINK3P 40325 -#define IDC_LINK4P 40326 -#define ID_Menu 40332 +#define IDC_LINKTIMEOUT 40321 +#define IDC_AUTOLINK 40322 +#define IDC_SERVERWAIT 40323 +#define IDC_LINK3P 40325 +#define IDC_LINK4P 40326 +#define ID_Menu 40332 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLANISOTROPIC 40333 -#define ID_OPTIONS_LINK_ENABLE 40335 -#define ID_RENDERAPI_VERTEX 40336 +#define ID_OPTIONS_LINK_ENABLE 40335 +#define ID_RENDERAPI_VERTEX 40336 #define ID_OPTIONS_VIDEO_RENDEROPTIONS_GLPOLYGONS 40337 -#define ID_VIDEO_SKIN 40338 -#define ID_OPTIONS_UI 40339 -#define ID_USERINTERFACE_SKIN 40340 -#define ID_SKIN_USE 40341 -#define ID_SKIN_SELECT 40342 -#define ID_OPTIONS_FILTER_PLUGIN 40343 -#define ID_OPTIONS_SELECT_PLUGIN 40344 -#define IDC_COMBO_PLUGIN 40345 -#define ID_OUTPUTAPI_DIRECTSOUND 40346 -#define ID_OUTPUTAPI_OPENAL 40347 -#define ID_OUTPUTAPI_SOFTWAREMIXING 40348 -#define ID_OUTPUTAPI_CONFIGURATION 40349 -#define ID_OUTPUTAPI_OALCONFIGURATION 40350 -#define ID_RENDERAPI_FILTER 40351 -#define ID_OPTIONS_SPEED 40353 -#define ID_RENDERAPI_MOTIONBLUR 40354 -#define ID_RENDERAPI_D3DMOTIONBLUR 40355 -#define ID_EMULATOR_BIOSFILES 40356 -#define ID_FILE_OPEN_GBC 40358 -#define ID_OUTPUTAPI_XAUDIO2 40359 -#define ID_PIXELFILTER_MULTI 40360 -#define ID_EMULATOR_LOADSTATESHOULD 40361 +#define ID_VIDEO_SKIN 40338 +#define ID_OPTIONS_UI 40339 +#define ID_USERINTERFACE_SKIN 40340 +#define ID_SKIN_USE 40341 +#define ID_SKIN_SELECT 40342 +#define ID_OPTIONS_FILTER_PLUGIN 40343 +#define ID_OPTIONS_SELECT_PLUGIN 40344 +#define IDC_COMBO_PLUGIN 40345 +#define ID_OUTPUTAPI_DIRECTSOUND 40346 +#define ID_OUTPUTAPI_OPENAL 40347 +#define ID_OUTPUTAPI_SOFTWAREMIXING 40348 +#define ID_OUTPUTAPI_CONFIGURATION 40349 +#define ID_OUTPUTAPI_OALCONFIGURATION 40350 +#define ID_RENDERAPI_FILTER 40351 +#define ID_OPTIONS_SPEED 40353 +#define ID_RENDERAPI_MOTIONBLUR 40354 +#define ID_RENDERAPI_D3DMOTIONBLUR 40355 +#define ID_EMULATOR_BIOSFILES 40356 +#define ID_FILE_OPEN_GBC 40358 +#define ID_OUTPUTAPI_XAUDIO2 40359 +#define ID_PIXELFILTER_MULTI 40360 +#define ID_EMULATOR_LOADSTATESHOULD 40361 #define ID_LOADGAME_DONOTCHANGEBATTERYSAVE 40362 #define ID_OUTPUTAPI_CONFIGURATION40363 40363 -#define ID_OUTPUTAPI_XAUDIO2CONFIG 40364 -#define ID_AUDIO_CORE_SETTINGS 40365 -#define ID_FILE_OPEN_GBA 40366 -#define ID_OPTIONS_VIDEO_LAYERS_RESET 40367 -#define ID_FILE_LOAD_DOTCODE 40368 -#define ID_FILE_SAVE_DOTCODE 40369 +#define ID_OUTPUTAPI_XAUDIO2CONFIG 40364 +#define ID_AUDIO_CORE_SETTINGS 40365 +#define ID_FILE_OPEN_GBA 40366 +#define ID_OPTIONS_VIDEO_LAYERS_RESET 40367 +#define ID_FILE_LOAD_DOTCODE 40368 +#define ID_FILE_SAVE_DOTCODE 40369 #define ID_LOADGAME_DONOTCHANGECHEATLIST 40371 #define ID_OPTIONS_EMULATOR_SAVETYPE_DETECTNOW 40372 -#define ID_FILE_PAUSE 40373 +#define ID_FILE_PAUSE 40373 #define ID_OPTIONS_EMULATOR_DIRECTORIES 40374 -#define ID_Menu40375 40375 -#define ID_OPTIONS_JOYBUS 40376 -#define ID_OPTIONS_FILTER_XBRZ2X 40377 -#define ID_OPTIONS_FILTER_XBRZ3X 40378 -#define ID_OPTIONS_FILTER_XBRZ4X 40379 -#define ID_OPTIONS_FILTER_XBRZ5X 40380 -#define ID_OPTIONS_FILTER_XBRZ6X 40381 +#define ID_Menu40375 40375 +#define ID_OPTIONS_JOYBUS 40376 +#define ID_OPTIONS_FILTER_XBRZ2X 40377 +#define ID_OPTIONS_FILTER_XBRZ3X 40378 +#define ID_OPTIONS_FILTER_XBRZ4X 40379 +#define ID_OPTIONS_FILTER_XBRZ5X 40380 +#define ID_OPTIONS_FILTER_XBRZ6X 40381 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 167 -#define _APS_NEXT_COMMAND_VALUE 40382 -#define _APS_NEXT_CONTROL_VALUE 1437 -#define _APS_NEXT_SYMED_VALUE 103 +#define _APS_NEXT_RESOURCE_VALUE 167 +#define _APS_NEXT_COMMAND_VALUE 40382 +#define _APS_NEXT_CONTROL_VALUE 1437 +#define _APS_NEXT_SYMED_VALUE 103 #endif #endif diff --git a/src/win32/rpi.h b/src/win32/rpi.h index c519567a..68ebeabc 100644 --- a/src/win32/rpi.h +++ b/src/win32/rpi.h @@ -8,69 +8,68 @@ // Modified by suanyuan //--------------------------------------------------------------------------------------------------------------------------- #if defined(_WIN32) -#include +#include #else #define HMODULE void * #endif //--------------------------------------------------------------------------------------------------------------------------- -typedef struct -{ - unsigned long Size; - unsigned long Flags; - void *SrcPtr; - unsigned long SrcPitch; - unsigned long SrcW; - unsigned long SrcH; - void *DstPtr; - unsigned long DstPitch; - unsigned long DstW; - unsigned long DstH; - unsigned long OutW; - unsigned long OutH; +typedef struct { + unsigned long Size; + unsigned long Flags; + void *SrcPtr; + unsigned long SrcPitch; + unsigned long SrcW; + unsigned long SrcH; + void *DstPtr; + unsigned long DstPitch; + unsigned long DstW; + unsigned long DstH; + unsigned long OutW; + unsigned long OutH; } RENDER_PLUGIN_OUTP; //--------------------------------------------------------------------------------------------------------------------------- -typedef void (*RENDPLUG_Output)(RENDER_PLUGIN_OUTP *); +typedef void (*RENDPLUG_Output)(RENDER_PLUGIN_OUTP *); //--------------------------------------------------------------------------------------------------------------------------- -typedef struct -{ - char Name[60]; - unsigned long Flags; - HMODULE Handle; - RENDPLUG_Output Output; +typedef struct { + char Name[60]; + unsigned long Flags; + HMODULE Handle; + RENDPLUG_Output Output; } RENDER_PLUGIN_INFO; //--------------------------------------------------------------------------------------------------------------------------- -typedef RENDER_PLUGIN_INFO *(*RENDPLUG_GetInfo)(void); +typedef RENDER_PLUGIN_INFO *(*RENDPLUG_GetInfo)(void); //--------------------------------------------------------------------------------------------------------------------------- -#define RPI_VERSION 0x02 +#define RPI_VERSION 0x02 -#define RPI_MMX_USED 0x000000100 -#define RPI_MMX_REQD 0x000000200 -#define RPI_555_SUPP 0x000000400 -#define RPI_565_SUPP 0x000000800 -#define RPI_888_SUPP 0x000001000 +#define RPI_MMX_USED 0x000000100 +#define RPI_MMX_REQD 0x000000200 +#define RPI_555_SUPP 0x000000400 +#define RPI_565_SUPP 0x000000800 +#define RPI_888_SUPP 0x000001000 -#define RPI_DST_WIDE 0x000008000 +#define RPI_DST_WIDE 0x000008000 -#define RPI_OUT_SCL1 0x000010000 -#define RPI_OUT_SCL2 0x000020000 -#define RPI_OUT_SCL3 0x000030000 -#define RPI_OUT_SCL4 0x000040000 +#define RPI_OUT_SCL1 0x000010000 +#define RPI_OUT_SCL2 0x000020000 +#define RPI_OUT_SCL3 0x000030000 +#define RPI_OUT_SCL4 0x000040000 -#define RPI_OUT_SCLMSK 0x0000f0000 -#define RPI_OUT_SCLSH 16 +#define RPI_OUT_SCLMSK 0x0000f0000 +#define RPI_OUT_SCLSH 16 //--------------------------------------------------------------------------------------------------------------------------- int rpiScaleFactor(); bool rpiInit(const char *sPluginName); -void rpiFilter(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, int height); +void rpiFilter(u8 *srcPtr, u32 srcPitch, u8 *deltaPtr, u8 *dstPtr, u32 dstPitch, int width, + int height); void rpiCleanup(); diff --git a/src/win32/stdafx.h b/src/win32/stdafx.h index c0430d93..51f5025e 100644 --- a/src/win32/stdafx.h +++ b/src/win32/stdafx.h @@ -1,10 +1,13 @@ #pragma once // make windows controls look newer / enable visual styles: -#pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' ""version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") +#pragma comment( \ + linker, \ + "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' " \ + "version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif #ifndef NO_STRICT @@ -13,18 +16,17 @@ #include "targetver.h" -#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit +#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS -#include // MFC core and standard components -#include // MFC extensions - +#include // MFC extensions +#include // MFC core and standard components #ifndef _AFX_NO_OLE_SUPPORT -#include // MFC support for Internet Explorer 4 Common Controls +#include // MFC support for Internet Explorer 4 Common Controls #endif #ifndef _AFX_NO_AFXCMN_SUPPORT -#include // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT +#include // MFC support for Windows Common Controls +#endif // _AFX_NO_AFXCMN_SUPPORT diff --git a/src/win32/targetver.h b/src/win32/targetver.h index f868e69f..ed4e8d1a 100644 --- a/src/win32/targetver.h +++ b/src/win32/targetver.h @@ -1,24 +1,26 @@ #pragma once // The following macros define the minimum required platform. The minimum required platform -// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run -// your application. The macros work by enabling all features available on platform versions up to and +// is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run +// your application. The macros work by enabling all features available on platform versions up to +// and // including the version specified. // Modify the following defines if you have to target a platform prior to the ones specified below. // Refer to MSDN for the latest info on corresponding values for different platforms. -#ifndef WINVER // Specifies that the minimum required platform is Windows XP. -#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. +#ifndef WINVER // Specifies that the minimum required platform is Windows XP. +#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif -#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows XP. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows XP. +#define _WIN32_WINNT \ + 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif -#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. -#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. +#ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. +#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. #endif -#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 5.0. -#define _WIN32_IE 0x0500 // Change this to the appropriate value to target other versions of IE. -#endif // Actually, we don't care +#ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 5.0. +#define _WIN32_IE 0x0500 // Change this to the appropriate value to target other versions of IE. +#endif // Actually, we don't care diff --git a/src/wx/drawing.h b/src/wx/drawing.h index 377fb987..e03debdf 100644 --- a/src/wx/drawing.h +++ b/src/wx/drawing.h @@ -3,17 +3,26 @@ class BasicDrawingPanel : public DrawingPanel, public wxPanel { -public: - BasicDrawingPanel(wxWindow* parent, int _width, int _height); - wxWindow* GetWindow() { return this; } - void Delete() { Destroy(); } + public: + BasicDrawingPanel(wxWindow *parent, int _width, int _height); + wxWindow *GetWindow() + { + return this; + } + void Delete() + { + Destroy(); + } -protected: - void PaintEv2(wxPaintEvent &ev) { PaintEv(ev); } - void DrawArea(wxWindowDC &dc); + protected: + void PaintEv2(wxPaintEvent &ev) + { + PaintEv(ev); + } + void DrawArea(wxWindowDC &dc); - DECLARE_CLASS() - DECLARE_EVENT_TABLE() + DECLARE_CLASS() + DECLARE_EVENT_TABLE() }; #ifndef NO_OGL @@ -21,45 +30,63 @@ protected: class GLDrawingPanel : public DrawingPanel, public wxGLCanvas { -public: - GLDrawingPanel(wxWindow* parent, int _width, int _height); - virtual ~GLDrawingPanel(); - wxWindow* GetWindow() { return this; } - void Delete() { Destroy(); } + public: + GLDrawingPanel(wxWindow *parent, int _width, int _height); + virtual ~GLDrawingPanel(); + wxWindow *GetWindow() + { + return this; + } + void Delete() + { + Destroy(); + } -protected: - void PaintEv2(wxPaintEvent &ev) { PaintEv(ev); } - void OnSize(wxSizeEvent &); - void DrawArea(wxWindowDC &dc); -#if wxCHECK_VERSION(2,9,0) || !defined(__WXMAC__) - wxGLContext ctx; + protected: + void PaintEv2(wxPaintEvent &ev) + { + PaintEv(ev); + } + void OnSize(wxSizeEvent &); + void DrawArea(wxWindowDC &dc); +#if wxCHECK_VERSION(2, 9, 0) || !defined(__WXMAC__) + wxGLContext ctx; #endif - bool did_init; - void Init(); - GLuint texid, vlist; - int texsize; + bool did_init; + void Init(); + GLuint texid, vlist; + int texsize; - DECLARE_CLASS() - DECLARE_EVENT_TABLE() + DECLARE_CLASS() + DECLARE_EVENT_TABLE() }; #endif #if defined(__WXMSW__) && !defined(NO_D3D) class DXDrawingPanel : public DrawingPanel, public wxPanel { -public: - DXDrawingPanel(wxWindow* parent, int _width, int _height); - wxWindow* GetWindow() { return this; } - void Delete() { Destroy(); } + public: + DXDrawingPanel(wxWindow *parent, int _width, int _height); + wxWindow *GetWindow() + { + return this; + } + void Delete() + { + Destroy(); + } -protected: - void PaintEv2(wxPaintEvent &ev) { PaintEv(ev); } - void DrawArea(wxWindowDC &); - bool did_init; - void Init(); + protected: + void PaintEv2(wxPaintEvent &ev) + { + PaintEv(ev); + } + void DrawArea(wxWindowDC &); + bool did_init; + void Init(); - DECLARE_CLASS() - DECLARE_EVENT_TABLE() + DECLARE_CLASS() + DECLARE_EVENT_TABLE() }; #endif @@ -68,19 +95,28 @@ protected: class CairoDrawingPanel : public DrawingPanel, public wxPanel { -public: - CairoDrawingPanel(wxWindow* parent, int _width, int _height); - ~CairoDrawingPanel(); - wxWindow* GetWindow() { return this; } - void Delete() { Destroy(); } + public: + CairoDrawingPanel(wxWindow *parent, int _width, int _height); + ~CairoDrawingPanel(); + wxWindow *GetWindow() + { + return this; + } + void Delete() + { + Destroy(); + } -protected: - void PaintEv2(wxPaintEvent &ev) { PaintEv(ev); } - void DrawArea(wxWindowDC &); - cairo_surface_t* conv_surf; + protected: + void PaintEv2(wxPaintEvent &ev) + { + PaintEv(ev); + } + void DrawArea(wxWindowDC &); + cairo_surface_t *conv_surf; - DECLARE_CLASS() - DECLARE_EVENT_TABLE() + DECLARE_CLASS() + DECLARE_EVENT_TABLE() }; #endif diff --git a/src/wx/filters.h b/src/wx/filters.h index 69694adb..aa771ac5 100644 --- a/src/wx/filters.h +++ b/src/wx/filters.h @@ -6,78 +6,78 @@ // most 16-bit filters require space in src rounded up to u32 // those that take delta take 1 src line of pixels, rounded up to u32 size // initial value appears to be all-0xff -void Pixelate32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Pixelate(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); +void Pixelate32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Pixelate(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); // next 3*2 use Init_2xSaI(555|565) and do not take into account int Init_2xSaI(u32 BitFormat); // endianness or bit shift variables in init. // next 4*2 may be MMX-accelerated -void _2xSaI32(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); -void _2xSaI(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); +void _2xSaI32(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); +void _2xSaI(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); // void Scale_2xSaI(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); -void Super2xSaI32(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); -void Super2xSaI(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); -void SuperEagle32(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); -void SuperEagle(u8* src, u32 spitch, u8* delta, u8* dst, u32 dstp, int w, int h); -void AdMame2x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void AdMame2x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void Super2xSaI32(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); +void Super2xSaI(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); +void SuperEagle32(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); +void SuperEagle(u8 *src, u32 spitch, u8 *delta, u8 *dst, u32 dstp, int w, int h); +void AdMame2x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void AdMame2x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // next 4 convert to rgb24 in internal buffers first, and then back again -void Bilinear32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Bilinear(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void BilinearPlus32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void BilinearPlus(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Scanlines32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Scanlines(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void ScanlinesTV32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void Bilinear32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Bilinear(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void BilinearPlus32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void BilinearPlus(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Scanlines32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Scanlines(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void ScanlinesTV32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // "TV" here means each pixel is faded horizontally & vertically rather than // inserting black scanlines // this depends on RGB_LOW_BITS_MASK extern int RGB_LOW_BITS_MASK; -void ScanlinesTV(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void ScanlinesTV(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // next 2 require calling hq2x_init first and whenever bpp changes void hq2x_init(unsigned bpp); -void hq2x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void hq2x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void lq2x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void lq2x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void hq2x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void hq2x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void lq2x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void lq2x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // the simple ones could greatly benefit from correct usage of preprocessor.. // in any case, they are worthless, since all renderers do "simple" or // better by default -void Simple2x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Simple2x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Simple3x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Simple3x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Simple4x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void Simple4x(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void Simple2x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Simple2x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Simple3x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Simple3x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Simple4x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void Simple4x(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // note: 16-bit input for asm version only! -void hq3x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void hq3x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // this takes 32-bit input // (by converting to 16-bit first in asm version) -void hq3x32_32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void hq3x16(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void hq3x32_32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void hq3x16(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // note: 16-bit input for asm version only! -void hq4x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void hq4x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // this takes 32-bit input // (by converting to 16-bit first in asm version) -void hq4x32_32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void hq4x16(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void hq4x32_32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void hq4x16(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); -void xbrz2x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void xbrz3x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void xbrz4x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void xbrz5x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); -void xbrz6x32(u8* src, u32 spitch, u8*, u8* dst, u32 dstp, int w, int h); +void xbrz2x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void xbrz3x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void xbrz4x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void xbrz5x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); +void xbrz6x32(u8 *src, u32 spitch, u8 *, u8 *dst, u32 dstp, int w, int h); // call ifc to ignore previous frame / when starting new void InterframeCleanup(); // all 4 are MMX-accelerated if enabled -void SmartIB(u8* src, u32 spitch, int width, int height); -void SmartIB32(u8* src, u32 spitch, int width, int height); -void MotionBlurIB(u8* src, u32 spitch, int width, int height); -void MotionBlurIB32(u8* src, u32 spitch, int width, int height); -void SmartIB(u8* src, u32 spitch, int width, int starty, int height); -void SmartIB32(u8* src, u32 spitch, int width, int starty, int height); -void MotionBlurIB(u8* src, u32 spitch, int width, int starty, int height); -void MotionBlurIB32(u8* src, u32 spitch, int width, int starty, int height); +void SmartIB(u8 *src, u32 spitch, int width, int height); +void SmartIB32(u8 *src, u32 spitch, int width, int height); +void MotionBlurIB(u8 *src, u32 spitch, int width, int height); +void MotionBlurIB32(u8 *src, u32 spitch, int width, int height); +void SmartIB(u8 *src, u32 spitch, int width, int starty, int height); +void SmartIB32(u8 *src, u32 spitch, int width, int starty, int height); +void MotionBlurIB(u8 *src, u32 spitch, int width, int starty, int height); +void MotionBlurIB32(u8 *src, u32 spitch, int width, int starty, int height); #endif /* FILTERS_H */ diff --git a/src/wx/ioregs.h b/src/wx/ioregs.h index cbd0bd78..f7b285a6 100644 --- a/src/wx/ioregs.h +++ b/src/wx/ioregs.h @@ -1,2074 +1,2117 @@ // this is essentially a copy of ../win32/IOViewRegisters.h using translatable // strings and more consts -struct IOData -{ - u16* address; - u16 offset; - const wxChar* name; - u16 write; - const wxChar* bits[16]; +struct IOData { + u16 *address; + u16 offset; + const wxChar *name; + u16 write; + const wxChar *bits[16]; }; -/* const */ IOData ioregs[] = // not const so tranlation can be done once -{ - { - &DISPCNT, 0, wxTRANSLATE("0x4000000-DISPCNT"), 0xFFF7, - { - wxT(""), - wxT(""), - wxTRANSLATE("BG Mode (3 bits)"), - wxTRANSLATE("CGB Mode"), - wxTRANSLATE("Display Frame"), - wxTRANSLATE("H-Blank Interval OBJ processing"), - wxTRANSLATE("OBJ Character mapping"), - wxTRANSLATE("Forced blank"), - wxTRANSLATE("BG0"), - wxTRANSLATE("BG1"), - wxTRANSLATE("BG2"), - wxTRANSLATE("BG3"), - wxTRANSLATE("OBJ"), - wxTRANSLATE("WIN0"), - wxTRANSLATE("WIN1"), - wxTRANSLATE("OBJWIN") - } - }, - { - &DISPSTAT, 4, wxTRANSLATE("0x4000004-DISPSTAT"), 0xFF38, - { - wxTRANSLATE("V-Blank Status"), - wxTRANSLATE("H-Blank Status"), - wxTRANSLATE("VCOUNT Evaluation"), - wxTRANSLATE("V-Blank Interrupt Enable"), - wxTRANSLATE("H-Blank Interrupt Enable"), - wxTRANSLATE("VCOUNT Match Interrupt Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("VCOUNT setting (8 bits)") - } - }, - { - &VCOUNT, 6, wxTRANSLATE("0x4000006-VCOUNT"), 0x0000, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("VCOUNT (8 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG0CNT, 8, wxTRANSLATE("0x4000008-BG0CNT"), 0xDFCF, - { - wxT(""), - wxTRANSLATE("Priority (2 bits)"), - wxT(""), - wxTRANSLATE("Char base (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Mosaic"), - wxTRANSLATE("16/256 colors"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Screen Base Block (5 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Size (2 bits)") - } - }, - { - &BG1CNT, 0xA, wxTRANSLATE("0x400000A-BG1CNT"), 0xDFCF, - { - wxT(""), - wxTRANSLATE("Priority (2 bits)"), - wxT(""), - wxTRANSLATE("Char base (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Mosaic"), - wxTRANSLATE("16/256 colors"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Screen Base Block (5 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Size (2 bits)") - } - }, - { - &BG2CNT, 0xC, wxTRANSLATE("0x400000C-BG2CNT"), 0xFFCF, - { - wxT(""), - wxTRANSLATE("Priority (2 bits)"), - wxT(""), - wxTRANSLATE("Char base (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Mosaic"), - wxTRANSLATE("16/256 colors"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Screen Base Block (5 bits)"), - wxTRANSLATE("Area Overflow"), - wxT(""), - wxTRANSLATE("Size (2 bits)") - } - }, - { - &BG3CNT, 0xE, wxTRANSLATE("0x400000E-BG3CNT"), 0xFFCF, - { - wxT(""), - wxTRANSLATE("Priority (2 bits)"), - wxT(""), - wxTRANSLATE("Char base (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Mosaic"), - wxTRANSLATE("16/256 colors"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Screen Base Block (5 bits)"), - wxTRANSLATE("Area Overflow"), - wxT(""), - wxTRANSLATE("Size (2 bits)") - } - }, - { - &BG0HOFS, 0x10, wxTRANSLATE("0x4000010-BG0HOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Horizontal Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG0VOFS, 0x12, wxTRANSLATE("0x4000012-BG0VOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Vertical Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG1HOFS, 0x14, wxTRANSLATE("0x4000014-BG1HOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Horizontal Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG1VOFS, 0x16, wxTRANSLATE("0x4000016-BG1VOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Vertical Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG2HOFS, 0x18, wxTRANSLATE("0x4000018-BG2HOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Horizontal Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG2VOFS, 0x1A, wxTRANSLATE("0x400001A-BG2VOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Vertical Offset (9 bits, W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG3HOFS, 0x1C, wxTRANSLATE("0x400001C-BG3HOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Horizontal Offset (9 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG3VOFS, 0x1E, wxTRANSLATE("0x400001E-BG3VOFS"), 0x01FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Vertical Offset (9 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT("") - } - }, - { - &BG2PA, 0x20, wxTRANSLATE("0x4000020-BG2PA"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dx (16 bits,W)") - } - }, - { - &BG2PB, 0x22, wxTRANSLATE("0x4000022-BG2PB"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dmx (16 bits,W)") - } - }, - { - &BG2PC, 0x24, wxTRANSLATE("0x4000024-BG2PC"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dy (16 bits,W)") - } - }, - { - &BG2PD, 0x26, wxTRANSLATE("0x4000026-BG2PD"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dmy (16 bits,W)") - } - }, - { - &BG2X_L, 0x28, wxTRANSLATE("0x4000028-BG2X_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("X low bits (16 bits,W)") - } - }, - { - &BG2X_H, 0x2A, wxTRANSLATE("0x400002A-BG2X_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("X high bits (12 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &BG2Y_L, 0x2C, wxTRANSLATE("0x400002C-BG2Y_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Y low bits (16 bits,W)") - } - }, - { - &BG2Y_H, 0x2E, wxTRANSLATE("0x400002E-BG2Y_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Y hight bits (12 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &BG3PA, 0x30, wxTRANSLATE("0x4000030-BG3PA"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dx (16 bits,W)") - } - }, - { - &BG3PB, 0x32, wxTRANSLATE("0x4000032-BG3PB"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dmx (16 bits,W)") - } - }, - { - &BG3PC, 0x34, wxTRANSLATE("0x4000034-BG3PC"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dy (16 bits,W)") - } - }, - { - &BG3PD, 0x36, wxTRANSLATE("0x4000036-BG3PD"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("dmy (16 bits,W)") - } - }, - { - &BG3X_L, 0x38, wxTRANSLATE("0x4000038-BG3X_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("X low bits (16 bits,W)") - } - }, - { - &BG3X_H, 0x3A, wxTRANSLATE("0x400003A-BG3X_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("X hight bits (12 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &BG3Y_L, 0x3C, wxTRANSLATE("0x400003C-BG3Y_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Y low bits (16 bits,W)") - } - }, - { - &BG3Y_H, 0x3E, wxTRANSLATE("0x400003E-BG3Y_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Y hight bits (12 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &WIN0H, 0x40, wxTRANSLATE("0x4000040-WIN0H"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 0 lower-right X (8 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 0 upper-left X (8 bits,W)"), - } - }, - { - &WIN1H, 0x42, wxTRANSLATE("0x4000042-WIN1H"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 1 lower-right X (8 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 1 upper-left (8 bits,W)"), - } - }, - { - &WIN0V, 0x44, wxTRANSLATE("0x4000044-WIN0V"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 0 lower-right Y (8 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 0 upper-left Y (8 bits,W)"), - } - }, - { - &WIN1V, 0x46, wxTRANSLATE("0x4000046-WIN1V"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 1 lower-right Y (8 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Win 1 upper-left Y (8 bits,W)"), - } - }, - { - &WININ, 0x48, wxTRANSLATE("0x4000048-WININ"), 0x3F3F, - { - wxTRANSLATE("WIN0 BG0"), - wxTRANSLATE("WIN0 BG1"), - wxTRANSLATE("WIN0 BG2"), - wxTRANSLATE("WIN0 BG3"), - wxTRANSLATE("WIN0 OBJ"), - wxTRANSLATE("WIN0 Special FX"), - wxT(""), - wxT(""), - wxTRANSLATE("WIN1 BG0"), - wxTRANSLATE("WIN1 BG1"), - wxTRANSLATE("WIN1 BG2"), - wxTRANSLATE("WIN1 BG3"), - wxTRANSLATE("WIN1 OBJ"), - wxTRANSLATE("WIN1 Special FX"), - wxT(""), - wxT(""), - } - }, - { - &WINOUT, 0x4A, wxTRANSLATE("0x400004A-WINOUT"), 0x3F3F, - { - wxTRANSLATE("WIN0/1 BG0"), - wxTRANSLATE("WIN0/1 BG1"), - wxTRANSLATE("WIN0/1 BG2"), - wxTRANSLATE("WIN0/1 BG3"), - wxTRANSLATE("WIN0/1 OBJ"), - wxTRANSLATE("WIN0/1 Special FX"), - wxT(""), - wxT(""), - wxTRANSLATE("OBJWIN BG0"), - wxTRANSLATE("OBJWIN BG1"), - wxTRANSLATE("OBJWIN BG2"), - wxTRANSLATE("OBJWIN BG3"), - wxTRANSLATE("OBJWIN OBJ"), - wxTRANSLATE("OBJWIN Special FX"), - wxT(""), - wxT(""), - } - }, - { - &MOSAIC, 0x4C, wxTRANSLATE("0x400004C-MOSAIC"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("BG H Size (4 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("BG V Size (4 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("OBJ H Size (4 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("OBJ V Size (4 bits,W)"), - } - }, - { - &BLDMOD, 0x50, wxTRANSLATE("0x4000050-BLDMOD"), 0x3FFF, - { - wxTRANSLATE("1st BG0"), - wxTRANSLATE("1st BG1"), - wxTRANSLATE("1st BG2"), - wxTRANSLATE("1st BG3"), - wxTRANSLATE("1st OBJ"), - wxTRANSLATE("1st BD"), - wxT(""), - wxTRANSLATE("FX Type (2 bits)"), - wxTRANSLATE("2nd BG0"), - wxTRANSLATE("2nd BG1"), - wxTRANSLATE("2nd BG2"), - wxTRANSLATE("2nd BG3"), - wxTRANSLATE("2nd OBJ"), - wxTRANSLATE("2nd BD"), - wxT(""), - wxT(""), - } - }, - { - &COLEV, 0x52, wxTRANSLATE("0x4000052-COLEV"), 0x1F1F, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Coefficient EVA (5 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Coefficient EVB (5 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &COLY, 0x54, wxTRANSLATE("0x4000054-COLEY"), 0x001F, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Coefficient EVY (5 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x60, wxTRANSLATE("0x4000060-SG10_L"), 0x007F, - { - wxT(""), - wxT(""), - wxTRANSLATE("Sweep Shifts (3 bits)"), - wxTRANSLATE("Sweep addition/decrease"), - wxT(""), - wxT(""), - wxTRANSLATE("Sweep Time (3 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x62, wxTRANSLATE("0x4000062-SG10_H"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Length (6 bits,W)"), - wxT(""), - wxTRANSLATE("Waveform Type (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Steps (3 bits)"), - wxTRANSLATE("Envelope Attenuate/Amplify"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Initial Value"), - } - }, - { - NULL, 0x64, wxTRANSLATE("0x4000064-SG11"), 0xC7FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Frequency (11 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Continuous/Counter"), - wxTRANSLATE("Initialization (W)"), - } - }, - { - NULL, 0x68, wxTRANSLATE("0x4000068-SG20"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Length (6 bits,W)"), - wxT(""), - wxTRANSLATE("Waveform Type (2 bits)"), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Steps (3 bits)"), - wxTRANSLATE("Envelope Attenuate/Amplify"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Initial Value"), - } - }, - { - NULL, 0x6C, wxTRANSLATE("0x400006C-SG21"), 0xC7FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Frequency (11 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Continuous/Counter"), - wxTRANSLATE("Initialization (W)"), - } - }, - { - NULL, 0x70, wxTRANSLATE("0x4000070-SG30_L"), 0x00E0, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Waveform 32/64 Steps"), - wxTRANSLATE("Waveform Bank 0/1"), - wxTRANSLATE("Sound Output"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x72, wxTRANSLATE("0x4000072-SG30_H"), 0xE0FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Length (8 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Output Level (2 bits)"), - wxTRANSLATE("Forced 3/4 Output Level"), - } - }, - { - NULL, 0x74, wxTRANSLATE("0x4000074-SG31"), 0xC7FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Frequency (11 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Continuous/Counter"), - wxTRANSLATE("Initialization (W)"), - } - }, - { - NULL, 0x78, wxTRANSLATE("0x4000078-SG40"), 0xFF3F, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Length (6 bits,W)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Steps (3 bits)"), - wxTRANSLATE("Envelope Attenuate/Amplify"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Envelope Initial Value"), - } - }, - { - NULL, 0x7C, wxTRANSLATE("0x400007C-SG41"), 0xC0FF, - { - wxT(""), - wxT(""), - wxTRANSLATE("Dividing Ratio Freq. (3 bits)"), - wxTRANSLATE("Counter 15/7 Steps"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Counter Shift Clock (4 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sound Continuous/Counter"), - wxTRANSLATE("Initialization (W)"), - } - }, - { - NULL, 0x80, wxTRANSLATE("0x4000080-SGCNT0_L"), 0xFF77, - { - wxT(""), - wxT(""), - wxTRANSLATE("Right Volume (3 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Left Volume (3 bits)"), - wxT(""), - wxTRANSLATE("Channel 1->Right"), - wxTRANSLATE("Channel 2->Right"), - wxTRANSLATE("Channel 3->Right"), - wxTRANSLATE("Channel 4->Right"), - wxTRANSLATE("Channel 1->Left"), - wxTRANSLATE("Channel 2->Left"), - wxTRANSLATE("Channel 3->Left"), - wxTRANSLATE("Channel 4->Left"), - } - }, - { - NULL, 0x82, wxTRANSLATE("0x4000082-SGCNT0_H"), 0xFF0F, - { - wxT(""), - wxTRANSLATE("Sound 1-4 Volume (2 bits)"), - wxTRANSLATE("DMA Sound A Volume"), - wxTRANSLATE("DMA Sound B Volume"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("DMA Sound A->Right"), - wxTRANSLATE("DMA Sound A->Left"), - wxTRANSLATE("DMA Sound A Timer"), - wxTRANSLATE("DMA Sound A Reset FIFO"), - wxTRANSLATE("DMA Sound B->Right"), - wxTRANSLATE("DMA Sound B->Left"), - wxTRANSLATE("DMA Sound B Timer"), - wxTRANSLATE("DMA Sound B Reset FIFO"), - } - }, - { - NULL, 0x84, wxTRANSLATE("0x4000084-SGCNT1"), 0x0080, - { - wxTRANSLATE("Sound 1 On"), - wxTRANSLATE("Sound 2 On"), - wxTRANSLATE("Sound 3 On"), - wxTRANSLATE("Sound 4 On"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Master Sound Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x88, wxTRANSLATE("0x4000088-SGBIAS"), 0xC3FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Bias Level (10 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Sampling Rate (2 bits)"), - } - }, - { - NULL, 0xA0, wxTRANSLATE("0x40000A0-SIGFIFOA_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 0 (8 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 1 (8 bits)"), - } - }, - { - NULL, 0xA2, wxTRANSLATE("0x40000A2-SIGFIFOA_H"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 2 (8 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 3 (8 bits)"), - } - }, - { - NULL, 0xA4, wxTRANSLATE("0x40000A4-SIGFIFOB_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 0 (8 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 1 (8 bits)"), - } - }, - { - NULL, 0xA6, wxTRANSLATE("0x40000A6-SIGFIFOB_H"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 2 (8 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Data 3 (8 bits)"), - } - }, - { - &DM0SAD_L, 0xB0, wxTRANSLATE("0x40000B0-DM0SAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (lower 16 bits)"), - } - }, - { - &DM0SAD_H, 0xB2, wxTRANSLATE("0x40000B2-DM0SAD_H"), 0x07FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (upper 11 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM0DAD_L, 0xB4, wxTRANSLATE("0x40000B4-DM0DAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (lower 16 bits)"), - } - }, - { - &DM0DAD_H, 0xB6, wxTRANSLATE("0x40000B6-DM0DAD_H"), 0x07FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (upper 11 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM0CNT_L, 0xB8, wxTRANSLATE("0x40000B8-DM0CNT_L"), 0x3FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Count (14 bits)"), - wxT(""), - wxT(""), - } - }, - { - &DM0CNT_H, 0xBA, wxTRANSLATE("0x40000BA-DM0CNT_H"), 0xF7E0, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address Control (2 bits)"), - wxT(""), - wxTRANSLATE("Source Address Control (2 bits)"), - wxTRANSLATE("Repeat"), - wxTRANSLATE("Transfer Type"), - wxT(""), - wxT(""), - wxTRANSLATE("Start Timing (2 bits)"), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - } - }, - { - &DM1SAD_L, 0xBC, wxTRANSLATE("0x40000BC-DM1SAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (lower 16 bits)"), - } - }, - { - &DM1SAD_H, 0xBE, wxTRANSLATE("0x40000BE-DM1SAD_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (upper 12 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM1DAD_L, 0xC0, wxTRANSLATE("0x40000C0-DM1DAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (lower 16 bits)"), - } - }, - { - &DM1DAD_H, 0xC2, wxTRANSLATE("0x40000C2-DM1DAD_H"), 0x07FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (upper 11 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM1CNT_L, 0xC4, wxTRANSLATE("0x40000C4-DM1CNT_L"), 0x3FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Count (14 bits)"), - wxT(""), - wxT(""), - } - }, - { - &DM1CNT_H, 0xC6, wxTRANSLATE("0x40000C6-DM1CNT_H"), 0xF7E0, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address Control (2 bits)"), - wxT(""), - wxTRANSLATE("Source Address Control (2 bits)"), - wxTRANSLATE("Repeat"), - wxTRANSLATE("Transfer Type"), - wxT(""), - wxT(""), - wxTRANSLATE("Start Timing (2 bits)"), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - } - }, - { - &DM2SAD_L, 0xC8, wxTRANSLATE("0x40000C8-DM2SAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (lower 16 bits)"), - } - }, - { - &DM2SAD_H, 0xCA, wxTRANSLATE("0x40000CA-DM2SAD_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (upper 12 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM2DAD_L, 0xCC, wxTRANSLATE("0x40000CC-DM2DAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (lower 16 bits)"), - } - }, - { - &DM2DAD_H, 0xCE, wxTRANSLATE("0x40000CE-DM2DAD_H"), 0x07FF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (upper 11 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM2CNT_L, 0xD0, wxTRANSLATE("0x40000D0-DM2CNT_L"), 0x3FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Count (14 bits)"), - wxT(""), - wxT(""), - } - }, - { - &DM2CNT_H, 0xD2, wxTRANSLATE("0x40000D2-DM2CNT_H"), 0xF7E0, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address Control (2 bits)"), - wxT(""), - wxTRANSLATE("Source Address Control (2 bits)"), - wxTRANSLATE("Repeat"), - wxTRANSLATE("Transfer Type"), - wxT(""), - wxT(""), - wxTRANSLATE("Start Timing (2 bits)"), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - } - }, - { - &DM3SAD_L, 0xD4, wxTRANSLATE("0x40000D4-DM3SAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (lower 16 bits)"), - } - }, - { - &DM3SAD_H, 0xD6, wxTRANSLATE("0x40000D6-DM3SAD_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Source Address (upper 12 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM3DAD_L, 0xD8, wxTRANSLATE("0x40000D8-DM3DAD_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (lower 16 bits)"), - } - }, - { - &DM3DAD_H, 0xDA, wxTRANSLATE("0x40000DA-DM3DAD_H"), 0x0FFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address (upper 12 bits)"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &DM3CNT_L, 0xDC, wxTRANSLATE("0x40000DC-DM3CNT_L"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Count (16 bits)"), - } - }, - { - &DM3CNT_H, 0xDE, wxTRANSLATE("0x40000DE-DM3CNT_H"), 0xFFE0, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Destination Address Control (2 bits)"), - wxT(""), - wxTRANSLATE("Source Address Control (2 bits)"), - wxTRANSLATE("Repeat"), - wxTRANSLATE("Transfer Type"), - wxTRANSLATE("Game Pak Data Request"), - wxT(""), - wxTRANSLATE("Start Timing (2 bits)"), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - } - }, - { - &TM0D, 0x100, wxTRANSLATE("0x4000100-TM0D"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Timer Counter (16 bits)"), - } - }, - { - &TM0CNT, 0x102, wxTRANSLATE("0x4000102-TM0CNT"), 0x00C7, - { - wxT(""), - wxTRANSLATE("Scalar Selection (2 bits)"), - wxTRANSLATE("Count Up"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &TM1D, 0x104, wxTRANSLATE("0x4000104-TM1D"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Timer Counter (16 bits)"), - } - }, - { - &TM1CNT, 0x106, wxTRANSLATE("0x4000106-TM1CNT"), 0x00C7, - { - wxT(""), - wxTRANSLATE("Scalar Selection (2 bits)"), - wxTRANSLATE("Count Up"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &TM2D, 0x108, wxTRANSLATE("0x4000108-TM2D"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Timer Counter (16 bits)"), - } - }, - { - &TM2CNT, 0x10A, wxTRANSLATE("0x400010A-TM2CNT"), 0x00C7, - { - wxT(""), - wxTRANSLATE("Scalar Selection (2 bits)"), - wxTRANSLATE("Count Up"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &TM3D, 0x10C, wxTRANSLATE("0x400010C-TM3D"), 0xFFFF, - { - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Timer Counter (16 bits)"), - } - }, - { - &TM3CNT, 0x10E, wxTRANSLATE("0x400010E-TM3CNT"), 0x00C7, - { - wxT(""), - wxTRANSLATE("Scalar Selection (2 bits)"), - wxTRANSLATE("Count Up"), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - &P1, 0x130, wxTRANSLATE("0x4000130-P1"), 0x03FF, - { - wxTRANSLATE("A"), - wxTRANSLATE("B"), - wxTRANSLATE("Select"), - wxTRANSLATE("Start"), - wxTRANSLATE("Right"), - wxTRANSLATE("Left"), - wxTRANSLATE("Up"), - wxTRANSLATE("Down"), - wxTRANSLATE("Shoulder Right"), - wxTRANSLATE("Shoulder Left"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x132, wxTRANSLATE("0x4000132-P1CNT"), 0xC3FF, - { - wxTRANSLATE("A"), - wxTRANSLATE("B"), - wxTRANSLATE("Select"), - wxTRANSLATE("Start"), - wxTRANSLATE("Right"), - wxTRANSLATE("Left"), - wxTRANSLATE("Up"), - wxTRANSLATE("Down"), - wxTRANSLATE("Shoulder Right"), - wxTRANSLATE("Shoulder Left"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Interrupt Request"), - wxTRANSLATE("Interrupt Condition"), - } - }, - { - &IE, 0x200, wxTRANSLATE("0x4000200-IE"), 0x3FFF, - { - wxTRANSLATE("VBlank"), - wxTRANSLATE("HBlank"), - wxTRANSLATE("VCount"), - wxTRANSLATE("Timer 0"), - wxTRANSLATE("Timer 1"), - wxTRANSLATE("Timer 2"), - wxTRANSLATE("Timer 3"), - wxTRANSLATE("Serial"), - wxTRANSLATE("DMA 0"), - wxTRANSLATE("DMA 1"), - wxTRANSLATE("DMA 2"), - wxTRANSLATE("DMA 3"), - wxTRANSLATE("Keypad"), - wxTRANSLATE("Game Pak"), - wxT(""), - wxT(""), - } - }, - { - &IF, 0x202, wxTRANSLATE("0x4000202-IF"), 0x0000, - { - wxTRANSLATE("VBlank"), - wxTRANSLATE("HBlank"), - wxTRANSLATE("VCount"), - wxTRANSLATE("Timer 0"), - wxTRANSLATE("Timer 1"), - wxTRANSLATE("Timer 2"), - wxTRANSLATE("Timer 3"), - wxTRANSLATE("Serial"), - wxTRANSLATE("DMA 0"), - wxTRANSLATE("DMA 1"), - wxTRANSLATE("DMA 2"), - wxTRANSLATE("DMA 3"), - wxTRANSLATE("Keypad"), - wxTRANSLATE("Game Pak"), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x204, wxTRANSLATE("0x4000204-WAITCNT"), 0x5FFF, - { - wxT(""), - wxTRANSLATE("SRAM Wait Control (2 bits)"), - wxT(""), - wxTRANSLATE("Wait State 0 First Access (2 bits)"), - wxTRANSLATE("Wait State 0 Second Access"), - wxT(""), - wxTRANSLATE("Wait State 1 First Access (2 bits)"), - wxTRANSLATE("Wait State 1 Second Access"), - wxT(""), - wxTRANSLATE("Wait State 2 First Access (2 bits)"), - wxTRANSLATE("Wait State 2 Second Access"), - wxT(""), - wxTRANSLATE("PHI Terminal Output (2 bits)"), - wxT(""), - wxTRANSLATE("Game Pak Prefetch Buffer"), - wxTRANSLATE("Game Pak Type Flag"), - } - }, - { - &IME, 0x208, wxTRANSLATE("0x4000208-IME"), 0x0001, - { - wxTRANSLATE("Master Interrupt Enable"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - } - }, - { - NULL, 0x300, wxTRANSLATE("0x4000300-HALTCNT"), 0x8001, - { - wxTRANSLATE("First Boot"), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxT(""), - wxTRANSLATE("Power Down"), - } - }, -}; +/* const */ IOData ioregs[] = // not const so tranlation can be done once + { + { &DISPCNT, + 0, + wxTRANSLATE("0x4000000-DISPCNT"), + 0xFFF7, + { wxT(""), + wxT(""), + wxTRANSLATE("BG Mode (3 bits)"), + wxTRANSLATE("CGB Mode"), + wxTRANSLATE("Display Frame"), + wxTRANSLATE("H-Blank Interval OBJ processing"), + wxTRANSLATE("OBJ Character mapping"), + wxTRANSLATE("Forced blank"), + wxTRANSLATE("BG0"), + wxTRANSLATE("BG1"), + wxTRANSLATE("BG2"), + wxTRANSLATE("BG3"), + wxTRANSLATE("OBJ"), + wxTRANSLATE("WIN0"), + wxTRANSLATE("WIN1"), + wxTRANSLATE("OBJWIN") } }, + { &DISPSTAT, + 4, + wxTRANSLATE("0x4000004-DISPSTAT"), + 0xFF38, + { wxTRANSLATE("V-Blank Status"), + wxTRANSLATE("H-Blank Status"), + wxTRANSLATE("VCOUNT Evaluation"), + wxTRANSLATE("V-Blank Interrupt Enable"), + wxTRANSLATE("H-Blank Interrupt Enable"), + wxTRANSLATE("VCOUNT Match Interrupt Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("VCOUNT setting (8 bits)") } }, + { &VCOUNT, + 6, + wxTRANSLATE("0x4000006-VCOUNT"), + 0x0000, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("VCOUNT (8 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG0CNT, + 8, + wxTRANSLATE("0x4000008-BG0CNT"), + 0xDFCF, + { wxT(""), + wxTRANSLATE("Priority (2 bits)"), + wxT(""), + wxTRANSLATE("Char base (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Mosaic"), + wxTRANSLATE("16/256 colors"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Screen Base Block (5 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Size (2 bits)") } }, + { &BG1CNT, + 0xA, + wxTRANSLATE("0x400000A-BG1CNT"), + 0xDFCF, + { wxT(""), + wxTRANSLATE("Priority (2 bits)"), + wxT(""), + wxTRANSLATE("Char base (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Mosaic"), + wxTRANSLATE("16/256 colors"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Screen Base Block (5 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Size (2 bits)") } }, + { &BG2CNT, + 0xC, + wxTRANSLATE("0x400000C-BG2CNT"), + 0xFFCF, + { wxT(""), + wxTRANSLATE("Priority (2 bits)"), + wxT(""), + wxTRANSLATE("Char base (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Mosaic"), + wxTRANSLATE("16/256 colors"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Screen Base Block (5 bits)"), + wxTRANSLATE("Area Overflow"), + wxT(""), + wxTRANSLATE("Size (2 bits)") } }, + { &BG3CNT, + 0xE, + wxTRANSLATE("0x400000E-BG3CNT"), + 0xFFCF, + { wxT(""), + wxTRANSLATE("Priority (2 bits)"), + wxT(""), + wxTRANSLATE("Char base (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Mosaic"), + wxTRANSLATE("16/256 colors"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Screen Base Block (5 bits)"), + wxTRANSLATE("Area Overflow"), + wxT(""), + wxTRANSLATE("Size (2 bits)") } }, + { &BG0HOFS, + 0x10, + wxTRANSLATE("0x4000010-BG0HOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Horizontal Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG0VOFS, + 0x12, + wxTRANSLATE("0x4000012-BG0VOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Vertical Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG1HOFS, + 0x14, + wxTRANSLATE("0x4000014-BG1HOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Horizontal Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG1VOFS, + 0x16, + wxTRANSLATE("0x4000016-BG1VOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Vertical Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG2HOFS, + 0x18, + wxTRANSLATE("0x4000018-BG2HOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Horizontal Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG2VOFS, + 0x1A, + wxTRANSLATE("0x400001A-BG2VOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Vertical Offset (9 bits, W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG3HOFS, + 0x1C, + wxTRANSLATE("0x400001C-BG3HOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Horizontal Offset (9 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG3VOFS, + 0x1E, + wxTRANSLATE("0x400001E-BG3VOFS"), + 0x01FF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Vertical Offset (9 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT("") } }, + { &BG2PA, + 0x20, + wxTRANSLATE("0x4000020-BG2PA"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dx (16 bits,W)") } }, + { &BG2PB, + 0x22, + wxTRANSLATE("0x4000022-BG2PB"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dmx (16 bits,W)") } }, + { &BG2PC, + 0x24, + wxTRANSLATE("0x4000024-BG2PC"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dy (16 bits,W)") } }, + { &BG2PD, + 0x26, + wxTRANSLATE("0x4000026-BG2PD"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dmy (16 bits,W)") } }, + { &BG2X_L, + 0x28, + wxTRANSLATE("0x4000028-BG2X_L"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("X low bits (16 bits,W)") } }, + { &BG2X_H, + 0x2A, + wxTRANSLATE("0x400002A-BG2X_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("X high bits (12 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &BG2Y_L, + 0x2C, + wxTRANSLATE("0x400002C-BG2Y_L"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Y low bits (16 bits,W)") } }, + { &BG2Y_H, + 0x2E, + wxTRANSLATE("0x400002E-BG2Y_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Y hight bits (12 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &BG3PA, + 0x30, + wxTRANSLATE("0x4000030-BG3PA"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dx (16 bits,W)") } }, + { &BG3PB, + 0x32, + wxTRANSLATE("0x4000032-BG3PB"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dmx (16 bits,W)") } }, + { &BG3PC, + 0x34, + wxTRANSLATE("0x4000034-BG3PC"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dy (16 bits,W)") } }, + { &BG3PD, + 0x36, + wxTRANSLATE("0x4000036-BG3PD"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("dmy (16 bits,W)") } }, + { &BG3X_L, + 0x38, + wxTRANSLATE("0x4000038-BG3X_L"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("X low bits (16 bits,W)") } }, + { &BG3X_H, + 0x3A, + wxTRANSLATE("0x400003A-BG3X_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("X hight bits (12 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &BG3Y_L, + 0x3C, + wxTRANSLATE("0x400003C-BG3Y_L"), + 0xFFFF, + { wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Y low bits (16 bits,W)") } }, + { &BG3Y_H, + 0x3E, + wxTRANSLATE("0x400003E-BG3Y_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Y hight bits (12 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &WIN0H, + 0x40, + wxTRANSLATE("0x4000040-WIN0H"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 0 lower-right X (8 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 0 upper-left X (8 bits,W)"), + } }, + { &WIN1H, + 0x42, + wxTRANSLATE("0x4000042-WIN1H"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 1 lower-right X (8 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 1 upper-left (8 bits,W)"), + } }, + { &WIN0V, + 0x44, + wxTRANSLATE("0x4000044-WIN0V"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 0 lower-right Y (8 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 0 upper-left Y (8 bits,W)"), + } }, + { &WIN1V, + 0x46, + wxTRANSLATE("0x4000046-WIN1V"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 1 lower-right Y (8 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Win 1 upper-left Y (8 bits,W)"), + } }, + { &WININ, + 0x48, + wxTRANSLATE("0x4000048-WININ"), + 0x3F3F, + { + wxTRANSLATE("WIN0 BG0"), + wxTRANSLATE("WIN0 BG1"), + wxTRANSLATE("WIN0 BG2"), + wxTRANSLATE("WIN0 BG3"), + wxTRANSLATE("WIN0 OBJ"), + wxTRANSLATE("WIN0 Special FX"), + wxT(""), + wxT(""), + wxTRANSLATE("WIN1 BG0"), + wxTRANSLATE("WIN1 BG1"), + wxTRANSLATE("WIN1 BG2"), + wxTRANSLATE("WIN1 BG3"), + wxTRANSLATE("WIN1 OBJ"), + wxTRANSLATE("WIN1 Special FX"), + wxT(""), + wxT(""), + } }, + { &WINOUT, + 0x4A, + wxTRANSLATE("0x400004A-WINOUT"), + 0x3F3F, + { + wxTRANSLATE("WIN0/1 BG0"), + wxTRANSLATE("WIN0/1 BG1"), + wxTRANSLATE("WIN0/1 BG2"), + wxTRANSLATE("WIN0/1 BG3"), + wxTRANSLATE("WIN0/1 OBJ"), + wxTRANSLATE("WIN0/1 Special FX"), + wxT(""), + wxT(""), + wxTRANSLATE("OBJWIN BG0"), + wxTRANSLATE("OBJWIN BG1"), + wxTRANSLATE("OBJWIN BG2"), + wxTRANSLATE("OBJWIN BG3"), + wxTRANSLATE("OBJWIN OBJ"), + wxTRANSLATE("OBJWIN Special FX"), + wxT(""), + wxT(""), + } }, + { &MOSAIC, + 0x4C, + wxTRANSLATE("0x400004C-MOSAIC"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("BG H Size (4 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("BG V Size (4 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("OBJ H Size (4 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("OBJ V Size (4 bits,W)"), + } }, + { &BLDMOD, + 0x50, + wxTRANSLATE("0x4000050-BLDMOD"), + 0x3FFF, + { + wxTRANSLATE("1st BG0"), + wxTRANSLATE("1st BG1"), + wxTRANSLATE("1st BG2"), + wxTRANSLATE("1st BG3"), + wxTRANSLATE("1st OBJ"), + wxTRANSLATE("1st BD"), + wxT(""), + wxTRANSLATE("FX Type (2 bits)"), + wxTRANSLATE("2nd BG0"), + wxTRANSLATE("2nd BG1"), + wxTRANSLATE("2nd BG2"), + wxTRANSLATE("2nd BG3"), + wxTRANSLATE("2nd OBJ"), + wxTRANSLATE("2nd BD"), + wxT(""), + wxT(""), + } }, + { &COLEV, + 0x52, + wxTRANSLATE("0x4000052-COLEV"), + 0x1F1F, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Coefficient EVA (5 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Coefficient EVB (5 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + } }, + { &COLY, + 0x54, + wxTRANSLATE("0x4000054-COLEY"), + 0x001F, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Coefficient EVY (5 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x60, + wxTRANSLATE("0x4000060-SG10_L"), + 0x007F, + { + wxT(""), + wxT(""), + wxTRANSLATE("Sweep Shifts (3 bits)"), + wxTRANSLATE("Sweep addition/decrease"), + wxT(""), + wxT(""), + wxTRANSLATE("Sweep Time (3 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x62, + wxTRANSLATE("0x4000062-SG10_H"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Length (6 bits,W)"), + wxT(""), + wxTRANSLATE("Waveform Type (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Steps (3 bits)"), + wxTRANSLATE("Envelope Attenuate/Amplify"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Initial Value"), + } }, + { NULL, + 0x64, + wxTRANSLATE("0x4000064-SG11"), + 0xC7FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Frequency (11 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Continuous/Counter"), + wxTRANSLATE("Initialization (W)"), + } }, + { NULL, + 0x68, + wxTRANSLATE("0x4000068-SG20"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Length (6 bits,W)"), + wxT(""), + wxTRANSLATE("Waveform Type (2 bits)"), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Steps (3 bits)"), + wxTRANSLATE("Envelope Attenuate/Amplify"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Initial Value"), + } }, + { NULL, + 0x6C, + wxTRANSLATE("0x400006C-SG21"), + 0xC7FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Frequency (11 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Continuous/Counter"), + wxTRANSLATE("Initialization (W)"), + } }, + { NULL, + 0x70, + wxTRANSLATE("0x4000070-SG30_L"), + 0x00E0, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Waveform 32/64 Steps"), + wxTRANSLATE("Waveform Bank 0/1"), + wxTRANSLATE("Sound Output"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x72, + wxTRANSLATE("0x4000072-SG30_H"), + 0xE0FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Length (8 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Output Level (2 bits)"), + wxTRANSLATE("Forced 3/4 Output Level"), + } }, + { NULL, + 0x74, + wxTRANSLATE("0x4000074-SG31"), + 0xC7FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Frequency (11 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Continuous/Counter"), + wxTRANSLATE("Initialization (W)"), + } }, + { NULL, + 0x78, + wxTRANSLATE("0x4000078-SG40"), + 0xFF3F, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Length (6 bits,W)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Steps (3 bits)"), + wxTRANSLATE("Envelope Attenuate/Amplify"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Envelope Initial Value"), + } }, + { NULL, + 0x7C, + wxTRANSLATE("0x400007C-SG41"), + 0xC0FF, + { + wxT(""), + wxT(""), + wxTRANSLATE("Dividing Ratio Freq. (3 bits)"), + wxTRANSLATE("Counter 15/7 Steps"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Counter Shift Clock (4 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sound Continuous/Counter"), + wxTRANSLATE("Initialization (W)"), + } }, + { NULL, + 0x80, + wxTRANSLATE("0x4000080-SGCNT0_L"), + 0xFF77, + { + wxT(""), + wxT(""), + wxTRANSLATE("Right Volume (3 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Left Volume (3 bits)"), + wxT(""), + wxTRANSLATE("Channel 1->Right"), + wxTRANSLATE("Channel 2->Right"), + wxTRANSLATE("Channel 3->Right"), + wxTRANSLATE("Channel 4->Right"), + wxTRANSLATE("Channel 1->Left"), + wxTRANSLATE("Channel 2->Left"), + wxTRANSLATE("Channel 3->Left"), + wxTRANSLATE("Channel 4->Left"), + } }, + { NULL, + 0x82, + wxTRANSLATE("0x4000082-SGCNT0_H"), + 0xFF0F, + { + wxT(""), + wxTRANSLATE("Sound 1-4 Volume (2 bits)"), + wxTRANSLATE("DMA Sound A Volume"), + wxTRANSLATE("DMA Sound B Volume"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("DMA Sound A->Right"), + wxTRANSLATE("DMA Sound A->Left"), + wxTRANSLATE("DMA Sound A Timer"), + wxTRANSLATE("DMA Sound A Reset FIFO"), + wxTRANSLATE("DMA Sound B->Right"), + wxTRANSLATE("DMA Sound B->Left"), + wxTRANSLATE("DMA Sound B Timer"), + wxTRANSLATE("DMA Sound B Reset FIFO"), + } }, + { NULL, + 0x84, + wxTRANSLATE("0x4000084-SGCNT1"), + 0x0080, + { + wxTRANSLATE("Sound 1 On"), + wxTRANSLATE("Sound 2 On"), + wxTRANSLATE("Sound 3 On"), + wxTRANSLATE("Sound 4 On"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Master Sound Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x88, + wxTRANSLATE("0x4000088-SGBIAS"), + 0xC3FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Bias Level (10 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Sampling Rate (2 bits)"), + } }, + { NULL, + 0xA0, + wxTRANSLATE("0x40000A0-SIGFIFOA_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 0 (8 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 1 (8 bits)"), + } }, + { NULL, + 0xA2, + wxTRANSLATE("0x40000A2-SIGFIFOA_H"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 2 (8 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 3 (8 bits)"), + } }, + { NULL, + 0xA4, + wxTRANSLATE("0x40000A4-SIGFIFOB_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 0 (8 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 1 (8 bits)"), + } }, + { NULL, + 0xA6, + wxTRANSLATE("0x40000A6-SIGFIFOB_H"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 2 (8 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Data 3 (8 bits)"), + } }, + { &DM0SAD_L, + 0xB0, + wxTRANSLATE("0x40000B0-DM0SAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (lower 16 bits)"), + } }, + { &DM0SAD_H, + 0xB2, + wxTRANSLATE("0x40000B2-DM0SAD_H"), + 0x07FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (upper 11 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM0DAD_L, + 0xB4, + wxTRANSLATE("0x40000B4-DM0DAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (lower 16 bits)"), + } }, + { &DM0DAD_H, + 0xB6, + wxTRANSLATE("0x40000B6-DM0DAD_H"), + 0x07FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (upper 11 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM0CNT_L, + 0xB8, + wxTRANSLATE("0x40000B8-DM0CNT_L"), + 0x3FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Count (14 bits)"), + wxT(""), + wxT(""), + } }, + { &DM0CNT_H, + 0xBA, + wxTRANSLATE("0x40000BA-DM0CNT_H"), + 0xF7E0, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address Control (2 bits)"), + wxT(""), + wxTRANSLATE("Source Address Control (2 bits)"), + wxTRANSLATE("Repeat"), + wxTRANSLATE("Transfer Type"), + wxT(""), + wxT(""), + wxTRANSLATE("Start Timing (2 bits)"), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + } }, + { &DM1SAD_L, + 0xBC, + wxTRANSLATE("0x40000BC-DM1SAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (lower 16 bits)"), + } }, + { &DM1SAD_H, + 0xBE, + wxTRANSLATE("0x40000BE-DM1SAD_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (upper 12 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM1DAD_L, + 0xC0, + wxTRANSLATE("0x40000C0-DM1DAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (lower 16 bits)"), + } }, + { &DM1DAD_H, + 0xC2, + wxTRANSLATE("0x40000C2-DM1DAD_H"), + 0x07FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (upper 11 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM1CNT_L, + 0xC4, + wxTRANSLATE("0x40000C4-DM1CNT_L"), + 0x3FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Count (14 bits)"), + wxT(""), + wxT(""), + } }, + { &DM1CNT_H, + 0xC6, + wxTRANSLATE("0x40000C6-DM1CNT_H"), + 0xF7E0, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address Control (2 bits)"), + wxT(""), + wxTRANSLATE("Source Address Control (2 bits)"), + wxTRANSLATE("Repeat"), + wxTRANSLATE("Transfer Type"), + wxT(""), + wxT(""), + wxTRANSLATE("Start Timing (2 bits)"), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + } }, + { &DM2SAD_L, + 0xC8, + wxTRANSLATE("0x40000C8-DM2SAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (lower 16 bits)"), + } }, + { &DM2SAD_H, + 0xCA, + wxTRANSLATE("0x40000CA-DM2SAD_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (upper 12 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM2DAD_L, + 0xCC, + wxTRANSLATE("0x40000CC-DM2DAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (lower 16 bits)"), + } }, + { &DM2DAD_H, + 0xCE, + wxTRANSLATE("0x40000CE-DM2DAD_H"), + 0x07FF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (upper 11 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM2CNT_L, + 0xD0, + wxTRANSLATE("0x40000D0-DM2CNT_L"), + 0x3FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Count (14 bits)"), + wxT(""), + wxT(""), + } }, + { &DM2CNT_H, + 0xD2, + wxTRANSLATE("0x40000D2-DM2CNT_H"), + 0xF7E0, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address Control (2 bits)"), + wxT(""), + wxTRANSLATE("Source Address Control (2 bits)"), + wxTRANSLATE("Repeat"), + wxTRANSLATE("Transfer Type"), + wxT(""), + wxT(""), + wxTRANSLATE("Start Timing (2 bits)"), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + } }, + { &DM3SAD_L, + 0xD4, + wxTRANSLATE("0x40000D4-DM3SAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (lower 16 bits)"), + } }, + { &DM3SAD_H, + 0xD6, + wxTRANSLATE("0x40000D6-DM3SAD_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Source Address (upper 12 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM3DAD_L, + 0xD8, + wxTRANSLATE("0x40000D8-DM3DAD_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (lower 16 bits)"), + } }, + { &DM3DAD_H, + 0xDA, + wxTRANSLATE("0x40000DA-DM3DAD_H"), + 0x0FFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address (upper 12 bits)"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &DM3CNT_L, + 0xDC, + wxTRANSLATE("0x40000DC-DM3CNT_L"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Count (16 bits)"), + } }, + { &DM3CNT_H, + 0xDE, + wxTRANSLATE("0x40000DE-DM3CNT_H"), + 0xFFE0, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Destination Address Control (2 bits)"), + wxT(""), + wxTRANSLATE("Source Address Control (2 bits)"), + wxTRANSLATE("Repeat"), + wxTRANSLATE("Transfer Type"), + wxTRANSLATE("Game Pak Data Request"), + wxT(""), + wxTRANSLATE("Start Timing (2 bits)"), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + } }, + { &TM0D, + 0x100, + wxTRANSLATE("0x4000100-TM0D"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Timer Counter (16 bits)"), + } }, + { &TM0CNT, + 0x102, + wxTRANSLATE("0x4000102-TM0CNT"), + 0x00C7, + { + wxT(""), + wxTRANSLATE("Scalar Selection (2 bits)"), + wxTRANSLATE("Count Up"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &TM1D, + 0x104, + wxTRANSLATE("0x4000104-TM1D"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Timer Counter (16 bits)"), + } }, + { &TM1CNT, + 0x106, + wxTRANSLATE("0x4000106-TM1CNT"), + 0x00C7, + { + wxT(""), + wxTRANSLATE("Scalar Selection (2 bits)"), + wxTRANSLATE("Count Up"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &TM2D, + 0x108, + wxTRANSLATE("0x4000108-TM2D"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Timer Counter (16 bits)"), + } }, + { &TM2CNT, + 0x10A, + wxTRANSLATE("0x400010A-TM2CNT"), + 0x00C7, + { + wxT(""), + wxTRANSLATE("Scalar Selection (2 bits)"), + wxTRANSLATE("Count Up"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &TM3D, + 0x10C, + wxTRANSLATE("0x400010C-TM3D"), + 0xFFFF, + { + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Timer Counter (16 bits)"), + } }, + { &TM3CNT, + 0x10E, + wxTRANSLATE("0x400010E-TM3CNT"), + 0x00C7, + { + wxT(""), + wxTRANSLATE("Scalar Selection (2 bits)"), + wxTRANSLATE("Count Up"), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { &P1, + 0x130, + wxTRANSLATE("0x4000130-P1"), + 0x03FF, + { + wxTRANSLATE("A"), + wxTRANSLATE("B"), + wxTRANSLATE("Select"), + wxTRANSLATE("Start"), + wxTRANSLATE("Right"), + wxTRANSLATE("Left"), + wxTRANSLATE("Up"), + wxTRANSLATE("Down"), + wxTRANSLATE("Shoulder Right"), + wxTRANSLATE("Shoulder Left"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x132, + wxTRANSLATE("0x4000132-P1CNT"), + 0xC3FF, + { + wxTRANSLATE("A"), + wxTRANSLATE("B"), + wxTRANSLATE("Select"), + wxTRANSLATE("Start"), + wxTRANSLATE("Right"), + wxTRANSLATE("Left"), + wxTRANSLATE("Up"), + wxTRANSLATE("Down"), + wxTRANSLATE("Shoulder Right"), + wxTRANSLATE("Shoulder Left"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Interrupt Request"), + wxTRANSLATE("Interrupt Condition"), + } }, + { &IE, + 0x200, + wxTRANSLATE("0x4000200-IE"), + 0x3FFF, + { + wxTRANSLATE("VBlank"), + wxTRANSLATE("HBlank"), + wxTRANSLATE("VCount"), + wxTRANSLATE("Timer 0"), + wxTRANSLATE("Timer 1"), + wxTRANSLATE("Timer 2"), + wxTRANSLATE("Timer 3"), + wxTRANSLATE("Serial"), + wxTRANSLATE("DMA 0"), + wxTRANSLATE("DMA 1"), + wxTRANSLATE("DMA 2"), + wxTRANSLATE("DMA 3"), + wxTRANSLATE("Keypad"), + wxTRANSLATE("Game Pak"), + wxT(""), + wxT(""), + } }, + { &IF, + 0x202, + wxTRANSLATE("0x4000202-IF"), + 0x0000, + { + wxTRANSLATE("VBlank"), + wxTRANSLATE("HBlank"), + wxTRANSLATE("VCount"), + wxTRANSLATE("Timer 0"), + wxTRANSLATE("Timer 1"), + wxTRANSLATE("Timer 2"), + wxTRANSLATE("Timer 3"), + wxTRANSLATE("Serial"), + wxTRANSLATE("DMA 0"), + wxTRANSLATE("DMA 1"), + wxTRANSLATE("DMA 2"), + wxTRANSLATE("DMA 3"), + wxTRANSLATE("Keypad"), + wxTRANSLATE("Game Pak"), + wxT(""), + wxT(""), + } }, + { NULL, + 0x204, + wxTRANSLATE("0x4000204-WAITCNT"), + 0x5FFF, + { + wxT(""), + wxTRANSLATE("SRAM Wait Control (2 bits)"), + wxT(""), + wxTRANSLATE("Wait State 0 First Access (2 bits)"), + wxTRANSLATE("Wait State 0 Second Access"), + wxT(""), + wxTRANSLATE("Wait State 1 First Access (2 bits)"), + wxTRANSLATE("Wait State 1 Second Access"), + wxT(""), + wxTRANSLATE("Wait State 2 First Access (2 bits)"), + wxTRANSLATE("Wait State 2 Second Access"), + wxT(""), + wxTRANSLATE("PHI Terminal Output (2 bits)"), + wxT(""), + wxTRANSLATE("Game Pak Prefetch Buffer"), + wxTRANSLATE("Game Pak Type Flag"), + } }, + { &IME, + 0x208, + wxTRANSLATE("0x4000208-IME"), + 0x0001, + { + wxTRANSLATE("Master Interrupt Enable"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + } }, + { NULL, + 0x300, + wxTRANSLATE("0x4000300-HALTCNT"), + 0x8001, + { + wxTRANSLATE("First Boot"), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxT(""), + wxTRANSLATE("Power Down"), + } }, + }; -#define NUM_IOREGS (sizeof(ioregs)/sizeof(ioregs[0])) +#define NUM_IOREGS (sizeof(ioregs) / sizeof(ioregs[0])) diff --git a/src/wx/openal.h b/src/wx/openal.h index d8f47634..cc88d891 100644 --- a/src/wx/openal.h +++ b/src/wx/openal.h @@ -15,110 +15,110 @@ // since the ALC typedefs are broken on Mac: #ifdef __WXMAC__ -typedef ALCcontext* (ALC_APIENTRY* LPALCCREATECONTEXT)(ALCdevice* device, const ALCint* attrlist); -typedef ALCboolean(ALC_APIENTRY* LPALCMAKECONTEXTCURRENT)(ALCcontext* context); -typedef void (ALC_APIENTRY* LPALCDESTROYCONTEXT)(ALCcontext* context); -typedef ALCdevice* (ALC_APIENTRY* LPALCOPENDEVICE)(const ALCchar* devicename); -typedef ALCboolean(ALC_APIENTRY* LPALCCLOSEDEVICE)(ALCdevice* device); -typedef ALCboolean(ALC_APIENTRY* LPALCISEXTENSIONPRESENT)(ALCdevice* device, const ALCchar* extname); -typedef const ALCchar* (ALC_APIENTRY* LPALCGETSTRING)(ALCdevice* device, ALCenum param); +typedef ALCcontext *(ALC_APIENTRY *LPALCCREATECONTEXT)(ALCdevice *device, const ALCint *attrlist); +typedef ALCboolean(ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)(ALCcontext *context); +typedef void(ALC_APIENTRY *LPALCDESTROYCONTEXT)(ALCcontext *context); +typedef ALCdevice *(ALC_APIENTRY *LPALCOPENDEVICE)(const ALCchar *devicename); +typedef ALCboolean(ALC_APIENTRY *LPALCCLOSEDEVICE)(ALCdevice *device); +typedef ALCboolean(ALC_APIENTRY *LPALCISEXTENSIONPRESENT)(ALCdevice *device, + const ALCchar *extname); +typedef const ALCchar *(ALC_APIENTRY *LPALCGETSTRING)(ALCdevice *device, ALCenum param); #endif // no more use of copyrighted OpenAL code just to load the stupid library -struct OPENALFNTABLE -{ - //LPALENABLE alEnable; - //LPALDISABLE alDisable; - //LPALISENABLED alIsEnabled; - //LPALGETSTRING alGetString; - //LPALGETBOOLEANV alGetBooleanv; - //LPALGETINTEGERV alGetIntegerv; - //LPALGETFLOATV alGetFloatv; - //LPALGETDOUBLEV alGetDoublev; - //LPALGETBOOLEAN alGetBoolean; - //LPALGETINTEGER alGetInteger; - //LPALGETFLOAT alGetFloat; - //LPALGETDOUBLE alGetDouble; - LPALGETERROR alGetError; - LPALISEXTENSIONPRESENT alIsExtensionPresent; - //LPALGETPROCADDRESS alGetProcAddress; - //LPALGETENUMVALUE alGetEnumValue; - //LPALLISTENERF alListenerf; - //LPALLISTENER3F alListener3f; - //LPALLISTENERFV alListenerfv; - //LPALLISTENERI alListeneri; - //LPALLISTENER3I alListener3i; - //LPALLISTENERIV alListeneriv; - //LPALGETLISTENERF alGetListenerf; - //LPALGETLISTENER3F alGetListener3f; - //LPALGETLISTENERFV alGetListenerfv; - //LPALGETLISTENERI alGetListeneri; - //LPALGETLISTENER3I alGetListener3i; - //LPALGETLISTENERIV alGetListeneriv; - LPALGENSOURCES alGenSources; - LPALDELETESOURCES alDeleteSources; - //LPALISSOURCE alIsSource; - //LPALSOURCEF alSourcef; - //LPALSOURCE3F alSource3f; - //LPALSOURCEFV alSourcefv; - LPALSOURCEI alSourcei; - //LPALSOURCE3I alSource3i; - //LPALSOURCEIV alSourceiv; - //LPALGETSOURCEF alGetSourcef; - //LPALGETSOURCE3F alGetSource3f; - //LPALGETSOURCEFV alGetSourcefv; - LPALGETSOURCEI alGetSourcei; - //LPALGETSOURCE3I alGetSource3i; - //LPALGETSOURCEIV alGetSourceiv; - //LPALSOURCEPLAYV alSourcePlayv; - //LPALSOURCESTOPV alSourceStopv; - //LPALSOURCEREWINDV alSourceRewindv; - //LPALSOURCEPAUSEV alSourcePausev; - LPALSOURCEPLAY alSourcePlay; - LPALSOURCESTOP alSourceStop; - //LPALSOURCEREWIND alSourceRewind; - LPALSOURCEPAUSE alSourcePause; - LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers; - LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers; - LPALGENBUFFERS alGenBuffers; - LPALDELETEBUFFERS alDeleteBuffers; - //LPALISBUFFER alIsBuffer; - LPALBUFFERDATA alBufferData; - //LPALBUFFERF alBufferf; - //LPALBUFFER3F alBuffer3f; - //LPALBUFFERFV alBufferfv; - //LPALBUFFERI alBufferi; - //LPALBUFFER3I alBuffer3i; - //LPALBUFFERIV alBufferiv; - //LPALGETBUFFERF alGetBufferf; - //LPALGETBUFFER3F alGetBuffer3f; - //LPALGETBUFFERFV alGetBufferfv; - //LPALGETBUFFERI alGetBufferi; - //LPALGETBUFFER3I alGetBuffer3i; - //LPALGETBUFFERIV alGetBufferiv; - //LPALDOPPLERFACTOR alDopplerFactor; - //LPALDOPPLERVELOCITY alDopplerVelocity; - //LPALSPEEDOFSOUND alSpeedOfSound; - //LPALDISTANCEMODEL alDistanceModel; +struct OPENALFNTABLE { + // LPALENABLE alEnable; + // LPALDISABLE alDisable; + // LPALISENABLED alIsEnabled; + // LPALGETSTRING alGetString; + // LPALGETBOOLEANV alGetBooleanv; + // LPALGETINTEGERV alGetIntegerv; + // LPALGETFLOATV alGetFloatv; + // LPALGETDOUBLEV alGetDoublev; + // LPALGETBOOLEAN alGetBoolean; + // LPALGETINTEGER alGetInteger; + // LPALGETFLOAT alGetFloat; + // LPALGETDOUBLE alGetDouble; + LPALGETERROR alGetError; + LPALISEXTENSIONPRESENT alIsExtensionPresent; + // LPALGETPROCADDRESS alGetProcAddress; + // LPALGETENUMVALUE alGetEnumValue; + // LPALLISTENERF alListenerf; + // LPALLISTENER3F alListener3f; + // LPALLISTENERFV alListenerfv; + // LPALLISTENERI alListeneri; + // LPALLISTENER3I alListener3i; + // LPALLISTENERIV alListeneriv; + // LPALGETLISTENERF alGetListenerf; + // LPALGETLISTENER3F alGetListener3f; + // LPALGETLISTENERFV alGetListenerfv; + // LPALGETLISTENERI alGetListeneri; + // LPALGETLISTENER3I alGetListener3i; + // LPALGETLISTENERIV alGetListeneriv; + LPALGENSOURCES alGenSources; + LPALDELETESOURCES alDeleteSources; + // LPALISSOURCE alIsSource; + // LPALSOURCEF alSourcef; + // LPALSOURCE3F alSource3f; + // LPALSOURCEFV alSourcefv; + LPALSOURCEI alSourcei; + // LPALSOURCE3I alSource3i; + // LPALSOURCEIV alSourceiv; + // LPALGETSOURCEF alGetSourcef; + // LPALGETSOURCE3F alGetSource3f; + // LPALGETSOURCEFV alGetSourcefv; + LPALGETSOURCEI alGetSourcei; + // LPALGETSOURCE3I alGetSource3i; + // LPALGETSOURCEIV alGetSourceiv; + // LPALSOURCEPLAYV alSourcePlayv; + // LPALSOURCESTOPV alSourceStopv; + // LPALSOURCEREWINDV alSourceRewindv; + // LPALSOURCEPAUSEV alSourcePausev; + LPALSOURCEPLAY alSourcePlay; + LPALSOURCESTOP alSourceStop; + // LPALSOURCEREWIND alSourceRewind; + LPALSOURCEPAUSE alSourcePause; + LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers; + LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers; + LPALGENBUFFERS alGenBuffers; + LPALDELETEBUFFERS alDeleteBuffers; + // LPALISBUFFER alIsBuffer; + LPALBUFFERDATA alBufferData; + // LPALBUFFERF alBufferf; + // LPALBUFFER3F alBuffer3f; + // LPALBUFFERFV alBufferfv; + // LPALBUFFERI alBufferi; + // LPALBUFFER3I alBuffer3i; + // LPALBUFFERIV alBufferiv; + // LPALGETBUFFERF alGetBufferf; + // LPALGETBUFFER3F alGetBuffer3f; + // LPALGETBUFFERFV alGetBufferfv; + // LPALGETBUFFERI alGetBufferi; + // LPALGETBUFFER3I alGetBuffer3i; + // LPALGETBUFFERIV alGetBufferiv; + // LPALDOPPLERFACTOR alDopplerFactor; + // LPALDOPPLERVELOCITY alDopplerVelocity; + // LPALSPEEDOFSOUND alSpeedOfSound; + // LPALDISTANCEMODEL alDistanceModel; - LPALCCREATECONTEXT alcCreateContext; - LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; - //LPALCPROCESSCONTEXT alcProcessContext; - //LPALCSUSPENDCONTEXT alcSuspendContext; - LPALCDESTROYCONTEXT alcDestroyContext; - //LPALCGETCURRENTCONTEXT alcGetCurrentContext; - //LPALCGETCONTEXTSDEVICE alcGetContextsDevice; - LPALCOPENDEVICE alcOpenDevice; - LPALCCLOSEDEVICE alcCloseDevice; - //LPALCGETERROR alcGetError; - LPALCISEXTENSIONPRESENT alcIsExtensionPresent; - //LPALCGETPROCADDRESS alcGetProcAddress; - //LPALCGETENUMVALUE alcGetEnumValue; - LPALCGETSTRING alcGetString; - //LPALCGETINTEGERV alcGetIntegerv; - //LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice; - //LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice; - //LPALCCAPTURESTART alcCaptureStart; - //LPALCCAPTURESTOP alcCaptureStop; - //LPALCCAPTURESAMPLES alcCaptureSamples; + LPALCCREATECONTEXT alcCreateContext; + LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; + // LPALCPROCESSCONTEXT alcProcessContext; + // LPALCSUSPENDCONTEXT alcSuspendContext; + LPALCDESTROYCONTEXT alcDestroyContext; + // LPALCGETCURRENTCONTEXT alcGetCurrentContext; + // LPALCGETCONTEXTSDEVICE alcGetContextsDevice; + LPALCOPENDEVICE alcOpenDevice; + LPALCCLOSEDEVICE alcCloseDevice; + // LPALCGETERROR alcGetError; + LPALCISEXTENSIONPRESENT alcIsExtensionPresent; + // LPALCGETPROCADDRESS alcGetProcAddress; + // LPALCGETENUMVALUE alcGetEnumValue; + LPALCGETSTRING alcGetString; + // LPALCGETINTEGERV alcGetIntegerv; + // LPALCCAPTUREOPENDEVICE alcCaptureOpenDevice; + // LPALCCAPTURECLOSEDEVICE alcCaptureCloseDevice; + // LPALCCAPTURESTART alcCaptureStart; + // LPALCCAPTURESTOP alcCaptureStop; + // LPALCCAPTURESAMPLES alcCaptureSamples; }; diff --git a/src/wx/opts.h b/src/wx/opts.h index 8aee3302..6dedca5c 100644 --- a/src/wx/opts.h +++ b/src/wx/opts.h @@ -2,101 +2,99 @@ #define WX_OPTS_H #define NUM_KEYS 21 -extern const wxChar* const joynames[NUM_KEYS]; +extern const wxChar *const joynames[NUM_KEYS]; extern wxJoyKeyBinding defkeys[NUM_KEYS * 2]; // keyboard + joystick defaults -extern struct opts_t -{ - opts_t(); - // while I would normally put large objects in front to reduce gaps, - // I instead organized this by opts.cpp table order +extern struct opts_t { + opts_t(); + // while I would normally put large objects in front to reduce gaps, + // I instead organized this by opts.cpp table order - /// Display - bool bilinear; - int filter; - wxString filter_plugin; - int ifb; - wxVideoMode fs_mode; - int max_threads; - int render_method; - int video_scale; - bool retain_aspect; - bool keep_on_top; + /// Display + bool bilinear; + int filter; + wxString filter_plugin; + int ifb; + wxVideoMode fs_mode; + int max_threads; + int render_method; + int video_scale; + bool retain_aspect; + bool keep_on_top; - /// GB - wxString gb_bios; - wxString gbc_bios; - // u16 systemGbPalette[8*3]; - bool print_auto_page, print_screen_cap; - wxString gb_rom_dir; - wxString gbc_rom_dir; + /// GB + wxString gb_bios; + wxString gbc_bios; + // u16 systemGbPalette[8*3]; + bool print_auto_page, print_screen_cap; + wxString gb_rom_dir; + wxString gbc_rom_dir; - /// GBA - wxString gba_bios; - int gba_link_type; - wxString link_host; - int link_proto; - bool link_auto; - wxString gba_rom_dir; + /// GBA + wxString gba_bios; + int gba_link_type; + wxString link_host; + int link_proto; + bool link_auto; + wxString gba_rom_dir; - /// General - bool autoload_state, autoload_cheats; - wxString battery_dir; - int onlineupdates; - long last_update; - wxString last_updated_filename; - bool recent_freeze; - wxString recording_dir; - int rewind_interval; - wxString scrshot_dir; - wxString state_dir; - int statusbar; + /// General + bool autoload_state, autoload_cheats; + wxString battery_dir; + int onlineupdates; + long last_update; + wxString last_updated_filename; + bool recent_freeze; + wxString recording_dir; + int rewind_interval; + wxString scrshot_dir; + wxString state_dir; + int statusbar; - /// Joypad - wxJoyKeyBinding_v joykey_bindings[4][NUM_KEYS]; - int autofire_rate; - int default_stick; + /// Joypad + wxJoyKeyBinding_v joykey_bindings[4][NUM_KEYS]; + int autofire_rate; + int default_stick; - /// Keyboard - wxAcceleratorEntry_v accels; + /// Keyboard + wxAcceleratorEntry_v accels; - /// Sound - int audio_api; - int audio_buffers; - wxString audio_dev; - int sound_en; // soundSetEnable() - int gba_sound_filter; - bool soundInterpolation; - bool gb_declick; - int gb_echo; - bool gb_effects_config_enabled; - bool dsound_hw_accel; - int gb_stereo; - bool gb_effects_config_surround; - int sound_qual; // soundSetSampleRate() / gbSoundSetSampleRate() - int sound_vol; // soundSetVolume() - bool upmix; // xa2 only + /// Sound + int audio_api; + int audio_buffers; + wxString audio_dev; + int sound_en; // soundSetEnable() + int gba_sound_filter; + bool soundInterpolation; + bool gb_declick; + int gb_echo; + bool gb_effects_config_enabled; + bool dsound_hw_accel; + int gb_stereo; + bool gb_effects_config_surround; + int sound_qual; // soundSetSampleRate() / gbSoundSetSampleRate() + int sound_vol; // soundSetVolume() + bool upmix; // xa2 only - /// Recent - wxFileHistory* recent; + /// Recent + wxFileHistory *recent; - /// wxWindows - // wxWidgets-generated options (opaque) + /// wxWindows + // wxWidgets-generated options (opaque) } gopts; -extern struct opt_desc -{ - const wxChar* opt; - const char* cmd; - const wxChar* desc; - wxString* stropt; - int* intopt; - const wxChar* enumvals; - int min, max; - bool* boolopt; - // current configured value - wxString curstr; - int curint; +extern struct opt_desc { + const wxChar *opt; + const char *cmd; + const wxChar *desc; + wxString *stropt; + int *intopt; + const wxChar *enumvals; + int min, max; + bool *boolopt; + // current configured value + wxString curstr; + int curint; #define curbool curint } opts[]; extern const int num_opts; @@ -112,6 +110,6 @@ void load_opts(); // will detect changes and write config if necessary void update_opts(); // returns true if option name correct; prints error if val invalid -bool opt_set(const wxChar* name, const wxChar* val); +bool opt_set(const wxChar *name, const wxChar *val); #endif /* WX_OPTS_H */ diff --git a/src/wx/viewsupt.h b/src/wx/viewsupt.h index a9911fe4..61b36795 100644 --- a/src/wx/viewsupt.h +++ b/src/wx/viewsupt.h @@ -1,8 +1,8 @@ #ifndef WX_VIEWSUPT_H #define WX_VIEWSUPT_H -#include #include +#include // avoid exporting too much stuff namespace Viewers @@ -13,54 +13,66 @@ namespace Viewers // - AutoUpdate checkbox toggles calling Update() every screen refresh class Viewer : public wxDialog { -public: - void CloseDlg(wxCloseEvent &ev); - Viewer(const wxChar* name); - virtual ~Viewer() {} - virtual void Update() = 0; - bool auto_update; + public: + void CloseDlg(wxCloseEvent &ev); + Viewer(const wxChar *name); + virtual ~Viewer() + { + } + virtual void Update() = 0; + bool auto_update; - // A lot of viewers have GUI elements to set parameters. Almost all - // of them just read back the value and update the display. This - // event handler does that with validators. - void ActiveCtrl(wxCommandEvent &ev); - void ActiveCtrlScr(wxScrollEvent &ev) { ActiveCtrl(ev); } - void ActiveCtrlSpin(wxSpinEvent &ev) { ActiveCtrl(ev); } + // A lot of viewers have GUI elements to set parameters. Almost all + // of them just read back the value and update the display. This + // event handler does that with validators. + void ActiveCtrl(wxCommandEvent &ev); + void ActiveCtrlScr(wxScrollEvent &ev) + { + ActiveCtrl(ev); + } + void ActiveCtrlSpin(wxSpinEvent &ev) + { + ActiveCtrl(ev); + } -protected: - const wxChar* dname; - void SetAutoUpdate(wxCommandEvent &ev) { auto_update = ev.IsChecked(); } + protected: + const wxChar *dname; + void SetAutoUpdate(wxCommandEvent &ev) + { + auto_update = ev.IsChecked(); + } - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; // on errors, abort program -#define baddialog() do { \ - wxLogError(_("Unable to load dialog %s from resources"), dname); \ - wxGetApp().frame->Close(true); \ - return; \ -} while(0) +#define baddialog() \ + do { \ + wxLogError(_("Unable to load dialog %s from resources"), dname); \ + wxGetApp().frame->Close(true); \ + return; \ + } while (0) // widgets to use with auto validator -#define getvfld(sv, n, t, v) do { \ - t *_w = sv XRCCTRL(*this, n, t); \ - if(!_w) \ - baddialog(); \ - _w->SetValidator(v); \ -} while(0) -#define getradio(sv, n, var, val) \ - getvfld(sv, n, wxRadioButton, wxBoolIntValidator(&var, val)) -#define getslider(sv, n, var) \ - getvfld(sv, n, wxSlider, wxGenericValidator(&var)) -#define getspin(sv, n, var) \ - getvfld(sv, n, wxSpinCtrl, wxGenericValidator(&var)) +#define getvfld(sv, n, t, v) \ + do { \ + t *_w = sv XRCCTRL(*this, n, t); \ + if (!_w) \ + baddialog(); \ + _w->SetValidator(v); \ + } while (0) +#define getradio(sv, n, var, val) getvfld(sv, n, wxRadioButton, wxBoolIntValidator(&var, val)) +#define getslider(sv, n, var) getvfld(sv, n, wxSlider, wxGenericValidator(&var)) +#define getspin(sv, n, var) getvfld(sv, n, wxSpinCtrl, wxGenericValidator(&var)) -#define LoadXRCViewer(t) do { \ - wxDialog *d = new Viewers::t##Viewer; \ - if(d) { \ - d->SetWindowStyle(wxCAPTION | wxRESIZE_BORDER); \ - d->Show(); } \ -} while(0) +#define LoadXRCViewer(t) \ + do { \ + wxDialog *d = new Viewers::t##Viewer; \ + if (d) { \ + d->SetWindowStyle(wxCAPTION | wxRESIZE_BORDER); \ + d->Show(); \ + } \ + } while (0) // a list box with no horizontal scrollbar and a funky vertical scrollbar: // range = 1 - 500 @@ -76,55 +88,64 @@ protected: class DisList : public wxPanel { -public: - DisList(); - // called after init to create subcontrols and size panel - void Refit(int cols); - void MoveSB(); - void MoveView(wxScrollEvent &ev); -private: - void RefillNeeded(); -public: - // called by parent's refill handler or any other time strings have - // changed - void Refill(); -private: - void Resize(wxSizeEvent &ev); - void SetSel(); + public: + DisList(); + // called after init to create subcontrols and size panel + void Refit(int cols); + void MoveSB(); + void MoveView(wxScrollEvent &ev); -public: - // make addr visible and then select it - void SetSel(u32 addr); - void UnSel() { issel = false; } + private: + void RefillNeeded(); - // currently visible lines - int nlines; - // at least nlines strings to display - wxArrayString strings; - // and their starting addrs (mostly for scrollbar) - wxArrayInt addrs; - // how far back to scroll for single line - int back_size; - // address of top line - u32 topaddr; - // max address for scrollbar - u32 maxaddr; -protected: - // assigned to textctrl to avoid mouse input - void MouseEvent(wxMouseEvent &ev) {} - // the subwidgets - wxTextCtrl tc; - wxScrollBar sb; - // cached computed line tc size - int lineheight, extraheight; - // need to know if tc/sb have been Create()d yet - bool didinit; - // selection info - u32 seladdr; - bool issel; + public: + // called by parent's refill handler or any other time strings have + // changed + void Refill(); - DECLARE_DYNAMIC_CLASS() // for xrc - DECLARE_EVENT_TABLE() + private: + void Resize(wxSizeEvent &ev); + void SetSel(); + + public: + // make addr visible and then select it + void SetSel(u32 addr); + void UnSel() + { + issel = false; + } + + // currently visible lines + int nlines; + // at least nlines strings to display + wxArrayString strings; + // and their starting addrs (mostly for scrollbar) + wxArrayInt addrs; + // how far back to scroll for single line + int back_size; + // address of top line + u32 topaddr; + // max address for scrollbar + u32 maxaddr; + + protected: + // assigned to textctrl to avoid mouse input + void MouseEvent(wxMouseEvent &ev) + { + } + // the subwidgets + wxTextCtrl tc; + wxScrollBar sb; + // cached computed line tc size + int lineheight, extraheight; + // need to know if tc/sb have been Create()d yet + bool didinit; + // selection info + u32 seladdr; + bool issel; + + DECLARE_DYNAMIC_CLASS() // for xrc + DECLARE_EVENT_TABLE() }; BEGIN_DECLARE_EVENT_TYPES() @@ -141,65 +162,69 @@ END_DECLARE_EVENT_TYPES() class MemView : public wxPanel { -public: - MemView(); - // called after init to create subcontrols and size panel - void Refit(); - void MoveSB(); - void MoveView(wxScrollEvent &ev); -private: - void RefillNeeded(); -public: - // called by parent's refill handler or any other time strings have - // changed - void Refill(); -private: - void Refill(wxDC &dc); - void RepaintEv(wxPaintEvent &ev); - void Repaint(); - void Resize(wxSizeEvent &ev); + public: + MemView(); + // called after init to create subcontrols and size panel + void Refit(); + void MoveSB(); + void MoveView(wxScrollEvent &ev); -public: - // make addr visible - void Show(u32 addr, bool force_update = false); + private: + void RefillNeeded(); - // current selection, or topaddr if none - u32 GetAddr(); - // currently visible lines - int nlines; - // at least nlines * 4 words to display - wxArrayInt words; - // address of top line - u32 topaddr; - // max address for scrollbar - u32 maxaddr; - // bytes per word == (1 << fmt) - int fmt; - // after write, these contain write addr and val - u32 writeaddr, writeval; - // when selection is made, this widget is updated w/ addr - wxControl* addrlab; -protected: - // easier than checking maxaddr - int addrlen; + public: + // called by parent's refill handler or any other time strings have + // changed + void Refill(); - void MouseEvent(wxMouseEvent &ev); - void KeyEvent(wxKeyEvent &ev); - // the subwidgets - wxPanel disp; - wxScrollBar sb; - wxCaret* caret; - // cached text size - int charheight, charwidth; - // need to know if tc/sb have been Create()d yet - bool didinit; - // selection info - int selnib, seladdr; - bool isasc; - void ShowCaret(); + private: + void Refill(wxDC &dc); + void RepaintEv(wxPaintEvent &ev); + void Repaint(); + void Resize(wxSizeEvent &ev); - DECLARE_DYNAMIC_CLASS() // for xrc - DECLARE_EVENT_TABLE() + public: + // make addr visible + void Show(u32 addr, bool force_update = false); + + // current selection, or topaddr if none + u32 GetAddr(); + // currently visible lines + int nlines; + // at least nlines * 4 words to display + wxArrayInt words; + // address of top line + u32 topaddr; + // max address for scrollbar + u32 maxaddr; + // bytes per word == (1 << fmt) + int fmt; + // after write, these contain write addr and val + u32 writeaddr, writeval; + // when selection is made, this widget is updated w/ addr + wxControl *addrlab; + + protected: + // easier than checking maxaddr + int addrlen; + + void MouseEvent(wxMouseEvent &ev); + void KeyEvent(wxKeyEvent &ev); + // the subwidgets + wxPanel disp; + wxScrollBar sb; + wxCaret *caret; + // cached text size + int charheight, charwidth; + // need to know if tc/sb have been Create()d yet + bool didinit; + // selection info + int selnib, seladdr; + bool isasc; + void ShowCaret(); + + DECLARE_DYNAMIC_CLASS() // for xrc + DECLARE_EVENT_TABLE() }; BEGIN_DECLARE_EVENT_TYPES() @@ -215,26 +240,33 @@ END_DECLARE_EVENT_TYPES() class ColorView : public wxControl { -public: - ColorView(wxWindow* parent, wxWindowID id); - void SetRGB(int r, int g, int b); - void GetRGB(int &_r, int &_g, int &_b) { _r = r; _g = g; _b = b; } + public: + ColorView(wxWindow *parent, wxWindowID id); + void SetRGB(int r, int g, int b); + void GetRGB(int &_r, int &_g, int &_b) + { + _r = r; + _g = g; + _b = b; + } -protected: - int r, g, b; - wxPanel* cp; - wxStaticText* rt, *gt, *bt; + protected: + int r, g, b; + wxPanel *cp; + wxStaticText *rt, *gt, *bt; }; -#define unkctrl(n, v) do { \ - if(!wxXmlResource::Get()->AttachUnknownControl(wxT(n), v, this)) \ - baddialog(); \ -} while(0) -#define colorctrl(v, n) do { \ - v = new ColorView(this, XRCID(n)); \ - if(!v) \ - baddialog(); \ - unkctrl(n, v); \ -} while(0) +#define unkctrl(n, v) \ + do { \ + if (!wxXmlResource::Get()->AttachUnknownControl(wxT(n), v, this)) \ + baddialog(); \ + } while (0) +#define colorctrl(v, n) \ + do { \ + v = new ColorView(this, XRCID(n)); \ + if (!v) \ + baddialog(); \ + unkctrl(n, v); \ + } while (0) // Display a small bitmap in jumbopixel style. If a pixel is selected, it // is highlighted with a border. For wxvbam, no event is generated. @@ -248,119 +280,135 @@ protected: class PixView : public wxPanel { -public: - PixView() : wxPanel(), bm(0) {} - bool InitBMP(int w = 8, int h = 8, ColorView* cv = NULL); - // stride is in pixels - // format is rgb24 (aka wxImage format) - // x/y is added to data and returned coords - // if data == NULL, bitmap will be reset to default (all-black) - virtual void SetData(const unsigned char* data, int stride, int x = 0, - int y = 0); - // desel if out of displayed range - void SetSel(int x, int y, bool dsel_cview_update = true); - // -1, -1 = no sel - void GetSel(int &x, int &y) - { - x = selx < 0 ? -1 : ox + selx; - y = sely < 0 ? -1 : oy + sely; - } - ColorView* cview; -protected: - wxImage im; - wxBitmap* bm; - void Redraw(wxPaintEvent &ev); - virtual void SelPoint(wxMouseEvent &ev); - int ox, oy, selx, sely; + public: + PixView() : wxPanel(), bm(0) + { + } + bool InitBMP(int w = 8, int h = 8, ColorView *cv = NULL); + // stride is in pixels + // format is rgb24 (aka wxImage format) + // x/y is added to data and returned coords + // if data == NULL, bitmap will be reset to default (all-black) + virtual void SetData(const unsigned char *data, int stride, int x = 0, int y = 0); + // desel if out of displayed range + void SetSel(int x, int y, bool dsel_cview_update = true); + // -1, -1 = no sel + void GetSel(int &x, int &y) + { + x = selx < 0 ? -1 : ox + selx; + y = sely < 0 ? -1 : oy + sely; + } + ColorView *cview; - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS() + protected: + wxImage im; + wxBitmap *bm; + void Redraw(wxPaintEvent &ev); + virtual void SelPoint(wxMouseEvent &ev); + int ox, oy, selx, sely; + + DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS() }; -#define pixview(v, n, w, h, cv) do { \ - v = XRCCTRL(*this, n, PixView); \ - if(!v) \ - baddialog(); \ - v->InitBMP(w, h, cv); \ -} while(0) +#define pixview(v, n, w, h, cv) \ + do { \ + v = XRCCTRL(*this, n, PixView); \ + if (!v) \ + baddialog(); \ + v->InitBMP(w, h, cv); \ + } while (0) // a graphics viewer panel; expected to be inside of a wxScrollWindow class GfxPanel : public wxPanel { -public: - GfxPanel() : wxPanel(), bm(0), selx(-1), sely(-1) {} - int bmw, bmh; - wxBitmap* bm; - wxImage* im; - PixView* pv; + public: + GfxPanel() : wxPanel(), bm(0), selx(-1), sely(-1) + { + } + int bmw, bmh; + wxBitmap *bm; + wxImage *im; + PixView *pv; -protected: - void DrawBitmap(wxPaintEvent &ev); - void Click(wxMouseEvent &ev); - void MouseMove(wxMouseEvent &ev); - void DoSel(wxMouseEvent &ev, bool force = false); -private: - int selx, sely; + protected: + void DrawBitmap(wxPaintEvent &ev); + void Click(wxMouseEvent &ev); + void MouseMove(wxMouseEvent &ev); + void DoSel(wxMouseEvent &ev, bool force = false); - DECLARE_DYNAMIC_CLASS() - DECLARE_EVENT_TABLE() + private: + int selx, sely; + + DECLARE_DYNAMIC_CLASS() + DECLARE_EVENT_TABLE() }; - BEGIN_DECLARE_EVENT_TYPES() // event generated on mouse click // generates wxMouseEvent with coords adjusted to original bitmap // size regardless of scaling DECLARE_LOCAL_EVENT_TYPE(EVT_COMMAND_GFX_CLICK, 0) END_DECLARE_EVENT_TYPES() -#define EVT_GFX_CLICK(id, fun) \ - DECLARE_EVENT_TABLE_ENTRY(EVT_COMMAND_GFX_CLICK, id, wxID_ANY, wxMouseEventHandler(fun), NULL), +#define EVT_GFX_CLICK(id, fun) \ + DECLARE_EVENT_TABLE_ENTRY(EVT_COMMAND_GFX_CLICK, \ + id, \ + wxID_ANY, \ + wxMouseEventHandler(fun), \ + NULL) \ + , // like Viewer, common stuff to all gfx viewers // this is what actually manages the GfxPanel class GfxViewer : public Viewer { -public: - GfxViewer(const wxChar* dname, int maxw, int maxh); - void ChangeBMP(); - void BMPSize(int w, int h); -protected: - void StretchTog(wxCommandEvent &ev); - void RefreshEv(wxCommandEvent &ev); - void SaveBMP(wxCommandEvent &ev); - wxImage image; - GfxPanel* gv; -private: - static wxString bmp_save_dir; - wxScrolledWindow* gvs; - wxCheckBox* str; + public: + GfxViewer(const wxChar *dname, int maxw, int maxh); + void ChangeBMP(); + void BMPSize(int w, int h); - DECLARE_EVENT_TABLE() + protected: + void StretchTog(wxCommandEvent &ev); + void RefreshEv(wxCommandEvent &ev); + void SaveBMP(wxCommandEvent &ev); + wxImage image; + GfxPanel *gv; + + private: + static wxString bmp_save_dir; + wxScrolledWindow *gvs; + wxCheckBox *str; + + DECLARE_EVENT_TABLE() }; // if the jumbopixel view is all there is, maybe send a GFX_CLICK.. class PixViewEvt : public PixView { - // generates a GFX_CLICK if a point is selected - void SetData(const unsigned char* data, int stride, int x = 0, - int y = 0); -protected: - // always generates a GFX_CLICK - void SelPoint(wxMouseEvent &ev); - void click(); - DECLARE_DYNAMIC_CLASS() + // generates a GFX_CLICK if a point is selected + void SetData(const unsigned char *data, int stride, int x = 0, int y = 0); + + protected: + // always generates a GFX_CLICK + void SelPoint(wxMouseEvent &ev); + void click(); + DECLARE_DYNAMIC_CLASS() }; // a display-only checkbox which does not look like it's disabled class DispCheckBox : public wxCheckBox { -public: - bool AcceptsFocus() { return false; } - void MouseEvent(wxMouseEvent &ev) {} - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS() + public: + bool AcceptsFocus() + { + return false; + } + void MouseEvent(wxMouseEvent &ev) + { + } + DECLARE_EVENT_TABLE() + DECLARE_DYNAMIC_CLASS() }; // standard widgets in graphical viewers - } #endif /* WX_VIEWSUPT_H */ diff --git a/src/wx/widgets/wx/checkedlistctrl.h b/src/wx/widgets/wx/checkedlistctrl.h index b90a63aa..15cb338d 100644 --- a/src/wx/widgets/wx/checkedlistctrl.h +++ b/src/wx/widgets/wx/checkedlistctrl.h @@ -9,31 +9,29 @@ // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// - #ifndef _WX_CHECKEDLISTCTRL_H_ #define _WX_CHECKEDLISTCTRL_H_ // wxWidgets headers -#include "wx/webupdatedef.h" // for the WXDLLIMPEXP_WEBUPDATE macro -#include +#include "wx/webupdatedef.h" // for the WXDLLIMPEXP_WEBUPDATE macro #include +#include #if wxUSE_CHECKEDLISTCTRL // image indexes (used internally by wxCheckedListCtrl) -#define wxCLC_UNCHECKED_IMGIDX 0 // unchecked & enabled -#define wxCLC_CHECKED_IMGIDX 1 // checked & enabled -#define wxCLC_DISABLED_UNCHECKED_IMGIDX 2 // unchecked & disabled -#define wxCLC_DISABLED_CHECKED_IMGIDX 3 // checked & disabled +#define wxCLC_UNCHECKED_IMGIDX 0 // unchecked & enabled +#define wxCLC_CHECKED_IMGIDX 1 // checked & enabled +#define wxCLC_DISABLED_UNCHECKED_IMGIDX 2 // unchecked & disabled +#define wxCLC_DISABLED_CHECKED_IMGIDX 3 // checked & disabled // additional state flags (wx's defines should end at 0x0100; see listbase.h) -#define wxLIST_STATE_CHECKED 0x010000 -#define wxLIST_STATE_ENABLED 0x100000 +#define wxLIST_STATE_CHECKED 0x010000 +#define wxLIST_STATE_ENABLED 0x100000 // additional wxCheckedListCtrl style flags // (wx's defines should at 0x8000; see listbase.h) -#define wxCLC_CHECK_WHEN_SELECTING 0x10000 - +#define wxCLC_CHECK_WHEN_SELECTING 0x10000 // ------------------------- // wxCheckedListCtrl events @@ -42,141 +40,158 @@ DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE, wxEVT_COMMAND_LIST_ITEM_CHECKED, -1); DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_WEBUPDATE, wxEVT_COMMAND_LIST_ITEM_UNCHECKED, -1); -#define EVT_LIST_ITEM_CHECKED(id, fn) \ - DECLARE_EVENT_TABLE_ENTRY( \ - wxEVT_COMMAND_LIST_ITEM_CHECKED, id, -1, \ - (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \ - (wxObject *) NULL \ - ), - -#define EVT_LIST_ITEM_UNCHECKED(id, fn) \ - DECLARE_EVENT_TABLE_ENTRY( \ - wxEVT_COMMAND_LIST_ITEM_UNCHECKED, id, -1, \ - (wxObjectEventFunction)(wxEventFunction)(wxListEventFunction)&fn, \ - (wxObject *) NULL \ - ), - +#define EVT_LIST_ITEM_CHECKED(id, fn) \ + DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_LIST_ITEM_CHECKED, \ + id, \ + -1, \ + (wxObjectEventFunction)(wxEventFunction)( \ + wxListEventFunction)&fn, \ + (wxObject *)NULL) \ + , +#define EVT_LIST_ITEM_UNCHECKED(id, fn) \ + DECLARE_EVENT_TABLE_ENTRY(wxEVT_COMMAND_LIST_ITEM_UNCHECKED, \ + id, \ + -1, \ + (wxObjectEventFunction)(wxEventFunction)( \ + wxListEventFunction)&fn, \ + (wxObject *)NULL) \ + , //! This is the class which performs all transactions with the server. //! It uses the wxSocket facilities. class WXDLLIMPEXP_WEBUPDATE wxCheckedListCtrl : public wxListCtrl { -protected: + protected: + // we have to keep a different array to keep track of the additional + // states we support.... + wxArrayInt m_stateList; - // we have to keep a different array to keep track of the additional - // states we support.... - wxArrayInt m_stateList; + // our set of checkbox images... + wxImageList m_imageList; - // our set of checkbox images... - wxImageList m_imageList; - -public: - wxCheckedListCtrl() + public: + wxCheckedListCtrl() #if CLC_VBAM_USAGE && CLC_USE_SYSICONS - : wxListCtrl(), m_imageList() {} + : wxListCtrl(), m_imageList() + { + } #else - : wxListCtrl(), m_imageList(16, 16, TRUE) {} + : wxListCtrl(), m_imageList(16, 16, TRUE) + { + } #endif - wxCheckedListCtrl(wxWindow* parent, wxWindowID id = -1, - const wxPoint &pt = wxDefaultPosition, - const wxSize &sz = wxDefaultSize, - long style = wxCLC_CHECK_WHEN_SELECTING, - const wxValidator &validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr) + wxCheckedListCtrl(wxWindow *parent, wxWindowID id = -1, + const wxPoint &pt = wxDefaultPosition, const wxSize &sz = wxDefaultSize, + long style = wxCLC_CHECK_WHEN_SELECTING, + const wxValidator &validator = wxDefaultValidator, + const wxString &name = wxListCtrlNameStr) #if CLC_VBAM_USAGE && CLC_USE_SYSICONS - : wxListCtrl(), m_imageList() + : wxListCtrl(), m_imageList() #else - : wxListCtrl(), m_imageList(16, 16, TRUE) + : wxListCtrl(), m_imageList(16, 16, TRUE) #endif - { Create(parent, id, pt, sz, style, validator, name); } + { + Create(parent, id, pt, sz, style, validator, name); + } - bool Create(wxWindow* parent, wxWindowID id = -1, - const wxPoint &pt = wxDefaultPosition, - const wxSize &sz = wxDefaultSize, - long style = wxCLC_CHECK_WHEN_SELECTING, - const wxValidator &validator = wxDefaultValidator, - const wxString &name = wxListCtrlNameStr); + bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint &pt = wxDefaultPosition, + const wxSize &sz = wxDefaultSize, long style = wxCLC_CHECK_WHEN_SELECTING, + const wxValidator &validator = wxDefaultValidator, + const wxString &name = wxListCtrlNameStr); #ifdef CLC_VBAM_USAGE - // for xrc usage, a separate init function is needed. - bool Init(); + // for xrc usage, a separate init function is needed. + bool Init(); #endif - virtual ~wxCheckedListCtrl() {} + virtual ~wxCheckedListCtrl() + { + } + public: // utilities + // core overloads (i.e. the most generic overloads) + bool GetItem(wxListItem &info) const; + bool SetItem(wxListItem &info); + long InsertItem(wxListItem &info); + bool DeleteItem(long item); + bool DeleteAllItems() + { + m_stateList.Clear(); + return wxListCtrl::DeleteAllItems(); + } -public: // utilities + bool SortItems(wxListCtrlCompare, long) + { + wxASSERT_MSG(0, wxT("Not implemented yet ! sorry... ")); + return FALSE; + } - // core overloads (i.e. the most generic overloads) - bool GetItem(wxListItem &info) const; - bool SetItem(wxListItem &info); - long InsertItem(wxListItem &info); - bool DeleteItem(long item); - bool DeleteAllItems() - { m_stateList.Clear(); return wxListCtrl::DeleteAllItems(); } + // shortcuts to the SetItemState function + void Check(long item, bool checked); + void Enable(long item, bool enable); + void CheckAll(bool checked = true); + void EnableAll(bool enable = true); - bool SortItems(wxListCtrlCompare, long) - { wxASSERT_MSG(0, wxT("Not implemented yet ! sorry... ")); return FALSE; } + // this needs to be redeclared otherwise it's hidden by our other Enable() function. + // However you should use #EnableAll instead of this function if you want to get + // good graphics (try to understand) + virtual bool Enable(bool enable = true) + { + return wxListCtrl::Enable(enable); + } - // shortcuts to the SetItemState function - void Check(long item, bool checked); - void Enable(long item, bool enable); - void CheckAll(bool checked = true); - void EnableAll(bool enable = true); + // shortcuts to the GetItemState function + bool IsChecked(long item) const + { + return GetItemState(item, wxLIST_STATE_CHECKED) != 0; + } + bool IsEnabled(long item) const + { + return GetItemState(item, wxLIST_STATE_ENABLED) != 0; + } - // this needs to be redeclared otherwise it's hidden by our other Enable() function. - // However you should use #EnableAll instead of this function if you want to get - // good graphics (try to understand) - virtual bool Enable(bool enable = true) - { return wxListCtrl::Enable(enable); } + // this needs to be redeclared otherwise it's hidden by our other IsEnabled() function. + bool IsEnabled() const + { + return wxWindow::IsEnabled(); + } - // shortcuts to the GetItemState function - bool IsChecked(long item) const - { return GetItemState(item, wxLIST_STATE_CHECKED) != 0; } - bool IsEnabled(long item) const - { return GetItemState(item, wxLIST_STATE_ENABLED) != 0; } + //! Returns the number of checked items in the control. + int GetCheckedItemCount() const; - // this needs to be redeclared otherwise it's hidden by our other IsEnabled() function. - bool IsEnabled() const - { return wxWindow::IsEnabled(); } + // we overload these so we are sure they will use our + // #GetItem and #SetItem functions... + bool SetItemState(long item, long state, long stateMask); + int GetItemState(long item, long stateMask) const; + long InsertItem(long index, const wxString &label, int imageIndex = -1); + long SetItem(long index, int col, const wxString &label, int imageId = -1); - //! Returns the number of checked items in the control. - int GetCheckedItemCount() const; + // the image associated with an element is already in used by wxCheckedListCtrl + // itself to show the checkbox and it cannot be handled by the user ! + bool SetItemImage(long, int) + { + wxASSERT_MSG(0, wxT("This function cannot be used with wxCheckedListCtrl !")); + return FALSE; + } - // we overload these so we are sure they will use our - // #GetItem and #SetItem functions... - bool SetItemState(long item, long state, long stateMask); - int GetItemState(long item, long stateMask) const; - long InsertItem(long index, const wxString &label, int imageIndex = -1); - long SetItem(long index, int col, const wxString &label, int imageId = -1); + protected: // event handlers + void OnMouseEvent(wxMouseEvent &event); - // the image associated with an element is already in used by wxCheckedListCtrl - // itself to show the checkbox and it cannot be handled by the user ! - bool SetItemImage(long, int) - { wxASSERT_MSG(0, wxT("This function cannot be used with wxCheckedListCtrl !")); return FALSE; } + protected: // internal utilities + static int GetItemImageFromAdditionalState(int addstate); + static int GetAndRemoveAdditionalState(long *state, int statemask); + wxColour GetBgColourFromAdditionalState(int additionalstate); -protected: // event handlers - - void OnMouseEvent(wxMouseEvent &event); - -protected: // internal utilities - - static int GetItemImageFromAdditionalState(int addstate); - static int GetAndRemoveAdditionalState(long* state, int statemask); - wxColour GetBgColourFromAdditionalState(int additionalstate); - -private: + private: #if CLC_VBAM_USAGE - DECLARE_DYNAMIC_CLASS(wxCheckedListCtrl) + DECLARE_DYNAMIC_CLASS(wxCheckedListCtrl) #else - DECLARE_CLASS(wxCheckedListCtrl) + DECLARE_CLASS(wxCheckedListCtrl) #endif - DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; +#endif // wxUSE_CHECKEDLISTCTRL -#endif // wxUSE_CHECKEDLISTCTRL - -#endif // _WX_CHECKEDLISTCTRL_H_ - +#endif // _WX_CHECKEDLISTCTRL_H_ diff --git a/src/wx/widgets/wx/joyedit.h b/src/wx/widgets/wx/joyedit.h index 63013357..7c2c3265 100644 --- a/src/wx/widgets/wx/joyedit.h +++ b/src/wx/widgets/wx/joyedit.h @@ -8,70 +8,89 @@ #include "wx/keyedit.h" #include "wx/sdljoy.h" -typedef struct wxJoyKeyBinding -{ - int key; // key code; listed first for easy static init - int mod; // modifier flags - int joy; // joystick # (starting at 1) - // if joy is non-0, key = control number, and mod = control type +typedef struct wxJoyKeyBinding { + int key; // key code; listed first for easy static init + int mod; // modifier flags + int joy; // joystick # (starting at 1) + // if joy is non-0, key = control number, and mod = control type } wxJoyKeyBinding; typedef std::vector wxJoyKeyBinding_v; // joystick control types // mod for joysticks -enum -{ - WXJB_AXIS_PLUS, WXJB_AXIS_MINUS, WXJB_BUTTON, WXJB_HAT_FIRST, - WXJB_HAT_N = WXJB_HAT_FIRST, WXJB_HAT_S, WXJB_HAT_W, WXJB_HAT_E, WXJB_HAT_NW, - WXJB_HAT_NE, WXJB_HAT_SW, WXJB_HAT_SE, WXJB_HAT_LAST = WXJB_HAT_SE -}; +enum { WXJB_AXIS_PLUS, + WXJB_AXIS_MINUS, + WXJB_BUTTON, + WXJB_HAT_FIRST, + WXJB_HAT_N = WXJB_HAT_FIRST, + WXJB_HAT_S, + WXJB_HAT_W, + WXJB_HAT_E, + WXJB_HAT_NW, + WXJB_HAT_NE, + WXJB_HAT_SW, + WXJB_HAT_SE, + WXJB_HAT_LAST = WXJB_HAT_SE }; class wxJoyKeyTextCtrl : public wxKeyTextCtrl { -public: - // default constructor; required for use with xrc - // FIXME: clearable and keyenter should be style flags - wxJoyKeyTextCtrl() : wxKeyTextCtrl() {} - virtual ~wxJoyKeyTextCtrl() {}; + public: + // default constructor; required for use with xrc + // FIXME: clearable and keyenter should be style flags + wxJoyKeyTextCtrl() : wxKeyTextCtrl() + { + } + virtual ~wxJoyKeyTextCtrl(){}; - // key is event.GetControlIndex(), and joy is event.GetJoy() + 1 - // mod is derived from GetControlValue() and GetControlType(): - // convert wxSDLJoyEvent's type+val into mod (WXJB_*) - static int DigitalButton(wxSDLJoyEvent &event); - // convert mod+key to accel string, separated by - - static wxString ToString(int mod, int key, int joy); - // convert multiple keys, separated by multikey - static wxString ToString(wxJoyKeyBinding_v keys, wxChar sep = wxT(',')); - // parses single key string into mod+key - static bool FromString(const wxString &s, int &mod, int &key, int &joy); - // parse multi-key string into array - // returns empty array on parse errors - static wxJoyKeyBinding_v FromString(const wxString &s, wxChar sep = wxT(',')); - // parse a single key in given wxChar array up to given len - static bool ParseString(const wxChar* s, int len, int &mod, int &key, int &joy); + // key is event.GetControlIndex(), and joy is event.GetJoy() + 1 + // mod is derived from GetControlValue() and GetControlType(): + // convert wxSDLJoyEvent's type+val into mod (WXJB_*) + static int DigitalButton(wxSDLJoyEvent &event); + // convert mod+key to accel string, separated by - + static wxString ToString(int mod, int key, int joy); + // convert multiple keys, separated by multikey + static wxString ToString(wxJoyKeyBinding_v keys, wxChar sep = wxT(',')); + // parses single key string into mod+key + static bool FromString(const wxString &s, int &mod, int &key, int &joy); + // parse multi-key string into array + // returns empty array on parse errors + static wxJoyKeyBinding_v FromString(const wxString &s, wxChar sep = wxT(',')); + // parse a single key in given wxChar array up to given len + static bool ParseString(const wxChar *s, int len, int &mod, int &key, int &joy); -protected: - void OnJoy(wxSDLJoyEvent &); + protected: + void OnJoy(wxSDLJoyEvent &); - DECLARE_DYNAMIC_CLASS(); - DECLARE_EVENT_TABLE(); + DECLARE_DYNAMIC_CLASS(); + DECLARE_EVENT_TABLE(); }; // A simple copy-only validator class wxJoyKeyValidator : public wxValidator { -public: - wxJoyKeyValidator(wxJoyKeyBinding_v* v) : wxValidator(), val(v) {} - wxJoyKeyValidator(const wxJoyKeyValidator &v) : wxValidator(), val(v.val) {} - wxObject* Clone() const { return new wxJoyKeyValidator(val); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - wxJoyKeyBinding_v* val; + public: + wxJoyKeyValidator(wxJoyKeyBinding_v *v) : wxValidator(), val(v) + { + } + wxJoyKeyValidator(const wxJoyKeyValidator &v) : wxValidator(), val(v.val) + { + } + wxObject *Clone() const + { + return new wxJoyKeyValidator(val); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } - DECLARE_CLASS(wxJoyKeyValidator) + protected: + wxJoyKeyBinding_v *val; + + DECLARE_CLASS(wxJoyKeyValidator) }; #endif /* WX_JOYKEYTEXT_H */ diff --git a/src/wx/widgets/wx/keyedit.h b/src/wx/widgets/wx/keyedit.h index 5e6748d5..e92d12d8 100644 --- a/src/wx/widgets/wx/keyedit.h +++ b/src/wx/widgets/wx/keyedit.h @@ -5,71 +5,101 @@ // The value is the symbolic name of the key pressed // Supports manual clearing (bs), multiple keys in widget, automatic tab on key -#include -#include #include +#include +#include typedef std::vector wxAcceleratorEntry_v; class wxKeyTextCtrl : public wxTextCtrl { -public: - // default constructor; required for use with xrc - // FIXME: clearable and keyenter should be style flags - wxKeyTextCtrl() : wxTextCtrl(), clearable(true), multikey(wxT(',')), - keyenter(true), lastmod(0), lastkey(0) {}; - virtual ~wxKeyTextCtrl() {}; + public: + // default constructor; required for use with xrc + // FIXME: clearable and keyenter should be style flags + wxKeyTextCtrl() + : wxTextCtrl(), clearable(true), multikey(wxT(',')), keyenter(true), lastmod(0), + lastkey(0){}; + virtual ~wxKeyTextCtrl(){}; - void SetClearable(bool set = true) { clearable = set; } - void SetMultikey(wxChar c = wxT(',')) { multikey = c; } - void SetKeyEnter(bool set = true) { keyenter = set; } + void SetClearable(bool set = true) + { + clearable = set; + } + void SetMultikey(wxChar c = wxT(',')) + { + multikey = c; + } + void SetKeyEnter(bool set = true) + { + keyenter = set; + } - bool GetClearable() { return clearable; } - wxChar GetMultikey() { return multikey; } - bool GetKeyEnter() { return keyenter; } + bool GetClearable() + { + return clearable; + } + wxChar GetMultikey() + { + return multikey; + } + bool GetKeyEnter() + { + return keyenter; + } - // convert mod+key to accel string, separated by - - static wxString ToString(int mod, int key); - // convert multiple keys, separated by multikey - static wxString ToString(wxAcceleratorEntry_v keys, wxChar sep = wxT(',')); - // parses single key string into mod+key - static bool FromString(const wxString &s, int &mod, int &key); - // parse multi-key string into accelentry array - // note that meta flag may be set in accelentry array item even - // where not supported for accelerators (i.e. non-mac) - // returns empty array on parse errors - static wxAcceleratorEntry_v FromString(const wxString &s, wxChar sep = wxT(',')); - // parse a single key in given wxChar array up to given len - static bool ParseString(const wxChar* s, int len, int &mod, int &key); + // convert mod+key to accel string, separated by - + static wxString ToString(int mod, int key); + // convert multiple keys, separated by multikey + static wxString ToString(wxAcceleratorEntry_v keys, wxChar sep = wxT(',')); + // parses single key string into mod+key + static bool FromString(const wxString &s, int &mod, int &key); + // parse multi-key string into accelentry array + // note that meta flag may be set in accelentry array item even + // where not supported for accelerators (i.e. non-mac) + // returns empty array on parse errors + static wxAcceleratorEntry_v FromString(const wxString &s, wxChar sep = wxT(',')); + // parse a single key in given wxChar array up to given len + static bool ParseString(const wxChar *s, int len, int &mod, int &key); -protected: - void OnKeyDown(wxKeyEvent &); - void OnKeyUp(wxKeyEvent &); + protected: + void OnKeyDown(wxKeyEvent &); + void OnKeyUp(wxKeyEvent &); - bool clearable; - wxChar multikey; - bool keyenter; - // the last keydown event received; this is processed on next keyup - int lastmod, lastkey; + bool clearable; + wxChar multikey; + bool keyenter; + // the last keydown event received; this is processed on next keyup + int lastmod, lastkey; - DECLARE_DYNAMIC_CLASS(); - DECLARE_EVENT_TABLE(); + DECLARE_DYNAMIC_CLASS(); + DECLARE_EVENT_TABLE(); }; // A simple copy-only validator class wxKeyValidator : public wxValidator { -public: - wxKeyValidator(wxAcceleratorEntry_v* v) : wxValidator(), val(v) {} - wxKeyValidator(const wxKeyValidator &v) : wxValidator(), val(v.val) {} - wxObject* Clone() const { return new wxKeyValidator(val); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - wxAcceleratorEntry_v* val; + public: + wxKeyValidator(wxAcceleratorEntry_v *v) : wxValidator(), val(v) + { + } + wxKeyValidator(const wxKeyValidator &v) : wxValidator(), val(v.val) + { + } + wxObject *Clone() const + { + return new wxKeyValidator(val); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } - DECLARE_CLASS(wxKeyValidator) + protected: + wxAcceleratorEntry_v *val; + + DECLARE_CLASS(wxKeyValidator) }; #endif /* WX_KEYTEXT_H */ diff --git a/src/wx/widgets/wx/sdljoy.h b/src/wx/widgets/wx/sdljoy.h index 19004cfc..87dee472 100644 --- a/src/wx/widgets/wx/sdljoy.h +++ b/src/wx/widgets/wx/sdljoy.h @@ -17,87 +17,118 @@ typedef struct wxSDLJoyState wxSDLJoyState_t; class wxSDLJoy : public wxTimer { -public: - // if analog, send events for all axis movement - // otherwise, only send events when values cross the 50% mark - // and max out values - wxSDLJoy(bool analog = false); - // but flag can be set later - void SetAnalog(bool analog = true) { digital = !analog; }; - // send events to this handler - // If NULL (default), send to window with keyboard focus - wxEvtHandler* Attach(wxEvtHandler*); - // add another joystick to the list of polled sticks - // -1 == add all - // If joy > # of joysticks, it is ignored - // This will start polling if a valid joystick is selected - void Add(int joy = -1); - // remove a joystick from the polled sticks - // -1 == remove all - // If joy > # of joysticks, it is ignored - // This will stop polling if all joysticks are disabled - void Remove(int joy = -1); - // query if a stick is being polled - bool IsPolling(int joy); - // query # of joysticks - int GetNumJoysticks() { return njoy; } - // query # of axes on given joystick - // 0 is returned if joy is invalid - int GetNumAxes(int joy); - // query # of hats on given joystick - // 0 is returned if joy is invalid - int GetNumHats(int joy); - // query # of buttons on given joystick - // 0 is returned if joy is invalid - int GetNumButtons(int joy); + public: + // if analog, send events for all axis movement + // otherwise, only send events when values cross the 50% mark + // and max out values + wxSDLJoy(bool analog = false); + // but flag can be set later + void SetAnalog(bool analog = true) + { + digital = !analog; + }; + // send events to this handler + // If NULL (default), send to window with keyboard focus + wxEvtHandler *Attach(wxEvtHandler *); + // add another joystick to the list of polled sticks + // -1 == add all + // If joy > # of joysticks, it is ignored + // This will start polling if a valid joystick is selected + void Add(int joy = -1); + // remove a joystick from the polled sticks + // -1 == remove all + // If joy > # of joysticks, it is ignored + // This will stop polling if all joysticks are disabled + void Remove(int joy = -1); + // query if a stick is being polled + bool IsPolling(int joy); + // query # of joysticks + int GetNumJoysticks() + { + return njoy; + } + // query # of axes on given joystick + // 0 is returned if joy is invalid + int GetNumAxes(int joy); + // query # of hats on given joystick + // 0 is returned if joy is invalid + int GetNumHats(int joy); + // query # of buttons on given joystick + // 0 is returned if joy is invalid + int GetNumButtons(int joy); - virtual ~wxSDLJoy(); -protected: - bool digital; - int njoy; - wxSDLJoyState_t* joystate; - wxEvtHandler* evthandler; - bool nosticks; - void Notify(); + virtual ~wxSDLJoy(); + + protected: + bool digital; + int njoy; + wxSDLJoyState_t *joystate; + wxEvtHandler *evthandler; + bool nosticks; + void Notify(); }; -enum -{ - // The types of supported controls - // values are signed-16 for axis, 0/1 for button - // hat is bitmask NESW/URDL - WXSDLJOY_AXIS, WXSDLJOY_HAT, WXSDLJOY_BUTTON +enum { + // The types of supported controls + // values are signed-16 for axis, 0/1 for button + // hat is bitmask NESW/URDL + WXSDLJOY_AXIS, + WXSDLJOY_HAT, + WXSDLJOY_BUTTON }; class wxSDLJoyEvent : public wxCommandEvent { - friend class wxSDLJoy; -public: - // Default constructor - wxSDLJoyEvent(wxEventType commandType = wxEVT_NULL, int id = 0) : - wxCommandEvent(commandType, id) {} - // accessors - unsigned short GetJoy() { return joy; } - unsigned short GetControlType() { return ctrl_type; } - unsigned short GetControlIndex() { return ctrl_idx; } - short GetControlValue() { return ctrl_val; } - short GetControlPrevValue() { return prev_val; } - // required for PostEvent, apparently - wxEvent* Clone(); -protected: - unsigned short joy; - unsigned short ctrl_type; - unsigned short ctrl_idx; - short ctrl_val; - short prev_val; + friend class wxSDLJoy; + + public: + // Default constructor + wxSDLJoyEvent(wxEventType commandType = wxEVT_NULL, int id = 0) + : wxCommandEvent(commandType, id) + { + } + // accessors + unsigned short GetJoy() + { + return joy; + } + unsigned short GetControlType() + { + return ctrl_type; + } + unsigned short GetControlIndex() + { + return ctrl_idx; + } + short GetControlValue() + { + return ctrl_val; + } + short GetControlPrevValue() + { + return prev_val; + } + // required for PostEvent, apparently + wxEvent *Clone(); + + protected: + unsigned short joy; + unsigned short ctrl_type; + unsigned short ctrl_idx; + short ctrl_val; + short prev_val; }; // Note: this means sdljoy can't be part of a library w/o extra work DECLARE_LOCAL_EVENT_TYPE(wxEVT_SDLJOY, -1) typedef void (wxEvtHandler::*wxSDLJoyEventFunction)(wxSDLJoyEvent &); -#define EVT_SDLJOY(fn) \ - DECLARE_EVENT_TABLE_ENTRY(wxEVT_SDLJOY, wxID_ANY, wxID_ANY, \ - (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) \ - wxStaticCastEvent(wxSDLJoyEventFunction, &fn), (wxObject *)NULL), \ +#define EVT_SDLJOY(fn) \ + DECLARE_EVENT_TABLE_ENTRY(wxEVT_SDLJOY, \ + wxID_ANY, \ + wxID_ANY, \ + (wxObjectEventFunction)(wxEventFunction)(wxCommandEventFunction) \ + wxStaticCastEvent(wxSDLJoyEventFunction, &fn), \ + (wxObject *)NULL) \ + , #endif /* JOYEVT_H */ diff --git a/src/wx/widgets/wx/wxmisc.h b/src/wx/widgets/wx/wxmisc.h index 544da876..2940fbea 100644 --- a/src/wx/widgets/wx/wxmisc.h +++ b/src/wx/widgets/wx/wxmisc.h @@ -6,71 +6,103 @@ // note that it must be checkbox, as wx radio buttons have rigid behavior class wxFarRadio : public wxCheckBox { -public: - wxFarRadio(); - virtual ~wxFarRadio(); - void SetValue(bool val); - // join this group with widget(s) in grp - void SetGroup(class wxFarRadio* grp); - // turn into a singleton - void BreakGroup(); - // iterate over members in group (ring) - wxFarRadio* GetNext(); -protected: - void UpdatedValue(); - void UpdateEvt(wxCommandEvent &ev); - wxFarRadio* Next; - DECLARE_DYNAMIC_CLASS() - DECLARE_EVENT_TABLE() + public: + wxFarRadio(); + virtual ~wxFarRadio(); + void SetValue(bool val); + // join this group with widget(s) in grp + void SetGroup(class wxFarRadio *grp); + // turn into a singleton + void BreakGroup(); + // iterate over members in group (ring) + wxFarRadio *GetNext(); + + protected: + void UpdatedValue(); + void UpdateEvt(wxCommandEvent &ev); + wxFarRadio *Next; + DECLARE_DYNAMIC_CLASS() + DECLARE_EVENT_TABLE() }; // boolean copy-only validator that uses a constant int // may be attached to radio button or checkbox class wxBoolIntValidator : public wxValidator { -public: - wxBoolIntValidator(int* _vptr, int _val, int _mask = ~0) : wxValidator(), - vptr(_vptr), val(_val), mask(_mask) {} - wxBoolIntValidator(const wxBoolIntValidator &v) : wxValidator(), - vptr(v.vptr), val(v.val), mask(v.mask) {} - wxObject* Clone() const { return new wxBoolIntValidator(vptr, val, mask); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - int val, mask, *vptr; + public: + wxBoolIntValidator(int *_vptr, int _val, int _mask = ~0) + : wxValidator(), vptr(_vptr), val(_val), mask(_mask) + { + } + wxBoolIntValidator(const wxBoolIntValidator &v) + : wxValidator(), vptr(v.vptr), val(v.val), mask(v.mask) + { + } + wxObject *Clone() const + { + return new wxBoolIntValidator(vptr, val, mask); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } + + protected: + int val, mask, *vptr; }; // boolean copy-only validator with reversed value // may be attached to radio button or checkbox class wxBoolRevValidator : public wxValidator { -public: - wxBoolRevValidator(bool* _vptr) : wxValidator(), vptr(_vptr) {} - wxBoolRevValidator(const wxBoolRevValidator &v) : wxValidator(), vptr(v.vptr) {} - wxObject* Clone() const { return new wxBoolRevValidator(vptr); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - bool* vptr; + public: + wxBoolRevValidator(bool *_vptr) : wxValidator(), vptr(_vptr) + { + } + wxBoolRevValidator(const wxBoolRevValidator &v) : wxValidator(), vptr(v.vptr) + { + } + wxObject *Clone() const + { + return new wxBoolRevValidator(vptr); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } + + protected: + bool *vptr; }; // wxFilePickerCtrl/wxDirPickerCtrl copy-only vvalidator class wxFileDirPickerValidator : public wxValidator { -public: - wxFileDirPickerValidator(wxString* _vptr) : wxValidator(), vptr(_vptr) {} - wxFileDirPickerValidator(const wxFileDirPickerValidator &v) : wxValidator(), - vptr(v.vptr) {} - wxObject* Clone() const { return new wxFileDirPickerValidator(vptr); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - wxString* vptr; -}; + public: + wxFileDirPickerValidator(wxString *_vptr) : wxValidator(), vptr(_vptr) + { + } + wxFileDirPickerValidator(const wxFileDirPickerValidator &v) : wxValidator(), vptr(v.vptr) + { + } + wxObject *Clone() const + { + return new wxFileDirPickerValidator(vptr); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } + protected: + wxString *vptr; +}; // color copy-only validator that supports either 32-bit or 16-bit color // value (but not endianness..) @@ -80,18 +112,30 @@ protected: class wxColorValidator : public wxValidator { -public: - wxColorValidator(uint32_t* vptr) : wxValidator(), ptr32(vptr), ptr16(0) {} - wxColorValidator(uint16_t* vptr) : wxValidator(), ptr16(vptr), ptr32(0) {} - wxColorValidator(const wxColorValidator &v) : wxValidator(), - ptr32(v.ptr32), ptr16(v.ptr16) {} - wxObject* Clone() const { return new wxColorValidator(*this); } - bool TransferToWindow(); - bool TransferFromWindow(); - bool Validate(wxWindow* p) { return true; } -protected: - uint32_t* ptr32; - uint16_t* ptr16; + public: + wxColorValidator(uint32_t *vptr) : wxValidator(), ptr32(vptr), ptr16(0) + { + } + wxColorValidator(uint16_t *vptr) : wxValidator(), ptr16(vptr), ptr32(0) + { + } + wxColorValidator(const wxColorValidator &v) : wxValidator(), ptr32(v.ptr32), ptr16(v.ptr16) + { + } + wxObject *Clone() const + { + return new wxColorValidator(*this); + } + bool TransferToWindow(); + bool TransferFromWindow(); + bool Validate(wxWindow *p) + { + return true; + } + + protected: + uint32_t *ptr32; + uint16_t *ptr16; }; // Copy-only validators for checkboxes and radio buttons that enables a set @@ -103,62 +147,89 @@ protected: // there's probably a standard wxWindowList or some such, but it's // undocumented and I prefer arrays -typedef std::vectorwxWindow_v; +typedef std::vector wxWindow_v; class wxBoolEnValidator : public wxGenericValidator { -public: - wxBoolEnValidator(bool* vptr) : wxGenericValidator(vptr) {} - wxBoolEnValidator(bool* vptr, wxWindow_v &cnt, std::vectorrev = std::vector()) : - wxGenericValidator(vptr), controls(cnt), reverse(rev) {} - wxBoolEnValidator(const wxBoolEnValidator &v) : wxGenericValidator(v), - controls(v.controls), reverse(v.reverse) {} - wxObject* Clone() const { return new wxBoolEnValidator(*this); } - // set these after init, rather than in constructor - wxWindow_v controls; - // set reverse entries to true if disabled when checkbox checked - // controls past the end of the reverse array are not reversed - std::vector reverse; - // inherit validate, xferfrom from parent - bool TransferToWindow(); + public: + wxBoolEnValidator(bool *vptr) : wxGenericValidator(vptr) + { + } + wxBoolEnValidator(bool *vptr, wxWindow_v &cnt, std::vector rev = std::vector()) + : wxGenericValidator(vptr), controls(cnt), reverse(rev) + { + } + wxBoolEnValidator(const wxBoolEnValidator &v) + : wxGenericValidator(v), controls(v.controls), reverse(v.reverse) + { + } + wxObject *Clone() const + { + return new wxBoolEnValidator(*this); + } + // set these after init, rather than in constructor + wxWindow_v controls; + // set reverse entries to true if disabled when checkbox checked + // controls past the end of the reverse array are not reversed + std::vector reverse; + // inherit validate, xferfrom from parent + bool TransferToWindow(); }; class wxBoolIntEnValidator : public wxBoolIntValidator { -public: - wxBoolIntEnValidator(int* vptr, int val, int mask = ~0) : - wxBoolIntValidator(vptr, val, mask) {} - wxBoolIntEnValidator(int* vptr, int val, int mask, wxWindow_v &cnt, - std::vectorrev = std::vector()) : - wxBoolIntValidator(vptr, val, mask), controls(cnt), reverse(rev) {} - wxBoolIntEnValidator(const wxBoolIntEnValidator &v) : - wxBoolIntValidator(v), controls(v.controls), reverse(v.reverse) {} - wxObject* Clone() const { return new wxBoolIntEnValidator(*this); } - // set these after init, rather than in constructor - wxWindow_v controls; - // set reverse entries to true if disabled when checkbox checked - // controls past the end of the reverse array are not reversed - std::vector reverse; - // inherit validate, xferfrom from parent - bool TransferToWindow(); + public: + wxBoolIntEnValidator(int *vptr, int val, int mask = ~0) + : wxBoolIntValidator(vptr, val, mask) + { + } + wxBoolIntEnValidator(int *vptr, int val, int mask, wxWindow_v &cnt, + std::vector rev = std::vector()) + : wxBoolIntValidator(vptr, val, mask), controls(cnt), reverse(rev) + { + } + wxBoolIntEnValidator(const wxBoolIntEnValidator &v) + : wxBoolIntValidator(v), controls(v.controls), reverse(v.reverse) + { + } + wxObject *Clone() const + { + return new wxBoolIntEnValidator(*this); + } + // set these after init, rather than in constructor + wxWindow_v controls; + // set reverse entries to true if disabled when checkbox checked + // controls past the end of the reverse array are not reversed + std::vector reverse; + // inherit validate, xferfrom from parent + bool TransferToWindow(); }; class wxBoolRevEnValidator : public wxBoolRevValidator { -public: - wxBoolRevEnValidator(bool* vptr) : wxBoolRevValidator(vptr) {} - wxBoolRevEnValidator(bool* vptr, wxWindow_v &cnt, std::vectorrev = std::vector()) : - wxBoolRevValidator(vptr), controls(cnt), reverse(rev) {} - wxBoolRevEnValidator(const wxBoolRevEnValidator &v) : wxBoolRevValidator(v), - controls(v.controls), reverse(v.reverse) {} - wxObject* Clone() const { return new wxBoolRevEnValidator(*this); } - // set these after init, rather than in constructor - wxWindow_v controls; - // set reverse entries to true if disabled when checkbox checked - // controls past the end of the reverse array are not reversed - std::vector reverse; - // inherit validate, xferfrom from parent - bool TransferToWindow(); + public: + wxBoolRevEnValidator(bool *vptr) : wxBoolRevValidator(vptr) + { + } + wxBoolRevEnValidator(bool *vptr, wxWindow_v &cnt, std::vector rev = std::vector()) + : wxBoolRevValidator(vptr), controls(cnt), reverse(rev) + { + } + wxBoolRevEnValidator(const wxBoolRevEnValidator &v) + : wxBoolRevValidator(v), controls(v.controls), reverse(v.reverse) + { + } + wxObject *Clone() const + { + return new wxBoolRevEnValidator(*this); + } + // set these after init, rather than in constructor + wxWindow_v controls; + // set reverse entries to true if disabled when checkbox checked + // controls past the end of the reverse array are not reversed + std::vector reverse; + // inherit validate, xferfrom from parent + bool TransferToWindow(); }; // and here's an event handler that can be attached to the widget or a parent @@ -167,24 +238,28 @@ public: // event handlers class wxBoolEnHandler : public wxEvtHandler { -public: - wxWindow_v controls; - std::vector reverse; - void ToggleCheck(wxCommandEvent &ev); - void Enable(wxCommandEvent &ev); - void Disable(wxCommandEvent &ev); + public: + wxWindow_v controls; + std::vector reverse; + void ToggleCheck(wxCommandEvent &ev); + void Enable(wxCommandEvent &ev); + void Disable(wxCommandEvent &ev); }; // use this to connect to the handler of id in win to obj -#define wxCBBoolEnHandlerConnect(win, id, obj) \ - (win)->Connect(id, wxEVT_COMMAND_CHECKBOX_CLICKED, \ - wxCommandEventHandler(wxBoolEnHandler::ToggleCheck), NULL, \ - &obj) +#define wxCBBoolEnHandlerConnect(win, id, obj) \ + (win)->Connect(id, \ + wxEVT_COMMAND_CHECKBOX_CLICKED, \ + wxCommandEventHandler(wxBoolEnHandler::ToggleCheck), \ + NULL, \ + &obj) -#define wxRBBoolEnHandlerConnect(win, id, obj, f) \ - (win)->Connect(id, wxEVT_COMMAND_RADIOBUTTON_SELECTED, \ - wxCommandEventHandler(wxBoolEnHandler::f), NULL, \ - &obj) +#define wxRBBoolEnHandlerConnect(win, id, obj, f) \ + (win)->Connect(id, \ + wxEVT_COMMAND_RADIOBUTTON_SELECTED, \ + wxCommandEventHandler(wxBoolEnHandler::f), \ + NULL, \ + &obj) #define wxRBEBoolEnHandlerConnect(win, id, obj) wxRBBoolEnHandlerConnect(win, id, obj, Enable) #define wxRBDBoolEnHandlerConnect(win, id, obj) wxRBBoolEnHandlerConnect(win, id, obj, Disable) diff --git a/src/wx/wxhead.h b/src/wx/wxhead.h index d0f4dbde..8dcd4c8b 100644 --- a/src/wx/wxhead.h +++ b/src/wx/wxhead.h @@ -17,13 +17,13 @@ // The following are not pulled in by wx.h // for some reason, mingw32 wx.h doesn't pull in listctrl by default +#include +#include +#include #include +#include #include #include -#include -#include -#include -#include // filehistory.h is separate only in 2.9+ #include @@ -41,7 +41,7 @@ #endif // compatibility with MacOSX 10.5 -#if !wxCHECK_VERSION(2,8,8) +#if !wxCHECK_VERSION(2, 8, 8) #define AddFileWithMimeType(a, b, c, m) AddFile(a, b, c) #define GetItemLabel GetText #define SetItemLabel SetText @@ -51,7 +51,7 @@ // compatibility with wx-2.9 // The only reason I use wxTRANSLATE at all is to get wxT as a side effect. -#if wxCHECK_VERSION(2,9,0) +#if wxCHECK_VERSION(2, 9, 0) #undef wxTRANSLATE #define wxTRANSLATE wxT #endif @@ -65,36 +65,35 @@ #include "wx/keyedit.h" -static inline void DoSetAccel(wxMenuItem* mi, wxAcceleratorEntry* acc) +static inline void DoSetAccel(wxMenuItem *mi, wxAcceleratorEntry *acc) { - wxString lab = mi->GetItemLabel(); - size_t tab = lab.find(wxT('\t')); + wxString lab = mi->GetItemLabel(); + size_t tab = lab.find(wxT('\t')); - // following short circuit returns are to avoid UI update on no change - if (tab == wxString::npos && !acc) - return; + // following short circuit returns are to avoid UI update on no change + if (tab == wxString::npos && !acc) + return; - wxString accs; + wxString accs; - if (acc) - // actually, use keyedit's ToString(), as it is more reliable - // and doesn't generate wx assertions - // accs = acc->ToString(); - accs = wxKeyTextCtrl::ToString(acc->GetFlags(), acc->GetKeyCode()); + if (acc) + // actually, use keyedit's ToString(), as it is more reliable + // and doesn't generate wx assertions + // accs = acc->ToString(); + accs = wxKeyTextCtrl::ToString(acc->GetFlags(), acc->GetKeyCode()); - if (tab != wxString::npos && accs == lab.substr(tab + 1)) - return; + if (tab != wxString::npos && accs == lab.substr(tab + 1)) + return; - if (tab != wxString::npos) - lab.resize(tab); + if (tab != wxString::npos) + lab.resize(tab); - if (acc) - { - lab.append(wxT('\t')); - lab.append(accs); - } + if (acc) { + lab.append(wxT('\t')); + lab.append(accs); + } - mi->SetItemLabel(lab); + mi->SetItemLabel(lab); } // wxrc helpers (for dynamic strings instead of constant) diff --git a/src/wx/wxvbam.h b/src/wx/wxvbam.h index 102fd70e..2db91017 100644 --- a/src/wx/wxvbam.h +++ b/src/wx/wxvbam.h @@ -2,112 +2,116 @@ #define WX_WXVBAM_H #include -#include #include +#include #include -#include "wxhead.h" -#include "wx/sdljoy.h" #include "wx/joyedit.h" #include "wx/keyedit.h" +#include "wx/sdljoy.h" #include "wx/wxmisc.h" +#include "wxhead.h" #ifndef NO_FFMPEG #include "../common/ffmpeg.h" #endif /* yeah, they aren't needed globally, but I'm too lazy to limit where needed */ #include "../System.h" -#include "../gba/Globals.h" +#include "../Util.h" +#include "../gb/gb.h" +#include "../gb/gbCheats.h" #include "../gb/gbGlobals.h" #include "../gb/gbSound.h" -#include "../gb/gb.h" -#include "../gba/Sound.h" -#include "../Util.h" -#include "../gba/GBALink.h" -#include "../gb/gbCheats.h" #include "../gba/Cheats.h" +#include "../gba/GBALink.h" +#include "../gba/Globals.h" +#include "../gba/Sound.h" -template -void CheckPointer(T pointer) +template void CheckPointer(T pointer) { - if (pointer == NULL) - { - std::string errormessage = "Pointer of type \""; - errormessage += typeid(pointer).name(); - errormessage += "\" was not correctly created."; - throw std::runtime_error(errormessage); - } + if (pointer == NULL) { + std::string errormessage = "Pointer of type \""; + errormessage += typeid(pointer).name(); + errormessage += "\" was not correctly created."; + throw std::runtime_error(errormessage); + } } -///Helper functions to convert WX's crazy string types to std::string +/// Helper functions to convert WX's crazy string types to std::string inline std::string ToString(wxCharBuffer aString) { - return std::string(aString); + return std::string(aString); } -inline std::string ToString(const wxChar* aString) +inline std::string ToString(const wxChar *aString) { - return std::string(wxString(aString).mb_str(wxConvUTF8)); + return std::string(wxString(aString).mb_str(wxConvUTF8)); } class MainFrame; class wxvbamApp : public wxApp { -public: - wxvbamApp() : wxApp(), pending_fullscreen(false) {} - virtual bool OnInit(); - virtual void OnInitCmdLine(wxCmdLineParser &); - virtual bool OnCmdLineParsed(wxCmdLineParser &); - wxString GetConfigurationPath(); - wxString GetAbsolutePath(wxString path); - // name of a file to load at earliest opportunity - wxString pending_load; - // list of options to set after config file loaded - wxArrayString pending_optset; - // set fullscreen mode after init - bool pending_fullscreen; + public: + wxvbamApp() : wxApp(), pending_fullscreen(false) + { + } + virtual bool OnInit(); + virtual void OnInitCmdLine(wxCmdLineParser &); + virtual bool OnCmdLineParsed(wxCmdLineParser &); + wxString GetConfigurationPath(); + wxString GetAbsolutePath(wxString path); + // name of a file to load at earliest opportunity + wxString pending_load; + // list of options to set after config file loaded + wxArrayString pending_optset; + // set fullscreen mode after init + bool pending_fullscreen; #if __WXMAC__ - // I suppose making this work will require tweaking the bundle - void MacOpenFile(const wxString &f) { pending_load = f; }; + // I suppose making this work will require tweaking the bundle + void MacOpenFile(const wxString &f) + { + pending_load = f; + }; #endif - // without this, global accels don't always work - int FilterEvent(wxEvent &event); - wxAcceleratorEntry_v accels; + // without this, global accels don't always work + int FilterEvent(wxEvent &event); + wxAcceleratorEntry_v accels; - // the main configuration - wxFileConfig* cfg; - // vba-over.ini - wxFileConfig* overrides; + // the main configuration + wxFileConfig *cfg; + // vba-over.ini + wxFileConfig *overrides; - wxFileName rom_database; - wxFileName rom_database_scene; - wxFileName rom_database_nointro; + wxFileName rom_database; + wxFileName rom_database_scene; + wxFileName rom_database_nointro; - wxString data_path; + wxString data_path; - MainFrame* frame; - // use this to get ms since program lauch - wxStopWatch timer; - // append log messages to this for the log viewer - wxString log; - // there's no way to retrieve "current" locale, so this is public - wxLocale locale; + MainFrame *frame; + // use this to get ms since program lauch + wxStopWatch timer; + // append log messages to this for the log viewer + wxString log; + // there's no way to retrieve "current" locale, so this is public + wxLocale locale; - //Handle most exceptions - virtual bool OnExceptionInMainLoop() - { - try {throw;} - catch (const std::exception &e) - { - std::cerr << "AN ERROR HAS OCCURRED: " << e.what() << std::endl; - return false; - } - } -private: - wxPathList config_path; - char* home; + // Handle most exceptions + virtual bool OnExceptionInMainLoop() + { + try { + throw; + } catch (const std::exception &e) { + std::cerr << "AN ERROR HAS OCCURRED: " << e.what() << std::endl; + return false; + } + } + + private: + wxPathList config_path; + char *home; }; DECLARE_APP(wxvbamApp); @@ -115,59 +119,55 @@ DECLARE_APP(wxvbamApp); // menu event handlers are declared with these macros in mainwind.cpp // and mainwind-handlers.h, mainwind-cmd.cpp, and mainwind-evt.cpp are // auto-generated from them -#define EVT_HANDLER(n, x) \ - void MainFrame::On##n(wxCommandEvent& WXUNUSED(event)) +#define EVT_HANDLER(n, x) void MainFrame::On##n(wxCommandEvent &WXUNUSED(event)) // some commands are masked under some conditions -#define EVT_HANDLER_MASK(n, x, m) \ - void MainFrame::On##n(wxCommandEvent& WXUNUSED(event)) \ - { \ - if(!(cmd_enable & (m))) \ - return; \ - Do##n(); \ - } \ - void MainFrame::Do##n() \ +#define EVT_HANDLER_MASK(n, x, m) \ + void MainFrame::On##n(wxCommandEvent &WXUNUSED(event)) \ + { \ + if (!(cmd_enable & (m))) \ + return; \ + Do##n(); \ + } \ + void MainFrame::Do##n() // here are those conditions -enum -{ - CMDEN_GB = (1 << 0), // GB ROM loaded - CMDEN_GBA = (1 << 1), // GBA ROM loaded - // the rest imply the above, unless: - // _ANY -> does not imply either - // _GBA -> only implies GBA - CMDEN_REWIND = (1 << 2), // rewind states available - CMDEN_SREC = (1 << 3), // sound recording in progress - CMDEN_NSREC = (1 << 4), // no sound recording - CMDEN_VREC = (1 << 5), // video recording - CMDEN_NVREC = (1 << 6), // no video recording - CMDEN_GREC = (1 << 7), // game recording - CMDEN_NGREC = (1 << 8), // no game recording - CMDEN_GPLAY = (1 << 9), // game playback - CMDEN_NGPLAY = (1 << 10), // no game playback - CMDEN_SAVST = (1 << 11), // any save states - CMDEN_GDB = (1 << 12), // gdb connected - CMDEN_NGDB_GBA = (1 << 13), // gdb not connected - CMDEN_NGDB_ANY = (1 << 14), // gdb not connected - CMDEN_NREC_ANY = (1 << 15), // not a/v recording - CMDEN_LINK_ANY = (1 << 16), // link enabled +enum { CMDEN_GB = (1 << 0), // GB ROM loaded + CMDEN_GBA = (1 << 1), // GBA ROM loaded + // the rest imply the above, unless: + // _ANY -> does not imply either + // _GBA -> only implies GBA + CMDEN_REWIND = (1 << 2), // rewind states available + CMDEN_SREC = (1 << 3), // sound recording in progress + CMDEN_NSREC = (1 << 4), // no sound recording + CMDEN_VREC = (1 << 5), // video recording + CMDEN_NVREC = (1 << 6), // no video recording + CMDEN_GREC = (1 << 7), // game recording + CMDEN_NGREC = (1 << 8), // no game recording + CMDEN_GPLAY = (1 << 9), // game playback + CMDEN_NGPLAY = (1 << 10), // no game playback + CMDEN_SAVST = (1 << 11), // any save states + CMDEN_GDB = (1 << 12), // gdb connected + CMDEN_NGDB_GBA = (1 << 13), // gdb not connected + CMDEN_NGDB_ANY = (1 << 14), // gdb not connected + CMDEN_NREC_ANY = (1 << 15), // not a/v recording + CMDEN_LINK_ANY = (1 << 16), // link enabled - CMDEN_NEVER = (1 << 31) // never (for NOOP) + CMDEN_NEVER = (1 << 31) // never (for NOOP) }; -#define ONLOAD_CMDEN (CMDEN_NSREC|CMDEN_NVREC|CMDEN_NGREC|CMDEN_NGPLAY) -#define UNLOAD_CMDEN_KEEP (CMDEN_NGDB_ANY|CMDEN_NREC_ANY|CMDEN_LINK_ANY) +#define ONLOAD_CMDEN (CMDEN_NSREC | CMDEN_NVREC | CMDEN_NGREC | CMDEN_NGPLAY) +#define UNLOAD_CMDEN_KEEP (CMDEN_NGDB_ANY | CMDEN_NREC_ANY | CMDEN_LINK_ANY) -struct checkable_mi_t -{ - int cmd; - wxMenuItem* mi; - bool* boolopt; - int* intopt, mask, val; +struct checkable_mi_t { + int cmd; + wxMenuItem *mi; + bool *boolopt; + int *intopt, mask, val; }; // wxArray is only for small types typedef std::vector checkable_mi_array_t; -typedef std::list dialog_list_t; +typedef std::list dialog_list_t; class GameArea; @@ -178,149 +178,156 @@ extern bool pause_next; class MainFrame : public wxFrame { -public: - MainFrame(); - ~MainFrame(); + public: + MainFrame(); + ~MainFrame(); - bool BindControls(); - void MenuOptionIntMask(const char* menuName, int &field, int mask); - void MenuOptionIntRadioValue(const char* menuName, int &field, int mask); - void MenuOptionBool(const char* menuName, bool &field); - void GetMenuOptionInt(const char* menuName, int &field, int mask); - void GetMenuOptionBool(const char* menuName, bool &field); - void SetMenuOption(const char* menuName, int value); + bool BindControls(); + void MenuOptionIntMask(const char *menuName, int &field, int mask); + void MenuOptionIntRadioValue(const char *menuName, int &field, int mask); + void MenuOptionBool(const char *menuName, bool &field); + void GetMenuOptionInt(const char *menuName, int &field, int mask); + void GetMenuOptionBool(const char *menuName, bool &field); + void SetMenuOption(const char *menuName, int value); - void SetJoystick(); + void SetJoystick(); - GameArea* GetPanel() { return panel; } + GameArea *GetPanel() + { + return panel; + } - wxString GetGamePath(wxString path); + wxString GetGamePath(wxString path); - // wxMSW pauses the game for menu popups and modal dialogs, but wxGTK - // does not. It's probably desirable to pause the game. To do this for - // dialogs, use this function instead of dlg->ShowModal() - int ShowModal(wxDialog* dlg); - // and here are the wrapper functions for use when ShowModal() isn't - // possible - void StartModal(); - void StopModal(); - // however, adding a handler for open/close menu to do the same is unsafe. - // there is no guarantee every show will be matched by a hide. - void MenuPopped(wxMenuEvent &evt); + // wxMSW pauses the game for menu popups and modal dialogs, but wxGTK + // does not. It's probably desirable to pause the game. To do this for + // dialogs, use this function instead of dlg->ShowModal() + int ShowModal(wxDialog *dlg); + // and here are the wrapper functions for use when ShowModal() isn't + // possible + void StartModal(); + void StopModal(); + // however, adding a handler for open/close menu to do the same is unsafe. + // there is no guarantee every show will be matched by a hide. + void MenuPopped(wxMenuEvent &evt); - // flags for enabling commands - int cmd_enable; + // flags for enabling commands + int cmd_enable; - // adjust menus based on current cmd_enable - void enable_menus(); - void EnableNetworkMenu(); + // adjust menus based on current cmd_enable + void enable_menus(); + void EnableNetworkMenu(); - // adjust menus based on available save game states - void update_state_ts(bool force = false); + // adjust menus based on available save game states + void update_state_ts(bool force = false); - // retrieve oldest/newest slot - // returns lowest-numbered slot on ties - int oldest_state_slot(); // or empty slot if available - int newest_state_slot(); // or 0 if none + // retrieve oldest/newest slot + // returns lowest-numbered slot on ties + int oldest_state_slot(); // or empty slot if available + int newest_state_slot(); // or 0 if none - // system-defined accelerators - wxAcceleratorEntry_v sys_accels; - // adjust recent menu with accelerators - void SetRecentAccels(); - // merge sys accels with user-defined accels (user overrides sys) - wxAcceleratorEntry_v get_accels(wxAcceleratorEntry_v user_accels); - // update menu and global accelerator table with sys+user accel defs - // probably not the quickest way to add/remove individual accels - void set_global_accels(); + // system-defined accelerators + wxAcceleratorEntry_v sys_accels; + // adjust recent menu with accelerators + void SetRecentAccels(); + // merge sys accels with user-defined accels (user overrides sys) + wxAcceleratorEntry_v get_accels(wxAcceleratorEntry_v user_accels); + // update menu and global accelerator table with sys+user accel defs + // probably not the quickest way to add/remove individual accels + void set_global_accels(); - // 2.8 has no HasFocus(), and FindFocus() doesn't work right - bool HasFocus() { return focused; } + // 2.8 has no HasFocus(), and FindFocus() doesn't work right + bool HasFocus() + { + return focused; + } - // Returns the link mode to set according to the options - LinkMode GetConfiguredLinkMode(); + // Returns the link mode to set according to the options + LinkMode GetConfiguredLinkMode(); - void IdentifyRom(); + void IdentifyRom(); - // Start GDB listener - void GDBBreak(); + // Start GDB listener + void GDBBreak(); - // The various viewer popups; these can be popped up as often as - // desired - void Disassemble(); - void IOViewer(); - void MapViewer(); - void MemViewer(); - void OAMViewer(); - void PaletteViewer(); - void TileViewer(); + // The various viewer popups; these can be popped up as often as + // desired + void Disassemble(); + void IOViewer(); + void MapViewer(); + void MemViewer(); + void OAMViewer(); + void PaletteViewer(); + void TileViewer(); - // since they will all have to be destroyed on game unload: - dialog_list_t popups; + // since they will all have to be destroyed on game unload: + dialog_list_t popups; - // this won't actually be destroyed, but it needs to be tracked so only - // one is ever up and it needs to be pinged when new messages arrive - LogDialog* logdlg; + // this won't actually be destroyed, but it needs to be tracked so only + // one is ever up and it needs to be pinged when new messages arrive + LogDialog *logdlg; - // the cheat search dialog isn't destroyed or tracked, but it needs - // to be cleared between games - void ResetCheatSearch(); + // the cheat search dialog isn't destroyed or tracked, but it needs + // to be cleared between games + void ResetCheatSearch(); - // call this to update the viewers once a frame: - void UpdateViewers(); + // call this to update the viewers once a frame: + void UpdateViewers(); - // Check for online updates to the emulator - bool CheckForUpdates(); + // Check for online updates to the emulator + bool CheckForUpdates(); - // required for building from xrc - DECLARE_DYNAMIC_CLASS(); - // required for event handling - DECLARE_EVENT_TABLE(); + // required for building from xrc + DECLARE_DYNAMIC_CLASS(); + // required for event handling + DECLARE_EVENT_TABLE(); - bool IsPaused(bool incendental = false) - { - return (paused && !pause_next && !incendental) || menus_opened || dialog_opened; - } -private: - GameArea* panel; + bool IsPaused(bool incendental = false) + { + return (paused && !pause_next && !incendental) || menus_opened || dialog_opened; + } - // the various reasons the game might be paused - bool paused; - int menus_opened, dialog_opened; + private: + GameArea *panel; - bool autoLoadMostRecent; - // copy of top-level menu bar as a context menu - wxMenu* ctx_menu; - // load/save states menu items - wxMenuItem* loadst_mi[10]; - wxMenuItem* savest_mi[10]; - wxDateTime state_ts[10]; - // checkable menu items - checkable_mi_array_t checkable_mi; - // recent menu item accels - wxMenu* recent; - wxAcceleratorEntry recent_accel[10]; - // joystick reader - wxSDLJoy joy; + // the various reasons the game might be paused + bool paused; + int menus_opened, dialog_opened; - // helper function for adding menu to accel editor - void add_menu_accels(wxTreeCtrl* tc, wxTreeItemId &parent, wxMenu* menu); + bool autoLoadMostRecent; + // copy of top-level menu bar as a context menu + wxMenu *ctx_menu; + // load/save states menu items + wxMenuItem *loadst_mi[10]; + wxMenuItem *savest_mi[10]; + wxDateTime state_ts[10]; + // checkable menu items + checkable_mi_array_t checkable_mi; + // recent menu item accels + wxMenu *recent; + wxAcceleratorEntry recent_accel[10]; + // joystick reader + wxSDLJoy joy; - // for detecting window focus - void OnActivate(wxActivateEvent &); - // quicker & more accurate than FindFocus() != NULL - bool focused; - // may work, may not... if so, load dropped file - void OnDropFile(wxDropFilesEvent &); - // pop up menu in fullscreen mode - void OnMenu(wxContextMenuEvent &); - // Load a named wxDialog from the XRC file - wxDialog* LoadXRCDialog(const char* name); - // Load a named wxDialog from the XRC file - wxDialog* LoadXRCropertySheetDialog(const char* name); + // helper function for adding menu to accel editor + void add_menu_accels(wxTreeCtrl *tc, wxTreeItemId &parent, wxMenu *menu); - void DownloadFile(wxString host, wxString url); - void UpdateFile(wxString host, wxString url); - wxString CheckForUpdates(wxString host, wxString url); + // for detecting window focus + void OnActivate(wxActivateEvent &); + // quicker & more accurate than FindFocus() != NULL + bool focused; + // may work, may not... if so, load dropped file + void OnDropFile(wxDropFilesEvent &); + // pop up menu in fullscreen mode + void OnMenu(wxContextMenuEvent &); + // Load a named wxDialog from the XRC file + wxDialog *LoadXRCDialog(const char *name); + // Load a named wxDialog from the XRC file + wxDialog *LoadXRCropertySheetDialog(const char *name); + + void DownloadFile(wxString host, wxString url); + void UpdateFile(wxString host, wxString url); + wxString CheckForUpdates(wxString host, wxString url); #include "cmdhandlers.h" }; @@ -328,49 +335,71 @@ private: // a helper class to avoid forgetting StopModal() class ModalPause { -public: - ModalPause() { wxGetApp().frame->StartModal(); } - ~ModalPause() { wxGetApp().frame->StopModal(); } + public: + ModalPause() + { + wxGetApp().frame->StartModal(); + } + ~ModalPause() + { + wxGetApp().frame->StopModal(); + } }; -enum showspeed -{ - // this order must match order of option enum and selector widget - SS_NONE, SS_PERCENT, SS_DETAILED +enum showspeed { + // this order must match order of option enum and selector widget + SS_NONE, + SS_PERCENT, + SS_DETAILED }; -enum filtfunc -{ - // this order must match order of option enum and selector widget - FF_NONE, FF_2XSAI, FF_SUPER2XSAI, FF_SUPEREAGLE, FF_PIXELATE, - FF_ADVMAME, FF_BILINEAR, FF_BILINEARPLUS, FF_SCANLINES, FF_TV, - FF_HQ2X, FF_LQ2X, FF_SIMPLE2X, FF_SIMPLE3X, FF_HQ3X, FF_SIMPLE4X, - FF_HQ4X, FF_XBRZ2X, FF_XBRZ3X, FF_XBRZ4X, FF_XBRZ5X, FF_XBRZ6X, FF_PLUGIN // plugin must always be last +enum filtfunc { + // this order must match order of option enum and selector widget + FF_NONE, + FF_2XSAI, + FF_SUPER2XSAI, + FF_SUPEREAGLE, + FF_PIXELATE, + FF_ADVMAME, + FF_BILINEAR, + FF_BILINEARPLUS, + FF_SCANLINES, + FF_TV, + FF_HQ2X, + FF_LQ2X, + FF_SIMPLE2X, + FF_SIMPLE3X, + FF_HQ3X, + FF_SIMPLE4X, + FF_HQ4X, + FF_XBRZ2X, + FF_XBRZ3X, + FF_XBRZ4X, + FF_XBRZ5X, + FF_XBRZ6X, + FF_PLUGIN // plugin must always be last }; -#define builtin_ff_scale(x) \ - ((x == FF_XBRZ6X) ? 6 : \ - (x == FF_XBRZ5X) ? 5 : \ - (x == FF_XBRZ4X || x == FF_HQ4X || x == FF_SIMPLE4X) ? 4 : \ - (x == FF_XBRZ3X || x == FF_HQ3X || x == FF_SIMPLE3X) ? 3 : \ - x == FF_PLUGIN ? 0 : x == FF_NONE ? 1 : 2) +#define builtin_ff_scale(x) \ + ((x == FF_XBRZ6X) ? 6 : (x == FF_XBRZ5X) \ + ? 5 \ + : (x == FF_XBRZ4X || x == FF_HQ4X || x == FF_SIMPLE4X) \ + ? 4 \ + : (x == FF_XBRZ3X || x == FF_HQ3X || x == FF_SIMPLE3X) \ + ? 3 \ + : x == FF_PLUGIN ? 0 : x == FF_NONE ? 1 : 2) -enum ifbfunc -{ - // this order must match order of option enum and selector widget - IFB_NONE, IFB_SMART, IFB_MOTION_BLUR +enum ifbfunc { + // this order must match order of option enum and selector widget + IFB_NONE, + IFB_SMART, + IFB_MOTION_BLUR }; // make sure and keep this in sync with opts.cpp! -enum renderer -{ - RND_SIMPLE, RND_OPENGL, RND_CAIRO, RND_DIRECT3D -}; +enum renderer { RND_SIMPLE, RND_OPENGL, RND_CAIRO, RND_DIRECT3D }; // likewise -enum audioapi -{ - AUD_SDL, AUD_OPENAL, AUD_DIRECTSOUND, AUD_XAUDIO2 -}; +enum audioapi { AUD_SDL, AUD_OPENAL, AUD_DIRECTSOUND, AUD_XAUDIO2 }; // an unfortunate legacy default; should have a non-digit preceding %d // the only reason to keep it is that user can set slotdir to old dir @@ -387,133 +416,160 @@ class DrawingPanel; class GameArea : public wxPanel { -public: - GameArea(); - virtual ~GameArea(); + public: + GameArea(); + virtual ~GameArea(); - // set to game title + link info - void SetFrameTitle(); + // set to game title + link info + void SetFrameTitle(); - void LoadGame(const wxString &name); - void UnloadGame(bool destruct = false); + void LoadGame(const wxString &name); + void UnloadGame(bool destruct = false); - IMAGE_TYPE game_type() { return loaded; } - u32 game_size() { return rom_size; } - wxString game_dir() { return loaded_game.GetPath(); } - wxString game_name() { return loaded_game.GetFullName(); } - wxString bat_dir() { return batdir; } - wxString state_dir() { return statedir; } - void recompute_dirs(); + IMAGE_TYPE game_type() + { + return loaded; + } + u32 game_size() + { + return rom_size; + } + wxString game_dir() + { + return loaded_game.GetPath(); + } + wxString game_name() + { + return loaded_game.GetFullName(); + } + wxString bat_dir() + { + return batdir; + } + wxString state_dir() + { + return statedir; + } + void recompute_dirs(); - bool LoadState(); - bool LoadState(int slot); - bool LoadState(const wxFileName &fname); + bool LoadState(); + bool LoadState(int slot); + bool LoadState(const wxFileName &fname); - bool SaveState(); - bool SaveState(int slot); - bool SaveState(const wxFileName &fname); + bool SaveState(); + bool SaveState(int slot); + bool SaveState(const wxFileName &fname); - // save to default location - void SaveBattery(bool quiet = false); + // save to default location + void SaveBattery(bool quiet = false); - // true if file at default location may not match memory - bool cheats_dirty; + // true if file at default location may not match memory + bool cheats_dirty; - static const int GBWidth = 160, GBHeight = 144, - SGBWidth = 256, SGBHeight = 224, - GBAWidth = 240, GBAHeight = 160; - void AddBorder(); - void DelBorder(); - // Delete() & set to NULL to force reinit - DrawingPanel* panel; - struct EmulatedSystem* emusys; + static const int GBWidth = 160, GBHeight = 144, SGBWidth = 256, SGBHeight = 224, + GBAWidth = 240, GBAHeight = 160; + void AddBorder(); + void DelBorder(); + // Delete() & set to NULL to force reinit + DrawingPanel *panel; + struct EmulatedSystem *emusys; - // pause game or signal a long operation, similar to pausing - void Pause(); - void Resume(); + // pause game or signal a long operation, similar to pausing + void Pause(); + void Resume(); - // true if paused since last reset of flag - bool was_paused; + // true if paused since last reset of flag + bool was_paused; - // osdstat is always displayed at top-left of screen - wxString osdstat; + // osdstat is always displayed at top-left of screen + wxString osdstat; - // osdtext is displayed for 3 seconds after osdtime, and then cleared - wxString osdtext; - u32 osdtime; + // osdtext is displayed for 3 seconds after osdtime, and then cleared + wxString osdtext; + u32 osdtime; - // Rewind: count down to 0 and rewind - u32 rewind_time; - // Rewind: flag to OnIdle to do a rewind - bool do_rewind; - // Rewind: rewind states - char* rewind_mem; // should be u8, really - int num_rewind_states; - int next_rewind_state; + // Rewind: count down to 0 and rewind + u32 rewind_time; + // Rewind: flag to OnIdle to do a rewind + bool do_rewind; + // Rewind: rewind states + char *rewind_mem; // should be u8, really + int num_rewind_states; + int next_rewind_state; - // Loaded rom information - IMAGE_TYPE loaded; - wxFileName loaded_game; - u32 rom_crc32; - wxString rom_name; - wxString rom_scene_rls; - wxString rom_scene_rls_name; - u32 rom_size; + // Loaded rom information + IMAGE_TYPE loaded; + wxFileName loaded_game; + u32 rom_crc32; + wxString rom_name; + wxString rom_scene_rls; + wxString rom_scene_rls_name; + u32 rom_size; - // FIXME: size this properly +// FIXME: size this properly #define NUM_REWINDS 8 -#define REWIND_SIZE 1024*512*NUM_REWINDS - // FIXME: make this a config option +#define REWIND_SIZE 1024 * 512 * NUM_REWINDS + // FIXME: make this a config option - void ShowFullScreen(bool full); - bool IsFullScreen() { return fullscreen; } - // set size of frame & panel to scaled screen size - void AdjustSize(bool force); + void ShowFullScreen(bool full); + bool IsFullScreen() + { + return fullscreen; + } + // set size of frame & panel to scaled screen size + void AdjustSize(bool force); #ifndef NO_FFMPEG - void StartSoundRecording(const wxString &fname); - void StopSoundRecording(); - void StartVidRecording(const wxString &fname); - void StopVidRecording(); - void AddFrame(const u8* data); // video - void AddFrame(const u16* data, int length); // audio - bool IsRecording() { return snd_rec.IsRecording() || vid_rec.IsRecording(); } + void StartSoundRecording(const wxString &fname); + void StopSoundRecording(); + void StartVidRecording(const wxString &fname); + void StopVidRecording(); + void AddFrame(const u8 *data); // video + void AddFrame(const u16 *data, int length); // audio + bool IsRecording() + { + return snd_rec.IsRecording() || vid_rec.IsRecording(); + } #endif - void StartGameRecording(const wxString &fname); - void StopGameRecording(); - void StartGamePlayback(const wxString &fname); - void StopGamePlayback(); + void StartGameRecording(const wxString &fname); + void StopGameRecording(); + void StartGamePlayback(const wxString &fname); + void StopGamePlayback(); -protected: - // set minsize of frame & panel to unscaled screen size - void LowerMinSize(); - // set minsize of frame & panel to scaled screen size - void AdjustMinSize(); + protected: + // set minsize of frame & panel to unscaled screen size + void LowerMinSize(); + // set minsize of frame & panel to scaled screen size + void AdjustMinSize(); - wxString batdir, statedir; + wxString batdir, statedir; - int basic_width, basic_height; - bool fullscreen; + int basic_width, basic_height; + bool fullscreen; - bool paused; - void OnIdle(wxIdleEvent &); - void OnKeyDown(wxKeyEvent &ev); - void OnKeyUp(wxKeyEvent &ev); - void OnSDLJoy(wxSDLJoyEvent &ev); + bool paused; + void OnIdle(wxIdleEvent &); + void OnKeyDown(wxKeyEvent &ev); + void OnKeyUp(wxKeyEvent &ev); + void OnSDLJoy(wxSDLJoyEvent &ev); #ifndef NO_FFMPEG - MediaRecorder snd_rec, vid_rec; + MediaRecorder snd_rec, vid_rec; #endif -public: - void ShowPointer(); - void HidePointer(); -protected: - void MouseEvent(wxMouseEvent &) { ShowPointer(); } - bool pointer_blanked; - u32 mouse_active_time; + public: + void ShowPointer(); + void HidePointer(); - DECLARE_DYNAMIC_CLASS() - DECLARE_EVENT_TABLE() + protected: + void MouseEvent(wxMouseEvent &) + { + ShowPointer(); + } + bool pointer_blanked; + u32 mouse_active_time; + + DECLARE_DYNAMIC_CLASS() + DECLARE_EVENT_TABLE() }; // wxString version of OSD message @@ -522,92 +578,92 @@ void systemScreenMessage(const wxString &msg); // List of all commands with their descriptions // sorted by cmd field for binary searching // filled in by copy-events.cmake -extern struct cmditem -{ - const wxChar* cmd, *name; - int cmd_id; - int mask_flags; // if non-0, one of the flags must be turned on in win - // to enable this command - wxMenuItem* mi; // the menu item to invoke command, if present +extern struct cmditem { + const wxChar *cmd, *name; + int cmd_id; + int mask_flags; // if non-0, one of the flags must be turned on in win + // to enable this command + wxMenuItem *mi; // the menu item to invoke command, if present } cmdtab[]; extern const int ncmds; // for binary search extern bool cmditem_lt(const struct cmditem &cmd1, const struct cmditem &cmd2); -#include #include "../win32/rpi.h" +#include class FilterThread; class DrawingPanel : public wxObject { -public: - DrawingPanel(int _width, int _height); - ~DrawingPanel(); - void DrawArea(u8** pixels); - // the following wouldn't be necessary with virtual inheritance - virtual wxWindow* GetWindow() = 0; - virtual void Delete() = 0; + public: + DrawingPanel(int _width, int _height); + ~DrawingPanel(); + void DrawArea(u8 **pixels); + // the following wouldn't be necessary with virtual inheritance + virtual wxWindow *GetWindow() = 0; + virtual void Delete() = 0; -protected: - virtual void DrawArea(wxWindowDC &) = 0; - virtual void DrawOSD(wxWindowDC &); - int width, height, scale; - u8* todraw; - u8* pixbuf1, *pixbuf2; - FilterThread* threads; - int nthreads; - wxSemaphore filt_done; - wxDynamicLibrary filt_plugin; - const RENDER_PLUGIN_INFO* rpi; // also flag indicating plugin loaded - // largest buffer required is 32-bit * (max width + 1) * (max height + 2) - u8 delta[257 * 4 * 226]; + protected: + virtual void DrawArea(wxWindowDC &) = 0; + virtual void DrawOSD(wxWindowDC &); + int width, height, scale; + u8 *todraw; + u8 *pixbuf1, *pixbuf2; + FilterThread *threads; + int nthreads; + wxSemaphore filt_done; + wxDynamicLibrary filt_plugin; + const RENDER_PLUGIN_INFO *rpi; // also flag indicating plugin loaded + // largest buffer required is 32-bit * (max width + 1) * (max height + 2) + u8 delta[257 * 4 * 226]; - // following can't work in 2.8 as intended - // inheriting from wxEvtHandler is required, but also breaks subclasses - // due to lack of virtual inheritance (2.9 drops wxEvtHandler req) - // so each child must have a paint event handler (not override of this, - // but it's not virtual anyway, so that won't happen) that calls this - void PaintEv(wxPaintEvent &ev); + // following can't work in 2.8 as intended + // inheriting from wxEvtHandler is required, but also breaks subclasses + // due to lack of virtual inheritance (2.9 drops wxEvtHandler req) + // so each child must have a paint event handler (not override of this, + // but it's not virtual anyway, so that won't happen) that calls this + void PaintEv(wxPaintEvent &ev); - DECLARE_ABSTRACT_CLASS() + DECLARE_ABSTRACT_CLASS() }; class LogDialog : public wxDialog { -public: - LogDialog(); - void Update(); -private: - wxTextCtrl* log; - void Save(wxCommandEvent &ev); - void Clear(wxCommandEvent &ev); + public: + LogDialog(); + void Update(); - DECLARE_EVENT_TABLE() + private: + wxTextCtrl *log; + void Save(wxCommandEvent &ev); + void Clear(wxCommandEvent &ev); + + DECLARE_EVENT_TABLE() }; #include "opts.h" class SoundDriver; -extern SoundDriver* newOpenAL(); +extern SoundDriver *newOpenAL(); // I should add this to SoundDriver, but wxArrayString is wx-specific // I suppose I could make subclass wxSoundDriver. maybe later. extern bool GetOALDevices(wxArrayString &names, wxArrayString &ids); #ifdef __WXMSW__ -extern SoundDriver* newDirectSound(); +extern SoundDriver *newDirectSound(); extern bool GetDSDevices(wxArrayString &names, wxArrayString &ids); -extern SoundDriver* newXAudio2_Output(); +extern SoundDriver *newXAudio2_Output(); extern bool GetXA2Devices(wxArrayString &names, wxArrayString &ids); #endif extern bool debugger; extern void (*dbgMain)(); extern void (*dbgSignal)(int, int); -extern void (*dbgOutput)(const char*, u32); +extern void (*dbgOutput)(const char *, u32); extern void remoteStubMain(); extern void remoteCleanUp(); extern void remoteStubSignal(int, int); -extern void remoteOutput(const char*, u32); +extern void remoteOutput(const char *, u32); extern bool debugOpenPty(); extern const wxString &debugGetSlavePty(); @@ -630,31 +686,31 @@ extern bool turbo; extern int joypress[4], autofire; // FIXME: these defines should be global to project and used instead of raw numbers -#define KEYM_A (1<<0) -#define KEYM_B (1<<1) -#define KEYM_SELECT (1<<2) -#define KEYM_START (1<<3) -#define KEYM_RIGHT (1<<4) -#define KEYM_LEFT (1<<5) -#define KEYM_UP (1<<6) -#define KEYM_DOWN (1<<7) -#define KEYM_R (1<<8) -#define KEYM_L (1<<9) -#define KEYM_SPEED (1<<10) -#define KEYM_CAPTURE (1<<11) -#define KEYM_GS (1<<12) +#define KEYM_A (1 << 0) +#define KEYM_B (1 << 1) +#define KEYM_SELECT (1 << 2) +#define KEYM_START (1 << 3) +#define KEYM_RIGHT (1 << 4) +#define KEYM_LEFT (1 << 5) +#define KEYM_UP (1 << 6) +#define KEYM_DOWN (1 << 7) +#define KEYM_R (1 << 8) +#define KEYM_L (1 << 9) +#define KEYM_SPEED (1 << 10) +#define KEYM_CAPTURE (1 << 11) +#define KEYM_GS (1 << 12) // actually, the wx port adds the following, which could be local: -#define REALKEY_MASK ((1<<13)-1) +#define REALKEY_MASK ((1 << 13) - 1) -#define KEYM_AUTO_A (1<<13) -#define KEYM_AUTO_B (1<<14) -#define KEYM_MOTION_UP (1<<15) -#define KEYM_MOTION_DOWN (1<<16) -#define KEYM_MOTION_LEFT (1<<17) -#define KEYM_MOTION_RIGHT (1<<18) -#define KEYM_MOTION_IN (1<<19) -#define KEYM_MOTION_OUT (1<<20) +#define KEYM_AUTO_A (1 << 13) +#define KEYM_AUTO_B (1 << 14) +#define KEYM_MOTION_UP (1 << 15) +#define KEYM_MOTION_DOWN (1 << 16) +#define KEYM_MOTION_LEFT (1 << 17) +#define KEYM_MOTION_RIGHT (1 << 18) +#define KEYM_MOTION_IN (1 << 19) +#define KEYM_MOTION_OUT (1 << 20) #include "filters.h"