#include #include #include "drivers/vesa/vesa.h" extern int mx, my, mz; extern int buttons[5]; struct cpu_state *lf_api_handler(struct cpu_state *cpu) { switch(HIWORD(cpu->eax)) { case 0: switch(LOWORD(cpu->eax)) { case 0: // Prozess beenden kill_task(current_task->pid, cpu); break; case 1: // Taskwechsel return schedule(cpu); break; } break; case 1: switch(LOWORD(cpu->eax)) { case 0: cpu->ebx = (uint32_t)kalloc(cpu->ebx); break; case 1: // free() break; } break; case 2: switch(LOWORD(cpu->eax)) { case 0: kprintf("%c", cpu->ebx); break; case 1: color = cpu->ebx; break; } break; case 3: switch(LOWORD(cpu->eax)) { case 0: cpu->ebx = keyboard_buffer != 0 ? keyboard_buffer : 0xFF; break; case 1: // cpu->ebx = scancode break; case 2: cpu->ebx = mx; cpu->ecx = my; cpu->edx = mz; break; case 3: cpu->ebx = buttons[0]; cpu->ecx = buttons[2]; cpu->edx = buttons[1]; break; } case 4: switch(LOWORD(cpu->eax)) { case 0: { int r, g, b, a; r = (cpu->edx >> 24) & 0xFF; g = (cpu->edx >> 16) & 0xFF; b = (cpu->edx >> 8 ) & 0xFF; a = (cpu->edx >> 0 ) & 0xFF; if(a == 255) putpixel(cpu->ecx * lfb_width + cpu->ebx, r, g, b); else putpixelRGBA(cpu->ebx, cpu->ecx, r, g, b, a); } break; case 1: // resX = cpu->ebx // resY = cpu->ecx // resDepth = cpu->edx break; case 2: cpu->ebx = lfb_width; cpu->ecx = lfb_height; cpu->edx = lfb_depth; break; case 3: switch_buffer(); break; case 4: { /* fill rectangle */ int r, g, b, a; r = (cpu->edx >> 24) & 0xFF; g = (cpu->edx >> 16) & 0xFF; b = (cpu->edx >> 8 ) & 0xFF; a = (cpu->edx >> 0 ) & 0xFF; int x = HIWORD(cpu->ebx); int w = LOWORD(cpu->ebx); int y = HIWORD(cpu->ecx); int h = LOWORD(cpu->ecx); for(; y < y + h; y++) { for(; x < x + w; x++) { if(a == 255) putpixel(y * lfb_width + x, r, g, b); else putpixelRGBA(x, y, r, g, b, a); } } } break; } } return cpu; }