diff --git a/src/base/base_entry_point.c b/src/base/base_entry_point.c index e94561a8..83aba9ef 100644 --- a/src/base/base_entry_point.c +++ b/src/base/base_entry_point.c @@ -18,6 +18,61 @@ main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **argum { ProfBeginCapture(arguments[0]); } +#if defined(OS_CORE_H) + os_init(); +#endif +#if defined(TASK_SYSTEM_H) + ts_init(); +#endif +#if defined(HASH_STORE_H) + hs_init(); +#endif +#if defined(FILE_STREAM_H) + fs_init(); +#endif +#if defined(TEXT_CACHE_H) + txt_init(); +#endif +#if defined(DBGI_H) + dbgi_init(); +#endif +#if defined(TXTI_H) + txti_init(); +#endif +#if defined(DEMON_CORE_H) + demon_init(); +#endif +#if defined(CTRL_CORE_H) + ctrl_init(); +#endif +#if defined(DASM_H) + dasm_init(); +#endif +#if defined(OS_GRAPHICAL_H) + os_graphical_init(); +#endif +#if defined(FONT_PROVIDER_H) + fp_init(); +#endif +#if defined(RENDER_CORE_H) + r_init(&cmdline); +#endif +#if defined(TEXTURE_CACHE_H) + tex_init(); +#endif +#if defined(GEO_CACHE_H) + geo_init(); +#endif +#if defined(FONT_CACHE_H) + f_init(); +#endif +#if defined(DF_CORE_H) + DF_StateDeltaHistory *hist = df_state_delta_history_alloc(); + df_core_init(&cmdline, hist); +#endif +#if defined(DF_GFX_H) + df_gfx_init(update_and_render, df_state_delta_history()); +#endif entry_point(&cmdline); if(capture) { diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index d3da0004..c7d7041f 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -10,12 +10,11 @@ //~ rjf: Main Layer Initialization internal void -ctrl_init(CTRL_WakeupFunctionType *wakeup_hook) +ctrl_init(void) { Arena *arena = arena_alloc(); ctrl_state = push_array(arena, CTRL_State, 1); ctrl_state->arena = arena; - ctrl_state->wakeup_hook = wakeup_hook; for(Architecture arch = (Architecture)0; arch < Architecture_COUNT; arch = (Architecture)(arch+1)) { String8 *reg_names = regs_reg_code_string_table_from_architecture(arch); @@ -72,6 +71,15 @@ ctrl_init(CTRL_WakeupFunctionType *wakeup_hook) } } +//////////////////////////////// +//~ rjf: Wakeup Callback Registration + +internal void +ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook) +{ + ctrl_state->wakeup_hook = wakeup_hook; +} + //////////////////////////////// //~ rjf: Basic Type Functions diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index bda8ec5a..f507548d 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -447,7 +447,12 @@ global CTRL_State *ctrl_state = 0; //////////////////////////////// //~ rjf: Main Layer Initialization -internal void ctrl_init(CTRL_WakeupFunctionType *wakeup_hook); +internal void ctrl_init(void); + +//////////////////////////////// +//~ rjf: Wakeup Callback Registration + +internal void ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook); //////////////////////////////// //~ rjf: Basic Type Functions diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index f19a43d4..7f48339e 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -6385,7 +6385,7 @@ df_push_cmd__root(DF_CmdParams *params, DF_CmdSpec *spec) //~ rjf: Main Layer Top-Level Calls internal void -df_core_init(String8 user_path, String8 profile_path, DF_StateDeltaHistory *hist) +df_core_init(CmdLine *cmdln, DF_StateDeltaHistory *hist) { Arena *arena = arena_alloc(); df_state = push_array(arena, DF_State, 1); @@ -6450,8 +6450,25 @@ df_core_init(String8 user_path, String8 profile_path, DF_StateDeltaHistory *hist { Temp scratch = scratch_begin(0, 0); + // rjf: unpack command line arguments + String8 user_cfg_path = cmd_line_string(cmdln, str8_lit("user")); + String8 profile_cfg_path = cmd_line_string(cmdln, str8_lit("profile")); + { + String8 user_program_data_path = os_string_from_system_path(scratch.arena, OS_SystemPath_UserProgramData); + String8 user_data_folder = push_str8f(scratch.arena, "%S/%S", user_program_data_path, str8_lit("raddbg")); + os_make_directory(user_data_folder); + if(user_cfg_path.size == 0) + { + user_cfg_path = push_str8f(scratch.arena, "%S/default.raddbg_user", user_data_folder); + } + if(profile_cfg_path.size == 0) + { + profile_cfg_path = push_str8f(scratch.arena, "%S/default.raddbg_profile", user_data_folder); + } + } + // rjf: set up config path state - String8 cfg_src_paths[DF_CfgSrc_COUNT] = {user_path, profile_path}; + String8 cfg_src_paths[DF_CfgSrc_COUNT] = {user_cfg_path, profile_cfg_path}; for(DF_CfgSrc src = (DF_CfgSrc)0; src < DF_CfgSrc_COUNT; src = (DF_CfgSrc)(src+1)) { df_state->cfg_path_arenas[src] = arena_alloc(); diff --git a/src/df/core/df_core.h b/src/df/core/df_core.h index 3c39e548..df3e866d 100644 --- a/src/df/core/df_core.h +++ b/src/df/core/df_core.h @@ -1690,7 +1690,7 @@ internal void df_push_cmd__root(DF_CmdParams *params, DF_CmdSpec *spec); //////////////////////////////// //~ rjf: Main Layer Top-Level Calls -internal void df_core_init(String8 user_path, String8 profile_path, DF_StateDeltaHistory *hist); +internal void df_core_init(CmdLine *cmdln, DF_StateDeltaHistory *hist); internal DF_CmdList df_core_gather_root_cmds(Arena *arena); internal void df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt); internal void df_core_end_frame(void); diff --git a/src/os/core/win32/os_core_win32.c b/src/os/core/win32/os_core_win32.c index 8ad5b58f..32e6b094 100644 --- a/src/os/core/win32/os_core_win32.c +++ b/src/os/core/win32/os_core_win32.c @@ -1779,20 +1779,15 @@ int main(int argc, char **argv) int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { SetUnhandledExceptionFilter(&win32_exception_filter); - Arena *args_arena = arena_alloc__sized(KB(64), KB(64)); - WCHAR *command_line = GetCommandLineW(); - int argc = 0; - WCHAR **argv_16 = CommandLineToArgvW(command_line, &argc); - char **argv = push_array(args_arena, char *, argc); + char **argv = __argv; + int argc = __argc; for(int i = 0; i < argc; i += 1) { - String16 arg16 = str16_cstring((U16 *)argv_16[i]); - String8 arg8 = str8_from_16(args_arena, arg16); + String8 arg8 = str8_cstring(argv[i]); if(str8_match(arg8, str8_lit("--quiet"), StringMatchFlag_CaseInsensitive)) { win32_g_is_quiet = 1; } - argv[i] = (char *)arg8.str; } main_thread_base_entry_point(entry_point, argv, (U64)argc); return 0; diff --git a/src/raddbg/raddbg_main.cpp b/src/raddbg/raddbg_main.cpp index 07f049da..24565311 100644 --- a/src/raddbg/raddbg_main.cpp +++ b/src/raddbg/raddbg_main.cpp @@ -140,14 +140,8 @@ entry_point(CmdLine *cmd_line) SetStdHandle(STD_ERROR_HANDLE, 0); #endif - //- rjf: initialize basic dependencies - os_init(); - ts_init(); - //- rjf: unpack command line arguments ExecMode exec_mode = ExecMode_Normal; - String8 user_cfg_path = str8_lit(""); - String8 profile_cfg_path = str8_lit(""); B32 auto_run = 0; B32 auto_step = 0; B32 jit_attach = 0; @@ -168,8 +162,6 @@ entry_point(CmdLine *cmd_line) { exec_mode = ExecMode_Help; } - user_cfg_path = cmd_line_string(cmd_line, str8_lit("user")); - profile_cfg_path = cmd_line_string(cmd_line, str8_lit("profile")); auto_run = cmd_line_has_flag(cmd_line, str8_lit("auto_run")); auto_step = cmd_line_has_flag(cmd_line, str8_lit("auto_step")); String8 jit_pid_string = cmd_line_string(cmd_line, str8_lit("jit_pid")); @@ -181,20 +173,8 @@ entry_point(CmdLine *cmd_line) jit_attach = (jit_addr != 0); } - //- rjf: set default user/profile paths - { - String8 user_program_data_path = os_string_from_system_path(scratch.arena, OS_SystemPath_UserProgramData); - String8 user_data_folder = push_str8f(scratch.arena, "%S/%S", user_program_data_path, str8_lit("raddbg")); - os_make_directory(user_data_folder); - if(user_cfg_path.size == 0) - { - user_cfg_path = push_str8f(scratch.arena, "%S/default.raddbg_user", user_data_folder); - } - if(profile_cfg_path.size == 0) - { - profile_cfg_path = push_str8f(scratch.arena, "%S/default.raddbg_profile", user_data_folder); - } - } + //- rjf: set up layers + ctrl_set_wakeup_hook(wakeup_hook); //- rjf: dispatch to top-level codepath based on execution mode switch(exec_mode) @@ -210,28 +190,6 @@ entry_point(CmdLine *cmd_line) IPCInfo *ipc_info = (IPCInfo *)ipc_shared_memory_base; ipc_info->msg_size = 0; - //- rjf: initialize stuff we depend on - { - hs_init(); - fs_init(); - txt_init(); - dbgi_init(); - txti_init(); - demon_init(); - ctrl_init(wakeup_hook); - dasm_init(); - os_graphical_init(); - fp_init(); - r_init(cmd_line); - tex_init(); - geo_init(); - f_init(); - DF_StateDeltaHistory *hist = df_state_delta_history_alloc(); - df_core_init(user_cfg_path, profile_cfg_path, hist); - df_gfx_init(update_and_render, hist); - os_set_cursor(OS_Cursor_Pointer); - } - //- rjf: setup initial target from command line args { String8List args = cmd_line->inputs; diff --git a/src/raddbgi_dump/raddbgi_dump_main.c b/src/raddbgi_dump/raddbgi_dump_main.c index b47f5789..5346b2f4 100644 --- a/src/raddbgi_dump/raddbgi_dump_main.c +++ b/src/raddbgi_dump/raddbgi_dump_main.c @@ -39,8 +39,6 @@ entry_point(CmdLine *cmd_line) ////////////////////////////// //- rjf: set up // - local_persist TCTX main_thread_tctx = {0}; - tctx_init_and_equip(&main_thread_tctx); Arena *arena = arena_alloc(); String8List errors = {0}; diff --git a/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c b/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c index df0454c2..42ed46b5 100644 --- a/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c +++ b/src/raddbgi_from_pdb/raddbgi_from_pdb_main.c @@ -50,10 +50,6 @@ internal void entry_point(CmdLine *cmdline) { - //- rjf: initialize dependencies - os_init(); - ts_init(); - //- rjf: initialize state, unpack command line Arena *arena = arena_alloc(); P2R_User2Convert *user2convert = p2r_user2convert_from_cmdln(arena, cmdline); diff --git a/src/scratch/ryan_scratch.c b/src/scratch/ryan_scratch.c index 46717f0a..11fa3a04 100644 --- a/src/scratch/ryan_scratch.c +++ b/src/scratch/ryan_scratch.c @@ -10,6 +10,5 @@ int main(int argument_count, char **arguments) { - return 0; }