--- frontvm/hardware/main.c 2018/04/24 17:57:15 1.1 +++ frontvm/hardware/main.c 2018/04/24 17:57:34 1.1.1.2 @@ -11,27 +11,23 @@ #include #include #include +#include #include #include "main.h" #include "configuration.h" -#include "decode.h" #include "dialog.h" #include "audio.h" #include "file.h" +#include "../m68000.h" #include "hostcall.h" #include "input.h" -#include "reset.h" #include "keymap.h" -#include "m68000.h" #include "misc.h" #include "screen.h" #include "sdlgui.h" #include "shortcut.h" -#include "video.h" - -#include "../cpu/hatari-glue.h" #define FORCE_WORKING_DIR /* Set default directory to cwd */ @@ -46,9 +42,6 @@ char szBootDiscImage[MAX_FILENAME_LENGTH char szWorkingDir[MAX_FILENAME_LENGTH] = { "" }; char szCurrentDir[MAX_FILENAME_LENGTH] = { "" }; -unsigned char STRam[MEMORY_SIZE]; /* This is our ST Ram, includes all TOS/hardware areas for ease */ - - /*-----------------------------------------------------------------------*/ /* Error handler @@ -112,15 +105,19 @@ void Main_EventHandler() { SDL_Event event; - if( SDL_PollEvent(&event) ) + while (SDL_PollEvent (&event)) switch( event.type ) { case SDL_QUIT: bQuitProgram = TRUE; + SDL_Quit (); + exit (0); break; case SDL_MOUSEMOTION: /* Read/Update internal mouse position */ input.motion_x += event.motion.xrel; input.motion_y += event.motion.yrel; + input.abs_x = event.motion.x; + input.abs_y = event.motion.y; break; case SDL_MOUSEBUTTONDOWN: Input_MousePress (event.button.button); @@ -190,12 +187,12 @@ void Main_Init(void) { /* Init SDL's video subsystem. Note: Audio and joystick subsystems will be initialized later (failures there are not fatal). */ - if(SDL_Init(SDL_INIT_VIDEO) < 0) + if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) { fprintf(stderr, "Could not initialize the SDL library:\n %s\n", SDL_GetError() ); exit(-1); } - + Misc_SeedRandom(1043618); SDLGui_Init(); Screen_Init(); @@ -206,12 +203,6 @@ void Main_Init(void) GemDOS_Init(); GemDOS_InitDrives(); - if(Reset_VM()) /* Reset all systems */ - { - /* If loading of the TOS failed, we bring up the GUI to let the - * user choose another TOS ROM file. */ - Dialog_DoProperty(); - } if(bQuitProgram) { SDL_Quit(); @@ -236,6 +227,20 @@ void Main_UnInit(void) SDL_Quit(); } +static Uint32 vbl_callback () +{ + FlagException (0); + return 20; +} + +void sig_handler (int signum) +{ + if (signum == SIGSEGV) { + printf ("Segfault! All is lost! Abandon ship!\n"); + Call_DumpDebug (); + abort (); + } +} /*-----------------------------------------------------------------------*/ /* @@ -243,7 +248,12 @@ void Main_UnInit(void) */ int main(int argc, char *argv[]) { + struct sigaction act; + act.sa_handler = sig_handler; + act.sa_flags = 0; + sigaction (SIGSEGV, &act, NULL); + /* Generate random seed */ srand( time(NULL) ); @@ -266,6 +276,8 @@ int main(int argc, char *argv[]) if( bUseFullscreen ) Screen_EnterFullScreen(); + SDL_AddTimer (20, &vbl_callback, NULL); + /* Run emulation */ Main_UnPauseEmulation(); Start680x0(); /* Start emulation */