forked from beefviper/hode-vs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
system.h
78 lines (62 loc) · 2.28 KB
/
system.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
* Heart of Darkness engine rewrite
* Copyright (C) 2009-2011 Gregory Montoir ([email protected])
*/
#ifndef SYSTEM_H__
#define SYSTEM_H__
#include "intern.h"
#define SYS_INP_UP (1 << 0)
#define SYS_INP_RIGHT (1 << 1)
#define SYS_INP_DOWN (1 << 2)
#define SYS_INP_LEFT (1 << 3)
#define SYS_INP_RUN (1 << 4) /* (1 << 0) */
#define SYS_INP_JUMP (1 << 5) /* (1 << 1) */
#define SYS_INP_SHOOT (1 << 6) /* (1 << 2) */
#define SYS_INP_ESC (1 << 7)
struct PlayerInput {
uint8_t prevMask, mask;
bool skip;
bool exit;
bool quit;
bool screenshot;
bool keyPressed(int keyMask) const {
return (prevMask & keyMask) == 0 && (mask & keyMask) == keyMask;
}
bool keyReleased(int keyMask) const {
return (prevMask & keyMask) == keyMask && (mask & keyMask) == 0;
}
};
struct AudioCallback {
void (*proc)(void *param, int16_t *stream, int len); // 22khz
void *userdata;
};
struct System {
PlayerInput inp, pad;
virtual ~System() {}
virtual void init(const char *title, int w, int h, bool fullscreen, bool widescreen, bool yuv) = 0;
virtual void destroy() = 0;
virtual void setScaler(const char *name, int multiplier) = 0;
virtual void setGamma(float gamma) = 0;
virtual void setPalette(const uint8_t *pal, int n, int depth) = 0;
virtual void clearPalette() = 0;
virtual void copyRect(int x, int y, int w, int h, const uint8_t *buf, int pitch) = 0;
virtual void copyYuv(int w, int h, const uint8_t *y, int ypitch, const uint8_t *u, int upitch, const uint8_t *v, int vpitch) = 0;
virtual void fillRect(int x, int y, int w, int h, uint8_t color) = 0;
virtual void copyRectWidescreen(int w, int h, const uint8_t *buf, const uint8_t *pal) = 0;
virtual void shakeScreen(int dx, int dy) = 0;
virtual void updateScreen(bool drawWidescreen) = 0;
virtual void processEvents() = 0;
virtual void sleep(int duration) = 0;
virtual uint32_t getTimeStamp() = 0;
virtual void startAudio(AudioCallback callback) = 0;
virtual void stopAudio() = 0;
virtual void lockAudio() = 0;
virtual void unlockAudio() = 0;
virtual AudioCallback setAudioCallback(AudioCallback callback) = 0;
};
extern void System_earlyInit();
extern void System_printLog(FILE *, const char *s);
extern void System_fatalError(const char *s);
extern bool System_hasCommandLine();
extern System *const g_system;
#endif // SYSTEM_H__