From a4092c4a6b1ad1589552c06b29a72d868ef778f1 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sun, 23 Apr 2023 17:16:39 +0200 Subject: Fix small font rendering and sprite drawing --- src/assets.c | 8 +- src/drawing.c | 258 +++++++++++++++++++++++++++--------------------------- src/main.c | 3 +- src/renderer.c | 73 --------------- src/renderer_m0.c | 19 ++++ 5 files changed, 153 insertions(+), 208 deletions(-) diff --git a/src/assets.c b/src/assets.c index 74d27d2..64a2265 100644 --- a/src/assets.c +++ b/src/assets.c @@ -104,10 +104,10 @@ u32 ch_btn_sprite[] = { }; static const u32 default_wave_buttons[] = { - 0xff013149, 0x850101ff, 0x3f202028, 0x2423203f, - 0xff016151, 0x49c501ff, 0x3f202c2a, 0x2928203f, - 0xff017d45, 0x45c501ff, 0x3f202828, 0x282f203f, - 0xff014911, 0x812501ff, 0x3f202128, 0x2420203f, + 0x493101ff, 0xff010185, 0x2820203f, 0x3f202324, + 0x516101ff, 0xff01c549, 0x2a2c203f, 0x3f202829, + 0x457d01ff, 0xff01c545, 0x2828203f, 0x3f202f28, + 0x114901ff, 0xff012581, 0x2821203f, 0x3f202024, }; // diff --git a/src/drawing.c b/src/drawing.c index 4f08e39..b790595 100644 --- a/src/drawing.c +++ b/src/drawing.c @@ -157,7 +157,7 @@ void draw_bank_buttons() { size_t x = BANK_START_X; size_t y = BANK_START_Y; - // txt_drawf_small("BANK", x - 2, y - 10, 4, COL_FG); + txt_drawf_small("BANK", x - 2, y - 10, COL_FG); char bank_names[] = { 'A', 'B', 'C', 'D', }; @@ -168,7 +168,7 @@ draw_bank_buttons() { } draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG); draw_rect(x, y, x + PAT_W, y + PAT_H, color); - // txt_drawc(bank_names[i], x + 4, y + 2, 6, color); + txt_drawc(bank_names[i], x + 4, y + 2, color); y += PAT_OFFSET_Y; } } @@ -177,7 +177,7 @@ void draw_pattern_buttons() { size_t x = PAT_START_X; size_t y = PAT_START_Y; - // txt_drawf_small("PAT", x, y - 10, 4, COL_FG); + txt_drawf_small("PAT", x, y - 10, COL_FG); char pat_names[] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', @@ -192,7 +192,7 @@ draw_pattern_buttons() { } draw_filled_rect(x, y, x + PAT_W, y + PAT_H, COL_BG); draw_rect(x, y, x + PAT_W, y + PAT_H, color); - // txt_drawc(pat_names[i], x + 4, y + 2, 6, color); + txt_drawc(pat_names[i], x + 4, y + 2, color); y += PAT_OFFSET_Y; } } @@ -244,14 +244,14 @@ draw_bpm() { draw_filled_rect(x, y, x + R_COL_W, y + BPM_H, COL_BG); draw_rect(x, y, x + R_COL_W, y + BPM_H, COL_FG); draw_line(x + 5, y, x + 19, y, COL_BG); - // txt_drawf_small("BPM", x + 5, y - 4, 4, COL_FG); + txt_drawf_small("BPM", x + 5, y - 4, COL_FG); // Make sure its horizontally centered if only 2 digits int bpm = patterns[pattern_selection_loc].bpm; if (bpm >= 100) { - txt_drawf("%d", x + 3, y + 7, 6, COL_FG, bpm); + txt_drawf("%d", x + 3, y + 7, COL_FG, bpm); } else { - txt_drawf("%d", x + 6, y + 7, 6, COL_FG, bpm); + txt_drawf("%d", x + 6, y + 7, COL_FG, bpm); } } @@ -568,38 +568,38 @@ draw_parameters_wave(void) { // Wave text. x -= 2; - // txt_drawf_small("%02x%02x%02x%02x", x, y + 20, 4, COL_FG, - // wave_a[0], wave_a[1], wave_a[2], wave_a[3]); - // txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 20, 4, COL_FG, - // wave_a[4], wave_a[5], wave_a[6], wave_a[7]); - // txt_drawf_small("%02x%02x%02x%02x", x, y + 28, 4, COL_FG, - // wave_a[8], wave_a[9], wave_a[10], wave_a[11]); - // txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 28, 4, COL_FG, - // wave_a[12], wave_a[13], wave_a[14], wave_a[15]); + txt_drawf_small("%02x%02x%02x%02x", x, y + 20, COL_FG, + wave_a[0], wave_a[1], wave_a[2], wave_a[3]); + txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 20, COL_FG, + wave_a[4], wave_a[5], wave_a[6], wave_a[7]); + txt_drawf_small("%02x%02x%02x%02x", x, y + 28, COL_FG, + wave_a[8], wave_a[9], wave_a[10], wave_a[11]); + txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 28, COL_FG, + wave_a[12], wave_a[13], wave_a[14], wave_a[15]); x += 70; - // txt_drawf_small("%02x%02x%02x%02x", x, y + 20, 4, COL_FG, - // wave_b[0], wave_b[1], wave_b[2], wave_b[3]); - // txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 20, 4, COL_FG, - // wave_b[4], wave_b[5], wave_b[6], wave_b[7]); - // txt_drawf_small("%02x%02x%02x%02x", x, y + 28, 4, COL_FG, - // wave_b[8], wave_b[9], wave_b[10], wave_b[11]); - // txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 28, 4, COL_FG, - // wave_b[12], wave_b[13], wave_b[14], wave_b[15]); + txt_drawf_small("%02x%02x%02x%02x", x, y + 20, COL_FG, + wave_b[0], wave_b[1], wave_b[2], wave_b[3]); + txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 20, COL_FG, + wave_b[4], wave_b[5], wave_b[6], wave_b[7]); + txt_drawf_small("%02x%02x%02x%02x", x, y + 28, COL_FG, + wave_b[8], wave_b[9], wave_b[10], wave_b[11]); + txt_drawf_small("%02x%02x%02x%02x", x + 34, y + 28, COL_FG, + wave_b[12], wave_b[13], wave_b[14], wave_b[15]); } // Draw default wave buttons. { - // Tile *wave_tiles = ASSETS_DEFAULT_WAVES; + u32 *tile = default_wave_buttons; size_t x = PARAMS_START_X; size_t y = PARAMS_START_Y + PARAMS_H - 12; for (size_t i = 0, k = 0; i < 4 * 2; i += 2, k++) { - // draw_tile(x + 17 * k, y, wave_tiles + i, COL_FG, true); - // draw_tile(x + 17 * k + 8, y, wave_tiles + i + 1, COL_FG, true); + draw_icn(x + 17 * k , y, &tile[i * 2 + 0], COL_FG, 1, 0); + draw_icn(x + 17 * k + 8, y, &tile[i * 2 + 2], COL_FG, 1, 0); } for (size_t i = 0, k = 0; i < 4 * 2; i += 2, k++) { - // draw_tile(x + 17 * k + 70, y, wave_tiles + i, COL_FG, true); - // draw_tile(x + 17 * k + 8 + 70, y, wave_tiles + i + 1, COL_FG, true); + draw_icn(x + 70 + 17 * k , y, &tile[i * 2 + 0], COL_FG, 1, 0); + draw_icn(x + 70 + 17 * k + 8, y, &tile[i * 2 + 2], COL_FG, 1, 0); } } @@ -612,17 +612,17 @@ draw_parameters_wave(void) { draw_line(x, y + 5, x, y + 16, COL_FG); draw_line(x + 30, y + 5, x + 30, y + 17, COL_FG); draw_line(x, y + 17, x + 30, y + 17, COL_FG); - // txt_drawf_small("mode", x + 6, y, 4, COL_FG); + txt_drawf_small("mode", x + 6, y, COL_FG); switch (pat->ch3.params[trig_selection_loc].wave_mode) { case 0: { - txt_drawf("A", x + 12, y + 7, 6, COL_FG); + txt_drawf("A", x + 12, y + 7, COL_FG); } break; case 1: { - txt_drawf("B", x + 12, y + 7, 6, COL_FG); + txt_drawf("B", x + 12, y + 7, COL_FG); } break; case 2: { - txt_drawf("A+B", x + 6, y + 7, 6, COL_FG); + txt_drawf("A+B", x + 6, y + 7, COL_FG); } break; } } @@ -636,23 +636,23 @@ draw_parameters_wave(void) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 30, y + 8, x + 30, y + 19, COL_FG); draw_line(x, y + 20, x + 30, y + 20, COL_FG); - // txt_drawf_small("vol", x + 8, y + 3, 4, COL_FG); + txt_drawf_small("vol", x + 8, y + 3, COL_FG); switch (pat->ch3.params[trig_selection_loc].wave_volume) { case 0: { - txt_drawf("0", x + 12, y + 10, 6, COL_FG); + txt_drawf("0", x + 12, y + 10, COL_FG); } break; case 1: { - txt_drawf("25", x + 9, y + 10, 6, COL_FG); + txt_drawf("25", x + 9, y + 10, COL_FG); } break; case 2: { - txt_drawf("50", x + 9, y + 10, 6, COL_FG); + txt_drawf("50", x + 9, y + 10, COL_FG); } break; case 3: { - txt_drawf("75", x + 9, y + 10, 6, COL_FG); + txt_drawf("75", x + 9, y + 10, COL_FG); } break; case 4: { - txt_drawf("100", x + 6, y + 10, 6, COL_FG); + txt_drawf("100", x + 6, y + 10, COL_FG); } break; } } @@ -731,20 +731,20 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("duty", x + 3, y + 3, 4, COL_FG); + txt_drawf_small("duty", x + 3, y + 3, COL_FG); switch (params->duty_cycle) { case 0: { - txt_drawf("12", x + 6, y + 10, 6, COL_FG); + txt_drawf("12", x + 6, y + 10, COL_FG); } break; case 1: { - txt_drawf("25", x + 6, y + 10, 6, COL_FG); + txt_drawf("25", x + 6, y + 10, COL_FG); } break; case 2: { - txt_drawf("50", x + 6, y + 10, 6, COL_FG); + txt_drawf("50", x + 6, y + 10, COL_FG); } break; case 3: { - txt_drawf("75", x + 6, y + 10, 6, COL_FG); + txt_drawf("75", x + 6, y + 10, COL_FG); } break; } } @@ -790,56 +790,56 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("vol", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("vol", x + 5, y + 3, COL_FG); switch (params->env_volume) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("6", x + 9, y + 10, 6, COL_FG); + txt_drawf("6", x + 9, y + 10, COL_FG); } break; case 2: { - txt_drawf("13", x + 6, y + 10, 6, COL_FG); + txt_drawf("13", x + 6, y + 10, COL_FG); } break; case 3: { - txt_drawf("20", x + 6, y + 10, 6, COL_FG); + txt_drawf("20", x + 6, y + 10, COL_FG); } break; case 4: { - txt_drawf("26", x + 6, y + 10, 6, COL_FG); + txt_drawf("26", x + 6, y + 10, COL_FG); } break; case 5: { - txt_drawf("33", x + 6, y + 10, 6, COL_FG); + txt_drawf("33", x + 6, y + 10, COL_FG); } break; case 6: { - txt_drawf("40", x + 6, y + 10, 6, COL_FG); + txt_drawf("40", x + 6, y + 10, COL_FG); } break; case 7: { - txt_drawf("46", x + 6, y + 10, 6, COL_FG); + txt_drawf("46", x + 6, y + 10, COL_FG); } break; case 8: { - txt_drawf("53", x + 6, y + 10, 6, COL_FG); + txt_drawf("53", x + 6, y + 10, COL_FG); } break; case 9: { - txt_drawf("60", x + 6, y + 10, 6, COL_FG); + txt_drawf("60", x + 6, y + 10, COL_FG); } break; case 10: { - txt_drawf("66", x + 6, y + 10, 6, COL_FG); + txt_drawf("66", x + 6, y + 10, COL_FG); } break; case 11: { - txt_drawf("73", x + 6, y + 10, 6, COL_FG); + txt_drawf("73", x + 6, y + 10, COL_FG); } break; case 12: { - txt_drawf("80", x + 6, y + 10, 6, COL_FG); + txt_drawf("80", x + 6, y + 10, COL_FG); } break; case 13: { - txt_drawf("86", x + 6, y + 10, 6, COL_FG); + txt_drawf("86", x + 6, y + 10, COL_FG); } break; case 14: { - txt_drawf("93", x + 6, y + 10, 6, COL_FG); + txt_drawf("93", x + 6, y + 10, COL_FG); } break; case 15: { - txt_drawf("100", x + 3, y + 10, 6, COL_FG); + txt_drawf("100", x + 3, y + 10, COL_FG); } break; } } @@ -853,16 +853,16 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("dir", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("dir", x + 5, y + 3, COL_FG); char arr_up[2] = { 0x19, 0 }; char arr_down[2] = { 0x18, 0 }; switch (params->env_direction) { case 0: { - txt_drawf(arr_up, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_up, x + 9, y + 11, COL_FG); } break; case 1: { - txt_drawf(arr_down, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_down, x + 9, y + 11, COL_FG); } break; } } @@ -876,32 +876,32 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("time", x + 3, y + 3, 4, COL_FG); + txt_drawf_small("time", x + 3, y + 3, COL_FG); switch (params->env_time) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("14", x + 6, y + 10, 6, COL_FG); + txt_drawf("14", x + 6, y + 10, COL_FG); } break; case 2: { - txt_drawf("28", x + 6, y + 10, 6, COL_FG); + txt_drawf("28", x + 6, y + 10, COL_FG); } break; case 3: { - txt_drawf("42", x + 6, y + 10, 6, COL_FG); + txt_drawf("42", x + 6, y + 10, COL_FG); } break; case 4: { - txt_drawf("57", x + 6, y + 10, 6, COL_FG); + txt_drawf("57", x + 6, y + 10, COL_FG); } break; case 5: { - txt_drawf("71", x + 6, y + 10, 6, COL_FG); + txt_drawf("71", x + 6, y + 10, COL_FG); } break; case 6: { - txt_drawf("85", x + 6, y + 10, 6, COL_FG); + txt_drawf("85", x + 6, y + 10, COL_FG); } break; case 7: { - txt_drawf("100", x + 3, y + 10, 6, COL_FG); + txt_drawf("100", x + 3, y + 10, COL_FG); } break; } } @@ -916,32 +916,32 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("num", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("num", x + 5, y + 3, COL_FG); switch (params->sweep_number) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("1", x + 9, y + 10, 6, COL_FG); + txt_drawf("1", x + 9, y + 10, COL_FG); } break; case 2: { - txt_drawf("2", x + 9, y + 10, 6, COL_FG); + txt_drawf("2", x + 9, y + 10, COL_FG); } break; case 3: { - txt_drawf("3", x + 9, y + 10, 6, COL_FG); + txt_drawf("3", x + 9, y + 10, COL_FG); } break; case 4: { - txt_drawf("4", x + 9, y + 10, 6, COL_FG); + txt_drawf("4", x + 9, y + 10, COL_FG); } break; case 5: { - txt_drawf("5", x + 9, y + 10, 6, COL_FG); + txt_drawf("5", x + 9, y + 10, COL_FG); } break; case 6: { - txt_drawf("6", x + 9, y + 10, 6, COL_FG); + txt_drawf("6", x + 9, y + 10, COL_FG); } break; case 7: { - txt_drawf("7", x + 9, y + 10, 6, COL_FG); + txt_drawf("7", x + 9, y + 10, COL_FG); } break; } } @@ -955,32 +955,32 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("time", x + 3, y + 3, 4, COL_FG); + txt_drawf_small("time", x + 3, y + 3, COL_FG); switch (params->sweep_time) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("1", x + 9, y + 10, 6, COL_FG); + txt_drawf("1", x + 9, y + 10, COL_FG); } break; case 2: { - txt_drawf("2", x + 9, y + 10, 6, COL_FG); + txt_drawf("2", x + 9, y + 10, COL_FG); } break; case 3: { - txt_drawf("3", x + 9, y + 10, 6, COL_FG); + txt_drawf("3", x + 9, y + 10, COL_FG); } break; case 4: { - txt_drawf("4", x + 9, y + 10, 6, COL_FG); + txt_drawf("4", x + 9, y + 10, COL_FG); } break; case 5: { - txt_drawf("5", x + 9, y + 10, 6, COL_FG); + txt_drawf("5", x + 9, y + 10, COL_FG); } break; case 6: { - txt_drawf("6", x + 9, y + 10, 6, COL_FG); + txt_drawf("6", x + 9, y + 10, COL_FG); } break; case 7: { - txt_drawf("7", x + 9, y + 10, 6, COL_FG); + txt_drawf("7", x + 9, y + 10, COL_FG); } break; } } @@ -994,16 +994,16 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("dir", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("dir", x + 5, y + 3, COL_FG); char arr_up[2] = { 0x19, 0 }; char arr_down[2] = { 0x18, 0 }; switch (params->sweep_direction) { case 0: { - txt_drawf(arr_up, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_up, x + 9, y + 11, COL_FG); } break; case 1: { - txt_drawf(arr_down, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_down, x + 9, y + 11, COL_FG); } break; } } @@ -1012,10 +1012,10 @@ draw_parameters_square(ChannelSquareParams *params, bool sweep) { { size_t x = PARAMS_START_X + x_offset; size_t y = PARAMS_START_Y + PARAMS_H - 45; - // txt_drawf_small("shape", x + 1, y - 12, 4, COL_FG); - // txt_drawf_small("envelope", x + 54, y - 12, 4, COL_FG); + txt_drawf_small("shape", x + 1, y - 12, COL_FG); + txt_drawf_small("envelope", x + 54, y - 12, COL_FG); if (sweep) { - // txt_drawf_small("sweep", x + 133, y - 12, 4, COL_FG); + txt_drawf_small("sweep", x + 133, y - 12, COL_FG); } } } @@ -1037,14 +1037,14 @@ draw_parameters_noise(void) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("mode", x + 3, y + 3, 4, COL_FG); + txt_drawf_small("mode", x + 3, y + 3, COL_FG); switch (params->bit_mode) { case 0: { - txt_drawf("A", x + 9, y + 10, 6, COL_FG); + txt_drawf("A", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("B", x + 9, y + 10, 6, COL_FG); + txt_drawf("B", x + 9, y + 10, COL_FG); } break; } } @@ -1090,56 +1090,56 @@ draw_parameters_noise(void) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("vol", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("vol", x + 5, y + 3, COL_FG); switch (params->env_volume) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("6", x + 9, y + 10, 6, COL_FG); + txt_drawf("6", x + 9, y + 10, COL_FG); } break; case 2: { - txt_drawf("13", x + 6, y + 10, 6, COL_FG); + txt_drawf("13", x + 6, y + 10, COL_FG); } break; case 3: { - txt_drawf("20", x + 6, y + 10, 6, COL_FG); + txt_drawf("20", x + 6, y + 10, COL_FG); } break; case 4: { - txt_drawf("26", x + 6, y + 10, 6, COL_FG); + txt_drawf("26", x + 6, y + 10, COL_FG); } break; case 5: { - txt_drawf("33", x + 6, y + 10, 6, COL_FG); + txt_drawf("33", x + 6, y + 10, COL_FG); } break; case 6: { - txt_drawf("40", x + 6, y + 10, 6, COL_FG); + txt_drawf("40", x + 6, y + 10, COL_FG); } break; case 7: { - txt_drawf("46", x + 6, y + 10, 6, COL_FG); + txt_drawf("46", x + 6, y + 10, COL_FG); } break; case 8: { - txt_drawf("53", x + 6, y + 10, 6, COL_FG); + txt_drawf("53", x + 6, y + 10, COL_FG); } break; case 9: { - txt_drawf("60", x + 6, y + 10, 6, COL_FG); + txt_drawf("60", x + 6, y + 10, COL_FG); } break; case 10: { - txt_drawf("66", x + 6, y + 10, 6, COL_FG); + txt_drawf("66", x + 6, y + 10, COL_FG); } break; case 11: { - txt_drawf("73", x + 6, y + 10, 6, COL_FG); + txt_drawf("73", x + 6, y + 10, COL_FG); } break; case 12: { - txt_drawf("80", x + 6, y + 10, 6, COL_FG); + txt_drawf("80", x + 6, y + 10, COL_FG); } break; case 13: { - txt_drawf("86", x + 6, y + 10, 6, COL_FG); + txt_drawf("86", x + 6, y + 10, COL_FG); } break; case 14: { - txt_drawf("93", x + 6, y + 10, 6, COL_FG); + txt_drawf("93", x + 6, y + 10, COL_FG); } break; case 15: { - txt_drawf("100", x + 3, y + 10, 6, COL_FG); + txt_drawf("100", x + 3, y + 10, COL_FG); } break; } } @@ -1153,16 +1153,16 @@ draw_parameters_noise(void) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("dir", x + 5, y + 3, 4, COL_FG); + txt_drawf_small("dir", x + 5, y + 3, COL_FG); char arr_up[2] = { 0x19, 0 }; char arr_down[2] = { 0x18, 0 }; switch (params->env_direction) { case 0: { - txt_drawf(arr_up, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_up, x + 9, y + 11, COL_FG); } break; case 1: { - txt_drawf(arr_down, x + 9, y + 11, 6, COL_FG); + txt_drawf(arr_down, x + 9, y + 11, COL_FG); } break; } } @@ -1176,32 +1176,32 @@ draw_parameters_noise(void) { draw_line(x, y + 8, x, y + 19, COL_FG); draw_line(x + 24, y + 8, x + 24, y + 19, COL_FG); draw_line(x, y + 20, x + 24, y + 20, COL_FG); - // txt_drawf_small("time", x + 3, y + 3, 4, COL_FG); + txt_drawf_small("time", x + 3, y + 3, COL_FG); switch (params->env_time) { case 0: { - txt_drawf("0", x + 9, y + 10, 6, COL_FG); + txt_drawf("0", x + 9, y + 10, COL_FG); } break; case 1: { - txt_drawf("14", x + 6, y + 10, 6, COL_FG); + txt_drawf("14", x + 6, y + 10, COL_FG); } break; case 2: { - txt_drawf("28", x + 6, y + 10, 6, COL_FG); + txt_drawf("28", x + 6, y + 10, COL_FG); } break; case 3: { - txt_drawf("42", x + 6, y + 10, 6, COL_FG); + txt_drawf("42", x + 6, y + 10, COL_FG); } break; case 4: { - txt_drawf("57", x + 6, y + 10, 6, COL_FG); + txt_drawf("57", x + 6, y + 10, COL_FG); } break; case 5: { - txt_drawf("71", x + 6, y + 10, 6, COL_FG); + txt_drawf("71", x + 6, y + 10, COL_FG); } break; case 6: { - txt_drawf("85", x + 6, y + 10, 6, COL_FG); + txt_drawf("85", x + 6, y + 10, COL_FG); } break; case 7: { - txt_drawf("100", x + 3, y + 10, 6, COL_FG); + txt_drawf("100", x + 3, y + 10, COL_FG); } break; } } @@ -1211,7 +1211,7 @@ draw_parameters_noise(void) { { size_t x = PARAMS_START_X + x_offset; size_t y = PARAMS_START_Y + PARAMS_H - 45; - // txt_drawf_small("envelope", x + 54, y - 12, 4, COL_FG); + txt_drawf_small("envelope", x + 54, y - 12, COL_FG); } } diff --git a/src/main.c b/src/main.c index 89d0444..8ee4945 100644 --- a/src/main.c +++ b/src/main.c @@ -21,8 +21,7 @@ WITH REGARD TO THIS SOFTWARE. void render(void) { - // TODO: Fix small font rendering. - // TODO: Draw remaining sprites. + // TODO: Make sure we are drawing the proper cursor color. // TODO: Decouple update from rendering. PROF(screen_fill(0), clear_cycles); PROF(draw_rect(0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1, 1), clear_cycles); diff --git a/src/renderer.c b/src/renderer.c index 07d79d6..65dfd2b 100644 --- a/src/renderer.c +++ b/src/renderer.c @@ -260,79 +260,6 @@ draw_filled_rect(size_t x0, size_t y0, size_t x1, size_t y1, u8 clr) { } } -IWRAM_CODE -void -draw_tile(size_t x, size_t y, Tile *tile, u8 clr, bool merge) { - BOUNDCHECK_SCREEN(x, y); - - // Find row position for the given x/y coordinates. - size_t tile_x = x / 8; - size_t tile_y = y / 8; - size_t start_col = x % 8; - size_t start_row = y % 8; - - // Get a pointer to the backbuffer and the tile row. - size_t pos = start_row + (tile_x + tile_y * 32) * 8; - u32 *backbuffer = &BACKBUF[pos]; - u32 *row = tile; - - // This will blend all colors weirdly if using tiles that contain colors - // higher than 1. - size_t shift_left = start_col * 4; - size_t shift_right = (8 - start_col) * 4; - u32 row_mask_left = merge ? 0 : 0xFFFFFFFF << shift_left; - u32 row_mask_right = merge ? 0 : 0xFFFFFFFF >> shift_right; - - // Draw the tiles. There are 4 possible cases: - // 1. The tile is exactly at the tile boundary. - // 2. The tile spans 2 tiles horizontally. - // 3. The tile spans 2 tiles vertically. - // 4. The tile spans 4 tiles. - if (start_col == 0 && start_row == 0) { - for (size_t i = 0; i < (8 - start_row); i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | row[i] * clr; - } - dirty_tiles[tile_y] |= 1 << tile_x; - } else if (start_row == 0) { - for (size_t i = 0; i < 8; i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | (row[i] * clr << shift_left); - backbuffer[8] = (backbuffer[8] & ~row_mask_right) | (row[i] * clr >> shift_right); - } - dirty_tiles[tile_y] |= 1 << tile_x; - dirty_tiles[tile_y] |= 1 << (tile_x + 1); - } else if (start_col == 0) { - for (size_t i = 0; i < (8 - start_row); i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | row[i] * clr; - } - backbuffer += 8 * 31; - for (size_t i = (8 - start_row); i < 8; i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | row[i] * clr; - } - dirty_tiles[tile_y] |= 1 << tile_x; - dirty_tiles[tile_y + 1] |= 1 << tile_x; - } else { - for (size_t i = 0; i < (8 - start_row); i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | (row[i] * clr << shift_left); - backbuffer[8] = (backbuffer[8] & ~row_mask_right) | (row[i] * clr >> shift_right); - } - backbuffer += 8 * 31; - for (size_t i = (8 - start_row); i < 8; i++, backbuffer++) { - BOUNDCHECK_SCREEN(x, y + i); - backbuffer[0] = (backbuffer[0] & ~row_mask_left) | (row[i] * clr << shift_left); - backbuffer[8] = (backbuffer[8] & ~row_mask_right) | (row[i] * clr >> shift_right); - } - dirty_tiles[tile_y] |= 1 << tile_x; - dirty_tiles[tile_y] |= 1 << (tile_x + 1); - dirty_tiles[tile_y + 1] |= 1 << tile_x; - dirty_tiles[tile_y + 1] |= 1 << (tile_x + 1); - } -} - void clear_screen(void) { dma_fill(FRONTBUF, 0, KB(20), 3); diff --git a/src/renderer_m0.c b/src/renderer_m0.c index 00874ea..bf15f56 100644 --- a/src/renderer_m0.c +++ b/src/renderer_m0.c @@ -837,6 +837,25 @@ txt_drawc(char c, size_t x, size_t y, u8 clr) { draw_icn(x, y, tile + 8 * c, clr, 1, 0); } +void +txt_drawc_small(char c, size_t x, size_t y, u8 clr) { + u8 *tile = font_icn; + c = c < 'a' ? c + 16 * 6 : c + 16 * 4; + draw_icn(x, y, tile + 8 * c, clr, 1, 0); +} + +#define txt_drawf_small(msg, x, y, clr, ...) \ + { \ + char buf[256] = {0}; \ + posprintf(buf, msg, ##__VA_ARGS__); \ + u8 tmp = text_engine.spacing;\ + txt_spacing(4);\ + text_engine.drawc = txt_drawc_small;\ + txt_draws(buf, x, y, clr); \ + txt_spacing(tmp);\ + text_engine.drawc = txt_drawc;\ + } + // // Initialization. // -- cgit v1.2.1