Skip to content

Conversation

@MegaMech
Copy link
Contributor

@MegaMech MegaMech commented Dec 29, 2025

Requires Kenix3/libultraship#969

This version uses floats

void scroll_texture_interpolated_save(Gfx* writableDList, const char* gfxAsset, s32 stepX, s32 stepY) {
    int8_t opcode = 0;
    if ((NULL == writableDList) || (NULL == gfxAsset)) {
        return;
    }

    Gfx* gfx = (Gfx*) gfxAsset;
    if (GameEngine_OTRSigCheck(gfx)) {
        gfx = (Gfx*) ResourceGetDataByName(gfx);
    }

    while ((opcode = GFX_GET_OPCODE(gfx->words.w0) >> 24) != G_ENDDL) {
        if (opcode == (int8_t)G_SETTILESIZE) {
            // Get values from the old tile size command
            int32_t tile = _SHIFTR(gfx->words.w1, 24, 12);
            float uls  = _SHIFTR(gfx->words.w0, 12, 12);
            float ult  = _SHIFTR(gfx->words.w0, 0,  12);
            float lrs  = _SHIFTR(gfx->words.w1, 12, 12);
            float lrt  = _SHIFTR(gfx->words.w1, 0,  12);
            
            // Write over old command to point to the new writeableDList
            __gSPDisplayList(gfx, &writableDList[0]);

            // Write DL data into writableDList. gDPScrollTexture takes up two Gfx
            gDPScrollTextureF(&writableDList[0], tile, *(uint32_t*)&uls, *(uint32_t*)&ult, *(uint32_t*)&lrs, *(uint32_t*)&lrt, stepX, stepY);
            gSPEndDisplayList(&writableDList[2]);
            break;
        }
        gfx++;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant