From 650c09af287ee6bacc9c53681bf83051350eedc8 Mon Sep 17 00:00:00 2001 From: cellos51 Date: Fri, 8 Aug 2025 09:54:24 -0400 Subject: [PATCH] Converted void to u16 in functions --- include/affine_background.h | 2 +- include/graphic_utils.h | 2 +- source/affine_background.c | 4 ++-- source/graphic_utils.c | 7 ++----- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/affine_background.h b/include/affine_background.h index 1b9ca4e..8e5f78f 100644 --- a/include/affine_background.h +++ b/include/affine_background.h @@ -12,6 +12,6 @@ void affine_background_init(); void affine_background_update(); void affine_background_set_color(COLOR color); // Must be called with an array of size at least AFFINE_BG_PAL_LEN -void affine_background_load_palette(const void *src); +void affine_background_load_palette(const u16 *src); #endif // AFFINE_BACKGROUND_H diff --git a/include/graphic_utils.h b/include/graphic_utils.h index 8160d81..79e0c61 100644 --- a/include/graphic_utils.h +++ b/include/graphic_utils.h @@ -127,6 +127,6 @@ void update_text_rect_to_right_align_num(Rect* rect, int num, int overflow_direc * This is useful because grit always loads the palette to the beginning of * pal_bg_mem[] */ -void memcpy16_tile8_with_palette_offset(void* dst, const void* src, uint hwcount, u8 palette_offset); +void memcpy16_tile8_with_palette_offset(u16* dst, const u16* src, uint hwcount, u8 palette_offset); #endif //GRAPHIC_UTILS_H diff --git a/source/affine_background.c b/source/affine_background.c index 66ddb3f..08ab9ee 100644 --- a/source/affine_background.c +++ b/source/affine_background.c @@ -8,7 +8,7 @@ AFF_SRC_EX asx = {32<<8, 64<<8, 120, 80, 0x0100, 0x0100, 0}; void affine_background_init() { - memcpy16_tile8_with_palette_offset(&tile8_mem[AFFINE_BG_CBB], affine_background_gfxTiles, affine_background_gfxTilesLen/2, AFFINE_BG_PB); + memcpy16_tile8_with_palette_offset((u16*)tile8_mem[AFFINE_BG_CBB], (const u16*)affine_background_gfxTiles, affine_background_gfxTilesLen/2, AFFINE_BG_PB); GRIT_CPY(&se_mem[AFFINE_BG_SBB], affine_background_gfxMap); affine_background_load_palette(affine_background_gfxPal); @@ -40,7 +40,7 @@ void affine_background_set_color(COLOR color) } } -void affine_background_load_palette(const void *src) +void affine_background_load_palette(const u16 *src) { memcpy16(&pal_bg_mem[AFFINE_BG_PB], src, AFFINE_BG_PAL_LEN); } \ No newline at end of file diff --git a/source/graphic_utils.c b/source/graphic_utils.c index 890cb33..931f674 100644 --- a/source/graphic_utils.c +++ b/source/graphic_utils.c @@ -168,14 +168,11 @@ void update_text_rect_to_right_align_num(Rect* rect, int num, int overflow_direc } } -void memcpy16_tile8_with_palette_offset(void* dst, const void* src, uint hwcount, u8 palette_offset) +void memcpy16_tile8_with_palette_offset(u16* dst, const u16* src, uint hwcount, u8 palette_offset) { - u16* dst16 = (u16*)dst; - const u16* src16 = (const u16*)src; - for (int i = 0; i < hwcount; i++) { // Copying u8 data twice across u16 data - dst16[i] = src16[i] + (((palette_offset) << 8) | (palette_offset)); + dst[i] = src[i] + (((palette_offset) << 8) | (palette_offset)); } } \ No newline at end of file