void blitRow()

in libs/screen/image.cpp [1037:1072]


void blitRow(Image_ img, int x, int y, Image_ from, int fromX, int fromH) {
    if (!img->inRange(x, 0) || !img->inRange(fromX, 0) || fromH <= 0)
        return;

    if (img->bpp() != 4 || from->bpp() != 4)
        return;

    int fy = 0;
    int stepFY = (from->width() << 16) / fromH;
    int endY = y + fromH;
    if (endY > img->height())
        endY = img->height();
    if (y < 0) {
        fy += -y * stepFY;
        y = 0;
    }

    auto dp = img->pix(x, y);
    auto sp = from->pix(fromX, 0);

    while (y < endY) {
        int p = fy >> 16, c;
        if (p & 1)
            c = sp[p >> 1] >> 4;
        else
            c = sp[p >> 1] & 0xf;
        if (y & 1) {
            *dp = (*dp & 0x0f) | (c << 4);
            dp++;
        } else {
            *dp = (*dp & 0xf0) | (c & 0xf);
        }
        y++;
        fy += stepFY;
    }
}