Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiTexture support #26

Open
0x1F9F1 opened this issue Jul 25, 2020 · 0 comments
Open

Fix MultiTexture support #26

0x1F9F1 opened this issue Jul 25, 2020 · 0 comments

Comments

@0x1F9F1
Copy link
Owner

0x1F9F1 commented Jul 25, 2020

Although AGI appears to support multi-texturing, support has been removed in a few places:
NoMultiTexture is always set to 1.
agiCurState.MaxTextures is always set to 1.

agiD3DPipeline::BeginGfx:

// test1560.exe

NoMultiTexture = 1;
if (hwcaps.dwDevCaps & 0x4000) {
    agiDisplayf("Separate texture memories (probably a voodoo!)");
    NoMultiTexture = 1;
}
agiCurState.State.MaxTextures = 1;
SeparateTextureMemories = 0;

// am.exe

NoMultiTexture = 1;
if (hwcaps.dwDevCaps & 0x4000) {
    agiDisplayf("Separate texture memories (probably a voodoo!)");
    SeparateTextureMemories = 1;
    NoMultiTexture = 1;
}
if (NoMultiTexture)
    agiRendState::SetMaxTextures(&agiCurState, 1);
else
    agiRendState::SetMaxTextures(&agiCurState, hwcaps.wMaxSimultaneousTextures);
if (agiRendState::GetMaxTextures((char*)&agiCurState) <= 1) {
    SeparateTextureMemories = 0;
} else {
    agiDisplayf("Multitexturing is supported!");
    v41 = v49->D3DDevice->lpVtbl->SetTextureStageState(v49->D3DDevice, 1, D3DTSS_TEXCOORDINDEX, 1);
    __DDTry(
        v41,
        (int)"D3DDevice->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,1)",
        (int)"C:\\mm\\src\\agid3d\\d3dpipe.c",
        583);
}

agiD3DTexDef::BeginGfx:

// am.exe

multi_texture = 0;

// ...
if (multi_texture
    && agiRendState::GetMaxTextures(&agiCurState) > 1
    && !strncmp(this->Params.Name, "SHADMAP", 7u)) {
    Displayf("Fixing shadow map '%s' for multitexturing...", this->Params.Name);
    surface = (uint16_t*)this->Surface->lpSurface;
    surface_bytes = 0;
    v19 = this->Surface->dwWidth;
    for (i = this->Surface->dwHeight; v19 && i; i >>= 1) {
        surface_bytes += i * v19;
        v19 >>= 1;
    }
    while (surface_bytes--) {
        *surface = ~(((signed int)*surface >> 12) | ((signed int)*surface >> 8) | ((signed int)*surface >> 4));
        ++surface;
    }
}
// ...
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

No branches or pull requests

1 participant