From d9ca4f87ccfc9c17594e8baafde24516c08c80f4 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Wed, 22 Dec 2010 03:29:10 +0100 Subject: [PATCH] minor code trimming and reformatting --- Makefile | 6 ++ asmmemfuncs.h | 206 ------------------------------------------ getset.h | 71 ++++++--------- gfx.cpp | 2 +- memmap.cpp | 50 +++++------ memmap.h | 2 +- sa1.cpp | 12 +-- tile.cpp | 277 +++------------------------------------------------------ tile.h | 20 ----- 9 files changed, 81 insertions(+), 565 deletions(-) delete mode 100644 asmmemfuncs.h diff --git a/Makefile b/Makefile index 108d616..ebda569 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,11 @@ else ifeq ($(ARCH),i386) CONF_BUILD_ASM_SPC700?=0 CONF_BUILD_ASM_SA1?=0 CONF_BUILD_MISC_ROUTINES?=misc_i386 +else ifeq ($(ARCH),amd64) + CONF_BUILD_ASM_CPU?=0 + CONF_BUILD_ASM_SPC700?=0 + CONF_BUILD_ASM_SA1?=0 + CONF_BUILD_MISC_ROUTINES?=misc_amd64 endif # Hardware pixel doubling (in N8x0) CONF_XSP?=0 @@ -93,6 +98,7 @@ all: drnoksnes clean: rm -f drnoksnes *.o *.d platform/*.o platform/*.d rm -f build-stamp configure-stamp + echo "$(OBJS)" remake: clean deps all diff --git a/asmmemfuncs.h b/asmmemfuncs.h deleted file mode 100644 index b859d07..0000000 --- a/asmmemfuncs.h +++ /dev/null @@ -1,206 +0,0 @@ -#ifndef _ASMMEMFUNCS_H_ -#define _ASMMEMFUNCS_H_ - -#define memset32(_dst, _c, _count) \ -({ uint32_t *dst = (_dst); uint32_t c = (_c); int count = (_count); uint32_t dummy0, dummy1, dummy2; \ - __asm__ __volatile__ ( \ - " cmp %[count], #4\n" \ - " blt 2f\n" \ - " mov %[dummy0], %[c]\n" \ - " tst %[dst], #4\n" \ - " strne %[c], [%[dst]], #4\n" \ - " subne %[count], %[count], #1\n" \ - " tst %[dst], #8\n" \ - " stmneia %[dst]!, {%[dummy0], %[c]}\n" \ - " subne %[count], %[count], #2\n" \ - " mov %[dummy1], %[c]\n" \ - " mov %[dummy2], %[c]\n" \ - "1:\n"\ - " subs %[count], %[count], #4\n" \ - " stmgeia %[dst]!, {%[dummy0], %[dummy1], %[dummy2], %[c]}\n" \ - " bge 1b\n" \ - " add %[count], %[count], #4\n" \ - "2:\n"\ - " subs %[count], %[count], #1\n" \ - " strge %[c], [%[dst]], #4\n" \ - " subs %[count], %[count], #1\n" \ - " strge %[c], [%[dst]], #4\n" \ - " subs %[count], %[count], #1\n" \ - " strge %[c], [%[dst]], #4\n" \ - "\n" \ - : [dst] "+&r" (dst), [count] "+&r" (count), [dummy0] "=&r" (dummy0), [dummy1] "=&r" (dummy1), [dummy2] "=&r" (dummy2), [c] "+&r" (c) \ - : \ - : "cc", "memory" \ - ); _dst; \ -}) - -#define memset16(_dst, _c, _count) \ -({ uint16_t *dst = (_dst); uint16_t c = (_c); int count = (_count); uint32_t dummy0, dummy1, dummy2; \ - __asm__ __volatile__ ( \ - " cmp %[count], #2\n" \ - " blt 3f\n" \ - /* Alignment is known to be at least 16-bit */ \ - " tst %[dst], #2\n" \ - " strneh %[c], [%[dst]], #2\n" \ - " subne %[count], %[count], #1\n" \ - /* Now we are 32-bit aligned (need to upgrade 'c' to 32-bit )*/ \ - " orr %[c], %[c], %[c], asl #16\n" \ - " mov %[dummy0], %[c]\n" \ - " cmp %[count], #8\n" \ - " blt 2f\n" \ - " tst %[dst], #4\n" \ - " strne %[c], [%[dst]], #4\n" \ - " subne %[count], %[count], #2\n" \ - " tst %[dst], #8\n" \ - " stmneia %[dst]!, {%[dummy0], %[c]}\n" \ - " subne %[count], %[count], #4\n" \ - /* Now we are 128-bit aligned */ \ - " mov %[dummy1], %[c]\n" \ - " mov %[dummy2], %[c]\n" \ - "1:\n" /* Copy 4 32-bit values per loop iteration */ \ - " subs %[count], %[count], #8\n" \ - " stmgeia %[dst]!, {%[dummy0], %[dummy1], %[dummy2], %[c]}\n" \ - " bge 1b\n" \ - " add %[count], %[count], #8\n" \ - "2:\n" /* Copy up to 3 remaining 32-bit values */ \ - " tst %[count], #4\n" \ - " stmneia %[dst]!, {%[dummy0], %[c]}\n" \ - " tst %[count], #2\n" \ - " strne %[c], [%[dst]], #4\n" \ - " and %[count], %[count], #1\n" \ - "3:\n" /* Copy up to 1 remaining 16-bit value */ \ - " subs %[count], %[count], #1\n" \ - " strgeh %[c], [%[dst]], #2\n" \ - "\n" \ - : [dst] "+&r" (dst), [count] "+&r" (count), [dummy0] "=&r" (dummy0), [dummy1] "=&r" (dummy1), [dummy2] "=&r" (dummy2), [c] "+&r" (c) \ - : \ - : "cc", "memory" \ - ); _dst;\ -}) - -#define memcpy32(_dst, _src, _count) \ -({ uint32_t *dst = (_dst); uint32_t *src = (_src); int count = (_count); \ - __asm__ __volatile__ ( \ - " cmp %[count], #4\n" \ - " blt 2f\n" \ - " tst %[dst], #4\n" \ - " ldrne r4, [%[src]], #4\n" \ - " strne r4, [%[dst]], #4\n" \ - " subne %[count], %[count], #1\n" \ - " tst %[dst], #8\n" \ - " ldmneia %[src]!, {r4-r5}\n" \ - " stmneia %[dst]!, {r4-r5}\n" \ - " subne %[count], %[count], #2\n" \ - "1:\n" \ - " subs %[count], %[count], #4\n" \ - " ldmgeia %[src]!, {r4-r7}\n" \ - " stmgeia %[dst]!, {r4-r7}\n" \ - " bge 1b\n" \ - " add %[count], %[count], #4\n" \ - "2:\n" \ - " tst %[count], #2\n" \ - " ldmneia %[src]!, {r4-r5}\n" \ - " stmneia %[dst]!, {r4-r5}\n" \ - " tst %[count], #1\n" \ - " ldrne r4, [%[src]], #4\n" \ - " strne r4, [%[dst]], #4\n" \ - "\n" \ - : [dst] "+&r" (dst), [src] "+&r" (src), [count] "+&r" (count) \ - : \ - : "r4", "r5", "r6", "r7", "cc", "memory" \ - ); _dst; \ -}) - -#define memcpy16(_dst, _src, _count) \ -({ uint16_t *dst = (_dst); uint16_t *src = (_src); int count = (_count); uint32_t dummy0; \ - __asm__ __volatile__ ( \ - " cmp %[count], #2\n" \ - " blt 6f\n" \ - /* Alignment is known to be at least 16-bit */ \ - " tst %[dst], #2\n" \ - " ldrneh r4, [%[src]], #2\n" \ - " strneh r4, [%[dst]], #2\n" \ - " subne %[count], %[count], #1\n" \ - /* Now destination address is 32-bit aligned, still need to check whether */ \ - /* source is 32-bit aligned or not */ \ - " tst %[src], #2\n" \ - " bne 3f\n" \ - /* Both destination and source are 32-bit aligned */ \ - " cmp %[count], #8\n" \ - " blt 2f\n" \ - " tst %[dst], #4\n" \ - " ldrne r4, [%[src]], #4\n" \ - " strne r4, [%[dst]], #4\n" \ - " subne %[count], %[count], #2\n" \ - " tst %[dst], #8\n" \ - " ldmneia %[src]!, {r4-r5}\n" \ - " stmneia %[dst]!, {r4-r5}\n" \ - " subne %[count], %[count], #4\n" \ - /* Destination address is 128-bit aligned, source address is 32-bit aligned */ \ - "1: subs %[count], %[count], #8\n" \ - " ldmgeia %[src]!, {r4-r7}\n" \ - " stmgeia %[dst]!, {r4-r7}\n" \ - " bge 1b\n" \ - " add %[count], %[count], #8\n" \ - /* Copy up to 3 remaining aligned 32-bit values */ \ - "2: tst %[count], #4\n" \ - " ldmneia %[src]!, {r4-r5}\n" \ - " stmneia %[dst]!, {r4-r5}\n" \ - " tst %[count], #2\n" \ - " ldrne r4, [%[src]], #4\n" \ - " strne r4, [%[dst]], #4\n" \ - " and %[count], %[count], #1\n" \ - " b 6f\n" \ - /* Destination is 32-bit aligned, but source is only 16-bit aligned */ \ - "3: cmp %[count], #8\n" \ - " blt 5f\n" \ - " tst %[dst], #4\n" \ - " ldrneh r4, [%[src]], #2\n" \ - " ldrneh r5, [%[src]], #2\n" \ - " orrne r4, r4, r5, asl #16\n" \ - " strne r4, [%[dst]], #4\n" \ - " subne %[count], %[count], #2\n" \ - " tst %[dst], #8\n" \ - " ldrneh r4, [%[src]], #2\n" \ - " ldrne r5, [%[src]], #4\n" \ - " ldrneh r6, [%[src]], #2\n" \ - " orrne r4, r4, r5, asl #16\n" \ - " movne r5, r5, lsr #16\n" \ - " orrne r5, r5, r6, asl #16\n" \ - " stmneia %[dst]!, {r4-r5}\n" \ - " subne %[count], %[count], #4\n" \ - /* Destination is 128-bit aligned, but source is only 16-bit aligned */ \ - "4: subs %[count], %[count], #8\n" \ - " ldrgeh r4, [%[src]], #2\n" \ - " ldmgeia %[src]!, {r5-r7}\n" \ - " ldrgeh %[dummy0], [%[src]], #2\n" \ - " orrge r4, r4, r5, asl #16\n" \ - " movge r5, r5, lsr #16\n" \ - " orrge r5, r5, r6, asl #16\n" \ - " movge r6, r6, lsr #16\n" \ - " orrge r6, r6, r7, asl #16\n" \ - " movge r7, r7, lsr #16\n" \ - " orrge r7, r7, %[dummy0], asl #16\n" \ - " stmgeia %[dst]!, {r4-r7}\n" \ - " bge 4b\n" \ - " add %[count], %[count], #8\n" \ - /* Copy up to 6 remaining 16-bit values (to 32-bit aligned destination) */ \ - "5: subs %[count], %[count], #2\n" \ - " ldrgeh r4, [%[src]], #2\n" \ - " ldrgeh r5, [%[src]], #2\n" \ - " orrge r4, r4, r5, asl #16\n" \ - " strge r4, [%[dst]], #4\n" \ - " bge 5b\n" \ - " add %[count], %[count], #2\n" \ - /* Copy the last remaining 16-bit value if any */ \ - "6: subs %[count], %[count], #1\n" \ - " ldrgeh r4, [%[src]], #2\n" \ - " strgeh r4, [%[dst]], #2\n" \ - "\n" \ - : [dst] "+&r" (dst), [src] "+&r" (src), [count] "+&r" (count), [dummy0] "=&r" (dummy0) \ - : \ - : "r4", "r5", "r6", "r7", "cc", "memory" \ - ); _dst; \ -}) - -#endif diff --git a/getset.h b/getset.h index 26e2709..4d50803 100644 --- a/getset.h +++ b/getset.h @@ -61,25 +61,22 @@ INLINE uint8 S9xGetByte (uint32 Address) #ifdef __memcheck__ mem_check+=(Address>>16)+Address; #endif -#if defined(VAR_CYCLES) || defined(CPU_SHUTDOWN) - int block; - uint8 *GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#else - uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#endif - if (GetAddress >= (uint8 *) CMemory::MAP_LAST) - { + const int block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK; + uint8 *GetAddress = Memory.Map[block]; + + if (GetAddress >= (uint8 *) CMemory::MAP_LAST) + { #ifdef VAR_CYCLES - CPU.Cycles += Memory.MemorySpeed [block]; + CPU.Cycles += Memory.MemorySpeed [block]; #endif #ifdef CPU_SHUTDOWN - if (Memory.BlockIsRAM [block]) - CPU.WaitAddress = CPU.PCAtOpcodeStart; + if (Memory.BlockIsRAM [block]) + CPU.WaitAddress = CPU.PCAtOpcodeStart; #endif - return (*(GetAddress + (Address & 0xffff))); - } + return (*(GetAddress + (Address & 0xffff))); + } - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: #ifdef VAR_CYCLES @@ -147,16 +144,14 @@ INLINE uint16 S9xGetWord (uint32 Address) #ifdef __memcheck__ mem_check+=(Address>>16)+Address; #endif - if ((Address & 0x1fff) == 0x1fff) - { - return (S9xGetByte (Address) | (S9xGetByte (Address + 1) << 8)); - } -#if defined(VAR_CYCLES) || defined(CPU_SHUTDOWN) - int block; - uint8 *GetAddress = Memory.Map [block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#else - uint8 *GetAddress = Memory.Map [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#endif + if ((Address & 0x1fff) == 0x1fff) + { + return (S9xGetByte (Address) | (S9xGetByte (Address + 1) << 8)); + } + + const int block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK; + uint8 *GetAddress = Memory.Map[block]; + if (GetAddress >= (uint8 *) CMemory::MAP_LAST) { #ifdef VAR_CYCLES @@ -174,7 +169,7 @@ INLINE uint16 S9xGetWord (uint32 Address) #endif } - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: #ifdef VAR_CYCLES @@ -256,12 +251,8 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) #if defined(CPU_SHUTDOWN) CPU.WaitAddress = NULL; #endif -#if defined(VAR_CYCLES) - int block; - uint8 *SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)]; -#else - uint8 *SetAddress = Memory.WriteMap [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#endif + const int block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK; + uint8 *SetAddress = Memory.WriteMap[block]; if (SetAddress >= (uint8 *) CMemory::MAP_LAST) { @@ -285,7 +276,7 @@ INLINE void S9xSetByte (uint8 Byte, uint32 Address) return; } - switch ((int) SetAddress) + switch ((CMemory::Types)(intptr_t) SetAddress) { case CMemory::MAP_PPU: #ifdef VAR_CYCLES @@ -382,12 +373,8 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) #if defined(CPU_SHUTDOWN) CPU.WaitAddress = NULL; #endif -#if defined (VAR_CYCLES) - int block; - uint8 *SetAddress = Memory.WriteMap [block = ((Address >> MEMMAP_SHIFT) & MEMMAP_MASK)]; -#else - uint8 *SetAddress = Memory.WriteMap [(Address >> MEMMAP_SHIFT) & MEMMAP_MASK]; -#endif + const int block = (Address >> MEMMAP_SHIFT) & MEMMAP_MASK; + uint8 *SetAddress = Memory.WriteMap[block]; if (SetAddress >= (uint8 *) CMemory::MAP_LAST) { @@ -412,7 +399,7 @@ INLINE void S9xSetWord (uint16 Word, uint32 Address) return; } - switch ((int) SetAddress) + switch ((CMemory::Types)(intptr_t) SetAddress) { case CMemory::MAP_PPU: #ifdef VAR_CYCLES @@ -517,7 +504,7 @@ INLINE uint8 *GetBasePointer (uint32 Address) if (GetAddress >= (uint8 *) CMemory::MAP_LAST) return (GetAddress); - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: return (Memory.FillRAM - 0x2000); @@ -553,7 +540,7 @@ INLINE uint8 *S9xGetMemPointer (uint32 Address) if (GetAddress >= (uint8 *) CMemory::MAP_LAST) return (GetAddress + (Address & 0xffff)); - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: return (Memory.FillRAM - 0x2000 + (Address & 0xffff)); @@ -604,7 +591,7 @@ INLINE void S9xSetPCBase (uint32 Address) return; } - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: #ifdef VAR_CYCLES diff --git a/gfx.cpp b/gfx.cpp index 3a92def..50d29d0 100644 --- a/gfx.cpp +++ b/gfx.cpp @@ -1852,7 +1852,7 @@ void DrawBackground (uint32 BGMode, uint32 bg, uint8 Z1, uint8 Z2) Count = 8 - Offset; if (Count > Width) Count = Width; - s -= Offset * GFX_PIX_SIZE; + s -= Offset * GFX_PIX_SIZE; Tile = READ_2BYTES(t); GFX.Z1 = GFX.Z2 = depths [(Tile & 0x2000) >> 13]; diff --git a/memmap.cpp b/memmap.cpp index bb60d5c..9113f41 100644 --- a/memmap.cpp +++ b/memmap.cpp @@ -41,9 +41,7 @@ #include #include -#ifdef __linux -//#include -#endif +/* Do not reencode this file. There are special chars on it. */ #include "snes9x.h" #include "memmap.h" @@ -1008,34 +1006,34 @@ bool8_32 CMemory::LoadSRAM (const char *filename) bool8_32 CMemory::SaveSRAM (const char *filename) { - int size = Memory.SRAMSize ? - (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SRTC) - { - size += SRTC_SRAM_PAD; - S9xSRTCPreSaveState (); - } + size_t size = Memory.SRAMSize ? + (1 << (Memory.SRAMSize + 3)) * 128 : 0; - if (Settings.SDD1) - S9xSDD1SaveLoggedData (); + if (Settings.SRTC) + { + size += SRTC_SRAM_PAD; + S9xSRTCPreSaveState (); + } - if (size > 0x20000) - size = 0x20000; + if (Settings.SDD1) S9xSDD1SaveLoggedData (); - if (size && *Memory.ROMFilename) - { - FILE *file; - if ((file = fopen (filename, "wb"))) + if (size > 0x20000) size = 0x20000; + + if (size && *Memory.ROMFilename) { - fwrite ((char *) ::SRAM, size, 1, file); - fclose (file); -#if defined(__linux) - chown (filename, getuid (), getgid ()); -#endif - return (TRUE); - } + FILE *file; + if ((file = fopen (filename, "wb"))) + { + if (fwrite((char *) ::SRAM, size, 1, file) == size) { + fclose(file); + return TRUE; + } + fclose(file); + return FALSE; + } } - return (FALSE); + + return FALSE; } void CMemory::FixROMSpeed () diff --git a/memmap.h b/memmap.h index ac88162..aef517f 100644 --- a/memmap.h +++ b/memmap.h @@ -122,7 +122,7 @@ public: const char *ROMID (); const char *CompanyID (); - enum { + enum Types { MAP_PPU, MAP_CPU, MAP_DSP, MAP_LOROM_SRAM, MAP_HIROM_SRAM, MAP_NONE, MAP_DEBUG, MAP_C4, MAP_BWRAM, MAP_BWRAM_BITMAP, MAP_BWRAM_BITMAP2, MAP_SA1RAM, MAP_LAST diff --git a/sa1.cpp b/sa1.cpp index a313030..cac5fee 100644 --- a/sa1.cpp +++ b/sa1.cpp @@ -160,7 +160,7 @@ uint8 S9xSA1GetByte (uint32 address) if (GetAddress >= (uint8 *) CMemory::MAP_LAST) return (*(GetAddress + (address & 0xffff))); - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: return (S9xGetSA1 (address & 0xffff)); @@ -199,15 +199,15 @@ uint16 S9xSA1GetWord (uint32 address) void S9xSA1SetByte (uint8 byte, uint32 address) { - uint8 *Setaddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK]; + uint8 *SetAddress = SA1.WriteMap [(address >> MEMMAP_SHIFT) & MEMMAP_MASK]; - if (Setaddress >= (uint8 *) CMemory::MAP_LAST) + if (SetAddress >= (uint8 *) CMemory::MAP_LAST) { - *(Setaddress + (address & 0xffff)) = byte; + *(SetAddress + (address & 0xffff)) = byte; return; } - switch ((int) Setaddress) + switch ((CMemory::Types)(intptr_t) SetAddress) { case CMemory::MAP_PPU: S9xSetSA1 (byte, address & 0xffff); @@ -269,7 +269,7 @@ void S9xSA1SetPCBase (uint32 address) return; } - switch ((int) GetAddress) + switch ((CMemory::Types)(intptr_t) GetAddress) { case CMemory::MAP_PPU: SA1.PCBase = Memory.FillRAM - 0x2000; diff --git a/tile.cpp b/tile.cpp index d2198a9..5597a14 100644 --- a/tile.cpp +++ b/tile.cpp @@ -556,90 +556,6 @@ inline void WRITE_4PIXELSHI16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELSx2 (uint32 Offset, uint8 *Pixels) -{ - register uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [0] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELS_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) -{ - register uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELSx2x2 (uint32 Offset, uint8 *Pixels) -{ - register uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.Pitch + N * 2] = \ - Screen [GFX.Pitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.Pitch + N * 2] = \ - Depth [GFX.Pitch + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELS_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) -{ - register uint8 Pixel; - uint8 *Screen = GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [GFX.Pitch + N * 2] = \ - Screen [GFX.Pitch + N * 2 + 1] = (uint8) GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [GFX.Pitch + N * 2] = \ - Depth [GFX.Pitch + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - void DrawTile(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { TILE_PREAMBLE @@ -660,47 +576,6 @@ void DrawClippedTile(uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS, WRITE_4PIXELS_FLIPPED, 4) } -void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) -} - -void DrawClippedTilex2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELSx2, WRITE_4PIXELS_FLIPPEDx2, 8) -} - -void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) -} - -void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELSx2x2, WRITE_4PIXELS_FLIPPEDx2x2, 8) -} - void DrawLargePixel (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) @@ -715,7 +590,7 @@ void DrawLargePixel (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (((uint8) GFX.ScreenColors [pixel]), PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -735,7 +610,7 @@ INLINE void WRITE_4PIXELS16 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -755,90 +630,6 @@ INLINE void WRITE_4PIXELS16_FLIPPED (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16x2 (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELS16_FLIPPEDx2 (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELS16x2x2 (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.Pitch >> 1) + N * 2] = \ - Screen [(GFX.Pitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.Pitch >> 1) + N * 2] = \ - Depth [(GFX.Pitch >> 1) + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - -INLINE void WRITE_4PIXELS16_FLIPPEDx2x2 (uint32 Offset, uint8 *Pixels) -{ - register uint32 Pixel; - uint16 *Screen = (uint16 *) GFX.S + Offset; - uint8 *Depth = GFX.DB + Offset; - -#define FN(N) \ - if (GFX.Z1 > Depth [N * 2] && (Pixel = Pixels[3 - N])) \ - { \ - Screen [N * 2] = Screen [N * 2 + 1] = Screen [(GFX.Pitch >> 1) + N * 2] = \ - Screen [(GFX.Pitch >> 1) + N * 2 + 1] = GFX.ScreenColors [Pixel]; \ - Depth [N * 2] = Depth [N * 2 + 1] = Depth [(GFX.Pitch >> 1) + N * 2] = \ - Depth [(GFX.Pitch >> 1) + N * 2 + 1] = GFX.Z2; \ - } - - FN(0) - FN(1) - FN(2) - FN(3) -#undef FN -} - void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount) { @@ -859,46 +650,6 @@ void DrawClippedTile16 (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16, WRITE_4PIXELS16_FLIPPED, 4) } -void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) -} - -void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2, WRITE_4PIXELS16_FLIPPEDx2, 8) -} - -void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - RENDER_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) -} - -void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount) -{ - TILE_PREAMBLE - register uint8 *bp; - - TILE_CLIP_PREAMBLE - RENDER_CLIPPED_TILE(WRITE_4PIXELS16x2x2, WRITE_4PIXELS16_FLIPPEDx2x2, 8) -} - void DrawLargePixel16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount) @@ -912,7 +663,7 @@ void DrawLargePixel16 (uint32 Tile, uint32 Offset, RENDER_TILE_LARGE (GFX.ScreenColors [pixel], PLOT_PIXEL) } -INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -944,7 +695,7 @@ INLINE void WRITE_4PIXELS16_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -976,7 +727,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1008,7 +759,7 @@ INLINE void WRITE_4PIXELS16_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1040,7 +791,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADD1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1072,7 +823,7 @@ INLINE void WRITE_4PIXELS16_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1104,7 +855,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_SUB (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1136,7 +887,7 @@ INLINE void WRITE_4PIXELS16_SUB1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_SUB1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1249,7 +1000,7 @@ void DrawClippedTile16Sub1_2 (uint32 Tile, uint32 Offset, RENDER_CLIPPED_TILE(WRITE_4PIXELS16_SUB1_2, WRITE_4PIXELS16_FLIPPED_SUB1_2, 4) } -INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1275,7 +1026,7 @@ INLINE void WRITE_4PIXELS16_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1301,7 +1052,7 @@ INLINE void WRITE_4PIXELS16_FLIPPED_ADDF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; @@ -1327,7 +1078,7 @@ INLINE void WRITE_4PIXELS16_SUBF1_2 (uint32 Offset, uint8 *Pixels) #undef FN } -INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) +STATIC INLINE void WRITE_4PIXELS16_FLIPPED_SUBF1_2 (uint32 Offset, uint8 *Pixels) { register uint32 Pixel; uint16 *Screen = (uint16 *) GFX.S + Offset; diff --git a/tile.h b/tile.h index 6ba51f1..7bd9544 100644 --- a/tile.h +++ b/tile.h @@ -46,16 +46,6 @@ void DrawTile (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTilex2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount); -void DrawClippedTilex2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount); -void DrawTilex2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount); -void DrawClippedTilex2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount); void DrawLargePixel (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); @@ -65,16 +55,6 @@ void DrawTile16 (uint32 Tile, uint32 Offset, uint32 StartLine, void DrawClippedTile16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount); -void DrawTile16x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount); -void DrawClippedTile16x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount); -void DrawTile16x2x2 (uint32 Tile, uint32 Offset, uint32 StartLine, - uint32 LineCount); -void DrawClippedTile16x2x2 (uint32 Tile, uint32 Offset, - uint32 StartPixel, uint32 Width, - uint32 StartLine, uint32 LineCount); void DrawLargePixel16 (uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Pixels, uint32 StartLine, uint32 LineCount); -- 1.7.9.5