コード例 #1
0
ファイル: test_cpu.py プロジェクト: xadozuk/chip8-emulator
 def setUp(self):
     self.memory = Memory(0x1000)
     self.sound_timer = Timer(freq=60)
     self.delay_timer = Timer(freq=60)
     self.cpu = Cpu(self.memory,
                    None,
                    delay_timer=self.delay_timer,
                    sound_timer=self.sound_timer)
コード例 #2
0
    def __init__(self, memory, display, delay_timer, sound_timer):
        self._memory = memory
        self._display = display

        self._delay_timer = delay_timer
        self._sound_timer = sound_timer

        self._v = [Register(8) for i in range(0, 0x10)]  # 0xF + 1
        self._i = Register(16)
        self._pc = 0x0

        self._stack = Memory(12, cell_bit_size=16)
        self._sp = 0

        self._standard_ops = {
            0x1: self._jump_to_address,
            0x2: self._call_subroutine,
            0x3: self._skip_if_reg_equal_const,
            0x4: self._skip_if_reg_not_equal_const,
            0x5: self._skip_if_reg_equal_reg,
            0x6: self._set_reg_to_const,
            0x7: self._add_const_to_reg,
            0x9: self._skip_if_reg_not_equal_reg,
            0xA: self._set_i_to_address,
            0xB: self._jump_to_address_plus_v0,
            0xC: self._set_reg_to_xor_rand_and_const,
            0xD: self._draw_sprite,
            0xE: self._skip_on_key_press_event,
        }

        self._extended_ops_decode = {
            0x0: self._decode_0_ops,
            0x8: self._decode_8_ops,
            0xF: self._decode_F_ops
        }

        self._8_ops = {
            0x0: self._mov_reg_to_reg,
            0x1: self._bitwise_or,
            0x2: self._bitwise_and,
            0x3: self._bitwise_xor,
            0x4: self._add_reg_to_reg,
            0x5: self._sub_reg_to_reg,
            0x6: self._right_shift,
            0x7: self._sub_reg_to_reg_inv,
            0xE: self._left_shift,
        }

        self._F_ops = {
            0x07: self._mov_delay_to_reg,
            0x0A: self._set_delay_to_reg,
            0x15: self._set_sound_to_reg,
            0x1E: self._add_reg_to_i,
            0x29: self._mov_reg_sprite_addr_to_i,
            0x33: self._mov_reg_to_bcd,
            0x55: self._dump_regs,
            0x65: self._load_regs
        }
コード例 #3
0
    def __init__(self):
        self._memory = Memory(0x1000)
        self._display = Display(64, 32)
        self._delay_timer = Timer(freq=60)
        self._sound_timer = Timer(freq=60)

        self._sound = Sound(self._sound_timer)
        self._cpu = Cpu(self._memory,
                        self._display,
                        delay_timer=self._delay_timer,
                        sound_timer=self._sound_timer)

        self._fps_time = datetime.now()

        pygame.init()
コード例 #4
0
    def __init__(self):
        super().__init__()
        self.memory = Memory()

        self.setupUi(self)
        self.scan_byte_size.insertItems(0, [str(t) for t in Type])
        self.scan_byte_size.setCurrentIndex(Type.UINT32.value)
        self.scan_widget.setEnabled(False)

        self.found_table.setModel(FoundAddressModel(self))
        self.found_table.horizontalHeader().setSectionResizeMode(0, QHeaderView.Stretch)

        self.new_scan.clicked.connect(self.new_scan_clicked)
        self.next_scan.clicked.connect(self.next_scan_clicked)
        self.actionAttach.triggered.connect(self.attach_triggered)
        self.found_table.doubleClicked.connect(self.found_table_double_clicked)
        self.saved_results.doubleClicked.connect(self.saved_model_double_clicked)
        self.search_for.setValidator(QIntValidator(self))
        self.scan_byte_size.currentIndexChanged.connect(self.type_changed)
コード例 #5
0
    def test_memory_initialization(self):
        m = Memory(32)

        for i in range(0, 32):
            self.assertEqual(m[i], 0x0)
コード例 #6
0
    def test_memory_out_of_bounds(self):
        m = Memory(32)

        self.assertRaises(IndexError, m.__getitem__, 32)
        self.assertRaises(IndexError, m.__getitem__, -1)
コード例 #7
0
 def test_memory_seeting_value_to_big(self):
     m = Memory(8, cell_bit_size=8)
     self.assertRaises(OverflowError, m.__setitem__, 0, 0xFFF)
コード例 #8
0
    def test_memory_setting_value(self):
        m = Memory(8)

        m[0] = 0xFF

        self.assertEqual(m[0], 0xFF)
コード例 #9
0
ファイル: memory_test.py プロジェクト: vikke1234/ot-project
 def setUp(self) -> None:
     self.memory = Memory()
     # just attach to own process, we're overriding the read values anyway
     self.memory.process = psutil.Process()
コード例 #10
0
ファイル: vm.py プロジェクト: dzonerzy/dvm
 def vm_exec_mem(self, bytecode):
     self.mem = Memory(bytecode)
     self.vm_exec()
コード例 #11
0
ファイル: vm.py プロジェクト: dzonerzy/dvm
 def _load(self, path):
     bc = file(path, "rb").read()
     self.mem = Memory(bc)