00001
00002
00003 #ifndef vga_console_h
00004 #define vga_console_h
00005
00006 #include "types.h"
00007 #include "console.h"
00008
00009
00010
00011
00012
00013
00020 class Vga_console : public Console
00021 {
00022 public:
00023
00027 void clear();
00028
00033 void scroll( unsigned n );
00034
00039 Address video_base() const;
00040
00045 void video_base( Address base );
00046
00057 Vga_console( Address base, unsigned width = 80, unsigned height = 25,
00058 bool light_white = false, bool use_color = false );
00059
00063 ~Vga_console();
00064
00068 int write( char const *str, size_t len );
00069
00073 int getchar( bool blocking = true );
00074
00075 inline bool const is_working();
00076
00077 private:
00078
00080 struct VChar {
00081 char c;
00082 char a;
00083 } __attribute__((packed));
00084
00085 VChar *_video_base;
00086 Address _crtc;
00087 unsigned _width, _height;
00088 unsigned _x, _y;
00089 unsigned _attribute;
00090 enum {
00091 MAX_ANSI_ESC_ARGS = 5,
00092 };
00093
00094 int ansi_esc_args[MAX_ANSI_ESC_ARGS];
00095 unsigned num_ansi_esc_args;
00096
00097 void (Vga_console::*wr)(char const *, size_t, unsigned & );
00098
00099 bool const _light_white;
00100 bool const _use_color;
00101 bool _is_working;
00102
00106 void blink_cursor( unsigned x, unsigned y );
00107
00108 public:
00109 Mword get_attributes() const;
00110
00111 private:
00112 inline int seq_6( char const *str, size_t len, unsigned &pos );
00113
00114 inline int seq_1( char const *, size_t, unsigned & );
00115
00116 inline int seq_5( char const *, size_t , unsigned & );
00117
00118 inline void ansi_attrib( int a );
00119
00120 void esc_write( char const *str, size_t len, unsigned &i );
00121
00122 void ansi_esc_write( char const *str, size_t len, unsigned &i );
00123
00124 void normal_write( char const *str, size_t len, unsigned &i );
00125 };
00126
00127
00128
00129
00130
00131
00132
00133
00134 inline bool const Vga_console::is_working()
00135 {
00136 return _is_working;
00137 }
00138
00139 #endif // vga_console_h