Skip to content

Commit b9a25e5

Browse files
author
aquanull
committed
Fixed Input Display.
1 parent c148cab commit b9a25e5

File tree

1 file changed

+49
-36
lines changed

1 file changed

+49
-36
lines changed

src/common/movie.cpp

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,48 +1106,43 @@ int VBAMovieCreate(const char *filename, const char *authorInfo, uint8 startFlag
11061106

11071107
void VBAUpdateButtonPressDisplay()
11081108
{
1109-
const static char KeyMap[] = { 'A', 'B', 's', 'S', '>', '<', '^', 'v', 'R', 'L', '!', '?', '{', '}', 'v', '^' };
1110-
const static int KeyOrder[] = { 5, 6, 4, 7, 0, 1, 9, 8, 3, 2, 12, 15, 13, 14, 11, 10 }; // < ^ > v A B L R S s { = } _
1111-
// ? !
11121109
const static int KeyMaxCount = 16;
1113-
1114-
char buffer[256] = " ";
1110+
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1111+
const static char KeyMap[] = { 'A', 'B', 's', 'S', '>', '<', '^', 'v', 'R', 'L', '!', '?', '{', '}', 'v', '^' };
1112+
// < ^ > v A B L R S s M{ M^ M} Mv N? O!
1113+
const static int KeyOrder[] = { 5, 6, 4, 7, 0, 1, 9, 8, 3, 2, 12, 15, 13, 14, 11, 10 };
11151114

11161115
int which = 0;
1117-
uint32 keys = currentButtons[which];
1118-
if (Movie.state != MOVIE_STATE_NONE)
1116+
uint16 currKeys = currentButtons[which];
1117+
uint16 nextKeys = nextButtons[which];
1118+
1119+
const int BufferSize = 64;
1120+
char buffer[BufferSize] = " ";
1121+
const char whiteSpaces[] = " ";
1122+
const int whiteOffset = strlen(whiteSpaces);
1123+
#ifdef WIN32
1124+
const bool eraseAll = !theApp.inputDisplay;
1125+
char grayList[BufferSize]; // FIXME: no grey available at the moment
1126+
char colorList[BufferSize];
1127+
memset(grayList, 4, strnlen(buffer, BufferSize));
1128+
memset(colorList, 1, strnlen(buffer, BufferSize));
1129+
1130+
uint16 autoHeldKeys = eraseAll ? 0 : theApp.autoHold & BUTTON_REGULAR_RECORDING_MASK;
1131+
uint16 autoFireKeys = eraseAll ? 0 : (theApp.autoFire | theApp.autoFire2) & BUTTON_REGULAR_RECORDING_MASK;
1132+
uint16 pressedKeys = eraseAll ? 0 : currKeys;
1133+
uint16 &lastKeys = lastButtons[which];
1134+
1135+
if (!eraseAll && Movie.state != MOVIE_STATE_NONE)
11191136
{
11201137
for (int i = 0; i < KeyMaxCount; ++i)
11211138
{
11221139
int j = KeyOrder[i];
11231140
int mask = (1 << (j));
1124-
buffer[strlen(" ") + i] = ((nextButtons[which] & mask) != 0) ? KeyMap[j] : ' ';
1141+
buffer[whiteOffset + i] = ((nextKeys & mask) != 0) ? KeyMap[j] : ' ';
11251142
}
11261143
}
1127-
#ifndef WIN32
1128-
systemScreenMessage(buffer, 3, -1);
1129-
// don't bother color-coding autofire and such
1130-
for (int i = 0; i < KeyMaxCount; ++i)
1131-
{
1132-
int j = KeyOrder[i];
1133-
int mask = (1 << (j));
1134-
buffer[strlen(" ") + i] = ((keys & mask) != 0) ? KeyMap[j] : ' ';
1135-
}
1136-
systemScreenMessage(buffer, 2, -1);
1137-
#else
1138-
char grayList[64]; // FIXME: no grey available at the moment
1139-
memset(grayList, 4, strlen(buffer));
11401144
systemScreenMessage(buffer, 3, -1, grayList);
11411145

1142-
const bool eraseAll = !theApp.inputDisplay;
1143-
uint32 autoHeldKeys = eraseAll ? 0 : theApp.autoHold & BUTTON_REGULAR_RECORDING_MASK;
1144-
uint32 autoFireKeys = eraseAll ? 0 : (theApp.autoFire | theApp.autoFire2) & BUTTON_REGULAR_RECORDING_MASK;
1145-
uint32 pressedKeys = eraseAll ? 0 : keys;
1146-
uint16 &lastKeys = lastButtons[which];
1147-
1148-
char colorList[64];
1149-
memset(colorList, 1, strlen(buffer));
1150-
11511146
if (!eraseAll)
11521147
{
11531148
for (int i = 0; i < KeyMaxCount; ++i)
@@ -1157,7 +1152,7 @@ void VBAUpdateButtonPressDisplay()
11571152
bool pressed = (pressedKeys & mask) != 0;
11581153
const bool autoHeld = (autoHeldKeys & mask) != 0;
11591154
const bool autoFired = (autoFireKeys & mask) != 0;
1160-
const bool erased = (lastButtons[which] & mask) != 0 && (!pressed && !autoHeld && !autoFired);
1155+
const bool erased = (lastKeys & mask) != 0 && (!pressed && !autoHeld && !autoFired);
11611156
extern int textMethod;
11621157
if (textMethod != 2 && (autoHeld || (autoFired && !pressed) || erased))
11631158
{
@@ -1169,18 +1164,36 @@ void VBAUpdateButtonPressDisplay()
11691164
else if (erased)
11701165
colorNum += 8; // black on black
11711166

1172-
colorList[strlen(" ") + i] = colorNum;
1167+
colorList[whiteOffset + i] = colorNum;
11731168
pressed = true;
11741169
}
1175-
buffer[strlen(" ") + i] = pressed ? KeyMap[j] : ' ';
1170+
buffer[whiteOffset + i] = pressed ? KeyMap[j] : ' ';
11761171
}
11771172
}
1173+
systemScreenMessage(buffer, 2, -1, colorList);
11781174

1179-
lastKeys = keys;
1175+
lastKeys = currKeys;
11801176
lastKeys |= theApp.autoHold & BUTTON_REGULAR_RECORDING_MASK;
11811177
lastKeys |= (theApp.autoFire | theApp.autoFire2) & BUTTON_REGULAR_RECORDING_MASK;
1182-
1183-
systemScreenMessage(buffer, 2, -1, colorList);
1178+
#else
1179+
// don't bother color-coding autofire and such
1180+
if (Movie.state != MOVIE_STATE_NONE)
1181+
{
1182+
for (int i = 0; i < KeyMaxCount; ++i)
1183+
{
1184+
int j = KeyOrder[i];
1185+
int mask = (1 << (j));
1186+
buffer[strlen(whiteOffset + i] = ((nextKeys & mask) != 0) ? KeyMap[j] : ' ';
1187+
}
1188+
}
1189+
systemScreenMessage(buffer, 3, -1);
1190+
for (int i = 0; i < KeyMaxCount; ++i)
1191+
{
1192+
int j = KeyOrder[i];
1193+
int mask = (1 << (j));
1194+
buffer[whiteOffset + i] = ((currKeys & mask) != 0) ? KeyMap[j] : ' ';
1195+
}
1196+
systemScreenMessage(buffer, 2, -1);
11841197
#endif
11851198
}
11861199

0 commit comments

Comments
 (0)