libmsx
C library for MSX
|
APIs for indirect access to banked memory. More...
Functions | |
uint8_t | bmem_get (bmemptr_t src) |
Read byte from banked memory. | |
uint16_t | bmem_get_u16 (bmemptr_t src) |
Read 16-bits value from banked memory. | |
void | bmem_read (bmemptr_t src, void *dst, uint16_t len) |
Read byte sequence from banked memory. | |
void | bmem_copy_to_vmem (bmemptr_t src, vmemptr_t dst, uint32_t len) |
Copy from banked memory to VRAM. | |
void | bmem_bload_s (bmemptr_t src) |
Load a BSAVE formatted binary in banked memory into VRAM. | |
APIs for indirect access to banked memory.
Banked memory is treated as a ROM with one large address space to read and copy data.
uint8_t bmem_get | ( | bmemptr_t | src | ) |
Read byte from banked memory.
src | address of banked memory. |
uint16_t bmem_get_u16 | ( | bmemptr_t | src | ) |
Read 16-bits value from banked memory.
src | address of banked memory. |
void bmem_read | ( | bmemptr_t | src, |
void * | dst, | ||
uint16_t | len | ||
) |
Read byte sequence from banked memory.
src | source address of banked memory. |
dst | destination address. |
len | number of bytes to be read. |
dst
and len
must be in range of 0xc000
to 0xfffe
. In libmsx
, the DATA
segment and stack areas are placed on page 3 so this is reasonable.CODE
segment, and the library code itself is included in CODE
segment. So these areas cannot be specified as the destination areas.0xffff
is not memory, that is "extended slot selector" register.dst
and len
. Unfortunately, however, the library cannot determine the appropriate bounds. The application programmer must deal with this. Copy from banked memory to VRAM.
src | source address of banked memory. |
dst | destination address of VRAM. |
len | number of bytes to be copied. |
void bmem_bload_s | ( | bmemptr_t | src | ) |
Load a BSAVE
formatted binary in banked memory into VRAM.
A BSAVE
formatted binary must consist of a 7-byte header followed by the data body, as follows:
address | contents |
---|---|
src+0 | 0xFE |
src+1 | lo-byte of start address |
src+2 | hi-byte of start address |
src+3 | lo-byte of end address |
src+4 | hi-byte of end address |
src+5 | lo-byte of run address |
src+6 | hi-byte of run address |
src+7 | body[0] |
... | ... |
src+7 + N-1 | body[N-1] |
where N == end - start + 1
, and start <= end
.
start
and end
indicate the range of VRAM addresses where the image was; for VRAM images, run
is not used.
This function copies the data body to start
..end
of VRAM.
src | address of BSAVE foramtted binary in banked memory. |