From ac20ad7192a90d72dd69a186016c6e6a91f71e9e Mon Sep 17 00:00:00 2001 From: Lemur42332543632 <120027513+Lemur42332543632@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:06:42 +0300 Subject: [PATCH] Add user friendly setWindowXXX(...) and VDP_setWindowOff(), VDP_setWindowFullScreen() methods (#372) * Add user friendly setWindowXXX(...) and VDP_setWindowOff() methods * Add VDP_setWindowFullScreen() --- inc/vdp.h | 42 ++++++++++++++++++++++++++++++++++++++++++ src/vdp.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/inc/vdp.h b/inc/vdp.h index 0dde6d08..f53abbe9 100644 --- a/inc/vdp.h +++ b/inc/vdp.h @@ -991,6 +991,48 @@ void VDP_setWindowHPos(u16 right, u16 pos); * The Vertical position of the window in 1 tile unit (8 pixels). */ void VDP_setWindowVPos(u16 down, u16 pos); +/** + * \brief + * Turns off the window. + */ +void VDP_setWindowOff(); +/** + * \brief + * Positions the window from the top edge of the screen by the specified number of rows (tiles). + * + * \param rows + * The number of rows, expressed in tiles. + */ +void VDP_setWindowOnTop(u16 rows); +/** + * \brief + * Positions the window from the bottom edge of the screen by the specified number of rows (tiles). + * + * \param rows + * The number of rows, expressed in tiles. + */ +void VDP_setWindowOnBottom(u16 rows); +/** + * \brief + * Positions the window from the left edge of the screen by the specified number of columns, each 2 tiles wide (16 pixels). + * + * \param cols + * The number of columns, expressed in double tiles. + */ +void VDP_setWindowOnLeft(u16 cols); +/** + * \brief + * Positions the window from the right edge of the screen by the specified number of columns, each 2 tiles wide (16 pixels). + * + * \param cols + * The number of columns, expressed in double tiles. + */ +void VDP_setWindowOnRight(u16 cols); +/** + * \brief + * Positions the window to full screen. + */ +void VDP_setWindowFullScreen(); /** * \brief diff --git a/src/vdp.c b/src/vdp.c index 707a63bd..b6202b44 100644 --- a/src/vdp.c +++ b/src/vdp.c @@ -808,6 +808,36 @@ void VDP_setWindowVPos(u16 down, u16 pos) *pw = 0x9200 | v; } +void VDP_setWindowOff() +{ + VDP_setWindowVPos(false, 0); + VDP_setWindowHPos(false, 0); +} + +void VDP_setWindowOnTop(u16 rows) +{ + VDP_setWindowVPos(false, rows); +} + +void VDP_setWindowOnBottom(u16 rows) +{ + VDP_setWindowVPos(true, (screenHeight / 8) - rows); +} + +void VDP_setWindowOnLeft(u16 cols) +{ + VDP_setWindowHPos(false, cols); +} + +void VDP_setWindowOnRight(u16 cols) +{ + VDP_setWindowHPos(true, (screenWidth / 16) - cols); +} + +void VDP_setWindowFullScreen() +{ + VDP_setWindowVPos(false, screenHeight / 8); +} void VDP_waitDMACompletion() {