Cleanup and moving of NanoCoat VM specific headers to their own include directory...
[SquirrelJME.git] / nanocoat / frontend / libretro / boot.c
blob55f4006b59eaec996b1bd570aba8dc8d824aea3e
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 #include <string.h>
12 #include "sjme/nvm/nvm.h"
13 #include "sjme/debug.h"
14 #include "3rdparty/libretro/libretro.h"
15 #include "frontend/libretro/shared.h"
16 #include "sjme/dylib.h"
18 static sjme_jboolean sjme_libretro_debugMessageHandler(sjme_lpcstr fullMessage,
19 sjme_lpcstr partMessage)
21 struct retro_message retroMessage;
22 struct retro_log_callback retroLogCallback;
24 if (sjme_libretro_envCallback != NULL)
26 /* Setup details. */
27 retroMessage.frames = 240;
28 retroMessage.msg = partMessage;
30 /* Emit message. */
31 sjme_libretro_envCallback(RETRO_ENVIRONMENT_SET_MESSAGE,
32 &retroMessage);
34 /* Is logging also available? */
35 memset(&retroLogCallback, 0, sizeof(retroLogCallback));
36 if (true == sjme_libretro_envCallback(
37 RETRO_ENVIRONMENT_GET_LOG_INTERFACE,
38 &retroLogCallback) &&
39 retroLogCallback.log != NULL)
40 retroLogCallback.log(RETRO_LOG_INFO, "%s\n",
41 fullMessage);
43 /* We handled it here, so SquirrelJME does not have to print it. */
44 return SJME_JNI_TRUE;
47 /* Not handled. */
48 return SJME_JNI_FALSE;
51 static sjme_jboolean sjme_libretro_exitHandler(int exitCode)
53 /* If there is no environment callback, then do nothing here. */
54 if (sjme_libretro_envCallback == NULL)
55 return SJME_JNI_FALSE;
57 /* Tell the front end to stop the core. */
58 sjme_libretro_envCallback(RETRO_ENVIRONMENT_SHUTDOWN, NULL);
59 return SJME_JNI_TRUE;
62 static sjme_jboolean sjme_libretro_abortHandler(void)
64 /* Forward to the exit handler. */
65 return sjme_libretro_exitHandler(1);
68 static sjme_debug_handlerFunctions sjme_libretro_debugHandlers =
70 .abort = sjme_libretro_abortHandler,
71 .exit = sjme_libretro_exitHandler,
72 .message = sjme_libretro_debugMessageHandler,
75 sjme_attrUnused RETRO_API unsigned retro_api_version(void)
77 return RETRO_API_VERSION;
80 sjme_attrUnused RETRO_API void retro_deinit(void)
84 sjme_attrUnused RETRO_API void retro_init(void)
86 /* Setup handlers for debug calls. */
87 sjme_debug_handlers = &sjme_libretro_debugHandlers;
90 sjme_attrUnused RETRO_API bool retro_load_game(
91 const struct retro_game_info* game)
93 static sjme_jint trigger;
95 /* If we requested no game then we do not really care, do we? */
96 if (game == NULL)
97 return true;
99 if (!(trigger++))
100 sjme_message("Impl. %s?", __func__);
102 return false;
105 sjme_attrUnused RETRO_API bool retro_load_game_special(unsigned game_type,
106 const struct retro_game_info *info, size_t num_info)
108 static sjme_jint trigger;
109 if (!(trigger++))
110 sjme_message("Impl. %s?", __func__);
111 return false;
114 sjme_attrUnused RETRO_API void retro_reset(void)
116 static sjme_jint trigger;
117 if (!(trigger++))
118 sjme_message("Impl. %s?", __func__);
121 sjme_attrUnused RETRO_API void retro_unload_game(void)
123 static sjme_jint trigger;
124 if (!(trigger++))
125 sjme_message("Impl. %s?", __func__);