Просмотр исходного кода

Memory optimization and fix for issue #35.

Esteban Fuentealba 1 год назад
Родитель
Сommit
7572aeac73
5 измененных файлов с 30 добавлено и 44 удалено
  1. 1 1
      application.fam
  2. 3 0
      docs/changelog.md
  3. 0 1
      malveke_gb_photo.h
  4. 0 20
      scenes/scene_file_select.c
  5. 26 22
      views/boilerplate_scene_1.c

+ 1 - 1
application.fam

@@ -10,7 +10,7 @@ App(
     ],
     stack_size=2 * 1024,
     order=10,
-    fap_version=[2,2],
+    fap_version=[2,3],
     fap_libs=["assets"],
     fap_icon="icons/icon_10px.png",
     fap_icon_assets="icons",

+ 3 - 0
docs/changelog.md

@@ -1,5 +1,8 @@
 # Changelog - Patch Notes
 
+## Version 2.3
+Memory optimization and fix for issue #35.
+
 ## Version 2.2
 Fix Frozen upon exiting the gb photo.
 

+ 0 - 1
malveke_gb_photo.h

@@ -51,7 +51,6 @@ typedef struct {
     int pos_y;
     bool show_instructions;
     uint8_t tile_data[16];
-    uint8_t scratchpad1[0x11FC]; // 0000 - 11fb
 
     unsigned long palette_color_hex_a;
     unsigned long palette_color_hex_b;

+ 0 - 20
scenes/scene_file_select.c

@@ -1,25 +1,6 @@
 #include "../malveke_gb_photo.h"
 #include <storage/storage.h>
 
-// static int32_t game_boy_camera_worker(void* context) {
-//     Boilerplate* app = context;
-
-//     if(!storage_file_open(
-//                 app->camera_ram_sav,
-//                 furi_string_get_cstr(app->file_path),
-//                 FSAM_READ,
-//                 FSOM_OPEN_EXISTING)) {
-
-//                     return 1;
-//     }
-
-//     storage_file_read(app->camera_ram_sav, app->scratchpad1, sizeof(app->scratchpad1));
-//     scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu);
-
-//     return 0;
-
-// }
-
 static bool file_select(Boilerplate* app) {
     furi_assert(app);
 
@@ -53,7 +34,6 @@ void boilerplate_scene_fileselect_on_enter(void* context) {
                furi_string_get_cstr(app->file_path),
                FSAM_READ,
                FSOM_OPEN_EXISTING)) {
-            storage_file_read(app->camera_ram_sav, app->scratchpad1, sizeof(app->scratchpad1));
             scene_manager_next_scene(app->scene_manager, BoilerplateSceneMenu);
         }
     } else {

+ 26 - 22
views/boilerplate_scene_1.c

@@ -80,33 +80,37 @@ void boilerplate_scene_1_draw(Canvas* canvas, BoilerplateScene1Model* model) {
         elements_button_center(canvas, "OK");
     } else {
         int count = (app->page + 1) * 0x1000;
-        uint8_t status = app->scratchpad1[0x11B2 + app->page];
-
-        storage_file_seek(app->camera_ram_sav, count, true);
-
-        for(int y = app->pos_y; y < 14; y++) {
-            for(int x = app->pos_x; x < 16; x++) {
-                storage_file_read(app->camera_ram_sav, app->tile_data, sizeof(app->tile_data));
-                for(int row = 0; row < 8; row++) {
-                    uint8_t temp1 = app->tile_data[row * 2];
-                    uint8_t temp2 = app->tile_data[row * 2 + 1];
-                    for(int pixel = 7; pixel >= 0; pixel--) {
-                        if(((temp1 & 1) + ((temp2 & 1) * 2)) >= 2) {
-                            canvas_draw_dot(canvas, (x * 8) + pixel, (y * 8) + row);
+        if(app->camera_ram_sav) {
+            storage_file_seek(app->camera_ram_sav, count - 0x1b1, true);
+            uint8_t status;
+            storage_file_read(app->camera_ram_sav, &status, 1);
+
+            storage_file_seek(app->camera_ram_sav, count, true);
+
+            for(int y = app->pos_y; y < 14; y++) {
+                for(int x = app->pos_x; x < 16; x++) {
+                    storage_file_read(app->camera_ram_sav, app->tile_data, sizeof(app->tile_data));
+                    for(int row = 0; row < 8; row++) {
+                        uint8_t temp1 = app->tile_data[row * 2];
+                        uint8_t temp2 = app->tile_data[row * 2 + 1];
+                        for(int pixel = 7; pixel >= 0; pixel--) {
+                            if(((temp1 & 1) + ((temp2 & 1) * 2)) >= 2) {
+                                canvas_draw_dot(canvas, (x * 8) + pixel, (y * 8) + row);
+                            }
+                            temp1 >>= 1;
+                            temp2 >>= 1;
                         }
-                        temp1 >>= 1;
-                        temp2 >>= 1;
                     }
                 }
             }
-        }
 
-        if(app->info) {
-            if(status == 0xFF) {
-                canvas_draw_rbox(canvas, 100, 4, 20, 11, 4);
-                canvas_invert_color(canvas);
-                canvas_draw_str_aligned(canvas, 110, 10, AlignCenter, AlignCenter, "D");
-                canvas_invert_color(canvas);
+            if(app->info) {
+                if(status == 0xFF) { // DELETED
+                    canvas_draw_rbox(canvas, 100, 4, 20, 11, 4);
+                    canvas_invert_color(canvas);
+                    canvas_draw_str_aligned(canvas, 110, 10, AlignCenter, AlignCenter, "D");
+                    canvas_invert_color(canvas);
+                }
             }
         }
     }