diff --git a/inds/7zAlloc.h b/inds/7zAlloc.h deleted file mode 100755 index 860f116..0000000 --- a/inds/7zAlloc.h +++ /dev/null @@ -1,15 +0,0 @@ -/* 7zAlloc.h -- Allocation functions -2010-10-29 : Igor Pavlov : Public domain */ - -#ifndef __7Z_ALLOC_H -#define __7Z_ALLOC_H - -#include - -void *SzAlloc(void *p, size_t size); -void SzFree(void *p, void *address); - -void *SzAllocTemp(void *p, size_t size); -void SzFreeTemp(void *p, void *address); - -#endif diff --git a/inds/7zFile.h b/inds/7zFile.h deleted file mode 100755 index 7a87368..0000000 --- a/inds/7zFile.h +++ /dev/null @@ -1,83 +0,0 @@ -/* 7zFile.h -- File IO -2009-11-24 : Igor Pavlov : P ublic domain */ - -#ifndef __7Z_FILE_H -#define __7Z_FILE_H - -#ifdef _WIN32 -#define USE_WINDOWS_FILE -#endif - -#ifdef USE_WINDOWS_FILE -#include -#else -#include -#endif - -#include "Types2.h" - -EXTERN_C_BEGIN - -/* ---------- File ---------- */ - -typedef struct -{ - #ifdef USE_WINDOWS_FILE - HANDLE handle; - #else - FILE *file; - #endif -} CSzFile; - -void File_Construct(CSzFile *p); -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -WRes InFile_Open(CSzFile *p, const char *name); -WRes OutFile_Open(CSzFile *p, const char *name); -#endif -#ifdef USE_WINDOWS_FILE -WRes InFile_OpenW(CSzFile *p, const WCHAR *name); -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); -#endif -WRes File_Close(CSzFile *p); - -/* reads max(*size, remain file's size) bytes */ -WRes File_Read(CSzFile *p, void *data, size_t *size); - -/* writes *size bytes */ -WRes File_Write(CSzFile *p, const void *data, size_t *size); - -WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, UInt64 *length); - - -/* ---------- FileInStream ---------- */ - -typedef struct -{ - ISeqInStream s; - CSzFile file; -} CFileSeqInStream; - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p); - - -typedef struct -{ - ISeekInStream s; - CSzFile file; -} CFileInStream; - -void FileInStream_CreateVTable(CFileInStream *p); - - -typedef struct -{ - ISeqOutStream s; - CSzFile file; -} CFileOutStream; - -void FileOutStream_CreateVTable(CFileOutStream *p); - -EXTERN_C_END - -#endif diff --git a/inds/7zStream.c b/inds/7zStream.c deleted file mode 100755 index 7096938..0000000 --- a/inds/7zStream.c +++ /dev/null @@ -1,169 +0,0 @@ -/* 7zStream.c -- 7z Stream functions -2010-03-11 : Igor Pavlov : Public domain */ - -#include - -#include "Types2.h" - -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; -} - -SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) -{ - 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; -} - -SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset) -{ - 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); -} - -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; -} - -SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) -{ - 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; -} - -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; -} - -static SRes LookToRead_Skip(void *pp, size_t offset) -{ - 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; -} - -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); -} - -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; -} - -void LookToRead_Init(CLookToRead *p) -{ - 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); -} - -void SecToLook_CreateVTable(CSecToLook *p) -{ - 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); -} - -void SecToRead_CreateVTable(CSecToRead *p) -{ - p->s.Read = SecToRead_Read; -} diff --git a/inds/Alloc.c b/inds/Alloc.c deleted file mode 100755 index bb24a77..0000000 --- a/inds/Alloc.c +++ /dev/null @@ -1,127 +0,0 @@ -/* Alloc.c -- Memory allocation functions -2008-09-24 -Igor Pavlov -Public domain */ - -#ifdef _WIN32 -#include -#endif -#include - -#include "Alloc.h" - -/* #define _SZ_ALLOC_DEBUG */ - -/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */ -#ifdef _SZ_ALLOC_DEBUG -#include -int g_allocCount = 0; -int g_allocCountMid = 0; -int g_allocCountBig = 0; -#endif - -void *MyAlloc(size_t size) -{ - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - { - void *p = malloc(size); - fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p); - return p; - } - #else - return malloc(size); - #endif -} - -void MyFree(void *address) -{ - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address); - #endif - free(address); -} - -#ifdef _WIN32 - -void *MidAlloc(size_t size) -{ - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++); - #endif - return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); -} - -void MidFree(void *address) -{ - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid); - #endif - if (address == 0) - return; - VirtualFree(address, 0, MEM_RELEASE); -} - -#ifndef MEM_LARGE_PAGES -#undef _7ZIP_LARGE_PAGES -#endif - -#ifdef _7ZIP_LARGE_PAGES -SIZE_T g_LargePageSize = 0; -typedef SIZE_T (WINAPI *GetLargePageMinimumP)(); -#endif - -void SetLargePageSize() -{ - #ifdef _7ZIP_LARGE_PAGES - SIZE_T size = 0; - GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) - GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); - if (largePageMinimum == 0) - return; - size = largePageMinimum(); - if (size == 0 || (size & (size - 1)) != 0) - return; - g_LargePageSize = size; - #endif -} - - -void *BigAlloc(size_t size) -{ - if (size == 0) - return 0; - #ifdef _SZ_ALLOC_DEBUG - fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++); - #endif - - #ifdef _7ZIP_LARGE_PAGES - if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18)) - { - void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)), - MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); - if (res != 0) - return res; - } - #endif - return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE); -} - -void BigFree(void *address) -{ - #ifdef _SZ_ALLOC_DEBUG - if (address != 0) - fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig); - #endif - - if (address == 0) - return; - VirtualFree(address, 0, MEM_RELEASE); -} - -#endif diff --git a/inds/Alloc.h b/inds/Alloc.h deleted file mode 100755 index 6b3f034..0000000 --- a/inds/Alloc.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Alloc.h -- Memory allocation functions -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __COMMON_ALLOC_H -#define __COMMON_ALLOC_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -void *MyAlloc(size_t size); -void MyFree(void *address); - -#ifdef _WIN32 - -void SetLargePageSize(); - -void *MidAlloc(size_t size); -void MidFree(void *address); -void *BigAlloc(size_t size); -void BigFree(void *address); - -#else - -#define MidAlloc(size) MyAlloc(size) -#define MidFree(address) MyFree(address) -#define BigAlloc(size) MyAlloc(size) -#define BigFree(address) MyFree(address) - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/inds/CHBgDropboxSync-master/CHBgDropboxSync.h b/inds/CHBgDropboxSync-master/CHBgDropboxSync.h deleted file mode 100755 index 0fb0861..0000000 --- a/inds/CHBgDropboxSync-master/CHBgDropboxSync.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// CHBgDropboxSync.h -// Passwords -// -// Created by Chris Hulbert on 4/03/12. -// - -#import -#import - -@interface CHBgDropboxSync : NSObject - -+ (void)start; -+ (void)forceStopIfRunning; -+ (void)clearLastSyncData; -@end diff --git a/inds/CHBgDropboxSync-master/ConciseKit/CKAdditions.h b/inds/CHBgDropboxSync-master/ConciseKit/CKAdditions.h deleted file mode 100755 index df2b145..0000000 --- a/inds/CHBgDropboxSync-master/ConciseKit/CKAdditions.h +++ /dev/null @@ -1,3 +0,0 @@ -#import "NSArray+ConciseKit.h" -#import "NSString+ConciseKit.h" -#import "NSDictionary+ConciseKit.h" \ No newline at end of file diff --git a/inds/CHBgDropboxSync-master/ConciseKit/CKMacros.h b/inds/CHBgDropboxSync-master/ConciseKit/CKMacros.h deleted file mode 100755 index 75b06c2..0000000 --- a/inds/CHBgDropboxSync-master/ConciseKit/CKMacros.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef __has_feature - #define __has_feature(x) 0 -#endif -#if __has_feature(objc_arc) - #define IF_ARC(with, without) with -#else - #define IF_ARC(with, without) without -#endif - -#define $new(Klass) IF_ARC([[Klass alloc] init], [[[Klass alloc] init] autorelease]) -#define $eql(a,b) [(a) isEqual:(b)] - -#define $arr(...) [NSArray arrayWithObjects:__VA_ARGS__, nil] -#define $marr(...) [NSMutableArray arrayWithObjects:__VA_ARGS__, nil] -#define $marrnew [NSMutableArray array] -#define $set(...) [NSSet setWithObjects:__VA_ARGS__, nil] -#define $mset(...) [NSMutableSet setWithObjects:__VA_ARGS__, nil] -#define $msetnew [NSMutableSet set] -#define $dict(...) [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil] -#define $mdict(...) [NSMutableDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil] -#define $mdictnew [NSMutableDictionary dictionary] -#define $str(...) [NSString stringWithFormat:__VA_ARGS__] -#define $mstr(...) [NSMutableString stringWithFormat:__VA_ARGS__] -#define $mstrnew [NSMutableString string] - -#define $bool(val) [NSNumber numberWithBool:(val)] -#define $char(val) [NSNumber numberWithChar:(val)] -#define $double(val) [NSNumber numberWithDouble:(val)] -#define $float(val) [NSNumber numberWithFloat:(val)] -#define $int(val) [NSNumber numberWithInt:(val)] -#define $integer(val) [NSNumber numberWithInteger:(val)] -#define $long(val) [NSNumber numberWithLong:(val)] -#define $longlong(val) [NSNumber numberWithLongLong:(val)] -#define $short(val) [NSNumber numberWithShort:(val)] -#define $uchar(val) [NSNumber numberWithUnsignedChar:(val)] -#define $uint(val) [NSNumber numberWithUnsignedInt:(val)] -#define $uinteger(val) [NSNumber numberWithUnsignedInteger:(val)] -#define $ulong(val) [NSNumber numberWithUnsignedLong:(val)] -#define $ulonglong(val) [NSNumber numberWithUnsignedLongLong:(val)] -#define $ushort(val) [NSNumber numberWithUnsignedShort:(val)] - -#define $nonretained(val) [NSValue valueWithNonretainedObject:(val)] -#define $pointer(val) [NSValue valueWithPointer:(val)] -#define $point(val) [NSValue valueWithPoint:(val)] -#define $range(val) [NSValue valueWithRange:(val)] -#define $rect(val) [NSValue valueWithRect:(val)] -#define $size(val) [NSValue valueWithSize:(val)] - -#define $safe(obj) ((NSNull *)(obj) == [NSNull null] ? nil : (obj)) diff --git a/inds/CHBgDropboxSync-master/ConciseKit/NSArray+ConciseKit.h b/inds/CHBgDropboxSync-master/ConciseKit/NSArray+ConciseKit.h deleted file mode 100755 index 5672317..0000000 --- a/inds/CHBgDropboxSync-master/ConciseKit/NSArray+ConciseKit.h +++ /dev/null @@ -1,30 +0,0 @@ -#import - -@interface NSArray (ConciseKit) - -- (id)$first; -- (id)$last; -- (id)$at:(NSUInteger)index; -- (NSArray *)$each:(void (^)(id obj))block; -- (NSArray *)$eachWithIndex:(void (^)(id obj, NSUInteger idx))block; -- (NSArray *)$eachWithStop:(void (^)(id obj, BOOL *stop))block; -- (NSArray *)$eachWithIndexAndStop:(void (^)(id obj, NSUInteger idx, BOOL *stop))block; -- (NSArray *)$map:(id (^)(id obj))block; -- (NSArray *)$mapWithIndex:(id (^)(id obj, NSUInteger idx))block; -- (id)$reduce:(id (^)(id memo, id obj))block; -- (id)$reduceStartingAt:(id)starting with:(id (^)(id memo, id obj))block; -- (NSArray *)$select:(BOOL(^)(id obj))block; -- (id)$detect:(BOOL(^)(id obj))block; -- (NSString *)$join; -- (NSString *)$join:(NSString *)separator; - -@end - -@interface NSMutableArray (ConciseKit) - -- (NSMutableArray *)$push:(id)anObject; -- (id)$pop; -- (NSMutableArray *)$unshift:(id)anObject; -- (id)$shift; - -@end \ No newline at end of file diff --git a/inds/CHBgDropboxSync-master/ConciseKit/NSString+ConciseKit.m b/inds/CHBgDropboxSync-master/ConciseKit/NSString+ConciseKit.m deleted file mode 100755 index 4083227..0000000 --- a/inds/CHBgDropboxSync-master/ConciseKit/NSString+ConciseKit.m +++ /dev/null @@ -1,45 +0,0 @@ -#import "NSString+ConciseKit.h" - -@implementation NSString (ConciseKit) - -- (NSString *)$append:(NSString *)aString { - return [self stringByAppendingString:aString]; -} - -- (NSString *)$prepend:(NSString *)aString { - return [NSString stringWithFormat:@"%@%@", aString, self]; -} - -- (NSArray *)$split:(NSString *)aString { - return [self componentsSeparatedByString:aString]; -} - -- (NSArray *)$split { - return [self componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; -} - -@end - -@implementation NSMutableString (ConciseKit) - -- (NSMutableString *)$append_:(NSString *)aString { - [self appendString:aString]; - return self; -} - -- (NSMutableString *)$prepend_:(NSString *)aString { - [self insertString:aString atIndex:0]; - return self; -} - -- (NSMutableString *)$insert:(NSString *)aString at:(NSUInteger)anIndex { - [self insertString:aString atIndex:anIndex]; - return self; -} - -- (NSMutableString *)$set:(NSString *)aString { - [self setString:aString]; - return self; -} - -@end \ No newline at end of file diff --git a/inds/CHBgDropboxSync-master/DropboxClearer.m b/inds/CHBgDropboxSync-master/DropboxClearer.m deleted file mode 100755 index 2cba073..0000000 --- a/inds/CHBgDropboxSync-master/DropboxClearer.m +++ /dev/null @@ -1,97 +0,0 @@ -// -// DropboxClearer.m -// Passwords -// -// Created by Chris on 10/03/12. -// - -#import "DropboxClearer.h" -#import - -@interface DropboxClearer() { - DBRestClient* client; - int successfulDeletesTogo; -} -@property(copy) dropboxCleared complete; -@end - -@implementation DropboxClearer -@synthesize complete; - -#pragma mark - Completion / cleanup - -- (void)finish:(BOOL)success { - // Autorelease the client using the following two lines, because we don't want it to release *just yet* because it probably called the function that called this, and would crash when the stack pops back to it. - // http://stackoverflow.com/questions/9643770/whats-the-equivalent-of-something-retain-autorelease-in-arc - __autoreleasing DBRestClient* autoreleaseClient = client; - [autoreleaseClient description]; - - // Free the client - client.delegate = nil; - client = nil; - - // Call the block - if (complete) { - complete(success); - complete = nil; - } - [[self class] cancelPreviousPerformRequestsWithTarget:self]; // Cancel the 'timeout' message that was intended for memory management. This'll free self. -} - -- (void)timeout { - [self finish:NO]; -} - -#pragma mark - Callbacks upon deletion - -- (void)restClient:(DBRestClient *)client deletedPath:(NSString *)path { - successfulDeletesTogo--; - if (successfulDeletesTogo<=0) { - [self finish:YES]; - } -} -- (void)restClient:(DBRestClient *)client deletePathFailedWithError:(NSError *)error { - [self finish:NO]; -} - -#pragma mark - Getting the list of files to erase - -// Called by dropbox when the metadata for a folder has returned -- (void)restClient:(DBRestClient*)_client loadedMetadata:(DBMetadata*)metadata { - successfulDeletesTogo=0; - for (DBMetadata* item in metadata.contents) { - successfulDeletesTogo++; - [client deletePath:item.path]; - } - if (!metadata.contents.count) { // All done - nothing to do! - [self finish:YES]; - } -} -- (void)restClient:(DBRestClient*)client metadataUnchangedAtPath:(NSString*)path { - [self finish:NO]; -} -- (void)restClient:(DBRestClient*)client loadMetadataFailedWithError:(NSError*)error { - [self finish:NO]; -} - -#pragma mark - Starting the process - -- (void)start { - client = [[DBRestClient alloc] initWithSession:[DBSession sharedSession]]; - client.delegate = self; - [client loadMetadata:@"/"]; -} - -// Create a dropbox clearer that calls your completion block when it's done. Handles memory for you. -+ (void)doClear:(dropboxCleared)complete { - if ([[DBSession sharedSession] isLinked]) { - DropboxClearer* dc = [[DropboxClearer alloc] init]; - dc.complete = complete; - [dc performSelector:@selector(timeout) withObject:nil afterDelay:30]; // A timeout, also this makes the runloop retain the clearer for us - [dc start]; - } else { - complete(YES); // Not linked - } -} - -@end diff --git a/inds/LZMAExtractor.h b/inds/LZMAExtractor.h deleted file mode 100755 index a754500..0000000 --- a/inds/LZMAExtractor.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// LZMAExtractor.h -// lzmaSDK -// -// Created by Brian Chaikelson on 11/19/09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// - -#import - -@interface LZMAExtractor : NSObject { -} - -// Extract all the contents of a .7z archive directly into the indicated dir. -// Directory structure is ignored if preserveDir is false. - -+ (NSArray*) extract7zArchive:(NSString*)archivePath - dirName:(NSString*)dirName - preserveDir:(BOOL)preserveDir; - -// Extract all the contents of a .7z archive into the indicated temp dir -// and return an array of the fully qualified filenames. This API -// implicitly passes preserveDir as FALSE, so directory elements in the -// entry name are always ignored as files are extracted. If multiple -// entries have duplicated filenames in different directories, then -// this API would would overwrite the duplicate entry file. - -+ (NSArray*) extract7zArchive:(NSString*)archivePath - tmpDirName:(NSString*)tmpDirName; - -// Extract just one entry from an archive and save it at the -// path indicated by outPath. - -+ (BOOL) extractArchiveEntry:(NSString*)archivePath - archiveEntry:(NSString*)archiveEntry - outPath:(NSString*)outPath; - -@end - diff --git a/inds/LZMAExtractor.m b/inds/LZMAExtractor.m deleted file mode 100755 index e97714d..0000000 --- a/inds/LZMAExtractor.m +++ /dev/null @@ -1,190 +0,0 @@ -// -// LZMAExtractor.m -// flipbooks -// -// Created by Mo DeJong on 11/19/09. -// Copyright 2009 __MyCompanyName__. All rights reserved. -// - -#import "LZMAExtractor.h" - -int do7z_extract_entry(char *archivePath, char *archiveCachePath, char *entryName, char *entryPath, int fullPaths); - -@implementation LZMAExtractor - -// Return a fully qualified random filename in the tmp dir. The filename is based on the -// exact time offset since 1970 so it should be unique. - -+ (NSString*) generateUniqueTmpCachePath -{ - NSString *tmpDir = NSTemporaryDirectory(); - - NSDate *nowDate = [NSDate date]; - NSTimeInterval ti = [nowDate timeIntervalSinceReferenceDate]; - - // Format number of seconds as a string with a decimal separator - NSString *doubleString = [NSString stringWithFormat:@"%f", ti]; - - // Remove the decimal point so that the file name consists of - // numeric characters only. - - NSRange range; - range = NSMakeRange(0, [doubleString length]); - NSString *noDecimalString = [doubleString stringByReplacingOccurrencesOfString:@"." - withString:@"" - options:0 - range:range]; - - range = NSMakeRange(0, [noDecimalString length]); - NSString *noMinusString = [noDecimalString stringByReplacingOccurrencesOfString:@"-" - withString:@"" - options:0 - range:range]; - - NSString *filename = [NSString stringWithFormat:@"%@%@", noMinusString, @".cache"]; - - NSString *tmpPath = [tmpDir stringByAppendingPathComponent:filename]; - - return tmpPath; -} - -// Recurse into directories to determine the full paths of elements extracted -// from a archive. - -+ (void) recurseIntoDirectories:(NSMutableArray*)fullPathContents - dirName:(NSString*)dirName - entryPrefix:(NSString*)entryPrefix -{ - NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:dirName error:nil]; - NSAssert(contents, @"contentsOfDirectoryAtPath failed"); - - for (NSString *path in contents) { - //NSLog(@"found dir path: %@", path); - NSString *fullPath = [dirName stringByAppendingPathComponent:path]; - //NSLog(@"found full path: %@", fullPath); - - BOOL isDirectory = FALSE; - BOOL exists = [[NSFileManager defaultManager] fileExistsAtPath:fullPath isDirectory:&isDirectory]; - assert(exists); - - NSString *combinedEntryPrefix; - if ([entryPrefix length] == 0) { - combinedEntryPrefix = path; - } else { - combinedEntryPrefix = [NSString stringWithFormat:@"%@/%@", entryPrefix, path]; - } - - //NSLog(@"found entry path: %@", combinedEntryPrefix); - - if (isDirectory) { - // Recurse into this directory and add the files in the directory - - [self recurseIntoDirectories:fullPathContents dirName:fullPath entryPrefix:combinedEntryPrefix]; - } else { - // A plain file path, append the entry name portion of the path. - - [fullPathContents addObject:fullPath]; - } - } - - return; -} - -// Extract all the contents of a .7z archive directly into the indicated dir - -+ (NSArray*) extract7zArchive:(NSString*)archivePath - dirName:(NSString*)dirName - preserveDir:(BOOL)preserveDir -{ - NSAssert([[NSFileManager defaultManager] fileExistsAtPath:archivePath], @"File does not exist"); - NSAssert(archivePath, @"archivePath"); - NSAssert(dirName, @"dirName"); - - BOOL worked, isDir, existsAlready; - - NSString *myTmpDir = dirName; - existsAlready = [[NSFileManager defaultManager] fileExistsAtPath:myTmpDir isDirectory:&isDir]; - - if (existsAlready && !isDir) { - worked = [[NSFileManager defaultManager] removeItemAtPath:myTmpDir error:nil]; - NSAssert(worked, @"could not remove existing file with same name as tmp dir"); - // create the directory below - } - - if (existsAlready && isDir) { - // Remove all the files in the named tmp dir - NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:myTmpDir error:nil]; - NSAssert(contents, @"contentsOfDirectoryAtPath failed"); - for (NSString *path in contents) { - NSLog(@"found existing dir path: %@", path); - NSString *myTmpDirPath = [myTmpDir stringByAppendingPathComponent:path]; - worked = [[NSFileManager defaultManager] removeItemAtPath:myTmpDirPath error:nil]; - NSAssert(worked, @"could not remove existing file"); - } - } else { - NSLog(@"mtp: %@", myTmpDir); - worked = [[NSFileManager defaultManager] createDirectoryAtPath:myTmpDir withIntermediateDirectories:YES attributes:nil error:nil]; - NSAssert(worked, @"could not create tmp dir"); - } - - worked = [[NSFileManager defaultManager] changeCurrentDirectoryPath:myTmpDir]; - NSAssert(worked, @"cd to tmp 7z dir failed"); - NSLog(@"cd to %@", myTmpDir); - - char *archivePathPtr = (char*) [archivePath UTF8String]; - NSString *archiveCachePath = [self generateUniqueTmpCachePath]; - char *archiveCachePathPtr = (char*) [archiveCachePath UTF8String]; - char *entryNamePtr = NULL; // Extract all entries by passing NULL - char *entryPathPtr = NULL; - - int result = do7z_extract_entry(archivePathPtr, archiveCachePathPtr, entryNamePtr, entryPathPtr, preserveDir ? 1 : 0); - if (result != 0 ) { - NSLog(@"Error Extracting 7z: %i \n%s", result, archivePathPtr); - return nil; - } - NSAssert(result == 0, @"could not extract files from 7z archive"); - - // Examine the contents of the current directory to see what was extracted - - NSMutableArray *fullPathContents = [NSMutableArray array]; - - [self recurseIntoDirectories:fullPathContents dirName:myTmpDir entryPrefix:@""]; - - return [NSArray arrayWithArray:fullPathContents]; -} - -// Extract all the contents of a .7z archive into the indicated temp dir -// and return an array of the fully qualified filenames. - -+ (NSArray*) extract7zArchive:(NSString*)archivePath - tmpDirName:(NSString*)tmpDirName -{ - NSAssert(archivePath, @"archivePath"); - NSAssert(tmpDirName, @"tmpDirName"); - NSString *tmpDir = NSTemporaryDirectory(); - NSString *fullTmpDir = [tmpDir stringByAppendingPathComponent:tmpDirName]; - return [self extract7zArchive:archivePath dirName:fullTmpDir preserveDir:FALSE]; -} - -// Extract just one entry from an archive and save it at the -// path indicated by outPath. - -+ (BOOL) extractArchiveEntry:(NSString*)archivePath - archiveEntry:(NSString*)archiveEntry - outPath:(NSString*)outPath -{ - NSAssert(archivePath, @"archivePath"); - NSAssert(archiveEntry, @"archiveEntry"); - NSAssert(outPath, @"outPath"); - - char *archivePathPtr = (char*) [archivePath UTF8String]; - NSString *archiveCachePath = [self generateUniqueTmpCachePath]; - char *archiveCachePathPtr = (char*) [archiveCachePath UTF8String]; - char *archiveEntryPtr = (char*) [archiveEntry UTF8String]; - char *outPathPtr = (char*) [outPath UTF8String]; - - int result = do7z_extract_entry(archivePathPtr, archiveCachePathPtr, archiveEntryPtr, outPathPtr, 0); - return (result == 0); -} - -@end diff --git a/inds/Lzma2Dec.h b/inds/Lzma2Dec.h deleted file mode 100755 index 827698d..0000000 --- a/inds/Lzma2Dec.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Lzma2Dec.h -- LZMA2 Decoder -2009-05-03 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_DEC_H -#define __LZMA2_DEC_H - -#include "LzmaDec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- State Interface ---------- */ - -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) -#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); -#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); - -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). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - 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); - - -/* ---------- One Call Interface ---------- */ - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - 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); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/inds/LzmaDec.c b/inds/LzmaDec.c deleted file mode 100755 index 0a65faf..0000000 --- a/inds/LzmaDec.c +++ /dev/null @@ -1,995 +0,0 @@ -/* LzmaDec.c -- LZMA Decoder -2010-12-15 : Igor Pavlov : Public domain */ - -#include "LzmaDec.h" - -#include - -#pragma clang diagnostic ignored "-Wmissing-prototypes" - -#define kNumTopBits 24 -#define kTopValue ((UInt32)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_INIT_SIZE 5 - -#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 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; } -#endif - -#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 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 kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -#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 -*/ - -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) -{ - 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; - - Byte *dic = p->dic; - SizeT dicBufSize = p->dicBufSize; - SizeT dicPos = p->dicPos; - - UInt32 processedPos = p->processedPos; - UInt32 checkDicSize = p->checkDicSize; - unsigned len = 0; - - const Byte *buf = p->buf; - UInt32 range = p->range; - UInt32 code = p->code; - - do - { - CLzmaProb *prob; - UInt32 bound; - unsigned ttt; - unsigned posState = processedPos & pbMask; - - 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 < 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; - } - - 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; - } - - len += kMatchMinLen; - - 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); - - 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->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; - - p->processedPos += len; - p->remainLen -= len; - while (len != 0) - { - len--; - 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); - - if (p->remainLen > kMatchSpecLenStart) - { - p->remainLen = kMatchSpecLenStart; - } - return 0; -} - -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; - - { - 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; - - 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; -} - - -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; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) -{ - 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; -} - -void LzmaDec_Init(CLzmaDec *p) -{ - 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; -} - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - SizeT inSize = *srcLen; - (*srcLen) = 0; - LzmaDec_WriteRem(p, dicLimit); - - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->remainLen != kMatchSpecLenStart) - { - int checkEndMarkNow; - - 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; - - LzmaDec_InitRc(p, p->tempBuf); - p->tempBufSize = 0; - } - - 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; - } - } - 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) -{ - 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; - } -} - -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->probs); - p->probs = 0; -} - -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->dic); - p->dic = 0; -} - -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *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; - - 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; -} - -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; -} - -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; -} - -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 outSize = *destLen, inSize = *srcLen; - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; - LzmaDec_Construct(&p); - RINOK(LzmaDec_AllocateProbs(&p, propData, propSize, alloc)); - p.dic = dest; - p.dicBufSize = outSize; - LzmaDec_Init(&p); - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - *destLen = p.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - LzmaDec_FreeProbs(&p, alloc); - return res; -} diff --git a/inds/MHWDirectoryWatcher.h b/inds/MHWDirectoryWatcher.h deleted file mode 100755 index 8138e1d..0000000 --- a/inds/MHWDirectoryWatcher.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * MHWDirectoryWatcher.h - * Created by Martin Hwasser on 12/19/11. - */ - -#import - -@interface MHWDirectoryWatcher : NSObject - -// Returns an initialized MHWDirectoryWatcher and begins to watch the path, if specified -+ (MHWDirectoryWatcher *)directoryWatcherAtPath:(NSString *)watchedPath - startImmediately:(BOOL)startImmediately - callback:(void(^)())cb; - -// Equivalent to calling +directoryWatcherAtPath:startImmediately and passing -// YES for startImmediately. -+ (MHWDirectoryWatcher *)directoryWatcherAtPath:(NSString *)watchPath - callback:(void(^)())cb; - -// Returns YES if started watching, NO if already is watching -- (BOOL)startWatching; - -// Returns YES if stopped watching, NO if not watching -- (BOOL)stopWatching; - -// The path being watched -@property (nonatomic, readonly, copy) NSString *watchedPath; - -@end diff --git a/inds/NSString+CompareToVersion.h b/inds/NSString+CompareToVersion.h deleted file mode 100755 index 7b7b3b5..0000000 --- a/inds/NSString+CompareToVersion.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// NSString+CompareToVersion.h -// Stijn Mathysen -// -// Created by Stijn Mathysen on 27/02/14. -// Copyright (c) 2014 Stijn Mathysen. Released under the MIT license -// - -#import - -@interface NSString (CompareToVersion) - --(NSComparisonResult)compareToVersion:(NSString *)version; - --(BOOL)isOlderThanVersion:(NSString *)version; --(BOOL)isNewerThanVersion:(NSString *)version; --(BOOL)isEqualToVersion:(NSString *)version; --(BOOL)isEqualOrOlderThanVersion:(NSString *)version; --(BOOL)isEqualOrNewerThanVersion:(NSString *)version; - -@end diff --git a/inds/NSString+CompareToVersion.m b/inds/NSString+CompareToVersion.m deleted file mode 100755 index b693efa..0000000 --- a/inds/NSString+CompareToVersion.m +++ /dev/null @@ -1,62 +0,0 @@ -// -// NSString+CompareToVersion.m -// Skylight BVBA -// -// Created by Stijn Mathysen on 27/02/14. -// Copyright (c) 2014 Stijn Mathysen. Released under the MIT license -// - -#import "NSString+CompareToVersion.h" - -@implementation NSString (CompareToVersion) - --(NSComparisonResult)compareToVersion:(NSString *)version{ - NSComparisonResult result; - - result = NSOrderedSame; - - if(![self isEqualToString:version]){ - NSArray *thisVersion = [self componentsSeparatedByString:@"."]; - NSArray *compareVersion = [version componentsSeparatedByString:@"."]; - - for(NSInteger index = 0; index < MAX([thisVersion count], [compareVersion count]); index++){ - NSInteger thisSegment = (index < [thisVersion count]) ? [[thisVersion objectAtIndex:index] integerValue] : 0; - NSInteger compareSegment = (index < [compareVersion count]) ? [[compareVersion objectAtIndex:index] integerValue] : 0; - - if(thisSegment < compareSegment){ - result = NSOrderedAscending; - break; - } - - if(thisSegment > compareSegment){ - result = NSOrderedDescending; - break; - } - } - } - - return result; -} - - --(BOOL)isOlderThanVersion:(NSString *)version{ - return ([self compareToVersion:version] == NSOrderedAscending); -} - --(BOOL)isNewerThanVersion:(NSString *)version{ - return ([self compareToVersion:version] == NSOrderedDescending); -} - --(BOOL)isEqualToVersion:(NSString *)version{ - return ([self compareToVersion:version] == NSOrderedSame); -} - --(BOOL)isEqualOrOlderThanVersion:(NSString *)version{ - return ([self compareToVersion:version] != NSOrderedDescending); -} - --(BOOL)isEqualOrNewerThanVersion:(NSString *)version{ - return ([self compareToVersion:version] != NSOrderedAscending); -} - -@end \ No newline at end of file diff --git a/inds/Ppmd.h b/inds/Ppmd.h deleted file mode 100755 index 8f43ff1..0000000 --- a/inds/Ppmd.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Ppmd.h -- PPMD codec common code -2011-01-27 : Igor Pavlov : Public domain -This code is based on PPMd var.H (2001): Dmitry Shkarin : Public domain */ - -#ifndef __PPMD_H -#define __PPMD_H - -#include "Types2.h" -#include "CpuArch.h" - -EXTERN_C_BEGIN - -#ifdef MY_CPU_32BIT - #define PPMD_32BIT -#endif - -#define PPMD_INT_BITS 7 -#define PPMD_PERIOD_BITS 7 -#define PPMD_BIN_SCALE (1 << (PPMD_INT_BITS + PPMD_PERIOD_BITS)) - -#define PPMD_GET_MEAN_SPEC(summ, shift, round) (((summ) + (1 << ((shift) - (round)))) >> (shift)) -#define PPMD_GET_MEAN(summ) PPMD_GET_MEAN_SPEC((summ), PPMD_PERIOD_BITS, 2) -#define PPMD_UPDATE_PROB_0(prob) ((prob) + (1 << PPMD_INT_BITS) - PPMD_GET_MEAN(prob)) -#define PPMD_UPDATE_PROB_1(prob) ((prob) - PPMD_GET_MEAN(prob)) - -#define PPMD_N1 4 -#define PPMD_N2 4 -#define PPMD_N3 4 -#define PPMD_N4 ((128 + 3 - 1 * PPMD_N1 - 2 * PPMD_N2 - 3 * PPMD_N3) / 4) -#define PPMD_NUM_INDEXES (PPMD_N1 + PPMD_N2 + PPMD_N3 + PPMD_N4) - -#pragma pack(push, 1) -/* Most compilers works OK here even without #pragma pack(push, 1), but some GCC compilers need it. */ - -/* SEE-contexts for PPM-contexts with masked symbols */ -typedef struct -{ - UInt16 Summ; /* Freq */ - Byte Shift; /* Speed of Freq change; low Shift is for fast change */ - Byte Count; /* Count to next change of Shift */ -} CPpmd_See; - -#define Ppmd_See_Update(p) if ((p)->Shift < PPMD_PERIOD_BITS && --(p)->Count == 0) \ - { (p)->Summ <<= 1; (p)->Count = (Byte)(3 << (p)->Shift++); } - -typedef struct -{ - Byte Symbol; - Byte Freq; - UInt16 SuccessorLow; - UInt16 SuccessorHigh; -} CPpmd_State; - -#pragma pack(pop) - -typedef - #ifdef PPMD_32BIT - CPpmd_State * - #else - UInt32 - #endif - CPpmd_State_Ref; - -typedef - #ifdef PPMD_32BIT - void * - #else - UInt32 - #endif - CPpmd_Void_Ref; - -typedef - #ifdef PPMD_32BIT - Byte * - #else - UInt32 - #endif - CPpmd_Byte_Ref; - -#define PPMD_SetAllBitsIn256Bytes(p) \ - { unsigned i; for (i = 0; i < 256 / sizeof(p[0]); i += 8) { \ - p[i+7] = p[i+6] = p[i+5] = p[i+4] = p[i+3] = p[i+2] = p[i+1] = p[i+0] = ~(size_t)0; }} - -EXTERN_C_END - -#endif diff --git a/inds/Ppmd8.c b/inds/Ppmd8.c deleted file mode 100755 index 4fe723f..0000000 --- a/inds/Ppmd8.c +++ /dev/null @@ -1,1120 +0,0 @@ -/* Ppmd8.c -- PPMdI codec -2010-03-24 : Igor Pavlov : Public domain -This code is based on PPMd var.I (2002): Dmitry Shkarin : Public domain */ - -#include - -#include "Ppmd8.h" - -const Byte PPMD8_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}; - -#define MAX_FREQ 124 -#define UNIT_SIZE 12 - -#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) -#else - #define REF(ptr) ((UInt32)((Byte *)(ptr) - (p)->Base)) -#endif - -#define STATS_REF(ptr) ((CPpmd_State_Ref)REF(ptr)) - -#define CTX(ref) ((CPpmd8_Context *)Ppmd8_GetContext(p, ref)) -#define STATS(ctx) Ppmd8_GetStats(p, ctx) -#define ONE_STATE(ctx) Ppmd8Context_OneState(ctx) -#define SUFFIX(ctx) CTX((ctx)->Suffix) - -typedef CPpmd8_Context * CTX_PTR; - -struct CPpmd8_Node_; - -typedef - #ifdef PPMD_32BIT - struct CPpmd8_Node_ * - #else - UInt32 - #endif - CPpmd8_Node_Ref; - -typedef struct CPpmd8_Node_ -{ - UInt32 Stamp; - CPpmd8_Node_Ref Next; - UInt32 NU; -} CPpmd8_Node; - -#ifdef PPMD_32BIT - #define NODE(ptr) (ptr) -#else - #define NODE(offs) ((CPpmd8_Node *)(p->Base + (offs))) -#endif - -#define EMPTY_NODE 0xFFFFFFFF - -void Ppmd8_Construct(CPpmd8 *p) -{ - unsigned i, k, m; - - 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; - } - - 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 < 5; i++) - p->NS2Indx[i] = (Byte)i; - for (m = i, k = 1; i < 260; i++) - { - p->NS2Indx[i] = (Byte)m; - if (--k == 0) - k = (++m) - 4; - } -} - -void Ppmd8_Free(CPpmd8 *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->Base); - p->Size = 0; - p->Base = 0; -} - -Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAlloc *alloc) -{ - if (p->Base == 0 || p->Size != size) - { - Ppmd8_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)) == 0) - return False; - p->Size = size; - } - return True; -} - -static void InsertNode(CPpmd8 *p, void *node, unsigned indx) -{ - ((CPpmd8_Node *)node)->Stamp = EMPTY_NODE; - ((CPpmd8_Node *)node)->Next = (CPpmd8_Node_Ref)p->FreeList[indx]; - ((CPpmd8_Node *)node)->NU = I2U(indx); - p->FreeList[indx] = REF(node); - p->Stamps[indx]++; -} - -static void *RemoveNode(CPpmd8 *p, unsigned indx) -{ - CPpmd8_Node *node = NODE((CPpmd8_Node_Ref)p->FreeList[indx]); - p->FreeList[indx] = node->Next; - p->Stamps[indx]--; - return node; -} - -static void SplitBlock(CPpmd8 *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); -} - -static void GlueFreeBlocks(CPpmd8 *p) -{ - CPpmd8_Node_Ref head = 0; - CPpmd8_Node_Ref *prev = &head; - unsigned i; - - p->GlueCount = 1 << 13; - memset(p->Stamps, 0, sizeof(p->Stamps)); - - /* Order-0 context is always at top UNIT, so we don't need guard NODE at the end. - All blocks up to p->LoUnit can be free, so we need guard NODE at LoUnit. */ - if (p->LoUnit != p->HiUnit) - ((CPpmd8_Node *)p->LoUnit)->Stamp = 0; - - /* Glue free blocks */ - for (i = 0; i < PPMD_NUM_INDEXES; i++) - { - CPpmd8_Node_Ref next = (CPpmd8_Node_Ref)p->FreeList[i]; - p->FreeList[i] = 0; - while (next != 0) - { - CPpmd8_Node *node = NODE(next); - if (node->NU != 0) - { - CPpmd8_Node *node2; - *prev = next; - prev = &(node->Next); - while ((node2 = node + node->NU)->Stamp == EMPTY_NODE) - { - node->NU += node2->NU; - node2->NU = 0; - } - } - next = node->Next; - } - } - *prev = 0; - - /* Fill lists of free blocks */ - while (head != 0) - { - CPpmd8_Node *node = NODE(head); - unsigned nu; - head = node->Next; - nu = node->NU; - if (nu == 0) - continue; - for (; 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); - } -} - -static void *AllocUnitsRare(CPpmd8 *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; -} - -static void *AllocUnits(CPpmd8 *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); -} - -#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(CPpmd8 *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; -} - -static void FreeUnits(CPpmd8 *p, void *ptr, unsigned nu) -{ - InsertNode(p, ptr, U2I(nu)); -} - -static void SpecialFreeUnit(CPpmd8 *p, void *ptr) -{ - if ((Byte *)ptr != p->UnitsStart) - InsertNode(p, ptr, 0); - else - { - #ifdef PPMD8_FREEZE_SUPPORT - *(UInt32 *)ptr = EMPTY_NODE; /* it's used for (Flags == 0xFF) check in RemoveBinContexts */ - #endif - p->UnitsStart += UNIT_SIZE; - } -} - -static void *MoveUnitsUp(CPpmd8 *p, void *oldPtr, unsigned nu) -{ - unsigned indx = U2I(nu); - void *ptr; - if ((Byte *)oldPtr > p->UnitsStart + 16 * 1024 || REF(oldPtr) > p->FreeList[indx]) - return oldPtr; - ptr = RemoveNode(p, indx); - MyMem12Cpy(ptr, oldPtr, nu); - if ((Byte*)oldPtr != p->UnitsStart) - InsertNode(p, oldPtr, indx); - else - p->UnitsStart += U2B(I2U(indx)); - return ptr; -} - -static void ExpandTextArea(CPpmd8 *p) -{ - UInt32 count[PPMD_NUM_INDEXES]; - unsigned i; - memset(count, 0, sizeof(count)); - if (p->LoUnit != p->HiUnit) - ((CPpmd8_Node *)p->LoUnit)->Stamp = 0; - - { - CPpmd8_Node *node = (CPpmd8_Node *)p->UnitsStart; - for (; node->Stamp == EMPTY_NODE; node += node->NU) - { - node->Stamp = 0; - count[U2I(node->NU)]++; - } - p->UnitsStart = (Byte *)node; - } - - for (i = 0; i < PPMD_NUM_INDEXES; i++) - { - CPpmd8_Node_Ref *next = (CPpmd8_Node_Ref *)&p->FreeList[i]; - while (count[i] != 0) - { - CPpmd8_Node *node = NODE(*next); - while (node->Stamp == 0) - { - *next = node->Next; - node = NODE(*next); - p->Stamps[i]--; - if (--count[i] == 0) - break; - } - next = &node->Next; - } - } -} - -#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); -} - -#define RESET_TEXT(offs) { p->Text = p->Base + p->AlignOffset + (offs); } - -static void RestartModel(CPpmd8 *p) -{ - unsigned i, k, m, r; - - memset(p->FreeList, 0, sizeof(p->FreeList)); - memset(p->Stamps, 0, sizeof(p->Stamps)); - RESET_TEXT(0); - 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->MinContext = p->MaxContext = (CTX_PTR)(p->HiUnit -= UNIT_SIZE); /* AllocContext(p); */ - p->MinContext->Suffix = 0; - p->MinContext->NumStats = 255; - p->MinContext->Flags = 0; - 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 = m = 0; m < 25; m++) - { - while (p->NS2Indx[i] == m) - i++; - for (k = 0; k < 8; k++) - { - UInt16 val = (UInt16)(PPMD_BIN_SCALE - kInitBinEsc[k] / (i + 1)); - UInt16 *dest = p->BinSumm[m] + k; - for (r = 0; r < 64; r += 8) - dest[r] = val; - } - } - - for (i = m = 0; m < 24; m++) - { - while (p->NS2Indx[i + 3] == m + 3) - i++; - for (k = 0; k < 32; k++) - { - CPpmd_See *s = &p->See[m][k]; - s->Summ = (UInt16)((2 * i + 5) << (s->Shift = PPMD_PERIOD_BITS - 4)); - s->Count = 7; - } - } -} - -void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod) -{ - p->MaxOrder = maxOrder; - p->RestoreMethod = restoreMethod; - RestartModel(p); - p->DummySee.Shift = PPMD_PERIOD_BITS; - p->DummySee.Summ = 0; /* unused */ - p->DummySee.Count = 64; /* unused */ -} - -static void Refresh(CPpmd8 *p, CTX_PTR ctx, unsigned oldNU, unsigned scale) -{ - unsigned i = ctx->NumStats, escFreq, sumFreq, flags; - CPpmd_State *s = (CPpmd_State *)ShrinkUnits(p, STATS(ctx), oldNU, (i + 2) >> 1); - ctx->Stats = REF(s); - #ifdef PPMD8_FREEZE_SUPPORT - /* fixed over Shkarin's code. Fixed code is not compatible with original code for some files in FREEZE mode. */ - scale |= (ctx->SummFreq >= ((UInt32)1 << 15)); - #endif - flags = (ctx->Flags & (0x10 + 0x04 * scale)) + 0x08 * (s->Symbol >= 0x40); - escFreq = ctx->SummFreq - s->Freq; - sumFreq = (s->Freq = (Byte)((s->Freq + scale) >> scale)); - do - { - escFreq -= (++s)->Freq; - sumFreq += (s->Freq = (Byte)((s->Freq + scale) >> scale)); - flags |= 0x08 * (s->Symbol >= 0x40); - } - while (--i); - ctx->SummFreq = (UInt16)(sumFreq + ((escFreq + scale) >> scale)); - ctx->Flags = (Byte)flags; -} - -static void SwapStates(CPpmd_State *t1, CPpmd_State *t2) -{ - CPpmd_State tmp = *t1; - *t1 = *t2; - *t2 = tmp; -} - -static CPpmd_Void_Ref CutOff(CPpmd8 *p, CTX_PTR ctx, unsigned order) -{ - int i; - unsigned tmp; - CPpmd_State *s; - - if (!ctx->NumStats) - { - s = ONE_STATE(ctx); - if ((Byte *)Ppmd8_GetPtr(p, SUCCESSOR(s)) >= p->UnitsStart) - { - if (order < p->MaxOrder) - SetSuccessor(s, CutOff(p, CTX(SUCCESSOR(s)), order + 1)); - else - SetSuccessor(s, 0); - if (SUCCESSOR(s) || order <= 9) /* O_BOUND */ - return REF(ctx); - } - SpecialFreeUnit(p, ctx); - return 0; - } - - ctx->Stats = STATS_REF(MoveUnitsUp(p, STATS(ctx), tmp = ((unsigned)ctx->NumStats + 2) >> 1)); - - for (s = STATS(ctx) + (i = ctx->NumStats); s >= STATS(ctx); s--) - if ((Byte *)Ppmd8_GetPtr(p, SUCCESSOR(s)) < p->UnitsStart) - { - CPpmd_State *s2 = STATS(ctx) + (i--); - SetSuccessor(s, 0); - SwapStates(s, s2); - } - else if (order < p->MaxOrder) - SetSuccessor(s, CutOff(p, CTX(SUCCESSOR(s)), order + 1)); - else - SetSuccessor(s, 0); - - if (i != ctx->NumStats && order) - { - ctx->NumStats = (Byte)i; - s = STATS(ctx); - if (i < 0) - { - FreeUnits(p, s, tmp); - SpecialFreeUnit(p, ctx); - return 0; - } - if (i == 0) - { - ctx->Flags = (ctx->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40); - *ONE_STATE(ctx) = *s; - FreeUnits(p, s, tmp); - ONE_STATE(ctx)->Freq = (Byte)((unsigned)ONE_STATE(ctx)->Freq + 11) >> 3; - } - else - Refresh(p, ctx, tmp, ctx->SummFreq > 16 * i); - } - return REF(ctx); -} - -#ifdef PPMD8_FREEZE_SUPPORT -static CPpmd_Void_Ref RemoveBinContexts(CPpmd8 *p, CTX_PTR ctx, unsigned order) -{ - CPpmd_State *s; - if (!ctx->NumStats) - { - s = ONE_STATE(ctx); - if ((Byte *)Ppmd8_GetPtr(p, SUCCESSOR(s)) >= p->UnitsStart && order < p->MaxOrder) - SetSuccessor(s, RemoveBinContexts(p, CTX(SUCCESSOR(s)), order + 1)); - else - SetSuccessor(s, 0); - /* Suffix context can be removed already, since different (high-order) - Successors may refer to same context. So we check Flags == 0xFF (Stamp == EMPTY_NODE) */ - if (!SUCCESSOR(s) && (!SUFFIX(ctx)->NumStats || SUFFIX(ctx)->Flags == 0xFF)) - { - FreeUnits(p, ctx, 1); - return 0; - } - else - return REF(ctx); - } - - for (s = STATS(ctx) + ctx->NumStats; s >= STATS(ctx); s--) - if ((Byte *)Ppmd8_GetPtr(p, SUCCESSOR(s)) >= p->UnitsStart && order < p->MaxOrder) - SetSuccessor(s, RemoveBinContexts(p, CTX(SUCCESSOR(s)), order + 1)); - else - SetSuccessor(s, 0); - - return REF(ctx); -} -#endif - -static UInt32 GetUsedMemory(const CPpmd8 *p) -{ - UInt32 v = 0; - unsigned i; - for (i = 0; i < PPMD_NUM_INDEXES; i++) - v += p->Stamps[i] * I2U(i); - return p->Size - (UInt32)(p->HiUnit - p->LoUnit) - (UInt32)(p->UnitsStart - p->Text) - U2B(v); -} - -#ifdef PPMD8_FREEZE_SUPPORT - #define RESTORE_MODEL(c1, fSuccessor) RestoreModel(p, c1, fSuccessor) -#else - #define RESTORE_MODEL(c1, fSuccessor) RestoreModel(p, c1) -#endif - -static void RestoreModel(CPpmd8 *p, CTX_PTR c1 - #ifdef PPMD8_FREEZE_SUPPORT - , CTX_PTR fSuccessor - #endif - ) -{ - CTX_PTR c; - CPpmd_State *s; - RESET_TEXT(0); - for (c = p->MaxContext; c != c1; c = SUFFIX(c)) - if (--(c->NumStats) == 0) - { - s = STATS(c); - c->Flags = (c->Flags & 0x10) + 0x08 * (s->Symbol >= 0x40); - *ONE_STATE(c) = *s; - SpecialFreeUnit(p, s); - ONE_STATE(c)->Freq = (ONE_STATE(c)->Freq + 11) >> 3; - } - else - Refresh(p, c, (c->NumStats+3) >> 1, 0); - - for (; c != p->MinContext; c = SUFFIX(c)) - if (!c->NumStats) - ONE_STATE(c)->Freq -= ONE_STATE(c)->Freq >> 1; - else if ((c->SummFreq += 4) > 128 + 4 * c->NumStats) - Refresh(p, c, (c->NumStats + 2) >> 1, 1); - - #ifdef PPMD8_FREEZE_SUPPORT - if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) - { - p->MaxContext = fSuccessor; - p->GlueCount += !(p->Stamps[1] & 1); - } - else if (p->RestoreMethod == PPMD8_RESTORE_METHOD_FREEZE) - { - while (p->MaxContext->Suffix) - p->MaxContext = SUFFIX(p->MaxContext); - RemoveBinContexts(p, p->MaxContext, 0); - p->RestoreMethod++; - p->GlueCount = 0; - p->OrderFall = p->MaxOrder; - } - else - #endif - if (p->RestoreMethod == PPMD8_RESTORE_METHOD_RESTART || GetUsedMemory(p) < (p->Size >> 1)) - RestartModel(p); - else - { - while (p->MaxContext->Suffix) - p->MaxContext = SUFFIX(p->MaxContext); - do - { - CutOff(p, p->MaxContext, 0); - ExpandTextArea(p); - } - while (GetUsedMemory(p) > 3 * (p->Size >> 2)); - p->GlueCount = 0; - p->OrderFall = p->MaxOrder; - } -} - -static CTX_PTR CreateSuccessors(CPpmd8 *p, Bool skip, CPpmd_State *s1, CTX_PTR c) -{ - CPpmd_State upState; - Byte flags; - CPpmd_Byte_Ref upBranch = (CPpmd_Byte_Ref)SUCCESSOR(p->FoundState); - /* fixed over Shkarin's code. Maybe it could work without + 1 too. */ - CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; - unsigned numPs = 0; - - if (!skip) - ps[numPs++] = p->FoundState; - - while (c->Suffix) - { - CPpmd_Void_Ref successor; - CPpmd_State *s; - c = SUFFIX(c); - if (s1) - { - s = s1; - s1 = NULL; - } - else if (c->NumStats != 0) - { - for (s = STATS(c); s->Symbol != p->FoundState->Symbol; s++); - if (s->Freq < MAX_FREQ - 9) - { - s->Freq++; - c->SummFreq++; - } - } - else - { - s = ONE_STATE(c); - s->Freq += (!SUFFIX(c)->NumStats & (s->Freq < 24)); - } - successor = SUCCESSOR(s); - if (successor != upBranch) - { - c = CTX(successor); - if (numPs == 0) - return c; - break; - } - ps[numPs++] = s; - } - - upState.Symbol = *(const Byte *)Ppmd8_GetPtr(p, upBranch); - SetSuccessor(&upState, upBranch + 1); - flags = 0x10 * (p->FoundState->Symbol >= 0x40) + 0x08 * (upState.Symbol >= 0x40); - - if (c->NumStats == 0) - 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) : ((cf + 2 * s0 - 3) / 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 = 0; - c1->Flags = flags; - *ONE_STATE(c1) = upState; - c1->Suffix = REF(c); - SetSuccessor(ps[--numPs], REF(c1)); - c = c1; - } - while (numPs != 0); - - return c; -} - -static CTX_PTR ReduceOrder(CPpmd8 *p, CPpmd_State *s1, CTX_PTR c) -{ - CPpmd_State *s = NULL; - CTX_PTR c1 = c; - CPpmd_Void_Ref upBranch = REF(p->Text); - - #ifdef PPMD8_FREEZE_SUPPORT - /* The BUG in Shkarin's code was fixed: ps could overflow in CUT_OFF mode. */ - CPpmd_State *ps[PPMD8_MAX_ORDER + 1]; - unsigned numPs = 0; - ps[numPs++] = p->FoundState; - #endif - - SetSuccessor(p->FoundState, upBranch); - p->OrderFall++; - - for (;;) - { - if (s1) - { - c = SUFFIX(c); - s = s1; - s1 = NULL; - } - else - { - if (!c->Suffix) - { - #ifdef PPMD8_FREEZE_SUPPORT - if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) - { - do { SetSuccessor(ps[--numPs], REF(c)); } while (numPs); - RESET_TEXT(1); - p->OrderFall = 1; - } - #endif - return c; - } - c = SUFFIX(c); - if (c->NumStats) - { - if ((s = STATS(c))->Symbol != p->FoundState->Symbol) - do { s++; } while (s->Symbol != p->FoundState->Symbol); - if (s->Freq < MAX_FREQ - 9) - { - s->Freq += 2; - c->SummFreq += 2; - } - } - else - { - s = ONE_STATE(c); - s->Freq += (s->Freq < 32); - } - } - if (SUCCESSOR(s)) - break; - #ifdef PPMD8_FREEZE_SUPPORT - ps[numPs++] = s; - #endif - SetSuccessor(s, upBranch); - p->OrderFall++; - } - - #ifdef PPMD8_FREEZE_SUPPORT - if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) - { - c = CTX(SUCCESSOR(s)); - do { SetSuccessor(ps[--numPs], REF(c)); } while (numPs); - RESET_TEXT(1); - p->OrderFall = 1; - return c; - } - else - #endif - if (SUCCESSOR(s) <= upBranch) - { - CTX_PTR successor; - CPpmd_State *s1 = p->FoundState; - p->FoundState = s; - - successor = CreateSuccessors(p, False, NULL, c); - if (successor == NULL) - SetSuccessor(s, 0); - else - SetSuccessor(s, REF(successor)); - p->FoundState = s1; - } - - if (p->OrderFall == 1 && c1 == p->MaxContext) - { - SetSuccessor(p->FoundState, SUCCESSOR(s)); - p->Text--; - } - if (SUCCESSOR(s) == 0) - return NULL; - return CTX(SUCCESSOR(s)); -} - -static void UpdateModel(CPpmd8 *p) -{ - CPpmd_Void_Ref successor, fSuccessor = SUCCESSOR(p->FoundState); - CTX_PTR c; - unsigned s0, ns, fFreq = p->FoundState->Freq; - Byte flag, fSymbol = p->FoundState->Symbol; - CPpmd_State *s = NULL; - - if (p->FoundState->Freq < MAX_FREQ / 4 && p->MinContext->Suffix != 0) - { - c = SUFFIX(p->MinContext); - - if (c->NumStats == 0) - { - s = ONE_STATE(c); - if (s->Freq < 32) - s->Freq++; - } - else - { - 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 = p->MaxContext; - if (p->OrderFall == 0 && fSuccessor) - { - CTX_PTR cs = CreateSuccessors(p, True, s, p->MinContext); - if (cs == 0) - { - SetSuccessor(p->FoundState, 0); - RESTORE_MODEL(c, CTX(fSuccessor)); - } - else - { - SetSuccessor(p->FoundState, REF(cs)); - p->MaxContext = cs; - } - return; - } - - *p->Text++ = p->FoundState->Symbol; - successor = REF(p->Text); - if (p->Text >= p->UnitsStart) - { - RESTORE_MODEL(c, CTX(fSuccessor)); /* check it */ - return; - } - - if (!fSuccessor) - { - CTX_PTR cs = ReduceOrder(p, s, p->MinContext); - if (cs == NULL) - { - RESTORE_MODEL(c, 0); - return; - } - fSuccessor = REF(cs); - } - else if ((Byte *)Ppmd8_GetPtr(p, fSuccessor) < p->UnitsStart) - { - CTX_PTR cs = CreateSuccessors(p, False, s, p->MinContext); - if (cs == NULL) - { - RESTORE_MODEL(c, 0); - return; - } - fSuccessor = REF(cs); - } - - if (--p->OrderFall == 0) - { - successor = fSuccessor; - p->Text -= (p->MaxContext != p->MinContext); - } - #ifdef PPMD8_FREEZE_SUPPORT - else if (p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE) - { - successor = fSuccessor; - RESET_TEXT(0); - p->OrderFall = 0; - } - #endif - - s0 = p->MinContext->SummFreq - (ns = p->MinContext->NumStats) - fFreq; - flag = 0x08 * (fSymbol >= 0x40); - - for (; c != p->MinContext; c = SUFFIX(c)) - { - unsigned ns1; - UInt32 cf, sf; - if ((ns1 = c->NumStats) != 0) - { - if ((ns1 & 1) != 0) - { - /* Expand for one UNIT */ - unsigned oldNU = (ns1 + 1) >> 1; - unsigned i = U2I(oldNU); - if (i != U2I(oldNU + 1)) - { - void *ptr = AllocUnits(p, i + 1); - void *oldPtr; - if (!ptr) - { - RESTORE_MODEL(c, CTX(fSuccessor)); - return; - } - oldPtr = STATS(c); - MyMem12Cpy(ptr, oldPtr, oldNU); - InsertNode(p, oldPtr, i); - c->Stats = STATS_REF(ptr); - } - } - c->SummFreq = (UInt16)(c->SummFreq + (3 * ns1 + 1 < ns)); - } - else - { - CPpmd_State *s = (CPpmd_State*)AllocUnits(p, 0); - if (!s) - { - RESTORE_MODEL(c, CTX(fSuccessor)); - 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 > 2)); - } - cf = 2 * fFreq * (c->SummFreq + 6); - sf = (UInt32)s0 + c->SummFreq; - if (cf < 6 * sf) - { - cf = 1 + (cf > sf) + (cf >= 4 * sf); - c->SummFreq += 4; - } - else - { - cf = 4 + (cf > 9 * sf) + (cf > 12 * sf) + (cf > 15 * sf); - c->SummFreq = (UInt16)(c->SummFreq + cf); - } - { - CPpmd_State *s = STATS(c) + ns1 + 1; - SetSuccessor(s, successor); - s->Symbol = fSymbol; - s->Freq = (Byte)cf; - c->Flags |= flag; - c->NumStats = (Byte)(ns1 + 1); - } - } - p->MaxContext = p->MinContext = CTX(fSuccessor); -} - -static void Rescale(CPpmd8 *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 - #ifdef PPMD8_FREEZE_SUPPORT - || p->RestoreMethod > PPMD8_RESTORE_METHOD_FREEZE - #endif - ); - s->Freq = (Byte)((s->Freq + adder) >> 1); - sumFreq = s->Freq; - - i = p->MinContext->NumStats; - 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 = (Byte)(p->MinContext->NumStats - i); - if (p->MinContext->NumStats == 0) - { - CPpmd_State tmp = *stats; - tmp.Freq = (Byte)((2 * tmp.Freq + escFreq - 1) / escFreq); - if (tmp.Freq > MAX_FREQ / 3) - tmp.Freq = MAX_FREQ / 3; - InsertNode(p, stats, U2I((numStats + 2) >> 1)); - p->MinContext->Flags = (p->MinContext->Flags & 0x10) + 0x08 * (tmp.Symbol >= 0x40); - *(p->FoundState = ONE_STATE(p->MinContext)) = tmp; - return; - } - n0 = (numStats + 2) >> 1; - n1 = (p->MinContext->NumStats + 2) >> 1; - if (n0 != n1) - p->MinContext->Stats = STATS_REF(ShrinkUnits(p, stats, n0, n1)); - p->MinContext->Flags &= ~0x08; - p->MinContext->Flags |= 0x08 * ((s = STATS(p->MinContext))->Symbol >= 0x40); - i = p->MinContext->NumStats; - do { p->MinContext->Flags |= 0x08*((++s)->Symbol >= 0x40); } while (--i); - } - p->MinContext->SummFreq = (UInt16)(sumFreq + escFreq - (escFreq >> 1)); - p->MinContext->Flags |= 0x4; - p->FoundState = STATS(p->MinContext); -} - -CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked1, UInt32 *escFreq) -{ - CPpmd_See *see; - if (p->MinContext->NumStats != 0xFF) - { - see = p->See[p->NS2Indx[p->MinContext->NumStats + 2] - 3] + - (p->MinContext->SummFreq > 11 * ((unsigned)p->MinContext->NumStats + 1)) + - 2 * (2 * (unsigned)p->MinContext->NumStats < - ((unsigned)SUFFIX(p->MinContext)->NumStats + numMasked1)) + - p->MinContext->Flags; - { - 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(CPpmd8 *p) -{ - CTX_PTR c = CTX(SUCCESSOR(p->FoundState)); - if (p->OrderFall == 0 && (Byte *)c >= p->UnitsStart) - p->MinContext = p->MaxContext = c; - else - { - UpdateModel(p); - p->MinContext = p->MaxContext; - } -} - -void Ppmd8_Update1(CPpmd8 *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 Ppmd8_Update1_0(CPpmd8 *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 Ppmd8_UpdateBin(CPpmd8 *p) -{ - p->FoundState->Freq = (Byte)(p->FoundState->Freq + (p->FoundState->Freq < 196)); - p->PrevSuccess = 1; - p->RunLength++; - NextContext(p); -} - -void Ppmd8_Update2(CPpmd8 *p) -{ - p->MinContext->SummFreq += 4; - if ((p->FoundState->Freq += 4) > MAX_FREQ) - Rescale(p); - p->RunLength = p->InitRL; - UpdateModel(p); - p->MinContext = p->MaxContext; -} - -/* H->I changes: - NS2Indx - GlewCount, and Glue method - BinSum - See / EscFreq - CreateSuccessors updates more suffix contexts - UpdateModel consts. - PrevSuccess Update -*/ diff --git a/inds/Ppmd8.h b/inds/Ppmd8.h deleted file mode 100755 index 6efd4ea..0000000 --- a/inds/Ppmd8.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Ppmd8.h -- PPMdI codec -2010-03-24 : Igor Pavlov : Public domain -This code is based on: - PPMd var.I (2002): Dmitry Shkarin : Public domain - Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ - -#ifndef __PPMD8_H -#define __PPMD8_H - -#include "Ppmd.h" - -EXTERN_C_BEGIN - -#define PPMD8_MIN_ORDER 2 -#define PPMD8_MAX_ORDER 16 - -struct CPpmd8_Context_; - -typedef - #ifdef PPMD_32BIT - struct CPpmd8_Context_ * - #else - UInt32 - #endif - CPpmd8_Context_Ref; - -typedef struct CPpmd8_Context_ -{ - Byte NumStats; - Byte Flags; - UInt16 SummFreq; - CPpmd_State_Ref Stats; - CPpmd8_Context_Ref Suffix; -} CPpmd8_Context; - -#define Ppmd8Context_OneState(p) ((CPpmd_State *)&(p)->SummFreq) - -/* The BUG in Shkarin's code for FREEZE mode was fixed, but that fixed - code is not compatible with original code for some files compressed - in FREEZE mode. So we disable FREEZE mode support. */ - -enum -{ - PPMD8_RESTORE_METHOD_RESTART, - PPMD8_RESTORE_METHOD_CUT_OFF - #ifdef PPMD8_FREEZE_SUPPORT - , PPMD8_RESTORE_METHOD_FREEZE - #endif -}; - -typedef struct -{ - CPpmd8_Context *MinContext, *MaxContext; - CPpmd_State *FoundState; - unsigned OrderFall, InitEsc, PrevSuccess, MaxOrder; - Int32 RunLength, InitRL; /* must be 32-bit at least */ - - UInt32 Size; - UInt32 GlueCount; - Byte *Base, *LoUnit, *HiUnit, *Text, *UnitsStart; - UInt32 AlignOffset; - unsigned RestoreMethod; - - /* Range Coder */ - UInt32 Range; - UInt32 Code; - UInt32 Low; - union - { - IByteIn *In; - IByteOut *Out; - } Stream; - - Byte Indx2Units[PPMD_NUM_INDEXES]; - Byte Units2Indx[128]; - CPpmd_Void_Ref FreeList[PPMD_NUM_INDEXES]; - UInt32 Stamps[PPMD_NUM_INDEXES]; - - Byte NS2BSIndx[256], NS2Indx[260]; - CPpmd_See DummySee, See[24][32]; - UInt16 BinSumm[25][64]; -} CPpmd8; - -void Ppmd8_Construct(CPpmd8 *p); -Bool Ppmd8_Alloc(CPpmd8 *p, UInt32 size, ISzAlloc *alloc); -void Ppmd8_Free(CPpmd8 *p, ISzAlloc *alloc); -void Ppmd8_Init(CPpmd8 *p, unsigned maxOrder, unsigned restoreMethod); -#define Ppmd8_WasAllocated(p) ((p)->Base != NULL) - - -/* ---------- Internal Functions ---------- */ - -extern const Byte PPMD8_kExpEscape[16]; - -#ifdef PPMD_32BIT - #define Ppmd8_GetPtr(p, ptr) (ptr) - #define Ppmd8_GetContext(p, ptr) (ptr) - #define Ppmd8_GetStats(p, ctx) ((ctx)->Stats) -#else - #define Ppmd8_GetPtr(p, offs) ((void *)((p)->Base + (offs))) - #define Ppmd8_GetContext(p, offs) ((CPpmd8_Context *)Ppmd8_GetPtr((p), (offs))) - #define Ppmd8_GetStats(p, ctx) ((CPpmd_State *)Ppmd8_GetPtr((p), ((ctx)->Stats))) -#endif - -void Ppmd8_Update1(CPpmd8 *p); -void Ppmd8_Update1_0(CPpmd8 *p); -void Ppmd8_Update2(CPpmd8 *p); -void Ppmd8_UpdateBin(CPpmd8 *p); - -#define Ppmd8_GetBinSumm(p) \ - &p->BinSumm[p->NS2Indx[Ppmd8Context_OneState(p->MinContext)->Freq - 1]][ \ - p->NS2BSIndx[Ppmd8_GetContext(p, p->MinContext->Suffix)->NumStats] + \ - p->PrevSuccess + p->MinContext->Flags + ((p->RunLength >> 26) & 0x20)] - -CPpmd_See *Ppmd8_MakeEscFreq(CPpmd8 *p, unsigned numMasked, UInt32 *scale); - - -/* ---------- Decode ---------- */ - -Bool Ppmd8_RangeDec_Init(CPpmd8 *p); -#define Ppmd8_RangeDec_IsFinishedOK(p) ((p)->Code == 0) -int Ppmd8_DecodeSymbol(CPpmd8 *p); /* returns: -1 as EndMarker, -2 as DataError */ - - -/* ---------- Encode ---------- */ - -#define Ppmd8_RangeEnc_Init(p) { (p)->Low = 0; (p)->Range = 0xFFFFFFFF; } -void Ppmd8_RangeEnc_FlushData(CPpmd8 *p); -void Ppmd8_EncodeSymbol(CPpmd8 *p, int symbol); /* symbol = -1 means EndMarker */ - -EXTERN_C_END - -#endif diff --git a/inds/Ppmd8Dec.c b/inds/Ppmd8Dec.c deleted file mode 100755 index 934eae7..0000000 --- a/inds/Ppmd8Dec.c +++ /dev/null @@ -1,155 +0,0 @@ -/* Ppmd8Dec.c -- PPMdI Decoder -2010-04-16 : Igor Pavlov : Public domain -This code is based on: - PPMd var.I (2002): Dmitry Shkarin : Public domain - Carryless rangecoder (1999): Dmitry Subbotin : Public domain */ - -#include "Ppmd8.h" - -#define kTop (1 << 24) -#define kBot (1 << 15) - -Bool Ppmd8_RangeDec_Init(CPpmd8 *p) -{ - unsigned i; - p->Low = 0; - p->Range = 0xFFFFFFFF; - p->Code = 0; - for (i = 0; i < 4; i++) - p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In); - return (p->Code < 0xFFFFFFFF); -} - -static UInt32 RangeDec_GetThreshold(CPpmd8 *p, UInt32 total) -{ - return p->Code / (p->Range /= total); -} - -static void RangeDec_Decode(CPpmd8 *p, UInt32 start, UInt32 size) -{ - start *= p->Range; - p->Low += start; - p->Code -= start; - p->Range *= size; - - while ((p->Low ^ (p->Low + p->Range)) < kTop || - (p->Range < kBot && ((p->Range = (0 - p->Low) & (kBot - 1)), 1))) - { - p->Code = (p->Code << 8) | p->Stream.In->Read(p->Stream.In); - p->Range <<= 8; - p->Low <<= 8; - } -} - -#define MASK(sym) ((signed char *)charMask)[sym] - -int Ppmd8_DecodeSymbol(CPpmd8 *p) -{ - size_t charMask[256 / sizeof(size_t)]; - if (p->MinContext->NumStats != 0) - { - CPpmd_State *s = Ppmd8_GetStats(p, p->MinContext); - unsigned i; - UInt32 count, hiCnt; - if ((count = RangeDec_GetThreshold(p, p->MinContext->SummFreq)) < (hiCnt = s->Freq)) - { - Byte symbol; - RangeDec_Decode(p, 0, s->Freq); - p->FoundState = s; - symbol = s->Symbol; - Ppmd8_Update1_0(p); - return symbol; - } - p->PrevSuccess = 0; - i = p->MinContext->NumStats; - do - { - if ((hiCnt += (++s)->Freq) > count) - { - Byte symbol; - RangeDec_Decode(p, hiCnt - s->Freq, s->Freq); - p->FoundState = s; - symbol = s->Symbol; - Ppmd8_Update1(p); - return symbol; - } - } - while (--i); - if (count >= p->MinContext->SummFreq) - return -2; - RangeDec_Decode(p, hiCnt, p->MinContext->SummFreq - hiCnt); - PPMD_SetAllBitsIn256Bytes(charMask); - MASK(s->Symbol) = 0; - i = p->MinContext->NumStats; - do { MASK((--s)->Symbol) = 0; } while (--i); - } - else - { - UInt16 *prob = Ppmd8_GetBinSumm(p); - if (((p->Code / (p->Range >>= 14)) < *prob)) - { - Byte symbol; - RangeDec_Decode(p, 0, *prob); - *prob = (UInt16)PPMD_UPDATE_PROB_0(*prob); - symbol = (p->FoundState = Ppmd8Context_OneState(p->MinContext))->Symbol; - Ppmd8_UpdateBin(p); - return symbol; - } - RangeDec_Decode(p, *prob, (1 << 14) - *prob); - *prob = (UInt16)PPMD_UPDATE_PROB_1(*prob); - p->InitEsc = PPMD8_kExpEscape[*prob >> 10]; - PPMD_SetAllBitsIn256Bytes(charMask); - MASK(Ppmd8Context_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 = Ppmd8_GetContext(p, p->MinContext->Suffix); - } - while (p->MinContext->NumStats == numMasked); - hiCnt = 0; - s = Ppmd8_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 = Ppmd8_MakeEscFreq(p, numMasked, &freqSum); - freqSum += hiCnt; - count = RangeDec_GetThreshold(p, freqSum); - - if (count < hiCnt) - { - Byte symbol; - CPpmd_State **pps = ps; - for (hiCnt = 0; (hiCnt += (*pps)->Freq) <= count; pps++); - s = *pps; - RangeDec_Decode(p, hiCnt - s->Freq, s->Freq); - Ppmd_See_Update(see); - p->FoundState = s; - symbol = s->Symbol; - Ppmd8_Update2(p); - return symbol; - } - if (count >= freqSum) - return -2; - RangeDec_Decode(p, hiCnt, freqSum - hiCnt); - see->Summ = (UInt16)(see->Summ + freqSum); - do { MASK(ps[--i]->Symbol) = 0; } while (i != 0); - } -} diff --git a/inds/RBVolumeButtons.m b/inds/RBVolumeButtons.m deleted file mode 100644 index cd7a71d..0000000 --- a/inds/RBVolumeButtons.m +++ /dev/null @@ -1,204 +0,0 @@ -// -// RBVolumeButtons.m -// VolumeSnap -// -// Created by Randall Brown on 11/17/11. -// Copyright (c) 2011 __MyCompanyName__. All rights reserved. -// - -#import "RBVolumeButtons.h" -#import -#import - -@interface RBVolumeButtons() - -@property (nonatomic) BOOL isStealingVolumeButtons; -@property (nonatomic) BOOL hadToLowerVolume; -@property (nonatomic) BOOL hadToRaiseVolume; -@property (nonatomic) BOOL suspended; -@property (nonatomic, readwrite) float launchVolume; -@property (nonatomic, retain) UIView *volumeView; - -@end - -@implementation RBVolumeButtons - -static void volumeListenerCallback ( - void *inClientData, - AudioSessionPropertyID inID, - UInt32 inDataSize, - const void *inData - ){ - const float *volumePointer = inData; - float volume = *volumePointer; - - if (volume > [(RBVolumeButtons*)inClientData launchVolume]) - { - [(RBVolumeButtons*)inClientData volumeUp]; - } - else if (volume < [(RBVolumeButtons*)inClientData launchVolume]) - { - [(RBVolumeButtons*)inClientData volumeDown]; - } -} - -- (void)volumeDown -{ - AudioSessionRemovePropertyListenerWithUserData(kAudioSessionProperty_CurrentHardwareOutputVolume, volumeListenerCallback, self); - - [[MPMusicPlayerController applicationMusicPlayer] setVolume:self.launchVolume]; - - [self performSelector:@selector(initializeVolumeButtonStealer) withObject:self afterDelay:0.1]; - - if (self.downBlock) - { - self.downBlock(); - } -} - -- (void)volumeUp -{ - AudioSessionRemovePropertyListenerWithUserData(kAudioSessionProperty_CurrentHardwareOutputVolume, volumeListenerCallback, self); - - [[MPMusicPlayerController applicationMusicPlayer] setVolume:self.launchVolume]; - - [self performSelector:@selector(initializeVolumeButtonStealer) withObject:self afterDelay:0.1]; - - if (self.upBlock) - { - self.upBlock(); - } -} - -- (void)startStealingVolumeButtonEvents -{ - NSAssert([[NSThread currentThread] isMainThread], @"This must be called from the main thread"); - - if (self.isStealingVolumeButtons) - { - return; - } - - self.isStealingVolumeButtons = YES; - - AudioSessionInitialize(NULL, NULL, NULL, NULL); - - const UInt32 sessionCategory = kAudioSessionCategory_AmbientSound; - AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory); - - AudioSessionSetActive(YES); - - self.launchVolume = [[MPMusicPlayerController applicationMusicPlayer] volume]; - self.hadToLowerVolume = self.launchVolume == 1.0; - self.hadToRaiseVolume = self.launchVolume == 0.0; - - // Avoid flashing the volume indicator - if (self.hadToLowerVolume || self.hadToRaiseVolume) - { - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.hadToLowerVolume) - { - [[MPMusicPlayerController applicationMusicPlayer] setVolume:0.95]; - self.launchVolume = 0.95; - } - - if (self.hadToRaiseVolume) - { - [[MPMusicPlayerController applicationMusicPlayer] setVolume:0.05]; - self.launchVolume = 0.05; - } - }); - } - - CGRect frame = CGRectMake(0, -100, 10, 0); - self.volumeView = [[[MPVolumeView alloc] initWithFrame:frame] autorelease]; - [self.volumeView sizeToFit]; - [[[[UIApplication sharedApplication] windows] firstObject] insertSubview:self.volumeView atIndex:0]; - - [self initializeVolumeButtonStealer]; - - if (!self.suspended) - { - // Observe notifications that trigger suspend - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(suspendStealingVolumeButtonEvents:) - name:UIApplicationWillResignActiveNotification // -> Inactive - object:nil]; - - // Observe notifications that trigger resume - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(resumeStealingVolumeButtonEvents:) - name:UIApplicationDidBecomeActiveNotification // <- Active - object:nil]; - } -} - -- (void)suspendStealingVolumeButtonEvents:(NSNotification *)notification -{ - if (self.isStealingVolumeButtons) - { - self.suspended = YES; // Call first! - [self stopStealingVolumeButtonEvents]; - } -} - -- (void)resumeStealingVolumeButtonEvents:(NSNotification *)notification -{ - if (self.suspended) - { - [self startStealingVolumeButtonEvents]; - self.suspended = NO; // Call last! - } -} - -- (void)stopStealingVolumeButtonEvents -{ - NSAssert([[NSThread currentThread] isMainThread], @"This must be called from the main thread"); - - if (!self.isStealingVolumeButtons) - { - return; - } - - // Stop observing all notifications - if (!self.suspended) - { - [[NSNotificationCenter defaultCenter] removeObserver:self]; - } - - AudioSessionRemovePropertyListenerWithUserData(kAudioSessionProperty_CurrentHardwareOutputVolume, volumeListenerCallback, self); - - if (self.hadToLowerVolume) - { - [[MPMusicPlayerController applicationMusicPlayer] setVolume:1.0]; - } - - if (self.hadToRaiseVolume) - { - [[MPMusicPlayerController applicationMusicPlayer] setVolume:0.0]; - } - - [self.volumeView removeFromSuperview]; - self.volumeView = nil; - - //AudioSessionSetActive(NO); - - self.isStealingVolumeButtons = NO; -} - -- (void)dealloc -{ - self.suspended = NO; - [self stopStealingVolumeButtonEvents]; - - self.upBlock = nil; - self.downBlock = nil; - [super dealloc]; -} - -- (void)initializeVolumeButtonStealer -{ - AudioSessionAddPropertyListener(kAudioSessionProperty_CurrentHardwareOutputVolume, volumeListenerCallback, self); -} - -@end diff --git a/inds/SCLTextView.h b/inds/SCLTextView.h deleted file mode 100755 index 4f91486..0000000 --- a/inds/SCLTextView.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// SCLTextView.h -// SCLAlertView -// -// Created by Diogo Autilio on 9/18/15. -// Copyright © 2015 AnyKey Entertainment. All rights reserved. -// - -#if defined(__has_feature) && __has_feature(modules) -@import UIKit; -#else -#import -#endif - -@interface SCLTextView : UITextField - -@end diff --git a/inds/UIDevice+Private.h b/inds/UIDevice+Private.h deleted file mode 100644 index 39c673b..0000000 --- a/inds/UIDevice+Private.h +++ /dev/null @@ -1,11 +0,0 @@ -#import - -#import "UITapticEngine.h" - -@interface UIDevice (Private) - -- (UITapticEngine *)tapticEngine; - -- (UITapticEngine *)_tapticEngine; - -@end \ No newline at end of file diff --git a/inds/UIDevice+Private.m b/inds/UIDevice+Private.m deleted file mode 100644 index 7226745..0000000 --- a/inds/UIDevice+Private.m +++ /dev/null @@ -1,22 +0,0 @@ -// -// UITapticEngine.m -// ViewControllerPreview -// -// Created by Dal Rupnik on 28/09/15. -// Copyright © 2015 Apple Inc. All rights reserved. -// - -#import "UIDevice+Private.h" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wincomplete-implementation" - -@implementation UIDevice (Private) - -- (UITapticEngine *)tapticEngine -{ - return [self _tapticEngine]; -} - -@end - -#pragma clang diagnostic pop diff --git a/inds/UIImage+Utilities.m b/inds/UIImage+Utilities.m deleted file mode 100644 index ab542f8..0000000 --- a/inds/UIImage+Utilities.m +++ /dev/null @@ -1,80 +0,0 @@ -// -// UIImage+Utilities.m -// ShoutOut -// -// Created by Will Cobb on 7/15/15. -// Copyright (c) 2015 Will Cobb. All rights reserved. -// - -#import "UIImage+Utilities.h" - -@implementation UIImage (Utilities) - -- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize -{ - UIImage *sourceImage = self; - UIImage *newImage = nil; - CGSize imageSize = sourceImage.size; - CGFloat width = imageSize.width; - CGFloat height = imageSize.height; - CGFloat targetWidth = targetSize.width; - CGFloat targetHeight = targetSize.height; - CGFloat scaleFactor = 0.0; - CGFloat scaledWidth = targetWidth; - CGFloat scaledHeight = targetHeight; - CGPoint thumbnailPoint = CGPointMake(0.0,0.0); - - if (CGSizeEqualToSize(imageSize, targetSize) == NO) - { - CGFloat widthFactor = targetWidth / width; - CGFloat heightFactor = targetHeight / height; - - if (widthFactor > heightFactor) - { - scaleFactor = widthFactor; // scale to fit height - } - else - { - scaleFactor = heightFactor; // scale to fit width - } - - scaledWidth = width * scaleFactor; - scaledHeight = height * scaleFactor; - - // center the image - if (widthFactor > heightFactor) - { - thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5; - } - else - { - if (widthFactor < heightFactor) - { - thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5; - } - } - } - - UIGraphicsBeginImageContextWithOptions(targetSize, 1.0f, 0.0f); // this will crop - - CGRect thumbnailRect = CGRectZero; - thumbnailRect.origin = thumbnailPoint; - thumbnailRect.size.width = scaledWidth; - thumbnailRect.size.height = scaledHeight; - - [sourceImage drawInRect:thumbnailRect]; - - newImage = UIGraphicsGetImageFromCurrentImageContext(); - - if(newImage == nil) - { - NSLog(@"could not scale image"); - } - - //pop the context to get back to the default - UIGraphicsEndImageContext(); - - return newImage; -} - -@end diff --git a/inds/UITapticEngine.h b/inds/UITapticEngine.h deleted file mode 100644 index ff6d733..0000000 --- a/inds/UITapticEngine.h +++ /dev/null @@ -1,10 +0,0 @@ -static int const UITapticEngineFeedbackPeek = 1001; -static int const UITapticEngineFeedbackPop = 1002; - -@interface UITapticEngine : NSObject - -- (void)actuateFeedback:(int)arg1; -- (void)endUsingFeedback:(int)arg1; -- (void)prepareUsingFeedback:(int)arg1; - -@end \ No newline at end of file diff --git a/inds/UIViewController+BackButtonHandler.h b/inds/UIViewController+BackButtonHandler.h deleted file mode 100644 index c4e96ab..0000000 --- a/inds/UIViewController+BackButtonHandler.h +++ /dev/null @@ -1,36 +0,0 @@ -// -// UIViewController+BackButtonHandler.h -// -// Created by Sergey Nikitenko on 10/1/13. -// Copyright 2013 Sergey Nikitenko. All rights reserved. -// -// Permission is hereby granted, free of charge, 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: -// -// 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, 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. -// - -#import - -@protocol BackButtonHandlerProtocol -@optional -// Override this method in UIViewController derived class to handle 'Back' button click --(BOOL)navigationShouldPopOnBackButton; -@end - -@interface UIViewController (BackButtonHandler) - -@end diff --git a/inds/ZAActivityBar/SKBounceAnimation/SKBounceAnimation.m b/inds/ZAActivityBar/SKBounceAnimation/SKBounceAnimation.m deleted file mode 100755 index 7968dd5..0000000 --- a/inds/ZAActivityBar/SKBounceAnimation/SKBounceAnimation.m +++ /dev/null @@ -1,381 +0,0 @@ -// -// SKBounceAnimation.m -// SKBounceAnimation -// -// Created by Soroush Khanlou on 6/15/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#import "SKBounceAnimation.h" - -/* - Keypaths: - - Float animations: - anchorPoint - cornerRadius - borderWidth - opacity - shadowRadius - shadowOpacity - zPosition - - Point/size animations: - position - shadowOffset - - Rect animations: - bounds - frame - not strictly animatable, use bounds - contentsRect - - Colors: - backgroundColor - borderColor - shadowColor - - CATransform3D: - transform - - - Meaningless: - backgroundFilters - compositingFilter - contents - doubleSided - filters - hidden - mask - masksToBounds - sublayers - sublayerTransform - - */ - -@interface SKBounceAnimation (Private) - -- (void) createValueArray; -- (NSArray*) valueArrayForStartValue:(CGFloat)startValue endValue:(CGFloat)endValue; -- (CGPathRef) createPathFromXValues:(NSArray*)xValues yValues:(NSArray*)yValues; -- (NSArray*) createRectArrayFromXValues:(NSArray*)xValues yValues:(NSArray*)yValues widths:(NSArray*)widths heights:(NSArray*)heights; -- (NSArray*) createColorArrayFromRed:(NSArray*)redValues green:(NSArray*)greenValues blue:(NSArray*)blueValues alpha:(NSArray*)alphaValues; -- (NSArray*) createTransformArrayFromM11:(NSArray*)m11 M12:(NSArray*)m12 M13:(NSArray*)m13 M14:(NSArray*)m14 - M21:(NSArray*)m21 M22:(NSArray*)m22 M23:(NSArray*)m23 M14:(NSArray*)m24 - M31:(NSArray*)m31 M32:(NSArray*)m32 M33:(NSArray*)m33 M14:(NSArray*)m34 - M41:(NSArray*)m41 M42:(NSArray*)m42 M43:(NSArray*)m43 M14:(NSArray*)m44; - -@end - -@implementation SKBounceAnimation - -@synthesize fromValue, byValue, toValue, numberOfBounces, shouldOvershoot; - -+ (SKBounceAnimation*) animationWithKeyPath:(NSString*)keyPath { - return [[self alloc] initWithKeyPath:keyPath]; -} - -- (id) initWithKeyPath:(NSString*)keyPath { - self = [super init]; - if (self) { - super.keyPath = keyPath; - self.numberOfBounces = 2; - self.shouldOvershoot = YES; - } - return self; -} - -- (void) setFromValue:(id)newFromValue { - [super setValue:newFromValue forKey:@"fromValueKey"]; - [self createValueArray]; -} - -- (void) setByValue:(id)newByValue { - [super setValue:newByValue forKey:@"byValueKey"]; - //don't know if this is to spec - self.toValue = [NSNumber numberWithFloat:[self.fromValue floatValue] + [self.byValue floatValue]]; - [self createValueArray]; -} - -- (void) setToValue:(id)newToValue { - [super setValue:newToValue forKey:@"toValueKey"]; - [self createValueArray]; -} - -- (void) setDuration:(CFTimeInterval)newDuration { - [super setDuration:newDuration]; - [self createValueArray]; -} - -- (void) setNumberOfBounces:(NSUInteger)newNumberOfBounces { - [super setValue:[NSNumber numberWithUnsignedInt:newNumberOfBounces] forKey:@"numBounces"]; - [self createValueArray]; -} - -- (NSUInteger) numberOfBounces { - return [[super valueForKey:@"numBounces"] unsignedIntValue]; -} - -- (void) setShouldOvershoot:(BOOL)newShouldOvershoot { - [super setValue:[NSNumber numberWithBool:newShouldOvershoot] forKey:@"shouldOvershootKey"]; - [self createValueArray]; -} - -- (BOOL) shouldOvershoot { - return [[super valueForKey:@"shouldOvershootKey"] boolValue]; -} - -- (void) setShake:(BOOL)newShake { - [super setValue:[NSNumber numberWithBool:newShake] forKey:@"shakeKey"]; - [self createValueArray]; -} - -- (BOOL) shake { - return [[super valueForKey:@"shakeKey"] boolValue]; -} - -- (id) fromValue { - return [super valueForKey:@"fromValueKey"]; -} - -- (id) byValue { - return [super valueForKey:@"byValueKey"]; -} - -- (id) toValue { - return [super valueForKey:@"toValueKey"]; -} - -- (void) createValueArray { - if (self.fromValue && self.toValue && self.duration) { - if ([self.fromValue isKindOfClass:[NSNumber class]] && [self.toValue isKindOfClass:[NSNumber class]]) { - self.values = [self valueArrayForStartValue:[self.fromValue floatValue] endValue:[self.toValue floatValue]]; - } else if ([self.fromValue isKindOfClass:[UIColor class]] && [self.toValue isKindOfClass:[UIColor class]]) { - const CGFloat *fromComponents = CGColorGetComponents(((UIColor*)self.fromValue).CGColor); - const CGFloat *toComponents = CGColorGetComponents(((UIColor*)self.toValue).CGColor); - // NSLog(@"thing"); - // NSLog(@"from %0.2f %0.2f %0.2f %0.2f", fromComponents[0], fromComponents[1], fromComponents[2], fromComponents[3]); - // NSLog(@"to %0.2f %0.2f %0.2f %0.2f", toComponents[0], toComponents[1], toComponents[2], toComponents[3]); - self.values = [self createColorArrayFromRed: - [self valueArrayForStartValue:fromComponents[0] endValue:toComponents[0]] - green: - [self valueArrayForStartValue:fromComponents[1] endValue:toComponents[1]] - blue: - [self valueArrayForStartValue:fromComponents[2] endValue:toComponents[2]] - alpha: - [self valueArrayForStartValue:fromComponents[3] endValue:toComponents[3]]]; - } else if ([self.fromValue isKindOfClass:[NSValue class]] && [self.toValue isKindOfClass:[NSValue class]]) { - NSString *valueType = [NSString stringWithCString:[self.fromValue objCType] encoding:NSStringEncodingConversionAllowLossy]; - if ([valueType rangeOfString:@"CGRect"].location == 1) { - CGRect fromRect = [self.fromValue CGRectValue]; - CGRect toRect = [self.toValue CGRectValue]; - self.values = [self createRectArrayFromXValues: - [self valueArrayForStartValue:fromRect.origin.x endValue:toRect.origin.x] - yValues: - [self valueArrayForStartValue:fromRect.origin.y endValue:toRect.origin.y] - widths: - [self valueArrayForStartValue:fromRect.size.width endValue:toRect.size.width] - heights: - [self valueArrayForStartValue:fromRect.size.height endValue:toRect.size.height]]; - - } else if ([valueType rangeOfString:@"CGPoint"].location == 1) { - CGPoint fromPoint = [self.fromValue CGPointValue]; - CGPoint toPoint = [self.toValue CGPointValue]; - CGPathRef path = createPathFromXYValues([self valueArrayForStartValue:fromPoint.x endValue:toPoint.x], [self valueArrayForStartValue:fromPoint.y endValue:toPoint.y]); - self.path = path; - CGPathRelease(path); - - } else if ([valueType rangeOfString:@"CATransform3D"].location == 1) { - CATransform3D fromTransform = [self.fromValue CATransform3DValue]; - CATransform3D toTransform = [self.toValue CATransform3DValue]; - - // NSLog(@"from [%0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f]", fromTransform.m11, fromTransform.m12, fromTransform.m13, fromTransform.m14, fromTransform.m21, fromTransform.m22, fromTransform.m23, fromTransform.m24, fromTransform.m31, fromTransform.m32, fromTransform.m33, fromTransform.m34, fromTransform.m41, fromTransform.m42, fromTransform.m43, fromTransform.m44); - // - // NSLog(@"to [%0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f; %0.2f %0.2f %0.2f %0.2f]", toTransform.m11, toTransform.m12, toTransform.m13, toTransform.m14, toTransform.m21, toTransform.m22, toTransform.m23, toTransform.m24, toTransform.m31, toTransform.m32, toTransform.m33, toTransform.m34, toTransform.m41, toTransform.m42, toTransform.m43, toTransform.m44); - - self.values = [self createTransformArrayFromM11: - [self valueArrayForStartValue:fromTransform.m11 endValue:toTransform.m11] - M12: - [self valueArrayForStartValue:fromTransform.m12 endValue:toTransform.m12] - M13: - [self valueArrayForStartValue:fromTransform.m13 endValue:toTransform.m13] - M14: - [self valueArrayForStartValue:fromTransform.m14 endValue:toTransform.m14] - M21: - [self valueArrayForStartValue:fromTransform.m21 endValue:toTransform.m21] - M22: - [self valueArrayForStartValue:fromTransform.m22 endValue:toTransform.m22] - M23: - [self valueArrayForStartValue:fromTransform.m23 endValue:toTransform.m23] - M24: - [self valueArrayForStartValue:fromTransform.m24 endValue:toTransform.m24] - M31: - [self valueArrayForStartValue:fromTransform.m31 endValue:toTransform.m31] - M32: - [self valueArrayForStartValue:fromTransform.m32 endValue:toTransform.m32] - M33: - [self valueArrayForStartValue:fromTransform.m33 endValue:toTransform.m33] - M34: - [self valueArrayForStartValue:fromTransform.m34 endValue:toTransform.m34] - M41: - [self valueArrayForStartValue:fromTransform.m41 endValue:toTransform.m41] - M42: - [self valueArrayForStartValue:fromTransform.m42 endValue:toTransform.m42] - M43: - [self valueArrayForStartValue:fromTransform.m43 endValue:toTransform.m43] - M44: - [self valueArrayForStartValue:fromTransform.m44 endValue:toTransform.m44] - ]; - } else if ([valueType rangeOfString:@"CGSize"].location == 1) { - CGSize fromSize = [self.fromValue CGSizeValue]; - CGSize toSize = [self.toValue CGSizeValue]; - CGPathRef path = self.path = - createPathFromXYValues([self valueArrayForStartValue:fromSize.width endValue:toSize.width], - [self valueArrayForStartValue:fromSize.height endValue:toSize.height]); - CGPathRelease(path); - } - - } - self.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]; - } -} - -- (NSArray*) createRectArrayFromXValues:(NSArray*)xValues yValues:(NSArray*)yValues widths:(NSArray*)widths heights:(NSArray*)heights { - NSAssert(xValues.count == yValues.count && xValues.count == widths.count && xValues.count == heights.count, @"array must have arrays of equal size"); - - NSUInteger numberOfRects = xValues.count; - NSMutableArray *values = [NSMutableArray arrayWithCapacity:numberOfRects]; - CGRect value; - - for (int i = 1; i < numberOfRects; i++) { - value = CGRectMake( - [[xValues objectAtIndex:i] floatValue], - [[yValues objectAtIndex:i] floatValue], - [[widths objectAtIndex:i] floatValue], - [[heights objectAtIndex:i] floatValue] - ); - [values addObject:[NSValue valueWithCGRect:value]]; - } - return values; -} - -static CGPathRef createPathFromXYValues(NSArray *xValues, NSArray *yValues) { - NSUInteger numberOfPoints = xValues.count; - CGMutablePathRef path = CGPathCreateMutable(); - CGPoint value; - value = CGPointMake([[xValues objectAtIndex:0] floatValue], [[yValues objectAtIndex:0] floatValue]); - CGPathMoveToPoint(path, NULL, value.x, value.y); - - for (int i = 1; i < numberOfPoints; i++) { - value = CGPointMake([[xValues objectAtIndex:i] floatValue], [[yValues objectAtIndex:i] floatValue]); - CGPathAddLineToPoint(path, NULL, value.x, value.y); - } - return path; -} - -- (NSArray*) createTransformArrayFromM11:(NSArray*)m11 M12:(NSArray*)m12 M13:(NSArray*)m13 M14:(NSArray*)m14 - M21:(NSArray*)m21 M22:(NSArray*)m22 M23:(NSArray*)m23 M24:(NSArray*)m24 - M31:(NSArray*)m31 M32:(NSArray*)m32 M33:(NSArray*)m33 M34:(NSArray*)m34 - M41:(NSArray*)m41 M42:(NSArray*)m42 M43:(NSArray*)m43 M44:(NSArray*)m44 { - NSUInteger numberOfTransforms = m11.count; - NSMutableArray *values = [NSMutableArray arrayWithCapacity:numberOfTransforms]; - CATransform3D value; - - for (int i = 1; i < numberOfTransforms; i++) { - value = CATransform3DIdentity; - value.m11 = [[m11 objectAtIndex:i] floatValue]; - value.m12 = [[m12 objectAtIndex:i] floatValue]; - value.m13 = [[m13 objectAtIndex:i] floatValue]; - value.m14 = [[m14 objectAtIndex:i] floatValue]; - - value.m21 = [[m21 objectAtIndex:i] floatValue]; - value.m22 = [[m22 objectAtIndex:i] floatValue]; - value.m23 = [[m23 objectAtIndex:i] floatValue]; - value.m24 = [[m24 objectAtIndex:i] floatValue]; - - value.m31 = [[m31 objectAtIndex:i] floatValue]; - value.m32 = [[m32 objectAtIndex:i] floatValue]; - value.m33 = [[m33 objectAtIndex:i] floatValue]; - value.m44 = [[m34 objectAtIndex:i] floatValue]; - - value.m41 = [[m41 objectAtIndex:i] floatValue]; - value.m42 = [[m42 objectAtIndex:i] floatValue]; - value.m43 = [[m43 objectAtIndex:i] floatValue]; - value.m44 = [[m44 objectAtIndex:i] floatValue]; - - [values addObject:[NSValue valueWithCATransform3D:value]]; - } - return values; -} - -- (NSArray*) createColorArrayFromRed:(NSArray*)redValues green:(NSArray*)greenValues blue:(NSArray*)blueValues alpha:(NSArray*)alphaValues { - NSAssert(redValues.count == blueValues.count && redValues.count == greenValues.count && redValues.count == alphaValues.count, @"array must have arrays of equal size"); - - NSUInteger numberOfColors = redValues.count; - NSMutableArray *values = [NSMutableArray arrayWithCapacity:numberOfColors]; - UIColor *value; - - for (int i = 1; i < numberOfColors; i++) { - value = [UIColor colorWithRed:[[redValues objectAtIndex:i] floatValue] - green:[[greenValues objectAtIndex:i] floatValue] - blue:[[blueValues objectAtIndex:i] floatValue] - alpha:[[alphaValues objectAtIndex:i] floatValue]]; - // NSLog(@"a color %@", value); - [values addObject:(id)value.CGColor]; - } - return values; -} - -- (NSArray*) valueArrayForStartValue:(CGFloat)startValue endValue:(CGFloat)endValue { - int steps = 60*self.duration; //60 fps desired - - CGFloat alpha = 0; - if (startValue == endValue) { - alpha = log2f(0.1f)/steps; - } else { - alpha = log2f(0.1f/fabs(endValue - startValue))/steps; - } - if (alpha > 0) { - alpha = -1.0f*alpha; - } - CGFloat numberOfPeriods = self.numberOfBounces/2 + 0.5; - CGFloat omega = numberOfPeriods * 2*M_PI/steps; - - //uncomment this to get the equation of motion - // NSLog(@"y = %0.2f * e^(%0.5f*x)*cos(%0.10f*x) + %0.0f over %d frames", startValue - endValue, alpha, omega, endValue, steps); - - NSMutableArray *values = [NSMutableArray arrayWithCapacity:steps]; - CGFloat value = 0; - - CGFloat sign = (endValue-startValue)/fabsf(endValue-startValue); - - CGFloat oscillationComponent; - CGFloat coefficient; - - // conforms to y = A * e^(-alpha*t)*cos(omega*t) - for (int t = 0; t < steps; t++) { - //decaying mass-spring-damper solution with initial displacement - - if (self.shake) { - oscillationComponent = sin(omega*t); - } else { - oscillationComponent = cos(omega*t); - } - - if (self.shouldOvershoot) { - coefficient = (startValue - endValue); - } else { - coefficient = -1*sign*fabsf((startValue - endValue)); - } - - value = coefficient * pow(2.71, alpha*t) * oscillationComponent + endValue; - - - - [values addObject:[NSNumber numberWithFloat:value]]; - } - return values; -} - - -@end - diff --git a/inds/ZAActivityBar/ZAActivityBar.bundle/error.png b/inds/ZAActivityBar/ZAActivityBar.bundle/error.png deleted file mode 100755 index 684fc25..0000000 Binary files a/inds/ZAActivityBar/ZAActivityBar.bundle/error.png and /dev/null differ diff --git a/inds/ZAActivityBar/ZAActivityBar.bundle/error@2x.png b/inds/ZAActivityBar/ZAActivityBar.bundle/error@2x.png deleted file mode 100755 index e9774e6..0000000 Binary files a/inds/ZAActivityBar/ZAActivityBar.bundle/error@2x.png and /dev/null differ diff --git a/inds/ZAActivityBar/ZAActivityBar.bundle/success.png b/inds/ZAActivityBar/ZAActivityBar.bundle/success.png deleted file mode 100755 index 085ab55..0000000 Binary files a/inds/ZAActivityBar/ZAActivityBar.bundle/success.png and /dev/null differ diff --git a/inds/ZAActivityBar/ZAActivityBar.m b/inds/ZAActivityBar/ZAActivityBar.m deleted file mode 100755 index 44280bb..0000000 --- a/inds/ZAActivityBar/ZAActivityBar.m +++ /dev/null @@ -1,797 +0,0 @@ -// -// ZAActivityBar.m -// -// Created by Zac Altman on 24/11/12. -// Copyright (c) 2012 Zac Altman. All rights reserved. -// - -#import "ZAActivityBar.h" -#import -#import "SKBounceAnimation.h" - -#define ZA_ANIMATION_SHOW_KEY @"showAnimation" -#define ZA_ANIMATION_DISMISS_KEY @"dismissAnimation" - -#ifdef __IPHONE_6_0 -# define UITextAlignmentCenter NSTextAlignmentCenter -# define UITextAlignmentLeft NSTextAlignmentLeft -# define UITextAlignmentRight NSTextAlignmentRight -# define UILineBreakModeTailTruncation NSLineBreakByTruncatingTail -# define UILineBreakModeMiddleTruncation NSLineBreakByTruncatingMiddle -#endif - -/////////////////////////////////////////////////////////////// - -@interface ZAActivityAction : NSObject -@property (nonatomic,strong) NSString *name; -@property (nonatomic,strong) NSString *status; -@end - -@implementation ZAActivityAction -@end - -/////////////////////////////////////////////////////////////// - -@interface ZAActivityBar () { - - // Why use a dictionary and an array? - // We need order as well as reference data, so they work together. - - NSMutableArray *_actionArray; - NSMutableDictionary *_actionDict; -} - -@property BOOL isVisible; -@property NSUInteger offset; - -@property (nonatomic, strong, readonly) UIView *actionIndicatorView; -@property (nonatomic, strong, readonly) UILabel *actionIndicatorLabel; -@property (nonatomic, strong, readonly) NSTimer *fadeOutTimer; -@property (nonatomic, strong, readonly) UIWindow *overlayWindow; -@property (nonatomic, strong, readonly) UIView *barView; -@property (nonatomic, strong, readonly) UILabel *stringLabel; -@property (nonatomic, strong, readonly) UIActivityIndicatorView *spinnerView; -@property (nonatomic, strong, readonly) UIImageView *imageView; - -- (void) showWithStatus:(NSString *)status forAction:(NSString *)action; -- (void) setStatus:(NSString*)string; -- (void) showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration forAction:(NSString *)action; - -- (void) dismissAll; -- (void) dismissForAction:(NSString *)action; - -- (void) registerNotifications; - -@end - -@implementation ZAActivityBar - -@synthesize fadeOutTimer, overlayWindow, barView, stringLabel, spinnerView, imageView, actionIndicatorView, actionIndicatorLabel; - -/////////////////////////////////////////////////////////////// - -#pragma mark - Offset Properties - -+ (void) setLocationBottom -{ - [ZAActivityBar sharedView].offset = 0.0f; -} - -+ (void) setLocationTabBar -{ - [ZAActivityBar sharedView].offset = 49.0f; -} - -+ (void) setLocationNavBar -{ - CGRect screenRect = [[UIScreen mainScreen] bounds]; - [ZAActivityBar sharedView].offset = screenRect.size.height - 120.0f; -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Action Methods - -- (ZAActivityAction *) getPrimaryAction { - - if (_actionArray.count == 0) - return nil; - - NSString *action = [_actionArray objectAtIndex:0]; - return [self getAction:action]; - -} - -- (ZAActivityAction *) getAction:(NSString *)action { - - if (![self actionExists:action]) - return nil; - - return [_actionDict objectForKey:action]; -} - -- (void) addAction:(NSString *)action withStatus:(NSString *)status { - - ZAActivityAction *a = [self getAction:action]; - - if (!a) { - [_actionArray addObject:action]; - a = [ZAActivityAction new]; - a.name = action; - } - - a.status = status; - - [_actionDict setObject:a forKey:action]; - - [self updateActionIndicator]; - -} - -- (void) removeAction:(NSString *)action { - - if (![self actionExists:action]) - return; - - [_actionDict removeObjectForKey:action]; - [_actionArray removeObject:action]; - - [self updateActionIndicator]; - -} - -- (BOOL) isPrimaryAction:(NSString *)action { - - if (![self actionExists:action]) - return NO; - - NSUInteger index = [_actionArray indexOfObject:action]; - return index == 0; - -} - -- (BOOL) actionExists:(NSString *)action { - return [_actionArray containsObject:action]; -} - -- (void) updateActionIndicator { - NSUInteger count = [_actionArray count]; - - // We only need to display this indicator if there is more than one message in the queue - BOOL makeHidden = (count <= 1); - BOOL isHidden = (self.actionIndicatorView.alpha == 0.0f); - - // Who doesn't love animations - BOOL shouldAnimate = isHidden != makeHidden; - - [self.actionIndicatorLabel setFrame:self.actionIndicatorView.bounds]; - - // When animating in, we want to change the text before the view is displayed - // Would be nice to only set the text in a single place... - if (isHidden) { - [self setActionIndicatorCount:count]; - } - - [UIView animateWithDuration:(shouldAnimate ? 0.1f : 0.0f) - delay:0.0f - options:UIViewAnimationOptionCurveEaseIn // Not required: |UIViewAnimationOptionBeginFromCurrentState - animations:^{ - self.actionIndicatorView.alpha = (makeHidden ? 0.0f : 1.0f); - - // When animating out, we don't want the text to change. - if (!makeHidden) { - [self setActionIndicatorCount:count]; - } - } completion:nil]; - -} - -- (void) setActionIndicatorCount:(NSUInteger)count { - [self.actionIndicatorLabel setText:[NSString stringWithFormat:@"%lu", count]]; - // May want to resize the shape to make a 'pill' shape in the future? Still looks fine for - // numbers up to 100. -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Show Methods - -+ (void) showWithStatus:(NSString *)status { - [ZAActivityBar showWithStatus:status forAction:DEFAULT_ACTION]; -} - -+ (void) showWithStatus:(NSString *)status forAction:(NSString *)action { - [[ZAActivityBar sharedView] showWithStatus:status forAction:action]; -} - -+ (void) show { - [ZAActivityBar showForAction:DEFAULT_ACTION]; -} - -+ (void) showForAction:(NSString *)action { - [[ZAActivityBar sharedView] showWithStatus:nil forAction:action]; -} - -- (void) showWithStatus:(NSString *)status forAction:(NSString *)action { - dispatch_async(dispatch_get_main_queue(), ^{ - if(!self.superview) - [self.overlayWindow addSubview:self]; - if ([UIApplication sharedApplication].statusBarHidden) return; //Don't show if in game - // Add the action - [self addAction:action withStatus:status]; - - // Only continue if the action should be visible. - BOOL isPrimaryAction = [self isPrimaryAction:action]; - if (!isPrimaryAction) - return; - - self.fadeOutTimer = nil; - self.imageView.hidden = YES; - - [self.overlayWindow setHidden:NO]; - [self.spinnerView startAnimating]; - - [self setStatus:status]; - - if (!_isVisible) { - _isVisible = YES; - - [self positionBar:nil]; - [self positionOffscreen]; - [self registerNotifications]; - - // We want to remove the previous animations - [self removeAnimationForKey:ZA_ANIMATION_DISMISS_KEY]; - - NSString *bounceKeypath = @"position.y"; - id bounceOrigin = [NSNumber numberWithFloat:self.barView.layer.position.y]; - id bounceFinalValue = [NSNumber numberWithFloat:[self getBarYPosition]]; - - SKBounceAnimation *bounceAnimation = [SKBounceAnimation animationWithKeyPath:bounceKeypath]; - [bounceAnimation setValue:ZA_ANIMATION_SHOW_KEY forKey:@"identifier"]; // So we can find identify animations later - bounceAnimation.fromValue = bounceOrigin; - bounceAnimation.toValue = bounceFinalValue; - bounceAnimation.shouldOvershoot = YES; - bounceAnimation.numberOfBounces = 4; - bounceAnimation.delegate = self; - bounceAnimation.removedOnCompletion = YES; - bounceAnimation.duration = 0.7f; - - [self.barView.layer addAnimation:bounceAnimation forKey:@"showAnimation"]; - - CGPoint position = self.barView.layer.position; - position.y = [bounceFinalValue floatValue]; - [self.barView.layer setPosition:position]; - - } - - }); -} - -// Success - -+ (void) showSuccessWithStatus:(NSString *)status { - [ZAActivityBar showSuccessWithStatus:status forAction:DEFAULT_ACTION]; -} - -+ (void) showSuccessWithStatus:(NSString *)status duration:(NSTimeInterval)duration { - [ZAActivityBar showSuccessWithStatus:status duration:duration forAction:DEFAULT_ACTION]; -} - -+ (void) showSuccessWithStatus:(NSString *)status forAction:(NSString *)action { - [ZAActivityBar showSuccessWithStatus:status duration:1.0f forAction:action]; -} - -+ (void) showSuccessWithStatus:(NSString *)status duration:(NSTimeInterval)duration forAction:(NSString *)action { - [ZAActivityBar showImage:[UIImage imageNamed:@"ZAActivityBar.bundle/success.png"] - status:status - duration:duration - forAction:action]; -} - -// Error - -+ (void) showErrorWithStatus:(NSString *)status { - [ZAActivityBar showErrorWithStatus:status forAction:DEFAULT_ACTION]; -} - -+ (void) showErrorWithStatus:(NSString *)status duration:(NSTimeInterval)duration { - [ZAActivityBar showErrorWithStatus:status duration:duration forAction:DEFAULT_ACTION]; -} - -+ (void) showErrorWithStatus:(NSString *)status forAction:(NSString *)action { - [ZAActivityBar showErrorWithStatus:status duration:1.0f forAction:action]; -} - -+ (void) showErrorWithStatus:(NSString *)status duration:(NSTimeInterval)duration forAction:(NSString *)action { - [ZAActivityBar showImage:[UIImage imageNamed:@"ZAActivityBar.bundle/error.png"] - status:status - duration:duration - forAction:action]; -} - -// Image - -+ (void)showImage:(UIImage *)image status:(NSString *)status { - [ZAActivityBar showImage:image status:status forAction:DEFAULT_ACTION]; -} - -+ (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration { - [ZAActivityBar showImage:image status:status duration:duration forAction:DEFAULT_ACTION]; -} - -+ (void)showImage:(UIImage *)image status:(NSString *)status forAction:(NSString *)action { - [ZAActivityBar showImage:image status:status duration:1.0f forAction:action]; -} - -+ (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration forAction:(NSString *)action { - [[ZAActivityBar sharedView] showImage:image - status:status - duration:duration - forAction:action]; -} - -- (void)showImage:(UIImage*)image status:(NSString*)status duration:(NSTimeInterval)duration forAction:(NSString *)action { - - // Add the action if it doesn't exist yet - if (![self actionExists:action]) { - [self addAction:action withStatus:status]; - } - - // Only continue if the action should be visible. - BOOL isPrimaryAction = [self isPrimaryAction:action]; - if (!isPrimaryAction) { - [self removeAction:action]; - return; - } - - if(![ZAActivityBar isVisible]) - [ZAActivityBar showForAction:action]; - - dispatch_async(dispatch_get_main_queue(), ^{ - - self.imageView.image = image; - self.imageView.hidden = NO; - [self setStatus:status]; - [self.spinnerView stopAnimating]; - - self.fadeOutTimer = [NSTimer scheduledTimerWithTimeInterval:duration - target:self - selector:@selector(dismissFromTimer:) - userInfo:action - repeats:NO]; - }); - -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Property Methods - -- (void)setStatus:(NSString *)string { - - CGFloat stringWidth = 0; - CGFloat stringHeight = 0; - CGRect labelRect = CGRectZero; - - if(string) { - float offset = (SPINNER_SIZE + 2 * ICON_OFFSET); - float width = self.barView.frame.size.width - offset; - CGSize stringSize = [string sizeWithFont:self.stringLabel.font - constrainedToSize:CGSizeMake(width, 300)]; - stringWidth = stringSize.width; - stringHeight = stringSize.height; - - labelRect = CGRectMake(offset, 0, stringWidth, HEIGHT); - - } - - self.stringLabel.hidden = NO; - self.stringLabel.text = string; - self.stringLabel.frame = labelRect; - -} - -+ (BOOL)isVisible { - return [[ZAActivityBar sharedView] isVisible]; -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Dismiss Methods - -+ (void) dismiss { - [[ZAActivityBar sharedView] dismissAll]; -} - -+ (void) dismissForAction:(NSString *)action { - [[ZAActivityBar sharedView] dismissForAction:action]; -} - -- (void) dismissAll { - - for (int i = (_actionArray.count - 1); i >= 0; i--) { - NSString *action = [_actionArray objectAtIndex:i]; - - // First item (visible one) - if (i == 0) { - [self dismissForAction:action]; - } - // Non-visible items - else { - [self removeAction:action]; - } - } -} - -- (void) dismissForAction:(NSString *)action { - dispatch_async(dispatch_get_main_queue(), ^{ - - // Check if the action is on the screen - BOOL onScreen = [self isPrimaryAction:action]; - - // Remove the action - [self removeAction:action]; - - // If this is the currently visible action, then let's do some magic - if (onScreen) { - - // Let's get the new primary action - ZAActivityAction *primaryAction = [self getPrimaryAction]; - - // And just update the visual. - if (primaryAction) { - [ZAActivityBar showWithStatus:primaryAction.status forAction:primaryAction.name]; - return; - } - - } - // If it's not visible, don't continue. - else { - return; - } - - if (_isVisible) { - _isVisible = NO; - - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - // If the animation is midway through, we want it to drop immediately - BOOL shouldDrop = [self.barView.layer.animationKeys containsObject:ZA_ANIMATION_SHOW_KEY]; - - // We want to remove the previous animations - [self removeAnimationForKey:ZA_ANIMATION_SHOW_KEY]; - - // Setup the animation values - NSString *keypath = @"position.y"; - id currentValue = [NSNumber numberWithFloat:self.barView.layer.position.y]; - id midValue = [NSNumber numberWithFloat:self.barView.layer.position.y - 7]; - id finalValue = [NSNumber numberWithFloat:[self getOffscreenYPosition]]; - - CAMediaTimingFunction *function = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; - NSArray *keyTimes = (shouldDrop ? @[@0.0,@0.3] : @[@0.0,@0.3,@0.5]); - NSArray *values = (shouldDrop ? @[currentValue,finalValue] : @[currentValue,midValue,finalValue]); - NSArray *timingFunctions = (shouldDrop ? @[function, function] : @[function, function, function]); - - // Get the duration. So we don't have to manually set it, this defaults to the final value in the animation keys. - float duration = [[keyTimes objectAtIndex:(keyTimes.count - 1)] floatValue]; - - // Perform the animation - CAKeyframeAnimation *frameAnimation = [CAKeyframeAnimation animationWithKeyPath:keypath]; - [frameAnimation setValue:ZA_ANIMATION_DISMISS_KEY forKey:@"identifier"]; // So we can find identify animations later -// [frameAnimation setCalculationMode:kCAAnimationLinear]; Defaults to Linear. - [frameAnimation setKeyTimes:keyTimes]; - [frameAnimation setValues:values]; - [frameAnimation setTimingFunctions:timingFunctions]; - [frameAnimation setDuration:duration]; - [frameAnimation setRemovedOnCompletion:YES]; - [frameAnimation setDelegate:self]; - - [self.barView.layer addAnimation:frameAnimation forKey:ZA_ANIMATION_DISMISS_KEY]; - - CGPoint position = self.barView.layer.position; - position.y = [finalValue floatValue]; - [self.barView.layer setPosition:position]; - } - }); -} - -- (void) dismissFromTimer:(NSTimer *)timer { - NSString *action = timer.userInfo; - [ZAActivityBar dismissForAction:action]; -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Helpers - -- (float) getOffscreenYPosition { - return [self getHeight] + ((HEIGHT / 2) + PADDING); -} - -- (float) getBarYPosition { - return [self getHeight] - ((HEIGHT / 2) + PADDING) - self.offset; -} - -// Returns the height for the bar in the current orientation -- (float) getHeight { - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; - float height = self.overlayWindow.frame.size.height; - - if (UIInterfaceOrientationIsLandscape(orientation)) { - height = self.overlayWindow.frame.size.width; - } - - return height; -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Animation Methods / Helpers - -// For some reason the SKBounceAnimation isn't removed if this method -// doesn't exist... Why? -- (void) animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { - - // If the animation actually finished - if (flag) { - - // Let's check if it's the right animation - BOOL isDismiss = [[anim valueForKey:@"identifier"] isEqualToString:ZA_ANIMATION_DISMISS_KEY]; - if (isDismiss) { - // Get rid of the stupid thing: - [overlayWindow removeFromSuperview]; - overlayWindow = nil; - } - } -} - -- (void) removeAnimationForKey:(NSString *)key { - if ([self.barView.layer.animationKeys containsObject:key]) { - CAAnimation *anim = [self.barView.layer animationForKey:key]; - - // Find out how far into the animation we made it - CFTimeInterval startTime = [[anim valueForKey:@"beginTime"] floatValue]; - CFTimeInterval pausedTime = [self.barView.layer convertTime:CACurrentMediaTime() fromLayer:nil]; - float diff = pausedTime - startTime; - - // We only need a ~rough~ frame, so it doesn't jump to the end position - // and stays as close to in place as possible. - int frame = (diff * 58.57 - 1); // 58fps? - NSArray *frames = [anim valueForKey:@"values"]; - if (frame >= frames.count) // For security - frame = frames.count - 1; - - float yOffset = [[frames objectAtIndex:frame] floatValue]; - - // And lets set that - CGPoint position = self.barView.layer.position; - position.y = yOffset; - - // We want to disable the implicit animation - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; - [self.barView.layer setPosition:position]; - [CATransaction commit]; - - // And... actually remove it. - [self.barView.layer removeAnimationForKey:key]; - } -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Misc - -- (void)drawRect:(CGRect)rect { - -} - -- (void)dealloc { - self.fadeOutTimer = nil; - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)setFadeOutTimer:(NSTimer *)newTimer { - - if(fadeOutTimer) - [fadeOutTimer invalidate], fadeOutTimer = nil; - - if(newTimer) - fadeOutTimer = newTimer; -} - -- (id)initWithFrame:(CGRect)frame { - - if ((self = [super initWithFrame:frame])) { - self.userInteractionEnabled = NO; - self.backgroundColor = [UIColor clearColor]; - self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - _isVisible = NO; - _actionArray = [NSMutableArray new]; - _actionDict = [NSMutableDictionary new]; - } - - return self; -} - -+ (ZAActivityBar *) sharedView { - static dispatch_once_t once; - static ZAActivityBar *sharedView; - dispatch_once(&once, ^ { sharedView = [[ZAActivityBar alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; }); - return sharedView; -} - -- (void) registerNotifications { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(positionBar:) - name:UIApplicationDidChangeStatusBarOrientationNotification - object:nil]; -} - -- (void) positionOffscreen { - CGPoint position = self.barView.layer.position; - position.y = [self getOffscreenYPosition]; - [self.barView.layer setPosition:position]; -} - -- (void) positionBar:(NSNotification *)notification { - - double animationDuration = 0.7; - - UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; - - CGFloat rotateAngle; - CGRect frame = self.overlayWindow.frame; - - switch (orientation) { - case UIInterfaceOrientationPortraitUpsideDown: - rotateAngle = M_PI; - break; - case UIInterfaceOrientationLandscapeLeft: - rotateAngle = -M_PI/2.0f; - break; - case UIInterfaceOrientationLandscapeRight: - rotateAngle = M_PI/2.0f; - break; - default: // as UIInterfaceOrientationPortrait - rotateAngle = 0.0; - break; - } - - if(notification) { - [UIView animateWithDuration:animationDuration - delay:0 - options:UIViewAnimationOptionAllowUserInteraction - animations:^{ - [self positionWithFrame:frame angle:rotateAngle]; - } completion:nil]; - } else { - [self positionWithFrame:frame angle:rotateAngle]; - } -} - -- (void) positionWithFrame:(CGRect)frame angle:(CGFloat)angle { - self.overlayWindow.transform = CGAffineTransformMakeRotation(angle); - self.overlayWindow.frame = frame; -} - -/////////////////////////////////////////////////////////////// - -#pragma mark - Getters - -- (UIView *) actionIndicatorView { - - if (!actionIndicatorView) { - - float size = HEIGHT / 2; - CGRect rect = CGRectZero; - rect.size = CGSizeMake(size, size); - rect.origin.y = (HEIGHT - size) / 2; - rect.origin.x = self.barView.bounds.size.width - size - rect.origin.y; - - actionIndicatorView = [UIView new]; - actionIndicatorView.alpha = 0.0f; - actionIndicatorView.frame = rect; - actionIndicatorView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin); - - // Circle shape - CAShapeLayer *pill = [CAShapeLayer new]; - pill.path = CGPathCreateWithEllipseInRect(actionIndicatorView.bounds, nil); - pill.fillColor = [UIColor whiteColor].CGColor; - [actionIndicatorView.layer addSublayer:pill]; - } - - if(!actionIndicatorView.superview) - [self.barView addSubview:actionIndicatorView]; - - return actionIndicatorView; -} - -- (UILabel *) actionIndicatorLabel { - if (!actionIndicatorLabel) { - actionIndicatorLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - actionIndicatorLabel.textColor = [UIColor blackColor]; - actionIndicatorLabel.backgroundColor = [UIColor clearColor]; - actionIndicatorLabel.adjustsFontSizeToFitWidth = YES; - actionIndicatorLabel.textAlignment = UITextAlignmentCenter; - actionIndicatorLabel.font = [UIFont boldSystemFontOfSize:12]; - actionIndicatorLabel.numberOfLines = 0; - } - - if(!actionIndicatorLabel.superview) - [self.actionIndicatorView addSubview:actionIndicatorLabel]; - - return actionIndicatorLabel; -} - -- (UILabel *)stringLabel { - if (!stringLabel) { - stringLabel = [[UILabel alloc] initWithFrame:CGRectZero]; - stringLabel.textColor = [UIColor whiteColor]; - stringLabel.backgroundColor = [UIColor clearColor]; - stringLabel.adjustsFontSizeToFitWidth = YES; - stringLabel.textAlignment = UITextAlignmentLeft; - stringLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters; - stringLabel.autoresizingMask = (UIViewAutoresizingFlexibleWidth); - stringLabel.font = [UIFont boldSystemFontOfSize:14]; - stringLabel.shadowColor = [UIColor blackColor]; - stringLabel.shadowOffset = CGSizeMake(0, -1); - stringLabel.numberOfLines = 0; - } - - if(!stringLabel.superview) - [self.barView addSubview:stringLabel]; - - return stringLabel; -} - -- (UIWindow *)overlayWindow { - if(!overlayWindow) { - overlayWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - overlayWindow.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; - overlayWindow.backgroundColor = [UIColor clearColor]; - overlayWindow.userInteractionEnabled = NO; - overlayWindow.windowLevel = UIWindowLevelNormal; // UIWindowLevelAlert = infront of keyboard. - } - return overlayWindow; -} - -- (UIView *)barView { - if(!barView) { - CGRect rect = CGRectMake(PADDING, FLT_MAX, self.overlayWindow.frame.size.width, HEIGHT); - rect.size.width -= 2 * PADDING; - rect.origin.y = [self getOffscreenYPosition]; - barView = [[UIView alloc] initWithFrame:rect]; - barView.layer.cornerRadius = 6; - barView.backgroundColor = BAR_COLOR; - barView.autoresizingMask = (UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth); - [self addSubview:barView]; - } - return barView; -} - -- (UIActivityIndicatorView *)spinnerView { - if (!spinnerView) { - spinnerView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; - spinnerView.hidesWhenStopped = YES; - spinnerView.frame = CGRectMake(ICON_OFFSET, ICON_OFFSET, SPINNER_SIZE, SPINNER_SIZE); - } - - if(!spinnerView.superview) - [self.barView addSubview:spinnerView]; - - return spinnerView; -} - -- (UIImageView *)imageView { - if (!imageView) - imageView = [[UIImageView alloc] initWithFrame:CGRectMake(ICON_OFFSET, ICON_OFFSET, SPINNER_SIZE, SPINNER_SIZE)]; - - if(!imageView.superview) - [self.barView addSubview:imageView]; - - return imageView; -} - -@end diff --git a/inds/controls/iNDSButtonControl.h b/inds/controls/iNDSButtonControl.h deleted file mode 100755 index 61e9ce7..0000000 --- a/inds/controls/iNDSButtonControl.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// ButtonControl.h -// iNDS -// -// Created by iNDS on 7/5/13. -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import "iNDSDirectionalControl.h" - -// This class really doesn't do much. It's basically here to make the code easier to read, but also in case of future expansion. - -// Below are identical to the superclass variants, just renamed for clarity -typedef NS_ENUM(NSInteger, iNDSButtonControlButton) { - iNDSButtonControlButtonX = 1 << 0, - iNDSButtonControlButtonB = 1 << 1, - iNDSButtonControlButtonY = 1 << 2, - iNDSButtonControlButtonA = 1 << 3, -}; - -@interface iNDSButtonControl : iNDSDirectionalControl - -@property (readonly, nonatomic) iNDSButtonControlButton selectedButtons; - -@end diff --git a/inds/controls/iNDSButtonControl.m b/inds/controls/iNDSButtonControl.m deleted file mode 100755 index 5e613fe..0000000 --- a/inds/controls/iNDSButtonControl.m +++ /dev/null @@ -1,40 +0,0 @@ -// -// ButtonControl.m -// iNDS -// -// Created by Riley Testut on 7/5/13. -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import "iNDSButtonControl.h" - -@interface iNDSDirectionalControl () - -@property (strong, nonatomic) UIImageView *backgroundImageView; - -@end - -@interface iNDSButtonControl () - -@property (readwrite, nonatomic) iNDSButtonControlButton selectedButtons; - -@end - -@implementation iNDSButtonControl - -- (id)initWithCoder:(NSCoder *)aDecoder -{ - self = [super initWithCoder:aDecoder]; - if (self) { - // Initialization code - - self.backgroundImageView.image = [UIImage imageNamed:@"ABXYPad"]; - } - return self; -} - -- (iNDSButtonControlButton)selectedButtons { - return (iNDSButtonControlButton)self.direction; -} - -@end diff --git a/inds/controls/iNDSDirectionalControl.h b/inds/controls/iNDSDirectionalControl.h deleted file mode 100755 index ee10b61..0000000 --- a/inds/controls/iNDSDirectionalControl.h +++ /dev/null @@ -1,30 +0,0 @@ -// -// iNDSDirectionalControl.h -// iNDS -// -// Created by iNDS -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import - -typedef NS_ENUM(NSInteger, iNDSDirectionalControlDirection) { - iNDSDirectionalControlDirectionUp = 1 << 0, - iNDSDirectionalControlDirectionDown = 1 << 1, - iNDSDirectionalControlDirectionLeft = 1 << 2, - iNDSDirectionalControlDirectionRight = 1 << 3, -}; - -typedef NS_ENUM(NSInteger, iNDSDirectionalControlStyle) { - iNDSDirectionalControlStyleDPad = 0, - iNDSDirectionalControlStyleJoystick = 1, -}; - -@interface iNDSDirectionalControl : UIControl - -@property (readonly, nonatomic) iNDSDirectionalControlDirection direction; -@property (assign, nonatomic) iNDSDirectionalControlStyle style; - -- (void) frameUpdated; - -@end diff --git a/inds/controls/iNDSDirectionalControl.m b/inds/controls/iNDSDirectionalControl.m deleted file mode 100755 index 06ed47e..0000000 --- a/inds/controls/iNDSDirectionalControl.m +++ /dev/null @@ -1,152 +0,0 @@ -// -// iNDSDirectionalControl.m -// iNDS -// -// Created by iNDS -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import "iNDSDirectionalControl.h" - -@interface iNDSDirectionalControl() { - CALayer *buttonImage; - CFTimeInterval lastMove; -} - -@property (readwrite, nonatomic) iNDSDirectionalControlDirection direction; -@property (assign, nonatomic) CGSize deadZone; // dead zone in the middle of the control -@property (strong, nonatomic) UIImageView *backgroundImageView; -@property (assign, nonatomic) CGRect deadZoneRect; - -@end - -@implementation iNDSDirectionalControl - -- (id)initWithCoder:(NSCoder *)aDecoder -{ - self = [super initWithCoder:aDecoder]; - if (self) { - // Initialization code - _backgroundImageView = [[UIImageView alloc] initWithFrame:self.bounds]; - _backgroundImageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; - [self addSubview:_backgroundImageView]; - - buttonImage = [[CALayer alloc] init]; - buttonImage.frame = CGRectMake(0, 0, self.frame.size.width/2.2, self.frame.size.width/2.2); - buttonImage.contents = (id)[UIImage imageNamed:@"JoystickButton"].CGImage; - buttonImage.anchorPoint = CGPointMake(0.5, 0.5); - //NSMutableDictionary *newActions = [[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSNull null], @"position", nil]; - buttonImage.actions = @{@"position": [NSNull null]}; - [self.layer addSublayer:buttonImage]; - - self.deadZone = CGSizeMake(self.frame.size.width/3, self.frame.size.height/3); - self.direction = iNDSDirectionalControlDirectionDown; - - - [self setStyle:iNDSDirectionalControlStyleDPad]; - } - return self; -} -- (void) frameUpdated -{ - self.deadZone = CGSizeMake(self.frame.size.width/3, self.frame.size.height/3); - self.deadZoneRect = CGRectMake((self.bounds.size.width - self.deadZone.width)/2, (self.bounds.size.height - self.deadZone.height)/2, self.deadZone.width, self.deadZone.height); - buttonImage.frame = CGRectMake(0, 0, self.frame.size.width/2.2, self.frame.size.width/2.2); - buttonImage.position = self.backgroundImageView.center; -} - - - -- (void) layoutSubviews -{ - [super layoutSubviews]; - [self frameUpdated]; -} - - -- (iNDSDirectionalControlDirection)directionForTouch:(UITouch *)touch -{ - // convert coords to based on center of control - CGPoint loc = [touch locationInView:self]; - //if (!CGRectContainsPoint(self.bounds, loc)) return 0; - iNDSDirectionalControlDirection direction = 0; - - if (loc.x > (self.bounds.size.width + self.deadZone.width)/2) direction |= iNDSDirectionalControlDirectionRight; - else if (loc.x < (self.bounds.size.width - self.deadZone.width)/2) direction |= iNDSDirectionalControlDirectionLeft; - if (loc.y > (self.bounds.size.height + self.deadZone.height)/2) direction |= iNDSDirectionalControlDirectionDown; - else if (loc.y < (self.bounds.size.height - self.deadZone.height)/2) direction |= iNDSDirectionalControlDirectionUp; - - return direction; -} - -- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - self.direction = [self directionForTouch:touch]; - [self sendActionsForControlEvents:UIControlEventValueChanged]; - - if (self.style == iNDSDirectionalControlStyleJoystick) { - CGPoint loc = [touch locationInView:self]; - buttonImage.position = loc; - lastMove = CACurrentMediaTime(); - } - return YES; -} - -- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - self.direction = [self directionForTouch:touch]; - [self sendActionsForControlEvents:UIControlEventValueChanged]; - - if (self.style == iNDSDirectionalControlStyleJoystick) { - // keep button inside - CGPoint loc = [touch locationInView:self]; - loc.x -= self.bounds.size.width/2; - loc.y -= self.bounds.size.height/2; - double radius = sqrt(loc.x*loc.x+loc.y*loc.y); - double maxRadius = self.bounds.size.width * 0.45; - if (radius > maxRadius) { - double angle = atan(loc.y/loc.x); - if (loc.x < 0) angle += M_PI; - loc.x = maxRadius * cos(angle); - loc.y = maxRadius * sin(angle); - } - loc.x += self.bounds.size.width/2; - loc.y += self.bounds.size.height/2; - if (CACurrentMediaTime() - lastMove > 0.033) { // increasing this value reduces refresh rate and greatly increases performance - buttonImage.position = loc; - lastMove = CACurrentMediaTime(); - } - } - return YES; -} - -- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event -{ - self.direction = 0; - [self sendActionsForControlEvents:UIControlEventValueChanged]; - - if (self.style == iNDSDirectionalControlStyleJoystick) { - buttonImage.position = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2); - } -} - -#pragma mark - Getters/Setters - -- (void)setStyle:(iNDSDirectionalControlStyle)style { - switch (style) { - case iNDSDirectionalControlStyleDPad: { - buttonImage.hidden = YES; - self.backgroundImageView.image = [UIImage imageNamed:@"DPad"]; - break; - } - - case iNDSDirectionalControlStyleJoystick: { - buttonImage.hidden = NO; - self.backgroundImageView.image = [UIImage imageNamed:@"JoystickBackground"]; - break; - } - } - _style = style; -} - -@end diff --git a/inds/core/emu.h b/inds/core/emu.h deleted file mode 100755 index 77b780a..0000000 --- a/inds/core/emu.h +++ /dev/null @@ -1,68 +0,0 @@ -// -// emu.h -// iNDS -// -// Created by rock88 on 18/12/2012. -// Copyright (c) 2012 Homebrew. All rights reserved. -// - -#ifndef _EMU_H_ -#define _EMU_H_ - -#include - -extern volatile bool execute; - -typedef unsigned char u8; -typedef unsigned int u32; - -typedef enum { - BUTTON_RIGHT = 0, - BUTTON_LEFT = 1, - BUTTON_DOWN = 2, - BUTTON_UP = 3, - BUTTON_SELECT = 4, - BUTTON_START = 5, - BUTTON_B = 6, - BUTTON_A = 7, - BUTTON_Y = 8, - BUTTON_X = 9, - BUTTON_L = 10, - BUTTON_R = 11, -} BUTTON_ID; - -void EMU_init(int lang = -1); -void EMU_loadSettings(); -bool EMU_doRomLoad(const char* path, const char* logical); -bool EMU_loadRom(const char* path); -void EMU_change3D(int type); -void EMU_changeSound(int type); -void EMU_enableSound(bool enable); -void iNDS_throttle(bool allowSleep = true, int forceFrameSkip = -1); -void EMU_setFrameSkip(int skip); -void EMU_setCPUMode(int cpuMode); -void EMU_setSynchMode(bool enabled); -void EMU_runCore(); -int EMU_runOther(); -void EMU_copyMasterBuffer(); -void EMU_pause(bool pause); -bool EMU_loadState(const char *filename); -bool EMU_saveState(const char *filename); -void* EMU_getVideoBuffer(size_t *outSize); - -void EMU_touchScreenTouch(int x, int y); -void EMU_touchScreenRelease(); - -void EMU_setWorkingDir(const char* path); -void EMU_closeRom(); - -void EMU_buttonDown(BUTTON_ID button); -void EMU_buttonUp(BUTTON_ID button); -void EMU_setDPad(bool up, bool down, bool left, bool right); -void EMU_setABXY(bool a, bool b, bool x, bool y); - - -const char *EMU_version(); - -#endif /* defined(__iNDS__emu__) */ - diff --git a/inds/core/iNDSGame.h b/inds/core/iNDSGame.h deleted file mode 100755 index adf4923..0000000 --- a/inds/core/iNDSGame.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// iNDSGame.h -// iNDS -// -// Created by Zydeco on 16/7/2013. -// Copyright (c) 2013 iNDS. All rights reserved. -// - -#import - -FOUNDATION_EXPORT NSString * const iNDSGameSaveStatesChangedNotification; - -@interface iNDSGame : NSObject - -@property (strong, nonatomic) NSString *path; -@property (nonatomic, readonly) NSString *title; -@property (nonatomic, readonly) NSString *rawTitle; -@property (nonatomic, readonly) NSString *gameTitle; -@property (nonatomic, readonly) UIImage *icon; -@property (nonatomic, readonly) NSInteger numberOfSaveStates; -@property (strong, nonatomic) NSString *pathForSavedStates; -@property (nonatomic, readonly) BOOL hasPauseState; - -+ (int)preferredLanguage; // returns a NDS_FW_LANG_ constant -+ (NSArray*)gamesAtPath:(NSString*)path saveStateDirectoryPath:(NSString*)saveStatePath; -+ (iNDSGame*)gameWithPath:(NSString*)path saveStateDirectoryPath:(NSString*)saveStatePath; -- (iNDSGame*)initWithPath:(NSString*)path saveStateDirectoryPath:(NSString*)saveStatePath; -- (NSString*)pathForSaveStateWithName:(NSString*)name; -- (NSString*)pathForSaveStateAtIndex:(NSInteger)idx; -- (NSString*)nameOfSaveStateAtIndex:(NSInteger)idx; -- (NSString*)nameOfSaveStateAtPath:(NSString*)path; -- (NSDate*)dateOfSaveStateAtIndex:(NSInteger)idx; -- (BOOL)deleteSaveStateAtIndex:(NSInteger)idx; -- (void)reloadSaveStates; -- (NSArray*)saveStates; - -@end diff --git a/inds/core/sndcoreaudio.h b/inds/core/sndcoreaudio.h deleted file mode 100755 index acc98b6..0000000 --- a/inds/core/sndcoreaudio.h +++ /dev/null @@ -1,19 +0,0 @@ -// -// sndcoreaudio.h -// iNDS -// -// Created by Zydeco on 3/7/2013. -// Copyright (c) 2013 Homebrew. All rights reserved. -// - -#ifndef iNDS_sndcoreaudio_h -#define iNDS_sndcoreaudio_h - -#include "SPU.h" - -extern SoundInterface_struct SNDCoreAudio; - -#define SNDCORE_COREAUDIO 1 - - -#endif diff --git a/inds/core/sndcoreaudio.mm b/inds/core/sndcoreaudio.mm deleted file mode 100755 index 7699e90..0000000 --- a/inds/core/sndcoreaudio.mm +++ /dev/null @@ -1,129 +0,0 @@ -// -// sndcoreaudio.mm -// iNDS -// -// Created by Zydeco on 3/7/2013. -// Copyright (c) 2013 Homebrew. All rights reserved. -// - -#import -#include "SPU.h" -#include "sndcoreaudio.h" -#include "main.h" - -int SNDCoreAudioInit(int buffersize); -void SNDCoreAudioDeInit(); -void SNDCoreAudioUpdateAudio(s16 *buffer, u32 num_samples); -u32 SNDCoreAudioGetAudioSpace(); -void SNDCoreAudioMuteAudio(); -void SNDCoreAudioUnMuteAudio(); -void SNDCoreAudioSetVolume(int volume); - -SoundInterface_struct SNDCoreAudio = { - SNDCORE_COREAUDIO, - "CoreAudio Sound Interface", - SNDCoreAudioInit, - SNDCoreAudioDeInit, - SNDCoreAudioUpdateAudio, - SNDCoreAudioGetAudioSpace, - SNDCoreAudioMuteAudio, - SNDCoreAudioUnMuteAudio, - SNDCoreAudioSetVolume, -}; - -#define NUM_BUFFERS 2 - -static int curFillBuffer = 0; -static int curReadBuffer = 0; -static int numFullBuffers = 0; -static int sndBufferSize; -static s16 *sndBuffer[NUM_BUFFERS]; -static bool audioQueueStarted = false; -static AudioQueueBufferRef aqBuffer[NUM_BUFFERS]; -static AudioQueueRef audioQueue; - -void SNDCoreAudioCallback (void *data, AudioQueueRef mQueue, AudioQueueBufferRef mBuffer) { - mBuffer->mAudioDataByteSize = sndBufferSize; - void *mAudioData = mBuffer->mAudioData; - if (numFullBuffers == 0) { - bzero(mAudioData, sndBufferSize); - } else { - memcpy(mAudioData, sndBuffer[curReadBuffer], sndBufferSize); - numFullBuffers--; - curReadBuffer = curReadBuffer ? 0 : 1; - } - AudioQueueEnqueueBuffer(mQueue, mBuffer, 0, NULL); -} - -int SNDCoreAudioInit(int buffersize) { - OSStatus err; - curReadBuffer = curFillBuffer = numFullBuffers = 0; - - // create queue - AudioStreamBasicDescription outputFormat; - outputFormat.mSampleRate = 44100; - outputFormat.mFormatID = kAudioFormatLinearPCM; - outputFormat.mFormatFlags = kAudioFormatFlagsCanonical; - outputFormat.mBytesPerPacket = 4; - outputFormat.mFramesPerPacket = 1; - outputFormat.mBytesPerFrame = 4; - outputFormat.mChannelsPerFrame = 2; - outputFormat.mBitsPerChannel = 16; - outputFormat.mReserved = 0; - err = AudioQueueNewOutput(&outputFormat, SNDCoreAudioCallback, NULL, CFRunLoopGetMain(), kCFRunLoopCommonModes, 0, &audioQueue); - if (err != noErr) return -1; - - // create buffers - sndBufferSize = buffersize; - for (int i=0; i. -*/ - -#ifndef _THROTTLE_H_ -#define _THROTTLE_H_ - -extern int FastForward; -extern bool FrameLimit; -void IncreaseSpeed(); -void DecreaseSpeed(); - -void InitSpeedThrottle(); -void SpeedThrottle(); - -void AutoFrameSkip_NextFrame(); -void AutoFrameSkip_IgnorePreviousDelay(); -int AutoFrameSkip_GetSkipAmount(int min=0, int max=9); - -#ifdef ANDROID -unsigned int GetTickCount(); -#endif - -#endif diff --git a/inds/de.lproj/Localizable.strings b/inds/de.lproj/Localizable.strings deleted file mode 100755 index b4d6dc5..0000000 --- a/inds/de.lproj/Localizable.strings +++ /dev/null @@ -1,49 +0,0 @@ -ROM_LIST = "ROM-Liste"; -ABOUT_INDS = "Über iNDS"; -SETTINGS = "Einstellungen"; -DONATE = "Spenden"; - -SHARE = "Teilen"; - -EMULATOR_CORE_CODE = "Emulator Core Code"; - -EMULATOR = "Emulator"; -CONTROLS = "Steuerung"; -DEVELOPER = "Entwickler"; -EXPERIMENTAL = "Experimentell"; - -OVERLAY_PIXEL_GRID_DETAIL = "Das Pixel-Raster erscheint weniger unscharf, reduziert jedoch auch die Helligkeit."; -ENABLE_DROPBOX_DETAIL = "Das Aktivieren von Dropbox fügt einen \"iNDS\"-Ordner deiner Dropbox hinzu. Deine Spielstände werden in die Dropbox synchronisiert und auf deine Geräte verteilt (iPhone, iPad, iPod Touch, Androidm PC, etc)."; -ARMLJIT_DETAIL = "GNU Lightning JIT macht das Ausführen von Spielen schneller. Dein iPhone muss gejailbreaked sein oder iNDS wird abstürzen."; - -AUTO = "Auto"; -DPAD = "D-Pad"; -JOYSTICK = "Joystick"; -TOP = "Oben"; -BOTTOM = "Unten"; - -FRAME_SKIP = "Bildüberspringung"; -DISABLE_SOUND = "Musik deaktivieren"; -OVERLAY_PIXEL_GRID = "Pixel-Raster anzeigen"; - -CONTROL_PAD_STYLE = "Steuerungstyp"; -CONTROL_POSITION_PORTRAIT = "Steuerungsposition (Portrait)"; -CONTROL_OPACITY_PORTRAIT = "Steuerungstransparenz (Portrait)"; - -ENABLE_DROPBOX = "Dropbox-Sync aktivieren"; -NOT_LINKED = "Nicht verbunden"; -LINKED = "Verbunden"; -UNLINKED = "Nicht mehr verbunden!"; -UNLINKED_DETAIL = "Dropbox ist nicht mehr verbunden. Deine Spiele werden nicht mehr synchronisiert."; -SUCCESS = "Verbindung erfolgreich"; -SUCCESS_DETAIL = "Dropbox wurde erfolgreich verbunden. iNDS wird nun automatisch deine Spielstände in einen Dropbox-Ordner namens 'iNDS' synchronisieren."; -DROPBOX_CFG_ERROR = "Fehler beim Konfigurieren von Dropbox"; - -SHOW_FPS = "FPS anzeigen"; -VIBRATION = "Vibration"; - -LAUNCH_GAME = "Spiel starten"; -LAUNCH_GAME_DETAIL = "Diese ROM öffnen"; -RESUME_AUTOSAVE = "Speicherstand laden"; - -ARMLJIT = "GNU Lightning JIT"; \ No newline at end of file diff --git a/inds/donation/iNDSDonationViewController.h b/inds/donation/iNDSDonationViewController.h deleted file mode 100755 index f612717..0000000 --- a/inds/donation/iNDSDonationViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// iNDSDonationViewController.h -// iNDS -// -// Created by Developer on 7/10/13. -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import - -@interface iNDSDonationViewController : UITableViewController { - IBOutlet UINavigationItem *donateTitle; - IBOutlet UILabel *donateLabel; -} -@end diff --git a/inds/dropbox/.DS_Store b/inds/dropbox/.DS_Store deleted file mode 100644 index 5008ddf..0000000 Binary files a/inds/dropbox/.DS_Store and /dev/null differ diff --git a/inds/dropbox/DropboxSDK.framework/Headers/DBDeltaEntry.h b/inds/dropbox/DropboxSDK.framework/Headers/DBDeltaEntry.h deleted file mode 100644 index 757d24f..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/DBDeltaEntry.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// DBDeltaEntry.h -// DropboxSDK -// -// Created by Brian Smith on 3/25/12. -// Copyright (c) 2012 Dropbox. All rights reserved. -// - -#import "DBMetadata.h" - -@interface DBDeltaEntry : NSObject { - NSString *lowercasePath; - DBMetadata *metadata; -} - -- (id)initWithArray:(NSArray *)array; - -@property (nonatomic, readonly) NSString *lowercasePath; -@property (nonatomic, readonly) DBMetadata *metadata; // nil if file has been deleted - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/DBJSON.h b/inds/dropbox/DropboxSDK.framework/Headers/DBJSON.h deleted file mode 100644 index de5ebe2..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/DBJSON.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2007-2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * 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. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import -#import "DBJsonParser.h" -#import "DBJsonWriter.h" - -/** - @brief Facade for DBJsonWriter/DBJsonParser. - - Requests are forwarded to instances of DBJsonWriter and DBJsonParser. - */ -@interface DBJSON : DBJsonBase { - -@private - DBJsonParser *jsonParser; - DBJsonWriter *jsonWriter; -} - - -/// Return the fragment represented by the given string -- (id)fragmentWithString:(NSString*)jsonrep - error:(NSError**)error; - -/// Return the object represented by the given string -- (id)objectWithString:(NSString*)jsonrep - error:(NSError**)error; - -/// Parse the string and return the represented object (or scalar) -- (id)objectWithString:(id)value - allowScalar:(BOOL)x - error:(NSError**)error; - - -/// Return JSON representation of an array or dictionary -- (NSString*)stringWithObject:(id)value - error:(NSError**)error; - -/// Return JSON representation of any legal JSON value -- (NSString*)stringWithFragment:(id)value - error:(NSError**)error; - -/// Return JSON representation (or fragment) for the given object -- (NSString*)stringWithObject:(id)value - allowScalar:(BOOL)x - error:(NSError**)error; - - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/DBJsonParser.h b/inds/dropbox/DropboxSDK.framework/Headers/DBJsonParser.h deleted file mode 100644 index c2a6978..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/DBJsonParser.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * 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. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import -#import "DBJsonBase.h" - -/** - @brief Options for the parser class. - - This exists so the DBJSON facade can implement the options in the parser without having to re-declare them. - */ -@protocol DBJsonParser - -/** - @brief Return the object represented by the given string. - - Returns the object represented by the passed-in string or nil on error. The returned object can be - a string, number, boolean, null, array or dictionary. - - @param repr the json string to parse - */ -- (id)objectWithString:(NSString *)repr; - -@end - - -/** - @brief The JSON parser class. - - JSON is mapped to Objective-C types in the following way: - - @li Null -> NSNull - @li String -> NSMutableString - @li Array -> NSMutableArray - @li Object -> NSMutableDictionary - @li Boolean -> NSNumber (initialised with -initWithBool:) - @li Number -> NSDecimalNumber - - Since Objective-C doesn't have a dedicated class for boolean values, these turns into NSNumber - instances. These are initialised with the -initWithBool: method, and - round-trip back to JSON properly. (They won't silently suddenly become 0 or 1; they'll be - represented as 'true' and 'false' again.) - - JSON numbers turn into NSDecimalNumber instances, - as we can thus avoid any loss of precision. (JSON allows ridiculously large numbers.) - - */ -@interface DBJsonParser : DBJsonBase { - -@private - const char *c; -} - -@end - -// don't use - exists for backwards compatibility with 2.1.x only. Will be removed in 2.3. -@interface DBJsonParser (Private) -- (id)fragmentWithString:(id)repr; -@end - - diff --git a/inds/dropbox/DropboxSDK.framework/Headers/DBQuota.h b/inds/dropbox/DropboxSDK.framework/Headers/DBQuota.h deleted file mode 100644 index b2c2c18..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/DBQuota.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// DBQuota.h -// DropboxSDK -// -// Created by Brian Smith on 5/3/10. -// Copyright 2010 Dropbox, Inc. All rights reserved. -// - -#import - -@interface DBQuota : NSObject { - long long normalConsumedBytes; - long long sharedConsumedBytes; - long long totalBytes; -} - -- (id)initWithDictionary:(NSDictionary*)dict; - -@property (nonatomic, readonly) long long normalConsumedBytes; -@property (nonatomic, readonly) long long sharedConsumedBytes; -@property (nonatomic, readonly) long long totalConsumedBytes; -@property (nonatomic, readonly) long long totalBytes; - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/DropboxSDK-Prefix.pch b/inds/dropbox/DropboxSDK.framework/Headers/DropboxSDK-Prefix.pch deleted file mode 100644 index dcc06b4..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/DropboxSDK-Prefix.pch +++ /dev/null @@ -1,7 +0,0 @@ -// -// Prefix header for all source files of the 'DropboxSDK' target in the 'DropboxSDK' project -// - -#ifdef __OBJC__ - #import -#endif diff --git a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPI.h b/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPI.h deleted file mode 100644 index 1449322..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPI.h +++ /dev/null @@ -1,86 +0,0 @@ -// -// MPOAuthAPI.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.05. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import -#import "MPOAuthCredentialStore.h" -#import "MPOAuthParameterFactory.h" - -extern NSString * const MPOAuthNotificationAccessTokenReceived; -extern NSString * const MPOAuthNotificationAccessTokenRejected; -extern NSString * const MPOAuthNotificationAccessTokenRefreshed; -extern NSString * const MPOAuthNotificationOAuthCredentialsReady; -extern NSString * const MPOAuthNotificationErrorHasOccurred; - -extern NSString * const MPOAuthCredentialRequestTokenKey; -extern NSString * const MPOAuthCredentialRequestTokenSecretKey; -extern NSString * const MPOAuthCredentialAccessTokenKey; -extern NSString * const MPOAuthCredentialAccessTokenSecretKey; -extern NSString * const MPOAuthCredentialSessionHandleKey; - -extern NSString * const MPOAuthTokenRefreshDateDefaultsKey; - -typedef enum { - MPOAuthSignatureSchemePlainText, - MPOAuthSignatureSchemeHMACSHA1, - MPOAuthSignatureSchemeRSASHA1 -} MPOAuthSignatureScheme; - -typedef enum { - MPOAuthAuthenticationStateUnauthenticated = 0, - MPOAuthAuthenticationStateAuthenticating = 1, - MPOAuthAuthenticationStateAuthenticated = 2 -} MPOAuthAuthenticationState; - -@protocol MPOAuthAPIInternalClient -@end - -@class MPOAuthAuthenticationMethod; - -@interface MPOAuthAPI : NSObject { -@private - id credentials_; - NSURL *baseURL_; - NSURL *authenticationURL_; - MPOAuthAuthenticationMethod *authenticationMethod_; - MPOAuthSignatureScheme signatureScheme_; - NSMutableArray *activeLoaders_; - MPOAuthAuthenticationState oauthAuthenticationState_; -} - -@property (nonatomic, readonly, retain) id credentials; -@property (nonatomic, readonly, retain) NSURL *baseURL; -@property (nonatomic, readonly, retain) NSURL *authenticationURL; -@property (nonatomic, readwrite, retain) MPOAuthAuthenticationMethod *authenticationMethod; -@property (nonatomic, readwrite, assign) MPOAuthSignatureScheme signatureScheme; - -@property (nonatomic, readonly, assign) MPOAuthAuthenticationState authenticationState; - - -- (id)initWithCredentials:(NSDictionary *)inCredentials andBaseURL:(NSURL *)inURL; -- (id)initWithCredentials:(NSDictionary *)inCredentials authenticationURL:(NSURL *)inAuthURL andBaseURL:(NSURL *)inBaseURL; -- (id)initWithCredentials:(NSDictionary *)inCredentials authenticationURL:(NSURL *)inAuthURL andBaseURL:(NSURL *)inBaseURL autoStart:(BOOL)aFlag; - -- (void)authenticate; -- (BOOL)isAuthenticated; - -- (void)performMethod:(NSString *)inMethod withTarget:(id)inTarget andAction:(SEL)inAction; -- (void)performMethod:(NSString *)inMethod atURL:(NSURL *)inURL withParameters:(NSArray *)inParameters withTarget:(id)inTarget andAction:(SEL)inAction; -- (void)performPOSTMethod:(NSString *)inMethod atURL:(NSURL *)inURL withParameters:(NSArray *)inParameters withTarget:(id)inTarget andAction:(SEL)inAction; -- (void)performURLRequest:(NSURLRequest *)inRequest withTarget:(id)inTarget andAction:(SEL)inAction; - -- (NSData *)dataForMethod:(NSString *)inMethod; -- (NSData *)dataForMethod:(NSString *)inMethod withParameters:(NSArray *)inParameters; -- (NSData *)dataForURL:(NSURL *)inURL andMethod:(NSString *)inMethod withParameters:(NSArray *)inParameters; - -- (id)credentialNamed:(NSString *)inCredentialName; -- (void)setCredential:(id)inCredential withName:(NSString *)inName; -- (void)removeCredentialNamed:(NSString *)inName; - -- (void)discardCredentials; - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPIRequestLoader.h b/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPIRequestLoader.h deleted file mode 100644 index affe1a2..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthAPIRequestLoader.h +++ /dev/null @@ -1,50 +0,0 @@ -// -// MPOAuthAPIRequestLoader.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.05. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import - -extern NSString * const MPOAuthNotificationRequestTokenReceived; -extern NSString * const MPOAuthNotificationRequestTokenRejected; -extern NSString * const MPOAuthNotificationAccessTokenReceived; -extern NSString * const MPOAuthNotificationAccessTokenRejected; -extern NSString * const MPOAuthNotificationAccessTokenRefreshed; -extern NSString * const MPOAuthNotificationErrorHasOccurred; - -@protocol MPOAuthCredentialStore; -@protocol MPOAuthParameterFactory; - -@class MPOAuthURLRequest; -@class MPOAuthURLResponse; -@class MPOAuthCredentialConcreteStore; - -@interface MPOAuthAPIRequestLoader : NSObject { - MPOAuthCredentialConcreteStore *_credentials; - MPOAuthURLRequest *_oauthRequest; - MPOAuthURLResponse *_oauthResponse; - NSMutableData *_dataBuffer; - NSString *_dataAsString; - NSError *_error; - id _target; - SEL _action; -} - -@property (nonatomic, readwrite, retain) id credentials; -@property (nonatomic, readwrite, retain) MPOAuthURLRequest *oauthRequest; -@property (nonatomic, readwrite, retain) MPOAuthURLResponse *oauthResponse; -@property (nonatomic, readonly, retain) NSData *data; -@property (nonatomic, readonly, retain) NSString *responseString; -@property (nonatomic, readwrite, assign) id target; -@property (nonatomic, readwrite, assign) SEL action; - -- (id)initWithURL:(NSURL *)inURL; -- (id)initWithRequest:(MPOAuthURLRequest *)inRequest; - -- (void)loadSynchronously:(BOOL)inSynchronous; - -@end - diff --git a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthConnection.h b/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthConnection.h deleted file mode 100644 index 71db8da..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthConnection.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// MPOAuthConnection.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.05. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import - -@protocol MPOAuthCredentialStore; -@protocol MPOAuthParameterFactory; - -@class MPOAuthURLRequest; -@class MPOAuthURLResponse; -@class MPOAuthCredentialConcreteStore; - -@interface MPOAuthConnection : NSURLConnection { -@private - MPOAuthCredentialConcreteStore *_credentials; -} - -@property (nonatomic, readonly) id credentials; - -+ (MPOAuthConnection *)connectionWithRequest:(MPOAuthURLRequest *)inRequest delegate:(id)inDelegate credentials:(NSObject *)inCredentials; -+ (NSData *)sendSynchronousRequest:(MPOAuthURLRequest *)inRequest usingCredentials:(NSObject *)inCredentials returningResponse:(MPOAuthURLResponse **)outResponse error:(NSError **)inError; -- (id)initWithRequest:(MPOAuthURLRequest *)inRequest delegate:(id)inDelegate credentials:(NSObject *)inCredentials; - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthCredentialConcreteStore.h b/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthCredentialConcreteStore.h deleted file mode 100644 index 9906415..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthCredentialConcreteStore.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// MPOAuthCredentialConcreteStore.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.11. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import -#import "MPOAuthCredentialStore.h" -#import "MPOAuthParameterFactory.h" - -@interface MPOAuthCredentialConcreteStore : NSObject { - NSMutableDictionary *store_; - NSURL *baseURL_; - NSURL *authenticationURL_; -} - -@property (nonatomic, readonly, retain) NSURL *baseURL; -@property (nonatomic, readonly, retain) NSURL *authenticationURL; - -@property (nonatomic, readonly) NSString *tokenSecret; -@property (nonatomic, readonly) NSString *signingKey; - -@property (nonatomic, readwrite, retain) NSString *requestToken; -@property (nonatomic, readwrite, retain) NSString *requestTokenSecret; -@property (nonatomic, readwrite, retain) NSString *accessToken; -@property (nonatomic, readwrite, retain) NSString *accessTokenSecret; - -@property (nonatomic, readwrite, retain) NSString *sessionHandle; - -- (id)initWithCredentials:(NSDictionary *)inCredential; -- (id)initWithCredentials:(NSDictionary *)inCredentials forBaseURL:(NSURL *)inBaseURL; -- (id)initWithCredentials:(NSDictionary *)inCredentials forBaseURL:(NSURL *)inBaseURL withAuthenticationURL:(NSURL *)inAuthenticationURL; - -- (void)setCredential:(id)inCredential withName:(NSString *)inName; -- (void)removeCredentialNamed:(NSString *)inName; - - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthSignatureParameter.h b/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthSignatureParameter.h deleted file mode 100644 index 08ec7c5..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/MPOAuthSignatureParameter.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// MPOAuthSignatureParameter.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.07. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import -#import "MPURLRequestParameter.h" - -#define kMPOAuthSignatureMethodPlaintext @"PLAINTEXT" -#define kMPOAuthSignatureMethodHMACSHA1 @"HMAC-SHA1" -#define kMPOAuthSignatureMethodRSASHA1 @"RSA-SHA1" - -@class MPOAuthURLRequest; - -@interface MPOAuthSignatureParameter : MPURLRequestParameter { - -} - -+ (NSString *)signatureBaseStringUsingParameterString:(NSString *)inParameterString forRequest:(MPOAuthURLRequest *)inRequest; -+ (NSString *)HMAC_SHA1SignatureForText:(NSString *)inText usingSecret:(NSString *)inSecret; - -- (id)initWithText:(NSString *)inText andSecret:(NSString *)inSecret forRequest:(MPOAuthURLRequest *)inRequest usingMethod:(NSString *)inMethod; - - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/NSDictionary+Dropbox.h b/inds/dropbox/DropboxSDK.framework/Headers/NSDictionary+Dropbox.h deleted file mode 100644 index d74cbfd..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/NSDictionary+Dropbox.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// NSDictionary+Dropbox.h -// Dropbox -// -// Created by Brian Smith on 6/5/11. -// Copyright 2011 Dropbox, Inc. All rights reserved. -// - - -@interface NSDictionary (Dropbox) - -+ (NSDictionary *)dictionaryWithQueryString:(NSString *)query; -- (NSString *)urlRepresentation; - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/NSString+DBJSON.h b/inds/dropbox/DropboxSDK.framework/Headers/NSString+DBJSON.h deleted file mode 100644 index 3e6e3be..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/NSString+DBJSON.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - Copyright (C) 2009 Stig Brautaset. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * 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. - - * Neither the name of the author nor the names of its contributors may be used - to endorse or promote products derived from this software without specific - prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#import - -/** - @brief Adds JSON parsing methods to NSString - -This is a category on NSString that adds methods for parsing the target string. -*/ -@interface NSString (NSString_DBJSON) - - -/** - @brief Returns the object represented in the receiver, or nil on error. - - Returns a a scalar object represented by the string's JSON fragment representation. - - @deprecated Given we bill ourselves as a "strict" JSON library, this method should be removed. - */ -- (id)JSONFragmentValue; - -/** - @brief Returns the NSDictionary or NSArray represented by the current string's JSON representation. - - Returns the dictionary or array represented in the receiver, or nil on error. - - Returns the NSDictionary or NSArray represented by the current string's JSON representation. - */ -- (id)JSONValue; - -@end diff --git a/inds/dropbox/DropboxSDK.framework/Headers/NSURLResponse+Encoding.h b/inds/dropbox/DropboxSDK.framework/Headers/NSURLResponse+Encoding.h deleted file mode 100644 index 40699ef..0000000 --- a/inds/dropbox/DropboxSDK.framework/Headers/NSURLResponse+Encoding.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// NSURL+MPEncodingAdditions.h -// MPOAuthConnection -// -// Created by Karl Adam on 08.12.05. -// Copyright 2008 matrixPointer. All rights reserved. -// - -#import - - -@interface NSURLResponse (EncodingAdditions) -- (NSStringEncoding)encoding; -@end diff --git a/inds/dropbox/DropboxSDK.framework/Info.plist b/inds/dropbox/DropboxSDK.framework/Info.plist deleted file mode 100644 index e41fedc..0000000 Binary files a/inds/dropbox/DropboxSDK.framework/Info.plist and /dev/null differ diff --git a/inds/es.lproj/Localizable.strings b/inds/es.lproj/Localizable.strings deleted file mode 100755 index 605d559..0000000 --- a/inds/es.lproj/Localizable.strings +++ /dev/null @@ -1,49 +0,0 @@ -ROM_LIST = "Lista de ROMs"; -ABOUT_INDS = "Acerca de iNDS"; -SETTINGS = "Ajustes"; -DONATE = "Donar"; - -SHARE = "Compartir"; - -EMULATOR_CORE_CODE = "Emulador de código de la base"; - -EMULATOR = "Emulador"; -CONTROLS = "Controles"; -DEVELOPER = "Desarrollador"; -EXPERIMENTAL = "Experimental"; - -OVERLAY_PIXEL_GRID_DETAIL = "La cuadrícula de píxeles hace que los juegos se vean menos borrosos, pero a la vez reduce el brillo."; -ENABLE_DROPBOX_DETAIL = "Activar Dropbox creará una carpeta llamada \"iNDS\" en tu cuenta de Dropbox. Tus partidas se sincronizarán a esa carpeta para que puedas seguirla en todos tus dispositivos (iPhone, iPad, iPod touch, Android, PC, etc)."; -ARMLJIT_DETAIL = "GNU Lighting JIT hace que los juegos funcionen más rápido. Usted debe estar jailbroken o iNDS se estrellará."; - -AUTO = "Auto"; -DPAD = "D-Pad"; -JOYSTICK = "Joystick"; -TOP = "Arriba"; -BOTTOM = "Abajo"; - -FRAME_SKIP = "Saltar Fotogramas"; -DISABLE_SOUND = "Desactivar Sonido"; -OVERLAY_PIXEL_GRID = "Mostrar Cuadrícula"; - -CONTROL_PAD_STYLE = "Estilo de Controles"; -CONTROL_POSITION_PORTRAIT = "Posicion de Controles (Vertical)"; -CONTROL_OPACITY_PORTRAIT = "Opacidad de Controles (Vertical)"; - -ENABLE_DROPBOX = "Sincronización"; -NOT_LINKED = "No Vinculado"; -LINKED = "vinculado"; -UNLINKED = "desvinculado!"; -UNLINKED_DETAIL = "Dropbox ha sido desvinculado. Sus archivos ya no se sincronizan."; -SUCCESS = "éxito"; -SUCCESS_DETAIL = "Dropbox se vinculó con éxito! Inds ahora comenzará a sincronizar tus archivos en una carpeta de Dropbox llamada 'inds' ubicado en el directorio raíz de Dropbox."; -DROPBOX_CFG_ERROR = "Error al configurar Dropbox"; - -SHOW_FPS = "Mostrar FPS"; -VIBRATION = "Vibración"; - -LAUNCH_GAME = "Iniciar Juego"; -LAUNCH_GAME_DETAIL = "Iniciando el juego normalmente"; -RESUME_AUTOSAVE = "Reanudar desde autoguardado"; - -ARMLJIT = "GNU Lightning JIT"; \ No newline at end of file diff --git a/inds/fr.lproj/Localizable.strings b/inds/fr.lproj/Localizable.strings deleted file mode 100755 index 9b4165a..0000000 --- a/inds/fr.lproj/Localizable.strings +++ /dev/null @@ -1,49 +0,0 @@ -ROM_LIST = "Liste de ROM"; -ABOUT_INDS = "À Propos De iNDS"; -SETTINGS = "Réglages"; -DONATE = "Faire Un Don"; - -SHARE = "Partager"; - -EMULATOR_CORE_CODE = "Émulateur Code De Base"; - -EMULATOR = "Émulateur"; -CONTROLS = "Contrôles"; -DEVELOPER = "Développeur"; -EXPERIMENTAL = "Expérimental"; - -OVERLAY_PIXEL_GRID_DETAIL = "La grille de pixels donne les jeux l'apparence d'être moins floue, mais en même temps, réduit la luminosité."; -ENABLE_DROPBOX_DETAIL = "L'activation de Dropbox va ajouter un dossier pour \"iNDS\" à votre compte pour Dropbox. Vos sauvegardes de jeu sera synchronisé à ce dossier afin qu'il portera à travers les dispositifs (iPhone, iPad, iPod touch, Android, PC, etc.)"; -ARMLJIT_DETAIL = "GNU Lighting JIT rend les jeux s'exécuter plus rapidement. Vous devez être jailbreaké, ou iNDS va planter."; - -AUTO = "Auto"; -DPAD = "D-Pad"; -JOYSTICK = "Joystick"; -TOP = "Haut"; -BOTTOM = "Bas"; - -FRAME_SKIP = "Saut De Trame"; -DISABLE_SOUND = "Désactiver Le Son"; -OVERLAY_PIXEL_GRID = "Grille De Pixels"; - -CONTROL_PAD_STYLE = "Style De Contrôle"; -CONTROL_POSITION_PORTRAIT = "Position Des Contrôles"; -CONTROL_OPACITY_PORTRAIT = "L'Opacité Des Contrôles"; - -ENABLE_DROPBOX = "Synchronisation"; -NOT_LINKED = "Non Lié"; -LINKED = "Linked"; -UNLINKED = "Unlinked!"; -UNLINKED_DETAIL = "Dropbox has been unlinked. Your save files will no longer be synced."; -SUCCESS = "Success"; -SUCCESS_DETAIL = "Dropbox was linked successfully! iNDS will now start syncing your saves to a Dropbox folder called 'iNDS' located in the root directory of your Dropbox folder."; -DROPBOX_CFG_ERROR = "Error Configuring Dropbox"; - -SHOW_FPS = "Montrer Le FPS"; -VIBRATION = "Vibration"; - -LAUNCH_GAME = "Launch Game"; -LAUNCH_GAME_DETAIL = "Boots the game normally"; -RESUME_AUTOSAVE = "Resume from Autosave"; - -ARMLJIT = "GNU Lightning JIT"; \ No newline at end of file diff --git a/inds/iCade/iCadeReaderView.m b/inds/iCade/iCadeReaderView.m deleted file mode 100755 index 3403b17..0000000 --- a/inds/iCade/iCadeReaderView.m +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (C) 2011 by Stuart Carnie - - Permission is hereby granted, free of charge, 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: - - 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, 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. - */ - -#import "iCadeReaderView.h" - -static const char *ON_STATES = "wdxayhujikol"; -static const char *OFF_STATES = "eczqtrfnmpgv"; - -@interface iCadeReaderView() - -- (void)didEnterBackground; -- (void)didBecomeActive; - -@end - -@implementation iCadeReaderView - -@synthesize iCadeState=_iCadeState, delegate=_delegate, active; - -- (id)initWithFrame:(CGRect)frame { - self = [super initWithFrame:frame]; - inputView = [[UIView alloc] initWithFrame:CGRectZero]; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didEnterBackground) name:UIApplicationDidEnterBackgroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeActive) name:UIApplicationDidBecomeActiveNotification object:nil]; - - return self; -} - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil]; -} - -- (void)didEnterBackground { - if (self.active) - [self resignFirstResponder]; -} - -- (void)didBecomeActive { - if (self.active) - [self becomeFirstResponder]; -} - -- (BOOL)canBecomeFirstResponder { - return YES; -} - -- (void)setActive:(BOOL)value { - if (active == value) return; - - active = value; - if (active) { - [self becomeFirstResponder]; - } else { - [self resignFirstResponder]; - } -} - -- (UIView*) inputView { - return inputView; -} - -- (void)setDelegate:(id)delegate { - _delegate = delegate; - if (!_delegate) return; - - _delegateFlags.stateChanged = [_delegate respondsToSelector:@selector(stateChanged:)]; - _delegateFlags.buttonDown = [_delegate respondsToSelector:@selector(buttonDown:)]; - _delegateFlags.buttonUp = [_delegate respondsToSelector:@selector(buttonUp:)]; -} - -#pragma mark - -#pragma mark UIKeyInput Protocol Methods - -- (BOOL)hasText { - return NO; -} - -- (void)insertText:(NSString *)text { - - char ch = [text characterAtIndex:0]; - char *p = strchr(ON_STATES, ch); - bool stateChanged = false; - if (p) { - int index = p-ON_STATES; - _iCadeState |= (1 << index); - stateChanged = true; - if (_delegateFlags.buttonDown) { - [_delegate buttonDown:(1 << index)]; - } - } else { - p = strchr(OFF_STATES, ch); - if (p) { - int index = p-OFF_STATES; - _iCadeState &= ~(1 << index); - stateChanged = true; - if (_delegateFlags.buttonUp) { - [_delegate buttonUp:(1 << index)]; - } - } - } - - if (stateChanged && _delegateFlags.stateChanged) { - [_delegate stateChanged:_iCadeState]; - } - - static int cycleResponder = 0; - if (++cycleResponder > 20) { - // necessary to clear a buffer that accumulates internally - cycleResponder = 0; - [self resignFirstResponder]; - [self becomeFirstResponder]; - } -} - -- (void)deleteBackward { - // This space intentionally left blank to complete protocol -} - -@end diff --git a/inds/iCade/iCadeState.h b/inds/iCade/iCadeState.h deleted file mode 100755 index 0355ee9..0000000 --- a/inds/iCade/iCadeState.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2011 by Stuart Carnie - - Permission is hereby granted, free of charge, 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: - - 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, 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. - */ - -typedef enum iCadeState { - iCadeJoystickNone = 0x000, - iCadeJoystickUp = 0x001, - iCadeJoystickRight = 0x002, - iCadeJoystickDown = 0x004, - iCadeJoystickLeft = 0x008, - - iCadeJoystickUpRight = iCadeJoystickUp | iCadeJoystickRight, - iCadeJoystickDownRight = iCadeJoystickDown | iCadeJoystickRight, - iCadeJoystickUpLeft = iCadeJoystickUp | iCadeJoystickLeft, - iCadeJoystickDownLeft = iCadeJoystickDown | iCadeJoystickLeft, - - iCadeButtonA = 0x010, - iCadeButtonB = 0x020, - iCadeButtonC = 0x040, - iCadeButtonD = 0x080, - iCadeButtonE = 0x100, - iCadeButtonF = 0x200, - iCadeButtonG = 0x400, - iCadeButtonH = 0x800, - -} iCadeState; diff --git a/inds/iNDSAddCheatTableViewController.mm b/inds/iNDSAddCheatTableViewController.mm deleted file mode 100644 index 0993619..0000000 --- a/inds/iNDSAddCheatTableViewController.mm +++ /dev/null @@ -1,97 +0,0 @@ -// -// iNDSAddCheatTableViewController.m -// iNDS -// -// Created by Will Cobb on 12/30/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSAddCheatTableViewController.h" -#import "AppDelegate.h" -#import "SCLAlertView.h" -#import "emu.h" -#import "cheatSystem.h" -@interface iNDSAddCheatTableViewController () { - BOOL showConfirmation; -} - -@end - -@implementation iNDSAddCheatTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - showConfirmation = YES; -} - -- (void)textViewDidChange:(UITextView *)textView -{ - showConfirmation = YES; - NSString *code = self.cheatCode.text; - code = [[code stringByReplacingOccurrencesOfString:@" " withString:@""] uppercaseString]; - code = [[code stringByReplacingOccurrencesOfString:@"\n" withString:@""] uppercaseString]; - NSMutableString *resultString = [[NSMutableString alloc] init]; - for (NSInteger i = 0; i < code.length; i++) { - [resultString appendString:[code substringWithRange:NSMakeRange(i, 1)]]; - if ((i + 1)%16 == 0 && i != 0 && i < code.length - 1) { - [resultString appendString:@"\n"]; - } else if ((i + 1)%8 == 0 && i != 0 && i < code.length - 1) { - [resultString appendString:@" "]; - } - } - - //Keep cursor coposition - NSRange cursorPosition = [textView selectedRange]; - textView.text = resultString; - dispatch_async(dispatch_get_main_queue(), ^{ - textView.selectedRange = NSMakeRange(cursorPosition.location+1, 0); - }); -} - - --(BOOL) navigationShouldPopOnBackButton { - if (showConfirmation) { - showConfirmation = NO; - NSLog(@"BYE: %ld %ld", self.cheatCode.text.length + 1, (self.cheatCode.text.length + 1) % 18); - if ((self.cheatCode.text.length + 1) % 18 == 0) { //A valid cheat code is entered - dispatch_async(dispatch_get_main_queue(), ^{ - SCLAlertView * alert = [[SCLAlertView alloc] initWithNewWindow]; - [alert addButton:@"Don't Save" actionBlock:^{ - [self.navigationController popViewControllerAnimated:YES]; - }]; - [alert showInfo:self title:@"Wait!" subTitle:@"Are you sure you want to leave without saving this cheat?" closeButtonTitle:@"Stay" duration:0.0]; - }); - return NO; - } - return YES; - - } - return YES; -} - -- (IBAction)saveCheat:(id)sender -{ - NSString *code = [self.cheatCode.text stringByReplacingOccurrencesOfString:@"\n" withString:@""]; - NSString *description = [NSString stringWithFormat:@"||%@||", self.cheatName.text]; - cheats->add_AR([code UTF8String], [description UTF8String], NO); - cheats->save(); - showConfirmation = NO; - [self.navigationController popViewControllerAnimated:YES]; -} - -- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section -{ - if (section == 0) { - return [NSString stringWithFormat:@"Game ID: %@", AppDelegate.sharedInstance.currentEmulatorViewController.game.rawTitle]; - } - return @""; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -#pragma mark - Table view data source - -@end diff --git a/inds/iNDSBugReportRomTableViewController.m b/inds/iNDSBugReportRomTableViewController.m deleted file mode 100644 index 7e480ac..0000000 --- a/inds/iNDSBugReportRomTableViewController.m +++ /dev/null @@ -1,41 +0,0 @@ -// -// iNDSBugReportRomTableViewController.m -// inds -// -// Created by Will Cobb on 3/30/16. -// Copyright © 2016 iNDS. All rights reserved. -// - -#import "iNDSBugReportRomTableViewController.h" -#import "iNDSBugReportSaveStateTableViewController.h" -#import "iNDSGame.h" -@implementation iNDSBugReportRomTableViewController - -- (void)viewDidLoad -{ - self.navigationItem.title = NSLocalizedString(@"ROM_LIST", nil); -} - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 1; -} - - -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - return NO; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - if (indexPath.section == 0) { - iNDSGame *game = games[indexPath.row]; - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - [self.delegate setGame:game]; - [self.navigationController popToRootViewControllerAnimated:YES]; - } else { - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - } -} -@end diff --git a/inds/iNDSBugReportSaveStateTableViewController.h b/inds/iNDSBugReportSaveStateTableViewController.h deleted file mode 100644 index 1e9b53d..0000000 --- a/inds/iNDSBugReportSaveStateTableViewController.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// iNDSBugReportSaveStateTableViewController.h -// inds -// -// Created by Will Cobb on 3/30/16. -// Copyright © 2016 iNDS. All rights reserved. -// - -#import "iNDSGameTableView.h" -#import "iNDSBugReportTableViewController.h" - -@interface iNDSBugReportSaveStateTableViewController : iNDSGameTableView - -@property id delegate; - -@end diff --git a/inds/iNDSCheatsFolderTableViewController.h b/inds/iNDSCheatsFolderTableViewController.h deleted file mode 100644 index d7cde8b..0000000 --- a/inds/iNDSCheatsFolderTableViewController.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// iNDSCheatsFolderTableViewController.h -// iNDS -// -// Created by Will Cobb on 12/30/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import - -@interface iNDSCheatsFolderTableViewController : UITableViewController - -@property (weak, nonatomic) NSMutableArray *folderCheats; - -@end diff --git a/inds/iNDSCheatsTableViewController.mm b/inds/iNDSCheatsTableViewController.mm deleted file mode 100644 index 2500462..0000000 --- a/inds/iNDSCheatsTableViewController.mm +++ /dev/null @@ -1,340 +0,0 @@ -// -// iNDSCheatsTableViewController.m -// iNDS -// -// Created by Will Cobb on 12/27/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSCheatsTableViewController.h" -#import "iNDSCheatsFolderTableViewController.h" -#import "AppDelegate.h" -#import "iNDSEmulatorViewController.h" -#import "SCLAlertView.h" -#include - -#include "emu.h" -#include "cheatSystem.h" - -#ifdef UseRarKit - #import -#else - #import "LZMAExtractor.h" -#endif - -@interface iNDSCheatsTableViewController () { - NSString *currentGameId; - iNDSEmulatorViewController *emulationController; - NSString *cheatsArchivePath; - BOOL cheatsLoaded; - NSXMLParser *cheatParser; - - NSMutableDictionary *cheatDict; - NSMutableArray *noFolderCodes; - - //XML - NSString *currentElemet; - NSString *currentGame; - BOOL inCurrentGame; - NSString *currentFolder; - BOOL inFolder; - BOOL inCheat; - NSString *cheatName; - NSString *cheatCode; - NSString *cheatNote; - - //Segue - NSString *openFolder; -} - -@end - -@implementation iNDSCheatsTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.navigationItem.title = @"Cheats"; - - emulationController = AppDelegate.sharedInstance.currentEmulatorViewController; - cheatsArchivePath = [[NSBundle mainBundle] pathForResource:@"cheats" ofType:@"rar"]; - currentGameId = emulationController.game.rawTitle; - - UITapGestureRecognizer* tapRecon = [[UITapGestureRecognizer alloc] initWithTarget:AppDelegate.sharedInstance.currentEmulatorViewController action:@selector(toggleSettings:)]; - tapRecon.numberOfTapsRequired = 2; - //[self.navigationController.navigationBar addGestureRecognizer:tapRecon]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - NSString *cheatSavePath = [NSString stringWithUTF8String:(char *)cheats->filename]; - //Eventually we might want to create our own NSInput stream to parse XML on the fly to reduce memory overhead and increase speed. This will work fine for now though - if (![[NSFileManager defaultManager] fileExistsAtPath:cheatSavePath]) { - NSLog(@"Loading DB Cheats"); - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - NSLog(@"Hey"); -#ifdef UseRarKit - NSError *error = nil; - URKArchive *archive = [[URKArchive alloc] initWithPath:cheatsArchivePath error:&error]; - NSData *cheatData = [archive extractDataFromFile:@"usrcheat1.xml" progress:nil error:&error]; -#else - NSString *extractPath = [AppDelegate.sharedInstance.documentsPath stringByAppendingPathComponent:@"cheats.xml"]; - NSString *archivePath = [[NSBundle mainBundle] pathForResource:@"cheats" ofType:@"7z"]; - if (![[NSFileManager defaultManager] fileExistsAtPath:extractPath]) { -// if (![LZMAExtractor extractArchiveEntry:archivePath archiveEntry:@"usrcheat1.xml" outPath:@"cheats.xml"]) { -// NSLog(@"Unable to extract 7z"); -// } - NSLog(@"%@", archivePath); - if (![LZMAExtractor extract7zArchive:archivePath dirName:NSTemporaryDirectory() preserveDir:YES]) { - NSLog(@"Unable to extract 7z"); - } - NSError *error; - [[NSFileManager defaultManager] moveItemAtPath:[NSTemporaryDirectory() stringByAppendingString:@"cheats.xml"] toPath:extractPath error:&error]; - if (error) { - NSLog(@"Error extracting: %@", error); - } - NSLog(@"Done Extracting"); - } else { - NSLog(@"Cheats file exists"); - } - - NSData *cheatData = [NSData dataWithContentsOfFile:extractPath]; -#endif - NSLog(@"CHeat data: %@", cheatData); - cheatParser = [[NSXMLParser alloc] initWithData:cheatData]; - cheatParser.delegate = self; - currentFolder = @""; - NSLog(@"Starting Parse %@", cheatData); - [cheatParser parse]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); - - }); - } else { - [self indexCheats]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); - } -} - -- (void)viewWillDisappear:(BOOL)animated -{ - [super viewWillDisappear:animated]; - cheats->save(); -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - - -- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { - currentElemet = elementName; - if (inCurrentGame) { - if ([elementName isEqualToString:@"folder"]) { - inFolder = YES; - } else if ([elementName isEqualToString:@"cheat"]) { - inCheat = YES; - } - } -} - -- (void)indexCheats -{ - cheatDict = [NSMutableDictionary dictionary]; - noFolderCodes = [NSMutableArray array]; - for (u32 i = 0; i < cheats->getSize(); i++) { - CHEATS_LIST *cheat = cheats->getItemByIndex(i); - NSString *description = [NSString stringWithCString:cheat->description encoding:NSUTF8StringEncoding]; - NSString *folder = [description componentsSeparatedByString:@"||"][0]; - if (folder.length == 0) { - [noFolderCodes addObject:[NSNumber numberWithInt:i]]; - } else { - if (!cheatDict[folder]) { - cheatDict[folder] = [NSMutableArray array]; - } - [cheatDict[folder] addObject:[NSNumber numberWithInt:i]]; - } - - } - cheatsLoaded = YES; - -} - -#pragma mark - XML - -- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { - - if ([currentElemet isEqualToString:@"gameid"]) { - inCurrentGame = [string isEqualToString:currentGameId]; - } else if (inCurrentGame) { - if (inCheat && [currentElemet isEqualToString:@"name"]) { - cheatName = string; - } else if (inCheat && [currentElemet isEqualToString:@"codes"]) { - cheatCode = string; - } else if (inCheat && [currentElemet isEqualToString:@"note"]) { - cheatNote = string; - } else if (inFolder && [currentElemet isEqualToString:@"name"]) { - currentFolder = string; - } - - } - currentElemet = @""; -} - -- (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { - - if (inFolder && [elementName isEqualToString:@"folder"]) { - inFolder = NO; - currentFolder = @""; - } - if (inCheat && [elementName isEqualToString:@"cheat"]) { - inCheat = NO; - /*NSLog(@"Cheat:"); - NSLog(@"%@-%@", currentFolder, cheatName); - NSLog(@"%@", cheatCode); - NSLog(@"%@", cheatNote);*/ - NSString * cheatDescription = [NSString stringWithFormat:@"%@||%@||%@", currentFolder, cheatName, cheatNote]; - cheats->add_AR([cheatCode UTF8String], [cheatDescription UTF8String], NO); - cheatName = @""; - cheatCode = @""; - cheatNote = @""; - } - -} - -- (void)parserDidEndDocument:(NSXMLParser *)parser { - cheats->save(); - [self indexCheats]; - dispatch_async(dispatch_get_main_queue(), ^{ - [self.tableView reloadData]; - }); -} - -#pragma mark - Table view data source - -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - return indexPath.section == 0; -} - -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (editingStyle == UITableViewCellEditingStyleDelete) { - if (indexPath.section == 0) { // Del game - u32 index = (u32)[noFolderCodes[indexPath.row] integerValue]; - cheats->remove(index); - [self indexCheats]; - [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; - } - } -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell * cell; - if (indexPath.section == 0) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cheat"]; - u32 index = (u32)[noFolderCodes[indexPath.row] integerValue]; - CHEATS_LIST *cheat = cheats->getItemByIndex(index); - cell.accessoryType = cheat->enabled ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone; - NSString *description = [NSString stringWithCString:cheat->description encoding:NSUTF8StringEncoding]; - NSString *name = [description componentsSeparatedByString:@"||"][1]; - cell.textLabel.text = name; - cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; - cell.textLabel.numberOfLines = 0; - cell.textLabel.font = [UIFont systemFontOfSize:14]; - } else { - if (!cheatsLoaded) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Loading"]; - cell.textLabel.text = @"Loading Cheats"; - UIActivityIndicatorView * activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - activity.frame = CGRectMake(self.view.frame.size.width - 50, 0, 44, 44); - [activity startAnimating]; - [cell addSubview:activity]; - } else { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Folder"]; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - NSString *folder = cheatDict.allKeys[indexPath.row]; - cell.textLabel.text = folder; - cell.textLabel.lineBreakMode = NSLineBreakByWordWrapping; - cell.textLabel.numberOfLines = 0; - cell.textLabel.font = [UIFont systemFontOfSize:16]; - - cell.imageView.image = [[UIImage imageNamed:@"Folder"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - cell.imageView.tintColor = [UIColor grayColor];//[UIApplication sharedApplication].delegate.window.tintColor; - } - } - return cell; -} - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 2; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (section == 0) return [noFolderCodes count]; //num user cheats - if (section == 1) { - if (cheatsLoaded) { - NSLog(@"CL"); - return cheatDict.allKeys.count; //num db cheats - } else { - NSLog(@"CNL"); - return 1; - } - } - return 0; -} - -- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath -{ - if (cheatsLoaded) { - if (indexPath.section == 0) { - u32 index = (u32)[noFolderCodes[indexPath.row] integerValue]; - CHEATS_LIST *cheat = cheats->getItemByIndex(index); - NSString *description = [NSString stringWithCString:cheat->description encoding:NSUTF8StringEncoding]; - NSString *name = [description componentsSeparatedByString:@"||"][1]; - NSAttributedString *attributedText = - [[NSAttributedString alloc] initWithString:name attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]}]; - CGRect rect = [attributedText boundingRectWithSize:CGSizeMake(tableView.bounds.size.width, CGFLOAT_MAX) - options:NSStringDrawingUsesLineFragmentOrigin - context:nil]; - return rect.size.height + 20; - } else { - NSString *folder = cheatDict.allKeys[indexPath.row]; - NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:folder attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:14]}]; - CGRect rect = [attributedText boundingRectWithSize:CGSizeMake(tableView.bounds.size.width, CGFLOAT_MAX) - options:NSStringDrawingUsesLineFragmentOrigin - context:nil]; - return MAX(70, rect.size.height + 20); - } - } - return 44; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath -{ - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - if (indexPath.section == 0) { - u32 index = (u32)[noFolderCodes[indexPath.row] integerValue]; - CHEATS_LIST *cheat = cheats->getItemByIndex(index); - cheat->enabled = !cheat->enabled; - [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]; - } else { - openFolder = cheatDict.allKeys[indexPath.row]; - [self performSegueWithIdentifier:@"OpenCheatFolder" sender:self]; - } -} - -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender -{ - if ([segue.identifier isEqualToString:@"OpenCheatFolder"]) { - iNDSCheatsFolderTableViewController * vc = segue.destinationViewController; - vc.folderCheats = cheatDict[openFolder]; - vc.navigationItem.title = openFolder; - } -} - -@end diff --git a/inds/iNDSEmulationProfileTableViewController.m b/inds/iNDSEmulationProfileTableViewController.m deleted file mode 100755 index 6eaff48..0000000 --- a/inds/iNDSEmulationProfileTableViewController.m +++ /dev/null @@ -1,116 +0,0 @@ -// -// iNDSEmulationProfileTableViewController.m -// iNDS -// -// Created by Will Cobb on 12/23/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSEmulationProfileTableViewController.h" -#import "iNDSEmulationProfile.h" -#import "AppDelegate.h" -@interface iNDSEmulationProfileTableViewController () { - NSArray * profiles; -} - -@end - -@implementation iNDSEmulationProfileTableViewController - --(void) viewDidLoad -{ - [super viewDidLoad]; - //[self tableView:self.tableView numberOfRowsInSection:0] - profiles = [iNDSEmulationProfile profilesAtPath:AppDelegate.sharedInstance.batteryDir]; - UIBarButtonItem * xButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:AppDelegate.sharedInstance.currentEmulatorViewController action:@selector(toggleSettings:)]; - xButton.imageInsets = UIEdgeInsetsMake(7, 3, 7, 0); - self.navigationItem.rightBarButtonItem = xButton; - UITapGestureRecognizer* tapRecon = [[UITapGestureRecognizer alloc] initWithTarget:AppDelegate.sharedInstance.currentEmulatorViewController action:@selector(toggleSettings:)]; - tapRecon.numberOfTapsRequired = 2; - //[self.navigationController.navigationBar addGestureRecognizer:tapRecon]; -} - -- (void) viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; -} - -#pragma mark - Table View - -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - return indexPath.section == 1; -} - - -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { - if (indexPath.section == 1) { - if (editingStyle == UITableViewCellEditingStyleDelete) { - iNDSEmulationProfile * profile = profiles[indexPath.row]; - if ([profile deleteProfile]) { - profiles = [iNDSEmulationProfile profilesAtPath:AppDelegate.sharedInstance.batteryDir]; - [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; - if ([profile.name isEqualToString:AppDelegate.sharedInstance.currentEmulatorViewController.profile.name]) { //Just deleted current profile - //Load default - [AppDelegate.sharedInstance.currentEmulatorViewController loadProfile:[[iNDSEmulationProfile alloc] initWithProfileName:@"iNDSDefaultProfile"]]; - } - } else { - NSLog(@"Error! unable to delete save state"); - } - } - } -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ - if (section == 0) return 1; - return profiles.count; -} - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 2; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; - if (indexPath.section == 0) { - cell.textLabel.text = @"Default"; - if ([AppDelegate.sharedInstance.currentEmulatorViewController.profile.name isEqualToString:@"iNDSDefaultProfile"]) { - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } - //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - } - else if (indexPath.section == 1) { - iNDSEmulationProfile * profile = profiles[indexPath.row]; - cell.textLabel.text = profile.name; - if ([profile.name isEqualToString:AppDelegate.sharedInstance.currentEmulatorViewController.profile.name]) { //Current profile - cell.accessoryType = UITableViewCellAccessoryCheckmark; - } else { - cell.accessoryType = UITableViewCellAccessoryNone; - } - } - return cell; -} - -#pragma mark - Select ROMs - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - iNDSEmulationProfile * profile; - if (indexPath.section == 0) { - profile = [[iNDSEmulationProfile alloc] initWithProfileName:@"iNDSDefaultProfile"]; - } else if (indexPath.section == 1) { - profile = profiles[indexPath.row]; - } - [AppDelegate.sharedInstance.currentEmulatorViewController loadProfile:profile]; - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - [profile ajustLayout]; - [self.navigationController popViewControllerAnimated:YES]; -} - - -@end diff --git a/inds/iNDSGameTableView.h b/inds/iNDSGameTableView.h deleted file mode 100755 index 2feaca1..0000000 --- a/inds/iNDSGameTableView.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// iNDSGameTableView.h -// iNDS -// -// Created by Will Cobb on 11/4/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import -#import "AppDelegate.h" - -@class iNDSGame; -@interface iNDSGameTableView : UITableViewController - -@property (atomic, strong) iNDSGame * game; - -@end diff --git a/inds/iNDSGameTableView.m b/inds/iNDSGameTableView.m deleted file mode 100755 index 78ae266..0000000 --- a/inds/iNDSGameTableView.m +++ /dev/null @@ -1,128 +0,0 @@ -// -// iNDSGameTableView.m -// iNDS -// -// Created by Will Cobb on 11/4/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSGameTableView.h" -#import "iNDSEmulatorViewController.h" -#import "SCLAlertView.h" -#import "CHBgDropboxSync.h" -@interface iNDSGameTableView() { - -} -@end - -@implementation iNDSGameTableView - --(void) viewDidLoad -{ - [super viewDidLoad]; - self.navigationItem.title = _game.gameTitle; -} - --(void) viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - [self.tableView reloadData]; - -} - -#pragma mark - Table View - -- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {} - -- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath -{ - return indexPath.section != 0; -} - -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section -{ - if (section == 0) - return 1; - return _game.saveStates.count; -} - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView -{ - return 2; -} - --(NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath { - - UITableViewRowAction *renameAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"rename" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ - SCLAlertView * alert = [[SCLAlertView alloc] initWithNewWindow]; - NSLog(@"Save %@", _game.saveStates[indexPath.row]); - UITextField *textField = [alert addTextField:@""]; - textField.text = [_game nameOfSaveStateAtIndex:indexPath.row]; - - [alert addButton:@"Rename" actionBlock:^(void) { - NSString *savePath = [_game pathForSaveStateAtIndex:indexPath.row]; - NSString *rootPath = savePath.stringByDeletingPathExtension.stringByDeletingPathExtension; - NSString *dstPath = [NSString stringWithFormat:@"%@.%@.dsv", rootPath, textField.text]; - NSLog(@"%@ - \n%@", savePath, dstPath); - - [[NSFileManager defaultManager] moveItemAtPath:savePath toPath:dstPath error:nil]; - [CHBgDropboxSync forceStopIfRunning]; //If we delete while syncing this shitty thing crashes - [_game reloadSaveStates]; - [tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; - }]; - [alert showEdit:self title:@"Rename" subTitle:@"Rename Save State" closeButtonTitle:@"Cancel" duration:0.0f]; - }]; - renameAction.backgroundColor = [UIColor colorWithRed:85/255.0 green:175/255.0 blue:238/255.0 alpha:1]; - - UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Delete" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){ - [CHBgDropboxSync forceStopIfRunning]; - if ([_game deleteSaveStateAtIndex:indexPath.row]) { - [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; - } else { - NSLog(@"Error! unable to delete save state"); - } - }]; - deleteAction.backgroundColor = [UIColor redColor]; - return @[deleteAction, renameAction]; -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell* cell; - if (indexPath.section == 0) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Launch"]; - cell.textLabel.text = @"Launch Normally"; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - } - else if (indexPath.section == 1) { - cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"]; - if (!cell) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"Cell"]; - } - // Name - NSString * saveStateTitle = [_game nameOfSaveStateAtIndex:indexPath.row]; - if ([saveStateTitle isEqualToString:@"pause"]) { - saveStateTitle = @"Auto Save"; - } - cell.textLabel.text = saveStateTitle; - - // Date - NSDateFormatter *timeFormatter = [[NSDateFormatter alloc]init]; - timeFormatter.dateFormat = @"h:mm a, MMMM d yyyy"; - NSString * dateString = [timeFormatter stringFromDate:[_game dateOfSaveStateAtIndex:indexPath.row]]; - cell.detailTextLabel.text = dateString; - cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; - } - return cell; -} - -#pragma mark - Select ROMs - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - [AppDelegate.sharedInstance startGame:_game withSavedState:indexPath.section == 0 ? -1 : indexPath.row]; - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - - -@end diff --git a/inds/iNDSProfileEditorTableViewController.m b/inds/iNDSProfileEditorTableViewController.m deleted file mode 100755 index f4380ef..0000000 --- a/inds/iNDSProfileEditorTableViewController.m +++ /dev/null @@ -1,121 +0,0 @@ -// -// iNDSProfileEditorTableViewController.m -// iNDS -// -// Created by Will Cobb on 12/26/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSProfileEditorTableViewController.h" -#import "AppDelegate.h" -#import "iNDSEmulationProfile.h" -@interface iNDSProfileEditorTableViewController () { - BOOL inEditingMode; - iNDSEmulatorViewController * emulationController; -} - -@end - -@implementation iNDSProfileEditorTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - emulationController = [AppDelegate sharedInstance].currentEmulatorViewController; - self.navigationItem.title = emulationController.profile.name; - - UIBarButtonItem * xButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:AppDelegate.sharedInstance.currentEmulatorViewController action:@selector(toggleSettings:)]; - xButton.imageInsets = UIEdgeInsetsMake(7, 3, 7, 0); - self.navigationItem.rightBarButtonItem = xButton; - UITapGestureRecognizer* tapRecon = [[UITapGestureRecognizer alloc] initWithTarget:AppDelegate.sharedInstance.currentEmulatorViewController action:@selector(toggleSettings:)]; - tapRecon.numberOfTapsRequired = 2; - //[self.navigationController.navigationBar addGestureRecognizer:tapRecon]; -} - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath -{ - UITableViewCell * cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; - if (inEditingMode) { - switch (indexPath.row) { - case 0: - cell.textLabel.text = @"Save Profile"; - break; - case 1: - cell.textLabel.text = @"Discard Changes"; - break; - default: - break; - } - } else { - switch (indexPath.row) { - case 0: - cell.textLabel.text = @"Edit Profile Layout"; - break; - case 1: - cell.textLabel.text = @"Rename Profile"; - break; - case 2: - cell.textLabel.text = @"New Profile"; - break; - case 3: - cell.textLabel.text = @"Duplicate Profile"; - break; - default: - break; - } - } - return cell; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - iNDSEmulationProfile * currentProfile = emulationController.profile; - if (!inEditingMode) { - if (indexPath.row == 0) { //Edit profile - self.navigationItem.hidesBackButton = YES; - [emulationController enterEditMode]; - inEditingMode = YES; - } else if (indexPath.row == 1) {//Rename - [currentProfile deleteProfile]; - [currentProfile saveProfileWithCancel:NO]; - } else if (indexPath.row == 2) {//New - self.navigationItem.hidesBackButton = YES; - iNDSEmulationProfile * defaultProfile = [[iNDSEmulationProfile alloc] initWithProfileName:@"iNDSDefaultProfile"]; - [emulationController loadProfile:defaultProfile]; - [emulationController enterEditMode]; - inEditingMode = YES; - } else if (indexPath.row == 3) {//Duplicate - [currentProfile saveProfileWithCancel:YES]; - } - } else { - if (indexPath.row == 0 ) {//Save - self.navigationItem.hidesBackButton = NO; - [emulationController.profile saveProfileWithCancel:NO]; - inEditingMode = NO; - } else { //Discard - //Just reload from file - NSString * profilePath = [iNDSEmulationProfile pathForProfileName:currentProfile.name]; - iNDSEmulationProfile * reloadedProfile = [iNDSEmulationProfile profileWithPath:profilePath]; - [emulationController loadProfile:reloadedProfile]; - inEditingMode = NO; - [emulationController exitEditMode]; - [self.navigationController popViewControllerAnimated:YES]; - } - - } - [tableView deselectRowAtIndexPath:indexPath animated:YES]; - [tableView reloadData]; -} - -#pragma mark - Table view data source -- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - if (inEditingMode) return 2; - return 4; -} - - -@end diff --git a/inds/iNDSRomDownloadManager.h b/inds/iNDSRomDownloadManager.h deleted file mode 100755 index 055ffc5..0000000 --- a/inds/iNDSRomDownloadManager.h +++ /dev/null @@ -1,40 +0,0 @@ -// -// iNDSRomDownloadManager.h -// iNDS -// -// Created by Will Cobb on 11/17/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import -@class iNDSRomDownload; - -@interface iNDSRomDownloadManager : NSObject - -@property (strong, readonly) NSMutableArray * activeDownloads; - -+ (id)sharedManager; -- (void)addRequest:(NSURLRequest *)request; -- (void)removeDownload:(iNDSRomDownload *)download; -@end - -@interface iNDSRomDownload : NSObject { - NSURLConnection * _connection; - - long long expectedBytes; - float progress; - - iNDSRomDownloadManager *_delegate; - NSFileHandle *fileHandle; - NSString * savePath; - NSURL * escapedPath; -} - -@property (weak, nonatomic)UILabel * progressLabel; -@property (weak, nonatomic)CALayer * progressLayer; - -- (id)initWithRequest:(NSURLRequest *)request delegate:(iNDSRomDownloadManager *)delegate; -- (float)progress; -- (NSString *)name; - -@end \ No newline at end of file diff --git a/inds/iNDSRomDownloadManager.m b/inds/iNDSRomDownloadManager.m deleted file mode 100755 index 8ba4a84..0000000 --- a/inds/iNDSRomDownloadManager.m +++ /dev/null @@ -1,135 +0,0 @@ -// -// iNDSRomDownloadManager.m -// iNDS -// -// Created by Will Cobb on 11/17/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSRomDownloadManager.h" -#import "AppDelegate.h" -#import "ZAActivityBar.h" - -@implementation iNDSRomDownload - -- (id)initWithRequest:(NSURLRequest *)request delegate:(iNDSRomDownloadManager *)delegate -{ - if (self = [super init]) { - _connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; - _delegate = delegate; - - savePath = [NSString stringWithFormat:@"file://%@%@", NSTemporaryDirectory(), [_connection.originalRequest.URL lastPathComponent]]; - escapedPath = [NSURL URLWithString:[savePath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; - - [[NSFileManager defaultManager] createFileAtPath:escapedPath.path contents:nil attributes:nil]; - fileHandle = [NSFileHandle fileHandleForWritingAtPath:escapedPath.path]; - if (!fileHandle) { - NSLog(@"Error opening handle"); - } - } - return self; -} - -- (float)progress -{ - return progress; -} - -- (NSString *)name -{ - return _connection.originalRequest.URL.path.lastPathComponent; -} - -- (void)stop -{ - [_connection cancel]; - _connection = nil; -} - -- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { - [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; - expectedBytes = [response expectedContentLength]; -} - -- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { - [fileHandle seekToEndOfFile]; - [fileHandle writeData:data]; - progress = [fileHandle offsetInFile] / (float)expectedBytes; - if (self.progressLabel) { - int roundedProgress = (int)(progress * 100); - self.progressLabel.text = [NSString stringWithFormat:@"Downloading: %i%%", roundedProgress]; - } -} - -- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { - [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; - [ZAActivityBar showErrorWithStatus:@"Failed to download ROM, Connection Error" duration:5]; - [_delegate removeDownload:self]; -} - -- (NSCachedURLResponse *) connection:(NSURLConnection *)connection willCacheResponse: (NSCachedURLResponse *)cachedResponse { - return nil; -} - -- (void) connectionDidFinishLoading:(NSURLConnection *)connection { - //NSFileManager *fm = [NSFileManager defaultManager]; - [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; - - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.progressLabel) - self.progressLabel.text = [NSString stringWithFormat:@"Opening"]; - }); - NSError * error; - - [fileHandle closeFile]; - - error = nil; - //[ZAActivityBar showWithStatus:@"Download Complete, Opening"]; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - [AppDelegate.sharedInstance application:nil openURL:escapedPath sourceApplication:nil annotation:nil]; - [_delegate removeDownload:self]; - [[NSNotificationCenter defaultCenter] postNotificationName:iNDSGameSaveStatesChangedNotification object:self]; - }); - -} -@end - - -@implementation iNDSRomDownloadManager - -+ (id)sharedManager { - static iNDSRomDownloadManager * sharedMyManager = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - sharedMyManager = [[self alloc] init]; - }); - return sharedMyManager; - -} - -- (id)init { - if (self = [super init]) { - _activeDownloads = [NSMutableArray new]; - } - return self; -} - -- (void)addRequest:(NSURLRequest *)request -{ - iNDSRomDownload *newDownload = [[iNDSRomDownload alloc] initWithRequest:request delegate:self]; - [_activeDownloads addObject:newDownload]; - [UIApplication sharedApplication].idleTimerDisabled = YES; - -} - -- (void)removeDownload:(iNDSRomDownload *)download -{ - if (![_activeDownloads containsObject:download]) return; - [_activeDownloads removeObject:download]; - [download stop]; - if (_activeDownloads.count == 0) { - [UIApplication sharedApplication].idleTimerDisabled = NO; - } -} - -@end diff --git a/inds/iNDSRomDownloader.h b/inds/iNDSRomDownloader.h deleted file mode 100755 index 9d21e12..0000000 --- a/inds/iNDSRomDownloader.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// iNDSRomDownloader.h -// iNDS -// -// Created by Will Cobb on 11/4/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import - -@interface iNDSRomDownloader : UIViewController - -@property id delegate; - -@end diff --git a/inds/iNDSSettingsTableViewController.m b/inds/iNDSSettingsTableViewController.m deleted file mode 100755 index 8b76042..0000000 --- a/inds/iNDSSettingsTableViewController.m +++ /dev/null @@ -1,154 +0,0 @@ -// -// iNDSSettingsTableViewController.m -// iNDS -// -// Created by Will Cobb on 12/21/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import "iNDSSettingsTableViewController.h" -#import "AppDelegate.h" -#import "iNDSEmulatorViewController.h" -#import "iNDSEmulatorSettingsViewController.h" -#import "iNDSEmulationProfile.h" -#import -@interface iNDSSettingsTableViewController () { - iNDSEmulatorViewController * emulationController; - - UIImageView *syncImageView; - UIBarButtonItem *barItem; -} -@end - -@implementation iNDSSettingsTableViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - self.navigationController.delegate = self; -} - -- (void)viewWillAppear:(BOOL)animated -{ - emulationController = [AppDelegate sharedInstance].currentEmulatorViewController; - self.romName.text = [AppDelegate sharedInstance].currentEmulatorViewController.game.gameTitle; - self.layoutName.text = [[NSUserDefaults standardUserDefaults] stringForKey:@"currentProfile"]; - if ([self.layoutName.text isEqualToString:@"iNDSDefaultProfile"]) { - self.layoutName.text = @"Default"; - } - - //Sync Image - UIImage *syncImage = [[UIImage imageNamed:@"Sync.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; - syncImageView = [[UIImageView alloc] initWithImage:syncImage]; - syncImageView.tintColor = [UIColor whiteColor]; - syncImageView.autoresizingMask = UIViewAutoresizingNone; - syncImageView.contentMode = UIViewContentModeCenter; - [syncImageView setHidden:YES]; - - UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; - button.frame = CGRectMake(0, 0, 30, 30); - [button addSubview:syncImageView]; - syncImageView.center = button.center; - barItem = [[UIBarButtonItem alloc] initWithCustomView:button]; - self.navigationItem.leftBarButtonItem = barItem; - - [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(showSync) name:@"iNDSDropboxSyncStarted" object:nil]; - [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(hideSync) name:@"iNDSDropboxSyncEnded" object:nil]; - - UIBarButtonItem * xButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:emulationController action:@selector(toggleSettings:)]; - xButton.imageInsets = UIEdgeInsetsMake(7, 3, 7, 0); - self.navigationItem.rightBarButtonItem = xButton; - UITapGestureRecognizer* tapRecon = [[UITapGestureRecognizer alloc] initWithTarget:emulationController action:@selector(toggleSettings:)]; - tapRecon.numberOfTapsRequired = 2; - tapRecon.delegate = self; - tapRecon.cancelsTouchesInView = NO; - //[self.navigationController.navigationBar addGestureRecognizer:tapRecon]; - -} - - -- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { - /*if ((touch.view == self.navigationItem.titleView)) { - NSLog(@"YES!"); - return YES; - } - NSLog(@"NO"); - return NO;*/ - //NSLog(@"%@\n", touch.view); - //return ![touch.view isKindOfClass:[UIButton class]]; - return (![[[touch view] class] isSubclassOfClass:[UIControl class]]); -} - -- (void)showSync -{ - [syncImageView setHidden:NO]; - CABasicAnimation* rotationAnimation; - rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"]; - rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 * -100]; - rotationAnimation.duration = 100; - rotationAnimation.cumulative = YES; - rotationAnimation.repeatCount = HUGE_VALF; - [syncImageView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"]; -} - -- (void)hideSync -{ - [syncImageView.layer removeAllAnimations]; - [syncImageView setHidden:YES]; -} - -- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated -{ - UITableViewController * tableController = (UITableViewController *)viewController; - - //Uncomment for animation - //[emulationController setSettingsHeight:tableController.tableView.contentSize.height + 44]; -} - - -- (void)didReceiveMemoryWarning { - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (IBAction)speedChanged:(UISegmentedControl*) control -{ - float translation[] = {0.5, 1, 2, 4}; - emulationController.speed = translation[control.selectedSegmentIndex]; - [emulationController toggleSettings:self]; -} - -#pragma mark - Table view data source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - return 1; -} - -- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - switch (indexPath.row) { - case 3: //Save State - [emulationController newSaveState]; //Request that the controller save - break; - case 8: //Reload - [emulationController reloadEmulator]; //Request that the controller save - break; - default: - break; - } - [tableView deselectRowAtIndexPath:indexPath animated:YES]; -} - -- (IBAction)close:(id)sender -{ - [emulationController toggleSettings:self]; -} - -- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender -{ - if ([segue.identifier isEqualToString:@"EmulatorSettings"]) { - iNDSEmulatorSettingsViewController * vc = segue.destinationViewController; - vc.navigationItem.leftBarButtonItems = nil; - } -} - -@end diff --git a/inds/indsemulationprofile.h b/inds/indsemulationprofile.h deleted file mode 100755 index b9e6ab5..0000000 --- a/inds/indsemulationprofile.h +++ /dev/null @@ -1,47 +0,0 @@ -// -// iNDSEmulationProfile.h -// iNDS -// -// Created by Will Cobb on 12/2/15. -// Copyright © 2015 iNDS. All rights reserved. -// - -#import -#import "iNDSButtonControl.h" -#import "iNDSDirectionalControl.h" - -@interface iNDSEmulationProfile : NSObject - -@property (strong, nonatomic) NSString* name; - -@property (assign, nonatomic) CGSize screenSize; - -@property (weak, nonatomic) UIView *mainScreen; -@property (weak, nonatomic) UIView *touchScreen; -@property (weak, nonatomic) UILabel *fpsLabel; -@property (weak, nonatomic) UIButton *settingsButton; -@property (weak, nonatomic) UIButton *startButton; -@property (weak, nonatomic) UIButton *selectButton; -@property (weak, nonatomic) UIButton *leftTrigger; -@property (weak, nonatomic) UIButton *rightTrigger; -@property (weak, nonatomic) iNDSDirectionalControl *directionalControl; -@property (weak, nonatomic) iNDSButtonControl *buttonControl; - -@property (weak, nonatomic) UISlider *sizeSlider; - - -- (id)initWithProfileName:(NSString*) name; -+ (NSArray*)profilesAtPath:(NSString*)profilesPath; -+ (iNDSEmulationProfile *)profileWithPath:(NSString*)path; -- (void)ajustLayout; -- (void)enterEditMode; -- (void)handlePan:(UIView *)currentView Location:(CGPoint) location state:(UIGestureRecognizerState) state; -- (void)sizeChanged:(UISlider *)sender; -- (void)deselectView; - -- (void)exitEditMode; -- (void)saveProfileWithCancel:(BOOL)showCancel; -- (BOOL)deleteProfile; -+ (NSString*)pathForProfileName:(NSString *)name; -@end - diff --git a/inds/ja.lproj/Localizable.strings b/inds/ja.lproj/Localizable.strings deleted file mode 100755 index 34202e2..0000000 --- a/inds/ja.lproj/Localizable.strings +++ /dev/null @@ -1,49 +0,0 @@ -ROM_LIST = "ROMリスト"; -ABOUT_INDS = "iNDSについて"; -SETTINGS = "設定"; -DONATE = "寄付"; - -SHARE = "シェア"; - -EMULATOR_CORE_CODE = "エミュレータコアコード"; - -EMULATOR = "エミュレータ"; -CONTROLS = "コントロール"; -DEVELOPER = "開発者"; -EXPERIMENTAL = "実験的"; - -OVERLAY_PIXEL_GRID_DETAIL = "ピクセルグリッドはゲームブラーを低減します。その代わり、ピクセルグリッドは明るさを低減します。"; -ENABLE_DROPBOX_DETAIL = "Dropboxとの同期を有効にすると、あなたのDropboxアカウントに「iNDS」フォルダを作成され、セーブデータ(DSV)に保存されます。よって、セーブデータはすべてのデバイス(iPhone、iPad、iPod touch、Android、PCなど)で利用できるようになります。"; -ARMLJIT_DETAIL = "GNU Lightning JITはエミュレーションが速くなります。脱獄(Jailbreak)をしていなければiNDSがクラッシュします。"; - -AUTO = "オート"; -DPAD = "Dパッド"; -JOYSTICK = "ジョイスティック"; -TOP = "上側"; -BOTTOM = "下側"; - -FRAME_SKIP = "フレームスキップ"; -DISABLE_SOUND = "サウンドを無効にする"; -OVERLAY_PIXEL_GRID = "ピクセルグリッド"; - -CONTROL_PAD_STYLE = "コントロールパッドスタイル"; -CONTROL_POSITION_PORTRAIT = "コントロールのポジション (縦向き時)"; -CONTROL_OPACITY_PORTRAIT = "コントロールの不透明 (縦向き時)"; - -ENABLE_DROPBOX = "Dropbox同期を有効にする"; -NOT_LINKED = "接続されていません"; -LINKED = "接続されてしました"; -UNLINKED = "切断されました!"; -UNLINKED_DETAIL = "Dropboxから切断されました。セーブデータは同期されません。"; -SUCCESS = "成功!"; -SUCCESS_DETAIL = "Dropbox接続されてしました!今から、Dropbox上の「iNDS」フォルダにあなたのセーブデータ(DSV)を同期します。"; -DROPBOX_CFG_ERROR = "Dropbox接続エラー"; - -SHOW_FPS = "FPSを表示"; -VIBRATION = "振動"; - -LAUNCH_GAME = "ゲームをスタートする"; -LAUNCH_GAME_DETAIL = "ゲームを起動する"; -RESUME_AUTOSAVE = "オートセーブから再開"; - -ARMLJIT = "GNU Lightning JIT"; \ No newline at end of file diff --git a/inds/minizip/ioapi.c b/inds/minizip/ioapi.c deleted file mode 100755 index e0f7382..0000000 --- a/inds/minizip/ioapi.c +++ /dev/null @@ -1,239 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - -*/ - -#if (defined(_WIN32)) - #define _CRT_SECURE_NO_WARNINGS -#endif - -#include "ioapi.h" - -voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) -{ - if (pfilefunc->zfile_func64.zopen64_file != NULL) - return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,filename,mode); - else - { - return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,(const char*)filename,mode); - } -} - -long call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) -{ - if (pfilefunc->zfile_func64.zseek64_file != NULL) - return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); - else - { - uLong offsetTruncated = (uLong)offset; - if (offsetTruncated != offset) - return -1; - else - return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); - } -} - -ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) -{ - if (pfilefunc->zfile_func64.zseek64_file != NULL) - return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); - else - { - uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); - if ((tell_uLong) == ((uLong)-1)) - return (ZPOS64_T)-1; - else - return tell_uLong; - } -} - -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) -{ - p_filefunc64_32->zfile_func64.zopen64_file = NULL; - p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; - p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; - p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; - p_filefunc64_32->zfile_func64.ztell64_file = NULL; - p_filefunc64_32->zfile_func64.zseek64_file = NULL; - p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; - -#ifndef __clang_analyzer__ - p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; -#endif - - p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; - p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; - p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; -} - - - -static voidpf ZCALLBACK fopen_file_func OF((voidpf opaque, const char* filename, int mode)); -static uLong ZCALLBACK fread_file_func OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -static uLong ZCALLBACK fwrite_file_func OF((voidpf opaque, voidpf stream, const void* buf,uLong size)); -static ZPOS64_T ZCALLBACK ftell64_file_func OF((voidpf opaque, voidpf stream)); -static long ZCALLBACK fseek64_file_func OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -static int ZCALLBACK fclose_file_func OF((voidpf opaque, voidpf stream)); -static int ZCALLBACK ferror_file_func OF((voidpf opaque, voidpf stream)); - -static voidpf ZCALLBACK fopen_file_func (voidpf opaque, const char* filename, int mode) -{ - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen(filename, mode_fopen); - return file; -} - -static voidpf ZCALLBACK fopen64_file_func (voidpf opaque, const void* filename, int mode) -{ - FILE* file = NULL; - const char* mode_fopen = NULL; - if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) - mode_fopen = "rb"; - else - if (mode & ZLIB_FILEFUNC_MODE_EXISTING) - mode_fopen = "r+b"; - else - if (mode & ZLIB_FILEFUNC_MODE_CREATE) - mode_fopen = "wb"; - - if ((filename!=NULL) && (mode_fopen != NULL)) - file = fopen64((const char*)filename, mode_fopen); - return file; -} - - -static uLong ZCALLBACK fread_file_func (voidpf opaque, voidpf stream, void* buf, uLong size) -{ - uLong ret; - ret = (uLong)fread(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -static uLong ZCALLBACK fwrite_file_func (voidpf opaque, voidpf stream, const void* buf, uLong size) -{ - uLong ret; - ret = (uLong)fwrite(buf, 1, (size_t)size, (FILE *)stream); - return ret; -} - -static long ZCALLBACK ftell_file_func (voidpf opaque, voidpf stream) -{ - long ret; - ret = ftell((FILE *)stream); - return ret; -} - - -static ZPOS64_T ZCALLBACK ftell64_file_func (voidpf opaque, voidpf stream) -{ - ZPOS64_T ret; - ret = ftello64((FILE *)stream); - return ret; -} - -static long ZCALLBACK fseek_file_func (voidpf opaque, voidpf stream, uLong offset, int origin) -{ - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - if (fseek((FILE *)stream, offset, fseek_origin) != 0) - ret = -1; - return ret; -} - -static long ZCALLBACK fseek64_file_func (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin) -{ - int fseek_origin=0; - long ret; - switch (origin) - { - case ZLIB_FILEFUNC_SEEK_CUR : - fseek_origin = SEEK_CUR; - break; - case ZLIB_FILEFUNC_SEEK_END : - fseek_origin = SEEK_END; - break; - case ZLIB_FILEFUNC_SEEK_SET : - fseek_origin = SEEK_SET; - break; - default: return -1; - } - ret = 0; - - if(fseeko64((FILE *)stream, offset, fseek_origin) != 0) - ret = -1; - - return ret; -} - - -static int ZCALLBACK fclose_file_func (voidpf opaque, voidpf stream) -{ - int ret; - ret = fclose((FILE *)stream); - return ret; -} - -static int ZCALLBACK ferror_file_func (voidpf opaque, voidpf stream) -{ - int ret; - ret = ferror((FILE *)stream); - return ret; -} - -void fill_fopen_filefunc (pzlib_filefunc_def) - zlib_filefunc_def* pzlib_filefunc_def; -{ - pzlib_filefunc_def->zopen_file = fopen_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell_file = ftell_file_func; - pzlib_filefunc_def->zseek_file = fseek_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} - -void fill_fopen64_filefunc (zlib_filefunc64_def* pzlib_filefunc_def) -{ - pzlib_filefunc_def->zopen64_file = fopen64_file_func; - pzlib_filefunc_def->zread_file = fread_file_func; - pzlib_filefunc_def->zwrite_file = fwrite_file_func; - pzlib_filefunc_def->ztell64_file = ftell64_file_func; - pzlib_filefunc_def->zseek64_file = fseek64_file_func; - pzlib_filefunc_def->zclose_file = fclose_file_func; - pzlib_filefunc_def->zerror_file = ferror_file_func; - pzlib_filefunc_def->opaque = NULL; -} diff --git a/inds/minizip/ioapi.h b/inds/minizip/ioapi.h deleted file mode 100755 index 7e20e95..0000000 --- a/inds/minizip/ioapi.h +++ /dev/null @@ -1,201 +0,0 @@ -/* ioapi.h -- IO base function header for compress/uncompress .zip - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications for Zip64 support - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - Changes - - Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) - Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. - More if/def section may be needed to support other platforms - Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. - (but you should use iowin32.c for windows instead) - -*/ - -#ifndef _ZLIBIOAPI64_H -#define _ZLIBIOAPI64_H - -#if (!defined(_WIN32)) && (!defined(WIN32)) - - // Linux needs this to support file operation on files larger then 4+GB - // But might need better if/def to select just the platforms that needs them. - - #ifndef __USE_FILE_OFFSET64 - #define __USE_FILE_OFFSET64 - #endif - #ifndef __USE_LARGEFILE64 - #define __USE_LARGEFILE64 - #endif - #ifndef _LARGEFILE64_SOURCE - #define _LARGEFILE64_SOURCE - #endif - #ifndef _FILE_OFFSET_BIT - #define _FILE_OFFSET_BIT 64 - #endif -#endif - -#include -#include -#include "zlib.h" - -#define USE_FILE32API -#if defined(USE_FILE32API) -#define fopen64 fopen -#define ftello64 ftell -#define fseeko64 fseek -#else -#ifdef _MSC_VER - #define fopen64 fopen - #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) - #define ftello64 _ftelli64 - #define fseeko64 _fseeki64 - #else // old MSC - #define ftello64 ftell - #define fseeko64 fseek - #endif -#endif -#endif - -/* -#ifndef ZPOS64_T - #ifdef _WIN32 - #define ZPOS64_T fpos_t - #else - #include - #define ZPOS64_T uint64_t - #endif -#endif -*/ - -#ifdef HAVE_MINIZIP64_CONF_H -#include "mz64conf.h" -#endif - -/* a type choosen by DEFINE */ -#ifdef HAVE_64BIT_INT_CUSTOM -typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; -#else -#ifdef HAS_STDINT_H -#include "stdint.h" -typedef uint64_t ZPOS64_T; -#else - - -#if defined(_MSC_VER) || defined(__BORLANDC__) -typedef unsigned __int64 ZPOS64_T; -#else -typedef unsigned long long int ZPOS64_T; -#endif -#endif -#endif - - - -#ifdef __cplusplus -extern "C" { -#endif - - -#define ZLIB_FILEFUNC_SEEK_CUR (1) -#define ZLIB_FILEFUNC_SEEK_END (2) -#define ZLIB_FILEFUNC_SEEK_SET (0) - -#define ZLIB_FILEFUNC_MODE_READ (1) -#define ZLIB_FILEFUNC_MODE_WRITE (2) -#define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) - -#define ZLIB_FILEFUNC_MODE_EXISTING (4) -#define ZLIB_FILEFUNC_MODE_CREATE (8) - - -#ifndef ZCALLBACK - #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) - #define ZCALLBACK CALLBACK - #else - #define ZCALLBACK - #endif -#endif - - - - -typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); -typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); -typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); -typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); -typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); - -typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); - - -/* here is the "old" 32 bits structure structure */ -typedef struct zlib_filefunc_def_s -{ - open_file_func zopen_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell_file_func ztell_file; - seek_file_func zseek_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc_def; - -typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); -typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); -typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); - -typedef struct zlib_filefunc64_def_s -{ - open64_file_func zopen64_file; - read_file_func zread_file; - write_file_func zwrite_file; - tell64_file_func ztell64_file; - seek64_file_func zseek64_file; - close_file_func zclose_file; - testerror_file_func zerror_file; - voidpf opaque; -} zlib_filefunc64_def; - -void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); -void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); - -/* now internal definition, only for zip.c and unzip.h */ -typedef struct zlib_filefunc64_32_def_s -{ - zlib_filefunc64_def zfile_func64; - open_file_func zopen32_file; - tell_file_func ztell32_file; - seek_file_func zseek32_file; -} zlib_filefunc64_32_def; - - -#define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) -#define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) -//#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) -//#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) -#define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) -#define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) - -voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); -long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); -ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); - -void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); - -#define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) -#define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) -#define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/inds/minizip/unzip.h b/inds/minizip/unzip.h deleted file mode 100755 index 3183968..0000000 --- a/inds/minizip/unzip.h +++ /dev/null @@ -1,437 +0,0 @@ -/* unzip.h -- IO for uncompress .zip files using zlib - Version 1.1, February 14h, 2010 - part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) - - Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) - - Modifications of Unzip for Zip64 - Copyright (C) 2007-2008 Even Rouault - - Modifications for Zip64 support on both zip and unzip - Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) - - For more info read MiniZip_info.txt - - --------------------------------------------------------------------------------- - - Condition of use and distribution are the same than zlib : - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - --------------------------------------------------------------------------------- - - Changes - - See header of unzip64.c - -*/ - -#ifndef _unz64_H -#define _unz64_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _ZLIB_H -#include "zlib.h" -#endif - -#ifndef _ZLIBIOAPI_H -#include "ioapi.h" -#endif - -#ifdef HAVE_BZIP2 -#include "bzlib.h" -#endif - -#define Z_BZIP2ED 12 - -#if defined(STRICTUNZIP) || defined(STRICTZIPUNZIP) -/* like the STRICT of WIN32, we define a pointer that cannot be converted - from (void*) without cast */ -typedef struct TagunzFile__ { int unused; } unzFile__; -typedef unzFile__ *unzFile; -#else -typedef voidp unzFile; -#endif - - -#define UNZ_OK (0) -#define UNZ_END_OF_LIST_OF_FILE (-100) -#define UNZ_ERRNO (Z_ERRNO) -#define UNZ_EOF (0) -#define UNZ_PARAMERROR (-102) -#define UNZ_BADZIPFILE (-103) -#define UNZ_INTERNALERROR (-104) -#define UNZ_CRCERROR (-105) - -/* tm_unz contain date/time info */ -typedef struct tm_unz_s -{ - uInt tm_sec; /* seconds after the minute - [0,59] */ - uInt tm_min; /* minutes after the hour - [0,59] */ - uInt tm_hour; /* hours since midnight - [0,23] */ - uInt tm_mday; /* day of the month - [1,31] */ - uInt tm_mon; /* months since January - [0,11] */ - uInt tm_year; /* years - [1980..2044] */ -} tm_unz; - -/* unz_global_info structure contain global data about the ZIPfile - These data comes from the end of central dir */ -typedef struct unz_global_info64_s -{ - ZPOS64_T number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info64; - -typedef struct unz_global_info_s -{ - uLong number_entry; /* total number of entries in - the central dir on this disk */ - uLong size_comment; /* size of the global comment of the zipfile */ -} unz_global_info; - -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_info64_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - ZPOS64_T compressed_size; /* compressed size 8 bytes */ - ZPOS64_T uncompressed_size; /* uncompressed size 8 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info64; - -typedef struct unz_file_info_s -{ - uLong version; /* version made by 2 bytes */ - uLong version_needed; /* version needed to extract 2 bytes */ - uLong flag; /* general purpose bit flag 2 bytes */ - uLong compression_method; /* compression method 2 bytes */ - uLong dosDate; /* last mod file date in Dos fmt 4 bytes */ - uLong crc; /* crc-32 4 bytes */ - uLong compressed_size; /* compressed size 4 bytes */ - uLong uncompressed_size; /* uncompressed size 4 bytes */ - uLong size_filename; /* filename length 2 bytes */ - uLong size_file_extra; /* extra field length 2 bytes */ - uLong size_file_comment; /* file comment length 2 bytes */ - - uLong disk_num_start; /* disk number start 2 bytes */ - uLong internal_fa; /* internal file attributes 2 bytes */ - uLong external_fa; /* external file attributes 4 bytes */ - - tm_unz tmu_date; -} unz_file_info; - -extern int ZEXPORT unzStringFileNameCompare OF ((const char* fileName1, - const char* fileName2, - int iCaseSensitivity)); -/* - Compare two filename (fileName1,fileName2). - If iCaseSenisivity = 1, comparision is case sensitivity (like strcmp) - If iCaseSenisivity = 2, comparision is not case sensitivity (like strcmpi - or strcasecmp) - If iCaseSenisivity = 0, case sensitivity is defaut of your operating system - (like 1 on Unix, 2 on Windows) -*/ - - -extern unzFile ZEXPORT unzOpen OF((const char *path)); -extern unzFile ZEXPORT unzOpen64 OF((const void *path)); -/* - Open a Zip file. path contain the full pathname (by example, - on a Windows XP computer "c:\\zlib\\zlib113.zip" or on an Unix computer - "zlib/zlib113.zip". - If the zipfile cannot be opened (file don't exist or in not valid), the - return value is NULL. - Else, the return value is a unzFile Handle, usable with other function - of this unzip package. - the "64" function take a const void* pointer, because the path is just the - value passed to the open64_file_func callback. - Under Windows, if UNICODE is defined, using fill_fopen64_filefunc, the path - is a pointer to a wide unicode string (LPCTSTR is LPCWSTR), so const char* - does not describe the reality -*/ - - -extern unzFile ZEXPORT unzOpen2 OF((const char *path, - zlib_filefunc_def* pzlib_filefunc_def)); -/* - Open a Zip file, like unzOpen, but provide a set of file low level API - for read/write the zip file (see ioapi.h) -*/ - -extern unzFile ZEXPORT unzOpen2_64 OF((const void *path, - zlib_filefunc64_def* pzlib_filefunc_def)); -/* - Open a Zip file, like unz64Open, but provide a set of file low level API - for read/write the zip file (see ioapi.h) -*/ - -extern int ZEXPORT unzClose OF((unzFile file)); -/* - Close a ZipFile opened with unzipOpen. - If there is files inside the .Zip opened with unzOpenCurrentFile (see later), - these files MUST be closed with unzipCloseCurrentFile before call unzipClose. - return UNZ_OK if there is no problem. */ - -extern int ZEXPORT unzGetGlobalInfo OF((unzFile file, - unz_global_info *pglobal_info)); - -extern int ZEXPORT unzGetGlobalInfo64 OF((unzFile file, - unz_global_info64 *pglobal_info)); -/* - Write info about the ZipFile in the *pglobal_info structure. - No preparation of the structure is needed - return UNZ_OK if there is no problem. */ - - -extern int ZEXPORT unzGetGlobalComment OF((unzFile file, - char *szComment, - uLong uSizeBuf)); -/* - Get the global comment string of the ZipFile, in the szComment buffer. - uSizeBuf is the size of the szComment buffer. - return the number of byte copied or an error code <0 -*/ - - -/***************************************************************************/ -/* Unzip package allow you browse the directory of the zipfile */ - -extern int ZEXPORT unzGoToFirstFile OF((unzFile file)); -/* - Set the current file of the zipfile to the first file. - return UNZ_OK if there is no problem -*/ - -extern int ZEXPORT unzGoToNextFile OF((unzFile file)); -/* - Set the current file of the zipfile to the next file. - return UNZ_OK if there is no problem - return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. -*/ - -extern int ZEXPORT unzLocateFile OF((unzFile file, - const char *szFileName, - int iCaseSensitivity)); -/* - Try locate the file szFileName in the zipfile. - For the iCaseSensitivity signification, see unzStringFileNameCompare - - return value : - UNZ_OK if the file is found. It becomes the current file. - UNZ_END_OF_LIST_OF_FILE if the file is not found -*/ - - -/* ****************************************** */ -/* Ryan supplied functions */ -/* unz_file_info contain information about a file in the zipfile */ -typedef struct unz_file_pos_s -{ - uLong pos_in_zip_directory; /* offset in zip file directory */ - uLong num_of_file; /* # of file */ -} unz_file_pos; - -extern int ZEXPORT unzGetFilePos( - unzFile file, - unz_file_pos* file_pos); - -extern int ZEXPORT unzGoToFilePos( - unzFile file, - unz_file_pos* file_pos); - -typedef struct unz64_file_pos_s -{ - ZPOS64_T pos_in_zip_directory; /* offset in zip file directory */ - ZPOS64_T num_of_file; /* # of file */ -} unz64_file_pos; - -extern int ZEXPORT unzGetFilePos64( - unzFile file, - unz64_file_pos* file_pos); - -extern int ZEXPORT unzGoToFilePos64( - unzFile file, - const unz64_file_pos* file_pos); - -/* ****************************************** */ - -extern int ZEXPORT unzGetCurrentFileInfo64 OF((unzFile file, - unz_file_info64 *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); - -extern int ZEXPORT unzGetCurrentFileInfo OF((unzFile file, - unz_file_info *pfile_info, - char *szFileName, - uLong fileNameBufferSize, - void *extraField, - uLong extraFieldBufferSize, - char *szComment, - uLong commentBufferSize)); -/* - Get Info about the current file - if pfile_info!=NULL, the *pfile_info structure will contain somes info about - the current file - if szFileName!=NULL, the filemane string will be copied in szFileName - (fileNameBufferSize is the size of the buffer) - if extraField!=NULL, the extra field information will be copied in extraField - (extraFieldBufferSize is the size of the buffer). - This is the Central-header version of the extra field - if szComment!=NULL, the comment string of the file will be copied in szComment - (commentBufferSize is the size of the buffer) -*/ - - -/** Addition for GDAL : START */ - -extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64 OF((unzFile file)); - -/** Addition for GDAL : END */ - - -/***************************************************************************/ -/* for reading the content of the current zipfile, you can open it, read data - from it, and close it (you can close it before reading all the file) - */ - -extern int ZEXPORT unzOpenCurrentFile OF((unzFile file)); -/* - Open for reading data the current file in the zipfile. - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFilePassword OF((unzFile file, - const char* password)); -/* - Open for reading data the current file in the zipfile. - password is a crypting password - If there is no error, the return value is UNZ_OK. -*/ - -extern int ZEXPORT unzOpenCurrentFile2 OF((unzFile file, - int* method, - int* level, - int raw)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - -extern int ZEXPORT unzOpenCurrentFile3 OF((unzFile file, - int* method, - int* level, - int raw, - const char* password)); -/* - Same than unzOpenCurrentFile, but open for read raw the file (not uncompress) - if raw==1 - *method will receive method of compression, *level will receive level of - compression - note : you can set level parameter as NULL (if you did not want known level, - but you CANNOT set method parameter as NULL -*/ - - -extern int ZEXPORT unzCloseCurrentFile OF((unzFile file)); -/* - Close the file in zip opened with unzOpenCurrentFile - Return UNZ_CRCERROR if all the file was read but the CRC is not good -*/ - -extern int ZEXPORT unzReadCurrentFile OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read bytes from the current file (opened by unzOpenCurrentFile) - buf contain buffer where data must be copied - len the size of buf. - - return the number of byte copied if somes bytes are copied - return 0 if the end of file was reached - return <0 with error code if there is an error - (UNZ_ERRNO for IO error, or zLib error for uncompress error) -*/ - -extern z_off_t ZEXPORT unztell OF((unzFile file)); - -extern ZPOS64_T ZEXPORT unztell64 OF((unzFile file)); -/* - Give the current position in uncompressed data -*/ - -extern int ZEXPORT unzeof OF((unzFile file)); -/* - return 1 if the end of file was reached, 0 elsewhere -*/ - -extern int ZEXPORT unzGetLocalExtrafield OF((unzFile file, - voidp buf, - unsigned len)); -/* - Read extra field from the current file (opened by unzOpenCurrentFile) - This is the local-header version of the extra field (sometimes, there is - more info in the local-header version than in the central-header) - - if buf==NULL, it return the size of the local extra field - - if buf!=NULL, len is the size of the buffer, the extra header is copied in - buf. - the return value is the number of bytes copied in buf, or (if <0) - the error code -*/ - -/***************************************************************************/ - -/* Get the current file offset */ -extern ZPOS64_T ZEXPORT unzGetOffset64 (unzFile file); -extern uLong ZEXPORT unzGetOffset (unzFile file); - -/* Set the current file offset */ -extern int ZEXPORT unzSetOffset64 (unzFile file, ZPOS64_T pos); -extern int ZEXPORT unzSetOffset (unzFile file, uLong pos); - - - -#ifdef __cplusplus -} -#endif - -#endif /* _unz64_H */ diff --git a/inds/settings/iNDSEmulatorSettingsViewController.m b/inds/settings/iNDSEmulatorSettingsViewController.m deleted file mode 100755 index b8a119b..0000000 --- a/inds/settings/iNDSEmulatorSettingsViewController.m +++ /dev/null @@ -1,319 +0,0 @@ -// -// Settings.m -// iNDS -// -// Created by Riley Testut on 7/5/13. -// Copyright (c) 2014 iNDS. All rights reserved. -// - -#import "AppDelegate.h" -#import "iNDSEmulatorSettingsViewController.h" -#import -#import "SCLAlertView.h" -#import "CHBgDropboxSync.h" - -@interface iNDSEmulatorSettingsViewController () - -@property (weak, nonatomic) IBOutlet UINavigationItem *settingsTitle; - -@property (weak, nonatomic) IBOutlet UILabel *frameSkipLabel; -@property (weak, nonatomic) IBOutlet UILabel *disableSoundLabel; - -@property (weak, nonatomic) IBOutlet UISegmentedControl *frameSkipControl; -@property (weak, nonatomic) IBOutlet UISwitch *disableSoundSwitch; - -@property (weak, nonatomic) IBOutlet UILabel *controlPadStyleLabel; -@property (weak, nonatomic) IBOutlet UILabel *controlOpacityLabel; - -@property (weak, nonatomic) IBOutlet UISegmentedControl *controlPadStyleControl; -@property (weak, nonatomic) IBOutlet UISlider *controlOpacitySlider; - -@property (weak, nonatomic) IBOutlet UILabel *showFPSLabel; -@property (weak, nonatomic) IBOutlet UILabel *autoSaveLabel; - -@property (weak, nonatomic) IBOutlet UISwitch *showFPSSwitch; -@property (weak, nonatomic) IBOutlet UISwitch *autoSaveSwitch; -@property (weak, nonatomic) IBOutlet UISwitch *fullScreenSwitch; -@property (weak, nonatomic) IBOutlet UISwitch *bicubicSwitch; - -@property (weak, nonatomic) IBOutlet UILabel *synchSoundLabel; -@property (weak, nonatomic) IBOutlet UISwitch *synchSoundSwitch; - -@property (weak, nonatomic) IBOutlet UISwitch *enableJITSwitch; - -@property (weak, nonatomic) IBOutlet UILabel *vibrateLabel; -@property (weak, nonatomic) IBOutlet UISwitch *vibrateSwitch; -@property (weak, nonatomic) IBOutlet UISwitch *bumperSwitch; - -@property (weak, nonatomic) IBOutlet UISwitch *disableTouchScreenSwitch; - -@property (weak, nonatomic) IBOutlet UILabel *dropboxLabel; - -@property (weak, nonatomic) IBOutlet UISwitch *dropboxSwitch; -@property (weak, nonatomic) IBOutlet UISwitch *cellularSwitch; -@property (weak, nonatomic) IBOutlet UILabel *accountLabel; - -- (IBAction)controlChanged:(id)sender; - -@end - -@implementation iNDSEmulatorSettingsViewController - -- (id)initWithStyle:(UITableViewStyle)style -{ - self = [super initWithStyle:style]; - if (self) { - // Custom initialization - } - return self; -} - -- (void)viewDidLoad -{ - [super viewDidLoad]; - - self.settingsTitle.title = NSLocalizedString(@"SETTINGS", nil); - - self.frameSkipLabel.text = NSLocalizedString(@"FRAME_SKIP", nil); - self.disableSoundLabel.text = NSLocalizedString(@"DISABLE_SOUND", nil); - //self.showPixelGridLabel.text = NSLocalizedString(@"OVERLAY_PIXEL_GRID", nil); - - self.controlPadStyleLabel.text = NSLocalizedString(@"CONTROL_PAD_STYLE", nil); - self.controlOpacityLabel.text = NSLocalizedString(@"CONTROL_OPACITY_PORTRAIT", nil); - - self.dropboxLabel.text = NSLocalizedString(@"ENABLE_DROPBOX", nil); - self.accountLabel.text = NSLocalizedString(@"NOT_LINKED", nil); - - self.showFPSLabel.text = NSLocalizedString(@"SHOW_FPS", nil); - self.vibrateLabel.text = NSLocalizedString(@"VIBRATION", nil); - - [self.frameSkipControl setTitle:NSLocalizedString(@"AUTO", nil) forSegmentAtIndex:5]; - - [self.controlPadStyleControl setTitle:NSLocalizedString(@"DPAD", nil) forSegmentAtIndex:0]; - [self.controlPadStyleControl setTitle:NSLocalizedString(@"JOYSTICK", nil) forSegmentAtIndex:1]; - - - UIView *hiddenSettingsTapView = [[UIView alloc] initWithFrame:CGRectMake(245, 0, 75, 44)]; - - UIBarButtonItem *hiddenSettingsBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:hiddenSettingsTapView]; - self.navigationItem.rightBarButtonItem = hiddenSettingsBarButtonItem; - - UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(revealHiddenSettings:)]; - tapGestureRecognizer.numberOfTapsRequired = 3; - [hiddenSettingsTapView addGestureRecognizer:tapGestureRecognizer]; -} - -- (void)viewWillAppear:(BOOL)animated -{ - [super viewWillAppear:animated]; - - [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - NSInteger frameSkip = [defaults integerForKey:@"frameSkip"]; - self.frameSkipControl.selectedSegmentIndex = frameSkip < 0 ? 5 : frameSkip; - self.disableSoundSwitch.on = [defaults boolForKey:@"disableSound"]; - - self.controlPadStyleControl.selectedSegmentIndex = [defaults integerForKey:@"controlPadStyle"]; - self.controlOpacitySlider.value = [defaults floatForKey:@"controlOpacity"]; - - self.showFPSSwitch.on = [defaults boolForKey:@"showFPS"]; - self.autoSaveSwitch.on = [defaults boolForKey:@"periodicSave"]; - self.fullScreenSwitch.on = [defaults boolForKey:@"fullScreenSettings"]; - self.bicubicSwitch.on = [defaults boolForKey:@"highresGraphics"]; - self.synchSoundSwitch.on = [defaults boolForKey:@"synchSound"]; - - self.enableJITSwitch.on = [defaults boolForKey:@"enableLightningJIT"]; - self.vibrateSwitch.on = [defaults boolForKey:@"vibrate"]; - self.bumperSwitch.on = [defaults boolForKey:@"volumeBumper"]; - - self.disableTouchScreenSwitch.on = [defaults boolForKey:@"disableTouchScreen"]; - - self.dropboxSwitch.on = [defaults boolForKey:@"enableDropbox"]; - self.cellularSwitch.on = [defaults boolForKey:@"enableDropboxCellular"]; - - if ([defaults boolForKey:@"enableDropbox"] == true) { - self.accountLabel.text = NSLocalizedString(@"LINKED", nil); - } - [self appDidBecomeActive]; -} - - - -- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section -{ - NSString *sectionName; - switch (section) - { - case 0: - sectionName = NSLocalizedString(@"EMULATOR", nil); - break; - case 1: - sectionName = NSLocalizedString(@"CONTROLS", nil); - break; - case 2: - sectionName = @"Dropbox"; - break; - case 3: - sectionName = NSLocalizedString(@"DEVELOPER", nil); - break; - case 4: - sectionName = @"Info"; - break; - case 5: - sectionName = NSLocalizedString(@"EXPERIMENTAL", nil); - break; - default: - sectionName = @""; - break; - } - return sectionName; -} - -- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section -{ - NSString *sectionName; - NSString *myVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]; - switch (section) - { - case 0: - //sectionName = NSLocalizedString(@"OVERLAY_PIXEL_GRID_DETAIL", nil); - sectionName = @"Periodic Save will automatically save the game state every few minutes and will store a limited number of saves."; - break; - case 2: - sectionName = NSLocalizedString(@"ENABLE_DROPBOX_DETAIL", nil); - break; - case 4: - sectionName = [NSString stringWithFormat:@"Version %@", myVersion]; - break; - case 5: - sectionName = NSLocalizedString(@"ARMLJIT_DETAIL", nil); - break; - default: - sectionName = @""; - break; - } - return sectionName; -} - -- (void)didReceiveMemoryWarning -{ - [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. -} - -- (IBAction)controlChanged:(id)sender -{ - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (sender == self.frameSkipControl) { - NSInteger frameSkip = self.frameSkipControl.selectedSegmentIndex; - if (frameSkip == 5) frameSkip = -1; - [defaults setInteger:frameSkip forKey:@"frameSkip"]; - } else if (sender == self.disableSoundSwitch) { - [defaults setBool:self.disableSoundSwitch.on forKey:@"disableSound"]; - } else if (sender == self.synchSoundSwitch) { - [defaults setBool:self.synchSoundSwitch.on forKey:@"synchSound"]; - } else if (sender == self.autoSaveSwitch) { - [defaults setBool:self.autoSaveSwitch.on forKey:@"periodicSave"]; - } else if (sender == self.fullScreenSwitch) { - [defaults setBool:self.fullScreenSwitch.on forKey:@"fullScreenSettings"]; - } else if (sender == self.bicubicSwitch) { - [defaults setBool:self.bicubicSwitch.on forKey:@"highresGraphics"]; - } else if (sender == self.controlPadStyleControl) { - [defaults setInteger:self.controlPadStyleControl.selectedSegmentIndex forKey:@"controlPadStyle"]; - } else if (sender == self.controlOpacitySlider) { - [defaults setFloat:self.controlOpacitySlider.value forKey:@"controlOpacity"]; - } else if (sender == self.showFPSSwitch) { - [defaults setBool:self.showFPSSwitch.on forKey:@"showFPS"]; - } else if (sender == self.enableJITSwitch) { - [defaults setBool:self.enableJITSwitch.on forKey:@"enableLightningJIT"]; - } else if (sender == self.vibrateSwitch) { - [defaults setBool:self.vibrateSwitch.on forKey:@"vibrate"]; - } else if (sender == self.bumperSwitch) { - [defaults setBool:self.bumperSwitch.on forKey:@"volumeBumper"]; - } else if (sender == self.disableTouchScreenSwitch) { - [defaults setBool:self.disableTouchScreenSwitch.on forKey:@"disableTouchScreen"]; - } else if (sender == self.dropboxSwitch) {//i'll use a better more foolproof method later. <- lol yeah right - if ([defaults boolForKey:@"enableDropbox"] == false) { - [[DBSession sharedSession] linkFromController:self]; - } else { - [CHBgDropboxSync forceStopIfRunning]; - [CHBgDropboxSync clearLastSyncData]; - [[DBSession sharedSession] unlinkAll]; - SCLAlertView * alert = [[SCLAlertView alloc] init]; - [alert showInfo:self title:NSLocalizedString(@"UNLINKED", nil) subTitle:NSLocalizedString(@"UNLINKED_DETAIL", nil) closeButtonTitle:@"Okay!" duration:0.0]; - - [defaults setBool:false forKey:@"enableDropbox"]; - self.accountLabel.text = NSLocalizedString(@"NOT_LINKED", nil); - } - } else if (sender == self.cellularSwitch) { - [defaults setBool:self.cellularSwitch.on forKey:@"enableDropboxCellular"]; - } -} - - -- (void)appDidBecomeActive -{ - self.dropboxSwitch.on = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableDropbox"]; - - NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if ([defaults boolForKey:@"enableDropbox"] == true) { - self.accountLabel.text = NSLocalizedString(@"LINKED", nil); - } -} - -- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath -{ - if (indexPath.section == 4) { //Info - switch (indexPath.row) { - case 0: //Will Cobb - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://twitter.com/miniroo321"]]; - break; - - case 1: //Updates - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://twitter.com/iNDSapp"]]; - break; - - case 3: //DeSmuME - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.desmume.org/"]]; - break; - - case 4: //PMP174 - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/pmp174"]]; - break; - - case 5: //Source - [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://github.com/WilliamLCobb/iNDS"]]; - break; - - default: - break; - } - } -} - -#pragma mark - Hidden Settings - -- (void)revealHiddenSettings:(UITapGestureRecognizer *)tapGestureRecognizer -{ - [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"revealHiddenSettings"]; - [[NSUserDefaults standardUserDefaults] synchronize]; - - [self.tableView reloadData]; -} - -#pragma mark - UITableView Data Source - -- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - /*if ([[NSUserDefaults standardUserDefaults] boolForKey:@"revealHiddenSettings"]) { - return 6 ; - }*/ - - return 5; -} - --(IBAction)back:(id)sender -{ - [self dismissViewControllerAnimated:YES completion:nil]; -} -@end diff --git a/inds/types.h b/inds/types.h deleted file mode 100755 index 91b9c8d..0000000 --- a/inds/types.h +++ /dev/null @@ -1,498 +0,0 @@ -/* - Copyright (C) 2005 Guillaume Duhamel - Copyright (C) 2008-2012 DeSmuME team - - This file is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. - - This file is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the this software. If not, see . -*/ - -#ifndef TYPES_HPP -#define TYPES_HPP - -//analyze microsoft compilers -#ifdef _MSC_VER -#define _WINDOWS -//todo - everyone will want to support this eventually, i suppose -#include "config.h" -#endif - -//enforce a constraint: gdb stub requires developer -#if defined(GDB_STUB) && !defined(DEVELOPER) -#define DEVELOPER -#endif - -#ifdef DEVELOPER -#define IF_DEVELOPER(X) X -#else -#define IF_DEVELOPER(X) -#endif - -#ifdef _WINDOWS - //#define HAVE_WX //not useful yet.... - #define HAVE_LIBAGG - #define ENABLE_SSE - #define ENABLE_SSE2 - #ifdef DEVELOPER - #define HAVE_LUA - #endif - #define HAVE_JIT -#endif - -#ifdef __GNUC__ -#ifdef __SSE__ -#define ENABLE_SSE -#endif -#ifdef __SSE2__ -#define ENABLE_SSE2 -#endif -#endif - -#ifdef NOSSE -#undef ENABLE_SSE -#endif - -#ifdef NOSSE2 -#undef ENABLE_SSE2 -#endif - -#ifdef _MSC_VER -#define strcasecmp(x,y) _stricmp(x,y) -#define strncasecmp(x, y, l) strnicmp(x, y, l) -#define snprintf _snprintf -#else -#define WINAPI -#endif - -#ifdef __GNUC__ -#include -#ifndef PATH_MAX -#define MAX_PATH 1024 -#else -#define MAX_PATH PATH_MAX -#endif -#endif - -#if defined(WIN32) || defined(_WIN32) -#define _alloca16(x) ((void *)((((int)_alloca( (x)+15 )) + 15) & ~15)) -#define _alloca32(x) ((void *)((((int)_alloca( (x)+31 )) + 31) & ~31)) -#else -#include -#define _alloca alloca -#define _alloca16(x) ((void *)((((uintptr_t)alloca( (x)+15 )) + 15) & ~15)) -#define _alloca32(x) ((void *)((((uintptr_t)_alloca( (x)+31 )) + 31) & ~31)) -#endif - -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define DS_ALIGN(X) __declspec(align(X)) -#elif defined(__GNUC__) -#define DS_ALIGN(X) __attribute__ ((aligned (X))) -#else -#define DS_ALIGN(X) -#endif - -#ifdef __arm__ -#define CACHE_ALIGN DS_ALIGN(64) -#else -#define CACHE_ALIGN DS_ALIGN(32) -#endif - -//use this for example when you want a byte value to be better-aligned -#define FAST_ALIGN DS_ALIGN(4) - -#ifdef __MINGW32__ -#define FASTCALL __attribute__((fastcall)) -#define ASMJIT_CALL_CONV kX86FuncConvGccFastCall -#define HAVE_FASTCALL -#elif defined (__i386__) && !defined(__clang__) -#define FASTCALL __attribute__((regparm(3))) -#define ASMJIT_CALL_CONV kX86FuncConvGccRegParm3 -#define HAVE_FASTCALL -#elif defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define FASTCALL __fastcall -#define ASMJIT_CALL_CONV kX86FuncConvMsFastCall -#define HAVE_FASTCALL -#else -#define FASTCALL -#define ASMJIT_CALL_CONV kX86FuncConvDefault -//#define HAVE_FASTCALL -#endif - -#ifdef _MSC_VER -#define _CDECL_ __cdecl -#else -#define _CDECL_ -#endif - -#ifndef INLINE -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define INLINE _inline -#else -#define INLINE inline -#endif -#endif - -#ifndef FORCEINLINE -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -#define FORCEINLINE __forceinline -#define MSC_FORCEINLINE __forceinline -#else -#define FORCEINLINE inline __attribute__((always_inline)) -#define MSC_FORCEINLINE -#endif -#endif - -#ifndef NOINLINE -#ifdef __GNUC__ -#define NOINLINE __attribute__((noinline)) -#else -#define NOINLINE __declspec(noinline) -#endif -#endif - -#if defined(__LP64__) -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -typedef unsigned long long u64; - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -typedef signed long long s64; -#else -typedef unsigned char u8; -typedef unsigned short u16; -typedef unsigned int u32; -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -typedef unsigned __int64 u64; -#else -typedef unsigned long long u64; -#endif - -typedef signed char s8; -typedef signed short s16; -typedef signed int s32; -#if defined(_MSC_VER) || defined(__INTEL_COMPILER) -typedef __int64 s64; -#else -typedef signed long long s64; -#endif -#endif - -typedef u8 uint8; -typedef u16 uint16; - -#ifndef OBJ_C -typedef u32 uint32; -#else -#define uint32 u32 //uint32 is defined in Leopard somewhere, avoid conflicts -#endif - -/*---------- GPU3D fixed-points types -----------*/ - -typedef s32 f32; -#define inttof32(n) ((n) << 12) -#define f32toint(n) ((n) >> 12) -#define floattof32(n) ((int32)((n) * (1 << 12))) -#define f32tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 t16; -#define f32tot16(n) ((t16)(n >> 8)) -#define inttot16(n) ((n) << 4) -#define t16toint(n) ((n) >> 4) -#define floattot16(n) ((t16)((n) * (1 << 4))) -#define t16ofloat(n) (((float)(n)) / (float)(1<<4)) - -typedef s16 v16; -#define inttov16(n) ((n) << 12) -#define f32tov16(n) (n) -#define floattov16(n) ((v16)((n) * (1 << 12))) -#define v16toint(n) ((n) >> 12) -#define v16tofloat(n) (((float)(n)) / (float)(1<<12)) - -typedef s16 v10; -#define inttov10(n) ((n) << 9) -#define f32tov10(n) ((v10)(n >> 3)) -#define v10toint(n) ((n) >> 9) -#define floattov10(n) ((v10)((n) * (1 << 9))) -#define v10tofloat(n) (((float)(n)) / (float)(1<<9)) - -/*----------------------*/ - -#ifndef OBJ_C -typedef int BOOL; -#else -//apple also defines BOOL -typedef int desmume_BOOL; -#define BOOL desmume_BOOL -#endif - -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifdef __BIG_ENDIAN__ -#ifndef WORDS_BIGENDIAN -#define WORDS_BIGENDIAN -#endif -#endif - -#ifdef WORDS_BIGENDIAN -# define LOCAL_BE -#else -# define LOCAL_LE -#endif - -/* little endian (ds' endianess) to local endianess convert macros */ -#ifdef LOCAL_BE /* local arch is big endian */ -# define LE_TO_LOCAL_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LE_TO_LOCAL_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -# define LE_TO_LOCAL_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) -# define LOCAL_TO_LE_16(x) ((((x)&0xff)<<8)|(((x)>>8)&0xff)) -# define LOCAL_TO_LE_32(x) ((((x)&0xff)<<24)|(((x)&0xff00)<<8)|(((x)>>8)&0xff00)|(((x)>>24)&0xff)) -# define LOCAL_TO_LE_64(x) ((((x)&0xff)<<56)|(((x)&0xff00)<<40)|(((x)&0xff0000)<<24)|(((x)&0xff000000)<<8)|(((x)>>8)&0xff000000)|(((x)>>24)&0xff00)|(((x)>>40)&0xff00)|(((x)>>56)&0xff)) -#else /* local arch is little endian */ -# define LE_TO_LOCAL_16(x) (x) -# define LE_TO_LOCAL_32(x) (x) -# define LE_TO_LOCAL_64(x) (x) -# define LOCAL_TO_LE_16(x) (x) -# define LOCAL_TO_LE_32(x) (x) -# define LOCAL_TO_LE_64(x) (x) -#endif - -// kilobytes and megabytes macro -#define MB(x) ((x)*1024*1024) -#define KB(x) ((x)*1024) - -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - -#define CPU_STR(c) ((c==ARM9)?"ARM9":"ARM7") -typedef enum -{ - ARM9 = 0, - ARM7 = 1 -} cpu_id_t; - -///endian-flips count bytes. count should be even and nonzero. -inline void FlipByteOrder(u8 *src, u32 count) -{ - u8 *start=src; - u8 *end=src+count-1; - - if((count&1) || !count) return; /* This shouldn't happen. */ - - while(count--) - { - u8 tmp; - - tmp=*end; - *end=*start; - *start=tmp; - end--; - start++; - } -} - - - -inline u64 double_to_u64(double d) { - union { - u64 a; - double b; - } fuxor; - fuxor.b = d; - return fuxor.a; -} - -inline double u64_to_double(u64 u) { - union { - u64 a; - double b; - } fuxor; - fuxor.a = u; - return fuxor.b; -} - -inline u32 float_to_u32(float f) { - union { - u32 a; - float b; - } fuxor; - fuxor.b = f; - return fuxor.a; -} - -inline float u32_to_float(u32 u) { - union { - u32 a; - float b; - } fuxor; - fuxor.a = u; - return fuxor.b; -} - - -///stores a 32bit value into the provided byte array in guaranteed little endian form -inline void en32lsb(u8 *buf, u32 morp) -{ - buf[0]=(u8)(morp); - buf[1]=(u8)(morp>>8); - buf[2]=(u8)(morp>>16); - buf[3]=(u8)(morp>>24); -} - -inline void en16lsb(u8* buf, u16 morp) -{ - buf[0]=(u8)morp; - buf[1]=(u8)(morp>>8); -} - -///unpacks a 64bit little endian value from the provided byte array into host byte order -inline u64 de64lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24)|((u64)morp[4]<<32)|((u64)morp[5]<<40)|((u64)morp[6]<<48)|((u64)morp[7]<<56); -} - -///unpacks a 32bit little endian value from the provided byte array into host byte order -inline u32 de32lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8)|(morp[2]<<16)|(morp[3]<<24); -} - -///unpacks a 16bit little endian value from the provided byte array into host byte order -inline u16 de16lsb(u8 *morp) -{ - return morp[0]|(morp[1]<<8); -} - -#ifndef ARRAY_SIZE -//taken from winnt.h -extern "C++" // templates cannot be declared to have 'C' linkage -template -char (*BLAHBLAHBLAH( UNALIGNED T (&)[N] ))[N]; - -#define ARRAY_SIZE(A) (sizeof(*BLAHBLAHBLAH(A))) -#endif - - -//fairly standard for loop macros -#define MACRODO1(TRICK,TODO) { const int X = TRICK; TODO; } -#define MACRODO2(X,TODO) { MACRODO1((X),TODO) MACRODO1(((X)+1),TODO) } -#define MACRODO4(X,TODO) { MACRODO2((X),TODO) MACRODO2(((X)+2),TODO) } -#define MACRODO8(X,TODO) { MACRODO4((X),TODO) MACRODO4(((X)+4),TODO) } -#define MACRODO16(X,TODO) { MACRODO8((X),TODO) MACRODO8(((X)+8),TODO) } -#define MACRODO32(X,TODO) { MACRODO16((X),TODO) MACRODO16(((X)+16),TODO) } -#define MACRODO64(X,TODO) { MACRODO32((X),TODO) MACRODO32(((X)+32),TODO) } -#define MACRODO128(X,TODO) { MACRODO64((X),TODO) MACRODO64(((X)+64),TODO) } -#define MACRODO256(X,TODO) { MACRODO128((X),TODO) MACRODO128(((X)+128),TODO) } - -//this one lets you loop any number of times (as long as N<256) -#define MACRODO_N(N,TODO) {\ - if((N)&0x100) MACRODO256(0,TODO); \ - if((N)&0x080) MACRODO128((N)&(0x100),TODO); \ - if((N)&0x040) MACRODO64((N)&(0x100|0x080),TODO); \ - if((N)&0x020) MACRODO32((N)&(0x100|0x080|0x040),TODO); \ - if((N)&0x010) MACRODO16((N)&(0x100|0x080|0x040|0x020),TODO); \ - if((N)&0x008) MACRODO8((N)&(0x100|0x080|0x040|0x020|0x010),TODO); \ - if((N)&0x004) MACRODO4((N)&(0x100|0x080|0x040|0x020|0x010|0x008),TODO); \ - if((N)&0x002) MACRODO2((N)&(0x100|0x080|0x040|0x020|0x010|0x008|0x004),TODO); \ - if((N)&0x001) MACRODO1((N)&(0x100|0x080|0x040|0x020|0x010|0x008|0x004|0x002),TODO); \ -} - -//--------------------------- -//Binary constant generator macro By Tom Torfs - donated to the public domain - -//turn a numeric literal into a hex constant -//(avoids problems with leading zeroes) -//8-bit constants max value 0x11111111, always fits in unsigned long -#define HEX__(n) 0x##n##LU - -//8-bit conversion function -#define B8__(x) ((x&0x0000000FLU)?1:0) \ -+((x&0x000000F0LU)?2:0) \ -+((x&0x00000F00LU)?4:0) \ -+((x&0x0000F000LU)?8:0) \ -+((x&0x000F0000LU)?16:0) \ -+((x&0x00F00000LU)?32:0) \ -+((x&0x0F000000LU)?64:0) \ -+((x&0xF0000000LU)?128:0) - -//for upto 8-bit binary constants -#define B8(d) ((unsigned char)B8__(HEX__(d))) - -// for upto 16-bit binary constants, MSB first -#define B16(dmsb,dlsb) (((unsigned short)B8(dmsb)<<8) \ -+ B8(dlsb)) - -// for upto 32-bit binary constants, MSB first */ -#define B32(dmsb,db2,db3,dlsb) (((unsigned long)B8(dmsb)<<24) \ -+ ((unsigned long)B8(db2)<<16) \ -+ ((unsigned long)B8(db3)<<8) \ -+ B8(dlsb)) - -//Sample usage: -//B8(01010101) = 85 -//B16(10101010,01010101) = 43605 -//B32(10000000,11111111,10101010,01010101) = 2164238933 -//--------------------------- - -#ifndef CTASSERT -#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1] -#endif - -static const char hexValid[23] = {"0123456789ABCDEFabcdef"}; - - -template inline void reconstruct(T* t) { - t->~T(); - new(t) T(); -} - -//-------------fixed point speedup macros - -#ifdef _WIN32 -#include -#endif - -FORCEINLINE s64 fx32_mul(const s32 a, const s32 b) -{ -#ifdef _WIN32 - return __emul(a,b); -#else - return ((s64)a)*((s64)b); -#endif -} - -FORCEINLINE s32 fx32_shiftdown(const s64 a) -{ -#ifdef _WIN32 - return (s32)__ll_rshift(a,12); -#else - return (s32)(a>>12); -#endif -} - -FORCEINLINE s64 fx32_shiftup(const s32 a) -{ -#ifdef _WIN32 - return __ll_lshift(a,12); -#else - return ((s64)a)<<12; -#endif -} - -#endif diff --git a/inds/zh-Hans.lproj/Localizable.strings b/inds/zh-Hans.lproj/Localizable.strings deleted file mode 100755 index 8debba3..0000000 --- a/inds/zh-Hans.lproj/Localizable.strings +++ /dev/null @@ -1,49 +0,0 @@ -ROM_LIST = "ROM列表"; -ABOUT_INDS = "关于iNDS"; -SETTINGS = "设置"; -DONATE = "捐助"; - -SHARE = "分享"; - -EMULATOR_CORE_CODE = "特别感谢"; - -EMULATOR = "模拟器设置"; -CONTROLS = "控制设置"; -DEVELOPER = "开发设置"; -EXPERIMENTAL = "实验设置"; - -OVERLAY_PIXEL_GRID_DETAIL = "像素网格会使画面看上去更清晰,但是黑色的网格会降低一半的亮度。"; -ENABLE_DROPBOX_DETAIL = "启用Dropbox将会在您的Dropbox帐户里增加一个“iNDS”文件夹。您的游戏存档将会保存到该文件夹,它会进行跨设备同步。(iPhone、iPad、iPod touch、Android、PC)。"; -ARMLJIT_DETAIL = "GNU Lighting JIT将让游戏运行得更快。您必须越狱您的iOS设备,否则iNDS会崩溃。"; - -AUTO = "自动"; -DPAD = "方向键"; -JOYSTICK = "摇杆"; -TOP = "顶部"; -BOTTOM = "底部"; - -FRAME_SKIP = "跳帧"; -DISABLE_SOUND = "禁用声音"; -OVERLAY_PIXEL_GRID = "显示网格"; - -CONTROL_PAD_STYLE = "控制类型"; -CONTROL_POSITION_PORTRAIT = "按键位置"; -CONTROL_OPACITY_PORTRAIT = "按键透明度"; - -ENABLE_DROPBOX = "开启Dropbox同步"; -NOT_LINKED = "未连接"; -LINKED = "已连接"; -UNLINKED = "连接断开!"; -UNLINKED_DETAIL = "Dropbox 的连接已经断开。已保存的文件将停止同步。"; -SUCCESS = "成功!"; -SUCCESS_DETAIL = "Dropbox 连接成功! iNDS 将会把已保存的文件同步到Dropbox 根目录里的文件夹“iNDS”中。"; -DROPBOX_CFG_ERROR = "Dropbox配置错误"; - -SHOW_FPS = "显示FPS"; -VIBRATION = "振动"; - -LAUNCH_GAME = "加载游戏"; -LAUNCH_GAME_DETAIL = "正常开始游戏"; -RESUME_AUTOSAVE = "从自动存档中继续游戏"; - -ARMLJIT = "GNU Lightning JIT"; \ No newline at end of file