From 905151abe911b49f34396c0827c30dd10c8ddb1a Mon Sep 17 00:00:00 2001 From: jacob Date: Thu, 10 Jul 2025 13:11:36 -0500 Subject: [PATCH] replace null, true, false with integers in code --- build.c | 54 +++++------ res/sh/material.hlsl | 2 +- src/arena.c | 8 +- src/arena.h | 4 +- src/ase.c | 22 ++--- src/asset_cache.c | 12 +-- src/bitbuff.c | 46 +++++----- src/bitbuff.h | 4 +- src/buddy.c | 24 ++--- src/buddy.h | 2 +- src/collider.c | 76 +++++++-------- src/common.h | 8 +- src/draw.c | 18 ++-- src/font.c | 10 +- src/gp_dx12.c | 196 +++++++++++++++++++-------------------- src/host.c | 46 +++++----- src/incbin.c | 4 +- src/json.c | 84 ++++++++--------- src/log.c | 2 +- src/log.h | 2 +- src/mixer.c | 12 +-- src/mixer.h | 2 +- src/mp3_mmf.c | 18 ++-- src/phys.c | 28 +++--- src/phys.h | 2 +- src/playback_wasapi.c | 26 +++--- src/prof_tracy.h | 8 +- src/resource.c | 16 ++-- src/settings.c | 24 ++--- src/sim.c | 50 +++++----- src/sim_ent.c | 28 +++--- src/sim_ent.h | 4 +- src/sim_step.c | 38 ++++---- src/snc.c | 12 +-- src/snc.h | 2 +- src/sock_win32.c | 44 ++++----- src/sound.c | 12 +-- src/space.c | 36 ++++---- src/sprite.c | 88 +++++++++--------- src/sprite.h | 4 +- src/string.c | 55 ++++++----- src/sys.h | 2 +- src/sys_win32.c | 208 +++++++++++++++++++++--------------------- src/tar.c | 6 +- src/ttf_dwrite.cpp | 22 ++--- src/user.c | 58 ++++++------ src/util.h | 4 +- 47 files changed, 712 insertions(+), 721 deletions(-) diff --git a/build.c b/build.c index 017de85c..dc412686 100644 --- a/build.c +++ b/build.c @@ -6,7 +6,7 @@ typedef struct StepList StepList; * Globals * ========================== */ -Bool force_rebuild = false; +Bool force_rebuild = 0; Arena perm = { 0 }; D_Store store = { 0 }; @@ -15,14 +15,14 @@ StepList *sl = { 0 }; /* Args */ String arg_outdir = Lit("build"); -Bool arg_msvc = false; -Bool arg_rtc = false; -Bool arg_asan = false; -Bool arg_crtlib = false; -Bool arg_debinfo = false; -Bool arg_developer = false; -Bool arg_profiling = false; -Bool arg_unoptimized = false; +Bool arg_msvc = 0; +Bool arg_rtc = 0; +Bool arg_asan = 0; +Bool arg_crtlib = 0; +Bool arg_debinfo = 0; +Bool arg_developer = 0; +Bool arg_profiling = 0; +Bool arg_unoptimized = 0; /* ========================== * * Util @@ -35,7 +35,7 @@ void Error(String msg) Bool IsDirty(D_Tag tag) { - Bool res = force_rebuild ? true : D_IsDirty(&store, &hist, tag); + Bool res = force_rebuild ? 1 : D_IsDirty(&store, &hist, tag); if (!res) { if (tag.kind == D_TagKind_File || tag.kind == D_TagKind_Dir) { res = !D_Exists(tag); @@ -47,13 +47,13 @@ Bool IsDirty(D_Tag tag) SH_CommandResult RunCommand(Arena *arena, String command) { - SH_CommandResult res = SH_RunCommandCaptureOutput(arena, command, true); + SH_CommandResult res = SH_RunCommandCaptureOutput(arena, command, 1); return res; } void KillRunningProcesses(void) { - SH_RunCommand(Lit("taskkill /im PowerPlay.exe /f /fi \"STATUS eq RUNNING\""), true); + SH_RunCommand(Lit("taskkill /im PowerPlay.exe /f /fi \"STATUS eq RUNNING\""), 1); } /* ========================== * @@ -350,15 +350,15 @@ void OnBuild(StringList cli_args) default: { if (StringEqual(arg, Lit("-O"))) arg_state = ArgState_OutputDir; - if (StringEqual(arg, Lit("-clang"))) arg_msvc = false; - if (StringEqual(arg, Lit("-msvc"))) arg_msvc = true; - if (StringEqual(arg, Lit("-rtc"))) arg_rtc = true; - if (StringEqual(arg, Lit("-asan"))) arg_asan = true; - if (StringEqual(arg, Lit("-crtlib"))) arg_crtlib = true; - if (StringEqual(arg, Lit("-debinfo"))) arg_debinfo = true; - if (StringEqual(arg, Lit("-developer"))) arg_developer = true; - if (StringEqual(arg, Lit("-profiling"))) arg_profiling = true; - if (StringEqual(arg, Lit("-unoptimized"))) arg_unoptimized = true; + if (StringEqual(arg, Lit("-clang"))) arg_msvc = 0; + if (StringEqual(arg, Lit("-msvc"))) arg_msvc = 1; + if (StringEqual(arg, Lit("-rtc"))) arg_rtc = 1; + if (StringEqual(arg, Lit("-asan"))) arg_asan = 1; + if (StringEqual(arg, Lit("-crtlib"))) arg_crtlib = 1; + if (StringEqual(arg, Lit("-debinfo"))) arg_debinfo = 1; + if (StringEqual(arg, Lit("-developer"))) arg_developer = 1; + if (StringEqual(arg, Lit("-profiling"))) arg_profiling = 1; + if (StringEqual(arg, Lit("-unoptimized"))) arg_unoptimized = 1; } break; } } @@ -625,7 +625,7 @@ void OnBuild(StringList cli_args) if (build_hash != old_build_hash) { SH_Print(Lit("Builder exe or build args have changed, forcing complete rebuild.\n")); - force_rebuild = true; + force_rebuild = 1; String data = StringFromStruct(&build_hash); D_ClearWrite(build_hash_file, data); } @@ -823,10 +823,10 @@ void OnBuild(StringList cli_args) D_TagList src_input_files = { 0 }; { D_Tag src_dir = D_TagFromPath(&perm, Lit("src"), D_TagKind_Dir); - D_TagList src_files = D_GetDirContents(&perm, src_dir, false); + D_TagList src_files = D_GetDirContents(&perm, src_dir, 0); for (D_TagListNode *n = src_files.first; n; n = n->next) { - Bool ignore = true; + Bool ignore = 1; D_Tag file = n->tag; String path = file.full_path; @@ -851,7 +851,7 @@ void OnBuild(StringList cli_args) StringEqual(name, Lit("ttf_dwrite.cpp"))); } } else { - ignore = false; + ignore = 0; } } @@ -948,7 +948,7 @@ void OnBuild(StringList cli_args) * Execute build steps * ========================== */ - Bool success = true; + Bool success = 1; I64 step_count = sl->count; if (step_count > 0) { KillRunningProcesses(); @@ -971,7 +971,7 @@ void OnBuild(StringList cli_args) if (s->res_status == StepStatus_Success) { SH_PrintF(Lit("[%F/%F] %F\n"), FmtI64(step_i), FmtI64(step_count), FmtStr(s->name)); } else if (s->res_status == StepStatus_Failure) { - success = false; + success = 0; SH_PrintF(Lit("[%F/%F] %F\n\n%F\n\n"), FmtI64(step_i), FmtI64(step_count), FmtStr(s->name), FmtStr(output)); } diff --git a/res/sh/material.hlsl b/res/sh/material.hlsl index 0d9e9aa3..a1cabed6 100644 --- a/res/sh/material.hlsl +++ b/res/sh/material.hlsl @@ -100,7 +100,7 @@ SH_ENTRY(ROOTSIG) struct ps_output ps(struct ps_input input) } else if (dist < half_thickness) { color_srgb = grid.line_srgb; } else { - bool checker = false; + bool checker = 0; uint cell_x = (uint)(abs(grid_pos.x) / spacing) + (grid_pos.x < 0); uint cell_y = (uint)(abs(grid_pos.y) / spacing) + (grid_pos.y < 0); if (cell_x % 2 == 0) { diff --git a/src/arena.c b/src/arena.c index a277cd0d..4f6bcc33 100644 --- a/src/arena.c +++ b/src/arena.c @@ -66,7 +66,7 @@ void *arena_push_bytes_no_zero(struct arena *arena, u64 size, u64 align) ASSERT(align > 0); ASSERT(!arena->readonly); - void *ptr = NULL; + void *ptr = 0; u8 *base = arena_base(arena); /* Check to avoid aligning when size = 0 */ @@ -121,14 +121,14 @@ void arena_copy_replace(struct arena *dst, struct arena *src) void arena_decommit_unused_blocks(struct arena *arena) { /* Not implemented */ - ASSERT(false); + ASSERT(0); (UNUSED)arena; } void arena_set_readonly(struct arena *arena) { #if RTC - arena->readonly = true; + arena->readonly = 1; #endif sys_memory_set_committed_readonly(arena, arena->committed + ARENA_HEADER_SIZE); } @@ -137,6 +137,6 @@ void arena_set_readwrite(struct arena *arena) { sys_memory_set_committed_readwrite(arena, arena->committed + ARENA_HEADER_SIZE); #if RTC - arena->readonly = false; + arena->readonly = 0; #endif } diff --git a/src/arena.h b/src/arena.h index 2ced94fd..118cafb4 100644 --- a/src/arena.h +++ b/src/arena.h @@ -85,7 +85,7 @@ INLINE void *arena_align(struct arena *arena, u64 align) } } else { /* 0 alignment */ - ASSERT(false); + ASSERT(0); return (void *)(arena_base(arena) + arena->pos); } } @@ -144,7 +144,7 @@ INLINE struct arena_temp _scratch_begin(struct arena *potential_conflict) STATIC_ASSERT(SYS_SCRATCH_ARENAS_PER_CTX == 2); /* Use `scratch_begin_no_conflict` if no conflicts are present */ - ASSERT(potential_conflict != NULL); + ASSERT(potential_conflict != 0); struct sys_scratch_ctx *ctx = sys_scratch_ctx_from_fiber_id(sys_current_fiber_id()); struct arena *scratch_arena = ctx->arenas[0]; diff --git a/src/ase.c b/src/ase.c index d0841a07..cc23731b 100644 --- a/src/ase.c +++ b/src/ase.c @@ -315,7 +315,7 @@ INTERNAL void inflate(u8 *dst, u8 *encoded) rep_count = 11 + consume_bits(&bb, 7); } else { /* Invalid len */ - ASSERT(false); + ASSERT(0); } while (rep_count--) { @@ -341,7 +341,7 @@ INTERNAL void inflate(u8 *dst, u8 *encoded) struct huffman lit_len_huffman = huffman_init(temp.arena, 15, lit_len_dist_table, hlit); struct huffman dist_huffman = huffman_init(temp.arena, 15, lit_len_dist_table + hlit, hdist); - while (true) { + while (1) { u32 lit_len = huffman_decode(&lit_len_huffman, &bb); if (lit_len <= 255) { *dst++ = lit_len & 0xFF; @@ -375,7 +375,7 @@ INTERNAL void inflate(u8 *dst, u8 *encoded) case BLOCK_TYPE_RESERVED: { /* TODO */ - ASSERT(false); + ASSERT(0); } break; } } @@ -588,10 +588,10 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri res.image.pixels = arena_push_array(arena, u32, image_width * image_height); u32 num_layers = 0; - struct layer *layer_head = NULL; + struct layer *layer_head = 0; - struct cel *cel_head = NULL; - struct cel *cel_tail = NULL; + struct cel *cel_head = 0; + struct cel *cel_tail = 0; /* Iterate frames */ u32 num_frames = 0; @@ -799,7 +799,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri abort: if (res.errors.count <= 0) { - res.success = true; + res.success = 1; } scratch_end(scratch); @@ -831,13 +831,13 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri make_image_dimensions_squareish(&ase_header, &frames_x, &frames_y, &image_width, &image_height); u32 num_frames = 0; - struct ase_frame *frame_head = NULL; + struct ase_frame *frame_head = 0; u32 num_spans = 0; - struct ase_span *span_head = NULL; + struct ase_span *span_head = 0; u32 num_slice_keys = 0; - struct ase_slice_key *slice_key_head = NULL; + struct ase_slice_key *slice_key_head = 0; /* Iterate frames */ for (u16 i = 0; i < ase_header.frames; ++i) { @@ -974,7 +974,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri res.slice_key_head = slice_key_head; if (res.errors.count <= 0) { - res.success = true; + res.success = 1; } return res; diff --git a/src/asset_cache.c b/src/asset_cache.c index 24d0580c..879e1ff8 100644 --- a/src/asset_cache.c +++ b/src/asset_cache.c @@ -70,7 +70,7 @@ INTERNAL struct asset *asset_cache_get_slot_locked(struct snc_lock *lock, struct (UNUSED)lock; u64 index = hash % countof(G.lookup); - while (true) { + while (1) { struct asset *slot = &G.lookup[index]; if (slot->hash) { /* Occupied */ @@ -100,13 +100,13 @@ u64 asset_cache_hash(struct string key) * * Returns existing asset entry or inserts a new one. * - * If is_first_touch (out parameter) is set to true, then the caller has + * If is_first_touch (out parameter) is set to 1, then the caller has * inserted the asset into the cache. * * */ struct asset *asset_cache_touch(struct string key, u64 hash, b32 *is_first_touch) { - struct asset *asset = NULL; + struct asset *asset = 0; /* Lookup */ { @@ -118,7 +118,7 @@ struct asset *asset_cache_touch(struct string key, u64 hash, b32 *is_first_touch /* Insert if not found */ if (asset->hash) { if (is_first_touch) { - *is_first_touch = false; + *is_first_touch = 0; } } else { struct snc_lock lock = snc_lock_e(&G.lookup_mutex); @@ -146,7 +146,7 @@ struct asset *asset_cache_touch(struct string key, u64 hash, b32 *is_first_touch }; snc_counter_add(&asset->counter, 1); if (is_first_touch) { - *is_first_touch = true; + *is_first_touch = 1; } ++G.num_assets; @@ -198,7 +198,7 @@ void *asset_cache_get_store_data(struct asset *asset) if (asset->status == ASSET_STATUS_READY) { return asset->store_data; } else { - return NULL; + return 0; } } diff --git a/src/bitbuff.c b/src/bitbuff.c index 5bcb6426..aabdad8a 100644 --- a/src/bitbuff.c +++ b/src/bitbuff.c @@ -91,7 +91,7 @@ struct bitbuff bitbuff_alloc(u64 arena_reserve) { struct bitbuff res = ZI; res.arena = arena_alloc(arena_reserve); - res.is_backed_by_arena = true; + res.is_backed_by_arena = 1; return res; } @@ -125,7 +125,7 @@ struct bitbuff_writer bw_from_bitbuff(struct bitbuff *bb) } res.cur_bit = 0; #if BITBUFF_DEBUG - res.debug_enabled = true; + res.debug_enabled = 1; #endif return res; } @@ -135,7 +135,7 @@ struct bitbuff_writer bw_from_bitbuff_no_debug(struct bitbuff *bb) { struct bitbuff_writer res = bw_from_bitbuff(bb); #if BITBUFF_DEBUG - res.debug_enabled = false; + res.debug_enabled = 0; #endif return res; } @@ -168,13 +168,13 @@ u8 *bw_get_written_raw(struct bitbuff_writer *bw) return bw->base; } -/* Returns true if num_bits would cause the writer to overflow its fixed buffer size (if writer is not backed by a dynamic arena bitbuff) */ +/* Returns 1 if num_bits would cause the writer to overflow its fixed buffer size (if writer is not backed by a dynamic arena bitbuff) */ b32 bw_check_overflow_bits(struct bitbuff_writer *bw, u64 num_bits) { - b32 res = false; + b32 res = 0; struct bitbuff *bb = bw->bb; if (bw->overflowed) { - res = true; + res = 1; } else { u64 bytes_needed = (bw->cur_bit + num_bits + 7) >> 3; if (bb->is_backed_by_arena) { @@ -188,10 +188,10 @@ b32 bw_check_overflow_bits(struct bitbuff_writer *bw, u64 num_bits) u64 max_len = bb->fixed_buffer.len; if (bytes_needed >= max_len) { /* Writer overflowed fixed buffer */ - ASSERT(false); - res = true; + ASSERT(0); + res = 1; bw->cur_bit = max_len << 3; - bw->overflowed = true; + bw->overflowed = 1; } } } @@ -388,7 +388,7 @@ struct bitbuff_reader br_from_bitbuff(struct bitbuff *bb) } res.cur_bit = 0; #if BITBUFF_DEBUG - res.debug_enabled = true; + res.debug_enabled = 1; #endif return res; } @@ -398,7 +398,7 @@ struct bitbuff_reader br_from_bitbuff_no_debug(struct bitbuff *bb) { struct bitbuff_reader res = br_from_bitbuff(bb); #if BITBUFF_DEBUG - res.debug_enabled = false; + res.debug_enabled = 0; #endif return res; } @@ -433,18 +433,18 @@ u64 br_num_bytes_left(struct bitbuff_reader *br) b32 br_check_overflow_bits(struct bitbuff_reader *br, u64 num_bits) { - b32 res = false; + b32 res = 0; if (br->overflowed) { - res = true; + res = 1; } else { u64 bits_needed = br->cur_bit + num_bits; u64 base_len_bits = br->base_len << 3; if (bits_needed > base_len_bits) { /* Tried to read past bitbuff memory */ - ASSERT(false); - res = true; + ASSERT(0); + res = 1; br->cur_bit = base_len_bits; - br->overflowed = true; + br->overflowed = 1; } } return res; @@ -603,7 +603,7 @@ struct string br_read_string(struct arena *arena, struct bitbuff_reader *br) struct string res = ZI; u64 len = br_read_uv(br); u8 *src = br_read_bytes_raw(br, len); - if (src != NULL) { + if (src != 0) { res.len = len; res.text = arena_push_array_no_zero(arena, u8, len); MEMCPY(res.text, src, len); @@ -622,14 +622,14 @@ void br_read_bytes(struct bitbuff_reader *br, struct string out) } } -/* NULL will return on bitbuff overflow, result should be checked. */ +/* Will return NULL on bitbuff overflow. Result should be checked. */ u8 *br_read_bytes_raw(struct bitbuff_reader *br, u64 num_bytes) { br_align(br); u64 num_bits = num_bytes << 3; if (br_check_overflow_bits(br, num_bits)) { - return NULL; + return 0; } u8 *raw = br->base + (br->cur_bit >> 3); @@ -657,8 +657,8 @@ void br_seek_to_byte(struct bitbuff_reader *br, u64 pos) br_seek_bytes(br, pos - cur_byte_pos); } else { /* Tried to seek byte backwards in reader */ - ASSERT(false); - br->overflowed = true; + ASSERT(0); + br->overflowed = 1; br->cur_bit = (br->base_len << 3); } @@ -767,7 +767,7 @@ void bitbuff_test(void) } else if (c.kind == kind_string) { bw_write_string(&bw, c.s.v); } else { - ASSERT(false); + ASSERT(0); } } encoded = bw_get_written(scratch.arena, &bw); @@ -799,7 +799,7 @@ void bitbuff_test(void) struct string r = br_read_string(scratch.arena, &br); ASSERT(string_eq(r, w)); } else { - ASSERT(false); + ASSERT(0); } } } diff --git a/src/bitbuff.h b/src/bitbuff.h index 0a5edca2..a90065a4 100644 --- a/src/bitbuff.h +++ b/src/bitbuff.h @@ -8,10 +8,10 @@ struct bitbuff { b32 is_backed_by_arena; - /* If `is_arena_bitbuff` is true, this dynamically-sized arena will be used for reading & writing (meaning writing cannot overflow) */ + /* If `is_arena_bitbuff` is 1, this dynamically-sized arena will be used for reading & writing (meaning writing cannot overflow) */ struct arena *arena; - /* If `is_arena_bitbuff` is false, this fixed-sized buffer willl be used for reading & writing */ + /* If `is_arena_bitbuff` is 0, this fixed-sized buffer willl be used for reading & writing */ struct string fixed_buffer; }; diff --git a/src/buddy.c b/src/buddy.c index 1745d780..f0e45c3a 100644 --- a/src/buddy.c +++ b/src/buddy.c @@ -72,17 +72,17 @@ INTERNAL void buddy_block_release_internal(struct buddy_ctx *ctx, struct buddy_l INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struct buddy_level *level) { - struct buddy_block *block = NULL; + struct buddy_block *block = 0; /* TODO: Tier oob check */ if (level->first_unused_block) { block = level->first_unused_block; level->first_unused_block = block->next; if (level->first_unused_block) { - level->first_unused_block->prev = NULL; + level->first_unused_block->prev = 0; } - block->used = true; - block->next = NULL; + block->is_used = 1; + block->next = 0; } else { if (level->backed) { struct buddy_level *parent_level = &ctx->levels[level->tier + 1]; @@ -90,14 +90,14 @@ INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struc /* Create left (used) block from parent block */ struct buddy_block *left = buddy_block_alloc_internal(ctx); - left->used = true; + left->is_used = 1; left->level = level; left->parent = parent_block; left->memory = parent_block->memory; /* Create right (unused) block from parent block */ struct buddy_block *right = buddy_block_alloc_internal(ctx); - right->used = false; + right->is_used = 0; right->level = level; right->parent = parent_block; right->memory = left->memory + level->size; @@ -122,13 +122,13 @@ INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struc /* Create left (used) block from existing child block memory */ struct buddy_block *left = buddy_block_alloc_internal(ctx); - left->used = true; + left->is_used = 1; left->level = level; left->memory = arena_base(arena); /* Create right (unused) block from new arena memory */ struct buddy_block *right = buddy_block_alloc_internal(ctx); - right->used = false; + right->is_used = 0; right->level = level; right->memory = left->memory + level->size; @@ -136,7 +136,7 @@ INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struc right->sibling = left; block = left; - level->backed = true; + level->backed = 1; } } @@ -145,11 +145,11 @@ INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struc INTERNAL void buddy_block_mark_unused(struct buddy_block *block) { - block->used = false; + block->is_used = 0; struct buddy_level *level = block->level; struct buddy_block *parent = block->parent; struct buddy_block *sibling = block->sibling; - if (!sibling->used && parent != NULL) { + if (!sibling->is_used && parent != 0) { /* Merge siblings */ struct buddy_ctx *ctx = level->ctx; buddy_block_release_internal(ctx, level, block); @@ -168,7 +168,7 @@ struct buddy_block *buddy_alloc(struct buddy_ctx *ctx, u64 size) { if (size > 0x00FFFFFFFFFFFFFFULL) { /* TODO: Error */ - ASSERT(false); + ASSERT(0); } /* TODO: Minimum block size */ diff --git a/src/buddy.h b/src/buddy.h index dc0468bd..3b8c5e58 100644 --- a/src/buddy.h +++ b/src/buddy.h @@ -2,7 +2,7 @@ #define BUDDY_H struct buddy_block { - b32 used; + b32 is_used; struct buddy_level *level; struct buddy_block *parent; struct buddy_block *sibling; diff --git a/src/collider.c b/src/collider.c index 95a598e2..29dc942a 100644 --- a/src/collider.c +++ b/src/collider.c @@ -5,7 +5,7 @@ /* How close can non-overlapping shapes be before collision is considered */ #define COLLISION_TOLERANCE 0.005f -/* NOTE: Should always be less than tolerance, since colliding = true if origin is within this distance. */ +/* NOTE: Should always be less than tolerance, since colliding = 1 if origin is within this distance. */ #define MIN_UNIQUE_PT_DIST_SQ (0.001f * 0.001f) /* To prevent extremely large prototypes when origin is in exact center of rounded feature */ @@ -141,8 +141,8 @@ struct gjk_result { struct collider_menkowski_simplex simplex; struct v2 final_dir; - /* If true, simplex represents triangle inside of menkowski difference - * encapsulating the origin. If false, simplex represents the closest + /* If 1, simplex represents triangle inside of menkowski difference + * encapsulating the origin. If 0, simplex represents the closest * feature on menkowski difference to the origin. */ b32 overlapping; @@ -157,7 +157,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct collider_shape *shape1, struct xform xf0, struct xform xf1, f32 min_unique_pt_dist_sq) #endif { - b32 overlapping = false; + b32 overlapping = 0; struct collider_menkowski_simplex s = ZI; struct v2 dir = ZI; struct collider_menkowski_point m = ZI; @@ -171,7 +171,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct struct v2 removed_a = ZI; struct v2 removed_b = ZI; u32 num_removed = 0; - while (true) { + while (1) { if (s.len == 1) { /* Second point is support point towards origin */ dir = v2_neg(s.a.p); @@ -180,7 +180,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct m = get_menkowski_point(shape0, shape1, xf0, xf1, dir); /* Check that new point is far enough away from existing point */ if (v2_len_sq(v2_sub(m.p, s.a.p)) < min_unique_pt_dist_sq) { - overlapping = false; + overlapping = 0; break; } s.b = s.a; @@ -203,7 +203,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct (num_removed >= 2 && v2_len_sq(v2_sub(m.p, removed_b)) < min_unique_pt_dist_sq)) ) || math_fabs(v2_wedge(v2_sub(s.b.p, s.a.p), v2_sub(m.p, s.a.p))) < min_unique_pt_dist_sq) { - overlapping = false; + overlapping = 0; break; } s.c = s.b; @@ -215,7 +215,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct (math_fabs(v2_wedge(v2_sub(s.c.p, s.b.p), v2_neg(s.b.p))) <= min_unique_pt_dist_sq) || (math_fabs(v2_wedge(v2_sub(s.c.p, s.a.p), v2_neg(s.a.p))) <= min_unique_pt_dist_sq)) { /* Simplex lies on origin */ - overlapping = true; + overlapping = 1; break; } } @@ -281,7 +281,7 @@ INTERNAL struct gjk_result gjk_get_simplex(struct collider_shape *shape0, struct s.a = s.c; } else { /* No region, must be in simplex */ - overlapping = true; + overlapping = 1; break; } } @@ -329,7 +329,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 struct collider_menkowski_feature closest_feature = ZI; struct v2 normal = ZI; - struct collider_menkowski_point *proto = NULL; + struct collider_menkowski_point *proto = 0; u32 proto_count = 0; if (gjk_res.overlapping) { struct collider_menkowski_simplex s = gjk_res.simplex; @@ -346,7 +346,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 i32 winding = v2_winding(v2_sub(s.c.p, s.a.p), v2_sub(s.b.p, s.a.p)); u32 epa_iterations = 0; - while (true) { + while (1) { ++epa_iterations; /* Find dir from origin to closest edge */ @@ -394,7 +394,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 /* Check validity of new point */ DBGSTEP; { - b32 valid = true; + b32 valid = 1; { /* NOTE: Changing this value affects how stable normals are for circular colliders */ @@ -409,10 +409,10 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0 if (dot >= -validity_epsilon && dot <= 1 - validity_epsilon && (v2_wedge(vab, vam) * -winding) >= -validity_epsilon) { /* New point is not between edge */ - valid = false; + valid = 0; } else if (v2_len_sq(vam) < min_unique_pt_dist_sq || v2_len_sq(vbm) < min_unique_pt_dist_sq) { /* New point is too close to existing */ - valid = false; + valid = 0; } } @@ -544,7 +544,7 @@ struct collider_collision_points_result collider_collision_points(struct collide struct collider_collision_point points[2] = ZI; u32 num_points = 0; - b32 colliding = false; + b32 colliding = 0; struct v2 normal = ZI; #if COLLIDER_DEBUG @@ -575,14 +575,14 @@ struct collider_collision_points_result collider_collision_points(struct collide /* Determine collision */ if (gjk_res.overlapping) { - colliding = true; + colliding = 1; } else { struct collider_menkowski_feature f = epa_res.closest_feature; /* Shapes not overlapping, determine if distance between shapes within tolerance */ if (f.len == 1) { struct v2 p = v2_neg(f.a.p); if (v2_len_sq(p) <= (tolerance * tolerance)) { - colliding = true; + colliding = 1; } } else { /* Project origin to determine if distance is within tolerance. */ @@ -592,7 +592,7 @@ struct collider_collision_points_result collider_collision_points(struct collide f32 ratio = clamp_f32(v2_dot(vab, vao) / v2_dot(vab, vab), 0, 1); struct v2 p = v2_add(f.a.p, v2_mul(vab, ratio)); if (v2_len_sq(p) <= (tolerance * tolerance)) { - colliding = true; + colliding = 1; } } } @@ -605,8 +605,8 @@ struct collider_collision_points_result collider_collision_points(struct collide struct collider_menkowski_feature f = epa_res.closest_feature; { - b32 collapse0 = false; - b32 collapse1 = false; + b32 collapse0 = 0; + b32 collapse1 = 0; struct collider_support_point a0 = f.a.s0; struct collider_support_point a1 = f.a.s1; @@ -618,7 +618,7 @@ struct collider_collision_points_result collider_collision_points(struct collide if (shape0->count > 1) { b0 = collider_get_support_point_internal(shape0, xf0, normal, b0.i); } else { - collapse0 = true; + collapse0 = 1; b0 = a0; } } @@ -626,13 +626,13 @@ struct collider_collision_points_result collider_collision_points(struct collide if (shape1->count > 1) { b1 = collider_get_support_point_internal(shape1, xf1, v2_neg(normal), b1.i); } else { - collapse1 = true; + collapse1 = 1; b1 = a1; } } } else { - collapse0 = true; - collapse1 = true; + collapse0 = 1; + collapse1 = 1; b0 = a0; b1 = a1; } @@ -683,8 +683,8 @@ struct collider_collision_points_result collider_collision_points(struct collide f32 b_sep = F32_INFINITY; struct v2 a_midpoint = ZI; struct v2 b_midpoint = ZI; - b32 ignore_a = true; - b32 ignore_b = true; + b32 ignore_a = 1; + b32 ignore_b = 1; if (!collapse0 && !collapse1) { /* Clip line to line */ struct clip_line_to_line_result clip_res = clip_line_to_line(a0.p, b0.p, a1.p, b1.p, normal); @@ -699,14 +699,14 @@ struct collider_collision_points_result collider_collision_points(struct collide b_sep = v2_dot(vb0b1_clipped, normal); a_midpoint = v2_add(a0_clipped, v2_mul(va0a1_clipped, 0.5f)); b_midpoint = v2_add(b0_clipped, v2_mul(vb0b1_clipped, 0.5f)); - ignore_a = false; - ignore_b = false; + ignore_a = 0; + ignore_b = 0; struct v2 vfin = v2_sub(b_midpoint, a_midpoint); if (v2_len_sq(vfin) < (0.005 * 0.005)) { if (a_sep > b_sep) { - ignore_a = true; + ignore_a = 1; } else { - ignore_b = true; + ignore_b = 1; } } res.a0_clipped = a0_clipped; @@ -729,7 +729,7 @@ struct collider_collision_points_result collider_collision_points(struct collide struct v2 vsep = v2_sub(p1, p0); a_midpoint = v2_add(p0, v2_mul(vsep, 0.5f)); a_sep = v2_dot(normal, p1) - v2_dot(normal, p0); - ignore_a = false; + ignore_a = 0; res.a0_clipped = p0; res.a1_clipped = p1; res.b0_clipped = p0; @@ -758,7 +758,7 @@ struct collider_collision_points_result collider_collision_points(struct collide } #if COLLIDER_DEBUG - res.solved = true; + res.solved = 1; abort: res.simplex = gjk_res.simplex; res.prototype.len = epa_res.prototype.len; @@ -787,7 +787,7 @@ struct collider_closest_points_result collider_closest_points(struct collider_sh struct v2 p0 = ZI; struct v2 p1 = ZI; - b32 colliding = false; + b32 colliding = 0; #if COLLIDER_DEBUG u32 dbg_step = 0; @@ -846,7 +846,7 @@ struct collider_closest_points_result collider_closest_points(struct collider_sh } #if COLLIDER_DEBUG - res.solved = true; + res.solved = 1; abort: res.simplex = gjk_res.simplex; res.prototype.len = epa_res.prototype.len; @@ -904,7 +904,7 @@ f32 collider_time_of_impact(struct collider_shape *c0, struct collider_shape *c1 u32 iteration = 0; while (math_fabs(t_sep) > tolerance && iteration < max_iterations) { - /* Use mix of bisection & false position method to find root + /* Use mix of bisection & 0 position method to find root * (as described in https://box2d.org/files/ErinCatto_ContinuousCollision_GDC2013.pdf) */ if (iteration & 1) { /* Bisect */ @@ -1001,7 +1001,7 @@ b32 collider_collision_boolean(struct collider_shape *shape0, struct collider_sh if (v2_dot(dir, p) >= 0) { s.b = s.a; s.a = p; - while (true) { + while (1) { /* Third point is support point in direction of line normal towards origin */ dir = v2_perp_towards_dir(v2_sub(s.b, s.a), v2_neg(s.a)); p = get_menkowski_point(shape0, shape1, dir); @@ -1029,12 +1029,12 @@ b32 collider_collision_boolean(struct collider_shape *shape0, struct collider_sh s.b = s.c; } else { /* Point is in simplex */ - return true; + return 1; } } } } - return false; + return 0; } #endif diff --git a/src/common.h b/src/common.h index bc31e74c..8c634a63 100644 --- a/src/common.h +++ b/src/common.h @@ -251,7 +251,7 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); #if COMPILER_MSVC /* Typeof not supported in MSVC */ # define TYPEOF_DEFINED 0 -# define typeof(type) ASSERT(false) +# define typeof(type) ASSERT(0) #else # define TYPEOF_DEFINED 1 # if LANGUAGE_CPP || (__STDC_VERSION__ < 202311L) @@ -282,12 +282,6 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t); # define FIELD_OFFSETOF(type, field) __builtin_offsetof(type, field) #endif -/* Bool */ -#if !LANGUAGE_CPP -# define true 1 -# define false 0 -#endif - /* Array */ #define IS_INDEXABLE(a) (sizeof(a[0])) #define IS_ARRAY(a) (IS_INDEXABLE(a) && (((void *)&a) == ((void *)a))) diff --git a/src/draw.c b/src/draw.c index a16cd6fa..b3ad691e 100644 --- a/src/draw.c +++ b/src/draw.c @@ -181,7 +181,7 @@ void draw_circle_line(struct gp_flow *flow, struct v2 pos, f32 radius, f32 thick .points = points, .count = detail }; - draw_poly_line(flow, a, true, thickness, color); + draw_poly_line(flow, a, 1, thickness, color); scratch_end(scratch); } @@ -190,7 +190,7 @@ void draw_quad_line(struct gp_flow *flow, struct quad quad, f32 thickness, u32 c { struct v2 points[] = { quad.p0, quad.p1, quad.p2, quad.p3 }; struct v2_array a = { .points = points, .count = countof(points) }; - draw_poly_line(flow, a, true, thickness, color); + draw_poly_line(flow, a, 1, thickness, color); } void draw_arrow_line(struct gp_flow *flow, struct v2 start, struct v2 end, f32 thickness, f32 arrowhead_height, u32 color) @@ -250,7 +250,7 @@ void draw_collider_line(struct gp_flow *flow, struct collider_shape shape, struc poly.points[i] = p; } } - draw_poly_line(flow, poly, true, thickness, color); + draw_poly_line(flow, poly, 1, thickness, color); scratch_end(scratch); } @@ -319,13 +319,13 @@ struct rect draw_text(struct gp_flow *flow, struct draw_text_params params) u64 num_lines = 0; f32 widest_line = 0; - struct drawable_line *first_line = NULL; - struct drawable_line *last_line = NULL; + struct drawable_line *first_line = 0; + struct drawable_line *last_line = 0; f32 first_line_top_offset = 0; f32 last_line_bottom_offset = 0; if (params.str.len > 0) { - b32 string_done = false; + b32 string_done = 0; struct string_codepoint_iter iter = string_codepoint_iter_begin(params.str); while (!string_done) { f32 line_width = 0; @@ -334,15 +334,15 @@ struct rect draw_text(struct gp_flow *flow, struct draw_text_params params) u64 num_line_glyphs = 0; struct drawable_glyph *line_glyphs = arena_push_dry(scratch.arena, struct drawable_glyph); - b32 line_done = false; + b32 line_done = 0; while (!line_done) { string_done = !string_codepoint_iter_next(&iter); if (string_done) { - line_done = true; + line_done = 1; } else { u32 codepoint = iter.codepoint; if (codepoint == '\n') { - line_done = true; + line_done = 1; } else { struct drawable_glyph *tg = arena_push(scratch.arena, struct drawable_glyph); ++num_line_glyphs; diff --git a/src/font.c b/src/font.c index 0986550e..b9fa5d9b 100644 --- a/src/font.c +++ b/src/font.c @@ -60,7 +60,7 @@ struct font_startup_receipt font_startup(struct gp_startup_receipt *gp_sr, INTERNAL struct font_task_params *font_task_params_alloc(void) { - struct font_task_params *p = NULL; + struct font_task_params *p = 0; { struct snc_lock lock = snc_lock_e(&G.params.mutex); if (G.params.head_free) { @@ -117,7 +117,7 @@ INTERNAL SYS_JOB_DEF(font_load_asset_job, job) struct gp_resource *texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32(result.image_data.width, result.image_data.height), result.image_data.pixels); /* Allocate store memory */ - struct font *font = NULL; + struct font *font = 0; { struct asset_cache_store store = asset_cache_store_open(); font = arena_push(store.arena, struct font); @@ -187,7 +187,7 @@ struct asset *font_load_asset(struct string path, f32 point_size, b32 wait) /* Push task */ asset_cache_mark_loading(asset); - sys_run(1, font_load_asset_job, params, SYS_PRIORITY_BACKGROUND, NULL); + sys_run(1, font_load_asset_job, params, SYS_PRIORITY_BACKGROUND, 0); if (wait) { asset_cache_wait(asset); } @@ -200,7 +200,7 @@ struct asset *font_load_asset(struct string path, f32 point_size, b32 wait) struct font *font_load_async(struct string path, f32 point_size) { __prof; - struct asset *asset = font_load_asset(path, point_size, false); + struct asset *asset = font_load_asset(path, point_size, 0); struct font *f = (struct font *)asset_cache_get_store_data(asset); return f; } @@ -208,7 +208,7 @@ struct font *font_load_async(struct string path, f32 point_size) struct font *font_load(struct string path, f32 point_size) { __prof; - struct asset *asset = font_load_asset(path, point_size, true); + struct asset *asset = font_load_asset(path, point_size, 1); asset_cache_wait(asset); struct font *f = (struct font *)asset_cache_get_store_data(asset); return f; diff --git a/src/gp_dx12.c b/src/gp_dx12.c index 0767845e..965bf97d 100644 --- a/src/gp_dx12.c +++ b/src/gp_dx12.c @@ -383,8 +383,8 @@ struct gp_startup_receipt gp_startup(void) app_register_exit_callback(gp_shutdown); /* Start evictor thread */ - G.evictor_thread_wake_event = CreateEvent(NULL, false, false, NULL); - G.evictor_thread = sys_thread_alloc(evictor_thread_entry_point, NULL, LIT("GPU resource evictor thread"), PROF_THREAD_GROUP_EVICTORS); + G.evictor_thread_wake_event = CreateEvent(0, 0, 0, 0); + G.evictor_thread = sys_thread_alloc(evictor_thread_entry_point, 0, LIT("GPU resource evictor thread"), PROF_THREAD_GROUP_EVICTORS); struct gp_startup_receipt res = ZI; return res; @@ -432,13 +432,13 @@ INTERNAL void dx12_init_device(void) u32 dxgi_factory_flags = 0; #if DX12_DEBUG { - ID3D12Debug *debug_controller0 = NULL; + ID3D12Debug *debug_controller0 = 0; hr = D3D12GetDebugInterface(&IID_ID3D12Debug, (void **)&debug_controller0); if (FAILED(hr)) { dx12_init_error(LIT("Failed to create ID3D12Debug0")); } - ID3D12Debug1 *debug_controller1 = NULL; + ID3D12Debug1 *debug_controller1 = 0; hr = ID3D12Debug_QueryInterface(debug_controller0, &IID_ID3D12Debug1, (void **)&debug_controller1); if (FAILED(hr)) { dx12_init_error(LIT("Failed to create ID3D12Debug1")); @@ -447,7 +447,7 @@ INTERNAL void dx12_init_device(void) ID3D12Debug_EnableDebugLayer(debug_controller0); /* FIXME: Enable this */ - //ID3D12Debug1_SetEnableGPUBasedValidation(debug_controller1, true); + //ID3D12Debug1_SetEnableGPUBasedValidation(debug_controller1, 1); ID3D12Debug_Release(debug_controller1); ID3D12Debug_Release(debug_controller0); @@ -463,12 +463,12 @@ INTERNAL void dx12_init_device(void) /* Create device */ { - IDXGIAdapter1 *adapter = NULL; - ID3D12Device *device = NULL; + IDXGIAdapter1 *adapter = 0; + ID3D12Device *device = 0; struct string error = LIT("Could not initialize GPU device."); struct string first_gpu_name = ZI; u32 adapter_index = 0; - while (true) { + while (1) { hr = IDXGIFactory6_EnumAdapterByGpuPreference(G.factory, adapter_index, DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE, &IID_IDXGIAdapter1, (void **)&adapter); if (SUCCEEDED(hr)) { DXGI_ADAPTER_DESC1 desc; @@ -482,8 +482,8 @@ INTERNAL void dx12_init_device(void) } ID3D12Device_Release(device); IDXGIAdapter1_Release(adapter); - adapter = NULL; - device = NULL; + adapter = 0; + device = 0; ++adapter_index; } else { break; @@ -503,25 +503,25 @@ INTERNAL void dx12_init_device(void) #if DX12_DEBUG /* Enable D3D12 Debug break */ { - ID3D12InfoQueue *info = NULL; + ID3D12InfoQueue *info = 0; hr = ID3D12Device_QueryInterface(G.device, &IID_ID3D12InfoQueue, (void **)&info); if (FAILED(hr)) { dx12_init_error(LIT("Failed to query ID3D12Device interface")); } - ID3D12InfoQueue_SetBreakOnSeverity(info, D3D12_MESSAGE_SEVERITY_CORRUPTION, TRUE); - ID3D12InfoQueue_SetBreakOnSeverity(info, D3D12_MESSAGE_SEVERITY_ERROR, TRUE); + ID3D12InfoQueue_SetBreakOnSeverity(info, D3D12_MESSAGE_SEVERITY_CORRUPTION, 1); + ID3D12InfoQueue_SetBreakOnSeverity(info, D3D12_MESSAGE_SEVERITY_ERROR, 1); ID3D12InfoQueue_Release(info); } /* Enable DXGI Debug break */ { - IDXGIInfoQueue *dxgi_info = NULL; + IDXGIInfoQueue *dxgi_info = 0; hr = DXGIGetDebugInterface1(0, &IID_IDXGIInfoQueue, (void **)&dxgi_info); if (FAILED(hr)) { dx12_init_error(LIT("Failed to get DXGI debug interface")); } - IDXGIInfoQueue_SetBreakOnSeverity(dxgi_info, DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, TRUE); - IDXGIInfoQueue_SetBreakOnSeverity(dxgi_info, DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, TRUE); + IDXGIInfoQueue_SetBreakOnSeverity(dxgi_info, DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_CORRUPTION, 1); + IDXGIInfoQueue_SetBreakOnSeverity(dxgi_info, DXGI_DEBUG_ALL, DXGI_INFO_QUEUE_MESSAGE_SEVERITY_ERROR, 1); IDXGIInfoQueue_Release(dxgi_info); } #endif @@ -529,14 +529,14 @@ INTERNAL void dx12_init_device(void) #if PROFILING_D3D /* Enable stable power state */ { - b32 success = true; + b32 success = 1; __profn("Set stable power state"); HKEY key = 0; success = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\AppModelUnlock", 0, KEY_READ, &key) == ERROR_SUCCESS; if (success) { DWORD value = ZI; DWORD dword_size = sizeof(DWORD); - success = RegQueryValueExW(key, L"AllowDevelopmentWithoutDevLicense", 0, NULL, (LPBYTE)&value, &dword_size) == ERROR_SUCCESS; + success = RegQueryValueExW(key, L"AllowDevelopmentWithoutDevLicense", 0, 0, (LPBYTE)&value, &dword_size) == ERROR_SUCCESS; RegCloseKey(key); if (success) { success = value != 0; @@ -549,7 +549,7 @@ INTERNAL void dx12_init_device(void) if (SUCCEEDED(hr)) { logf_info("ID3D12Device::SetStablePowerState succeeded"); } else { - success = false; + success = 0; logf_error("ID3D12Device::SetStablePowerState failed"); } } else { @@ -743,7 +743,7 @@ INTERNAL struct dx12_include_handler *dx12_include_handler_alloc(struct arena *a INTERNAL void dx12_include_handler_release(struct dx12_include_handler *handler) { for (u64 i = 0; i < handler->num_open_resources; ++i) { - ASSERT(false); /* Resource should have been closed by handler by now */ + ASSERT(0); /* Resource should have been closed by handler by now */ struct resource *res = &handler->open_resources[i]; resource_close(res); } @@ -787,9 +787,9 @@ INTERNAL SYS_JOB_DEF(shader_compile_job, job) struct arena_temp scratch = scratch_begin_no_conflict(); { i64 start_ns = sys_time_ns(); - b32 success = false; - ID3DBlob *blob = NULL; - ID3DBlob *error_blob = NULL; + b32 success = 0; + ID3DBlob *blob = 0; + ID3DBlob *error_blob = 0; if (resource_exists(shader_res)) { struct dx12_include_handler *include_handler = dx12_include_handler_alloc(scratch.arena, pipeline); @@ -809,7 +809,7 @@ INTERNAL SYS_JOB_DEF(shader_compile_job, job) /* Compile shader */ struct string friendly_name = string_cat(scratch.arena, LIT("res/"), shader_desc.file); char *friendly_name_cstr = cstr_from_string(scratch.arena, friendly_name); - char *target = NULL; + char *target = 0; switch (kind) { case SHADER_COMPILE_TASK_KIND_VS: { @@ -823,7 +823,7 @@ INTERNAL SYS_JOB_DEF(shader_compile_job, job) } D3D_SHADER_MACRO defines[] = { { "SH_CPU", "0" }, - { NULL, NULL } + { 0, 0 } }; HRESULT hr = D3DCompile(shader_src.text, shader_src.len, friendly_name_cstr, defines, (ID3DInclude *)include_handler, func_cstr, target, d3d_compile_flags, 0, &blob, &error_blob); success = SUCCEEDED(hr) && !error_blob; @@ -862,7 +862,7 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) struct pipeline_desc *desc = &sig->descs_in[job.id]; struct pipeline **pipelines_out = sig->pipelines_out; - struct pipeline *pipeline = NULL; + struct pipeline *pipeline = 0; { struct arena *pipeline_arena = arena_alloc(MEBI(64)); pipeline = arena_push(pipeline_arena, struct pipeline); @@ -879,7 +879,7 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) i64 start_ns = sys_time_ns(); struct string pipeline_name = pipeline->name; logf_info("Loading pipeline \"%F\"", FMT_STR(pipeline_name)); - b32 success = true; + b32 success = 1; HRESULT hr = 0; struct string error_str = LIT("Unknown error"); @@ -896,10 +896,10 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) if (success) { if (!resource_exists(&vs_res)) { error_str = string_format(scratch.arena, LIT("Shader source \"%F\" not found"), FMT_STR(desc->vs.file)); - success = false; + success = 0; } else if (!resource_exists(&ps_res)) { error_str = string_format(scratch.arena, LIT("Shader source \"%F\" not found"), FMT_STR(desc->ps.file)); - success = false; + success = 0; } } @@ -929,15 +929,15 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) * NOTE: This isn't necessary for creating the root signature (since it * could reuse the shader blob), however we'd like to verify that the * root signature exists and matches between shaders. */ - ID3D10Blob *rootsig_blob = NULL; + ID3D10Blob *rootsig_blob = 0; if (success) { __profn("Validate root signatures"); - char *vs_rootsig_data = NULL; - char *ps_rootsig_data = NULL; + char *vs_rootsig_data = 0; + char *ps_rootsig_data = 0; u32 vs_rootsig_data_len = 0; u32 ps_rootsig_data_len = 0; - ID3D10Blob *vs_rootsig_blob = NULL; - ID3D10Blob *ps_rootsig_blob = NULL; + ID3D10Blob *vs_rootsig_blob = 0; + ID3D10Blob *ps_rootsig_blob = 0; D3DGetBlobPart(ID3D10Blob_GetBufferPointer(vs.blob), ID3D10Blob_GetBufferSize(vs.blob), D3D_BLOB_ROOT_SIGNATURE, 0, &vs_rootsig_blob); D3DGetBlobPart(ID3D10Blob_GetBufferPointer(ps.blob), ID3D10Blob_GetBufferSize(ps.blob), D3D_BLOB_ROOT_SIGNATURE, 0, &ps_rootsig_blob); if (vs_rootsig_blob) { @@ -949,13 +949,13 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) ps_rootsig_data_len = ID3D10Blob_GetBufferSize(ps_rootsig_blob); } if (vs_rootsig_data_len == 0) { - success = false; + success = 0; error_str = LIT("Vertex shader is missing root signature"); } else if (ps_rootsig_data_len == 0) { - success = false; + success = 0; error_str = LIT("Pixel shader is missing root signature"); } else if (vs_rootsig_data_len != ps_rootsig_data_len || !MEMEQ(vs_rootsig_data, ps_rootsig_data, vs_rootsig_data_len)) { - success = false; + success = 0; error_str = LIT("Root signature mismatch between vertex and pixel shader"); } else { rootsig_blob = vs_rootsig_blob; @@ -966,31 +966,31 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) } /* Create root signature */ - ID3D12RootSignature *rootsig = NULL; + ID3D12RootSignature *rootsig = 0; if (success) { __profn("Create root signature"); hr = ID3D12Device_CreateRootSignature(G.device, 0, ID3D10Blob_GetBufferPointer(rootsig_blob), ID3D10Blob_GetBufferSize(rootsig_blob), &IID_ID3D12RootSignature, (void **)&rootsig); if (FAILED(hr)) { error_str = LIT("Failed to create root signature"); - success = false; + success = 0; } } /* Create PSO */ - ID3D12PipelineState *pso = NULL; + ID3D12PipelineState *pso = 0; if (success) { /* Default rasterizer state */ __profn("Create PSO"); D3D12_RASTERIZER_DESC raster_desc = { .FillMode = D3D12_FILL_MODE_SOLID, .CullMode = D3D12_CULL_MODE_NONE, - .FrontCounterClockwise = FALSE, + .FrontCounterClockwise = 0, .DepthBias = D3D12_DEFAULT_DEPTH_BIAS, .DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP, .SlopeScaledDepthBias = D3D12_DEFAULT_SLOPE_SCALED_DEPTH_BIAS, - .DepthClipEnable = TRUE, - .MultisampleEnable = FALSE, - .AntialiasedLineEnable = FALSE, + .DepthClipEnable = 1, + .MultisampleEnable = 0, + .AntialiasedLineEnable = 0, .ForcedSampleCount = 0, .ConservativeRaster = D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF }; @@ -998,7 +998,7 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) /* Input layout */ u32 num_input_layout_elements = 0; for (u32 i = 0; i < countof(desc->ia); ++i) { - if (desc->ia[i].SemanticName == NULL) { + if (desc->ia[i].SemanticName == 0) { break; } ++num_input_layout_elements; @@ -1010,10 +1010,10 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) /* Blend state */ D3D12_BLEND_DESC blend_desc = { - .AlphaToCoverageEnable = FALSE, - .IndependentBlendEnable = FALSE + .AlphaToCoverageEnable = 0, + .IndependentBlendEnable = 0 }; - blend_desc.RenderTarget[0].BlendEnable = TRUE; + blend_desc.RenderTarget[0].BlendEnable = 1; blend_desc.RenderTarget[0].SrcBlend = D3D12_BLEND_SRC_ALPHA; blend_desc.RenderTarget[0].DestBlend = D3D12_BLEND_INV_SRC_ALPHA; blend_desc.RenderTarget[0].BlendOp = D3D12_BLEND_OP_ADD; @@ -1024,8 +1024,8 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) /* Disable depth stencil */ D3D12_DEPTH_STENCIL_DESC depth_stencil_desc = { - .DepthEnable = FALSE, - .StencilEnable = FALSE + .DepthEnable = 0, + .StencilEnable = 0 }; /* PSO */ @@ -1052,7 +1052,7 @@ INTERNAL SYS_JOB_DEF(pipeline_init_job, job) hr = ID3D12Device_CreateGraphicsPipelineState(G.device, &pso_desc, &IID_ID3D12PipelineState, (void **)&pso); if (FAILED(hr)) { error_str = LIT("Failed to create pipeline state object"); - success = false; + success = 0; } } @@ -1134,7 +1134,7 @@ INTERNAL void pipeline_release_now(struct pipeline *pipeline) INTERNAL struct pipeline_scope *pipeline_scope_begin(void) { __prof; - struct pipeline_scope *scope = NULL; + struct pipeline_scope *scope = 0; { struct snc_lock lock = snc_lock_e(&G.pipelines_mutex); if (G.first_free_pipeline_scope) { @@ -1143,7 +1143,7 @@ INTERNAL struct pipeline_scope *pipeline_scope_begin(void) } snc_unlock(&lock); } - struct arena *arena = NULL; + struct arena *arena = 0; if (scope) { arena = scope->arena; } else { @@ -1297,7 +1297,7 @@ INTERNAL RESOURCE_WATCH_CALLBACK_FUNC_DEF(pipeline_resource_watch_callback, name INTERNAL struct descriptor *descriptor_alloc(struct cpu_descriptor_heap *dh) { __prof; - struct descriptor *d = NULL; + struct descriptor *d = 0; u32 index = 0; D3D12_CPU_DESCRIPTOR_HANDLE handle = ZI; { @@ -1342,7 +1342,7 @@ INTERNAL void descriptor_release(struct descriptor *descriptor) INTERNAL struct cpu_descriptor_heap *cpu_descriptor_heap_alloc(enum D3D12_DESCRIPTOR_HEAP_TYPE type) { __prof; - struct cpu_descriptor_heap *dh = NULL; + struct cpu_descriptor_heap *dh = 0; { struct arena *arena = arena_alloc(MEBI(64)); dh = arena_push(arena, struct cpu_descriptor_heap); @@ -1427,7 +1427,7 @@ struct material_grid_desc { INTERNAL struct flow *flow_alloc(void) { __prof; - struct flow *flow = NULL; + struct flow *flow = 0; { struct arena *arena = arena_alloc(MEBI(64)); flow = arena_push(arena, struct flow); @@ -1568,7 +1568,7 @@ enum dx12_resource_view_flags { INTERNAL struct dx12_resource *dx12_resource_alloc(D3D12_HEAP_PROPERTIES heap_props, D3D12_HEAP_FLAGS heap_flags, D3D12_RESOURCE_DESC desc, D3D12_RESOURCE_STATES initial_state, enum dx12_resource_view_flags view_flags) { __prof; - struct dx12_resource *r = NULL; + struct dx12_resource *r = 0; { struct snc_lock lock = snc_lock_e(&G.resources_mutex); if (G.first_free_resource) { @@ -1582,7 +1582,7 @@ INTERNAL struct dx12_resource *dx12_resource_alloc(D3D12_HEAP_PROPERTIES heap_pr MEMZERO_STRUCT(r); D3D12_CLEAR_VALUE clear_value = { .Format = desc.Format, .Color = { 0 } }; - D3D12_CLEAR_VALUE *clear_value_ptr = desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET ? &clear_value : NULL; + D3D12_CLEAR_VALUE *clear_value_ptr = desc.Flags & D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET ? &clear_value : 0; HRESULT hr = ID3D12Device_CreateCommittedResource(G.device, &heap_props, heap_flags, &desc, initial_state, clear_value_ptr, &IID_ID3D12Resource, (void **)&r->resource); if (FAILED(hr)) { /* TODO: Don't panic */ @@ -1606,15 +1606,15 @@ INTERNAL struct dx12_resource *dx12_resource_alloc(D3D12_HEAP_PROPERTIES heap_pr } if (view_flags & DX12_RESOURCE_VIEW_FLAG_SRV) { r->srv_descriptor = descriptor_alloc(G.cbv_srv_uav_heap); - ID3D12Device_CreateShaderResourceView(G.device, r->resource, NULL, r->srv_descriptor->handle); + ID3D12Device_CreateShaderResourceView(G.device, r->resource, 0, r->srv_descriptor->handle); } if (view_flags & DX12_RESOURCE_VIEW_FLAG_UAV) { r->uav_descriptor = descriptor_alloc(G.cbv_srv_uav_heap); - ID3D12Device_CreateUnorderedAccessView(G.device, r->resource, NULL, NULL, r->uav_descriptor->handle); + ID3D12Device_CreateUnorderedAccessView(G.device, r->resource, 0, 0, r->uav_descriptor->handle); } if (view_flags & DX12_RESOURCE_VIEW_FLAG_RTV) { r->rtv_descriptor = descriptor_alloc(G.rtv_heap); - ID3D12Device_CreateRenderTargetView(G.device, r->resource, NULL, r->rtv_descriptor->handle); + ID3D12Device_CreateRenderTargetView(G.device, r->resource, 0, r->rtv_descriptor->handle); } return r; @@ -1687,7 +1687,7 @@ INTERNAL struct command_list_pool *command_list_pool_alloc(struct command_queue INTERNAL struct command_queue *command_queue_alloc(enum D3D12_COMMAND_LIST_TYPE type, enum D3D12_COMMAND_QUEUE_PRIORITY priority, struct string dbg_name) { __prof; - struct command_queue *cq = NULL; + struct command_queue *cq = 0; { struct arena *arena = arena_alloc(GIBI(64)); cq = arena_push(arena, struct command_queue); @@ -1730,7 +1730,7 @@ INTERNAL void command_queue_release(struct command_queue *cq) INTERNAL struct command_list_pool *command_list_pool_alloc(struct command_queue *cq) { - struct command_list_pool *pool = NULL; + struct command_list_pool *pool = 0; { struct arena *arena = arena_alloc(GIBI(64)); pool = arena_push(arena, struct command_list_pool); @@ -1746,9 +1746,9 @@ INTERNAL struct command_list *command_list_open(struct command_list_pool *pool) struct command_queue *cq = pool->cq; u64 completed_fence_value = ID3D12Fence_GetCompletedValue(cq->submit_fence); - struct command_list *cl = NULL; - struct ID3D12GraphicsCommandList *old_cl = NULL; - struct ID3D12CommandAllocator *old_ca = NULL; + struct command_list *cl = 0; + struct ID3D12GraphicsCommandList *old_cl = 0; + struct ID3D12CommandAllocator *old_ca = 0; { struct snc_lock lock = snc_lock_e(&pool->mutex); /* Find first command list ready for reuse */ @@ -1794,7 +1794,7 @@ INTERNAL struct command_list *command_list_open(struct command_list_pool *pool) sys_panic(LIT("Failed to create command allocator")); } - hr = ID3D12Device_CreateCommandList(G.device, 0, cq->type, cl->ca, NULL, &IID_ID3D12GraphicsCommandList, (void **)&cl->cl); + hr = ID3D12Device_CreateCommandList(G.device, 0, cq->type, cl->ca, 0, &IID_ID3D12GraphicsCommandList, (void **)&cl->cl); if (FAILED(hr)) { sys_panic(LIT("Failed to create command list")); } @@ -1811,7 +1811,7 @@ INTERNAL struct command_list *command_list_open(struct command_list_pool *pool) sys_panic(LIT("Failed to reset command allocator")); } - hr = ID3D12GraphicsCommandList_Reset(cl->cl, cl->ca, NULL); + hr = ID3D12GraphicsCommandList_Reset(cl->cl, cl->ca, 0); if (FAILED(hr)) { sys_panic(LIT("Failed to reset command list")); } @@ -1911,8 +1911,8 @@ INTERNAL struct command_descriptor_heap *command_list_push_descriptor_heap(struc ASSERT(dh_cpu->type == D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); /* Src heap must have expected type */ /* Allocate GPU heap */ - struct command_descriptor_heap *cdh = NULL; - ID3D12DescriptorHeap *old_heap = NULL; + struct command_descriptor_heap *cdh = 0; + ID3D12DescriptorHeap *old_heap = 0; D3D12_CPU_DESCRIPTOR_HANDLE old_cpu_handle = ZI; D3D12_GPU_DESCRIPTOR_HANDLE old_gpu_handle = ZI; { @@ -2016,9 +2016,9 @@ INTERNAL struct command_buffer *command_list_push_buffer(struct command_list *cl u64 size = max_u64(DX12_COMMAND_BUFFER_MIN_SIZE, align_up_pow2(data.len)); /* Allocate buffer */ - struct command_buffer_group *cb_group = NULL; - struct command_buffer *cb = NULL; - struct dx12_resource *resource = NULL; + struct command_buffer_group *cb_group = 0; + struct command_buffer *cb = 0; + struct dx12_resource *resource = 0; { struct snc_lock lock = snc_lock_e(&G.command_buffers_mutex); @@ -2097,14 +2097,14 @@ INTERNAL struct command_buffer *command_list_push_buffer(struct command_list *cl /* Copy data to resource */ { D3D12_RANGE read_range = ZI; - void *dst = NULL; + void *dst = 0; HRESULT hr = ID3D12Resource_Map(cb->resource->resource, 0, &read_range, &dst); if (FAILED(hr) || !dst) { /* TODO: Don't panic */ sys_panic(LIT("Failed to map command buffer resource")); } MEMCPY(dst, data.text, data.len); - ID3D12Resource_Unmap(cb->resource->resource, 0, NULL); + ID3D12Resource_Unmap(cb->resource->resource, 0, 0); } /* Insert into command list */ @@ -2130,7 +2130,7 @@ INTERNAL void command_list_set_root_constant(struct command_list *cl, void *src, } } else { /* Root constant structs must pad to 32 bits */ - ASSERT(false); + ASSERT(0); } } @@ -2237,7 +2237,7 @@ struct gp_resource *gp_texture_alloc(enum gp_texture_format format, u32 flags, s ID3D12Device_GetCopyableFootprints(G.device, &desc, 0, 1, 0, &footprint, &upload_num_rows, &upload_row_size, &upload_size); /* Create temp upload heap */ - struct dx12_resource *upload = NULL; + struct dx12_resource *upload = 0; { enum dx12_resource_view_flags upload_view_flags = DX12_RESOURCE_VIEW_FLAG_NONE; @@ -2268,20 +2268,20 @@ struct gp_resource *gp_texture_alloc(enum gp_texture_format format, u32 flags, s /* FIXME: Copy based on footprint */ { D3D12_RANGE read_range = ZI; - void *dst = NULL; + void *dst = 0; HRESULT hr = ID3D12Resource_Map(upload->resource, 0, &read_range, &dst); if (FAILED(hr) || !dst) { /* TODO: Don't panic */ sys_panic(LIT("Failed to map texture upload resource")); } MEMCPY(dst, initial_data, size.x * size.y * pixel_size); - ID3D12Resource_Unmap(upload->resource, 0, NULL); + ID3D12Resource_Unmap(upload->resource, 0, 0); } #else /* FIXME: Copy based on footprint */ { D3D12_RANGE read_range = ZI; - void *mapped = NULL; + void *mapped = 0; HRESULT hr = ID3D12Resource_Map(upload->resource, 0, &read_range, &mapped); if (FAILED(hr) || !mapped) { /* TODO: Don't panic */ @@ -2292,7 +2292,7 @@ struct gp_resource *gp_texture_alloc(enum gp_texture_format format, u32 flags, s for (u32 y = 0; y < upload_num_rows; ++y) { memcpy(dst + y * footprint.Footprint.RowPitch, src + y * size.x * pixel_size, size.x * pixel_size); } - ID3D12Resource_Unmap(upload->resource, 0, NULL); + ID3D12Resource_Unmap(upload->resource, 0, 0); } #endif } @@ -2314,7 +2314,7 @@ struct gp_resource *gp_texture_alloc(enum gp_texture_format format, u32 flags, s .PlacedFootprint = footprint, }; - ID3D12GraphicsCommandList_CopyTextureRegion(cl->cl, &dst_loc, 0, 0, 0, &src_loc, NULL); + ID3D12GraphicsCommandList_CopyTextureRegion(cl->cl, &dst_loc, 0, 0, 0, &src_loc, 0); /* FIXME: Better barrier? */ //dx12_resource_barrier(cl->cl, r, D3D12_RESOURCE_STATE_ALL_SHADER_RESOURCE); } @@ -2324,7 +2324,7 @@ struct gp_resource *gp_texture_alloc(enum gp_texture_format format, u32 flags, s /* TODO: Return async waitable to caller */ { __profn("Wait for upload"); - HANDLE event = CreateEvent(NULL, false, false, NULL); + HANDLE event = CreateEvent(0, 0, 0, 0); ID3D12Fence_SetEventOnCompletion(cq->submit_fence, fence_target, event); WaitForSingleObject(event, INFINITE); CloseHandle(event); @@ -2438,10 +2438,10 @@ void gp_dispatch(struct gp_dispatch_params params) /* Transition render target */ enum D3D12_RESOURCE_STATES target_old_state = dx12_resource_barrier(cl->cl, target, D3D12_RESOURCE_STATE_RENDER_TARGET); { - ID3D12GraphicsCommandList_OMSetRenderTargets(cl->cl, 1, &target->rtv_descriptor->handle, false, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(cl->cl, 1, &target->rtv_descriptor->handle, 0, 0); if (params.clear_target) { f32 clear_color[] = { 0.0f, 0.0f, 0.0f, 0.0f }; - ID3D12GraphicsCommandList_ClearRenderTargetView(cl->cl, target->rtv_descriptor->handle, clear_color, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(cl->cl, target->rtv_descriptor->handle, clear_color, 0, 0); } } @@ -2538,7 +2538,7 @@ struct gp_memory_info gp_query_memory_info(void) struct gp_memory_info res = ZI; HRESULT hr = 0; - IDXGIAdapter3 *dxgiAdapter3 = NULL; + IDXGIAdapter3 *dxgiAdapter3 = 0; if (SUCCEEDED(hr)) { hr = IDXGIAdapter_QueryInterface(G.adapter, &IID_IDXGIAdapter3, (void **)&dxgiAdapter3); } @@ -2586,7 +2586,7 @@ INTERNAL struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, /* Flush direct queue */ //ID3D12CommandQueue_Signal(cq->cq, cq->submit_fence, ++cq->submit_fence_target); { - HANDLE event = CreateEvent(NULL, false, false, NULL); + HANDLE event = CreateEvent(0, 0, 0, 0); ID3D12Fence_SetEventOnCompletion(cq->submit_fence, cq->submit_fence_target, event); WaitForSingleObject(event, INFINITE); CloseHandle(event); @@ -2609,7 +2609,7 @@ INTERNAL struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, snc_unlock(&lock); } else { /* Create swapchain1 */ - IDXGISwapChain1 *swapchain1 = NULL; + IDXGISwapChain1 *swapchain1 = 0; { DXGI_SWAP_CHAIN_DESC1 desc = ZI; desc.Format = DX12_SWAPCHAIN_FORMAT; @@ -2623,7 +2623,7 @@ INTERNAL struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, desc.Flags = DX12_SWAPCHAIN_FLAGS; desc.AlphaMode = DXGI_ALPHA_MODE_IGNORE; desc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; - hr = IDXGIFactory2_CreateSwapChainForHwnd(G.factory, (IUnknown *)cq->cq, hwnd, &desc, NULL, NULL, &swapchain1); + hr = IDXGIFactory2_CreateSwapChainForHwnd(G.factory, (IUnknown *)cq->cq, hwnd, &desc, 0, 0, &swapchain1); if (FAILED(hr)) { sys_panic(LIT("Failed to create IDXGISwapChain1")); } @@ -2644,7 +2644,7 @@ INTERNAL struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, /* Allocate swapchain resources */ for (u32 i = 0; i < countof(swapchain->buffers); ++i) { - ID3D12Resource *resource = NULL; + ID3D12Resource *resource = 0; hr = IDXGISwapChain3_GetBuffer(swapchain->swapchain, i, &IID_ID3D12Resource, (void **)&resource); if (FAILED(hr)) { /* TODO: Don't panic */ @@ -2656,7 +2656,7 @@ INTERNAL struct swapchain_buffer *update_swapchain(struct swapchain *swapchain, sb->resource = resource; sb->rtv_descriptor = descriptor_alloc(G.rtv_heap); sb->state = D3D12_RESOURCE_STATE_COMMON; - ID3D12Device_CreateRenderTargetView(G.device, sb->resource, NULL, sb->rtv_descriptor->handle); + ID3D12Device_CreateRenderTargetView(G.device, sb->resource, 0, sb->rtv_descriptor->handle); } swapchain->resolution = resolution; @@ -2711,11 +2711,11 @@ INTERNAL void present_blit(struct swapchain_buffer *dst, struct dx12_resource *s ID3D12GraphicsCommandList_ResourceBarrier(cl->cl, 1, &rb); dst->state = rtb.StateAfter; } - ID3D12GraphicsCommandList_OMSetRenderTargets(cl->cl, 1, &dst->rtv_descriptor->handle, false, NULL); + ID3D12GraphicsCommandList_OMSetRenderTargets(cl->cl, 1, &dst->rtv_descriptor->handle, 0, 0); /* Clear */ f32 clear_color[] = { 0.0f, 0.0f, 0.0f, 0.0f }; - ID3D12GraphicsCommandList_ClearRenderTargetView(cl->cl, dst->rtv_descriptor->handle, clear_color, 0, NULL); + ID3D12GraphicsCommandList_ClearRenderTargetView(cl->cl, dst->rtv_descriptor->handle, clear_color, 0, 0); /* Bind pipeline */ ID3D12GraphicsCommandList_SetPipelineState(cl->cl, blit_pipeline->pso); @@ -2786,7 +2786,7 @@ void gp_present(struct sys_window *window, struct v2i32 backresolution, struct g __profn("Present"); HRESULT hr = IDXGISwapChain3_Present(swapchain->swapchain, vsync, present_flags); if (!SUCCEEDED(hr)) { - ASSERT(false); + ASSERT(0); } __profframe(0); } @@ -2822,7 +2822,7 @@ INTERNAL SYS_THREAD_DEF(evictor_thread_entry_point, arg) (UNUSED)arg; struct arena_temp scratch = scratch_begin_no_conflict(); - HANDLE event = CreateEvent(NULL, false, false, NULL); + HANDLE event = CreateEvent(0, 0, 0, 0); HANDLE events[2] = ZI; events[0] = G.evictor_thread_wake_event; events[1] = event; @@ -2839,7 +2839,7 @@ INTERNAL SYS_THREAD_DEF(evictor_thread_entry_point, arg) /* Copy queued data */ u32 num_fenced_releases = 0; - struct fenced_release_data *fenced_releases = NULL; + struct fenced_release_data *fenced_releases = 0; { __profn("Copy queued releases"); struct snc_lock lock = snc_lock_e(&G.fenced_releases_mutex); @@ -2862,7 +2862,7 @@ INTERNAL SYS_THREAD_DEF(evictor_thread_entry_point, arg) ID3D12Fence_SetEventOnCompletion(cq->submit_fence, targets[i], event); { __profn("Wait on fence"); - WaitForMultipleObjects(2, events, false, INFINITE); + WaitForMultipleObjects(2, events, 0, INFINITE); shutdown = atomic_i32_fetch(&G.evictor_thread_shutdown); } } @@ -2878,7 +2878,7 @@ INTERNAL SYS_THREAD_DEF(evictor_thread_entry_point, arg) default: { /* Unknown handle type */ - ASSERT(false); + ASSERT(0); } break; case FENCED_RELEASE_KIND_RESOURCE: diff --git a/src/host.c b/src/host.c index dc7779c5..040eb9cf 100644 --- a/src/host.c +++ b/src/host.c @@ -150,7 +150,7 @@ struct host_msg_assembler_lookup_bin { struct host_msg_assembler *last; }; -READONLY GLOBAL struct host_channel _g_host_channel_nil = { .valid = false }; +READONLY GLOBAL struct host_channel _g_host_channel_nil = { .valid = 0 }; GLOBAL struct { i32 _; @@ -299,7 +299,7 @@ INTERNAL struct host_channel *host_channel_alloc(struct host *host, struct sock_ ++host->num_channels_reserved; } MEMZERO_STRUCT(channel); - channel->valid = true; + channel->valid = 1; channel->id = id; channel->host = host; channel->address = address; @@ -358,7 +358,7 @@ INTERNAL void host_channel_release(struct host_channel *channel) } ++channel->id.gen; - channel->valid = false; + channel->valid = 0; channel->next_free = host->first_free_channel; host->first_free_channel = channel; } @@ -384,7 +384,7 @@ INTERNAL struct host_msg_assembler *host_get_msg_assembler(struct host *host, st return ma; } } - return NULL; + return 0; } INTERNAL struct host_msg_assembler *host_msg_assembler_alloc(struct host_channel *channel, u64 msg_id, u64 chunk_count, u64 now_ns, b32 is_reliable) @@ -528,7 +528,7 @@ INTERNAL b32 host_msg_assembler_is_chunk_filled(struct host_msg_assembler *ma, u if (chunk_id < ma->num_chunks_total) { return (ma->chunk_bitmap[chunk_id / 8] & (1 << (chunk_id % 8))) != 0; } - return false; + return 0; } INTERNAL void host_msg_assembler_set_chunk_received(struct host_msg_assembler *ma, u64 chunk_id) @@ -545,7 +545,7 @@ INTERNAL void host_msg_assembler_set_chunk_received(struct host_msg_assembler *m INTERNAL struct host_snd_packet *host_channel_snd_packet_alloc(struct host_channel *channel, b32 is_reliable) { struct host *host = channel->host; - struct host_snd_packet *packet = NULL; + struct host_snd_packet *packet = 0; if (host->first_free_packet) { packet = host->first_free_packet; host->first_free_packet = packet->next; @@ -686,7 +686,7 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) } } - b32 skip_packet = false; + b32 skip_packet = 0; b32 is_reliable = packet_flags & HOST_PACKET_FLAG_RELIABLE; if (channel->valid) { if (is_reliable) { @@ -694,7 +694,7 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) if (packet_seq == channel->our_acked_seq + 1) { channel->our_acked_seq = packet_seq; } else { - skip_packet = true; + skip_packet = 1; } } } @@ -722,7 +722,7 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) struct host_event *event = push_event(arena, &events); event->kind = HOST_EVENT_KIND_CHANNEL_OPENED; event->channel_id = channel->id; - channel->connected = true; + channel->connected = 1; } } break; @@ -802,12 +802,12 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) } } else { /* Overflow reading chunk */ - ASSERT(false); + ASSERT(0); } } } else { /* Chunk id/count mismatch */ - ASSERT(false); + ASSERT(0); } } } break; @@ -819,8 +819,8 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) } } /* Reset read buffer */ - rcv_buffer->first_packet = NULL; - rcv_buffer->last_packet = NULL; + rcv_buffer->first_packet = 0; + rcv_buffer->last_packet = 0; arena_reset(rcv_buffer->arena); } @@ -862,8 +862,8 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host) } packet = next; } - if (channel->first_reliable_packet == NULL) { - channel->last_reliable_packet = NULL; + if (channel->first_reliable_packet == 0) { + channel->last_reliable_packet = 0; } } /* Release timed out unreliable msg buffers */ @@ -911,7 +911,7 @@ void host_update_end(struct host *host) case HOST_CMD_KIND_TRY_CONNECT: { u8 packet_flags = 0; - struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, false); + struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, 0); struct bitbuff bb = bitbuff_from_string(STRING_FROM_ARRAY(packet->data)); struct bitbuff_writer bw = bw_from_bitbuff(&bb); bw_write_ubits(&bw, PACKET_MAGIC, 32); /* TODO: implicitly encode magic into crc32 */ @@ -924,7 +924,7 @@ void host_update_end(struct host *host) case HOST_CMD_KIND_CONNECT_SUCCESS: { u8 packet_flags = 0; - struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, false); + struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, 0); struct bitbuff bb = bitbuff_from_string(STRING_FROM_ARRAY(packet->data)); struct bitbuff_writer bw = bw_from_bitbuff(&bb); bw_write_ubits(&bw, PACKET_MAGIC, 32); /* TODO: implicitly encode magic into crc32 */ @@ -937,7 +937,7 @@ void host_update_end(struct host *host) case HOST_CMD_KIND_DISCONNECT: { u8 packet_flags = 0; - struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, false); + struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, 0); struct bitbuff bb = bitbuff_from_string(STRING_FROM_ARRAY(packet->data)); struct bitbuff_writer bw = bw_from_bitbuff(&bb); bw_write_ubits(&bw, PACKET_MAGIC, 32); /* TODO: implicitly encode magic into crc32 */ @@ -950,7 +950,7 @@ void host_update_end(struct host *host) case HOST_CMD_KIND_HEARTBEAT: { u8 packet_flags = 0; - struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, false); + struct host_snd_packet *packet = host_channel_snd_packet_alloc(channel, 0); struct bitbuff bb = bitbuff_from_string(STRING_FROM_ARRAY(packet->data)); struct bitbuff_writer bw = bw_from_bitbuff(&bb); bw_write_ubits(&bw, PACKET_MAGIC, 32); /* TODO: implicitly encode magic into crc32 */ @@ -1036,8 +1036,8 @@ void host_update_end(struct host *host) if (channel->first_unreliable_packet) { channel->last_unreliable_packet->next = host->first_free_packet; host->first_free_packet = channel->first_unreliable_packet; - channel->first_unreliable_packet = NULL; - channel->last_unreliable_packet = NULL; + channel->first_unreliable_packet = 0; + channel->last_unreliable_packet = 0; channel->num_unreliable_packets = 0; } host->bytes_sent += total_sent; @@ -1047,8 +1047,8 @@ void host_update_end(struct host *host) /* Reset cmds */ - host->first_cmd = NULL; - host->last_cmd = NULL; + host->first_cmd = 0; + host->last_cmd = 0; arena_reset(host->cmd_arena); scratch_end(scratch); diff --git a/src/incbin.c b/src/incbin.c index c96dd27d..f31a41cd 100644 --- a/src/incbin.c +++ b/src/incbin.c @@ -35,7 +35,7 @@ INTERNAL BOOL CALLBACK enum_func(HMODULE module, LPCWSTR type, LPCWSTR wstr_entr if (hres) { HGLOBAL hg = LoadResource(module, hres); if (hg) { - params->found = true; + params->found = 1; params->data.len = SizeofResource(module, hres); params->data.text = LockResource(hg); } @@ -57,7 +57,7 @@ struct string _incbin_get(struct _incbin_rc_resource *inc) /* Search RC file for the resource name */ struct string name_lower = string_lower(scratch.arena, inc->rc_name); struct rc_search_params params = { .name_lower = name_lower }; - EnumResourceNamesW(NULL, RT_RCDATA, &enum_func, (LONG_PTR)¶ms); + EnumResourceNamesW(0, RT_RCDATA, &enum_func, (LONG_PTR)¶ms); if (!params.found) { sys_panic(string_format(scratch.arena, LIT("INCBIN include not found in RC file: \"%F\""), diff --git a/src/json.c b/src/json.c index 874d0349..da53f47d 100644 --- a/src/json.c +++ b/src/json.c @@ -101,10 +101,10 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) bof->type = TOKEN_TYPE_BOF; u64 pos = 0; - b32 lexing_done = false; + b32 lexing_done = 0; while (!lexing_done) { /* Skip whitespace */ - b32 whitespace_done = false; + b32 whitespace_done = 0; while (!whitespace_done && pos < src.len) { switch (src.text[pos]) { CASE_NEWLINE: @@ -113,7 +113,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) } break; default: { - whitespace_done = true; + whitespace_done = 1; } break; } } @@ -125,7 +125,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) if (pos >= src.len) { t->type = TOKEN_TYPE_EOF; t->next = t; /* Self reference */ - lexing_done = true; + lexing_done = 1; } else { /* Lex known token types */ switch (src.text[pos]) { @@ -163,11 +163,11 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) /* Number */ case '-': { /* Verify '-' precedes digit */ - b32 next_is_digit = false; + b32 next_is_digit = 0; if ((pos + 1) < src.len) { switch (src.text[pos + 1]) { CASE_DIGIT_0_TO_9: { - next_is_digit = true; + next_is_digit = 1; } break; } } @@ -179,7 +179,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) CASE_DIGIT_0_TO_9: { t->type = TOKEN_TYPE_NUMBER; enum lex_number_state state = LEX_NUMBER_STATE_WHOLE; - b32 number_done = false; + b32 number_done = 0; while (!number_done && pos < src.len) { switch (src.text[pos]) { CASE_DIGIT_0_TO_9: { @@ -203,7 +203,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) state = LEX_NUMBER_STATE_FRACTION; pos += consume; } else { - number_done = true; + number_done = 1; } } break; @@ -240,12 +240,12 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) state = LEX_NUMBER_STATE_EXPONENT; pos += consume; } else { - number_done = true; + number_done = 1; } } break; default: { - number_done = true; + number_done = 1; } break; } } @@ -255,29 +255,29 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) case '"': { ++pos; - b32 string_done = false; - b32 next_escaped = false; + b32 string_done = 0; + b32 next_escaped = 0; while (!string_done && pos < src.len) { b32 escaped = next_escaped; - next_escaped = false; + next_escaped = 0; switch (src.text[pos]) { CASE_NEWLINE: { ++pos; - string_done = true; + string_done = 1; } break; case '"': { ++pos; if (!escaped) { t->type = TOKEN_TYPE_STRING; - string_done = true; + string_done = 1; } } break; case '\\': { ++pos; if (!escaped) { - next_escaped = true; + next_escaped = 1; } } break; @@ -294,7 +294,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) case 'n': { struct string keyword = g_keyword_strings[src.text[pos]]; - b32 match = true; + b32 match = 1; if ((pos + keyword.len - 1) < src.len) { if ((pos + keyword.len) < src.len) { /* Don't match if word continues past keyword */ @@ -305,7 +305,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) } break; default: { - match = false; + match = 0; } break; } } @@ -330,13 +330,13 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src) /* Lex unknown token */ if (t->type == TOKEN_TYPE_UNKNOWN) { - b32 unknown_done = false; + b32 unknown_done = 0; while (!unknown_done && pos < src.len) { switch (src.text[pos]) { CASE_SYMBOL: CASE_SPACE: CASE_NEWLINE: { - unknown_done = true; + unknown_done = 1; } break; default: { @@ -368,16 +368,16 @@ INTERNAL void append_char(struct arena *arena, struct string *str, u8 c) INTERNAL f64 interpret_number(struct string src) { - b32 whole_present = false; + b32 whole_present = 0; u64 whole_left = 0; u64 whole_right = 0; i32 whole_sign = 1; - b32 fraction_present = false; + b32 fraction_present = 0; u64 fraction_left = 0; u64 fraction_right = 0; - b32 exponent_present = false; + b32 exponent_present = 0; u64 exponent_left = 0; u64 exponent_right = 0; i32 exponent_sign = 1; @@ -397,7 +397,7 @@ INTERNAL f64 interpret_number(struct string src) switch (state) { case LEX_NUMBER_STATE_WHOLE: { if (!whole_present) { - whole_present = true; + whole_present = 1; whole_left = pos; } whole_right = pos; @@ -406,7 +406,7 @@ INTERNAL f64 interpret_number(struct string src) case LEX_NUMBER_STATE_FRACTION: { if (!fraction_present) { - fraction_present = true; + fraction_present = 1; fraction_left = pos; } fraction_right = pos; @@ -415,7 +415,7 @@ INTERNAL f64 interpret_number(struct string src) case LEX_NUMBER_STATE_EXPONENT: { if (!exponent_present) { - exponent_present = true; + exponent_present = 1; exponent_left = pos; } exponent_right = pos; @@ -449,7 +449,7 @@ INTERNAL f64 interpret_number(struct string src) default: { /* Unreachable */ - ASSERT(false); + ASSERT(0); ++pos; } break; } @@ -464,7 +464,7 @@ INTERNAL f64 interpret_number(struct string src) default: { /* Unreachable */ - ASSERT(false); + ASSERT(0); ++pos; } break; } @@ -472,7 +472,7 @@ INTERNAL f64 interpret_number(struct string src) default: { /* Unreachable */ - ASSERT(false); + ASSERT(0); ++pos; } break; } @@ -544,12 +544,12 @@ INTERNAL struct string interpret_string(struct arena *arena, struct string src, /* Ignore beginning quote */ u64 pos = 1; - b32 valid_close = false; - b32 string_done = false; - b32 next_escaped = false; + b32 valid_close = 0; + b32 string_done = 0; + b32 next_escaped = 0; while (!string_done && pos < src.len) { b32 escaped = next_escaped; - next_escaped = false; + next_escaped = 0; if (escaped) { switch (src.text[pos]) { @@ -607,13 +607,13 @@ INTERNAL struct string interpret_string(struct arena *arena, struct string src, } else { switch (src.text[pos]) { case '\\': { - escaped = true; + escaped = 1; ++pos; } break; case '"': { - string_done = true; - valid_close = true; + string_done = 1; + valid_close = 1; ++pos; } break; @@ -682,12 +682,12 @@ INTERNAL void parse(struct arena *arena, struct parser *p) u64 stack_count = 1; while (stack_count > 0) { - struct json *json = NULL; + struct json *json = 0; arena_pop(scratch.arena, struct json *, &json); --stack_count; struct json *parent_json = json->parent; - b32 is_new_parent = false; + b32 is_new_parent = 0; if (json->type == JSON_TYPE_OBJECT || json->type == JSON_TYPE_ARRAY) { /* No more children to parse for object/array, check for closing brace. */ enum token_type tok_close_type = json->type == JSON_TYPE_OBJECT ? TOKEN_TYPE_CURLY_BRACE_CLOSE : TOKEN_TYPE_SQUARE_BRACE_CLOSE; @@ -761,13 +761,13 @@ INTERNAL void parse(struct arena *arena, struct parser *p) case TOKEN_TYPE_KEYWORD_TRUE: { json->type = JSON_TYPE_BOOL; - json->value.boolean = true; + json->value.boolean = 1; at = at->next; } break; case TOKEN_TYPE_KEYWORD_FALSE: { json->type = JSON_TYPE_BOOL; - json->value.boolean = false; + json->value.boolean = 0; at = at->next; } break; @@ -779,13 +779,13 @@ INTERNAL void parse(struct arena *arena, struct parser *p) case TOKEN_TYPE_CURLY_BRACE_OPEN: { json->type = JSON_TYPE_OBJECT; at = at->next; - is_new_parent = true; + is_new_parent = 1; } break; case TOKEN_TYPE_SQUARE_BRACE_OPEN: { json->type = JSON_TYPE_ARRAY; at = at->next; - is_new_parent = true; + is_new_parent = 1; } break; default: { diff --git a/src/log.c b/src/log.c index a29655d0..28747142 100644 --- a/src/log.c +++ b/src/log.c @@ -71,7 +71,7 @@ void log_startup(struct string logfile_path) /* Keep log file open for appending */ if (sys_is_file(logfile_path)) { G.file = sys_file_open_append(logfile_path); - G.file_valid = true; + G.file_valid = 1; } } atomic_i32_fetch_set(&G.initialized, 1); diff --git a/src/log.h b/src/log.h index 182d5782..75c6fba2 100644 --- a/src/log.h +++ b/src/log.h @@ -46,7 +46,7 @@ struct log_event { struct sys_datetime datetime; i64 time_ns; - /* These will be nulled if LOG_INCLUDE_SOURCE_LOCATION is disabled */ + /* These will be zeroed if LOG_INCLUDE_SOURCE_LOCATION is disabled */ struct string file; i32 line; }; diff --git a/src/mixer.c b/src/mixer.c index 46e5020b..ebc8f193 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -97,7 +97,7 @@ INTERNAL struct track *track_from_handle(struct mixer_track_handle handle) if (track && track->gen == handle.gen) { return track; } else { - return NULL; + return 0; } } @@ -106,14 +106,14 @@ INTERNAL struct track *track_alloc_locked(struct snc_lock *lock, struct sound *s snc_assert_locked_e(lock, &G.mutex); (UNUSED)lock; - struct track *track = NULL; + struct track *track = 0; if (G.track_first_free) { /* Take from free list */ track = G.track_first_free; struct track *next_free = track->next; G.track_first_free = next_free; if (next_free) { - next_free->prev = NULL; + next_free->prev = 0; } *track = (struct track) { .gen = track->gen + 1 }; } else { @@ -164,7 +164,7 @@ INTERNAL void track_release_locked(struct snc_lock *lock, struct track *track) ++track->gen; /* Add to free list */ - track->prev = NULL; + track->prev = 0; track->next = G.track_first_free; if (G.track_first_free) { G.track_first_free->prev = track; @@ -278,7 +278,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count) struct v2 listener_dir = V2(0, 0); /* Create temp array of mixes */ - struct mix **mixes = NULL; + struct mix **mixes = 0; u64 mixes_count = 0; { struct snc_lock lock = snc_lock_e(&G.mutex); @@ -334,7 +334,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count) source_sample_pos_end = source_sample_pos_end % source->pcm.count; } else { source_sample_pos_end = source->pcm.count; - mix->track_finished = true; + mix->track_finished = 1; } } u64 source_frames_count = source_is_stereo ? source_samples_count / 2 : source_samples_count; diff --git a/src/mixer.h b/src/mixer.h index e383f354..73c8684d 100644 --- a/src/mixer.h +++ b/src/mixer.h @@ -11,7 +11,7 @@ struct sound; \ .volume = 1.0, \ .speed = 1.0, \ - .looping = false, \ + .looping = 0, \ \ .pos = V2(0, 0), \ \ diff --git a/src/mp3_mmf.c b/src/mp3_mmf.c index e13425e4..fa3c2327 100644 --- a/src/mp3_mmf.c +++ b/src/mp3_mmf.c @@ -51,20 +51,20 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct string encoded, IStream *i_stream = SHCreateMemStream(encoded.text, encoded.len); /* Create IMFByteStream from IStream */ - IMFByteStream *byte_stream = NULL; + IMFByteStream *byte_stream = 0; MFCreateMFByteStreamOnStream(i_stream, &byte_stream); /* Create reader from IMFByteStream */ IMFSourceReader *reader; - MFCreateSourceReaderFromByteStream(byte_stream, NULL, &reader); + MFCreateSourceReaderFromByteStream(byte_stream, 0, &reader); /* ========================== * * Get media type * ========================== */ /* Read only first audio stream */ - IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, FALSE); - IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, TRUE); + IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_ALL_STREAMS, 0); + IMFSourceReader_SetStreamSelection(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 1); WAVEFORMATEXTENSIBLE format = { .Format = { @@ -85,7 +85,7 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct string encoded, IMFMediaType *type; MFCreateMediaType(&type); MFInitMediaTypeFromWaveFormatEx(type, &format.Format, sizeof(format)); - IMFSourceReader_SetCurrentMediaType(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, NULL, type); + IMFSourceReader_SetCurrentMediaType(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, type); IMFMediaType_Release(type); /* ========================== * @@ -94,17 +94,17 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct string encoded, res.pcm.samples = arena_push_dry(arena, i16); u64 sample_bytes_read = 0; - while (true) { + while (1) { IMFSample *sample; DWORD sample_flags = 0; - HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, NULL, &sample_flags, NULL, &sample); + HRESULT hr = IMFSourceReader_ReadSample(reader, (DWORD)MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, 0, &sample_flags, 0, &sample); if (FAILED(hr)) { break; } /* Check if done */ if (sample_flags & MF_SOURCE_READERF_ENDOFSTREAM) { - res.success = true; + res.success = 1; break; } ASSERT(sample_flags == 0); @@ -115,7 +115,7 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct string encoded, BYTE *src; DWORD size_bytes; - IMFMediaBuffer_Lock(buffer, &src, NULL, &size_bytes); + IMFMediaBuffer_Lock(buffer, &src, 0, &size_bytes); { i16 *dst = arena_push_array_no_zero(arena, i16, (size_bytes + 1) >> 1); MEMCPY(dst, src, size_bytes); diff --git a/src/phys.c b/src/phys.c index 09f92079..d01b5c16 100644 --- a/src/phys.c +++ b/src/phys.c @@ -15,7 +15,7 @@ INTERNAL b32 can_contact(struct sim_ent *e0, struct sim_ent *e1) { - b32 res = false; + b32 res = 0; res = e0 != e1 && !sim_ent_id_eq(e0->top, e1->top) && !(sim_ent_has_prop(e0, SEPROP_WALL) && sim_ent_has_prop(e1, SEPROP_WALL)); @@ -46,7 +46,7 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, struct space_iter iter = space_iter_begin_aabb(space, aabb); struct space_entry *space_entry; - while ((space_entry = space_iter_next(&iter)) != NULL) { + while ((space_entry = space_iter_next(&iter)) != 0) { struct sim_ent *check1 = sim_ent_from_id(ss, space_entry->ent); if (!sim_ent_is_valid_and_active(check1)) continue; if (!(sim_ent_has_prop(check1, SEPROP_SOLID) || sim_ent_has_prop(check1, SEPROP_SENSOR))) continue; @@ -95,11 +95,11 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, STATIC_ASSERT(countof(constraint_ent->contact_constraint_data.points) == 2); STATIC_ASSERT(countof(collider_res.points) == 2); - struct phys_contact_constraint *constraint = NULL; + struct phys_contact_constraint *constraint = 0; if (collider_res.num_points > 0) { - b32 is_start = false; + b32 is_start = 0; if (!constraint_ent->valid) { - is_start = true; + is_start = 1; /* Create constraint */ constraint_ent = sim_ent_alloc_local_with_id(root, constraint_id); constraint_ent->contact_constraint_data.e0 = e0->id; @@ -121,10 +121,10 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, for (u32 i = 0; i < constraint->num_points; ++i) { struct phys_contact_point *old = &constraint->points[i]; u32 id = old->id; - b32 found = false; + b32 found = 0; for (u32 j = 0; j < collider_res.num_points; ++j) { if (collider_res.points[j].id == id) { - found = true; + found = 1; break; } } @@ -141,7 +141,7 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, struct v2 point = res_point->point; f32 sep = res_point->separation; u32 id = res_point->id; - struct phys_contact_point *contact = NULL; + struct phys_contact_point *contact = 0; /* Match */ for (u32 j = 0; j < constraint->num_points; ++j) { struct phys_contact_point *t = &constraint->points[j]; @@ -174,7 +174,7 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, struct v2 dir0 = e0->collision_dir; struct v2 dir1 = e1->collision_dir; f32 threshold = 0.5; - b32 is_wrong_dir = false; + b32 is_wrong_dir = 0; if (!v2_is_zero(dir0)) { is_wrong_dir = v2_dot(dir0, normal) <= threshold; } @@ -226,7 +226,7 @@ void phys_create_and_update_contacts(struct phys_step_ctx *ctx, f32 elapsed_dt, b32 skip_solve0 = collision_callback(&data, sim_step_ctx); b32 skip_solve1 = collision_callback(&data_inverted, sim_step_ctx); if (skip_solve0 || skip_solve1) { - constraint->skip_solve = true; + constraint->skip_solve = 1; } } } else if (constraint_ent->valid) { @@ -1184,14 +1184,14 @@ f32 phys_determine_earliest_toi(struct phys_step_ctx *ctx, f32 step_dt, f32 tole struct xform e0_xf_t0 = sim_ent_get_xform(e0); struct xform e0_xf_t1 = get_derived_xform(e0, step_dt); - /* TODO: Use swept aabb rather than combined aabb. This should prevent spikes from bullets returning false positive TOIs with irrelevant entities. */ + /* TODO: Use swept aabb rather than combined aabb. This should prevent spikes from bullets returning 0 positive TOIs with irrelevant entities. */ struct aabb aabb_t0 = collider_aabb_from_collider(&e0_collider, e0_xf_t0); struct aabb aabb_t1 = collider_aabb_from_collider(&e0_collider, e0_xf_t1); struct aabb combined_aabb = collider_aabb_from_combined_aabb(aabb_t0, aabb_t1); struct space_iter iter = space_iter_begin_aabb(space, combined_aabb); struct space_entry *entry; - while ((entry = space_iter_next(&iter)) != NULL) { + while ((entry = space_iter_next(&iter)) != 0) { struct sim_ent *e1 = sim_ent_from_id(ss, entry->ent); if (!sim_ent_should_simulate(e1)) continue; if (!(sim_ent_has_prop(e1, SEPROP_SOLID) || sim_ent_has_prop(e1, SEPROP_SENSOR))) continue; @@ -1294,7 +1294,7 @@ void phys_step(struct phys_step_ctx *ctx, f32 timestep) /* Solve */ #if SIM_PHYSICS_ENABLE_COLLISION - phys_solve_contacts(ctx, substep_dt, true); + phys_solve_contacts(ctx, substep_dt, 1); #endif phys_solve_motor_joints(ctx, substep_dt); phys_solve_mouse_joints(ctx, substep_dt); @@ -1305,7 +1305,7 @@ void phys_step(struct phys_step_ctx *ctx, f32 timestep) /* Relaxation solve */ #if SIM_PHYSICS_ENABLE_COLLISION && SIM_PHYSICS_ENABLE_RELAXATION - phys_solve_contacts(ctx, substep_dt, false); + phys_solve_contacts(ctx, substep_dt, 0); #endif } diff --git a/src/phys.h b/src/phys.h index a5bb5d05..aa9704e1 100644 --- a/src/phys.h +++ b/src/phys.h @@ -19,7 +19,7 @@ struct phys_collision_data { f32 dt; /* How much time elapsed in the step when this event occurred (this will equal the physics timestep unless an early time of impact occurred) */ }; -/* Callback can return true to prevent the physics system from resolving */ +/* Callback can return 1 to prevent the physics system from resolving */ #define PHYS_COLLISION_CALLBACK_FUNC_DEF(name, arg_collision_data, arg_sim_step_ctx) b32 name(struct phys_collision_data *arg_collision_data, struct sim_step_ctx *arg_sim_step_ctx) typedef PHYS_COLLISION_CALLBACK_FUNC_DEF(phys_collision_callback_func, collision_data, ctx); diff --git a/src/playback_wasapi.c b/src/playback_wasapi.c index 08c4ce6a..42cc28b0 100644 --- a/src/playback_wasapi.c +++ b/src/playback_wasapi.c @@ -60,7 +60,7 @@ struct playback_startup_receipt playback_startup(struct mixer_startup_receipt *m (UNUSED)mixer_sr; wasapi_initialize(); - G.playback_scheduler_thread = sys_thread_alloc(playback_scheduler_entry, NULL, LIT("Playback scheduler thread"), PROF_THREAD_GROUP_SCHEDULER); + G.playback_scheduler_thread = sys_thread_alloc(playback_scheduler_entry, 0, LIT("Playback scheduler thread"), PROF_THREAD_GROUP_SCHEDULER); app_register_exit_callback(&playback_shutdown); return (struct playback_startup_receipt) { 0 }; @@ -69,7 +69,7 @@ struct playback_startup_receipt playback_startup(struct mixer_startup_receipt *m INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(playback_shutdown) { __prof; - atomic_i32_fetch_set(&G.shutdown, true); + atomic_i32_fetch_set(&G.shutdown, 1); sys_thread_wait_release(G.playback_scheduler_thread); } @@ -85,7 +85,7 @@ INTERNAL void wasapi_initialize(void) /* Create enumerator to get audio device */ IMMDeviceEnumerator *enumerator; - CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (LPVOID *)&enumerator); + CoCreateInstance(&CLSID_MMDeviceEnumerator, 0, CLSCTX_ALL, &IID_IMMDeviceEnumerator, (LPVOID *)&enumerator); /* Get default playback device */ IMMDevice *device; @@ -93,7 +93,7 @@ INTERNAL void wasapi_initialize(void) IMMDeviceEnumerator_Release(enumerator); /* Create audio client for device */ - IMMDevice_Activate(device, &IID_IAudioClient, CLSCTX_ALL, NULL, (LPVOID *)&G.client); + IMMDevice_Activate(device, &IID_IAudioClient, CLSCTX_ALL, 0, (LPVOID *)&G.client); IMMDevice_Release(device); WAVEFORMATEXTENSIBLE format_ex = { @@ -113,7 +113,7 @@ INTERNAL void wasapi_initialize(void) WAVEFORMATEX *wfx = &format_ex.Format; #if 0 - b32 client_initialized = FALSE; + b32 client_initialized = 0; IAudioClient3 *client3; if (SUCCEEDED(IAudioClient_QueryInterface(G.client, &IID_IAudioClient3, (LPVOID *)&client3))) { /* From Martins: Minimum buffer size will typically be 480 samples (10msec @ 48khz) @@ -124,20 +124,20 @@ INTERNAL void wasapi_initialize(void) IAudioClient3_GetSharedModeEnginePeriod(client3, wfx, &default_period_samples, &fundamental_period_samples, &min_period_samples, &max_period_samples); const DWORD flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK; - if (SUCCEEDED(IAudioClient3_InitializeSharedAudioStream(client3, flags, min_period_samples, wfx, NULL))) { - client_initialized = TRUE; + if (SUCCEEDED(IAudioClient3_InitializeSharedAudioStream(client3, flags, min_period_samples, wfx, 0))) { + client_initialized = 1; } IAudioClient3_Release(client3); } #else - b32 client_initialized = false; + b32 client_initialized = 0; #endif if (!client_initialized) { /* Get duration for shared-mode streams, this will typically be 480 samples (10msec @ 48khz) */ REFERENCE_TIME duration; - IAudioClient_GetDevicePeriod(G.client, &duration, NULL); + IAudioClient_GetDevicePeriod(G.client, &duration, 0); /* Initialize audio playback * @@ -147,13 +147,13 @@ INTERNAL void wasapi_initialize(void) * but allows for any input format. */ const DWORD flags = AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY; - IAudioClient_Initialize(G.client, AUDCLNT_SHAREMODE_SHARED, flags, duration, 0, wfx, NULL); + IAudioClient_Initialize(G.client, AUDCLNT_SHAREMODE_SHARED, flags, duration, 0, wfx, 0); } IAudioClient_GetMixFormat(G.client, &G.buffer_format); /* Set up event handler to wait on */ - G.event = CreateEventW(NULL, FALSE, FALSE, NULL); + G.event = CreateEventW(0, 0, 0, 0); IAudioClient_SetEventHandle(G.client, G.event); /* Get playback client */ @@ -207,7 +207,7 @@ INTERNAL void wasapi_update_end(struct wasapi_buffer *wspbuf, struct mixed_pcm_f /* This shouldn't occur, mixer should be generating samples equivilent * to value returned from `playback_update_begin`. */ - ASSERT(false); + ASSERT(0); } #if !AUDIO_ENABLED @@ -256,7 +256,7 @@ INTERNAL SYS_THREAD_DEF(playback_scheduler_entry, _) { __profn("Run mix job & wait"); struct snc_counter counter = ZI; - sys_run(1, playback_mix_job, NULL, SYS_PRIORITY_CRITICAL, &counter); + sys_run(1, playback_mix_job, 0, SYS_PRIORITY_CRITICAL, &counter); snc_counter_wait(&counter); } } diff --git a/src/prof_tracy.h b/src/prof_tracy.h index df55c783..1e9903b7 100644 --- a/src/prof_tracy.h +++ b/src/prof_tracy.h @@ -32,9 +32,9 @@ #include TRACY_CLIENT_HEADER_PATH INLINE void __prof_zone_cleanup_func(TracyCZoneCtx *ctx) { TracyCZoneEnd(*ctx) } -#define __profnc(name, color) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { (name), __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), true ) +#define __profnc(name, color) static const struct ___tracy_source_location_data CAT(__tracy_source_location,__LINE__) = { (name), __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_zone_cleanup_func))) TracyCZoneCtx __tracy_zone_ctx = ___tracy_emit_zone_begin( &CAT(__tracy_source_location,__LINE__), 1 ) #define __profn(name) __profnc(name, 0) -#define __prof __profnc(NULL, 0) +#define __prof __profnc(0, 0) #define __profvalue(v) TracyCZoneValue(__tracy_zone_ctx, (v)) #define __profalloc(ptr, size) TracyCAlloc((ptr), (size)) @@ -109,14 +109,14 @@ enum __prof_plot_type { #if PROFILING_D3D /* Dx11 */ INLINE void __prof_dx11_zone_cleanup_func(TracyCD3D11ZoneCtx *ctx) { ___tracy_d3d11_emit_zone_end(*ctx); } -# define __profnc_dx11(dx11_ctx, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d11_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx11_zone_cleanup_func))) TracyCD3D11ZoneCtx __tracy_d3d11_zone_ctx; ___tracy_d3d11_emit_zone_begin( dx11_ctx, &__tracy_d3d11_zone_ctx, &CAT(__tracy_gpu_d3d11_source_location,__LINE__), true) +# define __profnc_dx11(dx11_ctx, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d11_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx11_zone_cleanup_func))) TracyCD3D11ZoneCtx __tracy_d3d11_zone_ctx; ___tracy_d3d11_emit_zone_begin( dx11_ctx, &__tracy_d3d11_zone_ctx, &CAT(__tracy_gpu_d3d11_source_location,__LINE__), 1) # define __prof_dx11_ctx(name) struct TracyCD3D11Ctx *name # define __prof_dx11_ctx_alloc(ctx, device, device_ctx, name, name_len) ctx = ___tracy_d3d11_context_announce(device, device_ctx, name, name_len) # define __prof_dx11_ctx_release(ctx) ___tracy_d3d11_context_terminate(ctx) # define __prof_dx11_collect(ctx) ___tracy_d3d11_context_collect(ctx) /* Dx12 */ INLINE void __prof_dx12_zone_cleanup_func(TracyCD3D12ZoneCtx *ctx) { ___tracy_d3d12_emit_zone_end(*ctx); } -# define __profnc_dx12(dx12_ctx, cmd_list, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d12_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx12_zone_cleanup_func))) TracyCD3D12ZoneCtx __tracy_d3d12_zone_ctx; ___tracy_d3d12_emit_zone_begin( dx12_ctx, cmd_list, &__tracy_d3d12_zone_ctx, &CAT(__tracy_gpu_d3d12_source_location,__LINE__), true) +# define __profnc_dx12(dx12_ctx, cmd_list, name, color) static const struct ___tracy_source_location_data CAT(__tracy_gpu_d3d12_source_location,__LINE__) = { name, __func__, __FILE__, (uint32_t)__LINE__, BGR32(color) }; __attribute((cleanup(__prof_dx12_zone_cleanup_func))) TracyCD3D12ZoneCtx __tracy_d3d12_zone_ctx; ___tracy_d3d12_emit_zone_begin( dx12_ctx, cmd_list, &__tracy_d3d12_zone_ctx, &CAT(__tracy_gpu_d3d12_source_location,__LINE__), 1) # define __prof_dx12_ctx(name) struct TracyCD3D12Ctx *name # define __prof_dx12_ctx_alloc(ctx, device, queue, name, name_len) ctx = ___tracy_d3d12_context_announce(device, queue, name, name_len) # define __prof_dx12_ctx_release(ctx) ___tracy_d3d12_context_terminate(ctx) diff --git a/src/resource.c b/src/resource.c index e6b4d51f..c468d2e9 100644 --- a/src/resource.c +++ b/src/resource.c @@ -73,8 +73,8 @@ struct resource_startup_receipt resource_startup(void) G.watch_dispatcher_info_arena = arena_alloc(GIBI(64)); app_register_exit_callback(&resource_shutdown); - G.resource_watch_monitor_thread = sys_thread_alloc(resource_watch_monitor_thread_entry_point, NULL, LIT("Resource watch monitor"), PROF_THREAD_GROUP_IO); - G.resource_watch_dispatch_thread = sys_thread_alloc(resource_watch_dispatcher_thread_entry_point, NULL, LIT("Resource watch dispatcher"), PROF_THREAD_GROUP_IO); + G.resource_watch_monitor_thread = sys_thread_alloc(resource_watch_monitor_thread_entry_point, 0, LIT("Resource watch monitor"), PROF_THREAD_GROUP_IO); + G.resource_watch_dispatch_thread = sys_thread_alloc(resource_watch_dispatcher_thread_entry_point, 0, LIT("Resource watch dispatcher"), PROF_THREAD_GROUP_IO); #endif @@ -94,7 +94,7 @@ struct resource resource_open(struct string name) if (entry) { res._data = entry->data; res._name = entry->file_name; - res._exists = true; + res._exists = 1; } return res; #else @@ -134,7 +134,7 @@ struct resource resource_open(struct string name) res._name_len = name.len; MEMCPY(res._name_text, name.text, name.len); } else { - ASSERT(false); + ASSERT(0); } return res; #endif @@ -247,7 +247,7 @@ INTERNAL SYS_THREAD_DEF(resource_watch_dispatcher_thread_entry_point, _) { __profn("Delay"); snc_unlock(&watch_dispatcher_lock); - sys_wait(NULL, NULL, 0, NS_FROM_SECONDS(WATCH_DISPATCHER_DELAY_SECONDS)); + sys_wait(0, 0, 0, NS_FROM_SECONDS(WATCH_DISPATCHER_DELAY_SECONDS)); watch_dispatcher_lock = snc_lock_e(&G.watch_dispatcher_mutex); } if (!atomic_i32_fetch(&G.watch_shutdown)) { @@ -260,7 +260,7 @@ INTERNAL SYS_THREAD_DEF(resource_watch_dispatcher_thread_entry_point, _) /* Build callbacks array */ u64 num_callbacks = 0; - resource_watch_callback **callbacks = NULL; + resource_watch_callback **callbacks = 0; struct snc_lock callbacks_lock = snc_lock_s(&G.watch_callbacks_mutex); { num_callbacks = G.num_watch_callbacks; @@ -278,10 +278,10 @@ INTERNAL SYS_THREAD_DEF(resource_watch_dispatcher_thread_entry_point, _) for (struct sys_watch_info *info = watch_info_list.first; info; info = info->next) { __profn("Dispatch"); /* Do not run callbacks for the same file more than once */ - b32 skip = false; + b32 skip = 0; u64 hash = hash_fnv64(HASH_FNV64_BASIS, info->name); if (dict_get(dedup_dict, hash) == 1) { - skip = true; + skip = 1; } else { dict_set(temp.arena, dedup_dict, hash, 1); } diff --git a/src/settings.c b/src/settings.c index 59133ba7..d9a6f6c2 100644 --- a/src/settings.c +++ b/src/settings.c @@ -71,12 +71,12 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct str goto abort; } - b32 found_maximized = false; - b32 found_fullscreen = false; - b32 found_x = false; - b32 found_y = false; - b32 found_width = false; - b32 found_height = false; + b32 found_maximized = 0; + b32 found_fullscreen = 0; + b32 found_x = 0; + b32 found_y = 0; + b32 found_width = 0; + b32 found_height = 0; for (struct json *child = window->child_first; child; child = child->next) { struct string key = child->key; @@ -88,7 +88,7 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct str if (child->value.boolean) { settings->flags |= SYS_WINDOW_SETTINGS_FLAG_MAXIMIZED; } - found_maximized = true; + found_maximized = 1; } else if (string_eq(key, LIT("fullscreen"))) { if (child->type != JSON_TYPE_BOOL) { error = LIT("Expected boolean for \"fulscreen\""); @@ -97,35 +97,35 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct str if (child->value.boolean) { settings->flags |= SYS_WINDOW_SETTINGS_FLAG_FULLSCREEN; } - found_fullscreen = true; + found_fullscreen = 1; } else if (string_eq(key, LIT("x"))) { if (child->type != JSON_TYPE_NUMBER) { error = LIT("Expected number for \"x\""); goto abort; } settings->floating_x = math_round_to_int(child->value.number); - found_x = true; + found_x = 1; } else if (string_eq(key, LIT("y"))) { if (child->type != JSON_TYPE_NUMBER) { error = LIT("Expected number for \"y\""); goto abort; } settings->floating_y = math_round_to_int(child->value.number); - found_y = true; + found_y = 1; } else if (string_eq(key, LIT("width"))) { if (child->type != JSON_TYPE_NUMBER) { error = LIT("Expected number for \"width\""); goto abort; } settings->floating_width = math_round_to_int(child->value.number); - found_width = true; + found_width = 1; } else if (string_eq(key, LIT("height"))) { if (child->type != JSON_TYPE_NUMBER) { error = LIT("Expected number for \"height\""); goto abort; } settings->floating_height = math_round_to_int(child->value.number); - found_height = true; + found_height = 1; } } diff --git a/src/sim.c b/src/sim.c index e57018fe..eb8ae3b4 100644 --- a/src/sim.c +++ b/src/sim.c @@ -66,26 +66,26 @@ struct sim_startup_receipt sim_startup(void) /* Nil client store */ G.nil_client_store = arena_push(G.nil_arena, struct sim_client_store); - G.nil_client_store->valid = false; + G.nil_client_store->valid = 0; /* Nil client */ G.nil_client = arena_push(G.nil_arena, struct sim_client); - G.nil_client->valid = false; + G.nil_client->valid = 0; G.nil_client->store = sim_client_store_nil(); /* Nil snapshot */ G.nil_snapshot = arena_push(G.nil_arena, struct sim_snapshot); - G.nil_snapshot->valid = false; + G.nil_snapshot->valid = 0; G.nil_snapshot->client = sim_client_nil(); /* Nil ent */ G.nil_ent = arena_push(G.nil_arena, struct sim_ent); G.nil_ent->ss = sim_snapshot_nil(); - G.nil_ent->valid = false; + G.nil_ent->valid = 0; G.nil_ent->id = SIM_ENT_NIL_ID; G.nil_ent->_local_xform = XFORM_IDENT; G.nil_ent->_xform = XFORM_IDENT; - G.nil_ent->_is_xform_dirty = false; + G.nil_ent->_is_xform_dirty = 0; G.nil_ent->friction = 0.5f; G.nil_ent->mass_unscaled = 1; G.nil_ent->inertia_unscaled = 1; @@ -110,7 +110,7 @@ struct sim_client_store *sim_client_store_alloc(void) store = arena_push(arena, struct sim_client_store); store->arena = arena; } - store->valid = true; + store->valid = 1; store->num_client_lookup_bins = CLIENT_LOOKUP_BINS; store->client_lookup_bins = arena_push_array(store->arena, struct sim_client_lookup_bin, store->num_client_lookup_bins); store->clients_arena = arena_alloc(GIBI(64)); @@ -153,7 +153,7 @@ struct sim_client *sim_client_alloc(struct sim_client_store *store) ++store->num_clients_allocated; *client = *sim_client_nil(); client->store = store; - client->valid = true; + client->valid = 1; client->handle = handle; client->snapshots_arena = arena_alloc(GIBI(8)); @@ -182,7 +182,7 @@ void sim_client_release(struct sim_client *client) /* Release client */ struct sim_client_store *store = client->store; - client->valid = false; + client->valid = 0; client->next_free = store->first_free_client; store->first_free_client = client->handle; --store->num_clients_allocated; @@ -283,7 +283,7 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn struct sim_snapshot *ss; { struct arena *arena = ZI; - struct arena *ents_arena = NULL; + struct arena *ents_arena = 0; { ss = client->first_free_snapshot; if (ss) { @@ -306,7 +306,7 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn } ss->tick = tick; - ss->valid = true; + ss->valid = 1; ss->client = client; ++client->num_ticks; @@ -348,8 +348,8 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn struct sim_ent *root = arena_push_no_zero(ss->ents_arena, struct sim_ent); *root = *sim_ent_nil(); root->ss = ss; - root->valid = true; - root->is_root = true; + root->valid = 1; + root->is_root = 1; root->mass_unscaled = F32_INFINITY; root->inertia_unscaled = F32_INFINITY; sim_ent_set_id(root, SIM_ENT_ROOT_ID); @@ -459,7 +459,7 @@ void sim_snapshot_release(struct sim_snapshot *ss) } } - ss->valid = false; + ss->valid = 0; ss->next_free = client->first_free_snapshot; client->first_free_snapshot = ss; --client->num_ticks; @@ -625,21 +625,21 @@ struct sim_snapshot *sim_snapshot_alloc_from_lerp(struct sim_client *client, str ASSERT(ss0->client != client && ss1->client != client); struct sim_snapshot *ss; - b32 should_blend = true; + b32 should_blend = 1; if (ss0->continuity_gen == ss1->continuity_gen && 0 < blend && blend < 1) { ss = sim_snapshot_alloc(client, ss0, ss0->tick); } else if (math_round_to_int64(blend) <= 0) { ss = sim_snapshot_alloc(client, ss0, ss0->tick); - should_blend = false; + should_blend = 0; } else { ss = sim_snapshot_alloc(client, ss1, ss1->tick); - should_blend = false; + should_blend = 0; } if (!ss0->valid || !ss1->valid) { /* New snapshot allocation caused one of the src snapshots original to release. * ss0 & ss1 should be from a separate client than the allocating one. */ - ASSERT(false); + ASSERT(0); } if (should_blend) { @@ -691,7 +691,7 @@ void sim_snapshot_sync_ents(struct sim_snapshot *local_ss, struct sim_snapshot * if (local_ent->valid && sim_ent_has_prop(local_ent, SEPROP_SYNC_DST)) { b32 should_sync = sim_ent_id_eq(local_ent->owner, remote_player) || sim_ent_id_is_nil(remote_player); if ((sync_flags & SIM_SYNC_FLAG_NOSYNC_PREDICTABLES) && sim_ent_id_eq(local_ent->predictor, local_ss->local_player)) { - should_sync = false; + should_sync = 0; } if (should_sync) { struct sim_ent *remote_ent = sim_ent_from_id(remote_ss, local_ent->id); @@ -827,7 +827,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) } } else { /* Invalid bin index */ - ASSERT(false); + ASSERT(0); } bin_changed = br_read_bit(br); @@ -854,7 +854,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) } else if (reserve_diff < 0) { /* TODO: Handle this */ /* NOTE: Should be impossible for snasphot reserve count to decrease at the moment */ - ASSERT(false); + ASSERT(0); } } @@ -982,7 +982,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) /* TODO: Delta decode index based on last read index */ u32 index = br_read_uv(br); b32 allocation_changed = br_read_bit(br); - b32 released = false; + b32 released = 0; u32 alloc_parent_index = ZI; struct sim_ent_id alloc_ent_id = ZI; @@ -1031,12 +1031,12 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) ASSERT(parent->valid); /* Parent for new entity allocation should always be valid */ if (parent->valid && index < ss->num_ents_reserved) { struct sim_ent *ent = &ss->ents[index]; - ent->valid = true; + ent->valid = 1; sim_ent_set_id(ent, n->alloc_ent_id); sim_ent_link_parent(parent, ent); } else { /* Received an invalid entity allocation */ - ASSERT(false); + ASSERT(0); } } } @@ -1050,7 +1050,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) sim_ent_decode(&ent_br, e); } else { /* Received delta for unallocated ent */ - ASSERT(false); + ASSERT(0); } } #else @@ -1088,7 +1088,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss) e->ss = ss; b32 valid_changed = br_read_bit(br); - b32 allocated = true; + b32 allocated = 1; if (valid_changed) { allocated = br_read_bit(br); } diff --git a/src/sim_ent.c b/src/sim_ent.c index 60ad01a4..d6c06fde 100644 --- a/src/sim_ent.c +++ b/src/sim_ent.c @@ -45,9 +45,9 @@ struct sim_ent *sim_ent_alloc_raw(struct sim_snapshot *ss, struct sim_ent *paren } *ent = *sim_ent_nil(); ent->ss = ss; - ent->valid = true; + ent->valid = 1; ent->owner = ss->client->player_id; - ent->_is_xform_dirty = true; + ent->_is_xform_dirty = 1; ++ss->num_ents_allocated; sim_ent_set_id(ent, id); @@ -117,7 +117,7 @@ void sim_ent_release_raw(struct sim_ent *ent) sim_ent_set_id(ent, SIM_ENT_NIL_ID); /* Release */ - ent->valid = false; + ent->valid = 0; ent->next_free = ss->first_free_ent; ss->first_free_ent = index_from_ent(ss, ent); --ss->num_ents_allocated; @@ -328,10 +328,10 @@ struct sim_ent *sim_ent_find_first_match_all(struct sim_snapshot *ss, struct sim for (u64 ent_index = 0; ent_index < count; ++ent_index) { struct sim_ent *ent = &entities[ent_index]; if (ent->valid) { - b32 all = true; + b32 all = 1; for (u64 i = 0; i < props.count; ++i) { if (!sim_ent_has_prop(ent, props.props[i])) { - all = false; + all = 0; break; } } @@ -369,7 +369,7 @@ void sim_ent_link_parent(struct sim_ent *ent, struct sim_ent *parent) parent->last = ent_id; if (parent->is_root) { - ent->is_top = true; + ent->is_top = 1; ent->top = ent_id; } else { ent->top = parent->top; @@ -413,7 +413,7 @@ INTERNAL void sim_ent_mark_child_xforms_dirty(struct sim_snapshot *ss, struct si if (child->_is_xform_dirty) { break; } else { - child->_is_xform_dirty = true; + child->_is_xform_dirty = 1; sim_ent_mark_child_xforms_dirty(ss, child); } } @@ -430,10 +430,10 @@ INTERNAL struct xform sim_ent_get_xform_internal(struct sim_snapshot *ss, struct xf = sim_ent_get_xform_internal(ss, parent); xf = xform_mul(xf, ent->_local_xform); ent->_xform = xf; - ent->_is_xform_dirty = false; + ent->_is_xform_dirty = 0; } ent->_xform = xf; - ent->_is_xform_dirty = false; + ent->_is_xform_dirty = 0; } else { xf = ent->_xform; } @@ -452,10 +452,10 @@ struct xform sim_ent_get_xform(struct sim_ent *ent) xf = sim_ent_get_xform_internal(ss, parent); xf = xform_mul(xf, ent->_local_xform); ent->_xform = xf; - ent->_is_xform_dirty = false; + ent->_is_xform_dirty = 0; } ent->_xform = xf; - ent->_is_xform_dirty = false; + ent->_is_xform_dirty = 0; } else { xf = ent->_xform; } @@ -480,7 +480,7 @@ void sim_ent_set_xform(struct sim_ent *ent, struct xform xf) ent->_local_xform = xform_mul(xform_invert(parent_global), xf); } ent->_xform = xf; - ent->_is_xform_dirty = false; + ent->_is_xform_dirty = 0; sim_ent_mark_child_xforms_dirty(ss, ent); } } @@ -489,7 +489,7 @@ void sim_ent_set_local_xform(struct sim_ent *ent, struct xform xf) { if (!xform_eq(xf, ent->_local_xform)) { ent->_local_xform = xf; - ent->_is_xform_dirty = true; + ent->_is_xform_dirty = 1; sim_ent_mark_child_xforms_dirty(ent->ss, ent); } } @@ -752,7 +752,7 @@ void sim_ent_encode(struct bitbuff_writer *bw, struct sim_ent *e0, struct sim_en /* FIXME: Things like xforms need to be retreived manually rather than memcopied. - * This will also be true for things like ent handles once uids are implemented. */ + * This will also be true for things like ent handles once uids are implemented. */ /* TODO: Granular delta encoding */ diff --git a/src/sim_ent.h b/src/sim_ent.h index d4fc037f..3e10ca03 100644 --- a/src/sim_ent.h +++ b/src/sim_ent.h @@ -482,9 +482,9 @@ INLINE b32 sim_ent_is_owner(struct sim_ent *ent) INLINE b32 sim_ent_should_simulate(struct sim_ent *ent) { - b32 res = false; + b32 res = 0; if (sim_ent_is_valid_and_active(ent)) { - res = true; + res = 1; if (sim_ent_has_prop(ent, SEPROP_SYNC_DST)) { struct sim_ent_id local_player = ent->ss->local_player; res = sim_ent_id_eq(local_player, ent->owner) || sim_ent_id_eq(local_player, ent->predictor); diff --git a/src/sim_step.c b/src/sim_step.c index 485321df..42068709 100644 --- a/src/sim_step.c +++ b/src/sim_step.c @@ -429,8 +429,8 @@ INTERNAL void test_generate_walls(struct sim_snapshot *world) /* Release existing walls and gather tile chunks. * NOTE: We sort tile chunks before iterating so that chunk-edge tiles only * need to check for adjacent walls to merge with in one direction */ - struct sim_ent **x_sorted_tile_chunks = NULL; - struct sim_ent **y_sorted_tile_chunks = NULL; + struct sim_ent **x_sorted_tile_chunks = 0; + struct sim_ent **y_sorted_tile_chunks = 0; u64 sorted_tile_chunks_count = 0; { x_sorted_tile_chunks = arena_push_dry(scratch.arena, struct sim_ent *); @@ -451,8 +451,8 @@ INTERNAL void test_generate_walls(struct sim_snapshot *world) /* NOTE: We sort x & y separately because it's possible that a wall * should merge with another wall that was generated from a diagonal chunk. */ - merge_sort(x_sorted_tile_chunks, sorted_tile_chunks_count, sizeof(*x_sorted_tile_chunks), tile_chunk_sort_x, NULL); - merge_sort(y_sorted_tile_chunks, sorted_tile_chunks_count, sizeof(*y_sorted_tile_chunks), tile_chunk_sort_y, NULL); + merge_sort(x_sorted_tile_chunks, sorted_tile_chunks_count, sizeof(*x_sorted_tile_chunks), tile_chunk_sort_x, 0); + merge_sort(y_sorted_tile_chunks, sorted_tile_chunks_count, sizeof(*y_sorted_tile_chunks), tile_chunk_sort_y, 0); } struct wall_node { @@ -467,7 +467,7 @@ INTERNAL void test_generate_walls(struct sim_snapshot *world) struct dict *horizontal_ends_dict = dict_init(scratch.arena, 1024); struct dict *vertical_ends_dict = dict_init(scratch.arena, 1024); - struct wall_node *first_wall = NULL; + struct wall_node *first_wall = 0; /* Generate horizontal wall nodes */ for (u64 sorted_index = 0; sorted_index < sorted_tile_chunks_count; ++sorted_index) { @@ -515,7 +515,7 @@ INTERNAL void test_generate_walls(struct sim_snapshot *world) if (wall_dir >= 0 && desired_wall_dir != wall_dir) { struct v2i32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32(wall_start, tile_y)); struct v2i32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32(wall_end, tile_y)); - struct wall_node *node = NULL; + struct wall_node *node = 0; if (wall_start == 0) { u64 start_hash = rand_u64_from_seed(*(u64 *)&start); start_hash = rand_u64_from_seeds(start_hash, wall_dir); @@ -605,7 +605,7 @@ INTERNAL void test_generate_walls(struct sim_snapshot *world) if (wall_dir >= 0 && desired_wall_dir != wall_dir) { struct v2i32 start = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32(tile_x, wall_start)); struct v2i32 end = sim_world_tile_index_from_local_tile_index(chunk_index, V2I32(tile_x, wall_end)); - struct wall_node *node = NULL; + struct wall_node *node = 0; if (wall_start == 0) { u64 start_hash = rand_u64_from_seed(*(u64 *)&start); start_hash = rand_u64_from_seeds(start_hash, wall_dir); @@ -705,7 +705,7 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, data, step_ctx) struct sim_ent *e0 = sim_ent_from_id(world, data->e0); struct sim_ent *e1 = sim_ent_from_id(world, data->e1); struct sim_ent *root = sim_ent_from_id(world, SIM_ENT_ROOT_ID); - b32 skip_solve = false; + b32 skip_solve = 0; if (sim_ent_should_simulate(e0) && sim_ent_should_simulate(e1)) { /* Bullet impact */ @@ -765,7 +765,7 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, data, step_ctx) } /* Update bullet */ - bullet->bullet_has_hit = true; + bullet->bullet_has_hit = 1; sim_ent_enable_prop(bullet, SEPROP_RELEASE); } } @@ -966,7 +966,7 @@ void sim_step(struct sim_step_ctx *ctx) if (sim_ent_has_prop(cmd_ent, SEPROP_CMD)) { struct sim_ent *player = sim_ent_from_id(world, cmd_ent->cmd_player); if (sim_ent_should_simulate(player)) { - b32 persist_cmd = false; + b32 persist_cmd = 0; if (!is_master && !sim_ent_id_eq(player->id, world->local_player)) { /* We are not the master and the command is not our own, skip processing */ continue; @@ -977,7 +977,7 @@ void sim_step(struct sim_step_ctx *ctx) case SIM_CMD_KIND_CONTROL: { /* Player's will send control cmds a lot, so keep it around to prevent re-creating it each time */ - persist_cmd = true; + persist_cmd = 1; /* Process control cmd for player */ struct sim_control old_control = player->player_control; @@ -988,8 +988,8 @@ void sim_step(struct sim_step_ctx *ctx) player->player_cursor_pos = control->dbg_cursor; player->player_hovered_ent = cmd_ent->cmd_control_hovered_ent; - player->player_dbg_drag_start = false; - player->player_dbg_drag_stop = false; + player->player_dbg_drag_start = 0; + player->player_dbg_drag_stop = 0; /* Cap movement vector magnitude */ if (v2_len_sq(control->move) > 1) { @@ -1000,11 +1000,11 @@ void sim_step(struct sim_step_ctx *ctx) if (ctx->is_master) { if (flags & SIM_CONTROL_FLAG_DRAG) { if (!(old_control.flags & SIM_CONTROL_FLAG_DRAG)) { - player->player_dbg_drag_start = true; + player->player_dbg_drag_start = 1; } } else { if (old_control.flags & SIM_CONTROL_FLAG_DRAG) { - player->player_dbg_drag_stop = true; + player->player_dbg_drag_stop = 1; } } if (flags & SIM_CONTROL_FLAG_DELETE) { @@ -1090,7 +1090,7 @@ void sim_step(struct sim_step_ctx *ctx) default: { /* Invalid cmd kind */ - ASSERT(false); + ASSERT(0); } break; } @@ -1219,7 +1219,7 @@ void sim_step(struct sim_step_ctx *ctx) /* Test collider */ #if 0 if (sim_ent_has_prop(ent, SEPROP_TEST)) { - //if ((true)) { + //if ((1)) { #if 0 ent->local_collider.points[0] = V2(0, 0); ent->local_collider.count = 1; @@ -1324,7 +1324,7 @@ void sim_step(struct sim_step_ctx *ctx) if ((world_time_ns - ent->last_primary_fire_ns >= NS_FROM_SECONDS(ent->primary_fire_delay)) || ent->last_primary_fire_ns == 0) { ent->last_primary_fire_ns = world_time_ns; } else { - primary_triggered = false; + primary_triggered = 0; } } if (secondary_triggered) { @@ -1332,7 +1332,7 @@ void sim_step(struct sim_step_ctx *ctx) if ((world_time_ns - ent->last_secondary_fire_ns >= NS_FROM_SECONDS(ent->secondary_fire_delay)) || ent->last_secondary_fire_ns == 0) { ent->last_secondary_fire_ns = world_time_ns; } else { - secondary_triggered = false; + secondary_triggered = 0; } } diff --git a/src/snc.c b/src/snc.c index 7d4efd8d..19c43d1c 100644 --- a/src/snc.c +++ b/src/snc.c @@ -12,13 +12,13 @@ struct snc_lock snc_lock_spin_e(struct snc_mutex *m, i32 spin) { - b32 locked = false; + b32 locked = 0; i32 spin_cnt = 0; while (!locked) { ++spin_cnt; u32 v = atomic_u32_fetch_test_set(&m->v, 0, 0x80000000); if (v == 0) { - locked = true; + locked = 1; } else if (v == 0x40000000) { /* Lock has pending bit set, try to lock */ u32 swp = atomic_u32_fetch_test_set(&m->v, v, 0x80000000); @@ -28,7 +28,7 @@ struct snc_lock snc_lock_spin_e(struct snc_mutex *m, i32 spin) } v = swp; if (v == 0x40000000) { - locked = true; + locked = 1; } } if (!locked && (v & 0xC0000000) == 0) { @@ -56,14 +56,14 @@ struct snc_lock snc_lock_spin_e(struct snc_mutex *m, i32 spin) #endif struct snc_lock lock = ZI; - lock.exclusive = true; + lock.exclusive = 1; lock.mutex = m; return lock; } struct snc_lock snc_lock_spin_s(struct snc_mutex *m, i32 spin) { - b32 locked = false; + b32 locked = 0; i32 spin_cnt = 0; while (!locked) { ++spin_cnt; @@ -72,7 +72,7 @@ struct snc_lock snc_lock_spin_s(struct snc_mutex *m, i32 spin) /* Lock has no exclusive or pending exclusive lock, increment shared count */ u32 swp = atomic_u32_fetch_test_set(&m->v, v, v + 1); if (v == swp) { - locked = true; + locked = 1; } else { v = swp; } diff --git a/src/snc.h b/src/snc.h index 948d3e2f..f8219b9f 100644 --- a/src/snc.h +++ b/src/snc.h @@ -34,7 +34,7 @@ struct snc_lock snc_lock_s(struct snc_mutex *m); void snc_unlock(struct snc_lock *lock); #if RTC -# define snc_assert_locked_e(l, m) ASSERT((l)->mutex == (m) && (l)->exclusive == true) +# define snc_assert_locked_e(l, m) ASSERT((l)->mutex == (m) && (l)->exclusive == 1) # define snc_assert_locked_e_or_s(l, m) ASSERT((l)->mutex == (m)) #else # define snc_assert_locked_e(l, m) (UNUSED)l diff --git a/src/sock_win32.c b/src/sock_win32.c index 9b8fcc30..632e0a33 100644 --- a/src/sock_win32.c +++ b/src/sock_win32.c @@ -70,13 +70,13 @@ INTERNAL struct sock_address sock_address_from_ip_port_cstr(char *ip_cstr, char hints.ai_socktype = SOCK_DGRAM; hints.ai_flags = AI_PASSIVE; - struct addrinfo *ai_res = NULL; + struct addrinfo *ai_res = 0; i32 status = getaddrinfo(ip_cstr, port_cstr, &hints, &ai_res); if (status == 0) { while (ai_res) { if (ai_res->ai_family == AF_INET) { struct sockaddr_in *sockaddr = (struct sockaddr_in *)ai_res->ai_addr; - res.valid = true; + res.valid = 1; res.family = SOCK_ADDRESS_FAMILY_IPV4; res.portnb = sockaddr->sin_port; STATIC_ASSERT(sizeof(sockaddr->sin_addr) == 4); @@ -86,7 +86,7 @@ INTERNAL struct sock_address sock_address_from_ip_port_cstr(char *ip_cstr, char /* TODO: Enable ipv6 */ #if 0 struct sockaddr_in6 *sockaddr = (struct sockaddr_in6 *)ai_res->ai_addr; - res.valid = true; + res.valid = 1; res.family = SOCK_ADDRESS_FAMILY_IPV6; res.portnb = sockaddr->sin6_port; STATIC_ASSERT(sizeof(sockaddr->sin6_addr) == 16); @@ -107,8 +107,8 @@ struct sock_address sock_address_from_string(struct string str) /* Parse string into ip & port */ u8 ip_buff[1024]; u8 port_buff[countof(ip_buff)]; - char *ip_cstr = NULL; - char *port_cstr = NULL; + char *ip_cstr = 0; + char *port_cstr = 0; { u64 colon_count = 0; for (u64 i = 0; i < str.len; ++i) { @@ -122,12 +122,12 @@ struct sock_address sock_address_from_string(struct string str) u64 parse_len = min_u64(min_u64(str.len, countof(ip_buff) - 1), countof(port_buff) - 1); if (colon_count > 1 && str.text[0] == '[') { /* Parse ipv6 with port */ - b32 parse_addr = true; + b32 parse_addr = 1; for (u64 i = 1; i < parse_len; ++i) { u8 c = str.text[i]; if (parse_addr) { if (c == ']') { - parse_addr = false; + parse_addr = 0; } else { ip_buff[ip_len] = c; ++ip_len; @@ -139,12 +139,12 @@ struct sock_address sock_address_from_string(struct string str) } } else if (colon_count == 1) { /* Parse address with port */ - b32 parse_addr = true; + b32 parse_addr = 1; for (u64 i = 0; i < parse_len; ++i) { u8 c = str.text[i]; if (parse_addr) { if (c == ':') { - parse_addr = false; + parse_addr = 0; } else { ip_buff[ip_len] = c; ++ip_len; @@ -177,7 +177,7 @@ struct sock_address sock_address_from_string(struct string str) struct sock_address sock_address_from_port(u16 port) { u8 port_buff[128]; - char *port_cstr = NULL; + char *port_cstr = 0; { u8 port_buff_reverse[countof(port_buff)]; u64 port_len = 0; @@ -197,7 +197,7 @@ struct sock_address sock_address_from_port(u16 port) } } - struct sock_address res = sock_address_from_ip_port_cstr(NULL, port_cstr); + struct sock_address res = sock_address_from_ip_port_cstr(0, port_cstr); return res; } @@ -244,10 +244,10 @@ INTERNAL struct win32_address win32_address_convert_any_to_localhost(struct win3 { if (addr.family == AF_INET) { u8 *bytes = (u8 *)&addr.sin.sin_addr; - b32 is_any = true; + b32 is_any = 1; for (u64 i = 0; i < 4; ++i) { if (bytes[i] != 0) { - is_any = false; + is_any = 0; break; } } @@ -257,10 +257,10 @@ INTERNAL struct win32_address win32_address_convert_any_to_localhost(struct win3 } } else if (addr.family == AF_INET6) { u8 *bytes = (u8 *)&addr.sin.sin_addr; - b32 is_any = true; + b32 is_any = 1; for (u64 i = 0; i < 16; ++i) { if (bytes[i] != 0) { - is_any = false; + is_any = 0; break; } } @@ -278,12 +278,12 @@ INTERNAL struct sock_address sock_address_from_win32_address(struct win32_addres res.family = SOCK_ADDRESS_FAMILY_IPV4; res.portnb = ws_addr.sin.sin_port; MEMCPY(res.ipnb, &ws_addr.sin.sin_addr, 4); - res.valid = true; + res.valid = 1; } else if (ws_addr.family == AF_INET6) { res.family = SOCK_ADDRESS_FAMILY_IPV6; res.portnb = ws_addr.sin6.sin6_port; MEMCPY(res.ipnb, &ws_addr.sin6.sin6_addr.s6_addr, 16); - res.valid = true; + res.valid = 1; } return res; } @@ -294,7 +294,7 @@ INTERNAL struct sock_address sock_address_from_win32_address(struct win32_addres INTERNAL struct win32_sock *win32_sock_alloc(void) { - struct win32_sock *ws = NULL; + struct win32_sock *ws = 0; { struct snc_lock lock = snc_lock_e(&G.win32_socks_mutex); if (G.first_free_win32_sock) { @@ -371,7 +371,7 @@ void sock_wake(struct sock *sock) struct sock *sock_wait_for_available_read(struct sock_array socks, f32 timeout) { - struct sock *res = NULL; + struct sock *res = 0; WSAPOLLFD fds[MAX_POLL_FDS] = ZI; for (u32 i = 0; i < socks.count; ++i) { @@ -414,12 +414,12 @@ struct sock_read_result sock_read(struct sock *sock, struct string read_buff) gstat_add(GSTAT_SOCK_BYTES_RECEIVED, size); res.data.text = read_buff.text; res.data.len = size; - res.valid = true; + res.valid = 1; } else { #if RTC i32 err = WSAGetLastError(); if (err != WSAEWOULDBLOCK && err != WSAETIMEDOUT && err != WSAECONNRESET) { - ASSERT(false); + ASSERT(0); } #endif } @@ -443,7 +443,7 @@ void sock_write(struct sock *sock, struct sock_address address, struct string da if (size != (i32)data.len) { i32 err = WSAGetLastError(); (UNUSED)err; - ASSERT(false); + ASSERT(0); } #endif } diff --git a/src/sound.c b/src/sound.c index 974a8652..3a9c024b 100644 --- a/src/sound.c +++ b/src/sound.c @@ -50,7 +50,7 @@ struct sound_startup_receipt sound_startup(struct asset_cache_startup_receipt *a INTERNAL struct sound_task_params *sound_task_params_alloc(void) { - struct sound_task_params *p = NULL; + struct sound_task_params *p = 0; { struct snc_lock lock = snc_lock_e(&G.params.mutex); if (G.params.head_free) { @@ -113,8 +113,8 @@ INTERNAL SYS_JOB_DEF(sound_load_asset_job, job) if (decoded.success) { /* Store */ - struct sound *sound = NULL; - i16 *samples = NULL; + struct sound *sound = 0; + i16 *samples = 0; { struct asset_cache_store store = asset_cache_store_open(); sound = arena_push_no_zero(store.arena, struct sound); @@ -135,7 +135,7 @@ INTERNAL SYS_JOB_DEF(sound_load_asset_job, job) logf_error("Error loading sound \"%F\": %F", FMT_STR(path), FMT_STR(error_msg)); /* Store */ - struct sound *sound = NULL; + struct sound *sound = 0; { struct asset_cache_store store = asset_cache_store_open(); sound = arena_push_no_zero(store.arena, struct sound); @@ -192,7 +192,7 @@ struct asset *sound_load_asset(struct string path, u32 flags, b32 wait) struct sound *sound_load_async(struct string path, u32 flags) { __prof; - struct asset *asset = sound_load_asset(path, flags, false); + struct asset *asset = sound_load_asset(path, flags, 0); struct sound *sound = (struct sound *)asset_cache_get_store_data(asset); return sound; } @@ -201,7 +201,7 @@ struct sound *sound_load_async(struct string path, u32 flags) struct sound *sound_load(struct string path, u32 flags) { __prof; - struct asset *asset = sound_load_asset(path, flags, true); + struct asset *asset = sound_load_asset(path, flags, 1); asset_cache_wait(asset); struct sound *sound = (struct sound *)asset_cache_get_store_data(asset); return sound; diff --git a/src/space.c b/src/space.c index 5abc4e82..ba0ff614 100644 --- a/src/space.c +++ b/src/space.c @@ -9,9 +9,9 @@ #define SPACE_ENTRIES_OFFSET (sizeof(struct space) + (sizeof(struct space) % alignof(struct space_entry))) /* Accessed via sim_ent_nil() */ -READONLY struct space_entry _g_space_entry_nil = { .valid = false }; -READONLY struct space_cell _g_space_cell_nil = { .valid = false }; -READONLY struct space _g_space_nil = { .valid = false }; +READONLY struct space_entry _g_space_entry_nil = { .valid = 0 }; +READONLY struct space_cell _g_space_cell_nil = { .valid = 0 }; +READONLY struct space _g_space_nil = { .valid = 0 }; /* ========================== * * Space alloc @@ -29,7 +29,7 @@ struct space *space_alloc(f32 cell_size, u32 num_bins_sqrt) space->entry_arena = arena; } - space->valid = true; + space->valid = 1; space->entries = arena_push_dry(space->entry_arena, struct space_entry); space->cell_arena = arena_alloc(GIBI(64)); @@ -53,9 +53,9 @@ void space_reset(struct space *space) arena_reset(space->cell_arena); space->bins = arena_push_array(space->cell_arena, struct space_cell_bin, space->num_bins); space->num_entries_reserved = 0; - space->first_free_cell = NULL; - space->first_free_cell_node = NULL; - space->first_free_entry = NULL; + space->first_free_cell = 0; + space->first_free_cell_node = 0; + space->first_free_entry = 0; } struct space *space_from_entry(struct space_entry *entry) @@ -126,7 +126,7 @@ INTERNAL void space_cell_node_alloc(struct v2i32 cell_pos, struct space_entry *e struct space_cell_bin *bin = &space->bins[bin_index]; /* Find existing cell */ - struct space_cell *cell = NULL; + struct space_cell *cell = 0; for (struct space_cell *n = bin->first_cell; n; n = n->next_in_bin) { if (v2i32_eq(n->pos, cell_pos)) { cell = n; @@ -152,7 +152,7 @@ INTERNAL void space_cell_node_alloc(struct v2i32 cell_pos, struct space_entry *e bin->last_cell = cell; cell->pos = cell_pos; cell->bin = bin; - cell->valid = true; + cell->valid = 1; } /* Allocate node */ @@ -242,7 +242,7 @@ INTERNAL void space_cell_node_release(struct space_cell_node *n) } else { bin->last_cell = prev; } - cell->valid = false; + cell->valid = 0; /* Insert cell into free list */ cell->next_free = space->first_free_cell; @@ -274,7 +274,7 @@ struct space_entry *space_entry_from_handle(struct space *space, struct space_en struct space_entry *space_entry_alloc(struct space *space, struct sim_ent_id ent) { - struct space_entry *entry = NULL; + struct space_entry *entry = 0; struct space_entry_handle handle = ZI; if (space->first_free_entry) { entry = space->first_free_entry; @@ -287,7 +287,7 @@ struct space_entry *space_entry_alloc(struct space *space, struct sim_ent_id ent ++space->num_entries_reserved; } MEMZERO_STRUCT(entry); - entry->valid = true; + entry->valid = 1; entry->handle = handle; entry->ent = ent; return entry; @@ -306,7 +306,7 @@ void space_entry_release(struct space_entry *entry) struct space *space = space_from_entry(entry); entry->next_free = space->first_free_entry; - entry->valid = false; + entry->valid = 0; ++entry->handle.gen; space->first_free_entry = entry; } @@ -391,17 +391,17 @@ struct space_entry *space_iter_next(struct space_iter *iter) struct v2i32 cell_cur = iter->cell_cur; i32 span = cell_end.x - cell_start.x; - struct space_cell_node *next_node = NULL; + struct space_cell_node *next_node = 0; if (cell_cur.x >= cell_start.x && cell_cur.x <= cell_end.x && cell_cur.y >= cell_start.y && cell_cur.y <= cell_end.y) { /* Started */ - ASSERT(iter->prev != NULL); + ASSERT(iter->prev != 0); next_node = iter->prev->next_in_cell; } else if (cell_cur.x > cell_end.x || cell_cur.y > cell_end.y) { /* Ended */ - return NULL; + return 0; } - while (true) { + while (1) { if (next_node) { struct space_entry *entry = next_node->entry; struct aabb entry_aabb = entry->aabb; @@ -432,5 +432,5 @@ struct space_entry *space_iter_next(struct space_iter *iter) iter->prev = next_node; iter->cell_cur = cell_cur; - return next_node ? next_node->entry : NULL; + return next_node ? next_node->entry : 0; } diff --git a/src/sprite.c b/src/sprite.c index ff335fed..9e21fb59 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -221,7 +221,7 @@ struct sprite_startup_receipt sprite_startup(struct gp_startup_receipt *gp_sr, /* Init nil texture */ G.nil_texture = arena_push(G.perm_arena, struct sprite_texture); - G.nil_texture->loaded = true; + G.nil_texture->loaded = 1; { struct arena_temp scratch = scratch_begin_no_conflict(); struct image_rgba purple_black_image = generate_purple_black_image(scratch.arena, 64, 64); @@ -238,7 +238,7 @@ struct sprite_startup_receipt sprite_startup(struct gp_startup_receipt *gp_sr, G.nil_sheet = arena_push(G.perm_arena, struct sprite_sheet); G.nil_sheet->image_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT); G.nil_sheet->frame_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT); - G.nil_sheet->loaded = true; + G.nil_sheet->loaded = 1; } arena_set_readonly(G.perm_arena); @@ -249,7 +249,7 @@ struct sprite_startup_receipt sprite_startup(struct gp_startup_receipt *gp_sr, G.scopes_arena = arena_alloc(GIBI(64)); - sys_run(1, sprite_evictor_job, NULL, SYS_PRIORITY_BACKGROUND, &G.shutdown_counter); + sys_run(1, sprite_evictor_job, 0, SYS_PRIORITY_BACKGROUND, &G.shutdown_counter); app_register_exit_callback(&sprite_shutdown); resource_register_watch_callback(&sprite_resource_watch_callback); @@ -263,7 +263,7 @@ INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(sprite_shutdown) /* Signal evictor shutdown */ { struct snc_lock lock = snc_lock_e(&G.evictor_scheduler_mutex); - G.evictor_scheduler_shutdown = true; + G.evictor_scheduler_shutdown = 1; snc_cv_broadcast(&G.evictor_scheduler_shutdown_cv); snc_unlock(&lock); } @@ -305,7 +305,7 @@ INTERNAL struct cache_entry_hash cache_entry_hash_from_tag_hash(u64 tag_hash, en INTERNAL struct sprite_scope_cache_ref *scope_ensure_ref_from_ref(struct sprite_scope *scope, struct cache_ref ref); INTERNAL void push_load_job(struct cache_ref ref, struct sprite_tag tag) { - struct load_cmd *cmd = NULL; + struct load_cmd *cmd = 0; { struct snc_lock lock = snc_lock_e(&G.load_cmds_mutex); if (G.first_free_load_cmd) { @@ -329,7 +329,7 @@ INTERNAL void push_load_job(struct cache_ref ref, struct sprite_tag tag) } /* Push work */ - sys_run(1, sprite_load_job, cmd, SYS_PRIORITY_BACKGROUND, NULL); + sys_run(1, sprite_load_job, cmd, SYS_PRIORITY_BACKGROUND, 0); } INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag tag) @@ -342,7 +342,7 @@ INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag t struct string path = tag.path; logf_info("Loading sprite texture [%F] \"%F\"", FMT_HEX(e->hash.v), FMT_STR(path)); - b32 success = false; + b32 success = 0; i64 start_ns = sys_time_ns(); ASSERT(string_ends_with(path, LIT(".ase"))); @@ -371,11 +371,11 @@ INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag t e->texture->width = decoded.image.width; e->texture->height = decoded.image.height; e->texture->gp_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM_SRGB, 0, V2I32(decoded.image.width, decoded.image.height), decoded.image.pixels); - e->texture->valid = true; - e->texture->loaded = true; + e->texture->valid = 1; + e->texture->loaded = 1; /* TODO: Query gpu for more accurate texture size in VRAM */ memory_size += (decoded.image.width * decoded.image.height) * sizeof(*decoded.image.pixels); - success = true; + success = 1; } } arena_set_readonly(e->arena); @@ -483,7 +483,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str /* Group slices by name and find out counts per frame */ u64 num_temp_slice_group_nodes = 0; - struct temp_slice_group_node *temp_slice_group_head = NULL; + struct temp_slice_group_node *temp_slice_group_head = 0; { struct dict *temp_slice_dict = dict_init(scratch.arena, (u64)(ase.num_slice_keys * 2)); for (struct ase_slice_key *ase_slice_key = ase.slice_key_head; ase_slice_key; ase_slice_key = ase_slice_key->next) { @@ -532,7 +532,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str u32 start = ase_slice->start; struct sprite_sheet_slice *slice = &slice_group->frame_slices[(start * slice_group->per_frame_count) + index_in_frame]; - slice->original = true; + slice->original = 1; f32 x1_px = ase_slice->x1; f32 y1_px = ase_slice->y1; @@ -598,7 +598,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str for (u32 i = start; i-- > 0;) { struct sprite_sheet_slice *target = &slice_group->frame_slices[(i * slice_group->per_frame_count) + index_in_frame]; *target = *slice; - target->original = false; + target->original = 0; } } @@ -609,7 +609,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str break; } else { *target = *slice; - target->original = false; + target->original = 0; } } } @@ -641,7 +641,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str struct sprite_sheet_slice *point_slice = &point_slice_group->frame_slices[(i * point_slices_per_frame) + j]; point_slice->dir_px = v2_sub(ray_end, point_slice->center_px); point_slice->dir = v2_sub(ray_end_norm, point_slice->center); - point_slice->has_ray = true; + point_slice->has_ray = 1; } } @@ -665,7 +665,7 @@ INTERNAL void cache_entry_load_sheet(struct cache_ref ref, struct sprite_tag tag struct string path = tag.path; logf_info("Loading sprite sheet [%F] \"%F\"", FMT_HEX(e->hash.v), FMT_STR(path)); - b32 success = false; + b32 success = 0; i64 start_ns = sys_time_ns(); ASSERT(e->kind == CACHE_ENTRY_KIND_SHEET); @@ -693,10 +693,10 @@ INTERNAL void cache_entry_load_sheet(struct cache_ref ref, struct sprite_tag tag /* Initialize */ e->sheet = arena_push_no_zero(e->arena, struct sprite_sheet); *e->sheet = init_sheet_from_ase_result(e->arena, decoded); - e->sheet->loaded = true; - e->sheet->valid = true; + e->sheet->loaded = 1; + e->sheet->valid = 1; - success = true; + success = 1; } } arena_set_readonly(e->arena); @@ -750,7 +750,7 @@ INTERNAL void refcount_add(struct cache_entry *e, i32 amount) ASSERT(new_refcount.count >= 0); break; } - } while (true); + } while (1); } INTERNAL struct sprite_scope_cache_ref *scope_ensure_ref_unsafe(struct sprite_scope *scope, struct cache_entry *e) @@ -767,7 +767,7 @@ INTERNAL struct sprite_scope_cache_ref *scope_ensure_ref_unsafe(struct sprite_sc } } - if (*slot == NULL) { + if (*slot == 0) { if (scope->num_references >= MAX_SCOPE_REFERENCES) { sys_panic(LIT("Max sprite scope references reached")); } @@ -802,9 +802,9 @@ INTERNAL struct sprite_scope_cache_ref *scope_ensure_ref_from_ref(struct sprite_ struct sprite_scope *sprite_scope_begin(void) { /* Alloc scope */ - struct sprite_scope *res = NULL; - struct sprite_scope_cache_ref **bins = NULL; - struct sprite_scope_cache_ref *pool = NULL; + struct sprite_scope *res = 0; + struct sprite_scope_cache_ref **bins = 0; + struct sprite_scope_cache_ref *pool = 0; { struct snc_lock lock = snc_lock_e(&G.scopes_mutex); { @@ -852,7 +852,7 @@ void sprite_scope_end(struct sprite_scope *scope) INTERNAL struct sprite_scope_cache_ref *cache_lookup(struct sprite_scope *scope, struct cache_entry_hash hash, struct snc_lock *bin_lock) { - struct sprite_scope_cache_ref *scope_ref = NULL; + struct sprite_scope_cache_ref *scope_ref = 0; struct cache_bin *bin = &G.cache.bins[hash.v % CACHE_BINS_COUNT]; snc_assert_locked_e_or_s(bin_lock, &bin->mutex); /* Lock required for iterating bin */ @@ -861,7 +861,7 @@ INTERNAL struct sprite_scope_cache_ref *cache_lookup(struct sprite_scope *scope, /* If resource reloading is enabled, then we want to find the * newest entry rather than the first one that exists since * there may be more than one matching entry in the cache */ - struct cache_entry *match = NULL; + struct cache_entry *match = 0; enum cache_entry_state match_state = CACHE_ENTRY_STATE_NONE; for (struct cache_entry *entry = bin->first; entry; entry = entry->next_in_bin) { if (entry->hash.v == hash.v) { @@ -891,7 +891,7 @@ INTERNAL struct sprite_scope_cache_ref *cache_entry_from_tag(struct sprite_scope { struct cache_entry_hash hash = cache_entry_hash_from_tag_hash(tag.hash, kind); u64 bin_index = hash.v % CACHE_BINS_COUNT; - struct sprite_scope_cache_ref *scope_ref = NULL; + struct sprite_scope_cache_ref *scope_ref = 0; /* Search for entry in scope */ if (!force_new) { @@ -928,7 +928,7 @@ INTERNAL struct sprite_scope_cache_ref *cache_entry_from_tag(struct sprite_scope if (!scope_ref) { /* Cache entry still absent, allocate new entry */ - struct cache_entry *entry = NULL; + struct cache_entry *entry = 0; { struct snc_lock pool_lock = snc_lock_e(&G.cache.entry_pool_mutex); if (G.cache.entry_pool_first_free) { @@ -969,14 +969,14 @@ INTERNAL struct sprite_scope_cache_ref *cache_entry_from_tag(struct sprite_scope INTERNAL void *data_from_tag_internal(struct sprite_scope *scope, struct sprite_tag tag, enum cache_entry_kind kind, b32 await) { /* TODO: Replace switch statements */ - void *res = NULL; + void *res = 0; switch (kind) { case CACHE_ENTRY_KIND_TEXTURE: { res = G.loading_texture; } break; case CACHE_ENTRY_KIND_SHEET: { res = G.loading_sheet; } break; default: { sys_panic(LIT("Unknown sprite cache entry kind")); } break; } - struct sprite_scope_cache_ref *scope_ref = cache_entry_from_tag(scope, tag, kind, false); + struct sprite_scope_cache_ref *scope_ref = cache_entry_from_tag(scope, tag, kind, 0); struct cache_ref ref = scope_ref->ref; enum cache_entry_state state = atomic_i32_fetch(&ref.e->state); @@ -1026,20 +1026,20 @@ INTERNAL void *data_from_tag_internal(struct sprite_scope *scope, struct sprite_ struct sprite_texture *sprite_texture_from_tag_await(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - return (struct sprite_texture *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, true); + return (struct sprite_texture *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, 1); } struct sprite_texture *sprite_texture_from_tag_async(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - return (struct sprite_texture *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, false); + return (struct sprite_texture *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, 0); } void sprite_texture_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, false); + data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_TEXTURE, 0); } /* ========================== * @@ -1049,19 +1049,19 @@ void sprite_texture_from_tag_prefetch(struct sprite_scope *scope, struct sprite_ struct sprite_sheet *sprite_sheet_from_tag_await(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - return (struct sprite_sheet *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, true); + return (struct sprite_sheet *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, 1); } struct sprite_sheet *sprite_sheet_from_tag_async(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - return (struct sprite_sheet *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, false); + return (struct sprite_sheet *)data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, 0); } void sprite_sheet_from_tag_prefetch(struct sprite_scope *scope, struct sprite_tag tag) { __prof; - data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, false); + data_from_tag_internal(scope, tag, CACHE_ENTRY_KIND_SHEET, 0); } @@ -1171,7 +1171,7 @@ INTERNAL void reload_if_exists(struct sprite_scope *scope, struct sprite_tag tag { struct cache_entry_hash hash = cache_entry_hash_from_tag_hash(tag.hash, kind); struct cache_bin *bin = &G.cache.bins[hash.v % CACHE_BINS_COUNT]; - struct sprite_scope_cache_ref *existing_ref = NULL; + struct sprite_scope_cache_ref *existing_ref = 0; struct snc_lock bin_lock = snc_lock_s(&bin->mutex); { existing_ref = cache_lookup(scope, hash, &bin_lock); @@ -1180,7 +1180,7 @@ INTERNAL void reload_if_exists(struct sprite_scope *scope, struct sprite_tag tag if (existing_ref) { logf_info("Sprite resource file \"%F\" has changed for sprite [%F].", FMT_STR(tag.path), FMT_HEX(hash.v)); - struct sprite_scope_cache_ref *scope_ref = cache_entry_from_tag(scope, tag, kind, true); + struct sprite_scope_cache_ref *scope_ref = cache_entry_from_tag(scope, tag, kind, 1); push_load_job(scope_ref->ref, tag); } } @@ -1235,7 +1235,7 @@ INTERNAL SORT_COMPARE_FUNC_DEF(evict_sort, arg_a, arg_b, udata) INTERNAL SYS_JOB_DEF(sprite_evictor_job, _) { (UNUSED)_; - b32 shutdown = false; + b32 shutdown = 0; while (!shutdown) { { __profn("Sprite evictor cycle"); @@ -1262,7 +1262,7 @@ INTERNAL SYS_JOB_DEF(sprite_evictor_job, _) #if RESOURCE_RELOADING b32 is_out_of_date = atomic_i32_fetch(&n->out_of_date); #else - b32 is_out_of_date = false; + b32 is_out_of_date = 0; #endif b32 is_old = cache_over_budget_threshold && ((cur_cycle - refcount.last_ref_cycle) > EVICTOR_GRACE_PERIOD_CYCLES); if (is_old || is_out_of_date) { @@ -1290,14 +1290,14 @@ INTERNAL SYS_JOB_DEF(sprite_evictor_job, _) /* Sort evict nodes */ { __profn("Evictor sort"); - merge_sort(evict_array, evict_array_count, sizeof(*evict_array), evict_sort, NULL); + merge_sort(evict_array, evict_array_count, sizeof(*evict_array), evict_sort, 0); } /* Remove evictable nodes from cache until under budget */ - struct evict_node *first_evicted = NULL; + struct evict_node *first_evicted = 0; { __profn("Evictor cache removal"); - b32 stop_evicting = false; + b32 stop_evicting = 0; for (u64 i = 0; i < evict_array_count && !stop_evicting; ++i) { struct evict_node *en = &evict_array[i]; struct cache_bin *bin = en->cache_bin; @@ -1332,7 +1332,7 @@ INTERNAL SYS_JOB_DEF(sprite_evictor_job, _) first_evicted = en; } else { /* Cache is no longer over budget or force evicting, stop iteration */ - stop_evicting = true; + stop_evicting = 1; } } snc_unlock(&bin_lock); diff --git a/src/sprite.h b/src/sprite.h index 9ce293af..feac7fe3 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -100,10 +100,10 @@ struct sprite_sheet_span { }; struct sprite_sheet_slice { - /* If true, this slice was not copied over from another frame in the sprite sheet */ + /* If 1, this slice was not copied over from another frame in the sprite sheet */ b32 original; - /* If true, the slice has a corresponding '.ray' slice affecting the 'dir' fields */ + /* If 1, the slice has a corresponding '.ray' slice affecting the 'dir' fields */ b32 has_ray; /* Values are in the range -0.5 (top / left edge) -> +0.5 (bottom / right edge) */ diff --git a/src/string.c b/src/string.c index 3fe8655d..42c94318 100644 --- a/src/string.c +++ b/src/string.c @@ -5,18 +5,15 @@ #include "uni.h" /* - * NOTE: Strings should be considered ~IMMUTABLE~ + * NOTE: Strings should be considered ~IMMUTABLE~ slices * - * All string functions return a new string as a result. Any strings used as - * an argument (IE: in string_cat) will not be modified. + * All string functions return a new string slice as a result. Any strings used + * as an argument (IE: in string_cat) will not be modified. * * Use the LIT macro to create strings from string literals * * NOTE: It is valid for a string to have len 0 but a non-NULL text pointer. - * Always check string.len rather than string.text for string presence. - * (If we want to change this behavior then we need to check for length = 0 in - * our functions that return a pointer from arena_push_dry, or guarantee that - * all functions returning an arena_push_dry do allocate.) + * Always check string len rather than text for string presence. */ /* ========================== * @@ -319,16 +316,16 @@ struct string string_lower(struct arena *arena, struct string str) b32 string_eq(struct string str1, struct string str2) { - b32 eq = true; + b32 eq = 1; if (str1.len == str2.len) { for (u64 i = 0; i < str1.len; ++i) { if (str1.text[i] != str2.text[i]) { - eq = false; + eq = 0; break; } } } else { - eq = false; + eq = 0; } return eq; } @@ -355,23 +352,23 @@ i32 string_cmp(struct string str1, struct string str2) b32 string_contains(struct string str, struct string substring) { if (substring.len > str.len) { - return false; + return 0; } for (u64 i = 0; i <= str.len - substring.len; ++i) { - b32 match = true; + b32 match = 1; for (u64 j = 0; j < substring.len; ++j) { if (str.text[i + j] != substring.text[j]) { - match = false; + match = 0; break; } } if (match) { - return true; + return 1; } } - return false; + return 0; } b32 string_starts_with(struct string str, struct string substring) @@ -379,12 +376,12 @@ b32 string_starts_with(struct string str, struct string substring) if (str.len >= substring.len) { for (u64 i = 0; i < substring.len; ++i) { if (str.text[i] != substring.text[i]) { - return false; + return 0; } } - return true; + return 1; } - return false; + return 0; } b32 string_ends_with(struct string str, struct string substring) @@ -393,12 +390,12 @@ b32 string_ends_with(struct string str, struct string substring) u64 start = str.len - substring.len; for (u64 i = 0; i < substring.len; ++i) { if (str.text[start + i] != substring.text[i]) { - return false; + return 0; } } - return true; + return 1; } - return false; + return 0; } /* ========================== * @@ -444,7 +441,7 @@ struct string string_formatv(struct arena *arena, struct string fmt, va_list arg u8 *final_text = arena_push_dry(arena, u8); u8 *end = fmt.text + fmt.len; - b32 no_more_args = false; + b32 no_more_args = 0; for (u8 *c = fmt.text; c < end; ++c) { u8 *next = ((c + 1) < end) ? (c + 1) : (u8 *)"\0"; @@ -498,16 +495,16 @@ struct string string_formatv(struct arena *arena, struct string fmt, va_list arg case FMT_TYPE_END: { /* Unexpected end. Not enough FMT args passed to function. */ - ASSERT(false); + ASSERT(0); parsed_str = string_copy(arena, LIT("")); - no_more_args = true; + no_more_args = 1; } break; default: { /* Unknown format type */ - ASSERT(false); + ASSERT(0); parsed_str = string_copy(arena, LIT("")); - no_more_args = true; + no_more_args = 1; } break; } /* Update final string len / start */ @@ -557,7 +554,7 @@ struct string_codepoint_iter string_codepoint_iter_begin(struct string str) }; } -/* Returns false if done iterating */ +/* Returns 0 if done iterating */ b32 string_codepoint_iter_next(struct string_codepoint_iter *iter) { if (iter->pos < iter->src.len) { @@ -565,9 +562,9 @@ b32 string_codepoint_iter_next(struct string_codepoint_iter *iter) struct uni_decode_utf8_result decoded = uni_decode_utf8(str_remaining); iter->pos += decoded.advance8; iter->codepoint = decoded.codepoint; - return true; + return 1; } else { - return false; + return 0; } } diff --git a/src/sys.h b/src/sys.h index 77515b95..51cd951c 100644 --- a/src/sys.h +++ b/src/sys.h @@ -374,7 +374,7 @@ struct sys_thread *sys_thread_alloc( ); void sys_thread_wait_release(struct sys_thread *thread); -b32 sys_thread_try_release(struct sys_thread *thread, f32 timeout_seconds); /* Returns false if the thread could not release in specified timeout (e.g. because it is still running) */ +b32 sys_thread_try_release(struct sys_thread *thread, f32 timeout_seconds); /* Returns 0 if the thread could not release in specified timeout (e.g. because it is still running) */ void sys_thread_force_release(struct sys_thread *thread); /* Gets the current executing thread's ID */ diff --git a/src/sys_win32.c b/src/sys_win32.c index 90c395c8..d6d5e98e 100644 --- a/src/sys_win32.c +++ b/src/sys_win32.c @@ -399,7 +399,7 @@ void sys_wait(void *addr, void *cmp, u32 size, i64 timeout_ns) timeout_ms = timeout_ns / 1000000; timeout_ms += (timeout_ms == 0) * math_fsign(timeout_ns); } - if (addr == NULL) { + if (addr == 0) { Sleep(timeout_ms); } else { WaitOnAddress(addr, cmp, size, timeout_ms); @@ -436,11 +436,11 @@ void sys_wake_all(void *addr) u64 wait_addr_bin_index = (u64)addr % NUM_WAIT_ADDR_BINS; struct wait_bin *wait_addr_bin = &G.wait_addr_bins[wait_addr_bin_index]; - struct wait_list *wait_addr_list = NULL; + struct wait_list *wait_addr_list = 0; /* Get list of waiters */ i32 num_waiters = 0; - struct fiber **waiters = NULL; + struct fiber **waiters = 0; { while (atomic_i32_fetch_test_set(&wait_addr_bin->lock, 0, 1) != 0) ix_pause(); { @@ -474,7 +474,7 @@ void sys_wake_all(void *addr) if (wait_time != 0) while (atomic_i32_fetch_test_set(&wait_time_bin->lock, 0, 1) != 0) ix_pause(); { /* Search for wait time list */ - struct wait_list *wait_time_list = NULL; + struct wait_list *wait_time_list = 0; if (wait_time != 0) { for (struct wait_list *tmp = wait_time_bin->first_wait_list; tmp && !wait_time_list; tmp = tmp->next_in_bin) { if (tmp->value == (u64)wait_time) { @@ -566,7 +566,7 @@ void sys_wake_all(void *addr) struct job_queue *queue = &G.job_queues[queue_kind]; tm_lock(&queue->lock); { - struct job_info *info = NULL; + struct job_info *info = 0; if (queue->first_free) { info = queue->first_free; queue->first_free = info->next; @@ -622,8 +622,8 @@ INTERNAL void job_fiber_entry(void *id_ptr); INTERNAL struct fiber *fiber_alloc(enum fiber_kind kind) { i16 fiber_id = 0; - struct fiber *fiber = NULL; - char *new_name_cstr = NULL; + struct fiber *fiber = 0; + char *new_name_cstr = 0; { tm_lock(&G.fibers_lock); { @@ -642,7 +642,7 @@ INTERNAL struct fiber *fiber_alloc(enum fiber_kind kind) } tm_unlock(&G.fibers_lock); } - if (new_name_cstr != NULL) { + if (new_name_cstr != 0) { fiber->id = fiber_id; /* Id to ASCII */ @@ -713,7 +713,7 @@ INTERNAL void fiber_release(struct fiber *fiber, i16 fiber_id) FORCE_INLINE struct fiber *fiber_from_id(i16 id) { if (id <= 0) { - return NULL; + return 0; } else { return &G.fibers[id]; } @@ -740,7 +740,7 @@ void sys_run(i32 count, sys_job_func *func, void *sig, enum sys_priority priorit struct job_queue *queue = &G.job_queues[queue_kind]; tm_lock(&queue->lock); { - struct job_info *info = NULL; + struct job_info *info = 0; if (queue->first_free) { info = queue->first_free; queue->first_free = info->next; @@ -806,7 +806,7 @@ INTERNAL void job_fiber_entry(void *id_ptr) i16 id = (i32)(i64)id_ptr; struct fiber *fiber = fiber_from_id(id); __prof_fiber_enter(fiber->name_cstr, PROF_THREAD_GROUP_FIBERS + fiber->id); - while (true) { + while (1) { /* Run job */ { //__profn("Run job"); @@ -855,7 +855,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) /* TODO: Heuristic pinning */ /* TODO: Pin non-worker threads to other cores */ HANDLE thread_handle = GetCurrentThread(); - b32 success = false; + b32 success = 0; (UNUSED)success; i32 priority = THREAD_PRIORITY_TIME_CRITICAL; @@ -874,8 +874,8 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) queues[i] = &G.job_queues[i]; } - struct fiber *job_fiber = NULL; - b32 shutdown = false; + struct fiber *job_fiber = 0; + b32 shutdown = 0; while (!shutdown) { /* Pull job from queue */ enum sys_priority job_priority = 0; @@ -896,7 +896,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) job_priority = job_priority_from_queue_kind(queue->kind); while (info && !job_func) { struct job_info *next = info->next; - b32 dequeue = false; + b32 dequeue = 0; if (info->fiber_id <= 0) { job_id = info->num_dispatched++; if (job_id < info->count) { @@ -907,7 +907,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) job_counter = info->counter; if (job_id == (info->count - 1)) { /* We're picking up the last dispatch, so dequeue the job */ - dequeue = true; + dequeue = 1; } } } else { @@ -918,11 +918,11 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) job_func = info->func; job_sig = info->sig; job_counter = info->counter; - dequeue = true; + dequeue = 1; } if (dequeue) { if (!next) { - queue->last = NULL; + queue->last = 0; } queue->first = next; info->next = queue->first_free; @@ -961,7 +961,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) job_fiber->job_counter = job_counter; job_fiber->parent_id = worker_fiber_id; job_fiber->yield_param = &yield; - b32 done = false; + b32 done = 0; while (!done) { job_fiber_resume(job_fiber); switch (yield.kind) { @@ -1002,7 +1002,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) case 2: cancel_wait = (u16)_InterlockedCompareExchange16(wait_addr, 0, 0) != *(u16 *)wait_cmp; break; case 4: cancel_wait = (u32)_InterlockedCompareExchange(wait_addr, 0, 0) != *(u32 *)wait_cmp; break; case 8: cancel_wait = (u64)_InterlockedCompareExchange64(wait_addr, 0, 0) != *(u64 *)wait_cmp; break; - default: cancel_wait = true; ASSERT(false); break; /* Invalid wait size */ + default: cancel_wait = 1; ASSERT(0); break; /* Invalid wait size */ } } if (wait_time != 0 && !cancel_wait) { @@ -1011,7 +1011,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) if (!cancel_wait) { if (wait_addr != 0) { /* Search for wait addr list in bin */ - struct wait_list *wait_addr_list = NULL; + struct wait_list *wait_addr_list = 0; for (struct wait_list *tmp = wait_addr_bin->first_wait_list; tmp && !wait_addr_list; tmp = tmp->next_in_bin) { if (tmp->value == (u64)wait_addr) { wait_addr_list = tmp; @@ -1052,7 +1052,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) } if (wait_time != 0) { /* Search for wait time list in bin */ - struct wait_list *wait_time_list = NULL; + struct wait_list *wait_time_list = 0; for (struct wait_list *tmp = wait_time_bin->first_wait_list; tmp && !wait_time_list; tmp = tmp->next_in_bin) { if (tmp->value == (u64)wait_time) { wait_time_list = tmp; @@ -1093,8 +1093,8 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) } /* Pop worker's job fiber */ - job_fiber = NULL; - done = true; + job_fiber = 0; + done = 1; } } if (wait_time != 0) atomic_i32_fetch_set(&wait_time_bin->lock, 0); @@ -1107,7 +1107,7 @@ INTERNAL SYS_THREAD_DEF(job_worker_entry, worker_ctx_arg) if (job_counter) { snc_counter_add(job_counter, -1); } - done = true; + done = 1; } break; } } @@ -1148,7 +1148,7 @@ INTERNAL SYS_THREAD_DEF(job_scheduler_entry, _) struct arena_temp scratch = scratch_begin_no_conflict(); /* Create high resolution timer */ - HANDLE timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); + HANDLE timer = CreateWaitableTimerExW(0, 0, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); if (!timer) { sys_panic(LIT("Failed to create high resolution timer")); } @@ -1171,7 +1171,7 @@ INTERNAL SYS_THREAD_DEF(job_scheduler_entry, _) //due.QuadPart = -32000; //due.QuadPart = -12000; //due.QuadPart = -8000; - SetWaitableTimerEx(timer, &due, 0, NULL, NULL, NULL, 0); + SetWaitableTimerEx(timer, &due, 0, 0, 0, 0, 0); WaitForSingleObject(timer, INFINITE); } @@ -1199,11 +1199,11 @@ INTERNAL SYS_THREAD_DEF(job_scheduler_entry, _) struct arena_temp temp = arena_temp_begin(scratch.arena); u64 wait_time_bin_index = (u64)current_cycle % NUM_WAIT_TIME_BINS; struct wait_bin *wait_time_bin = &G.wait_time_bins[wait_time_bin_index]; - struct wait_list *wait_time_list = NULL; + struct wait_list *wait_time_list = 0; /* Build list of waiters to resume */ i32 num_waiters = 0; - struct fiber **waiters = NULL; + struct fiber **waiters = 0; { while (atomic_i32_fetch_test_set(&wait_time_bin->lock, 0, 1) != 0) ix_pause(); { @@ -1239,7 +1239,7 @@ INTERNAL SYS_THREAD_DEF(job_scheduler_entry, _) if (wait_addr != 0) while (atomic_i32_fetch_test_set(&wait_addr_bin->lock, 0, 1) != 0) ix_pause(); { /* Search for wait addr list */ - struct wait_list *wait_addr_list = NULL; + struct wait_list *wait_addr_list = 0; if (wait_addr != 0) { for (struct wait_list *tmp = wait_addr_bin->first_wait_list; tmp && !wait_addr_list; tmp = tmp->next_in_bin) { if (tmp->value == (u64)wait_addr) { @@ -1336,7 +1336,7 @@ INTERNAL SYS_THREAD_DEF(job_scheduler_entry, _) struct job_queue *queue = &G.job_queues[queue_kind]; tm_lock(&queue->lock); { - struct job_info *info = NULL; + struct job_info *info = 0; if (queue->first_free) { info = queue->first_free; queue->first_free = info->next; @@ -1389,7 +1389,7 @@ INTERNAL SYS_THREAD_DEF(test_entry, _) /* Start scheduler */ atomic_i64_fetch_set(&G.current_scheduler_cycle_period_ns.v, DEFAULT_SCHEDULER_CYCLE_PERIOD_NS); - struct sys_thread *scheduler_thread = sys_thread_alloc(job_scheduler_entry, NULL, LIT("Scheduler thread"), PROF_THREAD_GROUP_SCHEDULER); + struct sys_thread *scheduler_thread = sys_thread_alloc(job_scheduler_entry, 0, LIT("Scheduler thread"), PROF_THREAD_GROUP_SCHEDULER); /* Start workers */ //G.num_worker_threads = 1; @@ -1515,7 +1515,7 @@ INTERNAL void win32_init_vk_btn_table(void) void *sys_memory_reserve(u64 size) { - void *ptr = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS); + void *ptr = VirtualAlloc(0, size, MEM_RESERVE, PAGE_NOACCESS); return ptr; } @@ -1613,12 +1613,12 @@ INTERNAL struct string string_from_win32_path(struct arena *arena, wchar_t *src) struct string sys_get_write_path(struct arena *arena) { - u16 *p = NULL; + u16 *p = 0; /* TODO: cache this? */ HRESULT res = SHGetKnownFolderPath( &FOLDERID_LocalAppData, 0, - NULL, + 0, &p ); struct string path = ZI; @@ -1653,7 +1653,7 @@ void sys_mkdir(struct string path) __prof; struct arena_temp scratch = scratch_begin_no_conflict(); wchar_t *path_wstr = wstr_from_string(scratch.arena, path); - int err_code = SHCreateDirectory(NULL, path_wstr); + int err_code = SHCreateDirectory(0, path_wstr); struct string err = ZI; switch (err_code) { case ERROR_BAD_PATHNAME: { @@ -1695,10 +1695,10 @@ struct sys_file sys_file_open_read(struct string path) path_wstr, GENERIC_READ, FILE_SHARE_READ, - NULL, + 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, - NULL + 0 ); file.handle = (u64)handle; file.valid = handle != INVALID_HANDLE_VALUE; @@ -1716,7 +1716,7 @@ struct sys_file sys_file_open_read_wait(struct string path) wchar_t *path_wstr = wstr_from_string(scratch.arena, path); i32 delay_ms = 1; HANDLE handle; - while ((handle = CreateFileW(path_wstr, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) { + while ((handle = CreateFileW(path_wstr, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)) == INVALID_HANDLE_VALUE) { if (GetLastError() == ERROR_SHARING_VIOLATION) { __profn("File share conflict delay"); Sleep(delay_ms); @@ -1745,10 +1745,10 @@ struct sys_file sys_file_open_write(struct string path) path_wstr, GENERIC_WRITE, 0, - NULL, + 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL + 0 ); file.handle = (u64)handle; file.valid = handle != INVALID_HANDLE_VALUE; @@ -1768,10 +1768,10 @@ struct sys_file sys_file_open_append(struct string path) path_wstr, FILE_APPEND_DATA, FILE_SHARE_READ, - NULL, + 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL + 0 ); file.handle = (u64)handle; file.valid = handle != INVALID_HANDLE_VALUE; @@ -1796,7 +1796,7 @@ struct string sys_file_read_all(struct arena *arena, struct sys_file file) struct string s = { .len = size, - .text = NULL + .text = 0 }; if (size > 0) { @@ -1808,8 +1808,8 @@ struct string sys_file_read_all(struct arena *arena, struct sys_file file) (HANDLE)file.handle, s.text, (DWORD)s.len, - NULL, /* lpNumberOfBytesRead */ - NULL + 0, /* lpNumberOfBytesRead */ + 0 ); } @@ -1834,8 +1834,8 @@ void sys_file_write(struct sys_file file, struct string data) (HANDLE)file.handle, data.text, (DWORD)data.len, - NULL, /* lpNumberOfBytesWritten */ - NULL + 0, /* lpNumberOfBytesWritten */ + 0 ); } @@ -1889,17 +1889,17 @@ struct sys_file_map sys_file_map_open_read(struct sys_file file) struct sys_file_map map = ZI; u64 size = sys_file_get_size(file); - u8 *base_ptr = NULL; + u8 *base_ptr = 0; HANDLE map_handle = 0; if (size > 0) { map_handle = CreateFileMappingW( (HANDLE)file.handle, - NULL, + 0, PAGE_READONLY, 0, 0, - NULL + 0 ); if (map_handle != INVALID_HANDLE_VALUE) { base_ptr = MapViewOfFile( @@ -1909,7 +1909,7 @@ struct sys_file_map sys_file_map_open_read(struct sys_file file) 0, 0 ); - if (base_ptr == NULL) { + if (base_ptr == 0) { /* Failed to create view */ CloseHandle(map_handle); map_handle = INVALID_HANDLE_VALUE; @@ -1921,7 +1921,7 @@ struct sys_file_map sys_file_map_open_read(struct sys_file file) } map.handle = (u64)map_handle; map.mapped_memory = STRING(size, base_ptr); - map.valid = map_handle != INVALID_HANDLE_VALUE && base_ptr != NULL; + map.valid = map_handle != INVALID_HANDLE_VALUE && base_ptr != 0; return map; @@ -1965,12 +1965,12 @@ b32 sys_file_filter_next(struct arena *arena, struct sys_file_filter *filter) struct win32_file_filter *filter_internal = (struct win32_file_filter *)filter->handle; WIN32_FIND_DATAW find_file_data = ZI; - b32 found = false; + b32 found = 0; if (filter_internal->find_handle) { found = FindNextFileW(filter_internal->find_handle, &find_file_data); } else { - filter_internal->find_handle = FindFirstFileExW(filter_internal->filter_wstr, FindExInfoStandard, &find_file_data, FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH); + filter_internal->find_handle = FindFirstFileExW(filter_internal->filter_wstr, FindExInfoStandard, &find_file_data, FindExSearchNameMatch, 0, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH); found = filter_internal->find_handle != INVALID_HANDLE_VALUE; } @@ -2011,7 +2011,7 @@ struct sys_watch *sys_watch_alloc(struct string dir_path) { struct arena_temp scratch = scratch_begin_no_conflict(); - struct win32_watch *w32_watch = NULL; + struct win32_watch *w32_watch = 0; { struct snc_lock lock = snc_lock_e(&G.watches_mutex); { @@ -2031,13 +2031,13 @@ struct sys_watch *sys_watch_alloc(struct string dir_path) dir_path_wstr, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, - NULL, + 0, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED, - NULL + 0 ); - w32_watch->wake_handle = CreateEventW(NULL, FALSE, FALSE, NULL); + w32_watch->wake_handle = CreateEventW(0, 0, 0, 0); scratch_end(scratch); return (struct sys_watch *)w32_watch; @@ -2068,20 +2068,20 @@ struct sys_watch_info_list sys_watch_wait(struct arena *arena, struct sys_watch FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_CREATION; - b32 done = false; + b32 done = 0; while (!done) { OVERLAPPED ov = ZI; - ov.hEvent = CreateEventW(NULL, FALSE, FALSE, NULL); + ov.hEvent = CreateEventW(0, 0, 0, 0); ASSERT(ov.hEvent); BOOL success = ReadDirectoryChangesW(w32_watch->dir_handle, w32_watch->results_buff, countof(w32_watch->results_buff), - true, + 1, filter, - NULL, + 0, &ov, - NULL); + 0); (UNUSED)success; ASSERT(success); @@ -2089,7 +2089,7 @@ struct sys_watch_info_list sys_watch_wait(struct arena *arena, struct sys_watch ov.hEvent, w32_watch->wake_handle }; - DWORD wait_res = WaitForMultipleObjects(2, handles, FALSE, INFINITE); + DWORD wait_res = WaitForMultipleObjects(2, handles, 0, INFINITE); if (wait_res == WAIT_OBJECT_0) { i64 offset = 0; @@ -2150,16 +2150,16 @@ struct sys_watch_info_list sys_watch_wait(struct arena *arena, struct sys_watch } if (res->NextEntryOffset == 0) { - done = true; + done = 1; } else { offset += res->NextEntryOffset; } } } else if (wait_res == WAIT_OBJECT_0 + 1) { ResetEvent(w32_watch->wake_handle); - done = true; + done = 1; } else { - ASSERT(false); + ASSERT(0); } } @@ -2230,14 +2230,14 @@ INTERNAL HWND win32_create_window(struct win32_window *window) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, - NULL, + 0, + 0, G.window_class.hInstance, - NULL + 0 ); /* Dark mode */ - BOOL dark_mode = true; + BOOL dark_mode = 1; DwmSetWindowAttribute(hwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, (LPCVOID)&dark_mode, sizeof(dark_mode)); /* Set window as userdata */ @@ -2275,12 +2275,12 @@ INTERNAL SYS_THREAD_DEF(window_thread_entry_point, arg) /* Hide cursor */ if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_HIDE) { - while(ShowCursor(false) >= 0); + while(ShowCursor(0) >= 0); } /* Show cursor */ if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_SHOW) { - while(ShowCursor(true) < 0); + while(ShowCursor(1) < 0); } /* Update position */ @@ -2293,7 +2293,7 @@ INTERNAL SYS_THREAD_DEF(window_thread_entry_point, arg) /* Stop clipping cursor */ if (cursor_flags & WIN32_WINDOW_CURSOR_SET_FLAG_DISABLE_CLIP) { - ClipCursor(NULL); + ClipCursor(0); } /* Clip cursor in window window */ @@ -2334,7 +2334,7 @@ INTERNAL SYS_THREAD_DEF(window_thread_entry_point, arg) INTERNAL struct win32_window *win32_window_alloc(void) { - struct win32_window *window = NULL; + struct win32_window *window = 0; { struct snc_lock lock = snc_lock_e(&G.windows_mutex); if (G.first_free_window) { @@ -2475,7 +2475,7 @@ INTERNAL void win32_update_window_from_settings(struct win32_window *window, str .right = settings->floating_x + settings->floating_width, .bottom = settings->floating_y + settings->floating_height }; - AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, false); + AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, 0); } WINDOWPLACEMENT wp = { @@ -2516,7 +2516,7 @@ INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, } LRESULT result = 0; - b32 is_release = false; + b32 is_release = 0; switch (msg) { case WM_CLOSE: case WM_DESTROY: { @@ -2546,7 +2546,7 @@ INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, case WM_KEYUP: case WM_KEYDOWN: { WORD vk_code = LOWORD(wparam); - b32 is_repeat = false; + b32 is_repeat = 0; enum sys_event_kind event_kind = SYS_EVENT_KIND_NONE; if (msg == WM_KEYDOWN || msg == WM_SYSKEYDOWN) { @@ -2620,7 +2620,7 @@ INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, case WM_RBUTTONUP: case WM_XBUTTONUP: { ReleaseCapture(); - is_release = true; + is_release = 1; } FALLTHROUGH; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: @@ -2689,7 +2689,7 @@ INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam, /* Read raw input buffer */ UINT buff_size; - GetRawInputData((HRAWINPUT)lparam, RID_INPUT, NULL, &buff_size, sizeof(RAWINPUTHEADER)); + GetRawInputData((HRAWINPUT)lparam, RID_INPUT, 0, &buff_size, sizeof(RAWINPUTHEADER)); u8 *buff = arena_push_array(scratch.arena, u8, buff_size); if (GetRawInputData((HRAWINPUT)lparam, RID_INPUT, buff, &buff_size, sizeof(RAWINPUTHEADER)) != buff_size) { logf_error("GetRawInputData did not return correct size"); @@ -2764,7 +2764,7 @@ void sys_window_unregister_event_callback(struct sys_window *sys_window, sys_win struct snc_lock lock = snc_lock_e(&window->event_callbacks_mutex); { u64 count = window->event_callbacks_count; - sys_window_event_callback_func *last = count > 0 ? window->event_callbacks[count - 1] : NULL; + sys_window_event_callback_func *last = count > 0 ? window->event_callbacks[count - 1] : 0; for (u64 i = 0; i < window->event_callbacks_count; ++i) { if (window->event_callbacks[i] == func) { @@ -2879,7 +2879,7 @@ void sys_window_cursor_disable_clip(struct sys_window *sys_window) INTERNAL struct win32_thread *win32_thread_alloc(void) { - struct win32_thread *t = NULL; + struct win32_thread *t = 0; struct snc_lock lock = snc_lock_e(&G.threads_mutex); { if (G.threads_first_free) { @@ -2930,7 +2930,7 @@ INTERNAL DWORD WINAPI win32_thread_proc(LPVOID vt) __profthread(t->thread_name_cstr, t->profiler_group); /* Initialize COM */ - CoInitializeEx(NULL, COINIT_MULTITHREADED); + CoInitializeEx(0, COINIT_MULTITHREADED); /* Set thread name */ if (t->thread_name_wstr[0] != 0) { @@ -2952,7 +2952,7 @@ struct sys_thread *sys_thread_alloc(sys_thread_func *entry_point, void *thread_d { __prof; struct arena_temp scratch = scratch_begin_no_conflict(); - ASSERT(entry_point != NULL); + ASSERT(entry_point != 0); logf_info("Creating thread \"%F\"", FMT_STR(thread_name)); @@ -2976,12 +2976,12 @@ struct sys_thread *sys_thread_alloc(sys_thread_func *entry_point, void *thread_d } t->handle = CreateThread( - NULL, + 0, THREAD_STACK_SIZE, win32_thread_proc, t, 0, - NULL + 0 ); if (!t->handle) { @@ -3003,7 +3003,7 @@ void sys_thread_wait_release(struct sys_thread *thread) b32 sys_thread_try_release(struct sys_thread *thread, f32 timeout_seconds) { __prof; - b32 success = false; + b32 success = 0; struct win32_thread *t = (struct win32_thread *)thread; HANDLE handle = t->handle; @@ -3012,7 +3012,7 @@ b32 sys_thread_try_release(struct sys_thread *thread, f32 timeout_seconds) DWORD timeout_ms = (timeout_seconds == F32_INFINITY) ? INFINITE : math_round_to_int(timeout_seconds * 1000); DWORD wait_res = WaitForSingleObject(handle, timeout_ms); if (wait_res == WAIT_OBJECT_0) { - success = true; + success = 1; CloseHandle(handle); win32_thread_release(t); } @@ -3087,7 +3087,7 @@ void sys_message_box(enum sys_message_box_kind kind, struct string message) } logf_info("Showing message box kind %F with text \"%F\"", FMT_SINT(kind), FMT_STR(message)); - MessageBoxExW(NULL, message_wstr, title, mbox_type, 0); + MessageBoxExW(0, message_wstr, title, mbox_type, 0); scratch_end(scratch); } @@ -3184,8 +3184,8 @@ void sys_panic(struct string msg) wstr[wstr_len] = 0; #if RTC - MessageBoxExW(NULL, wstr, L"Fatal error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); - ASSERT(false); + MessageBoxExW(0, wstr, L"Fatal error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); + ASSERT(0); #endif WRITE_BARRIER(); @@ -3204,14 +3204,14 @@ void sys_panic(struct string msg) b32 sys_run_command(struct string cmd) { - b32 success = false; + b32 success = 0; { struct arena_temp scratch = scratch_begin_no_conflict(); wchar_t *cmd_wstr = wstr_from_string(scratch.arena, cmd); STARTUPINFO si = ZI; si.cb = sizeof(si); PROCESS_INFORMATION pi = ZI; - success = CreateProcessW(NULL, cmd_wstr, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi); + success = CreateProcessW(0, cmd_wstr, 0, 0, 0, DETACHED_PROCESS, 0, 0, &si, &pi); scratch_end(scratch); } return success; @@ -3247,16 +3247,16 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, wchar_t cmd[sizeof(PROFILING_CMD_WSTR)] = ZI; MEMCPY(cmd, PROFILING_CMD_WSTR, sizeof(PROFILING_CMD_WSTR)); DeleteFileW(PROFILING_FILE_WSTR); - b32 success = CreateProcessW(NULL, cmd, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi); + b32 success = CreateProcessW(0, cmd, 0, 0, 0, DETACHED_PROCESS, 0, 0, &si, &pi); if (!success) { - MessageBoxExW(NULL, L"Failed to launch profiler using command '" PROFILING_CMD_WSTR L"'.", L"Error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); + MessageBoxExW(0, L"Failed to launch profiler using command '" PROFILING_CMD_WSTR L"'.", L"Error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); } } #endif __profthread("Main thread", PROF_THREAD_GROUP_MAIN); - const wchar_t *error_msg = NULL; + const wchar_t *error_msg = 0; /* Init timer */ { @@ -3297,7 +3297,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, SetThreadDescription(GetCurrentThread(), L"Main thread"); /* Set up panic event */ - G.panic_event = CreateEventW(NULL, true, false, NULL); + G.panic_event = CreateEventW(0, 1, 0, 0); /* Query system info */ GetSystemInfo(&G.info); @@ -3320,7 +3320,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, WNDCLASSEXW *wc = &G.window_class; wc->cbSize = sizeof(WNDCLASSEX); wc->lpszClassName = WINDOW_CLASS_NAME; - wc->hCursor = LoadCursor(NULL, IDC_ARROW); + wc->hCursor = LoadCursor(0, IDC_ARROW); wc->style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; //wc->hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wc->lpfnWndProc = win32_window_proc; @@ -3360,10 +3360,10 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, /* Call app thread and wait for return */ { /* Start app thread */ - struct sys_thread *app_thread = sys_thread_alloc(&win32_app_thread_entry_point, NULL, LIT("App thread"), PROF_THREAD_GROUP_APP); + struct sys_thread *app_thread = sys_thread_alloc(&win32_app_thread_entry_point, 0, LIT("App thread"), PROF_THREAD_GROUP_APP); /* Start test thread */ - struct sys_thread *test_thread = sys_thread_alloc(test_entry, NULL, LIT("Test thread"), PROF_THREAD_GROUP_APP); + struct sys_thread *test_thread = sys_thread_alloc(test_entry, 0, LIT("Test thread"), PROF_THREAD_GROUP_APP); /* Get app thread handle */ HANDLE app_thread_handle = 0; @@ -3381,7 +3381,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, app_thread_handle, G.panic_event }; - DWORD res = WaitForMultipleObjects(countof(wait_handles), wait_handles, false, INFINITE); + DWORD res = WaitForMultipleObjects(countof(wait_handles), wait_handles, 0, INFINITE); if (res == WAIT_OBJECT_0) { sys_thread_force_release(app_thread); } @@ -3435,8 +3435,8 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance, abort: if (error_msg) { - MessageBoxExW(NULL, error_msg, L"Fatal error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); - ASSERT(false); + MessageBoxExW(0, error_msg, L"Fatal error", MB_ICONSTOP | MB_SETFOREGROUND | MB_TOPMOST, 0); + ASSERT(0); return 1; } diff --git a/src/tar.c b/src/tar.c index a9bc5df5..0c8c0326 100644 --- a/src/tar.c +++ b/src/tar.c @@ -80,13 +80,13 @@ struct tar_archive tar_parse(struct arena *arena, struct string data, struct str if (!string_eq(STRING_FROM_ARRAY(header.ustar_indicator), LIT("ustar\0"))) { /* Invalid header */ - ASSERT(false); + ASSERT(0); continue; } if (header.file_name_prefix[0] != 0) { /* Header file name prefix not supported */ - ASSERT(false); + ASSERT(0); continue; } @@ -143,7 +143,7 @@ struct tar_archive tar_parse(struct arena *arena, struct string data, struct str /* Enter into hierarchy */ if (!entry->is_dir) { /* Find parent entry */ - struct tar_entry *parent_entry = NULL; + struct tar_entry *parent_entry = 0; for (struct string parent_dir_name = entry->file_name; parent_dir_name.len > 0; --parent_dir_name.len) { if (parent_dir_name.text[parent_dir_name.len - 1] == '/') { u64 hash = hash_fnv64(HASH_FNV64_BASIS, parent_dir_name); diff --git a/src/ttf_dwrite.cpp b/src/ttf_dwrite.cpp index 11933a7b..a64078a8 100644 --- a/src/ttf_dwrite.cpp +++ b/src/ttf_dwrite.cpp @@ -86,27 +86,27 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded, (UNUSED)error; /* File */ - IDWriteFontFile *font_file = NULL; + IDWriteFontFile *font_file = 0; { /* Create in memory loader */ - IDWriteInMemoryFontFileLoader *loader = NULL; + IDWriteInMemoryFontFileLoader *loader = 0; error = factory->CreateInMemoryFontFileLoader(&loader); error = factory->RegisterFontFileLoader(loader); - IDWriteFontSetBuilder1 *builder = NULL; + IDWriteFontSetBuilder1 *builder = 0; error = factory->CreateFontSetBuilder(&builder); - error = loader->CreateInMemoryFontFileReference(factory, encoded.text, (u32)encoded.len, NULL, &font_file); + error = loader->CreateInMemoryFontFileReference(factory, encoded.text, (u32)encoded.len, 0, &font_file); error = builder->AddFontFile(font_file); } /* Face */ - IDWriteFontFace *font_face = NULL; + IDWriteFontFace *font_face = 0; error = factory->CreateFontFace(DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, &font_file, 0, DWRITE_FONT_SIMULATIONS_NONE, &font_face); /* Render settings */ - IDWriteRenderingParams *default_rendering_params = NULL; + IDWriteRenderingParams *default_rendering_params = 0; error = factory->CreateRenderingParams(&default_rendering_params); - IDWriteRenderingParams *rendering_params = NULL; + IDWriteRenderingParams *rendering_params = 0; FLOAT gamma = default_rendering_params->GetGamma(); FLOAT enhanced_contrast = default_rendering_params->GetEnhancedContrast(); FLOAT clear_type_level = default_rendering_params->GetClearTypeLevel(); @@ -118,7 +118,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded, &rendering_params); /* Interop */ - IDWriteGdiInterop *dwrite_gdi_interop = NULL; + IDWriteGdiInterop *dwrite_gdi_interop = 0; error = factory->GetGdiInterop(&dwrite_gdi_interop); /* Get Metrics */ @@ -141,7 +141,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded, u16 glyph_count = font_face->GetGlyphCount(); /* Render target */ - IDWriteBitmapRenderTarget *render_target = NULL; + IDWriteBitmapRenderTarget *render_target = 0; /* FIXME: errors when point_size too high */ error = dwrite_gdi_interop->CreateBitmapRenderTarget(0, (UINT32)raster_target_w, (UINT32)raster_target_h, &render_target); render_target->SetPixelsPerDip(1.0); @@ -204,7 +204,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded, /* Compute glyph metrics */ DWRITE_GLYPH_METRICS glyph_metrics = ZI; - error = font_face->GetDesignGlyphMetrics(&i, 1, &glyph_metrics, false); + error = font_face->GetDesignGlyphMetrics(&i, 1, &glyph_metrics, 0); f32 off_x = (f32)bounding_box.left - raster_target_x; f32 off_y = (f32)bounding_box.top - raster_target_y; @@ -282,7 +282,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded, } /* Construct indices array */ - u16 *cache_indices = NULL; + u16 *cache_indices = 0; if (cache_codes_count > 0) { cache_indices = arena_push_array(arena, u16, cache_codes_count); font_face->GetGlyphIndices(cache_codes, cache_codes_count, cache_indices); diff --git a/src/user.c b/src/user.c index ff28d804..ee975a3c 100644 --- a/src/user.c +++ b/src/user.c @@ -253,8 +253,8 @@ struct user_startup_receipt user_startup(struct gp_startup_receipt *gp_sr, sys_window_register_event_callback(G.window, &window_event_callback); /* Start jobs */ - sys_run(1, local_sim_job, NULL, SYS_PRIORITY_HIGH, &G.shutdown_job_counters); - sys_run(1, user_job, NULL, SYS_PRIORITY_HIGH, &G.shutdown_job_counters); + sys_run(1, local_sim_job, 0, SYS_PRIORITY_HIGH, &G.shutdown_job_counters); + sys_run(1, user_job, 0, SYS_PRIORITY_HIGH, &G.shutdown_job_counters); app_register_exit_callback(&user_shutdown); return (struct user_startup_receipt) { 0 }; @@ -265,7 +265,7 @@ INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(user_shutdown) __prof; sys_window_unregister_event_callback(G.window, &window_event_callback); /* Signal shutdown */ - atomic_i32_fetch_set(&G.shutdown, true); + atomic_i32_fetch_set(&G.shutdown, 1); /* Wait for jobs shutdown */ snc_counter_wait(&G.shutdown_job_counters); } @@ -774,7 +774,7 @@ INTERNAL void user_update(void) G.user_cursor.x > G.user_size.x || G.user_cursor.y > G.user_size.y); #else - b32 out_of_bounds = false; + b32 out_of_bounds = 0; #endif G.bind_states[bind].is_held = pressed && !out_of_bounds; if (pressed) { @@ -965,14 +965,14 @@ INTERNAL void user_update(void) if (G.bind_states[USER_BIND_KIND_PAN].is_held) { if (!G.debug_camera_panning) { G.debug_camera_pan_start = world_cursor; - G.debug_camera_panning = true; + G.debug_camera_panning = 1; } struct v2 offset = v2_neg(v2_sub(G.debug_camera_pan_start, world_cursor)); G.world_to_user_xf = xform_translated(G.world_to_user_xf, offset); world_cursor = xform_invert_mul_v2(G.world_to_user_xf, G.user_cursor); G.debug_camera_pan_start = world_cursor; } else { - G.debug_camera_panning = false; + G.debug_camera_panning = 0; } /* Zoom view */ @@ -1158,7 +1158,7 @@ INTERNAL void user_update(void) /* Sort */ { __profn("Sort ents"); - merge_sort(sorted, sorted_count, sizeof(*sorted), ent_draw_order_cmp, NULL); + merge_sort(sorted, sorted_count, sizeof(*sorted), ent_draw_order_cmp, 0); } } @@ -1184,7 +1184,7 @@ INTERNAL void user_update(void) skip_debug_draw = skip_debug_draw || sim_ent_has_prop(ent, SEPROP_MOTOR_JOINT); b32 skip_debug_draw_transform = sim_ent_has_prop(ent, SEPROP_CAMERA); - skip_debug_draw_transform = true; + skip_debug_draw_transform = 1; struct xform sprite_xform = xform_mul(xf, ent->sprite_local_xform); @@ -1540,15 +1540,15 @@ INTERNAL void user_update(void) #if 0 /* Only draw points with large separation */ - b32 should_draw = false; + b32 should_draw = 0; for (u32 i = 0; i < data->num_points; ++i) { if (data->points[i].starting_separation < -0.1) { - should_draw = true; + should_draw = 1; break; } } #else - b32 should_draw = true; + b32 should_draw = 1; #endif if (should_draw) { @@ -1587,7 +1587,7 @@ INTERNAL void user_update(void) struct v2_array m = menkowski(temp.arena, &e0_collider, &e1_collider, e0_xf, e1_xf, detail); for (u64 i = 0; i < m.count; ++i) m.points[i] = xform_mul_v2(G.world_to_user_xf, m.points[i]); - draw_poly_line(G.ui_gp_flow, m, true, thickness, color); + draw_poly_line(G.ui_gp_flow, m, 1, thickness, color); //draw_poly(G.ui_gp_flow, m, color); } @@ -1614,7 +1614,7 @@ INTERNAL void user_update(void) .count = collider_res.prototype.len }; for (u64 i = 0; i < m.count; ++i) m.points[i] = xform_mul_v2(G.world_to_user_xf, m.points[i]); - draw_poly_line(G.ui_gp_flow, m, true, thickness, color); + draw_poly_line(G.ui_gp_flow, m, 1, thickness, color); for (u64 i = 0; i < m.count; ++i) draw_circle(G.ui_gp_flow, m.points[i], 10, color, 10); } @@ -2036,7 +2036,7 @@ INTERNAL void user_update(void) draw_debug_console(console_level, console_minimized); #else if (G.debug_draw) { - draw_debug_console(LOG_LEVEL_INFO, false); + draw_debug_console(LOG_LEVEL_INFO, 0); } #endif } @@ -2057,7 +2057,7 @@ INTERNAL void user_update(void) if (G.user_texture) { gp_resource_release(G.user_texture); } - G.user_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, GP_TEXTURE_FLAG_TARGETABLE, user_resolution, NULL); + G.user_texture = gp_texture_alloc(GP_TEXTURE_FORMAT_R8G8B8A8_UNORM, GP_TEXTURE_FLAG_TARGETABLE, user_resolution, 0); } /* Render world to user texture */ @@ -2067,7 +2067,7 @@ INTERNAL void user_update(void) params.draw_target = G.user_texture; params.draw_target_viewport = user_viewport; params.draw_target_view = G.world_to_user_xf; - params.clear_target = true; + params.clear_target = 1; gp_dispatch(params); } @@ -2200,7 +2200,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) //host_listen(host, net_listen_addr); #endif - b32 is_master = false; + b32 is_master = 0; struct host *host; if (G.connect_address_str.len > 0) { host = host_alloc(0); @@ -2208,7 +2208,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) host_queue_connect_to_address(host, addr); } else { host = host_alloc(12345); - is_master = true; + is_master = 1; } struct bitbuff msg_writer_bb = bitbuff_alloc(GIBI(64)); @@ -2222,7 +2222,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) struct sim_client *master_client = sim_client_nil(); /* Stores snapshots received from master */ struct sim_client *master_blended_client = sim_client_nil(); /* Stores interpolated master snapshots */ - b32 initialized_from_master = false; + b32 initialized_from_master = 0; @@ -2301,7 +2301,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) master_blended_client = sim_client_alloc(store); } else { /* We already have a master client */ - ASSERT(false); + ASSERT(0); } } } @@ -2385,7 +2385,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) } } else { /* We do not have the tick that the incoming delta is based from */ - ASSERT(false); + ASSERT(0); } tmp_encoded_len = br_read_uv(&msg_br); @@ -2423,13 +2423,13 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) } else { /* We do not have the tick that the incoming delta is based from. * This decode should never have been queued in the first place. */ - ASSERT(false); + ASSERT(0); } } if (!is_master && !initialized_from_master) { if (master_client->valid && master_client->last_tick > 0) { - initialized_from_master = true; + initialized_from_master = 1; } else { goto skip_step; } @@ -2437,7 +2437,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) b32 should_step = !atomic_i32_fetch(&G.user_paused); if (atomic_i32_fetch(&G.user_paused_steps) > 0) { - should_step = true; + should_step = 1; atomic_i32_fetch_add(&G.user_paused_steps, -1); } @@ -2518,7 +2518,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) /* TODO: Eventually determine master tick based on a delay to allow for jitter and also interpolation so we can lower snapshot publish frequency */ - b32 master_ss_is_blended = false; + b32 master_ss_is_blended = 0; struct sim_snapshot *master_ss = sim_snapshot_nil(); { /* How along are we between master sim ticks (0 = start of tick, 1 = end of tick) */ @@ -2570,13 +2570,13 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) blend = (f64)(master_blend_tick - left_snapshot->tick) / (f64)(right_snapshot->tick - left_snapshot->tick); f64 epsilon = 0.001; if (blend < epsilon) { - master_ss_is_blended = false; + master_ss_is_blended = 0; master_ss = left_snapshot; } else if (blend > 1 - epsilon) { - master_ss_is_blended = false; + master_ss_is_blended = 0; master_ss = right_snapshot; } else { - master_ss_is_blended = true; + master_ss_is_blended = 1; master_ss = sim_snapshot_alloc_from_lerp(master_blended_client, left_snapshot, right_snapshot, blend); /* Release unneeded blended master snapshots */ @@ -2586,7 +2586,7 @@ INTERNAL SYS_JOB_DEF(local_sim_job, _) } } } else { - master_ss_is_blended = false; + master_ss_is_blended = 0; master_ss = left_snapshot->valid ? left_snapshot : right_snapshot; } diff --git a/src/util.h b/src/util.h index efcee4fb..70c13e1d 100644 --- a/src/util.h +++ b/src/util.h @@ -198,7 +198,7 @@ INLINE void dict_set(struct arena *arena, struct dict *dict, u64 hash, u64 value INLINE struct dict_entry *dict_get_entry(struct dict *dict, u64 hash) { __prof; - struct dict_entry *result = NULL; + struct dict_entry *result = 0; struct dict_bin *bin = &dict->bins[hash % dict->bins_count]; for (struct dict_entry *entry = bin->first; entry; entry = entry->next_in_bin) { if (hash == entry->hash) { @@ -275,7 +275,7 @@ INLINE void sleep_precise(i64 sleep_time_ns) /* Sleep */ while (now_ns < target_ns - big_sleep - tolerance) { __profn("Sleep part"); - sys_wait(NULL, NULL, 0, big_sleep); + sys_wait(0, 0, 0, big_sleep); now_ns = sys_time_ns(); }