From 92aab4834b3a9a6b57c7470e2add9cb82ae330df Mon Sep 17 00:00:00 2001 From: rogerman Date: Wed, 18 May 2022 16:26:08 -0700 Subject: [PATCH] matrix.h: Fix some non-working AltiVec functions. This fixes setting the 2D layer's clear color and also setting an all-white/all-black master brightness level for AltiVec systems. --- desmume/src/matrix.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/desmume/src/matrix.h b/desmume/src/matrix.h index 1ab5cc3a5..def1faa71 100644 --- a/desmume/src/matrix.h +++ b/desmume/src/matrix.h @@ -697,9 +697,9 @@ static void memset_u16(void *dst, const u16 val, const size_t elementCount) v128u16 *dst_vec128 = (v128u16 *)dst; const size_t length_vec128 = elementCount / (sizeof(v128u16) / sizeof(u16)); - const v128u16 val_vec128 = (v128u16){val,val,val,val,val,val,val,val}; + v128u16 val_vec128 = (v128u16){val,val,val,val,val,val,val,val}; // Don't set as const, since vec_st() cannot store a const vector. for (size_t i = 0; i < length_vec128; i++) - vec_st(val_vec128, 0, dst_vec128 + i); + vec_st(val_vec128, i*sizeof(v128u16), dst_vec128); } template @@ -707,8 +707,8 @@ static void memset_u16_fast(void *dst, const u16 val) { v128u16 *dst_vec128 = (v128u16 *)dst; - const v128u16 val_vec128 = (v128u16){val,val,val,val,val,val,val,val}; - MACRODO_N(ELEMENTCOUNT / (sizeof(v128u16) / sizeof(u16)), vec_st(val_vec128, 0, dst_vec128 + (X))); + v128u16 val_vec128 = (v128u16){val,val,val,val,val,val,val,val}; // Don't set as const, since vec_st() cannot store a const vector. + MACRODO_N(ELEMENTCOUNT / (sizeof(v128u16) / sizeof(u16)), vec_st(val_vec128, (X)*sizeof(v128u16), dst_vec128)); } static void memset_u32(void *dst, const u32 val, const size_t elementCount) @@ -716,9 +716,9 @@ static void memset_u32(void *dst, const u32 val, const size_t elementCount) v128u32 *dst_vec128 = (v128u32 *)dst; const size_t length_vec128 = elementCount / (sizeof(v128u32) / sizeof(u32)); - const v128u32 val_vec128 = (v128u32){val,val,val,val}; + v128u32 val_vec128 = (v128u32){val,val,val,val}; // Don't set as const, since vec_st() cannot store a const vector. for (size_t i = 0; i < length_vec128; i++) - vec_st(val_vec128, 0, dst_vec128 + i); + vec_st(val_vec128, i*sizeof(v128u32), dst_vec128); } template @@ -726,8 +726,8 @@ static void memset_u32_fast(void *dst, const u32 val) { v128u32 *dst_vec128 = (v128u32 *)dst; - const v128u32 val_vec128 = (v128u32){val,val,val,val}; - MACRODO_N(ELEMENTCOUNT / (sizeof(v128u32) / sizeof(u32)), vec_st(val_vec128, 0, dst_vec128 + (X))); + v128u32 val_vec128 = (v128u32){val,val,val,val}; // Don't set as const, since vec_st() cannot store a const vector. + MACRODO_N(ELEMENTCOUNT / (sizeof(v128u32) / sizeof(u32)), vec_st(val_vec128, (X)*sizeof(v128u32), dst_vec128)); } template