/** * Reset ST emulator states, chips, interrupts and registers. * Return zero or negative TOS image load error code. */ static const char* Reset_ST(bool bCold) { if (bCold) { const char* error_str; error_str=memory_init(ConfigureParams.Memory.nMemoryBankSize); if (error_str!=NULL) { return error_str; } } CycInt_Reset(); /* Reset interrupts */ Video_Reset(); /* Reset video */ TMC_Reset(); /* Reset TMC Registers */ SCR_Reset(); /* Reset System Control Registers */ nvram_init(); /* Reset NVRAM */ SCSI_Reset(); /* Reset SCSI disks */ MO_Reset(); /* Reset MO disks */ Floppy_Reset(); /* Reset Floppy disks */ SCC_Reset(2); /* Reset SCC */ Ethernet_Reset(true); /* Reset Ethernet */ Sound_Reset(); /* Reset Sound */ Screen_Reset(); /* Reset screen */ DSP_Reset(); /* Reset DSP */ M68000_Reset(bCold); /* Reset CPU */ DebugCpu_SetDebugging(); /* Re-set debugging flag if needed */ return NULL; }
/* ================ FS_OpenStream open and reading basic info from sound stream ================ */ stream_t *FS_OpenStream( const char *filename ) { const char *ext = FS_FileExtension( filename ); string path, loadname; qboolean anyformat = true; const streamfmt_t *format; stream_t *stream; Sound_Reset(); // clear old streaminfo Q_strncpy( loadname, filename, sizeof( loadname )); if( Q_stricmp( ext, "" )) { // we needs to compare file extension with list of supported formats // and be sure what is real extension, not a filename with dot for( format = sound.streamformat; format && format->formatstring; format++ ) { if( !Q_stricmp( format->ext, ext )) { FS_StripExtension( loadname ); anyformat = false; break; } } } // now try all the formats in the selected list for( format = sound.streamformat; format && format->formatstring; format++) { if( anyformat || !Q_stricmp( ext, format->ext )) { Q_sprintf( path, format->formatstring, loadname, "", format->ext ); if(( stream = format->openfunc( path )) != NULL ) { stream->format = format; return stream; // done } } } if( !sound.streamformat || sound.streamformat->ext == NULL ) MsgDev( D_NOTE, "FS_OpenStream: soundlib offline\n" ); else MsgDev( D_NOTE, "FS_OpenStream: couldn't open \"%s\"\n", loadname ); return NULL; }
/** * Shortcut to sound on/off */ static void ShortCut_SoundOnOff(void) { ConfigureParams.Sound.bEnableSound = !ConfigureParams.Sound.bEnableSound; Sound_Reset(); }
/* ================ FS_LoadSound loading and unpack to wav any known sound ================ */ wavdata_t *FS_LoadSound( const char *filename, const byte *buffer, size_t size ) { const char *ext = FS_FileExtension( filename ); string path, loadname; qboolean anyformat = true; int filesize = 0; const loadwavfmt_t *format; byte *f; Sound_Reset(); // clear old sounddata Q_strncpy( loadname, filename, sizeof( loadname )); if( Q_stricmp( ext, "" )) { // we needs to compare file extension with list of supported formats // and be sure what is real extension, not a filename with dot for( format = sound.loadformats; format && format->formatstring; format++ ) { if( !Q_stricmp( format->ext, ext )) { FS_StripExtension( loadname ); anyformat = false; break; } } } // HACKHACK: skip any checks, load file from buffer if( filename[0] == '#' && buffer && size ) goto load_internal; // now try all the formats in the selected list for( format = sound.loadformats; format && format->formatstring; format++) { if( anyformat || !Q_stricmp( ext, format->ext )) { Q_sprintf( path, format->formatstring, loadname, "", format->ext ); f = FS_LoadFile( path, &filesize, false ); if( f && filesize > 0 ) { if( format->loadfunc( path, f, filesize )) { Mem_Free(f); // release buffer return SoundPack(); // loaded } else Mem_Free(f); // release buffer } } } load_internal: for( format = sound.loadformats; format && format->formatstring; format++ ) { if( anyformat || !Q_stricmp( ext, format->ext )) { if( buffer && size > 0 ) { if( format->loadfunc( loadname, buffer, size )) return SoundPack(); // loaded } } } if( !sound.loadformats || sound.loadformats->ext == NULL ) MsgDev( D_NOTE, "FS_LoadSound: soundlib offline\n" ); else if( filename[0] != '#' ) MsgDev( D_WARN, "FS_LoadSound: couldn't load \"%s\"\n", loadname ); return NULL; }
/** * Reset ST emulator states, chips, interrupts and registers. * Return zero or negative TOS image load error code. */ static int Reset_ST(bool bCold) { if (bCold) { int ret; Floppy_GetBootDrive(); /* Find which device to boot from (A: or C:) */ ret = TOS_LoadImage(); /* Load TOS, writes into cartridge memory */ if (ret) return ret; /* If we can not load a TOS image, return now! */ Cart_ResetImage(); /* Load cartridge program into ROM memory. */ Cart_Patch(); } CycInt_Reset(); /* Reset interrupts */ MFP_Reset(); /* Setup MFP chip */ Video_Reset(); /* Reset video */ VDI_Reset(); /* Reset internal VDI variables */ NvRam_Reset(); /* reset NvRAM (video) settings */ GemDOS_Reset(); /* Reset GEMDOS emulation */ if (bCold) { FDC_Reset( bCold ); /* Reset FDC */ } Floppy_Reset(); /* Reset Floppy */ if (ConfigureParams.System.nMachineType == MACHINE_FALCON || ConfigureParams.System.nMachineType == MACHINE_TT) { Ncr5380_Reset(); } if (ConfigureParams.System.nMachineType == MACHINE_FALCON) { DSP_Reset(); /* Reset the DSP */ Crossbar_Reset(bCold); /* Reset Crossbar sound */ } else DmaSnd_Reset(bCold); /* Reset DMA sound */ PSG_Reset(); /* Reset PSG */ Sound_Reset(); /* Reset Sound */ ACIA_Reset( ACIA_Array ); /* ACIA */ IKBD_Reset(bCold); /* Keyboard (after ACIA) */ if (ConfigureParams.System.nMachineType == MACHINE_FALCON && !bUseVDIRes) VIDEL_reset(); else Screen_Reset(); /* Reset screen */ M68000_Reset(bCold); /* Reset CPU */ DebugCpu_SetDebugging(); /* Re-set debugging flag if needed */ DebugDsp_SetDebugging(); Midi_Reset(); #if defined(__linux__) nf_scsidrv_reset(); #endif /* Start HBL, Timer B and VBL interrupts with a 0 cycle delay */ Video_StartInterrupts( 0 ); return 0; }
/** * Copy details back to configuration and perform reset. */ bool Change_CopyChangedParamsToConfiguration(CNF_PARAMS *current, CNF_PARAMS *changed, bool bForceReset) { bool NeedReset; bool bReInitSCSIEmu = false; bool bReInitEnetEmu = false; bool bReInitSoundEmu = false; bool bReInitIoMem = false; bool bScreenModeChange = false; int i; Dprintf("Changes for:\n"); /* Do we need to warn user that changes will only take effect after reset? */ if (bForceReset) NeedReset = bForceReset; else NeedReset = Change_DoNeedReset(current, changed); /* Do we need to change SCSI disks? */ for (i = 0; i < ESP_MAX_DEVS; i++) { if (!NeedReset && (current->SCSI.target[i].bDiskInserted != changed->SCSI.target[i].bDiskInserted || current->SCSI.target[i].bWriteProtected != changed->SCSI.target[i].bWriteProtected || strcmp(current->SCSI.target[i].szImageName, changed->SCSI.target[i].szImageName))) { bReInitSCSIEmu = true; break; } } /* Note: MO and floppy disk insert/eject called from GUI */ /* Do we need to change Ethernet connection? */ if (!NeedReset && current->Ethernet.bEthernetConnected != changed->Ethernet.bEthernetConnected) { bReInitEnetEmu = true; } /* Do we need to change Sound configuration? */ if (!NeedReset && (current->Sound.bEnableSound != changed->Sound.bEnableSound || current->Sound.bEnableMicrophone != changed->Sound.bEnableMicrophone)) { bReInitSoundEmu = true; } /* Copy details to configuration, * so it can be saved out or set on reset */ if (changed != &ConfigureParams) { ConfigureParams = *changed; } /* Copy details to global, if we reset copy them all */ Configuration_Apply(NeedReset); /* Check if all necessary files exist */ Dialog_CheckFiles(); if (bQuitProgram) { SDL_Quit(); exit(-2); } /* Re-init IO memory map? */ if (bReInitIoMem) { Dprintf("- IO mem<\n"); IoMem_Init(); } /* Re-init SCSI disks? */ if (bReInitSCSIEmu) { Dprintf("- SCSI disks<\n"); SCSI_Reset(); } /* Re-init Ethernet? */ if (bReInitEnetEmu) { Dprintf("- Ethernet<\n"); Ethernet_Reset(false); } /* Re-init Sound? */ if (bReInitSoundEmu) { Dprintf("- Sound<\n"); Sound_Reset(); } /* Force things associated with screen change */ if (bScreenModeChange) { Dprintf("- screenmode<\n"); Screen_ModeChanged(); } /* Do we need to perform reset? */ if (NeedReset) { const char *err_msg; Dprintf("- reset\n"); err_msg=Reset_Cold(); // if (err_msg!=NULL) { // DlgAlert_Notice(err_msg); // return false; // } } /* Go into/return from full screen if flagged */ if (!bInFullScreen && ConfigureParams.Screen.bFullScreen) Screen_EnterFullScreen(); else if (bInFullScreen && !ConfigureParams.Screen.bFullScreen) Screen_ReturnFromFullScreen(); /* update statusbar info (CPU, MHz, mem etc) */ Statusbar_UpdateInfo(); Dprintf("done.\n"); return true; }