Checksum calculation (slow in GCC)

Ask anything your want about Megadrive/Genesis programming.

Moderator: BigEvilCorporation

Post Reply
Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Checksum calculation (slow in GCC)

Post 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 :P
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
Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal »

i'm not surprise, it took the same time in asm...
Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post by Fonzie »

Ok :D 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.
Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal »

just put a screen "Now loading". nowadays, people are used to those screens :)
Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post 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.
HardWareMan
Very interested
Posts: 753
Joined: Sat Dec 15, 2007 7:49 am

Post 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?
Shiru
Very interested
Posts: 786
Joined: Sat Apr 07, 2007 3:11 am
Location: Russia, Moscow
Contact:

Post by Shiru »

HardWareMan wrote:Maybe this is anti-GG protection?
If so, then why need to protect whole ROM? Code area will be enough.
TmEE co.(TM)
Very interested
Posts: 2452
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post 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.
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen
8bitwizard
Very interested
Posts: 159
Joined: Sat Feb 24, 2007 11:35 pm
Location: San Antonio, TX

Post 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.
Fonzie
Genny lover
Posts: 323
Joined: Tue Aug 29, 2006 11:17 am
Contact:

Post 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...
Post Reply