From: chaoskagami Date: Wed, 3 Aug 2016 10:03:12 +0000 (-0400) Subject: Merge branch 'master' into wip/malloc X-Git-Tag: v0.3.0~72 X-Git-Url: https://chaos.moe/g/?a=commitdiff_plain;h=2a3b404f393558ee8deb8c6bab1aae19eb4b130d;p=corbenik%2Fcorbenik.git Merge branch 'master' into wip/malloc --- 2a3b404f393558ee8deb8c6bab1aae19eb4b130d diff --cc external/libctr9 index 1629815,0cb25b0..eb78012 --- a/external/libctr9 +++ b/external/libctr9 @@@ -1,1 -1,1 +1,1 @@@ - Subproject commit 1629815c5a08ff95c3b0d592bbf9583c63cd124b -Subproject commit 0cb25b034cb07a96077f1b0af4fd84960fdcd151 ++Subproject commit eb78012240776d8143a2c6eede4802410d606f85 diff --cc source/firm/firm.c index f8ab2da,07a03b8..698ff88 --- a/source/firm/firm.c +++ b/source/firm/firm.c @@@ -37,10 -37,11 +37,11 @@@ int decrypt_arm9bin(arm9bin_h *header, void dump_firm(firm_h** buffer, uint8_t index) { if (*buffer != NULL) return; - uint32_t firm_offset = 0x0B130000 + (index % 2) * 0x400000, - firm_size = 0x00100000; // 1MB, because + // NOTE - Cast, because GCC is making assumptions about 'index'. + uint32_t firm_offset = (uint32_t)(0x0B130000 + (index % 2) * 0x400000), + firm_b_size = 0x00100000; // 1MB, because - buffer[0] = malloc(firm_size); - buffer[0] = static_allocate(firm_b_size); ++ buffer[0] = malloc(firm_b_size); uint8_t ctr[0x10], cid[0x10], diff --cc source/main.c index cc8844c,9a728e1..3da3db2 --- a/source/main.c +++ b/source/main.c @@@ -33,25 -49,11 +49,11 @@@ main(int argc, char** argv ctr_screen_enable_backlight(CTR_SCREEN_BOTH); - set_font(PATH_TERMFONT); - install_interrupts(); // Get some free debug info. - if (c) { - // Failed to mount SD. Bomb out. - abort("Failed to mount SD card.\n"); - } - - if (argc >= 1 && argc < 2) { - // Valid argc passed. - fprintf(stderr, "Chainloaded. Path: %s\n", argv[0]); - } - - load_config(); // Load configuration. - if (CFG_BOOTENV == 7) { fprintf(stderr, "Rebooted from AGB, disabling EmuNAND.\n"); - config.options[OPTION_EMUNAND] = 0; + config->options[OPTION_EMUNAND] = 0; } // Autoboot. Non-standard code path. diff --cc source/option.c index 1d8d710,29b46d5..88924d5 --- a/source/option.c +++ b/source/option.c @@@ -9,11 -9,11 +9,12 @@@ void list_patches_build(char *name, in void regenerate_config() { - memset(&config, 0, sizeof(config)); - memcpy(&(config.magic), CONFIG_MAGIC, 4); - config.config_ver = config_version; - config.options[OPTION_ACCENT_COLOR] = 2; - config.options[OPTION_BRIGHTNESS] = 3; + for(int i=0; i < 4; i++) + config->magic[i] = CONFIG_MAGIC[i]; + + config->config_ver = config_version; + config->options[OPTION_ACCENT_COLOR] = 2; ++ config->options[OPTION_BRIGHTNESS] = 3; if (!(conf_handle = fopen(PATH_CONFIG, "w"))) abort("Failed to open config for write?\n"); @@@ -99,10 -96,10 +100,10 @@@ load_config( regenerate_config(); } - if (config.config_ver < config_version) { + if (config->config_ver < config_version) { fprintf(BOTTOM_SCREEN, "Config file has outdated version:\n" " %s\n" - "Regenerating with defaults...\n", + "Regenerating with defaults.\n", PATH_CONFIG); f_unlink(PATH_CONFIG); regenerate_config(); @@@ -129,10 -124,12 +128,12 @@@ save_config( if (!(conf_handle = fopen(PATH_CONFIG, "w"))) abort("Failed to open config for write?\n"); - config.options[OPTION_RECONFIGURED] = 0; // This should not persist to disk. + config->options[OPTION_RECONFIGURED] = 0; // This should not persist to disk. - fwrite(&config, 1, sizeof(config), conf_handle); + fwrite(config, 1, sizeof(struct config_file), conf_handle); fclose(conf_handle); - config.options[OPTION_RECONFIGURED] = 1; // Save caches on boot. + config->options[OPTION_RECONFIGURED] = 1; // Save caches on boot. + + fprintf(stderr, "Saved config successfully.\n"); } diff --cc source/screeninit.c index 2348aaf,72dc48e..9b1e255 --- a/source/screeninit.c +++ b/source/screeninit.c @@@ -30,7 -30,9 +30,9 @@@ screen_mode(uint32_t mode if (PDN_GPU_CNT == 1) screenInitAddress[2] = 0; // Do a full init. - screenInitAddress[3] = 0xFF; // Brightness + // FIXME - God awful syntactical hack. - screenInitAddress[3] = ("\x40\x8F\xC0\xFF")[config.options[OPTION_BRIGHTNESS]]; ++ screenInitAddress[3] = ("\x40\x8F\xC0\xFF")[config->options[OPTION_BRIGHTNESS]]; + screenInitAddress[4] = mode; // Mode *a11_entry = (uint32_t)screenInitAddress;