diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-08 23:34:33 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-08 23:34:33 +0100 |
commit | ef6a41652e0d3ee5b1745286fefa6d8f57509a23 (patch) | |
tree | 5f1a65c428c1e91656a0cf467b0cf7c41159fc70 | |
parent | e5a253ea9e9d249ad330ac2c8184ce79e3e38847 (diff) | |
download | tr8vm-ef6a41652e0d3ee5b1745286fefa6d8f57509a23.tar.gz tr8vm-ef6a41652e0d3ee5b1745286fefa6d8f57509a23.zip |
Fix reading from vram
-rw-r--r-- | tr8vm.c | 50 |
1 files changed, 31 insertions, 19 deletions
@@ -143,30 +143,42 @@ uint8_t port(uint8_t p, uint8_t v) if (blt_paramc != 6) return 0xff; - /* 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) + /* write into vram */ + if (v & 1) { - /* swap */ - uint16_t t = dst; - dst = src; - src = t; + uint16_t src = blt_param[0] | (blt_param[1] << 8); + uint16_t dst = VIDEO_RAM + blt_param[2] + blt_param[3] * 128; + + for (uint8_t y = 0; y < blt_param[5]; y++) + for (uint8_t x = 0; x < blt_param[4]; x++) + { + uint8_t b = read_m(src++); + + /* skip transparent if transparent flag is set */ + if ((v & 2) && (b & 128)) + continue; + + write_m(dst + x + y * 128, b); + } } + /* read from vram */ + else + { + uint16_t src = VIDEO_RAM + blt_param[2] + blt_param[3] * 128; + uint16_t dst = blt_param[0] | (blt_param[1] << 8); - for (uint8_t y = 0; y < blt_param[5]; y++) - for (uint8_t x = 0; x < blt_param[4]; x++) - { - uint8_t b = read_m(src++); + for (uint8_t y = 0; y < blt_param[5]; y++) + for (uint8_t x = 0; x < blt_param[4]; x++) + { + uint8_t b = read_m(src + x + y * 128); - /* skip transparent if transparent flag is set */ - if ((v & 2) && (b & 128)) - continue; + /* skip transparent if transparent flag is set */ + if ((v & 2) && (b & 128)) + continue; - write_m(dst + x + y * 128, b); - } + write_m(dst++, b); + } + } return p; } |