1: #include "old.h"
   2: 
   3: stdin()
   4: {
   5:     int piece1, piece2, side1, side2, rnk1, rnk2, file1, file2;
   6:     int ckf, c, m, *p1, *p2, to, amb, piece;
   7: 
   8:     piece1 = piece2 = side1 = side2 = -1;
   9:     rnk1 = rnk2 = file1 = file2  = -1;
  10:     ckf = 0;
  11:     if(match("o-o-o")||match("ooo")) {
  12:         piece1 = 6;
  13:         file1 = 3;
  14:         side1 = 1;
  15:         file2 = 2;
  16:         side2 = 0;
  17:         goto search;
  18:     }
  19:     if(match("o-o")||match("oo")) {
  20:         piece1 = 6;
  21:         file1 = 3;
  22:         file2 = 1;
  23:         goto search;
  24:     }
  25:     stdpin(&piece1, &side1, &rnk1, &file1);
  26:     c = *sbufp++;
  27:     if(c=='*' || c=='x')
  28:         stdpin(&piece2, &side2, &rnk2, &file2); else
  29:     if(c == '-')
  30:         stdbin(&side2, &rnk2, &file2); else
  31:         sbufp--;
  32: 
  33: search:
  34:     c = *sbufp++;
  35:     if(c == '+') {
  36:         ckf = 1;
  37:         c = *sbufp++;
  38:     }
  39:     if(c != '\0')
  40:         return(0);
  41: 
  42:     p1 = p2 = lmp;
  43:     mantom? bagen(): wagen();
  44:     m = -1;
  45:     amb = 0;
  46:     while(p1 != lmp) {
  47:         p1++;
  48:         piece = board[*p1>>8];
  49:         mantom? bmove(*p1): wmove(*p1);
  50:         to = amp[-3];
  51:         if(pcomp(piece, amp[-4],
  52:             piece1, side1, rnk1, file1))
  53:         if(pcomp(amp[-2], to,
  54:             piece2, side2, rnk2, file2))
  55:         if(comp(ckf, check())) {
  56:             if(m >= 0) {
  57:                 if(!amb) {
  58:                     printf("ambiguous\n");
  59:                     amb = 1;
  60:                 }
  61:             }
  62:             m = *p1;
  63:         }
  64:         p1++;
  65:         mantom? bremove(): wremove();
  66:     }
  67:     lmp = p2;
  68:     if(amb) return(-1);
  69:     return(m);
  70: }
  71: 
  72: stdpin(ap, as, ar, af)
  73: int *ap, *as, *ar, *af;
  74: {
  75:     int c;
  76: 
  77:     c = *sbufp++;
  78:     if(c == 'q') {
  79:         *as = 0;
  80:         stdpin(ap, as, ar, af);
  81:         return;
  82:     }
  83:     if(c == 'k') {
  84:         *as = 1;
  85:         stdpin(ap, as, ar, af);
  86:         return;
  87:     }
  88:     if(c == 'p') {
  89:         *ap = 1;
  90:         if(*as >= 0)
  91:             *af = 3;
  92:         goto loc;
  93:     }
  94:     if(c == 'n') {
  95:         *ap = 2;
  96:         goto pie;
  97:     }
  98:     if(c == 'b') {
  99:         *ap = 3;
 100:         goto pie;
 101:     }
 102:     if(c == 'r') {
 103:         *ap = 4;
 104:         goto pie;
 105:     }
 106:     sbufp--;
 107:     goto loc;
 108: 
 109: pie:
 110:     if(*sbufp == 'p') {
 111:         *af = (*ap-1)%3;
 112:         *ap = 1;
 113:         sbufp++;
 114:     }
 115: 
 116: loc:
 117:     if(*ap<0 && *as>=0) {
 118:         *ap = *as+5;
 119:         *as = -1;
 120:     }
 121:     if(*sbufp == '/') {
 122:         sbufp++;
 123:         stdbin(as, ar, af);
 124:     }
 125: }
 126: 
 127: stdbin(as, ar, af)
 128: int *as, *ar, *af;
 129: {
 130:     int c;
 131: 
 132: loop:
 133:     c = *sbufp++;
 134:     if(c == 'q') {
 135:         *as = 0;
 136:         goto kq;
 137:     }
 138:     if(c == 'k') {
 139:         *as = 1;
 140:     kq:
 141:         stdbin(as, ar, af);
 142:         if(*af < 0)
 143:             *af = 3;
 144:         return;
 145:     }
 146: 
 147:     if(c == 'r') {
 148:         *af = 0;
 149:         goto loop;
 150:     }
 151:     if(c == 'n') {
 152:         *af = 1;
 153:         goto loop;
 154:     }
 155:     if(c == 'b') {
 156:         *af = 2;
 157:         goto loop;
 158:     }
 159:     if(c>'0' && c<'9')
 160:         *ar = c-'1'; else
 161:         sbufp--;
 162: }
 163: 
 164: pcomp(p, l, pp, sp, rp, fp)
 165: int p, l, pp, sp, rp, fp;
 166: {
 167:     int r, f, s;
 168: 
 169:     f = l%8;
 170:     r = l/8;
 171:     if(!mantom)
 172:         r = 7-r;
 173:     if(f > 3) {
 174:         f = 7-f;
 175:         s = 1;
 176:     } else
 177:         s = 0;
 178: 
 179:     if(comp(pp, p))
 180:     if(comp(sp, s))
 181:     if(comp(rp, r))
 182:     if(comp(fp, f))
 183:         return(1);
 184:     return(0);
 185: }
 186: 
 187: comp(p, v)
 188: int p, v;
 189: {
 190: 
 191:     if(p < 0) return(1);
 192:     return(p == abs(v));
 193: }
 194: 
 195: abs(x)
 196: int x;
 197: {
 198: 
 199:     if(x < 0)
 200:         return(-x);
 201:     return(x);
 202: }

Defined functions

abs defined in line 195; used 4 times
comp defined in line 187; used 5 times
pcomp defined in line 164; used 2 times
stdbin defined in line 127; used 3 times
stdin defined in line 3; used 1 times
stdpin defined in line 72; used 4 times
Last modified: 1979-05-05
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2775
Valid CSS Valid XHTML 1.0 Strict