diff options
Diffstat (limited to 'backends/platform/psp/memory.cpp')
-rw-r--r-- | backends/platform/psp/memory.cpp | 66 |
1 files changed, 33 insertions, 33 deletions
diff --git a/backends/platform/psp/memory.cpp b/backends/platform/psp/memory.cpp index 9cf7ba7c6c..ba7645cf56 100644 --- a/backends/platform/psp/memory.cpp +++ b/backends/platform/psp/memory.cpp @@ -23,12 +23,12 @@ * */ -#include "common/scummsys.h" +#include "common/scummsys.h" #include "common/singleton.h" #include "common/list.h" #include "backends/platform/psp/psppixelformat.h" #include "backends/platform/psp/memory.h" - + // Class Copier -------------------------------------------------------------------------- //#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */ //#define __PSP_DEBUG_PRINT__ @@ -37,7 +37,7 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *format /* = NULL */) { DEBUG_ENTER_FUNC(); - + uint32 prefixDst = (((uint32)dst) & 0x3); prefixDst = prefixDst ? 4 - prefixDst : 0; // prefix only if we have address % 4 != 0 uint32 prefixSrc = (((uint32)src) & 0x3); @@ -47,11 +47,11 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form #ifdef __PSP_DEBUG_PRINT__ uint32 debugBytes = bytes; const byte *debugDst = dst, *debugSrc = src; -#endif +#endif uint32 words, remainingBytes; - + //PSP_DEBUG_PRINT("dst[%p], src[%p], bytes[%d], swap[%s], prefixDst[%u], prefixSrc[%u]\n", dst, src, bytes, swapRB ? "true" : "false", prefixDst, prefixSrc); - + if (prefixDst || prefixSrc) { // we're not aligned to word boundaries if (prefixDst != prefixSrc) { // worst case: we can never be aligned. this mode is highly inefficient. try to get engines not to use this mode too much PSP_DEBUG_PRINT("misaligned copy of %u bytes from %p to %p\n", bytes, src, dst); @@ -59,10 +59,10 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form copy8(dst, src, bytes); // no swap is possible on 8 bit else copy16((uint16 *)dst, (uint16 *)src, bytes, format); - - goto test; + + goto test; } - + // Do the prefix: the part to get us aligned if (prefixDst & 1) { // byte copy8(dst, src, prefixDst); // no swap available @@ -72,7 +72,7 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form if (bytes > prefixDst) // check that we can afford to subtract from bytes bytes -= prefixDst; else { - DEBUG_EXIT_FUNC(); + DEBUG_EXIT_FUNC(); return; } dst32 = (uint32 *)(dst + prefixDst); @@ -80,11 +80,11 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form } else { // We're aligned to word boundaries dst32 = (uint32 *)dst; src32 = (uint32 *)src; - } - + } + words = bytes >> 2; remainingBytes = bytes & 0x3; - + if (swapRB) { // need to swap for (; words > 0; words--) { *dst32 = format->swapRedBlue32(*src32); @@ -107,13 +107,13 @@ void Copier::copy(byte *dst, const byte *src, uint32 bytes, PSPPixelFormat *form copy16((uint16*)dst32, (uint16 *)src32, remainingBytes, format); } -test: +test: // debug #ifdef __PSP_DEBUG_PRINT__ bool mismatch = false; - for (uint32 i=0; i<debugBytes; i++) { - if (debugDst[i] != debugSrc[i]) { + for (uint32 i = 0; i < debugBytes; i++) { + if (debugDst[i] != debugSrc[i]) { if (mismatch == false) { PSP_DEBUG_PRINT_SAMELN("mismatch in copy:\n"); PSP_DEBUG_PRINT("dst[%p], src[%p], bytes[%u], swap[%s], prefixDst[%u], prefixSrc[%u]\n", debugDst, debugSrc, debugBytes, swapRB ? "true" : "false", prefixDst, prefixSrc); @@ -122,7 +122,7 @@ test: PSP_DEBUG_PRINT_SAMELN("%x!=%x ", debugSrc[i], debugDst[i]); } } - if (mismatch) + if (mismatch) PSP_DEBUG_PRINT("\n"); #endif @@ -134,7 +134,7 @@ inline void Copier::copy8(byte *dst, const byte *src, uint32 bytes) { *dst = *src; dst++; src++; - } + } } inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixelFormat *format /* = NULL */) { @@ -147,7 +147,7 @@ inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixe *dst = format->swapRedBlue16(*src); dst++; src++; - } + } } else { for (; shorts > 0 ; shorts--) { *dst = *src; @@ -158,8 +158,8 @@ inline void Copier::copy16(uint16 *dst, const uint16 *src, uint32 bytes, PSPPixe if (remainingBytes) *(byte *)dst = *(byte *)src; } - - + + // Class VramAllocator ----------------------------------- DECLARE_SINGLETON(VramAllocator) @@ -172,34 +172,34 @@ DECLARE_SINGLETON(VramAllocator) void *VramAllocator::allocate(int32 size, bool smallAllocation /* = false */) { DEBUG_ENTER_FUNC(); - assert (size > 0); - + assert(size > 0); + byte *lastAddress = smallAllocation ? (byte *)VRAM_SMALL_ADDRESS : (byte *)VRAM_START_ADDRESS; Common::List<Allocation>::iterator i; // Find a block that fits, starting from the beginning for (i = _allocList.begin(); i != _allocList.end(); ++i) { byte *currAddress = (*i).address; - + if (currAddress - lastAddress >= size) // We found a match break; - + if ((*i).getEnd() > lastAddress) lastAddress = (byte *)(*i).getEnd(); } if (lastAddress + size > (byte *)VRAM_END_ADDRESS) { PSP_DEBUG_PRINT("No space for allocation of %d bytes. %d bytes already allocated.\n", - size, _bytesAllocated); + size, _bytesAllocated); return NULL; } _allocList.insert(i, Allocation(lastAddress, size)); _bytesAllocated += size; - + PSP_DEBUG_PRINT("Allocated in VRAM, size %u at %p.\n", size, lastAddress); PSP_DEBUG_PRINT("Total allocated %u, remaining %u.\n", _bytesAllocated, (2 * 1024 * 1024) - _bytesAllocated); - + DEBUG_EXIT_FUNC(); return lastAddress; } @@ -208,9 +208,9 @@ void *VramAllocator::allocate(int32 size, bool smallAllocation /* = false */) { void VramAllocator::deallocate(void *address) { DEBUG_ENTER_FUNC(); address = (byte *)CACHED(address); // Make sure all addresses are the same - + Common::List<Allocation>::iterator i; - + // Find the Allocator to deallocate for (i = _allocList.begin(); i != _allocList.end(); ++i) { if ((*i).address == address) { @@ -220,8 +220,8 @@ void VramAllocator::deallocate(void *address) { DEBUG_EXIT_FUNC(); return; } - } - + } + PSP_DEBUG_PRINT("Address[%p] not allocated.\n", address); DEBUG_EXIT_FUNC(); -} +} |