<commit_before>use std::default::Default;

pub struct Chip8 {
    /*
     * 0x000-0x1FF - Chip 8 interpreter (contains font set in emu)
     * 0x050-0x0A0 - Used for the built in 4x5 pixel font set (0-F)
     * 0x200-0xFFF - Program ROM and work RAM
     */
    pub memory: [u8; 4096],

    /*
     * CPU registers: The Chip 8 has 15 8-bit general purpose registers
     * named V0,V1 up to VE. The 16th register is used  for the ‘carry flag’.
     */
    pub registers: [u8; 16],

    // Index register
    pub i: u16,

    // program counter
    pub pc: u16,

    // Screen - 64 x 32 pixels
    pub graphics: [u8; 64*32],

    // No timers, but 60hz counters
    pub delay_timer: u8,
    pub sound_timer: u8,

    // Stack needed to jump to certain addresses or call subroutines
    // The chip8 stack has 16 levels
    pub stack_pointer: u16,
    pub stack: [u16; 16],

    // Chip8 keypad had 16 keys - keep track of the kb state
    pub keypad: [u8; 16],
}

impl Default for Chip8 {
    #[inline]
    fn default() -> Chip8 {
        Chip8 {
            memory: [0u8; 4096],

            registers: [0u8; 16],

            i: 0u16,

            pc: 0x200u16,

            graphics: [0u8; 64*32],

            delay_timer: 0u8,
            sound_timer: 0u8,

            stack_pointer: 0u16,
            stack: [0u16; 16],

            keypad: [0u8; 16],
        }
    }
}

impl Chip8 {
   fn cycle(&self) {
        // fetch
        // Decode
        // Execute
        // Update timers
    }
}<commit_msg>fetch the opcode<commit_after>use std::default::Default;

pub struct Chip8 {
    /*
     * 0x000-0x1FF - Chip 8 interpreter (contains font set in emu)
     * 0x050-0x0A0 - Used for the built in 4x5 pixel font set (0-F)
     * 0x200-0xFFF - Program ROM and work RAM
     */
    pub memory: [u8; 4096],

    /*
     * CPU registers: The Chip 8 has 15 8-bit general purpose registers
     * named V0,V1 up to VE. The 16th register is used  for the ‘carry flag’.
     */
    pub registers: [u8; 16],

    // Index register
    pub i: u16,

    // program counter
    pub pc: u16,

    // Screen - 64 x 32 pixels
    pub graphics: [u8; 64*32],

    // No timers, but 60hz counters
    pub delay_timer: u8,
    pub sound_timer: u8,

    // Stack needed to jump to certain addresses or call subroutines
    // The chip8 stack has 16 levels
    pub stack_pointer: u16,
    pub stack: [u16; 16],

    // Chip8 keypad had 16 keys - keep track of the kb state
    pub keypad: [u8; 16],
}

impl Default for Chip8 {
    #[inline]
    fn default() -> Chip8 {
        Chip8 {
            memory: [0u8; 4096],

            registers: [0u8; 16],

            i: 0u16,

            pc: 0x200u16,

            graphics: [0u8; 64*32],

            delay_timer: 0u8,
            sound_timer: 0u8,

            stack_pointer: 0u16,
            stack: [0u16; 16],

            keypad: [0u8; 16],
        }
    }
}

impl Chip8 {
   fn cycle(&mut self) {
        // fetch
        let opcode: u16 = ((self.memory[(self.pc as uint)] as u16) << 8
                           | (self.memory[(self.pc + 1) as uint] as u16));

        // Decode
        // Execute
        // Increment the counter
        self.pc += 2;
        // Update timers
    }
}
{'fraction_non_alphanumeric': 0.10749690210656754, 'fraction_numerical': 0.07465923172242875, 'mean_word_length': 1.6402289452166803, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '290413', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1084, 'n_words': 373}