//Identical to function @ 0x00498E00
CImage* CSprite::createOverlay(u32 imageId, s8 x, s8 y, u32 direction) {
  assert(this);
  CImage *overlay = unusedImages.popHead();
  
  if (overlay) {
    const CListExtern<CImage, &CImage::link> images(this->imageHead, this->imageTail);
    if (this->imageHead) {
      images.insertBefore(overlay, this->mainGraphic);
    }
    else {
      this->mainGraphic = overlay;
      images.insertAfterHead(overlay);
    }

    overlay->initializeData(this, imageId, x, y);
    createUpdateImageSomething(overlay);
    updateImageDirection(overlay, direction);
  }
  return overlay;
}
void CSprite::setPosition(u16 x, u16 y) {
	assert(this);
	if (this->position.x == x && this->position.y == y) return;

	const int oldTileY = CLAMP(this->position.y / 32, 0, mapTileSize->height - 1);
	const int newTileY = CLAMP(y / 32, 0, mapTileSize->height - 1);

	this->position.x = x;
	this->position.y = y;

	if (oldTileY != newTileY) {
		const CListExtern<CSprite, &CSprite::link>
			spritesOnOldTileRow(spritesOnTileRow->heads[oldTileY],
				spritesOnTileRow->tails[oldTileY]),
			spritesOnNewTileRow(spritesOnTileRow->heads[newTileY],
				spritesOnTileRow->tails[newTileY]);

		spritesOnOldTileRow.unlink(this);
		spritesOnNewTileRow.insertAfterHead(this);
	}

	for (CImage *i = this->images.head; i; i = i->link.next)
		i->flags |= 1;
}