func LoadState() {
	defer func() {
		if err := recover(); err != nil {
			log.Printf("panic: init: %v\n", err)
		}
	}()

	nes.LoadGameState()
}
//export Java_com_ferg_afergulator_Engine_loadState
func Java_com_ferg_afergulator_Engine_loadState(env *C.JNIEnv, clazz C.jclass) {
	defer func() {
		if err := recover(); err != nil {
			log.Printf("panic: init: %v\n", err)
		}
	}()

	nes.LoadGameState()
}
Beispiel #3
0
func (v *Video) Render() {
	for running {
		select {
		case buf := <-v.videoTick:
			gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

			v.prog.Use()

			gl.ActiveTexture(gl.TEXTURE0)
			v.texture.Bind(gl.TEXTURE_2D)

			gl.TexImage2D(gl.TEXTURE_2D, 0, 3, 240, 224, 0, gl.RGBA,
				gl.UNSIGNED_INT_8_8_8_8, buf)

			gl.DrawArrays(gl.TRIANGLES, 0, 6)

			if v.screen != nil {
				sdl.GL_SwapBuffers()
				v.fpsmanager.FramerateDelay()
			}
		case ev := <-sdl.Events:
			switch e := ev.(type) {
			case sdl.ResizeEvent:
				v.ResizeEvent(int(e.W), int(e.H))
			case sdl.QuitEvent:
				os.Exit(0)
			case sdl.KeyboardEvent:
				switch e.Keysym.Sym {
				case sdl.K_ESCAPE:
					running = false
				case sdl.K_r:
					// Trigger reset interrupt
					if e.Type == sdl.KEYDOWN {
						// cpu.RequestInterrupt(InterruptReset)
					}
				case sdl.K_l:
					if e.Type == sdl.KEYDOWN {
						nes.LoadGameState()
					}
				case sdl.K_s:
					if e.Type == sdl.KEYDOWN {
						nes.SaveGameState()
					}
				case sdl.K_i:
					if e.Type == sdl.KEYDOWN {
						nes.AudioEnabled = !nes.AudioEnabled
					}
				case sdl.K_p:
					if e.Type == sdl.KEYDOWN {
						nes.TogglePause()
					}
				case sdl.K_d:
					if e.Type == sdl.KEYDOWN {
						jsHandler.ReloadFile(debugfile)
					}
				case sdl.K_m:
					if e.Type == sdl.KEYDOWN {
						nes.Handler.Handle("debug-mode")
					}
				case sdl.K_BACKSLASH:
					if e.Type == sdl.KEYDOWN {
						nes.Pause()
						nes.StepFrame()
					}
				case sdl.K_1:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(256, 240)
					}
				case sdl.K_2:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(512, 480)
					}
				case sdl.K_3:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(768, 720)
					}
				case sdl.K_4:
					if e.Type == sdl.KEYDOWN {
						v.ResizeEvent(1024, 960)
					}
				}

				switch e.Type {
				case sdl.KEYDOWN:
					nes.Pads[0].KeyDown(e, 0)
				case sdl.KEYUP:
					nes.Pads[0].KeyUp(e, 0)
				}
			}
		}
	}
}