Skip to content

Commit

Permalink
Cleanup: Moved PatchName to libdoomsday
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Jul 9, 2016
1 parent 1a93bd8 commit d9068aa
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 286 deletions.
3 changes: 2 additions & 1 deletion doomsday/apps/client/include/resource/compositetexture.h
Expand Up @@ -21,6 +21,8 @@
#ifndef DENG_RESOURCE_COMPOSITETEXTURE_H
#define DENG_RESOURCE_COMPOSITETEXTURE_H

#include <doomsday/resource/patchname.h>

#include <QList>
#include <QMultiMap>

Expand All @@ -29,7 +31,6 @@
#include <de/Vector>

#include "dd_types.h" // For lumpnum_t
#include "patchname.h"

namespace de {

Expand Down
52 changes: 0 additions & 52 deletions doomsday/apps/client/include/resource/tga.h
Expand Up @@ -27,58 +27,6 @@
/// @addtogroup resource
///@{

#if 0

/**
* Saves the buffer (which is formatted rgb565) to a Targa 24 image file.
*
* @param file Handle to the open file to be written to.
* @param w Width of the image in pixels.
* @param h Height of the image in pixels.
* @param buf Ptr to the image data to be written.
*
* @return Non-zero iff successful.
*/
int TGA_Save24_rgb565(FILE *file, int w, int h, uint16_t const *buf);

/**
* Save the rgb888 buffer as Targa 24.
*
* @param file Handle to the open file to be written to.
* @param w Width of the image in pixels.
* @param h Height of the image in pixels.
* @param buf Ptr to the image data to be written.
*
* @return Non-zero iff successful.
*/
int TGA_Save24_rgb888(FILE *file, int w, int h, uint8_t const *buf);

/**
* Save the rgb8888 buffer as Targa 24.
*
* @param file Handle to the open file to be written to.
* @param w Width of the image in pixels.
* @param h Height of the image in pixels.
* @param buf Ptr to the image data to be written.
*
* @return Non-zero iff successful.
*/
int TGA_Save24_rgba8888(FILE *file, int w, int h, uint8_t const *buf);

/**
* Save the rgb888 buffer as Targa 16.
*
* @param file Handle to the open file to be written to.
* @param w Width of the image in pixels.
* @param h Height of the image in pixels.
* @param buf Ptr to the image data to be written.
*
* @return Non-zero iff successful.
*/
int TGA_Save16_rgb888(FILE *file, int w, int h, uint8_t const *buf);

#endif

/**
* Loads a 24-bit or a 32-bit image (24-bit color + 8-bit alpha).
*
Expand Down
8 changes: 2 additions & 6 deletions doomsday/apps/client/src/clientapp.cpp
Expand Up @@ -180,8 +180,8 @@ DENG2_PIMPL(ClientApp)
// Don't raise alerts if the console history is open; the
// warning/error will be shown there.
if (ClientWindow::mainExists() &&
ClientWindow::main().taskBar().isOpen() &&
ClientWindow::main().taskBar().console().isLogOpen())
ClientWindow::main().taskBar().isOpen() &&
ClientWindow::main().taskBar().console().isLogOpen())
{
return *this;
}
Expand Down Expand Up @@ -256,10 +256,6 @@ DENG2_PIMPL(ClientApp)
DENG2_ASSERT(!"Unclean shutdown: exception in ~ClientApp");
}

//self.audienceForGameChange() -= this;
//self.audienceForGameUnload() -= this;
//self.audienceForConsoleRegistration() -= this;

updater.reset();
//delete infineSys;
delete inputSys;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/resource/compositetexture.cpp
Expand Up @@ -29,7 +29,7 @@
#include <doomsday/filesys/fs_main.h>
#include <doomsday/filesys/lumpindex.h>
#include <doomsday/resource/patch.h>
#include "resource/patchname.h"
#include <doomsday/resource/patchname.h>

namespace de {
namespace internal {
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/resource/resourcesystem.cpp
Expand Up @@ -55,6 +55,7 @@
#include <doomsday/filesys/fs_util.h>
#include <doomsday/filesys/lumpindex.h>
#include <doomsday/resource/patch.h>
#include <doomsday/resource/patchname.h>
#include <doomsday/SavedSession>
#include <doomsday/Session>

Expand All @@ -68,7 +69,6 @@
#include "dd_def.h"

#include "resource/compositetexture.h"
#include "resource/patchname.h"

#ifdef __CLIENT__
# include "gl/gl_tex.h"
Expand Down
219 changes: 0 additions & 219 deletions doomsday/apps/client/src/resource/tga.cpp
Expand Up @@ -99,20 +99,6 @@ static void setLastError(char const *msg)
strcpy(lastErrorMsg, msg);
}


#if 0
static void writeByte(FILE *f, uint8_t b)
{
fwrite(&b, 1, 1, f);
}

static void writeShort(FILE *f, int16_t s)
{
int16_t v = DD_SHORT(s);
fwrite(&v, sizeof(v), 1, f);
}
#endif

static uint8_t readByte(FileHandle &f)
{
uint8_t v;
Expand All @@ -127,90 +113,20 @@ static int16_t readShort(FileHandle &f)
return DD_SHORT(v);
}

#if 0
/**
* @param idLength Identification field size in bytes (max 255).
* @c 0 indicates no identification field.
* @param colorMapType Type of the color map, @c 0 or @c 1:
* @c 0 = color map data is not present.
* @c 1 = color map data IS present.
* @param imageType Image data type code, one of:
* @c 0 = no image data is present.
* @c 1 = uncompressed, color mapped image.
* @c 2 = uncompressed, true-color image.
* @c 3 = uncompressed, grayscale image.
* @c 9 = run-length encoded, color mapped image.
* @c 10 = run-length encoded, true-color image.
* @c 11 = run-length encoded, grayscale image.
* @param file Handle to the file to be written to.
*/
static void writeHeader(uint8_t idLength, uint8_t colorMapType,
uint8_t imageType, FILE *file)
{
writeByte(file, idLength);
writeByte(file, colorMapType? 1 : 0);
writeByte(file, imageType);
}
#endif

static void readHeader(tga_header_t *dst, FileHandle &file)
{
dst->idLength = readByte(file);
dst->colorMapType = readByte(file);
dst->imageType = readByte(file);
}

#if 0
/**
* @param index Index of first color map entry.
* @param length Total number of color map entries.
* @param entrySize Number of bits in a color map entry; 15/16/24/32.
* @param file Handle to the file to be written to.
*/
static void writeColorMapSpec(int16_t index, int16_t length, uint8_t entrySize,
FILE *file)
{
writeShort(file, index);
writeShort(file, length);
writeByte(file, entrySize);
}
#endif

static void readColorMapSpec(tga_colormapspec_t *dst, FileHandle &file)
{
dst->index = readShort(file);
dst->length = readShort(file);
dst->entrySize = readByte(file);
}

#if 0
/**
* @param xOrigin X coordinate of lower left corner.
* @param yOrigin Y coordinate of lower left corner.
* @param width Width of the image in pixels.
* @param height Height of the image in pixels.
* @param pixDepth Number of bits per pixel, one of; 16/24/32.
* @param file Handle to the file to be written to.
*/
static void writeImageSpec(int16_t xOrigin, int16_t yOrigin, int16_t width,
int16_t height, uint8_t pixDepth, FILE *file)
{
writeShort(file, xOrigin);
writeShort(file, yOrigin);
writeShort(file, width);
writeShort(file, height);
writeByte(file, pixDepth);

/*
* attributeBits:4; // Attribute bits associated with each pixel.
* reserved:1; // A reserved bit; must be 0.
* screenOrigin:1; // Location of screen origin; must be 0.
* dataInterleave:2; // TGA_INTERLEAVE_*
*/
writeByte(file, 0);
}
#endif

static void readImageSpec(tga_imagespec_t *dst, FileHandle &file)
{
dst->xOrigin = readShort(file);
Expand Down Expand Up @@ -239,141 +155,6 @@ const char* TGA_LastError(void)
return 0;
}

#if 0
int TGA_Save24_rgb565(FILE *file, int w, int h, const uint16_t *buf)
{
int i, k;
uint8_t *outBuf;
size_t outBufStart;

if(NULL == file || !buf || !(w > 0 && h > 0))
return 0;

// No identification field, no color map, Targa type 2 (unmapped RGB).
writeHeader(0, 0, 2, file);
writeColorMapSpec(0, 0, 0, file);
writeImageSpec(0, 0, w, h, 24, file);

/**
* Convert the buffer:
* From RRRRRGGGGGGBBBBB > ARRRRRGGGGGBBBBB
*
* \note Alpha will always be @c 0.
*/
outBuf = (uint8_t *) M_Malloc(w * h * 3);
outBufStart = w * h - 1; // From the end.
for(k = 0; k < h; ++k)
for(i = 0; i < w; ++i)
{
int16_t r, g, b;
const int16_t src = buf[k * w + i];
uint8_t* dst = &outBuf[outBufStart - (((k + 1) * w - 1 - i)) * 3];

r = (src >> 11) & 0x1f; // The last 5 bits.
g = (src >> 5) & 0x3f; // The middle 6 bits (one bit'll be lost).
b = src & 0x1f; // The first 5 bits.

dst[2] = b << 3;
dst[0] = g << 2;
dst[1] = r << 3;
}

// Write the converted buffer (bytes may go the wrong way around...!).
fwrite(outBuf, w * h * 3, 1, file);
free(outBuf);

return 1; // Success.
}

int TGA_Save24_rgb888(FILE* file, int w, int h, const uint8_t* buf)
{
uint8_t* outBuf;
int i;

if(NULL == file || !buf || !(w > 0 && h > 0))
return 0;

// No identification field, no color map, Targa type 2 (unmapped RGB).
writeHeader(0, 0, 2, file);
writeColorMapSpec(0, 0, 0, file);
writeImageSpec(0, 0, w, h, 24, file);

// The save format is BGR.
outBuf = (uint8_t *) M_Malloc(w * h * 3);
for(i = 0; i < w * h; ++i)
{
const uint8_t* src = &buf[i * 3];
uint8_t* dst = &outBuf[i * 3];

dst[0] = src[2];
dst[1] = src[1];
dst[2] = src[0];
}
fwrite(outBuf, w * h * 3, 1, file);
free(outBuf);

return 1; // Success.
}

int TGA_Save24_rgba8888(FILE* file, int w, int h, const uint8_t* buf)
{
uint8_t* outBuf;
int i;

if(NULL == file || !buf || !(w > 0 && h > 0))
return 0;

// No identification field, no color map, Targa type 2 (unmapped RGB).
writeHeader(0, 0, 2, file);
writeColorMapSpec(0, 0, 0, file);
writeImageSpec(0, 0, w, h, 24, file);

// The save format is BGR.
outBuf = (uint8_t *) M_Malloc(w * h * 3);
for(i = 0; i < w * h; ++i)
{
const uint8_t* src = &buf[i * 4];
uint8_t* dst = &outBuf[i * 3];

dst[0] = src[2];
dst[1] = src[1];
dst[2] = src[0];
}
fwrite(outBuf, w * h * 3, 1, file);
free(outBuf);

return 1; // Success.
}

int TGA_Save16_rgb888(FILE* file, int w, int h, const uint8_t* buf)
{
int16_t* outBuf;
int i;

if(NULL == file || !buf || !(w > 0 && h > 0))
return 0;

// No identification field, no color map, Targa type 2 (unmapped RGB).
writeHeader(0, 0, 2, file);
writeColorMapSpec(0, 0, 0, file);
writeImageSpec(0, 0, w, h, 16, file);

// The destination format is _RRRRRGG GGGBBBBB.
outBuf = (int16_t *) M_Malloc(w * h * 2);
for(i = 0; i < w * h; ++i)
{
const uint8_t* src = &buf[i * 3];
int16_t* dst = &outBuf[i];

*dst = (src[2] >> 3) + ((src[1] & 0xf8) << 2) + ((src[0] & 0xf8) << 7);
}
fwrite(outBuf, w * h * 2, 1, file);
free(outBuf);

return 1; // Success.
}
#endif

uint8_t *TGA_Load(FileHandle &file, Vector2ui &outSize, int &pixelSize)
{
uint8_t *dstBuf = 0;
Expand Down
Expand Up @@ -18,12 +18,12 @@
* 02110-1301 USA</small>
*/

#include "doomsday/resource/patchname.h"
#include "doomsday/filesys/fs_main.h"

#include <de/IReadable>
#include <de/Reader>
#include <de/String>
#include <doomsday/filesys/fs_main.h>

#include "resource/patchname.h"

namespace de {

Expand Down

0 comments on commit d9068aa

Please sign in to comment.