Previous 15994 Revisions Next

r6848 Friday 1st January, 2010 at 23:46:22 UTC by Nathan Woods
More Atari Ace cleanups
[docs]messnew.txt
[src/mess/audio]dai.c
[src/mess/devices]cartslot.c cassette.c flopdrv.c
[src/mess/drivers]a2600.c c128.c genesis.c gmaster.c ip22.c jaguar.c jr200.c mk14.c nc.c newbrain.c pce.c pcw.c saturn.c socrates.c spc1000.c specpls3.c tvc.c vt100.c vtech1.c
[src/mess/formats]ami_dsk.c flopimg.h nes_dsk.c oric_tap.c td0_dsk.c ti85_ser.c uef_cas.c zx81_p.c
[src/mess/includes]msx_slot.h
[src/mess/machine]amstrad.c atarifdc.c atom.c ay3600.c bbc.c bk.c compis.c cybiko.c dc.c dgn_beta.c electron.c exidy.c hec2hrp.c i8257.h irisha.c llc.c mc6846.c mekd2.c msx.c msx_slot.c ondra.c p2000t.c pc8801.c pecom.c pet.c pk8020.c pmd85.c pp01.c rmnimbus.c sms.c special.c svi318.c tc8521.c teleprinter.c terminal.c thomson.c ti85.c ti99_4x.c upd765.c ut88.c vtech2.c z1013.c
[src/mess/tools/imgtool/modules]d64.c fmsx_cas.c msx_dsk.c prodos.c svi_cas.c thomson.c ti85.c vmsx_gm2.c xsa.c
[src/mess/video]a7800.c arcadia.c avigo.c gb.c gba.c i82720.c m6845.c newport.c odyssey2.c orion.c pc8801.c pc_vga.c spectrum.c thomson.c ti85.c timex.c tms3556.c vdc8563.c vic6567.c z88.c

src/mess/devices/cassette.c
r6847r6848
355355   y *= ui_get_line_height() + 2.0f * UI_BOX_TB_BORDER;
356356   /* choose which frame of the animation we are at */
357357   n = ((int) position / ANIMATION_FPS) % ANIMATION_FRAMES;
358   /* Since you can have anything in a BDF file, we will use crude ascii characters instead */
359   snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
358360#if 0
359361   /* THE ANIMATION HASN'T WORKED SINCE 0.114 - LEFT HERE FOR REFERENCE */
360362   /* NEVER SEEN THE PLAY / RECORD ICONS */
361363   /* character pairs 2-3, 4-5, 6-7, 8-9 form little tape cassette images */
362   snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
363364      n * 2 + 2,                        /* cassette icon left */
364365      n * 2 + 3,                        /* cassette icon right */
365366      (uistate == CASSETTE_PLAY) ? 16 : 14,   /* play or record icon */
366#endif
367   /* Since you can have anything in a BDF file, we will use crude ascii characters instead */
368   snprintf(buf, ARRAY_LENGTH(buf), "%c%c %c %02d:%02d (%04d) [%02d:%02d (%04d)]",
367#else
369368      shapes[n],               /* cassette icon left */
370369      shapes[n|4],               /* cassette icon right */
371370      (uistate == CASSETTE_PLAY) ? 0x50 : 0x52,   /* play (P) or record (R) */
371#endif
372372      ((int) position / 60),
373373      ((int) position % 60),
374374      (int) position,
src/mess/devices/flopdrv.c
r6847r6848
980980      case DEVINFO_INT_IMAGE_TYPE:            info->i = IO_FLOPPY; break;
981981      case DEVINFO_INT_IMAGE_READABLE:         info->i = 1; break;
982982      case DEVINFO_INT_IMAGE_WRITEABLE:         info->i = 1; break;
983      case DEVINFO_INT_IMAGE_CREATABLE:   {
983      case DEVINFO_INT_IMAGE_CREATABLE:
984                                 {
984985                                    int cnt = 0;
985986                                    if ( device && device->static_config )
986987                                    {
r6847r6848
9991000      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(floppy); break;
10001001      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(floppy); break;
10011002      case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE:      info->p = (void *)floppy_option_guide; break;
1002      case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT:      {
1003      case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT:
1004      {
10031005         const struct FloppyFormat *floppy_options = ((floppy_config*)device->static_config)->formats;
10041006         int count;
10051007         for (count = 0; floppy_options[count].construct; count++)
10061008            ;
10071009         info->i = count;
10081010         break;
1009         }
1011      }
10101012
10111013      /* --- the following bits of info are returned as NULL-terminated strings --- */
10121014      case DEVINFO_STR_NAME:                  strcpy(info->s, "Floppy Disk"); break;
src/mess/devices/cartslot.c
r6847r6848
419419      case DEVINFO_INT_IMAGE_WRITEABLE:         info->i = 0; break;
420420      case DEVINFO_INT_IMAGE_CREATABLE:         info->i = 0; break;
421421      case DEVINFO_INT_IMAGE_RESET_ON_LOAD:      info->i = 1; break;
422      case DEVINFO_INT_IMAGE_MUST_BE_LOADED:      if ( device && device->inline_config) {
423                                          info->i = get_config(device)->must_be_loaded;
424                                       } else {
425                                          info->i = 0;
426                                       }
427                                       break;
422      case DEVINFO_INT_IMAGE_MUST_BE_LOADED:
423         if ( device && device->inline_config) {
424            info->i = get_config(device)->must_be_loaded;
425         } else {
426            info->i = 0;
427         }
428         break;
428429
429430      /* --- the following bits of info are returned as pointers to functions --- */
430431      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(cartslot);               break;
431432      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cartslot);      break;
432433      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cartslot);      break;
433434      case DEVINFO_FCT_GET_IMAGE_DEVICES:         info->f = (genf *) DEVICE_GET_IMAGE_DEVICES_NAME(cartslot);   break;
434      case DEVINFO_FCT_IMAGE_PARTIAL_HASH:      if ( device && device->inline_config && get_config(device)->device_partialhash) {
435                                          info->f = (genf *) get_config(device)->device_partialhash;
436                                       } else {
437                                          info->f = NULL;
438                                       }
439                                       break;
435      case DEVINFO_FCT_IMAGE_PARTIAL_HASH:
436         if ( device && device->inline_config && get_config(device)->device_partialhash) {
437            info->f = (genf *) get_config(device)->device_partialhash;
438         } else {
439            info->f = NULL;
440         }
441         break;
440442
441443      /* --- the following bits of info are returned as NULL-terminated strings --- */
442444      case DEVINFO_STR_NAME:                  strcpy(info->s, "Cartslot"); break;
src/mess/tools/imgtool/modules/fmsx_cas.c
r6847r6848
1313    mess/formats/fmsx_cas.[ch] files, for the actual conversion.
1414*/
1515
16typedef struct {
16typedef struct
17   {
1718   imgtool_image         base;
1819   char         *file_name;
1920   imgtool_stream          *file_handle;
src/mess/tools/imgtool/modules/thomson.c
r6847r6848
641641    else return -1;
642642    timeout--;
643643    if ( timeout < 0 ) return -1;
644  }
644  }
645645}
646646
647647/* number of blocks used by file */
r6847r6848
10671067    break;
10681068  case 1: d.format = 0; break;
10691069  case 2: d.format = 0xff; break;
1070  }
1070 }
10711071
10721072 /* comment */
10731073 comment = option_resolution_lookup_string( opts, 'C' );
src/mess/tools/imgtool/modules/ti85.c
r6847r6848
3131      "Range settings",      //0x18
3232      "Range settings",      //0x19
3333      "Range settings",      //0x1a
34      "Range settings"};      //0x1b
34      "Range settings"      //0x1b
35};
3536
3637typedef struct {
3738   char signature[0x08];
r6847r6848
429430   ti85_header header = {   {'*','*','T','I','8','5','*','*'},
430431            {0x1a, 0x0c, 0x00},
431432            "",
432            {0x00, 0x00} };
433            {0x00, 0x00}
434   };
433435
434436   char checksum[] = {0x00, 0x00};
435437
src/mess/tools/imgtool/modules/d64.c
r6847r6848
8383   0, // 1571 0x80
8484   { { 0 } },
8585   { '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0',
86     '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0' },
86     '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0'
87   },
8788   { 0xa0, 0xa0 }, { 0xa0, 0xa0 } , 0xa0, { '2', 'A' } , { '\xa0','\xa0','\xa0','\xa0' },
8889};
8990
r6847r6848
121122   40,3,'D',
122123   0,
123124   { '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0',
124     '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0', 0xa0, 0xa0 },
125     '\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0','\xa0', 0xa0, 0xa0
126   },
125127   { 0xa0, 0xa0 } , 0xa0, { '3', 'D' } , { '\xa0','\xa0' },
126128};
127129
src/mess/tools/imgtool/modules/vmsx_gm2.c
r6847r6848
1919
2020#define NewName "gmaster2.mem"
2121
22typedef struct {
22typedef struct
23   {
2324   imgtool_image         base;
2425   imgtool_stream          *file_handle;
2526   int          size;
src/mess/tools/imgtool/modules/prodos.c
r6847r6848
21262126   if (err)
21272127      return err;
21282128
2129   return IMGTOOLERR_SUCCESS;}
2129   return IMGTOOLERR_SUCCESS;
2130}
21302131
21312132
21322133
src/mess/tools/imgtool/modules/msx_dsk.c
r6847r6848
4545#include "utils.h"
4646
4747
48typedef struct {
48typedef struct
49   {
4950   imgtool_image         base;
5051   char         *file_name;
5152   imgtool_stream          *file_handle;
r6847r6848
172173#define    FORMAT_MULTI   (3)
173174
174175static int msx_dsk_image_init(const imgtool_module *mod, imgtool_stream *f, imgtool_image **outimg)
175{
176   {
176177   DSK_IMAGE *image;
177178   int size, disks, correct, format;
178    UINT8 header;
179   UINT8 header;
179180
180181   size = stream_size (f);
181182   if (size < (360*1024) )
src/mess/tools/imgtool/modules/svi_cas.c
r6847r6848
1313    Uses the mess/formats/svi_cas.[ch] files, for the actual conversion.
1414*/
1515
16typedef struct {
16typedef struct
17   {
1718   imgtool_image         base;
1819   char         *file_name;
1920   imgtool_stream          *file_handle;
src/mess/tools/imgtool/modules/xsa.c
r6847r6848
99#include "utils.h"
1010
1111
12typedef struct {
12typedef struct
13   {
1314   imgtool_image         base;
1415   char         *file_name;
1516   imgtool_stream          *file_handle;
r6847r6848
211212static unsigned cpdbmask[tblsize];
212213static const unsigned cpdext[] = { /* Extra bits for distance codes */
213214          0,  0,  0,  0,  1,  2,  3,  4,
214          5,  6,  7,  8,  9, 10, 11, 12};
215          5,  6,  7,  8,  9, 10, 11, 12
216};
215217
216218static SHORT tblsizes[tblsize];
217219static huf_node huftbl[2*tblsize-1];
r6847r6848
323325    do  {
324326      if (1 != stream_read (in, &byt, 1) )
325327         return IMGTOOLERR_READERROR;
326      } while (byt);
328    } while (byt);
327329   in_stream = in;
328330    bitcnt = 0;         /* nog geen bits gelezen               */
329331
src/mess/audio/dai.c
r6847r6848
2424                  0,  500, 1000, 1500,
2525               2000, 2500, 3000, 3500,
2626               4000, 4500, 5000, 5500,
27               6000, 6500, 7000, 7500};
27               6000, 6500, 7000, 7500
28};
2829
2930static const UINT16 dai_noise_volume_table[] = {
3031                    0,    0,    0,    0,
3132                    0,    0,    0,    0,
3233                       500, 1000, 1500, 2000,
33                 2500, 3000, 3500, 4000};
34                 2500, 3000, 3500, 4000
35};
3436
3537void dai_set_input(running_machine *machine, int index, int state)
3638{
src/mess/video/i82720.c
r6847r6848
12181218/*-------------------------------------------------------------------------*/
12191219static int gdc_nbr_expected_params(UINT8 command)
12201220{
1221   switch(command)
1222   {
1223      /* Video control commands */
1221    switch(command)
1222    {
1223      /* Video control commands */
12241224
1225      case CMD_START:
1226      case CMD_VSYNC_SLAVE:
1227      case CMD_VSYNC_MASTER:
1225      case CMD_START:
1226      case CMD_VSYNC_SLAVE:
1227      case CMD_VSYNC_MASTER:
12281228      case CMD_BCTRL_OFF:
12291229      case CMD_BCTRL_ON:
12301230      case CMD_FIGD:
r6847r6848
12631263                  return 16;
12641264            }
12651265         }
1266   }
1267
1266    }
12681267}
12691268
12701269
r6847r6848
13841383         data = 0xff;
13851384         data = 0x00;
13861385         break;
1387   }
1388   LOG((" returns %1X\n", data));
1386   }
1387   LOG((" returns %1X\n", data));
13891388   return(data);
13901389}
13911390
src/mess/video/gb.c
r6847r6848
660660                 */
661661            if( !((yidx >= SGB_YOFFSET && yidx < SGB_YOFFSET + 144) &&
662662               (xindex >= SGB_XOFFSET && xindex < SGB_XOFFSET + 160)) )
663               {
663            {
664664               gb_plot_pixel(bitmap, xindex, yidx, sgb_pal[pal + colour]);
665665            }
666666            xindex++;
r6847r6848
15001500         /* Generate lcd interrupt if requested */
15011501         if ( ! gb_lcd.mode_irq && ( LCDSTAT & 0x08 ) &&
15021502              ( ( ! gb_lcd.line_irq && gb_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1503             {
1503         {
15041504            cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE );
15051505         }
15061506         timer_adjust_oneshot(gb_lcd.lcd_timer, cputag_clocks_to_attotime(machine, "maincpu", 196 - gb_lcd.scrollx_adjust - gb_lcd.sprite_cycles), GB_LCD_STATE_LYXX_M0_PRE_INC);
r6847r6848
15521552            /* Generate lcd interrupt if requested */
15531553            if ( ! gb_lcd.mode_irq && gb_lcd.triggering_mode_irq &&
15541554                ( ( ! gb_lcd.triggering_line_irq && ! gb_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1555                {
1555            {
15561556               gb_lcd.mode_irq = 1;
15571557               cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE );
15581558            }
r6847r6848
17731773         /* Generate lcd interrupt if requested */
17741774         if ( ! gb_lcd.mode_irq && gb_lcd.triggering_mode_irq &&
17751775              ( ( ! gb_lcd.line_irq && gb_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1776             {
1776         {
17771777            cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE );
17781778            gb_lcd.triggering_mode_irq = 0;
17791779         }
r6847r6848
18431843            /* Generate lcd interrupt if requested */
18441844            if ( ! gb_lcd.mode_irq && ( LCDSTAT & 0x20 ) &&
18451845                ( ( ! gb_lcd.triggering_line_irq && ! gb_lcd.delayed_line_irq ) || ! ( LCDSTAT & 0x40 ) ) )
1846                {
1846            {
18471847               gb_lcd.mode_irq = 1;
18481848               cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE );
18491849            }
r6847r6848
18721872         /* Generate lcd interrupt if requested */
18731873         if ( ( gb_lcd.delayed_line_irq && gb_lcd.triggering_line_irq && ! ( LCDSTAT & 0x20 ) ) ||
18741874             ( !gb_lcd.mode_irq && ! gb_lcd.line_irq && ! gb_lcd.delayed_line_irq && ( LCDSTAT & 0x20 ) ) )
1875             {
1875         {
18761876            cputag_set_input_line( machine, "maincpu", LCD_INT, ASSERT_LINE );
18771877         }
18781878         gb_lcd.line_irq = gb_lcd.triggering_line_irq;
r6847r6848
22842284      {
22852285         if ( ( gb_lcd.state != GB_LCD_STATE_LYXX_M0_PRE_INC && CURLINE == data ) ||
22862286              ( gb_lcd.state == GB_LCD_STATE_LYXX_M0_INC && gb_lcd.triggering_line_irq ) )
2287             {
2287         {
22882288            LCDSTAT |= 0x04;
22892289            /* Generate lcd interrupt if requested */
22902290            if ( LCDSTAT & 0x40 )
src/mess/video/z88.c
r6847r6848
176176         ptr+=2;
177177
178178         /* inverted graphics? */
179            if (byte1 & Z88_SCR_HW_REV)
180            {
179         if (byte1 & Z88_SCR_HW_REV)
180         {
181181            pen1 = 0;
182182
183183            if (byte1 & Z88_SCR_HW_GRY)
r6847r6848
188188            {
189189               pen0 = 1;
190190            }
191            }
192            else
193                {
191         }
192         else
193         {
194194            pen0 = 0;
195195            if (byte1 & Z88_SCR_HW_GRY)
196196            {
src/mess/video/newport.c
r6847r6848
506506      }
507507      break;
508508   case 0x03: /* Register Write */
509   switch( nREX3_DCBRegSelect )
510   {
511   case 0x00:
512      verboselog(machine, 2, "VC2 Register Setup:\n" );
513      nVC2_RegIdx = ( data & 0xff000000 ) >> 24;
514      nVC2_RegData = ( data & 0x00ffff00 ) >> 8;
509      switch( nREX3_DCBRegSelect )
510      {
511      case 0x00:
512         verboselog(machine, 2, "VC2 Register Setup:\n" );
513         nVC2_RegIdx = ( data & 0xff000000 ) >> 24;
514         nVC2_RegData = ( data & 0x00ffff00 ) >> 8;
515515      switch( nVC2_RegIdx )
516516      {
517517      case 0x00:
r6847r6848
567567         break;
568568      case 0x1f:
569569         verboselog(machine, 2, "    Configuration:        %04x\n", nVC2_RegData );
570            nVC2_Register[0x20] = nVC2_RegData;
570         nVC2_Register[0x20] = nVC2_RegData;
571571         break;
572572      default:
573573         verboselog(machine, 2, "    Unknown VC2 Register: %04x\n", nVC2_RegData );
574574         break;
575575      }
576576         nVC2_Register[nVC2_RegIdx] = nVC2_RegData;
577      break;
577         break;
578578      default:
579579         verboselog(machine, 2, "Unknown VC2 Register Write: %02x = %08x\n", nREX3_DCBRegSelect, data );
580      break;
580         break;
581581      }
582582      break;
583583   default:
src/mess/video/pc_vga.c
r6847r6848
301301//#define CURSOR_POS (vga.crtc.data[0xf]|(vga.crtc.data[0xe]<<8))
302302
303303#define FONT1 ( ((vga.sequencer.data[3]&3)|((vga.sequencer.data[3]&0x10)<<2))*0x2000)
304#define FONT2 ( ((vga.sequencer.data[3]&c)>>2)|((vga.sequencer.data[3]&0x20)<<3))*0x2000)
304#define FONT2 ((((vga.sequencer.data[3]&c)>>2)|((vga.sequencer.data[3]&0x20)<<3))*0x2000)
305305
306306
307307INLINE UINT8 rotate_right(UINT8 val, UINT8 rot)
src/mess/video/arcadia.c
r6847r6848
307307         UINT8 ram1[2][16];
308308         struct   {
309309            UINT8 y,x;
310               } pos[4];
310         } pos[4];
311311         UINT8 ram2[4];
312312         UINT8 vpos;
313313         UINT8 sound1, sound2;
r6847r6848
325325         // 0x1a00
326326         UINT8 chars2[13][16];
327327         UINT8 ram3[3][16];
328         } d;
329      } reg;
330   bitmap_t *bitmap;
328   } d;
329    } reg;
330    bitmap_t *bitmap;
331331} arcadia_video={ 0 };
332332
333333VIDEO_START( arcadia )
src/mess/video/thomson.c
r6847r6848
429429         UINT8 rama = vram[ 0      ];         \
430430         UINT8 ramb = vram[ 0x2000 ];
431431
432#define END_UPDATE                     \
433      }                     \
434   }
435
432436#define UPDATE_HI( name )  UPDATE( name, 16 )
433437#define UPDATE_LOW( name ) UPDATE( name,  8 )
434438
435#define END_UPDATE } }
436439
437440
438
439441/* 320x200, 16-colors, constraints: 2 distinct colors per GPL (8 pixels) */
440442/* this also works for TO7, assuming the 2 top bits of each color byte are 1 */
441443
r6847r6848
746748
747749UPDATE_HI( overlay3 )
748750{
749   static const int p[2][2][2][2] =
750      { { { { 0, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } },
751        { { { 8, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } } };
751   static const int p[2][2][2][2] = {
752        { { { 0, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } },
753        { { { 8, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } }
754   };
752755   int i;
753756   for ( i = 0; i < 16; i += 4, rama >>= 1, ramb >>= 1 )
754757      dst[ 15 - i ] = dst[ 14 - i ] = dst[ 13 - i ] = dst[ 12 - i ] =
r6847r6848
759762
760763UPDATE_LOW( overlay3 )
761764{
762   static const int p[2][2][2][2] =
763      { { { { 0, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } },
764        { { { 8, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } } };
765   static const int p[2][2][2][2] = {
766        { { { 0, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } },
767        { { { 8, 1 }, { 2, 1 }, }, { { 4, 1 }, { 2, 1 } } }
768   };
765769   int i;
766770   for ( i = 0; i < 8; i += 2, rama >>= 1, ramb >>= 1 )
767771      dst[ 7 - i ] = dst[ 6 - i ] =
r6847r6848
958962      do
959963      {
960964         y++;
961         ypos ++ /* += scale */; }
962      while ( y < ybot && thom_border_l[ y ] == -1 );
965         ypos ++ /* += scale */;
966      } while ( y < ybot && thom_border_l[ y ] == -1 );
963967      wrect.max_y = ypos - 1;
964968      bitmap_fill( bitmap, &wrect , border);
965969   }
src/mess/video/spectrum.c
r6847r6848
152152                                        spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,ink);
153153                                else
154154                                        spectrum_plot_pixel(bitmap,scrx++,SPEC_TOP_BORDER+scry,pap);
155         }
155                        }
156156                scr++;
157157                attr++;
158158                }
159   }
159        }
160160
161161   border_draw(screen->machine, bitmap, full_refresh,
162162      SPEC_TOP_BORDER, SPEC_DISPLAY_YSIZE, SPEC_BOTTOM_BORDER,
src/mess/video/pc8801.c
r6847r6848
323323            memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc000, 0xefff, 0, 0, write_gvram_alu3_bank5);
324324            memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xf000, 0xffff, 0, 0, write_gvram_alu3_bank6);
325325            break;
326              }
326         }
327327            return 1;
328328      }
329329      else
r6847r6848
512512            attr_new &= ~TX_BL;
513513            if ((blink_count / blink_period) & 1)
514514               attr_new ^= TX_REV;
515            }
515         }
516516
517517         if (attr_new & TX_CUR)
518518         {
r6847r6848
760760      default:
761761         logerror("pc8801: illegal crtc command 0x%.2x.\n", data);
762762         return;
763          }
763      }
764764   }
765765   else
766766   {
src/mess/video/timex.c
r6847r6848
209209                unsigned short inkcolor = (ts2068_port_ff_data & 0x38) >> 3;
210210                for (count = 0; count < 192; count++)
211211                        ts2068_64col_scanline(screen->machine,bitmap, count, TS2068_TOP_BORDER, inkcolor);
212   }
212        }
213213        else if ((ts2068_port_ff_data & 7) == 2)
214214        {
215215                /* Extended Color mode */
src/mess/video/orion.c
r6847r6848
7575                              color += 8;
7676                            }
7777                            break;
78                  }
78                  }
7979            }
8080            *BITMAP_ADDR16(bitmap, y, x*8+(7-b)) = color;
8181         }
src/mess/video/a7800.c
r6847r6848
329329                  inc_hpos_by_2();
330330                  break;
331331
332               }   /* endswitch (mode) */
333            }   /* endwhile (ind_bytes > 0)*/
334          }   /* endfor (x=0; x<width; x++) */
332            }   /* endswitch (mode) */
333         }   /* endwhile (ind_bytes > 0)*/
334       }   /* endfor (x=0; x<width; x++) */
335335   }   /* endwhile (READ_MEM(dl + 1) != 0) */
336336}
337337
src/mess/video/vdc8563.c
r6847r6848
426426      memset(vdc.dirty+vdc.videoram_start, 1, vdc.videoram_size);
427427
428428   for (y=0, rect.min_y=height, rect.max_y=rect.min_y+height-1,
429          i=vdc.videoram_start&vdc.mask; y<h;
430       y++, rect.min_y+=height, rect.max_y+=height) {
431      for (x=0; x<w; x++, i=(i+1)&vdc.mask) {
432         if (vdc.dirty[i]) {
429      i=vdc.videoram_start&vdc.mask; y<h;
430      y++, rect.min_y+=height, rect.max_y+=height)
431   {
432      for (x=0; x<w; x++, i=(i+1)&vdc.mask)
433      {
434         if (vdc.dirty[i])
435         {
433436            drawgfx_opaque(bitmap,&rect,machine->gfx[0],
434437                  vdc.ram[i], FRAMECOLOR|(MONOCOLOR<<4), 0, 0,
435438                  machine->gfx[0]->width*x+8,height*y+height);
436            if ((vdc.cursor_on)&&(i==(CRTC6845_CURSOR_POS&vdc.mask))) {
439            if ((vdc.cursor_on)&&(i==(CRTC6845_CURSOR_POS&vdc.mask)))
440            {
437441               int k=height-CRTC6845_CURSOR_TOP;
438442               if (CRTC6845_CURSOR_BOTTOM<height) k=CRTC6845_CURSOR_BOTTOM-CRTC6845_CURSOR_TOP+1;
439443
r6847r6848
466470      memset(vdc.dirty+vdc.videoram_start, 1, vdc.videoram_size);
467471
468472   for (y=0, rect.min_y=height, rect.max_y=rect.min_y+height-1,
469          i=vdc.videoram_start&vdc.mask, j=vdc.colorram_start&vdc.mask; y<h;
470       y++, rect.min_y+=height, rect.max_y+=height) {
471      for (x=0; x<w; x++, i=(i+1)&vdc.mask, j=(j+1)&vdc.mask) {
473      i=vdc.videoram_start&vdc.mask, j=vdc.colorram_start&vdc.mask; y<h;
474      y++, rect.min_y+=height, rect.max_y+=height)
475   {
476      for (x=0; x<w; x++, i=(i+1)&vdc.mask, j=(j+1)&vdc.mask)
477      {
472478         if (vdc.dirty[i]||vdc.dirty[j])
473479         {
474480            {
r6847r6848
492498               }
493499            }
494500
495            if ((vdc.cursor_on)&&(i==(CRTC6845_CURSOR_POS&vdc.mask))) {
501            if ((vdc.cursor_on)&&(i==(CRTC6845_CURSOR_POS&vdc.mask)))
502            {
496503               int k=height-CRTC6845_CURSOR_TOP;
497504               if (CRTC6845_CURSOR_BOTTOM<height) k=CRTC6845_CURSOR_BOTTOM-CRTC6845_CURSOR_TOP+1;
498505
r6847r6848
527534      memset(vdc.dirty, 1, vdc.mask+1);
528535
529536   for (y=0, rect.min_y=height, rect.max_y=rect.min_y+height-1,
530          i=vdc.videoram_start&vdc.mask; y<h;
531       y++, rect.min_y+=height, rect.max_y+=height) {
532      for (x=0; x<w; x++, i=(i+1)&vdc.mask) {
533         for (j=0; j<height; j++) {
537      i=vdc.videoram_start&vdc.mask; y<h;
538      y++, rect.min_y+=height, rect.max_y+=height)
539   {
540      for (x=0; x<w; x++, i=(i+1)&vdc.mask)
541      {
542         for (j=0; j<height; j++)
543         {
534544            k=((i<<4)+j)&vdc.mask;
535            if (vdc.dirty[k]) {
545            if (vdc.dirty[k])
546            {
536547               drawgfx_opaque(bitmap,&rect,machine->gfx[1],
537548                     vdc.ram[k], FRAMECOLOR|(MONOCOLOR<<4), 0, 0,
538549                     machine->gfx[0]->width*x+8,height*y+height+j);
src/mess/video/avigo.c
r6847r6848
8080         LOG(("error: vid mem column write: %02x\n",data));
8181      }
8282      return;
83        }
83   }
8484
8585        if ((offset<0x0100) || (offset>=0x01f0))
8686        {
src/mess/video/vic6567.c
r6847r6848
21642164                        } \
21652165                     } \
21662166                  } \
2167                } \
2167               } \
21682168            } \
21692169         } \
21702170      } \
src/mess/video/odyssey2.c
r6847r6848
545545                  for ( m = 0x01; m > 0; m <<= 1, x++ )
546546                  {
547547                     if ( chr & m )
548                      {
548                     {
549549                        if ( x >= 0 && x < 160 )
550550                        {
551551                           /* Check if we collide with an already drawn source object */
src/mess/video/m6845.c
r6847r6848
592592                        crtc.HSYNC=True;
593593                        if (crtc.intf->out_HS_func) (crtc.intf->out_HS_func)(machine, 0,crtc.HSYNC); /* call HS update */
594594                }
595        }
595   }
596596
597597        if (crtc.HSYNC)
598598        {
src/mess/video/tms3556.c
r6847r6848
539539   double_lines = 0;
540540
541541#if 0
542   if (vdp.controlRegs[4] & 0x??
542   if ( vdp.controlRegs[4] & 0x?? )
543543   {   // interlaced mode
544544      ln = BITMAP_ADDR16(bmp, line, vdp.field);
545545   }
src/mess/video/ti85.c
r6847r6848
219219                 + ((*(ti85_frames+5*ti_video_memory_size+y*ti_screen_x_size+x)>>(7-b)) & 0x01);
220220
221221            *BITMAP_ADDR16(bitmap, y, x*8+b) = ti85_palette[ti85_LCD_contrast&0x1f][brightnes];
222                   }
222         }
223223   return 0;
224224}
225225
r6847r6848
257257                 + ((*(ti85_frames+5*ti_video_memory_size+y*ti_screen_x_size+x)>>(7-b)) & 0x01);
258258
259259            *BITMAP_ADDR16(bitmap, y, x*8+b) = ti85_palette[ti85_LCD_contrast&0x1f][brightnes];
260                   }
260         }
261261   return 0;
262262}
263263
src/mess/video/gba.c
r6847r6848
2727   }
2828}
2929
30static int coeff[32] = {  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
31                   16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16 };
30static int coeff[32] = {
31   0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
32   16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
33};
3234
3335/* Drawing functions */
3436static void draw_roz_bitmap_scanline(gba_state *gba_state, UINT32 *scanline, int ypos, UINT32 enablemask, UINT32 ctrl, INT32 X, INT32 Y, INT32 PA, INT32 PB, INT32 PC, INT32 PD, INT32 *currentx, INT32 *currenty, int changed, int depth);
src/mess/includes/msx_slot.h
r6847r6848
158158} msx_slot;
159159
160160extern const msx_slot msx_slot_list[];
161
161162#define MSX_SLOT_START \
162163const msx_slot msx_slot_list[] = {
164
163165#define MSX_SLOT_ROM(type, ent) { \
164166   type,                     \
165167   MSX_MEM_ROM,               \
r6847r6848
169171   slot_##ent##_map,            \
170172   NULL,                     \
171173   NULL,                     \
172   NULL },
174   NULL                     \
175},
176
173177#define MSX_SLOT_RAM(type, ent) { \
174178   type,                     \
175179   MSX_MEM_RAM,               \
r6847r6848
179183   slot_##ent##_map,            \
180184   NULL,                     \
181185   NULL,                     \
182   NULL },
186   NULL                     \
187},
188
183189#define MSX_SLOT(type, ent) { \
184190   type,                     \
185191   MSX_MEM_HANDLER,            \
r6847r6848
189195   slot_##ent##_map,            \
190196   slot_##ent##_write,            \
191197   NULL,                     \
192   NULL },
198   NULL                     \
199},
200
193201#define MSX_SLOT_SRAM(type, ent) { \
194202   type,                     \
195203   MSX_MEM_HANDLER,            \
r6847r6848
199207   slot_##ent##_map,            \
200208   slot_##ent##_write,            \
201209   slot_##ent##_loadsram,         \
202   slot_##ent##_savesram },
210   slot_##ent##_savesram         \
211},
212
203213#define MSX_SLOT_NULL(type) { \
204214   type,                     \
205215   MSX_MEM_ROM,               \
r6847r6848
209219   NULL,                     \
210220   NULL,                     \
211221   NULL,                     \
212   NULL },
222   NULL                     \
223},
224
213225#define MSX_SLOT_END \
214226   { SLOT_END, 0, "", NULL, NULL, NULL, NULL, NULL } \
215227};
r6847r6848
234246
235247extern const msx_driver_struct msx_driver_list[];
236248
237#define MSX_DRIVER_LIST    \
249#define MSX_DRIVER_LIST      \
238250const msx_driver_struct msx_driver_list[] = {
239#define MSX_DRIVER(foo)    \
251#define MSX_DRIVER(foo)      \
240252      { #foo, msx_slot_layout_##foo },
241253#define MSX_DRIVER_END      \
242254      { "", NULL }      \
src/mess/machine/dgn_beta.c
r6847r6848
600600   int RetVal;
601601   int Idx;
602602   int Selected;
603   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
604                              "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" };
603   static const char *const keynames[] = {
604      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
605      "KEY5", "KEY6", "KEY7", "KEY8", "KEY9"
606   };
605607
606608   LOG_KEYBOARD(("PB Read\n"));
607609
r6847r6848
10281030#if 0
10291031   int   Idx;
10301032   int   Row;
1031   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
1032                              "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" };
1033   static const char *const keynames[] = {
1034      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
1035      "KEY5", "KEY6", "KEY7", "KEY8", "KEY9"
1036   };
10331037
10341038   LOG_KEYBOARD(("Scanning Host keyboard\n"));
10351039
src/mess/machine/upd765.c
r6847r6848
15171517
15181518            /* sector id == EOT */
15191519            if (upd765_sector_count_complete(device) || upd765_read_data_stop(device))
1520             {
1520            {
15211521               upd765_read_complete(device);
15221522            }
15231523            else
r6847r6848
15251525               upd765_increment_sector(device);
15261526               upd765_read_data(device);
15271527            }
1528            }
1529            break;
1528         }
1529         break;
15301530
15311531         default:
15321532            break;
src/mess/machine/teleprinter.c
r6847r6848
169169  0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
170170  0x04,0x08,0x08,0x10,0x08,0x08,0x04,0x00,
171171  0x3e,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
172  0x2a,0x15,0x2a,0x15,0x2a,0x15,0x2a,0x15 };
172  0x2a,0x15,0x2a,0x15,0x2a,0x15,0x2a,0x15
173};
173174
174175static void teleprinter_scroll_line(const device_config *device)
175176{
src/mess/machine/msx_slot.c
r6847r6848
17731773      if ((mame_fread (f, buf, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
17741774         !strncmp (buf, PAC_HEADER, PAC_HEADER_LEN) &&
17751775         mame_fread (f, state->cart.fmpac.mem, 0x1ffe))
1776         {
1776      {
17771777         logerror ("fmpac: info: sram loaded\n");
17781778         mame_fclose (f);
17791779         return 0;
r6847r6848
18051805   {
18061806      if ((mame_fwrite (f, PAC_HEADER, PAC_HEADER_LEN) == PAC_HEADER_LEN) &&
18071807         (mame_fwrite (f, state->cart.fmpac.mem, 0x1ffe) == 0x1ffe))
1808         {
1808      {
18091809         logerror ("fmpac: info: sram saved\n");
18101810         mame_fclose (f);
18111811         return 0;
src/mess/machine/tc8521.c
r6847r6848
367367                        }
368368                      }
369369                    }
370                  }
370                 }
371371
372                  tc8521_alarm_check(device);
373               }
374            }
372                 tc8521_alarm_check(device);
373               }
374            }
375375         }
376376      }
377377   }
src/mess/machine/mc6846.c
r6847r6848
343343   case 1:
344344   {
345345      static const char *const cp2[8] =
346         {
346      {
347347         "in,neg-edge", "in,neg-edge,intr", "in,pos-edge", "in,pos-edge,intr",
348348         "out,intr-ack", "out,i/o-ack", "out,0", "out,1"
349349      };
350      static const char *const cp1[8] = {
350      static const char *const cp1[8] =
351      {
351352         "neg-edge", "neg-edge,intr", "pos-edge", "pos-edge,intr",
352353         "latched,neg-edge", "latched,neg-edge,intr",
353354         "latcged,pos-edge", "latcged,pos-edge,intr"
src/mess/machine/thomson.c
r6847r6848
701701      int keyline = pia6821_get_output_b( device );
702702      UINT8 val = 0xff;
703703      int i;
704      static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
705                                 "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
704      static const char *const keynames[] = {
705         "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
706         "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7"
707      };
706708
707709      for ( i = 0; i < 8; i++ )
708710      {
r6847r6848
16211623static READ8_DEVICE_HANDLER ( to770_sys_porta_in )
16221624{
16231625   /* keyboard */
1624   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
1625                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
1626   static const char *const keynames[] = {
1627      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
1628      "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7"
1629   };
16261630   int keyline = pia6821_get_output_b( device ) & 7;
16271631
16281632   return input_port_read(device->machine, keynames[7 - keyline]);
r6847r6848
19341938   UINT8 portb = pia6821_get_output_b( device );
19351939   int col = (portb >> 1) & 7;       /* key column */
19361940   int lin = 7 - ((portb >> 4) & 7); /* key line */
1937   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
1938                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
1941   static const char *const keynames[] = {
1942      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
1943      "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7"
1944   };
19391945
19401946   return ( input_port_read(device->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
19411947}
r6847r6848
26062612{
26072613   int line, bit;
26082614   UINT8 port;
2609   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
2610                              "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9" };
2615   static const char *const keynames[] = {
2616      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
2617      "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9"
2618   };
26112619
26122620   for ( line = 0; line < 10; line++ )
26132621   {
r6847r6848
28402848   int shift   = ! (input_port_read(machine, "keyboard_9") & 1);
28412849   int key = -1, line, bit;
28422850   UINT8 port;
2843   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
2844                              "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9" };
2851   static const char *const keynames[] = {
2852      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
2853      "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9"
2854   };
28452855
28462856   for ( line = 0; line < 10; line++ )
28472857   {
r6847r6848
32393249{
32403250   int line, bit;
32413251   UINT8 port;
3242   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
3243                              "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9" };
3252   static const char *const keynames[] = {
3253      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
3254      "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9"
3255   };
32443256
32453257   if ( input_port_read(machine, "config") & 2 )
32463258      return 0; /* disabled */
r6847r6848
32713283   int shift   = (input_port_read(machine, "keyboard_9") & 1) ? 0 : 0x080;
32723284   int key = -1, line, bit;
32733285   UINT8 port;
3274   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
3275                              "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9" };
3286   static const char *const keynames[] = {
3287      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
3288      "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9"
3289   };
32763290
32773291   if ( input_port_read(machine, "config") & 2 )
32783292      return -1; /* disabled */
r6847r6848
46444658   UINT8 portb = pia6821_get_output_b( device );
46454659   int col = (portb >> 4) & 7;    /* B bits 4-6: kbd column */
46464660   int lin = (portb >> 1) & 7;    /* B bits 1-3: kbd line */
4647   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
4648                              "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9" };
4661   static const char *const keynames[] = {
4662      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4",
4663      "keyboard_5", "keyboard_6", "keyboard_7", "keyboard_8", "keyboard_9"
4664   };
46494665
46504666   if ( ! (porta & 8) )
46514667      lin = 8;     /* A bit 3: 9-th kbd line select */
r6847r6848
50445060   UINT8 portb = pia6821_get_output_b( device );
50455061   int col = (portb >> 4) & 7;    /* B bits 4-6: kbd column */
50465062   int lin = (portb >> 1) & 7;    /* B bits 1-3: kbd line */
5047   static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
5048                              "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7" };
5063   static const char *const keynames[] = {
5064      "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3",
5065      "keyboard_4", "keyboard_5", "keyboard_6", "keyboard_7"
5066   };
50495067
50505068   return ( input_port_read(device->machine, keynames[lin]) & (1 << col) ) ? 0x80 : 0;
50515069   /* bit 7: key up */
src/mess/machine/pmd85.c
r6847r6848
245245
246246static  READ8_DEVICE_HANDLER ( pmd85_ppi_0_portb_r )
247247{
248   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
249                              "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" };
248   static const char *const keynames[] = {
249      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
250      "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15"
251   };
250252
251253   return input_port_read(device->machine, keynames[(pmd85_ppi_port_outputs[0][0] & 0x0f)]) & input_port_read(device->machine, "KEY15");
252254}
src/mess/machine/ay3600.c
r6847r6848
366366
367367   static unsigned int time_until_repeat = MAGIC_KEY_REPEAT_NUMBER;
368368
369   static const char *const portnames[] = { "keyb_0", "keyb_1", "keyb_2", "keyb_3", "keyb_4", "keyb_5", "keyb_6",
370                              "keypad_1", "keypad_2" };
369   static const char *const portnames[] = {
370      "keyb_0", "keyb_1", "keyb_2", "keyb_3", "keyb_4", "keyb_5", "keyb_6",
371      "keypad_1", "keypad_2"
372   };
371373
372374   /* check for these special cases because they affect the emulated key codes */
373375
r6847r6848
436438   /* reset key check */
437439   if (apple2_pressed_specialkey(machine, SPECIALKEY_RESET) &&
438440      (a2_no_ctrl_reset(machine) || switchkey & A2_KEY_CONTROL))
439      {
441   {
440442         if (!reset_flag)
441443         {
442444            reset_flag = 1;
src/mess/machine/p2000t.c
r6847r6848
4242
4343READ8_HANDLER (   p2000t_port_000f_r )
4444{
45   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
46                              "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" };
45   static const char *const keynames[] = {
46      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
47      "KEY5", "KEY6", "KEY7", "KEY8", "KEY9"
48   };
4749
4850   if (p2000t_ports.port_101f & P2000M_101F_KEYINT)
4951   {
src/mess/machine/pet.c
r6847r6848
100100static  READ8_DEVICE_HANDLER( pet_pia0_port_b_read )
101101{
102102   UINT8 data = 0xff;
103   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4",
104                              "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" };
103   static const char *const keynames[] = {
104      "ROW0", "ROW1", "ROW2", "ROW3", "ROW4",
105      "ROW5", "ROW6", "ROW7", "ROW8", "ROW9"
106   };
105107
106108   if (pet_keyline_select < 10)
107109   {
r6847r6848
118120{
119121   UINT8 data = 0xff;
120122   pet_state *state = device->machine->driver_data;
121   static const char *const keynames[] = { "ROW0", "ROW1", "ROW2", "ROW3", "ROW4",
122                              "ROW5", "ROW6", "ROW7", "ROW8", "ROW9" };
123   static const char *const keynames[] = {
124      "ROW0", "ROW1", "ROW2", "ROW3", "ROW4",
125      "ROW5", "ROW6", "ROW7", "ROW8", "ROW9"
126   };
123127
124128   if (pet_keyline_select < 10)
125129   {
src/mess/machine/mekd2.c
r6847r6848
484484      ".b.cccccccc...........b." \
485485      ".b.cccccccc...........b." \
486486      ".bbbbbbbbbbbbbbbbbbbbbb." \
487      "........................"};
487      "........................"
488   };
488489
489490   dst = memory_region(machine, "gfx1");
490491   memset(dst, 0, memory_region_length(machine, "gfx1"));
src/mess/machine/electron.c
r6847r6848
119119{
120120   UINT8 data = 0;
121121   int i;
122   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6",
123                              "LINE7", "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13" };
122   static const char *const keynames[] = {
123      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6",
124      "LINE7", "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13"
125   };
124126
125127   //logerror( "PC=%04x: keyboard read from paged rom area, address: %04x", activecpu_get_pc(), offset );
126128   for( i = 0; i < 14; i++ )
src/mess/machine/irisha.c
r6847r6848
4646static const char *const keynames[] = {
4747                     "LINE0", "LINE1", "LINE2", "LINE3",
4848                     "LINE4", "LINE5", "LINE6", "LINE7",
49                     "LINE8", "LINE9"};
49                     "LINE8", "LINE9"
50};
5051
5152static READ8_DEVICE_HANDLER (irisha_8255_portb_r )
5253{
src/mess/machine/bk.c
r6847r6848
2222static TIMER_CALLBACK(keyboard_callback)
2323{
2424   UINT8 code, i, j;
25   static const char *const keynames[] = { "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6",
26                              "LINE7", "LINE8", "LINE9", "LINE10", "LINE11" };
25   static const char *const keynames[] = {
26      "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6",
27      "LINE7", "LINE8", "LINE9", "LINE10", "LINE11"
28   };
2729
2830   for(i = 1; i < 12; i++)
2931   {
src/mess/machine/terminal.c
r6847r6848
169169   0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
170170   0x00, 0xe0, 0x10, 0x10, 0x0c, 0x10, 0x10, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171171   0x00, 0x62, 0x92, 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  };
172   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
173};
173174
174175static void terminal_scroll_line(const device_config *device)
175176{
src/mess/machine/amstrad.c
r6847r6848
16201620            default:
16211621               break;
16221622
1623      }
1623      }
16241624
16251625}
16261626
r6847r6848
28822882      }
28832883      return;
28842884   }
2885  switch (amstrad_Psg_FunctionSelected)
2886  {
2885   switch (amstrad_Psg_FunctionSelected)
2886   {
28872887     case 0:
28882888      {/* Inactive */
28892889      } break;
r6847r6848
29032903         prev_reg = ppi_port_outputs[amstrad_ppi_PortA];
29042904        }
29052905      break;
2906     default: {
2907    } break;
2906     default:
2907      {
2908      } break;
29082909   }
29092910}
29102911
r6847r6848
30553056   If keyboard matrix line 11-14 are selected, the byte is always &ff.
30563057   After testing on a real CPC, it is found that these never change, they always return &FF. */
30573058
3058   static const char *const keynames[] = { "keyboard_row_0", "keyboard_row_1", "keyboard_row_2", "keyboard_row_3", "keyboard_row_4",
3059                              "keyboard_row_5", "keyboard_row_6", "keyboard_row_7", "keyboard_row_8", "keyboard_row_9",
3060                              "keyboard_row_10" };
3059   static const char *const keynames[] = {
3060      "keyboard_row_0", "keyboard_row_1", "keyboard_row_2", "keyboard_row_3", "keyboard_row_4",
3061      "keyboard_row_5", "keyboard_row_6", "keyboard_row_7", "keyboard_row_8", "keyboard_row_9",
3062      "keyboard_row_10"
3063   };
30613064
30623065   if ( ( ppi_port_outputs[amstrad_ppi_PortC] & 0x0F ) > 10)
30633066   {
src/mess/machine/sms.c
r6847r6848
12871287
12881288      /* Check for 8KB on-cart RAM */
12891289      if (strstr(extrainfo, "8KB_CART_RAM"))
1290      {
1290      {
12911291         sms_state.cartridge[index].features |= CF_ONCART_RAM;
12921292         sms_state.cartridge[index].ram_size = 0x2000;
12931293         sms_state.cartridge[index].cartRAM = auto_alloc_array(image->machine, UINT8, sms_state.cartridge[index].ram_size);
src/mess/machine/llc.c
r6847r6848
6868{
6969   int i,j;
7070   UINT8 c;
71   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4",
72      "LINE5", "LINE6", "LINE7", "LINE8", "LINE9", "LINE10", "LINE11" };
71   static const char *const keynames[] = {
72      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4",
73      "LINE5", "LINE6", "LINE7", "LINE8", "LINE9", "LINE10", "LINE11"
74   };
7375
7476   for(i = 0; i < 12; i++)
7577   {
src/mess/machine/z1013.c
r6847r6848
4545
4646static READ8_DEVICE_HANDLER (z1013_port_b_r)
4747{
48   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3",
49      "LINE4", "LINE5", "LINE6", "LINE7" };
48   static const char *const keynames[] = {
49      "LINE0", "LINE1", "LINE2", "LINE3",
50      "LINE4", "LINE5", "LINE6", "LINE7"
51   };
5052   UINT8 data = input_port_read(device->machine, keynames[z1013_keyboard_line & 7]);
5153   if (z1013_keyboard_part==0x10) {
5254      return (data >> 4) & 0x0f;
src/mess/machine/ti85.c
r6847r6848
659659}
660660
661661WRITE8_HANDLER ( ti82_port_0010_w)
662 {
662{
663663   if (data == 0x00 || data == 0x01)
664664      ti82_video_mode = data;
665665   if (data >= 0x04 && data <= 0x07)
r6847r6848
766766}
767767
768768WRITE8_HANDLER ( ti83p_port_0010_w)
769 {
769{
770770   if (data == 0x00 || data == 0x01)
771771      ti82_video_mode = data;
772772   if (data == 0x02 || data == 0x03)
src/mess/machine/svi318.c
r6847r6848
188188static READ8_DEVICE_HANDLER ( svi318_ppi_port_b_r )
189189{
190190   int row;
191   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5",
192                              "LINE6", "LINE7", "LINE8", "LINE9", "LINE10" };
191   static const char *const keynames[] = {
192      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5",
193      "LINE6", "LINE7", "LINE8", "LINE9", "LINE10"
194   };
193195
194196   row = svi.keyboard_row;
195197   if (row <= 10)
r6847r6848
467469 5+1,10+1,10+1,10+1,10+1,11+1, 7+1,11+1, 5+1,10+1,10+1, 0+1,10+1,17+1, 7+1,11+1,
468470 5+1,10+1,10+1,11+1,10+1,11+1, 7+1,11+1, 5+1, 4+1,10+1,11+1,10+1, 0+1, 7+1,11+1,
469471 5+1,10+1,10+1,19+1,10+1,11+1, 7+1,11+1, 5+1, 4+1,10+1, 4+1,10+1, 0+1, 7+1,11+1,
470 5+1,10+1,10+1, 4+1,10+1,11+1, 7+1,11+1, 5+1, 6+1,10+1, 4+1,10+1, 0+1, 7+1,11+1};
472 5+1,10+1,10+1, 4+1,10+1,11+1, 7+1,11+1, 5+1, 6+1,10+1, 4+1,10+1, 0+1, 7+1,11+1
473};
471474
472475static const UINT8 cc_cb[0x100] = {
473476 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
r6847r6848
485488 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
486489 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
487490 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
488 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2};
491 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2
492};
489493
490494static const UINT8 cc_ed[0x100] = {
491495 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
r6847r6848
503507 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
504508 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
505509 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
506 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2};
510 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2
511};
507512
508513static const UINT8 cc_xy[0x100] = {
509514 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,15+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
r6847r6848
521526 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 0+2, 4+2, 4+2, 4+2, 4+2,
522527 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
523528 4+2,14+2, 4+2,23+2, 4+2,15+2, 4+2, 4+2, 4+2, 8+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
524 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,10+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2};
529 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,10+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2
530};
525531
526532static const UINT8 cc_xycb[0x100] = {
52753323+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
r6847r6848
53954523+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
54054623+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
54154723+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
54223+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2};
54823+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2
549};
543550
544551/* extra cycles if jr/jp/call taken and 'interrupt latency' on rst 0-7 */
545552static const UINT8 cc_ex[0x100] = {
r6847r6848
558565 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
559566 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
560567 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
561 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2+1};
568 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2+1
569};
562570
563571
564572DRIVER_INIT( svi318 )
r6847r6848
823831READ8_HANDLER( svi318_io_ext_r )
824832{
825833   UINT8 data = 0xff;
826   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
827   const device_config *printer = devtag_get_device(space->machine, "centronics");
834   const device_config *device;
828835
829836   if (svi.bankLow == SVI_CART)
830837   {
r6847r6848
834841   switch( offset )
835842   {
836843   case 0x12:
837      data = 0xfe | centronics_busy_r(printer);
844      device = devtag_get_device(space->machine, "centronics");
845      data = 0xfe | centronics_busy_r(device);
838846      break;
839847
840848   case 0x20:
r6847r6848
845853   case 0x25:
846854   case 0x26:
847855   case 0x27:
848      data = ins8250_r(devtag_get_device(space->machine, "ins8250_0"), offset & 7);
856      device = devtag_get_device(space->machine, "ins8250_0");
857      data = ins8250_r(device, offset & 7);
849858      break;
850859
851860   case 0x28:
r6847r6848
856865   case 0x2D:
857866   case 0x2E:
858867   case 0x2F:
859      data = ins8250_r(devtag_get_device(space->machine, "ins8250_1"), offset & 7);
868      device = devtag_get_device(space->machine, "ins8250_1");
869      data = ins8250_r(device, offset & 7);
860870      break;
861871
862872   case 0x30:
863      data = wd17xx_status_r(fdc, 0);
873      device = devtag_get_device(space->machine, "wd179x");
874      data = wd17xx_status_r(device, 0);
864875      break;
865876   case 0x31:
866      data = wd17xx_track_r(fdc, 0);
877      device = devtag_get_device(space->machine, "wd179x");
878      data = wd17xx_track_r(device, 0);
867879      break;
868880   case 0x32:
869      data = wd17xx_sector_r(fdc, 0);
881      device = devtag_get_device(space->machine, "wd179x");
882      data = wd17xx_sector_r(device, 0);
870883      break;
871884   case 0x33:
872      data = wd17xx_data_r(fdc, 0);
885      device = devtag_get_device(space->machine, "wd179x");
886      data = wd17xx_data_r(device, 0);
873887      break;
874888   case 0x34:
875889      data = svi318_fdc_irqdrq_r(space, 0);
876890      break;
877   case 0x51: {
878      const device_config *devconf = devtag_get_device(space->machine, "crtc");
879      data = mc6845_register_r(devconf, 0);
880      }
891   case 0x51:
892      device = devtag_get_device(space->machine, "crtc");
893      data = mc6845_register_r(device, 0);
881894      break;
882895   }
883896
r6847r6848
886899
887900WRITE8_HANDLER( svi318_io_ext_w )
888901{
889   const device_config *fdc = devtag_get_device(space->machine, "wd179x");
890   const device_config *printer = devtag_get_device(space->machine, "centronics");
902   const device_config *device;
891903
892904   if (svi.bankLow == SVI_CART)
893905   {
r6847r6848
897909   switch( offset )
898910   {
899911   case 0x10:
900      centronics_data_w(printer, 0, data);
912      device = devtag_get_device(space->machine, "centronics");
913      centronics_data_w(device, 0, data);
901914      break;
902915
903916   case 0x11:
904      centronics_strobe_w(printer, BIT(data, 0));
917      device = devtag_get_device(space->machine, "centronics");
918      centronics_strobe_w(device, BIT(data, 0));
905919      break;
906920
907921   case 0x20:
r6847r6848
912926   case 0x25:
913927   case 0x26:
914928   case 0x27:
915      ins8250_w(devtag_get_device(space->machine, "ins8250_0"), offset & 7, data);
929      device = devtag_get_device(space->machine, "ins8250_0");
930      ins8250_w(device, offset & 7, data);
916931      break;
917932
918933   case 0x28:
r6847r6848
923938   case 0x2D:
924939   case 0x2E:
925940   case 0x2F:
926      ins8250_w(devtag_get_device(space->machine, "ins8250_1"), offset & 7, data);
941      device = devtag_get_device(space->machine, "ins8250_1");
942      ins8250_w(device, offset & 7, data);
927943      break;
928944
929945   case 0x30:
930      wd17xx_command_w(fdc, 0, data);
946      device = devtag_get_device(space->machine, "wd179x");
947      wd17xx_command_w(device, 0, data);
931948      break;
932949   case 0x31:
933      wd17xx_track_w(fdc, 0, data);
950      device = devtag_get_device(space->machine, "wd179x");
951      wd17xx_track_w(device, 0, data);
934952      break;
935953   case 0x32:
936      wd17xx_sector_w(fdc, 0, data);
954      device = devtag_get_device(space->machine, "wd179x");
955      wd17xx_sector_w(device, 0, data);
937956      break;
938957   case 0x33:
939      wd17xx_data_w(fdc, 0, data);
958      device = devtag_get_device(space->machine, "wd179x");
959      wd17xx_data_w(device, 0, data);
940960      break;
941961   case 0x34:
942962      svi318_fdc_drive_motor_w(space, 0, data);
r6847r6848
945965      svi318_fdc_density_side_w(space, 0, data);
946966      break;
947967
948   case 0x50: {
949      const device_config *devconf = devtag_get_device(space->machine, "crtc");
950      mc6845_address_w(devconf, 0, data);
951      }
968   case 0x50:
969      device = devtag_get_device(space->machine, "crtc");
970      mc6845_address_w(device, 0, data);
952971      break;
953   case 0x51: {
954      const device_config *devconf = devtag_get_device(space->machine, "crtc");
955      mc6845_register_w(devconf, 0, data);
956      }
972   case 0x51:
973      device = devtag_get_device(space->machine, "crtc");
974      mc6845_register_w(device, 0, data);
957975      break;
958976
959977   case 0x58:
src/mess/machine/compis.c
r6847r6848
811811      if (new_maxB == 0)
812812      {
813813               new_maxB = 0x10000;
814            }
814      }
815815      }
816816
817817
r6847r6848
884884            else
885885            {
886886              timer_adjust_oneshot(t->int_timer, attotime_never, which);
887      }
887            }
888888   }
889889}
890890
src/mess/machine/vtech2.c
r6847r6848
153153        "ROM lo","ROM hi","MM I/O","Video RAM lo",
154154        "RAM #0","RAM #1","RAM #2","RAM #3",
155155        "RAM #4","RAM #5","RAM #6","RAM #7/Video RAM hi",
156        "ext ROM #0","ext ROM #1","ext ROM #2","ext ROM #3"};
156        "ext ROM #0","ext ROM #1","ext ROM #2","ext ROM #3"
157    };
157158   char bank[10];
158159   offset %= 4;
159160    data &= 15;
src/mess/machine/msx.c
r6847r6848
374374 5+1,10+1,10+1,10+1,10+1,11+1, 7+1,11+1, 5+1,10+1,10+1, 0+1,10+1,17+1, 7+1,11+1,
375375 5+1,10+1,10+1,11+1,10+1,11+1, 7+1,11+1, 5+1, 4+1,10+1,11+1,10+1, 0+1, 7+1,11+1,
376376 5+1,10+1,10+1,19+1,10+1,11+1, 7+1,11+1, 5+1, 4+1,10+1, 4+1,10+1, 0+1, 7+1,11+1,
377 5+1,10+1,10+1, 4+1,10+1,11+1, 7+1,11+1, 5+1, 6+1,10+1, 4+1,10+1, 0+1, 7+1,11+1};
377 5+1,10+1,10+1, 4+1,10+1,11+1, 7+1,11+1, 5+1, 6+1,10+1, 4+1,10+1, 0+1, 7+1,11+1
378};
378379
379380static const UINT8 cc_cb[0x100] = {
380381 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
r6847r6848
392393 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
393394 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
394395 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2,
395 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2};
396 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,15+2, 8+2
397};
396398
397399static const UINT8 cc_ed[0x100] = {
398400 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
r6847r6848
410412 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
411413 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
412414 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2,
413 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2};
415 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2, 8+2
416};
414417
415418static const UINT8 cc_xy[0x100] = {
416419 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,15+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
r6847r6848
428431 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 0+2, 4+2, 4+2, 4+2, 4+2,
429432 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
430433 4+2,14+2, 4+2,23+2, 4+2,15+2, 4+2, 4+2, 4+2, 8+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,
431 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,10+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2};
434 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2,10+2, 4+2, 4+2, 4+2, 4+2, 4+2, 4+2
435};
432436
433437static const UINT8 cc_xycb[0x100] = {
43443823+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
r6847r6848
44645023+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
44745123+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
44845223+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,
44923+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2};
45323+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2,23+2
454};
450455
451456/* extra cycles if jr/jp/call taken and 'interrupt latency' on rst 0-7 */
452457static const UINT8 cc_ex[0x100] = {
r6847r6848
465470 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
466471 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
467472 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2,
468 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2+1};
473 6, 0, 0, 0, 7, 0, 0, 2, 6, 0, 0, 0, 7, 0, 0, 2+1
474};
469475
470476
471477DRIVER_INIT( msx )
r6847r6848
967973      return;
968974   }
969975
970   for (layout = msx1.layout; layout->entry != MSX_LAYOUT_LAST;
971               layout++) {
976   for (layout = msx1.layout; layout->entry != MSX_LAYOUT_LAST; layout++) {
972977
973978      if (layout->entry == MSX_LAYOUT_SLOT_ENTRY) {
974979
src/mess/machine/dc.c
r6847r6848
520520               break;
521521         }
522522      }
523    }
523   }
524524}
525525
526526static void dreamcast_atapi_exit(running_machine* machine)
src/mess/machine/ondra.c
r6847r6848
4242      retVal |= input_port_read(space->machine, keynames[ondra_keyboard_line]);
4343   }
4444   return retVal;
45 }
45}
4646
4747static void ondra_update_banks(running_machine *machine)
4848{
src/mess/machine/exidy.c
r6847r6848
312312     - tied high, allowing PARIN and PAROUT bios routines to run */
313313
314314   UINT8 data = 0xc0;
315   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
316                              "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15" };
315   static const char *const keynames[] = {
316      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
317      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15"
318   };
317319
318320   /* bit 5 - vsync (inverted) */
319321   data |= (((~input_port_read(space->machine, "VS")) & 0x01)<<5);
r6847r6848
363365
364366   if ((start_address == 0x1d5) || (execute_address == 0xc858))
365367   {
366      UINT8 i, data[]={
368      UINT8 i;
369      static const UINT8 data[]={
367370         0xcd, 0x26, 0xc4,   // CALL C426    ;set up other pointers
368371         0x21, 0xd4, 1,      // LD HL,01D4   ;start of program address (used by C689)
369372         0x36, 0,      // LD (HL),00   ;make sure dummy end-of-line is there
370         0xc3, 0x89, 0xc6,};   // JP C689  ;run program
373         0xc3, 0x89, 0xc6   // JP C689  ;run program
374      };
371375
372376      for (i = 0; i < ARRAY_LENGTH(data); i++)
373377         memory_write_byte(space, 0xf01f + i, data[i]);
src/mess/machine/pc8801.c
r6847r6848
599599  if(is_V2mode) pc88sr_is_highspeed=1;
600600  switch((is_Nbasic ? 1 : 0) |
601601    (is_V2mode ? 2 : 0) |
602    (pc88sr_is_highspeed ? 4 : 0)) {
602    (pc88sr_is_highspeed ? 4 : 0))
603  {
603604  case 0:
604605    logerror("N88-BASIC(V1-S)");
605606    break;
src/mess/machine/atom.c
r6847r6848
277277READ8_DEVICE_HANDLER ( atom_8255_portb_r )
278278{
279279   int row;
280   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5",
281                              "KEY6", "KEY7", "KEY8", "KEY9", "KEY10", "KEY11" };
280   static const char *const keynames[] = {
281      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5",
282      "KEY6", "KEY7", "KEY8", "KEY9", "KEY10", "KEY11"
283   };
282284
283285   row = atom_8255_porta & 0x0f;
284286   /* logerror("8255: Read port b: %02X %02X\n", input_port_read(machine, port),
src/mess/machine/hec2hrp.c
r6847r6848
140140 }
141141 j = 1;
142142 if (n==0x00) // Reset machine ! (on ESC key)
143  {
143 {
144144          cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE);
145145          if (!strncmp(machine->gamedrv->name , "hec2xxxx" , 4) |
146146              !strncmp(machine->gamedrv->name , "victor" , 6)     ) // aviable for all HR machines
r6847r6848
467467      AU[15] =  ((Value & 0x040 )==0) ? 0 : 1 ;
468468      break;
469469   }
470  case 0x3000:
470  case 0x3000:
471471   // Mixer modification
472472   {
473473      ValMixer = (Value & 7) ;
474474       break;
475    }
476    default: break;
475   }
476  default: break;
477477
478   } //switch
478 } //switch
479479}
480480
481481
src/mess/machine/special.c
r6847r6848
292292             wd17xx_set_drive(fdc,data & 1);
293293             break;
294294
295  }
295   }
296296}
297297
298298/*
r6847r6848
430430   else
431431   {
432432      wd17xx_set_density (fdc,DEN_FM_HI);
433  }
433   }
434434}
src/mess/machine/rmnimbus.c
r6847r6848
1/* 
2    machine/rmnimbus.c
3     
4    Machine driver for the Research Machines Nimbus.
5     
6    Phill Harvey-Smith
7    2009-11-29.
8     
9    80186 internal DMA/Timer/PIC code borrowed from Compis driver.
10    Perhaps this needs merging into the 80186 core.....
11*/
12 
13 
14#include "driver.h"
15#include "memory.h"
16#include "cpu/i86/i86.h"
17#include "debug/debugcpu.h"
18#include "debug/debugcon.h"
19#include "devices/flopdrv.h"
20#include "machine/pic8259.h"
21#include "machine/pit8253.h"
22#include "machine/msm8251.h"
23#include "machine/z80sio.h"
24 
25#include "includes/rmnimbus.h"
26 
27/*-------------------------------------------------------------------------*/
28/* Defines, constants, and global variables                                */
29/*-------------------------------------------------------------------------*/
30 
31/* CPU 80186 */
32#define LATCH_INTS          1
33#define LOG_PORTS           0
34#define LOG_INTERRUPTS      0
35#define LOG_INTERRUPTS_EXT  0
36#define LOG_TIMER           0
37#define LOG_OPTIMIZATION    0
38#define LOG_DMA             0
39#define CPU_RESUME_TRIGGER   7123
40#define LOG_KEYBOARD        0
41#define LOG_SIO             0
42#define LOG_DISK            0
43 
44/* 80186 internal stuff */
45struct mem_state
46{
47   UINT16       lower;
48   UINT16       upper;
49   UINT16       middle;
50   UINT16       middle_size;
51   UINT16       peripheral;
52};
53 
54struct timer_state
55{
56   UINT16       control;
57   UINT16       maxA;
58   UINT16       maxB;
59   UINT16       count;
60   emu_timer   *int_timer;
61   emu_timer   *time_timer;
62   UINT8       time_timer_active;
63   attotime   last_time;
64};
65 
66struct dma_state
67{
68   UINT32       source;
69   UINT32       dest;
70   UINT16       count;
71   UINT16       control;
72   UINT8       finished;
73   emu_timer   *finish_timer;
74};
75 
76struct intr_state
77{
78   UINT8   pending;
79   UINT16   ack_mask;
80   UINT16   priority_mask;
81   UINT16   in_service;
82   UINT16   request;
83   UINT16   status;
84   UINT16   poll_status;
85   UINT16   timer;
86   UINT16   dma[2];
87   UINT16   ext[4];
88    UINT16  ext_vector[2]; // external vectors, when in cascade mode
89};
90 
91static struct i186_state
92{
93   struct timer_state   timer[3];
94   struct dma_state   dma[2];
95   struct intr_state   intr;
96   struct mem_state   mem;
97} i186;
98 
99 
100/* Z80 SIO */
101 
102const z80sio_interface sio_intf =
103{
104   sio_interrupt,         /* interrupt handler */
105   0, //sio_dtr_w,            /* DTR changed handler */
106   0,                  /* RTS changed handler */
107   0,                  /* BREAK changed handler */
108   sio_serial_transmit,   /* transmit handler */
109   sio_serial_receive      /* receive handler */
110};
111 
112struct keybord_state
113{
114    UINT8       keyrows[NIMBUS_KEYROWS];
115    emu_timer   *keyscan_timer;
116    UINT8       queue[KEYBOARD_QUEUE_SIZE];
117   UINT8       head;
118   UINT8       tail;
119} keyboard;
120 
121 
122 
123/* Floppy drives WD2793 */
124 
125static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w );
126static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w );
127 
128const wd17xx_interface nimbus_wd17xx_interface =
129{
130   DEVCB_LINE(nimbus_fdc_intrq_w),
131   DEVCB_LINE(nimbus_fdc_drq_w),
132   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
133};
134 
135static struct _nimbus_fdc
136{
137    UINT8 drq_enabled;
138    UINT8 irq_enabled;
139    UINT8 diskno;
140    UINT8 motor_on;
141} nimbus_fdc;
142 
143 
144static void drq_callback(running_machine *machine, int which);
145 
146static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[]);
147static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[]);
148 
149static int instruction_hook(const device_config *device, offs_t curpc);
150static void decode_subbios(const device_config *device,offs_t pc);
151static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si);
152static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si);
153static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si);
154static void decode_dssi_f_plonk_char(const device_config *device,UINT16  ds, UINT16 si);
155 
156static void fdc_reset(void);
157 
158static void keyboard_reset(void);
159static TIMER_CALLBACK(keyscan_callback);
160 
161#define num_ioports 0x80
162static UINT16   IOPorts[num_ioports];
163 
164UINT8 nextkey;
165UINT8 sio_int_state;
166 
167/*************************************
168 *
169 *  80186 interrupt controller
170 *
171 *************************************/
172static IRQ_CALLBACK(int_callback)
173{
174    UINT8   vector;
175    UINT16  old;
176    UINT16  oldreq;
177 
178   if (LOG_INTERRUPTS)
179      logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time(device->machine)), i186.intr.poll_status & 0x1f);
180 
181   /* clear the interrupt */
182   cpu_set_input_line(device, 0, CLEAR_LINE);
183   i186.intr.pending = 0;
184 
185    oldreq=i186.intr.request;
186 
187   /* clear the request and set the in-service bit */
188#if LATCH_INTS
189   i186.intr.request &= ~i186.intr.ack_mask;
190#else
191   i186.intr.request &= ~(i186.intr.ack_mask & 0x0f);
192#endif
193 
194   if((LOG_INTERRUPTS) && (i186.intr.request!=oldreq))
195        logerror("i186.intr.request changed from %02X to %02X\n",oldreq,i186.intr.request);
196 
197    old=i186.intr.in_service;
198 
199   i186.intr.in_service |= i186.intr.ack_mask;
200   
201    if((LOG_INTERRUPTS) && (i186.intr.in_service!=old))
202        logerror("i186.intr.in_service changed from %02X to %02X\n",old,i186.intr.in_service);
203     
204    if (i186.intr.ack_mask == 0x0001)
205   {
206      switch (i186.intr.poll_status & 0x1f)
207      {
208         case 0x08:   i186.intr.status &= ~0x01;   break;
209         case 0x12:   i186.intr.status &= ~0x02;   break;
210         case 0x13:   i186.intr.status &= ~0x04;   break;
211      }
212   }
213   i186.intr.ack_mask = 0;
214 
215   /* a request no longer pending */
216   i186.intr.poll_status &= ~0x8000;
217 
218   /* return the vector */
219    switch(i186.intr.poll_status & 0x1F)
220    {
221        case 0x0C   : vector=(i186.intr.ext[0] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[0] : (i186.intr.poll_status & 0x1f); break;
222        case 0x0D   : vector=(i186.intr.ext[1] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[1] : (i186.intr.poll_status & 0x1f); break;
223        default :
224            vector=i186.intr.poll_status & 0x1f; break;
225    }
226 
227    if (LOG_INTERRUPTS_EXT)
228   {
229        logerror("i186.intr.ext[0]=%04X i186.intr.ext[1]=%04X\n",i186.intr.ext[0],i186.intr.ext[1]);
230        logerror("Ext vectors : %02X %02X\n",i186.intr.ext_vector[0],i186.intr.ext_vector[1]);
231        logerror("Int %02X Calling vector %02X\n",i186.intr.poll_status,vector);
232    }
233     
234    return vector;
235}
236 
237 
238static void update_interrupt_state(running_machine *machine)
239{   
240    int new_vector = 0;
241    int Priority;
242    int IntNo;
243 
244   if (LOG_INTERRUPTS) 
245        logerror("update_interrupt_status: req=%04X stat=%04X serv=%04X priority_mask=%4X\n", i186.intr.request, i186.intr.status, i186.intr.in_service, i186.intr.priority_mask);
246 
247   /* loop over priorities */
248   for (Priority = 0; Priority <= i186.intr.priority_mask; Priority++)
249   {
250      /* note: by checking 4 bits, we also verify that the mask is off */
251      if ((i186.intr.timer & 15) == Priority)
252      {
253         /* if we're already servicing something at this level, don't generate anything new */
254         if (i186.intr.in_service & 0x01)
255            return;
256 
257         /* if there's something pending, generate an interrupt */
258         if (i186.intr.status & 0x07)
259         {
260            if (i186.intr.status & 1)
261               new_vector = 0x08;
262            else if (i186.intr.status & 2)
263               new_vector = 0x12;
264            else if (i186.intr.status & 4)
265               new_vector = 0x13;
266            else
267               popmessage("Invalid timer interrupt!");
268 
269            /* set the clear mask and generate the int */
270            i186.intr.ack_mask = 0x0001;
271            goto generate_int;
272         }
273      }
274 
275      /* check DMA interrupts */
276      for (IntNo = 0; IntNo < 2; IntNo++)
277         if ((i186.intr.dma[IntNo] & 0x0F) == Priority)
278         {
279            /* if we're already servicing something at this level, don't generate anything new */
280            if (i186.intr.in_service & (0x04 << IntNo))
281               return;
282 
283            /* if there's something pending, generate an interrupt */
284            if (i186.intr.request & (0x04 << IntNo))
285            {
286               new_vector = 0x0a + IntNo;
287 
288               /* set the clear mask and generate the int */
289               i186.intr.ack_mask = 0x0004 << IntNo;
290               goto generate_int;
291            }
292         }
293 
294        //logerror("Checking external ints\n");
295      /* check external interrupts */
296      for (IntNo = 0; IntNo < 4; IntNo++)
297         if ((i186.intr.ext[IntNo] & 0x0F) == Priority)
298         {
299                if (LOG_INTERRUPTS)
300                    logerror("Int%d priority=%d\n",IntNo,Priority);
301                 
302                /* if we're already servicing something at this level, don't generate anything new */
303            if (i186.intr.in_service & (0x10 << IntNo))
304               return;
305 
306            /* if there's something pending, generate an interrupt */
307            if (i186.intr.request & (0x10 << IntNo))
308            {
309               /* otherwise, generate an interrupt for this request */
310               new_vector = 0x0c + IntNo;
311 
312               /* set the clear mask and generate the int */
313               i186.intr.ack_mask = 0x0010 << IntNo;
314                    goto generate_int;
315            }
316         }
317   }
318   return;
319 
320generate_int:
321   /* generate the appropriate interrupt */
322   i186.intr.poll_status = 0x8000 | new_vector;
323   if (!i186.intr.pending)
324      cputag_set_input_line(machine, MAINCPU_TAG, 0, ASSERT_LINE);
325   i186.intr.pending = 1;
326   cpuexec_trigger(machine, CPU_RESUME_TRIGGER);
327   if (LOG_OPTIMIZATION) logerror("  - trigger due to interrupt pending\n");
328   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time(machine)), new_vector);
329}
330 
331 
332static void handle_eoi(running_machine *machine,int data)
333{
334    int Priority;
335    int IntNo;
336 
337   /* specific case */
338   if (!(data & 0x8000))
339   {
340      /* turn off the appropriate in-service bit */
341      switch (data & 0x1f)
342      {
343         case 0x08:   i186.intr.in_service &= ~0x01;   break;
344         case 0x12:   i186.intr.in_service &= ~0x01;   break;
345         case 0x13:   i186.intr.in_service &= ~0x01;   break;
346         case 0x0a:   i186.intr.in_service &= ~0x04;   break;
347         case 0x0b:   i186.intr.in_service &= ~0x08;   break;
348         case 0x0c:   i186.intr.in_service &= ~0x10;   break;
349         case 0x0d:   i186.intr.in_service &= ~0x20;   break;
350         case 0x0e:   i186.intr.in_service &= ~0x40;   break;
351         case 0x0f:   i186.intr.in_service &= ~0x80;   break;
352         default:   logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), data & 0x1f);
353      }
354      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time(machine)), data & 0x1f);
355   }
356 
357   /* non-specific case */
358   else
359   {
360      /* loop over priorities */
361      for (Priority = 0; Priority <= 7; Priority++)
362      {
363         /* check for in-service timers */
364         if ((i186.intr.timer & 0x07) == Priority && (i186.intr.in_service & 0x01))
365         {
366            i186.intr.in_service &= ~0x01;
367            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time(machine)));
368            return;
369         }
370 
371         /* check for in-service DMA interrupts */
372         for (IntNo = 0; IntNo < 2; IntNo++)
373            if ((i186.intr.dma[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x04 << IntNo)))
374            {
375               i186.intr.in_service &= ~(0x04 << IntNo);
376               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
377               return;
378            }
379 
380         /* check external interrupts */
381         for (IntNo = 0; IntNo < 4; IntNo++)
382            if ((i186.intr.ext[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x10 << IntNo)))
383            {
384               i186.intr.in_service &= ~(0x10 << IntNo);
385               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
386               return;
387            }
388      }
389   }
390}
391 
392/* Trigger an external interupt, optionally supplying the vector to take */
393static void external_int(running_machine *machine, UINT16 intno, UINT8 vector)
394{
395   if (LOG_INTERRUPTS_EXT) logerror("generating external int %02X, vector %02X\n",intno,vector);
396 
397   // Only 4 external ints
398    if(intno>3)
399    {
400        logerror("external_int() invalid external interupt no : 0x%02X (can only be 0..3)\n",intno);
401        return;
402    }
403     
404    // Only set external vector if cascade mode enabled, only valid for
405    // int 0 & int 1
406    if (intno<2)
407    {
408        if(i186.intr.ext[intno] & EXTINT_CTRL_CASCADE)
409            i186.intr.ext_vector[intno]=vector;
410    }
411     
412    // Turn on the requested request bit and handle interrupt
413    i186.intr.request |= (0x010 << intno);
414    update_interrupt_state(machine);
415}
416 
417 
418/*************************************
419 *
420 *  80186 internal timers
421 *
422 *************************************/
423 
424static TIMER_CALLBACK(internal_timer_int)
425{
426   int which = param;
427   struct timer_state *t = &i186.timer[which];
428 
429   if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which);
430 
431   /* set the max count bit */
432   t->control |= 0x0020;
433 
434   /* request an interrupt */
435   if (t->control & 0x2000)
436   {
437      i186.intr.status |= 0x01 << which;
438      update_interrupt_state(machine);
439      if (LOG_TIMER) logerror("  Generating timer interrupt\n");
440   }
441 
442   /* if we're continuous, reset */
443   if (t->control & 0x0001)
444   {
445      int count = t->maxA ? t->maxA : 0x10000;
446      timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which);
447      if (LOG_TIMER) logerror("  Repriming interrupt\n");
448   }
449   else
450      timer_adjust_oneshot(t->int_timer, attotime_never, which);
451}
452 
453 
454static void internal_timer_sync(int which)
455{
456   struct timer_state *t = &i186.timer[which];
457 
458   /* if we have a timing timer running, adjust the count */
459   if (t->time_timer_active)
460   {
461      attotime current_time = timer_timeelapsed(t->time_timer);
462      int net_clocks = attotime_mul(attotime_sub(current_time, t->last_time),  2000000).seconds;
463      t->last_time = current_time;
464 
465      /* set the max count bit if we passed the max */
466      if ((int)t->count + net_clocks >= t->maxA)
467         t->control |= 0x0020;
468 
469      /* set the new count */
470      if (t->maxA != 0)
471         t->count = (t->count + net_clocks) % t->maxA;
472      else
473         t->count = t->count + net_clocks;
474   }
475}
476 
477 
478static void internal_timer_update(running_machine *machine,
479                          int which,
480                                  int new_count,
481                                  int new_maxA,
482                                  int new_maxB,
483                                  int new_control)
484{
485   struct timer_state *t = &i186.timer[which];
486   int update_int_timer = 0;
487 
488    if (LOG_TIMER) 
489        logerror("internal_timer_update: %d, new_count=%d, new_maxA=%d, new_maxB=%d,new_control=%d\n",which,new_count,new_maxA,new_maxB,new_control);
490 
491   /* if we have a new count and we're on, update things */
492   if (new_count != -1)
493   {
494      if (t->control & 0x8000)
495      {
496         internal_timer_sync(which);
497         update_int_timer = 1;
498      }
499      t->count = new_count;
500   }
501 
502   /* if we have a new max and we're on, update things */
503   if (new_maxA != -1 && new_maxA != t->maxA)
504   {
505      if (t->control & 0x8000)
506      {
507         internal_timer_sync(which);
508         update_int_timer = 1;
509      }
510      t->maxA = new_maxA;
511      if (new_maxA == 0)
512      {
513               new_maxA = 0x10000;
514      }
515   }
516 
517   /* if we have a new max and we're on, update things */
518   if (new_maxB != -1 && new_maxB != t->maxB)
519   {
520      if (t->control & 0x8000)
521      {
522         internal_timer_sync(which);
523         update_int_timer = 1;
524      }
525 
526      t->maxB = new_maxB;
527 
528      if (new_maxB == 0)
529      {
530               new_maxB = 0x10000;
531            }
532      }
533     
534 
535   /* handle control changes */
536   if (new_control != -1)
537   {
538      int diff;
539 
540      /* merge back in the bits we don't modify */
541      new_control = (new_control & ~0x1fc0) | (t->control & 0x1fc0);
542 
543      /* handle the /INH bit */
544      if (!(new_control & 0x4000))
545         new_control = (new_control & ~0x8000) | (t->control & 0x8000);
546      new_control &= ~0x4000;
547 
548      /* check for control bits we don't handle */
549      diff = new_control ^ t->control;
550      if (diff & 0x001c)
551        logerror("%05X:ERROR! -unsupported timer mode %04X\n",
552            cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
553 
554      /* if we have real changes, update things */
555      if (diff != 0)
556      {
557 
558         /* if we're going off, make sure our timers are gone */
559         if ((diff & 0x8000) && !(new_control & 0x8000))
560         {
561            /* compute the final count */
562            internal_timer_sync(which);
563 
564            /* nuke the timer and force the interrupt timer to be recomputed */
565            timer_adjust_oneshot(t->time_timer, attotime_never, which);
566            t->time_timer_active = 0;
567            update_int_timer = 1;
568         }
569 
570         /* if we're going on, start the timers running */
571         else if ((diff & 0x8000) && (new_control & 0x8000))
572         {
573            /* start the timing */
574            timer_adjust_oneshot(t->time_timer, attotime_never, which);
575            t->time_timer_active = 1;
576            update_int_timer = 1;
577         }
578 
579         /* if something about the interrupt timer changed, force an update */
580         if (!(diff & 0x8000) && (diff & 0x2000))
581         {
582            internal_timer_sync(which);
583            update_int_timer = 1;
584         }
585      }
586 
587      /* set the new control register */
588      t->control = new_control;
589   }
590 
591   /* update the interrupt timer */
592      if (update_int_timer)
593      {
594            if ((t->control & 0x8000) && (t->control & 0x2000))
595            {
596              int diff = t->maxA - t->count;
597               if (diff <= 0)
598                  diff += 0x10000;
599               timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which);
600               if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which);
601            }
602            else
603            {
604              timer_adjust_oneshot(t->int_timer, attotime_never, which);
605      }
606   }
607}
608 
609 
610 
611/*************************************
612 *
613 *  80186 internal DMA
614 *
615 *************************************/
616 
617static TIMER_CALLBACK(dma_timer_callback)
618{
619   int which = param;
620   struct dma_state *d = &i186.dma[which];
621 
622   /* force an update and see if we're really done */
623   //stream_update(dma_stream, 0);
624 
625   /* complete the status update */
626   d->control &= ~0x0002;
627   d->source += d->count;
628   d->count = 0;
629 
630   /* check for interrupt generation */
631   if (d->control & 0x0100)
632   {
633      if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source);
634      i186.intr.request |= 0x04 << which;
635      update_interrupt_state(machine);
636   }
637}
638 
639 
640static void update_dma_control(running_machine *machine, int which, int new_control)
641{
642   struct dma_state *d = &i186.dma[which];
643   int diff;
644 
645   /* handle the CHG bit */
646   if (!(new_control & CHG_NOCHG))
647     new_control = (new_control & ~ST_STOP) | (d->control & ST_STOP);
648   new_control &= ~CHG_NOCHG;
649 
650   /* check for control bits we don't handle */
651   diff = new_control ^ d->control;
652   if ((LOG_DMA) && (diff & 0x6811))
653     logerror("%05X:ERROR! - unsupported DMA mode %04X\n",
654         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
655 
656   /* if we're going live, set a timer */
657   if ((diff & 0x0002) && (new_control & 0x0002))
658   {
659      /* make sure the parameters meet our expectations */
660      if ((new_control & 0xfe00) != 0x1600)
661      {
662         if (LOG_DMA) logerror("Unexpected DMA control %02X\n", new_control);
663      }
664      else if (/*!is_redline &&*/ ((d->dest & 1) || (d->dest & 0x3f) > 0x0b))
665      {
666         if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest);
667      }
668      else if (/*is_redline && */ (d->dest & 0xf000) != 0x4000 && (d->dest & 0xf000) != 0x5000)
669      {
670         if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest);
671      }
672 
673      /* otherwise, set a timer */
674      else
675      {
676//          int count = d->count;
677 
678         /* adjust for redline racer */
679            // int dacnum = (d->dest & 0x3f) / 2;
680 
681         if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
682 
683         d->finished = 0;
684/*          timer_adjust_oneshot(d->finish_timer,
685         ATTOTIME_IN_HZ(dac[dacnum].frequency) * (double)count, which);*/
686      }
687   }
688 
689   /* set the new control register */
690   d->control = new_control;
691}
692 
693static void drq_callback(running_machine *machine, int which)
694{
695    struct dma_state *dma = &i186.dma[which];
696   const address_space *memory_space   = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_PROGRAM);
697    const address_space *io_space       = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_IO);
698     
699    const address_space *src_space;
700    const address_space *dest_space;
701     
702    UINT16  dma_word;
703    UINT8   dma_byte;
704    UINT8   incdec_size;
705 
706    if (LOG_DMA)
707        logerror("Control=%04X, src=%05X, dest=%05X, count=%04X\n",dma->control,dma->source,dma->dest,dma->count);
708 
709    if(!(dma->control & ST_STOP))
710    {
711        logerror("%05X:ERROR! - drq%d with dma channel stopped\n",
712         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), which);
713           
714        return;
715    }
716 
717    if(dma->control & DEST_MIO)
718        dest_space=memory_space;
719    else
720        dest_space=io_space;
721     
722    if(dma->control & SRC_MIO)
723        src_space=memory_space;
724    else
725        src_space=io_space;
726     
727    // Do the transfer
728    if(dma->control & BYTE_WORD)
729    {
730        dma_word=memory_read_word(src_space,dma->source);
731        memory_write_word(dest_space,dma->dest,dma_word);
732        incdec_size=2;
733    }
734    else
735    {
736        dma_byte=memory_read_byte(src_space,dma->source);
737        memory_write_byte(dest_space,dma->dest,dma_byte);
738        incdec_size=1;
739    }
740     
741    // Increment or Decrement destination ans source pointers as needed
742    switch (dma->control & DEST_INCDEC_MASK)
743    {
744        case DEST_DECREMENT     : dma->dest -= incdec_size;
745        case DEST_INCREMENT     : dma->dest += incdec_size;
746    }
747     
748    switch (dma->control & SRC_INCDEC_MASK)
749    {
750        case SRC_DECREMENT     : dma->source -= incdec_size;
751        case SRC_INCREMENT     : dma->source += incdec_size;
752    }
753     
754    // decrement count
755    dma->count -= 1;
756     
757    // Terminate if count is zero, and terminate flag set
758    if((dma->control & TERMINATE_ON_ZERO) && (dma->count==0))
759    {
760        dma->control &= ~ST_STOP;
761        if (LOG_DMA) logerror("DMA terminated\n");
762    }
763     
764    // Interrupt if count is zero, and interrupt flag set
765    if((dma->control & INTERRUPT_ON_ZERO) && (dma->count==0))
766    {
767      if (LOG_DMA) logerror("DMA%d - requesting interrupt: count = %04X, source = %04X\n", which, dma->count, dma->source);
768      i186.intr.request |= 0x04 << which;
769      update_interrupt_state(machine);       
770    }
771}
772 
773/*-------------------------------------------------------------------------*/
774/* Name: rmnimbus                                                            */
775/* Desc: CPU - Initialize the 80186 CPU                                    */
776/*-------------------------------------------------------------------------*/
777static void nimbus_cpu_init(running_machine *machine)
778{
779 
780    logerror("Machine reset\n");
781     
782   /* create timers here so they stick around */
783   i186.timer[0].int_timer = timer_alloc(machine, internal_timer_int, NULL);
784   i186.timer[1].int_timer = timer_alloc(machine, internal_timer_int, NULL);
785   i186.timer[2].int_timer = timer_alloc(machine, internal_timer_int, NULL);
786   i186.timer[0].time_timer = timer_alloc(machine, NULL, NULL);
787   i186.timer[1].time_timer = timer_alloc(machine, NULL, NULL);
788   i186.timer[2].time_timer = timer_alloc(machine, NULL, NULL);
789   i186.dma[0].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
790   i186.dma[1].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
791}
792 
793static void nimbus_cpu_reset(running_machine *machine)
794{
795      /* reset the interrupt state */
796   i186.intr.priority_mask       = 0x0007;
797   i186.intr.timer          = 0x000f;
798   i186.intr.dma[0]         = 0x000f;
799   i186.intr.dma[1]         = 0x000f;
800   i186.intr.ext[0]         = 0x000f;
801   i186.intr.ext[1]         = 0x000f;
802   i186.intr.ext[2]         = 0x000f;
803   i186.intr.ext[3]         = 0x000f;
804    i186.intr.in_service        = 0x0000;
805     
806    /* External vectors by default to internal int 0/1 vectors */
807    i186.intr.ext_vector[0]      = 0x000C;
808   i186.intr.ext_vector[1]      = 0x000D;
809   
810    i186.intr.pending           = 0x0000;
811   i186.intr.ack_mask          = 0x0000;
812   i186.intr.request           = 0x0000;
813   i186.intr.status            = 0x0000;
814   i186.intr.poll_status       = 0x0000;
815   
816    logerror("CPU reset done\n");
817}
818 
819READ16_HANDLER( i186_internal_port_r )
820{
821   int temp, which;
822 
823   switch (offset)
824   {
825      case 0x11:
826         logerror("%05X:ERROR - read from 80186 EOI\n", cpu_get_pc(space->cpu));
827         break;
828 
829      case 0x12:
830         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll\n", cpu_get_pc(space->cpu));
831         if (i186.intr.poll_status & 0x8000)
832            int_callback(cputag_get_cpu(space->machine, MAINCPU_TAG), 0);
833         return i186.intr.poll_status;
834 
835      case 0x13:
836         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll status\n", cpu_get_pc(space->cpu));
837         return i186.intr.poll_status;
838 
839      case 0x14:
840         if (LOG_PORTS) logerror("%05X:read 80186 interrupt mask\n", cpu_get_pc(space->cpu));
841         temp  = (i186.intr.timer  >> 3) & 0x01;
842         temp |= (i186.intr.dma[0] >> 1) & 0x04;
843         temp |= (i186.intr.dma[1] >> 0) & 0x08;
844         temp |= (i186.intr.ext[0] << 1) & 0x10;
845         temp |= (i186.intr.ext[1] << 2) & 0x20;
846         temp |= (i186.intr.ext[2] << 3) & 0x40;
847         temp |= (i186.intr.ext[3] << 4) & 0x80;
848         return temp;
849 
850      case 0x15:
851         if (LOG_PORTS) logerror("%05X:read 80186 interrupt priority mask\n", cpu_get_pc(space->cpu));
852         return i186.intr.priority_mask;
853 
854      case 0x16:
855         if (LOG_PORTS) logerror("%05X:read 80186 interrupt in-service\n", cpu_get_pc(space->cpu));
856         return i186.intr.in_service;
857 
858      case 0x17:
859         if (LOG_PORTS) logerror("%05X:read 80186 interrupt request\n", cpu_get_pc(space->cpu));
860         temp = i186.intr.request & ~0x0001;
861         if (i186.intr.status & 0x0007)
862            temp |= 1;
863         return temp;
864 
865      case 0x18:
866         if (LOG_PORTS) logerror("%05X:read 80186 interrupt status\n", cpu_get_pc(space->cpu));
867         return i186.intr.status;
868 
869      case 0x19:
870         if (LOG_PORTS) logerror("%05X:read 80186 timer interrupt control\n", cpu_get_pc(space->cpu));
871         return i186.intr.timer;
872 
873      case 0x1a:
874         if (LOG_PORTS) logerror("%05X:read 80186 DMA 0 interrupt control\n", cpu_get_pc(space->cpu));
875         return i186.intr.dma[0];
876 
877      case 0x1b:
878         if (LOG_PORTS) logerror("%05X:read 80186 DMA 1 interrupt control\n", cpu_get_pc(space->cpu));
879         return i186.intr.dma[1];
880 
881      case 0x1c:
882         if (LOG_PORTS) logerror("%05X:read 80186 INT 0 interrupt control\n", cpu_get_pc(space->cpu));
883         return i186.intr.ext[0];
884 
885      case 0x1d:
886         if (LOG_PORTS) logerror("%05X:read 80186 INT 1 interrupt control\n", cpu_get_pc(space->cpu));
887         return i186.intr.ext[1];
888 
889      case 0x1e:
890         if (LOG_PORTS) logerror("%05X:read 80186 INT 2 interrupt control\n", cpu_get_pc(space->cpu));
891         return i186.intr.ext[2];
892 
893      case 0x1f:
894         if (LOG_PORTS) logerror("%05X:read 80186 INT 3 interrupt control\n", cpu_get_pc(space->cpu));
895         return i186.intr.ext[3];
896 
897      case 0x28:
898      case 0x2c:
899      case 0x30:
900         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d count\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4);
901         which = (offset - 0x28) / 4;
902         if (!(offset & 1))
903            internal_timer_sync(which);
904         return i186.timer[which].count;
905 
906      case 0x29:
907      case 0x2d:
908      case 0x31:
909         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d max A\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4);
910         which = (offset - 0x29) / 4;
911         return i186.timer[which].maxA;
912 
913      case 0x2a:
914      case 0x2e:
915         logerror("%05X:read 80186 Timer %d max B\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4);
916         which = (offset - 0x2a) / 4;
917         return i186.timer[which].maxB;
918 
919      case 0x2b:
920      case 0x2f:
921      case 0x33:
922         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d control\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4);
923         which = (offset - 0x2b) / 4;
924         return i186.timer[which].control;
925 
926      case 0x50:
927         if (LOG_PORTS) logerror("%05X:read 80186 upper chip select\n", cpu_get_pc(space->cpu));
928         return i186.mem.upper;
929 
930      case 0x51:
931         if (LOG_PORTS) logerror("%05X:read 80186 lower chip select\n", cpu_get_pc(space->cpu));
932         return i186.mem.lower;
933 
934      case 0x52:
935         if (LOG_PORTS) logerror("%05X:read 80186 peripheral chip select\n", cpu_get_pc(space->cpu));
936         return i186.mem.peripheral;
937 
938      case 0x53:
939         if (LOG_PORTS) logerror("%05X:read 80186 middle chip select\n", cpu_get_pc(space->cpu));
940         return i186.mem.middle;
941 
942      case 0x54:
943         if (LOG_PORTS) logerror("%05X:read 80186 middle P chip select\n", cpu_get_pc(space->cpu));
944         return i186.mem.middle_size;
945 
946      case 0x60:
947      case 0x68:
948         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower source address\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8);
949         which = (offset - 0x60) / 8;
950//          stream_update(dma_stream, 0);
951         return i186.dma[which].source;
952 
953      case 0x61:
954      case 0x69:
955         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper source address\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8);
956         which = (offset - 0x61) / 8;
957//          stream_update(dma_stream, 0);
958         return i186.dma[which].source >> 16;
959 
960      case 0x62:
961      case 0x6a:
962         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower dest address\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8);
963         which = (offset - 0x62) / 8;
964//          stream_update(dma_stream, 0);
965         return i186.dma[which].dest;
966 
967      case 0x63:
968      case 0x6b:
969         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper dest address\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8);
970         which = (offset - 0x63) / 8;
971//          stream_update(dma_stream, 0);
972         return i186.dma[which].dest >> 16;
973 
974      case 0x64:
975      case 0x6c:
976         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d transfer count\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8);
977         which = (offset - 0x64) / 8;
978//          stream_update(dma_stream, 0);
979         return i186.dma[which].count;
980 
981      case 0x65:
982      case 0x6d:
983         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d control\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8);
984         which = (offset - 0x65) / 8;
985//          stream_update(dma_stream, 0);
986         return i186.dma[which].control;
987 
988      default:
989         logerror("%05X:read 80186 port %02X\n", cpu_get_pc(space->cpu), offset);
990         break;
991   }
992   return 0x00;
993}
994 
995/*************************************
996 *
997 *  80186 internal I/O writes
998 *
999 *************************************/
1000 
1001WRITE16_HANDLER( i186_internal_port_w )
1002{
1003   int temp, which, data16 = data;
1004 
1005   switch (offset)
1006   {
1007      case 0x11:
1008         if (LOG_PORTS) logerror("%05X:80186 EOI = %04X\n", cpu_get_pc(space->cpu), data16);
1009         handle_eoi(space->machine,0x8000);
1010         update_interrupt_state(space->machine);
1011         break;
1012 
1013      case 0x12:
1014         logerror("%05X:ERROR - write to 80186 interrupt poll = %04X\n", cpu_get_pc(space->cpu), data16);
1015         break;
1016 
1017      case 0x13:
1018         logerror("%05X:ERROR - write to 80186 interrupt poll status = %04X\n", cpu_get_pc(space->cpu), data16);
1019         break;
1020 
1021      case 0x14:
1022         if (LOG_PORTS) logerror("%05X:80186 interrupt mask = %04X\n", cpu_get_pc(space->cpu), data16);
1023         i186.intr.timer  = (i186.intr.timer  & ~0x08) | ((data16 << 3) & 0x08);
1024         i186.intr.dma[0] = (i186.intr.dma[0] & ~0x08) | ((data16 << 1) & 0x08);
1025         i186.intr.dma[1] = (i186.intr.dma[1] & ~0x08) | ((data16 << 0) & 0x08);
1026         i186.intr.ext[0] = (i186.intr.ext[0] & ~0x08) | ((data16 >> 1) & 0x08);
1027         i186.intr.ext[1] = (i186.intr.ext[1] & ~0x08) | ((data16 >> 2) & 0x08);
1028         i186.intr.ext[2] = (i186.intr.ext[2] & ~0x08) | ((data16 >> 3) & 0x08);
1029         i186.intr.ext[3] = (i186.intr.ext[3] & ~0x08) | ((data16 >> 4) & 0x08);
1030         update_interrupt_state(space->machine);
1031         break;
1032 
1033      case 0x15:
1034         if (LOG_PORTS) logerror("%05X:80186 interrupt priority mask = %04X\n", cpu_get_pc(space->cpu), data16);
1035         i186.intr.priority_mask = data16 & 0x0007;
1036         update_interrupt_state(space->machine);
1037         break;
1038 
1039      case 0x16:
1040         if (LOG_PORTS) logerror("%05X:80186 interrupt in-service = %04X\n", cpu_get_pc(space->cpu), data16);
1041         i186.intr.in_service = data16 & 0x00ff;
1042         update_interrupt_state(space->machine);
1043         break;
1044 
1045      case 0x17:
1046         if (LOG_PORTS) logerror("%05X:80186 interrupt request = %04X\n", cpu_get_pc(space->cpu), data16);
1047         i186.intr.request = (i186.intr.request & ~0x00c0) | (data16 & 0x00c0);
1048         update_interrupt_state(space->machine);
1049         break;
1050 
1051      case 0x18:
1052         if (LOG_PORTS) logerror("%05X:WARNING - wrote to 80186 interrupt status = %04X\n", cpu_get_pc(space->cpu), data16);
1053         i186.intr.status = (i186.intr.status & ~0x8007) | (data16 & 0x8007);
1054         update_interrupt_state(space->machine);
1055         break;
1056 
1057      case 0x19:
1058         if (LOG_PORTS) logerror("%05X:80186 timer interrupt contol = %04X\n", cpu_get_pc(space->cpu), data16);
1059         i186.intr.timer = data16 & 0x000f;
1060         break;
1061 
1062      case 0x1a:
1063         if (LOG_PORTS) logerror("%05X:80186 DMA 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1064         i186.intr.dma[0] = data16 & 0x000f;
1065         break;
1066 
1067      case 0x1b:
1068         if (LOG_PORTS) logerror("%05X:80186 DMA 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1069         i186.intr.dma[1] = data16 & 0x000f;
1070         break;
1071 
1072      case 0x1c:
1073         if (LOG_PORTS) logerror("%05X:80186 INT 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1074         i186.intr.ext[0] = data16 & 0x007f;
1075         break;
1076 
1077      case 0x1d:
1078         if (LOG_PORTS) logerror("%05X:80186 INT 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1079         i186.intr.ext[1] = data16 & 0x007f;
1080         break;
1081 
1082      case 0x1e:
1083         if (LOG_PORTS) logerror("%05X:80186 INT 2 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1084         i186.intr.ext[2] = data16 & 0x001f;
1085         break;
1086 
1087      case 0x1f:
1088         if (LOG_PORTS) logerror("%05X:80186 INT 3 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1089         i186.intr.ext[3] = data16 & 0x001f;
1090         break;
1091 
1092      case 0x28:
1093      case 0x2c:
1094      case 0x30:
1095         if (LOG_PORTS) logerror("%05X:80186 Timer %d count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4, data16);
1096         which = (offset - 0x28) / 4;
1097         internal_timer_update(space->machine,which, data16, -1, -1, -1);
1098         break;
1099 
1100      case 0x29:
1101      case 0x2d:
1102      case 0x31:
1103         if (LOG_PORTS) logerror("%05X:80186 Timer %d max A = %04X\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4, data16);
1104         which = (offset - 0x29) / 4;
1105         internal_timer_update(space->machine,which, -1, data16, -1, -1);
1106         break;
1107 
1108      case 0x2a:
1109      case 0x2e:
1110         if (LOG_PORTS) logerror("%05X:80186 Timer %d max B = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4, data16);
1111         which = (offset - 0x2a) / 4;
1112         internal_timer_update(space->machine,which, -1, -1, data16, -1);
1113         break;
1114 
1115      case 0x2b:
1116      case 0x2f:
1117      case 0x33:
1118         if (LOG_PORTS) logerror("%05X:80186 Timer %d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4, data16);
1119         which = (offset - 0x2b) / 4;
1120         internal_timer_update(space->machine,which, -1, -1, -1, data16);
1121         break;
1122 
1123      case 0x50:
1124         if (LOG_PORTS) logerror("%05X:80186 upper chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1125         i186.mem.upper = data16 | 0xc038;
1126         break;
1127 
1128      case 0x51:
1129         if (LOG_PORTS) logerror("%05X:80186 lower chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1130         i186.mem.lower = (data16 & 0x3fff) | 0x0038; printf("%X",i186.mem.lower);
1131         break;
1132 
1133      case 0x52:
1134         if (LOG_PORTS) logerror("%05X:80186 peripheral chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1135         i186.mem.peripheral = data16 | 0x0038;
1136         break;
1137 
1138      case 0x53:
1139         if (LOG_PORTS) logerror("%05X:80186 middle chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1140         i186.mem.middle = data16 | 0x01f8;
1141         break;
1142 
1143      case 0x54:
1144         if (LOG_PORTS) logerror("%05X:80186 middle P chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1145         i186.mem.middle_size = data16 | 0x8038;
1146 
1147         temp = (i186.mem.peripheral & 0xffc0) << 4;
1148         if (i186.mem.middle_size & 0x0040)
1149         {
1150//              install_mem_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1151//              install_mem_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1152         }
1153         else
1154         {
1155            temp &= 0xffff;
1156//              install_port_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1157//              install_port_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1158         }
1159 
1160         /* we need to do this at a time when the I86 context is swapped in */
1161         /* this register is generally set once at startup and never again, so it's a good */
1162         /* time to set it up */
1163         cpu_set_irq_callback(space->cpu, int_callback);
1164         break;
1165 
1166      case 0x60:
1167      case 0x68:
1168         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8, data16);
1169         which = (offset - 0x60) / 8;
1170//          stream_update(dma_stream, 0);
1171         i186.dma[which].source = (i186.dma[which].source & ~0x0ffff) | (data16 & 0x0ffff);
1172         break;
1173 
1174      case 0x61:
1175      case 0x69:
1176         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8, data16);
1177         which = (offset - 0x61) / 8;
1178//          stream_update(dma_stream, 0);
1179         i186.dma[which].source = (i186.dma[which].source & ~0xf0000) | ((data16 << 16) & 0xf0000);
1180         break;
1181 
1182      case 0x62:
1183      case 0x6a:
1184         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8, data16);
1185         which = (offset - 0x62) / 8;
1186//          stream_update(dma_stream, 0);
1187         i186.dma[which].dest = (i186.dma[which].dest & ~0x0ffff) | (data16 & 0x0ffff);
1188         break;
1189 
1190      case 0x63:
1191      case 0x6b:
1192         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8, data16);
1193         which = (offset - 0x63) / 8;
1194//          stream_update(dma_stream, 0);
1195         i186.dma[which].dest = (i186.dma[which].dest & ~0xf0000) | ((data16 << 16) & 0xf0000);
1196         break;
1197 
1198      case 0x64:
1199      case 0x6c:
1200         if (LOG_PORTS) logerror("%05X:80186 DMA%d transfer count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8, data16);
1201         which = (offset - 0x64) / 8;
1202//          stream_update(dma_stream, 0);
1203         i186.dma[which].count = data16;
1204         break;
1205 
1206      case 0x65:
1207      case 0x6d:
1208         if (LOG_PORTS) logerror("%05X:80186 DMA%d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8, data16);
1209         which = (offset - 0x65) / 8;
1210//          stream_update(dma_stream, 0);
1211         update_dma_control(space->machine, which, data16);
1212         break;
1213 
1214      case 0x7f:
1215         if (LOG_PORTS) logerror("%05X:80186 relocation register = %04X\n", cpu_get_pc(space->cpu), data16);
1216 
1217         /* we assume here there that this doesn't happen too often */
1218         /* plus, we can't really remove the old memory range, so we also assume that it's */
1219         /* okay to leave us mapped where we were */
1220         temp = (data16 & 0x0fff) << 8;
1221         if (data16 & 0x1000)
1222         {
1223            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1224            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1225         }
1226         else
1227         {
1228            temp &= 0xffff;
1229            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1230            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1231         }
1232/*          popmessage("Sound CPU reset");*/
1233         break;
1234 
1235      default:
1236         logerror("%05X:80186 port %02X = %04X\n", cpu_get_pc(space->cpu), offset, data16);
1237         break;
1238   }
1239}
1240 
1241MACHINE_RESET(nimbus)
1242{
1243   /* CPU */
1244   nimbus_cpu_reset(machine); 
1245    fdc_reset();
1246    keyboard_reset();
1247}
1248 
1249DRIVER_INIT(nimbus)
1250{
1251}
1252 
1253MACHINE_START( nimbus )
1254{
1255    /* init cpu */
1256    nimbus_cpu_init(machine);
1257 
1258    keyboard.keyscan_timer=timer_alloc(machine, keyscan_callback, NULL);
1259     
1260   /* setup debug commands */
1261   if (machine->debug_flags & DEBUG_FLAG_ENABLED)
1262   {
1263      debug_console_register_command(machine, "nimbus_irq", CMDFLAG_NONE, 0, 0, 1, execute_debug_irq);
1264        debug_console_register_command(machine, "nimbus_intmasks", CMDFLAG_NONE, 0, 0, 0, execute_debug_intmasks);
1265 
1266        /* set up the instruction hook */
1267        debug_cpu_set_instruction_hook(cputag_get_cpu(machine, MAINCPU_TAG), instruction_hook);
1268     
1269    }
1270}
1271 
1272static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[])
1273{
1274    int IntNo;
1275    int IntMask;
1276     
1277    if(params>0)
1278    {   
1279        sscanf(param[0],"%d",&IntNo);
1280         
1281        IntMask=0x0000;
1282     
1283        switch (IntNo)
1284        {
1285            case 0  : IntMask=0x010; break;
1286            case 1  : IntMask=0x020; break;
1287            case 2  : IntMask=0x040; break;
1288            case 3  : IntMask=0x080; break;
1289        }
1290         
1291        i186.intr.request |= IntMask;
1292        update_interrupt_state(machine);
1293         
1294        debug_console_printf(machine,"triggering IRQ%d, IntMask=%4.4X, i186.intr.request=%4.4X\n",IntNo,IntMask,i186.intr.request);
1295         
1296//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, HOLD_LINE );
1297//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, CLEAR_LINE );
1298         
1299    }
1300    else
1301    {
1302        debug_console_printf(machine,"Error, you must supply an intno to trigger\n");
1303    }
1304   
1305     
1306}
1307 
1308 
1309static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[])
1310{
1311    int IntNo;
1312     
1313     
1314    debug_console_printf(machine,"i186.intr.priority_mask=%4X\n",i186.intr.priority_mask);
1315    for(IntNo=0; IntNo<4; IntNo++)
1316    {
1317        debug_console_printf(machine,"extInt%d mask=%4X\n",IntNo,i186.intr.ext[IntNo]);
1318    }
1319     
1320    debug_console_printf(machine,"i186.intr.request   = %04X\n",i186.intr.request);
1321    debug_console_printf(machine,"i186.intr.ack_mask  = %04X\n",i186.intr.ack_mask);
1322    debug_console_printf(machine,"i186.intr.in_service= %04X\n",i186.intr.in_service);
1323}
1324 
1325/*-----------------------------------------------
1326    instruction_hook - per-instruction hook
1327-----------------------------------------------*/
1328 
1329static int instruction_hook(const device_config *device, offs_t curpc)
1330{
1331    const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
1332    UINT8               *addr_ptr;
1333     
1334    addr_ptr = memory_get_read_ptr(space,curpc);
1335         
1336    if ((addr_ptr !=NULL) && (addr_ptr[0]==0xCD) && (addr_ptr[1]==0xF0))
1337        decode_subbios(device,curpc);
1338     
1339    return 0;
1340}
1341 
1342#define set_type(type_name)     sprintf(type_str,type_name)
1343#define set_drv(drv_name)       sprintf(drv_str,drv_name)
1344#define set_func(func_name)     sprintf(func_str,func_name)
1345 
1346static void decode_subbios(const device_config *device,offs_t pc)
1347{
1348    char    type_str[80];
1349    char    drv_str[80];
1350    char    func_str[80];
1351     
1352    void (*dump_dssi)(const device_config *,UINT16, UINT16) = NULL;
1353 
1354    const device_config *cpu = cputag_get_cpu(device->machine,MAINCPU_TAG);
1355     
1356    UINT16  ax = cpu_get_reg(cpu,I8086_AX);
1357    UINT16  bx = cpu_get_reg(cpu,I8086_BX);
1358    UINT16  cx = cpu_get_reg(cpu,I8086_CX);
1359    UINT16  ds = cpu_get_reg(cpu,I8086_DS);
1360    UINT16  si = cpu_get_reg(cpu,I8086_SI);
1361     
1362    logerror("=======================================================================\n");
1363    logerror("Sub-bios call at %08X, AX=%04X, BX=%04X, CX=%04X, DS:SI=%04X:%04X\n",pc,ax,bx,cx,ds,si);
1364 
1365    set_type("invalid");
1366    set_drv("invalid");
1367    set_func("invalid");
1368     
1369 
1370    switch (cx)
1371    {
1372        case 0   : 
1373        {
1374            set_type("t_mummu");
1375            set_drv("d_mummu");
1376             
1377            switch (ax)
1378            {
1379                case 0  : set_func("f_get_version_number"); break;
1380                case 1  : set_func("f_add_type_code"); break;
1381                case 2  : set_func("f_del_typc_code"); break;
1382                case 3  : set_func("f_get_TCB"); break;
1383                case 4  : set_func("f_add_driver_code"); break;
1384                case 5  : set_func("f_del_driver_code"); break;
1385                case 6  : set_func("f_get_DCB"); break;
1386                case 7  : set_func("f_get_copyright"); break;
1387            }
1388        }; break;
1389         
1390        case 1   : 
1391        {
1392            set_type("t_character");
1393            set_drv("d_printer");
1394             
1395            switch(ax)
1396            {
1397                case 0  : set_func("f_get_version_number"); break;
1398                case 1  : set_func("f_get_output_status"); break;
1399                case 2  : set_func("f_output_character"); break;
1400                case 3  : set_func("f_get_input_status"); break;
1401                case 4  : set_func("f_get_and_remove"); break;
1402                case 5  : set_func("f_get_no_remove"); break;
1403                case 6  : set_func("f_get_last_and_remove"); break;
1404                case 7  : set_func("f_get_last_no_remove"); break;
1405                case 8  : set_func("f_set_IO_parameters"); break;
1406            }
1407        }; break;
1408         
1409        case 2   : 
1410        {
1411            set_type("t_disk");
1412             
1413            switch(bx)
1414            {
1415                case 0  : set_drv("d_floppy"); break;
1416                case 1  : set_drv("d_winchester"); break;
1417                case 2  : set_drv("d_tape"); break;
1418                case 3  : set_drv("d_rompack"); break;
1419                case 4  : set_drv("d_eeprom"); break;
1420            }
1421             
1422            switch(ax)
1423            {
1424                case 0  : set_func("f_get_version_number"); break;             
1425                case 1  : set_func("f_initialise_unit"); break;
1426                case 2  : set_func("f_pseudo_init_unit"); break;
1427                case 3  : set_func("f_get_device_status"); break;
1428                case 4  : set_func("f_read_n_sectors"); break;
1429                case 5  : set_func("f_write_n_sectors"); break;
1430                case 6  : set_func("f_verify_n_sectors"); break;
1431                case 7  : set_func("f_media_check"); break;
1432                case 8  : set_func("f_recalibrate"); break;
1433                case 9  : set_func("f_motors_off"); break;
1434            }
1435             
1436        }; break;
1437         
1438        case 3   : 
1439        {
1440            set_type("t_piconet");
1441            switch(ax)
1442            {
1443                case 0  : set_func("f_get_version_number"); break;             
1444            }
1445        }; break;
1446         
1447        case 4   : 
1448        {
1449            set_type("t_tick");
1450            set_drv("d_tick");
1451             
1452            switch(ax)
1453            {
1454                case 0  : set_func("f_get_version_number"); break; 
1455                case 1  : set_func("f_ticks_per_second"); break; 
1456                case 2  : set_func("f_link_tick_routine"); break; 
1457                case 3  : set_func("f_unlink_tick_routine"); break;             
1458            }
1459        }; break;
1460         
1461        case 5   : 
1462        {
1463            set_type("t_graphics_input");
1464            switch(ax)
1465            {
1466                case 0  : set_func("f_get_version_number"); break;             
1467            }
1468        }; break;
1469         
1470        case 6   : 
1471        {
1472            set_type("t_graphics_output");
1473            set_drv("d_ngc_screen");
1474 
1475            switch(ax)
1476            {
1477                case 0  : set_func("f_get_version_number");                 break; 
1478                case 1  : set_func("f_graphics_output_cold_start");         break; 
1479                case 2  : set_func("f_graphics_output_warm_start");         break; 
1480                case 3  : set_func("f_graphics_output_off");                break; 
1481                case 4  : set_func("f_reinit_graphics_output");             break; 
1482                case 5  : set_func("f_polymarker");                         break; 
1483                case 6  : set_func("f_polyline");                           break; 
1484                case 7  : set_func("f_fill_area"); dump_dssi=&decode_dssi_f_fill_area; break; 
1485                case 8  : set_func("f_flood_fill_area"); break; 
1486                case 9  : set_func("f_plot_character_string"); dump_dssi=&decode_dssi_f_plot_character_string; break; 
1487                case 10 : set_func("f_define_graphics_clipping_area"); break; 
1488                case 11 : set_func("f_enquire_clipping_area_limits"); break; 
1489                case 12 : set_func("f_select_graphics_clipping_area"); break; 
1490                case 13 : set_func("f_enq_selctd_graphics_clip_area"); break; 
1491                case 14 : set_func("f_set_clt_element"); break; 
1492                case 15 : set_func("f_enquire_clt_element"); break; 
1493                case 16 : set_func("f_set_new_clt"); dump_dssi=&decode_dssi_f_set_new_clt; break; 
1494                case 17 : set_func("f_enquire_clt_contents"); break; 
1495                case 18 : set_func("f_define_dithering_pattern"); break; 
1496                case 19 : set_func("f_enquire_dithering_pattern"); break; 
1497                case 20 : set_func("f_draw_sprite"); break; 
1498                case 21 : set_func("f_move_sprite"); break; 
1499                case 22 : set_func("f_erase_sprite"); break; 
1500                case 23 : set_func("f_read_pixel"); break; 
1501                case 24 : set_func("f_read_to_limit"); break; 
1502                case 25 : set_func("f_read_area_pixel"); break; 
1503                case 26 : set_func("f_write_area_pixel"); break; 
1504                case 27 : set_func("f_copy_area_pixel"); break; 
1505 
1506                case 29 : set_func("f_read_area_word"); break; 
1507                case 30 : set_func("f_write_area_word"); break; 
1508                case 31 : set_func("f_copy_area_word"); break; 
1509                case 32 : set_func("f_swap_area_word"); break; 
1510                case 33 : set_func("f_set_border_colour"); break; 
1511                case 34 : set_func("f_enquire_border_colour"); break; 
1512                case 35 : set_func("f_enquire_miscellaneous_data"); break; 
1513                case 36  : set_func("f_circle"); break; 
1514 
1515                case 38 : set_func("f_arc_of_ellipse"); break; 
1516                case 39 : set_func("f_isin"); break; 
1517                case 40 : set_func("f_icos"); break; 
1518                case 41 : set_func("f_define_hatching_pattern"); break; 
1519                case 42 : set_func("f_enquire_hatching_pattern"); break; 
1520                case 43 : set_func("f_enquire_display_line"); break; 
1521                case 44 : set_func("f_plonk_logo"); break; 
1522            }
1523        }; break;
1524         
1525        case 7   : 
1526        {
1527            set_type("t_zend");
1528            switch(ax)
1529            {
1530                case 0  : set_func("f_get_version_number"); break;             
1531            }
1532        }; break;
1533         
1534        case 8   : 
1535        {
1536            set_type("t_zep");
1537            switch(ax)
1538            {
1539                case 0  : set_func("f_get_version_number"); break;             
1540            }
1541        }; break;
1542         
1543        case 9   : 
1544        {
1545            set_type("t_raw_console");
1546             
1547            switch(bx)
1548            {
1549                case 0  : 
1550                {
1551                    set_drv("d_screen");
1552             
1553                    switch(ax)
1554                    {
1555                        case 0  : set_func("f_get_version_number"); break;             
1556                        case 1  : set_func("f_plonk_char"); dump_dssi=decode_dssi_f_plonk_char; break;
1557                        case 2  : set_func("f_plonk_cursor"); break;
1558                        case 3  : set_func("f_kill_cursor"); break;
1559                        case 4  : set_func("f_scroll"); break;
1560                        case 5  : set_func("f_width"); break;
1561                        case 6  : set_func("f_get_char_set"); break;
1562                        case 7  : set_func("f_set_char_set"); break;
1563                        case 8  : set_func("f_reset_char_set"); break;
1564                        case 9  : set_func("f_set_plonk_parameters"); break;
1565                        case 10 : set_func("f_set_cursor_flash_rate"); break;
1566                    }
1567                }; break;
1568             
1569                case 1  :
1570                {
1571                    set_drv("d_keyboard");
1572                     
1573                    switch(ax)
1574                    {
1575                        case 0  : set_func("f_get_version_number"); break;             
1576                        case 1  : set_func("f_init_keyboard"); break;
1577                        case 2  : set_func("f_get_last_key_code"); break;
1578                        case 3  : set_func("f_get_bitmap"); break;
1579                    }
1580                }; break;
1581            }
1582        }; break;
1583         
1584        case 10   : 
1585        {
1586            set_type("t_acoustics");
1587            switch(ax)
1588            {
1589                case 0  : set_func("f_get_version_number"); break;             
1590            }
1591        }; break;
1592         
1593        case 11   : 
1594        {
1595            set_type("t_hard_sums");
1596            switch(ax)
1597            {
1598                case 0  : set_func("f_get_version_number"); break;             
1599            }
1600        }; break;     
1601    }
1602     
1603    logerror("Type=%s, Driver=%s, Function=%s\n",type_str,drv_str,func_str);
1604     
1605    if(dump_dssi!=NULL)
1606        dump_dssi(device,ds,si);
1607    logerror("=======================================================================\n");
1608}
1609 
1610void *get_dssi_ptr(const address_space *space, UINT16   ds, UINT16 si)
1611{
1612    int             addr;
1613 
1614    addr=((ds<<4)+si);
1615    OUTPUT_SEGOFS("DS:SI",ds,si);
1616 
1617    return memory_get_read_ptr(space, addr);
1618}
1619 
1620static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si)
1621{
1622    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1623 
1624    UINT16          *addr_ptr;
1625    t_area_params   *area_params;
1626    t_nimbus_brush  *brush;
1627    int             cocount;
1628 
1629    area_params = get_dssi_ptr(space,ds,si);
1630     
1631    OUTPUT_SEGOFS("SegBrush:OfsBrush",area_params->seg_brush,area_params->ofs_brush);
1632    brush=memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_brush,area_params->ofs_brush));
1633     
1634    logerror("Brush params\n");
1635    logerror("Style=%04X,          StyleIndex=%04X\n",brush->style,brush->style_index);
1636    logerror("Colour1=%04X,        Colour2=%04X\n",brush->colour1,brush->colour2);
1637    logerror("transparency=%04X,   boundry_spec=%04X\n",brush->transparency,brush->boundary_spec);
1638    logerror("boundry colour=%04X, save colour=%04X\n",brush->boundary_colour,brush->save_colour);
1639             
1640     
1641    OUTPUT_SEGOFS("SegData:OfsData",area_params->seg_data,area_params->ofs_data);
1642     
1643    addr_ptr = memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_data,area_params->ofs_data));
1644    for(cocount=0; cocount < area_params->count; cocount++)
1645    {
1646        logerror("x=%d y=%d\n",addr_ptr[cocount*2],addr_ptr[(cocount*2)+1]);
1647    }
1648}
1649 
1650static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si)
1651{
1652    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1653 
1654    UINT8          *char_ptr;
1655    t_plot_string_params   *plot_string_params;
1656    int             charno;
1657       
1658    plot_string_params=get_dssi_ptr(space,ds,si);
1659     
1660    OUTPUT_SEGOFS("SegFont:OfsFont",plot_string_params->seg_font,plot_string_params->ofs_font);
1661    OUTPUT_SEGOFS("SegData:OfsData",plot_string_params->seg_data,plot_string_params->ofs_data);
1662     
1663    logerror("x=%d, y=%d, length=%d\n",plot_string_params->x,plot_string_params->y,plot_string_params->length);
1664     
1665    char_ptr=memory_get_read_ptr(space, LINEAR_ADDR(plot_string_params->seg_data,plot_string_params->ofs_data));
1666 
1667    if (plot_string_params->length==0xFFFF)
1668        logerror("%s",char_ptr);
1669    else
1670        for(charno=0;charno<plot_string_params->length;charno++)
1671            logerror("%c",char_ptr[charno]);
1672         
1673    logerror("\n");
1674}
1675 
1676static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si)
1677{
1678    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1679    UINT16  *new_colours;
1680    int     colour;
1681    new_colours=get_dssi_ptr(space,ds,si);
1682     
1683    OUTPUT_SEGOFS("SegColours:OfsColours",ds,si);
1684     
1685    for(colour=0;colour<16;colour++)
1686        logerror("colour #%02X=%04X\n",colour,new_colours[colour]);
1687     
1688}
1689 
1690static void decode_dssi_f_plonk_char(const device_config *device,UINT16  ds, UINT16 si)
1691{
1692    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1693    UINT16  *params;
1694    params=get_dssi_ptr(space,ds,si);
1695     
1696    OUTPUT_SEGOFS("SegParams:OfsParams",ds,si);
1697 
1698    logerror("plonked_char=%c\n",params[0]);
1699}
1700 
1701 
1702READ16_HANDLER( nimbus_io_r )
1703{
1704    int pc=cpu_get_pc(space->cpu);
1705     
1706    logerror("Nimbus IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2)+0x30,mem_mask,IOPorts[offset]);
1707     
1708    switch (offset*2)
1709    {
1710        default         : return IOPorts[offset]; break;
1711    }
1712    return 0;
1713}
1714 
1715WRITE16_HANDLER( nimbus_io_w )
1716{
1717    int pc=cpu_get_pc(space->cpu);
1718 
1719    logerror("Nimbus IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2)+0x30,mem_mask);
1720     
1721    switch (offset*2)
1722    {
1723        default         : COMBINE_DATA(&IOPorts[offset]); break;
1724    }
1725}
1726 
1727 
1728/* 
1729    Keyboard emulation 
1730     
1731*/
1732 
1733static void keyboard_reset(void)
1734{
1735    memset(keyboard.keyrows,0xFF,NIMBUS_KEYROWS);
1736     
1737    // Setup timer to scan keyboard.
1738    timer_adjust_periodic(keyboard.keyscan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(50));
1739 
1740}
1741 
1742static void queue_scancode(UINT8 scancode)
1743{
1744   keyboard.queue[keyboard.head] = scancode;
1745   keyboard.head++;
1746   keyboard.head %= ARRAY_LENGTH(keyboard.queue);
1747}
1748 
1749static int keyboard_queue_read(void)
1750{
1751   int data;
1752   if (keyboard.tail == keyboard.head)
1753      return -1;
1754 
1755   data = keyboard.queue[keyboard.tail];
1756 
1757   if (LOG_KEYBOARD)
1758      logerror("keyboard_queue_read(): Keyboard Read 0x%02x\n",data);
1759 
1760   keyboard.tail++;
1761   keyboard.tail %= ARRAY_LENGTH(keyboard.queue);
1762   return data;
1763}
1764 
1765static TIMER_CALLBACK(keyscan_callback)
1766{
1767    UINT8   keyrow;
1768    UINT8   row;
1769    UINT8   bitno;
1770    UINT8   mask;
1771    static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
1772                                             "KEY5", "KEY6", "KEY7", "KEY8", "KEY9", 
1773                                             "KEY10"};
1774 
1775    for(row=0;row<NIMBUS_KEYROWS;row++)
1776    {
1777        keyrow=input_port_read(machine, keynames[row]);
1778         
1779        for(mask=0x80, bitno=7;mask>0;mask=mask>>1, bitno-=1)
1780        {
1781            if(!(keyrow & mask) && (keyboard.keyrows[row] & mask))
1782            {
1783                if (LOG_KEYBOARD) logerror("keypress %02X\n",(row<<3)+bitno);
1784                queue_scancode((row<<3)+bitno);
1785            }
1786   
1787            if((keyrow & mask) && !(keyboard.keyrows[row] & mask))
1788            {
1789                if (LOG_KEYBOARD) logerror("keyrelease %02X\n",0x80+(row<<3)+bitno);   
1790                queue_scancode(0x80+(row<<3)+bitno);
1791            }
1792        }
1793         
1794        keyboard.keyrows[row]=keyrow;
1795    }
1796}
1797 
1798 
1799/* 
1800 
1801Z80SIO, used for the keyboard interface 
1802 
1803*/
1804 
1805READ8_DEVICE_HANDLER( sio_r )
1806{
1807    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1808    UINT8 result = 0;
1809     
1810   switch (offset*2)
1811   {
1812        case 0 :
1813            result=z80sio_d_r(device, 0); 
1814            break;
1815        case 2 :
1816            result=z80sio_d_r(device, 1); 
1817            break;
1818        case 4 :
1819            result=z80sio_c_r(device, 0);
1820            break;
1821        case 6 :
1822            result=z80sio_c_r(device, 1);
1823            break;
1824   }
1825 
1826    if(LOG_SIO)
1827        logerror("Nimbus SIOR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0xF0,result);
1828 
1829   return result;
1830}
1831 
1832WRITE8_DEVICE_HANDLER( sio_w )
1833{
1834    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1835 
1836    if(LOG_SIO)
1837        logerror("Nimbus SIOW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0xF0);
1838 
1839   switch (offset*2)
1840   {
1841        case 0 :
1842            z80sio_d_w(device, 0, data);
1843            break;
1844        case 2 :
1845            z80sio_d_w(device, 1, data);
1846            break;
1847        case 4 :
1848            z80sio_c_w(device, 0, data);
1849            break;
1850        case 5 :
1851            z80sio_c_w(device, 1, data);
1852            break;
1853   }
1854}
1855 
1856/* Z80 SIO/2 */
1857 
1858void sio_interrupt(const device_config *device, int state)
1859{
1860    if(LOG_SIO)
1861        logerror("SIO Interrupt state=%02X\n",state);
1862 
1863    // Don't re-trigger if already active !
1864    if(state!=sio_int_state)
1865    {
1866        sio_int_state=state;
1867         
1868        if(state)
1869            external_int(device->machine,0,0x9C);
1870    }
1871}
1872 
1873WRITE8_DEVICE_HANDLER( sio_dtr_w )
1874{
1875   if (offset == 1)
1876   {
1877   }
1878}
1879 
1880WRITE8_DEVICE_HANDLER( sio_serial_transmit )
1881{
1882}
1883 
1884int sio_serial_receive( const device_config *device, int channel )
1885{
1886   if(channel==0)
1887    {
1888        return keyboard_queue_read();       
1889    }
1890    else
1891        return -1;
1892}
1893 
1894/* Floppy disk */
1895 
1896static void fdc_reset(void)
1897{
1898    nimbus_fdc.irq_enabled=0;
1899    nimbus_fdc.drq_enabled=0;
1900    nimbus_fdc.diskno=0;
1901    nimbus_fdc.motor_on=0;
1902}
1903 
1904static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w )
1905{
1906    if(LOG_DISK)
1907        logerror("nimbus_fdc_intrq_w(%d)\n", state);
1908 
1909    if(state && nimbus_fdc.irq_enabled)
1910    {
1911        external_int(device->machine,0,0x80);
1912    } 
1913}
1914 
1915static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w )
1916{
1917 
1918    if(LOG_DISK)
1919        logerror("nimbus_fdc_drq_w(%d)\n", state);
1920     
1921    if(state && nimbus_fdc.drq_enabled)
1922        drq_callback(device->machine,1);
1923}
1924 
1925READ8_HANDLER( nimbus_fdc_r )
1926{
1927      int result = 0;
1928   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1929    int pc=cpu_get_pc(space->cpu);
1930    const device_config *drive = devtag_get_device(space->machine, nimbus_wd17xx_interface.floppy_drive_tags[nimbus_fdc.diskno]);
1931   
1932    switch(offset*2)
1933   {
1934      case 0x08 :
1935         result = wd17xx_status_r(fdc, 0);
1936         if (LOG_DISK) logerror("Disk status=%2.2X\n",result);
1937         break;
1938      case 0x0A :
1939         result = wd17xx_track_r(fdc, 0);
1940         break;
1941      case 0x0C :
1942         result = wd17xx_sector_r(fdc, 0);
1943         break;
1944      case 0x0E :
1945         result = wd17xx_data_r(fdc, 0);
1946         break;
1947        case 0x10 :
1948            result = (nimbus_fdc.motor_on                                    ? 0x04 : 0x00) |
1949                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_INDEX) ? 0x00 : 0x02) |
1950                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_READY) ? 0x01 : 0x00);       
1951            break;
1952      default:
1953         break;
1954   }
1955 
1956    if(LOG_DISK)
1957        logerror("Nimbus FDCR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0x400,result);
1958 
1959   return result;
1960}
1961 
1962WRITE8_HANDLER( nimbus_fdc_w )
1963{
1964   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1965    int pc=cpu_get_pc(space->cpu);
1966 
1967    if(LOG_DISK)
1968        logerror("Nimbus FDCW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0x400);
1969 
1970    switch(offset*2)
1971   {
1972        case 0x00 :
1973            switch (data & 0x0F)
1974            {
1975                case 0x01 : nimbus_fdc.diskno=0; break;
1976                case 0x02 : nimbus_fdc.diskno=1; break;
1977                case 0x04 : nimbus_fdc.diskno=2; break;
1978                case 0x08 : nimbus_fdc.diskno=3; break;   
1979                //default : nimbus_fdc.diskno=NO_DRIVE_SELECTED; break; // no drive selected
1980            }
1981            if (nimbus_fdc.diskno!=NO_DRIVE_SELECTED)
1982            {
1983                wd17xx_set_drive(fdc, nimbus_fdc.diskno);
1984                wd17xx_set_side(fdc, (data & 0x10) ? 1 : 0);
1985            }
1986            nimbus_fdc.motor_on=(data & 0x20);
1987            nimbus_fdc.drq_enabled=(data & 0x80);
1988            nimbus_fdc.irq_enabled=1;
1989             
1990            // Nimbus FDC is hard wired for double density
1991            wd17xx_set_density(fdc, DEN_MFM_LO);
1992         break;
1993      case 0x08 :
1994         wd17xx_command_w(fdc, 0, data);
1995         break;
1996      case 0x0A :
1997         wd17xx_track_w(fdc, 0, data);
1998         break;
1999      case 0x0C :
2000         wd17xx_sector_w(fdc, 0, data);
2001         break;
2002      case 0x0E :
2003         wd17xx_data_w(fdc, 0, data);
2004         break;
2005   }
2006}
2007 
1/*
2    machine/rmnimbus.c
3   
4    Machine driver for the Research Machines Nimbus.
5   
6    Phill Harvey-Smith
7    2009-11-29.
8   
9    80186 internal DMA/Timer/PIC code borrowed from Compis driver.
10    Perhaps this needs merging into the 80186 core.....
11*/
12
13
14#include "driver.h"
15#include "memory.h"
16#include "cpu/i86/i86.h"
17#include "debug/debugcpu.h"
18#include "debug/debugcon.h"
19#include "devices/flopdrv.h"
20#include "machine/pic8259.h"
21#include "machine/pit8253.h"
22#include "machine/msm8251.h"
23#include "machine/z80sio.h"
24
25#include "includes/rmnimbus.h"
26
27/*-------------------------------------------------------------------------*/
28/* Defines, constants, and global variables                                */
29/*-------------------------------------------------------------------------*/
30
31/* CPU 80186 */
32#define LATCH_INTS          1
33#define LOG_PORTS           0
34#define LOG_INTERRUPTS      0
35#define LOG_INTERRUPTS_EXT  0
36#define LOG_TIMER           0
37#define LOG_OPTIMIZATION    0
38#define LOG_DMA             0
39#define CPU_RESUME_TRIGGER   7123
40#define LOG_KEYBOARD        0
41#define LOG_SIO             0
42#define LOG_DISK            0
43
44/* 80186 internal stuff */
45struct mem_state
46{
47   UINT16       lower;
48   UINT16       upper;
49   UINT16       middle;
50   UINT16       middle_size;
51   UINT16       peripheral;
52};
53
54struct timer_state
55{
56   UINT16       control;
57   UINT16       maxA;
58   UINT16       maxB;
59   UINT16       count;
60   emu_timer   *int_timer;
61   emu_timer   *time_timer;
62   UINT8       time_timer_active;
63   attotime   last_time;
64};
65
66struct dma_state
67{
68   UINT32       source;
69   UINT32       dest;
70   UINT16       count;
71   UINT16       control;
72   UINT8       finished;
73   emu_timer   *finish_timer;
74};
75
76struct intr_state
77{
78   UINT8   pending;
79   UINT16   ack_mask;
80   UINT16   priority_mask;
81   UINT16   in_service;
82   UINT16   request;
83   UINT16   status;
84   UINT16   poll_status;
85   UINT16   timer;
86   UINT16   dma[2];
87   UINT16   ext[4];
88    UINT16  ext_vector[2]; // external vectors, when in cascade mode
89};
90
91static struct i186_state
92{
93   struct timer_state   timer[3];
94   struct dma_state   dma[2];
95   struct intr_state   intr;
96   struct mem_state   mem;
97} i186;
98
99
100/* Z80 SIO */
101
102const z80sio_interface sio_intf =
103{
104   sio_interrupt,         /* interrupt handler */
105   0, //sio_dtr_w,            /* DTR changed handler */
106   0,                  /* RTS changed handler */
107   0,                  /* BREAK changed handler */
108   sio_serial_transmit,   /* transmit handler */
109   sio_serial_receive      /* receive handler */
110};
111
112struct keybord_state
113{
114    UINT8       keyrows[NIMBUS_KEYROWS];
115    emu_timer   *keyscan_timer;
116    UINT8       queue[KEYBOARD_QUEUE_SIZE];
117   UINT8       head;
118   UINT8       tail;
119} keyboard;
120
121
122
123/* Floppy drives WD2793 */
124
125static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w );
126static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w );
127
128const wd17xx_interface nimbus_wd17xx_interface =
129{
130   DEVCB_LINE(nimbus_fdc_intrq_w),
131   DEVCB_LINE(nimbus_fdc_drq_w),
132   {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3}
133};
134
135static struct _nimbus_fdc
136{
137    UINT8 drq_enabled;
138    UINT8 irq_enabled;
139    UINT8 diskno;
140    UINT8 motor_on;
141} nimbus_fdc;
142
143
144static void drq_callback(running_machine *machine, int which);
145
146static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[]);
147static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[]);
148
149static int instruction_hook(const device_config *device, offs_t curpc);
150static void decode_subbios(const device_config *device,offs_t pc);
151static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si);
152static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si);
153static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si);
154static void decode_dssi_f_plonk_char(const device_config *device,UINT16  ds, UINT16 si);
155
156static void fdc_reset(void);
157
158static void keyboard_reset(void);
159static TIMER_CALLBACK(keyscan_callback);
160
161#define num_ioports 0x80
162static UINT16   IOPorts[num_ioports];
163
164UINT8 nextkey;
165UINT8 sio_int_state;
166
167/*************************************
168 *
169 *  80186 interrupt controller
170 *
171 *************************************/
172static IRQ_CALLBACK(int_callback)
173{
174    UINT8   vector;
175    UINT16  old;
176    UINT16  oldreq;
177
178   if (LOG_INTERRUPTS)
179      logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time(device->machine)), i186.intr.poll_status & 0x1f);
180
181   /* clear the interrupt */
182   cpu_set_input_line(device, 0, CLEAR_LINE);
183   i186.intr.pending = 0;
184
185    oldreq=i186.intr.request;
186
187   /* clear the request and set the in-service bit */
188#if LATCH_INTS
189   i186.intr.request &= ~i186.intr.ack_mask;
190#else
191   i186.intr.request &= ~(i186.intr.ack_mask & 0x0f);
192#endif
193
194   if((LOG_INTERRUPTS) && (i186.intr.request!=oldreq))
195        logerror("i186.intr.request changed from %02X to %02X\n",oldreq,i186.intr.request);
196
197    old=i186.intr.in_service;
198
199   i186.intr.in_service |= i186.intr.ack_mask;
200   
201    if((LOG_INTERRUPTS) && (i186.intr.in_service!=old))
202        logerror("i186.intr.in_service changed from %02X to %02X\n",old,i186.intr.in_service);
203   
204    if (i186.intr.ack_mask == 0x0001)
205   {
206      switch (i186.intr.poll_status & 0x1f)
207      {
208         case 0x08:   i186.intr.status &= ~0x01;   break;
209         case 0x12:   i186.intr.status &= ~0x02;   break;
210         case 0x13:   i186.intr.status &= ~0x04;   break;
211      }
212   }
213   i186.intr.ack_mask = 0;
214
215   /* a request no longer pending */
216   i186.intr.poll_status &= ~0x8000;
217
218   /* return the vector */
219    switch(i186.intr.poll_status & 0x1F)
220    {
221        case 0x0C   : vector=(i186.intr.ext[0] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[0] : (i186.intr.poll_status & 0x1f); break;
222        case 0x0D   : vector=(i186.intr.ext[1] & EXTINT_CTRL_CASCADE) ? i186.intr.ext_vector[1] : (i186.intr.poll_status & 0x1f); break;
223        default :
224            vector=i186.intr.poll_status & 0x1f; break;
225    }
226
227    if (LOG_INTERRUPTS_EXT)
228   {
229        logerror("i186.intr.ext[0]=%04X i186.intr.ext[1]=%04X\n",i186.intr.ext[0],i186.intr.ext[1]);
230        logerror("Ext vectors : %02X %02X\n",i186.intr.ext_vector[0],i186.intr.ext_vector[1]);
231        logerror("Int %02X Calling vector %02X\n",i186.intr.poll_status,vector);
232    }
233   
234    return vector;
235}
236
237
238static void update_interrupt_state(running_machine *machine)
239{   
240    int new_vector = 0;
241    int Priority;
242    int IntNo;
243
244   if (LOG_INTERRUPTS)
245        logerror("update_interrupt_status: req=%04X stat=%04X serv=%04X priority_mask=%4X\n", i186.intr.request, i186.intr.status, i186.intr.in_service, i186.intr.priority_mask);
246
247   /* loop over priorities */
248   for (Priority = 0; Priority <= i186.intr.priority_mask; Priority++)
249   {
250      /* note: by checking 4 bits, we also verify that the mask is off */
251      if ((i186.intr.timer & 15) == Priority)
252      {
253         /* if we're already servicing something at this level, don't generate anything new */
254         if (i186.intr.in_service & 0x01)
255            return;
256
257         /* if there's something pending, generate an interrupt */
258         if (i186.intr.status & 0x07)
259         {
260            if (i186.intr.status & 1)
261               new_vector = 0x08;
262            else if (i186.intr.status & 2)
263               new_vector = 0x12;
264            else if (i186.intr.status & 4)
265               new_vector = 0x13;
266            else
267               popmessage("Invalid timer interrupt!");
268
269            /* set the clear mask and generate the int */
270            i186.intr.ack_mask = 0x0001;
271            goto generate_int;
272         }
273      }
274
275      /* check DMA interrupts */
276      for (IntNo = 0; IntNo < 2; IntNo++)
277         if ((i186.intr.dma[IntNo] & 0x0F) == Priority)
278         {
279            /* if we're already servicing something at this level, don't generate anything new */
280            if (i186.intr.in_service & (0x04 << IntNo))
281               return;
282
283            /* if there's something pending, generate an interrupt */
284            if (i186.intr.request & (0x04 << IntNo))
285            {
286               new_vector = 0x0a + IntNo;
287
288               /* set the clear mask and generate the int */
289               i186.intr.ack_mask = 0x0004 << IntNo;
290               goto generate_int;
291            }
292         }
293
294        //logerror("Checking external ints\n");
295      /* check external interrupts */
296      for (IntNo = 0; IntNo < 4; IntNo++)
297         if ((i186.intr.ext[IntNo] & 0x0F) == Priority)
298         {
299                if (LOG_INTERRUPTS)
300                    logerror("Int%d priority=%d\n",IntNo,Priority);
301               
302                /* if we're already servicing something at this level, don't generate anything new */
303            if (i186.intr.in_service & (0x10 << IntNo))
304               return;
305
306            /* if there's something pending, generate an interrupt */
307            if (i186.intr.request & (0x10 << IntNo))
308            {
309               /* otherwise, generate an interrupt for this request */
310               new_vector = 0x0c + IntNo;
311
312               /* set the clear mask and generate the int */
313               i186.intr.ack_mask = 0x0010 << IntNo;
314                    goto generate_int;
315            }
316         }
317   }
318   return;
319
320generate_int:
321   /* generate the appropriate interrupt */
322   i186.intr.poll_status = 0x8000 | new_vector;
323   if (!i186.intr.pending)
324      cputag_set_input_line(machine, MAINCPU_TAG, 0, ASSERT_LINE);
325   i186.intr.pending = 1;
326   cpuexec_trigger(machine, CPU_RESUME_TRIGGER);
327   if (LOG_OPTIMIZATION) logerror("  - trigger due to interrupt pending\n");
328   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time(machine)), new_vector);
329}
330
331
332static void handle_eoi(running_machine *machine,int data)
333{
334    int Priority;
335    int IntNo;
336
337   /* specific case */
338   if (!(data & 0x8000))
339   {
340      /* turn off the appropriate in-service bit */
341      switch (data & 0x1f)
342      {
343         case 0x08:   i186.intr.in_service &= ~0x01;   break;
344         case 0x12:   i186.intr.in_service &= ~0x01;   break;
345         case 0x13:   i186.intr.in_service &= ~0x01;   break;
346         case 0x0a:   i186.intr.in_service &= ~0x04;   break;
347         case 0x0b:   i186.intr.in_service &= ~0x08;   break;
348         case 0x0c:   i186.intr.in_service &= ~0x10;   break;
349         case 0x0d:   i186.intr.in_service &= ~0x20;   break;
350         case 0x0e:   i186.intr.in_service &= ~0x40;   break;
351         case 0x0f:   i186.intr.in_service &= ~0x80;   break;
352         default:   logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), data & 0x1f);
353      }
354      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time(machine)), data & 0x1f);
355   }
356
357   /* non-specific case */
358   else
359   {
360      /* loop over priorities */
361      for (Priority = 0; Priority <= 7; Priority++)
362      {
363         /* check for in-service timers */
364         if ((i186.intr.timer & 0x07) == Priority && (i186.intr.in_service & 0x01))
365         {
366            i186.intr.in_service &= ~0x01;
367            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time(machine)));
368            return;
369         }
370
371         /* check for in-service DMA interrupts */
372         for (IntNo = 0; IntNo < 2; IntNo++)
373            if ((i186.intr.dma[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x04 << IntNo)))
374            {
375               i186.intr.in_service &= ~(0x04 << IntNo);
376               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
377               return;
378            }
379
380         /* check external interrupts */
381         for (IntNo = 0; IntNo < 4; IntNo++)
382            if ((i186.intr.ext[IntNo] & 0x07) == Priority && (i186.intr.in_service & (0x10 << IntNo)))
383            {
384               i186.intr.in_service &= ~(0x10 << IntNo);
385               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time(machine)), IntNo);
386               return;
387            }
388      }
389   }
390}
391
392/* Trigger an external interupt, optionally supplying the vector to take */
393static void external_int(running_machine *machine, UINT16 intno, UINT8 vector)
394{
395   if (LOG_INTERRUPTS_EXT) logerror("generating external int %02X, vector %02X\n",intno,vector);
396 
397   // Only 4 external ints
398    if(intno>3)
399    {
400        logerror("external_int() invalid external interupt no : 0x%02X (can only be 0..3)\n",intno);
401        return;
402    }
403   
404    // Only set external vector if cascade mode enabled, only valid for
405    // int 0 & int 1
406    if (intno<2)
407    {
408        if(i186.intr.ext[intno] & EXTINT_CTRL_CASCADE)
409            i186.intr.ext_vector[intno]=vector;
410    }
411   
412    // Turn on the requested request bit and handle interrupt
413    i186.intr.request |= (0x010 << intno);
414    update_interrupt_state(machine);
415}
416
417
418/*************************************
419 *
420 *  80186 internal timers
421 *
422 *************************************/
423
424static TIMER_CALLBACK(internal_timer_int)
425{
426   int which = param;
427   struct timer_state *t = &i186.timer[which];
428
429   if (LOG_TIMER) logerror("Hit interrupt callback for timer %d\n", which);
430
431   /* set the max count bit */
432   t->control |= 0x0020;
433
434   /* request an interrupt */
435   if (t->control & 0x2000)
436   {
437      i186.intr.status |= 0x01 << which;
438      update_interrupt_state(machine);
439      if (LOG_TIMER) logerror("  Generating timer interrupt\n");
440   }
441
442   /* if we're continuous, reset */
443   if (t->control & 0x0001)
444   {
445      int count = t->maxA ? t->maxA : 0x10000;
446      timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which);
447      if (LOG_TIMER) logerror("  Repriming interrupt\n");
448   }
449   else
450      timer_adjust_oneshot(t->int_timer, attotime_never, which);
451}
452
453
454static void internal_timer_sync(int which)
455{
456   struct timer_state *t = &i186.timer[which];
457
458   /* if we have a timing timer running, adjust the count */
459   if (t->time_timer_active)
460   {
461      attotime current_time = timer_timeelapsed(t->time_timer);
462      int net_clocks = attotime_mul(attotime_sub(current_time, t->last_time),  2000000).seconds;
463      t->last_time = current_time;
464
465      /* set the max count bit if we passed the max */
466      if ((int)t->count + net_clocks >= t->maxA)
467         t->control |= 0x0020;
468
469      /* set the new count */
470      if (t->maxA != 0)
471         t->count = (t->count + net_clocks) % t->maxA;
472      else
473         t->count = t->count + net_clocks;
474   }
475}
476
477
478static void internal_timer_update(running_machine *machine,
479                          int which,
480                                  int new_count,
481                                  int new_maxA,
482                                  int new_maxB,
483                                  int new_control)
484{
485   struct timer_state *t = &i186.timer[which];
486   int update_int_timer = 0;
487
488    if (LOG_TIMER)
489        logerror("internal_timer_update: %d, new_count=%d, new_maxA=%d, new_maxB=%d,new_control=%d\n",which,new_count,new_maxA,new_maxB,new_control);
490
491   /* if we have a new count and we're on, update things */
492   if (new_count != -1)
493   {
494      if (t->control & 0x8000)
495      {
496         internal_timer_sync(which);
497         update_int_timer = 1;
498      }
499      t->count = new_count;
500   }
501
502   /* if we have a new max and we're on, update things */
503   if (new_maxA != -1 && new_maxA != t->maxA)
504   {
505      if (t->control & 0x8000)
506      {
507         internal_timer_sync(which);
508         update_int_timer = 1;
509      }
510      t->maxA = new_maxA;
511      if (new_maxA == 0)
512      {
513               new_maxA = 0x10000;
514      }
515   }
516
517   /* if we have a new max and we're on, update things */
518   if (new_maxB != -1 && new_maxB != t->maxB)
519   {
520      if (t->control & 0x8000)
521      {
522         internal_timer_sync(which);
523         update_int_timer = 1;
524      }
525
526      t->maxB = new_maxB;
527
528      if (new_maxB == 0)
529      {
530               new_maxB = 0x10000;
531      }
532      }
533   
534
535   /* handle control changes */
536   if (new_control != -1)
537   {
538      int diff;
539
540      /* merge back in the bits we don't modify */
541      new_control = (new_control & ~0x1fc0) | (t->control & 0x1fc0);
542
543      /* handle the /INH bit */
544      if (!(new_control & 0x4000))
545         new_control = (new_control & ~0x8000) | (t->control & 0x8000);
546      new_control &= ~0x4000;
547
548      /* check for control bits we don't handle */
549      diff = new_control ^ t->control;
550      if (diff & 0x001c)
551        logerror("%05X:ERROR! -unsupported timer mode %04X\n",
552            cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
553
554      /* if we have real changes, update things */
555      if (diff != 0)
556      {
557
558         /* if we're going off, make sure our timers are gone */
559         if ((diff & 0x8000) && !(new_control & 0x8000))
560         {
561            /* compute the final count */
562            internal_timer_sync(which);
563
564            /* nuke the timer and force the interrupt timer to be recomputed */
565            timer_adjust_oneshot(t->time_timer, attotime_never, which);
566            t->time_timer_active = 0;
567            update_int_timer = 1;
568         }
569
570         /* if we're going on, start the timers running */
571         else if ((diff & 0x8000) && (new_control & 0x8000))
572         {
573            /* start the timing */
574            timer_adjust_oneshot(t->time_timer, attotime_never, which);
575            t->time_timer_active = 1;
576            update_int_timer = 1;
577         }
578
579         /* if something about the interrupt timer changed, force an update */
580         if (!(diff & 0x8000) && (diff & 0x2000))
581         {
582            internal_timer_sync(which);
583            update_int_timer = 1;
584         }
585      }
586
587      /* set the new control register */
588      t->control = new_control;
589   }
590
591   /* update the interrupt timer */
592      if (update_int_timer)
593      {
594            if ((t->control & 0x8000) && (t->control & 0x2000))
595            {
596              int diff = t->maxA - t->count;
597               if (diff <= 0)
598                  diff += 0x10000;
599               timer_adjust_oneshot(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which);
600               if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which);
601            }
602            else
603            {
604              timer_adjust_oneshot(t->int_timer, attotime_never, which);
605            }
606   }
607}
608
609
610
611/*************************************
612 *
613 *  80186 internal DMA
614 *
615 *************************************/
616
617static TIMER_CALLBACK(dma_timer_callback)
618{
619   int which = param;
620   struct dma_state *d = &i186.dma[which];
621
622   /* force an update and see if we're really done */
623   //stream_update(dma_stream, 0);
624
625   /* complete the status update */
626   d->control &= ~0x0002;
627   d->source += d->count;
628   d->count = 0;
629
630   /* check for interrupt generation */
631   if (d->control & 0x0100)
632   {
633      if (LOG_DMA) logerror("DMA%d timer callback - requesting interrupt: count = %04X, source = %04X\n", which, d->count, d->source);
634      i186.intr.request |= 0x04 << which;
635      update_interrupt_state(machine);
636   }
637}
638
639
640static void update_dma_control(running_machine *machine, int which, int new_control)
641{
642   struct dma_state *d = &i186.dma[which];
643   int diff;
644
645   /* handle the CHG bit */
646   if (!(new_control & CHG_NOCHG))
647     new_control = (new_control & ~ST_STOP) | (d->control & ST_STOP);
648   new_control &= ~CHG_NOCHG;
649
650   /* check for control bits we don't handle */
651   diff = new_control ^ d->control;
652   if ((LOG_DMA) && (diff & 0x6811))
653     logerror("%05X:ERROR! - unsupported DMA mode %04X\n",
654         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), new_control);
655
656   /* if we're going live, set a timer */
657   if ((diff & 0x0002) && (new_control & 0x0002))
658   {
659      /* make sure the parameters meet our expectations */
660      if ((new_control & 0xfe00) != 0x1600)
661      {
662         if (LOG_DMA) logerror("Unexpected DMA control %02X\n", new_control);
663      }
664      else if (/*!is_redline &&*/ ((d->dest & 1) || (d->dest & 0x3f) > 0x0b))
665      {
666         if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest);
667      }
668      else if (/*is_redline && */ (d->dest & 0xf000) != 0x4000 && (d->dest & 0xf000) != 0x5000)
669      {
670         if (LOG_DMA) logerror("Unexpected DMA destination %02X\n", d->dest);
671      }
672
673      /* otherwise, set a timer */
674      else
675      {
676//          int count = d->count;
677
678         /* adjust for redline racer */
679            // int dacnum = (d->dest & 0x3f) / 2;
680
681         if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
682
683         d->finished = 0;
684/*          timer_adjust_oneshot(d->finish_timer,
685         ATTOTIME_IN_HZ(dac[dacnum].frequency) * (double)count, which);*/
686      }
687   }
688
689   /* set the new control register */
690   d->control = new_control;
691}
692
693static void drq_callback(running_machine *machine, int which)
694{
695    struct dma_state *dma = &i186.dma[which];
696   const address_space *memory_space   = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_PROGRAM);
697    const address_space *io_space       = cpu_get_address_space(cputag_get_cpu(machine, MAINCPU_TAG), ADDRESS_SPACE_IO);
698   
699    const address_space *src_space;
700    const address_space *dest_space;
701   
702    UINT16  dma_word;
703    UINT8   dma_byte;
704    UINT8   incdec_size;
705
706    if (LOG_DMA)
707        logerror("Control=%04X, src=%05X, dest=%05X, count=%04X\n",dma->control,dma->source,dma->dest,dma->count);
708
709    if(!(dma->control & ST_STOP))
710    {
711        logerror("%05X:ERROR! - drq%d with dma channel stopped\n",
712         cpu_get_pc(cputag_get_cpu(machine, MAINCPU_TAG)), which);
713           
714        return;
715    }
716 
717    if(dma->control & DEST_MIO)
718        dest_space=memory_space;
719    else
720        dest_space=io_space;
721   
722    if(dma->control & SRC_MIO)
723        src_space=memory_space;
724    else
725        src_space=io_space;
726   
727    // Do the transfer
728    if(dma->control & BYTE_WORD)
729    {
730        dma_word=memory_read_word(src_space,dma->source);
731        memory_write_word(dest_space,dma->dest,dma_word);
732        incdec_size=2;
733    }
734    else
735    {
736        dma_byte=memory_read_byte(src_space,dma->source);
737        memory_write_byte(dest_space,dma->dest,dma_byte);
738        incdec_size=1;
739    }
740   
741    // Increment or Decrement destination ans source pointers as needed
742    switch (dma->control & DEST_INCDEC_MASK)
743    {
744        case DEST_DECREMENT     : dma->dest -= incdec_size;
745        case DEST_INCREMENT     : dma->dest += incdec_size;
746    }
747   
748    switch (dma->control & SRC_INCDEC_MASK)
749    {
750        case SRC_DECREMENT     : dma->source -= incdec_size;
751        case SRC_INCREMENT     : dma->source += incdec_size;
752    }
753   
754    // decrement count
755    dma->count -= 1;
756   
757    // Terminate if count is zero, and terminate flag set
758    if((dma->control & TERMINATE_ON_ZERO) && (dma->count==0))
759    {
760        dma->control &= ~ST_STOP;
761        if (LOG_DMA) logerror("DMA terminated\n");
762    }
763   
764    // Interrupt if count is zero, and interrupt flag set
765    if((dma->control & INTERRUPT_ON_ZERO) && (dma->count==0))
766    {
767      if (LOG_DMA) logerror("DMA%d - requesting interrupt: count = %04X, source = %04X\n", which, dma->count, dma->source);
768      i186.intr.request |= 0x04 << which;
769      update_interrupt_state(machine);     
770    }
771}
772
773/*-------------------------------------------------------------------------*/
774/* Name: rmnimbus                                                            */
775/* Desc: CPU - Initialize the 80186 CPU                                    */
776/*-------------------------------------------------------------------------*/
777static void nimbus_cpu_init(running_machine *machine)
778{
779
780    logerror("Machine reset\n");
781   
782   /* create timers here so they stick around */
783   i186.timer[0].int_timer = timer_alloc(machine, internal_timer_int, NULL);
784   i186.timer[1].int_timer = timer_alloc(machine, internal_timer_int, NULL);
785   i186.timer[2].int_timer = timer_alloc(machine, internal_timer_int, NULL);
786   i186.timer[0].time_timer = timer_alloc(machine, NULL, NULL);
787   i186.timer[1].time_timer = timer_alloc(machine, NULL, NULL);
788   i186.timer[2].time_timer = timer_alloc(machine, NULL, NULL);
789   i186.dma[0].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
790   i186.dma[1].finish_timer = timer_alloc(machine, dma_timer_callback, NULL);
791}
792
793static void nimbus_cpu_reset(running_machine *machine)
794{
795      /* reset the interrupt state */
796   i186.intr.priority_mask       = 0x0007;
797   i186.intr.timer          = 0x000f;
798   i186.intr.dma[0]         = 0x000f;
799   i186.intr.dma[1]         = 0x000f;
800   i186.intr.ext[0]         = 0x000f;
801   i186.intr.ext[1]         = 0x000f;
802   i186.intr.ext[2]         = 0x000f;
803   i186.intr.ext[3]         = 0x000f;
804    i186.intr.in_service        = 0x0000;
805   
806    /* External vectors by default to internal int 0/1 vectors */
807    i186.intr.ext_vector[0]      = 0x000C;
808   i186.intr.ext_vector[1]      = 0x000D;
809   
810    i186.intr.pending           = 0x0000;
811   i186.intr.ack_mask          = 0x0000;
812   i186.intr.request           = 0x0000;
813   i186.intr.status            = 0x0000;
814   i186.intr.poll_status       = 0x0000;
815   
816    logerror("CPU reset done\n");
817}
818
819READ16_HANDLER( i186_internal_port_r )
820{
821   int temp, which;
822
823   switch (offset)
824   {
825      case 0x11:
826         logerror("%05X:ERROR - read from 80186 EOI\n", cpu_get_pc(space->cpu));
827         break;
828
829      case 0x12:
830         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll\n", cpu_get_pc(space->cpu));
831         if (i186.intr.poll_status & 0x8000)
832            int_callback(cputag_get_cpu(space->machine, MAINCPU_TAG), 0);
833         return i186.intr.poll_status;
834
835      case 0x13:
836         if (LOG_PORTS) logerror("%05X:read 80186 interrupt poll status\n", cpu_get_pc(space->cpu));
837         return i186.intr.poll_status;
838
839      case 0x14:
840         if (LOG_PORTS) logerror("%05X:read 80186 interrupt mask\n", cpu_get_pc(space->cpu));
841         temp  = (i186.intr.timer  >> 3) & 0x01;
842         temp |= (i186.intr.dma[0] >> 1) & 0x04;
843         temp |= (i186.intr.dma[1] >> 0) & 0x08;
844         temp |= (i186.intr.ext[0] << 1) & 0x10;
845         temp |= (i186.intr.ext[1] << 2) & 0x20;
846         temp |= (i186.intr.ext[2] << 3) & 0x40;
847         temp |= (i186.intr.ext[3] << 4) & 0x80;
848         return temp;
849
850      case 0x15:
851         if (LOG_PORTS) logerror("%05X:read 80186 interrupt priority mask\n", cpu_get_pc(space->cpu));
852         return i186.intr.priority_mask;
853
854      case 0x16:
855         if (LOG_PORTS) logerror("%05X:read 80186 interrupt in-service\n", cpu_get_pc(space->cpu));
856         return i186.intr.in_service;
857
858      case 0x17:
859         if (LOG_PORTS) logerror("%05X:read 80186 interrupt request\n", cpu_get_pc(space->cpu));
860         temp = i186.intr.request & ~0x0001;
861         if (i186.intr.status & 0x0007)
862            temp |= 1;
863         return temp;
864
865      case 0x18:
866         if (LOG_PORTS) logerror("%05X:read 80186 interrupt status\n", cpu_get_pc(space->cpu));
867         return i186.intr.status;
868
869      case 0x19:
870         if (LOG_PORTS) logerror("%05X:read 80186 timer interrupt control\n", cpu_get_pc(space->cpu));
871         return i186.intr.timer;
872
873      case 0x1a:
874         if (LOG_PORTS) logerror("%05X:read 80186 DMA 0 interrupt control\n", cpu_get_pc(space->cpu));
875         return i186.intr.dma[0];
876
877      case 0x1b:
878         if (LOG_PORTS) logerror("%05X:read 80186 DMA 1 interrupt control\n", cpu_get_pc(space->cpu));
879         return i186.intr.dma[1];
880
881      case 0x1c:
882         if (LOG_PORTS) logerror("%05X:read 80186 INT 0 interrupt control\n", cpu_get_pc(space->cpu));
883         return i186.intr.ext[0];
884
885      case 0x1d:
886         if (LOG_PORTS) logerror("%05X:read 80186 INT 1 interrupt control\n", cpu_get_pc(space->cpu));
887         return i186.intr.ext[1];
888
889      case 0x1e:
890         if (LOG_PORTS) logerror("%05X:read 80186 INT 2 interrupt control\n", cpu_get_pc(space->cpu));
891         return i186.intr.ext[2];
892
893      case 0x1f:
894         if (LOG_PORTS) logerror("%05X:read 80186 INT 3 interrupt control\n", cpu_get_pc(space->cpu));
895         return i186.intr.ext[3];
896
897      case 0x28:
898      case 0x2c:
899      case 0x30:
900         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d count\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4);
901         which = (offset - 0x28) / 4;
902         if (!(offset & 1))
903            internal_timer_sync(which);
904         return i186.timer[which].count;
905
906      case 0x29:
907      case 0x2d:
908      case 0x31:
909         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d max A\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4);
910         which = (offset - 0x29) / 4;
911         return i186.timer[which].maxA;
912
913      case 0x2a:
914      case 0x2e:
915         logerror("%05X:read 80186 Timer %d max B\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4);
916         which = (offset - 0x2a) / 4;
917         return i186.timer[which].maxB;
918
919      case 0x2b:
920      case 0x2f:
921      case 0x33:
922         if (LOG_PORTS) logerror("%05X:read 80186 Timer %d control\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4);
923         which = (offset - 0x2b) / 4;
924         return i186.timer[which].control;
925
926      case 0x50:
927         if (LOG_PORTS) logerror("%05X:read 80186 upper chip select\n", cpu_get_pc(space->cpu));
928         return i186.mem.upper;
929
930      case 0x51:
931         if (LOG_PORTS) logerror("%05X:read 80186 lower chip select\n", cpu_get_pc(space->cpu));
932         return i186.mem.lower;
933
934      case 0x52:
935         if (LOG_PORTS) logerror("%05X:read 80186 peripheral chip select\n", cpu_get_pc(space->cpu));
936         return i186.mem.peripheral;
937
938      case 0x53:
939         if (LOG_PORTS) logerror("%05X:read 80186 middle chip select\n", cpu_get_pc(space->cpu));
940         return i186.mem.middle;
941
942      case 0x54:
943         if (LOG_PORTS) logerror("%05X:read 80186 middle P chip select\n", cpu_get_pc(space->cpu));
944         return i186.mem.middle_size;
945
946      case 0x60:
947      case 0x68:
948         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower source address\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8);
949         which = (offset - 0x60) / 8;
950//          stream_update(dma_stream, 0);
951         return i186.dma[which].source;
952
953      case 0x61:
954      case 0x69:
955         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper source address\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8);
956         which = (offset - 0x61) / 8;
957//          stream_update(dma_stream, 0);
958         return i186.dma[which].source >> 16;
959
960      case 0x62:
961      case 0x6a:
962         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d lower dest address\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8);
963         which = (offset - 0x62) / 8;
964//          stream_update(dma_stream, 0);
965         return i186.dma[which].dest;
966
967      case 0x63:
968      case 0x6b:
969         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d upper dest address\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8);
970         which = (offset - 0x63) / 8;
971//          stream_update(dma_stream, 0);
972         return i186.dma[which].dest >> 16;
973
974      case 0x64:
975      case 0x6c:
976         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d transfer count\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8);
977         which = (offset - 0x64) / 8;
978//          stream_update(dma_stream, 0);
979         return i186.dma[which].count;
980
981      case 0x65:
982      case 0x6d:
983         if (LOG_PORTS) logerror("%05X:read 80186 DMA%d control\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8);
984         which = (offset - 0x65) / 8;
985//          stream_update(dma_stream, 0);
986         return i186.dma[which].control;
987
988      default:
989         logerror("%05X:read 80186 port %02X\n", cpu_get_pc(space->cpu), offset);
990         break;
991   }
992   return 0x00;
993}
994
995/*************************************
996 *
997 *  80186 internal I/O writes
998 *
999 *************************************/
1000
1001WRITE16_HANDLER( i186_internal_port_w )
1002{
1003   int temp, which, data16 = data;
1004
1005   switch (offset)
1006   {
1007      case 0x11:
1008         if (LOG_PORTS) logerror("%05X:80186 EOI = %04X\n", cpu_get_pc(space->cpu), data16);
1009         handle_eoi(space->machine,0x8000);
1010         update_interrupt_state(space->machine);
1011         break;
1012
1013      case 0x12:
1014         logerror("%05X:ERROR - write to 80186 interrupt poll = %04X\n", cpu_get_pc(space->cpu), data16);
1015         break;
1016
1017      case 0x13:
1018         logerror("%05X:ERROR - write to 80186 interrupt poll status = %04X\n", cpu_get_pc(space->cpu), data16);
1019         break;
1020
1021      case 0x14:
1022         if (LOG_PORTS) logerror("%05X:80186 interrupt mask = %04X\n", cpu_get_pc(space->cpu), data16);
1023         i186.intr.timer  = (i186.intr.timer  & ~0x08) | ((data16 << 3) & 0x08);
1024         i186.intr.dma[0] = (i186.intr.dma[0] & ~0x08) | ((data16 << 1) & 0x08);
1025         i186.intr.dma[1] = (i186.intr.dma[1] & ~0x08) | ((data16 << 0) & 0x08);
1026         i186.intr.ext[0] = (i186.intr.ext[0] & ~0x08) | ((data16 >> 1) & 0x08);
1027         i186.intr.ext[1] = (i186.intr.ext[1] & ~0x08) | ((data16 >> 2) & 0x08);
1028         i186.intr.ext[2] = (i186.intr.ext[2] & ~0x08) | ((data16 >> 3) & 0x08);
1029         i186.intr.ext[3] = (i186.intr.ext[3] & ~0x08) | ((data16 >> 4) & 0x08);
1030         update_interrupt_state(space->machine);
1031         break;
1032
1033      case 0x15:
1034         if (LOG_PORTS) logerror("%05X:80186 interrupt priority mask = %04X\n", cpu_get_pc(space->cpu), data16);
1035         i186.intr.priority_mask = data16 & 0x0007;
1036         update_interrupt_state(space->machine);
1037         break;
1038
1039      case 0x16:
1040         if (LOG_PORTS) logerror("%05X:80186 interrupt in-service = %04X\n", cpu_get_pc(space->cpu), data16);
1041         i186.intr.in_service = data16 & 0x00ff;
1042         update_interrupt_state(space->machine);
1043         break;
1044
1045      case 0x17:
1046         if (LOG_PORTS) logerror("%05X:80186 interrupt request = %04X\n", cpu_get_pc(space->cpu), data16);
1047         i186.intr.request = (i186.intr.request & ~0x00c0) | (data16 & 0x00c0);
1048         update_interrupt_state(space->machine);
1049         break;
1050
1051      case 0x18:
1052         if (LOG_PORTS) logerror("%05X:WARNING - wrote to 80186 interrupt status = %04X\n", cpu_get_pc(space->cpu), data16);
1053         i186.intr.status = (i186.intr.status & ~0x8007) | (data16 & 0x8007);
1054         update_interrupt_state(space->machine);
1055         break;
1056
1057      case 0x19:
1058         if (LOG_PORTS) logerror("%05X:80186 timer interrupt contol = %04X\n", cpu_get_pc(space->cpu), data16);
1059         i186.intr.timer = data16 & 0x000f;
1060         break;
1061
1062      case 0x1a:
1063         if (LOG_PORTS) logerror("%05X:80186 DMA 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1064         i186.intr.dma[0] = data16 & 0x000f;
1065         break;
1066
1067      case 0x1b:
1068         if (LOG_PORTS) logerror("%05X:80186 DMA 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1069         i186.intr.dma[1] = data16 & 0x000f;
1070         break;
1071
1072      case 0x1c:
1073         if (LOG_PORTS) logerror("%05X:80186 INT 0 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1074         i186.intr.ext[0] = data16 & 0x007f;
1075         break;
1076
1077      case 0x1d:
1078         if (LOG_PORTS) logerror("%05X:80186 INT 1 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1079         i186.intr.ext[1] = data16 & 0x007f;
1080         break;
1081
1082      case 0x1e:
1083         if (LOG_PORTS) logerror("%05X:80186 INT 2 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1084         i186.intr.ext[2] = data16 & 0x001f;
1085         break;
1086
1087      case 0x1f:
1088         if (LOG_PORTS) logerror("%05X:80186 INT 3 interrupt control = %04X\n", cpu_get_pc(space->cpu), data16);
1089         i186.intr.ext[3] = data16 & 0x001f;
1090         break;
1091
1092      case 0x28:
1093      case 0x2c:
1094      case 0x30:
1095         if (LOG_PORTS) logerror("%05X:80186 Timer %d count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x28) / 4, data16);
1096         which = (offset - 0x28) / 4;
1097         internal_timer_update(space->machine,which, data16, -1, -1, -1);
1098         break;
1099
1100      case 0x29:
1101      case 0x2d:
1102      case 0x31:
1103         if (LOG_PORTS) logerror("%05X:80186 Timer %d max A = %04X\n", cpu_get_pc(space->cpu), (offset - 0x29) / 4, data16);
1104         which = (offset - 0x29) / 4;
1105         internal_timer_update(space->machine,which, -1, data16, -1, -1);
1106         break;
1107
1108      case 0x2a:
1109      case 0x2e:
1110         if (LOG_PORTS) logerror("%05X:80186 Timer %d max B = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2a) / 4, data16);
1111         which = (offset - 0x2a) / 4;
1112         internal_timer_update(space->machine,which, -1, -1, data16, -1);
1113         break;
1114
1115      case 0x2b:
1116      case 0x2f:
1117      case 0x33:
1118         if (LOG_PORTS) logerror("%05X:80186 Timer %d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x2b) / 4, data16);
1119         which = (offset - 0x2b) / 4;
1120         internal_timer_update(space->machine,which, -1, -1, -1, data16);
1121         break;
1122
1123      case 0x50:
1124         if (LOG_PORTS) logerror("%05X:80186 upper chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1125         i186.mem.upper = data16 | 0xc038;
1126         break;
1127
1128      case 0x51:
1129         if (LOG_PORTS) logerror("%05X:80186 lower chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1130         i186.mem.lower = (data16 & 0x3fff) | 0x0038; printf("%X",i186.mem.lower);
1131         break;
1132
1133      case 0x52:
1134         if (LOG_PORTS) logerror("%05X:80186 peripheral chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1135         i186.mem.peripheral = data16 | 0x0038;
1136         break;
1137
1138      case 0x53:
1139         if (LOG_PORTS) logerror("%05X:80186 middle chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1140         i186.mem.middle = data16 | 0x01f8;
1141         break;
1142
1143      case 0x54:
1144         if (LOG_PORTS) logerror("%05X:80186 middle P chip select = %04X\n", cpu_get_pc(space->cpu), data16);
1145         i186.mem.middle_size = data16 | 0x8038;
1146
1147         temp = (i186.mem.peripheral & 0xffc0) << 4;
1148         if (i186.mem.middle_size & 0x0040)
1149         {
1150//              install_mem_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1151//              install_mem_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1152         }
1153         else
1154         {
1155            temp &= 0xffff;
1156//              install_port_read_handler(2, temp, temp + 0x2ff, peripheral_r);
1157//              install_port_write_handler(2, temp, temp + 0x2ff, peripheral_w);
1158         }
1159
1160         /* we need to do this at a time when the I86 context is swapped in */
1161         /* this register is generally set once at startup and never again, so it's a good */
1162         /* time to set it up */
1163         cpu_set_irq_callback(space->cpu, int_callback);
1164         break;
1165
1166      case 0x60:
1167      case 0x68:
1168         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x60) / 8, data16);
1169         which = (offset - 0x60) / 8;
1170//          stream_update(dma_stream, 0);
1171         i186.dma[which].source = (i186.dma[which].source & ~0x0ffff) | (data16 & 0x0ffff);
1172         break;
1173
1174      case 0x61:
1175      case 0x69:
1176         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper source address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x61) / 8, data16);
1177         which = (offset - 0x61) / 8;
1178//          stream_update(dma_stream, 0);
1179         i186.dma[which].source = (i186.dma[which].source & ~0xf0000) | ((data16 << 16) & 0xf0000);
1180         break;
1181
1182      case 0x62:
1183      case 0x6a:
1184         if (LOG_PORTS) logerror("%05X:80186 DMA%d lower dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x62) / 8, data16);
1185         which = (offset - 0x62) / 8;
1186//          stream_update(dma_stream, 0);
1187         i186.dma[which].dest = (i186.dma[which].dest & ~0x0ffff) | (data16 & 0x0ffff);
1188         break;
1189
1190      case 0x63:
1191      case 0x6b:
1192         if (LOG_PORTS) logerror("%05X:80186 DMA%d upper dest address = %04X\n", cpu_get_pc(space->cpu), (offset - 0x63) / 8, data16);
1193         which = (offset - 0x63) / 8;
1194//          stream_update(dma_stream, 0);
1195         i186.dma[which].dest = (i186.dma[which].dest & ~0xf0000) | ((data16 << 16) & 0xf0000);
1196         break;
1197
1198      case 0x64:
1199      case 0x6c:
1200         if (LOG_PORTS) logerror("%05X:80186 DMA%d transfer count = %04X\n", cpu_get_pc(space->cpu), (offset - 0x64) / 8, data16);
1201         which = (offset - 0x64) / 8;
1202//          stream_update(dma_stream, 0);
1203         i186.dma[which].count = data16;
1204         break;
1205
1206      case 0x65:
1207      case 0x6d:
1208         if (LOG_PORTS) logerror("%05X:80186 DMA%d control = %04X\n", cpu_get_pc(space->cpu), (offset - 0x65) / 8, data16);
1209         which = (offset - 0x65) / 8;
1210//          stream_update(dma_stream, 0);
1211         update_dma_control(space->machine, which, data16);
1212         break;
1213
1214      case 0x7f:
1215         if (LOG_PORTS) logerror("%05X:80186 relocation register = %04X\n", cpu_get_pc(space->cpu), data16);
1216
1217         /* we assume here there that this doesn't happen too often */
1218         /* plus, we can't really remove the old memory range, so we also assume that it's */
1219         /* okay to leave us mapped where we were */
1220         temp = (data16 & 0x0fff) << 8;
1221         if (data16 & 0x1000)
1222         {
1223            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1224            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_PROGRAM), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1225         }
1226         else
1227         {
1228            temp &= 0xffff;
1229            memory_install_read16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_r);
1230            memory_install_write16_handler(cputag_get_address_space(space->machine, MAINCPU_TAG, ADDRESS_SPACE_IO), temp, temp + 0xff, 0, 0, i186_internal_port_w);
1231         }
1232/*          popmessage("Sound CPU reset");*/
1233         break;
1234
1235      default:
1236         logerror("%05X:80186 port %02X = %04X\n", cpu_get_pc(space->cpu), offset, data16);
1237         break;
1238   }
1239}
1240
1241MACHINE_RESET(nimbus)
1242{
1243   /* CPU */
1244   nimbus_cpu_reset(machine);
1245    fdc_reset();
1246    keyboard_reset();
1247}
1248
1249DRIVER_INIT(nimbus)
1250{
1251}
1252
1253MACHINE_START( nimbus )
1254{
1255    /* init cpu */
1256    nimbus_cpu_init(machine);
1257
1258    keyboard.keyscan_timer=timer_alloc(machine, keyscan_callback, NULL);
1259   
1260   /* setup debug commands */
1261   if (machine->debug_flags & DEBUG_FLAG_ENABLED)
1262   {
1263      debug_console_register_command(machine, "nimbus_irq", CMDFLAG_NONE, 0, 0, 1, execute_debug_irq);
1264        debug_console_register_command(machine, "nimbus_intmasks", CMDFLAG_NONE, 0, 0, 0, execute_debug_intmasks);
1265
1266        /* set up the instruction hook */
1267        debug_cpu_set_instruction_hook(cputag_get_cpu(machine, MAINCPU_TAG), instruction_hook);
1268     
1269    }
1270}
1271
1272static void execute_debug_irq(running_machine *machine, int ref, int params, const char *param[])
1273{
1274    int IntNo;
1275    int IntMask;
1276   
1277    if(params>0)
1278    {   
1279        sscanf(param[0],"%d",&IntNo);
1280       
1281        IntMask=0x0000;
1282   
1283        switch (IntNo)
1284        {
1285            case 0  : IntMask=0x010; break;
1286            case 1  : IntMask=0x020; break;
1287            case 2  : IntMask=0x040; break;
1288            case 3  : IntMask=0x080; break;
1289        }
1290       
1291        i186.intr.request |= IntMask;
1292        update_interrupt_state(machine);
1293       
1294        debug_console_printf(machine,"triggering IRQ%d, IntMask=%4.4X, i186.intr.request=%4.4X\n",IntNo,IntMask,i186.intr.request);
1295       
1296//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, HOLD_LINE );
1297//        cputag_set_input_line(machine, MAINCPU_TAG, IntNo, CLEAR_LINE );
1298       
1299    }
1300    else
1301    {
1302        debug_console_printf(machine,"Error, you must supply an intno to trigger\n");
1303    }
1304   
1305   
1306}
1307
1308
1309static void execute_debug_intmasks(running_machine *machine, int ref, int params, const char *param[])
1310{
1311    int IntNo;
1312   
1313   
1314    debug_console_printf(machine,"i186.intr.priority_mask=%4X\n",i186.intr.priority_mask);
1315    for(IntNo=0; IntNo<4; IntNo++)
1316    {
1317        debug_console_printf(machine,"extInt%d mask=%4X\n",IntNo,i186.intr.ext[IntNo]);
1318    }
1319   
1320    debug_console_printf(machine,"i186.intr.request   = %04X\n",i186.intr.request);
1321    debug_console_printf(machine,"i186.intr.ack_mask  = %04X\n",i186.intr.ack_mask);
1322    debug_console_printf(machine,"i186.intr.in_service= %04X\n",i186.intr.in_service);
1323}
1324
1325/*-----------------------------------------------
1326    instruction_hook - per-instruction hook
1327-----------------------------------------------*/
1328
1329static int instruction_hook(const device_config *device, offs_t curpc)
1330{
1331    const address_space *space = cpu_get_address_space(device, ADDRESS_SPACE_PROGRAM);
1332    UINT8               *addr_ptr;
1333   
1334    addr_ptr = memory_get_read_ptr(space,curpc);
1335       
1336    if ((addr_ptr !=NULL) && (addr_ptr[0]==0xCD) && (addr_ptr[1]==0xF0))
1337        decode_subbios(device,curpc);
1338   
1339    return 0;
1340}
1341
1342#define set_type(type_name)     sprintf(type_str,type_name)
1343#define set_drv(drv_name)       sprintf(drv_str,drv_name)
1344#define set_func(func_name)     sprintf(func_str,func_name)
1345
1346static void decode_subbios(const device_config *device,offs_t pc)
1347{
1348    char    type_str[80];
1349    char    drv_str[80];
1350    char    func_str[80];
1351   
1352    void (*dump_dssi)(const device_config *,UINT16, UINT16) = NULL;
1353
1354    const device_config *cpu = cputag_get_cpu(device->machine,MAINCPU_TAG);
1355   
1356    UINT16  ax = cpu_get_reg(cpu,I8086_AX);
1357    UINT16  bx = cpu_get_reg(cpu,I8086_BX);
1358    UINT16  cx = cpu_get_reg(cpu,I8086_CX);
1359    UINT16  ds = cpu_get_reg(cpu,I8086_DS);
1360    UINT16  si = cpu_get_reg(cpu,I8086_SI);
1361   
1362    logerror("=======================================================================\n");
1363    logerror("Sub-bios call at %08X, AX=%04X, BX=%04X, CX=%04X, DS:SI=%04X:%04X\n",pc,ax,bx,cx,ds,si);
1364
1365    set_type("invalid");
1366    set_drv("invalid");
1367    set_func("invalid");
1368   
1369
1370    switch (cx)
1371    {
1372        case 0   :
1373        {
1374            set_type("t_mummu");
1375            set_drv("d_mummu");
1376           
1377            switch (ax)
1378            {
1379                case 0  : set_func("f_get_version_number"); break;
1380                case 1  : set_func("f_add_type_code"); break;
1381                case 2  : set_func("f_del_typc_code"); break;
1382                case 3  : set_func("f_get_TCB"); break;
1383                case 4  : set_func("f_add_driver_code"); break;
1384                case 5  : set_func("f_del_driver_code"); break;
1385                case 6  : set_func("f_get_DCB"); break;
1386                case 7  : set_func("f_get_copyright"); break;
1387            }
1388        }; break;
1389       
1390        case 1   :
1391        {
1392            set_type("t_character");
1393            set_drv("d_printer");
1394           
1395            switch(ax)
1396            {
1397                case 0  : set_func("f_get_version_number"); break;
1398                case 1  : set_func("f_get_output_status"); break;
1399                case 2  : set_func("f_output_character"); break;
1400                case 3  : set_func("f_get_input_status"); break;
1401                case 4  : set_func("f_get_and_remove"); break;
1402                case 5  : set_func("f_get_no_remove"); break;
1403                case 6  : set_func("f_get_last_and_remove"); break;
1404                case 7  : set_func("f_get_last_no_remove"); break;
1405                case 8  : set_func("f_set_IO_parameters"); break;
1406            }
1407        }; break;
1408       
1409        case 2   :
1410        {
1411            set_type("t_disk");
1412           
1413            switch(bx)
1414            {
1415                case 0  : set_drv("d_floppy"); break;
1416                case 1  : set_drv("d_winchester"); break;
1417                case 2  : set_drv("d_tape"); break;
1418                case 3  : set_drv("d_rompack"); break;
1419                case 4  : set_drv("d_eeprom"); break;
1420            }
1421           
1422            switch(ax)
1423            {
1424                case 0  : set_func("f_get_version_number"); break;           
1425                case 1  : set_func("f_initialise_unit"); break;
1426                case 2  : set_func("f_pseudo_init_unit"); break;
1427                case 3  : set_func("f_get_device_status"); break;
1428                case 4  : set_func("f_read_n_sectors"); break;
1429                case 5  : set_func("f_write_n_sectors"); break;
1430                case 6  : set_func("f_verify_n_sectors"); break;
1431                case 7  : set_func("f_media_check"); break;
1432                case 8  : set_func("f_recalibrate"); break;
1433                case 9  : set_func("f_motors_off"); break;
1434            }
1435           
1436        }; break;
1437       
1438        case 3   :
1439        {
1440            set_type("t_piconet");
1441            switch(ax)
1442            {
1443                case 0  : set_func("f_get_version_number"); break;           
1444            }
1445        }; break;
1446       
1447        case 4   :
1448        {
1449            set_type("t_tick");
1450            set_drv("d_tick");
1451           
1452            switch(ax)
1453            {
1454                case 0  : set_func("f_get_version_number"); break;
1455                case 1  : set_func("f_ticks_per_second"); break;
1456                case 2  : set_func("f_link_tick_routine"); break;
1457                case 3  : set_func("f_unlink_tick_routine"); break;           
1458            }
1459        }; break;
1460       
1461        case 5   :
1462        {
1463            set_type("t_graphics_input");
1464            switch(ax)
1465            {
1466                case 0  : set_func("f_get_version_number"); break;           
1467            }
1468        }; break;
1469       
1470        case 6   :
1471        {
1472            set_type("t_graphics_output");
1473            set_drv("d_ngc_screen");
1474
1475            switch(ax)
1476            {
1477                case 0  : set_func("f_get_version_number");                 break;
1478                case 1  : set_func("f_graphics_output_cold_start");         break;
1479                case 2  : set_func("f_graphics_output_warm_start");         break;
1480                case 3  : set_func("f_graphics_output_off");                break;
1481                case 4  : set_func("f_reinit_graphics_output");             break;
1482                case 5  : set_func("f_polymarker");                         break;
1483                case 6  : set_func("f_polyline");                           break;
1484                case 7  : set_func("f_fill_area"); dump_dssi=&decode_dssi_f_fill_area; break;
1485                case 8  : set_func("f_flood_fill_area"); break;
1486                case 9  : set_func("f_plot_character_string"); dump_dssi=&decode_dssi_f_plot_character_string; break;
1487                case 10 : set_func("f_define_graphics_clipping_area"); break;
1488                case 11 : set_func("f_enquire_clipping_area_limits"); break;
1489                case 12 : set_func("f_select_graphics_clipping_area"); break;
1490                case 13 : set_func("f_enq_selctd_graphics_clip_area"); break;
1491                case 14 : set_func("f_set_clt_element"); break;
1492                case 15 : set_func("f_enquire_clt_element"); break;
1493                case 16 : set_func("f_set_new_clt"); dump_dssi=&decode_dssi_f_set_new_clt; break;
1494                case 17 : set_func("f_enquire_clt_contents"); break;
1495                case 18 : set_func("f_define_dithering_pattern"); break;
1496                case 19 : set_func("f_enquire_dithering_pattern"); break;
1497                case 20 : set_func("f_draw_sprite"); break;
1498                case 21 : set_func("f_move_sprite"); break;
1499                case 22 : set_func("f_erase_sprite"); break;
1500                case 23 : set_func("f_read_pixel"); break;
1501                case 24 : set_func("f_read_to_limit"); break;
1502                case 25 : set_func("f_read_area_pixel"); break;
1503                case 26 : set_func("f_write_area_pixel"); break;
1504                case 27 : set_func("f_copy_area_pixel"); break;
1505
1506                case 29 : set_func("f_read_area_word"); break;
1507                case 30 : set_func("f_write_area_word"); break;
1508                case 31 : set_func("f_copy_area_word"); break;
1509                case 32 : set_func("f_swap_area_word"); break;
1510                case 33 : set_func("f_set_border_colour"); break;
1511                case 34 : set_func("f_enquire_border_colour"); break;
1512                case 35 : set_func("f_enquire_miscellaneous_data"); break;
1513                case 36  : set_func("f_circle"); break;
1514
1515                case 38 : set_func("f_arc_of_ellipse"); break;
1516                case 39 : set_func("f_isin"); break;
1517                case 40 : set_func("f_icos"); break;
1518                case 41 : set_func("f_define_hatching_pattern"); break;
1519                case 42 : set_func("f_enquire_hatching_pattern"); break;
1520                case 43 : set_func("f_enquire_display_line"); break;
1521                case 44 : set_func("f_plonk_logo"); break;
1522            }
1523        }; break;
1524       
1525        case 7   :
1526        {
1527            set_type("t_zend");
1528            switch(ax)
1529            {
1530                case 0  : set_func("f_get_version_number"); break;           
1531            }
1532        }; break;
1533       
1534        case 8   :
1535        {
1536            set_type("t_zep");
1537            switch(ax)
1538            {
1539                case 0  : set_func("f_get_version_number"); break;           
1540            }
1541        }; break;
1542       
1543        case 9   :
1544        {
1545            set_type("t_raw_console");
1546           
1547            switch(bx)
1548            {
1549                case 0  :
1550                {
1551                    set_drv("d_screen");
1552           
1553                    switch(ax)
1554                    {
1555                        case 0  : set_func("f_get_version_number"); break;           
1556                        case 1  : set_func("f_plonk_char"); dump_dssi=decode_dssi_f_plonk_char; break;
1557                        case 2  : set_func("f_plonk_cursor"); break;
1558                        case 3  : set_func("f_kill_cursor"); break;
1559                        case 4  : set_func("f_scroll"); break;
1560                        case 5  : set_func("f_width"); break;
1561                        case 6  : set_func("f_get_char_set"); break;
1562                        case 7  : set_func("f_set_char_set"); break;
1563                        case 8  : set_func("f_reset_char_set"); break;
1564                        case 9  : set_func("f_set_plonk_parameters"); break;
1565                        case 10 : set_func("f_set_cursor_flash_rate"); break;
1566                    }
1567                }; break;
1568           
1569                case 1  :
1570                {
1571                    set_drv("d_keyboard");
1572                   
1573                    switch(ax)
1574                    {
1575                        case 0  : set_func("f_get_version_number"); break;           
1576                        case 1  : set_func("f_init_keyboard"); break;
1577                        case 2  : set_func("f_get_last_key_code"); break;
1578                        case 3  : set_func("f_get_bitmap"); break;
1579                    }
1580                }; break;
1581            }
1582        }; break;
1583       
1584        case 10   :
1585        {
1586            set_type("t_acoustics");
1587            switch(ax)
1588            {
1589                case 0  : set_func("f_get_version_number"); break;           
1590            }
1591        }; break;
1592       
1593        case 11   :
1594        {
1595            set_type("t_hard_sums");
1596            switch(ax)
1597            {
1598                case 0  : set_func("f_get_version_number"); break;           
1599            }
1600        }; break;   
1601    }
1602   
1603    logerror("Type=%s, Driver=%s, Function=%s\n",type_str,drv_str,func_str);
1604   
1605    if(dump_dssi!=NULL)
1606        dump_dssi(device,ds,si);
1607    logerror("=======================================================================\n");
1608}
1609
1610void *get_dssi_ptr(const address_space *space, UINT16   ds, UINT16 si)
1611{
1612    int             addr;
1613
1614    addr=((ds<<4)+si);
1615    OUTPUT_SEGOFS("DS:SI",ds,si);
1616
1617    return memory_get_read_ptr(space, addr);
1618}
1619
1620static void decode_dssi_f_fill_area(const device_config *device,UINT16  ds, UINT16 si)
1621{
1622    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1623 
1624    UINT16          *addr_ptr;
1625    t_area_params   *area_params;
1626    t_nimbus_brush  *brush;
1627    int             cocount;
1628
1629    area_params = get_dssi_ptr(space,ds,si);
1630   
1631    OUTPUT_SEGOFS("SegBrush:OfsBrush",area_params->seg_brush,area_params->ofs_brush);
1632    brush=memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_brush,area_params->ofs_brush));
1633   
1634    logerror("Brush params\n");
1635    logerror("Style=%04X,          StyleIndex=%04X\n",brush->style,brush->style_index);
1636    logerror("Colour1=%04X,        Colour2=%04X\n",brush->colour1,brush->colour2);
1637    logerror("transparency=%04X,   boundry_spec=%04X\n",brush->transparency,brush->boundary_spec);
1638    logerror("boundry colour=%04X, save colour=%04X\n",brush->boundary_colour,brush->save_colour);
1639           
1640   
1641    OUTPUT_SEGOFS("SegData:OfsData",area_params->seg_data,area_params->ofs_data);
1642   
1643    addr_ptr = memory_get_read_ptr(space, LINEAR_ADDR(area_params->seg_data,area_params->ofs_data));
1644    for(cocount=0; cocount < area_params->count; cocount++)
1645    {
1646        logerror("x=%d y=%d\n",addr_ptr[cocount*2],addr_ptr[(cocount*2)+1]);
1647    }
1648}
1649
1650static void decode_dssi_f_plot_character_string(const device_config *device,UINT16  ds, UINT16 si)
1651{
1652    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1653 
1654    UINT8          *char_ptr;
1655    t_plot_string_params   *plot_string_params;
1656    int             charno;
1657       
1658    plot_string_params=get_dssi_ptr(space,ds,si);
1659   
1660    OUTPUT_SEGOFS("SegFont:OfsFont",plot_string_params->seg_font,plot_string_params->ofs_font);
1661    OUTPUT_SEGOFS("SegData:OfsData",plot_string_params->seg_data,plot_string_params->ofs_data);
1662   
1663    logerror("x=%d, y=%d, length=%d\n",plot_string_params->x,plot_string_params->y,plot_string_params->length);
1664   
1665    char_ptr=memory_get_read_ptr(space, LINEAR_ADDR(plot_string_params->seg_data,plot_string_params->ofs_data));
1666
1667    if (plot_string_params->length==0xFFFF)
1668        logerror("%s",char_ptr);
1669    else
1670        for(charno=0;charno<plot_string_params->length;charno++)
1671            logerror("%c",char_ptr[charno]);
1672       
1673    logerror("\n");
1674}
1675
1676static void decode_dssi_f_set_new_clt(const device_config *device,UINT16  ds, UINT16 si)
1677{
1678    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1679    UINT16  *new_colours;
1680    int     colour;
1681    new_colours=get_dssi_ptr(space,ds,si);
1682   
1683    OUTPUT_SEGOFS("SegColours:OfsColours",ds,si);
1684   
1685    for(colour=0;colour<16;colour++)
1686        logerror("colour #%02X=%04X\n",colour,new_colours[colour]);
1687   
1688}
1689
1690static void decode_dssi_f_plonk_char(const device_config *device,UINT16  ds, UINT16 si)
1691{
1692    const address_space *space = cputag_get_address_space(device->machine,MAINCPU_TAG, ADDRESS_SPACE_PROGRAM);
1693    UINT16  *params;
1694    params=get_dssi_ptr(space,ds,si);
1695   
1696    OUTPUT_SEGOFS("SegParams:OfsParams",ds,si);
1697
1698    logerror("plonked_char=%c\n",params[0]);
1699}
1700
1701
1702READ16_HANDLER( nimbus_io_r )
1703{
1704    int pc=cpu_get_pc(space->cpu);
1705   
1706    logerror("Nimbus IOR at pc=%08X from %04X mask=%04X, data=%04X\n",pc,(offset*2)+0x30,mem_mask,IOPorts[offset]);
1707   
1708    switch (offset*2)
1709    {
1710        default         : return IOPorts[offset]; break;
1711    }
1712    return 0;
1713}
1714
1715WRITE16_HANDLER( nimbus_io_w )
1716{
1717    int pc=cpu_get_pc(space->cpu);
1718
1719    logerror("Nimbus IOW at %08X write of %04X to %04X mask=%04X\n",pc,data,(offset*2)+0x30,mem_mask);
1720   
1721    switch (offset*2)
1722    {
1723        default         : COMBINE_DATA(&IOPorts[offset]); break;
1724    }
1725}
1726
1727
1728/*
1729    Keyboard emulation
1730   
1731*/
1732
1733static void keyboard_reset(void)
1734{
1735    memset(keyboard.keyrows,0xFF,NIMBUS_KEYROWS);
1736   
1737    // Setup timer to scan keyboard.
1738    timer_adjust_periodic(keyboard.keyscan_timer, attotime_zero, 0, ATTOTIME_IN_HZ(50));
1739
1740}
1741
1742static void queue_scancode(UINT8 scancode)
1743{
1744   keyboard.queue[keyboard.head] = scancode;
1745   keyboard.head++;
1746   keyboard.head %= ARRAY_LENGTH(keyboard.queue);
1747}
1748
1749static int keyboard_queue_read(void)
1750{
1751   int data;
1752   if (keyboard.tail == keyboard.head)
1753      return -1;
1754
1755   data = keyboard.queue[keyboard.tail];
1756
1757   if (LOG_KEYBOARD)
1758      logerror("keyboard_queue_read(): Keyboard Read 0x%02x\n",data);
1759
1760   keyboard.tail++;
1761   keyboard.tail %= ARRAY_LENGTH(keyboard.queue);
1762   return data;
1763}
1764
1765static TIMER_CALLBACK(keyscan_callback)
1766{
1767    UINT8   keyrow;
1768    UINT8   row;
1769    UINT8   bitno;
1770    UINT8   mask;
1771    static const char *const keynames[] = {
1772        "KEY0", "KEY1", "KEY2", "KEY3", "KEY4",
1773        "KEY5", "KEY6", "KEY7", "KEY8", "KEY9",
1774        "KEY10"
1775    };
1776
1777    for(row=0;row<NIMBUS_KEYROWS;row++)
1778    {
1779        keyrow=input_port_read(machine, keynames[row]);
1780       
1781        for(mask=0x80, bitno=7;mask>0;mask=mask>>1, bitno-=1)
1782        {
1783            if(!(keyrow & mask) && (keyboard.keyrows[row] & mask))
1784            {
1785                if (LOG_KEYBOARD) logerror("keypress %02X\n",(row<<3)+bitno);
1786                queue_scancode((row<<3)+bitno);
1787            }
1788   
1789            if((keyrow & mask) && !(keyboard.keyrows[row] & mask))
1790            {
1791                if (LOG_KEYBOARD) logerror("keyrelease %02X\n",0x80+(row<<3)+bitno); 
1792                queue_scancode(0x80+(row<<3)+bitno);
1793            }
1794        }
1795       
1796        keyboard.keyrows[row]=keyrow;
1797    }
1798}
1799
1800
1801/*
1802
1803Z80SIO, used for the keyboard interface
1804
1805*/
1806
1807READ8_DEVICE_HANDLER( sio_r )
1808{
1809    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1810    UINT8 result = 0;
1811   
1812   switch (offset*2)
1813   {
1814        case 0 :
1815            result=z80sio_d_r(device, 0);
1816            break;
1817        case 2 :
1818            result=z80sio_d_r(device, 1);
1819            break;
1820        case 4 :
1821            result=z80sio_c_r(device, 0);
1822            break;
1823        case 6 :
1824            result=z80sio_c_r(device, 1);
1825            break;
1826   }
1827
1828    if(LOG_SIO)
1829        logerror("Nimbus SIOR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0xF0,result);
1830
1831   return result;
1832}
1833
1834WRITE8_DEVICE_HANDLER( sio_w )
1835{
1836    int pc=cpu_get_pc(cputag_get_cpu(device->machine,MAINCPU_TAG));
1837
1838    if(LOG_SIO)
1839        logerror("Nimbus SIOW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0xF0);
1840
1841   switch (offset*2)
1842   {
1843        case 0 :
1844            z80sio_d_w(device, 0, data);
1845            break;
1846        case 2 :
1847            z80sio_d_w(device, 1, data);
1848            break;
1849        case 4 :
1850            z80sio_c_w(device, 0, data);
1851            break;
1852        case 5 :
1853            z80sio_c_w(device, 1, data);
1854            break;
1855   }
1856}
1857
1858/* Z80 SIO/2 */
1859
1860void sio_interrupt(const device_config *device, int state)
1861{
1862    if(LOG_SIO)
1863        logerror("SIO Interrupt state=%02X\n",state);
1864
1865    // Don't re-trigger if already active !
1866    if(state!=sio_int_state)
1867    {
1868        sio_int_state=state;
1869       
1870        if(state)
1871            external_int(device->machine,0,0x9C);
1872    }
1873}
1874
1875WRITE8_DEVICE_HANDLER( sio_dtr_w )
1876{
1877   if (offset == 1)
1878   {
1879   }
1880}
1881
1882WRITE8_DEVICE_HANDLER( sio_serial_transmit )
1883{
1884}
1885
1886int sio_serial_receive( const device_config *device, int channel )
1887{
1888   if(channel==0)
1889    {
1890        return keyboard_queue_read();     
1891    }
1892    else
1893        return -1;
1894}
1895
1896/* Floppy disk */
1897
1898static void fdc_reset(void)
1899{
1900    nimbus_fdc.irq_enabled=0;
1901    nimbus_fdc.drq_enabled=0;
1902    nimbus_fdc.diskno=0;
1903    nimbus_fdc.motor_on=0;
1904}
1905
1906static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_intrq_w )
1907{
1908    if(LOG_DISK)
1909        logerror("nimbus_fdc_intrq_w(%d)\n", state);
1910
1911    if(state && nimbus_fdc.irq_enabled)
1912    {
1913        external_int(device->machine,0,0x80);
1914    }
1915}
1916
1917static WRITE_LINE_DEVICE_HANDLER( nimbus_fdc_drq_w )
1918{
1919
1920    if(LOG_DISK)
1921        logerror("nimbus_fdc_drq_w(%d)\n", state);
1922   
1923    if(state && nimbus_fdc.drq_enabled)
1924        drq_callback(device->machine,1);
1925}
1926
1927READ8_HANDLER( nimbus_fdc_r )
1928{
1929      int result = 0;
1930   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1931    int pc=cpu_get_pc(space->cpu);
1932    const device_config *drive = devtag_get_device(space->machine, nimbus_wd17xx_interface.floppy_drive_tags[nimbus_fdc.diskno]);
1933   
1934    switch(offset*2)
1935   {
1936      case 0x08 :
1937         result = wd17xx_status_r(fdc, 0);
1938         if (LOG_DISK) logerror("Disk status=%2.2X\n",result);
1939         break;
1940      case 0x0A :
1941         result = wd17xx_track_r(fdc, 0);
1942         break;
1943      case 0x0C :
1944         result = wd17xx_sector_r(fdc, 0);
1945         break;
1946      case 0x0E :
1947         result = wd17xx_data_r(fdc, 0);
1948         break;
1949        case 0x10 :
1950            result = (nimbus_fdc.motor_on                                    ? 0x04 : 0x00) |
1951                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_INDEX) ? 0x00 : 0x02) |
1952                     (floppy_drive_get_flag_state(drive, FLOPPY_DRIVE_READY) ? 0x01 : 0x00);     
1953            break;
1954      default:
1955         break;
1956   }
1957
1958    if(LOG_DISK)
1959        logerror("Nimbus FDCR at pc=%08X from %04X data=%02X\n",pc,(offset*2)+0x400,result);
1960
1961   return result;
1962}
1963
1964WRITE8_HANDLER( nimbus_fdc_w )
1965{
1966   const device_config *fdc = devtag_get_device(space->machine, FDC_TAG);
1967    int pc=cpu_get_pc(space->cpu);
1968
1969    if(LOG_DISK)
1970        logerror("Nimbus FDCW at %08X write of %02X to %04X\n",pc,data,(offset*2)+0x400);
1971
1972    switch(offset*2)
1973   {
1974        case 0x00 :
1975            switch (data & 0x0F)
1976            {
1977                case 0x01 : nimbus_fdc.diskno=0; break;
1978                case 0x02 : nimbus_fdc.diskno=1; break;
1979                case 0x04 : nimbus_fdc.diskno=2; break;
1980                case 0x08 : nimbus_fdc.diskno=3; break; 
1981                //default : nimbus_fdc.diskno=NO_DRIVE_SELECTED; break; // no drive selected
1982            }
1983            if (nimbus_fdc.diskno!=NO_DRIVE_SELECTED)
1984            {
1985                wd17xx_set_drive(fdc, nimbus_fdc.diskno);
1986                wd17xx_set_side(fdc, (data & 0x10) ? 1 : 0);
1987            }
1988            nimbus_fdc.motor_on=(data & 0x20);
1989            nimbus_fdc.drq_enabled=(data & 0x80);
1990            nimbus_fdc.irq_enabled=1;
1991           
1992            // Nimbus FDC is hard wired for double density
1993            wd17xx_set_density(fdc, DEN_MFM_LO);
1994         break;
1995      case 0x08 :
1996         wd17xx_command_w(fdc, 0, data);
1997         break;
1998      case 0x0A :
1999         wd17xx_track_w(fdc, 0, data);
2000         break;
2001      case 0x0C :
2002         wd17xx_sector_w(fdc, 0, data);
2003         break;
2004      case 0x0E :
2005         wd17xx_data_w(fdc, 0, data);
2006         break;
2007   }
2008}
2009
src/mess/machine/ut88.c
r6847r6848
139139}
140140
141141static const UINT8 hex_to_7seg[16] =
142   {0x3F, 0x06, 0x5B, 0x4F,
142{
143    0x3F, 0x06, 0x5B, 0x4F,
143144    0x66, 0x6D, 0x7D, 0x07,
144145    0x7F, 0x6F, 0x77, 0x7c,
145    0x39, 0x5e, 0x79, 0x71 };
146    0x39, 0x5e, 0x79, 0x71
147};
146148
147149static TIMER_CALLBACK( update_display )
148150{
src/mess/machine/cybiko.c
r6847r6848
475475      }
476476      break;
477477      // serial dataflash
478      case H8S_IO_PORT3 :  {
478      case H8S_IO_PORT3 :
479      {
479480            const device_config *device = devtag_get_device(space->machine, "flash1");
480481            if (at45dbxx_pin_so(device)) data = data | H8S_P3_RXD1;
481         }
482         break;
482      }
483      break;
483484
484485      // rs232
485486      case H8S_IO_PORT5 : if (cybiko_rs232_pin_rxd()) data = data | H8S_P5_RXD2; break;
src/mess/machine/pp01.c
r6847r6848
207207static UINT8 pp01_key_line = 0;
208208static READ8_DEVICE_HANDLER (pp01_8255_portb_r )
209209{
210   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
211                                 "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF" };
210   static const char *const keynames[] = {
211      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
212      "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF"
213   };
212214
213215   return (input_port_read(device->machine,keynames[pp01_key_line]) & 0x3F) | (input_port_read(device->machine,"LINEALL") & 0xC0);
214216}
src/mess/machine/pecom.c
r6847r6848
8989
9090READ8_HANDLER (pecom_keyboard_r)
9191{
92   static const char *const keynames[] = {    "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
93                              "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
94                              "LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25" };
92   static const char *const keynames[] = {
93      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
94      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15", "LINE16",
95      "LINE17", "LINE18", "LINE19", "LINE20", "LINE21", "LINE22", "LINE23", "LINE24","LINE25"
96   };
9597   /*
9698       INP command BUS -> M(R(X)) BUS -> D
9799       so on each input, address is also set, 8 lower bits are used as input for keyboard
src/mess/machine/ti99_4x.c
r6847r6848
21562156static READ8_DEVICE_HANDLER( ti99_8_R9901_0 )
21572157{
21582158   int answer;
2159   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
2160                              "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" };
2159   static const char *const keynames[] = {
2160      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
2161      "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15"
2162   };
21612163
21622164   if (has_mecmouse && (KeyCol == 15))
21632165   {
r6847r6848
21892191static READ8_DEVICE_HANDLER( ti99_8_R9901_1 )
21902192{
21912193   int answer;
2192   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
2193                              "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" };
2194   static const char *const keynames[] = {
2195      "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7",
2196      "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15"
2197   };
21942198
21952199   if (has_mecmouse && (KeyCol == 15))
21962200   {
src/mess/machine/atarifdc.c
r6847r6848
796796      atari_dsk_construct,
797797      NULL
798798   )
799      { NULL }
800};
799FLOPPY_OPTIONS_END0
801800
802801static const floppy_config atari_floppy_config =
803802{
src/mess/machine/i8257.h
r6847r6848
1/***************************************************************************
2 
3    Intel 8257 Programmable DMA Controller emulation
4 
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7 
8****************************************************************************
9                            _____   _____
10                 _I/OR   1 |*    \_/     | 40  A7
11                 _I/OW   2 |             | 39  A6
12                 _MEMR   3 |             | 38  A5
13                 _MEMW   4 |             | 37  A4
14                  MARK   5 |             | 36  TC
15                 READY   6 |             | 35  A3
16                  HLDA   7 |             | 34  A2
17                 ADSTB   8 |             | 33  A1
18                   AEN   9 |             | 32  A0
19                   HRQ  10 |     8257    | 31  Vcc
20                   _CS  11 |             | 30  D0
21                   CLK  12 |             | 29  D1
22                 RESET  13 |             | 28  D2
23                _DACK2  14 |             | 27  D3
24                _DACK3  15 |             | 26  D4
25                  DRQ3  16 |             | 25  _DACK0
26                  DRQ2  17 |             | 24  _DACK1
27                  DRQ1  18 |             | 23  D5
28                  DRQ0  19 |             | 22  D6
29                   GND  20 |_____________| 21  D7
30 
31***************************************************************************/
32 
33#ifndef __I8257__
34#define __I8257__
35 
36#include "devcb.h"
37 
38/***************************************************************************
39    MACROS / CONSTANTS
40***************************************************************************/
41 
42#define I8257 DEVICE_GET_INFO_NAME(i8257)
43 
44#define MDRV_I8257_ADD(_tag, _clock, _config) \
45   MDRV_DEVICE_ADD(_tag, I8257, _clock) \
46   MDRV_DEVICE_CONFIG(_config)
47 
48#define I8257_INTERFACE(_name) \
49   const i8257_interface (_name) =
50 
51#define I8257_MEMORY_HANDLER(_tag, _space, _func) \
52   { DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
53     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
54     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
55     DEVCB_MEMORY_HANDLER(_tag, _space, _func) }
56 
57#define I8257_CHANNELS   4
58 
59/***************************************************************************
60    TYPE DEFINITIONS
61***************************************************************************/
62 
63typedef struct _i8257_interface i8257_interface;
64struct _i8257_interface
65{
66   devcb_write_line   out_hrq_func;
67   devcb_write_line   out_tc_func;
68   devcb_write_line   out_mark_func;
69 
70   /* memory */
71   devcb_read8         in_memr_func[I8257_CHANNELS];
72   devcb_write8      out_memw_func[I8257_CHANNELS];
73 
74   /* I/O */
75   devcb_read8         in_ior_func[I8257_CHANNELS];
76   devcb_write8      out_iow_func[I8257_CHANNELS];
77 
78   /* DMA acknowledge */
79   devcb_write_line   out_dack_func[I8257_CHANNELS];
80};
81 
82/***************************************************************************
83    PROTOTYPES
84***************************************************************************/
85 
86/* register access */
87READ8_DEVICE_HANDLER( i8257_r );
88WRITE8_DEVICE_HANDLER( i8257_w );
89 
90/* hold acknowledge */
91WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w );
92 
93/* ready */
94WRITE_LINE_DEVICE_HANDLER( i8257_ready_w );
95 
96/* data request */
97WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w );
98WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w );
99WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w );
100WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w );
101 
102DEVICE_GET_INFO( i8257 );
103 
104#endif
1/***************************************************************************
2
3    Intel 8257 Programmable DMA Controller emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8****************************************************************************
9                            _____   _____
10                 _I/OR   1 |*    \_/     | 40  A7
11                 _I/OW   2 |             | 39  A6
12                 _MEMR   3 |             | 38  A5
13                 _MEMW   4 |             | 37  A4
14                  MARK   5 |             | 36  TC
15                 READY   6 |             | 35  A3
16                  HLDA   7 |             | 34  A2
17                 ADSTB   8 |             | 33  A1
18                   AEN   9 |             | 32  A0
19                   HRQ  10 |     8257    | 31  Vcc
20                   _CS  11 |             | 30  D0
21                   CLK  12 |             | 29  D1
22                 RESET  13 |             | 28  D2
23                _DACK2  14 |             | 27  D3
24                _DACK3  15 |             | 26  D4
25                  DRQ3  16 |             | 25  _DACK0
26                  DRQ2  17 |             | 24  _DACK1
27                  DRQ1  18 |             | 23  D5
28                  DRQ0  19 |             | 22  D6
29                   GND  20 |_____________| 21  D7
30
31***************************************************************************/
32
33#ifndef __I8257__
34#define __I8257__
35
36#include "devcb.h"
37
38/***************************************************************************
39    MACROS / CONSTANTS
40***************************************************************************/
41
42#define I8257 DEVICE_GET_INFO_NAME(i8257)
43
44#define MDRV_I8257_ADD(_tag, _clock, _config) \
45   MDRV_DEVICE_ADD(_tag, I8257, _clock) \
46   MDRV_DEVICE_CONFIG(_config)
47
48#define I8257_INTERFACE(_name) \
49   const i8257_interface (_name) =
50
51#define I8257_MEMORY_HANDLER(_tag, _space, _func) \
52   { DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
53     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
54     DEVCB_MEMORY_HANDLER(_tag, _space, _func), \
55     DEVCB_MEMORY_HANDLER(_tag, _space, _func) \
56   }
57
58#define I8257_CHANNELS   4
59
60/***************************************************************************
61    TYPE DEFINITIONS
62***************************************************************************/
63
64typedef struct _i8257_interface i8257_interface;
65struct _i8257_interface
66{
67   devcb_write_line   out_hrq_func;
68   devcb_write_line   out_tc_func;
69   devcb_write_line   out_mark_func;
70
71   /* memory */
72   devcb_read8         in_memr_func[I8257_CHANNELS];
73   devcb_write8      out_memw_func[I8257_CHANNELS];
74
75   /* I/O */
76   devcb_read8         in_ior_func[I8257_CHANNELS];
77   devcb_write8      out_iow_func[I8257_CHANNELS];
78
79   /* DMA acknowledge */
80   devcb_write_line   out_dack_func[I8257_CHANNELS];
81};
82
83/***************************************************************************
84    PROTOTYPES
85***************************************************************************/
86
87/* register access */
88READ8_DEVICE_HANDLER( i8257_r );
89WRITE8_DEVICE_HANDLER( i8257_w );
90
91/* hold acknowledge */
92WRITE_LINE_DEVICE_HANDLER( i8257_hlda_w );
93
94/* ready */
95WRITE_LINE_DEVICE_HANDLER( i8257_ready_w );
96
97/* data request */
98WRITE_LINE_DEVICE_HANDLER( i8257_drq0_w );
99WRITE_LINE_DEVICE_HANDLER( i8257_drq1_w );
100WRITE_LINE_DEVICE_HANDLER( i8257_drq2_w );
101WRITE_LINE_DEVICE_HANDLER( i8257_drq3_w );
102
103DEVICE_GET_INFO( i8257 );
104
105#endif
src/mess/machine/pk8020.c
r6847r6848
3434
3535static READ8_HANDLER(keyboard_r)
3636{
37   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
38                                 "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15" };
37   static const char *const keynames[] = {
38      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
39      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15"
40   };
3941   UINT8 retVal=0x00;
4042   UINT8 line = 0;
4143   if (offset & 0x100)  line=8;
src/mess/machine/bbc.c
r6847r6848
809809
810810INTERRUPT_GEN( bbcb_keyscan )
811811{
812   static const char *const colnames[] = { "COL0", "COL1", "COL2", "COL3", "COL4",
813                              "COL5", "COL6", "COL7", "COL8", "COL9" };
812   static const char *const colnames[] = {
813      "COL0", "COL1", "COL2", "COL3", "COL4",
814      "COL5", "COL6", "COL7", "COL8", "COL9"
815   };
814816   const device_config *via_0 = devtag_get_device(device->machine, "via6522_0");
815817
816818     /* only do auto scan if keyboard is not enabled */
r6847r6848
845847
846848INTERRUPT_GEN( bbcm_keyscan )
847849{
848   static const char *const colnames[] = { "COL0", "COL1", "COL2", "COL3", "COL4",
849                              "COL5", "COL6", "COL7", "COL8", "COL9" };
850   static const char *const colnames[] = {
851      "COL0", "COL1", "COL2", "COL3", "COL4",
852      "COL5", "COL6", "COL7", "COL8", "COL9"
853   };
850854   const device_config *via_0 = devtag_get_device(device->machine, "via6522_0");
851855
852856     /* only do auto scan if keyboard is not enabled */
r6847r6848
859863
860864      /* this IF should be removed as soon as the dip switches (keyboard keys) are set for the master */
861865      if (column < 10)
862         {
866      {
863867         /* KBD IC4 8 input NAND gate */
864868         /* set the value of via_system ca2, by checking for any keys
865869                 being pressed on the selected column */
r6847r6848
887891   int bit;
888892   int row;
889893   int res;
890   static const char *const colnames[] = { "COL0", "COL1", "COL2", "COL3", "COL4",
891                              "COL5", "COL6", "COL7", "COL8", "COL9" };
894   static const char *const colnames[] = {
895      "COL0", "COL1", "COL2", "COL3", "COL4",
896      "COL5", "COL6", "COL7", "COL8", "COL9"
897   };
892898   const device_config *via_0 = devtag_get_device(space->machine, "via6522_0");
893899
894900   column = data & 0x0f;
src/mess/formats/uef_cas.c
r6847r6848
228228   int pos;
229229   INT16 *p = buffer;
230230
231        if ( bytes[0] == 0x1f && bytes[1] == 0x8b ) {
231   if ( bytes[0] == 0x1f && bytes[1] == 0x8b ) {
232232      if ( gz_ptr == NULL ) {
233233         return 1;
234234      }
src/mess/formats/ami_dsk.c
r6847r6848
105105      TRACKS([80])
106106      SECTORS([11]/22)
107107   )
108      { NULL }
109};
108FLOPPY_OPTIONS_END0
src/mess/formats/nes_dsk.c
r6847r6848
6262      nes_dsk_construct,
6363      NULL
6464   )
65      { NULL }
66};
65FLOPPY_OPTIONS_END0
src/mess/formats/flopimg.h
r6847r6848
102102   const struct FloppyFormat floppyoptions_##name[] =                        \
103103   {                                                         \
104104
105#define FLOPPY_OPTIONS_END0 \
106      { NULL }                     \
107   };
105108
106109#define FLOPPY_OPTIONS_EXTERN(name)                                    \
107110   extern const struct FloppyFormat floppyoptions_##name[]                     \
r6847r6848
115118      FLOPPY_OPTION( cqm, "cqm,dsk", "CopyQM floppy disk image",   cqm_dsk_identify, cqm_dsk_construct, NULL) \
116119      FLOPPY_OPTION( dsk, "dsk", "DSK floppy disk image",   dsk_dsk_identify, dsk_dsk_construct, NULL) \
117120      FLOPPY_OPTION( d88, "d77,d88",   "D88 Floppy Disk image", d88_dsk_identify, d88_dsk_construct, NULL)\
118      { NULL }                     \
119   };
121   FLOPPY_OPTIONS_END0
120122
121123FLOPPY_OPTIONS_EXTERN(default);
122124
src/mess/formats/td0_dsk.c
r6847r6848
621621                    tdctl.bufpos = (tdctl.r - pos - 1) & (N - 1);
622622                    tdctl.bufcnt = c - 255 + THRESHOLD;
623623                    tdctl.bufndx = 0;
624                }
624                }
625625            }
626626            else { // still chars from last string
627627                while( tdctl.bufndx < tdctl.bufcnt && count < len ) {
r6847r6848
635635                // reset bufcnt after copy string from text_buf[]
636636                if(tdctl.bufndx >= tdctl.bufcnt)
637637                    tdctl.bufndx = tdctl.bufcnt = 0;
638        }
638            }
639639    }
640640    return(count); // count == len, success
641641}
src/mess/formats/ti85_ser.c
r6847r6848
179179         free (ti85serial->receive_buffer);
180180         ti85serial->receive_buffer = NULL;
181181         return 0;
182           }
182      }
183183   }
184184   return 1;
185185}
src/mess/formats/zx81_p.c
r6847r6848
146146           0x00, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, /*60h-67h*/
147147           0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, /*68h-6fh*/
148148           0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, /*70h-77h*/
149           0x3d, 0x3e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, /*78h-7fh*/};
149           0x3d, 0x3e, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, /*78h-7fh*/
150};
150151
151152static void zx81_fill_file_name(const char* name)
152153{
src/mess/formats/oric_tap.c
r6847r6848
453453               for (i=0; i<100; i++)
454454               {
455455                                            p = oric_output_bit(p,1);
456                                        }
456               }
457457
458458               oric_cassette_state = ORIC_CASSETTE_WRITE_DATA;
459459               oric_data_count = 0;
src/mess/drivers/jaguar.c
r6847r6848
334334   UINT16 joybuts_result = 0xffef;
335335   int i;
336336   static const char *const keynames[2][8] =
337         {
338            { "JOY0", "JOY1", "JOY2", "JOY3",
339                  "JOY4", "JOY5", "JOY6", "JOY7" },
340            { "BUTTONS0", "BUTTONS1", "BUTTONS2", "BUTTONS3",
341                  "BUTTONS4", "BUTTONS5", "BUTTONS6", "BUTTONS7" }
342         };
337   {
338      { "JOY0", "JOY1", "JOY2", "JOY3", "JOY4", "JOY5", "JOY6", "JOY7" },
339      { "BUTTONS0", "BUTTONS1", "BUTTONS2", "BUTTONS3", "BUTTONS4", "BUTTONS5", "BUTTONS6", "BUTTONS7" }
340   };
343341
344342   /*
345343     *   16        12        8         4         0
src/mess/drivers/spc1000.c
r6847r6848
6363}
6464
6565static READ8_HANDLER(spc1000_keyboard_r) {
66   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3",
67                                 "LINE4", "LINE5", "LINE6", "LINE7",
68                                 "LINE8", "LINE9" };
66   static const char *const keynames[] = {
67      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4",
68      "LINE5", "LINE6", "LINE7", "LINE8", "LINE9"
69   };
6970   return input_port_read(space->machine, keynames[offset]);
7071}
7172
src/mess/drivers/ip22.c
r6847r6848
14661466
14671467static const SCSIConfigTable dev_table =
14681468{
1469        2,                                      /* 1 SCSI device */
1470        { { SCSI_ID_1, "harddisk1", SCSI_DEVICE_HARDDISK },
1471          { SCSI_ID_4, "cdrom", SCSI_DEVICE_CDROM } }  /* SCSI ID 4, using CD 0, and it's a CD-ROM */
1469   2,                                      /* 1 SCSI device */
1470   {
1471      { SCSI_ID_1, "harddisk1", SCSI_DEVICE_HARDDISK },
1472      { SCSI_ID_4, "cdrom", SCSI_DEVICE_CDROM }  /* SCSI ID 4, using CD 0, and it's a CD-ROM */
1473   }
14721474};
14731475
14741476static const struct WD33C93interface scsi_intf =
src/mess/drivers/c128.c
r6847r6848
219219   AM_RANGE(0xc000, 0xffff) AM_RAM
220220#else
221221   /* best to do reuse bankswitching numbers */
222   AM_RANGE(0x0000, 0x03ff) AM_READ_BANK("bank10") AM_WRITE_BANK(1))
223   AM_RANGE(0x0400, 0x0fff) AM_READ_BANK("bank11") AM_WRITE_BANK(2))
222   AM_RANGE(0x0000, 0x03ff) AM_READ_BANK("bank10") AM_WRITE_BANK("bank1")
223   AM_RANGE(0x0400, 0x0fff) AM_READ_BANK("bank11") AM_WRITE_BANK("bank2")
224224   AM_RANGE(0x1000, 0x1fff) AM_RAMBANK("bank3")
225225   AM_RANGE(0x2000, 0x3fff) AM_RAMBANK("bank4")
226226   AM_RANGE(0x4000, 0xbfff) AM_RAMBANK("bank5")
src/mess/drivers/a2600.c
r6847r6848
174174                           { 0x43, 0x58, 0x2d, 0x32, 10}, // Missile Command CX22 TrackBall
175175                           { 0x43, 0x58, 0x2d, 0x38, 11}, // Missile Command CX80 TrackBall
176176                           { 0x4e, 0xa8, 0xa4, 0xa2, 12}, // Omega Race for Joystick ONLY
177                           { 0xa6, 0xef, 0xb5, 0x38, 8}}; // Warlords.. paddles ONLY
177                           { 0xa6, 0xef, 0xb5, 0x38, 8} // Warlords.. paddles ONLY
178   };
178179   // start with this.. if anyone finds a game that does NOT work with both controllers enabled
179180   // it can be fixed here with a new signature (note that the Coleco Gemini has this setup also)
180181   left = JOYS+PADD; right = JOYS+PADD;
r6847r6848
297298                           { 0x20, 0x00, 0xd0, 0xc6, 0xc5 },
298299                           { 0x20, 0xc3, 0xf8, 0xa5, 0x82 },
299300                           { 0xd0, 0xfb, 0x20, 0x73, 0xfe },
300                           { 0x20, 0x00, 0xf0, 0x84, 0xd6 }};
301                           { 0x20, 0x00, 0xf0, 0x84, 0xd6 }
302   };
301303   if (cart_size == 0x2000)
302304   {
303305      UINT8 *cart = CART;
r6847r6848
325327                           { 0x8d, 0xe9, 0xff },
326328                           { 0xad, 0xe9, 0xff },
327329                           { 0xad, 0xed, 0xff },
328                           { 0xad, 0xf3, 0xbf }};
330                           { 0xad, 0xf3, 0xbf }
331   };
329332   if (cart_size == 0x2000)
330333   {
331334      UINT8 *cart = CART;
r6847r6848
349352   int i,j,numfound = 0;
350353   static const unsigned char signatures[][3] = {
351354                           { 0x9d, 0xff, 0xf3 },
352                           { 0x99, 0x00, 0xf4 }};
355                           { 0x99, 0x00, 0xf4 }
356   };
353357   if (cart_size == 0x0800 || cart_size == 0x1000)
354358   {
355359      UINT8 *cart = CART;
r6847r6848
372376{
373377   int i,j,numfound = 0;
374378   static const unsigned char signatures[][3] = {
375                           { 0x2c, 0xd0, 0xff }};
379                           { 0x2c, 0xd0, 0xff }
380   };
376381   if (cart_size == 0x2000)
377382   {
378383      UINT8 *cart = CART;
r6847r6848
397402   int i,j,numfound = 0;
398403   static const unsigned char signatures[][4] = {
399404                           { 0x2c, 0xc0, 0xef, 0x60 },
400                           { 0x8d, 0xa0, 0x0f, 0xf0 }};
405                           { 0x8d, 0xa0, 0x0f, 0xf0 }
406   };
401407   if (cart_size == 0x4000 || cart_size == 0x2000)
402408   {
403409      UINT8 *cart = CART;
r6847r6848
421427   int i,j,numfound = 0;
422428   static const unsigned char signatures[][3] = {
423429                           { 0xad, 0xe5, 0xff },
424                           { 0x8d, 0xe7, 0xff }};
430                           { 0x8d, 0xe7, 0xff }
431   };
425432   if (cart_size == 0x2000 || cart_size == 0x4000)
426433   {
427434      UINT8 *cart = CART;
r6847r6848
509516   UINT8 *cart = CART;
510517   static const unsigned char signatures[][5] = {
511518                           { 0xa2, 0x7f, 0x9d, 0x00, 0xf0 }, // dig dug
512                           { 0xae, 0xf6, 0xff, 0x4c, 0x00 }}; // off the wall
519                           { 0xae, 0xf6, 0xff, 0x4c, 0x00 } // off the wall
520   };
513521
514522   if (cart_size == 0x4000)
515523   {
src/mess/drivers/pcw.c
r6847r6848
222222/* PCW keyboard is mapped into memory */
223223static  READ8_HANDLER(pcw_keyboard_r)
224224{
225   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
226                              "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15" };
225   static const char *const keynames[] = {
226      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
227      "LINE8", "LINE9", "LINE10", "LINE11", "LINE12", "LINE13", "LINE14", "LINE15"
228   };
227229
228230   return input_port_read(space->machine, keynames[offset]);
229231}
src/mess/drivers/mk14.c
r6847r6848
2727
2828*/
2929static const char *const keynames[] = {
30                     "LINE0", "LINE1", "LINE2", "LINE3",
31                     "LINE4", "LINE5", "LINE6", "LINE7"};
30   "LINE0", "LINE1", "LINE2", "LINE3",
31   "LINE4", "LINE5", "LINE6", "LINE7"
32};
3233
3334static READ8_HANDLER(keyboard_r)
3435{
src/mess/drivers/tvc.c
r6847r6848
9595
9696static READ8_HANDLER( tvc_keyboard_r )
9797{
98   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
99                                 "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF"};
98   static const char *const keynames[] = {
99      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7",
100      "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF"
101   };
100102   return input_port_read(space->machine, keynames[tvc_keyline & 0x0f]);
101103}
102104
src/mess/drivers/gmaster.c
r6847r6848
6060   {
6161      memory_region(space->machine, "maincpu")[0x4000 + offset] = data;
6262      logerror("%.4x external memory %.4x written %.2x\n", (int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000 + offset, data);
63    }
63   }
6464   else
6565   {
6666      switch (offset)
r6847r6848
110110         break;
111111      default:
112112         logerror("%.4x memory %.4x written %.2x\n", (int)cpu_get_reg(space->cpu, CPUINFO_INT_PC), 0x4000 + offset, data);
113      }
113114   }
114    }
115115}
116116
117117static READ8_HANDLER( gmaster_port_r )
src/mess/drivers/newbrain.c
r6847r6848
506506
507507   newbrain_state *state = space->machine->driver_data;
508508
509   static const char *const keynames[] = { "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
510                              "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15" };
509   static const char *const keynames[] = {
510      "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
511      "D8", "D9", "D10", "D11", "D12", "D13", "D14", "D15"
512   };
511513
512514   /* keyboard row reset */
513515
src/mess/drivers/vtech1.c
r6847r6848
264264
265265   if (start_address == 0x7ae9)
266266   {
267      UINT8 i, data[]={
267      UINT8 i;
268      static const UINT8 data[]={
268269         0xe5,         // PUSH HL  ;save pcode pointer
269270         0x2a, 0x1c, 0x79,   // LD HL,(791C) ;get saved end_addr+1
270271         0x22, 0xf9, 0x78,   // LD (78F9),HL ;move it to correct place
271272         0x21, 0x39, 0x78,   // LD HL,7839   ;point to control flag
272273         0xcb, 0xf6,      // SET 6,(HL)   ;turn on autorun (cb b6 = manual run)
273274         0xcb, 0x9e,      // RES 3,(HL)   ;turn off verify (just in case)
274         0xc3, 0xcf, 0x36,};   // JP 36CF  ;enter bios at autorun point
275         0xc3, 0xcf, 0x36   // JP 36CF  ;enter bios at autorun point
276      };
275277
276278      for (i = 0; i < ARRAY_LENGTH(data); i++)
277279         memory_write_byte(space, 0x791e + i, data[i]);
r6847r6848
503505      vtech1_dsk_construct,
504506      NULL
505507   )
506      { NULL }
507};
508FLOPPY_OPTIONS_END0
508509
509510static const floppy_config vtech1_floppy_config =
510511{
src/mess/drivers/nc.c
r6847r6848
664664
665665static READ8_HANDLER(nc_key_data_in_r)
666666{
667   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4",
668                              "LINE5", "LINE6", "LINE7", "LINE8", "LINE9" };
667   static const char *const keynames[] = {
668      "LINE0", "LINE1", "LINE2", "LINE3", "LINE4",
669      "LINE5", "LINE6", "LINE7", "LINE8", "LINE9"
670   };
669671
670672   if (offset==9)
671673   {
src/mess/drivers/vt100.c
r6847r6848
6060static TIMER_CALLBACK(keyboard_callback)
6161{
6262   int i;
63   static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3",
64                                 "LINE4", "LINE5", "LINE6", "LINE7",
65                                 "LINE8", "LINE9", "LINEA", "LINEB",
66                                 "LINEC", "LINED", "LINEE", "LINEF" };
63   static const char *const keynames[] = {
64      "LINE0", "LINE1", "LINE2", "LINE3",
65      "LINE4", "LINE5", "LINE6", "LINE7",
66      "LINE8", "LINE9", "LINEA", "LINEB",
67      "LINEC", "LINED", "LINEE", "LINEF"
68   };
6769   UINT8 code;
6870   if (vt100_key_scan == 1) {
6971      for(i = 0; i < 16; i++)
r6847r6848
100102}
101103static WRITE8_HANDLER(vt100_baud_rate_w)
102104{
103   double baud_rate[] = { 50, 75, 110, 134.5, 150, 200, 300, 600, 1200,
104      1800, 2000, 2400, 3600, 4800, 9600, 19200 };
105   static const double baud_rate[] = {
106      50, 75, 110, 134.5, 150, 200, 300, 600, 1200,
107      1800, 2000, 2400, 3600, 4800, 9600, 19200
108   };
105109
106110   vt100_send_baud_rate = baud_rate[(data >>4) & 0x0f];
107111   vt100_recv_baud_rate = baud_rate[data & 0x0f];
src/mess/drivers/specpls3.c
r6847r6848
288288         memory_set_bankptr(machine, "bank4", ram_data);
289289
290290         logerror("extended memory paging: %02x\n", MemorySelection);
291      }
291   }
292292}
293293
294294
src/mess/drivers/socrates.c
r6847r6848
465465
466466static rgb_t socrates_create_color(UINT8 color)
467467{
468rgb_t composedcolor;
469double lumatable[256] = {
468  rgb_t composedcolor;
469  double lumatable[256] = {
470470    LUMA_COL_0
471471    LUMA_COL_COMMON
472472    LUMA_COL_2
r6847r6848
484484    LUMA_COL_COMMON
485485    LUMA_COL_F
486486  };
487double chromaintensity[256] = {
487  double chromaintensity[256] = {
488488  0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
489489    CHROMA_COL_COMMON
490490    CHROMA_COL_2
src/mess/drivers/jr200.c
r6847r6848
2121
2222static UINT8 *textram;
2323static UINT8 *border;
24static UINT8 io_reg[0x20] = {    0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
25                  0, 0, 0, 0, 0, 0, 0, 0, 0, 0   };
24static UINT8 io_reg[0x20] = {
25   0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
26   0, 0, 0, 0, 0, 0, 0, 0, 0, 0
27};
2628
2729static const UINT8 jr200_keycodes[4][9][8] =
2830{
src/mess/drivers/saturn.c
r6847r6848
23032303   { 0, 1, 2, 3 },
23042304   { 0, 4, 8, 12, 16, 20, 24, 28,
23052305     32*8+0, 32*8+4, 32*8+8, 32*8+12, 32*8+16, 32*8+20, 32*8+24, 32*8+28,
2306
2307     },
2306   },
23082307   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
23092308     32*16, 32*17,32*18, 32*19,32*20,32*21,32*22,32*23
2310
2311     },
2309   },
23122310   32*32
23132311};
23142312
src/mess/drivers/genesis.c
r6847r6848
9090/* They're needed to give the users the choice between different controllers */
9191static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
9292{
93   static const char *const pad6names[2][4] = {{ "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" },
94                                    { "EXTRA1", "EXTRA2", "UNUSED", "UNUSED" }};
93   static const char *const pad6names[2][4] = {
94      { "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" },
95      { "EXTRA1", "EXTRA2", "UNUSED", "UNUSED" }
96   };
9597   static const char *const pad3names[4] = { "PAD1_3B", "PAD2_3B", "UNUSED", "UNUSED" };
9698
9799   UINT8 retdata;
src/mess/drivers/pce.c
r6847r6848
144144static void pce_partialhash(char *dest, const unsigned char *data,
145145        unsigned long length, unsigned int functions)
146146{
147        if ( ( length <= PCE_HEADER_SIZE ) || ( length & PCE_HEADER_SIZE ) ) {
147   if ( ( length <= PCE_HEADER_SIZE ) || ( length & PCE_HEADER_SIZE ) ) {
148148           hash_compute(dest, &data[PCE_HEADER_SIZE], length - PCE_HEADER_SIZE, functions);
149149   } else {
150150      hash_compute(dest, data, length, functions);
docs/messnew.txt
r6847r6848
131131  update to this core.  [MAME team]
132132
133133- Cleanups (static qualifiers, headers, renames, reduced global symbols, dead
134  code cleanups and more multisession friendly init code).  [Atari Ace]
134  code cleanups, brace cleanups, and more multisession friendly init code).
135  [Atari Ace]
135136
136137- WD17xx write track supported in proper way instead of using more
137138  sector writes [Michael Zapf]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team