diff options
-rw-r--r-- | src/main.c | 69 |
1 files changed, 39 insertions, 30 deletions
@@ -73,7 +73,7 @@ rgb15(u32 red, u32 green, u32 blue ) { | |||
73 | #define COLOR_RED rgb15(31, 0, 12) | 73 | #define COLOR_RED rgb15(31, 0, 12) |
74 | #define COLOR_BLUE rgb15(2, 15, 30) | 74 | #define COLOR_BLUE rgb15(2, 15, 30) |
75 | #define COLOR_CYAN rgb15(0, 30, 30) | 75 | #define COLOR_CYAN rgb15(0, 30, 30) |
76 | #define COLOR_GREY rgb15(10, 10, 10) | 76 | #define COLOR_GREY rgb15(4, 4, 4) |
77 | #define COLOR_BLACK rgb15(0, 0, 0) | 77 | #define COLOR_BLACK rgb15(0, 0, 0) |
78 | #define COLOR_WHITE rgb15(28, 28, 28) | 78 | #define COLOR_WHITE rgb15(28, 28, 28) |
79 | 79 | ||
@@ -307,44 +307,53 @@ u32 profile_stop() { | |||
307 | } | 307 | } |
308 | 308 | ||
309 | int main(void) { | 309 | int main(void) { |
310 | DISP_CONTROL = DISP_MODE_4 | DISP_BG_2; | 310 | DISP_CONTROL = DISP_MODE_3 | DISP_BG_2; |
311 | 311 | ||
312 | PAL_BUFFER[1] = COLOR_RED; | 312 | draw_fill_rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, COLOR_GREY); |
313 | PAL_BUFFER[2] = COLOR_BLUE; | ||
314 | 313 | ||
315 | // Prepare the screen buffers by drawing a rectangle with different colors | 314 | int side = 60; |
316 | // to each page. | 315 | int x = 88; |
317 | draw_fill_rect_m4(0, 0, 20, 20, 1, SCREEN_PAGE_1); | 316 | int y = 70; |
318 | draw_fill_rect_m4(0, 0, 20, 20, 2, SCREEN_PAGE_2); | 317 | int line = 35; |
318 | int height = sqrt(side * side - (side / 2) * (side / 2)); | ||
319 | 319 | ||
320 | // Profile mode 4 vs mode 3 drawing fill_rects. | 320 | // Draw red triangle. |
321 | int n_iterations = 1000; | 321 | draw_line(x + height - 1, y - side / 2, x, y - 1, COLOR_RED); |
322 | profile_start(); | 322 | draw_line(x + height - 1, y + side / 2, x, y + 1, COLOR_RED); |
323 | for (size_t i = 0; i < n_iterations; ++i) { | 323 | draw_line(x + height - 1, y - side / 2 + 1, x, y, COLOR_RED); |
324 | draw_fill_rect_m4(0, 0, 20, 20, 1, SCREEN_PAGE_1); | 324 | draw_line(x + height - 1, y + side / 2 - 1, x, y, COLOR_RED); |
325 | } | ||
326 | u32 mode_4_count = profile_stop(); | ||
327 | 325 | ||
328 | DISP_CONTROL = DISP_MODE_3 | DISP_BG_2; | 326 | // Draw white triangle. |
329 | profile_start(); | 327 | draw_line(x, y - side / 2, x, y + side / 2, COLOR_WHITE); |
330 | for (size_t i = 0; i < n_iterations; ++i) { | 328 | draw_line(x + 1, y - side / 2, x + height, y - 1, COLOR_WHITE); |
331 | draw_fill_rect(0, 0, 20, 20, 1); | 329 | draw_line(x + 1, y + side / 2, x + height, y + 1, COLOR_WHITE); |
332 | } | ||
333 | u32 mode_3_count = profile_stop(); | ||
334 | 330 | ||
335 | char msg[240]; | 331 | // Draw white line at triangle tip. |
336 | sprintf(&msg, "m4: %u", mode_4_count); | 332 | draw_line(x + height, y - side / 2, x + height, y + side / 2, COLOR_WHITE); |
337 | put_text(0, 0, COLOR_RED, msg); | 333 | draw_line(x + height + 1, y - side / 2, x + height + 1, y + side / 2, COLOR_WHITE); |
338 | sprintf(&msg, "m3: %u", mode_3_count); | 334 | draw_line(x + height + 2, y - side / 2, x + height + 2, y + side / 2, COLOR_WHITE); |
339 | put_text(0, 16, COLOR_RED, msg); | 335 | // draw_line(x + height + 3, y - side / 2, x + height + 3, y + side / 2, COLOR_WHITE); |
336 | |||
337 | // Double triangle line. | ||
338 | draw_line(x - 1, y - side / 2, x - 1, y + side / 2, COLOR_WHITE); | ||
339 | draw_line(x + 1, y - side / 2 + 1, x + height, y, COLOR_WHITE); | ||
340 | draw_line(x + 1, y + side / 2 - 1, x + height, y, COLOR_WHITE); | ||
341 | |||
342 | // Draw white lines. | ||
343 | draw_line(x - line, y, x, y, COLOR_WHITE); | ||
344 | draw_line(x + height, y, x + height + line, y, COLOR_WHITE); | ||
345 | draw_line(x - line, y + 1, x, y + 1, COLOR_WHITE); | ||
346 | draw_line(x + height, y + 1, x + height + line, y + 1, COLOR_WHITE); | ||
347 | |||
348 | put_text(77, 125, COLOR_RED, "0xbadd10de"); | ||
340 | 349 | ||
341 | int frame_counter = 0; | 350 | int frame_counter = 0; |
342 | while(true) { | 351 | while(true) { |
343 | wait_vsync(); | 352 | wait_vsync(); |
344 | // if (frame_counter++ > 30) { | 353 | if (frame_counter++ > 30) { |
345 | // frame_counter = 0; | 354 | frame_counter = 0; |
346 | // flip_page(); | 355 | flip_page(); |
347 | // } | 356 | } |
348 | }; | 357 | }; |
349 | 358 | ||
350 | return 0; | 359 | return 0; |