2022-02-15
Part of my journey through Shenzhen I/O
Problem: There are two simple I/O inputs: point
and foul
. There is display attached via XBus that will display the current score when it is sent via an XBus packet. When point
is 100
, the score should increment. When foul
is 100
, the score should decrement by 2, but never go lower than 0.
I used a single MC4000 for this, wiring point
to p0
, foul
to p1
, and display
to x1
.
teq p0 100
+ add 1
teq p1 100
+ sub 2
+ tlt acc 0
+ mov 0 acc
mov acc x1
slp 1
This ended up scoring pretty well, costing is ¥3, using 268 power, and 8 lines of code, which is better than average on power, and the lowest value attainable on lines of code and cost.