diff options
author | Bad Diode <bd@badd10de.dev> | 2023-08-31 12:58:08 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-08-31 12:58:08 +0200 |
commit | cfc60ba401b9ca46c981f902512eb1f2cc07995f (patch) | |
tree | 19423692345c9def52c47e52f7ed42ee4d9f67da /src | |
parent | e7c567fcb695722b9e88866bf4216ff425daac9a (diff) | |
download | uxngba-cfc60ba401b9ca46c981f902512eb1f2cc07995f.tar.gz uxngba-cfc60ba401b9ca46c981f902512eb1f2cc07995f.zip |
Make sure keyboard is consistently colored
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 2 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/ppu.c | 11 | ||||
-rw-r--r-- | src/profiling.c | 24 |
4 files changed, 31 insertions, 10 deletions
diff --git a/src/config.c b/src/config.c index 9879ef1..278cf66 100644 --- a/src/config.c +++ b/src/config.c | |||
@@ -9,5 +9,5 @@ | |||
9 | #endif | 9 | #endif |
10 | 10 | ||
11 | #define PROF_ENABLE 0 | 11 | #define PROF_ENABLE 0 |
12 | #define TEXT_DISABLE 0 | 12 | #define TEXT_DISABLE 1 |
13 | #define SOUND_DISABLE 0 | 13 | #define SOUND_DISABLE 0 |
@@ -88,7 +88,7 @@ main(void) { | |||
88 | video_init(); | 88 | video_init(); |
89 | 89 | ||
90 | // Initialize text engine. | 90 | // Initialize text engine. |
91 | #if !defined(TEXT_DISABLE) || TEXT_DISABLE == 0 | 91 | #if !defined(TEXT_DISABLE) || TEXT_DISABLE == 0 || PROF_ENABLE > 0 |
92 | txt_init(1, TEXT_LAYER); | 92 | txt_init(1, TEXT_LAYER); |
93 | txt_position(0,0); | 93 | txt_position(0,0); |
94 | #endif | 94 | #endif |
@@ -109,7 +109,9 @@ main(void) { | |||
109 | FRAME_START(); | 109 | FRAME_START(); |
110 | PROF(handle_input(), input_cycles); | 110 | PROF(handle_input(), input_cycles); |
111 | PROF(uxn_eval_asm(PEEK2(&device_data[0x20])), eval_cycles); | 111 | PROF(uxn_eval_asm(PEEK2(&device_data[0x20])), eval_cycles); |
112 | #if !defined(SOUND_DISABLE) || SOUND_DISABLE == 0 | ||
112 | PROF(sound_mix(), mix_cycles); | 113 | PROF(sound_mix(), mix_cycles); |
114 | #endif | ||
113 | // TODO: allow configuration to do VSYNC at 15 or 30 fps to avoid too | 115 | // TODO: allow configuration to do VSYNC at 15 or 30 fps to avoid too |
114 | // much memory copying on demanding uxn roms. | 116 | // much memory copying on demanding uxn roms. |
115 | PROF_SHOW(); | 117 | PROF_SHOW(); |
@@ -225,9 +225,6 @@ putcolors(u8 *addr) { | |||
225 | (g << 1) | (g >> 3), | 225 | (g << 1) | (g >> 3), |
226 | (b << 1) | (b >> 3)); | 226 | (b << 1) | (b >> 3)); |
227 | PAL_BUFFER_BG[i] = color; | 227 | PAL_BUFFER_BG[i] = color; |
228 | for (size_t j = 0; j < 16; ++j) { | ||
229 | PAL_BUFFER_SPRITES[i * 16 + j] = color; | ||
230 | } | ||
231 | } | 228 | } |
232 | } | 229 | } |
233 | 230 | ||
@@ -824,9 +821,9 @@ video_init() { | |||
824 | PAL_BUFFER_BG[3] = COLOR_BLUE; | 821 | PAL_BUFFER_BG[3] = COLOR_BLUE; |
825 | for (size_t i = 0; i < 16; ++i) { | 822 | for (size_t i = 0; i < 16; ++i) { |
826 | PAL_BUFFER_SPRITES[i] = COLOR_BLACK; | 823 | PAL_BUFFER_SPRITES[i] = COLOR_BLACK; |
827 | PAL_BUFFER_SPRITES[1 * 16] = COLOR_WHITE; | 824 | PAL_BUFFER_SPRITES[i + 1 * 16] = COLOR_WHITE; |
828 | PAL_BUFFER_SPRITES[2 * 16] = COLOR_RED; | 825 | PAL_BUFFER_SPRITES[i + 2 * 16] = COLOR_RED; |
829 | PAL_BUFFER_SPRITES[3 * 16] = COLOR_BLUE; | 826 | PAL_BUFFER_SPRITES[i + 3 * 16] = COLOR_BLUE; |
830 | } | 827 | } |
831 | 828 | ||
832 | // Initialize background memory map. | 829 | // Initialize background memory map. |
@@ -849,7 +846,7 @@ video_init() { | |||
849 | keyboard[i].y = tile_y * 8; | 846 | keyboard[i].y = tile_y * 8; |
850 | OBJ_ATTR_0(i) = OBJ_SHAPE_SQUARE | OBJ_Y_COORD(keyboard[i].y) | OBJ_HIDDEN; | 847 | OBJ_ATTR_0(i) = OBJ_SHAPE_SQUARE | OBJ_Y_COORD(keyboard[i].y) | OBJ_HIDDEN; |
851 | OBJ_ATTR_1(i) = OBJ_SIZE_SMALL | OBJ_X_COORD(keyboard[i].x); | 848 | OBJ_ATTR_1(i) = OBJ_SIZE_SMALL | OBJ_X_COORD(keyboard[i].x); |
852 | OBJ_ATTR_2(i) = (SPRITE_START_IDX + keyboard[i].symbol) | OBJ_PAL_BANK(0); | 849 | OBJ_ATTR_2(i) = (SPRITE_START_IDX + keyboard[i].symbol) | OBJ_PAL_BANK(2); |
853 | tile_x++; | 850 | tile_x++; |
854 | if (tile_x - KEYBOARD_START_TILE_X >= KEYBOARD_ROW_SIZE) { | 851 | if (tile_x - KEYBOARD_START_TILE_X >= KEYBOARD_ROW_SIZE) { |
855 | tile_x = KEYBOARD_START_TILE_X; | 852 | tile_x = KEYBOARD_START_TILE_X; |
diff --git a/src/profiling.c b/src/profiling.c index 9817eb1..2d230df 100644 --- a/src/profiling.c +++ b/src/profiling.c | |||
@@ -39,7 +39,29 @@ | |||
39 | #define PROF_SHOW() \ | 39 | #define PROF_SHOW() \ |
40 | do { \ | 40 | do { \ |
41 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ | 41 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ |
42 | txt_printf("N CYCLES: %.8lu\n", eval_cycles);\ | 42 | txt_printf("INPUT %.8lu\n", avg_input_cycles);\ |
43 | txt_printf("EVAL %.8lu\n", avg_eval_cycles);\ | ||
44 | txt_printf("VIDEO\n");\ | ||
45 | txt_printf(">PIX %.8lu\n", avg_ppu_pixel_cycles);\ | ||
46 | txt_printf(">FILL %.8lu\n", avg_ppu_fill_cycles);\ | ||
47 | txt_printf(">1BPP %.8lu\n", avg_ppu_icn_cycles);\ | ||
48 | txt_printf(">2BPP %.8lu\n", avg_ppu_chr_cycles);\ | ||
49 | txt_printf(">FLIP %.8lu\n", avg_flip_cycles);\ | ||
50 | txt_printf("AUDIO %.8lu\n", avg_mix_cycles);\ | ||
51 | txt_printf("TOTAL %.8lu\n", avg_frame_cycles);\ | ||
52 | u32 frame_time =\ | ||
53 | FP_DIV(\ | ||
54 | FP_NUM(avg_frame_cycles + 1, 2),\ | ||
55 | FP_NUM(2809, 2),\ | ||
56 | 2) * 166;\ | ||
57 | u32 fps =\ | ||
58 | FP_DIV(\ | ||
59 | FP_NUM(280896 * 60, 2),\ | ||
60 | FP_NUM(avg_frame_cycles + 1, 2),\ | ||
61 | 2);\ | ||
62 | txt_printf("TIME %.8lu\n", frame_time >> 2);\ | ||
63 | txt_printf("FPS %.8lu\n", (fps >> 2) + 1);\ | ||
64 | screen_fill(BG_BACK, 0, 0, 8 * 16, 8 * 12, 2);\ | ||
43 | } while (0) | 65 | } while (0) |
44 | 66 | ||
45 | static u32 prof_frame_counter = 0; | 67 | static u32 prof_frame_counter = 0; |