Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vm rebuild #34

Draft
wants to merge 45 commits into
base: develop
Choose a base branch
from
Draft

Vm rebuild #34

wants to merge 45 commits into from

Conversation

Ryex
Copy link
Owner

@Ryex Ryex commented May 1, 2024

Goal here is to move the VM to using dynamic objects allowing the Game's logic to be modeled much more closely.

  • generic object trait
  • codegen the traits, enums, etc for instructions and logic
  • new frozen object interface, potential for less JSON when state is saved if the object template are in the database
  • lots of interface traits to handle logic
  • load/build ItemIntergretedCircuit10 from ObjectTemplate (relatively easy)
  • implementing the known circuit holders (both housings, tablet, suit)
  • remap the WASM interface
  • fix frontend to use new template system
  • clean up new errors to reach parity with devleop

@Ryex
Copy link
Owner Author

Ryex commented May 1, 2024

@ComputerDruid @Emilgardis if you want to stay away from this one I won't blame you. lots of macro work in these early stages.

Suffice it to say that I've built a rather nice and clean macro derivable Object interface trait that I'll be using to rework the rest of the VM.

Ie. when I'm done as far as the VM is concerned a circuit housing is nothing more than an Object implementing the CircuitHolder trait and anything with memory is just an object that implements Memory + (MemoryReadable &| MemoryWritable)
same with logic and Logicable

Copy link

github-actions bot commented May 1, 2024

🚀 Deployed on https://deploy-preview-34--ic10emu.netlify.app

Copy link
Contributor

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

xtask/src/generate.rs Outdated Show resolved Hide resolved
Ok(())
}

pub fn parse_json<'a, T: serde::Deserialize<'a>>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, i recognize this

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its' a very nice function, I wrote a much less friendly version once. I prefer this.

xtask/src/stationpedia.rs Outdated Show resolved Hide resolved
xtask/src/main.rs Outdated Show resolved Hide resolved
xtask/src/generate/instructions.rs Outdated Show resolved Hide resolved
ic10emu/src/vm/object/mod.rs Outdated Show resolved Hide resolved
xtask/Cargo.toml Outdated Show resolved Hide resolved
xtask/src/generate/database.rs Outdated Show resolved Hide resolved
xtask/src/generate/instructions.rs Outdated Show resolved Hide resolved
xtask/Cargo.toml Outdated Show resolved Hide resolved
@Ryex
Copy link
Owner Author

Ryex commented May 15, 2024

phew... finally getting close to parity after the rewrite. so much code...
once I finish off porting the instructions to traits it will just be a case of

  • load/build ItemIntergretedCircuit10 from ObjectTemplate (relatively easy)
  • implementing the known circuit holders (both housings, tablet, suit)
  • remap the WASM interface
  • fix frontend to use new template system

at this point the VM and object system is stable, so if anyone wants to double check it for my sanity that would be great.

@Ryex
Copy link
Owner Author

Ryex commented May 27, 2024

manic laughing commences
@Emilgardis
@ComputerDruid
It's Done.
the Rust rebuild is complete.

I now have to remap the wasm bindings and fix the frontend

@Emilgardis
Copy link
Contributor

😵

xtask/src/generate/instructions.rs Outdated Show resolved Hide resolved
ic10emu/src/vm/instructions/traits.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,1567 @@
use serde_derive::{Deserialize, Serialize};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing a big disclaimer that this is code-gen, I still feel like it should be put in a path like src/vm/instructions/codegen/ so that it's clear by just lookit at the file that it's code-gen, instead of only having to scroll up and seeing a disclaimer.

Same for traits.rs

Copy link
Owner Author

@Ryex Ryex May 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apparently quote does not preserve comments. fixed

ic10emu/src/vm/object/errors.rs Outdated Show resolved Hide resolved
ic10emu/src/vm/object/stationpedia.rs Show resolved Hide resolved
}
}

impl ObjectInfo {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should probably document these functions

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

fn get_radiation_factor(&self) -> f32;
}

pub trait IntegratedCircuit: Logicable + MemoryWritable + SourceCode + Item {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some documentation on these functions would be nice

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you were looking for? or should I be more in depth?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

ic10emu/src/grammar.rs Show resolved Hide resolved
@@ -2626,80 +214,87 @@ pub fn i64_to_f64(i: i64) -> f64 {

#[cfg(test)]
mod tests {
use crate::vm::VMError;

use super::*;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't forget these tests!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opp! your right. I commented them out during the rebuild because the interface changed a lot.
Fixed and passing.

Ryex added 15 commits May 27, 2024 22:12
…ct mixin, proxy vm to webworker to avoid hogging main thread
- parse and map meory instructions
- use FrozenObjectFull to propogate  data out of VM to componates (far
  less wasm calls)
smaller DOM updates  & easier data update paths.
fix sl-select problems with force update on signal sub

Signed-off-by: Rachel Powers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants