예제 #1
0
def test_decimal_suite(compiled_decimal_test):
    cpu6502.init()
    for (index, byte) in enumerate(compiled_decimal_test):
        cpu6502.write(index, byte)
    cpu6502.set_pc(0x0200)

    cpu6502.run_until_break()
    time.sleep(1)
    while cpu6502.is_running():
        time.sleep(1)

    assert 0x00 == cpu6502.read(0x000B)
예제 #2
0
파일: main.py 프로젝트: guillermobox/6502
def simulation_thread():
    global x, y, vx, vy, dt, g, a, fuel, cmd
    while True:
        cpu6502.write(0xE002, int(fuel[0] * 0xFF))
        cpu6502.write(0xE003, int(fuel[1] * 0xFF))
        cpu6502.write(0xE004, int(fuel[2] * 0xFF))

        time.sleep(0.1)
        cmd = cpu6502.read(0xE010)

        burn_speed = cmd / 255
        a = burn_speed * 10
        fuel[0] = max(fuel[0] - burn_speed * 0.001, 0)
        if fuel[0] == 0:
            a = 0

        vy = vy + (a - g) * dt
        y = y + vy * dt

        if y < 0:
            y = 0
            vy = 0
예제 #3
0
def test_can_read_and_write():
    cpu6502.write(0x0013, 0x99)
    assert 0x99 == cpu6502.read(0x0013)
예제 #4
0
def test_raises_on_read_range_error():
    with pytest.raises(ValueError):
        cpu6502.read(0x10000)
예제 #5
0
파일: fib.py 프로젝트: guillermobox/6502
import cpu6502
import time

with open('fib.bin', 'rb') as f:
    data = f.read()

cpu6502.init()
for (index, byte) in enumerate(data):
    cpu6502.write(0x4000 + index, byte)
cpu6502.set_pc(0x4000)
cpu6502.run_until_break()

time.sleep(0.1)
while cpu6502.is_running():
    time.sleep(0.1)

print("There are the last two fibonacci numbers computed:")
for i in range(0, 256):
    if i % 32 == 0:
        print()
    print('{:02x}'.format(cpu6502.read(0x1000 + i)), end='')
print()
for i in range(0, 256):
    if i % 32 == 0:
        print()
    print('{:02x}'.format(cpu6502.read(0x2000 + i)), end='')
print()