feat: ajout d'une gestion de pilotes video dans la projection de faire un pilote VBE/VESA
This commit is contained in:
parent
5683c69311
commit
86c4e4550e
|
@ -8,7 +8,7 @@ typedef struct vertex2d{
|
|||
u32 y;
|
||||
} vertex2d __attribute__ ((packed));
|
||||
|
||||
|
||||
void writepxl (u16 x, u16 y, u32 c);
|
||||
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color);
|
||||
void linev(vertex2d *A, vertex2d *B, u8 color);
|
||||
void hline(u32 x1, u32 x2, u32 y, u8 color);
|
||||
|
|
140
include/vga.h
140
include/vga.h
|
@ -6,41 +6,109 @@
|
|||
#define TEXTSCREEN 0xB8000 /* debut de la memoire video texte*/
|
||||
#define GRPHSCREEN 0xA0000 /* debut de la memoire video graphique*/
|
||||
|
||||
typedef u8 mode_def[64];
|
||||
/* Registres VGAs */
|
||||
|
||||
#define sequencer 0x3c4
|
||||
#define misc_write 0x3c2
|
||||
#define misc_read 0x3cc
|
||||
#define ccrt 0x3D4
|
||||
#define attribs 0x3c0
|
||||
#define graphics 0x3ce
|
||||
#define state 0x3da
|
||||
|
||||
u32 setvmode(u8);
|
||||
u32 loadfont(u8* def,u8 size,u8 font);
|
||||
void gotoscr(u16 x,u16 y);
|
||||
void useplane(u8 plan);
|
||||
u8 getfont(void);
|
||||
void setfont(u8 num);
|
||||
void waitvretrace(void);
|
||||
void waithretrace(void);
|
||||
void enablecursor(void);
|
||||
void disablecursor(void);
|
||||
void enablescroll(void);
|
||||
void disablescroll(void);
|
||||
void (*writepxl)(u16 x, u16 y, u32 c);
|
||||
void (*showchar)(u16 coordx,u16 coordy,u8 thechar,u8 attrib);
|
||||
void (*fill)(u8 attrib);
|
||||
void (*scroll)(u8 lines,u8 attrib);
|
||||
void split(u16 x);
|
||||
void showpage(u8 page);
|
||||
u8 getpage();
|
||||
void setpage(u8 page);
|
||||
u16 getnbpages(void);
|
||||
u16 getyres(void);
|
||||
u8 getdepth(void);
|
||||
u16 getxres(void);
|
||||
u8 getfont2(void);
|
||||
void enableblink(void);
|
||||
void disableblink(void);
|
||||
u8 (*getchar)(u16 coordx,u16 coordy);
|
||||
u8 (*getattrib)(u16 coordx,u16 coordy);
|
||||
void outreg(u16 port,u8 *src,u16 num);
|
||||
void outregsame(u16 port,u8 *src,u16 num);
|
||||
void inreg(u16 port,u8 *src,u16 num);
|
||||
void inregsame(u16 port,u8 *src,u16 num);
|
||||
u8 nextvmode(void);
|
||||
u8 getvmode(void);
|
||||
/* Taille d'un plan de bit */
|
||||
|
||||
#define planesize 0x10000
|
||||
|
||||
/* Registres VGA */
|
||||
typedef struct misc_regs {
|
||||
u8 Miscellaneous_Output_Register;
|
||||
} misc_reg __attribute__ ((packed));
|
||||
|
||||
typedef struct sequencer_regs {
|
||||
u8 Reset_Register;
|
||||
u8 Clocking_Mode_Register;
|
||||
u8 Map_Mask_Register;
|
||||
u8 Character_Map_Select_Register;
|
||||
u8 Sequencer_Memory_Mode_Register;
|
||||
} sequencer_reg __attribute__ ((packed));
|
||||
|
||||
typedef struct crtc_regs {
|
||||
u8 Horizontal_Total_Register;
|
||||
u8 End_Horizontal_Display_Register;
|
||||
u8 Start_Horizontal_Blanking_Register;
|
||||
u8 End_Horizontal_Blanking_Register;
|
||||
u8 Start_Horizontal_Retrace_Register;
|
||||
u8 End_Horizontal_Retrace_Register;
|
||||
u8 Vertical_Total_Register;
|
||||
u8 Overflow_Register;
|
||||
u8 Preset_Row_Scan_Register;
|
||||
u8 Maximum_Scan_Line_Register;
|
||||
u8 Cursor_Start_Register;
|
||||
u8 Cursor_End_Register;
|
||||
u8 Start_Address_High_Register;
|
||||
u8 Start_Address_Low_Register;
|
||||
u8 Cursor_Location_High_Register;
|
||||
u8 Cursor_Location_Low_Register;
|
||||
u8 Vertical_Retrace_Start_Register;
|
||||
u8 Vertical_Retrace_End_Register;
|
||||
u8 Vertical_Display_End_Register;
|
||||
u8 Offset_Register;
|
||||
u8 Underline_Location_Register;
|
||||
u8 Start_Vertical_Blanking_Register;
|
||||
u8 End_Vertical_Blanking;
|
||||
u8 CRTC_Mode_Control_Register;
|
||||
u8 Line_Compare_Register;
|
||||
} crtc_regs __attribute__ ((packed));
|
||||
|
||||
typedef struct graphics_regs {
|
||||
u8 Set_Reset_Register;
|
||||
u8 Enable_Set_Reset_Register;
|
||||
u8 Color_Compare_Register;
|
||||
u8 Data_Rotate_Register;
|
||||
u8 Read_Map_Select_Register;
|
||||
u8 Graphics_Mode_Register;
|
||||
u8 Miscellaneous_Graphics_Register;
|
||||
u8 Color_Dont_Care_Register;
|
||||
u8 Bit_Mask_Register;
|
||||
} graphics_regs __attribute__ ((packed));
|
||||
|
||||
typedef struct attributs_regs {
|
||||
u8 Palette Registers[16];
|
||||
u8 Attribute_Mode_Control_Register;
|
||||
u8 Overscan_Color_Register;
|
||||
u8 Color_Plane_Enable_Register;
|
||||
u8 Horizontal_Pixel_Panning_Register;
|
||||
u8 Color_Select_Register;
|
||||
} attributs_regs __attribute__ ((packed));
|
||||
|
||||
typedef struct vgamode {
|
||||
misc_regs misc;
|
||||
sequencer_regs sequencer;
|
||||
crtc_regs ctrc;
|
||||
graphics_regs graphic;
|
||||
attributs_regs attribut;
|
||||
} vgamode __attribute__ ((packed));
|
||||
|
||||
/* fonction obligatoires */
|
||||
u8 *VGA_detect_hardware (void);
|
||||
u8 VGA_setvideo_mode (u8 mode);
|
||||
u8 *VGA_getvideo_drivername (void);
|
||||
u8 *VGA_getvideo_capabilities (void);
|
||||
videoinfos *VGA_getvideo_info (void);
|
||||
u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src);
|
||||
u32 VGA_video_to_mem (u32 src,void *dst, u32 size);
|
||||
u32 VGA_video_to_video (u32 src,u32 dst, u32 size);
|
||||
void VGA_wait_vretrace (void);
|
||||
void VGA_wait_hretrace (void);
|
||||
void VGA_page_set (u8 page);
|
||||
void VGA_page_show (u8 page);
|
||||
void VGA_page_split (u16 y);
|
||||
void VGA_cursor_enable (void);
|
||||
void VGA_cursor_disable (void);
|
||||
void VGA_cursor_set (u16 x,u16 y);
|
||||
u32 VGA_font_load (u8 * def, u8 size, u8 font);
|
||||
void VGA_font1_set (u8 num);
|
||||
void VGA_font2_set (u8 num);
|
||||
void VGA_blink_enable (void);
|
||||
void VGA_blink_disable (void);
|
||||
|
|
106
include/video.h
106
include/video.h
|
@ -4,6 +4,42 @@
|
|||
|
||||
#include "stdarg.h"
|
||||
|
||||
#define maxdrivers 10
|
||||
|
||||
typedef struct drivers {
|
||||
u8* nom;
|
||||
videofonction* pointer;
|
||||
}
|
||||
|
||||
typedef struct capabilities {
|
||||
u8 modenumber;
|
||||
u16 width;
|
||||
u16 height;
|
||||
bool graphic;
|
||||
u8 depth;
|
||||
u8 refresh;
|
||||
}
|
||||
|
||||
typedef struct videoinfos {
|
||||
u8 currentmode
|
||||
u16 currentwidth;
|
||||
u16 currentheight;
|
||||
u8 currentdepth;
|
||||
u8 currentactivepage;
|
||||
u8 currentshowedpage;
|
||||
u16 currentcursorX;
|
||||
u16 currentcursorY;
|
||||
u8 currentfont1;
|
||||
u8 currentfont2;
|
||||
u16 currentpitch;
|
||||
bool isgraphic;
|
||||
bool isblinking;
|
||||
bool iscursorvisible;
|
||||
u8 pagesnumber;
|
||||
u32 pagesize;
|
||||
u32 baseaddress;
|
||||
} videoinfos __attribute__ ((packed));
|
||||
|
||||
typedef struct console {
|
||||
u8 attrib;
|
||||
s16 cursX;
|
||||
|
@ -15,10 +51,45 @@ typedef struct console {
|
|||
u8 page;
|
||||
} console __attribute__ ((packed));
|
||||
|
||||
typedef struct videofonction {
|
||||
u8 *(*detect_hardware) (void);
|
||||
u8 (*setvideo_mode) (u8 mode);
|
||||
u8 *(*getvideo_drivername) (void);
|
||||
u8 *(*getvideo_capabilities) (void);
|
||||
videoinfos *(*getvideo_info) (void);
|
||||
u32 (*mem_to_video) (void *src,u32 dst, u32 size, bool increment_src);
|
||||
u32 (*video_to_mem) (u32 src,void *dst, u32 size);
|
||||
u32 (*video_to_video) (u32 src,u32 dst, u32 size);
|
||||
void (*wait_vretrace) (void);
|
||||
void (*wait_hretrace) (void);
|
||||
void (*page_set) (u8 page);
|
||||
void (*page_show) (u8 page);
|
||||
void (*page_split) (u16 y);
|
||||
void (*cursor_enable) (void);
|
||||
void (*cursor_disable) (void);
|
||||
void (*cursor_set) (u16 x,u16 y);
|
||||
u32 (*font_load) (u8 * def, u8 size, u8 font);
|
||||
void (*font1_set) (u8 num);
|
||||
void (*font2_set) (u8 num);
|
||||
void (*blink_enable) (void);
|
||||
void (*blink_disable) (void);
|
||||
} videofonction __attribute__ ((packed));
|
||||
|
||||
void showhex(u8 src);
|
||||
/* Fonctions de bas niveau */
|
||||
void fill(u8 attrib);
|
||||
void scroll (u8 lines, u8 attrib);
|
||||
void scroll_enable(void);
|
||||
void scroll_disable(void);
|
||||
void showchar (u16 coordx, u16 coordy, u8 thechar, u8 attrib);
|
||||
u8 getchar (u16 coordx, u16 coordy);
|
||||
u8 getattrib (u16 coordx, u16 coordy);
|
||||
|
||||
/* Fonctions de console */
|
||||
void changevc(u8 vc);
|
||||
void putchar(u8 thechar);
|
||||
void clearscreen(void);
|
||||
|
||||
/* Fonctions de haut niveau */
|
||||
u32 print(u8* string);
|
||||
u32 printf (const u8 *string, ...);
|
||||
u32 sprintf(u8 *variable, const u8 *string, ...);
|
||||
|
@ -26,9 +97,40 @@ u32 snprintf(u8 *variable, u32 maxsize, const u8 *string, ...);
|
|||
u32 vprintf(const u8 * string, va_list args);
|
||||
u32 vsprintf(u8 *variable, const u8 *string, va_list args);
|
||||
u32 vsnprintf(u8 *variable, u32 maxsize, const u8 *string, va_list args);
|
||||
void changevc(u8 vc);
|
||||
|
||||
u8* itoa(u64 num, u8* str, u8 base, u64 dim, u8 achar);
|
||||
u8* sitoa(u64 num, u8 * str, u64 dim);
|
||||
u8* rtoadouble(double num, u8 * str, u8 precisioni , u8 precisionf);
|
||||
u8* rtoasingle(float num, u8 * str, u8 precisioni , u8 precisionf);
|
||||
u32 format(const u8 * string, va_list args, u32 maxsize, u32 (*fonction)(u8* src, u8** dest, u32 len), u8* dest);
|
||||
|
||||
/* Fonction pour gérer le pilote */
|
||||
void initdriver();
|
||||
void registerdriver(videofonction *pointer);
|
||||
void apply_bestdriver(void);
|
||||
void apply_nextdriver(void);
|
||||
void apply_driver(u8* name);
|
||||
void apply_nextvideomode(void);
|
||||
|
||||
/* Fonctions du pilote */
|
||||
u8 *(*detect_hardware) (void);
|
||||
u8 (*setvideo_mode) (u8 mode);
|
||||
u8 *(*getvideo_drivername) (void);
|
||||
u8 *(*getvideo_capabilities) (void);
|
||||
videoinfos *(*getvideo_info) (void);
|
||||
u32 (*mem_to_video) (void *src,u32 dst, u32 size, bool increment_src);
|
||||
u32 (*video_to_mem) (u32 src,void *dst, u32 size);
|
||||
u32 (*video_to_video) (u32 src,u32 dst, u32 size);
|
||||
void (*wait_vretrace) (void);
|
||||
void (*wait_hretrace) (void);
|
||||
void (*page_set) (u8 page);
|
||||
void (*page_show) (u8 page);
|
||||
void (*page_split) (u16 y);
|
||||
void (*cursor_enable) (void);
|
||||
void (*cursor_disable) (void);
|
||||
void (*cursor_set) (u16 x,u16 y);
|
||||
u32 (*font_load) (u8 * def, u8 size, u8 font);
|
||||
void (*font1_set) (u8 num);
|
||||
void (*font2_set) (u8 num);
|
||||
void (*blink_enable) (void);
|
||||
void (*blink_disable) (void);
|
||||
|
|
278
lib/VGA/modes.c
278
lib/VGA/modes.c
|
@ -4,220 +4,120 @@
|
|||
|
||||
/* definition des registres de la carte VGA pour differents modes */
|
||||
|
||||
#define maxgraphmode 11
|
||||
#define maxtextmode 5
|
||||
#define nbmodes 9
|
||||
|
||||
static mode_def textmodes[maxtextmode] = {
|
||||
|
||||
/*40*25 16 couleurs mode 0x00 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x08, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0xA0, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x14, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
45, 25, 4},
|
||||
|
||||
/*80*25 16 couleurs mode 0x01 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x00, 0x03, 0x00, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00,
|
||||
80, 25, 4},
|
||||
|
||||
/*80*50 16 couleurs mode 0x02 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 50, 4},
|
||||
|
||||
/*100*50 16 couleurs mode 0x03 */
|
||||
{
|
||||
0x67,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x32, 0x1F, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 50, 4},
|
||||
|
||||
/*100*60 16 couleurs mode 0x04 */
|
||||
{
|
||||
0xA7,
|
||||
0x03, 0x01, 0x03, 0x05, 0x02,
|
||||
0x70, 0x63, 0x64, 0x85, 0x68, 0x84, 0xFF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE7, 0x8E, 0xDF, 0x32, 0x1F, 0xDF, 0xE5, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 60, 4}
|
||||
static capabilities vgacapabilities[nbmodes] = {
|
||||
{0x00, 80, 25,false, 4, 0},
|
||||
{0x01, 80, 50,false, 4, 0},
|
||||
{0x80,640,480,true , 1, 0},
|
||||
{0x81,320,200,true , 2, 0},
|
||||
{0x82,640,480,true , 4, 0},
|
||||
{0x83,320,200,true , 8, 0},
|
||||
{0x84,320,400,true , 8, 0},
|
||||
{0x85,320,480,true , 8, 0},
|
||||
{0x86,360,480,true , 8, 0},
|
||||
{0xFF,000,000,false, 0, 0},
|
||||
};
|
||||
|
||||
static mode_def graphmodes[maxgraphmode] = {
|
||||
|
||||
static vgamode modes[nbmodes] = {
|
||||
|
||||
/*80*25 16 couleurs mode 0x00 */
|
||||
{{0x67},
|
||||
{0x03, 0x00, 0x03, 0x00, 0x02},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x4F, 0x0D, 0x0E, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x08, 0x00}},
|
||||
|
||||
/*80*50 16 couleurs mode 0x01 */
|
||||
{{0x63},
|
||||
{0x03, 0x01, 0x03, 0x05, 0x02},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x55, 0x81, 0xBF, 0x1F, 0x00,
|
||||
0x47, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x1F, 0x96, 0xB9, 0xA3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x14, 0x07, 0x38, 0x39, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x0C, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*640*480 n&b mode 0x80 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
{{0xE3},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x06},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0xEA, 0x0C, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 1},
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*320*200 4 couleurs mode 0x81 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x09, 0x03, 0x00, 0x02,
|
||||
0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
|
||||
{{0x63},
|
||||
{0x03, 0x09, 0x03, 0x00, 0x02},
|
||||
{0x2D, 0x27, 0x28, 0x90, 0x2B, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x9C, 0x0E, 0x8F, 0x14, 0x00, 0x96, 0xB9, 0xA3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x02, 0x00, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x03, 0x00, 0x00,
|
||||
40, 25,
|
||||
},
|
||||
0x01, 0x00, 0x03, 0x00, 0x00}},
|
||||
|
||||
/*640*480 16 couleurs mode 0x82 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
|
||||
{{0xE3},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x06},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x53, 0x9F, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0xE9, 0x8B, 0xDF, 0x28, 0x00, 0xE7, 0x04, 0xE3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
80, 60, 4},
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*720*480 16 couleurs mode 0x83 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x08, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x82, 0x60, 0x8D, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x06, 0x07, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0x0C, 0xDF, 0x2D, 0x08, 0xE8, 0x05, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
90, 60, 4},
|
||||
|
||||
/*800*600 16 couleurs mode 0x84 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x70, 0x63, 0x64, 0x92, 0x65, 0x82, 0x70, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8C, 0x57, 0x32, 0x00, 0x58, 0x70, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x10, 0x11, 0x3A, 0x3B,
|
||||
0x3C, 0x3D, 0x3E, 0x3F,
|
||||
0x01, 0x00, 0x0F, 0x00, 0x00,
|
||||
100, 75, 4},
|
||||
|
||||
/*320*200 256 couleurs RAPIDE mode 0x85 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x0E,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
/*320*200 256 couleurs RAPIDE mode 0x83 */
|
||||
{{0x63},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x0E},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x40, 0x96, 0xB9, 0xA3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8},
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*320*200 256 couleurs mode 0x86 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x0E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 25, 8},
|
||||
|
||||
/*320*400 256 couleurs mode 0x87 */
|
||||
{
|
||||
0x63,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
/*320*400 256 couleurs mode 0x84 */
|
||||
{{0x63},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x06},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0xBF, 0x1F, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x9C, 0x8E, 0x8F, 0x28, 0x00, 0x96, 0xB9, 0xE3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 50, 8},
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*320*480 256 couleurs mode 0x88 */
|
||||
{
|
||||
0xE3,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
/*320*480 256 couleurs mode 0x85 */
|
||||
{{0xE3},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x06},
|
||||
{0x5F, 0x4F, 0x50, 0x82, 0x54, 0x80, 0x0B, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0xEA, 0xAC, 0xDF, 0x28, 0x00, 0xE7, 0x06, 0xE3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
40, 60, 8},
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00}},
|
||||
|
||||
/*360*480 256 couleurs mode 0x89 */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
|
||||
/*360*480 256 couleurs mode 0x86 */
|
||||
{{0xE7},
|
||||
{0x03, 0x01, 0x0F, 0x00, 0x06},
|
||||
{0x6B, 0x59, 0x5A, 0x8E, 0x5E, 0x8A, 0x0D, 0x3E, 0x00,
|
||||
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0xEA, 0xAC, 0xDF, 0x2D, 0x00, 0xE7, 0x06, 0xE3, 0xFF},
|
||||
{0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF},
|
||||
{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
45, 60, 8},
|
||||
|
||||
/*400*600 256 couleurs mode 0x8A */
|
||||
{
|
||||
0xE7,
|
||||
0x03, 0x01, 0x0F, 0x00, 0x06,
|
||||
0x74, 0x63, 0x64, 0x97, 0x68, 0x95, 0x86, 0xF0, 0x00,
|
||||
0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x5B, 0x8D, 0x57, 0x32, 0x00, 0x60, 0x80, 0xE3, 0xFF,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x05, 0x0F, 0xFF,
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
|
||||
0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00,
|
||||
50, 75, 8}
|
||||
0x41, 0x00, 0x0F, 0x00, 0x00}},
|
||||
};
|
||||
|
|
|
@ -351,7 +351,7 @@ void exception14()
|
|||
cli();
|
||||
dumpcpu();
|
||||
save_stack *dump = getESP();
|
||||
exception_stack *current = getESP()+36;
|
||||
exception_stack *current = getESP()+sizeof(save_stack)+100;
|
||||
dump->eip=current->eip;
|
||||
dump->cs=current->cs;
|
||||
dump->oldesp=(current+1);
|
||||
|
|
|
@ -223,7 +223,7 @@ unsigned convert(u32 keypressed)
|
|||
}
|
||||
|
||||
else if (key == SCAN_F10) {
|
||||
nextvmode();
|
||||
apply_nextvideomode();
|
||||
}
|
||||
|
||||
/* Scroll Lock, Num Lock, and Caps Lock mise a jour des leds */
|
||||
|
|
671
lib/vga.c
671
lib/vga.c
|
@ -2,6 +2,7 @@
|
|||
/* COS2000 - Compatible Operating System - LGPL v3 - Hordé Nicolas */
|
||||
/* */
|
||||
#include "vga.h"
|
||||
#include "video.h"
|
||||
#include "memory.h"
|
||||
#include "asm.h"
|
||||
#include "types.h"
|
||||
|
@ -9,97 +10,223 @@
|
|||
#include "VGA/8x8fnt.c"
|
||||
#include "VGA/8x16fnt.c"
|
||||
|
||||
/* Registres VGAs */
|
||||
static videoinfos infos;
|
||||
|
||||
#define sequencer 0x3c4
|
||||
#define misc 0x3c2
|
||||
#define ccrt 0x3D4
|
||||
#define attribs 0x3c0
|
||||
#define graphics 0x3ce
|
||||
#define state 0x3da
|
||||
|
||||
/* Taille d'un plan de bit */
|
||||
|
||||
#define planesize 0x10000
|
||||
|
||||
static u16 resX, resY, color, splitY; /* resolution x,y en caractères et profondeur */
|
||||
|
||||
static u8 pages, activepage, showedpage; /* nombre de pages disponibles N° de la page active */
|
||||
static u32 linesize, pagesize; /* Taille d'une ligne et d'une page */
|
||||
static u8 vmode = 0xFF; /* mode en cours d'utilisation */
|
||||
static u32 basemem; /* Adresse de la mémoire vidéo */
|
||||
static bool scrolling, graphic, blink; /* Activation du défilement, Flag du mode graphique */
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Donne la resolution max horizontale */
|
||||
|
||||
u16 getxres(void)
|
||||
static videofonction fonctions =
|
||||
{
|
||||
return resX;
|
||||
VGA_detect_hardware;
|
||||
VGA_setvideo_mode;
|
||||
VGA_getvideo_drivername;
|
||||
VGA_getvideo_capabilities;
|
||||
VGA_getvideo_info;
|
||||
VGA_mem_to_video;
|
||||
VGA_video_to_mem;
|
||||
VGA_video_to_video;
|
||||
VGA_wait_vretrace;
|
||||
VGA_wait_hretrace;
|
||||
VGA_page_set;
|
||||
VGA_page_show;
|
||||
VGA_page_split;
|
||||
VGA_cursor_enable;
|
||||
VGA_cursor_disable;
|
||||
VGA_cursor_set;
|
||||
VGA_font_load;
|
||||
VGA_font1_set;
|
||||
VGA_font2_set;
|
||||
VGA_blink_enable;
|
||||
VGA_blink_disable;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Donne la profondeur en bit */
|
||||
/* Detecte si le hardware est disponible, return NULL ou pointeur sur le type de pilote */
|
||||
u8 *VGA_detect_hardware {
|
||||
return "LEGACY",
|
||||
};
|
||||
|
||||
u8 getdepth(void)
|
||||
/*******************************************************************************/
|
||||
/* Renvoie l'adresse du segment video */
|
||||
|
||||
u32 getbase(void)
|
||||
{
|
||||
return color;
|
||||
u32 base;
|
||||
/*outb(graphics, 6);
|
||||
base = inb(graphics + 1);
|
||||
base >>= 2;
|
||||
base &= 3;*/
|
||||
base = modes[infos.currentmode].graphics.Miscellaneous_Graphics_Register;
|
||||
switch (base) {
|
||||
case 0:
|
||||
case 1:
|
||||
base = 0xA0000;
|
||||
break;
|
||||
case 2:
|
||||
base = 0xB0000;
|
||||
break;
|
||||
case 3:
|
||||
base = 0xB8000;
|
||||
break;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Donne la resolution max verticale */
|
||||
/* Change le mode video courant */
|
||||
/* ERR 0 aucune
|
||||
/* ERR 1 mode non existant */
|
||||
|
||||
u16 getyres(void)
|
||||
u32 VGA_setvideo_mode(u8 mode)
|
||||
{
|
||||
return resY - splitY;
|
||||
u32 index;
|
||||
while(vgacapabilities[index].modenumber!=0xFF) {
|
||||
if (vgacapabilities[index].modenumber==mode) {
|
||||
infos.currentmode=vgacapabilities[index].modenumber;
|
||||
break;
|
||||
index++;
|
||||
}
|
||||
if (infos.currentmode!=mode)
|
||||
return 1;
|
||||
infos.currentwidth=vgacapabilities[index].width;
|
||||
infos.currentheight=vgacapabilities[index].height;
|
||||
infos.currentdepth=vgacapabilities[index].depth;
|
||||
infos.currentactivepage=0;
|
||||
infos.currentshowedpage=0;
|
||||
infos.currentcursorX=0;
|
||||
infos.currentcursorY=0;
|
||||
infos.currentfont1=0;
|
||||
infos.currentfont2=0;
|
||||
infos.isgraphic=vgacapabilities[index].graphic;
|
||||
infos.isblinking=false;
|
||||
infos.iscursorvisible=false;
|
||||
if (infos.isgraphic) {
|
||||
loadfont(font8x8, 8, 1);
|
||||
loadfont(font8x16, 16, 0);
|
||||
switch (infos.depth) {
|
||||
case 1:
|
||||
/* mode N&B */
|
||||
infos.currentpitch = infos.width;
|
||||
break;
|
||||
case 2:
|
||||
/* mode 4 couleurs */
|
||||
infos.currentpitch = (infos.width << 1);
|
||||
break;
|
||||
case 4:
|
||||
/* mode 16 couleurs */
|
||||
infos.currentpitch = infos.width;
|
||||
break;
|
||||
case 8:
|
||||
/* mode 256 couleurs */
|
||||
if (modes[index].sequencer.Sequencer_Memory_Mode_Register == 0x0E) {
|
||||
/* mode chainé (plus rapide mais limité en mémoire) */
|
||||
infos.currentpitch = (infos.width << 3);
|
||||
} else {
|
||||
/* mode non chainé */
|
||||
infos.currentpitch = (infos.width << 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
infos.pagesize = ((infos.height * infos.currentpitch) << 3);
|
||||
}
|
||||
else {
|
||||
infos.currentpitch= infos.width * 2;
|
||||
infos.pagesize=infos.height * infos.currentpitch;
|
||||
}
|
||||
infos.pagesnumber=(planesize / infos.currentpitch);
|
||||
infos.baseaddress=(modes[index].ccrt.Cursor_Location_High_Register << 8) + modes[index].ccrt.Cursor_Location_Low_Register + getbase();
|
||||
/* Initialise les registre "divers" */
|
||||
outb(misc, modes[index].misc);
|
||||
/* Initialise les registre d'etat */
|
||||
outb(state, 0x00);
|
||||
/* Initialise le séquenceur */
|
||||
outreg(sequencer, modes[index].sequencer, 5);
|
||||
/* Debloque le verouillage des registres controleur CRT */
|
||||
outb(ccrt, 0x11);
|
||||
outb(ccrt + 1, 0x0E);
|
||||
/* Initialise le controleur CRT */
|
||||
outreg(ccrt, ctrc, 25);
|
||||
/* Initialise le controleur graphique */
|
||||
outreg(graphics, modes[index].graphic, 9);
|
||||
inb(state);
|
||||
/* Initialise le controleur d'attributs */
|
||||
outregsame(attribs, modes[index].attributs, 21);
|
||||
inb(state);
|
||||
outb(attribs, 0x20);
|
||||
/* Initialise l'adresse des procedures de gestion graphique et les differentes
|
||||
variables en fonction de la profondeur et du mode */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Donne le nombre max de page ecran dispo */
|
||||
/* Renvoie le nom du driver */
|
||||
u8 *VGA_getvideo_drivername (void) {
|
||||
return "VGA";
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Renvoie un pointeur sur la structure des capacités graphiques */
|
||||
|
||||
u8 *VGA_getvideo_capabilities (void) {
|
||||
return vgacapabilities;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Renvoie un pointeur sur l'état courant de la carte */
|
||||
videoinfos *VGA_getvideo_info (void) {
|
||||
return infos;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Effecture un mouvement de la mémoire centrale vers la mémoire video (linéarisée) */
|
||||
u32 VGA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Effecture un mouvement de la mémoire video (linéarisée) vers la mémoire centrale*/
|
||||
u32 VGA_video_to_mem (u32 src,void *dst, u32 size) {
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Effecture un mouvement de la mémoire video (linéarisé) vers la mémoire vidéo (linéarisée) */
|
||||
u32 VGA_video_to_video (u32 src,u32 dst, u32 size) {
|
||||
|
||||
u16 getnbpages(void)
|
||||
{
|
||||
return pages;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Fixe la page ecran de travail */
|
||||
|
||||
void setpage(u8 page)
|
||||
void VGA_page_set(u8 page)
|
||||
{
|
||||
if (page < pages)
|
||||
activepage = page;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Recupere la page ecran de travail */
|
||||
|
||||
u8 getpage(void)
|
||||
{
|
||||
return activepage;
|
||||
if (page < infos.pagesnumber)
|
||||
infos.currentactivepage = page;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Affiche la page ecran specifié */
|
||||
|
||||
void showpage(u8 page)
|
||||
void VGA_page_show(u8 page)
|
||||
{
|
||||
if (page < pages) {
|
||||
if (page < infos.pagesnumber) {
|
||||
u16 addr;
|
||||
addr = page * pagesize / 2;
|
||||
addr = page * infos.pagesize / 2;
|
||||
outb(ccrt, 0x0C);
|
||||
outb(ccrt + 1, (addr >> 8));
|
||||
outb(ccrt, 0x0D);
|
||||
outb(ccrt + 1, (addr & 0xFF));
|
||||
showedpage = page;
|
||||
infos.currentshowedpage = page;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Sépare l'écran en 2 a partir de la ligne Y */
|
||||
|
||||
void split(u16 y)
|
||||
static splitY=0;
|
||||
|
||||
void VGA_page_split(u16 y)
|
||||
{
|
||||
if (y!=0) {
|
||||
u16 addr;
|
||||
if (graphic == 0)
|
||||
addr = (y << 3);
|
||||
|
@ -119,11 +246,7 @@ void split(u16 y)
|
|||
outb(ccrt + 1, (inb(ccrt + 1) & ~64) | ((addr >> 3) & 64));
|
||||
splitY = y;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Sépare l'écran en 2 a partir de la ligne Y */
|
||||
|
||||
void unsplit(void)
|
||||
else
|
||||
{
|
||||
/* line compare pour ligne atteinte */
|
||||
outb(ccrt, 0x18);
|
||||
|
@ -139,11 +262,12 @@ void unsplit(void)
|
|||
outb(ccrt + 1, inb(ccrt + 1) & ~64);
|
||||
splitY = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Attend la retrace verticale */
|
||||
|
||||
void waitvretrace(void)
|
||||
void VGA_wait_vretrace(void)
|
||||
{
|
||||
while ((inb(state) & 8) == 0) ;
|
||||
}
|
||||
|
@ -151,7 +275,7 @@ void waitvretrace(void)
|
|||
/*******************************************************************************/
|
||||
/* Attend la retrace horizontale */
|
||||
|
||||
void waithretrace(void)
|
||||
void VGA_wait_hretrace(void)
|
||||
{
|
||||
while ((inb(state) & 1) == 0) ;
|
||||
}
|
||||
|
@ -159,42 +283,27 @@ void waithretrace(void)
|
|||
/*******************************************************************************/
|
||||
/* Active l'affichage du curseur de texte */
|
||||
|
||||
void enablecursor(void)
|
||||
void VGA_cursor_enable(void)
|
||||
{
|
||||
u8 curs;
|
||||
/* active le curseur hardware */
|
||||
outb(ccrt, 10);
|
||||
curs = inb(ccrt + 1) & ~32;
|
||||
outb(ccrt + 1, curs);
|
||||
infos.isgraphic=true;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Desactive l'affichage du curseur de texte */
|
||||
|
||||
void disablecursor(void)
|
||||
void VGA_cursor_disable(void)
|
||||
{
|
||||
u8 curs;
|
||||
/* Desactive le curseur hardware */
|
||||
outb(ccrt, 10);
|
||||
curs = inb(ccrt + 1) | 32;
|
||||
outb(ccrt + 1, curs);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Active le scrolling en cas de débordement d'écran */
|
||||
|
||||
void enablescroll(void)
|
||||
{
|
||||
scrolling = true;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
||||
/* Desactive le scrolling en cas de débordement d'écran */
|
||||
|
||||
void disablescroll(void)
|
||||
{
|
||||
scrolling = false;
|
||||
infos.isgraphic=false;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
@ -213,387 +322,31 @@ void useplane(u8 plan)
|
|||
outb(sequencer + 1, mask);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Renvoie l'adresse du segment video */
|
||||
|
||||
u32 getbase(void)
|
||||
{
|
||||
u32 base;
|
||||
outb(graphics, 6);
|
||||
base = inb(graphics + 1);
|
||||
base >>= 2;
|
||||
base &= 3;
|
||||
switch (base) {
|
||||
case 0:
|
||||
case 1:
|
||||
base = 0xA0000;
|
||||
break;
|
||||
case 2:
|
||||
base = 0xB0000;
|
||||
break;
|
||||
case 3:
|
||||
base = 0xB8000;
|
||||
break;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* efface l'écran */
|
||||
|
||||
void (*fill) (u8 attrib);
|
||||
|
||||
void fill_text(u8 attrib)
|
||||
{
|
||||
memset((u8 *) (basemem + activepage * pagesize), ' ', pagesize / 2, 2);
|
||||
memset((u8 *) (basemem + activepage * pagesize + 1), attrib,
|
||||
pagesize / 2, 2);
|
||||
}
|
||||
|
||||
void fill_chain(u8 attrib)
|
||||
{
|
||||
memset((u8 *) (basemem + activepage * pagesize), attrib & 0x0F,
|
||||
pagesize, 1);
|
||||
}
|
||||
|
||||
void fill_unchain(u8 attrib)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
useplane(i);
|
||||
memset((u8 *) (basemem + activepage * pagesize), attrib & 0x0F,
|
||||
pagesize, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* fixe la position du curseur texte */
|
||||
|
||||
void gotoscr(u16 x, u16 y)
|
||||
void VGA_cursor_set(u16 x, u16 y)
|
||||
{
|
||||
u16 pos;
|
||||
if (splitY == 0)
|
||||
pos = (showedpage * pagesize / 2 + x + y * resX);
|
||||
pos = (infos.currentshowedpage * infos.pagesize / 2 + x + y * infos.width);
|
||||
else
|
||||
pos = (x + y * resX);
|
||||
pos = (x + y * infos.width);
|
||||
outb(ccrt, 0x0F);
|
||||
outb(ccrt + 1, (u8) (pos & 0x00FF));
|
||||
outb(ccrt, 0x0E);
|
||||
outb(ccrt + 1, (u8) ((pos & 0xFF00) >> 8));
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Fait defiler l'ecran de n lignes vers le haut */
|
||||
|
||||
void (*scroll) (u8 lines, u8 attrib);
|
||||
|
||||
void scroll_unchain(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling) {
|
||||
u8 i;
|
||||
for (i = 0; i < 4; i++) {
|
||||
useplane(i);
|
||||
memcpy((u8 *) (basemem + activepage * pagesize +
|
||||
linesize * 8 * lines), (u8 *) basemem,
|
||||
pagesize - linesize * 8 * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize +
|
||||
pagesize - linesize * 8 * lines),
|
||||
attrib & 0x0F, linesize * 8 * lines, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_chain(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling) {
|
||||
memcpy((u8 *) basemem + activepage * pagesize + linesize * 8 * lines,
|
||||
(u8 *) basemem + activepage * pagesize, pagesize - linesize * 8 * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize - linesize * 8 * lines), attrib & 0x0F, linesize * 8 * lines, 1);
|
||||
}
|
||||
}
|
||||
|
||||
void scroll_text(u8 lines, u8 attrib)
|
||||
{
|
||||
if (scrolling) {
|
||||
memcpy((u8 *) basemem + activepage * pagesize +
|
||||
linesize * lines, (u8 *) basemem + activepage * pagesize,
|
||||
pagesize - linesize * lines, 1);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize -
|
||||
linesize * lines - 2), ' ',
|
||||
(linesize * lines) / 2, 2);
|
||||
memset((u8 *) (basemem + activepage * pagesize + pagesize -
|
||||
linesize * lines - 1), attrib,
|
||||
(linesize * lines) / 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Affiche le caractère a l'écran */
|
||||
|
||||
void (*showchar) (u16 coordx, u16 coordy, u8 thechar, u8 attrib);
|
||||
|
||||
void showchar_graphic(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
{
|
||||
u8 x, y, pattern, set;
|
||||
for (y = 0; y < 8; y++) {
|
||||
pattern = font8x8[thechar * 8 + y];
|
||||
for (x = 0; x < 8; x++) {
|
||||
set = ((pattern >> (7 - x)) & 0x1); /* mettre un ROL importé depuis asm */
|
||||
if (set == 0)
|
||||
writepxl(coordx * 8 + x, coordy * 8 + y,
|
||||
((attrib & 0xF0) >> 8) * set);
|
||||
else
|
||||
writepxl(coordx * 8 + x, coordy * 8 + y,
|
||||
(attrib & 0x0F) * set);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void showchar_text(u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
{
|
||||
u8 *screen;
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX);
|
||||
*screen = thechar;
|
||||
*(++screen) = attrib;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Recupere le caractère a l'écran */
|
||||
|
||||
u8(*getchar) (u16 coordx, u16 coordy);
|
||||
|
||||
u8 getchar_text(u16 coordx, u16 coordy)
|
||||
{
|
||||
u8 *screen;
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX);
|
||||
return *screen;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Recupere les attributs a l'écran */
|
||||
|
||||
u8(*getattrib) (u16 coordx, u16 coordy);
|
||||
|
||||
u8 getattrib_text(u16 coordx, u16 coordy)
|
||||
{
|
||||
u8 *screen;
|
||||
screen =
|
||||
(u8 *) basemem + activepage * pagesize + 2 * (coordx +
|
||||
coordy * resX) + 1;
|
||||
return *screen;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Ecrit un pixel a l'écran */
|
||||
|
||||
void (*writepxl) (u16 x, u16 y, u32 c);
|
||||
|
||||
void writepxl_1bit(u16 x, u16 y, u32 c)
|
||||
{
|
||||
u8 *off;
|
||||
u8 mask;
|
||||
c = (c & 1) * 0xFF;
|
||||
off = (u8 *) (basemem + activepage * pagesize + linesize * y + x / 8);
|
||||
x = (x & 7) * 1;
|
||||
mask = 0x80 >> x;
|
||||
*off = ((*off) & ~mask) | (c & mask);
|
||||
}
|
||||
|
||||
void writepxl_2bits(u16 x, u16 y, u32 c)
|
||||
{
|
||||
u8 *off;
|
||||
u8 mask;
|
||||
c = (c & 3) * 0x55;
|
||||
off = (u8 *) (basemem + activepage * pagesize + linesize * y + x / 4);
|
||||
x = (x & 3) * 2;
|
||||
mask = 0xC0 >> x;
|
||||
*off = ((*off) & ~mask) | (c & mask);
|
||||
}
|
||||
|
||||
void writepxl_4bits(u16 x, u16 y, u32 c)
|
||||
{
|
||||
u8 *off;
|
||||
u8 mask, p, pmask;
|
||||
off = (u8 *) (basemem + activepage * pagesize + linesize * y + x / 8);
|
||||
x = (x & 7) * 1;
|
||||
mask = 0x80 >> x;
|
||||
pmask = 1;
|
||||
for (p = 0; p < 4; p++) {
|
||||
useplane(p);
|
||||
if (pmask & c)
|
||||
*off = ((*off) | mask);
|
||||
else
|
||||
*off = ((*off) & ~mask);
|
||||
pmask <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
void writepxl_8bits(u16 x, u16 y, u32 c)
|
||||
{
|
||||
u8 *off;
|
||||
off = (u8 *) (basemem + activepage * pagesize + linesize * y + x);
|
||||
*off = c;
|
||||
}
|
||||
|
||||
void writepxl_8bitsunchain(u16 x, u16 y, u32 c)
|
||||
{
|
||||
u8 *off;
|
||||
off = (u8 *) (basemem + activepage * pagesize + linesize * y + x / 4);
|
||||
useplane(x & 3);
|
||||
*off = c;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Met le mode video suivant */
|
||||
|
||||
u8 nextvmode(void)
|
||||
{
|
||||
u8 mode = getvmode();
|
||||
mode++;
|
||||
if (mode >= 0x80) {
|
||||
if (mode > maxgraphmode)
|
||||
mode = 0x0;
|
||||
} else {
|
||||
if (mode > maxtextmode)
|
||||
mode = 0x80;
|
||||
}
|
||||
setvmode(mode);
|
||||
return mode;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Change le mode video courant */
|
||||
|
||||
u32 setvmode(u8 mode)
|
||||
{
|
||||
u8 *def, gmode;
|
||||
/* Récupere la definition des registres VGA en fonction du mode
|
||||
graphique : >0x80
|
||||
text : 0x00 - 0x7F
|
||||
*/
|
||||
if (mode >= 0x80) {
|
||||
gmode = mode - 0x80;
|
||||
if (gmode > maxgraphmode)
|
||||
return 1; /* mode inexistant */
|
||||
def = graphmodes[gmode];
|
||||
graphic = true;
|
||||
} else {
|
||||
if (mode > maxtextmode)
|
||||
return 1; /* mode inexistant */
|
||||
def = textmodes[mode];
|
||||
graphic = false;
|
||||
loadfont(font8x8, 8, 1);
|
||||
loadfont(font8x16, 16, 0);
|
||||
}
|
||||
/* Initialise les registre "divers" */
|
||||
outb(misc, def[0]);
|
||||
/* Initialise les registre d'etat */
|
||||
outb(state, 0x00);
|
||||
/* Initialise le séquenceur */
|
||||
outreg(sequencer, &def[1], 5);
|
||||
/* Debloque le verouillage des registres controleur CRT */
|
||||
outb(ccrt, 0x11);
|
||||
outb(ccrt + 1, 0x0E);
|
||||
/* Initialise le controleur CRT */
|
||||
outreg(ccrt, &def[6], 25);
|
||||
/* Initialise le controleur graphique */
|
||||
outreg(graphics, &def[31], 9);
|
||||
inb(state);
|
||||
/* Initialise le controleur d'attributs */
|
||||
outregsame(attribs, &def[40], 21);
|
||||
inb(state);
|
||||
outb(attribs, 0x20);
|
||||
/* Récupere depuis la table de définition des mode la résolution et la
|
||||
profondeur (en bits) */
|
||||
resX = def[61];
|
||||
resY = def[62];
|
||||
color = def[63];
|
||||
/* Initialise l'adresse des procedures de gestion graphique et les differentes
|
||||
variables en fonction de la profondeur et du mode */
|
||||
if (!graphic) {
|
||||
/* mode texte */
|
||||
linesize = resX * 2;
|
||||
writepxl = NULL; /* pas d'affichage de pixels */
|
||||
showchar = showchar_text;
|
||||
scroll = scroll_text;
|
||||
fill = fill_text;
|
||||
pagesize = resY * linesize;
|
||||
getchar = getchar_text;
|
||||
getattrib = getattrib_text;
|
||||
} else {
|
||||
switch (color) {
|
||||
case 1:
|
||||
/* mode N&B */
|
||||
linesize = resX;
|
||||
writepxl = writepxl_1bit;
|
||||
fill = fill_chain;
|
||||
scroll = scroll_chain;
|
||||
break;
|
||||
case 2:
|
||||
/* mode 4 couleurs */
|
||||
linesize = (resX << 1);
|
||||
writepxl = writepxl_2bits;
|
||||
fill = fill_chain;
|
||||
scroll = scroll_chain;
|
||||
break;
|
||||
case 4:
|
||||
/* mode 16 couleurs */
|
||||
linesize = resX;
|
||||
writepxl = writepxl_4bits;
|
||||
fill = fill_unchain;
|
||||
scroll = scroll_unchain;
|
||||
break;
|
||||
case 8:
|
||||
/* mode 256 couleurs */
|
||||
if (def[5] == 0x0E) {
|
||||
/* mode chainé (plus rapide mais limité en mémoire) */
|
||||
linesize = (resX << 3);
|
||||
writepxl = writepxl_8bits;
|
||||
scroll = scroll_chain;
|
||||
fill = fill_chain;
|
||||
} else {
|
||||
/* mode non chainé */
|
||||
linesize = (resX << 1);
|
||||
writepxl = writepxl_8bitsunchain;
|
||||
scroll = scroll_unchain;
|
||||
fill = fill_unchain;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
showchar = showchar_graphic;
|
||||
pagesize = ((resY * linesize) << 3);
|
||||
}
|
||||
/* calcul des variables d'état video */
|
||||
activepage = 0;
|
||||
showedpage = 0;
|
||||
splitY = 0;
|
||||
vmode = mode;
|
||||
scrolling = 1;
|
||||
pages = (planesize / pagesize);
|
||||
basemem = (def[20] << 8) + def[21] + getbase();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Récupère le mode vidéo en cours */
|
||||
|
||||
u8 getvmode(void)
|
||||
{
|
||||
return vmode;
|
||||
info.currentcursorX=x;
|
||||
info.currentcursorY=y;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Charge une nouvelle police de caractère */
|
||||
/* ERR 1 mode graphique activé*/
|
||||
|
||||
u32 loadfont(u8 * def, u8 size, u8 font)
|
||||
u32 VGA_font_load(u8 * def, u8 size, u8 font)
|
||||
{
|
||||
if (graphics == 1)
|
||||
if (infos.isgraphic)
|
||||
return 1;
|
||||
u8 oldregs[5] = { 0, 0, 0, 0, 0 };
|
||||
u8 *base;
|
||||
|
@ -640,70 +393,50 @@ u32 loadfont(u8 * def, u8 size, u8 font)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Récupere le N° de la police de caractère en cours d'utilisation */
|
||||
|
||||
u8 getfont(void)
|
||||
{
|
||||
u8 num, tmp;
|
||||
outb(sequencer, 3);
|
||||
tmp = inb(sequencer + 1);
|
||||
num = (tmp & 0x03) | ((tmp & 0x10) >> 2);
|
||||
return num;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Récupere le N° de la police de caractère en cours d'utilisation */
|
||||
|
||||
u8 getfont2(void)
|
||||
{
|
||||
u8 num, tmp;
|
||||
outb(sequencer, 3);
|
||||
tmp = inb(sequencer + 1);
|
||||
num = ((tmp & 0x0C) >> 2) | ((tmp & 0x20) >> 3);
|
||||
return num;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Fixe le N° de la police de caractère a utiliser */
|
||||
|
||||
void setfont(u8 num)
|
||||
void VGA_font1_set(u8 num)
|
||||
{
|
||||
num &= 0x07;
|
||||
outb(sequencer, 3);
|
||||
outb(sequencer + 1,
|
||||
(inb(sequencer + 1) & 0xEC) | ((num & 0x03) +
|
||||
((num & 0x04) << 2)));
|
||||
info.currentfont1=num;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Fixe le N° de la police de caractère a utiliser */
|
||||
|
||||
void setfont2(u8 num)
|
||||
void VGA_font2_set(u8 num)
|
||||
{
|
||||
num &= 0x07;
|
||||
outb(sequencer, 3);
|
||||
outb(sequencer + 1,
|
||||
(inb(sequencer + 1) & 0xD3) | (((num & 0x03) << 2) +
|
||||
((num & 0x04) << 3)));
|
||||
info.currentfont2=num;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Autorise le clignotement */
|
||||
|
||||
void enableblink(void)
|
||||
void VGA_blink_enable(void)
|
||||
{
|
||||
outb(ccrt, 0x10);
|
||||
outb(ccrt + 1, (inb(sequencer + 1) | 0x04));
|
||||
info.isblinking=true;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Annule le clignotement */
|
||||
|
||||
void disableblink(void)
|
||||
void VGA_blink_disable(void)
|
||||
{
|
||||
outb(ccrt, 0x10);
|
||||
outb(ccrt + 1, (inb(sequencer + 1) & ~0x04));
|
||||
info.isblinking=false;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
|
|
152
lib/video.c
152
lib/video.c
|
@ -5,6 +5,8 @@
|
|||
#include "video.h"
|
||||
#include "stdarg.h"
|
||||
|
||||
drivers registred[maxdrivers];
|
||||
|
||||
console vc[8] = {
|
||||
{0x07, 0, 0, 0, 0, 0, 0, 0}
|
||||
,
|
||||
|
@ -815,3 +817,153 @@ u8 *sitoa(u64 num, u8 * str, u64 dim)
|
|||
return pointer;
|
||||
}
|
||||
/*******************************************************************************/
|
||||
/* initialise le tableau des pilotes vidéo */
|
||||
void initdriver() {
|
||||
for(u32 i=0;i<maxdrivers;i++)
|
||||
registred[i].nom=NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Enregistre un pilote dans le tableau des pilotes vidéo */
|
||||
void registerdriver(videofonction *pointer);
|
||||
{
|
||||
u32 i;
|
||||
for(i=0;i<maxdrivers;i++)
|
||||
if (registred[i].pointer==pointer)
|
||||
return;
|
||||
i=0;
|
||||
while (registred[i].nom!=NULL && i<maxdrivers)
|
||||
i++;
|
||||
registred[i].pointer=pointer;
|
||||
}
|
||||
/*******************************************************************************/
|
||||
/* Choisi le meilleur driver en terme d'affichage */
|
||||
void apply_bestdriver(void) {
|
||||
u32 i=0,j=0;
|
||||
u8 bestdepth=0x0;
|
||||
u8 bestresol=0x0;
|
||||
u8 bestmode=0x0;
|
||||
u8* bestdriver=NULL;
|
||||
while (registred[i].nom!=NULL && i<maxdrivers) {
|
||||
capabilities cap=registred[i].pointer.getvideo_capabilities();
|
||||
while(cap[j].modenumber!=0xFF) {
|
||||
if (cap[j].depth>bestdepth && (cap[j].width*cap[j].height)>=bestresol)
|
||||
{
|
||||
bestdepth=cap[j].depth;
|
||||
bestresol=cap[j].width*cap[j].height;
|
||||
bestmode=cap[j].modenumber;
|
||||
bestdriver=registred[i].pointer.getvideo_drivername();
|
||||
}
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (bestdriver!=NULL) apply_driver(bestdriver);
|
||||
setvideo_mode(bestmode);
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Choisi le meilleur driver spécifié par le nom */
|
||||
void apply_driver(u8* name);
|
||||
{
|
||||
u32 i=0;
|
||||
while (registred[i].nom!=NULL && i<maxdrivers) {
|
||||
if (strcmp(name,registred[i].nom)==0) {
|
||||
detect_hardware=registred[i].pointer.detect_hardware;
|
||||
setvideo_mode=registred[i].pointer.setvideo_mode;
|
||||
getvideo_drivername=registred[i].pointer.getvideo_drivername;
|
||||
getvideo_capabilities=registred[i].pointer.getvideo_capabilities;
|
||||
getvideo_info=registred[i].pointer.getvideo_info;
|
||||
mem_to_video=registred[i].pointer.mem_to_video;
|
||||
video_to_mem=registred[i].pointer.video_to_mem;
|
||||
video_to_video=registred[i].pointer.video_to_video;
|
||||
wait_vretrace=registred[i].pointer.wait_vretrace;
|
||||
wait_hretrace=registred[i].pointer.wait_hretrace;
|
||||
page_set=registred[i].pointer.page_set;
|
||||
page_show=registred[i].pointer.page_show;
|
||||
page_split=registred[i].pointer.page_split;
|
||||
cursor_enable=registred[i].pointer.cursor_enable;
|
||||
cursor_disable=registred[i].pointer.cursor_disable;
|
||||
cursor_set=registred[i].pointer.cursor_set;
|
||||
font_load=registred[i].pointer.font_load;
|
||||
font1_set=registred[i].pointer.font1_set;
|
||||
font2_set=registred[i].pointer.font2_set;
|
||||
blink_enable=registred[i].pointer.blink_enable;
|
||||
blink_disable=registred[i].pointer.blink_disable;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
setvideo_mode(0x0);
|
||||
}
|
||||
/*******************************************************************************/
|
||||
/* Applique le driver suivant */
|
||||
|
||||
void apply_nextdriver(void) {
|
||||
u32 i=0;
|
||||
while (registred[i].nom!=NULL && i<maxdrivers) {
|
||||
if (strcmp(getvideo_drivername(),registred[i].nom)==0) {
|
||||
i++;
|
||||
if (registred[i].nom!=NULL) i=0;
|
||||
apply_driver(registred[i].nom);
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/*******************************************************************************/
|
||||
/* Applique le mode suivant (le driver suivant si dernier mode) */
|
||||
|
||||
void apply_nextvideomode(void) {
|
||||
capabilities cap=getvideo_capabilities();
|
||||
videoinfos info=getvideo_info();
|
||||
u32 mode=info.modenumber;
|
||||
u8 index=0;
|
||||
while(cap[index].modenumber!=0xFF) {
|
||||
if (cap[index].modenumber==mode) {
|
||||
index++;
|
||||
if (cap[index].modenumber==0xFF)
|
||||
apply_nextdriver();
|
||||
else
|
||||
setvideo_mode(cap[index].modenumber);
|
||||
return;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************/
|
||||
|
||||
void fill(u8 attrib)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void scroll (u8 lines, u8 attrib)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void scroll_enable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void scroll_disable(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void showchar (u16 coordx, u16 coordy, u8 thechar, u8 attrib)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 getchar (u16 coordx, u16 coordy)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
u8 getattrib (u16 coordx, u16 coordy)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ align MULTIBOOT_TAG_ALIGN
|
|||
dd multiboot_header_end - multiboot_header
|
||||
dd -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + (multiboot_header_end - multiboot_header))
|
||||
align MULTIBOOT_TAG_ALIGN
|
||||
%if arch = "bits32"
|
||||
%if arch = "bitsd32"
|
||||
%warning "Avec la console VGA/EGA."
|
||||
console_tag_start:
|
||||
dw MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS ; type
|
||||
|
|
|
@ -46,7 +46,10 @@ void error()
|
|||
int main(u32 magic, u32 addr)
|
||||
{
|
||||
cli();
|
||||
setvmode(0x02);
|
||||
initdriver();
|
||||
registerdriver(&fonctions);
|
||||
apply_driver("VGA");
|
||||
setvideo_mode(0x02);
|
||||
/* Efface l'ecran */
|
||||
|
||||
print("\033[2J\000");
|
||||
|
|
Loading…
Reference in New Issue