Example #1
0
class GameBoy(object):

    def __init__(self, cart, bios='../DMG_ROM.bin', debug=False):
        self._debug = debug
        self._memory = self._init_memory(bios, cart)
        self._cpu = CPU(self._memory, self._debug)
        self._gpu = GPU(self._memory)

    def _init_memory(self, bios, cart):
        memory = Memory()
        with open(bios, 'rb') as bios, open(cart, 'rb') as cart:
            boot = bios.read()
            gamerom = cart.read()
            memory.load(boot, 0x0000)
            memory.load(gamerom, 0x0100)
        return memory

    def run(self):
        running = True
        while running:
            self._cpu.execute()
            if self._cpu._get_PC() > 0xFF:
                log.critical('FINISHED BOOT SEQUENCE! CONGRATS!')
                running = False
Example #2
0
 def __init__(self, cart, bios='../DMG_ROM.bin', debug=False):
     self._debug = debug
     self._memory = self._init_memory(bios, cart)
     self._cpu = CPU(self._memory, self._debug)
     self._gpu = GPU(self._memory)