crt9007: Add frame timer

altos2: Add bell (nw)
This commit is contained in:
AJR 2018-10-20 23:59:19 -04:00
parent 8955f8c03c
commit 451ffb3746
3 changed files with 43 additions and 24 deletions

View File

@ -11,9 +11,7 @@
TODO:
- cursor timer
- interrupts
- light pen
- frame timer
- light pen
- non-DMA mode
- DMA mode
- cursor/blank skew
@ -206,7 +204,7 @@ enum
// interrupt enable register bits
const int IE_VERTICAL_RETRACE = 0x40;
//const int IE_LIGHT_PEN = 0x20;
//const int IE_FRAME_TIMER = 0x01;
const int IE_FRAME_TIMER = 0x01;
// status register bits
const int STATUS_INTERRUPT_PENDING = 0x80;
@ -249,11 +247,13 @@ inline uint8_t crt9007_device::readbyte(offs_t address)
inline void crt9007_device::trigger_interrupt(int line)
{
int status = m_status;
m_status |= line;
if (INTERRUPT_ENABLE & line)
{
int status = m_status;
m_status |= STATUS_INTERRUPT_PENDING | line;
m_status |= STATUS_INTERRUPT_PENDING;
if (!(status & STATUS_INTERRUPT_PENDING))
{
@ -403,11 +403,11 @@ inline void crt9007_device::recompute_parameters()
if (!HAS_VALID_PARAMETERS) return;
// screen dimensions
//int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * m_hpixels_per_column;
//int vert_pix_total = SCAN_LINES_PER_FRAME;
int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * m_hpixels_per_column;
int vert_pix_total = SCAN_LINES_PER_FRAME;
// refresh rate
//attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * horiz_pix_total * vert_pix_total;
attotime refresh = clocks_to_attotime(CHARACTERS_PER_HORIZONTAL_PERIOD * vert_pix_total);
// horizontal sync
m_hsync_start = 0;
@ -426,19 +426,21 @@ inline void crt9007_device::recompute_parameters()
m_vsync_end = VERTICAL_SYNC_WIDTH;
// visible area
//rectangle visarea;
rectangle visarea(m_hsync_end, horiz_pix_total - 1, m_vsync_end, vert_pix_total - 1);
//visarea.set(m_hsync_end, horiz_pix_total - 1, m_vsync_end, vert_pix_total - 1);
LOG("CRT9007 Screen: %u x %u @ %f Hz\n", horiz_pix_total, vert_pix_total, ATTOSECONDS_TO_HZ(refresh.as_attoseconds()));
LOG("CRT9007 Visible Area: (%u, %u) - (%u, %u)\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
//LOG("CRT9007 Screen: %u x %u @ %f Hz\n", horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
//LOG("CRT9007 Visible Area: (%u, %u) - (%u, %u)\n", visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
//screen().configure(horiz_pix_total, vert_pix_total, visarea, refresh);
//screen().configure(horiz_pix_total, vert_pix_total, visarea, refresh.as_attoseconds());
(void)visarea;
m_hsync_timer->adjust(screen().time_until_pos(0, 0));
m_vsync_timer->adjust(screen().time_until_pos(0, 0));
m_vlt_timer->adjust(screen().time_until_pos(0, m_vlt_start), 1);
m_drb_timer->adjust(screen().time_until_pos(0, 0));
int frame_timer_line = m_drb_bottom - (OPERATION_MODE == OPERATION_MODE_DOUBLE_ROW_BUFFER ? SCAN_LINES_PER_DATA_ROW : 0);
m_frame_timer->adjust(screen().time_until_pos(frame_timer_line, 0), 0, refresh);
}
@ -508,6 +510,7 @@ void crt9007_device::device_start()
m_curs_timer = timer_alloc(TIMER_CURS);
m_drb_timer = timer_alloc(TIMER_DRB);
m_dma_timer = timer_alloc(TIMER_DMA);
m_frame_timer = timer_alloc(TIMER_FRAME);
// save state
save_item(NAME(m_reg));
@ -536,6 +539,7 @@ void crt9007_device::device_reset()
{
m_disp = false;
m_cblank = false;
m_status = 0;
// HS = 1
m_hs = true;
@ -689,6 +693,10 @@ void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int para
update_dma_timer();
break;
case TIMER_FRAME:
trigger_interrupt(IE_FRAME_TIMER);
break;
}
}
@ -743,7 +751,7 @@ READ8_MEMBER( crt9007_device::read )
case 0x3a:
data = m_status;
if (!machine().side_effects_disabled())
if (!machine().side_effects_disabled() && (m_status & STATUS_INTERRUPT_PENDING))
{
// reset interrupt pending bit
m_status &= ~STATUS_INTERRUPT_PENDING;

View File

@ -91,7 +91,8 @@ private:
TIMER_VLT,
TIMER_CURS,
TIMER_DRB,
TIMER_DMA
TIMER_DMA,
TIMER_FRAME
};
void crt9007(address_map &map);
@ -166,6 +167,7 @@ private:
emu_timer *m_curs_timer;
emu_timer *m_drb_timer;
emu_timer *m_dma_timer;
emu_timer *m_frame_timer;
};

View File

@ -21,10 +21,12 @@ Keyboard: P8035L CPU, undumped 2716 labelled "358_2758", XTAL marked "4608-300-1
#include "machine/z80dart.h"
#include "machine/clock.h"
#include "machine/x2212.h"
#include "sound/beep.h"
//#include "video/crt9006.h"
#include "video/crt9007.h"
//#include "video/crt9021.h"
#include "screen.h"
#include "speaker.h"
class altos2_state : public driver_device
{
@ -34,6 +36,7 @@ public:
, m_maincpu(*this, "maincpu")
, m_novram(*this, "novram")
, m_vpac(*this, "vpac")
, m_bell(*this, "bell")
, m_p_chargen(*this, "chargen")
, m_p_videoram(*this, "videoram")
{ }
@ -54,6 +57,7 @@ private:
required_device<z80_device> m_maincpu;
required_device<x2210_device> m_novram;
required_device<crt9007_device> m_vpac;
required_device<beep_device> m_bell;
required_region_ptr<u8> m_p_chargen;
required_shared_ptr<u8> m_p_videoram;
};
@ -89,7 +93,9 @@ WRITE8_MEMBER(altos2_state::video_mode_w)
m_vpac->set_character_width(10);
}
logerror("Writing %02X to mode register at %s\n", data, machine().describe_context());
m_bell->set_state(BIT(data, 4));
//logerror("Writing %02X to mode register at %s\n", data, machine().describe_context());
}
u32 altos2_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
@ -133,7 +139,7 @@ void altos2_state::altos2(machine_config &config)
m_maincpu->set_addrmap(AS_IO, &altos2_state::io_map);
m_maincpu->set_daisy_config(daisy_chain);
clock_device &ctc_clock(CLOCK(config, "ctc_clock", 4.9152_MHz_XTAL / 2)); // ctc & dart connections are guesswork
clock_device &ctc_clock(CLOCK(config, "ctc_clock", 4.9152_MHz_XTAL / 4));
ctc_clock.signal_handler().set("ctc", FUNC(z80ctc_device::trg0));
ctc_clock.signal_handler().append("ctc", FUNC(z80ctc_device::trg1));
ctc_clock.signal_handler().append("ctc", FUNC(z80ctc_device::trg2));
@ -142,9 +148,9 @@ void altos2_state::altos2(machine_config &config)
ctc.intr_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
ctc.zc_callback<0>().set("dart1", FUNC(z80dart_device::txca_w));
ctc.zc_callback<0>().append("dart1", FUNC(z80dart_device::rxca_w));
ctc.zc_callback<1>().set("dart1", FUNC(z80dart_device::rxtxcb_w));
ctc.zc_callback<2>().set("dart2", FUNC(z80dart_device::rxca_w));
ctc.zc_callback<2>().append("dart2", FUNC(z80dart_device::txca_w));
ctc.zc_callback<1>().set("dart2", FUNC(z80dart_device::rxca_w));
ctc.zc_callback<1>().append("dart2", FUNC(z80dart_device::txca_w));
ctc.zc_callback<2>().set("dart1", FUNC(z80dart_device::rxtxcb_w));
z80dart_device &dart1(Z80DART(config, "dart1", 8_MHz_XTAL / 2));
dart1.out_int_callback().set_inputline(m_maincpu, INPUT_LINE_IRQ0);
@ -163,6 +169,9 @@ void altos2_state::altos2(machine_config &config)
m_vpac->set_screen("screen");
m_vpac->set_character_width(10);
m_vpac->int_callback().set("ctc", FUNC(z80ctc_device::trg3));
SPEAKER(config, "mono").front_center();
BEEP(config, m_bell, 1000).add_route(ALL_OUTPUTS, "mono", 0.50);
}
ROM_START( altos2 )
@ -177,4 +186,4 @@ ROM_START( altos2 )
ROM_LOAD( "358_7258", 0x0000, 0x0800, NO_DUMP )
ROM_END
COMP( 1983, altos2, 0, 0, altos2, altos2, altos2_state, empty_init, "Altos Computer Systems", "Altos II Terminal", MACHINE_IS_SKELETON )
COMP(1983, altos2, 0, 0, altos2, altos2, altos2_state, empty_init, "Altos Computer Systems", "Altos II Terminal", MACHINE_NOT_WORKING | MACHINE_IMPERFECT_GRAPHICS)