CTAOS v5
This commit is contained in:
@ -6,32 +6,185 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//! multiboot info structure passed from boot loader
|
||||
/**The structure used by the VESA Controller Info table.*/
|
||||
struct _VESA_CONTROLLER_INFO {
|
||||
/** Vesa signature, should be "VESA". */
|
||||
unsigned char Signature[4];
|
||||
/** Version number, example: 0x0300 for VBE 3.0. */
|
||||
uint16_t Version;
|
||||
/** FAR pointer to OEM string. (seg:offset). */
|
||||
uint16_t OEMString[2];
|
||||
/** Capabilities, taken as 4 bytes. */
|
||||
uint32_t Capabilities;
|
||||
/** Video modes. FAR pointer (seg:offset). */
|
||||
uint16_t VideoModes[2];
|
||||
/** Total memory as number of 64k blocks. */
|
||||
uint16_t TotalMemory;
|
||||
} __attribute__((packed));
|
||||
|
||||
|
||||
enum _VESA_MODE_ATTRIBUTES {
|
||||
/** The mode is supported by the present hardware configuration. */
|
||||
IsSupported = 0x01,
|
||||
/** Optional information is available (must be = 1 for VBE v1.2+) */
|
||||
OptionalInformation = 0x02,
|
||||
/** BIOS output is supported. */
|
||||
BiosOutput = 0x04,
|
||||
/** Set if color, clear if monochrome. */
|
||||
IsColor = 0x08,
|
||||
/** Set if graphic mode, clear if text mode. */
|
||||
IsGraphic = 0x10,
|
||||
/** (VBE v2.0+) mode is not VGA compatible. */
|
||||
VGACompatible = 0x20,
|
||||
/** (VBE v2.0+) Bank switched mode not supported. */
|
||||
BankSwitchedNotSupported = 0x40,
|
||||
/** (VBE v2.0+) Linear framebuffer mode supported. */
|
||||
LinearFramebufferSupported = 0x80,
|
||||
/** (VBE v3.0) Interlaced mode available. */
|
||||
InterlacedAvailable = 0x100,
|
||||
/** (VBE/AF v1.0P) Application must call EnableDirrectAccess before calling bank-switching functions. */
|
||||
EnableDirectAccess = 0x100,
|
||||
/** (VBE v3.0) Hardware supports triple buffering. */
|
||||
TripleBufferingSupported = 0x200,
|
||||
/** (VBE v3.0) Hardware supports stereoscopic display. */
|
||||
StereoscopicSupported = 0x400,
|
||||
/** (VBE v3.0) Dual display start address support. */
|
||||
DualDisplayStartAddress = 0x800
|
||||
} VESAModeAttributeMasks;
|
||||
|
||||
enum _VESA_MODE_WINDOW_ATTRIBUTES {
|
||||
/** Window exists. */
|
||||
Exists = 0x1,
|
||||
/** Window is readable. */
|
||||
Readable = 0x2,
|
||||
/** Window is writable. */
|
||||
Writable = 0x4
|
||||
} VESAModeWindowAttributeMasks;
|
||||
|
||||
enum _VESA_MODE_MEMORY_MODELS {
|
||||
/** Text */
|
||||
Text = 0x00,
|
||||
/** CGA graphics*/
|
||||
CGA = 0x01,
|
||||
/** HGC graphics*/
|
||||
HGC = 0x02,
|
||||
/** 16-color EGA grahpics*/
|
||||
EGA = 0x03,
|
||||
/** packed pixel graphics*/
|
||||
PackedPixel = 0x04,
|
||||
/** "sequ 256 (non chain 4) grahpics*/
|
||||
Sequ256 = 0x05,
|
||||
/** Direct color (HiColor, 24bit TrueColor)*/
|
||||
DirectColor = 0x06,
|
||||
/** YUV (luminance-chrominance, also called YIQ)*/
|
||||
YUV = 0x07
|
||||
} VESAModeMemoryModels;
|
||||
|
||||
struct _VESA_MODE_INFO {
|
||||
/** Mode attributes, defined in VESAModeAttributeMasks. */
|
||||
uint16_t Attributes;
|
||||
/** Window attributes (window A or B), defined in VESAModeWindowAttributeMasks. */
|
||||
uint8_t WindowAttributesA, WindowAttributesB;
|
||||
/** Window granularity in KB. */
|
||||
uint16_t WindowGranularity;
|
||||
/** Start segment of window A (0x0000 if not supported).*/
|
||||
uint16_t WindowStartSegmentA;
|
||||
/** Start segment of window B (0x0000 if not supported).*/
|
||||
uint16_t WindowStartSegmentB;
|
||||
/** FAR window positioning function (equivalent to AX = 0x4F05. */
|
||||
uint32_t WindowPositioningFunction;
|
||||
/** Bytes per scanline.*/
|
||||
uint16_t BytesPerScanline;
|
||||
/** Width in pixels (graphics) or characters (text).*/
|
||||
uint16_t Width;
|
||||
/** Height in pixels (graphics) or characters (text).*/
|
||||
uint16_t Height;
|
||||
/** Width of character cell in pixels. */
|
||||
uint8_t CharacterWidth;
|
||||
/** Height of character cell in pixels. */
|
||||
uint8_t CharacterHeight;
|
||||
/** Number of memory planes. */
|
||||
uint8_t MemoryPlanes;
|
||||
/** Number of bits per pixel. */
|
||||
uint8_t Bpp;
|
||||
/** Number of banks.*/
|
||||
uint8_t Banks;
|
||||
/** Memory model type, defined in VESAModeMemoryModels.*/
|
||||
uint8_t MemoryModelType;
|
||||
/** Size of bank in KB. */
|
||||
uint8_t BankSize;
|
||||
/** Number of image pages minus one, that will fit in video RAM.*/
|
||||
uint8_t ImagePages;
|
||||
/** Reserved, 0x00 for VBE 1.0 to 2.0, 0x01 for VBE 3.0.*/
|
||||
uint8_t Reserved_0;
|
||||
|
||||
/** (VESA v1.2+) Self explanatory.*/
|
||||
uint8_t RedMaskSize, RedFieldPosition;
|
||||
uint8_t GreenMaskSize, GreenFieldPosition;
|
||||
uint8_t BlueMaskSize, BlueFieldPosition;
|
||||
uint8_t ReservedMaskSize, ReservedFieldPosition;
|
||||
/** (VESA v1.2+) Direct Color Mode info\n
|
||||
Bit 0: color ramp is programmable\n
|
||||
Bit 1: bytes in reserved field may be used by application.*/
|
||||
uint8_t DirectColorModeInfo;
|
||||
/** (VESA v2.0+) Physical address of linear video buffer.*/
|
||||
void* LinearVideoBuffer;
|
||||
/** (VESA v2.0+) Pointer to start of offscreen memory.*/
|
||||
void* OffscreenMemory;
|
||||
/** (VESA v2.0+) KB of offscreen memory.*/
|
||||
uint16_t OffscreenMemorySize;
|
||||
|
||||
/** (VESA v3.0) Bytes per scanline in linear modes.*/
|
||||
uint16_t BytesPerScanlineLinear;
|
||||
/** (VESA v3.0) Number of images minus one for banked video modes.*/
|
||||
uint8_t ImagesBankedMode;
|
||||
/** (VESA v3.0) Number of images minus one for linear video modes.*/
|
||||
uint8_t ImagesLinearMode;
|
||||
/** (VESA v3.0) LINEAR MODES ONLY\n
|
||||
* \DirectColorMaskSize: size of direct color <color> mask (in bits).\n
|
||||
* \BitPosition: bit position of <color> mask LSB (e.g. shift count)*/
|
||||
uint8_t RedDirectColorMaskSize, RedBitPosition;
|
||||
uint8_t GreenDirectColorMaskSize, GreenBitPosition;
|
||||
uint8_t BlueDirectColorMaskSize, BlueBitPosition;
|
||||
uint8_t ReservedDirectColorMaskSize, ReservedBitPosition;
|
||||
/** (VESA v3.0) Maximum pixel clock for graphics video mode, in Hz*/
|
||||
uint32_t MaxPixelClock;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/**The structure passed by the bootloader. */
|
||||
typedef struct {
|
||||
/** How much memory is installed on the system (in KB). */
|
||||
uint64_t Memory;
|
||||
/** Boot device. */
|
||||
uint32_t BootDevice;
|
||||
/** Pointer to a char[] string containing kernel parameters. */
|
||||
unsigned char* CommandLine;
|
||||
/** Number of other modules loaded by the bootloader. */
|
||||
uint32_t ModulesCount;
|
||||
/** Pointer to where other modules were loaded. */
|
||||
void* ModulesAddress;
|
||||
/** Size of memory map. */
|
||||
uint32_t MemoryMapLength;
|
||||
/** Pointer to memory map. */
|
||||
void* MemoryMapAddress;
|
||||
/** Drives info length. */
|
||||
uint32_t DrivesLength;
|
||||
/** Pointer to drives info. */
|
||||
void* DrivesAddress;
|
||||
/** BIOS ROM configuration table. */
|
||||
uint32_t ConfigurationTable;
|
||||
/** Name of bootloader, should be "CTA" (0 ended string). */
|
||||
unsigned char BootloaderName[4];
|
||||
/** APM Table. */
|
||||
uint32_t APMTable;
|
||||
/** VGA current video mode information. */
|
||||
uint8_t VGACurrentVideoMode;
|
||||
uint8_t VGACurrentVideoModeColumns;
|
||||
uint8_t VGACurrentVideoPage;
|
||||
/** VESA video mode(s) information. */
|
||||
struct _VESA_CONTROLLER_INFO* VESAControllerInformation;
|
||||
|
||||
|
||||
uint32_t m_flags;
|
||||
uint32_t m_memoryLo;
|
||||
uint32_t m_memoryHi;
|
||||
uint32_t m_bootDevice;
|
||||
uint32_t m_cmdLine;
|
||||
uint32_t m_modsCount;
|
||||
uint32_t m_modsAddr;
|
||||
uint32_t m_syms0;
|
||||
uint32_t m_syms1;
|
||||
uint32_t m_syms2;
|
||||
uint32_t m_mmap_length;
|
||||
uint32_t m_mmap_addr;
|
||||
uint32_t m_drives_length;
|
||||
uint32_t m_drives_addr;
|
||||
uint32_t m_config_table;
|
||||
uint32_t m_bootloader_name;
|
||||
uint32_t m_apm_table;
|
||||
uint32_t m_vbe_control_info;
|
||||
uint32_t m_vbe_mode_info;
|
||||
uint16_t m_vbe_mode;
|
||||
uint32_t m_vbe_interface_addr;
|
||||
uint16_t m_vbe_interface_len;
|
||||
} multiboot_info ;
|
||||
|
||||
|
||||
|
@ -1,30 +1,104 @@
|
||||
#ifndef __CONIO_H
|
||||
#define __CONIO_H
|
||||
#define _ATTRIB 0x0F
|
||||
|
||||
extern unsigned char default_background, default_foreground;
|
||||
extern char hex[16];
|
||||
#include <stdlib.h>
|
||||
//#define _ATTRIB 0x0F
|
||||
|
||||
extern void itoa (int value, char *string, unsigned int radix);
|
||||
extern int printf(const char* str, ...);
|
||||
extern int abs(int x);
|
||||
extern void graphics_init();
|
||||
extern void text_mode_cursor(int x, int y);
|
||||
extern void set_default_colors(unsigned char back, unsigned char fore);
|
||||
typedef struct {
|
||||
/** Console window width. */
|
||||
unsigned width;
|
||||
/** Console window height. */
|
||||
unsigned height;
|
||||
/** Default colors (can be changed later with ConsoleSetDefaultColors() routine)*/
|
||||
unsigned char defcolors;
|
||||
/** Pointer to a routine to set the blinking cursor position.\n
|
||||
Parameters are as following: (int x, int y), where x, y is a 2D position on the screen. */
|
||||
void (*cursor)(int, int);
|
||||
/** Pointer to a routine to put a character in a specified position.\n
|
||||
Parameters are as following: (int x, int y, unsigned char c),\n
|
||||
* where: x, y = 2D position on the screen\n
|
||||
* c = ascii character*/
|
||||
void (*putc)(int, int, unsigned char);
|
||||
/** Pointer to a routine to return a character in a specified position.\n
|
||||
Parameters are as following: (int x, int y), where x, y is a 2D position on the screen. */
|
||||
unsigned char (*getc)(int, int);
|
||||
/** Pointer to a routine to set the colors for the character in the specified position\n
|
||||
Parameters are as following: (int x, int y, unsigned char color),\n
|
||||
* where: x, y = 2D position on the screen\n
|
||||
* color = index in 16 color palette for background (high nibble) and foreground (low nibble)*/
|
||||
void (*putcolor)(int, int, unsigned char);
|
||||
/** Pointer to a routine to return the colors for the character in the specified position\n
|
||||
Parameters are as following: (int x, int y, unsigned char c),\n
|
||||
* where: x, y = 2D position on the screen*/
|
||||
unsigned char (*getcolor)(int, int);
|
||||
} ConsoleScreen;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/**Integer coordonates*/
|
||||
int X, Y;
|
||||
} Point;
|
||||
|
||||
typedef struct {
|
||||
/**Unsigned integer coordonates.*/
|
||||
unsigned X, Y;
|
||||
} UPoint;
|
||||
|
||||
enum COLORS {
|
||||
BLACK = 0x0,
|
||||
BLUE = 0x1,
|
||||
GREEN = 0x2,
|
||||
CYAN = 0x3,
|
||||
RED = 0x4,
|
||||
MAGENTA = 0x5,
|
||||
BROWN = 0x6,
|
||||
LIGHTGRAY = 0x7,
|
||||
DARKGRAY = 0x8,
|
||||
LIGHTBLUE = 0x9,
|
||||
LIGHTGREEN = 0xA,
|
||||
LIGHTCYAN = 0xB,
|
||||
LIGHTRED = 0xC,
|
||||
LIGHTMAGENTA = 0xD,
|
||||
YELLOW = 0xE,
|
||||
WHITE = 0xF,
|
||||
BLINK = 0x80
|
||||
};
|
||||
|
||||
enum CURSORSHAPE {
|
||||
_NOCURSOR = 0x0,
|
||||
_SOLIDCURSOR = 0x1,
|
||||
_NORMALCURSOR = 0x2
|
||||
};
|
||||
|
||||
/***/
|
||||
//extern char* cgets(char* string);
|
||||
|
||||
|
||||
extern void ConsoleInstall(ConsoleScreen screen);
|
||||
extern void ConsoleUpdateCursor(UPoint position, unsigned char type);
|
||||
extern void ConsoleScroll(unsigned lines);
|
||||
|
||||
|
||||
/** Clears to end of line in text window\n\n
|
||||
Declaration: void clreol(void);\n\n
|
||||
Remarks:\n
|
||||
clreol clears all characters from the cursor position to the end of the line
|
||||
within the current text window, without moving the cursor.\n\n
|
||||
Return Value: None*/
|
||||
extern void clreol();
|
||||
extern void clrscr();
|
||||
extern void scroll(int n);
|
||||
extern void prev_line();
|
||||
extern void next_line();
|
||||
extern void putc_pos_font(int x, int y, char c, unsigned char back, unsigned char fore);
|
||||
extern void putc_pos(int x, int y, char c);
|
||||
extern void putc_font(char c, unsigned char back, unsigned char fore);
|
||||
extern void putc(char c);
|
||||
extern void puts_pos_font(int x, int y, const char *str, unsigned char back, unsigned char fore);
|
||||
extern void puts_pos(int x, int y, const char *str);
|
||||
extern void puts(const char *str);
|
||||
extern void puts_font(const char *str, unsigned char back, unsigned char fore);
|
||||
extern void put_hex(unsigned int alpha);
|
||||
extern void put_hex_pos(int x, int y, unsigned int alpha);
|
||||
extern void put_bin (int x, int y, unsigned char xz);
|
||||
|
||||
extern int gettext (int left, int top, int right, int bottom, unsigned char* dest);
|
||||
extern void gotoxy (int x, int y);
|
||||
extern int cprintf(const char* str, ...);
|
||||
extern int cputs(const char* str);
|
||||
extern int cgets(char* string, int maxlen);
|
||||
extern int getch();
|
||||
extern int getche();
|
||||
extern void movetext(int left, int top, int right, int bottom, int destleft, int desttop);
|
||||
extern int putch(const char c);
|
||||
extern int puttext(int left, int top, int right, int bottom, unsigned char* src);
|
||||
extern void _setcursortype (int cursor);
|
||||
extern int wherex();
|
||||
extern int wherey();
|
||||
|
||||
#endif
|
@ -1,55 +1,31 @@
|
||||
#ifndef __CTYPE_H
|
||||
#define __CTYPE_H
|
||||
|
||||
/******************************
|
||||
* ctype.h *
|
||||
* - character macros *
|
||||
******************************/
|
||||
extern unsigned char _ctype[];
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Get rid of conversion warnings
|
||||
#pragma warning (disable:4244)
|
||||
#endif
|
||||
#define _CTYPE_ISCONTROL 0x01 // 0000 0001
|
||||
#define _CTYPE_ISSPACE 0x02 // 0000 0010
|
||||
#define _CTYPE_ISBLANK 0x04 // 0000 0100 etc.
|
||||
#define _CTYPE_ISPUNCT 0x08
|
||||
#define _CTYPE_ISDIGIT 0x10
|
||||
#define _CTYPE_ISHEX 0x20
|
||||
#define _CTYPE_ISUPPER 0x40
|
||||
#define _CTYPE_ISLOWER 0x80
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#define isalnum(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT))
|
||||
#define isalpha(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER))
|
||||
#define isblank(c) (_ctype[(int)c+1] & (_CTYPE_ISBLANK))
|
||||
#define iscntrl(c) (_ctype[(int)c+1] & (_CTYPE_ISCONTROL))
|
||||
#define isdigit(c) (_ctype[(int)c+1] & (_CTYPE_ISDIGIT))
|
||||
#define isgraph(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT | _CTYPE_ISPUNCT))
|
||||
#define islower(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER))
|
||||
#define isprint(c) (_ctype[(int)c+1] & (_CTYPE_ISLOWER | _CTYPE_ISUPPER | _CTYPE_ISDIGIT | _CTYPE_ISPUNCT | _CTYPE_ISBLANK))
|
||||
#define ispunct(c) (_ctype[(int)c+1] & (_CTYPE_ISPUNCT))
|
||||
#define isspace(c) (_ctype[(int)c+1] & (_CTYPE_ISSPACE))
|
||||
#define isupper(c) (_ctype[(int)c+1] & (_CTYPE_ISUPPER))
|
||||
#define isxdigit(c) (_ctype[(int)c+1] & (_CTYPE_ISHEX))
|
||||
|
||||
extern char _ctype[];
|
||||
extern int toupper(int c);
|
||||
extern int tolower(int c);
|
||||
|
||||
/* Constants */
|
||||
|
||||
#define CT_UP 0x01 /* upper case */
|
||||
#define CT_LOW 0x02 /* lower case */
|
||||
#define CT_DIG 0x04 /* digit */
|
||||
#define CT_CTL 0x08 /* control */
|
||||
#define CT_PUN 0x10 /* punctuation */
|
||||
#define CT_WHT 0x20 /* white space (space/cr/lf/tab) */
|
||||
#define CT_HEX 0x40 /* hex digit */
|
||||
#define CT_SP 0x80 /* hard space (0x20) */
|
||||
|
||||
/* Basic macros */
|
||||
|
||||
#define isalnum(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW | CT_DIG))
|
||||
#define isalpha(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP | CT_LOW))
|
||||
#define iscntrl(c) ((_ctype + 1)[(unsigned)(c)] & (CT_CTL))
|
||||
#define isdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG))
|
||||
#define isgraph(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG))
|
||||
#define islower(c) ((_ctype + 1)[(unsigned)(c)] & (CT_LOW))
|
||||
#define isprint(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN | CT_UP | CT_LOW | CT_DIG | CT_SP))
|
||||
#define ispunct(c) ((_ctype + 1)[(unsigned)(c)] & (CT_PUN))
|
||||
#define isspace(c) ((_ctype + 1)[(unsigned)(c)] & (CT_WHT))
|
||||
#define isupper(c) ((_ctype + 1)[(unsigned)(c)] & (CT_UP))
|
||||
#define isxdigit(c) ((_ctype + 1)[(unsigned)(c)] & (CT_DIG | CT_HEX))
|
||||
#define isascii(c) ((unsigned)(c) <= 0x7F)
|
||||
#define toascii(c) ((unsigned)(c) & 0x7F)
|
||||
#define tolower(c) (isupper(c) ? c + 'a' - 'A' : c)
|
||||
#define toupper(c) (islower(c) ? c + 'A' - 'a' : c)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
@ -3,14 +3,15 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
//#include <..\hal\floppy\floppy.h>
|
||||
#define far
|
||||
#define near
|
||||
|
||||
#define i86_start_interrupts() __asm__ __volatile__ ("sti");
|
||||
#define i86_clear_interrupts() __asm__ __volatile__ ("cli");
|
||||
|
||||
extern volatile TIME _internal_clock;
|
||||
|
||||
extern TIME i86_pit_get_time() ;
|
||||
extern unsigned* i86_read_sector (unsigned* where, unsigned char drive, int sectorLBA);
|
||||
// initialize hardware abstraction layer
|
||||
extern void i86_hal_initialize ();
|
||||
|
||||
@ -23,10 +24,10 @@ extern int i86_hal_shutdown ();
|
||||
//! output sound to speaker
|
||||
extern void sound (unsigned frequency);
|
||||
|
||||
//! read byte from device using port mapped io
|
||||
//! read unsigned char from device using port mapped io
|
||||
//extern unsigned char inportb (unsigned short _port);
|
||||
|
||||
//! write byte to device through port mapped io
|
||||
//! write unsigned char to device through port mapped io
|
||||
//extern void outportb (unsigned short _port, unsigned char _data);
|
||||
|
||||
//! sets new interrupt vector
|
||||
@ -44,6 +45,7 @@ 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
|
||||
@ -51,130 +53,132 @@ extern void reboot();
|
||||
#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;
|
||||
extern volatile unsigned char 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_PREFIX_PAUSE1 0x08 // Recieved first unsigned char from pause/break
|
||||
extern volatile unsigned char 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 volatile unsigned char 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
|
||||
extern unsigned char kb_scancode_set;
|
||||
|
||||
enum KB_KEYS {
|
||||
KB_KEY_PAUSE = 0x00,
|
||||
KB_KEY_F9 = 0x01,
|
||||
KB_KEY_F7 = 0x02,
|
||||
KB_KEY_F5 = 0X03,
|
||||
KB_KEY_F3 = 0x04,
|
||||
KB_KEY_F1 = 0x05,
|
||||
KB_KEY_F2 = 0x06,
|
||||
KB_KEY_F12 = 0x07,
|
||||
KB_KEY_PRINTSCRN = 0x08,
|
||||
KB_KEY_F10 = 0x09,
|
||||
KB_KEY_F8 = 0x0A,
|
||||
KB_KEY_F6 = 0x0B,
|
||||
KB_KEY_F4 = 0x0C,
|
||||
KB_KEY_TAB = 0x0D,
|
||||
KB_KEY_TILDA = 0x0E,
|
||||
KB_KEY_Q = 0x15,
|
||||
KB_KEY_1 = 0x16,
|
||||
KB_KEY_Z = 0x1A,
|
||||
KB_KEY_S = 0x1B,
|
||||
KB_KEY_A = 0x1C,
|
||||
KB_KEY_W = 0x1D,
|
||||
KB_KEY_2 = 0x1E,
|
||||
KB_KEY_LWIN = 0x1F,
|
||||
KB_KEY_C = 0x21,
|
||||
KB_KEY_X = 0x22,
|
||||
KB_KEY_D = 0x23,
|
||||
KB_KEY_E = 0x24,
|
||||
KB_KEY_4 = 0x25,
|
||||
KB_KEY_3 = 0x26,
|
||||
KB_KEY_RWIN = 0x27,
|
||||
KB_KEY_SPACE = 0x29,
|
||||
KB_KEY_V = 0x2A,
|
||||
KB_KEY_F = 0x2B,
|
||||
KB_KEY_T = 0x2C,
|
||||
KB_KEY_R = 0x2D,
|
||||
KB_KEY_5 = 0x2E,
|
||||
KB_KEY_MENU = 0x2F,
|
||||
KB_KEY_N = 0x31,
|
||||
KB_KEY_B = 0x32,
|
||||
KB_KEY_H = 0x33,
|
||||
KB_KEY_G = 0x34,
|
||||
KB_KEY_Y = 0x35,
|
||||
KB_KEY_6 = 0x36,
|
||||
KB_KEY_M = 0x3A,
|
||||
KB_KEY_J = 0x3B,
|
||||
KB_KEY_U = 0x3C,
|
||||
KB_KEY_7 = 0x3D,
|
||||
KB_KEY_8 = 0x3E,
|
||||
KB_KEY_COMMA = 0x41,
|
||||
KB_KEY_K = 0x42,
|
||||
KB_KEY_I = 0x43,
|
||||
KB_KEY_O = 0x44,
|
||||
KB_KEY_0 = 0x45,
|
||||
KB_KEY_9 = 0x46,
|
||||
KB_KEY_PERIOD = 0x49,
|
||||
KB_KEY_SLASH = 0x4A,
|
||||
KB_KEY_L = 0x4B,
|
||||
KB_KEY_SEMICOLON = 0x4C,
|
||||
KB_KEY_P = 0x4D,
|
||||
KB_KEY_DASH = 0x4E,
|
||||
KB_KEY_APOSTROPHE = 0x52,
|
||||
KB_KEY_LBRACKET = 0x54,
|
||||
KB_KEY_EQUAL = 0x55,
|
||||
KB_KEY_NUMPAD_ENTER = 0x59,
|
||||
KB_KEY_ENTER = 0x5A,
|
||||
KB_KEY_RBRACKET = 0x5B,
|
||||
KB_KEY_BACKSLASH = 0x5D,
|
||||
KB_KEY_END = 0x5E,
|
||||
KB_KEY_LEFT = 0x5F,
|
||||
KB_KEY_HOME = 0x60,
|
||||
KB_KEY_INSERT = 0x61,
|
||||
KB_KEY_DELETE = 0x62,
|
||||
KB_KEY_DOWN = 0x63,
|
||||
KB_KEY_RIGHT = 0x64,
|
||||
KB_KEY_UP = 0x65,
|
||||
KB_KEY_BACKSPACE = 0x66,
|
||||
KB_KEY_PGDOWN = 0x67,
|
||||
KB_KEY_PGUP = 0x68,
|
||||
KB_KEY_NUMPAD_1 = 0x69,
|
||||
KB_KEY_NUMPAD_SLASH = 0x6A,
|
||||
KB_KEY_NUMPAD_4 = 0x6B,
|
||||
KB_KEY_NUMPAD_7 = 0x6C,
|
||||
KB_KEY_NUMPAD_0 = 0x70,
|
||||
KB_KEY_NUMPAD_COLON = 0x71,
|
||||
KB_KEY_NUMPAD_2 = 0x72,
|
||||
KB_KEY_NUMPAD_5 = 0x73,
|
||||
KB_KEY_NUMPAD_6 = 0x74,
|
||||
KB_KEY_NUMPAD_8 = 0x75,
|
||||
KB_KEY_ESC = 0x76,
|
||||
KB_KEY_F11 = 0x78,
|
||||
KB_KEY_NUMPAD_PLUS = 0x79,
|
||||
KB_KEY_NUMPAD_3 = 0x7A,
|
||||
KB_KEY_NUMPAD_MINUS = 0x7B,
|
||||
KB_KEY_NUMPAD_ASTERISK = 0x7C,
|
||||
KB_KEY_NUMPAD_9 = 0x7D
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
byte status;
|
||||
byte lights;
|
||||
byte scancode;
|
||||
byte character;
|
||||
unsigned char status;
|
||||
unsigned char lights;
|
||||
unsigned char scancode;
|
||||
unsigned char character;
|
||||
} kb_key;
|
||||
|
||||
|
||||
extern char getch();
|
||||
//extern char getch();
|
||||
extern kb_key getkey();
|
||||
extern char scancode_to_ascii(byte scancode, byte status);
|
||||
extern byte get_key_status(byte scancode);
|
||||
extern char scancode_to_ascii(unsigned char scancode, unsigned char status);
|
||||
extern unsigned char get_key_status(unsigned char scancode);
|
||||
extern void kb_set_repeat(float rate, int delay);
|
||||
extern void kb_set_LEDs(byte status);
|
||||
extern void kb_set_LEDs(unsigned char status);
|
||||
|
||||
#endif
|
93
SysCore/include/stdlib.h
Normal file
93
SysCore/include/stdlib.h
Normal file
@ -0,0 +1,93 @@
|
||||
#ifndef __STDLIB_H__
|
||||
#define __STDLIB_H__
|
||||
|
||||
/** Returns the absolute value of an integer.*/
|
||||
#define abs(x) (x>0) ? (x) : (x*-1)
|
||||
/** Returns the absolute value of a long variable.*/
|
||||
#define labs(x) (x>0) ? (x) : (x*-1)
|
||||
/** Returns the maximum of two numbers.*/
|
||||
#define max(a, b) (a > b) ? a : b
|
||||
/** Returns the minimum of two numbers.*/
|
||||
#define min(a, b) (a < b) ? a : b
|
||||
#define NULL 0
|
||||
|
||||
/** div_t is a structure of integers used by div()\n
|
||||
Notes:\n
|
||||
- quot = quotient;\n
|
||||
- rem = remainder;\n */
|
||||
typedef struct {
|
||||
/** Quotient */
|
||||
long quot;
|
||||
/** Remainder */
|
||||
long rem;
|
||||
} div_t;
|
||||
|
||||
/** ldiv_t is a structure of integers used by ldiv()\n
|
||||
Notes:\n
|
||||
- quot = quotient;\n
|
||||
- rem = remainder;\n */
|
||||
typedef struct {
|
||||
/** Quotient*/
|
||||
long quot;
|
||||
/** Remainder*/
|
||||
long rem;
|
||||
} ldiv_t;
|
||||
|
||||
|
||||
// TODO: extern long double _atold (const char* string);
|
||||
// TODO: extern double atof (const char* string); // TODO: initialize FPU
|
||||
|
||||
/** Convert ASCII string to INT */
|
||||
extern int atoi (const char* string);
|
||||
|
||||
/** Convert ASCII string to LONG */
|
||||
extern long atol (const char* string);
|
||||
|
||||
/** Convert ASCII string in hexadecimal to unsigned integer.*/
|
||||
extern unsigned int atox (const char* string);
|
||||
|
||||
/** Peform a binary search\n
|
||||
Notes:\n
|
||||
- const void* key = A pointer to the element to look for\n
|
||||
- const void* base = A pointer to the first element of the table\n
|
||||
- unsigned nelem = The number of elements in the table\n
|
||||
- unsigned width = The size of one element of the table\n
|
||||
- int *fcmp = A user defined comparison routine\n */
|
||||
extern void* bsearch (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*));
|
||||
|
||||
/**Divides two integers and returns both the quotient and the remainder as a div_t structure.*/
|
||||
extern div_t div (int numerator, int denominator);
|
||||
|
||||
/** Convert SIGNED INT to ASCII string */
|
||||
extern void itoa (signed int value, char *string, int radix);
|
||||
|
||||
/**Divides two longs and returns both the quotient and the remainder as a ldiv_t structure.*/
|
||||
extern ldiv_t ldiv (long numerator, long denominator);
|
||||
|
||||
/**Does a linear search for *key in a table\n
|
||||
Notes:\n
|
||||
- const void* key = A pointer to the element to look for\n
|
||||
- const void* base = A pointer to the first element of the table\n
|
||||
- unsigned nelem = The number of elements in the table\n
|
||||
- unsigned width = The size of one element of the table\n
|
||||
- int *fcmp = A user defined comparison routine\n */
|
||||
void* lfind (const void* key, const void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*));
|
||||
|
||||
/** Convert SIGNED LONG to ASCII string */
|
||||
extern void ltoa (signed long value, char *string, int radix);
|
||||
|
||||
/** Sorts an array using an optimized quick sort algorithm.\n
|
||||
Notes:\n
|
||||
- void base = A pointer to the first element of the table\n
|
||||
- unsigned *nelem = The number of elements in the table\n
|
||||
- unsigned width = The size of one element of the table\n
|
||||
- int *fcmp = A user defined comparison routine\n */
|
||||
void qsort (void* base, unsigned nelem, unsigned width, int (*fcmp)(const void*, const void*));
|
||||
|
||||
/** Convert UNSIGNED INT to ASCII string */
|
||||
extern void uitoa (unsigned int value, char *string, int radix);
|
||||
|
||||
/** Convert UNSIGNED LONG to ASCII string */
|
||||
extern void ultoa (unsigned long value, char *string, int radix);
|
||||
|
||||
#endif
|
@ -1,21 +1,19 @@
|
||||
#ifndef __TIME_C
|
||||
#define __TIME_C
|
||||
|
||||
extern const char* clock_months[13];
|
||||
extern const char* clock_weekdays[8];
|
||||
extern byte clock_months_len[13];
|
||||
extern const char* clock_month[13];
|
||||
extern const char* clock_weekday[8];
|
||||
extern unsigned char clock_month_len[13];
|
||||
|
||||
typedef struct {
|
||||
byte seconds;
|
||||
byte minutes;
|
||||
byte hours;
|
||||
byte weekday;
|
||||
byte day;
|
||||
byte month;
|
||||
byte year;
|
||||
byte century;
|
||||
byte am_pm;
|
||||
|
||||
unsigned char second;
|
||||
unsigned char minute;
|
||||
unsigned char hour;
|
||||
unsigned char weekday;
|
||||
unsigned char day;
|
||||
unsigned char month;
|
||||
unsigned char year;
|
||||
unsigned char century;
|
||||
} TIME;
|
||||
|
||||
extern void _CLOCK_INC(TIME *tim);
|
||||
|
Reference in New Issue
Block a user