diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim index d7a5167..42794d8 100644 --- a/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim +++ b/app_run_tree/data/blumen_animations/ambient_patterns/ambient_1.foldanim @@ -4,7 +4,7 @@ layers_count: 3; blocks_count: 4; playable_range:{ min: 0; - max: 2000; + max: 10000; }; layers:{ layer:{ @@ -24,7 +24,7 @@ blocks:{ block:{ frame_range:{ min: 0; - max: 2000; + max: 19; }; layer_index: 0; animation_name: "Pattern_BulbMask"; @@ -32,7 +32,7 @@ blocks:{ block:{ frame_range:{ min: 0; - max: 2000; + max: 10000; }; layer_index: 1; animation_name: "Pattern_Leafy"; @@ -40,15 +40,15 @@ blocks:{ block:{ frame_range:{ min: 0; - max: 1032; + max: 5156; }; layer_index: 2; animation_name: "Pattern_Rainbow"; }; block:{ frame_range:{ - min: 959; - max: 2000; + min: 5040; + max: 10000; }; layer_index: 2; animation_name: "Pattern_Wavy"; diff --git a/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim b/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim index 2ed33bc..bc4979c 100644 --- a/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim +++ b/app_run_tree/data/blumen_animations/ambient_patterns/wavy_0.foldanim @@ -1,7 +1,7 @@ lumenarium_animation_file; animation_name: "wavy_0"; layers_count: 2; -blocks_count: 1; +blocks_count: 2; playable_range:{ min: 0; max: 7200; @@ -9,11 +9,11 @@ playable_range:{ layers:{ layer:{ name: "[New Layer]"; - blend: "Add"; + blend: "Overwrite"; }; layer:{ name: "Color"; - blend: "Add"; + blend: "Multiply"; }; }; blocks:{ @@ -25,4 +25,12 @@ blocks:{ layer_index: 1; animation_name: "Pattern_Wavy"; }; + block:{ + frame_range:{ + min: 78; + max: 3571; + }; + layer_index: 0; + animation_name: "Pattern_Leafy"; + }; }; diff --git a/app_run_tree/data/blumen_animations/anim_demo.foldanim b/app_run_tree/data/blumen_animations/anim_demo.foldanim deleted file mode 100644 index 6f424e1..0000000 --- a/app_run_tree/data/blumen_animations/anim_demo.foldanim +++ /dev/null @@ -1,132 +0,0 @@ -lumenarium_animation_file; -animation_name: "demo_anim"; -layers_count: 2; -blocks_count: 14; -playable_range:{ - min: 0; - max: 10000; -}; -layers:{ - layer:{ - name: "main"; - blend: "Add"; - }; - layer:{ - name: "color"; - blend: "Multiply"; - }; -}; -blocks:{ - block:{ - frame_range:{ - min: 2428; - max: 3017; - }; - layer_index: 0; - animation_name: "Pattern_HueShift"; - }; - block:{ - frame_range:{ - min: 1711; - max: 2487; - }; - layer_index: 0; - animation_name: "Pattern_Rainbow"; - }; - block:{ - frame_range:{ - min: 0; - max: 603; - }; - layer_index: 0; - animation_name: "Pattern_VerticalLines"; - }; - block:{ - frame_range:{ - min: 2945; - max: 3656; - }; - layer_index: 0; - animation_name: "Pattern_Wavy"; - }; - block:{ - frame_range:{ - min: 3592; - max: 4296; - }; - layer_index: 0; - animation_name: "Pattern_Patchy"; - }; - block:{ - frame_range:{ - min: 520; - max: 1225; - }; - layer_index: 0; - animation_name: "Pattern_Rotary"; - }; - block:{ - frame_range:{ - min: 4218; - max: 4939; - }; - layer_index: 0; - animation_name: "Pattern_LeafyPatchy"; - }; - block:{ - frame_range:{ - min: 4849; - max: 5431; - }; - layer_index: 0; - animation_name: "Pattern_HueShift"; - }; - block:{ - frame_range:{ - min: 1149; - max: 1819; - }; - layer_index: 0; - animation_name: "Pattern_Leafy"; - }; - block:{ - frame_range:{ - min: 5529; - max: 7782; - }; - layer_index: 1; - animation_name: "Pattern_Wavy"; - }; - block:{ - frame_range:{ - min: 5529; - max: 5979; - }; - layer_index: 0; - animation_name: "Pattern_Leafy"; - }; - block:{ - frame_range:{ - min: 5912; - max: 6328; - }; - layer_index: 0; - animation_name: "Pattern_VerticalLines"; - }; - block:{ - frame_range:{ - min: 6281; - max: 6581; - }; - layer_index: 0; - animation_name: "Pattern_Rotary"; - }; - block:{ - frame_range:{ - min: 6524; - max: 7025; - }; - layer_index: 0; - animation_name: "Pattern_HueShift"; - }; -}; diff --git a/src/app/patterns/blumen_patterns.h b/src/app/patterns/blumen_patterns.h index 65283c5..6530ccd 100644 --- a/src/app/patterns/blumen_patterns.h +++ b/src/app/patterns/blumen_patterns.h @@ -328,7 +328,7 @@ Pattern_Leafy(led_buffer* Leds, led_buffer_range Range, assembly Assembly, r32 T { DEBUG_TRACK_FUNCTION; blumen_lumen_state* BLState = (blumen_lumen_state*)UserData; - Time = Time * BLState->PatternSpeed; + Time = Time * BLState->PatternSpeed * .3f; phrase_hue Hue = BlumenLumen_GetCurrentHue(BLState, Assembly); v4 C0 = RGBFromPhraseHue(Hue.Hue0); diff --git a/src/app/platform_win32/win32_foldhaus.cpp b/src/app/platform_win32/win32_foldhaus.cpp index 4a4752d..d281552 100644 --- a/src/app/platform_win32/win32_foldhaus.cpp +++ b/src/app/platform_win32/win32_foldhaus.cpp @@ -40,8 +40,8 @@ window MainWindow; PLATFORM_GET_GPU_TEXTURE_HANDLE(Win32GetGPUTextureHandle) { - s32 Handle = SubmitTexture(Memory, Width, Height); - return Handle; + s32 Handle = SubmitTexture(Memory, Width, Height); + return Handle; } HDC FontDrawingDC; @@ -50,462 +50,462 @@ HFONT CurrentFont; GET_FONT_INFO(Win32GetFontInfo) { - platform_font_info Result = {}; - - FontDrawingDC = CreateCompatibleDC(NULL); - SetBkColor(FontDrawingDC, RGB(0, 0, 0)); - SetTextColor(FontDrawingDC, RGB(255, 255, 255)); - FontBitmap = CreateCompatibleBitmap(FontDrawingDC, PixelHeight * 2, PixelHeight * 2); - HGDIOBJ SelectObjectResult = SelectObject(FontDrawingDC, FontBitmap); - - CurrentFont = CreateFont(PixelHeight, 0, 0, 0, - FontWeight, - Italic, - Underline, - Strikeout, - ANSI_CHARSET, - OUT_OUTLINE_PRECIS, - CLIP_DEFAULT_PRECIS, - PROOF_QUALITY, - FIXED_PITCH, - FontName); - SelectFont(FontDrawingDC, CurrentFont); - - TEXTMETRIC WindowsFontMetrics = {}; - if (GetTextMetrics(FontDrawingDC, &WindowsFontMetrics)) - { - Result.PixelHeight = WindowsFontMetrics.tmHeight; - Result.Ascent = WindowsFontMetrics.tmAscent; - Result.Descent = WindowsFontMetrics.tmDescent; - Result.Leading = WindowsFontMetrics.tmExternalLeading; - Result.MaxCharWidth = WindowsFontMetrics.tmMaxCharWidth; - Result.CodepointStart = WindowsFontMetrics.tmFirstChar; - Result.CodepointOnePastLast = WindowsFontMetrics.tmLastChar + 1; - } - - return Result; + platform_font_info Result = {}; + + FontDrawingDC = CreateCompatibleDC(NULL); + SetBkColor(FontDrawingDC, RGB(0, 0, 0)); + SetTextColor(FontDrawingDC, RGB(255, 255, 255)); + FontBitmap = CreateCompatibleBitmap(FontDrawingDC, PixelHeight * 2, PixelHeight * 2); + HGDIOBJ SelectObjectResult = SelectObject(FontDrawingDC, FontBitmap); + + CurrentFont = CreateFont(PixelHeight, 0, 0, 0, + FontWeight, + Italic, + Underline, + Strikeout, + ANSI_CHARSET, + OUT_OUTLINE_PRECIS, + CLIP_DEFAULT_PRECIS, + PROOF_QUALITY, + FIXED_PITCH, + FontName); + SelectFont(FontDrawingDC, CurrentFont); + + TEXTMETRIC WindowsFontMetrics = {}; + if (GetTextMetrics(FontDrawingDC, &WindowsFontMetrics)) + { + Result.PixelHeight = WindowsFontMetrics.tmHeight; + Result.Ascent = WindowsFontMetrics.tmAscent; + Result.Descent = WindowsFontMetrics.tmDescent; + Result.Leading = WindowsFontMetrics.tmExternalLeading; + Result.MaxCharWidth = WindowsFontMetrics.tmMaxCharWidth; + Result.CodepointStart = WindowsFontMetrics.tmFirstChar; + Result.CodepointOnePastLast = WindowsFontMetrics.tmLastChar + 1; + } + + return Result; } DRAW_FONT_CODEPOINT(Win32DrawFontCodepoint) { - SIZE CodepointSize = {}; - if (GetTextExtentPoint32(FontDrawingDC, &Codepoint, 1, &CodepointSize)) - { - *OutWidth = CodepointSize.cx; - *OutHeight = CodepointSize.cy; - - RECT TextRect = {}; - TextRect.left = 0; - TextRect.right = *OutWidth; - TextRect.top = 0; - TextRect.bottom = *OutHeight; - - int Error = DrawText(FontDrawingDC, &Codepoint, 1, &TextRect, DT_LEFT | DT_NOCLIP | DT_TOP); - - u8* Row = DestBuffer + (YOffset * (DestBufferWidth * 4)); - COLORREF PixelColor; - for (u32 Y = 0; Y < *OutHeight; Y++) + SIZE CodepointSize = {}; + if (GetTextExtentPoint32(FontDrawingDC, &Codepoint, 1, &CodepointSize)) { - // NOTE(Peter): XOffset * 4 b/c its 4 bytes per pixel. - u8* Channel = (u8*)Row + (XOffset * 4); - for (u32 X = 0; X < *OutWidth; X++) - { - PixelColor = GetPixel(FontDrawingDC, X + TextRect.left, TextRect.bottom - Y); - Assert(PixelColor != CLR_INVALID); - u8 RValue = GetRValue(PixelColor); - *Channel++ = RValue; - *Channel++ = RValue; - *Channel++ = RValue; - *Channel++ = RValue; - } - Row += DestBufferWidth * 4; + *OutWidth = CodepointSize.cx; + *OutHeight = CodepointSize.cy; + + RECT TextRect = {}; + TextRect.left = 0; + TextRect.right = *OutWidth; + TextRect.top = 0; + TextRect.bottom = *OutHeight; + + int Error = DrawText(FontDrawingDC, &Codepoint, 1, &TextRect, DT_LEFT | DT_NOCLIP | DT_TOP); + + u8* Row = DestBuffer + (YOffset * (DestBufferWidth * 4)); + COLORREF PixelColor; + for (u32 Y = 0; Y < *OutHeight; Y++) + { + // NOTE(Peter): XOffset * 4 b/c its 4 bytes per pixel. + u8* Channel = (u8*)Row + (XOffset * 4); + for (u32 X = 0; X < *OutWidth; X++) + { + PixelColor = GetPixel(FontDrawingDC, X + TextRect.left, TextRect.bottom - Y); + Assert(PixelColor != CLR_INVALID); + u8 RValue = GetRValue(PixelColor); + *Channel++ = RValue; + *Channel++ = RValue; + *Channel++ = RValue; + *Channel++ = RValue; + } + Row += DestBufferWidth * 4; + } + } - - } } LRESULT CALLBACK HandleWindowEvents (HWND WindowHandle, UINT Msg, WPARAM WParam, LPARAM LParam) { - LRESULT Result = 0; - - switch (Msg) - { - case WM_SIZE: - { - Win32UpdateWindowDimension(&MainWindow); - //Win32ResizeDIBSection(&GlobalBackbuffer, MainWindow.Info.Width, MainWindow.Info.Height); - }break; + LRESULT Result = 0; - case WM_CLOSE: + switch (Msg) { - Result = DefWindowProc(WindowHandle, Msg, WParam, LParam); - Running = false; - }break; - - case WM_DESTROY: - { - }break; - - case WM_PAINT: - { - PAINTSTRUCT PaintStruct; - HDC DeviceContext; - b32 PaintResult; - - DeviceContext = BeginPaint(WindowHandle, &PaintStruct); - PaintResult = EndPaint(WindowHandle, &PaintStruct); - }break; - - case WM_ACTIVATE: - { - WindowIsActive = (LOWORD(WParam) == WA_ACTIVE || LOWORD(WParam) == WA_CLICKACTIVE); - }break; - - default: - { - Result = DefWindowProc(WindowHandle, Msg, WParam, LParam); + case WM_SIZE: + { + Win32UpdateWindowDimension(&MainWindow); + //Win32ResizeDIBSection(&GlobalBackbuffer, MainWindow.Info.Width, MainWindow.Info.Height); + }break; + + case WM_CLOSE: + { + Result = DefWindowProc(WindowHandle, Msg, WParam, LParam); + Running = false; + }break; + + case WM_DESTROY: + { + }break; + + case WM_PAINT: + { + PAINTSTRUCT PaintStruct; + HDC DeviceContext; + b32 PaintResult; + + DeviceContext = BeginPaint(WindowHandle, &PaintStruct); + PaintResult = EndPaint(WindowHandle, &PaintStruct); + }break; + + case WM_ACTIVATE: + { + WindowIsActive = (LOWORD(WParam) == WA_ACTIVE || LOWORD(WParam) == WA_CLICKACTIVE); + }break; + + default: + { + Result = DefWindowProc(WindowHandle, Msg, WParam, LParam); + } } - } - - return Result; + + return Result; } internal void HandleWindowMessage (MSG Message, window* Window, input_queue* InputQueue, mouse_state* Mouse) { - switch (Message.message) - { - case WM_MOUSEWHEEL: - { - Mouse->Scroll = GET_WHEEL_DELTA_WPARAM(Message.wParam); - }break; - - case WM_LBUTTONDOWN: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, false, true, - ShiftDown, AltDown, CtrlDown, false); - - Mouse->LeftButtonState |= KeyState_IsDown; - Mouse->DownPos = Mouse->Pos; - - // :Win32MouseEventCapture - // NOTE(Peter): We capture events when the mouse goes down so that - // if the user drags outside the window, we still get the mouse up - // event and can process it. Otherwise, we can get into cases where - // an event was started, didn't end, but the user can click again and - // try to start the event again. - // We relase event capture on mouse up. - SetCapture(Window->Handle); - }break; - - case WM_MBUTTONDOWN: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseMiddleButton, false, true, - ShiftDown, AltDown, CtrlDown, false); - Mouse->MiddleButtonState = KeyState_IsDown & ~KeyState_WasDown; - - // :Win32MouseEventCapture - SetCapture(Window->Handle); - }break; - - case WM_RBUTTONDOWN: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseRightButton, false, true, - ShiftDown, AltDown, CtrlDown, false); - Mouse->RightButtonState = KeyState_IsDown & ~KeyState_WasDown; - Mouse->DownPos = Mouse->Pos; - - // :Win32MouseEventCapture - SetCapture(Window->Handle); - }break; - - case WM_LBUTTONUP: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, true, false, - ShiftDown, AltDown, CtrlDown, false); - Mouse->LeftButtonState &= ~KeyState_IsDown; - - // :Win32MouseEventCapture - ReleaseCapture(); - }break; - - case WM_MBUTTONUP: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseMiddleButton, true, false, - ShiftDown, AltDown, CtrlDown, false); - Mouse->MiddleButtonState = ~KeyState_IsDown & KeyState_WasDown; - - // :Win32MouseEventCapture - ReleaseCapture(); - }break; - - case WM_RBUTTONUP: - { - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - AddInputEventEntry(InputQueue, KeyCode_MouseRightButton, true, false, - ShiftDown, AltDown, CtrlDown, false); - Mouse->RightButtonState = ~KeyState_IsDown & KeyState_WasDown; - - // :Win32MouseEventCapture - ReleaseCapture(); - }break; - - case WM_SYSKEYDOWN: - case WM_SYSKEYUP: - case WM_KEYDOWN: - case WM_KEYUP: + switch (Message.message) { + case WM_MOUSEWHEEL: + { + Mouse->Scroll = GET_WHEEL_DELTA_WPARAM(Message.wParam); + }break; + + case WM_LBUTTONDOWN: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, false, true, + ShiftDown, AltDown, CtrlDown, false); + + Mouse->LeftButtonState |= KeyState_IsDown; + Mouse->DownPos = Mouse->Pos; + + // :Win32MouseEventCapture + // NOTE(Peter): We capture events when the mouse goes down so that + // if the user drags outside the window, we still get the mouse up + // event and can process it. Otherwise, we can get into cases where + // an event was started, didn't end, but the user can click again and + // try to start the event again. + // We relase event capture on mouse up. + SetCapture(Window->Handle); + }break; + + case WM_MBUTTONDOWN: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseMiddleButton, false, true, + ShiftDown, AltDown, CtrlDown, false); + Mouse->MiddleButtonState = KeyState_IsDown & ~KeyState_WasDown; + + // :Win32MouseEventCapture + SetCapture(Window->Handle); + }break; + + case WM_RBUTTONDOWN: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseRightButton, false, true, + ShiftDown, AltDown, CtrlDown, false); + Mouse->RightButtonState = KeyState_IsDown & ~KeyState_WasDown; + Mouse->DownPos = Mouse->Pos; + + // :Win32MouseEventCapture + SetCapture(Window->Handle); + }break; + + case WM_LBUTTONUP: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseLeftButton, true, false, + ShiftDown, AltDown, CtrlDown, false); + Mouse->LeftButtonState &= ~KeyState_IsDown; + + // :Win32MouseEventCapture + ReleaseCapture(); + }break; + + case WM_MBUTTONUP: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseMiddleButton, true, false, + ShiftDown, AltDown, CtrlDown, false); + Mouse->MiddleButtonState = ~KeyState_IsDown & KeyState_WasDown; + + // :Win32MouseEventCapture + ReleaseCapture(); + }break; + + case WM_RBUTTONUP: + { + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + AddInputEventEntry(InputQueue, KeyCode_MouseRightButton, true, false, + ShiftDown, AltDown, CtrlDown, false); + Mouse->RightButtonState = ~KeyState_IsDown & KeyState_WasDown; + + // :Win32MouseEventCapture + ReleaseCapture(); + }break; + + case WM_SYSKEYDOWN: + case WM_SYSKEYUP: + case WM_KEYDOWN: + case WM_KEYUP: + { #if 0 - int VirtualKey = (int)Message.wParam; - key_code Key = Win32GetKeyCode(VirtualKey, true, false); - s32 KeyIndex = (int)Key; - - b32 KeyWasDown = (Message.lParam & (1 << 30)) != 0; - b32 KeyIsDown = (Message.lParam & (1 << 31)) == 0; - - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - // New Input Queue - AddInputEventEntry(InputQueue, Key, KeyWasDown, KeyIsDown, - ShiftDown, AltDown, CtrlDown, false); + int VirtualKey = (int)Message.wParam; + key_code Key = Win32GetKeyCode(VirtualKey, true, false); + s32 KeyIndex = (int)Key; + + b32 KeyWasDown = (Message.lParam & (1 << 30)) != 0; + b32 KeyIsDown = (Message.lParam & (1 << 31)) == 0; + + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + // New Input Queue + AddInputEventEntry(InputQueue, Key, KeyWasDown, KeyIsDown, + ShiftDown, AltDown, CtrlDown, false); #endif - TranslateMessage(&Message); - DispatchMessage(&Message); - }break; - - case WM_CHAR: - { - char VirtualKey = (char)Message.wParam; - key_code Key = CharToKeyCode(VirtualKey); - s32 KeyIndex = (int)Key; - - b32 KeyWasDown = (Message.lParam & (1 << 30)) != 0; - b32 KeyIsDown = (Message.lParam & (1 << 31)) == 0; - - b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; - b32 AltDown = GetKeyState(VK_MENU) & 0x8000; - b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; - - // New Input Queue - AddInputEventEntry(InputQueue, Key, KeyWasDown, KeyIsDown, - ShiftDown, AltDown, CtrlDown, false); - }break; - - default: - { - TranslateMessage(&Message); - DispatchMessage(&Message); - }break; - } + TranslateMessage(&Message); + DispatchMessage(&Message); + }break; + + case WM_CHAR: + { + char VirtualKey = (char)Message.wParam; + key_code Key = CharToKeyCode(VirtualKey); + s32 KeyIndex = (int)Key; + + b32 KeyWasDown = (Message.lParam & (1 << 30)) != 0; + b32 KeyIsDown = (Message.lParam & (1 << 31)) == 0; + + b32 ShiftDown = GetKeyState(VK_SHIFT) & 0x8000; + b32 AltDown = GetKeyState(VK_MENU) & 0x8000; + b32 CtrlDown = GetKeyState(VK_CONTROL) & 0x8000; + + // New Input Queue + AddInputEventEntry(InputQueue, Key, KeyWasDown, KeyIsDown, + ShiftDown, AltDown, CtrlDown, false); + }break; + + default: + { + TranslateMessage(&Message); + DispatchMessage(&Message); + }break; + } } internal void DebugPrint (char* Format, ...) { - char Buffer[256]; - gs_string StringBuffer = MakeString(Buffer, 256); - va_list Args; - va_start(Args, Format); - Log_PrintFVarArgs(GlobalLogBuffer, LogEntry_Message, Format, Args); - va_end(Args); + char Buffer[256]; + gs_string StringBuffer = MakeString(Buffer, 256); + va_list Args; + va_start(Args, Format); + Log_PrintFVarArgs(GlobalLogBuffer, LogEntry_Message, Format, Args); + va_end(Args); } internal void SetApplicationLinks (context* Context, win32_dll_refresh DLL, gs_work_queue* WorkQueue) { - if (DLL.IsValid) - { - Context->InitializeApplication = (initialize_application*)GetProcAddress(DLL.DLL, "InitializeApplication"); - Context->ReloadStaticData = (reload_static_data*)GetProcAddress(DLL.DLL, "ReloadStaticData"); - Context->UpdateAndRender = (update_and_render*)GetProcAddress(DLL.DLL, "UpdateAndRender"); - Context->CleanupApplication = (cleanup_application*)GetProcAddress(DLL.DLL, "CleanupApplication"); - } - else - { - Context->InitializeApplication = 0; - Context->ReloadStaticData = 0; - Context->UpdateAndRender = 0; - Context->CleanupApplication = 0; - } + if (DLL.IsValid) + { + Context->InitializeApplication = (initialize_application*)GetProcAddress(DLL.DLL, "InitializeApplication"); + Context->ReloadStaticData = (reload_static_data*)GetProcAddress(DLL.DLL, "ReloadStaticData"); + Context->UpdateAndRender = (update_and_render*)GetProcAddress(DLL.DLL, "UpdateAndRender"); + Context->CleanupApplication = (cleanup_application*)GetProcAddress(DLL.DLL, "CleanupApplication"); + } + else + { + Context->InitializeApplication = 0; + Context->ReloadStaticData = 0; + Context->UpdateAndRender = 0; + Context->CleanupApplication = 0; + } } internal void Win32_SendAddressedDataBuffer(gs_thread_context Context, addressed_data_buffer* BufferAt) { - DEBUG_TRACK_FUNCTION; - - u32 BuffersSent = 0; - u32 DataSizeSent = 0; - - switch(BufferAt->AddressType) - { - case AddressType_NetworkIP: - { - Win32Socket_SendTo(BufferAt->SendSocket, - BufferAt->V4SendAddress, - BufferAt->SendPort, - (const char*)BufferAt->Memory, - BufferAt->MemorySize, - 0); - }break; + DEBUG_TRACK_FUNCTION; - case AddressType_ComPort: + u32 BuffersSent = 0; + u32 DataSizeSent = 0; + + switch(BufferAt->AddressType) { - if (BufferAt->ComPort.Length > 0) - { - HANDLE SerialPort = Win32SerialArray_GetOrOpen(BufferAt->ComPort, 2000000, 8, NOPARITY, 1, Context.Transient); - if (SerialPort != INVALID_HANDLE_VALUE) + case AddressType_NetworkIP: { - if (Win32SerialPort_Write(SerialPort, BufferAt->Data)) - { - BuffersSent += 1; - DataSizeSent += BufferAt->Data.Size; - } - else - { - Win32SerialArray_Close(BufferAt->ComPort); - } - } - } - else - { + Win32Socket_SendTo(BufferAt->SendSocket, + BufferAt->V4SendAddress, + BufferAt->SendPort, + (const char*)BufferAt->Memory, + BufferAt->MemorySize, + 0); + }break; + + case AddressType_ComPort: + { + if (BufferAt->ComPort.Length > 0) + { + HANDLE SerialPort = Win32SerialArray_GetOrOpen(BufferAt->ComPort, 2000000, 8, NOPARITY, 1, Context.Transient); + if (SerialPort != INVALID_HANDLE_VALUE) + { + if (Win32SerialPort_Write(SerialPort, BufferAt->Data)) + { + BuffersSent += 1; + DataSizeSent += BufferAt->Data.Size; + } + else + { + Win32SerialArray_Close(BufferAt->ComPort); + } + } + } + else + { #if 0 - Log_Message(GlobalLogBuffer, - "Skipping data buffer because its COM Port isn't set"); + Log_Message(GlobalLogBuffer, + "Skipping data buffer because its COM Port isn't set"); #endif - } - }break; - - InvalidDefaultCase; - } + } + }break; + + InvalidDefaultCase; + } } internal void Win32_SendAddressedDataBuffer_Job(gs_thread_context Context, gs_data Arg) { - addressed_data_buffer* OutputData = (addressed_data_buffer*)Arg.Memory; - Win32_SendAddressedDataBuffer(Context, OutputData); + addressed_data_buffer* OutputData = (addressed_data_buffer*)Arg.Memory; + Win32_SendAddressedDataBuffer(Context, OutputData); } internal bool ReloadAndLinkDLL(win32_dll_refresh* DLL, context* Context, gs_work_queue* WorkQueue, bool ShouldError, bool AppReady) { - bool Success = false; - if (HotLoadDLL(DLL)) - { - SetApplicationLinks(Context, *DLL, WorkQueue); - Context->ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, AppReady); - Success = true; - Log_Message(GlobalLogBuffer, "Reloaded DLL\n"); - } - else if(ShouldError) - { - Log_Error(GlobalLogBuffer, "Unable to load application DLL at startup.\nAborting\n"); - } - return Success; + bool Success = false; + if (HotLoadDLL(DLL)) + { + SetApplicationLinks(Context, *DLL, WorkQueue); + Context->ReloadStaticData(*Context, GlobalDebugServices, GlobalLogBuffer, AppReady); + Success = true; + Log_Message(GlobalLogBuffer, "Reloaded DLL\n"); + } + else if(ShouldError) + { + Log_Error(GlobalLogBuffer, "Unable to load application DLL at startup.\nAborting\n"); + } + return Success; } internal gs_const_string GetExePath(HINSTANCE HInstance, gs_thread_context ThreadContext) { - gs_const_string Result = {}; - - u32 Error = 0; - u32 PathSize = MAX_PATH; - char* Path = PushArray(ThreadContext.Transient, char, PathSize); - DWORD Length = GetModuleFileNameA(HInstance, Path, PathSize); - - if (Length) - { - Error = GetLastError(); - if (Error == ERROR_INSUFFICIENT_BUFFER) { - // PathSize wasn't long enough - // TODO(pjs): handle this case - InvalidCodePath; + gs_const_string Result = {}; + + u32 Error = 0; + u32 PathSize = MAX_PATH; + char* Path = PushArray(ThreadContext.Transient, char, PathSize); + DWORD Length = GetModuleFileNameA(HInstance, Path, PathSize); + + if (Length) + { + Error = GetLastError(); + if (Error == ERROR_INSUFFICIENT_BUFFER) { + // PathSize wasn't long enough + // TODO(pjs): handle this case + InvalidCodePath; + } + + Result.Str = Path; + Result.Length = (u64)Length; + } + else + { + Error = GetLastError(); + InvalidCodePath; } - Result.Str = Path; - Result.Length = (u64)Length; - } - else - { - Error = GetLastError(); - InvalidCodePath; - } - - return Result; + return Result; } internal bool SetWorkingDirectory(HINSTANCE HInstance, gs_thread_context ThreadContext) { - bool Result = false; - - gs_const_string ExePath = GetExePath(HInstance, ThreadContext); - gs_string ScratchPath = PushString(ThreadContext.Transient, ExePath.Length + 128); - gs_string WorkingDirectory = PushString(ThreadContext.Transient, ExePath.Length + 128); - - while (WorkingDirectory.Length == 0) - { - s64 LastSlash = FindLastFromSet(ExePath, "\\/"); - if (LastSlash < 0) break; + bool Result = false; - ExePath = Substring(ExePath, 0, LastSlash); - PrintF(&ScratchPath, "%S\\data", ExePath); - NullTerminate(&ScratchPath); + gs_const_string ExePath = GetExePath(HInstance, ThreadContext); + gs_string ScratchPath = PushString(ThreadContext.Transient, ExePath.Length + 128); + gs_string WorkingDirectory = PushString(ThreadContext.Transient, ExePath.Length + 128); - gs_file_info PathInfo = GetFileInfo(ThreadContext.FileHandler, ScratchPath.ConstString); - if (PathInfo.Path.Length > 0 && - PathInfo.IsDirectory) { - PrintF(&WorkingDirectory, "%S", ExePath); - NullTerminate(&WorkingDirectory); - } - } - - if (WorkingDirectory.Length > 0) - { - Log_Message(GlobalLogBuffer, - "Setting Working Directory \n%S \n", - WorkingDirectory.ConstString); - Result = SetCurrentDirectory(WorkingDirectory.Str); - if (!Result) + while (WorkingDirectory.Length == 0) { - u32 Error = GetLastError(); - InvalidCodePath; + s64 LastSlash = FindLastFromSet(ExePath, "\\/"); + if (LastSlash < 0) break; + + ExePath = Substring(ExePath, 0, LastSlash); + PrintF(&ScratchPath, "%S\\data", ExePath); + NullTerminate(&ScratchPath); + + gs_file_info PathInfo = GetFileInfo(ThreadContext.FileHandler, ScratchPath.ConstString); + if (PathInfo.Path.Length > 0 && + PathInfo.IsDirectory) { + PrintF(&WorkingDirectory, "%S", ExePath); + NullTerminate(&WorkingDirectory); + } } - } - else - { - Log_Error(GlobalLogBuffer, "Error, no data folder found\n"); - } - - return Result; + + if (WorkingDirectory.Length > 0) + { + Log_Message(GlobalLogBuffer, + "Setting Working Directory \n%S \n", + WorkingDirectory.ConstString); + Result = SetCurrentDirectory(WorkingDirectory.Str); + if (!Result) + { + u32 Error = GetLastError(); + InvalidCodePath; + } + } + else + { + Log_Error(GlobalLogBuffer, "Error, no data folder found\n"); + } + + return Result; } #include "../../gs_libs/gs_path.h" @@ -513,67 +513,67 @@ SetWorkingDirectory(HINSTANCE HInstance, gs_thread_context ThreadContext) internal void Win32_SendOutputData(gs_thread_context ThreadContext, addressed_data_buffer_list OutputData) { - bool Multithread = true; - if (Multithread) - { - for (addressed_data_buffer* At = OutputData.Root; - At != 0; - At = At->Next) + bool Multithread = true; + if (Multithread) { - gs_data ProcArg = {}; - ProcArg.Memory = (u8*)At; - ProcArg.Size = sizeof(addressed_data_buffer); - Win32PushWorkOnQueue(&Win32WorkQueue.WorkQueue, Win32_SendAddressedDataBuffer_Job, ProcArg, ConstString("Send UART Data")); + for (addressed_data_buffer* At = OutputData.Root; + At != 0; + At = At->Next) + { + gs_data ProcArg = {}; + ProcArg.Memory = (u8*)At; + ProcArg.Size = sizeof(addressed_data_buffer); + Win32PushWorkOnQueue(&Win32WorkQueue.WorkQueue, Win32_SendAddressedDataBuffer_Job, ProcArg, ConstString("Send UART Data")); + } } - } - else - { - for (addressed_data_buffer* At = OutputData.Root; - At != 0; - At = At->Next) + else { - gs_data ProcArg = {}; - ProcArg.Memory = (u8*)At; - ProcArg.Size = sizeof(addressed_data_buffer); - Win32_SendAddressedDataBuffer_Job(ThreadContext, ProcArg); + for (addressed_data_buffer* At = OutputData.Root; + At != 0; + At = At->Next) + { + gs_data ProcArg = {}; + ProcArg.Memory = (u8*)At; + ProcArg.Size = sizeof(addressed_data_buffer); + Win32_SendAddressedDataBuffer_Job(ThreadContext, ProcArg); + } } - } - + } // Time internal system_time Win32GetSystemTime() { - system_time Result = {}; - - SYSTEMTIME WinLocalTime; - GetLocalTime(&WinLocalTime); - - SYSTEMTIME WinSysTime; - FILETIME WinSysFileTime; - GetSystemTime(&WinSysTime); - if (SystemTimeToFileTime((const SYSTEMTIME*)&WinSysTime, &WinSysFileTime)) - { - ULARGE_INTEGER SysTime = {}; - SysTime.LowPart = WinSysFileTime.dwLowDateTime; - SysTime.HighPart = WinSysFileTime.dwHighDateTime; + system_time Result = {}; - Result.NanosSinceEpoch = SysTime.QuadPart; - Result.Year = WinLocalTime.wYear; - Result.Month = WinLocalTime.wMonth; - Result.Day = WinLocalTime.wDay; - Result.Hour = WinLocalTime.wHour; - Result.Minute = WinLocalTime.wMinute; - Result.Second = WinLocalTime.wSecond; - } - else - { - u32 Error = GetLastError(); - InvalidCodePath; - } - - return Result; + SYSTEMTIME WinLocalTime; + GetLocalTime(&WinLocalTime); + + SYSTEMTIME WinSysTime; + FILETIME WinSysFileTime; + GetSystemTime(&WinSysTime); + if (SystemTimeToFileTime((const SYSTEMTIME*)&WinSysTime, &WinSysFileTime)) + { + ULARGE_INTEGER SysTime = {}; + SysTime.LowPart = WinSysFileTime.dwLowDateTime; + SysTime.HighPart = WinSysFileTime.dwHighDateTime; + + Result.NanosSinceEpoch = SysTime.QuadPart; + Result.Year = WinLocalTime.wYear; + Result.Month = WinLocalTime.wMonth; + Result.Day = WinLocalTime.wDay; + Result.Hour = WinLocalTime.wHour; + Result.Minute = WinLocalTime.wMinute; + Result.Second = WinLocalTime.wSecond; + } + else + { + u32 Error = GetLastError(); + InvalidCodePath; + } + + return Result; } int WINAPI @@ -584,202 +584,202 @@ WinMain ( INT NCmdShow ) { - gs_thread_context ThreadContext = Win32CreateThreadContext(); - - gs_memory_arena PlatformPermanent = MemoryArenaCreate(MB(4), - Bytes(8), ThreadContext.Allocator, - 0, - 0, - "Platform Memory"); - - GlobalLogBuffer = AllocStruct(ThreadContext.Allocator, log_buffer, "Global Log Buffer"); - *GlobalLogBuffer = Log_Init(&PlatformPermanent, 32); - - if (!SetWorkingDirectory(HInstance, ThreadContext)) return 1; - - context Context = {}; - Context.ThreadContext = ThreadContext; - Context.SystemTime_Current = Win32GetSystemTime(); - - gs_const_string Args = ConstString((char*)CmdLineArgs); - if (StringsEqual(Args, ConstString("-headless"))) - { - Log_Message(GlobalLogBuffer, "Running Headless\n"); - Context.Headless = true; - } - - if (!Context.Headless) - { - MainWindow = Win32CreateWindow (HInstance, "Foldhaus", 1440, 768, HandleWindowEvents); - Win32UpdateWindowDimension(&MainWindow); + gs_thread_context ThreadContext = Win32CreateThreadContext(); - win32_opengl_window_info OpenGLWindowInfo = {}; - OpenGLWindowInfo.ColorBits = 32; - OpenGLWindowInfo.AlphaBits = 8; - OpenGLWindowInfo.DepthBits = 0; - CreateOpenGLWindowContext(OpenGLWindowInfo, &MainWindow); - } - - s64 PerformanceCountFrequency = GetPerformanceFrequency(); - s64 LastFrameEnd = GetWallClock(); - r32 TargetSecondsPerFrame = 1 / 30.0f; - r32 LastFrameSecondsElapsed = 0.0f; - - GlobalDebugServices = PushStruct(&PlatformPermanent, debug_services); + gs_memory_arena PlatformPermanent = MemoryArenaCreate(MB(4), + Bytes(8), ThreadContext.Allocator, + 0, + 0, + "Platform Memory"); + + GlobalLogBuffer = AllocStruct(ThreadContext.Allocator, log_buffer, "Global Log Buffer"); + *GlobalLogBuffer = Log_Init(&PlatformPermanent, 32); + + if (!SetWorkingDirectory(HInstance, ThreadContext)) return 1; + + context Context = {}; + Context.ThreadContext = ThreadContext; + Context.SystemTime_Current = Win32GetSystemTime(); + + gs_const_string Args = ConstString((char*)CmdLineArgs); + if (StringsEqual(Args, ConstString("-headless"))) + { + Log_Message(GlobalLogBuffer, "Running Headless\n"); + Context.Headless = true; + } + + if (!Context.Headless) + { + MainWindow = Win32CreateWindow (HInstance, "Foldhaus", 1440, 768, HandleWindowEvents); + Win32UpdateWindowDimension(&MainWindow); + + win32_opengl_window_info OpenGLWindowInfo = {}; + OpenGLWindowInfo.ColorBits = 32; + OpenGLWindowInfo.AlphaBits = 8; + OpenGLWindowInfo.DepthBits = 0; + CreateOpenGLWindowContext(OpenGLWindowInfo, &MainWindow); + } + + s64 PerformanceCountFrequency = GetPerformanceFrequency(); + s64 LastFrameEnd = GetWallClock(); + r32 TargetSecondsPerFrame = 1 / 30.0f; + r32 LastFrameSecondsElapsed = 0.0f; + + GlobalDebugServices = PushStruct(&PlatformPermanent, debug_services); #if DEBUG - InitDebugServices_DebugMode(GlobalDebugServices, + InitDebugServices_DebugMode(GlobalDebugServices, + PerformanceCountFrequency, + GetWallClock, + Win32GetThreadId, + Context.ThreadContext, + PLATFORM_THREAD_COUNT + 1); +#else + InitDebugServices_OffMode(GlobalDebugServices, PerformanceCountFrequency, GetWallClock, Win32GetThreadId, Context.ThreadContext, PLATFORM_THREAD_COUNT + 1); -#else - InitDebugServices_OffMode(GlobalDebugServices, - PerformanceCountFrequency, - GetWallClock, - Win32GetThreadId, - Context.ThreadContext, - PLATFORM_THREAD_COUNT + 1); #endif - - input_queue InputQueue = InputQueue_Create(&PlatformPermanent, 32); - - Win32WorkQueue_Init(&PlatformPermanent, PLATFORM_THREAD_COUNT); - - // Platform functions - Context.GeneralWorkQueue = &Win32WorkQueue.WorkQueue; - Context.PlatformGetGPUTextureHandle = Win32GetGPUTextureHandle; - Context.PlatformGetSocketHandle = Win32GetSocketHandle; - Context.PlatformGetFontInfo = Win32GetFontInfo; - Context.PlatformDrawFontCodepoint = Win32DrawFontCodepoint; - - Context.ThreadManager = PushStruct(&PlatformPermanent, platform_thread_manager); - *Context.ThreadManager = CreatePlatformThreadManager(Win32CreateThread, Win32KillThread); - - Context.SocketManager = PushStruct(&PlatformPermanent, platform_socket_manager); - *Context.SocketManager = CreatePlatformSocketManager(Win32ConnectSocket, Win32CloseSocket, Win32SocketQueryStatus, Win32SocketPeek, Win32SocketReceive, Win32SocketSend); - - win32_dll_refresh DLLRefresh = InitializeDLLHotReloading(DLLName, WorkingDLLName, DLLLockFileName); - if (!ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, true, false)) { return -1; } - - Mouse_Init(); - - Win32SocketSystem_Init(&PlatformPermanent); - - Win32SerialArray_Create(&PlatformPermanent); - - render_command_buffer RenderBuffer = {}; - if (!Context.Headless) - { - RenderBuffer = AllocateRenderCommandBuffer(MB(12), &PlatformPermanent, ThreadContext); - } - - addressed_data_buffer_list OutputData = AddressedDataBufferList_Create(ThreadContext); - - Context.InitializeApplication(&Context); - - system_time StartTime = Win32GetSystemTime(); - - Running = true; - Context.WindowIsVisible = true; - while (Running) - { - if (GlobalDebugServices->RecordFrames) + + input_queue InputQueue = InputQueue_Create(&PlatformPermanent, 32); + + Win32WorkQueue_Init(&PlatformPermanent, PLATFORM_THREAD_COUNT); + + // Platform functions + Context.GeneralWorkQueue = &Win32WorkQueue.WorkQueue; + Context.PlatformGetGPUTextureHandle = Win32GetGPUTextureHandle; + Context.PlatformGetSocketHandle = Win32GetSocketHandle; + Context.PlatformGetFontInfo = Win32GetFontInfo; + Context.PlatformDrawFontCodepoint = Win32DrawFontCodepoint; + + Context.ThreadManager = PushStruct(&PlatformPermanent, platform_thread_manager); + *Context.ThreadManager = CreatePlatformThreadManager(Win32CreateThread, Win32KillThread); + + Context.SocketManager = PushStruct(&PlatformPermanent, platform_socket_manager); + *Context.SocketManager = CreatePlatformSocketManager(Win32ConnectSocket, Win32CloseSocket, Win32SocketQueryStatus, Win32SocketPeek, Win32SocketReceive, Win32SocketSend); + + win32_dll_refresh DLLRefresh = InitializeDLLHotReloading(DLLName, WorkingDLLName, DLLLockFileName); + if (!ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, true, false)) { return -1; } + + Mouse_Init(); + + Win32SocketSystem_Init(&PlatformPermanent); + + Win32SerialArray_Create(&PlatformPermanent); + + render_command_buffer RenderBuffer = {}; + if (!Context.Headless) { - EndDebugFrame(GlobalDebugServices); + RenderBuffer = AllocateRenderCommandBuffer(MB(12), &PlatformPermanent, ThreadContext); } - DEBUG_TRACK_SCOPE(MainLoop); + addressed_data_buffer_list OutputData = AddressedDataBufferList_Create(ThreadContext); + Context.InitializeApplication(&Context); + + system_time StartTime = Win32GetSystemTime(); + + Running = true; + Context.WindowIsVisible = true; + while (Running) { - Context.SystemTime_Last = Context.SystemTime_Current; - Context.SystemTime_Current = Win32GetSystemTime(); - + if (GlobalDebugServices->RecordFrames) + { + EndDebugFrame(GlobalDebugServices); + } + + DEBUG_TRACK_SCOPE(MainLoop); + + { + Context.SystemTime_Last = Context.SystemTime_Current; + Context.SystemTime_Current = Win32GetSystemTime(); + #define PRINT_SYSTEM_TIME 0 #if PRINT_SYSTEM_TIME - gs_string T = PushStringF(Context.ThreadContext.Transient, - 256, - "%d %d %d - %lld\n", - Context.SystemTime_Current.Hour, - Context.SystemTime_Current.Minute, - Context.SystemTime_Current.Second, - Context.SystemTime_Current.NanosSinceEpoch); - - u64 NanosElapsed = Context.SystemTime_Current.NanosSinceEpoch - StartTime.NanosSinceEpoch; - r64 SecondsElapsed = (r64)NanosElapsed * NanosToSeconds; - - Log_Message(GlobalLogBuffer, - "%lld %f Seconds \n", - NanosElapsed, - SecondsElapsed); + gs_string T = PushStringF(Context.ThreadContext.Transient, + 256, + "%d %d %d - %lld\n", + Context.SystemTime_Current.Hour, + Context.SystemTime_Current.Minute, + Context.SystemTime_Current.Second, + Context.SystemTime_Current.NanosSinceEpoch); + + u64 NanosElapsed = Context.SystemTime_Current.NanosSinceEpoch - StartTime.NanosSinceEpoch; + r64 SecondsElapsed = (r64)NanosElapsed * NanosToSeconds; + + Log_Message(GlobalLogBuffer, + "%lld %f Seconds \n", + NanosElapsed, + SecondsElapsed); #endif + } + + ResetInputQueue(&InputQueue); + + ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, false, true); + + AddressedDataBufferList_Clear(&OutputData); + + if (!Context.Headless) + { + Mouse_Update(MainWindow, &Context); + MSG Message; + while (PeekMessageA(&Message, MainWindow.Handle, 0, 0, PM_REMOVE)) + { + DEBUG_TRACK_SCOPE(PeekWindowsMessages); + HandleWindowMessage(Message, &MainWindow, &InputQueue, &Context.Mouse); + } + + Context.WindowBounds = rect2{v2{0, 0}, v2{(r32)MainWindow.Width, (r32)MainWindow.Height}}; + RenderBuffer.ViewWidth = MainWindow.Width; + RenderBuffer.ViewHeight = MainWindow.Height; + } + + Context.DeltaTime = LastFrameSecondsElapsed; + Context.TotalTime += (r64)Context.DeltaTime; + + Context.UpdateAndRender(&Context, InputQueue, &RenderBuffer, &OutputData); + + Win32_SendOutputData(ThreadContext, OutputData); + + if (!Context.Headless) + { + RenderCommandBuffer(RenderBuffer); + ClearRenderBuffer(&RenderBuffer); + + Mouse_Advance(&Context); + + HDC DeviceContext = GetDC(MainWindow.Handle); + SwapBuffers(DeviceContext); + ReleaseDC(MainWindow.Handle, DeviceContext); + } + + Win32DoQueueWorkUntilDone(&Win32WorkQueue.WorkQueue, Context.ThreadContext); + + s64 FinishedWorkTime = GetWallClock(); + r32 SecondsElapsed = GetSecondsElapsed(LastFrameEnd, FinishedWorkTime, PerformanceCountFrequency); + + while (SecondsElapsed < TargetSecondsPerFrame) + { + DEBUG_TRACK_SCOPE(UnusedTime); + u32 SleepTime = 1000.0f * (TargetSecondsPerFrame - SecondsElapsed); + Sleep(SleepTime); + SecondsElapsed = GetSecondsElapsed(LastFrameEnd, GetWallClock(), PerformanceCountFrequency); + } + + LastFrameSecondsElapsed = SecondsElapsed; + LastFrameEnd = GetWallClock(); } - ResetInputQueue(&InputQueue); - - ReloadAndLinkDLL(&DLLRefresh, &Context, &Win32WorkQueue.WorkQueue, false, true); - - AddressedDataBufferList_Clear(&OutputData); - - if (!Context.Headless) - { - Mouse_Update(MainWindow, &Context); - MSG Message; - while (PeekMessageA(&Message, MainWindow.Handle, 0, 0, PM_REMOVE)) - { - DEBUG_TRACK_SCOPE(PeekWindowsMessages); - HandleWindowMessage(Message, &MainWindow, &InputQueue, &Context.Mouse); - } - - Context.WindowBounds = rect2{v2{0, 0}, v2{(r32)MainWindow.Width, (r32)MainWindow.Height}}; - RenderBuffer.ViewWidth = MainWindow.Width; - RenderBuffer.ViewHeight = MainWindow.Height; - } - - Context.DeltaTime = LastFrameSecondsElapsed; - Context.TotalTime += (r64)Context.DeltaTime; - - Context.UpdateAndRender(&Context, InputQueue, &RenderBuffer, &OutputData); - + Context.CleanupApplication(Context, &OutputData); Win32_SendOutputData(ThreadContext, OutputData); - - if (!Context.Headless) - { - RenderCommandBuffer(RenderBuffer); - ClearRenderBuffer(&RenderBuffer); - - Mouse_Advance(&Context); - - HDC DeviceContext = GetDC(MainWindow.Handle); - SwapBuffers(DeviceContext); - ReleaseDC(MainWindow.Handle, DeviceContext); - } - Win32DoQueueWorkUntilDone(&Win32WorkQueue.WorkQueue, Context.ThreadContext); - s64 FinishedWorkTime = GetWallClock(); - r32 SecondsElapsed = GetSecondsElapsed(LastFrameEnd, FinishedWorkTime, PerformanceCountFrequency); + Win32WorkQueue_Cleanup(); + Win32SocketSystem_Cleanup(); - while (SecondsElapsed < TargetSecondsPerFrame) - { - DEBUG_TRACK_SCOPE(UnusedTime); - u32 SleepTime = 1000.0f * (TargetSecondsPerFrame - SecondsElapsed); - Sleep(SleepTime); - SecondsElapsed = GetSecondsElapsed(LastFrameEnd, GetWallClock(), PerformanceCountFrequency); - } - - LastFrameSecondsElapsed = SecondsElapsed; - LastFrameEnd = GetWallClock(); - } - - Context.CleanupApplication(Context, &OutputData); - Win32_SendOutputData(ThreadContext, OutputData); - Win32DoQueueWorkUntilDone(&Win32WorkQueue.WorkQueue, Context.ThreadContext); - - Win32WorkQueue_Cleanup(); - Win32SocketSystem_Cleanup(); - - return 0; + return 0; } #define WIN32_FOLDHAUS_CPP diff --git a/src/app/ss_blumen_lumen/blumen_lumen.cpp b/src/app/ss_blumen_lumen/blumen_lumen.cpp index 486a3fc..382690a 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen.cpp +++ b/src/app/ss_blumen_lumen/blumen_lumen.cpp @@ -574,6 +574,8 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) } } + + if (BLState->InPhraseReceptionMode) { r32 SecondsSincePhraseBegan = SecondsElapsed(BLState->TimePhraseReceptionBegan, Context->SystemTime_Current); @@ -759,7 +761,7 @@ BlumenLumen_CustomUpdate(gs_data UserData, app_state* State, context* Context) } // Dim the leds based on temp data - if (!BLState->DEBUG_IgnoreWeatherDimmingLeds) + if (false && !BLState->DEBUG_IgnoreWeatherDimmingLeds) { for (u32 i = 0; i < State->LedSystem.BuffersCount; i++) { diff --git a/src/app/ss_blumen_lumen/blumen_lumen_settings.h b/src/app/ss_blumen_lumen/blumen_lumen_settings.h index c8d44c1..7784fc0 100644 --- a/src/app/ss_blumen_lumen/blumen_lumen_settings.h +++ b/src/app/ss_blumen_lumen/blumen_lumen_settings.h @@ -57,7 +57,7 @@ global time_range LedOnTimes[] = { { 00, 00, 06, 30 }, }; global u32 LedOnTimesCount = CArrayLength(LedOnTimes); // do not edit -global b8 DEBUGIgnoreLedOnTimeRange = true; +global b8 DEBUGIgnoreLedOnTimeRange = false; // How long it takes to fade from the default pattern to the // voice activated pattern diff --git a/src/sculpture_gen/gen_blumen_lumen.cpp b/src/sculpture_gen/gen_blumen_lumen.cpp index 63ad60c..9edceb6 100644 --- a/src/sculpture_gen/gen_blumen_lumen.cpp +++ b/src/sculpture_gen/gen_blumen_lumen.cpp @@ -22,163 +22,163 @@ global log_buffer* GlobalLogBuffer; typedef struct { - v3 CenterStart; - v3 CenterEnd; - r32 Radius; - u32 SegmentsCount; - u32 SubsegmentsCount; - u32 SubsegmentLeds; - - // SACN - u32 SACNUniverseStart; - u32 SACNChannelStart; - - // UART - // Only one of these two values is needed. - // If ChannelsArray != 0, then it will be used, and assumed to - // have SegmentsCount values - // Otherwise, each segment will increment from ChannelStart - u32 ChannelStart; - u32* ChannelsArray; - - char* ComPort; - char* SectionTagValue; - char* FlowerTagValue; + v3 CenterStart; + v3 CenterEnd; + r32 Radius; + u32 SegmentsCount; + u32 SubsegmentsCount; + u32 SubsegmentLeds; + + // SACN + u32 SACNUniverseStart; + u32 SACNChannelStart; + + // UART + // Only one of these two values is needed. + // If ChannelsArray != 0, then it will be used, and assumed to + // have SegmentsCount values + // Otherwise, each segment will increment from ChannelStart + u32 ChannelStart; + u32* ChannelsArray; + + char* ComPort; + char* SectionTagValue; + char* FlowerTagValue; } loop_desc; internal void BuildLoop(gs_string* OutputBuffer, loop_desc Desc) { - r32 SegmentsArc = TauR32 / Desc.SegmentsCount; - r32 SubsegmentsArc = SegmentsArc / Desc.SubsegmentsCount; - - for (u32 i = 0; i < Desc.SegmentsCount; i++) - { - r32 ArcBase = SegmentsArc * i; + r32 SegmentsArc = TauR32 / Desc.SegmentsCount; + r32 SubsegmentsArc = SegmentsArc / Desc.SubsegmentsCount; - u32 Channel = 0; - if (Desc.ChannelsArray != 0) + for (u32 i = 0; i < Desc.SegmentsCount; i++) { - Channel = Desc.ChannelsArray[i]; - } - else - { - Channel = Desc.ChannelStart + i; + r32 ArcBase = SegmentsArc * i; + + u32 Channel = 0; + if (Desc.ChannelsArray != 0) + { + Channel = Desc.ChannelsArray[i]; + } + else + { + Channel = Desc.ChannelStart + i; + } + + WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort, + Desc.SACNUniverseStart, Desc.SACNChannelStart); + WriteSegmentSequenceOpen(OutputBuffer, Desc.SubsegmentsCount); + + for (u32 j = 0; j < Desc.SubsegmentsCount; j++) + { + r32 Arc = ArcBase + (SubsegmentsArc * j); + v3 Offset = v3{ SinR32(Arc), 0, CosR32(Arc) } * Desc.Radius; + v3 P0 = Desc.CenterStart + Offset; + v3 P1 = Desc.CenterEnd + Offset; + + // Swap directions on the middle strip + if (j%2 != 0) + { + v3 Temp = P0; + P0 = P1; + P1 = Temp; + } + + WriteSegmentSequenceSegment(OutputBuffer, P0, P1, Desc.SubsegmentLeds); + } + + WriteSegmentSequenceClose(OutputBuffer); + WriteSegmentTagsOpen(OutputBuffer, 2); + WriteSegmentTag(OutputBuffer, "section", Desc.SectionTagValue); + WriteSegmentTag(OutputBuffer, "flower", Desc.FlowerTagValue); + WriteSegmentTagsClose(OutputBuffer); + WriteLedStripClose(OutputBuffer); } - WriteLedStripOpen(OutputBuffer, Channel, Desc.ComPort, - Desc.SACNUniverseStart, Desc.SACNChannelStart); - WriteSegmentSequenceOpen(OutputBuffer, Desc.SubsegmentsCount); - - for (u32 j = 0; j < Desc.SubsegmentsCount; j++) - { - r32 Arc = ArcBase + (SubsegmentsArc * j); - v3 Offset = v3{ SinR32(Arc), 0, CosR32(Arc) } * Desc.Radius; - v3 P0 = Desc.CenterStart + Offset; - v3 P1 = Desc.CenterEnd + Offset; - - // Swap directions on the middle strip - if (j%2 != 0) - { - v3 Temp = P0; - P0 = P1; - P1 = Temp; - } - - WriteSegmentSequenceSegment(OutputBuffer, P0, P1, Desc.SubsegmentLeds); - } - - WriteSegmentSequenceClose(OutputBuffer); - WriteSegmentTagsOpen(OutputBuffer, 2); - WriteSegmentTag(OutputBuffer, "section", Desc.SectionTagValue); - WriteSegmentTag(OutputBuffer, "flower", Desc.FlowerTagValue); - WriteSegmentTagsClose(OutputBuffer); - WriteLedStripClose(OutputBuffer); - } - } typedef struct { - v3 Pos; - char* ComPort; - char* FlowerTagValue; - - // SACN - u32 SACNStemInnerStartUniverse; - u32 SACNStemOuterStartUniverse; - u32 SACNFlowerStemStartUniverse; - - // UART - u32* StemChannels; - u32* BloomOuterChannels; - u32* BloomInnerChannels; + v3 Pos; + char* ComPort; + char* FlowerTagValue; + + // SACN + u32 SACNStemInnerStartUniverse; + u32 SACNStemOuterStartUniverse; + u32 SACNFlowerStemStartUniverse; + + // UART + u32* StemChannels; + u32* BloomOuterChannels; + u32* BloomInnerChannels; } flower_desc; internal u32 BuildFlower(gs_string* OutputBuffer, flower_desc Desc) { - + #if 1 - // the bloom stem inner - loop_desc BloomStemInner = {}; - BloomStemInner.CenterStart = v3{0, 1.4f, 0}; - BloomStemInner.CenterEnd = v3{0, .9f, 0}; - BloomStemInner.Radius = .05f; - //BloomStemInner.SegmentsCount = 6; - BloomStemInner.SegmentsCount = 1; - BloomStemInner.SubsegmentsCount = 3; - BloomStemInner.SubsegmentLeds = 35; - BloomStemInner.SACNUniverseStart = Desc.SACNStemInnerStartUniverse; - BloomStemInner.SACNChannelStart = 1; - BloomStemInner.ChannelsArray = Desc.BloomInnerChannels; - BloomStemInner.ComPort = Desc.ComPort; - BloomStemInner.SectionTagValue = "inner_bloom"; - BloomStemInner.FlowerTagValue = Desc.FlowerTagValue; - BuildLoop(OutputBuffer, BloomStemInner); - - // the bloom stem outer - loop_desc BloomStemOuter = {}; - BloomStemOuter.CenterStart = v3{0, .5f, 0}; - BloomStemOuter.CenterEnd = v3{0, .9f, 0}; - BloomStemOuter.Radius = .07f; - //BloomStemOuter.SegmentsCount = 9; - BloomStemOuter.SegmentsCount = 1; - BloomStemOuter.SubsegmentsCount = 3; - BloomStemOuter.SubsegmentLeds = 41; - BloomStemOuter.SACNUniverseStart = Desc.SACNStemOuterStartUniverse; - BloomStemOuter.SACNChannelStart = 1; - BloomStemOuter.ChannelsArray = Desc.BloomOuterChannels; - BloomStemOuter.ComPort = Desc.ComPort; - BloomStemOuter.SectionTagValue = "outer_bloom"; - BloomStemOuter.FlowerTagValue = Desc.FlowerTagValue; - BuildLoop(OutputBuffer, BloomStemOuter); + // the bloom stem inner + loop_desc BloomStemInner = {}; + BloomStemInner.CenterStart = v3{0, 1.4f, 0}; + BloomStemInner.CenterEnd = v3{0, .9f, 0}; + BloomStemInner.Radius = .05f; + //BloomStemInner.SegmentsCount = 6; + BloomStemInner.SegmentsCount = 1; + BloomStemInner.SubsegmentsCount = 3; + BloomStemInner.SubsegmentLeds = 35; + BloomStemInner.SACNUniverseStart = Desc.SACNStemInnerStartUniverse; + BloomStemInner.SACNChannelStart = 1; + BloomStemInner.ChannelsArray = Desc.BloomInnerChannels; + BloomStemInner.ComPort = Desc.ComPort; + BloomStemInner.SectionTagValue = "inner_bloom"; + BloomStemInner.FlowerTagValue = Desc.FlowerTagValue; + BuildLoop(OutputBuffer, BloomStemInner); + + // the bloom stem outer + loop_desc BloomStemOuter = {}; + BloomStemOuter.CenterStart = v3{0, .5f, 0}; + BloomStemOuter.CenterEnd = v3{0, .9f, 0}; + BloomStemOuter.Radius = .07f; + //BloomStemOuter.SegmentsCount = 9; + BloomStemOuter.SegmentsCount = 1; + BloomStemOuter.SubsegmentsCount = 3; + BloomStemOuter.SubsegmentLeds = 41; + BloomStemOuter.SACNUniverseStart = Desc.SACNStemOuterStartUniverse; + BloomStemOuter.SACNChannelStart = 1; + BloomStemOuter.ChannelsArray = Desc.BloomOuterChannels; + BloomStemOuter.ComPort = Desc.ComPort; + BloomStemOuter.SectionTagValue = "outer_bloom"; + BloomStemOuter.FlowerTagValue = Desc.FlowerTagValue; + BuildLoop(OutputBuffer, BloomStemOuter); #endif - + #if 1 - // the flower stem - loop_desc FlowerStem = {}; - FlowerStem.CenterStart = v3{0, -1.5f, 0}; - FlowerStem.CenterEnd = v3{0, .5f, 0}; - FlowerStem.Radius = .05f; - //FlowerStem.SegmentsCount = 6; - FlowerStem.SegmentsCount = 1; - FlowerStem.SubsegmentsCount = 1; - FlowerStem.SubsegmentLeds = 300; - FlowerStem.SACNUniverseStart = Desc.SACNFlowerStemStartUniverse; - FlowerStem.SACNChannelStart = 1; - FlowerStem.ChannelsArray = Desc.StemChannels; - FlowerStem.ComPort = Desc.ComPort; - FlowerStem.SectionTagValue = "stem"; - FlowerStem.FlowerTagValue = Desc.FlowerTagValue; - BuildLoop(OutputBuffer, FlowerStem); + // the flower stem + loop_desc FlowerStem = {}; + FlowerStem.CenterStart = v3{0, .5f, 0}; + FlowerStem.CenterEnd = v3{0, -1.5f, 0}; + FlowerStem.Radius = .05f; + //FlowerStem.SegmentsCount = 6; + FlowerStem.SegmentsCount = 1; + FlowerStem.SubsegmentsCount = 1; + FlowerStem.SubsegmentLeds = 300; + FlowerStem.SACNUniverseStart = Desc.SACNFlowerStemStartUniverse; + FlowerStem.SACNChannelStart = 1; + FlowerStem.ChannelsArray = Desc.StemChannels; + FlowerStem.ComPort = Desc.ComPort; + FlowerStem.SectionTagValue = "stem"; + FlowerStem.FlowerTagValue = Desc.FlowerTagValue; + BuildLoop(OutputBuffer, FlowerStem); #endif - - u32 StripsCount = BloomStemInner.SegmentsCount; - StripsCount += BloomStemOuter.SegmentsCount; - StripsCount += FlowerStem.SegmentsCount; - - return StripsCount; + + u32 StripsCount = BloomStemInner.SegmentsCount; + StripsCount += BloomStemOuter.SegmentsCount; + StripsCount += FlowerStem.SegmentsCount; + + return StripsCount; } // Just for brevity, no real function provided @@ -186,116 +186,116 @@ BuildFlower(gs_string* OutputBuffer, flower_desc Desc) internal u8 FlowerStripToChannel(u8 Flower, u8 Channel) { - Assert(Flower < 3); - Assert(Channel < 8); - - u8 Result = 0; - Result |= (Flower & 0x03) << 3; - Result |= (Channel & 0x07); - - return Result; + Assert(Flower < 3); + Assert(Channel < 8); + + u8 Result = 0; + Result |= (Flower & 0x03) << 3; + Result |= (Channel & 0x07); + + return Result; } int main(int ArgCount, char** Args) { - gs_thread_context Ctx = Win32CreateThreadContext(); - GlobalLogBuffer = PushStruct(Ctx.Transient, log_buffer); - *GlobalLogBuffer = Log_Init(Ctx.Transient, 32); - - gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4)); - gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4)); - gs_string OutputBuffer2 = PushString(Ctx.Transient, MB(4)); - - u32 StripCount = 3; // used to be 21 + gs_thread_context Ctx = Win32CreateThreadContext(); + GlobalLogBuffer = PushStruct(Ctx.Transient, log_buffer); + *GlobalLogBuffer = Log_Init(Ctx.Transient, 32); + + gs_string OutputBuffer0 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer1 = PushString(Ctx.Transient, MB(4)); + gs_string OutputBuffer2 = PushString(Ctx.Transient, MB(4)); + + u32 StripCount = 3; // used to be 21 #if 0 - WriteAssemblyUARTOpen(&OutputBuffer0, - "Blumen Lumen - Silver Spring - 00", - 100, - v3{-1, 0, 0}, - StripCount, - ""); - WriteAssemblyUARTOpen(&OutputBuffer1, - "Blumen Lumen - Silver Spring - 01", - 100, - v3{0, 0, 0}, - StripCount, - ""); - WriteAssemblyUARTOpen(&OutputBuffer2, - "Blumen Lumen - Silver Spring - 02", - 100, - v3{1, 0, 0}, - StripCount, - ""); + WriteAssemblyUARTOpen(&OutputBuffer0, + "Blumen Lumen - Silver Spring - 00", + 100, + v3{-1, 0, 0}, + StripCount, + ""); + WriteAssemblyUARTOpen(&OutputBuffer1, + "Blumen Lumen - Silver Spring - 01", + 100, + v3{0, 0, 0}, + StripCount, + ""); + WriteAssemblyUARTOpen(&OutputBuffer2, + "Blumen Lumen - Silver Spring - 02", + 100, + v3{1, 0, 0}, + StripCount, + ""); #else - WriteAssemblySACNOpen(&OutputBuffer0, - "Blumen Lumen - Silver Spring - 00", - 100, - v3{-1, 0, 0}, - StripCount); - WriteAssemblySACNOpen(&OutputBuffer1, - "Blumen Lumen - Silver Spring - 01", - 100, - v3{0, 0, 0}, - StripCount); - WriteAssemblySACNOpen(&OutputBuffer2, - "Blumen Lumen - Silver Spring - 02", - 100, - v3{1, 0, 0}, - StripCount); + WriteAssemblySACNOpen(&OutputBuffer0, + "Blumen Lumen - Silver Spring - 00", + 100, + v3{-1, 0, 0}, + StripCount); + WriteAssemblySACNOpen(&OutputBuffer1, + "Blumen Lumen - Silver Spring - 01", + 100, + v3{0, 0, 0}, + StripCount); + WriteAssemblySACNOpen(&OutputBuffer2, + "Blumen Lumen - Silver Spring - 02", + 100, + v3{1, 0, 0}, + StripCount); #endif - - u32 StripCountOut = 0; - - u32 StemChannels[] = { FSC(2, 1), FSC(2, 2), FSC(2, 3), FSC(2, 4), FSC(2, 5), FSC(2, 6) }; - u32 BloomOuterChannels[] = { FSC(1, 0), FSC(1, 1), FSC(1, 2), FSC(1, 3), FSC(1, 4), FSC(1, 5), FSC(1, 6), FSC(1, 7), FSC(2, 0) }; - u32 BloomInnerChannels[] = { FSC(0, 0), FSC(0, 1), FSC(0, 2), FSC(0, 3), FSC(0, 4), FSC(0, 5) }; - flower_desc F0 = {}; - F0.Pos = v3{0, 0, 0}; - F0.ComPort = "\\\\.\\COM11"; - F0.FlowerTagValue = "left"; - F0.SACNStemInnerStartUniverse = 4; - F0.SACNStemOuterStartUniverse = 3; - F0.SACNFlowerStemStartUniverse = 1; - F0.StemChannels = StemChannels; - F0.BloomOuterChannels = BloomOuterChannels; - F0.BloomInnerChannels = BloomInnerChannels; - StripCountOut += BuildFlower(&OutputBuffer0, F0); - - flower_desc F1 = {}; - F1.Pos = v3{0, 0, 0}; - F1.ComPort = "\\\\.\\COM12"; - F1.FlowerTagValue = "center"; - F1.SACNStemInnerStartUniverse = 9; - F1.SACNStemOuterStartUniverse = 8; - F1.SACNFlowerStemStartUniverse = 6; - F1.StemChannels = StemChannels; - F1.BloomInnerChannels = BloomInnerChannels; - F1.BloomOuterChannels = BloomOuterChannels; - StripCountOut += BuildFlower(&OutputBuffer1, F1); - - flower_desc F2 = {}; - F2.Pos = v3{0, 0, 0}; - F2.ComPort = "\\\\.\\COM6"; - F2.FlowerTagValue = "right"; - F2.SACNStemInnerStartUniverse = 14; - F2.SACNStemOuterStartUniverse = 13; - F2.SACNFlowerStemStartUniverse = 11; - F2.StemChannels = StemChannels; - F2.BloomInnerChannels = BloomInnerChannels; - F2.BloomOuterChannels = BloomOuterChannels; - StripCountOut += BuildFlower(&OutputBuffer2, F2); - - WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_one.fold"), StringToData(OutputBuffer0)); - WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_two.fold"), StringToData(OutputBuffer1)); - WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_three.fold"), StringToData(OutputBuffer2)); - - //printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); - //printf("%d\n", StripCount); - - - - - return 0; + + u32 StripCountOut = 0; + + u32 StemChannels[] = { FSC(2, 1), FSC(2, 2), FSC(2, 3), FSC(2, 4), FSC(2, 5), FSC(2, 6) }; + u32 BloomOuterChannels[] = { FSC(1, 0), FSC(1, 1), FSC(1, 2), FSC(1, 3), FSC(1, 4), FSC(1, 5), FSC(1, 6), FSC(1, 7), FSC(2, 0) }; + u32 BloomInnerChannels[] = { FSC(0, 0), FSC(0, 1), FSC(0, 2), FSC(0, 3), FSC(0, 4), FSC(0, 5) }; + flower_desc F0 = {}; + F0.Pos = v3{0, 0, 0}; + F0.ComPort = "\\\\.\\COM11"; + F0.FlowerTagValue = "left"; + F0.SACNStemInnerStartUniverse = 4; + F0.SACNStemOuterStartUniverse = 3; + F0.SACNFlowerStemStartUniverse = 1; + F0.StemChannels = StemChannels; + F0.BloomOuterChannels = BloomOuterChannels; + F0.BloomInnerChannels = BloomInnerChannels; + StripCountOut += BuildFlower(&OutputBuffer0, F0); + + flower_desc F1 = {}; + F1.Pos = v3{0, 0, 0}; + F1.ComPort = "\\\\.\\COM12"; + F1.FlowerTagValue = "center"; + F1.SACNStemInnerStartUniverse = 9; + F1.SACNStemOuterStartUniverse = 8; + F1.SACNFlowerStemStartUniverse = 6; + F1.StemChannels = StemChannels; + F1.BloomInnerChannels = BloomInnerChannels; + F1.BloomOuterChannels = BloomOuterChannels; + StripCountOut += BuildFlower(&OutputBuffer1, F1); + + flower_desc F2 = {}; + F2.Pos = v3{0, 0, 0}; + F2.ComPort = "\\\\.\\COM6"; + F2.FlowerTagValue = "right"; + F2.SACNStemInnerStartUniverse = 14; + F2.SACNStemOuterStartUniverse = 13; + F2.SACNFlowerStemStartUniverse = 11; + F2.StemChannels = StemChannels; + F2.BloomInnerChannels = BloomInnerChannels; + F2.BloomOuterChannels = BloomOuterChannels; + StripCountOut += BuildFlower(&OutputBuffer2, F2); + + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_one.fold"), StringToData(OutputBuffer0)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_two.fold"), StringToData(OutputBuffer1)); + WriteEntireFile(Ctx.FileHandler, ConstString("data/ss_blumen_three.fold"), StringToData(OutputBuffer2)); + + //printf("%.*s\n", (u32)OutputBuffer.Length, OutputBuffer.Str); + //printf("%d\n", StripCount); + + + + + return 0; }