aboutsummaryrefslogtreecommitdiff
path: root/tr8vm.c
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2023-05-08 22:52:26 +0100
committerJuan J. Martinez <jjm@usebox.net>2023-05-08 22:52:26 +0100
commit0194f9c3bbb460647ce5a22e4e8e7859398d8da0 (patch)
tree3a4b5cd529f0f3c5e1b152418038ec1587e515c8 /tr8vm.c
parent676046a8e532fb8cb62d558dac6fba07232d1f70 (diff)
downloadtr8vm-0194f9c3bbb460647ce5a22e4e8e7859398d8da0.tar.gz
tr8vm-0194f9c3bbb460647ce5a22e4e8e7859398d8da0.zip
Support read from the screen
Diffstat (limited to 'tr8vm.c')
-rw-r--r--tr8vm.c22
1 files changed, 20 insertions, 2 deletions
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;