mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-26 14:27:14 +00:00
AGS: Move draw.cpp globals to Globals
This commit is contained in:
parent
b807c94441
commit
d88d97d69d
@ -90,11 +90,6 @@ extern "C" void ios_render();
|
||||
|
||||
extern int bg_just_changed;
|
||||
|
||||
color palette[256];
|
||||
|
||||
COLOR_MAP maincoltable;
|
||||
|
||||
|
||||
SpriteListEntry::SpriteListEntry()
|
||||
: bmp(nullptr)
|
||||
, pic(nullptr)
|
||||
@ -104,7 +99,7 @@ SpriteListEntry::SpriteListEntry()
|
||||
}
|
||||
|
||||
void setpal() {
|
||||
set_palette_range(palette, 0, 255, 0);
|
||||
set_palette_range(_G(palette), 0, 255, 0);
|
||||
}
|
||||
|
||||
// convert RGB to BGR for strange graphics cards
|
||||
@ -226,7 +221,7 @@ Bitmap *ReplaceBitmapWithSupportedFormat(Bitmap *bitmap) {
|
||||
Bitmap *PrepareSpriteForUse(Bitmap *bitmap, bool has_alpha) {
|
||||
bool must_switch_palette = bitmap->GetColorDepth() == 8 && _GP(game).GetColorDepth() > 8;
|
||||
if (must_switch_palette)
|
||||
select_palette(palette);
|
||||
select_palette(_G(palette));
|
||||
|
||||
Bitmap *new_bitmap = AdjustBitmapForUseWithDisplayMode(bitmap, has_alpha);
|
||||
if (new_bitmap != bitmap)
|
||||
@ -241,7 +236,7 @@ Bitmap *PrepareSpriteForUse(Bitmap *bitmap, bool has_alpha) {
|
||||
PBitmap PrepareSpriteForUse(PBitmap bitmap, bool has_alpha) {
|
||||
bool must_switch_palette = bitmap->GetColorDepth() == 8 && System_GetColorDepth() > 8;
|
||||
if (must_switch_palette)
|
||||
select_palette(palette);
|
||||
select_palette(_G(palette));
|
||||
|
||||
Bitmap *new_bitmap = AdjustBitmapForUseWithDisplayMode(bitmap.get(), has_alpha);
|
||||
new_bitmap = ReplaceBitmapWithSupportedFormat(new_bitmap);
|
||||
@ -1164,7 +1159,7 @@ int scale_and_flip_sprite(int useindx, int coldept, int zoom_level,
|
||||
// Ensure that anti-aliasing routines have a palette to
|
||||
// use for mapping while faded out
|
||||
if (_G(in_new_room))
|
||||
select_palette(palette);
|
||||
select_palette(_G(palette));
|
||||
|
||||
|
||||
if (isMirrored) {
|
||||
|
@ -49,8 +49,6 @@ namespace AGS3 {
|
||||
using namespace Shared;
|
||||
using namespace Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
// ** SCRIPT DYNAMIC SPRITE
|
||||
|
||||
void DynamicSprite_Delete(ScriptDynamicSprite *sds) {
|
||||
@ -270,7 +268,7 @@ int DynamicSprite_SaveToFile(ScriptDynamicSprite *sds, const char *namm) {
|
||||
ResolvedPath rp;
|
||||
if (!ResolveWritePathAndCreateDirs(filename, rp))
|
||||
return 0;
|
||||
return _GP(spriteset)[sds->slot]->SaveToFile(rp.FullPath, palette) ? 1 : 0;
|
||||
return _GP(spriteset)[sds->slot]->SaveToFile(rp.FullPath, _G(palette)) ? 1 : 0;
|
||||
}
|
||||
|
||||
ScriptDynamicSprite *DynamicSprite_CreateFromSaveGame(int sgslot, int width, int height) {
|
||||
|
@ -48,7 +48,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
extern color old_palette[256];
|
||||
|
||||
int run_claimable_event(const char *tsname, bool includeRoom, int numParams, const RuntimeScriptValue *params, bool *eventWasClaimed) {
|
||||
@ -221,9 +220,9 @@ void process_event(EventHappened *evp) {
|
||||
const Rect &viewport = _GP(play).GetMainViewport();
|
||||
|
||||
if ((theTransition == FADE_INSTANT) || ignore_transition)
|
||||
set_palette_range(palette, 0, 255, 0);
|
||||
set_palette_range(_G(palette), 0, 255, 0);
|
||||
else if (theTransition == FADE_NORMAL) {
|
||||
my_fade_in(palette, 5);
|
||||
my_fade_in(_G(palette), 5);
|
||||
} else if (theTransition == FADE_BOXOUT) {
|
||||
if (!_G(gfxDriver)->UsesMemoryBackBuffer()) {
|
||||
_G(gfxDriver)->BoxOutEffect(false, get_fixed_pixel_size(16), 1000 / GetGameSpeed());
|
||||
@ -231,7 +230,7 @@ void process_event(EventHappened *evp) {
|
||||
// First of all we render the game once again and save backbuffer from further editing.
|
||||
// We put temporary bitmap as a new backbuffer for the transition period, and
|
||||
// will be drawing saved image of the game over to that backbuffer, simulating "box-out".
|
||||
set_palette_range(palette, 0, 255, 0);
|
||||
set_palette_range(_G(palette), 0, 255, 0);
|
||||
construct_game_scene(true);
|
||||
construct_game_screen_overlay(false);
|
||||
_G(gfxDriver)->RenderToBackBuffer();
|
||||
@ -289,7 +288,7 @@ void process_event(EventHappened *evp) {
|
||||
|
||||
delete saved_viewport_bitmap;
|
||||
saved_viewport_bitmap = nullptr;
|
||||
set_palette_range(palette, 0, 255, 0);
|
||||
set_palette_range(_G(palette), 0, 255, 0);
|
||||
_G(gfxDriver)->DestroyDDB(ddb);
|
||||
} else if (theTransition == FADE_DISSOLVE) {
|
||||
int pattern[16] = { 0, 4, 14, 9, 5, 11, 2, 8, 10, 3, 12, 7, 15, 6, 13, 1 };
|
||||
@ -300,7 +299,7 @@ void process_event(EventHappened *evp) {
|
||||
for (aa = 0; aa < 16; aa++) {
|
||||
// merge the palette while dithering
|
||||
if (_GP(game).color_depth == 1) {
|
||||
fade_interpolate(old_palette, palette, interpal, aa * 4, 0, 255);
|
||||
fade_interpolate(old_palette, _G(palette), interpal, aa * 4, 0, 255);
|
||||
set_palette_range(interpal, 0, 255, 0);
|
||||
}
|
||||
// do the dissolving
|
||||
@ -321,7 +320,7 @@ void process_event(EventHappened *evp) {
|
||||
|
||||
delete saved_viewport_bitmap;
|
||||
saved_viewport_bitmap = nullptr;
|
||||
set_palette_range(palette, 0, 255, 0);
|
||||
set_palette_range(_G(palette), 0, 255, 0);
|
||||
_G(gfxDriver)->DestroyDDB(ddb);
|
||||
}
|
||||
|
||||
|
@ -113,8 +113,6 @@ using namespace AGS::Engine;
|
||||
extern int _G(psp_gfx_renderer);
|
||||
#endif
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
//=============================================================================
|
||||
// Audio
|
||||
//=============================================================================
|
||||
@ -881,7 +879,7 @@ void skip_serialized_bitmap(Stream *in) {
|
||||
long write_screen_shot_for_vista(Stream *out, Bitmap *screenshot) {
|
||||
// Save the screenshot to a memory stream so we can access the raw data
|
||||
Common::MemoryWriteStreamDynamic bitmap(DisposeAfterUse::YES);
|
||||
screenshot->SaveToFile(bitmap, palette);
|
||||
screenshot->SaveToFile(bitmap, _G(palette));
|
||||
|
||||
update_polled_stuff_if_runtime();
|
||||
|
||||
@ -1108,7 +1106,7 @@ void ReadCharacterExtras_Aligned(Stream *in) {
|
||||
}
|
||||
|
||||
void restore_game_palette(Stream *in) {
|
||||
in->SafeReadArray(&palette[0], PALETTE_COUNT);
|
||||
in->SafeReadArray(&_G(palette)[0], PALETTE_COUNT);
|
||||
}
|
||||
|
||||
void restore_game_dialogs(Stream *in) {
|
||||
@ -2199,7 +2197,7 @@ void RegisterStaticObjects() {
|
||||
ccAddExternalStaticObject("game", &_GP(play), &GameStaticManager);
|
||||
ccAddExternalStaticObject("gs_globals", &_GP(play).globalvars[0], &GlobalStaticManager);
|
||||
ccAddExternalStaticObject("mouse", &_GP(scmouse), &GlobalStaticManager);
|
||||
ccAddExternalStaticObject("palette", &palette[0], &GlobalStaticManager);
|
||||
ccAddExternalStaticObject("palette", &_G(palette)[0], &GlobalStaticManager);
|
||||
ccAddExternalStaticObject("system", &_GP(scsystem), &GlobalStaticManager);
|
||||
ccAddExternalStaticObject("savegameindex", &_GP(play).filenumbers[0], &GlobalStaticManager);
|
||||
}
|
||||
|
@ -76,7 +76,6 @@ using namespace AGS::Shared;
|
||||
#define ALLEGRO_KEYBOARD_HANDLER
|
||||
|
||||
extern int gui_disabled_style;
|
||||
extern color palette[256];
|
||||
|
||||
#if AGS_PLATFORM_OS_IOS || AGS_PLATFORM_OS_ANDROID
|
||||
extern int _G(psp_gfx_renderer);
|
||||
@ -835,7 +834,7 @@ int SaveScreenShot(const char *namm) {
|
||||
fileName.Format("%s%s", svg_dir.GetCStr(), namm);
|
||||
|
||||
Bitmap *buffer = CopyScreenIntoBitmap(_GP(play).GetMainViewport().GetWidth(), _GP(play).GetMainViewport().GetHeight());
|
||||
if (!buffer->SaveToFile(fileName, palette)) {
|
||||
if (!buffer->SaveToFile(fileName, _G(palette))) {
|
||||
delete buffer;
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,9 +29,6 @@
|
||||
|
||||
namespace AGS3 {
|
||||
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
void CyclePalette(int strt, int eend) {
|
||||
// hi-color game must invalidate screen since the palette changes
|
||||
// the effect of the drawing operations
|
||||
@ -43,12 +40,12 @@ void CyclePalette(int strt, int eend) {
|
||||
|
||||
if (eend > strt) {
|
||||
// forwards
|
||||
wcolrotate(strt, eend, 0, palette);
|
||||
set_palette_range(palette, strt, eend, 0);
|
||||
wcolrotate(strt, eend, 0, _G(palette));
|
||||
set_palette_range(_G(palette), strt, eend, 0);
|
||||
} else {
|
||||
// backwards
|
||||
wcolrotate(eend, strt, 1, palette);
|
||||
set_palette_range(palette, eend, strt, 0);
|
||||
wcolrotate(eend, strt, 1, _G(palette));
|
||||
set_palette_range(_G(palette), eend, strt, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@ -56,8 +53,8 @@ void SetPalRGB(int inndx, int rr, int gg, int bb) {
|
||||
if (_GP(game).color_depth > 1)
|
||||
invalidate_screen();
|
||||
|
||||
wsetrgb(inndx, rr, gg, bb, palette);
|
||||
set_palette_range(palette, inndx, inndx, 0);
|
||||
wsetrgb(inndx, rr, gg, bb, _G(palette));
|
||||
set_palette_range(_G(palette), inndx, inndx, 0);
|
||||
}
|
||||
/*void scSetPal(color*pptr) {
|
||||
wsetpalette(0,255,pptr);
|
||||
|
@ -41,8 +41,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
void FlipScreen(int amount) {
|
||||
if ((amount < 0) | (amount > 3)) quit("!FlipScreen: invalid argument (0-3)");
|
||||
_GP(play).screen_flipped = amount;
|
||||
@ -174,7 +172,7 @@ void FadeIn(int sppd) {
|
||||
if (_GP(play).fast_forward)
|
||||
return;
|
||||
|
||||
my_fade_in(palette, sppd);
|
||||
my_fade_in(_G(palette), sppd);
|
||||
}
|
||||
|
||||
} // namespace AGS3
|
||||
|
@ -40,9 +40,6 @@ namespace AGS3 {
|
||||
|
||||
using namespace AGS::Shared;
|
||||
|
||||
extern COLOR_MAP maincoltable;
|
||||
extern color palette[256];
|
||||
|
||||
ScriptRegion *GetRegionAtRoom(int xx, int yy) {
|
||||
return &_G(scrRegion)[GetRegionIDAtRoom(xx, yy)];
|
||||
}
|
||||
@ -123,8 +120,8 @@ void Region_RunInteraction(ScriptRegion *ssr, int mood) {
|
||||
|
||||
void generate_light_table() {
|
||||
if (_GP(game).color_depth == 1 && _G(color_map) == nullptr) {
|
||||
create_light_table(&maincoltable, palette, 0, 0, 0, nullptr);
|
||||
_G(color_map) = &maincoltable;
|
||||
create_light_table(&_GP(maincoltable), _G(palette), 0, 0, 0, nullptr);
|
||||
_G(color_map) = &_GP(maincoltable);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,8 +85,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
ScriptDrawingSurface *Room_GetDrawingSurfaceForBackground(int backgroundNumber) {
|
||||
if (_G(displayed_room) < 0)
|
||||
quit("!Room.GetDrawingSurfaceForBackground: no room is currently loaded");
|
||||
@ -455,11 +453,11 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
|
||||
// do the palette
|
||||
for (cc = 0; cc < 256; cc++) {
|
||||
if (_GP(game).paluses[cc] == PAL_BACKGROUND)
|
||||
palette[cc] = _GP(thisroom).Palette[cc];
|
||||
_G(palette)[cc] = _GP(thisroom).Palette[cc];
|
||||
else {
|
||||
// copy the gamewide colours into the room palette
|
||||
for (size_t i = 0; i < _GP(thisroom).BgFrameCount; ++i)
|
||||
_GP(thisroom).BgFrames[i].Palette[cc] = palette[cc];
|
||||
_GP(thisroom).BgFrames[i].Palette[cc] = _G(palette)[cc];
|
||||
}
|
||||
}
|
||||
|
||||
@ -639,14 +637,14 @@ void load_new_room(int newnum, CharacterInfo *forchar) {
|
||||
// the create_rgb_table call
|
||||
// so, fix them
|
||||
for (int ff = 0; ff < 256; ff++) {
|
||||
if (palette[ff].r > 63)
|
||||
palette[ff].r = 63;
|
||||
if (palette[ff].g > 63)
|
||||
palette[ff].g = 63;
|
||||
if (palette[ff].b > 63)
|
||||
palette[ff].b = 63;
|
||||
if (_G(palette)[ff].r > 63)
|
||||
_G(palette)[ff].r = 63;
|
||||
if (_G(palette)[ff].g > 63)
|
||||
_G(palette)[ff].g = 63;
|
||||
if (_G(palette)[ff].b > 63)
|
||||
_G(palette)[ff].b = 63;
|
||||
}
|
||||
create_rgb_table(&_GP(rgb_table), palette, nullptr);
|
||||
create_rgb_table(&_GP(rgb_table), _G(palette), nullptr);
|
||||
_G(rgb_map) = &_GP(rgb_table);
|
||||
}
|
||||
_G(our_eip) = 211;
|
||||
@ -984,7 +982,7 @@ void on_background_frame_change() {
|
||||
invalidate_cached_walkbehinds();
|
||||
|
||||
// get the new frame's palette
|
||||
memcpy(palette, _GP(thisroom).BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256);
|
||||
memcpy(_G(palette), _GP(thisroom).BgFrames[_GP(play).bg_frame].Palette, sizeof(color) * 256);
|
||||
|
||||
// hi-colour, update the palette. It won't have an immediate effect
|
||||
// but will be drawn properly when the screen fades in
|
||||
|
@ -38,8 +38,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
void get_new_size_for_sprite(int ee, int ww, int hh, int &newwid, int &newhit) {
|
||||
newwid = ww;
|
||||
newhit = hh;
|
||||
|
@ -71,7 +71,6 @@ enum {
|
||||
};
|
||||
|
||||
extern char lib_file_name[13];
|
||||
extern color palette[256];
|
||||
|
||||
static const int MB_ARRAY[3] = { 1, 2, 4 };
|
||||
|
||||
|
@ -63,8 +63,6 @@ namespace AGS3 {
|
||||
|
||||
using namespace Shared;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
namespace AGS {
|
||||
namespace Engine {
|
||||
|
||||
@ -195,7 +193,7 @@ HSaveError WriteGameState(PStream out) {
|
||||
// Game base
|
||||
_GP(game).WriteForSavegame(out);
|
||||
// Game palette
|
||||
out->SafeWriteArray(palette, PALETTE_COUNT);
|
||||
out->SafeWriteArray(_G(palette), PALETTE_COUNT);
|
||||
|
||||
if (_G(loaded_game_file_version) <= kGameVersion_272) {
|
||||
// Global variables
|
||||
@ -284,7 +282,7 @@ HSaveError ReadGameState(PStream in, int32_t cmp_ver, const PreservedParams &pp,
|
||||
// Game base
|
||||
_GP(game).ReadFromSavegame(in);
|
||||
// Game palette
|
||||
in->SafeReadArray(palette, PALETTE_COUNT);
|
||||
in->SafeReadArray(_G(palette), PALETTE_COUNT);
|
||||
|
||||
if (_G(loaded_game_file_version) <= kGameVersion_272) {
|
||||
// Legacy interaction global variables
|
||||
|
@ -83,8 +83,6 @@ namespace AGS3 {
|
||||
using namespace AGS::Shared;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
#define ALLEGRO_KEYBOARD_HANDLER
|
||||
|
||||
bool engine_init_allegro() {
|
||||
@ -615,7 +613,7 @@ void engine_init_game_settings() {
|
||||
|
||||
for (ee = 0; ee < 256; ee++) {
|
||||
if (_GP(game).paluses[ee] != PAL_BACKGROUND)
|
||||
palette[ee] = _GP(game).defpal[ee];
|
||||
_G(palette)[ee] = _GP(game).defpal[ee];
|
||||
}
|
||||
|
||||
for (ee = 0; ee < _GP(game).numcursors; ee++) {
|
||||
|
@ -150,6 +150,8 @@ Globals::Globals() {
|
||||
_dynamicallyCreatedSurfaces = new AGS::Shared::Bitmap *[MAX_DYNAMIC_SURFACES];
|
||||
Common::fill(_dynamicallyCreatedSurfaces, _dynamicallyCreatedSurfaces +
|
||||
MAX_DYNAMIC_SURFACES, (AGS::Shared::Bitmap *)nullptr);
|
||||
_palette = new color[256];
|
||||
_maincoltable = new COLOR_MAP();
|
||||
|
||||
// draw_software.cpp globals
|
||||
_BlackRects = new DirtyRects();
|
||||
@ -331,6 +333,8 @@ Globals::~Globals() {
|
||||
delete _sprlist;
|
||||
delete _thingsToDrawList;
|
||||
delete[] _dynamicallyCreatedSurfaces;
|
||||
delete[] _palette;
|
||||
delete[] _maincoltable;
|
||||
|
||||
// draw_software.cpp globals
|
||||
delete _BlackRects;
|
||||
|
@ -103,6 +103,7 @@ struct CCRegion;
|
||||
struct CharacterCache;
|
||||
struct CharacterExtras;
|
||||
struct CharacterInfo;
|
||||
struct color;
|
||||
struct COLOR_MAP;
|
||||
struct DialogTopic;
|
||||
struct DirtyRects;
|
||||
@ -480,6 +481,8 @@ public:
|
||||
AGS::Shared::Bitmap *_raw_saved_screen = nullptr;
|
||||
AGS::Shared::Bitmap **_dynamicallyCreatedSurfaces = nullptr;
|
||||
int _places_r = 3, _places_g = 2, _places_b = 3;
|
||||
color *_palette;
|
||||
COLOR_MAP *_maincoltable;
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
@ -84,8 +84,6 @@ using namespace AGS::Shared;
|
||||
using namespace AGS::Shared::Memory;
|
||||
using namespace AGS::Engine;
|
||||
|
||||
extern color palette[256];
|
||||
|
||||
void PluginSimulateMouseClick(int pluginButtonID) {
|
||||
_G(pluginSimulatedClick) = pluginButtonID - 1;
|
||||
}
|
||||
@ -417,7 +415,7 @@ AGSGameOptions *IAGSEngine::GetGameOptions() {
|
||||
return (AGSGameOptions *)&_GP(play);
|
||||
}
|
||||
AGSColor *IAGSEngine::GetPalette() {
|
||||
return (AGSColor *)&palette[0];
|
||||
return (AGSColor *)&_G(palette)[0];
|
||||
}
|
||||
void IAGSEngine::SetPalette(int32 start, int32 finish, AGSColor *cpl) {
|
||||
set_palette_range((color *)cpl, start, finish, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user