diff options
author | Juan J. Martinez <jjm@usebox.net> | 2023-05-10 20:34:07 +0100 |
---|---|---|
committer | Juan J. Martinez <jjm@usebox.net> | 2023-05-10 20:34:07 +0100 |
commit | f15e55b960e1aa4d63c29f85d5db931342b617d9 (patch) | |
tree | b0fcbe7233149dbbfe853bc23e8a42123dd92e11 | |
parent | 2a9dba45c2219757dccb249737d504b922f4451e (diff) | |
download | tr8vm-f15e55b960e1aa4d63c29f85d5db931342b617d9.tar.gz tr8vm-f15e55b960e1aa4d63c29f85d5db931342b617d9.zip |
Avoid magic number and fix in trasparent reading from VRAM
-rw-r--r-- | tr8vm.c | 13 | ||||
-rw-r--r-- | vm.h | 1 |
2 files changed, 9 insertions, 5 deletions
@@ -96,13 +96,13 @@ uint32_t *fb_data = NULL; static void update_fb() { - for (uint16_t addr = 0; addr < 16384; addr++) + for (uint16_t addr = 0; addr < VIDEO_RAM_LEN; addr++) fb_data[addr] = palette[ram[VIDEO_RAM + addr] & 15]; } void write_m(uint16_t addr, uint8_t b) { - if (addr >= VIDEO_RAM && addr < VIDEO_RAM + 16384) + if (addr >= VIDEO_RAM && addr < VIDEO_RAM + VIDEO_RAM_LEN) fb_data[addr - VIDEO_RAM] = palette[b & 15]; ram[addr] = b; @@ -159,7 +159,7 @@ static void update_ctl(SDL_Event *ev) uint8_t blt_set = 0; uint8_t blt_paramc = 0; -uint8_t blt_param[6] = { 0 }; +int8_t blt_param[6] = { 0 }; uint8_t port(uint8_t p, uint8_t v) { @@ -191,7 +191,7 @@ uint8_t port(uint8_t p, uint8_t v) if (v & 1) { uint16_t src = blt_param[0] | (blt_param[1] << 8); - uint16_t dst = VIDEO_RAM + blt_param[2] + blt_param[3] * 128; + uint16_t dst = VIDEO_RAM + blt_param[2] + blt_param[3] * TR8_W; for (uint8_t y = 0; y < blt_param[5]; y++) for (uint8_t x = 0; x < blt_param[4]; x++) @@ -208,7 +208,7 @@ uint8_t port(uint8_t p, uint8_t v) /* read from vram */ else { - uint16_t src = VIDEO_RAM + blt_param[2] + blt_param[3] * 128; + uint16_t src = VIDEO_RAM + blt_param[2] + blt_param[3] * TR8_W; uint16_t dst = blt_param[0] | (blt_param[1] << 8); for (uint8_t y = 0; y < blt_param[5]; y++) @@ -218,7 +218,10 @@ uint8_t port(uint8_t p, uint8_t v) /* skip transparent if transparent flag is set */ if ((v & 2) && (b & 128)) + { + dst++; continue; + } write_m(dst++, b); } @@ -26,6 +26,7 @@ #define _TR8_H #define VIDEO_RAM 0xbf00 +#define VIDEO_RAM_LEN 16384 #define FRAME_INT_VECT 0xff00 typedef struct |