⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vga.h

📁 从网上下载的一个自己编写的简单的操作系统源代码,对底层了解很有好处的
💻 H
字号:
#ifndef _VGA_H_
#define  _VGA_H_


#define COLS  80
#define ROWS  25
#define SIZE  64
#define VRAM  ((unsigned char *)0xc00b8000)
#define VRAM_TEXT ((unsigned char *)0xc00b8000)




#ifndef TEXTMODE

/* VGA12h 图形模式下使用 0xA0000 */
#undef VRAM
#define VRAM ((unsigned char *)0xc00a0000)

#define WIDTH 640
#define HEIGHT 480
#define COLORS 16

#define ASC_WIDTH 8
#define CHS_WIDTH 16
#define SPACING 2
#define CHAR_HEIGHT 16
#define LINE_HEIGHT (CHAR_HEIGHT + SPACING)
#define TIPS_POS	(LINE_HEIGHT * ROWS)
#define TIPS_HEIGHT	(HEIGHT - LINE_HEIGHT * ROWS)

#define ASC_NUM 256
#define CHS_QU 87
#define CHS_WEI 94
#define CHS_NUM (CHS_QU * CHS_WEI)


/* 定义图形显示操作寄存器 */
#define VGA_AC_INDEX 0x3C0
#define VGA_AC_WRITE 0x3C0
#define VGA_AC_READ 0x3C1
#define VGA_MISC_WRITE 0x3C2
#define VGA_SEQ_INDEX 0x3C4
#define VGA_SEQ_DATA 0x3C5
#define VGA_DAC_READ_INDEX 0x3C7
#define VGA_DAC_WRITE_INDEX 0x3C8
#define VGA_DAC_DATA 0x3C9
#define VGA_MISC_READ 0x3CC
#define VGA_GC_INDEX 0x3CE
#define VGA_GC_DATA 0x3CF
/* COLOR emulation MONO emulation */
#define VGA_CRTC_INDEX 0x3D4	/* 0x3B4 */
#define VGA_CRTC_DATA 0x3D5		/* 0x3B5 */
#define VGA_INSTAT_READ 0x3DA

#define VGA_NUM_SEQ_REGS 5
#define VGA_NUM_CRTC_REGS 25
#define VGA_NUM_GC_REGS 9
#define VGA_NUM_AC_REGS 21
#define VGA_NUM_REGS (1 + VGA_NUM_SEQ_REGS + VGA_NUM_CRTC_REGS + VGA_NUM_GC_REGS + VGA_NUM_AC_REGS)

#endif


/* define some io port */
#define VGA_IN     0x3D4
#define VGA_DATA   0x3D5




#ifndef TEXTMODE

/* 颜色枚举应放在其他位置 */
enum COLOR {
	/*  dark colors     */
	BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY,
	/*  light colors    */
    DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE
};



/*??? 置显示操作忙,应在 out 层次还是更高一层?
static int video_busy = 0;
*/

#endif


void vga_init(void);
void vga_pixel(unsigned int x, unsigned int y, unsigned int c);
void putchar(char ch);
void puts(char *s);
unsigned char getchar(void);
void vga_outbyte(unsigned int col, unsigned int y, unsigned char mask, unsigned int c);
void scroll_up(void);
void inline gotoxy(unsigned int x,unsigned int y);
void clear_vram(void);

inline void video_ascii(int col, int y, unsigned char ch, int c);
inline void video_gb2312(int col, int y, unsigned char c1, unsigned char c2, int c);

void console_init();
void video_logo();

#endif 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -