+static void hud_print(void *fb, int w, int x, int y, const char *text)
+{
+ if (pl_plat_hud_print)
+ pl_plat_hud_print(x, y, text, pl_vout_bpp);
+ else if (pl_vout_bpp == 16)
+ basic_text_out16_nf(fb, w, x, y, text);
+}
+
+static void hud_printf(void *fb, int w, int x, int y, const char *texto, ...)
+{
+ va_list args;
+ char buffer[256];
+
+ va_start(args, texto);
+ vsnprintf(buffer, sizeof(buffer), texto, args);
+ va_end(args);
+
+ hud_print(fb, w, x, y, buffer);
+}
+
+static void print_msg(int h, int border)
+{
+ hud_print(pl_vout_buf, pl_vout_w, border + 2, h - HUD_HEIGHT, hud_msg);
+}
+
+static void print_fps(int h, int border)
+{
+ hud_printf(pl_vout_buf, pl_vout_w, border + 2, h - HUD_HEIGHT,
+ "%2d %4.1f", pl_rearmed_cbs.flips_per_sec,
+ pl_rearmed_cbs.vsps_cur);
+}
+
+static void print_cpu_usage(int x, int h)
+{
+ hud_printf(pl_vout_buf, pl_vout_w, x - 28,
+ h - HUD_HEIGHT, "%3d", pl_rearmed_cbs.cpu_usage);
+}
+
+// draw 192x8 status of 24 sound channels
+static __attribute__((noinline)) void draw_active_chans(int vout_w, int vout_h)
+{
+ extern void spu_get_debug_info(int *chans_out, int *run_chans,
+ int *fmod_chans_out, int *noise_chans_out); // hack
+ int live_chans, run_chans, fmod_chans, noise_chans;
+
+ static const unsigned short colors[2] = { 0x1fe3, 0x0700 };
+ unsigned short *dest = (unsigned short *)pl_vout_buf +
+ vout_w * (vout_h - HUD_HEIGHT) + vout_w / 2 - 192/2;
+ unsigned short *d, p;
+ int c, x, y;
+
+ if (pl_vout_buf == NULL || pl_vout_bpp != 16)
+ return;
+
+ spu_get_debug_info(&live_chans, &run_chans, &fmod_chans, &noise_chans);
+
+ for (c = 0; c < 24; c++) {
+ d = dest + c * 8;
+ p = !(live_chans & (1<<c)) ? (run_chans & (1<<c) ? 0x01c0 : 0) :
+ (fmod_chans & (1<<c)) ? 0xf000 :
+ (noise_chans & (1<<c)) ? 0x001f :
+ colors[c & 1];
+ for (y = 0; y < 8; y++, d += vout_w)
+ for (x = 0; x < 8; x++)
+ d[x] = p;
+ }
+}
+
+static void print_hud(int x, int w, int h)
+{
+ if (h < 192)
+ return;
+
+ if (h > pl_vout_h)
+ h = pl_vout_h;
+
+ if (g_opts & OPT_SHOWSPU)
+ draw_active_chans(w, h);
+
+ if (hud_msg[0] != 0)
+ print_msg(h, x);
+ else if (g_opts & OPT_SHOWFPS)
+ print_fps(h, x);
+
+ if (g_opts & OPT_SHOWCPU)
+ print_cpu_usage(x + w, h);
+}
+
+/* update scaler target size according to user settings */
+static void update_layer_size(int w, int h)