exit app when song ends

This commit is contained in:
2025-06-24 19:05:01 +03:00
parent cfd6c97f32
commit f1343ea200
4 changed files with 396 additions and 18 deletions

View File

@ -6,7 +6,7 @@
#define BREAK_COMPATIBILITY 0
#else
#define OPENGL_DEBUG 0
#define FULLSCREEN 1
#define FULLSCREEN 0
#define DESPERATE 0
#define BREAK_COMPATIBILITY 0
#endif
@ -44,6 +44,7 @@ void entrypoint(void)
int __cdecl main(int argc, char* argv[])
#endif
{
// initialize window
#if FULLSCREEN
@ -59,7 +60,8 @@ int __cdecl main(int argc, char* argv[])
// you can create a pseudo fullscreen window by similarly enabling the WS_MAXIMIZE flag as above
// in which case you can replace the resolution parameters with 0s and save a couple bytes
// this only works if the resolution is set to the display device's native resolution
HDC hDC = GetDC(CreateWindow((LPCSTR)0xC018, 0, WS_POPUP | WS_VISIBLE, 0, 0, XRES, YRES, 0, 0, 0, 0));
HWND window = CreateWindow((LPCSTR)0xC018, 0, WS_POPUP | WS_VISIBLE, 0, 0, XRES, YRES, 0, 0, 0, 0);
HDC hDC = GetDC(window);
#endif
#endif
@ -105,19 +107,15 @@ int __cdecl main(int argc, char* argv[])
#endif
long playCursor = 0;
long lastPlayCursor = -1;
// main loop
direct_sound_buffer->Play(0, 0, 0);
do
{
direct_sound_buffer->GetCurrentPosition((DWORD*)&playCursor, NULL);
direct_sound_buffer->GetCurrentPosition((DWORD*)&playCursor, NULL);
float syncs[1 + SU_NUMSYNCS];
#ifdef EDITOR_CONTROLS
editor.beginFrame(timeGetTime());
#endif
#if !(DESPERATE)
// do minimal message handling so windows doesn't kill your application
// not always strictly necessary but increases compatibility and reliability a lot
@ -187,12 +185,11 @@ int __cdecl main(int argc, char* argv[])
editor.printFrameStatistics();
editor.updateShaders(&pidMain, &pidPost);
#endif
} while(!GetAsyncKeyState(VK_ESCAPE)
#if USE_AUDIO
&& playCursor < SU_LENGTH_IN_SAMPLES * 2 * sizeof(SUsample)
#endif
);
if (playCursor < lastPlayCursor) {
break;
}
lastPlayCursor = playCursor;
} while(!GetAsyncKeyState(VK_ESCAPE));
ExitProcess(0);
}

View File

@ -3,14 +3,14 @@
#define SU_RENDER_H
#define SU_CHANNEL_COUNT 2
#define SU_LENGTH_IN_SAMPLES 8282304
#define SU_LENGTH_IN_SAMPLES 920256
#define SU_BUFFER_LENGTH (SU_LENGTH_IN_SAMPLES*SU_CHANNEL_COUNT)
#define SU_SAMPLE_RATE 44100
#define SU_BPM 138
#define SU_ROWS_PER_BEAT 4
#define SU_ROWS_PER_PATTERN 16
#define SU_LENGTH_IN_PATTERNS 108
#define SU_LENGTH_IN_PATTERNS 12
#define SU_LENGTH_IN_ROWS (SU_LENGTH_IN_PATTERNS*SU_PATTERN_SIZE)
#define SU_SAMPLES_PER_ROW (SU_SAMPLE_RATE*60/(SU_BPM*SU_ROWS_PER_BEAT))
#define SU_NUMSYNCS 4