Merge branch clean-exit-light

This commit is contained in:
Flyinghead 2018-08-01 18:02:50 +02:00
commit 9942bfc86e
25 changed files with 158 additions and 167 deletions

View File

@ -4,7 +4,7 @@
#include "rend/TexCache.h" #include "rend/TexCache.h"
extern cResetEvent rs; extern cResetEvent rs;
extern int rend_en; extern int renderer_enabled;
extern cResetEvent frame_finished; extern cResetEvent frame_finished;
extern TA_context* rqueue; extern TA_context* rqueue;
@ -33,7 +33,7 @@ void dc_run()
double t1 = os_GetSeconds(); double t1 = os_GetSeconds();
printf("Loaded context in %g ms\n", (t1- t0) * 1000); printf("Loaded context in %g ms\n", (t1- t0) * 1000);
while(rend_en) while(renderer_enabled)
{ {
tad_context saved_tad = ctx->tad; tad_context saved_tad = ctx->tad;
rend_context saved_rend = ctx->rend; rend_context saved_rend = ctx->rend;

View File

@ -76,6 +76,7 @@ u32 VertexCount=0;
u32 FrameCount=1; u32 FrameCount=1;
Renderer* renderer; Renderer* renderer;
bool renderer_enabled = true; // Signals the renderer thread to exit
#if !defined(TARGET_NO_THREADS) #if !defined(TARGET_NO_THREADS)
cResetEvent rs(false,true); cResetEvent rs(false,true);
@ -251,6 +252,9 @@ bool rend_single_frame()
#if !defined(TARGET_NO_THREADS) #if !defined(TARGET_NO_THREADS)
rs.Wait(); rs.Wait();
#endif #endif
if (!renderer_enabled)
return false;
_pvrrc = DequeueRender(); _pvrrc = DequeueRender();
} }
while (!_pvrrc); while (!_pvrrc);
@ -266,8 +270,6 @@ bool rend_single_frame()
return do_swp; return do_swp;
} }
int rend_en = true;
void* rend_thread(void* p) void* rend_thread(void* p)
{ {
#if FEAT_HAS_NIXPROF #if FEAT_HAS_NIXPROF
@ -308,23 +310,15 @@ void* rend_thread(void* p)
//we don't know if this is true, so let's not speculate here //we don't know if this is true, so let's not speculate here
//renderer->Resize(640, 480); //renderer->Resize(640, 480);
while(rend_en) while (renderer_enabled)
{ {
if (rend_single_frame()) if (rend_single_frame())
renderer->Present(); renderer->Present();
} }
return 0; return NULL;
} }
#if HOST_OS==OS_LINUX || HOST_OS==OS_DARWIN
void rend_terminate()
{
rend_en = false;
printf("rend_terminate called\n");
}
#endif
#if !defined(TARGET_NO_THREADS) #if !defined(TARGET_NO_THREADS)
cThread rthd(rend_thread,0); cThread rthd(rend_thread,0);
#endif #endif
@ -539,11 +533,20 @@ bool rend_init()
void rend_term() void rend_term()
{ {
renderer_enabled = false;
#if !defined(TARGET_NO_THREADS)
rs.Set();
#endif
if (fCheckFrames) if (fCheckFrames)
fclose(fCheckFrames); fclose(fCheckFrames);
if (fLogFrames) if (fLogFrames)
fclose(fLogFrames); fclose(fLogFrames);
#if !defined(TARGET_NO_THREADS)
rthd.WaitToEnd();
#endif
} }
void rend_vblank() void rend_vblank()

View File

@ -16,6 +16,8 @@
libevdev_func1_t libevdev_event_code_from_name; libevdev_func1_t libevdev_event_code_from_name;
libevdev_func2_t libevdev_event_code_get_name; libevdev_func2_t libevdev_event_code_get_name;
void dc_stop(void);
void load_libevdev() void load_libevdev()
{ {
if (libevdev_tried) if (libevdev_tried)
@ -355,8 +357,7 @@
} else if (ie.code == controller->mapping->Btn_Start) { } else if (ie.code == controller->mapping->Btn_Start) {
SET_FLAG(kcode[port], DC_BTN_START, ie.value); SET_FLAG(kcode[port], DC_BTN_START, ie.value);
} else if (ie.code == controller->mapping->Btn_Escape) { } else if (ie.code == controller->mapping->Btn_Escape) {
if (ie.value == 0) dc_stop();
start_shutdown();
} else if (ie.code == controller->mapping->Btn_DPad_Left) { } else if (ie.code == controller->mapping->Btn_DPad_Left) {
SET_FLAG(kcode[port], DC_DPAD_LEFT, ie.value); SET_FLAG(kcode[port], DC_DPAD_LEFT, ie.value);
} else if (ie.code == controller->mapping->Btn_DPad_Right) { } else if (ie.code == controller->mapping->Btn_DPad_Right) {

View File

@ -1,10 +1,11 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <linux/joystick.h>
#include "linux-dist/joystick.h" #include "linux-dist/joystick.h"
#if defined(USE_JOYSTICK) #if defined(USE_JOYSTICK)
#include <linux/joystick.h>
const u32 joystick_map_btn_usb[JOYSTICK_MAP_SIZE] = { DC_BTN_Y, DC_BTN_B, DC_BTN_A, DC_BTN_X, 0, 0, 0, 0, 0, DC_BTN_START }; const u32 joystick_map_btn_usb[JOYSTICK_MAP_SIZE] = { DC_BTN_Y, DC_BTN_B, DC_BTN_A, DC_BTN_X, 0, 0, 0, 0, 0, DC_BTN_START };
const u32 joystick_map_axis_usb[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, 0, 0, 0, 0, 0, 0, 0, 0 }; const u32 joystick_map_axis_usb[JOYSTICK_MAP_SIZE] = { DC_AXIS_X, DC_AXIS_Y, 0, 0, 0, 0, 0, 0, 0, 0 };

View File

@ -252,6 +252,7 @@ void os_CreateWindow()
void common_linux_setup(); void common_linux_setup();
int dc_init(int argc,wchar* argv[]); int dc_init(int argc,wchar* argv[]);
void dc_run(); void dc_run();
void dc_term();
#ifdef TARGET_PANDORA #ifdef TARGET_PANDORA
void gl_term(); void gl_term();
@ -426,23 +427,6 @@ std::vector<string> find_system_data_dirs()
return dirs; return dirs;
} }
#if HOST_OS==OS_LINUX
#if defined(SUPPORT_X11)
void x11_gl_context_destroy();
void x11_window_destroy();
#endif
void dc_term();
void rend_terminate();
void ngen_terminate();
void start_shutdown(void)
{
printf("start_shutdown called\n");
rend_terminate();
ngen_terminate();
}
#endif
int main(int argc, wchar* argv[]) int main(int argc, wchar* argv[])
{ {
#ifdef TARGET_PANDORA #ifdef TARGET_PANDORA
@ -491,31 +475,25 @@ int main(int argc, wchar* argv[])
emscripten_set_main_loop(&dc_run, 100, false); emscripten_set_main_loop(&dc_run, 100, false);
#endif #endif
#ifdef TARGET_PANDORA #ifdef TARGET_PANDORA
clean_exit(0); clean_exit(0);
#endif #endif
#if HOST_OS==OS_LINUX
dc_term(); dc_term();
#if defined(USE_EVDEV)
printf("closing any open controllers\n");
for (int port = 0; port < 4 ; port++) #if defined(USE_EVDEV)
{ for (int port = 0; port < 4 ; port++)
if(evdev_controllers[port].fd >= 0)
{ {
close(evdev_controllers[port].fd); if(evdev_controllers[port].fd >= 0)
{
close(evdev_controllers[port].fd);
}
} }
} #endif
#endif
#if defined(SUPPORT_X11) #if defined(SUPPORT_X11)
/* Close the GL context */ x11_window_destroy();
x11_gl_context_destroy(); #endif
/* Destroy the window */
x11_window_destroy();
#endif
#endif
return 0; return 0;
} }

View File

@ -35,14 +35,16 @@ int x11_width;
int x11_height; int x11_height;
int ndcid = 0; int ndcid = 0;
void* x11_glc; void* x11_glc = NULL;
bool x11_fullscreen = false; bool x11_fullscreen = false;
void* x11_vis;
Atom wmDeleteMessage; Atom wmDeleteMessage;
void* x11_vis;
extern bool dump_frame_switch; extern bool dump_frame_switch;
void dc_stop(void);
enum enum
{ {
_NET_WM_STATE_REMOVE =0, _NET_WM_STATE_REMOVE =0,
@ -67,19 +69,17 @@ void x11_window_set_fullscreen(bool fullscreen)
XSendEvent((Display*)x11_disp, DefaultRootWindow((Display*)x11_disp), False, SubstructureNotifyMask, &xev); XSendEvent((Display*)x11_disp, DefaultRootWindow((Display*)x11_disp), False, SubstructureNotifyMask, &xev);
} }
void start_shutdown(void);
void event_x11_handle() void event_x11_handle()
{ {
XEvent event; XEvent event;
while(XPending((Display *)x11_disp)) { while(XPending((Display *)x11_disp))
{
XNextEvent((Display *)x11_disp, &event); XNextEvent((Display *)x11_disp, &event);
if (event.type == ClientMessage && if (event.type == ClientMessage &&
event.xclient.data.l[0] == wmDeleteMessage) { event.xclient.data.l[0] == wmDeleteMessage)
start_shutdown(); dc_stop();
}
} }
} }
@ -98,7 +98,7 @@ void input_x11_handle()
case KeyRelease: case KeyRelease:
if (e.type == KeyRelease && e.xkey.keycode == KEY_ESC) if (e.type == KeyRelease && e.xkey.keycode == KEY_ESC)
{ {
start_shutdown(); dc_stop();
} }
#ifndef RELEASE #ifndef RELEASE
else if (e.xkey.keycode == KEY_F10) else if (e.xkey.keycode == KEY_F10)
@ -269,7 +269,7 @@ void x11_window_create()
// Get a visual // Get a visual
XVisualInfo *vi = glXGetVisualFromFBConfig(x11Display, bestFbc); XVisualInfo *vi = glXGetVisualFromFBConfig(x11Display, bestFbc);
printf("Chosen visual ID = 0x%x\n", vi->visualid); printf("Chosen visual ID = 0x%lx\n", vi->visualid);
depth = vi->depth; depth = vi->depth;
@ -308,6 +308,7 @@ void x11_window_create()
x11Window = XCreateWindow(x11Display, RootWindow(x11Display, x11Screen), (ndcid%3)*640, (ndcid/3)*480, x11_width, x11_height, x11Window = XCreateWindow(x11Display, RootWindow(x11Display, x11Screen), (ndcid%3)*640, (ndcid/3)*480, x11_width, x11_height,
0, depth, InputOutput, x11Visual->visual, ui32Mask, &sWA); 0, depth, InputOutput, x11Visual->visual, ui32Mask, &sWA);
// Capture the close window event
wmDeleteMessage = XInternAtom(x11Display, "WM_DELETE_WINDOW", False); wmDeleteMessage = XInternAtom(x11Display, "WM_DELETE_WINDOW", False);
XSetWMProtocols(x11Display, x11Window, &wmDeleteMessage, 1); XSetWMProtocols(x11Display, x11Window, &wmDeleteMessage, 1);
@ -390,12 +391,18 @@ void x11_window_destroy()
if (x11_win) if (x11_win)
{ {
XDestroyWindow((Display*)x11_disp, (Window)x11_win); XDestroyWindow((Display*)x11_disp, (Window)x11_win);
x11_win = 0; x11_win = NULL;
} }
if (x11_disp) if (x11_disp)
{ {
if (x11_glc)
{
glXMakeCurrent((Display*)x11_disp, None, NULL);
glXDestroyContext((Display*)x11_disp, (GLXContext)x11_glc);
x11_glc = NULL;
}
XCloseDisplay((Display*)x11_disp); XCloseDisplay((Display*)x11_disp);
x11_disp = 0; x11_disp = NULL;
} }
} }
#endif #endif

View File

@ -4,8 +4,10 @@ extern void* x11_glc;
extern void input_x11_init(); extern void input_x11_init();
extern void event_x11_handle(); extern void event_x11_handle();
extern void input_x11_handle(); extern void input_x11_handle();
extern void event_x11_handle();
extern void x11_window_create(); extern void x11_window_create();
extern void x11_window_set_text(const char* text); extern void x11_window_set_text(const char* text);
extern void x11_window_destroy();
// numbers // numbers
const int KEY_1 = 10; const int KEY_1 = 10;

View File

@ -18,7 +18,7 @@
#include <sys/param.h> #include <sys/param.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/time.h> #include <sys/time.h>
#if !defined(_ANDROID) && !defined(TARGET_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN) && !defined(TARGET_OSX) && !defined(TARGET_OSX_X64) #if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN) && !defined(TARGET_OSX) && !defined(TARGET_OSX_X64)
#include <sys/personality.h> #include <sys/personality.h>
#include <dlfcn.h> #include <dlfcn.h>
#endif #endif
@ -292,7 +292,7 @@ void enable_runfast()
} }
void linux_fix_personality() { void linux_fix_personality() {
#if HOST_OS == OS_LINUX && !defined(_ANDROID) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN) #if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_OS_IPHONE) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN)
printf("Personality: %08X\n", personality(0xFFFFFFFF)); printf("Personality: %08X\n", personality(0xFFFFFFFF));
personality(~READ_IMPLIES_EXEC & personality(0xFFFFFFFF)); personality(~READ_IMPLIES_EXEC & personality(0xFFFFFFFF));
printf("Updated personality: %08X\n", personality(0xFFFFFFFF)); printf("Updated personality: %08X\n", personality(0xFFFFFFFF));
@ -300,7 +300,7 @@ void linux_fix_personality() {
} }
void linux_rpi2_init() { void linux_rpi2_init() {
#if (HOST_OS == OS_LINUX) && !defined(_ANDROID) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN) && defined(TARGET_VIDEOCORE) #if !defined(TARGET_BSD) && !defined(_ANDROID) && !defined(TARGET_NACL32) && !defined(TARGET_EMSCRIPTEN) && defined(TARGET_VIDEOCORE)
void* handle; void* handle;
void (*rpi_bcm_init)(void); void (*rpi_bcm_init)(void);

View File

@ -31,7 +31,12 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
#if !defined(TARGET_NO_EXCEPTIONS) #if !defined(TARGET_NO_EXCEPTIONS)
#if HOST_CPU == CPU_ARM #if HOST_CPU == CPU_ARM
#if HOST_OS == OS_LINUX #if defined(__FreeBSD__)
bicopy(reictx->pc, MCTX(.__gregs[_REG_PC]), to_segfault);
for (int i = 0; i < 15; i++)
bicopy(reictx->r[i], MCTX(.__gregs[i]), to_segfault);
#elif HOST_OS == OS_LINUX
bicopy(reictx->pc, MCTX(.arm_pc), to_segfault); bicopy(reictx->pc, MCTX(.arm_pc), to_segfault);
u32* r =(u32*) &MCTX(.arm_r0); u32* r =(u32*) &MCTX(.arm_r0);
@ -47,7 +52,12 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
#error HOST_OS #error HOST_OS
#endif #endif
#elif HOST_CPU == CPU_X86 #elif HOST_CPU == CPU_X86
#if HOST_OS == OS_LINUX #if defined(__FreeBSD__)
bicopy(reictx->pc, MCTX(.mc_eip), to_segfault);
bicopy(reictx->esp, MCTX(.mc_esp), to_segfault);
bicopy(reictx->eax, MCTX(.mc_eax), to_segfault);
bicopy(reictx->ecx, MCTX(.mc_ecx), to_segfault);
#elif HOST_OS == OS_LINUX
bicopy(reictx->pc, MCTX(.gregs[REG_EIP]), to_segfault); bicopy(reictx->pc, MCTX(.gregs[REG_EIP]), to_segfault);
bicopy(reictx->esp, MCTX(.gregs[REG_ESP]), to_segfault); bicopy(reictx->esp, MCTX(.gregs[REG_ESP]), to_segfault);
bicopy(reictx->eax, MCTX(.gregs[REG_EAX]), to_segfault); bicopy(reictx->eax, MCTX(.gregs[REG_EAX]), to_segfault);
@ -61,11 +71,15 @@ void context_segfault(rei_host_context_t* reictx, void* segfault_ctx, bool to_se
#error HOST_OS #error HOST_OS
#endif #endif
#elif HOST_CPU == CPU_X64 #elif HOST_CPU == CPU_X64
#if HOST_OS == OS_LINUX #if defined(__FreeBSD__) || defined(__DragonFly__)
bicopy(reictx->pc, MCTX(.gregs[REG_RIP]), to_segfault); bicopy(reictx->pc, MCTX(.mc_rip), to_segfault);
#elif HOST_OS == OS_DARWIN #elif defined(__NetBSD__)
bicopy(reictx->pc, MCTX(->__ss.__rip), to_segfault); bicopy(reictx->pc, MCTX(.__gregs[_REG_RIP]), to_segfault);
#endif #elif HOST_OS == OS_LINUX
bicopy(reictx->pc, MCTX(.gregs[REG_RIP]), to_segfault);
#else
#error HOST_OS
#endif
#elif HOST_CPU == CPU_MIPS #elif HOST_CPU == CPU_MIPS
bicopy(reictx->pc, MCTX(.pc), to_segfault); bicopy(reictx->pc, MCTX(.pc), to_segfault);
#elif HOST_CPU == CPU_GENERIC #elif HOST_CPU == CPU_GENERIC

View File

@ -255,6 +255,13 @@ void dc_term()
SaveSettings(); SaveSettings();
#endif #endif
SaveRomFiles(get_writable_data_path("/data/")); SaveRomFiles(get_writable_data_path("/data/"));
TermAudio();
}
void dc_stop()
{
sh4_cpu.Stop();
} }
void LoadSettings() void LoadSettings()

View File

@ -2,7 +2,11 @@
#ifdef USE_OSS #ifdef USE_OSS
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
#ifdef TARGET_BSD
#include <unistd.h>
#else
#include <sys/unistd.h> #include <sys/unistd.h>
#endif
#include <sys/soundcard.h> #include <sys/soundcard.h>
static int oss_audio_fd = -1; static int oss_audio_fd = -1;

View File

@ -173,14 +173,9 @@ do_iter:
HIDDEN(no_update) HIDDEN(no_update)
CSYM(no_update): @ next_pc _MUST_ be on r4 *R4 NOT R0 anymore* CSYM(no_update): @ next_pc _MUST_ be on r4 *R4 NOT R0 anymore*
@ Note: I suspect that the exit thread routine ldr r0,[r8,#-156] @load CpuRunning
@ below is inefficient. If anyone is familiar cmp r0,#0
@ with asm please consider optimising! beq CSYM(cleanup)
ldr r3, =CSYM(ngen_required) @ load r3 with the address of c variable ngen_required
ldr r0,[r3] @ dereference and store in r0
cmp r0,#0 @ compare r0 with numerical value 0
beq CSYM(cleanup) @ if compare is true jump to cleanup label and exit thread
#if DC_PLATFORM == DC_PLATFORM_NAOMI #if DC_PLATFORM == DC_PLATFORM_NAOMI
sub r2,r8,#0x4100000 sub r2,r8,#0x4100000

View File

@ -2339,18 +2339,4 @@ RuntimeBlockInfo* ngen_AllocateBlock()
return new DynaRBI(); return new DynaRBI();
}; };
/* This is declared outside the #if so that any
the .s file will still build and run in an infinity
loop if ngen_terminate is not available */
unsigned int ngen_required = true;
#if HOST_OS==OS_LINUX
void ngen_terminate(void)
{
printf("ngen_terminate called\n");
ngen_required = false;
}
#endif
#endif #endif

View File

@ -46,8 +46,6 @@ void ngen_FailedToFindBlock_internal() {
void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal;
unsigned int ngen_required = true;
void ngen_mainloop(void* v_cntx) void ngen_mainloop(void* v_cntx)
{ {
Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB));
@ -55,7 +53,7 @@ void ngen_mainloop(void* v_cntx)
cycle_counter = 0; cycle_counter = 0;
#if !defined(TARGET_BOUNDED_EXECUTION) #if !defined(TARGET_BOUNDED_EXECUTION)
while (ngen_required) { while (sh4_int_bCpuRun) {
#else #else
for (int i=0; i<10000; i++) { for (int i=0; i<10000; i++) {
#endif #endif
@ -75,12 +73,6 @@ void ngen_init()
{ {
} }
void ngen_terminate(void)
{
printf("ngen_terminate called\n");
ngen_required = false;
}
void ngen_GetFeatures(ngen_features* dst) void ngen_GetFeatures(ngen_features* dst)
{ {
dst->InterpreterFallback = false; dst->InterpreterFallback = false;

View File

@ -38,15 +38,13 @@ void ngen_FailedToFindBlock_internal() {
void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal; void(*ngen_FailedToFindBlock)() = &ngen_FailedToFindBlock_internal;
unsigned int ngen_required = true;
void ngen_mainloop(void* v_cntx) void ngen_mainloop(void* v_cntx)
{ {
Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB)); Sh4RCB* ctx = (Sh4RCB*)((u8*)v_cntx - sizeof(Sh4RCB));
cycle_counter = 0; cycle_counter = 0;
do { while (sh4_int_bCpuRun) {
cycle_counter = SH4_TIMESLICE; cycle_counter = SH4_TIMESLICE;
do { do {
DynarecCodeEntryPtr rcb = bm_GetCode(ctx->cntx.pc); DynarecCodeEntryPtr rcb = bm_GetCode(ctx->cntx.pc);
@ -56,17 +54,9 @@ void ngen_mainloop(void* v_cntx)
if (UpdateSystem()) { if (UpdateSystem()) {
rdv_DoInterrupts_pc(ctx->cntx.pc); rdv_DoInterrupts_pc(ctx->cntx.pc);
} }
} while (ngen_required); }
} }
#if HOST_OS==OS_LINUX || HOST_OS==OS_DARWIN
void ngen_terminate()
{
ngen_required = false;
printf("ngen thread stopped\n");
}
#endif
void ngen_init() void ngen_init()
{ {
} }

View File

@ -120,8 +120,10 @@ do_iter:
pop ecx pop ecx
call rdv_DoInterrupts call rdv_DoInterrupts
mov ecx,eax mov ecx,eax
# cmp byte ptr [sh4_int_bCpuRun],0 mov edx,[p_sh4rcb];
# jz cleanup add edx,[cpurun_offset];
cmp dword ptr [edx],0;
jz cleanup;
jmp no_update jmp no_update
cleanup: cleanup:

View File

@ -59,6 +59,8 @@ naked void ngen_FailedToFindBlock_()
} }
} }
const u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning);
void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_;
naked void ngen_mainloop(void* cntx) naked void ngen_mainloop(void* cntx)
{ {
@ -93,8 +95,10 @@ do_iter:
pop ecx; pop ecx;
call rdv_DoInterrupts; call rdv_DoInterrupts;
mov ecx,eax; mov ecx,eax;
// cmp byte ptr [sh4_int_bCpuRun],0; mov edx,[p_sh4rcb];
// jz cleanup; add edx,[cpurun_offset];
cmp dword ptr [edx],0;
jz cleanup;
jmp no_update; jmp no_update;
cleanup: cleanup:
@ -128,6 +132,7 @@ naked void DYNACALL ngen_blockcheckfail2(u32 addr)
} }
#else #else
u32 gas_offs=offsetof(Sh4RCB,cntx.jdyn); u32 gas_offs=offsetof(Sh4RCB,cntx.jdyn);
u32 cpurun_offset=offsetof(Sh4RCB,cntx.CpuRunning);
void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_; void (*ngen_FailedToFindBlock)()=&ngen_FailedToFindBlock_;
#endif #endif
#endif #endif

View File

@ -21,7 +21,7 @@ static SDL_GLContext glcontext;
static SDL_Joystick* JoySDL = 0; static SDL_Joystick* JoySDL = 0;
extern bool FrameSkipping; extern bool FrameSkipping;
extern void dc_term(); extern void dc_stop();
extern bool KillTex; extern bool KillTex;
#ifdef TARGET_PANDORA #ifdef TARGET_PANDORA
@ -374,10 +374,7 @@ void input_sdl_handle(u32 port)
if (keys[12]){ kcode[port] &= ~DC_BTN_START; } if (keys[12]){ kcode[port] &= ~DC_BTN_START; }
if (keys[9]) if (keys[9])
{ {
dc_term(); dc_stop();
// is there a proper way to exit? dc_term() doesn't end the dc_run() loop it seems
die("death by escape key");
} }
if (keys[10]) if (keys[10])
{ {

View File

@ -102,7 +102,7 @@ PCHAR*
return argv; return argv;
} }
void dc_stop(void);
bool VramLockedWrite(u8* address); bool VramLockedWrite(u8* address);
bool ngen_Rewrite(unat& addr,unat retadr,unat acc); bool ngen_Rewrite(unat& addr,unat retadr,unat acc);
@ -247,6 +247,8 @@ void UpdateInputState(u32 port)
if (GetAsyncKeyState(VK_F10)) if (GetAsyncKeyState(VK_F10))
DiscSwap(); DiscSwap();
if (GetAsyncKeyState(VK_ESCAPE))
dc_stop();
} }
void UpdateController(u32 port) void UpdateController(u32 port)
@ -734,7 +736,7 @@ void os_DoEvents()
// If the message is WM_QUIT, exit the while loop // If the message is WM_QUIT, exit the while loop
if (msg.message == WM_QUIT) if (msg.message == WM_QUIT)
{ {
sh4_cpu.Stop(); dc_stop();
} }
// Translate the message and dispatch it to WindowProc() // Translate the message and dispatch it to WindowProc()

View File

@ -15,17 +15,15 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) { func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
emu_main(); emu_main();
} }
func applicationWillTerminate(_ aNotification: Notification) { func applicationWillTerminate(_ aNotification: Notification) {
emu_shutdown() emu_dc_stop()
} }
func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
return true return true
} }
} }

View File

@ -81,7 +81,12 @@ class EmuGLView: NSOpenGLView, NSWindowDelegate {
self.window!.delegate = self self.window!.delegate = self
} }
override func viewDidMoveToWindow() {
super.viewDidMoveToWindow()
self.window!.delegate = self
}
func windowWillClose(_ notification: Notification) { func windowWillClose(_ notification: Notification) {
emu_shutdown() emu_dc_stop()
} }
} }

View File

@ -11,6 +11,7 @@
#include <MacTypes.h> #include <MacTypes.h>
void emu_main(); void emu_main();
void emu_dc_stop();
int emu_single_frame(int w, int h); int emu_single_frame(int w, int h);
void emu_gles_init(); void emu_gles_init();
void emu_key_input(UInt16 keyCode, int state); void emu_key_input(UInt16 keyCode, int state);

View File

@ -91,6 +91,8 @@ void gl_swap() {
void common_linux_setup(); void common_linux_setup();
int dc_init(int argc,wchar* argv[]); int dc_init(int argc,wchar* argv[]);
void dc_run(); void dc_run();
void dc_term();
void dc_stop();
bool has_init = false; bool has_init = false;
void* emuthread(void*) { void* emuthread(void*) {
@ -117,9 +119,18 @@ void* emuthread(void*) {
dc_run(); dc_run();
has_init = false;
dc_term();
return 0; return 0;
} }
extern "C" void emu_dc_stop()
{
dc_stop();
}
pthread_t emu_thread; pthread_t emu_thread;
extern "C" void emu_main() { extern "C" void emu_main() {
pthread_create(&emu_thread, 0, &emuthread, 0); pthread_create(&emu_thread, 0, &emuthread, 0);
@ -216,14 +227,3 @@ extern "C" void emu_key_input(UInt16 keyCode, int state) {
case 0x24: handle_key(Btn_Start, state); break; case 0x24: handle_key(Btn_Start, state); break;
} }
} }
void rend_terminate();
void ngen_terminate();
void dc_term();
extern "C" void emu_shutdown()
{
rend_terminate();
ngen_terminate();
dc_term();
}

View File

@ -3,11 +3,9 @@ FOR_LINUX :=1
#NO_REC := 1 #NO_REC := 1
#NO_REND := 1 #NO_REND := 1
WEBUI :=1 WEBUI :=1
USE_ALSA := 1
USE_OSS := 1 USE_OSS := 1
#USE_PULSEAUDIO := 1 #USE_PULSEAUDIO := 1
USE_EVDEV := 1 USE_EVDEV := 1
USE_JOYSTICK := 1
CXX=${CC_PREFIX}g++ CXX=${CC_PREFIX}g++
CC=${CC_PREFIX}gcc CC=${CC_PREFIX}gcc
@ -23,6 +21,13 @@ LIBS :=
CFLAGS := CFLAGS :=
CXXFLAGS := CXXFLAGS :=
ifneq (, $(filter $(shell uname -s), FreeBSD OpenBSD NetBSD DragonFly))
CFLAGS += -DTARGET_BSD
else
USE_ALSA := 1
USE_JOYSTICK := 1
endif
# Platform auto-detection # Platform auto-detection
# Can be overridden by using: # Can be overridden by using:
# make platform=x64 # make platform=x64
@ -30,7 +35,7 @@ ifeq (,$(platform))
ARCH = $(shell uname -m) ARCH = $(shell uname -m)
ifeq ($(ARCH), $(filter $(ARCH), i386 i686)) ifeq ($(ARCH), $(filter $(ARCH), i386 i686))
platform = x86 platform = x86
else ifeq ($(ARCH), $(filter $(ARCH), x86_64 AMD64)) else ifeq ($(ARCH), $(filter $(ARCH), x86_64 AMD64 amd64))
platform = x64 platform = x64
else ifneq (,$(findstring aarch64,$(ARCH))) else ifneq (,$(findstring aarch64,$(ARCH)))
HARDWARE = $(shell grep Hardware /proc/cpuinfo) HARDWARE = $(shell grep Hardware /proc/cpuinfo)
@ -92,7 +97,7 @@ ifneq (,$(findstring x86,$(platform)))
ASFLAGS += --32 ASFLAGS += --32
LDFLAGS += -m32 LDFLAGS += -m32
CFLAGS += -m32 -D TARGET_LINUX_x86 -D TARGET_NO_AREC -fsingle-precision-constant -fno-builtin-sqrtf CFLAGS += -m32 -D TARGET_LINUX_x86 -D TARGET_NO_AREC -fsingle-precision-constant -fno-builtin-sqrtf
CXXFLAGS += -fno-exceptions CXXFLAGS += -fexceptions
ifneq (,$(findstring sse4_1,$(platform))) ifneq (,$(findstring sse4_1,$(platform)))
HAS_SOFTREND := 1 HAS_SOFTREND := 1
@ -281,9 +286,9 @@ ifdef USE_DISPMANX
endif endif
ifdef USE_X11 ifdef USE_X11
CFLAGS += -D SUPPORT_X11 CFLAGS += `pkg-config --cflags x11` -D SUPPORT_X11
CXXFLAGS += -D SUPPORT_X11 CXXFLAGS += `pkg-config --cflags x11` -D SUPPORT_X11
LIBS += -lX11 LIBS += `pkg-config --libs x11`
endif endif
ifdef USE_EVDEV ifdef USE_EVDEV
@ -300,8 +305,8 @@ ifdef USE_OMX
endif endif
ifdef USE_ALSA ifdef USE_ALSA
CXXFLAGS += -D USE_ALSA CXXFLAGS += `pkg-config --cflags alsa` -D USE_ALSA
LIBS += -lasound LIBS += `pkg-config --libs alsa`
endif endif
ifdef USE_OSS ifdef USE_OSS
@ -309,8 +314,8 @@ ifdef USE_OSS
endif endif
ifdef USE_PULSEAUDIO ifdef USE_PULSEAUDIO
CXXFLAGS += -D USE_PULSEAUDIO CXXFLAGS += `pkg-config --cflags libpulse-simple` -D USE_PULSEAUDIO
LIBS += -lpulse-simple LIBS += `pkg-config --libs libpulse-simple`
endif endif
ifdef HAS_SOFTREND ifdef HAS_SOFTREND
@ -393,18 +398,14 @@ $(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.c $(DEPDIR)/%.d
$(POSTCOMPILE) $(POSTCOMPILE)
$(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.S $(BUILDDIR)/%.build_obj : $(RZDCY_SRC_DIR)/%.S
$(BUILDDIR)/%.build_obj: $(RZDCY_SRC_DIR)/%.S $(DEPDIR)/%.d $(AS) $(ASFLAGS) $(INCS) $< -o $@
mkdir -p $(dir $@)
mkdir -p .dep-$(dir $@)
$(AS) $(DEPFLAGS) $(ASFLAGS) $(INCS) $< -o $@
$(POSTCOMPILE)
install: $(EXECUTABLE) install: $(EXECUTABLE)
mkdir -p $(DESTDIR)$(PREFIX)/bin 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(PREFIX)/bin 2>/dev/null || true
mkdir -p $(DESTDIR)$(PREFIX)/share/reicast/mappings 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(PREFIX)/share/reicast/mappings 2>/dev/null || true
mkdir -p $(DESTDIR)$(MAN_DIR) 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(MAN_DIR) 2>/dev/null || true
mkdir -p $(DESTDIR)$(MENUENTRY_DIR) 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(MENUENTRY_DIR) 2>/dev/null || true
mkdir -p $(DESTDIR)$(ICON_DIR) 2>/dev/null || /bin/true mkdir -p $(DESTDIR)$(ICON_DIR) 2>/dev/null || true
install -m755 $(EXECUTABLE) $(DESTDIR)$(PREFIX)/bin/$(EXECUTABLE_NAME) install -m755 $(EXECUTABLE) $(DESTDIR)$(PREFIX)/bin/$(EXECUTABLE_NAME)
install -m755 tools/reicast-joyconfig.py $(DESTDIR)$(PREFIX)/bin/reicast-joyconfig install -m755 tools/reicast-joyconfig.py $(DESTDIR)$(PREFIX)/bin/reicast-joyconfig
install -m644 mappings/controller_gcwz.cfg $(DESTDIR)$(PREFIX)/share/reicast/mappings install -m644 mappings/controller_gcwz.cfg $(DESTDIR)$(PREFIX)/share/reicast/mappings

View File

@ -4,7 +4,7 @@ build:
steps: steps:
- script: - script:
name: install-dependencies name: install-dependencies
code: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y build-essential libasound2-dev libgl1-mesa-dev libx11-dev code: sudo apt-get clean && sudo apt-get update && sudo apt-get install -y build-essential pkgconf libasound2-dev libgl1-mesa-dev libx11-dev
- script: - script:
name: gcc-version name: gcc-version
code: gcc --version code: gcc --version