summaryrefslogtreecommitdiff
path: root/base/base.c
diff options
context:
space:
mode:
Diffstat (limited to 'base/base.c')
-rw-r--r--base/base.c125
1 files changed, 0 insertions, 125 deletions
diff --git a/base/base.c b/base/base.c
deleted file mode 100644
index c17ab47..0000000
--- a/base/base.c
+++ /dev/null
@@ -1,125 +0,0 @@
-#define _GNU_SOURCE
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <time.h>
-#include <inttypes.h>
-#include <immintrin.h>
-#include <unistd.h>
-
-#ifdef _WIN32
- #define WIN32_LEAN_AND_MEAN
- #define NOMINMAX
- #undef NOCRYPT
- #include <windows.h>
- #include <mmsystem.h>
-#elif defined(__linux__)
- #include <dlfcn.h>
- // #include <sched.h>
- // #include <unistd.h>
-#endif
-
-#include "settings.h"
-#ifdef PROFILER
-#define STB_SPRINTF_IMPLEMENTATION
-#define STB_SPRINTF_NOFLOAT
-#define STB_SPRINTF_STATIC
-#include "stb_sprintf.h"
-#define DEBUG_PRINT(format, ...) do { \
- char buf[512]; \
- int len = stbsp_snprintf(buf, sizeof(buf), format, ##__VA_ARGS__); \
- write(STDOUT_FILENO, buf, len); \
-} while(0)
-#else
-#define DEBUG_PRINT(...)
-#endif
-
-#include "opengl_loader.c"
-
-#include "incbin.h"
-#include "ugg.h"
-#include "state.c"
-#include "common.h"
-
-
-#include "opengl.c"
-#include "render.c"
-#include <mkfw/mkfw.c>
-
-#ifdef PROFILER
-#include "overlay.c"
-#endif
-#include "audio.c"
-#include "callbacks.c"
-
-/* [=]===^=[ main ]=================================================================^===[=] */
-int main(int argc, char **argv) {
- state.toggle_crt_emulation = true;
- mkfw_init(320*5, 240*5);
- mkfw_set_swapinterval(0);
- mkfw_set_window_min_size_and_aspect(320*3, 240*3, 320, 240);
- mkfw_set_key_callback(key_callback);
- mkfw_set_mouse_move_delta_callback(mouse_move_callback);
- mkfw_set_mouse_button_callback(mouse_button_callback);
- mkfw_set_framebuffer_size_callback(framebuffer_callback);
- opengl_setup(vertex_shader_start, fragment_shader_start);
- change_resolution(SCREEN_WIDTH, SCREEN_HEIGHT);
- framebuffer_callback(SCREEN_WIDTH*3, SCREEN_HEIGHT*3);
-#ifdef PROFILER
- overlay_init();
-#endif
- init_callback();
- audio_initialize();
-
- set_decay(30);
-
- bool running = true;
- uint64_t next_update = mkfw_gettime() + FRAMETIME;
- while(running && !mkfw_should_close()) {
- mkfw_pump_messages();
- if(key_pressed(MKS_KEY_ESCAPE)) { running = false; }
-
-#ifdef PROFILER
- reset_profiling_data();
-#endif
- render_callback();
-// #ifndef PERF_TEST
- apply_phosphor_decay();
-// #endif
- update_keyboard_state();
- update_modifier_state();
- update_mouse_state();
- state.frame_number++;
-
-#ifndef PERF_TEST
- render_frame();
-#ifdef PROFILER
- debug_render();
-#endif
-
- uint64_t now = mkfw_gettime();
- int64_t remaining = next_update - now;
- if(remaining > 0) {
- if(remaining > SLEEP_MARGIN_NS) {
- mkfw_sleep(remaining - SLEEP_MARGIN_NS);
- }
- while(mkfw_gettime() < next_update) { /**/ }
- } else {
- next_update = now;
- }
- next_update += FRAMETIME;
-
- mkfw_swap_buffers();
-#endif
- }
- shutdown_callback();
-#ifdef PROFILER
- overlay_shutdown();
-#endif
- audio_shutdown();
- mkfw_cleanup();
- return 0;
-}