summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/drivers/cit101.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/cit101.cpp')
-rw-r--r--src/mame/drivers/cit101.cpp123
1 files changed, 74 insertions, 49 deletions
diff --git a/src/mame/drivers/cit101.cpp b/src/mame/drivers/cit101.cpp
index 0ebbab007a5..160c538eab3 100644
--- a/src/mame/drivers/cit101.cpp
+++ b/src/mame/drivers/cit101.cpp
@@ -81,6 +81,7 @@ public:
protected:
virtual void machine_start() override;
private:
+ void draw_line(uint32_t *pixptr, int minx, int maxx, int line, bool last_line, u16 rowaddr, u16 rowattr, u8 scrattr);
u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
DECLARE_READ8_MEMBER(c000_ram_r);
@@ -122,63 +123,87 @@ void cit101_state::machine_start()
save_item(NAME(m_blink));
}
+
+void cit101_state::draw_line(uint32_t *pixptr, int minx, int maxx, int line, bool last_line, u16 rowaddr, u16 rowattr, u8 scrattr)
+{
+ // Character attribute bit 0: underline (also used to render cursor)
+ // Character attribute bit 1: reverse video (also used to render cursor)
+ // Character attribute bit 2: boldface
+ // Character attribute bit 3: blinking (half intensity)
+
+ const int char_width = BIT(scrattr, 1) ? 10 : 9;
+ int c = 0;
+ u8 attr = m_extraram[rowaddr];
+ u8 char_data = m_chargen[(m_mainram[rowaddr] << 4) | line];
+ if (last_line && BIT(attr, 0))
+ char_data ^= 0xff;
+ rgb_t on_color = BIT(attr, 1) ? rgb_t::black() : rgb_t::white();
+ rgb_t off_color = BIT(attr, 1) ? rgb_t::white() : rgb_t::black();
+ if (BIT(attr, 3) && m_blink)
+ on_color = rgb_t(0xc0, 0xc0, 0xc0);
+ bool last_bit = false;
+ for (int x = 0; x <= maxx; x++)
+ {
+ const bool cur_bit = BIT(char_data, 7);
+ if (x >= minx)
+ pixptr[x] = (cur_bit || (BIT(attr, 2) && last_bit)) ? on_color : off_color;
+ last_bit = cur_bit;
+
+ c++;
+ if (!BIT(rowattr, 9) || !BIT(c, 0))
+ {
+ if (c < (BIT(rowattr, 9) ? char_width << 1 : char_width))
+ char_data = (char_data << 1) | (char_data & 1);
+ else
+ {
+ c = 0;
+ rowaddr = (rowaddr + 1) & 0x3fff;
+ attr = m_extraram[rowaddr];
+ char_data = m_chargen[(m_mainram[rowaddr] << 4) | line];
+ if (last_line && BIT(attr, 0))
+ char_data ^= 0xff;
+ on_color = BIT(attr, 1) ? rgb_t::black() : rgb_t::white();
+ off_color = BIT(attr, 1) ? rgb_t::white() : rgb_t::black();
+ if (BIT(attr, 3) && m_blink)
+ on_color = rgb_t(0xc0, 0xc0, 0xc0);
+ last_bit = false;
+ }
+ }
+ }
+}
+
u32 cit101_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
- const int char_width = BIT(m_extraram[0], 1) ? 10 : 9;
- const u16 ptrbase = m_mainram[0];
+ const u8 scrattr = m_extraram[0];
- for (int y = cliprect.top(); y <= cliprect.bottom(); y++)
+ int y = 0;
+ for (u16 rowptr = m_mainram[0]; y <= cliprect.bottom(); rowptr += 2)
{
- const int row = y / 10;
- u16 rowaddr = m_mainram[row * 2 + ptrbase + 1] | (m_extraram[row * 2 + ptrbase + 1] & 0x3f) << 8;
- const u16 rowattr = m_mainram[row * 2 + ptrbase] | m_extraram[row * 2 + ptrbase] << 8;
- const int line = ((y % 10) / (BIT(rowattr, 8) ? 2 : 1) + (rowattr & 0x000f)) & 0xf;
-
- // Character attribute bit 0: underline (also used to render cursor)
- // Character attribute bit 1: reverse video (also used to render cursor)
- // Character attribute bit 2: boldface
- // Character attribute bit 3: blinking (half intensity)
-
- int c = 0;
- u8 attr = m_extraram[rowaddr];
- u8 char_data = m_chargen[(m_mainram[rowaddr] << 4) | line];
- if (line == 9 && BIT(attr, 0))
- char_data ^= 0xff;
- rgb_t on_color = BIT(attr, 1) ? rgb_t::black() : rgb_t::white();
- rgb_t off_color = BIT(attr, 1) ? rgb_t::white() : rgb_t::black();
- if (BIT(attr, 3) && m_blink)
- on_color = rgb_t(0xc0, 0xc0, 0xc0);
- bool last_bit = false;
- for (int x = screen.visible_area().left(); x <= screen.visible_area().right(); x++)
- {
- const bool cur_bit = BIT(char_data, 7);
- if (x >= cliprect.left() && x <= cliprect.right())
- bitmap.pix32(y, x) = (cur_bit || (BIT(attr, 2) && last_bit)) ? on_color : off_color;
- last_bit = cur_bit;
+ const u16 rowattr = m_mainram[rowptr] | m_extraram[rowptr] << 8;
+ const int rowlines = 16 - ((rowattr & 0x0f0) >> 4);
- c++;
- if (!BIT(rowattr, 9) || !BIT(c, 0))
+ int z = 0;
+ if (y < cliprect.top())
+ {
+ z = cliprect.top() - y;
+ if (z >= rowlines)
{
- if (c < (BIT(rowattr, 9) ? char_width << 1 : char_width))
- char_data = (char_data << 1) | (char_data & 1);
- else
- {
- c = 0;
- rowaddr++;
- attr = m_extraram[rowaddr];
- char_data = m_chargen[(m_mainram[rowaddr] << 4) | line];
- if (line == 9 && BIT(attr, 0))
- char_data ^= 0xff;
- on_color = BIT(attr, 1) ? rgb_t::black() : rgb_t::white();
- off_color = BIT(attr, 1) ? rgb_t::white() : rgb_t::black();
- if (BIT(attr, 3) && m_blink)
- on_color = rgb_t(0xc0, 0xc0, 0xc0);
- last_bit = false;
- }
+ y += rowlines;
+ continue;
}
+ y = cliprect.top();
}
- }
+ const u16 rowaddr = m_mainram[rowptr + 1] | (m_extraram[rowptr + 1] & 0x3f) << 8;
+ while (y <= cliprect.bottom())
+ {
+ const int line = ((z / (BIT(rowattr, 8) ? 2 : 1)) + (rowattr & 0x00f)) & 15;
+ const bool last_line = z++ == rowlines - 1;
+ draw_line(&bitmap.pix32(y++), cliprect.left(), cliprect.right(), line, last_line, rowaddr, rowattr, scrattr);
+ if (last_line)
+ break;
+ }
+ }
return 0;
}
@@ -394,4 +419,4 @@ ROM_START( cit101 )
ROM_LOAD( "5g_=7f00=.bin", 0x160, 0x020, NO_DUMP ) // position labeled TBP18S030
ROM_END
-COMP( 1980, cit101, 0, 0, cit101, cit101, cit101_state, empty_init, "C. Itoh Electronics", "CIT-101", MACHINE_IMPERFECT_GRAPHICS | MACHINE_NOT_WORKING )
+COMP( 1980, cit101, 0, 0, cit101, cit101, cit101_state, empty_init, "C. Itoh Electronics", "CIT-101", MACHINE_NOT_WORKING )