blob: 35e96c65e6957e69d0edce268e1e25782933359d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#include "vesa.h"
#include "graphics.h"
#include "../lib/lib.h"
#include "../input/input.h"
#include "../system.h"
void switch_to_vga() {
regs16_t regs;
regs.ax = 0x0003;
int32(0x10, ®s);
init();
terminal_write_line("FAILED!");
keyboard_install();
}
vbe_mode_info *vbe_set_mode(unsigned short mode) {
regs16_t regs;
regs.ax = 0x4F02;
regs.bx = mode | (1 << 14);
int32(0x10, ®s);
if (regs.ax == 0x004F) {
regs.ax = 0x4F01;
regs.cx = mode;
regs.di = 0x0000;
regs.es = 0xA000;
int32(0x10, ®s);
if (regs.ax != 0x004F) {
switch_to_vga();
}
vbe_mode_info *vbe_info = (vbe_mode_info *) 0xA0000;
vbe_width = vbe_info->width;
vbe_height = vbe_info->height;
vbe_bpp = vbe_info->bpp / 8;
vbe_pitch = vbe_info->pitch;
char *fb = (char *) vbe_info->framebuffer;
for (int i = 0; i < vbe_width * vbe_height * vbe_bpp; i++) {
fb[i] = 100;
fb[i + 1] = 100;
fb[i + 2] = 100;
}
regs.ax = 0x0000;
int32(0x16, ®s);
regs.ax = 0x0003;
int32(0x10, ®s);
return vbe_info;
} else {
switch_to_vga();
}
vbe_mode_info vbe_info;
return &vbe_info;
}
void set_optimal_resolution() {
extern vbe_info *vbe_init_structure;
regs16_t regs;
regs.ax = 0x4F00;
regs.di = vbe_init_structure;
regs.es = 0xA000;
int32(0x10, ®s);
if (regs.ax != 0x004F) {
switch_to_vga();
}
vbe_info *vbe_modes = (vbe_info *) 0xA0000;
if (strcmp(vbe_modes->signature, "VESA") == 0) {
init();
terminal_write_string("SUCCESS!\n");
keyboard_install();
} else {
init();
terminal_write_string("FAILED!\n");
keyboard_install();
}
}
|