added cx16.getrambank() / getrombank() to retrieve the current ram and rom bank numbers.

This commit is contained in:
Irmen de Jong
2021-12-04 15:27:54 +01:00
parent 397f98513b
commit 20401b99d8
2 changed files with 36 additions and 34 deletions

View File

@@ -381,6 +381,20 @@ inline asmsub rambank(ubyte bank @A) {
}} }}
} }
inline asmsub getrombank() -> ubyte @A {
; -- get the current rom bank
%asm {{
lda $01 ; rom bank register (v39+, used to be cx16.d1prb $9f60 in v38)
}}
}
inline asmsub getrambank() -> ubyte @A {
; -- get the current ram bank
%asm {{
lda $00 ; ram bank register (v39+, used to be cx16.d1pra $9f61 in v38)
}}
}
asmsub numbanks() -> ubyte @A { asmsub numbanks() -> ubyte @A {
; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb)
%asm {{ %asm {{

View File

@@ -1,43 +1,31 @@
%import textio %import textio
%zeropage basicsafe %zeropage basicsafe
%option no_sysinit
main { main {
ubyte[64*3] palette
sub start() { sub start() {
ubyte i ubyte num_banks = cx16.numbanks()
for i in 0 to len(palette)-1 { txt.print("number of ram banks ")
palette[i] = 15 txt.print_ub(num_banks)
} txt.print(" = ")
txt.print_uw($0008*num_banks)
for i in 0 to len(palette)-1 { txt.print("kb\n")
txt.print_ubhex(palette[i], false) print_banks()
} cx16.rambank(55)
txt.nl() cx16.rombank(3)
make_ehb_palette() print_banks()
for i in 0 to len(palette)-1 {
txt.print_ubhex(palette[i], false)
}
txt.nl()
} }
sub make_ehb_palette() { sub print_banks() {
; generate 32 additional Extra-Halfbrite colors in the cmap ubyte rambank = cx16.getrambank()
uword palletteptr = &palette ubyte rombank = cx16.getrombank()
uword ehbptr = palletteptr + 32*3 cx16.rombank(0) ; enable kernal
repeat 32 { txt.print("ram bank ")
@(ehbptr) = @(palletteptr)>>1 txt.print_ub(rambank)
ehbptr++ txt.nl()
palletteptr++ txt.print("rom bank ")
@(ehbptr) = @(palletteptr)>>1 txt.print_ub(rombank)
ehbptr++ txt.nl()
palletteptr++ cx16.rombank(rombank)
@(ehbptr) = @(palletteptr)>>1
ehbptr++
palletteptr++
}
} }
} }