1 // license:GPL-2.0+ 2 // copyright-holders:Raphael Nabet 3 /***************************************************************************** 4 * 5 * includes/lisa.h 6 * 7 * Lisa driver declarations 8 * 9 ****************************************************************************/ 10 11 #ifndef MAME_INCLUDES_LISA_H 12 #define MAME_INCLUDES_LISA_H 13 14 #include "cpu/m6502/m6504.h" 15 #include "cpu/m68000/m68000.h" 16 #include "machine/74259.h" 17 #include "machine/6522via.h" 18 #include "machine/6522via.h" 19 #include "machine/8530scc.h" 20 #include "machine/applefdc.h" 21 #include "machine/nvram.h" 22 #include "machine/sonydriv.h" 23 #include "sound/spkrdev.h" 24 #include "emupal.h" 25 #include "screen.h" 26 27 /* lisa MMU segment regs */ 28 struct real_mmu_entry 29 { 30 uint16_t sorg; 31 uint16_t slim; 32 }; 33 34 /* MMU regs translated into a more efficient format */ 35 enum mmu_entry_t { RAM_stack_r, RAM_r, RAM_stack_rw, RAM_rw, IO, invalid, special_IO }; 36 37 struct mmu_entry 38 { 39 offs_t sorg; /* (real_sorg & 0x0fff) << 9 */ 40 mmu_entry_t type; /* <-> (real_slim & 0x0f00) */ 41 int slim; /* (~ ((real_slim & 0x00ff) << 9)) & 0x01ffff */ 42 }; 43 44 enum floppy_hardware_t 45 { 46 twiggy, /* twiggy drives (Lisa 1) */ 47 sony_lisa2, /* 3.5'' drive with LisaLite adapter (Lisa 2) */ 48 sony_lisa210 /* 3.5'' drive with modified fdc hardware (Lisa 2/10, Mac XL) */ 49 }; 50 51 enum clock_mode_t 52 { 53 clock_timer_disable = 0, 54 timer_disable = 1, 55 timer_interrupt = 2, /* timer underflow generates interrupt */ 56 timer_power_on = 3 /* timer underflow turns system on if it is off and gens interrupt */ 57 }; /* clock mode */ 58 59 /* clock registers */ 60 struct clock_regs_t 61 { 62 long alarm; /* alarm (20-bit binary) */ 63 int years; /* years (4-bit binary ) */ 64 int days1; /* days (BCD : 1-366) */ 65 int days2; 66 int days3; 67 int hours1; /* hours (BCD : 0-23) */ 68 int hours2; 69 int minutes1; /* minutes (BCD : 0-59) */ 70 int minutes2; 71 int seconds1; /* seconds (BCD : 0-59) */ 72 int seconds2; 73 int tenths; /* tenths of second (BCD : 0-9) */ 74 75 int clock_write_ptr; /* clock byte to be written next (-1 if clock write disabled) */ 76 77 enum clock_mode_t clock_mode; 78 }; 79 80 struct lisa_features_t 81 { 82 unsigned int has_fast_timers : 1; /* I/O board VIAs are clocked at 1.25 MHz (?) instead of .5 MHz (?) (Lisa 2/10, Mac XL) */ 83 /* Note that the beep routine in boot ROMs implies that 84 VIA clock is 1.25 times faster with fast timers than with 85 slow timers. I read the schematics again and again, and 86 I simply don't understand : in one case the VIA is 87 connected to the 68k E clock, which is CPUCK/10, and in 88 another case, to a generated PH2 clock which is CPUCK/4, 89 with additional logic to keep it in phase with the 68k 90 memory cycle. After hearing the beep when MacWorks XL 91 boots, I bet the correct values are .625 MHz and .5 MHz. 92 Maybe the schematics are wrong, and PH2 is CPUCK/8. 93 Maybe the board uses a 6522 variant with different 94 timings. */ 95 floppy_hardware_t floppy_hardware; 96 unsigned int has_double_sided_floppy : 1; /* true on lisa 1 and *hacked* lisa 2/10 / Mac XL */ 97 unsigned int has_mac_xl_video : 1; /* modified video for MacXL */ 98 }; 99 100 101 class lisa_state : public driver_device 102 { 103 public: lisa_state(const machine_config & mconfig,device_type type,const char * tag)104 lisa_state(const machine_config &mconfig, device_type type, const char *tag) : 105 driver_device(mconfig, type, tag), 106 m_maincpu(*this, "maincpu"), 107 m_via0(*this, "via6522_0"), 108 m_via1(*this, "via6522_1"), 109 m_fdc(*this, "fdc"), 110 m_scc(*this, "scc"), 111 m_speaker(*this, "speaker"), 112 m_nvram(*this, "nvram"), 113 m_latch(*this, "latch"), 114 m_fdc_cpu(*this,"fdccpu"), 115 m_fdc_rom(*this,"fdc_rom"), 116 m_fdc_ram(*this,"fdc_ram"), 117 m_io_line0(*this, "LINE0"), 118 m_io_line1(*this, "LINE1"), 119 m_io_line2(*this, "LINE2"), 120 m_io_line3(*this, "LINE3"), 121 m_io_line4(*this, "LINE4"), 122 m_io_line5(*this, "LINE5"), 123 m_io_line6(*this, "LINE6"), 124 m_io_line7(*this, "LINE7"), 125 m_io_mouse_x(*this, "MOUSE_X"), 126 m_io_mouse_y(*this, "MOUSE_Y"), 127 m_palette(*this, "palette"), 128 m_screen(*this, "screen") 129 { } 130 131 void lisa(machine_config &config); 132 void lisa210(machine_config &config); 133 void macxl(machine_config &config); 134 135 void init_lisa210(); 136 void init_mac_xl(); 137 void init_lisa2(); 138 139 private: 140 required_device<m68000_base_device> m_maincpu; 141 required_device<via6522_device> m_via0; 142 required_device<via6522_device> m_via1; 143 optional_device<applefdc_base_device> m_fdc; 144 required_device<scc8530_legacy_device> m_scc; 145 required_device<speaker_sound_device> m_speaker; 146 required_device<nvram_device> m_nvram; 147 required_device<ls259_device> m_latch; 148 required_device<m6504_device> m_fdc_cpu; 149 150 required_shared_ptr<uint8_t> m_fdc_rom; 151 required_shared_ptr<uint8_t> m_fdc_ram; 152 153 required_ioport m_io_line0; 154 required_ioport m_io_line1; 155 required_ioport m_io_line2; 156 required_ioport m_io_line3; 157 required_ioport m_io_line4; 158 required_ioport m_io_line5; 159 required_ioport m_io_line6; 160 required_ioport m_io_line7; 161 required_ioport m_io_mouse_x; 162 required_ioport m_io_mouse_y; 163 164 required_device<palette_device> m_palette; 165 required_device<screen_device> m_screen; 166 167 uint8_t *m_ram_ptr; 168 uint8_t *m_rom_ptr; 169 uint8_t *m_videoROM_ptr; 170 int m_setup; 171 int m_seg; 172 real_mmu_entry m_real_mmu_regs[4][128]; 173 mmu_entry m_mmu_regs[4][128]; 174 int m_diag2; 175 int m_test_parity; 176 uint16_t m_mem_err_addr_latch; 177 int m_parity_error_pending; 178 int m_bad_parity_count; 179 std::unique_ptr<uint8_t[]> m_bad_parity_table; 180 int m_VTMSK; 181 int m_VTIR; 182 uint16_t m_video_address_latch; 183 uint16_t *m_videoram_ptr; 184 int m_KBIR; 185 int m_FDIR; 186 int m_DISK_DIAG; 187 int m_MT1; 188 int m_PWM_floppy_motor_speed; 189 int m_model; 190 lisa_features_t m_features; 191 int m_COPS_Ready; 192 int m_COPS_command; 193 int m_fifo_data[8]; 194 int m_fifo_size; 195 int m_fifo_head; 196 int m_fifo_tail; 197 int m_mouse_data_offset; 198 int m_COPS_force_unplug; 199 emu_timer *m_mouse_timer; 200 emu_timer *m_cops_ready_timer; 201 int m_hold_COPS_data; 202 int m_NMIcode; 203 clock_regs_t m_clock_regs; 204 int m_key_matrix[8]; 205 int m_last_mx; 206 int m_last_my; 207 int m_frame_count; 208 int m_videoROM_address; 209 uint8_t lisa_fdc_io_r(offs_t offset); 210 void lisa_fdc_io_w(offs_t offset, uint8_t data); 211 uint16_t lisa_r(offs_t offset, uint16_t mem_mask = ~0); 212 void lisa_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 213 uint16_t lisa_IO_r(offs_t offset, uint16_t mem_mask = ~0); 214 void lisa_IO_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 215 DECLARE_WRITE_LINE_MEMBER(diag1_w); 216 DECLARE_WRITE_LINE_MEMBER(diag2_w); 217 DECLARE_WRITE_LINE_MEMBER(seg1_w); 218 DECLARE_WRITE_LINE_MEMBER(seg2_w); 219 DECLARE_WRITE_LINE_MEMBER(setup_w); 220 DECLARE_WRITE_LINE_MEMBER(vtmsk_w); 221 DECLARE_WRITE_LINE_MEMBER(sfmsk_w); 222 DECLARE_WRITE_LINE_MEMBER(hdmsk_w); 223 224 virtual void machine_start() override; 225 virtual void machine_reset() override; 226 virtual void video_start() override; 227 void nvram_init(nvram_device &nvram, void *data, size_t size); 228 uint32_t screen_update_lisa(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 229 INTERRUPT_GEN_MEMBER(lisa_interrupt); 230 TIMER_CALLBACK_MEMBER(handle_mouse); 231 TIMER_CALLBACK_MEMBER(read_COPS_command); 232 TIMER_CALLBACK_MEMBER(set_COPS_ready); 233 void COPS_via_out_a(uint8_t data); 234 DECLARE_WRITE_LINE_MEMBER(COPS_via_out_ca2); 235 void COPS_via_out_b(uint8_t data); 236 DECLARE_WRITE_LINE_MEMBER(COPS_via_out_cb2); 237 238 void field_interrupts(); 239 void set_parity_error_pending(int value); 240 void set_VTIR(int value); 241 void cpu_board_control_access(offs_t offset); 242 void init_COPS(); 243 void reset_COPS(); 244 void lisa_fdc_ttl_glue_access(offs_t offset); 245 void COPS_send_data_if_possible(); 246 void COPS_queue_data(const uint8_t *data, int len); 247 void COPS_via_irq_func(int val); 248 void scan_keyboard(); 249 void unplug_keyboard(); 250 void plug_keyboard(); 251 void lisa210_fdc_map(address_map &map); 252 void lisa_fdc_map(address_map &map); 253 void lisa_map(address_map &map); 254 }; 255 256 #endif // MAME_INCLUDES_LISA_H 257