void sim_do_exit() { sim_kernel_shutdown(); SDL_Quit(); exit(EXIT_SUCCESS); }
/* * This thread will read the buttons in an interrupt like fashion, and * also initializes SDL_INIT_VIDEO and the surfaces * * it must be done in the same thread (at least on windows) because events only * work in the thread which called SDL_Init(SubSystem) with SDL_INIT_VIDEO * * This is an SDL thread and relies on preemptive behavoir of the host **/ static int sdl_event_thread(void * param) { SDL_InitSubSystem(SDL_INIT_VIDEO); SDL_Surface *picture_surface; int width, height; /* Try and load the background image. If it fails go without */ if (background) { picture_surface = SDL_LoadBMP("UI256.bmp"); if (picture_surface == NULL) { background = false; DEBUGF("warn: %s\n", SDL_GetError()); } } /* Set things up */ if (background) { width = UI_WIDTH; height = UI_HEIGHT; } else { #ifdef HAVE_REMOTE_LCD if (showremote) { width = SIM_LCD_WIDTH > SIM_REMOTE_WIDTH ? SIM_LCD_WIDTH : SIM_REMOTE_WIDTH; height = SIM_LCD_HEIGHT + SIM_REMOTE_HEIGHT; } else #endif { width = SIM_LCD_WIDTH; height = SIM_LCD_HEIGHT; } } if ((gui_surface = SDL_SetVideoMode(width * display_zoom, height * display_zoom, 24, SDL_HWSURFACE|SDL_DOUBLEBUF)) == NULL) { panicf("%s", SDL_GetError()); } SDL_WM_SetCaption(UI_TITLE, NULL); if (background && picture_surface != NULL) SDL_BlitSurface(picture_surface, NULL, gui_surface, NULL); /* let system_init proceed */ SDL_SemPost((SDL_sem *)param); /* * finally enter the button loop */ while(gui_message_loop()); /* Order here is relevent to prevent deadlocks and use of destroyed sync primitives by kernel threads */ sim_thread_shutdown(); sim_kernel_shutdown(); return 0; }