fn read_screen_state(chip8: &Chip8, screen_state: &mut [u8; 64 * 32 * 3]) -> bool {
    let mut idx = 0;
    let mut update = false;
    for i in 0..(64 * 32) {
        let b = chip8.display[i];
        let (r, g, b) = color(b).rgb();
        if screen_state[idx] != r || screen_state[idx + 1] != g || screen_state[idx + 2] != b {
            screen_state[idx] = r;
            screen_state[idx + 1] = g;
            screen_state[idx + 2] = b;
            update = true
        }
        idx += 3;
    }
    update
}
// read screen from chip8, coloring, if pixel changed, update screen state
read screen from chip8, coloring, if pixel changed, update screen state
read screen from chip8 coloring if pixel changed update screen state
fn read_screen_state(chip8: &Chip8, screen_state: &mut [u8; 64 * 32 * 3]) -> bool {
    let mut idx = 0;
    let mut update = false;
    for i in 0..(64 * 32) {
        let b = chip8.display[i];
        let (r, g, b) = color(b).rgb();
        if screen_state[idx] != r || screen_state[idx + 1] != g || screen_state[idx + 2] != b {
            screen_state[idx] = r;
            screen_state[idx + 1] = g;
            screen_state[idx + 2] = b;
            update = true
        }
        idx += 3;
    }
    update
}
fn read_screen_state ( chip8 : & Chip8 , screen_state : & mut [ u8 ; 64 * 32 * 3 ] ) -> bool { let mut idx = 0 ; let mut update = false ; for i in 0 .. ( 64 * 32 ) { let b = chip8 . display [ i ] ; let ( r , g , b ) = color ( b ) . rgb ( ) ; if screen_state [ idx ] != r || screen_state [ idx + 1 ] != g || screen_state [ idx + 2 ] != b { screen_state [ idx ] = r ; screen_state [ idx + 1 ] = g ; screen_state [ idx + 2 ] = b ; update = true } idx += 3 ; } update }
read screen from chip8, coloring, if pixel changed, update screen state
read screen from chip8 coloring if pixel changed update screen state
chip8
&Chip8
screen_state
&mut [u8; 64 * 32 * 3]
chip8
&Chip8
screen_state
&mut [u8; 64 * 32 * 3]