コード例 #1
0
ファイル: sdl.go プロジェクト: cocoa-alex/sms
func newSDL2xScreen(fullScreen bool) *sdl2xScreen {
	sdlMode := uint32(sdl.SWSURFACE)
	if fullScreen {
		application.Logf("%s", "Activate fullscreen mode")
		sdlMode = sdl.FULLSCREEN
		sdl.ShowCursor(sdl.DISABLE)
	}
	screenSurface := &sdlSurface{sdl.SetVideoMode(SCREEN_WIDTH*2, SCREEN_HEIGHT*2, 32, sdlMode)}
	if screenSurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	borderSurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, SCREEN_WIDTH*2, SCREEN_HEIGHT*2, 32, 0, 0, 0, 0)}
	if borderSurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	displaySurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, DISPLAY_WIDTH*2, DISPLAY_HEIGHT*2, 32, 0, 0, 0, 0)}
	if displaySurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	return &sdl2xScreen{screenSurface, borderSurface, displaySurface}
}
コード例 #2
0
ファイル: sdl.go プロジェクト: cocoa-alex/sms
func newSDLSurface(w, h int) *sdlSurface {
	surface := sdl.CreateRGBSurface(sdl.SWSURFACE, w, h, 32, 0, 0, 0, 0)
	if surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	return &sdlSurface{surface}
}
コード例 #3
0
ファイル: input.go プロジェクト: remogatto/sms
func (l *inputLoop) Run() {
	for {
		select {
		case <-l.pause:
			l.pause <- 0

		case <-l.terminate:
			l.terminate <- 0

		case _event := <-sdl.Events:
			switch e := _event.(type) {
			case sdl.QuitEvent:
				application.Exit()
			case sdl.KeyboardEvent:
				keyName := sdl.GetKeyName(sdl.Key(e.Keysym.Sym))
				application.Debugf("%d: %s\n", e.Keysym.Sym, keyName)
				if e.Type == sdl.KEYDOWN {
					l.sms.Command <- CmdJoypadEvent{keyMap[keyName], JOYPAD_DOWN}
				} else if e.Type == sdl.KEYUP {
					l.sms.Command <- CmdJoypadEvent{keyMap[keyName], JOYPAD_UP}
				}
				if e.Type == sdl.KEYDOWN && keyName == "p" {
					paused := make(chan bool)
					l.sms.Paused = !l.sms.Paused
					l.sms.Command <- CmdPauseEmulation{paused}
					<-paused
				}
				if e.Type == sdl.KEYDOWN && keyName == "d" {
					l.sms.Paused = true
					paused := make(chan bool)
					l.sms.Command <- CmdPauseEmulation{paused}
					<-paused
					l.sms.Command <- CmdShowCurrentInstruction{}
				}
				if e.Keysym.Sym == sdl.K_ESCAPE {
					application.Exit()
				}

			}
		}
	}
}
コード例 #4
0
ファイル: sdl.go プロジェクト: cocoa-alex/sms
func newSDLUnscaledScreen() *sdlUnscaledScreen {
	screenSurface := &sdlSurface{sdl.SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, sdl.SWSURFACE)}
	if screenSurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	borderSurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, SCREEN_WIDTH, SCREEN_HEIGHT, 32, 0, 0, 0, 0)}
	if borderSurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	displaySurface := &sdlSurface{sdl.CreateRGBSurface(sdl.SWSURFACE, DISPLAY_WIDTH, DISPLAY_HEIGHT, 32, 0, 0, 0, 0)}
	if displaySurface.surface == nil {
		log.Printf("%s", sdl.GetError())
		application.Exit()
		return nil
	}
	return &sdlUnscaledScreen{screenSurface, borderSurface, displaySurface}
}
コード例 #5
0
ファイル: main.go プロジェクト: remogatto/prettytest
func (h *sigterm) HandleSignal(s os.Signal) {
	switch ss := s.(type) {
	case syscall.Signal:
		switch ss {
		case syscall.SIGTERM, syscall.SIGINT:
			if h.hitCounter > 0 {
				application.Exit()
				return
			}
			application.Printf("Hit CTRL-C again to exit, otherwise tests will run again in %s.", RERUN_TIME)
			h.hitCounter++
			go func() {
				time.Sleep(RERUN_TIME)
				execGoTest(h.paths)
				h.hitCounter = 0
			}()
		}
	}
}
コード例 #6
0
ファイル: main.go プロジェクト: remogatto/sms
// Run runs the commandLoop.
// The loop waits for commands sent to sms.command channel.
func (l *commandLoop) Run() {
	for {
		select {
		case <-l.pause:
			l.pause <- 0
		case <-l.terminate:
			l.terminate <- 0
		case _cmd := <-l.emulatorLoop.sms.Command:
			switch cmd := _cmd.(type) {

			case sms.CmdRenderFrame:
				l.displayLoop.Display() <- l.emulatorLoop.sms.RenderFrame()
				l.numOfSentFrames++
				if l.numOfSentFrames > NUM_FRAMES_FOR_PROFILING && l.cpuProfiling {
					application.Exit()
				}

			case sms.CmdLoadROM:
				l.emulatorLoop.sms.LoadROM(cmd.Filename)

			case sms.CmdJoypadEvent:
				l.emulatorLoop.sms.Joypad(cmd.Value, cmd.Event)

			case sms.CmdPauseEmulation:
				l.emulatorLoop.pauseEmulation <- 0
				<-l.emulatorLoop.pauseEmulation
				cmd.Paused <- l.emulatorLoop.sms.Paused
				if application.Verbose && l.emulatorLoop.sms.Paused {
					// instructions := z80.DisassembleN(l.emulatorLoop.sms.Memory, l.emulatorLoop.sms.Cpu.PC(), 10)
					// showDisassembled(instructions)
				}

			}
		}
	}
}