mirror of https://github.com/snes9xgit/snes9x.git
commit
bf4e6f8b62
|
@ -5,17 +5,6 @@
|
|||
#include "../../resampler.h"
|
||||
#include "../../../msu1.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define inline inline
|
||||
#define alwaysinline inline __attribute__((always_inline))
|
||||
#elif defined(_MSC_VER)
|
||||
#define inline inline
|
||||
#define alwaysinline inline __forceinline
|
||||
#else
|
||||
#define inline inline
|
||||
#define alwaysinline inline
|
||||
#endif
|
||||
|
||||
#define debugvirtual
|
||||
|
||||
namespace SNES
|
||||
|
|
|
@ -74,15 +74,6 @@ uint32_t gradientARGB(uint32_t pixFront, uint32_t pixBack) //find intermediate c
|
|||
//
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FORCE_INLINE __forceinline
|
||||
#elif defined __GNUC__
|
||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||
#else
|
||||
#define FORCE_INLINE inline
|
||||
#endif
|
||||
|
||||
|
||||
enum RotationDegree //clock-wise
|
||||
{
|
||||
ROT_0,
|
||||
|
@ -268,7 +259,7 @@ input kernel area naming convention:
|
|||
-----------------
|
||||
*/
|
||||
template <class ColorDistance>
|
||||
FORCE_INLINE //detect blend direction
|
||||
alwaysinline //detect blend direction
|
||||
BlendResult preProcessCorners(const Kernel_4x4& ker, const xbrz::ScalerCfg& cfg) //result: F, G, J, K corners of "GradientType"
|
||||
{
|
||||
BlendResult result = {};
|
||||
|
@ -378,7 +369,7 @@ input kernel area naming convention:
|
|||
-------------
|
||||
*/
|
||||
template <class Scaler, class ColorDistance, RotationDegree rotDeg>
|
||||
FORCE_INLINE //perf: quite worth it!
|
||||
alwaysinline //perf: quite worth it!
|
||||
void blendPixel(const Kernel_3x3& ker,
|
||||
uint32_t* target, int trgWidth,
|
||||
unsigned char blendInfo, //result of preprocessing all four corners of pixel "e"
|
||||
|
|
4
gfx.cpp
4
gfx.cpp
|
@ -2134,10 +2134,10 @@ void S9xDrawCrosshair (const char *crosshair, uint8 fgcolor, uint8 bgcolor, int1
|
|||
uint8 p = crosshair[(r / rx) * 15 + (c / cx)];
|
||||
|
||||
if (p == '#' && fgcolor)
|
||||
*s = (fgcolor & 0x10) ? COLOR_ADD1_2(fg, *s) : fg;
|
||||
*s = (fgcolor & 0x10) ? COLOR_ADD::fn1_2(fg, *s) : fg;
|
||||
else
|
||||
if (p == '.' && bgcolor)
|
||||
*s = (bgcolor & 0x10) ? COLOR_ADD1_2(*s, bg) : bg;
|
||||
*s = (bgcolor & 0x10) ? COLOR_ADD::fn1_2(*s, bg) : bg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
107
gfx.h
107
gfx.h
|
@ -127,60 +127,77 @@ extern struct SGFX GFX;
|
|||
#define V_FLIP 0x8000
|
||||
#define BLANK_TILE 2
|
||||
|
||||
#define COLOR_ADD1_2(C1, C2) \
|
||||
((((((C1) & RGB_REMOVE_LOW_BITS_MASK) + \
|
||||
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1) + \
|
||||
((C1) & (C2) & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK)
|
||||
#define COLOR_ADD_BRIGHTNESS1_2 COLOR_ADD1_2
|
||||
|
||||
inline uint16 COLOR_ADD_BRIGHTNESS(uint16 C1, uint16 C2)
|
||||
struct COLOR_ADD
|
||||
{
|
||||
return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) |
|
||||
(brightness_cap[((C1 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
|
||||
// Proper 15->16bit color conversion moves the high bit of green into the low bit.
|
||||
#if GREEN_SHIFT_BITS == 6
|
||||
((brightness_cap[((C1 >> 6) & 0x1f) + ((C2 >> 6) & 0x1f)] & 0x10) << 1) |
|
||||
#endif
|
||||
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
|
||||
}
|
||||
static alwaysinline uint16 fn(uint16 C1, uint16 C2)
|
||||
{
|
||||
const int RED_MASK = 0x1F << RED_SHIFT_BITS;
|
||||
const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS;
|
||||
const int BLUE_MASK = 0x1F;
|
||||
|
||||
inline uint16 COLOR_ADD(uint16 C1, uint16 C2)
|
||||
int rb = C1 & (RED_MASK | BLUE_MASK);
|
||||
rb += C2 & (RED_MASK | BLUE_MASK);
|
||||
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||
int g = (C1 & (GREEN_MASK)) + (C2 & (GREEN_MASK));
|
||||
int rgbsaturate = (((g & (0x20 << GREEN_SHIFT_BITS)) | rbcarry) >> 5) * 0x1f;
|
||||
uint16 retval = (rb & (RED_MASK | BLUE_MASK)) | (g & GREEN_MASK) | rgbsaturate;
|
||||
#if GREEN_SHIFT_BITS == 6
|
||||
retval |= (retval & 0x0400) >> 5;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
|
||||
{
|
||||
return ((((C1 & RGB_REMOVE_LOW_BITS_MASK) +
|
||||
(C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1) +
|
||||
(C1 & C2 & RGB_LOW_BITS_MASK)) | ALPHA_BITS_MASK;
|
||||
}
|
||||
};
|
||||
|
||||
struct COLOR_ADD_BRIGHTNESS
|
||||
{
|
||||
const int RED_MASK = 0x1F << RED_SHIFT_BITS;
|
||||
const int GREEN_MASK = 0x1F << GREEN_SHIFT_BITS;
|
||||
const int BLUE_MASK = 0x1F;
|
||||
static alwaysinline uint16 fn(uint16 C1, uint16 C2)
|
||||
{
|
||||
return ((brightness_cap[ (C1 >> RED_SHIFT_BITS) + (C2 >> RED_SHIFT_BITS) ] << RED_SHIFT_BITS) |
|
||||
(brightness_cap[((C1 >> GREEN_SHIFT_BITS) & 0x1f) + ((C2 >> GREEN_SHIFT_BITS) & 0x1f)] << GREEN_SHIFT_BITS) |
|
||||
// Proper 15->16bit color conversion moves the high bit of green into the low bit.
|
||||
#if GREEN_SHIFT_BITS == 6
|
||||
((brightness_cap[((C1 >> 6) & 0x1f) + ((C2 >> 6) & 0x1f)] & 0x10) << 1) |
|
||||
#endif
|
||||
(brightness_cap[ (C1 & 0x1f) + (C2 & 0x1f)] ));
|
||||
}
|
||||
|
||||
int rb = C1 & (RED_MASK | BLUE_MASK);
|
||||
rb += C2 & (RED_MASK | BLUE_MASK);
|
||||
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||
int g = (C1 & (GREEN_MASK)) + (C2 & (GREEN_MASK));
|
||||
int rgbsaturate = (((g & (0x20 << GREEN_SHIFT_BITS)) | rbcarry) >> 5) * 0x1f;
|
||||
uint16 retval = (rb & (RED_MASK | BLUE_MASK)) | (g & GREEN_MASK) | rgbsaturate;
|
||||
#if GREEN_SHIFT_BITS == 6
|
||||
retval |= (retval & 0x0400) >> 5;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
|
||||
{
|
||||
return COLOR_ADD::fn1_2(C1, C2);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define COLOR_SUB1_2(C1, C2) \
|
||||
GFX.ZERO[(((C1) | RGB_HI_BITS_MASKx2) - \
|
||||
((C2) & RGB_REMOVE_LOW_BITS_MASK)) >> 1]
|
||||
|
||||
inline uint16 COLOR_SUB (uint16 C1, uint16 C2)
|
||||
struct COLOR_SUB
|
||||
{
|
||||
int rb1 = (C1 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | ((0x20 << 0) | (0x20 << RED_SHIFT_BITS));
|
||||
int rb2 = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK);
|
||||
int rb = rb1 - rb2;
|
||||
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||
int g = ((C1 & (SECOND_COLOR_MASK)) | (0x20 << GREEN_SHIFT_BITS)) - (C2 & (SECOND_COLOR_MASK));
|
||||
int rgbsaturate = (((g & (0x20 << GREEN_SHIFT_BITS)) | rbcarry) >> 5) * 0x1f;
|
||||
uint16 retval = ((rb & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | (g & SECOND_COLOR_MASK)) & rgbsaturate;
|
||||
static alwaysinline uint16 fn(uint16 C1, uint16 C2)
|
||||
{
|
||||
int rb1 = (C1 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | ((0x20 << 0) | (0x20 << RED_SHIFT_BITS));
|
||||
int rb2 = C2 & (THIRD_COLOR_MASK | FIRST_COLOR_MASK);
|
||||
int rb = rb1 - rb2;
|
||||
int rbcarry = rb & ((0x20 << RED_SHIFT_BITS) | (0x20 << 0));
|
||||
int g = ((C1 & (SECOND_COLOR_MASK)) | (0x20 << GREEN_SHIFT_BITS)) - (C2 & (SECOND_COLOR_MASK));
|
||||
int rgbsaturate = (((g & (0x20 << GREEN_SHIFT_BITS)) | rbcarry) >> 5) * 0x1f;
|
||||
uint16 retval = ((rb & (THIRD_COLOR_MASK | FIRST_COLOR_MASK)) | (g & SECOND_COLOR_MASK)) & rgbsaturate;
|
||||
#if GREEN_SHIFT_BITS == 6
|
||||
retval |= (retval & 0x0400) >> 5;
|
||||
retval |= (retval & 0x0400) >> 5;
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static alwaysinline uint16 fn1_2(uint16 C1, uint16 C2)
|
||||
{
|
||||
return GFX.ZERO[((C1 | RGB_HI_BITS_MASKx2) -
|
||||
(C2 & RGB_REMOVE_LOW_BITS_MASK)) >> 1];
|
||||
}
|
||||
};
|
||||
|
||||
void S9xStartScreenRefresh (void);
|
||||
void S9xEndScreenRefresh (void);
|
||||
|
|
|
@ -350,6 +350,9 @@ srcs += [
|
|||
'../debug.cpp',
|
||||
'../sdd1.cpp',
|
||||
'../tile.cpp',
|
||||
'../tileimpl-n1x1.cpp',
|
||||
'../tileimpl-n2x1.cpp',
|
||||
'../tileimpl-h2x1.cpp',
|
||||
'../srtc.cpp',
|
||||
'../gfx.cpp',
|
||||
'../memmap.cpp',
|
||||
|
|
|
@ -52,6 +52,9 @@ SOURCES_CXX := $(CORE_DIR)/apu/apu.cpp \
|
|||
$(CORE_DIR)/spc7110.cpp \
|
||||
$(CORE_DIR)/srtc.cpp \
|
||||
$(CORE_DIR)/tile.cpp \
|
||||
$(CORE_DIR)/tileimpl-n1x1.cpp \
|
||||
$(CORE_DIR)/tileimpl-n2x1.cpp \
|
||||
$(CORE_DIR)/tileimpl-h2x1.cpp \
|
||||
$(CORE_DIR)/sha256.cpp \
|
||||
$(CORE_DIR)/bml.cpp \
|
||||
$(CORE_DIR)/movie.cpp \
|
||||
|
|
|
@ -245,6 +245,7 @@
|
|||
<ClInclude Include="..\srtc.h" />
|
||||
<ClInclude Include="..\stream.h" />
|
||||
<ClInclude Include="..\tile.h" />
|
||||
<ClInclude Include="..\tileimpl.h" />
|
||||
<ClInclude Include="libretro.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -308,6 +309,9 @@
|
|||
<ClCompile Include="..\srtc.cpp" />
|
||||
<ClCompile Include="..\stream.cpp" />
|
||||
<ClCompile Include="..\tile.cpp" />
|
||||
<ClCompile Include="..\tileimpl-n1x1.cpp" />
|
||||
<ClCompile Include="..\tileimpl-n2x1.cpp" />
|
||||
<ClCompile Include="..\tileimpl-h2x1.cpp" />
|
||||
<ClCompile Include="libretro.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
@ -147,6 +147,9 @@
|
|||
<ClInclude Include="..\tile.h">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\tileimpl.h">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\apu\apu.h">
|
||||
<Filter>s9x-source\APU</Filter>
|
||||
</ClInclude>
|
||||
|
@ -329,6 +332,15 @@
|
|||
<ClCompile Include="..\tile.cpp">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-n1x1.cpp">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-n2x1.cpp">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-h2x1.cpp">
|
||||
<Filter>s9x-source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\apu\apu.cpp">
|
||||
<Filter>s9x-source\APU</Filter>
|
||||
</ClCompile>
|
||||
|
@ -357,4 +369,4 @@
|
|||
<Filter>s9x-source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -132,6 +132,9 @@
|
|||
<ClCompile Include="..\..\..\srtc.cpp" />
|
||||
<ClCompile Include="..\..\..\stream.cpp" />
|
||||
<ClCompile Include="..\..\..\tile.cpp" />
|
||||
<ClCompile Include="..\..\..\tileimpl-n1x1.cpp" />
|
||||
<ClCompile Include="..\..\..\tileimpl-n2x1.cpp" />
|
||||
<ClCompile Include="..\..\..\tileimpl-h2x1.cpp" />
|
||||
<ClCompile Include="..\..\libretro.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
|
|
@ -189,5 +189,14 @@
|
|||
<ClCompile Include="..\..\..\tile.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\tileimpl-n1x1.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\tileimpl-n2x1.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\tileimpl-h2x1.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -59,6 +59,18 @@
|
|||
BF0B3A011FA5816D002B04D3 /* snes.hpp in Headers */ = {isa = PBXBuildFile; fileRef = BF0B39AB1FA5792F002B04D3 /* snes.hpp */; };
|
||||
BF0B3A041FA58172002B04D3 /* resampler.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B39AD1FA5792F002B04D3 /* resampler.h */; };
|
||||
BF0B3A051FA58172002B04D3 /* resampler.h in Headers */ = {isa = PBXBuildFile; fileRef = BF0B39AD1FA5792F002B04D3 /* resampler.h */; };
|
||||
CE6E9065227D5E0F00C3FFC6 /* tileimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CE6E9064227D5E0F00C3FFC6 /* tileimpl.h */; };
|
||||
CE6E9066227D5E0F00C3FFC6 /* tileimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CE6E9064227D5E0F00C3FFC6 /* tileimpl.h */; };
|
||||
CE6E9067227D5E0F00C3FFC6 /* tileimpl.h in Headers */ = {isa = PBXBuildFile; fileRef = CE6E9064227D5E0F00C3FFC6 /* tileimpl.h */; };
|
||||
CE6E906B227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9068227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp */; };
|
||||
CE6E906C227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9068227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp */; };
|
||||
CE6E906D227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9068227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp */; };
|
||||
CE6E906E227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9069227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp */; };
|
||||
CE6E906F227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9069227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp */; };
|
||||
CE6E9070227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E9069227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp */; };
|
||||
CE6E9071227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E906A227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp */; };
|
||||
CE6E9072227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E906A227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp */; };
|
||||
CE6E9073227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CE6E906A227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp */; };
|
||||
CF047D38109D0E0600FD0754 /* 65c816.h in Headers */ = {isa = PBXBuildFile; fileRef = EAE0615A0526CCB900A80003 /* 65c816.h */; };
|
||||
CF047D3B109D0E0600FD0754 /* bsx.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2F381A09B17E9E0078DCA7 /* bsx.h */; };
|
||||
CF047D3C109D0E0600FD0754 /* c4.h in Headers */ = {isa = PBXBuildFile; fileRef = EAE061600526CCB900A80003 /* c4.h */; };
|
||||
|
@ -728,6 +740,10 @@
|
|||
BF0B39AD1FA5792F002B04D3 /* resampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = resampler.h; sourceTree = "<group>"; };
|
||||
BF0B39DE1FA580F9002B04D3 /* msu1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = msu1.cpp; sourceTree = "<group>"; };
|
||||
BF0B39E21FA58124002B04D3 /* msu1.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msu1.h; sourceTree = "<group>"; };
|
||||
CE6E9064227D5E0F00C3FFC6 /* tileimpl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tileimpl.h; sourceTree = "<group>"; };
|
||||
CE6E9068227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "tileimpl-h2x1.cpp"; sourceTree = "<group>"; };
|
||||
CE6E9069227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "tileimpl-n2x1.cpp"; sourceTree = "<group>"; };
|
||||
CE6E906A227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "tileimpl-n1x1.cpp"; sourceTree = "<group>"; };
|
||||
CF047E15109D0E0600FD0754 /* Snes9x (i386).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Snes9x (i386).app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
CF047E17109D0E0600FD0754 /* Info_i386.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info_i386.plist; sourceTree = "<group>"; };
|
||||
CF0567660CF98E7E00C7877C /* Snes9x.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Snes9x.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
|
@ -1224,6 +1240,7 @@
|
|||
EAE061EA0526CCB900A80003 /* srtc.h */,
|
||||
CFA82C3D0F1B43A60089C17F /* srtcemu.h */,
|
||||
EAE061EC0526CCB900A80003 /* tile.h */,
|
||||
CE6E9064227D5E0F00C3FFC6 /* tileimpl.h */,
|
||||
EA2F380F09B17E070078DCA7 /* bsx.cpp */,
|
||||
EAE0615F0526CCB900A80003 /* c4.cpp */,
|
||||
EAE061610526CCB900A80003 /* c4emu.cpp */,
|
||||
|
@ -1269,6 +1286,9 @@
|
|||
EAE061E90526CCB900A80003 /* srtc.cpp */,
|
||||
CFA82C3E0F1B43A60089C17F /* srtcemu.cpp */,
|
||||
EAE061EB0526CCB900A80003 /* tile.cpp */,
|
||||
CE6E9068227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp */,
|
||||
CE6E906A227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp */,
|
||||
CE6E9069227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp */,
|
||||
BF0B39791FA5792F002B04D3 /* apu */,
|
||||
CF5553B00EA24C36005957E4 /* filter */,
|
||||
EAA7B5D807609F76001BAB8B /* jma */,
|
||||
|
@ -1417,6 +1437,7 @@
|
|||
CF047D51109D0E0600FD0754 /* missing.h in Headers */,
|
||||
CF047D52109D0E0600FD0754 /* movie.h in Headers */,
|
||||
CF047D53109D0E0600FD0754 /* obc1.h in Headers */,
|
||||
CE6E9066227D5E0F00C3FFC6 /* tileimpl.h in Headers */,
|
||||
CF047D54109D0E0600FD0754 /* pixform.h in Headers */,
|
||||
CF047D55109D0E0600FD0754 /* port.h in Headers */,
|
||||
CF047D56109D0E0600FD0754 /* ppu.h in Headers */,
|
||||
|
@ -1603,6 +1624,7 @@
|
|||
CF0566E30CF98E7E00C7877C /* mac-netplay.h in Headers */,
|
||||
CF0566E40CF98E7E00C7877C /* mac-os.h in Headers */,
|
||||
CF0566E50CF98E7E00C7877C /* mac-prefs.h in Headers */,
|
||||
CE6E9065227D5E0F00C3FFC6 /* tileimpl.h in Headers */,
|
||||
CF0566E60CF98E7E00C7877C /* mac-quicktime.h in Headers */,
|
||||
BF0B39B81FA5792F002B04D3 /* SPC_DSP.h in Headers */,
|
||||
CF0566E70CF98E7E00C7877C /* mac-render.h in Headers */,
|
||||
|
@ -1653,6 +1675,7 @@
|
|||
CF2F462B1095EE72007D33FA /* missing.h in Headers */,
|
||||
CF2F462C1095EE72007D33FA /* movie.h in Headers */,
|
||||
CF2F462D1095EE72007D33FA /* obc1.h in Headers */,
|
||||
CE6E9067227D5E0F00C3FFC6 /* tileimpl.h in Headers */,
|
||||
CF2F462E1095EE72007D33FA /* pixform.h in Headers */,
|
||||
CF2F462F1095EE72007D33FA /* port.h in Headers */,
|
||||
CF2F46301095EE72007D33FA /* ppu.h in Headers */,
|
||||
|
@ -1981,6 +2004,7 @@
|
|||
CF047DD5109D0E0600FD0754 /* snapshot.cpp in Sources */,
|
||||
CF047DD8109D0E0600FD0754 /* spc7110.cpp in Sources */,
|
||||
CF047DD9109D0E0600FD0754 /* srtc.cpp in Sources */,
|
||||
CE6E906C227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */,
|
||||
CF047DDA109D0E0600FD0754 /* tile.cpp in Sources */,
|
||||
CF047DDB109D0E0600FD0754 /* 2xsai.cpp in Sources */,
|
||||
CF047DDC109D0E0600FD0754 /* blit.cpp in Sources */,
|
||||
|
@ -2013,11 +2037,13 @@
|
|||
CF047DF3109D0E0600FD0754 /* mac-dialog.cpp in Sources */,
|
||||
CF047DF4109D0E0600FD0754 /* mac-file.cpp in Sources */,
|
||||
CF047DF5109D0E0600FD0754 /* mac-gworld.cpp in Sources */,
|
||||
CE6E9072227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */,
|
||||
CF047DF6109D0E0600FD0754 /* mac-joypad.cpp in Sources */,
|
||||
CF047DF7109D0E0600FD0754 /* mac-keyboard.cpp in Sources */,
|
||||
CF047DF8109D0E0600FD0754 /* mac-multicart.cpp in Sources */,
|
||||
CF047DF9109D0E0600FD0754 /* mac-musicbox.mm in Sources */,
|
||||
CF047DFA109D0E0600FD0754 /* mac-netplay.cpp in Sources */,
|
||||
CE6E906F227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */,
|
||||
CF047DFB109D0E0600FD0754 /* mac-os.mm in Sources */,
|
||||
CF047DFC109D0E0600FD0754 /* mac-prefs.cpp in Sources */,
|
||||
CF047DFD109D0E0600FD0754 /* mac-quicktime.cpp in Sources */,
|
||||
|
@ -2037,6 +2063,7 @@
|
|||
CF0567040CF98E7E00C7877C /* c4.cpp in Sources */,
|
||||
CF0567050CF98E7E00C7877C /* c4emu.cpp in Sources */,
|
||||
CF0567060CF98E7E00C7877C /* cheats.cpp in Sources */,
|
||||
CE6E906B227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */,
|
||||
BF0B39AF1FA5792F002B04D3 /* apu.cpp in Sources */,
|
||||
CF0567070CF98E7E00C7877C /* cheats2.cpp in Sources */,
|
||||
CF0567080CF98E7E00C7877C /* clip.cpp in Sources */,
|
||||
|
@ -2055,6 +2082,7 @@
|
|||
CF5D3E250FAFD35400340007 /* dsp4.cpp in Sources */,
|
||||
CFE7FBB40D2F67BA002F3102 /* fxemu.cpp in Sources */,
|
||||
CF0567120CF98E7E00C7877C /* fxinst.cpp in Sources */,
|
||||
CE6E9071227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */,
|
||||
CF0567130CF98E7E00C7877C /* gfx.cpp in Sources */,
|
||||
CF0567140CF98E7E00C7877C /* globals.cpp in Sources */,
|
||||
CF0567150CF98E7E00C7877C /* loadzip.cpp in Sources */,
|
||||
|
@ -2077,6 +2105,7 @@
|
|||
CF0567270CF98E7E00C7877C /* spc7110.cpp in Sources */,
|
||||
CF0567280CF98E7E00C7877C /* srtc.cpp in Sources */,
|
||||
CF0567290CF98E7E00C7877C /* tile.cpp in Sources */,
|
||||
CE6E906E227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */,
|
||||
CF5553C90EA24C36005957E4 /* 2xsai.cpp in Sources */,
|
||||
CF5553CB0EA24C36005957E4 /* blit.cpp in Sources */,
|
||||
CF5553CD0EA24C36005957E4 /* epx.cpp in Sources */,
|
||||
|
@ -2171,6 +2200,7 @@
|
|||
CF2F46AF1095EE72007D33FA /* snapshot.cpp in Sources */,
|
||||
CF2F46B21095EE72007D33FA /* spc7110.cpp in Sources */,
|
||||
CF2F46B31095EE72007D33FA /* srtc.cpp in Sources */,
|
||||
CE6E906D227D5E1E00C3FFC6 /* tileimpl-h2x1.cpp in Sources */,
|
||||
CF2F46B41095EE72007D33FA /* tile.cpp in Sources */,
|
||||
CF2F46B51095EE72007D33FA /* 2xsai.cpp in Sources */,
|
||||
CF2F46B61095EE72007D33FA /* blit.cpp in Sources */,
|
||||
|
@ -2203,11 +2233,13 @@
|
|||
CF2F46CD1095EE72007D33FA /* mac-dialog.cpp in Sources */,
|
||||
CF2F46CE1095EE72007D33FA /* mac-file.cpp in Sources */,
|
||||
CF2F46CF1095EE72007D33FA /* mac-gworld.cpp in Sources */,
|
||||
CE6E9073227D5E1E00C3FFC6 /* tileimpl-n1x1.cpp in Sources */,
|
||||
CF2F46D01095EE72007D33FA /* mac-joypad.cpp in Sources */,
|
||||
CF2F46D11095EE72007D33FA /* mac-keyboard.cpp in Sources */,
|
||||
CF2F46D21095EE72007D33FA /* mac-multicart.cpp in Sources */,
|
||||
CF2F46D31095EE72007D33FA /* mac-musicbox.mm in Sources */,
|
||||
CF2F46D41095EE72007D33FA /* mac-netplay.cpp in Sources */,
|
||||
CE6E9070227D5E1E00C3FFC6 /* tileimpl-n2x1.cpp in Sources */,
|
||||
CF2F46D51095EE72007D33FA /* mac-os.mm in Sources */,
|
||||
CF2F46D61095EE72007D33FA /* mac-prefs.cpp in Sources */,
|
||||
CF2F46D71095EE72007D33FA /* mac-quicktime.cpp in Sources */,
|
||||
|
|
8
port.h
8
port.h
|
@ -44,6 +44,14 @@
|
|||
#define PIXEL_FORMAT RGB565
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define alwaysinline inline __attribute__((always_inline))
|
||||
#elif defined(_MSC_VER)
|
||||
#define alwaysinline __forceinline
|
||||
#else
|
||||
#define alwaysinline inline
|
||||
#endif
|
||||
|
||||
#ifndef snes9x_types_defined
|
||||
#define snes9x_types_defined
|
||||
typedef unsigned char bool8;
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*****************************************************************************\
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
This file is licensed under the Snes9x License.
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
|
||||
#define _TILEIMPL_CPP_
|
||||
#include "tileimpl.h"
|
||||
|
||||
namespace TileImpl {
|
||||
|
||||
template<class MATH, class BPSTART>
|
||||
void HiresBase<MATH, BPSTART>::Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2)
|
||||
{
|
||||
if (Z1 > GFX.DB[Offset + 2 * N] && (M))
|
||||
{
|
||||
GFX.S[Offset + 2 * N + 1] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]);
|
||||
if ((OffsetInLine + 2 * N ) != (SNES_WIDTH - 1) << 1)
|
||||
GFX.S[Offset + 2 * N + 2] = MATH::Calc((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N + 2]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]);
|
||||
if ((OffsetInLine + 2 * N) == 0 || (OffsetInLine + 2 * N) == GFX.RealPPL)
|
||||
GFX.S[Offset + 2 * N] = MATH::Calc((GFX.ClipColors ? 0 : GFX.SubScreen[Offset + 2 * N]), GFX.RealScreenColors[Pix], GFX.SubZBuffer[Offset + 2 * N]);
|
||||
GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// hires double width
|
||||
template struct Renderers<DrawTile16, Hires>;
|
||||
template struct Renderers<DrawClippedTile16, Hires>;
|
||||
template struct Renderers<DrawMosaicPixel16, Hires>;
|
||||
template struct Renderers<DrawBackdrop16, Hires>;
|
||||
template struct Renderers<DrawMode7MosaicBG1, Hires>;
|
||||
template struct Renderers<DrawMode7BG1, Hires>;
|
||||
template struct Renderers<DrawMode7MosaicBG2, Hires>;
|
||||
template struct Renderers<DrawMode7BG2, Hires>;
|
||||
|
||||
// hires double width interlace
|
||||
template struct Renderers<DrawTile16, HiresInterlace>;
|
||||
template struct Renderers<DrawClippedTile16, HiresInterlace>;
|
||||
template struct Renderers<DrawMosaicPixel16, HiresInterlace>;
|
||||
//template struct Renderers<DrawBackdrop16, Hires>;
|
||||
//template struct Renderers<DrawMode7MosaicBG1, Hires>;
|
||||
//template struct Renderers<DrawMode7BG1, Hires>;
|
||||
//template struct Renderers<DrawMode7MosaicBG2, Hires>;
|
||||
//template struct Renderers<DrawMode7BG2, Hires>;
|
||||
|
||||
} // namespace TileImpl
|
|
@ -0,0 +1,34 @@
|
|||
/*****************************************************************************\
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
This file is licensed under the Snes9x License.
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
|
||||
#define _TILEIMPL_CPP_
|
||||
#include "tileimpl.h"
|
||||
|
||||
namespace TileImpl {
|
||||
|
||||
template<class MATH, class BPSTART>
|
||||
void Normal1x1Base<MATH, BPSTART>::Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2)
|
||||
{
|
||||
(void) OffsetInLine;
|
||||
if (Z1 > GFX.DB[Offset + N] && (M))
|
||||
{
|
||||
GFX.S[Offset + N] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + N], GFX.SubZBuffer[Offset + N]);
|
||||
GFX.DB[Offset + N] = Z2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// normal width
|
||||
template struct Renderers<DrawTile16, Normal1x1>;
|
||||
template struct Renderers<DrawClippedTile16, Normal1x1>;
|
||||
template struct Renderers<DrawMosaicPixel16, Normal1x1>;
|
||||
template struct Renderers<DrawBackdrop16, Normal1x1>;
|
||||
template struct Renderers<DrawMode7MosaicBG1, Normal1x1>;
|
||||
template struct Renderers<DrawMode7BG1, Normal1x1>;
|
||||
template struct Renderers<DrawMode7MosaicBG2, Normal1x1>;
|
||||
template struct Renderers<DrawMode7BG2, Normal1x1>;
|
||||
|
||||
} // namespace TileImpl
|
|
@ -0,0 +1,44 @@
|
|||
/*****************************************************************************\
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
This file is licensed under the Snes9x License.
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
|
||||
#define _TILEIMPL_CPP_
|
||||
#include "tileimpl.h"
|
||||
|
||||
namespace TileImpl {
|
||||
|
||||
template<class MATH, class BPSTART>
|
||||
void Normal2x1Base<MATH, BPSTART>::Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2)
|
||||
{
|
||||
(void) OffsetInLine;
|
||||
if (Z1 > GFX.DB[Offset + 2 * N] && (M))
|
||||
{
|
||||
GFX.S[Offset + 2 * N] = GFX.S[Offset + 2 * N + 1] = MATH::Calc(GFX.ScreenColors[Pix], GFX.SubScreen[Offset + 2 * N], GFX.SubZBuffer[Offset + 2 * N]);
|
||||
GFX.DB[Offset + 2 * N] = GFX.DB[Offset + 2 * N + 1] = Z2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// normal double width
|
||||
template struct Renderers<DrawTile16, Normal2x1>;
|
||||
template struct Renderers<DrawClippedTile16, Normal2x1>;
|
||||
template struct Renderers<DrawMosaicPixel16, Normal2x1>;
|
||||
template struct Renderers<DrawBackdrop16, Normal2x1>;
|
||||
template struct Renderers<DrawMode7MosaicBG1, Normal2x1>;
|
||||
template struct Renderers<DrawMode7BG1, Normal2x1>;
|
||||
template struct Renderers<DrawMode7MosaicBG2, Normal2x1>;
|
||||
template struct Renderers<DrawMode7BG2, Normal2x1>;
|
||||
|
||||
// normal double width interlace
|
||||
template struct Renderers<DrawTile16, Interlace>;
|
||||
template struct Renderers<DrawClippedTile16, Interlace>;
|
||||
template struct Renderers<DrawMosaicPixel16, Interlace>;
|
||||
//template struct Renderers<DrawBackdrop16, Normal2x1>;
|
||||
//template struct Renderers<DrawMode7MosaicBG1, Normal2x1>;
|
||||
//template struct Renderers<DrawMode7BG1, Normal2x1>;
|
||||
//template struct Renderers<DrawMode7MosaicBG2, Normal2x1>;
|
||||
//template struct Renderers<DrawMode7BG2, Normal2x1>;
|
||||
|
||||
} // namespace TileImpl
|
|
@ -0,0 +1,801 @@
|
|||
/*****************************************************************************\
|
||||
Snes9x - Portable Super Nintendo Entertainment System (TM) emulator.
|
||||
This file is licensed under the Snes9x License.
|
||||
For further information, consult the LICENSE file in the root directory.
|
||||
\*****************************************************************************/
|
||||
|
||||
#ifndef _TILEIMPL_H_
|
||||
#define _TILEIMPL_H_
|
||||
|
||||
#include "snes9x.h"
|
||||
#include "ppu.h"
|
||||
#include "tile.h"
|
||||
|
||||
extern struct SLineMatrixData LineMatrixData[240];
|
||||
|
||||
|
||||
namespace TileImpl {
|
||||
|
||||
struct BPProgressive
|
||||
{
|
||||
enum { Pitch = 1 };
|
||||
static alwaysinline uint32 Get(uint32 StartLine) { return StartLine; }
|
||||
};
|
||||
|
||||
// Interlace: Only draw every other line, so we'll redefine bpstart_t and Pitch to do so.
|
||||
// Otherwise, it's the same as Normal2x1/Hires2x1.
|
||||
struct BPInterlace
|
||||
{
|
||||
enum { Pitch = 2 };
|
||||
static alwaysinline uint32 Get(uint32 StartLine) { return StartLine * 2 + BG.InterlaceLine; }
|
||||
};
|
||||
|
||||
|
||||
// The 1x1 pixel plotter, for speedhacking modes.
|
||||
template<class MATH, class BPSTART>
|
||||
struct Normal1x1Base
|
||||
{
|
||||
enum { Pitch = BPSTART::Pitch };
|
||||
typedef BPSTART bpstart_t;
|
||||
|
||||
static void Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2);
|
||||
};
|
||||
|
||||
template<class MATH>
|
||||
struct Normal1x1 : public Normal1x1Base<MATH, BPProgressive> {};
|
||||
|
||||
|
||||
// The 2x1 pixel plotter, for normal rendering when we've used hires/interlace already this frame.
|
||||
template<class MATH, class BPSTART>
|
||||
struct Normal2x1Base
|
||||
{
|
||||
enum { Pitch = BPSTART::Pitch };
|
||||
typedef BPSTART bpstart_t;
|
||||
|
||||
static void Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2);
|
||||
};
|
||||
|
||||
template<class MATH>
|
||||
struct Normal2x1 : public Normal2x1Base<MATH, BPProgressive> {};
|
||||
template<class MATH>
|
||||
struct Interlace : public Normal2x1Base<MATH, BPInterlace> {};
|
||||
|
||||
|
||||
// Hires pixel plotter, this combines the main and subscreen pixels as appropriate to render hires or pseudo-hires images.
|
||||
// Use it only on the main screen, subscreen should use Normal2x1 instead.
|
||||
// Hires math:
|
||||
// Main pixel is mathed as normal: Main(x, y) * Sub(x, y).
|
||||
// Sub pixel is mathed somewhat weird: Basically, for Sub(x + 1, y) we apply the same operation we applied to Main(x, y)
|
||||
// (e.g. no math, add fixed, add1/2 subscreen) using Main(x, y) as the "corresponding subscreen pixel".
|
||||
// Also, color window clipping clips Sub(x + 1, y) if Main(x, y) is clipped, not Main(x + 1, y).
|
||||
// We don't know how Sub(0, y) is handled.
|
||||
template<class MATH, class BPSTART>
|
||||
struct HiresBase
|
||||
{
|
||||
enum { Pitch = BPSTART::Pitch };
|
||||
typedef BPSTART bpstart_t;
|
||||
|
||||
static void Draw(uint8 N, uint8 M, uint32 Offset, uint32 OffsetInLine, uint8 Pix, uint8 Z1, uint8 Z2);
|
||||
};
|
||||
|
||||
template<class MATH>
|
||||
struct Hires : public HiresBase<MATH, BPProgressive> {};
|
||||
template<class MATH>
|
||||
struct HiresInterlace : public HiresBase<MATH, BPInterlace> {};
|
||||
|
||||
|
||||
class CachedTile
|
||||
{
|
||||
public:
|
||||
CachedTile(uint32 tile) : Tile(tile) {}
|
||||
|
||||
alwaysinline void GetCachedTile()
|
||||
{
|
||||
TileAddr = BG.TileAddress + ((Tile & 0x3ff) << BG.TileShift);
|
||||
if (Tile & 0x100)
|
||||
TileAddr += BG.NameSelect;
|
||||
TileAddr &= 0xffff;
|
||||
TileNumber = TileAddr >> BG.TileShift;
|
||||
if (Tile & H_FLIP)
|
||||
{
|
||||
pCache = &BG.BufferFlip[TileNumber << 6];
|
||||
if (!BG.BufferedFlip[TileNumber])
|
||||
BG.BufferedFlip[TileNumber] = BG.ConvertTileFlip(pCache, TileAddr, Tile & 0x3ff);
|
||||
}
|
||||
else
|
||||
{
|
||||
pCache = &BG.Buffer[TileNumber << 6];
|
||||
if (!BG.Buffered[TileNumber])
|
||||
BG.Buffered[TileNumber] = BG.ConvertTile(pCache, TileAddr, Tile & 0x3ff);
|
||||
}
|
||||
}
|
||||
|
||||
alwaysinline bool IsBlankTile() const
|
||||
{
|
||||
return ((Tile & H_FLIP) ? BG.BufferedFlip[TileNumber] : BG.Buffered[TileNumber]) == BLANK_TILE;
|
||||
}
|
||||
|
||||
alwaysinline void SelectPalette() const
|
||||
{
|
||||
if (BG.DirectColourMode)
|
||||
{
|
||||
GFX.RealScreenColors = DirectColourMaps[(Tile >> 10) & 7];
|
||||
}
|
||||
else
|
||||
GFX.RealScreenColors = &IPPU.ScreenColors[((Tile >> BG.PaletteShift) & BG.PaletteMask) + BG.StartPalette];
|
||||
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
|
||||
}
|
||||
|
||||
alwaysinline uint8* Ptr() const
|
||||
{
|
||||
return pCache;
|
||||
}
|
||||
|
||||
private:
|
||||
uint8 *pCache;
|
||||
uint32 Tile;
|
||||
uint32 TileNumber;
|
||||
uint32 TileAddr;
|
||||
};
|
||||
|
||||
|
||||
struct NOMATH
|
||||
{
|
||||
static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
|
||||
{
|
||||
return Main;
|
||||
}
|
||||
};
|
||||
typedef NOMATH Blend_None;
|
||||
|
||||
template<class Op>
|
||||
struct REGMATH
|
||||
{
|
||||
static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
|
||||
{
|
||||
return Op::fn(Main, (SD & 0x20) ? Sub : GFX.FixedColour);
|
||||
}
|
||||
};
|
||||
typedef REGMATH<COLOR_ADD> Blend_Add;
|
||||
typedef REGMATH<COLOR_SUB> Blend_Sub;
|
||||
typedef REGMATH<COLOR_ADD_BRIGHTNESS> Blend_AddBrightness;
|
||||
|
||||
template<class Op>
|
||||
struct MATHF1_2
|
||||
{
|
||||
static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
|
||||
{
|
||||
return GFX.ClipColors ? Op::fn(Main, GFX.FixedColour) : Op::fn1_2(Main, GFX.FixedColour);
|
||||
}
|
||||
};
|
||||
typedef MATHF1_2<COLOR_ADD> Blend_AddF1_2;
|
||||
typedef MATHF1_2<COLOR_SUB> Blend_SubF1_2;
|
||||
|
||||
template<class Op>
|
||||
struct MATHS1_2
|
||||
{
|
||||
static alwaysinline uint16 Calc(uint16 Main, uint16 Sub, uint8 SD)
|
||||
{
|
||||
return GFX.ClipColors ? REGMATH<Op>::Calc(Main, Sub, SD) : (SD & 0x20) ? Op::fn1_2(Main, Sub) : Op::fn(Main, GFX.FixedColour);
|
||||
}
|
||||
};
|
||||
typedef MATHS1_2<COLOR_ADD> Blend_AddS1_2;
|
||||
typedef MATHS1_2<COLOR_SUB> Blend_SubS1_2;
|
||||
typedef MATHS1_2<COLOR_ADD_BRIGHTNESS> Blend_AddS1_2Brightness;
|
||||
|
||||
template<
|
||||
template<class PIXEL_> class TILE,
|
||||
template<class MATH> class PIXEL
|
||||
>
|
||||
struct Renderers
|
||||
{
|
||||
enum { Pitch = PIXEL<Blend_None>::Pitch };
|
||||
typedef typename TILE< PIXEL<Blend_None> >::call_t call_t;
|
||||
|
||||
static call_t Functions[9];
|
||||
};
|
||||
|
||||
#ifdef _TILEIMPL_CPP_
|
||||
template<
|
||||
template<class PIXEL_> class TILE,
|
||||
template<class MATH> class PIXEL
|
||||
>
|
||||
typename Renderers<TILE, PIXEL>::call_t Renderers<TILE, PIXEL>::Functions[9] =
|
||||
{
|
||||
TILE< PIXEL<Blend_None> >::Draw,
|
||||
TILE< PIXEL<Blend_Add> >::Draw,
|
||||
TILE< PIXEL<Blend_AddF1_2> >::Draw,
|
||||
TILE< PIXEL<Blend_AddS1_2> >::Draw,
|
||||
TILE< PIXEL<Blend_Sub> >::Draw,
|
||||
TILE< PIXEL<Blend_SubF1_2> >::Draw,
|
||||
TILE< PIXEL<Blend_SubS1_2> >::Draw,
|
||||
TILE< PIXEL<Blend_AddBrightness> >::Draw,
|
||||
TILE< PIXEL<Blend_AddS1_2Brightness> >::Draw,
|
||||
};
|
||||
#endif
|
||||
|
||||
// Basic routine to render an unclipped tile.
|
||||
// Input parameters:
|
||||
// bpstart_t = either StartLine or (StartLine * 2 + BG.InterlaceLine),
|
||||
// so interlace modes can render every other line from the tile.
|
||||
// Pitch = 1 or 2, again so interlace can count lines properly.
|
||||
// DRAW_PIXEL(N, M) is a routine to actually draw the pixel. N is the pixel in the row to draw,
|
||||
// and M is a test which if false means the pixel should be skipped.
|
||||
// Z1 is the "draw if Z1 > cur_depth".
|
||||
// Z2 is the "cur_depth = new_depth". OBJ need the two separate.
|
||||
// Pix is the pixel to draw.
|
||||
|
||||
#define OFFSET_IN_LINE \
|
||||
uint32 OffsetInLine = Offset % GFX.RealPPL;
|
||||
#define DRAW_PIXEL(N, M) PIXEL::Draw(N, M, Offset, OffsetInLine, Pix, Z1, Z2)
|
||||
#define Z1 GFX.Z1
|
||||
#define Z2 GFX.Z2
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawTile16
|
||||
{
|
||||
typedef void (*call_t)(uint32, uint32, uint32, uint32);
|
||||
|
||||
enum { Pitch = PIXEL::Pitch };
|
||||
typedef typename PIXEL::bpstart_t bpstart_t;
|
||||
|
||||
static void Draw(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 LineCount)
|
||||
{
|
||||
CachedTile cache(Tile);
|
||||
int32 l;
|
||||
uint8 *bp, Pix;
|
||||
|
||||
cache.GetCachedTile();
|
||||
if (cache.IsBlankTile())
|
||||
return;
|
||||
cache.SelectPalette();
|
||||
|
||||
if (!(Tile & (V_FLIP | H_FLIP)))
|
||||
{
|
||||
bp = cache.Ptr() + bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp += 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
for (int x = 0; x < 8; x++) {
|
||||
Pix = bp[x]; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!(Tile & V_FLIP))
|
||||
{
|
||||
bp = cache.Ptr() + bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp += 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
for (int x = 0; x < 8; x++) {
|
||||
Pix = bp[7 - x]; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!(Tile & H_FLIP))
|
||||
{
|
||||
bp = cache.Ptr() + 56 - bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp -= 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
for (int x = 0; x < 8; x++) {
|
||||
Pix = bp[x]; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bp = cache.Ptr() + 56 - bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp -= 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
for (int x = 0; x < 8; x++) {
|
||||
Pix = bp[7 - x]; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#undef Z1
|
||||
#undef Z2
|
||||
|
||||
// Basic routine to render a clipped tile. Inputs same as above.
|
||||
|
||||
#define Z1 GFX.Z1
|
||||
#define Z2 GFX.Z2
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawClippedTile16
|
||||
{
|
||||
typedef void (*call_t)(uint32, uint32, uint32, uint32, uint32, uint32);
|
||||
|
||||
enum { Pitch = PIXEL::Pitch };
|
||||
typedef typename PIXEL::bpstart_t bpstart_t;
|
||||
|
||||
static void Draw(uint32 Tile, uint32 Offset, uint32 StartPixel, uint32 Width, uint32 StartLine, uint32 LineCount)
|
||||
{
|
||||
CachedTile cache(Tile);
|
||||
int32 l;
|
||||
uint8 *bp, Pix, w;
|
||||
|
||||
cache.GetCachedTile();
|
||||
if (cache.IsBlankTile())
|
||||
return;
|
||||
cache.SelectPalette();
|
||||
|
||||
if (!(Tile & (V_FLIP | H_FLIP)))
|
||||
{
|
||||
bp = cache.Ptr() + bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp += 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
w = Width;
|
||||
switch (StartPixel)
|
||||
{
|
||||
case 0: Pix = bp[0]; DRAW_PIXEL(0, Pix); if (!--w) break; /* Fall through */
|
||||
case 1: Pix = bp[1]; DRAW_PIXEL(1, Pix); if (!--w) break; /* Fall through */
|
||||
case 2: Pix = bp[2]; DRAW_PIXEL(2, Pix); if (!--w) break; /* Fall through */
|
||||
case 3: Pix = bp[3]; DRAW_PIXEL(3, Pix); if (!--w) break; /* Fall through */
|
||||
case 4: Pix = bp[4]; DRAW_PIXEL(4, Pix); if (!--w) break; /* Fall through */
|
||||
case 5: Pix = bp[5]; DRAW_PIXEL(5, Pix); if (!--w) break; /* Fall through */
|
||||
case 6: Pix = bp[6]; DRAW_PIXEL(6, Pix); if (!--w) break; /* Fall through */
|
||||
case 7: Pix = bp[7]; DRAW_PIXEL(7, Pix); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!(Tile & V_FLIP))
|
||||
{
|
||||
bp = cache.Ptr() + bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp += 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
w = Width;
|
||||
switch (StartPixel)
|
||||
{
|
||||
case 0: Pix = bp[7]; DRAW_PIXEL(0, Pix); if (!--w) break; /* Fall through */
|
||||
case 1: Pix = bp[6]; DRAW_PIXEL(1, Pix); if (!--w) break; /* Fall through */
|
||||
case 2: Pix = bp[5]; DRAW_PIXEL(2, Pix); if (!--w) break; /* Fall through */
|
||||
case 3: Pix = bp[4]; DRAW_PIXEL(3, Pix); if (!--w) break; /* Fall through */
|
||||
case 4: Pix = bp[3]; DRAW_PIXEL(4, Pix); if (!--w) break; /* Fall through */
|
||||
case 5: Pix = bp[2]; DRAW_PIXEL(5, Pix); if (!--w) break; /* Fall through */
|
||||
case 6: Pix = bp[1]; DRAW_PIXEL(6, Pix); if (!--w) break; /* Fall through */
|
||||
case 7: Pix = bp[0]; DRAW_PIXEL(7, Pix); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
if (!(Tile & H_FLIP))
|
||||
{
|
||||
bp = cache.Ptr() + 56 - bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp -= 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
w = Width;
|
||||
switch (StartPixel)
|
||||
{
|
||||
case 0: Pix = bp[0]; DRAW_PIXEL(0, Pix); if (!--w) break; /* Fall through */
|
||||
case 1: Pix = bp[1]; DRAW_PIXEL(1, Pix); if (!--w) break; /* Fall through */
|
||||
case 2: Pix = bp[2]; DRAW_PIXEL(2, Pix); if (!--w) break; /* Fall through */
|
||||
case 3: Pix = bp[3]; DRAW_PIXEL(3, Pix); if (!--w) break; /* Fall through */
|
||||
case 4: Pix = bp[4]; DRAW_PIXEL(4, Pix); if (!--w) break; /* Fall through */
|
||||
case 5: Pix = bp[5]; DRAW_PIXEL(5, Pix); if (!--w) break; /* Fall through */
|
||||
case 6: Pix = bp[6]; DRAW_PIXEL(6, Pix); if (!--w) break; /* Fall through */
|
||||
case 7: Pix = bp[7]; DRAW_PIXEL(7, Pix); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bp = cache.Ptr() + 56 - bpstart_t::Get(StartLine);
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, bp -= 8 * Pitch, Offset += GFX.PPL)
|
||||
{
|
||||
w = Width;
|
||||
switch (StartPixel)
|
||||
{
|
||||
case 0: Pix = bp[7]; DRAW_PIXEL(0, Pix); if (!--w) break; /* Fall through */
|
||||
case 1: Pix = bp[6]; DRAW_PIXEL(1, Pix); if (!--w) break; /* Fall through */
|
||||
case 2: Pix = bp[5]; DRAW_PIXEL(2, Pix); if (!--w) break; /* Fall through */
|
||||
case 3: Pix = bp[4]; DRAW_PIXEL(3, Pix); if (!--w) break; /* Fall through */
|
||||
case 4: Pix = bp[3]; DRAW_PIXEL(4, Pix); if (!--w) break; /* Fall through */
|
||||
case 5: Pix = bp[2]; DRAW_PIXEL(5, Pix); if (!--w) break; /* Fall through */
|
||||
case 6: Pix = bp[1]; DRAW_PIXEL(6, Pix); if (!--w) break; /* Fall through */
|
||||
case 7: Pix = bp[0]; DRAW_PIXEL(7, Pix); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#undef Z1
|
||||
#undef Z2
|
||||
|
||||
// Basic routine to render a single mosaic pixel.
|
||||
// DRAW_PIXEL, bpstart_t, Z1, Z2 and Pix are the same as above, but Pitch is not used.
|
||||
|
||||
#define Z1 GFX.Z1
|
||||
#define Z2 GFX.Z2
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawMosaicPixel16
|
||||
{
|
||||
typedef void (*call_t)(uint32, uint32, uint32, uint32, uint32, uint32);
|
||||
|
||||
typedef typename PIXEL::bpstart_t bpstart_t;
|
||||
|
||||
static void Draw(uint32 Tile, uint32 Offset, uint32 StartLine, uint32 StartPixel, uint32 Width, uint32 LineCount)
|
||||
{
|
||||
CachedTile cache(Tile);
|
||||
int32 l, w;
|
||||
uint8 Pix;
|
||||
|
||||
cache.GetCachedTile();
|
||||
if (cache.IsBlankTile())
|
||||
return;
|
||||
cache.SelectPalette();
|
||||
|
||||
if (Tile & H_FLIP)
|
||||
StartPixel = 7 - StartPixel;
|
||||
|
||||
if (Tile & V_FLIP)
|
||||
Pix = cache.Ptr()[56 - bpstart_t::Get(StartLine) + StartPixel];
|
||||
else
|
||||
Pix = cache.Ptr()[bpstart_t::Get(StartLine) + StartPixel];
|
||||
|
||||
if (Pix)
|
||||
{
|
||||
OFFSET_IN_LINE;
|
||||
for (l = LineCount; l > 0; l--, Offset += GFX.PPL)
|
||||
{
|
||||
for (w = Width - 1; w >= 0; w--)
|
||||
DRAW_PIXEL(w, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#undef Z1
|
||||
#undef Z2
|
||||
|
||||
// Basic routine to render the backdrop.
|
||||
// DRAW_PIXEL is the same as above, but since we're just replicating a single pixel there's no need for Pitch or bpstart_t
|
||||
// (or interlace at all, really).
|
||||
// The backdrop is always depth = 1, so Z1 = Z2 = 1. And backdrop is always color 0.
|
||||
|
||||
#define Z1 1
|
||||
#define Z2 1
|
||||
#define Pix 0
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawBackdrop16
|
||||
{
|
||||
typedef void (*call_t)(uint32 Offset, uint32 Left, uint32 Right);
|
||||
|
||||
static void Draw(uint32 Offset, uint32 Left, uint32 Right)
|
||||
{
|
||||
uint32 l, x;
|
||||
|
||||
GFX.RealScreenColors = IPPU.ScreenColors;
|
||||
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
|
||||
|
||||
OFFSET_IN_LINE;
|
||||
for (l = GFX.StartY; l <= GFX.EndY; l++, Offset += GFX.PPL)
|
||||
{
|
||||
for (x = Left; x < Right; x++)
|
||||
DRAW_PIXEL(x, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#undef Pix
|
||||
#undef Z1
|
||||
#undef Z2
|
||||
#undef DRAW_PIXEL
|
||||
|
||||
// Basic routine to render a chunk of a Mode 7 BG.
|
||||
// Mode 7 has no interlace, so bpstart_t and Pitch are unused.
|
||||
// We get some new parameters, so we can use the same DRAW_TILE to do BG1 or BG2:
|
||||
// DCMODE tests if Direct Color should apply.
|
||||
// BG is the BG, so we use the right clip window.
|
||||
// MASK is 0xff or 0x7f, the 'color' portion of the pixel.
|
||||
// We define Z1/Z2 to either be constant 5 or to vary depending on the 'priority' portion of the pixel.
|
||||
|
||||
#define CLIP_10_BIT_SIGNED(a) (((a) & 0x2000) ? ((a) | ~0x3ff) : ((a) & 0x3ff))
|
||||
|
||||
#define DRAW_PIXEL(N, M) PIXEL::Draw(N, M, Offset, OffsetInLine, Pix, OP::Z1(D, b), OP::Z2(D, b))
|
||||
|
||||
struct DrawMode7BG1_OP
|
||||
{
|
||||
enum {
|
||||
MASK = 0xff,
|
||||
BG = 0
|
||||
};
|
||||
static uint8 Z1(int D, uint8 b) { return D + 7; }
|
||||
static uint8 Z2(int D, uint8 b) { return D + 7; }
|
||||
static uint8 DCMODE() { return Memory.FillRAM[0x2130] & 1; }
|
||||
};
|
||||
struct DrawMode7BG2_OP
|
||||
{
|
||||
enum {
|
||||
MASK = 0x7f,
|
||||
BG = 1
|
||||
};
|
||||
static uint8 Z1(int D, uint8 b) { return D + ((b & 0x80) ? 11 : 3); }
|
||||
static uint8 Z2(int D, uint8 b) { return D + ((b & 0x80) ? 11 : 3); }
|
||||
static uint8 DCMODE() { return 0; }
|
||||
};
|
||||
|
||||
template<class PIXEL, class OP>
|
||||
struct DrawTileNormal
|
||||
{
|
||||
typedef void (*call_t)(uint32 Left, uint32 Right, int D);
|
||||
|
||||
static void Draw(uint32 Left, uint32 Right, int D)
|
||||
{
|
||||
uint8 *VRAM1 = Memory.VRAM + 1;
|
||||
|
||||
if (OP::DCMODE())
|
||||
{
|
||||
GFX.RealScreenColors = DirectColourMaps[0];
|
||||
}
|
||||
else
|
||||
GFX.RealScreenColors = IPPU.ScreenColors;
|
||||
|
||||
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
|
||||
|
||||
int aa, cc;
|
||||
int startx;
|
||||
|
||||
uint32 Offset = GFX.StartY * GFX.PPL;
|
||||
struct SLineMatrixData *l = &LineMatrixData[GFX.StartY];
|
||||
|
||||
OFFSET_IN_LINE;
|
||||
for (uint32 Line = GFX.StartY; Line <= GFX.EndY; Line++, Offset += GFX.PPL, l++)
|
||||
{
|
||||
int yy, starty;
|
||||
|
||||
int32 HOffset = ((int32) l->M7HOFS << 19) >> 19;
|
||||
int32 VOffset = ((int32) l->M7VOFS << 19) >> 19;
|
||||
|
||||
int32 CentreX = ((int32) l->CentreX << 19) >> 19;
|
||||
int32 CentreY = ((int32) l->CentreY << 19) >> 19;
|
||||
|
||||
if (PPU.Mode7VFlip)
|
||||
starty = 255 - (int) (Line + 1);
|
||||
else
|
||||
starty = Line + 1;
|
||||
|
||||
yy = CLIP_10_BIT_SIGNED(VOffset - CentreY);
|
||||
|
||||
int BB = ((l->MatrixB * starty) & ~63) + ((l->MatrixB * yy) & ~63) + (CentreX << 8);
|
||||
int DD = ((l->MatrixD * starty) & ~63) + ((l->MatrixD * yy) & ~63) + (CentreY << 8);
|
||||
|
||||
if (PPU.Mode7HFlip)
|
||||
{
|
||||
startx = Right - 1;
|
||||
aa = -l->MatrixA;
|
||||
cc = -l->MatrixC;
|
||||
}
|
||||
else
|
||||
{
|
||||
startx = Left;
|
||||
aa = l->MatrixA;
|
||||
cc = l->MatrixC;
|
||||
}
|
||||
|
||||
int xx = CLIP_10_BIT_SIGNED(HOffset - CentreX);
|
||||
int AA = l->MatrixA * startx + ((l->MatrixA * xx) & ~63);
|
||||
int CC = l->MatrixC * startx + ((l->MatrixC * xx) & ~63);
|
||||
|
||||
uint8 Pix;
|
||||
|
||||
if (!PPU.Mode7Repeat)
|
||||
{
|
||||
for (uint32 x = Left; x < Right; x++, AA += aa, CC += cc)
|
||||
{
|
||||
int X = ((AA + BB) >> 8) & 0x3ff;
|
||||
int Y = ((CC + DD) >> 8) & 0x3ff;
|
||||
|
||||
uint8 *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7);
|
||||
uint8 b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
|
||||
Pix = b & OP::MASK; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint32 x = Left; x < Right; x++, AA += aa, CC += cc)
|
||||
{
|
||||
int X = ((AA + BB) >> 8);
|
||||
int Y = ((CC + DD) >> 8);
|
||||
|
||||
uint8 b;
|
||||
|
||||
if (((X | Y) & ~0x3ff) == 0)
|
||||
{
|
||||
uint8 *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7);
|
||||
b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
}
|
||||
else
|
||||
if (PPU.Mode7Repeat == 3)
|
||||
b = *(VRAM1 + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
else
|
||||
continue;
|
||||
|
||||
Pix = b & OP::MASK; DRAW_PIXEL(x, Pix);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawMode7BG1 : public DrawTileNormal<PIXEL, DrawMode7BG1_OP> {};
|
||||
template<class PIXEL>
|
||||
struct DrawMode7BG2 : public DrawTileNormal<PIXEL, DrawMode7BG2_OP> {};
|
||||
|
||||
template<class PIXEL, class OP>
|
||||
struct DrawTileMosaic
|
||||
{
|
||||
typedef void (*call_t)(uint32 Left, uint32 Right, int D);
|
||||
|
||||
static void Draw(uint32 Left, uint32 Right, int D)
|
||||
{
|
||||
uint8 *VRAM1 = Memory.VRAM + 1;
|
||||
|
||||
if (OP::DCMODE())
|
||||
{
|
||||
GFX.RealScreenColors = DirectColourMaps[0];
|
||||
}
|
||||
else
|
||||
GFX.RealScreenColors = IPPU.ScreenColors;
|
||||
|
||||
GFX.ScreenColors = GFX.ClipColors ? BlackColourMap : GFX.RealScreenColors;
|
||||
|
||||
int aa, cc;
|
||||
int startx, StartY = GFX.StartY;
|
||||
|
||||
int HMosaic = 1, VMosaic = 1, MosaicStart = 0;
|
||||
int32 MLeft = Left, MRight = Right;
|
||||
|
||||
if (PPU.BGMosaic[0])
|
||||
{
|
||||
VMosaic = PPU.Mosaic;
|
||||
MosaicStart = ((uint32) GFX.StartY - PPU.MosaicStart) % VMosaic;
|
||||
StartY -= MosaicStart;
|
||||
}
|
||||
|
||||
if (PPU.BGMosaic[OP::BG])
|
||||
{
|
||||
HMosaic = PPU.Mosaic;
|
||||
MLeft -= MLeft % HMosaic;
|
||||
MRight += HMosaic - 1;
|
||||
MRight -= MRight % HMosaic;
|
||||
}
|
||||
|
||||
uint32 Offset = StartY * GFX.PPL;
|
||||
struct SLineMatrixData *l = &LineMatrixData[StartY];
|
||||
|
||||
OFFSET_IN_LINE;
|
||||
for (uint32 Line = StartY; Line <= GFX.EndY; Line += VMosaic, Offset += VMosaic * GFX.PPL, l += VMosaic)
|
||||
{
|
||||
if (Line + VMosaic > GFX.EndY)
|
||||
VMosaic = GFX.EndY - Line + 1;
|
||||
|
||||
int yy, starty;
|
||||
|
||||
int32 HOffset = ((int32) l->M7HOFS << 19) >> 19;
|
||||
int32 VOffset = ((int32) l->M7VOFS << 19) >> 19;
|
||||
|
||||
int32 CentreX = ((int32) l->CentreX << 19) >> 19;
|
||||
int32 CentreY = ((int32) l->CentreY << 19) >> 19;
|
||||
|
||||
if (PPU.Mode7VFlip)
|
||||
starty = 255 - (int) (Line + 1);
|
||||
else
|
||||
starty = Line + 1;
|
||||
|
||||
yy = CLIP_10_BIT_SIGNED(VOffset - CentreY);
|
||||
|
||||
int BB = ((l->MatrixB * starty) & ~63) + ((l->MatrixB * yy) & ~63) + (CentreX << 8);
|
||||
int DD = ((l->MatrixD * starty) & ~63) + ((l->MatrixD * yy) & ~63) + (CentreY << 8);
|
||||
|
||||
if (PPU.Mode7HFlip)
|
||||
{
|
||||
startx = MRight - 1;
|
||||
aa = -l->MatrixA;
|
||||
cc = -l->MatrixC;
|
||||
}
|
||||
else
|
||||
{
|
||||
startx = MLeft;
|
||||
aa = l->MatrixA;
|
||||
cc = l->MatrixC;
|
||||
}
|
||||
|
||||
int xx = CLIP_10_BIT_SIGNED(HOffset - CentreX);
|
||||
int AA = l->MatrixA * startx + ((l->MatrixA * xx) & ~63);
|
||||
int CC = l->MatrixC * startx + ((l->MatrixC * xx) & ~63);
|
||||
|
||||
uint8 Pix;
|
||||
uint8 ctr = 1;
|
||||
|
||||
if (!PPU.Mode7Repeat)
|
||||
{
|
||||
for (int32 x = MLeft; x < MRight; x++, AA += aa, CC += cc)
|
||||
{
|
||||
if (--ctr)
|
||||
continue;
|
||||
ctr = HMosaic;
|
||||
|
||||
int X = ((AA + BB) >> 8) & 0x3ff;
|
||||
int Y = ((CC + DD) >> 8) & 0x3ff;
|
||||
|
||||
uint8 *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7);
|
||||
uint8 b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
|
||||
if ((Pix = (b & OP::MASK)))
|
||||
{
|
||||
for (int32 h = MosaicStart; h < VMosaic; h++)
|
||||
{
|
||||
for (int32 w = x + HMosaic - 1; w >= x; w--)
|
||||
DRAW_PIXEL(w + h * GFX.PPL, (w >= (int32) Left && w < (int32) Right));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int32 x = MLeft; x < MRight; x++, AA += aa, CC += cc)
|
||||
{
|
||||
if (--ctr)
|
||||
continue;
|
||||
ctr = HMosaic;
|
||||
|
||||
int X = ((AA + BB) >> 8);
|
||||
int Y = ((CC + DD) >> 8);
|
||||
|
||||
uint8 b;
|
||||
|
||||
if (((X | Y) & ~0x3ff) == 0)
|
||||
{
|
||||
uint8 *TileData = VRAM1 + (Memory.VRAM[((Y & ~7) << 5) + ((X >> 2) & ~1)] << 7);
|
||||
b = *(TileData + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
}
|
||||
else
|
||||
if (PPU.Mode7Repeat == 3)
|
||||
b = *(VRAM1 + ((Y & 7) << 4) + ((X & 7) << 1));
|
||||
else
|
||||
continue;
|
||||
|
||||
if ((Pix = (b & OP::MASK)))
|
||||
{
|
||||
for (int32 h = MosaicStart; h < VMosaic; h++)
|
||||
{
|
||||
for (int32 w = x + HMosaic - 1; w >= x; w--)
|
||||
DRAW_PIXEL(w + h * GFX.PPL, (w >= (int32) Left && w < (int32) Right));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MosaicStart = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template<class PIXEL>
|
||||
struct DrawMode7MosaicBG1 : public DrawTileMosaic<PIXEL, DrawMode7BG1_OP> {};
|
||||
template<class PIXEL>
|
||||
struct DrawMode7MosaicBG2 : public DrawTileMosaic<PIXEL, DrawMode7BG2_OP> {};
|
||||
|
||||
|
||||
#undef DRAW_PIXEL
|
||||
|
||||
} // namespace TileImpl
|
||||
|
||||
#endif
|
|
@ -8,7 +8,7 @@
|
|||
OS = `uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"`
|
||||
BUILDDIR = .
|
||||
|
||||
OBJECTS = ../apu/apu.o ../apu/bapu/dsp/sdsp.o ../apu/bapu/smp/smp.o ../apu/bapu/smp/smp_state.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../msu1.o ../movie.o ../obc1.o ../ppu.o ../stream.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o ../statemanager.o ../sha256.o ../bml.o unix.o x11.o
|
||||
OBJECTS = ../apu/apu.o ../apu/bapu/dsp/sdsp.o ../apu/bapu/smp/smp.o ../apu/bapu/smp/smp_state.o ../bsx.o ../c4.o ../c4emu.o ../cheats.o ../cheats2.o ../clip.o ../conffile.o ../controls.o ../cpu.o ../cpuexec.o ../cpuops.o ../crosshairs.o ../dma.o ../dsp.o ../dsp1.o ../dsp2.o ../dsp3.o ../dsp4.o ../fxinst.o ../fxemu.o ../gfx.o ../globals.o ../logger.o ../memmap.o ../msu1.o ../movie.o ../obc1.o ../ppu.o ../stream.o ../sa1.o ../sa1cpu.o ../screenshot.o ../sdd1.o ../sdd1emu.o ../seta.o ../seta010.o ../seta011.o ../seta018.o ../snapshot.o ../snes9x.o ../spc7110.o ../srtc.o ../tile.o ../tileimpl-n1x1.o ../tileimpl-n2x1.o ../tileimpl-h2x1.o ../filter/2xsai.o ../filter/blit.o ../filter/epx.o ../filter/hq2x.o ../filter/snes_ntsc.o ../statemanager.o ../sha256.o ../bml.o unix.o x11.o
|
||||
DEFS = -DMITSHM
|
||||
|
||||
ifdef S9XDEBUGGER
|
||||
|
|
|
@ -1484,9 +1484,9 @@ void RenderDotMatrix3X (SSurface Src, SSurface Dst, RECT *rect)
|
|||
|
||||
#define DrawPix(on00,on01,on10,on11) /* on00 on01 */ \
|
||||
{ /* on10 on11 */ \
|
||||
const uint16 colorXA = COLOR_ADD(colorX,colorX); \
|
||||
const uint16 colorXS = COLOR_SUB(colorXA,colorX); \
|
||||
const uint16 colorX2 = COLOR_SUB(colorX,colorXS); \
|
||||
const uint16 colorXA = COLOR_ADD::fn(colorX,colorX); \
|
||||
const uint16 colorXS = COLOR_SUB::fn(colorXA,colorX); \
|
||||
const uint16 colorX2 = COLOR_SUB::fn(colorX,colorXS); \
|
||||
*dP1++ = _THREE_PIX(colorX2, colorX, colorX2); \
|
||||
*dP2++ = _THREE_PIX(colorX, colorXA, colorX); \
|
||||
*dP3++ = _THREE_PIX(colorX2, colorX, colorX2); \
|
||||
|
|
|
@ -423,6 +423,7 @@
|
|||
<ClInclude Include="..\bml.h" />
|
||||
<CustomBuild Include="..\stream.h" />
|
||||
<CustomBuild Include="..\tile.h" />
|
||||
<CustomBuild Include="..\tileimpl.h" />
|
||||
<ClInclude Include="..\unzip\crypt.h" />
|
||||
<ClInclude Include="..\unzip\ioapi.h" />
|
||||
<ClInclude Include="..\unzip\iowin32.h" />
|
||||
|
@ -566,6 +567,9 @@
|
|||
<ClCompile Include="..\bml.cpp" />
|
||||
<ClCompile Include="..\stream.cpp" />
|
||||
<ClCompile Include="..\tile.cpp" />
|
||||
<ClCompile Include="..\tileimpl-n1x1.cpp" />
|
||||
<ClCompile Include="..\tileimpl-n2x1.cpp" />
|
||||
<ClCompile Include="..\tileimpl-h2x1.cpp" />
|
||||
<ClCompile Include="..\unzip\ioapi.c" />
|
||||
<ClCompile Include="..\unzip\iowin32.c" />
|
||||
<ClCompile Include="..\unzip\mztools.c" />
|
||||
|
|
|
@ -446,6 +446,15 @@
|
|||
<ClCompile Include="..\tile.cpp">
|
||||
<Filter>Emu</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-n1x1.cpp">
|
||||
<Filter>Emu</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-n2x1.cpp">
|
||||
<Filter>Emu</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\tileimpl-h2x1.cpp">
|
||||
<Filter>Emu</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\unzip\ioapi.c">
|
||||
<Filter>UnZip</Filter>
|
||||
</ClCompile>
|
||||
|
@ -818,6 +827,9 @@
|
|||
<CustomBuild Include="..\tile.h">
|
||||
<Filter>Emu</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="..\tileimpl.h">
|
||||
<Filter>Emu</Filter>
|
||||
</CustomBuild>
|
||||
<CustomBuild Include="CDirect3D.h">
|
||||
<Filter>GUI\VideoDriver</Filter>
|
||||
</CustomBuild>
|
||||
|
@ -874,4 +886,4 @@
|
|||
</CustomBuild>
|
||||
<CustomBuild Include="snes9x.cfg" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
Loading…
Reference in New Issue