diff --git a/include/arm11/menu/menu_func.h b/include/arm11/menu/menu_func.h index 3bd5241..2211feb 100644 --- a/include/arm11/menu/menu_func.h +++ b/include/arm11/menu/menu_func.h @@ -19,10 +19,11 @@ */ #include "types.h" +#include "mem_map.h" #define NAND_BACKUP_PATH "sdmc:/3DS" // NAND backups standard path +#define DEVICE_BUFSIZE ((((REG_PDN_MPCORE_CFG>>1)&0x1) ? 1024 : 512) * 1024) // 1024 / 512 KiB #define PROGRESS_WIDTH 20 -#define DEVICE_BUFSIZE (512 * 1024) // 256 KiB u32 menuPresetNandTools(void); u32 menuPresetBootMenu(void); diff --git a/source/arm11/hardware/mcu.c b/source/arm11/hardware/mcu.c index 7e1b5aa..6bb18a5 100644 --- a/source/arm11/hardware/mcu.c +++ b/source/arm11/hardware/mcu.c @@ -90,7 +90,7 @@ state = I2C_readReg(I2C_DEV_MCU, RegExHW); - return (state & (1u << 4)) == 1; + return (bool) (state & (1u << 4)); } u8 MCU_readSystemModel(void) diff --git a/source/arm11/menu/battery.c b/source/arm11/menu/battery.c index ce2c6c0..40d3cb1 100644 --- a/source/arm11/menu/battery.c +++ b/source/arm11/menu/battery.c @@ -1,5 +1,3 @@ -#pragma once - /* * This file is part of fastboot 3DS * Copyright (C) 2017 derrek, profi200, d0k3 @@ -19,11 +17,11 @@ */ -#include "arm11/hardware/i2c.h" +#include "arm11/hardware/mcu.h" #include "arm11/menu/battery.h" void getBatteryState(BatteryState *battery) { - battery->percent = I2C_readReg(I2C_DEV_MCU, 0x0B); - battery->charging = (I2C_readReg(I2C_DEV_MCU, 0x0F) & (1<<4)); + battery->percent = MCU_readBatteryLevel(); + battery->charging = MCU_readBatteryChargeState(); } diff --git a/source/arm11/menu/menu_func.c b/source/arm11/menu/menu_func.c index d76fe14..12acddf 100644 --- a/source/arm11/menu/menu_func.c +++ b/source/arm11/menu/menu_func.c @@ -408,8 +408,7 @@ { s64 readBytes = (nand_size - p > DEVICE_BUFSIZE) ? DEVICE_BUFSIZE : nand_size - p; s32 errcode = 0; - if (!(p % (DEVICE_BUFSIZE*4))) - ee_printf_progress("NAND backup", PROGRESS_WIDTH, p, nand_size); + ee_printf_progress("NAND backup", PROGRESS_WIDTH, p, nand_size); updateScreens(); if ((errcode = fReadToDeviceBuffer(devHandle, p, readBytes, dbufHandle)) != 0) @@ -482,7 +481,7 @@ BatteryState battery; getBatteryState(&battery); if ((battery.percent <= 20) && !battery.charging) { - ee_printf("Battery below 20% and not charging.\nPlug in the charger and retry.\n"); + ee_printf("Battery below 20%% and not charging.\nPlug in the charger and retry.\n"); goto fail; } @@ -581,8 +580,7 @@ { s64 readBytes = (file_size - p > DEVICE_BUFSIZE) ? DEVICE_BUFSIZE : file_size - p; s32 errcode = 0; - if (!(p % (DEVICE_BUFSIZE*4))) - ee_printf_progress("NAND restore", PROGRESS_WIDTH, p, file_size); + ee_printf_progress("NAND restore", PROGRESS_WIDTH, p, file_size); updateScreens(); if ((errcode = fReadToDeviceBuffer(fHandle, p, readBytes, dbufHandle)) != 0) diff --git a/source/arm11/menu/menu_util.c b/source/arm11/menu/menu_util.c index 4d290e7..ab0672a 100644 --- a/source/arm11/menu/menu_util.c +++ b/source/arm11/menu/menu_util.c @@ -293,7 +293,8 @@ { if (cancelAllowed) { - ee_printf("\n\nCancel current operation?\n(A to confirm, B to continue)\n\n"); + ee_printf("\r%60.60s\r", ""); // delete current line + ee_printf("Cancel current operation?\n(A to confirm, B to continue)\n\n"); updateScreens(); do { @@ -311,7 +312,8 @@ } else { - ee_printf("\n\nCancel is not allowed here.\n\n"); + ee_printf("\r%60.60s\r", ""); // delete current line + ee_printf("Cancel is not allowed here.\n\n"); } hidGetPowerButton(true); // poweroff stopped