#include "bootboot.h"
#include "interrupts/Context.h"
#include "render/Framebuffer.h"
#include "std/errno.h"
#include <stdint.h>

extern BOOTBOOT bootboot;

void sys_paint(Context* context, uint64_t x, uint64_t y, uint64_t w, uint64_t h, uint64_t c)
{
    if ((x + w) > bootboot.fb_width)
    {
        context->rax = -EINVAL;
        return;
    }
    if ((y + h) > bootboot.fb_height)
    {
        context->rax = -EINVAL;
        return;
    }

    uint32_t color = (uint32_t)c;

    framebuffer0.paint_rect((uint32_t)x, (uint32_t)y, (uint32_t)w, (uint32_t)h, Color::from_integer(color));

    context->rax = 0;
}