Skip to content

Commit b6cdbed

Browse files
authored
Merge branch 'master' into build-log-additions
2 parents 2224dc1 + ab2db22 commit b6cdbed

9 files changed

Lines changed: 197 additions & 68 deletions

File tree

ZXBStudio/App.axaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,47 @@
8787
<Setter Property="CornerRadius" Value="4" />
8888
<Setter Property="Focusable" Value="False"></Setter>
8989
</Style>
90+
91+
<Style Selector="Button.toolbar_r90">
92+
<Setter Property="Background" Value="#ffb0b0b0" />
93+
<Setter Property="Width" Value="24" />
94+
<Setter Property="Height" Value="24" />
95+
<Setter Property="Padding" Value="2" />
96+
<Setter Property="CornerRadius" Value="4" />
97+
<Setter Property="Focusable" Value="False"></Setter>
98+
<Setter Property="RenderTransform">
99+
<Setter.Value>
100+
<RotateTransform Angle="90"/>
101+
</Setter.Value>
102+
</Setter>
103+
</Style>
104+
<Style Selector="Button.toolbar_r270">
105+
<Setter Property="Background" Value="#ffb0b0b0" />
106+
<Setter Property="Width" Value="24" />
107+
<Setter Property="Height" Value="24" />
108+
<Setter Property="Padding" Value="2" />
109+
<Setter Property="CornerRadius" Value="4" />
110+
<Setter Property="Focusable" Value="False"></Setter>
111+
<Setter Property="RenderTransform">
112+
<Setter.Value>
113+
<RotateTransform Angle="270"/>
114+
</Setter.Value>
115+
</Setter>
116+
</Style>
117+
<Style Selector="Button.toolbar_hMirror">
118+
<Setter Property="Background" Value="#ffb0b0b0" />
119+
<Setter Property="Width" Value="24" />
120+
<Setter Property="Height" Value="24" />
121+
<Setter Property="Padding" Value="2" />
122+
<Setter Property="CornerRadius" Value="4" />
123+
<Setter Property="Focusable" Value="False"></Setter>
124+
<Setter Property="RenderTransform">
125+
<Setter.Value>
126+
<ScaleTransform ScaleX="-1"/>
127+
</Setter.Value>
128+
</Setter>
129+
</Style>
130+
90131
<Style Selector="ToggleButton.toolbar">
91132
<Setter Property="Background" Value="#fff0f0f0" />
92133
<Setter Property="Width" Value="24" />
@@ -105,6 +146,24 @@
105146
<Style Selector="Button.toolbar:pressed /template/ ContentPresenter#PART_ContentPresenter">
106147
<Setter Property="Background" Value="#ff606060" />
107148
</Style>
149+
<Style Selector="Button.toolbar_r90:pointerover /template/ ContentPresenter#PART_ContentPresenter">
150+
<Setter Property="Background" Value="#fff0f0f0" />
151+
</Style>
152+
<Style Selector="Button.toolbar_r90:pressed /template/ ContentPresenter#PART_ContentPresenter">
153+
<Setter Property="Background" Value="#ff606060" />
154+
</Style>
155+
<Style Selector="Button.toolbar_r270:pointerover /template/ ContentPresenter#PART_ContentPresenter">
156+
<Setter Property="Background" Value="#fff0f0f0" />
157+
</Style>
158+
<Style Selector="Button.toolbar_r270:pressed /template/ ContentPresenter#PART_ContentPresenter">
159+
<Setter Property="Background" Value="#ff606060" />
160+
</Style>
161+
<Style Selector="Button.toolbar_hMirror:pointerover /template/ ContentPresenter#PART_ContentPresenter">
162+
<Setter Property="Background" Value="#fff0f0f0" />
163+
</Style>
164+
<Style Selector="Button.toolbar_hMirror:pressed /template/ ContentPresenter#PART_ContentPresenter">
165+
<Setter Property="Background" Value="#ff606060" />
166+
</Style>
108167
<Style Selector="ComboBox.toolbar">
109168
<Setter Property="Margin" Value="0"></Setter>
110169
<Setter Property="CornerRadius" Value="5"></Setter>

ZXBStudio/BuildSystem/ZXProjectBuilder.cs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -156,18 +156,23 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
156156
sb.AppendLine("!MMU./sysvars.inc,10,$1C00");
157157
}
158158
// Origin
159-
{
160-
int org = settings.Origin == null ? 32768 : settings.Origin.Value;
161-
sb.AppendLine(string.Format("!PCSP${0:X2},${1:X2}", org, org - 2));
162-
}
159+
int org = settings.Origin == null ? 32768 : settings.Origin.Value;
160+
sb.AppendLine(string.Format("!PCSP${0:X2},${1:X2}", org, org - 2));
163161
// Main file
164162
{
165-
var bank = 5;
166-
var address = 0x2000;
163+
int[] nextBank16K = { 255, 5, 2, 0 };
164+
int bank = org/16384;
165+
int offset = org-(bank * 16384);
166+
if(bank<0 || bank > 3)
167+
{
168+
outputLogWritter.WriteLine("Error: Invalid ORG direction, must be >0 and <65535");
169+
return false;
170+
}
171+
bank = nextBank16K[bank];
167172
sb.AppendLine(string.Format(".\\{0},{1},${2:X2}",
168173
Path.Combine(Path.GetFileNameWithoutExtension(settings.MainFile) + ".bin"),
169174
bank,
170-
address));
175+
offset));
171176
}
172177
// Save nex.cfg file
173178
{
@@ -203,16 +208,27 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
203208

204209
outputLogWritter.WriteLine("Building .nex file...");
205210
Process process = new Process();
206-
process.StartInfo.FileName = "python.exe";
207-
process.StartInfo.Arguments = string.Format("{0} nex.cfg {1}",
208-
Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "tools", "nextcreator.py"),
209-
Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex");
210-
process.StartInfo.WorkingDirectory = project.ProjectPath;
211-
process.StartInfo.UseShellExecute = false;
212-
process.StartInfo.CreateNoWindow = true;
213-
process.StartInfo.RedirectStandardOutput = true;
211+
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
212+
{
213+
process.StartInfo.FileName = "python";
214+
process.StartInfo.Arguments = string.Format("{0} nex.cfg {1}",
215+
Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "tools", "nextcreator.py"),
216+
Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex");
217+
process.StartInfo.WorkingDirectory = project.ProjectPath;
218+
process.StartInfo.UseShellExecute = false;
219+
process.StartInfo.CreateNoWindow = true;
220+
process.StartInfo.RedirectStandardOutput = true;
221+
}
222+
else
223+
{
224+
process.StartInfo.FileName = Path.Combine(Path.GetDirectoryName(ZXOptions.Current.ZxbcPath), "tools", "nextcreator.py");
225+
process.StartInfo.Arguments = "nex.cfg " + Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex";
226+
process.StartInfo.WorkingDirectory = project.ProjectPath;
227+
process.StartInfo.UseShellExecute = false;
228+
process.StartInfo.CreateNoWindow = true;
229+
process.StartInfo.RedirectStandardOutput = true;
230+
}
214231
process.Start();
215-
216232
process.WaitForExit();
217233

218234
if (!File.Exists(nexFile))

ZXBStudio/Controls/ZXOutputLog.axaml

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,27 @@
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:svg="using:Avalonia.Svg.Skia"
56
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
67
x:Class="ZXBasicStudio.Controls.ZXOutputLog">
7-
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF202020" Name="scrOutput" VerticalScrollBarVisibility="Auto">
8-
<TextBlock TextWrapping="Wrap" Foreground="White" Name="tbOutput" Padding="10"></TextBlock>
9-
</ScrollViewer>
10-
</UserControl>
8+
<UserControl.ContextMenu>
9+
<ContextMenu Placement="Pointer">
10+
<MenuItem Header="Clear output window" Name="mnuClearOutputWindow" />
11+
<MenuItem Header="Copy to clipboard" Name="mnuCopyToClipboard" />
12+
</ContextMenu>
13+
</UserControl.ContextMenu>
14+
<Grid RowDefinitions="auto,*">
15+
<Grid ColumnDefinitions="1*" DataContext=".ZXMemoryView">
16+
<StackPanel Grid.Row="0" Spacing="2" Orientation="Horizontal" Margin="2,4" HorizontalAlignment="Left">
17+
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnClearOutputWindow" ToolTip.Tip="Clear output window"><svg:Svg Path="/Svg/eraser-solid.svg"></svg:Svg></Button>
18+
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnCopyToClipboard" ToolTip.Tip="Copy output log to clipboard"><svg:Svg Path="/Svg/copy-solid.svg"></svg:Svg></Button>
19+
</StackPanel>
20+
</Grid>
21+
<Grid Grid.Row="1">
22+
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF202020" Name="scrOutput"
23+
VerticalScrollBarVisibility="Auto">
24+
<TextBlock TextWrapping="Wrap" Foreground="White" Name="tbOutput" Padding="10"></TextBlock>
25+
</ScrollViewer>
26+
</Grid>
27+
</Grid>
28+
</UserControl>

ZXBStudio/Controls/ZXOutputLog.axaml.cs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1+
using System;
2+
using System.Threading.Tasks;
13
using Avalonia.Controls;
4+
using Avalonia;
5+
using Avalonia.Controls.ApplicationLifetimes;
26
using ZXBasicStudio.Classes;
37

48
namespace ZXBasicStudio.Controls
@@ -8,16 +12,40 @@ public partial class ZXOutputLog : UserControl
812
ZXLogTextWriter _writer;
913

1014
public ZXLogTextWriter Writer { get { return _writer; } }
11-
15+
16+
1217
public ZXOutputLog()
1318
{
1419
InitializeComponent();
1520
_writer = new ZXLogTextWriter(tbOutput, scrOutput);
21+
mnuClearOutputWindow.Click += ClearOutputWindow;
22+
mnuCopyToClipboard.Click += CopyToClipboard;
23+
btnClearOutputWindow.Click += ClearOutputWindow;
24+
btnCopyToClipboard.Click += CopyToClipboard;
1625
}
1726

1827
public void Clear()
1928
{
2029
tbOutput.Text = "";
2130
}
31+
32+
private async void ClearOutputWindow(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
33+
{
34+
tbOutput.Text = "";
35+
}
36+
37+
private async void CopyToClipboard(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
38+
{
39+
await DoSetClipboardTextAsync(tbOutput.Text);
40+
}
41+
42+
private async Task DoSetClipboardTextAsync(string? text)
43+
{
44+
if (Application.Current?.ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop ||
45+
desktop.MainWindow?.Clipboard is not { } provider)
46+
throw new NullReferenceException("Missing Clipboard instance.");
47+
48+
await provider.SetTextAsync(text);
49+
}
2250
}
2351
}

ZXBStudio/DocumentEditors/ZXGraphics/FontGDUEditor.axaml

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,45 +8,7 @@
88
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
99
Focusable ="True"
1010
Background="#ff202020"
11-
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.FontGDUEditor">
12-
<UserControl.Styles>
13-
<Style Selector="Button.toolbar_r90">
14-
<Setter Property="Background" Value="#fff0f0f0" />
15-
<Setter Property="Width" Value="32" />
16-
<Setter Property="Height" Value="32" />
17-
<Setter Property="Padding" Value="4" />
18-
<Setter Property="CornerRadius" Value="4" />
19-
<Setter Property="RenderTransform">
20-
<Setter.Value>
21-
<RotateTransform Angle="90"/>
22-
</Setter.Value>
23-
</Setter>
24-
</Style>
25-
<Style Selector="Button.toolbar_r270">
26-
<Setter Property="Background" Value="#fff0f0f0" />
27-
<Setter Property="Width" Value="32" />
28-
<Setter Property="Height" Value="32" />
29-
<Setter Property="Padding" Value="4" />
30-
<Setter Property="CornerRadius" Value="4" />
31-
<Setter Property="RenderTransform">
32-
<Setter.Value>
33-
<RotateTransform Angle="270"/>
34-
</Setter.Value>
35-
</Setter>
36-
</Style>
37-
<Style Selector="Button.toolbar_hMirror">
38-
<Setter Property="Background" Value="#fff0f0f0" />
39-
<Setter Property="Width" Value="32" />
40-
<Setter Property="Height" Value="32" />
41-
<Setter Property="Padding" Value="4" />
42-
<Setter Property="CornerRadius" Value="4" />
43-
<Setter Property="RenderTransform">
44-
<Setter.Value>
45-
<ScaleTransform ScaleX="-1"/>
46-
</Setter.Value>
47-
</Setter>
48-
</Style>
49-
</UserControl.Styles>
11+
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.FontGDUEditor">
5012

5113
<Grid Name="grdMain">
5214
<Grid Name="grdEditor" ColumnDefinitions="180,4,*,4,200" Margin="0,8,0,0">

ZXBStudio/MainWindow.axaml.cs

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,38 +1427,67 @@ private async void BuildAndRun(object? sender, Avalonia.Interactivity.RoutedEven
14271427
}
14281428
else
14291429
{
1430+
// Cleaning...
1431+
{
1432+
outLog.Writer.WriteLine("Cleaning temp files...");
1433+
var file = Path.Combine(project.ProjectPath, Path.GetFileNameWithoutExtension(settings.MainFile) + ".bin");
1434+
if (File.Exists(file))
1435+
{
1436+
File.Delete(file);
1437+
}
1438+
file = Path.Combine(project.ProjectPath, "nex.cfg");
1439+
if (File.Exists(file))
1440+
{
1441+
File.Delete(file);
1442+
}
1443+
file = Path.Combine(project.ProjectPath, "sysvars.inc");
1444+
if (File.Exists(file))
1445+
{
1446+
File.Delete(file);
1447+
}
1448+
file = Path.Combine(project.ProjectPath, Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex");
1449+
if (File.Exists(file))
1450+
{
1451+
File.Delete(file);
1452+
}
1453+
}
1454+
14301455
try
14311456
{
1432-
var emulatorName = Path.GetFileName(emulatorPath);
1457+
var emulatorName = Path.GetFileNameWithoutExtension(emulatorPath);
1458+
var nextDrive = Path.Combine(project.ProjectPath, "nextdrive");
14331459
switch (emulatorName.ToLower())
14341460
{
1435-
case "cspect.exe":
1461+
case "cspect":
14361462
{
14371463
outLog.Writer.WriteLine("Launching CSpect...");
14381464
Process process = new Process();
14391465
process.StartInfo.FileName = emulatorPath;
14401466
process.StartInfo.Arguments = string.Format(
1441-
"-zxnext -tv -w3 -brk -r -mmc=.\\nextdrive\\ .\\nextdrive\\{0}",
1442-
Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex");
1467+
"-zxnext -tv -w3 -brk -r -mmc=\"{0}\" \"{1}\"",
1468+
nextDrive,
1469+
Path.Combine(nextDrive, Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex"));
14431470
process.StartInfo.WorkingDirectory = project.ProjectPath;
14441471
process.StartInfo.UseShellExecute = true;
14451472
process.StartInfo.CreateNoWindow = false;
1473+
outLog.Writer.WriteLine(process.StartInfo.FileName+" "+process.StartInfo.Arguments);
14461474
process.Start();
14471475
process.WaitForExit();
14481476
}
14491477
break;
1450-
case "zesarux.exe":
1478+
case "zesarux":
14511479
{
14521480
outLog.Writer.WriteLine("Launching ZEsarUX...");
14531481
Process process = new Process();
14541482
process.StartInfo.FileName = emulatorPath;
14551483
process.StartInfo.Arguments = string.Format(
1456-
"--noconfigfile --zoom 1 --machine TBBlue --realvideo --enabletimexvideo --tbblue-fast-boot-mode --enable-esxdos-handler --esxdos-root-dir {0} {1} --snap-no-change-machine",
1457-
Path.Combine(project.ProjectPath, "nextdrive"),
1458-
Path.Combine(project.ProjectPath, "nextdrive", Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex"));
1484+
"--noconfigfile --zoom 1 --machine TBBlue --realvideo --enabletimexvideo --tbblue-fast-boot-mode --enable-esxdos-handler --esxdos-root-dir \"{0}\" \"{1}\" --snap-no-change-machine",
1485+
nextDrive,
1486+
Path.Combine(nextDrive, Path.GetFileNameWithoutExtension(settings.MainFile) + ".nex"));
14591487
process.StartInfo.WorkingDirectory = Path.GetDirectoryName(emulatorPath);
14601488
process.StartInfo.UseShellExecute = true;
14611489
process.StartInfo.CreateNoWindow = false;
1490+
outLog.Writer.WriteLine(process.StartInfo.FileName + " " + process.StartInfo.Arguments);
14621491
process.Start();
14631492
process.WaitForExit();
14641493
}
Lines changed: 8 additions & 0 deletions
Loading

ZXBStudio/Svg/eraser-solid.svg

Lines changed: 6 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)