[Scummvm-git-logs] scummvm master -> f060408108578402206d605e3003c9d170468e9d

dreammaster dreammaster at scummvm.org
Sun Mar 7 22:33:09 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f060408108 AGS: Move palettes into Globals


Commit: f060408108578402206d605e3003c9d170468e9d
    https://github.com/scummvm/scummvm/commit/f060408108578402206d605e3003c9d170468e9d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2021-03-07T14:27:20-08:00

Commit Message:
AGS: Move palettes into Globals

Changed paths:
    engines/ags/engine/ac/screen.cpp
    engines/ags/globals.h
    engines/ags/lib/allegro.cpp
    engines/ags/lib/allegro/color.cpp
    engines/ags/lib/allegro/color.h
    engines/ags/lib/allegro/surface.cpp


diff --git a/engines/ags/engine/ac/screen.cpp b/engines/ags/engine/ac/screen.cpp
index 63d4c18b37..bdbc4788fb 100644
--- a/engines/ags/engine/ac/screen.cpp
+++ b/engines/ags/engine/ac/screen.cpp
@@ -75,7 +75,7 @@ void current_fade_out_effect() {
 
 	if ((theTransition == FADE_INSTANT) || ignore_transition) {
 		if (!_GP(play).keep_screen_during_instant_transition)
-			set_palette_range(black_palette, 0, 255, 0);
+			set_palette_range(_G(black_palette), 0, 255, 0);
 	} else if (theTransition == FADE_NORMAL) {
 		my_fade_out(5);
 	} else if (theTransition == FADE_BOXOUT) {
diff --git a/engines/ags/globals.h b/engines/ags/globals.h
index 96c430f48f..a70011ffc2 100644
--- a/engines/ags/globals.h
+++ b/engines/ags/globals.h
@@ -30,6 +30,7 @@
 #include "ags/engine/main/engine.h"
 #include "ags/lib/std/array.h"
 #include "ags/lib/std/set.h"
+#include "ags/lib/allegro/color.h"
 #include "ags/lib/allegro/fixed.h"
 #include "ags/lib/allegro/aintern.h"
 #include "common/events.h"
@@ -152,6 +153,11 @@ public:
 	int _trans_blend_blue = 0;
 	BlenderMode __blender_mode = kRgbToRgbBlender;
 
+	/* default palette structures */
+	PALETTE _black_palette;
+	PALETTE _current_palette;
+	PALETTE _prev_current_palette;
+
 	volatile int _mouse_x = 0;	// X position
 	volatile int _mouse_y = 0;	// Y position
 	volatile int _mouse_z = 0;	// Mouse wheel vertical
diff --git a/engines/ags/lib/allegro.cpp b/engines/ags/lib/allegro.cpp
index f2ee08555e..bf6962c217 100644
--- a/engines/ags/lib/allegro.cpp
+++ b/engines/ags/lib/allegro.cpp
@@ -24,90 +24,6 @@
 
 namespace AGS3 {
 
-/* default palette structures */
-PALETTE black_palette;
-PALETTE _current_palette;
-PALETTE _prev_current_palette;
-
-int _current_palette_changed = 0xFFFFFFFF;
-
-
-PALETTE desktop_palette = {
-   { 63, 63, 63, 0 },   { 63, 0,  0,  0 },   { 0,  63, 0,  0 },   { 63, 63, 0,  0 },
-   { 0,  0,  63, 0 },   { 63, 0,  63, 0 },   { 0,  63, 63, 0 },   { 16, 16, 16, 0 },
-   { 31, 31, 31, 0 },   { 63, 31, 31, 0 },   { 31, 63, 31, 0 },   { 63, 63, 31, 0 },
-   { 31, 31, 63, 0 },   { 63, 31, 63, 0 },   { 31, 63, 63, 0 },   { 0,  0,  0,  0 }
-};
-
-
-PALETTE default_palette = {
-   { 0,  0,  0,  0 },   { 0,  0,  42, 0 },   { 0,  42, 0,  0 },   { 0,  42, 42, 0 },
-   { 42, 0,  0,  0 },   { 42, 0,  42, 0 },   { 42, 21, 0,  0 },   { 42, 42, 42, 0 },
-   { 21, 21, 21, 0 },   { 21, 21, 63, 0 },   { 21, 63, 21, 0 },   { 21, 63, 63, 0 },
-   { 63, 21, 21, 0 },   { 63, 21, 63, 0 },   { 63, 63, 21, 0 },   { 63, 63, 63, 0 },
-   { 0,  0,  0,  0 },   { 5,  5,  5,  0 },   { 8,  8,  8,  0 },   { 11, 11, 11, 0 },
-   { 14, 14, 14, 0 },   { 17, 17, 17, 0 },   { 20, 20, 20, 0 },   { 24, 24, 24, 0 },
-   { 28, 28, 28, 0 },   { 32, 32, 32, 0 },   { 36, 36, 36, 0 },   { 40, 40, 40, 0 },
-   { 45, 45, 45, 0 },   { 50, 50, 50, 0 },   { 56, 56, 56, 0 },   { 63, 63, 63, 0 },
-   { 0,  0,  63, 0 },   { 16, 0,  63, 0 },   { 31, 0,  63, 0 },   { 47, 0,  63, 0 },
-   { 63, 0,  63, 0 },   { 63, 0,  47, 0 },   { 63, 0,  31, 0 },   { 63, 0,  16, 0 },
-   { 63, 0,  0,  0 },   { 63, 16, 0,  0 },   { 63, 31, 0,  0 },   { 63, 47, 0,  0 },
-   { 63, 63, 0,  0 },   { 47, 63, 0,  0 },   { 31, 63, 0,  0 },   { 16, 63, 0,  0 },
-   { 0,  63, 0,  0 },   { 0,  63, 16, 0 },   { 0,  63, 31, 0 },   { 0,  63, 47, 0 },
-   { 0,  63, 63, 0 },   { 0,  47, 63, 0 },   { 0,  31, 63, 0 },   { 0,  16, 63, 0 },
-   { 31, 31, 63, 0 },   { 39, 31, 63, 0 },   { 47, 31, 63, 0 },   { 55, 31, 63, 0 },
-   { 63, 31, 63, 0 },   { 63, 31, 55, 0 },   { 63, 31, 47, 0 },   { 63, 31, 39, 0 },
-   { 63, 31, 31, 0 },   { 63, 39, 31, 0 },   { 63, 47, 31, 0 },   { 63, 55, 31, 0 },
-   { 63, 63, 31, 0 },   { 55, 63, 31, 0 },   { 47, 63, 31, 0 },   { 39, 63, 31, 0 },
-   { 31, 63, 31, 0 },   { 31, 63, 39, 0 },   { 31, 63, 47, 0 },   { 31, 63, 55, 0 },
-   { 31, 63, 63, 0 },   { 31, 55, 63, 0 },   { 31, 47, 63, 0 },   { 31, 39, 63, 0 },
-   { 45, 45, 63, 0 },   { 49, 45, 63, 0 },   { 54, 45, 63, 0 },   { 58, 45, 63, 0 },
-   { 63, 45, 63, 0 },   { 63, 45, 58, 0 },   { 63, 45, 54, 0 },   { 63, 45, 49, 0 },
-   { 63, 45, 45, 0 },   { 63, 49, 45, 0 },   { 63, 54, 45, 0 },   { 63, 58, 45, 0 },
-   { 63, 63, 45, 0 },   { 58, 63, 45, 0 },   { 54, 63, 45, 0 },   { 49, 63, 45, 0 },
-   { 45, 63, 45, 0 },   { 45, 63, 49, 0 },   { 45, 63, 54, 0 },   { 45, 63, 58, 0 },
-   { 45, 63, 63, 0 },   { 45, 58, 63, 0 },   { 45, 54, 63, 0 },   { 45, 49, 63, 0 },
-   { 0,  0,  28, 0 },   { 7,  0,  28, 0 },   { 14, 0,  28, 0 },   { 21, 0,  28, 0 },
-   { 28, 0,  28, 0 },   { 28, 0,  21, 0 },   { 28, 0,  14, 0 },   { 28, 0,  7,  0 },
-   { 28, 0,  0,  0 },   { 28, 7,  0,  0 },   { 28, 14, 0,  0 },   { 28, 21, 0,  0 },
-   { 28, 28, 0,  0 },   { 21, 28, 0,  0 },   { 14, 28, 0,  0 },   { 7,  28, 0,  0 },
-   { 0,  28, 0,  0 },   { 0,  28, 7,  0 },   { 0,  28, 14, 0 },   { 0,  28, 21, 0 },
-   { 0,  28, 28, 0 },   { 0,  21, 28, 0 },   { 0,  14, 28, 0 },   { 0,  7,  28, 0 },
-   { 14, 14, 28, 0 },   { 17, 14, 28, 0 },   { 21, 14, 28, 0 },   { 24, 14, 28, 0 },
-   { 28, 14, 28, 0 },   { 28, 14, 24, 0 },   { 28, 14, 21, 0 },   { 28, 14, 17, 0 },
-   { 28, 14, 14, 0 },   { 28, 17, 14, 0 },   { 28, 21, 14, 0 },   { 28, 24, 14, 0 },
-   { 28, 28, 14, 0 },   { 24, 28, 14, 0 },   { 21, 28, 14, 0 },   { 17, 28, 14, 0 },
-   { 14, 28, 14, 0 },   { 14, 28, 17, 0 },   { 14, 28, 21, 0 },   { 14, 28, 24, 0 },
-   { 14, 28, 28, 0 },   { 14, 24, 28, 0 },   { 14, 21, 28, 0 },   { 14, 17, 28, 0 },
-   { 20, 20, 28, 0 },   { 22, 20, 28, 0 },   { 24, 20, 28, 0 },   { 26, 20, 28, 0 },
-   { 28, 20, 28, 0 },   { 28, 20, 26, 0 },   { 28, 20, 24, 0 },   { 28, 20, 22, 0 },
-   { 28, 20, 20, 0 },   { 28, 22, 20, 0 },   { 28, 24, 20, 0 },   { 28, 26, 20, 0 },
-   { 28, 28, 20, 0 },   { 26, 28, 20, 0 },   { 24, 28, 20, 0 },   { 22, 28, 20, 0 },
-   { 20, 28, 20, 0 },   { 20, 28, 22, 0 },   { 20, 28, 24, 0 },   { 20, 28, 26, 0 },
-   { 20, 28, 28, 0 },   { 20, 26, 28, 0 },   { 20, 24, 28, 0 },   { 20, 22, 28, 0 },
-   { 0,  0,  16, 0 },   { 4,  0,  16, 0 },   { 8,  0,  16, 0 },   { 12, 0,  16, 0 },
-   { 16, 0,  16, 0 },   { 16, 0,  12, 0 },   { 16, 0,  8,  0 },   { 16, 0,  4,  0 },
-   { 16, 0,  0,  0 },   { 16, 4,  0,  0 },   { 16, 8,  0,  0 },   { 16, 12, 0,  0 },
-   { 16, 16, 0,  0 },   { 12, 16, 0,  0 },   { 8,  16, 0,  0 },   { 4,  16, 0,  0 },
-   { 0,  16, 0,  0 },   { 0,  16, 4,  0 },   { 0,  16, 8,  0 },   { 0,  16, 12, 0 },
-   { 0,  16, 16, 0 },   { 0,  12, 16, 0 },   { 0,  8,  16, 0 },   { 0,  4,  16, 0 },
-   { 8,  8,  16, 0 },   { 10, 8,  16, 0 },   { 12, 8,  16, 0 },   { 14, 8,  16, 0 },
-   { 16, 8,  16, 0 },   { 16, 8,  14, 0 },   { 16, 8,  12, 0 },   { 16, 8,  10, 0 },
-   { 16, 8,  8,  0 },   { 16, 10, 8,  0 },   { 16, 12, 8,  0 },   { 16, 14, 8,  0 },
-   { 16, 16, 8,  0 },   { 14, 16, 8,  0 },   { 12, 16, 8,  0 },   { 10, 16, 8,  0 },
-   { 8,  16, 8,  0 },   { 8,  16, 10, 0 },   { 8,  16, 12, 0 },   { 8,  16, 14, 0 },
-   { 8,  16, 16, 0 },   { 8,  14, 16, 0 },   { 8,  12, 16, 0 },   { 8,  10, 16, 0 },
-   { 11, 11, 16, 0 },   { 12, 11, 16, 0 },   { 13, 11, 16, 0 },   { 15, 11, 16, 0 },
-   { 16, 11, 16, 0 },   { 16, 11, 15, 0 },   { 16, 11, 13, 0 },   { 16, 11, 12, 0 },
-   { 16, 11, 11, 0 },   { 16, 12, 11, 0 },   { 16, 13, 11, 0 },   { 16, 15, 11, 0 },
-   { 16, 16, 11, 0 },   { 15, 16, 11, 0 },   { 13, 16, 11, 0 },   { 12, 16, 11, 0 },
-   { 11, 16, 11, 0 },   { 11, 16, 12, 0 },   { 11, 16, 13, 0 },   { 11, 16, 15, 0 },
-   { 11, 16, 16, 0 },   { 11, 15, 16, 0 },   { 11, 13, 16, 0 },   { 11, 12, 16, 0 },
-   { 0,  0,  0,  0 },   { 0,  0,  0,  0 },   { 0,  0,  0,  0 },   { 0,  0,  0,  0 },
-   { 0,  0,  0,  0 },   { 0,  0,  0,  0 },   { 0,  0,  0,  0 },   { 63, 63, 63, 0 }
-};
-
-
 int install_allegro() {
 	errnum = AL_NOERROR;
 	return 0;
diff --git a/engines/ags/lib/allegro/color.cpp b/engines/ags/lib/allegro/color.cpp
index 0dc2c0a013..9763bddcda 100644
--- a/engines/ags/lib/allegro/color.cpp
+++ b/engines/ags/lib/allegro/color.cpp
@@ -50,17 +50,17 @@ void color::writeToFile(AGS::Shared::Stream *file) const {
 
 
 void set_color(int idx, const RGB *p) {
-	_current_palette[idx] = *p;
+	_G(current_palette)[idx] = *p;
 }
 
 void set_palette(const PALETTE p) {
 	for (int idx = 0; idx < PAL_SIZE; ++idx)
-		_current_palette[idx] = p[idx];
+		_G(current_palette)[idx] = p[idx];
 }
 
 void set_palette_range(const PALETTE p, int from, int to, int retracesync) {
 	for (int i = from; i < to; ++i) {
-		_current_palette[i] = p[i];
+		_G(current_palette)[i] = p[i];
 	}
 }
 
@@ -96,15 +96,15 @@ int makeacol32(int r, int g, int b, int a) {
 }
 
 int getr8(int c) {
-	return (int)_current_palette[c].r;
+	return (int)_G(current_palette)[c].r;
 }
 
 int getg8(int c) {
-	return (int)_current_palette[c].g;
+	return (int)_G(current_palette)[c].g;
 }
 
 int getb8(int c) {
-	return (int)_current_palette[c].b;
+	return (int)_G(current_palette)[c].b;
 }
 
 int getr15(int c) {
@@ -187,8 +187,8 @@ void select_palette(AL_CONST PALETTE p) {
 	int c;
 
 	for (c = 0; c < PAL_SIZE; c++) {
-		_prev_current_palette[c] = _current_palette[c];
-		_current_palette[c] = p[c];
+		_G(prev_current_palette)[c] = _G(current_palette)[c];
+		_G(current_palette)[c] = p[c];
 	}
 
 	// TODO: See if the remainder of Allegro's select_palette method is needed for AGS
@@ -198,7 +198,7 @@ void unselect_palette(void) {
 	int c;
 
 	for (c = 0; c < PAL_SIZE; c++)
-		_current_palette[c] = _prev_current_palette[c];
+		_G(current_palette)[c] = _G(prev_current_palette)[c];
 }
 
 void set_blender_mode(BlenderMode m, int r, int g, int b, int a) {
@@ -484,7 +484,7 @@ int makecol8(int r, int g, int b) {
 	if (_G(rgb_map))
 		return _G(rgb_map)->data[r >> 3][g >> 3][b >> 3];
 	else
-		return bestfit_color(_current_palette, r >> 2, g >> 2, b >> 2);
+		return bestfit_color(_G(current_palette), r >> 2, g >> 2, b >> 2);
 }
 
 
diff --git a/engines/ags/lib/allegro/color.h b/engines/ags/lib/allegro/color.h
index 70e3be95d6..8c3c74f924 100644
--- a/engines/ags/lib/allegro/color.h
+++ b/engines/ags/lib/allegro/color.h
@@ -58,9 +58,6 @@ struct color {
 typedef color RGB;
 typedef RGB PALETTE[PAL_SIZE];
 
-AL_VAR(PALETTE, _current_palette);
-AL_VAR(PALETTE, _prev_current_palette);
-
 #include "common/pack-end.h"    // END STRUCT PACKING
 
 struct RGB_MAP {
@@ -71,10 +68,6 @@ struct COLOR_MAP {
 	byte data[PAL_SIZE][PAL_SIZE];
 };
 
-AL_VAR(PALETTE, black_palette);
-AL_VAR(PALETTE, desktop_palette);
-AL_VAR(PALETTE, default_palette);
-
 enum BlenderMode {
 	kSourceAlphaBlender,
 	kArgbToArgbBlender,
diff --git a/engines/ags/lib/allegro/surface.cpp b/engines/ags/lib/allegro/surface.cpp
index 86388ba08a..fc5cc14ebf 100644
--- a/engines/ags/lib/allegro/surface.cpp
+++ b/engines/ags/lib/allegro/surface.cpp
@@ -134,9 +134,9 @@ void BITMAP::draw(const BITMAP *srcBitmap, const Common::Rect &srcRect,
 	if (srcFormat.bytesPerPixel == 1) {
 		for (int i = 0; i < PALETTE_COUNT; ++i)
 			pal[i] = format.RGBToColor(
-				VGA_COLOR_TRANS(_current_palette[i].r),
-				VGA_COLOR_TRANS(_current_palette[i].g),
-				VGA_COLOR_TRANS(_current_palette[i].b));
+				VGA_COLOR_TRANS(_G(current_palette)[i].r),
+				VGA_COLOR_TRANS(_G(current_palette)[i].g),
+				VGA_COLOR_TRANS(_G(current_palette)[i].b));
 		srcFormat = format;
 		// If we are skipping transparency, color 0 is skipped.
 		// Set it to transparent color to simplify the check below.




More information about the Scummvm-git-logs mailing list