From 2d3c20d3474ccb18615e611f4dcd3546a7290586 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Fri, 24 Apr 2026 05:25:50 +0200 Subject: [PATCH] c128: define golden ram area at $1300-$1BDF --- codeCore/src/prog8/code/target/C128Target.kt | 8 ++++---- compiler/res/prog8lib/cx16/monogfx.p8 | 4 ++-- compiler/src/prog8/compiler/BuiltinFunctions.kt | 2 +- docs/source/compiling.rst | 4 ++-- docs/source/targetsystem.rst | 14 ++++++++++++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/codeCore/src/prog8/code/target/C128Target.kt b/codeCore/src/prog8/code/target/C128Target.kt index bca11ddc4..6c15035bf 100644 --- a/codeCore/src/prog8/code/target/C128Target.kt +++ b/codeCore/src/prog8/code/target/C128Target.kt @@ -31,10 +31,10 @@ class C128Target: ICompilationTarget, override val PROGRAM_LOAD_ADDRESS = 0x1c01u override val PROGRAM_MEMTOP_ADDRESS = 0xc000u - override val BSSHIGHRAM_START = 0u // TODO address? - override val BSSHIGHRAM_END = 0u // TODO address? - override val BSSGOLDENRAM_START = 0u // TODO address? - override val BSSGOLDENRAM_END = 0u // TODO address? + override val BSSHIGHRAM_START = 0u // no high ram + override val BSSHIGHRAM_END = 0u // no high ram + override val BSSGOLDENRAM_START = 0x1300u + override val BSSGOLDENRAM_END = 0x1bdfu // note: $1be0 - $1bff contains the 16 virtual registers override lateinit var zeropage: Zeropage diff --git a/compiler/res/prog8lib/cx16/monogfx.p8 b/compiler/res/prog8lib/cx16/monogfx.p8 index 0d0341d1a..e8c8cfbeb 100644 --- a/compiler/res/prog8lib/cx16/monogfx.p8 +++ b/compiler/res/prog8lib/cx16/monogfx.p8 @@ -868,7 +868,7 @@ skip: } sub fill_scanline_left() -> bool { - ; TODO maybe this could use vera auto decrement, but that requires some clever masking calculations + ; TODO maybe this could use vera auto decrement, but that requires some clever masking calculations on the edges of the span to set only the correct bits in those vram bytes cx16.r9s = xx while xx >= 0 { if pgetset() @@ -879,7 +879,7 @@ skip: } sub fill_scanline_right() { - ; TODO maybe this could use vera auto increment, but that requires some clever masking calculations + ; TODO maybe this could use vera auto decrement, but that requires some clever masking calculations on the edges of the span to set only the correct bits in those vram bytes cx16.r9s = xx while xx <= width-1 { if pgetset() diff --git a/compiler/src/prog8/compiler/BuiltinFunctions.kt b/compiler/src/prog8/compiler/BuiltinFunctions.kt index ca3466cb3..26a967fa7 100644 --- a/compiler/src/prog8/compiler/BuiltinFunctions.kt +++ b/compiler/src/prog8/compiler/BuiltinFunctions.kt @@ -17,7 +17,7 @@ import kotlin.math.* private typealias ConstExpressionCaller = (args: List, position: Position, program: Program) -> NumericLiteral // Maps builtin functions to constant evaluators for compile-time execution -// TODO: add support for builtin functions that return multiple return values (such as divmod) +// TODO: add support for builtin functions that return multiple return values (such as divmod and lmh) internal val constEvaluatorsForBuiltinFuncs: Map = mapOf( "abs__byte" to { a, p, prg -> oneIntArgOutputInt(a, p, prg, true) { abs(it).toDouble() } }, "abs__word" to { a, p, prg -> oneIntArgOutputInt(a, p, prg, true) { abs(it).toDouble() } }, diff --git a/docs/source/compiling.rst b/docs/source/compiling.rst index 511030149..0617722a7 100644 --- a/docs/source/compiling.rst +++ b/docs/source/compiling.rst @@ -278,9 +278,9 @@ One or more .p8 module files Show a more detailed breakdown of the time taken in various compiler phases, for performance analysis of the compiler itself. ``-varsgolden`` - Like ``-varshigh``, but places the variables in the $0400-$07FF "golden ram" area instead. + Like ``-varshigh``, but places the variables in the "golden ram" area instead (e.g. $0400-$07FF on CX16, $1300-$1BDF on C128). Because this is in normal system memory, there are no bank switching issues. - This mode is only available on the Commander X16, and possibly on custom configured targets. + This mode is only available on the Commander X16 and the Commodore 128, and possibly on custom configured targets. ``-varshigh `` Places uninitialized non-zeropage variables in a separate memory area, instead of inside the program itself. diff --git a/docs/source/targetsystem.rst b/docs/source/targetsystem.rst index 5b3416dae..9bbfc853a 100644 --- a/docs/source/targetsystem.rst +++ b/docs/source/targetsystem.rst @@ -138,6 +138,20 @@ Footnotes for the Commodore 64 may free up more locations for use by Prog8 or to reserve them for other things. +Footnotes for the Commodore 128 +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. index:: single: Targets; Commodore 128 notes + +*Golden Ram $1300 - $1BDF* + Application RAM area, free to use if you don't use BASIC variables or strings. + Note: $1BE0 - $1BFF are used for the 16 virtual registers cx16.r0 .. cx16.r15. + There is no "high ram" defined on the C128. + +*Program RAM $1C00 - $BFFF* + On the C128 the Basic ROM is banked out by default, reclaiming the RAM area from $1C00 to $BFFF. + This gives about 41 Kb of contiguous RAM for Prog8 programs. + + Zero page usage by the Prog8 compiler ------------------------------------- .. index:: single: Targets; Zero page usage