MightyPirates / TIS-3D

TIS-100 inspired low-tech computing in Minecraft.
https://www.curseforge.com/minecraft/mc-mods/tis-3d
Other
108 stars 35 forks source link

Illegal color values are not handled gracefully #30

Closed SanityCh3ck closed 8 years ago

SanityCh3ck commented 8 years ago

... and I have the crash report to prove it: http://pastebin.com/Db3qHkCf The following code, given an appropriately placed display module, will crash like that.

MOV 255 UP
MOV 2 UP
MOV 2 UP
MOV 8 UP
MOV 8 UP

I think the problem is

  1. masking the value with 0xFF here and casting it can produce negative byte values. Wouldn't just casting and letting it overflow do the same?
  2. the % operator used here actually being the remainder, not the modulus. This will produce negative results for negative inputs.

I'm using v0.5.0.37 for MC 1.7.10

fnuecke commented 8 years ago

Ah, yeah, that whole part's a bit... weird. I'll rework that, thanks for letting me know!