diff options
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 41 |
1 files changed, 29 insertions, 12 deletions
@@ -37,6 +37,8 @@ | |||
37 | #define CONTROL_METHODS CONTROL_CONTROLLER,CONTROL_MOUSE,CONTROL_KEYBOARD | 37 | #define CONTROL_METHODS CONTROL_CONTROLLER,CONTROL_MOUSE,CONTROL_KEYBOARD |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #define PROF_ENABLE 1 | ||
41 | |||
40 | #ifdef PROF_ENABLE | 42 | #ifdef PROF_ENABLE |
41 | #if PROF_ENABLE == 0 | 43 | #if PROF_ENABLE == 0 |
42 | #define TEXT_ENABLE 1 | 44 | #define TEXT_ENABLE 1 |
@@ -51,22 +53,38 @@ | |||
51 | #ifndef PROF_SHOW_Y | 53 | #ifndef PROF_SHOW_Y |
52 | #define PROF_SHOW_Y 0 | 54 | #define PROF_SHOW_Y 0 |
53 | #endif | 55 | #endif |
56 | // #define PROF_SHOW() \ | ||
57 | // do { \ | ||
58 | // txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ | ||
59 | // txt_printf("INPUT: %lu ", input_cycles);\ | ||
60 | // txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ | ||
61 | // txt_printf("EVAL: %lu ", eval_cycles);\ | ||
62 | // txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ | ||
63 | // txt_printf("FLIP: %lu ", flip_cycles);\ | ||
64 | // txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ | ||
65 | // txt_printf("MIX: %lu ", mix_cycles);\ | ||
66 | // } while (0) | ||
54 | #define PROF_SHOW() \ | 67 | #define PROF_SHOW() \ |
55 | do { \ | 68 | do { \ |
56 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ | 69 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ |
57 | txt_printf("INPUT: %lu ", input_cycles);\ | 70 | txt_printf("PIX: %lu ", ppu_pixel_cycles);\ |
58 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ | 71 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ |
59 | txt_printf("EVAL: %lu ", eval_cycles);\ | 72 | txt_printf("2BPP: %lu ", ppu_chr_cycles);\ |
60 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ | 73 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ |
61 | txt_printf("FLIP: %lu ", flip_cycles);\ | 74 | txt_printf("1BPP: %lu ", ppu_icn_cycles);\ |
62 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ | 75 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ |
63 | txt_printf("MIX: %lu ", mix_cycles);\ | 76 | txt_printf("FLIP: %lu ", flip_cycles);\ |
64 | } while (0) | 77 | } while (0) |
65 | #define PROF_INIT() \ | 78 | #define PROF_INIT() \ |
66 | u32 flip_cycles = 0;\ | 79 | static u32 ppu_pixel_cycles = 0;\ |
67 | u32 eval_cycles = 0;\ | 80 | static u32 ppu_chr_cycles = 0;\ |
68 | u32 input_cycles = 0;\ | 81 | static u32 ppu_icn_cycles = 0;\ |
69 | u32 mix_cycles = 0; | 82 | static u32 flip_cycles = 0;\ |
83 | static u32 eval_cycles = 0;\ | ||
84 | static u32 input_cycles = 0;\ | ||
85 | static u32 mix_cycles = 0; | ||
86 | |||
87 | PROF_INIT(); | ||
70 | #else | 88 | #else |
71 | #define PROF(F,VAR) (F) | 89 | #define PROF(F,VAR) (F) |
72 | #define PROF_SHOW() | 90 | #define PROF_SHOW() |
@@ -131,7 +149,7 @@ screen_deo(u8 *ram, u8 *d, u8 port) { | |||
131 | u8 layer = d[0xe] & 0x40; | 149 | u8 layer = d[0xe] & 0x40; |
132 | PEKDEV(x, 0x8); | 150 | PEKDEV(x, 0x8); |
133 | PEKDEV(y, 0xa); | 151 | PEKDEV(y, 0xa); |
134 | ppu_pixel(layer ? ppu.fg : ppu.bg, x, y, d[0xe] & 0x3); | 152 | PROF(ppu_pixel(layer ? ppu.fg : ppu.bg, x, y, d[0xe] & 0x3), ppu_pixel_cycles); |
135 | if(d[0x6] & 0x01) POKDEV(0x8, x + 1); /* auto x+1 */ | 153 | if(d[0x6] & 0x01) POKDEV(0x8, x + 1); /* auto x+1 */ |
136 | if(d[0x6] & 0x02) POKDEV(0xa, y + 1); /* auto y+1 */ | 154 | if(d[0x6] & 0x02) POKDEV(0xa, y + 1); /* auto y+1 */ |
137 | break; | 155 | break; |
@@ -155,9 +173,9 @@ screen_deo(u8 *ram, u8 *d, u8 port) { | |||
155 | for(size_t i = 0; i <= n; i++) { | 173 | for(size_t i = 0; i <= n; i++) { |
156 | u8 *sprite = &ram[addr]; | 174 | u8 *sprite = &ram[addr]; |
157 | if (twobpp) { | 175 | if (twobpp) { |
158 | ppu_2bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy); | 176 | PROF(ppu_2bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy), ppu_chr_cycles); |
159 | } else { | 177 | } else { |
160 | ppu_1bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy); | 178 | PROF(ppu_1bpp(layer, x + dy * i, y + dx * i, sprite, color, flipx, flipy), ppu_icn_cycles); |
161 | } | 179 | } |
162 | addr += (d[0x6] & 0x04) << (1 + twobpp); | 180 | addr += (d[0x6] & 0x04) << (1 + twobpp); |
163 | } | 181 | } |
@@ -564,7 +582,6 @@ main(void) { | |||
564 | 582 | ||
565 | // Main loop. | 583 | // Main loop. |
566 | uxn_eval(&u, PAGE_PROGRAM); | 584 | uxn_eval(&u, PAGE_PROGRAM); |
567 | PROF_INIT(); | ||
568 | u8 frame_counter = 0; | 585 | u8 frame_counter = 0; |
569 | while(true) { | 586 | while(true) { |
570 | bios_vblank_wait(); | 587 | bios_vblank_wait(); |