|
|
1.1 ! root 1: #include "style.h" ! 2: #include "pacman.h" ! 3: ! 4: /* PIECES COMMENTED OUT TO SAVE SPACE */ ! 5: #ifdef BLIT ! 6: ! 7: Code textmode; ! 8: Point curloc; ! 9: ! 10: showchar(c) ! 11: char c; ! 12: { ! 13: static char str[] = "x"; ! 14: ! 15: str[0] = c; ! 16: curloc = string(&defont,str,&display,curloc,textmode); ! 17: } ! 18: ! 19: movexy(x,y) ! 20: int x,y; ! 21: { ! 22: curloc.x = x*9+8; ! 23: curloc.y = y*16+12; ! 24: } ! 25: #endif ! 26: ! 27: /*VARARGS1*/ ! 28: printf(fmt, x1) ! 29: char *fmt; ! 30: unsigned x1; ! 31: { ! 32: extern int showchar(); ! 33: ! 34: prf(fmt, &x1, showchar); ! 35: } ! 36: ! 37: ! 38: /* ! 39: * Scaled down version of C Library printf. ! 40: */ ! 41: ! 42: prf(fmt, adx, pfunc) ! 43: register char *fmt; ! 44: register int *adx; ! 45: int (*pfunc)(); ! 46: { ! 47: register int b, c, i, len; ! 48: char *s; ! 49: int zfill; ! 50: int any; ! 51: ! 52: loop: ! 53: while ((c = *fmt++) != '%') { ! 54: if(c == '\0') ! 55: return; ! 56: (*pfunc)(c); ! 57: } ! 58: len = 0; ! 59: zfill = 0; ! 60: ! 61: again: ! 62: c = *fmt++; ! 63: ! 64: switch (c) { ! 65: ! 66: /* ! 67: case 'x': case 'X': ! 68: b = 16; ! 69: goto number; ! 70: case 'o': case 'O': ! 71: b = 8; ! 72: goto number; ! 73: case 'D': ! 74: case 'u': ! 75: */ ! 76: case 'd': ! 77: b = 10; ! 78: number: ! 79: printn((long)*adx, b, len, zfill, pfunc); ! 80: break; ! 81: case 'l': ! 82: b = 10; ! 83: printn(*((long *)(adx++)), b, len, zfill, pfunc); ! 84: break; ! 85: /* ! 86: case 'c': ! 87: b = *adx; ! 88: for (i = 24; i >= 0; i -= 8) ! 89: if (c = (b >> i) & 0x7f) ! 90: (*pfunc)(c); ! 91: break; ! 92: case 'b': ! 93: b = *adx++; ! 94: s = (char *)*adx; ! 95: printn((long)b, *s++,0,0, pfunc); ! 96: any = 0; ! 97: if (b) { ! 98: (*pfunc)('<'); ! 99: while (i = *s++) { ! 100: if (b & (1 << (i-1))) { ! 101: if (any) ! 102: (*pfunc)(','); ! 103: any = 1; ! 104: for (; (c = *s) > 32; s++) ! 105: (*pfunc)(c); ! 106: } else ! 107: for (; *s > 32; s++) ! 108: ; ! 109: } ! 110: if (any) ! 111: (*pfunc)('>'); ! 112: } ! 113: break; ! 114: */ ! 115: case 's': ! 116: s = (char *)*adx; ! 117: while (c = *s++) ! 118: (*pfunc)(c); ! 119: break; ! 120: ! 121: case '0': ! 122: if ( len==0 ) zfill = 1; ! 123: case '1': case '2': case '3': case '4': ! 124: case '5': case '6': case '7': case '8': case '9': ! 125: len = len*10 + (c-'0'); ! 126: goto again; ! 127: ! 128: ! 129: ! 130: ! 131: case '%': ! 132: (*pfunc)('%'); ! 133: break; ! 134: } ! 135: adx++; ! 136: goto loop; ! 137: } ! 138: ! 139: /* ! 140: * Printn prints a number n in base b. ! 141: * We don't use recursion to avoid deep kernel stacks. ! 142: */ ! 143: printn(n, b, len, zfill, pfunc) ! 144: register long n; ! 145: register int len; ! 146: int (*pfunc)(); ! 147: { ! 148: char prbuf[11]; ! 149: register char *cp; ! 150: ! 151: if (b == 10 && n < 0) { ! 152: (*pfunc)('-'); ! 153: n = (unsigned)(-n); ! 154: } ! 155: cp = prbuf; ! 156: do { ! 157: *cp++ = "0123456789abcdef"[n%b]; ! 158: n /= b; ! 159: } while (n); ! 160: while ( len-- > cp-prbuf ) ! 161: if ( zfill ) ! 162: (*pfunc)('0'); ! 163: else ! 164: (*pfunc)(' '); ! 165: ! 166: do ! 167: (*pfunc)(*--cp); ! 168: while (cp > prbuf); ! 169: } ! 170: ! 171:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.