From fb100fe1abef4f61ad6aaca8e501ab13f1ca4b09 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 29 May 2021 09:28:35 +0200 Subject: Update README --- README.md | 26 ++++++++++++++++++++++++++ src/main.c | 25 ++++++++++++++++--------- 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" make run ROM_SRC=roms/audio.rom CONFIG="-DAUDIO_LOFI" ``` +### Text layer + +When writing text to the screen (for example using the console device) the text +will be drawn by default on the foreground layer. This can be controlled by +setting the `TEXT_MODE` option to 0 for foreground mode or 1 for background +mode. + +``` +make run CONFIG="-DTEXT_MODE=1" +``` + +### Performance metrics + +To enable profiling, the `PROF_ENABLE` macro can be used. This will display the +cycle count for input handling (INPUT), loop uxn evaluation (EVAL), screen +buffer flip (FLIP) and audio mixing (MIX). If `PROF_ENABLE` is set to 0, the +current frame numbers will be displayed, if set to 1, the maximum cycle count +for each section will be used instead. Enabling profiling can have a small +performance impact, so these numbers may not be 100% accurate, but should give +a good indication. Using `PROF_SHOW_X` and `PROF_SHOW_Y` we can control at which +tile the cycle count text will be located. + +``` +make run CONFIG="-DPROF_ENABLE=0 -DPROF_SHOW_Y=8 -DPROF_SHOW_X=8" +``` + [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. // Config parameters. // -#ifndef TEXT_LAYER +#if !defined(TEXT_MODE) || TEXT_MODE == 0 #define TEXT_LAYER ppu.fg +#else +#define TEXT_LAYER ppu.bg #endif #ifndef CONTROL_METHODS @@ -39,15 +41,21 @@ WITH REGARD TO THIS SOFTWARE. #elif PROF_ENABLE == 1 #define PROF(F,VAR) (profile_start(),(F),(VAR) = MAX(profile_stop(), (VAR))) #endif -#define PROF_SHOW(X,Y) \ +#ifndef PROF_SHOW_X +#define PROF_SHOW_X 0 +#endif +#ifndef PROF_SHOW_Y +#define PROF_SHOW_Y 0 +#endif +#define PROF_SHOW() \ do { \ - txt_position((X), (Y));\ + txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ txt_printf("INPUT: %lu ", input_cycles);\ - txt_position((X), (Y)+1);\ + txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+1);\ txt_printf("EVAL: %lu ", eval_cycles);\ - txt_position((X), (Y)+2);\ + txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+2);\ txt_printf("FLIP: %lu ", flip_cycles);\ - txt_position((X), (Y)+3);\ + txt_position((PROF_SHOW_X), (PROF_SHOW_Y)+3);\ txt_printf("MIX: %lu ", mix_cycles);\ } while (0) #define PROF_INIT() \ @@ -57,7 +65,7 @@ WITH REGARD TO THIS SOFTWARE. u32 mix_cycles = 0; #else #define PROF(F,VAR) (F) -#define PROF_SHOW(X,Y) +#define PROF_SHOW() #define PROF_INIT() #endif @@ -405,7 +413,6 @@ int main(void) { // Register interrupts. irq_init(); irs_set(IRQ_VBLANK, sound_vsync); - // irs_set(IRQ_TIMER_1, irs_stop_sample); // Initialize VM. dma_fill(&u, 0, sizeof(u), 3); @@ -427,7 +434,7 @@ int main(void) { PROF(handle_input(&u), input_cycles); PROF(evaluxn(&u, mempeek16(devscreen->dat, 0)), eval_cycles); PROF(sound_mix(), mix_cycles); - PROF_SHOW(9, 8); + PROF_SHOW(); PROF(flipbuf(&ppu), flip_cycles); } -- cgit v1.2.1