I am creating a emulator for a retro device where that device has simple memory mapped graphic (1, 2, or 4 bits per pixel).
I anticipate that I will need convert/map between the device window representation to SDL’s representation, periodically (30 or 60 times a second) pixel by pixel.
I’m new to SDL so would like to be steered in the right direction as to what mechanisms in SDL I should be using/focusing on.
I expect I need to manipulate the underlying SDL bitmaps (or what ever they are called in SDL) directly for efficiency reasons.
So where should I start looking?
For instance is there a mapping function that can do the work for me?
You should probably create a framebuffer where you manually draw things. I’d have a (threaded) function that copies from my custom framebuffer (1-4 bits) to the SDL framebuffer. You might want to use a pallet mode too, since it’s only 8 bits and you don’t have to do any conversions. In this case, you don’t need a threaded function.
I think you can do things like blit part of a surface and stuff like that but generally you should take care of your frame buffer by yourself, especially if you use nonstandard formats.
If I wanted to leave a portion of the window for a menu bar (top strip) and a status bar (bottom strip) does SDL have the concept of sub windows where I would render the texture into the appropriate sub (main) window?
Otherwise I must always add a constant to the offset when manipulating the memory buffer!
Yes, you can do that. SDL_RenderCopy lets you chose which part of the texture or screen you want to draw. In my case they are both null because it means the entire texture and the entire screen. https://wiki.libsdl.org/SDL_RenderCopy