TEENAGENT: Prefer getBasePtr over direct Surface::pixels access.

This commit is contained in:
Johannes Schickel 2013-08-03 00:58:47 +02:00
parent affb7c3cb3
commit 509f96dff3
4 changed files with 8 additions and 10 deletions

View File

@ -65,7 +65,7 @@ uint Font::render(Graphics::Surface *surface, int x, int y, char c, byte color)
byte *glyph = _data + READ_LE_UINT16(_data + idx * 2);
int h = glyph[0], w = glyph[1];
if (surface == NULL || surface->pixels == NULL || y + h <= 0 || y >= kScreenHeight || x + w <= 0 || x >= kScreenWidth)
if (surface == NULL || surface->getBasePtr(0, 0) == NULL || y + h <= 0 || y >= kScreenHeight || x + w <= 0 || x >= kScreenWidth)
return w - _widthPack;
int i0 = 0, j0 = 0;

View File

@ -160,7 +160,7 @@ void Resources::loadOff(Graphics::Surface &surface, byte *palette, int id) {
off.read(id, buf, bufferSize);
byte *src = buf;
byte *dst = (byte *)surface.pixels;
byte *dst = (byte *)surface.getBasePtr(0, 0);
memcpy(dst, src, 64000);
memcpy(palette, buf + 64000, 768);

View File

@ -48,7 +48,6 @@ Scene::Scene(TeenAgentEngine *vm) : _vm(vm), intro(false), _id(0), ons(0),
onEnabled = true;
memset(palette, 0, sizeof(palette));
background.pixels = 0;
FilePack varia;
varia.open("varia.res");
@ -74,8 +73,7 @@ Scene::Scene(TeenAgentEngine *vm) : _vm(vm), intro(false), _id(0), ons(0),
}
Scene::~Scene() {
if (background.pixels)
background.free();
background.free();
delete[] ons;
ons = 0;
@ -372,7 +370,7 @@ void Scene::init(int id, const Common::Point &pos) {
for (byte i = 0; i < 4; ++i)
customAnimation[i].free();
if (background.pixels == NULL)
if (background.getBasePtr(0, 0) == NULL)
background.create(kScreenWidth, kScreenHeight, Graphics::PixelFormat::createFormatCLUT8());
warp(pos);
@ -416,7 +414,7 @@ void Scene::init(int id, const Common::Point &pos) {
if (nowPlaying != _vm->res->dseg.get_byte(dsAddr_currentMusic))
_vm->music->load(_vm->res->dseg.get_byte(dsAddr_currentMusic));
_vm->_system->copyRectToScreen(background.pixels, background.pitch, 0, 0, background.w, background.h);
_vm->_system->copyRectToScreen(background.getBasePtr(0, 0), background.pitch, 0, 0, background.w, background.h);
setPalette(0);
}
@ -642,8 +640,8 @@ bool Scene::render(bool tickGame, bool tickMark, uint32 messageDelta) {
return true;
}
if (background.pixels && debugFeatures.feature[DebugFeatures::kShowBack]) {
_vm->_system->copyRectToScreen(background.pixels, background.pitch, 0, 0, background.w, background.h);
if (background.getBasePtr(0, 0) && debugFeatures.feature[DebugFeatures::kShowBack]) {
_vm->_system->copyRectToScreen(background.getBasePtr(0, 0), background.pitch, 0, 0, background.w, background.h);
} else
_vm->_system->fillScreen(0);

View File

@ -399,7 +399,7 @@ bool TeenAgentEngine::showLogo() {
return true;
}
_system->copyRectToScreen(s.pixels, s.w, s.x, s.y, s.w, s.h);
_system->copyRectToScreen(s.getBasePtr(0, 0), s.w, s.x, s.y, s.w, s.h);
_system->updateScreen();
_system->delayMillis(100);