Previous 15994 Revisions Next

r7801 Wednesday 14th April, 2010 at 01:26:19 UTC by Barry Rodewald
[FMTOWNS] Added mouse support for joystick port 2, made it the port 2 default.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r7800r7801
11/*
22
33    Fujitsu FM-Towns
4    driver by Barry Rodewald
45
56    Japanese computer system released in 1989.
67
78    CPU:  AMD 80386SX(DX?) (80387 available as add-on?)
89    Sound:  Yamaha YM3438
910            Ricoh RF5c68
10    Video:  VGA + some custom extra video hardware
11            320x200 - 640x480
12            16 - 32768 colours from a possible palette of between 4096 and
13              16.7m colours (depending on video mode)
14            1024 sprites (16x16)
11    Video:  Custom
12            16 or 256 colours from a 24-bit palette, or 15-bit high-colour
13            1024 sprites (16x16), rendered direct to VRAM
14            16 colour text mode, rendered direct to VRAM
1515
1616
1717    Fujitsu FM-Towns Marty
r7800r7801
1919    Japanese console, based on the FM-Towns computer, using an AMD 80386SX CPU,
2020    released in 1993
2121
22
2223    Issues: i386 protected mode is far from complete.
2324            Video emulation is far from complete.
2425
r7800r7801
4243 * 0x0042   : 8253 PIT counter 1
4344 * 0x0044   : 8253 PIT counter 2
4445 * 0x0046   : 8253 PIT mode port
45 * 0x0060   : 8253 PIT ???
46 * 0x0060   : 8253 PIT timer control
4647 * 0x006c RW: returns 0x00? (read) timer? (write)
4748 * 0x00a0-af: DMA controller 1 (uPD71071)
4849 * 0x00b0-bf: DMA controller 2 (uPD71071)
r7800r7801
8081 *      IRQ9 - Built-in CD-ROM controller
8182 *      IRQ11 - VSync interrupt
8283 *      IRQ12 - Printer port
83 *      IRQ13 - Sound (FM?), Mouse
84 *      IRQ15 - PCM
84 *      IRQ13 - Sound (YM3438/RF5c68), Mouse
85 *      IRQ15 - 16-bit PCM (expansion?)
8586 *
8687 * Machine ID list (I/O port 0x31)
8788 *
r7800r7801
645646 *  Port 0x60 - PIT Timer control
646647 *  On read:    bit 0: Timer 0 output level
647648 *              bit 1: Timer 1 output level
648 *              bits 4-2: Timer masks (timer 2 = sound)
649 *              bits 4-2: Timer masks (timer 2 = beeper)
649650 *  On write:   bits 2-0: Timer mask set
650651 *              bit 7: Timer 0 output reset
651652 */
r7800r7801
840841               ret |= 0x0000000f;
841842      }
842843     
843      //logerror("Mouse: X=%02x Y=%02x state=%i\n",towns_mouse_x,towns_mouse_y,towns_mouse_output);
844844      // button states are always visible
845845      state = input_port_read(space->machine,"mouse1");
846846      if(!(state & 0x01))
r7800r7801
850850      if(towns_pad_mask & 0x10)
851851         ret |= 0x00000040;
852852   }
853   if((porttype & 0xf0) == 0x20)  // mouse
854   {
855      switch(towns_mouse_output)
856      {
857         case MOUSE_X_HIGH:
858            ret |= ((towns_mouse_x & 0xf0) << 12);
859            break;
860         case MOUSE_X_LOW:
861            ret |= ((towns_mouse_x & 0x0f) << 16);
862            break;
863         case MOUSE_Y_HIGH:
864            ret |= ((towns_mouse_y & 0xf0) << 12);
865            break;
866         case MOUSE_Y_LOW:
867            ret |= ((towns_mouse_y & 0x0f) << 16);
868            break;
869         case MOUSE_START:
870         case MOUSE_SYNC:
871         default:
872            if(towns_mouse_output < MOUSE_Y_LOW)
873               ret |= 0x000f0000;
874      }
875     
876      // button states are always visible
877      state = input_port_read(space->machine,"mouse1");
878      if(!(state & 0x01))
879         ret |= 0x00100000;
880      if(!(state & 0x02))
881         ret |= 0x00200000;
882      if(towns_pad_mask & 0x20)
883         ret |= 0x00400000;
884   }
853885   
854886   return ret;
855887}
r7800r7801
859891   static UINT8 prev;
860892   static UINT8 prev_x,prev_y;
861893   UINT8 current_x,current_y;
894   UINT32 type = input_port_read(space->machine,"ctrltype");
862895   
863896   if(ACCESSING_BITS_16_23)
864897   {
865898      towns_pad_mask = (data & 0x00ff0000) >> 16;
866      if((input_port_read(space->machine,"ctrltype") & 0x0f) == 0x02)  // mouse
899      if((type & 0x0f) == 0x02)  // mouse
867900      {
868901         if((towns_pad_mask & 0x10) != 0 && (prev & 0x10) == 0)
869902         {
r7800r7801
899932         }
900933         prev = towns_pad_mask;
901934      }
935      if((type & 0xf0) == 0x20)  // mouse
936      {
937         if((towns_pad_mask & 0x20) != 0 && (prev & 0x20) == 0)
938         {
939            if(towns_mouse_output == MOUSE_START)
940            {
941               towns_mouse_output = MOUSE_X_HIGH;
942               current_x = input_port_read(space->machine,"mouse2");
943               current_y = input_port_read(space->machine,"mouse3");
944               towns_mouse_x = prev_x - current_x;
945               towns_mouse_y = prev_y - current_y;
946               prev_x = current_x;
947               prev_y = current_y;
948            }
949            else
950               towns_mouse_output++;
951            timer_adjust_periodic(towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero);
952         }
953         if((towns_pad_mask & 0x20) == 0 && (prev & 0x20) != 0)
954         {
955            if(towns_mouse_output == MOUSE_START)
956            {
957               towns_mouse_output = MOUSE_SYNC;
958               current_x = input_port_read(space->machine,"mouse2");
959               current_y = input_port_read(space->machine,"mouse3");
960               towns_mouse_x = prev_x - current_x;
961               towns_mouse_y = prev_y - current_y;
962               prev_x = current_x;
963               prev_y = current_y;
964            }
965            else
966               towns_mouse_output++;
967            timer_adjust_periodic(towns_mouse_timer,ATTOTIME_IN_USEC(600),0,attotime_zero);
968         }
969         prev = towns_pad_mask;
970      }
902971   }
903972}
904973
r7800r7801
18301899    PORT_CATEGORY_ITEM(0x00,"Nothing",10)
18311900    PORT_CATEGORY_ITEM(0x01,"Standard 2-button joystick",11)
18321901    PORT_CATEGORY_ITEM(0x02,"Mouse",12)
1833    PORT_CATEGORY_CLASS(0xf0,0x10,"Joystick port 2")
1902    PORT_CATEGORY_CLASS(0xf0,0x20,"Joystick port 2")
18341903    PORT_CATEGORY_ITEM(0x00,"Nothing",20)
18351904    PORT_CATEGORY_ITEM(0x10,"Standard 2-button joystick",21)
1905    PORT_CATEGORY_ITEM(0x20,"Mouse",22)
18361906
18371907// Keyboard
18381908  PORT_START( "key1" )  // scancodes 0x00-0x1f
r7800r7801
20102080    PORT_BIT(0x00000080,IP_ACTIVE_HIGH, IPT_UNUSED) PORT_CATEGORY(21)
20112081   
20122082  PORT_START("mouse1")  // buttons
2013     PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1) PORT_CATEGORY(12)
2014   PORT_BIT( 0x00000002, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2) PORT_CATEGORY(12)
2083     PORT_BIT( 0x00000001, IP_ACTIVE_HIGH, IPT_BUTTON1) PORT_NAME("Left mouse button") PORT_CODE(MOUSECODE_BUTTON1)
2084   PORT_BIT( 0x00000002, IP_ACTIVE_HIGH, IPT_BUTTON2) PORT_NAME("Right mouse button") PORT_CODE(MOUSECODE_BUTTON2)
20152085     
20162086  PORT_START("mouse2")  // X-axis
2017   PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(12)
2087   PORT_BIT( 0xff, 0x00, IPT_MOUSE_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1)
20182088
20192089  PORT_START("mouse3")  // Y-axis
2020   PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1) PORT_CATEGORY(12)
2090   PORT_BIT( 0xff, 0x00, IPT_MOUSE_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(0) PORT_PLAYER(1)
20212091
20222092INPUT_PORTS_END
20232093

Previous 15994 Revisions Next


© 1998-2018 The MESS Team