aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-07-09 21:55:17 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-07-09 21:55:17 +0100
commitf7c861e94eb95579c725dcd5d403acd7b4b318e3 (patch)
treee92db4f270a475de61b79c2f859314992dcd01ac
parent9ff574061910f9562ccf4b2f6a21dda66e2a3f08 (diff)
downloadgold-mine-run-f7c861e94eb95579c725dcd5d403acd7b4b318e3.tar.gz
gold-mine-run-f7c861e94eb95579c725dcd5d403acd7b4b318e3.zip
Assembler optimised blit copy hardcoded to 16x16
-rw-r--r--src/entities.c2
-rw-r--r--src/vga.c25
-rw-r--r--src/vga.h2
3 files changed, 28 insertions, 1 deletions
diff --git a/src/entities.c b/src/entities.c
index e24c119..0471fbc 100644
--- a/src/entities.c
+++ b/src/entities.c
@@ -61,7 +61,7 @@ void entities_draw()
{
dst.x = e->ox;
dst.y = e->oy + MAP_OFFS_Y;
- blit_copy(&dst);
+ blit_copy16x16(&dst);
e->erase = 0;
}
diff --git a/src/vga.c b/src/vga.c
index 70a9a67..c78fcec 100644
--- a/src/vga.c
+++ b/src/vga.c
@@ -196,3 +196,28 @@ void blit_copy(const Rect *dst)
dtarget += 320;
}
}
+
+void blit_copy16x16(const Rect *dst)
+{
+ uint8_t *src = buffer + dst->x + dst->y * 320;
+ uint8_t *dtarget = screen + dst->x + dst->y * 320;
+
+ asm volatile (
+ "movl $16, %%eax\n\t"
+ "movl $0x130, %%ebx\n\t"
+ "cld\n\t"
+ "blit_copy16x16_loop:\n\t"
+ "movsl\n\t"
+ "movsl\n\t"
+ "movsl\n\t"
+ "movsl\n\t"
+ "addl %%ebx, %%esi\n\t"
+ "addl %%ebx, %%edi\n\t"
+ "decl %%eax\n\t"
+ "orl %%eax, %%eax\n\t"
+ "jne blit_copy16x16_loop\n\t"
+ : /* no output */
+ : "S" (src), "D" (dtarget)
+ : "ecx", "ebx", "eax"
+ );
+}
diff --git a/src/vga.h b/src/vga.h
index 2441e24..1809c46 100644
--- a/src/vga.h
+++ b/src/vga.h
@@ -36,5 +36,7 @@ void blit_erase(uint8_t c);
/* copy from back buffer to screen */
void blit_copy_all();
void blit_copy(const Rect *dst);
+/* only fot 16x16 rects, w and h are ignored */
+void blit_copy16x16(const Rect *dst);
#endif /* _VGA_H */