参考:
https://www.bilibili.com/video/BV1VJ41157wq?p=11
https://blog.csdn.net/tyler_download/article/details/52712161
如何绘制鼠标,和绘制字体没有啥区别,弄个点阵,16×16d的二维数组。
void init_mouse_cursor(char* mouse, char bc) {
static char cursor[16][16] = {
"**************..",
"*OOOOOOOOOOO*...",
"*OOOOOOOOOO*....",
"*OOOOOOOOO*.....",
"*OOOOOOOO*......",
"*OOOOOOO*.......",
"*OOOOOOO*.......",
"*OOOOOOOO*......",
"*OOOO**OOO*.....",
"*OOO*..*OOO*....",
"*OO*....*OOO*...",
"*O*......*OOO*..",
"**........*OOO*.",
"*..........*OOO*",
"............*OO*",
".............***"
};
int x, y;
for (y = 0; y < 16; y++) {
for (x = 0; x < 16; x++) {
if (cursor[y][x] == '*') {
mouse[y*16 + x] = COL8_000000;
}
if (cursor[y][x] == 'O') {
mouse[y*16 + x] = COL8_FFFFFF;
}
if (cursor[y][x] == '.') {
mouse[y*16 + x] = bc;
}
}
}
}
void putblock(char* vram, int vxsize, int pxsize,
int pysize, int px0, int py0, char* buf, int bxsize) {
int x, y;
for (y = 0; y < pysize; y++)
for (x = 0; x < pxsize; x++) {
vram[(py0+y) * vxsize + (px0+x)] = buf[y * bxsize + x];
}
}
write_vga_cursor.c
void showString(...);
void putblock(char* vram, int vxsize, int pxsize,
int pysize, int px0, int py0, char* buf, int bxsize);
void init_mouse_cursor(char* mouse, char bc);
static char mcursor[256];
void CMain(void) {
...
showString(...);
init_mouse_cursor(mcursor, COL8_008484);
putblock(vram, xsize, 16, 16, 80, 80, mcursor, 16);
for(;;){
...
}
}
开始制作:
write_vga_cursor.c
gcc -m32 -fno-pie -s -c -o write_vga_cursor.o write_vga_cursor.c
../objconv-new/objconv/objconv -fnasm write_vga_cursor.o -o write_vga_cursor.asm
delete:
global
extern
section
endbr32
kernel.asm
%include "write_vga_cursor.asm"
nasm -o kernel.bat kernel.asm
sector:2-17
boot.asm change 20
鼠标可以画出来,但是不能动。如何动?只能通过CPU中断机制,鼠标动触发中断,中断处理程序重新擦出/重新画,就可以动鼠标了。
预知后事如何,请听下回分解。