[Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.65,1.66 events.cpp,1.66,1.67 gfx.cpp,1.61,1.62 gfx.h,1.38,1.39 resnames.h,1.36,1.37 saga.cpp,1.136,1.137 scene.cpp,1.147,1.148
Eugene Sandulenko
sev at users.sourceforge.net
Tue Oct 4 18:33:47 CEST 2005
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga interface.cpp,1.140,1.141
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.66,1.67 events.cpp,1.67,1.68 gfx.cpp,1.62,1.63 gfx.h,1.39,1.40 scene.cpp,1.148,1.149
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24468
Modified Files:
animation.cpp events.cpp gfx.cpp gfx.h resnames.h saga.cpp
scene.cpp
Log Message:
IHNM used only 248 colors for game graphics. Top part of the palette
was read from resources. Switching to this scheme fixes magenta outlines
in subtitles.
Index: animation.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/animation.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- animation.cpp 3 Oct 2005 10:01:08 -0000 1.65
+++ animation.cpp 5 Oct 2005 01:31:46 -0000 1.66
@@ -114,7 +114,7 @@
const Rect rect(width, height);
bgSurface->blit(rect, buf);
- _vm->_gfx->setPalette(palette);
+ _vm->_gfx->setPalette(palette, 0, 248);
free(buf);
free(resourceData);
Index: events.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/events.cpp,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- events.cpp 24 Sep 2005 19:25:59 -0000 1.66
+++ events.cpp 5 Oct 2005 01:31:46 -0000 1.67
@@ -149,11 +149,17 @@
case kPalEvent:
switch (event->op) {
case kEventBlackToPal:
- _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc, 0, 248);
+ else
+ _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
break;
case kEventPalToBlack:
- _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc, 0, 248);
+ else
+ _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
break;
default:
break;
@@ -232,11 +238,17 @@
case kPalEvent:
switch (event->op) {
case kEventBlackToPal:
- _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc, 0, 248);
+ else
+ _vm->_gfx->blackToPal((PalEntry *)event->data, event_pc);
break;
case kEventPalToBlack:
- _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc, 0, 248);
+ else
+ _vm->_gfx->palToBlack((PalEntry *)event->data, event_pc);
break;
default:
break;
@@ -332,7 +344,10 @@
if (event->param == kEvPSetPalette) {
PalEntry *palPointer;
_vm->_scene->getBGPal(palPointer);
- _vm->_gfx->setPalette(palPointer);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->setPalette(palPointer, 0, 248);
+ else
+ _vm->_gfx->setPalette(palPointer);
}
}
}
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.cpp,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- gfx.cpp 4 Oct 2005 18:19:14 -0000 1.61
+++ gfx.cpp 5 Oct 2005 01:31:46 -0000 1.62
@@ -26,7 +26,10 @@
#include "saga/saga.h"
#include "saga/gfx.h"
#include "saga/interface.h"
+#include "saga/resnames.h"
+#include "saga/rscfile.h"
#include "saga/scene.h"
+#include "saga/stream.h"
#include "common/system.h"
@@ -163,14 +166,42 @@
}
}
-void Gfx::setPalette(const PalEntry *pal) {
+void Gfx::initPalette() {
+ if(_vm->getGameType() != GType_IHNM)
+ return;
+
+ ResourceContext *resourceContext = _vm->_resource->getContext(GAME_RESOURCEFILE);
+ if (resourceContext == NULL) {
+ error("Resource::loadGlobalResources() resource context not found");
+ }
+
+ byte *resourcePointer;
+ size_t resourceLength;
+
+ _vm->_resource->loadResource(resourceContext, RID_IHNM_DEFAULT_PALETTE,
+ resourcePointer, resourceLength);
+
+ MemoryReadStream metaS(resourcePointer, resourceLength);
+
+ for(int i = 0; i < 256; i++) {
+ _globalPalette[i].red = metaS.readByte();
+ _globalPalette[i].green = metaS.readByte();
+ _globalPalette[i].blue = metaS.readByte();
+ }
+
+ free(resourcePointer);
+
+ setPalette(_globalPalette, 0, 256);
+}
+
+void Gfx::setPalette(const PalEntry *pal, int from, int numcolors) {
int i;
byte *ppal;
- for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
- ppal[0] = pal[i].red;
- ppal[1] = pal[i].green;
- ppal[2] = pal[i].blue;
+ for (i = 0, ppal = &_currentPal[from * 4]; i < numcolors; i++, ppal += 4) {
+ ppal[0] = _globalPalette[i].red = pal[i].red;
+ ppal[1] = _globalPalette[i].green = pal[i].green;
+ ppal[2] = _globalPalette[i].blue = pal[i].blue;
ppal[3] = 0;
}
@@ -188,15 +219,15 @@
// updates, only update the palette if the color actually changes.
if (_currentPal[4 * n + 0] != r) {
- _currentPal[4 * n + 0] = r;
+ _currentPal[4 * n + 0] = _globalPalette[n].red = r;
update = true;
}
if (_currentPal[4 * n + 1] != g) {
- _currentPal[4 * n + 1] = g;
+ _currentPal[4 * n + 1] = _globalPalette[n].green = g;
update = true;
}
if (_currentPal[4 * n + 2] != b) {
- _currentPal[4 * n + 2] = b;
+ _currentPal[4 * n + 2] = _globalPalette[n].blue = b;
update = true;
}
if (_currentPal[4 * n + 3] != 0) {
@@ -219,11 +250,12 @@
}
}
-void Gfx::palToBlack(PalEntry *src_pal, double percent) {
+void Gfx::palToBlack(PalEntry *srcPal, double percent, int from, int numcolors) {
int i;
//int fade_max = 255;
int new_entry;
byte *ppal;
+ PalEntry *palE;
double fpercent;
@@ -238,7 +270,12 @@
// Use the correct percentage change per frame for each palette entry
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
- new_entry = (int)(src_pal[i].red * fpercent);
+ if (i < from || i >= from + numcolors)
+ palE = &_globalPalette[i];
+ else
+ palE = &srcPal[i];
+
+ new_entry = (int)(palE->red * fpercent);
if (new_entry < 0) {
ppal[0] = 0;
@@ -246,7 +283,7 @@
ppal[0] = (byte) new_entry;
}
- new_entry = (int)(src_pal[i].green * fpercent);
+ new_entry = (int)(palE->green * fpercent);
if (new_entry < 0) {
ppal[1] = 0;
@@ -254,7 +291,7 @@
ppal[1] = (byte) new_entry;
}
- new_entry = (int)(src_pal[i].blue * fpercent);
+ new_entry = (int)(palE->blue * fpercent);
if (new_entry < 0) {
ppal[2] = 0;
@@ -271,16 +308,12 @@
_system->setPalette(_currentPal, 0, PAL_ENTRIES);
}
-void Gfx::blackToPal(PalEntry *src_pal, double percent) {
+void Gfx::blackToPal(PalEntry *srcPal, double percent, int from, int numcolors) {
int new_entry;
double fpercent;
- int color_delta;
- int best_wdelta = 0;
- int best_windex = 0;
- int best_bindex = 0;
- int best_bdelta = 1000;
byte *ppal;
int i;
+ PalEntry *palE;
if (percent > 1.0) {
percent = 1.0;
@@ -293,15 +326,20 @@
// Use the correct percentage change per frame for each palette entry
for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
- new_entry = (int)(src_pal[i].red - src_pal[i].red * fpercent);
+ if (i < from || i >= from + numcolors)
+ palE = &_globalPalette[i];
+ else
+ palE = &srcPal[i];
+
+ new_entry = (int)(palE->red - palE->red * fpercent);
if (new_entry < 0) {
ppal[0] = 0;
} else {
- ppal[0] = (byte) new_entry;
+ ppal[0] = (byte)new_entry;
}
- new_entry = (int)(src_pal[i].green - src_pal[i].green * fpercent);
+ new_entry = (int)(palE->green - palE->green * fpercent);
if (new_entry < 0) {
ppal[1] = 0;
@@ -309,7 +347,7 @@
ppal[1] = (byte) new_entry;
}
- new_entry = (int)(src_pal[i].blue - src_pal[i].blue * fpercent);
+ new_entry = (int)(palE->blue - palE->blue * fpercent);
if (new_entry < 0) {
ppal[2] = 0;
@@ -319,25 +357,6 @@
ppal[3] = 0;
}
- // Find the best white and black color indices again
- if (percent >= 1.0) {
- for (i = 0, ppal = _currentPal; i < PAL_ENTRIES; i++, ppal += 4) {
- color_delta = ppal[0];
- color_delta += ppal[1];
- color_delta += ppal[2];
-
- if (color_delta < best_bdelta) {
- best_bindex = i;
- best_bdelta = color_delta;
- }
-
- if (color_delta > best_wdelta) {
- best_windex = i;
- best_wdelta = color_delta;
- }
- }
- }
-
// Make 256th color black. See bug #1256368
if (_vm->getFeatures() & GF_MAC_RESOURCES && !_vm->_scene->isInIntro())
memset(&_currentPal[255 * 4], 0, 4);
Index: gfx.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/gfx.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- gfx.h 4 Oct 2005 17:44:41 -0000 1.38
+++ gfx.h 5 Oct 2005 01:31:46 -0000 1.39
@@ -134,11 +134,12 @@
return &_backBuffer;
}
- void setPalette(const PalEntry *pal);
+ void initPalette();
+ void setPalette(const PalEntry *pal, int from = 0, int numcolors = PAL_ENTRIES);
void setPaletteColor(int n, int r, int g, int b);
void getCurrentPal(PalEntry *src_pal);
- void palToBlack(PalEntry *src_pal, double percent);
- void blackToPal(PalEntry *src_pal, double percent);
+ void palToBlack(PalEntry *src_pal, double percent, int from = 0, int numcolors = PAL_ENTRIES);
+ void blackToPal(PalEntry *src_pal, double percent, int from = 0, int numcolors = PAL_ENTRIES);
void updateCursor() { setCursor(); }
void showCursor(bool state);
@@ -149,6 +150,8 @@
byte _currentPal[PAL_ENTRIES * 4];
OSystem *_system;
SagaEngine *_vm;
+
+ PalEntry _globalPalette[PAL_ENTRIES];
};
} // End of namespace Saga
Index: resnames.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/resnames.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- resnames.h 7 Aug 2005 00:00:41 -0000 1.36
+++ resnames.h 5 Oct 2005 01:31:46 -0000 1.37
@@ -47,6 +47,8 @@
#define IHNM_OBJ_PROFILE 0x4000
+#define RID_IHNM_DEFAULT_PALETTE 1
+
//actor names
#define ITE_ACTOR_PUZZLE 176
Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.136
retrieving revision 1.137
diff -u -d -r1.136 -r1.137
--- saga.cpp 28 Sep 2005 15:49:20 -0000 1.136
+++ saga.cpp 5 Oct 2005 01:31:46 -0000 1.137
@@ -253,7 +253,6 @@
debug(1, "Music disabled.");
}
-
_render = new Render(this, _system);
if (!_render->initialized()) {
return FAILURE;
@@ -270,6 +269,8 @@
_music->setVolume(-1, 1);
+ _gfx->initPalette();
+
return SUCCESS;
}
Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- scene.cpp 23 Sep 2005 14:29:26 -0000 1.147
+++ scene.cpp 5 Oct 2005 01:31:46 -0000 1.148
@@ -447,7 +447,10 @@
cPal[j].blue = *pal++;
}
free(colors);
- _vm->_gfx->setPalette(cPal);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->setPalette(cPal, 0, 248);
+ else
+ _vm->_gfx->setPalette(cPal);
}
@@ -1132,7 +1135,10 @@
pal[c].green = *palPtr++;
pal[c].blue = *palPtr++;
}
- _vm->_gfx->setPalette(pal);
+ if (_vm->getGameType() == GType_IHNM)
+ _vm->_gfx->setPalette(pal, 0, 248);
+ else
+ _vm->_gfx->setPalette(pal);
}
break;
default:
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/saga interface.cpp,1.140,1.141
- Next message: [Scummvm-cvs-logs] CVS: scummvm/saga animation.cpp,1.66,1.67 events.cpp,1.67,1.68 gfx.cpp,1.62,1.63 gfx.h,1.39,1.40 scene.cpp,1.148,1.149
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list