forked from RogueMaster/flipperzero-firmware-wPlugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RogueMaster:420' into Custom-Marauder
- Loading branch information
Showing
87 changed files
with
2,842 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,5 @@ App( | |
stack_size=2 * 1024, | ||
order=70, | ||
fap_icon="uart_10px.png", | ||
fap_category="Misc", | ||
fap_category="GPIO", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# FlipperZeroBrainfuck | ||
|
||
Brainfuck interpreter and editor for the F0. | ||
Supports text inputs and outputs. | ||
No protection against infinite loops or syntax errors. | ||
|
||
![Screenshot-20230117-202147](https://user-images.githubusercontent.com/16545187/213004616-8846e897-506e-4510-8012-fd2fe2bbe8a1.png) | ||
|
||
![Screenshot-20230117-202208](https://user-images.githubusercontent.com/16545187/213004659-d74751d2-76c4-4a7b-a0f2-f58623478b95.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
App( | ||
appid="Brainfuck", | ||
name="Brainfuck", | ||
apptype=FlipperAppType.EXTERNAL, | ||
entry_point="brainfuck_app", | ||
requires=[ | ||
"storage", | ||
"gui", | ||
], | ||
stack_size=8 * 1024, | ||
fap_icon="bfico.png", | ||
fap_category="Misc", | ||
fap_icon_assets="icons", | ||
fap_icon_assets_symbol="brainfuck", | ||
) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
#include "brainfuck_i.h" | ||
|
||
/* | ||
Due to the lack of documentation on the flipper i copied the picopass app, | ||
ripped its insides out and used its hollow corpse to build this app inside of. | ||
i dont know how this stuff works and after 6 hours of trying to learn it, i dont care | ||
*/ | ||
|
||
bool brainfuck_custom_event_callback(void* context, uint32_t event) { | ||
furi_assert(context); | ||
BFApp* brainfuck = context; | ||
return scene_manager_handle_custom_event(brainfuck->scene_manager, event); | ||
} | ||
|
||
bool brainfuck_back_event_callback(void* context) { | ||
furi_assert(context); | ||
BFApp* brainfuck = context; | ||
return scene_manager_handle_back_event(brainfuck->scene_manager); | ||
} | ||
|
||
BFApp* brainfuck_alloc() { | ||
BFApp* brainfuck = malloc(sizeof(BFApp)); | ||
|
||
brainfuck->dataSize = 0; | ||
brainfuck->view_dispatcher = view_dispatcher_alloc(); | ||
brainfuck->scene_manager = scene_manager_alloc(&brainfuck_scene_handlers, brainfuck); | ||
view_dispatcher_enable_queue(brainfuck->view_dispatcher); | ||
view_dispatcher_set_event_callback_context(brainfuck->view_dispatcher, brainfuck); | ||
view_dispatcher_set_custom_event_callback( | ||
brainfuck->view_dispatcher, brainfuck_custom_event_callback); | ||
view_dispatcher_set_navigation_event_callback( | ||
brainfuck->view_dispatcher, brainfuck_back_event_callback); | ||
|
||
// Open GUI record | ||
brainfuck->gui = furi_record_open(RECORD_GUI); | ||
view_dispatcher_attach_to_gui( | ||
brainfuck->view_dispatcher, brainfuck->gui, ViewDispatcherTypeFullscreen); | ||
|
||
// Open Notification record | ||
brainfuck->notifications = furi_record_open(RECORD_NOTIFICATION); | ||
|
||
// Submenu | ||
brainfuck->submenu = submenu_alloc(); | ||
view_dispatcher_add_view( | ||
brainfuck->view_dispatcher, brainfuckViewMenu, submenu_get_view(brainfuck->submenu)); | ||
|
||
// Popup | ||
brainfuck->popup = popup_alloc(); | ||
view_dispatcher_add_view( | ||
brainfuck->view_dispatcher, brainfuckViewPopup, popup_get_view(brainfuck->popup)); | ||
|
||
// Text Input | ||
brainfuck->text_input = text_input_alloc(); | ||
view_dispatcher_add_view( | ||
brainfuck->view_dispatcher, | ||
brainfuckViewTextInput, | ||
text_input_get_view(brainfuck->text_input)); | ||
|
||
// Textbox | ||
brainfuck->text_box = text_box_alloc(); | ||
view_dispatcher_add_view( | ||
brainfuck->view_dispatcher, brainfuckViewTextBox, text_box_get_view(brainfuck->text_box)); | ||
brainfuck->text_box_store = furi_string_alloc(); | ||
|
||
// Dev environment | ||
brainfuck->BF_dev_env = bf_dev_env_alloc(brainfuck); | ||
view_dispatcher_add_view( | ||
brainfuck->view_dispatcher, brainfuckViewDev, bf_dev_env_get_view(brainfuck->BF_dev_env)); | ||
|
||
// File path | ||
brainfuck->BF_file_path = furi_string_alloc(); | ||
|
||
return brainfuck; | ||
} | ||
|
||
void brainfuck_free(BFApp* brainfuck) { | ||
furi_assert(brainfuck); | ||
|
||
// Submenu | ||
view_dispatcher_remove_view(brainfuck->view_dispatcher, brainfuckViewMenu); | ||
submenu_free(brainfuck->submenu); | ||
|
||
// Popup | ||
view_dispatcher_remove_view(brainfuck->view_dispatcher, brainfuckViewPopup); | ||
popup_free(brainfuck->popup); | ||
|
||
// TextInput | ||
view_dispatcher_remove_view(brainfuck->view_dispatcher, brainfuckViewTextInput); | ||
text_input_free(brainfuck->text_input); | ||
|
||
// TextBox | ||
view_dispatcher_remove_view(brainfuck->view_dispatcher, brainfuckViewTextBox); | ||
text_box_free(brainfuck->text_box); | ||
furi_string_free(brainfuck->text_box_store); | ||
|
||
//dev env | ||
view_dispatcher_remove_view(brainfuck->view_dispatcher, brainfuckViewDev); | ||
bf_dev_env_free(brainfuck->BF_dev_env); | ||
|
||
// View Dispatcher | ||
view_dispatcher_free(brainfuck->view_dispatcher); | ||
|
||
// Scene Manager | ||
scene_manager_free(brainfuck->scene_manager); | ||
|
||
// GUI | ||
furi_record_close(RECORD_GUI); | ||
brainfuck->gui = NULL; | ||
|
||
// Notifications | ||
furi_record_close(RECORD_NOTIFICATION); | ||
brainfuck->notifications = NULL; | ||
|
||
free(brainfuck); | ||
} | ||
|
||
void brainfuck_show_loading_popup(void* context, bool show) { | ||
BFApp* brainfuck = context; | ||
TaskHandle_t timer_task = xTaskGetHandle(configTIMER_SERVICE_TASK_NAME); | ||
|
||
if(show) { | ||
// Raise timer priority so that animations can play | ||
vTaskPrioritySet(timer_task, configMAX_PRIORITIES - 1); | ||
view_dispatcher_switch_to_view(brainfuck->view_dispatcher, brainfuckViewLoading); | ||
} else { | ||
// Restore default timer priority | ||
vTaskPrioritySet(timer_task, configTIMER_TASK_PRIORITY); | ||
} | ||
} | ||
|
||
int32_t brainfuck_app(void* p) { | ||
UNUSED(p); | ||
BFApp* brainfuck = brainfuck_alloc(); | ||
if(!brainfuck) { | ||
return 0; | ||
} | ||
|
||
Storage* storage = furi_record_open(RECORD_STORAGE); | ||
storage_simply_mkdir(storage, "/ext/brainfuck"); | ||
|
||
scene_manager_next_scene(brainfuck->scene_manager, brainfuckSceneStart); | ||
|
||
view_dispatcher_run(brainfuck->view_dispatcher); | ||
|
||
brainfuck_free(brainfuck); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#pragma once | ||
|
||
typedef struct BFApp BFApp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#pragma once | ||
|
||
typedef struct BFDevEnv BFDevEnv; | ||
typedef struct BFExecEnv BFExecEnv; | ||
typedef unsigned char byte; | ||
|
||
#include "brainfuck.h" | ||
#include "worker.h" | ||
|
||
#include <furi.h> | ||
#include <gui/gui.h> | ||
#include <gui/view_dispatcher.h> | ||
#include <gui/scene_manager.h> | ||
#include <notification/notification_messages.h> | ||
|
||
#include <gui/modules/submenu.h> | ||
#include <gui/modules/popup.h> | ||
#include <gui/modules/loading.h> | ||
#include <gui/modules/text_input.h> | ||
#include <gui/modules/widget.h> | ||
#include <gui/modules/text_box.h> | ||
|
||
#include <dialogs/dialogs.h> | ||
#include <input/input.h> | ||
|
||
#include "scenes/brainfuck_scene.h" | ||
|
||
#include "views/bf_dev_env.h" | ||
|
||
#include <storage/storage.h> | ||
#include <lib/toolbox/path.h> | ||
#include <brainfuck_icons.h> | ||
|
||
#include <storage/storage.h> | ||
#include <stream/stream.h> | ||
#include <stream/buffered_file_stream.h> | ||
#include <toolbox/stream/file_stream.h> | ||
|
||
#define BF_INST_BUFFER_SIZE 2048 | ||
#define BF_OUTPUT_SIZE 512 | ||
#define BF_STACK_INITIAL_SIZE 128 | ||
#define BF_INPUT_BUFFER_SIZE 64 | ||
#define BF_STACK_STEP_SIZE 32 | ||
|
||
enum brainfuckCustomEvent { | ||
// Reserve first 100 events for button types and indexes, starting from 0 | ||
brainfuckCustomEventReserved = 100, | ||
|
||
brainfuckCustomEventViewExit, | ||
brainfuckCustomEventWorkerExit, | ||
brainfuckCustomEventByteInputDone, | ||
brainfuckCustomEventTextInputDone, | ||
}; | ||
|
||
typedef enum { | ||
EventTypeTick, | ||
EventTypeKey, | ||
} EventType; | ||
|
||
struct BFApp { | ||
ViewDispatcher* view_dispatcher; | ||
Gui* gui; | ||
NotificationApp* notifications; | ||
SceneManager* scene_manager; | ||
Submenu* submenu; | ||
Popup* popup; | ||
TextInput* text_input; | ||
TextBox* text_box; | ||
FuriString* text_box_store; | ||
FuriString* BF_file_path; | ||
BFDevEnv* BF_dev_env; | ||
int dataSize; | ||
char dataBuffer[BF_INST_BUFFER_SIZE]; | ||
char inputBuffer[BF_INPUT_BUFFER_SIZE]; | ||
}; | ||
|
||
typedef enum { | ||
brainfuckViewMenu, | ||
brainfuckViewPopup, | ||
brainfuckViewLoading, | ||
brainfuckViewTextInput, | ||
brainfuckViewTextBox, | ||
brainfuckViewWidget, | ||
brainfuckViewDev, | ||
brainfuckViewExec, | ||
} brainfuckView; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.