当前位置: 首页>>代码示例>>Python>>正文


Python Memory.read_rom方法代码示例

本文整理汇总了Python中memory.Memory.read_rom方法的典型用法代码示例。如果您正苦于以下问题:Python Memory.read_rom方法的具体用法?Python Memory.read_rom怎么用?Python Memory.read_rom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在memory.Memory的用法示例。


在下文中一共展示了Memory.read_rom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import read_rom [as 别名]

#.........这里部分代码省略.........
        elif n1 == 0xf and n3 == 0x1 and n4 == 0x5: # FX15 Delay timer = VX
            self._timer[0] = self._reg[n2] & 0xff
        elif n1 == 0xf and n3 == 0x1 and n4 == 0x8: # FX18 Sound timer = VX
            self._timer[1] = self._reg[n2]
        elif n1 == 0xf and n3 == 0x1 and n4 == 0xe: # FX1E I = I + VX
            self._I[0] = self._I[0] + self._reg[n2] & 0xffff
        elif n1 == 0xf and n3 == 0x2 and n4 == 0x9: # FX29	I points to the 4 x 5 font sprite of hex char in VX
            self._I[0] = (self._reg[n2] * 5) & 0xffff
        elif n1 == 0xf and n3 == 0x3 and n4 == 0x3: # FX33 Store BCD representation of VX in M(I)...M(I+2)
            self.memory.write(self._I[0], self._reg[n2] / 100)
            self.memory.write(self._I[0]+1, (self._reg[n2] % 10) / 10)
            self.memory.write(self._I[0]+2, self._reg[n2] % 10)
        elif n1 == 0xf and n3 == 0x5 and n4 == 0x5: # FX55 Save V0...VX in memory starting at M(I)
            for i in range(n2 + 1):
                self.memory.write(self.memory.read(self._I[0] + i), self._reg[i])
        elif n1 == 0xf and n3 == 0x6 and n4 == 0x5: # FX65 Load V0...VX from memory starting at M(I)
            for i in range(n2 + 1):
                self._reg[i] = self.memory.read(self._I[0] + i) & 0xff
        elif n1 == 0xf and n3 == 0x7 and n4 == 0x5:
            print "FX75	Save V0...VX (X<8) in the HP48 flags (***)"
            sys.exit(1)
        elif n1 == 0xf and n3 == 0x8 and n4 == 0x5:
            print "FX85	Load V0...VX (X<8) from the HP48 flags (***)"
            sys.exit(1)
        else:
            print "Error %1x%1x%1x%1x" % (n1,n2,n3,n4)
            sys.exit(1)

        if self._timer[0] > 0:
            self._timer[0] = self._timer[0] - 1
        if self._timer[1] > 0:
            self._timer[1] = self._timer[1] - 1
    
    def read_rom(self, filename):
        self.memory.read_rom(filename)

    def handle_input(self):
        events = pygame.event.get()
        for event in events: 
            if self._verbose: print event 
            if event.type == pygame.QUIT:
                sys.exit(0)
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
                sys.exit(0)
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_0:
                self._keystate[0x0] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_1:
                self._keystate[0x1] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_2:
                self._keystate[0x2] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_3:
                self._keystate[0x3] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_4:
                self._keystate[0x4] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_5:
                self._keystate[0x5] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_6:
                self._keystate[0x6] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_7:
                self._keystate[0x7] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_8:
                self._keystate[0x8] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_9:
                self._keystate[0x9] = 1
            elif event.type == pygame.KEYDOWN and event.key == pygame.K_a:
                self._keystate[0xa] = 1
开发者ID:mdurrer,项目名称:dev,代码行数:70,代码来源:cpu.py


注:本文中的memory.Memory.read_rom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。