00001 enum VideoMode {
00002 Text40x25BW = 0x0000,
00003
00004 Text40x25C = 0x0001,
00005 Text40 = 0x0001,
00006
00007 Text80x25BW = 0x0002,
00008
00009 Text80x25C = 0x0003,
00010 Text80 = 0x0003,
00011
00012 Graph320x200x4C = 0x0004,
00013 Graph320x200x4BW = 0x0005,
00014
00015 Graph640x200x4C = 0x0006,
00016
00017 GraphMonoCard = 0x0007,
00018
00019 Graph160x200x16 = 0x0008,
00020 Graph320x200x16 = 0x0009,
00021 Graph640x200x4 = 0x000A,
00022
00023 Graph320x200x16 = 0x000D,
00024 Graph640x200x16 = 0x000E,
00025 Graph640x350BW = 0x000F,
00026 Graph640x350x16 = 0x0010,
00027
00028 Graph640x480x2 = 0x0011,
00029
00030 Graph640x480x16 = 0x0012,
00031 VGA16 = 0x0012,
00032
00033 Graph320x200x256 = 0x0013,
00034 VGA256 = 0x0013
00035 };
00036
00037 struct textPos_t {
00038 UCHAR row;
00039 UCHAR col;
00040 };
00041
00042 typedef textPos_t cursor_t;
00043
00044 struct graphPos_t {
00045 UCHAR row;
00046 USHORT col;
00047 };
00048
00049 struct flash_cursor_t {
00050 UCHAR row_start;
00051 UCHAR row_end;
00052 };
00053
00054 struct cursorInfo_t {
00055 textPos_t normal;
00056 flash_cursor_t flashing;
00057 };
00058
00059 struct opticPen_t {
00060 textPos_t text;
00061 graphPos_t graph;
00062 UCHAR success;
00063 };
00064
00065 struct charInfo_t {
00066 UCHAR Ascii;
00067 UCHAR color;
00068 };
00069
00070 class BIOS_Video {
00071
00072 static void setVideo( VideoMode mode ) {
00073 USHORT vmode = (USHORT)mode;
00074
00075
00076 __asm {
00077 push ax
00078
00079 mov ax, vmode
00080 int 10h
00081
00082 pop ax
00083 }
00084 }
00085
00086 inline void setText() { setVideo( Text80 ); }
00087 inline void setVGA16() { setVideo( VGA16 ); }
00088 inline void setVGA256() { setVideo( VGA256 ); }
00089
00090 static void setCursor( UCHAR pageNo, UCHAR row, UCHAR col ) {
00091
00092
00093 __asm {
00094 push ax
00095 push bx
00096 push dx
00097
00098 mov ah, 02h
00099 mov bh, pageNo
00100 mov dh, row
00101 mov dl, col
00102
00103 int 10h
00104
00105 pop dx
00106 pop bx
00107 pop ax
00108 }
00109 }
00110
00111 static cursorInfo_t getCursor( UCHAR pageNo ) {
00112 cursorInfo_t c;
00113
00114
00115 __asm {
00116 push ax
00117 push bx
00118 push cx
00119 push dx
00120
00121 mov ah, 03h
00122 mov bh, pageNo
00123
00124 int 10h
00125
00126 mov c.normal.row dh
00127 mov c.normal.col, dl
00128 mov c.flash.row_start, ch
00129 mov c.flash.row_end, cl
00130
00131 pop dx
00132 pop cx
00133 pop bx
00134 pop ax
00135 }
00136
00137 return c;
00138 }
00139
00140 static opticPen_t getOpticPenPosition() {
00141 opticPen_t p;
00142
00143
00144 __asm {
00145 push ax
00146 push bx
00147 push cx
00148 push dx
00149
00150 mov ah, 04h
00151
00152 int 10h
00153
00154 mov p.success, ah
00155 mov p.text.row, dh
00156 mov p.text.col, dl
00157 mov p.graph.row, ch
00158 mov p.graph.col, bx
00159
00160 pop dx
00161 pop cx
00162 pop bx
00163 pop ax
00164 }
00165
00166 return p;
00167 }
00168
00169 static void setPageNo( UCHAR pageNo ) {
00170
00171
00172 __asm {
00173 push ax
00174
00175 mov ah, 05h
00176 mov al, pageNo
00177 int 10h
00178
00179 pop ax
00180 }
00181 }
00182
00183
00184
00185 static void scrollText( UCHAR dir, UCHAR nbLines, UCHAR color,
00186 textPos_t UpLeft, textPos_t DownRight )
00187 {
00188 UCHAR UpDown = 0x06;
00189 if ( dir != 0 ) { UpDown++; }
00190
00191
00192 __asm {
00193 push ax
00194 push bx
00195 push cx
00196 push dx
00197
00198 mov ah, UpDown
00199 mov al, nbLines
00200 mov bh, color
00201
00202 mov ch, UpLeft.row
00203 mov cl, UpLeft.col
00204
00205 mov dh, DownRight.row
00206 mov dl, DownRight.col
00207
00208 int 10h
00209
00210 pop dx
00211 pop cx
00212 pop bx
00213 pop ax
00214 }
00215 }
00216
00217 static charInfo_t readChar( UCHAR pageNo ) {
00218
00219 charInfo_t c;
00220
00221
00222 __asm {
00223 push ax
00224 push bx
00225
00226 mov ah, 08h
00227 mov bh, pageNo
00228
00229 int 10h
00230
00231 mov c.Ascii, al
00232 mov c.color, ah
00233
00234 pop bx
00235 pop ax
00236 }
00237
00238 return c;
00239 }
00240
00241
00242
00243
00244 static void writeCharWithAttributes( UCHAR pageNo, USHORT nbTimes,
00245 UCHAR AsciiCode, UCHAR attributes )
00246 {
00247
00248
00249 __asm {
00250 push ax
00251 push bx
00252 push cx
00253
00254 mov ah, 09h
00255 mov bh, pageNo
00256 mov cx, nbTimes
00257
00258 mov al, AsciiCode
00259 mov bl, attributes
00260
00261 int 10h
00262
00263 pop cx
00264 pop bx
00265 pop ax
00266 }
00267 }
00268
00269
00270
00271
00272 static void writeChar( UCHAR pageNo, USHORT nbTimes, UCHAR AsciiCode )
00273 {
00274
00275
00276 __asm {
00277 push ax
00278 push bx
00279 push cx
00280
00281 mov ah, 0Ah
00282 mov bh, pageNo
00283 mov cx, nbTimes
00284
00285 mov al, AsciiCode
00286
00287 int 10h
00288
00289 pop cx
00290 pop bx
00291 pop ax
00292 }
00293 }
00294
00295 static void borderColor( UCHAR color )
00296 {
00297
00298 __asm {
00299 push ax
00300 push bx
00301
00302 mov ah, 0Bh
00303 xor bh, bh
00304 mov bl, color
00305
00306 int 10h
00307
00308 pop bx
00309 pop ax
00310 }
00311 }
00312
00313 static void setPalette( UCHAR paletteNo )
00314 {
00315
00316 __asm {
00317 push ax
00318 push bx
00319
00320 mov ah, 0Bh
00321 mov bh, 01h
00322 mov bl, color
00323
00324 int 10h
00325
00326 pop bx
00327 pop ax
00328 }
00329 }
00330
00331
00332 };