tb1/tb1_snes/tools/snes_checksum.c
Vince Weaver dbaf404ec3 snes: rename tb_snes to tb1_snes
I kept typing it wrong anyway, and hey, git makes rename easy
2013-01-22 09:53:01 -05:00

37 lines
707 B
C

#include <stdio.h>
int main(int argc, char **argv) {
int byte,offset=0;
unsigned int total=0;
unsigned short checksum;
int debug=0;
while(1) {
byte=fgetc(stdin);
if (byte<0) break;
if (debug) {
if (offset==0xffdc) printf("%x\n",byte);
if (offset==0xffdd) printf("%x\n",byte);
if (offset==0xffde) printf("%x\n",byte);
if (offset==0xffdf) printf("%x\n",byte);
}
total+=byte;
offset++;
}
checksum=total&0xffff;
printf("\t.word\t$%hx\t\t; Complement of checksum\n",~checksum);
printf("\t.word\t$%hx\t\t; Unsigned 16-bit sum of ROM\n",checksum);
return 0;
}