mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 21:21:05 +00:00
indent run
svn-id: r4481
This commit is contained in:
parent
ad4809459d
commit
99bd8afcd4
@ -153,8 +153,7 @@ void hashconfig::merge(const hashconfig *h)
|
||||
// The config-class itself.
|
||||
|
||||
Config::Config (const char *cfg, const char *d)
|
||||
: filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0),
|
||||
willwrite(false)
|
||||
: filename(Scumm::Strdup(cfg)), domain(d ? Scumm::Strdup(d) : 0), hash(0), ndomains(0), willwrite(false)
|
||||
{
|
||||
FILE *cfg_file;
|
||||
char t[MAXLINELEN];
|
||||
|
192
gfx.cpp
192
gfx.cpp
@ -29,14 +29,14 @@ void Scumm::getGraphicsPerformance()
|
||||
int i;
|
||||
|
||||
for (i = 10; i != 0; i--) {
|
||||
initScreens(0, 0, _realWidth, _realHeight); //ender
|
||||
initScreens(0, 0, _realWidth, _realHeight); //ender
|
||||
}
|
||||
|
||||
if (!(_features & GF_SMALL_HEADER)) /* FIXME TEST: Enders Zak fix */
|
||||
_vars[VAR_PERFORMANCE_1] = 0; //_scummTimer;
|
||||
|
||||
for (i = 10; i != 0; i--) {
|
||||
setDirtyRange(0, 0, _realHeight); //ender
|
||||
setDirtyRange(0, 0, _realHeight); //ender
|
||||
drawDirtyScreenParts();
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void Scumm::initScreens(int a, int b, int w, int h)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
nukeResource(rtBuffer, i+1);
|
||||
nukeResource(rtBuffer, i + 1);
|
||||
nukeResource(rtBuffer, i + 5);
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ void Scumm::initScreens(int a, int b, int w, int h)
|
||||
}
|
||||
initVirtScreen(0, 0, b, _realWidth, h - b, true, true);
|
||||
initVirtScreen(1, 0, 0, _realWidth, b, false, false);
|
||||
initVirtScreen(2, 0, h, _realWidth, _realHeight - h, false, false); //ender
|
||||
initVirtScreen(2, 0, h, _realWidth, _realHeight - h, false, false); //ender
|
||||
|
||||
_screenB = b;
|
||||
_screenH = h;
|
||||
@ -96,8 +96,8 @@ void Scumm::initVirtScreen(int slot, int number, int top, int width, int height,
|
||||
if (vs->scrollable)
|
||||
size += 320 * 4;
|
||||
|
||||
createResource(rtBuffer, slot+1, size);
|
||||
vs->screenPtr = getResourceAddress(rtBuffer, slot+1);
|
||||
createResource(rtBuffer, slot + 1, size);
|
||||
vs->screenPtr = getResourceAddress(rtBuffer, slot + 1);
|
||||
|
||||
ptr = vs->screenPtr;
|
||||
for (i = 0; i < size; i++) // reset background ?
|
||||
@ -133,21 +133,20 @@ void Scumm::drawDirtyScreenParts()
|
||||
{
|
||||
int i;
|
||||
VirtScreen *vs;
|
||||
byte * src;
|
||||
byte *src;
|
||||
|
||||
updateDirtyScreen(2);
|
||||
if (_features & GF_OLD256)
|
||||
updateDirtyScreen(1);
|
||||
|
||||
if ((camera._last.x == camera._cur.x &&
|
||||
camera._last.y == camera._cur.y && (_features & GF_AFTER_V7))
|
||||
if ((camera._last.x == camera._cur.x && camera._last.y == camera._cur.y && (_features & GF_AFTER_V7))
|
||||
|| (camera._last.x == camera._cur.x)) {
|
||||
updateDirtyScreen(0);
|
||||
} else {
|
||||
vs = &virtscr[0];
|
||||
|
||||
src = vs->screenPtr + _screenStartStrip * 8 + camera._cur.y - 100;
|
||||
_system->copy_rect(src , 320, 0, vs->topline, 320, vs->height);
|
||||
_system->copy_rect(src, 320, 0, vs->topline, 320, vs->height);
|
||||
|
||||
for (i = 0; i < 40; i++) {
|
||||
vs->tdirty[i] = (byte)vs->height;
|
||||
@ -156,7 +155,7 @@ void Scumm::drawDirtyScreenParts()
|
||||
}
|
||||
|
||||
/* Handle shaking */
|
||||
if (_shakeEnabled && !_gui->isActive()) {
|
||||
if (_shakeEnabled && !_gui->isActive()) {
|
||||
_shakeFrame = (_shakeFrame + 1) & (NUM_SHAKE_POSITIONS - 1);
|
||||
_system->set_shake_pos(shake_positions[_shakeFrame]);
|
||||
}
|
||||
@ -167,7 +166,7 @@ void Scumm::updateDirtyScreen(int slot)
|
||||
gdi.updateDirtyScreen(&virtscr[slot]);
|
||||
}
|
||||
|
||||
void Gdi::updateDirtyScreen(VirtScreen * vs)
|
||||
void Gdi::updateDirtyScreen(VirtScreen *vs)
|
||||
{
|
||||
int i;
|
||||
int start, w, top, bottom;
|
||||
@ -187,17 +186,15 @@ void Gdi::updateDirtyScreen(VirtScreen * vs)
|
||||
|
||||
if (_vm->_features & GF_AFTER_V7 && (_vm->camera._cur.y != _vm->camera._last.y))
|
||||
drawStripToScreen(vs, start, w, 0, vs->height);
|
||||
else
|
||||
if (bottom) {
|
||||
else if (bottom) {
|
||||
top = vs->tdirty[i];
|
||||
vs->tdirty[i] = (byte)vs->height;
|
||||
vs->bdirty[i] = 0;
|
||||
if (i != 39 && vs->bdirty[i + 1] == (byte)bottom
|
||||
&& vs->tdirty[i + 1] == (byte)top) {
|
||||
if (i != 39 && vs->bdirty[i + 1] == (byte)bottom && vs->tdirty[i + 1] == (byte)top) {
|
||||
w += 8;
|
||||
continue;
|
||||
}
|
||||
if(_vm->_features & GF_AFTER_V7)
|
||||
if (_vm->_features & GF_AFTER_V7)
|
||||
drawStripToScreen(vs, start, w, 0, vs->height);
|
||||
else
|
||||
drawStripToScreen(vs, start, w, top, bottom);
|
||||
@ -207,7 +204,7 @@ void Gdi::updateDirtyScreen(VirtScreen * vs)
|
||||
}
|
||||
}
|
||||
|
||||
void Gdi::drawStripToScreen(VirtScreen * vs, int x, int w, int t, int b)
|
||||
void Gdi::drawStripToScreen(VirtScreen *vs, int x, int w, int t, int b)
|
||||
{
|
||||
byte *ptr;
|
||||
int scrollY;
|
||||
@ -223,15 +220,15 @@ void Gdi::drawStripToScreen(VirtScreen * vs, int x, int w, int t, int b)
|
||||
b = vs->height;
|
||||
|
||||
height = b - t;
|
||||
if(height > 200)
|
||||
if (height > 200)
|
||||
height = 200;
|
||||
|
||||
scrollY = _vm->camera._cur.y - 100;
|
||||
if(scrollY == -100)
|
||||
if (scrollY == -100)
|
||||
scrollY = 0;
|
||||
|
||||
ptr = vs->screenPtr + (t * 40 + x) * 8 + _readOffs + scrollY * 320;
|
||||
_vm->_system->copy_rect(ptr, 320, x * 8, vs->topline + t , w, height);
|
||||
_vm->_system->copy_rect(ptr, 320, x * 8, vs->topline + t, w, height);
|
||||
}
|
||||
|
||||
void blit(byte *dst, byte *src, int w, int h)
|
||||
@ -302,7 +299,7 @@ void Scumm::setCameraAt(int pos_x, int pos_y)
|
||||
}
|
||||
}
|
||||
|
||||
void Scumm::setCameraFollows(Actor * a)
|
||||
void Scumm::setCameraFollows(Actor *a)
|
||||
{
|
||||
if (_features & GF_AFTER_V7) {
|
||||
CameraData *cd = &camera;
|
||||
@ -318,8 +315,7 @@ void Scumm::setCameraFollows(Actor * a)
|
||||
ax = abs(a->x - cd->_cur.x);
|
||||
ay = abs(a->y - cd->_cur.y);
|
||||
|
||||
if (ax > _vars[VAR_CAMERA_THRESHOLD_X] ||
|
||||
ay > _vars[VAR_CAMERA_THRESHOLD_Y] || ax > 160 || ay > 100) {
|
||||
if (ax > _vars[VAR_CAMERA_THRESHOLD_X] || ay > _vars[VAR_CAMERA_THRESHOLD_Y] || ax > 160 || ay > 100) {
|
||||
setCameraAt(a->x, a->y);
|
||||
}
|
||||
|
||||
@ -341,8 +337,7 @@ void Scumm::setCameraFollows(Actor * a)
|
||||
|
||||
t = (a->x >> 3);
|
||||
|
||||
if (t - _screenStartStrip < cd->_leftTrigger ||
|
||||
t - _screenStartStrip > cd->_rightTrigger)
|
||||
if (t - _screenStartStrip < cd->_leftTrigger || t - _screenStartStrip > cd->_rightTrigger)
|
||||
setCameraAt(a->x, 0);
|
||||
|
||||
for (i = 1, a = getFirstActor(); ++a, i < NUM_ACTORS; i++) {
|
||||
@ -373,7 +368,7 @@ void Scumm::initBGBuffers(int height)
|
||||
assert(gdi._numZBuffer >= 1 && gdi._numZBuffer <= 5);
|
||||
|
||||
if (_features & GF_AFTER_V7)
|
||||
itemsize = (virtscr[0].height +4) * 40;
|
||||
itemsize = (virtscr[0].height + 4) * 40;
|
||||
else
|
||||
itemsize = (_scrHeight + 4) * 40;
|
||||
|
||||
@ -662,7 +657,7 @@ const uint32 zplane_tags[] = {
|
||||
MKID('ZP04')
|
||||
};
|
||||
|
||||
void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
void Gdi::drawBitmap(byte *ptr, VirtScreen *vs, int x, int y, int h,
|
||||
int stripnr, int numstrip, byte flag)
|
||||
{
|
||||
byte *smap_ptr, *where_draw_ptr;
|
||||
@ -687,11 +682,9 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
|
||||
if (_vm->_features & GF_SMALL_HEADER) {
|
||||
/* this is really ugly, FIXME */
|
||||
if (ptr[-2] == 'B' && ptr[-1] == 'M' &&
|
||||
READ_LE_UINT32(ptr - 6) > (READ_LE_UINT32(ptr) + 10)) {
|
||||
if (ptr[-2] == 'B' && ptr[-1] == 'M' && READ_LE_UINT32(ptr - 6) > (READ_LE_UINT32(ptr) + 10)) {
|
||||
zplane_list[1] = smap_ptr + READ_LE_UINT32(ptr);
|
||||
} else if (ptr[-4] == 'O' && ptr[-3] == 'I' &&
|
||||
READ_LE_UINT32(ptr - 8) > READ_LE_UINT32(ptr) + 12) {
|
||||
} else if (ptr[-4] == 'O' && ptr[-3] == 'I' && READ_LE_UINT32(ptr - 8) > READ_LE_UINT32(ptr) + 12) {
|
||||
zplane_list[1] = smap_ptr + READ_LE_UINT32(ptr);
|
||||
} else {
|
||||
zplane_list[1] = 0;
|
||||
@ -706,8 +699,7 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
|
||||
bottom = y + h;
|
||||
if (bottom > vs->height) {
|
||||
warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom,
|
||||
vs->height);
|
||||
warning("Gdi::drawBitmap, strip drawn to %d below window bottom %d", bottom, vs->height);
|
||||
}
|
||||
|
||||
twobufs = vs->alloctwobuffers;
|
||||
@ -737,8 +729,7 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
vs->bdirty[sx] = bottom;
|
||||
|
||||
_backbuff_ptr = vs->screenPtr + (y * 40 + x) * 8;
|
||||
_bgbak_ptr =
|
||||
_vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * 40 + x) * 8;
|
||||
_bgbak_ptr = _vm->getResourceAddress(rtBuffer, vs->number + 5) + (y * 40 + x) * 8;
|
||||
if (!twobufs) {
|
||||
_bgbak_ptr = _backbuff_ptr;
|
||||
}
|
||||
@ -772,13 +763,13 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
else
|
||||
decompressMaskImg();
|
||||
}
|
||||
|
||||
|
||||
for (i = 1; i < numzbuf; i++) {
|
||||
uint16 offs;
|
||||
|
||||
if (!zplane_list[i])
|
||||
continue;
|
||||
|
||||
continue;
|
||||
|
||||
if (_vm->_features & GF_SMALL_HEADER)
|
||||
if (_vm->_features & GF_OLD256)
|
||||
offs = READ_LE_UINT16(zplane_list[i] + stripnr * 2 + 4);
|
||||
@ -797,8 +788,7 @@ void Gdi::drawBitmap(byte *ptr, VirtScreen * vs, int x, int y, int h,
|
||||
else
|
||||
decompressMaskImg();
|
||||
} else {
|
||||
if (_useOrDecompress && flag & dbAllowMaskOr)
|
||||
; /* nothing */
|
||||
if (_useOrDecompress && flag & dbAllowMaskOr); /* nothing */
|
||||
else
|
||||
for (int h = 0; h < _numLinesToProcess; h++)
|
||||
_mask_ptr_dest[h * 40] = 0;
|
||||
@ -827,7 +817,7 @@ void Gdi::decompressBitmap()
|
||||
_palette_mod = 16;
|
||||
else
|
||||
_palette_mod = 0;
|
||||
|
||||
|
||||
switch (code) {
|
||||
case 1:
|
||||
unkDecode7();
|
||||
@ -1095,8 +1085,7 @@ void Scumm::redrawBGStrip(int start, int num)
|
||||
{
|
||||
int s = _screenStartStrip + start;
|
||||
|
||||
assert(s >= 0
|
||||
&& (size_t) s < sizeof(gfxUsageBits) / sizeof(gfxUsageBits[0]));
|
||||
assert(s >= 0 && (size_t) s < sizeof(gfxUsageBits) / sizeof(gfxUsageBits[0]));
|
||||
|
||||
_curVirtScreen = &virtscr[0];
|
||||
|
||||
@ -1129,7 +1118,7 @@ void Gdi::unkDecode1()
|
||||
do {
|
||||
_currentX = 8;
|
||||
do {
|
||||
FILL_BITS * dst++ = color + _palette_mod;;
|
||||
FILL_BITS *dst++ = color + _palette_mod;;
|
||||
|
||||
againPos:;
|
||||
|
||||
@ -1181,7 +1170,7 @@ void Gdi::unkDecode2()
|
||||
_currentX = 8;
|
||||
do {
|
||||
FILL_BITS if (color != _transparency)
|
||||
*dst = color + _palette_mod;
|
||||
*dst = color + _palette_mod;
|
||||
dst++;
|
||||
if (!READ_BIT) {
|
||||
} else if (!READ_BIT) {
|
||||
@ -1216,7 +1205,7 @@ void Gdi::unkDecode3()
|
||||
_currentX = 8;
|
||||
do {
|
||||
FILL_BITS if (color != _transparency)
|
||||
*dst = color + _palette_mod;
|
||||
*dst = color + _palette_mod;
|
||||
dst++;
|
||||
|
||||
againPos:;
|
||||
@ -1280,7 +1269,7 @@ void Gdi::unkDecode4()
|
||||
_tempNumLines = _numLinesToProcess;
|
||||
do {
|
||||
FILL_BITS if (color != _transparency)
|
||||
*dst = color + _palette_mod;
|
||||
*dst = color + _palette_mod;
|
||||
dst += 320;
|
||||
if (!READ_BIT) {
|
||||
} else if (!READ_BIT) {
|
||||
@ -1314,7 +1303,7 @@ void Gdi::unkDecode5()
|
||||
do {
|
||||
_currentX = 8;
|
||||
do {
|
||||
FILL_BITS * dst++ = color + _palette_mod;
|
||||
FILL_BITS *dst++ = color + _palette_mod;
|
||||
if (!READ_BIT) {
|
||||
} else if (!READ_BIT) {
|
||||
FILL_BITS color = bits & _decomp_mask;
|
||||
@ -1346,7 +1335,7 @@ void Gdi::unkDecode6()
|
||||
do {
|
||||
_tempNumLines = _numLinesToProcess;
|
||||
do {
|
||||
FILL_BITS * dst = color + _palette_mod;
|
||||
FILL_BITS *dst = color + _palette_mod;
|
||||
dst += 320;
|
||||
if (!READ_BIT) {
|
||||
} else if (!READ_BIT) {
|
||||
@ -1522,7 +1511,7 @@ void Gdi::unkDecode11()
|
||||
dst += 320;
|
||||
for (i = 0; i < 3; i++) {
|
||||
READ_256BIT if (!bits)
|
||||
break;
|
||||
break;
|
||||
}
|
||||
switch (i) {
|
||||
case 1:
|
||||
@ -1558,8 +1547,7 @@ void Scumm::restoreCharsetBg()
|
||||
_bkColor = 0;
|
||||
|
||||
if (gdi._mask_left != -1) {
|
||||
restoreBG(gdi._mask_left, gdi._mask_top, gdi._mask_right,
|
||||
gdi._mask_bottom);
|
||||
restoreBG(gdi._mask_left, gdi._mask_top, gdi._mask_right, gdi._mask_bottom);
|
||||
charset._hasMask = false;
|
||||
gdi._mask_left = -1;
|
||||
charset._strLeft = -1;
|
||||
@ -1603,16 +1591,13 @@ void Scumm::restoreBG(int left, int top, int right, int bottom)
|
||||
if (bottom >= height)
|
||||
bottom = height;
|
||||
|
||||
updateDirtyRect(vs->number, left, right, top - topline, bottom - topline,
|
||||
0x40000000);
|
||||
updateDirtyRect(vs->number, left, right, top - topline, bottom - topline, 0x40000000);
|
||||
|
||||
height = (top - topline) * 320 + vs->xstart + left;
|
||||
|
||||
backbuff = vs->screenPtr + height;
|
||||
bgbak = getResourceAddress(rtBuffer, vs->number + 5) + height;
|
||||
mask =
|
||||
getResourceAddress(rtBuffer,
|
||||
9) + top * 40 + (left >> 3) + _screenStartStrip;
|
||||
mask = getResourceAddress(rtBuffer, 9) + top * 40 + (left >> 3) + _screenStartStrip;
|
||||
if (vs->number == 0) {
|
||||
mask += vs->topline * 216;
|
||||
}
|
||||
@ -1621,8 +1606,7 @@ void Scumm::restoreBG(int left, int top, int right, int bottom)
|
||||
width = right - left;
|
||||
widthmod = (width >> 2) + 2;
|
||||
|
||||
if (vs->alloctwobuffers
|
||||
&& _currentRoom != 0 /*&& _vars[VAR_V5_DRAWFLAGS]&2 */ ) {
|
||||
if (vs->alloctwobuffers && _currentRoom != 0 /*&& _vars[VAR_V5_DRAWFLAGS]&2 */ ) {
|
||||
blit(backbuff, bgbak, width, height);
|
||||
if (vs->number == 0 && charset._hasMask && height) {
|
||||
do {
|
||||
@ -1640,8 +1624,7 @@ void Scumm::restoreBG(int left, int top, int right, int bottom)
|
||||
}
|
||||
}
|
||||
|
||||
void Scumm::updateDirtyRect(int virt, int left, int right, int top,
|
||||
int bottom, uint32 dirtybits)
|
||||
void Scumm::updateDirtyRect(int virt, int left, int right, int top, int bottom, uint32 dirtybits)
|
||||
{
|
||||
VirtScreen *vs = &virtscr[virt];
|
||||
int lp, rp;
|
||||
@ -1679,8 +1662,7 @@ void Scumm::updateDirtyRect(int virt, int left, int right, int top,
|
||||
setVirtscreenDirty(vs, left, top, right, bottom);
|
||||
}
|
||||
|
||||
void Scumm::setVirtscreenDirty(VirtScreen * vs, int left, int top, int right,
|
||||
int bottom)
|
||||
void Scumm::setVirtscreenDirty(VirtScreen *vs, int left, int top, int right, int bottom)
|
||||
{
|
||||
int lp = left >> 3;
|
||||
int rp = right >> 3;
|
||||
@ -1738,6 +1720,8 @@ void Scumm::unkScreenEffect4()
|
||||
warning("stub unkScreenEffect4()");
|
||||
}
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
|
||||
static const int8 screen_eff7_table1[4][16] = {
|
||||
{ 1, 1, -1, 1, -1, 1, -1, -1,
|
||||
1, -1, -1, -1, 1, 1, 1, -1},
|
||||
@ -1762,6 +1746,8 @@ static const byte transition_num_of_iterations[4] = {
|
||||
13, 25, 25, 25
|
||||
};
|
||||
|
||||
/* *INDENT-ON* */
|
||||
|
||||
/* Transition effect. There are four different effects possible,
|
||||
* indicated by the value of a:
|
||||
* 0: Iris effect
|
||||
@ -1774,7 +1760,7 @@ static const byte transition_num_of_iterations[4] = {
|
||||
*/
|
||||
void Scumm::transitionEffect(int a)
|
||||
{
|
||||
int delta[16]; // Offset applied during each iteration
|
||||
int delta[16]; // Offset applied during each iteration
|
||||
int tab_2[16];
|
||||
int i, j;
|
||||
int bottom;
|
||||
@ -1849,12 +1835,11 @@ void Scumm::setShake(int mode)
|
||||
|
||||
void Gdi::clearUpperMask()
|
||||
{
|
||||
memset(_vm->getResourceAddress(rtBuffer, 9),
|
||||
0, _imgBufOffs[1] - _imgBufOffs[0]
|
||||
memset(_vm->getResourceAddress(rtBuffer, 9), 0, _imgBufOffs[1] - _imgBufOffs[0]
|
||||
);
|
||||
}
|
||||
|
||||
void Scumm::clampCameraPos(ScummPoint * pt)
|
||||
void Scumm::clampCameraPos(ScummPoint *pt)
|
||||
{
|
||||
if (pt->x < _vars[VAR_CAMERA_MIN_X])
|
||||
pt->x = _vars[VAR_CAMERA_MIN_X];
|
||||
@ -1956,9 +1941,9 @@ void Scumm::moveCamera()
|
||||
|
||||
_vars[VAR_CAMERA_DEST_Y] = cd->_dest.y;
|
||||
|
||||
_vars[VAR_CAMERA_FOLLOWED_ACTOR] = cd ->_follows;
|
||||
_vars[VAR_CAMERA_FOLLOWED_ACTOR] = cd->_follows;
|
||||
|
||||
if(_vars[VAR_SCROLL_SCRIPT])
|
||||
if (_vars[VAR_SCROLL_SCRIPT])
|
||||
runScript(_vars[VAR_SCROLL_SCRIPT], 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
@ -2227,7 +2212,7 @@ void Gdi::resetBackground(int top, int bottom, int strip)
|
||||
if (bottom > vs->bdirty[strip])
|
||||
vs->bdirty[strip] = bottom;
|
||||
|
||||
offs = (top * 40 + _vm->_screenStartStrip + strip );
|
||||
offs = (top * 40 + _vm->_screenStartStrip + strip);
|
||||
_mask_ptr = _vm->getResourceAddress(rtBuffer, 9) + offs;
|
||||
_bgbak_ptr = _vm->getResourceAddress(rtBuffer, 5) + (offs << 3);
|
||||
_backbuff_ptr = vs->screenPtr + (offs << 3);
|
||||
@ -2262,7 +2247,7 @@ void Scumm::setCursorHotspot2(int x, int y)
|
||||
byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem)
|
||||
{
|
||||
int w, h, i;
|
||||
|
||||
|
||||
l >>= 3;
|
||||
if (l < 0)
|
||||
l = 0;
|
||||
@ -2280,7 +2265,7 @@ byte Scumm::isMaskActiveAt(int l, int t, int r, int b, byte *mem)
|
||||
|
||||
do {
|
||||
for (i = 0; i <= w; i++)
|
||||
if (mem[i]) {
|
||||
if (mem[i]) {
|
||||
return true;
|
||||
}
|
||||
mem += 40;
|
||||
@ -2340,7 +2325,7 @@ void Scumm::darkenPalette(int startColor, int endColor, int redScale, int greenS
|
||||
byte *cptr, *cur;
|
||||
int num;
|
||||
int color;
|
||||
|
||||
|
||||
cptr = getPalettePtr() + startColor * 3;
|
||||
cur = _currentPalette + startColor * 3;
|
||||
num = endColor - startColor + 1;
|
||||
@ -2433,7 +2418,7 @@ void Scumm::grabCursor(byte *ptr, int width, int height)
|
||||
dst += width;
|
||||
ptr += 320;
|
||||
}
|
||||
|
||||
|
||||
updateCursor();
|
||||
}
|
||||
|
||||
@ -2454,16 +2439,17 @@ void Scumm::useIm01Cursor(byte *im, int w, int h)
|
||||
|
||||
grabCursor(vs->screenPtr + vs->xstart, w, h);
|
||||
|
||||
blit(vs->screenPtr + vs->xstart,
|
||||
getResourceAddress(rtBuffer, 5) + vs->xstart, w, h);
|
||||
blit(vs->screenPtr + vs->xstart, getResourceAddress(rtBuffer, 5) + vs->xstart, w, h);
|
||||
}
|
||||
|
||||
void Scumm::updateCursor() {
|
||||
void Scumm::updateCursor()
|
||||
{
|
||||
_system->set_mouse_cursor(_grabbedCursor, _cursorWidth, _cursorHeight,
|
||||
_cursorHotspotX, _cursorHotspotY);
|
||||
_cursorHotspotX, _cursorHotspotY);
|
||||
}
|
||||
|
||||
void Scumm::animateCursor() {
|
||||
void Scumm::animateCursor()
|
||||
{
|
||||
if (_cursorAnimate) {
|
||||
if (!(_cursorAnimateIndex & 0x3)) {
|
||||
decompressDefaultCursor((_cursorAnimateIndex >> 2) & 3);
|
||||
@ -2511,7 +2497,7 @@ void Scumm::decompressDefaultCursor(int idx)
|
||||
color = default_cursor_colors[idx];
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if ((i<7) || (i>9)) {
|
||||
if ((i < 7) || (i > 9)) {
|
||||
_grabbedCursor[16 * 8 + i] = color;
|
||||
_grabbedCursor[16 * i + 8] = color;
|
||||
}
|
||||
@ -2561,8 +2547,7 @@ int Scumm::remapPaletteColor(int r, int g, int b, uint threshold)
|
||||
}
|
||||
}
|
||||
|
||||
if (threshold != (uint) - 1
|
||||
&& bestsum > threshold * threshold * (2 + 3 + 6)) {
|
||||
if (threshold != (uint) - 1 && bestsum > threshold * threshold * (2 + 3 + 6)) {
|
||||
pal = _currentPalette + (256 - 2) * 3;
|
||||
for (i = 254; i > 48; i--, pal -= 3) {
|
||||
if (pal[0] >= 252 && pal[1] >= 252 && pal[2] >= 252) {
|
||||
@ -2581,7 +2566,7 @@ int Scumm::remapPaletteColor(int r, int g, int b, uint threshold)
|
||||
// param2= mirror
|
||||
|
||||
// param1= never used ?
|
||||
void Scumm::drawBomp(BompDrawData *bd, int param1, byte* dataPtr, int param2, int param3)
|
||||
void Scumm::drawBomp(BompDrawData *bd, int param1, byte *dataPtr, int param2, int param3)
|
||||
{
|
||||
byte *dest = bd->out + bd->y * bd->outwidth, *src;
|
||||
int h = bd->srcheight;
|
||||
@ -2591,8 +2576,7 @@ void Scumm::drawBomp(BompDrawData *bd, int param1, byte* dataPtr, int param2, in
|
||||
return;
|
||||
|
||||
inside = (bd->x >= 0) && (bd->y >= 0) &&
|
||||
(bd->x <= bd->outwidth - bd->srcwidth) &&
|
||||
(bd->y <= bd->outheight - bd->srcheight);
|
||||
(bd->x <= bd->outwidth - bd->srcwidth) && (bd->y <= bd->outheight - bd->srcheight);
|
||||
|
||||
if (1 || bd->scale_x == 255 && bd->scale_y == 255) {
|
||||
/* Routine used when no scaling is needed */
|
||||
@ -2673,14 +2657,15 @@ void Scumm::drawBomp(BompDrawData *bd, int param1, byte* dataPtr, int param2, in
|
||||
/* scaling of bomp images not supported yet */
|
||||
}
|
||||
|
||||
CHECK_HEAP;
|
||||
CHECK_HEAP;
|
||||
}
|
||||
|
||||
|
||||
/* Yazoo: This function create the specialPalette used for semi-transparency in SamnMax */
|
||||
|
||||
|
||||
void Scumm::createSpecialPalette(int16 a, int16 b, int16 c, int16 d, int16 e, int16 colorMin, int16 colorMax)
|
||||
void Scumm::createSpecialPalette(int16 a, int16 b, int16 c, int16 d, int16 e, int16 colorMin,
|
||||
int16 colorMax)
|
||||
{
|
||||
byte *palPtr;
|
||||
byte *curPtr;
|
||||
@ -2708,34 +2693,35 @@ void Scumm::createSpecialPalette(int16 a, int16 b, int16 c, int16 d, int16 e, in
|
||||
|
||||
palPtr = getPalettePtr();
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
_proc_special_palette[i]=i;
|
||||
for (i = 0; i < 256; i++)
|
||||
_proc_special_palette[i] = i;
|
||||
|
||||
curPtr = palPtr + colorMin*3;
|
||||
curPtr = palPtr + colorMin * 3;
|
||||
|
||||
for(i=colorMin;i<colorMax;i++) {
|
||||
readComp1=*(curPtr++);
|
||||
readComp2=*(curPtr++);
|
||||
readComp3=*(curPtr++);
|
||||
for (i = colorMin; i < colorMax; i++) {
|
||||
readComp1 = *(curPtr++);
|
||||
readComp2 = *(curPtr++);
|
||||
readComp3 = *(curPtr++);
|
||||
|
||||
colorComp1=((readComp1)*c)>>8;
|
||||
colorComp2=((readComp2)*d)>>8;
|
||||
colorComp3=((readComp3)*e)>>8;
|
||||
colorComp1 = ((readComp1) * c) >> 8;
|
||||
colorComp2 = ((readComp2) * d) >> 8;
|
||||
colorComp3 = ((readComp3) * e) >> 8;
|
||||
|
||||
searchPtr = palPtr;
|
||||
bestResult = 32000;
|
||||
currentIndex = 0;
|
||||
|
||||
for(j=a;j<b;j++) {
|
||||
for (j = a; j < b; j++) {
|
||||
searchComp1 = (*searchPtr++);
|
||||
searchComp2 = (*searchPtr++);
|
||||
searchComp3 = (*searchPtr++);
|
||||
|
||||
currentResult = abs(searchComp1-colorComp1) + abs(searchComp2-colorComp2) + abs(searchComp3-colorComp3);
|
||||
currentResult =
|
||||
abs(searchComp1 - colorComp1) + abs(searchComp2 - colorComp2) + abs(searchComp3 - colorComp3);
|
||||
|
||||
if(currentResult<bestResult) {
|
||||
_proc_special_palette[i]=currentIndex;
|
||||
bestResult=currentResult;
|
||||
if (currentResult < bestResult) {
|
||||
_proc_special_palette[i] = currentIndex;
|
||||
bestResult = currentResult;
|
||||
}
|
||||
currentIndex++;
|
||||
}
|
||||
|
145
gui.cpp
145
gui.cpp
@ -66,16 +66,16 @@ enum {
|
||||
GWF_CLEARBG = 2,
|
||||
GWF_PARENT = 4,
|
||||
GWF_DELAY = 8,
|
||||
GWF_DEFAULT = GWF_BORDER|GWF_CLEARBG,
|
||||
GWF_BUTTON = GWF_BORDER|GWF_CLEARBG|GWF_DELAY
|
||||
GWF_DEFAULT = GWF_BORDER | GWF_CLEARBG,
|
||||
GWF_BUTTON = GWF_BORDER | GWF_CLEARBG | GWF_DELAY
|
||||
};
|
||||
|
||||
struct GuiWidget {
|
||||
byte _type;
|
||||
byte _page;
|
||||
byte _flags;
|
||||
int16 _x,_y;
|
||||
uint16 _w,_h;
|
||||
int16 _x, _y;
|
||||
uint16 _w, _h;
|
||||
uint16 _id;
|
||||
byte _string_number;
|
||||
uint8 _hotkey;
|
||||
@ -138,43 +138,48 @@ const GuiWidget launcher_dialog[] = {
|
||||
};
|
||||
|
||||
const GuiWidget keys_dialog[] = {
|
||||
{GUI_STAT, 0xFF, GWF_DEFAULT, 30, 10, 260, 130, 0, 0 },
|
||||
{GUI_STAT, 0xFF, GWF_DEFAULT, 30, 10, 260, 130, 0, 0},
|
||||
|
||||
// First action
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10, 15, 15, 10, 3}, // CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10, 15, 15, 11, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10, 15, 15, 10, 3}, // CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10, 15, 15, 11, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 11 + 33 + 10, 10 + 10, 100, 15, 100, 1},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 3, 100, 15, 1, 1},
|
||||
|
||||
//Second action
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5, 15, 15, 20, 3}, // CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5, 15, 15, 21, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5, 15, 15, 20, 3}, // CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5, 15, 15, 21, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5, 100, 15, 101, 2},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 3, 100, 15, 2, 2},
|
||||
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 3, 100, 15, 2, 2},
|
||||
|
||||
//Third action
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 30, 3},// CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 31, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 30, 3}, // CUSTOMTEXT_PLUS
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5, 15, 15, 31, 4}, // CUSTOMTEXT_MINUS
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5, 100, 15, 102, 3},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 3, 100, 15, 3, 3},
|
||||
|
||||
//Fourth action
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 40, 3},
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 41, 4},
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 103, 4},
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15,
|
||||
103, 4},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 4, 4},
|
||||
|
||||
//Fifth action
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 50, 3},
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15, 51, 4},
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 100, 15, 104, 5},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100, 15, 5, 5},
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 11, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15,
|
||||
50, 3},
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 30 + 33, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5, 15, 15,
|
||||
51, 4},
|
||||
{GUI_ACTIONTEXT, 0x01, GWF_BUTTON, 30 + 10 + 33 + 10, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5,
|
||||
100, 15, 104, 5},
|
||||
{GUI_KEYTEXT, 0x01, 0, 30 + 11 + 33 + 120, 10 + 10 + 15 + 5 + 15 + 5 + 15 + 5 + 15 + 5 + 3, 100,
|
||||
15, 5, 5},
|
||||
|
||||
//OK
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 60, 10 + 106, 54, 16, 60, 9 },
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 60, 10 + 106, 54, 16, 60, 9},
|
||||
//Previous-Next
|
||||
{GUI_NEXTTEXT, 0x01, GWF_BUTTON, 30 + 120, 10 + 106, 54, 16, 61, 0 },
|
||||
{0,0,0,0,0,0,0,0,0}
|
||||
{GUI_NEXTTEXT, 0x01, GWF_BUTTON, 30 + 120, 10 + 106, 54, 16, 61, 0},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
const GuiWidget about_dialog[] = {
|
||||
@ -182,8 +187,8 @@ const GuiWidget about_dialog[] = {
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 68, 20 + 10 + 15 + 5, 160, 15, 0, 9}, // Build
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 10, 20 + 10 + 15 + 5 + 15, 240, 15, 0, 10}, // ScummVM Url
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 75, 20 + 10 + 15 + 5 + 15 + 15 + 15, 150, 15, 0, 11}, // Lucasarts
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 110, 20 + 10 + 15 + 5 + 15 + 15 + 15 + 15, 40, 15, 0, 21}, // Except:
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 25, 20 + 100, 210, 15, 0, 22}, // Adventuresoft
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 110, 20 + 10 + 15 + 5 + 15 + 15 + 15 + 15, 40, 15, 0, 21}, // Except:
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 30 + 25, 20 + 100, 210, 15, 0, 22}, // Adventuresoft
|
||||
{GUI_SCROLLTEXT, 0x01, 0, 30 + 95, 20 + 10, 100, 15, 0},
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 30 + 100, 20 + 112, 54, 16, 40, 9},
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
@ -194,18 +199,18 @@ const GuiWidget options_dialog[] = {
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10, 40, 15, 1, 5, 'S'}, // Sound
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30, 80 + 10, 40, 15, 2, 6, 'K'}, // Keys
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10 + 40 + 30 + 40 + 30, 80 + 10, 40, 15, 3, 7, 'A'}, // About
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10 + 15 + 10, 40, 15, 4, 18, 'M'}, // Misc
|
||||
{GUI_CUSTOMTEXT, 0x01, GWF_BUTTON, 50 + 10, 80 + 10 + 15 + 10, 40, 15, 4, 18, 'M'}, // Misc
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
const GuiWidget misc_dialog[] = {
|
||||
{GUI_STAT, 0xFF, GWF_DEFAULT, 50, 80, 210, 65, 0, 0},
|
||||
{GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6, 14, 14, 1, 0, 'S'}, // checkbox for subtitles
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10, 140, 15, 0, 19}, // "Show speech subtitles"
|
||||
{GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6 + 16, 14, 14, 5, 0, 'A'}, // checkbox for amiga pallete
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10 + 15, 140, 15, 0, 20}, // "Amiga pallete conversion"
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20, 80 + 10 + 15 + 20, 54, 16, 3, 9, 13}, // ok
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20 + 80, 80 + 10 + 15 + 20, 54, 16, 4, 7}, // cancel
|
||||
{GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6, 14, 14, 1, 0, 'S'}, // checkbox for subtitles
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10, 140, 15, 0, 19}, // "Show speech subtitles"
|
||||
{GUI_CHECKBOX, 0x01, GWF_DEFAULT, 50 + 10, 80 + 6 + 16, 14, 14, 5, 0, 'A'}, // checkbox for amiga pallete
|
||||
{GUI_CUSTOMTEXT, 0x01, 0, 50 + 10 + 20, 80 + 10 + 15, 140, 15, 0, 20}, // "Amiga pallete conversion"
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20, 80 + 10 + 15 + 20, 54, 16, 3, 9, 13}, // ok
|
||||
{GUI_RESTEXT, 0x01, GWF_BUTTON, 50 + 10 + 20 + 80, 80 + 10 + 15 + 20, 54, 16, 4, 7}, // cancel
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
};
|
||||
|
||||
@ -232,10 +237,10 @@ const GuiWidget save_load_dialog[] = {
|
||||
{GUI_RESTEXT, 0x04, 0, 10, 7, 240, 16, 0, 3}, /* Name your SAVE game */
|
||||
|
||||
{GUI_STAT, 0xFF, GWF_DEFAULT, 6, 20, 170, 96, 0, 0},
|
||||
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 24, 16, 40, 0, 0}, /* Up (dummy) */
|
||||
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 72, 16, 40, 0, 1}, /* Down (dummy) */
|
||||
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 24, 16, 40, 1, 0}, /* Up */
|
||||
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 72, 16, 40, 2, 1}, /* Down */
|
||||
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 24, 16, 40, 0, 0}, /* Up (dummy) */
|
||||
{GUI_UPDOWNARROW, 0x01, GWF_BUTTON, 180, 72, 16, 40, 0, 1}, /* Down (dummy) */
|
||||
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 24, 16, 40, 1, 0}, /* Up */
|
||||
{GUI_UPDOWNARROW, 0xFE, GWF_BUTTON, 180, 72, 16, 40, 2, 1}, /* Down */
|
||||
|
||||
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 24, 160, 10, 20, 0},
|
||||
{GUI_RESTEXT, 0x06, GWF_CLEARBG, 10, 34, 160, 10, 21, 0},
|
||||
@ -326,8 +331,8 @@ void Gui::drawChar(const char str, int xx, int yy)
|
||||
|
||||
byte *ptr = getBasePtr(xx, yy);
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
for (y = 0; y < 8; y++) {
|
||||
for (x = 0; x < 8; x++) {
|
||||
unsigned char color;
|
||||
@ -344,8 +349,7 @@ void Gui::drawChar(const char str, int xx, int yy)
|
||||
_color = tempc;
|
||||
|
||||
}
|
||||
void Gui::drawString(const char *str, int x, int y, int w, byte color,
|
||||
bool center)
|
||||
void Gui::drawString(const char *str, int x, int y, int w, byte color, bool center)
|
||||
{
|
||||
StringTab *st = &_s->string[5];
|
||||
st->charset = 1;
|
||||
@ -364,7 +368,7 @@ void Gui::drawString(const char *str, int x, int y, int w, byte color,
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::drawWidget(const GuiWidget * w)
|
||||
void Gui::drawWidget(const GuiWidget *w)
|
||||
{
|
||||
const char *s;
|
||||
int x, y;
|
||||
@ -410,12 +414,10 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||
break;
|
||||
#ifdef _WIN32_WCE
|
||||
case GUI_KEYTEXT:
|
||||
strcpy(text,
|
||||
getGAPIKeyName(getAction((_current_page * 5) + w->_string_number - 1)->action_key));
|
||||
strcpy(text, getGAPIKeyName(getAction((_current_page * 5) + w->_string_number - 1)->action_key));
|
||||
break;
|
||||
case GUI_ACTIONTEXT:
|
||||
strcpy(text,
|
||||
getActionName(getAction((_current_page * 5) + w->_string_number - 1)->action_type));
|
||||
strcpy(text, getActionName(getAction((_current_page * 5) + w->_string_number - 1)->action_type));
|
||||
break;
|
||||
case GUI_NEXTTEXT:
|
||||
if (_current_page == 0)
|
||||
@ -429,9 +431,7 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||
|
||||
if (*text) {
|
||||
drawString(text, x + _parentX, y + _parentY, w->_w,
|
||||
(_clickWidget
|
||||
&& _clickWidget == w->_id) ? _textcolorhi : _textcolor,
|
||||
false);
|
||||
(_clickWidget && _clickWidget == w->_id) ? _textcolorhi : _textcolor, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -454,8 +454,8 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||
}
|
||||
|
||||
// Center the image
|
||||
x += w->_w/2 - IMG_SIZE/2;
|
||||
y += w->_h/2 - IMG_SIZE/2;
|
||||
x += w->_w / 2 - IMG_SIZE / 2;
|
||||
y += w->_h / 2 - IMG_SIZE / 2;
|
||||
if (w->_flags & GWF_BORDER) {
|
||||
x -= 4;
|
||||
y -= 4;
|
||||
@ -464,7 +464,7 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||
byte *ptr = getBasePtr(x, y);
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
|
||||
// If the checkbox is checked, or this is not a checkbox, draw the image
|
||||
if ((getCheckboxChecked(w->_id) == true) || (w->_type != GUI_CHECKBOX)) {
|
||||
for (int y2 = 0; y2 < IMG_SIZE; y2++) {
|
||||
@ -482,7 +482,7 @@ void Gui::drawWidget(const GuiWidget * w)
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::widgetClear(const GuiWidget * wid)
|
||||
void Gui::widgetClear(const GuiWidget *wid)
|
||||
{
|
||||
int x = wid->_x;
|
||||
int y = wid->_y;
|
||||
@ -494,8 +494,7 @@ void Gui::widgetClear(const GuiWidget * wid)
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
_s->setVirtscreenDirty(_vs, x + _parentX, y + _parentY, x + _parentX + w,
|
||||
y + _parentY + h);
|
||||
_s->setVirtscreenDirty(_vs, x + _parentX, y + _parentY, x + _parentX + w, y + _parentY + h);
|
||||
|
||||
if (wid->_flags & GWF_BORDER) {
|
||||
// Inset by 1 pixel in all directions
|
||||
@ -511,12 +510,13 @@ void Gui::widgetClear(const GuiWidget * wid)
|
||||
}
|
||||
}
|
||||
|
||||
void Gui::widgetBorder(const GuiWidget * w)
|
||||
void Gui::widgetBorder(const GuiWidget *w)
|
||||
{
|
||||
box(w->_x, w->_y, w->_w, w->_h);
|
||||
}
|
||||
|
||||
void Gui::box(int x, int y, int width, int height) {
|
||||
void Gui::box(int x, int y, int width, int height)
|
||||
{
|
||||
hline(x + 1, y, x + width - 2, _color);
|
||||
hline(x, y + 1, x + width - 1, _color);
|
||||
vline(x, y + 1, y + height - 2, _color);
|
||||
@ -538,18 +538,18 @@ byte *Gui::getBasePtr(int x, int y)
|
||||
return NULL;
|
||||
|
||||
return _vs->screenPtr + x + (y - _vs->topline) * 320 +
|
||||
_s->_screenStartStrip * 8 + (_s->camera._cur.y - 100)*320;
|
||||
_s->_screenStartStrip * 8 + (_s->camera._cur.y - 100) * 320;
|
||||
}
|
||||
|
||||
void Gui::line(int x, int y, int x2, int y2, byte color)
|
||||
{
|
||||
byte *ptr;
|
||||
|
||||
|
||||
if (x2 < x)
|
||||
x2 ^= x ^= x2 ^= x; // Swap x2 and x
|
||||
x2 ^= x ^= x2 ^= x; // Swap x2 and x
|
||||
|
||||
if (y2 < y)
|
||||
y2 ^= y ^= y2 ^= y; // Swap y2 and y
|
||||
y2 ^= y ^= y2 ^= y; // Swap y2 and y
|
||||
|
||||
ptr = getBasePtr(x, y);
|
||||
|
||||
@ -601,7 +601,7 @@ void Gui::handleSoundDialogCommand(int cmd)
|
||||
_s->_sound_volume_master = _gui_variables[0]; // Master
|
||||
_s->_sound_volume_music = _gui_variables[1]; // Music
|
||||
_s->_sound_volume_sfx = _gui_variables[2]; // SFX
|
||||
|
||||
|
||||
IMuse *imuse = _s->_imuse;
|
||||
imuse->set_music_volume(_s->_sound_volume_music);
|
||||
imuse->set_master_volume(_s->_sound_volume_master);
|
||||
@ -700,9 +700,9 @@ void Gui::handleMiscDialogCommand(int cmd)
|
||||
|
||||
// Amiga pallete conversion checkbox
|
||||
if (getCheckboxChecked(5))
|
||||
_s->_features = _s->_features | GF_AMIGA;
|
||||
_s->_features = _s->_features | GF_AMIGA;
|
||||
else
|
||||
_s->_features = _s->_features & ~GF_AMIGA;
|
||||
_s->_features = _s->_features & ~GF_AMIGA;
|
||||
_s->_fullRedraw = true;
|
||||
}
|
||||
close();
|
||||
@ -741,7 +741,6 @@ void Gui::handleKeysDialogCommand(int cmd)
|
||||
draw(0, 200);
|
||||
return;
|
||||
}
|
||||
|
||||
#else
|
||||
close();
|
||||
#endif
|
||||
@ -804,7 +803,7 @@ void Gui::handleCommand(int cmd)
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// If we get here, it's the SAVELOAD_DIALOG
|
||||
|
||||
switch (cmd) {
|
||||
@ -820,9 +819,9 @@ void Gui::handleCommand(int cmd)
|
||||
getSavegameNames(_slotIndex + 9);
|
||||
draw(20, 28);
|
||||
return;
|
||||
case 3: /* save button */
|
||||
case 3: /* save button */
|
||||
_cur_page = 2;
|
||||
getSavegameNames(1); /* Start at 1, since slot 0 is reserved for autosave */
|
||||
getSavegameNames(1); /* Start at 1, since slot 0 is reserved for autosave */
|
||||
draw(0, 100);
|
||||
return;
|
||||
case 4: /* load button */
|
||||
@ -847,8 +846,7 @@ void Gui::handleCommand(int cmd)
|
||||
_s->_saveLoadSlot = lastEdit + _slotIndex;
|
||||
_s->_saveLoadCompatible = false;
|
||||
_s->_saveLoadFlag = 1;
|
||||
memcpy(_s->_saveLoadName, game_names[lastEdit],
|
||||
sizeof(_s->_saveLoadName));
|
||||
memcpy(_s->_saveLoadName, game_names[lastEdit], sizeof(_s->_saveLoadName));
|
||||
close();
|
||||
return;
|
||||
case 9: /* options button */
|
||||
@ -889,7 +887,7 @@ const char *Gui::queryString(int stringno, int id)
|
||||
static char namebuf[64];
|
||||
char *result;
|
||||
int string;
|
||||
|
||||
|
||||
if (id >= 20 && id <= 28) {
|
||||
// Save game names
|
||||
sprintf(namebuf, "%2d. %s", id - 20 + _slotIndex, game_names[id - 20]);
|
||||
@ -1008,7 +1006,7 @@ void Gui::setCheckbox(bool state, int id)
|
||||
|
||||
void Gui::clearCheckboxes()
|
||||
{
|
||||
for (int id = 0; id <= 100; id++){
|
||||
for (int id = 0; id <= 100; id++) {
|
||||
_cbox_checked[id] = false;
|
||||
}
|
||||
}
|
||||
@ -1018,7 +1016,7 @@ void Gui::init(Scumm *s)
|
||||
/* Default GUI colors */
|
||||
_bgcolor = 0;
|
||||
_color = 0;
|
||||
_textcolor = 8; // 15 is nice
|
||||
_textcolor = 8; // 15 is nice
|
||||
_textcolorhi = 15;
|
||||
_shadowcolor = 0;
|
||||
_s = s;
|
||||
@ -1030,7 +1028,7 @@ void Gui::loop()
|
||||
{
|
||||
if (_active && !_inited) {
|
||||
_inited = true;
|
||||
draw(0, 200); // was 100
|
||||
draw(0, 200); // was 100
|
||||
_old_soundsPaused = _s->_soundsPaused;
|
||||
_s->pauseSounds(true);
|
||||
|
||||
@ -1102,7 +1100,6 @@ void Gui::close()
|
||||
draw_keyboard = false;
|
||||
toolbar_drawn = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1113,7 +1110,7 @@ void Gui::checkHotKey(int keycode)
|
||||
const GuiWidget *w = _widgets[i];
|
||||
if (w) {
|
||||
while (w->_type != GUI_NONE) {
|
||||
|
||||
|
||||
// This rubbish is needed because the current page is 0 when really it should be 1
|
||||
if (_cur_page == 0)
|
||||
page = 1;
|
||||
@ -1210,4 +1207,4 @@ void Gui::loop()
|
||||
_s->drawDirtyScreenParts();
|
||||
_s->_mouseButStat = 0;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
255
insane.cpp
255
insane.cpp
@ -32,8 +32,7 @@
|
||||
|
||||
void invalidblock(uint32 tag)
|
||||
{
|
||||
error("Encountered invalid block %c%c%c%c", tag >> 24, tag >> 16, tag >> 8,
|
||||
tag);
|
||||
error("Encountered invalid block %c%c%c%c", tag >> 24, tag >> 16, tag >> 8, tag);
|
||||
}
|
||||
|
||||
int _frameChanged;
|
||||
@ -74,13 +73,11 @@ void SmushPlayer::openFile(byte *fileName)
|
||||
{
|
||||
byte buf[100];
|
||||
|
||||
sprintf((char *)buf, "%sVIDEO/%s", (char *)sm->_gameDataPath,
|
||||
(char *)fileName);
|
||||
sprintf((char *)buf, "%sVIDEO/%s", (char *)sm->_gameDataPath, (char *)fileName);
|
||||
_in = fopen((char *)buf, "rb");
|
||||
|
||||
if (_in == NULL) {
|
||||
sprintf((char *)buf, "%svideo/%s", (char *)sm->_gameDataPath,
|
||||
(char *)fileName);
|
||||
sprintf((char *)buf, "%svideo/%s", (char *)sm->_gameDataPath, (char *)fileName);
|
||||
_in = fopen((char *)buf, "rb");
|
||||
|
||||
}
|
||||
@ -132,17 +129,18 @@ void SmushPlayer::parseAHDR()
|
||||
}
|
||||
|
||||
|
||||
void SmushPlayer::parseIACT() {
|
||||
void SmushPlayer::parseIACT()
|
||||
{
|
||||
unsigned int pos, bpos, tag, sublen, subpos, trk, idx, flags;
|
||||
bool new_mixer = false;
|
||||
byte * buf;
|
||||
byte *buf;
|
||||
|
||||
flags = SoundMixer::FLAG_AUTOFREE;
|
||||
|
||||
pos = 0;
|
||||
pos += 6;
|
||||
|
||||
trk = READ_LE_UINT32(_cur + pos); /* FIXME: is this correct ? */
|
||||
trk = READ_LE_UINT32(_cur + pos); /* FIXME: is this correct ? */
|
||||
pos += 4;
|
||||
|
||||
for (idx = 0; idx < MAX_STREAMER; idx++) {
|
||||
@ -151,9 +149,8 @@ void SmushPlayer::parseIACT() {
|
||||
}
|
||||
|
||||
if (idx == MAX_STREAMER) {
|
||||
for (idx = 0; idx < MAX_STREAMER; idx++) {
|
||||
if (_imusTrk[idx] == 0 &&
|
||||
g_scumm->_mixer->_channels[idx] == NULL) {
|
||||
for (idx = 0; idx < MAX_STREAMER; idx++) {
|
||||
if (_imusTrk[idx] == 0 && g_scumm->_mixer->_channels[idx] == NULL) {
|
||||
_imusTrk[idx] = trk;
|
||||
_imusSize[idx] = 0;
|
||||
new_mixer = true;
|
||||
@ -167,7 +164,7 @@ void SmushPlayer::parseIACT() {
|
||||
return;
|
||||
}
|
||||
|
||||
pos += 8; /* FIXME: what are these ? */
|
||||
pos += 8; /* FIXME: what are these ? */
|
||||
|
||||
while (pos < _frmeSize) {
|
||||
|
||||
@ -185,15 +182,13 @@ void SmushPlayer::parseIACT() {
|
||||
_imusSubSize[idx] = READ_BE_UINT32(_cur + pos);
|
||||
pos += 4;
|
||||
_imusSize[idx] -= 8;
|
||||
debug(3, "trk %d: tag '%4s' size %x",
|
||||
trk, _cur + pos - 8, _imusSubSize[idx]);
|
||||
debug(3, "trk %d: tag '%4s' size %x", trk, _cur + pos - 8, _imusSubSize[idx]);
|
||||
}
|
||||
|
||||
sublen = _imusSubSize[idx] < (_frmeSize - pos) ?
|
||||
_imusSubSize[idx] : (_frmeSize - pos);
|
||||
|
||||
sublen = _imusSubSize[idx] < (_frmeSize - pos) ? _imusSubSize[idx] : (_frmeSize - pos);
|
||||
|
||||
switch (_imusSubTag[idx]) {
|
||||
case 'MAP ' :
|
||||
case 'MAP ':
|
||||
tag = READ_BE_UINT32(_cur + pos);
|
||||
if (tag != 'FRMT')
|
||||
error("trk %d: no FRMT section");
|
||||
@ -202,27 +197,27 @@ void SmushPlayer::parseIACT() {
|
||||
_imusChan[idx] = READ_BE_UINT32(_cur + pos + 24);
|
||||
_imusPos[idx] = 0;
|
||||
break;
|
||||
case 'DATA' :
|
||||
case 'DATA':
|
||||
switch (_imusCodec[idx]) {
|
||||
case 8 :
|
||||
case 8:
|
||||
if (_imusChan[idx] == 2)
|
||||
flags |= SoundMixer::FLAG_STEREO;
|
||||
flags |= SoundMixer::FLAG_UNSIGNED;
|
||||
buf = (byte *) malloc(sublen);
|
||||
buf = (byte *)malloc(sublen);
|
||||
memcpy(buf, _cur + pos, sublen);
|
||||
bpos = sublen;
|
||||
break;
|
||||
case 12 :
|
||||
case 12:
|
||||
if (_imusChan[idx] == 2)
|
||||
flags |= SoundMixer::FLAG_STEREO;
|
||||
flags |= SoundMixer::FLAG_16BITS;
|
||||
buf = (byte *) malloc(2 * sublen);
|
||||
buf = (byte *)malloc(2 * sublen);
|
||||
|
||||
bpos = 0;
|
||||
subpos = 0;
|
||||
|
||||
while (subpos < sublen) {
|
||||
|
||||
|
||||
while (_imusPos[idx] < 3 && subpos < sublen) {
|
||||
_imusData[idx][_imusPos[idx]] = _cur[pos + subpos];
|
||||
_imusPos[idx]++;
|
||||
@ -249,13 +244,12 @@ void SmushPlayer::parseIACT() {
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
error("trk %d: unknown iMUS codec %d",
|
||||
trk, _imusCodec[idx]);
|
||||
default:
|
||||
error("trk %d: unknown iMUS codec %d", trk, _imusCodec[idx]);
|
||||
}
|
||||
|
||||
debug(3, "trk %d: iMUSE play part, len 0x%x rate %d remain 0x%x",
|
||||
trk, bpos, _imusRate[idx], _imusSubSize[idx]);
|
||||
trk, bpos, _imusRate[idx], _imusSubSize[idx]);
|
||||
|
||||
if (new_mixer) {
|
||||
g_scumm->_mixer->play_stream(NULL, idx, buf, bpos, _imusRate[idx], flags);
|
||||
@ -267,16 +261,15 @@ void SmushPlayer::parseIACT() {
|
||||
with signed/unsigned issues */
|
||||
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
error("trk %d: unknown tag inside iMUS %08x [%c%c%c%c]",
|
||||
trk, _imusSubTag[idx], _imusSubTag[idx] >> 24,
|
||||
_imusSubTag[idx] >> 16, _imusSubTag[idx] >> 8,
|
||||
_imusSubTag[idx]);
|
||||
trk, _imusSubTag[idx], _imusSubTag[idx] >> 24,
|
||||
_imusSubTag[idx] >> 16, _imusSubTag[idx] >> 8, _imusSubTag[idx]);
|
||||
}
|
||||
|
||||
_imusSubSize[idx] -= sublen;
|
||||
_imusSize[idx] -= sublen;
|
||||
pos += sublen;
|
||||
_imusSize[idx] -= sublen;
|
||||
pos += sublen;
|
||||
|
||||
if (_imusSubSize[idx] == 0 && _imusSubTag[idx] == 'DATA') {
|
||||
_imusTrk[idx] = 0;
|
||||
@ -373,14 +366,13 @@ void codec37_bompdepack(byte *dst, byte *src, int len)
|
||||
} while (len -= num);
|
||||
}
|
||||
|
||||
void codec37_proc4(byte *dst, byte *src, int next_offs, int bw, int bh,
|
||||
int pitch, int16 * table)
|
||||
void codec37_proc4(byte *dst, byte *src, int next_offs, int bw, int bh, int pitch, int16 *table)
|
||||
{
|
||||
byte code, *tmp;
|
||||
int i;
|
||||
uint32 t;
|
||||
|
||||
if (pitch != 320) {
|
||||
if (pitch != 320) {
|
||||
warning("invalid pitch");
|
||||
return;
|
||||
}
|
||||
@ -390,30 +382,30 @@ void codec37_proc4(byte *dst, byte *src, int next_offs, int bw, int bh,
|
||||
do {
|
||||
code = *src++;
|
||||
if (code == 0xFD) {
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
src += 1;
|
||||
dst += 4;
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
src += 1;
|
||||
dst += 4;
|
||||
} else if (code == 0xFE) {
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
t = src[1];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
t = src[2];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
t = src[3];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
t = src[1];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
t = src[2];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
t = src[3];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
src += 4;
|
||||
dst += 4;
|
||||
} else if (code == 0xFF) {
|
||||
} else if (code == 0xFF) {
|
||||
*(uint32 *)(dst + 0) = ((uint32 *)src)[0];
|
||||
*(uint32 *)(dst + 320) = ((uint32 *)src)[1];
|
||||
*(uint32 *)(dst + 320 * 2) = ((uint32 *)src)[2];
|
||||
@ -421,20 +413,20 @@ void codec37_proc4(byte *dst, byte *src, int next_offs, int bw, int bh,
|
||||
src += 16;
|
||||
dst += 4;
|
||||
} else if (code == 0x00) {
|
||||
uint16 count = src[0] + 1;
|
||||
src += 1;
|
||||
for (uint16 l = 0; l < count; l++) {
|
||||
tmp = dst + next_offs;
|
||||
uint16 count = src[0] + 1;
|
||||
src += 1;
|
||||
for (uint16 l = 0; l < count; l++) {
|
||||
tmp = dst + next_offs;
|
||||
*(uint32 *)(dst + 0) = *(uint32 *)(tmp);
|
||||
*(uint32 *)(dst + 320) = *(uint32 *)(tmp + 320);
|
||||
*(uint32 *)(dst + 320) = *(uint32 *)(tmp + 320);
|
||||
*(uint32 *)(dst + 320 * 2) = *(uint32 *)(tmp + 320 * 2);
|
||||
*(uint32 *)(dst + 320 * 3) = *(uint32 *)(tmp + 320 * 3);
|
||||
dst += 4;
|
||||
i--;
|
||||
if (i == 0) {
|
||||
i = bw;
|
||||
dst += 320 * 4 - 320;
|
||||
bh--;
|
||||
i = bw;
|
||||
dst += 320 * 4 - 320;
|
||||
bh--;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
@ -446,17 +438,20 @@ void codec37_proc4(byte *dst, byte *src, int next_offs, int bw, int bh,
|
||||
*(uint32 *)(dst + 320 * 3) = *(uint32 *)(tmp + 320 * 3);
|
||||
dst += 4;
|
||||
}
|
||||
if (i <= 0) break;
|
||||
if (bh <= 0) break;
|
||||
if (i <= 0)
|
||||
break;
|
||||
if (bh <= 0)
|
||||
break;
|
||||
} while (--i);
|
||||
dst += 320 * 4 - 320;
|
||||
if (bh <= 0) break;
|
||||
if (bh <= 0)
|
||||
break;
|
||||
} while (--bh);
|
||||
}
|
||||
|
||||
|
||||
void codec37_proc5(int game, byte *dst, byte *src, int next_offs, int bw, int bh,
|
||||
int pitch, int16 * table)
|
||||
int pitch, int16 *table)
|
||||
{
|
||||
byte code, *tmp;
|
||||
int i;
|
||||
@ -474,30 +469,30 @@ void codec37_proc5(int game, byte *dst, byte *src, int next_offs, int bw, int bh
|
||||
|
||||
// FIXME: Full Throttle has different FD and FEs?
|
||||
if ((game == GID_DIG) && (code == 0xFD)) {
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
src += 1;
|
||||
dst += 4;
|
||||
} else if ((game == GID_DIG) && (code == 0xFE)) {
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
t = src[1];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
t = src[2];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
t = src[3];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
t = src[0];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 0) = t;
|
||||
t = src[1];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320) = t;
|
||||
t = src[2];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 2) = t;
|
||||
t = src[3];
|
||||
t += (t << 8) + (t << 16) + (t << 24);
|
||||
*(uint32 *)(dst + 320 * 3) = t;
|
||||
src += 4;
|
||||
dst += 4;
|
||||
} else if (code == 0xFF) {
|
||||
} else if (code == 0xFF) {
|
||||
*(uint32 *)(dst + 0) = ((uint32 *)src)[0];
|
||||
*(uint32 *)(dst + 320) = ((uint32 *)src)[1];
|
||||
*(uint32 *)(dst + 320 * 2) = ((uint32 *)src)[2];
|
||||
@ -632,8 +627,7 @@ void codec37_maketable(PersistentCodecData37 * pcd, int pitch, byte idx)
|
||||
|
||||
for (i = 0; i < 255; i++) {
|
||||
j = i + idx * 255;
|
||||
pcd->table1[i] =
|
||||
maketable_bytes[j * 2 + 1] * pitch + maketable_bytes[j * 2];
|
||||
pcd->table1[i] = maketable_bytes[j * 2 + 1] * pitch + maketable_bytes[j * 2];
|
||||
}
|
||||
}
|
||||
|
||||
@ -660,8 +654,7 @@ int codec37(int game, CodecData * cd, PersistentCodecData37 * pcd)
|
||||
curbuf = pcd->deltaBufs[pcd->curtable];
|
||||
memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf);
|
||||
size = *(uint32 *)(cd->src + 4);
|
||||
memset(curbuf + size, 0,
|
||||
pcd->deltaBuf + pcd->deltaSize - curbuf - size);
|
||||
memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size);
|
||||
memcpy(curbuf, cd->src + 16, size);
|
||||
break;
|
||||
}
|
||||
@ -675,8 +668,7 @@ int codec37(int game, CodecData * cd, PersistentCodecData37 * pcd)
|
||||
return (1);
|
||||
|
||||
memset(pcd->deltaBuf, 0, curbuf - pcd->deltaBuf);
|
||||
memset(curbuf + size, 0,
|
||||
pcd->deltaBuf + pcd->deltaSize - curbuf - size);
|
||||
memset(curbuf + size, 0, pcd->deltaBuf + pcd->deltaSize - curbuf - size);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -697,12 +689,12 @@ int codec37(int game, CodecData * cd, PersistentCodecData37 * pcd)
|
||||
}
|
||||
|
||||
codec37_proc5(game, pcd->deltaBufs[pcd->curtable], cd->src + 16,
|
||||
pcd->deltaBufs[pcd->curtable ^ 1] -
|
||||
pcd->deltaBufs[pcd->curtable], width_in_blocks,
|
||||
height_in_blocks, src_pitch, pcd->table1);
|
||||
pcd->deltaBufs[pcd->curtable ^ 1] -
|
||||
pcd->deltaBufs[pcd->curtable], width_in_blocks,
|
||||
height_in_blocks, src_pitch, pcd->table1);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
case 4:{
|
||||
uint16 number = *(uint16 *)(cd->src + 2);
|
||||
|
||||
@ -754,7 +746,7 @@ void codec37_init(PersistentCodecData37 * pcd, int width, int height)
|
||||
pcd->deltaBufs[0] = pcd->deltaBuf + 0x3E00;
|
||||
pcd->deltaBufs[1] = pcd->deltaBuf + width * height + 0xBA00;
|
||||
pcd->curtable = 0;
|
||||
pcd->table1 = (int16 *) calloc(255, sizeof(uint16));
|
||||
pcd->table1 = (int16 *)calloc(255, sizeof(uint16));
|
||||
}
|
||||
|
||||
void SmushPlayer::parseFOBJ()
|
||||
@ -786,14 +778,14 @@ void SmushPlayer::parseFOBJ()
|
||||
}
|
||||
}
|
||||
|
||||
void SmushPlayer::parsePSAD() // FIXME: Needs to append to
|
||||
{ // a sound buffer
|
||||
void SmushPlayer::parsePSAD() // FIXME: Needs to append to
|
||||
{ // a sound buffer
|
||||
unsigned int pos, sublen, tag, idx, trk;
|
||||
bool new_mixer = false;
|
||||
byte * buf;
|
||||
byte *buf;
|
||||
pos = 0;
|
||||
|
||||
trk = READ_LE_UINT16(_cur + pos); /* FIXME: is this correct ? */
|
||||
|
||||
trk = READ_LE_UINT16(_cur + pos); /* FIXME: is this correct ? */
|
||||
pos += 2;
|
||||
|
||||
for (idx = 0; idx < MAX_STREAMER; idx++) {
|
||||
@ -803,8 +795,7 @@ void SmushPlayer::parsePSAD() // FIXME: Needs to append to
|
||||
|
||||
if (idx == MAX_STREAMER) {
|
||||
for (idx = 0; idx < MAX_STREAMER; idx++) {
|
||||
if (_psadTrk[idx] == 0 &&
|
||||
g_scumm->_mixer->_channels[idx] == NULL) {
|
||||
if (_psadTrk[idx] == 0 && g_scumm->_mixer->_channels[idx] == NULL) {
|
||||
_psadTrk[idx] = trk;
|
||||
_saudSize[idx] = 0;
|
||||
new_mixer = true;
|
||||
@ -818,8 +809,8 @@ void SmushPlayer::parsePSAD() // FIXME: Needs to append to
|
||||
return;
|
||||
}
|
||||
|
||||
pos += 8; /* FIXME: what are these ? */
|
||||
|
||||
pos += 8; /* FIXME: what are these ? */
|
||||
|
||||
while (pos < _frmeSize) {
|
||||
|
||||
if (_saudSize[idx] == 0) {
|
||||
@ -830,52 +821,50 @@ void SmushPlayer::parsePSAD() // FIXME: Needs to append to
|
||||
_saudSize[idx] = READ_BE_UINT32(_cur + pos);
|
||||
pos += 4;
|
||||
}
|
||||
|
||||
|
||||
if (_saudSubSize[idx] == 0) {
|
||||
_saudSubTag[idx] = READ_BE_UINT32(_cur + pos);
|
||||
pos += 4;
|
||||
_saudSubSize[idx] = READ_BE_UINT32(_cur + pos);
|
||||
pos += 4;
|
||||
_saudSize[idx] -= 8;
|
||||
debug(3, "trk %d: tag '%4s' size %x",
|
||||
trk, _cur + pos - 8, _saudSubSize[idx]);
|
||||
debug(3, "trk %d: tag '%4s' size %x", trk, _cur + pos - 8, _saudSubSize[idx]);
|
||||
}
|
||||
|
||||
sublen = _saudSubSize[idx] < (_frmeSize - pos) ?
|
||||
_saudSubSize[idx] : (_frmeSize - pos);
|
||||
|
||||
sublen = _saudSubSize[idx] < (_frmeSize - pos) ? _saudSubSize[idx] : (_frmeSize - pos);
|
||||
|
||||
switch (_saudSubTag[idx]) {
|
||||
case 'STRK' :
|
||||
case 'STRK':
|
||||
/* FIXME: what is this stuff ? */
|
||||
_strkRate[idx] = 22050;
|
||||
break;
|
||||
case 'SDAT' :
|
||||
buf = (byte *) malloc(sublen);
|
||||
case 'SDAT':
|
||||
buf = (byte *)malloc(sublen);
|
||||
|
||||
memcpy(buf, _cur + pos, sublen);
|
||||
|
||||
debug(3, "trk %d: SDAT part len 0x%x rate %d",
|
||||
trk, sublen, _strkRate[idx]);
|
||||
|
||||
debug(3, "trk %d: SDAT part len 0x%x rate %d", trk, sublen, _strkRate[idx]);
|
||||
|
||||
if (new_mixer) {
|
||||
g_scumm->_mixer->play_stream(NULL, idx, buf, sublen, _strkRate[idx], SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
|
||||
g_scumm->_mixer->play_stream(NULL, idx, buf, sublen, _strkRate[idx],
|
||||
SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
|
||||
} else {
|
||||
g_scumm->_mixer->append(idx, buf, sublen,
|
||||
_strkRate[idx], SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
|
||||
g_scumm->_mixer->append(idx, buf, sublen,
|
||||
_strkRate[idx], SoundMixer::FLAG_UNSIGNED | SoundMixer::FLAG_AUTOFREE);
|
||||
}
|
||||
break;
|
||||
case 'SMRK' :
|
||||
case 'SMRK':
|
||||
_psadTrk[idx] = 0;
|
||||
break;
|
||||
case 'SHDR' :
|
||||
case 'SHDR':
|
||||
/* FIXME: what is this stuff ? */
|
||||
break;
|
||||
default :
|
||||
default:
|
||||
error("trk %d: unknown tag inside PSAD", trk);
|
||||
}
|
||||
_saudSubSize[idx] -= sublen;
|
||||
_saudSize[idx] -= sublen;
|
||||
pos += sublen;
|
||||
_saudSize[idx] -= sublen;
|
||||
pos += sublen;
|
||||
}
|
||||
}
|
||||
|
||||
@ -982,13 +971,13 @@ void SmushPlayer::setPalette()
|
||||
|
||||
byte *p = palette_colors;
|
||||
|
||||
|
||||
|
||||
|
||||
byte *data = _fluPalette;
|
||||
|
||||
|
||||
|
||||
for (i = 0; i != 256; i++, data += 3, p+=4) {
|
||||
for (i = 0; i != 256; i++, data += 3, p += 4) {
|
||||
|
||||
p[0] = data[0];
|
||||
|
||||
@ -1074,7 +1063,7 @@ void SmushPlayer::startVideo(short int arg, byte *videoFile)
|
||||
sm->_system->copy_rect(sm->_videoBuffer, 320, 0, 0, 320, 200);
|
||||
sm->_system->update_screen();
|
||||
sm->waitForTimer(60);
|
||||
|
||||
|
||||
//sm->delta = sm->_system->waitTick(sm->delta);
|
||||
}
|
||||
|
||||
|
264
resource.cpp
264
resource.cpp
@ -66,14 +66,11 @@ void Scumm::openRoom(int room)
|
||||
if (!(_features & GF_SMALL_HEADER)) {
|
||||
|
||||
if (_features & GF_AFTER_V7)
|
||||
sprintf(buf, "%s%s.la%d", _gameDataPath, _exe_name,
|
||||
room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
sprintf(buf, "%s%s.la%d", _gameDataPath, _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
else if (_features & GF_HUMONGOUS)
|
||||
sprintf(buf, "%s%s.he%.1d", _gameDataPath, _exe_name,
|
||||
room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
sprintf(buf, "%s%s.he%.1d", _gameDataPath, _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
else
|
||||
sprintf(buf, "%s%s.%.3d", _gameDataPath, _exe_name,
|
||||
room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
sprintf(buf, "%s%s.%.3d", _gameDataPath, _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
|
||||
_encbyte = (_features & GF_USE_KEY) ? 0x69 : 0;
|
||||
} else if (!(_features & GF_SMALL_NAMES)) {
|
||||
@ -86,8 +83,7 @@ void Scumm::openRoom(int room)
|
||||
askForDisk(buf);
|
||||
|
||||
} else {
|
||||
sprintf(buf, "%sdisk%.2d.lec", _gameDataPath,
|
||||
res.roomno[rtRoom][room]);
|
||||
sprintf(buf, "%sdisk%.2d.lec", _gameDataPath, res.roomno[rtRoom][room]);
|
||||
_encbyte = 0x69;
|
||||
}
|
||||
} else {
|
||||
@ -186,8 +182,10 @@ bool Scumm::openResourceFile(const char *filename)
|
||||
|
||||
_fileHandle = fileOpen(buf, 1);
|
||||
if (!_fileHandle) {
|
||||
char *e = buf;
|
||||
do *e = tolower(*e); while(*e++);
|
||||
char *e = buf;
|
||||
do
|
||||
*e = tolower(*e);
|
||||
while (*e++);
|
||||
_fileHandle = fileOpen(buf, 1);
|
||||
}
|
||||
|
||||
@ -269,8 +267,8 @@ void Scumm::readIndexFile()
|
||||
num = fileReadWordLE();
|
||||
assert(num == _numGlobalObjects);
|
||||
|
||||
if (_features & GF_AFTER_V8) { /* FIXME: Not sure.. */
|
||||
for (i=0; i<num; i++) {
|
||||
if (_features & GF_AFTER_V8) { /* FIXME: Not sure.. */
|
||||
for (i = 0; i < num; i++) {
|
||||
fileSeek(_fileHandle, 40, SEEK_CUR);
|
||||
_objectStateTable[i] = fileReadByte();
|
||||
_objectRoomTable[i] = fileReadByte();
|
||||
@ -309,8 +307,8 @@ void Scumm::readIndexFile()
|
||||
readResTypeList(rtRoom, MKID('ROOM'), "room");
|
||||
break;
|
||||
|
||||
case MKID('DRSC'): // FIXME: Verify
|
||||
readResTypeList(rtRoomScripts,MKID('RMSC'), "room script");
|
||||
case MKID('DRSC'): // FIXME: Verify
|
||||
readResTypeList(rtRoomScripts, MKID('RMSC'), "room script");
|
||||
break;
|
||||
|
||||
case MKID('DSCR'):
|
||||
@ -402,8 +400,7 @@ void Scumm::readResTypeList(int id, uint32 tag, const char *name)
|
||||
}
|
||||
|
||||
|
||||
void Scumm::allocResTypeData(int id, uint32 tag, int num, const char *name,
|
||||
int mode)
|
||||
void Scumm::allocResTypeData(int id, uint32 tag, int num, const char *name, int mode)
|
||||
{
|
||||
debug(9, "allocResTypeData(%s/%s,%x,%d,%d)", resTypeFromId(id), name, FROM_LE_32(tag), num, mode);
|
||||
assert(id >= 0 && id < (int)(sizeof(res.mode) / sizeof(res.mode[0])));
|
||||
@ -438,7 +435,7 @@ void Scumm::loadCharset(int no)
|
||||
|
||||
memset(_charsetData, 0, sizeof(_charsetData));
|
||||
|
||||
assert(no < (int) sizeof(_charsetData)/16);
|
||||
assert(no < (int)sizeof(_charsetData) / 16);
|
||||
checkRange(_maxCharsets - 1, 1, no, "Loading illegal charset %d");
|
||||
|
||||
// ensureResourceLoaded(6, no);
|
||||
@ -474,7 +471,7 @@ void Scumm::ensureResourceLoaded(int type, int i)
|
||||
|
||||
loadResource(type, i);
|
||||
|
||||
if (!(_features & GF_AFTER_V7) && !(_features & GF_SMALL_HEADER))
|
||||
if (!(_features & GF_AFTER_V7) && !(_features & GF_SMALL_HEADER))
|
||||
if (type == rtRoom && i == _roomResource)
|
||||
_vars[VAR_ROOM_FLAG] = 1;
|
||||
}
|
||||
@ -485,7 +482,7 @@ int Scumm::loadResource(int type, int idx)
|
||||
uint32 fileOffs;
|
||||
uint32 size, tag;
|
||||
|
||||
// debug(1, "loadResource(%s,%d)", resTypeFromId(type),idx);
|
||||
// debug(1, "loadResource(%s,%d)", resTypeFromId(type),idx);
|
||||
|
||||
if (type == rtCharset && (_features & GF_SMALL_HEADER)) {
|
||||
loadCharset(idx);
|
||||
@ -530,8 +527,7 @@ int Scumm::loadResource(int type, int idx)
|
||||
tag = fileReadDword();
|
||||
|
||||
if (tag != res.tags[type]) {
|
||||
error("%s %d not in room %d at %d+%d",
|
||||
res.name[type], type, roomNr, _fileOffset, fileOffs);
|
||||
error("%s %d not in room %d at %d+%d", res.name[type], type, roomNr, _fileOffset, fileOffs);
|
||||
}
|
||||
|
||||
size = fileReadDwordBE();
|
||||
@ -571,17 +567,14 @@ int Scumm::readSoundResource(int type, int idx)
|
||||
total_size = fileReadDwordBE();
|
||||
|
||||
debug(8, " basetag: %c%c%c%c, total_size=%d",
|
||||
(char)((basetag >> 24) & 0xff),
|
||||
(char)((basetag >> 16) & 0xff),
|
||||
(char)((basetag >> 8) & 0xff),
|
||||
(char)(basetag & 0xff),
|
||||
total_size);
|
||||
(char)((basetag >> 24) & 0xff),
|
||||
(char)((basetag >> 16) & 0xff),
|
||||
(char)((basetag >> 8) & 0xff), (char)(basetag & 0xff), total_size);
|
||||
|
||||
//if (_gameId == GID_SAMNMAX || _features & GF_AFTER_V7) {
|
||||
if (basetag == MKID('MIDI') || basetag == MKID('iMUS')) {
|
||||
fileSeek(_fileHandle, -8, SEEK_CUR);
|
||||
fileRead(_fileHandle, createResource(type, idx, total_size + 8),
|
||||
total_size + 8);
|
||||
fileRead(_fileHandle, createResource(type, idx, total_size + 8), total_size + 8);
|
||||
return 1;
|
||||
} else if (basetag == MKID('SOU ')) {
|
||||
best_pri = -1;
|
||||
@ -591,7 +584,7 @@ int Scumm::readSoundResource(int type, int idx)
|
||||
pos += size;
|
||||
|
||||
pri = -1;
|
||||
|
||||
|
||||
switch (tag) {
|
||||
case MKID('ADL '):
|
||||
if (_use_adlib)
|
||||
@ -616,12 +609,9 @@ int Scumm::readSoundResource(int type, int idx)
|
||||
}
|
||||
|
||||
debug(8, " tag: %c%c%c%c, total_size=%d, pri=%d",
|
||||
(char)((tag >> 24) & 0xff),
|
||||
(char)((tag >> 16) & 0xff),
|
||||
(char)((tag >> 8) & 0xff),
|
||||
(char)(tag & 0xff),
|
||||
size, pri);
|
||||
|
||||
(char)((tag >> 24) & 0xff),
|
||||
(char)((tag >> 16) & 0xff), (char)((tag >> 8) & 0xff), (char)(tag & 0xff), size, pri);
|
||||
|
||||
|
||||
if (pri > best_pri) {
|
||||
best_pri = pri;
|
||||
@ -646,52 +636,52 @@ int Scumm::readSoundResource(int type, int idx)
|
||||
} else if (basetag == MKID('Mac0')) {
|
||||
debug(1, "Found base tag Mac0 in sound %d, size %d", idx, total_size);
|
||||
debug(1, "It was at position %d", filePos(_fileHandle));
|
||||
|
||||
|
||||
/* Offset
|
||||
0x14, 0x1C, 0x20, 0x24 - offsets of channel 1/2/3/4 chunk-
|
||||
Each channel has tag "Chan", followed by its length. At the end
|
||||
of each chan follows either an empty "Done" chunk (length 0) or an
|
||||
empty "Loop" chunk. Maybe "Loop" indicates the song should be
|
||||
played forever?!?.
|
||||
|
||||
|
||||
There can be various different subchunks it seems. The
|
||||
following combinations appear in Monkey Island:
|
||||
100: ORGA, TROM, BASS,
|
||||
101: ORGA, SHAK, BASS,
|
||||
103: PIPE, PIPE, PIPE,
|
||||
104: VIBE, WHIS, BASS,
|
||||
108: ORGA, MARI, BASS,
|
||||
110: ORGA, SHAK, VIBE,
|
||||
111: MARI, SHAK, BASS,
|
||||
115: PLUC, SHAK, WHIS,
|
||||
100: ORGA, TROM, BASS,
|
||||
101: ORGA, SHAK, BASS,
|
||||
103: PIPE, PIPE, PIPE,
|
||||
104: VIBE, WHIS, BASS,
|
||||
108: ORGA, MARI, BASS,
|
||||
110: ORGA, SHAK, VIBE,
|
||||
111: MARI, SHAK, BASS,
|
||||
115: PLUC, SHAK, WHIS,
|
||||
One guess is that these are instrument names: Organ, Marimba, Whistle...
|
||||
Maybe there is a mapping table someplace? Maybe these are even mapped to
|
||||
Mac1 type "instruments" ?
|
||||
|
||||
|
||||
What follows are four byte "commands" it seems, like this (hex):
|
||||
01 68 4F 49
|
||||
01 68 00 40
|
||||
01 68 4F 49
|
||||
...
|
||||
01 68 00 40
|
||||
02 1C 5B 40
|
||||
00 B4 00 40
|
||||
...
|
||||
01 68 37 3C
|
||||
00 18 37 38
|
||||
04 20 3E 34
|
||||
01 68 4A 3C
|
||||
|
||||
01 68 4F 49
|
||||
01 68 00 40
|
||||
01 68 4F 49
|
||||
...
|
||||
01 68 00 40
|
||||
02 1C 5B 40
|
||||
00 B4 00 40
|
||||
...
|
||||
01 68 37 3C
|
||||
00 18 37 38
|
||||
04 20 3E 34
|
||||
01 68 4A 3C
|
||||
|
||||
More data:
|
||||
00 09 3E 10
|
||||
01 5F 00 40
|
||||
00 9C 36 40
|
||||
00 CC 00 40
|
||||
00 18 42 49
|
||||
00 18 45 3C
|
||||
01 29 4A 3C
|
||||
00 0F 00 40
|
||||
|
||||
00 09 3E 10
|
||||
01 5F 00 40
|
||||
00 9C 36 40
|
||||
00 CC 00 40
|
||||
00 18 42 49
|
||||
00 18 45 3C
|
||||
01 29 4A 3C
|
||||
00 0F 00 40
|
||||
|
||||
Maybe I am mistaken when I think it's four byte, some other parts
|
||||
seem to suggest it's 2 byte oriented, or even variable lenght...
|
||||
*/
|
||||
@ -717,8 +707,7 @@ int Scumm::readSoundResource(int type, int idx)
|
||||
fileRead(_fileHandle, createResource(type, idx, total_size), total_size - 8);
|
||||
return 1;
|
||||
} else {
|
||||
fprintf(stderr, "WARNING: Unrecognized base tag 0x%08lx in sound %d\n",
|
||||
basetag, idx);
|
||||
fprintf(stderr, "WARNING: Unrecognized base tag 0x%08lx in sound %d\n", basetag, idx);
|
||||
}
|
||||
res.roomoffs[type][idx] = 0xFFFFFFFF;
|
||||
return 0;
|
||||
@ -734,7 +723,7 @@ int Scumm::getResourceRoomNr(int type, int idx)
|
||||
byte *Scumm::getResourceAddress(int type, int idx)
|
||||
{
|
||||
byte *ptr;
|
||||
|
||||
|
||||
|
||||
CHECK_HEAP validateResource("getResourceAddress", type, idx);
|
||||
if (!res.address[type]) {
|
||||
@ -771,17 +760,18 @@ byte *Scumm::getStringAddress(int i)
|
||||
|
||||
|
||||
|
||||
byte *Scumm::getStringAddressVar(int i) {
|
||||
byte *Scumm::getStringAddressVar(int i)
|
||||
{
|
||||
byte *addr;
|
||||
|
||||
addr=getResourceAddress(rtString,_vars[i]);
|
||||
if(addr==NULL)
|
||||
error("NULL string var %d slot %d",i,_vars[i]);
|
||||
addr = getResourceAddress(rtString, _vars[i]);
|
||||
if (addr == NULL)
|
||||
error("NULL string var %d slot %d", i, _vars[i]);
|
||||
|
||||
if (_features & GF_NEW_OPCODES)
|
||||
return ((ArrayHeader *)addr)->data;
|
||||
return ((ArrayHeader *)addr)->data;
|
||||
|
||||
return(addr);
|
||||
return (addr);
|
||||
}
|
||||
|
||||
void Scumm::setResourceCounter(int type, int idx, byte flag)
|
||||
@ -797,8 +787,7 @@ byte *Scumm::createResource(int type, int idx, uint32 size)
|
||||
{
|
||||
byte *ptr;
|
||||
|
||||
CHECK_HEAP
|
||||
debug(9, "createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
|
||||
CHECK_HEAP debug(9, "createResource(%s,%d,%d)", resTypeFromId(type), idx, size);
|
||||
|
||||
validateResource("allocating", type, idx);
|
||||
nukeResource(type, idx);
|
||||
@ -832,7 +821,7 @@ void Scumm::nukeResource(int type, int idx)
|
||||
debug(9, "nukeResource(%s,%d)", resTypeFromId(type), idx);
|
||||
|
||||
CHECK_HEAP if (!res.address[type])
|
||||
return;
|
||||
return;
|
||||
|
||||
assert(idx >= 0 && idx < res.num[type]);
|
||||
|
||||
@ -891,7 +880,7 @@ byte *findResource(uint32 tag, byte *searchin)
|
||||
|
||||
do {
|
||||
size = READ_BE_UINT32_UNALIGNED(f->ptr + 4);
|
||||
if ((int32) size <= 0)
|
||||
if ((int32)size <= 0)
|
||||
return NULL;
|
||||
|
||||
f->pos += size;
|
||||
@ -923,7 +912,7 @@ byte *findResourceSmall(uint32 tag, byte *searchin)
|
||||
|
||||
do {
|
||||
size = READ_LE_UINT32(f->ptr);
|
||||
if ((int32) size <= 0)
|
||||
if ((int32)size <= 0)
|
||||
return NULL;
|
||||
|
||||
f->pos += size;
|
||||
@ -953,10 +942,9 @@ byte *findResource(uint32 tag, byte *searchin, int idx)
|
||||
return searchin;
|
||||
|
||||
size = READ_BE_UINT32_UNALIGNED(searchin + 4);
|
||||
if ((int32) size <= 0) {
|
||||
if ((int32)size <= 0) {
|
||||
error("(%c%c%c%c) Not found in %d... illegal block len %d",
|
||||
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF,
|
||||
(tag >> 24) & 0xFF, 0, size);
|
||||
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -986,10 +974,9 @@ byte *findResourceSmall(uint32 tag, byte *searchin, int idx)
|
||||
if (READ_LE_UINT16(searchin + 4) == smallTag && !idx--)
|
||||
return searchin;
|
||||
|
||||
if ((int32) size <= 0) {
|
||||
if ((int32)size <= 0) {
|
||||
error("(%c%c%c%c) Not found in %d... illegal block len %d",
|
||||
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF,
|
||||
(tag >> 24) & 0xFF, 0, size);
|
||||
tag & 0xFF, (tag >> 8) & 0xFF, (tag >> 16) & 0xFF, (tag >> 24) & 0xFF, 0, size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -1056,7 +1043,7 @@ void Scumm::expireResources(uint32 size)
|
||||
int best_type, best_res = 0;
|
||||
uint32 oldAllocatedSize;
|
||||
|
||||
// return;
|
||||
// return;
|
||||
|
||||
if (_expire_counter != 0xFF) {
|
||||
_expire_counter = 0xFF;
|
||||
@ -1076,8 +1063,7 @@ void Scumm::expireResources(uint32 size)
|
||||
if (res.mode[i]) {
|
||||
for (j = res.num[i]; --j >= 0;) {
|
||||
flag = res.flags[i][j];
|
||||
if (!(flag & 0x80) && flag >= best_counter
|
||||
&& res.address[i][j] && !isResourceInUse(i, j)) {
|
||||
if (!(flag & 0x80) && flag >= best_counter && res.address[i][j] && !isResourceInUse(i, j)) {
|
||||
best_counter = flag;
|
||||
best_type = i;
|
||||
best_res = j;
|
||||
@ -1092,8 +1078,7 @@ void Scumm::expireResources(uint32 size)
|
||||
|
||||
increaseResourceCounter();
|
||||
|
||||
debug(5, "Expired resources, mem %d -> %d", oldAllocatedSize,
|
||||
_allocatedSize);
|
||||
debug(5, "Expired resources, mem %d -> %d", oldAllocatedSize, _allocatedSize);
|
||||
}
|
||||
|
||||
void Scumm::freeResources()
|
||||
@ -1156,8 +1141,7 @@ void Scumm::resourceStats()
|
||||
}
|
||||
}
|
||||
|
||||
printf("Total allocated size=%ld, locked=%ld(%ld)\n", _allocatedSize,
|
||||
lockedSize, lockedNum);
|
||||
printf("Total allocated size=%ld, locked=%ld(%ld)\n", _allocatedSize, lockedSize, lockedNum);
|
||||
}
|
||||
|
||||
void Scumm::heapClear(int mode)
|
||||
@ -1171,10 +1155,10 @@ void Scumm::unkHeapProc2(int a, int b)
|
||||
void Scumm::readMAXS()
|
||||
{
|
||||
if (_features & GF_AFTER_V8) {
|
||||
fileSeek(_fileHandle, 50+50, SEEK_CUR);
|
||||
_numVariables = fileReadDwordLE(); /* ? 1500 */
|
||||
_numBitVariables = fileReadDwordLE(); /* ? 2048 */
|
||||
fileReadDwordLE(); /* 40 */
|
||||
fileSeek(_fileHandle, 50 + 50, SEEK_CUR);
|
||||
_numVariables = fileReadDwordLE(); /* ? 1500 */
|
||||
_numBitVariables = fileReadDwordLE(); /* ? 2048 */
|
||||
fileReadDwordLE(); /* 40 */
|
||||
_numScripts = fileReadDwordLE();
|
||||
_numSounds = fileReadDwordLE();
|
||||
_numCharsets = fileReadDwordLE();
|
||||
@ -1190,7 +1174,7 @@ void Scumm::readMAXS()
|
||||
fileReadDwordLE();
|
||||
_numArray = fileReadDwordLE();
|
||||
|
||||
_objectRoomTable = (byte*)calloc(_numGlobalObjects, 1);
|
||||
_objectRoomTable = (byte *)calloc(_numGlobalObjects, 1);
|
||||
_numGlobalScripts = 2000;
|
||||
|
||||
_shadowPaletteSize = NUM_SHADOW_PALETTE * 256;
|
||||
@ -1281,7 +1265,7 @@ void Scumm::allocateArrays()
|
||||
_inventory = (uint16 *)calloc(_numInventory, sizeof(uint16));
|
||||
_verbs = (VerbSlot *)calloc(_numVerbs, sizeof(VerbSlot));
|
||||
_objs = (ObjectData *)calloc(_numLocalObjects, sizeof(ObjectData));
|
||||
_vars = (int16 *) calloc(_numVariables, sizeof(int16));
|
||||
_vars = (int16 *)calloc(_numVariables, sizeof(int16));
|
||||
_bitVars = (byte *)calloc(_numBitVariables >> 3, 1);
|
||||
|
||||
allocResTypeData(rtCostume,
|
||||
@ -1309,7 +1293,7 @@ void Scumm::allocateArrays()
|
||||
|
||||
bool Scumm::isGlobInMemory(int type, int idx)
|
||||
{
|
||||
validateResource("isGlobInMemory",type,idx);
|
||||
validateResource("isGlobInMemory", type, idx);
|
||||
|
||||
return res.address[type][idx] != NULL;
|
||||
}
|
||||
@ -1357,28 +1341,64 @@ uint16 newTag2Old(uint32 oldTag)
|
||||
}
|
||||
|
||||
|
||||
char *Scumm::resTypeFromId(int id) {
|
||||
char *Scumm::resTypeFromId(int id)
|
||||
{
|
||||
static char buf[100];
|
||||
|
||||
switch(id) {
|
||||
case rtRoom: sprintf(buf, "Room"); break;
|
||||
case rtScript: sprintf(buf, "Script"); break;
|
||||
case rtCostume: sprintf(buf, "Costume"); break;
|
||||
case rtSound: sprintf(buf, "Sound"); break;
|
||||
case rtInventory: sprintf(buf, "Inventory"); break;
|
||||
case rtCharset: sprintf(buf, "Charset"); break;
|
||||
case rtString: sprintf(buf, "String"); break;
|
||||
case rtVerb: sprintf(buf, "Verb"); break;
|
||||
case rtActorName: sprintf(buf, "ActorName"); break;
|
||||
case rtBuffer: sprintf(buf, "Buffer"); break;
|
||||
case rtScaleTable:sprintf(buf, "ScaleTable"); break;
|
||||
case rtTemp: sprintf(buf, "Temp"); break;
|
||||
case rtFlObject: sprintf(buf, "FlObject"); break;
|
||||
case rtMatrix: sprintf(buf, "Matrix"); break;
|
||||
case rtBox: sprintf(buf, "Box"); break;
|
||||
case rtLast: sprintf(buf, "Last"); break;
|
||||
case rtNumTypes: sprintf(buf, "NumTypes"); break;
|
||||
default: sprintf(buf,"%d", id);
|
||||
switch (id) {
|
||||
case rtRoom:
|
||||
sprintf(buf, "Room");
|
||||
break;
|
||||
case rtScript:
|
||||
sprintf(buf, "Script");
|
||||
break;
|
||||
case rtCostume:
|
||||
sprintf(buf, "Costume");
|
||||
break;
|
||||
case rtSound:
|
||||
sprintf(buf, "Sound");
|
||||
break;
|
||||
case rtInventory:
|
||||
sprintf(buf, "Inventory");
|
||||
break;
|
||||
case rtCharset:
|
||||
sprintf(buf, "Charset");
|
||||
break;
|
||||
case rtString:
|
||||
sprintf(buf, "String");
|
||||
break;
|
||||
case rtVerb:
|
||||
sprintf(buf, "Verb");
|
||||
break;
|
||||
case rtActorName:
|
||||
sprintf(buf, "ActorName");
|
||||
break;
|
||||
case rtBuffer:
|
||||
sprintf(buf, "Buffer");
|
||||
break;
|
||||
case rtScaleTable:
|
||||
sprintf(buf, "ScaleTable");
|
||||
break;
|
||||
case rtTemp:
|
||||
sprintf(buf, "Temp");
|
||||
break;
|
||||
case rtFlObject:
|
||||
sprintf(buf, "FlObject");
|
||||
break;
|
||||
case rtMatrix:
|
||||
sprintf(buf, "Matrix");
|
||||
break;
|
||||
case rtBox:
|
||||
sprintf(buf, "Box");
|
||||
break;
|
||||
case rtLast:
|
||||
sprintf(buf, "Last");
|
||||
break;
|
||||
case rtNumTypes:
|
||||
sprintf(buf, "NumTypes");
|
||||
break;
|
||||
default:
|
||||
sprintf(buf, "%d", id);
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
333
x11.cpp
333
x11.cpp
@ -50,7 +50,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
class OSystem_X11 : public OSystem {
|
||||
class OSystem_X11:public OSystem {
|
||||
public:
|
||||
// Set colors of the palette
|
||||
void set_palette(const byte *colors, uint start, uint num);
|
||||
@ -68,32 +68,32 @@ public:
|
||||
|
||||
// Either show or hide the mouse cursor
|
||||
bool show_mouse(bool visible);
|
||||
|
||||
|
||||
// Set the position of the mouse cursor
|
||||
void set_mouse_pos(int x, int y);
|
||||
|
||||
|
||||
// Set the bitmap that's used when drawing the cursor.
|
||||
void set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y);
|
||||
|
||||
|
||||
// Shaking is used in SCUMM. Set current shake position.
|
||||
void set_shake_pos(int shake_pos);
|
||||
|
||||
|
||||
// Get the number of milliseconds since the program was started.
|
||||
uint32 get_msecs();
|
||||
|
||||
|
||||
// Delay for a specified amount of milliseconds
|
||||
void delay_msecs(uint msecs);
|
||||
|
||||
|
||||
// Create a thread
|
||||
void *create_thread(ThreadProc *proc, void *param);
|
||||
|
||||
|
||||
// Get the next event.
|
||||
// Returns true if an event was retrieved.
|
||||
// Returns true if an event was retrieved.
|
||||
bool poll_event(Event *event);
|
||||
|
||||
|
||||
// Set function that generates samples
|
||||
bool set_sound_proc(void *param, SoundProc *proc, byte sound);
|
||||
|
||||
|
||||
// Poll cdrom status
|
||||
// Returns true if cd audio is playing
|
||||
bool poll_cdrom();
|
||||
@ -114,7 +114,7 @@ public:
|
||||
uint32 property(int param, Property *value);
|
||||
|
||||
// Add a callback timer
|
||||
void set_timer(int timer, int (*callback)(int));
|
||||
void set_timer(int timer, int (*callback) (int));
|
||||
|
||||
// Mutex handling
|
||||
void *create_mutex(void);
|
||||
@ -125,7 +125,7 @@ public:
|
||||
static OSystem *create(int gfx_mode, bool full_screen);
|
||||
|
||||
private:
|
||||
OSystem_X11();
|
||||
OSystem_X11();
|
||||
|
||||
typedef struct {
|
||||
int x, y, w, h;
|
||||
@ -186,7 +186,7 @@ private:
|
||||
|
||||
unsigned int _timer_duration, _timer_next_expiry;
|
||||
bool _timer_active;
|
||||
int (*_timer_callback)(int);
|
||||
int (*_timer_callback) (int);
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@ -350,15 +350,14 @@ OSystem_X11::OSystem_X11()
|
||||
wm_hints->initial_state = NormalState;
|
||||
XStringListToTextProperty(&name, 1, &window_name);
|
||||
XSetWMProperties(display, window, &window_name, &window_name,
|
||||
NULL /* argv */ , 0 /* argc */ , NULL /* size hints */ ,
|
||||
wm_hints, NULL /* class hints */ );
|
||||
NULL /* argv */ , 0 /* argc */ , NULL /* size hints */ ,
|
||||
wm_hints, NULL /* class hints */ );
|
||||
XFree(wm_hints);
|
||||
|
||||
XSelectInput(display, window,
|
||||
ExposureMask | KeyPressMask | KeyReleaseMask |
|
||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
|
||||
StructureNotifyMask);
|
||||
|
||||
ExposureMask | KeyPressMask | KeyReleaseMask |
|
||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask);
|
||||
|
||||
values.foreground = BlackPixel(display, screen);
|
||||
black_gc = XCreateGC(display, window, GCForeground, &values);
|
||||
|
||||
@ -383,14 +382,16 @@ out_of_loop:
|
||||
gettimeofday(&start_time, NULL);
|
||||
}
|
||||
|
||||
uint32 OSystem_X11::get_msecs() {
|
||||
uint32 OSystem_X11::get_msecs()
|
||||
{
|
||||
struct timeval current_time;
|
||||
gettimeofday(¤t_time, NULL);
|
||||
return (uint32) (((current_time.tv_sec - start_time.tv_sec) * 1000) +
|
||||
((current_time.tv_usec - start_time.tv_usec) / 1000));
|
||||
return (uint32)(((current_time.tv_sec - start_time.tv_sec) * 1000) +
|
||||
((current_time.tv_usec - start_time.tv_usec) / 1000));
|
||||
}
|
||||
|
||||
void OSystem_X11::init_size(uint w, uint h) {
|
||||
void OSystem_X11::init_size(uint w, uint h)
|
||||
{
|
||||
static XShmSegmentInfo shminfo;
|
||||
|
||||
fb_width = w;
|
||||
@ -405,12 +406,13 @@ void OSystem_X11::init_size(uint w, uint h) {
|
||||
|
||||
XConfigureWindow(display, window, CWWidth | CWHeight, &new_values);
|
||||
}
|
||||
|
||||
#ifdef USE_XV_SCALING
|
||||
image = XvShmCreateImage(display, 65, 0x03, 0, fb_width, fb_height, &shminfo);
|
||||
shminfo.shmid = shmget(IPC_PRIVATE, image->data_size, IPC_CREAT | 0700);
|
||||
#else
|
||||
image = XShmCreateImage(display, DefaultVisual(display, screen), 16, ZPixmap, NULL, &shminfo, fb_width, fb_height);
|
||||
image =
|
||||
XShmCreateImage(display, DefaultVisual(display, screen), 16, ZPixmap, NULL, &shminfo, fb_width,
|
||||
fb_height);
|
||||
shminfo.shmid = shmget(IPC_PRIVATE, fb_width * fb_height * 2, IPC_CREAT | 0700);
|
||||
#endif
|
||||
shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
|
||||
@ -431,7 +433,8 @@ void OSystem_X11::init_size(uint w, uint h) {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool OSystem_X11::set_sound_proc(void *param, SoundProc *proc, byte format) {
|
||||
bool OSystem_X11::set_sound_proc(void *param, SoundProc *proc, byte format)
|
||||
{
|
||||
static THREAD_PARAM thread_param;
|
||||
|
||||
/* And finally start the music thread */
|
||||
@ -440,21 +443,22 @@ bool OSystem_X11::set_sound_proc(void *param, SoundProc *proc, byte format) {
|
||||
thread_param.format = format;
|
||||
|
||||
if (format == SOUND_16BIT)
|
||||
pthread_create(&sound_thread, NULL, sound_and_music_thread, (void *) &thread_param);
|
||||
pthread_create(&sound_thread, NULL, sound_and_music_thread, (void *)&thread_param);
|
||||
else
|
||||
warning("Only support 16 bit sound for now. Disabling sound ");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OSystem_X11::set_palette(const byte *colors, uint start, uint num) {
|
||||
void OSystem_X11::set_palette(const byte *colors, uint start, uint num)
|
||||
{
|
||||
const byte *data = colors;
|
||||
#ifdef USE_XV_SCALING
|
||||
unsigned int *pal = &(palette[start]);
|
||||
#else
|
||||
unsigned short *pal = &(palette[start]);
|
||||
#endif
|
||||
|
||||
|
||||
do {
|
||||
#ifdef USE_XV_SCALING
|
||||
*pal++ = (data[0] << 16) | (data[1] << 8) | data[2];
|
||||
@ -477,7 +481,8 @@ void OSystem_X11::set_palette(const byte *colors, uint start, uint num) {
|
||||
num_of_dirty_square++; \
|
||||
}
|
||||
|
||||
void OSystem_X11::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h) {
|
||||
void OSystem_X11::copy_rect(const byte *buf, int pitch, int x, int y, int w, int h)
|
||||
{
|
||||
unsigned char *dst;
|
||||
|
||||
if (y < 0) {
|
||||
@ -505,7 +510,8 @@ void OSystem_X11::copy_rect(const byte *buf, int pitch, int x, int y, int w, int
|
||||
}
|
||||
}
|
||||
|
||||
void OSystem_X11::update_screen_helper(const dirty_square * d, dirty_square * dout) {
|
||||
void OSystem_X11::update_screen_helper(const dirty_square * d, dirty_square * dout)
|
||||
{
|
||||
int x, y;
|
||||
unsigned char *ptr_src = local_fb + (fb_width * d->y) + d->x;
|
||||
#ifdef USE_XV_SCALING
|
||||
@ -513,7 +519,7 @@ void OSystem_X11::update_screen_helper(const dirty_square * d, dirty_square * do
|
||||
#else
|
||||
unsigned short *ptr_dst = ((unsigned short *)image->data) + (fb_width * d->y) + d->x;
|
||||
#endif
|
||||
|
||||
|
||||
for (y = 0; y < d->h; y++) {
|
||||
for (x = 0; x < d->w; x++) {
|
||||
*ptr_dst++ = palette[*ptr_src++];
|
||||
@ -531,12 +537,13 @@ void OSystem_X11::update_screen_helper(const dirty_square * d, dirty_square * do
|
||||
dout->h = d->y + d->h;
|
||||
}
|
||||
|
||||
void OSystem_X11::update_screen() {
|
||||
void OSystem_X11::update_screen()
|
||||
{
|
||||
bool full_redraw = false;
|
||||
bool need_redraw = false;
|
||||
static const dirty_square ds_full = { 0, 0, fb_width, fb_height };
|
||||
dirty_square dout = { fb_width, fb_height, 0, 0 };
|
||||
|
||||
|
||||
/* First make sure the mouse is drawn, if it should be drawn. */
|
||||
draw_mouse();
|
||||
|
||||
@ -565,31 +572,31 @@ void OSystem_X11::update_screen() {
|
||||
if (current_shake_pos < new_shake_pos)
|
||||
XFillRectangle(display, window, black_gc, 0, current_shake_pos, window_width, new_shake_pos);
|
||||
else
|
||||
XFillRectangle(display, window, black_gc, 0, window_height - current_shake_pos,
|
||||
window_width, window_height - new_shake_pos);
|
||||
XFillRectangle(display, window, black_gc, 0, window_height - current_shake_pos,
|
||||
window_width, window_height - new_shake_pos);
|
||||
#ifndef USE_XV_SCALING
|
||||
XShmPutImage(display, window, DefaultGC(display, screen), image,
|
||||
0, 0, scumm_x, scumm_y + new_shake_pos,
|
||||
fb_width, fb_height, 0);
|
||||
0, 0, scumm_x, scumm_y + new_shake_pos, fb_width, fb_height, 0);
|
||||
#endif
|
||||
current_shake_pos = new_shake_pos;
|
||||
} else if (need_redraw == true) {
|
||||
#ifdef USE_XV_SCALING
|
||||
XvShmPutImage(display, 65, window, DefaultGC(display, screen), image,
|
||||
0, 0, fb_width, fb_height, 0, 0, window_width, window_height, 0);
|
||||
0, 0, fb_width, fb_height, 0, 0, window_width, window_height, 0);
|
||||
#else
|
||||
XShmPutImage(display, window, DefaultGC(display, screen), image,
|
||||
dout.x, dout.y, scumm_x + dout.x, scumm_y + dout.y + current_shake_pos,
|
||||
dout.w - dout.x, dout.h - dout.y, 0);
|
||||
dout.x, dout.y, scumm_x + dout.x, scumm_y + dout.y + current_shake_pos,
|
||||
dout.w - dout.x, dout.h - dout.y, 0);
|
||||
#endif
|
||||
XFlush(display);
|
||||
}
|
||||
}
|
||||
|
||||
bool OSystem_X11::show_mouse(bool visible) {
|
||||
bool OSystem_X11::show_mouse(bool visible)
|
||||
{
|
||||
if (_mouse_visible == visible)
|
||||
return visible;
|
||||
|
||||
|
||||
bool last = _mouse_visible;
|
||||
_mouse_visible = visible;
|
||||
|
||||
@ -601,11 +608,13 @@ bool OSystem_X11::show_mouse(bool visible) {
|
||||
return last;
|
||||
}
|
||||
|
||||
void OSystem_X11::quit() {
|
||||
void OSystem_X11::quit()
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void OSystem_X11::draw_mouse() {
|
||||
void OSystem_X11::draw_mouse()
|
||||
{
|
||||
if (_mouse_drawn || !_mouse_visible)
|
||||
return;
|
||||
_mouse_drawn = true;
|
||||
@ -678,7 +687,8 @@ void OSystem_X11::draw_mouse() {
|
||||
}
|
||||
}
|
||||
|
||||
void OSystem_X11::undraw_mouse() {
|
||||
void OSystem_X11::undraw_mouse()
|
||||
{
|
||||
if (!_mouse_drawn)
|
||||
return;
|
||||
_mouse_drawn = false;
|
||||
@ -698,66 +708,76 @@ void OSystem_X11::undraw_mouse() {
|
||||
}
|
||||
}
|
||||
|
||||
void OSystem_X11::set_mouse_pos(int x, int y) {
|
||||
void OSystem_X11::set_mouse_pos(int x, int y)
|
||||
{
|
||||
if ((x != cur_state.x) || (y != cur_state.y)) {
|
||||
cur_state.x = x;
|
||||
cur_state.y = y;
|
||||
undraw_mouse();
|
||||
}
|
||||
}
|
||||
|
||||
void OSystem_X11::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y) {
|
||||
|
||||
void OSystem_X11::set_mouse_cursor(const byte *buf, uint w, uint h, int hotspot_x, int hotspot_y)
|
||||
{
|
||||
cur_state.w = w;
|
||||
cur_state.h = h;
|
||||
cur_state.hot_x = hotspot_x;
|
||||
cur_state.hot_y = hotspot_y;
|
||||
_ms_buf = (byte*)buf;
|
||||
_ms_buf = (byte *)buf;
|
||||
|
||||
undraw_mouse();
|
||||
}
|
||||
|
||||
void OSystem_X11::set_shake_pos(int shake_pos) {
|
||||
|
||||
void OSystem_X11::set_shake_pos(int shake_pos)
|
||||
{
|
||||
new_shake_pos = shake_pos;
|
||||
}
|
||||
|
||||
void *OSystem_X11::create_thread(ThreadProc *proc, void *param) {
|
||||
void *OSystem_X11::create_thread(ThreadProc *proc, void *param)
|
||||
{
|
||||
pthread_t *thread = (pthread_t *) malloc(sizeof(pthread_t));
|
||||
if (pthread_create(thread, NULL, (void * (*)(void *)) proc, param))
|
||||
if (pthread_create(thread, NULL, (void *(*)(void *))proc, param))
|
||||
return NULL;
|
||||
else
|
||||
return thread;
|
||||
}
|
||||
|
||||
uint32 OSystem_X11::property(int param, Property *value) {
|
||||
switch (param)
|
||||
{
|
||||
case PROP_GET_SAMPLE_RATE:
|
||||
return 22050;
|
||||
case PROP_GET_FULLSCREEN:
|
||||
return 0;
|
||||
uint32 OSystem_X11::property(int param, Property *value)
|
||||
{
|
||||
switch (param) {
|
||||
case PROP_GET_SAMPLE_RATE:
|
||||
return 22050;
|
||||
case PROP_GET_FULLSCREEN:
|
||||
return 0;
|
||||
}
|
||||
warning("Property not implemented yet (%d) ", param);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool OSystem_X11::poll_cdrom() {
|
||||
bool OSystem_X11::poll_cdrom()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void OSystem_X11::play_cdrom(int track, int num_loops, int start_frame, int end_frame) {
|
||||
void OSystem_X11::play_cdrom(int track, int num_loops, int start_frame, int end_frame)
|
||||
{
|
||||
}
|
||||
|
||||
void OSystem_X11::stop_cdrom() {
|
||||
void OSystem_X11::stop_cdrom()
|
||||
{
|
||||
}
|
||||
|
||||
void OSystem_X11::update_cdrom() {
|
||||
void OSystem_X11::update_cdrom()
|
||||
{
|
||||
}
|
||||
|
||||
void OSystem_X11::delay_msecs(uint msecs) {
|
||||
void OSystem_X11::delay_msecs(uint msecs)
|
||||
{
|
||||
usleep(msecs * 1000);
|
||||
}
|
||||
|
||||
bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
bool OSystem_X11::poll_event(Event *scumm_event)
|
||||
{
|
||||
/* First, handle timers */
|
||||
uint32 current_msecs = get_msecs();
|
||||
|
||||
@ -772,76 +792,79 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
XNextEvent(display, &event);
|
||||
switch (event.type) {
|
||||
case Expose:{
|
||||
int real_w, real_h;
|
||||
int real_x, real_y;
|
||||
real_x = event.xexpose.x;
|
||||
real_y = event.xexpose.y;
|
||||
real_w = event.xexpose.width;
|
||||
real_h = event.xexpose.height;
|
||||
if (real_x < scumm_x) {
|
||||
real_w -= scumm_x - real_x;
|
||||
real_x = 0;
|
||||
} else {
|
||||
real_x -= scumm_x;
|
||||
}
|
||||
if (real_y < scumm_y) {
|
||||
real_h -= scumm_y - real_y;
|
||||
real_y = 0;
|
||||
} else {
|
||||
real_y -= scumm_y;
|
||||
}
|
||||
if ((real_h <= 0) || (real_w <= 0))
|
||||
break;
|
||||
if ((real_x >= fb_width) || (real_y >= fb_height))
|
||||
break;
|
||||
int real_w, real_h;
|
||||
int real_x, real_y;
|
||||
real_x = event.xexpose.x;
|
||||
real_y = event.xexpose.y;
|
||||
real_w = event.xexpose.width;
|
||||
real_h = event.xexpose.height;
|
||||
if (real_x < scumm_x) {
|
||||
real_w -= scumm_x - real_x;
|
||||
real_x = 0;
|
||||
} else {
|
||||
real_x -= scumm_x;
|
||||
}
|
||||
if (real_y < scumm_y) {
|
||||
real_h -= scumm_y - real_y;
|
||||
real_y = 0;
|
||||
} else {
|
||||
real_y -= scumm_y;
|
||||
}
|
||||
if ((real_h <= 0) || (real_w <= 0))
|
||||
break;
|
||||
if ((real_x >= fb_width) || (real_y >= fb_height))
|
||||
break;
|
||||
|
||||
if ((real_x + real_w) >= fb_width) {
|
||||
real_w = fb_width - real_x;
|
||||
}
|
||||
if ((real_y + real_h) >= fb_height) {
|
||||
real_h = fb_height - real_y;
|
||||
}
|
||||
if ((real_x + real_w) >= fb_width) {
|
||||
real_w = fb_width - real_x;
|
||||
}
|
||||
if ((real_y + real_h) >= fb_height) {
|
||||
real_h = fb_height - real_y;
|
||||
}
|
||||
|
||||
/* Compute the intersection of the expose event with the real ScummVM display zone */
|
||||
AddDirtyRec(real_x, real_y, real_w, real_h);
|
||||
}
|
||||
break;
|
||||
/* Compute the intersection of the expose event with the real ScummVM display zone */
|
||||
AddDirtyRec(real_x, real_y, real_w, real_h);
|
||||
}
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
switch (event.xkey.keycode) {
|
||||
case 132:
|
||||
report_presses = 0;
|
||||
break;
|
||||
case 132:
|
||||
report_presses = 0;
|
||||
break;
|
||||
|
||||
case 133:
|
||||
fake_right_mouse = 1;
|
||||
break;
|
||||
}
|
||||
case 133:
|
||||
fake_right_mouse = 1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case KeyRelease: {
|
||||
/* I am using keycodes here and NOT keysyms to be sure that even if the user
|
||||
remaps his iPAQ's keyboard, it will still work.
|
||||
*/
|
||||
int keycode = -1;
|
||||
int ascii = -1;
|
||||
byte mode = 0;
|
||||
case KeyRelease:{
|
||||
/* I am using keycodes here and NOT keysyms to be sure that even if the user
|
||||
remaps his iPAQ's keyboard, it will still work.
|
||||
*/
|
||||
int keycode = -1;
|
||||
int ascii = -1;
|
||||
byte mode = 0;
|
||||
|
||||
if (event.xkey.state & 0x01) mode |= KBD_SHIFT;
|
||||
if (event.xkey.state & 0x04) mode |= KBD_CTRL;
|
||||
if (event.xkey.state & 0x08) mode |= KBD_ALT;
|
||||
switch (event.xkey.keycode) {
|
||||
if (event.xkey.state & 0x01)
|
||||
mode |= KBD_SHIFT;
|
||||
if (event.xkey.state & 0x04)
|
||||
mode |= KBD_CTRL;
|
||||
if (event.xkey.state & 0x08)
|
||||
mode |= KBD_ALT;
|
||||
switch (event.xkey.keycode) {
|
||||
case 9: /* Escape on my PC */
|
||||
case 130: /* Calendar on the iPAQ */
|
||||
keycode = 27;
|
||||
break;
|
||||
|
||||
case 71: /* F5 on my PC */
|
||||
case 71: /* F5 on my PC */
|
||||
case 128: /* Record on the iPAQ */
|
||||
keycode = 319;
|
||||
break;
|
||||
|
||||
case 65: /* Space on my PC */
|
||||
case 65: /* Space on my PC */
|
||||
case 131: /* Schedule on the iPAQ */
|
||||
keycode = 32;
|
||||
break;
|
||||
@ -855,23 +878,23 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
break;
|
||||
|
||||
default:{
|
||||
KeySym xsym;
|
||||
xsym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
|
||||
keycode = xsym;
|
||||
if ((xsym >= 'a') && (xsym <= 'z') && (event.xkey.state & 0x01))
|
||||
xsym &= ~0x20; /* Handle shifted keys */
|
||||
ascii = xsym;
|
||||
KeySym xsym;
|
||||
xsym = XKeycodeToKeysym(display, event.xkey.keycode, 0);
|
||||
keycode = xsym;
|
||||
if ((xsym >= 'a') && (xsym <= 'z') && (event.xkey.state & 0x01))
|
||||
xsym &= ~0x20; /* Handle shifted keys */
|
||||
ascii = xsym;
|
||||
}
|
||||
}
|
||||
if (keycode != -1) {
|
||||
scumm_event->event_code = EVENT_KEYDOWN;
|
||||
scumm_event->kbd.keycode = keycode;
|
||||
scumm_event->kbd.ascii = (ascii != -1 ? ascii : keycode);
|
||||
scumm_event->kbd.flags = mode;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (keycode != -1)
|
||||
{
|
||||
scumm_event->event_code = EVENT_KEYDOWN;
|
||||
scumm_event->kbd.keycode = keycode;
|
||||
scumm_event->kbd.ascii = (ascii != -1 ? ascii : keycode);
|
||||
scumm_event->kbd.flags = mode;
|
||||
return true;
|
||||
}
|
||||
} break;
|
||||
break;
|
||||
|
||||
case ButtonPress:
|
||||
if (report_presses != 0) {
|
||||
@ -887,7 +910,7 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
scumm_event->mouse.y = event.xbutton.y - scumm_y;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (report_presses != 0) {
|
||||
@ -901,9 +924,9 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
scumm_event->event_code = EVENT_RBUTTONUP;
|
||||
scumm_event->mouse.x = event.xbutton.x - scumm_x;
|
||||
scumm_event->mouse.y = event.xbutton.y - scumm_y;
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
scumm_event->event_code = EVENT_MOUSEMOVE;
|
||||
@ -912,16 +935,15 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
return true;
|
||||
|
||||
case ConfigureNotify:{
|
||||
if ((window_width != event.xconfigure.width) ||
|
||||
(window_height != event.xconfigure.height)) {
|
||||
window_width = event.xconfigure.width;
|
||||
window_height = event.xconfigure.height;
|
||||
scumm_x = (window_width - fb_width) / 2;
|
||||
scumm_y = (window_height - fb_height) / 2;
|
||||
XFillRectangle(display, window, black_gc, 0, 0, window_width, window_height);
|
||||
if ((window_width != event.xconfigure.width) || (window_height != event.xconfigure.height)) {
|
||||
window_width = event.xconfigure.width;
|
||||
window_height = event.xconfigure.height;
|
||||
scumm_x = (window_width - fb_width) / 2;
|
||||
scumm_y = (window_height - fb_height) / 2;
|
||||
XFillRectangle(display, window, black_gc, 0, 0, window_width, window_height);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("Unhandled event : %d\n", event.type);
|
||||
@ -932,7 +954,8 @@ bool OSystem_X11::poll_event(Event *scumm_event) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OSystem_X11::set_timer(int timer, int (*callback)(int)) {
|
||||
void OSystem_X11::set_timer(int timer, int (*callback) (int))
|
||||
{
|
||||
if (callback != NULL) {
|
||||
_timer_duration = timer;
|
||||
_timer_next_expiry = get_msecs() + timer;
|
||||
@ -943,21 +966,25 @@ void OSystem_X11::set_timer(int timer, int (*callback)(int)) {
|
||||
}
|
||||
}
|
||||
|
||||
void *OSystem_X11::create_mutex(void) {
|
||||
void *OSystem_X11::create_mutex(void)
|
||||
{
|
||||
pthread_mutex_t *mutex = (pthread_mutex_t *) malloc(sizeof(pthread_mutex_t));
|
||||
pthread_mutex_init(mutex, NULL);
|
||||
return (void *) mutex;
|
||||
return (void *)mutex;
|
||||
}
|
||||
|
||||
void OSystem_X11::lock_mutex(void *mutex) {
|
||||
void OSystem_X11::lock_mutex(void *mutex)
|
||||
{
|
||||
pthread_mutex_lock((pthread_mutex_t *) mutex);
|
||||
}
|
||||
|
||||
void OSystem_X11::unlock_mutex(void *mutex) {
|
||||
void OSystem_X11::unlock_mutex(void *mutex)
|
||||
{
|
||||
pthread_mutex_unlock((pthread_mutex_t *) mutex);
|
||||
}
|
||||
|
||||
void OSystem_X11::delete_mutex(void *mutex) {
|
||||
void OSystem_X11::delete_mutex(void *mutex)
|
||||
{
|
||||
pthread_mutex_destroy((pthread_mutex_t *) mutex);
|
||||
free(mutex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user