From 9314c346da4d539ebd8706c7265b35ae38de114a Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sat, 3 Jun 2023 19:14:45 +0200 Subject: [PATCH] -target option is now required; c64 no longer the default --- compiler/src/prog8/CompilerMain.kt | 2 +- compiler/src/prog8/compiler/ModuleImporter.kt | 1 + docs/source/building.rst | 9 ++++----- docs/source/libraries.rst | 8 ++++++-- docs/source/upgrading8.rst | 1 + examples/animals.p8 | 2 +- examples/balls.p8 | 2 +- examples/bsieve.p8 | 2 +- examples/{ => c64}/balloonflight.p8 | 0 examples/{ => c64}/bdmusic-irq.p8 | 0 examples/{ => c64}/bdmusic.p8 | 0 examples/{ => c64}/charset.p8 | 0 examples/{ => c64}/cube3d-sprites.p8 | 0 examples/{ => c64}/cube3d.p8 | 0 examples/{ => c64}/plasma.p8 | 0 examples/{ => c64}/rasterbars.p8 | 0 examples/{ => c64}/sprites.p8 | 0 examples/{ => c64}/starfield.p8 | 0 examples/{ => c64}/tehtriz.p8 | 0 examples/{ => c64}/turtle-gfx.p8 | 0 examples/{ => c64}/wizzine.p8 | 0 examples/cube3d-float.p8 | 2 +- examples/cube3d-gfx.p8 | 2 +- examples/{ => cx16}/cxlogo.p8 | 4 ++-- examples/dirlist.p8 | 2 ++ examples/fibonacci.p8 | 2 +- examples/line-circle-gfx.p8 | 2 +- examples/line-circle-txt.p8 | 2 +- examples/mandelbrot-gfx.p8 | 2 +- examples/mandelbrot.p8 | 2 +- examples/maze.p8 | 2 +- examples/numbergame.p8 | 2 +- examples/primes.p8 | 3 +-- examples/screencodes.p8 | 2 +- examples/sorting.p8 | 2 +- examples/swirl-float.p8 | 2 +- examples/swirl.p8 | 2 +- examples/test.p8 | 14 +++++++------- examples/textelite.p8 | 2 +- 39 files changed, 42 insertions(+), 36 deletions(-) rename examples/{ => c64}/balloonflight.p8 (100%) rename examples/{ => c64}/bdmusic-irq.p8 (100%) rename examples/{ => c64}/bdmusic.p8 (100%) rename examples/{ => c64}/charset.p8 (100%) rename examples/{ => c64}/cube3d-sprites.p8 (100%) rename examples/{ => c64}/cube3d.p8 (100%) rename examples/{ => c64}/plasma.p8 (100%) rename examples/{ => c64}/rasterbars.p8 (100%) rename examples/{ => c64}/sprites.p8 (100%) rename examples/{ => c64}/starfield.p8 (100%) rename examples/{ => c64}/tehtriz.p8 (100%) rename examples/{ => c64}/turtle-gfx.p8 (100%) rename examples/{ => c64}/wizzine.p8 (100%) rename examples/{ => cx16}/cxlogo.p8 (75%) diff --git a/compiler/src/prog8/CompilerMain.kt b/compiler/src/prog8/CompilerMain.kt index 371c07ea8..5d3074394 100644 --- a/compiler/src/prog8/CompilerMain.kt +++ b/compiler/src/prog8/CompilerMain.kt @@ -48,7 +48,7 @@ private fun compileMain(args: Array): Boolean { val quietAssembler by cli.option(ArgType.Boolean, fullName = "quietasm", description = "don't print assembler output results") val slowCodegenWarnings by cli.option(ArgType.Boolean, fullName = "slowwarn", description="show debug warnings about slow/problematic assembly code generation") val sourceDirs by cli.option(ArgType.String, fullName="srcdirs", description = "list of extra paths, separated with ${File.pathSeparator}, to search in for imported modules").multiple().delimiter(File.pathSeparator) - val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}', '${AtariTarget.NAME}', '${VMTarget.NAME}')").default(C64Target.NAME) + val compilationTarget by cli.option(ArgType.String, fullName = "target", description = "target output of the compiler (one of '${C64Target.NAME}', '${C128Target.NAME}', '${Cx16Target.NAME}', '${AtariTarget.NAME}', '${VMTarget.NAME}')").required() val startVm by cli.option(ArgType.Boolean, fullName = "vm", description = "load and run a .p8ir IR source file in the VM") val watchMode by cli.option(ArgType.Boolean, fullName = "watch", description = "continuous compilation mode (watch for file changes)") val varsHigh by cli.option(ArgType.Boolean, fullName = "varshigh", description = "put uninitialized variables in high memory area instead of at the end of the program") diff --git a/compiler/src/prog8/compiler/ModuleImporter.kt b/compiler/src/prog8/compiler/ModuleImporter.kt index 4c2dcae6c..00a6ed3fe 100644 --- a/compiler/src/prog8/compiler/ModuleImporter.kt +++ b/compiler/src/prog8/compiler/ModuleImporter.kt @@ -32,6 +32,7 @@ class ModuleImporter(private val program: Program, val programPath = path.resolve(normalizedFilePath) if(programPath.exists()) { println("Compiling program ${Path("").absolute().relativize(programPath)}") + println("Compiler target: $compilationTargetName") val source = SourceCode.File(programPath) return Ok(importModule(source)) } diff --git a/docs/source/building.rst b/docs/source/building.rst index 55a412a87..2a8e8740d 100644 --- a/docs/source/building.rst +++ b/docs/source/building.rst @@ -109,10 +109,9 @@ One or more .p8 module files Prints short command line usage information. ``-target `` - Sets the target output of the compiler. + Sets the target output of the compiler. This option is required. ``c64`` = Commodore 64, ``c128`` = Commodore 128, ``cx16`` = Commander X16, ``atari`` = Atari 800 XL, ``virtual`` = builtin virtual machine. - Default = ``c64``. ``-srcdirs `` Specify a list of extra paths (separated with ':'), to search in for imported modules. @@ -292,11 +291,11 @@ Examples A couple of example programs can be found in the 'examples' directory of the source tree. Make sure you have installed the :ref:`requirements`. Then, for instance, -to compile and run the rasterbars example program, use this command:: +to compile and run the Commodore 64 rasterbars example program, use this command:: - $ java -jar prog8compiler.jar -emu examples/rasterbars.p8 + $ java -jar prog8compiler.jar -target c64 -emu examples/rasterbars.p8 or:: - $ ./p8compile.sh -emu examples/rasterbars.p8 + $ ./p8compile.sh -target c64 -emu examples/rasterbars.p8 diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst index 15bc9fef3..011a974fb 100644 --- a/docs/source/libraries.rst +++ b/docs/source/libraries.rst @@ -47,8 +47,12 @@ sys (part of syslib) system when the program is running. The following return values are currently defined: - - 16 = compiled for Commander X16 with 65C02 CPU - - 64 = compiled for Commodore 64 with 6502/6510 CPU + - 8 = Atari 8 bits + - 16 = Commander X16 + - 64 = Commodore 64 + - 128 = Commodore 128 + - 255 = Virtual machine + ``exit (returncode)`` Immediately stops the program and exits it, with the returncode in the A register. diff --git a/docs/source/upgrading8.rst b/docs/source/upgrading8.rst index bfd2deb06..d7acf5a53 100644 --- a/docs/source/upgrading8.rst +++ b/docs/source/upgrading8.rst @@ -23,6 +23,7 @@ Details of several important ones and how to convert version 8 code can be found - added gfx2.fill() flood fill routine - added @split storage class for (u)word arrays to store them as split lsb/msb arrays which is more efficient (but doesn't yet support all array operations) - added -splitarrays command line option and '%option splitarrays' to treat all word arrays as tagged with @split +- the -target option is now required, c64 is no longer a default. ``cx16diskio`` is now just ``diskio`` diff --git a/examples/animals.p8 b/examples/animals.p8 index df8c3485d..70385ae30 100644 --- a/examples/animals.p8 +++ b/examples/animals.p8 @@ -2,7 +2,7 @@ %import string ; Animal guessing game where the computer gets smarter every time. -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { const ubyte database_size = 100 diff --git a/examples/balls.p8 b/examples/balls.p8 index 883dddb7c..08f7fb9bf 100644 --- a/examples/balls.p8 +++ b/examples/balls.p8 @@ -2,7 +2,7 @@ %import math %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/bsieve.p8 b/examples/bsieve.p8 index d24f70ced..87e09d38b 100644 --- a/examples/bsieve.p8 +++ b/examples/bsieve.p8 @@ -4,7 +4,7 @@ %option no_sysinit ; The "Byte Sieve" test. https://en.wikipedia.org/wiki/Byte_Sieve -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { sub start() { diff --git a/examples/balloonflight.p8 b/examples/c64/balloonflight.p8 similarity index 100% rename from examples/balloonflight.p8 rename to examples/c64/balloonflight.p8 diff --git a/examples/bdmusic-irq.p8 b/examples/c64/bdmusic-irq.p8 similarity index 100% rename from examples/bdmusic-irq.p8 rename to examples/c64/bdmusic-irq.p8 diff --git a/examples/bdmusic.p8 b/examples/c64/bdmusic.p8 similarity index 100% rename from examples/bdmusic.p8 rename to examples/c64/bdmusic.p8 diff --git a/examples/charset.p8 b/examples/c64/charset.p8 similarity index 100% rename from examples/charset.p8 rename to examples/c64/charset.p8 diff --git a/examples/cube3d-sprites.p8 b/examples/c64/cube3d-sprites.p8 similarity index 100% rename from examples/cube3d-sprites.p8 rename to examples/c64/cube3d-sprites.p8 diff --git a/examples/cube3d.p8 b/examples/c64/cube3d.p8 similarity index 100% rename from examples/cube3d.p8 rename to examples/c64/cube3d.p8 diff --git a/examples/plasma.p8 b/examples/c64/plasma.p8 similarity index 100% rename from examples/plasma.p8 rename to examples/c64/plasma.p8 diff --git a/examples/rasterbars.p8 b/examples/c64/rasterbars.p8 similarity index 100% rename from examples/rasterbars.p8 rename to examples/c64/rasterbars.p8 diff --git a/examples/sprites.p8 b/examples/c64/sprites.p8 similarity index 100% rename from examples/sprites.p8 rename to examples/c64/sprites.p8 diff --git a/examples/starfield.p8 b/examples/c64/starfield.p8 similarity index 100% rename from examples/starfield.p8 rename to examples/c64/starfield.p8 diff --git a/examples/tehtriz.p8 b/examples/c64/tehtriz.p8 similarity index 100% rename from examples/tehtriz.p8 rename to examples/c64/tehtriz.p8 diff --git a/examples/turtle-gfx.p8 b/examples/c64/turtle-gfx.p8 similarity index 100% rename from examples/turtle-gfx.p8 rename to examples/c64/turtle-gfx.p8 diff --git a/examples/wizzine.p8 b/examples/c64/wizzine.p8 similarity index 100% rename from examples/wizzine.p8 rename to examples/c64/wizzine.p8 diff --git a/examples/cube3d-float.p8 b/examples/cube3d-float.p8 index fa5c4039e..3a7930a4c 100644 --- a/examples/cube3d-float.p8 +++ b/examples/cube3d-float.p8 @@ -3,7 +3,7 @@ %import test_stack %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/cube3d-gfx.p8 b/examples/cube3d-gfx.p8 index 197a601c7..62518e51a 100644 --- a/examples/cube3d-gfx.p8 +++ b/examples/cube3d-gfx.p8 @@ -2,7 +2,7 @@ %import graphics %import math -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/cxlogo.p8 b/examples/cx16/cxlogo.p8 similarity index 75% rename from examples/cxlogo.p8 rename to examples/cx16/cxlogo.p8 index ff2df45e0..31883d7c2 100644 --- a/examples/cxlogo.p8 +++ b/examples/cx16/cxlogo.p8 @@ -2,7 +2,7 @@ %import math %import cx16logo -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { sub start() { @@ -10,7 +10,7 @@ main { ubyte col = math.rnd() % (txt.DEFAULT_WIDTH-13) + 3 ubyte row = math.rnd() % (txt.DEFAULT_HEIGHT-7) cx16logo.logo_at(col, row) - txt.plot(col-3, row+7 ) + txt.plot(col-3, row+7) txt.print("commander x16") } } diff --git a/examples/dirlist.p8 b/examples/dirlist.p8 index bbc890e25..39d11f9f0 100644 --- a/examples/dirlist.p8 +++ b/examples/dirlist.p8 @@ -4,6 +4,8 @@ %import test_stack %option no_sysinit +; Note: this program can be compiled for multiple target systems. + main { sub start() { diskio.set_drive(8) diff --git a/examples/fibonacci.p8 b/examples/fibonacci.p8 index 7b8b602ed..966e78710 100644 --- a/examples/fibonacci.p8 +++ b/examples/fibonacci.p8 @@ -2,7 +2,7 @@ %zeropage basicsafe ; This example computes the first 20 values of the Fibonacci sequence. -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { sub start() { diff --git a/examples/line-circle-gfx.p8 b/examples/line-circle-gfx.p8 index cde6c5315..937d457f7 100644 --- a/examples/line-circle-gfx.p8 +++ b/examples/line-circle-gfx.p8 @@ -2,7 +2,7 @@ %import test_stack %import math -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/line-circle-txt.p8 b/examples/line-circle-txt.p8 index bebaec974..621f7e882 100644 --- a/examples/line-circle-txt.p8 +++ b/examples/line-circle-txt.p8 @@ -2,7 +2,7 @@ %import syslib %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/mandelbrot-gfx.p8 b/examples/mandelbrot-gfx.p8 index e346c7a1e..e21690e9c 100644 --- a/examples/mandelbrot-gfx.p8 +++ b/examples/mandelbrot-gfx.p8 @@ -7,7 +7,7 @@ ; NOTE: this will take an eternity to draw on a real c64. A CommanderX16 is a bit faster. ; even in Vice in warp mode (700% speed on my machine) it's slow, but you can see progress -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { const uword width = 320 diff --git a/examples/mandelbrot.p8 b/examples/mandelbrot.p8 index f7edc22c0..f220c26f5 100644 --- a/examples/mandelbrot.p8 +++ b/examples/mandelbrot.p8 @@ -3,7 +3,7 @@ %import test_stack %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { const uword width = 30 diff --git a/examples/maze.p8 b/examples/maze.p8 index be3820281..ee210b94b 100644 --- a/examples/maze.p8 +++ b/examples/maze.p8 @@ -6,7 +6,7 @@ ; This program shows a depth-first maze generation algorithm (1 possible path from start to finish), ; and a depth-first maze solver algorithm, both using a stack to store the path taken. -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { sub start() { diff --git a/examples/numbergame.p8 b/examples/numbergame.p8 index c579e04ee..57d643695 100644 --- a/examples/numbergame.p8 +++ b/examples/numbergame.p8 @@ -4,7 +4,7 @@ %zeropage basicsafe ; The classic number guessing game. -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/primes.p8 b/examples/primes.p8 index 4998f266c..e621cf1dc 100644 --- a/examples/primes.p8 +++ b/examples/primes.p8 @@ -1,8 +1,7 @@ %import textio -; %import test_stack %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/screencodes.p8 b/examples/screencodes.p8 index 1b2bfb36d..0ce78e088 100644 --- a/examples/screencodes.p8 +++ b/examples/screencodes.p8 @@ -1,7 +1,7 @@ %import textio %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/sorting.p8 b/examples/sorting.p8 index f584dec42..bc562a403 100644 --- a/examples/sorting.p8 +++ b/examples/sorting.p8 @@ -1,7 +1,7 @@ %import textio %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/swirl-float.p8 b/examples/swirl-float.p8 index cb79d34db..c49820c4a 100644 --- a/examples/swirl-float.p8 +++ b/examples/swirl-float.p8 @@ -2,7 +2,7 @@ %import floats %zeropage floatsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { diff --git a/examples/swirl.p8 b/examples/swirl.p8 index af0a211e3..6fcacbf14 100644 --- a/examples/swirl.p8 +++ b/examples/swirl.p8 @@ -2,7 +2,7 @@ %import textio %zeropage basicsafe -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main { const uword screenwidth = txt.DEFAULT_WIDTH diff --git a/examples/test.p8 b/examples/test.p8 index 6d97c1eca..857ce20ec 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -6,7 +6,7 @@ main { str name1 = "name1" str name2 = "name2" - uword[] names = [name1, name2, "name3"] + uword[] @split names = [name1, name2, "name3"] uword ww ; for ww in names { @@ -22,12 +22,12 @@ main { names[idx]-- txt.print_uw(names[1]) -; names = [1111,2222,3333] -; for ww in names { -; txt.print_uw(ww) -; txt.spc() -; } -; txt.nl() + names = [1111,2222,3333] + for ww in names { + txt.print_uw(ww) + txt.spc() + } + txt.nl() txt.print("end.") } } diff --git a/examples/textelite.p8 b/examples/textelite.p8 index 26b15a27a..7240f09a1 100644 --- a/examples/textelite.p8 +++ b/examples/textelite.p8 @@ -9,7 +9,7 @@ ; Prog8 adaptation of the Text-Elite galaxy system trading simulation engine. ; Original C-version obtained from: http://www.elitehomepage.org/text/index.htm -; Note: this program is compatible with C64 and CX16. +; Note: this program can be compiled for multiple target systems. main {