mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 20:21:06 +00:00
TITANIC: Adding screen initialization code
This commit is contained in:
parent
43d3b138ca
commit
c9c85ee622
@ -20,26 +20,79 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/debug.h"
|
||||
#include "engines/util.h"
|
||||
#include "titanic/titanic.h"
|
||||
#include "titanic/direct_draw.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
DirectDraw::DirectDraw(TitanicEngine *vm) : Manager(vm) {
|
||||
DirectDraw::DirectDraw(TitanicEngine *vm) : _vm(vm) {
|
||||
_field8 = 0;
|
||||
_fieldC = 0;
|
||||
_width = 0;
|
||||
_height = 0;
|
||||
_bpp = 0;
|
||||
_field1C = 0;
|
||||
_numBackSurfaces = 0;
|
||||
_field24 = 0;
|
||||
}
|
||||
|
||||
void DirectDraw::setDisplayMode(int width, int height, int bpp, int refreshRate) {
|
||||
debugC(ERROR_BASIC, kDebugGraphics, "DirectDraw::SetDisplayMode (%d x %d), %d bpp",
|
||||
width, height, bpp);
|
||||
assert(bpp == 8);
|
||||
initGraphics(width, height, true);
|
||||
}
|
||||
|
||||
void DirectDraw::diagnostics() {
|
||||
debugC(ERROR_BASIC, kDebugGraphics, "Running DirectDraw Diagnostic...");
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
DirectDrawManager::DirectDrawManager(TitanicEngine *vm) :
|
||||
Manager(vm), _directDraw(vm) {
|
||||
DirectDrawManager::DirectDrawManager(TitanicEngine *vm, int v) : _directDraw(vm) {
|
||||
_mainSurface = nullptr;
|
||||
_backSurfaces[0] = _backSurfaces[1] = nullptr;
|
||||
_directDraw._field8 = v;
|
||||
}
|
||||
|
||||
void DirectDrawManager::initVideo(int width, int height, int bpp, int numBackSurfaces) {
|
||||
debugC(ERROR_BASIC, kDebugGraphics, "Initialising video surfaces");
|
||||
_directDraw._width = width;
|
||||
_directDraw._numBackSurfaces = numBackSurfaces;
|
||||
_directDraw._height = height;
|
||||
_directDraw._bpp = bpp;
|
||||
|
||||
if (numBackSurfaces) {
|
||||
setResolution();
|
||||
} else {
|
||||
initSurface();
|
||||
}
|
||||
}
|
||||
|
||||
void DirectDrawManager::setResolution() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void DirectDrawManager::proc2() {
|
||||
|
||||
}
|
||||
|
||||
void DirectDrawManager::proc3() {
|
||||
|
||||
}
|
||||
|
||||
void DirectDrawManager::initSurface() {
|
||||
debugC(ERROR_BASIC, kDebugGraphics, "Creating surfaces");
|
||||
_directDraw.setDisplayMode(_directDraw._width, _directDraw._height,
|
||||
_directDraw._bpp, 0);
|
||||
|
||||
_mainSurface = new Graphics::Surface();
|
||||
_mainSurface->create(_directDraw._width, _directDraw._height,
|
||||
Graphics::PixelFormat::createFormatCLUT8());
|
||||
_backSurfaces[0] = new Graphics::Surface();
|
||||
_backSurfaces[0]->create(_directDraw._width, _directDraw._height,
|
||||
Graphics::PixelFormat::createFormatCLUT8());
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -25,30 +25,64 @@
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/array.h"
|
||||
#include "titanic/titanic.h"
|
||||
#include "graphics/surface.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class DirectDraw: public Manager {
|
||||
class TitanicEngine;
|
||||
|
||||
class DirectDraw {
|
||||
private:
|
||||
TitanicEngine *_vm;
|
||||
public:
|
||||
int _field8;
|
||||
int _fieldC;
|
||||
int _width;
|
||||
int _height;
|
||||
int _bpp;
|
||||
int _field1C;
|
||||
int _numBackSurfaces;
|
||||
int _field24;
|
||||
public:
|
||||
DirectDraw(TitanicEngine *vm);
|
||||
|
||||
/**
|
||||
* Sets a new display mode
|
||||
*/
|
||||
void setDisplayMode(int width, int height, int bpp, int refreshRate);
|
||||
|
||||
/**
|
||||
* Logs diagnostic information
|
||||
*/
|
||||
void diagnostics();
|
||||
};
|
||||
|
||||
class DirectDrawManager: public Manager {
|
||||
class DirectDrawManager {
|
||||
public:
|
||||
DirectDraw _directDraw;
|
||||
void *_mainSurface;
|
||||
void *_backSurfaces[2];
|
||||
Graphics::Surface *_mainSurface;
|
||||
Graphics::Surface *_backSurfaces[2];
|
||||
public:
|
||||
DirectDrawManager(TitanicEngine *vm);
|
||||
DirectDrawManager(TitanicEngine *vm, int v);
|
||||
|
||||
/**
|
||||
* Initializes video surfaces
|
||||
* @param width Screen width
|
||||
* @param height Screen height
|
||||
* @param bpp Bits per pixel
|
||||
* @param numBackSurfaces Number of back surfaces
|
||||
*/
|
||||
void initVideo(int width, int height, int bpp, int numBackSurfaces);
|
||||
|
||||
void setResolution();
|
||||
|
||||
void proc2();
|
||||
|
||||
void proc3();
|
||||
|
||||
/**
|
||||
* Initializes the surface for the screen
|
||||
*/
|
||||
void initSurface();
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -27,4 +27,8 @@ namespace Titanic {
|
||||
STFont::STFont() {
|
||||
}
|
||||
|
||||
void STFont::load(int fontNumber) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -31,6 +31,8 @@ class STFont {
|
||||
public:
|
||||
public:
|
||||
STFont();
|
||||
|
||||
void load(int fontNumber);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "titanic/screen_manager.h"
|
||||
#include "titanic/video_surface.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
@ -33,11 +34,10 @@ CScreenManagerRec::CScreenManagerRec() {
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
CScreenManager::CScreenManager() {
|
||||
CScreenManager::CScreenManager(TitanicEngine *vm): _vm(vm) {
|
||||
_screenManagerPtr = nullptr;
|
||||
|
||||
_field4 = 0;
|
||||
_fontRenderSurface = nullptr;
|
||||
_frontRenderSurface = nullptr;
|
||||
_mouseCursor = nullptr;
|
||||
_textCursor = nullptr;
|
||||
_fontNumber = 0;
|
||||
@ -47,31 +47,51 @@ CScreenManager::~CScreenManager() {
|
||||
_screenManagerPtr = nullptr;
|
||||
}
|
||||
|
||||
void CScreenManager::proc2(int v) {
|
||||
if (v)
|
||||
_field4 = v;
|
||||
void CScreenManager::setWindowHandle(int v) {
|
||||
// Not needed
|
||||
}
|
||||
|
||||
bool CScreenManager::proc3(int v) {
|
||||
if (!v || _field4)
|
||||
return false;
|
||||
|
||||
_field4 = 0;
|
||||
bool CScreenManager::resetWindowHandle(int v) {
|
||||
proc27();
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
OSScreenManager::OSScreenManager(): CScreenManager() {
|
||||
OSScreenManager::OSScreenManager(TitanicEngine *vm): CScreenManager(vm),
|
||||
_directDrawManager(vm, 0) {
|
||||
_field48 = 0;
|
||||
_field4C = 0;
|
||||
_field50 = 0;
|
||||
_field54 = 0;
|
||||
_directDrawManager = nullptr;
|
||||
}
|
||||
|
||||
void OSScreenManager::setMode() {}
|
||||
OSScreenManager::~OSScreenManager() {
|
||||
destroyFrontAndBackBuffers();
|
||||
}
|
||||
|
||||
void OSScreenManager::setMode(int width, int height, int bpp, int numBackSurfaces, bool flag2) {
|
||||
destroyFrontAndBackBuffers();
|
||||
_directDrawManager.initVideo(width, height, bpp, numBackSurfaces);
|
||||
|
||||
_frontRenderSurface = new OSVideoSurface(this, nullptr);
|
||||
_frontRenderSurface->setSurface(this, _directDrawManager._mainSurface);
|
||||
|
||||
for (uint idx = 0; idx < numBackSurfaces; ++idx) {
|
||||
OSVideoSurface videoSurface(this, nullptr);
|
||||
videoSurface.setSurface(this, _directDrawManager._backSurfaces[idx]);
|
||||
}
|
||||
|
||||
// Load fonts
|
||||
_fonts[0].load(149);
|
||||
_fonts[1].load(151);
|
||||
_fonts[2].load(152);
|
||||
_fonts[3].load(153);
|
||||
|
||||
// Load the cursors
|
||||
loadCursors();
|
||||
}
|
||||
|
||||
void OSScreenManager::proc5() {}
|
||||
void OSScreenManager::proc6() {}
|
||||
void OSScreenManager::proc7() {}
|
||||
@ -96,4 +116,17 @@ void OSScreenManager::proc25() {}
|
||||
void OSScreenManager::showCursor() {}
|
||||
void OSScreenManager::proc27() {}
|
||||
|
||||
void OSScreenManager::destroyFrontAndBackBuffers() {
|
||||
delete _frontRenderSurface;
|
||||
_frontRenderSurface = nullptr;
|
||||
|
||||
for (uint idx = 0; idx < _backSurfaces.size(); ++idx)
|
||||
delete _backSurfaces[idx];
|
||||
_backSurfaces.clear();
|
||||
}
|
||||
|
||||
void OSScreenManager::loadCursors() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -25,10 +25,14 @@
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/array.h"
|
||||
#include "titanic/direct_draw.h"
|
||||
#include "titanic/font.h"
|
||||
#include "titanic/video_surface.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class TitanicEngine;
|
||||
|
||||
class CSurface {
|
||||
};
|
||||
|
||||
@ -43,26 +47,27 @@ public:
|
||||
};
|
||||
|
||||
class CScreenManager {
|
||||
protected:
|
||||
TitanicEngine *_vm;
|
||||
public:
|
||||
void *_screenManagerPtr;
|
||||
public:
|
||||
int _field4;
|
||||
Common::Array<CSurface> _backSurfaces;
|
||||
CSurface *_fontRenderSurface;
|
||||
Common::Array<CVideoSurface *> _backSurfaces;
|
||||
CVideoSurface *_frontRenderSurface;
|
||||
CScreenManagerRec _entries[2];
|
||||
void *_mouseCursor;
|
||||
void *_textCursor;
|
||||
int _fontNumber;
|
||||
public:
|
||||
CScreenManager();
|
||||
CScreenManager(TitanicEngine *vm);
|
||||
virtual ~CScreenManager();
|
||||
|
||||
void fn1() {}
|
||||
void fn2() {}
|
||||
|
||||
virtual void proc2(int v);
|
||||
virtual bool proc3(int v);
|
||||
virtual void setMode() = 0;
|
||||
virtual void setWindowHandle(int v);
|
||||
virtual bool resetWindowHandle(int v);
|
||||
virtual void setMode(int width, int height, int bpp, int numBackSurfaces, bool flag2) = 0;
|
||||
virtual void proc5() = 0;
|
||||
virtual void proc6() = 0;
|
||||
virtual void proc7() = 0;
|
||||
@ -89,17 +94,29 @@ public:
|
||||
};
|
||||
|
||||
class OSScreenManager: CScreenManager {
|
||||
private:
|
||||
DirectDrawManager _directDrawManager;
|
||||
|
||||
/**
|
||||
* Frees any surface buffers
|
||||
*/
|
||||
void destroyFrontAndBackBuffers();
|
||||
|
||||
/**
|
||||
* Load game cursors
|
||||
*/
|
||||
void loadCursors();
|
||||
public:
|
||||
int _field48;
|
||||
int _field4C;
|
||||
int _field50;
|
||||
int _field54;
|
||||
void *_directDrawManager;
|
||||
STFont _fonts[4];
|
||||
public:
|
||||
OSScreenManager();
|
||||
OSScreenManager(TitanicEngine *vm);
|
||||
virtual ~OSScreenManager();
|
||||
|
||||
virtual void setMode();
|
||||
virtual void setMode(int width, int height, int bpp, int numBackSurfaces, bool flag2);
|
||||
virtual void proc5();
|
||||
virtual void proc6();
|
||||
virtual void proc7();
|
||||
|
@ -53,7 +53,7 @@ void TitanicEngine::initialize() {
|
||||
|
||||
CSaveableObject::initClassList();
|
||||
_window = new CMainGameWindow(this);
|
||||
_screenManager = new OSScreenManager();
|
||||
_screenManager = new OSScreenManager(this);
|
||||
}
|
||||
|
||||
Common::Error TitanicEngine::run() {
|
||||
|
@ -50,6 +50,10 @@ enum TitanicDebugChannels {
|
||||
|
||||
#define TITANIC_SAVEGAME_VERSION 1
|
||||
|
||||
#define ERROR_BASIC 1
|
||||
#define ERROR_INTERMEDIATE 2
|
||||
#define ERROR_DETAILED 3
|
||||
|
||||
struct TitanicGameDescription;
|
||||
class TitanicEngine;
|
||||
|
||||
@ -62,13 +66,6 @@ struct TitanicSavegameHeader {
|
||||
int _totalFrames;
|
||||
};
|
||||
|
||||
class Manager {
|
||||
protected:
|
||||
TitanicEngine *_vm;
|
||||
public:
|
||||
Manager(TitanicEngine *vm) : _vm(vm) {}
|
||||
};
|
||||
|
||||
class TitanicEngine : public Engine {
|
||||
private:
|
||||
/**
|
||||
|
@ -24,4 +24,19 @@
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
CVideoSurface::CVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface):
|
||||
_screenManager(screenManager), _surface(surface) {
|
||||
}
|
||||
|
||||
void CVideoSurface::setSurface(CScreenManager *screenManager, Graphics::Surface *surface) {
|
||||
_screenManager = screenManager;
|
||||
_surface = surface;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
OSVideoSurface::OSVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface):
|
||||
CVideoSurface(screenManager, surface) {
|
||||
}
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
@ -25,16 +25,26 @@
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/array.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "titanic/font.h"
|
||||
|
||||
namespace Titanic {
|
||||
|
||||
class CVideoSurface {
|
||||
class CScreenManager;
|
||||
|
||||
class CVideoSurface {
|
||||
private:
|
||||
CScreenManager *_screenManager;
|
||||
Graphics::Surface *_surface;
|
||||
public:
|
||||
CVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface);
|
||||
|
||||
void setSurface(CScreenManager *screenManager, Graphics::Surface *surface);
|
||||
};
|
||||
|
||||
class OSVideoSurface : CVideoSurface {
|
||||
|
||||
class OSVideoSurface : public CVideoSurface {
|
||||
public:
|
||||
OSVideoSurface(CScreenManager *screenManager, Graphics::Surface *surface);
|
||||
};
|
||||
|
||||
} // End of namespace Titanic
|
||||
|
Loading…
x
Reference in New Issue
Block a user