diff --git a/compiler/res/prog8lib/c128/syslib.p8 b/compiler/res/prog8lib/c128/syslib.p8 index aebe365d9..6a22bebbc 100644 --- a/compiler/res/prog8lib/c128/syslib.p8 +++ b/compiler/res/prog8lib/c128/syslib.p8 @@ -324,6 +324,20 @@ extsub $FF6E = JSRFAR() ; ---- C128 specific system utility routines: ---- +inline asmsub banks(ubyte banks @A) { + ; -- set the memory bank configuration MMU register + %asm {{ + sta $FF00 + }} +} + +inline asmsub getbanks() -> ubyte @A { + ; -- get the current memory bank configuration from the MMU register + %asm {{ + lda $FF00 + }} +} + asmsub disable_basic() clobbers(A) { %asm {{ lda $0a04 ; disable BASIC shadow registers @@ -1061,6 +1075,8 @@ asmsub init_system() { jsr cbm.IOINIT jsr cbm.RESTOR jsr cbm.CINT + lda #%00001110 + sta $ff00 ; bank out basic rom so we have ram from $1c00-$bfff lda #6 sta c64.EXTCOL lda #7 diff --git a/docs/source/_static/symboldumps/skeletons-c128.txt b/docs/source/_static/symboldumps/skeletons-c128.txt index a592d363e..2be36acc1 100644 --- a/docs/source/_static/symboldumps/skeletons-c128.txt +++ b/docs/source/_static/symboldumps/skeletons-c128.txt @@ -445,7 +445,9 @@ c128 { &ubyte VM3 &ubyte VM4 JSRFAR () = $ff6e + banks (ubyte banks @A) disable_basic () -> clobbers (A) + getbanks () -> ubyte @A x16jsrfar () } diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 451b08911..bf7dc9215 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -449,6 +449,8 @@ Arrays can be initialized with a range expression or an array literal value. You can write out such an initializer value over several lines if you want to improve readability. When an initialization value is given, you are allowed to omit the array size in the declaration, because it can be inferred from the initialization value. +You can use '*' to repeat array fragments to build up a larger array. + **numbers:** unless prefixed for hex or binary as described below, all numbers are decimal numbers. There is no octal notation. diff --git a/docs/source/technical.rst b/docs/source/technical.rst index 32913e7df..a016fc452 100644 --- a/docs/source/technical.rst +++ b/docs/source/technical.rst @@ -36,7 +36,7 @@ On certain systems prog8 provides support for managing the ROM or RAM banks that system get banks (returns byte) set banks ======= ============================================= =========== c64 ``c64.getbanks()`` ``c64.banks(x)`` -c128 *TODO* *TODO* +c128 ``c128.getbanks()`` ``c128.banks(x)`` cx16 ``cx16.getrombank()`` , ``cx16.getrambank()`` ``cx16.rombank(x)`` , ``cx16.rambank(x)`` other N/A N/A ======= ============================================= =========== @@ -80,13 +80,15 @@ The bank number is not translated into assembly (only as a comment):: Instead change banks in a controlled manual way (or not at all). .. note:: - On the C64, the Basic ROM is *banked out* by default when running a Prog8 program, because - it is not needed. This means we get access to another 8Kb of RAM at that + On the C64 and C128, the Basic ROM is *banked out* by default when running a Prog8 program, because + it is not needed. This means on the C64 we get access to another 8Kb of RAM at that memory area, which actually gives us a 50 Kb contiguous RAM block from $0801 to $d000 (exclusive). This means you can create programs of up to **50 Kb** size with prog8 on the C64. + On the C128, it means programs can use ~41 Kb of contiguous RAM at $1c00 to $c000 (exclusive). However, if your program uses floats, Prog8 *does* need the Basic ROM for the floating point routines, - and it won't be banked out. Such programs are limited to the regular size of about 38 Kb. - Be aware that the bank setting is only done if you are not using ``%option no_sysinit``! + and it won't be banked out. Such programs are limited to the regular size of about 38 Kb on the C64, and less on the C128. + Be aware that the bank setting is only done if you are *not* using ``%option no_sysinit`` because the + program's bootstrap code is what initializes the memory bank configuration. .. _symbol-prefixing: diff --git a/examples/test.p8 b/examples/test.p8 index ae8fb2c5e..c9c330962 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,71 +1,31 @@ -%import floats %import textio -%option no_sysinit %zeropage basicsafe -; DIRTY tests main { - uword @shared @dirty globw - uword @shared globwi = 4444 - float @shared @dirty globf - float @shared globfi = 4 - ubyte[5] @shared @dirty globarr1 - ubyte[] @shared globarr2 = [11,22,33,44,55] - sub start() { - testdirty() - txt.nl() - testdirty() - txt.nl() - } - - sub testdirty() { - uword @shared @dirty locw - uword @shared locwi = 4444 - float @shared @dirty locf - float @shared locfi = 4.0 - ubyte[5] @shared @dirty locarr1 - ubyte[] @shared locarr2 = [11,22,33,44,55] - - txt.print("globals: ") - txt.print_uw(globw) + txt.print_ubbin(c128.getbanks(), true) txt.spc() - floats.print(globf) - txt.print(" with init: ") - txt.print_uw(globwi) + txt.print_ub(@($4000)) txt.spc() - floats.print(globfi) - txt.print(" arrays: ") - txt.print_ub(globarr1[2]) - txt.spc() - txt.print_ub(globarr2[2]) - txt.print("\nlocals: ") - txt.print_uw(locw) - txt.spc() - floats.print(locf) - txt.print(" with init: ") - txt.print_uw(locwi) - txt.spc() - floats.print(locfi) - txt.print(" arrays: ") - txt.print_ub(locarr1[2]) - txt.spc() - txt.print_ub(locarr2[2]) + txt.print_ub(@($8000)) txt.nl() + @($4000)++ + @($8000)++ + txt.print_ub(@($4000)) + txt.spc() + txt.print_ub(@($8000)) + txt.nl() - globw++ - globwi++ - globf++ - globfi++ - globarr1[2]++ - globarr2[2]++ - locw++ - locwi++ - locf++ - locfi++ - locarr1[2]++ - locarr2[2]++ + c128.banks(0) + txt.print_ubbin(c128.getbanks(), true) + txt.spc() + @($4000)++ + @($8000)++ + txt.print_ub(@($4000)) + txt.spc() + txt.print_ub(@($8000)) + txt.nl() } }