From ad09400dd7360504ca6a98993549ea63c1173d11 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 9 Dec 2024 17:01:34 -0700 Subject: [PATCH 1/5] chore: run fbt --- chess/smallchesslib.h | 2 +- flipchess.h | 7 +++++-- helpers/flipchess_custom_event.h | 2 +- helpers/flipchess_file.c | 12 ++++++------ helpers/flipchess_file.h | 2 +- helpers/flipchess_voice.cpp | 2 +- sam/stm32_sam.cpp | 8 +++++--- sam/stm32_sam.h | 2 +- scenes/flipchess_scene_config.h | 2 +- scenes/flipchess_scene_menu.c | 2 +- scenes/flipchess_scene_scene_1.c | 2 +- scenes/flipchess_scene_settings.c | 4 ++-- scenes/flipchess_scene_startscreen.c | 2 +- views/flipchess_scene_1.c | 27 ++++++++++++--------------- views/flipchess_scene_1.h | 2 +- views/flipchess_startscreen.c | 3 +-- views/flipchess_startscreen.h | 2 +- 17 files changed, 42 insertions(+), 41 deletions(-) diff --git a/chess/smallchesslib.h b/chess/smallchesslib.h index 802ec7f..0382cfc 100644 --- a/chess/smallchesslib.h +++ b/chess/smallchesslib.h @@ -3515,4 +3515,4 @@ uint8_t SCL_boardMoveIsLegal(SCL_Board board, uint8_t squareFrom, uint8_t square return SCL_squareSetContains(moves, squareTo); } -#endif // guard \ No newline at end of file +#endif // guard diff --git a/flipchess.h b/flipchess.h index 761f667..8849575 100644 --- a/flipchess.h +++ b/flipchess.h @@ -19,7 +19,7 @@ #define FLIPCHESS_VERSION "v1.11" #define TEXT_BUFFER_SIZE 96 -#define TEXT_SIZE (TEXT_BUFFER_SIZE - 1) +#define TEXT_SIZE (TEXT_BUFFER_SIZE - 1) typedef struct { Gui* gui; @@ -65,7 +65,10 @@ typedef enum { FlipChessPlayerAI3 = 3, } FlipChessPlayerMode; -typedef enum { FlipChessTextInputDefault, FlipChessTextInputGame } FlipChessTextInputState; +typedef enum { + FlipChessTextInputDefault, + FlipChessTextInputGame +} FlipChessTextInputState; typedef enum { FlipChessStatusNone = 0, diff --git a/helpers/flipchess_custom_event.h b/helpers/flipchess_custom_event.h index 4391a2f..098160a 100644 --- a/helpers/flipchess_custom_event.h +++ b/helpers/flipchess_custom_event.h @@ -13,4 +13,4 @@ typedef enum { FlipChessCustomEventScene1Right, FlipChessCustomEventScene1Ok, FlipChessCustomEventScene1Back, -} FlipChessCustomEvent; \ No newline at end of file +} FlipChessCustomEvent; diff --git a/helpers/flipchess_file.c b/helpers/flipchess_file.c index 99aee49..f2acde3 100644 --- a/helpers/flipchess_file.c +++ b/helpers/flipchess_file.c @@ -3,15 +3,15 @@ #include // #define FLIPCHESS_APP_BASE_FOLDER APP_BOARDA_PATH("flipchess") -#define FLIPCHESS_APP_BASE_FOLDER EXT_PATH("apps_data/flipchess") +#define FLIPCHESS_APP_BASE_FOLDER EXT_PATH("apps_data/flipchess") #define FLIPCHESS_APP_BASE_FOLDER_PATH(path) FLIPCHESS_APP_BASE_FOLDER "/" path -#define FLIPCHESS_BOARD_FILE_NAME "board_fen.txt" -#define FLIPCHESS_BOARD_FILE_NAME_BAK "board_fen.bak" -#define FLIPCHESS_BOARD_PATH FLIPCHESS_APP_BASE_FOLDER_PATH(FLIPCHESS_BOARD_FILE_NAME) -#define FLIPCHESS_BOARD_PATH_BAK FLIPCHESS_APP_BASE_FOLDER_PATH(FLIPCHESS_BOARD_FILE_NAME_BAK) +#define FLIPCHESS_BOARD_FILE_NAME "board_fen.txt" +#define FLIPCHESS_BOARD_FILE_NAME_BAK "board_fen.bak" +#define FLIPCHESS_BOARD_PATH FLIPCHESS_APP_BASE_FOLDER_PATH(FLIPCHESS_BOARD_FILE_NAME) +#define FLIPCHESS_BOARD_PATH_BAK FLIPCHESS_APP_BASE_FOLDER_PATH(FLIPCHESS_BOARD_FILE_NAME_BAK) #define FILE_MAX_PATH_LEN 48 -#define FILE_MAX_CHARS 94 +#define FILE_MAX_CHARS 94 bool flipchess_has_file(const FlipChessFile file_type, const char* file_name, const bool remove) { bool ret = false; diff --git a/helpers/flipchess_file.h b/helpers/flipchess_file.h index 1550b2e..b29a25b 100644 --- a/helpers/flipchess_file.h +++ b/helpers/flipchess_file.h @@ -12,4 +12,4 @@ bool flipchess_save_file( const FlipChessFile file_type, const char* file_name, const bool append, - const bool overwrite); \ No newline at end of file + const bool overwrite); diff --git a/helpers/flipchess_voice.cpp b/helpers/flipchess_voice.cpp index 9e0c199..0ef416e 100644 --- a/helpers/flipchess_voice.cpp +++ b/helpers/flipchess_voice.cpp @@ -34,4 +34,4 @@ void flipchess_voice_a_strange_game() { voice.say("A STRANGE GAME... THE ONLY WINNING MOVE IS NOT TO PLAY."); furi_hal_speaker_release(); } -} \ No newline at end of file +} diff --git a/sam/stm32_sam.cpp b/sam/stm32_sam.cpp index cd36ec6..3dd3691 100644 --- a/sam/stm32_sam.cpp +++ b/sam/stm32_sam.cpp @@ -3304,7 +3304,8 @@ void STM32SAM::AddInflection(unsigned char mem48, unsigned char phase1) { // FIXME: Explain this fix better, it's not obvious // ML : A =, fixes a problem with invalid pitch with '.' - while((A = pitches[X]) == 127) X++; + while((A = pitches[X]) == 127) + X++; pos48398: //48398: CLC @@ -3787,7 +3788,8 @@ int STM32SAM::Parser1() { Y = 0; // CLEAR THE STRESS TABLE - for(i = 0; i < 256; i++) stress[i] = 0; + for(i = 0; i < 256; i++) + stress[i] = 0; // THIS CODE MATCHES THE PHONEME LETTERS TO THE TABLE // pos41078: @@ -5628,7 +5630,7 @@ void STM32SAM::setThroat(unsigned char _throat /* = 128 */) { #include #include -#define FURI_HAL_SPEAKER_TIMER TIM16 +#define FURI_HAL_SPEAKER_TIMER TIM16 #define FURI_HAL_SPEAKER_CHANNEL LL_TIM_CHANNEL_CH1 void STM32SAM::begin(void) { diff --git a/sam/stm32_sam.h b/sam/stm32_sam.h index 910227a..c9d5326 100644 --- a/sam/stm32_sam.h +++ b/sam/stm32_sam.h @@ -93,4 +93,4 @@ class STM32SAM { }; // STM32SAM class -#endif \ No newline at end of file +#endif diff --git a/scenes/flipchess_scene_config.h b/scenes/flipchess_scene_config.h index a1cc0d5..4b030dc 100644 --- a/scenes/flipchess_scene_config.h +++ b/scenes/flipchess_scene_config.h @@ -1,4 +1,4 @@ ADD_SCENE(flipchess, startscreen, Startscreen) ADD_SCENE(flipchess, menu, Menu) ADD_SCENE(flipchess, scene_1, Scene_1) -ADD_SCENE(flipchess, settings, Settings) \ No newline at end of file +ADD_SCENE(flipchess, settings, Settings) diff --git a/scenes/flipchess_scene_menu.c b/scenes/flipchess_scene_menu.c index 448bfc6..c2e193a 100644 --- a/scenes/flipchess_scene_menu.c +++ b/scenes/flipchess_scene_menu.c @@ -88,4 +88,4 @@ bool flipchess_scene_menu_on_event(void* context, SceneManagerEvent event) { void flipchess_scene_menu_on_exit(void* context) { FlipChess* app = context; submenu_reset(app->submenu); -} \ No newline at end of file +} diff --git a/scenes/flipchess_scene_scene_1.c b/scenes/flipchess_scene_scene_1.c index 11e96b5..0029f6e 100644 --- a/scenes/flipchess_scene_scene_1.c +++ b/scenes/flipchess_scene_scene_1.c @@ -52,4 +52,4 @@ void flipchess_scene_scene_1_on_exit(void* context) { if(app->import_game == 1 && strlen(app->import_game_text) > 0) { flipchess_save_file(app->import_game_text, FlipChessFileBoard, NULL, false, true); } -} \ No newline at end of file +} diff --git a/scenes/flipchess_scene_settings.c b/scenes/flipchess_scene_settings.c index 51833b9..127050f 100644 --- a/scenes/flipchess_scene_settings.c +++ b/scenes/flipchess_scene_settings.c @@ -2,7 +2,7 @@ #include "../helpers/flipchess_voice.h" #include -#define TEXT_LABEL_ON "ON" +#define TEXT_LABEL_ON "ON" #define TEXT_LABEL_OFF "OFF" const char* const haptic_text[2] = { @@ -99,4 +99,4 @@ void flipchess_scene_settings_on_exit(void* context) { FlipChess* app = context; variable_item_list_set_selected_item(app->variable_item_list, 0); variable_item_list_reset(app->variable_item_list); -} \ No newline at end of file +} diff --git a/scenes/flipchess_scene_startscreen.c b/scenes/flipchess_scene_startscreen.c index f9dfde7..b417e13 100644 --- a/scenes/flipchess_scene_startscreen.c +++ b/scenes/flipchess_scene_startscreen.c @@ -64,4 +64,4 @@ void flipchess_scene_startscreen_on_exit(void* context) { if(app->sound == 1) { flipchess_voice_shall_we_play(); } -} \ No newline at end of file +} diff --git a/views/flipchess_scene_1.c b/views/flipchess_scene_1.c index 630e9af..b44b6e4 100644 --- a/views/flipchess_scene_1.c +++ b/views/flipchess_scene_1.c @@ -10,16 +10,16 @@ #include "../helpers/flipchess_voice.h" #include "../helpers/flipchess_haptic.h" -#define SCL_960_CASTLING 0 // setting to 1 compiles a 960 version of smolchess -#define XBOARD_DEBUG 0 // will create files with xboard communication +#define SCL_960_CASTLING 0 // setting to 1 compiles a 960 version of smolchess +#define XBOARD_DEBUG 0 // will create files with xboard communication #define SCL_EVALUATION_FUNCTION SCL_boardEvaluateStatic -#define SCL_DEBUG_AI 0 +#define SCL_DEBUG_AI 0 #include "../chess/smallchesslib.h" -#define ENABLE_960 0 // setting to 1 enables 960 chess -#define MAX_TEXT_LEN 15 // 15 = max length of text -#define MAX_TEXT_BUF (MAX_TEXT_LEN + 1) // max length of text + null terminator +#define ENABLE_960 0 // setting to 1 enables 960 chess +#define MAX_TEXT_LEN 15 // 15 = max length of text +#define MAX_TEXT_BUF (MAX_TEXT_LEN + 1) // max length of text + null terminator #define THREAD_WAIT_TIME 20 // time to wait for draw thread to finish struct FlipChessScene1 { @@ -231,15 +231,14 @@ uint8_t flipchess_turn(FlipChessScene1Model* model) { // Color check before allowing piece selection char piece = model->game.board[model->squareSelected]; if(piece != '.' && - SCL_pieceIsWhite(piece) == SCL_boardWhitesTurn(model->game.board)) { + SCL_pieceIsWhite(piece) == SCL_boardWhitesTurn(model->game.board)) { model->squareFrom = model->squareSelected; model->turnState = 1; } } else if(model->turnState == 1 && model->squareSelected != 255) { // Validate before executing - if(SCL_boardMoveIsLegal(model->game.board, - model->squareFrom, - model->squareSelected)) { + if(SCL_boardMoveIsLegal( + model->game.board, model->squareFrom, model->squareSelected)) { model->squareTo = model->squareSelected; model->turnState = 2; model->squareSelectedLast = model->squareSelected; @@ -665,8 +664,7 @@ void flipchess_scene_1_exit(void* context) { furi_assert(context); FlipChessScene1* instance = (FlipChessScene1*)context; - with_view_model( - instance->view, FlipChessScene1Model * model, { model->paramExit = 0; }, true); + with_view_model(instance->view, FlipChessScene1Model * model, { model->paramExit = 0; }, true); } void flipchess_scene_1_enter(void* context) { @@ -727,8 +725,7 @@ FlipChessScene1* flipchess_scene_1_alloc() { void flipchess_scene_1_free(FlipChessScene1* instance) { furi_assert(instance); - with_view_model( - instance->view, FlipChessScene1Model * model, { UNUSED(model); }, true); + with_view_model(instance->view, FlipChessScene1Model * model, { UNUSED(model); }, true); view_free(instance->view); free(instance); @@ -737,4 +734,4 @@ void flipchess_scene_1_free(FlipChessScene1* instance) { View* flipchess_scene_1_get_view(FlipChessScene1* instance) { furi_assert(instance); return instance->view; -} \ No newline at end of file +} diff --git a/views/flipchess_scene_1.h b/views/flipchess_scene_1.h index a57a907..4273e5a 100644 --- a/views/flipchess_scene_1.h +++ b/views/flipchess_scene_1.h @@ -16,4 +16,4 @@ View* flipchess_scene_1_get_view(FlipChessScene1* flipchess_static); FlipChessScene1* flipchess_scene_1_alloc(); -void flipchess_scene_1_free(FlipChessScene1* flipchess_static); \ No newline at end of file +void flipchess_scene_1_free(FlipChessScene1* flipchess_static); diff --git a/views/flipchess_startscreen.c b/views/flipchess_startscreen.c index 5b1c3c7..963b338 100644 --- a/views/flipchess_startscreen.c +++ b/views/flipchess_startscreen.c @@ -148,8 +148,7 @@ FlipChessStartscreen* flipchess_startscreen_alloc() { void flipchess_startscreen_free(FlipChessStartscreen* instance) { furi_assert(instance); - with_view_model( - instance->view, FlipChessStartscreenModel * model, { UNUSED(model); }, true); + with_view_model(instance->view, FlipChessStartscreenModel * model, { UNUSED(model); }, true); view_free(instance->view); free(instance); } diff --git a/views/flipchess_startscreen.h b/views/flipchess_startscreen.h index 7c62035..a4905a3 100644 --- a/views/flipchess_startscreen.h +++ b/views/flipchess_startscreen.h @@ -16,4 +16,4 @@ View* flipchess_startscreen_get_view(FlipChessStartscreen* flipchess_static); FlipChessStartscreen* flipchess_startscreen_alloc(); -void flipchess_startscreen_free(FlipChessStartscreen* flipchess_static); \ No newline at end of file +void flipchess_startscreen_free(FlipChessStartscreen* flipchess_static); From 9d481a1f19aec461872b1256287855cb529cf4b9 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 9 Dec 2024 17:02:19 -0700 Subject: [PATCH 2/5] chore: bump version --- application.fam | 2 +- flipchess.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application.fam b/application.fam index 653ca76..6a6e369 100644 --- a/application.fam +++ b/application.fam @@ -14,6 +14,6 @@ App( fap_category="Games", fap_author="Struan Clark (xtruan)", fap_weburl="https://github.com/xtruan/flipper-chess", - fap_version=(1, 11), + fap_version=(1, 12), fap_description="Chess for Flipper", ) diff --git a/flipchess.h b/flipchess.h index 8849575..292fd7e 100644 --- a/flipchess.h +++ b/flipchess.h @@ -16,7 +16,7 @@ #include "views/flipchess_startscreen.h" #include "views/flipchess_scene_1.h" -#define FLIPCHESS_VERSION "v1.11" +#define FLIPCHESS_VERSION "v1.12" #define TEXT_BUFFER_SIZE 96 #define TEXT_SIZE (TEXT_BUFFER_SIZE - 1) From 3e1e5b6c698920503402aef551c3b0894b64b0c3 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 9 Dec 2024 17:04:14 -0700 Subject: [PATCH 3/5] chore: bump catalog --- catalog/manifest.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/catalog/manifest.yml b/catalog/manifest.yml index 117f3c3..445a968 100644 --- a/catalog/manifest.yml +++ b/catalog/manifest.yml @@ -2,9 +2,9 @@ sourcecode: type: git location: origin: https://github.com/xtruan/flipper-chess.git - commit_sha: e5ee4520dfc68080b1723b03f6d8e857ec10a6b0 + commit_sha: 9d481a1f19aec461872b1256287855cb529cf4b9 description: "How about a nice game of chess?" -changelog: "v1.11 - Update to support new FW" +changelog: "v1.12 - Update to fix illegal move bug" author: "@xtruan" screenshots: - "./catalog/startscreen.png" From d00c818b652269aff0336adef9ce26c5d94576f4 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 9 Dec 2024 17:10:18 -0700 Subject: [PATCH 4/5] chore: remove view_dispatcher_enable_queue --- flipchess.c | 1 - 1 file changed, 1 deletion(-) diff --git a/flipchess.c b/flipchess.c index d6528c3..ef8138b 100644 --- a/flipchess.c +++ b/flipchess.c @@ -64,7 +64,6 @@ FlipChess* flipchess_app_alloc() { //Scene additions app->view_dispatcher = view_dispatcher_alloc(); - view_dispatcher_enable_queue(app->view_dispatcher); app->scene_manager = scene_manager_alloc(&flipchess_scene_handlers, app); view_dispatcher_set_event_callback_context(app->view_dispatcher, app); From 77f2a20000b6b92285f7ca3ad7f183e7c2527a32 Mon Sep 17 00:00:00 2001 From: Struan Clark Date: Mon, 9 Dec 2024 17:10:46 -0700 Subject: [PATCH 5/5] chore: bump catalog again --- catalog/manifest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catalog/manifest.yml b/catalog/manifest.yml index 445a968..784ff4c 100644 --- a/catalog/manifest.yml +++ b/catalog/manifest.yml @@ -2,7 +2,7 @@ sourcecode: type: git location: origin: https://github.com/xtruan/flipper-chess.git - commit_sha: 9d481a1f19aec461872b1256287855cb529cf4b9 + commit_sha: d00c818b652269aff0336adef9ce26c5d94576f4 description: "How about a nice game of chess?" changelog: "v1.12 - Update to fix illegal move bug" author: "@xtruan"