diff --git a/src/main/java/dk/camelot64/kickc/KickC.java b/src/main/java/dk/camelot64/kickc/KickC.java index ba30d2d5e..16ab2403f 100644 --- a/src/main/java/dk/camelot64/kickc/KickC.java +++ b/src/main/java/dk/camelot64/kickc/KickC.java @@ -61,6 +61,9 @@ public class KickC implements Callable { @CommandLine.Option(names = {"-e"}, description = "Execute the assembled prg file using VICE. Implicitly assembles the output.") private boolean execute = false; + @CommandLine.Option(names = {"-emu"}, description = "Execute the assembled program file by passing it to the named emulator. Implicitly assembles the output.") + private String emulator = null; + @CommandLine.Option(names = {"-d"}, description = "Debug the assembled prg file using C64Debugger. Implicitly assembles the output.") private boolean debug = false; @@ -390,7 +393,7 @@ public class KickC implements Callable { // Assemble the asm-file if instructed String prgFileName = outputFileNameBase + ".prg"; Path prgPath = outputDir.resolve(prgFileName); - if(assemble || execute || debug) { + if(assemble || execute || debug || (emulator != null)) { Path kasmLogPath = outputDir.resolve(outputFileNameBase + ".klog"); System.out.println("Assembling to " + prgPath.toString()); String[] assembleCommand = {asmPath.toString(), "-log", kasmLogPath.toString(), "-o", prgPath.toString(), "-vicesymbols", "-showmem", "-debugdump"}; @@ -419,30 +422,34 @@ public class KickC implements Callable { } } - // Debug the prg-file if instructed if(debug) { - System.out.println("Debugging " + prgPath); + emulator = "C64Debugger"; + } + if(execute) { + emulator = "x64sc"; + } + String emuOptions = ""; + if(emulator.equals("C64Debugger")) { Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs"); - String debugCommand = "C64Debugger " + "-symbols " + viceSymbolsPath + " -wait 2500" + " -prg " + prgPath.toString(); - if(verbose) { - System.out.println("Debugging command: " + debugCommand); - } - Process process = Runtime.getRuntime().exec(debugCommand); - process.waitFor(); + emuOptions = "-symbols " + viceSymbolsPath + " -wait 2500" + " "; + } + // The program names used by VICE emulators + List viceEmus = Arrays.asList("x64", "x64sc", "x128", "x64dtv", "xcbm2", "xcbm5x0", "xpet", "xplus4", "xscpu64", "xvic"); + if(viceEmus.contains(emulator)) { + Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs"); + emuOptions = "-moncommands " + viceSymbolsPath.toAbsolutePath().toString() + " "; } // Execute the prg-file if instructed - if(execute) { - System.out.println("Executing " + prgPath); - Path viceSymbolsPath = outputDir.resolve(outputFileNameBase + ".vs"); - String executeCommand = "x64sc " + "-moncommands " + viceSymbolsPath + " " + prgPath.toString(); + if(emulator != null) { + System.out.println("Executing " + prgPath + " using " + emulator); + String executeCommand = emulator + " " + emuOptions + prgPath.toAbsolutePath().toString(); if(verbose) { System.out.println("Executing command: " + executeCommand); } Process process = Runtime.getRuntime().exec(executeCommand); process.waitFor(); } - } return null; diff --git a/src/main/java/dk/camelot64/kickc/model/TargetCpu.java b/src/main/java/dk/camelot64/kickc/model/TargetCpu.java index 16432bb39..1a7c755e2 100644 --- a/src/main/java/dk/camelot64/kickc/model/TargetCpu.java +++ b/src/main/java/dk/camelot64/kickc/model/TargetCpu.java @@ -11,7 +11,7 @@ import java.util.List; public enum TargetCpu { /** Vanilla MOS 6502 CPU running in ROM - no illegal opcodes, no self-modifying code. */ ROM6502("rom6502", Collections.singletonList(Feature.MOS6502_COMMON)), - /** MOS 6502 CPU - allows illegal instructions, no self-modifying code. */ + /** MOS 6502 CPU running in ROM - allows illegal instructions, no self-modifying code. */ ROM6502X("rom6502x", Arrays.asList(Feature.MOS6502_COMMON, Feature.MOS6502_UNODC)), /** Vanilla MOS 6502 CPU - no illegal opcodes, allows self-modifying code. */ MOS6502("mos6502", Arrays.asList(Feature.MOS6502_COMMON, Feature.MOS6502_SELFMOD)), @@ -29,7 +29,7 @@ public enum TargetCpu { public static final TargetCpu DEFAULT = MOS6502X; /** Feature of a CPU. A feature is represented by a folder containing a number of fragments. */ - public static enum Feature { + public enum Feature { /** Official Instruction Set of the MOS6502 CPU. https://www.masswerk.at/6502/6502_instruction_set.html */ MOS6502_COMMON("mos6502-common"), /** The Undocumented Opcodes of the MOS6502 CPU. http://www.oxyron.de/html/opcodes02.html */