#include #include #include "draw_menu.h" #include "draw.h" #include "menu.h" #include "progress.h" #define PALETTE_COLOR_TRSP 0 #define PALETTE_COLOR_BLACK 1 #define PALETTE_COLOR_WHITE 192 /* rgb(255, 255, 255) */ #define PALETTE_COLOR_GREY 193 /* rgb(128, 128, 128) */ #define PALETTE_COLOR_GRASS 194 /* rgb(140, 182, 66) */ #define PALETTE_COLOR_OCEAN 195 /* rgb( 41, 125, 165) */ #define PALETTE_COLOR_GREEN 235 /* rgb( 58, 174, 41) */ #define PALETTE_COLOR_BLUE 231 /* rgb( 49, 158, 189) */ #define PALETTE_COLOR_GREENDARK 201 /* rgb( 55, 100, 49) */ #define PALETTE_COLOR_BLUEDARK 197 /* rgb( 52, 94, 110) */ #define PALETTE_COLOR_LRED 240 /* rgb(219, 111, 111) */ #define PALETTE_COLOR_LGREEN 232 /* rgb(107, 196, 97) */ #define PALETTE_COLOR_LBLUE 228 /* rgb(101, 183, 205) */ #define PALETTE_COLOR_LYELLOW 248 /* rgb(211, 177, 92) */ static const uint8_t PALETTE_LCOLORS[4] = { PALETTE_COLOR_LYELLOW, PALETTE_COLOR_LRED, PALETTE_COLOR_LGREEN, PALETTE_COLOR_LBLUE, }; static uint8_t menu_icons_sprites[3][7*9+2]; #define SIGN_SX 96 #define SIGN_SY 40 #define SIGN_X ((320 - SIGN_SX) / 2) #define SIGN_Y ((240 - SIGN_SY) / 2) #define ROAD_X (320 * 2) #define ROAD_Y (190) static void draw_menu_sign(int x, int y) { static const uint8_t rects[] = {44,0,4,39, 43,1,6,37, 2,5,86,18, 1,6,87,16, 0,7,89,14}; static const uint8_t lines[] = {87,5,94,12, 87,6,94,13, 86,6,93,13, 87,22,94,15, 87,21,94,14, 86,21,93,14}; uint8_t i; gfx_SetColor(PALETTE_COLOR_GREY); gfx_Rectangle(x+45, y+2, 2, 35); gfx_SetColor(PALETTE_COLOR_BLACK); for (i = 0; i < sizeof(rects) / 4; ++i) { const uint8_t* rect = &rects[i * 4]; gfx_Rectangle(x+rect[0], y+rect[1], rect[2], rect[3]); } gfx_SetColor(PALETTE_COLOR_WHITE); gfx_FillRectangle(x+2, y+7, 88, 14); gfx_FillRectangle(x+90, y+11, 4, 6); gfx_SetColor(PALETTE_COLOR_BLACK); for (i = 0; i < sizeof(lines) / 4; ++i) { const uint8_t* line = &lines[i * 4]; gfx_Line(x+line[0], y+line[1], x+line[2], y+line[3]); } gfx_SetTextConfig(gfx_text_clip); gfx_PrintStringXY("RGB EXPRESS", x+5, y+11); gfx_SetTextConfig(gfx_text_noclip); } static void draw_menu_info(void) { gfx_SetTextFGColor(PALETTE_COLOR_BLUEDARK); gfx_PrintStringXY("press [enter] to play", 89, 24 - 7 - 4 - 4); gfx_PrintStringXY("press [clear] to quit", 91, 24 + 7 + 4 - 4); gfx_SetTextFGColor(PALETTE_COLOR_GREENDARK); gfx_PrintStringXY("original game by Bad Crane", 71, 120 - 7 - 4 - 2); gfx_PrintStringXY("remake by Nathan MESNARD", 73, 120 + 7 + 4 - 2); gfx_SetTextFGColor(PALETTE_COLOR_BLACK); } static void draw_menu_houses(void) { uint16_t house_index = ((menu_view_x + 170 - 1) / 320) - 3; int house_x = (320 - ((menu_view_x + 170) % 320)) % 320; uint8_t d; for (d = 2; d --> 0;) { uint16_t house_level_first = house_index * 10 - 10 + 1; uint16_t house_level_last = house_level_first + 10 - 1; if (house_level_last > menu_levels_count) house_level_last = menu_levels_count; if ((house_index == menu_level_x) && (menu_level_status == MENU_VISIBLE) && (house_x >= 127+4-9 && house_x <= 127+95-13-9)) draw_bubble_arrow(house_x+9, 125+28-1); draw_house(house_x, 164, --house_index % 4, house_level_last > 0 && progress_levels_done(house_level_first, house_level_last)); if (!house_index) break; house_x -= 320; } } void draw_menu(void) { static const uint8_t level_status_icon[4] = {1,0,2,3}; gfx_FillScreen(PALETTE_COLOR_GRASS); //gfx_SetColor(PALETTE_COLOR_GRASS); //if (menu_view_y < 240) gfx_HorizLine_NoClip(0, menu_view_y, (240 - menu_view_y) * 320); //gfx_FillRectangle_NoClip(0, menu_view_y, 320, 240 - menu_view_y); gfx_SetColor(PALETTE_COLOR_OCEAN); if (menu_view_y) gfx_HorizLine_NoClip(0, 0, menu_view_y * 320); //gfx_FillRectangle_NoClip(0, 0, 320, menu_view_y); if (menu_view_x <= SIGN_X + SIGN_SX) { draw_menu_sign(SIGN_X - menu_view_x, menu_view_y + SIGN_Y - MENU_LAND_Y); } else if ((menu_view_x < 320 * 3) && (menu_level_status == MENU_NONE)) { draw_menu_info(); } draw_menu_road(ROAD_X - menu_view_x, menu_view_y + ROAD_Y - MENU_LAND_Y); draw_menu_truck(menu_view_x < 320 * 2 ? (320 * 2 - menu_view_x) / 2 + 150 : 150, menu_view_y + ROAD_Y - MENU_LAND_Y - 4 - (((menu_view_x + 20) / 40) & 1), menu_view_vx); if (menu_level_status == MENU_VISIBLE) { uint8_t y; draw_bubble(127, 28, 95, 125); if (menu_level_y) { gfx_SetColor(PALETTE_LCOLORS[menu_level_x % 4]); gfx_FillRectangle_NoClip(128+2, menu_level_y*12 + (31-12), 93-4, 12 - 1); } else { gfx_PrintStringXY("No level", 132 + 17, 3 * 12 + (32-12) + 1); gfx_PrintStringXY("found.", 132 + 22, 4 * 12 + (32-12) + 1); gfx_PrintStringXY("Reinstall", 132 + 12, 7 * 12 + (32-12) + 1); gfx_PrintStringXY("RGBELVLS.", 132 + 9, 8 * 12 + (32-12) + 1); } for (y = 1; y <= menu_level_ymax; ++y) { uint16_t level_index = (menu_level_x-1)*10+y; uint8_t icon = level_status_icon[progress_level_get(level_index)]; draw_level_name(level_index, 132, y * 12 + (32-12) + 1); if (icon) gfx_TransparentSprite_NoClip( (gfx_sprite_t*) menu_icons_sprites[icon-1], 127 + 95 - 1 - 4 - 7, y * 12 + (32-12) ); } } if (menu_view_x > 320 * 4 - 170) draw_menu_houses(); gfx_SwapDraw(); } void draw_menu_init(void) { static const uint8_t menu_icons_bits[3][9] = { {0x9C,0xBE,0xB6,0xB6,0xFF,0xFF,0xFF,0xFF,0xFF}, {0x80,0x83,0x83,0x87,0x86,0xEE,0xFC,0xBC,0x98}, {0x80,0x80,0x80,0x9C,0xBE,0xBE,0xBE,0x9C,0x80}, }; uint8_t icon_index; for (icon_index = 0; icon_index < 3; ++icon_index) { uint8_t byte_index; for (byte_index = 9; byte_index > 0;) { uint8_t* output = &menu_icons_sprites[icon_index][byte_index * 7 + 2]; uint8_t bits; for (bits = menu_icons_bits[icon_index][--byte_index]; bits; bits >>= 1) { *--output = bits & 1 ? PALETTE_COLOR_BLACK : PALETTE_COLOR_TRSP; } } menu_icons_sprites[icon_index][0] = 7; menu_icons_sprites[icon_index][1] = 9; } }