Previous 199869 Revisions Next

r17795 Tuesday 11th September, 2012 at 14:28:51 UTC by Curt Coder
(MESS) mos8563: Fixed attributes. (nw)
[src/emu/video]mc6845.c mc6845.h

trunk/src/emu/video/mc6845.c
r17794r17795
2222
2323**********************************************************************/
2424
25/*
26
27   TODO:
28
29   - mos8563
30
31      - horizontal scroll
32      - vertical scroll
33      - pixel double width
34      - bitmap modes
35      - display enable begin/end
36
37*/
38
2539#include "emu.h"
2640#include "mc6845.h"
2741#include "machine/devhelpr.h"
r17794r17795
369383      case 0x15:  m_attribute_addr   = ((data & 0xff) << 0) | (m_attribute_addr & 0xff00); break;
370384      case 0x16:    m_horiz_char       =   data & 0xff; break;
371385      case 0x17:   m_vert_char_disp   =   data & 0x1f; break;
372      case 0x18:   m_vert_scroll      =   data & 0x1f; break;
373      case 0x19:   m_horiz_scroll      =   data & 0x1f; break;
386      case 0x18:   m_vert_scroll      =   data & 0xff; break;
387      case 0x19:   m_horiz_scroll      =   data & 0xff; break;
374388      case 0x1a:   m_color               =   data & 0xff; break;
375389      case 0x1b:   m_row_addr_incr      =   data & 0xff; break;
376390      case 0x1c:   m_char_base_addr   =   data & 0xf0; break;
r17794r17795
856870}
857871
858872
873UINT8 mc6845_device::draw_scanline(int y, bitmap_rgb32 &bitmap, const rectangle &cliprect, void *param)
874{
875   /* compute the current raster line */
876   UINT8 ra = y % (m_max_ras_addr + 1);
877
878   /* check if the cursor is visible and is on this scanline */
879   int cursor_visible = m_cursor_state &&
880                  (ra >= (m_cursor_start_ras & 0x1f)) &&
881                  (ra <= m_cursor_end_ras) &&
882                  (m_cursor_addr >= m_current_disp_addr) &&
883                  (m_cursor_addr < (m_current_disp_addr + m_horiz_disp));
884
885   /* compute the cursor X position, or -1 if not visible */
886   INT8 cursor_x = cursor_visible ? (m_cursor_addr - m_current_disp_addr) : -1;
887
888   /* call the external system to draw it */
889   if (MODE_ROW_COLUMN_ADDRESSING)
890   {
891      UINT8 cc = 0;
892      UINT8 cr = y / (m_max_ras_addr + 1);
893      UINT16 ma = (cr << 8) | cc;
894
895      m_update_row(this, bitmap, cliprect, ma, ra, y, m_horiz_disp, cursor_x, param);
896   }
897   else
898   {
899      m_update_row(this, bitmap, cliprect, m_current_disp_addr, ra, y, m_horiz_disp, cursor_x, param);
900   }
901
902   /* update MA if the last raster address */
903   if (ra == m_max_ras_addr)
904      m_current_disp_addr = (m_current_disp_addr + m_horiz_disp) & 0x3fff;
905
906   return ra;
907}
908
909
859910UINT32 mc6845_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
860911{
861912   assert(bitmap.valid());
r17794r17795
881932      /* for each row in the visible region */
882933      for (y = cliprect.min_y; y <= cliprect.max_y; y++)
883934      {
884         /* compute the current raster line */
885         UINT8 ra = y % (m_max_ras_addr + 1);
886
887         /* check if the cursor is visible and is on this scanline */
888         int cursor_visible = m_cursor_state &&
889                        (ra >= (m_cursor_start_ras & 0x1f)) &&
890                        (ra <= m_cursor_end_ras) &&
891                        (m_cursor_addr >= m_current_disp_addr) &&
892                        (m_cursor_addr < (m_current_disp_addr + m_horiz_disp));
893
894         /* compute the cursor X position, or -1 if not visible */
895         INT8 cursor_x = cursor_visible ? (m_cursor_addr - m_current_disp_addr) : -1;
896
897         /* call the external system to draw it */
898         if (MODE_ROW_COLUMN_ADDRESSING)
899         {
900            UINT8 cc = 0;
901            UINT8 cr = y / (m_max_ras_addr + 1);
902            UINT16 ma = (cr << 8) | cc;
903
904            m_update_row(this, bitmap, cliprect, ma, ra, y, m_horiz_disp, cursor_x, param);
905         }
906         else
907         {
908            m_update_row(this, bitmap, cliprect, m_current_disp_addr, ra, y, m_horiz_disp, cursor_x, param);
909         }
910
911         /* update MA if the last raster address */
912         if (ra == m_max_ras_addr)
913            m_current_disp_addr = (m_current_disp_addr + m_horiz_disp) & 0x3fff;
935         this->draw_scanline(y, bitmap, cliprect, param);
914936      }
915937
916938      /* call the tear down function if any */
r17794r17795
11711193
11721194   m_update_row = vdc_update_row;
11731195
1196   m_char_blink_state = false;
1197   m_char_blink_count = 0;
1198   m_attribute_addr = 0;
1199   m_horiz_char = 0;
1200   m_vert_char_disp = 0;
1201   m_vert_scroll = 0;
1202   m_horiz_scroll = 0;
1203   m_color = 0;
1204   m_row_addr_incr = 0;
1205   m_char_base_addr = 0;
1206   m_underline_ras = 0;
1207   m_word_count = 0;
1208   m_data = 0;
1209   m_block_addr = 0;
1210   m_de_begin = 0;
1211   m_dram_refresh = 0;
1212   m_sync_polarity = 0;
1213
11741214   save_item(NAME(m_char_buffer));
11751215   save_item(NAME(m_attr_buffer));
11761216   save_item(NAME(m_attribute_addr));
r17794r17795
11871227   save_item(NAME(m_block_addr));
11881228   save_item(NAME(m_de_begin));
11891229   save_item(NAME(m_dram_refresh));
1230   save_item(NAME(m_sync_polarity));
11901231}
11911232
11921233
11931234void mos8568_device::device_start()
11941235{
11951236   mos8563_device::device_start();
1196
1197   save_item(NAME(m_sync_polarity));
11981237}
11991238
12001239
r17794r17795
13621401};
13631402
13641403
1404void mos8563_device::update_cursor_state()
1405{
1406   mc6845_device::update_cursor_state();
1407
1408   /* save and increment character blink counter */
1409   UINT8 last_char_blink_count = m_char_blink_count;
1410   m_char_blink_count++;
1411
1412   /* switch on character blinking mode */
1413   if (VSS_CBRATE)
1414   {
1415      if ((last_char_blink_count & 0x20) != (m_char_blink_count & 0x20))
1416         m_char_blink_state = !m_char_blink_state;
1417   }
1418   else
1419   {
1420      if ((last_char_blink_count & 0x10) != (m_char_blink_count & 0x10))
1421         m_char_blink_state = !m_char_blink_state;
1422   }
1423}
1424
1425
1426UINT8 mos8563_device::draw_scanline(int y, bitmap_rgb32 &bitmap, const rectangle &cliprect, void *param)
1427{
1428   UINT8 ra = mc6845_device::draw_scanline(y, bitmap, cliprect, param);
1429
1430   if (ra == m_max_ras_addr)
1431      m_current_disp_addr = (m_current_disp_addr + m_row_addr_incr) & 0x3fff;
1432
1433   return ra;
1434}
1435
1436
13651437void mos8563_device::update_row(bitmap_rgb32 &bitmap, const rectangle &cliprect, UINT16 ma, UINT8 ra, UINT16 y, UINT8 x_count, INT8 cursor_x, void *param)
13661438{
13671439   for (int column = 0; column < x_count; column++)
r17794r17795
13721444      }
13731445      else
13741446      {
1375         UINT8 code = read_videoram(ma + column);
1447         UINT16 code = read_videoram(ma + column);
13761448
1377         offs_t attr_addr = m_attribute_addr + column;
1449         offs_t attr_addr = m_attribute_addr + (ma - m_disp_start_addr) + column;
13781450         UINT8 attr = 0;
13791451
13801452         UINT8 cth = (m_horiz_char >> 4) + 1;
r17794r17795
13971469
13981470         offs_t font_addr;
13991471
1472         code |= ATTR_ALTERNATE_CHARSET << 8;
1473
14001474         if (m_max_ras_addr < 16)
1401            font_addr = ((m_char_base_addr >> 5) << 13) | (ATTR_ALTERNATE_CHARSET << 12) | (code << 4) | ra;
1475            font_addr = ((m_char_base_addr >> 5) << 13) | (code << 4) | ra;
14021476         else
1403            font_addr = ((m_char_base_addr >> 5) << 13) | (ATTR_ALTERNATE_CHARSET << 13) | (code << 5) | ra;
1477            font_addr = ((m_char_base_addr >> 5) << 13) | (code << 5) | ra;
14041478
14051479         UINT8 data = read_videoram(font_addr);
14061480
14071481         if (column == cursor_x) data = 0xff;
14081482         if (ra >= cdv) data = 0;
14091483         if (ATTR_UNDERLINE && (ra == m_underline_ras)) data = 0xff;
1484         if (ATTR_BLINK && !m_char_blink_state) data = 0;
14101485
14111486         if (ATTR_REVERSE)
14121487         {
r17794r17795
14141489            bg = fg;
14151490            fg = temp;
14161491         }
1417         // TODO ATTR_BLINK
14181492
1419         for (int bit = 0; bit < MIN(cdh, 8); bit++)
1493         for (int bit = 0; bit < cdh; bit++)
14201494         {
14211495            int x = (column * cth) + bit;
14221496
1423            bitmap.pix32(y, x) = MOS8563_PALETTE[BIT(data, 7) ? fg : bg];
1424            data <<= 1;
1497            bitmap.pix32(y, x) = MOS8563_PALETTE[(BIT(data, 7) ^ VSS_RVS) ? fg : bg];
1498
1499            if ((bit < 8) || !HSS_SEMI) data <<= 1;
14251500         }
14261501      }
14271502   }
trunk/src/emu/video/mc6845.h
r17794r17795
283283   void set_vsync(int state);
284284   void set_cur(int state);
285285   void handle_line_timer();
286   void update_cursor_state();
286   virtual void update_cursor_state();
287   virtual UINT8 draw_scanline(int y, bitmap_rgb32 &bitmap, const rectangle &cliprect, void *param);
287288};
288289
289290
r17794r17795
407408   UINT8 m_char_buffer[80];
408409   UINT8 m_attr_buffer[80];
409410
411   bool   m_char_blink_state;
412   UINT8   m_char_blink_count;
413
410414   /* register file */
411415   UINT16   m_attribute_addr;      /* 0x14/0x15 */
412416   UINT8   m_horiz_char;         /* 0x16 */
r17794r17795
423427   UINT16   m_de_begin;            /* 0x22/0x23 */
424428   UINT8   m_dram_refresh;         /* 0x24 */
425429   UINT8   m_sync_polarity;      /* 0x25 */
430
431   virtual void update_cursor_state();
432   virtual UINT8 draw_scanline(int y, bitmap_rgb32 &bitmap, const rectangle &cliprect, void *param);
426433};
427434
428435class mos8568_device : public mos8563_device

Previous 199869 Revisions Next


© 1997-2024 The MAME Team