1 #include <stdio.h>
2
3 // Create the ctv.h header file
4 // which includes all combinations of the cps tile drawing functions
5
main()6 int main()
7 {
8 int nCuMask=0;
9 int nCuBpp=0;
10 int nCuSize=0;
11 int nCuRows=0;
12 int nCuCare=0;
13 int nCuFlipX=0;
14
15 for (nCuMask=0; nCuMask<=2; nCuMask++)
16 {
17 printf ("#define CU_MASK (%d)\n\n",nCuMask);
18 for (nCuBpp=2; nCuBpp<=4; nCuBpp++)
19 {
20 printf ("#define CU_BPP (%d)\n\n",nCuBpp);
21 for (nCuSize=8; nCuSize<=32; nCuSize<<=1)
22 {
23 printf ("#define CU_SIZE (%d)\n\n",nCuSize);
24 for (nCuRows=0; nCuRows<2; nCuRows++)
25 {
26 printf ("#define CU_ROWS (%d)\n\n",nCuRows);
27 for (nCuCare=0; nCuCare<2; nCuCare++)
28 {
29 printf ("#define CU_CARE (%d)\n",nCuCare);
30 for (nCuFlipX=0; nCuFlipX<2; nCuFlipX++)
31 {
32 printf ("#define CU_FLIPX (%d)\n",nCuFlipX);
33
34 if (((nCuRows && (nCuSize != 16)) || (nCuRows && nCuMask))) {
35 printf("// Invalid combination of capabilities.\n");
36 } else {
37 printf ("static INT32 ");
38 printf ("CtvDo");
39 printf ("%d",nCuBpp);
40 printf ("%.2d",nCuSize);
41 if (nCuRows) printf ("r"); else printf ("_");
42 if (nCuCare) printf ("c"); else printf ("_");
43 if (nCuFlipX) printf ("f"); else printf ("_");
44 if (nCuMask==1) printf ("m()\n#include \"ctv_do.h\"\n");
45 else if (nCuMask==2) printf ("b()\n#include \"ctv_do.h\"\n");
46 else printf ("_()\n#include \"ctv_do.h\"\n");
47 }
48
49
50
51 printf ("#undef CU_FLIPX\n");
52 }
53 printf ("#undef CU_CARE\n\n");
54 }
55 printf ("#undef CU_ROWS\n\n");
56 }
57 printf ("#undef CU_SIZE\n\n");
58 }
59 printf ("#undef CU_BPP\n\n");
60 }
61 printf ("#undef CU_MASK\n\n");
62 }
63
64 printf ("\n\n");
65
66 printf ("// Filler function\n");
67 printf ("static INT32 CtvDo_______() { return 0; }\n\n\n\n");
68
69 for (nCuMask=0; nCuMask<=2; nCuMask++)
70 {
71 for (nCuBpp=2; nCuBpp<=4; nCuBpp++)
72 {
73 int i=0;
74
75 if (nCuMask==1)
76 {
77 printf ("// Lookup table for %d bpp with Sprite Masking\n",nCuBpp);
78 printf ("static CtvDoFn CtvDo%dm[0x20]={\n",nCuBpp);
79 }
80 else if (nCuMask==2)
81 {
82 printf ("// Lookup table for %d bpp with BgHi\n",nCuBpp);
83 printf ("static CtvDoFn CtvDo%db[0x20]={\n",nCuBpp);
84 }
85 else
86 {
87 printf ("// Lookup table for %d bpp\n",nCuBpp);
88 printf ("static CtvDoFn CtvDo%d[0x20]={\n",nCuBpp);
89 }
90
91 for (i=0;i<0x20;i++)
92 {
93 int s;
94 printf ("CtvDo");
95
96 s=(i&24)+8;
97 if (s!=8 && s!=16 && s!=32) { printf ("_______"); goto End; }
98 if ((i&4) && (s!=16)) { printf ("_______"); goto End; }
99 if ((i&4) && nCuMask) { printf ("_______"); goto End; }
100 printf ("%d",nCuBpp);
101 printf ("%.2d",s);
102 if (i&4) printf ("r"); else printf ("_");
103 if (i&2) printf ("c"); else printf ("_");
104 if (i&1) printf ("f"); else printf ("_");
105 if (nCuMask==1) printf ("m");
106 else if (nCuMask==2) printf ("b");
107 else printf ("_");
108
109 End:
110 printf (",");
111 if (((i+1)&3)==0) printf("\n");
112 }
113 printf ("};\n");
114 }
115 }
116
117 printf ("\n\n");
118 printf ("// Current BPP:\n");
119 printf ("CtvDoFn CtvDoX[0x20];\n");
120 printf ("CtvDoFn CtvDoXM[0x20];\n");
121 printf ("CtvDoFn CtvDoXB[0x20];\n");
122 printf ("\n\n");
123
124 return 0;
125 }
126