/* $Id: gen.c,v 1.1 2004/03/30 07:19:17 jmuelmen Exp $ */ #include #include "surf_drv.h" #define Rdp(x) (1 / (1 / Rd + 1 / Rdd)) #define Req(a) (1 / (1 / R((a)) + 1 / Rt + 1 / Rset)) #define R(a) ((255 - (a)) * Rv / 256.0 + Rw) #define v(a) (vref * (Rdp(1) + Req((a))) / Rdp(1)) static const double Rdd = 8.0; static const double Rset = 39.9; static const double Rt = 62.0; static const double vref = 1.24; extern FILE *outfile; void look_gen (double Rd, double Rv, double Rw) { static unsigned short addr = SURF_LOOKUP_ADDR; unsigned short i; printf("Giving it a go with %f, %f, %f\n", Rd, Rv, Rw); for (i = 0; i < 0x0100; i += 0x20, addr += 0x20) { unsigned short j; unsigned long checksum = 0x20 + (addr >> 8) + (addr & 0xff); fprintf(outfile, ":20%.4X00", addr); for (j = i; j < i + 0x20; ++j) { double V = v(j); int vv = (int)((V - 1.2) / 2.048 * (1 << 12)); int vvv = vv >> 4; fprintf(outfile, "%.2X", (unsigned char)vvv); checksum += vvv; } checksum %= 0x100; checksum = 0x100 - checksum; fprintf(outfile, "%.2X\n", (unsigned char)checksum); } }