Previous 15994 Revisions Next

r2782 Saturday 31st May, 2008 at 14:08:59 UTC by Fabio Priuli
[THOMSON] removed a few occurrences of input_port_read_indexed
[src/mess/devices]thomflop.c
[src/mess/includes]thomson.h
[src/mess/machine]thomson.c
[src/mess/video]thomson.c

src/mess/devices/thomflop.c
r2781r2782
17161716   if ( offset == 8 )
17171717   {
17181718      /* network ID of the computer */
1719      UINT8 id = input_port_read_indexed(machine, THOM_INPUT_FCONFIG ) >> 3;
1719      UINT8 id = input_port_read(machine, "fconfig") >> 3;
17201720      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), id ));
17211721      return id;
17221722   }
r2781r2782
17741774
17751775void to7_floppy_reset ( running_machine *machine )
17761776{
1777   to7_controller_type = (input_port_read_indexed(machine, THOM_INPUT_FCONFIG ) ) & 7;
1777   to7_controller_type = (input_port_read(machine, "fconfig") ) & 7;
17781778
17791779   switch ( to7_controller_type )
17801780   {
src/mess/includes/thomson.h
r2781r2782
1212
1313/*************************** common ********************************/
1414
15/* input ports (first port number of each class) */
16#define THOM_INPUT_LIGHTPEN  0 /* 3 ports: analog X, analog Y, and button */
17#define THOM_INPUT_GAME      3 /* 2-5 ports: joystick, mouse */
18#define THOM_INPUT_KEYBOARD  8 /* 8-10 lines */
19#define THOM_INPUT_CONFIG   18 /* machine-specific options */
20#define THOM_INPUT_FCONFIG  19 /* floppy / network options */
21#define THOM_INPUT_VCONFIG  20 /* video options */
22#define THOM_INPUT_MCONFIG  21 /* modem / speech options */
23
2415/* 6821 PIAs */
2516#define THOM_PIA_SYS    0  /* system PIA */
2617#define THOM_PIA_GAME   1  /* music & game PIA (joypad + sound) */
src/mess/video/thomson.c
r2781r2782
5959{
6060   const device_config *screen = video_screen_first(machine->config);
6161   const rectangle *visarea = video_screen_get_visible_area(screen);
62   UINT8 p = input_port_read_indexed(machine, THOM_INPUT_VCONFIG );
62   UINT8 p = input_port_read(machine, "vconfig");
6363   int new_w, new_h, changed = 0;
6464
6565   switch ( p & 3 )
r2781r2782
140140
141141static void thom_get_lightpen_pos( int*x, int* y )
142142{
143   *x = input_port_read_indexed(Machine,  THOM_INPUT_LIGHTPEN     );
144   *y = input_port_read_indexed(Machine,  THOM_INPUT_LIGHTPEN + 1 );
143   *x = input_port_read(Machine, "lightpen_x");
144   *y = input_port_read(Machine, "lightpen_y");
145145
146146   if ( *x < 0 )
147147      *x = 0;
src/mess/machine/thomson.c
r2781r2782
378378
379379static READ8_HANDLER ( to7_timer_port_in )
380380{
381   int lightpen = (input_port_read_indexed(machine, THOM_INPUT_LIGHTPEN + 2 ) & 1) ? 2 : 0;
381   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
382382   int cass = to7_get_cassette() ? 0x80 : 0;
383383   return lightpen | cass;
384384}
r2781r2782
474474      int keyline = pia_get_output_b( THOM_PIA_SYS );
475475      UINT8 val = 0xff;
476476      int i;
477      char tag[12];
478     
477479      for ( i = 0; i < 8; i++ )
478480      {
479481         if ( ! (keyline & (1 << i)) )
480            val &= input_port_read_indexed(machine,  THOM_INPUT_KEYBOARD + i );
482         {
483            sprintf(tag, "keyboard_%d", i);
484            val &= input_port_read(machine, tag);
485         }
481486      }
482487      return val;
483488   }
r2781r2782
769774
770775READ8_HANDLER ( to7_modem_mea8000_r )
771776{
772   if ( input_port_read_indexed(machine, THOM_INPUT_MCONFIG ) & 1 )
777   if ( input_port_read(machine, "mconfig") & 1 )
773778      return mea8000_r( machine, offset );
774779   else
775780   {
r2781r2782
785790
786791WRITE8_HANDLER ( to7_modem_mea8000_w )
787792{
788   if ( input_port_read_indexed(machine, THOM_INPUT_MCONFIG ) & 1 )
793   if ( input_port_read(machine, "mconfig") & 1 )
789794      mea8000_w( machine, offset, data );
790795   else
791796   {
r2781r2782
833838static UINT8 to7_get_mouse_signal( void )
834839{
835840   UINT8 xa, xb, ya, yb;
836   UINT16 dx = input_port_read_indexed(Machine,  THOM_INPUT_GAME + 2 ); /* x axis */
837   UINT16 dy = input_port_read_indexed(Machine,  THOM_INPUT_GAME + 3 ); /* y axis */
841   UINT16 dx = input_port_read(Machine, "mouse_x"); /* x axis */
842   UINT16 dy = input_port_read(Machine, "mouse_y"); /* y axis */
838843   xa = ((dx + 1) & 3) <= 1;
839844   xb = (dx & 3) <= 1;
840845   ya = ((dy + 1) & 3) <= 1;
r2781r2782
854859static READ8_HANDLER ( to7_game_porta_in )
855860{
856861   UINT8 data;
857   if ( input_port_read_indexed(machine, THOM_INPUT_CONFIG ) & 1 )
862   if ( input_port_read(machine, "config") & 1 )
858863   {
859864      /* mouse */
860865      data = to7_get_mouse_signal() & 0x0c;             /* XB, YB */
861      data |= input_port_read_indexed(machine, THOM_INPUT_GAME + 4 ) & 3; /* buttons */
866      data |= input_port_read(machine, "mouse_button") & 3; /* buttons */
862867   }
863868   else
864869   {
865870      /* joystick */
866      data = input_port_read_indexed(machine, THOM_INPUT_GAME );
871      data = input_port_read(machine, "game_port_directions");
867872      /* bit 0=0 => P1 up      bit 4=0 => P2 up
868873         bit 1=0 => P1 down    bit 5=0 => P2 down
869874         bit 2=0 => P1 left    bit 6=0 => P2 left
r2781r2782
895900static READ8_HANDLER ( to7_game_portb_in )
896901{
897902   UINT8 data;
898   if ( input_port_read_indexed(machine, THOM_INPUT_CONFIG ) & 1 )
903   if ( input_port_read(machine, "config") & 1 )
899904   {
900905      /* mouse */
901906      UINT8 mouse =  to7_get_mouse_signal();
r2781r2782
912917      /* bits 2-3: action buttons B (0=pressed) */
913918      /* bits 4-5: unused (ouput) */
914919      /* bits 0-1: unknown! */
915      data = input_port_read_indexed(machine, THOM_INPUT_GAME + 1 );
920      data = input_port_read(machine, "game_port_buttons");
916921   }
917922   return data;
918923}
r2781r2782
949954/* this should be called periodically */
950955static TIMER_CALLBACK(to7_game_update_cb)
951956{
952   if ( input_port_read_indexed(machine, THOM_INPUT_CONFIG ) & 1 )
957   if ( input_port_read(machine, "config") & 1 )
953958   {
954959      /* mouse */
955960      UINT8 mouse = to7_get_mouse_signal();
r2781r2782
959964   else
960965   {
961966      /* joystick */
962      UINT8 in = input_port_read_indexed(machine, THOM_INPUT_GAME );
967      UINT8 in = input_port_read(machine, "game_port_buttons");
963968      pia_set_input_cb2( THOM_PIA_GAME, (in & 0x80) ? 1 : 0 ); /* P2 action A */
964969      pia_set_input_ca2( THOM_PIA_GAME, (in & 0x40) ? 1 : 0 ); /* P1 action A */
965970      pia_set_input_cb1( THOM_PIA_GAME, (in & 0x08) ? 1 : 0 ); /* P2 action B */
r2781r2782
13641369static READ8_HANDLER ( to770_sys_porta_in )
13651370{
13661371   /* keyboard */
1372   char tag[12];
13671373   int keyline = pia_get_output_b( THOM_PIA_SYS ) & 7;
1368   return input_port_read_indexed(machine,  THOM_INPUT_KEYBOARD + 7 - keyline );
1374   
1375   sprintf(tag, "keyboard_%d", 7 - keyline);
1376   return input_port_read(machine, tag);
13691377}
13701378
13711379
r2781r2782
16461654{
16471655   return
16481656      (mo5_get_cassette() ? 0x80 : 0) |     /* bit 7: cassette input */
1649      ((input_port_read_indexed(machine, THOM_INPUT_LIGHTPEN + 2 ) & 1) ? 0x20 : 0)
1657      ((input_port_read(machine, "lightpen_button") & 1) ? 0x20 : 0)
16501658      /* bit 5: lightpen button */;
16511659}
16521660
r2781r2782
16641672   UINT8 portb = pia_get_output_b( THOM_PIA_SYS );
16651673   int col = (portb >> 1) & 7;       /* key column */
16661674   int lin = 7 - ((portb >> 4) & 7); /* key line */
1667   return ( input_port_read_indexed(machine,  THOM_INPUT_KEYBOARD+lin ) & (1 << col) ) ? 0x80 : 0;
1675   char tag[12];
1676   
1677   sprintf(tag, "keyboard_%d", lin);
1678   return ( input_port_read(machine, tag) & (1 << col) ) ? 0x80 : 0;
16681679}
16691680
16701681
r2781r2782
23242335static int to9_kbd_ktest ( void )
23252336{
23262337   int line, bit;
2338   UINT8 port;
2339   char tag[12];
23272340
23282341   for ( line = 0; line < 10; line++ )
23292342   {
2330      UINT8 port = input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + line );
2343      sprintf(tag, "keyboard_%d", line);
2344      port = input_port_read(Machine, tag);
23312345
23322346      if ( line == 7 || line == 9 )
23332347         port |= 1; /* shift & control */
r2781r2782
25522566/* returns the ASCII code for the key, or 0 for no key */
25532567static int to9_kbd_get_key( void )
25542568{
2555   int control = ! (input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + 7 ) & 1);
2556   int shift   = ! (input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + 9 ) & 1);
2569   int control = ! (input_port_read(Machine, "keyboard_7") & 1);
2570   int shift   = ! (input_port_read(Machine, "keyboard_9") & 1);
25572571   int key = -1, line, bit;
2572   UINT8 port;
2573   char tag[12];
25582574
25592575   for ( line = 0; line < 10; line++ )
25602576   {
2561      UINT8 port = input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + line );
2577      sprintf(tag, "keyboard_%d", line);
2578      port = input_port_read(Machine, tag);
25622579
25632580      if ( line == 7 || line == 9 )
25642581         port |= 1; /* shift & control */
r2781r2782
26492666
26502667      case 1: /* x axis */
26512668      {
2652         int newx = input_port_read_indexed(machine, THOM_INPUT_GAME + 2 );
2669         int newx = input_port_read(machine, "mouse_x");
26532670         UINT8 data = ( (newx - to9_mouse_x) & 0xf ) - 8;
26542671         to9_kbd_send( data, 1 );
26552672         to9_mouse_x = newx;
r2781r2782
26582675
26592676      case 2: /* y axis */
26602677      {
2661         int newy = input_port_read_indexed(machine, THOM_INPUT_GAME + 3 );
2678         int newy = input_port_read(machine, "mouse_y");
26622679         UINT8 data = ( (newy - to9_mouse_y) & 0xf ) - 8;
26632680         to9_kbd_send( data, 1 );
26642681         to9_mouse_y = newy;
r2781r2782
26672684
26682685      case 3: /* axis overflow & buttons */
26692686      {
2670         int b = input_port_read_indexed(machine, THOM_INPUT_GAME + 4 );
2687         int b = input_port_read(machine, "mouse_button");
26712688         UINT8 data = 0;
26722689         if ( b & 1 ) data |= 1;
26732690         if ( b & 2 ) data |= 4;
r2781r2782
29612978static int to8_kbd_ktest ( void )
29622979{
29632980   int line, bit;
2981   UINT8 port;
2982   char tag[12];
29642983
2965   if ( input_port_read_indexed(Machine, THOM_INPUT_CONFIG ) & 2 )
2984   if ( input_port_read(Machine, "config") & 2 )
29662985      return 0; /* disabled */
29672986
29682987   for ( line = 0; line < 10; line++ )
29692988   {
2970      UINT8 port = input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + line );
2989      sprintf(tag, "keyboard_%d", line);
2990      port = input_port_read(Machine, tag);
29712991
29722992      if ( line == 7 || line == 9 )
29732993         port |= 1; /* shift & control */
r2781r2782
29873007/* keyboard scan & return keycode (or -1) */
29883008static int to8_kbd_get_key( void )
29893009{
2990   int control = (input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + 7 ) & 1) ? 0 : 0x100;
2991   int shift   = (input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + 9 ) & 1) ? 0 : 0x080;
3010   int control = (input_port_read(Machine, "keyboard_7") & 1) ? 0 : 0x100;
3011   int shift   = (input_port_read(Machine, "keyboard_9") & 1) ? 0 : 0x080;
29923012   int key = -1, line, bit;
2993
2994   if ( input_port_read_indexed(Machine,  THOM_INPUT_CONFIG ) & 2 )
3013   UINT8 port;
3014   char tag[12];
3015   
3016   if ( input_port_read(Machine, "config") & 2 )
29953017      return -1; /* disabled */
29963018
29973019   for ( line = 0; line < 10; line++ )
29983020   {
2999      UINT8 port = input_port_read_indexed(Machine,  THOM_INPUT_KEYBOARD + line );
3021      sprintf(tag, "keyboard_%d", line);
3022      port = input_port_read(Machine, tag);
30003023
30013024      if ( line == 7 || line == 9 )
30023025         port |= 1; /* shift & control */
r2781r2782
37123735
37133736static READ8_HANDLER ( to8_timer_port_in )
37143737{
3715   int lightpen = (input_port_read_indexed(machine, THOM_INPUT_LIGHTPEN + 2 ) & 1) ? 2 : 0;
3738   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
37163739   int cass = to7_get_cassette() ? 0x80 : 0;
37173740   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
37183741   int lock = to8_kbd_caps ? 0 : 8; /* undocumented! */
r2781r2782
39083931
39093932static READ8_HANDLER ( to9p_timer_port_in )
39103933{
3911   int lightpen = (input_port_read_indexed(machine, THOM_INPUT_LIGHTPEN + 2 ) & 1) ? 2 : 0;
3934   int lightpen = (input_port_read(machine, "lightpen_button") & 1) ? 2 : 0;
39123935   int cass = to7_get_cassette() ? 0x80 : 0;
39133936   int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40;
39143937   return lightpen | cass | dtr;
r2781r2782
42484271static TIMER_CALLBACK(mo6_game_update_cb)
42494272{
42504273   /* unlike the TO8, CB1 & CB2 are not connected to buttons */
4251   if ( input_port_read_indexed(machine, THOM_INPUT_CONFIG ) & 1 )
4274   if ( input_port_read(machine, "config") & 1 )
42524275   {
42534276      UINT8 mouse = to7_get_mouse_signal();
42544277      pia_set_input_ca1( THOM_PIA_GAME, mouse & 1 ); /* XA */
r2781r2782
42574280   else
42584281   {
42594282      /* joystick */
4260      UINT8 in = input_port_read_indexed(machine, THOM_INPUT_GAME );
4283      UINT8 in = input_port_read(machine, "game_port_buttons");
42614284      pia_set_input_ca1( THOM_PIA_GAME, in & 0x04 ); /* P1 action B */
42624285      pia_set_input_ca2( THOM_PIA_GAME, in & 0x40 ); /* P1 action A */
42634286   }
r2781r2782
42974320   return
42984321      (mo5_get_cassette() ? 0x80 : 0) |     /* bit 7: cassette input */
42994322      8 |                                   /* bit 3: kbd-line float up to 1 */
4300      ((input_port_read_indexed(machine, THOM_INPUT_LIGHTPEN + 2 ) & 1) ? 2 : 0);
4323      ((input_port_read(machine, "lightpen_button") & 1) ? 2 : 0);
43014324   /* bit 1: lightpen button */;
43024325}
43034326
r2781r2782
43104333   UINT8 portb = pia_get_output_b( THOM_PIA_SYS );
43114334   int col = (portb >> 4) & 7;    /* B bits 4-6: kbd column */
43124335   int lin = (portb >> 1) & 7;    /* B bits 1-3: kbd line */
4336   char tag[12];
43134337
43144338   if ( ! (porta & 8) )
43154339      lin = 8;     /* A bit 3: 9-th kbd line select */
43164340
4341   sprintf(tag, "keyboard_%d", lin);
43174342   return
4318      ( input_port_read_indexed(machine,  THOM_INPUT_KEYBOARD + lin ) & (1 << col) )
4319      ?  0x80 : 0; /* bit 7: key up */
4343      ( input_port_read(machine, tag) & (1 << col) ) ?  0x80 : 0;
4344   /* bit 7: key up */
43204345}
43214346
43224347
r2781r2782
47324757   UINT8 portb = pia_get_output_b( THOM_PIA_SYS );
47334758   int col = (portb >> 4) & 7;    /* B bits 4-6: kbd column */
47344759   int lin = (portb >> 1) & 7;    /* B bits 1-3: kbd line */
4760   char tag[12];
4761   
4762   sprintf(tag, "keyboard_%d", lin);
47354763   return
4736      ( input_port_read_indexed(machine,  THOM_INPUT_KEYBOARD + lin ) & (1 << col) )
4737      ?  0x80 : 0; /* bit 7: key up */
4764      ( input_port_read(machine, tag) & (1 << col) ) ? 0x80 : 0;
4765   /* bit 7: key up */
47384766}
47394767
47404768

Previous 15994 Revisions Next


© 1998-2018 The MESS Team