From 1f2105f3be06f130c9e0fc94076dceed6ec0a25e Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Thu, 22 Feb 2024 11:14:40 +0100 Subject: [PATCH] time to rewrite now --- Cargo.lock | 254 ------ Cargo.toml | 4 +- broken.mir | 2255 +++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 1 + src/main.rs | 377 ++++++++- 5 files changed, 2632 insertions(+), 259 deletions(-) create mode 100644 broken.mir diff --git a/Cargo.lock b/Cargo.lock index 6d5febb..fb2c1f5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,35 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "ab_glyph" -version = "0.2.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225" -dependencies = [ - "ab_glyph_rasterizer", - "owned_ttf_parser", -] - -[[package]] -name = "ab_glyph_rasterizer" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" - -[[package]] -name = "ahash" -version = "0.8.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01" -dependencies = [ - "cfg-if", - "getrandom", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "android-activity" version = "0.5.2" @@ -58,18 +29,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" -[[package]] -name = "arrayref" -version = "0.3.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" - -[[package]] -name = "arrayvec" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" - [[package]] name = "as-raw-xcb-connection" version = "1.0.1" @@ -171,18 +130,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "calloop-wayland-source" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f0ea9b9476c7fad82841a8dbb380e2eae480c21910feba80725b46931ed8f02" -dependencies = [ - "calloop", - "rustix", - "wayland-backend", - "wayland-client", -] - [[package]] name = "cc" version = "1.0.83" @@ -447,17 +394,6 @@ dependencies = [ "windows-targets 0.48.5", ] -[[package]] -name = "getrandom" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "190092ea657667030ac6a35e305e62fc4dd69fd98ac98631e5d3a2b1575a12b5" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - [[package]] name = "hashbrown" version = "0.14.3" @@ -691,15 +627,6 @@ dependencies = [ "libredox", ] -[[package]] -name = "owned_ttf_parser" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7" -dependencies = [ - "ttf-parser", -] - [[package]] name = "percent-encoding" version = "2.3.1" @@ -828,19 +755,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" -[[package]] -name = "sctk-adwaita" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82b2eaf3a5b264a521b988b2e73042e742df700c4f962cde845d1541adb46550" -dependencies = [ - "ab_glyph", - "log", - "memmap2", - "smithay-client-toolkit", - "tiny-skia", -] - [[package]] name = "serde" version = "1.0.196" @@ -876,31 +790,6 @@ version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6ecd384b10a64542d77071bd64bd7b231f4ed5940fba55e98c3de13824cf3d7" -[[package]] -name = "smithay-client-toolkit" -version = "0.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60e3d9941fa3bacf7c2bf4b065304faa14164151254cd16ce1b1bc8fc381600f" -dependencies = [ - "bitflags 2.4.2", - "calloop", - "calloop-wayland-source", - "cursor-icon", - "libc", - "log", - "memmap2", - "rustix", - "thiserror", - "wayland-backend", - "wayland-client", - "wayland-csd-frame", - "wayland-cursor", - "wayland-protocols", - "wayland-protocols-wlr", - "wayland-scanner", - "xkeysym", -] - [[package]] name = "smol_str" version = "0.2.1" @@ -941,12 +830,6 @@ dependencies = [ "x11rb", ] -[[package]] -name = "strict-num" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" - [[package]] name = "syn" version = "2.0.48" @@ -978,31 +861,6 @@ dependencies = [ "syn", ] -[[package]] -name = "tiny-skia" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6a067b809476893fce6a254cf285850ff69c847e6cfbade6a20b655b6c7e80d" -dependencies = [ - "arrayref", - "arrayvec", - "bytemuck", - "cfg-if", - "log", - "tiny-skia-path", -] - -[[package]] -name = "tiny-skia-path" -version = "0.11.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de35e8a90052baaaf61f171680ac2f8e925a1e43ea9d2e3a00514772250e541" -dependencies = [ - "arrayref", - "bytemuck", - "strict-num", -] - [[package]] name = "tiny-xlib" version = "0.2.2" @@ -1048,12 +906,6 @@ version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -[[package]] -name = "ttf-parser" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" - [[package]] name = "unicode-ident" version = "1.0.12" @@ -1066,12 +918,6 @@ version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "walkdir" version = "2.4.0" @@ -1082,12 +928,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - [[package]] name = "wasm-bindgen" version = "0.2.90" @@ -1180,66 +1020,6 @@ dependencies = [ "wayland-scanner", ] -[[package]] -name = "wayland-csd-frame" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" -dependencies = [ - "bitflags 2.4.2", - "cursor-icon", - "wayland-backend", -] - -[[package]] -name = "wayland-cursor" -version = "0.31.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71ce5fa868dd13d11a0d04c5e2e65726d0897be8de247c0c5a65886e283231ba" -dependencies = [ - "rustix", - "wayland-client", - "xcursor", -] - -[[package]] -name = "wayland-protocols" -version = "0.31.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f81f365b8b4a97f422ac0e8737c438024b5951734506b0e1d775c73030561f4" -dependencies = [ - "bitflags 2.4.2", - "wayland-backend", - "wayland-client", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-plasma" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23803551115ff9ea9bce586860c5c5a971e360825a0309264102a9495a5ff479" -dependencies = [ - "bitflags 2.4.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - -[[package]] -name = "wayland-protocols-wlr" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" -dependencies = [ - "bitflags 2.4.2", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-scanner", -] - [[package]] name = "wayland-scanner" version = "0.31.1" @@ -1518,7 +1298,6 @@ version = "0.29.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c824f11941eeae66ec71111cc2674373c772f482b58939bb4066b642aa2ffcf" dependencies = [ - "ahash", "android-activity", "atomic-waker", "bitflags 2.4.2", @@ -1532,7 +1311,6 @@ dependencies = [ "js-sys", "libc", "log", - "memmap2", "ndk", "ndk-sys", "objc2", @@ -1542,16 +1320,10 @@ dependencies = [ "raw-window-handle", "redox_syscall 0.3.5", "rustix", - "sctk-adwaita", - "smithay-client-toolkit", "smol_str", "unicode-segmentation", "wasm-bindgen", "wasm-bindgen-futures", - "wayland-backend", - "wayland-client", - "wayland-protocols", - "wayland-protocols-plasma", "web-sys", "web-time", "windows-sys 0.48.0", @@ -1601,12 +1373,6 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e63e71c4b8bd9ffec2c963173a4dc4cbde9ee96961d4fcb4429db9929b606c34" -[[package]] -name = "xcursor" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a0ccd7b4a5345edfcd0c3535718a4e9ff7798ffc536bb5b5a0e26ff84732911" - [[package]] name = "xkbcommon-dl" version = "0.4.1" @@ -1625,23 +1391,3 @@ name = "xkeysym" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "054a8e68b76250b253f671d1268cb7f1ae089ec35e195b2efb2a4e9a836d0621" - -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/Cargo.toml b/Cargo.toml index 3ea3a60..99e0880 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -softbuffer = "0.4.1" -winit = "0.29.10" +softbuffer = { version = "0.4.1" } +winit = { version = "0.29.10", default-features = false, features = [ "x11", "rwh_06" ] } diff --git a/broken.mir b/broken.mir new file mode 100644 index 0000000..5ebe7e0 --- /dev/null +++ b/broken.mir @@ -0,0 +1,2255 @@ +// WARNING: This output format is intended for human consumers only +// and is subject to change without notice. Knock yourself out. +fn main() -> () { + let mut _0: (); + let _1: winit::event_loop::EventLoop<()>; + let mut _2: std::result::Result, winit::error::EventLoopError>; + let mut _4: std::result::Result; + let mut _5: winit::window::WindowBuilder; + let _6: &winit::event_loop::EventLoopWindowTarget<()>; + let _7: &winit::event_loop::EventLoop<()>; + let _8: (); + let _9: &winit::event_loop::EventLoopWindowTarget<()>; + let mut _10: &winit::event_loop::EventLoop<()>; + let mut _11: winit::event_loop::ControlFlow; + let _12: (); + let _13: &winit::event_loop::EventLoopWindowTarget<()>; + let mut _14: &winit::event_loop::EventLoop<()>; + let mut _15: winit::event_loop::ControlFlow; + let mut _17: std::result::Result>, softbuffer::SoftBufferError>; + let mut _18: winit::raw_window_handle::DisplayHandle<'_>; + let mut _19: std::result::Result, winit::raw_window_handle::HandleError>; + let mut _20: &winit::window::Window; + let mut _22: std::result::Result, winit::raw_window_handle::WindowHandle<'_>>, softbuffer::SoftBufferError>; + let _23: &softbuffer::Context>; + let mut _24: winit::raw_window_handle::WindowHandle<'_>; + let mut _25: std::result::Result, winit::raw_window_handle::HandleError>; + let mut _26: &winit::window::Window; + let _28: (); + let mut _29: std::result::Result<(), winit::error::EventLoopError>; + let mut _30: winit::event_loop::EventLoop<()>; + let mut _31: {closure@src/main.rs:34:14: 34:27}; + let mut _32: &winit::window::Window; + let mut _33: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>; + let mut _34: &mut game::GameState; + let mut _35: bool; + let mut _36: bool; + scope 1 { + debug event_loop => _1; + let _3: winit::window::Window; + scope 2 { + debug window => _3; + let _16: softbuffer::Context>; + scope 3 { + debug context => _16; + let mut _21: softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>; + scope 4 { + debug surface => _21; + let mut _27: game::GameState; + scope 5 { + debug game => _27; + } + } + } + } + } + + bb0: { + _36 = const false; + _35 = const false; + _2 = EventLoop::<()>::new() -> [return: bb1, unwind continue]; + } + + bb1: { + _1 = Result::, EventLoopError>::unwrap(move _2) -> [return: bb2, unwind continue]; + } + + bb2: { + _36 = const true; + _5 = WindowBuilder::new() -> [return: bb3, unwind: bb32]; + } + + bb3: { + _35 = const true; + _7 = &_1; + _6 = as Deref>::deref(_7) -> [return: bb4, unwind: bb30]; + } + + bb4: { + _35 = const false; + _4 = WindowBuilder::build::<()>(move _5, _6) -> [return: bb5, unwind: bb30]; + } + + bb5: { + _35 = const false; + _3 = Result::::unwrap(move _4) -> [return: bb6, unwind: bb32]; + } + + bb6: { + _10 = &_1; + _9 = as Deref>::deref(move _10) -> [return: bb7, unwind: bb27]; + } + + bb7: { + _11 = winit::event_loop::ControlFlow::Poll; + _8 = EventLoopWindowTarget::<()>::set_control_flow(_9, move _11) -> [return: bb8, unwind: bb27]; + } + + bb8: { + _14 = &_1; + _13 = as Deref>::deref(move _14) -> [return: bb9, unwind: bb27]; + } + + bb9: { + _15 = winit::event_loop::ControlFlow::Wait; + _12 = EventLoopWindowTarget::<()>::set_control_flow(_13, move _15) -> [return: bb10, unwind: bb27]; + } + + bb10: { + _20 = &_3; + _19 = ::display_handle(move _20) -> [return: bb11, unwind: bb27]; + } + + bb11: { + _18 = Result::, HandleError>::unwrap(move _19) -> [return: bb12, unwind: bb27]; + } + + bb12: { + _17 = softbuffer::Context::>::new(move _18) -> [return: bb13, unwind: bb27]; + } + + bb13: { + _16 = Result::>, SoftBufferError>::unwrap(move _17) -> [return: bb14, unwind: bb27]; + } + + bb14: { + _23 = &_16; + _26 = &_3; + _25 = ::window_handle(move _26) -> [return: bb15, unwind: bb26]; + } + + bb15: { + _24 = Result::, HandleError>::unwrap(move _25) -> [return: bb16, unwind: bb26]; + } + + bb16: { + _22 = Surface::, WindowHandle<'_>>::new(_23, move _24) -> [return: bb17, unwind: bb26]; + } + + bb17: { + _21 = Result::, WindowHandle<'_>>, SoftBufferError>::unwrap(move _22) -> [return: bb18, unwind: bb26]; + } + + bb18: { + _27 = GameState::init() -> [return: bb19, unwind: bb25]; + } + + bb19: { + _36 = const false; + _30 = move _1; + _32 = &_3; + _33 = &mut _21; + _34 = &mut _27; + _31 = {closure@src/main.rs:34:14: 34:27} { window: move _32, surface: move _33, game: move _34 }; + _29 = EventLoop::<()>::run::<{closure@src/main.rs:34:14: 34:27}>(move _30, move _31) -> [return: bb20, unwind: bb25]; + } + + bb20: { + _28 = Result::<(), EventLoopError>::unwrap(move _29) -> [return: bb21, unwind: bb25]; + } + + bb21: { + drop(_21) -> [return: bb22, unwind: bb26]; + } + + bb22: { + drop(_16) -> [return: bb23, unwind: bb27]; + } + + bb23: { + drop(_3) -> [return: bb24, unwind: bb32]; + } + + bb24: { + _36 = const false; + return; + } + + bb25 (cleanup): { + drop(_21) -> [return: bb26, unwind terminate(cleanup)]; + } + + bb26 (cleanup): { + drop(_16) -> [return: bb27, unwind terminate(cleanup)]; + } + + bb27 (cleanup): { + drop(_3) -> [return: bb32, unwind terminate(cleanup)]; + } + + bb28 (cleanup): { + resume; + } + + bb29 (cleanup): { + drop(_5) -> [return: bb32, unwind terminate(cleanup)]; + } + + bb30 (cleanup): { + switchInt(_35) -> [0: bb32, otherwise: bb29]; + } + + bb31 (cleanup): { + drop(_1) -> [return: bb28, unwind terminate(cleanup)]; + } + + bb32 (cleanup): { + switchInt(_36) -> [0: bb28, otherwise: bb31]; + } +} + +fn main::{closure#0}(_1: &mut {closure@src/main.rs:34:14: 34:27}, _2: Event<()>, _3: &EventLoopWindowTarget<()>) -> () { + debug event => _2; + debug elwt => _3; + debug window => (*((*_1).0: &winit::window::Window)); + debug surface => (*((*_1).1: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>)); + debug game => (*((*_1).2: &mut game::GameState)); + let mut _0: (); + let mut _4: isize; + let mut _5: isize; + let mut _6: isize; + let mut _7: isize; + let _8: winit::window::WindowId; + let _9: &winit::window::WindowId; + let mut _10: bool; + let mut _11: &winit::window::WindowId; + let _12: winit::window::WindowId; + let mut _13: (std::option::Option>, std::option::Option>); + let mut _15: std::option::Option>; + let mut _16: u32; + let mut _17: std::option::Option>; + let mut _18: u32; + let mut _19: isize; + let mut _20: isize; + let _23: (); + let mut _24: std::result::Result<(), softbuffer::SoftBufferError>; + let mut _26: std::result::Result, winit::raw_window_handle::WindowHandle<'_>>, softbuffer::SoftBufferError>; + let _27: (); + let mut _28: &mut [u32]; + let mut _29: &mut softbuffer::Buffer<'_, winit::raw_window_handle::DisplayHandle<'_>, winit::raw_window_handle::WindowHandle<'_>>; + let _30: (); + let _31: (); + let mut _32: &game::GameState; + let mut _33: &mut softbuffer::Buffer<'_, winit::raw_window_handle::DisplayHandle<'_>, winit::raw_window_handle::WindowHandle<'_>>; + let mut _34: (std::num::NonZero, std::num::NonZero); + let _35: (); + let mut _36: std::result::Result<(), softbuffer::SoftBufferError>; + let mut _37: softbuffer::Buffer<'_, winit::raw_window_handle::DisplayHandle<'_>, winit::raw_window_handle::WindowHandle<'_>>; + let _38: winit::window::WindowId; + let _39: &winit::window::WindowId; + let mut _40: bool; + let mut _41: &winit::window::WindowId; + let mut _42: &winit::window::WindowId; + let _43: winit::window::WindowId; + let mut _44: bool; + let mut _45: &winit::window::WindowId; + let mut _46: &winit::window::WindowId; + let _47: winit::window::WindowId; + let _48: (); + let mut _49: &winit::window::Window; + let mut _50: &winit::window::Window; + let mut _51: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>; + let mut _52: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>; + let mut _53: &mut game::GameState; + let mut _54: &mut game::GameState; + let mut _55: &winit::window::Window; + let mut _56: &winit::window::Window; + let mut _57: bool; + scope 1 { + debug window_id => _8; + debug window_id => _9; + scope 2 { + debug width => _21; + debug height => _22; + let _14: winit::dpi::PhysicalSize; + let _21: std::num::NonZero; + let _22: std::num::NonZero; + let mut _25: softbuffer::Buffer<'_, winit::raw_window_handle::DisplayHandle<'_>, winit::raw_window_handle::WindowHandle<'_>>; + scope 3 { + debug size => _14; + } + scope 4 { + debug buffer => _25; + } + } + } + scope 5 { + debug window_id => _38; + debug window_id => _39; + } + + bb0: { + _57 = const false; + _7 = discriminant(_2); + switchInt(move _7) -> [1: bb3, otherwise: bb32]; + } + + bb1: { + _5 = discriminant((((((_2 as WindowEvent).1: winit::event::WindowEvent) as KeyboardInput).1: winit::event::KeyEvent).1: winit::keyboard::Key)); + switchInt(move _5) -> [0: bb2, otherwise: bb32]; + } + + bb2: { + _4 = discriminant((((((((_2 as WindowEvent).1: winit::event::WindowEvent) as KeyboardInput).1: winit::event::KeyEvent).1: winit::keyboard::Key) as Named).0: winit::keyboard::NamedKey)); + switchInt(move _4) -> [42: bb28, otherwise: bb32]; + } + + bb3: { + _9 = &((_2 as WindowEvent).0: winit::window::WindowId); + _49 = deref_copy ((*_1).0: &winit::window::Window); + _12 = Window::id(_49) -> [return: bb4, unwind: bb34]; + } + + bb4: { + _11 = &_12; + _10 = ::eq(_9, move _11) -> [return: bb5, unwind: bb34]; + } + + bb5: { + switchInt(move _10) -> [0: bb7, otherwise: bb6]; + } + + bb6: { + _8 = ((_2 as WindowEvent).0: winit::window::WindowId); + _50 = deref_copy ((*_1).0: &winit::window::Window); + _14 = Window::inner_size(_50) -> [return: bb8, unwind: bb34]; + } + + bb7: { + _6 = discriminant(((_2 as WindowEvent).1: winit::event::WindowEvent)); + switchInt(move _6) -> [3: bb24, 9: bb1, otherwise: bb32]; + } + + bb8: { + _16 = (_14.0: u32); + _15 = NonZero::::new(move _16) -> [return: bb9, unwind: bb34]; + } + + bb9: { + _18 = (_14.1: u32); + _17 = NonZero::::new(move _18) -> [return: bb10, unwind: bb34]; + } + + bb10: { + _13 = (move _15, move _17); + _20 = discriminant((_13.0: std::option::Option>)); + switchInt(move _20) -> [1: bb11, otherwise: bb32]; + } + + bb11: { + _19 = discriminant((_13.1: std::option::Option>)); + switchInt(move _19) -> [1: bb12, otherwise: bb32]; + } + + bb12: { + _21 = (((_13.0: std::option::Option>) as Some).0: std::num::NonZero); + _22 = (((_13.1: std::option::Option>) as Some).0: std::num::NonZero); + _51 = deref_copy ((*_1).1: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>); + _24 = Surface::, WindowHandle<'_>>::resize(_51, _21, _22) -> [return: bb13, unwind: bb34]; + } + + bb13: { + _23 = Result::<(), SoftBufferError>::unwrap(move _24) -> [return: bb14, unwind: bb34]; + } + + bb14: { + _52 = deref_copy ((*_1).1: &mut softbuffer::Surface, winit::raw_window_handle::WindowHandle<'_>>); + _26 = Surface::, WindowHandle<'_>>::buffer_mut(_52) -> [return: bb15, unwind: bb34]; + } + + bb15: { + _25 = Result::, WindowHandle<'_>>, SoftBufferError>::unwrap(move _26) -> [return: bb16, unwind: bb34]; + } + + bb16: { + _57 = const true; + _29 = &mut _25; + _28 = , WindowHandle<'_>> as DerefMut>::deref_mut(move _29) -> [return: bb17, unwind: bb37]; + } + + bb17: { + _27 = core::slice::::fill(_28, const 0_u32) -> [return: bb18, unwind: bb37]; + } + + bb18: { + _53 = deref_copy ((*_1).2: &mut game::GameState); + _30 = GameState::update(_53) -> [return: bb19, unwind: bb37]; + } + + bb19: { + _54 = deref_copy ((*_1).2: &mut game::GameState); + _32 = &(*_54); + _33 = &mut _25; + _34 = (_21, _22); + _31 = GameState::render(move _32, _33, move _34) -> [return: bb20, unwind: bb37]; + } + + bb20: { + _57 = const false; + _37 = move _25; + _36 = Buffer::<'_, DisplayHandle<'_>, WindowHandle<'_>>::present(move _37) -> [return: bb21, unwind: bb37]; + } + + bb21: { + _35 = Result::<(), SoftBufferError>::unwrap(move _36) -> [return: bb22, unwind: bb37]; + } + + bb22: { + _57 = const false; + goto -> bb32; + } + + bb23: { + _48 = EventLoopWindowTarget::<()>::exit(_3) -> [return: bb38, unwind: bb34]; + } + + bb24: { + _39 = &((_2 as WindowEvent).0: winit::window::WindowId); + _41 = _39; + _55 = deref_copy ((*_1).0: &winit::window::Window); + _43 = Window::id(_55) -> [return: bb25, unwind: bb34]; + } + + bb25: { + _42 = &_43; + _40 = ::eq(move _41, move _42) -> [return: bb26, unwind: bb34]; + } + + bb26: { + switchInt(move _40) -> [0: bb32, otherwise: bb27]; + } + + bb27: { + _38 = ((_2 as WindowEvent).0: winit::window::WindowId); + goto -> bb23; + } + + bb28: { + _39 = &((_2 as WindowEvent).0: winit::window::WindowId); + _45 = _39; + _56 = deref_copy ((*_1).0: &winit::window::Window); + _47 = Window::id(_56) -> [return: bb29, unwind: bb34]; + } + + bb29: { + _46 = &_47; + _44 = ::eq(move _45, move _46) -> [return: bb30, unwind: bb34]; + } + + bb30: { + switchInt(move _44) -> [0: bb32, otherwise: bb31]; + } + + bb31: { + _38 = ((_2 as WindowEvent).0: winit::window::WindowId); + goto -> bb23; + } + + bb32: { + drop(_2) -> [return: bb33, unwind continue]; + } + + bb33: { + return; + } + + bb34 (cleanup): { + drop(_2) -> [return: bb35, unwind terminate(cleanup)]; + } + + bb35 (cleanup): { + resume; + } + + bb36 (cleanup): { + drop(_25) -> [return: bb34, unwind terminate(cleanup)]; + } + + bb37 (cleanup): { + switchInt(_57) -> [0: bb34, otherwise: bb36]; + } + + bb38: { + goto -> bb32; + } +} + +const PADDLE_SIZE: (u32, u32) = { + let mut _0: (u32, u32); + + bb0: { + _0 = (const 5_u32, const 50_u32); + return; + } +} + +const BALL_RADIUS: u32 = { + let mut _0: u32; + + bb0: { + _0 = const 10_u32; + return; + } +} + +const BALL_VEC_RIGHT_UP: (i16, i16) = { + let mut _0: (i16, i16); + + bb0: { + _0 = (const 8_i16, const 12_i16); + return; + } +} + +const FIELD_SIZE: (u32, u32) = { + let mut _0: (u32, u32); + + bb0: { + _0 = (const 1200_u32, const 700_u32); + return; + } +} + +const FIELD_BORDER_WIDTH: u32 = { + let mut _0: u32; + + bb0: { + _0 = const 5_u32; + return; + } +} + +const TICK_LEN: f32 = { + let mut _0: f32; + + bb0: { + _0 = Div(const 1000f32, const 60f32); + return; + } +} + +fn game::::fmt(_1: &BallDirection, _2: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + debug self => _1; + debug f => _2; + let mut _0: std::result::Result<(), std::fmt::Error>; + let mut _3: &str; + let mut _4: isize; + let _5: &str; + let _6: &str; + let _7: &str; + let _8: &str; + + bb0: { + _4 = discriminant((*_1)); + switchInt(move _4) -> [0: bb2, 1: bb3, 2: bb4, 3: bb1, otherwise: bb7]; + } + + bb1: { + _8 = const "LeftDown"; + _3 = _8; + goto -> bb5; + } + + bb2: { + _5 = const "RightUp"; + _3 = _5; + goto -> bb5; + } + + bb3: { + _6 = const "RightDown"; + _3 = _6; + goto -> bb5; + } + + bb4: { + _7 = const "LeftUp"; + _3 = _7; + goto -> bb5; + } + + bb5: { + _0 = Formatter::<'_>::write_str(_2, move _3) -> [return: bb6, unwind continue]; + } + + bb6: { + return; + } + + bb7: { + unreachable; + } +} + +fn game::::clone(_1: &BallDirection) -> BallDirection { + debug self => _1; + let mut _0: game::BallDirection; + + bb0: { + _0 = (*_1); + return; + } +} + +fn game::::eq(_1: &BallDirection, _2: &BallDirection) -> bool { + debug self => _1; + debug other => _2; + let mut _0: bool; + let _3: isize; + scope 1 { + debug __self_tag => _3; + let _4: isize; + scope 2 { + debug __arg1_tag => _4; + } + } + + bb0: { + _3 = discriminant((*_1)); + _4 = discriminant((*_2)); + _0 = Eq(_3, _4); + return; + } +} + +fn game::::assert_receiver_is_total_eq(_1: &BallDirection) -> () { + debug self => _1; + let mut _0: (); + + bb0: { + return; + } +} + +fn game::::fmt(_1: &HorizontalCollisionCheck, _2: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + debug self => _1; + debug f => _2; + let mut _0: std::result::Result<(), std::fmt::Error>; + let mut _3: &str; + let mut _4: isize; + let _5: &str; + let _6: &str; + let _7: &str; + + bb0: { + _4 = discriminant((*_1)); + switchInt(move _4) -> [0: bb2, 1: bb3, 2: bb1, otherwise: bb6]; + } + + bb1: { + _7 = const "Right"; + _3 = _7; + goto -> bb4; + } + + bb2: { + _5 = const "None"; + _3 = _5; + goto -> bb4; + } + + bb3: { + _6 = const "Left"; + _3 = _6; + goto -> bb4; + } + + bb4: { + _0 = Formatter::<'_>::write_str(_2, move _3) -> [return: bb5, unwind continue]; + } + + bb5: { + return; + } + + bb6: { + unreachable; + } +} + +fn game::::clone(_1: &HorizontalCollisionCheck) -> HorizontalCollisionCheck { + debug self => _1; + let mut _0: game::HorizontalCollisionCheck; + + bb0: { + _0 = (*_1); + return; + } +} + +fn game::::eq(_1: &HorizontalCollisionCheck, _2: &HorizontalCollisionCheck) -> bool { + debug self => _1; + debug other => _2; + let mut _0: bool; + let _3: isize; + scope 1 { + debug __self_tag => _3; + let _4: isize; + scope 2 { + debug __arg1_tag => _4; + } + } + + bb0: { + _3 = discriminant((*_1)); + _4 = discriminant((*_2)); + _0 = Eq(_3, _4); + return; + } +} + +fn game::::assert_receiver_is_total_eq(_1: &HorizontalCollisionCheck) -> () { + debug self => _1; + let mut _0: (); + + bb0: { + return; + } +} + +fn game::::fmt(_1: &VerticalCollisionCheck, _2: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + debug self => _1; + debug f => _2; + let mut _0: std::result::Result<(), std::fmt::Error>; + let mut _3: &str; + let mut _4: isize; + let _5: &str; + let _6: &str; + let _7: &str; + + bb0: { + _4 = discriminant((*_1)); + switchInt(move _4) -> [0: bb2, 1: bb3, 2: bb1, otherwise: bb6]; + } + + bb1: { + _7 = const "Bottom"; + _3 = _7; + goto -> bb4; + } + + bb2: { + _5 = const "None"; + _3 = _5; + goto -> bb4; + } + + bb3: { + _6 = const "Top"; + _3 = _6; + goto -> bb4; + } + + bb4: { + _0 = Formatter::<'_>::write_str(_2, move _3) -> [return: bb5, unwind continue]; + } + + bb5: { + return; + } + + bb6: { + unreachable; + } +} + +fn game::::clone(_1: &VerticalCollisionCheck) -> VerticalCollisionCheck { + debug self => _1; + let mut _0: game::VerticalCollisionCheck; + + bb0: { + _0 = (*_1); + return; + } +} + +fn game::::eq(_1: &VerticalCollisionCheck, _2: &VerticalCollisionCheck) -> bool { + debug self => _1; + debug other => _2; + let mut _0: bool; + let _3: isize; + scope 1 { + debug __self_tag => _3; + let _4: isize; + scope 2 { + debug __arg1_tag => _4; + } + } + + bb0: { + _3 = discriminant((*_1)); + _4 = discriminant((*_2)); + _0 = Eq(_3, _4); + return; + } +} + +fn game::::assert_receiver_is_total_eq(_1: &VerticalCollisionCheck) -> () { + debug self => _1; + let mut _0: (); + + bb0: { + return; + } +} + +fn game::::fmt(_1: &CollisionCheck, _2: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + debug self => _1; + debug f => _2; + let mut _0: std::result::Result<(), std::fmt::Error>; + let _3: &str; + let mut _4: &dyn std::fmt::Debug; + let _5: &game::HorizontalCollisionCheck; + let mut _6: &dyn std::fmt::Debug; + let _7: &&game::VerticalCollisionCheck; + let _8: &game::VerticalCollisionCheck; + + bb0: { + _3 = const "CollisionCheck"; + _5 = &((*_1).0: game::HorizontalCollisionCheck); + _4 = _5 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); + _8 = &((*_1).1: game::VerticalCollisionCheck); + _7 = &_8; + _6 = _7 as &dyn std::fmt::Debug (PointerCoercion(Unsize)); + _0 = Formatter::<'_>::debug_tuple_field2_finish(_2, _3, move _4, move _6) -> [return: bb1, unwind continue]; + } + + bb1: { + return; + } +} + +fn game::::clone(_1: &CollisionCheck) -> CollisionCheck { + debug self => _1; + let mut _0: game::CollisionCheck; + scope 1 { + scope 2 { + } + } + + bb0: { + _0 = (*_1); + return; + } +} + +fn game::::eq(_1: &CollisionCheck, _2: &CollisionCheck) -> bool { + debug self => _1; + debug other => _2; + let mut _0: bool; + let mut _3: bool; + let mut _4: &game::HorizontalCollisionCheck; + let mut _5: &game::HorizontalCollisionCheck; + let mut _6: &game::VerticalCollisionCheck; + let mut _7: &game::VerticalCollisionCheck; + + bb0: { + _4 = &((*_1).0: game::HorizontalCollisionCheck); + _5 = &((*_2).0: game::HorizontalCollisionCheck); + _3 = ::eq(move _4, move _5) -> [return: bb1, unwind continue]; + } + + bb1: { + switchInt(move _3) -> [0: bb3, otherwise: bb2]; + } + + bb2: { + _6 = &((*_1).1: game::VerticalCollisionCheck); + _7 = &((*_2).1: game::VerticalCollisionCheck); + _0 = ::eq(move _6, move _7) -> [return: bb4, unwind continue]; + } + + bb3: { + _0 = const false; + goto -> bb4; + } + + bb4: { + return; + } +} + +fn game::::assert_receiver_is_total_eq(_1: &CollisionCheck) -> () { + debug self => _1; + let mut _0: (); + scope 1 { + scope 2 { + } + } + + bb0: { + return; + } +} + +fn game::::check_field(_1: (u32, u32), _2: (u32, u32)) -> CollisionCheck { + debug obj_pos => _1; + debug obj_size => _2; + let mut _0: game::CollisionCheck; + let _3: game::HorizontalCollisionCheck; + let mut _4: u32; + let mut _5: bool; + let mut _6: u32; + let mut _7: u32; + let mut _8: u32; + let mut _9: (u32, bool); + let mut _10: u32; + let mut _11: (u32, u32); + let mut _13: u32; + let mut _14: bool; + let mut _15: u32; + let mut _16: u32; + let mut _17: u32; + let mut _18: (u32, bool); + let mut _19: u32; + let mut _20: (u32, u32); + let mut _21: game::HorizontalCollisionCheck; + let mut _22: game::VerticalCollisionCheck; + scope 1 { + debug horizontal => _3; + let _12: game::VerticalCollisionCheck; + scope 2 { + debug vertical => _12; + } + } + + bb0: { + _4 = (_1.0: u32); + switchInt(move _4) -> [0: bb1, otherwise: bb2]; + } + + bb1: { + _3 = HorizontalCollisionCheck::Left; + goto -> bb6; + } + + bb2: { + _7 = (_1.0: u32); + _8 = (_2.0: u32); + _9 = CheckedAdd(_7, _8); + assert(!move (_9.1: bool), "attempt to compute `{} + {}`, which would overflow", move _7, move _8) -> [success: bb3, unwind continue]; + } + + bb3: { + _6 = move (_9.0: u32); + _11 = const _; + _10 = (_11.0: u32); + _5 = Ge(move _6, move _10); + switchInt(move _5) -> [0: bb5, otherwise: bb4]; + } + + bb4: { + _3 = HorizontalCollisionCheck::Right; + goto -> bb6; + } + + bb5: { + _3 = HorizontalCollisionCheck::None; + goto -> bb6; + } + + bb6: { + _13 = (_1.1: u32); + switchInt(move _13) -> [0: bb7, otherwise: bb8]; + } + + bb7: { + _12 = VerticalCollisionCheck::Top; + goto -> bb12; + } + + bb8: { + _16 = (_1.1: u32); + _17 = (_2.1: u32); + _18 = CheckedAdd(_16, _17); + assert(!move (_18.1: bool), "attempt to compute `{} + {}`, which would overflow", move _16, move _17) -> [success: bb9, unwind continue]; + } + + bb9: { + _15 = move (_18.0: u32); + _20 = const _; + _19 = (_20.1: u32); + _14 = Ge(move _15, move _19); + switchInt(move _14) -> [0: bb11, otherwise: bb10]; + } + + bb10: { + _12 = VerticalCollisionCheck::Bottom; + goto -> bb12; + } + + bb11: { + _12 = VerticalCollisionCheck::None; + goto -> bb12; + } + + bb12: { + _21 = _3; + _22 = _12; + _0 = CollisionCheck(move _21, move _22); + return; + } +} + +fn game::::no_collisions(_1: &CollisionCheck) -> bool { + debug self => _1; + let mut _0: bool; + let mut _2: isize; + let mut _3: isize; + + bb0: { + _3 = discriminant(((*_1).0: game::HorizontalCollisionCheck)); + switchInt(move _3) -> [0: bb1, otherwise: bb2]; + } + + bb1: { + _2 = discriminant(((*_1).1: game::VerticalCollisionCheck)); + _0 = Eq(_2, const 0_isize); + goto -> bb3; + } + + bb2: { + _0 = const false; + goto -> bb3; + } + + bb3: { + return; + } +} + +fn game::::get_vec(_1: &BallDirection) -> (i16, i16) { + debug self => _1; + let mut _0: (i16, i16); + let mut _2: isize; + let mut _3: i16; + let mut _4: (i16, i16); + let mut _5: i16; + let mut _6: i16; + let mut _7: (i16, i16); + let mut _8: bool; + let mut _9: i16; + let mut _10: i16; + let mut _11: (i16, i16); + let mut _12: bool; + let mut _13: i16; + let mut _14: (i16, i16); + let mut _15: i16; + let mut _16: i16; + let mut _17: (i16, i16); + let mut _18: bool; + let mut _19: i16; + let mut _20: i16; + let mut _21: (i16, i16); + let mut _22: bool; + + bb0: { + _2 = discriminant((*_1)); + switchInt(move _2) -> [0: bb2, 1: bb3, 2: bb5, 3: bb1, otherwise: bb10]; + } + + bb1: { + _17 = const _; + _16 = (_17.0: i16); + _18 = Eq(_16, const i16::MIN); + assert(!move _18, "attempt to negate `{}`, which would overflow", _16) -> [success: bb7, unwind continue]; + } + + bb2: { + _0 = const _; + goto -> bb9; + } + + bb3: { + _4 = const _; + _3 = (_4.0: i16); + _7 = const _; + _6 = (_7.1: i16); + _8 = Eq(_6, const i16::MIN); + assert(!move _8, "attempt to negate `{}`, which would overflow", _6) -> [success: bb4, unwind continue]; + } + + bb4: { + _5 = Neg(move _6); + _0 = (move _3, move _5); + goto -> bb9; + } + + bb5: { + _11 = const _; + _10 = (_11.0: i16); + _12 = Eq(_10, const i16::MIN); + assert(!move _12, "attempt to negate `{}`, which would overflow", _10) -> [success: bb6, unwind continue]; + } + + bb6: { + _9 = Neg(move _10); + _14 = const _; + _13 = (_14.1: i16); + _0 = (move _9, move _13); + goto -> bb9; + } + + bb7: { + _15 = Neg(move _16); + _21 = const _; + _20 = (_21.1: i16); + _22 = Eq(_20, const i16::MIN); + assert(!move _22, "attempt to negate `{}`, which would overflow", _20) -> [success: bb8, unwind continue]; + } + + bb8: { + _19 = Neg(move _20); + _0 = (move _15, move _19); + goto -> bb9; + } + + bb9: { + return; + } + + bb10: { + unreachable; + } +} + +fn game::::init() -> GameState { + let mut _0: game::GameState; + let mut _1: (u32, u32); + let mut _2: u32; + let mut _3: u32; + let mut _4: (u32, u32); + let mut _5: bool; + let mut _6: u32; + let mut _7: u32; + let mut _8: (u32, u32); + let mut _9: bool; + let mut _10: u32; + let mut _11: u32; + let mut _12: (u32, u32); + let mut _13: bool; + let mut _14: u32; + let mut _15: u32; + let mut _16: (u32, u32); + let mut _17: bool; + let mut _18: game::BallDirection; + let mut _19: (u32, u32); + let mut _20: std::time::Instant; + + bb0: { + _4 = const _; + _3 = (_4.0: u32); + _5 = Eq(const 2_u32, const 0_u32); + assert(!move _5, "attempt to divide `{}` by zero", _3) -> [success: bb1, unwind continue]; + } + + bb1: { + _2 = Div(move _3, const 2_u32); + _8 = const _; + _7 = (_8.1: u32); + _9 = Eq(const 2_u32, const 0_u32); + assert(!move _9, "attempt to divide `{}` by zero", _7) -> [success: bb2, unwind continue]; + } + + bb2: { + _6 = Div(move _7, const 2_u32); + _1 = (move _2, move _6); + _12 = const _; + _11 = (_12.0: u32); + _13 = Eq(const 2_u32, const 0_u32); + assert(!move _13, "attempt to divide `{}` by zero", _11) -> [success: bb3, unwind continue]; + } + + bb3: { + _10 = Div(move _11, const 2_u32); + _16 = const _; + _15 = (_16.0: u32); + _17 = Eq(const 2_u32, const 0_u32); + assert(!move _17, "attempt to divide `{}` by zero", _15) -> [success: bb4, unwind continue]; + } + + bb4: { + _14 = Div(move _15, const 2_u32); + _18 = BallDirection::RightUp; + _19 = (const 0_u32, const 0_u32); + _20 = Instant::now() -> [return: bb5, unwind continue]; + } + + bb5: { + _0 = GameState { ball_pos: move _1, ball_direction: move _18, paddle_r_pos: move _10, paddle_y_pos: move _14, scores: move _19, last_frame_time: move _20 }; + return; + } +} + +fn game::::render(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (NonZero, NonZero)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let _4: (u32, u32); + let mut _5: u32; + let mut _6: std::num::NonZero; + let mut _7: u32; + let mut _8: std::num::NonZero; + let _9: (); + let _10: (); + scope 1 { + debug win_size => _4; + } + + bb0: { + _6 = (_3.0: std::num::NonZero); + _5 = NonZero::::get(move _6) -> [return: bb1, unwind continue]; + } + + bb1: { + _8 = (_3.1: std::num::NonZero); + _7 = NonZero::::get(move _8) -> [return: bb2, unwind continue]; + } + + bb2: { + _4 = (move _5, move _7); + _9 = GameState::render_field(_1, _2, _4) -> [return: bb3, unwind continue]; + } + + bb3: { + _10 = GameState::render_ball(_1, _2, _4) -> [return: bb4, unwind continue]; + } + + bb4: { + return; + } +} + +fn game::::update(_1: &mut GameState) -> () { + debug self => _1; + let mut _0: (); + let _2: f32; + let mut _3: &game::GameState; + let mut _4: std::time::Instant; + let _5: (); + scope 1 { + debug delta_t => _2; + } + + bb0: { + _3 = &(*_1); + _2 = GameState::delta_time(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + _4 = Instant::now() -> [return: bb2, unwind continue]; + } + + bb2: { + ((*_1).5: std::time::Instant) = move _4; + _5 = GameState::move_ball(_1) -> [return: bb3, unwind continue]; + } + + bb3: { + return; + } +} + +fn game::::move_ball(_1: &mut GameState) -> () { + debug self => _1; + let mut _0: (); + let _2: (i16, i16); + let mut _3: &game::BallDirection; + let mut _5: &game::GameState; + let mut _7: u32; + let mut _8: u32; + let mut _9: u32; + let mut _10: i32; + let mut _11: f32; + let mut _12: f32; + let mut _13: i16; + let mut _14: u32; + let mut _15: u32; + let mut _16: (u32, u32); + let mut _17: (u32, bool); + let mut _18: u32; + let mut _19: u32; + let mut _20: u32; + let mut _21: i32; + let mut _22: f32; + let mut _23: f32; + let mut _24: i16; + let mut _25: u32; + let mut _26: u32; + let mut _27: (u32, u32); + let mut _28: (u32, bool); + let _29: (); + let mut _30: std::fmt::Arguments<'_>; + let mut _31: &[&str]; + let mut _32: &[core::fmt::rt::Argument<'_>]; + let _33: &[core::fmt::rt::Argument<'_>; 2]; + let _34: [core::fmt::rt::Argument<'_>; 2]; + let mut _35: core::fmt::rt::Argument<'_>; + let _36: &(u32, u32); + let mut _37: core::fmt::rt::Argument<'_>; + let _38: &(u32, u32); + let mut _39: (u32, u32); + let mut _41: (u32, u32); + let mut _42: u32; + let mut _43: u32; + let mut _44: u32; + let mut _45: u32; + let mut _46: (u32, u32); + let mut _47: u32; + let mut _48: (u32, bool); + let mut _49: u32; + let mut _50: (u32, bool); + let mut _53: game::BallDirection; + let mut _54: (game::BallDirection, (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)); + let mut _55: game::BallDirection; + let mut _56: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck); + let mut _57: isize; + let mut _58: isize; + let mut _59: isize; + let mut _60: isize; + let mut _61: isize; + let mut _62: isize; + let mut _63: isize; + let mut _64: isize; + let mut _65: isize; + let mut _66: isize; + let mut _67: isize; + let mut _68: isize; + let mut _69: isize; + let _71: !; + let mut _72: std::fmt::Arguments<'_>; + let mut _73: &[&str]; + let mut _74: &[core::fmt::rt::Argument<'_>]; + let _75: &[core::fmt::rt::Argument<'_>; 1]; + let _76: [core::fmt::rt::Argument<'_>; 1]; + let mut _77: core::fmt::rt::Argument<'_>; + let _78: &(game::BallDirection, (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)); + let mut _79: &[core::fmt::rt::Placeholder]; + let _80: &[core::fmt::rt::Placeholder; 1]; + let _81: [core::fmt::rt::Placeholder; 1]; + let mut _82: core::fmt::rt::Placeholder; + let mut _83: core::fmt::rt::Alignment; + let mut _84: core::fmt::rt::Count; + let mut _85: core::fmt::rt::Count; + let mut _86: core::fmt::rt::UnsafeArg; + scope 1 { + debug vec => _2; + let _4: f32; + scope 2 { + debug delta_t => _4; + let _6: (u32, u32); + scope 3 { + debug new_pos => _6; + let _40: game::CollisionCheck; + let mut _88: &[&str; 3]; + scope 4 { + debug check_res => _40; + let _51: game::HorizontalCollisionCheck; + let _52: game::VerticalCollisionCheck; + scope 5 { + debug horizontal => _51; + debug vertical => _52; + let _70: (game::BallDirection, (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)); + scope 6 { + debug other => _70; + let mut _87: &[&str; 1]; + scope 7 { + } + } + } + } + } + } + } + + bb0: { + _3 = &((*_1).1: game::BallDirection); + _2 = BallDirection::get_vec(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + _5 = &(*_1); + _4 = GameState::delta_time(move _5) -> [return: bb2, unwind continue]; + } + + bb2: { + _9 = (((*_1).0: (u32, u32)).0: u32); + _13 = (_2.0: i16); + _12 = move _13 as f32 (IntToFloat); + _11 = Mul(move _12, _4); + _10 = move _11 as i32 (FloatToInt); + _8 = core::num::::saturating_add_signed(move _9, move _10) -> [return: bb3, unwind continue]; + } + + bb3: { + _16 = const _; + _15 = (_16.0: u32); + _17 = CheckedSub(_15, const _); + assert(!move (_17.1: bool), "attempt to compute `{} - {}`, which would overflow", move _15, const _) -> [success: bb4, unwind continue]; + } + + bb4: { + _14 = move (_17.0: u32); + _7 = ::clamp(move _8, const 0_u32, move _14) -> [return: bb5, unwind continue]; + } + + bb5: { + _20 = (((*_1).0: (u32, u32)).1: u32); + _24 = (_2.1: i16); + _23 = move _24 as f32 (IntToFloat); + _22 = Mul(move _23, _4); + _21 = move _22 as i32 (FloatToInt); + _19 = core::num::::saturating_add_signed(move _20, move _21) -> [return: bb6, unwind continue]; + } + + bb6: { + _27 = const _; + _26 = (_27.1: u32); + _28 = CheckedSub(_26, const _); + assert(!move (_28.1: bool), "attempt to compute `{} - {}`, which would overflow", move _26, const _) -> [success: bb7, unwind continue]; + } + + bb7: { + _25 = move (_28.0: u32); + _18 = ::clamp(move _19, const 0_u32, move _25) -> [return: bb8, unwind continue]; + } + + bb8: { + _6 = (move _7, move _18); + _88 = const _; + _31 = _88 as &[&str] (PointerCoercion(Unsize)); + _36 = &((*_1).0: (u32, u32)); + _35 = core::fmt::rt::Argument::<'_>::new_debug::<(u32, u32)>(_36) -> [return: bb9, unwind continue]; + } + + bb9: { + _38 = &_6; + _37 = core::fmt::rt::Argument::<'_>::new_debug::<(u32, u32)>(_38) -> [return: bb10, unwind continue]; + } + + bb10: { + _34 = [move _35, move _37]; + _33 = &_34; + _32 = _33 as &[core::fmt::rt::Argument<'_>] (PointerCoercion(Unsize)); + _30 = Arguments::<'_>::new_v1(move _31, move _32) -> [return: bb11, unwind continue]; + } + + bb11: { + _29 = _print(move _30) -> [return: bb12, unwind continue]; + } + + bb12: { + _39 = _6; + ((*_1).0: (u32, u32)) = move _39; + _43 = (_6.0: u32); + _42 = core::num::::saturating_sub(move _43, const _) -> [return: bb13, unwind continue]; + } + + bb13: { + _45 = (_6.1: u32); + _44 = core::num::::saturating_sub(move _45, const _) -> [return: bb14, unwind continue]; + } + + bb14: { + _41 = (move _42, move _44); + _48 = CheckedMul(const _, const 2_u32); + assert(!move (_48.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb15, unwind continue]; + } + + bb15: { + _47 = move (_48.0: u32); + _50 = CheckedMul(const _, const 2_u32); + assert(!move (_50.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb16, unwind continue]; + } + + bb16: { + _49 = move (_50.0: u32); + _46 = (move _47, move _49); + _40 = CollisionCheck::check_field(move _41, move _46) -> [return: bb17, unwind continue]; + } + + bb17: { + _51 = (_40.0: game::HorizontalCollisionCheck); + _52 = (_40.1: game::VerticalCollisionCheck); + _55 = ((*_1).1: game::BallDirection); + _56 = (_51, _52); + _54 = (move _55, move _56); + _69 = discriminant((_54.0: game::BallDirection)); + switchInt(move _69) -> [0: bb18, 1: bb22, 2: bb25, 3: bb28, otherwise: bb40]; + } + + bb18: { + _59 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).0: game::HorizontalCollisionCheck)); + switchInt(move _59) -> [0: bb19, 2: bb21, otherwise: bb20]; + } + + bb19: { + _57 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _57) -> [0: bb31, 1: bb32, otherwise: bb20]; + } + + bb20: { + _70 = _54; + _87 = const _; + _73 = _87 as &[&str] (PointerCoercion(Unsize)); + _78 = &_70; + _77 = core::fmt::rt::Argument::<'_>::new_debug::<(BallDirection, (HorizontalCollisionCheck, VerticalCollisionCheck))>(_78) -> [return: bb35, unwind continue]; + } + + bb21: { + _58 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _58) -> [0: bb33, 1: bb34, otherwise: bb20]; + } + + bb22: { + _62 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).0: game::HorizontalCollisionCheck)); + switchInt(move _62) -> [0: bb23, 2: bb24, otherwise: bb20]; + } + + bb23: { + _60 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _60) -> [0: bb32, 2: bb31, otherwise: bb20]; + } + + bb24: { + _61 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _61) -> [0: bb34, 2: bb33, otherwise: bb20]; + } + + bb25: { + _65 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).0: game::HorizontalCollisionCheck)); + switchInt(move _65) -> [0: bb26, 1: bb27, otherwise: bb20]; + } + + bb26: { + _63 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _63) -> [0: bb33, 1: bb34, otherwise: bb20]; + } + + bb27: { + _64 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _64) -> [0: bb31, 1: bb32, otherwise: bb20]; + } + + bb28: { + _68 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).0: game::HorizontalCollisionCheck)); + switchInt(move _68) -> [0: bb29, 1: bb30, otherwise: bb20]; + } + + bb29: { + _66 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _66) -> [0: bb34, 2: bb33, otherwise: bb20]; + } + + bb30: { + _67 = discriminant(((_54.1: (game::HorizontalCollisionCheck, game::VerticalCollisionCheck)).1: game::VerticalCollisionCheck)); + switchInt(move _67) -> [0: bb32, 1: bb31, otherwise: bb20]; + } + + bb31: { + _53 = BallDirection::RightUp; + goto -> bb39; + } + + bb32: { + _53 = BallDirection::RightDown; + goto -> bb39; + } + + bb33: { + _53 = BallDirection::LeftUp; + goto -> bb39; + } + + bb34: { + _53 = BallDirection::LeftDown; + goto -> bb39; + } + + bb35: { + _76 = [move _77]; + _75 = &_76; + _74 = _75 as &[core::fmt::rt::Argument<'_>] (PointerCoercion(Unsize)); + _83 = core::fmt::rt::Alignment::Unknown; + _84 = core::fmt::rt::Count::Implied; + _85 = core::fmt::rt::Count::Implied; + _82 = core::fmt::rt::Placeholder::new(const 0_usize, const ' ', move _83, const 4_u32, move _84, move _85) -> [return: bb36, unwind continue]; + } + + bb36: { + _81 = [move _82]; + _80 = &_81; + _79 = _80 as &[core::fmt::rt::Placeholder] (PointerCoercion(Unsize)); + _86 = core::fmt::rt::UnsafeArg::new() -> [return: bb37, unwind continue]; + } + + bb37: { + _72 = Arguments::<'_>::new_v1_formatted(move _73, move _74, move _79, const core::fmt::rt::UnsafeArg {{ _private: () }}) -> [return: bb38, unwind continue]; + } + + bb38: { + _71 = panic_fmt(move _72) -> unwind continue; + } + + bb39: { + ((*_1).1: game::BallDirection) = move _53; + return; + } + + bb40: { + unreachable; + } +} + +promoted[0] in game::::move_ball: &[&str; 1] = { + let mut _0: &[&str; 1]; + let mut _1: [&str; 1]; + + bb0: { + _1 = [const "Invalid collision: "]; + _0 = &_1; + return; + } +} + +promoted[1] in game::::move_ball: &[&str; 3] = { + let mut _0: &[&str; 3]; + let mut _1: [&str; 3]; + + bb0: { + _1 = [const "", const " -> ", const "\n"]; + _0 = &_1; + return; + } +} + +fn game::::delta_time(_1: &GameState) -> f32 { + debug self => _1; + let mut _0: f32; + let mut _2: f32; + let mut _3: u128; + let mut _4: &std::time::Duration; + let _5: std::time::Duration; + let mut _6: &std::time::Instant; + let _7: std::time::Instant; + let mut _8: std::time::Instant; + + bb0: { + _7 = Instant::now() -> [return: bb1, unwind continue]; + } + + bb1: { + _6 = &_7; + _8 = ((*_1).5: std::time::Instant); + _5 = Instant::duration_since(move _6, move _8) -> [return: bb2, unwind continue]; + } + + bb2: { + _4 = &_5; + _3 = Duration::as_millis(move _4) -> [return: bb3, unwind continue]; + } + + bb3: { + _2 = move _3 as f32 (IntToFloat); + _0 = Div(move _2, const _); + return; + } +} + +fn game::::render_field(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (u32, u32)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let _4: (u32, u32); + let mut _5: u32; + let mut _6: u32; + let mut _7: u32; + let mut _8: bool; + let mut _9: u32; + let mut _10: u32; + let mut _11: (u32, u32); + let mut _12: bool; + let mut _13: u32; + let mut _14: u32; + let mut _15: u32; + let mut _16: bool; + let mut _17: u32; + let mut _18: u32; + let mut _19: (u32, u32); + let mut _20: bool; + let _21: (); + let mut _22: (u32, u32); + let mut _23: u32; + let mut _24: u32; + let mut _25: u32; + let mut _26: u32; + let mut _27: (u32, u32); + let mut _28: u32; + let mut _29: u32; + let mut _30: (u32, u32); + let mut _31: u32; + let mut _32: (u32, bool); + let _33: (); + let mut _34: (u32, u32); + let mut _35: u32; + let mut _36: u32; + let mut _37: u32; + let mut _38: (u32, u32); + let mut _39: u32; + let mut _40: (u32, u32); + let mut _41: u32; + let mut _42: (u32, u32); + let _43: (); + let mut _44: (u32, u32); + let mut _45: u32; + let mut _46: u32; + let mut _47: u32; + let mut _48: u32; + let mut _49: u32; + let mut _50: (u32, u32); + let mut _51: (u32, u32); + let mut _52: u32; + let mut _53: u32; + let mut _54: (u32, u32); + let mut _55: u32; + let mut _56: (u32, bool); + let _57: (); + let mut _58: (u32, u32); + let mut _59: u32; + let mut _60: u32; + let mut _61: u32; + let mut _62: (u32, u32); + let mut _63: u32; + let mut _64: (u32, u32); + let mut _65: (u32, u32); + let mut _66: u32; + let mut _67: u32; + let mut _68: u32; + let mut _69: bool; + let mut _70: u32; + let mut _71: bool; + let mut _72: (u32, bool); + let mut _73: u32; + let mut _74: (u32, u32); + let mut _75: u32; + let mut _76: (u32, u32); + scope 1 { + debug field_pos => _4; + } + + bb0: { + _7 = (_3.0: u32); + _8 = Eq(const 2_u32, const 0_u32); + assert(!move _8, "attempt to divide `{}` by zero", _7) -> [success: bb1, unwind continue]; + } + + bb1: { + _6 = Div(move _7, const 2_u32); + _11 = const _; + _10 = (_11.0: u32); + _12 = Eq(const 2_u32, const 0_u32); + assert(!move _12, "attempt to divide `{}` by zero", _10) -> [success: bb2, unwind continue]; + } + + bb2: { + _9 = Div(move _10, const 2_u32); + _5 = core::num::::saturating_sub(move _6, move _9) -> [return: bb3, unwind continue]; + } + + bb3: { + _15 = (_3.1: u32); + _16 = Eq(const 2_u32, const 0_u32); + assert(!move _16, "attempt to divide `{}` by zero", _15) -> [success: bb4, unwind continue]; + } + + bb4: { + _14 = Div(move _15, const 2_u32); + _19 = const _; + _18 = (_19.1: u32); + _20 = Eq(const 2_u32, const 0_u32); + assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb5, unwind continue]; + } + + bb5: { + _17 = Div(move _18, const 2_u32); + _13 = core::num::::saturating_sub(move _14, move _17) -> [return: bb6, unwind continue]; + } + + bb6: { + _4 = (move _5, move _13); + _24 = (_4.0: u32); + _23 = core::num::::saturating_sub(move _24, const _) -> [return: bb7, unwind continue]; + } + + bb7: { + _26 = (_4.1: u32); + _25 = core::num::::saturating_sub(move _26, const _) -> [return: bb8, unwind continue]; + } + + bb8: { + _22 = (move _23, move _25); + _30 = const _; + _29 = (_30.0: u32); + _32 = CheckedMul(const _, const 2_u32); + assert(!move (_32.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb9, unwind continue]; + } + + bb9: { + _31 = move (_32.0: u32); + _28 = core::num::::saturating_add(move _29, move _31) -> [return: bb10, unwind continue]; + } + + bb10: { + _27 = (move _28, const _); + _21 = draw_rect(_2, _3, move _22, move _27, const 16711680_u32) -> [return: bb11, unwind continue]; + } + + bb11: { + _36 = (_4.0: u32); + _38 = const _; + _37 = (_38.0: u32); + _35 = core::num::::saturating_add(move _36, move _37) -> [return: bb12, unwind continue]; + } + + bb12: { + _39 = (_4.1: u32); + _34 = (move _35, move _39); + _42 = const _; + _41 = (_42.1: u32); + _40 = (const _, move _41); + _33 = draw_rect(_2, _3, move _34, move _40, const 65280_u32) -> [return: bb13, unwind continue]; + } + + bb13: { + _46 = (_4.0: u32); + _45 = core::num::::saturating_sub(move _46, const _) -> [return: bb14, unwind continue]; + } + + bb14: { + _48 = (_4.1: u32); + _50 = const _; + _49 = (_50.1: u32); + _47 = core::num::::saturating_add(move _48, move _49) -> [return: bb15, unwind continue]; + } + + bb15: { + _44 = (move _45, move _47); + _54 = const _; + _53 = (_54.0: u32); + _56 = CheckedMul(const _, const 2_u32); + assert(!move (_56.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb16, unwind continue]; + } + + bb16: { + _55 = move (_56.0: u32); + _52 = core::num::::saturating_add(move _53, move _55) -> [return: bb17, unwind continue]; + } + + bb17: { + _51 = (move _52, const _); + _43 = draw_rect(_2, _3, move _44, move _51, const 16711935_u32) -> [return: bb18, unwind continue]; + } + + bb18: { + _60 = (_4.0: u32); + _59 = core::num::::saturating_sub(move _60, const _) -> [return: bb19, unwind continue]; + } + + bb19: { + _61 = (_4.1: u32); + _58 = (move _59, move _61); + _64 = const _; + _63 = (_64.1: u32); + _62 = (const _, move _63); + _57 = draw_rect(_2, _3, move _58, move _62, const 65535_u32) -> [return: bb20, unwind continue]; + } + + bb20: { + _68 = (_3.0: u32); + _69 = Eq(const 2_u32, const 0_u32); + assert(!move _69, "attempt to divide `{}` by zero", _68) -> [success: bb21, unwind continue]; + } + + bb21: { + _67 = Div(move _68, const 2_u32); + _71 = Eq(const 2_u32, const 0_u32); + assert(!move _71, "attempt to divide `{}` by zero", const _) -> [success: bb22, unwind continue]; + } + + bb22: { + _70 = Div(const _, const 2_u32); + _72 = CheckedSub(_67, _70); + assert(!move (_72.1: bool), "attempt to compute `{} - {}`, which would overflow", move _67, move _70) -> [success: bb23, unwind continue]; + } + + bb23: { + _66 = move (_72.0: u32); + _73 = (_4.1: u32); + _65 = (move _66, move _73); + _76 = const _; + _75 = (_76.1: u32); + _74 = (const _, move _75); + _0 = draw_rect(_2, _3, move _65, move _74, const 8355711_u32) -> [return: bb24, unwind continue]; + } + + bb24: { + return; + } +} + +fn game::::render_ball(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (u32, u32)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let _4: (u32, u32); + let mut _5: u32; + let mut _6: u32; + let mut _7: u32; + let mut _8: bool; + let mut _9: u32; + let mut _10: u32; + let mut _11: (u32, u32); + let mut _12: bool; + let mut _13: u32; + let mut _14: u32; + let mut _15: u32; + let mut _16: bool; + let mut _17: u32; + let mut _18: u32; + let mut _19: (u32, u32); + let mut _20: bool; + let mut _22: u32; + let mut _23: u32; + let mut _24: u32; + let mut _25: u32; + let mut _26: (u32, bool); + let mut _27: u32; + let mut _28: u32; + let mut _29: u32; + let mut _30: u32; + let mut _31: (u32, bool); + let _32: (); + let mut _33: (u32, u32); + let mut _34: u32; + let mut _35: (u32, bool); + let mut _36: u32; + let mut _37: (u32, bool); + scope 1 { + debug field_pos => _4; + let _21: (u32, u32); + scope 2 { + debug ball_render_pos => _21; + } + } + + bb0: { + _7 = (_3.0: u32); + _8 = Eq(const 2_u32, const 0_u32); + assert(!move _8, "attempt to divide `{}` by zero", _7) -> [success: bb1, unwind continue]; + } + + bb1: { + _6 = Div(move _7, const 2_u32); + _11 = const _; + _10 = (_11.0: u32); + _12 = Eq(const 2_u32, const 0_u32); + assert(!move _12, "attempt to divide `{}` by zero", _10) -> [success: bb2, unwind continue]; + } + + bb2: { + _9 = Div(move _10, const 2_u32); + _5 = core::num::::saturating_sub(move _6, move _9) -> [return: bb3, unwind continue]; + } + + bb3: { + _15 = (_3.1: u32); + _16 = Eq(const 2_u32, const 0_u32); + assert(!move _16, "attempt to divide `{}` by zero", _15) -> [success: bb4, unwind continue]; + } + + bb4: { + _14 = Div(move _15, const 2_u32); + _19 = const _; + _18 = (_19.1: u32); + _20 = Eq(const 2_u32, const 0_u32); + assert(!move _20, "attempt to divide `{}` by zero", _18) -> [success: bb5, unwind continue]; + } + + bb5: { + _17 = Div(move _18, const 2_u32); + _13 = core::num::::saturating_sub(move _14, move _17) -> [return: bb6, unwind continue]; + } + + bb6: { + _4 = (move _5, move _13); + _24 = (((*_1).0: (u32, u32)).0: u32); + _25 = (_4.0: u32); + _26 = CheckedAdd(_24, _25); + assert(!move (_26.1: bool), "attempt to compute `{} + {}`, which would overflow", move _24, move _25) -> [success: bb7, unwind continue]; + } + + bb7: { + _23 = move (_26.0: u32); + _22 = core::num::::saturating_sub(move _23, const _) -> [return: bb8, unwind continue]; + } + + bb8: { + _29 = (((*_1).0: (u32, u32)).1: u32); + _30 = (_4.1: u32); + _31 = CheckedAdd(_29, _30); + assert(!move (_31.1: bool), "attempt to compute `{} + {}`, which would overflow", move _29, move _30) -> [success: bb9, unwind continue]; + } + + bb9: { + _28 = move (_31.0: u32); + _27 = core::num::::saturating_sub(move _28, const _) -> [return: bb10, unwind continue]; + } + + bb10: { + _21 = (move _22, move _27); + _35 = CheckedMul(const _, const 2_u32); + assert(!move (_35.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb11, unwind continue]; + } + + bb11: { + _34 = move (_35.0: u32); + _37 = CheckedMul(const _, const 2_u32); + assert(!move (_37.1: bool), "attempt to compute `{} * {}`, which would overflow", const _, const 2_u32) -> [success: bb12, unwind continue]; + } + + bb12: { + _36 = move (_37.0: u32); + _33 = (move _34, move _36); + _32 = draw_rect(_2, _3, _21, move _33, const 16777215_u32) -> [return: bb13, unwind continue]; + } + + bb13: { + return; + } +} + +fn game::::render_paddles(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (u32, u32)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let mut _4: !; + + bb0: { + _4 = core::panicking::panic(const "not yet implemented") -> unwind continue; + } +} + +fn game::::render_paddle(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (u32, u32)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let mut _4: !; + + bb0: { + _4 = core::panicking::panic(const "not yet implemented") -> unwind continue; + } +} + +fn game::::render_scores(_1: &GameState, _2: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _3: (u32, u32)) -> () { + debug self => _1; + debug buf => _2; + debug win_size => _3; + let mut _0: (); + let mut _4: !; + + bb0: { + _4 = core::panicking::panic(const "not yet implemented") -> unwind continue; + } +} + +fn draw_rect(_1: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, _2: (u32, u32), _3: (u32, u32), _4: (u32, u32), _5: u32) -> () { + debug buf => _1; + debug buf_size => _2; + debug pos => _3; + debug size => _4; + debug color => _5; + let mut _0: (); + let mut _6: std::ops::Range; + let mut _7: std::ops::Range; + let mut _8: u32; + let mut _9: u32; + let mut _10: u32; + let mut _11: u32; + let mut _12: (u32, bool); + let mut _13: std::ops::Range; + let mut _14: std::option::Option; + let mut _15: &mut std::ops::Range; + let mut _16: isize; + let mut _18: std::ops::Range; + let mut _19: std::ops::Range; + let mut _20: u32; + let mut _21: u32; + let mut _22: u32; + let mut _23: u32; + let mut _24: (u32, bool); + let mut _26: std::option::Option; + let mut _27: &mut std::ops::Range; + let mut _28: isize; + let mut _31: usize; + let mut _32: usize; + let mut _33: usize; + let mut _34: u32; + let mut _35: (usize, bool); + let mut _36: usize; + let mut _37: (usize, bool); + let mut _38: &mut [u32]; + let mut _39: usize; + let mut _40: bool; + scope 1 { + debug iter => _13; + let _17: u32; + scope 2 { + debug y => _17; + let mut _25: std::ops::Range; + scope 3 { + debug iter => _25; + let _29: u32; + scope 4 { + debug x => _29; + let _30: usize; + scope 5 { + debug index => _30; + } + } + } + } + } + + bb0: { + _8 = (_3.1: u32); + _10 = (_3.1: u32); + _11 = (_4.1: u32); + _12 = CheckedAdd(_10, _11); + assert(!move (_12.1: bool), "attempt to compute `{} + {}`, which would overflow", move _10, move _11) -> [success: bb1, unwind continue]; + } + + bb1: { + _9 = move (_12.0: u32); + _7 = std::ops::Range:: { start: move _8, end: move _9 }; + _6 = as IntoIterator>::into_iter(move _7) -> [return: bb2, unwind continue]; + } + + bb2: { + _13 = move _6; + goto -> bb3; + } + + bb3: { + _15 = &mut _13; + _14 = as Iterator>::next(_15) -> [return: bb4, unwind continue]; + } + + bb4: { + _16 = discriminant(_14); + switchInt(move _16) -> [0: bb6, 1: bb5, otherwise: bb16]; + } + + bb5: { + _17 = ((_14 as Some).0: u32); + _20 = (_3.0: u32); + _22 = (_3.0: u32); + _23 = (_4.0: u32); + _24 = CheckedAdd(_22, _23); + assert(!move (_24.1: bool), "attempt to compute `{} + {}`, which would overflow", move _22, move _23) -> [success: bb7, unwind continue]; + } + + bb6: { + return; + } + + bb7: { + _21 = move (_24.0: u32); + _19 = std::ops::Range:: { start: move _20, end: move _21 }; + _18 = as IntoIterator>::into_iter(move _19) -> [return: bb8, unwind continue]; + } + + bb8: { + _25 = move _18; + goto -> bb9; + } + + bb9: { + _27 = &mut _25; + _26 = as Iterator>::next(_27) -> [return: bb10, unwind continue]; + } + + bb10: { + _28 = discriminant(_26); + switchInt(move _28) -> [0: bb3, 1: bb11, otherwise: bb16]; + } + + bb11: { + _29 = ((_26 as Some).0: u32); + _32 = _17 as usize (IntToInt); + _34 = (_2.0: u32); + _33 = move _34 as usize (IntToInt); + _35 = CheckedMul(_32, _33); + assert(!move (_35.1: bool), "attempt to compute `{} * {}`, which would overflow", move _32, move _33) -> [success: bb12, unwind continue]; + } + + bb12: { + _31 = move (_35.0: usize); + _36 = _29 as usize (IntToInt); + _37 = CheckedAdd(_31, _36); + assert(!move (_37.1: bool), "attempt to compute `{} + {}`, which would overflow", move _31, move _36) -> [success: bb13, unwind continue]; + } + + bb13: { + _30 = move (_37.0: usize); + _38 = , WindowHandle<'_>> as DerefMut>::deref_mut(_1) -> [return: bb14, unwind continue]; + } + + bb14: { + _39 = Len((*_38)); + _40 = Lt(_30, _39); + assert(move _40, "index out of bounds: the length is {} but the index is {}", move _39, _30) -> [success: bb15, unwind continue]; + } + + bb15: { + (*_38)[_30] = _5; + goto -> bb9; + } + + bb16: { + unreachable; + } +} + +fn CollisionCheck(_1: HorizontalCollisionCheck, _2: VerticalCollisionCheck) -> CollisionCheck { + let mut _0: game::CollisionCheck; + + bb0: { + _0 = CollisionCheck(move _1, move _2); + return; + } +} + +// MIR FOR CTFE +fn CollisionCheck(_1: HorizontalCollisionCheck, _2: VerticalCollisionCheck) -> CollisionCheck { + let mut _0: game::CollisionCheck; + + bb0: { + _0 = CollisionCheck(move _1, move _2); + return; + } +} diff --git a/flake.nix b/flake.nix index 87be8fe..20718dc 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,7 @@ libxkbcommon xorg.libXi xorg.libXcursor + cargo-watch ]; }) ]; diff --git a/src/main.rs b/src/main.rs index fede4fe..2360ec0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,11 @@ -use std::num::NonZeroU32; +use std::{ + num::NonZeroU32, + time::{Duration, Instant}, +}; +use game::GameState; use winit::{ + dpi::PhysicalSize, event::{Event, KeyEvent, WindowEvent}, event_loop::{ControlFlow, EventLoop}, keyboard::{Key, NamedKey}, @@ -10,7 +15,10 @@ use winit::{ fn main() { let event_loop = EventLoop::new().unwrap(); - let window = WindowBuilder::new().build(&event_loop).unwrap(); + let window = WindowBuilder::new() + .with_inner_size(winit::dpi::Size::Physical(PhysicalSize::new(1200, 700))) + .build(&event_loop) + .unwrap(); // ControlFlow::Poll continuously runs the event loop, even if the OS hasn't // dispatched any events. This is ideal for games and similar applications. @@ -24,9 +32,13 @@ fn main() { let context = softbuffer::Context::new(window.display_handle().unwrap()).unwrap(); let mut surface = softbuffer::Surface::new(&context, window.window_handle().unwrap()).unwrap(); + let mut game = GameState::init(); + event_loop .run(|event, elwt| { - elwt.set_control_flow(ControlFlow::Wait); + elwt.set_control_flow(ControlFlow::WaitUntil( + Instant::now() + Duration::from_millis(1000 / 60), + )); match event { Event::WindowEvent { @@ -51,6 +63,8 @@ fn main() { // } buffer.fill(0); + game.update(); + game.render(&mut buffer, (width, height)); buffer.present().unwrap(); } @@ -75,3 +89,360 @@ fn main() { }) .unwrap(); } + +mod game { + use std::{convert::identity, num::NonZeroU32, time::Instant}; + + use softbuffer::Buffer; + use winit::raw_window_handle::{DisplayHandle, WindowHandle}; + + const PADDLE_SIZE: (u32, u32) = (5, 50); + const BALL_RADIUS: u32 = 10; + const BALL_VEC_RIGHT_DOWN: (i16, i16) = (8, 12); + const FIELD_SIZE: (u32, u32) = (1200, 700); + const FIELD_BORDER_WIDTH: u32 = 5; + const TICK_LEN: f32 = 1000. / 60.; + + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + enum BallDirection { + RightUp, + RightDown, + LeftUp, + LeftDown, + } + + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + enum HorizontalCollisionCheck { + None, + Left, + Right, + } + + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + enum VerticalCollisionCheck { + None, + Top, + Bottom, + } + + #[derive(Debug, Clone, Copy, PartialEq, Eq)] + struct CollisionCheck(HorizontalCollisionCheck, VerticalCollisionCheck); + + impl CollisionCheck { + fn check_field(obj_pos: (u32, u32), obj_size: (u32, u32)) -> Self { + let horizontal = if obj_pos.0 == 0 { + HorizontalCollisionCheck::Left + } else if (obj_pos.0 + obj_size.0) >= FIELD_SIZE.0 { + HorizontalCollisionCheck::Right + } else { + HorizontalCollisionCheck::None + }; + let vertical = if obj_pos.1 == 0 { + VerticalCollisionCheck::Top + } else if (obj_pos.1 + obj_size.1) >= FIELD_SIZE.1 { + VerticalCollisionCheck::Bottom + } else { + VerticalCollisionCheck::None + }; + Self(horizontal, vertical) + } + + fn no_collisions(&self) -> bool { + matches!( + self, + CollisionCheck(HorizontalCollisionCheck::None, VerticalCollisionCheck::None) + ) + } + } + + struct MovingObject { + prev_pos: (u32, u32), + } + + impl BallDirection { + fn get_vec(&self) -> (i16, i16) { + match self { + BallDirection::RightDown => BALL_VEC_RIGHT_DOWN, + BallDirection::RightUp => (BALL_VEC_RIGHT_DOWN.0, -BALL_VEC_RIGHT_DOWN.1), + BallDirection::LeftUp => (-BALL_VEC_RIGHT_DOWN.0, BALL_VEC_RIGHT_DOWN.1), + BallDirection::LeftDown => (-BALL_VEC_RIGHT_DOWN.0, -BALL_VEC_RIGHT_DOWN.1), + } + } + } + + pub struct GameState { + ball_pos: (u32, u32), + ball_direction: BallDirection, + paddle_r_pos: u32, + paddle_y_pos: u32, + scores: (u32, u32), + last_frame_time: Instant, + } + + impl GameState { + pub fn init() -> Self { + Self { + ball_pos: (FIELD_SIZE.0 / 2, FIELD_SIZE.1 / 2), + paddle_r_pos: FIELD_SIZE.0 / 2, + paddle_y_pos: FIELD_SIZE.0 / 2, + ball_direction: BallDirection::RightDown, + scores: (0, 0), + last_frame_time: Instant::now(), + } + } + + pub fn render( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (NonZeroU32, NonZeroU32), + ) { + let win_size = (win_size.0.get(), win_size.1.get()); + self.render_field(buf, win_size); + self.render_ball(buf, win_size); + } + + pub fn update(&mut self) { + let delta_t = self.delta_time(); + + self.last_frame_time = Instant::now(); + self.move_ball(); + } + + fn move_ball(&mut self) { + let vec = self.ball_direction.get_vec(); + let delta_t = self.delta_time(); + + let new_pos = ( + self.ball_pos + .0 + .saturating_add_signed((vec.0 as f32 * delta_t) as i32) + .clamp(0, FIELD_SIZE.0 - BALL_RADIUS), + self.ball_pos + .1 + .saturating_add_signed((vec.1 as f32 * delta_t) as i32) + .clamp(0, FIELD_SIZE.1 - BALL_RADIUS), + ); + // println!("{:?} -> {:?}", self.ball_pos, new_pos); + self.ball_pos = new_pos; + + let check_res = CollisionCheck::check_field( + ( + new_pos.0.saturating_sub(BALL_RADIUS), + new_pos.1.saturating_sub(BALL_RADIUS), + ), + (BALL_RADIUS * 2, BALL_RADIUS * 2), + ); + + let CollisionCheck(horizontal, vertical) = check_res; + + self.ball_direction = match (self.ball_direction, (horizontal, vertical)) { + ( + BallDirection::RightUp, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::Bottom), + ) + | ( + BallDirection::RightDown, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::None), + ) + | ( + BallDirection::LeftUp, + (HorizontalCollisionCheck::Left, VerticalCollisionCheck::None), + ) + | ( + BallDirection::LeftDown, + (HorizontalCollisionCheck::Left, VerticalCollisionCheck::Top), + ) => BallDirection::RightDown, + + ( + BallDirection::RightUp, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::None), + ) + | ( + BallDirection::RightDown, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::Top), + ) + | ( + BallDirection::LeftUp, + (HorizontalCollisionCheck::Left, VerticalCollisionCheck::Top), + ) + | ( + BallDirection::LeftDown, + (HorizontalCollisionCheck::Left, VerticalCollisionCheck::None), + ) => BallDirection::RightUp, + + ( + BallDirection::RightUp, + (HorizontalCollisionCheck::Right, VerticalCollisionCheck::Bottom), + ) + | ( + BallDirection::RightDown, + (HorizontalCollisionCheck::Right, VerticalCollisionCheck::None), + ) + | ( + BallDirection::LeftUp, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::None), + ) + | ( + BallDirection::LeftDown, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::Bottom), + ) => BallDirection::LeftUp, + + ( + BallDirection::RightUp, + (HorizontalCollisionCheck::Right, VerticalCollisionCheck::None), + ) + | ( + BallDirection::RightDown, + (HorizontalCollisionCheck::Right, VerticalCollisionCheck::Top), + ) + | ( + BallDirection::LeftUp, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::Top), + ) + | ( + BallDirection::LeftDown, + (HorizontalCollisionCheck::None, VerticalCollisionCheck::None), + ) => BallDirection::LeftDown, + + other => panic!("Invalid collision: {other:#?}"), + }; + } + + fn delta_time(&self) -> f32 { + Instant::now() + .duration_since(self.last_frame_time) + .as_millis() as f32 + / TICK_LEN + } + + fn render_field( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (u32, u32), + ) { + let field_pos = ( + (win_size.0 / 2).saturating_sub(FIELD_SIZE.0 / 2), + (win_size.1 / 2).saturating_sub(FIELD_SIZE.1 / 2), + ); + + // top border + draw_rect( + buf, + win_size, + ( + field_pos.0.saturating_sub(FIELD_BORDER_WIDTH), + field_pos.1.saturating_sub(FIELD_BORDER_WIDTH), + ), + ( + FIELD_SIZE.0.saturating_add(FIELD_BORDER_WIDTH * 2), + FIELD_BORDER_WIDTH, + ), + 0xff0000, + ); + // right border + draw_rect( + buf, + win_size, + (field_pos.0.saturating_add(FIELD_SIZE.0), field_pos.1), + (FIELD_BORDER_WIDTH, FIELD_SIZE.1), + 0x00ff00, + ); + // bottom border + draw_rect( + buf, + win_size, + ( + field_pos.0.saturating_sub(FIELD_BORDER_WIDTH), + field_pos.1.saturating_add(FIELD_SIZE.1), + ), + ( + FIELD_SIZE.0.saturating_add(FIELD_BORDER_WIDTH * 2), + FIELD_BORDER_WIDTH, + ), + 0xff00ff, + ); + // left border + draw_rect( + buf, + win_size, + (field_pos.0.saturating_sub(FIELD_BORDER_WIDTH), field_pos.1), + (FIELD_BORDER_WIDTH, FIELD_SIZE.1), + 0x00ffff, + ); + // draw midline + draw_rect( + buf, + win_size, + ((win_size.0 / 2) - (FIELD_BORDER_WIDTH / 2), field_pos.1), + (FIELD_BORDER_WIDTH, FIELD_SIZE.1), + 0x7f7f7f, + ) + } + fn render_ball( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (u32, u32), + ) { + let field_pos = ( + (win_size.0 / 2).saturating_sub(FIELD_SIZE.0 / 2), + (win_size.1 / 2).saturating_sub(FIELD_SIZE.1 / 2), + ); + // let field_pos = identity(( + // (win_size.0 / 2).saturating_sub(FIELD_SIZE.0 / 2), + // (win_size.1 / 2).saturating_sub(FIELD_SIZE.1 / 2), + // )); + // println!("{}, {}", field_pos.0, field_pos.1); + + let ball_render_pos = ( + (self.ball_pos.0 + field_pos.0).saturating_sub(BALL_RADIUS), + (self.ball_pos.1 + field_pos.1).saturating_sub(BALL_RADIUS), + ); + + draw_rect( + buf, + win_size, + ball_render_pos, + (BALL_RADIUS * 2, BALL_RADIUS * 2), + 0xffffff, + ); + } + fn render_paddles( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (u32, u32), + ) { + todo!() + } + fn render_paddle( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (u32, u32), + ) { + todo!() + } + fn render_scores( + &self, + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + win_size: (u32, u32), + ) { + todo!() + } + } + + fn draw_rect( + buf: &mut Buffer<'_, DisplayHandle<'_>, WindowHandle<'_>>, + buf_size: (u32, u32), + pos: (u32, u32), + size: (u32, u32), + color: u32, + ) { + for y in pos.1..(pos.1 + size.1) { + for x in pos.0..(pos.0 + size.0) { + let index = y as usize * buf_size.0 as usize + x as usize; + if let Some(px) = buf.get_mut(index) { + *px = color + } + } + } + } +}