mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-30 09:37:53 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -51,126 +51,120 @@ using namespace portapack;
|
|||
namespace ui {
|
||||
|
||||
void LoadModuleView::focus() {
|
||||
button_ok.focus();
|
||||
button_ok.focus();
|
||||
}
|
||||
|
||||
void LoadModuleView::on_show() {
|
||||
char md5_signature[16];
|
||||
uint8_t c;
|
||||
|
||||
memcpy(md5_signature, (const void *)(0x10087FF0), 16);
|
||||
for (c=0; c<16; c++) {
|
||||
if (md5_signature[c] != _hash[c]) break;
|
||||
}
|
||||
//text_info.set(to_string_hex(*((unsigned int*)0x10087FF0), 8));
|
||||
|
||||
if (c == 16) {
|
||||
text_info.set("Module already loaded :)");
|
||||
_mod_loaded = true;
|
||||
} else {
|
||||
text_info.set("Loading module");
|
||||
loadmodule();
|
||||
}
|
||||
char md5_signature[16];
|
||||
uint8_t c;
|
||||
|
||||
memcpy(md5_signature, (const void*)(0x10087FF0), 16);
|
||||
for (c = 0; c < 16; c++) {
|
||||
if (md5_signature[c] != _hash[c]) break;
|
||||
}
|
||||
// text_info.set(to_string_hex(*((unsigned int*)0x10087FF0), 8));
|
||||
|
||||
if (c == 16) {
|
||||
text_info.set("Module already loaded :)");
|
||||
_mod_loaded = true;
|
||||
} else {
|
||||
text_info.set("Loading module");
|
||||
loadmodule();
|
||||
}
|
||||
}
|
||||
|
||||
int LoadModuleView::load_image() {
|
||||
const char magic[6] = {'P', 'P', 'M', ' ', 0x02, 0x00};
|
||||
UINT bw;
|
||||
uint8_t i;
|
||||
uint32_t cnt;
|
||||
char md5sum[16];
|
||||
FILINFO modinfo;
|
||||
FIL modfile;
|
||||
DIR rootdir;
|
||||
FRESULT res;
|
||||
|
||||
// Scan SD card root directory for files with the right MD5 fingerprint at the right location
|
||||
if (f_opendir(&rootdir, "/") == FR_OK) {
|
||||
for (;;) {
|
||||
res = f_readdir(&rootdir, &modinfo);
|
||||
if (res != FR_OK || modinfo.fname[0] == 0) break; // Reached last file, abort
|
||||
// Only care about files with .bin extension
|
||||
if ((!(modinfo.fattrib & AM_DIR)) && (modinfo.fname[9] == 'B') && (modinfo.fname[10] == 'I') && (modinfo.fname[11] == 'N')) {
|
||||
res = f_open(&modfile, modinfo.fname, FA_OPEN_EXISTING | FA_READ);
|
||||
if (res != FR_OK) return 0;
|
||||
// Magic bytes and version check
|
||||
f_read(&modfile, &md5sum, 6, &bw);
|
||||
for (i = 0; i < 6; i++)
|
||||
if (md5sum[i] != magic[i]) break;
|
||||
if (i == 6) {
|
||||
f_lseek(&modfile, 26);
|
||||
f_read(&modfile, &md5sum, 16, &bw);
|
||||
for (i = 0; i < 16; i++)
|
||||
if (md5sum[i] != _hash[i]) break;
|
||||
// f_read can't read more than 512 bytes at a time ?
|
||||
if (i == 16) {
|
||||
f_lseek(&modfile, 512);
|
||||
for (cnt = 0; cnt < 64; cnt++) {
|
||||
if (f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base() + (cnt * 512)), 512, &bw)) return 0;
|
||||
}
|
||||
f_close(&modfile);
|
||||
f_closedir(&rootdir);
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
f_close(&modfile);
|
||||
}
|
||||
}
|
||||
f_closedir(&rootdir);
|
||||
}
|
||||
|
||||
return 0;
|
||||
const char magic[6] = {'P', 'P', 'M', ' ', 0x02, 0x00};
|
||||
UINT bw;
|
||||
uint8_t i;
|
||||
uint32_t cnt;
|
||||
char md5sum[16];
|
||||
FILINFO modinfo;
|
||||
FIL modfile;
|
||||
DIR rootdir;
|
||||
FRESULT res;
|
||||
|
||||
// Scan SD card root directory for files with the right MD5 fingerprint at the right location
|
||||
if (f_opendir(&rootdir, "/") == FR_OK) {
|
||||
for (;;) {
|
||||
res = f_readdir(&rootdir, &modinfo);
|
||||
if (res != FR_OK || modinfo.fname[0] == 0) break; // Reached last file, abort
|
||||
// Only care about files with .bin extension
|
||||
if ((!(modinfo.fattrib & AM_DIR)) && (modinfo.fname[9] == 'B') && (modinfo.fname[10] == 'I') && (modinfo.fname[11] == 'N')) {
|
||||
res = f_open(&modfile, modinfo.fname, FA_OPEN_EXISTING | FA_READ);
|
||||
if (res != FR_OK) return 0;
|
||||
// Magic bytes and version check
|
||||
f_read(&modfile, &md5sum, 6, &bw);
|
||||
for (i = 0; i < 6; i++)
|
||||
if (md5sum[i] != magic[i]) break;
|
||||
if (i == 6) {
|
||||
f_lseek(&modfile, 26);
|
||||
f_read(&modfile, &md5sum, 16, &bw);
|
||||
for (i = 0; i < 16; i++)
|
||||
if (md5sum[i] != _hash[i]) break;
|
||||
// f_read can't read more than 512 bytes at a time ?
|
||||
if (i == 16) {
|
||||
f_lseek(&modfile, 512);
|
||||
for (cnt = 0; cnt < 64; cnt++) {
|
||||
if (f_read(&modfile, reinterpret_cast<void*>(portapack::memory::map::m4_code.base() + (cnt * 512)), 512, &bw)) return 0;
|
||||
}
|
||||
f_close(&modfile);
|
||||
f_closedir(&rootdir);
|
||||
LPC_RGU->RESET_CTRL[0] = (1 << 13);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
f_close(&modfile);
|
||||
}
|
||||
}
|
||||
f_closedir(&rootdir);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LoadModuleView::loadmodule() {
|
||||
//baseband::shutdown();
|
||||
|
||||
/*EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch,
|
||||
[this](Message* const p) {
|
||||
(void)p;*/
|
||||
if (load_image()) {
|
||||
text_infob.set("Module loaded :)");
|
||||
_mod_loaded = true;
|
||||
} else {
|
||||
text_info.set("Module not found :(");
|
||||
_mod_loaded = false;
|
||||
}
|
||||
// }
|
||||
//);
|
||||
|
||||
// baseband::shutdown();
|
||||
|
||||
/*EventDispatcher::message_map().register_handler(Message::ID::ReadyForSwitch,
|
||||
[this](Message* const p) {
|
||||
(void)p;*/
|
||||
if (load_image()) {
|
||||
text_infob.set("Module loaded :)");
|
||||
_mod_loaded = true;
|
||||
} else {
|
||||
text_info.set("Module not found :(");
|
||||
_mod_loaded = false;
|
||||
}
|
||||
// }
|
||||
//);
|
||||
}
|
||||
|
||||
LoadModuleView::LoadModuleView(
|
||||
NavigationView& nav,
|
||||
const char * hash,
|
||||
ViewID viewid
|
||||
)
|
||||
{
|
||||
NavigationView& nav,
|
||||
const char* hash,
|
||||
ViewID viewid) {
|
||||
add_children({&text_info,
|
||||
&text_infob,
|
||||
&button_ok});
|
||||
|
||||
add_children({
|
||||
&text_info,
|
||||
&text_infob,
|
||||
&button_ok
|
||||
});
|
||||
|
||||
_hash = hash;
|
||||
_hash = hash;
|
||||
|
||||
button_ok.on_select = [this, &nav, viewid](Button&){
|
||||
nav.pop();
|
||||
if (_mod_loaded == true) {
|
||||
if (viewid == AudioTX) nav.push<AudioTXView>();
|
||||
if (viewid == Xylos) nav.push<XylosView>();
|
||||
if (viewid == EPAR) nav.push<EPARView>();
|
||||
if (viewid == LCR) nav.push<LCRView>();
|
||||
if (viewid == SoundBoard) nav.push<SoundBoardView>();
|
||||
if (viewid == AnalogAudio) nav.push<AnalogAudioView>();
|
||||
if (viewid == RDS) nav.push<RDSView>();
|
||||
if (viewid == CloseCall) nav.push<CloseCallView>();
|
||||
if (viewid == Receiver) nav.push<ReceiverMenuView>();
|
||||
if (viewid == Jammer) nav.push<JammerView>();
|
||||
}
|
||||
};
|
||||
button_ok.on_select = [this, &nav, viewid](Button&) {
|
||||
nav.pop();
|
||||
if (_mod_loaded == true) {
|
||||
if (viewid == AudioTX) nav.push<AudioTXView>();
|
||||
if (viewid == Xylos) nav.push<XylosView>();
|
||||
if (viewid == EPAR) nav.push<EPARView>();
|
||||
if (viewid == LCR) nav.push<LCRView>();
|
||||
if (viewid == SoundBoard) nav.push<SoundBoardView>();
|
||||
if (viewid == AnalogAudio) nav.push<AnalogAudioView>();
|
||||
if (viewid == RDS) nav.push<RDSView>();
|
||||
if (viewid == CloseCall) nav.push<CloseCallView>();
|
||||
if (viewid == Receiver) nav.push<ReceiverMenuView>();
|
||||
if (viewid == Jammer) nav.push<JammerView>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue