From 3dda29781eb6a898bc24c6abc4bead299995fe93 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Thu, 8 Apr 2021 01:03:31 +0200 Subject: [PATCH] changed MEMTOP2 into cx16.numbanks() to query the number of RAM banks installed --- compiler/res/prog8lib/cx16/syslib.p8 | 24 ++++++++++++------------ examples/test.p8 | 17 +++-------------- syntax-files/Vim/prog8_builtins.vim | 2 +- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 1728e98c2..6b02de019 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -24,7 +24,7 @@ romsub $FF8D = VECTOR(uword userptr @ XY, ubyte dir @ Pc) clobbers(A,Y) ; re romsub $FF90 = SETMSG(ubyte value @ A) ; set Kernal message control flag romsub $FF93 = SECOND(ubyte address @ A) clobbers(A) ; (alias: LSTNSA) send secondary address after LISTEN romsub $FF96 = TKSA(ubyte address @ A) clobbers(A) ; (alias: TALKSA) send secondary address after TALK -romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer. NOTE: as a Cx16 extension, also returns the number of RAM memory banks in register A ! See MEMTOP2 +romsub $FF99 = MEMTOP(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set top of memory pointer. NOTE: as a Cx16 extension, also returns the number of RAM memory banks in register A ! See cx16.numbanks() romsub $FF9C = MEMBOT(uword address @ XY, ubyte dir @ Pc) -> uword @ XY ; read/set bottom of memory pointer romsub $FF9F = SCNKEY() clobbers(A,X,Y) ; scan the keyboard romsub $FFA2 = SETTMO(ubyte timeout @ A) ; set time-out flag for IEEE bus @@ -87,17 +87,6 @@ asmsub RDTIM16() -> uword @AY { }} } -asmsub MEMTOP2() -> ubyte @A { - ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. - %asm {{ - phx - sec - jsr c64.MEMTOP - plx - rts - }} -} - } cx16 { @@ -310,6 +299,17 @@ inline asmsub rambank(ubyte rambank @A) { }} } +asmsub numbanks() -> ubyte @A { + ; -- uses MEMTOP's cx16 extension to query the number of available RAM banks. (each is 8 Kb) + %asm {{ + phx + sec + jsr c64.MEMTOP + plx + rts + }} +} + asmsub vpeek(ubyte bank @A, uword address @XY) -> ubyte @A { ; -- get a byte from VERA's video memory ; note: inefficient when reading multiple sequential bytes! diff --git a/examples/test.p8 b/examples/test.p8 index 5fa49f37a..288c4ba96 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,20 +4,9 @@ main { sub start() { -; cx16.rambank(4) -; cx16.rambank(4) -; cx16.rambank(4) -; cx16.rambank(4) -; cx16.rambank(4) - ubyte xx - xx = calc2(41, 12345) - txt.print_ub(xx) ; must be 99 + ubyte num = cx16.numbanks() + + txt.print_ub(num) txt.nl() } - - inline sub calc2(ubyte a1, uword a2) -> ubyte { - uword thesum - thesum = a2 + a1 - return lsb(thesum) - } } diff --git a/syntax-files/Vim/prog8_builtins.vim b/syntax-files/Vim/prog8_builtins.vim index d737d5a75..155414d8d 100644 --- a/syntax-files/Vim/prog8_builtins.vim +++ b/syntax-files/Vim/prog8_builtins.vim @@ -518,7 +518,6 @@ syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" -syn match prog8BuiltInFunc "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" syn match prog8BuiltInVar "\" @@ -674,6 +673,7 @@ syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" +syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\" syn match prog8BuiltInFunc "\"