src/emu/video/tms9928a.c
| r12394 | r12395 | |
| 13 | 13 | ** Improved over the years by MESS and MAME teams. |
| 14 | 14 | ** |
| 15 | 15 | ** Todo: |
| 16 | | ** - Convert implementation to modern device. |
| 17 | | ** - The screen image is rendered in `one go'. Modifications during |
| 18 | | ** screen build up are not shown. |
| 19 | 16 | ** - Colours are incorrect. [fixed by R Nabet ?] |
| 20 | 17 | ** - Sprites 8-31 are ghosted/cloned in mode 3 when using less than |
| 21 | 18 | ** three pattern tables. Exact behaviour is not known. |
| r12394 | r12395 | |
| 23 | 20 | |
| 24 | 21 | #include "emu.h" |
| 25 | 22 | #include "tms9928a.h" |
| 23 | #include "machine/devhelpr.h" |
| 26 | 24 | |
| 27 | 25 | |
| 26 | const device_type TMS9928A = &device_creator<tms9928a_device>; |
| 27 | const device_type TMS9918 = &device_creator<tms9918_device>; |
| 28 | const device_type TMS9918A = &device_creator<tms9918a_device>; |
| 29 | const device_type TMS9118 = &device_creator<tms9118_device>; |
| 30 | const device_type TMS9128 = &device_creator<tms9128_device>; |
| 31 | const device_type TMS9929 = &device_creator<tms9929_device>; |
| 32 | const device_type TMS9929A = &device_creator<tms9929a_device>; |
| 33 | const device_type TMS9129 = &device_creator<tms9129_device>; |
| 34 | |
| 35 | |
| 28 | 36 | /* |
| 29 | 37 | New palette (R. Nabet). |
| 30 | 38 | |
| r12394 | r12395 | |
| 53 | 61 | E Gray 0.80 0.47 0.47 0.80 0.80 0.80 204 204 204 |
| 54 | 62 | F White 1.00 0.47 0.47 1.00 1.00 1.00 255 255 255 |
| 55 | 63 | */ |
| 56 | | static const rgb_t TMS9928A_palette[16] = |
| 64 | static const rgb_t tms9928a_palette[16] = |
| 57 | 65 | { |
| 58 | 66 | RGB_BLACK, |
| 59 | 67 | RGB_BLACK, |
| r12394 | r12395 | |
| 73 | 81 | RGB_WHITE |
| 74 | 82 | }; |
| 75 | 83 | |
| 76 | | /* |
| 77 | | ** Forward declarations of internal functions. |
| 78 | | */ |
| 79 | | static void draw_mode0 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 80 | | static void draw_mode1 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 81 | | static void draw_mode2 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 82 | | static void draw_mode12 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 83 | | static void draw_mode3 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 84 | | static void draw_mode23 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 85 | | static void draw_modebogus (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 86 | | static void draw_sprites (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect); |
| 87 | | static void change_register (running_machine &machine, int reg, UINT8 data); |
| 88 | 84 | |
| 89 | | static void (*const ModeHandlers[])(device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) = { |
| 90 | | draw_mode0, draw_mode1, draw_mode2, draw_mode12, |
| 91 | | draw_mode3, draw_modebogus, draw_mode23, |
| 92 | | draw_modebogus |
| 93 | | }; |
| 94 | | |
| 95 | | #define IMAGE_SIZE (256*192) /* size of rendered image */ |
| 96 | | |
| 97 | | #define LEFT_BORDER 15 /* a bit less for 9918a??? */ |
| 98 | | #define RIGHT_BORDER 15 /* 13 for 9929a */ |
| 99 | | #define TOP_BORDER_60HZ 27 |
| 100 | | #define BOTTOM_BORDER_60HZ 24 |
| 101 | | #define TOP_BORDER_50HZ 51 /* unknown (102 for top+bottom?) */ |
| 102 | | #define BOTTOM_BORDER_50HZ 51 /* unknown (102 for top+bottom?) */ |
| 103 | | #define TOP_BORDER tms.top_border |
| 104 | | #define BOTTOM_BORDER tms.bottom_border |
| 105 | | |
| 106 | | #define TMS_50HZ ((tms.model == TMS9929) || (tms.model == TMS9929A)) |
| 107 | | #define TMS_REVA ((tms.model == TMS99x8A) || (tms.model == TMS9929A)) |
| 108 | | #define TMS_MODE ( (TMS_REVA ? (tms.Regs[0] & 2) : 0) | \ |
| 109 | | ((tms.Regs[1] & 0x10)>>4) | ((tms.Regs[1] & 8)>>1)) |
| 110 | | |
| 111 | | typedef struct { |
| 112 | | /* TMS9928A internal settings */ |
| 113 | | UINT8 ReadAhead,Regs[8],StatusReg,FifthSprite,latch,INT; |
| 114 | | INT32 Addr; |
| 115 | | int colour,pattern,nametbl,spriteattribute,spritepattern; |
| 116 | | int colourmask,patternmask; |
| 117 | | void (*INTCallback)(running_machine &, int); |
| 118 | | /* memory */ |
| 119 | | UINT8 *vMem, *dBackMem; |
| 120 | | bitmap_t *tmpbmp; |
| 121 | | int vramsize, model; |
| 122 | | /* emulation settings */ |
| 123 | | int LimitSprites; /* max 4 sprites on a row, like original TMS9918A */ |
| 124 | | int top_border, bottom_border; |
| 125 | | rectangle visarea; |
| 126 | | } TMS9928A; |
| 127 | | |
| 128 | | static TMS9928A tms; |
| 129 | | |
| 130 | 85 | /* |
| 131 | 86 | ** initialize the palette |
| 132 | 87 | */ |
| 133 | | static PALETTE_INIT( tms9928a ) |
| 88 | PALETTE_INIT( tms9928a ) |
| 134 | 89 | { |
| 135 | | palette_set_colors(machine, 0, TMS9928A_palette, TMS9928A_PALETTE_SIZE); |
| 90 | palette_set_colors(machine, 0, tms9928a_palette, TMS9928A_PALETTE_SIZE); |
| 136 | 91 | } |
| 137 | 92 | |
| 138 | 93 | |
| 139 | | /* |
| 140 | | ** The init, reset and shutdown functions |
| 141 | | */ |
| 142 | | void TMS9928A_reset () { |
| 143 | | int i; |
| 144 | | |
| 145 | | for (i=0;i<8;i++) tms.Regs[i] = 0; |
| 146 | | tms.StatusReg = 0; tms.FifthSprite = 0; |
| 147 | | tms.nametbl = tms.pattern = tms.colour = 0; |
| 148 | | tms.spritepattern = tms.spriteattribute = 0; |
| 149 | | tms.colourmask = tms.patternmask = 0; |
| 150 | | tms.Addr = tms.ReadAhead = tms.INT = 0; |
| 151 | | tms.latch = 0; |
| 94 | tms9928a_device::tms9928a_device( const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_50hz, bool is_reva ) |
| 95 | : device_t( mconfig, type, name, tag, owner, clock ) |
| 96 | { |
| 97 | m_50hz = is_50hz; |
| 98 | m_reva = is_reva; |
| 152 | 99 | } |
| 153 | 100 | |
| 154 | | static void TMS9928A_start (running_machine &machine, const TMS9928a_interface *intf) |
| 101 | |
| 102 | tms9928a_device::tms9928a_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock ) |
| 103 | : device_t( mconfig, TMS9928A, "tms9928a", tag, owner, clock ) |
| 155 | 104 | { |
| 156 | | assert_always(((intf->vram == 0x1000) || (intf->vram == 0x2000) || (intf->vram == 0x4000)), "4, 8 or 16 kB vram please"); |
| 105 | m_50hz = false; |
| 106 | m_reva = true; |
| 107 | } |
| 157 | 108 | |
| 158 | | tms.model = intf->model; |
| 159 | 109 | |
| 160 | | tms.top_border = TMS_50HZ ? TOP_BORDER_50HZ : TOP_BORDER_60HZ; |
| 161 | | tms.bottom_border = TMS_50HZ ? BOTTOM_BORDER_50HZ : BOTTOM_BORDER_60HZ; |
| 110 | READ8_MEMBER( tms9928a_device::vram_read ) |
| 111 | { |
| 112 | UINT8 data = m_ReadAhead; |
| 162 | 113 | |
| 163 | | tms.INTCallback = intf->int_callback; |
| 114 | m_ReadAhead = m_vMem[ m_Addr ]; |
| 115 | m_Addr = (m_Addr + 1) & (m_vram_size - 1); |
| 116 | m_latch = 0; |
| 164 | 117 | |
| 165 | | /* determine the visible area */ |
| 166 | | tms.visarea.min_x = LEFT_BORDER - MIN(intf->borderx, LEFT_BORDER); |
| 167 | | tms.visarea.max_x = LEFT_BORDER + 32*8 - 1 + MIN(intf->borderx, RIGHT_BORDER); |
| 168 | | tms.visarea.min_y = tms.top_border - MIN(intf->bordery, tms.top_border); |
| 169 | | tms.visarea.max_y = tms.top_border + 24*8 - 1 + MIN(intf->bordery, tms.bottom_border); |
| 118 | return data; |
| 119 | } |
| 170 | 120 | |
| 171 | | /* configure the screen if we weren't overridden */ |
| 172 | | if (machine.primary_screen->width() == LEFT_BORDER+32*8+RIGHT_BORDER && |
| 173 | | machine.primary_screen->height() == TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ) |
| 174 | | machine.primary_screen->configure(LEFT_BORDER + 32*8 + RIGHT_BORDER, tms.top_border + 24*8 + tms.bottom_border, tms.visarea, machine.primary_screen->frame_period().attoseconds); |
| 175 | 121 | |
| 176 | | /* Video RAM */ |
| 177 | | tms.vramsize = intf->vram; |
| 178 | | tms.vMem = auto_alloc_array_clear(machine, UINT8, intf->vram); |
| 122 | WRITE8_MEMBER( tms9928a_device::vram_write ) |
| 123 | { |
| 124 | m_vMem[ m_Addr ] = data; |
| 125 | m_Addr = (m_Addr + 1) & (m_vram_size - 1); |
| 126 | m_ReadAhead = data; |
| 127 | m_latch = 0; |
| 128 | } |
| 179 | 129 | |
| 180 | | /* Sprite back buffer */ |
| 181 | | tms.dBackMem = auto_alloc_array(machine, UINT8, IMAGE_SIZE); |
| 182 | 130 | |
| 183 | | /* back bitmap */ |
| 184 | | tms.tmpbmp = auto_bitmap_alloc (machine, 256, 192, machine.primary_screen->format()); |
| 131 | READ8_MEMBER( tms9928a_device::register_read ) |
| 132 | { |
| 133 | UINT8 data = m_StatusReg; |
| 185 | 134 | |
| 186 | | TMS9928A_reset (); |
| 187 | | tms.LimitSprites = 1; |
| 135 | m_StatusReg = m_FifthSprite; |
| 136 | if (m_INT) { |
| 137 | m_INT = 0; |
| 138 | if ( !m_irq_changed.isnull() ) |
| 139 | m_irq_changed( m_INT ); |
| 140 | } |
| 141 | m_latch = 0; |
| 188 | 142 | |
| 189 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[0]); |
| 190 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[1]); |
| 191 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[2]); |
| 192 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[3]); |
| 193 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[4]); |
| 194 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[5]); |
| 195 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[6]); |
| 196 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Regs[7]); |
| 197 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.StatusReg); |
| 198 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.FifthSprite); |
| 199 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.ReadAhead); |
| 200 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.latch); |
| 201 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.Addr); |
| 202 | | state_save_register_item(machine, "tms9928a", NULL, 0, tms.INT); |
| 203 | | state_save_register_item_pointer(machine, "tms9928a", NULL, 0, tms.vMem, intf->vram); |
| 143 | return data; |
| 204 | 144 | } |
| 205 | 145 | |
| 206 | 146 | |
| 207 | | void TMS9928A_post_load (running_machine &machine) { |
| 208 | | int i; |
| 147 | void tms9928a_device::change_register(UINT8 reg, UINT8 val) { |
| 148 | static const UINT8 Mask[8] = |
| 149 | { 0x03, 0xfb, 0x0f, 0xff, 0x07, 0x7f, 0x07, 0xff }; |
| 150 | static const char *const modes[] = |
| 151 | { |
| 152 | "Mode 0 (GRAPHIC 1)", "Mode 1 (TEXT 1)", "Mode 2 (GRAPHIC 2)", |
| 153 | "Mode 1+2 (TEXT 1 variation)", "Mode 3 (MULTICOLOR)", |
| 154 | "Mode 1+3 (BOGUS)", "Mode 2+3 (MULTICOLOR variation)", |
| 155 | "Mode 1+2+3 (BOGUS)" |
| 156 | }; |
| 157 | UINT8 b; |
| 209 | 158 | |
| 210 | | /* all registers need to be re-written, so tables are recalculated */ |
| 211 | | for (i=0;i<8;i++) |
| 212 | | change_register (machine, i, tms.Regs[i]); |
| 159 | val &= Mask[reg]; |
| 160 | m_Regs[reg] = val; |
| 213 | 161 | |
| 214 | | /* make sure the interrupt request is set properly */ |
| 215 | | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); |
| 216 | | } |
| 162 | logerror("TMS9928A('%s'): Reg %d = %02xh\n", tag(), reg, (int)val); |
| 217 | 163 | |
| 218 | | |
| 219 | | /* |
| 220 | | ** The I/O functions. |
| 221 | | */ |
| 222 | | READ8_HANDLER (TMS9928A_vram_r) { |
| 223 | | UINT8 ret = tms.ReadAhead; |
| 224 | | tms.ReadAhead = tms.vMem[tms.Addr]; |
| 225 | | tms.Addr = (tms.Addr + 1) & (tms.vramsize - 1); |
| 226 | | tms.latch = 0; |
| 227 | | return ret; |
| 164 | switch (reg) |
| 165 | { |
| 166 | case 0: |
| 167 | /* re-calculate masks and pattern generator & colour */ |
| 168 | if (val & 2) |
| 169 | { |
| 170 | m_colour = ((m_Regs[3] & 0x80) * 64) & (m_vram_size - 1); |
| 171 | m_colourmask = (m_Regs[3] & 0x7f) * 8 | 7; |
| 172 | m_pattern = ((m_Regs[4] & 4) * 2048) & (m_vram_size - 1); |
| 173 | m_patternmask = ( (m_Regs[4] & 3) << 8 ) | (m_colourmask & 0xff); |
| 174 | } |
| 175 | else |
| 176 | { |
| 177 | m_colour = (m_Regs[3] * 64) & (m_vram_size - 1); |
| 178 | m_pattern = (m_Regs[4] * 2048) & (m_vram_size - 1); |
| 179 | } |
| 180 | m_mode = ( (m_reva ? (m_Regs[0] & 2) : 0) | ((m_Regs[1] & 0x10)>>4) | ((m_Regs[1] & 8)>>1)); |
| 181 | logerror("TMS9928A('%s'): %s\n", tag(), modes[m_mode]); |
| 182 | break; |
| 183 | case 1: |
| 184 | /* check for changes in the INT line */ |
| 185 | b = (val & 0x20) && (m_StatusReg & 0x80) ; |
| 186 | if (b != m_INT) |
| 187 | { |
| 188 | m_INT = b; |
| 189 | if ( !m_irq_changed.isnull() ) |
| 190 | m_irq_changed( m_INT ); |
| 191 | } |
| 192 | m_mode = ( (m_reva ? (m_Regs[0] & 2) : 0) | ((m_Regs[1] & 0x10)>>4) | ((m_Regs[1] & 8)>>1)); |
| 193 | logerror("TMS9928A('%s'): %s\n", tag(), modes[m_mode]); |
| 194 | break; |
| 195 | case 2: |
| 196 | m_nametbl = (val * 1024) & (m_vram_size - 1); |
| 197 | break; |
| 198 | case 3: |
| 199 | if (m_Regs[0] & 2) |
| 200 | { |
| 201 | m_colour = ((val & 0x80) * 64) & (m_vram_size - 1); |
| 202 | m_colourmask = ( (val & 0x7f) * 8 ) | 7; |
| 203 | } |
| 204 | else |
| 205 | { |
| 206 | m_colour = (val * 64) & (m_vram_size - 1); |
| 207 | } |
| 208 | m_patternmask = ( (m_Regs[4] & 3) * 256 ) | (m_colourmask & 255); |
| 209 | break; |
| 210 | case 4: |
| 211 | if (m_Regs[0] & 2) |
| 212 | { |
| 213 | m_pattern = ((val & 4) * 2048) & (m_vram_size - 1); |
| 214 | m_patternmask = ( (val & 3) * 256 ) | 255; |
| 215 | } |
| 216 | else |
| 217 | { |
| 218 | m_pattern = (val * 2048) & (m_vram_size - 1); |
| 219 | } |
| 220 | break; |
| 221 | case 5: |
| 222 | m_spriteattribute = (val * 128) & (m_vram_size - 1); |
| 223 | break; |
| 224 | case 6: |
| 225 | m_spritepattern = (val * 2048) & (m_vram_size - 1); |
| 226 | break; |
| 227 | case 7: |
| 228 | /* The backdrop is updated at TMS9928A_refresh() */ |
| 229 | break; |
| 230 | } |
| 228 | 231 | } |
| 229 | 232 | |
| 230 | | WRITE8_HANDLER (TMS9928A_vram_w) { |
| 231 | | tms.vMem[tms.Addr] = data; |
| 232 | | tms.Addr = (tms.Addr + 1) & (tms.vramsize - 1); |
| 233 | | tms.ReadAhead = data; |
| 234 | | tms.latch = 0; |
| 235 | | } |
| 236 | 233 | |
| 237 | | READ8_HANDLER (TMS9928A_register_r) { |
| 238 | | UINT8 ret = tms.StatusReg; |
| 239 | | tms.StatusReg = tms.FifthSprite; |
| 240 | | if (tms.INT) { |
| 241 | | tms.INT = 0; |
| 242 | | if (tms.INTCallback) tms.INTCallback (space->machine(), tms.INT); |
| 243 | | } |
| 244 | | tms.latch = 0; |
| 245 | | return ret; |
| 246 | | } |
| 247 | | |
| 248 | | WRITE8_HANDLER (TMS9928A_register_w) { |
| 249 | | int reg; |
| 250 | | |
| 251 | | if (tms.latch) { |
| 234 | WRITE8_MEMBER( tms9928a_device::register_write ) |
| 235 | { |
| 236 | if (m_latch) { |
| 252 | 237 | /* set high part of read/write address */ |
| 253 | | tms.Addr = ((UINT16)data << 8 | (tms.Addr & 0xff)) & (tms.vramsize - 1); |
| 238 | m_Addr = ((data << 8) | (m_Addr & 0xff)) & (m_vram_size - 1); |
| 254 | 239 | |
| 255 | 240 | if (data & 0x80) { |
| 256 | 241 | /* register write */ |
| 257 | | reg = data & 7; |
| 258 | | change_register (space->machine(), reg, tms.Addr & 0xff); |
| 242 | change_register (data & 7, m_Addr & 0xff); |
| 259 | 243 | } else { |
| 260 | 244 | if ( !(data & 0x40) ) { |
| 261 | 245 | /* read ahead */ |
| 262 | | TMS9928A_vram_r (space,0); |
| 246 | vram_read(space, 0); |
| 263 | 247 | } |
| 264 | 248 | } |
| 265 | | tms.latch = 0; |
| 249 | m_latch = 0; |
| 266 | 250 | } else { |
| 267 | 251 | /* set low part of read/write address */ |
| 268 | | tms.Addr = ((tms.Addr & 0xff00) | data) & (tms.vramsize - 1); |
| 269 | | tms.latch = 1; |
| 252 | m_Addr = ((m_Addr & 0xff00) | data) & (m_vram_size - 1); |
| 253 | m_latch = 1; |
| 270 | 254 | } |
| 271 | 255 | } |
| 272 | 256 | |
| 273 | | static void change_register (running_machine &machine, int reg, UINT8 val) { |
| 274 | | static const UINT8 Mask[8] = |
| 275 | | { 0x03, 0xfb, 0x0f, 0xff, 0x07, 0x7f, 0x07, 0xff }; |
| 276 | | static const char *const modes[] = { |
| 277 | | "Mode 0 (GRAPHIC 1)", "Mode 1 (TEXT 1)", "Mode 2 (GRAPHIC 2)", |
| 278 | | "Mode 1+2 (TEXT 1 variation)", "Mode 3 (MULTICOLOR)", |
| 279 | | "Mode 1+3 (BOGUS)", "Mode 2+3 (MULTICOLOR variation)", |
| 280 | | "Mode 1+2+3 (BOGUS)" |
| 281 | | }; |
| 282 | | UINT8 b; |
| 283 | 257 | |
| 284 | | val &= Mask[reg]; |
| 285 | | tms.Regs[reg] = val; |
| 258 | void tms9928a_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 259 | { |
| 260 | int vpos = m_screen->vpos(); |
| 261 | UINT16 BackColour = m_Regs[7] & 15; |
| 262 | UINT16 *p = BITMAP_ADDR16( m_tmpbmp, vpos, 0 ); |
| 286 | 263 | |
| 287 | | logerror("TMS9928A: Reg %d = %02xh\n", reg, (int)val); |
| 288 | | switch (reg) { |
| 289 | | case 0: |
| 290 | | /* re-calculate masks and pattern generator & colour */ |
| 291 | | if (val & 2) { |
| 292 | | tms.colour = ((tms.Regs[3] & 0x80) * 64) & (tms.vramsize - 1); |
| 293 | | tms.colourmask = (tms.Regs[3] & 0x7f) * 8 | 7; |
| 294 | | tms.pattern = ((tms.Regs[4] & 4) * 2048) & (tms.vramsize - 1); |
| 295 | | tms.patternmask = (tms.Regs[4] & 3) * 256 | |
| 296 | | (tms.colourmask & 255); |
| 297 | | } else { |
| 298 | | tms.colour = (tms.Regs[3] * 64) & (tms.vramsize - 1); |
| 299 | | tms.pattern = (tms.Regs[4] * 2048) & (tms.vramsize - 1); |
| 300 | | } |
| 301 | | logerror("TMS9928A: %s\n", modes[TMS_MODE]); |
| 302 | | break; |
| 303 | | case 1: |
| 304 | | /* check for changes in the INT line */ |
| 305 | | b = (val & 0x20) && (tms.StatusReg & 0x80) ; |
| 306 | | if (b != tms.INT) { |
| 307 | | tms.INT = b; |
| 308 | | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); |
| 309 | | } |
| 310 | | logerror("TMS9928A: %s\n", modes[TMS_MODE]); |
| 311 | | break; |
| 312 | | case 2: |
| 313 | | tms.nametbl = (val * 1024) & (tms.vramsize - 1); |
| 314 | | break; |
| 315 | | case 3: |
| 316 | | if (tms.Regs[0] & 2) { |
| 317 | | tms.colour = ((val & 0x80) * 64) & (tms.vramsize - 1); |
| 318 | | tms.colourmask = (val & 0x7f) * 8 | 7; |
| 319 | | } else { |
| 320 | | tms.colour = (val * 64) & (tms.vramsize - 1); |
| 321 | | } |
| 322 | | tms.patternmask = (tms.Regs[4] & 3) * 256 | (tms.colourmask & 255); |
| 323 | | break; |
| 324 | | case 4: |
| 325 | | if (tms.Regs[0] & 2) { |
| 326 | | tms.pattern = ((val & 4) * 2048) & (tms.vramsize - 1); |
| 327 | | tms.patternmask = (val & 3) * 256 | 255; |
| 328 | | } else { |
| 329 | | tms.pattern = (val * 2048) & (tms.vramsize - 1); |
| 330 | | } |
| 331 | | break; |
| 332 | | case 5: |
| 333 | | tms.spriteattribute = (val * 128) & (tms.vramsize - 1); |
| 334 | | break; |
| 335 | | case 6: |
| 336 | | tms.spritepattern = (val * 2048) & (tms.vramsize - 1); |
| 337 | | break; |
| 338 | | case 7: |
| 339 | | /* The backdrop is updated at TMS9928A_refresh() */ |
| 340 | | break; |
| 341 | | } |
| 342 | | } |
| 264 | if (!BackColour) |
| 265 | BackColour=1; |
| 343 | 266 | |
| 344 | | /* |
| 345 | | ** Interface functions |
| 346 | | */ |
| 267 | if ( vpos == 0 ) |
| 268 | { |
| 269 | rgb_t oldcolor = palette_get_color(machine(), 0); |
| 347 | 270 | |
| 348 | | void TMS9928A_set_spriteslimit (int limit) { |
| 349 | | tms.LimitSprites = limit; |
| 350 | | } |
| 271 | /* note we preserve the alpha here; this is so that it can be controlled independently */ |
| 272 | /* see cliffhgr.c for an example */ |
| 273 | palette_set_color(machine(), 0, (tms9928a_palette[BackColour] & MAKE_ARGB(0,255,255,255)) | (oldcolor & MAKE_ARGB(255,0,0,0))); |
| 274 | } |
| 351 | 275 | |
| 352 | | /* |
| 353 | | ** Updates the screen (the dMem memory area). |
| 354 | | */ |
| 355 | | SCREEN_UPDATE( tms9928a ) |
| 356 | | { |
| 357 | | INT32 BackColour = tms.Regs[7] & 15; |
| 358 | | rgb_t oldcolor = palette_get_color(screen->machine(), 0); |
| 276 | int y = vpos - m_top_border; |
| 359 | 277 | |
| 360 | | if (!BackColour) BackColour=1; |
| 361 | | /* note we preserve the alpha here; this is so that it can be controlled independently */ |
| 362 | | /* see cliffhgr.c for an example */ |
| 363 | | palette_set_color(screen->machine(), 0, (TMS9928A_palette[BackColour] & MAKE_ARGB(0,255,255,255)) | (oldcolor & MAKE_ARGB(255,0,0,0))); |
| 278 | if ( y < 0 || y >= 192 || ! (m_Regs[1] & 0x40) ) |
| 279 | { |
| 280 | /* Draw backdrop colour */ |
| 281 | for ( int i = 0; i < TMS9928A_TOTAL_HORZ; i++ ) |
| 282 | p[i] = BackColour; |
| 364 | 283 | |
| 365 | | if (! (tms.Regs[1] & 0x40)) |
| 366 | | bitmap_fill(bitmap, cliprect, screen->machine().pens[BackColour]); |
| 284 | /* Check for end of active display */ |
| 285 | if ( y == 192 ) |
| 286 | { |
| 287 | UINT8 b; |
| 288 | |
| 289 | m_StatusReg |= 0x80; |
| 290 | b = (m_Regs[1] & 0x20) != 0; |
| 291 | if (b != m_INT) { |
| 292 | m_INT = b; |
| 293 | if ( !m_irq_changed.isnull() ) |
| 294 | m_irq_changed( m_INT ); |
| 295 | } |
| 296 | } |
| 297 | } |
| 367 | 298 | else |
| 368 | 299 | { |
| 369 | | (*ModeHandlers[TMS_MODE])(screen, tms.tmpbmp, cliprect); |
| 300 | /* Draw regular line */ |
| 370 | 301 | |
| 371 | | copybitmap(bitmap, tms.tmpbmp, 0, 0, LEFT_BORDER, TOP_BORDER, cliprect); |
| 302 | /* Left border */ |
| 303 | for ( int i = 0; i < TMS9928A_HORZ_DISPLAY_START; i++ ) |
| 304 | p[i] = BackColour; |
| 305 | |
| 306 | /* Active display */ |
| 307 | |
| 308 | switch( m_mode ) |
| 372 | 309 | { |
| 373 | | rectangle rt; |
| 310 | case 0: /* MODE 0 */ |
| 311 | // if (vpos==100 ) popmessage("TMS9928A MODE 0"); |
| 312 | { |
| 313 | UINT16 addr = m_nametbl + ( ( y & 0xF8 ) << 2 ); |
| 374 | 314 | |
| 375 | | /* set borders */ |
| 376 | | rt.min_x = 0; rt.max_x = LEFT_BORDER+256+RIGHT_BORDER-1; |
| 377 | | rt.min_y = 0; rt.max_y = TOP_BORDER-1; |
| 378 | | bitmap_fill (bitmap, &rt, BackColour); |
| 379 | | rt.min_y = TOP_BORDER+192; rt.max_y = TOP_BORDER+192+BOTTOM_BORDER-1; |
| 380 | | bitmap_fill (bitmap, &rt, BackColour); |
| 315 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ ) |
| 316 | { |
| 317 | UINT8 charcode = m_vMem[ addr ]; |
| 318 | UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ]; |
| 319 | UINT8 colour = m_vMem[ m_colour + ( charcode >> 3 ) ]; |
| 320 | UINT16 fg = colour >> 4; |
| 321 | UINT16 bg = colour & 15; |
| 381 | 322 | |
| 382 | | rt.min_y = TOP_BORDER; rt.max_y = TOP_BORDER+192-1; |
| 383 | | rt.min_x = 0; rt.max_x = LEFT_BORDER-1; |
| 384 | | bitmap_fill (bitmap, &rt, BackColour); |
| 385 | | rt.min_x = LEFT_BORDER+256; rt.max_x = LEFT_BORDER+256+RIGHT_BORDER-1; |
| 386 | | bitmap_fill (bitmap, &rt, BackColour); |
| 387 | | } |
| 388 | | draw_sprites(screen, bitmap, cliprect); |
| 389 | | } |
| 323 | for ( int i = 0; i < 8; pattern <<= 1, i++ ) |
| 324 | p[x+i] = ( pattern & 0x80 ) ? fg : bg; |
| 325 | } |
| 326 | } |
| 327 | break; |
| 390 | 328 | |
| 391 | | return 0; |
| 392 | | } |
| 329 | case 1: /* MODE 1 */ |
| 330 | //if (vpos==100 ) popmessage("TMS9928A MODE 1"); |
| 331 | { |
| 332 | UINT16 addr = m_nametbl + ( ( y >> 3 ) * 40 ); |
| 333 | UINT16 fg = m_Regs[7] >> 4; |
| 334 | UINT16 bg = m_Regs[7] & 15; |
| 393 | 335 | |
| 394 | | int TMS9928A_interrupt(running_machine &machine) { |
| 395 | | int b; |
| 336 | /* Extra 8 pixels left border */ |
| 337 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 8; x++ ) |
| 338 | p[x] = bg; |
| 396 | 339 | |
| 397 | | /* when skipping frames, calculate sprite collision */ |
| 398 | | if (machine.video().skip_this_frame()) { |
| 399 | | draw_sprites (machine.primary_screen, NULL, NULL); |
| 400 | | } |
| 340 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 8; x < TMS9928A_HORZ_DISPLAY_START + 248; x+= 6, addr++ ) |
| 341 | { |
| 342 | UINT16 charcode = m_vMem[ addr ]; |
| 343 | UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ]; |
| 401 | 344 | |
| 402 | | tms.StatusReg |= 0x80; |
| 403 | | b = (tms.Regs[1] & 0x20) != 0; |
| 404 | | if (b != tms.INT) { |
| 405 | | tms.INT = b; |
| 406 | | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); |
| 407 | | } |
| 345 | for ( int i = 0; i < 6; pattern <<= 1, i++ ) |
| 346 | p[x+i] = ( pattern & 0x80 ) ? fg : bg; |
| 347 | } |
| 408 | 348 | |
| 409 | | return b; |
| 410 | | } |
| 349 | /* Extra 8 pixels right border */ |
| 350 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 248; x < TMS9928A_HORZ_DISPLAY_START + 256; x++ ) |
| 351 | p[x] = bg; |
| 352 | } |
| 353 | break; |
| 411 | 354 | |
| 412 | | static void draw_mode1 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 413 | | int pattern,x,y,yy,xx,name,charcode; |
| 414 | | UINT8 fg,bg,*patternptr; |
| 415 | | rectangle rt; |
| 416 | | const pen_t *pens; |
| 355 | case 2: /* MODE 2 */ |
| 356 | //if (vpos==100 ) popmessage("TMS9928A MODE 2"); |
| 357 | { |
| 358 | UINT16 addr = m_nametbl + ( ( y >> 3 ) * 32 ); |
| 417 | 359 | |
| 418 | | pens = screen->machine().pens; |
| 419 | | fg = pens[tms.Regs[7] / 16]; |
| 420 | | bg = pens[tms.Regs[7] & 15]; |
| 360 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ ) |
| 361 | { |
| 362 | UINT16 charcode = m_vMem[ addr ] + ( ( y >> 6 ) << 8 ); |
| 363 | UINT8 pattern = m_vMem[ m_pattern + ( ( charcode & m_patternmask ) << 3 ) + ( y & 7 ) ]; |
| 364 | UINT8 colour = m_vMem[ m_colour + ( ( charcode & m_colourmask ) << 3 ) + ( y & 7 ) ]; |
| 365 | UINT16 fg = colour >> 4; |
| 366 | UINT16 bg = colour & 15; |
| 421 | 367 | |
| 422 | | /* colours at sides must be reset */ |
| 423 | | rt.min_y = 0; rt.max_y = 191; |
| 424 | | rt.min_x = 0; rt.max_x = 7; |
| 425 | | bitmap_fill (bitmap, &rt, bg); |
| 426 | | rt.min_y = 0; rt.max_y = 191; |
| 427 | | rt.min_x = 248; rt.max_x = 255; |
| 428 | | bitmap_fill (bitmap, &rt, bg); |
| 368 | for ( int i = 0; i < 8; pattern <<= 1, i++ ) |
| 369 | p[x+i] = ( pattern & 0x80 ) ? fg : bg; |
| 370 | } |
| 371 | } |
| 372 | break; |
| 429 | 373 | |
| 430 | | name = 0; |
| 431 | | for (y=0;y<24;y++) { |
| 432 | | for (x=0;x<40;x++) { |
| 433 | | charcode = tms.vMem[tms.nametbl+name]; |
| 434 | | name++; |
| 435 | | patternptr = tms.vMem + tms.pattern + (charcode*8); |
| 436 | | for (yy=0;yy<8;yy++) { |
| 437 | | pattern = *patternptr++; |
| 438 | | for (xx=0;xx<6;xx++) { |
| 439 | | *BITMAP_ADDR16(bitmap, y*8+yy, 8+x*6+xx) = (pattern & 0x80) ? fg : bg; |
| 440 | | pattern *= 2; |
| 441 | | } |
| 442 | | } |
| 443 | | } |
| 444 | | } |
| 445 | | } |
| 374 | case 3: /* MODE 1+2 */ |
| 375 | //if (vpos==100) popmessage("TMS9928A MODE1+2"); |
| 376 | { |
| 377 | UINT16 addr = m_nametbl + ( ( y >> 3 ) * 40 ); |
| 378 | UINT16 fg = m_Regs[7] >> 4; |
| 379 | UINT16 bg = m_Regs[7] & 15; |
| 446 | 380 | |
| 447 | | static void draw_mode12 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 448 | | int pattern,x,y,yy,xx,name,charcode; |
| 449 | | UINT8 fg,bg,*patternptr; |
| 450 | | const pen_t *pens; |
| 451 | | rectangle rt; |
| 381 | /* Extra 8 pixels left border */ |
| 382 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 8; x++ ) |
| 383 | p[x] = bg; |
| 452 | 384 | |
| 453 | | pens = screen->machine().pens; |
| 454 | | fg = pens[tms.Regs[7] / 16]; |
| 455 | | bg = pens[tms.Regs[7] & 15]; |
| 385 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 8; x < TMS9928A_HORZ_DISPLAY_START + 248; x+= 6, addr++ ) |
| 386 | { |
| 387 | UINT16 charcode = ( m_vMem[ addr ] + ( ( y >> 6 ) << 8 ) ) & m_patternmask; |
| 388 | UINT8 pattern = m_vMem[ m_pattern + ( charcode << 3 ) + ( y & 7 ) ]; |
| 456 | 389 | |
| 457 | | /* colours at sides must be reset */ |
| 458 | | rt.min_y = 0; rt.max_y = 191; |
| 459 | | rt.min_x = 0; rt.max_x = 7; |
| 460 | | bitmap_fill (bitmap, &rt, bg); |
| 461 | | rt.min_y = 0; rt.max_y = 191; |
| 462 | | rt.min_x = 248; rt.max_x = 255; |
| 463 | | bitmap_fill (bitmap, &rt, bg); |
| 390 | for ( int i = 0; i < 6; pattern <<= 1, i++ ) |
| 391 | p[x+i] = ( pattern & 0x80 ) ? fg : bg; |
| 392 | } |
| 464 | 393 | |
| 465 | | name = 0; |
| 466 | | for (y=0;y<24;y++) { |
| 467 | | for (x=0;x<40;x++) { |
| 468 | | charcode = (tms.vMem[tms.nametbl+name]+(y/8)*256)&tms.patternmask; |
| 469 | | name++; |
| 470 | | patternptr = tms.vMem + tms.pattern + (charcode*8); |
| 471 | | for (yy=0;yy<8;yy++) { |
| 472 | | pattern = *patternptr++; |
| 473 | | for (xx=0;xx<6;xx++) { |
| 474 | | *BITMAP_ADDR16(bitmap, y*8+yy, 8+x*6+xx) = (pattern & 0x80) ? fg : bg; |
| 475 | | pattern *= 2; |
| 476 | | } |
| 477 | | } |
| 478 | | } |
| 479 | | } |
| 480 | | } |
| 394 | /* Extra 8 pixels right border */ |
| 395 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 248; x < TMS9928A_HORZ_DISPLAY_START + 256; x++ ) |
| 396 | p[x] = bg; |
| 397 | } |
| 398 | break; |
| 481 | 399 | |
| 482 | | static void draw_mode0 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 483 | | int pattern,x,y,yy,xx,name,charcode,colour; |
| 484 | | UINT8 fg,bg,*patternptr; |
| 485 | | const pen_t *pens; |
| 400 | case 4: /* MODE 3 */ |
| 401 | //if (vpos==100 ) popmessage("TMS9928A MODE 3"); |
| 402 | { |
| 403 | UINT16 addr = m_nametbl + ( ( y >> 3 ) * 32 ); |
| 486 | 404 | |
| 487 | | pens = screen->machine().pens; |
| 488 | | name = 0; |
| 489 | | for (y=0;y<24;y++) { |
| 490 | | for (x=0;x<32;x++) { |
| 491 | | charcode = tms.vMem[tms.nametbl+name]; |
| 492 | | name++; |
| 493 | | patternptr = tms.vMem + tms.pattern + charcode*8; |
| 494 | | colour = tms.vMem[tms.colour+charcode/8]; |
| 495 | | fg = pens[colour / 16]; |
| 496 | | bg = pens[colour & 15]; |
| 497 | | for (yy=0;yy<8;yy++) { |
| 498 | | pattern=*patternptr++; |
| 499 | | for (xx=0;xx<8;xx++) { |
| 500 | | *BITMAP_ADDR16(bitmap, y*8+yy, x*8+xx) = (pattern & 0x80) ? fg : bg; |
| 501 | | pattern *= 2; |
| 502 | | } |
| 503 | | } |
| 504 | | } |
| 505 | | } |
| 506 | | } |
| 405 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ ) |
| 406 | { |
| 407 | UINT8 charcode = m_vMem[ addr ]; |
| 408 | UINT8 colour = m_vMem[ m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) ]; |
| 409 | UINT16 fg = colour >> 4; |
| 410 | UINT16 bg = colour & 15; |
| 507 | 411 | |
| 508 | | static void draw_mode2 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 509 | | int colour,name,x,y,yy,pattern,xx,charcode; |
| 510 | | UINT8 fg,bg; |
| 511 | | const pen_t *pens; |
| 512 | | UINT8 *colourptr,*patternptr; |
| 412 | p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg; |
| 413 | p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg; |
| 414 | } |
| 415 | } |
| 416 | break; |
| 513 | 417 | |
| 514 | | pens = screen->machine().pens; |
| 515 | | name = 0; |
| 516 | | for (y=0;y<24;y++) { |
| 517 | | for (x=0;x<32;x++) { |
| 518 | | charcode = tms.vMem[tms.nametbl+name]+(y/8)*256; |
| 519 | | name++; |
| 520 | | colour = (charcode&tms.colourmask); |
| 521 | | pattern = (charcode&tms.patternmask); |
| 522 | | patternptr = tms.vMem+tms.pattern+colour*8; |
| 523 | | colourptr = tms.vMem+tms.colour+pattern*8; |
| 524 | | for (yy=0;yy<8;yy++) { |
| 525 | | pattern = *patternptr++; |
| 526 | | colour = *colourptr++; |
| 527 | | fg = pens[colour / 16]; |
| 528 | | bg = pens[colour & 15]; |
| 529 | | for (xx=0;xx<8;xx++) { |
| 530 | | *BITMAP_ADDR16(bitmap, y*8+yy, x*8+xx) = (pattern & 0x80) ? fg : bg; |
| 531 | | pattern *= 2; |
| 532 | | } |
| 533 | | } |
| 534 | | } |
| 535 | | } |
| 536 | | } |
| 418 | case 5: case 7: /* MODE bogus */ |
| 419 | //if (vpos==100 ) popmessage("TMS9928A MODE bogus"); |
| 420 | { |
| 421 | UINT16 fg = m_Regs[7] >> 4; |
| 422 | UINT16 bg = m_Regs[7] & 15; |
| 537 | 423 | |
| 538 | | static void draw_mode3 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 539 | | int x,y,yy,yyy,name,charcode; |
| 540 | | UINT8 fg,bg,*patternptr; |
| 541 | | const pen_t *pens; |
| 424 | /* Extra 8 pixels left border */ |
| 425 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 8; x++ ) |
| 426 | p[x] = bg; |
| 542 | 427 | |
| 543 | | pens = screen->machine().pens; |
| 544 | | name = 0; |
| 545 | | for (y=0;y<24;y++) { |
| 546 | | for (x=0;x<32;x++) { |
| 547 | | charcode = tms.vMem[tms.nametbl+name]; |
| 548 | | name++; |
| 549 | | patternptr = tms.vMem+tms.pattern+charcode*8+(y&3)*2; |
| 550 | | for (yy=0;yy<2;yy++) { |
| 551 | | fg = pens[(*patternptr / 16)]; |
| 552 | | bg = pens[((*patternptr++) & 15)]; |
| 553 | | for (yyy=0;yyy<4;yyy++) { |
| 554 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+0) = fg; |
| 555 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+1) = fg; |
| 556 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+2) = fg; |
| 557 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+3) = fg; |
| 558 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+4) = bg; |
| 559 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+5) = bg; |
| 560 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+6) = bg; |
| 561 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+7) = bg; |
| 562 | | } |
| 563 | | } |
| 564 | | } |
| 565 | | } |
| 566 | | } |
| 428 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 8; x < TMS9928A_HORZ_DISPLAY_START + 248; x+= 6 ) |
| 429 | { |
| 430 | p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg; |
| 431 | p[x+4] = p[x+5] = bg; |
| 432 | } |
| 567 | 433 | |
| 568 | | static void draw_mode23 (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 569 | | int x,y,yy,yyy,name,charcode; |
| 570 | | UINT8 fg,bg,*patternptr; |
| 571 | | const pen_t *pens; |
| 434 | /* Extra 8 pixels right border */ |
| 435 | for ( int x = TMS9928A_HORZ_DISPLAY_START + 248; x < TMS9928A_HORZ_DISPLAY_START + 256; x++ ) |
| 436 | p[x] = bg; |
| 437 | } |
| 438 | break; |
| 572 | 439 | |
| 573 | | pens = screen->machine().pens; |
| 574 | | name = 0; |
| 575 | | for (y=0;y<24;y++) { |
| 576 | | for (x=0;x<32;x++) { |
| 577 | | charcode = tms.vMem[tms.nametbl+name]; |
| 578 | | name++; |
| 579 | | patternptr = tms.vMem + tms.pattern + |
| 580 | | ((charcode+(y&3)*2+(y/8)*256)&tms.patternmask)*8; |
| 581 | | for (yy=0;yy<2;yy++) { |
| 582 | | fg = pens[(*patternptr / 16)]; |
| 583 | | bg = pens[((*patternptr++) & 15)]; |
| 584 | | for (yyy=0;yyy<4;yyy++) { |
| 585 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+0) = fg; |
| 586 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+1) = fg; |
| 587 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+2) = fg; |
| 588 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+3) = fg; |
| 589 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+4) = bg; |
| 590 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+5) = bg; |
| 591 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+6) = bg; |
| 592 | | *BITMAP_ADDR16(bitmap, y*8+yy*4+yyy, x*8+7) = bg; |
| 593 | | } |
| 594 | | } |
| 595 | | } |
| 596 | | } |
| 597 | | } |
| 440 | case 6: /* MODE 2+3 */ |
| 441 | //if (vpos==100 ) popmessage("TMS9928A MODE 2+3"); |
| 442 | { |
| 443 | UINT16 addr = m_nametbl + ( ( y >> 3 ) * 32 ); |
| 598 | 444 | |
| 599 | | static void draw_modebogus (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 600 | | UINT8 fg,bg; |
| 601 | | int x,y,n,xx; |
| 602 | | const pen_t *pens; |
| 445 | for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 256; x+= 8, addr++ ) |
| 446 | { |
| 447 | UINT8 charcode = m_vMem[ addr ]; |
| 448 | UINT8 colour = m_vMem[ m_pattern + ( ( ( charcode + ( ( y >> 2 ) & 7 ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask ) << 3 ) ]; |
| 449 | UINT16 fg = colour >> 4; |
| 450 | UINT16 bg = colour & 15; |
| 603 | 451 | |
| 604 | | pens = screen->machine().pens; |
| 605 | | fg = pens[tms.Regs[7] / 16]; |
| 606 | | bg = pens[tms.Regs[7] & 15]; |
| 452 | p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg; |
| 453 | p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg; |
| 454 | } |
| 455 | } |
| 456 | break; |
| 457 | } |
| 607 | 458 | |
| 608 | | for (y=0;y<192;y++) { |
| 609 | | xx=0; |
| 610 | | n=8; while (n--) *BITMAP_ADDR16(bitmap, y, xx++) = bg; |
| 611 | | for (x=0;x<40;x++) { |
| 612 | | n=4; while (n--) *BITMAP_ADDR16(bitmap, y, xx++) = fg; |
| 613 | | n=2; while (n--) *BITMAP_ADDR16(bitmap, y, xx++) = bg; |
| 614 | | } |
| 615 | | n=8; while (n--) *BITMAP_ADDR16(bitmap, y, xx++) = bg; |
| 616 | | } |
| 617 | | } |
| 459 | /* Draw sprites */ |
| 460 | if ( ( m_Regs[1] & 0x50 ) != 0x40 ) |
| 461 | { |
| 462 | /* sprites are disabled */ |
| 463 | m_FifthSprite = 31; |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | UINT8 sprite_size = ( m_Regs[1] & 0x02 ) ? 16 : 8; |
| 468 | UINT8 sprite_mag = m_Regs[1] & 0x01; |
| 469 | UINT8 sprite_height = sprite_size * ( sprite_mag + 1 ); |
| 470 | UINT8 spr_drawn[32+256+32] = { 0 }; |
| 471 | UINT8 num_sprites = 0; |
| 618 | 472 | |
| 619 | | /* |
| 620 | | ** This function renders the sprites. Sprite collision is calculated in |
| 621 | | ** in a back buffer (tms.dBackMem), because sprite collision detection |
| 622 | | ** is rather complicated (transparent sprites also cause the sprite |
| 623 | | ** collision bit to be set, and ``illegal'' sprites do not count |
| 624 | | ** (they're not displayed)). |
| 625 | | ** |
| 626 | | ** This code should be optimized. One day. |
| 627 | | */ |
| 628 | | static void draw_sprites (device_t *screen, bitmap_t *bitmap, const rectangle *cliprect) { |
| 629 | | UINT8 *attributeptr,*patternptr,c; |
| 630 | | int p,x,y,size,i,j,large,yy,xx,limit[192], |
| 631 | | illegalsprite,illegalspriteline; |
| 632 | | UINT16 line,line2; |
| 633 | | const pen_t *pens; |
| 473 | for ( UINT16 sprattr = 0; sprattr < 128; sprattr += 4 ) |
| 474 | { |
| 475 | int spr_y = m_vMem[ m_spriteattribute + sprattr + 0 ]; |
| 634 | 476 | |
| 635 | | if ((tms.Regs[1] & 0x50) != 0x40) { |
| 636 | | /* sprites are disabled */ |
| 637 | | tms.FifthSprite = 31; |
| 638 | | return; |
| 639 | | } |
| 477 | /* Stop processing sprites */ |
| 478 | if ( spr_y == 208 ) |
| 479 | break; |
| 640 | 480 | |
| 641 | | pens = screen->machine().pens; |
| 642 | | attributeptr = tms.vMem + tms.spriteattribute; |
| 643 | | size = (tms.Regs[1] & 2) ? 16 : 8; |
| 644 | | large = (int)(tms.Regs[1] & 1); |
| 481 | if ( spr_y > 0xE0 ) |
| 482 | spr_y -= 256; |
| 645 | 483 | |
| 646 | | for (x=0;x<192;x++) limit[x] = 4; |
| 647 | | tms.StatusReg &= ~0x20; /* reset collision */ |
| 648 | | illegalspriteline = 255; |
| 649 | | illegalsprite = 0; |
| 484 | /* vert pos 255 is displayed on the first line of the screen */ |
| 485 | spr_y++; |
| 650 | 486 | |
| 651 | | memset (tms.dBackMem, 0, IMAGE_SIZE); |
| 652 | | for (p=0;p<32;p++) { |
| 653 | | y = *attributeptr++; |
| 654 | | if (y == 208) break; |
| 655 | | if (y > 208) { |
| 656 | | y=-(~y&255); |
| 657 | | } else { |
| 658 | | y++; |
| 659 | | } |
| 660 | | x = *attributeptr++; |
| 661 | | patternptr = tms.vMem + tms.spritepattern + |
| 662 | | ((size == 16) ? *attributeptr & 0xfc : *attributeptr) * 8; |
| 663 | | attributeptr++; |
| 664 | | c = (*attributeptr & 0x0f); |
| 665 | | if (*attributeptr & 0x80) x -= 32; |
| 666 | | attributeptr++; |
| 487 | /* is sprite enabled on this line? */ |
| 488 | if ( spr_y <= y && y < spr_y + sprite_height ) |
| 489 | { |
| 490 | int spr_x = m_vMem[ m_spriteattribute + sprattr + 1 ]; |
| 491 | UINT8 sprcode = m_vMem[ m_spriteattribute + sprattr + 2 ]; |
| 492 | UINT8 sprcol = m_vMem[ m_spriteattribute + sprattr + 3 ]; |
| 493 | UINT16 pataddr = m_spritepattern + ( ( sprite_size == 16 ) ? sprcode & ~0x03 : sprcode ) * 8; |
| 667 | 494 | |
| 668 | | if (!large) { |
| 669 | | /* draw sprite (not enlarged) */ |
| 670 | | for (yy=y;yy<(y+size);yy++) { |
| 671 | | if ( (yy < 0) || (yy > 191) ) continue; |
| 672 | | if (limit[yy] == 0) { |
| 673 | | /* illegal sprite line */ |
| 674 | | if (yy < illegalspriteline) { |
| 675 | | illegalspriteline = yy; |
| 676 | | illegalsprite = p; |
| 677 | | } else if (illegalspriteline == yy) { |
| 678 | | if (illegalsprite > p) { |
| 679 | | illegalsprite = p; |
| 680 | | } |
| 681 | | } |
| 682 | | if (tms.LimitSprites) continue; |
| 683 | | } else limit[yy]--; |
| 684 | | line = 256*patternptr[yy-y] + patternptr[yy-y+16]; |
| 685 | | for (xx=x;xx<(x+size);xx++) { |
| 686 | | if (line & 0x8000) { |
| 687 | | if ((xx >= 0) && (xx < 256)) { |
| 688 | | if (tms.dBackMem[yy*256+xx]) { |
| 689 | | tms.StatusReg |= 0x20; |
| 690 | | } else { |
| 691 | | tms.dBackMem[yy*256+xx] = 0x01; |
| 692 | | } |
| 693 | | if (c && ! (tms.dBackMem[yy*256+xx] & 0x02)) |
| 694 | | { |
| 695 | | tms.dBackMem[yy*256+xx] |= 0x02; |
| 696 | | if (bitmap) |
| 697 | | *BITMAP_ADDR16(bitmap, TOP_BORDER+yy, LEFT_BORDER+xx) = pens[c]; |
| 698 | | } |
| 699 | | } |
| 700 | | } |
| 701 | | line *= 2; |
| 702 | | } |
| 703 | | } |
| 704 | | } else { |
| 705 | | /* draw enlarged sprite */ |
| 706 | | for (i=0;i<size;i++) { |
| 707 | | yy=y+i*2; |
| 708 | | line2 = 256*patternptr[i] + patternptr[i+16]; |
| 709 | | for (j=0;j<2;j++) { |
| 710 | | if ( (yy >= 0) && (yy <= 191) ) { |
| 711 | | if (limit[yy] == 0) { |
| 712 | | /* illegal sprite line */ |
| 713 | | if (yy < illegalspriteline) { |
| 714 | | illegalspriteline = yy; |
| 715 | | illegalsprite = p; |
| 716 | | } else if (illegalspriteline == yy) { |
| 717 | | if (illegalsprite > p) { |
| 718 | | illegalsprite = p; |
| 719 | | } |
| 720 | | } |
| 721 | | if (tms.LimitSprites) continue; |
| 722 | | } else limit[yy]--; |
| 723 | | line = line2; |
| 724 | | for (xx=x;xx<(x+size*2);xx+=2) { |
| 725 | | if (line & 0x8000) { |
| 726 | | if ((xx >=0) && (xx < 256)) { |
| 727 | | if (tms.dBackMem[yy*256+xx]) { |
| 728 | | tms.StatusReg |= 0x20; |
| 729 | | } else { |
| 730 | | tms.dBackMem[yy*256+xx] = 0x01; |
| 731 | | } |
| 732 | | if (c && ! (tms.dBackMem[yy*256+xx] & 0x02)) |
| 733 | | { |
| 734 | | tms.dBackMem[yy*256+xx] |= 0x02; |
| 735 | | if (bitmap) |
| 736 | | *BITMAP_ADDR16(bitmap, TOP_BORDER+yy, LEFT_BORDER+xx) = pens[c]; |
| 737 | | } |
| 738 | | } |
| 739 | | if (((xx+1) >=0) && ((xx+1) < 256)) { |
| 740 | | if (tms.dBackMem[yy*256+xx+1]) { |
| 741 | | tms.StatusReg |= 0x20; |
| 742 | | } else { |
| 743 | | tms.dBackMem[yy*256+xx+1] = 0x01; |
| 744 | | } |
| 745 | | if (c && ! (tms.dBackMem[yy*256+xx+1] & 0x02)) |
| 746 | | { |
| 747 | | tms.dBackMem[yy*256+xx+1] |= 0x02; |
| 748 | | if (bitmap) |
| 749 | | *BITMAP_ADDR16(bitmap, TOP_BORDER+yy, LEFT_BORDER+xx+1) = pens[c]; |
| 750 | | } |
| 751 | | } |
| 752 | | } |
| 753 | | line *= 2; |
| 754 | | } |
| 755 | | } |
| 756 | | yy++; |
| 757 | | } |
| 758 | | } |
| 759 | | } |
| 760 | | } |
| 495 | num_sprites++; |
| 761 | 496 | |
| 762 | | /* The sprite number is only updated if the overflow bit is clear, |
| 763 | | ** and the overflow bit will only be set if bit 6 and 7 are both clear. */ |
| 764 | | if (illegalspriteline == 255) tms.FifthSprite = (p > 31) ? 31 : p; |
| 765 | | else tms.FifthSprite = illegalsprite; |
| 766 | | if (~tms.StatusReg & 0x40) { |
| 767 | | tms.StatusReg |= tms.FifthSprite; |
| 768 | | if (~tms.StatusReg & 0x80) tms.StatusReg |= 0x40; |
| 769 | | } |
| 770 | | } |
| 497 | /* Fifth sprite encountered? */ |
| 498 | if( num_sprites == 5 ) |
| 499 | { |
| 500 | m_FifthSprite = sprattr / 4; |
| 771 | 501 | |
| 772 | | static TMS9928a_interface sIntf; |
| 502 | if (~m_StatusReg & 0x40) |
| 503 | { |
| 504 | m_StatusReg |= m_FifthSprite; |
| 505 | if (~m_StatusReg & 0x80) m_StatusReg |= 0x40; |
| 506 | } |
| 507 | } |
| 773 | 508 | |
| 509 | if ( sprite_mag ) |
| 510 | pataddr += ( ( ( y - spr_y ) & 0x1F ) >> 1 ); |
| 511 | else |
| 512 | pataddr += ( ( y - spr_y ) & 0x0F ); |
| 774 | 513 | |
| 775 | | void TMS9928A_configure (const TMS9928a_interface *intf) |
| 514 | UINT8 pattern = m_vMem[ pataddr ]; |
| 515 | |
| 516 | if ( sprcol & 0x80 ) |
| 517 | spr_x -= 32; |
| 518 | |
| 519 | sprcol &= 0x0f; |
| 520 | |
| 521 | for ( int s = 0; s < sprite_size; s += 8 ) |
| 522 | { |
| 523 | for ( int i = 0; i < 8; pattern <<= 1, i++ ) |
| 524 | { |
| 525 | int colission_index = spr_x + ( sprite_mag ? i * 2 : i ) + 32; |
| 526 | |
| 527 | for ( int z = 0; z <= sprite_mag; colission_index++, z++ ) |
| 528 | { |
| 529 | /* Check for colission */ |
| 530 | if ( spr_drawn[ colission_index ] ) |
| 531 | m_StatusReg |= 0x20; |
| 532 | spr_drawn[ colission_index ] |= 0x01; |
| 533 | |
| 534 | /* Check if pixel should be drawn */ |
| 535 | if ( ( pattern & 0x80 ) && sprcol && num_sprites < 5 ) |
| 536 | { |
| 537 | if ( colission_index >= 32 && colission_index < 32 + 256 ) |
| 538 | { |
| 539 | /* Has another sprite already drawn here? */ |
| 540 | if ( ! ( spr_drawn[ colission_index ] & 0x02 ) ) |
| 541 | { |
| 542 | spr_drawn[ colission_index ] |= 0x02; |
| 543 | p[ TMS9928A_HORZ_DISPLAY_START + colission_index - 32 ] = sprcol; |
| 544 | } |
| 545 | } |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | |
| 550 | pattern = m_vMem[ pataddr + 16 ]; |
| 551 | spr_x += sprite_mag ? 16 : 8; |
| 552 | } |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | /* Right border */ |
| 558 | for ( int i = TMS9928A_HORZ_DISPLAY_START + 256; i < TMS9928A_TOTAL_HORZ; i++ ) |
| 559 | p[i] = BackColour; |
| 560 | } |
| 561 | |
| 562 | /* Schedule next callback */ |
| 563 | m_line_timer->adjust( m_screen->time_until_pos( ( vpos + 1 ) % m_screen->height() , 0 ) ); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | void tms9928a_device::update( bitmap_t *bitmap, const rectangle *cliprect ) |
| 776 | 568 | { |
| 777 | | sIntf = *intf; |
| 569 | copybitmap( bitmap, m_tmpbmp, 0, 0, 0, 0, cliprect ); |
| 778 | 570 | } |
| 779 | 571 | |
| 780 | 572 | |
| 781 | | VIDEO_START( tms9928a ) |
| 573 | void tms9928a_device::device_config_complete() |
| 782 | 574 | { |
| 783 | | assert(sIntf.model != TMS_INVALID_MODEL); |
| 784 | | TMS9928A_start(machine, &sIntf); |
| 575 | const tms9928a_interface *intf = reinterpret_cast<const tms9928a_interface *>(static_config()); |
| 576 | |
| 577 | if ( intf != NULL ) |
| 578 | { |
| 579 | *static_cast<tms9928a_interface *>(this) = *intf; |
| 580 | } |
| 581 | else |
| 582 | { |
| 583 | m_vram_size = 0; |
| 584 | memset(&m_out_int_line, 0, sizeof(m_out_int_line)); |
| 585 | } |
| 785 | 586 | } |
| 786 | 587 | |
| 787 | 588 | |
| 788 | | MACHINE_CONFIG_FRAGMENT( tms9928a ) |
| 589 | void tms9928a_device::device_start() |
| 590 | { |
| 591 | assert_always(((m_vram_size == 0x1000) || (m_vram_size == 0x2000) || (m_vram_size == 0x4000)), "4, 8 or 16 kB vram please"); |
| 789 | 592 | |
| 790 | | /* video hardware */ |
| 791 | | MCFG_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK) |
| 593 | m_screen = machine().device<screen_device>( m_screen_tag ); |
| 594 | assert( m_screen != NULL ); |
| 792 | 595 | |
| 793 | | MCFG_SCREEN_ADD("screen", RASTER) |
| 794 | | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 795 | | MCFG_SCREEN_SIZE(LEFT_BORDER+32*8+RIGHT_BORDER, TOP_BORDER_60HZ+24*8+BOTTOM_BORDER_60HZ) |
| 796 | | MCFG_SCREEN_VISIBLE_AREA(LEFT_BORDER-12, LEFT_BORDER+32*8+12-1, TOP_BORDER_60HZ-9, TOP_BORDER_60HZ+24*8+9-1) |
| 797 | | MCFG_SCREEN_UPDATE(tms9928a) |
| 596 | m_top_border = m_50hz ? TMS9928A_VERT_DISPLAY_START_PAL : TMS9928A_VERT_DISPLAY_START_NTSC; |
| 798 | 597 | |
| 799 | | MCFG_PALETTE_LENGTH(TMS9928A_PALETTE_SIZE) |
| 800 | | MCFG_PALETTE_INIT(tms9928a) |
| 598 | m_irq_changed.resolve( m_out_int_line, *this ); |
| 801 | 599 | |
| 802 | | MCFG_VIDEO_START(tms9928a) |
| 803 | | MACHINE_CONFIG_END |
| 600 | /* Video RAM */ |
| 601 | m_vMem = auto_alloc_array_clear(machine(), UINT8, m_vram_size); |
| 804 | 602 | |
| 603 | /* back bitmap */ |
| 604 | m_tmpbmp = auto_bitmap_alloc(machine(), TMS9928A_TOTAL_HORZ, TMS9928A_TOTAL_VERT_PAL, m_screen->format()); |
| 605 | |
| 606 | m_line_timer = timer_alloc(TIMER_LINE); |
| 607 | |
| 608 | m_LimitSprites = 1; |
| 609 | |
| 610 | save_item(NAME(m_Regs[0])); |
| 611 | save_item(NAME(m_Regs[1])); |
| 612 | save_item(NAME(m_Regs[2])); |
| 613 | save_item(NAME(m_Regs[3])); |
| 614 | save_item(NAME(m_Regs[4])); |
| 615 | save_item(NAME(m_Regs[5])); |
| 616 | save_item(NAME(m_Regs[6])); |
| 617 | save_item(NAME(m_Regs[7])); |
| 618 | save_item(NAME(m_StatusReg)); |
| 619 | save_item(NAME(m_FifthSprite)); |
| 620 | save_item(NAME(m_ReadAhead)); |
| 621 | save_item(NAME(m_latch)); |
| 622 | save_item(NAME(m_Addr)); |
| 623 | save_item(NAME(m_INT)); |
| 624 | save_pointer(NAME(m_vMem), m_vram_size); |
| 625 | save_item(NAME(m_colour)); |
| 626 | save_item(NAME(m_colourmask)); |
| 627 | save_item(NAME(m_pattern)); |
| 628 | save_item(NAME(m_patternmask)); |
| 629 | save_item(NAME(m_nametbl)); |
| 630 | save_item(NAME(m_spriteattribute)); |
| 631 | save_item(NAME(m_spritepattern)); |
| 632 | save_item(NAME(m_mode)); |
| 633 | } |
| 634 | |
| 635 | |
| 636 | void tms9928a_device::device_reset() |
| 637 | { |
| 638 | for ( int i = 0; i < 8; i++ ) |
| 639 | m_Regs[i] = 0; |
| 640 | |
| 641 | m_StatusReg = 0; |
| 642 | m_FifthSprite = 31; |
| 643 | m_nametbl = 0; |
| 644 | m_pattern = 0; |
| 645 | m_colour = 0; |
| 646 | m_spritepattern = 0; |
| 647 | m_spriteattribute = 0; |
| 648 | m_colourmask = 0; |
| 649 | m_patternmask = 0; |
| 650 | m_Addr = 0; |
| 651 | m_ReadAhead = 0; |
| 652 | m_INT = 0; |
| 653 | m_latch = 0; |
| 654 | m_mode = 0; |
| 655 | |
| 656 | m_line_timer->adjust( m_screen->time_until_pos( 0, 0 ) ); |
| 657 | } |
| 658 | |
src/emu/video/tms9928a.h
| r12394 | r12395 | |
| 23 | 23 | |
| 24 | 24 | */ |
| 25 | 25 | |
| 26 | #ifndef __TMS9928A_H__ |
| 27 | #define __TMS9928A_H__ |
| 28 | |
| 29 | #include "emu.h" |
| 30 | #include "machine//devhelpr.h" |
| 31 | |
| 32 | |
| 26 | 33 | #define TMS9928A_PALETTE_SIZE 16 |
| 27 | 34 | |
| 28 | | /* |
| 29 | | ** The different models |
| 30 | | */ |
| 31 | | typedef enum |
| 35 | |
| 36 | /* Some defines used in defining the screens */ |
| 37 | #define TMS9928A_TOTAL_HORZ 342 |
| 38 | #define TMS9928A_TOTAL_VERT_NTSC 262 |
| 39 | #define TMS9928A_TOTAL_VERT_PAL 313 |
| 40 | |
| 41 | #define TMS9928A_HORZ_DISPLAY_START (2 + 14 + 8 + 13) |
| 42 | #define TMS9928A_VERT_DISPLAY_START_PAL (13 + 51) |
| 43 | #define TMS9928A_VERT_DISPLAY_START_NTSC (13 + 27) |
| 44 | |
| 45 | |
| 46 | #define TMS9928A_INTERFACE(name) \ |
| 47 | const tms9928a_interface (name) = |
| 48 | |
| 49 | |
| 50 | #define MCFG_TMS9928A_ADD(_tag, _variant, _config) \ |
| 51 | MCFG_DEVICE_ADD(_tag, _variant, XTAL_10_738635MHz / 2 ) \ |
| 52 | MCFG_DEVICE_CONFIG(_config) \ |
| 53 | MCFG_PALETTE_LENGTH(TMS9928A_PALETTE_SIZE) \ |
| 54 | MCFG_PALETTE_INIT(tms9928a) \ |
| 55 | |
| 56 | |
| 57 | #define MCFG_TMS9928A_SCREEN_ADD_NTSC(_screen_tag) \ |
| 58 | MCFG_SCREEN_ADD( _screen_tag, RASTER ) \ |
| 59 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) \ |
| 60 | MCFG_SCREEN_RAW_PARAMS( XTAL_10_738635MHz / 2, TMS9928A_TOTAL_HORZ, TMS9928A_HORZ_DISPLAY_START-12, TMS9928A_HORZ_DISPLAY_START + 256 + 12, \ |
| 61 | TMS9928A_TOTAL_VERT_NTSC, TMS9928A_VERT_DISPLAY_START_NTSC - 12, TMS9928A_VERT_DISPLAY_START_NTSC + 192 + 12 ) |
| 62 | |
| 63 | |
| 64 | #define MCFG_TMS9928A_SCREEN_ADD_PAL(_screen_tag) \ |
| 65 | MCFG_SCREEN_ADD(_screen_tag, RASTER ) \ |
| 66 | MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) \ |
| 67 | MCFG_SCREEN_RAW_PARAMS( XTAL_10_738635MHz / 2, TMS9928A_TOTAL_HORZ, TMS9928A_HORZ_DISPLAY_START-12, TMS9928A_HORZ_DISPLAY_START + 256 + 12, \ |
| 68 | TMS9928A_TOTAL_VERT_PAL, TMS9928A_VERT_DISPLAY_START_PAL - 12, TMS9928A_VERT_DISPLAY_START_PAL + 192 + 12 ) |
| 69 | |
| 70 | |
| 71 | extern const device_type TMS9918; |
| 72 | extern const device_type TMS9918A; |
| 73 | extern const device_type TMS9118; |
| 74 | extern const device_type TMS9928A; |
| 75 | extern const device_type TMS9128; |
| 76 | extern const device_type TMS9929; |
| 77 | extern const device_type TMS9929A; |
| 78 | extern const device_type TMS9129; |
| 79 | |
| 80 | |
| 81 | typedef struct _tms9928a_interface tms9928a_interface; |
| 82 | struct _tms9928a_interface |
| 32 | 83 | { |
| 33 | | TMS_INVALID_MODEL, |
| 34 | | TMS99x8, |
| 35 | | TMS9929, |
| 36 | | TMS99x8A, |
| 37 | | TMS9929A |
| 38 | | } tms9928a_model; |
| 84 | const char *m_screen_tag; |
| 85 | int m_vram_size; /* 4K, 8K, or 16K. This should be replaced by fetching data from an address space? */ |
| 86 | devcb_write_line m_out_int_line; /* Callback is called whenever the state of the INT output changes */ |
| 87 | }; |
| 39 | 88 | |
| 40 | | /* |
| 41 | | ** MachineDriver video declarations for the TMS9928A chip |
| 42 | | */ |
| 43 | | typedef struct TMS9928a_interface |
| 89 | |
| 90 | PALETTE_INIT( tms9928a ); |
| 91 | |
| 92 | |
| 93 | class tms9928a_device : public device_t, |
| 94 | public tms9928a_interface |
| 44 | 95 | { |
| 45 | | tms9928a_model model; /* model: tms9929(a) runs at 50Hz instead of 60Hz */ |
| 46 | | int vram; /* VRAM size in bytes (4k, 8k or 16k) */ |
| 47 | | int borderx, bordery; /* number of border pixels to show in each direction */ |
| 48 | | void (*int_callback)(running_machine &, int); /* callback which is called whenever the state |
| 49 | | ** of the INT output of the TMS9918A changes (may be NULL)*/ |
| 50 | | } TMS9928a_interface; |
| 96 | public: |
| 97 | // construction/destruction |
| 98 | tms9928a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 99 | tms9928a_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock, bool is_50hz = false, bool is_reva = true); |
| 51 | 100 | |
| 52 | | /* |
| 53 | | ** configuration function |
| 54 | | */ |
| 55 | | extern void TMS9928A_configure (const TMS9928a_interface *intf); |
| 101 | DECLARE_READ8_MEMBER( vram_read ); |
| 102 | DECLARE_WRITE8_MEMBER( vram_write ); |
| 103 | DECLARE_READ8_MEMBER( register_read ); |
| 104 | DECLARE_WRITE8_MEMBER( register_write ); |
| 56 | 105 | |
| 57 | | /* |
| 58 | | ** reset function |
| 59 | | */ |
| 60 | | extern void TMS9928A_reset (void); |
| 106 | /* update the screen */ |
| 107 | void update( bitmap_t *bitmap, const rectangle *cliprect ); |
| 61 | 108 | |
| 62 | | /* |
| 63 | | ** The I/O functions |
| 64 | | */ |
| 65 | | extern READ8_HANDLER (TMS9928A_vram_r); |
| 66 | | extern WRITE8_HANDLER (TMS9928A_vram_w); |
| 67 | | extern READ8_HANDLER (TMS9928A_register_r); |
| 68 | | extern WRITE8_HANDLER (TMS9928A_register_w); |
| 109 | protected: |
| 110 | // device-level overrides |
| 111 | virtual void device_config_complete(); |
| 112 | virtual void device_start(); |
| 113 | virtual void device_reset(); |
| 114 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 69 | 115 | |
| 70 | | /* |
| 71 | | ** Call this function to render the screen. |
| 72 | | */ |
| 73 | | extern VIDEO_START( tms9928a ); |
| 74 | | extern SCREEN_UPDATE( tms9928a ); |
| 116 | // device_memory_interface overrides |
| 117 | virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const { return (spacenum == AS_0) ? &m_space_config : NULL; } |
| 75 | 118 | |
| 76 | | /* |
| 77 | | ** This next function must be called 50 (tms9929a) or 60 (tms99x8a) times per second, |
| 78 | | ** to generate the necessary interrupts |
| 79 | | */ |
| 80 | | int TMS9928A_interrupt (running_machine &machine); |
| 119 | private: |
| 120 | void change_register(UINT8 reg, UINT8 val); |
| 81 | 121 | |
| 82 | | /* |
| 83 | | ** Set display of illegal sprites on or off |
| 84 | | */ |
| 85 | | void TMS9928A_set_spriteslimit (int); |
| 122 | static const device_timer_id TIMER_LINE = 0; |
| 86 | 123 | |
| 87 | | /* |
| 88 | | ** After loading a state, call this function |
| 89 | | */ |
| 90 | | void TMS9928A_post_load (running_machine &machine); |
| 124 | screen_device *m_screen; |
| 91 | 125 | |
| 92 | | /* |
| 93 | | ** MachineDriver video declarations for the TMS9928A chip |
| 94 | | */ |
| 95 | | MACHINE_CONFIG_EXTERN( tms9928a ); |
| 126 | /* TMS9928A internal settings */ |
| 127 | UINT8 m_ReadAhead; |
| 128 | UINT8 m_Regs[8]; |
| 129 | UINT8 m_StatusReg; |
| 130 | UINT8 m_FifthSprite; |
| 131 | UINT8 m_latch; |
| 132 | UINT8 m_INT; |
| 133 | UINT16 m_Addr; |
| 134 | UINT16 m_colour; |
| 135 | UINT16 m_pattern; |
| 136 | UINT16 m_nametbl; |
| 137 | UINT16 m_spriteattribute; |
| 138 | UINT16 m_spritepattern; |
| 139 | int m_colourmask; |
| 140 | int m_patternmask; |
| 141 | devcb_resolved_write_line m_irq_changed; |
| 142 | bool m_50hz; |
| 143 | bool m_reva; |
| 144 | |
| 145 | /* memory */ |
| 146 | const address_space_config m_space_config; |
| 147 | |
| 148 | UINT8 *m_vMem; |
| 149 | bitmap_t *m_tmpbmp; |
| 150 | emu_timer *m_line_timer; |
| 151 | UINT8 m_mode; |
| 152 | |
| 153 | /* emulation settings */ |
| 154 | int m_LimitSprites; /* max 4 sprites on a row, like original TMS9918A */ |
| 155 | int m_top_border; |
| 156 | }; |
| 157 | |
| 158 | |
| 159 | class tms9918_device : public tms9928a_device |
| 160 | { |
| 161 | public: |
| 162 | tms9918_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 163 | : tms9928a_device( mconfig, TMS9918, "tms9918", tag, owner, clock, false, false ) { } |
| 164 | }; |
| 165 | |
| 166 | |
| 167 | class tms9918a_device : public tms9928a_device |
| 168 | { |
| 169 | public: |
| 170 | tms9918a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 171 | : tms9928a_device( mconfig, TMS9918A, "tms9918a", tag, owner, clock, false, true ) { } |
| 172 | }; |
| 173 | |
| 174 | |
| 175 | class tms9118_device : public tms9928a_device |
| 176 | { |
| 177 | public: |
| 178 | tms9118_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 179 | : tms9928a_device( mconfig, TMS9118, "tms9118", tag, owner, clock, false, false ) { } |
| 180 | }; |
| 181 | |
| 182 | |
| 183 | class tms9128_device : public tms9928a_device |
| 184 | { |
| 185 | public: |
| 186 | tms9128_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 187 | : tms9928a_device( mconfig, TMS9128, "tms9128", tag, owner, clock, false, false ) { } |
| 188 | }; |
| 189 | |
| 190 | |
| 191 | class tms9929_device : public tms9928a_device |
| 192 | { |
| 193 | public: |
| 194 | tms9929_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 195 | : tms9928a_device( mconfig, TMS9929, "tms9929", tag, owner, clock, false, true ) { } |
| 196 | }; |
| 197 | |
| 198 | |
| 199 | class tms9929a_device : public tms9928a_device |
| 200 | { |
| 201 | public: |
| 202 | tms9929a_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 203 | : tms9928a_device( mconfig, TMS9929A, "tms9929a", tag, owner, clock, true, true ) { } |
| 204 | }; |
| 205 | |
| 206 | |
| 207 | class tms9129_device : public tms9928a_device |
| 208 | { |
| 209 | public: |
| 210 | tms9129_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 211 | : tms9928a_device( mconfig, TMS9129, "tms9129", tag, owner, clock, true, false ) { } |
| 212 | }; |
| 213 | |
| 214 | |
| 215 | #endif |
src/mess/drivers/sg1000.c
| r12394 | r12395 | |
| 76 | 76 | #include "machine/i8255.h" |
| 77 | 77 | #include "machine/msm8251.h" |
| 78 | 78 | #include "machine/upd765.h" |
| 79 | #include "video/tms9928a.h" |
| 79 | 80 | #include "sound/sn76496.h" |
| 80 | 81 | #include "crsshair.h" |
| 81 | 82 | #include "includes/sg1000.h" |
| r12394 | r12395 | |
| 166 | 167 | static ADDRESS_MAP_START( sg1000_io_map, AS_IO, 8, sg1000_state ) |
| 167 | 168 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 168 | 169 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 169 | | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 170 | | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 170 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, vram_read, vram_write) |
| 171 | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, register_read, register_write) |
| 171 | 172 | AM_RANGE(0xdc, 0xdc) AM_READ_PORT("PA7") |
| 172 | 173 | AM_RANGE(0xdd, 0xdd) AM_READ_PORT("PB7") |
| 173 | 174 | AM_RANGE(0xde, 0xde) AM_READ(joysel_r) AM_WRITENOP |
| r12394 | r12395 | |
| 191 | 192 | static ADDRESS_MAP_START( omv_io_map, AS_IO, 8, sg1000_state ) |
| 192 | 193 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 193 | 194 | AM_RANGE(0x40, 0x40) AM_MIRROR(0x3f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 194 | | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 195 | | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 195 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x3e) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, vram_read, vram_write) |
| 196 | AM_RANGE(0x81, 0x81) AM_MIRROR(0x3e) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, register_read, register_write) |
| 196 | 197 | AM_RANGE(0xc0, 0xc0) AM_MIRROR(0x38) AM_READ_PORT("C0") |
| 197 | 198 | AM_RANGE(0xc1, 0xc1) AM_MIRROR(0x38) AM_READ_PORT("C1") |
| 198 | 199 | AM_RANGE(0xc2, 0xc2) AM_MIRROR(0x38) AM_READ_PORT("C2") |
| r12394 | r12395 | |
| 218 | 219 | static ADDRESS_MAP_START( sc3000_io_map, AS_IO, 8, sg1000_state ) |
| 219 | 220 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 220 | 221 | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 221 | | AM_RANGE(0xbe, 0xbe) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 222 | | AM_RANGE(0xbf, 0xbf) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 222 | AM_RANGE(0xbe, 0xbe) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, vram_read, vram_write) |
| 223 | AM_RANGE(0xbf, 0xbf) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, register_read, register_write) |
| 223 | 224 | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE(UPD9255_TAG, i8255_device, read, write) |
| 224 | 225 | ADDRESS_MAP_END |
| 225 | 226 | |
| r12394 | r12395 | |
| 228 | 229 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 229 | 230 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xdf) AM_DEVREADWRITE(UPD9255_TAG, i8255_device, read, write) |
| 230 | 231 | AM_RANGE(0x00, 0x00) AM_MIRROR(0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 231 | | AM_RANGE(0x00, 0x00) AM_MIRROR(0xae) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 232 | | AM_RANGE(0x01, 0x01) AM_MIRROR(0xae) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 232 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xae) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, vram_read, vram_write) |
| 233 | AM_RANGE(0x01, 0x01) AM_MIRROR(0xae) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, register_read, register_write) |
| 233 | 234 | AM_RANGE(0x60, 0x60) AM_MIRROR(0x9f) AM_READ(sc3000_r_r) |
| 234 | 235 | ADDRESS_MAP_END |
| 235 | 236 | */ |
| r12394 | r12395 | |
| 250 | 251 | static ADDRESS_MAP_START( sf7000_io_map, AS_IO, 8, sf7000_state ) |
| 251 | 252 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 252 | 253 | AM_RANGE(0x7f, 0x7f) AM_DEVWRITE_LEGACY(SN76489A_TAG, sn76496_w) |
| 253 | | AM_RANGE(0xbe, 0xbe) AM_READWRITE_LEGACY(TMS9928A_vram_r, TMS9928A_vram_w) |
| 254 | | AM_RANGE(0xbf, 0xbf) AM_READWRITE_LEGACY(TMS9928A_register_r, TMS9928A_register_w) |
| 254 | AM_RANGE(0xbe, 0xbe) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, vram_read, vram_write) |
| 255 | AM_RANGE(0xbf, 0xbf) AM_DEVREADWRITE(TMS9918A_TAG, tms9918a_device, register_read, register_write) |
| 255 | 256 | AM_RANGE(0xdc, 0xdf) AM_DEVREADWRITE(UPD9255_0_TAG, i8255_device, read, write) |
| 256 | 257 | AM_RANGE(0xe0, 0xe0) AM_DEVREAD_LEGACY(UPD765_TAG, upd765_status_r) |
| 257 | 258 | AM_RANGE(0xe1, 0xe1) AM_DEVREADWRITE_LEGACY(UPD765_TAG, upd765_data_r, upd765_data_w) |
| r12394 | r12395 | |
| 531 | 532 | TMS9928a_interface tms9928a_interface |
| 532 | 533 | -------------------------------------------------*/ |
| 533 | 534 | |
| 534 | | INTERRUPT_GEN( sg1000_int ) |
| 535 | static WRITE_LINE_DEVICE_HANDLER(sg1000_vdp_interrupt) |
| 535 | 536 | { |
| 536 | | TMS9928A_interrupt(device->machine()); |
| 537 | cputag_set_input_line(device->machine(), Z80_TAG, INPUT_LINE_IRQ0, state); |
| 537 | 538 | } |
| 538 | 539 | |
| 539 | | static void sg1000_vdp_interrupt(running_machine &machine, int state) |
| 540 | static TMS9928A_INTERFACE(sg1000_tms9918a_interface) |
| 540 | 541 | { |
| 541 | | cputag_set_input_line(machine, Z80_TAG, INPUT_LINE_IRQ0, state); |
| 542 | | } |
| 543 | | |
| 544 | | const TMS9928a_interface tms9928a_interface = |
| 545 | | { |
| 546 | | TMS99x8A, |
| 542 | "screen", |
| 547 | 543 | 0x4000, |
| 548 | | 0, 0, |
| 549 | | sg1000_vdp_interrupt |
| 544 | DEVCB_LINE(sg1000_vdp_interrupt) |
| 550 | 545 | }; |
| 551 | 546 | |
| 547 | static SCREEN_UPDATE( sg1000 ) |
| 548 | { |
| 549 | tms9918a_device *tms9918a = screen->machine().device<tms9918a_device>( TMS9918A_TAG ); |
| 550 | |
| 551 | tms9918a->update( bitmap, cliprect ); |
| 552 | return 0; |
| 553 | } |
| 554 | |
| 552 | 555 | /*------------------------------------------------- |
| 553 | 556 | I8255_INTERFACE( sc3000_ppi_intf ) |
| 554 | 557 | -------------------------------------------------*/ |
| r12394 | r12395 | |
| 977 | 980 | |
| 978 | 981 | void sg1000_state::machine_start() |
| 979 | 982 | { |
| 980 | | /* configure VDP */ |
| 981 | | TMS9928A_configure(&tms9928a_interface); |
| 982 | | |
| 983 | 983 | /* toggle light gun crosshair */ |
| 984 | 984 | machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); |
| 985 | 985 | |
| r12394 | r12395 | |
| 993 | 993 | |
| 994 | 994 | void sc3000_state::machine_start() |
| 995 | 995 | { |
| 996 | | /* configure VDP */ |
| 997 | | TMS9928A_configure(&tms9928a_interface); |
| 998 | | |
| 999 | 996 | /* toggle light gun crosshair */ |
| 1000 | 997 | machine().scheduler().timer_set(attotime::zero, FUNC(lightgun_tick)); |
| 1001 | 998 | |
| r12394 | r12395 | |
| 1011 | 1008 | |
| 1012 | 1009 | void sf7000_state::machine_start() |
| 1013 | 1010 | { |
| 1014 | | /* configure VDP */ |
| 1015 | | TMS9928A_configure(&tms9928a_interface); |
| 1016 | | |
| 1017 | 1011 | /* configure memory banking */ |
| 1018 | 1012 | memory_configure_bank(machine(), "bank1", 0, 1, machine().region(Z80_TAG)->base(), 0); |
| 1019 | 1013 | memory_configure_bank(machine(), "bank1", 1, 1, ram_get_ptr(m_ram), 0); |
| r12394 | r12395 | |
| 1048 | 1042 | MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) |
| 1049 | 1043 | MCFG_CPU_PROGRAM_MAP(sg1000_map) |
| 1050 | 1044 | MCFG_CPU_IO_MAP(sg1000_io_map) |
| 1051 | | MCFG_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1052 | 1045 | |
| 1053 | 1046 | /* video hardware */ |
| 1054 | | MCFG_FRAGMENT_ADD(tms9928a) |
| 1055 | | MCFG_SCREEN_MODIFY(SCREEN_TAG) |
| 1056 | | MCFG_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 1057 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1047 | MCFG_TMS9928A_ADD( TMS9918A_TAG, TMS9918A, sg1000_tms9918a_interface ) |
| 1048 | MCFG_TMS9928A_SCREEN_ADD_NTSC( "screen" ) |
| 1049 | MCFG_SCREEN_UPDATE( sg1000 ) |
| 1058 | 1050 | |
| 1059 | 1051 | /* sound hardware */ |
| 1060 | 1052 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| r12394 | r12395 | |
| 1103 | 1095 | MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) // LH0080A |
| 1104 | 1096 | MCFG_CPU_PROGRAM_MAP(sc3000_map) |
| 1105 | 1097 | MCFG_CPU_IO_MAP(sc3000_io_map) |
| 1106 | | MCFG_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1107 | 1098 | |
| 1108 | 1099 | /* video hardware */ |
| 1109 | | MCFG_FRAGMENT_ADD(tms9928a) |
| 1110 | | MCFG_SCREEN_MODIFY(SCREEN_TAG) |
| 1111 | | MCFG_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 1112 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1100 | MCFG_TMS9928A_ADD( TMS9918A_TAG, TMS9918A, sg1000_tms9918a_interface ) |
| 1101 | MCFG_TMS9928A_SCREEN_ADD_NTSC( "screen" ) |
| 1102 | MCFG_SCREEN_UPDATE( sg1000 ) |
| 1113 | 1103 | |
| 1114 | 1104 | /* sound hardware */ |
| 1115 | 1105 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| r12394 | r12395 | |
| 1144 | 1134 | MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_10_738635MHz/3) |
| 1145 | 1135 | MCFG_CPU_PROGRAM_MAP(sf7000_map) |
| 1146 | 1136 | MCFG_CPU_IO_MAP(sf7000_io_map) |
| 1147 | | MCFG_CPU_VBLANK_INT(SCREEN_TAG, sg1000_int) |
| 1148 | 1137 | |
| 1149 | 1138 | /* video hardware */ |
| 1150 | | MCFG_FRAGMENT_ADD(tms9928a) |
| 1151 | | MCFG_SCREEN_MODIFY(SCREEN_TAG) |
| 1152 | | MCFG_SCREEN_REFRESH_RATE((float)XTAL_10_738635MHz/2/342/262) |
| 1153 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1139 | MCFG_TMS9928A_ADD( TMS9918A_TAG, TMS9918A, sg1000_tms9918a_interface ) |
| 1140 | MCFG_TMS9928A_SCREEN_ADD_NTSC( "screen" ) |
| 1141 | MCFG_SCREEN_UPDATE( sg1000 ) |
| 1154 | 1142 | |
| 1155 | 1143 | /* sound hardware */ |
| 1156 | 1144 | MCFG_SPEAKER_STANDARD_MONO("mono") |
src/mess/drivers/msx.c
| r12394 | r12395 | |
| 331 | 331 | AM_RANGE( 0x91, 0x91) AM_DEVWRITE("centronics", msx_printer_data_w) |
| 332 | 332 | AM_RANGE( 0xa0, 0xa7) AM_DEVREADWRITE("ay8910", ay8910_r, msx_ay8910_w ) |
| 333 | 333 | AM_RANGE( 0xa8, 0xab) AM_DEVREADWRITE_MODERN("ppi8255", i8255_device, read, write) |
| 334 | | AM_RANGE( 0x98, 0x98) AM_READWRITE( TMS9928A_vram_r, TMS9928A_vram_w ) |
| 335 | | AM_RANGE( 0x99, 0x99) AM_READWRITE( TMS9928A_register_r, TMS9928A_register_w ) |
| 334 | AM_RANGE( 0x98, 0x98) AM_DEVREADWRITE_MODERN("tms9928a", tms9928a_device, vram_read, vram_write) |
| 335 | AM_RANGE( 0x99, 0x99) AM_DEVREADWRITE_MODERN("tms9928a", tms9928a_device, register_read, register_write) |
| 336 | 336 | AM_RANGE( 0xd8, 0xd9) AM_READWRITE( msx_kanji_r, msx_kanji_w ) |
| 337 | 337 | ADDRESS_MAP_END |
| 338 | 338 | |
| r12394 | r12395 | |
| 1051 | 1051 | MCFG_CPU_ADD("maincpu", Z80, 3579545) /* 3.579545 MHz */ |
| 1052 | 1052 | MCFG_CPU_PROGRAM_MAP(msx_memory_map) |
| 1053 | 1053 | MCFG_CPU_IO_MAP(msx_io_map) |
| 1054 | | MCFG_CPU_VBLANK_INT("screen", msx_interrupt) |
| 1054 | MCFG_CPU_VBLANK_INT("screen", msx_interrupt) /* Needed for mouse updates */ |
| 1055 | 1055 | MCFG_QUANTUM_TIME(attotime::from_hz(60)) |
| 1056 | 1056 | |
| 1057 | 1057 | MCFG_MACHINE_START( msx ) |
| r12394 | r12395 | |
| 1059 | 1059 | |
| 1060 | 1060 | MCFG_I8255_ADD( "ppi8255", msx_ppi8255_interface ) |
| 1061 | 1061 | |
| 1062 | | /* video hardware */ |
| 1063 | | MCFG_FRAGMENT_ADD(tms9928a) |
| 1064 | | MCFG_SCREEN_MODIFY("screen") |
| 1065 | | MCFG_SCREEN_REFRESH_RATE(60) |
| 1066 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 1067 | | MCFG_SCREEN_SIZE(MSX_TOTAL_XRES_PIXELS, MSX_TOTAL_YRES_PIXELS) |
| 1068 | | MCFG_SCREEN_VISIBLE_AREA(MSX_XBORDER_PIXELS - MSX_VISIBLE_XBORDER_PIXELS, MSX_TOTAL_XRES_PIXELS - MSX_XBORDER_PIXELS + MSX_VISIBLE_XBORDER_PIXELS - 1, MSX_YBORDER_PIXELS - MSX_VISIBLE_YBORDER_PIXELS, MSX_TOTAL_YRES_PIXELS - MSX_YBORDER_PIXELS + MSX_VISIBLE_YBORDER_PIXELS - 1) |
| 1069 | | |
| 1070 | 1062 | /* sound hardware */ |
| 1071 | 1063 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 1072 | 1064 | MCFG_SOUND_ADD("dac", DAC, 0) |
| r12394 | r12395 | |
| 1094 | 1086 | MACHINE_CONFIG_END |
| 1095 | 1087 | |
| 1096 | 1088 | |
| 1089 | static WRITE_LINE_DEVICE_HANDLER(tms9928a_interrupt) |
| 1090 | { |
| 1091 | cputag_set_input_line(device->machine(), "maincpu", 0, (state ? HOLD_LINE : CLEAR_LINE)); |
| 1092 | } |
| 1093 | |
| 1094 | |
| 1095 | static SCREEN_UPDATE( msx ) |
| 1096 | { |
| 1097 | tms9928a_device *tms9928a = screen->machine().device<tms9928a_device>( "tms9928a" ); |
| 1098 | |
| 1099 | tms9928a->update( bitmap, cliprect ); |
| 1100 | return 0; |
| 1101 | } |
| 1102 | |
| 1103 | |
| 1104 | static TMS9928A_INTERFACE(msx_tms9928a_interface) |
| 1105 | { |
| 1106 | "screen", |
| 1107 | 0x4000, |
| 1108 | DEVCB_LINE(tms9928a_interrupt) |
| 1109 | }; |
| 1110 | |
| 1111 | |
| 1112 | static MACHINE_CONFIG_DERIVED( msx_ntsc, msx ) |
| 1113 | /* Video hardware */ |
| 1114 | MCFG_TMS9928A_ADD( "tms9928a", TMS9928A, msx_tms9928a_interface ) |
| 1115 | MCFG_TMS9928A_SCREEN_ADD_NTSC( "screen" ) |
| 1116 | MCFG_SCREEN_UPDATE( msx ) |
| 1117 | MACHINE_CONFIG_END |
| 1118 | |
| 1119 | |
| 1097 | 1120 | static MACHINE_CONFIG_DERIVED( msx_pal, msx ) |
| 1098 | | MCFG_SCREEN_MODIFY("screen") |
| 1099 | | MCFG_SCREEN_REFRESH_RATE(50) |
| 1121 | /* Video hardware */ |
| 1122 | MCFG_TMS9928A_ADD( "tms9928a", TMS9929A, msx_tms9928a_interface ) |
| 1123 | MCFG_TMS9928A_SCREEN_ADD_PAL( "screen" ) |
| 1124 | MCFG_SCREEN_UPDATE( msx ) |
| 1100 | 1125 | MACHINE_CONFIG_END |
| 1101 | 1126 | |
| 1127 | |
| 1102 | 1128 | #define MSX2_XBORDER_PIXELS 16 |
| 1103 | 1129 | #define MSX2_YBORDER_PIXELS 28 |
| 1104 | 1130 | #define MSX2_TOTAL_XRES_PIXELS 256 * 2 + (MSX2_XBORDER_PIXELS * 2) |
| r12394 | r12395 | |
| 3812 | 3838 | COMP(1983, ax170, msx, 0, msx_pal, msx, msx, "Al Alamiah", "AX-170" , 0) |
| 3813 | 3839 | COMP(1983, canonv10, msx, 0, msx_pal, msx, msx, "Canon", "V-10" , 0) |
| 3814 | 3840 | COMP(1983, canonv20, msx, 0, msx_pal, msx, msx, "Canon", "V-20" , 0) |
| 3815 | | COMP(1984, dpc100, msx, 0, msx, msxkr, msx, "Daewoo", "IQ-1000 DPC-100 (Korea)" , 0) |
| 3816 | | COMP(1984, dpc180, msx, 0, msx, msxkr, msx, "Daewoo", "IQ-1000 DPC-180 (Korea)" , 0) |
| 3817 | | COMP(1984, dpc200, msx, 0, msx, msxkr, msx, "Daewoo", "IQ-1000 DPC-200 (Korea)" , 0) |
| 3841 | COMP(1984, dpc100, msx, 0, msx_ntsc, msxkr, msx, "Daewoo", "IQ-1000 DPC-100 (Korea)" , 0) |
| 3842 | COMP(1984, dpc180, msx, 0, msx_ntsc, msxkr, msx, "Daewoo", "IQ-1000 DPC-180 (Korea)" , 0) |
| 3843 | COMP(1984, dpc200, msx, 0, msx_ntsc, msxkr, msx, "Daewoo", "IQ-1000 DPC-200 (Korea)" , 0) |
| 3818 | 3844 | COMP(1983, gsfc200, msx, 0, msx_pal, msx, msx, "Goldstar", "FC-200" , 0) |
| 3819 | | COMP(1983, expert10, msx, 0, msx, expert10, msx, "Gradiente", "Expert 1.0 (Brazil)" , 0) |
| 3820 | | COMP(1984, expert11, msx, 0, msx, expert11, msx, "Gradiente", "Expert 1.1 (Brazil)" , 0) |
| 3821 | | COMP(1984, expert13, msx, 0, msx, expert11, msx, "Gradiente", "Expert 1.3 (Brazil)" , 0) |
| 3822 | | COMP(1985, expertdp, msx, 0, msx, expert11, msx, "Gradiente", "Expert DDPlus (Brazil)", 0 ) |
| 3823 | | COMP(1984, expertpl, msx, 0, msx, expert11, msx, "Gradiente", "Expert Plus (Brazil)" , 0) |
| 3845 | COMP(1983, expert10, msx, 0, msx_ntsc, expert10, msx, "Gradiente", "Expert 1.0 (Brazil)" , 0) |
| 3846 | COMP(1984, expert11, msx, 0, msx_ntsc, expert11, msx, "Gradiente", "Expert 1.1 (Brazil)" , 0) |
| 3847 | COMP(1984, expert13, msx, 0, msx_ntsc, expert11, msx, "Gradiente", "Expert 1.3 (Brazil)" , 0) |
| 3848 | COMP(1985, expertdp, msx, 0, msx_ntsc, expert11, msx, "Gradiente", "Expert DDPlus (Brazil)", 0 ) |
| 3849 | COMP(1984, expertpl, msx, 0, msx_ntsc, expert11, msx, "Gradiente", "Expert Plus (Brazil)" , 0) |
| 3824 | 3850 | COMP(1983, jvchc7gb, msx, 0, msx_pal, msx, msx, "JVC", "HC-7GB" , 0) |
| 3825 | 3851 | COMP(1983, mlf80, msx, 0, msx_pal, msx, msx, "Mitsubishi", "ML-F80" , 0) |
| 3826 | 3852 | COMP(1983, mlfx1, msx, 0, msx_pal, msx, msx, "Mitsubishi", "ML-FX1" , 0) |
| 3827 | | COMP(1984, cf1200, msx, 0, msx, msxjp, msx, "National / Matsushita", "CF-1200 (Japan)" , 0) |
| 3828 | | COMP(1983, cf2000, msx, 0, msx, msxjp, msx, "National / Matsushita", "CF-2000 (Japan)" , 0) |
| 3829 | | COMP(1984, cf2700, msx, 0, msx, msxjp, msx, "National / Matsushita", "CF-2700 (Japan)" , 0) |
| 3830 | | COMP(1984, cf3000, msx, 0, msx, msxjp, msx, "National / Matsushita", "CF-3000 (Japan)" , 0) |
| 3831 | | COMP(1985, cf3300, msx, 0, msx, msxjp, msx, "National / Matsushita", "CF-3300 (Japan)", 0 ) |
| 3832 | | COMP(1985, fs1300, msx, 0, msx, msxjp, msx, "National / Matsushita", "FS-1300 (Japan)" , 0) |
| 3833 | | COMP(1985, fs4000, msx, 0, msx, msxjp, msx, "National / Matsushita", "FS-4000 (Japan)" , 0) |
| 3853 | COMP(1984, cf1200, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "CF-1200 (Japan)" , 0) |
| 3854 | COMP(1983, cf2000, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "CF-2000 (Japan)" , 0) |
| 3855 | COMP(1984, cf2700, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "CF-2700 (Japan)" , 0) |
| 3856 | COMP(1984, cf3000, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "CF-3000 (Japan)" , 0) |
| 3857 | COMP(1985, cf3300, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "CF-3300 (Japan)", 0 ) |
| 3858 | COMP(1985, fs1300, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "FS-1300 (Japan)" , 0) |
| 3859 | COMP(1985, fs4000, msx, 0, msx_ntsc, msxjp, msx, "National / Matsushita", "FS-4000 (Japan)" , 0) |
| 3834 | 3860 | COMP(1983, nms801, msx, 0, msx_pal, msx, msx, "Philips", "NMS-801" , 0) |
| 3835 | | COMP(1984, vg8000, msx, 0, msx, msx, msx, "Philips", "VG-8000" , GAME_NOT_WORKING) |
| 3836 | | COMP(1984, vg8010, msx, 0, msx, msx, msx, "Philips", "VG-8010" , GAME_NOT_WORKING) |
| 3837 | | COMP(1984, vg8010f, msx, 0, msx, msx, msx, "Philips", "VG-8010F" , GAME_NOT_WORKING) |
| 3838 | | COMP(1985, vg802000, msx, 0, msx, msx, msx, "Philips", "VG-8020-00" , 0) |
| 3839 | | COMP(1985, vg802020, msx, 0, msx, msx, msx, "Philips", "VG-8020-20" , 0) |
| 3861 | COMP(1984, vg8000, msx, 0, msx_ntsc, msx, msx, "Philips", "VG-8000" , GAME_NOT_WORKING) |
| 3862 | COMP(1984, vg8010, msx, 0, msx_ntsc, msx, msx, "Philips", "VG-8010" , GAME_NOT_WORKING) |
| 3863 | COMP(1984, vg8010f, msx, 0, msx_ntsc, msx, msx, "Philips", "VG-8010F" , GAME_NOT_WORKING) |
| 3864 | COMP(1985, vg802000, msx, 0, msx_ntsc, msx, msx, "Philips", "VG-8020-00" , 0) |
| 3865 | COMP(1985, vg802020, msx, 0, msx_ntsc, msx, msx, "Philips", "VG-8020-20" , 0) |
| 3840 | 3866 | COMP(1985, piopx7, msx, 0, msx_pal, msx, msx, "Pioneer", "PX-07" , 0) |
| 3841 | 3867 | COMP(1985, mpc100, msx, 0, msx_pal, msx, msx, "Sanyo", "MPC-100" , 0) |
| 3842 | | COMP(1985, hotbit11, msx, 0, msx, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.1" , 0) |
| 3843 | | COMP(1985, hotbit12, msx, 0, msx, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.2" , 0) |
| 3844 | | COMP(1985, hotbi13b, msx, 0, msx, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.3b" , 0) |
| 3845 | | COMP(1985, hotbi13p, msx, 0, msx, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.3p" , 0) |
| 3868 | COMP(1985, hotbit11, msx, 0, msx_ntsc, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.1" , 0) |
| 3869 | COMP(1985, hotbit12, msx, 0, msx_ntsc, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.2" , 0) |
| 3870 | COMP(1985, hotbi13b, msx, 0, msx_ntsc, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.3b" , 0) |
| 3871 | COMP(1985, hotbi13p, msx, 0, msx_ntsc, hotbit, msx, "Sharp / Epcom", "HB-8000 Hotbit 1.3p" , 0) |
| 3846 | 3872 | COMP(1985, hb10p, msx, 0, msx_pal, msx, msx, "Sony", "HB-10P" , 0) |
| 3847 | 3873 | COMP(1985, hb20p, msx, 0, msx_pal, msx, msx, "Sony", "HB-20P (Spanish)" , 0) |
| 3848 | | COMP(1985, hb201, msx, 0, msx, msxjp, msx, "Sony", "HB-201 (Japan)" , 0) |
| 3874 | COMP(1985, hb201, msx, 0, msx_ntsc, msxjp, msx, "Sony", "HB-201 (Japan)" , 0) |
| 3849 | 3875 | COMP(1985, hb201p, msx, 0, msx_pal, msx, msx, "Sony", "HB-201P" , 0) |
| 3850 | 3876 | COMP(1984, hb501p, msx, 0, msx_pal, msx, msx, "Sony", "HB-501P" , 0) |
| 3851 | 3877 | COMP(1983, hb55d, msx, 0, msx_pal, msx, msx, "Sony", "HB-55D (Germany)" , 0) |