system cleanup
parent
95104afd37
commit
5b41098824
|
@ -4,7 +4,7 @@
|
|||
#define MDFR_ALT 2
|
||||
#define MDFR_SHIFT 4
|
||||
|
||||
typedef unsigned short Code;
|
||||
typedef u16 Code;
|
||||
|
||||
struct Key_Codes{
|
||||
Code back;
|
||||
|
|
46
4ed.cpp
46
4ed.cpp
|
@ -2691,7 +2691,6 @@ external App_Step_Sig(app_step){
|
|||
for (i32 i = 0; i < input->press_count; ++i){
|
||||
key_data.keys[key_data.count++] = input->press[i];
|
||||
}
|
||||
|
||||
for (i32 i = 0; i < input->hold_count; ++i){
|
||||
key_data.keys[key_data.count++] = input->hold[i];
|
||||
}
|
||||
|
@ -2720,15 +2719,15 @@ external App_Step_Sig(app_step){
|
|||
// NOTE(allen): detect mouse hover status
|
||||
i32 mx = mouse_data.mx;
|
||||
i32 my = mouse_data.my;
|
||||
bool32 mouse_in_edit_area = 0;
|
||||
bool32 mouse_in_margin_area = 0;
|
||||
b32 mouse_in_edit_area = 0;
|
||||
b32 mouse_in_margin_area = 0;
|
||||
Panel *mouse_panel = 0;
|
||||
i32 mouse_panel_i = 0;
|
||||
|
||||
{
|
||||
Panel *panel = 0;
|
||||
bool32 in_edit_area = 0;
|
||||
bool32 in_margin_area = 0;
|
||||
b32 in_edit_area = 0;
|
||||
b32 in_margin_area = 0;
|
||||
i32 panel_count = vars->layout.panel_count;
|
||||
i32 panel_i;
|
||||
|
||||
|
@ -2752,15 +2751,15 @@ external App_Step_Sig(app_step){
|
|||
}
|
||||
}
|
||||
|
||||
bool32 mouse_on_divider = 0;
|
||||
bool32 mouse_divider_vertical = 0;
|
||||
b32 mouse_on_divider = 0;
|
||||
b32 mouse_divider_vertical = 0;
|
||||
i32 mouse_divider_id = 0;
|
||||
i32 mouse_divider_side = 0;
|
||||
|
||||
if (mouse_in_margin_area){
|
||||
bool32 resize_area = 0;
|
||||
b32 resize_area = 0;
|
||||
i32 divider_id = 0;
|
||||
bool32 seeking_v_divider = 0;
|
||||
b32 seeking_v_divider = 0;
|
||||
i32 seeking_child_on_side = 0;
|
||||
Panel *panel = mouse_panel;
|
||||
if (mx >= panel->inner.x0 && mx < panel->inner.x1){
|
||||
|
@ -2840,7 +2839,7 @@ external App_Step_Sig(app_step){
|
|||
i32 divider_id = div.id;
|
||||
do{
|
||||
Divider_And_ID other_div = layout_get_divider(&vars->layout, divider_id);
|
||||
bool32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
|
||||
b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
|
||||
i32 pos = other_div.divider->pos;
|
||||
if (divider_match && pos > mid && pos < max){
|
||||
max = pos;
|
||||
|
@ -2858,7 +2857,7 @@ external App_Step_Sig(app_step){
|
|||
|
||||
while (top > 0){
|
||||
Divider_And_ID other_div = layout_get_divider(&vars->layout, divider_stack[--top]);
|
||||
bool32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
|
||||
b32 divider_match = (other_div.divider->v_divider == mouse_divider_vertical);
|
||||
i32 pos = other_div.divider->pos;
|
||||
if (divider_match && pos > mid && pos < max){
|
||||
max = pos;
|
||||
|
@ -3025,12 +3024,12 @@ external App_Step_Sig(app_step){
|
|||
View *view_ = panel->view;
|
||||
if (view_){
|
||||
Assert(view_->do_view);
|
||||
bool32 active = (panel == active_panel);
|
||||
b32 active = (panel == active_panel);
|
||||
Input_Summary input = (active)?(active_input):(dead_input);
|
||||
if (panel == mouse_panel){
|
||||
input.mouse = mouse_data;
|
||||
}
|
||||
if (view_->do_view(system, thread, view_, panel->inner, active_view,
|
||||
if (view_->do_view(system, view_, panel->inner, active_view,
|
||||
VMSG_STEP, 0, &input, &active_input)){
|
||||
app_result.redraw = 1;
|
||||
}
|
||||
|
@ -3199,12 +3198,12 @@ external App_Step_Sig(app_step){
|
|||
View *view = panel->view;
|
||||
if (view){
|
||||
view->do_view(system,
|
||||
thread, view, inner, active_view,
|
||||
view, inner, active_view,
|
||||
VMSG_RESIZE, 0, &dead_input, &active_input);
|
||||
view = (view->is_minor)?view->major:0;
|
||||
if (view){
|
||||
view->do_view(system,
|
||||
thread, view, inner, active_view,
|
||||
view, inner, active_view,
|
||||
VMSG_RESIZE, 0, &dead_input, &active_input);
|
||||
}
|
||||
}
|
||||
|
@ -3232,12 +3231,12 @@ external App_Step_Sig(app_step){
|
|||
View *view = panel->view;
|
||||
if (view){
|
||||
view->do_view(system,
|
||||
thread, view, panel->inner, active_view,
|
||||
view, panel->inner, active_view,
|
||||
VMSG_STYLE_CHANGE, 0, &dead_input, &active_input);
|
||||
view = (view->is_minor)?view->major:0;
|
||||
if (view){
|
||||
view->do_view(system,
|
||||
thread, view, panel->inner, active_view,
|
||||
view, panel->inner, active_view,
|
||||
VMSG_STYLE_CHANGE, 0, &dead_input, &active_input);
|
||||
}
|
||||
}
|
||||
|
@ -3257,19 +3256,18 @@ external App_Step_Sig(app_step){
|
|||
i32_Rect full = panel->full;
|
||||
i32_Rect inner = panel->inner;
|
||||
|
||||
View *view_ = panel->view;
|
||||
View *view = panel->view;
|
||||
Style *style = &vars->style;
|
||||
|
||||
bool32 active = (panel == active_panel);
|
||||
b32 active = (panel == active_panel);
|
||||
u32 back_color = style->main.back_color;
|
||||
draw_rectangle(target, full, back_color);
|
||||
|
||||
if (view_){
|
||||
Assert(view_->do_view);
|
||||
if (view){
|
||||
Assert(view->do_view);
|
||||
draw_push_clip(target, panel->inner);
|
||||
view_->do_view(system,
|
||||
thread, view_, panel->inner, active_view,
|
||||
VMSG_DRAW, target, &dead_input, &active_input);
|
||||
view->do_view(system, view, panel->inner, active_view,
|
||||
VMSG_DRAW, target, &dead_input, &active_input);
|
||||
draw_pop_clip(target);
|
||||
}
|
||||
|
||||
|
|
34
4ed.h
34
4ed.h
|
@ -59,7 +59,7 @@ struct Key_Input_Data{
|
|||
Key_Event_Data hold[KEY_INPUT_BUFFER_SIZE];
|
||||
i32 press_count;
|
||||
i32 hold_count;
|
||||
|
||||
|
||||
b8 control_keys[CONTROL_KEY_COUNT];
|
||||
b8 caps_lock;
|
||||
};
|
||||
|
@ -85,20 +85,20 @@ get_single_key(Key_Summary *summary, i32 index){
|
|||
}
|
||||
|
||||
struct Mouse_State{
|
||||
bool32 out_of_window;
|
||||
bool32 left_button, right_button;
|
||||
bool32 left_button_prev, right_button_prev;
|
||||
b32 out_of_window;
|
||||
b32 left_button, right_button;
|
||||
b32 left_button_prev, right_button_prev;
|
||||
i32 x, y;
|
||||
i16 wheel;
|
||||
};
|
||||
|
||||
struct Mouse_Summary{
|
||||
i32 mx, my;
|
||||
bool32 l, r;
|
||||
bool32 press_l, press_r;
|
||||
bool32 release_l, release_r;
|
||||
bool32 out_of_window;
|
||||
bool32 wheel_used;
|
||||
b32 l, r;
|
||||
b32 press_l, press_r;
|
||||
b32 release_l, release_r;
|
||||
b32 out_of_window;
|
||||
b32 wheel_used;
|
||||
i16 wheel_amount;
|
||||
};
|
||||
|
||||
|
@ -118,8 +118,9 @@ struct Thread_Context;
|
|||
|
||||
#define App_Init_Sig(name) \
|
||||
b32 name(System_Functions *system, \
|
||||
Thread_Context *thread, Application_Memory *memory, \
|
||||
Key_Codes *loose_codes, Clipboard_Contents clipboard, \
|
||||
Application_Memory *memory, \
|
||||
Key_Codes *loose_codes, \
|
||||
Clipboard_Contents clipboard, \
|
||||
Config_API api)
|
||||
|
||||
typedef App_Init_Sig(App_Init);
|
||||
|
@ -136,17 +137,18 @@ enum Application_Mouse_Cursor{
|
|||
|
||||
struct Application_Step_Result{
|
||||
Application_Mouse_Cursor mouse_cursor_type;
|
||||
bool32 redraw;
|
||||
b32 redraw;
|
||||
};
|
||||
|
||||
#define App_Step_Sig(name) Application_Step_Result \
|
||||
name(System_Functions *system, \
|
||||
Thread_Context *thread, Key_Codes *codes, \
|
||||
Key_Input_Data *input, Mouse_State *mouse, \
|
||||
b32 time_step, Render_Target *target, \
|
||||
Key_Codes *codes, \
|
||||
Key_Input_Data *input, \
|
||||
Mouse_State *mouse, \
|
||||
Render_Target *target, \
|
||||
Application_Memory *memory, \
|
||||
Clipboard_Contents clipboard, \
|
||||
b32 first_step, b32 force_redraw)
|
||||
b32 time_step, b32 first_step, b32 force_redraw)
|
||||
|
||||
typedef App_Step_Sig(App_Step);
|
||||
|
||||
|
|
|
@ -70,8 +70,15 @@
|
|||
#include "4ed.h"
|
||||
#include "4ed_rendering.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
# include <GL/gl.h>
|
||||
#elif defined(__linux__)
|
||||
# include <SDL/SDL.h>
|
||||
# include <GL/gl.h>
|
||||
#else
|
||||
# error UNSUPPORTED PLATFORM
|
||||
#endif
|
||||
|
||||
#include "4ed_internal.h"
|
||||
|
||||
|
|
|
@ -1748,7 +1748,7 @@ step_draw_library(System_Functions *system,
|
|||
}
|
||||
|
||||
internal
|
||||
DO_VIEW_SIG(do_color_view){
|
||||
Do_View_Sig(do_color_view){
|
||||
view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
|
||||
Color_View *color_view = (Color_View*)view;
|
||||
i32 result = 0;
|
||||
|
|
|
@ -33,7 +33,7 @@ map_hash(u16 event_code, u8 modifiers){
|
|||
return result;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
map_add(Command_Map *map, u16 event_code, u8 modifiers, Command_Function function, Custom_Command_Function *custom = 0){
|
||||
Assert(map->count * 8 < map->max * 7);
|
||||
Command_Binding bind;
|
||||
|
@ -55,7 +55,7 @@ map_add(Command_Map *map, u16 event_code, u8 modifiers, Command_Function functio
|
|||
return 0;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
map_find_entry(Command_Map *map, u16 event_code, u8 modifiers, i32 *index_out){
|
||||
i64 hash = map_hash(event_code, modifiers);
|
||||
i32 max = map->max;
|
||||
|
@ -71,9 +71,9 @@ map_find_entry(Command_Map *map, u16 event_code, u8 modifiers, i32 *index_out){
|
|||
return 0;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
map_find(Command_Map *map, u16 event_code, u8 modifiers, Command_Binding *bind_out){
|
||||
bool32 result;
|
||||
b32 result;
|
||||
i32 index;
|
||||
result = map_find_entry(map, event_code, modifiers, &index);
|
||||
if (result){
|
||||
|
@ -82,9 +82,9 @@ map_find(Command_Map *map, u16 event_code, u8 modifiers, Command_Binding *bind_o
|
|||
return result;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
map_drop(Command_Map *map, u16 event_code, u8 modifiers){
|
||||
bool32 result;
|
||||
b32 result;
|
||||
i32 index;
|
||||
result = map_find_entry(map, event_code, modifiers, &index);
|
||||
if (result){
|
||||
|
|
|
@ -349,7 +349,7 @@ step_debug_view(Debug_View *view, i32_Rect rect, Render_Target *target,
|
|||
}
|
||||
|
||||
internal
|
||||
DO_VIEW_SIG(do_debug_view){
|
||||
Do_View_Sig(do_debug_view){
|
||||
view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
|
||||
Debug_View *debug_view = (Debug_View*)view;
|
||||
i32 result = 0;
|
||||
|
|
|
@ -3720,7 +3720,7 @@ do_undo_slider(Widget_ID wid, UI_State *state, UI_Layout *layout, i32 max, i32 v
|
|||
}
|
||||
|
||||
internal i32
|
||||
step_file_view(System_Functions *system, Thread_Context *thread, View *view_, i32_Rect rect,
|
||||
step_file_view(System_Functions *system, View *view_, i32_Rect rect,
|
||||
bool32 is_active, Input_Summary *user_input){
|
||||
view_->mouse_cursor_type = APP_MOUSE_CURSOR_IBEAM;
|
||||
i32 result = 0;
|
||||
|
@ -3944,7 +3944,7 @@ buffer_get_sync(Editing_File *file){
|
|||
}
|
||||
|
||||
internal i32
|
||||
draw_file_view(Thread_Context *thread, View *view_, i32_Rect rect, bool32 is_active,
|
||||
draw_file_view(View *view_, i32_Rect rect, bool32 is_active,
|
||||
Render_Target *target){
|
||||
File_View *view = (File_View*)view_;
|
||||
Editing_File *file = view->file;
|
||||
|
@ -4363,7 +4363,7 @@ free_file_view(View *view){
|
|||
}
|
||||
|
||||
internal
|
||||
DO_VIEW_SIG(do_file_view){
|
||||
Do_View_Sig(do_file_view){
|
||||
i32 result = 0;
|
||||
switch (message){
|
||||
case VMSG_RESIZE:
|
||||
|
@ -4373,11 +4373,11 @@ DO_VIEW_SIG(do_file_view){
|
|||
}break;
|
||||
case VMSG_DRAW:
|
||||
{
|
||||
result = draw_file_view(thread, view, rect, (view == active), target);
|
||||
result = draw_file_view(view, rect, (view == active), target);
|
||||
}break;
|
||||
case VMSG_STEP:
|
||||
{
|
||||
result = step_file_view(system, thread, view, rect, (view == active), user_input);
|
||||
result = step_file_view(system, view, rect, (view == active), user_input);
|
||||
}break;
|
||||
case VMSG_FREE:
|
||||
{
|
||||
|
|
|
@ -187,7 +187,7 @@ step_draw_int_view(System_Functions *system,
|
|||
return result;
|
||||
}
|
||||
|
||||
DO_VIEW_SIG(do_interactive_view){
|
||||
Do_View_Sig(do_interactive_view){
|
||||
i32 result = 0;
|
||||
|
||||
view->mouse_cursor_type = APP_MOUSE_CURSOR_ARROW;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* 12.17.2014
|
||||
*
|
||||
* Win32-US Keyboard layer for project codename "4ed"
|
||||
* Win32-US Keyboard layer for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -13,10 +13,10 @@ globalvar u16 keycode_lookup_table[255];
|
|||
globalvar u16 loose_keycode_lookup_table[255];
|
||||
|
||||
internal void
|
||||
keycode_init(Key_Codes *codes, Key_Codes *loose_codes){
|
||||
keycode_init(Key_Codes *codes){
|
||||
// NOTE(allen): Assign values to the global keycodes.
|
||||
// Skip over the ascii characters that are used as codes.
|
||||
u16 code = 1;
|
||||
u16 code = 1, loose;
|
||||
u16 *codes_array = (u16*)codes;
|
||||
for (i32 i = 0; i < sizeof(Key_Codes)/2;){
|
||||
switch (code){
|
||||
|
@ -28,13 +28,7 @@ keycode_init(Key_Codes *codes, Key_Codes *loose_codes){
|
|||
codes_array[i++] = code++;
|
||||
}
|
||||
}
|
||||
|
||||
code = 1;
|
||||
codes_array = (u16*)loose_codes;
|
||||
for (i32 i = 0; i < sizeof(Key_Codes)/2; ++i){
|
||||
codes_array[i] = code++;
|
||||
}
|
||||
|
||||
|
||||
// NOTE(allen): lookup table for conversion from
|
||||
// win32 vk values to fred_keycode values.
|
||||
for (u8 i = 0; i < 255; ++i){
|
||||
|
@ -44,8 +38,7 @@ keycode_init(Key_Codes *codes, Key_Codes *loose_codes){
|
|||
loose_keycode_lookup_table[i] = 0;
|
||||
}
|
||||
else{
|
||||
|
||||
u16 code, loose = 0;
|
||||
loose = 0;
|
||||
switch (i){
|
||||
case VK_SPACE: code = loose = ' '; break;
|
||||
case VK_BACK: code = loose = codes->back; break;
|
||||
|
@ -106,7 +99,7 @@ loose_keycode_lookup(u8 virtual_keycode){
|
|||
return loose_keycode_lookup_table[virtual_keycode];
|
||||
}
|
||||
|
||||
inline bool32
|
||||
inline b32
|
||||
keycode_has_ascii(u16 keycode){
|
||||
return (keycode >= 0x20 && keycode < 0x7F) || keycode == '\n' || keycode == '\t';
|
||||
}
|
||||
|
@ -161,3 +154,4 @@ keycode_to_character_ascii(Key_Codes *codes,
|
|||
}
|
||||
|
||||
// BOTTOM
|
||||
|
||||
|
|
|
@ -38,13 +38,13 @@ enum View_Message{
|
|||
};
|
||||
|
||||
struct View;
|
||||
#define DO_VIEW_SIG(name) \
|
||||
i32 (name)(System_Functions *system, Thread_Context *thread, \
|
||||
#define Do_View_Sig(name) \
|
||||
i32 (name)(System_Functions *system, \
|
||||
View *view, i32_Rect rect, View *active, \
|
||||
View_Message message, Render_Target *target, \
|
||||
Input_Summary *user_input, Input_Summary *active_input)
|
||||
|
||||
typedef DO_VIEW_SIG(Do_View_Function);
|
||||
typedef Do_View_Sig(Do_View_Function);
|
||||
|
||||
#define HANDLE_COMMAND_SIG(name) \
|
||||
void (name)(System_Functions *system, View *view, \
|
||||
|
@ -193,7 +193,7 @@ live_set_alloc_view(Live_Views *live_set, Mem_Options *mem){
|
|||
inline void
|
||||
live_set_free_view(System_Functions *system, Live_Views *live_set, View *view){
|
||||
Assert(live_set->count > 0);
|
||||
view->do_view(system, 0, view, {}, 0, VMSG_FREE, 0, {}, 0);
|
||||
view->do_view(system, view, {}, 0, VMSG_FREE, 0, {}, 0);
|
||||
view->next_free = live_set->free_view;
|
||||
live_set->free_view = view;
|
||||
--live_set->count;
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 14.11.2015
|
||||
*
|
||||
* Linux-US Keyboard layer for 4coder
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
internal Key_Event_Data
|
||||
get_key_event(SDL_Event *event){
|
||||
Key_Event_Data result = {};
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -23,16 +23,15 @@
|
|||
|
||||
inline real32
|
||||
ABS(real32 x){
|
||||
#if C_MATH
|
||||
return abs(x);
|
||||
#endif
|
||||
if (x < 0) x = -x;
|
||||
return x;
|
||||
}
|
||||
|
||||
inline real32
|
||||
MOD(real32 x, i32 m){
|
||||
#if C_MATH
|
||||
real32 whole, frac;
|
||||
frac = modf(x, &whole);
|
||||
frac = modff(x, &whole);
|
||||
return ((i32)(whole) % m) + frac;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ step_draw_menu_view(Menu_View *view, Render_Target *target, i32_Rect rect,
|
|||
return result;
|
||||
}
|
||||
|
||||
DO_VIEW_SIG(do_menu_view){
|
||||
Do_View_Sig(do_menu_view){
|
||||
i32 result = 0;
|
||||
|
||||
Menu_View *menu_view = (Menu_View*)view;
|
||||
|
|
|
@ -474,12 +474,14 @@ style_format_for_use(Font_Set *fonts, Style *out, Style_File_Format_v3 *style){
|
|||
style_format_for_use(fonts, out, &form);
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
style_library_import(System_Functions *system,
|
||||
char *filename, Font_Set *fonts, Style *out, i32 max,
|
||||
i32 *count_opt, i32 *total_opt = 0){
|
||||
bool32 result = 1;
|
||||
b32 result = 1;
|
||||
File_Data file = system->load_file(filename);
|
||||
Style_Page_Header *h = 0;
|
||||
|
||||
if (!file.data){
|
||||
result = 0;
|
||||
}
|
||||
|
@ -496,7 +498,7 @@ style_library_import(System_Functions *system,
|
|||
cursor = h+1;
|
||||
}
|
||||
|
||||
Style_Page_Header *h = (Style_Page_Header*)cursor;
|
||||
h = (Style_Page_Header*)cursor;
|
||||
to_read = h->count;
|
||||
cursor = h+1;
|
||||
|
||||
|
@ -545,9 +547,9 @@ early_exit:
|
|||
return result;
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
style_library_add(Style_Library *library, Style *style){
|
||||
bool32 result = 0;
|
||||
b32 result = 0;
|
||||
i32 count = library->count;
|
||||
String my_name = style->name;
|
||||
Style *ostyle = library->styles;
|
||||
|
|
13
4ed_system.h
13
4ed_system.h
|
@ -16,8 +16,8 @@ struct Plat_Handle{
|
|||
};
|
||||
|
||||
struct File_Data{
|
||||
void *data;
|
||||
u32 size;
|
||||
void *data;
|
||||
u32 size;
|
||||
};
|
||||
|
||||
struct Time_Stamp{
|
||||
|
@ -31,14 +31,19 @@ typedef Sys_Load_File_Sig(System_Load_File);
|
|||
#define Sys_Save_File_Sig(name) i32 name(char *filename, void *data, i32 size)
|
||||
typedef Sys_Save_File_Sig(System_Save_File);
|
||||
|
||||
#define Sys_File_Size_Sig(name) i32 name(char *filename)
|
||||
typedef Sys_File_Size_Sig(System_File_Size);
|
||||
|
||||
#define Sys_File_Time_Stamp_Sig(name) Time_Stamp name(char *filename)
|
||||
typedef Sys_File_Time_Stamp_Sig(System_File_Time_Stamp);
|
||||
|
||||
#define Sys_Time_Stamp_Now_Sig(name) u64 name()
|
||||
typedef Sys_Time_Stamp_Now_Sig(System_Time_Stamp_Now);
|
||||
|
||||
#if 0
|
||||
#define Sys_Free_File_Sig(name) void name(File_Data file)
|
||||
typedef Sys_Free_File_Sig(System_Free_File);
|
||||
#endif
|
||||
|
||||
#define Sys_Get_Current_Directory_Sig(name) i32 name(char *out, i32 max)
|
||||
typedef Sys_Get_Current_Directory_Sig(System_Get_Current_Directory);
|
||||
|
@ -68,10 +73,10 @@ typedef Sys_Get_Memory_Sig(System_Get_Memory);
|
|||
|
||||
#define get_memory(size) get_memory_full(size, __LINE__, __FILE__)
|
||||
|
||||
#define Sys_Free_Memory_Sig(name) void name(void *block);
|
||||
#define Sys_Free_Memory_Sig(name) void name(void *block)
|
||||
typedef Sys_Free_Memory_Sig(System_Free_Memory);
|
||||
|
||||
#define Sys_Post_Clipboard_Sig(name) void name(String str);
|
||||
#define Sys_Post_Clipboard_Sig(name) void name(String str)
|
||||
typedef Sys_Post_Clipboard_Sig(System_Post_Clipboard);
|
||||
|
||||
#define Sys_Time_Sig(name) i64 name()
|
||||
|
|
|
@ -0,0 +1,404 @@
|
|||
/*
|
||||
* Mr. 4th Dimention - Allen Webster
|
||||
*
|
||||
* 14.11.2015
|
||||
*
|
||||
* Linux layer for project codename "4ed"
|
||||
*
|
||||
*/
|
||||
|
||||
// TOP
|
||||
|
||||
#ifdef FRED_NOT_PACKAGE
|
||||
|
||||
#define FRED_INTERNAL 1
|
||||
#define FRED_SLOW 1
|
||||
|
||||
#define FRED_PRINT_DEBUG 1
|
||||
#define FRED_PRINT_DEBUG_FILE_LINE 0
|
||||
#define FRED_PROFILING 1
|
||||
#define FRED_PROFILING_OS 0
|
||||
#define FRED_FULL_ERRORS 0
|
||||
|
||||
#else
|
||||
|
||||
#define FRED_SLOW 0
|
||||
#define FRED_INTERNAL 0
|
||||
|
||||
#define FRED_PRINT_DEBUG 0
|
||||
#define FRED_PRINT_DEBUG_FILE_LINE 0
|
||||
#define FRED_PROFILING 0
|
||||
#define FRED_PROFILING_OS 0
|
||||
#define FRED_FULL_ERRORS 0
|
||||
|
||||
#endif
|
||||
|
||||
#define SOFTWARE_RENDER 0
|
||||
|
||||
#if FRED_INTERNAL == 0
|
||||
# undef FRED_PRINT_DEBUG
|
||||
# define FRED_PRINT_DEBUG 0
|
||||
# undef FRED_PROFILING
|
||||
# define FRED_PROFILING 0
|
||||
# undef FRED_PROFILING_OS
|
||||
# define FRED_PROFILING_OS 0
|
||||
#endif
|
||||
|
||||
#if FRED_PRINT_DEBUG == 0
|
||||
# undef FRED_PRINT_DEBUG_FILE_LINE
|
||||
# define FRED_PRINT_DEBUG_FILE_LINE 0
|
||||
# undef FRED_PRINT_DEBUG_FILE_LINE
|
||||
# define FRED_PROFILING_OS 0
|
||||
#endif
|
||||
|
||||
#define FPS 30
|
||||
#define frame_useconds (1000000 / FPS)
|
||||
|
||||
#include "4ed_meta.h"
|
||||
|
||||
#define FCPP_FORBID_MALLOC
|
||||
|
||||
#include "4cpp_types.h"
|
||||
#define FCPP_STRING_IMPLEMENTATION
|
||||
#include "4cpp_string.h"
|
||||
|
||||
#include "4ed_mem.cpp"
|
||||
|
||||
#include "4ed_math.cpp"
|
||||
#include "4coder_custom.h"
|
||||
#include "4ed_system.h"
|
||||
#include "4ed.h"
|
||||
#include "4ed_rendering.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <SDL/SDL.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "4ed_internal.h"
|
||||
#include "4ed_linux_keyboard.cpp"
|
||||
|
||||
#define printe(m) printf("%s:%d: %s\n", __FILE__, __LINE__, #m)
|
||||
|
||||
struct Linux_Vars{
|
||||
Application_Memory mem;
|
||||
Key_Input_Data input;
|
||||
b32 keep_going;
|
||||
|
||||
Clipboard_Contents clipboard;
|
||||
|
||||
void *app_code, *custom;
|
||||
|
||||
System_Functions *system;
|
||||
App_Functions app;
|
||||
Config_API config_api;
|
||||
};
|
||||
|
||||
Linux_Vars linuxvars;
|
||||
|
||||
internal
|
||||
Sys_Get_Memory_Sig(system_get_memory_){
|
||||
void *ptr = 0;
|
||||
i32 prot = PROT_READ | PROT_WRITE;
|
||||
i32 flags = MAP_PRIVATE | MAP_ANON;
|
||||
|
||||
#if FRED_INTERNAL
|
||||
ptr = mmap(0, size + sizeof(Sys_Bubble), prot, flags, -1, 0);
|
||||
|
||||
Sys_Bubble *bubble = (Sys_Bubble*)ptr;
|
||||
bubble->flags = MEM_BUBBLE_SYS_DEBUG;
|
||||
bubble->line_number = line_number;
|
||||
bubble->file_name = file_name;
|
||||
bubble->size = size;
|
||||
//WaitForSingleObject(win32vars.DEBUG_sysmem_lock, INFINITE);
|
||||
insert_bubble(&win32vars.internal_bubble, bubble);
|
||||
//ReleaseSemaphore(win32vars.DEBUG_sysmem_lock, 1, 0);
|
||||
ptr = bubble + 1;
|
||||
#else
|
||||
ptr = mmap(0, size + sizeof(i32), prot, flags, -1, 0);
|
||||
|
||||
i32 *size_ptr = (i32*)ptr;
|
||||
*size_ptr = size;
|
||||
ptr = size_ptr + 1;
|
||||
#endif
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#define system_get_memory(size) system_get_memory_(size, __LINE__, __FILE__)
|
||||
|
||||
internal
|
||||
Sys_Free_Memory_Sig(system_free_memory){
|
||||
if (block){
|
||||
#if FRED_INTERNAL
|
||||
Sys_Bubble *bubble = ((Sys_Bubble*)block) - 1;
|
||||
Assert((bubble->flags & MEM_BUBBLE_DEBUG_MASK) == MEM_BUBBLE_SYS_DEBUG);
|
||||
//WaitForSingleObject(win32vars.DEBUG_sysmem_lock, INFINITE);
|
||||
remove_bubble(bubble);
|
||||
//ReleaseSemaphore(win32vars.DEBUG_sysmem_lock, 1, 0);
|
||||
munmap(bubble, bubble->size);
|
||||
#else
|
||||
i32 *size_ptr = (i32*)block - 1;
|
||||
munmap(size_ptr, *size_ptr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Time_Sig(system_time){
|
||||
i64 result = 0;
|
||||
struct timespec tp;
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0){
|
||||
result = tp.tv_sec*1000000 + tp.tv_nsec/1000;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Load_File_Sig(system_load_file){
|
||||
File_Data result = {};
|
||||
i32 prot = PROT_READ;
|
||||
i32 flags = MAP_PRIVATE | MAP_ANON;
|
||||
|
||||
struct stat sb;
|
||||
if (stat(filename, &sb) == 0){
|
||||
result.size = sb.st_size;
|
||||
result.data = system_get_memory(result.size);
|
||||
if (result.data){
|
||||
i32 file = open(filename, O_RDONLY);
|
||||
i32 result_size = read(file, result.data, result.size);
|
||||
Assert(result_size == result.size);
|
||||
close(file);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Save_File_Sig(system_save_file){
|
||||
i32 file = open(filename, O_CREAT | O_WRONLY);
|
||||
if (!file) return 0;
|
||||
|
||||
i32 result_size = write(file, data, size);
|
||||
Assert(result_size == size);
|
||||
|
||||
close(file);
|
||||
return 1;
|
||||
}
|
||||
|
||||
internal b32
|
||||
LinuxLoadAppCode(){
|
||||
b32 result = 0;
|
||||
|
||||
char app_code_file[] = "4ed_app.so";
|
||||
i32 app_code_file_len = sizeof(app_code_file) - 1;
|
||||
|
||||
char path[1024];
|
||||
i32 size = readlink("/proc/self/exe", path,
|
||||
1024 - app_code_file_len - 1);
|
||||
|
||||
for (--size;
|
||||
path[size] != '/' && size > 0;
|
||||
--size);
|
||||
memcpy(path + size + 1, app_code_file, app_code_file_len + 1);
|
||||
|
||||
linuxvars.app_code = SDL_LoadObject(path);
|
||||
if (linuxvars.app_code){
|
||||
result = 1;
|
||||
linuxvars.app.init = (App_Init*)
|
||||
SDL_LoadFunction(linuxvars.app_code, "app_init");
|
||||
linuxvars.app.step = (App_Step*)
|
||||
SDL_LoadFunction(linuxvars.app_code, "app_step");
|
||||
}
|
||||
else{
|
||||
// TODO(allen): initialization failure
|
||||
printe(app_code);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Acquire_Lock_Sig(system_acquire_lock){
|
||||
AllowLocal(id);
|
||||
}
|
||||
|
||||
internal
|
||||
Sys_Release_Lock_Sig(system_release_lock){
|
||||
AllowLocal(id);
|
||||
}
|
||||
|
||||
internal void
|
||||
LinuxLoadSystemCode(){
|
||||
linuxvars.system->get_memory_full = system_get_memory_;
|
||||
linuxvars.system->free_memory = system_free_memory;
|
||||
|
||||
linuxvars.system->load_file = system_load_file;
|
||||
linuxvars.system->save_file = system_save_file;
|
||||
|
||||
#if 0
|
||||
linuxvars.system->file_time_stamp = system_file_time_stamp;
|
||||
linuxvars.system->time_stamp_now = system_time_stamp_now;
|
||||
linuxvars.system->free_file = system_free_file;
|
||||
|
||||
linuxvars.system->get_current_directory = system_get_current_directory;
|
||||
linuxvars.system->get_easy_directory = system_get_easy_directory;
|
||||
|
||||
linuxvars.system->get_file_list = system_get_file_list;
|
||||
linuxvars.system->free_file_list = system_free_file_list;
|
||||
|
||||
linuxvars.system->post_clipboard = system_post_clipboard;
|
||||
linuxvars.system->time = system_time;
|
||||
|
||||
linuxvars.system->cli_call = system_cli_call;
|
||||
linuxvars.system->cli_begin_update = system_cli_begin_update;
|
||||
linuxvars.system->cli_update_step = system_cli_update_step;
|
||||
linuxvars.system->cli_end_update = system_cli_end_update;
|
||||
|
||||
linuxvars.system->thread_get_id = system_thread_get_id;
|
||||
linuxvars.system->thread_current_job_id = system_thread_current_job_id;
|
||||
linuxvars.system->post_job = system_post_job;
|
||||
linuxvars.system->cancel_job = system_cancel_job;
|
||||
linuxvars.system->job_is_pending = system_job_is_pending;
|
||||
linuxvars.system->grow_thread_memory = system_grow_thread_memory;
|
||||
linuxvars.system->acquire_lock = system_acquire_lock;
|
||||
linuxvars.system->release_lock = system_release_lock;
|
||||
|
||||
linuxvars.system->force_redraw = system_force_redraw;
|
||||
|
||||
linuxvars.system->internal_sentinel = INTERNAL_system_sentinel;
|
||||
linuxvars.system->internal_get_thread_states = INTERNAL_get_thread_states;
|
||||
#endif
|
||||
}
|
||||
|
||||
int main(){
|
||||
linuxvars = {};
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO)){
|
||||
// TODO(allen): initialization failure
|
||||
printe(SDL_Init);
|
||||
return(1);
|
||||
}
|
||||
SDL_EnableUNICODE(1);
|
||||
|
||||
if (!LinuxLoadAppCode()){
|
||||
return(1);
|
||||
}
|
||||
|
||||
System_Functions system_;
|
||||
System_Functions *system = &system_;
|
||||
linuxvars.system = system;
|
||||
LinuxLoadSystemCode();
|
||||
|
||||
const SDL_VideoInfo *info = SDL_GetVideoInfo();
|
||||
if (!info){
|
||||
// TODO(allen): initialization failure
|
||||
printe(info);
|
||||
return(1);
|
||||
}
|
||||
|
||||
{
|
||||
void *base;
|
||||
#if FRED_INTERNAL
|
||||
base = (void*)Mbytes(128);
|
||||
#else
|
||||
base = (void*)0;
|
||||
#endif
|
||||
|
||||
i32 prot = PROT_READ | PROT_WRITE;
|
||||
i32 flags = MAP_PRIVATE | MAP_ANON;
|
||||
|
||||
linuxvars.mem.vars_memory_size = Mbytes(2);
|
||||
linuxvars.mem.vars_memory = mmap(base, linuxvars.mem.vars_memory_size,
|
||||
prot, flags, -1, 0);
|
||||
|
||||
#if FRED_INTERNAL
|
||||
base = (void*)Mbytes(160);
|
||||
#else
|
||||
base = (void*)0;
|
||||
#endif
|
||||
|
||||
linuxvars.mem.target_memory_size = Mbytes(64);
|
||||
linuxvars.mem.target_memory = mmap(base, linuxvars.mem.target_memory_size,
|
||||
prot, flags, -1, 0);
|
||||
}
|
||||
|
||||
i32 width = 800;
|
||||
i32 height = 600;
|
||||
i32 bpp = info->vfmt->BitsPerPixel;
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
|
||||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 8);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
i32 flags = SDL_OPENGL;
|
||||
|
||||
if (SDL_SetVideoMode(width, height, bpp, flags) == 0){
|
||||
// TODO(allen): initialization failure
|
||||
printe(SDL_SetVideoMode);
|
||||
return(1);
|
||||
}
|
||||
|
||||
SDL_WM_SetCaption("4coder-window", 0);
|
||||
|
||||
system_acquire_lock(FRAME_LOCK);
|
||||
b32 first = 1;
|
||||
linuxvars.keep_going = 1;
|
||||
|
||||
SDL_Event event;
|
||||
for (;linuxvars.keep_going && SDL_WaitEvent(&event);){
|
||||
b32 pass_to_app = 0;
|
||||
|
||||
linuxvars.input = {};
|
||||
linuxvars.clipboard = {};
|
||||
switch (event.type){
|
||||
case SDL_ACTIVEEVENT:
|
||||
{
|
||||
if ((event.active.state & SDL_APPACTIVE) && event.active.gain)
|
||||
pass_to_app = 1;
|
||||
}break;
|
||||
|
||||
case SDL_KEYDOWN:
|
||||
{
|
||||
pass_to_app = 1;
|
||||
linuxvars.input.press[linuxvars.input.press_count++] =
|
||||
get_key_event(&event);
|
||||
}break;
|
||||
|
||||
case SDL_QUIT:
|
||||
{
|
||||
linuxvars.keep_going = 0;
|
||||
}break;
|
||||
|
||||
}
|
||||
|
||||
if (pass_to_app){
|
||||
Application_Step_Result app_result =
|
||||
linuxvars.app.step(linuxvars.system,
|
||||
0,
|
||||
0,
|
||||
&linuxvars.input,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
&linuxvars.mem,
|
||||
linuxvars.clipboard,
|
||||
first, 1);
|
||||
|
||||
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
// BOTTOM
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
#endif
|
||||
|
||||
#define FPS 30
|
||||
#define FRAME_TIME (1000000 / FPS)
|
||||
#define frame_useconds (1000000 / FPS)
|
||||
|
||||
#include "4ed_meta.h"
|
||||
|
||||
|
@ -70,28 +70,10 @@
|
|||
#include "4ed.h"
|
||||
#include "4ed_rendering.h"
|
||||
|
||||
Config_API config_api;
|
||||
|
||||
#include <windows.h>
|
||||
#include <GL/gl.h>
|
||||
|
||||
#include "4ed_internal.h"
|
||||
|
||||
#if 0
|
||||
#define FCPP_LEXER_IMPLEMENTATION
|
||||
#include "4cpp_lexer.h"
|
||||
#include "4ed_rendering.cpp"
|
||||
#include "4ed_command.cpp"
|
||||
#include "4ed_layout.cpp"
|
||||
#include "4ed_style.cpp"
|
||||
#include "4ed_file_view.cpp"
|
||||
#include "4ed_color_view.cpp"
|
||||
#include "4ed_interactive_view.cpp"
|
||||
#include "4ed_menu_view.cpp"
|
||||
#include "4ed_debug_view.cpp"
|
||||
#include "4ed.cpp"
|
||||
#endif
|
||||
|
||||
#include "4ed_keyboard.cpp"
|
||||
|
||||
struct Full_Job_Data{
|
||||
|
@ -128,7 +110,7 @@ struct Thread_Group{
|
|||
|
||||
struct Win32_Vars{
|
||||
HWND window_handle;
|
||||
Key_Codes key_codes, loose_codes;
|
||||
Key_Codes key_codes;
|
||||
Key_Input_Data input_data, previous_data;
|
||||
|
||||
#if SOFTWARE_RENDER
|
||||
|
@ -148,15 +130,15 @@ struct Win32_Vars{
|
|||
u32 volatile force_redraw;
|
||||
|
||||
Mouse_State mouse;
|
||||
bool32 focus;
|
||||
bool32 keep_playing;
|
||||
b32 focus;
|
||||
b32 keep_playing;
|
||||
HCURSOR cursor_ibeam;
|
||||
HCURSOR cursor_arrow;
|
||||
HCURSOR cursor_leftright;
|
||||
HCURSOR cursor_updown;
|
||||
Application_Mouse_Cursor prev_mouse_cursor;
|
||||
Clipboard_Contents clipboard_contents;
|
||||
bool32 next_clipboard_is_self;
|
||||
b32 next_clipboard_is_self;
|
||||
DWORD clipboard_sequence;
|
||||
|
||||
Thread_Context main_thread;
|
||||
|
@ -167,15 +149,16 @@ struct Win32_Vars{
|
|||
HANDLE DEBUG_sysmem_lock;
|
||||
Thread_Memory *thread_memory;
|
||||
|
||||
i64 performance_frequency;
|
||||
i64 start_pcount;
|
||||
|
||||
HMODULE custom;
|
||||
HMODULE app_code;
|
||||
|
||||
i64 performance_frequency;
|
||||
i64 start_pcount;
|
||||
|
||||
System_Functions *system;
|
||||
App_Functions app;
|
||||
|
||||
Config_API config_api;
|
||||
|
||||
#if FRED_INTERNAL
|
||||
Sys_Bubble internal_bubble;
|
||||
#endif
|
||||
|
@ -195,13 +178,13 @@ system_get_memory_(i32 size, i32 line_number, char *file_name){
|
|||
|
||||
#if FRED_INTERNAL
|
||||
ptr = VirtualAlloc(0, size + sizeof(Sys_Bubble), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
|
||||
|
||||
Sys_Bubble *bubble = (Sys_Bubble*)ptr;
|
||||
bubble->flags = MEM_BUBBLE_SYS_DEBUG;
|
||||
bubble->line_number = line_number;
|
||||
bubble->file_name = file_name;
|
||||
bubble->size = size;
|
||||
WaitForSingleObject(win32vars.DEBUG_sysmem_lock, INFINITE);
|
||||
|
||||
insert_bubble(&win32vars.internal_bubble, bubble);
|
||||
ReleaseSemaphore(win32vars.DEBUG_sysmem_lock, 1, 0);
|
||||
ptr = bubble + 1;
|
||||
|
@ -495,7 +478,7 @@ Win32Resize(i32 width, i32 height){
|
|||
}
|
||||
|
||||
internal void
|
||||
Win32KeyboardHandle(bool8 current_state, bool8 previous_state, WPARAM wParam){
|
||||
Win32KeyboardHandle(b8 current_state, b8 previous_state, WPARAM wParam){
|
||||
u16 key = keycode_lookup((u8)wParam);
|
||||
if (key != -1){
|
||||
if (current_state & !previous_state){
|
||||
|
@ -639,12 +622,15 @@ Win32Callback(HWND hwnd, UINT uMsg,
|
|||
|
||||
Clipboard_Contents empty_contents = {};
|
||||
win32vars.app.step(win32vars.system,
|
||||
&win32vars.main_thread, &win32vars.key_codes,
|
||||
&win32vars.previous_data, &win32vars.mouse,
|
||||
0, &win32vars.target, &win32memory, empty_contents, 0, 1);
|
||||
&win32vars.key_codes,
|
||||
&win32vars.previous_data,
|
||||
&win32vars.mouse,
|
||||
&win32vars.target,
|
||||
&win32memory,
|
||||
empty_contents,
|
||||
0, 0, 1);
|
||||
|
||||
Win32RedrawScreen(hdc);
|
||||
|
||||
EndPaint(hwnd, &ps);
|
||||
}break;
|
||||
|
||||
|
@ -719,9 +705,9 @@ ThreadProc(LPVOID lpParameter){
|
|||
}
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
Win32JobIsPending(Work_Queue *queue, u32 job_id){
|
||||
bool32 result;
|
||||
b32 result;
|
||||
u32 job_index;
|
||||
Full_Job_Data *full_job;
|
||||
|
||||
|
@ -754,7 +740,7 @@ system_post_job(Thread_Group_ID group_id, Job_Data job){
|
|||
|
||||
Assert((queue->write_position + 1) % QUEUE_WRAP != queue->read_position % QUEUE_WRAP);
|
||||
|
||||
bool32 success = 0;
|
||||
b32 success = 0;
|
||||
u32 result = 0;
|
||||
while (!success){
|
||||
u32 write_index = queue->write_position;
|
||||
|
@ -816,7 +802,7 @@ system_cancel_job(Thread_Group_ID group_id, u32 job_id){
|
|||
}
|
||||
}
|
||||
|
||||
internal bool32
|
||||
internal b32
|
||||
system_job_is_pending(Thread_Group_ID group_id, u32 job_id){
|
||||
Work_Queue *queue = win32vars.queues + group_id;;
|
||||
return Win32JobIsPending(queue, job_id);
|
||||
|
@ -1001,6 +987,9 @@ Win32LoadAppCode(){
|
|||
|
||||
internal void
|
||||
Win32LoadSystemCode(){
|
||||
win32vars.system->get_memory_full = system_get_memory_;
|
||||
win32vars.system->free_memory = system_free_memory;
|
||||
|
||||
win32vars.system->load_file = system_load_file;
|
||||
win32vars.system->save_file = system_save_file;
|
||||
win32vars.system->file_time_stamp = system_file_time_stamp;
|
||||
|
@ -1013,9 +1002,6 @@ Win32LoadSystemCode(){
|
|||
win32vars.system->get_file_list = system_get_file_list;
|
||||
win32vars.system->free_file_list = system_free_file_list;
|
||||
|
||||
win32vars.system->get_memory_full = system_get_memory_;
|
||||
win32vars.system->free_memory = system_free_memory;
|
||||
|
||||
win32vars.system->post_clipboard = system_post_clipboard;
|
||||
win32vars.system->time = system_time;
|
||||
|
||||
|
@ -1045,7 +1031,6 @@ WinMain(HINSTANCE hInstance,
|
|||
LPSTR lpCmdLine,
|
||||
int nCmdShow){
|
||||
win32vars = {};
|
||||
config_api = {};
|
||||
|
||||
if (!Win32LoadAppCode()){
|
||||
// TODO(allen): Failed to load app code, serious problem.
|
||||
|
@ -1069,15 +1054,15 @@ WinMain(HINSTANCE hInstance,
|
|||
win32vars.internal_bubble.flags = MEM_BUBBLE_SYS_DEBUG;
|
||||
#endif
|
||||
|
||||
keycode_init(&win32vars.key_codes, &win32vars.loose_codes);
|
||||
keycode_init(&win32vars.key_codes);
|
||||
|
||||
#ifdef FRED_SUPER
|
||||
win32vars.custom = LoadLibraryA("4coder_custom.dll");
|
||||
if (win32vars.custom){
|
||||
config_api.get_bindings = (Get_Binding_Data_Function*)
|
||||
win32vars.config_api.get_bindings = (Get_Binding_Data_Function*)
|
||||
GetProcAddress(win32vars.custom, "get_bindings");
|
||||
|
||||
config_api.set_extra_font = (Set_Extra_Font_Function*)
|
||||
win32vars.config_api.set_extra_font = (Set_Extra_Font_Function*)
|
||||
GetProcAddress(win32vars.custom, "set_extra_font");
|
||||
}
|
||||
#endif
|
||||
|
@ -1147,7 +1132,7 @@ WinMain(HINSTANCE hInstance,
|
|||
window_class.lpszClassName,
|
||||
WINDOW_NAME,
|
||||
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
|
||||
CW_USEDEFAULT/*x*/, CW_USEDEFAULT/*y*/,
|
||||
CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
window_rect.right - window_rect.left,
|
||||
window_rect.bottom - window_rect.top,
|
||||
0, 0, hInstance, 0);
|
||||
|
@ -1259,6 +1244,7 @@ WinMain(HINSTANCE hInstance,
|
|||
// TODO(allen): diagnostics
|
||||
}
|
||||
}
|
||||
|
||||
else{
|
||||
if (IsClipboardFormatAvailable(CF_TEXT)){
|
||||
if (OpenClipboard(win32vars.window_handle)){
|
||||
|
@ -1276,9 +1262,9 @@ WinMain(HINSTANCE hInstance,
|
|||
}
|
||||
}
|
||||
|
||||
if (!win32vars.app.init(win32vars.system, &win32vars.main_thread,
|
||||
if (!win32vars.app.init(win32vars.system,
|
||||
&win32memory, &win32vars.key_codes,
|
||||
win32vars.clipboard_contents, config_api)){
|
||||
win32vars.clipboard_contents, win32vars.config_api)){
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
@ -1288,7 +1274,7 @@ WinMain(HINSTANCE hInstance,
|
|||
system_acquire_lock(FRAME_LOCK);
|
||||
Thread_Context *thread = &win32vars.main_thread;
|
||||
AllowLocal(thread);
|
||||
bool32 first = 1;
|
||||
b32 first = 1;
|
||||
i64 timer_start = system_time();
|
||||
|
||||
while (win32vars.keep_playing){
|
||||
|
@ -1391,14 +1377,15 @@ WinMain(HINSTANCE hInstance,
|
|||
i32 redraw = InterlockedExchange(&win32vars.force_redraw, 0);
|
||||
ProfileEnd(OS_input);
|
||||
|
||||
Application_Step_Result result =
|
||||
win32vars.app.step(win32vars.system,
|
||||
&win32vars.main_thread, &win32vars.key_codes,
|
||||
&win32vars.input_data, &win32vars.mouse,
|
||||
1, &win32vars.target,
|
||||
Application_Step_Result result =
|
||||
win32vars.app.step(win32vars.system,
|
||||
&win32vars.key_codes,
|
||||
&win32vars.input_data,
|
||||
&win32vars.mouse,
|
||||
&win32vars.target,
|
||||
&win32memory,
|
||||
win32vars.clipboard_contents,
|
||||
first, redraw);
|
||||
1, first, redraw);
|
||||
|
||||
ProfileStart(OS_frame_out);
|
||||
first = 0;
|
||||
|
@ -1421,7 +1408,7 @@ WinMain(HINSTANCE hInstance,
|
|||
|
||||
ProfileStart(frame_sleep);
|
||||
i64 timer_end = system_time();
|
||||
i64 end_target = (timer_start + FRAME_TIME);
|
||||
i64 end_target = (timer_start + frame_useconds);
|
||||
|
||||
system_release_lock(FRAME_LOCK);
|
||||
while (timer_end < end_target){
|
||||
|
|
Loading…
Reference in New Issue