Skip to content

Commit

Permalink
Meet the blitters. +other assorted changes.
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.renegadeprojects.com/yrpp/trunk@219 bbc44d77-a14d-0410-bbfb-905795908d03
  • Loading branch information
DCoderLT committed Apr 19, 2009
1 parent aef717a commit 21ac20b
Show file tree
Hide file tree
Showing 57 changed files with 2,775 additions and 16 deletions.
118 changes: 118 additions & 0 deletions Blitters.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#ifndef SHITBLIT_H
#define SHITBLIT_H

// This file contains strong language, excessive amounts of copy pasting and is known to make grown men cry.
// Proceed at your own risk.
// Don't forget to email ex-Westwood coders and tell them just how much you love their awesome code.

class BlitterCore {
public:
BlitterCore() {};
virtual ~BlitterCore() {};

// depending on the blitter, these have different intepretations and usage
// zBuf - pointer to Z-buffer data
// zMin - minimum Z value (context)
// aBuf - pointer to Alpha buffer data
// aLvl - Alpha threshold (context)
// warpOffset - offset for warping the data (context)
virtual void Blit
(void *dst, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit0
(void *dst, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl,
WORD unknownArg, DWORD useless) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit1
(void *dst, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit2
(void *dst, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl,
DWORD useless) = 0;

};

template<typename T>
class Blitter : public BlitterCore {
public:
Blitter() {};
virtual ~Blitter() {};

// depending on the blitter, these have different intepretations and usage
// zBuf - pointer to Z-buffer data
// zMin - minimum Z value (context)
// aBuf - pointer to Alpha buffer data
// aLvl - Alpha threshold (context)
// warpOffset - offset for warping the data (context)
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl,
WORD unknownArg, DWORD useless) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl) = 0;

// actual body: this->Blit(dst, src, length, zMin, zBuf, aBuf, aLvl, 0);
virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl,
DWORD useless) = 0;

byte *Data; // LightConvertClass's byte buffer
};

class RLEBlitterCore {
public:
RLEBlitterCore() {};
virtual ~RLEBlitterCore() {};

// depending on the blitter, these have different intepretations and usage
// zBuf - pointer to Z-buffer data
// zMin - minimum Z value (context)
// aBuf - pointer to Alpha buffer data
// aLvl - Alpha threshold (context)
// warpOffset - offset for warping the data (context)
virtual void Blit
(void *dst, byte *src, byte Length, int EncodedLen, int a6, int a7, int a8, int a9, int a10, int a11) = 0;

// actual body: this->Blit(dst, src, Length, EncodedLen, a6, a7, a8, a9, a10, a11);
virtual void CallBlit0
(void *dst, byte *src, byte Length, int EncodedLen, int a6, int a7, int a8, int a9, int a10, int a11,
DWORD useless) = 0;

byte *Data; // LightConvertClass's byte buffer
};

template<typename T>
class RLEBlitter : public RLEBlitterCore {
public:
RLEBlitter() {};
virtual ~RLEBlitter() {};

/*
// depending on the blitter, these have different intepretations and usage
// zBuf - pointer to Z-buffer data
// zMin - minimum Z value (context)
// aBuf - pointer to Alpha buffer data
// aLvl - Alpha threshold (context)
// warpOffset - offset for warping the data (context)
virtual void Blit
(T *dst, byte *src, byte Length, int EncodedLen, int a6, int a7, int a8, int a9, int a10, int a11) = 0;
// actual body: this->Blit(dst, src, Length, EncodedLen, a6, a7, a8, a9, a10, a11);
virtual void CallBlit0
(T *dst, byte *src, byte Length, int EncodedLen, int a6, int a7, int a8, int a9, int a10, int a11,
DWORD useless) = 0;
byte *Data; // LightConvertClass's byte buffer
*/
};


#endif
41 changes: 41 additions & 0 deletions Blitters/Blitter/BlitPlainXlat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef BLITPLAINXLAT_H
#define BLITPLAINXLAT_H

#include <Blitters.h>

template <typename T>
class BlitPlainXlat : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
for (; length > 0; --length, ++dst) {
word *buf = this->Data;
int idx = *src++;
*dst = buf[idx];
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
47 changes: 47 additions & 0 deletions Blitters/Blitter/BlitPlainXlatAlpha.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#ifndef BLITPLAINXLATALPHA_H
#define BLITPLAINXLATALPHA_H

#include <Blitters.h>

template <typename T>
class BlitPlainXlatAlpha : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
int alphaLevel = min((261 * max(aLvl, 0)) >> 11, 254);
word *extra = this->ExtraData[alphaLevel << 9];
for (; length > 0; --length, ++dst) {
word *buf = this->Data;
byte srcv = *src++;
byte aphv = *aBuf++;
*dst++ = this->Data[srcv | extra[aphv]];
if (Drawing::ABuffer->BufferEnd <= aBuf) {
aBuf -= Drawing::ABuffer->BufferSize;
}
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
45 changes: 45 additions & 0 deletions Blitters/Blitter/BlitPlainXlatZRead.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#ifndef BLITPLAINXLATZREAD_H
#define BLITPLAINXLATZREAD_H

#include <Blitters.h>

template <typename T>
class BlitPlainXlatZRead : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
for (; length > 0; --length, ++dst) {
WORD zVal = *zBuf++;
if (zVal > zMin) {
*dst = this->Data[*src++];
}
if (Drawing::ZBuffer->BufferEnd <= zBuf) {
zBuf -= Drawing::ZBuffer->BufferSize;
}
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
48 changes: 48 additions & 0 deletions Blitters/Blitter/BlitPlainXlatZReadWrite.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef BLITPLAINXLATZREADWRITE_H
#define BLITPLAINXLATZREADWRITE_H

#include <Blitters.h>

template <typename T>
class BlitPlainXlatZReadWrite : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
for (; length > 0; --length, ++dst) {
WORD zVal = *zBuf;
if (zVal > zMin) {
byte srcval = *src++;
*dst = this->Data[srcval];
*zBuf = srcval;
}
++zBuf;
if (Drawing::ZBuffer->BufferEnd <= zBuf) {
zBuf -= Drawing::ZBuffer->BufferSize;
}
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
41 changes: 41 additions & 0 deletions Blitters/Blitter/BlitTransDarken.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef BLITTRANSDARKEN_H
#define BLITTRANSDARKEN_H

#include <Blitters.h>

template <typename T>
class BlitTransDarken : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
for (; length > 0; --length, ++dst) {
if (*src++) {
*dst = this->Data & (*dst >> 1);
}
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
48 changes: 48 additions & 0 deletions Blitters/Blitter/BlitTransDarkenZRead.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef BLITTRANSDARKENZREAD_H
#define BLITTRANSDARKENZREAD_H

#include <Blitters.h>

template <typename T>
class BlitTransDarkenZRead : public Blitter<T> {
virtual void Blit
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, int warpOffset)
{
T *dst = reinterpret_cast < T * >(dest);
for (; length > 0; --length, ++dst) {
WORD zVal = *zBuf++;
if (zVal > zMin) {
int idx = *src++;
if (idx) {
*dst = this->Data & (*dst >> 1);
}
}
if (Drawing::ZBuffer->BufferEnd <= zBuf) {
zBuf -= Drawing::ZBuffer->BufferSize;
}
}
}

virtual void CallBlit0
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, WORD unknownArg, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit1
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

virtual void CallBlit2
(void *dest, byte *src, unsigned int length, WORD zMin, WORD *zBuf, WORD *aBuf, WORD aLvl, DWORD useless)
{
this->Blit(dest, src, length, zMin, zBuf, aBuf, aLvl, 0);
}

public:
T *Data;
};

#endif
Loading

0 comments on commit 21ac20b

Please sign in to comment.