summaryrefslogtreecommitdiff
path: root/macosx/PcsxrMemoryObject.m
diff options
context:
space:
mode:
authorSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-06-25 22:50:14 +0000
committerSND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97>2013-06-25 22:50:14 +0000
commit03e3c01771cd7c1b502f5b79b902123fbee96d02 (patch)
treec75207320cadfd8b6b5b7c17bc294f50653cec7f /macosx/PcsxrMemoryObject.m
parent6c9a81db199b7c6f86cc28d14255ab81d25a0f58 (diff)
downloadpcsxr-03e3c01771cd7c1b502f5b79b902123fbee96d02.tar.gz
Implement creating and selecting memory cards in the memory card manager.
Get rid of imageFromMcd:index: and move the code to imagesFromMcd:. git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85555 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PcsxrMemoryObject.m')
-rwxr-xr-xmacosx/PcsxrMemoryObject.m52
1 files changed, 25 insertions, 27 deletions
diff --git a/macosx/PcsxrMemoryObject.m b/macosx/PcsxrMemoryObject.m
index 16989b67..3b0818c8 100755
--- a/macosx/PcsxrMemoryObject.m
+++ b/macosx/PcsxrMemoryObject.m
@@ -34,11 +34,33 @@ NSString *const memoryAnimateTimerKey = @"PCSXR Memory Card Image Animate";
{
NSMutableArray *imagesArray = [[NSMutableArray alloc] initWithCapacity:block->IconCount];
for (int i = 0; i < block->IconCount; i++) {
- [imagesArray addObject:[self imageFromMcd:block index:i]];
+ NSImage *memImage = nil;
+ {
+ NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:16 pixelsHigh:16 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
+
+ short *icon = block->Icon;
+
+ int x, y, c, v, r, g, b;
+ for (v = 0; v < 256; v++) {
+ x = (v % 16);
+ y = (v / 16);
+ c = icon[(i * 256) + v];
+ r = (c & 0x001f) << 3;
+ g = ((c & 0x03e0) >> 5) << 3;
+ b = ((c & 0x7c00) >> 10) << 3;
+ [imageRep setColor:[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] atX:x y:y];
+ }
+ memImage = [[NSImage alloc] init];
+ [memImage addRepresentation:imageRep];
+ RELEASEOBJ(imageRep);
+ [memImage setSize:NSMakeSize(32, 32)];
+ }
+ [imagesArray addObject:memImage];
+ RELEASEOBJ(memImage);
}
- NSArray *retArray = [[NSArray alloc] initWithArray:imagesArray];
+ NSArray *retArray = [NSArray arrayWithArray:imagesArray];
RELEASEOBJ(imagesArray);
- return AUTORELEASEOBJ(retArray);
+ return retArray;
}
+ (NSImage *)blankImage
@@ -51,34 +73,10 @@ NSString *const memoryAnimateTimerKey = @"PCSXR Memory Card Image Animate";
[[NSColor blackColor] set];
[NSBezierPath fillRect:imageRect];
[imageBlank unlockFocus];
-
}
return imageBlank;
}
-+ (NSImage *)imageFromMcd:(McdBlock *)block index:(int)idx
-{
- NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:16 pixelsHigh:16 bitsPerSample:8 samplesPerPixel:3 hasAlpha:NO isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace bytesPerRow:0 bitsPerPixel:0];
-
- short *icon = block->Icon;
-
- int x, y, c, i, r, g, b;
- for (i = 0; i < 256 * (idx + 1); i++) {
- x = (i % 16);
- y = (i / 16);
- c = icon[(idx * 256) + i];
- r = (c & 0x001f) << 3;
- g = ((c & 0x03e0) >> 5) << 3;
- b = ((c & 0x7c00) >> 10) << 3;
- [imageRep setColor:[NSColor colorWithCalibratedRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0] atX:x y:y];
- }
- NSImage *theImage = [[NSImage alloc] init];
- [theImage addRepresentation:imageRep];
- RELEASEOBJ(imageRep);
- [theImage setSize:NSMakeSize(32, 32)];
- return AUTORELEASEOBJ(theImage);
-}
-
- (id)initWithMcdBlock:(McdBlock *)infoBlock
{
if (self = [super init]) {