dos33fsprogs/pt3_player/table_gen/table_gen.c

305 lines
8.8 KiB
C

#include <stdio.h>
#include <string.h>
static unsigned char out[256];
static unsigned char PT3VolumeTable_33_34[]={
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, //0
0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x1,0x1,0x1, //1
0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x2, //2
0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x1,0x2,0x2,0x2,0x2,0x3,0x3,0x3,0x3, //3
0x0,0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4, //4
0x0,0x0,0x0,0x1,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x4,0x5,0x5, //5
0x0,0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6, //6
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x4,0x5,0x5,0x6,0x6,0x7,0x7, //7
0x0,0x0,0x1,0x1,0x2,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x6,0x7,0x7,0x8, //8
0x0,0x0,0x1,0x1,0x2,0x3,0x3,0x4,0x5,0x5,0x6,0x6,0x7,0x8,0x8,0x9, //9
0x0,0x0,0x1,0x2,0x2,0x3,0x4,0x4,0x5,0x6,0x6,0x7,0x8,0x8,0x9,0xA, //a
0x0,0x0,0x1,0x2,0x3,0x3,0x4,0x5,0x6,0x6,0x7,0x8,0x9,0x9,0xA,0xB, //b
0x0,0x0,0x1,0x2,0x3,0x4,0x4,0x5,0x6,0x7,0x8,0x8,0x9,0xA,0xB,0xC, //c
0x0,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xB,0xC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3,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xA,0xB,0xC,0xD,
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,
0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xA,0xB,0xC,0xD,0xE,0xF,
};
static unsigned char gen1[]={
// 16 0
0xf0,
// 8 0,8 1
0x70,0x71,
// 6 0,5 1,5 2
0x50,0x41,0x42,
// 4 0,4 1,4 2,4 3
0x30,0x31,0x32,0x33,
// 4 0,3 1,3 2,3 3,3 4
0x30,0x21,0x22,0x23,0x24,
// 3 0,3 1,2 2,3 3,3 4,2 5
0x20,0x21,0x12,0x23,0x24,0x15,
// 3 0,2 1,2 2,3 3,2 4,2 5,2 6
0x20,0x11,0x12,0x23,0x14,0x15,0x16,
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,
// 2 0,2 1,2 2,2 3,1 4,2 5,2 6,2 7,1 8
0x10,0x11,0x12,0x13,0x04,0x15,0x16,0x17,0x08,
// 2 0,2 1,1 2,2 3,1 4,2 5,2 6,1 7,2 8,1 9
0x10,0x11,0x02,0x13,0x04,0x15,0x16,0x07,0x18,0x09,
// 2 0,1 1,2 2,1 3,2 4,1 5,2 6,1 7,2 8,1 9,1 A
0x10,0x01,0x12,0x03,0x14,0x05,0x16,0x07,0x18,0x09,0x0a,
// 2 0,1 1,1 2,2 3,1 4,1 5,2 6,1 7,1 8,2 9,1 A,1 B
0x10,0x01,0x02,0x13,0x04,0x05,0x16,0x07,0x08,0x19,0x0a,0x0b,
// 2 0,1 1,1 2,1 3,2 4,1 5,1 6,1 7,2 8,1 9,1 A,1 B,1 C
0x10,0x01,0x02,0x03,0x14,0x05,0x06,0x07,0x18,0x09,0x0a,0x0b,0x0c,
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,2 7,1 8,1 9,1 A,1 B,1 C,1 D
0x10,0x01,0x02,0x03,0x04,0x05,0x06,0x17,0x08,0x09,0x0a,0x0b,0x0c,0x0d,
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E
0x10,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
};
static void gen_table_1(void) {
int total=0,temp,index=0,i;
while(total<256) {
temp=gen1[index];
for(i=0;i<(temp>>4)+1;i++) {
out[total]=temp&0xf;
total++;
}
index++;
}
}
static unsigned char gen2[]={
// 16 0 SKIP this always 0
// 8 0,8 1
// 770 = 111 1,11 00
0xfc,
// 6 0,5 1,5 2
// 544 = 101 1,00 00 -- 400 = 100,0 0000
0xb0,0x80,
// 4 0,4 1,4 2,4 3
// 330 330 = 011 0,11 00 011 0,11 00
0x6c,0x6c,
// 4 0,3 1,3 2,3 3,3 4
// 323 220 = 0110,1011 0100,1000
0x6b,0x48,
// 3 0,3 1,2 2,3 3,3 4,2 5
// 222 222 = 010 0,10 10 010 0,10 10
0x4a,0x4a,
// 3 0,2 1,2 2,3 3,2 4,2 5,2 6
// 212 212 100 = 010 0,01 10 010 0,10 01 00100000
0x46,0x46,0x20,
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
// 112 112 110 = 0010,0110 0010,0110 0010,01 00
0x26,0x26,0x24,
// 2 0,2 1,2 2,2 3,1 4,2 5,2 6,2 7,1 8
// 112 102 111 - 0010,0110 0010,0010 0010,0101
0x26,0x22,0x25,
// 2 0,2 1,1 2,2 3,1 4,2 5,2 6,1 7,2 8,1 9
// 111 102 102 000 = 0010,0101 0010,0010 0010,0010 0000,0000
0x25,0x22,0x22,0x00,
// 2 0,1 1,2 2,1 3,2 4,1 5,2 6,1 7,2 8,1 9,1 A
// 102 011 102 000 - 0010,0010 0000,0101 0010,0010 0000,0000
0x22,0x05,0x22,0x00,
// 2 0,1 1,1 2, 2 3,1 4,1 5, 2 6,1 7,1 8, 2 9,1 A,1 B
// 101 101 101 101 = 0010,0001
0x21,0x21,0x21,0x21,
// 2 0,1 1,1 2, 1 3,2 4,1 5, 1 6,1 7,2 8, 1 9,1 A,1 B, 1 C
// 101 011 002 001 000 = 0010,0001 0000,0101 0000,0010 0000,0001 0000,0000
0x21,0x05,0x02,0x01,0x00,
// 2 0,1 1,1 2, 1 3,1 4,1 5, 1 6,2 7,1 8, 1 9,1 A,1 B, 1 C,1 D
// 101 001 011 001 000 = 0010,0001 0000,0001 0000,0101 0000,0001 0000,0000
0x21,0x01,0x05,0x1,0x0,
// 2 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E
// 101 001 001 001 001 000 = 001 0,00 01 000 000 01
0x21,0x01,0x01,0x01,0x01,0x00,
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
// 001 001 001 001 001 000 = 000 000 01
0x01,0x01,0x01,0x01,0x01,0x00,
};
static unsigned char gen3[]={
// 16 0 SKIP this always 0
// 8 0,8 1
// 770 = 111 1,11 00
0xfc,
// 4 0,8 1,4 2
// 370 300 = 011 1,11 00 -- 011,0 0000
0x7c,0x60,
// 3 0,5 1,5 2, 3 3
// 240 420 = 0101,000 1000,1000
0x50,0x88,
// 2 0,4 1, 4 2,4 3,2 4
// 130 332 = 0010,1100, 0110,1110
0x2c,0x6e,
// 2 0,3 1,3 2, 3 3,3 4,2 5
// 123 222 = 001 0,10 11 010 0,10 10
0x2b,0x4a,
// 2 0,2 1,3 2, 2 3,3 4,2 5, 2 6
// 113 122 100 = 001 0,01 11 001 0,10 10 00100000
0x27,0x2a,0x20,
// 2 0,2 1,2 2,2 3,2 4,2 5,2 6,2 7
// 112 112 110 = 0010,0110 0010,0110 0010,01 00
0x26,0x26,0x24,
// 1 0,2 1,2 2, 2 3,2 4,2 5, 2 6,2 7,1 8
// 012 112 111 - 0000,0110 0010,0110 0010,0101
0x06,0x26,0x25,
// 1 0,2 1,2 2, 1 3,2 4,2 5, 1 6,2 7,2 8, 1 9
// 012 012 012 000 = 0000,0110 0000,0000
0x06,0x06,0x06,0x00,
// 1 0,2 1,1 2, 2 3,1 4,2 5, 1 6,2 7,1 8, 2 9,1 A
// 011 102 011 100 - 0000,0101 0010,0010 0010,0010 0010,0000
0x05,0x22,0x05,0x20,
// 1 0,2 1,1 2, 1 3,2 4,1 5, 1 6,2 7,1 8, 1 9,2 A,1 B
// 011 111 011 011 = 0000,0101
0x05,0x05,0x05,0x05,
// 1 0,1 1,2 2, 1 3,1 4,1 5, 2 6,1 7,1 8, 1 9,2 A,1 B, 1 C
// 002 001 101 011 000 = 0000,0010 0000,0001 0010,0001 0000,0101 0000,0000
0x02,0x01,0x21,0x05,0x00,
// 1 0,1 1,1 2, 2 3,1 4,1 5, 1 6,1 7,1 8, 1 9,2 A,1 B, 1 C,1 D
// 001 101 001 011 000 = 0010,0001 0000,0001 0000,0101 0000,0001 0000,0000
0x01,0x21,0x01,0x05,0x00,
// 1 0,1 1,1 2, 1 3,1 4,1 5, 1 6,2 7,1 8, 1 9,1 A,1 B, 1 C,1 D,1 E
// 001 001 011 001 001 000 = 001 0,00 01 000 000 01
0x01,0x01,0x05,0x01,0x01,0x01,
// 1 0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1 9,1 A,1 B,1 C,1 D,1 E,1 F
// 001 001 001 001 001 000 = 000 000 01
0x01,0x01,0x01,0x01,0x01,0x00,
};
static void gen_table_2(unsigned char *g) {
int row=0,column=0,val,index=0,temp,i,total=0;
while(row<15) {
val=0;
column=0;
printf("\n");
while(1) {
temp=(g[index]>>5)&0x7;
for(i=0;i<temp+1;i++) {
out[16+total]=val;
printf("%x ",val);
total++;
column++;
}
if (column>=16) break;
val++;
temp=(g[index]>>2)&0x7;
for(i=0;i<temp+1;i++) {
out[16+total]=val;
printf("%x ",val);
total++;
column++;
}
if (column>=16) break;
temp=(g[index])&0x3;
if (temp!=0) {
val++;
for(i=0;i<temp;i++) {
out[16+total]=val;
printf("%x ",val);
total++;
column++;
}
}
val++;
if (column>=16) break;
index++;
}
index++;
row++;
}
}
int main(int argc, char **argv) {
int i;
printf("Default is 256 bytes!\n");
printf("\nNext is %ld bytes\n",sizeof(gen1));
memset(out,0,256);
gen_table_1();
for(i=0;i<256;i++) {
if (out[i]!=PT3VolumeTable_33_34[i]) {
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
i,i,PT3VolumeTable_33_34[i],out[i]);
return -1;
}
}
printf("\nNext is %ld bytes\n",sizeof(gen2));
memset(out,0,256);
gen_table_2(gen2);
for(i=0;i<256;i++) {
if (out[i]!=PT3VolumeTable_33_34[i]) {
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
i,i,PT3VolumeTable_33_34[i],out[i]);
return -1;
}
}
printf("\nGNext is %ld bytes\n",sizeof(gen3));
memset(out,0,256);
gen_table_2(gen3);
for(i=0;i<256;i++) {
if (out[i]!=PT3VolumeTable_35[i]) {
fprintf(stderr,"Mismatch at %d (%x) expected %d got %d!\n",
i,i,PT3VolumeTable_35[i],out[i]);
return -1;
}
}
return 0;
}