Added compile fixes for Mmc (ie changed __fastcall's to FASTCALL macro, hopefully doesn't break other builds). Did a bunch of all around cleanups for the Cocoa port. Also added code-level support for multiple key bindings for ds buttons, and caps independance for key bindings based on that.

This commit is contained in:
gecko_reverse 2008-08-07 08:49:09 +00:00
parent 178efa543a
commit 9bca9c442f
20 changed files with 573 additions and 588 deletions

View File

@ -17,6 +17,7 @@
- Added French translation (thanks to Pierre Rudloff). [Jeff]
- Added basic key mapping configuration to application preferences (thanks to Julio GorgŽ). [Jeff]
- Added keyboard shortcuts for Execute, Pause and Reset command (thanks to Julio GorgŽ). [Jeff]
- Default key mappings are no longer case sensitive. [Jeff]
Windows port:
- Removed the bug report link with a define, to avoid reports from betas/external builds [shash]
- Added the version on window bar to recognize versions from screenshots [shash]

View File

@ -6,8 +6,8 @@
1) Compiling instructions...................................13
2) How to use DeSmuME.......................................31
3) Contact information......................................78
4) Disclaimer...............................................95
3) Contact information......................................73
4) Disclaimer...............................................90
1 Compiling instructions______________________________________
@ -45,7 +45,8 @@ Linux and Windows versions.
Click the lower screen for DS touch-screen input.
Here are the default key mappings(may be subject to change):
Key mappings can be changed or viewed from the preferences
panel. Here are the defaults (may be subject to change):
up arrow - Up
left arrow - Left
down arrow - Down
@ -59,12 +60,6 @@ n - Right Trigger
enter - Start button
space - Select button
Keys can be customized with command line:
DeSmuME.app/Contents/MacOS/DeSmuME -KeyA v -KeyB b ...
KeyA, KeyB, KeyX, KeyY, KeyL, KeyR, KeyUp, KeyDown
KeyLeft, KeyRight, KeyStart, and KeySelect are all accepted.
States can be saved with shift + number keys.
States can be loaded with the number keys.

View File

@ -22,6 +22,7 @@
*/
#include "FIFO.h"
#include <string.h>
void FIFOInit(FIFO * fifo)
{

View File

@ -174,7 +174,7 @@ void MMU_Init(void) {
int i;
LOG("MMU init\n");
printlog("MMU init\n");
//printlog("MMU init\n");
memset(&MMU, 0, sizeof(MMU_struct));

View File

@ -137,8 +137,8 @@
729BECEF0D9D581900ED561B /* AudioUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioUnit.framework; path = /System/Library/Frameworks/AudioUnit.framework; sourceTree = "<absolute>"; };
729BECF80D9D589E00ED561B /* OGLRender.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = OGLRender.c; path = ../windows/OGLRender.c; sourceTree = SOURCE_ROOT; };
729BECF90D9D589E00ED561B /* OGLRender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OGLRender.h; path = ../windows/OGLRender.h; sourceTree = SOURCE_ROOT; };
72C000010D9D59E60046B7EA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; };
72C000020D9D59E60046B7EA /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = SOURCE_ROOT; };
72C000010D9D59E60046B7EA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
72C000020D9D59E60046B7EA /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = InfoPlist.strings; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* DeSmuME.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DeSmuME.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@ -156,7 +156,7 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
080E96DDFE201D6D7F000001 /* Classes */ = {
080E96DDFE201D6D7F000001 /* Cocoa Port */ = {
isa = PBXGroup;
children = (
7277B8EA0D9F25F700D283BD /* about.m */,
@ -180,7 +180,7 @@
729BEC6E0D9D55DB00ED561B /* video_output_view.m */,
729BEC6D0D9D55DB00ED561B /* video_output_view.h */,
);
name = Classes;
name = "Cocoa Port";
sourceTree = "<group>";
};
1058C7A0FEA54F0111CA2CBB /* Linked Frameworks */ = {
@ -211,12 +211,10 @@
29B97314FDCFA39411CA2CEA /* DeSmuME */ = {
isa = PBXGroup;
children = (
72C000010D9D59E60046B7EA /* Info.plist */,
72C000020D9D59E60046B7EA /* InfoPlist.strings */,
729BECEF0D9D581900ED561B /* AudioUnit.framework */,
729BECE60D9D57F600ED561B /* OpenGL.framework */,
080E96DDFE201D6D7F000001 /* Classes */,
29B97315FDCFA39411CA2CEA /* Other Sources */,
080E96DDFE201D6D7F000001 /* Cocoa Port */,
29B97315FDCFA39411CA2CEA /* Core */,
29B97317FDCFA39411CA2CEA /* Resources */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
@ -224,7 +222,7 @@
name = DeSmuME;
sourceTree = "<group>";
};
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
29B97315FDCFA39411CA2CEA /* Core */ = {
isa = PBXGroup;
children = (
729BECF80D9D589E00ED561B /* OGLRender.c */,
@ -280,12 +278,14 @@
729BECCA0D9D57AF00ED561B /* wifi.c */,
729BECCB0D9D57AF00ED561B /* wifi.h */,
);
name = "Other Sources";
name = Core;
sourceTree = "<group>";
};
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
72C000010D9D59E60046B7EA /* Info.plist */,
72C000020D9D59E60046B7EA /* InfoPlist.strings */,
726D68AA0E310B1800800002 /* French.nib */,
726D68AB0E310B1800800002 /* French.strings */,
7277B6DF0D9E045700D283BD /* English.nib */,

Binary file not shown.

View File

@ -1,10 +1,18 @@
/* DeSmuME Strings File */
/* FRENCH */
/* General */
"DeSmuME Emulator" = "DeSmuME Emulator";
/* Menu Headers */
"File" = "Fichier";
"Emulation" = "Emulation";
"View" = "Présentation";
"Sound" = "Son";
"Window" = "Fenêtre";
"Help" = "Aide";
/* File Menu */
"Open ROM..." = "Ouvrir une ROM...";
"Open Recent" = "Fichiers récents";
"ROM Info..." = "Informations sur la ROM...";
@ -14,6 +22,8 @@
"Load State" = "Charger l'état";
"Close ROM" = "Fermer la ROM";
"Slot %d" = "Slot %d";
/* Emulation Menu */
"Execute" = "Exécuter";
"Pause" = "Pause";
"Reset" = "Réinitialiser";
@ -22,6 +32,8 @@
"Off" = "Off";
"Skip %d" = "%d";
"Set FAT Image File..." = "Définir le fichier d'image FAT...";
/* View Menu */
"Size 1x" = "Taille 1x";
"Size 2x" = "Taille 2x";
"Size 3x" = "Taille 3x";
@ -45,12 +57,20 @@
"Sub BG2" = "Sub BG2";
"Sub BG3" = "Sub BG3";
"Save Screenshot..." = "Enregistrer une capture d'écran...";
/* Sound Menu */
"Volume" = "Volume";
"Volume %d" = "%d%";
"Mute" = "Muet";
/* Window Menu */
/* Help Menu */
"Go to Website" = "Aller sur le site web";
"Go to Forums" = "Aller sur les forums";
"Submit a Bug Report" = "Envoyer un rapport de bug";
/* About panel */
"DeSmuME" = "DeSmuME";
"Nintendo DS Emulator" = "Emulateur Nintendo DS";
"Version %@" = "Version %@";
@ -58,18 +78,52 @@
"License" = "Licence";
"Authors" = "Auteurs";
"Change Log" = "Change Log";
/* Dialogs */
"Are you sure you want to quit?" = "Etes vous su de vouloir quitter ?";
"Are you sure you want to close the ROM?" = "Etes vous sur de vouloir fermer la ROM ?";
/* Status Bar Messages */
"No ROM Loaded" = "Aucune ROM chargée";
"Executing" = "Exécution";
"Paused" = "En pause";
/* Preferences Window */
"DeSmuME Preferences" = "Préférences de DeSmuME";
"Interface" = "Interface";
"Controls" = "Contrôles";
"DS Firmware" = "DS Firmware";
"Yes" = "Oui";
"No" = "Non";
/* Interface Preferences */
"Execute Upon Load" = "Exécuter après le chargement";
//"When Launching, Load" = ?;
//"Load Nothing" = ?;
//"Load Last ROM" = ?;
/* Control Preferences */
//"A Button" = ?;
//"B Button" = ?;
//"X Button" = ?;
//"Y Button" = ?;
//"L Button" = ?;
//"R Button" = ?;
//"Up Button" = ?;
//"Down Button" = ?;
//"Left Button" = ?;
//"Right Button" = ?;
//"Start Button" = ?;
//"Select Button" = ?;
//"Up Key" = ?;
//"Down Key" = ?;
//"Left Key" = ?;
//"Right Key" = ?;
//"Space Bar" = ?;
//"Enter Key" = ?;
/* ROM Info */
"ROM File" = "Fichier";
"ROM Title" = "Titre";
"ROM Maker" = "Maker";
@ -78,6 +132,8 @@
"ARM7 Size" = "ARM7 Size";
"Data Size" = "Taille des données";
"ROM Icon" = "Icône de la ROM";
/* Screenshots */
"Save Screenshot to File..." = "Enregistrer une capture d'écran dans un fichier...";
"Select Image Format: " = "Sélectionner le format d'image :";
"Pick by Extension" = "Choisir par extension";
@ -86,12 +142,17 @@
"JPG" = "JPG";
"PNG" = "PNG";
"TIFF" = "TIFF";
/* Status Bar */
"No ROM loaded" = "Aucune ROM chargée";
"ROM Loaded" = "ROM chargée";
"Emulation Executing" = "Exécution";
"Emulation Paused" = "En pause";
"Emulation Reset" = "Réinitialiser";
/* Save States */
"Save State..." = "Enregistrer l'état...";
"Are you sure you want to clear all save slots?" = "Etes vous sur de vouloir effacer toutes les sauvegardes ?";
/* Errors */
"Error" = "Erreur";
"An emulation error occured" = "Une erreur d'émulation est survenue";

Binary file not shown.

View File

@ -24,11 +24,6 @@
//Dialog Boxes-------------------------------------------------
////////////////////////////////////////////////////////////////
void messageDialogBlank()
{
NSRunAlertPanel(@"Click OK", @" ", nil/*OK*/, nil, nil);
}
void messageDialog(NSString *title, NSString *text)
{
NSRunAlertPanel(title, text, nil/*OK*/, nil, nil);
@ -36,7 +31,7 @@ void messageDialog(NSString *title, NSString *text)
BOOL messageDialogYN(NSString *title, NSString *text)
{
return NSRunAlertPanel(title, text, @"Yes", @"No", nil) != 0;
return NSRunAlertPanel(title, text, NSLocalizedString(@"Yes", nil), NSLocalizedString(@"No", nil), nil) != 0;
}
//does an open dialog to choose an NDS file

View File

@ -19,7 +19,6 @@
#import <Cocoa/Cocoa.h>
void messageDialogBlank();
void messageDialog(NSString *title, NSString *text);
BOOL messageDialogYN(NSString *title, NSString *text);
NSString* openDialog(NSArray *file_types);

View File

@ -32,7 +32,8 @@
VideoOutputWindow *my_ds;
}
//preferences
+ (NSView*)createPreferencesView:(NSRect)size;
+ (NSView*)createPreferencesView:(float)width;
+ (NSDictionary*)appDefaults;
//creation/deletion
- (id)initWithWindow:(VideoOutputWindow*)nds;

View File

@ -21,14 +21,135 @@
#import "main_window.h"
#import "preferences.h"
@implementation InputHandler
unsigned char utf8_return = 0x0D;
unsigned char utf8_right[3] = { 0xEF, 0x9C, 0x83 };
unsigned char utf8_up[3] = { 0xEF, 0x9C, 0x80 };
unsigned char utf8_down[3] = { 0xEF, 0x9C, 0x81 };
unsigned char utf8_left[3] = { 0xEF, 0x9C, 0x82 };
+ (NSView*)createPreferencesView:(NSRect)size
@interface ControlsDelegate : NSObject {}
+ (id)sharedObject;
@end
inline int testKey(NSString *chars_pressed, NSString *chars_for_key)
{
return nil; //to be implemented someday
//Checks for common characters in chars_pressed and chars_for_key
unichar *buffer1 = malloc([chars_pressed length] * sizeof(unichar));
unichar *buffer2 = malloc([chars_for_key length] * sizeof(unichar));
if(!buffer1 || !buffer2)return 0;
[chars_pressed getCharacters:buffer1];
[chars_for_key getCharacters:buffer2];
int i1, i2;
for(i1 = 0; i1 < [chars_pressed length]; i1++)
for(i2 = 0; i2 < [chars_for_key length]; i2++)
if(buffer1[i1] == buffer2[i2])
{
free(buffer1);
free(buffer2);
return 1;
}
free(buffer1);
free(buffer2);
return 0;
}
//
@implementation ControlsDelegate
+ (id)sharedObject
{
static ControlsDelegate* object = nil;
if(!object)object = [[ControlsDelegate alloc] init];
return object;
}
- (void)bindingForKeyA:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_A]; }
- (void)bindingForKeyB:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_B]; }
- (void)bindingForKeyX:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_X]; }
- (void)bindingForKeyY:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_Y]; }
- (void)bindingForKeyL:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_L]; }
- (void)bindingForKeyR:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_R]; }
- (void)bindingForKeyUp:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_UP]; }
- (void)bindingForKeyDown:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_DOWN]; }
- (void)bindingForKeyLeft:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_LEFT]; }
- (void)bindingForKeyRight:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_RIGHT]; }
- (void)bindingForKeyStart:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_START]; }
- (void)bindingForKeySelect:(id)sender { [[NSUserDefaults standardUserDefaults] setValue:[[sender selectedItem] representedObject] forKey:PREF_KEY_SELECT]; }
@end
//
@implementation InputHandler
//Class functions ---------------------------------
+ (NSView*)createPreferencesView:(float)width
{
NSArray *keys = [NSArray arrayWithObjects:
@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9",
@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L",
@"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"V", @"W", @"X", @"Y", @"Z",
@"Up Key" , @"Down Key" , @"Left Key" ,
@"Right Key", @"Space Bar", @"Enter Key",
nil];
NSArray *objects = [NSArray arrayWithObjects:
@"0" , @"1" , @"2" , @"3" , @"4" , @"5" , @"6" , @"7" , @"8" , @"9",
@"aA", @"bB", @"cC", @"dD", @"eE", @"fF", @"gG", @"hH", @"iI", @"jJ", @"kK", @"lL",
@"mM", @"nN", @"oO", @"pP", @"qQ", @"rR", @"sS", @"tT", @"vV", @"wW", @"xX", @"yY", @"zZ",
[[[NSString alloc] initWithBytesNoCopy:utf8_up length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_down length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_left length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_right length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
@" ",
[[[NSString alloc] initWithBytesNoCopy:&utf8_return length:1 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
nil];
NSDictionary *keyboardMap = [[NSDictionary alloc] initWithObjects:objects forKeys:keys];
NSDictionary *controls_options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyA:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_A,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyB:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_B,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyX:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_X,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyY:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_Y,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyL:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_L,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyR:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_R,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyUp:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_UP,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyDown:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_DOWN,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyLeft:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_RIGHT,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyRight:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_RIGHT,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyStart:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_START,
[NSArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeySelect:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_SELECT,
nil];
return createPreferencesView(@"Use the popup buttons on the right to change settings", controls_options, [ControlsDelegate sharedObject]);
}
+ (NSDictionary*)appDefaults
{
return [NSDictionary dictionaryWithObjectsAndKeys:
@"vV", PREF_KEY_A,
@"bB", PREF_KEY_B,
@"gG", PREF_KEY_X,
@"hH", PREF_KEY_Y,
@"cC", PREF_KEY_L,
@"nN", PREF_KEY_R,
@" ", PREF_KEY_SELECT,
[[[NSString alloc] initWithBytesNoCopy:utf8_up length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_UP,
[[[NSString alloc] initWithBytesNoCopy:utf8_down length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_DOWN,
[[[NSString alloc] initWithBytesNoCopy:utf8_left length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_LEFT,
[[[NSString alloc] initWithBytesNoCopy:utf8_right length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_RIGHT,
[[[NSString alloc] initWithBytesNoCopy:&utf8_return length:1 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_START,
nil];
}
//Member Functions -----------------------------------
- (id)init
{
//make sure we go through through the designated init function
@ -55,22 +176,22 @@
- (void)keyDown:(NSEvent*)event
{
if([event isARepeat])return;
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
NSString *chars = [event characters];
if([chars rangeOfString:[settings stringForKey:PREF_KEY_A ]].location!=NSNotFound)[my_ds pressA];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_B ]].location!=NSNotFound)[my_ds pressB];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_SELECT]].location!=NSNotFound)[my_ds pressSelect];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_START ]].location!=NSNotFound)[my_ds pressStart];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_RIGHT ]].location!=NSNotFound)[my_ds pressRight];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_LEFT ]].location!=NSNotFound)[my_ds pressLeft];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_UP ]].location!=NSNotFound)[my_ds pressUp];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_DOWN ]].location!=NSNotFound)[my_ds pressDown];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_R ]].location!=NSNotFound)[my_ds pressR];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_L ]].location!=NSNotFound)[my_ds pressL];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_X ]].location!=NSNotFound)[my_ds pressX];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_Y ]].location!=NSNotFound)[my_ds pressY];
if(testKey(chars, [settings stringForKey:PREF_KEY_A ]))[my_ds pressA];
else if(testKey(chars, [settings stringForKey:PREF_KEY_B ]))[my_ds pressB];
else if(testKey(chars, [settings stringForKey:PREF_KEY_SELECT]))[my_ds pressSelect];
else if(testKey(chars, [settings stringForKey:PREF_KEY_START ]))[my_ds pressStart];
else if(testKey(chars, [settings stringForKey:PREF_KEY_RIGHT ]))[my_ds pressRight];
else if(testKey(chars, [settings stringForKey:PREF_KEY_LEFT ]))[my_ds pressLeft];
else if(testKey(chars, [settings stringForKey:PREF_KEY_UP ]))[my_ds pressUp];
else if(testKey(chars, [settings stringForKey:PREF_KEY_DOWN ]))[my_ds pressDown];
else if(testKey(chars, [settings stringForKey:PREF_KEY_R ]))[my_ds pressR];
else if(testKey(chars, [settings stringForKey:PREF_KEY_L ]))[my_ds pressL];
else if(testKey(chars, [settings stringForKey:PREF_KEY_X ]))[my_ds pressX];
else if(testKey(chars, [settings stringForKey:PREF_KEY_Y ]))[my_ds pressY];
}
- (void)keyUp:(NSEvent*)event
@ -78,18 +199,18 @@
NSUserDefaults *settings = [NSUserDefaults standardUserDefaults];
NSString *chars = [event characters];
if([chars rangeOfString:[settings stringForKey:PREF_KEY_A ]].location!=NSNotFound)[my_ds liftA];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_B ]].location!=NSNotFound)[my_ds liftB];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_SELECT]].location!=NSNotFound)[my_ds liftSelect];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_START ]].location!=NSNotFound)[my_ds liftStart];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_RIGHT ]].location!=NSNotFound)[my_ds liftRight];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_LEFT ]].location!=NSNotFound)[my_ds liftLeft];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_UP ]].location!=NSNotFound)[my_ds liftUp];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_DOWN ]].location!=NSNotFound)[my_ds liftDown];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_R ]].location!=NSNotFound)[my_ds liftR];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_L ]].location!=NSNotFound)[my_ds liftL];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_X ]].location!=NSNotFound)[my_ds liftX];
else if([chars rangeOfString:[settings stringForKey:PREF_KEY_Y ]].location!=NSNotFound)[my_ds liftY];
if(testKey(chars, [settings stringForKey:PREF_KEY_A ]))[my_ds liftA];
else if(testKey(chars, [settings stringForKey:PREF_KEY_B ]))[my_ds liftB];
else if(testKey(chars, [settings stringForKey:PREF_KEY_SELECT]))[my_ds liftSelect];
else if(testKey(chars, [settings stringForKey:PREF_KEY_START ]))[my_ds liftStart];
else if(testKey(chars, [settings stringForKey:PREF_KEY_RIGHT ]))[my_ds liftRight];
else if(testKey(chars, [settings stringForKey:PREF_KEY_LEFT ]))[my_ds liftLeft];
else if(testKey(chars, [settings stringForKey:PREF_KEY_UP ]))[my_ds liftUp];
else if(testKey(chars, [settings stringForKey:PREF_KEY_DOWN ]))[my_ds liftDown];
else if(testKey(chars, [settings stringForKey:PREF_KEY_R ]))[my_ds liftR];
else if(testKey(chars, [settings stringForKey:PREF_KEY_L ]))[my_ds liftL];
else if(testKey(chars, [settings stringForKey:PREF_KEY_X ]))[my_ds liftX];
else if(testKey(chars, [settings stringForKey:PREF_KEY_Y ]))[my_ds liftY];
}
- (void)mouseDown:(NSEvent*)event

View File

@ -32,8 +32,6 @@ FIXME: .nds.gba support?
//Globals----------------------------------------------------------------------------------------
NSAutoreleasePool *autorelease;
//view (defined/managed in main_window.m)
extern NSMenuItem *resize1x;
extern NSMenuItem *resize2x;
@ -90,6 +88,7 @@ extern NSMenuItem *rom_info_item;
@interface AppDelegate : NSObject
{}
//our methods
- (void)pickROM;
@ -110,295 +109,261 @@ VideoOutputWindow *main_window;
//This generates and sets the entire menubar (and sets defaults)
void CreateMenu(AppDelegate *delegate)
{
//Grab the main menu
NSMenu *main_menu = [NSApp mainMenu];
if(main_menu == nil)return;
//
int i;
NSMenuItem *temp;
NSMenu* file;
NSMenu* emulation;
NSMenu* view;
NSMenu* sound_menu;
//NSMenu* window;
NSMenu* help;
//File Menu
temp = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu *file_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"File", nil)];
if(file_menu != nil)
{
[main_menu setSubmenu:file_menu forItem:temp];
NSMenu* frame_skip_menu;
[[file_menu addItemWithTitle:NSLocalizedString(@"Open ROM...", nil) action:@selector(pickROM) keyEquivalent:@"o"] setTarget:delegate];
NSMenu *menu = [NSApp mainMenu];
//Recent items menu
// Thanks to Jeff Johnson and the Lap Cat Software Blog for their information on the Open Recent menu in Cocoa
// http://lapcatsoftware.com/blog/
NSMenuItem *file_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *emulation_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *view_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *sound_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
//NSMenuItem *window_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenuItem *help_item = [menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
temp = [file_menu addItemWithTitle:NSLocalizedString(@"Open Recent", nil) action:nil keyEquivalent:@""];
//Create the File Menu
file = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"File", nil)];
[menu setSubmenu:file forItem:file_item];
NSMenu *recent_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Open Recent", nil)];
temp = [file addItemWithTitle:NSLocalizedString(@"Open ROM...", nil) action:@selector(pickROM) keyEquivalent:@"o"];
[temp setTarget:delegate];
if(recent_menu != nil)
{
[recent_menu performSelector:@selector(_setMenuName:) withObject:@"NSRecentDocumentsMenu"];
[temp setSubmenu:recent_menu];
//recent items menu
/* Thanks to Jeff Johnson and the Lap Cat Software Blog for their information on the Open Recent menu in Cocoa*/
/* http://lapcatsoftware.com/blog/ */
[[recent_menu addItemWithTitle:@"Clear Menu" action:@selector(clearRecentDocuments:) keyEquivalent:@""] setTarget:[NSDocumentController sharedDocumentController]];
temp = [file addItemWithTitle:NSLocalizedString(@"Open Recent", nil) action:nil keyEquivalent:@""];
[recent_menu release];
}
[file_menu addItem:[NSMenuItem separatorItem]];
//All the recent documents menu stuff is managed by Cocoa
NSMenu *recent_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Open Recent", nil)];
[recent_menu performSelector:@selector(_setMenuName:) withObject:@"NSRecentDocumentsMenu"];
[temp setSubmenu:recent_menu];
temp = [recent_menu addItemWithTitle:@"Clear Menu" action:@selector(clearRecentDocuments:) keyEquivalent:@""];
[temp setTarget:[NSDocumentController sharedDocumentController]];
[recent_menu release];
[file addItem:[NSMenuItem separatorItem]];
rom_info_item = [file addItemWithTitle:NSLocalizedString(@"ROM Info...", nil) action:@selector(showRomInfo) keyEquivalent:@""];
rom_info_item = [file_menu addItemWithTitle:NSLocalizedString(@"ROM Info...", nil) action:@selector(showRomInfo) keyEquivalent:@""];
#ifdef HAVE_LIBZ //internally, save states only work when zlib is there
[file_menu addItem:[NSMenuItem separatorItem]];
[file addItem:[NSMenuItem separatorItem]];
[save_state_as_item = [file_menu addItemWithTitle:NSLocalizedString(@"Save State As...", nil) action:@selector(saveStateAs) keyEquivalent:@""] setEnabled:NO];
save_state_as_item = [file addItemWithTitle:NSLocalizedString(@"Save State As...", nil) action:@selector(saveStateAs) keyEquivalent:@""];
[save_state_as_item setEnabled:NO];
[load_state_from_item = [file_menu addItemWithTitle:NSLocalizedString(@"Load State From...", nil) action:@selector(loadStateFrom) keyEquivalent:@""] setEnabled:NO];
load_state_from_item = [file addItemWithTitle:NSLocalizedString(@"Load State From...", nil) action:@selector(loadStateFrom) keyEquivalent:@""];
[load_state_from_item setEnabled:NO];
[file_menu addItem:[NSMenuItem separatorItem]];
[file addItem:[NSMenuItem separatorItem]];
//Save state menu
temp = [file addItemWithTitle:NSLocalizedString(@"Save State", nil) action:nil keyEquivalent:@""];
NSMenu *save_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Save State", nil)];
[temp setSubmenu:save_state_menu];
[save_state_as_item setEnabled:NO];
temp = [file_menu addItemWithTitle:NSLocalizedString(@"Save State", nil) action:nil keyEquivalent:@""];
temp = [file addItemWithTitle:NSLocalizedString(@"Load State", nil) action:nil keyEquivalent:@""];
NSMenu *load_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Load State", nil)];
[temp setSubmenu:load_state_menu];
NSMenu *save_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Save State", nil)];
if(save_state_menu != nil)
{
[temp setSubmenu:save_state_menu];
for(i = 0; i < SAVE_SLOTS; i++)
{
saveSlot_item[i] = [save_state_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Slot %d", nil), i+1] action:@selector(saveToSlot:) keyEquivalent:[NSString stringWithFormat:@"%d", i<9?i+1:0]];
[saveSlot_item[i] setKeyEquivalentModifierMask:NSShiftKeyMask];
for(i = 0; i < SAVE_SLOTS; i++)
{
saveSlot_item[i] = [save_state_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Slot %d", nil), i+1] action:@selector(saveToSlot:) keyEquivalent:[NSString stringWithFormat:@"%d", i<9?i+1:0]];
[saveSlot_item[i] setKeyEquivalentModifierMask:NSShiftKeyMask];
}
[save_state_menu release];
}
loadSlot_item[i] = [load_state_menu addItemWithTitle:[saveSlot_item[i] title] action:@selector(loadFromSlot:) keyEquivalent:[NSString stringWithFormat:@"%d", i<9?i+1:0]];
[loadSlot_item[i] setKeyEquivalentModifierMask:0];
}
//Load state menu
/* To be implemented when saves.h provides
a way to get the time of a save that's not string/human formatted...
temp = [file_menu addItemWithTitle:NSLocalizedString(@"Load State", nil) action:nil keyEquivalent:@""];
NSMenu *load_state_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Load State", nil)];
if(load_state_menu != nil)
{
[temp setSubmenu:load_state_menu];
[save_state_menu addItem:[NSMenuItem separatorItem]];
for(i = 0; i < SAVE_SLOTS; i++)
{
loadSlot_item[i] = [load_state_menu addItemWithTitle:[saveSlot_item[i] title] action:@selector(loadFromSlot:) keyEquivalent:[NSString stringWithFormat:@"%d", i<9?i+1:0]];
[loadSlot_item[i] setKeyEquivalentModifierMask:0];
}
[load_state_menu release];
}
temp = [save_state_menu addItemWithTitle:@"Save Over Oldest" action:nil keyEquivalent:@""];
temp = [save_state_menu addItemWithTitle:@"Save Over Latest" action:nil keyEquivalent:@""];
*/
/* to be implemented after saves.h provides a way to delete saves...
[save_state_menu addItem:[NSMenuItem separatorItem]];
clear_all_saves_item = [save_state_menu addItemWithTitle:@"Clear Menu" action:@selector(askAndClearStates) keyEquivalent:@""];
*/
/*
[save_state_menu addItem:[NSMenuItem separatorItem]];
temp = [save_state_menu addItemWithTitle:NSLocalizedString(@"View States", nil) action:nil keyEquivalent:@""];
*/
/* To be implemented when saves.h provides
a way to get the time of a save that's not a string / human formatted...
[load_state_menu addItem:[NSMenuItem separatorItem]];
temp = [load_state_menu addItemWithTitle:@"Load Oldest" action:nil keyEquivalent:@""];
temp = [load_state_menu addItemWithTitle:@"Load Latest" action:nil keyEquivalent:@""];
*/
/*
[load_state_menu addItem:[NSMenuItem separatorItem]];
temp = [load_state_menu addItemWithTitle:@"View States" action:nil keyEquivalent:@""];
*/
[save_state_menu release];
[load_state_menu release];
#else
for(i = 0; i < SAVE_SLOTS; i++)
{
saveSlot_item[i] = nil;
loadSlot_item[i] = nil;
}
#endif
[file addItem:[NSMenuItem separatorItem]];
[file_menu addItem:[NSMenuItem separatorItem]];
close_rom_item = [file addItemWithTitle:NSLocalizedString(@"Close ROM", nil) action:@selector(askAndCloseROM) keyEquivalent:@"w"];
close_rom_item = [file_menu addItemWithTitle:NSLocalizedString(@"Close ROM", nil) action:@selector(askAndCloseROM) keyEquivalent:@"w"];
[file release];
//Create the Emulation Menu
emulation = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Emulation", nil)];
[menu setSubmenu:emulation forItem:emulation_item];
execute_item = [emulation addItemWithTitle:NSLocalizedString(@"Execute", nil) action:@selector(execute) keyEquivalent:@"e"];
pause_item = [emulation addItemWithTitle:NSLocalizedString(@"Pause", nil) action:@selector(pause) keyEquivalent:@"p"];
reset_item = [emulation addItemWithTitle:NSLocalizedString(@"Reset", nil) action:@selector(reset) keyEquivalent:@"r"];
[emulation addItem:[NSMenuItem separatorItem]];
temp = [emulation addItemWithTitle:NSLocalizedString(@"Frame Skip", nil) action:nil keyEquivalent:@""];
frame_skip_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Frame Skip", nil)];
[temp setSubmenu:frame_skip_menu];
frame_skip_auto_item = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Auto", nil) action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
[frame_skip_menu addItem:[NSMenuItem separatorItem]];
frame_skip_item[0] = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Off", nil) action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
for(i = 1; i < MAX_FRAME_SKIP; i++)
{
frame_skip_item[i] = [frame_skip_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Skip %d", nil), i] action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
[file_menu release];
}
[frame_skip_menu release];
[emulation addItem:[NSMenuItem separatorItem]];
//Emulation menu
temp = [emulation addItemWithTitle:NSLocalizedString(@"Set FAT Image File...", nil) action:@selector(pickFlash) keyEquivalent:@""];
[emulation release];
//Create the screens menu
view = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"View", nil)];
[menu setSubmenu:view forItem:view_item];
resize1x = [view addItemWithTitle:NSLocalizedString(@"Size 1x", nil) action:@selector(resizeScreen1x) keyEquivalent:@"1"];
resize2x = [view addItemWithTitle:NSLocalizedString(@"Size 2x", nil) action:@selector(resizeScreen2x) keyEquivalent:@"2"];
resize3x = [view addItemWithTitle:NSLocalizedString(@"Size 3x", nil) action:@selector(resizeScreen3x) keyEquivalent:@"3"];
resize4x = [view addItemWithTitle:NSLocalizedString(@"Size 4x", nil) action:@selector(resizeScreen4x) keyEquivalent:@"4"];
[view addItem:[NSMenuItem separatorItem]];
/*
[view addItemWithTitle:NSLocalizedString(@"Full Screen", nil) action:nil keyEquivalent:@"f"];
[view addItem:[NSMenuItem separatorItem]];
*/
constrain_item = [view addItemWithTitle:NSLocalizedString(@"Constrain Proportions", nil) action:@selector(toggleConstrainProportions) keyEquivalent:@""];
min_size_item = [view addItemWithTitle:NSLocalizedString(@"No Smaller Than DS", nil) action:@selector(toggleMinSize) keyEquivalent:@""];
toggle_status_bar_item = [view addItemWithTitle:NSLocalizedString(@"Show Status Bar", nil) action:@selector(toggleStatusBar) keyEquivalent:@"/"];
[view addItem:[NSMenuItem separatorItem]];
temp = [view addItemWithTitle:NSLocalizedString(@"Rotation", nil) action:nil keyEquivalent:@""];
NSMenu *rotation_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Rotation", nil)];
[temp setSubmenu: rotation_menu];
rotation0_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 0", nil) action:@selector(setRotation0) keyEquivalent:@""];
rotation90_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 90", nil) action:@selector(setRotation90) keyEquivalent:@""];
rotation180_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 180", nil) action:@selector(setRotation180) keyEquivalent:@""];
rotation270_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 270", nil) action:@selector(setRotation270) keyEquivalent:@""];
[rotation_menu release];
[view addItem:[NSMenuItem separatorItem]];
temp = [view addItemWithTitle:NSLocalizedString(@"Layers", nil) action:nil keyEquivalent:@""];
NSMenu *layer_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Layers", nil)];
[temp setSubmenu: layer_menu];
topBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG0", nil) action:@selector(toggleTopBackground0) keyEquivalent:@""];
topBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG1", nil) action:@selector(toggleTopBackground1) keyEquivalent:@""];
topBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG2", nil) action:@selector(toggleTopBackground2) keyEquivalent:@""];
topBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG3", nil) action:@selector(toggleTopBackground3) keyEquivalent:@""];
[layer_menu addItem:[NSMenuItem separatorItem]];
subBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG0", nil) action:@selector(toggleSubBackground0) keyEquivalent:@""];
subBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG1", nil) action:@selector(toggleSubBackground1) keyEquivalent:@""];
subBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG2", nil) action:@selector(toggleSubBackground2) keyEquivalent:@""];
subBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG3", nil) action:@selector(toggleSubBackground3) keyEquivalent:@""];
[layer_menu release];
[view addItem:[NSMenuItem separatorItem]];
screenshot_to_file_item = [view addItemWithTitle:NSLocalizedString(@"Save Screenshot...", nil) action:@selector(saveScreenshot) keyEquivalent:@""];
[view release];
//Create the sound menu
sound_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Sound", nil)];
[menu setSubmenu:sound_menu forItem:sound_item];
temp = [sound_menu addItemWithTitle:NSLocalizedString(@"Volume", nil) action:nil keyEquivalent:@""];
[temp setTarget:[NSApp delegate]];
NSMenu *volume_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Volume", nil)];
[sound_menu setSubmenu:volume_menu forItem:temp];
for(i = 0; i < 10; i++)
temp = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu *emulation_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Emulation", nil)];
if(emulation_menu != nil)
{
volume_item[i] = [volume_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Volume %d", nil), (i+1)*10] action:@selector(setVolumeFromMenu:) keyEquivalent:@""];
[main_menu setSubmenu:emulation_menu forItem:temp];
execute_item = [emulation_menu addItemWithTitle:NSLocalizedString(@"Execute", nil) action:@selector(execute) keyEquivalent:@"e"];
pause_item = [emulation_menu addItemWithTitle:NSLocalizedString(@"Pause", nil) action:@selector(pause) keyEquivalent:@"p"];
reset_item = [emulation_menu addItemWithTitle:NSLocalizedString(@"Reset", nil) action:@selector(reset) keyEquivalent:@"r"];
[emulation_menu addItem:[NSMenuItem separatorItem]];
//Frake skip menu
temp = [emulation_menu addItemWithTitle:NSLocalizedString(@"Frame Skip", nil) action:nil keyEquivalent:@""];
NSMenu *frame_skip_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Frame Skip", nil)];
if(frame_skip_menu != nil)
{
[temp setSubmenu:frame_skip_menu];
frame_skip_auto_item = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Auto", nil) action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
[frame_skip_menu addItem:[NSMenuItem separatorItem]];
frame_skip_item[0] = [frame_skip_menu addItemWithTitle:NSLocalizedString(@"Off", nil) action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
for(i = 1; i < MAX_FRAME_SKIP; i++)
{
frame_skip_item[i] = [frame_skip_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Skip %d", nil), i] action:@selector(setFrameSkipFromMenuItem:) keyEquivalent:@""];
}
[frame_skip_menu release];
}
[emulation_menu addItem:[NSMenuItem separatorItem]];
[emulation_menu addItemWithTitle:NSLocalizedString(@"Set FAT Image File...", nil) action:@selector(pickFlash) keyEquivalent:@""];
[emulation_menu release];
}
[volume_menu release];
//View menu
[sound_menu addItem:[NSMenuItem separatorItem]];
temp = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu *view_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"View", nil)];
if(view_menu)
{
[main_menu setSubmenu:view_menu forItem:temp];
mute_item = [sound_menu addItemWithTitle:NSLocalizedString(@"Mute", nil) action:@selector(toggleMute) keyEquivalent:@""];
/*
[sound_menu addItem:[NSMenuItem separatorItem]];
resize1x = [view_menu addItemWithTitle:NSLocalizedString(@"Size 1x", nil) action:@selector(resizeScreen1x) keyEquivalent:@"1"];
resize2x = [view_menu addItemWithTitle:NSLocalizedString(@"Size 2x", nil) action:@selector(resizeScreen2x) keyEquivalent:@"2"];
resize3x = [view_menu addItemWithTitle:NSLocalizedString(@"Size 3x", nil) action:@selector(resizeScreen3x) keyEquivalent:@"3"];
resize4x = [view_menu addItemWithTitle:NSLocalizedString(@"Size 4x", nil) action:@selector(resizeScreen4x) keyEquivalent:@"4"];
temp = [sound_menu addItemWithTitle:@"Record to File..." action:@selector(chooseSoundOutputFile) keyEquivalent: @"r"];
[view_menu addItem:[NSMenuItem separatorItem]];
temp = [sound_menu addItemWithTitle:@"Pause Recording" action:@selector(startRecording) keyEquivalent: @""];
constrain_item = [view_menu addItemWithTitle:NSLocalizedString(@"Constrain Proportions", nil) action:@selector(toggleConstrainProportions) keyEquivalent:@""];
min_size_item = [view_menu addItemWithTitle:NSLocalizedString(@"No Smaller Than DS", nil) action:@selector(toggleMinSize) keyEquivalent:@""];
toggle_status_bar_item = [view_menu addItemWithTitle:NSLocalizedString(@"Show Status Bar", nil) action:@selector(toggleStatusBar) keyEquivalent:@"/"];
temp = [sound_menu addItemWithTitle:@"Save Recording" action:@selector(pauseRecording) keyEquivalent: @""];
*/
[view_menu addItem:[NSMenuItem separatorItem]];
[sound_menu release];
//Rotation menu
temp = [view_menu addItemWithTitle:NSLocalizedString(@"Rotation", nil) action:nil keyEquivalent:@""];
NSMenu *rotation_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Rotation", nil)];
if(rotation_menu != nil)
{
[temp setSubmenu:rotation_menu];
//Create the window menu
/*
window = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Window", nil)];
[menu setSubmenu:window forItem:window_item];
rotation0_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 0", nil) action:@selector(setRotation0) keyEquivalent:@""];
rotation90_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 90", nil) action:@selector(setRotation90) keyEquivalent:@""];
rotation180_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 180", nil) action:@selector(setRotation180) keyEquivalent:@""];
rotation270_item = [rotation_menu addItemWithTitle:NSLocalizedString(@"Rotation 270", nil) action:@selector(setRotation270) keyEquivalent:@""];
[window addItemWithTitle:@"Minimize" action:nil keyEquivalent:@""];
[window addItemWithTitle:@"Zoom" action:nil keyEquivalent:@""];
[window addItem:[NSMenuItem separatorItem]];
[window addItemWithTitle:@"Bring All to Front" action:nil keyEquivalent:@""];
[window addItem:[NSMenuItem separatorItem]];
[window addItemWithTitle:@"DS Display" action:nil keyEquivalent:@""];
//[window addItemWithTitle:@"Save State Viewer" action:nil keyEquivalent:@""];
//[window addItemWithTitle:@"Debugger" action:nil keyEquivalent:@""];
//[window addItem:[NSMenuItem separatorItem]];
//[window addItemWithTitle:@"(screenshots)" action:nil keyEquivalent:@""];
[rotation_menu release];
}
[view_menu addItem:[NSMenuItem separatorItem]];
//[window release];
*/
//Layer Menu
temp = [view_menu addItemWithTitle:NSLocalizedString(@"Layers", nil) action:nil keyEquivalent:@""];
NSMenu *layer_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Layers", nil)];
if(layer_menu != nil)
{
[temp setSubmenu: layer_menu];
topBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG0", nil) action:@selector(toggleTopBackground0) keyEquivalent:@""];
topBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG1", nil) action:@selector(toggleTopBackground1) keyEquivalent:@""];
topBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG2", nil) action:@selector(toggleTopBackground2) keyEquivalent:@""];
topBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Top BG3", nil) action:@selector(toggleTopBackground3) keyEquivalent:@""];
[layer_menu addItem:[NSMenuItem separatorItem]];
subBG0_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG0", nil) action:@selector(toggleSubBackground0) keyEquivalent:@""];
subBG1_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG1", nil) action:@selector(toggleSubBackground1) keyEquivalent:@""];
subBG2_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG2", nil) action:@selector(toggleSubBackground2) keyEquivalent:@""];
subBG3_item = [layer_menu addItemWithTitle:NSLocalizedString(@"Sub BG3", nil) action:@selector(toggleSubBackground3) keyEquivalent:@""];
[layer_menu release];
}
[view_menu addItem:[NSMenuItem separatorItem]];
screenshot_to_file_item = [view_menu addItemWithTitle:NSLocalizedString(@"Save Screenshot...", nil) action:@selector(saveScreenshot) keyEquivalent:@""];
[view_menu release];
}
//Sound Menu
temp = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu *sound_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Sound", nil)];
if(sound_menu != nil)
{
[main_menu setSubmenu:sound_menu forItem:temp];
[temp = [sound_menu addItemWithTitle:NSLocalizedString(@"Volume", nil) action:nil keyEquivalent:@""] setTarget:[NSApp delegate]];
NSMenu *volume_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Volume", nil)];
if(volume_menu)
{
[sound_menu setSubmenu:volume_menu forItem:temp];
for(i = 0; i < 10; i++)
volume_item[i] = [volume_menu addItemWithTitle:[NSString stringWithFormat:NSLocalizedString(@"Volume %d", nil), (i+1)*10] action:@selector(setVolumeFromMenu:) keyEquivalent:@""];
[volume_menu release];
}
[sound_menu addItem:[NSMenuItem separatorItem]];
mute_item = [sound_menu addItemWithTitle:NSLocalizedString(@"Mute", nil) action:@selector(toggleMute) keyEquivalent:@""];
//[sound_menu addItem:[NSMenuItem separatorItem]];
//temp = [sound_menu addItemWithTitle:@"Record to File..." action:@selector(chooseSoundOutputFile) keyEquivalent: @"r"];
//temp = [sound_menu addItemWithTitle:@"Pause Recording" action:@selector(startRecording) keyEquivalent: @""];
//temp = [sound_menu addItemWithTitle:@"Save Recording" action:@selector(pauseRecording) keyEquivalent: @""];
[sound_menu release];
}
//Create the help menu
help = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Help", nil)];
[menu setSubmenu:help forItem:help_item];
temp = [main_menu addItemWithTitle:@"" action:nil keyEquivalent:@""];
NSMenu *help_menu = [[NSMenu alloc] initWithTitle:NSLocalizedString(@"Help", nil)];
if(help_menu != nil)
{
[main_menu setSubmenu:help_menu forItem:temp];
temp = [help addItemWithTitle:NSLocalizedString(@"Go to Website", nil) action:@selector(launchWebsite) keyEquivalent: @""];
[temp setTarget:NSApp];
[[help_menu addItemWithTitle:NSLocalizedString(@"Go to Website", nil) action:@selector(launchWebsite) keyEquivalent: @""] setTarget:NSApp];
[[help_menu addItemWithTitle:NSLocalizedString(@"Go to Forums", nil) action:@selector(launchForums) keyEquivalent: @""] setTarget:NSApp];
[[help_menu addItemWithTitle:NSLocalizedString(@"Submit a Bug Report", nil) action:@selector(bugReport) keyEquivalent: @""] setTarget:NSApp];
temp = [help addItemWithTitle:NSLocalizedString(@"Go to Forums", nil) action:@selector(launchForums) keyEquivalent: @""];
[temp setTarget:NSApp];
temp = [help addItemWithTitle:NSLocalizedString(@"Submit a Bug Report", nil) action:@selector(bugReport) keyEquivalent: @""];
[temp setTarget:NSApp];
[help release];
[help_menu release];
}
}
//Main Function--------------------------------------------------------------------------------------
@ -407,24 +372,16 @@ int main(int argc, char *argv[])
{
srand(time(NULL));
autorelease = [[NSAutoreleasePool alloc] init];
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[NSApplication sharedApplication];
[NSApp setDelegate:[[AppDelegate alloc] init]];
return NSApplicationMain(argc, (const char**)argv);
}
//gdb stuff--------------------------------------------------------------------------------
//don't know and don't care
void *createThread_gdb(void (*thread_function)(void *data), void *thread_data)
{
return NULL;
}
void joinThread_gdb(void *thread_handle)
{
int result = NSApplicationMain(argc, (const char**)argv);
[pool release];
return result;
}
//Implementations-------------------------------------------------------------------------
@ -543,12 +500,12 @@ fail:
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication*)sender
{
//Ask user if he/she wants to quit
//ask the user if quitting is acceptable
if(messageDialogYN(NSLocalizedString(@"DeSmuME Emulator", nil), NSLocalizedString(@"Are you sure you want to quit?", nil)))
return NSTerminateNow;
else
//Ask user about quitting if a rom is loaded (avoid accidentally quiting with unsaved progress)
if([main_window ROMLoaded])
if(!messageDialogYN(NSLocalizedString(@"DeSmuME Emulator", nil), NSLocalizedString(@"Are you sure you want to quit?", nil)))
return NSTerminateCancel;
return NSTerminateNow;
}
- (void)applicationWillTerminate:(NSNotification*)notification

View File

@ -43,43 +43,42 @@
#define DS_SCREEN_Y_RATIO ((192.0 * 2.0) / 256.0)
//
NSMenuItem *close_rom_item;
NSMenuItem *execute_item;
NSMenuItem *pause_item;
NSMenuItem *reset_item;
NSMenuItem *save_state_as_item;
NSMenuItem *load_state_from_item;
NSMenuItem *saveSlot_item[MAX_SLOTS];
NSMenuItem *loadSlot_item[MAX_SLOTS];
//NSMenuItem *clear_all_saves_item;
NSMenuItem *rom_info_item;
NSMenuItem *frame_skip_auto_item;
NSMenuItem *frame_skip_item[MAX_FRAME_SKIP];
NSMenuItem *close_rom_item = nil;
NSMenuItem *execute_item = nil;
NSMenuItem *pause_item = nil;
NSMenuItem *reset_item = nil;
NSMenuItem *save_state_as_item = nil;
NSMenuItem *load_state_from_item = nil;
NSMenuItem *saveSlot_item[MAX_SLOTS] = { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil }; //make sure this corresponds to the amount in max slots
NSMenuItem *loadSlot_item[MAX_SLOTS] = { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil };
NSMenuItem *rom_info_item = nil;
NSMenuItem *frame_skip_auto_item = nil;
NSMenuItem *frame_skip_item[MAX_FRAME_SKIP] = { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil };
NSMenuItem *volume_item[10];
NSMenuItem *mute_item;
NSMenuItem *volume_item[10] = { nil, nil, nil, nil, nil, nil, nil, nil, nil, nil };
NSMenuItem *mute_item = nil;
//screen menu items
NSMenuItem *resize1x;
NSMenuItem *resize2x;
NSMenuItem *resize3x;
NSMenuItem *resize4x;
NSMenuItem *constrain_item;
NSMenuItem *min_size_item;
NSMenuItem *toggle_status_bar_item;
NSMenuItem *rotation0_item;
NSMenuItem *rotation90_item;
NSMenuItem *rotation180_item;
NSMenuItem *rotation270_item;
NSMenuItem *topBG0_item;
NSMenuItem *topBG1_item;
NSMenuItem *topBG2_item;
NSMenuItem *topBG3_item;
NSMenuItem *subBG0_item;
NSMenuItem *subBG1_item;
NSMenuItem *subBG2_item;
NSMenuItem *subBG3_item;
NSMenuItem *screenshot_to_file_item;
NSMenuItem *resize1x = nil;
NSMenuItem *resize2x = nil;
NSMenuItem *resize3x = nil;
NSMenuItem *resize4x = nil;
NSMenuItem *constrain_item = nil;
NSMenuItem *min_size_item = nil;
NSMenuItem *toggle_status_bar_item = nil;
NSMenuItem *rotation0_item = nil;
NSMenuItem *rotation90_item = nil;
NSMenuItem *rotation180_item = nil;
NSMenuItem *rotation270_item = nil;
NSMenuItem *topBG0_item = nil;
NSMenuItem *topBG1_item = nil;
NSMenuItem *topBG2_item = nil;
NSMenuItem *topBG3_item = nil;
NSMenuItem *subBG0_item = nil;
NSMenuItem *subBG1_item = nil;
NSMenuItem *subBG2_item = nil;
NSMenuItem *subBG3_item = nil;
NSMenuItem *screenshot_to_file_item = nil;
@implementation VideoOutputWindow

View File

@ -17,7 +17,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import "nds_control.h"
#import "nds_control.h"=
#import <OpenGL/OpenGL.h>
#import <OpenGL/gl.h>
@ -82,11 +82,11 @@ struct NDS_fw_config_data firmware;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
flash_file = [[defaults stringForKey:PREF_FLASH_FILE] retain];
if ([flash_file length] > 0) {
NSLog(@"Using flash file: \"%@\"\n", flash_file);
//NSLog(@"Using flash file: \"%@\"\n", flash_file);
} else {
[flash_file release];
flash_file = nil;
NSLog(@"No flash file given\n");
//NSLog(@"No flash file given\n");
}
//check if we can send messages on other threads, which we will use for video update
@ -129,7 +129,7 @@ struct NDS_fw_config_data firmware;
} else
{
[context makeCurrentContext];
//check extensions
BOOL supports_pixel_buffers = NO;
const char *extension_list = (const char*)glGetString(GL_EXTENSIONS);
@ -141,14 +141,14 @@ struct NDS_fw_config_data firmware;
//attempt to use a pixel-buffer for hopefully hardware accelerated offscreen drawing
if(supports_pixel_buffers == YES)
{
{
NSOpenGLPixelBuffer *pixel_buffer = [[NSOpenGLPixelBuffer alloc]
initWithTextureTarget:GL_TEXTURE_2D
textureInternalFormat:GL_RGBA
textureMaxMipMapLevel:0
pixelsWide:DS_SCREEN_WIDTH
pixelsHigh:DS_SCREEN_HEIGHT*2];
if(pixel_buffer == nil)
{
GLenum error = glGetError();
@ -161,31 +161,31 @@ struct NDS_fw_config_data firmware;
gl_ready = true;
}
}
//if pixel buffers didn't work out, try simple offscreen renderings (probably software accelerated)
if(!gl_ready)
{
[context setOffScreen:(void*)&gpu_buff width:DS_SCREEN_WIDTH height:DS_SCREEN_HEIGHT rowbytes:DS_SCREEN_WIDTH*5];
[context setOffScreen:(void*)&gpu_buff width:DS_SCREEN_WIDTH height:DS_SCREEN_HEIGHT rowbytes:DS_SCREEN_WIDTH*5];
gl_ready = true;
}
}
if(context)
{
[context makeCurrentContext];
NDS_3D_SetDriver(GPU3D_OPENGL);
if(!gpu3D->NDS_3D_Init())
messageDialog(NSLocalizedString(@"Error", nil), @"Unable to initialize OpenGL components");
}
if(prev_context != nil) //make sure the old context is restored, and make sure our new context is not set in this thread (since the other thread will need it)
{
{
[prev_context makeCurrentContext];
[prev_context release];
} else
[NSOpenGLContext clearCurrentContext];
//Sound Init
if(SPU_ChangeSoundCore(SNDCORE_OSX, 735 * 4) != 0)
messageDialog(NSLocalizedString(@"Error", nil), @"Unable to initialize sound core");
@ -485,11 +485,11 @@ struct NDS_fw_config_data firmware;
- (void)reset
{
//note that the execution_lock method would probably be a little better
//but the NDS_Reset() function sets execution to false for some reason
//we treat execution == false as an emulation error
//pausing allows the other thread to not think theres an emulation error
//[execution_lock lock];
bool old_run = run;
if(old_run)
@ -497,12 +497,12 @@ struct NDS_fw_config_data firmware;
run = false;
while(!paused){}
}
NDS_Reset();
//[execution_lock unlock];
run = old_run;
//if there was a previous emulation error, clear it, since we reset
execute = true;
}
@ -936,12 +936,12 @@ struct NDS_fw_config_data firmware;
- (BOOL)loadState:(NSString*)file
{
[execution_lock lock];
//Set the GPU context (if it exists) incase the core needs to load anything into opengl during state load
NSOpenGLContext *prev_context = [NSOpenGLContext currentContext];
[prev_context retain];
[context makeCurrentContext];
BOOL result = NO;
if(savestate_load([file cStringUsingEncoding:NSUTF8StringEncoding]))
result = YES;
@ -954,7 +954,7 @@ struct NDS_fw_config_data firmware;
[prev_context release];
} else
[NSOpenGLContext clearCurrentContext];
return result;
}
@ -982,11 +982,11 @@ struct NDS_fw_config_data firmware;
BOOL result = NO;
[execution_lock lock];
//Set the GPU context (if it exists) incase the core needs to load anything into opengl during state load
NSOpenGLContext *prev_context = [NSOpenGLContext currentContext];
[prev_context retain];
[context makeCurrentContext];
[context makeCurrentContext];
loadstate_slot(slot + 1); //no exection handling?
result = YES;
@ -999,7 +999,7 @@ struct NDS_fw_config_data firmware;
[prev_context release];
} else
[NSOpenGLContext clearCurrentContext];
return result;
}
@ -1269,10 +1269,10 @@ struct NDS_fw_config_data firmware;
if(frame_end_time - last_video_update > 10000)
{
last_video_update = frame_end_time;
ScreenState *new_screen_data = [[ScreenState alloc] init];
[new_screen_data setColorData:GPU_screen];
if(timer_based)
{ //for tiger compatibility
[video_update_lock lock];
@ -1281,7 +1281,7 @@ struct NDS_fw_config_data firmware;
[video_update_lock unlock];
} else
{ //for leopard and later
//this will generate a warning when compiling on tiger or earlier, but it should
//be ok since the purpose of the if statement is to check if this will work
[self performSelector:@selector(videoUpdateHelper:) onThread:gui_thread withObject:new_screen_data waitUntilDone:NO];

View File

@ -17,6 +17,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import <Cocoa/Cocoa.h>
#define PREF_EXECUTE_UPON_LOAD @"Execute Upon Load"
#define PREF_AFTER_LAUNCHED @"When Launching, Load"
@ -25,18 +27,19 @@
#define PREF_FLASH_FILE @"Flash File"
#define PREF_KEY_A @"Key A"
#define PREF_KEY_B @"Key B"
#define PREF_KEY_X @"Key X"
#define PREF_KEY_Y @"Key Y"
#define PREF_KEY_L @"Key L"
#define PREF_KEY_R @"Key R"
#define PREF_KEY_UP @"Key Up"
#define PREF_KEY_DOWN @"Key Down"
#define PREF_KEY_LEFT @"Key Left"
#define PREF_KEY_RIGHT @"Key Right"
#define PREF_KEY_START @"Key Start"
#define PREF_KEY_SELECT @"Key Select"
#define PREF_KEY_A @"A Button"
#define PREF_KEY_B @"B Button"
#define PREF_KEY_X @"X Button"
#define PREF_KEY_Y @"Y Button"
#define PREF_KEY_L @"L Button"
#define PREF_KEY_R @"R Button"
#define PREF_KEY_UP @"Up Button"
#define PREF_KEY_DOWN @"Down Button"
#define PREF_KEY_LEFT @"Left Button"
#define PREF_KEY_RIGHT @"Right Button"
#define PREF_KEY_START @"Start Button"
#define PREF_KEY_SELECT @"Select Button"
void setAppDefaults(); //this is defined in preferences.m and should be called at app launch
NSView *createPreferencesView(NSString *helpinfo, NSDictionary *options, id delegate); //utility func for creating a preference panel with a set of options

View File

@ -41,88 +41,32 @@ const CGFloat PREFERENCES_WIDTH = 365;
NSFont *preferences_font;
NSDictionary *preferences_font_attribs;
NSDictionary *desmume_defaults;
NSDictionary *keyboardMap; // TODO: name it something else
NSMutableDictionary *defaults;
///////////////////////////////
unsigned char utf8_return = 0x0D;
unsigned char utf8_right[3] = { 0xEF, 0x9C, 0x83 };
unsigned char utf8_up[3] = { 0xEF, 0x9C, 0x80 };
unsigned char utf8_down[3] = { 0xEF, 0x9C, 0x81 };
unsigned char utf8_left[3] = { 0xEF, 0x9C, 0x82 };
//This needs to be called when the program starts
void setAppDefaults()
{
desmume_defaults = [NSDictionary dictionaryWithObjectsAndKeys:
defaults = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
//Flash file default
@"", PREF_FLASH_FILE,
//Interface defaults
@"Yes", PREF_EXECUTE_UPON_LOAD,
PREF_AFTER_LAUNCHED_OPTION_NOTHING, PREF_AFTER_LAUNCHED,
//Firmware defaults
//@"DeSmuME User", PREF_FIRMWARE_PLAYER_NAME,
//@"English", PREF_FIRMWARE_LANGUAGE,
//Flash file default
@"", PREF_FLASH_FILE,
PREF_AFTER_LAUNCHED_OPTION_NOTHING, PREF_AFTER_LAUNCHED,
//Key defaults
@"v", PREF_KEY_A,
@"b", PREF_KEY_B,
@"g", PREF_KEY_X,
@"h", PREF_KEY_Y,
@"c", PREF_KEY_L,
@"n", PREF_KEY_R,
@" ", PREF_KEY_SELECT,
[[[NSString alloc] initWithBytesNoCopy:utf8_up length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_UP,
[[[NSString alloc] initWithBytesNoCopy:utf8_down length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_DOWN,
[[[NSString alloc] initWithBytesNoCopy:utf8_left length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_LEFT,
[[[NSString alloc] initWithBytesNoCopy:utf8_right length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_RIGHT,
[[[NSString alloc] initWithBytesNoCopy:&utf8_return length:1 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease], PREF_KEY_START,
nil];
[desmume_defaults retain];
//Input defaults
[defaults addEntriesFromDictionary:[InputHandler appDefaults]];
//window size defaults
NSRect temp;
temp.origin.x = 600;
temp.origin.y = 600;
temp.size.width = 500;
temp.size.height = 600;
//[NSData dataWithBytes:&temp length:sizeof(NSRect)], @"DeSmuME Preferences Window", nil];
[[NSUserDefaults standardUserDefaults] registerDefaults:desmume_defaults];
}
void setKeyboardMap()
{
// Create a dictionary mapping the keyboard
NSArray *keys = [NSArray arrayWithObjects:
@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9",
@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L",
@"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"V", @"W", @"X", @"Y", @"Z",
@"[UP]", @"[DOWN]", @"[LEFT]", @"[RIGHT]", @"[SPACE]", @"[RETURN]", nil];
NSArray *objects = [NSArray arrayWithObjects:
@"0", @"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9",
@"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", @"j", @"k", @"l",
@"m", @"n", @"o", @"p", @"q", @"r", @"s", @"t", @"v", @"w", @"x", @"y", @"z",
[[[NSString alloc] initWithBytesNoCopy:utf8_up length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_down length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_left length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
[[[NSString alloc] initWithBytesNoCopy:utf8_right length:3 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
@" ",
[[[NSString alloc] initWithBytesNoCopy:&utf8_return length:1 encoding:NSUTF8StringEncoding freeWhenDone:NO] autorelease],
nil];
keyboardMap = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
///////////////////////////////
@ -142,7 +86,6 @@ void setKeyboardMap()
{
//NSText *text_field = [notification object];
//NSString *text = [text_field string];
}
- (void)executeUponLoad:(id)sender
@ -160,78 +103,6 @@ void setKeyboardMap()
[[NSUserDefaults standardUserDefaults] setObject:PREF_AFTER_LAUNCHED_OPTION_LAST_ROM forKey:PREF_AFTER_LAUNCHED];
}
- (void)bindingForKeyA:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_A];
}
- (void)bindingForKeyB:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_B];
}
- (void)bindingForKeyX:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_X];
}
- (void)bindingForKeyY:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_Y];
}
- (void)bindingForKeyL:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_L];
}
- (void)bindingForKeyR:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_R];
}
- (void)bindingForKeyUp:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_UP];
}
- (void)bindingForKeyDown:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_DOWN];
}
- (void)bindingForKeyLeft:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_LEFT];
}
- (void)bindingForKeyRight:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_RIGHT];
}
- (void)bindingForKeyStart:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_START];
}
- (void)bindingForKeySelect:(id)sender
{
NSString* key = [sender titleOfSelectedItem];
[[NSUserDefaults standardUserDefaults] setValue:[keyboardMap valueForKey:key] forKey:PREF_KEY_SELECT];
}
@end
////////////////////////////////////////////////////
@ -428,9 +299,9 @@ NSView *createPreferencesView(NSString *helpinfo, NSDictionary *options, id dele
//loop through each option in the options list
//this is done backwards since we build the view upwards
//fixme: because dictionaries lack order, options should not be passed as a dictionary
// NSArray *keys = [options allKeys];
NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedCompare:)];
NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedCompare:)];
NSEnumerator *key_enumerator = [keys reverseObjectEnumerator];
id key, key_raw, object;
@ -467,7 +338,6 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
}
else if([[object objectAtIndex:0] compare:@"Array"] == NSOrderedSame)
{
//Create the button for this option
NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:button_rect pullsDown:NO];
@ -483,7 +353,7 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
{
//add the item to the popup buttons list
[button addItemWithTitle:NSLocalizedString([object objectAtIndex:i],nil)];
//if this is the currently selected or default item
if([current_setting compare:[object objectAtIndex:i]] == NSOrderedSame)
{
@ -496,18 +366,18 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
{ //the user setting for this option was not found
//get the default value
current_setting = [desmume_defaults objectForKey:key_raw];
NSString *default_setting = [defaults objectForKey:key_raw];
//show an error
messageDialog(NSLocalizedString(@"Error",nil), [NSString stringWithFormat:NSLocalizedString(@"%@ setting corrupt, resetting to default (%@)",nil),key, NSLocalizedString(current_setting, nil)]);
messageDialog(NSLocalizedString(@"Error",nil), [NSString stringWithFormat:@"%@ setting corrupt (%@), resetting to default (%@)", key, NSLocalizedString(current_setting, nil), NSLocalizedString(default_setting, nil)]);
//set the setting to default
[[NSUserDefaults standardUserDefaults] setObject:current_setting forKey:key_raw];
[[NSUserDefaults standardUserDefaults] setObject:default_setting forKey:key_raw];
//show the default setting in the button
for(i = 2; i < [object count]; i++)
if([current_setting compare:[object objectAtIndex:i]] == NSOrderedSame)
;//[button selectItemAtIndex:i - 2];
;//[button selectItemAtIndex:i - 2]; fixme
}
[view addSubview:button];
@ -555,6 +425,7 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
//add the item to the popup buttons list
NSString* key = [keys objectAtIndex:i];
[button addItemWithTitle:NSLocalizedString(key,nil)];
[[button lastItem] setRepresentedObject:[keymap objectForKey:key]];
if ( [current_setting compare:[keymap valueForKey:key] ] == NSOrderedSame ) {
[button selectItemAtIndex:i];
@ -597,9 +468,8 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
[view setFrame:temprect];
[help_text release];
[view autorelease];
return view;
return [view autorelease];
}
@ -626,41 +496,18 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
//Create interface view
NSDictionary *interface_options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSArray arrayWithObjects:@"Bool", [NSData dataWithBytes:&@selector(executeUponLoad:) length:sizeof(SEL)], @"Yes", @"No",nil], PREF_EXECUTE_UPON_LOAD,
[NSArray arrayWithObjects:@"Array", [NSData dataWithBytes:&@selector(afterLaunch:) length:sizeof(SEL)], PREF_AFTER_LAUNCHED_OPTION_NOTHING, PREF_AFTER_LAUNCHED_OPTION_LAST_ROM, nil], PREF_AFTER_LAUNCHED,
nil];
NSView *interface_view = createPreferencesView(@"Use the popup buttons on the right to change settings", interface_options, delegate);
//Create the controls view
setKeyboardMap();
NSDictionary *controls_options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyA:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_A,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyB:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_B,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyX:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_X,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyY:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_Y,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyL:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_L,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyR:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_R,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyUp:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_UP,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyDown:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_DOWN,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyLeft:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_LEFT,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyRight:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_RIGHT,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeyStart:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_START,
[NSMutableArray arrayWithObjects:@"Dictionary", [NSData dataWithBytes:&@selector(bindingForKeySelect:) length:sizeof(SEL)], keyboardMap , nil] , PREF_KEY_SELECT,
nil];
NSView *controls_view = createPreferencesView(@"Use the popup buttons on the right to change settings", controls_options, delegate);
NSView *controls_view = [InputHandler createPreferencesView:PREFERENCES_WIDTH];
[controls_view setFrame:NSMakeRect(0, 0, PREFERENCES_WIDTH, [controls_view frame].size.height)];
//create the preferences window
NSWindow *preferences_window = [[NSWindow alloc] initWithContentRect:[interface_view frame] styleMask:
@ -668,7 +515,7 @@ NSArray* keys = [[options allKeys] sortedArrayUsingSelector:@selector(localizedC
[preferences_window setTitle:NSLocalizedString(@"DeSmuME Preferences", nil)];
[preferences_window setDelegate:delegate];
[preferences_window setFrameAutosaveName:@"DeSmuME Preferences Window"];
[preferences_window setFrameOrigin:NSMakePoint(500,500)];
[[preferences_window contentView] addSubview:interface_view];
//create the toolbar delegate

View File

@ -23,20 +23,20 @@
#include <stdlib.h>
#include "matrix.h"
void __fastcall MatrixInit (float *matrix)
void FASTCALL MatrixInit (float *matrix)
{
memset (matrix, 0, sizeof(float)*16);
matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f;
}
#ifdef SSE2
void __fastcall MatrixIdentity (float *matrix) //============== TODO
void FASTCALL MatrixIdentity (float *matrix) //============== TODO
{
memset (matrix, 0, sizeof(float)*16);
matrix[0] = matrix[5] = matrix[10] = matrix[15] = 1.f;
}
float __fastcall MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix)
float FASTCALL MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix)
{
int iMod = index%4, iDiv = (index>>2)<<2;
@ -44,12 +44,12 @@ float __fastcall MatrixGetMultipliedIndex (int index, float *matrix, float *righ
(matrix[iMod+8]*rightMatrix[iDiv+2])+(matrix[iMod+12]*rightMatrix[iDiv+3]);
}
void __fastcall MatrixSet (float *matrix, int x, int y, float value) // TODO
void FASTCALL MatrixSet (float *matrix, int x, int y, float value) // TODO
{
matrix [x+(y<<2)] = value;
}
void __fastcall MatrixCopy (float *matrixDST, float *matrixSRC)
void FASTCALL MatrixCopy (float *matrixDST, float *matrixSRC)
{
memcpy (matrixDST, matrixSRC, sizeof(float)*16);
}

View File

@ -21,6 +21,8 @@
#ifndef MATRIX_H
#define MATRIX_H
#include "types.h"
#ifdef SSE2
#include <xmmintrin.h>
#include <emmintrin.h>
@ -42,19 +44,19 @@ typedef struct MatrixStack
} MatrixStack;
#ifdef SSE2
void __fastcall MatrixInit (float *matrix);
extern void __fastcall MatrixMultVec3x3 (const gMatrix matrix, const gMatrix vecPtr);
extern void __fastcall MatrixMultVec4x4 (const gMatrix matrix, const gMatrix vecPtr);
void __fastcall MatrixIdentity (float *matrix);
extern void __fastcall MatrixMultiply (const gMatrix matrix, const gMatrix rightMatrix);
float __fastcall MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix);
void __fastcall MatrixSet (float *matrix, int x, int y, float value);
void __fastcall MatrixCopy (const gMatrix matrixDST, const gMatrix matrixSRC);
extern void __fastcall MatrixTranslate (const gMatrix matrix, const gMatrix ptr);
extern void __fastcall MatrixScale (const gMatrix matrix, const gMatrix ptr);
void __fastcall MatrixScale (const gMatrix matrix, const gMatrix ptr);
void FASTCALL MatrixInit (float *matrix);
extern void FASTCALL MatrixMultVec3x3 (const gMatrix matrix, const gMatrix vecPtr);
extern void FASTCALL MatrixMultVec4x4 (const gMatrix matrix, const gMatrix vecPtr);
void FASTCALL MatrixIdentity (float *matrix);
extern void FASTCALL MatrixMultiply (const gMatrix matrix, const gMatrix rightMatrix);
float FASTCALL MatrixGetMultipliedIndex (int index, float *matrix, float *rightMatrix);
void FASTCALL MatrixSet (float *matrix, int x, int y, float value);
void FASTCALL MatrixCopy (const gMatrix matrixDST, const gMatrix matrixSRC);
extern void FASTCALL MatrixTranslate (const gMatrix matrix, const gMatrix ptr);
extern void FASTCALL MatrixScale (const gMatrix matrix, const gMatrix ptr);
void FASTCALL MatrixScale (const gMatrix matrix, const gMatrix ptr);
#else
void __fastcall MatrixInit (float *matrix);
void FASTCALL MatrixInit (float *matrix);
void MatrixMultVec3x3 (float *matrix, float *vecPtr);
void MatrixMultVec4x4 (float *matrix, float *vecPtr);
void MatrixIdentity (float *matrix);

View File

@ -23,6 +23,8 @@
#ifndef FASTCALL
#ifdef __MINGW32__
#define FASTCALL __attribute__((fastcall))
#elif defined (DESMUME_COCOA)
#define FASTCALL __attribute__((fastcall))
#elif defined (__i386__)
#define FASTCALL __attribute__((regparm(3)))
#else
@ -39,6 +41,7 @@
#endif
#ifdef DESMUME_COCOA
#define __declspec(ignore)
#ifdef __BIG_ENDIAN__
#define WORDS_BIGENDIAN
#endif