diff --git a/README.md b/README.md index f864cbc..befd434 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,8 @@ vendor - microui (temp) - box3d? - build.sh -> bootstrap shim for `compile/build.odin` +- stb +- kb (https://github.com/JimmyLefevre/kb) ## Hot Reload diff --git a/game/game.odin b/game/game.odin index cd9bb15..821dc39 100644 --- a/game/game.odin +++ b/game/game.odin @@ -25,15 +25,16 @@ g: Game_Memory t: Test_Memory game_api := core.Game_API { - settings = settings, - init_once = init_once, - init = init, - update = update, - render = render, - destroy = destroy, - should_close = should_close, - force_reload = force_reload, - force_restart = force_restart, + settings = settings, + register_memory = register_memory, + init_once = init_once, + init = init, + update = update, + render = render, + destroy = destroy, + should_close = should_close, + force_reload = force_reload, + force_restart = force_restart, } // ----------------------------------------- @@ -54,13 +55,15 @@ settings :: proc() -> base.Settings { } } -init_once :: proc() { - fmt.println("init once") - +register_memory :: proc() { base.register_region("game_memory", &g, size_of(Game_Memory)) base.register_region("test_memory", &t, size_of(Test_Memory)) } +init_once :: proc() { + fmt.println("init once") +} + init :: proc() { fmt.println("hello from .dll!") diff --git a/odinfmt.json b/odinfmt.json index ff28670..68a0383 100644 --- a/odinfmt.json +++ b/odinfmt.json @@ -1,11 +1,13 @@ { "$schema": "https://raw.githubusercontent.com/DanielGavin/ols/master/misc/odinfmt.schema.json", + "align_comments": true, "align_struct_fields": true, "align_struct_values": true, "character_width": 80, "indent_cases": true, "newline_limit": 1, "newline_style": "LF", + "preserve_struct_blank_lines": true, "sort_imports": true, "space_single_line_blocks": true, "tabs": true, diff --git a/src/base/hot_reload.odin b/src/base/hot_reload.odin index 4fff699..6c4f7d0 100644 --- a/src/base/hot_reload.odin +++ b/src/base/hot_reload.odin @@ -145,13 +145,14 @@ register_region :: proc( return nil } -read_snapshot :: proc() -> os.Error { +// returns `fresh` = `true` when booting without a snapshot +read_snapshot :: proc() -> (fresh: bool, err: os.Error) { assert(hr.region_headers != nil, "[hot-reload] uninitialized") assert(hr.regions != nil, "[hot-reload] uninitialized") if !os.exists(hr.snapshot_path) { hr.write_full_snapshot = true - return nil + return true, nil } snapshot := os.open(hr.snapshot_path, {.Read}) or_return @@ -220,7 +221,7 @@ read_snapshot :: proc() -> os.Error { copy(dest, data_bytes) } - return nil + return false, nil } // Next write will be a full memory snapshot diff --git a/src/core/api.odin b/src/core/api.odin index e35c40c..99a986f 100644 --- a/src/core/api.odin +++ b/src/core/api.odin @@ -6,13 +6,14 @@ import "sindri:base" // Types Game_API :: struct { - settings: proc() -> base.Settings, - init_once: proc(), - init: proc(), - update: proc(dt: f32), - render: proc(), - destroy: proc(), - should_close: proc() -> bool, - force_reload: proc() -> bool, - force_restart: proc() -> bool, + settings: proc() -> base.Settings, + register_memory: proc(), + init_once: proc(), + init: proc(), + update: proc(dt: f32), + render: proc(), + destroy: proc(), + should_close: proc() -> bool, + force_reload: proc() -> bool, + force_restart: proc() -> bool, } diff --git a/src/core/things.odin b/src/core/things.odin index 96ed969..8ce0498 100644 --- a/src/core/things.odin +++ b/src/core/things.odin @@ -43,6 +43,7 @@ Thing :: struct { Things :: struct { things: [THINGS_MAX]Thing, + // TODO: Collapse used and gen into 1 array used: [THINGS_MAX]bool, gen: [THINGS_MAX]u16, free_list: [THINGS_MAX]Thing_Idx, diff --git a/src/main.odin b/src/main.odin index 9dbea74..a3b04fd 100644 --- a/src/main.odin +++ b/src/main.odin @@ -49,9 +49,11 @@ main :: proc() { base.register_region("things", &things, size_of(core.Things)) - api.init_once() + api.register_memory() - base.read_snapshot() + fresh, err := base.read_snapshot() + fmt.assertf(err == nil, "[main] couldnt read snapshot", err) + if fresh do api.init_once() api.init()