]> 4ch.mooo.com Git - 16.git/commitdiff
Added improve keyboard support~ for scroll.exe ^^
authorsparky4 <sparky4@cock.li>
Sun, 7 Sep 2014 20:49:20 +0000 (15:49 -0500)
committersparky4 <sparky4@cock.li>
Sun, 7 Sep 2014 20:49:20 +0000 (15:49 -0500)
modified:   16/Project 16.bfproject
deleted:    16/modex16/PALVIEW.EXE
new file:   16/modex16/dos_kb.c
new file:   16/modex16/dos_kb.h
new file:   16/modex16/lib/lib_com.cpp
new file:   16/modex16/lib/lib_com.h
modified:   16/modex16/makefile
modified:   16/modex16/pcxtest.exe
modified:   16/modex16/scroll.c
modified:   16/modex16/scroll.exe
modified:   16/modex16/test.exe
modified:   16/modex16/test2.exe

12 files changed:
16/Project 16.bfproject
16/modex16/PALVIEW.EXE [deleted file]
16/modex16/dos_kb.c [new file with mode: 0644]
16/modex16/dos_kb.h [new file with mode: 0644]
16/modex16/lib/lib_com.cpp [new file with mode: 0644]
16/modex16/lib/lib_com.h [new file with mode: 0644]
16/modex16/makefile
16/modex16/pcxtest.exe
16/modex16/scroll.c
16/modex16/scroll.exe
16/modex16/test.exe
16/modex16/test2.exe

index 7b17875c9acb80986cd90b397d9fe0f6d83743a0..43a1f5ad262a4bb480497dfa3d48a2f3baa6527c 100644 (file)
@@ -2,7 +2,7 @@ c2e.convert_special: 0
 e2c.convert_num: 0
 openfiles: /dos/z/16/16/dos_gfx.cpp:7655:7604:0:
 openfiles: /dos/z/16/16/dos_gfx.h:910:295:0:
-openfiles: /dos/z/16/16/dos_kb.c:217:0:0:
+openfiles: /dos/z/16/16/dos_kb.c:0:0:0:
 openfiles: /dos/z/16/16/dos_kb.h:161:0:0:
 openfiles: /dos/z/16/16/lib/lib_com.cpp:2:0:0:
 openfiles: /dos/z/16/16/lib/lib_com.h:633:1027:0:
@@ -11,7 +11,11 @@ openfiles: /dos/z/16/16/project16.txt:8063:6091:0:
 openfiles: /dos/z/16/16/16.txt:0:0:0:
 openfiles: /dos/z/16/16/lib/x/MODEX.H:5511:2798:0:
 openfiles: /dos/z/16/16/TEST.C:430:6112:0:
-openfiles: /dos/z/16/16/modex16/scroll.c:1610:1479:1:
+openfiles: /dos/z/16/16/modex16/scroll.c:1537:1152:1:
+openfiles: /dos/z/16/16/modex16/modex16.h:156:0:0:
+openfiles: /dos/z/16/16/modex16/makefile:106:0:0:
+openfiles: /dos/z/16/16/modex16/dos_kb.c:3565:2934:0:
+openfiles: /dos/z/16/16/modex16/dos_kb.h:0:0:0:
 snr_recursion_level: 0
 convertcolumn_horizontally: 0
 adv_open_matchname: 0
@@ -23,7 +27,7 @@ view_left_panel: 0
 default_mime_type: text/plain
 e2c.convert_xml: 1
 c2e.convert_iso: 0
-opendir: file:///dos/z/16/16/lib
+opendir: file:///dos/z/16/16/modex16
 wrap_text_default: 0
 bookmarks_filename_mode: 1
 ssearch_text: mapScrollRight
@@ -48,13 +52,6 @@ ssearch_regex: 0
 e2c.convert_iso: 0
 ssearch_casesens: 0
 charmap_block: 1
-recent_files: file:///dos/z/16/16/w_modex/MODEX.HPP
-recent_files: file:///dos/z/16/16/w_modex/XPRIM.HPP
-recent_files: file:///dos/z/16/16/w_modex/XPRIM.CPP
-recent_files: file:///dos/z/16/16/w_modex/MODEX.CPP
-recent_files: file:///dos/z/16/16/w_modex/TEST.CPP
-recent_files: file:///dos/z/16/16/Project%2016.bfproject
-recent_files: file:///dos/z/16/16/lib/x/compile.bat
 recent_files: file:///dos/z/16/16/x.bat
 recent_files: file:///dos/z/16/16/xx.bat
 recent_files: file:///dos/z/16/16/lib/x/MXPN.ASM
@@ -85,16 +82,26 @@ recent_files: file:///dos/z/16/16/lib/MODEX16.H
 recent_files: file:///dos/z/16/16/modex16/SCROLL.C
 recent_files: file:///dos/z/16/16/modex16/scroll.c
 recent_files: file:///dos/z/16/16/dos_gfx.h
-recent_files: file:///dos/z/16/16/dos_gfx.cpp
-recent_files: file:///dos/z/16/16/lib/lib_com.h
-recent_files: file:///dos/z/16/16/dos_kb.c
 recent_files: file:///dos/z/16/16/dos_kb.h
 recent_files: file:///dos/z/16/16/lib/lib_com.cpp
-recent_files: file:///dos/z/16/16/scroll.txt
-recent_files: file:///dos/z/16/16/project16.txt
+recent_files: file:///dos/z/16/16/lib/lib_com.h
 recent_files: file:///dos/z/16/16/16.txt
+recent_files: file:///dos/z/16/16/dos_gfx.cpp
+recent_files: file:///dos/z/16/16/project16.txt
+recent_files: file:///dos/z/16/16/scroll.txt
 recent_files: file:///dos/z/16/16/TEST.C
 recent_files: file:///dos/z/16/16/lib/x/MODEX.H
+recent_files: file:///dos/z/16/src/lib/dos_comm.c
+recent_files: file:///dos/z/16/src/eng_comm.cpp
+recent_files: file:///dos/z/16/src/eng_comm.h
+recent_files: file:///dos/z/16/src/lib/dos_comm.h
+recent_files: file:///dos/z/16/16/modex16/lib/lib_com.h
+recent_files: file:///dos/z/16/16/modex16/lib/lib_com.cpp
+recent_files: file:///dos/z/16/16/dos_kb.c
+recent_files: file:///dos/z/16/16/modex16/modex16.h
+recent_files: file:///dos/z/16/16/modex16/makefile
+recent_files: file:///dos/z/16/16/modex16/dos_kb.h
+recent_files: file:///dos/z/16/16/modex16/dos_kb.c
 snr_replacetype: 0
 savedir: file:///dos/z/16/16/modex16
 spell_check_default: 1
diff --git a/16/modex16/PALVIEW.EXE b/16/modex16/PALVIEW.EXE
deleted file mode 100644 (file)
index 4c721d3..0000000
Binary files a/16/modex16/PALVIEW.EXE and /dev/null differ
diff --git a/16/modex16/dos_kb.c b/16/modex16/dos_kb.c
new file mode 100644 (file)
index 0000000..b6eac79
--- /dev/null
@@ -0,0 +1,140 @@
+/* Thanks to Alex Russell for example code */
+/* Thanks to Gary Neal for example code */
+#include "dos_kb.h"
+
+// keyboard buffer
+static byte key[NUM_SCANCODES]; // pressed
+static byte kea[NUM_SCANCODES]; // released
+
+#ifdef __cplusplus             /* Function must be declared C style */
+extern "C" {
+#endif
+static void interrupt (far *oldkb)(void) = NULL; /* BIOS keyboard handler */
+#ifdef __cplusplus
+}
+#endif
+
+/*
+ * Comment out the following #define if you don't want the testing main()
+ * to be included.
+ */
+//#define TESTING
+
+/*****************NEW KEYBOARD 09h ISR***********************/
+void interrupt newkb(void){
+       byte kee;
+       register char qx;
+
+       kee = inp(0x60);        /* Read the keyboard scan code */
+
+       /* Clear keyboard controller on XT machines */
+       qx = inp(0x61);    /* Get keyboard control register */
+       qx |= 0x82;
+       outp(0x61, qx);    /* Toggle acknowledge bit high */
+       qx &= 0x7F;
+       outp(0x61, qx);    /* Toggle acknowledge bit low */
+
+       /* Interpret the scan code and set our flags */
+       #ifdef TESTING
+       //printf("%d[%d]\n",kee,key[kee]);
+       #endif
+       if(kee & 0x80)
+               key[kee & 0x7F] = 0; // a key is released
+       else
+               key[kee] = kea[kee] = 1; // a key is pressed
+
+       /* Acknowledge the interrupt to the programmable interrupt controller */
+       outp(0x20, 0x20);      /* Signal non specific end of interrupt */
+}
+
+/* ---------------------- init_keyboard() ---------------- April 17,1993 */
+/* restore the bios keyboard handler */
+/* ---------------------- deinit_keyboard() -------------- April 17,1993 */
+void setkb(int vq){
+       int i;  /* Index variable */
+       if(!vq){ // deinitiation
+               /* Abort if our function pointer has no valid address */
+               if(oldkb == NULL) return;
+               /* Set address in our function pointer in interrupt vector table */
+               _dos_setvect(9, oldkb);
+               /* Reset our function pointer to contain no valid address */
+               oldkb = NULL;
+               #ifdef TESTING
+               /* Print the key heap */
+               /*printf("\n");
+               for(i=0; i<NUM_SCANCODES; i++){
+                       if(i==NUM_SCANCODES/2) printf("================================\n");
+                       printf("%03d[%d][%d]",i+1,key[i],kea[i]);
+                       if(key[i]==1)printf("====");
+                       printf(",\n");
+               }*/
+               #endif
+       }else if(vq == 1){ // initiation
+               byte far *lock_key;
+
+               /* Abort if our function pointer has a valid address. */
+               if(oldkb != NULL) return;
+
+               /* Clear the keyboard buttons state arrays */
+               for(i = 0; i < NUM_SCANCODES; i++)
+                       key[i] = kea[i] = 0;
+
+               /* save old BIOS key board handler */
+               oldkb = _dos_getvect(9);
+
+               // turn off num-lock via BIOS
+               lock_key = MK_FP(0x040, 0x017); // Pointing to the address of the bios shift state keys
+               *lock_key&=(~(16 | 32 | 64)); // toggle off the locks by changing the values of the 4th, 5th, and 6th bits of the address byte of 0040:0017
+               oldkb();        // call BIOS keyhandler to change keyboard lights
+
+               /* setup our own handler */
+               _dos_setvect(9, newkb);
+       }
+}
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
+ * keyp                                                              *
+ *                                                                      *
+ * Returns the status of the key requested.                            *
+ * The status is 1 if the key is pressed or has been pressed since the     *
+ * last call to this function for that particular key.              *
+\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+int keyp(byte c){
+       register char retVal;
+
+       /* Key value in range of keyboard keys available */
+       c &= 0x7F;
+
+       /* Get the status of the key requested */
+       retVal = key[c] | kea[c];
+
+       /* Reset the was pressed status for the requested key */
+       kea[c] = 0;
+
+       /* Return the requested key's state */
+       return retVal;
+}
+
+
+/*
+ * The library testing routines follows below.
+ */
+
+#ifdef TESTING
+
+/*
+ * Library test (program) entry point.
+ */
+
+void main(void)
+{
+       byte q;
+       setkb(1);
+       while(!keyp(1))
+       {
+               keyp(q);
+       }
+       setkb(0);
+}
+
+#endif
diff --git a/16/modex16/dos_kb.h b/16/modex16/dos_kb.h
new file mode 100644 (file)
index 0000000..ea81462
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef _DOSLIB_KB_H_\r
+#define _DOSLIB_KB_H_\r
+#include "lib\lib_com.h"\r
+\r
+/* Maximum number of scan codes on keyboard controllers */\r
+#define NUM_SCANCODES   128\r
+\r
+#ifdef __cplusplus      /* Functions must be declared C style */\r
+extern "C" {\r
+#endif\r
+void interrupt far newkb(void);\r
+//extern void interrupt (far *oldkb)(void);\r
+void setkb(int vq);\r
+int keyp(byte c);\r
+\r
+/* Define macro */\r
+//#define kepn(c) key[c & 0x7F]\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif/*_DOSLIB_KB_H_*/\r
diff --git a/16/modex16/lib/lib_com.cpp b/16/modex16/lib/lib_com.cpp
new file mode 100644 (file)
index 0000000..19ad2dd
--- /dev/null
@@ -0,0 +1,21 @@
+//#include "src\lib\lib_com.h"
+#include "lib\lib_com.h"
+\r
+/* local function */\r
+void wait(clock_t wait);\r
+\r
+/* Function: Wait **********************************************************\r
+*\r
+*     Parameters:    wait - time in microseconds\r
+*\r
+*     Description:    pauses for a specified number of microseconds.\r
+*\r
+*/\r
+void wait(clock_t wait){\r
+       clock_t goal;\r
+\r
+       if(!wait) return;\r
+\r
+       goal = wait + clock();\r
+       while((goal > clock()) && !kbhit()) ;\r
+} /* End of wait */
\ No newline at end of file
diff --git a/16/modex16/lib/lib_com.h b/16/modex16/lib/lib_com.h
new file mode 100644 (file)
index 0000000..5a203b9
--- /dev/null
@@ -0,0 +1,106 @@
+#ifndef _LIBCOM_H_\r
+#define _LIBCOM_H_\r
+#include <dos.h>\r
+#include <stdio.h>\r
+#include <conio.h> // just for wait\r
+#include <time.h> // just for wait
+#include "types.h"\r
+\r
+/* Control codes for all keys on the keyboard */\r
+//here temperarly\r
+#define KEY_A          (0x1E)\r
+#define KEY_B          (0x30)\r
+#define KEY_C          (0x2E)\r
+#define KEY_D          (0x20)\r
+#define KEY_E          (0x12)\r
+#define KEY_F          (0x21)\r
+#define KEY_G          (0x22)\r
+#define KEY_H          (0x23)\r
+#define KEY_I          (0x17)\r
+#define KEY_J          (0x24)\r
+#define KEY_K          (0x25)\r
+#define KEY_L          (0x26)\r
+#define KEY_M          (0x32)\r
+#define KEY_N          (0x31)\r
+#define KEY_O          (0x18)\r
+#define KEY_P          (0x19)\r
+#define KEY_Q          (0x10)\r
+#define KEY_R          (0x13)\r
+#define KEY_S          (0x1F)\r
+#define KEY_T          (0x14)\r
+#define KEY_U          (0x16)\r
+#define KEY_V          (0x2F)\r
+#define KEY_W          (0x11)\r
+#define KEY_X          (0x2D)\r
+#define KEY_Y          (0x15)\r
+#define KEY_Z          (0x2C)\r
+#define KEY_1          (0x02)\r
+#define KEY_2          (0x03)\r
+#define KEY_3          (0x04)\r
+#define KEY_4          (0x05)\r
+#define KEY_5          (0x06)\r
+#define KEY_6          (0x07)\r
+#define KEY_7          (0x08)\r
+#define KEY_8          (0x09)\r
+#define KEY_9          (0x0A)\r
+#define KEY_0          (0x0B)\r
+#define KEY_DASH               (0x0C)  /* -_ */\r
+#define KEY_EQUAL              (0x0D)  /* =+ */\r
+#define KEY_LBRACKET   (0x1A)  /* [{ */\r
+#define KEY_RBRACKET   (0x1B)  /* ]} */\r
+#define KEY_SEMICOLON  (0x27)  /* ;: */\r
+#define KEY_RQUOTE     (0x28)  /* '" */\r
+#define KEY_LQUOTE     (0x29)  /* `~ */\r
+#define KEY_PERIOD     (0x33)  /* .> */\r
+#define KEY_COMMA              (0x34)  /* ,< */\r
+#define KEY_SLASH              (0x35)  /* /? */\r
+#define KEY_BACKSLASH  (0x2B)  /* \| */\r
+#define KEY_F1         (0x3B)\r
+#define KEY_F2         (0x3C)\r
+#define KEY_F3         (0x3D)\r
+#define KEY_F4         (0x3E)\r
+#define KEY_F5         (0x3F)\r
+#define KEY_F6         (0x40)\r
+#define KEY_F7         (0x41)\r
+#define KEY_F8         (0x42)\r
+#define KEY_F9         (0x43)\r
+#define KEY_F10                (0x44)\r
+#define KEY_ESC                (0x01)\r
+#define KEY_BACKSPACE   (0x0E)\r
+#define KEY_TAB                (0x0F)\r
+#define KEY_ENTER              (0x1C)\r
+#define KEY_CONTROL    (0x1D)\r
+#define KEY_LSHIFT     (0x2A)\r
+#define KEY_RSHIFT     (0x36)\r
+#define KEY_PRTSC              (0x37)\r
+#define KEY_ALT                (0x38)\r
+#define KEY_SPACE              (0x39)\r
+#define KEY_CAPSLOCK   (0x3A)\r
+#define KEY_NUMLOCK    (0x45)\r
+#define KEY_SCROLLLOCK (0x46)\r
+#define KEY_HOME               (0x47)\r
+#define KEY_UP         (0x48)\r
+#define KEY_PGUP               (0x49)\r
+#define KEY_MINUS              (0x4A)\r
+#define KEY_LEFT               (0x4B)\r
+#define KEY_CENTER     (0x4C)\r
+#define KEY_RIGHT              (0x4D)\r
+#define KEY_PLUS               (0x4E)\r
+#define KEY_END                (0x4F)\r
+#define KEY_DOWN               (0x50)\r
+#define KEY_PGDOWN     (0x51)\r
+#define KEY_INS                (0x52)\r
+#define KEY_DEL                (0x53)\r
+\r
+#define KEY_LWIN               (0x73)\r
+#define KEY_RWIN               (0x74)\r
+#define KEY_MENU               (0x75)\r
+\r
+\r
+//typedef unsigned char byte;
+//typedef unsigned int word;
+//typedef unsigned short syte;\r
+\r
+void wait(clock_t wait);\r
+\r
+#endif/*_LIBCOM_H_*/\r
index e0a07cc4ecc9f577e2c5d2273685644a00df5c15..bdf9d9489e79cd99e8d13199d1a921185c7988dc 100644 (file)
@@ -1,8 +1,8 @@
 FLAGS=-0 \r
 all: test.exe pcxtest.exe test2.exe scroll.exe\r
 \r
-scroll.exe: scroll.obj modex16.obj\r
-       wcl $(FLAGS) scroll.obj modex16.obj\r
+scroll.exe: scroll.obj modex16.obj dos_kb.obj\r
+       wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj\r
 scroll.obj: scroll.c\r
        wcl $(FLAGS) -c scroll.c\r
 test.exe: test.obj modex16.obj\r
@@ -25,7 +25,10 @@ pcxtest.obj: pcxtest.c modex16.h
 \r
 modex16.obj: modex16.h modex16.c\r
        wcl $(FLAGS) -c modex16.c\r
-       \r
+
+dos_kb.obj: dos_kb.h dos_kb.c\r
+       wcl $(FLAGS) -c dos_kb.c
+\r
 clean: \r
        del *.obj\r
        del *.exe\r
index 4ab5474eda921991e739342a6e978af201ef95d2..89c7beff065ba4d4782f7bd4bddae2d09650380e 100644 (file)
Binary files a/16/modex16/pcxtest.exe and b/16/modex16/pcxtest.exe differ
index dbfe39765d08a33b220fec28d193a2e36ebdfd9c..43edbcd589949a3f8c9ff53a7357ec85abea6084 100644 (file)
@@ -1,8 +1,9 @@
 #include "modex16.h"\r
 #include <stdio.h>\r
-#include <stdlib.h>\r
+#include <stdlib.h>
+#include "dos_kb.h"\r
 \r
-word far *clock= (word far*) 0x046C; /* 18.2hz clock */\r
+//word far *clock= (word far*) 0x046C; /* 18.2hz clock */\r
 \r
 typedef struct {\r
     bitmap_t *data;\r
@@ -48,13 +49,16 @@ void main() {
     int show1=1;\r
     int tx, ty;\r
     int x, y;
-       int ch=0x0;
+       //int ch=0x0;
+       byte ch;
        int q=0;\r
     page_t screen;\r
     map_t map;\r
     map_view_t mv;\r
-    byte *ptr;\r
-    \r
+    byte *ptr;
+
+    setkb(1);\r
+\r
     /* create the map */\r
     map = allocMap(40,30);\r
     initMap(&map);\r
@@ -69,10 +73,12 @@ void main() {
     mapGoTo(&mv, 0, 0);\r
     modexShowPage(mv.page);\r
 
-       while(1){ \r
+       while(!keyp(1))
+       {\r
     // scroll all the way to the right\r
     //for(x=0; x<(map.width*16-SCREEN_WIDTH); x++) {
-       if(ch==0x4d){
+       //if(ch==0x4d){
+       if(keyp(77)){
        for(q=0; q<16; q++) {\r
        mapScrollRight(&mv, 1);\r
        modexShowPage(mv.page);
@@ -81,7 +87,8 @@ void main() {
 \r
     // scroll all the way to the left\r
     //for(; x>0; x--) {
-       if(ch==0x4b){
+       //if(ch==0x4b){
+       if(keyp(75)){
        for(q=0; q<16; q++) {\r
        mapScrollLeft(&mv, 1);\r
        modexShowPage(mv.page);
@@ -90,7 +97,8 @@ void main() {
 \r
     // scroll all the way down\r
     //for(y=0; y<(map.height*16-SCREEN_HEIGHT); y++) {
-       if(ch==0x50){
+       //if(ch==0x50){
+       if(keyp(80)){
                for(q=0; q<16; q++) {\r
         mapScrollDown(&mv, 1);\r
         modexShowPage(mv.page);
@@ -99,7 +107,8 @@ void main() {
 \r
     // scroll all the way up\r
     //for(; y>0; y--) {
-       if(ch==0x48){
+       //if(ch==0x48){
+       if(keyp(72)){
                for(q=0; q<16; q++) {\r
        mapScrollUp(&mv, 1);\r
        modexShowPage(mv.page);
@@ -111,12 +120,14 @@ void main() {
         modexWaitBorder();\r
     }*/
     //while(1){
-                       ch=getch();
-                       //printf("0x%02x\n", ch);\r
-                       if(ch==0x71)break; // 'q'\r
-                       if(ch==0x1b)break; // 'ESC'\r
+//                     ch=getch();
+                       //printf("0x%02x\n", ch);
+                       keyp(ch);\r
+//                     if(ch==0x71)break; // 'q'\r
+//                     if(ch==0x1b)break; // 'ESC'\r
 }\r
-    modexLeave();\r
+    modexLeave();
+       setkb(0);\r
 }\r
 \r
 \r
index 213610d934be63dc67ca285790e26031038ed215..321a7a725ba70f5913b0b84c1815461ab2ff81e5 100755 (executable)
Binary files a/16/modex16/scroll.exe and b/16/modex16/scroll.exe differ
index b0247b18e9ecb1cc9481de996b4b5eeabf440af8..dbc7ed27b32b7b009eade58ed286b7514893b26a 100644 (file)
Binary files a/16/modex16/test.exe and b/16/modex16/test.exe differ
index 23ca0df0b881ee1fbc2fe085faeb6600d6899847..a0f75a1e9f666b3babba4f526c33edc380ee09e8 100644 (file)
Binary files a/16/modex16/test2.exe and b/16/modex16/test2.exe differ