nutribrain
Still Fresh
I'm having a problem on my second little programm I write. I want to do a Space Invaders type game and are stuck now at the point I want to draw all the invaders sprites to the buffer. I seems that from the upper left corner to the middle of the bottom a diagonal line/area is spanned which is black opague and hide my sprites and everything under it.
I'm using Mr.Mirkos SDK (BTW great one!).
I suspect the 'gp_clearFramebuffer16' function to be too slow to fill the whole buffer and keeps on filling it right after I write my sprites. And that results in the black "curtain". Also I've read about a cache problem concerning the Samsung chip inside the GP32.
I bet that this is a timing problem so I tried to unroll the code but didn't succeed. And I also tried to adjust the clockspeed from 66 to 133 but this only had the result that the "curtain" has a different position.
My code looks like this:
It would be very nice if someone could help me on this.
BTW: The first steps in C programming for then GP32 I did about one and a half year ago. And when I saw that there is a replacement lib for the original Gamepark SDK, I thought about give it a try. And I have to say till now this lib my Mr.Mirko is absolutely GREAT!!! I appreciate very much the work and effort he puts into this project.
I'm using Mr.Mirkos SDK (BTW great one!).
I suspect the 'gp_clearFramebuffer16' function to be too slow to fill the whole buffer and keeps on filling it right after I write my sprites. And that results in the black "curtain". Also I've read about a cache problem concerning the Samsung chip inside the GP32.
I bet that this is a timing problem so I tried to unroll the code but didn't succeed. And I also tried to adjust the clockspeed from 66 to 133 but this only had the result that the "curtain" has a different position.
My code looks like this:
Code:
while(1) {
swap_screen();
gp_clearFramebuffer16(framebuffer[nflip],0x0000); // very very fast asm, faster than memset
for (i=0; i<INVADERLINES; i++) {
j = 0;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
gp_drawSprite ( &invader20Sprite, invaders[i][j].x, invaders[i][j].y, framebuffer[nflip], INVADERWIDTH, INVADERHEIGHT ); j++;
}
gp_drawSpriteT ( &cruiserSprite, cruiser.x, cruiser.y, framebuffer[nflip], 0x0000, cruiser.width, cruiser.height );
if (shotFired) draw_shot();
It would be very nice if someone could help me on this.
BTW: The first steps in C programming for then GP32 I did about one and a half year ago. And when I saw that there is a replacement lib for the original Gamepark SDK, I thought about give it a try. And I have to say till now this lib my Mr.Mirko is absolutely GREAT!!! I appreciate very much the work and effort he puts into this project.