aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2012-11-29 03:00:17 +0000
committerD G Turner2012-11-29 03:00:17 +0000
commita6f2703ec27f83185731942f3d3e7600826a905b (patch)
tree2507ed85a1253c129eb111d37b81b99d74909633
parentbcee44793fe1444bb08fa15e057ee254acae6bb4 (diff)
downloadscummvm-rg350-a6f2703ec27f83185731942f3d3e7600826a905b.tar.gz
scummvm-rg350-a6f2703ec27f83185731942f3d3e7600826a905b.tar.bz2
scummvm-rg350-a6f2703ec27f83185731942f3d3e7600826a905b.zip
DREAMWEB: Further cleanup to keyboard input buffer code.
Removed the buffer from being a global non-const variable. Also, the code changes should allow the buffer size to be increased by just changing the size of _keyBuffer if needed.
-rw-r--r--engines/dreamweb/dreamweb.cpp4
-rw-r--r--engines/dreamweb/dreamweb.h12
-rw-r--r--engines/dreamweb/stubs.cpp8
3 files changed, 10 insertions, 14 deletions
diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 1bcf6298b3..65df466a7b 100644
--- a/engines/dreamweb/dreamweb.cpp
+++ b/engines/dreamweb/dreamweb.cpp
@@ -397,14 +397,14 @@ Common::String DreamWebEngine::getSavegameFilename(int slot) const {
void DreamWebEngine::keyPressed(uint16 ascii) {
debug(2, "key pressed = %04x", ascii);
- uint16 in = (_bufferIn + 1) & 0x0f;
+ uint16 in = (_bufferIn + 1) % ARRAYSIZE(_keyBuffer);
uint16 out = _bufferOut;
if (in == out) {
warning("keyboard buffer is full");
return;
}
_bufferIn = in;
- DreamWeb::g_keyBuffer[in] = ascii;
+ _keyBuffer[in] = ascii;
}
void DreamWebEngine::getPalette(uint8 *data, uint start, uint count) {
diff --git a/engines/dreamweb/dreamweb.h b/engines/dreamweb/dreamweb.h
index 419f20207f..dcf6a06b7c 100644
--- a/engines/dreamweb/dreamweb.h
+++ b/engines/dreamweb/dreamweb.h
@@ -89,10 +89,6 @@ const unsigned int kNumRoomTexts = 38;
const unsigned int kNumFreeTexts = 82;
const unsigned int kNumPersonTexts = 1026;
-// Keyboard buffer. data.word(kBufferin) and data.word(kBufferout) are indexes
-// into this, making it a ring buffer
-extern uint8 g_keyBuffer[16];
-
// Engine Debug Flags
enum {
kDebugAnimation = (1 << 0),
@@ -157,6 +153,12 @@ public:
const Common::String& getSpeechDirName() { return _speechDirName; }
private:
+ // Keyboard buffer. _bufferIn and _bufferOut are indexes
+ // into this, making it a ring buffer
+ uint8 _keyBuffer[16];
+ uint16 _bufferIn;
+ uint16 _bufferOut;
+
void keyPressed(uint16 ascii);
void setSpeed(uint speed);
@@ -422,8 +424,6 @@ public:
uint8 _addToBlue;
uint16 _lastSoundReel;
Common::KeyCode _lastHardKey;
- uint16 _bufferIn;
- uint16 _bufferOut;
uint8 _blinkFrame;
uint8 _blinkCount;
uint8 _reAssesChanges;
diff --git a/engines/dreamweb/stubs.cpp b/engines/dreamweb/stubs.cpp
index cf072fa790..de21d8e3af 100644
--- a/engines/dreamweb/stubs.cpp
+++ b/engines/dreamweb/stubs.cpp
@@ -26,10 +26,6 @@
namespace DreamWeb {
-// Keyboard buffer. _bufferIn and _bufferOut are indexes
-// into this, making it a ring buffer
-uint8 g_keyBuffer[16];
-
const Room g_roomData[] = {
// location 0
{ "DREAMWEB.R00", // Ryan's apartment
@@ -2208,8 +2204,8 @@ void DreamWebEngine::readKey() {
return;
}
- bufOut = (bufOut + 1) & 15; // The buffer has size 16
- _currentKey = g_keyBuffer[bufOut];
+ bufOut = (bufOut + 1) % ARRAYSIZE(_keyBuffer);
+ _currentKey = _keyBuffer[bufOut];
_bufferOut = bufOut;
}