Exemple #1
0
def barcamp1(challenge, student, code, completed):
    a = Assembler()
    rom, errors = a.assemble( ".org $C000\n"+code + "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000" )
    if errors: return None
    
    e = Emulator( rom[0x10:0x4010], rom[0x4010:] )
    for i in range(0x100):
        e.step()
        if e.last_op == 0x60: break
    if e.X == 160 and e.Y == 100:
        return rom_size(rom), 100
    else: None
Exemple #2
0
def barcamp1(challenge, student, code, completed):
    a = Assembler()
    rom, errors = a.assemble(
        ".org $C000\n" + code +
        "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000"
    )
    if errors: return None

    e = Emulator(rom[0x10:0x4010], rom[0x4010:])
    for i in range(0x100):
        e.step()
        if e.last_op == 0x60: break
    if e.X == 160 and e.Y == 100:
        return rom_size(rom), 100
    else:
        None
Exemple #3
0
def barcamp3(challenge, student, code, completed):
    a = Assembler()
    
    preamble = ".org $C000\n.define PADDLE_1Y=$204\n"
    postamble = "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000"
    
    rom, errors = a.assemble( preamble+code + postamble )
    if errors: None
    for test in [[0],[4],[5],[4,3]]:
        e = Emulator( rom[0x10:0x4010], rom[0x4010:] )
        for t in test: e.controller(1,t)
        for i in range(0x100):
            e.step()
            if e.last_op == 0x60: break
        if 4 in test and e.read(0x204) != 1: return None
        if 5 in test and e.read(0x204) != 0xff: return None
    return rom_size(rom), 100
Exemple #4
0
def barcamp3(challenge, student, code, completed):
    a = Assembler()

    preamble = ".org $C000\n.define PADDLE_1Y=$204\n"
    postamble = "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000"

    rom, errors = a.assemble(preamble + code + postamble)
    if errors: None
    for test in [[0], [4], [5], [4, 3]]:
        e = Emulator(rom[0x10:0x4010], rom[0x4010:])
        for t in test:
            e.controller(1, t)
        for i in range(0x100):
            e.step()
            if e.last_op == 0x60: break
        if 4 in test and e.read(0x204) != 1: return None
        if 5 in test and e.read(0x204) != 0xff: return None
    return rom_size(rom), 100
Exemple #5
0
def barcamp2(challenge, student, code, completed):
    a = Assembler()
    
    preamble = ".org $C000\n.define BALL_X=$200\n.define BALL_Y=$201\n.define BALL_DX=$202\n.define BALL_DY=$203\n"
    postamble = "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000"
    
    rom, errors = a.assemble( preamble+code + postamble )
    if errors: return None
    for test in [[54,32,1,1],[0,99,0xff,0xff],[55,0xff,0xff,1]]:
        e = Emulator( rom[0x10:0x4010], rom[0x4010:] )
        e.write( test[0], 0x200 )
        e.write( test[1], 0x201 )
        e.X = test[2]
        e.Y = test[3]
        for i in range(0x100):
            e.step()
            if e.last_op == 0x60: break
        if e.read(0x200) != (test[0]+test[2])&0xff or e.read(0x201) != (test[1]+test[3])&0xff:
            return None
    return rom_size(rom), 100
Exemple #6
0
def barcamp2(challenge, student, code, completed):
    a = Assembler()

    preamble = ".org $C000\n.define BALL_X=$200\n.define BALL_Y=$201\n.define BALL_DX=$202\n.define BALL_DY=$203\n"
    postamble = "\nforever:\n jmp forever\n.org $fffa\n.dw $C000\n.dw $C000\n.dw $C000"

    rom, errors = a.assemble(preamble + code + postamble)
    if errors: return None
    for test in [[54, 32, 1, 1], [0, 99, 0xff, 0xff], [55, 0xff, 0xff, 1]]:
        e = Emulator(rom[0x10:0x4010], rom[0x4010:])
        e.write(test[0], 0x200)
        e.write(test[1], 0x201)
        e.X = test[2]
        e.Y = test[3]
        for i in range(0x100):
            e.step()
            if e.last_op == 0x60: break
        if e.read(0x200) != (test[0] + test[2]) & 0xff or e.read(
                0x201) != (test[1] + test[3]) & 0xff:
            return None
    return rom_size(rom), 100