static Error memsee1(int blocktype, Pointer start, ulong size, Pointer p) { if (size >= ((struct dispinfo *)p)->smallsize) return OK; pix_set((struct dispinfo *)p, start, size, color_smallalloc); return OK; }
void live(tLcdLine *life) { unsigned char us, count; signed char y,x; memset(tmp, 0, sizeof(tmp)); for(y = 0; y < HEIGHT; ++y) { //printf("%s\n", byte_to_binary(1 << i++)); for(x = 0; x < WIDTH; ++x) { us = pix_get(life, x, y); count = pix_get(life, x + -1, y + -1) + pix_get(life, x + -1, y + 0) + pix_get(life, x + -1, y + 1) + pix_get(life, x + 0, y + -1) + pix_get(life, x + 0, y + 1) + pix_get(life, x + 1, y + 1) + pix_get(life, x + 1, y + 0) + pix_get(life, x + 1, y + -1); //printf("%i,%i,%i\n",(int)x,(int)y,(int)count); if(us) { if( (count == 2) || !!(count== 3)) { pix_set(tmp,x,y); } } else { if(count == 3) { pix_set(tmp,x,y); } } } } for(y = 0; y < HEIGHT; ++y) { memcpy(life[y].Data, tmp[y].Data, sizeof(tmp[y].Data)); } }
/* the main routine which arranges for the memory manager to call us back * for each allocated block, and then asks the x server to display our * updated image. */ static Error report_memory (struct dispinfo *d) { int wsquares; /* count of window squares */ int mblocks; /* count of memory blocks */ /* mark all of memory free */ memset (d->memory_pixel, color_free, WinSize(d)); /* arrange for the memory manager to call us back with each allocated * block. the memsee() routines set the pixels as allocated. */ if (d->which == MEMORY_LOCAL) { DXDebugLocalAlloc(d->nproc, MEMORY_ALLOCATED, memsee, (Pointer)d); } else { DXDebugAlloc(d->which, MEMORY_ALLOCATED, memsee, (Pointer)d); if (d->smallsize > 0) DXDebugAlloc(d->which, MEMORY_ALLOCATED, memsee1, (Pointer)d); } /* and finally, see if there are any squares at the end of the window * which are beyond the end of the arena and are only there because * the window is square and the number of rows had to be rounded up. */ wsquares = WinSize(d) / PixelSize(d); mblocks = DivideRoundedUp(d->arena_size, d->bytes_vp); if (wsquares > mblocks) pix_set(d, (Pointer)((ubyte *)d->arena_base + d->arena_size), (wsquares - mblocks) * d->bytes_vp, color_extra); /* finished image. make it available to be displayed. */ XPutImage (d->disp, d->wind, d->gc, d->memory_image, 0, 0, 0, 0, d->win_width, d->win_height); XFlush(d->disp); return OK; }
/* turn on pixels corresponding to this memory range */ static Error memsee(int blocktype, Pointer start, ulong size, Pointer p) { pix_set((struct dispinfo *)p, start, size, color_alloc); return OK; }