git » fp-git.git » commit d4c3cec

first files

author peter_k
2005-06-22 21:08:15 UTC
committer peter_k
2005-06-22 21:08:15 UTC
parent 10ffe860e15715a08380cf9d942a955a6a3fe3e9

first files

poprecog/pop2nn/keyboard.c +19 -0
poprecog/pop2nn/keyboard.h +3 -0
poprecog/pop2nn/main.c +50 -0

diff --git a/poprecog/pop2nn/keyboard.c b/poprecog/pop2nn/keyboard.c
new file mode 100644
index 0000000..2d4305b
--- /dev/null
+++ b/poprecog/pop2nn/keyboard.c
@@ -0,0 +1,19 @@
+extern volatile char key[128];
+
+char keyStatus[128];
+
+void refreshKeys()
+{
+    int i;
+    
+    for (i = 0; i < 128; i++)
+        if (key[i])
+        {
+            if (keyStatus[i] < 2)
+                keyStatus[i]++;
+            else
+                keyStatus[i] = 2;    
+        }
+        else
+            keyStatus[i] = 0;
+}
diff --git a/poprecog/pop2nn/keyboard.h b/poprecog/pop2nn/keyboard.h
new file mode 100644
index 0000000..e916681
--- /dev/null
+++ b/poprecog/pop2nn/keyboard.h
@@ -0,0 +1,3 @@
+void refreshKeys(void);
+
+extern char keyStatus[128];
diff --git a/poprecog/pop2nn/main.c b/poprecog/pop2nn/main.c
new file mode 100644
index 0000000..62a25fd
--- /dev/null
+++ b/poprecog/pop2nn/main.c
@@ -0,0 +1,50 @@
+/*
+**  PRINCE OF PERSIA 2 : No Name
+**  New, tiny Prince Of Persia 2 engine.
+**  (c) Copyright 2005 Princed Development Team
+**  Programmed by peter_k
+*/
+
+/*
+  Changelog:
+  - 2005.06.22 about 22:00 - I've start coding this ;)
+*/
+
+/* Header files */
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <dirent.h>
+#include <allegro.h>
+
+#include "keyboard.h"
+
+int main(int argc, char *argv[])
+{
+    int result;
+  
+    allegro_init();
+    install_timer();
+    install_keyboard();    
+    set_color_depth(16);
+    set_color_conversion(COLORCONV_TOTAL);
+
+   	result = set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 320, 200, 0, 0);
+   	if (result != 0)
+    {
+    		  allegro_message(allegro_error);
+    		  exit(-1);
+   	}
+   	
+   	for (;;)
+   	{
+        refreshKeys();
+
+        if (key[KEY_ESC]) break;
+        textprintf(screen, font, 50, 50, makecol16(255, 255, 255), "RIGHT ARROW: %d    %d    ", key[KEY_RIGHT], keyStatus[KEY_RIGHT]);
+        
+        rest(200);  
+    }
+    return 0;
+}
+END_OF_MAIN();