mirror of
https://github.com/deater/tb1.git
synced 2024-09-27 13:54:42 +00:00
snes: checksum working
Finally got the checksum working. I had the checksum/complement fields reversed somehow.
This commit is contained in:
parent
b25ca3382a
commit
78c0113545
@ -2,7 +2,8 @@ AS=cl65
|
|||||||
LD=ld65
|
LD=ld65
|
||||||
|
|
||||||
|
|
||||||
all: tb1_snes.sfc
|
all: checksum.inc
|
||||||
|
|
||||||
|
|
||||||
tb1_snes.sfc: tb1_snes.o snes-hirom.cfg
|
tb1_snes.sfc: tb1_snes.o snes-hirom.cfg
|
||||||
$(LD) -o tb1_snes.sfc --config snes-hirom.cfg --obj tb1_snes.o
|
$(LD) -o tb1_snes.sfc --config snes-hirom.cfg --obj tb1_snes.o
|
||||||
@ -14,6 +15,12 @@ tb1_snes.o: tb1_snes.s snes_init.s \
|
|||||||
tb1_title.tiles: graphics/tb1_title.pcx ./tools/pcx_to_tiles_8bpp
|
tb1_title.tiles: graphics/tb1_title.pcx ./tools/pcx_to_tiles_8bpp
|
||||||
./tools/pcx_to_tiles_8bpp < graphics/tb1_title.pcx > tb1_title.tiles
|
./tools/pcx_to_tiles_8bpp < graphics/tb1_title.pcx > tb1_title.tiles
|
||||||
|
|
||||||
|
checksum.inc: ./tools/snes_checksum tb1_snes.sfc
|
||||||
|
./tools/snes_checksum < tb1_snes.sfc > checksum.inc
|
||||||
|
|
||||||
|
tools/snes_checksum:
|
||||||
|
cd tools && make
|
||||||
|
|
||||||
tools/pcx_to_tiles_8bpp:
|
tools/pcx_to_tiles_8bpp:
|
||||||
cd tools && make
|
cd tools && make
|
||||||
|
|
||||||
|
2
tb_snes/checksum.inc
Normal file
2
tb_snes/checksum.inc
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
.word $c807 ; Complement of checksum
|
||||||
|
.word $37f8 ; Unsigned 16-bit sum of ROM
|
@ -293,9 +293,7 @@ output:
|
|||||||
.byte $01 ; Country Code (1=NTSC,2=PAL)
|
.byte $01 ; Country Code (1=NTSC,2=PAL)
|
||||||
.byte $00 ; License Code (0=unassigned)
|
.byte $00 ; License Code (0=unassigned)
|
||||||
.byte $00 ; Version
|
.byte $00 ; Version
|
||||||
.word $37f8 ; Unsigned 16-bit sum of ROM
|
.include "checksum.inc"
|
||||||
.word $c807 ; Complement of checksum
|
|
||||||
|
|
||||||
.word $0,$0 ; unknown?
|
.word $0,$0 ; unknown?
|
||||||
|
|
||||||
; Interrupt Vectors!
|
; Interrupt Vectors!
|
||||||
|
@ -2,22 +2,31 @@
|
|||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
int byte;
|
int byte,offset=0;
|
||||||
unsigned int total=0;
|
unsigned int total=0;
|
||||||
unsigned short checksum;
|
unsigned short checksum;
|
||||||
|
int debug=0;
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
byte=fgetc(stdin);
|
byte=fgetc(stdin);
|
||||||
if (byte<0) break;
|
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;
|
total+=byte;
|
||||||
|
offset++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checksum=total&0xffff;
|
checksum=total&0xffff;
|
||||||
|
|
||||||
printf("Checksum: %hx\n",checksum);
|
printf("\t.word\t$%hx\t\t; Complement of checksum\n",~checksum);
|
||||||
printf("Complement: %hx\n",~checksum);
|
printf("\t.word\t$%hx\t\t; Unsigned 16-bit sum of ROM\n",checksum);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user