@@ -302,7 +302,7 @@ public MainWindow()
302302 ZXLayoutPersister . RestoreLayout ( grdMain , dockLeft , dockRight , dockBottom , new [ ] { _playerDock } ) ;
303303 }
304304
305-
305+
306306 private void OpenAbout ( object ? sender , RoutedEventArgs e )
307307 {
308308 ZXAboutDialog zXAboutDialog = new ZXAboutDialog ( ) ;
@@ -1400,10 +1400,13 @@ private async void Build(object? sender, Avalonia.Interactivity.RoutedEventArgs
14001400 EmulatorInfo . CanDebug = false ;
14011401 EmulatorInfo . CanRun = false ;
14021402 BlockEditors ( ) ;
1403+
14031404 _ = Task . Run ( ( ) =>
14041405 {
14051406 if ( peExplorer . RootPath != null )
1407+ {
14061408 ZXProjectBuilder . Build ( outLog . Writer ) ;
1409+ }
14071410
14081411 Dispatcher . UIThread . InvokeAsync ( ( ) =>
14091412 {
@@ -1413,6 +1416,8 @@ private async void Build(object? sender, Avalonia.Interactivity.RoutedEventArgs
14131416 } ) ;
14141417 } ) ;
14151418 }
1419+
1420+
14161421 private async void BuildAndRun ( object ? sender , Avalonia . Interactivity . RoutedEventArgs e )
14171422 {
14181423 if ( string . IsNullOrWhiteSpace ( ZXOptions . Current . ZxbcPath ) || string . IsNullOrWhiteSpace ( ZXOptions . Current . ZxbasmPath ) )
@@ -1480,45 +1485,56 @@ private async void BuildAndRun(object? sender, Avalonia.Interactivity.RoutedEven
14801485 {
14811486 var emulatorName = Path . GetFileNameWithoutExtension ( emulatorPath ) ;
14821487 var nextDrive = Path . Combine ( project . ProjectPath , "nextdrive" ) ;
1483- switch ( emulatorName . ToLower ( ) )
1488+
1489+ if ( settings . ExternalEmulator )
14841490 {
1485- case "cspect" :
1491+ outLog . Writer . WriteLine ( $ "Custom emulator launcher: { settings . ExternalEmuladorValue } ") ;
1492+ if ( ! ZXProjectBuilder . ExecuteFile ( settings . ExternalEmuladorValue , new string [ ]
14861493 {
1487- outLog . Writer . WriteLine ( "Launching CSpect..." ) ;
1488- Process process = new Process ( ) ;
1489- process . StartInfo . FileName = emulatorPath ;
1490- process . StartInfo . Arguments = string . Format (
1491- "-zxnext -tv -w3 -brk -r -mmc=\" {0}\" \" {1}\" " ,
1492- nextDrive ,
1493- Path . Combine ( nextDrive , Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ) ;
1494- process . StartInfo . WorkingDirectory = project . ProjectPath ;
1495- process . StartInfo . UseShellExecute = true ;
1496- process . StartInfo . CreateNoWindow = false ;
1497- outLog . Writer . WriteLine ( process . StartInfo . FileName + " " + process . StartInfo . Arguments ) ;
1498- process . Start ( ) ;
1499- process . WaitForExit ( ) ;
1500- }
1501- break ;
1502- case "zesarux" :
1503- {
1504- outLog . Writer . WriteLine ( "Launching ZEsarUX..." ) ;
1505- Process process = new Process ( ) ;
1506- process . StartInfo . FileName = emulatorPath ;
1507- process . StartInfo . Arguments = string . Format (
1508- "--noconfigfile --zoom 1 --machine TBBlue --realvideo --enabletimexvideo --tbblue-fast-boot-mode --enable-esxdos-handler --esxdos-root-dir \" {0}\" \" {1}\" --snap-no-change-machine" ,
1509- nextDrive ,
1510- Path . Combine ( nextDrive , Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ) ;
1511- process . StartInfo . WorkingDirectory = Path . GetDirectoryName ( emulatorPath ) ;
1512- process . StartInfo . UseShellExecute = true ;
1513- process . StartInfo . CreateNoWindow = false ;
1514- outLog . Writer . WriteLine ( process . StartInfo . FileName + " " + process . StartInfo . Arguments ) ;
1515- process . Start ( ) ;
1516- process . WaitForExit ( ) ;
1517- }
1518- break ;
1519- default :
1520- errorMsg = "There is no valid emulator configured for Next. Please configure an emulator (CSpect or ZEsarUX) from the Tools -> Options menu." ;
1521- break ;
1494+ nextDrive ,
1495+ Path . GetFileNameWithoutExtension ( settings . MainFile )
1496+ } ,
1497+ project . ProjectPath ,
1498+ outLog . Writer ) )
1499+ {
1500+ errorMsg = "Error executing custom emulator launcher." ;
1501+ }
1502+ }
1503+ else if ( emulatorName . ToLower ( ) == "cspect" )
1504+ {
1505+ outLog . Writer . WriteLine ( "Launching CSpect..." ) ;
1506+ Process process = new Process ( ) ;
1507+ process . StartInfo . FileName = emulatorPath ;
1508+ process . StartInfo . Arguments = string . Format (
1509+ "-zxnext -tv -w3 -brk -r -mmc=\" {0}\" \" {1}\" " ,
1510+ nextDrive ,
1511+ Path . Combine ( nextDrive , Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ) ;
1512+ process . StartInfo . WorkingDirectory = project . ProjectPath ;
1513+ process . StartInfo . UseShellExecute = true ;
1514+ process . StartInfo . CreateNoWindow = false ;
1515+ outLog . Writer . WriteLine ( process . StartInfo . FileName + " " + process . StartInfo . Arguments ) ;
1516+ process . Start ( ) ;
1517+ process . WaitForExit ( ) ;
1518+ }
1519+ else if ( emulatorName . ToLower ( ) == "zesarux" )
1520+ {
1521+ outLog . Writer . WriteLine ( "Launching ZEsarUX..." ) ;
1522+ Process process = new Process ( ) ;
1523+ process . StartInfo . FileName = emulatorPath ;
1524+ process . StartInfo . Arguments = string . Format (
1525+ "--noconfigfile --zoom 1 --machine TBBlue --realvideo --enabletimexvideo --tbblue-fast-boot-mode --enable-esxdos-handler --esxdos-root-dir \" {0}\" \" {1}\" --snap-no-change-machine" ,
1526+ nextDrive ,
1527+ Path . Combine ( nextDrive , Path . GetFileNameWithoutExtension ( settings . MainFile ) + ".nex" ) ) ;
1528+ process . StartInfo . WorkingDirectory = Path . GetDirectoryName ( emulatorPath ) ;
1529+ process . StartInfo . UseShellExecute = true ;
1530+ process . StartInfo . CreateNoWindow = false ;
1531+ outLog . Writer . WriteLine ( process . StartInfo . FileName + " " + process . StartInfo . Arguments ) ;
1532+ process . Start ( ) ;
1533+ process . WaitForExit ( ) ;
1534+ }
1535+ else
1536+ {
1537+ errorMsg = "There is no valid emulator configured for Next. Please configure an emulator (CSpect or ZEsarUX) from the Tools -> Options menu." ;
15221538 }
15231539 }
15241540 catch ( Exception ex )
@@ -1541,38 +1557,61 @@ private async void BuildAndRun(object? sender, Avalonia.Interactivity.RoutedEven
15411557 else if ( program != null )
15421558 {
15431559 // No Next mode :)
1544- loadedProgram = program ;
1545- var disas = openDocuments . FirstOrDefault ( e => e . DocumentPath == ZXConstants . DISASSEMBLY_DOC ) as ZXTextEditor ;
1546-
1547- Dispatcher . UIThread . InvokeAsync ( async ( ) =>
1560+ if ( settings . ExternalEmulator )
15481561 {
1549- if ( disas != null )
1562+ outLog . Writer . WriteLine ( $ "Custom emulator launcher: { settings . ExternalEmuladorValue } ") ;
1563+ if ( ! ZXProjectBuilder . ExecuteFile ( settings . ExternalEmuladorValue , new string [ ]
1564+ {
1565+ project . ProjectPath ,
1566+ Path . GetFileNameWithoutExtension ( settings . MainFile )
1567+ } ,
1568+ project . ProjectPath ,
1569+ outLog . Writer ) )
1570+ {
1571+ outLog . Writer . WriteLine ( "Error executing custom emulator launcher." ) ;
1572+ }
1573+ Dispatcher . UIThread . InvokeAsync ( ( ) =>
15501574 {
1551- if ( loadedProgram . Disassembly == null )
1575+ UnblockEditors ( ) ;
1576+ EmulatorInfo . CanDebug = FileInfo . ProjectLoaded ;
1577+ EmulatorInfo . CanRun = FileInfo . ProjectLoaded ;
1578+ } ) ;
1579+ }
1580+ else
1581+ {
1582+ loadedProgram = program ;
1583+ var disas = openDocuments . FirstOrDefault ( e => e . DocumentPath == ZXConstants . DISASSEMBLY_DOC ) as ZXTextEditor ;
1584+
1585+ Dispatcher . UIThread . InvokeAsync ( async ( ) =>
1586+ {
1587+ if ( disas != null )
15521588 {
1553- var parent = disas . Parent as TabItem ;
1554- if ( parent != null )
1589+ if ( loadedProgram . Disassembly == null )
15551590 {
1556- parent . IsSelected = true ;
1557- CloseFile ( null , e ) ;
1591+ var parent = disas . Parent as TabItem ;
1592+ if ( parent != null )
1593+ {
1594+ parent . IsSelected = true ;
1595+ CloseFile ( null , e ) ;
1596+ }
15581597 }
1598+ else
1599+ disas . Text = loadedProgram . Disassembly . Content ;
15591600 }
1560- else
1561- disas . Text = loadedProgram . Disassembly . Content ;
1562- }
15631601
1564- if ( ! emu . InjectProgram ( program . Org , program . Binary , program . Banks ? . ToArray ( ) , true ) )
1565- {
1566- await this . ShowError ( "Error" , "Cannot inject program! Check program size and address." ) ;
1567- }
1568- else
1569- {
1570- emuDock . Select ( ) ;
1571- emu . Focus ( ) ;
1572- }
1573- EmulatorInfo . CanDebug = FileInfo . ProjectLoaded ;
1574- EmulatorInfo . CanRun = FileInfo . ProjectLoaded ;
1575- } ) ;
1602+ if ( ! emu . InjectProgram ( program . Org , program . Binary , program . Banks ? . ToArray ( ) , true ) )
1603+ {
1604+ await this . ShowError ( "Error" , "Cannot inject program! Check program size and address." ) ;
1605+ }
1606+ else
1607+ {
1608+ emuDock . Select ( ) ;
1609+ emu . Focus ( ) ;
1610+ }
1611+ EmulatorInfo . CanDebug = FileInfo . ProjectLoaded ;
1612+ EmulatorInfo . CanRun = FileInfo . ProjectLoaded ;
1613+ } ) ;
1614+ }
15761615 }
15771616 else
15781617 {
0 commit comments