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


Python Memory.display方法代码示例

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


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

示例1: run

# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import display [as 别名]
def run(path, debug, max_cycles):
    with open(path, "rb") as rom_file:
        debug_title = debug == "TITLE"
        debug_header = debug == "HEADER" or debug == "ALL"
        debug_mem = debug == "MEMORY" or debug == "ALL"
        debug_instructions = debug == "INSTRUCTIONS" or debug == "ALL"
        debug_registers = debug == "REGISTERS" or debug == "ALL"
        rom = [i for i in rom_file.read()]
        
        header = Header(rom, debug_header)
        mem = Memory(rom, header)
        if debug_title:
            print("Title: " + header.name)
        if debug_instructions:
            print("PC:    Operation")
        
        interrupts = Interrupts()
        cpu = CPU(mem, interrupts, debug_instructions, debug_registers)
        timer = Timer(interrupts)
        sound = Sound()
        link = Link()
        joypad = Joypad()
        lcdc = LCDC(mem, interrupts)
        mem.setupIO(lcdc, interrupts, timer, sound, link, joypad)
        total_cycles = 0

        try:
            pygame.init()
            while cpu.run_state != "QUIT":
                for event in pygame.event.get():
                    if event.type == pygame.QUIT:
                        cpu.run_state = "QUIT"
                    if event.type == pygame.KEYDOWN or event.type == pygame.KEYUP:
                        joypad.keyEvent(event)

                interrupts.update()
                if cpu.run_state == "RUN":
                    cpu.run()
                else:
                    cpu.cycles += 1

                timer.update(cpu.cycles)
                lcdc.update(cpu.cycles)

                total_cycles += cpu.popCycles()
                if max_cycles >= 0 and total_cycles > max_cycles:
                    cpu.run_state = "QUIT"
        except AssertionError as e:
            if debug_mem:
                mem.display()
            traceback.print_tb(e.__traceback__)
        except KeyboardInterrupt as e:
            if debug_mem:
                mem.display()
        else:
            if debug_mem:
                mem.display()
开发者ID:rukai,项目名称:GameToy,代码行数:59,代码来源:gametoy.py

示例2: run_simulation

# 需要导入模块: from memory import Memory [as 别名]
# 或者: from memory.Memory import display [as 别名]
def run_simulation( plist, algorithm = None, quiet = True):
    """
    Runs 'first', 'best', 'next' or 'worst' algorithm on a list of processes. 
    If 'quiet', then there is no user interaction.
    """
    TIME = time = 0

    END  = max( [p.exit_time for p in plist] )
    M = Memory(MAIN_MEM, OS_MEM, plist)
    M.display(t=TIME)

    # Outer loop to take input from the user. 
    while(True):

        if (not quiet):
            try:
                time = int( input('Enter time to view memory configuration:' ) )
                if (time == 0): 
                    break
            except:
                break

        # Inner loop to run the simulation.
        while ( TIME < END ):

            TIME += 1

            changed = 0
            changed += M.remove_all(plist, TIME )
            changed += M.add_all(plist, TIME, algorithm, quiet = quiet)

            if (not quiet and time == TIME):
                break

            if (changed > 0 and quiet):
                M.display(t=TIME)

        # If the user is controlling the loop, just continue.
        if (not quiet):
            M.display(t=TIME)
            #M = Memory(MAIN_MEM, OS_MEM, plist)
            #TIME = 0
            continue

        break
开发者ID:joechip504,项目名称:process-memory-simulation,代码行数:47,代码来源:memsim.py


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