aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sword1/animation.cpp22
-rw-r--r--sword1/animation.h6
-rw-r--r--sword2/driver/animation.cpp35
-rw-r--r--sword2/driver/animation.h6
4 files changed, 29 insertions, 40 deletions
diff --git a/sword1/animation.cpp b/sword1/animation.cpp
index c289ea86a1..c6ea7bc0cb 100644
--- a/sword1/animation.cpp
+++ b/sword1/animation.cpp
@@ -103,7 +103,7 @@ bool AnimationState::init(const char *basename) {
lut2 = lookup[1];
lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2);
#else
- buildLookup2();
+ buildLookup();
overlay = (NewGuiColor*)calloc(640 * 400, sizeof(NewGuiColor));
_sys->show_overlay();
#endif
@@ -217,13 +217,13 @@ bool AnimationState::checkPaletteSwitch() {
#else
-bool AnimationState::lookupInit = false;
-NewGuiColor AnimationState::lookup2[BITDEPTH * BITDEPTH * 256];
+NewGuiColor *AnimationState::lookup = 0;
-void AnimationState::buildLookup2() {
+void AnimationState::buildLookup() {
+ if (lookup)
+ return;
- if (lookupInit) return;
- lookupInit = true;
+ lookup = (NewGuiColor *)calloc(BITDEPTH * BITDEPTH * 256, sizeof(NewGuiColor));
int y, cb, cr;
int r, g, b;
@@ -237,13 +237,13 @@ void AnimationState::buildLookup2() {
b = ((y-16) * 256 + (int) (2.018 * 256) * ((cb << SHIFT) - 128)) / 256;
if (r < 0) r = 0;
- if (r > 255) r = 255;
+ else if (r > 255) r = 255;
if (g < 0) g = 0;
- if (g > 255) g = 255;
+ else if (g > 255) g = 255;
if (b < 0) b = 0;
- if (b > 255) b = 255;
+ else if (b > 255) b = 255;
- lookup2[pos++] = _sys->RGBToColor(r, g, b);
+ lookup[pos++] = _sys->RGBToColor(r, g, b);
}
}
}
@@ -340,7 +340,7 @@ bool AnimationState::decodeFrame() {
#else
if ((bgSoundStream == NULL) || (bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < (framenum+3)){
- plotYUV(lookup2, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
+ plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
if (bgSoundStream) {
while ((bgSoundStream->getSamplesPlayed()*12/bgSoundStream->getRate()) < framenum+1)
diff --git a/sword1/animation.h b/sword1/animation.h
index 61f2b788ac..cee94f341f 100644
--- a/sword1/animation.h
+++ b/sword1/animation.h
@@ -111,10 +111,8 @@ private:
byte pal[4 * 256];
} palettes[50];
#else
- static NewGuiColor lookup2[BITDEPTH * BITDEPTH * 256];
+ static NewGuiColor *lookup;
NewGuiColor * overlay;
- static bool lookupInit;
-
#endif
public:
@@ -131,7 +129,7 @@ private:
void buildLookup(int p, int lines);
bool checkPaletteSwitch();
#else
- void buildLookup2(void);
+ void buildLookup(void);
void plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat);
#endif
};
diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp
index e7712a43f7..2f097210fe 100644
--- a/sword2/driver/animation.cpp
+++ b/sword2/driver/animation.cpp
@@ -106,7 +106,7 @@ bool AnimationState::init(const char *name) {
lut2 = lookup[1];
lutcalcnum = (BITDEPTH + palettes[palnum].end + 2) / (palettes[palnum].end + 2);
#else
- buildLookup2();
+ buildLookup();
overlay = (NewGuiColor*)calloc(640 * 400, sizeof(NewGuiColor));
_vm->_system->show_overlay();
#endif
@@ -220,14 +220,13 @@ bool AnimationState::checkPaletteSwitch() {
#else
-bool AnimationState::lookupInit = false;
-NewGuiColor AnimationState::lookup2[BITDEPTH * BITDEPTH * 256];
+NewGuiColor *AnimationState::lookup = 0;
-void AnimationState::buildLookup2() {
- if (lookupInit)
+void AnimationState::buildLookup() {
+ if (lookup)
return;
- lookupInit = true;
+ lookup = (NewGuiColor *)calloc(BITDEPTH * BITDEPTH * 256, sizeof(NewGuiColor));
int y, cb, cr;
int r, g, b;
@@ -240,20 +239,14 @@ void AnimationState::buildLookup2() {
g = ((y - 16) * 256 - (int) (0.813 * 256) * ((cr << SHIFT) - 128) - (int) (0.391 * 256) * ((cb << SHIFT) - 128)) / 256;
b = ((y - 16) * 256 + (int) (2.018 * 256) * ((cb << SHIFT) - 128)) / 256;
- if (r < 0)
- r = 0;
- if (r > 255)
- r = 255;
- if (g < 0)
- g = 0;
- if (g > 255)
- g = 255;
- if (b < 0)
- b = 0;
- if (b > 255)
- b = 255;
-
- lookup2[pos++] = _vm->_system->RGBToColor(r, g, b);
+ if (r < 0) r = 0;
+ else if (r > 255) r = 255;
+ if (g < 0) g = 0;
+ else if (g > 255) g = 255;
+ if (b < 0) b = 0;
+ else if (b > 255) b = 255;
+
+ lookup[pos++] = _vm->_system->RGBToColor(r, g, b);
}
}
}
@@ -372,7 +365,7 @@ bool AnimationState::decodeFrame() {
if ((bgSoundStream == NULL) ||
(bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < (framenum+3)){
- plotYUV(lookup2, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
+ plotYUV(lookup, sequence_i->width, sequence_i->height, info->display_fbuf->buf);
if (bgSoundStream) {
while ((bgSoundStream->getSamplesPlayed() * 12 / bgSoundStream->getRate()) < framenum + 1)
diff --git a/sword2/driver/animation.h b/sword2/driver/animation.h
index 4841a26d3f..03d4fb0283 100644
--- a/sword2/driver/animation.h
+++ b/sword2/driver/animation.h
@@ -104,10 +104,8 @@ private:
byte pal[4 * 256];
} palettes[50];
#else
- static NewGuiColor lookup2[BITDEPTH * BITDEPTH * 256];
+ static NewGuiColor *lookup;
NewGuiColor *overlay;
- static bool lookupInit;
-
#endif
public:
@@ -129,7 +127,7 @@ private:
void buildLookup(int p, int lines);
bool checkPaletteSwitch();
#else
- void buildLookup2(void);
+ void buildLookup(void);
void plotYUV(NewGuiColor *lut, int width, int height, byte *const *dat);
#endif
};