2016-02-07 21:15:58 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 21.01.2014
|
|
|
|
*
|
|
|
|
* System functions for project codename "4ed"
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
2019-06-01 23:58:28 +00:00
|
|
|
// TODO(allen): rewrite using new arenas and strings!!!!! rewrite rewrite rewrite rewrite rewrite
|
|
|
|
|
2017-03-12 01:20:24 +00:00
|
|
|
#if !defined(FCODER_SYSTEM_INTERFACE_H)
|
|
|
|
#define FCODER_SYSTEM_INTERFACE_H
|
|
|
|
|
|
|
|
// types
|
2016-02-07 21:15:58 +00:00
|
|
|
struct Plat_Handle{
|
|
|
|
u32 d[4];
|
|
|
|
};
|
|
|
|
|
2017-03-11 18:35:12 +00:00
|
|
|
// files
|
2019-08-04 00:49:40 +00:00
|
|
|
#define Sys_Get_Canonical_Sig(n) String_Const_u8 n(Arena *arena, String_Const_u8 name)
|
2016-08-26 17:52:35 +00:00
|
|
|
typedef Sys_Get_Canonical_Sig(System_Get_Canonical);
|
2016-05-27 17:11:38 +00:00
|
|
|
|
2019-08-04 00:49:40 +00:00
|
|
|
#define Sys_Get_File_List_Sig(name) File_List name(Arena *arena, String_Const_u8 directory)
|
|
|
|
typedef Sys_Get_File_List_Sig(System_Get_File_List);
|
|
|
|
|
2017-03-11 18:35:12 +00:00
|
|
|
// file load/save
|
2019-06-01 23:58:28 +00:00
|
|
|
#define Sys_Quick_File_Attributes_Sig(name) File_Attributes name(String_Const_u8 file_name)
|
2019-02-14 00:24:03 +00:00
|
|
|
typedef Sys_Quick_File_Attributes_Sig(System_Quick_File_Attributes);
|
|
|
|
|
2016-08-26 17:52:35 +00:00
|
|
|
#define Sys_Load_Handle_Sig(name) b32 name(char *filename, Plat_Handle *handle_out)
|
|
|
|
typedef Sys_Load_Handle_Sig(System_Load_Handle);
|
2016-08-22 23:54:20 +00:00
|
|
|
|
2019-02-13 23:15:22 +00:00
|
|
|
#define Sys_Load_Attributes_Sig(name) File_Attributes name(Plat_Handle handle)
|
|
|
|
typedef Sys_Load_Attributes_Sig(System_Load_Attributes);
|
2016-08-22 23:54:20 +00:00
|
|
|
|
2016-08-26 17:52:35 +00:00
|
|
|
#define Sys_Load_File_Sig(name) b32 name(Plat_Handle handle, char *buffer, u32 size)
|
2016-08-22 23:54:20 +00:00
|
|
|
typedef Sys_Load_File_Sig(System_Load_File);
|
|
|
|
|
2016-08-26 17:52:35 +00:00
|
|
|
#define Sys_Load_Close_Sig(name) b32 name(Plat_Handle handle)
|
|
|
|
typedef Sys_Load_Close_Sig(System_Load_Close);
|
|
|
|
|
2019-02-13 23:15:22 +00:00
|
|
|
#define Sys_Save_File_Sig(name) File_Attributes name(char *filename, char *buffer, u32 size)
|
2016-08-22 23:54:20 +00:00
|
|
|
typedef Sys_Save_File_Sig(System_Save_File);
|
2016-05-27 17:11:38 +00:00
|
|
|
|
2017-03-11 18:35:12 +00:00
|
|
|
// time
|
2016-08-26 17:52:35 +00:00
|
|
|
#define Sys_Now_Time_Sig(name) u64 name()
|
|
|
|
typedef Sys_Now_Time_Sig(System_Now_Time);
|
2016-08-24 23:01:33 +00:00
|
|
|
|
2019-02-04 01:33:44 +00:00
|
|
|
#define Sys_Wake_Up_Timer_Create_Sig(name) Plat_Handle name()
|
|
|
|
typedef Sys_Wake_Up_Timer_Create_Sig(System_Wake_Up_Timer_Create);
|
|
|
|
|
|
|
|
#define Sys_Wake_Up_Timer_Release_Sig(name) void name(Plat_Handle handle)
|
|
|
|
typedef Sys_Wake_Up_Timer_Release_Sig(System_Wake_Up_Timer_Release);
|
|
|
|
|
|
|
|
#define Sys_Wake_Up_Timer_Set_Sig(name) void name(Plat_Handle handle, u32 time_milliseconds)
|
|
|
|
typedef Sys_Wake_Up_Timer_Set_Sig(System_Wake_Up_Timer_Set);
|
|
|
|
|
|
|
|
#define Sys_Wake_Up_Timer_Check_Sig(name) u64 name(Plat_Handle handle)
|
|
|
|
typedef Sys_Wake_Up_Timer_Check_Sig(System_Wake_Up_Timer_Check);
|
|
|
|
|
2019-08-13 04:19:02 +00:00
|
|
|
#define Sys_Signal_Step_Sig(name) void name(u32 code)
|
|
|
|
typedef Sys_Signal_Step_Sig(System_Signal_Step);
|
|
|
|
|
|
|
|
#define Sys_Sleep_Sig(name) void name(u64 microseconds)
|
|
|
|
typedef Sys_Sleep_Sig(System_Sleep);
|
|
|
|
|
2017-03-11 18:35:12 +00:00
|
|
|
// clipboard
|
2019-06-01 23:58:28 +00:00
|
|
|
#define Sys_Post_Clipboard_Sig(name) void name(String_Const_u8 str)
|
2016-02-07 21:15:58 +00:00
|
|
|
typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard);
|
|
|
|
|
|
|
|
// cli
|
|
|
|
struct CLI_Handles{
|
|
|
|
Plat_Handle proc;
|
|
|
|
Plat_Handle out_read;
|
|
|
|
Plat_Handle out_write;
|
2017-11-28 19:11:44 +00:00
|
|
|
Plat_Handle in_read;
|
|
|
|
Plat_Handle in_write;
|
2016-02-07 21:15:58 +00:00
|
|
|
u32 scratch_space[4];
|
|
|
|
i32 exit;
|
|
|
|
};
|
|
|
|
|
2017-11-28 19:11:44 +00:00
|
|
|
#define Sys_CLI_Call_Sig(n, path, script, cli_out) b32 n(char *path, char *script, CLI_Handles *cli_out)
|
|
|
|
typedef Sys_CLI_Call_Sig(System_CLI_Call, path, script, cli_out);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
|
|
|
#define Sys_CLI_Begin_Update_Sig(name) void name(CLI_Handles *cli)
|
|
|
|
typedef Sys_CLI_Begin_Update_Sig(System_CLI_Begin_Update);
|
|
|
|
|
|
|
|
#define Sys_CLI_Update_Step_Sig(name) b32 name(CLI_Handles *cli, char *dest, u32 max, u32 *amount)
|
|
|
|
typedef Sys_CLI_Update_Step_Sig(System_CLI_Update_Step);
|
|
|
|
|
|
|
|
#define Sys_CLI_End_Update_Sig(name) b32 name(CLI_Handles *cli)
|
|
|
|
typedef Sys_CLI_End_Update_Sig(System_CLI_End_Update);
|
|
|
|
|
2019-02-24 07:22:16 +00:00
|
|
|
//
|
|
|
|
|
2019-06-18 04:47:00 +00:00
|
|
|
#define Sys_Open_Color_Picker_Sig(name) void name(Color_Picker *picker)
|
2019-02-24 07:22:16 +00:00
|
|
|
typedef Sys_Open_Color_Picker_Sig(System_Open_Color_Picker);
|
|
|
|
|
2016-02-07 21:15:58 +00:00
|
|
|
// thread
|
2019-08-04 05:36:13 +00:00
|
|
|
typedef Plat_Handle System_Thread;
|
|
|
|
typedef Plat_Handle System_Mutex;
|
|
|
|
typedef Plat_Handle System_Condition_Variable;
|
|
|
|
typedef void Thread_Function(void *ptr);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Thread_Launch_Sig(name) System_Thread name(Thread_Function *proc, void *ptr)
|
|
|
|
typedef Sys_Thread_Launch_Sig(System_Thread_Launch);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Thread_Join_Sig(name) void name(System_Thread thread)
|
|
|
|
typedef Sys_Thread_Join_Sig(System_Thread_Join);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Thread_Free_Sig(name) void name(System_Thread thread)
|
|
|
|
typedef Sys_Thread_Free_Sig(System_Thread_Free);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-16 02:54:06 +00:00
|
|
|
#define Sys_Thread_Get_ID_Sig(name) i32 name(void)
|
|
|
|
typedef Sys_Thread_Get_ID_Sig(System_Thread_Get_ID);
|
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Mutex_Make_Sig(name) System_Mutex name(void)
|
|
|
|
typedef Sys_Mutex_Make_Sig(System_Mutex_Make);
|
2019-01-29 05:36:17 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Mutex_Acquire_Sig(name) void name(System_Mutex mutex)
|
|
|
|
typedef Sys_Mutex_Acquire_Sig(System_Mutex_Acquire);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Mutex_Release_Sig(name) void name(System_Mutex mutex)
|
|
|
|
typedef Sys_Mutex_Release_Sig(System_Mutex_Release);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Mutex_Free_Sig(name) void name(System_Mutex mutex)
|
|
|
|
typedef Sys_Mutex_Free_Sig(System_Mutex_Free);
|
2016-07-19 23:47:27 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Condition_Variable_Make_Sig(name) System_Condition_Variable name(void)
|
|
|
|
typedef Sys_Condition_Variable_Make_Sig(System_Condition_Variable_Make);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Condition_Variable_Wait_Sig(name) void name(System_Condition_Variable cv, System_Mutex mutex)
|
|
|
|
typedef Sys_Condition_Variable_Wait_Sig(System_Condition_Variable_Wait);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Condition_Variable_Signal_Sig(name) void name(System_Condition_Variable cv)
|
|
|
|
typedef Sys_Condition_Variable_Signal_Sig(System_Condition_Variable_Signal);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
#define Sys_Condition_Variable_Free_Sig(name) void name(System_Condition_Variable cv)
|
|
|
|
typedef Sys_Condition_Variable_Free_Sig(System_Condition_Variable_Free);
|
2016-02-07 21:15:58 +00:00
|
|
|
|
2017-06-30 22:54:06 +00:00
|
|
|
// memory
|
2017-03-23 22:45:32 +00:00
|
|
|
#define Sys_Memory_Allocate_Sig(name) void* name(umem size)
|
2017-01-23 06:19:43 +00:00
|
|
|
typedef Sys_Memory_Allocate_Sig(System_Memory_Allocate);
|
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
#define Sys_Memory_Set_Protection_Sig(name) b32 name(void *ptr, umem size, u32 flags)
|
2017-01-23 06:19:43 +00:00
|
|
|
typedef Sys_Memory_Set_Protection_Sig(System_Memory_Set_Protection);
|
|
|
|
|
2017-03-23 22:45:32 +00:00
|
|
|
#define Sys_Memory_Free_Sig(name) void name(void *ptr, umem size)
|
2017-01-23 06:19:43 +00:00
|
|
|
typedef Sys_Memory_Free_Sig(System_Memory_Free);
|
|
|
|
|
2017-06-30 22:54:06 +00:00
|
|
|
// file system
|
2019-07-24 07:41:40 +00:00
|
|
|
#define Sys_Get_Current_Path_Sig(name) String_Const_u8 name(Arena *arena)
|
2017-07-19 16:33:12 +00:00
|
|
|
typedef Sys_Get_Current_Path_Sig(System_Get_Current_Path);
|
|
|
|
|
2019-07-24 07:41:40 +00:00
|
|
|
#define Sys_Get_4ed_Path_Sig(name) String_Const_u8 name(Arena *arena)
|
2017-01-23 06:19:43 +00:00
|
|
|
typedef Sys_Get_4ed_Path_Sig(System_Get_4ed_Path);
|
|
|
|
|
2017-06-30 22:54:06 +00:00
|
|
|
// behavior and appearance options
|
2017-01-23 06:19:43 +00:00
|
|
|
#define Sys_Show_Mouse_Cursor_Sig(name) void name(i32 show)
|
|
|
|
typedef Sys_Show_Mouse_Cursor_Sig(System_Show_Mouse_Cursor);
|
|
|
|
|
2017-07-18 22:09:16 +00:00
|
|
|
#define Sys_Set_Fullscreen_Sig(name) b32 name(b32 full_screen)
|
|
|
|
typedef Sys_Set_Fullscreen_Sig(System_Set_Fullscreen);
|
2017-01-23 06:19:43 +00:00
|
|
|
|
2019-02-26 23:08:42 +00:00
|
|
|
#define Sys_Is_Fullscreen_Sig(name) b32 name()
|
2017-01-23 06:19:43 +00:00
|
|
|
typedef Sys_Is_Fullscreen_Sig(System_Is_Fullscreen);
|
|
|
|
|
2016-02-07 21:15:58 +00:00
|
|
|
struct System_Functions{
|
2019-07-21 18:16:34 +00:00
|
|
|
Font_Make_Face_Function *font_make_face;
|
2019-07-24 07:41:40 +00:00
|
|
|
Graphics_Get_Texture_Function *get_texture;
|
|
|
|
Graphics_Fill_Texture_Function *fill_texture;
|
2017-03-12 01:20:24 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// files
|
2019-02-14 00:24:03 +00:00
|
|
|
System_Get_Canonical *get_canonical;
|
2019-08-04 00:49:40 +00:00
|
|
|
System_Get_File_List *get_file_list;
|
2019-02-14 00:24:03 +00:00
|
|
|
System_Quick_File_Attributes *quick_file_attributes;
|
|
|
|
System_Load_Handle *load_handle;
|
|
|
|
System_Load_Attributes *load_attributes;
|
|
|
|
System_Load_File *load_file;
|
|
|
|
System_Load_Close *load_close;
|
|
|
|
System_Save_File *save_file;
|
2016-08-26 17:52:35 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// time
|
2016-08-26 17:52:35 +00:00
|
|
|
System_Now_Time *now_time;
|
2019-02-04 01:33:44 +00:00
|
|
|
System_Wake_Up_Timer_Create *wake_up_timer_create;
|
|
|
|
System_Wake_Up_Timer_Release *wake_up_timer_release;
|
|
|
|
System_Wake_Up_Timer_Set *wake_up_timer_set;
|
2019-08-13 04:19:02 +00:00
|
|
|
System_Signal_Step *signal_step;
|
|
|
|
System_Sleep *sleep;
|
2016-05-29 03:12:12 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// clipboard
|
2016-02-07 21:15:58 +00:00
|
|
|
System_Post_Clipboard *post_clipboard;
|
2016-05-29 03:12:12 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// cli
|
2017-07-19 16:33:12 +00:00
|
|
|
System_CLI_Call *cli_call;
|
2016-02-07 21:15:58 +00:00
|
|
|
System_CLI_Begin_Update *cli_begin_update;
|
2017-07-19 16:33:12 +00:00
|
|
|
System_CLI_Update_Step *cli_update_step;
|
|
|
|
System_CLI_End_Update *cli_end_update;
|
2016-05-29 03:12:12 +00:00
|
|
|
|
2019-02-24 07:22:16 +00:00
|
|
|
// TODO(allen):
|
2019-08-04 05:36:13 +00:00
|
|
|
System_Open_Color_Picker *open_color_picker;
|
2019-02-24 07:22:16 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// threads
|
|
|
|
System_Thread_Launch *thread_launch;
|
|
|
|
System_Thread_Join *thread_join;
|
|
|
|
System_Thread_Free *thread_free;
|
2019-08-16 02:54:06 +00:00
|
|
|
System_Thread_Get_ID *thread_get_id;
|
2019-08-04 05:36:13 +00:00
|
|
|
System_Mutex_Make *mutex_make;
|
|
|
|
System_Mutex_Acquire *mutex_acquire;
|
|
|
|
System_Mutex_Release *mutex_release;
|
|
|
|
System_Mutex_Free *mutex_free;
|
|
|
|
System_Condition_Variable_Make *condition_variable_make;
|
|
|
|
System_Condition_Variable_Wait *condition_variable_wait;
|
|
|
|
System_Condition_Variable_Signal *condition_variable_signal;
|
|
|
|
System_Condition_Variable_Free *condition_variable_free;
|
2016-05-29 03:12:12 +00:00
|
|
|
|
2019-08-04 05:36:13 +00:00
|
|
|
// custom
|
2017-01-23 06:19:43 +00:00
|
|
|
System_Memory_Allocate *memory_allocate;
|
|
|
|
System_Memory_Set_Protection *memory_set_protection;
|
|
|
|
System_Memory_Free *memory_free;
|
2017-11-30 15:44:08 +00:00
|
|
|
|
2017-07-19 16:33:12 +00:00
|
|
|
System_Get_Current_Path *get_current_path;
|
2017-01-23 06:19:43 +00:00
|
|
|
System_Get_4ed_Path *get_4ed_path;
|
2017-11-30 15:44:08 +00:00
|
|
|
|
2017-01-23 06:19:43 +00:00
|
|
|
System_Show_Mouse_Cursor *show_mouse_cursor;
|
2017-07-18 22:09:16 +00:00
|
|
|
System_Set_Fullscreen *set_fullscreen;
|
2017-01-23 06:19:43 +00:00
|
|
|
System_Is_Fullscreen *is_fullscreen;
|
2016-02-07 21:15:58 +00:00
|
|
|
};
|
|
|
|
|
2017-03-12 01:20:24 +00:00
|
|
|
#endif
|
|
|
|
|
2016-02-07 21:15:58 +00:00
|
|
|
// BOTTOM
|
|
|
|
|