From 9d9715afabdc72f55a340dd4fb9672616ef3dcac Mon Sep 17 00:00:00 2001 From: T_chan Date: Mon, 5 Jul 2021 20:37:17 +0000 Subject: [PATCH] Avoid the need to hard-reset the Dreamcast to exit the sample --- samples/nehe02/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/samples/nehe02/main.c b/samples/nehe02/main.c index ae6a0d0..1b2e3e0 100644 --- a/samples/nehe02/main.c +++ b/samples/nehe02/main.c @@ -1,3 +1,7 @@ +#ifdef __DREAMCAST__ +#include +#endif + #include "GL/gl.h" #include "GL/glu.h" #include "GL/glkos.h" @@ -34,6 +38,23 @@ void ReSizeGLScene(int Width, int Height) glMatrixMode(GL_MODELVIEW); } +int check_start() { +#ifdef __DREAMCAST__ + maple_device_t *cont; + cont_state_t *state; + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state) + return state->buttons & CONT_START; + } +#endif + + return 0; +} /* The main drawing function. */ void DrawGLScene() @@ -116,6 +137,9 @@ int main(int argc, char **argv) ReSizeGLScene(640, 480); while(1) { + if(check_start()) + break; + DrawGLScene(); }