Commit 7fb1ff3e authored by GnoStiC's avatar GnoStiC

puae 2.3.1

parent 93f80690
......@@ -5,8 +5,9 @@
*
* Copyright 1996 Bernd Schmidt
* Copyright 2004,2010 Steven J. Saunders
* 2010 Mustafa TUFAN
* 2010,2011 Mustafa TUFAN
*/
#include <stdlib.h>
#include <stdarg.h>
......@@ -46,7 +47,6 @@ typedef unsigned int NSUInteger;
#endif
#endif
static unsigned long memsizes[] = {
/* 0 */ 0,
/* 1 */ 0x00040000, /* 256K */
......@@ -76,10 +76,7 @@ static unsigned long memsizes[] = {
#import <Cocoa/Cocoa.h>
/* The GTK GUI code seems to use 255 as max path length. Not sure why it
* doesn't use MAX_DPATH... but we will follow its example.
*/
#define COCOA_GUI_MAX_PATH 255
#define COCOA_GUI_MAX_PATH MAX_DPATH
/* These prototypes aren't declared in the sdlgfx header for some reason */
extern void toggle_fullscreen (int mode);
......@@ -101,12 +98,14 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
{
NSString *applicationName;
NSArray *diskImageTypes;
NSArray *KickRomTypes;
NSArray *FlashRamTypes;
NSArray *CartridgeTypes;
}
+ (id) sharedInstance;
- (void)createMenus;
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag;
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag
keyEquivalent:(NSString *)keyEquiv keyEquivalentMask:(NSUInteger)mask;
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag keyEquivalent:(NSString *)keyEquiv keyEquivalentMask:(NSUInteger)mask;
- (BOOL)validateMenuItem:(id <NSMenuItem>)item;
- (void)insertDisk:(id)sender;
- (void)ejectDisk:(id)sender;
......@@ -133,6 +132,8 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
- (void)changeCPU:(id)sender;
- (void)changeCPUSpeed:(id)sender;
- (void)changeFPU:(id)sender;
- (void)changeBlitter:(id)sender;
- (void)changeCollision:(id)sender;
@end
@implementation PuaeGui
......@@ -140,7 +141,6 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
+ (id) sharedInstance
{
static id sharedInstance = nil;
if (sharedInstance == nil) sharedInstance = [[self alloc] init];
return sharedInstance;
......@@ -152,12 +152,15 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (self) {
applicationName = [[NSString alloc] initWithString:getApplicationName()];
diskImageTypes =[[NSArray alloc] initWithObjects:@"adf", @"adz",
@"zip", @"dms", @"fdi",
diskImageTypes =[[NSArray alloc] initWithObjects:@"adf", @"adz", @"zip", @"dms", @"fdi",
#ifdef CAPS
@"ipf",
#endif
nil]; // Note: Use lowercase for these
KickRomTypes =[[NSArray alloc] initWithObjects:@"rom", @"roz"];
FlashRamTypes =[[NSArray alloc] initWithObjects:@"ram", @"raz"];
CartridgeTypes =[[NSArray alloc] initWithObjects:@"cart", @"rom", @"roz"];
}
return self;
......@@ -195,11 +198,34 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
// [self createMenuItemInMenu:vAmigaMenu withTitle:@"Pause" action:@selector(pauseAmiga:) tag:0];
#ifdef ACTION_REPLAY
[self createMenuItemInMenu:vAmigaMenu
withTitle:@"Action Replay Freeze"
action:@selector(actionReplayFreeze:)
tag:0];
[self createMenuItemInMenu:vAmigaMenu withTitle:@"Action Replay Freeze" action:@selector(actionReplayFreeze:) tag:0];
#endif
[vAmigaMenu addItem:[NSMenuItem separatorItem]];
// quick starts
NSMenu *quickstartMenu = [[NSMenu alloc] initWithTitle:@"QuickStart"];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 500" action:@selector(QuickStart:) tag:500];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 500+" action:@selector(QuickStart:) tag:501];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 600" action:@selector(QuickStart:) tag:600];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 1000" action:@selector(QuickStart:) tag:1000];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 1200" action:@selector(QuickStart:) tag:1200];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 3000" action:@selector(QuickStart:) tag:3000];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 4000" action:@selector(QuickStart:) tag:4000];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Amiga 4000T" action:@selector(QuickStart:) tag:4001];
[self createMenuItemInMenu:quickstartMenu withTitle:@"CD32" action:@selector(QuickStart:) tag:32];
[self createMenuItemInMenu:quickstartMenu withTitle:@"CDTV" action:@selector(QuickStart:) tag:33];
[self createMenuItemInMenu:quickstartMenu withTitle:@"Arcadia" action:@selector(QuickStart:) tag:34];
menuItem = [[NSMenuItem alloc] initWithTitle:@"QuickStart" action:nil keyEquivalent:@""];
[menuItem setSubmenu:quickstartMenu];
[vAmigaMenu addItem:menuItem];
[menuItem release];
[quickstartMenu release];
[vAmigaMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:vAmigaMenu withTitle:@"Select Kick ROM" action:@selector(selectKickROM:) tag:0];
[self createMenuItemInMenu:vAmigaMenu withTitle:@"Select Cartridge ROM" action:@selector(selectCartridge:) tag:0];
[self createMenuItemInMenu:vAmigaMenu withTitle:@"Select Flash RAM" action:@selector(selectFlashRAM:) tag:0];
[vAmigaMenu addItem:[NSMenuItem separatorItem]];
......@@ -207,45 +233,31 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
NSMenu *insertFloppyMenu = [[NSMenu alloc] initWithTitle:@"Insert Floppy"];
for (driveNumber=0; driveNumber<4; driveNumber++) {
[self createMenuItemInMenu:insertFloppyMenu
withTitle:[NSString stringWithFormat:@"DF%d...",driveNumber]
action:@selector(insertDisk:)
tag:driveNumber];
[self createMenuItemInMenu:insertFloppyMenu withTitle:[NSString stringWithFormat:@"DF%d...",driveNumber] action:@selector(insertDisk:) tag:driveNumber];
}
menuItem = [[NSMenuItem alloc] initWithTitle:@"Insert Floppy" action:nil keyEquivalent:@""];
[menuItem setSubmenu:insertFloppyMenu];
[vAmigaMenu addItem:menuItem];
[menuItem release];
[insertFloppyMenu release];
// Add menu items for ejecting from floppy drives 1 - 4
NSMenu *ejectFloppyMenu = [[NSMenu alloc] initWithTitle:@"Eject Floppy"];
[self createMenuItemInMenu:ejectFloppyMenu withTitle:@"All" action:@selector(ejectAllDisks:) tag:0];
[ejectFloppyMenu addItem:[NSMenuItem separatorItem]];
for (driveNumber=0; driveNumber<4; driveNumber++) {
[self createMenuItemInMenu:ejectFloppyMenu
withTitle:[NSString stringWithFormat:@"DF%d",driveNumber]
action:@selector(ejectDisk:)
tag:driveNumber];
[self createMenuItemInMenu:ejectFloppyMenu withTitle:[NSString stringWithFormat:@"DF%d",driveNumber] action:@selector(ejectDisk:) tag:driveNumber];
}
menuItem = [[NSMenuItem alloc] initWithTitle:@"Eject Floppy" action:nil keyEquivalent:@""];
[menuItem setSubmenu:ejectFloppyMenu];
[vAmigaMenu addItem:menuItem];
[menuItem release];
[ejectFloppyMenu release];
menuItem = [[NSMenuItem alloc] initWithTitle:@"PUAE" action:nil keyEquivalent:@""];
[menuItem setSubmenu:vAmigaMenu];
[[NSApp mainMenu] insertItem:menuItem atIndex:1];
[menuItem release];
[vAmigaMenu release];
......@@ -265,13 +277,13 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[memMenu addItem:menuItem];
[menuItem release];
NSMenu *bogoMenu = [[NSMenu alloc] initWithTitle:@"Bogo Mem"];
NSMenu *bogoMenu = [[NSMenu alloc] initWithTitle:@"Slow Mem"];
[self createMenuItemInMenu:bogoMenu withTitle:@"None" action:@selector(changeBogoMem:) tag:0];
[self createMenuItemInMenu:bogoMenu withTitle:@"512 KB" action:@selector(changeBogoMem:) tag:2];
[self createMenuItemInMenu:bogoMenu withTitle:@"1 MB" action:@selector(changeBogoMem:) tag:3];
[self createMenuItemInMenu:bogoMenu withTitle:@"1.5 MB" action:@selector(changeBogoMem:) tag:14];
[self createMenuItemInMenu:bogoMenu withTitle:@"1.8 MB" action:@selector(changeBogoMem:) tag:15];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Bogo Mem" action:nil keyEquivalent:@""];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Slow Mem" action:nil keyEquivalent:@""];
[menuItem setSubmenu:bogoMenu];
[memMenu addItem:menuItem];
[menuItem release];
......@@ -311,7 +323,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[memMenu addItem:menuItem];
[menuItem release];
NSMenu *z3chipMenu = [[NSMenu alloc] initWithTitle:@"Z3 Chip Mem"];
NSMenu *z3chipMenu = [[NSMenu alloc] initWithTitle:@"32bit Chip Mem"];
[self createMenuItemInMenu:z3chipMenu withTitle:@"None" action:@selector(changeZ3ChipMem:) tag:0];
[self createMenuItemInMenu:z3chipMenu withTitle:@"16 MB" action:@selector(changeZ3ChipMem:) tag:7];
[self createMenuItemInMenu:z3chipMenu withTitle:@"32 MB" action:@selector(changeZ3ChipMem:) tag:8];
......@@ -320,7 +332,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:z3chipMenu withTitle:@"256 MB" action:@selector(changeZ3ChipMem:) tag:11];
[self createMenuItemInMenu:z3chipMenu withTitle:@"512 MB" action:@selector(changeZ3ChipMem:) tag:12];
[self createMenuItemInMenu:z3chipMenu withTitle:@"1 GB" action:@selector(changeZ3ChipMem:) tag:13];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Z3 Chip Mem" action:nil keyEquivalent:@""];
menuItem = [[NSMenuItem alloc] initWithTitle:@"32bit Chip Mem" action:nil keyEquivalent:@""];
[menuItem setSubmenu:z3chipMenu];
[memMenu addItem:menuItem];
[menuItem release];
......@@ -350,7 +362,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[menuItem release];
// MEM MENU END
// CHIPSET MENU START
// SYSTEM MENU START
NSMenu *systemMenu = [[NSMenu alloc] initWithTitle:@"System"];
NSMenu *cpuMenu = [[NSMenu alloc] initWithTitle:@"CPU"];
......@@ -360,6 +372,12 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:cpuMenu withTitle:@"68030" action:@selector(changeCPU:) tag:3];
[self createMenuItemInMenu:cpuMenu withTitle:@"68040" action:@selector(changeCPU:) tag:4];
[self createMenuItemInMenu:cpuMenu withTitle:@"68060" action:@selector(changeCPU:) tag:6];
[cpuMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:cpuMenu withTitle:@"24-bit Addressing" action:@selector(changeCPU:) tag:10];
[self createMenuItemInMenu:cpuMenu withTitle:@"More Compatible" action:@selector(changeCPU:) tag:11];
#ifdef MMU
[self createMenuItemInMenu:cpuMenu withTitle:@"68040 MMU" action:@selector(changeCPU:) tag:12];
#endif
menuItem = [[NSMenuItem alloc] initWithTitle:@"CPU" action:nil keyEquivalent:@""];
[menuItem setSubmenu:cpuMenu];
[systemMenu addItem:menuItem];
......@@ -379,6 +397,8 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:fpuMenu withTitle:@"68881" action:@selector(changeFPU:) tag:1];
[self createMenuItemInMenu:fpuMenu withTitle:@"68882" action:@selector(changeFPU:) tag:2];
[self createMenuItemInMenu:fpuMenu withTitle:@"CPU Internal" action:@selector(changeFPU:) tag:3];
[fpuMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:fpuMenu withTitle:@"More Compatible" action:@selector(changeFPU:) tag:10];
menuItem = [[NSMenuItem alloc] initWithTitle:@"FPU" action:nil keyEquivalent:@""];
[menuItem setSubmenu:fpuMenu];
[systemMenu addItem:menuItem];
......@@ -390,23 +410,104 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:chipsetMenu withTitle:@"ECS Denise" action:@selector(changeChipset:) tag:2];
[self createMenuItemInMenu:chipsetMenu withTitle:@"ECS Full" action:@selector(changeChipset:) tag:3];
[self createMenuItemInMenu:chipsetMenu withTitle:@"AGA" action:@selector(changeChipset:) tag:4];
[chipsetMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:chipsetMenu withTitle:@"NTSC" action:@selector(changeChipset:) tag:10];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Chipset" action:nil keyEquivalent:@""];
[menuItem setSubmenu:chipsetMenu];
[systemMenu addItem:menuItem];
[menuItem release];
NSMenu *chipsetXMenu = [[NSMenu alloc] initWithTitle:@"Chipset Extra"];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"" action:@selector(changeChipsetX:) tag:0];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"Generic" action:@selector(changeChipsetX:) tag:1];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"CDTV" action:@selector(changeChipsetX:) tag:2];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"CD32" action:@selector(changeChipsetX:) tag:3];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A500" action:@selector(changeChipsetX:) tag:4];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A500+" action:@selector(changeChipsetX:) tag:5];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A600" action:@selector(changeChipsetX:) tag:6];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A1000" action:@selector(changeChipsetX:) tag:7];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A1200" action:@selector(changeChipsetX:) tag:8];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A2000" action:@selector(changeChipsetX:) tag:9];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A3000" action:@selector(changeChipsetX:) tag:10];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A3000T" action:@selector(changeChipsetX:) tag:11];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A4000" action:@selector(changeChipsetX:) tag:12];
[self createMenuItemInMenu:chipsetXMenu withTitle:@"A4000T" action:@selector(changeChipsetX:) tag:13];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Chipset Extra" action:nil keyEquivalent:@""];
[menuItem setSubmenu:chipsetXMenu];
[systemMenu addItem:menuItem];
[menuItem release];
NSMenu *blitterMenu = [[NSMenu alloc] initWithTitle:@"Blitter"];
[self createMenuItemInMenu:blitterMenu withTitle:@"Immediate Blits" action:@selector(changeBlitter:) tag:0];
[self createMenuItemInMenu:blitterMenu withTitle:@"Cycle-exact Blitter" action:@selector(changeBlitter:) tag:1];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Blitter" action:nil keyEquivalent:@""];
[menuItem setSubmenu:blitterMenu];
[systemMenu addItem:menuItem];
[menuItem release];
NSMenu *collisionMenu = [[NSMenu alloc] initWithTitle:@"Collision Level"];
[self createMenuItemInMenu:collisionMenu withTitle:@"None" action:@selector(changeCollision:) tag:0];
[self createMenuItemInMenu:collisionMenu withTitle:@"Sprites Only" action:@selector(changeCollision:) tag:1];
[self createMenuItemInMenu:collisionMenu withTitle:@"Sprites and Sprites vs. Playfield" action:@selector(changeCollision:) tag:2];
[self createMenuItemInMenu:collisionMenu withTitle:@"Full" action:@selector(changeCollision:) tag:3];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Collision Level" action:nil keyEquivalent:@""];
[menuItem setSubmenu:collisionMenu];
[systemMenu addItem:menuItem];
[menuItem release];
menuItem = [[NSMenuItem alloc] initWithTitle:@"System" action:nil keyEquivalent:@""];
[menuItem setSubmenu:systemMenu];
[[NSApp mainMenu] insertItem:menuItem atIndex:3];
[systemMenu release];
[menuItem release];
// CHIPSET MENU END
// SYSTEM MENU END
// SOUND MENU START
NSMenu *soundMenu = [[NSMenu alloc] initWithTitle:@"Sound"];
NSMenu *semuMenu = [[NSMenu alloc] initWithTitle:@"Emulation"];
[self createMenuItemInMenu:semuMenu withTitle:@"Disabled" action:@selector(changeSound:) tag:0];
[self createMenuItemInMenu:semuMenu withTitle:@"Disabled, but emulated" action:@selector(changeSound:) tag:1];
[self createMenuItemInMenu:semuMenu withTitle:@"Enabled" action:@selector(changeSound:) tag:2];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Emulation" action:nil keyEquivalent:@""];
[menuItem setSubmenu:semuMenu];
[soundMenu addItem:menuItem];
[menuItem release];
NSMenu *sfilterMenu = [[NSMenu alloc] initWithTitle:@"Filter"];
[self createMenuItemInMenu:sfilterMenu withTitle:@"Always Off" action:@selector(changeSoundFilter:) tag:0];
[self createMenuItemInMenu:sfilterMenu withTitle:@"Emulated (A500)" action:@selector(changeSoundFilter:) tag:1];
[self createMenuItemInMenu:sfilterMenu withTitle:@"Emulated (A1200)" action:@selector(changeSoundFilter:) tag:2];
[self createMenuItemInMenu:sfilterMenu withTitle:@"Always On (A500)" action:@selector(changeSoundFilter:) tag:3];
[self createMenuItemInMenu:sfilterMenu withTitle:@"Always On (A1200)" action:@selector(changeSoundFilter:) tag:4];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Filter" action:nil keyEquivalent:@""];
[menuItem setSubmenu:sfilterMenu];
[soundMenu addItem:menuItem];
[menuItem release];
NSMenu *sinterMenu = [[NSMenu alloc] initWithTitle:@"Interpolation"];
[self createMenuItemInMenu:sinterMenu withTitle:@"" action:@selector(changeSoundInterpolation:) tag:0];
[self createMenuItemInMenu:sinterMenu withTitle:@"Anti" action:@selector(changeSoundInterpolation:) tag:1];
[self createMenuItemInMenu:sinterMenu withTitle:@"Sinc" action:@selector(changeSoundInterpolation:) tag:2];
[self createMenuItemInMenu:sinterMenu withTitle:@"RH" action:@selector(changeSoundInterpolation:) tag:3];
[self createMenuItemInMenu:sinterMenu withTitle:@"Crux" action:@selector(changeSoundInterpolation:) tag:4];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Interpolation" action:nil keyEquivalent:@""];
[menuItem setSubmenu:sinterMenu];
[soundMenu addItem:menuItem];
[menuItem release];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Sound" action:nil keyEquivalent:@""];
[menuItem setSubmenu:soundMenu];
[[NSApp mainMenu] insertItem:menuItem atIndex:4];
[soundMenu release];
[menuItem release];
// SOUND MENU END
// Create a menu for changing aspects of emulator control
NSMenu *controlMenu = [[NSMenu alloc] initWithTitle:@"Control"];
NSMenu *portMenu = [[NSMenu alloc] initWithTitle:@"Game Port 0"];
[self createMenuItemInMenu:portMenu withTitle:@"None" action:@selector(changePort0:) tag:JSEM_END];
[self createMenuItemInMenu:portMenu withTitle:@"Joystick 0" action:@selector(changePort0:) tag:JSEM_JOYS];
[self createMenuItemInMenu:portMenu withTitle:@"Joystick 1" action:@selector(changePort0:) tag:JSEM_JOYS+1];
......@@ -418,16 +519,13 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:portMenu withTitle:@"X-Arcade (Left)" action:@selector(changePort0:) tag:JSEM_KBDLAYOUT+3];
[self createMenuItemInMenu:portMenu withTitle:@"X-Arcade (Right)" action:@selector(changePort0:) tag:JSEM_KBDLAYOUT+4];
#endif
menuItem = [[NSMenuItem alloc] initWithTitle:@"Game Port 0" action:nil keyEquivalent:@""];
[menuItem setSubmenu:portMenu];
[controlMenu addItem:menuItem];
[menuItem release];
[portMenu release];
portMenu = [[NSMenu alloc] initWithTitle:@"Game Port 1"];
[self createMenuItemInMenu:portMenu withTitle:@"None" action:@selector(changePort1:) tag:JSEM_END];
[self createMenuItemInMenu:portMenu withTitle:@"Joystick 0" action:@selector(changePort1:) tag:JSEM_JOYS];
[self createMenuItemInMenu:portMenu withTitle:@"Joystick 1" action:@selector(changePort1:) tag:JSEM_JOYS+1];
......@@ -439,54 +537,41 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
[self createMenuItemInMenu:portMenu withTitle:@"X-Arcade (Left)" action:@selector(changePort1:) tag:JSEM_KBDLAYOUT+3];
[self createMenuItemInMenu:portMenu withTitle:@"X-Arcade (Right)" action:@selector(changePort1:) tag:JSEM_KBDLAYOUT+4];
#endif
menuItem = [[NSMenuItem alloc] initWithTitle:@"Game Port 1" action:nil keyEquivalent:@""];
[menuItem setSubmenu:portMenu];
[controlMenu addItem:menuItem];
[menuItem release];
[portMenu release];
[self createMenuItemInMenu:controlMenu withTitle:@"Swap Port 0 and 1" action:@selector(swapGamePorts:) tag:0];
[controlMenu addItem:[NSMenuItem separatorItem]];
[self createMenuItemInMenu:controlMenu withTitle:@"Grab Mouse" action:@selector(grabMouse:) tag:0
keyEquivalent:@"g" keyEquivalentMask:NSCommandKeyMask|NSAlternateKeyMask];
[self createMenuItemInMenu:controlMenu withTitle:@"Grab Mouse" action:@selector(grabMouse:) tag:0 keyEquivalent:@"g" keyEquivalentMask:NSCommandKeyMask|NSAlternateKeyMask];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Control" action:nil keyEquivalent:@""];
[menuItem setSubmenu:controlMenu];
[[NSApp mainMenu] insertItem:menuItem atIndex:4];
[[NSApp mainMenu] insertItem:menuItem atIndex:5];
[controlMenu release];
[menuItem release];
// Create a menu for changing aspects of emulator control
NSMenu *displayMenu = [[NSMenu alloc] initWithTitle:@"Display"];
[self createMenuItemInMenu:displayMenu withTitle:@"Fullscreen" action:@selector(goFullscreen:) tag:0
keyEquivalent:@"s" keyEquivalentMask:NSCommandKeyMask|NSAlternateKeyMask];
[self createMenuItemInMenu:displayMenu withTitle:@"Fullscreen" action:@selector(goFullscreen:) tag:0 keyEquivalent:@"s" keyEquivalentMask:NSCommandKeyMask|NSAlternateKeyMask];
[self createMenuItemInMenu:displayMenu withTitle:@"Inhibit" action:@selector(toggleInhibitDisplay:) tag:0];
menuItem = [[NSMenuItem alloc] initWithTitle:@"Display" action:nil keyEquivalent:@""];
[menuItem setSubmenu:displayMenu];
[[NSApp mainMenu] insertItem:menuItem atIndex:5];
[[NSApp mainMenu] insertItem:menuItem atIndex:6];
[displayMenu release];
[menuItem release];
}
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag
{
[self createMenuItemInMenu:menu withTitle:title action:anAction tag:tag
keyEquivalent:@"" keyEquivalentMask:NSCommandKeyMask];
[self createMenuItemInMenu:menu withTitle:title action:anAction tag:tag keyEquivalent:@"" keyEquivalentMask:NSCommandKeyMask];
}
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag
keyEquivalent:(NSString *)keyEquiv keyEquivalentMask:(NSUInteger)mask
- (void)createMenuItemInMenu:(NSMenu *)menu withTitle:(NSString *)title action:(SEL)anAction tag:(int)tag keyEquivalent:(NSString *)keyEquiv keyEquivalentMask:(NSUInteger)mask
{
NSMenuItem *menuItem = [[NSMenuItem alloc] initWithTitle:title action:anAction keyEquivalent:keyEquiv];
[menuItem setKeyEquivalentModifierMask:mask];
......@@ -499,7 +584,6 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
- (BOOL)validateMenuItem:(id <NSMenuItem>)item
{
NSMenuItem *menuItem = (NSMenuItem *)item;
BOOL canSetHidden = [menuItem respondsToSelector:@selector(setHidden:)];
SEL menuAction = [menuItem action];
......@@ -566,7 +650,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
long mem_size, v;
if (menuAction == @selector(changeChipMem:)) {
mem_size = 0;
switch (currprefs.chipmem_size) {
switch (changed_prefs.chipmem_size) {
case 0x00040000: mem_size = 1; break;
case 0x00080000: mem_size = 2; break;
case 0x00100000: mem_size = 3; break;
......@@ -581,7 +665,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (menuAction == @selector(changeBogoMem:)) {
mem_size = 0;
switch (currprefs.bogomem_size) {
switch (changed_prefs.bogomem_size) {
case 0x00000000: mem_size = 0; break;
case 0x00080000: mem_size = 2; break;
case 0x00100000: mem_size = 3; break;
......@@ -593,8 +677,10 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
}
if (menuAction == @selector(changeFastMem:)) {
if (changed_prefs.chipmem_size > 0x200000) return NO;
mem_size = 0;
switch (currprefs.fastmem_size) {
switch (changed_prefs.fastmem_size) {
case 0x00000000: mem_size = 0; break;
case 0x00100000: mem_size = 3; break;
case 0x00200000: mem_size = 4; break;
......@@ -603,11 +689,15 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
}
if (mem_size == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
return YES;
}
if (menuAction == @selector(changeZ3FastMem:)) {
if (changed_prefs.address_space_24) return NO;
mem_size = 0;
v = currprefs.z3fastmem_size + currprefs.z3fastmem2_size;
v = changed_prefs.z3fastmem_size + changed_prefs.z3fastmem2_size;
if (v < 0x00100000)
mem_size = 0;
else if (v < 0x00200000)
......@@ -647,11 +737,15 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (mem_size == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
return YES;
}
if (menuAction == @selector(changeZ3ChipMem:)) {
if (changed_prefs.address_space_24) return NO;
mem_size = 0;
v = currprefs.z3chipmem_size;
v = changed_prefs.z3chipmem_size;
if (v < 0x01000000)
mem_size = 0;
else if (v < 0x02000000)
......@@ -671,11 +765,13 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (mem_size == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
return YES;
}
if (menuAction == @selector(changeGfxMem:)) {
mem_size = 0;
switch (currprefs.gfxmem_size) {
switch (changed_prefs.gfxmem_size) {
case 0x00000000: mem_size = 0; break;
case 0x00100000: mem_size = 3; break;
case 0x00200000: mem_size = 4; break;
......@@ -695,7 +791,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
if (menuAction == @selector(changeChipset:)) {
v = 0;
switch (currprefs.chipset_mask) {
switch (changed_prefs.chipset_mask) {
case 0: v = 0; break;
case 1: v = 1; break;
case 2: v = 2; break;
......@@ -705,27 +801,115 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
}
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
if (tag == 10) {
if (changed_prefs.ntscmode) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
}
if (menuAction == @selector(changeChipsetX:)) {
if (changed_prefs.cs_compatible == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (menuAction == @selector(changeCPU:)) {
v = (currprefs.cpu_model - 68000) / 10;
v = (changed_prefs.cpu_model - 68000) / 10;
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
if (tag == 10) {
if (changed_prefs.cpu_model != 68020) return NO;
if (changed_prefs.address_space_24) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (tag == 11) {
if (changed_prefs.cpu_compatible) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
#ifdef MMU
if (tag == 12) {
if (changed_prefs.mmu_model) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
#endif
return YES;
}
if (menuAction == @selector(changeCPUSpeed:)) {
if (currprefs.cpu_cycle_exact == 1) {
if (changed_prefs.cpu_cycle_exact == 1) {
v = 2;
} else {
if (currprefs.m68k_speed == -1) v = 0;
if (currprefs.m68k_speed == 0) v = 1;
if (changed_prefs.m68k_speed == -1) v = 0;
if (changed_prefs.m68k_speed == 0) v = 1;
}
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (menuAction == @selector(changeFPU:)) {
v = currprefs.fpu_model == 0 ? 0 : (currprefs.fpu_model == 68881 ? 1 : (currprefs.fpu_model == 68882 ? 2 : 3));
v = changed_prefs.fpu_model == 0 ? 0 : (changed_prefs.fpu_model == 68881 ? 1 : (changed_prefs.fpu_model == 68882 ? 2 : 3));
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
if (tag == 10) {
if (changed_prefs.fpu_strict) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (changed_prefs.cpu_model > 68030 || changed_prefs.cpu_compatible || changed_prefs.cpu_cycle_exact) {
if (tag < 3) return NO;
}
if (tag == 3) {
if (!changed_prefs.cpu_model >= 68040) {
return NO;
}
}
return YES;
}
if (menuAction == @selector(changeBlitter:)) {
if (tag == 0) {
if (changed_prefs.immediate_blits) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (tag == 1) {
if (changed_prefs.blitter_cycle_exact) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
}
if (menuAction == @selector(changeCollision:)) {
if (changed_prefs.collision_level == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (menuAction == @selector(changeSound:)) {
v = changed_prefs.produce_sound;
if (v == 3) v = 2;
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (menuAction == @selector(changeSoundInterpolation:)) {
if (changed_prefs.sound_interpol == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
if (menuAction == @selector(changeSoundFilter:)) {
v = 0;
switch (changed_prefs.sound_filter) {
case 0:
v = 0;
break;
case 1:
v = changed_prefs.sound_filter_type ? 2 : 1;
break;
case 2:
v = changed_prefs.sound_filter_type ? 4 : 3;
break;
}
if (v == tag) [menuItem setState:NSOnState];
else [menuItem setState:NSOffState];
}
......@@ -776,8 +960,10 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
{
changed_prefs.jports[0].id = [((NSMenuItem*)sender) tag];
if( changed_prefs.jports[0].id != currprefs.jports[0].id )
if (changed_prefs.jports[0].id != currprefs.jports[0].id) {
inputdevice_updateconfig (&changed_prefs);
inputdevice_config_change();
}
}
// Invoked when the user selects an option from the 'Port 1' menu
......@@ -795,6 +981,7 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
{
changed_prefs.jports[0].id = currprefs.jports[1].id;
changed_prefs.jports[1].id = currprefs.jports[0].id;
inputdevice_updateconfig (&changed_prefs);
inputdevice_config_change();
}
......@@ -867,6 +1054,174 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
}
}
// kick.rom
- (void)displayOpenPanelForKickROM:(id)sender
{
ensureNotFullscreen();
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setTitle:@"Select Kick ROM"];
// make sure setMessage (OS X 10.3+) is available before calling it
if ([oPanel respondsToSelector:@selector(setMessage:)])
[oPanel setMessage:@"Select Kick ROM"];
[oPanel setPrompt:@"Select"];
NSString *contextInfo = "";
// recall the path of kick rom that was loaded last time
NSString *nskickpath = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastUsedKickPath"];
// If the configuration includes a setting for the "kick_path" attribute
// start the OpenPanel in that directory.. but only the first time.
static int kick_run_once = 0;
if (!kick_run_once) {
kick_run_once++;
const char *kick_path = currprefs.romfile;
if (kick_path != NULL) {
char homedir[MAX_PATH];
snprintf(homedir, MAX_PATH, "%s/", getenv("HOME"));
// default value for kick_path is "$HOME/"
if (strncmp(kick_path, homedir, MAX_PATH) != 0)
nskickpath = [NSString stringWithCString:kick_path encoding:NSASCIIStringEncoding];
}
}
[oPanel beginSheetForDirectory:nskickpath file:nil
types:KickRomTypes
modalForWindow:[NSApp mainWindow]
modalDelegate:self
didEndSelector:@selector(selectKickROMPanelDidEnd:returnCode:contextInfo:)
contextInfo:contextInfo];
}
// called after kick rom selection panel
- (void)selectKickROMPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode != NSOKButton) return;
NSArray *files = [sheet filenames];
NSString *file = [files objectAtIndex:0];
lossyASCIICopy (changed_prefs.romfile, file, COCOA_GUI_MAX_PATH);
[[NSUserDefaults standardUserDefaults] setObject:[file stringByDeletingLastPathComponent] forKey:@"LastUsedKickPath"];
}
// flash.rom
- (void)displayOpenPanelForFlashRAM:(id)sender
{
ensureNotFullscreen();
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setTitle:@"Select Flash RAM"];
// make sure setMessage (OS X 10.3+) is available before calling it
if ([oPanel respondsToSelector:@selector(setMessage:)])
[oPanel setMessage:@"Select Flash RAM"];
[oPanel setPrompt:@"Select"];
NSString *contextInfo = "";
// recall the path of kick rom that was loaded last time
NSString *nsflashpath = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastUsedFlashPath"];
// If the configuration includes a setting for the "flash_path" attribute
// start the OpenPanel in that directory.. but only the first time.
static int flash_run_once = 0;
if (!flash_run_once) {
flash_run_once++;
const char *flash_path = currprefs.flashfile;
if (flash_path != NULL) {
char homedir[MAX_PATH];
snprintf(homedir, MAX_PATH, "%s/", getenv("HOME"));
// default value for flash_path is "$HOME/"
if (strncmp(flash_path, homedir, MAX_PATH) != 0)
nsflashpath = [NSString stringWithCString:flash_path encoding:NSASCIIStringEncoding];
}
}
[oPanel beginSheetForDirectory:nsflashpath file:nil
types:FlashRamTypes
modalForWindow:[NSApp mainWindow]
modalDelegate:self
didEndSelector:@selector(selectFlashRAMPanelDidEnd:returnCode:contextInfo:)
contextInfo:contextInfo];
}
// called after flash ram selection panel
- (void)selectFlashRAMPanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode != NSOKButton) return;
NSArray *files = [sheet filenames];
NSString *file = [files objectAtIndex:0];
lossyASCIICopy (changed_prefs.flashfile, file, COCOA_GUI_MAX_PATH);
[[NSUserDefaults standardUserDefaults] setObject:[file stringByDeletingLastPathComponent] forKey:@"LastUsedFlashPath"];
}
// cartridge rom
- (void)displayOpenPanelForCartridge:(id)sender
{
ensureNotFullscreen();
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
[oPanel setTitle:@"Select Cartridge ROM"];
// make sure setMessage (OS X 10.3+) is available before calling it
if ([oPanel respondsToSelector:@selector(setMessage:)])
[oPanel setMessage:@"Select Cartridge ROM"];
[oPanel setPrompt:@"Select"];
NSString *contextInfo = "";
// recall the path of kick rom that was loaded last time
NSString *nscartpath = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastUsedCartPath"];
// If the configuration includes a setting for the "cart_path" attribute
// start the OpenPanel in that directory.. but only the first time.
static int cart_run_once = 0;
if (!cart_run_once) {
cart_run_once++;
const char *cart_path = currprefs.cartfile;
if (cart_path != NULL) {
char homedir[MAX_PATH];
snprintf(homedir, MAX_PATH, "%s/", getenv("HOME"));
// default value for cart_path is "$HOME/"
if (strncmp(cart_path, homedir, MAX_PATH) != 0)
nscartpath = [NSString stringWithCString:cart_path encoding:NSASCIIStringEncoding];
}
}
[oPanel beginSheetForDirectory:nscartpath file:nil
types:CartridgeTypes
modalForWindow:[NSApp mainWindow]
modalDelegate:self
didEndSelector:@selector(selectCartridgePanelDidEnd:returnCode:contextInfo:)
contextInfo:contextInfo];
}
// called after cartridge rom selection panel
- (void)selectCartridgePanelDidEnd:(NSOpenPanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
if (returnCode != NSOKButton) return;
NSArray *files = [sheet filenames];
NSString *file = [files objectAtIndex:0];
lossyASCIICopy (changed_prefs.cartfile, file, COCOA_GUI_MAX_PATH);
[[NSUserDefaults standardUserDefaults] setObject:[file stringByDeletingLastPathComponent] forKey:@"LastUsedCartPath"];
}
- (void)hebeHebe:(id)sender
{
NSRect frame = NSMakeRect(100, 100, 200, 200);
......@@ -955,12 +1310,41 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
// chipset
- (void)changeChipset:(id)sender
{
if ([((NSMenuItem*)sender) tag] < 10) {
changed_prefs.chipset_mask = [((NSMenuItem*)sender) tag];
} else {
changed_prefs.ntscmode = !changed_prefs.ntscmode;
}
}
// chipset extra
- (void)changeChipsetX:(id)sender
{
changed_prefs.cs_compatible = [((NSMenuItem*)sender) tag];
built_in_chipset_prefs (&changed_prefs);
}
// blitter
- (void)changeBlitter:(id)sender
{
if ([((NSMenuItem*)sender) tag] == 0)
changed_prefs.immediate_blits = !changed_prefs.immediate_blits;
if ([((NSMenuItem*)sender) tag] == 1)
changed_prefs.blitter_cycle_exact = !changed_prefs.blitter_cycle_exact;
config_changed = 1;
}
// collision
- (void)changeCollision:(id)sender
{
changed_prefs.collision_level = [((NSMenuItem*)sender) tag];
config_changed = 1;
}
// cpu
- (void)changeCPU:(id)sender
{
if ([((NSMenuItem*)sender) tag] < 10) {
unsigned int newcpu, newfpu;
newcpu = 68000 + ([((NSMenuItem*)sender) tag] * 10);
newfpu = changed_prefs.fpu_model;
......@@ -994,8 +1378,21 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
changed_prefs.address_space_24 = 0;
break;
}
} else {
switch ([((NSMenuItem*)sender) tag]) {
case 10:
changed_prefs.address_space_24 = !changed_prefs.address_space_24;
break;
case 11:
changed_prefs.cpu_compatible = !changed_prefs.cpu_compatible;
break;
#ifdef MMU
case 12:
// changed_prefs.mmu_model = 68040;
break;
#endif
}
}
}
// cpu speed
......@@ -1015,6 +1412,17 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
changed_prefs.m68k_speed = 0;
changed_prefs.cpu_cycle_exact = 1;
}
changed_prefs.blitter_cycle_exact = changed_prefs.cpu_cycle_exact;
if (changed_prefs.cpu_cycle_exact) {
if (changed_prefs.cpu_model == 68000)
changed_prefs.cpu_compatible = 1;
if (changed_prefs.cpu_model <= 68020)
changed_prefs.m68k_speed = 0;
changed_prefs.immediate_blits = 0;
changed_prefs.gfx_framerate = 1;
changed_prefs.cachesize = 0;
}
}
// fpu
......@@ -1022,9 +1430,72 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
{
unsigned int v;
v = [((NSMenuItem*)sender) tag];
/* if (v == 1) v = 68881;
if (v < 10) {
/* if (v == 1) v = 68881;
if (v == 2) v = 68882;*/
changed_prefs.fpu_model = v;
} else {
changed_prefs.fpu_strict = !changed_prefs.fpu_strict;
}
}
// sound
- (void)changeSound:(id)sender
{
changed_prefs.produce_sound = [((NSMenuItem*)sender) tag];
config_changed = 1;
}
// sound interpolation
- (void)changeSoundInterpolation:(id)sender
{
changed_prefs.sound_interpol = [((NSMenuItem*)sender) tag];
config_changed = 1;
}
// sound filter
- (void)changeSoundFilter:(id)sender
{
switch ([((NSMenuItem*)sender) tag]) {
case 0:
changed_prefs.sound_filter = 0;
break;
case 1:
changed_prefs.sound_filter = 1;
changed_prefs.sound_filter_type = 0;
break;
case 2:
changed_prefs.sound_filter = 1;
changed_prefs.sound_filter_type = 1;
break;
case 3:
changed_prefs.sound_filter = 2;
changed_prefs.sound_filter_type = 0;
break;
case 4:
changed_prefs.sound_filter = 2;
changed_prefs.sound_filter_type = 1;
break;
}
config_changed = 1;
}
// select kick rom
- (void)selectKickROM:(id)sender
{
[self displayOpenPanelForKickROM:[((NSMenuItem*)sender) tag]];
}
// select flash ram
- (void)selectFlashRAM:(id)sender
{
[self displayOpenPanelForFlashRAM:[((NSMenuItem*)sender) tag]];
}
// select cartridge rom
- (void)selectCartridge:(id)sender
{
[self displayOpenPanelForCartridge:[((NSMenuItem*)sender) tag]];
}
@end
......@@ -1034,18 +1505,19 @@ static BOOL wasFullscreen = NO; // used by ensureNotFullscreen() and restoreFull
*/
int ensureNotFullscreen (void)
{
int result = 0;
unsigned int result = 0;
if (is_fullscreen ()) {
toggle_fullscreen (0);
if (is_fullscreen ())
if (is_fullscreen ()) {
write_log ("Cannot activate GUI in full-screen mode\n");
else {
} else {
result = 1;
wasFullscreen = YES;
}
}
#ifdef USE_SDL
// Un-hide the mouse
SDL_ShowCursor(SDL_ENABLE);
......@@ -1060,7 +1532,6 @@ void restoreFullscreen (void)
// Re-hide the mouse
SDL_ShowCursor(SDL_DISABLE);
#endif
if ((!is_fullscreen ()) && (wasFullscreen == YES))
toggle_fullscreen(0);
......@@ -1140,7 +1611,7 @@ void gui_handle_events (void)
void gui_display (int shortcut)
{
int result;
//int result;
if ((shortcut >= 0) && (shortcut < 4)) {
[[PuaeGui sharedInstance] displayOpenPanelForInsertIntoDriveNumber:shortcut];
......
......@@ -169,7 +169,7 @@ static void trim (TCHAR *s)
s[_tcslen(s) - 1] = 0;
}
int isharddrive (const TCHAR *name)
static int isharddrive (const TCHAR *name)
{
int i;
......@@ -271,7 +271,8 @@ int hdf_open_target (struct hardfiledata *hfd, const char *pname)
i--;
}
if (h != INVALID_HANDLE_VALUE) {
size_t ret, low;
size_t ret;
int low;
ret = fseek (h, 0, SEEK_END);
if (ret)
goto end;
......@@ -478,7 +479,7 @@ int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int
if (hfd->drive_empty)
return 0;
if (offset < hfd->virtual_size) {
uae_u64 len2 = offset + len <= hfd->virtual_size ? len : hfd->virtual_size - offset;
uae_u64 len2 = offset + (unsigned)len <= hfd->virtual_size ? (unsigned)len : hfd->virtual_size - offset;
if (!hfd->virtual_rdb)
return 0;
memcpy (buffer, hfd->virtual_rdb + offset, len2);
......@@ -486,7 +487,7 @@ int hdf_read_target (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int
}
offset -= hfd->virtual_size;
while (len > 0) {
int maxlen;
unsigned int maxlen;
size_t ret;
if (hfd->physsize < CACHE_SIZE) {
hfd->cache_valid = 0;
......
......@@ -22,5 +22,8 @@ extern void write_log (const char *, ...) PRINTF_FORMAT;
extern void flush_log (void);
extern void set_logfile (const char *logfile_name);
extern void uae_reset (int);
extern void jit_abort (const char *fmt, ...);
extern void write_dlog (const char *format, ...);
extern char *setconsolemode (char *buffer, int maxlen);
#endif /* WRITELOG_H */
......@@ -66,7 +66,7 @@ extern struct zfile *zfile_gunzip (struct zfile *z);
extern int zfile_is_diskimage (const TCHAR *name);
extern int iszip (struct zfile *z);
extern int zfile_convertimage (const TCHAR *src, const TCHAR *dst);
//extern struct zfile *zuncompress (struct znode*, struct zfile *z, int dodefault, int mask, int *retcode, int index);
//extern struct zfile *zuncompress (struct znode *parent, struct zfile *z, int dodefault, int mask, int *retcode, int index);
extern void zfile_seterror (const TCHAR *format, ...);
extern TCHAR *zfile_geterror (void);
extern int zfile_truncate (struct zfile *z, uae_s64 size);
......@@ -106,6 +106,7 @@ extern const TCHAR *uae_diskimageextensions[];
extern struct zvolume *zfile_fopen_archive (const TCHAR *filename);
extern struct zvolume *zfile_fopen_archive2 (const TCHAR *filename, int flags);
extern struct zvolume *zfile_fopen_archive_root (const TCHAR *filename, int flags);
extern struct zvolume *zvolume_alloc_nofile (const TCHAR *name, unsigned int id, void *handle, const TCHAR *volumename);
extern void zfile_fclose_archive (struct zvolume *zv);
extern int zfile_fs_usage_archive (const TCHAR *path, const TCHAR *disk, struct fs_usage *fsp);
extern int zfile_stat_archive (const TCHAR *path, struct _stat64 *statbuf);
......
/*
* PUAE - The Un*x Amiga Emulator
*
* A collection of ugly and random stuff brought in from Win32
* which desparately needs to be tidied up
*
*
* Copyright 2004 Richard Drummond
* Copyright 2010-2011 Mustafa TUFAN
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "misc.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
......@@ -23,6 +27,9 @@
#include "keymap/keymap.h"
#include "keyboard.h"
#include <stdarg.h>
#include "clipboard.h"
#include "fsdb.h"
#include "debug.h"
#define TRUE 1
#define FALSE 0
......@@ -61,12 +68,17 @@ static struct winuae_currentmode *currentmode = &currentmodestruct;
static int serial_period_hsyncs, serial_period_hsync_counter;
static int data_in_serdatr; /* new data received */
// --- dinput.cpp START ---
// dinput
int rawkeyboard = -1;
static bool rawinput_enabled_mouse, rawinput_enabled_keyboard;
int no_rawinput;
int is_tablet (void)
{
return tablet ? 1 : 0;
}
//win32gfx
void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp)
{
*dxp = 0;
......@@ -75,11 +87,6 @@ void getgfxoffset (int *dxp, int *dyp, int *mxp, int *myp)
*myp = 0;
}
int is_tablet (void)
{
return tablet ? 1 : 0;
}
int vsync_switchmode (int hz, int oldhz)
{
static int tempvsync;
......@@ -99,6 +106,7 @@ int vsync_switchmode (int hz, int oldhz)
hz = hz * dbl;
found = NULL;
/* for (i = 0; md->DisplayModes[i].depth >= 0 && !found; i++) {
struct PicassoResolution *r = &md->DisplayModes[i];
if (r->res.width == w && r->res.height == h && r->depth == d) {
......@@ -147,6 +155,7 @@ int vsync_switchmode (int hz, int oldhz)
return 0;
}
// serial_win32
void serial_check_irq (void)
{
if (data_in_serdatr)
......@@ -179,6 +188,7 @@ void serial_hsynchandler (void)
*/
}
//win32
/*
static int drvsampleres[] = {
IDR_DRIVE_CLICK_A500_1, DS_CLICK,
......@@ -189,6 +199,8 @@ static int drvsampleres[] = {
-1
};
*/
// driveclick_win32
int driveclick_loadresource (struct drvsample *sp, int drivetype)
{
/*
......@@ -307,8 +319,10 @@ static int driveclick_fdrawcmd_init(int drive)
uae_start_thread ("DriveClick", driveclick_thread, NULL, NULL);
return 1;
*/
return 1;
}
// win32
uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
{
#ifdef _WIN32
......@@ -344,8 +358,10 @@ uae_u32 emulib_target_getcpurate (uae_u32 v, uae_u32 *low)
return t2-t1;
*/
#endif
return 0;
}
void setmouseactivexy (int x, int y, int dir)
{
/* int diff = 8;
......@@ -378,6 +394,7 @@ void setmouseactive (int active)
{
}
// unicode
char *au_fs_copy (char *dst, int maxlen, const char *src)
{
unsigned int i;
......@@ -388,6 +405,7 @@ char *au_fs_copy (char *dst, int maxlen, const char *src)
return dst;
}
// fsdb_mywin32
int my_existsfile (const char *name)
{
struct stat sonuc;
......@@ -425,7 +443,7 @@ int my_getvolumeinfo (const char *root)
return ret;
}
// clipboard.c
// clipboard
static uaecptr clipboard_data;
static int vdelay, signaling, initialized;
......@@ -465,7 +483,7 @@ void amiga_clipboard_got_data (uaecptr data, uae_u32 size, uae_u32 actual)
}
}
// win32
int get_guid_target (uae_u8 *out)
{
unsigned Data1, Data2, Data3, Data4;
......@@ -488,10 +506,7 @@ int get_guid_target (uae_u8 *out)
return 1;
}
static int testwritewatch (void)
{
}
// win32gfx
void machdep_free (void)
{
}
......@@ -501,7 +516,7 @@ void target_run (void)
//shellexecute (currprefs.win32_commandpathstart);
}
// --- dinput.cpp ---
// dinput
int input_get_default_keyboard (int i)
{
if (rawinput_enabled_keyboard) {
......@@ -513,7 +528,7 @@ int input_get_default_keyboard (int i)
}
}
// --- unicode.cpp ---
// unicode
static unsigned int fscodepage;
char *ua_fs (const char *s, int defchar)
......@@ -528,7 +543,7 @@ char *ua_copy (char *dst, int maxlen, const char *src)
return dst;
}
// --- win32gui.cpp ---
// win32gui
static int qs_override;
int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isdefault)
......@@ -586,7 +601,7 @@ int target_cfgfile_load (struct uae_prefs *p, char *filename, int type, int isde
return v;
}
// --- win32gfx.c
// win32gfx
int screen_is_picasso = 0;
struct uae_filter *usedfilter;
uae_u32 redc[3 * 256], grec[3 * 256], bluc[3 * 256];
......@@ -603,7 +618,7 @@ int isfullscreen (void)
return isfullscreen_2 (&currprefs);
}
// --- win32.c
// win32
uae_u8 *save_log (int bootlog, int *len)
{
FILE *f;
......@@ -672,7 +687,7 @@ void refreshtitle (void)
*/
}
// win32gui.c
// win32gui
#define MAX_ROM_PATHS 10
int scan_roms (int show)
{
......@@ -696,7 +711,7 @@ end:
return ret;
}
// dinput.c
// dinput
int input_get_default_lightpen (struct uae_input_device *uid, int i, int port, int af)
{
/* struct didata *did;
......@@ -782,7 +797,7 @@ void setid_af (struct uae_input_device *uid, int i, int slot, int sub, int port,
uid[i].flags[slot][sub] |= ID_FLAG_TOGGLE;
}
// win32.c
// win32
void target_quit (void)
{
//shellexecute (currprefs.win32_commandpathend);
......@@ -876,7 +891,8 @@ TCHAR *au_copy (TCHAR *dst, int maxlen, const char *src)
memcpy (dst, src, maxlen);
return dst;
}
//writelog.cpp
// writelog
int consoleopen = 0;
static int realconsole = 1;
......@@ -913,7 +929,7 @@ void debugger_change (int mode)
// regsetint (NULL, "DebuggerType", debugger_type);
openconsole ();
}
// unicode.c
// unicode
char *ua (const TCHAR *s)
{
return s;
......@@ -927,7 +943,7 @@ char *utf8u (const char *s)
return s;
}
// fsdb_mywin32.c
// fsdb_mywin32
FILE *my_opentext (const TCHAR *name)
{
FILE *f;
......@@ -964,7 +980,6 @@ int ispressed (int key)
return 0;
}
static int specialkeycode (void)
{
return 0; //currprefs.win32_specialkey;
......@@ -997,9 +1012,9 @@ int getcapslock (void)
int capstable[7];
// this returns bogus state if caps change when in exclusive mode..
/* host_capslockstate = GetKeyState (VK_CAPITAL) & 1;
host_numlockstate = GetKeyState (VK_NUMLOCK) & 1;
host_scrolllockstate = GetKeyState (VK_SCROLL) & 1;*/
host_capslockstate = 1; //GetKeyState (VK_CAPITAL) & 1;
host_numlockstate = 0; //GetKeyState (VK_NUMLOCK) & 1;
host_scrolllockstate = 0; //GetKeyState (VK_SCROLL) & 1;
capstable[0] = DIK_CAPITAL;
capstable[1] = host_capslockstate;
capstable[2] = DIK_NUMLOCK;
......@@ -1030,17 +1045,22 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
if (scancode == specialkeycode ())
return;
/* if (scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
code = AKS_QUIT;*/
#ifdef WIN32
if (scancode == DIK_F11 && currprefs.win32_ctrl_F11_is_quit && ctrlpressed ())
code = AKS_QUIT;
#endif
scancode_new = scancode;
if (!specialpressed () && inputdevice_iskeymapped (keyboard, scancode))
scancode = 0;
#ifdef WIN32
// GUI must be always available
/* if (scancode_new == DIK_F12 && currprefs.win32_guikey < 0)
if (scancode_new == DIK_F12 && currprefs.win32_guikey < 0)
scancode = scancode_new;
if (scancode_new == currprefs.win32_guikey && scancode_new != DIK_F12)
scancode = scancode_new;*/
scancode = scancode_new;
#endif
// write_log ("kbd1 = %d, scancode = %d (0x%02x), state = %d\n", keyboard, scancode, scancode, newstate);
......@@ -1053,7 +1073,6 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
}
}
if (newstate && code == 0) {
if (scancode == DIK_F12 /*|| scancode == currprefs.win32_guikey*/) {
if (ctrlpressed ()) {
......@@ -1198,7 +1217,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
}
scancode = scancode_new;
/* if (!specialpressed () && newstate) {
if (!specialpressed () && newstate) {
if (scancode == DIK_CAPITAL) {
host_capslockstate = host_capslockstate ? 0 : 1;
capslockstate = host_capslockstate;
......@@ -1211,7 +1230,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
host_scrolllockstate = host_scrolllockstate ? 0 : 1;
capslockstate = host_scrolllockstate;
}
}*/
}
if (specialpressed ())
return;
......@@ -1220,7 +1239,7 @@ void my_kbd_handler (int keyboard, int scancode, int newstate)
inputdevice_translatekeycode (keyboard, scancode, newstate);
}
//win32gfx
// win32gfx
#define MAX_DISPLAYS 10
struct MultiDisplay Displays[MAX_DISPLAYS];
......@@ -1309,7 +1328,7 @@ void addmode (struct MultiDisplay *md, int w, int h, int d, int rate, int nondx)
md->DisplayModes[i].res.width, md->DisplayModes[i].res.height, md->DisplayModes[i].depth * 8);
}
//dxwrap
// dxwrap
int DirectDraw_CurrentRefreshRate (void)
{
//DirectDraw_GetDisplayMode ();
......@@ -1331,7 +1350,7 @@ int D3D_goodenough (void)
return 0;
}
//debug_win32
// debug_win32
void update_debug_info(void)
{
}
/*
* UAE - The Un*x Amiga Emulator
/*
* PUAE - The Un*x Amiga Emulator
*
* OS-specific memory support functions
*
* Copyright 2004 Richard Drummond
* Copyright 2010 Mustafa Tufan
*/
#include "sysconfig.h"
......@@ -110,6 +111,13 @@ void preinit_shm (void)
uae_u64 totalphys64;
uae_u32 max_allowed_mman;
if (natmem_offset)
free (natmem_offset);
natmem_offset = NULL;
if (p96mem_offset)
free (p96mem_offset);
p96mem_offset = NULL;
#ifdef CPU_64_BIT
max_allowed_mman = 2048;
#else
......@@ -202,7 +210,7 @@ restart:
write_log ("NATMEM: retrying %d..\n", rounds);
rounds++;
if (natmem_offset)
free(natmem_offset);
free (natmem_offset);
natmem_offset = NULL;
natmem_offset_end = NULL;
canbang = 0;
......@@ -216,13 +224,15 @@ restart:
size = 0x10000000;
if (currprefs.z3fastmem_size || currprefs.z3fastmem2_size || currprefs.z3chipmem_size) {
z3size = currprefs.z3fastmem_size + currprefs.z3fastmem2_size + currprefs.z3chipmem_size + (currprefs.z3fastmem_start - 0x10000000);
if (currprefs.gfxmem_size)
rtgbarrier = 16 * 1024 * 1024;
if (currprefs.gfxmem_size) {
rtgbarrier = 16 * 1024 * 1024 - ((currprefs.z3fastmem_size + currprefs.z3fastmem2_size) & 0x00ffffff);
}
if (currprefs.z3chipmem_size && (currprefs.z3fastmem_size || currprefs.z3fastmem2_size))
z3chipbarrier = 16 * 1024 * 1024;
} else {
rtgbarrier = 0;
}
totalsize = size + z3size + currprefs.gfxmem_size;
while (totalsize > size64) {
int change = lowmem ();
......@@ -281,11 +291,11 @@ restart:
if (!natmem_offset) {
write_log ("NATMEM: No special area could be allocated! (1) err=%d\n", errno);
} else {
write_log ("NATMEM: Our special area: 0x%p-0x%p (%08x %dM)\n",
write_log ("NATMEM: Our special area: %p-%p (%08x %dM)\n",
natmem_offset, (uae_u8*)natmem_offset + natmemsize,
natmemsize, natmemsize >> 20);
if (currprefs.gfxmem_size)
write_log ("NATMEM: P96 special area: 0x%p-0x%p (%08x %dM)\n",
write_log ("NATMEM: P96 special area: %p-%p (%08x %dM)\n",
p96mem_offset, (uae_u8*)p96mem_offset + currprefs.gfxmem_size,
currprefs.gfxmem_size, currprefs.gfxmem_size >> 20);
canbang = 1;
......@@ -489,7 +499,7 @@ void *my_shmat (int shmid, void *shmaddr, int shmflg)
if (shmids[shmid].key == shmid && shmids[shmid].size) {
shmids[shmid].mode = 0;
shmids[shmid].natmembase = natmem_offset;
write_log ("SHMAddr %s %p = 0x%p - 0x%p\n", shmids[shmid].name, (uae_u8*)shmaddr-natmem_offset, shmaddr, natmem_offset);
write_log ("SHMAddr %s %p = %p - %p\n", shmids[shmid].name, (uae_u8*)shmaddr-natmem_offset, shmaddr, natmem_offset);
// if (shmaddr)
// free (shmaddr);
result = valloc (/*shmaddr,*/ size);
......
......@@ -82,7 +82,7 @@ static void trap_HandleExtendedTrap (TrapHandler, int has_retval);
uaecptr find_trap (const TCHAR *name)
{
int i;
unsigned int i;
for (i = 0; i < trap_count; i++) {
struct Trap *trap = &traps[i];
......@@ -109,7 +109,7 @@ unsigned int define_trap (TrapHandler handler_func, int flags, const TCHAR *name
abort ();
return -1;
} else {
int i;
unsigned int i;
unsigned int trap_num;
struct Trap *trap;
uaecptr addr = here ();
......
......@@ -124,10 +124,10 @@ static uae_u32 REGPARAM2 uaeexe_server (TrapContext *context)
dst = (char*)get_real_address (ARG (0));
len = ARG (1);
s = ua (cmd);
strncpy (dst, s, len);
// s = ua (cmd);
strncpy (dst, cmd, len);
write_log ("Sending '%s' to remote cli\n", cmd);
xfree (s);
// xfree (s);
xfree (cmd);
return ARG (0);
}
......@@ -27,6 +27,8 @@
#include "audio.h"
#include "picasso96.h"
#include "version.h"
#include "filesys.h"
#include "misc.h"
/*
* Returns UAE Version
......@@ -246,10 +248,10 @@ static uae_u32 emulib_GetUaeConfig (uaecptr place)
put_byte (place + 35, 1);
for (j = 0; j < 4; j++) {
char *s = ua (currprefs.floppyslots[j].df);
// char *s = ua (currprefs.floppyslots[j].df);
for (i = 0; i < 256; i++)
put_byte (place + 36 + i + j * 256, s[i]);
xfree (s);
put_byte (place + 36 + i + j * 256, currprefs.floppyslots[j].df[i]);
// xfree (s);
}
return 1;
}
......@@ -341,7 +343,8 @@ static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
{
TCHAR tmp[MAX_DPATH];
char *s;
int v, i;
int v;
unsigned int i;
if (mode)
return -1;
......@@ -351,12 +354,12 @@ static int native_dos_op (uae_u32 mode, uae_u32 p1, uae_u32 p2, uae_u32 p3)
v = get_native_path (p1, tmp);
if (v)
return v;
s = ua (tmp);
for (i = 0; i <= strlen (s) && i < p3 - 1; i++) {
put_byte (p2 + i, s[i]);
//s = ua (tmp);
for (i = 0; i <= strlen (tmp) && i < p3 - 1; i++) {
put_byte (p2 + i, tmp[i]);
put_byte (p2 + i + 1, 0);
}
xfree (s);
//xfree (s);
return 0;
}
#ifndef UAEGFX_INTERNAL
......
......@@ -96,6 +96,7 @@ void flush_log (void)
fflush (logfile ? logfile : stderr);
}
// Write Debug Log
void write_dlog (const char *format, ...)
{
......
......@@ -32,6 +32,7 @@
#include "archivers/wrp/warp.h"
#include <zlib.h>
#include <stdarg.h>
#include "misc.h"
static struct zfile *zlist = 0;
......@@ -1465,7 +1466,7 @@ static struct zfile *openzip (const TCHAR *pname)
_tcscpy (name, pname);
i = _tcslen (name) - 2;
while (i > 0) {
if (name[i] == '/' || name[i] == '\\' && i > 4) {
if ((name[i] == '/' || name[i] == '\\') && i > 4) {
v = name[i];
name[i] = 0;
for (j = 0; plugins_7z[j]; j++) {
......@@ -1989,8 +1990,8 @@ size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z)
l2 = (z->size - z->seek) / l1;
else
l2 = 0;
if (l2 < 0)
l2 = 0;
// if (l2 < 0)
// l2 = 0;
}
memcpy (b, z->data + z->offset + z->seek, l1 * l2);
z->seek += l1 * l2;
......@@ -2006,8 +2007,8 @@ size_t zfile_fread (void *b, size_t l1, size_t l2, struct zfile *z)
l2 = (size - v) / l1;
else
l2 = 0;
if (l2 < 0)
l2 = 0;
// if (l2 < 0)
// l2 = 0;
}
zfile_fseek (z->parent, z->seek + z->offset, SEEK_SET);
v = z->seek;
......@@ -2102,7 +2103,7 @@ TCHAR *zfile_fgets (TCHAR *s, int size, struct zfile *z)
p++;
}
*p = 0;
if (size > strlen (s2) + 1)
if ((unsigned)size > strlen (s2) + 1)
size = strlen (s2) + 1;
au_copy (s, size, s2);
return s + size;
......@@ -2112,7 +2113,7 @@ TCHAR *zfile_fgets (TCHAR *s, int size, struct zfile *z)
s1 = fgets (s2, size, z->f);
if (!s1)
return NULL;
if (size > strlen (s2) + 1)
if ((unsigned)size > strlen (s2) + 1)
size = strlen (s2) + 1;
au_copy (s, size, s2);
return s + size;
......@@ -2178,7 +2179,7 @@ int zfile_zuncompress (void *dst, int dstsize, struct zfile *src, int srcsize)
int left = srcsize - incnt;
if (left == 0)
break;
if (left > sizeof (inbuf))
if ((unsigned)left > sizeof (inbuf))
left = sizeof (inbuf);
zs.next_in = inbuf;
zs.avail_in = zfile_fread (inbuf, 1, left, src);
......@@ -2659,7 +2660,7 @@ static struct znode *get_znode (struct zvolume *zv, const TCHAR *ppath, int recu
return zn;
} else {
int len = _tcslen (zpath);
if (_tcslen (path) >= len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !_tcsnicmp (zpath, path, len)) {
if (_tcslen (path) >= (unsigned)len && (path[len] == 0 || path[len] == FSDB_DIR_SEPARATOR) && !_tcsnicmp (zpath, path, len)) {
if (path[len] == 0)
return zn;
if (zn->vchild) {
......
......@@ -844,10 +844,10 @@ static void recurseadf (struct znode *zn, int root, TCHAR *name)
return;
if (gl (adf, 0) != 2)
break;
if (gl (adf, 1 * 4) != block)
if (gl (adf, 1 * 4) != (unsigned)block)
break;
secondary = gl (adf, bs - 1 * 4);
if (secondary != -3 && secondary != 2)
if (/*secondary != -3 &&*/ secondary != 2)
break;
memset (&zai, 0, sizeof zai);
fname = getBSTR (adf->block + bs - 20 * 4);
......@@ -860,7 +860,7 @@ static void recurseadf (struct znode *zn, int root, TCHAR *name)
}
_tcscat (name2, fname);
zai.name = name2;
if (size < 0 || size > 0x7fffffff)
if (/*size < 0 ||*/ size > 0x7fffffff)
size = 0;
zai.size = size;
zai.flags = gl (adf, bs - 48 * 4);
......@@ -1134,7 +1134,7 @@ static int sfsfindblock (struct adfhandle *adf, int btree, int theblock, struct
blocks = glx (p + 12);
else
blocks = gwx (p + 12);
if (key == theblock) {
if (key == (unsigned)theblock) {
struct sfsblock *sb;
if (*sfsblockcnt >= *sfsmaxblockcnt) {
*sfsmaxblockcnt += 100;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment