Previous 15994 Revisions Next

r10300 Saturday 5th February, 2011 at 16:04:11 UTC by Curt Coder
[ST] Added preliminary mouse support.
[src/mess/drivers]atarist.c
[src/mess/includes]atarist.h

src/mess/includes/atarist.h
r10299r10300
6464        m_ram(*this, RAM_TAG),
6565        m_acia_ikbd_irq(1),
6666        m_acia_midi_irq(1),
67        m_ikbd_mouse_x(0),
68        m_ikbd_mouse_y(0),
69        m_ikbd_mouse_px(IKBD_MOUSE_PHASE_STATIC),
70        m_ikbd_mouse_py(IKBD_MOUSE_PHASE_STATIC),
71        m_ikbd_mouse_pc(0),
6772        m_ikbd_joy(1)
6873   { }
6974
r10299r10300
116121   DECLARE_WRITE16_MEMBER( blitter_op_w );
117122   DECLARE_WRITE16_MEMBER( blitter_ctrl_w );
118123
124   void mouse_tick();
119125   inline pen_t shift_mode_0();
120126   inline pen_t shift_mode_1();
121127   inline pen_t shift_mode_2();
r10299r10300
173179   int m_acia_ikbd_irq;
174180   int m_acia_midi_irq;
175181   UINT16 m_ikbd_keylatch;
182   UINT8 m_ikbd_mouse;
176183   UINT8 m_ikbd_mouse_x;
177184   UINT8 m_ikbd_mouse_y;
178185   UINT8 m_ikbd_mouse_px;
r10299r10300
238245   UINT32 m_blitter_srcbuf;
239246   
240247   /* timers */
248   emu_timer *m_mouse_timer;
241249   emu_timer *m_glue_timer;
242250   emu_timer *m_shifter_timer;
243251};
src/mess/drivers/atarist.c
r10299r10300
2727    - floppy write
2828    - floppy DMA transfer timer
2929    - MSA disk image support
30    - mouse
30    - mouse moves too fast?
3131    - UK keyboard layout for the special keys
3232    - accurate screen timing
3333    - STe DMA sound and LMC1992 Microwire mixer
r10299r10300
410410//**************************************************************************
411411
412412//-------------------------------------------------
413//  mouse_tick -
414//-------------------------------------------------
415
416void st_state::mouse_tick()
417{
418   /*
419
420            Right   Left        Up      Down
421
422        XA  1100    0110    YA  1100    0110
423        XB  0110    1100    YB  0110    1100
424
425    */
426
427   UINT8 x = input_port_read_safe(machine, "IKBD_MOUSEX", 0x00);
428   UINT8 y = input_port_read_safe(machine, "IKBD_MOUSEY", 0x00);
429
430   if (m_ikbd_mouse_pc == 0)
431   {
432      if (x == m_ikbd_mouse_x)
433      {
434         logerror("IKBD Mouse X: static\n");
435         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_STATIC;
436      }
437      else if ((x > m_ikbd_mouse_x) || (x == 0 && m_ikbd_mouse_x == 0xff))
438      {
439         logerror("IKBD Mouse X: positive\n");
440         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_POSITIVE;
441      }
442      else if ((x < m_ikbd_mouse_x) || (x == 0xff && m_ikbd_mouse_x == 0))
443      {
444         logerror("IKBD Mouse X: negative\n");
445         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_NEGATIVE;
446      }
447
448      if (y == m_ikbd_mouse_y)
449      {
450         logerror("IKBD Mouse Y: static\n");
451         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_STATIC;
452      }
453      else if ((y > m_ikbd_mouse_y) || (y == 0 && m_ikbd_mouse_y == 0xff))
454      {
455         logerror("IKBD Mouse Y: positive\n");
456         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_POSITIVE;
457      }
458      else if ((y < m_ikbd_mouse_y) || (y == 0xff && m_ikbd_mouse_y == 0))
459      {
460         logerror("IKBD Mouse Y: negative\n");
461         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_NEGATIVE;
462      }
463
464      m_ikbd_mouse_x = x;
465      m_ikbd_mouse_y = y;
466   }
467
468   m_ikbd_mouse = 0;
469
470   m_ikbd_mouse |= IKBD_MOUSE_XYB[m_ikbd_mouse_px][m_ikbd_mouse_pc];       // XB
471   m_ikbd_mouse |= IKBD_MOUSE_XYA[m_ikbd_mouse_px][m_ikbd_mouse_pc] << 1; // XA
472   m_ikbd_mouse |= IKBD_MOUSE_XYB[m_ikbd_mouse_py][m_ikbd_mouse_pc] << 2; // YA
473   m_ikbd_mouse |= IKBD_MOUSE_XYA[m_ikbd_mouse_py][m_ikbd_mouse_pc] << 3; // YB
474
475   logerror("IBKD Mouse pc %u data %02x\n", m_ikbd_mouse_pc, m_ikbd_mouse);
476
477   m_ikbd_mouse_pc++;
478   m_ikbd_mouse_pc &= 0x03;
479}
480
481
482//-------------------------------------------------
483//  TIMER_CALLBACK( st_mouse_tick )
484//-------------------------------------------------
485
486static TIMER_CALLBACK( st_mouse_tick )
487{
488   st_state *state = machine->driver_data<st_state>();
489
490   state->mouse_tick();
491}
492
493
494//-------------------------------------------------
413495//  ikbd_port1_r -
414496//-------------------------------------------------
415497
r10299r10300
558640
559641   if (m_ikbd_joy) return 0xff;
560642
561   if (input_port_read(machine, "config") & 0x01)
643   UINT8 data = input_port_read_safe(machine, "IKBD_JOY0", 0xff);
644
645   if ((input_port_read(machine, "config") & 0x01) == 0)
562646   {
563      return input_port_read_safe(machine, "IKBD_JOY0", 0xff);
647      data = (data & 0xf0) | m_ikbd_mouse;
564648   }
565   else
566   {
567      /*
568649
569                Right   Left        Up      Down
570
571            XA  1100    0110    YA  1100    0110
572            XB  0110    1100    YB  0110    1100
573
574        */
575
576      UINT8 data = input_port_read_safe(machine, "IKBD_JOY0", 0xff) & 0xf0;
577      UINT8 x = input_port_read_safe(machine, "IKBD_MOUSEX", 0x00);
578      UINT8 y = input_port_read_safe(machine, "IKBD_MOUSEY", 0x00);
579
580      if (x == m_ikbd_mouse_x)
581      {
582         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_STATIC;
583      }
584      else if (x > m_ikbd_mouse_x)
585      {
586         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_POSITIVE;
587      }
588      else if (x < m_ikbd_mouse_x)
589      {
590         m_ikbd_mouse_px = IKBD_MOUSE_PHASE_NEGATIVE;
591      }
592
593      if (y == m_ikbd_mouse_y)
594      {
595         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_STATIC;
596      }
597      else if (y > m_ikbd_mouse_y)
598      {
599         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_POSITIVE;
600      }
601      else if (y < m_ikbd_mouse_y)
602      {
603         m_ikbd_mouse_py = IKBD_MOUSE_PHASE_NEGATIVE;
604      }
605
606      data |= IKBD_MOUSE_XYB[m_ikbd_mouse_px][m_ikbd_mouse_pc];       // XB
607      data |= IKBD_MOUSE_XYA[m_ikbd_mouse_px][m_ikbd_mouse_pc] << 1; // XA
608      data |= IKBD_MOUSE_XYA[m_ikbd_mouse_py][m_ikbd_mouse_pc] << 2; // YA
609      data |= IKBD_MOUSE_XYB[m_ikbd_mouse_py][m_ikbd_mouse_pc] << 3; // YB
610
611      m_ikbd_mouse_pc++;
612
613      if (m_ikbd_mouse_pc == 4)
614      {
615         m_ikbd_mouse_pc = 0;
616      }
617
618      m_ikbd_mouse_x = x;
619      m_ikbd_mouse_y = y;
620
621      return data;
622   }
650   return data;
623651}
624652
625653
r10299r10300
11961224   AM_RANGE(0xff8608, 0xff860d) AM_READWRITE8(dma_counter_r, dma_base_w, 0x00ff)
11971225   AM_RANGE(0xff8800, 0xff8801) AM_DEVREADWRITE8_LEGACY(YM2149_TAG, ay8910_r, ay8910_data_w, 0xff00)
11981226   AM_RANGE(0xff8802, 0xff8803) AM_DEVWRITE8_LEGACY(YM2149_TAG, ay8910_data_w, 0xff00)
1227   AM_RANGE(0xff8a00, 0xff8a1f) AM_READWRITE(blitter_halftone_r, blitter_halftone_w)
1228   AM_RANGE(0xff8a20, 0xff8a21) AM_READWRITE(blitter_src_inc_x_r, blitter_src_inc_x_w)
1229   AM_RANGE(0xff8a22, 0xff8a23) AM_READWRITE(blitter_src_inc_y_r, blitter_src_inc_y_w)
1230   AM_RANGE(0xff8a24, 0xff8a27) AM_READWRITE(blitter_src_r, blitter_src_w)
1231   AM_RANGE(0xff8a28, 0xff8a2d) AM_READWRITE(blitter_end_mask_r, blitter_end_mask_w)
1232   AM_RANGE(0xff8a2e, 0xff8a2f) AM_READWRITE(blitter_dst_inc_x_r, blitter_dst_inc_x_w)
1233   AM_RANGE(0xff8a30, 0xff8a31) AM_READWRITE(blitter_dst_inc_y_r, blitter_dst_inc_y_w)
1234   AM_RANGE(0xff8a32, 0xff8a35) AM_READWRITE(blitter_dst_r, blitter_dst_w)
1235   AM_RANGE(0xff8a36, 0xff8a37) AM_READWRITE(blitter_count_x_r, blitter_count_x_w)
1236   AM_RANGE(0xff8a38, 0xff8a39) AM_READWRITE(blitter_count_y_r, blitter_count_y_w)
1237   AM_RANGE(0xff8a3a, 0xff8a3b) AM_READWRITE(blitter_op_r, blitter_op_w)
1238   AM_RANGE(0xff8a3c, 0xff8a3d) AM_READWRITE(blitter_ctrl_r, blitter_ctrl_w)
11991239   AM_RANGE(0xfffa00, 0xfffa3f) AM_DEVREADWRITE8(MC68901_TAG, mc68901_device, read, write, 0x00ff)
12001240   AM_RANGE(0xfffc00, 0xfffc01) AM_DEVREADWRITE8_LEGACY(MC6850_0_TAG, acia6850_stat_r, acia6850_ctrl_w, 0xff00)
12011241   AM_RANGE(0xfffc02, 0xfffc03) AM_DEVREADWRITE8_LEGACY(MC6850_0_TAG, acia6850_data_r, acia6850_data_w, 0xff00)
r10299r10300
22092249   state_save_register_global(machine, m_fdc_sectors);
22102250   state_save_register_global(machine, m_fdc_dmabytes);
22112251   state_save_register_global(machine, m_ikbd_keylatch);
2252   state_save_register_global(machine, m_ikbd_mouse);
22122253   state_save_register_global(machine, m_ikbd_mouse_x);
22132254   state_save_register_global(machine, m_ikbd_mouse_y);
22142255   state_save_register_global(machine, m_ikbd_mouse_px);
r10299r10300
22302271
22312272void st_state::machine_start()
22322273{
2233   /* configure RAM banking */
2274   // configure RAM banking
22342275   configure_memory();
22352276
2236   /* set CPU interrupt callback */
2277   // set CPU interrupt callback
22372278   cpu_set_irq_callback(m_maincpu, atarist_int_ack);
22382279
2239   /* register for state saving */
2280   // allocate timers
2281   m_mouse_timer = timer_alloc(machine, st_mouse_tick, NULL);
2282   timer_adjust_periodic(m_mouse_timer, attotime::zero, 0, attotime::from_hz(500));
2283   
2284   // register for state saving
22402285   state_save();
22412286}
22422287

Previous 15994 Revisions Next


© 1998-2018 The MESS Team