pub fn Cycle(&mut self) {
        // Fetch opcode
        //let _: () = self.memory[self.program_counter as usize].checked_shl(8).unwrap_or(0);
        self.op_code = ((self.memory[self.program_counter as usize] as u16).checked_shl(8).unwrap_or(0)) | self.memory[(self.program_counter + 1) as usize] as u16;
        if (self.debug_mode) { 
            eprintln!("Opcode: {}", &self.op_code);
        }
        // increment pc before we do anything
        self.program_counter += 2;

        // decode and execute
        // TODO: actually implement this
        self.table[((self.op_code & 0xF000).checked_shr(12).unwrap_or(0)) as usize](self);

        // Decrement delay timer if it exists
        if (self.delay_timer > 0) {
            self.delay_timer -= 1;
        }

        // Decrement sound timer if it exists
        if (self.sound_timer > 0) {
            self.sound_timer -= 1;
        }

    }
// the opcodes are stored in memory starting from index 512, i need to decode them and map each opcode to one of my functions
// The CHIP-8 Architecture uses big-endian (0x00 0xe0 -> 0x00e0)
the opcodes are stored in memory starting from index 512, i need to decode them and map each opcode to one of my functions
The CHIP-8 Architecture uses big-endian (0x00 0xe0 -> 0x00e0)
the opcodes are stored in memory starting from index 512 i need to decode them and map each opcode to one of my functions The CHIP - 8 Architecture uses big - endian ( 0x00 0xe0 - > 0x00e0 )
pub fn Cycle(&mut self) {
        // Fetch opcode
        //let _: () = self.memory[self.program_counter as usize].checked_shl(8).unwrap_or(0);
        self.op_code = ((self.memory[self.program_counter as usize] as u16).checked_shl(8).unwrap_or(0)) | self.memory[(self.program_counter + 1) as usize] as u16;
        if (self.debug_mode) { 
            eprintln!("Opcode: {}", &self.op_code);
        }
        // increment pc before we do anything
        self.program_counter += 2;
        // decode and execute
        // TODO: actually implement this
        self.table[((self.op_code & 0xF000).checked_shr(12).unwrap_or(0)) as usize](self);
        // Decrement delay timer if it exists
        if (self.delay_timer > 0) {
            self.delay_timer -= 1;
        }
        // Decrement sound timer if it exists
        if (self.sound_timer > 0) {
            self.sound_timer -= 1;
        }
    }
pub fn Cycle ( & mut self ) { // Fetch opcode //let _: () = self.memory[self.program_counter as usize].checked_shl(8).unwrap_or(0); self . op_code = ( ( self . memory [ self . program_counter as usize ] as u16 ) . checked_shl ( 8 ) . unwrap_or ( 0 ) ) | self . memory [ ( self . program_counter + 1 ) as usize ] as u16 ; if ( self . debug_mode ) { eprintln ! ( " " self op_code ) ; } // increment pc before we do anything self . program_counter += 2 ; // decode and execute // TODO: actually implement this self . table [ ( ( self . op_code & 0xF000 ) . checked_shr ( 12 ) . unwrap_or ( 0 ) ) as usize ] ( self ) ; // Decrement delay timer if it exists if ( self . delay_timer > 0 ) { self . delay_timer -= 1 ; } // Decrement sound timer if it exists if ( self . sound_timer > 0 ) { self . sound_timer -= 1 ; } }
the opcodes are stored in memory starting from index 512, i need to decode them and map each opcode to one of my functions
The CHIP-8 Architecture uses big-endian (0x00 0xe0 -> 0x00e0)
the opcodes are stored in memory starting from index 512 i need to decode them and map each opcode to one of my functions The CHIP - 8 Architecture uses big - endian ( 0x00 0xe0 - > 0x00e0 )
&mut self