The Memory card editor for Mac OS X should be up and running now.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@72644 e17a0e51-4ae3-4d35-97c3-1a29b211df97
This commit is contained in:
parent
ef5d0defe9
commit
232c3563b4
|
@ -59,3 +59,6 @@
|
|||
"Delete Block" = "Delete Block";
|
||||
"Deleting a block will remove all saved data on that block.\n\nThis cannot be undone." = "Deleting a block will remove all saved data on that block.\n\nThis cannot be undone.";
|
||||
"Delete" = "Delete";
|
||||
"No Free Space" = "No Free Space";
|
||||
"Memory card %d doesn't have a free block on it. Please remove some blocks on that card to continue" = "Memory card %d doesn't have a free block on it. Please remove some blocks on that card to continue";
|
||||
"Okay" = "Okay";
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="589069415"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:687</string>
|
||||
<int key="NSTag">1</int>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="786361046">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
|
@ -98,6 +99,7 @@
|
|||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="3271293"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:687</string>
|
||||
<int key="NSTag">2</int>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="55938044">
|
||||
<int key="NSCellFlags">67239424</int>
|
||||
|
@ -362,7 +364,6 @@
|
|||
<string key="NSFrame">{{362, 25}, {93, 32}}</string>
|
||||
<reference key="NSSuperview" ref="1006"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:687</string>
|
||||
<int key="NSTag">2</int>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
|
@ -474,7 +475,6 @@
|
|||
<string key="NSFrame">{{0, 16}, {181, 17}}</string>
|
||||
<reference key="NSSuperview" ref="729211047"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:3944</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="459126093">
|
||||
|
@ -579,22 +579,6 @@
|
|||
<object class="IBObjectContainer" key="IBDocument.Objects">
|
||||
<object class="NSMutableArray" key="connectionRecords">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">moveToLeft:</string>
|
||||
<reference key="source" ref="1001"/>
|
||||
<reference key="destination" ref="146799775"/>
|
||||
</object>
|
||||
<int key="connectionID">11</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">moveToRight:</string>
|
||||
<reference key="source" ref="1001"/>
|
||||
<reference key="destination" ref="589069415"/>
|
||||
</object>
|
||||
<int key="connectionID">12</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">leftMove</string>
|
||||
|
@ -667,6 +651,22 @@
|
|||
</object>
|
||||
<int key="connectionID">73</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">moveBlock:</string>
|
||||
<reference key="source" ref="1001"/>
|
||||
<reference key="destination" ref="146799775"/>
|
||||
</object>
|
||||
<int key="connectionID">76</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">moveBlock:</string>
|
||||
<reference key="source" ref="1001"/>
|
||||
<reference key="destination" ref="589069415"/>
|
||||
</object>
|
||||
<int key="connectionID">77</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">itemPrototype</string>
|
||||
|
@ -1192,7 +1192,7 @@
|
|||
<reference key="dict.values" ref="1002"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">75</int>
|
||||
<int key="maxID">77</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -1206,15 +1206,13 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>deleteMemoryObject:</string>
|
||||
<string>formatCard:</string>
|
||||
<string>moveToLeft:</string>
|
||||
<string>moveToRight:</string>
|
||||
<string>moveBlock:</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
|
@ -1223,8 +1221,7 @@
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>deleteMemoryObject:</string>
|
||||
<string>formatCard:</string>
|
||||
<string>moveToLeft:</string>
|
||||
<string>moveToRight:</string>
|
||||
<string>moveBlock:</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -1237,11 +1234,7 @@
|
|||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">moveToLeft:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
<object class="IBActionInfo">
|
||||
<string key="name">moveToRight:</string>
|
||||
<string key="name">moveBlock:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</object>
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
NSMutableArray *memCard2Array;
|
||||
}
|
||||
|
||||
- (IBAction)moveToLeft:(id)sender;
|
||||
- (IBAction)moveToRight:(id)sender;
|
||||
- (IBAction)moveBlock:(id)sender;
|
||||
- (IBAction)formatCard:(id)sender;
|
||||
- (IBAction)deleteMemoryObject:(id)sender;
|
||||
- (void)loadMemoryCardInfoForCard:(int)theCard;
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
#define MAX_MEMCARD_BLOCKS 15
|
||||
|
||||
static inline NSImage *imageFromMcd(short * icon)
|
||||
static NSImage *imageFromMcd(short * icon)
|
||||
{
|
||||
NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:16 pixelsHigh:16 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
|
||||
|
||||
|
@ -49,6 +49,13 @@ static inline NSImage *imageFromMcd(short * icon)
|
|||
return [theImage autorelease];
|
||||
}
|
||||
|
||||
static inline void CopyMemcardData(char *from, char *to, int *i, char *str, int copy) {
|
||||
memcpy(to + (*i + 1) * 128, from + (copy + 1) * 128, 128);
|
||||
SaveMcd(str, to, (*i + 1) * 128, 128);
|
||||
memcpy(to + (*i + 1) * 1024 * 8, from + (copy + 1) * 1024 * 8, 1024 * 8);
|
||||
SaveMcd(str, to, (*i + 1) * 1024 * 8, 1024 * 8);
|
||||
}
|
||||
|
||||
@implementation PcsxrMemCardController
|
||||
|
||||
//memCard1Array KVO functions
|
||||
|
@ -125,11 +132,11 @@ static inline NSImage *imageFromMcd(short * icon)
|
|||
for (i = 0; i < MAX_MEMCARD_BLOCKS; i++) {
|
||||
GetMcdBlockInfo(theCard, i, &info);
|
||||
PcsxrMemoryObject *ob = [[PcsxrMemoryObject alloc] init];
|
||||
NSString *engDes = nil, *japDes = nil;
|
||||
ob.englishName = [NSString stringWithCString:info.Title encoding:NSASCIIStringEncoding];
|
||||
ob.sjisName = [NSString stringWithCString:info.sTitle encoding:NSShiftJISStringEncoding];
|
||||
ob.memImage = imageFromMcd(info.Icon);
|
||||
ob.memNumber = i;
|
||||
ob.memFlags = info.Flags;
|
||||
[newArray insertObject:ob atIndex:i];
|
||||
[ob release];
|
||||
}
|
||||
|
@ -150,14 +157,91 @@ static inline NSImage *imageFromMcd(short * icon)
|
|||
[self loadMemoryCardInfoForCard:2];
|
||||
}
|
||||
|
||||
- (IBAction)moveToLeft:(id)sender
|
||||
- (int)findFreeMemCardSlot:(int)target_card
|
||||
{
|
||||
BOOL found = NO;
|
||||
NSString *blockName;
|
||||
NSArray *cardArray;
|
||||
if (target_card == 1) {
|
||||
cardArray = [self memCard1Array];
|
||||
}else {
|
||||
cardArray = [self memCard2Array];
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
while (i < 15 && found == NO) {
|
||||
blockName = [[cardArray objectAtIndex:i] englishName];
|
||||
if ([blockName isEqualToString:@""]) {
|
||||
found = YES;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (found == YES)
|
||||
return i;
|
||||
|
||||
// no free slots, try to find a deleted one
|
||||
i = 0;
|
||||
while (i < 15 && found == NO) {
|
||||
unsigned char flags = [[cardArray objectAtIndex:i] memFlags];
|
||||
if ((flags & 0xF0) != 0x50) {
|
||||
found = YES;
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (found == YES)
|
||||
return i;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
- (IBAction)moveToRight:(id)sender
|
||||
- (IBAction)moveBlock:(id)sender
|
||||
{
|
||||
NSInteger memCardSelect = [sender tag];
|
||||
NSCollectionView *cardView;
|
||||
NSIndexSet *selection;
|
||||
int toCard, fromCard, freeSlot;
|
||||
char *str, *source, *destination;
|
||||
if (memCardSelect == 1) {
|
||||
str = Config.Mcd1;
|
||||
source = Mcd2Data;
|
||||
destination = Mcd1Data;
|
||||
cardView = memCard2view;
|
||||
toCard = 1;
|
||||
fromCard = 2;
|
||||
} else {
|
||||
str = Config.Mcd2;
|
||||
source = Mcd1Data;
|
||||
destination = Mcd2Data;
|
||||
cardView = memCard1view;
|
||||
toCard = 2;
|
||||
fromCard = 1;
|
||||
}
|
||||
selection = [cardView selectionIndexes];
|
||||
if (!selection || [selection count] == 0) {
|
||||
NSBeep();
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger selectedIndex = [selection firstIndex];
|
||||
|
||||
freeSlot = [self findFreeMemCardSlot:toCard];
|
||||
if (freeSlot == -1) {
|
||||
NSRunCriticalAlertPanel(NSLocalizedString(@"No Free Space", nil), [NSString stringWithFormat:NSLocalizedString(@"Memory card %d doesn't have a free block on it. Please remove some blocks on that card to continue", nil), toCard], NSLocalizedString(@"Okay", nil), nil, nil);
|
||||
return;
|
||||
}
|
||||
|
||||
CopyMemcardData(source, destination, &freeSlot, str, selectedIndex);
|
||||
|
||||
|
||||
|
||||
if (toCard == 1) {
|
||||
LoadMcd(1, Config.Mcd1);
|
||||
} else {
|
||||
LoadMcd(2, Config.Mcd2);
|
||||
}
|
||||
[self loadMemoryCardInfoForCard:toCard];
|
||||
}
|
||||
|
||||
- (IBAction)formatCard:(id)sender
|
||||
|
@ -167,25 +251,83 @@ static inline NSImage *imageFromMcd(short * icon)
|
|||
NSInteger memCardSelect = [sender tag];
|
||||
if (memCardSelect == 1) {
|
||||
CreateMcd(Config.Mcd1);
|
||||
LoadMcd(1, Config.Mcd1);
|
||||
[self loadMemoryCardInfoForCard:1];
|
||||
} else {
|
||||
CreateMcd(Config.Mcd2);
|
||||
LoadMcd(2, Config.Mcd2);
|
||||
[self loadMemoryCardInfoForCard:2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)deleteMemoryObjectAtSlot:(int)slotnum card:(int)cardNum
|
||||
{
|
||||
int xor = 0, i, j;
|
||||
char *data, *ptr, *filename;
|
||||
NSArray *cardArray;
|
||||
PcsxrMemoryObject *memObject;
|
||||
if (cardNum == 1) {
|
||||
filename = Config.Mcd1;
|
||||
data = Mcd1Data;
|
||||
cardArray = [self memCard1Array];
|
||||
} else {
|
||||
filename = Config.Mcd2;
|
||||
data = Mcd2Data;
|
||||
cardArray = [self memCard2Array];
|
||||
}
|
||||
memObject = [cardArray objectAtIndex:slotnum];
|
||||
unsigned char flags = [memObject memFlags];
|
||||
i = slotnum;
|
||||
i++;
|
||||
ptr = data + i * 128;
|
||||
|
||||
if ((flags & 0xF0) == 0xA0) {
|
||||
if ((flags & 0xF) >= 1 &&
|
||||
(flags & 0xF) <= 3) { // deleted
|
||||
*ptr = 0x50 | (flags & 0xF);
|
||||
} else return;
|
||||
} else if ((flags & 0xF0) == 0x50) { // used
|
||||
*ptr = 0xA0 | (flags & 0xF);
|
||||
} else { return; }
|
||||
|
||||
for (j = 0; j < 127; j++) xor ^= *ptr++;
|
||||
*ptr = xor;
|
||||
|
||||
SaveMcd(filename, data, i * 128, 128);
|
||||
|
||||
}
|
||||
|
||||
- (IBAction)deleteMemoryObject:(id)sender {
|
||||
NSInteger deleteOkay = NSRunAlertPanel(NSLocalizedString(@"Delete Block", nil), NSLocalizedString(@"Deleting a block will remove all saved data on that block.\n\nThis cannot be undone.", nil), NSLocalizedString(@"Cancel", nil), NSLocalizedString(@"Delete", nil), nil);
|
||||
if (deleteOkay == NSAlertAlternateReturn) {
|
||||
NSInteger memCardSelect = [sender tag];
|
||||
NSIndexSet *selected;
|
||||
NSArray *cardArray;
|
||||
if (memCardSelect == 1) {
|
||||
selected = [memCard1view selectionIndexes];
|
||||
cardArray = [self memCard1Array];
|
||||
} else {
|
||||
selected = [memCard2view selectionIndexes];
|
||||
cardArray = [self memCard2Array];
|
||||
}
|
||||
|
||||
if (!selected || [selected count] == 0) {
|
||||
NSBeep();
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger selectedIndex = [selected firstIndex];
|
||||
[self deleteMemoryObjectAtSlot:selectedIndex card:memCardSelect];
|
||||
|
||||
if (memCardSelect == 1) {
|
||||
LoadMcd(1, Config.Mcd1);
|
||||
[self loadMemoryCardInfoForCard:1];
|
||||
} else {
|
||||
|
||||
LoadMcd(2, Config.Mcd2);
|
||||
[self loadMemoryCardInfoForCard:2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <AppKit/NSImage.h>
|
||||
|
||||
@interface PcsxrMemoryObject : NSObject
|
||||
{
|
||||
|
@ -14,12 +15,14 @@
|
|||
NSString *sjisName;
|
||||
NSImage *memImage;
|
||||
short memNumber;
|
||||
unsigned char memFlags;
|
||||
}
|
||||
|
||||
@property(copy, readwrite) NSString * englishName;
|
||||
@property(copy, readwrite) NSString * sjisName;
|
||||
@property(retain, readwrite) NSImage * memImage;
|
||||
@property(readwrite) short memNumber;
|
||||
@property(readwrite) unsigned char memFlags;
|
||||
|
||||
|
||||
@end
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
@synthesize sjisName;
|
||||
@synthesize memImage;
|
||||
@synthesize memNumber;
|
||||
@synthesize memFlags;
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue