From 97d01a7325d9624a3b907f767a5b251c992cd47e Mon Sep 17 00:00:00 2001 From: fincs Date: Thu, 16 Feb 2017 13:48:40 +0100 Subject: [PATCH] GPUCMD_Add: allow NULL for adding zerofilled parameter data --- libctru/source/gpu/gpu.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libctru/source/gpu/gpu.c b/libctru/source/gpu/gpu.c index 7029622..e7b748c 100644 --- a/libctru/source/gpu/gpu.c +++ b/libctru/source/gpu/gpu.c @@ -57,23 +57,20 @@ void GPUCMD_FlushAndRun(void) void GPUCMD_Add(u32 header, const u32* param, u32 paramlength) { - u32 zero=0x0; - - if(!param || !paramlength) - { - paramlength=1; - param=&zero; - } - + if(!paramlength)paramlength=1; if(!gpuCmdBuf || gpuCmdBufOffset+paramlength+1>gpuCmdBufSize)return; paramlength--; header|=(paramlength&0x7ff)<<20; - gpuCmdBuf[gpuCmdBufOffset]=param[0]; + gpuCmdBuf[gpuCmdBufOffset]=param ? param[0] : 0; gpuCmdBuf[gpuCmdBufOffset+1]=header; - if(paramlength)memcpy(&gpuCmdBuf[gpuCmdBufOffset+2], ¶m[1], paramlength*4); + if(paramlength) + { + if(param)memcpy(&gpuCmdBuf[gpuCmdBufOffset+2], ¶m[1], paramlength*4); + else memset(&gpuCmdBuf[gpuCmdBufOffset+2], 0, paramlength*4); + } gpuCmdBufOffset+=paramlength+2;