Exemple #1
0
def main():
    # Initialize CPU
    cpu = Cpu()

    # Initialize graphics
    key_lookup = initialize_io()
    key = None

    # Specify Rom (TODO: Build CLI)
    rom_path = "~Barend/Github/Chip-8/Roms/EMULOGO.ch8"

    # Load ROM
    load_rom(cpu.memory, cpu.pc, rom_path)

    # Main cycle
    while cpu.pc <= 4096:
        # Get pressed keys
        for event in pygame.event.get():
            if event.type == pygame.KEYDOWN:
                key = key_lookup[event.unicode]

        # fetch opcode from memory
        opcode = cpu.fetch_opcode(cpu.pc)
        hex_opcode = hex(opcode)
        program_counter = cpu.pc

        # Execute opcode
        cpu.execute_operation(opcode, key)