diff --git a/cart.wat b/cart.wat index 8626c53..8e88bbf 100644 --- a/cart.wat +++ b/cart.wat @@ -23,12 +23,17 @@ ;; The width of the text, initialized lazily at first TIC ;; A value of zero indicates uninitialization + ;; Offset: 98320 + ;; Length: 8 bytes + ;; Velocity of text, stored in the same manor as position + ;; Length: 12 bytes (data (i32.const 98316) "HI FROM WAT") (func $tic (if (call $is_initted) (call $init)) + (call $update) (call $view)) (func $view (local $pos i64) @@ -48,6 +53,28 @@ (i32.const 3) ;; Scale (i32.const 0)))) ;; Not small font + (func $update (local $newpos v128) (local $tests v128) + (i64.store + (i32.const 98330) + (i64x2.extract_lane 0 + (i32x4.sub + (v128.const i32x4 1 1 1 1) ;; Unit vector + (i32x4.mul + (v128.or ;; Velocities that we need to swap + (i32x4.lt_s ;; Position components < 0 + (v128.const i32x4 0 0 0 0) + (local.tee $newpos ;; Position updated with velocity + (i32x4.add + (v128.load (i32.const 98304)) ;; Position + (v128.load (i32.const 98330))))) ;; Velocity + (i32x4.gt_s + (local.get $newpos) + (v128.const i32x4 239 135 0 0))) ;; Window upper bounds + (i32x4.splat (i32.const 2)))))) + (v128.store + (i32.const 98304) + (local.get $newpos))) + (func $is_initted (result i32) (i32.eqz (i32.load