180 lines
6.2 KiB
C
180 lines
6.2 KiB
C
|
#ifndef _HAL_H
|
||
|
#define _HAL_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#include <time.h>
|
||
|
#define far
|
||
|
#define near
|
||
|
|
||
|
#define i86_start_interrupts() __asm__ __volatile__ ("sti");
|
||
|
#define i86_clear_interrupts() __asm__ __volatile__ ("cli");
|
||
|
|
||
|
extern volatile TIME _internal_clock;
|
||
|
|
||
|
// initialize hardware abstraction layer
|
||
|
extern void i86_hal_initialize ();
|
||
|
|
||
|
// shutdown hardware abstraction layer
|
||
|
extern int i86_hal_shutdown ();
|
||
|
|
||
|
//! notifies hal interrupt is done
|
||
|
//extern void interruptdone (unsigned int intno);
|
||
|
|
||
|
//! output sound to speaker
|
||
|
extern void sound (unsigned frequency);
|
||
|
|
||
|
//! read byte from device using port mapped io
|
||
|
//extern unsigned char inportb (unsigned short _port);
|
||
|
|
||
|
//! write byte to device through port mapped io
|
||
|
//extern void outportb (unsigned short _port, unsigned char _data);
|
||
|
|
||
|
//! sets new interrupt vector
|
||
|
//extern void setvect (int intno, void ( far &vect) ( ) );
|
||
|
|
||
|
//! returns current interrupt vector
|
||
|
//extern void ( far * getvect (int intno)) ( );
|
||
|
|
||
|
//! returns cpu vender
|
||
|
extern const char* get_cpu_vender ();
|
||
|
|
||
|
extern void reboot();
|
||
|
|
||
|
|
||
|
/**********************************************************************
|
||
|
* KEYBOARD STUFF *
|
||
|
**********************************************************************/
|
||
|
#define KB_KEY_LSHIFT 0x81 // 1000 0001
|
||
|
#define KB_KEY_RSHIFT 0X82 // 1000 0010
|
||
|
#define KB_KEY_LALT 0X84 // 1000 0100
|
||
|
#define KB_KEY_RALT 0x88 // 1000 1000
|
||
|
#define KB_KEY_LCTRL 0x90 // 1001 0000
|
||
|
#define KB_KEY_RCTRL 0xA0 // 1010 0000
|
||
|
#define KB_KEY_FSHIFT 0xC0 // 1100 0000
|
||
|
extern volatile byte kb_modifier_status;
|
||
|
|
||
|
#define KB_PREFIX_GRAY 0x01 // Gray
|
||
|
#define KB_PREFIX_BREAK 0x02 // Break code
|
||
|
#define KB_PREFIX_PAUSE 0x04 // Pause/break key
|
||
|
#define KB_PREFIX_PAUSE1 0x08 // Recieved first byte from pause/break
|
||
|
extern volatile byte kb_prefix;
|
||
|
|
||
|
#define KB_KEY_SCROLL 0xF1 // 1111 0001
|
||
|
#define KB_KEY_NUM 0xF2 // 1111 0010
|
||
|
#define KB_KEY_CAPS 0xF4 // 1111 0100
|
||
|
extern volatile byte kb_lights_status;
|
||
|
|
||
|
extern byte kb_scancode_set;
|
||
|
#define KB_KEY_PAUSE 0x00
|
||
|
#define KB_KEY_F9 0x01
|
||
|
#define KB_KEY_F7 0x02
|
||
|
#define KB_KEY_F5 0X03
|
||
|
#define KB_KEY_F3 0x04
|
||
|
#define KB_KEY_F1 0x05
|
||
|
#define KB_KEY_F2 0x06
|
||
|
#define KB_KEY_F12 0x07
|
||
|
#define KB_KEY_PRINTSCRN 0x08
|
||
|
#define KB_KEY_F10 0x09
|
||
|
#define KB_KEY_F8 0x0A
|
||
|
#define KB_KEY_F6 0x0B
|
||
|
#define KB_KEY_F4 0x0C
|
||
|
#define KB_KEY_TAB 0x0D
|
||
|
#define KB_KEY_TILDA 0x0E
|
||
|
#define KB_KEY_Q 0x15
|
||
|
#define KB_KEY_1 0x16
|
||
|
#define KB_KEY_Z 0x1A
|
||
|
#define KB_KEY_S 0x1B
|
||
|
#define KB_KEY_A 0x1C
|
||
|
#define KB_KEY_W 0x1D
|
||
|
#define KB_KEY_2 0x1E
|
||
|
#define KB_KEY_LWIN 0x1F
|
||
|
#define KB_KEY_C 0x21
|
||
|
#define KB_KEY_X 0x22
|
||
|
#define KB_KEY_D 0x23
|
||
|
#define KB_KEY_E 0x24
|
||
|
#define KB_KEY_4 0x25
|
||
|
#define KB_KEY_3 0x26
|
||
|
#define KB_KEY_RWIN 0x27
|
||
|
#define KB_KEY_SPACE 0x29
|
||
|
#define KB_KEY_V 0x2A
|
||
|
#define KB_KEY_F 0x2B
|
||
|
#define KB_KEY_T 0x2C
|
||
|
#define KB_KEY_R 0x2D
|
||
|
#define KB_KEY_5 0x2E
|
||
|
#define KB_KEY_MENU 0x2F
|
||
|
#define KB_KEY_N 0x31
|
||
|
#define KB_KEY_B 0x32
|
||
|
#define KB_KEY_H 0x33
|
||
|
#define KB_KEY_G 0x34
|
||
|
#define KB_KEY_Y 0x35
|
||
|
#define KB_KEY_6 0x36
|
||
|
#define KB_KEY_M 0x3A
|
||
|
#define KB_KEY_J 0x3B
|
||
|
#define KB_KEY_U 0x3C
|
||
|
#define KB_KEY_7 0x3D
|
||
|
#define KB_KEY_8 0x3E
|
||
|
#define KB_KEY_COMMA 0x41
|
||
|
#define KB_KEY_K 0x42
|
||
|
#define KB_KEY_I 0x43
|
||
|
#define KB_KEY_O 0x44
|
||
|
#define KB_KEY_0 0x45
|
||
|
#define KB_KEY_9 0x46
|
||
|
#define KB_KEY_PERIOD 0x49
|
||
|
#define KB_KEY_SLASH 0x4A
|
||
|
#define KB_KEY_L 0x4B
|
||
|
#define KB_KEY_SEMICOLON 0x4C
|
||
|
#define KB_KEY_P 0x4D
|
||
|
#define KB_KEY_DASH 0x4E
|
||
|
#define KB_KEY_APOSTROPHE 0x52
|
||
|
#define KB_KEY_LBRACKET 0x54
|
||
|
#define KB_KEY_EQUAL 0x55
|
||
|
#define KB_KEY_NUMPAD_ENTER 0x59
|
||
|
#define KB_KEY_ENTER 0x5A
|
||
|
#define KB_KEY_RBRACKET 0x5B
|
||
|
#define KB_KEY_BACKSLASH 0x5D
|
||
|
#define KB_KEY_END 0x5E
|
||
|
#define KB_KEY_LEFT 0x5F
|
||
|
#define KB_KEY_HOME 0x60
|
||
|
#define KB_KEY_INSERT 0x61
|
||
|
#define KB_KEY_DELETE 0x62
|
||
|
#define KB_KEY_DOWN 0x63
|
||
|
#define KB_KEY_RIGHT 0x64
|
||
|
#define KB_KEY_UP 0x65
|
||
|
#define KB_KEY_BACKSPACE 0x66
|
||
|
#define KB_KEY_PGDOWN 0x67
|
||
|
#define KB_KEY_PGUP 0x68
|
||
|
#define KB_KEY_NUMPAD_1 0x69
|
||
|
#define KB_KEY_NUMPAD_SLASH 0x6A
|
||
|
#define KB_KEY_NUMPAD_4 0x6B
|
||
|
#define KB_KEY_NUMPAD_7 0x6C
|
||
|
#define KB_KEY_NUMPAD_0 0x70
|
||
|
#define KB_KEY_NUMPAD_COLON 0x71
|
||
|
#define KB_KEY_NUMPAD_2 0x72
|
||
|
#define KB_KEY_NUMPAD_5 0x73
|
||
|
#define KB_KEY_NUMPAD_6 0x74
|
||
|
#define KB_KEY_NUMPAD_8 0x75
|
||
|
#define KB_KEY_ESC 0x76
|
||
|
#define KB_KEY_F11 0x78
|
||
|
#define KB_KEY_NUMPAD_PLUS 0x79
|
||
|
#define KB_KEY_NUMPAD_3 0x7A
|
||
|
#define KB_KEY_NUMPAD_MINUS 0x7B
|
||
|
#define KB_KEY_NUMPAD_ASTERISK 0x7C
|
||
|
#define KB_KEY_NUMPAD_9 0x7D
|
||
|
|
||
|
|
||
|
typedef struct {
|
||
|
byte status;
|
||
|
byte lights;
|
||
|
byte scancode;
|
||
|
byte character;
|
||
|
} kb_key;
|
||
|
|
||
|
|
||
|
extern char getch();
|
||
|
extern kb_key getkey();
|
||
|
extern char scancode_to_ascii(byte scancode, byte status);
|
||
|
extern byte get_key_status(byte scancode);
|
||
|
extern void kb_set_repeat(float rate, int delay);
|
||
|
extern void kb_set_LEDs(byte status);
|
||
|
|
||
|
#endif
|