by rep_lodsb · 2y ago · 0 comments
Sadly it doesn't work on my system: the display is drawn at the start (sometimes partially), and then only ever updates when switching between virtual consoles.
Tried adding O_SYNC to the open flags for the framebuffer, and it didn't help. It's writing to the device 60 times per second, just won't show for some reason.
Thanks for trying it :)
BTW, is there a problem with the JavaScript on my website?
Well, not immediately. At first there was an entirely different problem: everything on the screen was garbled!
However it was easy to figure out why and fix it: depending on the hardware and resolution, lines in the framebuffer can have extra padding beyond what's needed for the visible pixels. That information is available in another info structure:
; Get size of line in framebuffer
mov eax, 16 ; sys_ioctl
mov edi, [drw_fbfd]
mov esi, 0x4602 ; FBIOGET_FSCREENINFO
mov rdx, rsp
syscall
mov eax, [rsp+0x30] ; bytes per line
shr eax, 2 ; convert to pixels
mov [drw_fb_pitch], eax
There are only a few places in draw.asm that then need to be changed to multiply by this new variable instead of drw_fb_w. push 0 ; put X,Y offsets on stack
sub rsp, 16 ; 4 more dwords (don't care)
mov eax, 16 ; sys_ioctl
mov edi, [drw_fbfd]
mov esi, 0x4606 ; FBIOPAN_DISPLAY
mov rdx, rsp ; ptr to structure on stack
syscall
add rsp, 24 ; drop it
ret
From what little documentation there is, this IOCTL takes a fb_var_screeninfo structure, but only pays attention to the x/y offset fields (so allocating 24 bytes for it should be enough). With the offsets set to zero, it now works perfectly on my machine.>BTW, is there a problem with the JavaScript on my website?
I just block all JavaScript by default, and strongly believe that websites should remain usable that way.
It's really too bad how the Linux kernel provides these APIs, but barely any documentation, and the only way you're supposed to interact with them is through some specially "blessed" abstraction layer running in userspace (X11/Wayland/SDL, pulseaudio, etc.) which inevitably demands linking in C libraries.