rom.append(int.from_bytes(byte, byteorder="big")) byte = file.read(1) return rom bios = load_rom("DMG_ROM.bin") # Load bios rom = load_rom("tetris.gb") # Load rom mem = Memory(0x10000, rom=rom, bios=bios) mem2 = Memory(0x10000, rom=rom, bios=bios) mem.load_bios() mem.load_rom() mem2.load_bios() mem2.load_rom() cpu = CPU(mem) mem.cpu = cpu cpu2 = CPU2(mem2) mem2.cpu = cpu2 clock_rate = 4194304 gpu_rate = 456 cycles = 0 cycles2 = 0 while True: lastpc1 = cpu.pc lastpc2 = cpu2.pc cycles += cpu.cycle() cycles2 += cpu2.cycle() if cycles > gpu_rate: print(hex(cpu.pc), hex(cpu2.pc))
bios_path = input("Enter a relative path to the BIOS: ") bios = load_rom(bios_path) # Load bios rom_path = input("Enter a relative path to the ROM: ") rom = load_rom(rom_path) # Load rom mem = Memory(0x10000, rom=rom, bios=bios) mem.load_bios() mem.load_rom() # TODO: Account for ROM banking cpu = CPU(mem) # Initialize CPU. To see stuff happen, make silent=False gpu = GPU(mem, scale=2) # Initialize GPU mem.cpu = cpu gpu.start() clock_rate = 4194304 gpu_rate = 456 cycles = 0 highest_pc = -1 while True: cycles += cpu.cycle() if cycles > gpu_rate: cycles -= gpu_rate cpu.mem[LY] += 1 if cpu.mem[LY] == 144: gpu.update() cpu.mem[IF] |= 1 # VBlank Interrupt enable