1 // license:BSD-3-Clause 2 // copyright-holders:Nathan Woods, Raphael Nabet, R. Belmont 3 /***************************************************************************** 4 * 5 * includes/mac.h 6 * 7 * Macintosh driver declarations 8 * 9 ****************************************************************************/ 10 #ifndef MAME_INCLUDES_MAC_H 11 #define MAME_INCLUDES_MAC_H 12 13 #pragma once 14 15 #include "machine/8530scc.h" 16 #include "machine/6522via.h" 17 #include "machine/ram.h" 18 #include "machine/timer.h" 19 #include "machine/egret.h" 20 #include "machine/cuda.h" 21 #include "machine/macadb.h" 22 #include "bus/nubus/nubus.h" 23 #include "bus/macpds/macpds.h" 24 #include "machine/applefdc.h" 25 #include "machine/ncr539x.h" 26 #include "machine/ncr5380.h" 27 #include "machine/macrtc.h" 28 #include "sound/asc.h" 29 #include "sound/awacs.h" 30 #include "sound/dac.h" 31 #include "cpu/m68000/m68000.h" 32 #include "emupal.h" 33 #include "screen.h" 34 35 #define MAC_SCREEN_NAME "screen" 36 #define MAC_539X_1_TAG "539x_1" 37 #define MAC_539X_2_TAG "539x_2" 38 39 // model helpers 40 #define ADB_IS_BITBANG_CLASS ((m_model == MODEL_MAC_SE || m_model == MODEL_MAC_CLASSIC) || (m_model >= MODEL_MAC_II && m_model <= MODEL_MAC_IICI) || (m_model == MODEL_MAC_SE30) || (m_model == MODEL_MAC_QUADRA_700)) 41 #define ADB_IS_EGRET (m_model >= MODEL_MAC_LC && m_model <= MODEL_MAC_CLASSIC_II) || ((m_model >= MODEL_MAC_IISI) && (m_model <= MODEL_MAC_IIVI)) 42 #define ADB_IS_CUDA ((m_model >= MODEL_MAC_COLOR_CLASSIC && m_model <= MODEL_MAC_LC_580) || ((m_model >= MODEL_MAC_QUADRA_660AV) && (m_model <= MODEL_MAC_QUADRA_630)) || (m_model >= MODEL_MAC_POWERMAC_6100)) 43 #define ADB_IS_PM_CLASS ((m_model >= MODEL_MAC_PORTABLE && m_model <= MODEL_MAC_PB100) || (m_model >= MODEL_MAC_PB140 && m_model <= MODEL_MAC_PBDUO_270c)) 44 45 // video parameters for classic Macs 46 #define MAC_H_VIS (512) 47 #define MAC_V_VIS (342) 48 #define MAC_H_TOTAL (704) // (512+192) 49 #define MAC_V_TOTAL (370) // (342+28) 50 51 /*----------- defined in machine/mac.c -----------*/ 52 53 void mac_fdc_set_enable_lines(device_t *device, int enable_mask); 54 55 /* Mac driver data */ 56 57 class mac_state : public driver_device 58 { 59 public: mac_state(const machine_config & mconfig,device_type type,const char * tag)60 mac_state(const machine_config &mconfig, device_type type, const char *tag) : 61 driver_device(mconfig, type, tag), 62 m_maincpu(*this, "maincpu"), 63 m_via1(*this, "via6522_0"), 64 m_via2(*this, "via6522_1"), 65 m_asc(*this, "asc"), 66 m_awacs(*this, "awacs"), 67 m_egret(*this, EGRET_TAG), 68 m_cuda(*this, CUDA_TAG), 69 m_macadb(*this, "macadb"), 70 m_ram(*this, RAM_TAG), 71 m_scc(*this, "scc"), 72 m_539x_1(*this, MAC_539X_1_TAG), 73 m_539x_2(*this, MAC_539X_2_TAG), 74 m_ncr5380(*this, "ncr5380"), 75 m_fdc(*this, "fdc"), 76 m_rtc(*this, "rtc"), 77 m_montype(*this, "MONTYPE"), 78 m_main_buffer(true), 79 m_vram(*this,"vram"), 80 m_vram16(*this,"vram16"), 81 m_via2_ca1_hack(0), 82 m_screen(*this, "screen"), 83 m_palette(*this, "palette") 84 { 85 m_rom_size = 0; 86 m_rom_ptr = nullptr; 87 } 88 89 void add_scsi(machine_config &config, bool cdrom = false); 90 void add_base_devices(machine_config &config, bool rtc = true, bool super_woz = false); 91 void add_asc(machine_config &config, asc_device::asc_type type = asc_device::asc_type::ASC); 92 void add_nubus(machine_config &config, bool bank1 = true, bool bank2 = true); 93 template <typename T> void add_nubus_pds(machine_config &config, const char *slot_tag, T &&opts); 94 void add_via1_adb(machine_config &config, bool macii); 95 void add_via2(machine_config &config); 96 void add_pb1xx_vias(machine_config &config); 97 void add_pb1xx_screen(machine_config &config); 98 void add_egret(machine_config &config, int type); 99 void add_cuda(machine_config &config, int type); 100 101 void maclc(machine_config &config, bool cpu = true, bool egret = true, asc_device::asc_type asc_type = asc_device::asc_type::V8); 102 void macpb170(machine_config &config); 103 void maciisi(machine_config &config); 104 void maclc2(machine_config &config, bool egret = true); 105 void maclc3(machine_config &config, bool egret = true); 106 void macpd210(machine_config &config); 107 void maciici(machine_config &config); 108 void maciix(machine_config &config, bool nubus_bank1 = true, bool nubus_bank2 = true); 109 void maclc520(machine_config &config); 110 void pwrmac(machine_config &config); 111 void maciivx(machine_config &config); 112 void maccclas(machine_config &config); 113 void maciivi(machine_config &config); 114 void macpb160(machine_config &config); 115 void maciicx(machine_config &config); 116 void macqd700(machine_config &config); 117 void macse30(machine_config &config); 118 void macpb180(machine_config &config); 119 void macpb145(machine_config &config); 120 void macpb180c(machine_config &config); 121 void maciifx(machine_config &config); 122 void macpb140(machine_config &config); 123 void macclas2(machine_config &config); 124 void macii(machine_config &config, bool cpu = true, asc_device::asc_type asc_type = asc_device::asc_type::ASC, 125 bool nubus = true, bool nubus_bank1 = true, bool nubus_bank2 = true); 126 void maciihmu(machine_config &config); 127 128 void init_maclc2(); 129 void init_maciifdhd(); 130 void init_macse30(); 131 void init_maciivx(); 132 void init_maciivi(); 133 void init_macii(); 134 void init_macclassic(); 135 void init_macclassic2(); 136 void init_maciifx(); 137 void init_maclc(); 138 void init_macse(); 139 void init_macpm6100(); 140 void init_maclc520(); 141 void init_maciici(); 142 void init_maciix(); 143 void init_maclrcclassic(); 144 void init_maciisi(); 145 void init_maciicx(); 146 void init_maclc3(); 147 void init_maclc3plus(); 148 void init_macpm7100(); 149 void init_macpm8100(); 150 151 /* tells which model is being emulated (set by macxxx_init) */ 152 enum model_t 153 { 154 MODEL_MAC_128K512K, // 68000 machines 155 MODEL_MAC_512KE, 156 MODEL_MAC_PLUS, 157 MODEL_MAC_SE, 158 MODEL_MAC_CLASSIC, 159 160 MODEL_MAC_PORTABLE, // Portable/PB100 are sort of hybrid classic and Mac IIs 161 MODEL_MAC_PB100, 162 163 MODEL_MAC_II, // Mac II class 68020/030 machines 164 MODEL_MAC_II_FDHD, 165 MODEL_MAC_IIX, 166 MODEL_MAC_IICX, 167 MODEL_MAC_IICI, 168 MODEL_MAC_IISI, 169 MODEL_MAC_IIVX, 170 MODEL_MAC_IIVI, 171 MODEL_MAC_IIFX, 172 MODEL_MAC_SE30, 173 174 MODEL_MAC_LC, // LC class 68030 machines, generally using a V8 or compatible gate array 175 MODEL_MAC_LC_II, 176 MODEL_MAC_LC_III, 177 MODEL_MAC_LC_III_PLUS, 178 MODEL_MAC_CLASSIC_II, 179 MODEL_MAC_COLOR_CLASSIC, 180 181 MODEL_MAC_LC_475, // LC III clones with Cuda instead of Egret and 68LC040 on most models 182 MODEL_MAC_LC_520, 183 MODEL_MAC_LC_550, 184 MODEL_MAC_TV, 185 MODEL_MAC_LC_575, 186 MODEL_MAC_LC_580, 187 188 MODEL_MAC_PB140, // 68030 PowerBooks. 140/145/145B/170 all have the same machine ID 189 MODEL_MAC_PB160, // 160/180/165 all have the same machine ID too 190 MODEL_MAC_PB165c, 191 MODEL_MAC_PB180c, 192 MODEL_MAC_PB150, // 150 is fairly radically different from the other 1x0s 193 194 MODEL_MAC_PBDUO_210, // 68030 PowerBook Duos 195 MODEL_MAC_PBDUO_230, 196 MODEL_MAC_PBDUO_250, 197 MODEL_MAC_PBDUO_270c, 198 199 MODEL_MAC_QUADRA_700, // 68(LC)040 desktops 200 MODEL_MAC_QUADRA_610, 201 MODEL_MAC_QUADRA_650, 202 MODEL_MAC_QUADRA_800, 203 MODEL_MAC_QUADRA_900, 204 MODEL_MAC_QUADRA_950, 205 MODEL_MAC_QUADRA_660AV, 206 MODEL_MAC_QUADRA_840AV, 207 MODEL_MAC_QUADRA_605, 208 MODEL_MAC_QUADRA_630, 209 210 MODEL_MAC_PB550c, // 68(LC)040 PowerBooks 211 MODEL_MAC_PB520, 212 MODEL_MAC_PB520c, 213 MODEL_MAC_PB540, 214 MODEL_MAC_PB540c, 215 MODEL_MAC_PB190, 216 MODEL_MAC_PB190cs, 217 218 MODEL_MAC_POWERMAC_6100, // NuBus PowerMacs 219 MODEL_MAC_POWERMAC_7100, 220 MODEL_MAC_POWERMAC_8100 221 }; 222 223 model_t m_model; 224 225 private: 226 required_device<cpu_device> m_maincpu; 227 required_device<via6522_device> m_via1; 228 optional_device<via6522_device> m_via2; 229 optional_device<asc_device> m_asc; 230 optional_device<awacs_device> m_awacs; 231 optional_device<egret_device> m_egret; 232 optional_device<cuda_device> m_cuda; 233 optional_device<macadb_device> m_macadb; 234 required_device<ram_device> m_ram; 235 required_device<scc8530_legacy_device> m_scc; 236 optional_device<ncr539x_device> m_539x_1; 237 optional_device<ncr539x_device> m_539x_2; 238 optional_device<ncr5380_device> m_ncr5380; 239 required_device<applefdc_base_device> m_fdc; 240 optional_device<rtc3430042_device> m_rtc; 241 242 //required_ioport m_mouse0, m_mouse1, m_mouse2; 243 //optional_ioport_array<7> m_keys; 244 optional_ioport m_montype; 245 246 virtual void machine_start() override; 247 virtual void machine_reset() override; 248 249 enum 250 { 251 RBV_TYPE_RBV = 0, 252 RBV_TYPE_V8, 253 RBV_TYPE_SONORA, 254 RBV_TYPE_DAFB 255 }; 256 257 258 uint32_t m_overlay; 259 260 uint32_t m_via2_vbl; 261 uint32_t m_se30_vbl_enable; 262 uint8_t m_nubus_irq_state; 263 264 emu_timer *m_overlay_timeout; 265 TIMER_CALLBACK_MEMBER(overlay_timeout_func); 266 uint32_t rom_switch_r(offs_t offset); 267 268 bool m_main_buffer; 269 int m_adb_irq_pending; 270 int m_screen_buffer; 271 int irq_count, ca1_data, ca2_data; 272 273 // 60.15 Hz timer for RBV/V8/Sonora/Eagle/VASP/etc. 274 emu_timer *m_6015_timer; 275 276 // ADB refresh timer, independent of anything else going on 277 emu_timer *m_adbupdate_timer; 278 WRITE_LINE_MEMBER(adb_irq_w)279 WRITE_LINE_MEMBER(adb_irq_w) { m_adb_irq_pending = state; } 280 281 // RBV and friends (V8, etc) 282 uint8_t m_rbv_regs[256], m_rbv_ier, m_rbv_ifr, m_rbv_type, m_rbv_montype, m_rbv_vbltime; 283 uint32_t m_rbv_colors[3], m_rbv_count, m_rbv_clutoffs, m_rbv_immed10wr; 284 uint32_t m_rbv_palette[256]; 285 uint8_t m_sonora_vctl[8]; 286 emu_timer *m_vbl_timer, *m_cursor_timer; 287 uint16_t m_cursor_line; 288 289 // this is shared among all video setups with vram 290 optional_shared_ptr<uint32_t> m_vram; 291 optional_shared_ptr<uint16_t> m_vram16; 292 293 // interrupts 294 int m_scc_interrupt, m_via_interrupt, m_via2_interrupt, m_scsi_interrupt, m_asc_interrupt, m_last_taken_interrupt; 295 296 // defined in machine/mac.c 297 void v8_resize(); 298 void set_memory_overlay(int overlay); 299 void scc_mouse_irq( int x, int y ); 300 void nubus_slot_interrupt(uint8_t slot, uint32_t state); 301 DECLARE_WRITE_LINE_MEMBER(set_scc_interrupt); 302 void set_via_interrupt(int value); 303 void set_via2_interrupt(int value); 304 void field_interrupts(); 305 void vblank_irq(); 306 void rbv_recalc_irqs(); 307 void update_volume(); 308 309 uint16_t mac_via_r(offs_t offset); 310 void mac_via_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 311 uint16_t mac_via2_r(offs_t offset); 312 void mac_via2_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 313 uint16_t mac_autovector_r(offs_t offset); 314 void mac_autovector_w(offs_t offset, uint16_t data); 315 uint16_t mac_iwm_r(offs_t offset, uint16_t mem_mask = ~0); 316 void mac_iwm_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 317 uint16_t mac_scc_r(offs_t offset); 318 void mac_scc_w(offs_t offset, uint16_t data); 319 void mac_scc_2_w(offs_t offset, uint16_t data); 320 uint16_t macplus_scsi_r(offs_t offset, uint16_t mem_mask = ~0); 321 void macplus_scsi_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 322 void macii_scsi_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 323 uint32_t macii_scsi_drq_r(offs_t offset, uint32_t mem_mask = ~0); 324 void macii_scsi_drq_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 325 326 uint32_t rbv_ramdac_r(); 327 void rbv_ramdac_w(offs_t offset, uint32_t data); 328 void ariel_ramdac_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 329 uint8_t mac_sonora_vctl_r(offs_t offset); 330 void mac_sonora_vctl_w(offs_t offset, uint8_t data); 331 uint8_t mac_rbv_r(offs_t offset); 332 void mac_rbv_w(offs_t offset, uint8_t data); 333 334 uint32_t mac_read_id(); 335 336 uint16_t mac_config_r(); 337 338 uint32_t biu_r(offs_t offset, uint32_t mem_mask = ~0); 339 void biu_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); 340 uint8_t oss_r(offs_t offset); 341 void oss_w(offs_t offset, uint8_t data); 342 uint32_t buserror_r(); 343 uint8_t swimiop_r(offs_t offset); 344 void swimiop_w(offs_t offset, uint8_t data); 345 uint8_t scciop_r(offs_t offset); 346 void scciop_w(offs_t offset, uint8_t data); 347 348 uint8_t hmc_r(); 349 void hmc_w(offs_t offset, uint8_t data); 350 uint8_t amic_dma_r(); 351 void amic_dma_w(offs_t offset, uint8_t data); 352 uint8_t pmac_diag_r(offs_t offset); 353 354 DECLARE_WRITE_LINE_MEMBER(nubus_irq_9_w); 355 DECLARE_WRITE_LINE_MEMBER(nubus_irq_a_w); 356 DECLARE_WRITE_LINE_MEMBER(nubus_irq_b_w); 357 DECLARE_WRITE_LINE_MEMBER(nubus_irq_c_w); 358 DECLARE_WRITE_LINE_MEMBER(nubus_irq_d_w); 359 DECLARE_WRITE_LINE_MEMBER(nubus_irq_e_w); 360 361 DECLARE_WRITE_LINE_MEMBER(irq_539x_1_w); 362 DECLARE_WRITE_LINE_MEMBER(drq_539x_1_w); 363 364 DECLARE_WRITE_LINE_MEMBER(cuda_reset_w); 365 366 DECLARE_WRITE_LINE_MEMBER(mac_scsi_irq); 367 DECLARE_WRITE_LINE_MEMBER(mac_asc_irq); 368 369 void mac512ke_map(address_map &map); 370 void macii_map(address_map &map); 371 void maciici_map(address_map &map); 372 void maciifx_map(address_map &map); 373 void maclc3_map(address_map &map); 374 void maclc_map(address_map &map); 375 void macpb140_map(address_map &map); 376 void macpb160_map(address_map &map); 377 void macpb165c_map(address_map &map); 378 void macpd210_map(address_map &map); 379 void macplus_map(address_map &map); 380 void macse30_map(address_map &map); 381 void macse_map(address_map &map); 382 void pwrmac_map(address_map &map); 383 void quadra700_map(address_map &map); 384 has_adb()385 inline bool has_adb() { return m_model >= MODEL_MAC_SE; } 386 387 // wait states for accessing the VIA 388 int m_via_cycles; 389 390 uint8_t m_oss_regs[0x400]; 391 392 // AMIC for x100 PowerMacs 393 uint8_t m_amic_regs[0x200]; 394 395 // HMC for x100 PowerMacs 396 uint64_t m_hmc_reg, m_hmc_shiftout; 397 398 int m_via2_ca1_hack; 399 optional_device<screen_device> m_screen; 400 optional_device<palette_device> m_palette; 401 402 uint32_t m_rom_size; 403 uint32_t *m_rom_ptr; 404 405 emu_timer *m_scanline_timer; 406 407 uint8_t m_pm_req, m_pm_state, m_pm_dptr, m_pm_cmd; 408 409 DECLARE_VIDEO_START(mac); 410 DECLARE_VIDEO_START(macsonora); 411 DECLARE_VIDEO_RESET(macrbv); 412 DECLARE_VIDEO_START(macv8); 413 DECLARE_VIDEO_RESET(macsonora); 414 DECLARE_VIDEO_RESET(maceagle); 415 DECLARE_VIDEO_START(macrbv); 416 uint32_t screen_update_mac(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 417 uint32_t screen_update_macse30(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 418 uint32_t screen_update_macrbv(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 419 uint32_t screen_update_macrbvvram(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 420 uint32_t screen_update_macv8(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 421 uint32_t screen_update_macsonora(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 422 uint32_t screen_update_macpbwd(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 423 DECLARE_WRITE_LINE_MEMBER(mac_rbv_vbl); 424 TIMER_CALLBACK_MEMBER(mac_6015_tick); 425 TIMER_CALLBACK_MEMBER(mac_adbrefresh_tick); 426 TIMER_CALLBACK_MEMBER(mac_scanline_tick); 427 DECLARE_WRITE_LINE_MEMBER(mac_adb_via_out_cb2); 428 uint8_t mac_via_in_a(); 429 uint8_t mac_via_in_b(); 430 uint8_t mac_via_in_b_ii(); 431 void mac_via_out_a(uint8_t data); 432 void mac_via_out_b(uint8_t data); 433 uint8_t mac_via_in_a_pmu(); 434 uint8_t mac_via_in_b_pmu(); 435 void mac_via_out_a_pmu(uint8_t data); 436 void mac_via_out_b_pmu(uint8_t data); 437 void mac_via_out_b_bbadb(uint8_t data); 438 void mac_via_out_b_egadb(uint8_t data); 439 void mac_via_out_b_cdadb(uint8_t data); 440 uint8_t mac_via_in_b_via2pmu(); 441 void mac_via_out_b_via2pmu(uint8_t data); 442 uint8_t mac_via2_in_a(); 443 uint8_t mac_via2_in_b(); 444 void mac_via2_out_a(uint8_t data); 445 void mac_via2_out_b(uint8_t data); 446 uint8_t mac_via2_in_a_pmu(); 447 uint8_t mac_via2_in_b_pmu(); 448 void mac_via2_out_a_pmu(uint8_t data); 449 void mac_via2_out_b_pmu(uint8_t data); 450 void mac_state_load(); 451 DECLARE_WRITE_LINE_MEMBER(mac_via_irq); 452 DECLARE_WRITE_LINE_MEMBER(mac_via2_irq); 453 void set_scc_waitrequest(int waitrequest); 454 void mac_driver_init(model_t model); 455 void mac_install_memory(offs_t memory_begin, offs_t memory_end, offs_t memory_size, void *memory_data, int is_rom, const char *bank); 456 offs_t mac_dasm_override(std::ostream &stream, offs_t pc, const util::disasm_interface::data_buffer &opcodes, const util::disasm_interface::data_buffer ¶ms); 457 }; 458 459 #endif // MAME_INCLUDES_MAC_H 460