Compare commits

...
2 Commits
Author SHA1 Message Date
Rob Loach fd4487e877 Fix syntax 2019-01-01 23:57:24 -05:00
Rob Loach 3d38f93a9a Add ability to launch core without content 2019-01-01 12:22:50 -05:00
4 changed files with 42 additions and 19 deletions

No files matched your search

+32 -19
View File
@@ -44,6 +44,7 @@ func Load(sofile string) error {
state.Global.Core.UnloadGame()
state.Global.Core.Deinit()
state.Global.GamePath = ""
state.Global.SupportNoGame = false
state.Global.CoreRunning = false
}
@@ -77,7 +78,13 @@ func Load(sofile string) error {
menu.UpdateOptions(opts)
log.Println("[Core]: Core loaded: " + si.LibraryName)
if state.Global.SupportNoGame {
log.Println("[Core]: Core launching: " + si.LibraryName)
StartCore()
} else {
log.Println("[Core]: Core loaded: " + si.LibraryName)
}
return nil
}
@@ -112,6 +119,28 @@ func unzipGame(filename string) (string, int64, error) {
return path, size, nil
}
// StartCore will set the start up the loaded core, with or without a game being loaded first.
func StartCore() {
si := state.Global.Core.GetSystemInfo()
avi := state.Global.Core.GetSystemAVInfo()
vid.Geom = avi.Geometry
// Append the library name to the window title.
if len(si.LibraryName) > 0 {
vid.Window.SetTitle("Ludo - " + si.LibraryName)
}
input.Init(vid, menu)
audio.Init(int32(avi.Timing.SampleRate))
if state.Global.AudioCb.SetState != nil {
state.Global.AudioCb.SetState(true)
}
state.Global.CoreRunning = true
state.Global.MenuActive = false
}
// LoadGame loads a game. A core has to be loaded first.
func LoadGame(filename string) error {
si := state.Global.Core.GetSystemInfo()
@@ -135,26 +164,10 @@ func LoadGame(filename string) error {
return errors.New("failed to load the game")
}
avi := state.Global.Core.GetSystemAVInfo()
vid.Geom = avi.Geometry
// Append the library name to the window title.
if len(si.LibraryName) > 0 {
vid.Window.SetTitle("Ludo - " + si.LibraryName)
}
input.Init(vid, menu)
audio.Init(int32(avi.Timing.SampleRate))
if state.Global.AudioCb.SetState != nil {
state.Global.AudioCb.SetState(true)
}
state.Global.CoreRunning = true
state.Global.MenuActive = false
state.Global.GamePath = filename
log.Println("[Core]: Game loaded: " + filename)
StartCore()
return nil
}
+2
View File
@@ -47,6 +47,8 @@ func environment(cmd uint32, data unsafe.Pointer) bool {
state.Global.FrameTimeCb = libretro.SetFrameTimeCallback(data)
case libretro.EnvironmentSetAudioCallback:
state.Global.AudioCb = libretro.SetAudioCallback(data)
case libretro.EnvironmentSetSupportNoGame:
state.Global.SupportNoGame = libretro.GetBool(data)
case libretro.EnvironmentGetCanDupe:
libretro.SetBool(data, true)
case libretro.EnvironmentSetPixelFormat:
+7
View File
@@ -169,6 +169,7 @@ const (
EnvironmentGetUsername = uint32(C.RETRO_ENVIRONMENT_GET_USERNAME)
EnvironmentGetLogInterface = uint32(C.RETRO_ENVIRONMENT_GET_LOG_INTERFACE)
EnvironmentGetCanDupe = uint32(C.RETRO_ENVIRONMENT_GET_CAN_DUPE)
EnvironmentSetSupportNoGame = uint32(C.RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME)
EnvironmentSetPixelFormat = uint32(C.RETRO_ENVIRONMENT_SET_PIXEL_FORMAT)
EnvironmentGetSystemDirectory = uint32(C.RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY)
EnvironmentGetSaveDirectory = uint32(C.RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY)
@@ -514,6 +515,12 @@ func SetBool(data unsafe.Pointer, val bool) {
*b = C.bool(val)
}
// GetBool is an environment callback helper to get a boolean
func GetBool(data unsafe.Pointer) bool {
b := (*C.bool)(data)
return (bool)(*b)
}
// SetString is an environment callback helper to set a string
func SetString(data unsafe.Pointer, val string) {
s := (**C.char)(data)
+1
View File
@@ -12,6 +12,7 @@ type State struct {
Core libretro.Core // Current libretro core
FrameTimeCb libretro.FrameTimeCallback
AudioCb libretro.AudioCallback
SupportNoGame bool // When set to true, the core doesn't require content to run
CoreRunning bool
MenuActive bool // When set to true, will display the menu layer
Verbose bool