keyboard.h
author Mohammed Khoory
Wed Jul 07 19:11:38 2010 -0400 (22 months ago)
changeset 5 bcf3d6f89c62
permissions -rw-r--r--
Keyboard support, code movement, and TestManager

Major Changes
=============
- Added "testman.h" and "testman.cpp" to be used exclusively to test stuff (from a
GameManager perspective)
- Moved all the testing stuff to testman.cpp. 9game is just an empty class now to
manage other GameManagers
- Moved all the initializing stuff from 9Game to main. 9Game is like any other
GameManager now (just that it manages other GameManagers)
- Added keyboard.h and keyboard.c to handle keyboard interrupts (by replacing the
keyboard ISR)
- Keyboard is working :D can read more than one key at a time. (tested in
TestManager with WASD)

Minor Changes
=============
- Removed the exception throwing in SpriteLoader::unloadFile() (because it just
makes things unnecessarily complicated)
- added finished() to GameManager to indicate whether a GameManager is finished or
not
- Animation test + key control test. Sprite moves around depending on wasd key
input. (program ends when off screen to right)
- Set 0x00 as transparency color with drawSprite (TODO: change to make this
customizeable on runtime)
- Edited Makefile to reflect new changes

Notes
=====
- Animation seems to work nice and smooth in dosbox, slow in dosemu, so maybe I
should start testing in both dosemu and dosbox
- TODO: fix bug with drawSprite. When a sprite is drawn on the right of the screen
it "wraps around" to the other side by one pixel in width
     1 #ifndef KEYBOARD
     2 #define KEYBOARD
     3 
     4 /*#ifdef __cplusplus
     5 extern "C" {
     6 #endif*/
     7 /* functions and a custom ISR used to handle the keyboard 
     8 	- DOS by itself can only handle one key at a time, so we need to 
     9 	replace the interrupt service routine (ISR) to make it handle more 
    10 	than one key at a time
    11 */
    12 #include <dpmi.h>
    13 #include <io.h>
    14 #include <conio.h>
    15 #include <dos.h>
    16 
    17 // insert some keyboard codes here as DEFINES (or static chars)
    18 
    19 
    20 char enabled;
    21 volatile char keys[256]; // stores keyboard state
    22 
    23 // keyboard ISRs
    24 _go32_dpmi_seginfo oldKeyboardHandlerSeginfo;
    25 _go32_dpmi_seginfo newKeyboardHandlerSeginfo;
    26 
    27 void handler();
    28 void handler_end();
    29 
    30 int attach_keyboard_handler();
    31 void detach_keyboard_handler();
    32 
    33 char keyPressed(unsigned char key);
    34 
    35 /*
    36 #ifdef __cplusplus
    37 }
    38 #endif
    39 */
    40 #endif