From dc9963a431d175607890498819179210831fc23b Mon Sep 17 00:00:00 2001 From: sin365 <353374337@qq.com> Date: Wed, 4 Dec 2024 14:34:00 +0800 Subject: [PATCH] =?UTF-8?q?video=20cpu=E6=B8=B2=E6=9F=93=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/NesEmulator/VideoProvider.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs index f0963d1..495cf09 100644 --- a/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs +++ b/AxibugEmuOnline.Client/Assets/Script/NesEmulator/VideoProvider.cs @@ -57,8 +57,8 @@ namespace AxibugEmuOnline.Client public unsafe void SetDrawData(uint* screenData) { PrepareUI(screenData); - if (GPUTurbo) PrepareForGPU(screenData); - else PrepareForCPU(screenData); + if (GPUTurbo) PrepareForGPU(screenData);//判断使用GPU还是CPU + else PrepareForCPU(screenData);//使用CPU if (GPUTurbo) { @@ -144,6 +144,7 @@ namespace AxibugEmuOnline.Client for (int line = 0; line < PPU.SCREEN_HEIGHT; line++) { + //PS:如果是CPU计算,宽度减少16的不必要部分,才能对齐 width = PPU.SCREEN_WIDTH - 16; while (width > 0) @@ -151,14 +152,17 @@ namespace AxibugEmuOnline.Client var edx = screenData[pScn + 8]; uint index = edx & 0xFF; + //按下标颜色查找表中真实颜色 var colorData = palRaw[index]; //dst中颜色排列为abgr,而colorData排列为argb uint r = (colorData & 0x00FF0000) >> 16; // 提取Red通道 uint g = (colorData & 0x0000FF00) >> 8; // 提取Green通道 uint b = (colorData & 0x000000FF); // 提取Blue通道 + //用rgb构建颜色对象(如果非unity 可以用这个rgb 构建System.Drawing.Color 单个颜色对象) uint abgr = 0xFF000000 | (b << 16) | (g << 8) | (r << 0); + //放进颜色矩阵 Dst[pDst] = abgr; pScn += 1;