diff --git a/src/mess/drivers/super80.c b/src/mess/drivers/super80.c index 771eb95cd7b..0ec66c414d3 100644 --- a/src/mess/drivers/super80.c +++ b/src/mess/drivers/super80.c @@ -181,20 +181,18 @@ hardware. ***********************************************************************************************************/ -#include "emu.h" #include "super80.lh" #include "includes/super80.h" - #include "formats/z80bin.h" -#define MASTER_CLOCK (XTAL_12MHz) -#define PIXEL_CLOCK (MASTER_CLOCK/2) -#define HTOTAL (384) -#define HBEND (0) -#define HBSTART (256) -#define VTOTAL (240) -#define VBEND (0) -#define VBSTART (160) +#define MASTER_CLOCK (XTAL_12MHz) +#define PIXEL_CLOCK (MASTER_CLOCK/2) +#define HTOTAL (384) +#define HBEND (0) +#define HBSTART (256) +#define VTOTAL (240) +#define VBEND (0) +#define VBSTART (160) #define SUPER80V_SCREEN_WIDTH (560) #define SUPER80V_SCREEN_HEIGHT (300) diff --git a/src/mess/includes/super80.h b/src/mess/includes/super80.h index ee0682b791a..e7a42dc62c3 100644 --- a/src/mess/includes/super80.h +++ b/src/mess/includes/super80.h @@ -1,3 +1,4 @@ +#include "emu.h" #include "cpu/z80/z80.h" #include "cpu/z80/z80daisy.h" #include "sound/wave.h" @@ -28,16 +29,19 @@ public: m_wave(*this, WAVE_TAG), m_speaker(*this, SPEAKER_TAG), m_centronics(*this, "centronics"), - m_6845(*this, "crtc") + m_6845(*this, "crtc"), + m_io_dsw(*this, "DSW"), + m_io_x0(*this, "X0"), + m_io_x1(*this, "X1"), + m_io_x2(*this, "X2"), + m_io_x3(*this, "X3"), + m_io_x4(*this, "X4"), + m_io_x5(*this, "X5"), + m_io_x6(*this, "X6"), + m_io_x7(*this, "X7"), + m_io_config(*this, "CONFIG") { } - required_device m_maincpu; - required_device m_pio; - required_device m_cass; - required_device m_wave; - required_device m_speaker; - required_device m_centronics; - optional_device m_6845; DECLARE_READ8_MEMBER( super80v_low_r ); DECLARE_READ8_MEMBER( super80v_high_r ); DECLARE_WRITE8_MEMBER( super80v_low_w ); @@ -52,7 +56,7 @@ public: DECLARE_WRITE8_MEMBER( super80r_f0_w ); DECLARE_READ8_MEMBER( super80_read_ff ); DECLARE_WRITE8_MEMBER( pio_port_a_w ); - //DECLARE_READ8_MEMBER( pio_port_b_r ); + DECLARE_READ8_MEMBER( pio_port_b_r ); virtual void machine_reset(); UINT8 m_shared; UINT8 m_keylatch; @@ -74,6 +78,7 @@ public: UINT8 *m_p_videoram; UINT8 *m_p_colorram; UINT8 *m_p_pcgram; + UINT8 *m_p_ram; void mc6845_cursor_configure(); DECLARE_DRIVER_INIT(super80); DECLARE_DRIVER_INIT(super80v); @@ -89,7 +94,23 @@ public: TIMER_CALLBACK_MEMBER(super80_timer); TIMER_CALLBACK_MEMBER(super80_reset); TIMER_CALLBACK_MEMBER(super80_halfspeed); - DECLARE_READ8_MEMBER(pio_port_b_r); + required_device m_maincpu; + required_device m_pio; + required_device m_cass; + required_device m_wave; + required_device m_speaker; + required_device m_centronics; + optional_device m_6845; + required_ioport m_io_dsw; + required_ioport m_io_x0; + required_ioport m_io_x1; + required_ioport m_io_x2; + required_ioport m_io_x3; + required_ioport m_io_x4; + required_ioport m_io_x5; + required_ioport m_io_x6; + required_ioport m_io_x7; + required_ioport m_io_config; }; diff --git a/src/mess/machine/super80.c b/src/mess/machine/super80.c index b8f8f7ede6a..2fa5d5dd5ce 100644 --- a/src/mess/machine/super80.c +++ b/src/mess/machine/super80.c @@ -1,6 +1,5 @@ /* Super80.c written by Robbbert, 2005-2009. See driver source for documentation. */ -#include "emu.h" #include "includes/super80.h" @@ -12,17 +11,26 @@ WRITE8_MEMBER( super80_state::pio_port_a_w ) m_keylatch = data; }; -READ8_MEMBER(super80_state::pio_port_b_r)// cannot be modernised yet as super80 hangs at start +READ8_MEMBER(super80_state::pio_port_b_r) { - char kbdrow[6]; - UINT8 i; UINT8 data = 0xff; - for (i = 0; i < 8; i++) - { - sprintf(kbdrow,"X%d",i); - if (!BIT(m_keylatch, i)) data &= ioport(kbdrow)->read(); - } + if (!BIT(m_keylatch, 0)) + data &= m_io_x0->read(); + if (!BIT(m_keylatch, 1)) + data &= m_io_x1->read(); + if (!BIT(m_keylatch, 2)) + data &= m_io_x2->read(); + if (!BIT(m_keylatch, 3)) + data &= m_io_x3->read(); + if (!BIT(m_keylatch, 4)) + data &= m_io_x4->read(); + if (!BIT(m_keylatch, 5)) + data &= m_io_x5->read(); + if (!BIT(m_keylatch, 6)) + data &= m_io_x6->read(); + if (!BIT(m_keylatch, 7)) + data &= m_io_x7->read(); return data; }; @@ -50,7 +58,7 @@ static void super80_cassette_motor( running_machine &machine, UINT8 data ) state->m_cass->change_state(CASSETTE_MOTOR_ENABLED,CASSETTE_MASK_MOTOR); /* does user want to hear the sound? */ - if BIT(machine.root_device().ioport("CONFIG")->read(), 3) + if BIT(state->m_io_config->read(), 3) state->m_cass->change_state(CASSETTE_SPEAKER_ENABLED,CASSETTE_MASK_SPEAKER); else state->m_cass->change_state(CASSETTE_SPEAKER_MUTED,CASSETTE_MASK_SPEAKER); @@ -104,19 +112,19 @@ TIMER_CALLBACK_MEMBER(super80_state::super80_reset) TIMER_CALLBACK_MEMBER(super80_state::super80_halfspeed) { UINT8 go_fast = 0; - if ( (!BIT(m_shared, 2)) | (!BIT(machine().root_device().ioport("CONFIG")->read(), 1)) ) /* bit 2 of port F0 is low, OR user turned on config switch */ + if ( (!BIT(m_shared, 2)) | (!BIT(m_io_config->read(), 1)) ) /* bit 2 of port F0 is low, OR user turned on config switch */ go_fast++; /* code to slow down computer to 1 MHz by halting cpu on every second frame */ if (!go_fast) { if (!m_int_sw) - machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, ASSERT_LINE); // if going, stop it + m_maincpu->set_input_line(INPUT_LINE_HALT, ASSERT_LINE); // if going, stop it m_int_sw++; if (m_int_sw > 1) { - machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); // if stopped, start it + m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); // if stopped, start it m_int_sw = 0; } } @@ -124,7 +132,7 @@ TIMER_CALLBACK_MEMBER(super80_state::super80_halfspeed) { if (m_int_sw < 8) // @2MHz, reset just once { - machine().device("maincpu")->execute().set_input_line(INPUT_LINE_HALT, CLEAR_LINE); + m_maincpu->set_input_line(INPUT_LINE_HALT, CLEAR_LINE); m_int_sw = 8; // ...not every time } } @@ -156,7 +164,7 @@ READ8_MEMBER( super80_state::super80_dc_r ) READ8_MEMBER( super80_state::super80_f2_r ) { - UINT8 data = ioport("DSW")->read() & 0xf0; // dip switches on pcb + UINT8 data = m_io_dsw->read() & 0xf0; // dip switches on pcb data |= m_cass_data[2]; // bit 0 = output of U1, bit 1 = MDS cass state, bit 2 = current wave_state data |= 0x08; // bit 3 - not used return data; diff --git a/src/mess/video/super80.c b/src/mess/video/super80.c index 6b07ae0204e..5ef5c9c817d 100644 --- a/src/mess/video/super80.c +++ b/src/mess/video/super80.c @@ -5,7 +5,6 @@ 2. Undocumented cursor start and end-lines is not supported by MMD, so we do it here. */ -#include "emu.h" #include "includes/super80.h" @@ -76,7 +75,7 @@ void super80_state::screen_eof_super80m(screen_device &screen, bool state) if (state) { /* if we chose another palette or colour mode, enable it */ - UINT8 chosen_palette = (machine().root_device().ioport("CONFIG")->read() & 0x60)>>5; // read colour dipswitches + UINT8 chosen_palette = (m_io_config->read() & 0x60)>>5; // read colour dipswitches if (chosen_palette != m_current_palette) // any changes? { @@ -93,11 +92,10 @@ UINT32 super80_state::screen_update_super80(screen_device &screen, bitmap_ind16 { UINT8 y,ra,chr=32,gfx,screen_on=0; UINT16 sy=0,ma=m_vidpg,x; - UINT8 *RAM = memregion("maincpu")->base(); - output_set_value("cass_led",(m_shared & 0x20) ? 1 : 0); + output_set_value("cass_led",BIT(m_shared, 5)); - if ((m_shared & 4) || (!(machine().root_device().ioport("CONFIG")->read() & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ + if ((BIT(m_shared, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ screen_on++; for (y = 0; y < 16; y++) @@ -109,7 +107,7 @@ UINT32 super80_state::screen_update_super80(screen_device &screen, bitmap_ind16 for (x = 0; x < 32; x++) // done this way to avoid x overflowing on page FF { if (screen_on) - chr = RAM[ma | x] & 0x3f; + chr = m_p_ram[ma | x] & 0x3f; /* get pattern of pixels for that character scanline */ gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)]; @@ -134,11 +132,10 @@ UINT32 super80_state::screen_update_super80d(screen_device &screen, bitmap_ind16 { UINT8 y,ra,chr=32,gfx,screen_on=0; UINT16 sy=0,ma=m_vidpg,x; - UINT8 *RAM = memregion("maincpu")->base(); - output_set_value("cass_led",(m_shared & 0x20) ? 1 : 0); + output_set_value("cass_led",BIT(m_shared, 5)); - if ((m_shared & 4) || (!(machine().root_device().ioport("CONFIG")->read() & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ + if ((BIT(m_shared, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ screen_on++; for (y = 0; y < 16; y++) @@ -150,7 +147,7 @@ UINT32 super80_state::screen_update_super80d(screen_device &screen, bitmap_ind16 for (x = 0; x < 32; x++) { if (screen_on) - chr = RAM[ma | x]; + chr = m_p_ram[ma | x]; /* get pattern of pixels for that character scanline */ gfx = m_p_chargen[((chr & 0x7f)<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)] ^ ((chr & 0x80) ? 0xff : 0); @@ -175,11 +172,10 @@ UINT32 super80_state::screen_update_super80e(screen_device &screen, bitmap_ind16 { UINT8 y,ra,chr=32,gfx,screen_on=0; UINT16 sy=0,ma=m_vidpg,x; - UINT8 *RAM = memregion("maincpu")->base(); - output_set_value("cass_led",(m_shared & 0x20) ? 1 : 0); + output_set_value("cass_led",BIT(m_shared, 5)); - if ((m_shared & 4) || (!(machine().root_device().ioport("CONFIG")->read() & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ + if ((BIT(m_shared, 2)) | (!BIT(m_io_config->read(), 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ screen_on++; for (y = 0; y < 16; y++) @@ -191,7 +187,7 @@ UINT32 super80_state::screen_update_super80e(screen_device &screen, bitmap_ind16 for (x = 0; x < 32; x++) { if (screen_on) - chr = RAM[ma | x]; + chr = m_p_ram[ma | x]; /* get pattern of pixels for that character scanline */ gfx = m_p_chargen[(chr<<4) | ((ra & 8) >> 3) | ((ra & 7) << 1)]; @@ -216,15 +212,14 @@ UINT32 super80_state::screen_update_super80m(screen_device &screen, bitmap_ind16 { UINT8 y,ra,chr=32,gfx,screen_on=0; UINT16 sy=0,ma=m_vidpg,x; - UINT8 col, bg=0, fg=0, options=machine().root_device().ioport("CONFIG")->read(); - UINT8 *RAM = memregion("maincpu")->base(); + UINT8 col, bg=0, fg=0, options=m_io_config->read(); /* get selected character generator */ UINT8 cgen = m_current_charset ^ ((options & 0x10)>>4); /* bit 0 of port F1 and cgen config switch */ - output_set_value("cass_led",(m_shared & 0x20) ? 1 : 0); + output_set_value("cass_led",BIT(m_shared, 5)); - if ((m_shared & 4) || (!(options & 4))) /* bit 2 of port F0 is high, OR user turned on config switch */ + if ((BIT(m_shared, 2)) | (!BIT(options, 2))) /* bit 2 of port F0 is high, OR user turned on config switch */ screen_on++; if (screen_on) @@ -244,11 +239,11 @@ UINT32 super80_state::screen_update_super80m(screen_device &screen, bitmap_ind16 for (x = 0; x < 32; x++) { if (screen_on) - chr = RAM[ma | x]; + chr = m_p_ram[ma | x]; if (!(options & 0x40)) { - col = RAM[0xfe00 | ma | x]; /* byte of colour to display */ + col = m_p_ram[0xfe00 | ma | x]; /* byte of colour to display */ fg = col & 0x0f; bg = (col & 0xf0) >> 4; } @@ -279,6 +274,7 @@ VIDEO_START_MEMBER(super80_state,super80) { m_vidpg = 0xfe00; m_p_chargen = memregion("chargen")->base(); + m_p_ram = memregion("maincpu")->base(); } /**************************** I/O PORTS *****************************************************************/ @@ -384,8 +380,8 @@ UINT32 super80_state::screen_update_super80v(screen_device &screen, bitmap_rgb32 m_framecnt++; m_speed = m_mc6845_reg[10]&0x20, m_flash = m_mc6845_reg[10]&0x40; // cursor modes m_cursor = (m_mc6845_reg[14]<<8) | m_mc6845_reg[15]; // get cursor position - m_s_options=machine().root_device().ioport("CONFIG")->read(); - output_set_value("cass_led",(m_shared & 0x20) ? 1 : 0); + m_s_options=m_io_config->read(); + output_set_value("cass_led",BIT(m_shared, 5)); m_6845->screen_update(screen, bitmap, cliprect); return 0; }