Mercurial > repos > blastem
comparison vdp.c @ 2411:efd2242c2c23
Fix silly TMS9918A bug, make CRAM viewer sorta useful in TMS9918A modes, make mode4 address map externally viewable for debugger
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 04 Jan 2024 22:13:46 -0800 |
parents | ce9f5a42c481 |
children | dc05f1805921 |
comparison
equal
deleted
inserted
replaced
2410:f1574b22d5d9 | 2411:efd2242c2c23 |
---|---|
58 INACTIVE = 0, | 58 INACTIVE = 0, |
59 PREPARING, //used for line 0x1FF | 59 PREPARING, //used for line 0x1FF |
60 ACTIVE | 60 ACTIVE |
61 }; | 61 }; |
62 | 62 |
63 static uint16_t mode4_address_map[0x4000]; | 63 uint16_t mode4_address_map[0x4000]; |
64 static uint32_t planar_to_chunky[256]; | 64 static uint32_t planar_to_chunky[256]; |
65 static uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 228, 255}; | 65 static uint8_t levels[] = {0, 27, 49, 71, 87, 103, 119, 130, 146, 157, 174, 190, 206, 228, 255}; |
66 | 66 |
67 static uint8_t debug_base[][3] = { | 67 static uint8_t debug_base[][3] = { |
68 {127, 127, 127}, //BG | 68 {127, 127, 127}, //BG |
2028 for (int x = 0; x < 8; x++) | 2028 for (int x = 0; x < 8; x++) |
2029 { | 2029 { |
2030 *(fb++) = context->colors[i]; | 2030 *(fb++) = context->colors[i]; |
2031 } | 2031 } |
2032 } | 2032 } |
2033 } else { | 2033 } else if (context->type == VDP_GENESIS || (context->regs[REG_MODE_1] & BIT_MODE_4)) { |
2034 for (int i = MODE4_OFFSET; i < MODE4_OFFSET+32; i++) | 2034 for (int i = MODE4_OFFSET; i < MODE4_OFFSET+32; i++) |
2035 { | 2035 { |
2036 for (int x = 0; x < 16; x++) | 2036 for (int x = 0; x < 16; x++) |
2037 { | 2037 { |
2038 *(fb++) = context->colors[i]; | 2038 *(fb++) = context->colors[i]; |
2039 } | |
2040 } | |
2041 } else if (context->type != VDP_GENESIS) { | |
2042 uint16_t address = context->regs[REG_COLOR_TABLE] << 6; | |
2043 for (int i = 0; i < 32; i++, address++) | |
2044 { | |
2045 uint8_t entry = context->vdpmem[mode4_address_map[address] ^ 1]; | |
2046 uint8_t fg = entry >> 4, bg = entry & 0xF; | |
2047 uint32_t fg_full, bg_full; | |
2048 if (context->type == VDP_GAMEGEAR) { | |
2049 //Game Gear uses CRAM entries 16-31 for TMS9918A modes | |
2050 fg_full = context->colors[fg + 16 + MODE4_OFFSET]; | |
2051 bg_full = context->colors[bg + 16 + MODE4_OFFSET]; | |
2052 } else { | |
2053 fg <<= 1; | |
2054 fg = (fg & 0xE) | (fg << 1 & 0x20); | |
2055 fg_full = context->color_map[fg | FBUF_TMS]; | |
2056 bg <<= 1; | |
2057 bg = (bg & 0xE) | (bg << 1 & 0x20); | |
2058 bg_full = context->color_map[bg | FBUF_TMS]; | |
2059 } | |
2060 for (int x = 0; x < 8; x++) | |
2061 { | |
2062 *(fb++) = fg_full; | |
2063 } | |
2064 for (int x = 0; x < 8; x++) | |
2065 { | |
2066 *(fb++) = bg_full; | |
2039 } | 2067 } |
2040 } | 2068 } |
2041 } | 2069 } |
2042 } | 2070 } |
2043 if ( | 2071 if ( |
3634 //Multicolor | 3662 //Multicolor |
3635 external_slot(context); | 3663 external_slot(context); |
3636 return; | 3664 return; |
3637 } | 3665 } |
3638 uint16_t address = context->regs[REG_COLOR_TABLE] << 6; | 3666 uint16_t address = context->regs[REG_COLOR_TABLE] << 6; |
3639 if (context->regs[REG_MODE_2] & BIT_M3) { | 3667 if (context->regs[REG_MODE_1] & BIT_M3) { |
3640 //Graphics II | 3668 //Graphics II |
3641 uint16_t upper_vcounter_mask; | 3669 uint16_t upper_vcounter_mask; |
3642 uint16_t pattern_name_mask; | 3670 uint16_t pattern_name_mask; |
3643 if (context->type > VDP_SMS2) { | 3671 if (context->type > VDP_SMS2) { |
3644 //SMS1 and TMS9918A | 3672 //SMS1 and TMS9918A |