diff --git a/build.c b/build.c index f1105827..957096a9 100644 --- a/build.c +++ b/build.c @@ -442,7 +442,7 @@ void OnBuild(StringList cli_args) D_Tag res_dir = D_TagFromPath(&perm, Lit("res"), D_TagKind_Dir); D_Tag icon_file = D_TagFromPath(&perm, Lit("icon.ico"), D_TagKind_File); - D_Tag inc_src_file = D_TagFromPath(&perm, Lit("src/inc.c"), D_TagKind_File); + D_Tag inc_src_file = D_TagFromPath(&perm, Lit("src/inc/inc_core.c"), D_TagKind_File); D_Tag rc_res_file = D_TagFromPath(&perm, StringF(&perm, Lit("%F/rc.res"), FmtStr(out_obj_dir_path)), D_TagKind_File); /* ========================== * @@ -496,7 +496,6 @@ void OnBuild(StringList cli_args) "-fno-strict-aliasing " "-fno-finite-loops " "-fwrapv " - "-I src/ " "-msse4.1 " "-msse4.2 ")); @@ -962,14 +961,30 @@ void OnBuild(StringList cli_args) D_GetDirContents(&perm, &src_files, src_dir, 0); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/base/base.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/prof/prof.cpp"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/sys/sys.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/gp/gp.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/resource/resource.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/watch/watch.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/tar/tar.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/ase/ase.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/mp3/mp3.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/json/json.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/ttf/ttf.cpp"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/dxc/dxc.cpp"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/sprite/sprite.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/font/font.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/sound/sound.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/draw/draw.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/inc/inc.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/host/host.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/asset_cache/asset_cache.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/mixer/mixer.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/settings/settings.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/space/space.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/collider/collider.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/app/app.c"), D_TagKind_File)); + D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/playback/playback.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/sim/sim.c"), D_TagKind_File)); D_TagListAppend(&perm, &src_files, D_TagFromPath(&perm, Lit("src/user/user.c"), D_TagKind_File)); @@ -993,7 +1008,7 @@ void OnBuild(StringList cli_args) if (PlatformWindows) { ignore = !(StringEqual(name, Lit("sys_win32.c")) || StringEqual(name, Lit("gp_dx12.c")) || - StringEqual(name, Lit("playback_wasapi.c")) || + StringEqual(name, Lit("playback_win32.c")) || StringEqual(name, Lit("mp3_mmf.c")) || StringEqual(name, Lit("ttf_dwrite.cpp")) || StringEqual(name, Lit("dxc.cpp"))); diff --git a/src/app/app.c b/src/app/app.c new file mode 100644 index 00000000..48498f5a --- /dev/null +++ b/src/app/app.c @@ -0,0 +1,3 @@ +#include "app.h" + +#include "app_core.c" diff --git a/src/app/app.h b/src/app/app.h new file mode 100644 index 00000000..30635e04 --- /dev/null +++ b/src/app/app.h @@ -0,0 +1,24 @@ +#ifndef APP_H +#define APP_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../ttf/ttf.h" +#include "../gp/gp.h" +#include "../sim/sim.h" +#include "../user/user.h" +#include "../sprite/sprite.h" +#include "../watch/watch.h" +#include "../draw/draw.h" +#include "../sound/sound.h" +#include "../font/font.h" +#include "../asset_cache/asset_cache.h" +#include "../mixer/mixer.h" +#include "../settings/settings.h" +#include "../host/host.h" +#include "../resource/resource.h" +#include "../playback/playback.h" + +#include "app_core.h" + +#endif diff --git a/src/app.c b/src/app/app_core.c similarity index 96% rename from src/app.c rename to src/app/app_core.c index a7253745..80c457c8 100644 --- a/src/app.c +++ b/src/app/app_core.c @@ -1,22 +1,3 @@ -#include "app.h" -#include "base/base.h" -#include "sys/sys.h" -#include "ttf/ttf.h" -#include "gp/gp.h" -#include "sim/sim.h" -#include "user/user.h" -#include "playback.h" -#include "resource.h" -#include "asset_cache.h" -#include "font.h" -#include "sprite.h" -#include "mixer.h" -#include "sound.h" -#include "settings.h" -#include "draw.h" -#include "host.h" -#include "watch.h" - GLOBAL struct { struct arena *arena; struct string write_path; diff --git a/src/app.h b/src/app/app_core.h similarity index 68% rename from src/app.h rename to src/app/app_core.h index b178288e..bfbf7cbe 100644 --- a/src/app.h +++ b/src/app/app_core.h @@ -1,6 +1 @@ -#ifndef APP_H -#define APP_H - struct string app_write_path_cat(struct arena *arena, struct string filename); - -#endif diff --git a/src/asset_cache/asset_cache.c b/src/asset_cache/asset_cache.c new file mode 100644 index 00000000..bbf567ec --- /dev/null +++ b/src/asset_cache/asset_cache.c @@ -0,0 +1,3 @@ +#include "asset_cache.h" + +#include "asset_cache_core.c" diff --git a/src/asset_cache/asset_cache.h b/src/asset_cache/asset_cache.h new file mode 100644 index 00000000..986277bd --- /dev/null +++ b/src/asset_cache/asset_cache.h @@ -0,0 +1,9 @@ +#ifndef ASSET_CACHE_H +#define ASSET_CACHE_H + +#include "../base/base.h" +#include "../sys/sys.h" + +#include "asset_cache_core.h" + +#endif diff --git a/src/asset_cache.c b/src/asset_cache/asset_cache_core.c similarity index 98% rename from src/asset_cache.c rename to src/asset_cache/asset_cache_core.c index a4398585..7fc6b1c1 100644 --- a/src/asset_cache.c +++ b/src/asset_cache/asset_cache_core.c @@ -1,7 +1,3 @@ -#include "asset_cache.h" -#include "base/base.h" -#include "sys/sys.h" - /* ========================== * * Global state * ========================== */ diff --git a/src/asset_cache.h b/src/asset_cache/asset_cache_core.h similarity index 91% rename from src/asset_cache.h rename to src/asset_cache/asset_cache_core.h index d8ae7e9c..8e434950 100644 --- a/src/asset_cache.h +++ b/src/asset_cache/asset_cache_core.h @@ -1,9 +1,3 @@ -#ifndef ASSET_CACHE_H -#define ASSET_CACHE_H - -#include "base/base.h" -#include "sys/sys.h" - enum asset_status { ASSET_STATUS_NONE, @@ -49,5 +43,3 @@ struct asset_cache_store asset_cache_store_open(void); void asset_cache_store_close(struct asset_cache_store *store); u64 asset_cache_hash(struct string key); - -#endif diff --git a/src/base/base.c b/src/base/base.c index e03020d9..5a9298df 100644 --- a/src/base/base.c +++ b/src/base/base.c @@ -2,8 +2,9 @@ #include "base_fiber.c" #include "base_arena.c" -#include "base_buddy.c" +#include "base_gstat.c" #include "base_memory.c" +#include "base_buddy.c" #include "base_rand.c" #include "base_string.c" #include "base_bitbuff.c" diff --git a/src/base/base.h b/src/base/base.h index 75e1b9f4..dc072a17 100644 --- a/src/base/base.h +++ b/src/base/base.h @@ -1,11 +1,12 @@ #ifndef BASE_H #define BASE_H -#include "../gstat.h" +#include "../prof/prof.h" #include "base_intrinsics.h" #include "base_atomic.h" #include "base_fiber.h" +#include "base_gstat.h" #include "base_memory.h" #include "base_arena.h" #include "base_buddy.h" diff --git a/src/gstat.c b/src/base/base_gstat.c similarity index 73% rename from src/gstat.c rename to src/base/base_gstat.c index 6cb0199e..9d33c4ba 100644 --- a/src/gstat.c +++ b/src/base/base_gstat.c @@ -1,5 +1,3 @@ -#include "gstat.h" - #if GSTAT_ENABLED struct _gstats _g_gstats = ZI; #endif diff --git a/src/gstat.h b/src/base/base_gstat.h similarity index 91% rename from src/gstat.h rename to src/base/base_gstat.h index 1cceffdc..035617e6 100644 --- a/src/gstat.h +++ b/src/base/base_gstat.h @@ -1,12 +1,7 @@ -#ifndef GSTAT_H -#define GSTAT_H - /* Program-wide statistics */ #if GSTAT_ENABLED -#include "base/base.h" - struct _gstats { struct atomic64_padded GSTAT_SOCK_BYTES_SENT; struct atomic64_padded GSTAT_SOCK_BYTES_RECEIVED; @@ -30,6 +25,3 @@ extern struct _gstats _g_gstats; #define gstat_get(name) 0 #endif - - -#endif diff --git a/src/collider/collider.c b/src/collider/collider.c new file mode 100644 index 00000000..af2f721b --- /dev/null +++ b/src/collider/collider.c @@ -0,0 +1,3 @@ +#include "collider.h" + +#include "collider_core.c" diff --git a/src/collider/collider.h b/src/collider/collider.h new file mode 100644 index 00000000..65fe51e5 --- /dev/null +++ b/src/collider/collider.h @@ -0,0 +1,8 @@ +#ifndef COLLIDER_H +#define COLLIDER_H + +#include "../base/base.h" + +#include "collider_core.h" + +#endif diff --git a/src/collider.c b/src/collider/collider_core.c similarity index 99% rename from src/collider.c rename to src/collider/collider_core.c index 239ae0b6..587ff533 100644 --- a/src/collider.c +++ b/src/collider/collider_core.c @@ -1,7 +1,3 @@ -#include "collider.h" -#include "base/base.h" -#include "gstat.h" - /* How close can non-overlapping shapes be before collision is considered */ #define COLLISION_TOLERANCE 0.005f diff --git a/src/collider.h b/src/collider/collider_core.h similarity index 98% rename from src/collider.h rename to src/collider/collider_core.h index 95d0f058..c751fefd 100644 --- a/src/collider.h +++ b/src/collider/collider_core.h @@ -1,6 +1,3 @@ -#ifndef COLLIDER_H -#define COLLIDER_H - struct collider_support_point { struct v2 p; u32 i; /* Index of original point in shape */ @@ -70,5 +67,3 @@ f32 collider_time_of_impact(struct collider_shape *c0, struct collider_shape *c1 struct v2_array menkowski(struct arena *arena, struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1, u32 detail); struct v2_array cloud(struct arena *arena, struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1); - -#endif diff --git a/src/common.h b/src/common.h index c4c57063..ef350747 100644 --- a/src/common.h +++ b/src/common.h @@ -680,17 +680,6 @@ INLINE f64 clamp_f64(f64 v, f64 min, f64 max) { return v < min ? min : v > max ? #include "config.h" -/* ========================== * - * Profiling - * ========================== */ - -#include "prof_tracy.h" - -#define PROF_THREAD_GROUP_FIBERS -(i64)GIBI(1) -#define PROF_THREAD_GROUP_SCHEDULER -(i64)MEBI(3) -#define PROF_THREAD_GROUP_WINDOW -(i64)MEBI(2) -#define PROF_THREAD_GROUP_MAIN -(i64)MEBI(1) - #ifdef __cplusplus } #endif diff --git a/src/config.h b/src/config.h index bb6667f2..9c7410fe 100644 --- a/src/config.h +++ b/src/config.h @@ -82,6 +82,11 @@ /* If enabled, things like network writes & memory allocations will be tracked in a global statistics struct */ #define GSTAT_ENABLED 1 +#define PROF_THREAD_GROUP_FIBERS -(i64)GIBI(1) +#define PROF_THREAD_GROUP_SCHEDULER -(i64)MEBI(3) +#define PROF_THREAD_GROUP_WINDOW -(i64)MEBI(2) +#define PROF_THREAD_GROUP_MAIN -(i64)MEBI(1) + /* ========================== * * Settings * ========================== */ diff --git a/src/draw/draw.c b/src/draw/draw.c new file mode 100644 index 00000000..857dc99d --- /dev/null +++ b/src/draw/draw.c @@ -0,0 +1,3 @@ +#include "draw.h" + +#include "draw_core.c" diff --git a/src/draw/draw.h b/src/draw/draw.h new file mode 100644 index 00000000..691bb359 --- /dev/null +++ b/src/draw/draw.h @@ -0,0 +1,12 @@ +#ifndef DRAW_H +#define DRAW_H + +#include "../base/base.h" +#include "../gp/gp.h" +#include "../sprite/sprite.h" +#include "../font/font.h" +#include "../collider/collider.h" + +#include "draw_core.h" + +#endif diff --git a/src/draw.c b/src/draw/draw_core.c similarity index 99% rename from src/draw.c rename to src/draw/draw_core.c index fbea3c01..9cbc7bac 100644 --- a/src/draw.c +++ b/src/draw/draw_core.c @@ -1,9 +1,3 @@ -#include "draw.h" -#include "base/base.h" -#include "font.h" -#include "sprite.h" -#include "collider.h" - GLOBAL struct { struct gp_resource *solid_white_texture; } G = ZI, DEBUG_ALIAS(G, G_draw); diff --git a/src/draw.h b/src/draw/draw_core.h similarity index 98% rename from src/draw.h rename to src/draw/draw_core.h index cf36b7db..00703d81 100644 --- a/src/draw.h +++ b/src/draw/draw_core.h @@ -1,8 +1,3 @@ -#ifndef DRAW_H -#define DRAW_H - -#include "gp/gp.h" - struct font; struct font_startup_receipt; @@ -138,5 +133,3 @@ struct draw_text_params { }; struct rect draw_text(struct gp_render_sig *sig, struct draw_text_params params); - -#endif diff --git a/src/font/font.c b/src/font/font.c new file mode 100644 index 00000000..90ae31f5 --- /dev/null +++ b/src/font/font.c @@ -0,0 +1,3 @@ +#include "font.h" + +#include "font_core.c" diff --git a/src/font/font.h b/src/font/font.h new file mode 100644 index 00000000..dc745f33 --- /dev/null +++ b/src/font/font.h @@ -0,0 +1,12 @@ +#ifndef FONT_H +#define FONT_H + +#include "../base/base.h" +#include "../ttf/ttf.h" +#include "../gp/gp.h" +#include "../resource/resource.h" +#include "../asset_cache/asset_cache.h" + +#include "font_core.h" + +#endif diff --git a/src/font.c b/src/font/font_core.c similarity index 98% rename from src/font.c rename to src/font/font_core.c index 93eec2bf..60d098e0 100644 --- a/src/font.c +++ b/src/font/font_core.c @@ -1,10 +1,3 @@ -#include "font.h" -#include "base/base.h" -#include "ttf/ttf.h" -#include "gp/gp.h" -#include "asset_cache.h" -#include "resource.h" - #define LOOKUP_TABLE_SIZE (256) GLOBAL u32 g_font_codes[] = { 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F,0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F,0xA0,0xA1,0xA2,0xA3,0xA4,0xA5,0xA6,0xA7,0xA8,0xA9,0xAA,0xAB,0xAC,0xAD,0xAE,0xAF,0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF,0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF,0xD0,0xD1,0xD2,0xD3,0xD4,0xD5,0xD6,0xD7,0xD8,0xD9,0xDA,0xDB,0xDC,0xDD,0xDE,0xDF,0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF,0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF diff --git a/src/font.h b/src/font/font_core.h similarity index 93% rename from src/font.h rename to src/font/font_core.h index 4249e4c4..ad8bb9ee 100644 --- a/src/font.h +++ b/src/font/font_core.h @@ -1,8 +1,3 @@ -#ifndef FONT_H -#define FONT_H - -#include "base/base.h" - struct asset; struct asset_cache_startup_receipt; struct ttf_startup_receipt; @@ -35,5 +30,3 @@ struct font *font_load_async(struct string path, f32 point_size); struct font *font_load(struct string path, f32 point_size); struct font_glyph *font_get_glyph(struct font *font, u32 codepoint); - -#endif diff --git a/src/gp/gp.h b/src/gp/gp.h index 5a264da0..5efd4495 100644 --- a/src/gp/gp.h +++ b/src/gp/gp.h @@ -6,6 +6,9 @@ #include "../tar/tar.h" #include "../ase/ase.h" #include "../dxc/dxc.h" +#include "../inc/inc.h" +#include "../resource/resource.h" +#include "../watch/watch.h" #include "gp_core.h" diff --git a/src/gp/gp_core_dx12.c b/src/gp/gp_core_dx12.c index 280cacd6..5ea4ef5d 100644 --- a/src/gp/gp_core_dx12.c +++ b/src/gp/gp_core_dx12.c @@ -1,8 +1,5 @@ -#include "../sprite.h" -#include "../gstat.h" -#include "../resource.h" -#include "../inc.h" -#include "../watch.h" +/* TODO: Remove this */ +#include "../sprite/sprite.h" /* Include common shader types */ #define SH_CPU 1 diff --git a/src/host/host.c b/src/host/host.c new file mode 100644 index 00000000..55c45291 --- /dev/null +++ b/src/host/host.c @@ -0,0 +1,3 @@ +#include "host.h" + +#include "host_core.c" diff --git a/src/host/host.h b/src/host/host.h new file mode 100644 index 00000000..b45b2e48 --- /dev/null +++ b/src/host/host.h @@ -0,0 +1,9 @@ +#ifndef HOST_H +#define HOST_H + +#include "../base/base.h" +#include "../sys/sys.h" + +#include "host_core.h" + +#endif diff --git a/src/host.c b/src/host/host_core.c similarity index 99% rename from src/host.c rename to src/host/host_core.c index fccaef09..6cecff1e 100644 --- a/src/host.c +++ b/src/host/host_core.c @@ -1,7 +1,3 @@ -#include "host.h" -#include "base/base.h" -#include "sys/sys.h" - /* TODO: * * Rate limiting. diff --git a/src/host.h b/src/host/host_core.h similarity index 97% rename from src/host.h rename to src/host/host_core.h index 09c7b4ba..6abe1135 100644 --- a/src/host.h +++ b/src/host/host_core.h @@ -1,9 +1,3 @@ -#ifndef HOST_H -#define HOST_H - -#include "base/base.h" -#include "sys/sys.h" - #define HOST_CHANNEL_ID_NIL (struct host_channel_id) { .gen = 0, .idx = 0 } #define HOST_CHANNEL_ID_ALL (struct host_channel_id) { .gen = U32_MAX, .idx = U32_MAX } @@ -137,5 +131,3 @@ INLINE b32 host_channel_id_is_nil(struct host_channel_id id) { return id.gen == struct host_event_list host_update_begin(struct arena *arena, struct host *host); void host_update_end(struct host *host); - -#endif diff --git a/src/inc/inc.c b/src/inc/inc.c new file mode 100644 index 00000000..a89d040a --- /dev/null +++ b/src/inc/inc.c @@ -0,0 +1,3 @@ +#include "inc.h" + +#include "inc_core.c" diff --git a/src/inc/inc.h b/src/inc/inc.h new file mode 100644 index 00000000..5a032d4c --- /dev/null +++ b/src/inc/inc.h @@ -0,0 +1,8 @@ +#ifndef INC_H +#define INC_H + +#include "../base/base.h" + +#include "inc_core.h" + +#endif diff --git a/src/inc.c b/src/inc/inc_core.c similarity index 92% rename from src/inc.c rename to src/inc/inc_core.c index e183c53f..0e144a53 100644 --- a/src/inc.c +++ b/src/inc/inc_core.c @@ -1,6 +1,3 @@ -#include "inc.h" -#include "base/base.h" - /* This is the file that actually includes binary data meant to be embedded in * the executable. Embedded files should be added as dependencies to this source * file via the build system to ensure this translation unit is recompiled upon diff --git a/src/inc.h b/src/inc/inc_core.h similarity index 72% rename from src/inc.h rename to src/inc/inc_core.h index c14138ed..e604ab46 100644 --- a/src/inc.h +++ b/src/inc/inc_core.h @@ -1,10 +1,5 @@ -#ifndef INC_H -#define INC_H - #if RESOURCES_EMBEDDED struct string inc_res_tar(void); #endif struct string inc_dxc_tar(void); - -#endif diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c new file mode 100644 index 00000000..38b0235f --- /dev/null +++ b/src/mixer/mixer.c @@ -0,0 +1,3 @@ +#include "mixer.h" + +#include "mixer_core.c" diff --git a/src/mixer/mixer.h b/src/mixer/mixer.h new file mode 100644 index 00000000..ce2ff76a --- /dev/null +++ b/src/mixer/mixer.h @@ -0,0 +1,10 @@ +#ifndef MIXER_H +#define MIXER_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../sound/sound.h" + +#include "mixer_core.h" + +#endif diff --git a/src/mixer.c b/src/mixer/mixer_core.c similarity index 99% rename from src/mixer.c rename to src/mixer/mixer_core.c index bcdd6116..82f8f52c 100644 --- a/src/mixer.c +++ b/src/mixer/mixer_core.c @@ -1,8 +1,3 @@ -#include "mixer.h" -#include "base/base.h" -#include "sys/sys.h" -#include "sound.h" - /* TODO: Cap max sounds playing. */ /* Terminology: diff --git a/src/mixer.h b/src/mixer/mixer_core.h similarity index 96% rename from src/mixer.h rename to src/mixer/mixer_core.h index 73c8684d..61abe1d5 100644 --- a/src/mixer.h +++ b/src/mixer/mixer_core.h @@ -1,6 +1,3 @@ -#ifndef MIXER_H -#define MIXER_H - struct sound; #define MIXER_FLAG_NONE 0x0 @@ -50,5 +47,3 @@ void mixer_set_listener(struct v2 pos, struct v2 dir); /* Mixing */ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_request_count); - -#endif diff --git a/src/playback/playback.c b/src/playback/playback.c new file mode 100644 index 00000000..42af1243 --- /dev/null +++ b/src/playback/playback.c @@ -0,0 +1,7 @@ +#include "playback.h" + +#if PLATFORM_WINDOWS +# include "playback_core_win32.c" +#else +# error Playback core not implemented for this platform +#endif diff --git a/src/playback/playback.h b/src/playback/playback.h new file mode 100644 index 00000000..c3a7c2b0 --- /dev/null +++ b/src/playback/playback.h @@ -0,0 +1,10 @@ +#ifndef PLAYBACK_H +#define PLAYBACK_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../mixer/mixer.h" + +#include "playback_core.h" + +#endif diff --git a/src/playback.h b/src/playback/playback_core.h similarity index 77% rename from src/playback.h rename to src/playback/playback_core.h index 12bae469..0d63f8bc 100644 --- a/src/playback.h +++ b/src/playback/playback_core.h @@ -1,9 +1,4 @@ -#ifndef PLAYBACK_H -#define PLAYBACK_H - struct mixer_startup_receipt; struct playback_startup_receipt { i32 _; }; struct playback_startup_receipt playback_startup(struct mixer_startup_receipt *mixer_sr); - -#endif diff --git a/src/playback_wasapi.c b/src/playback/playback_core_win32.c similarity index 98% rename from src/playback_wasapi.c rename to src/playback/playback_core_win32.c index 8e349e28..fad38683 100644 --- a/src/playback_wasapi.c +++ b/src/playback/playback_core_win32.c @@ -5,12 +5,6 @@ * https://gist.github.com/mmozeiko/5a5b168e61aff4c1eaec0381da62808f#file-win32_wasapi-h * ========================== */ -#include "playback.h" -#include "base/base.h" -#include "sys/sys.h" -#include "mixer.h" -#include "app.h" - #define COBJMACROS #define WIN32_LEAN_AND_MEAN #define UNICODE diff --git a/src/prof/prof.cpp b/src/prof/prof.cpp new file mode 100644 index 00000000..e04e5cc6 --- /dev/null +++ b/src/prof/prof.cpp @@ -0,0 +1,3 @@ +#include "prof.h" + +#include "prof_core_tracy.cpp" diff --git a/src/prof/prof.h b/src/prof/prof.h new file mode 100644 index 00000000..2e4f2206 --- /dev/null +++ b/src/prof/prof.h @@ -0,0 +1,6 @@ +#ifndef PROF_H +#define PROF_H + +#include "prof_core_tracy.h" + +#endif diff --git a/src/prof/prof_core_tracy.cpp b/src/prof/prof_core_tracy.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/prof_tracy.h b/src/prof/prof_core_tracy.h similarity index 99% rename from src/prof_tracy.h rename to src/prof/prof_core_tracy.h index 6582732e..977848d1 100644 --- a/src/prof_tracy.h +++ b/src/prof/prof_core_tracy.h @@ -1,6 +1,3 @@ -#ifndef PROF_H -#define PROF_H - #if PROFILING #if COMPILER_MSVC @@ -153,5 +150,3 @@ FORCE_NO_INLINE INLINE void __prof_fiber_leave(void) { TracyCFiberLeave; } # define __prof_fiber_enter(fiber_name, profiler_group) # define __prof_fiber_leave() #endif - -#endif diff --git a/src/prof_tracy.cpp b/src/prof_tracy.cpp deleted file mode 100644 index aecad03b..00000000 --- a/src/prof_tracy.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#if PROFILING - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Weverything" -#define TRACY_FIBERS -# include TRACY_CLIENT_SRC_PATH -#pragma clang diagnostic pop - -#endif diff --git a/src/resource/resource.c b/src/resource/resource.c new file mode 100644 index 00000000..4e9714cb --- /dev/null +++ b/src/resource/resource.c @@ -0,0 +1,3 @@ +#include "resource.h" + +#include "resource_core.c" diff --git a/src/resource/resource.h b/src/resource/resource.h new file mode 100644 index 00000000..cfa0df62 --- /dev/null +++ b/src/resource/resource.h @@ -0,0 +1,14 @@ +#ifndef RESOURCE_H +#define RESOURCE_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../tar/tar.h" + +#if RESOURCES_EMBEDDED +# include "../inc/inc.h" +#endif + +#include "resource_core.h" + +#endif diff --git a/src/resource.c b/src/resource/resource_core.c similarity index 94% rename from src/resource.c rename to src/resource/resource_core.c index 4a0a06aa..7df10f85 100644 --- a/src/resource.c +++ b/src/resource/resource_core.c @@ -1,17 +1,7 @@ -#include "resource.h" -#include "app.h" -#include "base/base.h" -#include "sys/sys.h" -#include "tar/tar.h" - /* ========================== * * Global data * ========================== */ -#if RESOURCES_EMBEDDED -# include "inc.h" -#endif - /* Add resource data to binary */ GLOBAL struct { diff --git a/src/resource.h b/src/resource/resource_core.h similarity index 94% rename from src/resource.h rename to src/resource/resource_core.h index ec0cb974..7637dd73 100644 --- a/src/resource.h +++ b/src/resource/resource_core.h @@ -1,8 +1,3 @@ -#ifndef RESOURCE_H -#define RESOURCE_H - -#include "sys/sys.h" - #define RESOURCE_NAME_LEN_MAX 256 /* A resource contains data that can be retrieved globally by name. @@ -53,5 +48,3 @@ struct resource resource_open(struct string name); #else #define resource_get_name(res_ptr) STRING((res_ptr)->_name_len, (res_ptr)->_name_text) #endif - -#endif diff --git a/src/settings/settings.c b/src/settings/settings.c new file mode 100644 index 00000000..3e05f5c3 --- /dev/null +++ b/src/settings/settings.c @@ -0,0 +1,3 @@ +#include "settings.h" + +#include "settings_core.c" diff --git a/src/settings/settings.h b/src/settings/settings.h new file mode 100644 index 00000000..8ed9a898 --- /dev/null +++ b/src/settings/settings.h @@ -0,0 +1,10 @@ +#ifndef SETTINGS_H +#define SETTINGS_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../json/json.h" + +#include "settings_core.h" + +#endif diff --git a/src/settings.c b/src/settings/settings_core.c similarity index 98% rename from src/settings.c rename to src/settings/settings_core.c index 4dcfebbf..928b2c5d 100644 --- a/src/settings.c +++ b/src/settings/settings_core.c @@ -1,8 +1,3 @@ -#include "settings.h" -#include "base/base.h" -#include "sys/sys.h" -#include "json/json.h" - struct string settings_serialize(struct arena *arena, const struct sys_window_settings *settings) { __prof; diff --git a/src/settings.h b/src/settings/settings_core.h similarity index 84% rename from src/settings.h rename to src/settings/settings_core.h index 6af5532c..59d69cbe 100644 --- a/src/settings.h +++ b/src/settings/settings_core.h @@ -1,9 +1,5 @@ -#ifndef SETTINGS_H -#define SETTINGS_H - struct sys_window_settings; struct string settings_serialize(struct arena *arena, const struct sys_window_settings *settings); -struct sys_window_settings *settings_deserialize(struct arena *arena, struct string src, struct string *error_out); -#endif +struct sys_window_settings *settings_deserialize(struct arena *arena, struct string src, struct string *error_out); diff --git a/src/sim/sim.h b/src/sim/sim.h index 43cfc7ca..943c4d7e 100644 --- a/src/sim/sim.h +++ b/src/sim/sim.h @@ -2,11 +2,11 @@ #define SIM_H #include "../base/base.h" -#include "../collider.h" -#include "../sprite.h" -#include "../space.h" -#include "../host.h" -#include "../mixer.h" +#include "../sprite/sprite.h" +#include "../collider/collider.h" +#include "../space/space.h" +#include "../host/host.h" +#include "../mixer/mixer.h" #include "sim_core.h" #include "sim_phys.h" diff --git a/src/sound/sound.c b/src/sound/sound.c new file mode 100644 index 00000000..aa22fe9e --- /dev/null +++ b/src/sound/sound.c @@ -0,0 +1,3 @@ +#include "sound.h" + +#include "sound_core.c" diff --git a/src/sound/sound.h b/src/sound/sound.h new file mode 100644 index 00000000..ef384e10 --- /dev/null +++ b/src/sound/sound.h @@ -0,0 +1,12 @@ +#ifndef SOUND_H +#define SOUND_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../mp3/mp3.h" +#include "../resource/resource.h" +#include "../asset_cache/asset_cache.h" + +#include "sound_core.h" + +#endif diff --git a/src/sound.c b/src/sound/sound_core.c similarity index 97% rename from src/sound.c rename to src/sound/sound_core.c index 384dce97..90210950 100644 --- a/src/sound.c +++ b/src/sound/sound_core.c @@ -1,10 +1,3 @@ -#include "sound.h" -#include "base/base.h" -#include "sys/sys.h" -#include "resource.h" -#include "asset_cache.h" -#include "mp3/mp3.h" - #define SOUND_SAMPLE_RATE 48000 struct sound_task_params { diff --git a/src/sound.h b/src/sound/sound_core.h similarity index 92% rename from src/sound.h rename to src/sound/sound_core.h index ad00b820..865e5398 100644 --- a/src/sound.h +++ b/src/sound/sound_core.h @@ -1,6 +1,3 @@ -#ifndef SOUND_H -#define SOUND_H - #define SOUND_FLAG_NONE 0x0 #define SOUND_FLAG_STEREO 0x1 @@ -18,5 +15,3 @@ struct sound_startup_receipt sound_startup(struct asset_cache_startup_receipt *a struct asset *sound_load_asset(struct string path, u32 flags, b32 wait); struct sound *sound_load_async(struct string path, u32 flags); struct sound *sound_load(struct string path, u32 flags); - -#endif diff --git a/src/space/space.c b/src/space/space.c new file mode 100644 index 00000000..2d6c673c --- /dev/null +++ b/src/space/space.c @@ -0,0 +1,3 @@ +#include "space.h" + +#include "space_core.c" diff --git a/src/space/space.h b/src/space/space.h new file mode 100644 index 00000000..dff648e0 --- /dev/null +++ b/src/space/space.h @@ -0,0 +1,9 @@ +#ifndef SPACE_H +#define SPACE_H + +#include "../base/base.h" +#include "../collider/collider.h" + +#include "space_core.h" + +#endif diff --git a/src/space.c b/src/space/space_core.c similarity index 99% rename from src/space.c rename to src/space/space_core.c index cbad7dea..b9948268 100644 --- a/src/space.c +++ b/src/space/space_core.c @@ -1,7 +1,3 @@ -#include "space.h" -#include "base/base.h" -#include "collider.h" - /* FIXME: Default space entry & cell pointers to nil */ /* Offset in bytes from start of space struct to start of entry array (assume adjacently allocated) */ diff --git a/src/space.h b/src/space/space_core.h similarity index 98% rename from src/space.h rename to src/space/space_core.h index 1cc4ac20..f04e5ae2 100644 --- a/src/space.h +++ b/src/space/space_core.h @@ -1,6 +1,3 @@ -#ifndef SPACE_H -#define SPACE_H - struct space_cell_bin; struct space_entry { @@ -132,5 +129,3 @@ void space_entry_update_aabb(struct space_entry *entry, struct aabb new_aabb); struct space_iter space_iter_begin_aabb(struct space *space, struct aabb aabb); struct space_entry *space_iter_next(struct space_iter *iter); #define space_iter_end(i) - -#endif diff --git a/src/sprite/sprite.c b/src/sprite/sprite.c new file mode 100644 index 00000000..c1dca241 --- /dev/null +++ b/src/sprite/sprite.c @@ -0,0 +1,3 @@ +#include "sprite.h" + +#include "sprite_core.c" diff --git a/src/sprite/sprite.h b/src/sprite/sprite.h new file mode 100644 index 00000000..5c93ec56 --- /dev/null +++ b/src/sprite/sprite.h @@ -0,0 +1,13 @@ +#ifndef SPRITE_H +#define SPRITE_H + +#include "../base/base.h" +#include "../sys/sys.h" +#include "../gp/gp.h" +#include "../ase/ase.h" +#include "../resource/resource.h" +#include "../watch/watch.h" + +#include "sprite_core.h" + +#endif diff --git a/src/sprite.c b/src/sprite/sprite_core.c similarity index 99% rename from src/sprite.c rename to src/sprite/sprite_core.c index 696d17a5..04791532 100644 --- a/src/sprite.c +++ b/src/sprite/sprite_core.c @@ -1,12 +1,3 @@ -#include "sprite.h" -#include "base/base.h" -#include "sys/sys.h" -#include "ase/ase.h" -#include "resource.h" -#include "app.h" -#include "gp/gp.h" -#include "watch.h" - /* The evictor will begin evicting once cache usage is > threshold. * It will entries until the budget has shrunk < target. */ #define CACHE_MEMORY_BUDGET_THRESHOLD (MEBI(256)) diff --git a/src/sprite.h b/src/sprite/sprite_core.h similarity index 98% rename from src/sprite.h rename to src/sprite/sprite_core.h index 3b194b69..ce6b01db 100644 --- a/src/sprite.h +++ b/src/sprite/sprite_core.h @@ -1,8 +1,3 @@ -#ifndef SPRITE_H -#define SPRITE_H - -#include "base/base.h" - struct sprite_sheet_span; struct sprite_sheet_slice_group; @@ -136,5 +131,3 @@ struct sprite_sheet_slice sprite_sheet_get_slice(struct sprite_sheet *sheet, str /* Returns all slices with name in frame */ struct sprite_sheet_slice_array sprite_sheet_get_slices(struct sprite_sheet *sheet, struct string name, u32 frame_index); - -#endif diff --git a/src/sys/sys.h b/src/sys/sys.h index 048a6bd2..5fd71073 100644 --- a/src/sys/sys.h +++ b/src/sys/sys.h @@ -2,8 +2,6 @@ #define SYS_H #include "../base/base.h" -#include "../app.h" -#include "../gstat.h" #include "sys_snc.h" #include "sys_sleep.h" diff --git a/src/ttf/ttf_core_dwrite.cpp b/src/ttf/ttf_core_dwrite.cpp index f514fc1b..7d4edf4e 100644 --- a/src/ttf/ttf_core_dwrite.cpp +++ b/src/ttf/ttf_core_dwrite.cpp @@ -3,7 +3,7 @@ extern "C" { -#include "../font.h" +#include "../font/font.h" } #pragma warning(push, 0) diff --git a/src/user/user.h b/src/user/user.h index 3ecb1b64..351a60a8 100644 --- a/src/user/user.h +++ b/src/user/user.h @@ -3,6 +3,12 @@ #include "../base/base.h" #include "../sim/sim.h" +#include "../gp/gp.h" +#include "../sprite/sprite.h" +#include "../font/font.h" +#include "../collider/collider.h" +#include "../draw/draw.h" +#include "../host/host.h" #include "user_core.h" diff --git a/src/user/user_core.c b/src/user/user_core.c index 2959ee43..ccdfad0d 100644 --- a/src/user/user_core.c +++ b/src/user/user_core.c @@ -1,18 +1,3 @@ -#include "user.h" -#include "base/base.h" -#include "sys/sys.h" -#include "gp/gp.h" -#include "sim/sim.h" -#include "font.h" -#include "sprite.h" -#include "draw.h" -#include "asset_cache.h" -#include "mixer.h" -#include "collider.h" -#include "host.h" -#include "gstat.h" -#include "app.h" - struct bind_state { b32 is_held; /* Is this bind held down this frame */ u32 num_presses; /* How many times was this bind's pressed since last frame */ diff --git a/src/user/user_core.h b/src/user/user_core.h index 3bb6eecf..c30960b1 100644 --- a/src/user/user_core.h +++ b/src/user/user_core.h @@ -1,6 +1,3 @@ -#include "base/base.h" -#include "sys/sys.h" - struct font_startup_receipt; struct sprite_startup_receipt; struct draw_startup_receipt; diff --git a/src/watch/watch.c b/src/watch/watch.c new file mode 100644 index 00000000..d97ac3cd --- /dev/null +++ b/src/watch/watch.c @@ -0,0 +1,3 @@ +#include "watch.h" + +#include "watch_core.c" diff --git a/src/watch/watch.h b/src/watch/watch.h new file mode 100644 index 00000000..885ffb44 --- /dev/null +++ b/src/watch/watch.h @@ -0,0 +1,9 @@ +#ifndef WATCH_H +#define WATCH_H + +#include "../base/base.h" +#include "../sys/sys.h" + +#include "watch_core.h" + +#endif diff --git a/src/watch.c b/src/watch/watch_core.c similarity index 99% rename from src/watch.c rename to src/watch/watch_core.c index adaa68b9..819135d8 100644 --- a/src/watch.c +++ b/src/watch/watch_core.c @@ -1,10 +1,5 @@ -#include "watch.h" - #if RESOURCE_RELOADING -#include "base/base.h" -#include "sys/sys.h" - struct watch_event { struct string name; struct watch_event *next; diff --git a/src/watch.h b/src/watch/watch_core.h similarity index 88% rename from src/watch.h rename to src/watch/watch_core.h index d116ada1..dbb0c477 100644 --- a/src/watch.h +++ b/src/watch/watch_core.h @@ -1,6 +1,3 @@ -#ifndef WATCH_H -#define WATCH_H - #define WATCH_CALLBACK_FUNC_DEF(func_name, arg_name) void func_name(struct string arg_name) typedef WATCH_CALLBACK_FUNC_DEF(watch_callback, name); @@ -11,5 +8,3 @@ void watch_register_callback(watch_callback *callback); #else #define watch_register_callback(callback) #endif - -#endif