Skip to content

Commit

Permalink
Memory optimization and fix for issue #35.
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanFuentealba committed Apr 9, 2024
1 parent f6a2fb2 commit 84e75d2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down

0 comments on commit 84e75d2

Please sign in to comment.