diff --git a/core_codegen_c_language.cpp b/core_codegen_c_language.cpp index 98d9bbc..594db68 100644 --- a/core_codegen_c_language.cpp +++ b/core_codegen_c_language.cpp @@ -572,7 +572,7 @@ gen_ast(Ast *ast){ CASE(IF, If){ For(node->ifs){ - gen_line(node); + gen_line(it); genln(""); if(it->init) { gen_expr(it->init); @@ -586,7 +586,7 @@ gen_ast(Ast *ast){ gen_stmt_scope(it->scope); } else{ - genln("else"); + gen("else"); if(it->expr){ gen(" if("); gen_expr(it->expr); @@ -788,6 +788,7 @@ compile_to_c_code(){ #define CORE_Assert(x) do{if(!(x))__debugbreak();}while(0) #define CORE_AssertMessage(x,...) CORE_Assert(x) #define CORE_BufferSize(x) (sizeof(x)/sizeof((x)[0])) + typedef struct String{ uint8_t *str; int64_t len; @@ -863,6 +864,7 @@ CORE_MemoryCopy(void *dst, void *src, size_t size){ } genln(""); + gen_lambda(it.item[0]->unique_name, it.item[0]->lambda, false); } } diff --git a/examples/using_multimedia.core b/examples/using_multimedia.core index 4be041b..ea5c83c 100644 --- a/examples/using_multimedia.core +++ b/examples/using_multimedia.core @@ -3,4 +3,5 @@ WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int StartMultimedia(title = "Hello, people!") for UpdateMultimedia() - pass \ No newline at end of file + if Mu.key[Key.Escape].is_down + Mu.quit = true \ No newline at end of file diff --git a/modules/Multimedia.core b/modules/Multimedia.core index 0d342f5..c38bd33 100644 --- a/modules/Multimedia.core +++ b/modules/Multimedia.core @@ -1,5 +1,5 @@ #import "Base.core" -#import "MathVec3.core" +#import "Math.core" #import "Arena.core" W32 :: #load "win32_multimedia.core" @@ -16,13 +16,13 @@ MU :: struct key: [Key.Count]KeyState frame_count: U64 - time: MuTime + time: MUTime quit: Bool frame_arena: Arena os: W32.OS -MuTime :: struct +MUTime :: struct total : F64 delta : F64 // @modifiable start : F64 diff --git a/modules/win32_multimedia.core b/modules/win32_multimedia.core index 045501f..036d302 100644 --- a/modules/win32_multimedia.core +++ b/modules/win32_multimedia.core @@ -137,6 +137,11 @@ StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!" Mu.y = Mu.os.bitmap.size.y UpdateMultimedia :: (): Bool + msg: MSG + for PeekMessageW(&msg, Mu.os.window, 0, 0, PM_REMOVE) == 1 + TranslateMessage(&msg) + DispatchMessageW(&msg) + Mu.frame_count += 1 frame_time := Time() - Mu.time.frame_start Mu.time.total += frame_time @@ -156,18 +161,21 @@ UpdateMultimedia :: (): Bool return !Mu.quit WindowProc :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT + result: LRESULT if msg == WM_DESTROY PostQuitMessage(0) return 0 elif msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN - key := MapVKToKey(msg) + key := MapVKToKey(wparam) Mu.key[key].is_down = true elif msg == WM_KEYUP || msg == WM_SYSKEYUP - key := MapVKToKey(msg) + key := MapVKToKey(wparam) Mu.key[key].is_down = false - else;; return DefWindowProcW(hwnd, msg, wparam, lparam) + else;; result = DefWindowProcW(hwnd, msg, wparam, lparam) + + return result /*# @@ -244,9 +252,9 @@ el = "" for val,map in mapping: print(f" {el}if vk == {map} ;; return Key.{val}") el = "el" -print(" Assert(false, \"Unidentified Virtual Key\")") +print(" return Key.None") */ -MapVKToKey :: (vk: U32): Key +MapVKToKey :: (vk: WPARAM): Key if vk == VK_UP ;; return Key.Up elif vk == VK_DOWN ;; return Key.Down elif vk == VK_LEFT ;; return Key.Left @@ -305,5 +313,5 @@ MapVKToKey :: (vk: U32): Key elif vk == '7' ;; return Key.K7 elif vk == '8' ;; return Key.K8 elif vk == '9' ;; return Key.K9 - Assert(false, "Unidentified Virtual Key") + return Key.Nil /*END*/ \ No newline at end of file