for games, only for static screens.
I switched back to using the 256-color mode and after some changes to 32x_images.c, i came up with the following :
Code: Select all
void drawBackground(char* spriteBuffer)
vu16 *frameBuffer16 = &MARS_FRAMEBUFFER;
unsigned short size = 35840;
fast_memcpy(frameBuffer16 + 0x100, spriteBuffer, size);
void drawSprite(vu8* spriteBuffer2, vu16 x, vu16 y, unsigned short xWidth, unsigned char yWidth)
//each byte represents the color for each pixel. Allows us to reverse which we can't do with words
vu8 *frameBuffer8 = (vu8*) &MARS_FRAMEBUFFER;
unsigned short bufCnt;
unsigned char rowPos,yCount,xCount;
const unsigned short lineTableEnd = 0x100;
uint32 fbOff = lineTableEnd;
unsigned short topre;
//offset the number of pixels in each line to start to draw the image
xOff = x;
fbOff = lineTableEnd*2;
//y-offset for top of 320 to correct line in framebuffer
fbOff = fbOff + (y * 320);
//x-offset from start of first line
fbOff = fbOff + xOff;
bufCnt = 0;
yCount = 0;
xCount = 0;
rowPos = 0;
topre = (320 - (xWidth + xOff)) + xOff;
for (rowPos = 0; rowPos < yWidth; rowPos++)
for(xCount = 0; xCount < xWidth; xCount++)
bufCnt = (rowPos * (xWidth)) + xCount;
frameBuffer8[fbOff] = spriteBuffer2[bufCnt];
fbOff = fbOff + topre;
The funny thing i noticed is the fact that byte 0x00 is transparent when using drawSprite, even though i'm not explicitly supporting transparency.
I looked up online why it does that and apparently it was done on purpose by Sega.
Either way, it works in our advantage for sprites but it's really annoying for backgrounds.
I got pretty good speed but i feel like it could have been a little... faster.
ammianus came up with drawSpriteMaster here but it does not work well for me. (plus, it's slower anyway)
haroldoop told me to use SuperVDP but apparently it does not work on real hardware due to 68k->32X DMA not working properly.
The function i'm taking issue with is drawSprite : two for..loops just slowdowns things a bit.
How could it be improved ?
I'm just interested in one plane and sprites : if i want to have another plane, i would just use the Genesis's hardware for that.