Annotation of uae/genblitter.c, revision 1.1.1.1

1.1       root        1:  /* 
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   * 
                      4:   * Optimized blitter minterm function generator
                      5:   * 
                      6:   * (c) 1995 Bernd Schmidt
                      7:   */
                      8: 
                      9: #include <stdio.h>
                     10: #include <string.h>
                     11: 
                     12: #include "config.h"
                     13: #include "amiga.h"
                     14: 
                     15: static bool bitset(int mt, int bit)
                     16: {
                     17:     return mt & (1<<bit);
                     18: }
                     19: 
                     20: int main(void)
                     21: {
                     22:     int minterm;
                     23:     printf("static __inline__ UWORD blit_func(UWORD srca, UWORD srcb, UWORD srcc, UBYTE mt)\n{\nswitch(mt){\n");
                     24:     for (minterm = 0; minterm < 256; minterm++) {
                     25:        bool firstor = true;
                     26:        int bits = 0;
                     27:        int i;
                     28:        printf("case 0x%x:\n", minterm);
                     29:        printf("\treturn ");
                     30:        for(i=0; i<8; i++) {
                     31:            if (bitset(minterm, i) && !bitset(bits,i)) {
                     32:                int j;
                     33:                int dontcare = 0;
                     34:                bool firstand = true;
                     35:                int bitbucket[8], bitcount;
                     36:                
                     37:                bits |= 1<<i;
                     38:                bitcount = 1; bitbucket[0] = i;
                     39:                for(j=1; j<8; j *= 2) {
                     40:                    bool success = true;
                     41:                    int k;
                     42:                    for(k=0; k < bitcount; k++) {                       
                     43:                        if (!bitset(minterm, bitbucket[k] ^ j)) {
                     44:                            success = false;
                     45:                        }
                     46:                    }
                     47:                    if (success) {
                     48:                        int l;
                     49:                        dontcare |= j;
                     50:                        for(l=bitcount; l < bitcount*2; l++) {
                     51:                            bitbucket[l] = bitbucket[l-bitcount] ^ j;
                     52:                            bits |= 1 << bitbucket[l];
                     53:                        }
                     54:                        bitcount *= 2;
                     55:                    }
                     56:                }
                     57:                if (firstor) {
                     58:                    firstor = false;
                     59:                } else {
                     60:                    printf(" | ");
                     61:                }
                     62:                for (j=1; j<8; j *= 2) {
                     63:                    if (!(dontcare & j)) {
                     64:                        if (firstand) {
                     65:                            firstand = false;
                     66:                            printf("(");
                     67:                        } else {
                     68:                            printf(" & ");
                     69:                        }
                     70:                        if (!(i & j))
                     71:                            printf("~");
                     72:                        printf("src%c", (j == 1 ? 'c' : j == 2 ? 'b' : 'a'));
                     73:                    }
                     74:                }
                     75:                if (!firstand) {                    
                     76:                    printf(")");
                     77:                } else {
                     78:                    printf("0xFFFF");
                     79:                }
                     80:            }
                     81:        }
                     82:        if (firstor)
                     83:            printf("0");
                     84:        printf(";\n");
                     85:     }
                     86:     printf("}\n");
                     87:     printf("return 0;\n"); /* No, sir, it doesn't! */
                     88:     printf("}\n");
                     89:     return 0;
                     90: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.