Page 1 of 1
Checksum calculation (slow in GCC)
Posted: Tue Oct 28, 2008 11:38 am
by Fonzie
Hi

I wanted to make my own checksum routine today... Basically adding all the bytes of the rom to a 16bit word :
Code: Select all
temp=0;
for(i=0x200;i<4096*1024;i++)
{
temp+=(*checksum0);
checksum0++;
}
The fact is... it takes around 15-20 seconds to checksum 4MegaBytes

So my question is... Is that normal for GCC code?
I want my checksum to be done in less than 1 second... is that possible in C? Should I jump 16bytes by 16bytes to make it faster (and also less accurate :/ )
I must admit I'm quite shocked by the time it takes to browse 4MB of bytes... wow.
Thx for your inputs.
Fonz
Posted: Tue Oct 28, 2008 11:43 am
by Pascal
i'm not surprise, it took the same time in asm...
Posted: Tue Oct 28, 2008 12:35 pm
by Fonzie
Ok

Thx.
I just passed to word to twice a bit the speed...
Well, i'll have to make something more fancy for the ultra 64MEG of power checksumming ^^ Don't want to wait 30 seconds haha.
Posted: Tue Oct 28, 2008 1:40 pm
by Pascal
just put a screen "Now loading". nowadays, people are used to those screens

Posted: Tue Oct 28, 2008 1:53 pm
by Shiru
Why you want to make checksum for whole ROM every time? It's slightly pointless. If you want to have this function to ensure that cartridge isn't damaged, you can make this test optional (executed only while hold some buttons on power-up or reset), and describe that in the manual.
Posted: Tue Oct 28, 2008 2:15 pm
by HardWareMan
Shiru wrote:Why you want to make checksum for whole ROM every time? It's slightly pointless. If you want to have this function to ensure that cartridge isn't damaged, you can make this test optional (executed only while hold some buttons on power-up or reset), and describe that in the manual.
Maybe this is anti-GG protection?
Posted: Tue Oct 28, 2008 3:23 pm
by Shiru
HardWareMan wrote:Maybe this is anti-GG protection?
If so, then why need to protect whole ROM? Code area will be enough.
Posted: Tue Oct 28, 2008 3:55 pm
by TmEE co.(TM)
Even with really optimized ASM checksummer, you have to wait 10 seconds before 32Mbit gets calculated, somewhat less if you use Longs instead of Words.
Posted: Sat Nov 01, 2008 2:41 pm
by 8bitwizard
If you really want to calculate the checksum, why stop everything else to do it?
Have the checksum run incrementally as the game and title screens run, or in the vblank, then do whatever you want when it finishes and finds the wrong checksum.
Posted: Sat Jan 17, 2009 5:52 pm
by Fonzie
Shiru wrote:Why you want to make checksum for whole ROM every time? It's slightly pointless. If you want to have this function to ensure that cartridge isn't damaged, you can make this test optional (executed only while hold some buttons on power-up or reset), and describe that in the manual.
Thx for all the answers... It is exactly for that, I just run the checksum a single time, when you play the game for the first time.
In that way, I can be sure that nobody start playing with a defective cartridge (that a simple checksum would not especially detect with a bit of bad luck).
So Long does speed up compared to words... interesting...