AC_INIT([Corbenik], [0.1.2], [https://github.com/chaoskagami/corbenik], [corbenik])
AM_INIT_AUTOMAKE([foreign no-dist-gzip dist-xz subdir-objects])
-AC_CONFIG_MACRO_DIRS([m4])
-
# Find AR and RANLIB for lto support before initializing libtool
AC_CHECK_TOOL([AR],gcc-ar)
AC_CHECK_TOOL([RANLIB],gcc-ranlib)
screen_bottom
};
-_UNUSED static struct framebuffers
+struct framebuffers
{
uint8_t *top_left;
uint8_t *top_right;
uint8_t *bottom;
-} *framebuffers = (struct framebuffers *)0x23FFFE00;
+};
+
+_UNUSED static struct framebuffers *framebuffers_cakehax = (struct framebuffers *)0x23FFFE00;
+extern struct framebuffers *framebuffers;
// This is marked unused since it occurs in all files.
#define TOP_FB framebuffers->top_left
std_init();
- int c = fmount();
-
- if (c) {
- // Failed to mount SD. Bomb out.
- // TODO - What the hell does one even do in this situation?
- // Spin until the card is available to mount, maybe?
- abort("Failed to mount SD card.\n");
- }
-
- if (argc >= 1 && argc < 2) {
- // Valid argc passed.
- fprintf(stderr, "Chainloaded. Path: %s\n", argv[0]);
- }
+ if (fmount())
+ poweroff(); // Failed to mount SD. Bomb out.
set_font(PATH_TERMFONT); // Read the font before all else.
config->options[OPTION_BRIGHTNESS] = 3;
if (!(conf_handle = fopen(PATH_CONFIG, "w")))
- abort("Failed to open config for write?\n");
+ poweroff();
fwrite(config, 1, sizeof(struct config_file), conf_handle);
fclose(conf_handle);
-
- fprintf(BOTTOM_SCREEN, "Config file written.\n");
}
void
int updated = 0;
if (config->options[OPTION_ACCENT_COLOR] == 0) {
- fprintf(stderr, "Config update: accent color\n");
config->options[OPTION_ACCENT_COLOR] = 2;
updated = 1;
}
// Zero on success.
if (!(conf_handle = fopen(PATH_CONFIG, "r"))) {
- fprintf(BOTTOM_SCREEN, "Config file is missing:\n"
- " %s\n"
- "Regenerating with defaults.\n",
- PATH_CONFIG);
regenerate_config();
} else {
fread(config, 1, sizeof(struct config_file), conf_handle);
fclose(conf_handle);
if (memcmp(&(config->magic), CONFIG_MAGIC, 4)) {
- fprintf(BOTTOM_SCREEN, "Config file at:\n"
- " %s\n"
- "has incorrect magic:\n"
- " '%c%c%c%c'\n"
- "Regenerating with defaults.\n",
- PATH_CONFIG, config->magic[0], config->magic[1], config->magic[2], config->magic[3]);
f_unlink(PATH_CONFIG);
regenerate_config();
}
if (config->config_ver < config_version) {
- fprintf(BOTTOM_SCREEN, "Config file has outdated version:\n"
- " %s\n"
- "Regenerating with defaults.\n",
- PATH_CONFIG);
f_unlink(PATH_CONFIG);
regenerate_config();
}
list_patches_build(PATH_PATCHES, 0);
- if (!config->options[OPTION_SILENCE])
- fprintf(BOTTOM_SCREEN, "Config file loaded.\n");
-
update_config();
}
static volatile uint32_t *const a11_entry = (volatile uint32_t *)0x1FFFFFF8;
+struct framebuffers* framebuffers = NULL;
+
void
screen_mode(uint32_t mode)
{
while (*a11_entry);
+ if (!framebuffers) {
+ framebuffers = malloc(sizeof(struct framebuffers));
+ memcpy(framebuffers, framebuffers_cakehax, sizeof(struct framebuffers));
+ }
+
// Turn on backlight
i2cWriteRegister(I2C_DEV_MCU, 0x22, 1 << 1);
}