📄 lockscreen_default.c
字号:
for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) free((char *)(LINT_CAST(pt))); free((char *)(LINT_CAST(rw))); } row = NULL;}staticrefreshboard(){ struct row *rw; struct point *pt; int i,j; for(i = 0; i < rightedge; i++) for(j = 0; j < bottomedge; j++) (*board)[i][j] = 0; for (rw = row; rw != NULL; rw = rw->r_nxt) { for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) { i = rw->r_x; j = pt->p_y; if (i >= 0 && i < rightedge && j >= 0 && j < bottomedge) (*board)[i][j] = pt->p_color; } }}/* * called from lifetool */staticnewgen(){ struct row *oldrw, *rw; struct point *pt, *oldpt; int i,j; for (rw = row, oldrw = rw; rw != NULL; oldrw = rw, rw = rw->r_nxt) { for (pt = rw->r_point, oldpt = pt; pt != NULL; oldpt = pt, pt = pt->p_nxt) pt->p_delete = nbors(oldrw, rw, oldpt, pt); } newstuff(); lock(); for (rw = row; rw != NULL; rw = rw->r_nxt) { for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt){ if (pt->p_delete >=4 || pt->p_delete <=1) { /* * should delete pt directly */ i = rw->r_x; j = pt->p_y; deletepoint(i,j); if (i >= 0 && i < rightedge && j >= 0 && j < bottomedge && (*board)[i][j]) { erase_stone(i, j); (*board)[i][j] = 0; } } } } if (colormonitor) { for (rw = row; rw != NULL; rw = rw->r_nxt) for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) if (pt->p_color < CMSIZE-2) pt->p_color++; } while(stack > 0){ stack--; i = addx[stack]; j = addy[stack]; addpoint(i, j); if (i >= 0 && i < rightedge && j >= 0 && j < bottomedge && (*board)[i][j] == 0) { paint_stone(i, j, INITCOLOR); (*board)[i][j] = 1; } } if (colormonitor) { for (rw = row; rw != NULL; rw = rw->r_nxt) { for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) { i = rw->r_x; j = pt->p_y; if (i >= 0 && i < rightedge && j >= 0 && j<bottomedge && pt->p_color > INITCOLOR) paint_stone(i, j, (int)pt->p_color); } } } unlock();}staticnbors(oldrw, rw, oldpt, pt) struct row *rw, *oldrw; struct point *pt, *oldpt;{ struct point *tmppt; int x, y; int cnt = 0; x = rw->r_x; y = pt->p_y; if (oldpt != pt && oldpt->p_y == y-1) cnt++; if (pt->p_nxt != NULL && pt->p_nxt->p_y == y+1) cnt++; if (rw != oldrw && oldrw->r_x == x-1) { for(tmppt = oldrw->r_point; tmppt != NULL; tmppt = tmppt->p_nxt) { if (tmppt->p_y == y-1) cnt++; if (tmppt->p_y == y) cnt++; if (tmppt->p_y == y+1) { cnt++; break; } if (tmppt->p_y >= y+1) break; } } if (rw->r_nxt != NULL && rw->r_nxt->r_x == x+1) { for(tmppt = rw->r_nxt->r_point; tmppt != NULL; tmppt = tmppt->p_nxt) { if (tmppt->p_y == y-1) cnt++; if (tmppt->p_y == y) cnt++; if (tmppt->p_y == y+1) { cnt++; break; } if (tmppt->p_y >= y+1) break; } } return cnt;}static struct xy *candidates;#define addxy(X,Y) \ xx = (X) % HASHSIZE; \ yy = (Y) % HASHSIZE; \ p = (*hash)[xx][yy]; \ for (;;) { \ if (p == NULL) { \ p = (struct xy *)newmalloc(); \ p->x = (X); \ p->y = (Y); \ p->cnt = 1; \ p->nxt = (*hash)[xx][yy]; \ (*hash)[xx][yy] = p; \ break; \ } \ if (p->x == (X) && p->y == (Y)) { \ p->cnt++; \ if (p->cnt == 3) { \ p->chain = candidates; \ candidates = p; \ } \ break; \ } \ p = p->nxt; \ }staticnewstuff(){ register struct row *rw; register struct point *pt; register struct xy *p; register unsigned int x, y; register unsigned int xx,yy; static int firsttime = 1; if (firsttime) { firsttime = 0; initchain(); } candidates = NULL; bzero((char *)(LINT_CAST(hash)), HASHSIZE * HASHSIZE * sizeof(struct xy *)); for (rw = row; rw != NULL; rw = rw->r_nxt) { x = rw->r_x; for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) { y = pt->p_y; addxy(x-1, y-1); addxy(x-1, y); addxy(x-1, y+1); addxy(x, y-1); addxy(x, y+1); addxy(x+1, y-1); addxy(x+1, y); addxy(x+1, y+1); } } findbirths();}staticfindbirths(){ register struct xy *p; for (p = candidates; p != NULL; p = p->chain) { if (p->cnt == 3) addtostack(p->x, p->y); } restorespace();}staticaddtostack(i, j){ addx[stack] = i; addy[stack++] = j; if (stack >= STACK) { (void)fprintf(stderr, "overflowed stack\n"); exit(1); }}static struct chain { struct xy ch_xy; struct chain *ch_nxt;} *chain, *headchain, *endchain;staticinitchain(){ headchain = (struct chain *)(LINT_CAST(malloc(sizeof(struct chain)))); headchain->ch_nxt = NULL; endchain = headchain; chain = headchain;}staticrestorespace(){ chain = headchain;}staticnewmalloc(){ struct chain *ch; chain = chain->ch_nxt; if (chain == NULL) { ch = (struct chain *)(LINT_CAST(malloc(sizeof(struct chain)))); ch->ch_nxt = NULL; endchain->ch_nxt = ch; endchain = ch; chain = ch; } return (int)(chain);}staticchecksum(){ register struct row *rw; register struct point *pt; register int sum; sum = 0; for (rw = row; rw != NULL; rw = rw->r_nxt) { sum = 7*sum + rw->r_x; for (pt = rw->r_point; pt != NULL; pt = pt->p_nxt) sum = 7*sum + pt->p_y; } return (sum);}static int cnt;staticdrawpattern(num){ init(); switch(num) { case EIGHT: paint(6,6); paint(6,7); paint(6,8); paint(7,6); paint(7,7); paint(7,8); paint(8,6); paint(8,7); paint(8,8); paint(9,9); paint(9,10); paint(9,11); paint(10,9); paint(10,10); paint(10,11); paint(11,9); paint(11,10); paint(11,11); break; case PULSAR: paint(10,10); paint(11,10); paint(12,10); paint(13,10); paint(14,10); paint(10,11); paint(14,11); break; case BARBER: paint(2,2); paint(2,3); paint(3,2); paint(4,3); paint(4,5); paint(6,5); paint(6,7); paint(8,7); paint(8,9); paint(10,9); paint(10,11); paint(12,11); paint(12,13); paint(13,14); paint(14,13); paint(14,14); break; case HERTZ: paint(2,6); paint(2,7); paint(2,9); paint(2,10); paint(3,6); paint(3,10); paint(4,7); paint(4,8); paint(4,9); paint(6,7); paint(6,8); paint(6,9); paint(7,3); paint(7,4); paint(7,6); paint(7,8); paint(7,10); paint(7,12); paint(7,13); paint(8,3); paint(8,4); paint(8,6); paint(8,10); paint(8,12); paint(8,13); paint(9,6); paint(9,10); paint(10,6); paint(10,10); paint(11,7); paint(11,8); paint(11,9); paint(13,7); paint(13,8); paint(13,9); paint(14,6); paint(14,10); paint(15,6); paint(15,7); paint(15,9); paint(15,10); break; case TUMBLER: paint(2,6); paint(2,7); paint(2,8); paint(3,3); paint(3,4); paint(3,8); paint(4,3); paint(4,4); paint(4,5); paint(4,6); paint(4,7); paint(6,3); paint(6,4); paint(6,5); paint(6,6); paint(6,7); paint(7,3); paint(7,4); paint(7,8); paint(8,6); paint(8,7); paint(8,8); break; case PERIOD4: paint(1,3); paint(2,2); paint(2,4); paint(4,1); paint(4,2); paint(4,6); paint(5,1); paint(5,7); paint(6,4); paint(6,6); paint(7,3); paint(7,4); break; case PERIOD5: paint(1,4); paint(1,5); paint(2,3); paint(2,6); paint(3,2); paint(3,7); paint(4,1); paint(4,8); paint(5,1); paint(5,8); paint(6,2); paint(6,7); paint(7,3); paint(7,6); paint(8,4); paint(8,5); break; case PERIOD6: paint(1,2); paint(1,3); paint(2,2); paint(2,3); paint(4,2); paint(5,1); paint(5,3); paint(6,1); paint(6,4); paint(6,7); paint(6,8); paint(7,5); paint(7,7); paint(7,8); paint(8,3); paint(8,4); break; case PINWHEEL: paint(1,7); paint(1,8); paint(2,7); paint(2,8); paint(4,5); paint(4,6); paint(4,7); paint(4,8); paint(5,1); paint(5,2); paint(5,4); paint(5,9); paint(6,1); paint(6,2); paint(6,4); paint(6,5); paint(6,9); paint(7,4); paint(7,7); paint(7,9); paint(7,11); paint(7,12); paint(8,4); paint(8,6); paint(8,9); paint(8,11); paint(8,12); paint(9,5); paint(9,6); paint(9,7); paint(9,8); paint(11,5); paint(11,6); paint(12,5); paint(12,6); break; default: return; } doit();}static left;static right;static top;static bottom;staticpaint(x,y){ if (x < left) left = x; if (x > right) right = x; if (y < top) top = y; if (y > bottom) bottom = y; xarr[cnt] = x; yarr[cnt++] = y;}staticrealpaint(l, r){ int i, x, y; for (i = 0; i < cnt; i++) { x = xarr[i] + l; y = yarr[i] + r; addpoint(x, y); if (x > rightedge-1 || y > bottomedge-1) return; paint_stone(x, y, INITCOLOR); }}staticinit(){ left = MAXINT; right = MININT; top = MAXINT; bottom = MININT; cnt = 0;}staticdoit(){ realpaint(-left + (rightedge - (right - left))/2, (-top + (bottomedge - (bottom - top))/2));}static voidalloc_memory(){ board = (char (*)[MAXPIXELS / SPACING][MAXPIXELS / SPACING]) malloc(sizeof(*board)); if ((int) board == 0) goto malloc_failed; addx = (int *) (LINT_CAST(malloc(STACK * sizeof(int)))); if (addx == (int *) 0) goto malloc_failed; addy = (int *) (LINT_CAST(malloc(STACK * sizeof(int)))); if (addy == (int *) 0) goto malloc_failed; hash = (struct xy *(*)[HASHSIZE][HASHSIZE]) (LINT_CAST(malloc(sizeof(*hash)))); if ((int) hash == 0) goto malloc_failed; xarr = (int *) (LINT_CAST(malloc(200))); if (xarr == (int *) 0) goto malloc_failed; yarr = (int *) (LINT_CAST(malloc(200))); if (yarr == (int *) 0) goto malloc_failed; return; /* Success */malloc_failed: (void)fprintf(stderr, "malloc failed (out of swap space?)\n"); exit(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -