[Scummvm-cvs-logs] scummvm master -> a6f2703ec27f83185731942f3d3e7600826a905b

digitall dgturner at iee.org
Thu Nov 29 04:03:13 CET 2012


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
a6f2703ec2 DREAMWEB: Further cleanup to keyboard input buffer code.


Commit: a6f2703ec27f83185731942f3d3e7600826a905b
    https://github.com/scummvm/scummvm/commit/a6f2703ec27f83185731942f3d3e7600826a905b
Author: D G Turner (digitall at scummvm.org)
Date: 2012-11-28T19:00:17-08:00

Commit Message:
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.

Changed paths:
    engines/dreamweb/dreamweb.cpp
    engines/dreamweb/dreamweb.h
    engines/dreamweb/stubs.cpp



diff --git a/engines/dreamweb/dreamweb.cpp b/engines/dreamweb/dreamweb.cpp
index 1bcf629..65df466 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 419f202..dcf6a06 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 cf072fa..de21d8e 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;
 }
 






More information about the Scummvm-git-logs mailing list