1 // license:BSD-3-Clause 2 // copyright-holders:Curt Coder, Robbbert, Wilbert Pol 3 #ifndef MAME_INCLUDES_OSI_H 4 #define MAME_INCLUDES_OSI_H 5 6 #pragma once 7 8 9 #include "cpu/m6502/m6502.h" 10 #include "formats/basicdsk.h" 11 #include "imagedev/cassette.h" 12 #include "imagedev/floppy.h" 13 #include "machine/6850acia.h" 14 #include "machine/6821pia.h" 15 #include "machine/timer.h" 16 #include "machine/ram.h" 17 #include "sound/discrete.h" 18 #include "sound/beep.h" 19 #include "emupal.h" 20 21 #define SCREEN_TAG "screen" 22 #define M6502_TAG "m6502" 23 #define DISCRETE_TAG "discrete" 24 25 #define X1 3932160 26 #define UK101_X1 XTAL(8'000'000) 27 28 #define OSI600_VIDEORAM_SIZE 0x400 29 #define OSI630_COLORRAM_SIZE 0x400 30 31 class sb2m600_state : public driver_device 32 { 33 public: sb2m600_state(const machine_config & mconfig,device_type type,const char * tag)34 sb2m600_state(const machine_config &mconfig, device_type type, const char *tag) 35 : driver_device(mconfig, type, tag) 36 , m_cassbit(0) 37 , m_cassold(0) 38 , m_maincpu(*this, M6502_TAG) 39 , m_acia(*this, "acia") 40 , m_cass(*this, "cassette") 41 , m_discrete(*this, DISCRETE_TAG) 42 , m_ram(*this, RAM_TAG) 43 , m_video_ram(*this, "video_ram") 44 , m_color_ram(*this, "color_ram") 45 , m_p_chargen(*this, "chargen") 46 , m_io_keyboard(*this, "ROW%u", 0) 47 , m_io_sound(*this, "Sound") 48 , m_io_reset(*this, "Reset") 49 { } 50 51 void osi600(machine_config &config); 52 53 protected: 54 virtual void machine_start() override; 55 virtual void video_start() override; 56 57 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 58 uint8_t keyboard_r(); 59 void keyboard_w(uint8_t data); 60 void ctrl_w(uint8_t data); 61 TIMER_DEVICE_CALLBACK_MEMBER(kansas_w); 62 TIMER_DEVICE_CALLBACK_MEMBER(kansas_r); 63 64 void floppy_index_callback(floppy_image_device *floppy, int state); 65 66 void osi630_palette(palette_device &palette) const; 67 68 void osi600_video(machine_config &config); 69 void osi630_video(machine_config &config); 70 void osi600_mem(address_map &map); 71 72 uint8_t m_cass_data[4]; 73 bool m_cassbit; 74 bool m_cassold; 75 required_device<cpu_device> m_maincpu; 76 required_device<acia6850_device> m_acia; 77 required_device<cassette_image_device> m_cass; 78 optional_device<discrete_sound_device> m_discrete; 79 required_device<ram_device> m_ram; 80 required_shared_ptr<uint8_t> m_video_ram; 81 optional_shared_ptr<uint8_t> m_color_ram; 82 required_region_ptr<u8> m_p_chargen; 83 required_ioport_array<8> m_io_keyboard; 84 required_ioport m_io_sound; 85 required_ioport m_io_reset; 86 87 /* floppy state */ 88 int m_fdc_index; 89 90 /* keyboard state */ 91 uint8_t m_keylatch; 92 93 /* video state */ 94 int m_32; 95 int m_coloren; 96 }; 97 98 class c1p_state : public sb2m600_state 99 { 100 public: c1p_state(const machine_config & mconfig,device_type type,const char * tag)101 c1p_state(const machine_config &mconfig, device_type type, const char *tag) 102 : sb2m600_state(mconfig, type, tag) 103 , m_beeper(*this, "beeper") 104 , m_beep_timer(*this, "beep_timer") 105 { } 106 107 void init_c1p(); 108 void c1p(machine_config &config); 109 110 protected: 111 virtual void machine_start() override; 112 void osi630_ctrl_w(uint8_t data); 113 void osi630_sound_w(uint8_t data); 114 void c1p_mem(address_map &map); 115 TIMER_DEVICE_CALLBACK_MEMBER(beep_timer); 116 117 required_device<beep_device> m_beeper; 118 required_device<timer_device> m_beep_timer; 119 }; 120 121 class c1pmf_state : public c1p_state 122 { 123 public: c1pmf_state(const machine_config & mconfig,device_type type,const char * tag)124 c1pmf_state(const machine_config &mconfig, device_type type, const char *tag) 125 : c1p_state(mconfig, type, tag) 126 , m_floppy0(*this, "floppy0") 127 , m_floppy1(*this, "floppy1") 128 { } 129 130 void c1pmf(machine_config &config); 131 132 protected: 133 virtual void machine_start() override; 134 135 uint8_t osi470_pia_pa_r(); 136 void osi470_pia_pa_w(uint8_t data); 137 void osi470_pia_pb_w(uint8_t data); 138 DECLARE_WRITE_LINE_MEMBER( osi470_pia_cb2_w ); 139 140 void c1pmf_mem(address_map &map); 141 142 private: 143 required_device<floppy_connector> m_floppy0; 144 required_device<floppy_connector> m_floppy1; 145 }; 146 147 class uk101_state : public sb2m600_state 148 { 149 public: uk101_state(const machine_config & mconfig,device_type type,const char * tag)150 uk101_state(const machine_config &mconfig, device_type type, const char *tag) 151 : sb2m600_state(mconfig, type, tag) 152 { } 153 154 void uk101(machine_config &config); 155 156 protected: 157 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 158 159 void keyboard_w(uint8_t data); 160 void uk101_video(machine_config &config); 161 void uk101_mem(address_map &map); 162 }; 163 164 #endif // MAME_INCLUDES_OSI_H 165