scummvm/engines/saga2/vbacksav.cpp

118 lines
2.9 KiB
C++
Raw Permalink Normal View History

2021-05-17 20:47:39 +02:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2021-05-17 20:47:39 +02:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* aint32 with this program; if not, write to the Free Software
*
*
* Based on the original sources
* Faery Tale II -- The Halls of the Dead
* (c) 1993-1996 The Wyrmkeep Entertainment Co.
*/
2021-06-23 14:41:01 +02:00
#include "saga2/saga2.h"
2021-05-17 20:47:39 +02:00
#include "saga2/vbacksav.h"
namespace Saga2 {
gBackSave::gBackSave(const Rect16 &extent) {
2021-06-30 01:21:14 +02:00
Rect16 displayRect(0, 0, 640, 480);
2021-05-17 20:47:39 +02:00
// initialize the rectangle
savedRegion = intersect(extent, displayRect); // intersect with display size
// Set up the image structure for the video page
savedPixels.size.x = savedRegion.width;
savedPixels.size.y = savedRegion.height;
// savedPixels.data = (uint8 *)malloc( savedPixels.bytes() );
2021-06-02 00:57:39 +02:00
savedPixels.data = (uint8 *)malloc(savedPixels.bytes());
2021-05-17 20:47:39 +02:00
// Initialize the graphics port
setMap(&savedPixels);
setMode(drawModeReplace);
2021-06-13 16:56:52 +02:00
saved = false;
2021-05-17 20:47:39 +02:00
}
/********* vbacksav.cpp/gBackSave::~gBackSave ************************
*
* NAME gBackSave::~gBackSave
*
* SYNOPSIS
*
* FUNCTION
*
* INPUTS
*
* RESULT
*
**********************************************************************
*/
gBackSave::~gBackSave() {
free(savedPixels.data);
}
/********* vbacksav.cpp/gBackSave::save ******************************
*
* NAME gBackSave::save
*
* SYNOPSIS
*
* FUNCTION
*
* INPUTS
*
* RESULT
*
**********************************************************************
*/
void gBackSave::save(gDisplayPort &port) {
if (!saved && savedPixels.data) {
port.protoPage.readPixels(savedRegion,
2021-05-17 20:47:39 +02:00
savedPixels.data,
savedPixels.size.x);
2021-06-13 16:56:52 +02:00
saved = true;
2021-05-17 20:47:39 +02:00
}
}
/********* vbacksav.cpp/gBackSave::restore ***************************
*
* NAME gBackSave::restore
*
* SYNOPSIS
*
* FUNCTION
*
* INPUTS
*
* RESULT
*
**********************************************************************
*/
void gBackSave::restore(gDisplayPort &port) {
if (saved && savedPixels.data) {
port.protoPage.writePixels(savedRegion,
2021-05-17 20:47:39 +02:00
savedPixels.data,
savedPixels.size.x);
2021-06-13 16:56:52 +02:00
saved = false;
2021-05-17 20:47:39 +02:00
}
}
} // end of namespace Saga2