예제 #1
0
# pygame 'clock' used to limit to 60fps on fast computers
clock = pygame.time.Clock()



# load game and init emulator
rom = open(args[0], 'rb').read()
sram = None
if len(args) > 1:
	sram = open(args[1], 'rb').read()

emu = snes_core.EmulatedSNES(libsnes)
emu.load_cartridge_normal(rom, sram)

# register callbacks
pgvid.set_video_refresh_cb(emu, paint_frame)
pgaud.set_audio_sample_cb(emu)
emu.set_input_state_cb(input_state)

# unplug player 2 controller so we don't get twice as many input state callbacks
emu.set_controller_port_device(snes_core.PORT_2, snes_core.DEVICE_NONE)

# run each frame until closed.
running = True
while running:
	emu.run()
	clock.tick(60)
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			running = False
		elif event.type == pygame.KEYDOWN:
예제 #2
0
# pygame 'clock' used to limit to 60fps on fast computers
clock = pygame.time.Clock()


# load game and init emulator
rom = open(args[0], "rb").read()
sram = None
if len(args) > 1:
    sram = open(args[1], "rb").read()

emu = snes_core.EmulatedSNES(libsnes)
emu.load_cartridge_normal(rom, sram)

# register callbacks
pgvid.set_video_refresh_cb(emu, paint_frame)
pgaud.set_audio_sample_cb(emu)
emu.set_input_state_cb(input_state)

# unplug player 2 controller so we don't get twice as many input state callbacks
emu.set_controller_port_device(snes_core.PORT_2, snes_core.DEVICE_NONE)

# run each frame until closed.
running = True
while running:
    emu.run()
    clock.tick(60)
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False
        elif event.type == pygame.KEYDOWN:
예제 #3
0
    else:
        pad = tas.next_input()
    inputframe += 1


def state_smv_input(port, device, index, id):
    global pad
    return bool(pad[0] & (0x8000 >> id))


def paint_frame(im):
    global screen
    # blit snes screen centered in pygame's display
    w, h = im.get_size()
    sw, sh = screen.get_size()
    screen.blit(im, ((sw - w) / 2, (sh - h) / 2))
    pygame.display.flip()


# register drawing and input-reading callbacks
emu.set_input_poll_cb(poll_smv_input)
emu.set_input_state_cb(state_smv_input)
pygame_output.set_video_refresh_cb(emu, paint_frame)

# run the emulator, frame at a time
running = True
while running:
    emu.run()
    for event in pygame.event.get():
        if event.type == pygame.QUIT: running = False
예제 #4
0
	if 0 <= inputframe < 100: pass
	else: 
		pad = tas.next_input()
	inputframe += 1

def state_smv_input(port, device, index, id):
	global pad
	return bool(pad[0] & (0x8000 >> id))

def paint_frame(im):
	global screen
	# blit snes screen centered in pygame's display
	w,h = im.get_size()
	sw,sh = screen.get_size()
	screen.blit(im, ((sw - w)/2, (sh - h)/2))
	pygame.display.flip()


# register drawing and input-reading callbacks
emu.set_input_poll_cb(poll_smv_input)
emu.set_input_state_cb(state_smv_input)
pygame_output.set_video_refresh_cb(emu, paint_frame)

# run the emulator, frame at a time
running = True
while running:
	emu.run()
	for event in pygame.event.get():
		if event.type == pygame.QUIT: running = False