osx: allow exit with button. clean exit

terminate network in dc_term to avoid static init order issues
osx: call dc_term before exit
osx: exit app when exit button is pressed (dc_exit)
osx: ignore -NSDoc... app args
This commit is contained in:
Flyinghead 2020-04-23 11:46:34 +02:00
parent 1d1cd347ef
commit adfe30cf4c
8 changed files with 28 additions and 14 deletions

View File

@ -129,6 +129,13 @@ bool ParseCommandLine(int argc,char* argv[])
cl-=as;
arg+=as;
}
#ifdef __MACH__
else if (!strncmp(*arg, "-NSDocumentRevisions", 20))
{
arg++;
cl--;
}
#endif
else
{
char* extension = strrchr(*arg, '.');

View File

@ -14,6 +14,7 @@
#include "naomi_cart.h"
#include "naomi_regs.h"
#include "naomi_m3comm.h"
#include "network/naomi_network.h"
//#define NAOMI_COMM
@ -539,6 +540,7 @@ void naomi_reg_Term()
}
#endif
m3comm.closeNetwork();
naomiNetwork.terminate();
}
void naomi_reg_Reset(bool hard)
@ -571,6 +573,7 @@ void naomi_reg_Reset(bool hard)
reg_dimm_parameterh = 0;
reg_dimm_status = 0x11;
m3comm.closeNetwork();
naomiNetwork.terminate();
}
static u8 aw_maple_devs;

View File

@ -83,12 +83,6 @@ void NaomiM3Comm::sendNetwork()
}
}
NaomiM3Comm::~NaomiM3Comm()
{
closeNetwork();
naomiNetwork.terminate();
}
u32 NaomiM3Comm::ReadMem(u32 address, u32 size)
{
switch (address & 255)

View File

@ -28,7 +28,6 @@
class NaomiM3Comm
{
public:
~NaomiM3Comm();
u32 ReadMem(u32 address, u32 size);
void WriteMem(u32 address, u32 data, u32 size);
bool DmaStart(u32 addr, u32 data);

View File

@ -21,7 +21,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
func applicationWillTerminate(_ aNotification: Notification) {
emu_dc_exit()
emu_dc_term()
}
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {

View File

@ -67,8 +67,10 @@ class EmuGLView: NSOpenGLView, NSWindowDelegate {
@objc func timerTick() {
if (emu_frame_pending())
{
if (!emu_renderer_enabled()) {
NSApplication.shared.terminate(self)
}
else if (emu_frame_pending()) {
self.needsDisplay = true
}
}
@ -154,8 +156,4 @@ class EmuGLView: NSOpenGLView, NSWindowDelegate {
self.window!.delegate = self
self.window!.acceptsMouseMovedEvents = true
}
func windowWillClose(_ notification: Notification) {
emu_dc_exit()
}
}

View File

@ -11,6 +11,8 @@
#include <MacTypes.h>
void emu_dc_exit();
void emu_dc_term();
bool emu_renderer_enabled();
int emu_single_frame(int w, int h);
void emu_gles_init(int width, int height);
int emu_reicast_init();

View File

@ -25,6 +25,7 @@
#include "stdclass.h"
#include "wsi/context.h"
#include "emulator.h"
#include "hw/pvr/Renderer_if.h"
OSXKeyboardDevice keyboard(0);
static std::shared_ptr<OSXKbGamepadDevice> kb_gamepad(0);
@ -94,6 +95,11 @@ extern "C" void emu_dc_exit()
dc_exit();
}
extern "C" void emu_dc_term()
{
dc_term();
}
extern "C" void emu_dc_resume()
{
dc_resume();
@ -108,6 +114,11 @@ extern "C" bool emu_frame_pending()
return rend_framePending() || gui_is_open();
}
extern "C" bool emu_renderer_enabled()
{
return renderer_enabled;
}
extern "C" int emu_single_frame(int w, int h) {
if (!emu_frame_pending())
return 0;