rnd-20091024-1-src
[rocksndiamonds.git] / src / game_sp / Input.c
index a7ac7798d545d0038d2a881eaa5f0db87cc1c280..5271795c48a8ee35bccad43f318b9504b3bb9643 100644 (file)
@@ -24,6 +24,37 @@ DemoBufferObject DemoBuffer;
 
 int KeyScanCode7;
 
+int map_key_RND_to_SP(int key)
+{
+  if (key & KEY_BUTTON)
+  {
+    return (key & MV_UP                ? keySpaceUp    :
+           key & MV_LEFT       ? keySpaceLeft  :
+           key & MV_DOWN       ? keySpaceDown  :
+           key & MV_RIGHT      ? keySpaceRight : keySpace);
+  }
+  else
+  {
+    return (key & MV_UP                ? keyUp         :
+           key & MV_LEFT       ? keyLeft       :
+           key & MV_DOWN       ? keyDown       :
+           key & MV_RIGHT      ? keyRight      : keyNone);
+  }
+}
+
+int map_key_SP_to_RND(int key)
+{
+  return (key == keyUp         ? MV_UP                 :
+         key == keyLeft        ? MV_LEFT               :
+         key == keyDown        ? MV_DOWN               :
+         key == keyRight       ? MV_RIGHT              :
+         key == keySpaceUp     ? KEY_BUTTON | MV_UP    :
+         key == keySpaceLeft   ? KEY_BUTTON | MV_LEFT  :
+         key == keySpaceDown   ? KEY_BUTTON | MV_DOWN  :
+         key == keySpaceRight  ? KEY_BUTTON | MV_RIGHT :
+         key == keySpace       ? KEY_BUTTON            : MV_NONE);
+}
+
 void subCheckJoystick()
 {
 }
@@ -37,11 +68,23 @@ int subCheckRightMouseButton()
   return subCheckRightMouseButton;
 }
 
-int subProcessKeyboardInput()
+int subProcessKeyboardInput(byte action)
 {
   int subProcessKeyboardInput;
 
-  int LastKey;
+  static int LastKey = 0;
+
+#if 1
+
+  DemoKeyCode = map_key_RND_to_SP(action);
+
+#if 0
+    printf("::: DemoKeyCode == %d\n", DemoKeyCode);
+#endif
+
+  return subProcessKeyboardInput;
+
+#else
 
   //  On Error GoTo NoKeyboardAccessEH
   //    Call DKeyboard.Acquire
@@ -51,9 +94,13 @@ int subProcessKeyboardInput()
   if (DemoFlag != 0)
   {
     subGetNextDemoKey();
+
+#if 0
+    printf("::: DemoKeyCode == %d\n", DemoKeyCode);
+#endif
+
     if (ExitToMenuFlag != 0)
       return subProcessKeyboardInput;
-
   }
   else
   {
@@ -106,6 +153,8 @@ int subProcessKeyboardInput()
     }
   }
 
+#endif
+
   // demo recording
   if (RecordDemoFlag == 1)
     DemoBuffer.AddDemoKey(DemoKeyCode);
@@ -126,6 +175,10 @@ int subProcessKeyboardInput()
     }
     else
     {
+#if 1
+      printf("::: Input.c: subProcessKeyboardInput(): kill murphy\n");
+#endif
+
       KillMurphyFlag = 1;
       //        ExplodeFieldSP MurphyPosIndex
       //        LeadOutCounter = &H20