Sets the 8 Least Significant bits (the offset) of the memory address where video memory starts.
void cpct_setVideoMemoryOffset (u8 offset)
(1B L) offset | New starting offset for Video Memory (8 Least Significant bits) |
call cpct_setVideoMemoryOffset_asm
Changes part of the address where video memory starts (Video Memory Start Address, VMSA). Video memory starts at an address that can be defined in binary as follows:
-------------------------------------------------------- VMSA = [ ppppppoooooooo00 ] -------------------------------------------------------- Figure 1 - Video Memory Start Address (VMSA) composition
where you have 6 bits that define the Page (p-bits), and 8 bits that define the offset (o-bits). The 2 Least Significant Bits (LSb) are always set to 0.
This function changes the 8 bits that define the offset (the o-bits). These 8 bits are controlled by Register R13 from the CRTC. If you wanted to change the 6 Most Significant bits (the page), you should use cpct_setVideoMemoryPage
Changing the offset effectively changes the place where your video memory starts in your system RAM, immediately changing what is displayed on screen. This could be used to produce scrolling effects or to make a fine grained control of double / triple buffers by hardware.
To better explain this, lets show an example,
1 | You want your VMSA at 0xC0A0, instead of 0xC000 |
2 | 0xC0A0 corresponds to page = 0x30, offset = 0xA0 (check Figure 1) |
3 | Page 0x30 is set by default (memory address starts at 0xC000 at power on) |
4 | You only have to call cpct_setVideoMemoryOffset(0xA0) |
Another example, requiring page and offset to be set, could be the next one. Imagine you have a double buffer starting at memory address 0x801A and you wanted to make it visible on screen. Your code to do that could be like this:
... cpct_setVideoMemoryPage(cpct_page80); // Set page 0x80 cpct_setVideoMemoryOffset(0x1A); // Set offset 0x1A ...
When creating hardware back buffers, always take into account that video memory is never considered linear by Gate Array. This means that, wherever you put your VMSA, it will be considered the start of a Video Memory made of 8-pixel-line characters. Consult cpct_drawSprite for more details on how video memory is distributed at its default place (it will be distributed similarly at every place it were located).
F, BC, HL
9 bytes
Case | microSecs (us) | CPU Cycles ----------------------------------------- Any | 15 | 60 -----------------------------------------