From 0194f9c3bbb460647ce5a22e4e8e7859398d8da0 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Mon, 8 May 2023 22:52:26 +0100 Subject: Support read from the screen --- tr8vm.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'tr8vm.c') diff --git a/tr8vm.c b/tr8vm.c index 59d08b7..69a0123 100644 --- a/tr8vm.c +++ b/tr8vm.c @@ -121,24 +121,41 @@ uint8_t port(uint8_t p, uint8_t v) { switch (p) { + /* blitter control */ case 0xb0: + /* settings mode */ if (v & 128) { blt_set = 1; blt_paramc = 0; return p; } - if (v & 1) + /* draw (read or write) */ + if (v & 5) { blt_set = 0; + /* can't be both */ + if ((v & 1) && (v & 4)) + return 0xff; + + /* missing parameters */ if (blt_paramc != 6) return 0xff; - /* draw */ + /* 1: write into vram */ uint16_t src = blt_param[0] | (blt_param[1] << 8); uint16_t dst = VIDEO_RAM + blt_param[2] + blt_param[3] * 128; + /* 4: read from vram */ + if (v & 4) + { + /* swap */ + uint16_t t = dst; + dst = src; + src = t; + } + for (uint8_t y = 0; y < blt_param[5]; y++) for (uint8_t x = 0; x < blt_param[4]; x++) { @@ -155,6 +172,7 @@ uint8_t port(uint8_t p, uint8_t v) } return 0xff; + /* blitter settings */ case 0xb1: if (!blt_set || blt_paramc > 5) return 0xff; -- cgit v1.2.3