fix drawalpha "properly"

This commit is contained in:
ThatGamerBlue
2020-03-22 15:15:39 +00:00
parent 57384e8537
commit 9f908191bf
2 changed files with 19 additions and 7 deletions

View File

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

View File

@@ -125,13 +125,16 @@ public class RasterizerAlpha extends AbstractInjector
StackContext alphaPop = isub.getPops().get(0); StackContext alphaPop = isub.getPops().get(0);
InstructionContext alphaPusher = alphaPop.getPushed(); InstructionContext alphaPusher = alphaPop.getPushed();
InstructionContext isubResult = isub.getPushes().get(0).getPopped().get(0); InstructionContext isubResult = isub.getPushes().get(0).getPopped().get(0);
boolean shouldSubtractLocal = false;
if (pushesToSameVar(isubResult, alphaPusher)) if (pushesToSameVar(isubResult, alphaPusher))
{ {
alphaPusher = resolveFieldThroughInvokes(alphaPop); shouldSubtractLocal = true;
alphaPusher = isubResult;
/*alphaPusher = resolveFieldThroughInvokes(alphaPop);
if (alphaPusher == null) 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); int storeIdx = instrs.getInstructions().indexOf(instruction);
@@ -139,13 +142,22 @@ public class RasterizerAlpha extends AbstractInjector
Instruction alphaPushI = alphaPusher.getInstruction(); Instruction alphaPushI = alphaPusher.getInstruction();
if (alphaPushI instanceof GetStatic) 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 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) else if (alphaPushI instanceof LVTInstruction)
{ {
if (shouldSubtractLocal)
{
instrs.addInstruction(storeIdx++, new LDC(instrs, 255));
instrs.addInstruction(storeIdx++, new ILoad(instrs, ((LVTInstruction) alphaPushI).getVariableIndex())); 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)); instrs.getInstructions().set(storeIdx, new InvokeStatic(instrs, DRAWALPHA));