mirror of
				https://github.com/Ed94/HandmadeHero.git
				synced 2025-11-03 15:26:12 -08:00 
			
		
		
		
	minor cleanup
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -25,6 +25,8 @@ build
 | 
				
			|||||||
**/*.pdb
 | 
					**/*.pdb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**/*.hmi
 | 
					**/*.hmi
 | 
				
			||||||
 | 
					**/*.symbols
 | 
				
			||||||
 | 
					
 | 
				
			||||||
data/test.out
 | 
					data/test.out
 | 
				
			||||||
data/handmade_engine.symbols
 | 
					data/handmade_engine.symbols
 | 
				
			||||||
data/handmade_win32.exe
 | 
					data/handmade_win32.exe
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								.vscode/bookmarks.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								.vscode/bookmarks.json
									
									
									
									
										vendored
									
									
								
							@@ -19,17 +19,17 @@
 | 
				
			|||||||
					"label": "Timing"
 | 
										"label": "Timing"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"line": 1479,
 | 
										"line": 1477,
 | 
				
			||||||
					"column": 4,
 | 
										"column": 4,
 | 
				
			||||||
					"label": "Main Loop : Audio Processing"
 | 
										"label": "Main Loop : Audio Processing"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"line": 1598,
 | 
										"line": 1596,
 | 
				
			||||||
					"column": 2,
 | 
										"column": 2,
 | 
				
			||||||
					"label": "Main Loop : Timing Update"
 | 
										"label": "Main Loop : Timing Update"
 | 
				
			||||||
				},
 | 
									},
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					"line": 1682,
 | 
										"line": 1680,
 | 
				
			||||||
					"column": 0,
 | 
										"column": 0,
 | 
				
			||||||
					"label": "Main Loop : End"
 | 
										"label": "Main Loop : End"
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 
 | 
				
			|||||||
										
											Binary file not shown.
										
									
								
							@@ -26,7 +26,9 @@ struct EngineActions
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	b32 toggle_wave_tone = false;
 | 
						b32 toggle_wave_tone = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if Build_Development
 | 
				
			||||||
	b32 pause_renderer  = false;
 | 
						b32 pause_renderer  = false;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct PlayerActions
 | 
					struct PlayerActions
 | 
				
			||||||
@@ -322,7 +324,9 @@ void input_poll_engine_actions( InputState* input, EngineActions* actions )
 | 
				
			|||||||
	actions->raise_tone_hz |= keyboard->Right.EndedDown;
 | 
						actions->raise_tone_hz |= keyboard->Right.EndedDown;
 | 
				
			||||||
	actions->lower_tone_hz |= keyboard->Left.EndedDown;
 | 
						actions->lower_tone_hz |= keyboard->Left.EndedDown;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if Build_Development
 | 
				
			||||||
	actions->pause_renderer |= pressed( keyboard->Pause );
 | 
						actions->pause_renderer |= pressed( keyboard->Pause );
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	actions->toggle_wave_tone |= pressed( keyboard->Q );
 | 
						actions->toggle_wave_tone |= pressed( keyboard->Q );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -473,6 +477,7 @@ void update_and_render( InputState* input, OffscreenBuffer* back_buffer, Memory*
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						#if Build_Development
 | 
				
			||||||
		if ( engine_actions.pause_renderer )
 | 
							if ( engine_actions.pause_renderer )
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			if ( state->RendererPaused )
 | 
								if ( state->RendererPaused )
 | 
				
			||||||
@@ -486,6 +491,7 @@ void update_and_render( InputState* input, OffscreenBuffer* back_buffer, Memory*
 | 
				
			|||||||
				state->RendererPaused = true;
 | 
									state->RendererPaused = true;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ( state->InputRecordingIndex )
 | 
						if ( state->InputRecordingIndex )
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -40,11 +40,8 @@ NS_PLATFORM_BEGIN
 | 
				
			|||||||
// (Example: Letting the user change the refresh-rate of the monitor or the engine's target frame-rate)
 | 
					// (Example: Letting the user change the refresh-rate of the monitor or the engine's target frame-rate)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if Build_Development
 | 
					#if Build_Development
 | 
				
			||||||
/*
 | 
					 | 
				
			||||||
	IMPORTANT : These are not for shipping code - they are blocking and the write isn't protected.
 | 
					 | 
				
			||||||
*/
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using DebugSetPauseRenderingFn = void (b32 value);
 | 
					using DebugSetPauseRenderingFn = void (b32 value);
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct File
 | 
					struct File
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -98,7 +95,6 @@ void get_symbol_from_module_table( File symbol_table, u32 symbol_ID, char* symbo
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	*symbol_name = '\0';
 | 
						*symbol_name = '\0';
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
#pragma region Settings Exposure
 | 
					#pragma region Settings Exposure
 | 
				
			||||||
// Exposing specific properties for user configuration in settings
 | 
					// Exposing specific properties for user configuration in settings
 | 
				
			||||||
@@ -128,6 +124,7 @@ using GetModuleProcedureFn = void* ( BinaryModule module, char const* symbol );
 | 
				
			|||||||
// It will allow for only reading or writting to a file at a time.
 | 
					// It will allow for only reading or writting to a file at a time.
 | 
				
			||||||
// Note: If anything more robust is needed, I'll grab it from the zpl-c library.
 | 
					// Note: If anything more robust is needed, I'll grab it from the zpl-c library.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// TODO(Ed) : These need to be converted to an async interface.
 | 
				
			||||||
using FileCheckExistsFn  = b32 ( Str const file_path );
 | 
					using FileCheckExistsFn  = b32 ( Str const file_path );
 | 
				
			||||||
using FileCloseFn 		 = void ( File* file );
 | 
					using FileCloseFn 		 = void ( File* file );
 | 
				
			||||||
using FileDelete         = b32 ( Str const file_path );
 | 
					using FileDelete         = b32 ( Str const file_path );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -138,8 +138,7 @@ FILETIME file_get_last_write_time( char const* path )
 | 
				
			|||||||
	return dll_file_info.ftLastWriteTime;
 | 
						return dll_file_info.ftLastWriteTime;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if Build_Debug
 | 
					struct AudioTimeMarker
 | 
				
			||||||
struct DebugTimeMarker
 | 
					 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	DWORD OutputPlayCusror;
 | 
						DWORD OutputPlayCusror;
 | 
				
			||||||
	DWORD OutputWriteCursor;
 | 
						DWORD OutputWriteCursor;
 | 
				
			||||||
@@ -152,6 +151,7 @@ struct DebugTimeMarker
 | 
				
			|||||||
	DWORD ExpectedFlipCursor;
 | 
						DWORD ExpectedFlipCursor;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if Build_Debug
 | 
				
			||||||
internal void
 | 
					internal void
 | 
				
			||||||
debug_draw_vertical( s32 x_pos, s32 top, s32 bottom, s32 color )
 | 
					debug_draw_vertical( s32 x_pos, s32 top, s32 bottom, s32 color )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -195,7 +195,7 @@ debug_draw_sound_buffer_marker( DirectSoundBuffer* sound_buffer, f32 ratio
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
internal void
 | 
					internal void
 | 
				
			||||||
debug_sync_display( DirectSoundBuffer* sound_buffer
 | 
					debug_sync_display( DirectSoundBuffer* sound_buffer
 | 
				
			||||||
                   , u32 num_markers, DebugTimeMarker* markers
 | 
					                   , u32 num_markers, AudioTimeMarker* markers
 | 
				
			||||||
				   , u32 current_marker
 | 
									   , u32 current_marker
 | 
				
			||||||
                   , f32 ms_per_frame )
 | 
					                   , f32 ms_per_frame )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -206,7 +206,7 @@ debug_sync_display( DirectSoundBuffer* sound_buffer
 | 
				
			|||||||
	u32 line_height = 64;
 | 
						u32 line_height = 64;
 | 
				
			||||||
	for ( u32 marker_index = 0; marker_index < num_markers; ++ marker_index )
 | 
						for ( u32 marker_index = 0; marker_index < num_markers; ++ marker_index )
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		DebugTimeMarker* marker = & markers[marker_index];
 | 
							AudioTimeMarker* marker = & markers[marker_index];
 | 
				
			||||||
		assert( marker->OutputPlayCusror  < sound_buffer->SecondaryBufferSize );
 | 
							assert( marker->OutputPlayCusror  < sound_buffer->SecondaryBufferSize );
 | 
				
			||||||
		assert( marker->OutputWriteCursor < sound_buffer->SecondaryBufferSize );
 | 
							assert( marker->OutputWriteCursor < sound_buffer->SecondaryBufferSize );
 | 
				
			||||||
		assert( marker->OutputLocation    < sound_buffer->SecondaryBufferSize );
 | 
							assert( marker->OutputLocation    < sound_buffer->SecondaryBufferSize );
 | 
				
			||||||
@@ -843,6 +843,12 @@ process_pending_window_messages( engine::KeyboardState* keyboard )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#pragma region Platfom API
 | 
					#pragma region Platfom API
 | 
				
			||||||
#if Build_Development
 | 
					#if Build_Development
 | 
				
			||||||
 | 
					void debug_set_pause_rendering( b32 value )
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Pause_Rendering = value;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
b32 file_check_exists( Str path )
 | 
					b32 file_check_exists( Str path )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	HANDLE file_handle = CreateFileA( path
 | 
						HANDLE file_handle = CreateFileA( path
 | 
				
			||||||
@@ -1022,12 +1028,6 @@ u32 file_write_content( File* file, u32 content_size, void* content_memory )
 | 
				
			|||||||
	return bytes_written;
 | 
						return bytes_written;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void debug_set_pause_rendering( b32 value )
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	Pause_Rendering = value;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
u32 get_monitor_refresh_rate()
 | 
					u32 get_monitor_refresh_rate()
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	return 0;
 | 
						return 0;
 | 
				
			||||||
@@ -1223,7 +1223,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
			L"Handmade Hero",
 | 
								L"Handmade Hero",
 | 
				
			||||||
			WS_Overlapped_Window | WS_Initially_Visible,
 | 
								WS_Overlapped_Window | WS_Initially_Visible,
 | 
				
			||||||
			CW_Use_Default, CW_Use_Default, // x, y
 | 
								CW_Use_Default, CW_Use_Default, // x, y
 | 
				
			||||||
			CW_Use_Default, CW_Use_Default, // width, height
 | 
								1100, 700, // width, height
 | 
				
			||||||
			0, 0,                         // parent, menu
 | 
								0, 0,                         // parent, menu
 | 
				
			||||||
			instance, 0                   // instance, param
 | 
								instance, 0                   // instance, param
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
@@ -1307,6 +1307,10 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
	DWORD             ds_cursor_byte_delta = 0;
 | 
						DWORD             ds_cursor_byte_delta = 0;
 | 
				
			||||||
	f32               ds_latency_ms        = 0;
 | 
						f32               ds_latency_ms        = 0;
 | 
				
			||||||
	DirectSoundBuffer ds_sound_buffer;
 | 
						DirectSoundBuffer ds_sound_buffer;
 | 
				
			||||||
 | 
						u32               audio_marker_index = 0;
 | 
				
			||||||
 | 
						AudioTimeMarker   audio_time_markers[ Monitor_Refresh_Max_Supported ] {};
 | 
				
			||||||
 | 
						u32               audio_time_markers_size = Engine_Refresh_Hz / 2;
 | 
				
			||||||
 | 
						assert( audio_time_markers_size <= Monitor_Refresh_Max_Supported )
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		ds_sound_buffer.IsPlaying        = 0;
 | 
							ds_sound_buffer.IsPlaying        = 0;
 | 
				
			||||||
		ds_sound_buffer.SamplesPerSecond = 48000;
 | 
							ds_sound_buffer.SamplesPerSecond = 48000;
 | 
				
			||||||
@@ -1333,12 +1337,6 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
			ds_sound_buffer.GuardSampleBytes = min_guard_sample_bytes;
 | 
								ds_sound_buffer.GuardSampleBytes = min_guard_sample_bytes;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
#if Build_Development
 | 
					 | 
				
			||||||
	u32             debug_marker_index = 0;
 | 
					 | 
				
			||||||
	DebugTimeMarker debug_markers[ Monitor_Refresh_Max_Supported ] {};
 | 
					 | 
				
			||||||
	u32             debug_marker_history_size = Engine_Refresh_Hz / 2;
 | 
					 | 
				
			||||||
	assert( debug_marker_history_size <= Monitor_Refresh_Max_Supported )
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	engine::InputState input {};
 | 
						engine::InputState input {};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1546,7 +1544,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
			sound_buffer.Samples            = ds_sound_buffer.Samples;
 | 
								sound_buffer.Samples            = ds_sound_buffer.Samples;
 | 
				
			||||||
			engine_api.update_audio( & sound_buffer, & engine_memory, & platform_api );
 | 
								engine_api.update_audio( & sound_buffer, & engine_memory, & platform_api );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			DebugTimeMarker* marker = & debug_markers[ debug_marker_index ];
 | 
								AudioTimeMarker* marker = & audio_time_markers[ audio_marker_index ];
 | 
				
			||||||
			marker->OutputPlayCusror   = ds_play_cursor;
 | 
								marker->OutputPlayCusror   = ds_play_cursor;
 | 
				
			||||||
			marker->OutputWriteCursor  = ds_write_cursor;
 | 
								marker->OutputWriteCursor  = ds_write_cursor;
 | 
				
			||||||
			marker->OutputLocation     = byte_to_lock;
 | 
								marker->OutputLocation     = byte_to_lock;
 | 
				
			||||||
@@ -1642,7 +1640,7 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
		#if Build_Development
 | 
							#if Build_Development
 | 
				
			||||||
			// Note: debug_marker_index is wrong for the 0th index
 | 
								// Note: debug_marker_index is wrong for the 0th index
 | 
				
			||||||
			debug_sync_display( & ds_sound_buffer
 | 
								debug_sync_display( & ds_sound_buffer
 | 
				
			||||||
				, debug_marker_history_size, debug_markers, debug_marker_index - 1
 | 
									, audio_time_markers_size, audio_time_markers, audio_marker_index - 1
 | 
				
			||||||
				, Engine_Frame_Target_MS );
 | 
									, Engine_Frame_Target_MS );
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1666,8 +1664,8 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
					sound_is_valid = true;
 | 
										sound_is_valid = true;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				assert( debug_marker_index < debug_marker_history_size )
 | 
									assert( audio_marker_index < audio_time_markers_size )
 | 
				
			||||||
				DebugTimeMarker* marker = & debug_markers[ debug_marker_index ];
 | 
									AudioTimeMarker* marker = & audio_time_markers[ audio_marker_index ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				marker->FlipPlayCursor  = play_cursor;
 | 
									marker->FlipPlayCursor  = play_cursor;
 | 
				
			||||||
				marker->FlipWriteCursor = write_cursor;
 | 
									marker->FlipWriteCursor = write_cursor;
 | 
				
			||||||
@@ -1676,9 +1674,9 @@ WinMain( HINSTANCE instance, HINSTANCE prev_instance, LPSTR commandline, int sho
 | 
				
			|||||||
		#endif
 | 
							#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		#if Build_Development
 | 
							#if Build_Development
 | 
				
			||||||
			debug_marker_index++;
 | 
								audio_marker_index++;
 | 
				
			||||||
			if ( debug_marker_index >= debug_marker_history_size )
 | 
								if ( audio_marker_index >= audio_time_markers_size )
 | 
				
			||||||
				debug_marker_index = 0;
 | 
									audio_marker_index = 0;
 | 
				
			||||||
		#endif
 | 
							#endif
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user