Esempio n. 1
0
def search(dir, x, y, cpu, dist):

    if dists[y][x] < dist:
        return

    
    global q
    global fx
    global fy
    
    cpu.stdin.append(dir)
    cpu.run()

    result = cpu.stdout.pop()
    
    if result == 0:
        grid[y][x] = "#"
    elif result == 1:
        grid[y][x] = "."
        q.append((copy.deepcopy(cpu), x, y, dist))
        dists[y][x] = dist
    else:
        grid[y][x] = "~"
        dists[y][x] = dist
        fx = x
        fy = y
Esempio n. 2
0
def main():
    if len(argv) < 2:
        raise Exception("program file required")

    program = load_program(argv[1])

    state = CpuState()

    try:
        run(program, state)
        print(state)
    except Exception as e:
        print(e)
Esempio n. 3
0
def exec(inp):
    for c in inp:
        cpu.stdin.append(ord(c))
    cpu.stdin.append(ord("\n"))
    cpu.run()
Esempio n. 4
0
import cpu
import itertools

cpu = cpu.CPU("25.state")
cpu.run()


def exec(inp):
    for c in inp:
        cpu.stdin.append(ord(c))
    cpu.stdin.append(ord("\n"))
    cpu.run()


def out():
    out = ""
    while cpu.stdout:
        out += chr(cpu.stdout.pop())
    return out


while True:
    line = input()
    if line == "bf":
        print("brrr")

        possible = [
            "food ration", "weather machine", "antenna",
            "space law space brochure", "semiconductor", "planetoid",
            "monolith"
        ]
Esempio n. 5
0
from ppu import PPU
from threading import Thread
from queue import Queue
import time

data = array("B")

if len(sys.argv) < 2:
    print("pls give rom name")
    sys.exit()

filename = sys.argv[1]
filesize = os.stat(filename).st_size

print("Loading", filename, " (" + str(filesize) + " bytes)")

with open(filename, 'rb') as f:
    data.fromfile(f, filesize)

queue = Queue()

render_thread = Thread(target=renderer.render, args=(queue, ))
render_thread.start()

memory.loadROM(data)
memory.loadBootstrap()

ppu = PPU(queue)

cpu.run(ppu)