@@ -21,6 +21,8 @@ procedure RenderSongToFile(Song: TSong; Filename: String); |
| 21 |
|
21 |
|
| 22 |
implementation |
22 |
implementation |
| 23 |
|
23 |
|
|
|
24 |
uses process; |
|
|
25 |
|
| 24 |
function RenderOrderTable(OrderMatrix: TOrderMatrix): String; |
26 |
function RenderOrderTable(OrderMatrix: TOrderMatrix): String; |
| 25 |
function ArrayHelper(Ints: array of Integer): String; |
27 |
function ArrayHelper(Ints: array of Integer): String; |
| 26 |
var |
28 |
var |
@@ -144,6 +146,8 @@ function RenderPreviewROM(Song: TSong): Boolean; |
| 144 |
var |
146 |
var |
| 145 |
OutFile: Text; |
147 |
OutFile: Text; |
| 146 |
I: Integer; |
148 |
I: Integer; |
|
|
149 |
Proc: TProcess; |
|
|
150 |
OutSL: TStringList; |
| 147 |
label AssemblyError, Cleanup; |
151 |
label AssemblyError, Cleanup; |
| 148 |
begin |
152 |
begin |
| 149 |
AssignFile(OutFile, './hUGEDriver/wave.htt'); |
153 |
AssignFile(OutFile, './hUGEDriver/wave.htt'); |
@@ -172,17 +176,33 @@ begin |
| 172 |
// Assemble the ROM |
176 |
// Assemble the ROM |
| 173 |
Chdir('hUGEDriver'); |
177 |
Chdir('hUGEDriver'); |
| 174 |
|
178 |
|
| 175 |
if ExecuteProcess(('rgbasm'), |
179 |
OutSL := TStringList.Create; |
| 176 |
'-opreview.obj driverLite.z80', []) <> 0 then |
180 |
Proc := TProcess.Create(nil); |
| 177 |
goto AssemblyError; |
181 |
Proc.Options := Proc.Options + [poWaitOnExit, poUsePipes, poStdErrToOutput]; |
| 178 |
|
182 |
|
| 179 |
if ExecuteProcess(('rgblink'), |
183 |
Proc.Executable := 'rgbasm'; |
| 180 |
'-mpreview.map -npreview.sym -opreview.gb preview.obj', []) <> 0 then |
184 |
Proc.Parameters.Clear; |
| 181 |
goto AssemblyError; |
185 |
Proc.Parameters.add('-opreview.obj'); |
| 182 |
|
186 |
Proc.Parameters.add('driverLite.z80'); |
| 183 |
if ExecuteProcess(('rgbfix'), |
187 |
Proc.Execute; |
| 184 |
'-p0 -v preview.gb', []) <> 0 then |
188 |
if Proc.ExitCode <> 0 then goto AssemblyError; |
| 185 |
goto AssemblyError; |
189 |
|
|
|
190 |
Proc.Executable := 'rgblink'; |
|
|
191 |
Proc.Parameters.Clear; |
|
|
192 |
Proc.Parameters.add('-mpreview.map'); |
|
|
193 |
Proc.Parameters.add('-npreview.sym'); |
|
|
194 |
Proc.Parameters.add('-opreview.gb'); |
|
|
195 |
Proc.Parameters.add('preview.obj'); |
|
|
196 |
Proc.Execute; |
|
|
197 |
if Proc.ExitCode <> 0 then goto AssemblyError; |
|
|
198 |
|
|
|
199 |
Proc.Executable := 'rgbfix'; |
|
|
200 |
Proc.Parameters.Clear; |
|
|
201 |
Proc.Parameters.add('-p0'); |
|
|
202 |
Proc.Parameters.add('-v'); |
|
|
203 |
Proc.Parameters.add('preview.gb'); |
|
|
204 |
Proc.Execute; |
|
|
205 |
if Proc.ExitCode <> 0 then goto AssemblyError; |
| 186 |
|
206 |
|
| 187 |
Result := True; |
207 |
Result := True; |
| 188 |
goto Cleanup; |
208 |
goto Cleanup; |
@@ -190,9 +210,19 @@ begin |
| 190 |
// Eh, screw good practice. How bad can it be? |
210 |
// Eh, screw good practice. How bad can it be? |
| 191 |
AssemblyError: |
211 |
AssemblyError: |
| 192 |
Result := False; |
212 |
Result := False; |
| 193 |
MessageDlg('Error!', 'There was an error assembling the song for playback. Write the rest of this dialog.', mtError, [mbOK], 0); |
213 |
OutSL.LoadFromStream(Proc.Output); |
|
|
214 |
MessageDlg( |
|
|
215 |
'Error!', |
|
|
216 |
'There was an error assembling the song for playback.'+LineEnding+LineEnding+ |
|
|
217 |
Proc.Executable+' output:'+LineEnding+ |
|
|
218 |
OutSL.Text, |
|
|
219 |
mtError, |
|
|
220 |
[mbOK], |
|
|
221 |
0); |
| 194 |
|
222 |
|
| 195 |
Cleanup: |
223 |
Cleanup: |
|
|
224 |
Proc.Free; |
|
|
225 |
OutSL.Free; |
| 196 |
Chdir('..'); |
226 |
Chdir('..'); |
| 197 |
end; |
227 |
end; |
| 198 |
|
228 |
|