ULTIMA8: Some minor shape and render cleanups

This commit is contained in:
Matthew Duggan 2020-03-21 14:41:11 +09:00 committed by Paul Gilbert
parent 8676a75ce0
commit 547a1d72a3
7 changed files with 27 additions and 75 deletions

View File

@ -631,7 +631,7 @@ bool ConvertShape::CheckUnsafe(IDataSource *source, const ConvertShapeFormat *cs
bool result = true;
// Just to be safe
int start_pos = source->getPos();
const uint32 start_pos = source->getPos();
// Read the ident
if (csf->_bytes_ident)
@ -739,7 +739,7 @@ bool ConvertShape::CheckUnsafe(IDataSource *source, const ConvertShapeFormat *cs
void ConvertShape::Write(ODataSource *dest, const ConvertShapeFormat *csf, uint32 &write_len)
{
// Just to be safe
uint32 start_pos = dest->getPos();
const uint32 start_pos = dest->getPos();
// Write the ident
if (csf->_bytes_ident) dest->write(csf->_ident, csf->_bytes_ident);

View File

@ -207,9 +207,6 @@ public:
// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
virtual void PaintHighlightInvis(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) = 0;
//! Paint a shape masked against destination alpha
virtual void PaintMasked(Shape *s, uint32 framenum, int32 x, int32 y, bool trans = false, bool mirrored = false, uint32 col32 = 0, bool untformed_pal = false) = 0;
//
// Basic Line Drawing
//

View File

@ -72,7 +72,7 @@ public:
ENABLE_CUSTOM_MEMORY_ALLOCATION()
protected:
private:
// This will load a u8 style shape 'optimized'.
void LoadU8Format(const uint8 *data, uint32 size, const ConvertShapeFormat *format);

View File

@ -54,7 +54,7 @@ public:
uint8 getPixelAtPoint(int32 x, int32 y) const; // Get the pixel at the point
void getConvertShapeFrame(ConvertShapeFrame &csf);
protected:
private:
// This will load a u8 style shape 'optimized'.
void LoadU8Format(const uint8 *data, uint32 size);

View File

@ -942,35 +942,6 @@ template<class uintX> void SoftRenderSurface<uintX>::PaintHighlightInvis(Shape *
#undef BLEND_SHAPES
}
//
// void SoftRenderSurface::PaintHighlight(Shape* s, uint32 frame, int32 x, int32 y, bool mirrored)
//
// Desc: Standard shape drawing functions. Masked against Dest Alpha. Highlights, Clips, and conditionally Flips and Xforms
//
template<class uintX> void SoftRenderSurface<uintX>::PaintMasked(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal) {
#define FLIP_SHAPES
#define FLIP_CONDITIONAL mirrored
#define XFORM_SHAPES
#define XFORM_CONDITIONAL trans
#define BLEND_SHAPES(src,dst) BlendHighlight(src,cr,cg,cb,ca,255-ca)
#define DESTALPHA_MASK
uint32 ca = TEX32_A(col32);
uint32 cr = TEX32_R(col32);
uint32 cg = TEX32_G(col32);
uint32 cb = TEX32_B(col32);
#include "ultima/ultima8/graphics/soft_render_surface.inl"
#undef FLIP_SHAPES
#undef FLIP_CONDITIONAL
#undef XFORM_SHAPES
#undef XFORM_CONDITIONAL
#undef BLEND_SHAPES
#undef DESTALPHA_MASK
}
//
// Instantiate the SoftRenderSurface Class
//

View File

@ -106,10 +106,6 @@ public:
// TODO: virtual void PaintHighlightInvis(CachedShape* s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32);
void PaintHighlightInvis(Shape *s, uint32 frame, int32 x, int32 y, bool trans, bool mirrored, uint32 col32, bool untformed_pal = false) override;
// Paint a shape masked against destination alpha
void PaintMasked(Shape *s, uint32 framenum, int32 x, int32 y, bool trans, bool mirrored, uint32 col32 = 0, bool untformed_pal = false) override;
//
// Basic Line Drawing
//

View File

@ -167,25 +167,13 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
// The Function
//
// All the variables we want
const uint8 *linedata;
int32 xpos;
sintptr line; // sintptr for pointer arithmetic
int32 dlen;
uintX *pixptr;
uintX *endrun;
uintX *line_start;
uint32 pix;
// Sanity check
if (framenum >= s->frameCount())
return;
if (s->getPalette() == 0)
return;
const ShapeFrame *frame = s->getFrame(framenum);
const ShapeFrame *frame = s->getFrame(framenum);
const uint8 *rle_data = frame->_rle_data;
const uint32 *line_offsets = frame->_line_offsets;
const uint32 *pal = untformed_pal?
@ -199,21 +187,19 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
&(s->getPalette()->_xform[0]);
#endif
int32 width_ = frame->_width;
int32 height_ = frame->_height;
const int32 width_ = frame->_width;
const int32 height_ = frame->_height;
x -= XNEG(frame->_xoff);
y -= frame->_yoff;
// Do it this way if compressed
if (frame->_compressed) for (int i=0; i<height_; i++) {
xpos = 0;
line = y+i;
int32 xpos = 0;
sintptr line = y+i;
if (NOT_CLIPPED_Y) {
linedata = rle_data + line_offsets[i];
line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + _pitch*line);
const uint8 *linedata = rle_data + line_offsets[i];
uintX *line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + _pitch*line);
LINE_END_ASSIGN();
do {
@ -221,14 +207,15 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
if (xpos == width_) break;
dlen = *linedata++;
int type = dlen & 1;
int32 dlen = *linedata++;
const int type = dlen & 1;
dlen >>= 1;
pixptr = line_start+x+XNEG(xpos);
endrun = pixptr + XNEG(dlen);
uintX *pixptr = line_start+x+XNEG(xpos);
uintX *endrun = pixptr + XNEG(dlen);
if (!type) {
// Identical to the uncompressed case
while (pixptr != endrun) {
if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) {
#ifdef XFORM_SHAPES
@ -244,17 +231,18 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
linedata++;
}
} else {
// a run of the same pixel
#ifdef XFORM_SHAPES
pix = xform_pal[*linedata];
if (USE_XFORM_FUNC) {
const uint32 pix = xform_pal[*linedata];
while (pixptr != endrun) {
if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) *pixptr = CUSTOM_BLEND(BlendPreModulated(xform_pal[*linedata],*pixptr));
if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) *pixptr = CUSTOM_BLEND(BlendPreModulated(pix,*pixptr));
pixptr += XNEG(1);
}
} else
#endif
{
pix = pal[*linedata];
const uint32 pix = pal[*linedata];
while (pixptr != endrun)
{
if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED)
@ -274,12 +262,12 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
}
// Uncompressed
else for (int i=0; i<height_; i++) {
linedata = rle_data + line_offsets[i];
xpos = 0;
line = y+i;
int32 xpos = 0;
sintptr line = y+i;
if (NOT_CLIPPED_Y) {
line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + _pitch*line);
const uint8 *linedata = rle_data + line_offsets[i];
uintX *line_start = reinterpret_cast<uintX *>(static_cast<uint8*>(OFFSET_PIXELS) + _pitch*line);
LINE_END_ASSIGN();
do {
@ -287,10 +275,10 @@ const int32 neg = (FLIP_CONDITIONAL)?-1:0;
if (xpos == width_) break;
dlen = *linedata++;
const int32 dlen = *linedata++;
pixptr= line_start+x+XNEG(xpos);
endrun = pixptr + XNEG(dlen);
uintX *pixptr = line_start+x+XNEG(xpos);
uintX *endrun = pixptr + XNEG(dlen);
while (pixptr != endrun) {
if (NOT_CLIPPED_X && NOT_DESTINATION_MASKED) {