Skip to content

Commit

Permalink
HUGO: Some more renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Jun 13, 2012
1 parent 9bc0591 commit 9984481
Show file tree
Hide file tree
Showing 7 changed files with 160 additions and 160 deletions.
66 changes: 33 additions & 33 deletions engines/hugo/display.cpp
Expand Up @@ -85,20 +85,20 @@ Screen::Screen(HugoEngine *vm) : _vm(vm) {
fontLoadedFl[i] = false;
}
for (int i = 0; i < kBlitListSize; i++) {
_dlBlistList[i].x = 0;
_dlBlistList[i].y = 0;
_dlBlistList[i].dx = 0;
_dlBlistList[i].dy = 0;
_dlBlistList[i]._x = 0;
_dlBlistList[i]._y = 0;
_dlBlistList[i]._dx = 0;
_dlBlistList[i]._dy = 0;
}
for (int i = 0; i < kRectListSize; i++) {
_dlAddList[i].x = 0;
_dlAddList[i].y = 0;
_dlAddList[i].dx = 0;
_dlAddList[i].dy = 0;
_dlRestoreList[i].x = 0;
_dlRestoreList[i].y = 0;
_dlRestoreList[i].dx = 0;
_dlRestoreList[i].dy = 0;
_dlAddList[i]._x = 0;
_dlAddList[i]._y = 0;
_dlAddList[i]._dx = 0;
_dlAddList[i]._dy = 0;
_dlRestoreList[i]._x = 0;
_dlRestoreList[i]._y = 0;
_dlRestoreList[i]._dx = 0;
_dlRestoreList[i]._dy = 0;
}
}

Expand Down Expand Up @@ -274,15 +274,15 @@ void Screen::displayFrame(const int sx, const int sy, seq_t *seq, const bool for
void Screen::merge(const rect_t *rectA, rect_t *rectB) {
debugC(6, kDebugDisplay, "merge()");

int16 xa = rectA->x + rectA->dx; // Find x2,y2 for each rectangle
int16 xb = rectB->x + rectB->dx;
int16 ya = rectA->y + rectA->dy;
int16 yb = rectB->y + rectB->dy;
int16 xa = rectA->_x + rectA->_dx; // Find x2,y2 for each rectangle
int16 xb = rectB->_x + rectB->_dx;
int16 ya = rectA->_y + rectA->_dy;
int16 yb = rectB->_y + rectB->_dy;

rectB->x = MIN(rectA->x, rectB->x); // Minimum x,y
rectB->y = MIN(rectA->y, rectB->y);
rectB->dx = MAX(xa, xb) - rectB->x; // Maximum dx,dy
rectB->dy = MAX(ya, yb) - rectB->y;
rectB->_x = MIN(rectA->_x, rectB->_x); // Minimum x,y
rectB->_y = MIN(rectA->_y, rectB->_y);
rectB->_dx = MAX(xa, xb) - rectB->_x; // Maximum dx,dy
rectB->_dy = MAX(ya, yb) - rectB->_y;
}

/**
Expand All @@ -301,7 +301,7 @@ int16 Screen::mergeLists(rect_t *list, rect_t *blist, const int16 len, int16 ble
int16 c = 0;
rect_t *bp = blist;
for (int16 b = 0; b < blen; b++, bp++) {
if (bp->dx) // blist entry used
if (bp->_dx) // blist entry used
if (isOverlapping(list, bp))
coalesce[c++] = b;
}
Expand All @@ -318,7 +318,7 @@ int16 Screen::mergeLists(rect_t *list, rect_t *blist, const int16 len, int16 ble
while (--c) {
rect_t *cp = &blist[coalesce[c]];
merge(cp, bp);
cp->dx = 0; // Delete entry
cp->_dx = 0; // Delete entry
}
}
}
Expand Down Expand Up @@ -348,10 +348,10 @@ void Screen::displayList(dupdate_t update, ...) {
}
va_start(marker, update); // Initialize variable arguments
p = &_dlAddList[_dlAddIndex];
p->x = va_arg(marker, int); // x
p->y = va_arg(marker, int); // y
p->dx = va_arg(marker, int); // dx
p->dy = va_arg(marker, int); // dy
p->_x = va_arg(marker, int); // x
p->_y = va_arg(marker, int); // y
p->_dx = va_arg(marker, int); // dx
p->_dy = va_arg(marker, int); // dy
va_end(marker); // Reset variable arguments
_dlAddIndex++;
break;
Expand All @@ -370,15 +370,15 @@ void Screen::displayList(dupdate_t update, ...) {

// Blit the combined blit-list
for (_dlRestoreIndex = 0, p = _dlBlistList; _dlRestoreIndex < blitLength; _dlRestoreIndex++, p++) {
if (p->dx) // Marks a used entry
displayRect(p->x, p->y, p->dx, p->dy);
if (p->_dx) // Marks a used entry
displayRect(p->_x, p->_y, p->_dx, p->_dy);
}
break;
case kDisplayRestore: // Restore each rectangle
for (_dlRestoreIndex = 0, p = _dlAddList; _dlRestoreIndex < _dlAddIndex; _dlRestoreIndex++, p++) {
// Restoring from _backBuffer to _frontBuffer
_dlRestoreList[_dlRestoreIndex] = *p; // Copy add-list to restore-list
moveImage(_backBuffer, p->x, p->y, p->dx, p->dy, kXPix, _frontBuffer, p->x, p->y, kXPix);
moveImage(_backBuffer, p->_x, p->_y, p->_dx, p->_dy, kXPix, _frontBuffer, p->_x, p->_y, kXPix);
}
_dlAddIndex = 0; // Reset add-list
break;
Expand Down Expand Up @@ -628,19 +628,19 @@ void Screen::hideCursor() {
}

bool Screen::isInX(const int16 x, const rect_t *rect) const {
return (x >= rect->x) && (x <= rect->x + rect->dx);
return (x >= rect->_x) && (x <= rect->_x + rect->_dx);
}

bool Screen::isInY(const int16 y, const rect_t *rect) const {
return (y >= rect->y) && (y <= rect->y + rect->dy);
return (y >= rect->_y) && (y <= rect->_y + rect->_dy);
}

/**
* Check if two rectangles are overlapping
*/
bool Screen::isOverlapping(const rect_t *rectA, const rect_t *rectB) const {
return (isInX(rectA->x, rectB) || isInX(rectA->x + rectA->dx, rectB) || isInX(rectB->x, rectA) || isInX(rectB->x + rectB->dx, rectA)) &&
(isInY(rectA->y, rectB) || isInY(rectA->y + rectA->dy, rectB) || isInY(rectB->y, rectA) || isInY(rectB->y + rectB->dy, rectA));
return (isInX(rectA->_x, rectB) || isInX(rectA->_x + rectA->_dx, rectB) || isInX(rectB->_x, rectA) || isInX(rectB->_x + rectB->_dx, rectA)) &&
(isInY(rectA->_y, rectB) || isInY(rectA->_y + rectA->_dy, rectB) || isInY(rectB->_y, rectA) || isInY(rectB->_y + rectB->_dy, rectA));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions engines/hugo/display.h
Expand Up @@ -39,10 +39,10 @@ static const int kCenter = -1; // Used to center text in x
class Screen {
public:
struct rect_t { // Rectangle used in Display list
int16 x; // Position in dib
int16 y; // Position in dib
int16 dx; // width
int16 dy; // height
int16 _x; // Position in dib
int16 _y; // Position in dib
int16 _dx; // width
int16 _dy; // height
};

Screen(HugoEngine *vm);
Expand Down
70 changes: 35 additions & 35 deletions engines/hugo/file.cpp
Expand Up @@ -53,7 +53,7 @@ static const int s_bootCypherLen = sizeof(s_bootCypher) - 1;


FileManager::FileManager(HugoEngine *vm) : _vm(vm) {
has_read_header = false;
_hasReadHeader = false;
firstUIFFl = true;
}

Expand Down Expand Up @@ -115,23 +115,23 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr
debugC(1, kDebugFile, "readPCX(..., %s)", name);

// Read in the PCC header and check consistency
PCC_header.mfctr = f.readByte();
PCC_header.vers = f.readByte();
PCC_header.enc = f.readByte();
PCC_header.bpx = f.readByte();
PCC_header.x1 = f.readUint16LE();
PCC_header.y1 = f.readUint16LE();
PCC_header.x2 = f.readUint16LE();
PCC_header.y2 = f.readUint16LE();
PCC_header.xres = f.readUint16LE();
PCC_header.yres = f.readUint16LE();
f.read(PCC_header.palette, sizeof(PCC_header.palette));
PCC_header.vmode = f.readByte();
PCC_header.planes = f.readByte();
PCC_header.bytesPerLine = f.readUint16LE();
f.read(PCC_header.fill2, sizeof(PCC_header.fill2));

if (PCC_header.mfctr != 10)
_PCCHeader._mfctr = f.readByte();
_PCCHeader._vers = f.readByte();
_PCCHeader._enc = f.readByte();
_PCCHeader._bpx = f.readByte();
_PCCHeader._x1 = f.readUint16LE();
_PCCHeader._y1 = f.readUint16LE();
_PCCHeader._x2 = f.readUint16LE();
_PCCHeader._y2 = f.readUint16LE();
_PCCHeader._xres = f.readUint16LE();
_PCCHeader._yres = f.readUint16LE();
f.read(_PCCHeader._palette, sizeof(_PCCHeader._palette));
_PCCHeader._vmode = f.readByte();
_PCCHeader._planes = f.readByte();
_PCCHeader._bytesPerLine = f.readUint16LE();
f.read(_PCCHeader._fill2, sizeof(_PCCHeader._fill2));

if (_PCCHeader._mfctr != 10)
error("Bad data file format: %s", name);

// Allocate memory for seq_t if 0
Expand All @@ -142,10 +142,10 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr

// Find size of image data in 8-bit DIB format
// Note save of x2 - marks end of valid data before garbage
uint16 bytesPerLine4 = PCC_header.bytesPerLine * 4; // 4-bit bpl
uint16 bytesPerLine4 = _PCCHeader._bytesPerLine * 4; // 4-bit bpl
seqPtr->_bytesPerLine8 = bytesPerLine4 * 2; // 8-bit bpl
seqPtr->_lines = PCC_header.y2 - PCC_header.y1 + 1;
seqPtr->_x2 = PCC_header.x2 - PCC_header.x1 + 1;
seqPtr->_lines = _PCCHeader._y2 - _PCCHeader._y1 + 1;
seqPtr->_x2 = _PCCHeader._x2 - _PCCHeader._x1 + 1;
// Size of the image
uint16 size = seqPtr->_lines * seqPtr->_bytesPerLine8;

Expand All @@ -168,12 +168,12 @@ seq_t *FileManager::readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr
for (int i = 0; i < (c & kLengthMask); i++) {
*p++ = d;
if ((uint16)(p - pline) == bytesPerLine4)
p = convertPCC(pline, y++, PCC_header.bytesPerLine, imagePtr);
p = convertPCC(pline, y++, _PCCHeader._bytesPerLine, imagePtr);
}
} else {
*p++ = c;
if ((uint16)(p - pline) == bytesPerLine4)
p = convertPCC(pline, y++, PCC_header.bytesPerLine, imagePtr);
p = convertPCC(pline, y++, _PCCHeader._bytesPerLine, imagePtr);
}
}
return seqPtr;
Expand Down Expand Up @@ -296,27 +296,27 @@ sound_pt FileManager::getSound(const int16 sound, uint16 *size) {
return 0;
}

if (!has_read_header) {
if (!_hasReadHeader) {
for (int i = 0; i < kMaxSounds; i++) {
s_hdr[i]._size = fp.readUint16LE();
s_hdr[i]._offset = fp.readUint32LE();
_s_hdr[i]._size = fp.readUint16LE();
_s_hdr[i]._offset = fp.readUint32LE();
}
if (fp.err())
error("Wrong sound file format");
has_read_header = true;
_hasReadHeader = true;
}

*size = s_hdr[sound]._size;
*size = _s_hdr[sound]._size;
if (*size == 0)
error("Wrong sound file format or missing sound %d", sound);

// Allocate memory for sound or music, if possible
sound_pt soundPtr = (byte *)malloc(s_hdr[sound]._size); // Ptr to sound data
sound_pt soundPtr = (byte *)malloc(_s_hdr[sound]._size); // Ptr to sound data
assert(soundPtr);

// Seek to data and read it
fp.seek(s_hdr[sound]._offset, SEEK_SET);
if (fp.read(soundPtr, s_hdr[sound]._size) != s_hdr[sound]._size)
fp.seek(_s_hdr[sound]._offset, SEEK_SET);
if (fp.read(soundPtr, _s_hdr[sound]._size) != _s_hdr[sound]._size)
error("Wrong sound file format");

fp.close();
Expand Down Expand Up @@ -639,8 +639,8 @@ uif_hdr_t *FileManager::getUIFHeader(const uif_t id) {
error("Wrong UIF file format");

for (int i = 0; i < kMaxUifs; ++i) {
UIFHeader[i].size = ip.readUint16LE();
UIFHeader[i].offset = ip.readUint32LE();
UIFHeader[i]._size = ip.readUint16LE();
UIFHeader[i]._offset = ip.readUint32LE();
}

ip.close();
Expand All @@ -661,7 +661,7 @@ void FileManager::readUIFItem(const int16 id, byte *buf) {

// Seek to data
uif_hdr_t *UIFHeaderPtr = getUIFHeader((uif_t)id);
ip.seek(UIFHeaderPtr->offset, SEEK_SET);
ip.seek(UIFHeaderPtr->_offset, SEEK_SET);

// We support pcx images and straight data
seq_t *dummySeq; // Dummy seq_t for image data
Expand All @@ -671,7 +671,7 @@ void FileManager::readUIFItem(const int16 id, byte *buf) {
free(dummySeq);
break;
default: // Read file data into supplied array
if (ip.read(buf, UIFHeaderPtr->size) != UIFHeaderPtr->size)
if (ip.read(buf, UIFHeaderPtr->_size) != UIFHeaderPtr->_size)
error("Wrong UIF file format");
break;
}
Expand Down
42 changes: 21 additions & 21 deletions engines/hugo/file.h
Expand Up @@ -37,8 +37,8 @@ namespace Hugo {
enum ovl_t {kOvlBoundary, kOvlOverlay, kOvlBase};

struct uif_hdr_t { // UIF font/image look up
uint16 size; // Size of uif item
uint32 offset; // Offset of item in file
uint16 _size; // Size of uif item
uint32 _offset; // Offset of item in file
};


Expand Down Expand Up @@ -85,24 +85,24 @@ class FileManager {
* Structure of scenery file lookup entry
*/
struct sceneBlock_t {
uint32 scene_off;
uint32 scene_len;
uint32 b_off;
uint32 b_len;
uint32 o_off;
uint32 o_len;
uint32 ob_off;
uint32 ob_len;
uint32 _scene_off;
uint32 _scene_len;
uint32 _b_off;
uint32 _b_len;
uint32 _o_off;
uint32 _o_len;
uint32 _ob_off;
uint32 _ob_len;
};

struct PCC_header_t { // Structure of PCX file header
byte mfctr, vers, enc, bpx;
uint16 x1, y1, x2, y2; // bounding box
uint16 xres, yres;
byte palette[3 * kNumColors]; // EGA color palette
byte vmode, planes;
uint16 bytesPerLine; // Bytes per line
byte fill2[60];
struct _PCCHeader_t { // Structure of PCX file header
byte _mfctr, _vers, _enc, _bpx;
uint16 _x1, _y1, _x2, _y2; // bounding box
uint16 _xres, _yres;
byte _palette[3 * kNumColors]; // EGA color palette
byte _vmode, _planes;
uint16 _bytesPerLine; // Bytes per line
byte _fill2[60];
}; // Header of a PCC file

bool firstUIFFl;
Expand All @@ -112,13 +112,13 @@ class FileManager {
Common::File _sceneryArchive1; // Handle for scenery file
Common::File _objectsArchive; // Handle for objects file

PCC_header_t PCC_header;
_PCCHeader_t _PCCHeader;

seq_t *readPCX(Common::ReadStream &f, seq_t *seqPtr, byte *imagePtr, const bool firstFl, const char *name);

// If this is the first call, read the lookup table
bool has_read_header;
sound_hdr_t s_hdr[kMaxSounds]; // Sound lookup table
bool _hasReadHeader;
sound_hdr_t _s_hdr[kMaxSounds]; // Sound lookup table

private:
byte *convertPCC(byte *p, const uint16 y, const uint16 bpl, image_pt dataPtr) const;
Expand Down

0 comments on commit 9984481

Please sign in to comment.