aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md26
-rw-r--r--src/main.c25
2 files changed, 42 insertions, 9 deletions
diff --git a/README.md b/README.md
index 0988e6e..dbc90c0 100644
--- a/README.md
+++ b/README.md
@@ -76,4 +76,30 @@ make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_HIFI"
76make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_LOFI" 76make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_LOFI"
77``` 77```
78 78
79### Text layer
80
81When writing text to the screen (for example using the console device) the text
82will be drawn by default on the foreground layer. This can be controlled by
83setting the `TEXT_MODE` option to 0 for foreground mode or 1 for background
84mode.
85
86```
87make run CONFIG="-DTEXT_MODE=1"
88```
89
90### Performance metrics
91
92To enable profiling, the `PROF_ENABLE` macro can be used. This will display the
93cycle count for input handling (INPUT), loop uxn evaluation (EVAL), screen
94buffer flip (FLIP) and audio mixing (MIX). If `PROF_ENABLE` is set to 0, the
95current frame numbers will be displayed, if set to 1, the maximum cycle count
96for each section will be used instead. Enabling profiling can have a small
97performance impact, so these numbers may not be 100% accurate, but should give
98a good indication. Using `PROF_SHOW_X` and `PROF_SHOW_Y` we can control at which
99tile the cycle count text will be located.
100
101```
102make run CONFIG="-DPROF_ENABLE=0 -DPROF_SHOW_Y=8 -DPROF_SHOW_X=8"
103```
104
79[noodle]: https://wiki.xxiivv.com/site/noodle.html 105[noodle]: https://wiki.xxiivv.com/site/noodle.html
diff --git a/src/main.c b/src/main.c
index 9a22000..4b2b2d6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -25,8 +25,10 @@ WITH REGARD TO THIS SOFTWARE.
25// Config parameters. 25// Config parameters.
26// 26//
27 27
28#ifndef TEXT_LAYER 28#if !defined(TEXT_MODE) || TEXT_MODE == 0
29#define TEXT_LAYER ppu.fg 29#define TEXT_LAYER ppu.fg
30#else
31#define TEXT_LAYER ppu.bg
30#endif 32#endif
31 33
32#ifndef CONTROL_METHODS 34#ifndef CONTROL_METHODS
@@ -39,15 +41,21 @@ WITH REGARD TO THIS SOFTWARE.
39#elif PROF_ENABLE == 1 41#elif PROF_ENABLE == 1
40#define PROF(F,VAR) (profile_start(),(F),(VAR) = MAX(profile_stop(), (VAR))) 42#define PROF(F,VAR) (profile_start(),(F),(VAR) = MAX(profile_stop(), (VAR)))
41#endif 43#endif
42#define PROF_SHOW(X,Y) \ 44#ifndef PROF_SHOW_X
45#define PROF_SHOW_X 0
46#endif
47#ifndef PROF_SHOW_Y
48#define PROF_SHOW_Y 0
49#endif
50#define PROF_SHOW() \
43 do { \ 51 do { \
44 txt_position((X), (Y));\ 52 txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\
45 txt_printf("INPUT: %lu ", input_cycles);\ 53 txt_printf("INPUT: %lu ", input_cycles);\
46 txt_position((X), (Y)+1);\ 54 txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\
47 txt_printf("EVAL: %lu ", eval_cycles);\ 55 txt_printf("EVAL: %lu ", eval_cycles);\
48 txt_position((X), (Y)+2);\ 56 txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\
49 txt_printf("FLIP: %lu ", flip_cycles);\ 57 txt_printf("FLIP: %lu ", flip_cycles);\
50 txt_position((X), (Y)+3);\ 58 txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\
51 txt_printf("MIX: %lu ", mix_cycles);\ 59 txt_printf("MIX: %lu ", mix_cycles);\
52 } while (0) 60 } while (0)
53#define PROF_INIT() \ 61#define PROF_INIT() \
@@ -57,7 +65,7 @@ WITH REGARD TO THIS SOFTWARE.
57 u32 mix_cycles = 0; 65 u32 mix_cycles = 0;
58#else 66#else
59#define PROF(F,VAR) (F) 67#define PROF(F,VAR) (F)
60#define PROF_SHOW(X,Y) 68#define PROF_SHOW()
61#define PROF_INIT() 69#define PROF_INIT()
62#endif 70#endif
63 71
@@ -405,7 +413,6 @@ int main(void) {
405 // Register interrupts. 413 // Register interrupts.
406 irq_init(); 414 irq_init();
407 irs_set(IRQ_VBLANK, sound_vsync); 415 irs_set(IRQ_VBLANK, sound_vsync);
408 // irs_set(IRQ_TIMER_1, irs_stop_sample);
409 416
410 // Initialize VM. 417 // Initialize VM.
411 dma_fill(&u, 0, sizeof(u), 3); 418 dma_fill(&u, 0, sizeof(u), 3);
@@ -427,7 +434,7 @@ int main(void) {
427 PROF(handle_input(&u), input_cycles); 434 PROF(handle_input(&u), input_cycles);
428 PROF(evaluxn(&u, mempeek16(devscreen->dat, 0)), eval_cycles); 435 PROF(evaluxn(&u, mempeek16(devscreen->dat, 0)), eval_cycles);
429 PROF(sound_mix(), mix_cycles); 436 PROF(sound_mix(), mix_cycles);
430 PROF_SHOW(9, 8); 437 PROF_SHOW();
431 PROF(flipbuf(&ppu), flip_cycles); 438 PROF(flipbuf(&ppu), flip_cycles);
432 } 439 }
433 440