o get crc working on 8 banks
This commit is contained in:
parent
dc83f998c7
commit
aa29d483eb
@ -1,7 +1,7 @@
|
||||
#include "data.h"
|
||||
|
||||
|
||||
word crc_update (byte *data, word size)
|
||||
word crc_update (char far *data, word size)
|
||||
{
|
||||
word i;
|
||||
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 j;
|
||||
word crc=0;
|
||||
word v;
|
||||
for (j=0; j<size; j++){
|
||||
v = addr;
|
||||
crc = crc ^ ((word)v<< 8);
|
||||
crc = crc ^ ((word) *(byte*)(addr+j)<< 8);
|
||||
for (i=0; i<8; i++){
|
||||
if (crc & 0x8000)
|
||||
crc = (crc << 1) ^ 0x1021;
|
||||
@ -36,4 +34,4 @@ word crc_update_mem (word addr, word size)
|
||||
}
|
||||
}
|
||||
return crc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
|
||||
word crc_update (byte *data, word size);
|
||||
word crc_update_mem (unsigned long, word size);
|
||||
|
||||
|
||||
@ -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) {
|
||||
buf[a] = (i >> (4 * (2 * 2 - 1 - a))) & 0xf;
|
||||
/*
|
||||
long a;
|
||||
for (a = 0; a < size; ++a) {
|
||||
buf[a] = (i >> ((long)size * (2 * 2 - 1 - a))) & 0xf;
|
||||
if (buf[a] < 10)
|
||||
buf[a] += '0';
|
||||
else
|
||||
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){
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
void initDebugMap(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 enableDebugScreen(void);
|
||||
10
snes/crc/hex.py
Normal file
10
snes/crc/hex.py
Normal 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;
|
||||
|
||||
@ -30,11 +30,11 @@ void main(void) {
|
||||
word crc01;
|
||||
word crc02;
|
||||
padStatus pad1;
|
||||
char line_header[32] = "BANK CRC 123456789ABCDEF";
|
||||
char line_header[32] = "BANK CRC ADDR 123456789ABCDEF";
|
||||
char line[32] = " ";
|
||||
char test_buffer[] = "da";
|
||||
char *pointer;
|
||||
|
||||
char far * pointer;
|
||||
unsigned long addr;
|
||||
initInternalRegisters();
|
||||
|
||||
*(byte*) 0x2105 = 0x01; // MODE 1 value
|
||||
@ -47,15 +47,21 @@ void main(void) {
|
||||
writeln(line_header,0);
|
||||
|
||||
while(1){
|
||||
pointer = (void*)0x8000;
|
||||
pointer = (void*)0x008000;
|
||||
addr = 0x008000;
|
||||
|
||||
crc02 = crc_update(test_buffer,2);
|
||||
//crc01 = crc_update(pointer,255);
|
||||
for(j=0; j<8; j++) {
|
||||
crc01 = crc_update(pointer,0x8000);
|
||||
int2hex(j,&line[0]);
|
||||
int2hex(crc01,&line[5]);
|
||||
//int2hex((word)pointer,&line[10]);
|
||||
for(j=0; j<16; j++) {
|
||||
//crc01 = crc_update(pointer,0x8000);
|
||||
crc01 = crc_update_mem(addr,0x8000);
|
||||
|
||||
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);
|
||||
pointer += 0x010000;
|
||||
addr += 0x010000;
|
||||
}
|
||||
while(!pad1.start) {
|
||||
waitForVBlank();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user