diff --git a/src/mame/drivers/tk635.cpp b/src/mame/drivers/tk635.cpp index 7ef69bd3637..996f63e094f 100644 --- a/src/mame/drivers/tk635.cpp +++ b/src/mame/drivers/tk635.cpp @@ -19,7 +19,6 @@ Notes: - Identical to the Qume QVT-72 Plus? - - Character shape defintions start at 0x20000 in the ROM TODO: - Everything @@ -36,7 +35,11 @@ class tk635_state : public driver_device public: tk635_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), - m_maincpu(*this, "maincpu") + m_maincpu(*this, "maincpu"), + m_ram(*this, "ram"), + m_charram(*this, "charram"), + m_nmi_enable(false), + m_voffset(0) { } void tk635(machine_config &config); @@ -47,37 +50,139 @@ protected: private: required_device m_maincpu; + required_shared_ptr m_ram; + required_shared_ptr m_charram; void mem_map(address_map &map); void io_map(address_map &map); uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); + void vblank_w(int state); + + uint8_t unk_00_r(); + void voffset_lsb_w(uint8_t data); + void voffset_msb_w(uint8_t data); + uint8_t unk_11_r(); + uint8_t unk_19_r(); + void unk_f0_w(uint8_t data); + + bool m_nmi_enable; + uint16_t m_voffset; }; void tk635_state::mem_map(address_map &map) { - map(0x00000, 0x1ffff).ram(); + map(0x00000, 0x1ffff).ram().share("ram"); + map(0x20000, 0x23fff).ram().share("charram"); map(0xc0000, 0xfffff).rom().region("maincpu", 0); } void tk635_state::io_map(address_map &map) { + map(0x00, 0x00).r(FUNC(tk635_state::unk_00_r)); + map(0x04, 0x04).w(FUNC(tk635_state::voffset_lsb_w)); + map(0x05, 0x05).w(FUNC(tk635_state::voffset_msb_w)); + map(0x11, 0x11).r(FUNC(tk635_state::unk_11_r)); +// map(0x13, 0x13).ram(); // host port + map(0x19, 0x19).r(FUNC(tk635_state::unk_19_r)); +// map(0x1b, 0x1b).ram(); // aux port + map(0xf0, 0xf0).w(FUNC(tk635_state::unk_f0_w)); } static INPUT_PORTS_START( tk635 ) INPUT_PORTS_END +static const gfx_layout char_layout_8x16 = +{ + 8, 16, + 512, + 1, + { 0 }, + { STEP8(0, 1) }, + { STEP16(0, 8) }, + 8*32 +}; + +static GFXDECODE_START(chars) + GFXDECODE_RAM("charram", 0, char_layout_8x16, 0, 1) +GFXDECODE_END + uint32_t tk635_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { + for (int y = 0; y < 26; y++) + { + for (int x = 0; x < 132; x++) + { + uint8_t code = m_ram[(0x10000 | m_voffset) + (y * 132) + x]; + + // draw 16 lines + for (int i = 0; i < 16; i++) + { + uint8_t data = m_charram[(code << 5) + i]; + + // 8 pixels of the character + for (int p = 0; p < 8; p++) + bitmap.pix32(y * 16 + i, x * 9 + p) = BIT(data, 7 - p) ? rgb_t::white() : rgb_t::black(); + + // 9th pixel empty + bitmap.pix32(y * 16 + i, x * 9 + 8) = rgb_t::black(); + } + } + } + return 0; } +void tk635_state::vblank_w(int state) +{ + if (state == 1 && m_nmi_enable) + m_maincpu->pulse_input_line(INPUT_LINE_NMI, attotime::zero); +} + +uint8_t tk635_state::unk_00_r() +{ + logerror("unk_00_r: %02x\n", 0x10); + return 0x10; +} + +void tk635_state::voffset_lsb_w(uint8_t data) +{ + m_voffset = (m_voffset & 0xff00) | data; +} + +void tk635_state::voffset_msb_w(uint8_t data) +{ + m_voffset = (data << 8) | (m_voffset & 0x00ff); +} + +uint8_t tk635_state::unk_11_r() +{ + logerror("unk_11_r: %02x\n", 0x09); + return 0x09; +} + +uint8_t tk635_state::unk_19_r() +{ + logerror("unk_19_r: %02x\n", 0x09); + return 0x09; +} + +void tk635_state::unk_f0_w(uint8_t data) +{ + logerror("unk_f0_w: %02x\n", data); + m_nmi_enable = true; +} + void tk635_state::machine_start() { + // register for save states + save_item(NAME(m_nmi_enable)); + save_item(NAME(m_voffset)); } void tk635_state::machine_reset() { + m_nmi_enable = false; } void tk635_state::tk635(machine_config &config) @@ -90,10 +195,13 @@ void tk635_state::tk635(machine_config &config) screen.set_refresh_hz(70); screen.set_vblank_time(ATTOSECONDS_IN_USEC(2500)); // not accurate screen.set_screen_update(FUNC(tk635_state::screen_update)); - screen.set_size(800, 600); - screen.set_visarea(0, 800-1, 0, 600-1); + screen.set_size(1188, 416); + screen.set_visarea(0, 1188-1, 0, 416-1); + screen.screen_vblank().set(FUNC(tk635_state::vblank_w)); PALETTE(config, "palette").set_entries(16); + + GFXDECODE(config, "gfxdecode", "palette", chars); } ROM_START( tk635 ) @@ -101,4 +209,4 @@ ROM_START( tk635 ) ROM_LOAD("fw_v0_23.bin", 0x00000, 0x40000, CRC(bec6fdae) SHA1(37dc46f6b761d874bd1627a1137bc4082e364698)) ROM_END -COMP( 199?, tk635, 0, 0, tk635, tk635, tk635_state, empty_init, "Termtek", "TK-635", MACHINE_IS_SKELETON ) +COMP( 199?, tk635, 0, 0, tk635, tk635, tk635_state, empty_init, "Termtek", "TK-635", MACHINE_NOT_WORKING | MACHINE_NO_SOUND | MACHINE_SUPPORTS_SAVE )