def execute(self, opcode): (_, x_reg, y_reg, _) = get_opcode_digits(opcode) if self.registers.v[x_reg] != self.registers.v[y_reg]: self.program_counter.skip() else: self.program_counter.next()
def execute(self, opcode): (_, reg, _, _) = get_opcode_digits(opcode) value = opcode & 0x00FF if self.registers.v[reg] == value: self.program_counter.skip() else: self.program_counter.next()
def emulate_cycle(self): opcode = int.from_bytes(self.memory.get(self.program_counter.value, 2), byteorder='big') (first_digit, _, _, _) = get_opcode_digits(opcode) opcode_set = self.op_table[first_digit] opcode_set.execute(opcode) self.timers.tick()
def execute(self, opcode): (_, reg, _, opcode_end) = get_opcode_digits(opcode) key_num = self.registers.v[reg] is_pressed = self.keypad.is_pressed(key_num) if (opcode_end == 0xE): self.conditional_skip(is_pressed) else: self.conditional_skip(not is_pressed)
def execute(self, opcode): (_, x_reg, y_reg, last_hex_digit) = get_opcode_digits(opcode) x_value = self.registers.v[x_reg] y_value = self.registers.v[y_reg] if last_hex_digit == 0x000E: op = self.shift_left_8xxE else: op = self.operation_table[last_hex_digit] op(x_reg, x_value, y_value)
def execute(self, opcode): (_, x_coord, y_coord, height) = get_opcode_digits(opcode) self.registers.v[15] = 0 for line_num in range(height): sprite_line = self.memory.get_byte(self.registers.i + line_num) collision = self.graphics.set_sprite_line(x_coord, y_coord + line_num, sprite_line) if collision: self.registers.v[15] = 1 self.program_counter.next()
def execute(self, opcode): (_, reg, _, _) = get_opcode_digits(opcode) value = opcode & 0x00FF self.registers.v[reg] = (self.registers.v[reg] + value) % 256 self.program_counter.next()
def execute(self, opcode): (_, reg, _, _) = get_opcode_digits(opcode) val = opcode & 0x00FF self.registers.v[reg] = val & random.randint(0, 255) self.program_counter.next()
def execute(self, opcode): (_, x_reg, _, _) = get_opcode_digits(opcode) opcode_end = opcode & 0x00FF op = self.operation_table[opcode_end] op(x_reg)