Previous 199869 Revisions Next

r20519 Saturday 26th January, 2013 at 22:35:29 UTC by Curt Coder
(MESS) lisa: Removed runtime tagmap lookups. (nw)
[src/mess/drivers]lisa.c
[src/mess/includes]lisa.h
[src/mess/machine]lisa.c

trunk/src/mess/machine/lisa.c
r20518r20519
3636    Raphael Nabet, 2000-2003
3737*/
3838
39#include "emu.h"
4039#include "includes/lisa.h"
41#include "machine/6522via.h"
42#include "machine/applefdc.h"
43#include "devices/sonydriv.h"
44#include "cpu/m68000/m68000.h"
45#include "sound/speaker.h"
4640
4741
4842/*
r20518r20519
9185    a hard disk
9286*/
9387
94static void COPS_via_irq_func(device_t *device, int val);
95
96
9788const via6522_interface lisa_via6522_0_intf =
9889{
9990   /* COPS via */
r20518r20519
10394   DEVCB_DRIVER_MEMBER(lisa_state,COPS_via_out_a), DEVCB_DRIVER_MEMBER(lisa_state,COPS_via_out_b),
10495   DEVCB_DRIVER_MEMBER(lisa_state,COPS_via_out_ca2), DEVCB_DRIVER_MEMBER(lisa_state,COPS_via_out_cb2),
10596   DEVCB_NULL, DEVCB_NULL,
106   DEVCB_LINE(COPS_via_irq_func),
97   DEVCB_DRIVER_LINE_MEMBER(lisa_state,COPS_via_irq_func)
10798};
10899
109100const via6522_interface lisa_via6522_1_intf =
r20518r20519
114105   DEVCB_NULL, DEVCB_NULL,
115106   DEVCB_NULL, DEVCB_NULL,
116107   DEVCB_NULL, DEVCB_NULL,
117   DEVCB_NULL, DEVCB_NULL,
108   DEVCB_NULL, DEVCB_NULL
118109};
119110
120111/*
r20518r20519
149140    Interrupt handling
150141*/
151142
152static void lisa_field_interrupts(running_machine &machine)
143void lisa_state::field_interrupts()
153144{
154   lisa_state *state = machine.driver_data<lisa_state>();
155   if (state->m_parity_error_pending)
145   if (m_parity_error_pending)
156146      return; /* don't touch anything... */
157147
158148#if 0
159149   if (RSIR)
160150      // serial interrupt
161      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
151      m_maincpu->set_input_line_and_vector(M68K_IRQ_6, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
162152   else if (int0)
163153      // external interrupt
164      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
154      m_maincpu->set_input_line_and_vector(M68K_IRQ_5, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
165155   else if (int1)
166156      // external interrupt
167      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
157      m_maincpu->set_input_line_and_vector(M68K_IRQ_4, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
168158   else if (int2)
169159      // external interrupt
170      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
160      m_maincpu->set_input_line_and_vector(M68K_IRQ_3, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
171161   else
172162#endif
173   if (state->m_KBIR)
163   if (m_KBIR)
174164      /* COPS VIA interrupt */
175      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
176   else if (state->m_FDIR || state->m_VTIR)
165      m_maincpu->set_input_line_and_vector(M68K_IRQ_2, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
166   else if (m_FDIR || m_VTIR)
177167      /* floppy disk or VBl */
178      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
168      m_maincpu->set_input_line_and_vector(M68K_IRQ_1, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
179169   else
180170      /* clear all interrupts */
181      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
171      m_maincpu->set_input_line_and_vector(M68K_IRQ_1, CLEAR_LINE, M68K_INT_ACK_AUTOVECTOR);
182172}
183173
184static void set_parity_error_pending(running_machine &machine, int value)
174void lisa_state::set_parity_error_pending(int value)
185175{
186   lisa_state *state = machine.driver_data<lisa_state>();
187176#if 1
188177   /* does not work well due to bugs in 68k cores */
189   state->m_parity_error_pending = value;
190   if (state->m_parity_error_pending)
178   m_parity_error_pending = value;
179   if (m_parity_error_pending)
191180   {
192      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
181      m_maincpu->set_input_line_and_vector(M68K_IRQ_7, ASSERT_LINE, M68K_INT_ACK_AUTOVECTOR);
193182   }
194183   else
195184   {
196      machine.device("maincpu")->execute().set_input_line(M68K_IRQ_7, CLEAR_LINE);
185      m_maincpu->set_input_line(M68K_IRQ_7, CLEAR_LINE);
197186   }
198187#else
199188   /* work-around... */
200   if ((! state->m_parity_error_pending) && value)
189   if ((! m_parity_error_pending) && value)
201190   {
202      state->m_parity_error_pending = 1;
203      machine.device("maincpu")->execute().set_input_line_and_vector(M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR);
191      m_parity_error_pending = 1;
192      m_maincpu->set_input_line_and_vector(M68K_IRQ_7, PULSE_LINE, M68K_INT_ACK_AUTOVECTOR);
204193   }
205   else if (state->m_parity_error_pending && (! value))
194   else if (m_parity_error_pending && (! value))
206195   {
207      state->m_parity_error_pending = 0;
208      lisa_field_interrupts(machine);
196      m_parity_error_pending = 0;
197      field_interrupts();
209198   }
210199#endif
211200}
212201
213INLINE void set_VTIR(running_machine &machine, int value)
202void lisa_state::set_VTIR(int value)
214203{
215   lisa_state *state = machine.driver_data<lisa_state>();
216   if (state->m_VTIR != value)
204   if (m_VTIR != value)
217205   {
218      state->m_VTIR = value;
219      if (state->m_VTIR==1)
220         lisa_field_interrupts(machine);
206      m_VTIR = value;
207      if (m_VTIR==1)
208         field_interrupts();
221209   }
222210}
223211
r20518r20519
227215    keyboard interface (COPS simulation; our COPS CPU core is too broken and too esoteric to emulate this correctly, I tried)
228216*/
229217
230INLINE void COPS_send_data_if_possible(running_machine &machine)
218void lisa_state::COPS_send_data_if_possible()
231219{
232   lisa_state *state = machine.driver_data<lisa_state>();
233   via6522_device *via_0 = machine.device<via6522_device>("via6522_0");
234   address_space &space = machine.device("maincpu")->memory().space(AS_PROGRAM);
220   address_space &space = m_maincpu->space(AS_PROGRAM);
235221
236   if ((! state->m_hold_COPS_data) && state->m_fifo_size && (! state->m_COPS_Ready))
222   if ((! m_hold_COPS_data) && m_fifo_size && (! m_COPS_Ready))
237223   {
238//        printf("COPsim: sending %02x to VIA\n", state->m_fifo_data[state->m_fifo_head]);
224//        printf("COPsim: sending %02x to VIA\n", m_fifo_data[m_fifo_head]);
239225
240      via_0->write_porta(space, 0, state->m_fifo_data[state->m_fifo_head]);   /* output data */
241      if (state->m_fifo_head == state->m_mouse_data_offset)
242         state->m_mouse_data_offset = -1;    /* we just phased out the mouse data in buffer */
243      state->m_fifo_head = (state->m_fifo_head+1) & 0x7;
244      state->m_fifo_size--;
245      via_0->write_ca1(1);        /* pulse ca1 so that VIA reads it */
246      via_0->write_ca1(0);        /* BTW, I have no idea how a real COPS does it ! */
226      m_via0->write_porta(space, 0, m_fifo_data[m_fifo_head]);   /* output data */
227      if (m_fifo_head == m_mouse_data_offset)
228         m_mouse_data_offset = -1;    /* we just phased out the mouse data in buffer */
229      m_fifo_head = (m_fifo_head+1) & 0x7;
230      m_fifo_size--;
231      m_via0->write_ca1(1);        /* pulse ca1 so that VIA reads it */
232      m_via0->write_ca1(0);        /* BTW, I have no idea how a real COPS does it ! */
247233   }
248234}
249235
250236/* send data (queue it into the FIFO if needed) */
251static void COPS_queue_data(running_machine &machine, const UINT8 *data, int len)
237void lisa_state::COPS_queue_data(const UINT8 *data, int len)
252238{
253   lisa_state *state = machine.driver_data<lisa_state>();
254239#if 0
255   if (state->m_fifo_size + len <= 8)
240   if (m_fifo_size + len <= 8)
256241#else
257242   /* trash old data */
258   while (state->m_fifo_size > 8 - len)
243   while (m_fifo_size > 8 - len)
259244   {
260      if (state->m_fifo_head == state->m_mouse_data_offset)
261         state->m_mouse_data_offset = -1;    /* we just phased out the mouse data in buffer */
262      state->m_fifo_head = (state->m_fifo_head+1) & 0x7;
263      state->m_fifo_size--;
245      if (m_fifo_head == m_mouse_data_offset)
246         m_mouse_data_offset = -1;    /* we just phased out the mouse data in buffer */
247      m_fifo_head = (m_fifo_head+1) & 0x7;
248      m_fifo_size--;
264249   }
265250#endif
266251
r20518r20519
269254
270255      while (len--)
271256      {
272         state->m_fifo_data[state->m_fifo_tail] = * (data++);
273         state->m_fifo_tail = (state->m_fifo_tail+1) & 0x7;
274         state->m_fifo_size++;
257         m_fifo_data[m_fifo_tail] = * (data++);
258         m_fifo_tail = (m_fifo_tail+1) & 0x7;
259         m_fifo_size++;
275260      }
276261
277262      /*logerror("COPS_queue_data : trying to send data to VIA\n");*/
278      COPS_send_data_if_possible(machine);
263      COPS_send_data_if_possible();
279264   }
280265}
281266
r20518r20519
288273
289274/* keyboard matrix to detect transition */
290275
291static void scan_keyboard(running_machine &machine)
276void lisa_state::scan_keyboard()
292277{
293   lisa_state *state = machine.driver_data<lisa_state>();
294278   int i, j;
295   int keybuf;
296279   UINT8 keycode;
297   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7" };
280   UINT8 keybuf[8] = { m_io_line0->read(), m_io_line1->read(), m_io_line2->read(), m_io_line3->read(),
281                  m_io_line4->read(), m_io_line5->read(), m_io_line6->read(), m_io_line7->read() };
298282
299   if (! state->m_COPS_force_unplug)
283   if (! m_COPS_force_unplug)
300284      for (i=0; i<8; i++)
301285      {
302         keybuf = machine.root_device().ioport(keynames[i])->read();
303
304         if (keybuf != state->m_key_matrix[i])
286         if (keybuf[i] != m_key_matrix[i])
305287         {   /* if state has changed, find first bit which has changed */
306288            /*logerror("keyboard state changed, %d %X\n", i, keybuf);*/
307289
308290            for (j=0; j<16; j++)
309291            {
310               if (((keybuf ^ state->m_key_matrix[i]) >> j) & 1)
292               if (((keybuf[i] ^ m_key_matrix[i]) >> j) & 1)
311293               {
312294                  /* update key_matrix */
313                  state->m_key_matrix[i] = (state->m_key_matrix[i] & ~ (1 << j)) | (keybuf & (1 << j));
295                  m_key_matrix[i] = (m_key_matrix[i] & ~ (1 << j)) | (keybuf[i] & (1 << j));
314296
315297                  /* create key code */
316298                  keycode = (i << 4) | j;
317                  if (keybuf & (1 << j))
299                  if (keybuf[i] & (1 << j))
318300                  {   /* key down */
319301                     keycode |= 0x80;
320302                  }
321303#if 0
322                  if (keycode == state->m_NMIcode)
304                  if (keycode == m_NMIcode)
323305                  {   /* generate NMI interrupt */
324                     machine.device("maincpu")->execute().set_input_line(M68K_IRQ_7, PULSE_LINE);
325                     machine.device("maincpu")->execute().set_input_line_vector(M68K_IRQ_7, M68K_INT_ACK_AUTOVECTOR);
306                     m_maincpu->set_input_line(M68K_IRQ_7, PULSE_LINE);
307                     m_maincpu->set_input_line_vector(M68K_IRQ_7, M68K_INT_ACK_AUTOVECTOR);
326308                  }
327309#endif
328                  COPS_queue_data(machine, & keycode, 1);
310                  COPS_queue_data(&keycode, 1);
329311               }
330312            }
331313         }
r20518r20519
344326      return; /* ???? */
345327#endif
346328
347   new_mx = machine().root_device().ioport("MOUSE_X")->read();
348   new_my = machine().root_device().ioport("MOUSE_Y")->read();
329   new_mx = m_io_mouse_x->read();
330   new_my = m_io_mouse_y->read();
349331
350332   /* see if it moved in the x coord */
351333   if (new_mx != m_last_mx)
r20518r20519
407389            m_fifo_size += 3;
408390
409391            /*logerror("handle_mouse : trying to send data to VIA\n");*/
410            COPS_send_data_if_possible(machine());
392            COPS_send_data_if_possible();
411393         }
412394         /* else, mouse data is lost forever (correct ??) */
413395      }
r20518r20519
418400TIMER_CALLBACK_MEMBER(lisa_state::read_COPS_command)
419401{
420402   int command;
421   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
422   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
403   address_space &space = m_maincpu->space(AS_PROGRAM);
423404
424405   m_COPS_Ready = 0;
425406
426407   /*logerror("read_COPS_command : trying to send data to VIA\n");*/
427   COPS_send_data_if_possible(machine());
408   COPS_send_data_if_possible();
428409
429410   /* some pull-ups allow the COPS to read 1s when the VIA port is not set as output */
430   command = (m_COPS_command | (~ via_0->read(space, VIA_DDRA))) & 0xff;
411   command = (m_COPS_command | (~ m_via0->read(space, VIA_DDRA))) & 0xff;
431412
432413//    printf("Dropping Ready, command = %02x\n", command);
433414
r20518r20519
581562            reply[5] = (m_clock_regs.minutes2 << 4) | m_clock_regs.seconds1;
582563            reply[6] = (m_clock_regs.seconds2 << 4) | m_clock_regs.tenths;
583564
584            COPS_queue_data(machine(), reply, 7);
565            COPS_queue_data(reply, 7);
585566         }
586567         break;
587568      }
r20518r20519
597578   machine().scheduler().timer_set(attotime::from_usec(20), timer_expired_delegate(FUNC(lisa_state::read_COPS_command),this));
598579}
599580
600static void reset_COPS(lisa_state *state)
581void lisa_state::reset_COPS()
601582{
602583   int i;
603584
604   state->m_fifo_size = 0;
605   state->m_fifo_head = 0;
606   state->m_fifo_tail = 0;
607   state->m_mouse_data_offset = -1;
585   m_fifo_size = 0;
586   m_fifo_head = 0;
587   m_fifo_tail = 0;
588   m_mouse_data_offset = -1;
608589
609590   for (i=0; i<8; i++)
610      state->m_key_matrix[i] = 0;
591      m_key_matrix[i] = 0;
611592
612   state->m_mouse_timer->reset();
593   m_mouse_timer->reset();
613594}
614595
615static void unplug_keyboard(running_machine &machine)
596void lisa_state::unplug_keyboard()
616597{
617598   static const UINT8 cmd[2] =
618599   {
r20518r20519
620601      0xFD    /* keyboard unplugged */
621602   };
622603
623   COPS_queue_data(machine, cmd, 2);
604   COPS_queue_data(cmd, 2);
624605}
625606
626
627static void plug_keyboard(running_machine &machine)
607void lisa_state::plug_keyboard()
628608{
629609   /*
630610       possible keyboard IDs according to Lisa Hardware Manual and boot ROM source code
r20518r20519
648628      0x3f    /* keyboard ID - US for now */
649629   };
650630
651   COPS_queue_data(machine, cmd, 2);
631   COPS_queue_data(cmd, 2);
652632}
653633
654634
655635/* called at power-up */
656static void init_COPS(running_machine &machine)
636void lisa_state::init_COPS()
657637{
658   lisa_state *state = machine.driver_data<lisa_state>();
659   state->m_COPS_Ready = 0;
638   m_COPS_Ready = 0;
660639
661   reset_COPS(state);
640   reset_COPS();
662641}
663642
664643
r20518r20519
683662   /*logerror("COPS CA2 line state : %d\n", val);*/
684663
685664   /*logerror("COPS_via_out_ca2 : trying to send data to VIA\n");*/
686   COPS_send_data_if_possible(machine());
665   COPS_send_data_if_possible();
687666}
688667
689668/*
r20518r20519
715694
716695WRITE8_MEMBER(lisa_state::COPS_via_out_b)
717696{
718   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
719
720697   /* pull-up */
721   data |= (~ via_0->read(space,VIA_DDRA)) & 0x01;
698   data |= (~ m_via0->read(space,VIA_DDRA)) & 0x01;
722699
723700   if (data & 0x01)
724701   {
725702      if (m_COPS_force_unplug)
726703      {
727704         m_COPS_force_unplug = 0;
728         plug_keyboard(machine());
705         plug_keyboard();
729706      }
730707   }
731708   else
r20518r20519
733710      if (! m_COPS_force_unplug)
734711      {
735712         m_COPS_force_unplug = 1;
736         unplug_keyboard(machine());
713         unplug_keyboard();
737714         //reset_COPS(state);
738715      }
739716   }
r20518r20519
741718
742719WRITE8_MEMBER(lisa_state::COPS_via_out_cb2)
743720{
744   device_t *speaker = machine().device(SPEAKER_TAG);
745   speaker_level_w(speaker, data);
721   speaker_level_w(m_speaker, data);
746722}
747723
748static void COPS_via_irq_func(device_t *device, int val)
724void lisa_state::COPS_via_irq_func(int val)
749725{
750   lisa_state *state = device->machine().driver_data<lisa_state>();
751   if (state->m_KBIR != val)
726   if (m_KBIR != val)
752727   {
753      state->m_KBIR = val;
754      lisa_field_interrupts(device->machine());
728      m_KBIR = val;
729      field_interrupts();
755730   }
756731}
757732
r20518r20519
835810   lisa_state *state = machine.driver_data<lisa_state>();
836811   /* upper 7 bits -> segment # */
837812   int segment = (address >> 17) & 0x7f;
838   int the_seg = state->m_seg;
813   int the_seg = m_seg;
839814
840815   address &= 0xffffff;
841816
842817   printf("lisa: logical address %x\n", address);
843818
844   if (state->m_setup)
819   if (m_setup)
845820   {
846821      if (address & 0x004000)
847822      {
r20518r20519
855830         }
856831         else
857832         {   /* system ROMs */
858            direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->m_rom_ptr - (address & 0x3fff));
833            direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, m_rom_ptr - (address & 0x3fff));
859834         }
860835
861836         return -1;
r20518r20519
863838
864839   }
865840
866   if (machine.device("maincpu")->state().state_int(M68K_SR) & 0x2000)
841   if (m_maincpu->state_int(M68K_SR) & 0x2000)
867842   {
868843      /* supervisor mode -> force register file 0 */
869844      the_seg = 0;
r20518r20519
873848      int seg_offset = address & 0x01ffff;
874849
875850      /* add revelant origin -> address */
876      offs_t mapped_address = (state->m_mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff;
851      offs_t mapped_address = (m_mmu_regs[the_seg][segment].sorg + seg_offset) & 0x1fffff;
877852
878      switch ((mmu_entry_t)state->m_mmu_regs[the_seg][segment].type)
853      switch ((mmu_entry_t)m_mmu_regs[the_seg][segment].type)
879854      {
880855      case RAM_r:
881856      case RAM_rw:
882         if (seg_offset > state->m_mmu_regs[the_seg][segment].slim)
857         if (seg_offset > m_mmu_regs[the_seg][segment].slim)
883858         {
884859            /* out of segment limits : bus error */
885860            printf("illegal opbase address%lX\n", (long) address);
886861         }
887         direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->m_ram_ptr + mapped_address - address);
862         direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, m_ram_ptr + mapped_address - address);
888863         printf("RAM\n");
889864         break;
890865
r20518r20519
897872         break;
898873
899874      case special_IO:
900         direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, state->m_rom_ptr + (mapped_address & 0x003fff) - address);
875         direct.explicit_configure((address & 0xffc000), (address & 0xffc000) + 0x003fff, 0xffffff, m_rom_ptr + (mapped_address & 0x003fff) - address);
901876         printf("ROM\n");
902877         break;
903878      }
r20518r20519
912887NVRAM_HANDLER(lisa)
913888{
914889   lisa_state *state = machine.driver_data<lisa_state>();
890
915891   if (read_or_write)
916892   {
917893      file->write(state->m_fdc_ram, 1024);
r20518r20519
950926#if 0
951927   UINT32 temp32;
952928   SINT8 temp8;
953   temp32 = (state->m_clock_regs.alarm << 12) | (state->m_clock_regs.years << 8) | (state->m_clock_regs.days1 << 4)
954         | state->m_clock_regs.days2;
929   temp32 = (m_clock_regs.alarm << 12) | (m_clock_regs.years << 8) | (m_clock_regs.days1 << 4)
930         | m_clock_regs.days2;
955931
956   temp32 = (state->m_clock_regs.days3 << 28) | (state->m_clock_regs.hours1 << 24) | (state->m_clock_regs.hours2 << 20)
957         | (state->m_clock_regs.minutes1 << 16) | (state->m_clock_regs.minutes2 << 12)
958         | (state->m_clock_regs.seconds1 << 8) | (state->m_clock_regs.seconds2 << 4) | state->m_clock_regs.tenths;
932   temp32 = (m_clock_regs.days3 << 28) | (m_clock_regs.hours1 << 24) | (m_clock_regs.hours2 << 20)
933         | (m_clock_regs.minutes1 << 16) | (m_clock_regs.minutes2 << 12)
934         | (m_clock_regs.seconds1 << 8) | (m_clock_regs.seconds2 << 4) | m_clock_regs.tenths;
959935
960936   temp8 = clock_mode;         /* clock mode */
961937
962   temp8 = state->m_clock_regs.clock_write_ptr;    /* clock byte to be written next (-1 if clock write disabled) */
938   temp8 = m_clock_regs.clock_write_ptr;    /* clock byte to be written next (-1 if clock write disabled) */
963939#endif
964940}
965941
r20518r20519
967943void init_lisa1(void)
968944{
969945   lisa_state *state = machine.driver_data<lisa_state>();
970   state->m_model = lisa1;
971   state->m_features.has_fast_timers = 0;
972   state->m_features.floppy_hardware = twiggy;
973   state->m_features.has_double_sided_floppy = 1;
974   state->m_features.has_mac_xl_video = 0;
946   m_model = lisa1;
947   m_features.has_fast_timers = 0;
948   m_features.floppy_hardware = twiggy;
949   m_features.has_double_sided_floppy = 1;
950   m_features.has_mac_xl_video = 0;
975951}
976952#endif
977953
978954DRIVER_INIT_MEMBER(lisa_state,lisa2)
979955{
980   m_ram_ptr = machine().root_device().memregion("maincpu")->base() + RAM_OFFSET;
956   m_ram_ptr = memregion("maincpu")->base() + RAM_OFFSET;
981957   m_rom_ptr = memregion("maincpu")->base() + ROM_OFFSET;
982958   m_model = lisa2;
983959   m_features.has_fast_timers = 0;
r20518r20519
990966
991967DRIVER_INIT_MEMBER(lisa_state,lisa210)
992968{
993   m_ram_ptr = machine().root_device().memregion("maincpu")->base() + RAM_OFFSET;
969   m_ram_ptr = memregion("maincpu")->base() + RAM_OFFSET;
994970   m_rom_ptr = memregion("maincpu")->base() + ROM_OFFSET;
995971   m_model = lisa210;
996972   m_features.has_fast_timers = 1;
r20518r20519
1003979
1004980DRIVER_INIT_MEMBER(lisa_state,mac_xl)
1005981{
1006   m_ram_ptr = machine().root_device().memregion("maincpu")->base() + RAM_OFFSET;
982   m_ram_ptr = memregion("maincpu")->base() + RAM_OFFSET;
1007983   m_rom_ptr = memregion("maincpu")->base() + ROM_OFFSET;
1008984   m_model = mac_xl;
1009985   m_features.has_fast_timers = 1;
r20518r20519
10241000
10251001void lisa_state::machine_reset()
10261002{
1027   m_ram_ptr = machine().root_device().memregion("maincpu")->base() + RAM_OFFSET;
1028   m_rom_ptr = machine().root_device().memregion("maincpu")->base() + ROM_OFFSET;
1003   m_ram_ptr = memregion("maincpu")->base() + RAM_OFFSET;
1004   m_rom_ptr = memregion("maincpu")->base() + ROM_OFFSET;
10291005   m_videoROM_ptr = memregion("gfx1")->base();
10301006
1031//  machine().device("maincpu")->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate_create_static(lisa_OPbaseoverride, *machine()));
1032//  m68k_set_reset_callback(machine().device("maincpu"), /*lisa_reset_instr_callback*/NULL);
1007//  m_maincpu->memory().space(AS_PROGRAM).set_direct_update_handler(direct_update_delegate_create_static(lisa_OPbaseoverride, *machine()));
1008//  m68k_set_reset_callback(m_maincpu, /*lisa_reset_instr_callback*/NULL);
10331009
10341010   /* init MMU */
10351011   m_setup = 1;
r20518r20519
10461022   /* init video */
10471023
10481024   m_VTMSK = 0;
1049   set_VTIR(machine(), 0);
1025   set_VTIR(0);
10501026
10511027   m_video_address_latch = 0;
10521028   m_videoram_ptr = (UINT16 *) m_ram_ptr;
10531029
10541030   /* reset COPS keyboard/mouse controller */
1055   init_COPS(machine());
1031   init_COPS();
10561032
10571033   {
10581034      COPS_via_out_ca2(generic_space(), 0, 0);    /* VIA core forgets to do so */
r20518r20519
10621038   {
10631039      if (m_features.floppy_hardware == sony_lisa2)
10641040      {
1065         sony_set_enable_lines(machine().device("fdc"),1);   /* on lisa2, drive unit 1 is always selected (?) */
1041         sony_set_enable_lines(m_fdc, 1);   /* on lisa2, drive unit 1 is always selected (?) */
10661042      }
10671043   }
10681044
10691045   /* reset 68k to pick up proper vectors from MMU */
1070   machine().device("maincpu")->reset();
1046   m_maincpu->reset();
10711047}
10721048
10731049INTERRUPT_GEN_MEMBER(lisa_state::lisa_interrupt)
r20518r20519
10921068                     0x80,   /* RESET code */
10931069                     0xFC    /* timer time-out */
10941070                  };
1095                  COPS_queue_data(machine(), cmd, 2);
1071                  COPS_queue_data(cmd, 2);
10961072
10971073                  m_clock_regs.alarm = 0xfffffL;
10981074               }
r20518r20519
11591135
11601136   /* set VBI */
11611137   if (m_VTMSK)
1162      set_VTIR(machine(), 1);
1138      set_VTIR(1);
11631139   else
1164      set_VTIR(machine(), 0);
1140      set_VTIR(0);
11651141
11661142   /* do keyboard scan */
1167   scan_keyboard(machine());
1143   scan_keyboard();
11681144}
11691145
11701146/*
r20518r20519
11741150    cannot support 2 floppy drives)...
11751151*/
11761152
1177INLINE void lisa_fdc_ttl_glue_access(running_machine &machine, offs_t offset)
1153void lisa_state::lisa_fdc_ttl_glue_access(offs_t offset)
11781154{
1179   lisa_state *state = machine.driver_data<lisa_state>();
11801155   switch ((offset & 0x000E) >> 1)
11811156   {
11821157   case 0:
r20518r20519
11891164      /* enable/disable the motor on Lisa 1 */
11901165      /* can disable the motor on Lisa 2/10, too (although it is not useful) */
11911166      /* On lisa 2, commands the loading of the speed register on lisalite board */
1192      if (state->m_features.floppy_hardware == sony_lisa2)
1167      if (m_features.floppy_hardware == sony_lisa2)
11931168      {
1194         int oldMT1 = state->m_MT1;
1195         state->m_MT1 = offset & 1;
1196         if (state->m_MT1 && ! oldMT1)
1169         int oldMT1 = m_MT1;
1170         m_MT1 = offset & 1;
1171         if (m_MT1 && ! oldMT1)
11971172         {
1198            applefdc_base_device *fdc = machine.device<applefdc_base_device>("fdc");
1199
1200            state->m_PWM_floppy_motor_speed = (state->m_PWM_floppy_motor_speed << 1) & 0xff;
1201            if (fdc->get_lines() & APPLEFDC_PH0)
1202               state->m_PWM_floppy_motor_speed |= 1;
1203            sony_set_speed(((256-state->m_PWM_floppy_motor_speed) * 1.3) + 237);
1173            m_PWM_floppy_motor_speed = (m_PWM_floppy_motor_speed << 1) & 0xff;
1174            if (m_fdc->get_lines() & APPLEFDC_PH0)
1175               m_PWM_floppy_motor_speed |= 1;
1176            sony_set_speed(((256-m_PWM_floppy_motor_speed) * 1.3) + 237);
12041177         }
12051178      }
12061179      /*else
1207          state->m_MT1 = offset & 1;*/
1180          m_MT1 = offset & 1;*/
12081181      break;
12091182   case 4:
12101183      /*DIS = offset & 1;*/   /* forbids access from the 68000 to our RAM */
r20518r20519
12121185   case 5:
12131186      /*HDS = offset & 1;*/       /* head select (-> disk side) on twiggy */
12141187#if 0
1215      if (state->m_features.floppy_hardware == twiggy)
1188      if (m_features.floppy_hardware == twiggy)
12161189         twiggy_set_head_line(offset & 1);
12171190      else
12181191#endif
1219      if (state->m_features.floppy_hardware == sony_lisa210)
1220         sony_set_sel_line(machine.device("fdc"), offset & 1);
1192      if (m_features.floppy_hardware == sony_lisa210)
1193         sony_set_sel_line(m_fdc, offset & 1);
12211194      break;
12221195   case 6:
1223      state->m_DISK_DIAG = offset & 1;
1196      m_DISK_DIAG = offset & 1;
12241197      break;
12251198   case 7:
1226      state->m_FDIR = offset & 1; /* Interrupt request to 68k */
1227      lisa_field_interrupts(machine);
1199      m_FDIR = offset & 1; /* Interrupt request to 68k */
1200      field_interrupts();
12281201      break;
12291202   }
12301203}
r20518r20519
12321205READ8_MEMBER(lisa_state::lisa_fdc_io_r)
12331206{
12341207   int answer=0;
1235   applefdc_base_device *fdc = machine().device<applefdc_base_device>("fdc");
12361208
12371209   switch ((offset & 0x0030) >> 4)
12381210   {
12391211   case 0: /* IWM */
1240      answer = fdc->read(offset);
1212      answer = m_fdc->read(offset);
12411213      break;
12421214
12431215   case 1: /* TTL glue */
1244      lisa_fdc_ttl_glue_access(machine(), offset);
1216      lisa_fdc_ttl_glue_access(offset);
12451217      answer = 0; /* ??? */
12461218      break;
12471219
r20518r20519
12591231
12601232WRITE8_MEMBER(lisa_state::lisa_fdc_io_w)
12611233{
1262   applefdc_base_device *fdc = machine().device<applefdc_base_device>("fdc");
1263
12641234   switch ((offset & 0x0030) >> 4)
12651235   {
12661236   case 0: /* IWM */
1267      fdc->write(offset, data);
1237      m_fdc->write(offset, data);
12681238      break;
12691239
12701240   case 1: /* TTL glue */
1271      lisa_fdc_ttl_glue_access(machine(), offset);
1241      lisa_fdc_ttl_glue_access(offset);
12721242      break;
12731243
12741244   case 2: /* writes the PWM register */
r20518r20519
13911361      }
13921362   }
13931363
1394   if (machine().device("maincpu")->state().state_int(M68K_SR) & 0x2000)
1364   if (m_maincpu->state_int(M68K_SR) & 0x2000)
13951365      /* supervisor mode -> force register file 0 */
13961366      the_seg = 0;
13971367
r20518r20519
14201390               && (m_bad_parity_table[address >> 3] & (0x3 << (address & 0x7))))
14211391         {
14221392            m_mem_err_addr_latch = address >> 5;
1423            set_parity_error_pending(machine(), 1);
1393            set_parity_error_pending(1);
14241394         }
14251395
14261396         break;
r20518r20519
14381408               && (m_bad_parity_table[address >> 3] & (0x3 << (address & 0x7))))
14391409         {
14401410            m_mem_err_addr_latch = address >> 5;
1441            set_parity_error_pending(machine(), 1);
1411            set_parity_error_pending(1);
14421412         }
14431413
14441414         break;
r20518r20519
14931463               if ((time_in_frame >= 364) && (time_in_frame <= 375))
14941464               {
14951465                  answer = m_videoROM_ptr[m_videoROM_address|0x80] << 8;
1496            logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer, machine().device("maincpu")->safe_pc(), time_in_frame);
1466            logerror("reading1 %06X=%04x %s time=%d\n", address, answer, machine().describe_context(), time_in_frame);
14971467               }
14981468               else
14991469               {
15001470                  answer = m_videoROM_ptr[m_videoROM_address] << 8;
1501            logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer, machine().device("maincpu")->safe_pc(), time_in_frame);
1471            logerror("reading2 %06X=%04x %s time=%d\n", address, answer, machine().describe_context(), time_in_frame);
15021472               }
15031473            }
15041474
r20518r20519
15971567      }
15981568   }
15991569
1600   if (machine().device("maincpu")->state().state_int(M68K_SR) & 0x2000)
1570   if (m_maincpu->state_int(M68K_SR) & 0x2000)
16011571      /* supervisor mode -> force register file 0 */
16021572      the_seg = 0;
16031573
r20518r20519
17281698*                                                                                      *
17291699\**************************************************************************************/
17301700
1731INLINE void cpu_board_control_access(running_machine &machine, offs_t offset)
1701void lisa_state::cpu_board_control_access(offs_t offset)
17321702{
1733   lisa_state *state = machine.driver_data<lisa_state>();
17341703   switch ((offset & 0x03ff) << 1)
17351704   {
17361705   case 0x0002:    /* Set DIAG1 Latch */
17371706   case 0x0000:    /* Reset DIAG1 Latch */
17381707      break;
17391708   case 0x0006:    /* Set Diag2 Latch */
1740      state->m_diag2 = 1;
1709      m_diag2 = 1;
17411710      break;
17421711   case 0x0004:    /* ReSet Diag2 Latch */
1743      state->m_diag2 = 0;
1712      m_diag2 = 0;
17441713      break;
17451714   case 0x000A:    /* SEG1 Context Selection bit SET */
17461715      /*logerror("seg bit 0 set\n");*/
1747      state->m_seg |= 1;
1716      m_seg |= 1;
17481717      break;
17491718   case 0x0008:    /* SEG1 Context Selection bit RESET */
17501719      /*logerror("seg bit 0 clear\n");*/
1751      state->m_seg &= ~1;
1720      m_seg &= ~1;
17521721      break;
17531722   case 0x000E:    /* SEG2 Context Selection bit SET */
17541723      /*logerror("seg bit 1 set\n");*/
1755      state->m_seg |= 2;
1724      m_seg |= 2;
17561725      break;
17571726   case 0x000C:    /* SEG2 Context Selection bit RESET */
17581727      /*logerror("seg bit 1 clear\n");*/
1759      state->m_seg &= ~2;
1728      m_seg &= ~2;
17601729      break;
17611730   case 0x0010:    /* SETUP register SET */
1762      logerror("setup SET PC=%x\n", machine.device("maincpu")->safe_pc());
1763      state->m_setup = 1;
1731      logerror("setup SET %s\n", machine().describe_context());
1732      m_setup = 1;
17641733      break;
17651734   case 0x0012:    /* SETUP register RESET */
1766      logerror("setup UNSET PC=%x\n", machine.device("maincpu")->safe_pc());
1767      state->m_setup = 0;
1735      logerror("setup UNSET %s\n", machine().describe_context());
1736      m_setup = 0;
17681737      break;
17691738   case 0x001A:    /* Enable Vertical Retrace Interrupt */
1770      logerror("enable retrace PC=%x\n", machine.device("maincpu")->safe_pc());
1771      state->m_VTMSK = 1;
1739      logerror("enable retrace %s\n", machine().describe_context());
1740      m_VTMSK = 1;
17721741      break;
17731742   case 0x0018:    /* Disable Vertical Retrace Interrupt */
1774      logerror("disable retrace PC=%x\n", machine.device("maincpu")->safe_pc());
1775      state->m_VTMSK = 0;
1776      set_VTIR(machine, 2);
1743      logerror("disable retrace %s\n", machine().describe_context());
1744      m_VTMSK = 0;
1745      set_VTIR(2);
17771746      break;
17781747   case 0x0016:    /* Enable Soft Error Detect. */
17791748   case 0x0014:    /* Disable Soft Error Detect. */
17801749      break;
17811750   case 0x001E:    /* Enable Hard Error Detect */
1782      state->m_test_parity = 1;
1751      m_test_parity = 1;
17831752      break;
17841753   case 0x001C:    /* Disable Hard Error Detect */
1785      state->m_test_parity = 0;
1786      set_parity_error_pending(machine, 0);
1754      m_test_parity = 0;
1755      set_parity_error_pending(0);
17871756      break;
17881757   }
17891758}
17901759
17911760READ16_MEMBER(lisa_state::lisa_IO_r)
17921761{
1793   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
1794   via6522_device *via_1 = machine().device<via6522_device>("via6522_1");
17951762   int answer=0;
17961763
17971764   switch ((offset & 0x7000) >> 12)
r20518r20519
18411808         case 2: /* parallel port */
18421809            /* 1 VIA located at 0xD901 */
18431810            if (ACCESSING_BITS_0_7)
1844               answer = via_1->read(space, (offset >> 2) & 0xf);
1811               answer = m_via1->read(space, (offset >> 2) & 0xf);
18451812            break;
18461813
18471814         case 3: /* keyboard/mouse cops via */
18481815            /* 1 VIA located at 0xDD81 */
18491816            if (ACCESSING_BITS_0_7)
1850               answer = via_0->read(space, offset & 0xf);
1817               answer = m_via0->read(space, offset & 0xf);
18511818            break;
18521819         }
18531820      }
r20518r20519
18581825      switch ((offset & 0x0C00) >> 10)
18591826      {
18601827      case 0x0:   /* cpu board control */
1861         cpu_board_control_access(machine(), offset & 0x03ff);
1828         cpu_board_control_access(offset & 0x03ff);
18621829         break;
18631830
18641831      case 0x1:   /* Video Address Latch */
r20518r20519
19051872         else
19061873                  answer |= 0x04;
19071874         /* huh... we need to emulate some other bits */
1908         logerror("read status PC=%x val=%x\n", machine().device("maincpu")->safe_pc(), answer);
1875         logerror("read status %s val=%x\n", machine().describe_context(), answer);
19091876
19101877         break;
19111878      }
r20518r20519
19171884
19181885WRITE16_MEMBER(lisa_state::lisa_IO_w)
19191886{
1920   via6522_device *via_0 = machine().device<via6522_device>("via6522_0");
1921   via6522_device *via_1 = machine().device<via6522_device>("via6522_1");
1922
19231887   switch ((offset & 0x7000) >> 12)
19241888   {
19251889   case 0x0:
r20518r20519
19671931
19681932         case 2: /* paralel port */
19691933            if (ACCESSING_BITS_0_7)
1970               via_1->write(space, (offset >> 2) & 0xf, data & 0xff);
1934               m_via1->write(space, (offset >> 2) & 0xf, data & 0xff);
19711935            break;
19721936
19731937         case 3: /* keyboard/mouse cops via */
19741938            if (ACCESSING_BITS_0_7)
1975               via_0->write(space, offset & 0xf, data & 0xff);
1939               m_via0->write(space, offset & 0xf, data & 0xff);
19761940            break;
19771941         }
19781942      }
r20518r20519
19831947      switch ((offset & 0x0C00) >> 10)
19841948      {
19851949      case 0x0:   /* cpu board control */
1986         cpu_board_control_access(machine(), offset & 0x03ff);
1950         cpu_board_control_access(offset & 0x03ff);
19871951         break;
19881952
19891953      case 0x1:   /* Video Address Latch */
trunk/src/mess/includes/lisa.h
r20518r20519
99#ifndef LISA_H_
1010#define LISA_H_
1111
12#include "emu.h"
1213#include "machine/6522via.h"
1314#include "machine/8530scc.h"
15#include "machine/6522via.h"
16#include "machine/applefdc.h"
17#include "devices/sonydriv.h"
18#include "cpu/m68000/m68000.h"
19#include "sound/speaker.h"
1420
1521#define COP421_TAG      "u9f"
1622#define KB_COP421_TAG   "kbcop"
r20518r20519
95101   lisa_state(const machine_config &mconfig, device_type type, const char *tag)
96102      : driver_device(mconfig, type, tag),
97103      m_maincpu(*this, "maincpu"),
104      m_via0(*this, "via6522_0"),
105      m_via1(*this, "via6522_1"),
106      m_fdc(*this, "fdc"),
98107      m_scc(*this, "scc"),
108      m_speaker(*this, SPEAKER_TAG),
99109      m_fdc_rom(*this,"fdc_rom"),
100      m_fdc_ram(*this,"fdc_ram") { }
110      m_fdc_ram(*this,"fdc_ram"),
111      m_io_line0(*this, "LINE0"),
112      m_io_line1(*this, "LINE1"),
113      m_io_line2(*this, "LINE2"),
114      m_io_line3(*this, "LINE3"),
115      m_io_line4(*this, "LINE4"),
116      m_io_line5(*this, "LINE5"),
117      m_io_line6(*this, "LINE6"),
118      m_io_line7(*this, "LINE7"),
119      m_io_mouse_x(*this, "MOUSE_X"),
120      m_io_mouse_y(*this, "MOUSE_Y")
121   { }
101122
102   required_device<cpu_device> m_maincpu;
123   required_device<legacy_cpu_device> m_maincpu;
124   required_device<via6522_device> m_via0;
125   required_device<via6522_device> m_via1;
126   optional_device<applefdc_base_device> m_fdc;
103127   required_device<scc8530_t> m_scc;
128   required_device<speaker_sound_device> m_speaker;
104129
105130   required_shared_ptr<UINT8> m_fdc_rom;
106131   required_shared_ptr<UINT8> m_fdc_ram;
132
133   required_ioport m_io_line0;
134   required_ioport m_io_line1;
135   required_ioport m_io_line2;
136   required_ioport m_io_line3;
137   required_ioport m_io_line4;
138   required_ioport m_io_line5;
139   required_ioport m_io_line6;
140   required_ioport m_io_line7;
141   required_ioport m_io_mouse_x;
142   required_ioport m_io_mouse_y;
143
107144   UINT8 *m_ram_ptr;
108145   UINT8 *m_rom_ptr;
109146   UINT8 *m_videoROM_ptr;
r20518r20519
174211   DECLARE_WRITE8_MEMBER(COPS_via_out_b);
175212   DECLARE_WRITE8_MEMBER(COPS_via_out_cb2);
176213   DECLARE_READ8_MEMBER(parallel_via_in_b);
214
215   void field_interrupts();
216   void set_parity_error_pending(int value);
217   void set_VTIR(int value);
218   void cpu_board_control_access(offs_t offset);
219   void init_COPS();
220   void reset_COPS();
221   void lisa_fdc_ttl_glue_access(offs_t offset);
222   void COPS_send_data_if_possible();
223   void COPS_queue_data(const UINT8 *data, int len);
224   void COPS_via_irq_func(int val);
225   void scan_keyboard();
226   void unplug_keyboard();
227   void plug_keyboard();
177228};
178229
179230
trunk/src/mess/drivers/lisa.c
r20518r20519
2929ADDRESS_MAP_END
3030
3131static ADDRESS_MAP_START( lisa_cop_io_map, AS_IO, 8, lisa_state )
32   AM_RANGE(COP400_PORT_L, COP400_PORT_L)
33   AM_RANGE(COP400_PORT_G, COP400_PORT_G)
34   AM_RANGE(COP400_PORT_D, COP400_PORT_D)
35   AM_RANGE(COP400_PORT_IN, COP400_PORT_IN)
32   AM_RANGE(COP400_PORT_L, COP400_PORT_L) AM_NOP
33   AM_RANGE(COP400_PORT_G, COP400_PORT_G) AM_NOP
34   AM_RANGE(COP400_PORT_D, COP400_PORT_D) AM_NOP
35   AM_RANGE(COP400_PORT_IN, COP400_PORT_IN) AM_NOP
3636   AM_RANGE(COP400_PORT_SK, COP400_PORT_SK) AM_WRITENOP
3737   AM_RANGE(COP400_PORT_SIO, COP400_PORT_SIO) AM_NOP
3838   AM_RANGE(COP400_PORT_CKO, COP400_PORT_CKO) AM_READNOP
3939ADDRESS_MAP_END
4040
4141static ADDRESS_MAP_START( kb_cop_io_map, AS_IO, 8, lisa_state )
42   AM_RANGE(COP400_PORT_L, COP400_PORT_L)
43   AM_RANGE(COP400_PORT_G, COP400_PORT_G)
44   AM_RANGE(COP400_PORT_D, COP400_PORT_D)
45   AM_RANGE(COP400_PORT_IN, COP400_PORT_IN)
42   AM_RANGE(COP400_PORT_L, COP400_PORT_L) AM_NOP
43   AM_RANGE(COP400_PORT_G, COP400_PORT_G) AM_NOP
44   AM_RANGE(COP400_PORT_D, COP400_PORT_D) AM_NOP
45   AM_RANGE(COP400_PORT_IN, COP400_PORT_IN) AM_NOP
4646   AM_RANGE(COP400_PORT_SK, COP400_PORT_SK) AM_WRITENOP
4747   AM_RANGE(COP400_PORT_SIO, COP400_PORT_SIO) AM_NOP
4848   AM_RANGE(COP400_PORT_CKO, COP400_PORT_CKO) AM_READNOP

Previous 199869 Revisions Next


© 1997-2024 The MAME Team