diff --git a/compiler/res/prog8lib/cx16/graphics.p8 b/compiler/res/prog8lib/cx16/graphics.p8 index b9269b468..e3d303ad2 100644 --- a/compiler/res/prog8lib/cx16/graphics.p8 +++ b/compiler/res/prog8lib/cx16/graphics.p8 @@ -2,9 +2,10 @@ %import syslib %import textio -; bitmap pixel graphics module for the CommanderX16 +; Bitmap pixel graphics module for the CommanderX16 ; wraps the graphics functions that are in ROM. -; only black/white monchrome 320x200 for now. +; only black/white monchrome 320x200 for now. (i.e. truncated at the bottom) +; For full-screen 640x480 or 320x240 graphics, use the "gfx2" module instead. (but that is Cx16-specific) graphics { const uword WIDTH = 320 @@ -133,5 +134,3 @@ graphics { cx16.FB_set_pixel(1) } } - - diff --git a/compiler/src/prog8/ast/processing/AstChecker.kt b/compiler/src/prog8/ast/processing/AstChecker.kt index e83d81820..9b3bd4424 100644 --- a/compiler/src/prog8/ast/processing/AstChecker.kt +++ b/compiler/src/prog8/ast/processing/AstChecker.kt @@ -202,6 +202,9 @@ internal class AstChecker(private val program: Program, if(subroutine.name in BuiltinFunctions) err("cannot redefine a built-in function") + if(subroutine.parameters.size>16) + err("subroutines are limited to 16 parameters") + val uniqueNames = subroutine.parameters.asSequence().map { it.name }.toSet() if(uniqueNames.size!=subroutine.parameters.size) err("parameter names must be unique") diff --git a/compiler/src/prog8/compiler/target/c64/codegen/FunctionCallAsmGen.kt b/compiler/src/prog8/compiler/target/c64/codegen/FunctionCallAsmGen.kt index 6ab14877f..8212ff867 100644 --- a/compiler/src/prog8/compiler/target/c64/codegen/FunctionCallAsmGen.kt +++ b/compiler/src/prog8/compiler/target/c64/codegen/FunctionCallAsmGen.kt @@ -47,21 +47,19 @@ internal class FunctionCallAsmGen(private val program: Program, private val asmg // just a single parameter, no risk of clobbering registers argumentViaRegister(sub, IndexedValue(0, sub.parameters.single()), stmt.args[0]) } else { - // multiple register arguments, risk of register clobbering. - // evaluate arguments onto the stack, and load the registers from the evaluated values on the stack. when { stmt.args.all {it is AddressOf || it is NumericLiteralValue || it is StringLiteralValue || it is ArrayLiteralValue || it is IdentifierReference} -> { - // no risk of clobbering for these simple argument types. Optimize the register loading. + // There's no risk of clobbering for these simple argument types. Optimize the register loading directly from these values. for(arg in sub.parameters.withIndex().zip(stmt.args)) { argumentViaRegister(sub, arg.first, arg.second) } } else -> { - // Risk of clobbering due to complex expression args. Work via the stack. + // Risk of clobbering due to complex expression args. Work via the evaluation stack. registerArgsViaStackEvaluation(stmt, sub) } } diff --git a/examples/cx16/gfx2.p8 b/examples/cx16/gfx2.p8 index 952ed68d7..00e81d185 100644 --- a/examples/cx16/gfx2.p8 +++ b/examples/cx16/gfx2.p8 @@ -1,10 +1,17 @@ +%target cx16 %import textio %import graphics %import test_stack %zeropage basicsafe %option no_sysinit -; TODO full-screen graphics mode library, in development. (as replacement for the graphics routines in ROM that are constrained to 200 vertical pixels and lores mode only) +; Bitmap pixel graphics module for the CommanderX16 +; Custom routines to use the full-screen 640x480 and 320x240 screen modes. +; This is only compatible with the Cx16. +; For compatible graphics code that words on C64 too, use the "graphics" module instead. + + +; TODO this is in development. main { diff --git a/examples/test.p8 b/examples/test.p8 index 8aa7d92e7..7d042e0ab 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -23,12 +23,16 @@ main { sub start () { txt.chrout('!') - ubyte bank = 1 + uword bank = 1 uword address = 1000 ubyte value = 123 bank++ - vpoke(bank, address, value) - vpokeasm(address, bank, value) ; TODO generates params on stack if expression is used such as lsb(bank). CHECK STACK UNWINDING!!! + + test_stack.test() + vpoke(lsb(bank), address, value) + test_stack.test() + vpokeasm(address, lsb(bank), value) ; TODO generates params on stack if expression is used such as lsb(bank). CHECK STACK UNWINDING!!! + test_stack.test() ; TODO also see if we can do this via R0-R15 temp registers rather than using the estack??? } }