SDCC framework - How to access system video sprite memory
Created by: valen, Last modification: Wed 07 of Jul, 2010 (13:18 UTC)
Access to system memory. (read/write)
There are 15 banks by 32KB (Page window: 8000-FFFF).
Logical banks numbers are 0-14.
SET_SYSTEM_PAGE(page);
Example:
Let's page in last system memory bank (14) and zero it.
SET_SYSTEM_PAGE(14);
memset((void*)0x8000, 0, 0x8000);
Note: You can use system memory for code/data. CPU can execute code only from system memory.
Access to video memory. (read/write)
There are 64 banks by 8KB (Page window: 2000-3FFF. Must be paged in,
accessed and paged out).
Banks numbers are 0-63.
SET_VIDEO_PAGE(video_page);
Example:
Let's page in last video memory bank (63) and zero it.
PAGE_IN_VIDEO_RAM();
SET_VIDEO_PAGE(63);
memset((void*)0x2000, 0, 0x2000);
PAGE_OUT_VIDEO_RAM();
Note: there is also another method for video memory access - Direct VRAM access mode.
Access to sprite memory. (write only)
There are 32 banks by 4KB (Page window: 1000-1FFF. Must be paged in,
accessed and paged out).
Banks numbers are 0-31.
SET_SPRITE_PAGE(sprite_page);
Example:
Let's page in last sprite memory bank (31) and zero it.
PAGE_IN_SPRITE_RAM();
SET_SPRITE_PAGE(31);
memset((void*)0x1000, 0, 0x1000);
PAGE_OUT_SPRITE_RAM();