Esempio n. 1
0
def main():
    # Set up command line arguments parser
    parser = argparse.ArgumentParser(description='NES Emulator')
    parser.add_argument('rom_path',
                        metavar='R',
                        type=str,
                        help='The location to the rom file')
    args = parser.parse_args()

    # load rom
    with open(args.rom_path, 'rb') as file:
        rom_bytes = file.read()

    rom = ROM(rom_bytes)

    # create ram
    ram = RAM()

    # create ppu
    ppu = PPU()

    # create cpu
    cpu = CPU(ram, ppu)
    cpu.start_up()
    cpu.run_rom(rom)
Esempio n. 2
0
 def __init__(self):
     self.cpu = CPU(self)
     self.mmu = MMU(self)
     self.ppu = PPU(self)
     self.cartridge = None
     self.ram = [0xFF] * 2048
     self._clock = 0
Esempio n. 3
0
    def __init__(self):
        self.cpu = CPU()
        self.cpu.set_bus(self)

        self.ppu = PPU()

        self.cpu_ram = [0] * 64 * 1024
Esempio n. 4
0
 def __init__(self, rom_path):
     self.rom_path = rom_path
     self._screen = Screen()
     self._memory = Memory()
     self._ppu = PPU(self._screen, self._memory)
     self._apu = APU(self._memory)
     self._rom = ROM(rom_path)
     self._cpu = CPU(self._memory, self._ppu, self._apu, self._rom)
Esempio n. 5
0
def cpu():
    ram = RAM()
    ppu = PPU()
    cpu = CPU(ram, ppu)
    cpu.start_up()
    cpu.rom = MagicMock()
    cpu.rom.memory_start_location = 0
    cpu.rom.memory_end_location = 0x1FFF
    return cpu
Esempio n. 6
0
    def __init__(self):
        self.MEMORY_SIZE = 0x800  # 2kB

        self.rom = None
        self.ram = RAM(self.MEMORY_SIZE)
        self.cpu = CPU(self.cpu_read, self.cpu_write)
        self.ppu = PPU(self.ppu_read, self.ppu_write)

        self.system_clock = 0
Esempio n. 7
0
 def __init__(self, RAM, ROM, SRAM, use_MAD1_mapping, SRAM_size):
     self.RAM = RAM  # TODO: maybe rename to WRAM
     self.ROM = ROM
     self.SRAM = SRAM
     self.use_MAD1_mapping = use_MAD1_mapping
     self.SRAM_size = SRAM_size
     self.dma = DMAController()
     self.hdm = HDMAController()
     self.internal_cpu_registers = InternalCPURegisters()
     self.ppu = PPU()
Esempio n. 8
0
    def __init__(self, file_name):
        pygame.init()
        self.screen = pygame.display.set_mode([256, 240])

        self.nes_file = self.read_nes_file(file_name)
        self.main_memory = [0 for _ in range(0x800)]
        self.save_memory = [0 for _ in range(0x2000)]
        self.ppu = PPU(self.nes_file)
        self.cpu = CPU(self.nes_file, self.main_memory, self.save_memory,
                       self.ppu)
Esempio n. 9
0
 def __init__(self, bootrom, rom, skip_bootrom=False):
     self.timer = Timer()
     self.ppu = PPU()
     self.apu = APU()
     self.joypad = Joypad()
     self.cartridge = Cartridge(rom)
     self.mmu = MMU(bootrom, self.cartridge, self.timer, self.ppu, self.apu,
                    self.joypad)
     self.timer.mmu = self.mmu
     self.ppu.mmu = self.mmu
     self.joypad.mmu = self.mmu
     self.cpu = CPU(self.mmu)
     self.t_cycles = 0
     self.reset(skip_bootrom)
Esempio n. 10
0
def main():
    # set up command line argument parser
    parser = argparse.ArgumentParser(description="NES Emulator.")
    parser.add_argument('rom_path',
                        metavar='R',
                        type=str,
                        help='path to nes rom')
    parser.add_argument('--test')

    args = parser.parse_args()

    # TODO: validate rom path is correct
    print(args.rom_path)

    # load rom
    with open(args.rom_path, 'rb') as file:
        rom_bytes = file.read()

    # create ram
    ram = RAM()

    # create ppu
    ppu = PPU()

    # create apu
    apu = APU()

    rom = ROM(rom_bytes)

    # create cpu
    cpu: CPU = CPU(ram, ppu, apu)
    cpu.start_up()
    cpu.load_rom(rom, args.test)

    # check if running test rom
    if args.test:
        # load in the test log
        with open('test_log.log', 'r') as nes_test_file:
            nes_test_log = NesTestLog(nes_test_file.readlines())
        while True:
            cpu.identify()
            nes_test_log.compare(cpu)
            cpu.execute()
    else:
        while True:
            cpu.identify()
            cpu.execute()
Esempio n. 11
0
    def __init__(self,
                 rom: str,
                 skipBios: bool = False,
                 nostalgic: bool = False) -> None:
        # main units
        self.z80 = Z80(self)
        self.ppu = PPU(self, nostalgic)
        self.mmu = MMU(self, rom)
        self.timer = Timer(self)
        # log dict
        self.LOG = {}
        # global states
        self.frames = 0
        self.paused = False

        self.initData(skipBios)
        print(INSTRUCTION)
Esempio n. 12
0
    def __init__(self, rom_bytes, testing):
        self.rom = ROM(rom_bytes)

        # create ram
        self.ram = RAM()

        # create ppu and apu
        self.ppu = PPU()
        self.apu = APU()

        # create cpu
        self.cpu = CPU(self.ram, self.ppu, self.apu)

        # create ppu window
        self.window = Window()

        self.testing = testing

        self.nes_test_log = None
Esempio n. 13
0
def main():

	# Check if there's a parameter
	if len(sys.argv) != 2:
		print ("Provide a .nes file\n")
		return
	
	window = Window()
	window.set_size(256, 240)
	# window.set_size(768, 720)
	cpu = CPU()
	ppu = PPU(window)
	bus = BUS(cpu, ppu)
	cart = Cartridge(sys.argv[1])
	bus.insertCartridge(cart)
	
	cpu.connectBus(bus)

	# Do all init (load pallettes, background, set flags...) before running pyglet loop
	
	pyglet.clock.schedule_interval(bus.setFrame, 1/60.0)
	pyglet.app.run()
Esempio n. 14
0
def main():
    mode = 1
    frequency = 0

    if len(sys.argv) >= 2:
        cpu = CPU(mode=0 if "async" in sys.argv else 1,
                  frequency=frequency,
                  console=False if "noconsole" in sys.argv else True)

    else:
        cpu = CPU(mode=mode, frequency=frequency, console=True)

    if sys.platform == "win32":
        ppu = PPU(cpu)
        ppu.start()

    clear()
    print(cpu)
    print("6502 Emulator by Andrija Jovanovic\n")
    print("Running ROM: ", end='')
    print(cpu.rom_path)
    input("\nPress <Enter> to start...")
    cpu.start()
Esempio n. 15
0
def main():
    parser = argparse.ArgumentParser(description='NesEmulator :)')
    parser.add_argument('rom_path',
                        metavar='R',
                        type=str,
                        help='Path to the NES ROM')

    args = parser.parse_args()

    # TODO: Implement drag and drop rom system
    print(args.rom_path)

    with open(args.rom_path, 'rb') as file:
        rom_bytes = file.read()

        rom = ROM(rom_bytes)

        ram = RAM()
        ppu = PPU()

        cpu = CPU(ram, ppu)
        cpu.start_up()
        cpu.run_rom(rom)
Esempio n. 16
0
def main():
    parser = argparse.ArgumentParser(description='NES Emulator.')

    parser.add_argument('rom_path',
                        metavar='R',
                        type=str,
                        help='path to the nes rom')

    args = parser.parse_args()

    print(args.rom_path)

    with open(args.rom_path, 'rb') as file:
        rom_bytes = file.read()

    rom = ROM(rom_bytes)

    memory = Memory()
    ppu = PPU()

    cpu = CPU(memory, ppu)

    cpu.initialization()
    cpu.load_rom(rom)
Esempio n. 17
0
 def __init__(self, prg, chr):
     self.ppu = PPU(chr)
     self.cpu = CPU(prg, self.ppu)
     self.frame = self.ppu.init_frame()
Esempio n. 18
0
    else:
        rom_file_name = 'supermario.nes'

    nes = NES()
    rom = ROM(nes)
    if rom.headercheck(rom_file_name) != True:
        exit()
    nes.rom = rom

    mem = MEMORY(nes)
    rom.load(rom_file_name, mem)
    nes.mem = mem

    cpu = CPU(nes)
    nes.cpu = cpu
    cpu.reset()

    ppu = PPU(nes)
    nes.ppu = ppu
    ppu.reset()

    disp = DISPLAY(nes)
    nes.disp = disp
    disp.init()

    in_put = INPUT(nes)
    nes.in_put = in_put
    in_put.reset()

    nes.start()
Esempio n. 19
0
from ppu import PPU
from threading import Thread
from queue import Queue
import time

data = array("B")

if len(sys.argv) < 2:
    print("pls give rom name")
    sys.exit()

filename = sys.argv[1]
filesize = os.stat(filename).st_size

print("Loading", filename, " (" + str(filesize) + " bytes)")

with open(filename, 'rb') as f:
    data.fromfile(f, filesize)

queue = Queue()

render_thread = Thread(target=renderer.render, args=(queue, ))
render_thread.start()

memory.loadROM(data)
memory.loadBootstrap()

ppu = PPU(queue)

cpu.run(ppu)