changed MEMTOP2 into cx16.numbanks() to query the number of RAM banks installed

This commit is contained in:
Irmen de Jong 2021-04-08 01:03:31 +02:00
parent a9d297ee31
commit 3dda29781e
3 changed files with 16 additions and 27 deletions

View File

@ -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!

View File

@ -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)
}
}

View File

@ -518,7 +518,6 @@ syn match prog8BuiltInFunc "\<c64\.PLOT\>"
syn match prog8BuiltInFunc "\<c64\.IOBASE\>"
syn match prog8BuiltInFunc "\<c64\.STOP2\>"
syn match prog8BuiltInFunc "\<c64\.RDTIM16\>"
syn match prog8BuiltInFunc "\<c64\.MEMTOP2\>"
syn match prog8BuiltInVar "\<cx16\.CINV\>"
syn match prog8BuiltInVar "\<cx16\.NMI_VEC\>"
syn match prog8BuiltInVar "\<cx16\.RESET_VEC\>"
@ -674,6 +673,7 @@ syn match prog8BuiltInFunc "\<cx16\.entropy_get\>"
syn match prog8BuiltInFunc "\<cx16\.monitor\>"
syn match prog8BuiltInFunc "\<cx16\.rombank\>"
syn match prog8BuiltInFunc "\<cx16\.rambank\>"
syn match prog8BuiltInFunc "\<cx16\.numbanks\>"
syn match prog8BuiltInFunc "\<cx16\.vpeek\>"
syn match prog8BuiltInFunc "\<cx16\.vaddr\>"
syn match prog8BuiltInFunc "\<cx16\.vpoke\>"