Day 10 Complete

This commit is contained in:
Edward R. Gonzalez 2023-09-14 00:43:35 -04:00
parent 3a0d1124c9
commit 97c2a46805
6 changed files with 87 additions and 89 deletions

View File

@ -512,6 +512,7 @@ WinMain(
JSL_DeviceHandle device_handles[4] {};
u32 jsl_getconnected_found = JslGetConnectedDeviceHandles( device_handles, jsl_num_devices );
{
if ( jsl_getconnected_found != jsl_num_devices )
{
OutputDebugStringA( "Error: JSLGetConnectedDeviceHandles didn't find as many as were stated with JslConnectDevices\n");
@ -525,6 +526,8 @@ WinMain(
JslSetLightColour( device_handles[ jsl_device_index ], (255 << 8) );
}
}
}
// MessageBox( 0, L"First message!", L"Handmade Hero", MB_Ok_Btn | MB_Icon_Information );
@ -611,12 +614,19 @@ WinMain(
u16 stick_right_x = 0;
u16 stick_right_y = 0;
// TODO : Add sine wave test
// Windows
MSG window_msg_info;
u64 perf_counter_frequency;
QueryPerformanceFrequency( rcast(LARGE_INTEGER*, & perf_counter_frequency) );
u64 last_frame_time;
QueryPerformanceCounter( rcast(LARGE_INTEGER*, & last_frame_time) );
u64 last_cycle_time = __rdtsc();
while( Running )
{
// Window Management
@ -820,6 +830,28 @@ WinMain(
#endif
DS_SecondaryBuffer->Play( 0, 0, DSBPLAY_LOOPING );
} while(0);
u64 end_cycle_count = __rdtsc();
u64 frame_cycle_time_end;
QueryPerformanceCounter( rcast( LARGE_INTEGER*, & frame_cycle_time_end) );
// TODO : Display value here
#define MS_PER_SECOND 1000
#define MegaCycles_Per_Second (1000 * 1000)
u64 cycles_elapsed = end_cycle_count - last_cycle_time;
s32 mega_cycles_elapsed = cycles_elapsed / MegaCycles_Per_Second;
u64 frame_time_elapsed = frame_cycle_time_end - last_frame_time;
u32 ms_per_frame = MS_PER_SECOND * frame_time_elapsed / perf_counter_frequency;
u32 fps = perf_counter_frequency / frame_time_elapsed;
char ms_timing_debug[256] {};
wsprintfA( ms_timing_debug, "%d ms\n" "FPS: %d\n" "mega cycles: %d\n", ms_per_frame, fps, mega_cycles_elapsed );
OutputDebugStringA( ms_timing_debug );
last_cycle_time = end_cycle_count;
last_frame_time = frame_cycle_time_end;
}
if ( jsl_num_devices > 0 )

View File

@ -5,64 +5,46 @@
/* Platform architecture */
#if defined( _WIN64 ) || defined( __x86_64__ ) || defined( _M_X64 ) || defined( __64BIT__ ) || defined( __powerpc64__ ) || defined( __ppc64__ ) || defined( __aarch64__ )
# ifndef GEN_ARCH_64_BIT
# define GEN_ARCH_64_BIT 1
# ifndef ARCH_64_BIT
# define ARCH_64_BIT 1
# endif
#else
# ifndef GEN_ARCH_32_BItxt_StrCaT
# define GEN_ARCH_32_BIT 1
# endif
# error A 32-bit architecture is not supported
#endif
/* Platform OS */
#if defined( _WIN32 ) || defined( _WIN64 )
# ifndef GEN_SYSTEM_WINDOWS
# define GEN_SYSTEM_WINDOWS 1
# ifndef SYSTEM_WINDOWS
# define SYSTEM_WINDOWS 1
# endif
#elif defined( __APPLE__ ) && defined( __MACH__ )
# ifndef GEN_SYSTEM_OSX
# define GEN_SYSTEM_OSX 1
# ifndef SYSTEM_OSX
# define SYSTEM_OSX 1
# endif
# ifndef GEN_SYSTEM_MACOS
# define GEN_SYSTEM_MACOS 1
# ifndef SYSTEM_MACOS
# define SYSTEM_MACOS 1
# endif
# include <TargetConditionals.h>
# if TARGET_IPHONE_SIMULATOR == 1 || TARGET_OS_IPHONE == 1
# ifndef GEN_SYSTEM_IOS
# define GEN_SYSTEM_IOS 1
# ifndef SYSTEM_IOS
# define SYSTEM_IOS 1
# endif
# endif
#elif defined( __unix__ )
# ifndef GEN_SYSTEM_UNIX
# ifndef SYSTEM_UNIX
# define GEN_SYSTEM_UNIX 1
# endif
# if defined( ANDROID ) || defined( __ANDROID__ )
# ifndef GEN_SYSTEM_ANDROID
# define GEN_SYSTEM_ANDROID 1
# ifndef SYSTEM_ANDROID
# define SYSTEM_ANDROID 1
# endif
# ifndef GEN_SYSTEM_LINUX
# define GEN_SYSTEM_LINUX 1
# ifndef SYSTEM_LINUX
# define SYSTEM_LINUX 1
# endif
# elif defined( __linux__ )
# ifndef GEN_SYSTEM_LINUX
# define GEN_SYSTEM_LINUX 1
# endif
# elif defined( __FreeBSD__ ) || defined( __FreeBSD_kernel__ )
# ifndef GEN_SYSTEM_FREEBSD
# define GEN_SYSTEM_FREEBSD 1
# endif
# elif defined( __OpenBSD__ )
# ifndef GEN_SYSTEM_OPENBSD
# define GEN_SYSTEM_OPENBSD 1
# endif
# elif defined( __EMSCRIPTEN__ )
# ifndef GEN_SYSTEM_EMSCRIPTEN
# define GEN_SYSTEM_EMSCRIPTEN 1
# endif
# elif defined( __CYGWIN__ )
# ifndef GEN_SYSTEM_CYGWIN
# define GEN_SYSTEM_CYGWIN 1
# ifndef SYSTEM_LINUX
# define SYSTEM_LINUX 1
# endif
# else
# error This UNIX operating system is not supported
@ -74,29 +56,17 @@
/* Platform compiler */
#if defined( _MSC_VER )
# define GEN_COMPILER_MSVC 1
#elif defined( __GNUC__ )
# define GEN_COMPILER_GCC 1
# define COMPILER_MSVC 1
#elif defined( __clang__ )
# define GEN_COMPILER_CLANG 1
#elif defined( __MINGW32__ )
# define GEN_COMPILER_MINGW 1
# define COMPILER_CLANG 1
#else
# error Unknown compiler
#endif
#if defined( __has_attribute )
# define GEN_HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
# define HAS_ATTRIBUTE( attribute ) __has_attribute( attribute )
#else
# define GEN_HAS_ATTRIBUTE( attribute ) ( 0 )
#endif
#if defined(GEN_GCC_VERSION_CHECK)
# undef GEN_GCC_VERSION_CHECK
#endif
#if defined(GEN_GCC_VERSION)
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (GEN_GCC_VERSION >= GEN_VERSION_ENCODE(major, minor, patch))
#else
# define GEN_GCC_VERSION_CHECK(major,minor,patch) (0)
# define HAS_ATTRIBUTE( attribute ) ( 0 )
#endif
#pragma endregion Platform Detection
@ -106,7 +76,7 @@
# include <stdarg.h>
# include <stddef.h>
# if defined( GEN_SYSTEM_WINDOWS )
# if defined( SYSTEM_WINDOWS )
# include <intrin.h>
# endif

View File

@ -1,4 +1,5 @@
# define CONSTANTS
#pragma once
# define EPSILON 1.19209290e-7f
# define ZERO 0.0f
# define ONE 1.0f

View File

@ -22,18 +22,13 @@
#define I64_MIN ( -0x7fffffffffffffffll - 1 )
#define I64_MAX 0x7fffffffffffffffll
#if defined( GEN_ARCH_32_BIT )
# define USIZE_MIN GEN_U32_MIN
# define USIZE_MAX GEN_U32_MAX
# define ISIZE_MIN GEN_S32_MIN
# define ISIZE_MAX GEN_S32_MAX
#elif defined( GEN_ARCH_64_BIT )
#if defined( ARCH_64_BIT )
# define USIZE_MIN GEN_U64_MIN
# define USIZE_MAX GEN_U64_MAX
# define ISIZE_MIN GEN_I64_MIN
# define ISIZE_MAX GEN_I64_MAX
#else
# error Unknown architecture size. This library only supports 32 bit and 64 bit architectures.
# error Unknown architecture size. This library only supports 64 bit architectures.
#endif
#define F32_MIN 1.17549435e-38f
@ -41,7 +36,7 @@
#define F64_MIN 2.2250738585072014e-308
#define F64_MAX 1.7976931348623157e+308
#if defined( GEN_COMPILER_MSVC )
#if defined( COMPILER_MSVC )
# if _MSC_VER < 1300
typedef unsigned char u8;
typedef signed char s8;
@ -87,21 +82,9 @@ typedef ptrdiff_t sw;
static_assert( sizeof( uw ) == sizeof( sw ), "sizeof(uw) != sizeof(sw)" );
// NOTE: (u)zpl_intptr is only here for semantic reasons really as this library will only support 32/64 bit OSes.
#if defined( _WIN64 )
typedef signed __int64 sptr;
typedef unsigned __int64 uptr;
#elif defined( _WIN32 )
// NOTE; To mark types changing their size, e.g. zpl_intptr
# ifndef _W64
# if ! defined( __midl ) && ( defined( _X86_ ) || defined( _M_IX86 ) ) && _MSC_VER >= 1300
# define _W64 __w64
# else
# define _W64
# endif
# endif
typedef _W64 signed int sptr;
typedef _W64 unsigned int uptr;
#else
typedef uintptr_t uptr;
typedef intptr_t sptr;

View File

@ -1,6 +1,7 @@
/*
Alternative header for windows.h
*/
#pragma once
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
@ -112,21 +113,25 @@ WIN_LIB_API DWORD WINAPI XInputGetState
(
DWORD dwUserIndex, // Index of the gamer associated with the device
XINPUT_STATE* pState // Receives the current state
) WIN_NOEXCEPT;
);
WIN_LIB_API DWORD WINAPI XInputSetState
(
DWORD dwUserIndex, // Index of the gamer associated with the device
XINPUT_VIBRATION* pVibration // The vibration information to send to the controller
) WIN_NOEXCEPT;
);
DWORD WINAPI xinput_get_state_stub( DWORD dwUserIndex, XINPUT_STATE* pVibration ) {
do_once_start
OutputDebugStringA( "xinput_get_state stubbed!\n");
do_once_end
return ERROR_DEVICE_NOT_CONNECTED;
}
DWORD WINAPI xinput_set_state_stub( DWORD dwUserIndex, XINPUT_VIBRATION* pVibration ) {
do_once_start
OutputDebugStringA( "xinput_set_state stubbed!\n");
do_once_end
return ERROR_DEVICE_NOT_CONNECTED;
}

View File

@ -115,6 +115,7 @@ if ( $vendor -match "clang" )
$flag_debug = '-g'
$flag_debug_codeview = '-gcodeview'
$flag_define = '-D'
$flag_exceptions_disabled = '-fno-exceptions'
$flag_preprocess = '-E'
$flag_include = '-I'
$flag_library = '-l'
@ -162,6 +163,7 @@ if ( $vendor -match "clang" )
$compiler_args += @(
$flag_no_color_diagnostics,
$flag_exceptions_disabled,
$flag_target_arch, $target_arch,
$flag_wall,
$flag_preprocess_non_intergrated,
@ -210,6 +212,8 @@ if ( $vendor -match "msvc" )
$flag_compile = '/c'
$flag_debug = '/Zi'
$flag_define = '/D'
$flag_exceptions_disabled = '/EHs-c-'
$flag_RTTI_disabled = '/GR-'
$flag_include = '/I'
$flag_full_src_path = '/FC'
$flag_nologo = '/nologo'
@ -245,6 +249,9 @@ if ( $vendor -match "msvc" )
$compiler_args += @(
$flag_nologo,
$flag_exceptions_disabled,
( $flag_define + '_HAS_EXCEPTIONS=0' ),
$flag_RTTI_disabled,
$flag_preprocess_conform,
$flag_full_src_path,
( $flag_path_interm + $path_build + '\' ),