static int dedup_write(const void *buf, uint32_t len, uint64_t offset) { const char *bufi = buf; uint32_t displacement = offset % BLOCK_SIZE; /* If we don't begin on a block boundary, handle that case separately. */ if (displacement != 0) { uint32_t write_size = MIN(len, BLOCK_SIZE - displacement); write_one_block(bufi, write_size, offset); bufi += write_size; len -= write_size; offset += write_size; } /* Now handle the full blocks. */ while (len > BLOCK_SIZE) { assert(offset % BLOCK_SIZE == 0); write_one_block(bufi, BLOCK_SIZE, offset); bufi += BLOCK_SIZE; len -= BLOCK_SIZE; offset += BLOCK_SIZE; } /* Finally, handle the case where we don't end on a block boundary. */ if (len != 0) write_one_block(bufi, len, offset); return 0; }
static unsigned long write_one_list(unsigned long *bl, unsigned long length, unsigned long offset) { unsigned long i; // 0x10: /8 for pointer /2 it has to be done in steps of 2 for (i = 0; i < length / 0x10; i++) { offset = write_one_block((unsigned long *) *bl, *(bl + 1), offset); bl += 2; } return offset; }
void write_tetri(t_map *map, t_dcell *tetri) { int i; char letter; letter = retrieve_letter(tetri->tetri); i = 0; while (tetri->point[i]) { write_one_block(map, tetri->point[i], tetri->offset, letter); ++i; } tetri->put = 1; tetri->pos->y = map->point->y; tetri->pos->x = map->point->x; }