/* * This file is part of open_agb_firm * Copyright (C) 2021 derrek, profi200 * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #include "fs.h" #include "arm11/open_agb_firm.h" #include "drivers/gfx.h" #include "arm11/drivers/mcu.h" #include "arm11/console.h" #include "arm11/drivers/codec.h" #include "arm11/drivers/hid.h" #include "arm11/drivers/timer.h" #include "arm11/power.h" #include "arm11/acf.h" // @MERGE 231006 START #include "oaf_error_codes.h" // @MERGE 231006 END #include "arm11/anopatch.h" static void setBacklight(void) { u16 backlightMax; u16 backlightMin; if(MCU_getSystemModel() >= 4) { backlightMax=800; backlightMin=50; } else { backlightMax=500; backlightMin=20; } u16 backlight = oafGetBacklightConfig(); if (backlight > backlightMax) backlight = backlightMax; else if (backlight < backlightMin) backlight = backlightMin; setBrightness( backlight ); } Result fReadSize( FHandle file, void *buff, unsigned size, uint32_t *readout ) { uint32_t fill = 0; uint32_t readed; do{ Result res; if( RES_OK != (res=fRead(file, buff+fill, size-fill < 256 ? size-fill : 256, &readed)) ){ *readout = fill; return res; } fill += readed; } while( fill < size ); *readout = fill; return RES_OK; } static char firm_path[FIRMPATH_SIZELIMIT]; int main() { int reboot = 0; strncpy( firm_path, FIRMPATH_INCOME, FIRMPATH_SIZELIMIT ); //Result res = fMount(FS_DRIVE_SDMC); bool direct_off = false; if(res == RES_OK) res = oafParseConfigEarly(); GFX_init(GFX_BGR8, GFX_BGR565, GFX_TOP_2D); setBacklight(); consoleInit(GFX_LCD_BOT, NULL); //CODEC_init(); if(res == RES_OK && (res = oafInitAndRun(firm_path, &direct_off)) == RES_OK) { do { hidScanInput(); if(hidGetExtraKeys(0) & (KEY_POWER_HELD | KEY_POWER)) break; oafUpdate(); } while(1); reboot = oafHaltMode(); oafFinish(); } else if( !direct_off ) printErrorWaitInput(res, 0); if( reboot ) { if( RES_OK == oafPreboot(firm_path) ) { CODEC_deinit(); GFX_deinit(); fUnmount(FS_DRIVE_SDMC); TIMER_sleepMs(500); power_reboot(); return 0; } } CODEC_deinit(); GFX_deinit(); fUnmount(FS_DRIVE_SDMC); power_off(); return 0; }