C128: adjust MEMTOP value to $C000 during runtime (41 Kb of available space because Basic ROM is banked out)

This commit is contained in:
Irmen de Jong
2025-10-12 15:02:36 +02:00
parent d69eead6d8
commit d2719d23f5
3 changed files with 50 additions and 12 deletions
+9
View File
@@ -1302,6 +1302,11 @@ asmsub init_system() {
lda #0
sta c64.BGCOL0
jsr disable_runstop_and_charsetswitch
; basic is not banked in, adjust MEMTOP
ldx #<$c000
ldy #>$c000
clc
jsr cbm.MEMTOP
cli
rts
}}
@@ -1323,6 +1328,10 @@ asmsub cleanup_at_exit() {
sta $ff00 ; default bank 15
jsr cbm.CLRCHN ; reset i/o channels
jsr enable_runstop_and_charsetswitch
ldx #<$ff00
ldy #>$ff00
clc
jsr cbm.MEMTOP ; adjust MEMTOP to original value again
lda _exitcarry
lsr a
lda _exitcode
+1
View File
@@ -101,6 +101,7 @@ Language Features
- Supports the sixteen 'virtual' 16-bit registers R0 to R15 as defined on the Commander X16. You can look at them as general purpose global variables. These are also available on the other compilation targets!
- On the Commander X16: Support for low level system features such as Vera Fx, which includes 16x16 bits multiplication in hardware and fast memory copy and fill.
- 50 Kb of available program RAM size on the C64 by default; because Basic ROM is banked out altogether
- 41 Kb of available program RAM size on the C128 by default; because Basic ROM is banked out altogether
- Many library routines are available across compiler targets. This means that as long as you only use standard Kernal
and core prog8 library routines, it is sometimes possible to compile the *exact same program* for different machines by just changing the compilation target flag.
+40 -12
View File
@@ -1,24 +1,52 @@
%import textio
%zeropage basicsafe
;;%option no_sysinit
main {
sub start() {
long @shared lv1 = -123456
txt.print_l(abs(lv1))
txt.spc()
lv1 = -99999
lv1 = abs(lv1)
txt.print_l(abs(lv1))
txt.print("memtop=")
cx16.r0 = cbm.MEMTOP(0, true)
txt.print_uwhex(cx16.r0, true)
txt.nl()
cx16.r4 = $1122
cx16.r5 = $abcd
txt.print_ulhex(mklong(cx16.r5H,cx16.r5L,cx16.r4H,cx16.r4L), true)
txt.print("bfff: ")
@($bfff) = 123
cx16.r9++
txt.print_ub(@($bfff))
txt.spc()
txt.print_ulhex(mklong2(cx16.r5,cx16.r4), true)
@($bfff) = 0
cx16.r9++
txt.print_ub(@($bfff))
txt.nl()
txt.print("c000: ")
@($c000) = 123
cx16.r9++
txt.print_ub(@($c000))
txt.spc()
@($c000) = 0
cx16.r9++
txt.print_ub(@($c000))
txt.nl()
txt.print("d000: ")
@($d000) = 123
cx16.r9++
txt.print_ub(@($d000))
txt.spc()
@($d000) = 0
cx16.r9++
txt.print_ub(@($d000))
txt.nl()
txt.print("e000: ")
@($e000) = 123
cx16.r9++
txt.print_ub(@($e000))
txt.spc()
@($e000) = 0
cx16.r9++
txt.print_ub(@($e000))
txt.nl()
}
}