Compare commits

..

3 Commits

Author SHA1 Message Date
fa62e3a2eb removed old metatag 2022-03-13 22:29:37 +01:00
a1bb41f8a2 redstone bundle mask improvement 2022-03-13 22:29:25 +01:00
57bf49bea9 added lshift polyfill 2022-03-13 22:28:48 +01:00
5 changed files with 46 additions and 8 deletions

View File

@@ -109,7 +109,7 @@ abstract WriteBinaryHandle(FileHandle) from FileHandle {
} }
} }
@:enum abstract BinarySeekWhence(String) to String { enum abstract BinarySeekWhence(String) to String {
var Set = "set"; // Relative to the beginning of the file. var Set = "set"; // Relative to the beginning of the file.
var Current = "cur"; // Relative to the current position. This is the default. var Current = "cur"; // Relative to the current position. This is the default.
var End = "end"; // Relative to the end of the file. var End = "end"; // Relative to the end of the file.

View File

@@ -1,6 +1,6 @@
package kernel.http; package kernel.http;
@:enum abstract StatusCode(Int) from Int { enum abstract StatusCode(Int) from Int {
var Continue = 100; var Continue = 100;
var SwitchingProtocols = 101; var SwitchingProtocols = 101;
var Processing = 102; var Processing = 102;

View File

@@ -1,10 +1,45 @@
package kernel.peripherals; package kernel.peripherals;
import haxe.ds.ReadOnlyArray;
import util.Color; import util.Color;
using tink.CoreApi; using tink.CoreApi;
typedef BundleMask = Color; abstract BundleMask(Int) from cc.Colors.Color to cc.Colors.Color {
public inline function new(i:Int) {
this = i;
}
@:from
public static function fromColor(c: Color) {
return new BundleMask(c);
}
@:op(A + B)
@:op(A | B)
public inline function combine(rhs: BundleMask):BundleMask {
return this | rhs;
}
@:op(A + B)
@:op(A | B)
public inline function combineWithColor(rhs: Color):BundleMask {
return this | rhs;
}
public function getComponents(): ReadOnlyArray<Color> {
var components: Array<Color> = [];
var mask = 1;
for (i in 0...16){
if ((this & mask) > 0 ){
components.push(mask);
}
mask = mask << 1;
}
return components;
}
}
class Redstone implements IPeripheral { class Redstone implements IPeripheral {
@@ -22,16 +57,19 @@ class Redstone implements IPeripheral {
this.addr = side; this.addr = side;
this.onChange = this.onChangeTrigger.asSignal(); this.onChange = this.onChangeTrigger.asSignal();
updateState();
KernelEvents.instance.onRedstone.handle(()->{ KernelEvents.instance.onRedstone.handle(()->{
if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState == this.getBundledInput())){ if ((this.getAnalogInput() != this.analogInputState) || (this.bundleInputState != this.getBundledInput())){
updateState();
this.onChangeTrigger.trigger(null); this.onChangeTrigger.trigger(null);
} }
}); });
} }
public function getAddr():String { public function getAddr():String {
return this.addr; return this.addr;
updateState();
} }
private function updateState() { private function updateState() {

View File

@@ -45,8 +45,7 @@ bit.tohex = function(x,n)
end end
bit.lshift = function(x,n) bit.lshift = function(x,n)
print("ERROR: Tell a dev to implement: bit.lshift") return bit.blshift(x,n);
error()
end end

View File

@@ -21,7 +21,8 @@ enum abstract Color(Int) from cc.Colors.Color to cc.Colors.Color {
var Black = 0x8000; var Black = 0x8000;
@:op(A + B) @:op(A + B)
@:op(A | B)
public inline function combine(rhs: Color):BundleMask { public inline function combine(rhs: Color):BundleMask {
return this + rhs; return this | rhs;
} }
} }