// Includes // #include #include #include #include #include #include // #include "mp3.h" // Code // #define button_color 0xbbbbbb #define button_size 44 #define field_size 4 int field[field_size][field_size] = { {0, 0, 0, 1}, {0, 0, 1, 0}, {0, 0, 0, 1}, {1, 0, 0, 0} }; char* title = "Fridge"; #define BUTTON_RESTART 99 short victory = 0; // Load pictures // char temp_path[4096]; Image* HORIZONTAL_IMAGE; Image* VERTICAL_IMAGE; char* load_file_inmem(char* fname, int32_t* read_sz) { FILE *f = fopen(fname, "rb"); if (!f) { exit(1); } if (fseek(f, 0, SEEK_END)) { exit(1); } int filefield_size = ftell(f); rewind(f); char* fdata = malloc(filefield_size); if(!fdata) { exit(1); } *read_sz = fread(fdata, 1, filefield_size, f); if (ferror(f)) { exit(1); } fclose(f); return fdata; } void load_pictures() { const int icon_rgb_field_size = button_size*button_size; Image *image_data; char *filedata; strcpy(temp_path, "h.png"); int32_t read_bytes; filedata = load_file_inmem(temp_path, &read_bytes); HORIZONTAL_IMAGE = malloc(icon_rgb_field_size * 3); image_data = img_decode(filedata, read_bytes, 0); img_to_rgb2(image_data, HORIZONTAL_IMAGE); strcpy(temp_path, "v.png"); filedata = load_file_inmem(temp_path, &read_bytes); VERTICAL_IMAGE = malloc(icon_rgb_field_size * 3); image_data = img_decode(filedata, read_bytes, 0); img_to_rgb2(image_data, VERTICAL_IMAGE); img_destroy(image_data); free(filedata); } // GUI functions // void RedrawButtons() { for (int j = 5, x = 0; x