1 // license:BSD-3-Clause 2 // copyright-holders:Nathan Woods,R. Belmont 3 /***************************************************************************** 4 * 5 * includes/apple3.h 6 * 7 * Apple /// 8 * 9 ****************************************************************************/ 10 11 #ifndef MAME_INCLUDES_APPLE3_H 12 #define MAME_INCLUDES_APPLE3_H 13 14 #pragma once 15 16 #include "cpu/m6502/m6502.h" 17 #include "machine/ram.h" 18 #include "machine/timer.h" 19 #include "bus/a2bus/a2bus.h" 20 #include "machine/mos6551.h" 21 #include "machine/6522via.h" 22 #include "machine/kb3600.h" 23 #include "machine/mm58167.h" 24 #include "sound/dac.h" 25 #include "machine/wozfdc.h" 26 #include "imagedev/floppy.h" 27 #include "formats/flopimg.h" 28 #include "emupal.h" 29 #include "screen.h" 30 31 #define VAR_VM0 0x0001 32 #define VAR_VM1 0x0002 33 #define VAR_VM2 0x0004 34 #define VAR_VM3 0x0008 35 #define VAR_EXTA0 0x0010 36 #define VAR_EXTA1 0x0020 37 #define VAR_EXTPOWER 0x0040 38 #define VAR_EXTSIDE 0x0080 39 40 class apple3_state : public driver_device 41 { 42 public: apple3_state(const machine_config & mconfig,device_type type,const char * tag)43 apple3_state(const machine_config &mconfig, device_type type, const char *tag) : 44 driver_device(mconfig, type, tag), 45 m_maincpu(*this, "maincpu"), 46 m_ram(*this, RAM_TAG), 47 m_via(*this, "via6522_%u", 0), 48 m_acia(*this, "acia"), 49 m_fdc(*this, "fdc"), 50 m_ay3600(*this, "ay3600"), 51 m_a2bus(*this, "a2bus"), 52 m_rtc(*this, "rtc"), 53 m_bell(*this, "bell"), 54 m_dac(*this, "dac"), 55 m_kbspecial(*this, "keyb_special"), 56 m_palette(*this, "palette"), 57 m_screen(*this, "screen"), 58 m_joy1x(*this, "joy_1_x"), 59 m_joy1y(*this, "joy_1_y"), 60 m_joy2x(*this, "joy_2_x"), 61 m_joy2y(*this, "joy_2_y"), 62 m_joybuttons(*this, "joy_buttons"), 63 m_pdltimer(*this, "pdltimer"), 64 floppy0(*this, "0"), 65 floppy1(*this, "1"), 66 floppy2(*this, "2"), 67 floppy3(*this, "3") 68 { 69 } 70 71 required_device<m6502_device> m_maincpu; 72 required_device<ram_device> m_ram; 73 required_device_array<via6522_device, 2> m_via; 74 required_device<mos6551_device> m_acia; 75 required_device<appleiii_fdc_device> m_fdc; 76 required_device<ay3600_device> m_ay3600; 77 required_device<a2bus_device> m_a2bus; 78 required_device<mm58167_device> m_rtc; 79 required_device<dac_bit_interface> m_bell; 80 required_device<dac_byte_interface> m_dac; 81 required_ioport m_kbspecial; 82 required_device<palette_device> m_palette; 83 required_device<screen_device> m_screen; 84 required_ioport m_joy1x, m_joy1y, m_joy2x, m_joy2y, m_joybuttons; 85 required_device<timer_device> m_pdltimer; 86 required_device<floppy_connector> floppy0; 87 required_device<floppy_connector> floppy1; 88 required_device<floppy_connector> floppy2; 89 required_device<floppy_connector> floppy3; 90 91 uint8_t apple3_memory_r(offs_t offset); 92 void apple3_memory_w(offs_t offset, uint8_t data); 93 DECLARE_WRITE_LINE_MEMBER(apple3_sync_w); 94 uint8_t apple3_c0xx_r(offs_t offset); 95 void apple3_c0xx_w(offs_t offset, uint8_t data); 96 void init_apple3(); 97 virtual void machine_reset() override; 98 virtual void video_start() override; 99 uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 100 TIMER_CALLBACK_MEMBER(scanstart_cb); 101 TIMER_CALLBACK_MEMBER(scanend_cb); 102 void apple3_via_0_out_a(uint8_t data); 103 void apple3_via_0_out_b(uint8_t data); 104 void apple3_via_1_out_a(uint8_t data); 105 void apple3_via_1_out_b(uint8_t data); 106 void apple3_write_charmem(); 107 void text40(bitmap_ind16 &bitmap, const rectangle &cliprect); 108 void text80(bitmap_ind16 &bitmap, const rectangle &cliprect); 109 void graphics_hgr(bitmap_ind16 &bitmap, const rectangle &cliprect); 110 void graphics_chgr(bitmap_ind16 &bitmap, const rectangle &cliprect); 111 void graphics_shgr(bitmap_ind16 &bitmap, const rectangle &cliprect); 112 void graphics_chires(bitmap_ind16 &bitmap, const rectangle &cliprect); 113 uint8_t *apple3_bankaddr(uint16_t bank, offs_t offset); 114 uint8_t *apple3_get_zpa_addr(offs_t offset); 115 void apple3_update_memory(); 116 void apple3_via_out(uint8_t *var, uint8_t data); 117 uint8_t *apple3_get_indexed_addr(offs_t offset); 118 TIMER_DEVICE_CALLBACK_MEMBER(apple3_c040_tick); 119 void palette_init(palette_device &palette) const; 120 DECLARE_READ_LINE_MEMBER(ay3600_shift_r); 121 DECLARE_READ_LINE_MEMBER(ay3600_control_r); 122 DECLARE_WRITE_LINE_MEMBER(ay3600_data_ready_w); 123 virtual void device_post_load() override; 124 TIMER_DEVICE_CALLBACK_MEMBER(paddle_timer); 125 void pdl_handler(int offset); 126 DECLARE_FLOPPY_FORMATS( floppy_formats ); 127 DECLARE_WRITE_LINE_MEMBER(a2bus_irq_w); 128 DECLARE_WRITE_LINE_MEMBER(a2bus_nmi_w); 129 DECLARE_WRITE_LINE_MEMBER(vbl_w); 130 DECLARE_WRITE_LINE_MEMBER(a2bus_inh_w); 131 132 // these need to be public for now 133 uint32_t m_flags; 134 int m_enable_mask; 135 136 void apple3(machine_config &config); 137 void apple3_map(address_map &map); 138 private: 139 uint8_t m_via_0_a; 140 uint8_t m_via_0_b; 141 uint8_t m_via_1_a; 142 uint8_t m_via_1_b; 143 offs_t m_zpa; 144 uint8_t m_last_n; 145 uint8_t m_char_mem[0x800]; 146 std::unique_ptr<uint32_t[]> m_hgr_map; 147 148 bool m_sync; 149 bool m_rom_has_been_disabled; 150 int m_cnxx_slot; 151 uint8_t m_indir_bank; 152 153 uint8_t *m_bank2, *m_bank3, *m_bank4, *m_bank5, *m_bank8, *m_bank9; 154 uint8_t *m_bank10, *m_bank11; 155 uint8_t *m_bank6, *m_bank7rd, *m_bank7wr; 156 int m_bell_state; 157 int m_c040_time; 158 uint16_t m_lastchar, m_strobe; 159 uint8_t m_transchar; 160 bool m_charwrt; 161 162 emu_timer *m_scanstart, *m_scanend; 163 164 int m_analog_sel; 165 bool m_ramp_active; 166 int m_pdl_charge; 167 int m_va, m_vb, m_vc; 168 int m_smoothscr; 169 170 int m_inh_state; 171 }; 172 173 #endif // MAME_INCLUDES_APPLE3_H 174