mapData
mapData is a small, low-level free function on the xt6502 target. It
bank-switches the data window (the banked data region, the $A000 region
in the memory map), so you choose which 8 KB page is visible there before
reading or writing through it.
#import "mapData.xc"Overview
Section titled “Overview”The xt6502 exposes more RAM than the 6502 can address at once by paging 8 KB
banks in and out of fixed windows. mapData selects which page is mapped into
the data window, so code can reach data that lives in a bank other than the one
it started in. It is a global function available to all code, called as
mapData(page), not a method on a class.
mapData
Section titled “mapData”void mapData(i16 page)The page argument selects the bank:
page == -1: map the same page as the current code area into the data window. This gives the calling class or function its own 8 KB data area, located with the running code: the data window then aliases the bank the caller executes from.page >= 0: map the specified page number (0–255) into the data window.
The function changes only what is visible in the window; it moves no bytes. After the call, ordinary loads and stores through the window address access the selected page.
When to use it
Section titled “When to use it”Use mapData for manual banked data access: reaching into a data bank that
is not currently mapped, or setting up a private per-object or per-function data
area with mapData(-1) before using it. It is a building block for low-level
code. Most programs let the compiler and runtime manage banking and never call
it directly.
See also
Section titled “See also”- The 6502 standard library: the other system services implemented specifically for the 6502.