REminiscence/systemstub.h

124 lines
3.0 KiB
C
Raw Normal View History

2016-03-20 17:00:00 +01:00
/*
* REminiscence - Flashback interpreter
2019-10-27 17:00:00 +01:00
* Copyright (C) 2005-2019 Gregory Montoir (cyx@users.sourceforge.net)
2015-08-02 18:00:00 +02:00
*/
#ifndef SYSTEMSTUB_H__
#define SYSTEMSTUB_H__
#include "intern.h"
2017-11-03 17:00:00 +01:00
#include "scaler.h"
2015-08-02 18:00:00 +02:00
struct PlayerInput {
enum {
DIR_UP = 1 << 0,
DIR_DOWN = 1 << 1,
DIR_LEFT = 1 << 2,
DIR_RIGHT = 1 << 3
};
enum {
DF_FASTMODE = 1 << 0,
DF_DBLOCKS = 1 << 1,
2021-09-05 18:00:00 +02:00
DF_SETLIFE = 1 << 2,
DF_AUTOZOOM = 1 << 3
2015-08-02 18:00:00 +02:00
};
uint8_t dirMask;
bool enter;
bool space;
bool shift;
bool backspace;
bool escape;
char lastChar;
bool save;
bool load;
int stateSlot;
2019-12-28 17:00:00 +01:00
bool rewind;
2015-08-02 18:00:00 +02:00
uint8_t dbgMask;
bool quit;
};
2017-11-03 17:00:00 +01:00
struct ScalerParameters {
ScalerType type;
2019-12-28 17:00:00 +01:00
char name[32];
2017-11-03 17:00:00 +01:00
int factor;
static ScalerParameters defaults();
};
2015-08-02 18:00:00 +02:00
struct SystemStub {
2016-05-09 18:00:00 +02:00
typedef void (*AudioCallback)(void *param, int16_t *stream, int len);
2015-08-02 18:00:00 +02:00
PlayerInput _pi;
virtual ~SystemStub() {}
2019-12-28 17:00:00 +01:00
virtual void init(const char *title, int w, int h, bool fullscreen, int widescreenMode, const ScalerParameters *scalerParameters) = 0;
2015-08-02 18:00:00 +02:00
virtual void destroy() = 0;
2018-03-18 17:00:00 +01:00
virtual bool hasWidescreen() const = 0;
2016-03-20 17:00:00 +01:00
virtual void setScreenSize(int w, int h) = 0;
2015-08-02 18:00:00 +02:00
virtual void setPalette(const uint8_t *pal, int n) = 0;
2019-10-27 17:00:00 +01:00
virtual void getPalette(uint8_t *pal, int n) = 0;
2015-08-02 18:00:00 +02:00
virtual void setPaletteEntry(int i, const Color *c) = 0;
virtual void getPaletteEntry(int i, Color *c) = 0;
virtual void setOverscanColor(int i) = 0;
virtual void copyRect(int x, int y, int w, int h, const uint8_t *buf, int pitch) = 0;
2018-03-18 17:00:00 +01:00
virtual void copyRectRgb24(int x, int y, int w, int h, const uint8_t *rgb) = 0;
2021-09-05 18:00:00 +02:00
virtual void zoomRect(int x, int y, int h, int w) = 0;
2019-10-27 17:00:00 +01:00
virtual void copyWidescreenLeft(int w, int h, const uint8_t *buf) = 0;
virtual void copyWidescreenRight(int w, int h, const uint8_t *buf) = 0;
virtual void copyWidescreenMirror(int w, int h, const uint8_t *buf) = 0;
virtual void copyWidescreenBlur(int w, int h, const uint8_t *buf) = 0;
2023-03-31 15:23:51 +02:00
virtual void copyWidescreenCDi(int w, int h, const uint8_t *buf, const uint8_t *pal) = 0;
2019-10-27 17:00:00 +01:00
virtual void clearWidescreen() = 0;
virtual void enableWidescreen(bool enable) = 0;
2015-08-02 18:00:00 +02:00
virtual void fadeScreen() = 0;
virtual void updateScreen(int shakeOffset) = 0;
virtual void processEvents() = 0;
virtual void sleep(int duration) = 0;
virtual uint32_t getTimeStamp() = 0;
virtual void startAudio(AudioCallback callback, void *param) = 0;
virtual void stopAudio() = 0;
virtual uint32_t getOutputSampleRate() = 0;
virtual void lockAudio() = 0;
virtual void unlockAudio() = 0;
};
struct LockAudioStack {
LockAudioStack(SystemStub *stub)
: _stub(stub) {
_stub->lockAudio();
}
~LockAudioStack() {
_stub->unlockAudio();
}
SystemStub *_stub;
};
2021-09-05 18:00:00 +02:00
struct ToggleWidescreenStack {
ToggleWidescreenStack(SystemStub *stub, bool state)
: _stub(stub), _state(state) {
if (_stub->hasWidescreen()) {
_stub->enableWidescreen(_state);
}
}
~ToggleWidescreenStack() {
if (_stub->hasWidescreen()) {
_stub->enableWidescreen(!_state);
}
}
SystemStub *_stub;
bool _state;
};
2015-08-02 18:00:00 +02:00
extern SystemStub *SystemStub_SDL_create();
#endif // SYSTEMSTUB_H__