Skip to content

Commit

Permalink
Allow for loading from disk file only
Browse files Browse the repository at this point in the history
  • Loading branch information
azertyfun committed Sep 5, 2016
1 parent 9e1711c commit 4f9282c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/tk/azertyfun/dcputoolchain/DCPUToolChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public static void usage() {
"\n" +
"Usage:\n" +
" java -jar DCPU-Toolchain.jar assemble <input file> <output file> [--bootloader=/path/to/file] [--big-endian] [--disable-shortLiterals]\n" +
" 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" +
" 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" +
"\n" +
"Options:\n" +
" --assemble The specified input file is assembly instead of binary and must be assembled at runtime.\n" +
Expand Down
52 changes: 27 additions & 25 deletions src/tk/azertyfun/dcputoolchain/Emulator.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,35 +277,37 @@ public Emulator(String[] args) {

hardware.add(bootDrive);
} else {
M35FD bootDrive;
if(bootloader) {
File tmpFile = File.createTempFile("DCPUToolchain", Long.toString(System.currentTimeMillis()));
byte[] input_file_data = Files.readAllBytes(Paths.get(input_file));

byte[] bootloader_data_bytes = new byte[1024];
for (int i = 0; i < 512; ++i) {
if(little_endian != bootloader_little_endian) {
bootloader_data_bytes[i * 2] = (byte) (bootloader_data[i] & 0xFF);
bootloader_data_bytes[i * 2 + 1] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
} else {
bootloader_data_bytes[i * 2] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
bootloader_data_bytes[i * 2 + 1] = (byte) (bootloader_data[i] & 0xFF);
if(!input_file.equalsIgnoreCase("none")) {
M35FD bootDrive;
if (bootloader) {
File tmpFile = File.createTempFile("DCPUToolchain", Long.toString(System.currentTimeMillis()));
byte[] input_file_data = Files.readAllBytes(Paths.get(input_file));

byte[] bootloader_data_bytes = new byte[1024];
for (int i = 0; i < 512; ++i) {
if (little_endian != bootloader_little_endian) {
bootloader_data_bytes[i * 2] = (byte) (bootloader_data[i] & 0xFF);
bootloader_data_bytes[i * 2 + 1] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
} else {
bootloader_data_bytes[i * 2] = (byte) ((bootloader_data[i] >> 8) & 0xFF);
bootloader_data_bytes[i * 2 + 1] = (byte) (bootloader_data[i] & 0xFF);
}
}
}

FileOutputStream fos = new FileOutputStream(tmpFile);
fos.write(bootloader_data_bytes);
fos.write(input_file_data);
fos.close();
FileOutputStream fos = new FileOutputStream(tmpFile);
fos.write(bootloader_data_bytes);
fos.write(input_file_data);
fos.close();

bootDrive = hardwareTracker.requestM35FD(tmpFile.getAbsolutePath(), little_endian);
} else {
bootDrive = hardwareTracker.requestM35FD(input_file, little_endian);
}
bootDrive.connectTo(dcpu);
bootDrive.powerOn();
bootDrive = hardwareTracker.requestM35FD(tmpFile.getAbsolutePath(), little_endian);
} else {
bootDrive = hardwareTracker.requestM35FD(input_file, little_endian);
}
bootDrive.connectTo(dcpu);
bootDrive.powerOn();

hardware.add(bootDrive);
hardware.add(bootDrive);
}
}
dcpu.setRam(getClass().getResourceAsStream("/rom.bin"), rom_little_endian);

Expand Down

0 comments on commit 4f9282c

Please sign in to comment.