(svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
parent
7884a07b43
commit
5e85e8c5e0
@ -1,47 +0,0 @@
|
||||
/* $Id$ */
|
||||
|
||||
/** @file hal.h Hardware Abstraction Layer declarations */
|
||||
|
||||
#ifndef HAL_H
|
||||
#define HAL_H
|
||||
|
||||
struct HalCommonDriver {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)();
|
||||
};
|
||||
|
||||
struct HalVideoDriver {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)();
|
||||
void (*make_dirty)(int left, int top, int width, int height);
|
||||
void (*main_loop)();
|
||||
bool (*change_resolution)(int w, int h);
|
||||
void (*toggle_fullscreen)(bool fullscreen);
|
||||
};
|
||||
|
||||
struct HalSoundDriver {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)();
|
||||
};
|
||||
|
||||
struct HalMusicDriver {
|
||||
const char *(*start)(const char * const *parm);
|
||||
void (*stop)();
|
||||
|
||||
void (*play_song)(const char *filename);
|
||||
void (*stop_song)();
|
||||
bool (*is_song_playing)();
|
||||
void (*set_volume)(byte vol);
|
||||
};
|
||||
|
||||
extern HalMusicDriver *_music_driver;
|
||||
extern HalSoundDriver *_sound_driver;
|
||||
extern HalVideoDriver *_video_driver;
|
||||
|
||||
enum DriverType {
|
||||
VIDEO_DRIVER = 0,
|
||||
SOUND_DRIVER = 1,
|
||||
MUSIC_DRIVER = 2,
|
||||
};
|
||||
|
||||
#endif /* HAL_H */
|
@ -0,0 +1,35 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef MUSIC_MUSIC_DRIVER_HPP
|
||||
#define MUSIC_MUSIC_DRIVER_HPP
|
||||
|
||||
#include "../driver.h"
|
||||
|
||||
class MusicDriver: public Driver {
|
||||
public:
|
||||
virtual void PlaySong(const char *filename) = 0;
|
||||
|
||||
virtual void StopSong() = 0;
|
||||
|
||||
virtual bool IsSongPlaying() = 0;
|
||||
|
||||
virtual void SetVolume(byte vol) = 0;
|
||||
};
|
||||
|
||||
class MusicDriverFactoryBase: public DriverFactoryBase {
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class MusicDriverFactory: public MusicDriverFactoryBase {
|
||||
public:
|
||||
MusicDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_MUSIC); }
|
||||
|
||||
/**
|
||||
* Get the long, human readable, name for the Driver-class.
|
||||
*/
|
||||
const char *GetName();
|
||||
};
|
||||
|
||||
extern MusicDriver *_music_driver;
|
||||
|
||||
#endif /* MUSIC_MUSIC_DRIVER_HPP */
|
@ -0,0 +1,27 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef SOUND_SOUND_DRIVER_HPP
|
||||
#define SOUND_SOUND_DRIVER_HPP
|
||||
|
||||
#include "../driver.h"
|
||||
|
||||
class SoundDriver: public Driver {
|
||||
};
|
||||
|
||||
class SoundDriverFactoryBase: public DriverFactoryBase {
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class SoundDriverFactory: public SoundDriverFactoryBase {
|
||||
public:
|
||||
SoundDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_SOUND); }
|
||||
|
||||
/**
|
||||
* Get the long, human readable, name for the Driver-class.
|
||||
*/
|
||||
const char *GetName();
|
||||
};
|
||||
|
||||
extern SoundDriver *_sound_driver;
|
||||
|
||||
#endif /* SOUND_SOUND_DRIVER_HPP */
|
@ -0,0 +1,35 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef VIDEO_VIDEO_DRIVER_HPP
|
||||
#define VIDEO_VIDEO_DRIVER_HPP
|
||||
|
||||
#include "../driver.h"
|
||||
|
||||
class VideoDriver: public Driver {
|
||||
public:
|
||||
virtual void MakeDirty(int left, int top, int width, int height) = 0;
|
||||
|
||||
virtual void MainLoop() = 0;
|
||||
|
||||
virtual bool ChangeResolution(int w, int h) = 0;
|
||||
|
||||
virtual void ToggleFullscreen(bool fullscreen) = 0;
|
||||
};
|
||||
|
||||
class VideoDriverFactoryBase: public DriverFactoryBase {
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class VideoDriverFactory: public VideoDriverFactoryBase {
|
||||
public:
|
||||
VideoDriverFactory() { this->RegisterDriver(((T *)this)->GetName(), Driver::DT_VIDEO); }
|
||||
|
||||
/**
|
||||
* Get the long, human readable, name for the Driver-class.
|
||||
*/
|
||||
const char *GetName();
|
||||
};
|
||||
|
||||
extern VideoDriver *_video_driver;
|
||||
|
||||
#endif /* VIDEO_VIDEO_DRIVER_HPP */
|
Loading…
Reference in New Issue