From d676282b555b3c6427ec4b2c222921022523c832 Mon Sep 17 00:00:00 2001 From: RogueMaster Date: Wed, 19 Oct 2022 18:15:55 -0400 Subject: [PATCH] fbt format --- .../main/nfc/scenes/nfc_scene_passport_auth.c | 14 +- .../main/nfc/scenes/nfc_scene_passport_date.c | 8 +- .../nfc/scenes/nfc_scene_passport_read_auth.c | 34 +- applications/main/nfc/scenes/nfc_scene_read.c | 2 +- applications/plugins/clock_app/clock_app.c | 79 ++--- .../plugins/heap_defence_game/hede_assets.c | 27 +- applications/plugins/sam/sam_app.cpp | 3 +- .../scorched_tanks/scorched_tanks_game_app.c | 304 ++++++++---------- .../subbrute/helpers/subbrute_worker.c | 2 +- .../scenes/subbrute_scene_save_name.c | 9 +- .../desktop/views/desktop_view_main.c | 15 +- .../services/dolphin/helpers/dolphin_deed.c | 2 +- applications/services/gui/gui.c | 11 +- 13 files changed, 241 insertions(+), 269 deletions(-) diff --git a/applications/main/nfc/scenes/nfc_scene_passport_auth.c b/applications/main/nfc/scenes/nfc_scene_passport_auth.c index fe4bd056b..01671942a 100644 --- a/applications/main/nfc/scenes/nfc_scene_passport_auth.c +++ b/applications/main/nfc/scenes/nfc_scene_passport_auth.c @@ -48,7 +48,10 @@ void nfc_scene_passport_auth_on_enter(void* context) { const size_t temp_str_size = 15; char temp_str[temp_str_size]; - snprintf(temp_str, temp_str_size, "%02u%02u%02u", + snprintf( + temp_str, + temp_str_size, + "%02u%02u%02u", mrtd_data->auth.birth_date.year, mrtd_data->auth.birth_date.month, mrtd_data->auth.birth_date.day); @@ -56,7 +59,10 @@ void nfc_scene_passport_auth_on_enter(void* context) { item = variable_item_list_add(variable_item_list, "Birth Date", 1, NULL, NULL); variable_item_set_current_value_text(item, temp_str); - snprintf(temp_str, temp_str_size, "%02u%02u%02u", + snprintf( + temp_str, + temp_str_size, + "%02u%02u%02u", mrtd_data->auth.expiry_date.year, mrtd_data->auth.expiry_date.month, mrtd_data->auth.expiry_date.day); @@ -74,9 +80,7 @@ void nfc_scene_passport_auth_on_enter(void* context) { temp_str[10] = '.'; temp_str[11] = '\x00'; } - variable_item_set_current_value_text( - item, - temp_str); + variable_item_set_current_value_text(item, temp_str); item = variable_item_list_add( variable_item_list, diff --git a/applications/main/nfc/scenes/nfc_scene_passport_date.c b/applications/main/nfc/scenes/nfc_scene_passport_date.c index d2d2f92a9..4dc174326 100644 --- a/applications/main/nfc/scenes/nfc_scene_passport_date.c +++ b/applications/main/nfc/scenes/nfc_scene_passport_date.c @@ -44,13 +44,7 @@ void nfc_scene_passport_date_on_enter(void* context) { date_empty = true; } else { char temp_str[10]; - snprintf( - temp_str, - 10, - "%02u%02u%02u", - date_value.year, - date_value.month, - date_value.day); + snprintf(temp_str, 10, "%02u%02u%02u", date_value.year, date_value.month, date_value.day); memcpy(nfc->text_store, temp_str, DATE_LENGTH); nfc->text_store[DATE_LENGTH] = '\x00'; diff --git a/applications/main/nfc/scenes/nfc_scene_passport_read_auth.c b/applications/main/nfc/scenes/nfc_scene_passport_read_auth.c index 0f0f82684..66a4a515d 100644 --- a/applications/main/nfc/scenes/nfc_scene_passport_read_auth.c +++ b/applications/main/nfc/scenes/nfc_scene_passport_read_auth.c @@ -17,7 +17,10 @@ const char months[13][4] = { "DEC", }; -void nfc_scene_passport_read_auth_widget_callback(GuiButtonType result, InputType type, void* context) { +void nfc_scene_passport_read_auth_widget_callback( + GuiButtonType result, + InputType type, + void* context) { Nfc* nfc = context; if(type == InputTypeShort) { view_dispatcher_send_custom_event(nfc->view_dispatcher, result); @@ -38,13 +41,18 @@ void nfc_scene_passport_read_auth_on_enter(void* context) { // TODO: indicate BAC / PACE used uint16_t lds_version = mrtd_data->files.EF_COM.lds_version; - furi_string_cat_printf(temp_str, "LDS version: %d.%d\n", lds_version/100, lds_version%100); + furi_string_cat_printf(temp_str, "LDS version: %d.%d\n", lds_version / 100, lds_version % 100); uint32_t unicode_version = mrtd_data->files.EF_COM.unicode_version; - furi_string_cat_printf(temp_str, "Unicode version: %d.%d.%d\n", (uint8_t)(unicode_version/10000), (uint8_t)(unicode_version/100%100), (uint8_t)(unicode_version%100)); + furi_string_cat_printf( + temp_str, + "Unicode version: %d.%d.%d\n", + (uint8_t)(unicode_version / 10000), + (uint8_t)(unicode_version / 100 % 100), + (uint8_t)(unicode_version % 100)); furi_string_cat_printf(temp_str, "Avail.files: "); - for(size_t i=0; ifiles.EF_COM.tag_list[i]; const EFFile* file = mrtd_tag_to_file(tag); if(file->tag) { @@ -57,8 +65,8 @@ void nfc_scene_passport_read_auth_on_enter(void* context) { EF_DIR_contents* EF_DIR = &mrtd_data->files.EF_DIR; if(EF_DIR->applications_count > 0) { furi_string_cat_printf(temp_str, "Apps:\n"); - for(uint8_t i=0; iapplications_count; ++i) { - for(uint8_t n=0; napplications_count; ++i) { + for(uint8_t n = 0; n < sizeof(AIDValue); ++n) { furi_string_cat_printf(temp_str, "%02X ", EF_DIR->applications[i][n]); } furi_string_cat_printf(temp_str, "\n"); @@ -72,9 +80,19 @@ void nfc_scene_passport_read_auth_on_enter(void* context) { furi_string_cat_printf(temp_str, "Name: %s\n", DG1->name); furi_string_cat_printf(temp_str, "DocNr: %s\n", DG1->docnr); furi_string_cat_printf(temp_str, "Nationality: %s\n", DG1->nationality); - furi_string_cat_printf(temp_str, "Birth Date: %02d %s %02d\n", DG1->birth_date.day, months[DG1->birth_date.month], DG1->birth_date.year); + furi_string_cat_printf( + temp_str, + "Birth Date: %02d %s %02d\n", + DG1->birth_date.day, + months[DG1->birth_date.month], + DG1->birth_date.year); furi_string_cat_printf(temp_str, "Sex: %s\n", DG1->sex); - furi_string_cat_printf(temp_str, "Expiry Date: %02d %s %02d\n", DG1->expiry_date.day, months[DG1->expiry_date.month], DG1->expiry_date.year); + furi_string_cat_printf( + temp_str, + "Expiry Date: %02d %s %02d\n", + DG1->expiry_date.day, + months[DG1->expiry_date.month], + DG1->expiry_date.year); widget_add_text_scroll_element(widget, 0, 0, 128, 52, furi_string_get_cstr(temp_str)); furi_string_free(temp_str); diff --git a/applications/main/nfc/scenes/nfc_scene_read.c b/applications/main/nfc/scenes/nfc_scene_read.c index 8d39560aa..c7010794a 100644 --- a/applications/main/nfc/scenes/nfc_scene_read.c +++ b/applications/main/nfc/scenes/nfc_scene_read.c @@ -89,7 +89,7 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) { notification_message(nfc->notifications, &sequence_success); if(nfc->dev->dev_data.mrtd_data.auth_success) { scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthSuccess); - //TODO: } else if(nfc->dev->dev_data.mrtd_data.auth.method != MrtdAuthMethodNone) { + //TODO: } else if(nfc->dev->dev_data.mrtd_data.auth.method != MrtdAuthMethodNone) { //scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadAuthFailed); } else { scene_manager_next_scene(nfc->scene_manager, NfcScenePassportReadSuccess); diff --git a/applications/plugins/clock_app/clock_app.c b/applications/plugins/clock_app/clock_app.c index 1946a3fc7..4280ecdd9 100644 --- a/applications/plugins/clock_app/clock_app.c +++ b/applications/plugins/clock_app/clock_app.c @@ -216,63 +216,25 @@ const NotificationMessage message_blue_127 = { }; const NotificationSequence sequence_rainbow = { - &message_red_255, - &message_green_0, - &message_blue_0, - &message_delay_250, - &message_red_255, - &message_green_127, - &message_blue_0, - &message_delay_250, - &message_red_255, - &message_green_255, - &message_blue_0, - &message_delay_250, - &message_red_127, - &message_green_255, - &message_blue_0, - &message_delay_250, - &message_red_0, - &message_green_255, - &message_blue_0, - &message_delay_250, - &message_red_0, - &message_green_255, - &message_blue_127, - &message_delay_250, - &message_red_0, - &message_green_255, - &message_blue_255, - &message_delay_250, - &message_red_0, - &message_green_127, - &message_blue_255, - &message_delay_250, - &message_red_0, - &message_green_0, - &message_blue_255, - &message_delay_250, - &message_red_127, - &message_green_0, - &message_blue_255, - &message_delay_250, - &message_red_255, - &message_green_0, - &message_blue_255, - &message_delay_250, - &message_red_255, - &message_green_0, - &message_blue_127, - &message_delay_250, - &message_red_127, - &message_green_127, - &message_blue_127, - &message_delay_250, - &message_red_255, - &message_green_255, - &message_blue_255, - &message_delay_250, - NULL, + &message_red_255, &message_green_0, &message_blue_0, + &message_delay_250, &message_red_255, &message_green_127, + &message_blue_0, &message_delay_250, &message_red_255, + &message_green_255, &message_blue_0, &message_delay_250, + &message_red_127, &message_green_255, &message_blue_0, + &message_delay_250, &message_red_0, &message_green_255, + &message_blue_0, &message_delay_250, &message_red_0, + &message_green_255, &message_blue_127, &message_delay_250, + &message_red_0, &message_green_255, &message_blue_255, + &message_delay_250, &message_red_0, &message_green_127, + &message_blue_255, &message_delay_250, &message_red_0, + &message_green_0, &message_blue_255, &message_delay_250, + &message_red_127, &message_green_0, &message_blue_255, + &message_delay_250, &message_red_255, &message_green_0, + &message_blue_255, &message_delay_250, &message_red_255, + &message_green_0, &message_blue_127, &message_delay_250, + &message_red_127, &message_green_127, &message_blue_127, + &message_delay_250, &message_red_255, &message_green_255, + &message_blue_255, &message_delay_250, NULL, }; static void desktop_view_main_dumbmode_changed(DesktopSettings* settings) { @@ -369,7 +331,8 @@ static void clock_render_callback(Canvas* const canvas, void* ctx) { elements_button_right(canvas, "S:ByMin"); } } - if(state->w_test && state->desktop_settings->is_dumbmode) canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); + if(state->w_test && state->desktop_settings->is_dumbmode) + canvas_draw_icon(canvas, 0, 0, &I_GameMode_11x8); } static void clock_state_init(ClockState* const state) { diff --git a/applications/plugins/heap_defence_game/hede_assets.c b/applications/plugins/heap_defence_game/hede_assets.c index ec8b933b9..f45c0583d 100644 --- a/applications/plugins/heap_defence_game/hede_assets.c +++ b/applications/plugins/heap_defence_game/hede_assets.c @@ -4,8 +4,25 @@ #include "hede_assets.h" #include -const uint8_t _A_HD_BoxDestroyed_10x10_0[] = {0x01,0x00,0x10,0x00,0x00,0x1d,0xa2,0x01,0xc8,0x80,0x6d,0x20,0x15,0x08,0x06,0x72,0x01,0x48,0x07,0xa0,}; -const uint8_t _A_HD_BoxDestroyed_10x10_1[] = {0x00,0x00,0x00,0x28,0x01,0x4A,0x00,0xA8,0x01,0x84,0x00,0x22,0x00,0x88,0x00,0x58,0x01,0x22,0x00,0x00,0x00,}; -const uint8_t _A_HD_BoxDestroyed_10x10_2[] = {0x00,0x00,0x00,0x08,0x01,0x42,0x00,0x09,0x01,0x00,0x02,0x02,0x00,0x01,0x02,0x00,0x01,0x21,0x00,0x42,0x02,}; -const uint8_t *_A_HD_BoxDestroyed_10x10[] = {_A_HD_BoxDestroyed_10x10_0,_A_HD_BoxDestroyed_10x10_1,_A_HD_BoxDestroyed_10x10_2}; -const Icon A_HD_BoxDestroyed_10x10 = {.width=10,.height=10,.frame_count=3,.frame_rate=4,.frames=_A_HD_BoxDestroyed_10x10}; \ No newline at end of file +const uint8_t _A_HD_BoxDestroyed_10x10_0[] = { + 0x01, 0x00, 0x10, 0x00, 0x00, 0x1d, 0xa2, 0x01, 0xc8, 0x80, + 0x6d, 0x20, 0x15, 0x08, 0x06, 0x72, 0x01, 0x48, 0x07, 0xa0, +}; +const uint8_t _A_HD_BoxDestroyed_10x10_1[] = { + 0x00, 0x00, 0x00, 0x28, 0x01, 0x4A, 0x00, 0xA8, 0x01, 0x84, 0x00, + 0x22, 0x00, 0x88, 0x00, 0x58, 0x01, 0x22, 0x00, 0x00, 0x00, +}; +const uint8_t _A_HD_BoxDestroyed_10x10_2[] = { + 0x00, 0x00, 0x00, 0x08, 0x01, 0x42, 0x00, 0x09, 0x01, 0x00, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x21, 0x00, 0x42, 0x02, +}; +const uint8_t* _A_HD_BoxDestroyed_10x10[] = { + _A_HD_BoxDestroyed_10x10_0, + _A_HD_BoxDestroyed_10x10_1, + _A_HD_BoxDestroyed_10x10_2}; +const Icon A_HD_BoxDestroyed_10x10 = { + .width = 10, + .height = 10, + .frame_count = 3, + .frame_rate = 4, + .frames = _A_HD_BoxDestroyed_10x10}; \ No newline at end of file diff --git a/applications/plugins/sam/sam_app.cpp b/applications/plugins/sam/sam_app.cpp index 8bd0eda3c..9f332ddef 100644 --- a/applications/plugins/sam/sam_app.cpp +++ b/applications/plugins/sam/sam_app.cpp @@ -7,7 +7,8 @@ extern "C" int32_t sam_app(void* p) { UNUSED(p); voice.begin(); - voice.say("All your base are belong to us. You have no chance to survive make your time. ha. ha. ha. GOOD BYE. "); + voice.say( + "All your base are belong to us. You have no chance to survive make your time. ha. ha. ha. GOOD BYE. "); return 0; } \ No newline at end of file diff --git a/applications/plugins/scorched_tanks/scorched_tanks_game_app.c b/applications/plugins/scorched_tanks/scorched_tanks_game_app.c index d0ac91e71..6adf29bb2 100644 --- a/applications/plugins/scorched_tanks/scorched_tanks_game_app.c +++ b/applications/plugins/scorched_tanks/scorched_tanks_game_app.c @@ -25,7 +25,7 @@ // That's a filthy workaround but sin(player.aimAngle) breaks it all... If you're able to fix it, please do create a PR! double scorched_tanks_sin[91] = { - 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.122, -0.139, -0.156, -0.174, -0.191, + 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.122, -0.139, -0.156, -0.174, -0.191, -0.208, -0.225, -0.242, -0.259, -0.276, -0.292, -0.309, -0.326, -0.342, -0.358, -0.375, -0.391, -0.407, -0.423, -0.438, -0.454, -0.469, -0.485, -0.500, -0.515, -0.530, -0.545, -0.559, -0.574, -0.588, -0.602, -0.616, -0.629, -0.643, -0.656, -0.669, -0.682, -0.695, -0.707, -0.719, -0.731, @@ -42,19 +42,24 @@ double scorched_tanks_cos[91] = { 0.423, 0.407, 0.391, 0.375, 0.358, 0.342, 0.326, 0.309, 0.292, 0.276, 0.259, 0.242, 0.225, 0.208, 0.191, 0.174, 0.156, 0.139, 0.122, 0.105, 0.087, 0.070, 0.052, 0.035, 0.017, 0.000}; double scorched_tanks_tan[91] = { - 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.123, -0.141, -0.158, -0.176, - -0.194, -0.213, -0.231, -0.249, -0.268, -0.287, -0.306, -0.325, -0.344, -0.364, -0.384, - -0.404, -0.424, -0.445, -0.466, -0.488, -0.510, -0.532, -0.554, -0.577, -0.601, -0.625, - -0.649, -0.674, -0.700, -0.727, -0.754, -0.781, -0.810, -0.839, -0.869, -0.900, -0.932, - -0.966, -1.000, -1.036, -1.072, -1.111, -1.150, -1.192, -1.235, -1.280, -1.327, -1.376, - -1.428, -1.483, -1.540, -1.600, -1.664, -1.732, -1.804, -1.881, -1.963, -2.050, -2.144, - -2.246, -2.356, -2.475, -2.605, -2.747, -2.904, -3.078, -3.271, -3.487, -3.732, -4.011, - -4.331, -4.704, -5.144, -5.671, -6.313, -7.115, -8.144, -9.513, -11.429, -14.298, -19.077, + 0.000, -0.017, -0.035, -0.052, -0.070, -0.087, -0.105, -0.123, -0.141, -0.158, -0.176, + -0.194, -0.213, -0.231, -0.249, -0.268, -0.287, -0.306, -0.325, -0.344, -0.364, -0.384, + -0.404, -0.424, -0.445, -0.466, -0.488, -0.510, -0.532, -0.554, -0.577, -0.601, -0.625, + -0.649, -0.674, -0.700, -0.727, -0.754, -0.781, -0.810, -0.839, -0.869, -0.900, -0.932, + -0.966, -1.000, -1.036, -1.072, -1.111, -1.150, -1.192, -1.235, -1.280, -1.327, -1.376, + -1.428, -1.483, -1.540, -1.600, -1.664, -1.732, -1.804, -1.881, -1.963, -2.050, -2.144, + -2.246, -2.356, -2.475, -2.605, -2.747, -2.904, -3.078, -3.271, -3.487, -3.732, -4.011, + -4.331, -4.704, -5.144, -5.671, -6.313, -7.115, -8.144, -9.513, -11.429, -14.298, -19.077, -28.627, -57.254, -90747.269}; -unsigned char scorched_tanks_ground_modifiers[SCREEN_WIDTH] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +unsigned char scorched_tanks_ground_modifiers[SCREEN_WIDTH] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 28, 26, 24, 22, 20, + 18, 16, 14, 12, 10, 8, 6, 4, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; -typedef struct -{ +typedef struct { // +-----x // | // | @@ -63,8 +68,7 @@ typedef struct uint8_t y; } Point; -typedef struct -{ +typedef struct { // +-----x // | // | @@ -73,16 +77,14 @@ typedef struct double y; } PointDetailed; -typedef struct -{ +typedef struct { unsigned char locationX; unsigned char hp; int aimAngle; unsigned char firePower; } Tank; -typedef struct -{ +typedef struct { Point ground[SCREEN_WIDTH]; Tank player; Tank enemy; @@ -95,41 +97,33 @@ typedef struct PointDetailed bulletVector; } Game; -typedef enum -{ +typedef enum { EventTypeTick, EventTypeKey, } EventType; -typedef struct -{ +typedef struct { EventType type; InputEvent input; } ScorchedTanksEvent; -int scorched_tanks_random(int min, int max) -{ +int scorched_tanks_random(int min, int max) { return min + rand() % ((max + 1) - min); } -void scorched_tanks_generate_ground(Game *game_state) -{ +void scorched_tanks_generate_ground(Game* game_state) { int lastHeight = 45; - for (unsigned char a = 0; a < SCREEN_WIDTH; a++) - { + for(unsigned char a = 0; a < SCREEN_WIDTH; a++) { int diffHeight = scorched_tanks_random(-2, 3); int changeLength = scorched_tanks_random(1, 6); - if (diffHeight == 0) - { + if(diffHeight == 0) { changeLength = 1; } - for (int b = 0; b < changeLength; b++) - { - if (a + b < SCREEN_WIDTH) - { + for(int b = 0; b < changeLength; b++) { + if(a + b < SCREEN_WIDTH) { int index = a + b; int newPoint = lastHeight + diffHeight; newPoint = newPoint < MIN_GROUND_HEIGHT ? MIN_GROUND_HEIGHT : newPoint; @@ -137,9 +131,7 @@ void scorched_tanks_generate_ground(Game *game_state) game_state->ground[index].x = index; game_state->ground[index].y = newPoint - scorched_tanks_ground_modifiers[a]; lastHeight = newPoint; - } - else - { + } else { a += b; break; } @@ -149,20 +141,21 @@ void scorched_tanks_generate_ground(Game *game_state) } } -void scorched_tanks_init_game(Game *game_state) -{ - game_state->player.locationX = PLAYER_INIT_LOCATION_X + scorched_tanks_random(0, MAX_PLAYER_DIFF_X) - MAX_PLAYER_DIFF_X / 2; +void scorched_tanks_init_game(Game* game_state) { + game_state->player.locationX = PLAYER_INIT_LOCATION_X + + scorched_tanks_random(0, MAX_PLAYER_DIFF_X) - + MAX_PLAYER_DIFF_X / 2; game_state->player.aimAngle = PLAYER_INIT_AIM; game_state->player.firePower = PLAYER_INIT_POWER; game_state->enemy.aimAngle = PLAYER_INIT_AIM; game_state->enemy.firePower = PLAYER_INIT_POWER; - game_state->enemy.locationX = ENEMY_INIT_LOCATION_X + scorched_tanks_random(0, MAX_ENEMY_DIFF_X) - MAX_ENEMY_DIFF_X / 2; + game_state->enemy.locationX = + ENEMY_INIT_LOCATION_X + scorched_tanks_random(0, MAX_ENEMY_DIFF_X) - MAX_ENEMY_DIFF_X / 2; game_state->isPlayerTurn = true; game_state->windSpeed = scorched_tanks_random(0, MAX_WIND); - for (int x = 0; x < SCREEN_WIDTH; x++) - { + for(int x = 0; x < SCREEN_WIDTH; x++) { game_state->trajectory[x].x = 0; game_state->trajectory[x].y = 0; } @@ -170,10 +163,8 @@ void scorched_tanks_init_game(Game *game_state) scorched_tanks_generate_ground(game_state); } -void scorched_tanks_calculate_trajectory(Game *game_state) -{ - if (game_state->isShooting) - { +void scorched_tanks_calculate_trajectory(Game* game_state) { + if(game_state->isShooting) { game_state->bulletVector.x += ((double)game_state->windSpeed - MAX_WIND / 2) / 40; game_state->bulletVector.y += GRAVITY_FORCE; @@ -182,30 +173,30 @@ void scorched_tanks_calculate_trajectory(Game *game_state) int totalDistanceToEnemy = 100; - if (game_state->isPlayerTurn) - { + if(game_state->isPlayerTurn) { double distanceToEnemyX = game_state->enemy.locationX - game_state->bulletPosition.x; - double distanceToEnemyY = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE - game_state->bulletPosition.y; - totalDistanceToEnemy = sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); - } - else - { + double distanceToEnemyY = game_state->ground[game_state->enemy.locationX].y - + TANK_COLLIDER_SIZE - game_state->bulletPosition.y; + totalDistanceToEnemy = + sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); + } else { double distanceToEnemyX = game_state->player.locationX - game_state->bulletPosition.x; - double distanceToEnemyY = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE - game_state->bulletPosition.y; - totalDistanceToEnemy = sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); + double distanceToEnemyY = game_state->ground[game_state->player.locationX].y - + TANK_COLLIDER_SIZE - game_state->bulletPosition.y; + totalDistanceToEnemy = + sqrt(distanceToEnemyX * distanceToEnemyX + distanceToEnemyY * distanceToEnemyY); } - if (totalDistanceToEnemy <= TANK_COLLIDER_SIZE) - { + if(totalDistanceToEnemy <= TANK_COLLIDER_SIZE) { game_state->isShooting = false; scorched_tanks_init_game(game_state); game_state->isPlayerTurn = !game_state->isPlayerTurn; return; } - if (game_state->bulletPosition.x > SCREEN_WIDTH || - game_state->bulletPosition.y > game_state->ground[(int)round(game_state->bulletPosition.x)].y) - { + if(game_state->bulletPosition.x > SCREEN_WIDTH || + game_state->bulletPosition.y > + game_state->ground[(int)round(game_state->bulletPosition.x)].y) { game_state->isShooting = false; game_state->bulletPosition.x = 0; game_state->bulletPosition.y = 0; @@ -214,21 +205,24 @@ void scorched_tanks_calculate_trajectory(Game *game_state) return; } - if (game_state->bulletPosition.y > 0) - { - game_state->trajectory[game_state->trajectoryAnimationStep].x = round(game_state->bulletPosition.x); - game_state->trajectory[game_state->trajectoryAnimationStep].y = round(game_state->bulletPosition.y); + if(game_state->bulletPosition.y > 0) { + game_state->trajectory[game_state->trajectoryAnimationStep].x = + round(game_state->bulletPosition.x); + game_state->trajectory[game_state->trajectoryAnimationStep].y = + round(game_state->bulletPosition.y); game_state->trajectoryAnimationStep++; } } } -static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsigned char y, bool isPlayer) -{ +static void scorched_tanks_draw_tank( + Canvas* const canvas, + unsigned char x, + unsigned char y, + bool isPlayer) { unsigned char lineIndex = 0; - if (isPlayer) - { + if(isPlayer) { // Draw tank base canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++); canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); @@ -237,9 +231,7 @@ static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsi // draw turret canvas_draw_line(canvas, x - 2, y - lineIndex, x + 1, y - lineIndex++); canvas_draw_line(canvas, x - 2, y - lineIndex, x, y - lineIndex++); - } - else - { + } else { // Draw tank base canvas_draw_line(canvas, x - 3, y - lineIndex, x + 3, y - lineIndex++); canvas_draw_line(canvas, x - 4, y - lineIndex, x + 4, y - lineIndex++); @@ -251,12 +243,10 @@ static void scorched_tanks_draw_tank(Canvas *const canvas, unsigned char x, unsi } } -static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) -{ - const Game *game_state = acquire_mutex((ValueMutex *)ctx, 25); +static void scorched_tanks_render_callback(Canvas* const canvas, void* ctx) { + const Game* game_state = acquire_mutex((ValueMutex*)ctx, 25); - if (game_state == NULL) - { + if(game_state == NULL) { return; } @@ -264,13 +254,11 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) canvas_set_color(canvas, ColorBlack); - if (game_state->isShooting) - { + if(game_state->isShooting) { canvas_draw_dot(canvas, game_state->bulletPosition.x, game_state->bulletPosition.y); } - for (int a = 1; a < SCREEN_WIDTH; a++) - { + for(int a = 1; a < SCREEN_WIDTH; a++) { canvas_draw_line( canvas, game_state->ground[a - 1].x, @@ -278,23 +266,29 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) game_state->ground[a].x, game_state->ground[a].y); - if (game_state->trajectory[a].y != 0) - { + if(game_state->trajectory[a].y != 0) { canvas_draw_dot(canvas, game_state->trajectory[a].x, game_state->trajectory[a].y); } } - scorched_tanks_draw_tank(canvas, game_state->enemy.locationX, game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE, true); + scorched_tanks_draw_tank( + canvas, + game_state->enemy.locationX, + game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE, + true); - scorched_tanks_draw_tank(canvas, game_state->player.locationX, game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE, false); + scorched_tanks_draw_tank( + canvas, + game_state->player.locationX, + game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE, + false); int aimX1 = 0; int aimY1 = 0; int aimX2 = 0; int aimY2 = 0; - if (game_state->isPlayerTurn) - { + if(game_state->isPlayerTurn) { aimX1 = game_state->player.locationX; aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE; @@ -305,9 +299,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) aimX1 += 1; aimX2 += 1; - } - else - { + } else { aimX1 = game_state->enemy.locationX; aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE; @@ -330,8 +322,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) snprintf(buffer2, sizeof(buffer2), "wind: %i", game_state->windSpeed - MAX_WIND / 2); canvas_draw_str(canvas, 55, 10, buffer2); - if (game_state->isPlayerTurn) - { + if(game_state->isPlayerTurn) { canvas_draw_str(canvas, 93, 10, "player1"); char buffer[12]; @@ -340,9 +331,7 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) snprintf(buffer, sizeof(buffer), "p: %u", game_state->player.firePower); canvas_draw_str(canvas, 27, 10, buffer); - } - else - { + } else { canvas_draw_str(canvas, 93, 10, "player2"); char buffer[12]; @@ -353,83 +342,64 @@ static void scorched_tanks_render_callback(Canvas *const canvas, void *ctx) canvas_draw_str(canvas, 27, 10, buffer); } - release_mutex((ValueMutex *)ctx, game_state); + release_mutex((ValueMutex*)ctx, game_state); } -static void scorched_tanks_input_callback(InputEvent *input_event, FuriMessageQueue *event_queue) -{ +static void scorched_tanks_input_callback(InputEvent* input_event, FuriMessageQueue* event_queue) { furi_assert(event_queue); ScorchedTanksEvent event = {.type = EventTypeKey, .input = *input_event}; furi_message_queue_put(event_queue, &event, FuriWaitForever); } -static void scorched_tanks_update_timer_callback(FuriMessageQueue *event_queue) -{ +static void scorched_tanks_update_timer_callback(FuriMessageQueue* event_queue) { furi_assert(event_queue); ScorchedTanksEvent event = {.type = EventTypeTick}; furi_message_queue_put(event_queue, &event, 0); } -static void scorched_tanks_increase_power(Game *game_state) -{ - if (game_state->player.firePower < MAX_FIRE_POWER && !game_state->isShooting) - { - if (game_state->isPlayerTurn && game_state->player.firePower < MAX_FIRE_POWER) - { +static void scorched_tanks_increase_power(Game* game_state) { + if(game_state->player.firePower < MAX_FIRE_POWER && !game_state->isShooting) { + if(game_state->isPlayerTurn && game_state->player.firePower < MAX_FIRE_POWER) { game_state->player.firePower++; } - if (!game_state->isPlayerTurn && game_state->enemy.firePower < MAX_FIRE_POWER) - { + if(!game_state->isPlayerTurn && game_state->enemy.firePower < MAX_FIRE_POWER) { game_state->enemy.firePower++; } } } -static void scorched_tanks_decrease_power(Game *game_state) -{ - if (game_state->player.firePower > MIN_FIRE_POWER && !game_state->isShooting) - { - if (game_state->isPlayerTurn && game_state->player.firePower > MIN_FIRE_POWER) - { +static void scorched_tanks_decrease_power(Game* game_state) { + if(game_state->player.firePower > MIN_FIRE_POWER && !game_state->isShooting) { + if(game_state->isPlayerTurn && game_state->player.firePower > MIN_FIRE_POWER) { game_state->player.firePower--; } - if (!game_state->isPlayerTurn && game_state->enemy.firePower > MIN_FIRE_POWER) - { + if(!game_state->isPlayerTurn && game_state->enemy.firePower > MIN_FIRE_POWER) { game_state->enemy.firePower--; } } } -static void scorched_tanks_aim_up(Game *game_state) -{ - if (!game_state->isShooting) - { - if (game_state->isPlayerTurn && game_state->player.aimAngle < 90) - { +static void scorched_tanks_aim_up(Game* game_state) { + if(!game_state->isShooting) { + if(game_state->isPlayerTurn && game_state->player.aimAngle < 90) { game_state->player.aimAngle++; } - if (!game_state->isPlayerTurn && game_state->enemy.aimAngle < 90) - { + if(!game_state->isPlayerTurn && game_state->enemy.aimAngle < 90) { game_state->enemy.aimAngle++; } } } -static void scorched_tanks_aim_down(Game *game_state) -{ - if (game_state->player.aimAngle > 0 && !game_state->isShooting) - { - if (game_state->isPlayerTurn) - { +static void scorched_tanks_aim_down(Game* game_state) { + if(game_state->player.aimAngle > 0 && !game_state->isShooting) { + if(game_state->isPlayerTurn) { game_state->player.aimAngle--; - } - else - { + } else { game_state->enemy.aimAngle--; } } @@ -442,97 +412,91 @@ const NotificationSequence sequence_long_vibro = { NULL, }; -static void scorched_tanks_fire(Game *game_state) -{ - if (!game_state->isShooting) - { - if (game_state->isPlayerTurn) - { +static void scorched_tanks_fire(Game* game_state) { + if(!game_state->isShooting) { + if(game_state->isPlayerTurn) { double sinFromAngle = scorched_tanks_sin[game_state->player.aimAngle]; double cosFromAngle = scorched_tanks_cos[game_state->player.aimAngle]; unsigned char aimX1 = game_state->player.locationX; - unsigned char aimY1 = game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE; + unsigned char aimY1 = + game_state->ground[game_state->player.locationX].y - TANK_COLLIDER_SIZE; int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; game_state->bulletPosition.x = aimX2; game_state->bulletPosition.y = aimY2; - game_state->bulletVector.x = scorched_tanks_cos[game_state->player.aimAngle] * ((double)game_state->player.firePower / 10); - game_state->bulletVector.y = scorched_tanks_sin[game_state->player.aimAngle] * ((double)game_state->player.firePower / 10); - } - else - { + game_state->bulletVector.x = scorched_tanks_cos[game_state->player.aimAngle] * + ((double)game_state->player.firePower / 10); + game_state->bulletVector.y = scorched_tanks_sin[game_state->player.aimAngle] * + ((double)game_state->player.firePower / 10); + } else { double sinFromAngle = scorched_tanks_sin[game_state->enemy.aimAngle]; double cosFromAngle = scorched_tanks_cos[game_state->enemy.aimAngle]; unsigned char aimX1 = game_state->enemy.locationX; - unsigned char aimY1 = game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE; + unsigned char aimY1 = + game_state->ground[game_state->enemy.locationX].y - TANK_COLLIDER_SIZE; int aimX2 = aimX1 + TANK_BARREL_LENGTH * cosFromAngle; int aimY2 = aimY1 + TANK_BARREL_LENGTH * sinFromAngle; aimX2 = aimX1 - (aimX2 - aimX1); game_state->bulletPosition.x = aimX2; game_state->bulletPosition.y = aimY2; - game_state->bulletVector.x = -scorched_tanks_cos[game_state->enemy.aimAngle] * ((double)game_state->enemy.firePower / 10); - game_state->bulletVector.y = scorched_tanks_sin[game_state->enemy.aimAngle] * ((double)game_state->enemy.firePower / 10); + game_state->bulletVector.x = -scorched_tanks_cos[game_state->enemy.aimAngle] * + ((double)game_state->enemy.firePower / 10); + game_state->bulletVector.y = scorched_tanks_sin[game_state->enemy.aimAngle] * + ((double)game_state->enemy.firePower / 10); } game_state->trajectoryAnimationStep = 0; - for (int x = 0; x < SCREEN_WIDTH; x++) - { + for(int x = 0; x < SCREEN_WIDTH; x++) { game_state->trajectory[x].x = 0; game_state->trajectory[x].y = 0; } game_state->isShooting = true; - NotificationApp *notification = furi_record_open("notification"); + NotificationApp* notification = furi_record_open("notification"); notification_message(notification, &sequence_long_vibro); notification_message(notification, &sequence_blink_white_100); furi_record_close("notification"); } } -int32_t scorched_tanks_game_app(void *p) -{ +int32_t scorched_tanks_game_app(void* p) { UNUSED(p); srand(DWT->CYCCNT); - FuriMessageQueue *event_queue = furi_message_queue_alloc(8, sizeof(ScorchedTanksEvent)); + FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(ScorchedTanksEvent)); - Game *game_state = malloc(sizeof(Game)); + Game* game_state = malloc(sizeof(Game)); scorched_tanks_init_game(game_state); ValueMutex state_mutex; - if (!init_mutex(&state_mutex, game_state, sizeof(ScorchedTanksEvent))) - { + if(!init_mutex(&state_mutex, game_state, sizeof(ScorchedTanksEvent))) { FURI_LOG_E("ScorchedTanks", "cannot create mutex\r\n"); free(game_state); return 255; } - ViewPort *view_port = view_port_alloc(); + ViewPort* view_port = view_port_alloc(); view_port_draw_callback_set(view_port, scorched_tanks_render_callback, &state_mutex); view_port_input_callback_set(view_port, scorched_tanks_input_callback, event_queue); - FuriTimer *timer = + FuriTimer* timer = furi_timer_alloc(scorched_tanks_update_timer_callback, FuriTimerTypePeriodic, event_queue); furi_timer_start(timer, 2000); // Open GUI and register view_port - Gui *gui = furi_record_open(RECORD_GUI); + Gui* gui = furi_record_open(RECORD_GUI); gui_add_view_port(gui, view_port, GuiLayerFullscreen); ScorchedTanksEvent event; - for (bool processing = true; processing;) - { + for(bool processing = true; processing;) { FuriStatus event_status = furi_message_queue_get(event_queue, &event, 50); - if (event.type == EventTypeKey) - { // && game->isPlayerTurn - if (event.input.type == InputTypeRepeat || event.input.type == InputTypeShort) - { - switch (event.input.key) - { + if(event.type == EventTypeKey) { // && game->isPlayerTurn + if(event.input.type == InputTypeRepeat || event.input.type == InputTypeShort) { + switch(event.input.key) { case InputKeyUp: scorched_tanks_aim_up(game_state); break; @@ -553,9 +517,7 @@ int32_t scorched_tanks_game_app(void *p) break; } } - } - else if (event.type == EventTypeTick) - { + } else if(event.type == EventTypeTick) { scorched_tanks_calculate_trajectory(game_state); } diff --git a/applications/plugins/subbrute/helpers/subbrute_worker.c b/applications/plugins/subbrute/helpers/subbrute_worker.c index 3ec04a9a4..ac7435b71 100644 --- a/applications/plugins/subbrute/helpers/subbrute_worker.c +++ b/applications/plugins/subbrute/helpers/subbrute_worker.c @@ -188,7 +188,7 @@ bool subbrute_worker_start(SubBruteWorker* instance) { void subbrute_worker_stop(SubBruteWorker* instance) { furi_assert(instance); - if (!instance->worker_running) { + if(!instance->worker_running) { return; } diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c b/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c index b5919ae5a..bb129e948 100644 --- a/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c +++ b/applications/plugins/subbrute/scenes/subbrute_scene_save_name.c @@ -47,9 +47,14 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) { if(strcmp(instance->text_store, "")) { furi_string_reset(instance->file_path); furi_string_cat_printf( - instance->file_path, "%s/%s%s", SUBBRUTE_PATH, instance->text_store, SUBBRUTE_FILE_EXT); + instance->file_path, + "%s/%s%s", + SUBBRUTE_PATH, + instance->text_store, + SUBBRUTE_FILE_EXT); - if(subbrute_device_save_file(instance->device, furi_string_get_cstr(instance->file_path))) { + if(subbrute_device_save_file( + instance->device, furi_string_get_cstr(instance->file_path))) { scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess); success = true; consumed = true; diff --git a/applications/services/desktop/views/desktop_view_main.c b/applications/services/desktop/views/desktop_view_main.c index 415005edc..3903160a1 100644 --- a/applications/services/desktop/views/desktop_view_main.c +++ b/applications/services/desktop/views/desktop_view_main.c @@ -84,7 +84,8 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { } else if(event->key == InputKeyDown) { main_view->callback(DesktopMainEventOpenFavoriteSecondary, main_view->context); } else if(event->key == InputKeyLeft) { - main_view->callback(DesktopMainEventOpenSubRemote, main_view->context); // OPENS SUBGHZ REMOTE + main_view->callback( + DesktopMainEventOpenSubRemote, main_view->context); // OPENS SUBGHZ REMOTE } } } else if(main_view->is_gamemode == true) { @@ -105,9 +106,11 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { } else if(event->key == InputKeyUp) { main_view->callback(DesktopMainEventOpenDOOM, main_view->context); // OPENS DOOM } else if(event->key == InputKeyDown) { - main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez + main_view->callback( + DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez } else if(event->key == InputKeyLeft) { - main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS + main_view->callback( + DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS } } } else { @@ -127,9 +130,11 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { } else if(event->key == InputKeyUp) { main_view->callback(DesktopMainEventOpenSnake, main_view->context); // OPENS SNAKE } else if(event->key == InputKeyDown) { - main_view->callback(DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez + main_view->callback( + DesktopMainEventOpenZombiez, main_view->context); // OPENS Zombiez } else if(event->key == InputKeyLeft) { - main_view->callback(DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS + main_view->callback( + DesktopMainEventOpenTetris, main_view->context); // OPENS TETRIS } } } diff --git a/applications/services/dolphin/helpers/dolphin_deed.c b/applications/services/dolphin/helpers/dolphin_deed.c index 5e6d1a51d..074d6f21d 100644 --- a/applications/services/dolphin/helpers/dolphin_deed.c +++ b/applications/services/dolphin/helpers/dolphin_deed.c @@ -51,7 +51,7 @@ static uint8_t dolphin_deed_limits[] = { 100, // DolphinAppIr 100, // DolphinAppIbutton 100, // DolphinAppBadusb - // 100, // DolphinAppU2f + // 100, // DolphinAppU2f // 100, // DolphinAppGpio 100, // DolphinAppPlugin }; diff --git a/applications/services/gui/gui.c b/applications/services/gui/gui.c index db080a5a0..c7b2619d4 100644 --- a/applications/services/gui/gui.c +++ b/applications/services/gui/gui.c @@ -113,7 +113,6 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) { 2, canvas_width(gui->canvas) - 1, canvas_height(gui->canvas) - 4); - } // Left side @@ -128,7 +127,7 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) { canvas_frame_set( gui->canvas, x - 1, - // SASQUACH SAYS : This is the white box behind the left bar, move it 64 to hide it + // SASQUACH SAYS : This is the white box behind the left bar, move it 64 to hide it GUI_STATUS_BAR_Y + 64, width + 2, GUI_STATUS_BAR_WORKAREA_HEIGHT + 2); @@ -138,8 +137,12 @@ static void gui_redraw_status_bar(Gui* gui, bool need_attention) { canvas_set_color(gui->canvas, ColorBlack); // ViewPort draw canvas_frame_set( - // SASQUACH SAYS : This is where you move the Icons for the left bar, 64 to hide it - gui->canvas, x, GUI_STATUS_BAR_Y + 64, width, GUI_STATUS_BAR_WORKAREA_HEIGHT); + // SASQUACH SAYS : This is where you move the Icons for the left bar, 64 to hide it + gui->canvas, + x, + GUI_STATUS_BAR_Y + 64, + width, + GUI_STATUS_BAR_WORKAREA_HEIGHT); view_port_draw(view_port, gui->canvas); // Recalculate next position left_used += (width + 2);