diff --git a/codeCore/src/prog8/code/core/ICompilationTarget.kt b/codeCore/src/prog8/code/core/ICompilationTarget.kt index 9b4d9e0c4..62e592e9b 100644 --- a/codeCore/src/prog8/code/core/ICompilationTarget.kt +++ b/codeCore/src/prog8/code/core/ICompilationTarget.kt @@ -28,6 +28,7 @@ interface ICompilationTarget: IStringEncoding, IMemSizer { val libraryPath: Path? val customLauncher: List val additionalAssemblerOptions: String? + val defaultOutputType: OutputType fun initializeMemoryAreas(compilerOptions: CompilationOptions) fun getFloatAsmBytes(num: Number): String diff --git a/codeCore/src/prog8/code/target/C128Target.kt b/codeCore/src/prog8/code/target/C128Target.kt index f4750a806..6b2a4e788 100644 --- a/codeCore/src/prog8/code/target/C128Target.kt +++ b/codeCore/src/prog8/code/target/C128Target.kt @@ -12,6 +12,7 @@ class C128Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N override val libraryPath = null override val customLauncher: List = emptyList() override val additionalAssemblerOptions = null + override val defaultOutputType = OutputType.PRG companion object { const val NAME = "c128" diff --git a/codeCore/src/prog8/code/target/C64Target.kt b/codeCore/src/prog8/code/target/C64Target.kt index ba9fb1106..60b6c9435 100644 --- a/codeCore/src/prog8/code/target/C64Target.kt +++ b/codeCore/src/prog8/code/target/C64Target.kt @@ -13,6 +13,7 @@ class C64Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No override val libraryPath = null override val customLauncher: List = emptyList() override val additionalAssemblerOptions = null + override val defaultOutputType = OutputType.PRG companion object { const val NAME = "c64" diff --git a/codeCore/src/prog8/code/target/ConfigFileTarget.kt b/codeCore/src/prog8/code/target/ConfigFileTarget.kt index 3228a8cd3..e82090eb8 100644 --- a/codeCore/src/prog8/code/target/ConfigFileTarget.kt +++ b/codeCore/src/prog8/code/target/ConfigFileTarget.kt @@ -24,6 +24,7 @@ class ConfigFileTarget( override val BSSHIGHRAM_END: UInt, override val BSSGOLDENRAM_START: UInt, override val BSSGOLDENRAM_END: UInt, + override val defaultOutputType: OutputType, override val libraryPath: Path, override val customLauncher: List, override val additionalAssemblerOptions: String?, @@ -110,6 +111,9 @@ class ConfigFileTarget( val assemblerOptionsStr = props.getProperty("assembler_options", "").trim() val assemblerOptions = if(assemblerOptionsStr.isBlank()) null else assemblerOptionsStr + val outputTypeString = props.getProperty("output_type", "PRG") + val defaultOutputType = OutputType.valueOf(outputTypeString.uppercase()) + return ConfigFileTarget( configfile.nameWithoutExtension, Encoding.entries.first { it.prefix==props.getString("encoding") }, @@ -121,6 +125,7 @@ class ConfigFileTarget( props.getInteger("bss_highram_end"), props.getInteger("bss_goldenram_start"), props.getInteger("bss_goldenram_end"), + defaultOutputType, libraryPath, customLauncher, assemblerOptions, diff --git a/codeCore/src/prog8/code/target/Cx16Target.kt b/codeCore/src/prog8/code/target/Cx16Target.kt index 612389752..f13511cab 100644 --- a/codeCore/src/prog8/code/target/Cx16Target.kt +++ b/codeCore/src/prog8/code/target/Cx16Target.kt @@ -12,6 +12,7 @@ class Cx16Target: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by N override val libraryPath = null override val customLauncher: List = emptyList() override val additionalAssemblerOptions = null + override val defaultOutputType = OutputType.PRG companion object { const val NAME = "cx16" diff --git a/codeCore/src/prog8/code/target/PETTarget.kt b/codeCore/src/prog8/code/target/PETTarget.kt index 6088f1015..d0d9be82f 100644 --- a/codeCore/src/prog8/code/target/PETTarget.kt +++ b/codeCore/src/prog8/code/target/PETTarget.kt @@ -12,6 +12,7 @@ class PETTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by No override val libraryPath = null override val customLauncher: List = emptyList() override val additionalAssemblerOptions = null + override val defaultOutputType = OutputType.PRG companion object { const val NAME = "pet32" diff --git a/codeCore/src/prog8/code/target/VMTarget.kt b/codeCore/src/prog8/code/target/VMTarget.kt index 1c4f234ef..7b2041396 100644 --- a/codeCore/src/prog8/code/target/VMTarget.kt +++ b/codeCore/src/prog8/code/target/VMTarget.kt @@ -13,6 +13,7 @@ class VMTarget: ICompilationTarget, IStringEncoding by Encoder, IMemSizer by Nor override val libraryPath = null override val customLauncher: List = emptyList() override val additionalAssemblerOptions = null + override val defaultOutputType = OutputType.PRG companion object { const val NAME = "virtual" diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index 1b67a1c4e..793356f50 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -384,13 +384,13 @@ internal fun determineCompilationOptions(program: Program, compTarget: ICompilat .toList() val outputType = if (outputTypeStr == null) { - OutputType.PRG + compTarget.defaultOutputType } else { try { OutputType.valueOf(outputTypeStr) } catch (_: IllegalArgumentException) { // set default value; actual check and error handling of invalid option is handled in the AstChecker later - OutputType.PRG + compTarget.defaultOutputType } } var launcherType = if (launcherTypeStr == null) diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 963b54129..1837acafe 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -1,8 +1,6 @@ TODO ==== -atari customtarget: default output should be .xex not .prg (10.5 still did it correctly) - test irqs on various targets: set_irq, set_rasterirq can memset/memsetw be written without the need of a temp register variable? diff --git a/examples/customtarget/src/atari-fibonacci.p8 b/examples/customtarget/src/atari-fibonacci.p8 index b0434e525..0c70342ee 100644 --- a/examples/customtarget/src/atari-fibonacci.p8 +++ b/examples/customtarget/src/atari-fibonacci.p8 @@ -1,7 +1,6 @@ %import textio %zeropage basicsafe %launcher none -%output xex ; This example computes the first 20 values of the Fibonacci sequence. ; Note: this program is compatible with atari. diff --git a/examples/customtarget/src/atari-hello.p8 b/examples/customtarget/src/atari-hello.p8 index 3ef4559d9..e770a103a 100644 --- a/examples/customtarget/src/atari-hello.p8 +++ b/examples/customtarget/src/atari-hello.p8 @@ -1,7 +1,6 @@ %import textio %zeropage basicsafe %launcher none -%output xex ; hello world test for Atari 8-bit diff --git a/examples/customtarget/targetconfigs/atari.properties b/examples/customtarget/targetconfigs/atari.properties index 4e7d480dd..6d2be0488 100644 --- a/examples/customtarget/targetconfigs/atari.properties +++ b/examples/customtarget/targetconfigs/atari.properties @@ -3,6 +3,7 @@ cpu = 6502 encoding = atascii +output_type = XEX load_address = $2000 memtop = $ffff bss_highram_start = 0 diff --git a/examples/customtarget/targetconfigs/neo6502.properties b/examples/customtarget/targetconfigs/neo6502.properties index 4f6ad79e5..63a802d8f 100644 --- a/examples/customtarget/targetconfigs/neo6502.properties +++ b/examples/customtarget/targetconfigs/neo6502.properties @@ -3,6 +3,7 @@ cpu = 65C02 encoding = iso +# output_type = PRG load_address = $0800 memtop = $fc00 bss_highram_start = 0 diff --git a/examples/customtarget/targetconfigs/tinyc64.properties b/examples/customtarget/targetconfigs/tinyc64.properties index af950f02a..3728f1a52 100644 --- a/examples/customtarget/targetconfigs/tinyc64.properties +++ b/examples/customtarget/targetconfigs/tinyc64.properties @@ -2,6 +2,7 @@ cpu = 6502 encoding = petscii +# output_type = PRG load_address = $0801 memtop = $cfe0 bss_highram_start = $c000 diff --git a/examples/customtarget/targetconfigs/tinycx16.properties b/examples/customtarget/targetconfigs/tinycx16.properties index fc6069d6a..228a1721d 100644 --- a/examples/customtarget/targetconfigs/tinycx16.properties +++ b/examples/customtarget/targetconfigs/tinycx16.properties @@ -2,6 +2,7 @@ cpu = 65C02 encoding = petscii +# output_type = PRG load_address = $0801 memtop = $9f00 bss_highram_start = $a000 diff --git a/examples/customtarget/targetconfigs/tinypet.properties b/examples/customtarget/targetconfigs/tinypet.properties index 26cb6ab80..77063dc47 100644 --- a/examples/customtarget/targetconfigs/tinypet.properties +++ b/examples/customtarget/targetconfigs/tinypet.properties @@ -2,6 +2,7 @@ cpu = 6502 encoding = petscii +# output_type = PRG load_address = $0401 memtop = $8000 bss_highram_start = 0