Merge pull request #4 from open-osrs/fix-alpha

gpu: fix drawalpha "properly"
This commit is contained in:
ThatGamerBlue
2020-03-24 18:46:14 +00:00
committed by GitHub
2 changed files with 19 additions and 7 deletions

View File

@@ -13,10 +13,10 @@ plugins {
`maven-publish`
}
val oprsver = "1.5.44-SNAPSHOT"
val oprsver = "3.1.0"
group = "com.openosrs"
version = "1.0.3.1"
version = "1.0.3.2"
repositories {
mavenCentral()

View File

@@ -125,13 +125,16 @@ public class RasterizerAlpha extends AbstractInjector
StackContext alphaPop = isub.getPops().get(0);
InstructionContext alphaPusher = alphaPop.getPushed();
InstructionContext isubResult = isub.getPushes().get(0).getPopped().get(0);
boolean shouldSubtractLocal = false;
if (pushesToSameVar(isubResult, alphaPusher))
{
alphaPusher = resolveFieldThroughInvokes(alphaPop);
shouldSubtractLocal = true;
alphaPusher = isubResult;
/*alphaPusher = resolveFieldThroughInvokes(alphaPop);
if (alphaPusher == null)
throw new RuntimeException("Alpha var is overwritten and we don't know what pushed it"); // cheeky unchecked
throw new RuntimeException("Alpha var is overwritten and we don't know what pushed it"); // cheeky unchecked*/
}
int storeIdx = instrs.getInstructions().indexOf(instruction);
@@ -139,13 +142,22 @@ public class RasterizerAlpha extends AbstractInjector
Instruction alphaPushI = alphaPusher.getInstruction();
if (alphaPushI instanceof GetStatic)
{
//instrs.addInstruction(storeIdx++, new LDC(instrs, 255));
instrs.addInstruction(storeIdx++, new LDC(instrs, 255));
instrs.addInstruction(storeIdx++, new GetStatic(instrs, ((GetStatic) alphaPushI).getField()));
//instrs.addInstruction(storeIdx++, new ISub(instrs, InstructionType.ISUB));
instrs.addInstruction(storeIdx++, new ISub(instrs, InstructionType.ISUB));
}
else if (alphaPushI instanceof LVTInstruction)
{
instrs.addInstruction(storeIdx++, new ILoad(instrs, ((LVTInstruction) alphaPushI).getVariableIndex()));
if (shouldSubtractLocal)
{
instrs.addInstruction(storeIdx++, new LDC(instrs, 255));
instrs.addInstruction(storeIdx++, new ILoad(instrs, ((LVTInstruction) alphaPushI).getVariableIndex()));
instrs.addInstruction(storeIdx++, new ISub(instrs, InstructionType.ISUB));
}
else
{
instrs.addInstruction(storeIdx++, new ILoad(instrs, ((LVTInstruction) alphaPushI).getVariableIndex()));
}
}
instrs.getInstructions().set(storeIdx, new InvokeStatic(instrs, DRAWALPHA));