summaryrefslogtreecommitdiff
path: root/BinaryDisplay.cpp
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-06-30 16:41:17 +0930
committerDaniel Jones <admin@danieljon.es>2020-06-30 16:41:17 +0930
commit93f4f323e5374e65a9cadd5903fa020188e59ee1 (patch)
tree7484749791728ae439131ec7397472c02e7d477d /BinaryDisplay.cpp
parent61a3297b662b1bd8621016c8b5b492dd37bf5675 (diff)
downloadfoxlogicgates-93f4f323e5374e65a9cadd5903fa020188e59ee1.tar.gz
foxlogicgates-93f4f323e5374e65a9cadd5903fa020188e59ee1.zip
Functionality: basic binary display functions, needs work
Diffstat (limited to 'BinaryDisplay.cpp')
-rw-r--r--BinaryDisplay.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/BinaryDisplay.cpp b/BinaryDisplay.cpp
index 0e55ba3..8526511 100644
--- a/BinaryDisplay.cpp
+++ b/BinaryDisplay.cpp
@@ -12,5 +12,46 @@ BinaryDisplay::BinaryDisplay(int x_, int y_, int width, int height)
void
BinaryDisplay::update_state()
{
- puts("update binary display");
+ sum_value = 0;
+ if (input0 && input0->get_object_type() == Object::GATE && input0->get_output_state())
+ sum_value |= 1 << 0;
+ if (input1 && input1->get_object_type() == Object::GATE && input1->get_output_state())
+ sum_value |= 1 << 1;
+ if (input2 && input2->get_object_type() == Object::GATE && input2->get_output_state())
+ sum_value |= 1 << 2;
+ if (input3 && input3->get_object_type() == Object::GATE && input3->get_output_state())
+ sum_value |= 1 << 3;
+ if (input4 && input4->get_object_type() == Object::GATE && input4->get_output_state())
+ sum_value |= 1 << 4;
+ if (input5 && input5->get_object_type() == Object::GATE && input5->get_output_state())
+ sum_value |= 1 << 5;
+ if (input6 && input6->get_object_type() == Object::GATE && input6->get_output_state())
+ sum_value |= 1 << 6;
+ if (input7 && input7->get_object_type() == Object::GATE && input7->get_output_state())
+ sum_value |= 1 << 7;
}
+
+void
+BinaryDisplay::remove_input(int id)
+{
+ if (input0 && input0->get_id() == id)
+ input0 = nullptr;
+
+ if (input1 && input1->get_id() == id)
+ input1 = nullptr;
+ if (input2 && input2->get_id() == id)
+ input2 = nullptr;
+ if (input3 && input3->get_id() == id)
+ input3 = nullptr;
+ if (input4 && input5->get_id() == id)
+ input5 = nullptr;
+ if (input5 && input5->get_id() == id)
+ input5 = nullptr;
+ if (input6 && input6->get_id() == id)
+ input6 = nullptr;
+ if (input7 && input7->get_id() == id)
+ input7 = nullptr;
+ update_state();
+}
+
+