From: sparky4 Date: Sun, 7 Sep 2014 20:49:20 +0000 (-0500) Subject: Added improve keyboard support~ for scroll.exe ^^ X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=27b190bc76b1f75811d6686daf3fde0167e10704;p=16.git Added improve keyboard support~ for scroll.exe ^^ 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 --- diff --git a/16/Project 16.bfproject b/16/Project 16.bfproject index 7b17875c..43a1f5ad 100644 --- a/16/Project 16.bfproject +++ b/16/Project 16.bfproject @@ -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 index 4c721d3b..00000000 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 index 00000000..b6eac792 --- /dev/null +++ b/16/modex16/dos_kb.c @@ -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 clock()) && !kbhit()) ; +} /* 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 index 00000000..5a203b9d --- /dev/null +++ b/16/modex16/lib/lib_com.h @@ -0,0 +1,106 @@ +#ifndef _LIBCOM_H_ +#define _LIBCOM_H_ +#include +#include +#include // just for wait +#include // just for wait +#include "types.h" + +/* Control codes for all keys on the keyboard */ +//here temperarly +#define KEY_A (0x1E) +#define KEY_B (0x30) +#define KEY_C (0x2E) +#define KEY_D (0x20) +#define KEY_E (0x12) +#define KEY_F (0x21) +#define KEY_G (0x22) +#define KEY_H (0x23) +#define KEY_I (0x17) +#define KEY_J (0x24) +#define KEY_K (0x25) +#define KEY_L (0x26) +#define KEY_M (0x32) +#define KEY_N (0x31) +#define KEY_O (0x18) +#define KEY_P (0x19) +#define KEY_Q (0x10) +#define KEY_R (0x13) +#define KEY_S (0x1F) +#define KEY_T (0x14) +#define KEY_U (0x16) +#define KEY_V (0x2F) +#define KEY_W (0x11) +#define KEY_X (0x2D) +#define KEY_Y (0x15) +#define KEY_Z (0x2C) +#define KEY_1 (0x02) +#define KEY_2 (0x03) +#define KEY_3 (0x04) +#define KEY_4 (0x05) +#define KEY_5 (0x06) +#define KEY_6 (0x07) +#define KEY_7 (0x08) +#define KEY_8 (0x09) +#define KEY_9 (0x0A) +#define KEY_0 (0x0B) +#define KEY_DASH (0x0C) /* -_ */ +#define KEY_EQUAL (0x0D) /* =+ */ +#define KEY_LBRACKET (0x1A) /* [{ */ +#define KEY_RBRACKET (0x1B) /* ]} */ +#define KEY_SEMICOLON (0x27) /* ;: */ +#define KEY_RQUOTE (0x28) /* '" */ +#define KEY_LQUOTE (0x29) /* `~ */ +#define KEY_PERIOD (0x33) /* .> */ +#define KEY_COMMA (0x34) /* ,< */ +#define KEY_SLASH (0x35) /* /? */ +#define KEY_BACKSLASH (0x2B) /* \| */ +#define KEY_F1 (0x3B) +#define KEY_F2 (0x3C) +#define KEY_F3 (0x3D) +#define KEY_F4 (0x3E) +#define KEY_F5 (0x3F) +#define KEY_F6 (0x40) +#define KEY_F7 (0x41) +#define KEY_F8 (0x42) +#define KEY_F9 (0x43) +#define KEY_F10 (0x44) +#define KEY_ESC (0x01) +#define KEY_BACKSPACE (0x0E) +#define KEY_TAB (0x0F) +#define KEY_ENTER (0x1C) +#define KEY_CONTROL (0x1D) +#define KEY_LSHIFT (0x2A) +#define KEY_RSHIFT (0x36) +#define KEY_PRTSC (0x37) +#define KEY_ALT (0x38) +#define KEY_SPACE (0x39) +#define KEY_CAPSLOCK (0x3A) +#define KEY_NUMLOCK (0x45) +#define KEY_SCROLLLOCK (0x46) +#define KEY_HOME (0x47) +#define KEY_UP (0x48) +#define KEY_PGUP (0x49) +#define KEY_MINUS (0x4A) +#define KEY_LEFT (0x4B) +#define KEY_CENTER (0x4C) +#define KEY_RIGHT (0x4D) +#define KEY_PLUS (0x4E) +#define KEY_END (0x4F) +#define KEY_DOWN (0x50) +#define KEY_PGDOWN (0x51) +#define KEY_INS (0x52) +#define KEY_DEL (0x53) + +#define KEY_LWIN (0x73) +#define KEY_RWIN (0x74) +#define KEY_MENU (0x75) + + +//typedef unsigned char byte; +//typedef unsigned int word; +//typedef unsigned short syte; + +void wait(clock_t wait); + +#endif/*_LIBCOM_H_*/ diff --git a/16/modex16/makefile b/16/modex16/makefile index e0a07cc4..bdf9d948 100644 --- a/16/modex16/makefile +++ b/16/modex16/makefile @@ -1,8 +1,8 @@ FLAGS=-0 all: test.exe pcxtest.exe test2.exe scroll.exe -scroll.exe: scroll.obj modex16.obj - wcl $(FLAGS) scroll.obj modex16.obj +scroll.exe: scroll.obj modex16.obj dos_kb.obj + wcl $(FLAGS) scroll.obj modex16.obj dos_kb.obj scroll.obj: scroll.c wcl $(FLAGS) -c scroll.c test.exe: test.obj modex16.obj @@ -25,7 +25,10 @@ pcxtest.obj: pcxtest.c modex16.h modex16.obj: modex16.h modex16.c wcl $(FLAGS) -c modex16.c - + +dos_kb.obj: dos_kb.h dos_kb.c + wcl $(FLAGS) -c dos_kb.c + clean: del *.obj del *.exe diff --git a/16/modex16/pcxtest.exe b/16/modex16/pcxtest.exe index 4ab5474e..89c7beff 100644 Binary files a/16/modex16/pcxtest.exe and b/16/modex16/pcxtest.exe differ diff --git a/16/modex16/scroll.c b/16/modex16/scroll.c index dbfe3976..43edbcd5 100644 --- a/16/modex16/scroll.c +++ b/16/modex16/scroll.c @@ -1,8 +1,9 @@ #include "modex16.h" #include -#include +#include +#include "dos_kb.h" -word far *clock= (word far*) 0x046C; /* 18.2hz clock */ +//word far *clock= (word far*) 0x046C; /* 18.2hz clock */ typedef struct { bitmap_t *data; @@ -48,13 +49,16 @@ void main() { int show1=1; int tx, ty; int x, y; - int ch=0x0; + //int ch=0x0; + byte ch; int q=0; page_t screen; map_t map; map_view_t mv; - byte *ptr; - + byte *ptr; + + setkb(1); + /* create the map */ map = allocMap(40,30); initMap(&map); @@ -69,10 +73,12 @@ void main() { mapGoTo(&mv, 0, 0); modexShowPage(mv.page); - while(1){ + while(!keyp(1)) + { // scroll all the way to the right //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++) { mapScrollRight(&mv, 1); modexShowPage(mv.page); @@ -81,7 +87,8 @@ void main() { // scroll all the way to the left //for(; x>0; x--) { - if(ch==0x4b){ + //if(ch==0x4b){ + if(keyp(75)){ for(q=0; q<16; q++) { mapScrollLeft(&mv, 1); modexShowPage(mv.page); @@ -90,7 +97,8 @@ void main() { // scroll all the way down //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++) { mapScrollDown(&mv, 1); modexShowPage(mv.page); @@ -99,7 +107,8 @@ void main() { // scroll all the way up //for(; y>0; y--) { - if(ch==0x48){ + //if(ch==0x48){ + if(keyp(72)){ for(q=0; q<16; q++) { mapScrollUp(&mv, 1); modexShowPage(mv.page); @@ -111,12 +120,14 @@ void main() { modexWaitBorder(); }*/ //while(1){ - ch=getch(); - //printf("0x%02x\n", ch); - if(ch==0x71)break; // 'q' - if(ch==0x1b)break; // 'ESC' +// ch=getch(); + //printf("0x%02x\n", ch); + keyp(ch); +// if(ch==0x71)break; // 'q' +// if(ch==0x1b)break; // 'ESC' } - modexLeave(); + modexLeave(); + setkb(0); } diff --git a/16/modex16/scroll.exe b/16/modex16/scroll.exe index 213610d9..321a7a72 100755 Binary files a/16/modex16/scroll.exe and b/16/modex16/scroll.exe differ diff --git a/16/modex16/test.exe b/16/modex16/test.exe index b0247b18..dbc7ed27 100644 Binary files a/16/modex16/test.exe and b/16/modex16/test.exe differ diff --git a/16/modex16/test2.exe b/16/modex16/test2.exe index 23ca0df0..a0f75a1e 100644 Binary files a/16/modex16/test2.exe and b/16/modex16/test2.exe differ