Skip to content

Commit

Permalink
ACCESS: In progress inventory display screen
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Aug 24, 2014
1 parent 955df7a commit ee62d6c
Show file tree
Hide file tree
Showing 12 changed files with 363 additions and 64 deletions.
3 changes: 3 additions & 0 deletions engines/access/asurface.cpp
Expand Up @@ -265,6 +265,9 @@ void ASurface::copyTo(ASurface *dest, const Common::Rect &bounds) {
}
}

void ASurface::copyTo(ASurface *dest) {
copyTo(dest, Common::Point());
}

void ASurface::plotF(SpriteFrame *frame, const Common::Point &pt) {
sPlotF(frame, Common::Rect(pt.x, pt.y, pt.x + frame->w, pt.y + frame->h));
Expand Down
2 changes: 2 additions & 0 deletions engines/access/asurface.h
Expand Up @@ -92,6 +92,8 @@ class ASurface : public Graphics::Surface {

void copyTo(ASurface *dest, const Common::Rect &bounds);

void copyTo(ASurface *dest);

void saveBlock(const Common::Rect &bounds);

void restoreBlock();
Expand Down
88 changes: 47 additions & 41 deletions engines/access/events.cpp
Expand Up @@ -41,62 +41,68 @@ EventsManager::EventsManager(AccessEngine *vm): _vm(vm) {
_priorFrameTime = 0;
_leftButton = _rightButton = false;
_mouseCol = _mouseRow = 0;
_mouseMode = 0;
_cursorExitFlag = false;
}

EventsManager::~EventsManager() {
_invCursor.free();
}

void EventsManager::setCursor(CursorType cursorId) {
if (cursorId == _cursorId)
return;
_cursorId = cursorId;

if (_mouseMode == 1 && cursorId == CURSOR_ARROW)
_mouseMode = 2;
else if (_mouseMode == 2 && cursorId != CURSOR_ARROW)
_mouseMode = 1;

// Get a pointer to the mouse data to use, and get the cursor hotspot
const byte *srcP = Amazon::CURSORS[cursorId];
int hotspotX = (int16)READ_LE_UINT16(srcP);
int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
srcP += 4;

// Create a surface to build up the cursor on
Graphics::Surface cursorSurface;
cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
byte *destP = (byte *)cursorSurface.getPixels();
Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);

// Loop to build up the cursor
for (int y = 0; y < CURSOR_HEIGHT; ++y) {
destP = (byte *)cursorSurface.getBasePtr(0, y);
int width = CURSOR_WIDTH;
int skip = *srcP++;
int plot = *srcP++;
if (skip >= width)
break;
if (cursorId == CURSOR_INVENTORY) {
// Set the cursor
CursorMan.replaceCursor(_invCursor.getPixels(), _invCursor.w, _invCursor.h,
0, 0, 0);
} else {
// Get a pointer to the mouse data to use, and get the cursor hotspot
const byte *srcP = Amazon::CURSORS[cursorId];
int hotspotX = (int16)READ_LE_UINT16(srcP);
int hotspotY = (int16)READ_LE_UINT16(srcP + 2);
srcP += 4;

// Create a surface to build up the cursor on
Graphics::Surface cursorSurface;
cursorSurface.create(16, 16, Graphics::PixelFormat::createFormatCLUT8());
byte *destP = (byte *)cursorSurface.getPixels();
Common::fill(destP, destP + CURSOR_WIDTH * CURSOR_HEIGHT, 0);

// Loop to build up the cursor
for (int y = 0; y < CURSOR_HEIGHT; ++y) {
destP = (byte *)cursorSurface.getBasePtr(0, y);
int width = CURSOR_WIDTH;
int skip = *srcP++;
int plot = *srcP++;
if (skip >= width)
break;

// Skip over pixels
destP += skip;
width -= skip;

// Write out the pixels to plot
while (plot > 0 && width > 0) {
*destP++ = *srcP++;
--plot;
--width;
}
}

// Skip over pixels
destP += skip;
width -= skip;
// Set the cursor
CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
hotspotX, hotspotY, 0);

// Write out the pixels to plot
while (plot > 0 && width > 0) {
*destP++ = *srcP++;
--plot;
--width;
}
// Free the cursor surface
cursorSurface.free();
}
}

// Set the cursor
CursorMan.replaceCursor(cursorSurface.getPixels(), CURSOR_WIDTH, CURSOR_HEIGHT,
hotspotX, hotspotY, 0);

// Free the cursor surface
cursorSurface.free();
void EventsManager::setCursorData(Graphics::Surface *src, const Common::Rect &r) {
_invCursor.create(r.width(), r.height(), Graphics::PixelFormat::createFormatCLUT8());
_invCursor.copyRectToSurface(*src, 0, 0, r);
}

void EventsManager::showCursor() {
Expand Down
10 changes: 8 additions & 2 deletions engines/access/events.h
Expand Up @@ -32,7 +32,8 @@ namespace Access {
enum CursorType {
CURSOR_NONE = -1,
CURSOR_ARROW = 0, CURSOR_CROSSHAIRS, CURSOR_2, CURSOR_3, CURSOR_LOOK,
CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP
CURSOR_USE, CURSOR_TAKE, CURSOR_CLIMB, CURSOR_TALK, CURSOR_HELP,
CURSOR_INVENTORY = 99
};

#define GAME_FRAME_RATE 100
Expand All @@ -45,6 +46,7 @@ class EventsManager {
AccessEngine *_vm;
uint32 _frameCounter;
uint32 _priorFrameTime;
Graphics::Surface _invCursor;

bool checkForNextFrameCounter();

Expand All @@ -55,7 +57,6 @@ class EventsManager {
bool _leftButton, _rightButton;
Common::Point _mousePos;
int _mouseCol, _mouseRow;
int _mouseMode;
bool _cursorExitFlag;
Common::FixedStack<Common::KeyState> _keypresses;
public:
Expand All @@ -74,6 +75,11 @@ class EventsManager {
*/
void setCursor(CursorType cursorId);

/**
* Set the image for the inventory cursor
*/
void setCursorData(Graphics::Surface *src, const Common::Rect &r);

/**
* Return the current cursor Id
*/
Expand Down
8 changes: 8 additions & 0 deletions engines/access/files.cpp
Expand Up @@ -39,6 +39,14 @@ void FileIdent::load(Common::SeekableReadStream &s) {

/*------------------------------------------------------------------------*/

CellIdent::CellIdent(int cell, int fileNum, int subfile) {
_cell = cell;
_fileNum = fileNum;
_subfile = subfile;
}

/*------------------------------------------------------------------------*/

FileManager::FileManager(AccessEngine *vm): _vm(vm) {
switch (vm->getGameID()) {
case GType_Amazon:
Expand Down
3 changes: 3 additions & 0 deletions engines/access/files.h
Expand Up @@ -43,6 +43,9 @@ struct FileIdent {

struct CellIdent : FileIdent {
byte _cell;

CellIdent() {}
CellIdent(int cell, int fileNum, int subfile);
};

class FileManager {
Expand Down

0 comments on commit ee62d6c

Please sign in to comment.