extracting neo and atari compiler targets into configuration files instead

This commit is contained in:
Irmen de Jong
2025-02-12 00:05:47 +01:00
parent fd39c22616
commit 49982b49b6
18 changed files with 119 additions and 22 deletions
+3 -6
View File
@@ -421,12 +421,9 @@ internal fun determineCompilationOptions(program: Program, compTarget: ICompilat
OutputType.PRG
}
}
var launcherType = if (launcherTypeStr == null) {
when(compTarget) {
is AtariTarget -> CbmPrgLauncherType.NONE
else -> CbmPrgLauncherType.BASIC
}
} else {
var launcherType = if (launcherTypeStr == null)
CbmPrgLauncherType.BASIC
else {
try {
CbmPrgLauncherType.valueOf(launcherTypeStr)
} catch (_: IllegalArgumentException) {
@@ -7,12 +7,7 @@ import io.kotest.matchers.shouldNotBe
import io.kotest.matchers.string.shouldContain
import io.kotest.matchers.string.shouldStartWith
import io.kotest.matchers.types.instanceOf
import prog8.code.ast.PtAssignment
import prog8.code.ast.PtBinaryExpression
import prog8.code.ast.PtFunctionCall
import prog8.code.ast.PtIfElse
import prog8.code.ast.PtPrefix
import prog8.code.ast.PtVariable
import prog8.code.ast.*
import prog8.code.core.BaseDataType
import prog8.code.core.DataType
import prog8.code.target.*
@@ -386,7 +381,6 @@ main {
compileText(C64Target(), false, text, writeAssembly = true) shouldNotBe null
compileText(C128Target(), false, text, writeAssembly = true) shouldNotBe null
compileText(PETTarget(), false, text, writeAssembly = true) shouldNotBe null
compileText(AtariTarget(), false, text, writeAssembly = true) shouldNotBe null
compileText(VMTarget(), false, text, writeAssembly = true) shouldNotBe null
}
+1
View File
@@ -14,6 +14,7 @@ TODO
Future Things and Ideas
^^^^^^^^^^^^^^^^^^^^^^^
- Improve compilation target configurability: the program type (CBMPRG, ATARIXEX etc) is still hardcoded into the compiler (AssemblyProgram.kt)
- Look at github PR for improved romability
- Kotlin: can we use inline value classes in certain spots?
- add float support to the configurable compiler targets
+27 -8
View File
@@ -1,18 +1,37 @@
.PHONY: all clean
all: main-c64.prg main-cx16.prg main-pet.prg
all: main-c64.prg main-cx16.prg main-pet.prg atari-hello.xex atari-fibonacci.xex neo-hello.bin
clean:
rm -f *.prg *.PRG *.asm *.vice-*
rm -f *.prg *.PRG *.xex *.bin *.asm *.vice-*
main-c64.prg: main.p8 tinyc64.properties
prog8c -target ./tinyc64.properties main.p8 -sourcelines
main-c64.prg: src/main.p8 targetconfigs/tinyc64.properties
prog8c -target targetconfigs/tinyc64.properties src/main.p8 -sourcelines
mv main.prg $@
main-cx16.prg: main.p8 tinycx16.properties
prog8c -target ./tinycx16.properties main.p8 -sourcelines
main-cx16.prg: src/main.p8 targetconfigs/tinycx16.properties
prog8c -target targetconfigs/tinycx16.properties src/main.p8 -sourcelines
mv main.prg $@
main-pet.prg: main.p8 tinypet.properties
prog8c -target ./tinypet.properties main.p8 -sourcelines
main-pet.prg: src/main.p8 targetconfigs/tinypet.properties
prog8c -target targetconfigs/tinypet.properties src/main.p8 -sourcelines
mv main.prg $@
atari-hello.xex: src/atari-hello.p8
prog8c -target targetconfigs/atari.properties src/atari-hello.p8
atari-fibonacci.xex: src/atari-fibonacci.p8
prog8c -target targetconfigs/atari.properties src/atari-fibonacci.p8
neo-hello.bin: src/neo-hello.p8
prog8c -target targetconfigs/neo6502.properties src/neo-hello.p8
run-atari-hello:
prog8c -target targetconfigs/atari.properties src/atari-hello.p8 -emu
run-atari-fibonacci:
prog8c -target targetconfigs/atari.properties src/atari-fibonacci.p8 -emu
run-neo-hello:
prog8c -target targetconfigs/neo6502.properties src/neo-hello.p8 -emu
@@ -7,7 +7,7 @@ neo {
&uword RESET_VEC = $FFFC ; 6502 reset vector, determined by the kernal if banked in
&uword IRQ_VEC = $FFFE ; 6502 interrupt vector, determined by the kernal if banked in
%asminclude "library:neo/neo6502.asm"
%asminclude "neo6502.asm"
}
sys {
+4
View File
@@ -0,0 +1,4 @@
Various examples for configurable target machines, such as the NEO6502, Atari 800,
and "tiny" example configurations for the X16 or C64 that provide more example materials.
Look in the Makefile to see how to build or run the various programs.
@@ -1,5 +1,6 @@
%import textio
%zeropage basicsafe
%launcher none
; This example computes the first 20 values of the Fibonacci sequence.
; Note: this program is compatible with atari.
@@ -1,5 +1,6 @@
%import textio
%zeropage basicsafe
%launcher none
; hello world test for Atari 8-bit
@@ -0,0 +1,40 @@
# configuration file for a C64 like Prog8 compilation target
cpu = 6502
program = ATARIXEX
encoding = atascii
load_address = $2000
memtop = $ffff
bss_highram_start = 0
bss_highram_end = 0
bss_goldenram_start = 0
bss_goldenram_end = 0
# io_regions specifies memory-mapped I/O registers that should be treated differentely.
# it can be zero or more memory address ranges (inclusive) separated by comma
io_regions = $d000-$dfff
# zeropage scratch variables. zp_scratch_reg must always be zp_scratch_b1+1 !
zp_scratch_b1 = $cb
zp_scratch_reg = $cc
zp_scratch_w1 = $cd
zp_scratch_w2 = $cf
# free zeropage locations for the various zp usage methods
# zero or more zeropage address ranges (inclusive).
zp_fullsafe = $00-$ff
zp_kernalsafe = $00-$ff
zp_basicsafe = $00-$ff
# the start of the 32 bytes used by the R0-R15 virtual registers. Can be in Zeropage or elsewhere.
virtual_registers = $1b00
# Where can we find the standard library (syslib.p8). You can still add more paths manually using -srcdirs
library = ./libraries/atari
# if a non-empty custom launcher string is supplied, the compiler won't output ANY launcher / init code by itself,
# and instead outputs whatever is specified here. (You can use \n here for newline and \ for line continuantions)
custom_launcher =
# additional options passed to the assembler program
assembler_options =
@@ -0,0 +1,40 @@
# configuration file for a C64 like Prog8 compilation target
cpu = 65C02
program = NEORAW
encoding = iso
load_address = $0800
memtop = $fc00
bss_highram_start = 0
bss_highram_end = 0
bss_goldenram_start = 0
bss_goldenram_end = 0
# io_regions specifies memory-mapped I/O registers that should be treated differentely.
# it can be zero or more memory address ranges (inclusive) separated by comma
io_regions = $ff00-$ff0f
# zeropage scratch variables. zp_scratch_reg must always be zp_scratch_b1+1 !
zp_scratch_b1 = $fa
zp_scratch_reg = $fb
zp_scratch_w1 = $fc
zp_scratch_w2 = $fe
# free zeropage locations for the various zp usage methods
# zero or more zeropage address ranges (inclusive).
zp_fullsafe = $22-$ff
zp_kernalsafe = $22-$ff
zp_basicsafe = $22-$ff
# the start of the 32 bytes used by the R0-R15 virtual registers. Can be in Zeropage or elsewhere.
virtual_registers = $02
# Where can we find the standard library (syslib.p8). You can still add more paths manually using -srcdirs
library = ./libraries/neo6502
# if a non-empty custom launcher string is supplied, the compiler won't output ANY launcher / init code by itself,
# and instead outputs whatever is specified here. (You can use \n here for newline and \ for line continuantions)
custom_launcher =
# additional options passed to the assembler program
assembler_options =