OS X: Begin work on the memory card QuickLook.
Disable the memory card QuickLook parts: it can wait for another day. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@91006 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
994de0b66c
commit
743106ec0b
|
@ -2,9 +2,10 @@
|
|||
#include <CoreServices/CoreServices.h>
|
||||
#include <QuickLook/QuickLook.h>
|
||||
#include "MyQuickLook.h"
|
||||
#include <zlib.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#include "nopic.h"
|
||||
//#include <zlib.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
//#include "nopic.h"
|
||||
#import "PSXMemEnumerator.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
Generate a preview for file
|
||||
|
@ -39,6 +40,7 @@ void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
|
|||
|
||||
OSStatus GeneratePreviewForFreeze(void *thisInterface, QLPreviewRequestRef preview, NSURL *url, NSDictionary *options)
|
||||
{
|
||||
#if 0
|
||||
NSData *data;
|
||||
gzFile f;
|
||||
const char* state_filename;
|
||||
|
@ -74,9 +76,13 @@ OSStatus GeneratePreviewForFreeze(void *thisInterface, QLPreviewRequestRef previ
|
|||
}
|
||||
free(pMem);
|
||||
return noErr;
|
||||
#else
|
||||
return unimpErr;
|
||||
#endif
|
||||
}
|
||||
|
||||
static OSStatus GeneratePreviewForMemCard(void *thisInterface, QLPreviewRequestRef preview, NSURL *url, NSDictionary *options)
|
||||
{
|
||||
NSArray *memCards = CreateArrayByEnumeratingMemoryCardAtURL(url);
|
||||
return unimpErr;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
#include <CoreServices/CoreServices.h>
|
||||
#include <QuickLook/QuickLook.h>
|
||||
#include "MyQuickLook.h"
|
||||
#include <zlib.h>
|
||||
//#include <zlib.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#include "nopic.h"
|
||||
//#include "nopic.h"
|
||||
#import "PSXMemEnumerator.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
Generate a thumbnail for file
|
||||
|
@ -40,6 +41,7 @@ void CancelThumbnailGeneration(void *thisInterface, QLThumbnailRequestRef thumbn
|
|||
|
||||
OSStatus GenerateThumbnailForFreeze(void *thisInterface, QLThumbnailRequestRef thumbnail, NSURL *url, NSDictionary *options, CGSize maxSize)
|
||||
{
|
||||
#if 0
|
||||
gzFile f;
|
||||
const char* state_filename = NULL;
|
||||
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:96 pixelsHigh:128 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
|
||||
|
@ -85,9 +87,13 @@ OSStatus GenerateThumbnailForFreeze(void *thisInterface, QLThumbnailRequestRef t
|
|||
QLThumbnailRequestSetImageWithData(thumbnail, (__bridge CFDataRef)(data), NULL);
|
||||
}
|
||||
return noErr;
|
||||
#else
|
||||
return unimpErr;
|
||||
#endif
|
||||
}
|
||||
|
||||
OSStatus GenerateThumbnailForMemCard(void *thisInterface, QLThumbnailRequestRef thumbnail, NSURL *url, NSDictionary *options, CGSize maxSize)
|
||||
{
|
||||
//NSArray *memCards = CreateArrayByEnumeratingMemoryCardAtURL(url);
|
||||
return unimpErr;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
//
|
||||
// PSXMemEnumerator.h
|
||||
// Pcsxr
|
||||
//
|
||||
// Created by C.W. Betts on 7/20/14.
|
||||
//
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "PcsxrMemoryObject.h"
|
||||
#include "MyQuickLook.h"
|
||||
|
||||
__private_extern NSArray *CreateArrayByEnumeratingMemoryCardAtURL(NSURL *location) NS_RETURNS_RETAINED;
|
|
@ -0,0 +1,179 @@
|
|||
//
|
||||
// PSXMemEnumerator.c
|
||||
// Pcsxr
|
||||
//
|
||||
// Created by C.W. Betts on 7/20/14.
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#import "PSXMemEnumerator.h"
|
||||
|
||||
#define MAX_MEMCARD_BLOCKS 15
|
||||
|
||||
static void GetSoloBlockInfo(unsigned char *data, int block, McdBlock *Info)
|
||||
{
|
||||
unsigned char *ptr = data + block * 8192 + 2;
|
||||
unsigned char *str = Info->Title;
|
||||
unsigned short clut[16];
|
||||
unsigned char * sstr = Info->sTitle;
|
||||
unsigned short c;
|
||||
int i, x = 0;
|
||||
|
||||
memset(Info, 0, sizeof(McdBlock));
|
||||
Info->IconCount = *ptr & 0x3;
|
||||
ptr += 2;
|
||||
|
||||
for (i = 0; i < 48; i++) {
|
||||
c = *(ptr) << 8;
|
||||
c |= *(ptr + 1);
|
||||
if (!c)
|
||||
break;
|
||||
|
||||
// Convert ASCII characters to half-width
|
||||
if (c >= 0x8281 && c <= 0x829A) {
|
||||
c = (c - 0x8281) + 'a';
|
||||
} else if (c >= 0x824F && c <= 0x827A) {
|
||||
c = (c - 0x824F) + '0';
|
||||
} else if (c == 0x8140) {
|
||||
c = ' ';
|
||||
} else if (c == 0x8143) {
|
||||
c = ',';
|
||||
} else if (c == 0x8144) {
|
||||
c = '.';
|
||||
} else if (c == 0x8146) {
|
||||
c = ':';
|
||||
} else if (c == 0x8147) {
|
||||
c = ';';
|
||||
} else if (c == 0x8148) {
|
||||
c = '?';
|
||||
} else if (c == 0x8149) {
|
||||
c = '!';
|
||||
} else if (c == 0x815E) {
|
||||
c = '/';
|
||||
} else if (c == 0x8168) {
|
||||
c = '"';
|
||||
} else if (c == 0x8169) {
|
||||
c = '(';
|
||||
} else if (c == 0x816A) {
|
||||
c = ')';
|
||||
} else if (c == 0x816D) {
|
||||
c = '[';
|
||||
} else if (c == 0x816E) {
|
||||
c = ']';
|
||||
} else if (c == 0x817C) {
|
||||
c = '-';
|
||||
} else {
|
||||
str[i] = ' ';
|
||||
sstr[x++] = *ptr++;
|
||||
sstr[x++] = *ptr++;
|
||||
continue;
|
||||
}
|
||||
|
||||
str[i] = sstr[x++] = c;
|
||||
ptr += 2;
|
||||
}
|
||||
|
||||
ptr = data + block * 8192 + 0x60; // icon palette data
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
clut[i] = *((unsigned short *)ptr);
|
||||
ptr += 2;
|
||||
}
|
||||
|
||||
for (i = 0; i < Info->IconCount; i++) {
|
||||
short *icon = &Info->Icon[i * 16 * 16];
|
||||
|
||||
ptr = data + block * 8192 + 128 + 128 * i; // icon data
|
||||
|
||||
for (x = 0; x < 16 * 16; x++) {
|
||||
icon[x++] = clut[*ptr & 0xf];
|
||||
icon[x] = clut[*ptr >> 4];
|
||||
ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
ptr = data + block * 128;
|
||||
|
||||
Info->Flags = *ptr;
|
||||
|
||||
ptr += 0xa;
|
||||
strlcpy(Info->ID, ptr, 12);
|
||||
ptr += 12;
|
||||
strlcpy(Info->Name, ptr, 16);
|
||||
}
|
||||
|
||||
static inline PCSXRMemFlags MemBlockFlag(unsigned char blockFlags)
|
||||
{
|
||||
if ((blockFlags & 0xF0) == 0xA0) {
|
||||
if ((blockFlags & 0xF) >= 1 && (blockFlags & 0xF) <= 3)
|
||||
return memFlagDeleted;
|
||||
else
|
||||
return memFlagFree;
|
||||
} else if ((blockFlags & 0xF0) == 0x50) {
|
||||
if ((blockFlags & 0xF) == 0x1)
|
||||
return memFlagUsed;
|
||||
else if ((blockFlags & 0xF) == 0x2)
|
||||
return memFlagLink;
|
||||
else if ((blockFlags & 0xF) == 0x3)
|
||||
return memFlagEndLink;
|
||||
} else
|
||||
return memFlagFree;
|
||||
|
||||
//Xcode complains unless we do this...
|
||||
//NSLog(@"Unknown flag %x", blockFlags);
|
||||
return memFlagFree;
|
||||
}
|
||||
|
||||
|
||||
NSArray *CreateArrayByEnumeratingMemoryCardAtURL(NSURL *location)
|
||||
{
|
||||
NSMutableArray *memArray = [[NSMutableArray alloc] initWithCapacity:MAX_MEMCARD_BLOCKS];
|
||||
if (!location) {
|
||||
return nil;
|
||||
}
|
||||
NSData *fileData = [[NSData alloc] initWithContentsOfURL:location options:NSDataReadingMappedIfSafe error:NULL];
|
||||
if (!fileData) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
const unsigned char *memPtr = [fileData bytes];
|
||||
if ([fileData length] == MCD_SIZE + 64)
|
||||
memPtr += 64;
|
||||
else if([fileData length] == MCD_SIZE + 3904)
|
||||
memPtr += 3904;
|
||||
else if ([fileData length] != MCD_SIZE)
|
||||
return nil;
|
||||
|
||||
int i = 0, x;
|
||||
while (i < MAX_MEMCARD_BLOCKS) {
|
||||
x = 1;
|
||||
McdBlock memBlock;
|
||||
GetSoloBlockInfo((unsigned char *)memPtr, i + 1, &memBlock);
|
||||
|
||||
if (MemBlockFlag(memBlock.Flags) == memFlagFree) {
|
||||
//Free space: ignore
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
do {
|
||||
McdBlock tmpBlock;
|
||||
GetSoloBlockInfo((unsigned char *)memPtr, i + x + 1, &tmpBlock);
|
||||
if ((tmpBlock.Flags & 0x3) == 0x3) {
|
||||
x++;
|
||||
break;
|
||||
} else if ((tmpBlock.Flags & 0x2) == 0x2) {
|
||||
x++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} while (i + x - 1 < MAX_MEMCARD_BLOCKS);
|
||||
@autoreleasepool {
|
||||
PcsxrMemoryObject *obj = [[PcsxrMemoryObject alloc] initWithMcdBlock:&memBlock startingIndex:i size:x];
|
||||
[memArray addObject:obj];
|
||||
}
|
||||
i += x;
|
||||
}
|
||||
|
||||
return [[NSArray alloc] initWithArray:memArray];
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
<string>QLGenerator</string>
|
||||
<key>LSItemContentTypes</key>
|
||||
<array>
|
||||
<string>com.codeplex.pcsxr.freeze</string>
|
||||
<string>com.codeplex.pcsxr.memcard</string>
|
||||
</array>
|
||||
</dict>
|
||||
</array>
|
||||
|
|
|
@ -4,11 +4,9 @@
|
|||
// The contents of this file are implicitly included at the beginning of every source file.
|
||||
//
|
||||
|
||||
#include <CoreFoundation/CoreFoundation.h>
|
||||
#include <CoreFoundation/CFPlugInCOM.h>
|
||||
#include <CoreServices/CoreServices.h>
|
||||
#include <QuickLook/QuickLook.h>
|
||||
#include "MyQuickLook.h"
|
||||
|
||||
#ifdef __OBJC__
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "PcsxrMemoryObject.h"
|
||||
#endif
|
||||
|
|
|
@ -194,6 +194,8 @@
|
|||
554FD70C17C6A1F10056CF66 /* SDL2.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 554FD70817C6A13E0056CF66 /* SDL2.framework */; };
|
||||
55534AF518183BFB006D6BCB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 55534AF418183BFB006D6BCB /* main.m */; };
|
||||
5557769A17EBE7D60019D008 /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 5557769917EBE7D60019D008 /* Media.xcassets */; };
|
||||
556C37A9197C815C001A4265 /* PSXMemEnumerator.m in Sources */ = {isa = PBXBuildFile; fileRef = 556C37A8197C815C001A4265 /* PSXMemEnumerator.m */; };
|
||||
556C37AB197C9C59001A4265 /* PcsxrMemoryObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 55A90228147D89380037E18F /* PcsxrMemoryObject.m */; };
|
||||
5581463917AABCD100862DBF /* PcsxrCheatHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 5581463817AABCD100862DBF /* PcsxrCheatHandler.m */; };
|
||||
559366CA12B694DF004ACC1E /* iR3000A-64.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C112B694DF004ACC1E /* iR3000A-64.c */; };
|
||||
559366CB12B694DF004ACC1E /* ix86-64.c in Sources */ = {isa = PBXBuildFile; fileRef = 559366C212B694DF004ACC1E /* ix86-64.c */; };
|
||||
|
@ -212,6 +214,7 @@
|
|||
55C7A214148B2B3800C22ABC /* PcsxrMemCard.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55C7A216148B2B3800C22ABC /* PcsxrMemCard.xib */; };
|
||||
55CA586B17E799E6007424D5 /* DiskArbitration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55CA586A17E799E6007424D5 /* DiskArbitration.framework */; };
|
||||
55DA3723189440C800B44951 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 551A76B2178693EA0052D185 /* CoreFoundation.framework */; };
|
||||
55DFBAAF197B8CCD00620084 /* Pcsxr-QL.qlgenerator in Copy QuickLook Plug-In */ = {isa = PBXBuildFile; fileRef = 550E343718E6293D00A1AD21 /* Pcsxr-QL.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
55E0ACE0178B69620005C945 /* LaunchArg.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E0ACDF178B69600005C945 /* LaunchArg.m */; };
|
||||
55E15994184564D4007983CB /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55E15993184564D4007983CB /* GLKit.framework */; };
|
||||
55E15996184567D5007983CB /* GL2Code.m in Sources */ = {isa = PBXBuildFile; fileRef = 55E15995184567D5007983CB /* GL2Code.m */; };
|
||||
|
@ -403,6 +406,7 @@
|
|||
dstPath = Contents/Library/QuickLook;
|
||||
dstSubfolderSpec = 1;
|
||||
files = (
|
||||
55DFBAAF197B8CCD00620084 /* Pcsxr-QL.qlgenerator in Copy QuickLook Plug-In */,
|
||||
);
|
||||
name = "Copy QuickLook Plug-In";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -734,6 +738,8 @@
|
|||
5569B0BD182F0BCE00991C9C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/DFNet.strings; sourceTree = "<group>"; };
|
||||
5569B0BF182F0BD500991C9C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/SockDialog.strings; sourceTree = "<group>"; };
|
||||
5569B0C1182F0BE100991C9C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/NetPcsxrHIDInputPluginMain.strings; sourceTree = "<group>"; };
|
||||
556C37A8197C815C001A4265 /* PSXMemEnumerator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PSXMemEnumerator.m; sourceTree = "<group>"; };
|
||||
556C37AA197C81F9001A4265 /* PSXMemEnumerator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PSXMemEnumerator.h; sourceTree = "<group>"; };
|
||||
55707E8E18123579007CC5D0 /* hu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
55707E901812357B007CC5D0 /* hu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
55707E921812357D007CC5D0 /* hu */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = hu; path = hu.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
|
@ -1171,6 +1177,8 @@
|
|||
550E344318E6293D00A1AD21 /* GenerateThumbnailForURL.m */,
|
||||
550E344518E6293D00A1AD21 /* GeneratePreviewForURL.m */,
|
||||
550E344718E6293D00A1AD21 /* main.c */,
|
||||
556C37AA197C81F9001A4265 /* PSXMemEnumerator.h */,
|
||||
556C37A8197C815C001A4265 /* PSXMemEnumerator.m */,
|
||||
550E343E18E6293D00A1AD21 /* Supporting Files */,
|
||||
);
|
||||
path = "Pcsxr-QL";
|
||||
|
@ -2344,7 +2352,9 @@
|
|||
files = (
|
||||
550E344418E6293D00A1AD21 /* GenerateThumbnailForURL.m in Sources */,
|
||||
550E344618E6293D00A1AD21 /* GeneratePreviewForURL.m in Sources */,
|
||||
556C37AB197C9C59001A4265 /* PcsxrMemoryObject.m in Sources */,
|
||||
550E344818E6293D00A1AD21 /* main.c in Sources */,
|
||||
556C37A9197C815C001A4265 /* PSXMemEnumerator.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue