Skip to content

Commit 4f9282c

Browse files
author
azertyfun
committed
Allow for loading from disk file only
1 parent 9e1711c commit 4f9282c

File tree

2 files changed

+28
-26
lines changed

2 files changed

+28
-26
lines changed

src/tk/azertyfun/dcputoolchain/DCPUToolChain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public static void usage() {
7575
"\n" +
7676
"Usage:\n" +
7777
" java -jar DCPU-Toolchain.jar assemble <input file> <output file> [--bootloader=/path/to/file] [--big-endian] [--disable-shortLiterals]\n" +
78-
" java -jar DCPU-Toolchain.jar run <file> [--assemble] [--big-endian] [--rom-big-endian] [--bootloader=/path/to/file] [--debugger] [--clock] [--keyboard] [--lem1802] [--edc] [--M35FD=/path/to/file] [--M525HD=/path/to/file] [--console]\n" +
78+
" java -jar DCPU-Toolchain.jar run <file | none> [--assemble] [--big-endian] [--rom-big-endian] [--bootloader=/path/to/file] [--debugger] [--clock] [--keyboard] [--lem1802] [--edc] [--M35FD=/path/to/file] [--M525HD=/path/to/file] [--console]\n" +
7979
"\n" +
8080
"Options:\n" +
8181
" --assemble The specified input file is assembly instead of binary and must be assembled at runtime.\n" +

src/tk/azertyfun/dcputoolchain/Emulator.java

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -277,35 +277,37 @@ public Emulator(String[] args) {
277277

278278
hardware.add(bootDrive);
279279
} else {
280-
M35FD bootDrive;
281-
if(bootloader) {
282-
File tmpFile = File.createTempFile("DCPUToolchain", Long.toString(System.currentTimeMillis()));
283-
byte[] input_file_data = Files.readAllBytes(Paths.get(input_file));
284-
285-
byte[] bootloader_data_bytes = new byte[1024];
286-
for (int i = 0; i < 512; ++i) {
287-
if(little_endian != bootloader_little_endian) {
288-
bootloader_data_bytes[i * 2] = (byte) (bootloader_data[i] & 0xFF);
289-
bootloader_data_bytes[i * 2 + 1] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
290-
} else {
291-
bootloader_data_bytes[i * 2] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
292-
bootloader_data_bytes[i * 2 + 1] = (byte) (bootloader_data[i] & 0xFF);
280+
if(!input_file.equalsIgnoreCase("none")) {
281+
M35FD bootDrive;
282+
if (bootloader) {
283+
File tmpFile = File.createTempFile("DCPUToolchain", Long.toString(System.currentTimeMillis()));
284+
byte[] input_file_data = Files.readAllBytes(Paths.get(input_file));
285+
286+
byte[] bootloader_data_bytes = new byte[1024];
287+
for (int i = 0; i < 512; ++i) {
288+
if (little_endian != bootloader_little_endian) {
289+
bootloader_data_bytes[i * 2] = (byte) (bootloader_data[i] & 0xFF);
290+
bootloader_data_bytes[i * 2 + 1] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
291+
} else {
292+
bootloader_data_bytes[i * 2] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
293+
bootloader_data_bytes[i * 2 + 1] = (byte) (bootloader_data[i] & 0xFF);
294+
}
293295
}
294-
}
295296

296-
FileOutputStream fos = new FileOutputStream(tmpFile);
297-
fos.write(bootloader_data_bytes);
298-
fos.write(input_file_data);
299-
fos.close();
297+
FileOutputStream fos = new FileOutputStream(tmpFile);
298+
fos.write(bootloader_data_bytes);
299+
fos.write(input_file_data);
300+
fos.close();
300301

301-
bootDrive = hardwareTracker.requestM35FD(tmpFile.getAbsolutePath(), little_endian);
302-
} else {
303-
bootDrive = hardwareTracker.requestM35FD(input_file, little_endian);
304-
}
305-
bootDrive.connectTo(dcpu);
306-
bootDrive.powerOn();
302+
bootDrive = hardwareTracker.requestM35FD(tmpFile.getAbsolutePath(), little_endian);
303+
} else {
304+
bootDrive = hardwareTracker.requestM35FD(input_file, little_endian);
305+
}
306+
bootDrive.connectTo(dcpu);
307+
bootDrive.powerOn();
307308

308-
hardware.add(bootDrive);
309+
hardware.add(bootDrive);
310+
}
309311
}
310312
dcpu.setRam(getClass().getResourceAsStream("/rom.bin"), rom_little_endian);
311313

0 commit comments

Comments
 (0)