From fe3a68284fe74fe127a34e13e95c4b1ce2c9cd2a Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Thu, 22 Dec 2022 22:49:27 -0800 Subject: [PATCH] replace comparisons with bit math bullshit integers in the range [0, 15] fit entirely in the bit mask 0x000F. integers out of that range will have at least one bit 0x0010 or higher, or will have the sign bit 0x8000 set. so to find out if one of two numbers is out of range [0, 15], we can check the bit mask of their bitwise or. this saves tokens and cycles. it is also completely illegible. very in the spirit of Pico-8, I love it. --- chameleonic.p8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chameleonic.p8 b/chameleonic.p8 index 812c428..0d28ada 100644 --- a/chameleonic.p8 +++ b/chameleonic.p8 @@ -438,7 +438,7 @@ function level:spawn_exit() if (self:_mget(x,y)!=18) return for nx=x-1,x+1 do for ny=y-1,y+1 do - if nx<0 or ny<0 or nx>15 or ny>15 then + if (nx | ny) & 0xFFF0 ~= 0 then self._wins[_mix(nx,ny)]=true end end