From 9d93f30426921a8b48ef6a57cf92879d9cd2a67c Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Fri, 23 Dec 2022 00:02:02 -0800 Subject: [PATCH] Fix crate math. I forgot that -1 & 1 = 1 rather than 0 so all the bit math didn't work. But I can fix it with polynomial algebra! this is much better. --- chameleonic.p8 | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 498cf3f..a711592 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -502,11 +502,7 @@ function level:get_latch(dx,dy,px,py) local dx1,dy1=-sgn0(dx),-sgn0(dy) if crate then - if crate.def & ( - dy1 >>> 15 | - (dy1 & 0x1) << 2 | - (dx1 & 0x8000) >>> 12 | - (dx1 & 0x1) << 1) ~= 0 then + if crate.def & dy1*dy1*(2.5+1.5*dy1)+dx1*dx1*(5-3*dx1) ~= 0 then return { el="crate", dx=dx1,dy=dy1,