aboutsummaryrefslogtreecommitdiff
path: root/macosx/plugins/DFCdrom/macsrc
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/plugins/DFCdrom/macsrc')
-rw-r--r--macosx/plugins/DFCdrom/macsrc/PluginConfigController.h18
-rw-r--r--macosx/plugins/DFCdrom/macsrc/PluginConfigController.m158
-rw-r--r--macosx/plugins/DFCdrom/macsrc/cdr-macosx.c250
-rw-r--r--macosx/plugins/DFCdrom/macsrc/cfg.c53
4 files changed, 0 insertions, 479 deletions
diff --git a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.h b/macosx/plugins/DFCdrom/macsrc/PluginConfigController.h
deleted file mode 100644
index b7f6faf..0000000
--- a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.h
+++ /dev/null
@@ -1,18 +0,0 @@
-#define PluginConfigController DFCdromPluginConfigController
-
-#import <Cocoa/Cocoa.h>
-
-@interface PluginConfigController : NSWindowController
-{
- IBOutlet NSControl *Cached;
- IBOutlet NSSlider *CacheSize;
- IBOutlet NSPopUpButton *CdSpeed;
-
- NSMutableDictionary *keyValues;
-}
-- (IBAction)cancel:(id)sender;
-- (IBAction)ok:(id)sender;
-
-- (void)loadValues;
-
-@end
diff --git a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m b/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m
deleted file mode 100644
index 02b3a76..0000000
--- a/macosx/plugins/DFCdrom/macsrc/PluginConfigController.m
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program 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 program 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 this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#import "PluginConfigController.h"
-#include "cdr.h"
-
-#define APP_ID @"net.pcsx.DFCdrom"
-#define PrefsKey APP_ID @" Settings"
-
-static PluginConfigController *windowController;
-
-void AboutDlgProc()
-{
- // Get parent application instance
- NSApplication *app = [NSApplication sharedApplication];
- NSBundle *bundle = [NSBundle bundleWithIdentifier:APP_ID];
-
- // Get Credits.rtf
- NSString *path = [bundle pathForResource:@"Credits" ofType:@"rtf"];
- NSAttributedString *credits;
- if (path) {
- credits = [[[NSAttributedString alloc] initWithPath: path
- documentAttributes:NULL] autorelease];
- } else {
- credits = [[[NSAttributedString alloc] initWithString:@""] autorelease];
- }
-
- // Get Application Icon
- NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[bundle bundlePath]];
- NSSize size = NSMakeSize(64, 64);
- [icon setSize:size];
-
- [app orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys:
- [bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
- icon, @"ApplicationIcon",
- [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
- [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], @"Version",
- [bundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
- credits, @"Credits",
- nil]];
-}
-
-void ConfDlgProc()
-{
- NSWindow *window;
-
- if (windowController == nil) {
- windowController = [[PluginConfigController alloc] initWithWindowNibName:@"DFCdromPluginConfig"];
- }
- window = [windowController window];
-
- [windowController loadValues];
-
- [window center];
- [window makeKeyAndOrderFront:nil];
-}
-
-void ReadConfig()
-{
- NSDictionary *keyValues;
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
- [[NSMutableDictionary alloc] initWithObjectsAndKeys:
- [NSNumber numberWithBool:YES], @"Threaded",
- [NSNumber numberWithInt:64], @"Cache Size",
- [NSNumber numberWithInt:0], @"Speed",
- nil], PrefsKey, nil]];
-
- keyValues = [defaults dictionaryForKey:PrefsKey];
-
- ReadMode = ([[keyValues objectForKey:@"Threaded"] boolValue] ? THREADED : NORMAL);
- CacheSize = [[keyValues objectForKey:@"Cache Size"] intValue];
- CdrSpeed = [[keyValues objectForKey:@"Speed"] intValue];
-}
-
-@implementation PluginConfigController
-
-- (IBAction)cancel:(id)sender
-{
- [self close];
-}
-
-- (IBAction)ok:(id)sender
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
- NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues];
-
- [writeDic setObject:[NSNumber numberWithInt:[Cached intValue]] forKey:@"Threaded"];
- [writeDic setObject:[NSNumber numberWithInt:[CacheSize intValue]] forKey:@"Cache Size"];
-
- switch ([CdSpeed indexOfSelectedItem]) {
- case 1: [writeDic setObject:[NSNumber numberWithInt:1] forKey:@"Speed"]; break;
- case 2: [writeDic setObject:[NSNumber numberWithInt:2] forKey:@"Speed"]; break;
- case 3: [writeDic setObject:[NSNumber numberWithInt:4] forKey:@"Speed"]; break;
- case 4: [writeDic setObject:[NSNumber numberWithInt:8] forKey:@"Speed"]; break;
- case 5: [writeDic setObject:[NSNumber numberWithInt:16] forKey:@"Speed"]; break;
- case 6: [writeDic setObject:[NSNumber numberWithInt:32] forKey:@"Speed"]; break;
- default: [writeDic setObject:[NSNumber numberWithInt:0] forKey:@"Speed"]; break;
- }
-
- // write to defaults
- [defaults setObject:writeDic forKey:PrefsKey];
- [defaults synchronize];
-
- // and set global values accordingly
- ReadConfig();
-
- [self close];
-}
-
-- (void)loadValues
-{
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
-
- ReadConfig();
-
- // load from preferences
- [keyValues release];
- keyValues = [[defaults dictionaryForKey:PrefsKey] retain];
-
- [Cached setIntValue:[[keyValues objectForKey:@"Threaded"] intValue]];
- [CacheSize setIntValue:[[keyValues objectForKey:@"Cache Size"] intValue]];
-
- switch ([[keyValues objectForKey:@"Speed"] intValue]) {
- case 1: [CdSpeed selectItemAtIndex:1]; break;
- case 2: [CdSpeed selectItemAtIndex:2]; break;
- case 4: [CdSpeed selectItemAtIndex:3]; break;
- case 8: [CdSpeed selectItemAtIndex:4]; break;
- case 16: [CdSpeed selectItemAtIndex:5]; break;
- case 32: [CdSpeed selectItemAtIndex:6]; break;
- default: [CdSpeed selectItemAtIndex:0]; break;
- }
-}
-
-- (void)awakeFromNib
-{
-}
-
-@end
diff --git a/macosx/plugins/DFCdrom/macsrc/cdr-macosx.c b/macosx/plugins/DFCdrom/macsrc/cdr-macosx.c
deleted file mode 100644
index 806b659..0000000
--- a/macosx/plugins/DFCdrom/macsrc/cdr-macosx.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program 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 program 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 this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-#ifdef _MACOSX
-
-#include <IOKit/IOKitLib.h>
-#include <IOKit/IOBSD.h>
-#include <IOKit/storage/IOCDMedia.h>
-#include <IOKit/storage/IODVDMedia.h>
-#include <IOKit/storage/IOMedia.h>
-#include <IOKit/storage/IOCDMediaBSDClient.h>
-#include <CoreFoundation/CoreFoundation.h>
-
-int cdHandle = -1;
-char cdDevice[4096] = "";
-
-static int IsPsxDisc(const char *dev) {
- int fd;
- char buf[CD_FRAMESIZE_RAW];
- dk_cd_read_t r;
-
- fd = open(dev, O_RDONLY, 0);
- if (fd < 0) return 0;
-
- memset(&r, 0, sizeof(r));
-
- r.offset = msf_to_lba(0, 2, 4) * CD_FRAMESIZE_RAW;
- r.sectorArea = 0xF8;
- r.sectorType = kCDSectorTypeUnknown;
- r.bufferLength = CD_FRAMESIZE_RAW;
- r.buffer = buf;
-
- if (ioctl(fd, DKIOCCDREAD, &r) != kIOReturnSuccess) {
- close(fd);
- return 0;
- }
-
- close(fd);
-
- if (strncmp(buf + 56, "Sony Computer Entertainment", 27) == 0) {
- return 1;
- }
-
- return 0;
-}
-
-static void FindCdDevice(char *dev) {
- io_object_t next_media;
- kern_return_t kern_result;
- io_iterator_t media_iterator;
- CFMutableDictionaryRef classes_to_match;
- const char *name, *cd = kIOCDMediaClass, *dvd = kIODVDMediaClass;
-
- dev[0] = '\0';
- name = cd;
-
-start:
- classes_to_match = IOServiceMatching(name);
- if (classes_to_match == NULL) goto end;
-
- CFDictionarySetValue(classes_to_match, CFSTR(kIOMediaEjectableKey),
- kCFBooleanTrue);
-
- kern_result = IOServiceGetMatchingServices(kIOMasterPortDefault,
- classes_to_match, &media_iterator);
-
- if (kern_result != KERN_SUCCESS) goto end;
-
- next_media = IOIteratorNext(media_iterator);
- if (next_media != 0) {
- char psz_buf[0x32];
- size_t dev_path_length;
- CFTypeRef str_bsd_path;
-
- do {
- str_bsd_path = IORegistryEntryCreateCFProperty(next_media,
- CFSTR(kIOBSDNameKey), kCFAllocatorDefault, 0);
-
- if (str_bsd_path == NULL) {
- IOObjectRelease(next_media);
- continue;
- }
-
- strcpy(psz_buf, "/dev/r");
- dev_path_length = strlen(psz_buf);
-
- if (CFStringGetCString(str_bsd_path, (char *)&psz_buf + dev_path_length,
- sizeof(psz_buf) - dev_path_length, kCFStringEncodingASCII))
- {
- strcpy(dev, psz_buf);
-
- if (IsPsxDisc(dev)) {
- CFRelease(str_bsd_path);
- IOObjectRelease(next_media);
- IOObjectRelease(media_iterator);
- return;
- }
- }
-
- CFRelease(str_bsd_path);
- IOObjectRelease(next_media);
- } while ((next_media = IOIteratorNext(media_iterator)) != 0);
- }
-
- IOObjectRelease(media_iterator);
-
-end:
- if (dev[0] == '\0') {
- if (name == cd) {
- name = dvd; // Is this really necessary or correct? Dunno...
- goto start;
- }
- }
-}
-
-int OpenCdHandle(const char *dev) {
- if (dev != NULL && dev[0] != '\0') strcpy(cdDevice, dev);
- else if (cdDevice[0] == '\0') FindCdDevice(cdDevice);
-
- cdHandle = open(cdDevice, O_RDONLY, 0);
- if (cdHandle < 0) return -1;
-
- if (CdrSpeed > 0) {
- u_int16_t speed = kCDSpeedMin * CdrSpeed;
- ioctl(cdHandle, DKIOCCDSETSPEED, &speed);
- }
-
- return 0;
-}
-
-void CloseCdHandle() {
- if (cdHandle != -1) close(cdHandle);
- cdHandle = -1;
-}
-
-int IsCdHandleOpen() {
- return 1;
-}
-
-long GetTN(unsigned char *buffer) {
- if (cdHandle < 0) return -1;
-
- // TODO
- buffer[0] = 1;
- buffer[1] = 1;
-
- return 0;
-}
-
-long GetTD(unsigned char track, unsigned char *buffer) {
- if (cdHandle < 0) return -1;
-
- // TODO
- memset(buffer + 1, 0, 3);
- return 0;
-}
-
-long GetTE(unsigned char track, unsigned char *m, unsigned char *s, unsigned char *f) {
- return -1; // TODO
-}
-
-long ReadSector(crdata *cr) {
- int lba;
- dk_cd_read_t r;
-
- if (cdHandle < 0) return -1;
-
- lba = msf_to_lba(cr->msf.cdmsf_min0, cr->msf.cdmsf_sec0, cr->msf.cdmsf_frame0);
-
- memset(&r, 0, sizeof(r));
-
- r.offset = lba * CD_FRAMESIZE_RAW;
- r.sectorArea = 0xF8;
- r.sectorType = kCDSectorTypeUnknown;
- r.bufferLength = CD_FRAMESIZE_RAW;
- r.buffer = cr->buf;
-
- if (ioctl(cdHandle, DKIOCCDREAD, &r) != kIOReturnSuccess) {
- return -1;
- }
-
- return 0;
-}
-
-long PlayCDDA(unsigned char *sector) {
- return 0; // TODO
-}
-
-long StopCDDA() {
- return 0; // TODO
-}
-
-long GetStatus(int playing, struct CdrStat *stat) {
- memset(stat, 0, sizeof(struct CdrStat));
- stat->Type = 0x01;
-
- // Close and reopen the CD handle. If opening failed,
- // then there is no CD in drive.
- // Note that this WILL be screwed if user inserted another
- // removable device such as USB stick when tray is open.
- // There may be a better way, but this should do the job.
- if (cdHandle >= 0) {
- close(cdHandle);
- cdHandle = -1;
- }
-
- cdHandle = open(cdDevice, O_RDONLY, 0);
- if (cdHandle < 0) {
- // No CD in drive
- stat->Type = 0xff;
- stat->Status |= 0x10;
- } else {
- if (CdrSpeed > 0) {
- u_int16_t speed = kCDSpeedMin * CdrSpeed;
- ioctl(cdHandle, DKIOCCDSETSPEED, &speed);
- }
- }
-
- return 0;
-}
-
-unsigned char *ReadSub(const unsigned char *time) {
- return NULL; // TODO
-}
-
-char *CDRgetDriveLetter(void) {
- return cdDevice;
-}
-
-#endif
diff --git a/macosx/plugins/DFCdrom/macsrc/cfg.c b/macosx/plugins/DFCdrom/macsrc/cfg.c
deleted file mode 100644
index 6b5c151..0000000
--- a/macosx/plugins/DFCdrom/macsrc/cfg.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>.
- * All Rights Reserved.
- *
- * Based on: Cdrom for Psemu Pro like Emulators
- * By: linuzappz <linuzappz@hotmail.com>
- *
- * This program 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 program 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 this program; if not, see <http://www.gnu.org/licenses>.
- */
-
-#include "cdr.h"
-
-void AboutDlgProc();
-void ConfDlgProc();
-void ReadConfig();
-
-char CdromDev[256];
-long ReadMode;
-long UseSubQ;
-long CacheSize;
-long CdrSpeed;
-long SpinDown;
-
-void LoadConf() {
- strcpy(CdromDev, "");
- ReadMode = THREADED;
- UseSubQ = 0;
- CacheSize = 64;
- CdrSpeed = 0;
- SpinDown = SPINDOWN_VENDOR_SPECIFIC;
-
- ReadConfig();
-}
-
-long CDRconfigure() {
- ConfDlgProc();
- return 0;
-}
-
-void CDRabout() {
- AboutDlgProc();
-} \ No newline at end of file