Right, this can be tricky. There's lots of horrid Bank Switching and stuff, and moving these windows around. I'll assume for the moment that we're plotting 256 colour pixels.
If you just want to plot a single pixel, the process requires several steps:
1. Calculate the Memory location of the pixel
2. Calculate the Required Window position
3. Switch to the Bank
4. Calculate the memory offset of the pixel from the start of the bank.
5. write the pixel to the screen.
This is much easier in a flat memory mode.
There are a few Global variables that this procedure will need when calculating things. If you don't like global variables, then you can figure out the cute little message passing stuff yourself.
BytesPerScanline ; the number of bytes used per scanline. see page 5 WinGranularity ; the accuracy to which a memory window can be positioned see page 0 CurrentWindowPos ; the current position of the Write Window (in granularity units). If it's already in the right position, we won't bother to move it.OK, i'll explain how to perform each step in turn to plot a pixel at (x, y):
MemoryPosition = (BytesPerScanLine * y) + xThat's simple enough.
WindowPosition = MemoryPosition / WinGranularity
SetWindowPosition(WindowPosition) CurrentWindowPos = WindowPosition
PixelOffset = MemoryPosition - (WinGranularity * WindowPosition)
Write a byte at [PixelOffset]