snes: try to get checksum valid

It's not working for reasons I don't understand.
This commit is contained in:
Vince Weaver 2013-01-16 17:36:23 -05:00
parent 33c9828283
commit b25ca3382a
4 changed files with 43 additions and 6 deletions

View File

@ -1,6 +1,6 @@
#
# Attempts a proper layout for a SNES HiROM image
#
# This one is a 512kB (4Mbit) image
#------------------------------------------------------------------------------
#
@ -13,7 +13,7 @@ MEMORY {
RAM: start = $7e2000, size = $e000, type = rw, define = yes;
STACK: start = $000000, size = $2000, type = rw, define = yes;
SRAM: start = $006000, size = $2000, type = rw, define = yes;
MOREROM: start = $410000, size = $10000, type = ro, file = %O, fill = yes, define = yes;
MOREROM: start = $410000, size = $70000, type = ro, file = %O, fill = yes, define = yes;
}
#------------------------------------------------------------------------------
#

View File

@ -293,8 +293,10 @@ output:
.byte $01 ; Country Code (1=NTSC,2=PAL)
.byte $00 ; License Code (0=unassigned)
.byte $00 ; Version
.byte $7f, $73, $80, $8c ; Unsigned 16-bit sum of ROM
.byte $ff, $ff, $ff, $ff ; Complement of checksum
.word $37f8 ; Unsigned 16-bit sum of ROM
.word $c807 ; Complement of checksum
.word $0,$0 ; unknown?
; Interrupt Vectors!

View File

@ -5,7 +5,8 @@ LFLAGS =
all: bin2byte color_convert convert_font convert_font_bin \
dump_font make_pal pcx_to_sprite \
pcx_to_tiles_4bpp pcx_to_tiles_8bpp \
ansi_to_tile string_to_bytes convert_font_4bpp
ansi_to_tile string_to_bytes convert_font_4bpp \
snes_checksum
ansi_to_tile: ansi_to_tile.o
@ -94,11 +95,18 @@ string_to_bytes.o: string_to_bytes.c
$(CC) $(CFLAGS) -c string_to_bytes.c
snes_checksum: snes_checksum.o
$(CC) $(LFLAGS) -o snes_checksum snes_checksum.o
snes_checksum.o: snes_checksum.c
$(CC) $(CFLAGS) -c snes_checksum.c
clean:
rm -f *.o *~ bin2byte color_convert convert_font \
convert_font_bin dump_font make_pal pcx_to_sprite \
pcx_to_tiles_4bpp pcx_to_tiles_8bpp \
ansi_to_tile string_to_bytes \
convert_font_4bpp
convert_font_4bpp snes_checksum

View File

@ -0,0 +1,27 @@
#include <stdio.h>
int main(int argc, char **argv) {
int byte;
unsigned int total=0;
unsigned short checksum;
while(1) {
byte=fgetc(stdin);
if (byte<0) break;
total+=byte;
}
checksum=total&0xffff;
printf("Checksum: %hx\n",checksum);
printf("Complement: %hx\n",~checksum);
return 0;
}