Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions hl.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
<AdditionalOptions>/wd4456 /wd4100 /wd4204 /wd4702 /wd4457 %(AdditionalOptions)</AdditionalOptions>
<BufferSecurityCheck>false</BufferSecurityCheck>
Expand All @@ -217,7 +217,7 @@
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
Expand Down Expand Up @@ -265,7 +265,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;HL_VTUNE;HL_DX12_AGILITY_VERSION=618;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;HL_VTUNE;HL_DX12_AGILITY_VERSION=618;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/wd4456 /wd4100 /wd4204 /wd4702 /wd4457 %(AdditionalOptions)</AdditionalOptions>
<BufferSecurityCheck>false</BufferSecurityCheck>
<ConformanceMode>true</ConformanceMode>
Expand All @@ -276,7 +276,7 @@
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
Expand Down
10 changes: 10 additions & 0 deletions libs/ui/ui_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ HL_PRIM bool HL_NAME(ui_sentinel_is_paused)( vsentinel *s ) {
return false;
}

HL_PRIM bool HL_NAME(ui_create_console)() {
return false;
}

HL_PRIM bool HL_NAME(ui_attach_console)( int pid ) {
return false;
}

HL_PRIM void HL_NAME(ui_close_console)() {
}

Expand Down Expand Up @@ -86,6 +94,8 @@ DEFINE_PRIM(_VOID, ui_win_set_enable, _WIN _BOOL);
DEFINE_PRIM(_VOID, ui_win_destroy, _WIN);
DEFINE_PRIM(_I32, ui_loop, _BOOL);
DEFINE_PRIM(_VOID, ui_stop_loop, _NO_ARG);
DEFINE_PRIM(_BOOL, ui_create_console, _NO_ARG);
DEFINE_PRIM(_BOOL, ui_attach_console, _I32);
DEFINE_PRIM(_VOID, ui_close_console, _NO_ARG);

DEFINE_PRIM(_SENTINEL, ui_start_sentinel, _F64 _FUN(_VOID,_NO_ARG));
Expand Down
24 changes: 23 additions & 1 deletion libs/ui/ui_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void sentinel_loop( vsentinel *s ) {
// simulate a call
# ifdef HL_64
int_val* rsp = (int_val*)regs.Rsp;
// ensure the stack is aligned to 16 bytes
// ensure the stack is aligned to 16 bytes
rsp = (int_val*)((int_val)rsp & ~15);
*--rsp = (int_val)regs.Rip;
regs.Rsp = (int_val)rsp;
Expand Down Expand Up @@ -278,6 +278,26 @@ HL_PRIM bool HL_NAME(ui_sentinel_is_paused)( vsentinel *s ) {
return s->pause;
}

static void reattach_std() {
freopen("CONIN$","r",stdin);
freopen("CONOUT$","w",stdout);
freopen("CONOUT$","w",stderr);
}

HL_PRIM bool HL_NAME(ui_create_console)() {
if( !AllocConsole() )
return false;
reattach_std();
return true;
}

HL_PRIM bool HL_NAME(ui_attach_console)( int pid ) {
if( !AttachConsole(pid) )
return false;
reattach_std();
return true;
}

HL_PRIM void HL_NAME(ui_close_console)() {
FreeConsole();
}
Expand Down Expand Up @@ -390,6 +410,8 @@ DEFINE_PRIM(_VOID, ui_win_set_enable, _WIN _BOOL);
DEFINE_PRIM(_VOID, ui_win_destroy, _WIN);
DEFINE_PRIM(_I32, ui_loop, _BOOL);
DEFINE_PRIM(_VOID, ui_stop_loop, _NO_ARG);
DEFINE_PRIM(_BOOL, ui_create_console, _NO_ARG);
DEFINE_PRIM(_BOOL, ui_attach_console, _I32);
DEFINE_PRIM(_VOID, ui_close_console, _NO_ARG);

DEFINE_PRIM(_SENTINEL, ui_start_sentinel, _F64 _FUN(_VOID,_NO_ARG));
Expand Down
5 changes: 5 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,3 +325,8 @@ int main(int argc, pchar *argv[]) {
return 0;
}

#if (defined(HL_WIN_DESKTOP) && !defined(_CONSOLE)) || defined(HL_XBS)
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdShow) {
return wmain(__argc, __wargv);
}
#endif
Loading