J пре 3 година
родитељ
комит
43bfbb62a8
4 измењених фајлова са 21 додато и 28 уклоњено
  1. 2 0
      .gitignore
  2. 3 5
      README.md
  3. 1 0
      scenes/brainfuck_scene_dev.c
  4. 15 23
      views/bf_dev_env.c

+ 2 - 0
.gitignore

@@ -0,0 +1,2 @@
+
+README.md

+ 3 - 5
README.md

@@ -1,10 +1,8 @@
 # FlipperZeroBrainfuck
 
 Brainfuck interpreter and editor for the F0.  
-Supports text inputs and outputs.
-No protection against infinite loops or syntax errors.  
-Major limitation is that programs MUST terminate, or it will freeze at "RUNNING"
+Currently doesnt support inputs but runs and outputs (mostly) fine.  
 
-![Screenshot-20230117-202147](https://user-images.githubusercontent.com/16545187/213004616-8846e897-506e-4510-8012-fd2fe2bbe8a1.png)
+![Screenshot-20230115-223703](https://user-images.githubusercontent.com/16545187/212570889-08a22563-2cff-4783-9a7a-f648a708f95d.png)
 
-![Screenshot-20230117-202208](https://user-images.githubusercontent.com/16545187/213004659-d74751d2-76c4-4a7b-a0f2-f58623478b95.png)
+![Screenshot-20230115-223726](https://user-images.githubusercontent.com/16545187/212570903-cffdb4ed-dfea-4de2-8ef0-6832fe2bbd2b.png)

+ 1 - 0
scenes/brainfuck_scene_dev.c

@@ -14,3 +14,4 @@ bool brainfuck_scene_dev_env_on_event(void* context, SceneManagerEvent event) {
 void brainfuck_scene_dev_env_on_exit(void* context) {
     UNUSED(context);
 }
+

+ 15 - 23
views/bf_dev_env.c

@@ -78,21 +78,21 @@ static void bf_dev_draw_button(Canvas* canvas, int x, int y, bool selected, cons
     }
 }
 
+void bf_save_changes(){
+    //remove old file
+    Storage* storage = furi_record_open(RECORD_STORAGE);
+    storage_simply_remove(storage, furi_string_get_cstr(appDev->BF_file_path));
+
+    //save new file
+    Stream* stream = buffered_file_stream_alloc(storage);
+    buffered_file_stream_open(stream, furi_string_get_cstr(appDev->BF_file_path), FSAM_WRITE, FSOM_CREATE_ALWAYS);
+    stream_write(stream, (const uint8_t*)appDev->dataBuffer, appDev->dataSize);
+    buffered_file_stream_close(stream);
+}
+
 static void bf_dev_draw_callback(Canvas* canvas, void* _model) {
     UNUSED(_model);
 
-    // if(execCountdown > 0){
-    //     execCountdown--;
-    //     canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "RUNNING...");
-    //     if(execCountdown == 0){
-    //         initWorker(appDev);
-    //         beginWorker();
-    //         text_box_set_text(appDev->text_box, workerGetOutput());
-    //         scene_manager_next_scene(appDev->scene_manager, brainfuckSceneExecEnv);
-    //     }
-    //     return;
-    // }
-
     if(saveNotifyCountdown > 0){
         canvas_draw_str_aligned(canvas, 64, 32, AlignCenter, AlignCenter, "SAVED");
         saveNotifyCountdown--;
@@ -298,6 +298,8 @@ static bool bf_dev_process_ok(BFDevEnv* devEnv, InputEvent* event) {
                 furi_thread_join(workerThread);
             }
 
+            bf_save_changes();
+
             initWorker(appDev);
             text_box_set_focus(appDev->text_box, TextBoxFocusEnd);
             text_box_set_text(appDev->text_box, workerGetOutput());
@@ -311,17 +313,7 @@ static bool bf_dev_process_ok(BFDevEnv* devEnv, InputEvent* event) {
 
         case 11:
         {
-            //remove old file
-            Storage* storage = furi_record_open(RECORD_STORAGE);
-            storage_simply_remove(storage, furi_string_get_cstr(appDev->BF_file_path));
-
-            //save new file
-            Stream* stream = buffered_file_stream_alloc(storage);
-            buffered_file_stream_open(stream, furi_string_get_cstr(appDev->BF_file_path), FSAM_WRITE, FSOM_CREATE_ALWAYS);
-            stream_write(stream, (const uint8_t*)appDev->dataBuffer, appDev->dataSize);
-            buffered_file_stream_close(stream);
-
-            //notify
+            bf_save_changes();
             saveNotifyCountdown = 3;
             break;
         }