Fixing line directive codegen for ifs, handling vkey codes
This commit is contained in:
@@ -572,7 +572,7 @@ gen_ast(Ast *ast){
|
|||||||
|
|
||||||
CASE(IF, If){
|
CASE(IF, If){
|
||||||
For(node->ifs){
|
For(node->ifs){
|
||||||
gen_line(node);
|
gen_line(it);
|
||||||
genln("");
|
genln("");
|
||||||
if(it->init) {
|
if(it->init) {
|
||||||
gen_expr(it->init);
|
gen_expr(it->init);
|
||||||
@@ -586,7 +586,7 @@ gen_ast(Ast *ast){
|
|||||||
gen_stmt_scope(it->scope);
|
gen_stmt_scope(it->scope);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
genln("else");
|
gen("else");
|
||||||
if(it->expr){
|
if(it->expr){
|
||||||
gen(" if(");
|
gen(" if(");
|
||||||
gen_expr(it->expr);
|
gen_expr(it->expr);
|
||||||
@@ -788,6 +788,7 @@ compile_to_c_code(){
|
|||||||
#define CORE_Assert(x) do{if(!(x))__debugbreak();}while(0)
|
#define CORE_Assert(x) do{if(!(x))__debugbreak();}while(0)
|
||||||
#define CORE_AssertMessage(x,...) CORE_Assert(x)
|
#define CORE_AssertMessage(x,...) CORE_Assert(x)
|
||||||
#define CORE_BufferSize(x) (sizeof(x)/sizeof((x)[0]))
|
#define CORE_BufferSize(x) (sizeof(x)/sizeof((x)[0]))
|
||||||
|
|
||||||
typedef struct String{
|
typedef struct String{
|
||||||
uint8_t *str;
|
uint8_t *str;
|
||||||
int64_t len;
|
int64_t len;
|
||||||
@@ -863,6 +864,7 @@ CORE_MemoryCopy(void *dst, void *src, size_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
genln("");
|
genln("");
|
||||||
|
|
||||||
gen_lambda(it.item[0]->unique_name, it.item[0]->lambda, false);
|
gen_lambda(it.item[0]->unique_name, it.item[0]->lambda, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,5 @@
|
|||||||
WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int
|
WinMain :: (hInstance: HINSTANCE, hPrevInstance: HINSTANCE, lpCmdLine: LPSTR, nShowCmd: int): int
|
||||||
StartMultimedia(title = "Hello, people!")
|
StartMultimedia(title = "Hello, people!")
|
||||||
for UpdateMultimedia()
|
for UpdateMultimedia()
|
||||||
pass
|
if Mu.key[Key.Escape].is_down
|
||||||
|
Mu.quit = true
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#import "Base.core"
|
#import "Base.core"
|
||||||
#import "MathVec3.core"
|
#import "Math.core"
|
||||||
#import "Arena.core"
|
#import "Arena.core"
|
||||||
W32 :: #load "win32_multimedia.core"
|
W32 :: #load "win32_multimedia.core"
|
||||||
|
|
||||||
@@ -16,13 +16,13 @@ MU :: struct
|
|||||||
|
|
||||||
key: [Key.Count]KeyState
|
key: [Key.Count]KeyState
|
||||||
frame_count: U64
|
frame_count: U64
|
||||||
time: MuTime
|
time: MUTime
|
||||||
quit: Bool
|
quit: Bool
|
||||||
|
|
||||||
frame_arena: Arena
|
frame_arena: Arena
|
||||||
os: W32.OS
|
os: W32.OS
|
||||||
|
|
||||||
MuTime :: struct
|
MUTime :: struct
|
||||||
total : F64
|
total : F64
|
||||||
delta : F64 // @modifiable
|
delta : F64 // @modifiable
|
||||||
start : F64
|
start : F64
|
||||||
|
|||||||
@@ -137,6 +137,11 @@ StartMultimedia :: (x: S64 = 1280, y: S64 = 720, title: String = "Hello people!"
|
|||||||
Mu.y = Mu.os.bitmap.size.y
|
Mu.y = Mu.os.bitmap.size.y
|
||||||
|
|
||||||
UpdateMultimedia :: (): Bool
|
UpdateMultimedia :: (): Bool
|
||||||
|
msg: MSG
|
||||||
|
for PeekMessageW(&msg, Mu.os.window, 0, 0, PM_REMOVE) == 1
|
||||||
|
TranslateMessage(&msg)
|
||||||
|
DispatchMessageW(&msg)
|
||||||
|
|
||||||
Mu.frame_count += 1
|
Mu.frame_count += 1
|
||||||
frame_time := Time() - Mu.time.frame_start
|
frame_time := Time() - Mu.time.frame_start
|
||||||
Mu.time.total += frame_time
|
Mu.time.total += frame_time
|
||||||
@@ -156,18 +161,21 @@ UpdateMultimedia :: (): Bool
|
|||||||
return !Mu.quit
|
return !Mu.quit
|
||||||
|
|
||||||
WindowProc :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
WindowProc :: (hwnd: HWND, msg: UINT, wparam: WPARAM, lparam: LPARAM): LRESULT
|
||||||
|
result: LRESULT
|
||||||
if msg == WM_DESTROY
|
if msg == WM_DESTROY
|
||||||
PostQuitMessage(0)
|
PostQuitMessage(0)
|
||||||
return 0
|
return 0
|
||||||
elif msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN
|
elif msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN
|
||||||
key := MapVKToKey(msg)
|
key := MapVKToKey(wparam)
|
||||||
Mu.key[key].is_down = true
|
Mu.key[key].is_down = true
|
||||||
elif msg == WM_KEYUP || msg == WM_SYSKEYUP
|
elif msg == WM_KEYUP || msg == WM_SYSKEYUP
|
||||||
key := MapVKToKey(msg)
|
key := MapVKToKey(wparam)
|
||||||
Mu.key[key].is_down = false
|
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:
|
for val,map in mapping:
|
||||||
print(f" {el}if vk == {map} ;; return Key.{val}")
|
print(f" {el}if vk == {map} ;; return Key.{val}")
|
||||||
el = "el"
|
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
|
if vk == VK_UP ;; return Key.Up
|
||||||
elif vk == VK_DOWN ;; return Key.Down
|
elif vk == VK_DOWN ;; return Key.Down
|
||||||
elif vk == VK_LEFT ;; return Key.Left
|
elif vk == VK_LEFT ;; return Key.Left
|
||||||
@@ -305,5 +313,5 @@ MapVKToKey :: (vk: U32): Key
|
|||||||
elif vk == '7' ;; return Key.K7
|
elif vk == '7' ;; return Key.K7
|
||||||
elif vk == '8' ;; return Key.K8
|
elif vk == '8' ;; return Key.K8
|
||||||
elif vk == '9' ;; return Key.K9
|
elif vk == '9' ;; return Key.K9
|
||||||
Assert(false, "Unidentified Virtual Key")
|
return Key.Nil
|
||||||
/*END*/
|
/*END*/
|
||||||
Reference in New Issue
Block a user