@@ -75,24 +75,28 @@ fn submain() !void {
7575 agnes .agnes_set_input (ag , & ag_input , 0 );
7676
7777 while (true ) {
78- if (! agnes .agnes_next_frame (ag )) {
79- try console .print ("Next frame failed!\n " , .{});
80- try console .flush ();
81- }
78+ checkKeys ();
79+ var new_frame :bool = false ;
80+ _ = agnes .agnes_tick (ag , & new_frame );
8281
83- var i :usize = 0 ;
84- for (0.. agnes .AGNES_SCREEN_HEIGHT ) | y | {
85- for (0.. agnes .AGNES_SCREEN_WIDTH ) | x | {
86- const c = agnes .agnes_get_screen_pixel (ag , @intCast (x ), @intCast (y ));
87- const c_val = @as (u32 , @intCast (0xFF )) << 24 | @as (u32 , @intCast (c .b )) << 16 | @as (u32 , @intCast (c .g )) << 8 | @as (u32 , @intCast (c .r ));
88- gfxFramebuffer [i ] = c_val ;
89- i += 1 ;
82+ if (new_frame ) {
83+ if (! agnes .agnes_next_frame (ag )) {
84+ try console .print ("Next frame failed!\n " , .{});
85+ try console .flush ();
9086 }
91- }
9287
93- checkKeys ();
88+ var i :usize = 0 ;
89+ for (0.. agnes .AGNES_SCREEN_HEIGHT ) | y | {
90+ for (0.. agnes .AGNES_SCREEN_WIDTH ) | x | {
91+ const c = agnes .agnes_get_screen_pixel (ag , @intCast (x ), @intCast (y ));
92+ const c_val = @as (u32 , @intCast (0xFF )) << 24 | @as (u32 , @intCast (c .b )) << 16 | @as (u32 , @intCast (c .g )) << 8 | @as (u32 , @intCast (c .r ));
93+ gfxFramebuffer [i ] = c_val ;
94+ i += 1 ;
95+ }
96+ }
9497
95- uvm .render (@ptrCast (& gfxFramebuffer ), WIDTH * HEIGHT * 4 );
98+ uvm .render (@ptrCast (& gfxFramebuffer ), WIDTH * HEIGHT * 4 );
99+ }
96100 }
97101}
98102
0 commit comments