diff --git a/src/emu/video/crt9007.c b/src/emu/video/crt9007.c index ca465e7976a..19b420f11f1 100644 --- a/src/emu/video/crt9007.c +++ b/src/emu/video/crt9007.c @@ -38,15 +38,20 @@ #include "crt9007.h" -// device type definition -const device_type CRT9007 = &device_creator; + +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type CRT9007 = &device_creator; + //************************************************************************** // MACROS / CONSTANTS //************************************************************************** -#define LOG 0 +#define LOG 1 #define HAS_VALID_PARAMETERS \ (m_reg[0x00] && m_reg[0x01] && m_reg[0x07] && m_reg[0x08] && m_reg[0x09]) @@ -217,7 +222,7 @@ const int STATUS_LIGHT_PEN_UPDATE = 0x20; //************************************************************************** // default address map -static ADDRESS_MAP_START( crt9007, AS_0, 8, crt9007_device ) +static ADDRESS_MAP_START( crt9007, AS_0, 8, crt9007_t ) AM_RANGE(0x0000, 0x3fff) AM_RAM ADDRESS_MAP_END @@ -231,7 +236,7 @@ ADDRESS_MAP_END // readbyte - read a byte at the given address //------------------------------------------------- -inline UINT8 crt9007_device::readbyte(offs_t address) +inline UINT8 crt9007_t::readbyte(offs_t address) { return space().read_byte(address); } @@ -241,7 +246,7 @@ inline UINT8 crt9007_device::readbyte(offs_t address) // trigger_interrupt - //------------------------------------------------- -inline void crt9007_device::trigger_interrupt(int line) +inline void crt9007_t::trigger_interrupt(int line) { if (INTERRUPT_ENABLE & line) { @@ -252,7 +257,7 @@ inline void crt9007_device::trigger_interrupt(int line) if (!(status & STATUS_INTERRUPT_PENDING)) { if (LOG) logerror("CRT9007 '%s' INT 1\n", tag()); - m_out_int_func(ASSERT_LINE); + m_write_int(ASSERT_LINE); } } } @@ -262,7 +267,7 @@ inline void crt9007_device::trigger_interrupt(int line) // update_cblank_line - //------------------------------------------------- -inline void crt9007_device::update_cblank_line() +inline void crt9007_t::update_cblank_line() { int x = m_screen->hpos(); int y = m_screen->vpos(); @@ -276,7 +281,7 @@ inline void crt9007_device::update_cblank_line() if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CBLANK %u\n", tag(), y, x, m_cblank); - m_out_cblank_func(m_cblank); + m_write_cblank(m_cblank); } } @@ -285,7 +290,7 @@ inline void crt9007_device::update_cblank_line() // update_hsync_timer - //------------------------------------------------- -inline void crt9007_device::update_hsync_timer(int state) +inline void crt9007_t::update_hsync_timer(int state) { int y = m_screen->vpos(); @@ -302,7 +307,7 @@ inline void crt9007_device::update_hsync_timer(int state) // update_vsync_timer - //------------------------------------------------- -inline void crt9007_device::update_vsync_timer(int state) +inline void crt9007_t::update_vsync_timer(int state) { int next_y = state ? m_vsync_start : m_vsync_end; @@ -316,7 +321,7 @@ inline void crt9007_device::update_vsync_timer(int state) // update_vlt_timer - //------------------------------------------------- -inline void crt9007_device::update_vlt_timer(int state) +inline void crt9007_t::update_vlt_timer(int state) { // this signal is active during all visible scan lines and during the horizontal trace at vertical retrace int y = m_screen->vpos(); @@ -334,7 +339,7 @@ inline void crt9007_device::update_vlt_timer(int state) // update_curs_timer - //------------------------------------------------- -inline void crt9007_device::update_curs_timer(int state) +inline void crt9007_t::update_curs_timer(int state) { // this signal is active for 1 character time for all scanlines within the data row // TODO @@ -345,7 +350,7 @@ inline void crt9007_device::update_curs_timer(int state) // update_drb_timer - //------------------------------------------------- -inline void crt9007_device::update_drb_timer(int state) +inline void crt9007_t::update_drb_timer(int state) { // this signal is active for 1 full scan line (VLT edge to edge) at the top scan line of each new row // there is 1 extra DRB signal during the 1st scanline of the vertical retrace interval @@ -381,7 +386,7 @@ inline void crt9007_device::update_drb_timer(int state) // update_dma_timer - //------------------------------------------------- -inline void crt9007_device::update_dma_timer() +inline void crt9007_t::update_dma_timer() { // TODO } @@ -391,7 +396,7 @@ inline void crt9007_device::update_dma_timer() // recompute_parameters - //------------------------------------------------- -inline void crt9007_device::recompute_parameters() +inline void crt9007_t::recompute_parameters() { // check that necessary registers have been loaded if (!HAS_VALID_PARAMETERS) return; @@ -444,55 +449,35 @@ inline void crt9007_device::recompute_parameters() //************************************************************************** //------------------------------------------------- -// crt9007_device - constructor +// crt9007_t - constructor //------------------------------------------------- -crt9007_device::crt9007_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, CRT9007, "SMC CRT9007", tag, owner, clock, "crt9007", __FILE__), - device_memory_interface(mconfig, *this), - device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007)) +crt9007_t::crt9007_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, CRT9007, "SMC CRT9007", tag, owner, clock, "crt9007", __FILE__), + device_memory_interface(mconfig, *this), + device_video_interface(mconfig, *this), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007)), + m_write_int(*this), + m_write_dmar(*this), + m_write_hs(*this), + m_write_vs(*this), + m_write_vlt(*this), + m_write_curs(*this), + m_write_drb(*this), + m_write_cblank(*this), + m_write_slg(*this), + m_write_sld(*this) { for (int i = 0; i < 0x3d; i++) m_reg[i] = 0; } -//------------------------------------------------- -// device_config_complete - perform any -// operations now that the configuration is -// complete -//------------------------------------------------- - -void crt9007_device::device_config_complete() -{ - // inherit a copy of the static data - const crt9007_interface *intf = reinterpret_cast(static_config()); - if (intf != NULL) - *static_cast(this) = *intf; - - // or initialize to defaults if none provided - else - { - memset(&m_out_int_cb, 0, sizeof(m_out_int_cb)); - memset(&m_out_dmar_cb, 0, sizeof(m_out_dmar_cb)); - memset(&m_out_vs_cb, 0, sizeof(m_out_vs_cb)); - memset(&m_out_hs_cb, 0, sizeof(m_out_hs_cb)); - memset(&m_out_vlt_cb, 0, sizeof(m_out_vlt_cb)); - memset(&m_out_curs_cb, 0, sizeof(m_out_curs_cb)); - memset(&m_out_drb_cb, 0, sizeof(m_out_drb_cb)); - memset(&m_out_cblank_cb, 0, sizeof(m_out_cblank_cb)); - memset(&m_out_slg_cb, 0, sizeof(m_out_slg_cb)); - memset(&m_out_sld_cb, 0, sizeof(m_out_sld_cb)); - } -} - - //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- -void crt9007_device::device_start() +void crt9007_t::device_start() { // allocate timers m_hsync_timer = timer_alloc(TIMER_HSYNC); @@ -503,22 +488,16 @@ void crt9007_device::device_start() m_dma_timer = timer_alloc(TIMER_DMA); // resolve callbacks - m_out_int_func.resolve(m_out_int_cb, *this); - m_out_dmar_func.resolve(m_out_dmar_cb, *this); - m_out_hs_func.resolve(m_out_hs_cb, *this); - m_out_vs_func.resolve(m_out_vs_cb, *this); - m_out_vlt_func.resolve(m_out_vlt_cb, *this); - m_out_curs_func.resolve(m_out_curs_cb, *this); - m_out_drb_func.resolve(m_out_drb_cb, *this); - m_out_cblank_func.resolve(m_out_cblank_cb, *this); - m_out_slg_func.resolve(m_out_slg_cb, *this); - m_out_sld_func.resolve(m_out_sld_cb, *this); - - // set horizontal pixels per column - m_hpixels_per_column = hpixels_per_column; - - // register for state saving -// state_save_register_device_item(this, 0, ); + m_write_int.resolve_safe(); + m_write_dmar.resolve_safe(); + m_write_hs.resolve_safe(); + m_write_vs.resolve_safe(); + m_write_vlt.resolve_safe(); + m_write_curs.resolve_safe(); + m_write_drb.resolve_safe(); + m_write_cblank.resolve_safe(); + m_write_slg.resolve_safe(); + m_write_sld.resolve_safe(); } @@ -526,43 +505,43 @@ void crt9007_device::device_start() // device_reset - device-specific reset //------------------------------------------------- -void crt9007_device::device_reset() +void crt9007_t::device_reset() { m_disp = 0; m_vs = 0; m_cblank = 0; // HS = 1 - m_out_hs_func(1); + m_write_hs(1); // VS = 1 - m_out_vs_func(1); + m_write_vs(1); // CBLANK = 1 - m_out_cblank_func(0); + m_write_cblank(0); // CURS = 0 - m_out_curs_func(0); + m_write_curs(0); // VLT = 0 - m_out_vlt_func(0); + m_write_vlt(0); // DRB = 1 - m_out_drb_func(1); + m_write_drb(1); // INT = 0 - m_out_int_func(CLEAR_LINE); + m_write_int(CLEAR_LINE); // 28 (DMAR) = 0 - m_out_dmar_func(CLEAR_LINE); + m_write_dmar(CLEAR_LINE); // 29 (WBEN) = 0 // 30 (SLG) = 0 - m_out_slg_func(0); + m_write_slg(0); // 31 (SLD) = 0 - m_out_sld_func(0); + m_write_sld(0); // 32 (LPSTB) = 0 } @@ -572,7 +551,7 @@ void crt9007_device::device_reset() // device_clock_changed - handle clock change //------------------------------------------------- -void crt9007_device::device_clock_changed() +void crt9007_t::device_clock_changed() { recompute_parameters(); } @@ -582,7 +561,7 @@ void crt9007_device::device_clock_changed() // device_timer - handle timer events //------------------------------------------------- -void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +void crt9007_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { int x = m_screen->hpos(); int y = m_screen->vpos(); @@ -594,7 +573,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para if (LOG) logerror("CRT9007 '%s' y %03u x %04u : HS %u\n", tag(), y, x, m_hs); - m_out_hs_func(m_hs); + m_write_hs(m_hs); update_cblank_line(); @@ -606,7 +585,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VS %u\n", tag(), y, x, m_vs); - m_out_vs_func(param); + m_write_vs(param); if (m_vs) { @@ -628,7 +607,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VLT %u\n", tag(), y, x, m_vlt); - m_out_vlt_func(param); + m_write_vlt(param); update_vlt_timer(param); break; @@ -636,7 +615,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para case TIMER_CURS: if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CURS %u\n", tag(), y, x, param); - m_out_curs_func(param); + m_write_curs(param); update_curs_timer(param); break; @@ -646,7 +625,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para if (LOG) logerror("CRT9007 '%s' y %03u x %04u : DRB %u\n", tag(), y, x, m_drb); - m_out_drb_func(param); + m_write_drb(param); if (!m_drb && !DMA_DISABLE) { @@ -657,7 +636,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para m_dmar = 1; if (LOG) logerror("CRT9007 '%s' DMAR 1\n", tag()); - m_out_dmar_func(ASSERT_LINE); + m_write_dmar(ASSERT_LINE); } update_drb_timer(param); @@ -677,7 +656,7 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para // any address spaces owned by this device //------------------------------------------------- -const address_space_config *crt9007_device::memory_space_config(address_spacenum spacenum) const +const address_space_config *crt9007_t::memory_space_config(address_spacenum spacenum) const { return (spacenum == AS_0) ? &m_space_config : NULL; } @@ -687,7 +666,7 @@ const address_space_config *crt9007_device::memory_space_config(address_spacenum // read - register read //------------------------------------------------- -READ8_MEMBER( crt9007_device::read ) +READ8_MEMBER( crt9007_t::read ) { UINT8 data = 0; @@ -717,7 +696,7 @@ READ8_MEMBER( crt9007_device::read ) // reset interrupt pending bit m_status &= ~STATUS_INTERRUPT_PENDING; if (LOG) logerror("CRT9007 '%s' INT 0\n", tag()); - m_out_int_func(CLEAR_LINE); + m_write_int(CLEAR_LINE); break; case 0x3b: @@ -743,7 +722,7 @@ READ8_MEMBER( crt9007_device::read ) // write - register write //------------------------------------------------- -WRITE8_MEMBER( crt9007_device::write ) +WRITE8_MEMBER( crt9007_t::write ) { m_reg[offset] = data; @@ -913,7 +892,7 @@ WRITE8_MEMBER( crt9007_device::write ) // ack_w - DMA acknowledge //------------------------------------------------- -WRITE_LINE_MEMBER( crt9007_device::ack_w ) +WRITE_LINE_MEMBER( crt9007_t::ack_w ) { if (LOG) logerror("CRT9007 '%s' ACK: %u\n", tag(), state); @@ -931,7 +910,7 @@ WRITE_LINE_MEMBER( crt9007_device::ack_w ) // lpstb_w - light pen strobe //------------------------------------------------- -WRITE_LINE_MEMBER( crt9007_device::lpstb_w ) +WRITE_LINE_MEMBER( crt9007_t::lpstb_w ) { if (LOG) logerror("CRT9007 '%s' LPSTB: %u\n", tag(), state); @@ -945,31 +924,12 @@ WRITE_LINE_MEMBER( crt9007_device::lpstb_w ) //------------------------------------------------- -// vlt_r - +// set_character_width - //------------------------------------------------- -READ_LINE_MEMBER( crt9007_device::vlt_r ) +void crt9007_t::set_character_width(int value) { - return m_vlt; -} + m_hpixels_per_column = value; - -//------------------------------------------------- -// wben_r - -//------------------------------------------------- - -READ_LINE_MEMBER( crt9007_device::wben_r ) -{ - return m_wben; -} - - -//------------------------------------------------- -// set_hpixels_per_column - -//------------------------------------------------- - -void crt9007_device::set_hpixels_per_column(int hpixels_per_column) -{ - m_hpixels_per_column = hpixels_per_column; recompute_parameters(); } diff --git a/src/emu/video/crt9007.h b/src/emu/video/crt9007.h index 75e680f5a91..51544110118 100644 --- a/src/emu/video/crt9007.h +++ b/src/emu/video/crt9007.h @@ -52,14 +52,38 @@ // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_CRT9007_ADD(_tag, _clock, _config, _map) \ - MCFG_DEVICE_ADD(_tag, CRT9007, _clock) \ - MCFG_DEVICE_CONFIG(_config) \ - MCFG_DEVICE_ADDRESS_MAP(AS_0, _map) +#define MCFG_CRT9007_CHARACTER_WIDTH(_value) \ + crt9007_t::static_set_character_width(*device, _value); +#define MCFG_CRT9007_INT_CALLBACK(_write) \ + devcb = &crt9007_t::set_int_wr_callback(*device, DEVCB2_##_write); -#define CRT9007_INTERFACE(name) \ - const crt9007_interface (name) = +#define MCFG_CRT9007_DMAR_CALLBACK(_write) \ + devcb = &crt9007_t::set_dmar_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_VS_CALLBACK(_write) \ + devcb = &crt9007_t::set_vs_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_HS_CALLBACK(_write) \ + devcb = &crt9007_t::set_hs_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_VLT_CALLBACK(_write) \ + devcb = &crt9007_t::set_vlt_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_CURS_CALLBACK(_write) \ + devcb = &crt9007_t::set_curs_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_DRB_CALLBACK(_write) \ + devcb = &crt9007_t::set_drb_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_CBLANK_CALLBACK(_write) \ + devcb = &crt9007_t::set_cblank_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_SLG_CALLBACK(_write) \ + devcb = &crt9007_t::set_slg_wr_callback(*device, DEVCB2_##_write); + +#define MCFG_CRT9007_SLD_CALLBACK(_write) \ + devcb = &crt9007_t::set_sld_wr_callback(*device, DEVCB2_##_write); @@ -67,53 +91,38 @@ // TYPE DEFINITIONS //************************************************************************** +// ======================> crt9007_t -// ======================> crt9007_interface - -struct crt9007_interface -{ - int hpixels_per_column; /* number of pixels per video memory address */ - - devcb_write_line m_out_int_cb; - devcb_write_line m_out_dmar_cb; - - devcb_write_line m_out_vs_cb; - devcb_write_line m_out_hs_cb; - - devcb_write_line m_out_vlt_cb; - devcb_write_line m_out_curs_cb; - devcb_write_line m_out_drb_cb; - devcb_write_line m_out_cblank_cb; - - devcb_write_line m_out_slg_cb; - devcb_write_line m_out_sld_cb; -}; - - - -// ======================> crt9007_device - -class crt9007_device : public device_t, - public device_memory_interface, - public device_video_interface, - public crt9007_interface +class crt9007_t : public device_t, + public device_memory_interface, + public device_video_interface { public: // construction/destruction - crt9007_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + crt9007_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + + static void static_set_character_width(device_t &device, int value) { downcast(device).m_hpixels_per_column = value; } + + template static devcb2_base &set_int_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_int.set_callback(object); } + template static devcb2_base &set_dmar_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_dmar.set_callback(object); } + template static devcb2_base &set_vs_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_vs.set_callback(object); } + template static devcb2_base &set_hs_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_hs.set_callback(object); } + template static devcb2_base &set_vlt_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_vlt.set_callback(object); } + template static devcb2_base &set_curs_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_curs.set_callback(object); } + template static devcb2_base &set_drb_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_drb.set_callback(object); } + template static devcb2_base &set_cblank_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_cblank.set_callback(object); } + template static devcb2_base &set_slg_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_slg.set_callback(object); } + template static devcb2_base &set_sld_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_sld.set_callback(object); } DECLARE_READ8_MEMBER( read ); DECLARE_WRITE8_MEMBER( write ); DECLARE_WRITE_LINE_MEMBER( ack_w ); DECLARE_WRITE_LINE_MEMBER( lpstb_w ); - DECLARE_READ_LINE_MEMBER( vlt_r ); - DECLARE_READ_LINE_MEMBER( wben_r ); - void set_hpixels_per_column(int hpixels_per_column); + void set_character_width(int value); protected: // device-level overrides - virtual void device_config_complete(); virtual void device_start(); virtual void device_reset(); virtual void device_clock_changed(); @@ -123,12 +132,15 @@ protected: virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const; private: - static const device_timer_id TIMER_HSYNC = 0; - static const device_timer_id TIMER_VSYNC = 1; - static const device_timer_id TIMER_VLT = 2; - static const device_timer_id TIMER_CURS = 3; - static const device_timer_id TIMER_DRB = 4; - static const device_timer_id TIMER_DMA = 5; + enum + { + TIMER_HSYNC, + TIMER_VSYNC, + TIMER_VLT, + TIMER_CURS, + TIMER_DRB, + TIMER_DMA + }; inline UINT8 readbyte(offs_t address); @@ -143,16 +155,19 @@ private: inline void recompute_parameters(); - devcb_resolved_write_line m_out_int_func; - devcb_resolved_write_line m_out_dmar_func; - devcb_resolved_write_line m_out_hs_func; - devcb_resolved_write_line m_out_vs_func; - devcb_resolved_write_line m_out_vlt_func; - devcb_resolved_write_line m_out_curs_func; - devcb_resolved_write_line m_out_drb_func; - devcb_resolved_write_line m_out_cblank_func; - devcb_resolved_write_line m_out_slg_func; - devcb_resolved_write_line m_out_sld_func; + // address space configurations + const address_space_config m_space_config; + + devcb2_write_line m_write_int; + devcb2_write_line m_write_dmar; + devcb2_write_line m_write_hs; + devcb2_write_line m_write_vs; + devcb2_write_line m_write_vlt; + devcb2_write_line m_write_curs; + devcb2_write_line m_write_drb; + devcb2_write_line m_write_cblank; + devcb2_write_line m_write_slg; + devcb2_write_line m_write_sld; // registers UINT8 m_reg[0x3d]; @@ -175,7 +190,7 @@ private: int m_cblank; int m_vlt; int m_drb; - int m_wben; + //int m_wben; //int m_slg; //int m_sld; int m_lpstb; @@ -194,9 +209,6 @@ private: emu_timer *m_curs_timer; emu_timer *m_drb_timer; emu_timer *m_dma_timer; - - // address space configurations - const address_space_config m_space_config; }; diff --git a/src/emu/video/crt9021.c b/src/emu/video/crt9021.c index 51921850ac3..f63d42a3327 100644 --- a/src/emu/video/crt9021.c +++ b/src/emu/video/crt9021.c @@ -14,8 +14,6 @@ TODO: - attributes - - reverse video - - character blank - character blink - underline - full/half intensity @@ -26,7 +24,6 @@ - character mode w/underline - double height characters - double width characters - - parallel scan line - serial scan line - cursor - underline @@ -35,16 +32,19 @@ - blinking reverse video - programmable character blink rate (75/25 duty) - programmable cursor blink rate (50/50 duty) - - data/attribute latches + - attribute latches */ -#include "emu.h" #include "crt9021.h" -// device type definition -const device_type CRT9021 = &device_creator; +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type CRT9021 = &device_creator; + //************************************************************************** @@ -54,41 +54,40 @@ const device_type CRT9021 = &device_creator; #define LOG 0 -// attributes -enum -{ - ATTRIBUTE_REVID = 0x80, - ATTRIBUTE_INT = 0x40, - ATTRIBUTE_BLINK = 0x20, - ATTRIBUTE_MS1 = 0x10, - ATTRIBUTE_MS0 = 0x08, - ATTRIBUTE_CHABL = 0x04, - ATTRIBUTE_BKC = 0x02, - ATTRIBUTE_BLC = 0x01 -}; - - - -//************************************************************************** -// INLINE HELPERS -//************************************************************************** - - //************************************************************************** // LIVE DEVICE //************************************************************************** //------------------------------------------------- -// crt9021_device - constructor +// crt9021_t - constructor //------------------------------------------------- -crt9021_device::crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, CRT9021, "SMC CRT9021", tag, owner, clock, "crt9021", __FILE__), - device_video_interface(mconfig, *this), - m_in_data_cb(*this), - m_in_attr_cb(*this), - m_in_atten_cb(*this) +crt9021_t::crt9021_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, CRT9021, "SMC CRT9021", tag, owner, clock, "crt9021", __FILE__), + device_video_interface(mconfig, *this), + m_data(0), + m_ms0(0), + m_ms1(0), + m_revid(0), + m_chabl(0), + m_blink(0), + m_intin(0), + m_atten(0), + m_cursor(0), + m_retbl(0), + m_ld_sh(1), + m_sld(1), + m_slg(0), + m_blc(0), + m_bkc(0), + m_sl0(0), + m_sl1(0), + m_sl2(0), + m_sl3(0), + m_vsync(0), + m_sr(0), + m_intout(0) { } @@ -97,21 +96,43 @@ crt9021_device::crt9021_device(const machine_config &mconfig, const char *tag, d // device_start - device-specific startup //------------------------------------------------- -void crt9021_device::device_start() +void crt9021_t::device_start() { // allocate timers + m_vdc_timer = timer_alloc(); - // resolve callbacks - m_in_data_cb.resolve_safe(0); - m_in_attr_cb.resolve_safe(0); - m_in_atten_cb.resolve_safe(0); + if (!m_display_cb.isnull()) + { + m_vdc_timer->adjust(clocks_to_attotime(8), 0, clocks_to_attotime(8)); + } - // register for state saving - save_item(NAME(m_slg)); - save_item(NAME(m_sld)); + // register bitmap + m_screen->register_screen_bitmap(m_bitmap); + + // state saving + save_item(NAME(m_data)); + save_item(NAME(m_ms0)); + save_item(NAME(m_ms1)); + save_item(NAME(m_revid)); + save_item(NAME(m_chabl)); + save_item(NAME(m_blink)); + save_item(NAME(m_intin)); + save_item(NAME(m_atten)); save_item(NAME(m_cursor)); save_item(NAME(m_retbl)); + save_item(NAME(m_ld_sh)); + save_item(NAME(m_sld)); + save_item(NAME(m_slg)); + save_item(NAME(m_blc)); + save_item(NAME(m_bkc)); + save_item(NAME(m_sl0)); + save_item(NAME(m_sl1)); + save_item(NAME(m_sl2)); + save_item(NAME(m_sl3)); save_item(NAME(m_vsync)); + save_item(NAME(m_sr)); + save_item(NAME(m_intout)); + save_item(NAME(m_sld)); } @@ -119,8 +140,12 @@ void crt9021_device::device_start() // device_clock_changed - handle clock change //------------------------------------------------- -void crt9021_device::device_clock_changed() +void crt9021_t::device_clock_changed() { + if (!m_display_cb.isnull()) + { + m_vdc_timer->adjust(clocks_to_attotime(8), 0, clocks_to_attotime(8)); + } } @@ -128,72 +153,57 @@ void crt9021_device::device_clock_changed() // device_timer - handle timer events //------------------------------------------------- -void crt9021_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +void crt9021_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { + m_display_cb(m_bitmap, m_screen->vpos(), m_screen->hpos(), m_sr, m_intout); } //------------------------------------------------- -// slg_w - scan line gate +// ld_sh_w - load/shift //------------------------------------------------- -WRITE_LINE_MEMBER( crt9021_device::slg_w ) +WRITE_LINE_MEMBER( crt9021_t::ld_sh_w ) { - if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state); + if (LOG) logerror("CRT9021 '%s' LD/SH: %u\n", tag(), state); - m_slg = state; -} - - -//------------------------------------------------- -// sld_w - scan line data -//------------------------------------------------- - -WRITE_LINE_MEMBER( crt9021_device::sld_w ) -{ - if (LOG) logerror("CRT9021 '%s' SLG: %u\n", tag(), state); - - if (!m_slg) + if (!m_ld_sh && state) { - m_sld <<= 1; - m_sld |= state; + // shift in scanline data + if (!m_slg) + { + m_sl >>= 1; + m_sl |= m_sld << 3; + } + + // latch data + if (m_retbl) + { + m_sr = 0; + } + else + { + m_sr = m_chabl ? 0 : m_data; + + if (m_revid) m_sr ^= 0xff; + } + + // latch attributes + if (m_atten) + { + // TODO + } } } -//------------------------------------------------- -// cursor_w - cursor -//------------------------------------------------- - -WRITE_LINE_MEMBER( crt9021_device::cursor_w ) -{ - if (LOG) logerror("CRT9021 '%s' CURSOR: %u\n", tag(), state); - - m_cursor = state; -} - - -//------------------------------------------------- -// retbl_w - retrace blank -//------------------------------------------------- - -WRITE_LINE_MEMBER( crt9021_device::retbl_w ) -{ - if (LOG) logerror("CRT9021 '%s' RETBL: %u\n", tag(), state); - - m_retbl = state; -} - - //------------------------------------------------- // vsync_w - vertical sync //------------------------------------------------- -WRITE_LINE_MEMBER( crt9021_device::vsync_w ) +WRITE_LINE_MEMBER( crt9021_t::vsync_w ) { if (LOG) logerror("CRT9021 '%s' VSYNC: %u\n", tag(), state); - - m_vsync = state; } @@ -201,7 +211,9 @@ WRITE_LINE_MEMBER( crt9021_device::vsync_w ) // screen_update - update screen //------------------------------------------------- -UINT32 crt9021_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) +UINT32 crt9021_t::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { + m_bitmap.fill(rgb_t::black, cliprect); + return 0; } diff --git a/src/emu/video/crt9021.h b/src/emu/video/crt9021.h index 6ef1b6f6fae..64f82753a85 100644 --- a/src/emu/video/crt9021.h +++ b/src/emu/video/crt9021.h @@ -35,47 +35,54 @@ -//************************************************************************** -// MACROS / CONSTANTS -//************************************************************************** - - - - //************************************************************************** // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_CRT9021_IN_DATA_CB(_devcb) \ - devcb = &crt9021_device::set_in_data_callback(*device, DEVCB2_##_devcb); +#define CRT9021_DRAW_CHARACTER_MEMBER(_name) void _name(bitmap_rgb32 &bitmap, int y, int x, UINT8 data, int intout) -#define MCFG_CRT9021_IN_ATTR_CB(_devcb) \ - devcb = &crt9021_device::set_in_attr_callback(*device, DEVCB2_##_devcb); -#define MCFG_CRT9021_IN_ATTEN_CB(_devcb) \ - devcb = &crt9021_device::set_in_atten_callback(*device, DEVCB2_##_devcb); +#define MCFG_CRT9021_DRAW_CHARACTER_CALLBACK_OWNER(_class, _method) \ + crt9021_t::static_set_display_callback(*device, crt9021_draw_character_delegate(&_class::_method, #_class "::" #_method, downcast<_class *>(owner))); + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** -// ======================> crt9021_device +typedef device_delegate crt9021_draw_character_delegate; -class crt9021_device : public device_t, - public device_video_interface + +// ======================> crt9021_t + +class crt9021_t : public device_t, + public device_video_interface { public: // construction/destruction - crt9021_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + crt9021_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - template static devcb2_base &set_in_data_callback(device_t &device, _Object object) { return downcast(device).m_in_data_cb.set_callback(object); } - template static devcb2_base &set_in_attr_callback(device_t &device, _Object object) { return downcast(device).m_in_attr_cb.set_callback(object); } - template static devcb2_base &set_in_atten_callback(device_t &device, _Object object) { return downcast(device).m_in_atten_cb.set_callback(object); } + static void static_set_display_callback(device_t &device, crt9021_draw_character_delegate callback) { downcast(device).m_display_cb = callback; } - DECLARE_WRITE_LINE_MEMBER( slg_w ); - DECLARE_WRITE_LINE_MEMBER( sld_w ); - DECLARE_WRITE_LINE_MEMBER( cursor_w ); - DECLARE_WRITE_LINE_MEMBER( retbl_w ); + DECLARE_WRITE8_MEMBER( write ) { m_data = data; } + DECLARE_WRITE_LINE_MEMBER( ms0_w ) { m_ms0 = state; } + DECLARE_WRITE_LINE_MEMBER( ms1_w ) { m_ms1 = state; } + DECLARE_WRITE_LINE_MEMBER( revid_w ) { m_revid = state; } + DECLARE_WRITE_LINE_MEMBER( chabl_w ) { m_chabl = state; } + DECLARE_WRITE_LINE_MEMBER( blink_w ) { m_blink = state; } + DECLARE_WRITE_LINE_MEMBER( intin_w ) { m_intin = state; } + DECLARE_WRITE_LINE_MEMBER( atten_w ) { m_atten = state; } + DECLARE_WRITE_LINE_MEMBER( cursor_w ) { m_cursor = state; } + DECLARE_WRITE_LINE_MEMBER( retbl_w ) { m_retbl = state; } + DECLARE_WRITE_LINE_MEMBER( ld_sh_w ); + DECLARE_WRITE_LINE_MEMBER( sld_w ) { m_sld = state; } + DECLARE_WRITE_LINE_MEMBER( slg_w ) { m_slg = state; } + DECLARE_WRITE_LINE_MEMBER( blc_w ) { m_blc = state; } + DECLARE_WRITE_LINE_MEMBER( bkc_w ) { m_bkc = state; } + DECLARE_WRITE_LINE_MEMBER( sl0_w ) { m_sl0 = state; } + DECLARE_WRITE_LINE_MEMBER( sl1_w ) { m_sl1 = state; } + DECLARE_WRITE_LINE_MEMBER( sl2_w ) { m_sl2 = state; } + DECLARE_WRITE_LINE_MEMBER( sl3_w ) { m_sl3 = state; } DECLARE_WRITE_LINE_MEMBER( vsync_w ); UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -87,16 +94,47 @@ protected: virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); private: - devcb2_read8 m_in_data_cb; - devcb2_read8 m_in_attr_cb; + enum + { + MS_WIDE_GRAPHICS, + MS_CHARACTER, + MS_THIN_GRAPHICS, + MS_UNDERLINE + }; - devcb2_read_line m_in_atten_cb; + crt9021_draw_character_delegate m_display_cb; - int m_slg; - int m_sld; + bitmap_rgb32 m_bitmap; + + // inputs + UINT8 m_data; + int m_ms0; + int m_ms1; + int m_revid; + int m_chabl; + int m_blink; + int m_intin; + int m_atten; int m_cursor; int m_retbl; + int m_ld_sh; + int m_sld; + int m_slg; + int m_blc; + int m_bkc; + int m_sl0; + int m_sl1; + int m_sl2; + int m_sl3; int m_vsync; + + // outputs + UINT8 m_sr; + int m_intout; + int m_sl; + + // timers + emu_timer *m_vdc_timer; }; diff --git a/src/emu/video/crt9212.c b/src/emu/video/crt9212.c index 971be9cdd25..b61b9ea3510 100644 --- a/src/emu/video/crt9212.c +++ b/src/emu/video/crt9212.c @@ -9,11 +9,26 @@ **********************************************************************/ -#include "emu.h" +/* + + TODO: + + - RCLK and WCLK are clocked simultaneously since that's what tandy2k does and we have no other users + +*/ + #include "crt9212.h" +//************************************************************************** +// DEVICE DEFINITIONS +//************************************************************************** + +const device_type CRT9212 = &device_creator; + + + //************************************************************************** // MACROS / CONSTANTS //************************************************************************** @@ -21,112 +36,94 @@ #define LOG 0 -#define REN \ - m_in_ren_cb() - -#define WEN \ - m_in_wen_cb() - -#define WEN2 \ - m_in_wen2_cb() - -#define ROF(_state) \ - m_out_rof_cb(_state); - -#define WOF(_state) \ - m_out_wof_cb(_state); - - - -//************************************************************************** -// INLINE HELPERS -//************************************************************************** - //************************************************************************** // LIVE DEVICE //************************************************************************** -// device type definition -const device_type CRT9212 = &device_creator; - //------------------------------------------------- -// crt9212_device - constructor +// crt9212_t - constructor //------------------------------------------------- -crt9212_device::crt9212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) - : device_t(mconfig, CRT9212, "SMC CRT9212", tag, owner, clock, "crt9212", __FILE__), - m_out_rof_cb(*this), - m_out_wof_cb(*this), - m_in_ren_cb(*this), - m_in_wen_cb(*this), - m_in_wen2_cb(*this) +crt9212_t::crt9212_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : + device_t(mconfig, CRT9212, "SMC CRT9212", tag, owner, clock, "crt9212", __FILE__), + m_write_dout(*this), + m_write_rof(*this), + m_write_wof(*this), + m_data(0), + m_clrcnt(0), + m_tog(0), + m_ren(0), + m_wen1(1), + m_wen2(0), + m_oe(0), + m_rclk(0), + m_wclk(0), + m_buffer(0), + m_rac(0), + m_wac(0) { } + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- -void crt9212_device::device_start() +void crt9212_t::device_start() { // resolve callbacks - m_out_rof_cb.resolve_safe(); - m_out_wof_cb.resolve_safe(); - m_in_ren_cb.resolve_safe(0); - m_in_wen_cb.resolve_safe(0); - m_in_wen2_cb.resolve_safe(0); + m_write_dout.resolve_safe(); + m_write_rof.resolve_safe(); + m_write_wof.resolve_safe(); - // register for state saving - save_item(NAME(m_input)); - save_item(NAME(m_output)); + // allocate timers + m_rwclk_timer = timer_alloc(); + + if (clock()) + { + m_rwclk_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock())); + } + + // state saving + save_item(NAME(m_data)); + save_item(NAME(m_clrcnt)); + save_item(NAME(m_tog)); + save_item(NAME(m_ren)); + save_item(NAME(m_wen1)); + save_item(NAME(m_wen2)); + save_item(NAME(m_oe)); + save_item(NAME(m_rclk)); + save_item(NAME(m_wclk)); + save_item(NAME(m_ram[0])); + save_item(NAME(m_ram[1])); save_item(NAME(m_buffer)); save_item(NAME(m_rac)); save_item(NAME(m_wac)); - save_item(NAME(m_tog)); - save_item(NAME(m_clrcnt)); - save_item(NAME(m_rclk)); - save_item(NAME(m_wclk)); } //------------------------------------------------- -// read - buffer read +// device_clock_changed - handle clock change //------------------------------------------------- -READ8_MEMBER( crt9212_device::read ) +void crt9212_t::device_clock_changed() { - return m_output; + m_rwclk_timer->adjust(attotime::from_hz(clock()), 0, attotime::from_hz(clock())); } //------------------------------------------------- -// write - buffer write +// device_timer - handle timer events //------------------------------------------------- -WRITE8_MEMBER( crt9212_device::write ) +void crt9212_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { - m_input = data; -} + rclk_w(1); + rclk_w(0); - -//------------------------------------------------- -// clrcnt_w - clear address counters -//------------------------------------------------- - -WRITE_LINE_MEMBER( crt9212_device::clrcnt_w ) -{ - m_clrcnt = state; -} - - -//------------------------------------------------- -// tog_w - toggle buffer -//------------------------------------------------- - -WRITE_LINE_MEMBER( crt9212_device::tog_w ) -{ - m_tog = state; + wclk_w(1); + wclk_w(0); } @@ -134,7 +131,7 @@ WRITE_LINE_MEMBER( crt9212_device::tog_w ) // rclk_w - read clock //------------------------------------------------- -WRITE_LINE_MEMBER( crt9212_device::rclk_w ) +WRITE_LINE_MEMBER( crt9212_t::rclk_w ) { if (m_rclk && !state) { @@ -147,21 +144,21 @@ WRITE_LINE_MEMBER( crt9212_device::rclk_w ) // clear write address counter m_wac = 0; - WOF(0); + m_write_wof(0); } else { // clear read address counter m_rac = 0; - ROF(0); + m_write_rof(0); } } else { - if (REN && (m_rac < CRT9212_RAM_SIZE)) + if (m_ren && (m_rac < CRT9212_RAM_SIZE)) { // - m_output = m_ram[m_rac][!m_buffer]; + m_write_dout(m_ram[m_rac][!m_buffer]); // increment read address counter m_rac++; @@ -169,7 +166,7 @@ WRITE_LINE_MEMBER( crt9212_device::rclk_w ) if (m_rac == CRT9212_RAM_SIZE) { // set read overflow - ROF(1); + m_write_rof(1); } } } @@ -183,14 +180,14 @@ WRITE_LINE_MEMBER( crt9212_device::rclk_w ) // wclk_w - write clock //------------------------------------------------- -WRITE_LINE_MEMBER( crt9212_device::wclk_w ) +WRITE_LINE_MEMBER( crt9212_t::wclk_w ) { - if (!m_rclk && state) + if (!m_wclk && state) { - if (WEN && WEN2 && (m_wac < CRT9212_RAM_SIZE)) + if (m_wen1 && m_wen2 && (m_wac < CRT9212_RAM_SIZE)) { // - m_ram[m_rac][m_buffer] = m_input; + m_ram[m_rac][m_buffer] = m_data; // increment read address counter m_wac++; @@ -198,7 +195,7 @@ WRITE_LINE_MEMBER( crt9212_device::wclk_w ) if (m_wac == CRT9212_RAM_SIZE) { // set write overflow - WOF(1); + m_write_wof(1); } } } diff --git a/src/emu/video/crt9212.h b/src/emu/video/crt9212.h index 57cda052dc4..9ce53d2c07e 100644 --- a/src/emu/video/crt9212.h +++ b/src/emu/video/crt9212.h @@ -47,70 +47,73 @@ const int CRT9212_RAM_SIZE = 135; // INTERFACE CONFIGURATION MACROS //************************************************************************** -#define MCFG_CRT9212_OUT_ROF_CB(_devcb) \ - devcb = &crt9212_device::set_out_rof_callback(*device, DEVCB2_##_devcb); +#define MCFG_CRT9212_DOUT_CALLBACK(_write) \ + devcb = &crt9212_t::set_dout_wr_callback(*device, DEVCB2_##_write); -#define MCFG_CRT9212_OUT_WOF_CB(_devcb) \ - devcb = &crt9212_device::set_out_wof_callback(*device, DEVCB2_##_devcb); - -#define MCFG_CRT9212_IN_REN_CB(_devcb) \ - devcb = &crt9212_device::set_in_ren_callback(*device, DEVCB2_##_devcb); +#define MCFG_CRT9212_ROF_CALLBACK(_write) \ + devcb = &crt9212_t::set_rof_wr_callback(*device, DEVCB2_##_write); -#define MCFG_CRT9212_IN_WEN_CB(_devcb) \ - devcb = &crt9212_device::set_in_wen_callback(*device, DEVCB2_##_devcb); +#define MCFG_CRT9212_WOF_CALLBACK(_write) \ + devcb = &crt9212_t::set_wof_wr_callback(*device, DEVCB2_##_write); -#define MCFG_CRT9212_IN_WEN2_CB(_devcb) \ - devcb = &crt9212_device::set_in_wen2_callback(*device, DEVCB2_##_devcb); //************************************************************************** // TYPE DEFINITIONS //************************************************************************** -// ======================> crt9212_device +// ======================> crt9212_t -class crt9212_device : public device_t +class crt9212_t : public device_t { public: // construction/destruction - crt9212_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); + crt9212_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); - template static devcb2_base &set_out_rof_callback(device_t &device, _Object object) { return downcast(device).m_out_rof_cb.set_callback(object); } - template static devcb2_base &set_out_wof_callback(device_t &device, _Object object) { return downcast(device).m_out_wof_cb.set_callback(object); } - template static devcb2_base &set_in_ren_callback(device_t &device, _Object object) { return downcast(device).m_in_ren_cb.set_callback(object); } - template static devcb2_base &set_in_wen_callback(device_t &device, _Object object) { return downcast(device).m_in_wen_cb.set_callback(object); } - template static devcb2_base &set_in_wen2_callback(device_t &device, _Object object) { return downcast(device).m_in_wen2_cb.set_callback(object); } + template static devcb2_base &set_dout_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_dout.set_callback(object); } + template static devcb2_base &set_rof_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_rof.set_callback(object); } + template static devcb2_base &set_wof_wr_callback(device_t &device, _Object object) { return downcast(device).m_write_wof.set_callback(object); } - DECLARE_READ8_MEMBER( read ); - DECLARE_WRITE8_MEMBER( write ); - DECLARE_WRITE_LINE_MEMBER( clrcnt_w ); - DECLARE_WRITE_LINE_MEMBER( tog_w ); + DECLARE_WRITE8_MEMBER( write ) { m_data = data; } + DECLARE_WRITE_LINE_MEMBER( clrcnt_w ) { m_clrcnt = state; } + DECLARE_WRITE_LINE_MEMBER( tog_w ) { m_tog = state; } + DECLARE_WRITE_LINE_MEMBER( ren_w ) { m_ren = state; } + DECLARE_WRITE_LINE_MEMBER( wen1_w ) { m_wen1 = state; } + DECLARE_WRITE_LINE_MEMBER( wen2_w ) { m_wen2 = state; } + DECLARE_WRITE_LINE_MEMBER( oe_w ) { m_oe = state; } DECLARE_WRITE_LINE_MEMBER( rclk_w ); DECLARE_WRITE_LINE_MEMBER( wclk_w ); protected: // device-level overrides virtual void device_start(); + virtual void device_clock_changed(); + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); private: - devcb2_write_line m_out_rof_cb; - devcb2_write_line m_out_wof_cb; - devcb2_read_line m_in_ren_cb; - devcb2_read_line m_in_wen_cb; - devcb2_read_line m_in_wen2_cb; + devcb2_write8 m_write_dout; + devcb2_write_line m_write_rof; + devcb2_write_line m_write_wof; + // inputs + UINT8 m_data; + int m_clrcnt; + int m_tog; + int m_ren; + int m_wen1; + int m_wen2; + int m_oe; + int m_rclk; + int m_wclk; + + // internal state UINT8 m_ram[CRT9212_RAM_SIZE][2]; - - UINT8 m_input; - UINT8 m_output; - int m_buffer; int m_rac; int m_wac; - int m_tog; - int m_clrcnt; - int m_rclk; - int m_wclk; + + // timers + emu_timer *m_rwclk_timer; }; diff --git a/src/mess/drivers/tandy2k.c b/src/mess/drivers/tandy2k.c index 8ff5cd122a0..3ef8c8c24ab 100644 --- a/src/mess/drivers/tandy2k.c +++ b/src/mess/drivers/tandy2k.c @@ -235,7 +235,7 @@ WRITE8_MEMBER( tandy2k_state::addr_ctrl_w ) if (m_clkcnt != BIT(data, 6)) { - m_vpac->set_hpixels_per_column(character_width); + m_vpac->set_character_width(character_width); m_clkcnt = BIT(data, 6); } @@ -279,7 +279,7 @@ static ADDRESS_MAP_START( tandy2k_io, AS_IO, 16, tandy2k_state ) AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8(I8259A_0_TAG, pic8259_device, read, write, 0x00ff) AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8(I8259A_1_TAG, pic8259_device, read, write, 0x00ff) AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8(I8272A_TAG, i8272a_device, mdma_r, mdma_w, 0x00ff) -// AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_device, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00) +// AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_t, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00) AM_RANGE(0x00100, 0x0017f) AM_READWRITE(vpac_r, vpac_w) // AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff) // AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w) @@ -353,20 +353,30 @@ WRITE_LINE_MEMBER( tandy2k_state::vpac_drb_w ) m_drb1->tog_w(state); } -static CRT9007_INTERFACE( vpac_intf ) +WRITE8_MEMBER( tandy2k_state::drb_attr_w ) { - 10, - DEVCB_DEVICE_LINE_MEMBER(I8259A_1_TAG, pic8259_device, ir1_w), - DEVCB_NULL, // DMAR 80186 HOLD - DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, vsync_w), // VS - DEVCB_NULL, // HS - DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_vlt_w), // VLT - DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, cursor_w), // CURS - DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_drb_w), // DRB - DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, retbl_w), // CBLANK - DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, slg_w), // SLG - DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, sld_w) // SLD -}; + /* + + bit description + + 0 BLC -> DBLC + 1 BKC -> DBKC + 2 CHABL + 3 MS0 + 4 MS1 + 5 BLINK + 6 INT + 7 REVID + + */ + + m_vac->chabl_w(BIT(data, 2)); + m_vac->ms0_w(BIT(data, 3)); + m_vac->ms1_w(BIT(data, 4)); + m_vac->blink_w(BIT(data, 5)); + m_vac->intin_w(BIT(data, 6)); + m_vac->revid_w(BIT(data, 7)); +} // Intel 8251A Interface @@ -632,25 +642,29 @@ static MACHINE_CONFIG_START( tandy2k, tandy2k_state ) MCFG_SCREEN_SIZE(640, 480) MCFG_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) - MCFG_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, vpac_intf, vpac_mem) + MCFG_DEVICE_ADD(CRT9007_TAG, CRT9007, XTAL_16MHz*28/16) + MCFG_DEVICE_ADDRESS_MAP(AS_0, vpac_mem) + MCFG_CRT9007_CHARACTER_WIDTH(10) + MCFG_CRT9007_INT_CALLBACK(DEVWRITELINE(I8259A_1_TAG, pic8259_device, ir1_w)) + //MCFG_CRT9007_DMAR_CALLBACK(80186 HOLD) + MCFG_CRT9007_VS_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, vsync_w)) + MCFG_CRT9007_VLT_CALLBACK(WRITELINE(tandy2k_state, vpac_vlt_w)) + MCFG_CRT9007_CURS_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, cursor_w)) + MCFG_CRT9007_DRB_CALLBACK(WRITELINE(tandy2k_state, vpac_drb_w)) + MCFG_CRT9007_CBLANK_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, retbl_w)) + MCFG_CRT9007_SLG_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, slg_w)) + MCFG_CRT9007_SLD_CALLBACK(DEVWRITELINE(CRT9021B_TAG, crt9021_t, sld_w)) MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) - MCFG_DEVICE_ADD(CRT9212_0_TAG, CRT9212, 0) - // ROF - // WOF - MCFG_CRT9212_IN_REN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, vlt_r)) // REN - MCFG_CRT9212_IN_WEN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, wben_r)) // WEN - MCFG_CRT9212_IN_WEN2_CB(VCC) // WEN2 - MCFG_DEVICE_ADD(CRT9212_1_TAG, CRT9212, 0) - // ROF - // WOF - MCFG_CRT9212_IN_REN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, vlt_r)) // REN - MCFG_CRT9212_IN_WEN_CB(DEVREADLINE(CRT9007_TAG, crt9007_device, wben_r)) // WEN - MCFG_CRT9212_IN_WEN2_CB(VCC) // WEN2 + + MCFG_DEVICE_ADD(CRT9212_0_TAG, CRT9212, XTAL_16MHz*28/16/8) + MCFG_CRT9212_DOUT_CALLBACK(DEVWRITE8(CRT9021B_TAG, crt9021_t, write)) + + MCFG_DEVICE_ADD(CRT9212_1_TAG, CRT9212, XTAL_16MHz*28/16/8) + MCFG_CRT9212_DOUT_CALLBACK(WRITE8(tandy2k_state, drb_attr_w)) + MCFG_DEVICE_ADD(CRT9021B_TAG, CRT9021, XTAL_16MHz*28/16/8) - MCFG_CRT9021_IN_DATA_CB(DEVREAD8(CRT9212_0_TAG, crt9212_device, read)) // data - MCFG_CRT9021_IN_ATTR_CB(DEVREAD8(CRT9212_1_TAG, crt9212_device, read)) // attributes - MCFG_CRT9021_IN_ATTEN_CB(VCC) MCFG_VIDEO_SET_SCREEN(SCREEN_TAG) + MCFG_PALETTE_ADD_BLACK_AND_WHITE("palette") // sound hardware MCFG_SPEAKER_STANDARD_MONO("mono") diff --git a/src/mess/includes/tandy2k.h b/src/mess/includes/tandy2k.h index 8f4f9ba8232..2ae8c369706 100644 --- a/src/mess/includes/tandy2k.h +++ b/src/mess/includes/tandy2k.h @@ -41,8 +41,8 @@ class tandy2k_state : public driver_device { public: - tandy2k_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + tandy2k_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, I80186_TAG), m_uart(*this, I8251A_TAG), m_i8255a(*this, I8255A_TAG), @@ -73,10 +73,10 @@ public: required_device m_fdc; required_device m_pic0; required_device m_pic1; - required_device m_vpac; - required_device m_drb0; - required_device m_drb1; - required_device m_vac; + required_device m_vpac; + required_device m_drb0; + required_device m_drb1; + required_device m_vac; required_device m_centronics; required_device m_speaker; required_device m_ram; @@ -115,6 +115,7 @@ public: DECLARE_WRITE_LINE_MEMBER( kbddat_w ); DECLARE_READ8_MEMBER( irq_callback ); DECLARE_WRITE_LINE_MEMBER( fdc_drq ); + DECLARE_WRITE8_MEMBER( drb_attr_w ); /* DMA state */ UINT8 m_dma_mux;