forked from techtronics/bermuda
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwin16.cpp
56 lines (53 loc) · 1.45 KB
/
win16.cpp
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
/*
* Bermuda Syndrome engine rewrite
* Copyright (C) 2007-2011 Gregory Montoir
*/
#include "file.h"
#include "game.h"
#include "mixer.h"
#include "systemstub.h"
int Game::win16_sndPlaySound(int op, void *data) {
debug(DBG_WIN16, "win16_sndPlaySound() %d", op);
switch (op) {
case 22:
if (!_mixer->isSoundPlaying(_mixerSoundId)) {
return 1;
}
break;
case 3: {
const char *fileName = (const char *)data;
File *f = _fs.openFile(fileName, false);
if (f) {
_mixer->playSound(f, &_mixerSoundId);
_fs.closeFile(f);
} else {
warning("Unable to open wav file '%s'", fileName);
}
}
break;
case 6:
case 7:
_mixer->stopSound(_mixerSoundId);
break;
default:
warning("Unhandled op %d in win16_sndPlaySound", op);
break;
}
return 0;
}
void Game::win16_stretchBits(SceneBitmap *bits, int srcHeight, int srcWidth, int srcY, int srcX, int dstHeight, int dstWidth, int dstY, int dstX) {
debug(DBG_WIN16, "win16_stretchBits() %d,%d %d,%d", srcX, srcY, srcWidth, srcHeight);
assert(srcWidth == dstWidth && srcHeight == dstHeight);
const uint8_t *src = bits->bits + srcY * bits->pitch + srcX;
if (dstX >= kGameScreenWidth) {
return;
} else if (dstX + dstWidth > kGameScreenWidth) {
dstWidth = kGameScreenWidth - dstX;
}
if (dstY >= kGameScreenHeight) {
return;
} else if (dstY + dstHeight > kGameScreenHeight) {
dstHeight = kGameScreenHeight - dstY;
}
_stub->copyRect(dstX, dstY, dstWidth, dstHeight, src, bits->pitch);
}