--- previous/src/main.c 2018/04/24 19:25:30 1.1.1.2 +++ previous/src/main.c 2018/04/24 19:27:31 1.1.1.4 @@ -26,6 +26,7 @@ const char Main_fileid[] = "Hatari main. #include "reset.h" #include "resolution.h" #include "screen.h" +#include "scsi.h" #include "sdlgui.h" #include "shortcut.h" #include "statusbar.h" @@ -35,6 +36,7 @@ const char Main_fileid[] = "Hatari main. #include "avi_record.h" #include "debugui.h" #include "clocks_timings.h" +#include "file.h" #include "hatari-glue.h" @@ -42,6 +44,7 @@ const char Main_fileid[] = "Hatari main. #include #endif +int nFrameSkips; bool bQuitProgram = false; /* Flag to quit program cleanly */ @@ -269,8 +272,8 @@ void Main_WaitOnVbl(void) } // FrameDuration_micro = (Sint64) ( 1000000.0 / nScreenRefreshRate + 0.5 ); /* round to closest integer */ -// FrameDuration_micro = ClocksTimings_GetVBLDuration_micro ( ConfigureParams.System.nMachineType , nScreenRefreshRate ); - FrameDuration_micro = 1000000/50; + FrameDuration_micro = ClocksTimings_GetVBLDuration_micro ( ConfigureParams.System.nMachineType , 68 ); +// FrameDuration_micro = 1000000/50; CurrentTicks = Time_GetTicks(); if ( DestTicks == 0 ) /* first call, init DestTicks */ @@ -287,11 +290,11 @@ void Main_WaitOnVbl(void) if (!nFirstMilliTick) nFirstMilliTick = Main_GetTicks(); } -// if (nFrameSkips < ConfigureParams.Screen.nFrameSkips) -// { -// nFrameSkips += 1; - // Log_Printf(LOG_DEBUG, "Increased frameskip to %d\n", nFrameSkips); -// } + if (nFrameSkips < ConfigureParams.Screen.nFrameSkips) + { + nFrameSkips += 1; + Log_Printf(LOG_DEBUG, "Increased frameskip to %d\n", nFrameSkips); + } /* Only update DestTicks for next VBL */ DestTicks = CurrentTicks + FrameDuration_micro; return; @@ -299,13 +302,13 @@ void Main_WaitOnVbl(void) /* If automatic frameskip is enabled and delay's more than twice * the effect of single frameskip, decrease frameskip */ -// if (nFrameSkips > 0 -// && ConfigureParams.Screen.nFrameSkips >= AUTO_FRAMESKIP_LIMIT -// && 2*nDelay > FrameDuration_micro/nFrameSkips) -// { -// nFrameSkips -= 1; - // Log_Printf(LOG_DEBUG, "Decreased frameskip to %d\n", nFrameSkips); -// } + if (nFrameSkips > 0 + && ConfigureParams.Screen.nFrameSkips >= AUTO_FRAMESKIP_LIMIT + && 2*nDelay > FrameDuration_micro/nFrameSkips) + { + nFrameSkips -= 1; + Log_Printf(LOG_DEBUG, "Decreased frameskip to %d\n", nFrameSkips); + } if (bAccurateDelays) { @@ -382,7 +385,7 @@ static void Main_HandleMouseMotion(SDL_E /* Ignore motion when position has changed right after a reset or TOS * (especially version 4.04) might get confused and play key clicks */ - if (bIgnoreNextMouseMotion) + if (bIgnoreNextMouseMotion ) { bIgnoreNextMouseMotion = false; return; @@ -514,13 +517,14 @@ void Main_EventHandler(void) break; case SDL_KEYDOWN: - fprintf(stderr, "keydwn\n"); - Keymap_KeyDown(&event.key.keysym); - ShortCut_ActKey(); +// fprintf(stderr, "keydwn\n"); +// Keymap_KeyDown(&event.key.keysym); + KeyTranslator(&event.key.keysym); break; case SDL_KEYUP: - Keymap_KeyUp(&event.key.keysym); +// Keymap_KeyUp(&event.key.keysym); + KeyRelease(&event.key.keysym); break; default: @@ -539,9 +543,9 @@ void Main_EventHandler(void) void Main_SetTitle(const char *title) { if (title) - SDL_WM_SetCaption(title, "Hatari"); + SDL_WM_SetCaption(title, "Previous"); else - SDL_WM_SetCaption(PROG_NAME, "Hatari"); + SDL_WM_SetCaption(PROG_NAME, "Previous"); } /*-----------------------------------------------------------------------*/ @@ -568,9 +572,6 @@ static void Main_Init(void) ClocksTimings_InitMachine ( ConfigureParams.System.nMachineType ); Resolution_Init(); SDLGui_Init(); -// Printer_Init(); -// RS232_Init(); -// Midi_Init(); Screen_Init(); Main_SetTitle(NULL); // HostScreen_Init(); @@ -579,37 +580,40 @@ static void Main_Init(void) M68000_Init(); /* Init CPU emulation */ // Audio_Init(); // DmaSnd_Init(); -// Keymap_Init(); + Keymap_Init(); + - /* Init HD emulation */ -// HDC_Init(); -// Ide_Init(); -// GemDOS_Init(); -// if (ConfigureParams.HardDisk.bUseHardDiskDirectories) -// { - /* uses variables set by HDC_Init()! */ -// GemDOS_InitDrives(); -// } - - if (Reset_Cold()) /* Reset all systems, load TOS image */ - { - /* If loading of the TOS failed, we bring up the GUI to let the - * user choose another TOS ROM file. */ -// Dialog_DoProperty(); - } /* call menu at startup */ - Dialog_DoProperty(); + if (!File_Exists(sConfigFileName) || ConfigureParams.ConfigDialog.bShowConfigDialogAtStartup) + Dialog_DoProperty(); + else + Dialog_CheckFiles(); + if (bQuitProgram) - { - fprintf(stderr, "Failed to load TOS image!\n"); - SDL_Quit(); - exit(-2); - } - + { + SDL_Quit(); + exit(-2); + } + + +// const char *err_msg; +// +// while ((err_msg=Reset_Cold())!=NULL) +// { +// DlgMissing_Rom(); +// if (bQuitProgram) { +// Main_RequestQuit(); +// break; +// } +// } + + Reset_Cold(); + +// if (bQuitProgram) { +// SDL_Quit(); +// exit(-2); +// } IoMem_Init(); -// NvRam_Init(); -// Joy_Init(); -// Sound_Init(); /* done as last, needs CPU & DSP running... */ DebugUI_Init(); @@ -623,22 +627,9 @@ static void Main_Init(void) static void Main_UnInit(void) { Screen_ReturnFromFullScreen(); -// Floppy_UnInit(); -// HDC_UnInit(); -// Midi_UnInit(); -// RS232_UnInit(); -// Printer_UnInit(); + SCSI_Uninit(); IoMem_UnInit(); -// NvRam_UnInit(); -// GemDOS_UnInitDrives(); -// Ide_UnInit(); -// Joy_UnInit(); -// if (Sound_AreWeRecording()) -// Sound_EndRecording(); -// Audio_UnInit(); SDLGui_UnInit(); -// DSP_UnInit(); -// HostScreen_UnInit(); Screen_UnInit(); Exit680x0(); @@ -754,25 +745,12 @@ int main(int argc, char *argv[]) /* Check if SDL_Delay is accurate */ Main_CheckForAccurateDelays(); -// if ( AviRecordOnStartup ) /* Immediatly starts avi recording ? */ -// Avi_StartRecording ( ConfigureParams.Video.AviRecordFile , ConfigureParams.Screen.bCrop , -// ConfigureParams.Video.AviRecordFps == 0 ? -// ClocksTimings_GetVBLPerSec ( ConfigureParams.System.nMachineType , nScreenRefreshRate ) : -// (Uint32)ConfigureParams.Video.AviRecordFps << CLOCKS_TIMINGS_SHIFT_VBL , -// 1 << CLOCKS_TIMINGS_SHIFT_VBL , -// ConfigureParams.Video.AviRecordVcodec ); /* Run emulation */ Main_UnPauseEmulation(); M68000_Start(); /* Start emulation */ -// if (bRecordingAvi) -// { - /* cleanly close the avi file */ -// Statusbar_AddMessage("Finishing AVI file...", 100); -// Statusbar_Update(sdlscrn); -// Avi_StopRecording(); -// } + /* Un-init emulation system */ Main_UnInit();