summaryrefslogtreecommitdiff
path: root/src/cmd/dvd.c
diff options
context:
space:
mode:
authordzwdz2023-09-22 23:42:30 +0200
committerdzwdz2023-09-22 23:42:30 +0200
commit6a4d4a41a664e6a4c406a449ea847abd4a224bcf (patch)
tree0a637697c8697929beb8f4b7ff69d8b74f9e28bb /src/cmd/dvd.c
parenta3d6aa9f8d427b86a33dc05bed98a2e88229a285 (diff)
build: support single file commands
Diffstat (limited to 'src/cmd/dvd.c')
-rw-r--r--src/cmd/dvd.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/cmd/dvd.c b/src/cmd/dvd.c
new file mode 100644
index 0000000..0b5caaf
--- /dev/null
+++ b/src/cmd/dvd.c
@@ -0,0 +1,42 @@
+#include <camellia/execbuf.h>
+#include <camellia/syscalls.h>
+#include <err.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <draw.h>
+
+struct framebuf fb;
+struct rect dirty;
+
+void draw_rect(uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t col) {
+ for (uint32_t i = 0; i < w; i++) {
+ for (uint32_t j = 0; j < h; j++) {
+ *((uint32_t*)(fb.b + fb.pitch * (y+j) + 4 * (x+i))) = col;
+ }
+ }
+ dirty_mark(&dirty, x, y);
+ dirty_mark(&dirty, x + w, y + h);
+}
+
+int main(void) {
+ if (fb_setup(&fb, "/dev/video/") < 0) {
+ err(1, "fb_setup");
+ return 1;
+ }
+ int dx = 2, dy = 2, x = 100, y = 100, w = 150, h = 70;
+ uint32_t col = 0x800000;
+
+ for (;;) {
+ if (x + dx < 0 || (size_t)(x + dx + w) >= fb.width) dx *= -1;
+ if (y + dy < 0 || (size_t)(y + dy + h) >= fb.height) dy *= -1;
+ x += dx;
+ y += dy;
+ draw_rect(x, y, w, h, col++);
+ dirty_flush(&dirty, &fb);
+ _sys_sleep(1000 / 60);
+ }
+
+ return 1;
+}