flip_world.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <flip_world.h>
  2. #include <flip_storage/storage.h>
  3. char *fps_choices_str[] = {"30", "60", "120", "240"};
  4. uint8_t fps_index = 0;
  5. char *yes_or_no_choices[] = {"No", "Yes"};
  6. uint8_t screen_always_on_index = 1;
  7. uint8_t sound_on_index = 1;
  8. uint8_t vibration_on_index = 1;
  9. char *player_sprite_choices[] = {"naked", "sword", "axe", "bow"};
  10. uint8_t player_sprite_index = 1;
  11. char *vgm_levels[] = {"-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
  12. uint8_t vgm_x_index = 2;
  13. uint8_t vgm_y_index = 2;
  14. uint8_t game_mode_index = 0;
  15. float atof_(const char *nptr) { return (float)strtod(nptr, NULL); }
  16. float atof_furi(const FuriString *nptr) { return atof_(furi_string_get_cstr(nptr)); }
  17. bool is_str(const char *src, const char *dst) { return strcmp(src, dst) == 0; }
  18. bool is_enough_heap(size_t heap_size, bool check_blocks)
  19. {
  20. const size_t min_heap = heap_size + 1024; // 1KB buffer
  21. const size_t min_free = memmgr_get_free_heap();
  22. if (min_free < min_heap)
  23. {
  24. FURI_LOG_E(TAG, "Not enough heap memory: There are %zu bytes free.", min_free);
  25. return false;
  26. }
  27. if (check_blocks)
  28. {
  29. const size_t max_free_block = memmgr_heap_get_max_free_block();
  30. if (max_free_block < min_heap)
  31. {
  32. FURI_LOG_E(TAG, "Not enough free blocks: %zu bytes", max_free_block);
  33. return false;
  34. }
  35. }
  36. return true;
  37. }