Initial commit
This commit is contained in:
175
engines/m4/platform/draw.cpp
Normal file
175
engines/m4/platform/draw.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/algorithm.h"
|
||||
#include "common/textconsole.h"
|
||||
#include "m4/platform/draw.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch) {
|
||||
byte val, count;
|
||||
int line = 0, numY = 0;
|
||||
byte *destP = outBuff;
|
||||
|
||||
for (;;) {
|
||||
count = *inBuff++;
|
||||
|
||||
if (count) {
|
||||
// Basic run length
|
||||
val = *inBuff++;
|
||||
Common::fill(destP, destP + count, val);
|
||||
destP += count;
|
||||
|
||||
} else {
|
||||
count = *inBuff++;
|
||||
|
||||
if (count >= 3) {
|
||||
// Block of uncompressed pixels to copy
|
||||
Common::copy(inBuff, inBuff + count, destP);
|
||||
inBuff += count;
|
||||
destP += count;
|
||||
|
||||
} else if (!(count & 3)) {
|
||||
// End of Line code
|
||||
++line;
|
||||
destP = outBuff + line * pitch;
|
||||
|
||||
} else if (!(count & 2)) {
|
||||
break;
|
||||
|
||||
} else {
|
||||
// Move down by X, Y amount
|
||||
destP += *inBuff++; // x amount
|
||||
numY = *inBuff++; // y amount
|
||||
line += numY;
|
||||
destP += numY * pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint8 *SkipRLE_Lines(uint32 linesToSkip, uint8 *rleData) {
|
||||
while (linesToSkip > 0) {
|
||||
if (*rleData) {
|
||||
// Simple RLE sequence, so skip over count and value
|
||||
rleData += 2;
|
||||
|
||||
} else if (rleData[1] >= 3) {
|
||||
rleData += 2 + rleData[2];
|
||||
} else {
|
||||
rleData += 2;
|
||||
--linesToSkip;
|
||||
}
|
||||
}
|
||||
|
||||
return rleData;
|
||||
}
|
||||
|
||||
size_t RLE8Decode_Size(byte *src, int pitch) {
|
||||
size_t total = 0, line = 0, y;
|
||||
byte count;
|
||||
|
||||
for (;;) {
|
||||
count = *src++;
|
||||
|
||||
if (count) {
|
||||
total += count;
|
||||
++src;
|
||||
} else {
|
||||
count = *src++;
|
||||
|
||||
if (count >= 3) {
|
||||
// Block of uncompressed pixels to copy
|
||||
total += count;
|
||||
src += count;
|
||||
|
||||
} else if (!(count & 3)) {
|
||||
// End of Line code
|
||||
++line;
|
||||
total = line * pitch;
|
||||
|
||||
} else if (!(count & 2)) {
|
||||
break;
|
||||
|
||||
} else {
|
||||
// Move down by X, Y amount
|
||||
total += *src++; // x amount
|
||||
y = *src++; // y amount
|
||||
line += y;
|
||||
total += y * pitch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
void RLE_Draw(Buffer *src, Buffer *dest, int32 x, int32 y) {
|
||||
const byte *srcP = src->data;
|
||||
byte *destData = dest->data + y * dest->w + x;
|
||||
byte *destP = destData;
|
||||
int destWidth = dest->w;
|
||||
byte count, val;
|
||||
int line = 0;
|
||||
|
||||
assert(x >= 0 && y >= 0 && x < dest->w && y < dest->h);
|
||||
|
||||
for (;;) {
|
||||
count = *srcP++;
|
||||
|
||||
if (count) {
|
||||
// Basic run length
|
||||
val = *srcP++;
|
||||
|
||||
// 0 pixels are transparent, and are skipped. Otherwise, draw pixels
|
||||
if (val != 0)
|
||||
Common::fill(destP, destP + count, val);
|
||||
destP += count;
|
||||
|
||||
} else {
|
||||
count = *srcP++;
|
||||
|
||||
if (count >= 3) {
|
||||
// Block of uncompressed pixels to copy
|
||||
for (; count > 0; --count, ++destP) {
|
||||
val = *srcP++;
|
||||
if (val != 0)
|
||||
*destP = val;
|
||||
}
|
||||
|
||||
} else if (!(count & 3)) {
|
||||
// End of line code
|
||||
++line;
|
||||
destP = destData + line * destWidth;
|
||||
|
||||
} else {
|
||||
// Stop drawing image. Seems weird that it doesn't handle the X/Y offset
|
||||
// form for count & 2, but the original explicitly doesn't implement it
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assert(destP <= (dest->data + dest->h * dest->stride));
|
||||
}
|
||||
|
||||
} // namespace M4
|
||||
49
engines/m4/platform/draw.h
Normal file
49
engines/m4/platform/draw.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_DRAW_H
|
||||
#define M4_PLATFORM_DRAW_H
|
||||
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
/**
|
||||
* Decode an 8BPP RLE encoded image
|
||||
*/
|
||||
void RLE8Decode(const uint8 *inBuff, uint8 *outBuff, uint32 pitch);
|
||||
|
||||
/**
|
||||
* Given RLE data, skips over a given number of encoded lines
|
||||
*/
|
||||
uint8 *SkipRLE_Lines(uint32 linesToSkip, uint8 *rleData);
|
||||
|
||||
/**
|
||||
* Returns the size of an RLE encoded image
|
||||
* @param data RLE data
|
||||
* @param pitch Image pitch
|
||||
* @returns Decoded image's size in bytes
|
||||
*/
|
||||
size_t RLE8Decode_Size(byte *src, int pitch);
|
||||
|
||||
} // namespace M4
|
||||
|
||||
#endif
|
||||
251
engines/m4/platform/events.cpp
Normal file
251
engines/m4/platform/events.cpp
Normal file
@@ -0,0 +1,251 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/system.h"
|
||||
#include "m4/platform/events.h"
|
||||
#include "m4/vars.h"
|
||||
#include "m4/m4.h"
|
||||
#include "m4/platform/timer.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
/*
|
||||
* Define call mask bit fields
|
||||
*/
|
||||
|
||||
enum {
|
||||
CursorPositionChanged = 0,
|
||||
LeftButtonPressed, LeftButtonReleased, RightButtonPressed,
|
||||
RightButtonReleased
|
||||
};
|
||||
|
||||
/*
|
||||
* Define call mask values
|
||||
*/
|
||||
#define CPC ((uint16)(1 << CursorPositionChanged))
|
||||
#define LBD ((uint16)(1 << LeftButtonPressed))
|
||||
#define LBU ((uint16)(1 << LeftButtonReleased))
|
||||
#define LBH ((uint16)(1 << LeftButtonHold))
|
||||
#define RBD ((uint16)(1 << RightButtonPressed))
|
||||
#define RBU ((uint16)(1 << RightButtonReleased))
|
||||
#define RBH ((uint16)(1 << RightButtonHold))
|
||||
|
||||
#define LBC (LBD + LBU)
|
||||
#define RBC (RBD + RBU)
|
||||
#define MBC (MBD + MBU)
|
||||
#define MSA (LBC + RBC + CPC)
|
||||
#define OEMA (LBC + RBC + MBC + CPC)
|
||||
|
||||
#define _MLD (_mouseStateEvent & LBD)
|
||||
#define _ClearMLD _mouseStateEvent &= ~LBD
|
||||
#define _MLU (_mouseStateEvent & LBU)
|
||||
#define _ClearMLU _mouseStateEvent &= ~LBU
|
||||
|
||||
#define _MRD (_mouseStateEvent & RBD)
|
||||
#define _ClearMRD _mouseStateEvent &= ~RBD
|
||||
#define _MRU (_mouseStateEvent & RBU)
|
||||
#define _ClearMRU _mouseStateEvent &= ~RBU
|
||||
|
||||
#define _MMOVE ((_mouseX != _oldX) || (_mouseY != _oldY))
|
||||
#define _MSAVE _oldX = _mouseX; _oldY = _mouseY
|
||||
|
||||
Events *g_events;
|
||||
|
||||
Events::Events() {
|
||||
g_events = this;
|
||||
}
|
||||
|
||||
Events::~Events() {
|
||||
g_events = nullptr;
|
||||
}
|
||||
|
||||
void Events::process() {
|
||||
pollEvents();
|
||||
}
|
||||
|
||||
void Events::pollEvents() {
|
||||
Common::Event ev;
|
||||
while (g_system->getEventManager()->pollEvent(ev)) {
|
||||
if (ev.type == Common::EVENT_QUIT || ev.type == Common::EVENT_RETURN_TO_LAUNCHER) {
|
||||
_G(kernel).going = false;
|
||||
} else if (ev.type >= Common::EVENT_MOUSEMOVE && ev.type <= Common::EVENT_MBUTTONUP) {
|
||||
handleMouseEvent(ev);
|
||||
} else if (ev.type == Common::EVENT_KEYDOWN || ev.type == Common::EVENT_KEYUP) {
|
||||
handleKeyboardEvent(ev);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Events::handleMouseEvent(const Common::Event &ev) {
|
||||
_mouseX = ev.mouse.x;
|
||||
_mouseY = ev.mouse.y;
|
||||
|
||||
switch (ev.type) {
|
||||
case Common::EVENT_MOUSEMOVE:
|
||||
_mouseStateEvent |= CPC;
|
||||
break;
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
_mouseStateEvent |= LBD;
|
||||
ButtonState = 1;
|
||||
break;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
_mouseStateEvent |= LBU;
|
||||
ButtonState = 0;
|
||||
break;
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
_mouseStateEvent |= RBD;
|
||||
ButtonState = 2;
|
||||
break;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
_mouseStateEvent |= RBU;
|
||||
ButtonState = 0;
|
||||
break;
|
||||
|
||||
case Common::EVENT_WHEELDOWN:
|
||||
_G(toggle_cursor) = CURSCHANGE_NEXT;
|
||||
break;
|
||||
case Common::EVENT_WHEELUP:
|
||||
_G(toggle_cursor) = CURSCHANGE_PREVIOUS;
|
||||
break;
|
||||
case Common::EVENT_MBUTTONDOWN:
|
||||
_G(toggle_cursor) = CURSCHANGE_TOGGLE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Events::handleKeyboardEvent(const Common::Event &ev) {
|
||||
if (ev.type == Common::EVENT_KEYDOWN && _pendingKeys.size() < 16)
|
||||
_pendingKeys.push(ev.kbd);
|
||||
}
|
||||
|
||||
MouseEvent Events::mouse_get_event() {
|
||||
process();
|
||||
|
||||
switch (_mouse_state) {
|
||||
case _MS_no_event:
|
||||
if (_MLD) {
|
||||
_ClearMLD;
|
||||
if (_dclickTime && (timer_read_60() < _dclickTime)) {
|
||||
_mouse_state = _MS_doubleclick_Down;
|
||||
_dclickTime = 0;
|
||||
return _ME_doubleclick;
|
||||
}
|
||||
_dclickTime = 0;
|
||||
_mouse_state = _MS_L_clickDown;
|
||||
return _ME_L_click;
|
||||
}
|
||||
if (_MRD) {
|
||||
_ClearMRD;
|
||||
_mouse_state = _MS_R_clickDown;
|
||||
return _ME_R_click;
|
||||
}
|
||||
if (_MMOVE) {
|
||||
_MSAVE;
|
||||
return _ME_move;
|
||||
}
|
||||
return _ME_no_event;
|
||||
|
||||
case _MS_L_clickDown:
|
||||
if (_MLU || !ButtonState) {
|
||||
_dclickTime = timer_read_60() + 15;
|
||||
_ClearMLU;
|
||||
_mouse_state = _MS_no_event;
|
||||
return _ME_L_release;
|
||||
}
|
||||
if (_MMOVE) {
|
||||
_MSAVE;
|
||||
return _ME_L_drag;
|
||||
}
|
||||
return _ME_L_hold;
|
||||
|
||||
case _MS_R_clickDown:
|
||||
if (_MRU) {
|
||||
_ClearMRU;
|
||||
_mouse_state = _MS_no_event;
|
||||
_G(toggle_cursor) = CURSCHANGE_NEXT;
|
||||
return _ME_R_release;
|
||||
}
|
||||
if (_MMOVE) {
|
||||
_MSAVE;
|
||||
return _ME_R_drag;
|
||||
}
|
||||
return _ME_R_hold;
|
||||
|
||||
case _MS_doubleclick_Down:
|
||||
if (_MLU) {
|
||||
_ClearMLU; _ClearMLD;
|
||||
_mouse_state = _MS_no_event;
|
||||
return _ME_doubleclick_release;
|
||||
}
|
||||
if (_MMOVE) {
|
||||
_MSAVE;
|
||||
return _ME_doubleclick_drag;
|
||||
}
|
||||
return _ME_doubleclick_hold;
|
||||
|
||||
default:
|
||||
return _ME_no_event;
|
||||
}
|
||||
|
||||
return _ME_no_event;
|
||||
}
|
||||
|
||||
bool Events::util_kbd_check(int32 *parm1) {
|
||||
process();
|
||||
|
||||
if (!parm1 || _pendingKeys.empty())
|
||||
return false;
|
||||
|
||||
Common::KeyState ks = _pendingKeys.pop();
|
||||
if (is_mod_key(ks))
|
||||
return false;
|
||||
|
||||
int flags = ks.flags & (Common::KBD_CTRL | Common::KBD_ALT);
|
||||
int key = (ks.ascii >= 32 && ks.ascii <= 127 && !flags) ? ks.ascii : (int)ks.keycode;
|
||||
*parm1 = key | (flags << 16);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Events::delay(uint amount) {
|
||||
uint32 beginTime = g_system->getMillis(), newTime;
|
||||
|
||||
do {
|
||||
krn_pal_game_task();
|
||||
g_system->delayMillis(5);
|
||||
process();
|
||||
|
||||
newTime = g_system->getMillis();
|
||||
} while (!g_engine->shouldQuit() && newTime < (beginTime + amount));
|
||||
}
|
||||
|
||||
MouseEvent mouse_get_event() {
|
||||
return g_events->mouse_get_event();
|
||||
}
|
||||
|
||||
bool util_kbd_check(int32 *parm1) {
|
||||
return g_events->util_kbd_check(parm1);
|
||||
}
|
||||
|
||||
} // namespace M4
|
||||
141
engines/m4/platform/events.h
Normal file
141
engines/m4/platform/events.h
Normal file
@@ -0,0 +1,141 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_EVENTS_H
|
||||
#define M4_PLATFORM_EVENTS_H
|
||||
|
||||
#include "common/queue.h"
|
||||
#include "common/events.h"
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
enum MouseEvent {
|
||||
_ME_no_event, // 0
|
||||
_ME_move, // 1
|
||||
_ME_L_click, // 2
|
||||
_ME_L_hold, // 3
|
||||
_ME_L_drag, // 4
|
||||
_ME_L_release, // 5
|
||||
_ME_R_click, // 6
|
||||
_ME_R_hold, // 7
|
||||
_ME_R_drag, // 8
|
||||
_ME_R_release, // 9
|
||||
_ME_both_click, // 10
|
||||
_ME_both_hold, // 11
|
||||
_ME_both_drag, // 12
|
||||
_ME_both_release, // 13
|
||||
_ME_doubleclick, // 14
|
||||
_ME_doubleclick_hold, // 15
|
||||
_ME_doubleclick_drag, // 16
|
||||
_ME_doubleclick_release
|
||||
};
|
||||
|
||||
enum mausState {
|
||||
_MS_no_event, // 0
|
||||
_MS_L_clickDown, // 1
|
||||
_MS_R_clickDown, // 2
|
||||
_MS_both_clickDown, // 3
|
||||
_MS_doubleclick_Down // 4
|
||||
};
|
||||
|
||||
struct MouseInfo {
|
||||
uint16 Event = 0;
|
||||
uint16 ButtonState = 0;
|
||||
uint16 CursorColumn = 0; // x
|
||||
uint16 CursorRow = 0; // y
|
||||
uint16 HorizontalMickeyCount = 0;
|
||||
uint16 VerticalMickeyCount = 0;
|
||||
};
|
||||
|
||||
struct Events : public MouseInfo {
|
||||
private:
|
||||
Common::Queue<Common::KeyState> _pendingKeys;
|
||||
uint16 &_mouseX = CursorColumn;
|
||||
uint16 &_mouseY = CursorRow;
|
||||
uint16 _oldX = 0xffff;
|
||||
uint16 _oldY = 0xffff;
|
||||
mausState _mouse_state = _MS_no_event;
|
||||
uint32 _mouseStateEvent = 0;
|
||||
uint32 _dclickTime = 0;
|
||||
|
||||
/**
|
||||
* Handles reading in pending events from the ScummVM event queue
|
||||
*/
|
||||
void pollEvents();
|
||||
|
||||
/**
|
||||
* Handles mouse events
|
||||
*/
|
||||
void handleMouseEvent(const Common::Event &ev);
|
||||
|
||||
/**
|
||||
* Handles keyboard events
|
||||
*/
|
||||
void handleKeyboardEvent(const Common::Event &ev);
|
||||
|
||||
/**
|
||||
* Tells if key event refers to one of the mod-keys
|
||||
*/
|
||||
inline bool is_mod_key(const Common::KeyState &ks) {
|
||||
return ks.keycode == Common::KEYCODE_LCTRL || ks.keycode == Common::KEYCODE_RCTRL ||
|
||||
ks.keycode == Common::KEYCODE_LALT || ks.keycode == Common::KEYCODE_RALT ||
|
||||
ks.keycode == Common::KEYCODE_LSHIFT || ks.keycode == Common::KEYCODE_RSHIFT ||
|
||||
ks.keycode == Common::KEYCODE_MODE;
|
||||
}
|
||||
|
||||
public:
|
||||
Events();
|
||||
~Events();
|
||||
|
||||
/**
|
||||
* Updates pending events and timers
|
||||
*/
|
||||
void process();
|
||||
|
||||
/**
|
||||
* Get the next pending mouse event
|
||||
*/
|
||||
MouseEvent mouse_get_event();
|
||||
|
||||
/**
|
||||
* Get the next pending keyboard event
|
||||
*/
|
||||
bool util_kbd_check(int32 *parm1);
|
||||
|
||||
void clearMouseStateEvent() {
|
||||
_mouseStateEvent = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delays by a given number of milliseconds
|
||||
*/
|
||||
void delay(uint amount);
|
||||
};
|
||||
|
||||
extern Events *g_events;
|
||||
|
||||
MouseEvent mouse_get_event();
|
||||
bool util_kbd_check(int32 *parm1);
|
||||
|
||||
} // namespace M4
|
||||
|
||||
#endif
|
||||
148
engines/m4/platform/keys.h
Normal file
148
engines/m4/platform/keys.h
Normal file
@@ -0,0 +1,148 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_KEYS_H
|
||||
#define M4_PLATFORM_KEYS_H
|
||||
|
||||
#include "common/events.h"
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
enum {
|
||||
KEY_CTRL_A = (Common::KBD_CTRL << 16) | Common::KEYCODE_a,
|
||||
KEY_CTRL_B = (Common::KBD_CTRL << 16) | Common::KEYCODE_b,
|
||||
KEY_CTRL_C = (Common::KBD_CTRL << 16) | Common::KEYCODE_c,
|
||||
KEY_CTRL_D = (Common::KBD_CTRL << 16) | Common::KEYCODE_d,
|
||||
KEY_CTRL_E = (Common::KBD_CTRL << 16) | Common::KEYCODE_e,
|
||||
KEY_CTRL_F = (Common::KBD_CTRL << 16) | Common::KEYCODE_f,
|
||||
KEY_CTRL_G = (Common::KBD_CTRL << 16) | Common::KEYCODE_g,
|
||||
KEY_CTRL_H = (Common::KBD_CTRL << 16) | Common::KEYCODE_h,
|
||||
KEY_CTRL_I = (Common::KBD_CTRL << 16) | Common::KEYCODE_i,
|
||||
KEY_CTRL_J = (Common::KBD_CTRL << 16) | Common::KEYCODE_j,
|
||||
KEY_CTRL_K = (Common::KBD_CTRL << 16) | Common::KEYCODE_k,
|
||||
KEY_CTRL_L = (Common::KBD_CTRL << 16) | Common::KEYCODE_l,
|
||||
KEY_CTRL_M = (Common::KBD_CTRL << 16) | Common::KEYCODE_m,
|
||||
KEY_CTRL_N = (Common::KBD_CTRL << 16) | Common::KEYCODE_n,
|
||||
KEY_CTRL_O = (Common::KBD_CTRL << 16) | Common::KEYCODE_o,
|
||||
KEY_CTRL_P = (Common::KBD_CTRL << 16) | Common::KEYCODE_p,
|
||||
KEY_CTRL_Q = (Common::KBD_CTRL << 16) | Common::KEYCODE_q,
|
||||
KEY_CTRL_R = (Common::KBD_CTRL << 16) | Common::KEYCODE_r,
|
||||
KEY_CTRL_S = (Common::KBD_CTRL << 16) | Common::KEYCODE_s,
|
||||
KEY_CTRL_T = (Common::KBD_CTRL << 16) | Common::KEYCODE_t,
|
||||
KEY_CTRL_U = (Common::KBD_CTRL << 16) | Common::KEYCODE_u,
|
||||
KEY_CTRL_V = (Common::KBD_CTRL << 16) | Common::KEYCODE_v,
|
||||
KEY_CTRL_W = (Common::KBD_CTRL << 16) | Common::KEYCODE_w,
|
||||
KEY_CTRL_X = (Common::KBD_CTRL << 16) | Common::KEYCODE_x,
|
||||
KEY_CTRL_Y = (Common::KBD_CTRL << 16) | Common::KEYCODE_y,
|
||||
KEY_CTRL_Z = (Common::KBD_CTRL << 16) | Common::KEYCODE_z,
|
||||
|
||||
KEY_ALT_A = (Common::KBD_ALT << 16) | Common::KEYCODE_a,
|
||||
KEY_ALT_B = (Common::KBD_ALT << 16) | Common::KEYCODE_b,
|
||||
KEY_ALT_C = (Common::KBD_ALT << 16) | Common::KEYCODE_c,
|
||||
KEY_ALT_D = (Common::KBD_ALT << 16) | Common::KEYCODE_d,
|
||||
KEY_ALT_E = (Common::KBD_ALT << 16) | Common::KEYCODE_e,
|
||||
KEY_ALT_F = (Common::KBD_ALT << 16) | Common::KEYCODE_f,
|
||||
KEY_ALT_G = (Common::KBD_ALT << 16) | Common::KEYCODE_g,
|
||||
KEY_ALT_H = (Common::KBD_ALT << 16) | Common::KEYCODE_h,
|
||||
KEY_ALT_I = (Common::KBD_ALT << 16) | Common::KEYCODE_i,
|
||||
KEY_ALT_J = (Common::KBD_ALT << 16) | Common::KEYCODE_j,
|
||||
KEY_ALT_K = (Common::KBD_ALT << 16) | Common::KEYCODE_k,
|
||||
KEY_ALT_L = (Common::KBD_ALT << 16) | Common::KEYCODE_l,
|
||||
KEY_ALT_M = (Common::KBD_ALT << 16) | Common::KEYCODE_m,
|
||||
KEY_ALT_N = (Common::KBD_ALT << 16) | Common::KEYCODE_n,
|
||||
KEY_ALT_O = (Common::KBD_ALT << 16) | Common::KEYCODE_o,
|
||||
KEY_ALT_P = (Common::KBD_ALT << 16) | Common::KEYCODE_p,
|
||||
KEY_ALT_Q = (Common::KBD_ALT << 16) | Common::KEYCODE_q,
|
||||
KEY_ALT_R = (Common::KBD_ALT << 16) | Common::KEYCODE_r,
|
||||
KEY_ALT_S = (Common::KBD_ALT << 16) | Common::KEYCODE_s,
|
||||
KEY_ALT_T = (Common::KBD_ALT << 16) | Common::KEYCODE_t,
|
||||
KEY_ALT_U = (Common::KBD_ALT << 16) | Common::KEYCODE_u,
|
||||
KEY_ALT_V = (Common::KBD_ALT << 16) | Common::KEYCODE_v,
|
||||
KEY_ALT_W = (Common::KBD_ALT << 16) | Common::KEYCODE_w,
|
||||
KEY_ALT_X = (Common::KBD_ALT << 16) | Common::KEYCODE_x,
|
||||
KEY_ALT_Y = (Common::KBD_ALT << 16) | Common::KEYCODE_y,
|
||||
KEY_ALT_Z = (Common::KBD_ALT << 16) | Common::KEYCODE_z,
|
||||
|
||||
KEY_ALT_0 = (Common::KBD_ALT << 16) | Common::KEYCODE_0,
|
||||
KEY_ALT_1 = (Common::KBD_ALT << 16) | Common::KEYCODE_1,
|
||||
KEY_ALT_2 = (Common::KBD_ALT << 16) | Common::KEYCODE_2,
|
||||
KEY_ALT_3 = (Common::KBD_ALT << 16) | Common::KEYCODE_3,
|
||||
KEY_ALT_4 = (Common::KBD_ALT << 16) | Common::KEYCODE_4,
|
||||
KEY_ALT_5 = (Common::KBD_ALT << 16) | Common::KEYCODE_5,
|
||||
KEY_ALT_6 = (Common::KBD_ALT << 16) | Common::KEYCODE_6,
|
||||
KEY_ALT_7 = (Common::KBD_ALT << 16) | Common::KEYCODE_7,
|
||||
KEY_ALT_8 = (Common::KBD_ALT << 16) | Common::KEYCODE_8,
|
||||
KEY_ALT_9 = (Common::KBD_ALT << 16) | Common::KEYCODE_9,
|
||||
|
||||
KEY_PAD_MINUS = Common::KEYCODE_KP_MINUS,
|
||||
KEY_PAD_PLUS = Common::KEYCODE_KP_PLUS,
|
||||
KEY_PAD_TIMES = Common::KEYCODE_KP_MULTIPLY,
|
||||
KEY_PAD_DIVIDE = Common::KEYCODE_KP_DIVIDE,
|
||||
};
|
||||
|
||||
enum {
|
||||
KEY_PAGE_UP = Common::KEYCODE_PAGEUP,
|
||||
KEY_PAGE_DOWN = Common::KEYCODE_PAGEDOWN,
|
||||
KEY_HOME = Common::KEYCODE_HOME,
|
||||
KEY_END = Common::KEYCODE_END,
|
||||
KEY_DELETE = Common::KEYCODE_DELETE,
|
||||
KEY_BACKSP = Common::KEYCODE_BACKSPACE,
|
||||
KEY_TAB = Common::KEYCODE_TAB,
|
||||
KEY_SHFTTAB = (Common::KBD_SHIFT << 16) | Common::KEYCODE_TAB,
|
||||
KEY_RETURN = Common::KEYCODE_RETURN,
|
||||
KEY_ESCAPE = Common::KEYCODE_ESCAPE,
|
||||
KEY_SPACE = Common::KEYCODE_SPACE,
|
||||
KEY_CLEAR = Common::KEYCODE_CLEAR,
|
||||
|
||||
KEY_LEFT = Common::KEYCODE_LEFT,
|
||||
KEY_RIGHT = Common::KEYCODE_RIGHT,
|
||||
KEY_UP = Common::KEYCODE_UP,
|
||||
KEY_DOWN = Common::KEYCODE_DOWN,
|
||||
|
||||
KEY_ALT_UP = (Common::KBD_ALT << 16) | Common::KEYCODE_UP,
|
||||
KEY_ALT_DOWN = (Common::KBD_ALT << 16) | Common::KEYCODE_DOWN,
|
||||
KEY_ALT_LEFT = (Common::KBD_ALT << 16) | Common::KEYCODE_LEFT,
|
||||
KEY_ALT_RIGHT = (Common::KBD_ALT << 16) | Common::KEYCODE_RIGHT,
|
||||
|
||||
KEY_CTRL_UP = (Common::KBD_CTRL << 16) | Common::KEYCODE_UP,
|
||||
KEY_CTRL_DOWN = (Common::KBD_CTRL << 16) | Common::KEYCODE_DOWN,
|
||||
KEY_CTRL_LEFT = (Common::KBD_CTRL << 16) | Common::KEYCODE_LEFT,
|
||||
KEY_CTRL_RIGHT = (Common::KBD_CTRL << 16) | Common::KEYCODE_RIGHT,
|
||||
|
||||
KEY_F1 = Common::KEYCODE_F1,
|
||||
KEY_F2 = Common::KEYCODE_F2,
|
||||
KEY_F3 = Common::KEYCODE_F3,
|
||||
KEY_F4 = Common::KEYCODE_F4,
|
||||
|
||||
KEY_F5 = Common::KEYCODE_F5,
|
||||
KEY_F6 = Common::KEYCODE_F6,
|
||||
KEY_F7 = Common::KEYCODE_F7,
|
||||
KEY_F8 = Common::KEYCODE_F8,
|
||||
KEY_F9 = Common::KEYCODE_F9,
|
||||
KEY_F10 = Common::KEYCODE_F10,
|
||||
KEY_F11 = Common::KEYCODE_F11,
|
||||
KEY_F12 = Common::KEYCODE_F12
|
||||
};
|
||||
|
||||
} // namespace M4
|
||||
|
||||
#endif
|
||||
272
engines/m4/platform/sound/digi.cpp
Normal file
272
engines/m4/platform/sound/digi.cpp
Normal file
@@ -0,0 +1,272 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "audio/audiostream.h"
|
||||
#include "audio/mixer.h"
|
||||
#include "audio/decoders/raw.h"
|
||||
#include "m4/platform/sound/digi.h"
|
||||
#include "m4/adv_r/adv_file.h"
|
||||
#include "m4/core/imath.h"
|
||||
#include "m4/fileio/extensions.h"
|
||||
#include "m4/vars.h"
|
||||
#include "m4/m4.h"
|
||||
|
||||
namespace M4 {
|
||||
namespace Sound {
|
||||
|
||||
Digi::~Digi() {
|
||||
unload_sounds();
|
||||
}
|
||||
|
||||
void Digi::loadFootstepSounds(const char **names) {
|
||||
if (!_sounds.empty())
|
||||
unload_sounds();
|
||||
|
||||
if (names) {
|
||||
for (; *names; ++names)
|
||||
preload(*names, true, NOWHERE);
|
||||
}
|
||||
}
|
||||
|
||||
void Digi::unload_sounds() {
|
||||
_mixer->stopAll();
|
||||
|
||||
for (auto it = _sounds.begin(); it != _sounds.end(); ++it) {
|
||||
rtoss(it->_value._filename);
|
||||
free(it->_value._data);
|
||||
}
|
||||
|
||||
_sounds.clear();
|
||||
}
|
||||
|
||||
bool Digi::preload(const Common::String &name, bool isFootsteps, int roomNum) {
|
||||
MemHandle workHandle;
|
||||
int32 assetSize;
|
||||
|
||||
if (_sounds.contains(name))
|
||||
return true;
|
||||
|
||||
// Load in the sound
|
||||
Common::String fileName = expand_name_2_RAW(name, roomNum);
|
||||
if ((workHandle = rget(fileName, &assetSize)) == nullptr)
|
||||
error("Could not find sound - %s", fileName.c_str());
|
||||
|
||||
HLock(workHandle);
|
||||
const byte *pSrc = (byte *)*workHandle;
|
||||
byte *pDest = (byte *)malloc(assetSize);
|
||||
Common::copy(pSrc, pSrc + assetSize, pDest);
|
||||
|
||||
HUnLock(workHandle);
|
||||
|
||||
_sounds[name] = DigiEntry(fileName, pDest, assetSize);
|
||||
_sounds[name]._isFootsteps = isFootsteps;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Digi::unload(const Common::String &name) {
|
||||
if (_sounds.contains(name)) {
|
||||
// Stop it if it's playing
|
||||
for (int channel = 0; channel < MAX_CHANNELS; ++channel) {
|
||||
if (_channels[channel]._name == name)
|
||||
stop(channel, true);
|
||||
}
|
||||
|
||||
// Remove the underlying resource
|
||||
if (!_sounds[name]._filename.empty() && !_sounds[name]._isFootsteps) {
|
||||
rtoss(_sounds[name]._filename);
|
||||
_sounds[name]._filename.clear();
|
||||
|
||||
// Delete the sound entry
|
||||
free(_sounds[name]._data);
|
||||
_sounds.erase(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Digi::task() {
|
||||
// No implementation
|
||||
}
|
||||
|
||||
int32 Digi::play(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num) {
|
||||
return play(name, channel, vol, trigger, room_num, false);
|
||||
}
|
||||
|
||||
int32 Digi::play_loop(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num) {
|
||||
return play(name, channel, vol, trigger, room_num, true);
|
||||
}
|
||||
|
||||
int32 Digi::play(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num, bool loop) {
|
||||
assert(channel < 4);
|
||||
|
||||
// Assure no prior sound for the channel is playing
|
||||
stop(channel);
|
||||
|
||||
if (!loop)
|
||||
g_engine->drawSubtitle(name);
|
||||
|
||||
// Load in the new sound
|
||||
preload(name, false, room_num);
|
||||
DigiEntry &entry = _sounds[name];
|
||||
Channel &c = _channels[channel];
|
||||
|
||||
// Create new audio stream
|
||||
Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
|
||||
Audio::makeRawStream(entry._data, entry._size, 11025, Audio::FLAG_UNSIGNED,
|
||||
DisposeAfterUse::NO),
|
||||
loop ? 0 : 1);
|
||||
_mixer->playStream(Audio::Mixer::kSFXSoundType, &c._soundHandle, stream,
|
||||
-1, vol);
|
||||
|
||||
if (trigger < 0 || trigger > 32767)
|
||||
trigger = -1;
|
||||
c._trigger = kernel_trigger_create(trigger);
|
||||
c._name = name;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Digi::playFootsteps() {
|
||||
// Get a list of the walking sounds
|
||||
Common::Array<Common::String> names;
|
||||
|
||||
for (auto it = _sounds.begin(); it != _sounds.end(); ++it) {
|
||||
if (it->_value._isFootsteps)
|
||||
names.push_back(it->_key);
|
||||
}
|
||||
|
||||
if (!names.empty()) {
|
||||
play(names[imath_ranged_rand(0, (int)names.size() - 1)].c_str(),
|
||||
1, 100, NO_TRIGGER, GLOBAL_SCENE);
|
||||
}
|
||||
}
|
||||
|
||||
void Digi::stop(uint channel, bool calledFromUnload) {
|
||||
assert(channel < 4);
|
||||
|
||||
Channel &c = _channels[channel];
|
||||
if (!c._name.empty()) {
|
||||
Common::String name = c._name;
|
||||
|
||||
_mixer->stopHandle(c._soundHandle);
|
||||
c._trigger = -1;
|
||||
c._name.clear();
|
||||
g_engine->clearSubtitle();
|
||||
|
||||
if (!calledFromUnload) {
|
||||
digi_unload(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Digi::flush_mem() {
|
||||
unload_sounds();
|
||||
}
|
||||
|
||||
void Digi::read_another_chunk() {
|
||||
// For ScummVM, the audio data is completely loaded for each sound. But we still
|
||||
// need to check whether a sound has finished so it's trigger can be dispatched
|
||||
for (int channel = 0; channel < MAX_CHANNELS; ++channel) {
|
||||
Channel &c = _channels[channel];
|
||||
|
||||
// Check if the channel has a sound playing that finished
|
||||
if (c._trigger != -1 && !_mixer->isSoundHandleActive(c._soundHandle)) {
|
||||
int trigger = c._trigger;
|
||||
c._trigger = -1;
|
||||
stop(channel);
|
||||
|
||||
// Dispatch the trigger
|
||||
kernel_trigger_dispatchx(trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Digi::play_state(int channel) const {
|
||||
return _mixer->isSoundHandleActive(_channels[channel]._soundHandle);
|
||||
}
|
||||
|
||||
void Digi::change_volume(int channel, int vol) {
|
||||
_mixer->setChannelVolume(_channels[channel]._soundHandle, vol);
|
||||
}
|
||||
|
||||
int32 Digi::ticks_to_play(const char *name, int roomNum) {
|
||||
// Get the file and retrieve it's size
|
||||
Common::String filename = expand_name_2_RAW(name, roomNum);
|
||||
SysFile sf(filename);
|
||||
double size = sf.size();
|
||||
sf.close();
|
||||
|
||||
term_message(" digi_ticks_to_play");
|
||||
term_message(" %s", filename.c_str());
|
||||
term_message(" size = %f, room = %d", size, roomNum);
|
||||
|
||||
return (int32)floor(size * 0.000090702946 * 60.0);
|
||||
}
|
||||
|
||||
void Digi::change_panning(int val1, int val2) {
|
||||
if (_G(game).room_id != _panningTodoRoom) {
|
||||
_panningTodoRoom = _G(game).room_id;
|
||||
warning("TODO: digi_change_panning");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Sound
|
||||
|
||||
bool digi_preload(const Common::String &name, int roomNum) {
|
||||
return _G(digi).preload(name, false, roomNum);
|
||||
}
|
||||
|
||||
void digi_unload(const Common::String &name) {
|
||||
_G(digi).unload(name);
|
||||
}
|
||||
|
||||
int32 digi_play(const char *name, uint channel, int32 vol, int32 trigger, int32 room_num) {
|
||||
return _G(digi).play(name, channel, vol, trigger, room_num);
|
||||
}
|
||||
|
||||
int32 digi_play_loop(const char *name, uint channel, int32 vol, int32 trigger, int32 room_num) {
|
||||
return _G(digi).play_loop(name, channel, vol, trigger, room_num);
|
||||
}
|
||||
|
||||
void digi_read_another_chunk() {
|
||||
return _G(digi).read_another_chunk();
|
||||
}
|
||||
|
||||
void digi_stop(int slot) {
|
||||
_G(digi).stop(slot);
|
||||
}
|
||||
|
||||
bool digi_play_state(int channel) {
|
||||
return _G(digi).play_state(channel);
|
||||
}
|
||||
|
||||
void digi_change_volume(int channel, int vol) {
|
||||
_G(digi).change_volume(channel, vol);
|
||||
}
|
||||
|
||||
int32 digi_ticks_to_play(const char *name, int roomNum) {
|
||||
return _G(digi).ticks_to_play(name, roomNum);
|
||||
}
|
||||
|
||||
void digi_change_panning(int val1, int val2) {
|
||||
_G(digi).change_panning(val1, val2);
|
||||
}
|
||||
|
||||
} // namespace M4
|
||||
126
engines/m4/platform/sound/digi.h
Normal file
126
engines/m4/platform/sound/digi.h
Normal file
@@ -0,0 +1,126 @@
|
||||
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_SOUND_DIGI_H
|
||||
#define M4_PLATFORM_SOUND_DIGI_H
|
||||
|
||||
#include "audio/mixer.h"
|
||||
#include "audio/audiostream.h"
|
||||
#include "common/hashmap.h"
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
namespace M4 {
|
||||
namespace Sound {
|
||||
|
||||
#define MAX_CHANNELS 4
|
||||
|
||||
/**
|
||||
* M4 Digital player digivolves to ScummVM-digital player
|
||||
*/
|
||||
class Digi {
|
||||
/**
|
||||
* Digital sound entry
|
||||
*/
|
||||
struct DigiEntry {
|
||||
Common::String _filename;
|
||||
byte *_data = nullptr;
|
||||
size_t _size = 0;
|
||||
bool _isFootsteps = false;
|
||||
DigiEntry() {}
|
||||
DigiEntry(Common::String &name, byte *data, size_t size) :
|
||||
_filename(name), _data(data), _size(size) {}
|
||||
};
|
||||
/**
|
||||
* Sound channel
|
||||
*/
|
||||
struct Channel {
|
||||
Audio::SoundHandle _soundHandle;
|
||||
int _trigger = -1;
|
||||
Common::String _name;
|
||||
};
|
||||
private:
|
||||
Audio::Mixer *_mixer;
|
||||
Channel _channels[4];
|
||||
Common::HashMap<Common::String, DigiEntry> _sounds;
|
||||
int _panningTodoRoom = 0;
|
||||
|
||||
int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger,
|
||||
int32 room_num, bool loop);
|
||||
|
||||
public:
|
||||
Digi(Audio::Mixer *mixer) : _mixer(mixer) {}
|
||||
~Digi();
|
||||
|
||||
/**
|
||||
* Preload a digi sample into memory buffer for play back later.
|
||||
*/
|
||||
bool preload(const Common::String &name, bool isFootsteps, int roomNum = -1);
|
||||
|
||||
/**
|
||||
* A room can designate one or more sounds to be randomly played when
|
||||
* the player walks around
|
||||
*/
|
||||
void loadFootstepSounds(const char **names);
|
||||
|
||||
void unload_sounds();
|
||||
void unload(const Common::String &name);
|
||||
void task();
|
||||
|
||||
// digi_play and digi_play_loop play a particular sound file in a given channel,
|
||||
// at a particular volume. The room_num parameter tells us what directory the sound
|
||||
// is stored in (all sounds are AIFFs). Trigger is an integer that is fed into
|
||||
// kernel_dispatch_trigger when the sound has finished playing
|
||||
// If the sound has been preloaded it will be played from memory, otherwise it will
|
||||
// be streamed from disk
|
||||
|
||||
int32 play(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
|
||||
int32 play_loop(const Common::String &name, uint channel, int32 vol, int32 trigger, int32 room_num = -1);
|
||||
void playFootsteps();
|
||||
void stop(uint channel, bool calledFromUnload = false);
|
||||
void flush_mem();
|
||||
|
||||
void read_another_chunk();
|
||||
bool play_state(int channel) const;
|
||||
void change_volume(int channel, int vol);
|
||||
|
||||
int32 ticks_to_play(const char *name, int roomNum = -1);
|
||||
void change_panning(int val1, int val2);
|
||||
};
|
||||
|
||||
} // namespace Sound
|
||||
|
||||
bool digi_preload(const Common::String &name, int roomNum = -1);
|
||||
void digi_unload(const Common::String &name);
|
||||
int32 digi_play(const char *name, uint channel, int32 vol = 255,
|
||||
int32 trigger = -1, int32 room_num = -1);
|
||||
int32 digi_play_loop(const char *name, uint channel, int32 vol = 255,
|
||||
int32 trigger = -1, int32 room_num = -1);
|
||||
void digi_read_another_chunk();
|
||||
void digi_stop(int channel);
|
||||
bool digi_play_state(int channel);
|
||||
void digi_change_volume(int channel, int vol);
|
||||
int32 digi_ticks_to_play(const char *name, int roomNum = -1);
|
||||
void digi_change_panning(int val1, int val2);
|
||||
|
||||
} // namespace M4
|
||||
|
||||
#endif
|
||||
310
engines/m4/platform/sound/midi.cpp
Normal file
310
engines/m4/platform/sound/midi.cpp
Normal file
@@ -0,0 +1,310 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "m4/platform/sound/midi.h"
|
||||
#include "m4/adv_r/adv_file.h"
|
||||
#include "m4/vars.h"
|
||||
|
||||
#include "common/config-manager.h"
|
||||
#include "audio/adlib_hmisos.h"
|
||||
#include "audio/adlib_ms.h"
|
||||
#include "audio/fmopl.h"
|
||||
#include "audio/midiparser.h"
|
||||
#include "audio/midiparser_hmp.h"
|
||||
#include "audio/mt32gm.h"
|
||||
|
||||
namespace M4 {
|
||||
namespace Sound {
|
||||
|
||||
int Midi::_midiEndTrigger;
|
||||
|
||||
Midi::Midi() {
|
||||
_driver = nullptr;
|
||||
_paused = false;
|
||||
_deviceType = MT_NULL;
|
||||
_midiParser = nullptr;
|
||||
_midiData = nullptr;
|
||||
}
|
||||
|
||||
Midi::~Midi() {
|
||||
stop();
|
||||
|
||||
if (_driver != nullptr) {
|
||||
_driver->setTimerCallback(nullptr, nullptr);
|
||||
_driver->close();
|
||||
}
|
||||
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (_midiParser != nullptr)
|
||||
delete _midiParser;
|
||||
if (_midiData != nullptr)
|
||||
delete[] _midiData;
|
||||
if (_driver != nullptr) {
|
||||
delete _driver;
|
||||
_driver = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
int Midi::open() {
|
||||
assert(_driver == nullptr);
|
||||
|
||||
// Check the type of device that the user has configured.
|
||||
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
|
||||
_deviceType = MidiDriver::getMusicType(dev);
|
||||
if (_deviceType == MT_GM && ConfMan.getBool("native_mt32"))
|
||||
_deviceType = MT_MT32;
|
||||
|
||||
OPL::Config::OplType oplType;
|
||||
switch (_deviceType) {
|
||||
case MT_ADLIB:
|
||||
oplType = MidiDriver_ADLIB_HMISOS::detectOplType(OPL::Config::kOpl3) ? OPL::Config::kOpl3 : OPL::Config::kOpl2;
|
||||
MidiDriver_ADLIB_HMISOS *adLibDriver;
|
||||
adLibDriver = new MidiDriver_ADLIB_HMISOS(oplType);
|
||||
_driver = adLibDriver;
|
||||
|
||||
Common::SeekableReadStream *instrumentBankStream;
|
||||
instrumentBankStream = SearchMan.createReadStreamForMember(Common::Path("MELODIC.BNK"));
|
||||
Common::SeekableReadStream *rhythmBankStream;
|
||||
rhythmBankStream = SearchMan.createReadStreamForMember(Common::Path("DRUM.BNK"));
|
||||
|
||||
adLibDriver->loadInstrumentBanks(instrumentBankStream, rhythmBankStream);
|
||||
|
||||
break;
|
||||
case MT_GM:
|
||||
case MT_MT32:
|
||||
_driver = new MidiDriver_MT32GM(MusicType::MT_GM);
|
||||
break;
|
||||
default:
|
||||
_driver = new MidiDriver_NULL_Multisource();
|
||||
break;
|
||||
}
|
||||
|
||||
_midiParser = new MidiParser_HMP(0);
|
||||
|
||||
_driver->property(MidiDriver::PROP_USER_VOLUME_SCALING, true);
|
||||
// Riddle's MIDI data does not consistently set values for every controller
|
||||
// at the start of every track
|
||||
_driver->setControllerDefault(MidiDriver_Multisource::CONTROLLER_DEFAULT_PITCH_BEND);
|
||||
_driver->setControllerDefault(MidiDriver_Multisource::CONTROLLER_DEFAULT_MODULATION);
|
||||
_driver->setControllerDefault(MidiDriver_Multisource::CONTROLLER_DEFAULT_PANNING);
|
||||
_driver->setControllerDefault(MidiDriver_Multisource::CONTROLLER_DEFAULT_REVERB);
|
||||
_driver->setControllerDefault(MidiDriver_Multisource::CONTROLLER_DEFAULT_CHORUS);
|
||||
|
||||
_midiParser->property(MidiParser::mpDisableAutoStartPlayback, true);
|
||||
// Riddle's MIDI data uses sustain
|
||||
_midiParser->property(MidiParser::mpSendSustainOffOnNotesOff, true);
|
||||
|
||||
// Open the MIDI driver.
|
||||
int returnCode = _driver->open();
|
||||
if (returnCode != 0)
|
||||
error("Midi::open - Failed to open MIDI music driver - error code %d.", returnCode);
|
||||
|
||||
syncSoundSettings();
|
||||
|
||||
// Connect the driver and the parser.
|
||||
_midiParser->setMidiDriver(_driver);
|
||||
_midiParser->setTimerRate(_driver->getBaseTempo());
|
||||
_driver->setTimerCallback(this, &onTimer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Midi::load(byte* in, int32 size) {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (_midiParser == nullptr)
|
||||
return;
|
||||
|
||||
_midiParser->unloadMusic();
|
||||
|
||||
if (_midiData != nullptr)
|
||||
delete[] _midiData;
|
||||
_midiData = new byte[size];
|
||||
|
||||
Common::copy(in, in + size, _midiData);
|
||||
|
||||
_midiParser->loadMusic(_midiData, size);
|
||||
}
|
||||
|
||||
void Midi::play() {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (_midiParser == nullptr || _driver == nullptr)
|
||||
return;
|
||||
|
||||
_midiParser->startPlaying();
|
||||
}
|
||||
|
||||
void Midi::pause(bool pause) {
|
||||
if (_paused == pause || _driver == nullptr)
|
||||
return;
|
||||
|
||||
_paused = pause;
|
||||
|
||||
if (_midiParser != nullptr) {
|
||||
Common::StackLock lock(_mutex);
|
||||
if (_paused) {
|
||||
_midiParser->pausePlaying();
|
||||
} else {
|
||||
_midiParser->resumePlaying();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Midi::stop() {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
if (_midiParser != nullptr) {
|
||||
_midiParser->stopPlaying();
|
||||
if (_driver != nullptr)
|
||||
_driver->deinitSource(0);
|
||||
}
|
||||
}
|
||||
|
||||
bool Midi::isPlaying() {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
return _midiParser->isPlaying();
|
||||
}
|
||||
|
||||
void Midi::startFade(uint16 duration, uint16 targetVolume) {
|
||||
if (_driver == nullptr || _midiParser == nullptr || !_midiParser->isPlaying())
|
||||
return;
|
||||
|
||||
_driver->startFade(0, duration, targetVolume);
|
||||
}
|
||||
|
||||
bool Midi::isFading() {
|
||||
return _driver->isFading(0);
|
||||
}
|
||||
|
||||
void Midi::syncSoundSettings() {
|
||||
if (_driver != nullptr)
|
||||
_driver->syncSoundSettings();
|
||||
}
|
||||
|
||||
void Midi::midi_play(const char *name, int volume, bool loop, int trigger, int roomNum) {
|
||||
if (_driver == nullptr || _midiParser == nullptr)
|
||||
return;
|
||||
|
||||
_midiEndTrigger = trigger;
|
||||
|
||||
// Load in the resource
|
||||
Common::String fileName = expand_name_2_HMP(name, roomNum);
|
||||
int32 assetSize;
|
||||
MemHandle workHandle = rget(fileName, &assetSize);
|
||||
if (workHandle == nullptr)
|
||||
error("Could not find music - %s", fileName.c_str());
|
||||
|
||||
HLock(workHandle);
|
||||
/*
|
||||
Common::DumpFile dump;
|
||||
dump.open(fileName.c_str());
|
||||
dump.write(*workHandle, assetSize);
|
||||
dump.close();
|
||||
*/
|
||||
|
||||
load((byte *)*workHandle, assetSize);
|
||||
_midiParser->setTrack(0);
|
||||
_midiParser->property(MidiParser::mpAutoLoop, loop ? 1 : 0);
|
||||
// TODO Some calls use volume 0? What is that supposed to do?
|
||||
_driver->setSourceVolume(0, volume);
|
||||
|
||||
play();
|
||||
|
||||
/*
|
||||
#ifdef TODO
|
||||
byte *pSrc = (byte *)*workHandle;
|
||||
|
||||
MidiParser *parser = MidiParser::createParser_SMF();
|
||||
bool loaded = parser->loadMusic(pSrc, assetSize);
|
||||
|
||||
if (loaded) {
|
||||
stop();
|
||||
parser->setTrack(0);
|
||||
parser->setMidiDriver(this);
|
||||
parser->setTimerRate(_driver->getBaseTempo());
|
||||
parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1);
|
||||
|
||||
_parser = parser;
|
||||
_isLooping = false;
|
||||
_isPlaying = true;
|
||||
}
|
||||
#else
|
||||
// TODO: When music is properly implemented, trigger when music done
|
||||
if (trigger != -1)
|
||||
kernel_timing_trigger(10, trigger);
|
||||
#endif
|
||||
*/
|
||||
|
||||
HUnLock(workHandle);
|
||||
rtoss(fileName);
|
||||
}
|
||||
|
||||
void Midi::task() {
|
||||
// No implementation
|
||||
}
|
||||
|
||||
void Midi::loop() {
|
||||
// No implementation
|
||||
}
|
||||
|
||||
void Midi::midi_fade_volume(int targetVolume, int duration) {
|
||||
uint16 durationMsec = duration * 1000 / 30;
|
||||
startFade(durationMsec, targetVolume);
|
||||
// TODO Should this stop playback when fade is completed?
|
||||
// Should this call return after the fade has completed?
|
||||
}
|
||||
|
||||
void Midi::onTimer(void* data) {
|
||||
Midi *m = (Midi *)data;
|
||||
Common::StackLock lock(m->_mutex);
|
||||
|
||||
if (m->_midiParser != nullptr) {
|
||||
m->_midiParser->onTimer();
|
||||
if (!m->_midiParser->isPlaying() && _midiEndTrigger >= 0) {
|
||||
// FIXME Can this trigger a deadlock on the mutex?
|
||||
kernel_timing_trigger(10, _midiEndTrigger);
|
||||
_midiEndTrigger = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Sound
|
||||
|
||||
void midi_play(const char *name, int volume, bool loop, int trigger, int roomNum) {
|
||||
_G(midi).midi_play(name, volume, loop, trigger, roomNum);
|
||||
}
|
||||
|
||||
void midi_loop() {
|
||||
_G(midi).loop();
|
||||
}
|
||||
|
||||
void midi_stop() {
|
||||
_G(midi).stop();
|
||||
}
|
||||
|
||||
void midi_fade_volume(int targetVolume, int duration) {
|
||||
_G(midi).midi_fade_volume(targetVolume, duration);
|
||||
}
|
||||
|
||||
} // namespace M4
|
||||
82
engines/m4/platform/sound/midi.h
Normal file
82
engines/m4/platform/sound/midi.h
Normal file
@@ -0,0 +1,82 @@
|
||||
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_SOUND_PLATFORM_MIDI_H
|
||||
#define M4_SOUND_PLATFORM_MIDI_H
|
||||
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
#include "audio/mididrv_ms.h"
|
||||
#include "audio/midiparser.h"
|
||||
|
||||
namespace M4 {
|
||||
namespace Sound {
|
||||
|
||||
class Midi {
|
||||
private:
|
||||
static int _midiEndTrigger;
|
||||
|
||||
Common::Mutex _mutex;
|
||||
|
||||
MusicType _deviceType;
|
||||
|
||||
MidiDriver_Multisource *_driver;
|
||||
MidiParser *_midiParser;
|
||||
byte *_midiData;
|
||||
|
||||
bool _paused;
|
||||
|
||||
protected:
|
||||
static void onTimer(void *data);
|
||||
|
||||
public:
|
||||
Midi();
|
||||
~Midi();
|
||||
|
||||
int open();
|
||||
|
||||
void load(byte *in, int32 size);
|
||||
void play();
|
||||
void pause(bool pause);
|
||||
void stop();
|
||||
bool isPlaying();
|
||||
void startFade(uint16 duration, uint16 targetVolume);
|
||||
bool isFading();
|
||||
|
||||
void syncSoundSettings();
|
||||
|
||||
void midi_play(const char *name, int volume, bool loop, int trigger, int roomNum);
|
||||
void task();
|
||||
void loop();
|
||||
void midi_fade_volume(int targetVolume, int duration);
|
||||
};
|
||||
|
||||
} // namespace Sound
|
||||
|
||||
void midi_play(const char *name, int volume, bool loop, int trigger, int roomNum);
|
||||
void midi_loop();
|
||||
void midi_stop();
|
||||
void midi_fade_volume(int targetVolume, int duration);
|
||||
|
||||
} // namespace M4
|
||||
|
||||
#endif
|
||||
111
engines/m4/platform/tile/tile_read.cpp
Normal file
111
engines/m4/platform/tile/tile_read.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "m4/platform/tile/tile_read.h"
|
||||
#include "m4/core/errors.h"
|
||||
#include "m4/graphics/gr_buff.h"
|
||||
#include "m4/mem/memman.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
void tt_read_header(SysFile *ifp, int32 *file_x, int32 *file_y,
|
||||
int32 *num_x_tiles, int32 *num_y_tiles, int32 *tile_x, int32 *tile_y, RGB8 *pal) {
|
||||
int32 value;
|
||||
|
||||
// Initalize return parameters
|
||||
*num_x_tiles = 0;
|
||||
*num_y_tiles = 0;
|
||||
*tile_x = 0;
|
||||
*tile_y = 0;
|
||||
*file_x = 0;
|
||||
*file_y = 0;
|
||||
|
||||
// Open file
|
||||
if (!ifp->exists())
|
||||
error_show(FL, 'FNF!', ".TT file");
|
||||
|
||||
ifp->readUint32LE(); // skip chunk ID
|
||||
ifp->readUint32LE(); // skip chunk size
|
||||
|
||||
*file_x = ifp->readSint32LE();
|
||||
*file_y = ifp->readSint32LE();
|
||||
*num_x_tiles = ifp->readSint32LE();
|
||||
*num_y_tiles = ifp->readSint32LE();
|
||||
*tile_x = ifp->readSint32LE();
|
||||
*tile_y = ifp->readSint32LE();
|
||||
|
||||
// Write color table
|
||||
for (int i = 0; i < 256; i++) {
|
||||
value = ifp->readSint32LE();
|
||||
|
||||
pal[i].r = (value >> 16) & 0x0ff;
|
||||
pal[i].g = (value >> 8) & 0x0ff;
|
||||
pal[i].b = (value) & 0x0ff;
|
||||
}
|
||||
}
|
||||
|
||||
Buffer *tt_read(SysFile *ifp, int index, int32 tile_x, int32 tile_y) {
|
||||
int32 tile_size;
|
||||
int offset;
|
||||
Buffer *out = (Buffer *)mem_alloc(sizeof(Buffer), "tile buffer");
|
||||
|
||||
if (!out)
|
||||
error_show(FL, 'OOM!', "fail to allocate mem for buffer structure");
|
||||
|
||||
out->data = nullptr;
|
||||
out->w = 0;
|
||||
out->stride = 0;
|
||||
out->h = 0;
|
||||
|
||||
// Check parameters
|
||||
if (index < 0)
|
||||
error_show(FL, 'TILI');
|
||||
|
||||
tile_size = tile_x * tile_y;
|
||||
|
||||
if (index == 0) {
|
||||
// First tile data
|
||||
if (!ifp->exists())
|
||||
error_show(FL, 'FNF!', ".TT file");
|
||||
|
||||
// Read data of tiles to file
|
||||
offset = index * tile_size + 256 * 4 + 32; // Get rid of color table and header stuff
|
||||
ifp->seek((uint32)offset);
|
||||
}
|
||||
|
||||
gr_buffer_init(out, "back tile", tile_x, tile_y);
|
||||
if (out->data == nullptr) {
|
||||
out->w = 0;
|
||||
out->stride = 0;
|
||||
out->h = 0;
|
||||
error_show(FL, 'OOM!', "fail to allocate mem for .TT buffer");
|
||||
return out;
|
||||
}
|
||||
|
||||
out->w = out->stride = tile_x;
|
||||
out->h = tile_y;
|
||||
|
||||
ifp->read(out->data, tile_size);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
} // End of namespace M4
|
||||
46
engines/m4/platform/tile/tile_read.h
Normal file
46
engines/m4/platform/tile/tile_read.h
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_TILE_READ_H
|
||||
#define M4_PLATFORM_TILE_READ_H
|
||||
|
||||
#include "m4/m4_types.h"
|
||||
#include "m4/fileio/sys_file.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
/**
|
||||
* Gets some information about a tt file
|
||||
*/
|
||||
void tt_read_header(SysFile *ifp, int32 *file_x, int32 *file_y,
|
||||
int32 *num_x_tiles, int32 *num_y_tiles, int32 *tile_x, int32 *tile_y, RGB8 *pal);
|
||||
|
||||
/**
|
||||
* Returns a pointer to an initialized buffer containing the image data.
|
||||
* If an error occurs, out.x contains the error number while out.y is zero,
|
||||
* and out.data is nullptr.
|
||||
*/
|
||||
Buffer *tt_read(SysFile *ifp, int index, int32 tile_x, int32 tile_y);
|
||||
|
||||
} // End of namespace M4
|
||||
|
||||
#endif
|
||||
44
engines/m4/platform/timer.cpp
Normal file
44
engines/m4/platform/timer.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common/system.h"
|
||||
#include "m4/platform/timer.h"
|
||||
#include "m4/vars.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
uint32 timer_read() {
|
||||
return g_system->getMillis() * 60 / 1000;
|
||||
}
|
||||
|
||||
uint32 timer_read_dos() {
|
||||
return g_system->getMillis() * 60 / 1000;
|
||||
}
|
||||
|
||||
uint32 timer_read_600() {
|
||||
return g_system->getMillis() * 600 / 1000;
|
||||
}
|
||||
|
||||
uint32 timer_read_60() {
|
||||
return g_system->getMillis() * 60 / 1000;
|
||||
}
|
||||
|
||||
} // End of namespace M4
|
||||
37
engines/m4/platform/timer.h
Normal file
37
engines/m4/platform/timer.h
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef M4_PLATFORM_TIMER_H
|
||||
#define M4_PLATFORM_TIMER_H
|
||||
|
||||
#include "m4/m4_types.h"
|
||||
|
||||
namespace M4 {
|
||||
|
||||
uint32 timer_read();
|
||||
uint32 timer_read_dos();
|
||||
uint32 timer_read_600();
|
||||
uint32 timer_read_60();
|
||||
|
||||
} // End of namespace M4
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user