Previous 199869 Revisions Next

r18102 Sunday 23rd September, 2012 at 22:15:51 UTC by R. Belmont
tms99x8: Converted to using RGB32 bitmap so chips can coexist with other video screens [R. Belmont]
[src/emu/video]tms9928a.c tms9928a.h
[src/mess/drivers]einstein.c

trunk/src/emu/video/tms9928a.c
r18101r18102
7070    E Gray          0.80    0.47    0.47    0.80    0.80    0.80    204 204 204
7171    F White         1.00    0.47    0.47    1.00    1.00    1.00    255 255 255
7272*/
73static const rgb_t tms9928a_palette[16] =
73static const rgb_t tms9928a_palette[TMS9928A_PALETTE_SIZE] =
7474{
7575   RGB_BLACK,
7676   RGB_BLACK,
r18101r18102
9393tms9928a_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 )
9494   : device_t( mconfig, type, name, tag, owner, clock ),
9595     device_memory_interface(mconfig, *this),
96     m_space_config("vram", ENDIANNESS_BIG, 8, 14)
96      m_space_config("vram",ENDIANNESS_BIG, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(memmap))
9797{
9898   m_50hz = is_50hz;
9999   m_reva = is_reva;
100   static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
100//   static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
101101}
102102
103103
104104tms9928a_device::tms9928a_device( const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock )
105105   : device_t( mconfig, TMS9928A, "TMS9928A", tag, owner, clock ),
106106     device_memory_interface(mconfig, *this),
107     m_space_config("vram", ENDIANNESS_BIG, 8, 14)
107    m_space_config("vram",ENDIANNESS_BIG, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(memmap))
108108{
109109   m_50hz = false;
110110   m_reva = true;
111   static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
111//   static_set_addrmap(*this, AS_DATA, ADDRESS_MAP_NAME(memmap));
112112}
113113
114114
r18101r18102
163163{
164164   // update backdrop colour to transparent if EXTVID bit is set
165165   if ((m_Regs[7] & 15) == 0)
166      palette_set_color(machine(), 0, MAKE_ARGB(m_Regs[0] & 1 ? 0 : 255,0,0,0));
166      m_palette[0] = MAKE_ARGB(m_Regs[0] & 1 ? 0 : 255,0,0,0);
167167}
168168
169169
r18101r18102
280280   int raw_vpos = m_screen->vpos();
281281   int vpos = raw_vpos * m_vertical_size / m_screen->height();
282282   UINT16 BackColour = m_Regs[7] & 15;
283   UINT16 *p = &m_tmpbmp.pix16(vpos);
283   UINT32 *p = &m_tmpbmp.pix32(vpos);
284284
285285   int y = vpos - m_top_border;
286286
r18101r18102
288288   {
289289      /* Draw backdrop colour */
290290      for ( int i = 0; i < TMS9928A_TOTAL_HORZ; i++ )
291         p[i] = BackColour;
291         p[i] = m_palette[BackColour];
292292
293293      /* vblank is set at the last cycle of the first inactive line */
294294      if ( y == 193 )
r18101r18102
303303
304304      /* Left border */
305305      for ( int i = 0; i < TMS9928A_HORZ_DISPLAY_START; i++ )
306         p[i] = BackColour;
306         p[i] = m_palette[BackColour];
307307
308308      /* Active display */
309309
r18101r18102
319319               UINT8 charcode = m_vram_space->read_byte( addr );
320320               UINT8 pattern =  m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( y & 7 ) );
321321               UINT8 colour =  m_vram_space->read_byte( m_colour + ( charcode >> 3 ) );
322               UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
323               UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
322               rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
323               rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
324324
325325               for ( int i = 0; i < 8; pattern <<= 1, i++ )
326326                  p[x+i] = ( pattern & 0x80 ) ? fg : bg;
r18101r18102
332332         //if (vpos==100 ) popmessage("TMS9928A MODE 1");
333333         {
334334            UINT16 addr = m_nametbl + ( ( y >> 3 ) * 40 );
335            UINT16 fg = (m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour;
336            UINT16 bg = BackColour;
335            rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
336            rgb_t bg = m_palette[BackColour];
337337
338338            /* Extra 6 pixels left border */
339339            for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 6; x++ )
r18101r18102
364364               UINT16 charcode =  m_vram_space->read_byte( addr ) + ( ( y >> 6 ) << 8 );
365365               UINT8 pattern =  m_vram_space->read_byte( m_pattern + ( ( charcode & m_patternmask ) << 3 ) + ( y & 7 ) );
366366               UINT8 colour =  m_vram_space->read_byte( m_colour + ( ( charcode & m_colourmask ) << 3 ) + ( y & 7 ) );
367               UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
368               UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
367               rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
368               rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
369369
370370               for ( int i = 0; i < 8; pattern <<= 1, i++ )
371371                  p[x+i] = ( pattern & 0x80 ) ? fg : bg;
r18101r18102
377377         //if (vpos==100) popmessage("TMS9928A MODE1+2");
378378         {
379379            UINT16 addr = m_nametbl + ( ( y >> 3 ) * 40 );
380            UINT16 fg = (m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour;
381            UINT16 bg = BackColour;
380            rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
381            rgb_t bg = m_palette[BackColour];
382382
383383            /* Extra 6 pixels left border */
384384            for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 6; x++ )
r18101r18102
408408            {
409409               UINT8 charcode =  m_vram_space->read_byte( addr );
410410               UINT8 colour =  m_vram_space->read_byte( m_pattern + ( charcode << 3 ) + ( ( y >> 2 ) & 7 ) );
411               UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
412               UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
411               rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
412               rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
413413
414414               p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg;
415415               p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg;
r18101r18102
420420      case 5:   case 7:      /* MODE bogus */
421421         //if (vpos==100 ) popmessage("TMS9928A MODE bogus");
422422         {
423            UINT16 fg = (m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour;
424            UINT16 bg = BackColour;
423            rgb_t fg = m_palette[(m_Regs[7] >> 4) ? (m_Regs[7] >> 4) : BackColour];
424            rgb_t bg = m_palette[BackColour];
425425
426426            /* Extra 6 pixels left border */
427427            for ( int x = TMS9928A_HORZ_DISPLAY_START; x < TMS9928A_HORZ_DISPLAY_START + 6; x++ )
r18101r18102
448448            {
449449               UINT8 charcode =  m_vram_space->read_byte( addr );
450450               UINT8 colour =  m_vram_space->read_byte( m_pattern + ( ( ( charcode + ( ( y >> 2 ) & 7 ) + ( ( y >> 6 ) << 8 ) ) & m_patternmask ) << 3 ) );
451               UINT16 fg = (colour >> 4) ? (colour >> 4) : BackColour;
452               UINT16 bg = (colour & 15) ? (colour & 15) : BackColour;
451               rgb_t fg = m_palette[(colour >> 4) ? (colour >> 4) : BackColour];
452               rgb_t bg = m_palette[(colour & 15) ? (colour & 15) : BackColour];
453453
454454               p[x+0] = p[x+1] = p[x+2] = p[x+3] = fg;
455455               p[x+4] = p[x+5] = p[x+6] = p[x+7] = bg;
r18101r18102
542542                                 if ( ! ( spr_drawn[ colission_index ] & 0x02 ) )
543543                                 {
544544                                    spr_drawn[ colission_index ] |= 0x02;
545                                    p[ TMS9928A_HORZ_DISPLAY_START + colission_index - 32 ] = sprcol;
545                                    p[ TMS9928A_HORZ_DISPLAY_START + colission_index - 32 ] = m_palette[sprcol];
546546                                 }
547547                              }
548548                           }
r18101r18102
567567
568568      /* Right border */
569569      for ( int i = TMS9928A_HORZ_DISPLAY_START + 256; i < TMS9928A_TOTAL_HORZ; i++ )
570         p[i] = BackColour;
570         p[i] = m_palette[BackColour];
571571   }
572572
573573   /* Schedule next callback */
r18101r18102
575575}
576576
577577
578UINT32 tms9928a_device::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
578UINT32 tms9928a_device::screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect )
579579{
580580   copybitmap( bitmap, m_tmpbmp, 0, 0, 0, 0, cliprect );
581581   return 0;
r18101r18102
600600
601601void tms9928a_device::device_start()
602602{
603   m_screen = machine().device<screen_device>( m_screen_tag );
603    astring tempstring;
604    m_screen = downcast<screen_device *>(machine().device(siblingtag(tempstring,m_screen_tag)));
604605   assert( m_screen != NULL );
605606
606607   m_top_border = m_50hz ? TMS9928A_VERT_DISPLAY_START_PAL : TMS9928A_VERT_DISPLAY_START_NTSC;
r18101r18102
616617
617618   m_line_timer = timer_alloc(TIMER_LINE);
618619
619   palette_set_colors(machine(), 0, tms9928a_palette, TMS9928A_PALETTE_SIZE);
620   /* copy default palette into working palette */
621    for (int i = 0; i < TMS9928A_PALETTE_SIZE; i++)
622    {
623      m_palette[i] = tms9928a_palette[i];
624    }
620625
621626   save_item(NAME(m_Regs[0]));
622627   save_item(NAME(m_Regs[1]));
r18101r18102
641646   save_item(NAME(m_spriteattribute));
642647   save_item(NAME(m_spritepattern));
643648   save_item(NAME(m_mode));
649   save_item(NAME(m_palette));
644650}
645651
646652
trunk/src/emu/video/tms9928a.h
r18101r18102
4949
5050#define MCFG_TMS9928A_ADD(_tag, _variant, _config) \
5151   MCFG_DEVICE_ADD(_tag, _variant, XTAL_10_738635MHz / 2 ) \
52   MCFG_DEVICE_CONFIG(_config) \
53   MCFG_PALETTE_LENGTH(TMS9928A_PALETTE_SIZE) \
52   MCFG_DEVICE_CONFIG(_config)
5453
5554
5655#define MCFG_TMS9928A_SCREEN_ADD_NTSC(_screen_tag) \
r18101r18102
8483};
8584
8685
87PALETTE_INIT( tms9928a );
88
89
9086class tms9928a_device :   public device_t,
9187                  public device_memory_interface,
9288                  public tms9928a_interface
r18101r18102
10298   DECLARE_WRITE8_MEMBER( register_write );
10399
104100   /* update the screen */
105   UINT32 screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
106   bitmap_ind16 &get_bitmap() { return m_tmpbmp; }
101   UINT32 screen_update( screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect );
102   bitmap_rgb32 &get_bitmap() { return m_tmpbmp; }
107103
108104   /* RESET pin */
109105   void reset_line(int state) { if (state==ASSERT_LINE) device_reset(); }
r18101r18102
145141   devcb_resolved_write_line   m_irq_changed;
146142   bool   m_50hz;
147143   bool   m_reva;
144   rgb_t   m_palette[16];
148145
149146   /* memory */
150147   const address_space_config      m_space_config;
151148   address_space*               m_vram_space;
152149
153   bitmap_ind16 m_tmpbmp;
150   bitmap_rgb32 m_tmpbmp;
154151   emu_timer   *m_line_timer;
155152   UINT8      m_mode;
156153
trunk/src/mess/drivers/einstein.c
r18101r18102
486486   if (&screen == m_color_screen)
487487   {
488488      tms9929a_device *tms9929a = machine().device<tms9929a_device>( "tms9929a" );
489      const rgb_t *palette = palette_entry_list_raw(bitmap.palette());
490      bitmap_ind16 &src = tms9929a->get_bitmap();
489      bitmap_rgb32 &src = tms9929a->get_bitmap();
491490      for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
492491         for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
493            bitmap.pix32(y, x) = palette[src.pix16(y, x)];
492            bitmap.pix32(y, x) = src.pix32(y, x);
494493   }
495494   else if (&screen == m_crtc_screen)
496495      m_mc6845->screen_update( screen, bitmap, cliprect);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team