From 30d3269fbfc4456edd4d4d23f48396862911a223 Mon Sep 17 00:00:00 2001 From: Andrea Date: Sat, 12 Dec 2020 11:09:14 +0000 Subject: [PATCH] Remove a few more Win32 memory functions. (PR #888) CopyMemory, MoveMemory, FillMemory. --- source/DiskImageHelper.cpp | 8 ++++---- source/Harddisk.cpp | 2 +- source/Memory.cpp | 8 ++++---- source/Windows/WinVideo.cpp | 18 +++++++++--------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/source/DiskImageHelper.cpp b/source/DiskImageHelper.cpp index 66f3c061..f7778343 100644 --- a/source/DiskImageHelper.cpp +++ b/source/DiskImageHelper.cpp @@ -554,7 +554,7 @@ DWORD CImageBase::NibblizeTrack(LPBYTE trackimagebuffer, SectorOrder_e SectorOrd *(imageptr++) = 0xD5; *(imageptr++) = 0xAA; *(imageptr++) = 0xAD; - CopyMemory(imageptr, Code62(ms_SectorNumber[SectorOrder][sector]), 343); + memcpy(imageptr, Code62(ms_SectorNumber[SectorOrder][sector]), 343); imageptr += 343; *(imageptr++) = 0xDE; *(imageptr++) = 0xAA; @@ -575,9 +575,9 @@ DWORD CImageBase::NibblizeTrack(LPBYTE trackimagebuffer, SectorOrder_e SectorOrd void CImageBase::SkewTrack(const int nTrack, const int nNumNibbles, const LPBYTE pTrackImageBuffer) { int nSkewBytes = (nTrack*768) % nNumNibbles; - CopyMemory(m_pWorkBuffer, pTrackImageBuffer, nNumNibbles); - CopyMemory(pTrackImageBuffer, m_pWorkBuffer+nSkewBytes, nNumNibbles-nSkewBytes); - CopyMemory(pTrackImageBuffer+nNumNibbles-nSkewBytes, m_pWorkBuffer, nSkewBytes); + memcpy(m_pWorkBuffer, pTrackImageBuffer, nNumNibbles); + memcpy(pTrackImageBuffer, m_pWorkBuffer+nSkewBytes, nNumNibbles-nSkewBytes); + memcpy(pTrackImageBuffer+nNumNibbles-nSkewBytes, m_pWorkBuffer, nSkewBytes); } //------------------------------------- diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 6b3a7067..3bc27345 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -597,7 +597,7 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG } } - MoveMemory(pHDD->hd_buf, mem+pHDD->hd_memblock, HD_BLOCK_SIZE); + memmove(pHDD->hd_buf, mem+pHDD->hd_memblock, HD_BLOCK_SIZE); if (bRes) bRes = ImageWriteBlock(pHDD->imagehandle, pHDD->hd_diskblock, pHDD->hd_buf); diff --git a/source/Memory.cpp b/source/Memory.cpp index 7dd4e556..9c222f9d 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1132,7 +1132,7 @@ static void UpdatePaging(BOOL initialize) // SAVE THE CURRENT PAGING SHADOW TABLE LPBYTE oldshadow[256]; if (!initialize) - CopyMemory(oldshadow,memshadow,256*sizeof(LPBYTE)); + memcpy(oldshadow,memshadow,256*sizeof(LPBYTE)); // UPDATE THE PAGING TABLES BASED ON THE NEW PAGING SWITCH VALUES UINT loop; @@ -1245,10 +1245,10 @@ static void UpdatePaging(BOOL initialize) ((*(memdirty+loop) & 1) || (loop <= 1))) { *(memdirty+loop) &= ~1; - CopyMemory(oldshadow[loop],mem+(loop << 8),256); + memcpy(oldshadow[loop],mem+(loop << 8),256); } - CopyMemory(mem+(loop << 8),memshadow[loop],256); + memcpy(mem+(loop << 8),memshadow[loop],256); } } } @@ -1320,7 +1320,7 @@ static void BackMainImage(void) for (UINT loop = 0; loop < 256; loop++) { if (memshadow[loop] && ((*(memdirty+loop) & 1) || (loop <= 1))) - CopyMemory(memshadow[loop], mem+(loop << 8), 256); + memcpy(memshadow[loop], mem+(loop << 8), 256); *(memdirty+loop) &= ~1; } diff --git a/source/Windows/WinVideo.cpp b/source/Windows/WinVideo.cpp index c0d4e86e..a6152530 100644 --- a/source/Windows/WinVideo.cpp +++ b/source/Windows/WinVideo.cpp @@ -151,7 +151,7 @@ void VideoBenchmark () { DWORD totaltextfps = 0; g_uVideoMode = VF_TEXT; - FillMemory(mem+0x400,0x400,0x14); + memset(mem+0x400,0x14,0x400); VideoRedrawScreen(); DWORD milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; @@ -159,9 +159,9 @@ void VideoBenchmark () { DWORD cycle = 0; do { if (cycle & 1) - FillMemory(mem+0x400,0x400,0x14); + memset(mem+0x400,0x14,0x400); else - CopyMemory(mem+0x400,mem+((cycle & 2) ? 0x4000 : 0x6000),0x400); + memcpy(mem+0x400,mem+((cycle & 2) ? 0x4000 : 0x6000),0x400); VideoRefreshScreen(); if (cycle++ >= 3) cycle = 0; @@ -173,7 +173,7 @@ void VideoBenchmark () { // SIMULATE THE ACTIVITY OF AN AVERAGE GAME DWORD totalhiresfps = 0; g_uVideoMode = VF_HIRES; - FillMemory(mem+0x2000,0x2000,0x14); + memset(mem+0x2000,0x14,0x2000); VideoRedrawScreen(); milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; @@ -181,9 +181,9 @@ void VideoBenchmark () { cycle = 0; do { if (cycle & 1) - FillMemory(mem+0x2000,0x2000,0x14); + memset(mem+0x2000,0x14,0x2000); else - CopyMemory(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); + memcpy(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); VideoRefreshScreen(); if (cycle++ >= 3) cycle = 0; @@ -257,7 +257,7 @@ void VideoBenchmark () { // WITH FULL EMULATION OF THE CPU, JOYSTICK, AND DISK HAPPENING AT // THE SAME TIME DWORD realisticfps = 0; - FillMemory(mem+0x2000,0x2000,0xAA); + memset(mem+0x2000,0xAA,0x2000); VideoRedrawScreen(); milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; @@ -274,9 +274,9 @@ void VideoBenchmark () { } } if (cycle & 1) - FillMemory(mem+0x2000,0x2000,0xAA); + memset(mem+0x2000,0xAA,0x2000); else - CopyMemory(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); + memcpy(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); VideoRedrawScreen(); if (cycle++ >= 3) cycle = 0;