MCPcopy Create free account
hub / github.com/Ruddle/Fomos / _start

Function _start

app_background/src/main.rs:20–61  ·  view source on GitHub ↗
(ctx: &mut Context<Store>)

Source from the content-addressed store, hash-verified

18
19#[no_mangle]
20pub extern "C" fn _start(ctx: &mut Context<Store>) -> i32 {
21 unsafe { ALLOCATOR.swap(ctx) };
22 unsafe { LOGGER.swap(ctx.log) };
23
24 // (ctx.log)("back start");
25 // x86_64::instructions::interrupts::int3();
26
27 let store: Box<Store>;
28 if let Some(ptr) = ctx.store.take() {
29 store = ptr;
30 } else {
31 st::log("store not found");
32 let pix = imagine::image::Bitmap::try_from_png_bytes(IMG);
33 if pix.is_none() {
34 st::log("No pix");
35 return -1;
36 }
37 store = Box::new(Store { pix: pix.unwrap() })
38 }
39
40 let pix = &store.pix;
41
42 let dx = (libm::cosf((ctx.start_time as f32) * 0.001) * 2.0) as usize;
43
44 for y in 0..ctx.fb.h {
45 for x in 0..ctx.fb.w {
46 let lx = x as f32 / (ctx.fb.w) as f32;
47 let ly = y as f32 / (ctx.fb.h) as f32;
48 let px = (lx * pix.width as f32) as usize;
49 let py = (ly * pix.height as f32) as usize;
50 let v = pix.pixels[px + py * pix.width as usize];
51 let p = &mut ctx.fb.pixels[x + y * ctx.fb.w];
52 p.r = v.r;
53 p.g = v.g;
54 p.b = v.b;
55 }
56 }
57
58 *ctx.store = Some(store);
59
60 return 0;
61}

Callers

nothing calls this directly

Calls 2

logFunction · 0.70
swapMethod · 0.45

Tested by

no test coverage detected