Archived

This topic is now archived and is closed to further replies.

GBA- Changing the data in my arrays...?

This topic is 5776 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I''ve been playing around in mode 3, and in the process I''ve been trying to manually back buffer things. Now, I''ve encountered a bit of a problem. It seems that the data in my back buffer array is changed as soon as I put it in. If I do this:
  
for (x = 0; x < 240; x++){
    for (y = 0; y < 160; y++){
	int place = x+y*240;
	videoBuffer[place] = 0xFFFF;
    }
}
  
Then the screen, as expected, draws completely white. No problem. Then I add an array "int backBuffer[38400];", and do this:
  
for (x = 0; x < 240; x++){
    for (y = 0; y < 160; y++){
        int place = x+y*240;
        backBuffer[place] = 0xFFFF;
        videoBuffer[place] = backBuffer[place];
    }
}
  
Then the screen is filled with, what would seem to me anyway, pretty random garbage. Is it just me, or is the data in backBuffer getting corrupted somewhere in the process of those two lines of code? If the data is corrupted that instantaneously, there''s no way I can use it as I intend... What''s going on here? -Arek the Absolute

Share this post


Link to post
Share on other sites
Hi Arek the Absolute I have worked on doing mode3 double buffering in the past and its not worth the struggle. The only way I have found that it works fast enough is to use some sort of DMA copy each frame or using memcpy. Anyway to solve your problem you should try clearing the memory of your buffer before using it using memset(&backBuffer,0x000,240*160) or using the new unsigned short backBuffer[240*160] pointer if your using c++.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The GBA only has 32kb IWRAM (used for storing variables and stuff) and 256kb EWRAM (usually used to store data). Your backbuffer doesn''t fit in that 32kb IWRAM, that''s why it isn''t working.

Share this post


Link to post
Share on other sites
HI again as AP has stated that can be the problem but I think it is unlikely as with both compilers GCC and ARM SDT use the rw memory base as the external ram adderess 0x02000000 - 0x0203FFFF but as stated before it could be the problem.

Share this post


Link to post
Share on other sites