Add do_not_waste_structure_battery_charger.asm

This commit is contained in:
Ivor Barhansky 2024-07-30 10:41:54 +00:00
parent cb1ef42f53
commit 144e2cbff5

View File

@ -0,0 +1,30 @@
define SBC HASH("StructureBatteryCharger")
define SBC1 HASH("Charger 1")
define SBC2 HASH("Charger 2")
alias CHARGEID r15
alias UNCHARGEDAmount r14
start:
yield
move CHARGEID SBC1
jal donotwaste
move CHARGEID SBC2
jal donotwaste
j start
donotwaste:
move UNCHARGEDAmount 0
move r0 4
donotwasteloop:
lbns r1 SBC CHARGEID r0 Occupied Sum
breqz r1 4
lbns r1 SBC CHARGEID r0 ChargeRatio Sum
brge r1 0.99 2
add UNCHARGEDAmount UNCHARGEDAmount 1
sub r0 r0 1
bgez r0 donotwasteloop
sgtz r0 UNCHARGEDAmount
sbn SBC CHARGEID On r0
j ra