[SDL] Best way to implement a simple "Framebuffer"
Peter Hickman
peterhickman386 at googlemail.com
Mon Sep 26 07:52:06 PDT 2011
Ok this is just going to be picky and maybe the compiler will catch these
sort of things for you but...
Why do you have a default case in the switch, it will never get there!
What is alpha a variable, the 'a'. It only has one value ever. That could be
a constant.
In your drawing code you could rewrite it by swapping the x and y loops over
allowing the y*32 to be calculated less.
for(y = 0; y < 32; y++) {
y32 = y * 32;
for(x = 0; x < 32; x++) {
addr = graphix_address+x+y32; // calculate address starting at 0x200, 1
line is 32 bytes in size, 32 lines on screen
set_px(x,y, get6502memory(addr)); // give set_px the byte in
"graphics" memory
}
}
Ok this will draw the screen column by row rather than row by column (or is
it the other way around). But you should get a little speed up with this,
not sure if this is the sort of thing a compiler can catch - it would be
nice if it could.
Finally given that r, g and b as initially assigned the value 255 I would
remove them from the case statements.
As I said this is just nitpicking and will be of only marginal help but I'm
in that sort of mood today :)
You should definitely try Benjamin's suggestion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20110926/1c0ff248/attachment.htm>
More information about the SDL
mailing list