aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorMelody Horn <melody@boringcactus.com>2021-03-07 22:27:59 -0700
committerMelody Horn <melody@boringcactus.com>2021-03-07 22:27:59 -0700
commit204ee3854d3d45338ed9f1659d44f23062bfac77 (patch)
tree8b58d90d7b9ad367f6be1f336cd6146f6417e87c /src/main.rs
parentb8bb816d72217c1afdb18858481db737e52a4e7f (diff)
downloadhope-main.tar.gz
hope-main.zip
expand the hardcoded system so it draws a dot under the cursorHEADmain
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs85
1 files changed, 68 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index ef61de7..c457354 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -12,8 +12,6 @@ const WIDTH: usize = 1600;
const HEIGHT: usize = 900;
fn main() {
- let mut buffer: Vec<u32> = vec![0; WIDTH * HEIGHT];
-
let mut window = Window::new(
"the Hope system",
WIDTH,
@@ -51,6 +49,34 @@ fn main() {
..Default::default()
};
+ let zero_constant = basic_actors::Constant {
+ r#type: u24.clone(),
+ value: actor::Value::Number(number::Number::from(0)),
+ };
+ world.upsert_actor_type("Zero Constant".to_string(), Box::new(zero_constant));
+ let zero_constant = system.add_child("Zero Constant".to_string());
+
+ let buffer_size_constant = basic_actors::Constant {
+ r#type: nonnegative_int.clone(),
+ value: actor::Value::Number(number::Number::from(WIDTH * HEIGHT)),
+ };
+ world.upsert_actor_type("Buffer Size Constant".to_string(), Box::new(buffer_size_constant));
+ let buffer_size_constant = system.add_child("Buffer Size Constant".to_string());
+
+ let repeat_u24 = basic_actors::RepeatValue {
+ r#type: u24.clone(),
+ };
+ world.upsert_actor_type("Repeat u24".to_string(), Box::new(repeat_u24));
+ let repeat_u24 = system.add_child("Repeat u24".to_string());
+ system.add_cable(
+ actor::ProducerSlotID::ChildOutput(zero_constant, "Value".to_string()),
+ actor::ConsumerSlotID::ChildInput(repeat_u24, "Value".to_string())
+ );
+ system.add_cable(
+ actor::ProducerSlotID::ChildOutput(buffer_size_constant, "Value".to_string()),
+ actor::ConsumerSlotID::ChildInput(repeat_u24, "Count".to_string())
+ );
+
let deconstruct_record = basic_actors::DeconstructRecord {
record_type: screen_position_type,
};
@@ -61,39 +87,64 @@ fn main() {
actor::ConsumerSlotID::ChildInput(deconstruct_record, "Record".to_string())
);
- world.upsert_actor_type("Add".to_string(), Box::new(basic_actors::Add));
+ let width_constant = basic_actors::Constant {
+ r#type: nonnegative_int.clone(),
+ value: actor::Value::Number(number::Number::from(WIDTH)),
+ };
+ world.upsert_actor_type("Width Constant".to_string(), Box::new(width_constant));
+ let width_constant = system.add_child("Width Constant".to_string());
+
+ let multiply = basic_actors::Multiply;
+ world.upsert_actor_type("Multiply".to_string(), Box::new(multiply));
+ let multiply = system.add_child("Multiply".to_string());
+ system.add_cable(
+ actor::ProducerSlotID::ChildOutput(deconstruct_record, "Y".to_string()),
+ actor::ConsumerSlotID::ChildInput(multiply, "N1".to_string())
+ );
+ system.add_cable(
+ actor::ProducerSlotID::ChildOutput(width_constant, "Value".to_string()),
+ actor::ConsumerSlotID::ChildInput(multiply, "N2".to_string())
+ );
+
+ let add = basic_actors::Add;
+ world.upsert_actor_type("Add".to_string(), Box::new(add));
let add = system.add_child("Add".to_string());
system.add_cable(
actor::ProducerSlotID::ChildOutput(deconstruct_record, "X".to_string()),
actor::ConsumerSlotID::ChildInput(add, "N1".to_string())
);
system.add_cable(
- actor::ProducerSlotID::ChildOutput(deconstruct_record, "Y".to_string()),
+ actor::ProducerSlotID::ChildOutput(multiply, "Result".to_string()),
actor::ConsumerSlotID::ChildInput(add, "N2".to_string())
);
- let buffer_size_constant = basic_actors::Constant {
- r#type: nonnegative_int.clone(),
- value: actor::Value::Number(number::Number::from(WIDTH * HEIGHT)),
+ let red_constant = basic_actors::Constant {
+ r#type: u24.clone(),
+ value: actor::Value::Number(number::Number::from(0xFF << 16))
};
- world.upsert_actor_type("Buffer Size Constant".to_string(), Box::new(buffer_size_constant));
- let buffer_size_constant = system.add_child("Buffer Size Constant".to_string());
+ world.upsert_actor_type("Red Constant".to_string(), Box::new(red_constant));
+ let red_constant = system.add_child("Red Constant".to_string());
- let repeat_u24 = basic_actors::RepeatValue {
- r#type: u24,
+ let set_u24 = basic_actors::SetListItem {
+ r#type: u24.clone()
};
- world.upsert_actor_type("Repeat u24".to_string(), Box::new(repeat_u24));
- let repeat_u24 = system.add_child("Repeat u24".to_string());
+ world.upsert_actor_type("Set u24".to_string(), Box::new(set_u24));
+ let set_u24 = system.add_child("Set u24".to_string());
+ system.add_cable(
+ actor::ProducerSlotID::ChildOutput(repeat_u24, "List".to_string()),
+ actor::ConsumerSlotID::ChildInput(set_u24, "List".to_string())
+ );
system.add_cable(
actor::ProducerSlotID::ChildOutput(add, "Result".to_string()),
- actor::ConsumerSlotID::ChildInput(repeat_u24, "Value".to_string())
+ actor::ConsumerSlotID::ChildInput(set_u24, "Index".to_string())
);
system.add_cable(
- actor::ProducerSlotID::ChildOutput(buffer_size_constant, "Value".to_string()),
- actor::ConsumerSlotID::ChildInput(repeat_u24, "Count".to_string())
+ actor::ProducerSlotID::ChildOutput(red_constant, "Value".to_string()),
+ actor::ConsumerSlotID::ChildInput(set_u24, "Value".to_string())
);
+
system.add_cable(
- actor::ProducerSlotID::ChildOutput(repeat_u24, "List".to_string()),
+ actor::ProducerSlotID::ChildOutput(set_u24, "List".to_string()),
actor::ConsumerSlotID::Output("screen_buffer".to_string())
);