From: quzar <qu...@us...> - 2025-02-03 06:53:04
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "A pseudo Operating System for the Dreamcast.". The branch, master has been updated via bad425592df5401515f296802a05ddfef1afe8b5 (commit) via 4969106edddb605584d2dbeb31af9fd3a1e79e0e (commit) via 9670df33546c528cff937f637140b843569b3fe5 (commit) via 4f974a2ea4a6029cef07c3892e54d6af23809643 (commit) via eec75932a4f12963f5f2dcb20802e22f7503f542 (commit) via ef670bf41feed3dfa86cf0777f929700b2b29d9d (commit) via 84b378405de41b0196b7946a306fba7aa9981308 (commit) via 88685f91ca691da06e00fbea0ce3a3f670b96af4 (commit) via 7b9e21e8f21004fd5b12f3fc2bbc4b16edf9a294 (commit) via 2ab1204eedaea205a507ce71999c694a27009e9d (commit) via d8c1ce0321c368998f68a13700beb7a84592f2ca (commit) via 2e539f91d5ac022622547391f2bcf9b5a0cc9e9c (commit) via f3bb2d8952db395011db1c8e86b07aa4ac0192d7 (commit) via 8df6c24a222f70b9be91acccfd8b1cc7384f6f52 (commit) via 163be4b6433b9ba986b76b7c90525bf4813347a1 (commit) via acc4bae0f4370e39073611ccf55a5b44b7ab2452 (commit) via 1e2cbd3cc5516a1827ebd8c5672929e0aedf7485 (commit) via dfd76879d0abaa4a154067225370446e30ae6fb0 (commit) via e3ab7d197a455d4c802d2006243eda4d6ef6fbc9 (commit) from 80a54c601e71dfeb44ec764583815ac353580205 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit bad425592df5401515f296802a05ddfef1afe8b5 Merge: 4969106e eec75932 Author: Donald Haase <qu...@ya...> Date: Sun Feb 2 21:39:21 2025 -0500 Merge pull request #922 from sizious/dc-chain-mingw64-updates `dc-chain` update documentations commit 4969106edddb605584d2dbeb31af9fd3a1e79e0e Author: Falco Girgis <gyr...@gm...> Date: Sun Feb 2 21:37:17 2025 -0500 VMU Button Bitflag Fix, Plus Maintaining Previous Button States. (#915) * Fixed #defines for VMU button bitflags. - Bitflags were never correctly defined for the VMU buttons in vmu.h, but it was never caught, since you can also access them via bitfields. - Corrected the incorrect flags. * Added tracking for previous VMU button state. In order to do anything useful in terms of responding to button state change events, such as when a button is FIRST pressed or FIRST released, any app would have to maintain the previous state of the buttons in order to compare them to the current state. We've been moving this functionality into KOS, so I've done the same with the VMU buttons. Since the maple state data is static for every device, we aren't storing any extra information anyway. Just using one more byte of the 1024 byte buffer at the end of our device (for a whopping 2 bytes of total button info). - Pulled VMU buttons out of state and into their own union of raw button masks and individual bitfields. - Added logic to driver to cache the previous frame's state - Created new vmu_state_t struct exposing these two frames' worth of button state info. * Made vmu_cond_t struct private. This struct is only for processing the raw maple response packet when querying for button states... There was no reason to expose it as something cluttering up the main API and confusing our users. - Moved vmu_cond_t from vmu.h to vmu.c. - Updated copyright information. commit 9670df33546c528cff937f637140b843569b3fe5 Merge: 4f974a2e ef670bf4 Author: Donald Haase <qu...@ya...> Date: Sun Feb 2 03:04:06 2025 -0500 Merge pull request #913 from KallistiOS/falco/string_h_deprecation Deprecated string.h and removed usages. commit 4f974a2ea4a6029cef07c3892e54d6af23809643 Merge: 80a54c60 88685f91 Author: Donald Haase <qu...@ya...> Date: Sun Feb 2 00:29:45 2025 -0500 Merge pull request #899 from KallistiOS/dont_optimize_sq_flush Ensure sq_writeback is flagged as causing memory to change. commit eec75932a4f12963f5f2dcb20802e22f7503f542 Merge: 7b9e21e8 80a54c60 Author: Mickaël Cardoso <si...@gm...> Date: Wed Jan 29 08:48:04 2025 +0100 Merge branch 'master' into dc-chain-mingw64-updates commit ef670bf41feed3dfa86cf0777f929700b2b29d9d Merge: 84b37840 80a54c60 Author: Falco Girgis <gyr...@gm...> Date: Tue Jan 28 22:06:23 2025 -0600 Merge branch 'master' of github.com:KallistiOS/KallistiOS into falco/string_h_deprecation commit 84b378405de41b0196b7946a306fba7aa9981308 Merge: e3ab7d19 c753c2ba Author: Falco Girgis <gyr...@gm...> Date: Tue Jan 28 21:59:18 2025 -0600 Merge branch 'master' into falco/string_h_deprecation commit 88685f91ca691da06e00fbea0ce3a3f670b96af4 Author: QuzarDC <qu...@co...> Date: Mon Jan 27 22:37:32 2025 -0500 Ensure sq_writeback is flagged as causing memory to change. First reported with #897, a regression from #877. While it's appropriate for the generalized dcache_pref_block to not have outputs, setting the same for the store queue writeback causes it to be optimized away in some situations (specifically DR). This simply rolls back to the previous behavior for the sq case. It should be possible to optimize further, but different attempts led to build failures. commit 7b9e21e8f21004fd5b12f3fc2bbc4b16edf9a294 Author: SiZiOUS <si...@gm...> Date: Mon Jan 27 20:53:23 2025 +0100 `dc-chain`: adding GCC 8.5.0 patch for MinGW-w64 Note: This is the same patch as for the other Windows environments. commit 2ab1204eedaea205a507ce71999c694a27009e9d Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 15:38:04 2025 +0100 `dc-chain`: small cosmetic fix for MinGW. commit d8c1ce0321c368998f68a13700beb7a84592f2ca Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 15:37:29 2025 +0100 `dc-chain`: big update on MinGW-w64 documentation As this is now the foundation used for DreamSDK! commit 2e539f91d5ac022622547391f2bcf9b5a0cc9e9c Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 15:12:35 2025 +0100 `dc-chain`: update changelog and contributors list. commit f3bb2d8952db395011db1c8e86b07aa4ac0192d7 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 15:03:41 2025 +0100 `dc-chain`: updating original MinGW link mingw.org has been abandoned, this domain is not linked to the original MinGW team anymore. commit 8df6c24a222f70b9be91acccfd8b1cc7384f6f52 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 14:58:25 2025 +0100 `dc-chain`: harmonizing README links This is just cosmetic fix. commit 163be4b6433b9ba986b76b7c90525bf4813347a1 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 14:56:39 2025 +0100 `dc-chain`: fix README link for all platforms And not only for MinGW-w64 as intended in the beginning... commit acc4bae0f4370e39073611ccf55a5b44b7ab2452 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 14:54:18 2025 +0100 `dc-chain`: fix KOS README link commit 1e2cbd3cc5516a1827ebd8c5672929e0aedf7485 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 14:52:59 2025 +0100 `dc-chain`: fix change log link commit dfd76879d0abaa4a154067225370446e30ae6fb0 Author: SiZiOUS <si...@gm...> Date: Sun Jan 26 14:52:09 2025 +0100 `dc-chain`: removing link on `Makefile.cfg` This file is not provided anymore now. commit e3ab7d197a455d4c802d2006243eda4d6ef6fbc9 Author: Falco Girgis <gyr...@gm...> Date: Sat Jan 25 16:50:04 2025 -0600 Deprecated string.h and removed usages. <kos/string.h> is full of routines which completely break at high optimization levels (they get optimized out), from invoking undefined behavior in C and C++ due to breaking strict aliasing rules. This has caused a myriad of subtle issues at high optimization levels over the years, due to these calls getting optimized away, and now we finally know why. Avoid them at all costs. - Deprecated the heck out of kos/string.h with Doxygen documentation, tags, and attributes explaining why. - Removed all usages of these functions from within KOS. - Removed all usages of these functions from KOS-ports. ----------------------------------------------------------------------- Summary of changes: examples/dreamcast/vmu/vmu_game/vmu_game.c | 5 +- examples/dreamcast/vmu/vmu_pkg/vmu.c | 5 +- include/kos/string.h | 48 ++++++++++++++--- kernel/arch/dreamcast/hardware/maple/maple_utils.c | 2 +- kernel/arch/dreamcast/hardware/maple/vmu.c | 24 ++++++--- kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 3 +- kernel/arch/dreamcast/hardware/pvr/pvr_scene.c | 3 +- kernel/arch/dreamcast/hardware/pvr/pvr_texture.c | 4 +- kernel/arch/dreamcast/include/arch/cache.h | 10 +++- kernel/arch/dreamcast/include/dc/maple/vmu.h | 63 +++++++++++++--------- kernel/arch/dreamcast/util/fb_console.c | 5 +- kernel/arch/dreamcast/util/fb_console_naomi.c | 5 +- kernel/arch/dreamcast/util/vmu_fb.c | 3 -- utils/dc-chain/README.md | 14 ++--- utils/dc-chain/doc/CHANGELOG.md | 1 + utils/dc-chain/doc/CONTRIBUTORS.md | 4 +- utils/dc-chain/doc/alpine.md | 4 +- utils/dc-chain/doc/bsd.md | 4 +- utils/dc-chain/doc/cygwin.md | 4 +- utils/dc-chain/doc/debian.md | 4 +- utils/dc-chain/doc/macos.md | 4 +- utils/dc-chain/doc/mingw/README.md | 3 +- utils/dc-chain/doc/mingw/mingw-w64.md | 58 +++++++++++--------- utils/dc-chain/doc/mingw/mingw.md | 10 ++-- .../gcc-8.5.0.diff | 0 25 files changed, 175 insertions(+), 115 deletions(-) copy utils/dc-chain/patches/{i686-w64-mingw32 => x86_64-w64-mingw32}/gcc-8.5.0.diff (100%) diff --git a/examples/dreamcast/vmu/vmu_game/vmu_game.c b/examples/dreamcast/vmu/vmu_game/vmu_game.c index 7b90b0ef..b59f2e76 100644 --- a/examples/dreamcast/vmu/vmu_game/vmu_game.c +++ b/examples/dreamcast/vmu/vmu_game/vmu_game.c @@ -8,7 +8,6 @@ a VMU game file to a VMU with a DC-compatible header so it can be played on the vmu. */ #include <kos.h> -#include <kos/string.h> void draw_findings(void) { file_t d; @@ -31,7 +30,7 @@ void new_vmu(void) { if(dev == NULL) { if(dev_checked) { - memset4(vram_s + 88 * 640, 0, 640 * (480 - 64) * 2); + memset(vram_s + 88 * 640, 0, 640 * (480 - 64) * 2); bfont_draw_str_vram_fmt(10, 88, false, "No VMU"); dev_checked = 0; } @@ -39,7 +38,7 @@ void new_vmu(void) { else if(dev_checked) { } else { - memset4(vram_s + 88 * 640, 0, 640 * (480 - 88)); + memset(vram_s + 88 * 640, 0, 640 * (480 - 88)); draw_findings(); dev_checked = 1; } diff --git a/examples/dreamcast/vmu/vmu_pkg/vmu.c b/examples/dreamcast/vmu/vmu_pkg/vmu.c index 6362005d..65896555 100644 --- a/examples/dreamcast/vmu/vmu_pkg/vmu.c +++ b/examples/dreamcast/vmu/vmu_pkg/vmu.c @@ -9,7 +9,6 @@ any other VMU file from the BIOS menus. */ #include <kos.h> -#include <kos/string.h> void draw_dir(void) { file_t d; @@ -42,7 +41,7 @@ void new_vmu(void) { if(dev == NULL) { if(dev_checked) { - memset4(vram_s + 88 * 640, 0, 640 * (480 - 64) * 2); + memset(vram_s + 88 * 640, 0, 640 * (480 - 64) * 2); bfont_draw_str(vram_s + 88 * 640 + 10, 640, 0, "No VMU"); dev_checked = 0; } @@ -50,7 +49,7 @@ void new_vmu(void) { else if(dev_checked) { } else { - memset4(vram_s + 88 * 640, 0, 640 * (480 - 88)); + memset(vram_s + 88 * 640, 0, 640 * (480 - 88)); draw_dir(); dev_checked = 1; } diff --git a/include/kos/string.h b/include/kos/string.h index 7bf7a72b..855a565d 100644 --- a/include/kos/string.h +++ b/include/kos/string.h @@ -1,18 +1,28 @@ /* KallistiOS ##version## kos/string.h - Copyright (C)2004 Megan Potter - + Copyright (C) 2004 Megan Potter + Copyright (C) 2025 Falco Girgis */ /** \file kos/string.h \brief Variants on standard block memory copy/set functions. \ingroup system_types + \deprecated This file contains variants on the standard block memory copy/set functions. These variants copy/set memory in the specified block sizes, which may be helpful for interacting with memory-mapped hardware. + \note + None of these routines are actually faster than using the equivalent + standard C functions such as memcpy() and memset()! + + \warning + Due to the fact that it breaks C and C++'s strict aliasing rules, this + entire API is no longer safe to use, as its calls can get optimized away + and never happen with higher optimization levels! + \author Megan Potter */ @@ -29,56 +39,80 @@ __BEGIN_DECLS */ /** \brief Copy a block of memory, 4 bytes at a time. + \deprecated Invokes undefined behavior. Use memcpy(). This function is identical to memcpy(), except it copies 4 bytes at a time. + \warning + This function breaks C/C++ strict aliasing rules and is no longer + considered safe to use. It's also slow. + \param dest The destination of the copy. \param src The source to copy. \param count The number of bytes to copy. This should be divisible by 4 (and will be rounded down if not). \return The original value of dest. */ -void * memcpy4(void * dest, const void *src, size_t count); +void *memcpy4(void *dest, const void *src, size_t count) + __depr("Unsafe. Use memcpy()."); /** \brief Set a block of memory, 4 bytes at a time. + \deprecated Invokes undefined behavior. Use memset(). This function is identical to memset(), except it sets 4 bytes at a time. This implies that all 32-bits of c are used, not just the first 8 as in memset(). + \warning + This function breaks C/C++ strict aliasing rules and is no longer + considered safe to use. + \param s The destination of the set. \param c The value to set to. \param count The number of bytes to set. This should be divisible by 4 (and will be rounded down if not). \return The original value of dest. */ -void * memset4(void * s, unsigned long c, size_t count); +void *memset4(void *s, unsigned long c, size_t count) + __depr("Unsafe. Use memset()."); /** \brief Copy a block of memory, 2 bytes at a time. + \deprecated Invokes undefined behavior. Use memcpy(). This function is identical to memcpy(), except it copies 2 bytes at a time. + \warning + This function breaks C/C++ strict aliasing rules and is no longer + considered safe to use. It's also slow. + \param dest The destination of the copy. \param src The source to copy. \param count The number of bytes to copy. This should be divisible by 2 (and will be rounded down if not). \return The original value of dest. */ -void * memcpy2(void * dest, const void *src, size_t count); +void *memcpy2(void * dest, const void *src, size_t count) + __depr("Unsafe. Use memcpy()."); -/** \brief Set a block of memory, 2 bytes at a time. +/** \brief Set a block of memory, 2 bytes at a time. + \deprecated Invokes undefined behavior. This function is identical to memset(), except it sets 2 bytes at a time. This implies that all 16-bits of c are used, not just the first 8 as in memset(). + \warning + This function breaks C/C++ strict aliasing rules and is no longer + considered safe to use. + \param s The destination of the set. \param c The value to set to. \param count The number of bytes to set. This should be divisible by 2 (and will be rounded down if not). \return The original value of dest. */ -void * memset2(void * s, unsigned short c, size_t count); +void *memset2(void *s, unsigned short c, size_t count) + __depr("Unsafe."); /** @} */ diff --git a/kernel/arch/dreamcast/hardware/maple/maple_utils.c b/kernel/arch/dreamcast/hardware/maple/maple_utils.c index e10bf365..9fddad06 100644 --- a/kernel/arch/dreamcast/hardware/maple/maple_utils.c +++ b/kernel/arch/dreamcast/hardware/maple/maple_utils.c @@ -172,7 +172,7 @@ void maple_gun_read_pos(int *x, int *y) { /* Debugging help */ void maple_sentinel_setup(void * buffer, int bufsize) { assert(bufsize % 4 == 0); - memset4(buffer, 0xdeadbeef, bufsize); + memset(buffer, 0xdeadbeef, bufsize); } void maple_sentinel_verify(const char * bufname, void * buffer, int bufsize) { diff --git a/kernel/arch/dreamcast/hardware/maple/vmu.c b/kernel/arch/dreamcast/hardware/maple/vmu.c index d03c4557..2a4fc304 100644 --- a/kernel/arch/dreamcast/hardware/maple/vmu.c +++ b/kernel/arch/dreamcast/hardware/maple/vmu.c @@ -3,7 +3,7 @@ vmu.c Copyright (C) 2002, 2003 Megan Potter Copyright (C) 2008 Donald Haase - Copyright (C) 2023 Falco Girgis + Copyright (C) 2023, 2025 Falco Girgis */ /* @@ -28,6 +28,12 @@ #define VMU_BLOCK_WRITE_RETRY_TIME 100 /* time to sleep until retrying a failed write */ +/* VMU's raw condition data: 0 = PRESSED, 1 = RELEASED */ +typedef struct vmu_cond { + uint8_t raw_buttons; + uint8_t dummy[3]; +} vmu_cond_t; + typedef struct vmu_datetime { uint16_t year; /* 0 - 9999 */ uint8_t month; /* 1 - 12 */ @@ -95,8 +101,10 @@ static void vmu_poll_reply(maple_state_t *st, maple_frame_t *frm) { /* Fill the "nice" struct from the raw data */ cooked = (vmu_state_t *)(frm->dev->status); + /* Copy over current button states to previous states. */ + cooked->buttons.previous = cooked->buttons.current; /* Invert raw struct as nice struct */ - cooked->buttons = ~(raw->raw_buttons); + cooked->buttons.current.raw = ~(raw->raw_buttons); /* Check to see if the VMU is upside-down in the controller and readjust its directional buttons accordingly. */ @@ -104,12 +112,12 @@ static void vmu_poll_reply(maple_state_t *st, maple_frame_t *frm) { if(cont && (cont->info.functions & MAPLE_FUNC_CONTROLLER) && (frm->dev->info.connector_direction == cont->info.connector_direction)) { - cooked->buttons = (cooked->buttons & 0xf0) | - (cooked->dpad_up << 1) | /* down */ - (cooked->dpad_down << 0) | /* up */ - (cooked->dpad_left << 3) | /* right */ - (cooked->dpad_right << 2); /* left */ - + cooked->buttons.current.raw = + (cooked->buttons.current.raw & 0xf0) | + (cooked->buttons.current.dpad_up << 1) | /* down */ + (cooked->buttons.current.dpad_down << 0) | /* up */ + (cooked->buttons.current.dpad_left << 3) | /* right */ + (cooked->buttons.current.dpad_right << 2); /* left */ } frm->dev->status_valid = 1; diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c index 740d0f60..46401f98 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c @@ -14,7 +14,6 @@ #include <dc/pvr.h> #include <dc/video.h> #include <kos/regfield.h> -#include <kos/string.h> #include "pvr_internal.h" @@ -216,7 +215,7 @@ void pvr_begin_queued_render(void) { bkg.argb3 = pvr_state.bg_color; vrl = (uint32_t *)(PVR_RAM_BASE | PVR_GET(PVR_TA_VERTBUF_POS)); - memcpy4(vrl, &bkg, sizeof(bkg)); + memcpy(vrl, &bkg, sizeof(bkg)); /* Reset the ISP/TSP, just in case */ //PVR_SET(PVR_RESET, PVR_RESET_ISPTSP); diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c index 58b0eb24..928eee0f 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_scene.c @@ -11,7 +11,6 @@ #include <string.h> #include <kos/genwait.h> #include <kos/regfield.h> -#include <kos/string.h> #include <kos/thread.h> #include <dc/pvr.h> #include <dc/sq.h> @@ -351,7 +350,7 @@ int pvr_scene_finish(void) { } // Put a zero-marker on the end. - memset4(b->base[i] + b->ptr[i], 0, 32); + memset(b->base[i] + b->ptr[i], 0, 32); b->ptr[i] += 32; // Verify that there is no overrun. diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c b/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c index 49ea049e..c8d73edc 100644 --- a/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c +++ b/kernel/arch/dreamcast/hardware/pvr/pvr_texture.c @@ -6,9 +6,9 @@ */ #include <assert.h> -#include <kos/string.h> #include <dc/pvr.h> #include <dc/sq.h> +#include <string.h> #include "pvr_internal.h" /* @@ -198,7 +198,7 @@ void pvr_txr_load_kimg(const kos_img_t *img, pvr_ptr_t dst, uint32 flags) { pvr_txr_load(img->data, dst, img->byte_count); } else { - memcpy4(dst, img->data, img->byte_count); + memcpy(dst, img->data, img->byte_count); } } } diff --git a/kernel/arch/dreamcast/include/arch/cache.h b/kernel/arch/dreamcast/include/arch/cache.h index 0581b27a..e0af62be 100644 --- a/kernel/arch/dreamcast/include/arch/cache.h +++ b/kernel/arch/dreamcast/include/arch/cache.h @@ -149,9 +149,15 @@ static __always_inline void dcache_pref_block(const void *src) { This function initiates write-back for one Store Queue. - \param ptr The SQ mapped address to write-back. + \param src The SQ mapped address to write-back. */ -#define dcache_wback_sq(ptr) dcache_pref_block(ptr) +static __always_inline void dcache_wback_sq(void *src) { + __asm__ __volatile__("pref @%0\n" + : /* No outputs */ + : "r" (src) + : "memory" + ); +} /** \brief Allocate one block of the data/operand cache. diff --git a/kernel/arch/dreamcast/include/dc/maple/vmu.h b/kernel/arch/dreamcast/include/dc/maple/vmu.h index 88f35b5b..6eee44b8 100644 --- a/kernel/arch/dreamcast/include/dc/maple/vmu.h +++ b/kernel/arch/dreamcast/include/dc/maple/vmu.h @@ -3,7 +3,8 @@ dc/maple/vmu.h Copyright (C) 2000-2002 Jordan DeLong, Megan Potter Copyright (C) 2008 Donald Haase - Copyright (C) 2023 Falco Girgis, Andy Barajas + Copyright (C) 2023 Andy Barajas + Copyright (C) 2023, 2025 Falco Girgis */ @@ -31,6 +32,7 @@ __BEGIN_DECLS #include <arch/types.h> #include <dc/maple.h> +#include <kos/regfield.h> #include <stdint.h> #include <time.h> @@ -537,39 +539,50 @@ int vmu_get_datetime(maple_device_t *dev, time_t *unix); @{ */ -#define VMU_DPAD_UP (0<<1) /**< \brief Up Dpad button on the VMU */ -#define VMU_DPAD_DOWN (1<<1) /**< \brief Down Dpad button on the VMU */ -#define VMU_DPAD_LEFT (2<<1) /**< \brief Left Dpad button on the VMU */ -#define VMU_DPAD_RIGHT (3<<1) /**< \brief Right Dpad button on the VMU */ -#define VMU_A (4<<1) /**< \brief 'A' button on the VMU */ -#define VMU_B (5<<1) /**< \brief 'B' button on the VMU */ -#define VMU_MODE (6<<1) /**< \brief Mode button on the VMU */ -#define VMU_SLEEP (7<<1) /**< \brief Sleep button on the VMU */ +#define VMU_DPAD_UP BIT(0) /**< Up Dpad button on the VMU */ +#define VMU_DPAD_DOWN BIT(1) /**< Down Dpad button on the VMU */ +#define VMU_DPAD_LEFT BIT(2) /**< Left Dpad button on the VMU */ +#define VMU_DPAD_RIGHT BIT(3) /**< Right Dpad button on the VMU */ +#define VMU_A BIT(4) /**< 'A' button on the VMU */ +#define VMU_B BIT(5) /**< 'B' button on the VMU */ +#define VMU_MODE BIT(6) /**< Mode button on the VMU */ +#define VMU_SLEEP BIT(7) /**< Sleep button on the VMU */ -/** \brief VMU's raw condition data: 0 = PRESSED, 1 = RELEASED */ -typedef struct vmu_cond { - uint8_t raw_buttons; /**< \brief Combined button mask */ - uint8_t dummy[3]; /**< \brief Unused response data */ -} vmu_cond_t; +/** \brief Represents the combined state of all VMU buttons. -/** \brief VMU's "civilized" state data: 0 = RELEASED, 1 = PRESSED + Button states values: + - `0`: Released + - `1`: Pressed \note The Dpad buttons are automatically reoriented for you depending on which direction the VMU is facing in a particular type of controller. */ -typedef union vmu_state { - uint8_t buttons; /**< \brief Combined button state mask */ +typedef union vmu_buttons { + uint8_t raw; /**< Combined button state mask */ struct { - uint8_t dpad_up: 1; /**< \brief Dpad Up button state */ - uint8_t dpad_down: 1; /**< \brief Dpad Down button state */ - uint8_t dpad_left: 1; /**< \brief Dpad Left button state */ - uint8_t dpad_right: 1; /**< \brief Dpad Right button state */ - uint8_t a: 1; /**< \brief 'A' button state */ - uint8_t b: 1; /**< \brief 'B' button state */ - uint8_t mode: 1; /**< \brief Mode button state */ - uint8_t sleep: 1; /**< \brief Sleep button state */ + uint8_t dpad_up: 1; /**< Dpad Up button state */ + uint8_t dpad_down: 1; /**< Dpad Down button state */ + uint8_t dpad_left: 1; /**< Dpad Left button state */ + uint8_t dpad_right: 1; /**< Dpad Right button state */ + uint8_t a: 1; /**< 'A' button state */ + uint8_t b: 1; /**< 'B' button state */ + uint8_t mode: 1; /**< Mode button state */ + uint8_t sleep: 1; /**< Sleep button state */ }; +} vmu_buttons_t; + +/** "Civilized" structure containing VMU's current state. + + \note + Don't forget that if you want valid button state information, you must + enable polling for it in the driver with vmu_set_buttons_enabled()! +*/ +typedef struct vmu_state { + struct { + vmu_buttons_t current; /**< Button states from the current frame */ + vmu_buttons_t previous; /**< Button states from the previous frame */ + } buttons; /**< Latest two frames of button state data */ } vmu_state_t; /** @} */ diff --git a/kernel/arch/dreamcast/util/fb_console.c b/kernel/arch/dreamcast/util/fb_console.c index 681978bf..8bd24ddb 100644 --- a/kernel/arch/dreamcast/util/fb_console.c +++ b/kernel/arch/dreamcast/util/fb_console.c @@ -8,7 +8,6 @@ #include <string.h> #include <errno.h> #include <kos/dbgio.h> -#include <kos/string.h> #include <dc/fb_console.h> #include <dc/biosfont.h> #include <dc/video.h> @@ -76,10 +75,10 @@ static int fb_write(int c) { /* If going down a line put us over the edge of the screen, move everything up a line, fixing the problem. */ if(cur_y + FONT_CHAR_HEIGHT > max_y) { - memcpy4(t + min_y * fb_w, t + (min_y + FONT_CHAR_HEIGHT) * fb_w, + memcpy(t + min_y * fb_w, t + (min_y + FONT_CHAR_HEIGHT) * fb_w, (cur_y - min_y - FONT_CHAR_HEIGHT) * fb_w * 2); cur_y -= FONT_CHAR_HEIGHT; - memset4(t + cur_y * fb_w, 0, FONT_CHAR_HEIGHT * fb_w * 2); + memset(t + cur_y * fb_w, 0, FONT_CHAR_HEIGHT * fb_w * 2); } } diff --git a/kernel/arch/dreamcast/util/fb_console_naomi.c b/kernel/arch/dreamcast/util/fb_console_naomi.c index 65264479..23a18571 100644 --- a/kernel/arch/dreamcast/util/fb_console_naomi.c +++ b/kernel/arch/dreamcast/util/fb_console_naomi.c @@ -8,7 +8,6 @@ #include <string.h> #include <errno.h> #include <kos/dbgio.h> -#include <kos/string.h> #include <dc/fb_console.h> #include <dc/video.h> #include <dc/minifont.h> @@ -78,10 +77,10 @@ static int fb_write(int c) { /* If going down a line put us over the edge of the screen, move everything up a line, fixing the problem. */ if(cur_y + FONT_CHAR_HEIGHT > max_y) { - memcpy4(t + min_y * fb_w, t + (min_y + FONT_CHAR_HEIGHT) * fb_w, + memcpy(t + min_y * fb_w, t + (min_y + FONT_CHAR_HEIGHT) * fb_w, (cur_y - min_y - FONT_CHAR_HEIGHT) * fb_w * 2); cur_y -= FONT_CHAR_HEIGHT; - memset4(t + cur_y * fb_w, 0, FONT_CHAR_HEIGHT * fb_w * 2); + memset(t + cur_y * fb_w, 0, FONT_CHAR_HEIGHT * fb_w * 2); } ...<truncated>... hooks/post-receive -- A pseudo Operating System for the Dreamcast. |