|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include "pic.h" ! 3: #include "y.tab.h" ! 4: ! 5: struct obj *movegen(type) ! 6: { ! 7: static int prevdx, prevdy; ! 8: int i, dx, dy, some; ! 9: int defx, defy; ! 10: struct obj *p; ! 11: struct obj *ppos; ! 12: static int xtab[] = { 1, 0, -1, 0 }; /* R=0, U=1, L=2, D=3 */ ! 13: static int ytab[] = { 0, 1, 0, -1 }; ! 14: ! 15: defx = getvar("movewid"); ! 16: defy = getvar("moveht"); ! 17: dx = dy = some = 0; ! 18: for (i = 0; i < nattr; i++) { ! 19: switch (attr[i].a_type) { ! 20: case LJUST: case RJUST: case CENTER: case SPREAD: case FILL: case ABOVE: case BELOW: ! 21: savetext(attr[i].a_type, attr[i].a_val); ! 22: break; ! 23: case SAME: ! 24: dx = prevdx; ! 25: dy = prevdy; ! 26: some++; ! 27: break; ! 28: case LEFT: ! 29: dx -= (attr[i].a_val==0) ? defx : attr[i].a_val; ! 30: some++; ! 31: hvmode = L_DIR; ! 32: break; ! 33: case RIGHT: ! 34: dx += (attr[i].a_val==0) ? defx : attr[i].a_val; ! 35: some++; ! 36: hvmode = R_DIR; ! 37: break; ! 38: case UP: ! 39: dy += (attr[i].a_val==0) ? defy : attr[i].a_val; ! 40: some++; ! 41: hvmode = U_DIR; ! 42: break; ! 43: case DOWN: ! 44: dy -= (attr[i].a_val==0) ? defy : attr[i].a_val; ! 45: some++; ! 46: hvmode = D_DIR; ! 47: break; ! 48: case TO: ! 49: ppos = (struct obj *) attr[i].a_val; ! 50: dx = ppos->o_x - curx; ! 51: dy = ppos->o_y - cury; ! 52: some++; ! 53: break; ! 54: case BY: ! 55: ppos = (struct obj *) attr[i].a_val; ! 56: dx = ppos->o_x; ! 57: dy = ppos->o_y; ! 58: some++; ! 59: break; ! 60: case FROM: ! 61: case AT: ! 62: ppos = (struct obj *) attr[i].a_val; ! 63: curx = ppos->o_x; ! 64: cury = ppos->o_y; ! 65: break; ! 66: } ! 67: } ! 68: if (some) { ! 69: defx = dx; ! 70: defy = dy; ! 71: } else { ! 72: defx *= xtab[hvmode]; ! 73: defy *= ytab[hvmode]; ! 74: } ! 75: prevdx = defx; ! 76: prevdy = defy; ! 77: extreme(curx, cury); ! 78: curx += defx; ! 79: cury += defy; ! 80: extreme(curx, cury); ! 81: p = makenode(MOVE, 0); ! 82: dprintf("M %d %d\n", curx, cury); ! 83: return(p); ! 84: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.