2008-09-07 14:26:38 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2008-12-07 15:42:49 -07:00
|
|
|
#include <stdarg.h>
|
|
|
|
|
2008-09-07 14:26:38 -06:00
|
|
|
#ifndef _WIN32
|
|
|
|
//#include <curses.h>
|
|
|
|
#else
|
|
|
|
#endif
|
|
|
|
|
2009-01-12 16:59:27 -07:00
|
|
|
#include "Common.h"
|
|
|
|
|
|
|
|
#if defined(HAVE_COCOA) && HAVE_COCOA
|
|
|
|
#import "cocoaApp.h"
|
|
|
|
#endif
|
2008-12-07 15:42:49 -07:00
|
|
|
|
2008-09-07 14:26:38 -06:00
|
|
|
#include "Globals.h"
|
2008-09-09 19:01:28 -06:00
|
|
|
#include "Host.h"
|
2008-09-07 14:26:38 -06:00
|
|
|
#include "ISOFile.h"
|
|
|
|
#include "CPUDetect.h"
|
2008-09-07 15:06:55 -06:00
|
|
|
#include "cmdline.h"
|
|
|
|
#include "Thread.h"
|
|
|
|
#include "PowerPC/PowerPC.h"
|
2008-09-07 14:26:38 -06:00
|
|
|
|
2009-01-12 13:52:45 -07:00
|
|
|
|
2008-09-07 14:26:38 -06:00
|
|
|
#include "BootManager.h"
|
|
|
|
void* g_pCodeWindow = NULL;
|
|
|
|
void* main_frame = NULL;
|
|
|
|
bool wxPanicAlert(const char* text, bool /*yes_no*/)
|
|
|
|
{
|
|
|
|
return(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OK, this thread boundary is DANGEROUS on linux
|
|
|
|
// wxPostEvent / wxAddPendingEvent is the solution.
|
|
|
|
void Host_NotifyMapLoaded(){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateLogDisplay(){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateDisasmDialog(){}
|
|
|
|
|
|
|
|
|
2008-09-07 15:06:55 -06:00
|
|
|
Common::Event updateMainFrameEvent;
|
|
|
|
void Host_UpdateMainFrame()
|
|
|
|
{
|
|
|
|
updateMainFrameEvent.Set();
|
|
|
|
}
|
2008-09-07 14:26:38 -06:00
|
|
|
|
|
|
|
void Host_UpdateBreakPointView(){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateMemoryView(){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_SetDebugMode(bool){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_SetWaitCursor(bool enable){}
|
|
|
|
|
|
|
|
|
|
|
|
void Host_UpdateStatusBar(const char* _pText){}
|
|
|
|
|
2008-09-09 19:01:28 -06:00
|
|
|
void Host_SysMessage(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list list;
|
|
|
|
char msg[512];
|
|
|
|
|
|
|
|
va_start(list, fmt);
|
|
|
|
vsprintf(msg, fmt, list);
|
|
|
|
va_end(list);
|
|
|
|
|
|
|
|
size_t len = strlen(msg);
|
|
|
|
if (msg[len - 1] != '\n') {
|
|
|
|
msg[len - 1] = '\n';
|
|
|
|
msg[len] = '\0';
|
|
|
|
}
|
|
|
|
fprintf(stderr, msg);
|
|
|
|
}
|
|
|
|
|
2008-12-09 15:08:40 -07:00
|
|
|
void Host_UpdateLeds(int led_bits)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void Host_UpdateSpeakerStatus(int index, int speaker_bits)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
void Host_UpdateStatus()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-10-30 10:36:45 -06:00
|
|
|
void Host_SetWiiMoteConnectionState(int _State) {}
|
|
|
|
|
2009-01-12 13:52:45 -07:00
|
|
|
|
|
|
|
//for cocoa we need to hijack the main to get event
|
|
|
|
#if defined(HAVE_COCOA) && HAVE_COCOA
|
2009-01-12 16:59:27 -07:00
|
|
|
|
|
|
|
@interface CocoaThread : NSObject
|
|
|
|
{
|
|
|
|
}
|
|
|
|
- (void)cocoaThreadStart;
|
|
|
|
- (void)cocoaThreadRun:(id)sender;
|
|
|
|
- (void)cocoaThreadQuit:(NSNotification*)note;
|
|
|
|
@end
|
|
|
|
|
|
|
|
static NSString *CocoaThreadHaveFinish = @"CocoaThreadHaveFinish";
|
|
|
|
|
|
|
|
int cocoaArgc;
|
|
|
|
char **cocoaArgv;
|
2009-01-12 13:52:45 -07:00
|
|
|
int appleMain(int argc, char *argv[]);
|
|
|
|
|
2009-01-12 16:59:27 -07:00
|
|
|
@implementation CocoaThread
|
|
|
|
|
|
|
|
- (void)cocoaThreadStart
|
|
|
|
{
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(cocoaThreadQuit:) name:CocoaThreadHaveFinish object:nil];
|
|
|
|
[NSThread detachNewThreadSelector:@selector(cocoaThreadRun:) toTarget:self withObject:nil];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)cocoaThreadRun:(id)sender
|
|
|
|
{
|
|
|
|
|
|
|
|
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
//launch main
|
|
|
|
appleMain(cocoaArgc,cocoaArgv);
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:CocoaThreadHaveFinish object:nil];
|
|
|
|
|
|
|
|
[pool release];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)cocoaThreadQuit:(NSNotification*)note
|
|
|
|
{
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-01-12 13:52:45 -07:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
|
2009-01-12 16:59:27 -07:00
|
|
|
cocoaArgc = argc;
|
|
|
|
cocoaArgv = argv;
|
|
|
|
|
2009-01-12 13:52:45 -07:00
|
|
|
cocoaCreateApp();
|
|
|
|
|
2009-01-12 16:59:27 -07:00
|
|
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
|
|
|
|
|
|
|
CocoaThread *thread = [[CocoaThread alloc] init];
|
|
|
|
NSEvent *event = [[NSEvent alloc] init];
|
|
|
|
|
|
|
|
[thread cocoaThreadStart];
|
|
|
|
|
|
|
|
//cocoa event loop
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ];
|
|
|
|
cocoaSendEvent(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[event release];
|
|
|
|
[thread release];
|
|
|
|
[pool release];
|
2009-01-12 13:52:45 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int appleMain(int argc, char *argv[])
|
|
|
|
#else
|
2008-09-07 14:26:38 -06:00
|
|
|
// Include SDL header so it can hijack main().
|
2008-12-07 10:09:40 -07:00
|
|
|
#if defined(USE_SDL) && USE_SDL
|
2008-09-07 14:26:38 -06:00
|
|
|
#include <SDL.h>
|
2008-10-20 11:32:15 -06:00
|
|
|
#endif
|
2008-09-07 14:26:38 -06:00
|
|
|
int main(int argc, char* argv[])
|
2009-01-12 13:52:45 -07:00
|
|
|
#endif
|
2008-09-07 14:26:38 -06:00
|
|
|
{
|
2008-09-07 15:02:57 -06:00
|
|
|
gengetopt_args_info args_info;
|
|
|
|
|
|
|
|
if (cmdline_parser (argc, argv, &args_info) != 0)
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
if (args_info.inputs_num < 1)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Please supply at least one argument - the ISO to boot.\n");
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
std::string bootFile(args_info.inputs[0]);
|
|
|
|
|
2008-09-07 15:06:55 -06:00
|
|
|
updateMainFrameEvent.Init();
|
2009-02-06 11:04:24 -07:00
|
|
|
cpu_info.Detect();
|
2008-09-07 15:02:57 -06:00
|
|
|
BootManager::BootCore(bootFile);
|
2008-09-07 15:06:55 -06:00
|
|
|
while (PowerPC::state != PowerPC::CPU_POWERDOWN)
|
|
|
|
{
|
|
|
|
updateMainFrameEvent.Wait();
|
|
|
|
}
|
2008-09-07 14:26:38 -06:00
|
|
|
|
2008-09-07 15:02:57 -06:00
|
|
|
cmdline_parser_free (&args_info);
|
|
|
|
return(0);
|
2008-09-07 14:26:38 -06:00
|
|
|
}
|