aboutsummaryrefslogtreecommitdiff
path: root/saga
diff options
context:
space:
mode:
authorEugene Sandulenko2005-04-22 01:38:27 +0000
committerEugene Sandulenko2005-04-22 01:38:27 +0000
commit65ade039ecf14033ec114de0697ccb8cfa987673 (patch)
tree763ea04c183ef35282cabcca0b6954594987df83 /saga
parenta81fbc04d996152399857dd01e70dfb78d4d1f02 (diff)
downloadscummvm-rg350-65ade039ecf14033ec114de0697ccb8cfa987673.tar.gz
scummvm-rg350-65ade039ecf14033ec114de0697ccb8cfa987673.tar.bz2
scummvm-rg350-65ade039ecf14033ec114de0697ccb8cfa987673.zip
o Fix save/load. Now it restores game properly but still at exit #0.
o Proper background for inset rooms. Crowd is gone now. o Draw black border around inset rooms. svn-id: r17744
Diffstat (limited to 'saga')
-rw-r--r--saga/events.cpp27
-rw-r--r--saga/gfx.cpp19
-rw-r--r--saga/gfx.h2
-rw-r--r--saga/interface.cpp6
-rw-r--r--saga/isomap.cpp7
-rw-r--r--saga/isomap.h1
-rw-r--r--saga/saveload.cpp78
-rw-r--r--saga/scene.cpp6
-rw-r--r--saga/script.h2
9 files changed, 92 insertions, 56 deletions
diff --git a/saga/events.cpp b/saga/events.cpp
index bbf916443c..759ac679b1 100644
--- a/saga/events.cpp
+++ b/saga/events.cpp
@@ -302,7 +302,7 @@ int Events::handleOneShot(EVENT *event) {
break;
case BG_EVENT:
{
- BUFFER_INFO rbuf_info;
+ BUFFER_INFO rbuf_info;
Point bg_pt;
if (!(_vm->_scene->getFlags() & kSceneFlagISO)) {
@@ -317,6 +317,29 @@ int Events::handleOneShot(EVENT *event) {
bufToBuffer(rbuf_info.bg_buf, rbuf_info.bg_buf_w, rbuf_info.bg_buf_h,
bginfo.bg_buf, bginfo.bg_w, bginfo.bg_h, NULL, &bg_pt);
+
+ // If it is inset scene then draw black border
+ if (bginfo.bg_w < _vm->getDisplayWidth() || bginfo.bg_h < _vm->getSceneHeight()) {
+ SURFACE s;
+ s.pixels = rbuf_info.bg_buf;
+ s.w = s.pitch = rbuf_info.bg_buf_w;
+ s.h = rbuf_info.bg_buf_h;
+ s.bytesPerPixel = 1;
+ Common::Rect rect1(2, bginfo.bg_h + 4);
+ Common::Rect rect2(bginfo.bg_w + 4, 2);
+ Common::Rect rect3(2, bginfo.bg_h + 4);
+ Common::Rect rect4(bginfo.bg_w + 4, 2);
+ rect1.moveTo(bginfo.bg_x - 2, bginfo.bg_y - 2);
+ rect2.moveTo(bginfo.bg_x - 2, bginfo.bg_y - 2);
+ rect3.moveTo(bginfo.bg_x + bginfo.bg_w, bginfo.bg_y - 2);
+ rect4.moveTo(bginfo.bg_x - 2, bginfo.bg_y + bginfo.bg_h);
+
+ drawRect(&s, rect1, kITEColorBlack);
+ drawRect(&s, rect2, kITEColorBlack);
+ drawRect(&s, rect3, kITEColorBlack);
+ drawRect(&s, rect4, kITEColorBlack);
+ }
+
if (event->param == SET_PALETTE) {
PALENTRY *pal_p;
_vm->_scene->getBGPal(&pal_p);
@@ -436,7 +459,7 @@ int Events::handleOneShot(EVENT *event) {
rect.bottom = event->param3;
rect.left = event->param4;
rect.right = event->param5;
- drawRect((SURFACE *)event->data, &rect, event->param);
+ drawRect((SURFACE *)event->data, rect, event->param);
break;
case EVENT_SETFLAG:
_vm->_render->setFlag(event->param);
diff --git a/saga/gfx.cpp b/saga/gfx.cpp
index 450284b89d..072205f456 100644
--- a/saga/gfx.cpp
+++ b/saga/gfx.cpp
@@ -87,7 +87,7 @@ int drawPalette(SURFACE *dst_s) {
pal_rect.left = (x * 8) + 4;
pal_rect.right = pal_rect.left + 8;
- drawRect(dst_s, &pal_rect, color);
+ drawRect(dst_s, pal_rect, color);
color++;
}
}
@@ -355,20 +355,15 @@ int bufToBuffer(byte *dst_buf, int dst_w, int dst_h, const byte *src,
// Fills a rectangle in the surface ds from point 'p1' to point 'p2' using
// the specified color.
-int drawRect(SURFACE *ds, const Rect *dst_rect, int color) {
- Rect r(ds->w, ds->h);
+int drawRect(SURFACE *ds, Rect &dst_rect, int color) {
+ dst_rect.clip(ds->w, ds->h);
- if (dst_rect != NULL) {
- r = *dst_rect;
- r.clip(ds->w, ds->h);
-
- if (!r.isValidRect()) {
- // Empty or negative region
- return FAILURE;
- }
+ if (!dst_rect.isValidRect()) {
+ // Empty or negative region
+ return FAILURE;
}
- ds->fillRect(r, color);
+ ds->fillRect(dst_rect, color);
return SUCCESS;
}
diff --git a/saga/gfx.h b/saga/gfx.h
index e65d91f4be..75b2a284a4 100644
--- a/saga/gfx.h
+++ b/saga/gfx.h
@@ -79,7 +79,7 @@ int bufToSurface(SURFACE *ds, const byte *src, int src_w, int src_h, Rect *src_r
int bufToBuffer(byte * dst_buf, int dst_w, int dst_h, const byte *src,
int src_w, int src_h, Rect *src_rect, Point *dst_pt);
int getClipInfo(CLIPINFO *clipinfo);
-int drawRect(SURFACE *ds, const Rect *dst_rect, int color);
+int drawRect(SURFACE *ds, Rect &dst_rect, int color);
int drawFrame(SURFACE *ds, const Point *p1, const Point *p2, int color);
int drawPolyLine(SURFACE *ds, const Point *pts, int pt_ct, int draw_color);
int clipLine(SURFACE *ds, const Point *src_p1, const Point *src_p2, Point *dst_p1, Point *dst_p2);
diff --git a/saga/interface.cpp b/saga/interface.cpp
index 2e27612de2..85eb0b1f16 100644
--- a/saga/interface.cpp
+++ b/saga/interface.cpp
@@ -440,7 +440,7 @@ void Interface::drawStatusBar() {
rect.right = _vm->getDisplayWidth();
rect.bottom = _vm->getDisplayInfo().statusY + _vm->getDisplayInfo().statusHeight;
- drawRect(backBuffer, &rect, _vm->getDisplayInfo().statusBGColor);
+ drawRect(backBuffer, rect, _vm->getDisplayInfo().statusBGColor);
string_w = _vm->_font->getStringWidth(SMALL_FONT_ID, _statusText, 0, 0);
@@ -835,7 +835,7 @@ void Interface::converseDisplayTextLines(SURFACE *ds) {
rect.moveTo(_conversePanel.x + _conversePanel.buttons[0].xOffset,
_conversePanel.y + _conversePanel.buttons[0].yOffset);
- drawRect(ds, &rect, kITEColorDarkGrey); //fill bullet place
+ drawRect(ds, rect, kITEColorDarkGrey); //fill bullet place
for (int i = 0; i < CONVERSE_TEXT_LINES; i++) {
relPos = _converseStartPos + i;
@@ -854,7 +854,7 @@ void Interface::converseDisplayTextLines(SURFACE *ds) {
_conversePanel.calcPanelButtonRect(&_conversePanel.buttons[i], rect);
rect.left += 8;
- drawRect(ds, &rect, backgnd);
+ drawRect(ds, rect, backgnd);
str = _converseText[relPos].text;
diff --git a/saga/isomap.cpp b/saga/isomap.cpp
index 484ee5ef3b..7b0a3b4ee4 100644
--- a/saga/isomap.cpp
+++ b/saga/isomap.cpp
@@ -380,13 +380,18 @@ int16 IsoMap::findMulti(int16 tileIndex, int16 absU, int16 absV, int16 absH) {
int IsoMap::draw(SURFACE *ds) {
Rect isoRect(_vm->getDisplayWidth(), _vm->getDisplayInfo().sceneHeight);
- drawRect(ds, &isoRect, 0);
+ drawRect(ds, isoRect, 0);
_tileClip = isoRect;
drawTiles(ds, NULL);
return SUCCESS;
}
+void IsoMap::setMapPosition(int x, int y) {
+ _mapPosition.x = x;
+ _mapPosition.y = y;
+}
+
void IsoMap::drawSprite(SURFACE *ds, SpriteList &spriteList, int spriteNumber, const Location &location, const Point &screenPosition, int scale) {
int width;
int height;
diff --git a/saga/isomap.h b/saga/isomap.h
index a59f559dcd..4a23b74f41 100644
--- a/saga/isomap.h
+++ b/saga/isomap.h
@@ -168,6 +168,7 @@ public:
bool nextTileTarget(ActorData* actor);
void setTileDoorState(int doorNumber, int doorState);
Point getMapPosition() { return _mapPosition; }
+ void setMapPosition(int x, int y);
private:
void drawTiles(SURFACE *ds, const Location *location);
diff --git a/saga/saveload.cpp b/saga/saveload.cpp
index fd7f096104..71661128a2 100644
--- a/saga/saveload.cpp
+++ b/saga/saveload.cpp
@@ -35,6 +35,7 @@
#include "saga/script.h"
#include "saga/interface.h"
#include "saga/scene.h"
+#include "saga/render.h"
namespace Saga {
@@ -103,46 +104,49 @@ void SagaEngine::save() {
}
void SagaEngine::load() {
- File out;
+ File in;
int actorsCount, objsCount, commonBufferSize;
int scenenum, inset;
+ int mapx, mapy;
- out.open("ite.sav");
+ in.open("ite.sav");
- if (!out.isOpen())
+ if (!in.isOpen())
return;
- actorsCount = out.readSint16LE();
- objsCount = out.readSint16LE();
- commonBufferSize = out.readSint16LE();
- _actor->setProtagState(out.readSint16LE());
+ actorsCount = in.readSint16LE();
+ objsCount = in.readSint16LE();
+ commonBufferSize = in.readSint16LE();
+ _actor->setProtagState(in.readSint16LE());
// Surrounding scene
- scenenum = out.readSint32LE();
- out.readSint32LE();
+ scenenum = in.readSint32LE();
+ in.readSint32LE();
// Inset scene
- inset = out.readSint32LE();
- out.readSint32LE();
+ inset = in.readSint32LE();
+ in.readSint32LE();
+
+ debug(0, "scene: %d out: %d", scenenum, inset);
uint16 i;
for (i = 0; i < actorsCount; i++) {
ActorData *a = _actor->_actors[i];
- a->sceneNumber = out.readSint32LE();
- a->location.x = out.readSint16LE();
- a->location.y = out.readSint16LE();
- a->location.z = out.readSint16LE();
- a->finalTarget.x = out.readSint16LE();
- a->finalTarget.y = out.readSint16LE();
- a->finalTarget.z = out.readSint16LE();
- a->currentAction = out.readByte();
- a->facingDirection = out.readByte();
- a->targetObject = out.readSint16LE();
- a->flags = (a->flags & ~(kProtagonist | kFollower) | out.readByte());
- a->frameNumber = out.readByte();
- out.readSint16LE();
+ a->sceneNumber = in.readSint32LE();
+ a->location.x = in.readSint16LE();
+ a->location.y = in.readSint16LE();
+ a->location.z = in.readSint16LE();
+ a->finalTarget.x = in.readSint16LE();
+ a->finalTarget.y = in.readSint16LE();
+ a->finalTarget.z = in.readSint16LE();
+ a->currentAction = in.readByte();
+ a->facingDirection = in.readByte();
+ a->targetObject = in.readSint16LE();
+ a->flags = (a->flags & ~(kProtagonist | kFollower) | in.readByte());
+ a->frameNumber = in.readByte();
+ in.readSint16LE();
}
_interface->clearInventory();
@@ -151,28 +155,29 @@ void SagaEngine::load() {
ObjectData *o = _actor->_objs[i];
int pos;
- o->sceneNumber = out.readSint32LE();
- o->id = out.readSint32LE();
- o->location.x = out.readSint16LE();
- o->location.y = out.readSint16LE();
- o->location.z = out.readSint16LE();
- o->nameIndex = out.readSint16LE();
+ o->sceneNumber = in.readSint32LE();
+ o->id = in.readSint32LE();
+ o->location.x = in.readSint16LE();
+ o->location.y = in.readSint16LE();
+ o->location.z = in.readSint16LE();
+ o->nameIndex = in.readSint16LE();
- pos = out.readSint16LE();
+ pos = in.readSint16LE();
if (o->sceneNumber == ITE_SCENE_INV) {
_interface->addToInventory(_actor->objIndexToId(i), pos);
}
- out.readByte();
+ in.readByte();
}
for (i = 0; i < commonBufferSize; i++)
- _script->_commonBuffer[i] = out.readByte();
+ _script->_commonBuffer[i] = in.readByte();
- _isoMap->getMapPosition().x = out.readSint16LE();
- _isoMap->getMapPosition().y = out.readSint16LE();
+ mapx = in.readSint16LE();
+ mapy = in.readSint16LE();
- out.close();
+ in.close();
+ _isoMap->setMapPosition(mapx, mapy);
// FIXME: When save/load screen will be implemented we should
// call these after that screen left by user
@@ -184,6 +189,7 @@ void SagaEngine::load() {
_scene->changeScene(scenenum, 0);
if (inset != scenenum) {
+ _render->drawScene();
_scene->clearSceneQueue();
_scene->changeScene(inset, 0);
}
diff --git a/saga/scene.cpp b/saga/scene.cpp
index 2c0b0b5b0a..44021f1710 100644
--- a/saga/scene.cpp
+++ b/saga/scene.cpp
@@ -1013,6 +1013,12 @@ int Scene::endScene() {
_vm->_script->abortAllThreads();
_vm->_script->_skipSpeeches = false;
+ // Copy current screen to render buffer so inset rooms will get proper background
+ SURFACE *back_buf = _vm->_gfx->getBackBuffer();
+ BUFFER_INFO rbuf_info;
+
+ _vm->_render->getBufferInfo(&rbuf_info);
+ bufToBuffer(rbuf_info.bg_buf, rbuf_info.bg_buf_w, rbuf_info.bg_buf_h, (byte *)back_buf->pixels, back_buf->w, back_buf->h, NULL, NULL);
// Free scene background
if (_bg.loaded) {
free(_bg.buf);
diff --git a/saga/script.h b/saga/script.h
index d115116f1f..5066f2d89d 100644
--- a/saga/script.h
+++ b/saga/script.h
@@ -31,7 +31,7 @@
namespace Saga {
-#define COMMON_BUFFER_SIZE 1024
+#define COMMON_BUFFER_SIZE 1024 // Why 1024?
#define S_LUT_ENTRYLEN_ITECD 22
#define S_LUT_ENTRYLEN_ITEDISK 16