From 86fe424f46f21a59ae871bb68ad20c998fe11b4a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 7 Sep 2025 12:22:02 +0200 Subject: checkpoint --- code/handmade.cpp | 135 +++++++++++++++++++++++++++++------------------------ code/libs/linuxhmh | 2 +- 2 files changed, 74 insertions(+), 63 deletions(-) (limited to 'code') diff --git a/code/handmade.cpp b/code/handmade.cpp index fb96977..ca64c27 100644 --- a/code/handmade.cpp +++ b/code/handmade.cpp @@ -532,7 +532,7 @@ PLATFORM_WORK_QUEUE_CALLBACK(GetTodaysWordleCurl) struct tm *LocalTimeNow = localtime(&Now); u8 URLBuffer[256] = {}; - stbsp_sprintf((char *)URLBuffer, "%s/%d-%02d-%d.json", URL, + stbsp_sprintf((char *)URLBuffer, "%s/%d-%02d-%02d.json", URL, LocalTimeNow->tm_year + 1900, LocalTimeNow->tm_mon + 1, LocalTimeNow->tm_mday); @@ -946,79 +946,87 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) s32 PatternRowAt = 0; s32 PatternRowsCount = 6; - for(s32 WordsIndex = 0; - ((WordsIndex < WordsCount) && - (PatternRowAt < PatternRowsCount)); - WordsIndex++) + for(s32 PatternRowAt = 0; + PatternRowAt < PatternRowsCount; + PatternRowAt++) { - // Match the pattern's row against the guess. - // TODO(luca): Check if the guess == the word and skip it otherwise it would end the game. - s32 PatternMatches = 1; - u8 *Guess = &Words[WordsIndex*(WORDLE_LENGTH+1)]; - for(s32 CharIndex = 0; - ((CharIndex < WORDLE_LENGTH) && - (PatternMatches)); - CharIndex++) + s32 PatternMatches = 0; + u8 *Guess = 0; + + for(s32 WordsIndex = 0; + ((WordsIndex < WordsCount) && + (!PatternMatches)); + WordsIndex++) { - u8 GuessCh = Guess[CharIndex]; - s32 PatternValue = GameState->PatternGrid[PatternRowAt][CharIndex]; - - if(PatternValue == SquareColor_Green) - { - PatternMatches = (GuessCh == Word[CharIndex]); - } - else if(PatternValue == SquareColor_Yellow) + // Match the pattern's row against the guess. + // TODO(luca): Check if the guess == the word and skip it otherwise it would end the game. + Guess = &Words[WordsIndex*(WORDLE_LENGTH+1)]; + PatternMatches = 1; + for(s32 CharIndex = 0; + ((CharIndex < WORDLE_LENGTH) && + (PatternMatches)); + CharIndex++) { - PatternMatches = 0; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + u8 GuessCh = Guess[CharIndex]; + s32 PatternValue = GameState->PatternGrid[PatternRowAt][CharIndex]; + + if(PatternValue == SquareColor_Green) + { + PatternMatches = (GuessCh == Word[CharIndex]); + } + else if(PatternValue == SquareColor_Yellow) { - if(Word[CharAt] == GuessCh) + PatternMatches = 0; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - if(CharAt != CharIndex) + if(Word[CharAt] == GuessCh) { - // TODO(luca): Should also check that position does not match. - PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); - } - else - { - PatternMatches = 0; + if(CharAt != CharIndex) + { + // TODO(luca): Should also check that position does not match. + PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); + } + else + { + PatternMatches = 0; + } + + break; } - - break; } + } - - } - // TODO(luca): Have one that can be either yellow/green + // TODO(luca): Have one that can be either yellow/green #if 0 - else if(PatternValue == 1) - { - PatternMatches = 0; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + else if(PatternValue == 1) { - if(Word[CharAt] == GuessCh) + PatternMatches = 0; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); - break; + if(Word[CharAt] == GuessCh) + { + PatternMatches = ValidLetterCountInGuess(Word, Guess, GuessCh); + break; + } } } - } #endif - else if(PatternValue == SquareColor_Gray) - { - PatternMatches = 1; - for(s32 CharAt = 0; - CharAt < WORDLE_LENGTH; - CharAt++) + else if(PatternValue == SquareColor_Gray) { - if(Word[CharAt] == GuessCh) + PatternMatches = 1; + for(s32 CharAt = 0; + CharAt < WORDLE_LENGTH; + CharAt++) { - PatternMatches = 0; - break; + if(Word[CharAt] == GuessCh) + { + PatternMatches = 0; + break; + } } } } @@ -1029,12 +1037,15 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) DrawText(Buffer, &DefaultFont, FontScale, WORDLE_LENGTH, Guess, TextOffset, color_rgb(1.0f), false); - - TextOffset.Y += YAdvance; - - WordsIndex = 0; - PatternRowAt++; } + else + { + u8 Text[] = "no match"; + DrawText(Buffer, &GameState->ItalicFont, FontScale, + sizeof(Text) - 1, Text, + TextOffset, color_rgb(0.6f), false); + } + TextOffset.Y += YAdvance; } } diff --git a/code/libs/linuxhmh b/code/libs/linuxhmh index 36c8c66..0049454 160000 --- a/code/libs/linuxhmh +++ b/code/libs/linuxhmh @@ -1 +1 @@ -Subproject commit 36c8c66d7e04d2a1b84630294cec3fb6dca90b22 +Subproject commit 00494541c8c1c4c7c8feb779cf401c015d42bc4b -- cgit v1.2.3-70-g09d2 From 753406922ee9d0001c9ecc4f5ea3f4fcaa077e38 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 16 Sep 2025 12:17:31 +0200 Subject: checkpoint --- .gitmodules | 3 --- build/handmade.so | Bin 263840 -> 263840 bytes build/linux_handmade | Bin 88272 -> 88528 bytes code/handmade.cpp | 20 +++++++++++++------- 4 files changed, 13 insertions(+), 10 deletions(-) delete mode 100644 .gitmodules (limited to 'code') diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index f2e64bf..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "code/libs/linuxhmh"] - path = code/libs/linuxhmh - url = git@autumn:linuxhmh diff --git a/build/handmade.so b/build/handmade.so index c9e6fde..9a1d827 100755 Binary files a/build/handmade.so and b/build/handmade.so differ diff --git a/build/linux_handmade b/build/linux_handmade index 609ac5e..6ee8550 100755 Binary files a/build/linux_handmade and b/build/linux_handmade differ diff --git a/code/handmade.cpp b/code/handmade.cpp index ca64c27..932215d 100644 --- a/code/handmade.cpp +++ b/code/handmade.cpp @@ -659,6 +659,7 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) InitFont(Thread, &GameState->RegularFont, Memory, "../data/fonts/jetbrains_mono_regular.ttf"); InitFont(Thread, &GameState->ItalicFont, Memory, "../data/fonts/jetbrains_mono_italic.ttf"); InitFont(Thread, &GameState->BoldFont, Memory, "../data/fonts/jetbrains_mono_bold.ttf"); + // TODO(luca): Italic & Bold font. GameState->SelectedColor = SquareColor_Yellow; GameState->ExportedPatternIndex = 0; @@ -1055,7 +1056,7 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) // NOTE(luca): Debug code for drawing inputted text. #if 1 { - r32 FontScale = stbtt_ScaleForPixelHeight(&DefaultFont.Info, 20.0f); + r32 FontScale = stbtt_ScaleForPixelHeight(&DefaultFont.Info, 22.0); v2 Offset = {100.0f, 30.0f}; @@ -1091,6 +1092,16 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) DrawRectangle(Buffer, vMin + -1, vMax + 1, ColorBG); } + // TODO(luca): Placeholder text when text is empty. + // Draw the text + { + DrawText(Buffer, &DefaultFont, FontScale, + GameState->TextInputCount, (u8 *)GameState->TextInputText, + Offset, ColorFG, true); + + Assert(GameState->TextInputCount <= ArrayCount(GameState->TextInputText)); + } + // Draw cursor { v2 vMin = {Offset.X + TextWidth, Offset.Y - Baseline}; @@ -1098,13 +1109,8 @@ extern "C" GAME_UPDATE_AND_RENDER(GameUpdateAndRender) DrawRectangle(Buffer, vMin, vMax, ColorFG); } - // Draw the text - DrawText(Buffer, &DefaultFont, FontScale, - GameState->TextInputCount, (u8 *)GameState->TextInputText, - Offset, ColorFG, true); - - Assert(GameState->TextInputCount <= ArrayCount(GameState->TextInputText)); } + #endif } -- cgit v1.2.3-70-g09d2 From ea122ba7ef3bc5db176527eae42df9d15d661977 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 16 Sep 2025 12:19:49 +0200 Subject: checkpoint --- code/libs/linuxhmh | 1 - code/libs/linuxhmh/handmade_platform.h | 1 + code/libs/linuxhmh/linux_handmade.cpp | 1 + code/libs/linuxhmh/linux_handmade.h | 1 + code/libs/linuxhmh/linux_profile.h | 1 + code/libs/linuxhmh/linux_x11_keysyms_to_strings.c | 1 + code/libs/linuxhmh/win32_handmade.cpp | 1 + code/libs/linuxhmh/win32_handmade.h | 1 + 8 files changed, 7 insertions(+), 1 deletion(-) delete mode 160000 code/libs/linuxhmh create mode 120000 code/libs/linuxhmh/handmade_platform.h create mode 120000 code/libs/linuxhmh/linux_handmade.cpp create mode 120000 code/libs/linuxhmh/linux_handmade.h create mode 120000 code/libs/linuxhmh/linux_profile.h create mode 120000 code/libs/linuxhmh/linux_x11_keysyms_to_strings.c create mode 120000 code/libs/linuxhmh/win32_handmade.cpp create mode 120000 code/libs/linuxhmh/win32_handmade.h (limited to 'code') diff --git a/code/libs/linuxhmh b/code/libs/linuxhmh deleted file mode 160000 index 0049454..0000000 --- a/code/libs/linuxhmh +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 00494541c8c1c4c7c8feb779cf401c015d42bc4b diff --git a/code/libs/linuxhmh/handmade_platform.h b/code/libs/linuxhmh/handmade_platform.h new file mode 120000 index 0000000..3ea1f09 --- /dev/null +++ b/code/libs/linuxhmh/handmade_platform.h @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/handmade_platform.h \ No newline at end of file diff --git a/code/libs/linuxhmh/linux_handmade.cpp b/code/libs/linuxhmh/linux_handmade.cpp new file mode 120000 index 0000000..aa62040 --- /dev/null +++ b/code/libs/linuxhmh/linux_handmade.cpp @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/linux_handmade.cpp \ No newline at end of file diff --git a/code/libs/linuxhmh/linux_handmade.h b/code/libs/linuxhmh/linux_handmade.h new file mode 120000 index 0000000..693943d --- /dev/null +++ b/code/libs/linuxhmh/linux_handmade.h @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/linux_handmade.h \ No newline at end of file diff --git a/code/libs/linuxhmh/linux_profile.h b/code/libs/linuxhmh/linux_profile.h new file mode 120000 index 0000000..38f71cb --- /dev/null +++ b/code/libs/linuxhmh/linux_profile.h @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/linux_profile.h \ No newline at end of file diff --git a/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c b/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c new file mode 120000 index 0000000..0dc8717 --- /dev/null +++ b/code/libs/linuxhmh/linux_x11_keysyms_to_strings.c @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/linux_x11_keysyms_to_strings.c \ No newline at end of file diff --git a/code/libs/linuxhmh/win32_handmade.cpp b/code/libs/linuxhmh/win32_handmade.cpp new file mode 120000 index 0000000..040801a --- /dev/null +++ b/code/libs/linuxhmh/win32_handmade.cpp @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/win32_handmade.cpp \ No newline at end of file diff --git a/code/libs/linuxhmh/win32_handmade.h b/code/libs/linuxhmh/win32_handmade.h new file mode 120000 index 0000000..b2ecdef --- /dev/null +++ b/code/libs/linuxhmh/win32_handmade.h @@ -0,0 +1 @@ +/home/aluc/proj/handmade/linuxhmh/win32_handmade.h \ No newline at end of file -- cgit v1.2.3-70-g09d2 From 188d480246975ec71f37d817303ee1baa913c99c Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 17 Sep 2025 12:43:03 +0200 Subject: checkpoint --- build/handmade.so | Bin 263840 -> 263840 bytes build/linux_handmade | Bin 88528 -> 88608 bytes code/build.sh | 8 ++++++-- 3 files changed, 6 insertions(+), 2 deletions(-) (limited to 'code') diff --git a/build/handmade.so b/build/handmade.so index 9a1d827..8726fef 100755 Binary files a/build/handmade.so and b/build/handmade.so differ diff --git a/build/linux_handmade b/build/linux_handmade index 6ee8550..c31fae5 100755 Binary files a/build/linux_handmade and b/build/linux_handmade differ diff --git a/code/build.sh b/code/build.sh index 966bcc3..4a08c7c 100755 --- a/code/build.sh +++ b/code/build.sh @@ -5,7 +5,7 @@ cd "$ThisDir" mkdir ../build > /dev/null 2>&1 -# Supported: clang, g++ +# Supported: clang Compiler="clang" CompilerFlags=" @@ -16,6 +16,7 @@ CompilerFlags=" -DHANDMADE_SLOW -DOS_LINUX -nostdinc++ + " WarningFlags="-Wall @@ -26,7 +27,10 @@ WarningFlags="-Wall -Wno-write-strings -Wno-pointer-arith -Wno-unused-parameter --Wno-unused-function" +-Wno-unused-function +-Wno-int-to-pointer-cast +-Wno-missing-field-initializers +" ClangCompilerFlags=" -ftime-trace -- cgit v1.2.3-70-g09d2 From a36d8e063dcaca2fe4c6d15f4695b4602a7d3655 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 21 Sep 2025 16:10:35 +0200 Subject: checkpoint --- build/linux_handmade | Bin 89456 -> 89456 bytes code/build.sh | 1 + 2 files changed, 1 insertion(+) (limited to 'code') diff --git a/build/linux_handmade b/build/linux_handmade index e5128b0..495db72 100755 Binary files a/build/linux_handmade and b/build/linux_handmade differ diff --git a/code/build.sh b/code/build.sh index 4a08c7c..9575bfe 100755 --- a/code/build.sh +++ b/code/build.sh @@ -15,6 +15,7 @@ CompilerFlags=" -DHANDMADE_INTERNAL -DHANDMADE_SLOW -DOS_LINUX +-DHANDMADE_SMALL_RESOLUTION -nostdinc++ " -- cgit v1.2.3-70-g09d2