aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-06-06 22:58:48 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-06-06 22:58:48 +0100
commit1c1e91bd8bf4e9d08cd4d8ee41568e3d25ee8256 (patch)
tree9f556e4cf692f83938ec772342b4cd6bb89323d8 /src/main.c
parent960db500527928e88bfb3787c9861a8b09f44749 (diff)
downloadgold-mine-run-1c1e91bd8bf4e9d08cd4d8ee41568e3d25ee8256.tar.gz
gold-mine-run-1c1e91bd8bf4e9d08cd4d8ee41568e3d25ee8256.zip
First stab at the sw blitter
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/src/main.c b/src/main.c
index 9876404..89ae860 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,7 +1,7 @@
#include <stdint.h>
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <stdio.h>
#include <crt0.h>
#include "keyb.h"
@@ -29,25 +29,50 @@ int main(int argc, char *argv[])
set_palette(binary_palette_start);
- uint8_t *screen = open_framebuffer();
- if (!screen)
+ if (!open_framebuffer())
{
set_mode(3);
fprintf(stderr, "ERROR: failed to open the framebuffer\n");
return 1;
}
- int i = 0;
+ blit_erase(0);
+
+ uint8_t bg[24 * 24] = { 0 };
+ uint16_t x = 10, y = 10;
+ int8_t ix = 1, iy = 1;
+ uint8_t c = 0;
+
while (!keys[KEY_ESC])
{
- wait_vsync();
+ // erase
+ blit(bg, x, y, 24, 24);
- memset(screen, i, 320 * 200);
- i++;
- if (i > 15)
- i = 0;
+ x += ix;
+ y += iy;
+
+ if (x >= 320 - 24 || x == 0)
+ {
+ ix *= -1;
+ c = (c + 1) % 15;
+ blit_erase(c);
+ memset(bg, c, 24 * 24);
+ }
+ if (y >= 200 - 24 || y == 0)
+ {
+ iy *= -1;
+ c = (c + 1) % 15;
+ blit_erase(c);
+ memset(bg, c, 24 * 24);
+ }
+
+ // draw
+ blit(binary_sprites_start, x, y, 24, 24);
+
+ wait_vsync();
+ blit_update();
- timer_wait(1);
+ //timer_wait(1);
}
set_mode(3);