Code Snippets: Difference between revisions
Eacontrerasd (talk | contribs) mNo edit summary |
Eacontrerasd (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
SUPERBASIC uses a lot of the memory available, so when you want to store data on a different Bank you want to POKE or PEEK outside the normal memory range, to do so you can use the following PROCEDURES. PLease note that these are not by any means a fast way to do it since we reconfigure the memory LUT so that the memory under the registers location ($C000-$DF00) points to the address that we want to poke or peek on the fly, after that we get or set the content of the memory address and restore the segments so that the Kernel does not blow up after returning. Contrary to what I initially believed it works!.<blockquote> | SUPERBASIC uses a lot of the memory available, so when you want to store data on a different Bank you want to POKE or PEEK outside the normal memory range, to do so you can use the following PROCEDURES. PLease note that these are not by any means a fast way to do it since we reconfigure the memory LUT so that the memory under the registers location ($C000-$DF00) points to the address that we want to poke or peek on the fly, after that we get or set the content of the memory address and restore the segments so that the Kernel does not blow up after returning. Contrary to what I initially believed it works!.<blockquote> | ||
<code> | |||
REM "XPEEK - value is stored in peekvalue variable" | REM "XPEEK - value is stored in peekvalue variable" | ||
Line 19: | Line 19: | ||
?1=0:?$E=prevblock | ?1=0:?$E=prevblock | ||
endproc | endproc | ||
REM "XPOKE" | |||
proc xpoke(addr,value) | proc xpoke(addr,value) | ||
Line 33: | Line 36: | ||
?1=0:?$E=prevblock | ?1=0:?$E=prevblock | ||
endproc </ | endproc </code> | ||
__FORCETOC__ | __FORCETOC__ |
Revision as of 22:22, 14 May 2025
Index of SUPERBASIC Code Snippets (Hopefully this will be sorted by Topic when they grow)
Poking and Peeking Memory in a different Bank
SUPERBASIC uses a lot of the memory available, so when you want to store data on a different Bank you want to POKE or PEEK outside the normal memory range, to do so you can use the following PROCEDURES. PLease note that these are not by any means a fast way to do it since we reconfigure the memory LUT so that the memory under the registers location ($C000-$DF00) points to the address that we want to poke or peek on the fly, after that we get or set the content of the memory address and restore the segments so that the Kernel does not blow up after returning. Contrary to what I initially believed it works!.
REM "XPEEK - value is stored in peekvalue variable"
proc xpeek(addr)
local block:block=addr\8192:local prevblock
local offset:offset=addr%8192
?0=179:prevblock=?$E:?$E=block:?1=4
peekvalue=peek($C000+offset)
?1=0:?$E=prevblock
endproc
REM "XPOKE"
proc xpoke(addr,value)
local block:block=addr\8192:local prevblock
local offset:offset=addr%8192
?0=179:prevblock=?$E:?$E=block:?1=4
?($C000+offset)=value
?1=0:?$E=prevblock
endproc