diff --git a/cfg.cpp b/cfg.cpp index 5cd3b08..98ff63f 100644 --- a/cfg.cpp +++ b/cfg.cpp @@ -56,6 +56,7 @@ const ini_var_t ini_vars[] = { { "FB_TERMINAL", (void*)(&(cfg.fb_terminal)), UINT8, 0, 1 }, { "OSD_TIMEOUT", (void*)(&(cfg.osd_timeout)), INT16, 5, 3600 }, { "DIRECT_VIDEO", (void*)(&(cfg.direct_video)), UINT8, 0, 1 }, + { "OSD_ROTATE", (void*)(&(cfg.osd_rotate)), UINT8, 0, 2 }, }; // mist ini config diff --git a/cfg.h b/cfg.h index 18af5e1..7382a01 100644 --- a/cfg.h +++ b/cfg.h @@ -38,6 +38,7 @@ typedef struct { int16_t bootcore_timeout; uint8_t fb_size; uint8_t fb_terminal; + uint8_t osd_rotate; uint16_t osd_timeout; char bootcore[256]; char video_conf[1024]; diff --git a/osd.cpp b/osd.cpp index e67f7ee..8a7a0cf 100644 --- a/osd.cpp +++ b/osd.cpp @@ -593,6 +593,18 @@ void InfoEnable(int x, int y, int width, int height) DisableOsd(); } +void OsdRotation(uint8_t rotate) +{ + if (is_minimig()) return; + spi_osd_cmd_cont(MM1_OSDCMDDISABLE); + spi_w(0); + spi_w(0); + spi_w(0); + spi_w(0); + spi_w(rotate); + DisableOsd(); +} + // disable displaying of OSD void OsdDisable(void) { diff --git a/osd.h b/osd.h index f736564..f99c08c 100644 --- a/osd.h +++ b/osd.h @@ -73,6 +73,7 @@ void OsdWriteOffset(unsigned char n, const char *s, unsigned char inver, unsigne void OsdClear(void); void OsdEnable(unsigned char mode); void InfoEnable(int x, int y, int width, int height); +void OsdRotation(uint8_t rotate); void OsdDisable(void); void ConfigVideo(unsigned char hires, unsigned char lores, unsigned char scanlines); void ConfigAudio(unsigned char audio); diff --git a/user_io.cpp b/user_io.cpp index 9fb2737..7cc4238 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -862,6 +862,8 @@ void user_io_init(const char *path) break; } + OsdRotation((cfg.osd_rotate == 1) ? 3 : (cfg.osd_rotate == 2) ? 1 : 0); + spi_uio_cmd_cont(UIO_GETUARTFLG); uart_mode = spi_w(0); DisableIO(); diff --git a/video.cpp b/video.cpp index 28f00e9..696e670 100644 --- a/video.cpp +++ b/video.cpp @@ -892,6 +892,12 @@ void video_menu_bg(int n, int idle) } vs_wait(); }; + + if (cfg.osd_rotate) + { + imlib_context_set_image(logo); + imlib_image_orientate(cfg.osd_rotate == 1 ? 3 : 1); + } } else { @@ -1016,16 +1022,42 @@ void video_menu_bg(int n, int idle) int src_w = imlib_image_get_width(); int src_h = imlib_image_get_height(); + printf("logo: src_w=%d, src_h=%d\n", src_w, src_h); + int dst_w, dst_h; + int dst_x, dst_y; + if (cfg.osd_rotate) + { + dst_h = fb_height / 2; + dst_w = src_w * dst_h / src_h; + if (cfg.osd_rotate == 1) + { + dst_x = 0; + dst_y = fb_height - dst_h; + } + else + { + dst_x = fb_width - dst_w; + dst_y = 0; + } + } + else + { + dst_x = 0; + dst_y = 0; + dst_w = fb_width * 2 / 7; + dst_h = src_h * dst_w / src_w; + } + if (*bg) { imlib_context_set_image(*bg); imlib_blend_image_onto_image(logo, 1, 0, 0, //int source_x, int source_y, src_w, src_h, //int source_width, int source_height, - 0, 0, //int destination_x, int destination_y, - fb_width*2 / 7, src_h*fb_width*2 / (src_w * 7) //int destination_width, int destination_height + dst_x, dst_y, //int destination_x, int destination_y, + dst_w, dst_h //int destination_width, int destination_height ); } else