1 // license:BSD-3-Clause 2 // copyright-holders:Robbbert 3 #ifndef MAME_INCLUDES_SUPER80_H 4 #define MAME_INCLUDES_SUPER80_H 5 6 #pragma once 7 8 #include "bus/centronics/ctronics.h" 9 #include "cpu/z80/z80.h" 10 #include "imagedev/cassette.h" 11 #include "imagedev/floppy.h" 12 #include "imagedev/snapquik.h" 13 #include "machine/buffer.h" 14 #include "machine/timer.h" 15 #include "machine/wd_fdc.h" 16 #include "machine/z80daisy.h" 17 #include "machine/z80dma.h" 18 #include "machine/z80pio.h" 19 #include "sound/samples.h" 20 #include "sound/spkrdev.h" 21 #include "video/mc6845.h" 22 #include "emupal.h" 23 #include "screen.h" 24 25 /* Bits in m_portf0 variable: 26 d5 cassette LED 27 d4 super80v rom or pcg bankswitch (1=pcg ram, 0=char gen rom) 28 d2 super80v video or colour bankswitch (1=video ram, 0=colour ram) 29 d2 super80 screen off (=2mhz) or on (bursts of 2mhz at 50hz = 1mhz) */ 30 31 class super80_state : public driver_device 32 { 33 public: super80_state(const machine_config & mconfig,device_type type,const char * tag)34 super80_state(const machine_config &mconfig, device_type type, const char *tag) 35 : driver_device(mconfig, type, tag) 36 , m_palette(*this, "palette") 37 , m_gfxdecode(*this, "gfxdecode") 38 , m_screen(*this, "screen") 39 , m_maincpu(*this, "maincpu") 40 , m_rom(*this, "maincpu") 41 , m_ram(*this, "mainram") 42 , m_p_chargen(*this, "chargen") 43 , m_pio(*this, "z80pio") 44 , m_cassette(*this, "cassette") 45 , m_samples(*this, "samples") 46 , m_speaker(*this, "speaker") 47 , m_centronics(*this, "centronics") 48 , m_cent_data_out(*this, "cent_data_out") 49 , m_io_dsw(*this, "DSW") 50 , m_io_config(*this, "CONFIG") 51 , m_io_keyboard(*this, "KEY.%u", 0) 52 , m_cass_led(*this, "cass_led") 53 { } 54 55 void super80m(machine_config &config); 56 void super80(machine_config &config); 57 void super80e(machine_config &config); 58 void super80d(machine_config &config); 59 60 protected: 61 void machine_reset_common(); 62 void machine_start_common(); 63 void cassette_motor(bool data); 64 void screen_vblank_super80m(bool state); 65 void portf0_w(u8 data); 66 void portdc_w(u8 data); 67 void pio_port_a_w(u8 data); 68 u8 pio_port_b_r(); 69 u8 portf2_r(); 70 u8 m_portf0; 71 u8 m_s_options; 72 u8 m_palette_index; 73 u8 m_keylatch; 74 u8 m_cass_data[4]; 75 u8 m_key_pressed; 76 u8 m_last_data; 77 bool m_boot_in_progress; 78 void super80m_palette(palette_device &palette) const; 79 TIMER_DEVICE_CALLBACK_MEMBER(timer_k); 80 TIMER_DEVICE_CALLBACK_MEMBER(kansas_r); 81 DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb); 82 required_device<palette_device> m_palette; 83 required_device<gfxdecode_device> m_gfxdecode; 84 required_device<screen_device> m_screen; 85 required_device<z80_device> m_maincpu; 86 required_region_ptr<u8> m_rom; 87 memory_passthrough_handler *m_rom_shadow_tap; 88 required_shared_ptr<u8> m_ram; 89 required_region_ptr<u8> m_p_chargen; 90 required_device<z80pio_device> m_pio; 91 required_device<cassette_image_device> m_cassette; 92 required_device<samples_device> m_samples; 93 required_device<speaker_sound_device> m_speaker; 94 required_device<centronics_device> m_centronics; 95 required_device<output_latch_device> m_cent_data_out; 96 required_ioport m_io_dsw; 97 required_ioport m_io_config; 98 required_ioport_array<8> m_io_keyboard; 99 output_finder<> m_cass_led; 100 101 private: 102 103 void machine_reset() override; 104 void machine_start() override; 105 void portf1_w(u8 data); 106 TIMER_DEVICE_CALLBACK_MEMBER(timer_h); 107 uint32_t screen_update_super80(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 108 uint32_t screen_update_super80d(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 109 uint32_t screen_update_super80e(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 110 uint32_t screen_update_super80m(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 111 112 void super80_io(address_map &map); 113 void super80_map(address_map &map); 114 void super80e_io(address_map &map); 115 void super80m_map(address_map &map); 116 117 u8 m_int_sw; 118 u16 m_vidpg; 119 bool m_current_charset; 120 }; 121 122 123 class super80v_state : public super80_state 124 { 125 public: super80v_state(const machine_config & mconfig,device_type type,const char * tag)126 super80v_state(const machine_config &mconfig, device_type type, const char *tag) 127 : super80_state(mconfig, type, tag) 128 , m_crtc(*this, "crtc") 129 , m_dma(*this, "dma") 130 , m_fdc (*this, "fdc") 131 , m_floppy0(*this, "fdc:0") 132 , m_floppy1(*this, "fdc:1") 133 , m_floppy2(*this, "fdc:2") 134 , m_floppy3(*this, "fdc:3") 135 { } 136 137 void super80v(machine_config &config); 138 139 protected: 140 void super80v_map(address_map &map); 141 void super80v_io(address_map &map); 142 void machine_reset() override; 143 void machine_start() override; 144 void port3f_w(u8 data); 145 u8 port3e_r(); 146 std::unique_ptr<u8[]> m_vram; 147 DECLARE_WRITE_LINE_MEMBER(busreq_w); 148 uint8_t memory_read_byte(offs_t offset); 149 void memory_write_byte(offs_t offset, uint8_t data); 150 uint8_t io_read_byte(offs_t offset); 151 void io_write_byte(offs_t offset, uint8_t data); 152 MC6845_UPDATE_ROW(crtc_update_row); 153 uint32_t screen_update_super80v(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 154 required_device<mc6845_device> m_crtc; 155 required_device<z80dma_device> m_dma; 156 required_device<wd2793_device> m_fdc; 157 required_device<floppy_connector> m_floppy0; 158 required_device<floppy_connector> m_floppy1; 159 required_device<floppy_connector> m_floppy2; 160 required_device<floppy_connector> m_floppy3; 161 162 private: 163 void low_w(offs_t offset, u8 data); 164 void high_w(offs_t offset, u8 data); 165 u8 low_r(offs_t offset); 166 u8 high_r(offs_t offset); 167 }; 168 169 class super80r_state : public super80v_state 170 { 171 public: 172 using super80v_state::super80v_state; 173 174 void super80r(machine_config &config); 175 176 private: 177 void super80r_map(address_map &map); 178 void low_w(offs_t offset, u8 data); 179 void high_w(offs_t offset, u8 data); 180 u8 low_r(offs_t offset); 181 u8 high_r(offs_t offset); 182 }; 183 184 185 #endif // MAME_INCLUDES_SUPER80_H 186