o get crc working on 8 banks

This commit is contained in:
optixx 2009-04-26 15:02:10 +02:00
parent dc83f998c7
commit aa29d483eb
6 changed files with 52 additions and 21 deletions

View File

@ -1,7 +1,7 @@
#include "data.h" #include "data.h"
word crc_update (byte *data, word size) word crc_update (char far *data, word size)
{ {
word i; word i;
word j; word j;
@ -19,15 +19,13 @@ word crc_update (byte *data, word size)
} }
word crc_update_mem (word addr, word size) word crc_update_mem (unsigned long addr, word size)
{ {
word i; word i;
word j; word j;
word crc=0; word crc=0;
word v;
for (j=0; j<size; j++){ for (j=0; j<size; j++){
v = addr; crc = crc ^ ((word) *(byte*)(addr+j)<< 8);
crc = crc ^ ((word)v<< 8);
for (i=0; i<8; i++){ for (i=0; i<8; i++){
if (crc & 0x8000) if (crc & 0x8000)
crc = (crc << 1) ^ 0x1021; crc = (crc << 1) ^ 0x1021;

View File

@ -1,3 +1,4 @@
word crc_update (byte *data, word size); word crc_update (byte *data, word size);
word crc_update_mem (unsigned long, word size);

View File

@ -12,17 +12,33 @@ void initDebugMap(void) {
} }
} }
void int2hex(word i, char *buf) char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
void int2hex(unsigned long number, char *buf,word size)
{ {
word a; /*
for (a = 0; a < 4; ++a) { long a;
buf[a] = (i >> (4 * (2 * 2 - 1 - a))) & 0xf; for (a = 0; a < size; ++a) {
buf[a] = (i >> ((long)size * (2 * 2 - 1 - a))) & 0xf;
if (buf[a] < 10) if (buf[a] < 10)
buf[a] += '0'; buf[a] += '0';
else else
buf[a] += 'A' - 10; buf[a] += 'A' - 10;
} }
buf[a] = 0; */
//buf[a] = 0;
unsigned long n;
unsigned char i;
//unsigned char x;
for (i = 0; i < size; i++) {
n = number >> 4;
//x = (number - (n << 4));
buf[size-i-1] = hex_chars[(number - (n << 4))];
number = n;
}
} }
void writeln(char *buffer,word y){ void writeln(char *buffer,word y){

View File

@ -1,5 +1,5 @@
void initDebugMap(void); void initDebugMap(void);
void debug(void); void debug(void);
void int2hex(word i, char *buf); void int2hex(unsigned long i, char *buf,word size);
void writeln(char* line,word y); void writeln(char* line,word y);
void enableDebugScreen(void); void enableDebugScreen(void);

10
snes/crc/hex.py Normal file
View File

@ -0,0 +1,10 @@
number=0xffaaee
size = 6
print hex(number)
for i in range(0,size):
n = number >> 4;
print size-i-1, hex(number - (n << 4));
number = n;

View File

@ -30,11 +30,11 @@ void main(void) {
word crc01; word crc01;
word crc02; word crc02;
padStatus pad1; padStatus pad1;
char line_header[32] = "BANK CRC 123456789ABCDEF"; char line_header[32] = "BANK CRC ADDR 123456789ABCDEF";
char line[32] = " "; char line[32] = " ";
char test_buffer[] = "da"; char test_buffer[] = "da";
char *pointer; char far * pointer;
unsigned long addr;
initInternalRegisters(); initInternalRegisters();
*(byte*) 0x2105 = 0x01; // MODE 1 value *(byte*) 0x2105 = 0x01; // MODE 1 value
@ -47,15 +47,21 @@ void main(void) {
writeln(line_header,0); writeln(line_header,0);
while(1){ while(1){
pointer = (void*)0x8000; pointer = (void*)0x008000;
addr = 0x008000;
crc02 = crc_update(test_buffer,2); crc02 = crc_update(test_buffer,2);
//crc01 = crc_update(pointer,255); //crc01 = crc_update(pointer,255);
for(j=0; j<8; j++) { for(j=0; j<16; j++) {
crc01 = crc_update(pointer,0x8000); //crc01 = crc_update(pointer,0x8000);
int2hex(j,&line[0]); crc01 = crc_update_mem(addr,0x8000);
int2hex(crc01,&line[5]);
//int2hex((word)pointer,&line[10]); int2hex((unsigned long)j,&line[0],4);
int2hex((unsigned long)crc01,&line[5],4);
int2hex((unsigned long)addr,&line[10],6);
writeln(line,j+1); writeln(line,j+1);
pointer += 0x010000;
addr += 0x010000;
} }
while(!pad1.start) { while(!pad1.start) {
waitForVBlank(); waitForVBlank();